Conversation
Reviewer's GuideRefactors ShapeTesselator to support optional OpenMP-parallel face processing, improves normal computation by using precomputed triangulation normals when available, and optimizes several data paths by preallocating exact buffer sizes and avoiding repeated insert/push_back operations and intermediate string formatting. Updated class diagram for ShapeTesselator parallel processing and normals optimizationclassDiagram
class ShapeTesselator {
- bool computed
- bool use_parallel
- TopoDS_Shape myShape
- Standard_Real myDeviation
- std_vector_face_ptr face_list
- std_vector_edge edge_list
+ ShapeTesselator(aShape)
+ Tessellate(compute_edges, mesh_quality, parallel)
+ GetVerticesPositionAsTuple() const
+ GetNormalsAsTuple() const
+ ExportShapeToX3DTriangleSet() const
- ProcessFaces(faces)
- ProcessSingleFace(face, triangulation, location, face_data)
- ProcessNormals(face, triangulation, face_data)
- ProcessTriangles(face, triangulation, face_data)
}
class Face {
+ std_vector_float vertex_coords
+ std_vector_float normal_coords
+ std_vector_int triangle_indices
+ Standard_Integer number_of_triangles
+ Standard_Integer number_of_normals
+ Standard_Integer number_of_invalid_normals
}
class Edge {
+ std_vector_float vertex_coords
}
ShapeTesselator "1" *-- "*" Face
ShapeTesselator "1" *-- "*" Edge
Flow diagram for ShapeTesselator Tessellate face processing and normals computationflowchart TD
A[Tessellate] --> B[Collect faces from myShape]
B --> C[Set use_parallel flag]
C --> D{OpenMP available and use_parallel and num_faces > 1}
D -->|Yes| E[Parallel for over faces]
D -->|No| F[Sequential loop over faces]
E --> G[For each face:<br/>ProcessSingleFace]
F --> G
G --> H[ProcessNormals]
H --> I{triangulation HasNormals}
I -->|Yes| J[Copy precomputed normals<br/>from triangulation]
I -->|No| K{triangulation HasUVNodes}
K -->|Yes| L[Compute normals<br/>via BRepGProp_Face Normal]
K -->|No| M[Increment<br/>number_of_invalid_normals]
J --> N[Update face_data<br/>normal_coords]
L --> N
M --> N
N --> O[ProcessTriangles<br/>and fill triangle_indices]
O --> P[Append face_data<br/>into face_list]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- In
ExportShapeToX3DTriangleSet, normals are now derived viaconsolidated_triangle_indicesandconsolidated_normalsinstead of usingObjGetTriangle/normals_idx; please double-check that vertex and normal indexing are still aligned for all code paths, as this changes the previous separation of vertex and normal indices and may alter output for cases with distinct normal indexing. - The new
#include <mutex>appears unused after these changes; consider removing it to avoid confusion about implied synchronization mechanisms around the OpenMP parallelization. - The OpenMP branch in
ProcessFaceswrites intoface_listafter the parallel region, butface_listis only reserved tofaces.size()and not cleared beforehand; ifTessellatecan be called multiple times on the same object, consider explicitly clearingface_listbefore appending to avoid accumulating stale data.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `ExportShapeToX3DTriangleSet`, normals are now derived via `consolidated_triangle_indices` and `consolidated_normals` instead of using `ObjGetTriangle`/`normals_idx`; please double-check that vertex and normal indexing are still aligned for all code paths, as this changes the previous separation of vertex and normal indices and may alter output for cases with distinct normal indexing.
- The new `#include <mutex>` appears unused after these changes; consider removing it to avoid confusion about implied synchronization mechanisms around the OpenMP parallelization.
- The OpenMP branch in `ProcessFaces` writes into `face_list` after the parallel region, but `face_list` is only reserved to `faces.size()` and not cleared beforehand; if `Tessellate` can be called multiple times on the same object, consider explicitly clearing `face_list` before appending to avoid accumulating stale data.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by Sourcery
Optimize and extend ShapeTesselator by adding optional parallel face processing, leveraging precomputed normals when available, and reducing memory allocations and string formatting overhead across tessellation and export routines.
Enhancements: