CGAL Mesh_3 (Panel) - User Manual
Dragonfly Prototype Apps · CGAL Mesh_3 (Panel)...
Version 1.0 · 2026-07-04
English Manual
Contents
1. Overview
1.1 How it works
2. Use Cases
3. Installation & Enabling
4. Runtime Environment & First-time Setup
5. User Interface
5.1 Input (from Dragonfly) group
5.2 Output & Executable group
Abaqus .inp and NASTRAN .bdf: two independent checkboxes in Output & Executable are enabled by default. Disable either to omit that format; .vtu is always written and MEDIT .mesh remains optional.
5.3 Mesh_3 Criteria (sizes in VOXELS) group
5.4 Mesh Optimization group
5.5 Action buttons, log and completion dialog
6. Step-by-step Usage
6.1 Basic workflow (end to end)
11. Use <name>.inp for Abaqus or ANSYS, and <name>.bdf for COMSOL or ANSYS. Check material partitions and coordinate units, then assign physical material properties, loads and boundary conditions.
6.2 Choosing the mesh size criteria
6.3 Viewing and using the results
5. In <name>.inp, *NODE lists nodes, *ELEMENT, TYPE=C3D4 lists four-node tetrahedra, and LABEL_<id> *ELSETs preserve Multi-ROI labels. No physical material constants, loads or boundary conditions are included.
6. In <name>.bdf, GRID lists nodes, CTETRA lists tetrahedra, and PSOLID IDs preserve Multi-ROI labels. MAT1 E=1 and Poisson ratio=0.3 are import placeholders; replace them before solving.
7. Parameter Reference
8. Outputs
The new <name>.inp and <name>.bdf use the same CGAL volume mesh. The solver_outputs field in <name>_result.json lists generated files. All mesh files use the chosen World or Image coordinate mode; the numerical length unit follows the source image and is not declared in the file.
Format scope: .inp is a flat C3D4 mesh with per-label element sets for Abaqus and ANSYS External Model. .bdf is free-field NASTRAN for COMSOL and ANSYS. Neither is a complete analysis model. Degenerate elements cause solver-format export to fail while the existing .vtu remains available.
9. FAQ & Troubleshooting
10. Notes & Known Limitations
11. References
1. Overview
The CGAL Mesh_3 (Panel) plugin turns your Dragonfly segmentation — a multi-material Multi-ROI, a binary ROI, or an integer label Channel — directly into a simulation-ready tetrahedral (volume) mesh. The mesh is written as a .vtu file (optionally plus a MEDIT .mesh file) in true Dragonfly world coordinates, with every tetrahedron carrying a MaterialID cell attribute equal to its original label value, ready for ParaView or FEM/simulation packages.
The underlying engine is the Mesh_3 3D mesh generation component of the open-source computational geometry library CGAL (the plugin is built against CGAL 5.5+/6.0): a labeled-image mesh domain (create_labeled_image_mesh_domain) is built from your labels, make_mesh_3 generates the tetrahedra, and the Perturb, Exude, Lloyd and ODT quality optimizers can be applied. All meshing runs in a standalone local executable, cgal_mesher.exe — CGAL is never loaded into Dragonfly's bundled Python, so the plugin is completely non-invasive to the Dragonfly installation.
Licensing notes: the plugin ships with the Prototype Apps Full Package; the meshing core cgal_mesher.exe is built on the open-source components CGAL, GMP/MPFR and nlohmann-json, and is bundled together with the required runtime libraries (gmp-10.dll, mpfr-6.dll and the MSVC runtime DLLs). It is invoked as an external subprocess. For the exact license terms of the open-source components, please refer to their official project pages.
- Three input types: Multi-ROI (multi-material), ROI (binary), integer label Channel.
- True world-coordinate output: the full origin + voxel spacing + orientation (4x4 affine) is carried through, so registered/rotated data lands in the right place.
- Material preservation: each tetrahedron's
MaterialIDequals its original label value — multi-material meshes need no remapping. - Controllable quality: five Mesh_3 criteria (facet angle/size/distance, cell size, radius-edge ratio) plus four optimizer switches.
- Run statistics: every run also writes
_result.json(vertex/tet counts, per-material tet counts, bounding box, timing, parameters used).
1.1 How it works
1. The panel reads the selected object's label volume directly (in-process) from the live Dragonfly session, together with its full voxel-to-world geometry (origin + spacing + orientation, encoded as a 4x4 voxel_to_world affine matrix).
2. The data is exported as labels.npy + metadata.json into a per-run job folder (labels are automatically narrowed to uint8 or uint16).
3. cgal_mesher.exe runs CGAL Mesh_3 in voxel space (the quality size criteria are in voxels) and automatically zero-pads the volume by one voxel on every side, so objects touching the image border still get a complete outer surface.
4. When exporting the mesh vertices (in the World output mode) they are mapped back to Dragonfly world coordinates through the voxel_to_world matrix; the run writes .vtu (optionally .mesh) plus the _result.json statistics file.
Meshing runs on a background worker thread, so the Dragonfly UI stays responsive; the Generate Mesh button is disabled while a job runs, and only one job runs at a time.
2. Use Cases
For anyone who needs to run physics simulations on segmented 3D image data, this plugin converts the segmentation into a solver-readable volume mesh in one step:
- Pre-processing (volume mesh generation) for FEM stress, heat transfer, fluid flow, electromagnetics and similar simulations.
- Simulation modeling of industrial CT data — cast parts, additively manufactured parts.
- Materials science: battery electrodes, porous materials and other microstructures.
- Life science: bone and tissue structures.
- Multi-material meshing: every class (phase) of a Multi-ROI is preserved as a separate material in the mesh, so different phases can get different material properties.
- Results open in ParaView, or feed into simulation toolchains such as Gmsh / NGSolve / Abaqus.
3. Installation & Enabling
1. Download the Prototype Apps online package from ImageFly and extract it. Close Dragonfly, run install_prototype_apps.exe and select the Dragonfly version to install into.
2. Start Dragonfly, open Prototype Apps ▸ App Store and search for CGAL Mesh_3 (Panel). If an Enable button is shown, click it and follow the sign-in, download or installation prompts.
3. Restart Dragonfly when prompted, then open CGAL Mesh_3 (Panel) from the Prototype Apps menu. Return to App Store to enable or disable it later.
To uninstall all Prototype Apps, close Dragonfly and run uninstall_prototype_apps.exe from the online package.
4. Runtime Environment & First-time Setup
This plugin has no Setup Environment button and needs no environment build: the mesher cgal_mesher.exe, together with its runtime libraries (gmp-10.dll, mpfr-6.dll, MSVC runtime DLLs), ships bundled in the bin\ subfolder of the plugin's code folder and is auto-detected when the panel opens. No internet, no GPU, no WSL — after ticking it in the installer and restarting Dragonfly it is ready to use.
- Mesher executable (auto-detected):
%LOCALAPPDATA%\comet\<DragonflyVersion>\pythonUserExtensions\GenericMenuItems\CgalMesh\bin\cgal_mesher.exe - User configuration:
%LOCALAPPDATA%\CgalMesh\config.json— remembers the last-used exe path and output folder; updated automatically on every Generate Mesh click. - Default output folder:
C:\CGALMeshJobs(changeable in the panel; the change is remembered; created automatically at run time if missing).
If the exe path field is empty or the file has been moved, click the … browse button next to it and point it at cgal_mesher.exe; the path is stored in the configuration file as well.
Supported Dragonfly versions: 2025.1 and 2027.1 (the panel uses Dragonfly's own PyQt6 and Python; one codebase serves both versions).
Unlike other heavy Prototype Apps plugins, this one downloads nothing at install or first use — it works out of the box.
5. User Interface
From top to bottom the panel shows: one blue hint line ("Generate a tetrahedral mesh (CGAL Mesh_3) from a Multi-ROI / ROI / label Channel..."), four parameter groups (scrollable), two action buttons, and the run log window at the bottom. Each element is described below.
5.1 Input (from Dragonfly) group
- Label object dropdown: lists every object in the current session that can serve as a label volume — all Multi-ROIs, ROIs and Channels (empty objects with zero voxels are filtered out). Entries are formatted
Title [Kind] [Z x Y x X], where Kind is MultiROI / ROI or the object class name; duplicate names get a GUID prefix suffix for disambiguation. - The list auto-refreshes (re-enumerated from the session roughly every 2.5 seconds) — no manual action needed after creating or deleting objects; your current selection is preserved across refreshes. Objects currently selected in Dragonfly are listed first.
- Grey hint at the top of the group: "Multi-ROI / ROI / label Channels refresh automatically from the session."
5.2 Output & Executable group
- Output folder: the output root folder (default
C:\CGALMeshJobs, or your last-used value); the … button opens a folder browser. Every run creates its own job subfolder inside it. - cgal_mesher.exe: path to the mesher executable, pre-filled automatically with the bundled
bin\cgal_mesher.exe; the … button lets you point elsewhere. - Output coordinates dropdown:
World (Dragonfly coordinates)(default — mesh vertices in Dragonfly world coordinates, perfectly aligned with the source data) orImage (origin 0, axis-aligned)(an origin-0, axis-aligned image frame for downstream FE tools that prefer it). - Also write MEDIT .mesh checkbox (off by default): additionally writes a MEDIT-format
.meshfile next to the.vtu.
5.3 Mesh_3 Criteria (sizes in VOXELS) group
Five numeric fields map to CGAL Mesh_3's five quality criteria. Note: all size-type criteria (Facet size, Facet distance, Cell size) are in VOXELS, independent of the data's physical spacing; the conversion is: physical size = voxels x voxel spacing along that axis.
- Facet angle (deg) (default 30): lower bound on the surface-triangle angles, in degrees.
- Facet size (default 2.0): upper bound on the surface-triangle circumball radius, in voxels.
- Facet distance (default 1.0): maximum approximation error between a surface facet and the true boundary, in voxels — controls how faithfully the boundary is reproduced.
- Cell size (default 2.0): upper bound on the tetrahedron circumball radius, in voxels — the main knob for overall mesh density.
- Cell radius-edge ratio (default 3.0): upper bound on the ratio of a tetrahedron's circumball radius to its shortest edge — controls element shape quality.
5.4 Mesh Optimization group
- Fast (disable all optimizers) (off by default): skips every optimizer — fastest, lowest quality.
- Perturb (on by default): vertex perturbation, removes degenerate elements.
- Exude (sliver removal) (on by default): exudation, removes sliver tetrahedra.
- Lloyd (off by default): Lloyd global smoothing optimizer (slower).
- ODT (off by default): ODT global optimizer (slower).
- Verbose mesher log (off by default): makes the mesher print a much more detailed progress log — useful for troubleshooting.
Perturb + Exude together is CGAL's default quality combination; when Fast is ticked, the other optimizer checkboxes have no effect.
5.5 Action buttons, log and completion dialog
- Generate Mesh (blue button): reads the selected object and starts the meshing job; disabled while a job is running.
- Open Output Folder: opens the most recent job's output folder in Windows Explorer (or the output root if nothing has run yet).
- Log window (read-only text box at the bottom): shows object refreshes, the export, every line of the mesher's output, and error messages.
When a run finishes, a CGAL Mesh_3 completion dialog pops up: on success it shows Vertices, Tetrahedra, Materials, Time and the output file path, with an Open Output Folder button (the default) and Close; on failure it shows "Meshing failed." plus the exact error text.
6. Step-by-step Usage
6.1 Basic workflow (end to end)
1. Prepare your segmentation in Dragonfly: a Multi-ROI (multi-material), a binary ROI, or an integer label Channel. Labels must be non-negative integers; 0 means background.
2. Open Prototype Apps ▸ CGAL Mesh_3 (Panel)....
3. Pick the input object in the Label object dropdown (the list auto-refreshes; check the kind and dimensions shown in brackets).
4. Confirm the Output folder (default C:\CGALMeshJobs); click … to change it.
5. Leave the auto-detected cgal_mesher.exe path untouched (unless you deliberately moved the executable).
6. Choose Output coordinates: keep the default World when the mesh must align with your Dragonfly data.
7. Set the five Mesh_3 Criteria for the target mesh density (units are voxels — see 6.2 for guidance).
8. Adjust the Mesh Optimization checkboxes as needed; for a first trial run, ticking Fast gives a quick preview.
9. Click Generate Mesh. The log window streams the export and mesher output; you can keep working in Dragonfly meanwhile.
10. When the completion dialog appears, check the vertex/tetrahedron/material statistics, click Open Output Folder, and take the .vtu (plus selected .inp, .bdf or .mesh) files.
6.2 Choosing the mesh size criteria
The size criteria are in voxels, so compare them directly with the voxel scale of the features you care about: Cell size / Facet size must be clearly smaller than the voxel thickness of the finest structure of interest, otherwise that structure cannot be captured — in the extreme case the mesh comes out empty (the mesher reports "empty mesh", return code 2). Conversely, smaller values mean a finer mesh, and the tetrahedron count, memory and run time grow steeply.
- Do a first trial with the defaults (Facet size 2.0 / Cell size 2.0 voxels) plus Fast, read the tetrahedron count from the completion dialog, then refine or coarsen as needed.
- When you need physical units, convert manually: physical size = voxels x voxel spacing (the mesh itself, in World mode, is already in physical coordinates).
- To improve boundary fidelity only, reduce Facet distance first; to control the overall mesh size, adjust Cell size first.
The whole selected volume is meshed at its current resolution: the larger the volume and the finer the criteria, the higher the memory use and run time. For large volumes, validate the workflow with coarse criteria first.
6.3 Viewing and using the results
1. Click Open Output Folder to open this run's job folder (named like cgal_<objectname>_<date_time>).
2. Drag <name>.vtu into ParaView and color by the MaterialID cell array to inspect the mesh per material.
3. For toolchains that read MEDIT (e.g. Gmsh), use the optionally generated <name>.mesh.
4. Open <name>_result.json for the total vertex/tetrahedron counts, per-material tetrahedron counts, the world-space bounding box, the timing, and all parameters used in this run.
7. Parameter Reference
Parameter | Default | Description |
Label object | (session objects) | Input dropdown: Multi-ROI / ROI / label Channel; auto-refreshes about every 2.5 s. |
Output folder | C:\CGALMeshJobs | Output root; each run creates a timestamped job subfolder inside it; remembered across sessions. |
cgal_mesher.exe | auto-detected (bundled) | Path to the mesher; defaults to bin\cgal_mesher.exe inside the plugin's code folder; remembered. |
Output coordinates | World (Dragonfly coordinates) | Vertex coordinate frame: World = Dragonfly world coordinates (origin/spacing/orientation); Image = origin-0, axis-aligned image frame. |
Also write MEDIT .mesh | off | Additionally writes a MEDIT .mesh file (1-based indices, material stored as the tetrahedron ref). |
Facet angle (deg) | 30 | Lower bound on surface-triangle angles (degrees). |
Facet size | 2.0 | Upper bound on surface-triangle circumball radius, in voxels. |
Facet distance | 1.0 | Maximum surface approximation error, in voxels; smaller = more faithful boundary. |
Cell size | 2.0 | Upper bound on tetrahedron circumball radius, in voxels; main mesh-density knob. |
Cell radius-edge ratio | 3.0 | Upper bound on circumball radius / shortest edge; controls element shape quality. |
Fast (disable all optimizers) | off | Skips all quality optimizers — fastest, lowest quality. |
Perturb | on | Vertex perturbation; removes degenerate elements. |
Exude (sliver removal) | on | Exudation; removes sliver tetrahedra. |
Lloyd | off | Lloyd global optimizer (slower). |
ODT | off | ODT global optimizer (slower). |
Verbose mesher log | off | More detailed mesher log output. |
8. Outputs
This plugin outputs files (it does not create new objects inside Dragonfly). Each run creates a job folder cgal_<objectname>_<YYYYMMDD_HHMMSS> under the output root, containing:
File | Description |
<name>.vtu | Main output: VTK XML UnstructuredGrid (ASCII) tetrahedral mesh; every cell carries an Int32 MaterialID attribute = original label value. Opens directly in ParaView. |
<name>.mesh | Optional (when Also write MEDIT .mesh is ticked): MEDIT-format mesh, 1-based vertex/tetrahedron indices, material written as the tetrahedron ref. |
<name>_result.json | Run statistics: output path, coordinate mode, num_vertices, num_tetrahedra, num_materials, materials (tetrahedron count per label), bbox_min/bbox_max, seconds, parameters. |
labels.npy | Intermediate file: the exported label volume (uint8/uint16, C-order Z,Y,X). |
metadata.json | Intermediate file: shape, spacing, origin, the 4x4 voxel_to_world matrix and the label list. |
How to view: open the .vtu in ParaView and color by MaterialID; in World mode the mesh sits in exactly the same coordinate frame as the source data in Dragonfly, so it can be overlaid with other exported data.
v1 does not re-import the tetrahedral volume mesh into Dragonfly (Dragonfly's native mesh support is mainly surface meshes) — use the output files in ParaView / your simulation package.
9. FAQ & Troubleshooting
Q: The menu entry CGAL Mesh_3 (Panel)... is missing?
A: Confirm that CGAL Mesh_3 (Panel) is enabled in Prototype Apps ▸ App Store, then restart Dragonfly.
Q: My object does not appear in the dropdown?
A: The list only shows Multi-ROIs / ROIs / Channels that actually contain volume data (zero-voxel objects are filtered out), and it refreshes about every 2.5 seconds — wait a moment if the object was just created or is still loading. If Generate Mesh reports "select a valid input object (it may still be loading)", re-select once loading has finished.
Q: Error "CGAL mesher exe not found"?
A: The exe path field points to a missing file. Click the … button next to it and browse to %LOCALAPPDATA%\comet\<DragonflyVersion>\pythonUserExtensions\GenericMenuItems\CgalMesh\bin\cgal_mesher.exe; the path is remembered afterwards.
Q: "empty mesh" error / failure with return code 2?
A: The size criteria are too large relative to your structures — Cell size / Facet size are in voxels, and if they exceed the voxel thickness of a structure it is skipped entirely. Reduce Cell size and Facet size and retry; also verify the selected object really contains non-zero labels.
Q: The mesh is too big / the run is too slow?
A: Increase Cell size and Facet size (most effective), tick Fast to skip the optimizers, and leave Lloyd / ODT unticked. Tick Verbose mesher log to watch progress. A running job cannot be cancelled from the panel, so it is best to try coarse settings first and refine once the mesh size is confirmed.
Q: What are the label restrictions?
A: Labels must be non-negative integers: negative values raise an error; the maximum label value must not exceed 65535 (above that you are asked to re-label). 0 is treated as background/exterior and is not meshed; every non-zero label becomes one material. Floating-point Channels are rounded to the nearest integer before use.
Q: In ParaView, the mesh does not line up with my exported image data?
A: Check that Output coordinates was set to World (Dragonfly coordinates) when the mesh was generated — that mode carries the true origin, spacing and orientation; the Image mode is an origin-0, axis-aligned frame, so a mismatch between the two is expected.
Q: Can I load the generated volume mesh back into Dragonfly?
A: Not in the current version — Dragonfly's native mesh objects mainly target surface meshes, while this plugin outputs tetrahedral volume meshes. Use Open Output Folder and view the files in ParaView or another external tool.
10. Notes & Known Limitations
- Sizes are in voxels: Facet size, Facet distance and Cell size are in voxel units (the group title says "sizes in VOXELS"), independent of physical spacing; only the output mesh coordinates (World mode) are in physical/world units.
- Label 0 = background/exterior and is not meshed; every non-zero label produces one material.
- The dropdown lists all Channels: pick a genuine integer label map. A plain grayscale Channel would turn every gray value into a material, which is usually not what you want.
- The maximum label value is 65535 (internally stored as uint8 or uint16 depending on the maximum); negative labels are rejected.
- Before meshing, the volume is automatically zero-padded by one voxel on every side so that border-touching objects get a complete outer surface — this is intended behavior.
- If the input object has no Box geometry, unit spacing and an identity transform are used (a log message says so) — the output is then effectively in image coordinates.
- A running job cannot be cancelled; the Generate Mesh button stays disabled until it finishes. Evaluate the mesh size with coarse criteria first.
- v1 does not import the volume mesh back into Dragonfly; the deliverables are standard mesh files (.vtu / .mesh).
- labels.npy / metadata.json in the job folder are intermediate files; once you have verified the result they can be deleted to save disk space.
- The configuration (exe path, output folder) is stored in
%LOCALAPPDATA%\CgalMesh\config.json; uninstalling the plugin does not delete it.
11. References
- The CGAL (Computational Geometry Algorithms Library) project and the official documentation of its Mesh_3 3D mesh generation component (this plugin is built against CGAL 5.5+/6.0; GMP/MPFR numeric backend).
- VTK / ParaView: the
.vtu(VTK XML UnstructuredGrid) format and mesh viewing. - The MEDIT
.meshformat: a classic mesh exchange format readable by Gmsh and other tools. - Downstream simulation tools (examples): Gmsh, NGSolve, Abaqus.
- For online installation and plugin activation, see Chapter 3.