![]() |
Open CASCADE Technology
6.7.0
|
|
This manual explains how to use the Modeling Algorithms. It provides basic documentation on modeling algorithms. For advanced information on Modeling Algorithms, see our offerings on our web site at www.opencascade.org/support/training/
The Modeling Algorithms module brings together a wide range of topological algorithms used in modeling. Along with these tools, you will find the geometric algorithms, which they call.
The algorithms available are divided into:
The Topology API of Open CASCADE Technology (OCCT) includes the following six packages:
The classes in these six packages provide the user with a simple and powerful interface.
As an example, the class BRepBuilderAPI_MakeEdge can be used to create a linear edge from two points.
This is the simplest way to create edge E from two points P1, P2, but the developer can test for errors when he is not as confident of the data as in the previous example.
In this example an intermediary object ME has been introduced. This can be tested for the completion of the function before accessing the result. More information on error handling in the topology programming interface can be found in the next section.
BRepBuilderAPI_MakeEdge provides valuable information. For example, when creating an edge from two points, two vertices have to be created from the points. Sometimes you may be interested in getting these vertices quickly without exploring the new edge. Such information can be provided when using a class. The following example shows a function creating an edge and two vertices from two points.
The BRepBuilderAPI_MakeEdge class provides the two methods Vertex1 and Vertex2, which return the two vertices used to create the edge.
How can BRepBuilderAPI_MakeEdge be both a function and a class? It can do this because it uses the casting capabilities of C++. The BRepBuilderAPI_MakeEdge class has a method called Edge; in the previous example the line E = ME could have been written.
This instruction tells the C++ compiler that there is an implicit casting of a BRepBuilderAPI_MakeEdge into a TopoDS_Edge using the Edge method. It means this method is automatically called when a BRepBuilderAPI_MakeEdge is found where a TopoDS_Edge is required.
This feature allows you to provide classes, which have the simplicity of function calls when required and the power of classes when advanced processing is necessary. All the benefits of this approach are explained when describing the topology programming interface classes.
A method can report an error in the two following situations:
The second situation is supposed to become increasingly exceptional as a system is debugged and it is handled by the exception mechanism. Using exceptions avoids handling error statuses in the call to a method: a very cumbersome style of programming.
In the first situation, an exception is also supposed to be raised because the calling method should have verified the arguments and if it did not do so, there is a bug. For example if before calling MakeEdge you are not sure that the two points are non-identical, this situation must be tested.
Making those validity checks on the arguments can be tedious to program and frustrating as you have probably correctly surmised that the method will perform the test twice. It does not trust you. As the test involves a great deal of computation, performing it twice is also time-consuming.
Consequently, you might be tempted to adopt the highly inadvisable style of programming illustrated in the following example:
To help the user, the Topology API classes only raise the exception StdFail_NotDone. Any other exception means that something happened which was unforeseen in the design of this API.
The NotDone exception is only raised when the user tries to access the result of the computation and the original data is corrupted. At the construction of the class instance, if the algorithm cannot be completed, the internal flag NotDone is set. This flag can be tested and in some situations a more complete description of the error can be queried. If the user ignores the NotDone status and tries to access the result, an exception is raised.
Open CASCADE Technology geometric tools include:
The Geom2dAPI_InterCurveCurve class allows the evaluation of the intersection points (gp_Pnt2d) between two geometric curves (Geom2d_Curve) and the evaluation of the points of self-intersection of a curve.
This class may be instantiated either for intersection of curves C1 and C2.
or for self-intersection of curve C3.
Calls the number of intersection points
To select the desired intersection point, pass an integer index value in argument.
To call the number of intersection segments, use
To select the desired intersection segment pass integer index values in argument.
If you need access to a wider range of functionalities the following method will return the algorithmic object for the calculation of intersections:
The GeomAPI_IntCS class is used to compute the intersection points between a curve and a surface.
This class is instantiated as follows:
To call the number of intersection points, use:
Where Index is an integer between 1 and nb, calls the intersection points.
The GeomAPI_IntSS class is used to compute the intersection of two surfaces from Geom_Surface with respect to a given tolerance.
This class is instantiated as follows:
Once the GeomAPI_IntSS object has been created, it can be interpreted.
Calls the number of intersection curves.
Where Index is an integer between 1 and nb, calls the intersection curves.
Interpolation provides functionalities for interpolating BSpline curves, whether in 2D, using Geom2dAPI_Interpolate, or 3D using GeomAPI_Interpolate.
This class is used to interpolate a BSplineCurve passing through an array of points. If tangency is not requested at the point of interpolation, continuity will be C2. If tangency is requested at the point, continuity will be C1. If Periodicity is requested, the curve will be closed and the junction will be the first point given. The curve will then have a continuity of C1 only. This class may be instantiated as follows:
It is possible to call the BSpline curve from the object defined above it.
Note that the Handle(Geom2d_BSplineCurve) operator has been redefined by the method Curve(). Consequently, it is unnecessary to pass via the construction of an intermediate object of the Geom2dAPI_Interpolate type and the following syntax is correct.
This class may be instantiated as follows:
It is possible to call the BSpline curve from the object defined above it.
Note that the Handle(Geom_BSplineCurve) operator has been redefined by the method Curve(). Thus, it is unnecessary to pass via the construction of an intermediate object of the GeomAPI_Interpolate type and the following syntax is correct.
Handle(Geom_BSplineCurve) C = GeomAPI_Interpolate(Points, Standard_False, 1.0e-7);
Boundary conditions may be imposed with the method Load.
There are two packages to create lines and circles from constraints: Geom2dGcc and GccAna. Geom2dGcc deals with reference-handled geometric objects from the Geom2d package, while GccAna deals with value-handled geometric objects from the gp package.
The Geom2dGcc package solves geometric constructions of lines and circles expressed by constraints such as tangency or parallelism, that is, a constraint expressed in geometric terms. As a simple example the following figure shows a line which is constrained to pass through a point and be tangent to a circle.
The Geom2dGcc package deals only with 2d objects from the Geom2d package. These objects are the points, lines and circles available.
All other lines such as Bezier curves and conic sections except for circles are considered general curves and must be differentiable twice.
The GccAna package deals with points, lines, and circles from the gp package. Apart from constructors for lines and circles, it also allows the creation of conics from the bisection of other geometric objects.
The following analytic algorithms using value-handled entities for creation of 2D lines or circles with geometric constraints are available:
There are three categories of available algorithms, which complement each other:
An analytic algorithm will solve a system of equations, whereas a geometric algorithm works with notions of parallelism, tangency, intersection and so on.
Both methods can provide solutions. An iterative algorithm, however, seeks to refine an approximate solution.
The appropriate algorithm is the one, which reaches a solution of the required accuracy in the least time. Only the solutions actually requested by the user should be calculated. A simple means to reduce the number of solutions is the notion of a "qualifier". There are four qualifiers, which are:
It is not hard to define the interior and exterior of a circle. As is shown in the following diagram, the exterior is indicated by the sense of the binormal, that is to say the right side according to the sense of traversing the circle. The left side is therefore the interior (or "material").
It is sometimes necessary to define in advance the sense of travel along a line to be created. This sense will be from first to second argument.
The following figure shows a line, which is first tangent to circle C1 which is interior to the line, and then passes through point P1.
The following four diagrams illustrate four cases of using qualifiers in the creation of a line. The fifth shows the solution if no qualifiers are given.
Note that the qualifier "Outside" is used to mean "Mutually exterior".
Example 1 Case 1
Syntax:
Example 1 Case 2
Syntax:
Example 1 Case 3
Syntax:
Example 1 Case 4
Syntax:
Example 1 Case 5
Syntax:
The following four diagrams show the four cases in using qualifiers in the creation of a circle.
Example 2 Case 1
Syntax:
Example 2 Case 2
Syntax:
Example 2 Case 3
Syntax:
Example 2 Case 4
Syntax:
Example 2 Case 5
The following syntax will give all the circles of radius Rad, which are tangent to C1 and C2 without discrimination of relative position:
The objects created by this toolkit are non-persistent.
The GccEnt package contains the following package methods:
This enables creation of expressions, for example:
The objective in this case is to find all circles of radius Rad, which are tangent to both circle C1 and C2, C1 being outside and C2 being inside.
We consider the following to be the case:
GccAna package implements analytic algorithms. It deals only with points, lines, and circles from gp package. Here is a list of the services offered:
For each algorithm, the tolerance (and angular tolerance if appropriate) is given as an argument. Calculation is done with the highest precision available from the hardware.
*Geom2dGcc *package offers algorithms, which produce 2d lines or circles with geometric constraints. For arguments, it takes curves for which an approximate solution is not requested. A tolerance value on the result is given as a starting parameter. The following services are provided:
All calculations will be done to the highest precision available from the hardware.
Geom2dGcc package offers iterative algorithms find a solution by refining an approximate solution. It produces 2d lines or circles with geometric constraints. For all geometric arguments except points, an approximate solution may be given as a starting parameter. The tolerance or angular tolerance value is given as an argument. The following services are provided:
FairCurve package provides a set of classes to create faired 2D curves or 2D curves with minimal variation in curvature.
The class Batten allows producing faired curves defined on the basis of one or more constraints on each of the two reference points. These include point, angle of tangency and curvature settings. The following constraint orders are available:
Only 0 and 1 constraint orders are used. The function Curve returns the result as a 2D BSpline curve.
The class MinimalVariation allows producing curves with minimal variation in curvature at each reference point. The following constraint orders are available:
Constraint orders of 0, 1 and 2 can be used. The algorithm minimizes tension, sagging and jerk energy.
The function Curve returns the result as a 2D BSpline curve.
If you want to give a specific length to a batten curve, use:
where b is the name of the batten curve object
Free sliding is generally more aesthetically pleasing than constrained sliding. However, the computation can fail with values such as angles greater than p/2, because in this case, the length is theoretically infinite.
In other cases, when sliding is imposed and the sliding factor is too large, the batten can collapse.
The constructor parameters, Tolerance and NbIterations, control how precise the computation is, and how long it will take.
The GeomFill package provides the following services for creating surfaces from boundary curves:
The class BezierCurves allows producing a Bezier surface from contiguous Bezier curves. Note that problems may occur with rational Bezier Curves.
The class BSplineCurves allows producing a BSpline surface from contiguous BSpline curves. Note that problems may occur with rational BSplines.
The class Pipe allows producing a pipe by sweeping a curve (the section) along another curve (the path). The result is a BSpline surface.
The class GeomFill_ConstrainedFilling allows filling a contour defined by two, three or four curves as well as by tangency constraints. The resulting surface is a BSpline.
The class GeomFill_SimpleBound allows you defining a boundary for the surface to be constructed.
The class GeomFill_BoundWithSurf allows defining a boundary for the surface to be constructed. This boundary will already be joined to another surface.
The enumerations FillingStyle specify the styles used to build the surface. These include:
The GeomPlate package provides the following services for creating surfaces respecting curve and point constraints:
The class BuildPlateSurface allows creating a framework to build surfaces according to curve and point constraints as well as tolerance settings. The result is returned with the function Surface.
Note that you do not have to specify an initial surface at the time of construction. It can be added later or, if none is loaded, a surface will be computed automatically.
The class CurveConstraint allows defining curves as constraints to the surface, which you want to build.
The class PointConstraint allows defining points as constraints to the surface, which you want to build.
The class Surface allows describing the characteristics of plate surface objects returned by BuildPlateSurface::Surface using the methods of Geom_Surface
The class MakeApprox allows converting a GeomPlate surface into a Geom_BSplineSurface.
This package provides functionality for projecting points onto 2D and 3D curves and surfaces.
Geom2dAPI_ProjectPointOnCurve allows calculation of all the normals projected from a point (gp_Pnt2d) onto a geometric curve (Geom2d_Curve). The calculation may be restricted to a given domain.
The curve does not have to be a Geom2d_TrimmedCurve. The algorithm will function with any class inheriting Geom2d_Curve.
This class may be instantiated as in the following example:
To restrict the search for normals to a given domain *[U1,U2]*, use the following constructor:
Having thus created the Geom2dAPI_ProjectPointOnCurve object, we can now interrogate it.
The solutions are indexed in a range from 1 to Projector.NbPoints(). The point, which corresponds to a given Index may be found:
For a given point corresponding to a given Index:
This can also be programmed as:
We can find the distance between the initial point and a point, which corresponds to the given Index:
This class offers a method to return the closest solution point to the starting point. This solution is accessed as follows:
Some operators have been redefined to find the closest solution.
Standard_Real() returns the minimum distance from the point to the curve.
Standard_Integer() returns the number of solutions.
gp_Pnt2d() returns the nearest solution point.
Using these operators makes coding easier when you only need the nearest point. Thus:
can be written more concisely as:
However, note that in this second case no intermediate Geom2dAPI_ProjectPointOnCurve object is created, and thus it is impossible to have access to other solution points.
If you want to use the wider range of functionalities available from the Extrema package, a call to the Extrema() method will return the algorithmic object for calculating extrema. For example:
This class is instantiated as in the following example:
If you wish to restrict the search for normals to the given domain [U1,U2], use the following constructor:
Having thus created the GeomAPI_ProjectPointOnCurve object, you can now interrogate it.
The solutions are indexed in a range from 1 to Projector.NbPoints(). The point, which corresponds to a given index, may be found:
For a given point corresponding to a given index:
This can also be programmed as:
The distance between the initial point and a point, which corresponds to a given index, may be found:
This class offers a method to return the closest solution point to the starting point. This solution is accessed as follows:
Some operators have been redefined to find the nearest solution.
Standard_Real() returns the minimum distance from the point to the curve.
Standard_Integer() returns the number of solutions.
gp_Pnt2d() returns the nearest solution point.
Using these operators makes coding easier when you only need the nearest point. In this way,
can be written more concisely as:
In the second case, however, no intermediate GeomAPI_ProjectPointOnCurve object is created, and it is impossible to access other solutions points.
If you want to use the wider range of functionalities available from the Extrema package, a call to the Extrema() method will return the algorithmic object for calculating the extrema. For example:
GeomAPI_ProjectPointOnSurf class allows calculation of all normals projected from a point from gp_Pnt onto a geometric surface from Geom_Surface.
GeomAPI_ProjectPointOnSurf is instantiated as in the following example:
To restrict the search for normals within the given rectangular domain [U1, U2, V1, V2], use the following constructor:
The values of U1, U2, V1 and V2 lie at or within their maximum and minimum limits, i.e.:
Having thus created the GeomAPI_ProjectPointOnSurf object, you can interrogate it.
The solutions are indexed in a range from 1 to Proj.NbPoints(). The point corresponding to the given index may be found:
For a given point corresponding to the given index:
The distance between the initial point and a point corresponding to the given index may be found:
This class offers a method, which returns the closest solution point to the starting point. This solution is accessed as follows:
Some operators have been redefined to help you find the nearest solution.
Standard_Real() returns the minimum distance from the point to the surface.
Standard_Integer() returns the number of solutions.
gp_Pnt2d() returns the nearest solution point.
Using these operators makes coding easier when you only need the nearest point. In this way,
can be written more concisely as:
In the second case, however, no intermediate GeomAPI_ProjectPointOnSurf object is created, and it is impossible to access other solution points.
If you want to use the wider range of functionalities available from the Extrema package, a call to the Extrema() method will return the algorithmic object for calculating the extrema as follows:
The To2d and To3d methods are used to;
These methods are called as follows:
Open CASCADE Technology topological tools include:
The standard topological objects include
There are two root classes for their construction and modification:
BRepBuilderAPI_MakeVertex creates a new vertex from a 3D point from gp.
This class always creates a new vertex and has no other methods.
Use BRepBuilderAPI_MakeEdge to create from a curve and vertices. The basic method is to construct an edge from a curve, two vertices, and two parameters. All other constructions are derived from this one. The basic method and its arguments are described first, followed by the other methods. The BRepBuilderAPI_MakeEdge class can provide extra information and return an error status.
where C is the domain of the edge; V1 is the first vertex oriented FORWARD; V2 is the second vertex oriented REVERSED; p1 and p2 are the parameters for the vertices V1 and V2 on the curve. The default tolerance is associated with this edge.
The curve
The vertices
The parameters
The figure below illustrates two special cases, a semi-infinite edge and an edge on a periodic curve.
BRepBuilderAPI_MakeEdge class provides methods, which are all simplified calls of the previous one:
The five following methods are thus derived from the basic construction:
Six methods (the five above and the basic method) are also provided for curves from the gp package in place of Curve from Geom. The methods create the corresponding Curve from Geom and are implemented for the following classes:
gp_Lin creates a Geom_Line gp_Circ creates a Geom_Circle gp_Elips creates a Geom_Ellipse gp_Hypr creates a Geom_Hyperbola gp_Parab creates a Geom_Parabola
There are also two methods to construct edges from two vertices or two points. These methods assume that the curve is a line; the vertices or points must have different locations.
If BRepBuilderAPI_MakeEdge is used as a class, it can provide two vertices. This is useful when the vertices were not provided as arguments, for example when the edge was constructed from a curve and parameters. The two methods Vertex1 and Vertex2 return the vertices. Note that the returned vertices can be null if the edge is open in the corresponding direction.
The Error method returns a term of the BRepBuilderAPI_EdgeError enumeration. It can be used to analyze the error when IsDone method returns False. The terms are:
The following example creates a rectangle centered on the origin of dimensions H, L with fillets of radius R. The edges and the vertices are stored in the arrays theEdges and theVertices. We use class Array1OfShape (i.e. not arrays of edges or vertices). See the image below.
Use BRepBuilderAPI_MakeEdge2d class to make edges on a working plane from 2d curves. The working plane is a default value of the BRepBuilderAPI package (see the Plane methods).
BRepBuilderAPI_MakeEdge2d class is strictly similar to BRepBuilderAPI_MakeEdge, but it uses 2D geometry from gp and Geom2d instead of 3D geometry.
BRepBuilderAPI_MakePolygon class is used to build polygonal wires from vertices or points. Points are automatically changed to vertices as in BRepBuilderAPI_MakeEdge.
The basic usage of BRepBuilderAPI_MakePolygon is to create a wire by adding vertices or points using the Add method. At any moment, the current wire can be extracted. The close method can be used to close the current wire. In the following example, a closed wire is created from an array of points.
Short-cuts are provided for 2, 3, or 4 points or vertices. Those methods have a Boolean last argument to tell if the polygon is closed. The default value is False.
Two examples:
Example of a closed triangle from three vertices:
Example of an open polygon from four points:
BRepBuilderAPI_MakePolygon class maintains a current wire. The current wire can be extracted at any moment and the construction can proceed to a longer wire. After each point insertion, the class maintains the last created edge and vertex, which are returned by the methods Edge, FirstVertex and LastVertex.
When the added point or vertex has the same location as the previous one it is not added to the current wire but the most recently created edge becomes Null. The Added method can be used to test this condition. The MakePolygon class never raises an error. If no vertex has been added, the Wire is Null. If two vertices are at the same location, no edge is created.
Use BRepBuilderAPI_MakeFace class to create a face from a surface and wires. An underlying surface is constructed from a surface and optional parametric values. Wires can be added to the surface. A planar surface can be constructed from a wire. An error status can be returned after face construction.
A face can be constructed from a surface and four parameters to determine a limitation of the UV space. The parameters are optional, if they are omitted the natural bounds of the surface are used. Up to four edges and vertices are created with a wire. No edge is created when the parameter is infinite.
Constraints on the parameters are similar to the constraints in BRepBuilderAPI_MakeEdge.
The two basic constructions (from a surface and from a surface and parameters) are implemented for all the gp package surfaces, which are transformed in the corresponding Surface from Geom.
gp package surface | Geom package surface | |
---|---|---|
gp_Pln | Geom_Plane | |
gp_Cylinder | Geom_CylindricalSurface | |
gp_Cone | creates a | Geom_ConicalSurface |
gp_Sphere | Geom_SphericalSurface | |
gp_Torus | Geom_ToroidalSurface |
Once a face has been created, a wire can be added using the Add method. For example, the following code creates a cylindrical surface and adds a wire.
More than one wire can be added to a face, provided that they do not cross each other and they define only one area on the surface. (Note that this is not checked). The edges on a Face must have a parametric curve description.
If there is no parametric curve for an edge of the wire on the Face it is computed by projection.
For one wire, a simple syntax is provided to construct the face from the surface and the wire. The above lines could be written:
A planar face can be created from only a wire, provided this wire defines a plane. For example, to create a planar face from a set of points you can use BRepBuilderAPI_MakePolygon and BRepBuilderAPI_MakeFace.
The last use of MakeFace is to copy an existing face to add new wires. For example the following code adds a new wire to a face:
To add more than one wire an instance of the BRepBuilderAPI_MakeFace class can be created with the face and the first wire and the new wires inserted with the Add method.
The Error method returns an error status, which is a term from the BRepBuilderAPI_FaceError enumeration.
The wire is a composite shape built not from a geometry, but by the assembly of edges. BRepBuilderAPI_MakeWire class can build a wire from one or more edges or connect new edges to an existing wire.
Up to four edges can be used directly, for example:
For a higher or unknown number of edges the Add method must be used; for example, to build a wire from an array of shapes (to be edges).
The class can be constructed with a wire. A wire can also be added. In this case, all the edges of the wires are added. For example to merge two wires:
BRepBuilderAPI_MakeWire class connects the edges to the wire. When a new edge is added if one of its vertices is shared with the wire it is considered as connected to the wire. If there is no shared vertex, the algorithm searches for a vertex of the edge and a vertex of the wire, which are at the same location (the tolerances of the vertices are used to test if they have the same location). If such a pair of vertices is found, the edge is copied with the vertex of the wire in place of the original vertex. All the vertices of the edge can be exchanged for vertices from the wire. If no connection is found the wire is considered to be disconnected. This is an error.
BRepBuilderAPI_MakeWire class can return the last edge added to the wire (Edge method). This edge can be different from the original edge if it was copied.
The Error method returns a term of the BRepBuilderAPI_WireError enumeration: WireDone - no error occurred. EmptyWire - no initialization of the algorithm, an empty constructor was used. DisconnectedWire - the last added edge was not connected to the wire. NonManifoldWire - the wire with some singularity.
The shell is a composite shape built not from a geometry, but by the assembly of faces. Use BRepBuilderAPI_MakeShell class to build a Shell from a set of Faces. What may be important is that each face should have the required continuity. That is why an initial surface is broken up into faces.
The solid is a composite shape built not from a geometry, but by the assembly of shells. Use BRepBuilderAPI_MakeSolid class to build a Solid from a set of Shells. Its use is similar to the use of the MakeWire class: shells are added to the solid in the same way that edges are added to the wire in MakeWire.
BRepBuilderAPI_Transform class can be used to apply a transformation to a shape (see class gp_Trsf). The methods have a boolean argument to copy or share the original shape, as long as the transformation allows (it is only possible for direct isometric transformations). By default, the original shape is shared.
The following example deals with the rotation of shapes.
Use the BRepBuilderAPI_Copy class to duplicate a shape. A new shape is thus created. In the following example, a solid is copied:
BRepPrimAPI_MakeBox class allows building a parallelepiped box. The result is either a Shell or a Solid. There are four ways to build a box:
An error is raised if the box is flat in any dimension using the default precision. The following code shows how to create a box:
The four methods to build a box are shown in the figure:
BRepPrimAPI_MakeWedge class allows building a wedge, which is a slanted box, i.e. a box with angles. The wedge is constructed in much the same way as a box i.e. from three dimensions dx,dy,dz plus arguments or from an axis system, three dimensions, and arguments.
The following figure shows two ways to build wedges. One is to add an ltx dimension, which is the length in x of the face at dy. The second is to add xmin, xmax, zmin, zmax to describe the face at dy.
The first method is a particular case of the second with xmin = 0, xmax = ltx, zmin = 0, zmax = dz. To make a centered pyramid you can use xmin = xmax = dx / 2, zmin = zmax = dz / 2.
BRepPrimAPI_MakeOneAxis is a deferred class used as a root class for all classes constructing rotational primitives. Rotational primitives are created by rotating a curve around an axis. They cover the cylinder, the cone, the sphere, the torus, and the revolution, which provides all other curves.
The particular constructions of these primitives are described, but they all have some common arguments, which are:
The result of the OneAxis construction is a Solid, a Shell, or a Face. The face is the face covering the rotational surface. Remember that you will not use the OneAxis directly but one of the derived classes, which provide improved constructions. The following figure illustrates the OneAxis arguments.
BRepPrimAPI_MakeCylinder class allows creating cylindrical primitives. A cylinder is created either in the default coordinate system or in a given coordinate system (gp_Ax2). There are two constructions:
The following code builds the cylindrical face of the figure, which is a quarter of cylinder along the Y axis with the origin at X,Y,Z, a length of DY, and a radius R.
BRepPrimAPI_MakeCone class allows creating conical primitives. Like a cylinder, a cone is created either in the default coordinate system or in a given coordinate system (gp_Ax2). There are two constructions:
The following code builds the solid cone of the figure, which is located in the default system with radii R1 and R2 and height H.
BRepPrimAPI_MakeSphere class allows creating spherical primitives. Like a cylinder, a sphere is created either in the default coordinate system or in a given coordinate system (gp_Ax2). There are four constructions:
The following code builds four spheres from a radius and three angles.
Note that we could equally well choose to create Shells instead of Solids.
BRepPrimAPI_MakeTorus class allows creating toroidal primitives. Like the other primitives, a torus is created either in the default coordinate system or in a given coordinate system (gp_Ax2). There are four constructions similar to the sphere constructions:
Note that we could equally well choose to create Solids instead of Shells.
BRepPrimAPI_MakeRevolution class allows building a uniaxial primitive from a curve. As other uniaxial primitives it can be created in the default coordinate system or in a given coordinate system.
The curve can be any Geom_Curve, provided it is planar and lies in the same plane as the Z-axis of local coordinate system. There are four modes of construction:
Sweeps are the objects you obtain by sweeping a profile along a path. The profile can be of any topology. The path is usually a curve or a wire. The profile generates objects according to the following rules:
It is forbidden to sweep Solids and Composite Solids. A Compound generates a Compound with the sweep of all its elements.
BRepPrimAPI_MakePrism class allows creating a linear prism from a shape and a vector or a direction.
The following code creates a finite, an infinite and a semi-infinite solid using a face, a direction and a length.
BRepPrimAPI_MakeRevol class allows creating a rotational sweep from a shape, an axis (gp_Ax1), and an angle. The angle has a default value of 2*PI which means a closed revolution.
BRepPrimAPI_MakeRevol constructors have a last argument to copy or share the original shape. The following code creates a a full and a partial rotation using a face, an axis and an angle.
Boolean operations are used to create new shapes from the combinations of two shapes.
Operation | Result |
---|---|
Fuse | all points in S1 or S2 |
Common | all points in S1 and S2 |
Cut S1 by S2 | all points in S1 and not in S2 |
BRepAlgoAPI_BooleanOperation class is the deferred root class for Boolean operations.
BRepAlgoAPI_Fuse performs the Fuse operation.
BRepAlgoAPI_Common performs the Common operation.
BRepAlgoAPI_Cut performs the Cut operation.
BRepAlgoAPI_Section performs the section, described as a TopoDS_Compound made of TopoDS_Edge.
A fillet is a smooth face replacing a sharp edge.
BRepFilletAPI_MakeFillet class allows filleting a shape.
To produce a fillet, it is necessary to define the filleted shape at the construction of the class and add fillet descriptions using the Add method.
A fillet description contains an edge and a radius. The edge must be shared by two faces. The fillet is automatically extended to all edges in a smooth continuity with the original edge. It is not an error to add a fillet twice, the last description holds.
A chamfer is a rectilinear edge replacing a sharp vertex of the face.
The use of BRepFilletAPI_MakeChamfer class is similar to the use of BRepFilletAPI_MakeFillet, except for the following:
BRepFilletAPI_MakeFillet2d class allows constructing fillets and chamfers on planar faces. To create a fillet on planar face: define it, indicate, which vertex is to be deleted, and give the fillet radius with AddFillet method.
A chamfer can be calculated with AddChamfer method. It can be described by
If face F2 is created by 2D fillet and chamfer builder from face F1, the builder can be rebuilt (the builder recovers the status it had before deletion). To do so, use the following syntax:
Shelling is used to offset given faces of a solid by a specific value. It rounds or intersects adjacent faces along its edges depending on the convexity of the edge.
The constructor BRepOffsetAPI_MakeThickSolid shelling operator takes the solid, the list of faces to remove and an offset value as input.
BRepOffsetAPI_DraftAngle class allows modifying a shape by applying draft angles to its planar, cylindrical and conical faces.
The class is created or initialized from a shape, then faces to be modified are added; for each face, three arguments are used:
The following code places a draft angle on several faces of a shape; the same direction, angle and neutral plane are used for each face:
BRepOffsetAPI_MakePipe class allows creating a pipe from a Spine, which is a Wire and a Profile which is a Shape. This implementation is limited to spines with smooth transitions, sharp transitions are precessed by BRepOffsetAPI_MakePipeShell. To be more precise the continuity must be G1, which means that the tangent must have the same direction, though not necessarily the same magnitude, at neighboring edges.
The angle between the spine and the profile is preserved throughout the pipe.
BRepOffsetAPI_MakeEvolved class allows creating an evolved solid from a Spine (planar face or wire) and a profile (wire).
The evolved solid is an unlooped sweep generated by the spine and the profile.
The evolved solid is created by sweeping the profile’s reference axes on the spine. The origin of the axes moves to the spine, the X axis and the local tangent coincide and the Z axis is normal to the face.
The reference axes of the profile can be defined following two distinct modes:
BRepOffsetAPI_Sewing class allows sewing TopoDS Shapes together along their common edges. The edges can be partially shared as in the following example.
The following methods are used in this class:
Additional methods can be used to give information on the number of free boundaries, multiple edges and degenerate shapes.
BRepOffsetAPI_FindContiguousEdges class is used to find edges, which coincide among a set of shapes within the given tolerance; these edges can be analyzed for tangency, continuity (C1, G2, etc.)...
The constructor takes as arguments the tolerance defining the edge proximity (10-6 by default) and a flag used to mark degenerated shapes.
The following methods are used in this class:
BRepFeat package is used to manipulate extensions of the classical boundary representation of shapes closer to features. In that sense, BRepFeat is an extension of BRepBuilderAPI package.
The Form from BRepFeat class is a deferred class used as a root for form features. It inherits MakeShape from BRepBuilderAPI and provides implementation of methods keep track of all sub-shapes.
MakePrism from BRepFeat class is used to build a prism interacting with a shape. It is created or initialized from
There are six Perform methods:
Method | Description |
---|---|
Perform(Height) | The resulting prism is of the given length. |
Perform(Until) | The prism is defined between the position of the base and the given face. |
Perform(From, Until) | The prism is defined between the two faces From and Until. |
PerformUntilEnd() | The prism is semi-infinite, limited by the actual position of the base. |
PerformFromEnd(Until) | The prism is semi-infinite, limited by the face Until. |
PerformThruAll() | The prism is infinite. In the case of a depression, the result is similar to a cut with an infinite prism. In the case of a protrusion, infinite parts are not kept in the result. |
Note that Add method can be used before Perform methods to indicate that a face generated by an edge slides onto a face of the base shape.
In the following sequence, a protrusion is performed, i.e. a face of the shape is changed into a prism.
MakeDPrism from BRepFeat class is used to build draft prism topologies interacting with a basis shape . These can be depressions or protrusions. A class object is created or initialized from
Evidently the input data for MakeDPrism are the same as for MakePrism except for a new parameter Angle and a missing parameter Direction: the direction of the prism generation is determined automatically as the normal to the base of the prism. The semantics of draft prism feature creation is based on the construction of shapes:
The shape defining construction of the draft prism feature can be either the supporting edge or the concerned area of a face.
In case of the supporting edge, this contour can be attached to a face of the basis shape by binding. When the contour is bound to this face, the information that the contour will slide on the face becomes available to the relevant class methods. In case of the concerned area of a face, it is possible to cut it out and move it to a different height, which will define the limiting face of a protrusion or depression direction .
The Perform methods are the same as for MakePrism.
The MakeRevol from BRepFeat class is used to build a revolution interacting with a shape. It is created or initialized from
There are four Perform methods:
Method | Description |
---|---|
Perform(Angle) | The resulting revolution is of the given magnitude. |
Perform(Until) | The revolution is defined between the actual position of the base and the given face. |
Perform(From, Until) | The revolution is defined between the two faces, From and Until. |
PerformThruAll() | The result is similar to Perform(2*PI). |
Note that Add method can be used before Perform methods to indicate that a face generated by an edge slides onto a face of the base shape.
In the following sequence, a face is revolved and the revolution is limited by a face of the base shape.
This method constructs compound shapes with pipe features: depressions or protrusions. A class object is created or initialized from
There are three Perform methods:
Method | Description |
---|---|
Perform() | The pipe is defined along the entire path (spine wire) |
Perform(Until) | The pipe is defined along the path until a given face |
Perform(From, Until) | The pipe is defined between the two faces From and Until |
MakeLinearForm class creates a rib or a groove along a planar surface.
The semantics of mechanical features is built around giving thickness to a contour. This thickness can either be symmetrical - on one side of the contour - or dissymmetrical - on both sides. As in the semantics of form features, the thickness is defined by construction of shapes in specific contexts.
The development contexts differ, however, in the case of mechanical features. Here they include extrusion:
There is one Perform() method, which performs a prism from the wire along the direction1 and direction2 interacting with base shape Sbase. The height of the prism is Magnitude(Direction1)+Magnitude(direction2).
The Gluer from BRepFeat class allows gluing two solids along faces. The contact faces of the glued shape must not have parts outside the contact faces of the basic shape. The class is created or initialized from two shapes: the “glued” shape and the basic shape (on which the other shape is glued). Two Bind methods are used to bind a face of the glued shape to a face of the basic shape and an edge of the glued shape to an edge of the basic shape.
Note that every face and edge has to be bounded, if two edges of two glued faces are coincident they must be explicitly bounded.
SplitShape from BRepFeat class is used to split faces of a shape with wires or edges. The shape containing the new entities is rebuilt, sharing the unmodified ones.
The class is created or initialized from a shape (the basic shape). Three Add methods are available:
Note The added wires and edges must define closed wires on faces or wires located between two existing edges. Existing edges must not be intersected.
To provide the precision required in industrial design, drawings need to offer the possibility of removing lines, which are hidden in a given projection.
For this the Hidden Line Removal component provides two algorithms: HLRBRep_Algo and HLRBRep_PolyAlgo.
These algorithms are based on the principle of comparing each edge of the shape to be visualized with each of its faces, and calculating the visible and the hidden parts of each edge. Note that these are not the algorithms used in generating shading, which calculate the visible and hidden parts of each face in a shape to be visualized by comparing each face in the shape with every other face in the same shape. These algorithms operate on a shape and remove or indicate edges hidden by faces. For a given projection, they calculate a set of lines characteristic of the object being represented. They are also used in conjunction with extraction utilities, which reconstruct a new, simplified shape from a selection of the results of the calculation. This new shape is made up of edges, which represent the shape visualized in the projection.
HLRBRep_Algo takes the shape itself into account whereas HLRBRep_PolyAlgo works with a polyhedral simplification of the shape. When you use HLRBRep_Algo, you obtain an exact result, whereas, when you use HLRBRep_PolyAlgo, you reduce the computation time.
No smoothing algorithm is provided. Consequently, a polyhedron will be treated as such and the algorithms will give the results in form of line segments conforming to the mathematical definition of the polyhedron. This is always the case with HLRBRep_PolyAlgo.
HLRBRep_Algo and HLRBRep_PolyAlgo can deal with any kind of object, for example, assemblies of volumes, surfaces, and lines, as long as there are no unfinished objects or points within it.
However, there some restrictions in HLR use:
The following services are related to Hidden Lines Removal :
To pass a TopoDS_Shape to an HLRBRep_Algo object, use HLRBRep_Algo::Add. With an HLRBRep_PolyAlgo object, use HLRBRep_PolyAlgo::Load. If you wish to add several shapes, use Add or Load as often as necessary.
HLRBRep_Algo::Projector and HLRBRep_PolyAlgo::Projector set a projector object which defines the parameters of the view. This object is an HLRAlgo_Projector.
HLRBRep_PolyAlgo::Update launches the calculation of outlines of the shape visualized by the HLRBRep_PolyAlgo framework.
In the case of HLRBRep_Algo, use HLRBRep_Algo::Update. With this algorithm, you must also call the method HLRBRep_Algo::Hide to calculate visible and hidden lines of the shape to be visualized. With an HLRBRep_PolyAlgo object, visible and hidden lines are computed by HLRBRep_PolyHLRToShape.
The classes HLRBRep_HLRToShape and HLRBRep_PolyHLRToShape present a range of extraction filters for an HLRBRep_Algo object and an HLRBRep_PolyAlgo object, respectively. They highlight the type of edge from the results calculated by the algorithm on a shape. With both extraction classes, you can highlight the following types of output:
To perform extraction on an HLRBRep_PolyHLRToShape object, use HLRBRep_PolyHLRToShape::Update function.
For an HLRBRep_HLRToShape object built from an HLRBRepAlgo object you can also highlight:
The HLRBRep_PolyAlgo algorithm works with triangulation of shapes. This is provided by the function BRepMesh::Mesh, which adds a triangulation of the shape to its topological data structure. This triangulation is computed with a given deflection.
Meshing covers a shape with a triangular mesh. Other than hidden line removal, you can use meshing to transfer the shape to another tool: a manufacturing tool, a shading algorithm, a finite element algorithm, or a collision algorithm, for example.
You can obtain information on the shape by first exploring it. To then access triangulation of a face in the shape, use BRepTool::Triangulation. To access a polygon which is the approximation of an edge of the face, use BRepTool::PolygonOnTriangulation.