Meshlab

MeshLab (http://www.meshlab.net/) is a free tool that can be installed and used on a Mikado controller. MeshLab can be used to view and edit mesh-based CAD files such as the STL file format. The following tutorials explain CAD editing options that enable optimum results in object recognition.

Of course, you can also use a tool of your choice to implement the modifications to your CAD model.

Basics: Loading and saving STL

Screenshot MeshLab GUI

MeshLab GUI

  • Open MeshLab and load the desired product

    • Main menu → File → Import Mesh…

    • Select the desired file (e.g. in the mikado/cells/<cell name>/meshes/<file name>.stl directory)

    • Confirm “Post-Open Processing” message with OK

  • Export STL file:

    • File → Export Mesh As…

    • Enter new file name

    • Select STL as format → Save

Hint

Save modified CAD files under a new name so that you can restore old versions at any time.

Center product coordinate system

  • Display product coordinate system

    • Render → Show axis

Show screenshot of coordinate system

MeshLab: Display coordinate system

  • Center coordinate system

    • Filters → Normals, Curvatures and Orientation → Transform: Move, Translate, Center

    • “translate center of bbox to the origin”

    • Apply

Screenshot MeshLab Transform coordinate system

MeshLab: Transform coordinate system

Screenshot MeshLab coordinate system centered

MeshLab: Coordinate system centered

Hint

  • The coordinate system can also be moved and rotated manually using the “Transform” filter. If the STL is in a unit other than millimetres, this can also be converted here using the “Transform: Scale” filter (see Scale STL).

  • A preview is possible for most filters by activating the “Preview” option.

Scale STL

If you want to change the size of your CAD or change the unit, you can scale the STL using Meshlab.

Screenshot of MeshLab filter for scaling

MeshLab: Filter for scaling

  • Activate “Uniform scaling”

  • Activate “Preview” so that changes are displayed immediately

  • Adjust the factor for “X axis” (1.0 → 100%, 0.01 → 1%). For example, if you want to convert a CAD that was defined in meters to millimeters, select the value 1000.0

  • Apply

Screenshot of MeshLab filter for scaling - settings

MeshLab: Filter for scaling - Settings

Screenshot MeshLab Scaled STL

MeshLab: Scaled STL

STL Reduce number of triangles

The number of triangles of a product influences the loading time of a product and in particular the collision checks during path planning. It is recommended to reduce the number of triangles until important product features and structures are still recognizable.

  • The current number of triangles is shown in the status display at the bottom

  • Hauptmenü → Filters → Remeshing, Simplification and Reconstruction → Quadric Edge Collapse Decimation

Screenshot of MeshLab decimation filter

MeshLab: Decimation filter

  • Specify the desired number of triangles → Apply

    • Before applying a different parameterization, first reload the model (“Reload” button: meshlab_reload_button)

Screenshot MeshLab Decimated model of the T-piece

MeshLab: Decimated model of the T-piece

Remove STL surfaces

Many CAD design data contain some surfaces and structures that are never visible from a camera view. These include internal structures or, depending on the application, the underside of a product. This property can also be used to reduce the CAD for symmetrical parts. A sphere, for example, is always visible from a single camera as a hemisphere at most. In this case, the lower half of a sphere can be removed for an object search. This increases the maximum score that can be achieved. This leads to more stable and faster object position detection.

Sphere CAD
Hemisphere CAD

Example: For object matching of a sphere, a hemisphere leads to higher scores. However, the collision model must still represent the complete product.

Hint

The Product management chapter describes how different CADs can be set up for object searches and collision checks.

The following steps describe how the number of triangles can be decimated.

  1. Load product (see Basics: Loading and saving STL)

  2. Select areas (marked areas are colored red)

    1. Option 1: Rectangle selection
      Select faces in a rectangular region (“Select Faces in a rectangular region”)
      • Select selection symbol

      • Select the area of the CAD with the mouse button held down. All triangles that project into the area are added to the selection.

      Hint

      Notes on rectangle selection:

      • If you hold down the “Ctrl” key, the selected area is added to the existing selection

      • If you hold down the “Shift” key, the selected area is removed from the existing selection

      • The “ESC” button can be used to switch between selection and camera mode

      • To exit the selection mode, click on the selected symbol again

      Screenshot of MeshLab rectangle selection

      MeshLab: Rectangle selection

    2. Option 2: Brush tool
      Select areas with the brush tool (“Z-Painting”)
      • Click on the brush symbol

      • Select marking brush (red brush)

      • “Brush” areas with the mouse

      Hint

      Notes on the brush tool:

      • Left mouse button adds areas to the selection

      • Right mouse button removes the selection areas

      • Brush type and size can be set using the brush options

      • The “ESC” button can be used to switch between brush and camera mode

      • To exit the selection mode, click on the selected symbol again

      Screenshot of MeshLab brush selection

      MeshLab: Brush selection

  3. Remove areas

    1. Method 1:
      Remove structures selected on the product (Remove selected areas)
      • Selektierte Dreiecke entfernen (“Delete the current set of selected faces and all the vertices surrounded by that faces.”)

      Screenshot MeshLab selected triangles removed

      MeshLab: Selected triangles removed

    2. Method 2:
      Select what is visible to the camera on the product (remove all areas that are not part of the selection)
      • This method is used to select what is visible to the camera on the product (remove all areas that do not belong to the selection)

      • Invert selection

        • Filters → Selection → Invert Selection

        • Apply

      Screenshot MeshLab Invert selection

      MeshLab: Invert selection

      Screenshot MeshLab selection inverted

      MeshLab: Selection inverted

      • Selektierte Dreiecke entfernen (“Delete the current set of selected faces and all the vertices surrounded by that faces.”)

  4. STL exportieren (s. Basics: Loading and saving STL)

Hint

  • View the selection from all sides before removing it. Elongated or misshapen triangles often lead to unwanted selections.

  • Also save intermediate versions.

  • Under certain circumstances, it can be helpful to change the Field Of View (FOV). To do this, hold down the “Shift” key while scrolling with the mouse wheel.

STL Automatically remove internal surfaces

Section Remove STL surfaces describes how to select and remove surfaces / triangles of a product using manual tools. If you want to remove the internal and therefore invisible triangles of your product, you can also have MeshLab do this automatically. MeshLab offers algorithms that detect hidden triangles.

The following instructions explain the individual steps using the example product ‘locking bolt’. The manufacturer’s CAD data also includes an internal bolt, which is not visible from the outside. In addition, deep holes are also rarely part of the point cloud, which is why triangles can also be removed here. These surfaces are removed in the following steps using Meshlab.

  1. Load product (see Basics: Loading and saving STL)

    Screenshot of MeshLab sample product 'Locking bar CAD'

    MeshLab: An example product ‘Locking bar CAD’

  2. Calculate ambient occlusion

    In this step, a kind of “visibility rating” is calculated for each triangle. In the next step, this value serves as the basis for deciding whether the triangle can be removed or not.

    1. Open the dialog for the Ambient Occlusion Filter under

      Filters → Color Creation and Processing → Ambient Occlusion Per Vertex

    2. Activate ‘Use GPU acceleration’, then confirm with ‘Apply’ The calculation is started and a visibility rating is assigned to each vertex as a quality feature. The areas are now displayed brightly if visibility is good and darkly if visibility is low.

    Screenshot MeshLab Ambient Occlusion Filter

    MeshLab: “Visibility assessment” using the ambient occlusion filter

  3. Select areas based on visibility

    The results of the previous step can now be used as the basis for a selection/selection of triangles.

    1. Filters → Selection → Select Faces by Vertex Quality

    2. Set the ‘Min Quality’ parameter to the lowest value.

    3. Activate “Preview”

    4. Adjust ‘Max Quality’ until only the desired areas are selected (colored red)

    5. ‘Apply’

    Hint

    • It may not be possible to clearly separate partially covered areas from the areas to be removed. In this case, you can also use manual tools to subsequently adjust the selection (see Remove STL surfaces).

    • Under ‘Render’ → ‘Render Mode’, you can switch between different types of visualization of the CAD model. The ‘Wireframe’ display, for example, also allows internal surfaces to be visualized as a triangular mesh.

    Screenshot of MeshLab selection based on visibility (low threshold value)

    MeshLab: Selection based on the visibility of an area with a low threshold value

    Screenshot of MeshLab selection based on visibility (higher threshold value)

    MeshLab: Selection based on the visibility of a surface with a higher threshold value: further inner surfaces are selected. Selected surfaces are now also added in the lower area, as the structures are located in a depression.

  4. Remove areas

    Selektierte Dreiecke entfernen (“Delete the current set of selected faces and all the vertices surrounded by that faces.”)

    Screenshot of MeshLab locking bars without internal structures

    MeshLab: The edited STL now has hardly any internal structures and can now be reworked manually or saved. As a high threshold value was selected in this example, the rings inside the lower holes have also been removed.

  5. STL exportieren (s. Basics: Loading and saving STL)