Overview

The StixMesh library provides a variety of high-level helper functions. All functions have the stixmesh_ prefix.

stixmesh_cache_add()

void stixmesh_cache_add(
        RoseObject * obj, 
        StixMesh * mesh
        );

The stixmesh_cache_add() function associates a mesh with a STEP object. The cache takes ownership of the mesh and will delete it when the STEP object is deleted, so do not associate a mesh with more than one STEP object.

The stixmesh_cache_find() function returns a cached mesh. More than one mesh can be associated with an object and the stixmesh_cache_find_finest() and stixmesh_cache_find_coarsest() functions examine the tolerances used to create the mesh.

stixmesh_cache_asm_create()

void stixmesh_cache_asm_create(
	stp_product_definition * pd,
	RoseMeshOptions * opts = 0
	);

The stixmesh_cache_asm_create() function walks the shape tree of an assembly and create meshes and cache for each solid. The mesh is associated with the STEP representation_item for each solid. This function expects stix_tag_asms() to have been called so that assemblies can be walked. Just uses stixmesh_create() to facet.

stixmesh_cache_asm_find_bounds()

void stixmesh_cache_asm_find_bounds(
	stp_product_definition * pd,
	RoseBoundingBox * bbox
	);

The stixmesh_cache_asm_find_bounds() function walks the shape tree of an assembly and compute the bounding box for the assembly from cached mesh data. As above, this function expects stix_tag_asms() to have been called so that assemblies can be walked.

stixmesh_cache_delete()

void stixmesh_cache_delete(
        RoseObject * obj
        );

The stixmesh_cache_delete() function deletes any and all meshes associated with a STEP object.

stixmesh_cache_find()

StixMesh * stixmesh_cache_find(
        RoseObject * obj
        );

The stixmesh_cache_find() function returns a cached mesh if one is associated with a STEP object. More than one mesh can be associated with an object and the stixmesh_cache_find_finest() and stixmesh_cache_find_coarsest() functions examine the tolerances used to create the mesh.

stixmesh_cache_find_coarsest()

StixMesh * stixmesh_cache_find_coarsest(
        RoseObject * obj
        );

The stixmesh_cache_find_coarsest() function examines all meshes associated with a STEP object and returns the mesh that was created with the largest geometric tolerance.

stixmesh_cache_find_finest()

StixMesh * stixmesh_cache_find_finest(
        RoseObject * obj
        );

The stixmesh_cache_find_finest() function examines all meshes associated with a STEP object and returns the mesh that was created with the smallest geometric tolerance.

stixmesh_cache_remove()

void stixmesh_cache_remove (
        RoseObject * obj, 
        StixMesh * mesh
        );

The stixmesh_cache_remove() function removes a particular mesh from the cache associated with a STEP object. Since the mesh is no longer cached, remember to delete it when you are finished with it. Use stixmesh_cache_delete() instead if you just want to delete all meshes.

stixmesh_count_shapes_asm()

unsigned stixmesh_count_shapes_asm(
        stp_representation * sr,
        rose_uint_vector * roots
        );

The stixmesh_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.

stixmesh_create()

StixMesh * stixmesh_create(
        stp_representation * rep,
        stp_representation_item * shell,
        RoseMeshOptions opts=0
        );

StixMesh * stixmesh_create(
        stp_representation * rep,
        RoseMeshOptions opts=0
        );

The stixmesh_create() functions facet and return a detached mesh for the given representation item. The caller must delete the mesh when no longer needed. The functions use the worker API to render the mesh, so it may use multiple threads, but it waits until the mesh is complete to return. It is more efficient to use stixmesh_worker_render() if you need to mesh multiple shells.

The version that takes a representation and representation_item expects one of the shell types that the faceter can handle, or a single face. The version that takes just a representation searches for a shell type in the items set.

stixmesh_create_ap242_product_for_shape_rep()

stp_product * stixmesh_create_ap242_product_for_shape_rep(
        stp_shape_representation * rep
	);

The stixmesh_create_ap242_product_for_shape_rep function creates an AP242 product structure (e.g. product, product_definition_formation, product_definition and other associated instances). For a given shape_representation. The fields are filled in with the constants for AP242. This is a convenience function to create valid STEP file when writing out tessellated geometry.

stixmesh_create_tessellated_shape_rep()

stp_tessellated_shape_representation * stixmesh_create_tessellated_shape_rep(
        RoseDesign * targ_des,
        const RoseMesh * fs,
        stp_representation_context * ctx,
        stp_manifold_solid_brep * geom_link = 0
        );

The stixmesh_create_tessellated_shape_rep creates an AP242 tessellated shape representation for a given mesh. This function calls stixmesh_create_tessellated_solid() to create a solid from the mesh and then creates a shape representation object to hold the solid.

The ctx context parameter specifies the units for the resulting shape representation.

If the optional geom_link parameter is given, the resulting solid point back to this brep through its geometric_link field. This parameter should be the original brep that was faceted to make the mesh, and the target design should be the same design as the original data. This will also set the geometric link for each tesselated face back to the original STEP face that was faceted to make the mesh face.

stixmesh_create_tessellated_solid()

stp_tessellated_solid * stixmesh_create_tessellated_solid(
        RoseDesign * targ_des,
        const RoseMesh * fs,
        stp_manifold_solid_brep * geom_link = 0
        );

The stixmesh_create_tessellated_solid() function creates an AP242 tessellated solid from a mesh. The resulting solid will have faces corresponding to any found in the mesh.

If the optional geom_link parameter is given, the resulting solid point back to this brep through its geometric_link field. This parameter should be the original brep that was faceted to make the mesh, and the target design should be the same design as the original data. This will also set the geometric link for each tesselated face back to the original STEP face that was faceted to make the mesh face.

stixmesh_export_3mf()

int stixmesh_export_3mf(
	const char * o_3mf,
	stp_representation * shape,
	RoseMeshWorkerContext * wc
	);

int stixmesh_export_3mf(
	const char * o_3mf,
	SetOfstp_representation * shapes,
	RoseMeshWorkerContext * wc
	);

int stixmesh_export_3mf(
	const char * o_3mf,
	StpAsmProductDefVec * roots,
	RoseMeshWorkerContext * wc
	);

int stixmesh_export_3mf(
	const char * o_3mf,
	RoseDesign * des,
	RoseMeshWorkerContext * wc
	);

The stixmesh_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.

stixmesh_flavor_is_bad_orientation()

int stixmesh_flavor_is_bad_orientation(
        stp_representation_item * face
        );

The stixmesh_flavor_is_bad_orientation function returns true if the shape representation has unusable orientation data. If this is true, the rendered shell will not be usable for geometric analysis, and if the part is visualized, it must be colored on both sides.

stixmesh_flavor_resolve()

void stixmesh_flavor_resolve(
        RoseDesign * des
        );

The stixmesh_favor_resolve() function searches a RoseDesign for known quality issues that cannot be resolved in any other way. Currently, it looks for files generated by a CAM system in which the face senses are incorrect, resulting in bad topology, and the faces need to be drawn two-sided.

stixmesh_get_color()

unsigned stixmesh_get_color(
        stp_representation_item * it
        );

The stixmesh_get_color() function gets the color of a representation item based of the presentation information associated with the item. You must call stixmesh_resolve_presentation() before using this function.

If the item does not have an assigned color, the function return STIXMESH_NULL_COLOR The color is a packed RGB code is returned as an unsigned value. To decode this:

unsigned rgb = stixmesh_get_color(it);
unsigned red   = (rgb & 0xff0000) >> 16;
unsigned green = (rgb & 0x00ff00) >> 8;
unsigned blue  = (rgb & 0x0000ff);

stixmesh_get_constructive_geometry()

StixMeshConstructiveGeomVec * stixmesh_get_constructive_geometry(
        stp_representation * shape
        );

The stixmesh_get_constructive_geometry() function returns the constructive geometry associated with with a STEP shape. You must call stixmesh_resolve_presentation() before using this function. This function return null if the shape has no associated construcive geometry.

The returns value is an instance of type StixMeshConstructiveGeomVec. This is a subtype of rose_vector containing elements of type stp_constructive_geometry_representation.

stixmesh_get_draughting_info()

StixMeshDraughtingInfoVec * stixmesh_get_draughting_info(
        RoseObject * identified_item
        );

struct StixMeshDraughtingInfo {
        stp_geometric_item_specific_usage * gisu;
        stp_draughting_model_item_association * dmia;
};

The stixmesh_get_draughting_info() function returns the draughting information associated with a given STEP object. You must call stixmesh_resolve_presentation() before using this function. If there is no draughting information assiciated with the shape, this function return null.

The identified_item parameter is an object that is reference by the geometric_item_specific_usage object in the draughting model. This will often be a face to which an annotation applies.

stixmesh_get_draughting_models()

StixMeshRepresentationVec * stixmesh_get_draughting_models(
        stp_shape_representation * shape
        );

The stixmesh_get_draughting_models() function returns the draughting models associated with with a STEP shape. You must call stixmesh_resolve_presentation() before using this function. If there is no draughting model assiciated with the shape, this function return null.

The returns value is an instance of type StixMeshRepresentationVec. This is a subtype of rose_vector containing elements of type stp_representation.

stixmesh_get_estimated_bounding_box()

int stixmesh_get_estimated_bounding_box(
        RoseBoundingBox * bbox,
        stp_face * face,
        stp_representation * rep
        );

int stixmesh_get_estimated_bounding_box(
        RoseBoundingBox * bbox,
        stp_curve_bounded_surface * surf,
        stp_representation * rep
        );

The stixmesh_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.

stixmesh_get_stp_face()

stp_representation_item * stixmesh_get_stp_face(
	const RoseMeshFace * face
	);
stp_representation_item * stixmesh_get_stp_face(
	const RoseMesh * fs,
	unsigned face_idx
	);

The stixmesh_get_stp_face() function finds the STEP face property associated with a mesh face and returns the STEP representation item object. If no face association is present, the function will return NULL.

stixmesh_get_stp_faceinfo()

const RoseMeshFaceInfo * stixmesh_get_stp_faceinfo(
	const RoseMeshFace * face
	);
const RoseMeshFaceInfo * stixmesh_get_stp_faceinfo(
	const RoseMesh * fs,
	unsigned face_idx
	);

The stixmesh_get_stp_faceinfo() function finds the STEP face property associated with a mesh face. If no face property is present, the function will return NULL. The property holds rendering status information.

stixmesh_get_styled_items()

StixMeshStyledItemVec * stixmesh_get_styled_items(
	stp_representation_item * it
	);

The stixmesh_get_styled_items() function returns a rose_vector subtype containing styled items that refer to a given representation item.

stixmesh_get_trim_bounding_box()

RoseBoundingBox * stixmesh_get_trim_bounding_box(
        stp_face * face,
        stp_representation * rep
        );

RoseBoundingBox * stixmesh_get_trim_bounding_box(
        stp_curve_bounded_surface * surf,
        stp_representation * rep
        );

The stixmesh_get_trim_bouding_box() functions compute the bounding box of the trim curves of a face or surface.

stixmesh_get_uncertainty()

double stixmesh_get_uncertainty(	
	stp_representation_context * rc
	);

double stixmesh_get_uncertainty(
	stp_representation * rep
	);

The stixmesh_get_uncertainty() function calls stix_get_context_uncertainty(), but substitutes a default value converted to the representation length unit if no uncertainty is given.

stixmesh_has_shell()

int stixmesh_has_shell(
        stp_shape_representation * sr
        );

The stixmesh_has_shell() function determines if a given STEP representation contains a shell. It return 1 if the representation has a shell, 0 otherwise.

stixmesh_init()

void stixmesh_init();

The stixmesh_init() function should be called before any other operations in the faceter library are. This function sets the FPU using rose_mesh_fpu_save() to make sure that computations done by the faceter library are consistent.

The stixmesh_shutdown() function restores the FPU..

stixmesh_is_inside()

void stixmesh_is_inside(
        RoseReal2DArray * verts,
        double pt[2]
);

The stixsim_is_inside() function determines if a given 2D point is inside the given 2D polygon. This can be used to determine if a point in UV space is on the face.

stixmesh_resolve_presentation()

void stixmesh_resolve_presentation(
        RoseDesign * des
        );

The stixmesh_resolve_presentation() function scans a model for presentation information, and stores the data is RoseManager objects. This cached presentation information can then be retrieved using the stixmesh_get_color(), stixmesh_get_constructive_geometry() , stixmesh_get_draughting_models().

stixmesh_save_stp_shell()

void stixmesh_save_stp_shell(
        RoseXMLWriter * xml, 
        const StixMesh * shell, 
        const char * id,
        unsigned color
        );

void stixmesh_save_stp_shell(
        RoseXMLWriter * xml, 
        RoseMeshXMLOpts * opts,
        const StixMesh * shell, 
        const char * id,
        unsigned color
        );

void stixmesh_save_stp_shell(
        const char * fname, 
        const StixMesh * shell, 
        const char * id,
        unsigned color
        );

void stixmesh_save_stp_shell(
        const char * fname, 
        RoseMeshXMLOpts * opts,
        const StixMesh * shell, 
        const char * id,
        unsigned color
        );

The stixmesh_save_stp_shell() functions write mesh to an XML file. These differ from the stixmesh_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.

stixmesh_shutdown()

void stixmesh_shutdown();

The stixmesh_shutdown function restores FPU status to previous settings if necessary using using rose_mesh_fpu_restore().

stixmesh_worker_cancel()

void stixmesh_worker_cancel(
	stp_representation * rep,
	stp_representation_item * item,
	RoseMeshWorkerContext * context
	);

The stixmesh_worker_cancel() function finds the builder for the context, representation, and item. If one exists, it cancels any faceting.

stixmesh_worker_find_builder()

StixMeshBuilder * stixmesh_worker_find_builder(
	stp_representation * rep,
	stp_representation_item * item,
	RoseMeshWorkerContext * context = 0
	);

The stixmesh_worker_find_builder() function returns an existing mesh builder for faceting the given context, representation, and item, or null if one has not been created. If the context is omitted, the function returns the first builder found. Use stixmesh_worker_make_builder() to search for the mesh builder and create it if it does not yet exist.

stixmesh_worker_is_design_queued()

int stixmesh_worker_is_design_queued(
	RoseDesign * des,
	RoseMeshWorkerContext * context
	);

The stixmesh_worker_is_design_queued() function returns true if stixmesh_worker_render_design() has already been called on the given design.

stixmesh_worker_make_builder()

StixMeshBuilder * stixmesh_worker_make_builder(
	stp_representation * rep,
	stp_representation_item * item,
	RoseMeshWorkerContext * context
	);

The stixmesh_worker_make_builder() function creates or returns an existing mesh builder for faceting the given context, representation, and item. If one exists, it is returned, otherwise a new builder is created and cached with the representation_item for future use. The stixmesh_worker_find_builder() function just looks for the mesh builder but does not create one.

stixmesh_worker_remove_builder()

int stixmesh_worker_remove_builder(
	stp_representation * rep,
	stp_representation_item * item,
	RoseMeshWorkerContext * context
	);

The stixmesh_worker_remove_builder() function finds the builder for the context, representation, and item. If one exists, it cancels any faceting and then deletes the builder.

stixmesh_worker_render()

int stixmesh_worker_render(
	stp_representation * rep,
	stp_representation_item * item,
	RoseMeshWorkerContext * context
	);

The stixmesh_worker_render() function calls stixmesh_worker_make_builder() to find or create a builder, and then rose_mesh_worker_render() to submit it to the processing queue.

stixmesh_worker_render_design()

void stixmesh_worker_render_design(
	RoseDesign * des,
	RoseMeshWorkerContext * context,
	int force = 0   /* render the design, even it it has already been done*/
	);

The stixmesh_worker_render_design() function creates workers for all of the shells in a design and submits them to the processing queue. Afterwards, you can find the mesh for a particular shell by calling stixmesh_worker_find_builder() and getting the mesh from that with StixMeshBuilder::getStpMesh().

RoseDesign * d;
RoseMeshWorkerContext context;
RoseMeshOptions facet_opts;
context.setFacetOptions(&facet_opts);

// create meshes for everything in the design
stixmesh_worker_render_design(d, &context);
rose_mesh_worker_wait_all();

stixmesh_worker_wait()

const StixMesh * stixmesh_worker_wait(
	stp_representation * rep,
	stp_representation_item * item,
	RoseMeshWorkerContext * context,
	int flush=1
	);

The stixmesh_worker_wait() function finds the builder for the given context, representation, and item, and calls rose_mesh_worker_wait() to block until faceting of the item is complete.