Open CASCADE Technology
7.6.0
|
|
This manual explains how to use Shape Healing. It provides basic documentation on its operation. For advanced information on Shape Healing and its applications, see our E-learning & Training offerings.
The Shape Healing toolkit provides a set of tools to work on the geometry and topology of Open CASCADE Technology (OCCT) shapes. Shape Healing adapts shapes so as to make them as appropriate for use by Open CASCADE Technology as possible.
Here are a few examples of typical problems with illustrations of how Shape Healing deals with them:
The problem: Face on a periodical surface is limited by wires which make a full trip around the surface. These wires are closed in 3d but not closed in parametric space of the surface. This is not valid in Open CASCADE. The solution: Shape Healing fixes this face by inserting seam edge which combines two open wires and thus closes the parametric space. Note that internal wires are processed correctly.
The problem: Wires on face have incorrect orientation, so that interior and outer parts of the face are mixed. The solution: Shape Healing recovers correct orientation of wires.
The problem: Face is invalid because its boundary wire has self-intersection (on two adjacent edges) The solution: Shape Healing cuts intersecting edges at intersection points thus making boundary valid.
The problem: There is a gap between two edges in the wire, so that wire is not closed The solution: Shape Healing closes a gap by inserting lacking edge.
Shape Healing currently includes several packages that are designed to help you to:
The following diagram shows dependencies of API packages:
Each sub-domain has its own scope of functionality:
Message management is used for creating messages, filling them with various parameters and storing them in the trace file. This tool provides functionality for attaching messages to the shapes for deferred analysis of various run-time events. In this document only general principles of using Shape Healing will be described. For more detailed information, see the corresponding header files.
Tools responsible for analysis, fixing and upgrading of shapes can give the information about how these operations were performed. This information can be obtained by the user with the help of mechanism of status querying.
Each fixing and upgrading tool has its own status, which is reset when their methods are called. The status can contain several flags, which give the information about how the method was performed. For exploring the statuses, a set of methods named Status...() is provided. These methods accept enumeration ShapeExtend_Status and return True if the status has the corresponding flag set. The meaning of flags for each method is described below.
The status may contain a set of Boolean flags (internally represented by bits). Flags are coded by enumeration ShapeExtend_Status. This enumeration provides the following families of statuses:
It is possible to test the status for the presence of some flag(s), using Status...() method(s) provided by the class:
8 'DONE' and 8 'FAIL' flags, named ShapeExtend_DONE1 ... ShapeExtend_FAIL8, are defined for a detailed analysis of the encountered situation. Each method assigns its own meaning to each flag, documented in the header for that method. There are also three enumerative values used for testing several flags at a time:
Algorithms for fixing problematic (violating the OCCT requirements) shapes are placed in package ShapeFix.
Each class of package ShapeFix deals with one certain type of shapes or with some family of problems.
There is no necessity for you to detect problems before using ShapeFix because all components of package ShapeFix make an analysis of existing problems before fixing them by a corresponding tool from package of ShapeAnalysis and then fix the discovered problems.
The ShapeFix package currently includes functions that:
The simplest way for fixing shapes is to use classes ShapeFix_Shape and ShapeFix_Wireframe on a whole shape with default parameters. A combination of these tools can fix most of the problems that shapes may have. The sequence of actions is as follows :
Handle(ShapeFix_Shape) sfs = new ShapeFix_Shape; sfs->Init ( shape );
sfs->SetPrecision ( Prec ); sfs->SetMaxTolerance ( maxTol ); sfs->SetMinTolerance ( mintol );where:
sfs->Perform();
TopoDS_Shape aResult = sfs->Shape();In some cases using only ShapeFix_Shape can be insufficient. It is possible to use tools for merging and removing small edges and fixing gaps between 2D and 3D curves.
If you do not want to make fixes on the whole shape or make a definite set of fixes you can set flags for separate fix cases (marking them ON or OFF) and you can also use classes for fixing specific types of sub-shapes such as solids, shells, faces, wires, etc.
For each type of sub-shapes there are specific types of fixing tools such as ShapeFix_Solid, ShapeFix_Shell, ShapeFix_Face, ShapeFix_Wire, etc.
If you want to make a fix on one sub-shape of a certain shape it is possible to take the following steps:
For example, in the following way it is possible to fix face Face1 of shape Shape1:
A set of required fixes and invalid sub-shapes can be obtained with the help of tools responsible for the analysis of shape validity (section 3.2).
Each class of package ShapeFix deals with one certain type of shapes or with a family of problems. Each repairing tool makes fixes for the specified shape and its sub-shapes with the help of method Perform() containing an optimal set of fixes. The execution of these fixes in the method Perform can be managed with help of a set of control flags (fixes can be either forced or forbidden).
The following sequence of actions should be applied to perform fixes:
The flags Fix...Mode() are used to control the execution of fixing procedures from the API fixing methods. By default, these flags have values equal to -1, this means that the corresponding procedure will either be called or not called, depending on the situation. If the flag is set to 1, the procedure is executed anyway; if the flag is 0, the procedure is not executed. The name of the flag corresponds to the fixing procedure that is controlled. For each fixing tool there exists its own set of flags. To set a flag to the desired value, get a tool containing this flag and set the flag to the required value.
For example, it is possible to forbid performing fixes to remove small edges - FixSmall
Class ShapeFix_Shape allows using repairing tools for all sub-shapes of a shape. It provides access to all repairing tools for fixing sub-shapes of the specified shape and to all control flags from these tools.
For example, it is possible to force the removal of invalid 2D curves from a face.
Class ShapeFix_Solid allows fixing solids and building a solid from a shell to obtain a valid solid with a finite volume. The tool ShapeFix_Shell is used for correction of shells belonging to a solid.
This tool has the following control flags:
Class ShapeFix_Shell allows fixing wrong orientation of faces in a shell. It changes the orientation of faces in the shell so that all faces in the shell have coherent orientations. If it is impossible to orient all faces in the shell (like in case of Mebious tape), then a few manifold or non-manifold shells will be created depending on the specified Non-manifold mode. The ShapeFix_Face tool is used to correct faces in the shell. This tool has the following control flags:
Class ShapeFix_Face allows fixing the problems connected with wires of a face. It allows controlling the creation of a face (adding wires), and fixing wires by means of tool ShapeFix_Wire. When a wire is added to a face, it can be reordered and degenerated edges can be fixed. This is performed or not depending on the user-defined flags (by default, False). The following fixes are available:
This tool has the following control flags:
Class ShapeFix_Wire allows fixing a wire. Its method Perform() performs all the available fixes in addition to the geometrical filling of gaps. The geometrical filling of gaps can be made with the help of the tool for fixing the wireframe of shape ShapeFix_Wireframe.
The fixing order and the default behavior of Perform() is as follows:
The flag ClosedWireMode specifies whether the wire is (or should be) closed or not. If that flag is True (by default), fixes that require or force connection between edges are also executed for the last and the first edges.
The fixing methods can be turned on/off by using their corresponding control flags:
Some fixes can be made in three ways:
When it is possible to make a fix in more than one way (e.g., either by increasing the tolerance or shifting a vertex), it is chosen according to the user-defined flags:
FixReorder is necessary for most other fixes (but is not necessary for Open CASCADE Technology). It checks whether edges in the wire go in a sequential order (the end of a preceding edge is the start of a following one). If it is not so, an attempt to reorder the edges is made.
FixSmall method searches for the edges, which have a length less than the given value (degenerated edges are ignored). If such an edge is found, it is removed provided that one of the following conditions is satisfied:
FixConnected method forces two adjacent edges to share the same common vertex (if they do not have a common one). It checks whether the end vertex of the preceding edge coincides with the start vertex of the following edge with the given precision, and then creates a new vertex and sets it as a common vertex for the fixed edges. At that point, edges are copied, hence the wire topology is changed (regardless of the ModifyTopologyMode flag). If the vertices do not coincide, this method fails.
FixEdgeCurves method performs a set of fixes dealing with 3D curves and 2D curves of edges in a wire.
These fixes will be activated with the help of a set of fixes from the repairing tool for edges called ShapeFix_Edge. Each of these fixes can be forced or forbidden by means of setting the corresponding flag to either True or False.
The mentioned fixes and the conditions of their execution are:
This fix is required if 2D curves of some edges in a wire lying on a closed surface were recomputed from 3D curves. In that case, the 2D curve for the edge, which goes along the seam of the surface, can be incorrectly shifted at an integer number of periods. The method FixShifted detects such cases and shifts wrong 2D curves back, ensuring that the 2D curves of the edges in the wire are connected.
FixDegenerated method checks whether an edge in a wire lies on a degenerated point of the supporting surface, or whether there is a degenerated point between the edges. If one of these cases is detected for any edge, a new degenerated edge is created and it replaces the current edge in the first case or is added to the wire in the second case. The newly created degenerated edge has a straight 2D curve, which goes from the end of the 2D curve of the preceding edge to the start of the following one.
FixSelfIntersection method detects and fixes the following problems:
FixLacking method checks whether a wire is not closed in the parametric space of the surface (while it can be closed in 3D). This is done by checking whether the gap between 2D curves of each of the two adjacent edges in the wire is smaller than the tolerance of the corresponding vertex. The algorithm computes the gap between the edges, analyses positional relationship of the ends of these edges and (if possible) tries to insert a new edge into the gap or increases the tolerance.
The following methods check gaps between the ends of 2D or 3D curves of adjacent edges:
Boolean flag FixGapsByRanges is used to activate an additional mode applied before converting to B-Splines. When this mode is on, methods try to find the most precise intersection of curves, or the most precise projection of a target point, or an extremity point between two curves (to modify their parametric range accordingly). This mode is off by default. Independently of the additional mode described above, if gaps remain, these methods convert curves to B-Spline form and shift their ends if a gap is detected.
Let us create a custom set of fixes as an example.
Let us correct the following wire:
It is necessary to apply the tools for the analysis of wire validity to check that:
As the result all failures have been fixed.
Class ShapeFix_Edge provides tools for fixing invalid edges. The following geometrical and/or topological inconsistencies are detected and fixed:
To see how this tool works, it is possible to take an edge, where the maximum deviation between the 3D curve and 2D curve P1 is greater than the edge tolerance.
First it is necessary to apply the tool for checking the edge validity to find that the maximum deviation between pcurve and 3D curve is greater than tolerance. Then we can use the repairing tool to increase the tolerance and make the deviation acceptable.
As the result, the edge tolerance has been increased.
Class ShapeFix_Wireframe provides methods for geometrical fixing of gaps and merging small edges in a shape. This class performs the following operations:
Fixing of small edges can be managed with the help of two flags:
It is desirable that a shape is topologically correct before applying the methods of this class.
Class ShapeFix_FixSmallFaceThis tool is intended for dropping small faces from the shape. The following cases are processed:
The sequence of actions for performing the fix is the same as for the fixes described above:
This tool provides a functionality to set tolerances of a shape and its sub-shapes. In Open CASCADE Technology only vertices, edges and faces have tolerances.
This tool allows processing each concrete type of sub-shapes or all types at a time. You set the tolerance functionality as follows:
The ShapeAnalysis package provides tools for the analysis of topological shapes. It is not necessary to check a shape by these tools before the execution of repairing tools because these tools are used for the analysis before performing fixes inside the repairing tools. However, if you want, these tools can be used for detecting some of shape problems independently from the repairing tools.
It can be done in the following way:
It is possible to check whether a face has an outer boundary with the help of method ShapeAnalysis::IsOuterBound.
Class ShapeAnalysis_Wire is intended to analyze a wire. It provides functionalities both to explore wire properties and to check its conformance to Open CASCADE Technology requirements. These functionalities include:
Note that all checking operations except for the first one are based on the assumption that edges in the wire are ordered. Thus, if the wire is detected as non-ordered it is necessary to order it before calling other checking operations. This can be done, for example, with the help of the ShapeFix_Wire::FixOrder() method.
This tool should be initialized with wire, face (or a surface with a location) or precision. Once the tool has been initialized, it is possible to perform the necessary checking operations. In order to obtain all information on a wire at a time the global method Perform is provided. It calls all other API checking operations to check each separate case.
API methods check for corresponding cases only, the value and the status they return can be analyzed to understand whether the case was detected or not.
Some methods in this class are:
This class maintains status management. Each API method stores the status of its last execution which can be queried by the corresponding Status..() method. In addition, each API method returns a Boolean value, which is True when a case being analyzed is detected (with the set ShapeExtend_DONE status), otherwise it is False.
Class ShapeAnalysis_Edge is intended to analyze edges. It provides the following functionalities to work with an edge:
This class supports status management described above.
Class ShapeAnalysis_CheckSmallFace class is intended for analyzing small faces from the shape using the following methods:
Class ShapeAnalysis_Shell allows checking the orientation of edges in a manifold shell. With the help of this tool, free edges (edges entered into one face) and bad edges (edges entered into the shell twice with the same orientation) can be found. By occurrence of bad and free edges a conclusion about the shell validity and the closure of the shell can be made.
Class ShapeAnalysis_ShapeTolerance allows computing tolerances of the shape and its sub-shapes. In Open CASCADE Technology only vertices, edges and faces have tolerances:
This tool allows analyzing each concrete type of sub-shapes or all types at a time. The analysis of tolerance functionality is the following:
Class ShapeAnalysis_FreeBounds is intended to analyze and output the free bounds of a shape. Free bounds are wires consisting of edges referenced only once by only one face in the shape. This class works on two distinct types of shapes when analyzing their free bounds:
When connecting edges into wires this algorithm tries to build wires of maximum length. Two options are provided for the user to extract closed sub-contours out of closed and/or open contours. Free bounds are returned as two compounds, one for closed and one for open wires. To obtain a result it is necessary to use methods:
This class also provides some static methods for advanced use: connecting edges/wires to wires, extracting closed sub-wires from wires, distributing wires into compounds for closed and open wires.
Class ShapeAnalysis_ShapeContents provides tools counting the number of sub-shapes and selecting a sub-shape by the following criteria:
Methods for getting the number of sub-shapes:
Methods for calculating the number of geometrical objects or sub-shapes with a specified type:
and selecting sub-shapes by various criteria.
The corresponding flags should be set to True for storing a shape by a specified criteria:
Let us, for example, select faces based on offset surfaces.
Upgrading tools are intended for adaptation of shapes for better use by Open CASCADE Technology or for customization to particular needs, i.e. for export to another system. This means that not only it corrects and upgrades but also changes the definition of a shape with regard to its geometry, size and other aspects. Convenient API allows you to create your own tools to perform specific upgrading. Additional tools for particular cases provide an ability to divide shapes and surfaces according to certain criteria.
These tools provide such modifications when one topological object can be divided or converted to several ones according to specified criteria. Besides, there are high level API tools for particular cases which:
All tools for particular cases are based on general tools for shape splitting but each of them has its own tools for splitting or converting geometry in accordance with the specified criteria.
General tools for shape splitting are:
Tools for shape splitting use tools for geometry splitting:
If it is necessary to split a shape by a specified continuity, split closed faces in the shape, split surfaces of revolution in the shape by angle or to convert all surfaces, all 3D curves, all 2D curves in the shape to Bezier, it is possible to use the existing/available tools.
The usual way to use these tools exception for the tool of converting a C0 BSpline curve is the following:
Let us, for example, split all surfaces and all 3D and 2D curves having a continuity of less the C2.
To create a new splitting tool it is necessary to create tools for geometry splitting according to a desirable criterion. The new tools should be inherited from basic tools for geometry splitting. Then the new tools should be set into corresponding tools for shape splitting.
To change the value of criterion of shape splitting it is necessary to create a new tool for shape splitting that should be inherited from the general splitting tool for shapes.
Let us split a shape according to a specified criterion.
Class ShapeUpgrade_ShapeDivide provides shape splitting and converting according to the given criteria. It performs these operations for each face with the given tool for face splitting (ShapeUpgrade_FaceDivide by default).
This tool provides access to the tool for dividing faces with the help of the methods SetSplitFaceTool and GetSpliFaceTool.
Class ShapeUpgrade_FaceDivide divides a Face (edges in the wires, by splitting 3D and 2D curves, as well as the face itself, by splitting the supporting surface) according to the given criteria.
The area of the face intended for division is defined by 2D curves of the wires on the Face. All 2D curves are supposed to be defined (in the parametric space of the supporting surface). The result is available after the call to the Perform method. It is a Shell containing all resulting Faces. All modifications made during the splitting operation are recorded in the external context (ShapeBuild_ReShape).
This tool provides access to the tool for wire division and surface splitting by means of the following methods:
Class ShapeUpgrade_WireDivide divides edges in the wire lying on the face or free wires or free edges with a given criterion. It splits the 3D curve and 2D curve(s) of the edge on the face. Other 2D curves, which may be associated with the edge, are simply copied. If the 3D curve is split then the 2D curve on the face is split as well, and vice-versa. The original shape is not modified. Modifications made are recorded in the context (ShapeBuild_ReShape).
This tool provides access to the tool for dividing and splitting 3D and 2D curves by means of the following methods:
and it also provides access to the mode for splitting edges by methods SetEdgeMode and GetEdgeMode.
This mode sets whether only free edges, only shared edges or all edges are split.
Class ShapeUpgrade_EdgeDivide divides edges and their geometry according to the specified criteria. It is used in the wire-dividing tool.
This tool provides access to the tool for dividing and splitting 3D and 2D curves by the following methods:
There are three general tools for geometry splitting.
All these tools are constructed the same way: They have methods:
To create new tools for geometry splitting it is enough to inherit a new tool from the general tool for splitting a corresponding type of geometry and to redefine the method for computation of splitting values according to the specified criterion in them. (method Compute).
Header file for the tool for surface splitting by continuity:
Class ShapeUpgrade_ShapeDivideContinuity allows converting geometry with continuity less than the specified continuity to geometry with target continuity. If converting is not possible than geometrical object is split into several ones, which satisfy the given criteria. A topological object based on this geometry is replaced by several objects based on the new geometry.
Class ShapeUpgrade_ShapeDivideAngle allows splitting all surfaces of revolution, cylindrical, toroidal, conical, spherical surfaces in the given shape so that each resulting segment covers not more than the defined angle (in radians).
Class ShapeUpgrade_ShapeConvertToBezier is an API tool for performing a conversion of 3D, 2D curves to Bezier curves and surfaces to Bezier based surfaces (Bezier surface, surface of revolution based on Bezier curve, offset surface based on any of previous types).
This tool provides access to various flags for conversion of different types of curves and surfaces to Bezier by methods:
Let us attempt to produce a conversion of planes to Bezier surfaces.
Class ShapeUpgrade_ShapeDivideClosed provides splitting of closed faces in the shape to a defined number of components by the U and V parameters. It topologically and (partially) geometrically processes closed faces and performs splitting with the help of class ShapeUpgrade_ClosedFaceDivide.
The API methods for this tool is a package of methods ShapeUpgrade::C0BSplineToSequenceOfC1BsplineCurve, which converts a C0 B-Spline curve into a sequence of C1 B-Spline curves. This method splits a B-Spline at the knots with multiplicities equal to degree, it does not use any tolerance and therefore does not change the geometry of the B-Spline. The method returns True if C0 B-Spline was successfully split, otherwise returns False (if BS is C1 B-Spline).
ShapeUpgrade_ShapeDivideArea can work with compounds, solids, shells and faces. During the work this tool examines each face of a specified shape and if the face area exceeds the specified maximal area, this face is divided. Face splitting is performed in the parametric space of this face. The values of splitting in U and V directions are calculated with the account of translation of the bounding box form parametric space to 3D space.
Such calculations are necessary to avoid creation of strip faces. In the process of splitting the holes on the initial face are taken into account. After the splitting all new faces are checked by area again and the splitting procedure is repeated for the faces whose area still exceeds the max allowed area. Sharing between faces in the shape is preserved and the resulting shape is of the same type as the source shape.
An example of using this tool is presented in the figures below:
ShapeUpgrade_ShapeDivideArea is inherited from the base class ShapeUpgrade_ShapeDivide and should be used in the following way:
Note that the use of method ShapeFix::SameParameter is necessary, otherwise the parameter edges obtained as a result of splitting can be different.
Customization tools are intended for adaptation of shape geometry in compliance with the customer needs. They modify a geometrical object to another one in the shape.
To implement the necessary shape modification it is enough to initialize the appropriate tool by the shape and desirable parameters and to get the resulting shape. For example for conversion of indirect surfaces in the shape do the following:
This method provides conversion of indirect elementary surfaces (elementary surfaces with left-handed coordinate systems) in the shape into direct ones. New 2d curves (recomputed for converted surfaces) are added to the same edges being shared by both the resulting shape and the original shape S.
This method returns a new shape, which is a scaled original shape with a coefficient equal to the specified value of scale. It uses the tool ShapeCustom_TrsfModification.
ShapeCustom_BSplineRestriction allows approximation of surfaces, curves and 2D curves with a specified degree, maximum number of segments, 2d tolerance and 3d tolerance. If the approximation result cannot be achieved with the specified continuity, the latter can be reduced.
The method with all parameters looks as follows:
It returns a new shape with all surfaces, curves and 2D curves of BSpline/Bezier type or based on them, converted with a degree less than MaxDegree or with a number of spans less then NbMaxSegment depending on the priority parameter Degree. If this parameter is equal to True then Degree will be increased to the value GmaxDegree, otherwise NbMaxSegments will be increased to the value GmaxSegments. GmaxDegree and GMaxSegments are the maximum possible degree and the number of spans correspondingly. These values will be used in cases when an approximation with specified parameters is impossible and either GmaxDegree or GMaxSegments is selected depending on the priority.
Note that if approximation is impossible with GMaxDegree, even then the number of spans can exceed the specified GMaxSegment. Rational specifies whether Rational BSpline/Bezier should be converted into polynomial B-Spline.
Also note that the continuity of surfaces in the resulting shape can be less than the given value.
To convert other types of curves and surfaces to BSpline with required parameters it is necessary to use flags from class ShapeCustom_RestrictionParameters, which is just a container of flags. The following flags define whether a specified-type geometry has been converted to BSpline with the required parameters:
This method returns a new shape with all elementary periodic surfaces converted to Geom_SurfaceOfRevolution. It uses the tool ShapeCustom_ConvertToRevolution.
This method returns a new shape with all surfaces of linear extrusion, revolution and offset surfaces converted according to flags to Geom_BSplineSurface (with the same parameterization). It uses the tool ShapeCustom_ConvertToBSpline.
If, in addition to the resulting shape, you want to get the history of modification of sub-shapes you should not use the package methods described above and should use your own code instead:
The general calling syntax for scaling is
Note that scale is a real value. You can refine your mapping process by using additional calls to follow shape mapping sub-shape by sub-shape. The following code along with pertinent includes can be used:
The map, called context in our example, contains the history. Substitutions are made one by one and all shapes are transformed. To determine what happens to a particular sub-shape, it is possible to use:
ShapeUpgrade_RemoveInternalWires tool removes internal wires with contour area less than the specified minimal area. It can work with compounds, solids, shells and faces.
If the flag RemoveFaceMode is set to TRUE, separate faces or a group of faces with outer wires, which consist only of edges that belong to the removed internal wires, are removed (seam edges are not taken into account). Such faces can be removed only for a sewed shape.
Internal wires can be removed by the methods Perform. Both methods Perform can not be carried out if the class has not been initialized by the shape. In such case the status of Perform is set to FAIL .
The method Perform without arguments removes from all faces in the specified shape internal wires whose area is less than the minimal area.
The other method Perform has a sequence of shapes as an argument. This sequence can contain faces or wires. If the sequence of shapes contains wires, only the internal wires are removed.
If the sequence of shapes contains faces, only the internal wires from these faces are removed.
An example of using this tool is presented in the figures below:
After the processing three internal wires with contour area less than the specified minimal area have been removed. One internal face has been removed. The outer wire of this face consists of the edges belonging to the removed internal wires and a seam edge. Two other internal faces have not been removed because their outer wires consist not only of edges belonging to the removed wires.
After the processing six internal wires with contour area less than the specified minimal area have been removed. Six internal faces have been removed. These faces can be united into groups of faces. Each group of faces has an outer wire consisting only of edges belonging to the removed internal wires. Such groups of faces are also removed.
The example of method application is also given below:
Class ShapeCustom_Surface allows:
To convert surfaces to analytical form this class analyzes the form and the closure of the source surface and defines whether it can be approximated by analytical surface of one of the following types:
The conversion is done only if the new (analytical) surface does not deviate from the source one more than by the given precision.
ShapeUpgrade_UnifySameDomain tool allows unifying all possible faces and edges of a shape, which lies on the same geometry. Faces/edges are considered as 'same-domain' if the neighboring faces/edges lie on coincident surfaces/curves. Such faces/edges can be unified into one face/edge. This tool takes an input shape and returns a new one. All modifications of the initial shape are recorded during the operation.
The following options are available:
By default, UnifyFaces and UnifyEdges are set to TRUE; ConcatBSplines is set to FALSE.
The common methods of this tool are as follows:
The example of the usage is given below:
Class ShapeBuild_ReShape rebuilds a shape by making predefined substitutions on some of its components. During the first phase, it records requests to replace or remove some individual shapes. For each shape, the last given request is recorded. Requests may be applied as Oriented (i.e. only to an item with the same orientation) or not (the orientation of the replacing shape corresponds to that of the original one). Then these requests may be applied to any shape, which may contain one or more of these individual shapes.
This tool has a flag for taking the location of shapes into account (for keeping the structure of assemblies) (ModeConsiderLocation). If this mode is equal to Standard_True, the shared shapes with locations will be kept. If this mode is equal to Standard_False, some different shapes will be produced from one shape with different locations after rebuilding. By default, this mode is equal to Standard_False.
To use this tool for the reconstruction of shapes it is necessary to take the following steps:
Additional method IsNewShape can be used to check if the shape has been recorded by BRepTools_ReShape tool as a value.
Note that in fact class ShapeBuild_ReShape is an alias for class BRepTools_ReShape. They differ only in queries of statuses in the ShapeBuild_ReShape class.
Let us use the tool to get the result shape after modification of sub-shapes of the initial shape:
ShapExtend_Status is used to report the status after executing some methods that can either fail, do something, or do nothing. The status is a set of flags DONEi and FAILi. Any combination of them can be set at the same time. For exploring the status, enumeration is used.
The values have the following meaning:
Value | Meaning |
---|---|
OK, | Nothing is done, everything OK |
DONE1, | Something was done, case 1 |
DONE8, | Something was done, case 8 |
DONE, | Something was done (any of DONE#) |
FAIL1, | The method failed, case 1 |
FAIL8, | The method failed, case 8 |
FAIL | The method failed (any of FAIL# occurred) |
Class ShapeExtend_WireData provides a data structure necessary to work with the wire as with an ordered list of edges, and that is required for many algorithms. The advantage of this class is that it allows to work with incorrect wires.
The object of the class ShapeExtend_WireData can be initialized by TopoDS_Wire and converted back to TopoDS_Wire.
An edge in the wire is defined by its rank number. Operations of accessing, adding and removing an edge at/to the given rank number are provided. Operations of circular permutation and reversing (both orientations of all edges and the order of edges) are provided on the whole wire as well.
This class also provides a method to check if the edge in the wire is a seam (if the wire lies on a face).
Let us remove edges from the wire and define whether it is seam edge
Class ShapeExtend_Explorer is intended to explore shapes and convert different representations (list, sequence, compound) of complex shapes. It provides tools for:
Class ShapeExtend_MsgRegistrator attaches messages to objects (generic Transient or shape). The objects of this class are transmitted to the Shape Healing algorithms so that they could collect messages occurred during shape processing. Messages are added to the Maps (stored as a field) that can be used, for instance, by Data Exchange processors to attach those messages to initial file entities.
Let us send and get a message attached to object:
Classes MoniTool_Timer and MoniTool_TimerSentry are used for measuring the performance of a current operation or any part of code, and provide the necessary API. Timers are used for debugging and performance optimizing purposes.
Let us try to use timers in XSDRAWIGES.cxx and IGESBRep_Reader.cxx to analyse the performance of command igesbrep:
The result of DumpTimer() after file translation is as follows:
TIMER | Elapsed | CPU User | CPU Sys | Hits |
---|---|---|---|---|
IGES_LoadFile | 1.0 sec | 0.9 sec | 0.0 sec | 1 |
IGESToBRep_Transfer | 14.5 sec | 4.4 sec | 0.1 sec | 1311 |
The Shape Processing module allows defining and applying the general Shape Processing as a customizable sequence of Shape Healing operators. The customization is implemented via the user-editable resource file, which defines the sequence of operators to be executed and their parameters.
The Shape Processing functionality is implemented with the help of the XSAlgo interface. The main function XSAlgo_AlgoContainer::ProcessShape() does shape processing with specified tolerances and returns the resulting shape and associated information in the form of Transient.
This function is used in the following way:
Let us create a custom sequence of operations:
For example: input of the following string:
means that the corresponding functions from ShapeProcess_OperLibrary will be performed with the original shape aShape using parameters defined for MyOper1 and MyOper3 in the resource file.
It is necessary to note that these operations will be performed step by step and the result obtained after performing the first operation will be used as the initial shape for the second operation.
This operator sets all faces based on indirect surfaces, defined with left-handed coordinate systems as direct faces. This concerns surfaces defined by Axis Placement (Cylinders, etc). Such Axis Placement may be indirect, which is allowed in Cascade, but not allowed in some other systems. This operator reverses indirect placements and recomputes PCurves accordingly.
This operator is required after calling some other operators, according to the computations they do. Its call is explicit, so each call can be removed according to the operators, which are either called or not afterwards. This mainly concerns splitting operators that can split edges.
The operator applies the computation SameParameter which ensures that various representations of each edge (its 3d curve, the pcurve on each of the faces on which it lies) give the same 3D point for the same parameter, within a given tolerance.
This operator can be called with the following parameters:
This operator is used for conversion of surfaces, curves 2d curves to BSpline surfaces with a specified degree and a specified number of spans. It performs approximations on surfaces, curves and 2d curves with a specified degree, maximum number of segments, 2d tolerance, 3d tolerance. The specified continuity can be reduced if the approximation with a specified continuity was not done successfully.
This operator can be called with the following parameters:
The following flags allow managing the conversion of special types of curves or surfaces, in addition to BSpline. They are controlled by SurfaceMode, Curve3dMode or Curve2dMode respectively; by default, only BSplines and Bezier Geometries are considered:
For each of the Mode parameters listed above, if it is True, the specified geometry is converted to BSpline, otherwise only its basic geometry is checked and converted (if necessary) keeping the original type of geometry (revolution, offset, etc).
This operator converts elementary periodic surfaces to SurfaceOfRevolution.
This operator splits surfaces of revolution, cylindrical, toroidal, conical, spherical surfaces in the given shape so that each resulting segment covers not more than the defined number of degrees.
It can be called with the following parameters:
This operator converts some specific types of Surfaces, to BSpline (according to parameters). It can be called with the following parameters:
This operator is used for data supported as Bezier only and converts various types of geometries to Bezier. It can be called with the following parameters used in computation of conversion :
The following parameters are controlled by SurfaceMode, Curve3dMode or Curve2dMode (according to the case):
This operator splits a shape in order to have each geometry (surface, curve 3d, curve 2d) correspond the given criterion of continuity. It can be called with the following parameters:
Because of algorithmic limitations in the operator BSplineRestriction (in some particular cases, this operator can produce unexpected C0 geometry), if SplitContinuity is called, it is recommended to call it after BSplineRestriction. Continuity Values will be set as GeomAbs_Shape (i.e. C0 G1 C1 G2 C2 CN) besides direct integer values (resp. 0 1 2 3 4 5).
This operator splits faces, which are closed even if they are not revolutionary or cylindrical, conical, spherical, toroidal. This corresponds to BSpline or Bezier surfaces which can be closed (whether periodic or not), hence they have a seam edge. As a result, no more seam edges remain. The number of points allows to control the minimum count of faces to be produced per input closed face.
This operator can be called with the following parameters:
This operator must be called when FixFaceSize and/or DropSmallEdges are called. Using Surface Healing may require an additional call to BSplineRestriction to ensure that modified geometries meet the requirements for BSpline. This operators repairs geometries which contain gaps between edges in wires (always performed) or gaps on faces, controlled by parameter SurfaceMode, Gaps on Faces are fixed by using algorithms of Surface Healing This operator can be called with the following parameters:
This operator may change the original geometry. In addition, it is CPU consuming, and it may fail in some cases. Also FixGaps can help only when there are gaps obtained as a result of removal of small edges that can be removed by DropSmallEdges or FixFaceSize.
This operator removes faces, which are small in all directions (spot face) or small in one direction (strip face). It can be called with the parameter Real : Tolerance, which sets the minimal dimension, which is used to consider a face, is small enough to be removed.
This operator drops edges in a wire, and merges them with adjacent edges, when they are smaller than the given value (Tolerance3d) and when the topology allows such merging (i.e. same adjacent faces for each of the merged edges). Free (non-shared by adjacent faces) small edges can be also removed in case if they share the same vertex Parameters.
It can be called with the parameter Real : Tolerance3d, which sets the dimension used to determine if an edge is small.
This operator may be added for fixing invalid shapes. It performs various checks and fixes, according to the modes listed hereafter. Management of a set of fixes can be performed by flags as follows:
By default, the flags are not set, the checks are carried out each individual shape.
This operator can be called with the following parameters:
This operator handles closed edges i.e. edges with one vertex. Such edges are not supported in some receiving systems. This operator splits topologically closed edges (i.e. edges having one vertex) into two edges. Degenerated edges and edges with a size of less than Tolerance are not processed.
Various messages about modification, warnings and fails can be generated in the process of shape fixing or upgrade. The messaging mechanism allows generating messages, which will be sent to the chosen target medium a file or the screen. The messages may report failures and/or warnings or provide information on events such as analysis, fixing or upgrade of shapes.
Enumeration Message_Gravity is used for defining message gravity. It provides the following message statuses:
Class Message_MsgFile allows defining messages by loading a custom message file into memory. It is necessary to create a custom message file before loading it into memory, as its path will be used as the argument to load it. Each message in the message file is identified by a key. The user can get the text content of the message by specifying the message key.
The message file is an ASCII file, which defines a set of messages. Each line of the file must have a length of less than 255 characters.
All lines in the file starting with the exclamation sign (perhaps preceded by spaces and/or tabs) are considered as comments and are ignored. A message file may contain several messages. Each message is identified by its key (string). Each line in the file starting with the dot character (perhaps preceded by spaces and/or tabs) defines the key. The key is a string starting with a symbol placed after the dot and ending with the symbol preceding the ending of the newline character \n. All lines in the file after the key and before the next keyword (and which are not comments) define the message for that key. If the message consists of several lines, the message string will contain newline symbols \n between each line (but not at the end).
The following example illustrates the structure of a message file:
A custom file can be loaded into memory using the method Message_MsgFile::LoadFile, taking as an argument the path to your file as in the example below:
The class Message_Msg allows using the message file loaded as a template. This class provides a tool for preparing the message, filling it with parameters, storing and outputting to the default trace file. A message is created from a key: this key identifies the message to be created in the message file. The text of the message is taken from the loaded message file (class Message_MsgFile is used). The text of the message can contain places for parameters, which are to be filled by the proper values when the message is prepared. These parameters can be of the following types:
Class Message_TraceFile is intended to manage the trace file (or stream) for outputting messages and the current trace level. Trace level is an integer number, which is used when messages are sent. Generally, 0 means minimum, > 0 various levels. If the current trace level is lower than the level of the message it is not output to the trace file. The trace level is to be managed and used by the users. There are two ways of using trace files:
A new default log file can be added using method SetDefault with the same arguments as in the constructor. The default trace level can be changed by using method SetDefLevel. In this way, the information received in the log file is modified. It is possible to close the log file and set the default trace output to the screen display instead of the log file using the method SetDefault without any arguments.