Overview
The RoseMeshBuilder class controls access to mesh data while it being created by a faceter. This allows a viewer to display partially faceted meshes while background worker threads continue to generate more meshes. Subclasses of RoseMeshBuilder handle the specific details for faceting STEP, IFC, or other data.
beginCS() / endCS()
void beginCS(); void endCS();
The beginCS() function starts a critical section and endCS() ends it. There may be worker threads in the background, so it is important that all access to the mesh data be properly synchronized. Most of the data access functions in this class are synchronized, but you must manually synchronize if you access mesh data from a RoseMesh when the shell is not fully faceted.
There must be a call to endCS() for every call to beginCS, otherwise you may deadlock the faceter.
getBoundingBox()
void getBoundingBox( RoseBoundingBox &bbox ); void getBoundingBox( RoseBoundingBox &bbox, const RoseMeshFacet * facet );
The getBoundingBox() function fills in the bbox parameter with an exact bounding box size. The version that takes a facet parameter returns the box surrounding the facet.
The version that takes no other parameters returns the bounding box of the entire shell. If the shell is still being faceted, it returns the bounding box of the facets created so far. The getEstimatedBoundingBox() function may return a more accurate result before the shell is fully rendered.
getCanceledFlag()
int getCanceledFlag()
The getCanceledFlag() function returns the local "canceled" flag for the builder. A faceting job for a single mesh may be canceled by setting this local flag, or faceting across all threads and shells may be canceled by setting a flag on an associated RoseMeshThreadMonitor object. The isCanceled() function checks both while this function only checks the local flag.
getDiagonal()
double getDiagonal()
The getDiagonal() function returns the diagonal of the estimated bounding box.
getEdgeCount()
unsigned getEdgeCount();
The getEdgeCount() function returns the number of edges in the mesh. This function provides its own synchronization, and thus should be used in preference to directly accessing the facet set if there is any chance that faceting threads are accessing this builder.
getEdgeInfo()
const RoseMeshEdgeInfo * getEdgeInfo (unsigned idx);
The getEdgeInfo() function returns a pointer to an internal structure describing a edge curve on the mesh.
getEstimatedBoundingBox()
const RoseBoundingBox & getEstimatedBoundingBox();
The getEstimatedBoundingBox() function returns a provisional bounding box based on the trim curves. This is available before the shell is fully rendered but may differ from the final box due to surfaces extending into the space beyond the trim curves.
getFaceBuilder()
RoseMeshFaceBuilder * getFaceBuilder(unsigned i);
The getFaceBuilder() function returns a pointer to an internal face builder object used to construct the mesh.
getFaceCount()
unsigned getFaceCount();
The getFaceCount() function returns the number of STEP faces in the mesh. This function provides its own synchronization, and thus should be used in preference to directly accessing the facet set if there is any chance that faceting threads are accessing this builder.
getFaceDescription()
RoseStringObject getFaceDescription(unsigned i); RoseStringObject getFaceDescription(RoseMeshFaceBuilder * b);
The getFaceDescription() function returns a text description of the face for debugging and error reporting purposes.
getFaceInfo()
const RoseMeshFaceInfo * getFaceInfo(unsigned idx);
The getFaceInfo() function returns extra mathematical surface and solver information from the original, unmeshed face surface. This also includes the edge loop information and original UV trim curves. This infomation is usually discarded after faceting to save space but can be kept by setting the RoseMeshOptions::setSaveFaceInfo() flag.
getFacet()
const RoseMeshFacet * getFacet(unsigned i);
The getFacet() function returns a facet desription struct by index. This function provides its own synchronization, and thus should be used in preference to directly accessig the facet set if there is any chance that faceting threads are accessing this builder.
getFacetArea()
double getFacetArea (const RoseMeshFacet * facet); double getFacetArea (unsigned idx);
The getFacetArea() function returns the area of a facet triangle, either by index or by structure.
getFacetCount()
unsigned getFacetCount();
The getFacetCount() function returns the number of facets in the mesh created so far. This function provides its own synchronization, and thus should be used in preference to directly accessig the facet set if there is any chance that faceting threads are accessing this builder.
getFacetNormal()
void getFacetNormal( double normal[3], const RoseMeshFacet * f );
The getFacetNormal() function calls RoseMesh::getFacetNormal() on the mesh is under construction, with appropriate thread synchronization.
getFacetVertexNormal()
void getFacetVertexNormal( double n[3], const RoseMeshFacet * facet, unsigned vidx ); void getFacetVertexNormal( double n[3], unsigned fidx, unsigned vidx );
The getFacetVertexNormal() function calls RoseMesh::getFacetVertexNormal() while the mesh is under construction, with appropriate thread synchronization.
getGlobalUncertainty()
double getGlobalUncertainty() const;
The getGlobalUncertainty() function returns the global uncertainty of the mesh. This comes from the original geometric model.
getMonitor()
RoseMeshThreadMonitor * getMonitor();
The getMonitor() function returns the current thread monitor.
getNormal()
void getNormal( double xyz[3], unsigned i );
The getNormal() function returns a normal direction vector from the facet set. This function provides its own synchronization, and thus should be used in preference to directly accessing the facet set if there is any chance that faceting threads are accessing this builder.
getNormalUnsync()
const double * getNormalUnsync( unsigned i );
The getNormalUnsync() function returns a normal directon vector as an array of doubles. This is a direct pointer into the actual buffer used, and thus cannot be synchronized. (Another thread may cause the buffer to be expanded and moved.) Any call to this function must be externally synchronized by placing it (and any use of the returned value) within a beginCS / endCS block.
getOptions()
RoseMeshOptions * getOptions();
The getOptions() function returns the options object that was associated with the builder on its creation.
getSurfaceArea()
double getSurfaceArea()
The getSurfaceArea() function calls RoseMesh::getSurfaceArea() while the mesh is under construction, with appropriate thread synchronization.
getTolerance()
double getTolerance();
The getTolerance() function returns the rendering tolerance.
getTriangleNormal()
void getTriangleNormal( double normal[3], unsigned v0, unsigned v1, unsigned v2 );
The getTriangleNormal() function calls RoseMesh::getTriangleNormal() while the mesh is under construction, with appropriate thread synchronization.
getVertex()
void getVertex( double xyz[3], unsigned i );
The getVertex() function returns a vertex from the facet set. This function provides its own synchronization, and thus should be used in preference to directly accessig the facet set if there is any chance that faceting threads are accessing this builder.
getVertexCount()
unsigned getVertexCount();
The getVertexCount() function returns the number of vertices currently in the mesh, with proper thread synchronization.
getVertexUnsync()
const double * getVertexUnsync( unsigned i );
The getVertexUnsync() function returns a vertex as an array of doubles. This is a direct pointer into the actual buffer used, and thus cannot be synchronized. (Another thread may cause the buffer to be expanded and moved.) Any call to this function must be externally synchronized by placing it (and any use of the returned value) within a beginCS / #endCS block.
builder->beginCS(); const double * pt = builder->getVertexUnsync(idx); printf ("Coordinates=(%f,%f,%f)\n", pt[0], pt[1], pt[2]); builder->endCS();
isCanceled()
int isCanceled();
The isCanceled() function returns true (nonzero) if either meshing for this particular builder has been canceled or meshing across all threads has been canceled. The getCanceledFlag() returns the local value for the builder, and getMonitor() returns the thread monitor which can be queried for its status.
isComplete()
int isComplete();
The isComplete() function returns true (nonzero) if all shell faces have completed rendering. This can be used to test if a mesh is fully rendered before performing some geometric analysis against it. The isUsable() function tests whether rendering is complete and all faces were successfully faceted. The RoseMeshFace::isComplete() function tests an individual face.
isRenderPrep()
virtual int isRenderPrep();
The isRenderPrep() function returns true (nonzero) if the renderPrep() has already been called for the mesh.
isUsable()
int isUsable()
The isUsable() function returns true if all rendering is complete and all faces were successfully faceted. If true, the mesh should form a watertight shell.
makeEdgeCurve()
virtual int makeEdgeCurve( RoseCurve & curve, unsigned idx, int full_loop ) = 0;
The makeEdgeCurve() function is a pure virtual function intended for subclasses to implement edge curve linearization algorithms specific to different kinds of mathematical representations and source data models.
makeFaceSurface()
virtual int makeFaceSurface( RoseSurface *& surf, int & sense, int & orientation, RoseMeshFaceBuilder * face )=0;
The makeFaceSurface() function is a pure virtual function intended for subclasses to implement meshing algorithms specific to different kinds of mathematical representations and source data models.
renderFace()
int renderFace(unsigned idx); int renderFace(RoseMeshFaceBuilder * face);
The renderFace() function renders a single face of the mesh. Since the faceting process is compute intensive, this function may be called from a worker thread to perform the faceting. This function should be called once for each face in the mesh, and multiple faces of the same mesh may be rendered at the same time. This function returns a boolean value indicating wether the faceter was able to facet the face.
renderPrep()
virtual int renderPrep();
The renderPrep() function prepares the mesh for rendering. All faces must be added, and the tolerance must be set before this methos is called. Once renderPrep returns, then the faces can be rendered in background worker threads.
This function returns 1 (true) on success. If there was an error, it returns 0.
setCanceledFlag()
void setCanceledFlag(int yn);
The setCanceledFlag() function sets the local canceled flag for the builder. See isCanceled() for more discussion on how rendering is canceled.
setMonitor()
void setMonitor( RoseMeshThreadMonitor * ctl );
The setMonitor() function sets the monitor for the faceter to use. The monitor is an object that manages multiple threads, each performing meshing operations on different shells. Using the monitor, one can cancel all faceting operations. This may be used, for example, if the user loads a new file, so the current faceting tasks need to be quickly terminated.
setTolerance()
void setTolerance( double tol );
The setTolerance() function sets the rendering tolerance for the faceter. This value is clamped to be greater than or equal to the getGlobalUncertainty() value. This determines the number of facets that are generated. A smaller tolerance value results in more facets. The tolerance must be set before the renderPrep function is called. If the tolerance is not set, a default value is computed by taking the estimated bounding box * 1/500.