Overview
The STEP mesher transforms STEP geometry and topology definitions into triangular meshes for display in OpenGL, WebGL and DirectX or for export to formats like STL, AMF, and 3MF.
Use the stix_mesh_make() or stix_mesh_make_all() functions to create meshes for stp_representation_item objects. Meshing can take place in the background using multiple threads for speed and versions the "make" functions allow control over when the work must be completed.
Each mesh is linked to its source STEP object and the "make" function return a previously created mesh if one exists. Use stix_mesh_find() to just look for an existing mesh without creating one.
These functions return an StixMesh object, which is a subclass of RoseMesh with extra functions to return the STEP source objects for faces and edges.
The example below creates meshes for everything in a file. Then loops over all of the representatation items, and if a mesh was created for it, prints the mesh size.
RoseDesign * design; // index the STEP presentation information so the mesher can find // color information for solids and faces. stix_present_tag(design); // create meshes for everything in the design stix_mesh_make_all(design); // Print all of the meshes. A real program would walk the STEP assembly // structure and print the meshes in context with the products that they // are associated with. RoseCursor objs; RoseObject * obj; objs.traverse(d); objs.domain(ROSE_DOMAIN(stp_representation)); while ((obj=objs.next()) != 0) { stp_representation * rep = ROSE_CAST(stp_representation,obj); SetOfstp_representation_item * items = rep->Items(); unsigned i,sz; for (i=0, sz=items->size(); i<sz; i++) { stp_representation_item * it = items->get(i); StixMesh * mesh = stix_mesh_find(it, rep); if (mesh) { printf (Item #%lu: mesh with %u triangles\n, it->entity_id(), mesh->getFacetCount()); } } }
stix_mesh_can_make()
int stix_mesh_can_make( stp_representation_item * item, stp_representation * rep = 0 );
The stix_mesh_can_make() function returns non-zero if a mesh can be created from the representation item, such as an manifold_solid_brep or tessellated_solid. It returns zero if no mesh can be made from the item, such as an axis2_placement_3d. It also returns zero for an mapped_item, since it is the underlying item that is meshed, not the mapping.
stix_mesh_delete()
void stix_mesh_delete( stp_representation_item * item, stp_representation * rep = 0, RoseMeshNotify * notify = 0 );
The stix_mesh_delete() function deletes any mesh associated with the given representation item. If a representation or notify object are provided, only a mesh created with matching values will be deleted.
This is a wrapper around rose_mesh_cache_delete()
stix_mesh_delete_all()
void stix_mesh_delete_all( RoseDesign * design, RoseMeshNotify * notify = 0 );
The stix_mesh_delete_all() function is an alias for rose_mesh_delete_all().
It deletes all meshes associated with data objects in the design. This function is not usually needed because all meshes are automatically deleted when the design is deleted.
stix_mesh_detach()
StixMesh * stix_mesh_detach( stp_representation_item * item, stp_representation * rep = 0, RoseMeshNotify * notify = 0 );
The stix_mesh_detach() function finds the effective mesh associated with the given representation item. The association is removed and it becomes the responsibility of the caller to delete the mesh object when finished.
This is a wrapper around rose_mesh_cache_find() followed by rose_mesh_cache_detach()
stix_mesh_find()
StixMesh * stix_mesh_find( stp_representation_item * item, stp_representation * rep = 0, RoseMeshNotify * notify = 0 );
The stix_mesh_find() function finds the effective mesh associated with the given representation item. If a representation or notify object are provided, only a mesh created with matching values will be returned.
This is a wrapper around rose_mesh_cache_find() that will only return an instance of the StixMesh subtype.
stix_mesh_init()
void stix_mesh_init();
The stix_mesh_init() function should be called once before doing any meshing operations. This function sets the FPU using rose_mesh_fpu_save() to make sure that computations done by the faceter library are consistent.
The stix_mesh_shutdown() function restores the FPU..
stix_mesh_job_init()
StixMesh * stix_mesh_job_init( stp_representation_item * item, stp_representation * rep, RoseMeshOptions * opts, RoseMeshNotify * notify );
The stix_mesh_job_init() function is for internal use. Use one of the stix_mesh_make() functions instead. This creates a mesh and associates it with a representation item. It does not check if a mesh is already associated with the representation item and does not start the meshing process.
stix_mesh_make()
StixMesh * stix_mesh_make( // return when done stp_representation_item * item, stp_representation * rep, RoseMeshOptions * opts = 0, RoseMeshNotify * notify = 0 ); StixMesh * stix_mesh_make_start( // return after starting stp_representation_item * item, stp_representation * rep, RoseMeshOptions * opts = 0, RoseMeshNotify * notify = 0 ); StixMesh * stix_mesh_make_job( // return immediately stp_representation_item * item, stp_representation * rep, RoseMeshOptions * opts = 0, RoseMeshNotify * notify = 0 );
The stix_mesh_make() functions find or create a mesh for the given representation item and representation. An options structure can be provided to control tolerance and other values used by the mesher. Meshing can take place in the background using multiple threads for speed. The three versions of this function allow control over when the work must be completed.
If the STEP style information has been previously indexed by calling stix_style_tag(), the meshes will have color information for solids and faces.
All of the functions first call stix_mesh_find() and will return an existing mesh object if present. If one can be made, they will create an empty mesh object and associate it with the representation item. The functions differ on what happens next.
The stix_mesh_make() function will create the contents and return the mesh when it is complete. It may use several threads, but still only works on one mesh at a time.
The stix_mesh_make_start() function will begin creating the contents as a background job and return the empty mesh immediately. The mesh may not be usable for some time, but you can start many items, then wait for them to complete. This will generally be faster on multi-core CPUs than doing it one at a time. Consider using stix_mesh_make_all() if you want to mesh everything in a file.
The stix_mesh_make_job() function will return the empty mesh immediately. Background work is prepared but has not begun. This is useful if you want to get everything ready, but may not need the mesh data until later. You can call start and wait functions when it is eventually needed.
A notify object can be provided to distinguish meshes made for a particular purpose and to get update messages as portions of meshes become available.
stp_representation_item * it; stp_representation * rep; StixMesh * mesh; // prepare one mesh mesh = stix_mesh_make(it, rep); // do something -- ready to use // batch prepare some meshes for (i=0; i<sz; i++) { (void) stix_mesh_make_start(get_item(i), get_rep(i)); } rose_mesh_wait_all(); // wait for everything to be done // everything now completed, use them for (i=0; i<sz; i++) { mesh = stix_mesh_find(get_item(i), get_rep(i)); // do something -- ready to use }
stix_mesh_make_all()
void stix_mesh_make_all( // return when done RoseDesign * design, RoseMeshOptions * opts = 0, RoseMeshNotify * notify = 0 ); void stix_mesh_make_all_start( // return after starting RoseDesign * design, RoseMeshOptions * opts = 0, RoseMeshNotify * notify = 0 ); void stix_mesh_make_all_job( // return immediately RoseDesign * design, RoseMeshOptions * opts = 0, RoseMeshNotify * notify = 0 );
The stix_mesh_make_all() functions create meshes for everything in the design. An options structure can be provided to control tolerance and other values used by the mesher. After this function is called, stix_mesh_find() will return an existing mesh object for everything that can be meshed.
The three versions of this function allow control over when the work must be completed and follow the convention used by stix_mesh_make().
The stix_mesh_make_all() function will return when all meshes are complete. The stix_mesh_make_all_start() function will begin work on all meshes and then return. Call wait or wait all when you completed data. The stix_mesh_make_all_job() function prepares everything but you must start start and wait for meshes individually.
A notify object can be provided to distinguish meshes made for a particular purpose and to get update messages as portions of meshes become available.
RoseDesign * StixMesh * mesh; // prepare all meshes stix_mesh_make_all(design); // everything now completed, use them for (i=0; i<sz; i++) { mesh = stix_mesh_find(get_item(i), get_rep(i)); // do something -- ready to use } // ANOTHER POSSIBIILITY // start background work on all meshes stix_mesh_make_all_start(design); ( do other setup) // block until all meshes are ready rose_mesh_job_wait_all();
stix_mesh_shutdown()
void stix_mesh_shutdown();
The stix_mesh_shutdown function restores FPU status to previous settings if necessary using using rose_mesh_fpu_restore().
stix_mesh_count_shapes_asm()
unsigned stix_mesh_count_shapes_asm( stp_representation * sr, rose_uint_vector * roots );
The stix_mesh_count_shapes_asm() function returns the number of shapes in an assembly. This is used to report on the progess of potentially long-running export operations.
stix_mesh_export_3mf()
int stix_mesh_export_3mf( const char * o_3mf, stp_representation * shape, RoseMeshWorkerContext * wc ); int stix_mesh_export_3mf( const char * o_3mf, SetOfstp_representation * shapes, RoseMeshWorkerContext * wc ); int stix_mesh_export_3mf( const char * o_3mf, StpAsmProductDefVec * roots, RoseMeshWorkerContext * wc ); int stix_mesh_export_3mf( const char * o_3mf, RoseDesign * des, RoseMeshWorkerContext * wc );
The stix_mesh_export_3mf() functions facet the given STEP representations or assembly components using the options specified in the worker context and then calls rose_mesh_write_3mf() to write the meshes out in 3MF format.
stix_mesh_get_estimated_bounding_box()
int stix_mesh_get_estimated_bounding_box( RoseBoundingBox * bbox, stp_face * face, stp_representation * rep ); int stix_mesh_get_estimated_bounding_box( RoseBoundingBox * bbox, stp_curve_bounded_surface * surf, stp_representation * rep );
The stix_mesh_get_estimated_bouding_box() functions determine the bounding box of a facet or curve_bounded_surface. This bounding box is either the boudning box of the trim bounding/trim curves or, if it is bounded by a single vertex_loop, the bounding box of the underlying surface. An accurate bounding box cannot be determined until the surface is faceted.
The bounding box is placed in the bbox parameter. This function return 0 (false) if there was an error, 1 otherwise.
stix_mesh_get_trim_bounding_box()
RoseBoundingBox * stix_mesh_get_trim_bounding_box( stp_face * face, stp_representation * rep ); RoseBoundingBox * stix_mesh_get_trim_bounding_box( stp_curve_bounded_surface * surf, stp_representation * rep );
The stix_mesh_get_trim_bouding_box() functions compute the bounding box of the trim curves of a face or surface.
stix_mesh_save_stp_shell()
void stix_mesh_save_stp_shell( RoseXMLWriter * xml, const StixMesh * shell, const char * id, unsigned color ); void stix_mesh_save_stp_shell( RoseXMLWriter * xml, RoseMeshXMLOpts * opts, const StixMesh * shell, const char * id, unsigned color ); void stix_mesh_save_stp_shell( const char * fname, const StixMesh * shell, const char * id, unsigned color ); void stix_mesh_save_stp_shell( const char * fname, RoseMeshXMLOpts * opts, const StixMesh * shell, const char * id, unsigned color );
The stix_mesh_save_stp_shell() functions write mesh to an XML file. These differ from the stix_mesh_save_shell functions in that they have multiple <facets> elements - one for each face of the STEP shell, each of which may have a uniqie color.