We collect in this namespace all utilities which operate on OpenCASCADE entities. OpenCASCADE splits every object into a topological description and a geometrical entity. The basic topological description is a TopoDS_Shape. TopoDS_Shapes are light objects, and can be copied around. The closest deal.II analog is a TriaIterator.
The OpenCASCADE topology is designed with reference to the STEP standard ISO-10303-42. The structure is an oriented one-way graph, where parents refer to their children, and there are no back references. Abstract structure is implemented as C++ classes from the TopoDS package. A TopoDS_Shape is manipulated by value and contains 3 fields: location, orientation and a myTShape handle (of the TopoDS_TShape type). According to OpenCASCADE documentation, myTShape and Location are used to share data between various shapes to save memory. For example, an edge belonging to two faces has equal Locations and myTShape fields but different Orientations (Forward in context of one face and Reversed in one of the other).
Valid shapes include collection of other shapes, solids, faces, edges, vertices, etc.
Once a topological description is available, if a concrete geometrical object can be created, the BRep classes allow one to extract the actual geometrical information from a shape.
This is done by inheriting abstract topology classes from the TopoDS package by those implementing a boundary representation model (from the BRep package). Only 3 types of topological objects have geometric representations – vertex, edge, and face.
Every TopoDS_Shape can be queried to figure out what type of shape it is, and actual geometrical objects, like surfaces, curves or points, can be extracted using BRepTools.
In this namespace we provide readers and writers that read standard CAD files, and return a TopoDS_Shape, or that write a CAD file, given a TopoDS_Shape. Most of the functions in the OpenCASCADE namespace deal with TopoDS_Shapes of one type or another, and provide interfaces to common deal.II objects, like Triangulation, Manifold, and so on.
Notice that most of these tools are only useful when spacedim is equal to three, since OpenCASCADE only operates in three-dimensional mode. In some cases they can be used in two dimensions as well, and the third dimension will be set to zero.
If you wish to use these tools when the dimension of the space is two, then make sure your CAD files are actually flat and that all z coordinates are equal to zero, as otherwise you will get many exceptions.
Count the subobjects of a shape. This function is useful to gather information about the TopoDS_Shape passed as argument. It returns the number of faces, edges and vertices (the only topological entities associated with actual geometries) which are contained in the given shape.
Definition at line 88 of file utilities.cc.
Read IGES files and translate their content into openCascade topological entities. The option scale_factor is used to compensate for different units being used in the IGES files and in the target application. The standard unit for IGES files is millimiters. The return object is a TopoDS_Shape which contains all objects from the file.
Definition at line 238 of file utilities.cc.
Write the given topological shape into an IGES file.
Definition at line 267 of file utilities.cc.
Read STL files and translate their content into openCascade topological entities. The return object is a TopoDS_Shape which contains all objects from the file.
Definition at line 280 of file utilities.cc.
Write the given topological shape into an STL file. In order to do so the shape must contain a mesh structure, the function checks if all the faces of the shape have an attached mesh, if this is not the case it proceeds to mesh it automatically. We remark that the automatic mesh generation in OpenCASCADE takes care only of the geometrical resemblance between the shape and the mesh, to control the shape and regularity of the triangles you should use other meshing softwares. The two arguments
deflection and
angular_deflection select the accuracy of the created triangulation with respect to the orginal topological shape. The argument
sew_different_faces gives the possibility to use a Sewer from OpenCASCADE to create a watertight closed STL using the argument
sewer_tolerance. The argument
is_relative specifies if distance are relative and
in_parallel if the execution should be in parallel.
Definition at line 290 of file utilities.cc.
Read STEP files and translate their content into openCascade topological entities. The option scale_factor is used to compensate for different units being used in the STEP files and in the target application. The standard unit for STEP files is millimiters. The return object is a TopoDS_Shape which contains all objects from the file.
Definition at line 360 of file utilities.cc.
Write the given topological shape into an STEP file.
Definition at line 389 of file utilities.cc.
This function returns the tolerance associated with the shape. Each CAD geometrical object is defined along with a tolerance, which indicates possible inaccuracy of its placement. For instance, the tolerance of a vertex indicates that it can be located in any point contained in a sphere centered in the nominal position and having radius tol. While carrying out an operation such as projecting a point onto a surface (which will in turn have its tolerance) we must keep in mind that the precision of the projection will be limited by the tolerance with which the surface is built. The tolerance is computed taking the maximum tolerance among the subshapes composing the shape.
Definition at line 405 of file utilities.cc.
Perform the intersection of the given topological shape with the plane \(c_x x + c_y y + c_z z +c = 0\). The returned topological shape will contain as few bsplines as possible. An exception is thrown if the intersection produces an empty shape.
Definition at line 429 of file utilities.cc.
Try to join all edges contained in the given TopoDS_Shape into a single TopoDS_Edge, containing as few BSPlines as possible. If the input shape contains faces, they will be ignored by this function. If the contained edges cannot be joined into a single one, i.e., they form disconnected curves, an exception will be thrown.
Definition at line 443 of file utilities.cc.
Creates a smooth BSpline curve passing through the points in the assigned vector, and store it in the returned TopoDS_Shape (which is of type TopoDS_Edge). The points are reordered internally according to their scalar product with the direction, if direction is different from zero, otherwise they are used as passed. Notice that this function changes the input points if required by the algorithm.
This class is used to interpolate a BsplineCurve passing through an array of points, with a C2 Continuity. If the optional parameter
closed is set to true, then the curve will be C2 at all points except the first (where only C1 continuity will be given), and it will be a closed curve.
The curve is guaranteed to be at distance
tolerance from the input points. If the algorithm fails in generating such a curve, an exception is thrown.
Definition at line 557 of file utilities.cc.
Extract all subshapes from a TopoDS_Shape, and store the results into standard containers. If the shape does not contain a certain type of shape, the respective container will be empty.
Definition at line 107 of file utilities.cc.
Create a triangulation from a single face. This class extracts the first u and v parameter of the parametric surface making up this face, and creates a Triangulation<2,spacedim> containing a single coarse cell reflecting this face. If the surface is not a trimmed surface, the vertices of this cell will coincide with the TopoDS_Vertex vertices of the original TopoDS_Face. This, however, is often not the case, and the user should be careful on how this mesh is used.
If you call this function with a Triangulation<2,2>, make sure that the input face has all z coordinates set to zero, or you'll get an exception.
Definition at line 891 of file utilities.cc.
Given a Triangulation and an optional Mapping, create a vector of smooth curves that interpolate the connected parts of the boundary vertices of the Triangulation and return them as a vector of TopoDS_Edge objects.
This function constructs closed Bspline curve objects passing through all vertices of the boundary of the triangulation, with \(C^2\) Continuity on each vertex except the first, where only \(C^1\) continuity is guaranteed.
The returned curves are ordered with respect to the indices of the faces that make up the triangulation boundary, i.e., the first curve is the one extracted starting from the face with the lowest index, and so on.
triangulation
Definition at line 600 of file utilities.cc.
Extract all compound shapes from a TopoDS_Shape, and store the results into standard containers. If the shape does not contain a certain type of compound, the respective container will be empty.
Definition at line 133 of file utilities.cc.
Project the point
origin on the topological shape given by
in_shape, and returns the projected point, the subshape which contains the point and the parametric u and v coordinates of the point within the resulting shape. If the shape is not elementary, all its subshapes are iterated, faces first, then edges, and the returned shape is the closest one to the point
origin. If the returned shape is an edge, then only the u coordinate is filled with sensible information, and the v coordinate is set to zero.
This function returns a tuple containing the projected point, the shape, the u coordinate and the v coordinate (which is different from zero only if the resulting shape is a face).
Definition at line 704 of file utilities.cc.
Return the projection of the point
origin on the topological shape given by
in_shape. If the shape is not elementary, all its subshapes are iterated, faces first, then edges, and the returned point is the closest one to the
in_shape, regardless of its type.
Definition at line 787 of file utilities.cc.
Given an elementary shape
in_shape and the reference coordinates within the shape, returns the corresponding point in real space. If the shape is a TopoDS_Edge, the
v coordinate is ignored. Only edges or faces, as returned by the function project_point_and_pull_back(), can be used as input to this function. If this is not the case, an Exception is thrown.
Definition at line 833 of file utilities.cc.
Given a TopoDS_Face
face and the reference coordinates within this face, returns the corresponding point in real space, the normal to the surface at that point and the min and max curvatures as a tuple.
Definition at line 854 of file utilities.cc.
Get the closest point to the given topological shape, together with the normal and the min and max curvatures at that point. If the shape is not elementary, all its sub-faces (only the faces) are iterated, faces first, and only the closest point is returned. This function will throw an exception if the
in_shape does not contain at least one face.
Definition at line 797 of file utilities.cc.
Intersect a line passing through the given
origin point along
direction and the given topological shape. If there is more than one intersection, it will return the closest one.
The optional
tolerance parameter is used to compute distances.
Definition at line 511 of file utilities.cc.
Convert OpenCASCADE point into a Point<spacedim>.
The tolerance argument is used to check if the non used components of the OpenCASCADE point are close to zero. If this is not the case, an assertion is thrown in debug mode.
Definition at line 188 of file utilities.cc.
Convert Point<3> into OpenCASCADE point.
Definition at line 171 of file utilities.cc.
Sort two points according to their scalar product with direction. If the norm of the direction is zero, then use lexicographical ordering. The optional parameter is used as a relative tolerance when comparing objects.
Definition at line 215 of file utilities.cc.