polyfoammesh.core.feature_detector
Classes
|
Runs feature detection in a SEPARATE PROCESS, driven from a background QThread. |
|
|
|
|
|
- class polyfoammesh.core.feature_detector.SharpEdge(point_a, point_b, angle, length)[source]
Bases:
object- Parameters:
- class polyfoammesh.core.feature_detector.GapRegion(center, gap_width, normal)[source]
Bases:
object- Parameters:
- class polyfoammesh.core.feature_detector.FeatureMap(sharp_edges=<factory>, gap_regions=<factory>, curvature_radius=1.0, suggested_min_cell=0.01, suggested_max_cell=0.1)[source]
Bases:
object- Parameters:
- class polyfoammesh.core.feature_detector.FeatureDetector[source]
Bases:
object- analyze_step(filepath, detail='medium', scale=1.0)[source]
Analyse filepath and suggest cell sizes.
scale converts the CAD file’s own units into the units the rest of the app works in (metres) — the SAME factor MainWindow applies to the loaded geometry. Without it, this returns sizes in the CAD file’s units while the caller treats them as metres: confirmed live on a 3 m model authored in mm, where GMSH’s bbox is 3000 and the suggestion came back as 150 — applied as 150 METRES, i.e. 50x the whole model, which then got clamped and logged as “maxCellSize clamped from 100.0000 to 1.5000”.
- Return type:
- Parameters:
- suggest_cell_sizes(feature_map, bbox_dim)[source]
- Return type:
- Parameters:
feature_map (FeatureMap)
bbox_dim (float)
- class polyfoammesh.core.feature_detector.FeatureDetectWorker(step_path, detail, scale=1.0, parent=None)[source]
Bases:
QObjectRuns feature detection in a SEPARATE PROCESS, driven from a background QThread.
Two independent reasons this cannot run in-process on the GUI thread:
Responsiveness: analyze_step() calls gmsh.model.mesh.generate(2), a full 2D surface remesh. On a complex or poorly-defeatured CAD model GMSH can spend a long time retrying (“Splitting those edges and trying again”, “N elements remain invalid in surface M”) — the app showed “Not Responding” for that whole time when it ran on the GUI thread.
Crash isolation: gmsh bundles its OWN OpenCASCADE build, while the app separately loads cadquery/OCP’s OpenCASCADE for STEP handling. Both live in one process, and driving gmsh’s OCC STEP reader on a complex model took the entire application down with a hard native crash — no Python traceback, just a dead process (reported live on both the serial and parallel meshing paths, on a geometry where GMSH’s log showed it fighting “3 intersections in the 1D mesh”). Feature detection is a nice-to-have that only refines suggested cell sizes; it must never be able to kill a meshing run. Running it out-of-process means even a segfault is just a non-zero exit code here, and the caller falls back to the existing cell sizes.
- finished
- TIMEOUT_S = 120
- staticMetaObject = PySide6.QtCore.QMetaObject("FeatureDetectWorker" inherits "QObject": Methods: #4 type=Signal, signature=finished(PyObject,PyObject), parameters=PyObject, PyObject #5 type=Slot, signature=run() )