Encyclopaedia Index

WORKSHOP - CAD Import: Importing and Repairing STL Files


The aim of this tutorial is to show:

The tutorial is in several stages. The first stage imports a single STL file for a complex building geometry. There is an obvious error in the imported file. In the second stage, this error is repaired, but the geometry is still not detected correctly. In the final stage, the single STL is replaced by individual STL files for the various elements of the geometry. The final stage forms a separate tutorial.

The full geometry of the case is shown in Figure 1 below.


Figure 1. The geometry of the CAD import example

The CFD solution is not of interest for this tutorial.

A complete step-by-step guide, showing how to set the case from the default mode of operation, is provided below.

Accessing PHOENICS-VR.

From the system level:

To enter the PHOENICS-VR environment, click on the PHOENICS icon on the desktop, or click on Start, programs, PHOENICS, PHOENICS.

From the commander level:

To enter the PHOENICS-VR environment, click on the 'Run vre' icon in the left column.


In PHOENICS-VR environment,


Start with an 'empty' case - click on 'File' then on 'Start New Case', then on 'Core'', then click on 'OK'; to confirm the resetting.


To enter VR Editor:


This is the default mode of operation.

Within VR Editor.

Import the STL file

Click on on the VR-Editor panel (or the O icon on the tool bar) to bring up the Object Management Dialog; and then on 'Object', 'New', 'New object'.

Click on the 'Shape' tab, then on 'CAD file'.

In the file browser, browse to \phoenics\d_polis\d_wkshp\cadimprt, and select the file complete.stl. Click 'Open'.

On the Import STL Data dialog that opens, click OK to accept the setting that the converted geometry file is to be placed in the current working directory. (If this were a common geometry that was to be used in many projects, it would be better to place it in the central store so that it was easily accessible). The following dialog should appear:

Change the 'No' next to 'Take size from CAD file' to 'Yes'.

In the STL file, the co-ordinates are given in millimetres, but we want to work in metres. Enter 0.001 in the 'Geometry scaling factor' entry box. Click OK. The converted geometry file will now be read in. The size of the new object will be set to 858m * 693m * 234m, at 0.0, 0.0, 0.0.

Click OK to close the Object specification dialog.

On the toolbar, click the down arrow next to and select 'Fit to window'. The screen should look like this:

Checking for Obvious Errors

Click on 'Domain' in the Object management Dialog, or click on the image background to release the highlighted object. Click 'Settings', 'Near Plane', 'Reset' to ensure the image appears correctly.

Using the mouse, rotate, pan and zoom the image to inspect the geometry. Details of the mouse operation are given in TR/326, VR-Editor Hand-Set, Mouse Control. You should be able to find this peculiarity:

The dark building to the left of the wheel appears inside out from whatever angle it is viewed from.

To help diagnose the problem, click 'View', 'Show backs of objects'. This tells VR-Editor to draw both sides of each facet, not just those facing outwards. The image should change to:

The inside-out part now looks correct. This is a good indication that the facets of the affected region are pointing in the wrong direction.

Repairing the error

The utility program FacetFix can be used to repair many common errors in geometry files. To start FacetFix, click 'Run', 'Utilities', 'FacetFix'. The FacetFix GUI should appear:

image001.gif (7187 bytes)

Click 'Browse for input', change file type from STL to DAT, select complete.dat and click 'Open'. Click 'Run FacetFix'. After a short while the FacetFix dialog will close, indicating that the repair is finished.

To open the corrected geometry file, double-click on the buildings in the main graphics window. This will open the Object specification dialog. Go to the 'Shape' page. Click 'complete' next to 'Geometry'. In the file browser, browse to the current working director (by default \phoenics\d_priv1). Check that 'Files of type' is set to 'All files (*.*)'. Select 'complete_0.dat and click 'Open'. On the next Geometry Import dialog just click OK, as we are only replacing the geometry for the existing object. Click 'OK' to close the Object Specification dialog.

The screen should now look like:

This should now not change when 'View', 'Show backs of objects' is turned on and off, indicating that all the facts do indeed point outwards. The colours in the image have been introduced by FacetFix. It has used a different colour for each closed volume it has found in the original data set.

Checking for Detection Problems

Having imported the geometry, it is worth checking to see if it will be detected properly by the Earth solver. Do do this, we need to set a mesh and perform 2 or 3 sweeps (iterations).

Click on the Mesh toggle on the hand-set or toolbar, then click on the image to bring up the Grid mesh Settings dialog. Toggle all three directions from Auto to Manual. Set the Number of cells to 100 for X and Y, and 50 for Z. Click OK to close the dialog, and on the Mesh toggle to turn off the mesh display.

Click on on the hand-set or M on the toolbar to bring up the main Menu. Go to the Numerics page. Change the 'Total number of iterations' to 2, then Top Menu, OK to close the Main Menu.

Click 'Run' 'Solver' to make the Earth run.

Once the Solver run has finished, enter the VR-Viewer to examine the solution (Click 'Run' - 'Post processor' ,'GUI ').

In the Viewer, switch the plotting plane to Z (click Z on the handset or toolbar), and select the property-marker variable PRPS by clicking the icon on the hand-set or toolbar, then selecting PRPS from the list of variables. Switch the contours on by ticking 'Show contours' on the Viewer Options dialog, or by clicking on the hand-set or toolbar. The PRPS contours should be blue in the airspace, and red inside the buildings.

To see inside the buildings, go to wireframe mode by clicking on the hand-set or toolbar.

Moving the probe up to around 75m, we can see that the tower blocks are either detected poorly, or else not detected at all.

Why is this?

Further Error Checking

Careful inspection of the tower blocks shows that they do not sit on top of the podiums, they penetrate through them:

Although the solver can cope with interpenetrating objects, it can really only do so effectively when the interpenetrating parts come from separate objects. It cannot do so when they are part of the same object.

The solution to this problem is to go back to the CAD program and export the towers and podiums as separate STL files, the reassemble them in PHOENICS.

Importing multiple CAD files forms the topic of the next tutorial.

Saving the results.

In the PHOENICS-VR environment, click on 'Save as a case', make a new folder called 'CAD', select the new folder, and save as 'STAGE_1'.