Class t8_cad_handle

Class Documentation

class t8_cad_handle

This class manages OpenCASCADE shapes and implements helper functions for working with the shapes.

Public Functions

t8_cad_handle(const std::string_view fileprefix)

Constructor of the cad shape handle.

The shape is initialized based on a .brep file with the given prefix. The internal structure extracts and stores geometric information such as vertices, edges, and faces from this file. The number and type of vertices should match the tree type (quad/hex/tri), and the cad data must be valid. This constructor is intended for general use, including file-based mesh creation.

Parameters:

fileprefix[in] Prefix of a .brep file from which to extract cad geometry.

t8_cad_handle(TopoDS_Shape cad_shape_in)

Constructor of the cad shape.

The shape is initialized directly from an existing TopoDS_Shape. This constructor is especially useful for use in scripts, testing, or integration with mesh generators that already provide geometry in memory. It avoids file I/O and allows full control over the CAD input.

Parameters:

cad_shape_in[in] cad shape geometry object.

t8_cad_handle()

Constructor of the cad shape for testing purposes.

Sets an invalid cad_shape.

~t8_cad_handle()

Destructor of the cad shape handle.

void load(const std::string_view fileprefix)

Loads a cad shape from a .brep file with the given prefix and maps it.

Parameters:

fileprefix[in] Prefix of a .brep file from which to extract cad geometry.

void load(TopoDS_Shape cad_shape_in)

Loads a cad shape from an existing TopoDS_Shape and maps it.

Parameters:

cad_shape_in[in] The input cad shape.

int is_line(const int curve_index) const

Check if a cad_curve is a line.

Parameters:

curve_index[in] The index of the cad_curve.

Returns:

1 if curve is a line, 0 if curve is not a line.

int is_plane(const int surface_index) const

Check if a cad_surface is a plane.

Parameters:

surface_index[in] The index of the cad_surface.

Returns:

1 if surface is a plane linear, 0 if surface is not a plane.

const TopoDS_Vertex get_cad_vertex(const int index) const

Get a cad vertex from the cad_shape.

Parameters:

index[in] The index of the vertex in the cad_shape.

Returns:

The cad vertex.

const TopoDS_Edge get_cad_edge(const int index) const

Get a cad edge from the cad_shape.

Parameters:

index[in] The index of the edge in the cad_shape.

Returns:

The cad edge.

const TopoDS_Face get_cad_face(const int index) const

Get a cad face from the cad_shape.

Parameters:

index[in] The index of the face in the cad_shape.

Returns:

The cad face.

const gp_Pnt get_cad_point(const int index) const

Get a cad point from the cad_shape.

Parameters:

index[in] The index of the point in the cad_shape.

Returns:

The cad point.

const Handle_Geom_Curve get_cad_curve(const int index) const

Get a cad curve from the cad_shape.

Parameters:

index[in] The index of the curve in the cad_shape.

Returns:

The cad curve.

const Handle_Geom_Surface get_cad_surface(const int index) const

Get a cad surface from the cad_shape.

Parameters:

index[in] The index of the surface in the cad_shape.

Returns:

The cad surface.

const TopTools_IndexedMapOfShape get_cad_shape_vertex_map() const

Get the cad_shape_vertex2edge_map.

Returns:

The cad_shape_vertex_map.

const TopTools_IndexedMapOfShape get_cad_shape_edge_map() const

Get the cad_shape_edge2face_map.

Returns:

The cad_shape_edge_map.

const TopTools_IndexedMapOfShape get_cad_shape_face_map() const

Get the cad_shape_face_map.

Returns:

The cad_shape_face_map.

int get_common_edge_of_vertices(const int vertex1_index, const int vertex2_index) const

Check if two cad points share a common cad edge.

Parameters:
  • vertex1_index[in] The index of the first cad point.

  • vertex2_index[in] The index of the second cad point.

Returns:

Index of the shared edge. 0 if there is no shared edge.

int get_common_face_of_edges(const int edge1_index, const int edge2_index) const

Check if two cad edges share a common cad face.

Parameters:
  • edge1_index[in] The index of the first cad edge.

  • edge2_index[in] The index of the second cad edge.

Returns:

Index of the shared face. 0 if there is no shared face.

int get_common_face_of_vertex_and_edge(const int vertex_index, const int edge_index) const

Check if a cad vertex and cad edge share a common face.

Parameters:
  • vertex_index[in] The index of the cad vertex.

  • edge_index[in] The index of the cad edge.

Returns:

Index of the shared face. 0 if there is no shared face.

int get_common_face_of_vertices(const int vertex1_index, const int vertex2_index) const

Check if two cad vertices share a common cad face.

Parameters:
  • vertex1_index[in] The index of the first cad edge.

  • vertex2_index[in] The index of the second cad edge.

Returns:

Index of the shared face. 0 if there is no shared face.

int is_vertex_on_edge(const int vertex_index, const int edge_index) const

Check if a cad vertex lies on an cad edge.

Parameters:
  • vertex_index[in] The index of the cad vertex.

  • edge_index[in] The index of the cad edge.

Returns:

1 if vertex lies on edge, otherwise 0.

int is_edge_on_face(const int edge_index, const int face_index) const

Check if a cad vertex lies on an cad edge.

Parameters:
  • edge_index[in] The index of the cad vertex.

  • face_index[in] The index of the cad edge.

Returns:

1 if vertex lies on edge, otherwise 0.

int is_vertex_on_face(const int vertex_index, const int face_index) const

Check if a cad vertex lies on an cad face.

Parameters:
  • vertex_index[in] The index of the cad vertex.

  • face_index[in] The index of the cad face.

Returns:

1 if vertex lies on face, otherwise 0.

bool vertex_is_seam(const int vertex_index, const int edge_index) const

Returns true if vertex_index is on a seam of edge_index.

A seam is a vertex which connects a curve to itself.

Parameters:
  • vertex_index[in] The index of the cad vertex.

  • edge_index[in] The index of the cad edge.

Returns:

true if the vertex is a seam. false otherwise.

bool vertex_is_on_seam_edge(const int vertex_index, const int face_index) const

Returns true if vertex_index is on a seam of face_index.

A seam is an edge which connects a surface to itself.

Parameters:
  • vertex_index[in] The index of the cad vertex.

  • face_index[in] The index of the cad face.

Returns:

true if the edge is a seam. false otherwise.

bool edge_is_seam(const int edge_index, const int face_index) const

Returns true if edge_index is a seam of face_index.

A seam is an edge which connects a surface to itself.

Parameters:
  • edge_index[in] The index of the cad edge.

  • face_index[in] The index of the cad face.

Returns:

true if the edge is a seam. false otherwise.

void get_parameter_of_vertex_on_edge(const int vertex_index, const int edge_index, double *edge_param, std::optional<double> reference_edge_param = std::nullopt) const

Retrieves the parameter of an cad vertex on an cad edge.

The vertex has to lie on the edge.

Warning

If the edge is closed in any direction and the vertex is the closing bound, it is random which side of the closed edge the parameter is from. The parameter is correct, but for curved elements it has to be checked if the parameter has to be converted onto the other bound.

Parameters:
  • vertex_index[in] The index of the cad vertex.

  • edge_index[in] The index of the cad edge.

  • edge_param[out] The parameter of the vertex on the edge.

  • reference_edge_param[in] Reference parameters on the edge.

void get_parameters_of_vertex_on_face(const int vertex_index, const int face_index, double face_params[2], std::optional<std::span<const double, 2>> reference_face_params = std::nullopt) const

Retrieves the parameters of an cad vertex on a cad face.

The vertex has to lie on the face. If the vertex is in a seam, the vertex closer to the reference_face_params is chosen.

Warning

If the face is closed in any direction and the vertex is on the seam and no reference parameters are provided it is random which side of the closed face the parameters are from. The parameters are correct, but for curved elements it has to be checked if the parameters have to be converted onto the other bound.

Parameters:
  • vertex_index[in] The index of the cad vertex.

  • face_index[in] The index of the cad face.

  • face_params[out] The parameters of the vertex on the face.

  • reference_face_params[in] Reference parameters on the surface.

void edge_parameter_to_face_parameters(const int edge_index, const int face_index, const double edge_param, double face_params_out[2], std::optional<std::span<const double, 2>> reference_face_params = std::nullopt) const

Converts the parameters of a cad edge to the corresponding parameters on a cad face.

The edge has to lie on the face. If the edge is a seam, the edge closer to the reference_face_params is chosen.

Warning

If the face is closed in any direction and the edge is the seam and no reference parameters are provided it is random which side of the closed face the parameters are from. The parameters are correct, but for curved elements it has to be checked if the parameters have to be converted onto the other side of the seam.

Parameters:
  • edge_index[in] The index of the cad edge, which parameters should be converted to face parameters.

  • face_index[in] The index of the cad face, on to which the edge parameters should be converted.

  • edge_param[in] The parameter on the edge.

  • face_params_out[out] The corresponding parameters on the face.

  • reference_face_params[in] Reference parameters on the surface.

void get_face_parametric_bounds(const int surface_index, double *bounds) const

Finds the parametric bounds of an cad face.

Parameters:
  • surface_index[in] The index of the cad face.

  • bounds[out] The parametric bounds of the cad face.

void get_edge_parametric_bounds(const int edge_index, double *bounds) const

Finds the parametric bounds of an cad edge.

Parameters:
  • edge_index[in] The index of the cad edge.

  • bounds[out] The parametric bounds of the cad edge.

int edge_is_closed(int edge_index) const

Checks if an edge is closed.

Parameters:

edge_index[in] The index of the closed edge.

Returns:

true if edge is closed

inline void ref()

Increase the reference count of the cad handle.

inline void unref()

Decrease the reference count of the cad handle.

If the reference count reaches zero, the cad handle is deleted.

bool surface_is_closed(int geometry_index) const

Checks if a surface is closed in any direction.

Parameters:

geometry_index[in] The index of the closed geometry.

Returns:

true if geometry is closed in any direction.

bool surface_is_closed(int geometry_index, int direction) const

Checks if a surface is closed in its U direction or V direction.

Parameters:
  • geometry_index[in] The index of the closed geometry.

  • direction[in] The direction, which should be check for closeness. 0 stands for the U direction and 1 for the V direction.

Returns:

true if geometry is closed in the given direction.