1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

Compare commits

...

24 Commits

Author SHA1 Message Date
emv
ea9cfaa201 0029692: Add functionality to make the group of touching same-dimensional shapes connected
Implementation of the new class *BOPAlgo_MakeConnected* for making the group of touching same-dimensional shapes connected.
Provide the material association for the first sub-elements of the input shapes.
Provide possibility to make the connected shape periodic.

Draw commands for new algorithm:
* makeconnected - make the input shapes connected or glued, performs material associations;
* cmaterialson - returns the materials located on the requested side of a shape;
* cmakeperiodic - makes the connected shape periodic in requested directions;
* crepeatshape - repeats the periodic connected shape in requested directions requested number of times.

Documentation & test cases for the new algorithm.
2018-04-13 11:25:57 +03:00
emv
f6d80ad0bf 0029683: Add functionality to make the TopoDS_Shape periodic in 3D space
Implementation of the new class *BOPAlgo_MakePeriodic* for making the shape periodic in 3D space.
Periodicity of the shape means that the shape can be repeated in any periodic direction any number of times without creation of the new geometry or splits.
The idea of this algorithm is to make the shape look similarly on the opposite sides or on the period bounds of periodic directions.
It does not mean that the opposite sides of the shape will be mirrored. It just means the the opposite sides of the shape should be split by each other and obtain the same geometry on opposite sides.
Such approach will allow repeating the shape, i.e. translating the copy of a shape on the period, without creation of new geometry because there will be no coinciding parts of different dimension.

Draw commands for the new algorithm:
* makeperiodic - makes the shape periodic in required directions;
* repeatshape - repeats the periodic shape in requested periodic direction;
* periodictwins - returns the periodic twins for the shape;
* clearrepetitions - clears all previous repetitions of the periodic shape.

Documentation & test cases for the algorithm.
2018-04-13 11:25:44 +03:00
emv
a0540d9bb9 0029604: Uniform mechanism providing History of shape's modifications for OCCT algorithms in DRAW
Implementation of the mechanism for unification of the history commands for all OCCT algorithms.
The following Draw commands should be used to track the history of shapes modifications of any operation:
- modified - to find the shapes modified from the given shape in the given history.
- generated - to find the shapes generated from the given shape in the given history.
- isdeleted - to check if the given shape has been deleted during operation.

The mechanism allows fast & easy enabling of the DRAW history support for the algorithms supporting the history on the API level (i.e. the algorithm should have the methods Modified(), Generated() and IsDeleted()).
To enable the draw history support it is necessary to store the history of the algorithm into the session. For instance:

TopTools_ListOfShape Objects = ...; // Objects
TopTools_ListOfShape Tools = ...; // Tools

BRepAlgoAPI_Cut aCut(Objects, Tools); // Boolean cut operation

BRepTest_Objects::SetHistory(Objects, aCut); // Store the history for the Objects (overwrites the history in the session)
BRepTest_Objects::AddHistory(Tools, aCut);   // Add the history for the Tools

To get the stored history in draw the command "savehistory" should be used. It saves the history kept in session into a Drawable object with the given name:

# perform cut
bcut r s1 s2

# save history of cut
savehistory cut_history

explode s1 f
modified m cut_history s1_1

The Draw History commands of the following algorithms have been removed:
- Boolean Operations;
- Defeaturing;
- Unify same domain;
- Sweep;
- Thrusections;

All these algorithms have been switched to support the new Draw history mechanism.

The Fillet and Blend algorithms have been also enabled to support history commands.
2018-04-13 11:11:37 +03:00
jgv
ab2ebdcf20 0029204: BRepOffsetAPI_MakePipeShell produces invalid result and raises exception in Draw
1.The algorithm searching the section in the corner (ChooseSection) is modified to be able to find simple cases with rather big tolerance.

2. The constructor of BRepFill_Section is modified: now it removes locations in the shape of section like it was done in BRepFill_Pipe.

3. Correction of U-edges by Same Parameter has been added to the method BRepFill_Sweep::Build.
2018-04-13 11:11:09 +03:00
emv
288e693a98 0029646: Boolean Operations algorithm produces a face with self-intersecting wire
Boolean operations - Allow repeated intersection of edges to find the coinciding pairs.
Previously, only the edges rejected by bounding boxes classification has been additionally checked on coincidence. The current patch removes this filter allowing all edges with coinciding vertices to be checked on coincidence.

Adjustment of the test cases for current behavior:
1. The following cases are improvements:
boolean volumemaker A8
bugs modalg_1 buc60703_1
bugs modalg_1 buc60703_2
bugs modalg_1 buc60703_4
bugs modalg_6 bug26789_1
bugs modalg_6 bug26789_2
bugs modalg_7 bug26883_4
bugs modalg_7 bug27948

2. bugs modalg_7 bug29580_1 is modified to extend the validity checks.
2018-04-13 11:00:36 +03:00
emv
1eeb2c0d2f 0029580: Regression: invalid result of BOP Fuse
Boolean Operation - avoid creation of INTERNAL solid from unclassified faces in Solid Builder algorithm.
Instead warn the user that some of the faces have been unclassified and not used for solids creation.

Adjustment of the test cases.
Test cases for the issue.
2018-04-13 11:00:35 +03:00
emv
5d706f2fa0 0029481: Implementation of the Feature Removal algorithm
Implementation of the 3D model De-featuring algorithm intended for the removal of the unwanted parts (or features) from the model consisting of solids. The features can be the holes, protrusions, gaps, chamfers, fillets etc.
The algorithm removes all possible requested features from the shape and builds the new shape as a result. The input model is not modified.

On the API level the algorithm is implemented in the class *BRepAlgoAPI_Defeaturing*. The actual features removal is performed by the low-level algorithm *BOPAlgo_RemoveFeatures*.

Documentation of the new classes.
Implementation of the DRAW commands for working with new algorithm.
Test cases for the new functionality.

Changes in other algorithms used by De-featuring algorithm:
- Provide history support for the solids in *ShapeUpgrade_UnifySameDomain* algorithm;
- Implementation of the mechanism to merge History of any Algorithm with standard history methods such as IsDeleted(), Modified() and Generated() into *BRepTools_History*;
- Correction of the ElCLib::CircleParameter().
2018-04-13 10:59:19 +03:00
emv
70b3dfe471 0029502: Improve performance of the ShapeUpgrade_UnifySameDomain::UnifyEdges() method
Avoid repeated merging of the same chains of edges by processing all edges at once.

Test cases for the issue.
2018-04-13 10:54:37 +03:00
emv
d69056db56 0029363: No history for shapes which were produced as a result of intersection
1. Implementation of the *Generated* method for the algorithms in Boolean Component.
In terms of these algorithms the shape from the arguments can have Generated shapes only if these new shapes have been obtained as a result of pure intersection (not overlapping) of this shape with any other shapes from arguments.
Thus, the Generated shapes are always:
* VERTICES created from the intersection points and may be Generated from edges and faces only;
* EDGES created from the intersection edges and may be Generated from faces only.

So, only EDGES and FACES could have information about Generated shapes. For all other types of shapes the list of Generated shapes will be empty.

2. Optimization and simplification of the Modified and IsDeleted methods based on the correct filling of the BOPAlgo_BuilderShape::myImagesResult map.

3. Provide history of unification of the solids in the CellsBuilder algorithm.

4. Update of the documentation of Boolean Operations User guide with new chapter "History Information" describing rules for filling history for operations in Boolean Component.

5. Test cases for the issue. New grid "history" has been added into "boolean" category.
2018-04-13 10:52:44 +03:00
emv
1bda31fb86 0029333: Boolean Operations - Prevent modification of the input shapes in case their sub-shapes have not been modified
Prevent modification of the input shapes in destructive mode in case their sub-shapes have not been modified:
1. Prevent edge splitting for the pave blocks with old vertices if it is possible to use the existing edge (*BOPAlgo_PaveFiller::MakeSplitEdges*);
2. Prevent creation of the new containers (WIRES/SHELLS/COMPSOLIDS) if non of its parts have been modified (*BOPAlgo_Builder::FillImagesContainer*);
3. Prevent creation of the new face if non of its wires have been modified (*BOPAlgo_Builder::FillImagesFaces*);
4. If possible, use the original face to be the representative for the group of SD faces (*BOPAlgo_Builder::FillSameDomainFaces*).

Cosmetic changes:
1. Documentation of the *BOPAlgo_Builder* class.
2. Making simple methods of the *BOPAlgo_Builder* class inline.
3. Getting rid of the *BOPAlgo_Builder::mySplits* field as it is excessive. *BOPAlgo_Builder::myImages* can be used instead.
3. Moving the Check Inverted option from *BOPAlgo_Options* to *BOPAlgo_Builder*.

Test cases for the issue.
Adjustment of the test case to their current behavior.
Test case *blend/complex/H2* has been deleted as duplicate of the test case *blend/simple/Z1*.
2018-04-13 10:41:37 +03:00
emv
989b64326c 0029312: Using OBB to speed up Boolean Operations
1. Implementation of the user-defined option for usage of Oriented Bounding Boxes (OBB) in Boolean Operations for additional filtering (rejection) of selected for intersection pairs of sub-shapes.

By default the usage of OBB is turned off.
To enable/disable its usage the method SetUseOBB(flag) should be used. This method is available for all operations in Boolean Component.
To enable/disable it in draw the command "buseobb 0/1" should be used. Note, that this will affect all subsequent operations.

The OBB for the shapes are built by first necessity and stored into operation context (IntTools_Context).

2. Usage of the OBB in some test cases.
2017-12-06 17:18:17 +03:00
nbv
934097524f 0029311: Implementation of the Oriented Bounding Boxes (OBB) functionality
1. The class Bnd_OBB has been created to describe the Oriented Bounding Box.

2. Several key methods have been implemented: Bnd_OBB::IsOut(...), Bnd_OBB::Add(...) and Bnd_OBB::Enlarge(...).

3. Interface of Bnd_Box class has changed. New methods have been created. See Bnd_Box.hxx for detailed information.

4. BRepBndLib and Draw_Box classes have been amended in order to provide correct work with Bnd_OBB class.

5. Interface of "bounding" DRAW-command has been changed. Please see help for detailed information.

6. New DRAW-command "isbbinterf" has been created. Please see help for detailed information.

7. "boundingstr" and "optbounding" DRAW-commands have been eliminated because their function can be made by "bounding" DRAW-command (e.g. see tests/bugs/vis/buc60857 or samples/tcl/snowflake.tcl test cases).

8. Documentation has been updated.
2017-12-06 16:45:09 +03:00
kgv
2630ebd7c3 0029251: Configuration - problem compiling OCCT 7.2 with glibc 2.26
Standard_CLocaleSentry does not include xlocale.h when using glibc anymore.
HAVE_XLOCALE_H has been renamed to OCCT_CLOCALE_POSIX2008 to avoid confusion.

Renamed macros OCC_CHECK_BASE_CLASS -> OCCT_CHECK_BASE_CLASS.
2017-12-05 12:41:28 +03:00
emv
249ab67907 0029321: Improve performance of the 3D offset algorithm for the planar cases
Disable additional intersection of the splits of offset faces implemented in method BRepOffset_MakeOffset::Intersection3D() for the mode "Complete" and join type "Intersection".
This method is insufficient, as it does not allow to detect the tangential faces, necessary for this mode.
Intersection is performed in the method BuildShellsCompleteInter() developed for this mode.
2017-11-22 14:54:49 +03:00
emv
15da20700b 0029322: Unify faces classification procedures in Boolean Operations
1. Unify the faces classification procedure of the methods BOPAlgo_BuilderSolid::PerformInternalShapes() and BOPAlgo_Builder::FillIn3DParts() using the latter as a base.
The new method BOPAlgo_Tools::ClassifyFaces() has been created for that. Both methods mentioned above have been updated to use the new one.

2. Forced intersection of the edges after enlarge of the tolerance values of their vertices during the operation has been added into BOP's intersection algorithm (BOPAlgo_PaveFiller).
BOPAlgo_Tools::PerformCommonBlocks() method has been updated to avoid loosing faces of the already created Common blocks.

As a result the case "boolean gdml_private ZF6" became more stable, because the intermediate result is no longer invalid.
Additional test cases have been added to verify this improvement (bugs modalg_7 bug29322_*)

3. When building PCurves for edges on faces, check the existing PCurves on its validity for periodic surfaces and adjust PCurves if necessary.
The improvement helps to produce the valid result in the test case "bugs moddata_1 bug152".

4. Avoid creation of empty Edge-Edge interference if the intersection point is lying close to a shared vertex.
The improvement helps obtain the valid result of the "bopcheck" operation in the test case "bugs modalg_7 bug27683".

Adjustment of the test case to current behavior:
- Avoid usage of the self-intersecting torus in the test case "boolean gdml_public A9".
- Fix the input shape in the test case "boolean bopfuse_complex H1" to provide valid result.
- Test cases "bugs moddata_1 bug152_1 bug152_2" have been unified into single test case "bugs moddata_1 bug152". Now, the case rebuilds invalid input data and performs all types of Boolean operations.
- Change the test case "bugs modalg_7 bug22750" to produce valid intermediate results used in subsequent operations as arguments.
- The following test cases are improvements:
- "boolean volumemaker D8"
- "boolean volumemaker G1"
- "bugs modalg_7 bug27683"
2017-11-22 14:17:45 +03:00
msv
1ced3e2ccf 0029234: BRepOffsetAPI_NormalProjection produces INTERNAL edges and vertices
Make the algorithm BRepOffsetAPI_NormalProjection use section operation instead of common to get the edge-result of projection to be in face restrictions.

Correct Boolean operation algorithm to produce correctly oriented result in the case of common between face and edge.

The algorithm ShapeUpgrade_UnifySameDomain has been patched to correctly gather same domain faces in a compound.

The TCL script snowflake.tcl has been corrected to get rid of dependence on the order of edges in the result of Boolean operation.
2017-11-22 14:16:18 +03:00
msv
de0eb2d1ce 0029182: BOPAlgo_PaveFiller sometimes raises exception in parallel mode
Data races have been prevented in the code of BOPAlgo_PaveFiller that makes pcurves of edges on faces. For that:
- Put into treatment only unique edge-face pairs.
- If the same edge is treated with different faces in different threads simultaneously this also causes data races. To avoid this make the edge's copy in each thread and update the copy. The original edge is updated only after finishing parallel processing.

The new method BOPTools_AlgoTools::CopyEdge has been added to make a copy of an edge with vertices.

Big screenshot in the test script tests/bugs/modalg_7/bug28200 has been replaced with a small one.
2017-11-22 14:15:56 +03:00
emv
d39c53700f 0029073: Regression: General Cut produces invalid shape
Boolean Operations:
1. Face/Face intersection post treatment - Unify vertices put on the section curves, which were rejected as existing ones, with the vertices of edges by which these section curves have been rejected.

2. Extend Warnings Reporting system of Boolean operations with the new warnings:
- BOPAlgo_AlertIntersectionOfPairOfShapesFailed - to be added when the intersection of pair of sub-shapes of the arguments has failed;
- BOPAlgo_AlertBuildingPCurveFailed - to be added when the building of the 2D curve of the edge on face has failed;
- BOPAlgo_AlertAcquiredSelfIntersection - to be added when the positioning and tolerances of the arguments leads to creation of self-interfered shapes.

These new warnings allow completing the operation even if intersection of some of the sub-shapes or building of some of the PCurves has failed. Moreover, they allow getting the pairs of sub-shapes on which the intersection/projection has failed, providing the user ability to analyze the intersection results.

Note that if some of these warnings appear, the result of the operation should be carefully analyzed for validity.

3. Print messages for the Warnings/Errors met during checking of the shape on self-intersection ("bopcheck" command).
2017-11-22 14:15:55 +03:00
emv
e2785edd92 0029301: Improve performance of Boolean Operations
Improve performance of Boolean operations algorithm by:
- Improving the check of Same Domain faces (BOPAlgo_Builder::FillSameDomainFaces());
- Faster rejection of outer faces for solids using Bounding Box classification first (BOPAlgo_Builder::FillIn3DParts());
- Using IncAllocator for local containers.

Quality improvement has been made in BOPAlgo_PaveFiller class:
1. Method IsExistingPaveBlock() has been corrected to provide the correct edge tolerance and to obtain valid intermediate results in the test case "boolean gdml_private ZH3".
   New test case have been added to verify this improvement (bugs modalg_7 bug29301).
2. Method PutClosingPaveOnCurve() has been corrected to use the tolerance of the pave put on the bound for checking curve on closeness.
   Additional check for the curve to have valid range after addition of the pave on the other end has been added to prevent considering the small curves (covered by vertex tolerance) as closed ones.
   As a result of this modification the test case boolean gdml_public B2 has been fixed (TODO removed).

Adjustment of the test cases to current behavior:
- boolean bopcommon_complex J1 - the produced result was incorrect as it was self-interfered. There should be no common in this case.
- offset shape_type_i_c ZZ1 - the incorrect result is now produced instead of null shape.
2017-11-14 13:23:00 +03:00
msv
333fa3e9bd 0028467: Improve UnifySameDomain performance
This patch turns off some not needed modes of fix in the called ShapeFix_Face algorithm.

It stores pcurves on planes in the edges to avoid repeated computation of the same pcurves many times (it is done only when SafeInputMode is false).

It avoids unnecessary replace/apply actions in the modification context.

It removes the code that makes decomposition of surface of the face on several faces.

The new command buildpcurvesonplane has been added, which builds and stores pcurves of edges on planar faces. This is useful for investigations how presence of pcurves on planes influence performance of algorithms.

Make drawing of dimension line in snowflake test independent on the order of vertices in the result.
2017-11-10 14:22:06 +03:00
emv
b61707279f 0029293: Boolean Operations algorithm does not preserve the orientations of the faces
While building splits of faces (BOPAlgo_Builder::FillImagesFaces()) make sure that the orientation of the input face will be passed to its splits.

Extend draw command "normals" with new key "[-print]" which allows printing values of the normal vector.

Test cases for the issue.
2017-11-08 14:19:30 +03:00
emv
eea21625fb 0029237: Improve performance of Boolean Operations
In order to improve performance of Boolean Operations on the relatively fast cases the following improvements have been made:
1. Initialization of the FaceInfo information for the faces participating in Face/Face interference, even when the gluing is ON, to take into account intersection of their sub-shapes.
2. Code simplification & duplication removal - the methods BOPAlgo_ShellSplitter::MakeConnexityBlocks and BOPAlgo_WireSplitter::MakeConnexityBlocks have been unified into BOPTools_AlgoTools::MakeConnexityBlocks.
3. Avoid unnecessary bounding box computation for solids during DS initialization. The bounding boxes for solids will be computed during the building stage to find faces located inside solids.
   For the shape self-interference check (performed by the BOPAlgo_CheckerSI), the bounding box is still computed, as it is necessary to resolve Shape/Solid intersections.
4. Use only three sample points to check coincidence of line and plane.
5. Perform necessity of planes intersection only when the gluing is off.
6. Avoid repeated initialization of 2D classifier while building splits of the faces.
7. Post treat stage:
7.1. Method CorrectWires: Save edge's data (PCurve, parameter of the vertex, range) to avoid its recalculation.
7.2. Method CheckEdge: While checking vertices on edges avoid unnecessary calculation of their location.
8. Provide possibility to disable the classification of the input solids on the inverted status (to be the holes in the space).
9. Avoid building of bounding boxes for faces/solids during splitting of the input arguments for their classification relatively hole faces/shells if there are no holes created.
10. Avoid rebuilding of the faces/solids from arguments which does not acquire any inside parts from other arguments during the operation by using their draft versions as their splits.

Test cases for the issue.
Correction of the test cases boolean gdml_public A9 and bugs modalg_7 bug28485 as they are improvements.
Additional test case for the issue #28485 as it is fixed by the current changes.
2017-11-02 07:07:01 +03:00
emv
b542b3d6a1 0029188: Null shape is produced by 3D offset algorithm (mode="Complete", Join Type="Intersection")
The following improvements have been made in the 3D offset algorithm for mode "Complete" and Join type "Intersection":
- RemoveInsideFaces() - Removal of the invalid parts outside of the solids built from the splits of offset faces is now performed. It helps to avoid their rebuilding and speed-up the computation.
- FindVerticesToAvoid() - Strengthening the criteria for the vertices to be avoided in the new splits.

Test cases for the issue.
Adjustment of the test cases to current behavior.
2017-10-16 15:55:28 +03:00
emv
788cb92681 0029135: 3D Offset algorithm produces a NULL shape
UpdateValidEdges in BRepOffset_MakeOffset_1 - Perform the filtering of splits of the edges in two stages:
1. Separate filtering of the connected blocks using localized bounding edges taken only from the splits of offset faces from the block;
2. Combined treatment of the remaining splits using bounding edges from the splits of all offset faces.
2017-10-06 07:06:29 +03:00
464 changed files with 21006 additions and 7205 deletions

View File

@@ -68,6 +68,7 @@ FILE_TO_LIST ("adm/RESOURCES" RESOURCES)
foreach (CurrentResource ${RESOURCES})
get_filename_component (CurrentResource_FileName "${CurrentResource}" NAME)
if ("${CurrentResource_FileName}" STREQUAL TObj.msg OR
"${CurrentResource_FileName}" STREQUAL BOPAlgo.msg OR
"${CurrentResource_FileName}" STREQUAL Units.dat OR
"${CurrentResource}" STREQUAL XSMessage OR
"${CurrentResource}" STREQUAL SHMessage OR

View File

@@ -1437,3 +1437,40 @@ The Error/Warning reporting system of the algorithms in Boolean Component (in al
The methods returning the status of errors and warnings of the algorithms (ErrorStatus() and WarningStatus()) have been removed.
Instead use methods HasErrors() and HasWarnings() to check for presence of errors and warnings, respectively.
The full list of errors and warnings, with associated data such as problematic sub-shapes, can be obtained by method GetReport().
@section upgrade_occt721 Upgrade to OCCT 7.2.1
@subsection upgrade_721_Changes_In_USD Changes in ShapeUpgrade_UnifySameDomain
The following public methods in the class ShapeUpgrade_UnifySameDomain became protected:
* *UnifyFaces*
* *UnifyEdges*
The following public method has been removed:
* *UnifyFacesAndEdges*
@subsection upgrade_721_Move_BuildPCurveForEdgeOnPlane Moving BuildPCurveForEdgeOnPlane from BOPTools_AlgoTools2D to BRepLib
The methods BuildPCurveForEdgeOnPlane and BuildPCurveForEdgesOnPlane have been moved from the class BOPTools_AlgoTools2D
to the more lower level class BRepLib.
@subsection upgrade_721_removed Removed features
The following obsolete features have been removed:
* The method *BOPAlgo_Builder::Splits()* has been removed as excessive. The method *BOPAlgo_Builder::Images()* can be used instead.
@section upgrade_occt730 Upgrade to OCCT 7.3.0
@subsection upgrade_730_BOPAlgo_Section Changes in BOPAlgo_Section
The public method *BuildSection()* in the class *BOPAlgo_Section* has became protected. The methods *Perform()* or *PerformWithFiller()* should be called for construction of the result of SECTION operation.
@subsection upgrade_730_BuilderSolid Boolean Operations - Solid Builder algorithm
Previously, the unclassified faces of *BOPAlgo_BuilderSolid* algorithm (the faces which have not been used for solids creation and located outside of all created solids) have been used to form an additional solid (not closed one) with INTERNAL orientation.
Since new version, these unclassified faces are no longer added into resulting solids. Instead, the @ref occt_algorithms_ers "warning" containing these faces appears.
The following public methods of the *BOPAlgo_BuilderSolid* class have been removed as excessive:
* void SetSolid(const TopoDS_Solid& theSolid);
* const TopoDS_Solid& Solid() const;

View File

@@ -548,7 +548,8 @@ The class *BOPAlgo_Options* provides the following options for the algorithms:
* Check the presence of the Errors and Warnings;
* Turn on/off the parallel processing;
* Set the additional tolerance for the operation;
* Break the operations by user request.
* Break the operations by user request;
* Usage of Oriented Bounding boxes in the operation.
@subsection occt_algorithms_root_classes_2 Class BOPAlgo_Algo
@@ -785,6 +786,118 @@ The types of resulting shapes depend on the type of the corresponding argument p
| 7 | EDGE | Set of split EDGEs | |
| 8 | VERTEX | VERTEX | |
@subsection occt_algorithms_7_3a Options
The General Fuse algorithm has a set of options, which allow speeding-up the operation and improving the quality of the result:
* Parallel processing option allows running the algorithm in parallel mode;
* Fuzzy option allows setting the additional tolerance for the operation;
* Safe input shapes option allows preventing modification of the input shapes;
* Gluing option allows speeding-up the intersection of the arguments;
* Possibility to disable the check for the inverted solids among input shapes;
* Usage of Oriented Bounding Boxes in the operation;
* History support.
For more detailed information on these options please see the @ref occt_algorithms_11a "Advanced options" section.
@subsection occt_algorithms_7_3b Usage
The following example illustrates how to use the GF algorithm:
#### Usage of the GF algorithm on C++ level
~~~~
BOPAlgo_Builder aBuilder;
// Setting arguments
TopTools_ListOfShape aLSObjects = …; // Objects
aBuilder.SetArguments(aLSObjects);
// Setting options for GF
// Set parallel processing mode (default is false)
Standard_Boolean bRunParallel = Standard_True;
aBuilder.SetRunParallel(bRunParallel);
// Set Fuzzy value (default is Precision::Confusion())
Standard_Real aFuzzyValue = 1.e-5;
aBuilder.SetFuzzyValue(aFuzzyValue);
// Set safe processing mode (default is false)
Standard_Boolean bSafeMode = Standard_True;
aBuilder.SetNonDestructive(bSafeMode);
// Set Gluing mode for coinciding arguments (default is off)
BOPAlgo_GlueEnum aGlue = BOPAlgo_GlueShift;
aBuilder.SetGlue(aGlue);
// Disabling/Enabling the check for inverted solids (default is true)
Standard Boolean bCheckInverted = Standard_False;
aBuilder.SetCheckInverted(bCheckInverted);
// Set OBB usage (default is false)
Standard_Boolean bUseOBB = Standard_True;
aBuilder.SetUseOBB(buseobb);
// Perform the operation
aBuilder.Perform();
// Check for the errors
if (aBuilder.HasErrors())
{
return;
}
// Check for the warnings
if (aBuilder.HasWarnings())
{
// treatment of the warnings
...
}
// result of the operation
const TopoDS_Shape& aResult = aBuilder.Shape();
~~~~
#### Usage of the GF algorithm on Tcl level
~~~~
# prepare the arguments
box b1 10 10 10
box b2 3 4 5 10 10 10
box b3 5 6 7 10 10 10
# clear inner contents
bclearobjects; bcleartools;
# set the arguments
baddobjects b1 b2 b3
# setting options for GF
# set parallel processing mode (default is 0)
brunparallel 1
# set Fuzzy value
bfuzzyvalue 1.e-5
# set safe processing mode (default is 0)
bnondestructive 1
# set gluing mode (default is 0)
bglue 1
# set check for inverted (default is 1)
bcheckinverted 0
# set obb usage (default is 0)
buseobb 1
# perform intersection
bfillds
# perform GF operaton
bbuild result
~~~~
@subsection occt_algorithms_7_3 Examples
Please, have a look at the examples, which can help to better understand the definitions.
@@ -1061,7 +1174,7 @@ The input data for this step is a *BOPAlgo_Builder* object after building result
@section occt_algorithms_8 Splitter Algorithm
The Splitter algorithm allows splitting a group of arbitrary shapes by another group of arbitrary shapes.<br>
It is based on the General Fuse algorithm, thus all options of the General Fuse such as Fuzzy mode, safe processing mode, parallel mode, gluing mode and history support are also available in this algorithm.
It is based on the General Fuse algorithm, thus all options of the General Fuse (see @ref occt_algorithms_7_3a "GF Options") are also available in this algorithm.
@subsection occt_algorithms_8_1 Arguments
@@ -1082,22 +1195,18 @@ It is based on the General Fuse algorithm, thus all options of the General Fuse
On the low level the Splitter algorithm is implemented in class *BOPAlgo_Splitter*. The usage of this algorithm looks as follows:
~~~~~
BOPAlgo_Splitter aSplitter;
BOPCol_ListOfShape aLSObjects = …; // Objects
BOPCol_ListOfShape aLSTools = …; // Tools
Standard_Boolean bRunParallel = Standard_False; /* parallel or single mode (the default value is FALSE)*/
Standard_Real aTol = 0.0; /* fuzzy option (default value is 0)*/
Standard_Boolean bSafeMode = Standard_False; /* protect or not the arguments from modification*/
BOPAlgo_Glue aGlue = BOPAlgo_GlueOff; /* Glue option to speed up intersection of the arguments*/
// setting arguments
// Setting arguments and tools
TopTools_ListOfShape aLSObjects = …; // Objects
TopTools_ListOfShape aLSTools = …; // Tools
aSplitter.SetArguments(aLSObjects);
aSplitter.SetTools(aLSTools);
// setting options
aSplitter.SetRunParallel(bRunParallel);
aSplitter.SetFuzzyValue(aTol);
aSplitter.SetNonDestructive(bSafeMode);
aSplitter.SetGlue(aGlue);
//
aSplitter.Perform(); //perform the operation
// Set options for the algorithm
// setting options for this algorithm is similar to setting options for GF algorithm (see "GF Usage" chapter)
...
// Perform the operation
aSplitter.Perform();
if (aSplitter.HasErrors()) { //check error status
return;
}
@@ -2041,7 +2150,7 @@ The algorithm creates only closed solids. In general case the result solids are
But the algorithm allows preventing the addition of the internal for solids parts into result. In this case the result solids will be manifold and not contain any internal parts. However, this option does not prevent from the occurrence of the internal edges or vertices in the faces.<br>
Non-closed faces, free wires etc. located outside of any solid are always excluded from the result.
The Volume Maker algorithm is implemented in the class BOPAlgo_MakerVolume. It is based on the General Fuse (GF) algorithm. All the options of the GF algorithm such as possibility to run algorithm in parallel mode, fuzzy option, safe mode, glue options and history support are also available in this algorithm.
The Volume Maker algorithm is implemented in the class BOPAlgo_MakerVolume. It is based on the General Fuse (GF) algorithm. All the options of the GF algorithm (see @ref occt_algorithms_7_3a "GF Options") are also available in this algorithm.
The requirements for the arguments are the same as for the arguments of GF algorithm - they could be of any type, but each argument should be valid and not self-interfered.
@@ -2054,23 +2163,19 @@ This option is useful e.g. for building a solid from the faces of one shell or f
The usage of the algorithm on the API level:
~~~~
BOPAlgo_MakerVolume aMV;
BOPCol_ListOfShape aLS = …; // arguments
Standard_Boolean bRunParallel = Standard_False; /* parallel or single mode (the default value is FALSE)*/
Standard_Boolean bIntersect = Standard_True; /* intersect or not the arguments (the default value is TRUE)*/
Standard_Real aTol = 0.0; /* fuzzy option (default value is 0)*/
Standard_Boolean bSafeMode = Standard_False; /* protect or not the arguments from modification*/
BOPAlgo_Glue aGlue = BOPAlgo_GlueOff; /* Glue option to speed up intersection of the arguments*/
Standard_Boolean bAvoidInternalShapes = Standard_False; /* Avoid or not the internal for solids shapes in the result*/
//
// Set the arguments
TopTools_ListOfShape aLS = …; // arguments
aMV.SetArguments(aLS);
aMV.SetRunParallel(bRunParallel);
aMV.SetIntersect(bIntersect);
aMV.SetFuzzyValue(aTol);
aMV.SetNonDestructive(bSafeMode);
aMV.SetGlue(aGlue);
// Set options for the algorithm
// setting options for this algorithm is similar to setting options for GF algorithm (see "GF Usage" chapter)
...
// Additional option of the algorithm
Standard_Boolean bAvoidInternalShapes = Standard_False; /* Avoid or not the internal for solids shapes in the result*/
aMV.SetAvoidInternalShapes(bAvoidInternalShapes);
//
aMV.Perform(); //perform the operation
// Perform the operation
aMV.Perform();
if (aMV.HasErrors()) { //check error status
return;
}
@@ -2128,7 +2233,7 @@ The algorithm can also create containers from the connected Cells added into res
The algorithm has been implemented in the *BOPAlgo_CellsBuilder* class.
Cells Builder is based on the General Fuse algorithm. Thus all options of the General Fuse algorithm, such as parallel processing mode, fuzzy mode, safe processing mode, gluing mode and history support are also available in this algorithm.
Cells Builder is based on the General Fuse algorithm. Thus all options of the General Fuse algorithm (see @ref occt_algorithms_7_3a "GF Options") are also available in this algorithm.
The requirements for the input shapes are the same as for General Fuse - each argument should be valid in terms of *BRepCheck_Analyzer* and *BOPAlgo_ArgumentAnalyzer*.
@@ -2148,18 +2253,14 @@ It is possible to create typed Containers from the parts added into result by us
Here is the example of the algorithm use on the API level:
~~~~
BOPAlgo_CellsBuilder aCBuilder;
BOPCol_ListOfShape aLS = …; // arguments
Standard_Boolean bRunParallel = Standard_False; /* parallel or single mode (the default value is FALSE)*/
Standard_Real aTol = 0.0; /* fuzzy option (the default value is 0)*/
Standard_Boolean bSafeMode = Standard_False; /* protect or not the arguments from modification*/
BOPAlgo_Glue aGlue = BOPAlgo_GlueOff; /* Glue option to speed up the intersection of arguments*/
//
// Set the arguments
TopTools_ListOfShape aLS = …; // arguments
aCBuilder.SetArguments(aLS);
aCBuilder.SetRunParallel(bRunParallel);
aCBuilder.SetFuzzyValue(aTol);
aCBuilder.SetNonDestructive(bSafeMode);
aCBuilder.SetGlue(aGlue);
//
// Set options for the algorithm
// setting options for this algorithm is similar to setting options for GF algorithm (see "GF Usage" chapter)
...
aCBuilder.Perform(); // build splits of all arguments (GF)
if (aCBuilder.HasErrors()) { // check error status
return;
@@ -2718,6 +2819,63 @@ To enable the safe processing mode for the operation in DRAW, it is necessary to
bnondestructive 1
~~~~
@subsection occt_algorithms_11a_4 Disabling check of the input solids for inverted status
By default, all input solids are checked for inverted status, i.e. the solids are classified to understand if they are holes in the space (negative volumes) or normal solids (positive volumes). The possibility to disable the check of the input solids for inverted status is the advanced option in Boolean Operation component. This option can be applied to all Basic operations such as General Fuse, Splitting, Boolean, Section, Maker Volume, Cells building.
This option allows avoiding time-consuming classification of the input solids and operate with them as with positive volumes, saving up to 10 percent of time on the cases with big number of input solids.
The classification should be disabled only if the user is sure that there are no negative volumes among the input solids, otherwise the result may be invalid.
@subsubsection occt_algorithms_11a_4_1 Usage
#### API level
To enable/disable the classification of the input solids it is necessary to call *SetCheckInverted()* method with the appropriate value:
~~~~
BOPAlgo_Builder aGF;
//
....
// disabling the classification of the input solid
aGF.SetCheckInverted(Standard_False);
//
....
~~~~
#### TCL level
To enable/disable the classification of the solids in DRAW, it is necessary to call the *bcheckinverted* command with appropriate value:
* 0 - disabling the classification;
* 1 - default value, enabling the classification.
~~~~
bcheckinverted 0
~~~~
@subsection occt_algorithms_11a_5_obb Usage of Oriented Bounding Boxes
Since Oriented Bounding Boxes are usually much tighter than Axes Aligned Bounding Boxes (for more information on OBB please see the @ref occt_modat_6 "Bounding boxes" chapter of Modeling data User guide) its usage can significantly speed-up the intersection stage of the operation by reducing the number of interfering objects.
@subsubsection occt_algorithms_11a_5_obb_1 Usage
#### API level
To enable/disable the usage of OBB in the operation it is necessary to call the *SetUseOBB()* method with the approriate value:
~~~~
BOPAlgo_Builder aGF;
//
....
// Enabling the usage of OBB in the operation
aGF.SetUseOBB(Standard_True);
//
....
~~~~
#### TCL level
To enable/disable the usage of OBB in the operation in DRAW it is necessary to call the *buseobb* command with the approriate value:
* 0 - disabling the usage of OBB;
* 1 - enabling the usage of OBB.
~~~~
buseobb 1
~~~~
@section occt_algorithms_ers Errors and warnings reporting system
The chapter describes the Error/Warning reporting system of the algorithms in the Boolean Component.
@@ -2771,6 +2929,148 @@ Warning: The positioning of the shapes leads to creation of small edges without
~~~~
@section occt_algorithms_history History Information
All operations in Boolean Component support @ref occt_modalg_hist "History information". This chapter describes how the History is filled for these operations.
Additionally to Vertices, Edges and Faces the history is also available for the Solids.
The rules for filling the History information about Deleted and Modified shapes are the same as for the API algorithms.
Only the rules for Generated shapes require clarification.
In terms of the algorithms in Boolean Component the shape from the arguments can have Generated shapes only if these new shapes
have been obtained as a result of pure intersection (not overlapping) of this shape with any other shapes from arguments. Thus, the Generated shapes are always:
* VERTICES created from the intersection points and may be Generated from edges and faces only;
* EDGES created from the intersection edges and may be Generated from faces only.
So, only EDGES and FACES could have information about Generated shapes. For all other types of shapes the list of Generated shapes will be empty.
@subsection occt_algorithms_history_ex Examples
Here are some examples illustrating the History information.
@subsubsection occt_algorithms_history_ex_del Deleted shapes
The result of CUT operation of two overlapping planar faces (see the example below) does not contain any parts from the tool face. Thus, the tool face is considered as Deleted.
If the faces are not fully coinciding, the result must contain some parts of the object face. In this case object face will be considered as not deleted.
But if the faces are fully coinciding, the result must be empty, and both faces will be considered as Deleted.
Example of the overlapping faces:
~~~~
plane p 0 0 0 0 0 1
mkface f1 p -10 10 -10 10
mkface f2 p 0 20 -10 10
bclearobjects
bcleartools
baddobjects f1
baddtools f2
bfillds
bbop r 2
savehistory cut_hist
isdeleted cut_hist f1
# Not deleted
isdeleted cut_hist f2
# Deleted
~~~~
@subsubsection occt_algorithms_history_ex_modif Modified shapes
In the FUSE operation of two edges intersecting in one point (see the example below), both edges will be split by the intersection point. All these splits will be contained in the result.
Thus, each of the input edges will be Modified into its two splits.
But in the CUT operation on the same edges, the tool edge will be Deleted from the result and, thus, will not have any Modified shapes.
Example of the intersecting edges:
~~~~
line l1 0 0 0 1 0 0
mkedge e1 l1 -10 10
line l2 0 0 0 0 1 0
mkedge e2 l2 -10 10
bclearobjects
bcleartools
baddobjects e1
baddtools e2
bfillds
# fuse operation
bbop r 1
savehistory fuse_hist
modified m1 fuse_hist e1
nbshapes m1
# EDGES: 2
modified m2 fuse_hist e2
nbshapes m2
# EDGES: 2
# cut operation
bbop r 2
savehistory cut_hist
modified m1 cut_hist e1
nbshapes m1
# EDGES: 2
modified m2 cut_hist e2
# The shape has not been modified
~~~~
@subsubsection occt_algorithms_history_gen Generated shapes
The two intersecting edges will both have the intersection vertices Generated from them.
As for the operation with intersecting faces, consider the following example:
~~~~
plane p1 0 0 0 0 0 1
mkface f1 p1 -10 10 -10 10
plane p2 0 0 0 1 0 0
mkface f2 p2 -10 10 -10 10
bclearobjects
bcleartools
baddobjects f1
baddtools f2
bfillds
# fuse operation
bbop r 1
savehistory fuse_hist
generated gf1 fuse_hist f1
nbshapes gf1
# EDGES: 1
generated gf2 fuse_hist f2
nbshapes gf2
# EDGES: 1
# common operation - result is empty
bbop r 0
savehistory com_hist
generated gf1 com_hist f1
# No shapes were generated from the shape
generated gf2 com_hist f2
# No shapes were generated from the shape
~~~~
@section occt_algorithms_11b Usage
The chapter contains some examples of the OCCT Boolean Component usage. The usage is possible on two levels: C++ and Tcl.
@@ -2813,41 +3113,18 @@ The following example illustrates how to use General Fuse operator:
#include <TopTools_ListOfShape.hxx>
#include <BRepAlgoAPI_BuilderAlgo.hxx>
{…
Standard_Boolean bRunParallel;
Standard_Real aFuzzyValue;
BRepAlgoAPI_BuilderAlgo aBuilder;
//
// prepare the arguments
TopTools_ListOfShape& aLS=…;
//
bRunParallel=Standard_True;
aFuzzyValue=2.1e-5;
//
// set the arguments
aBuilder.SetArguments(aLS);
// set parallel processing mode
// if bRunParallel= Standard_True : the parallel processing is switched on
// if bRunParallel= Standard_False : the parallel processing is switched off
aBuilder.SetRunParallel(bRunParallel);
//
// set Fuzzy value
// if aFuzzyValue=0.: the Fuzzy option is off
// if aFuzzyValue>0.: the Fuzzy option is on
aBuilder.SetFuzzyValue(aFuzzyValue);
//
// safe mode - avoid modification of the arguments
Standard_Boolean bSafeMode = Standard_True;
// if bSafeMode == Standard_True - the safe mode is switched on
// if bSafeMode == Standard_False - the safe mode is switched off
aBuilder.SetNonDestructive(bSafeMode);
//
// gluing options - for coinciding arguments
BOPAlgo_GlueEnum aGlueOpt = BOPAlgo_GlueFull;
// if aGlueOpt == BOPAlgo_GlueOff - the gluing mode is switched off
// if aGlueOpt == BOPAlgo_GlueShift - the gluing mode is switched on
// if aGlueOpt == BOPAlgo_GlueFull - the gluing mode is switched on
aBuilder.SetGlue(aGlueOpt);
//
// Set options for the algorithm
// setting options on this level is similar to setting options to GF algorithm on low level (see "GF Usage" chapter)
...
// run the algorithm
aBuilder.Build();
if (aBuilder.HasErrors()) {
@@ -2874,28 +3151,10 @@ bclearobjects; bcleartools;
#
# set the arguments
baddobjects b1 b2 b3
# set parallel processing mode
# 1: the parallel processing is switched on
# 0: the parallel processing is switched off
brunparallel 1
#
# set Fuzzy value
# 0. : the Fuzzy option is off
# >0. : the Fuzzy option is on
bfuzzyvalue 0.
#
# set safe processing mode
bnondestructive 1
# set safe mode
# 1 - the safe processing mode is switched on
# 0 - the safe processing mode is switched off
#
# set gluing mode
bglue 1
# set the gluing mode
# 1 or 2 - the gluing mode is switched on
# 0 - the gluing mode is switched off
#
# set options for the algorithm (see "GF Usage" chapter)
...
# run the algorithm
# r is the result of the operation
bapibuild r
@@ -2924,31 +3183,9 @@ TopTools_ListOfShape& aLSTools = … ;
aSplitter.SetArguments(aLSObjects);
aSplitter.SetTools(aLSTools);
//
// set options
// parallel processing mode
Standard_Boolean bRunParallel = Standard_True;
// bRunParallel == Standard_True - the parallel processing is switched on
// bRunParallel == Standard_False - the parallel processing is switched off
aSplitter.SetRunParallel();
//
// fuzzy value - additional tolerance for the operation
Standard_Real aFuzzyValue = 1.e-5;
// if aFuzzyValue == 0. - the Fuzzy option is off
// if aFuzzyValue > 0. - the Fuzzy option is on
aSplitter.SetFuzzyValue(aFuzzyValue);
//
// safe mode - avoid modification of the arguments
Standard_Boolean bSafeMode = Standard_True;
// if bSafeMode == Standard_True - the safe mode is switched on
// if bSafeMode == Standard_False - the safe mode is switched off
aSplitter.SetNonDestructive(bSafeMode);
//
// gluing options - for coinciding arguments
BOPAlgo_GlueEnum aGlueOpt = BOPAlgo_GlueFull;
// if aGlueOpt == BOPAlgo_GlueOff - the gluing mode is switched off
// if aGlueOpt == BOPAlgo_GlueShift - the gluing mode is switched on
// if aGlueOpt == BOPAlgo_GlueFull - the gluing mode is switched on
aSplitter.SetGlue(aGlueOpt);
// Set options for the algorithm
// setting options for this algorithm is similar to setting options for GF algorithm (see "GF Usage" chapter)
...
//
// run the algorithm
aSplitter.Build();
@@ -2981,27 +3218,8 @@ baddobjects b1 b2
# set the tools
baddtools f
#
# set parallel processing mode
# 1: the parallel processing is switched on
# 0: the parallel processing is switched off
brunparallel 1
#
# set Fuzzy value
# 0. : the Fuzzy option is off
# >0. : the Fuzzy option is on
bfuzzyvalue 0.
#
# set safe processing mode
bnondestructive 1
# set safe mode
# 1 - the safe processing mode is switched on
# 0 - the safe processing mode is switched off
#
# set gluing mode
bglue 1
# set the gluing mode
# 1 or 2 - the gluing mode is switched on
# 0 - the gluing mode is switched off
# set options for the algorithm (see "GF Usage" chapter)
...
#
# run the algorithm
# r is the result of the operation
@@ -3034,28 +3252,9 @@ The following example illustrates how to use Common operation:
aBuilder.SetArguments(aLS);
aBuilder.SetTools(aLT);
//
// set parallel processing mode
// if bRunParallel= Standard_True : the parallel processing is switched on
// if bRunParallel= Standard_False : the parallel processing is switched off
aBuilder.SetRunParallel(bRunParallel);
//
// set Fuzzy value
// if aFuzzyValue=0.: the Fuzzy option is off
// if aFuzzyValue>0.: the Fuzzy option is on
aBuilder.SetFuzzyValue(aFuzzyValue);
//
// safe mode - avoid modification of the arguments
Standard_Boolean bSafeMode = Standard_True;
// if bSafeMode == Standard_True - the safe mode is switched on
// if bSafeMode == Standard_False - the safe mode is switched off
aBuilder.SetNonDestructive(bSafeMode);
//
// gluing options - for coinciding arguments
BOPAlgo_GlueEnum aGlueOpt = BOPAlgo_GlueFull;
// if aGlueOpt == BOPAlgo_GlueOff - the gluing mode is switched off
// if aGlueOpt == BOPAlgo_GlueShift - the gluing mode is switched on
// if aGlueOpt == BOPAlgo_GlueFull - the gluing mode is switched on
aBuilder.SetGlue(aGlueOpt);
// Set options for the algorithm
// setting options for this algorithm is similar to setting options for GF algorithm (see "GF Usage" chapter)
...
//
// run the algorithm
aBuilder.Build();
@@ -3085,27 +3284,8 @@ bclearobjects; bcleartools;
baddobjects b1 b3
baddtools b2
#
# set parallel processing mode
# 1: the parallel processing is switched on
# 0: the parallel processing is switched off
brunparallel 1
#
# set Fuzzy value
# 0. : the Fuzzy option is off
# >0. : the Fuzzy option is on
bfuzzyvalue 0.
#
# set safe processing mode
bnondestructive 1
# set safe mode
# 1 - the safe processing mode is switched on
# 0 - the safe processing mode is switched off
#
# set gluing mode
bglue 1
# set the gluing mode
# 1 or 2 - the gluing mode is switched on
# 0 - the gluing mode is switched off
# set options for the algorithm (see "GF Usage" chapter)
...
#
# run the algorithm
# r is the result of the operation
@@ -3139,28 +3319,9 @@ The following example illustrates how to use Fuse operation:
aBuilder.SetArguments(aLS);
aBuilder.SetTools(aLT);
//
// set parallel processing mode
// if bRunParallel= Standard_True : the parallel processing is switched on
// if bRunParallel= Standard_False : the parallel processing is switched off
aBuilder.SetRunParallel(bRunParallel);
//
// set Fuzzy value
// if aFuzzyValue=0.: the Fuzzy option is off
// if aFuzzyValue>0.: the Fuzzy option is on
aBuilder.SetFuzzyValue(aFuzzyValue);
//
// safe mode - avoid modification of the arguments
Standard_Boolean bSafeMode = Standard_True;
// if bSafeMode == Standard_True - the safe mode is switched on
// if bSafeMode == Standard_False - the safe mode is switched off
aBuilder.SetNonDestructive(bSafeMode);
//
// gluing options - for coinciding arguments
BOPAlgo_GlueEnum aGlueOpt = BOPAlgo_GlueFull;
// if aGlueOpt == BOPAlgo_GlueOff - the gluing mode is switched off
// if aGlueOpt == BOPAlgo_GlueShift - the gluing mode is switched on
// if aGlueOpt == BOPAlgo_GlueFull - the gluing mode is switched on
aBuilder.SetGlue(aGlueOpt);
// Set options for the algorithm
// setting options for this algorithm is similar to setting options for GF algorithm (see "GF Usage" chapter)
...
//
// run the algorithm
aBuilder.Build();
@@ -3190,27 +3351,8 @@ bclearobjects; bcleartools;
baddobjects b1 b3
baddtools b2
#
# set parallel processing mode
# 1: the parallel processing is switched on
# 0: the parallel processing is switched off
brunparallel 1
#
# set Fuzzy value
# 0. : the Fuzzy option is off
# >0. : the Fuzzy option is on
bfuzzyvalue 0.
#
# set safe processing mode
bnondestructive 1
# set safe mode
# 1 - the safe processing mode is switched on
# 0 - the safe processing mode is switched off
#
# set gluing mode
bglue 1
# set the gluing mode
# 1 or 2 - the gluing mode is switched on
# 0 - the gluing mode is switched off
# set options for the algorithm (see "GF Usage" chapter)
...
#
# run the algorithm
# r is the result of the operation
@@ -3244,28 +3386,9 @@ The following example illustrates how to use Cut operation:
aBuilder.SetArguments(aLS);
aBuilder.SetTools(aLT);
//
// set parallel processing mode
// if bRunParallel= Standard_True : the parallel processing is switched on
// if bRunParallel= Standard_False : the parallel processing is switched off
aBuilder.SetRunParallel(bRunParallel);
//
// set Fuzzy value
// if aFuzzyValue=0.: the Fuzzy option is off
// if aFuzzyValue>0.: the Fuzzy option is on
aBuilder.SetFuzzyValue(aFuzzyValue);
//
// safe mode - avoid modification of the arguments
Standard_Boolean bSafeMode = Standard_True;
// if bSafeMode == Standard_True - the safe mode is switched on
// if bSafeMode == Standard_False - the safe mode is switched off
aBuilder.SetNonDestructive(bSafeMode);
//
// gluing options - for coinciding arguments
BOPAlgo_GlueEnum aGlueOpt = BOPAlgo_GlueFull;
// if aGlueOpt == BOPAlgo_GlueOff - the gluing mode is switched off
// if aGlueOpt == BOPAlgo_GlueShift - the gluing mode is switched on
// if aGlueOpt == BOPAlgo_GlueFull - the gluing mode is switched on
aBuilder.SetGlue(aGlueOpt);
// Set options for the algorithm
// setting options for this algorithm is similar to setting options for GF algorithm (see "GF Usage" chapter)
...
//
// run the algorithm
aBuilder.Build();
@@ -3295,27 +3418,8 @@ bclearobjects; bcleartools;
baddobjects b1 b3
baddtools b2
#
# set parallel processing mode
# 1: the parallel processing is switched on
# 0: the parallel processing is switched off
brunparallel 1
#
# set Fuzzy value
# 0. : the Fuzzy option is off
# >0. : the Fuzzy option is on
bfuzzyvalue 0.
#
# set safe processing mode
bnondestructive 1
# set safe mode
# 1 - the safe processing mode is switched on
# 0 - the safe processing mode is switched off
# set gluing mode
#
bglue 1
# set the gluing mode
# 1 or 2 - the gluing mode is switched on
# 0 - the gluing mode is switched off
# set options for the algorithm (see "GF Usage" chapter)
...
#
# run the algorithm
# r is the result of the operation
@@ -3350,28 +3454,9 @@ The following example illustrates how to use Section operation:
aBuilder.SetArguments(aLS);
aBuilder.SetTools(aLT);
//
// set parallel processing mode
// if bRunParallel= Standard_True : the parallel processing is switched on
// if bRunParallel= Standard_False : the parallel processing is switched off
aBuilder.SetRunParallel(bRunParallel);
//
// set Fuzzy value
// if aFuzzyValue=0.: the Fuzzy option is off
// if aFuzzyValue>0.: the Fuzzy option is on
aBuilder.SetFuzzyValue(aFuzzyValue);
//
// safe mode - avoid modification of the arguments
Standard_Boolean bSafeMode = Standard_True;
// if bSafeMode == Standard_True - the safe mode is switched on
// if bSafeMode == Standard_False - the safe mode is switched off
aBuilder.SetNonDestructive(bSafeMode);
//
// gluing options - for coinciding arguments
BOPAlgo_GlueEnum aGlueOpt = BOPAlgo_GlueFull;
// if aGlueOpt == BOPAlgo_GlueOff - the gluing mode is switched off
// if aGlueOpt == BOPAlgo_GlueShift - the gluing mode is switched on
// if aGlueOpt == BOPAlgo_GlueFull - the gluing mode is switched on
aBuilder.SetGlue(aGlueOpt);
// Set options for the algorithm
// setting options for this algorithm is similar to setting options for GF algorithm (see "GF Usage" chapter)
...
//
// run the algorithm
aBuilder.Build();
@@ -3401,27 +3486,8 @@ bclearobjects; bcleartools;
baddobjects b1 b3
baddtools b2
#
# set parallel processing mode
# 1: the parallel processing is switched on
# 0: the parallel processing is switched off
brunparallel 1
#
# set Fuzzy value
# 0. : the Fuzzy option is off
# >0. : the Fuzzy option is on
bfuzzyvalue 0.
#
# set safe processing mode
bnondestructive 1
# set safe mode
# 1 - the safe processing mode is switched on
# 0 - the safe processing mode is switched off
#
# set gluing mode
bglue 1
# set the gluing mode
# 1 or 2 - the gluing mode is switched on
# 0 - the gluing mode is switched off
# set options for the algorithm (see "GF Usage" chapter)
...
#
# run the algorithm
# r is the result of the operation

View File

@@ -5821,6 +5821,9 @@ The following topics are covered in the eight sections of this chapter:
* Transformations of shapes: translation, copy, etc.
* Topological operations, or booleans.
* Drafting and blending.
* Defeaturing.
* Making shapes periodic in 3D space.
* Making shapes connected.
* Analysis of shapes.
@@ -7299,13 +7302,160 @@ buildevol
~~~~~
@subsection occt_draw_defeaturing Defeaturing
Draw command **removefeatures** is intended for performing @ref occt_modalg_defeaturing "3D Model Defeaturing", i.e. it performs the removal of the requested features from the shape.
Syntax:
~~~~
removefeatures result shape f1 f2 ... [-nohist] [-parallel]
Where:
result - result of the operation;
shape - the shape to remove the features from;
f1, f2 - features to remove from the shape;
Options:
nohist - disables the history collection;
parallel - enables the parallel processing mode.
~~~~
@subsection occt_draw_makeperiodic 3D Model Periodicity
Draw module for @ref occt_modalg_makeperiodic "making the shape periodic" includes the following commands:
* **makeperiodic** - makes the shape periodic in required directions;
* **repeatshape** - repeats the periodic shape in requested periodic direction;
* **periodictwins** - returns the periodic twins for the shape;
* **clearrepetitions** - clears all previous repetitions of the periodic shape.
@subsubsection occt_draw_makeperiodic_makeperiodic makeperiodic
The command makes the shape periodic in the required directions with the required period.
If trimming is given it trims the shape to fit the requested period.
Syntax:
~~~~
makeperiodic result shape [-x/y/z period [-trim first]]
Where:
result - resulting periodic shape;
shape - input shape to make it periodic:
-x/y/z period - option to make the shape periodic in X, Y or Z direction with the given period;
-trim first - option to trim the shape to fit the required period, starting the period in first.
~~~~
@subsubsection occt_draw_makeperiodic_repeatshape repeatshape
The command repeats the periodic shape in periodic direction requested number of time.
The result contains the all the repeated shapes glued together.
The command should be called after **makeperiodic** command.
Syntax:
~~~~
repeatshape result -x/y/z times
Where:
result - resulting shape;
-x/y/z times - direction for repetition and number of repetitions (negative number of times means the repetition in negative direction).
~~~~
@subsubsection occt_draw_makeperiodic_periodictwins periodictwins
For the given shape the command returns the identical shapes located on the opposite sides of the periodic direction.
All periodic twins should have the same geometry.
The command should be called after **makeperiodic** command.
Syntax:
~~~~
periodictwins twins shape
Where:
twins - periodic twins for the given shape
shape - shape to find the twins for
~~~~
@subsubsection occt_draw_makeperiodic_clearrepetitions clearrepetitions
The command clears all previous repetitions of the periodic shape allowing to start the repetitions over.
No arguments are needed for the command.
@subsection occt_draw_makeconnected Making the touching shapes connected
Draw module for @ref occt_modalg_makeconnected "making the touching same-dimensional shapes connected" includes the following commands:
* **makeconnected** - make the input shapes connected or glued, performs material associations;
* **cmaterialson** - returns the materials located on the requested side of a shape;
* **cmakeperiodic** - makes the connected shape periodic in requested directions;
* **crepeatshape** - repeats the periodic connected shape in requested directions requested number of times.
@subsubsection occt_draw_makeconnected_makeconnected makeconnected
The command makes the input touching shapes connected.
Syntax:
~~~~
makeconnected result shape1 shape2 ...
Where:
result - resulting connected shape.
shape1 shape2 ... - shapes to be made connected.
~~~~
@subsubsection occt_draw_makeconnected_cmaterialson cmaterialson
The command returns the materials located on the requested side of the shape.
The command should be called after the shapes have been made connected, i.e. after the command **makeconnected**.
Syntax:
~~~~
cmaterialson result +/- shape
Where:
result - material shapes
shape - shape for which the materials are needed
+/- - side of a given shape ('+' for positive side, '-' - for negative).
~~~~
@subsubsection occt_draw_makeconnected_cmakeperiodic cmakeperiodic
The command makes the connected shape periodic in the required directions with the required period.
The command should be called after the shapes have been made connected, i.e. after the command **makeconnected**.
Syntax:
~~~~
cmakeperiodic result [-x/y/z period [-trim first]]
Where:
result - resulting periodic shape;
shape - input shape to make it periodic:
-x/y/z period - option to make the shape periodic in X, Y or Z direction with the given period;
-trim first - option to trim the shape to fit the required period, starting the period in first.
~~~~
@subsubsection occt_draw_makeconnected_crepeatshape crepeatshape
The command repeats the connected periodic shape in the required periodic directions required number of times.
The command should be called after the shapes have been made connected and periodic, i.e. after the commands **makeconnected** and **cmakeperiodic**.
Syntax:
~~~~
crepeatshape result -x/y/z times
Where:
result - resulting shape;
-x/y/z times - direction for repetition and number of repetitions (negative number of times means the repetition in negative direction).
~~~~
@subsection occt_draw_7_9 Analysis of topology and geometry
Analysis of shapes includes commands to compute length, area, volumes and inertial properties, as well as to compute some aspects impacting shape validity.
* Use **lprops**, **sprops**, **vprops** to compute integral properties.
* Use **bounding** to display the bounding box of a shape.
* Use **bounding** to compute and to display the bounding box of a shape.
* Use **distmini** to calculate the minimum distance between two shapes.
* Use **isbbinterf** to check if the two shapes are interfered by their bounding boxes.
* Use **xdistef**, **xdistcs**, **xdistcc**, **xdistc2dc2dss**, **xdistcc2ds** to check the distance between two objects on even grid.
* Use **checkshape** to check validity of the shape.
* Use **tolsphere** to see the tolerance spheres of all vertices in the shape.
@@ -7358,20 +7508,135 @@ I.Z = 314159.265357595
Syntax:
~~~~~
bounding shape
bounding {-s shape | -c xmin ymin zmin xmax ymax zmax} [-obb] [-shape name] [-dump] [-notriangulation] [-perfmeter name NbIters] [-save xmin ymin zmin xmax ymax zmax] [-nodraw] [-optimal] [-exttoler]
~~~~~
Displays the bounding box of a shape. The bounding box is a cuboid created with faces parallel to the x, y, and z planes. The command returns the dimension values of the the box, *xmin ymin zmin xmax ymax zmax.*
Computes and displays the bounding box (BndBox) of a shape. The bounding box is a cuboid circumscribes the source shape.
Generaly, bounding boxes can be divided on two main types:
- axis-aligned BndBox (AABB). I.e. the box whose edges are parallel to the some axis of World Coordinate System (WCS);
- oriented BndBox (OBB). I.e. not AABB.
**Example:**
Detailed information about this command is availabe in DRAW help-system (enter "help bounding" in DRAW-application).
**Example 1: Creation of AABB with given corners**
~~~~~
# bounding box of a torus
bounding -c 50 100 30 180 200 100 -shape result
# look at the box
vdisplay result
vfit
vsetdispmode 1
~~~~~
**Example 2: Compare AABB and OBB**
~~~~~
# Create a torus and rotate it
ptorus t 20 5
bounding t
==-27.059805107309852 -27.059805107309852 -
5.0000001000000003
==27.059805107309852 27.059805107309852
5.0000001000000003
trotate t 5 10 15 1 1 1 28
# Create AABB from the torus
bounding -s t -shape ra -dump -save x1 y1 z1 x2 y2 z2
==Axes-aligned bounding box
==X-range: -26.888704600189307 23.007685197265488
==Y-range: -22.237699567214314 27.658690230240481
==Z-range: -13.813966507560762 12.273995247458407
# Obtain the boundaries
dump x1 y1 z1 x2 y2 z2
==*********** Dump of x1 *************
==-26.8887046001893
==*********** Dump of y1 *************
==-22.2376995672143
==*********** Dump of z1 *************
==-13.8139665075608
==*********** Dump of x2 *************
==23.0076851972655
==*********** Dump of y2 *************
==27.6586902302405
==*********** Dump of z2 *************
==12.2739952474584
# Compute the volume of AABB
vprops ra 1.0e-12
==Mass : 64949.9
# Let us check this value
dval (x2-x1)*(y2-y1)*(z2-z1)
==64949.886543606823
~~~~~
The same result is obtained.
~~~~~
# Create OBB from the torus
bounding -s t -shape ro -dump -obb
==Oriented bounding box
==Center: -1.9405097014619073 2.7104953315130857 -0.76998563005117782
==X-axis: 0.31006700219833244 -0.23203206410428409 0.9219650619059514
==Y-axis: 0.098302309139513336 -0.95673739537318336 -0.27384340837854165
==Z-axis: 0.94561890324040099 0.17554109923901748 -0.27384340837854493
==Half X: 5.0000002000000077
==Half Y: 26.783728747002169
==Half Z: 26.783728747002165
# Compute the volume of OBB
vprops ro 1.0e-12
==Mass : 28694.7
~~~~~
As we can see, the volume of OBB is significantly less than the volume of AABB.
@subsubsection occt_draw_7_9_2a isbbinterf
Syntax:
~~~~~
isbbinterf shape1 shape2 [-o]
~~~~~
Checks whether the bounding-boxes created from the given shapes are interfered. If "-o"-option is switched on then the oriented boxes will be checked. Otherwise, axes-aligned boxes will be checked.
**Example 1: Not interfered AABB**
~~~~~
box b1 100 60 140 20 10 80
box b2 210 200 80 120 60 90
isbbinterf b1 b2
==The shapes are NOT interfered by AABB.
~~~~~
**Example 2: Interfered AABB**
~~~~~
box b1 300 300 300
box b2 100 100 100 50 50 50
isbbinterf b1 b2
==The shapes are interfered by AABB.
~~~~~
**Example 3: Not interfered OBB**
~~~~~
box b1 100 150 200
copy b1 b2
trotate b1 -150 -150 -150 1 2 3 -40
trotate b2 -150 -150 -150 1 5 2 60
# Check of interference
isbbinterf b1 b2 -o
==The shapes are NOT interfered by OBB.
~~~~~
**Example 4: Interfered OBB**
~~~~~
box b1 100 150 200
copy b1 b2
trotate b1 -50 -50 -50 1 1 1 -40
trotate b2 -50 -50 -50 1 1 1 60
# Check of interference
isbbinterf b1 b2 -o
==The shapes are interfered by OBB.
~~~~~
@subsubsection occt_draw_7_9_3 distmini
@@ -7873,6 +8138,163 @@ Options:
* -a AngTol - angular tolerance used for distinguishing the planar faces;
* -s Shared(0/1) - boolean flag which defines whether the input edges are already shared or have to be intersected.
@subsection occt_draw_hist History commands
Draw module for @ref occt_modalg_hist "History Information support" includes the command to save history into a drawable object and the actual history commands:
* *savehistory*;
* *isdeleted*;
* *modified*;
* *generated*.
@subsubsection occt_draw_hist_save savehistory
*savehistory* command saves the history from the session into a drawable object with the given name.
Syntax:
~~~~
savehistory : savehistory name
~~~~
If the history of some operation is needed the *savehistory* command should be called after the command performing the operation.
If some other operation supporting history will be performed before the history of first operation is saved it will be overwritten with the new history.
Example:
~~~~
box b1 10 10 10
box b2 5 0 0 10 10 15
bfuse r b1 b2
savehistory fuse_hist
dump fuse_hist
#*********** Dump of fuse_hist *************
# History contains:
# - 4 Deleted shapes;
# - 20 Modified shapes;
# - 6 Generated shapes.
unifysamedom ru r
savehistory usd_hist
dump usd_hist
#*********** Dump of usd_hist *************
#History contains:
# - 14 Deleted shapes;
# - 28 Modified shapes;
# - 0 Generated shapes.
~~~~
@subsubsection occt_draw_hist_isdel isdeleted
*isdeleted* command checks if the given shape has been deleted in the given history.
Syntax:
~~~~
isdeleted : isdeleted history shape
~~~~
Example:
~~~~
box b1 4 4 4 2 2 2
box b2 10 10 10
bcommon r b1 b2
savehistory com_hist
# all vertices, edges and faces of the b2 are deleted
foreach s [join [list [explode b2 v] [explode b2 e] [explode b2 f] ] ] {
isdeleted com_hist $s
# Deleted
}
~~~~
@subsubsection occt_draw_hist_mod modified
*modified* command returns the shapes Modified from the given shape in the given history. All modified shapes are put into compound. If the shape has not been modified the resulting compound will be empty. Note that if the shape has been modified into a single shape only, it will be returned without enclosure into compound.
Syntax:
~~~~
modified : modified modified_shapes history shape
~~~~
Example:
~~~~
box b 10 10 10
explode b e
fillet r b 2 b_1
savehistory fillet_hist
explode b f
modified m3 fillet_hist b_3
modified m5 fillet_hist b_5
~~~~
@subsubsection occt_draw_hist_gen generated
*generated* command returns the shapes Generated from the given shape in the given history. All generated shapes are put into compound. If no shapes have been generated from the shape the resulting compound will be empty. Note that if the shape has generated a single shape only, it will be returned without enclosure into compound.
Syntax:
~~~~
generated : generated generated_shapes history shape
~~~~
Example:
~~~~
polyline w1 0 0 0 10 0 0 10 10 0
polyline w2 5 1 10 9 1 10 9 5 10
thrusections r 0 0 w1 w2
savehistory loft_hist
explode w1 e
explode w2 e
generated g11 loft_hist w1_1
generated g12 loft_hist w1_2
generated g21 loft_hist w2_1
generated g22 loft_hist w2_2
compare g11 g21
# equal shapes
compare g12 g22
# equal shapes
~~~~
@subsubsection occt_draw_hist_extension Enabling Draw history support for the algorithms
Draw History mechanism allows fast and easy enabling of the Draw history support for the OCCT algorithms supporting standard history methods.
To enable History commands for the algorithm it is necessary to save the history of the algorithm into the session.
For that, it is necessary to put the following code into the command implementation just after the command is done:
~~~~
BRepTest_Objects::SetHistory(ListOfArguments, Algorithm);
~~~~
Here is the example of how it is done in the command performing Split operation (see implementation of the *bapisplit* command):
~~~~
BRepAlgoAPI_Splitter aSplitter;
// setting arguments
aSplitter.SetArguments(BOPTest_Objects::Shapes());
// setting tools
aSplitter.SetTools(BOPTest_Objects::Tools());
// setting options
aSplitter.SetRunParallel(BOPTest_Objects::RunParallel());
aSplitter.SetFuzzyValue(BOPTest_Objects::FuzzyValue());
aSplitter.SetNonDestructive(BOPTest_Objects::NonDestructive());
aSplitter.SetGlue(BOPTest_Objects::Glue());
aSplitter.SetCheckInverted(BOPTest_Objects::CheckInverted());
aSplitter.SetUseOBB(BOPTest_Objects::UseOBB());
// performing operation
aSplitter.Build();
// Store the history for the Objects (overwrites the history in the session)
BRepTest_Objects::SetHistory(BOPTest_Objects::Shapes(), aSplitter);
// Add the history for the Tools
BRepTest_Objects::AddHistory(BOPTest_Objects::Tools(), aSplitter);
~~~~
@subsection occt_draw_7_12 Texture Mapping to a Shape

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

View File

@@ -1283,6 +1283,109 @@ Standard_DomainError::Raise
TopoDS_Edge E = ME;
~~~~~
@subsection occt_modalg_hist History support
All topological API algorithms support the history of shapes modifications (or just History) for their arguments.
Generally, the history is available for the following types of sub-shapes of input shapes:
* Vertex
* Edge
* Face
Some algorithms also support the history for Solids.
The history information consists of the following information:
* Information about Deleted shapes;
* Information about Modified shapes;
* Information about Generated shapes.
The History is filled basing on the result of the operation. History cannot return any shapes not contained in the result.
Thus, if the result of the operation is empty shape, all input shapes will be considered as Deleted and none will have Modified and Generated shapes.
The history information can be accessed by the API methods:
* *Standard_Boolean IsDeleted(const TopoDS_Shape& theS)* - to check if the shape has been Deleted during the operation;
* *const TopTools_ListOfShape& Modified(const TopoDS_Shape& theS)* - to get the shapes Modified from the given shape;
* *const TopTools_ListOfShape& Generated(const TopoDS_Shape& theS)* - to get the shapes Generated from the given shape.
@subsubsection occt_modalg_hist_del Deleted shapes
The shape is considered as Deleted during the operation if all of the following conditions are met:
* The shape is the part of the argument shapes of the operation;
* The result shape does not contain the shape itself;
* The result shape does not contain any of the splits of the shape.
For example, in the CUT operation between two intersecting solids all vertices/edges/faces located completely inside the Tool solid will be Deleted during the operation.
@subsubsection occt_modalg_hist_mod Modified shapes
The shape is considered as Modified during the operation if the result shape contains the splits of the shape, not the shape itself. The shape can be modified only into the shapes with same dimension.
The splits of the shape contained in the result shape are Modified from the shape.
The Modified shapes are created from the sub-shapes of the input shapes and, generally, repeat their geometry.
The list of Modified elements will contain only those which are contained in the result of the operation. If the list is empty the shape has not been modified and it is necessary to check if it has been Deleted.
For example, after translation of the shape in any direction all its sub-shapes will be modified into their translated copies.
@subsubsection occt_modalg_hist_gen Generated shapes
The shapes contained in the result shape are considered as Generated from the input shape if they were produced during the operation and have different dimension with the shapes from which they were created.
The list of Generated elements will contain only those which are contained in the result of the operation. If the list is empty no new shapes have been Generated from the shape.
For example, extrusion of the edge in some direction will create a face. This face will be generated from the edge.
@subsubsection occt_modalg_hist_tool BRepTools_History
*BRepTools_History* is the general History tool intended for unification of the histories of different algorithms.
BRepTools_History can be created from any algorithm supporting the standard history methods (IsDeleted(), Modified() and Generated()):
~~~~
// The arguments of the operation
TopoDS_Shape aS = ...;
// Perform transformation on the shape
gp_Trsf aTrsf;
aTrsf.SetTranslationPart(gp_Vec(0, 0, 1));
BRepBuilderAPI_Transform aTransformer(aS, aTrsf); // Transformation API algorithm
const TopoDS_Shape& aRes = aTransformer.Shape();
// Create the translation history object
TopTools_ListOfShape anArguments;
anArguments.Append(aS);
BRepTools_History aHistory(anArguments, aTransformer);
~~~~
BRepTools_History also allows merging of the histories. Thus, if you have two or more subsequent operations you can get one final history combined from histories of these operations:
~~~~
Handle(BRepTools_History) aHist1 = ...; // History of first operation
Handle(BRepTools_History) aHist2 = ...; // History of second operation
~~~~
It is possible to merge the second history into the first one:
~~~~
aHist1->Merge(aHist2);
~~~~
Or create the new history keeping the two histories unmodified:
~~~~
Handle(BRepTools_History) aResHistory = new BRepTools_History;
aResHistory->Merge(aHist1);
aResHistory->Merge(aHist2);
~~~~
The possibility of Merging of the histories and its creation from the API algorithms allows providing easy History support for the new algorithms.
@subsubsection occt_modalg_hist_draw DRAW history support
DRAW History support for the algorithms supporting history is provided by three basic commands:
* *isdeleted*;
* *modified*;
* *generated*.
For more information on the Draw History mechanism please refer the corresponding chapter in the Draw users guide - @ref occt_draw_hist "History commands".
@section occt_modalg_3 Standard Topological Objects
The following standard topological objects can be created:
@@ -3035,3 +3138,489 @@ Meshing covers a shape with a triangular mesh. Other than hidden line removal, y
You can obtain information on the shape by first exploring it. To access triangulation of a face in the shape later, use *BRepTool::Triangulation*. To access a polygon, which is the approximation of an edge of the face, use *BRepTool::PolygonOnTriangulation*.
@section occt_modalg_defeaturing 3D Model Defeaturing
The Open CASCADE Technology Defeaturing algorithm is intended for removal of the unwanted parts or features from the model. These parts could be the holes, protrusions, gaps, chamfers, fillets etc.
Feature detection is not performed, and all features desired for removal should be defined by the user. The input shape is not modified during Defeaturing, the new shape is built in the result.
On the API level the Defeaturing algorithm is implemented in the *BRepAlgoAPI_Defeaturing* class. On the input the algorithm accepts the shape to remove the features from and the features (one or many) to remove from the shape.
Currently, the input shape should either be SOLID, or COMPSOLID, or COMPOUND of SOLIDs.
The features to remove are the sets of faces forming the features. It does not matter how the feature faces are given. It could be the separate faces or the collections of them. The faces should belong to the initial shape, and those that do not belong will be ignored.
The actual features removal is performed by the low-level *BOPAlgo_RemoveFeatures* algorithm. On the API level, all the inputs are passed into the tool and the method *BOPAlgo_RemoveFeatures::Perform()* is called.
Before starting Features removal all the faces requested for removal from the shape are sorted on the connected blocks - each block represents single feature to remove.
The features will be removed from the shape one by one, which will allow removing all possible features even if there were some problems with the removal of some of them (due to e.g. incorrect input data).
The removed feature is filled by the extension of the faces adjacent to the feature. In general, the algorithm of removing of the single feature from the shape looks as follows:
* Find the faces adjacent to the feature;
* Extend the adjacent faces to cover the feature;
* Trim the extended faces by the bounds of original face (except for bounds common with the feature), so it will cover the feature only;
* Rebuild the solids with reconstructed adjacent faces avoiding the feature faces.
If the single feature removal was successful, the result shape is overwritten with the new shape, otherwise the results are not kept, and the warning is given.
Either way the process continues with the next feature.
The Defeaturing algorithm has the following options:
* History support;
and the options available from base class (*BOPAlgo_Options*):
* Error/Warning reporting system;
* Parallel processing mode.
Please note that the other options of the base class are not supported here and will have no effect.
<b>History support</b> allows tracking modification of the input shape in terms of Modified, IsDeleted and Generated. By default, the history is collected, but it is possible to disable it using the method *TrackHistory(false)*.
On the low-level the history information is collected by the history tool *BRepTools_History*, which can be accessed through the method *BOPAlgo_RemoveFeatures::History()*.
<b>Error/Warning reporting system</b> - allows obtaining the extended overview of the Errors/Warnings occurred during the operation. As soon as any error appears the algorithm stops working. The warnings allow continuing the job, informing the user that something went wrong. The algorithm returns the following errors/warnings:
* BOPAlgo_AlertUnsupportedType - the alert will be given as an error if the input shape does not contain any solids, and as a warning if the input shape contains not only solids, but also other shapes;
* BOPAlgo_AlertNoFacesToRemove - the error alert is given in case there are no faces to remove from the shape (nothing to do);
* BOPAlgo_AlertUnableToRemoveTheFeature - the warning alert is given to inform the user the removal of the feature is not possible. The algorithm will still try to remove the other features;
* BOPAlgo_AlertRemoveFeaturesFailed - the error alert is given in case if the operation was aborted by the unknown reason.
For more information on the error/warning reporting system please see the chapter @ref occt_algorithms_ers "Errors and warnings reporting system" of Boolean operations user guide.
<b>Parallel processing mode</b> - allows running the algorithm in parallel mode obtaining the result faster.
The algorithm has certain limitations:
* Intersection of the surfaces of the connected faces adjacent to the feature should not be empty. It means, that such faces should not be tangent to each other.
If the intersection of the adjacent faces will be empty, the algorithm will be unable to trim the faces correctly and, most likely, the feature will not be removed.
* The algorithm does not process the INTERNAL parts of the solids, they are simply removed during reconstruction.
Note, that for successful removal of the feature, the extended faces adjacent to the feature should cover the feature completely, otherwise the solids will not be rebuild.
Take a look at the simple shape on the image below:
@figure{/user_guides/modeling_algos/images/modeling_algos_rf_im001.png,"",220}
Removal of all three faces of the gap is not going to work, because there will be no face to fill the transverse part of the step.
Although, removal of only two faces, keeping one of the transverse faces, will fill the gap with the kept face:
<table align="center">
<tr>
<td>@figure{/user_guides/modeling_algos/images/modeling_algos_rf_im002.png,"Keeping the right transverse face",220}</td>
<td>@figure{/user_guides/modeling_algos/images/modeling_algos_rf_im003.png,"Keeping the left transverse face",220}</td>
</tr>
</table>
@subsection occt_modalg_defeaturing_usage Usage
Here is the example of usage of the *BRepAlgoAPI_Defeaturing* algorithm on the C++ level:
~~~~
TopoDS_Shape aSolid = ...; // Input shape to remove the features from
TopTools_ListOfShape aFeatures = ...; // Features to remove from the shape
Standard_Boolean bRunParallel = ...; // Parallel processing mode
Standard_Boolean isHistoryNeeded = ...; // History support
BRepAlgoAPI_Defeaturing aDF; // Defeaturing algorithm
aDF.SetShape(aSolid); // Set the shape
aDF.AddFacesToRemove(aFaces); // Add faces to remove
aDF.SetRunParallel(bRunParallel); // Define the processing mode (parallel or single)
aDF.TrackHistory(isHistoryNeeded); // Define whether to track the shapes modifications
aDF.Build(); // Perform the operation
if (!aDF.IsDone()) // Check for the errors
{
// error treatment
Standard_SStream aSStream;
aDF.DumpErrors(aSStream);
return;
}
if (aDF.HasWarnings()) // Check for the warnings
{
// warnings treatment
Standard_SStream aSStream;
aDF.DumpWarnings(aSStream);
}
const TopoDS_Shape& aResult = aDF.Shape(); // Result shape
~~~~
To track the history of a shape use the API history methods:
~~~~
// Obtain modification of the shape
const TopTools_ListOfShape& BRepAlgoAPI_Defeaturing::Modified(const TopoDS_Shape& theS);
// Obtain shapes generated from the shape
const TopTools_ListOfShape& BRepAlgoAPI_Defeaturing::Generated(const TopoDS_Shape& theS);
// Check if the shape is removed or not
Standard_Boolean BRepAlgoAPI_Defeaturing::IsDeleted(const TopoDS_Shape& theS);
~~~~
For the usage of the Defeaturing algorithm on the Draw level the command <b>removefeatures</b> has been implemented.
To track the history of a shape modification during Defeaturing the @ref occt_draw_hist "standard history commands" can be used.
For more details on commands above please refer the @ref occt_draw_defeaturing "Defeaturing commands" of the Draw test harness user guide.
To have possibility to access the error/warning shapes of the operation use the *bdrawwarnshapes* command before running the algorithm (see command usage in the @ref occt_algorithms_ers "Errors and warnings reporting system" of Boolean operations user guide).
@subsection occt_modalg_defeaturing_examples Examples
Here are the few examples of defeaturing of the ANC101 model:
@figure{/user_guides/modeling_algos/images/modeling_algos_rf_im004.png,"ANC101 model",220}</td>
<table align="center">
<tr>
<td>@figure{/user_guides/modeling_algos/images/modeling_algos_rf_im005.png,"Removing the cylindrical protrusion",220}</td>
<td>@figure{/user_guides/modeling_algos/images/modeling_algos_rf_im006.png,"Result",220}</td></td>
</tr>
<tr>
<td>@figure{/user_guides/modeling_algos/images/modeling_algos_rf_im007.png,"Removing the cylindrical holes",220}</td>
<td>@figure{/user_guides/modeling_algos/images/modeling_algos_rf_im008.png,"Result",220}</td></td>
</tr>
<tr>
<td>@figure{/user_guides/modeling_algos/images/modeling_algos_rf_im009.png,"Removing the cylindrical holes",220}</td>
<td>@figure{/user_guides/modeling_algos/images/modeling_algos_rf_im010.png,"Result",220}</td></td>
</tr>
<tr>
<td>@figure{/user_guides/modeling_algos/images/modeling_algos_rf_im011.png,"Removing the small gaps in the front",220}</td>
<td>@figure{/user_guides/modeling_algos/images/modeling_algos_rf_im012.png,"Result",220}</td></td>
</tr>
<tr>
<td>@figure{/user_guides/modeling_algos/images/modeling_algos_rf_im013.png,"Removing the gaps in the front completely",220}</td>
<td>@figure{/user_guides/modeling_algos/images/modeling_algos_rf_im014.png,"Result",220}</td></td>
</tr>
<tr>
<td>@figure{/user_guides/modeling_algos/images/modeling_algos_rf_im015.png,"Removing the cylindrical protrusion",220}</td>
<td>@figure{/user_guides/modeling_algos/images/modeling_algos_rf_im016.png,"Result",220}</td></td>
</tr>
</table>
Here are the few examples of defeaturing of the model containing boxes with blends:
@figure{/user_guides/modeling_algos/images/modeling_algos_rf_im017.png,"Box blend model",220}</td>
<table align="center">
<tr>
<td>@figure{/user_guides/modeling_algos/images/modeling_algos_rf_im018.png,"Removing the blend",220}</td>
<td>@figure{/user_guides/modeling_algos/images/modeling_algos_rf_im019.png,"Result",220}</td></td>
</tr>
<tr>
<td>@figure{/user_guides/modeling_algos/images/modeling_algos_rf_im020.png,"Removing the blend",220}</td>
<td>@figure{/user_guides/modeling_algos/images/modeling_algos_rf_im021.png,"Result",220}</td></td>
</tr>
<tr>
<td>@figure{/user_guides/modeling_algos/images/modeling_algos_rf_im022.png,"Removing the blend",220}</td>
<td>@figure{/user_guides/modeling_algos/images/modeling_algos_rf_im023.png,"Result",220}</td></td>
</tr>
<tr>
<td>@figure{/user_guides/modeling_algos/images/modeling_algos_rf_im024.png,"Removing the blend",220}</td>
<td>@figure{/user_guides/modeling_algos/images/modeling_algos_rf_im025.png,"Result",220}</td></td>
</tr>
<tr>
<td>@figure{/user_guides/modeling_algos/images/modeling_algos_rf_im026.png,"Removing the blend",220}</td>
<td>@figure{/user_guides/modeling_algos/images/modeling_algos_rf_im027.png,"Result",220}</td></td>
</tr>
<tr>
<td>@figure{/user_guides/modeling_algos/images/modeling_algos_rf_im028.png,"Removing the blend",220}</td>
<td>@figure{/user_guides/modeling_algos/images/modeling_algos_rf_im029.png,"Result",220}</td></td>
</tr>
</table>
@section occt_modalg_makeperiodic 3D Model Periodicity
Open CASCADE Technology provides tools for making an arbitrary 3D model (or just shape) periodic in 3D space in the specified directions.
Periodicity of the shape means that the shape can be repeated in any periodic direction any number of times without creation of the new geometry or splits.
The idea of this algorithm is to make the shape look similarly on the opposite sides or on the period bounds of periodic directions.
It does not mean that the opposite sides of the shape will be mirrored. It just means the the opposite sides of the shape should be split by each other and obtain the same geometry on opposite sides.
Such approach will allow repeating the shape, i.e. translating the copy of a shape on the period, without creation of new geometry because there will be no coinciding parts of different dimension.
For better understanding of what periodicity means lets create a simple prism and make it periodic.
The following draw script creates the L-shape prism with extensions 10x5x10:
~~~~
polyline p 0 0 0 0 0 10 5 0 10 5 0 5 10 0 5 10 0 0 0 0 0
mkplane f p
prism s f 0 5 0
~~~~
@figure{/user_guides/modeling_algos/images/modeling_algos_mkperiodic_im001.png,"Shape to make periodic",220}
Making this shape periodic in X, Y and Z directions with the periods matching the shape's extensions should make the splits of negative X and Z sides of the shape. The shape is already similar on opposite sides of Y directions, thus no new splits is expected.
Here is the shape after making it periodic:
@figure{/user_guides/modeling_algos/images/modeling_algos_mkperiodic_im002.png,"Periodic shape",220}
And here is the repetition of the shape once in X and Z directions:
@figure{/user_guides/modeling_algos/images/modeling_algos_mkperiodic_im003.png,"Repeated shape",220}
The OCCT Shape Periodicity tools also allows making the shape periodic with the period not matching the shape's extensions. Let's make the shape periodic with 11, 11 and 6 for X, Y, Z periods accordingly.
Such values of periods mean that there will be a gap between repeated shapes, and since during repetition the opposite sides do not touch the shape will not be split at all.
Here is the repetition of the shape once in X and Z directions:
@figure{/user_guides/modeling_algos/images/modeling_algos_mkperiodic_im004.png,"Repeated shape",220}
As expected, the shape is not split and the repeated elements do not touch.
If necessary the algorithm will trim the shape to fit into the requested period by splitting it with the planes limiting the shape's requested periods.
E.g. let's make the L-shape periodic only in X direction with the period 2 starting at X parameter 4:
@figure{/user_guides/modeling_algos/images/modeling_algos_mkperiodic_im005.png,"Periodic trimmed shape",220}
@subsection occt_modalg_makeperiodic_how_it_works How the shape is made periodic
For making the shape periodic in certain direction the algorithm performs the following steps:
* Creates the copy of the shape and moves it on the period into negative side of the requested direction;
* Splits the negative side of the shape by the moved copy, ensuring copying of the geometry from positive side to negative;
* Creates the copy of the shape (with already split negative side) and moves it on the period into the positive side of the requested direction;
* Splits the positive side of the shape by the moved copy, ensuring copying of the geometry from negative side to positive.
Repeated copying of the geometry ensures that the corner edges of the periodic shape will have the same geometry on opposite sides of all periodic directions.
Thus, in the periodic shape the geometry from positive side of the shape is always copied on the negative side of periodic directions.
@subsection occt_modalg_makeperiodic_association Opposite shapes association
The algorithm also associates the identical (or twin) shapes located on the opposite sides of the periodic shape. By the construction, the twin shapes should always have the same geometry and distanced from each other on the period.
It is possible that the shape does not have any twins. It means that when repeating this shape will not touch the opposite side of the shape. In the example when the periods of the shape are grater than its extensions, non of the sub-shapes has a twin.
@subsection occt_modalg_makeperiodic_repetition Periodic shape repetition
The algorithm also provides the methods to repeat the periodic shape in periodic directions. To repeat shape the algorithm makes the requested number of copies of the shape and translates them one by one on the time * period value.
After all copies are made and translated they are glued to have valid shape.
The subsequent repetitions are performed on the repeated shape, thus e.g. repeating the shape two times in any periodic direction will create result containing three shapes (original plus two copies).
Single subsequent repetition in any direction will result already in 6 shapes.
The repetitions can be cleared and started over.
@subsection occt_modalg_makeperiodic_history History support
The algorithm supports the history of shapes modifications, thus it is possible to track how the shapes have been changed to make it periodic and what new shapes have been created during repetitions.
Both split history and history of periodic shape repetition are available here. Note, that all repeated shapes are stored as generated into the history.
*BRepTools_History* is used for history support.
@subsection occt_modalg_makeperiodic_errors Errors/Warnings
The algorithm supports the Error/Warning reporting system which allows obtaining the extended overview of the errors and warning occurred during the operation.
As soon as any error appears the algorithm stops working. The warnings allow continuing the job, informing the user that something went wrong.
The algorithm returns the following alerts:
* *BOPAlgo_AlertNoPeriodicityRequired* - Error alert is given if no periodicity has been requested in any direction;
* *BOPAlgo_AlertUnableToTrim* - Error alert is given if the trimming of the shape for fitting it into requested period has failed;
* *BOPAlgo_AlertUnableToMakeIdentical* - Error alert is given if splitting of the shape by its moved copies has failed;
* *BOPAlgo_AlertUnableToRepeat* - Warning alert is given if the gluing of the repeated shapes has failed.
For more information on the error/warning reporting system please see the chapter @ref occt_algorithms_ers "Errors and warnings reporting system" of Boolean operations user guide.
@subsection occt_modalg_makeperiodic_usage Usage
The algorithm is implemented in the class *BOPAlgo_MakePeriodic*.
Here is the example of its usage on the API level:
~~~~
TopoDS_Shape aShape = ...; // The shape to make periodic
Standard_Boolean bMakeXPeriodic = ...; // Flag for making or not the shape periodic in X direction
Standard_Real aXPeriod = ...; // X period for the shape
Standard_Boolean isXTrimmed = ...; // Flag defining whether it is necessary to trimming
// the shape to fit to X period
Standard_Real aXFirst = ...; // Start of the X period
// (really necessary only if the trimming is requested)
Standard_Boolean bRunParallel = ...; // Parallel processing mode or single
BOPAlgo_MakePeriodic aPeriodicityMaker; // Periodicity maker
aPeriodicityMaker.SetShape(aShape); // Set the shape
aPeriodicityMaker.MakeXPeriodic(bMakePeriodic, aXPeriod); // Making the shape periodic in X direction
aPeriodicityMaker.SetTrimmed(isXTrimmed, aXFirst); // Trim the shape to fit X period
aPeriodicityMaker.SetRunParallel(bRunParallel); // Set the parallel processing mode
aPeriodicityMaker.Perform(); // Performing the operation
if (aPeriodicityMaker.HasErrors()) // Check for the errors
{
// errors treatment
Standard_SStream aSStream;
aPeriodicityMaker.DumpErrors(aSStream);
return;
}
if (aPeriodicityMaker.HasWarnings()) // Check for the warnings
{
// warnings treatment
Standard_SStream aSStream;
aPeriodicityMaker.DumpWarnings(aSStream);
}
const TopoDS_Shape& aPeriodicShape = aPeriodicityMaker.Shape(); // Result periodic shape
aPeriodicityMaker.XRepeat(2); // Making repetitions
const TopoDS_Shape& aRepeat = aPeriodicityMaker.RepeatedShape(); // Getting the repeated shape
aPeriodicityMaker.ClearRepetitions(); // Clearing the repetitions
~~~~
Please note, that the class is based on the options class *BOPAlgo_Options*, which provides the following options for the algorithm:
* Error/Warning reporting system;
* Parallel processing mode.
The other options of the base class are not supported here and will have no effect.
All the history information obtained during the operation is stored into *BRepTools_History* object and available through *History()* method:
~~~~
// Get the history object
const Handle(BRepTools_History)& BOPAlgo_MakePeriodic::History();
~~~~
For the usage of the MakePeriodic algorithm on the Draw level the following commands have been implemented:
* **makeperiodic**
* **repeatshape**
* **periodictwins**
* **clearrepetitions**
For more details on the periodicity commands please refer the @ref occt_draw_makeperiodic "Periodicity commands" of the Draw test harness user guide.
To track the history of a shape modification during MakePeriodic operation the @ref occt_draw_hist "standard history commands" can be used.
To have possibility to access the error/warning shapes of the operation use the *bdrawwarnshapes* command before running the algorithm (see command usage in the @ref occt_algorithms_ers "Errors and warnings reporting system" of Boolean operations user guide).
@subsection occt_modalg_makeperiodic_examples Examples
Imagine that you need to make the drills in the plate on the same distance from each other. To model this process it is necessary to make a lot of cylinders (simulating the drills) and cut these cylinders from the plate.
With the periodicity tool, the process looks very simple:
~~~~
# create plate 100 x 100
box plate -50 -50 0 100 100 1
# create a single drill with radius 1
pcylinder drill 1 1
# locate the drill in the left corner
ttranslate drill -48 -48 0
# make the drill periodic with 4 as X and Y periods, so the distance between drills will be 2
makeperiodic drill drill -x 4 -trim -50 -y 4 -trim -50
# repeat the drill to fill the plate, in result we get net of 25 x 25 drills
repeatshape drills -x 24 -y 24
# cut the drills from the plate
bcut result plate drills
~~~~
@figure{/user_guides/modeling_algos/images/modeling_algos_mkperiodic_im006.png,"Plate with drills",220}
@section occt_modalg_makeconnected Making touching shapes connected
Open CASCADE Technology provides tools for making the same-dimensional touching shapes connected (or glued), i.e. for making the coinciding geometries topologically shared among shapes.
To make the shapes connected they are glued by the means of @ref occt_algorithms_7 "General Fuse algorithm". The option BOPAlgo_GlueShift is used, thus if the input shapes have been interfering the algorithm will be unable to recognize this.
Making the group of shapes connected can be a useful e.g. before meshing the group. It will allow making the resulting mesh conformal.
The algorithm for making the shapes connected is is implemented in the class *BOPAlgo_MakeConnected*.
@subsection occt_modalg_makeconnected_materials Material association
In frames of this tool the input shapes are called materials, and each input shape has a unique material.
After making the shapes connected, the first sub-elements of the input shapes are associated with the shapes to which the belong. At that, the orientation of the sub-elements in the shape is taken into account.
The associations are made for the following types:
* For input SOLIDS the resulting FACES are associated with the input solids;
* For input FACES the resulting EDGES are associated with the input faces;
* For input EDGES the resulting VERTICES are associated with the input edges.
The association process is called the material association. It allows finding the coinciding elements for the opposite input shapes. These elements will be associated to at least two materials (one on the positive side of the shape, the other - on negative).
For obtaining the material information the following methods should be used
* *MaterialsOnPositiveSide()* - returns the original shapes (materials) located on the positive side of the given shape (i.e. with FORWARD orientation);
* *MaterialsOnNegativeSide()* - returns the original shapes (materials) located on the negative side of the given shape (i.e. with REVERSED orientation);
~~~~
// Returns the original shapes which images contain the given shape with FORWARD orientation.
const TopTools_ListOfShape& BOPAlgo_MakeConnected::MaterialsOnPositiveSide(const TopoDS_Shape& theS)
// Returns the original shapes which images contain the given shape with REVERSED orientation.
const TopTools_ListOfShape& BOPAlgo_MakeConnected::MaterialsOnNegativeSide(const TopoDS_Shape& theS)
~~~~
@subsection occt_modalg_makeconnected_makeperiodic Making connected shape periodic
The tool provides possibility to make the connected shape @ref occt_modalg_makeperiodic "periodic".
Since by making the shape periodic it ensures that the geometry of coinciding shapes on the opposite sides will be the same it allows reusing the mesh of the shape for its periodic twins.
After making the shape periodic the material associations are updated to correspond to the actual state of the result shape. Repetition of the periodic shape is also possible from here. Material associations are not going to be lost.
@subsection occt_modalg_makeconnected_history History support
The algorithm supports history of shapes modifications during the operation. Additionally to standard history method provided by *BRepTools_History* and used here as a history tool, the algorithm also provides the method to track the back connection - from resulting shapes to the input ones.
The method is called *GetOrigins()*:
~~~~
// Returns the list of original shapes from which the current shape has been created.
const TopTools_ListOfShape& BOPAlgo_MakeConnected::GetOrigins(const TopoDS_Shape& theS);
~~~~
Both Gluing history and history of making the shape periodic and periodic shape repetition are available here. Note, that all repeated shapes are stored as generated into the history.
@subsection occt_modalg_makeconnected_errors Errors/Warnings
The algorithm supports the Error/Warning reporting system which allows obtaining the extended overview of the errors and warning occurred during the operation.
As soon as any error appears the algorithm stops working. The warnings allow continuing the job, informing the user that something went wrong.
The algorithm returns the following alerts:
* *BOPAlgo_AlertTooFewArguments* - error alert is given on the attempt to run the algorithm without the arguments;
* *BOPAlgo_AlertMultiDimensionalArguments* - error alert is given on the attempt to run the algorithm on multi-dimensional arguments;
* *BOPAlgo_AlertUnableToGlue* - error alert is given if the gluer algorithm is unable to glue the given arguments;
* *BOPAlgo_AlertUnableToMakePeriodic* - warning alert is given if the periodicity maker is unable to make the connected shape periodic with given options;
* *BOPAlgo_AlertShapeIsNotPeriodic* - warning alert is given on the attempt to repeat the shape before making it periodic.
For more information on the error/warning reporting system please see the chapter @ref occt_algorithms_ers "Errors and warnings reporting system" of Boolean operations user guide.
@subsection occt_modalg_makeconnected_usage Usage
Here is the example of usage of the *BOPAlgo_MakePeriodic* algorithm on the API level:
~~~~
TopTools_ListOfShape anArguments = ...; // Shapes to make connected
Standard_Boolean bRunParallel = ...; // Parallel processing mode
BOPAlgo_MakeConnected aMC; // Tool for making the shapes connected
aMC.SetArguments(anArguments); // Set the shapes
aMC.SetRunParallel(bRunParallel); // Set parallel processing mode
aMC.Perform(); // Perform the operation
if (aMC.HasErrors()) // Check for the errors
{
// errors treatment
Standard_SStream aSStream;
aMC.DumpErrors(aSStream);
return;
}
if (aMC.HasWarnings()) // Check for the warnings
{
// warnings treatment
Standard_SStream aSStream;
aMC.DumpWarnings(aSStream);
}
const TopoDS_Shape& aGluedShape = aMC.Shape(); // Connected shape
// Checking material associations
TopAbs_ShapeEnum anElemType = ...; // Type of first BRep sub-element
TopExp_Explorer anExp(anArguments.First(), anElemType);
for (; anExp.More(); anExp.Next())
{
const TopoDS_Shape& anElement = anExp.Current();
const TopTools_ListOfShape& aNegativeM = aMC.MaterialsOnNegativeSide(anElement);
const TopTools_ListOfShape& aPositiveM = aMC.MaterialsOnPositiveSide(anElement);
}
// Making the connected shape periodic
BOPAlgo_MakePeriodic::PeriodicityParams aParams = ...; // Options for periodicity of the connected shape
aMC.MakePeriodic(aParams);
// Shape repetition after making it periodic
// Check if the shape has been made periodic successfully
if (aMC.PeriodicityTool().HasErrors())
{
// Periodicity maker error treatment
}
// Shape repetition in periodic directions
aMC.RepeatShape(0, 2);
const TopoDS_Shape& aShape = aMC.PeriodicShape(); // Periodic and repeated shape
~~~~
Please note, that the class is based on the options class *BOPAlgo_Options*, which provides the following options for the algorithm:
* Error/Warning reporting system;
* Parallel processing mode.
The other options of the base class are not supported here and will have no effect.
All the history information obtained during the operation is stored into *BRepTools_History* object and available through *History()* method:
~~~~
// Get the history object
const Handle(BRepTools_History)& BOPAlgo_MakeConnected::History();
~~~~
For the usage of the MakeConnected algorithm on the Draw level the following commands have been implemented:
* **makeconnected**
* **cmaterialson**
* **cmakeperiodic**
* **crepeatshape**
For more details on the connexity commands please refer the @ref occt_draw_makeconnected "MakeConnected commands" of the Draw test harness user guide.
To track the history of a shape modification during MakeConnected operation the @ref occt_draw_hist "standard history commands" can be used.
To have possibility to access the error/warning shapes of the operation use the *bdrawwarnshapes* command before running the algorithm (see command usage in the @ref occt_algorithms_ers "Errors and warnings reporting system" of Boolean operations user guide).

Binary file not shown.

After

Width:  |  Height:  |  Size: 641 KiB

View File

@@ -1294,3 +1294,99 @@ The following sample code reads a shape from ASCII file and writes it to a binar
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@section occt_modat_6 Bounding boxes
*Bounding box(es) (BndBox(es))* is used in many OCCT algorithms. In general, it is some filter to avoid check of excess interferences between pairs of shapes (check of interferences between BndBoxes is much simpler then between shapes and if BndBoxes do not interfere then there is no point in searching interferences between the corresponding shapes).
Generally, BndBoxes can be divided on two main types:
- axis-aligned BndBox (AABB). I.e. the box whose edges are parallel to the axes of World Coordinate System (WCS);
- oriented BndBox (OBB). I.e. not AABB.
In fact, every AABB is a specific case of OBB.<br>
The image below illustrates the example, when using OBB is better than AABB.
@figure{/user_guides/modeling_data/images/modeling_data_image015.png,"Illustrating the problem with AABB.",320}
AABBs in this picture are interfered. Therefore, many OCCT-algorithms will spend much time to interfere the shapes. However, if we check OBBs, which are not interfered, then searching of interferences between the shapes will not be necessary. At that, creation and analysis of OBBs takes significantly more time than the analogical operations with AABB.
Later in this section, the BndBox having the smallest surface area will be called as <b> optimal </b>.
In OCCT, BndBox(es) are described in Bnd package. In general, Bnd_Box class describes AABB, Bnd_OBB class describes OBB. These classes contain the following common methods (this list is not complete; please see the documentation about corresponding class for detailed information):
- SetVoid() and IsVoid(). SetVoid method clears the existing BndBox. IsVoid method indicates whether the BndBox is initialized.
- Enlarge(...). Extends the current BndBox.
- Add(...). Rebuilds the current BndBox in order to cover all previous objects (which it was created from) and the argument of the method.
- IsOut(...). Checks whether the argument is inside/outside of the current BndBox.
Also, BRepBndLib class contains methods to provide creation of BndBox (both AABB and OBB) from the complex shape.
@subsection occt_modat_6_1 Brief description of some algorithms working with OBB
@subsubsection occt_modat_6_1_1 Creation of OBB from set of points
The algorithm is described in <a href="http://www.idt.mdh.se/~tla/publ/FastOBBs.pdf">"Fast Computation of Tight Fitting Oriented Bounding Boxes" by Thomas Larsson and Linus Källberg</a>. It includes the following steps:
<span>1.</span> Choose \f$ N_{a} (N_{a} \geq 3) \f$ initial axes.<br>
<span>2.</span> Project every given point to the every chosen (in item 1) axis. At that, "minimal" and "maximal" points of every axis (i.e. point having minimal and maximal parameter (correspondingly) of the projection to this axis) are chosen. I.e. \f$ 2*N_{a} \f$ points will be held and this set can contain equal points. Later (unless otherwise specified) in this algorithm we will work with these \f$ 2*N_{a} \f$ points only.<br>
<span>3.</span> Choose one pair of points among all pairs of "minimal" and "maximal" points of every axis (from item 1), with two furthest points. Let \f$ p_{0} \f$ and \f$ p_{1} \f$ be the "minimal" and "maximal" point of this pair.<br>
<span>4.</span> Create an axis \f$ \mathbf{e_{0}}\left \{ \overrightarrow{p_{0}p_{1}} \right \} \f$ (i.e. having direction \f$ \overrightarrow{p_{0}p_{1}} \f$ ).<br>
<span>5.</span> Choose the point \f$ p_{2} \f$ (from the set defined in item 2) which is in the maximal distance from the infinite line directed along \f$ \mathbf{e_{0}} \f$ axis.<br>
Further, let us consider the triangle \f$ T_{0}\left \langle p_{0}, p_{1}, p_{2} \right \rangle \f$ (i.e. having vertices \f$ p_{0}, p_{1} \f$ and \f$ p_{2} \f$). Namely:
<span>6.</span> Create new axes: \f$ \mathbf{e_{1}}\left \{ \overrightarrow{p_{1}p_{2}} \right \} \f$, \f$ \mathbf{e_{2}}\left \{ \overrightarrow{p_{2}p_{0}} \right \} \f$, \f$ \mathbf{n}\left \{ \overrightarrow{\mathbf{e_{0}}} \times \overrightarrow{\mathbf{e_{1}}} \right \} \f$, \f$ \mathbf{m_{0}}\left \{ \overrightarrow{\mathbf{e_{0}}} \times \overrightarrow{\mathbf{n}} \right \} \f$, \f$ \mathbf{m_{1}}\left \{ \overrightarrow{\mathbf{e_{1}}} \times \overrightarrow{\mathbf{n}} \right \} \f$, \f$ \mathbf{m_{2}}\left \{ \overrightarrow{\mathbf{e_{2}}} \times \overrightarrow{\mathbf{n}} \right \} \f$.<br>
<span>7.</span> Create OBBs based on the following axis: \f$ \left \{ \mathbf{e_{0}} \vdots \mathbf{m_{0}} \vdots \mathbf{n} \right \} \f$, \f$ \left \{ \mathbf{e_{1}} \vdots \mathbf{m_{1}} \vdots \mathbf{n} \right \} \f$ and \f$ \left \{ \mathbf{e_{2}} \vdots \mathbf{m_{2}} \vdots \mathbf{n} \right \} \f$ . Choose optimal OBB.<br>
<span>8.</span> Choose the points \f$ q_{0} \f$ and \f$ q_{1} \f$ (from the set defined in item 2), which are in maximal distance from the plane of the triangle \f$ T_{0} \f$ (from both sides of this plane). At that, \f$ q_{0} \f$ has minimal coordinate along the axis \f$ \mathbf{n} \f$, \f$ q_{1} \f$ has a maximal coordinate.<br>
<span>9.</span> Repeat the step 6...7 for the triangles \f$ T_{1}\left \langle p_{0}, p_{1}, q_{0} \right \rangle \f$, \f$ T_{2}\left \langle p_{1}, p_{2}, q_{0} \right \rangle \f$, \f$ T_{3}\left \langle p_{0}, p_{2}, q_{0} \right \rangle \f$, \f$ T_{4}\left \langle p_{0}, p_{1}, q_{1} \right \rangle \f$, \f$ T_{5}\left \langle p_{1}, p_{2}, q_{1} \right \rangle \f$, \f$ T_{6}\left \langle p_{0}, p_{2}, q_{1} \right \rangle \f$.<br>
<span>10.</span> Compute the center of OBB and its half dimensions.<br>
<span>11.</span> Create OBB using the center, axes and half dimensions.<br>
This algorithm is realized in Bnd_OBB::ReBuild(...) method.
@subsubsection occt_modat_6_1_2 Creation of OBB based on Axes of inertia
The algorithm contains the following steps:
1. Calculate three inertia axes, which will be the axes of the OBB.
2. Transform the source object (TopoDS_Shape) into the local coordinate system based on the axes from item 1.
3. Create an AABB for the shape obtained in the item 2.
4. Compute the center of AABB and its half dimensions
5. Transform the center into the WCS
6. Create OBB using the center, axes and half dimensions.
@subsubsection occt_modat_6_1_3 Method IsOut for a point
1. Project the point to each axis.
2. Check, whether the absolute value of the projection parameter greater than the correspond half-dimension. In this case, IsOut method will return TRUE.
@subsubsection occt_modat_6_1_4 Method IsOut for another OBB
According to the <a href="http://www.jkh.me/files/tutorials/Separating%20Axis%20Theorem%20for%20Oriented%20Bounding%20Boxes.pdf">"Separating Axis Theorem for Oriented Bounding Boxes"</a>, it is necessary to check the 15 separating axes: 6 axes of the boxes and 9 are their cross products.<br>
The algorithm of analyzing axis \f$ \mathbf{l} \f$ is following:
1. Compute the "length" according to the formula: \f$ L_{j}=\sum_{i=0}^{2}{H_{i}\cdot \left | \overrightarrow{\mathbf{a_{i}}} \cdot \overrightarrow{\mathbf{l}} \right |} \f$. Here, \f$ \mathbf{a_{i}} \f$ is an i-th axis (X-axis, Y-axis, Z-axis) of j-th BndBox (j=1...2). \f$ H_{i} \f$ is a half-dimension along i-th axis.
2. If \f$ \left |\overrightarrow{C_{1}C_{2}} \cdot \overrightarrow{\mathbf{l}} \right | > L_{1}+L_{2} \f$ (where \f$ C_{j} \f$ is the center of j-th OBB) then the considered OBBs are not interfered in terms of the axis \f$ \mathbf{l} \f$.
If OBBs are not interfered in terms of at least one axis (of 15) then they are not interfered at all.
@subsubsection occt_modat_6_1_5 Method Add for point or another BndBox
Create new OBB (see the section @ref occt_modat_6_1_1) based on the source point and all vertices of the given BndBoxes.
@subsection occt_modat_6_2 Add a shape
Method BRepBndLib::AddOBB(...) allows creating BndBox from the complex object (TopoDS_Shape). This method uses both algorithms described in the sections @ref occt_modat_6_1_1 and sections @ref occt_modat_6_1_2.
The first algorithm is used if the shape outer shell can be represented by a set of points contained in the shape. Namely, only the following elements are the source of set of points:
- Nodes of triangulation;
- Nodes of Poly_Polygon3D;
- Vertices of edges with linear 3D-curve lying in the planar face;
- Vertices of edges with linear 3D-curve if the source shape does not contain more complex topological structure (e.g. the source shape is a compound of edges);
- Vertices if the source shape does not contain more complex topological structure (e.g. the source shape is a compound of vertices).
If required set of points cannot be extracted then the algorithm from section @ref occt_modat_6_1_2 is used for OBB creation.
The package BRepBndLib contains the methods BRepBndLib::Add(...), BRepBndLib::AddClose(...) and BRepBndLib::AddOptimal(...) for creation of AABB of a shape. Please see reference manual for detailed information.
@subsection occt_modat_6_3 Limitations of algorithm for OBB creation.
1. The algorithm described in the section @ref occt_modat_6_1_1 works significantly better (finds resulting OBB with less surface area) and faster than the algorithm from the section @ref occt_modat_6_1_2. Nevertheless, (in general) the result returned by both algorithms is not always optimal (i.e. sometimes another OBB exists having less surface area). Moreover, the first method does not allow computing OBB of shapes with complex geometry.
2. Currently, the algorithm of OBB creation is implemented for objects in 3D-space only.

View File

@@ -41,11 +41,11 @@ tcopy bxx b10
# make some boxes hollow
for {set i 1} {$i <= 1} {incr i} {
set dim [boundingstr b$i]
set dx [expr [lindex $dim 3] - [lindex $dim 0]]
set x1 [expr [lindex $dim 0] + 0.1 * $dx]
set x2 [expr [lindex $dim 1] + 0.1 * $dx]
set x3 [expr [lindex $dim 2] + 0.1 * $dx]
set dim [bounding -s b$i -save xmin ymin zmin xmax ymax zmax]
set dx [dval xmax-xmin]
set x1 [dval xmin+0.1*$dx]
set x2 [dval ymin+0.1*$dx]
set x3 [dval zmin+0.1*$dx]
box bc $x1 $x2 $x3 0.8*$dx 0.8*$dx $dx
bcut bb b$i bc
tcopy bb b$i

View File

@@ -59,12 +59,10 @@ prism f4 l2 0 -1 0
compound f1 f2 f3 bc
bfuse r bc f4
bcut r r f5
explode r e
wire w r_4 r_1 r_20 r_21 r_22 r_23 r_24 r_25 r_26 r_7 r_30 r_31 r_32 r_33 r_27 r_28 r_29 r_11 r_38 r_34 r_35 r_36 r_37 r_16 r_17
tcopy w w1
tmirror w1 -6 0 0 0 1 0
wire w w w1
mkface w p w
tcopy r r1
tmirror r1 -6 0 0 0 1 0
bfuse w r r1
unifysamedom w w
donly w
# construct complete snowflake
@@ -135,9 +133,32 @@ vsetcolorbg 255 255 255
vtop
vfit
# add dimension
explode snowflake v
vdimension length -length -shapes snowflake_89 snowflake_15 -plane xoy -value 0.001 -dispunits mm -showunits -flyout 70 -label above -color black -text 5 3d sh
# add dimension:
# detect vertices extremal in X direction
bounding -s snowflake -save x1 y1 z1 x2 y2 z2
plane f1 x1 0 0 1 0 0
plane f2 x2 0 0 1 0 0
mkface f1 f1
mkface f2 f2
bsection s1 snowflake f1
bsection s2 snowflake f2
# select only upper vertices (nearer to the upper bound)
explode s1 v
explode s2 v
plane fup 0 y2 0 0 1 0
mkface fup fup
for {set i 1} {$i <= 2} {incr i} {
set dmin 1e10
for {set j 1} {$j <= 2} {incr j} {
distmini d s${i}_$j fup
set dist [dval d_val]
if {$dmin > $dist} {
set dmin $dist
eval set v$i s${i}_$j
}
}
}
vdimension length -length -shapes $v1 $v2 -plane xoy -value 0.001 -dispunits mm -showunits -flyout 70 -label above -color black -text 5 3d sh
if { [regexp HAVE_GL2PS [dversion]] } {
puts "You can use command vexport to generate PDF: vexport your_file_path.pdf"

View File

@@ -67,3 +67,51 @@ Warning: Removal of internal boundaries among Faces has failed
.BOPAlgo_AlertRemovalOfIBForEdgesFailed
Warning: Removal of internal boundaries among Edges has failed
.BOPAlgo_AlertIntersectionOfPairOfShapesFailed
Warning: Intersection of pair of shapes has failed
.BOPAlgo_AlertBuildingPCurveFailed
Warning: Building 2D curve of edge on face has failed
.BOPAlgo_AlertAcquiredSelfIntersection
Warning: Some sub-shapes of some of the argument become connected through other shapes and the argument became self-interfered
.BOPAlgo_AlertUnsupportedType
Warning: Unsupported type of input shape
.BOPAlgo_AlertUnableToRemoveTheFeature
Warning: Unable to remove the feature
.BOPAlgo_AlertNoFacesToRemove
Error: No faces have been found for removal
.BOPAlgo_AlertRemoveFeaturesFailed
Error: The Feature Removal algorithm has failed
.BOPAlgo_AlertSolidBuilderUnusedFaces
Warning: Some of the faces passed to the Solid Builder algorithm have not been classified and not used for solids creation
.BOPAlgo_AlertNoPeriodicityRequired
Error: No periodicity has been requested for the shape
.BOPAlgo_AlertUnableToTrim
Error: Unable to trim the shape for making it periodic (BOP Common fails)
.BOPAlgo_AlertUnableToMakeIdentical
Error: Unable to make the shape to look identical on opposite sides (Splitter fails)
.BOPAlgo_AlertUnableToRepeat
Error: Unable to repeat the shape (Gluer fails)
.BOPAlgo_AlertMultiDimensionalArguments
Error: Multi-dimensional arguments
.BOPAlgo_AlertUnableToMakePeriodic
Warning: Unable to make the shape periodic
.BOPAlgo_AlertUnableToGlue
Error: Unable to glue the shapes
.BOPAlgo_AlertShapeIsNotPeriodic
Warning: The shape is not periodic

View File

@@ -30,7 +30,7 @@ DEFINE_SIMPLE_ALERT(BOPAlgo_AlertBuilderFailed)
//! The intersection of the arguments has failed
DEFINE_SIMPLE_ALERT(BOPAlgo_AlertIntersectionFailed)
//! The type of Boolean Operation is not set
//! More than one argument is provided
DEFINE_SIMPLE_ALERT(BOPAlgo_AlertMultipleArguments)
//! The Pave Filler (the intersection tool) has not been created
@@ -78,4 +78,54 @@ DEFINE_ALERT_WITH_SHAPE(BOPAlgo_AlertShellSplitterFailed)
//! Some edges are too small and have no valid range
DEFINE_ALERT_WITH_SHAPE(BOPAlgo_AlertTooSmallEdge)
//! Intersection of pair of shapes has failed
DEFINE_ALERT_WITH_SHAPE(BOPAlgo_AlertIntersectionOfPairOfShapesFailed)
//! Building 2D curve of edge on face has failed
DEFINE_ALERT_WITH_SHAPE(BOPAlgo_AlertBuildingPCurveFailed)
//! Some sub-shapes of some of the argument become connected through
//! other shapes and the argument became self-interfered
DEFINE_ALERT_WITH_SHAPE(BOPAlgo_AlertAcquiredSelfIntersection)
//! Unsupported type of input shape
DEFINE_ALERT_WITH_SHAPE(BOPAlgo_AlertUnsupportedType)
//! No faces have been found for removal
DEFINE_SIMPLE_ALERT(BOPAlgo_AlertNoFacesToRemove)
//! Unable to remove the feature
DEFINE_ALERT_WITH_SHAPE(BOPAlgo_AlertUnableToRemoveTheFeature)
//! The Feature Removal algorithm has failed
DEFINE_SIMPLE_ALERT(BOPAlgo_AlertRemoveFeaturesFailed)
//! Some of the faces passed to the Solid Builder algorithm have not been classified
//! and not used for solids creation
DEFINE_ALERT_WITH_SHAPE(BOPAlgo_AlertSolidBuilderUnusedFaces)
//! No periodicity has been requested for the shape
DEFINE_SIMPLE_ALERT(BOPAlgo_AlertNoPeriodicityRequired)
//! Unable to trim the shape for making it periodic (BOP Common fails)
DEFINE_ALERT_WITH_SHAPE(BOPAlgo_AlertUnableToTrim)
//! Unable to make the shape to look identical on opposite sides (Splitter fails)
DEFINE_ALERT_WITH_SHAPE(BOPAlgo_AlertUnableToMakeIdentical)
//! Unable to repeat the shape (Gluer fails)
DEFINE_ALERT_WITH_SHAPE(BOPAlgo_AlertUnableToRepeat)
//! Multi-dimensional arguments
DEFINE_SIMPLE_ALERT(BOPAlgo_AlertMultiDimensionalArguments)
//! Unable to make the shape periodic
DEFINE_ALERT_WITH_SHAPE(BOPAlgo_AlertUnableToMakePeriodic)
//! Unable to glue the shapes
DEFINE_ALERT_WITH_SHAPE(BOPAlgo_AlertUnableToGlue)
//! The shape is not periodic
DEFINE_ALERT_WITH_SHAPE(BOPAlgo_AlertShapeIsNotPeriodic)
#endif // _BOPAlgo_Alerts_HeaderFile

View File

@@ -16,6 +16,7 @@
#include <BOPAlgo_BOP.hxx>
#include <BOPAlgo_BuilderSolid.hxx>
#include <BOPAlgo_PaveFiller.hxx>
#include <BOPAlgo_Tools.hxx>
#include <BOPAlgo_Alerts.hxx>
#include <BOPCol_DataMapOfShapeShape.hxx>
#include <BOPCol_IndexedDataMapOfShapeListOfShape.hxx>
@@ -411,6 +412,7 @@ void BOPAlgo_BOP::Perform()
pPF->SetFuzzyValue(myFuzzyValue);
pPF->SetNonDestructive(myNonDestructive);
pPF->SetGlue(myGlue);
pPF->SetUseOBB(myUseOBB);
//
pPF->Perform();
//
@@ -811,9 +813,11 @@ void BOPAlgo_BOP::BuildShape()
}
// make containers
BOPCol_ListOfShape aLCRes;
BOPCol_MapOfShape aMInpFence;
aItLS.Initialize(aLSC);
for (; aItLS.More(); aItLS.Next()) {
const TopoDS_Shape& aSC = aItLS.Value();
aMInpFence.Add(aSC);
//
BOPTools_AlgoTools::MakeContainer(TopAbs_COMPOUND, aRC);
//
@@ -895,19 +899,44 @@ void BOPAlgo_BOP::BuildShape()
for (; aItLS.More(); aItLS.Next()) {
aBB.Add(aResult, aItLS.Value());
}
//
// add the rest of the shapes into result
// create map of containers
BOPCol_MapOfShape aMSResult;
BOPTools::MapShapes(aResult, aMSResult);
//
aIt.Initialize(myRC);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aS = aIt.Value();
if (aMSResult.Add(aS)) {
aBB.Add(aResult, aS);
// get input non-container shapes
BOPCol_ListOfShape aLSNonCont;
for (i = 0; i < 2; ++i)
{
const BOPCol_ListOfShape& aLS = !i ? myArguments : myTools;
aItLS.Initialize(aLS);
for (; aItLS.More(); aItLS.Next())
{
const TopoDS_Shape& aS = aItLS.Value();
BOPAlgo_Tools::TreatCompound(aS, aMInpFence, aLSNonCont);
}
}
//
// put non-container shapes in the result
aItLS.Initialize(aLSNonCont);
for (; aItLS.More(); aItLS.Next())
{
const TopoDS_Shape& aS = aItLS.Value();
if (myImages.IsBound(aS))
{
const BOPCol_ListOfShape& aLSIm = myImages.Find(aS);
aItLSIm.Initialize(aLSIm);
for (; aItLSIm.More(); aItLSIm.Next())
{
const TopoDS_Shape& aSIm = aItLSIm.Value();
if (aMSRC.Contains(aSIm) && aMSResult.Add(aSIm))
aBB.Add(aResult, aSIm);
}
}
else if (aMSRC.Contains(aS) && aMSResult.Add(aS))
aBB.Add(aResult, aS);
}
myShape = aResult;
}
//=======================================================================
@@ -1006,38 +1035,17 @@ void BOPAlgo_BOP::BuildSolid()
}
//
BOPCol_IndexedDataMapOfShapeListOfShape aMEF;
// Split faces will be added in the end
// to avoid errors in BuilderSolid algorithm
BOPCol_ListOfShape aLF, aLFx;
// Fill the list of faces to build the result solids
BOPCol_ListOfShape aSFS;
aNb = aMFS.Extent();
for (i = 1; i <= aNb; ++i) {
const BOPCol_ListOfShape& aLSx = aMFS(i);
if (aLSx.Extent() == 1) {
const TopoDS_Shape& aFx = aMFS.FindKey(i);
BOPTools::MapShapesAndAncestors(aFx, TopAbs_EDGE, TopAbs_FACE, aMEF);
if (IsBoundSplits(aFx, aMEF)){
aLFx.Append(aFx);
continue;
}
aLF.Append(aFx);
aSFS.Append(aFx);
}
}
//
// Faces to build result solids
BOPCol_ListOfShape aSFS;
aItLS.Initialize(aLF);
for(; aItLS.More(); aItLS.Next()) {
const TopoDS_Shape& aFx = aItLS.Value();
aSFS.Append(aFx);
}
//
// Split faces
aItLS.Initialize(aLFx);
for (; aItLS.More(); aItLS.Next()) {
const TopoDS_Shape& aFx = aItLS.Value();
aSFS.Append(aFx);
}
//
// Internal faces
aNb = aMFI.Extent();
for (i = 1; i <= aNb; ++i) {
@@ -1050,16 +1058,19 @@ void BOPAlgo_BOP::BuildSolid()
BOPTools_AlgoTools::MakeContainer(TopAbs_COMPOUND, aRC);
if (aSFS.Extent()) {
// Build solids from set of faces
BOPAlgo_BuilderSolid aSB;
aSB.SetContext(myContext);
aSB.SetShapes(aSFS);
aSB.Perform();
if (aSB.HasErrors()) {
BOPAlgo_BuilderSolid aBS;
aBS.SetContext(myContext);
aBS.SetShapes(aSFS);
aBS.Perform();
if (aBS.HasErrors()) {
AddError (new BOPAlgo_AlertSolidBuilderFailed); // SolidBuilder failed
return;
}
myReport->Merge(aBS.GetReport());
// new solids
const BOPCol_ListOfShape& aLSR = aSB.Areas();
const BOPCol_ListOfShape& aLSR = aBS.Areas();
//
// add new solids to result
aItLS.Initialize(aLSR);
@@ -1169,54 +1180,6 @@ void BOPAlgo_BOP::BuildSolid()
myShape = aResult;
}
//=======================================================================
//function : IsBoundSplits
//purpose :
//=======================================================================
Standard_Boolean BOPAlgo_BOP::IsBoundSplits
(const TopoDS_Shape& aS,
BOPCol_IndexedDataMapOfShapeListOfShape& aMEF)
{
Standard_Boolean bRet = Standard_False;
if (mySplits.IsBound(aS) || myOrigins.IsBound(aS)) {
return !bRet;
}
BOPCol_ListIteratorOfListOfShape aIt;
Standard_Integer aNbLS;
TopAbs_Orientation anOr;
//
//check face aF may be connected to face from mySplits
TopExp_Explorer aExp(aS, TopAbs_EDGE);
for (; aExp.More(); aExp.Next()) {
const TopoDS_Edge& aE = (*(TopoDS_Edge*)(&aExp.Current()));
//
anOr = aE.Orientation();
if (anOr==TopAbs_INTERNAL) {
continue;
}
//
if (BRep_Tool::Degenerated(aE)) {
continue;
}
//
const BOPCol_ListOfShape& aLS=aMEF.FindFromKey(aE);
aNbLS = aLS.Extent();
if (!aNbLS) {
continue;
}
//
aIt.Initialize(aLS);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aSx = aIt.Value();
if (mySplits.IsBound(aSx) || myOrigins.IsBound(aS)) {
return !bRet;
}
}
}
//
return bRet;
}
//=======================================================================
//function : TypeToExplore
//purpose :
//=======================================================================

View File

@@ -109,8 +109,6 @@ protected:
Standard_EXPORT void BuildSolid();
Standard_EXPORT Standard_Boolean IsBoundSplits (const TopoDS_Shape& theS, BOPCol_IndexedDataMapOfShapeListOfShape& theMEF);
//! Treatment of the cases with empty shapes.<br>
//! It returns TRUE if there is nothing to do, i.e.
//! all shapes in one of the groups are empty shapes.

View File

@@ -69,4 +69,52 @@ static const char BOPAlgo_BOPAlgo_msg[] =
"Warning: Removal of internal boundaries among Faces has failed\n"
"\n"
".BOPAlgo_AlertRemovalOfIBForEdgesFailed\n"
"Warning: Removal of internal boundaries among Edges has failed\n";
"Warning: Removal of internal boundaries among Edges has failed\n"
"\n"
".BOPAlgo_AlertIntersectionOfPairOfShapesFailed\n"
"Warning: Intersection of pair of shapes has failed\n"
"\n"
".BOPAlgo_AlertBuildingPCurveFailed\n"
"Warning: Building 2D curve of edge on face has failed\n"
"\n"
".BOPAlgo_AlertAcquiredSelfIntersection\n"
"Warning: Some sub-shapes of some of the argument become connected through other shapes and the argument became self-interfered\n"
"\n"
".BOPAlgo_AlertUnsupportedType\n"
"Warning: Unsupported type of input shape\n"
"\n"
".BOPAlgo_AlertUnableToRemoveTheFeature\n"
"Warning: Unable to remove the feature\n"
"\n"
".BOPAlgo_AlertNoFacesToRemove\n"
"Error: No faces have been found for removal\n"
"\n"
".BOPAlgo_AlertRemoveFeaturesFailed\n"
"Error: The Feature Removal algorithm has failed\n"
"\n"
".BOPAlgo_AlertSolidBuilderUnusedFaces\n"
"Warning: Some of the faces passed to the Solid Builder algorithm have not been classified and not used for solids creation\n"
"\n"
".BOPAlgo_AlertNoPeriodicityRequired\n"
"Error: No periodicity has been requested for the shape\n"
"\n"
".BOPAlgo_AlertUnableToTrim\n"
"Error: Unable to trim the shape for making it periodic (BOP Common fails)\n"
"\n"
".BOPAlgo_AlertUnableToMakeIdentical\n"
"Error: Unable to make the shape to look identical on opposite sides (Splitter fails)\n"
"\n"
".BOPAlgo_AlertUnableToRepeat\n"
"Error: Unable to repeat the shape (Gluer fails)\n"
"\n"
".BOPAlgo_AlertMultiDimensionalArguments\n"
"Error: Multi-dimensional arguments\n"
"\n"
".BOPAlgo_AlertUnableToMakePeriodic\n"
"Warning: Unable to make the shape periodic\n"
"\n"
".BOPAlgo_AlertUnableToGlue\n"
"Error: Unable to glue the shapes\n"
"\n"
".BOPAlgo_AlertShapeIsNotPeriodic\n"
"Warning: The shape is not periodic\n";

View File

@@ -50,10 +50,10 @@ BOPAlgo_Builder::BOPAlgo_Builder()
myEntryPoint(0),
myImages(100, myAllocator),
myShapesSD(100, myAllocator),
mySplits(100, myAllocator),
myOrigins(100, myAllocator),
myNonDestructive(Standard_False),
myGlue(BOPAlgo_GlueOff)
myGlue(BOPAlgo_GlueOff),
myCheckInverted(Standard_True)
{
}
//=======================================================================
@@ -71,10 +71,10 @@ BOPAlgo_Builder::BOPAlgo_Builder
myEntryPoint(0),
myImages(100, myAllocator),
myShapesSD(100, myAllocator),
mySplits(100, myAllocator),
myOrigins(100, myAllocator),
myNonDestructive(Standard_False),
myGlue(BOPAlgo_GlueOff)
myGlue(BOPAlgo_GlueOff),
myCheckInverted(Standard_True)
{
}
//=======================================================================
@@ -101,7 +101,6 @@ void BOPAlgo_Builder::Clear()
myMapFence.Clear();
myImages.Clear();
myShapesSD.Clear();
mySplits.Clear();
myOrigins.Clear();
}
//=======================================================================
@@ -131,95 +130,6 @@ void BOPAlgo_Builder::SetArguments(const BOPCol_ListOfShape& theShapes)
}
}
//=======================================================================
//function : Arguments
//purpose :
//=======================================================================
const BOPCol_ListOfShape& BOPAlgo_Builder::Arguments()const
{
return myArguments;
}
//=======================================================================
//function : Images
//purpose :
//=======================================================================
const BOPCol_DataMapOfShapeListOfShape& BOPAlgo_Builder::Images()const
{
return myImages;
}
//=======================================================================
//function : Origins
//purpose :
//=======================================================================
const BOPCol_DataMapOfShapeListOfShape& BOPAlgo_Builder::Origins()const
{
return myOrigins;
}
//=======================================================================
//function : ShapesSd
//purpose :
//=======================================================================
const BOPCol_DataMapOfShapeShape& BOPAlgo_Builder::ShapesSD()const
{
return myShapesSD;
}
//=======================================================================
//function : Splits
//purpose :
//=======================================================================
const BOPCol_DataMapOfShapeListOfShape& BOPAlgo_Builder::Splits()const
{
return mySplits;
}
//=======================================================================
//function : PPaveFiller
//purpose :
//=======================================================================
BOPAlgo_PPaveFiller BOPAlgo_Builder::PPaveFiller()
{
return myPaveFiller;
}
//=======================================================================
//function : PDS
//purpose :
//=======================================================================
BOPDS_PDS BOPAlgo_Builder::PDS()
{
return myDS;
}
//=======================================================================
//function : SetNonDestructive
//purpose :
//=======================================================================
void BOPAlgo_Builder::SetNonDestructive(const Standard_Boolean theFlag)
{
myNonDestructive = theFlag;
}
//=======================================================================
//function : NonDestructive
//purpose :
//=======================================================================
Standard_Boolean BOPAlgo_Builder::NonDestructive() const
{
return myNonDestructive;
}
//=======================================================================
//function : SetGlue
//purpose :
//=======================================================================
void BOPAlgo_Builder::SetGlue(const BOPAlgo_GlueEnum theGlue)
{
myGlue=theGlue;
}
//=======================================================================
//function : Glue
//purpose :
//=======================================================================
BOPAlgo_GlueEnum BOPAlgo_Builder::Glue() const
{
return myGlue;
}
//=======================================================================
// function: CheckData
// purpose:
//=======================================================================
@@ -286,6 +196,7 @@ void BOPAlgo_Builder::Perform()
pPF->SetFuzzyValue(myFuzzyValue);
pPF->SetNonDestructive(myNonDestructive);
pPF->SetGlue(myGlue);
pPF->SetUseOBB(myUseOBB);
//
pPF->Perform();
//
@@ -303,6 +214,7 @@ void BOPAlgo_Builder::PerformWithFiller(const BOPAlgo_PaveFiller& theFiller)
myNonDestructive = theFiller.NonDestructive();
myFuzzyValue = theFiller.FuzzyValue();
myGlue = theFiller.Glue();
myUseOBB = theFiller.UseOBB();
PerformInternal(theFiller);
}
//=======================================================================

View File

@@ -54,6 +54,10 @@ class BOPAlgo_PaveFiller;
//! shapes during the operation (by default it is off);<br>
//! - *Gluing options* - allows to speed up the calculation of the intersections
//! on the special cases, in which some sub-shapes are coinciding.<br>
//! - *Disabling the check for inverted solids* - Disables/Enables the check of the input solids
//! for inverted status (holes in the space). The default value is TRUE,
//! i.e. the check is performed. Setting this flag to FALSE for inverted solids,
//! most likely will lead to incorrect results.
//!
//! The algorithm returns the following Error statuses:
//! - *BOPAlgo_AlertTooFewArguments* - in case there are no enough arguments to perform the operation;
@@ -67,139 +71,301 @@ public:
DEFINE_STANDARD_ALLOC
//! Empty constructor.
Standard_EXPORT BOPAlgo_Builder();
Standard_EXPORT virtual ~BOPAlgo_Builder();
Standard_EXPORT BOPAlgo_Builder(const BOPCol_BaseAllocator& theAllocator);
Standard_EXPORT virtual void Clear() Standard_OVERRIDE;
Standard_EXPORT BOPAlgo_PPaveFiller PPaveFiller();
Standard_EXPORT BOPDS_PDS PDS();
Standard_EXPORT virtual void AddArgument (const TopoDS_Shape& theShape);
Standard_EXPORT virtual void SetArguments (const BOPCol_ListOfShape& theLS);
Standard_EXPORT const BOPCol_ListOfShape& Arguments() const;
Standard_EXPORT virtual ~BOPAlgo_Builder();
Standard_EXPORT BOPAlgo_Builder(const Handle(NCollection_BaseAllocator)& theAllocator);
//! Clears the content of the algorithm.
Standard_EXPORT virtual void Clear() Standard_OVERRIDE;
//! Returns the PaveFiller, algorithm for sub-shapes intersection.
BOPAlgo_PPaveFiller PPaveFiller()
{
return myPaveFiller;
}
//! Returns the Data Structure, holder of intersection information.
BOPDS_PDS PDS()
{
return myDS;
}
//! Returns the Context, tool for cashing heavy algorithms.
Handle(IntTools_Context) Context() const
{
return myContext;
}
public: //! @name Arguments
//! Adds the argument to the operation.
Standard_EXPORT virtual void AddArgument (const TopoDS_Shape& theShape);
//! Sets the list of arguments for the operation.
Standard_EXPORT virtual void SetArguments (const BOPCol_ListOfShape& theLS);
//! Returns the list of arguments.
const BOPCol_ListOfShape& Arguments() const
{
return myArguments;
}
public: //! @name Options
Standard_EXPORT virtual void Perform() Standard_OVERRIDE;
Standard_EXPORT virtual void PerformWithFiller (const BOPAlgo_PaveFiller& theFiller);
//! Returns the list of shapes generated from the
//! shape theS.
Standard_EXPORT virtual const TopTools_ListOfShape& Generated (const TopoDS_Shape& theS) Standard_OVERRIDE;
//! Returns the list of shapes modified from the shape
//! theS.
Standard_EXPORT virtual const TopTools_ListOfShape& Modified (const TopoDS_Shape& theS) Standard_OVERRIDE;
//! Returns true if the shape theS has been deleted.
Standard_EXPORT virtual Standard_Boolean IsDeleted (const TopoDS_Shape& theS) Standard_OVERRIDE;
Standard_EXPORT const BOPCol_DataMapOfShapeListOfShape& Images() const;
Standard_EXPORT Standard_Boolean IsInterferred (const TopoDS_Shape& theS) const;
//! Returns myOrigins.
Standard_EXPORT const BOPCol_DataMapOfShapeListOfShape& Origins() const;
//! Returns myShapesSD.
Standard_EXPORT const BOPCol_DataMapOfShapeShape& ShapesSD() const;
//! Returns mySplits.
Standard_EXPORT const BOPCol_DataMapOfShapeListOfShape& Splits() const;
//! Sets the flag that defines the mode of treatment.
//! In non-destructive mode the argument shapes are not modified. Instead
//! a copy of a sub-shape is created in the result if it is needed to be updated.
//! This flag is taken into account if internal PaveFiller is used only.
//! In the case of calling PerformWithFiller the corresponding flag of that PaveFiller
//! is in force.
Standard_EXPORT void SetNonDestructive(const Standard_Boolean theFlag);
void SetNonDestructive(const Standard_Boolean theFlag)
{
myNonDestructive = theFlag;
}
//! Returns the flag that defines the mode of treatment.
//! In non-destructive mode the argument shapes are not modified. Instead
//! a copy of a sub-shape is created in the result if it is needed to be updated.
Standard_EXPORT Standard_Boolean NonDestructive() const;
Standard_Boolean NonDestructive() const
{
return myNonDestructive;
}
//! Sets the glue option for the algorithm
Standard_EXPORT void SetGlue(const BOPAlgo_GlueEnum theGlue);
void SetGlue(const BOPAlgo_GlueEnum theGlue)
{
myGlue = theGlue;
}
//! Returns the glue option of the algorithm
Standard_EXPORT BOPAlgo_GlueEnum Glue() const;
BOPAlgo_GlueEnum Glue() const
{
return myGlue;
}
protected:
//! Enables/Disables the check of the input solids for inverted status
void SetCheckInverted(const Standard_Boolean theCheck)
{
myCheckInverted = theCheck;
}
//! Prepare information for history support
//! Returns the flag defining whether the check for input solids on inverted status
//! should be performed or not.
Standard_Boolean CheckInverted() const
{
return myCheckInverted;
}
public: //! @name Performing the operation
//! Performs the operation.
//! The intersection will be performed also.
Standard_EXPORT virtual void Perform() Standard_OVERRIDE;
//! Performs the operation with the prepared filler.
//! The intersection will not be performed in this case.
Standard_EXPORT virtual void PerformWithFiller (const BOPAlgo_PaveFiller& theFiller);
public: //! @name History methods
//! Returns the list of shapes generated from the shape theS.
Standard_EXPORT virtual const TopTools_ListOfShape& Generated (const TopoDS_Shape& theS) Standard_OVERRIDE;
//! Returns the list of shapes modified from the shape theS.
Standard_EXPORT virtual const TopTools_ListOfShape& Modified (const TopoDS_Shape& theS) Standard_OVERRIDE;
//! Returns true if the shape theS has been deleted.
Standard_EXPORT virtual Standard_Boolean IsDeleted (const TopoDS_Shape& theS) Standard_OVERRIDE;
protected: //! @name History methods
//! Prepare information for history support.
Standard_EXPORT virtual void PrepareHistory() Standard_OVERRIDE;
//! Prepare history information for the input shapes taking into account possible
//! operation-specific modifications.
//! For instance, in the CellsBuilder operation, additionally to splitting input shapes
//! the splits of the shapes (or the shapes themselves) may be unified during removal of internal
//! boundaries. In this case each split should be linked to the unified shape.
//!
//! To have correct history information, the method should be redefined in each operation
//! where such additional modification is possible. The input shape <theS> should be the one from arguments,
//! and the returning list should contain all final elements to which the input shape has evolved,
//! including those not contained in the result shape.
//!
//! The method returns pointer to the list of modified elements.
//! NULL pointer means that the shape has not been modified at all.
//!
//! The General Fuse operation does not perform any other modification than splitting the input
//! shapes basing on their intersection information. This information is contained in myImages map.
//! Thus, here the method returns only splits (if any) contained in this map.
Standard_EXPORT virtual const TopTools_ListOfShape* LocModified(const TopoDS_Shape& theS);
public: //! @name Images/Origins
//! Returns the map of images.
const BOPCol_DataMapOfShapeListOfShape& Images() const
{
return myImages;
}
//! Returns the map of origins.
const BOPCol_DataMapOfShapeListOfShape& Origins() const
{
return myOrigins;
}
//! Returns the map of Same Domain (SD) shapes - coinciding shapes
//! from different arguments.
const BOPCol_DataMapOfShapeShape& ShapesSD() const
{
return myShapesSD;
}
protected: //! @name Methods for building the result
//! Performs the building of the result.
//! The method calls the PerfromInternal1() method surrounded by a try-catch block.
Standard_EXPORT virtual void PerformInternal (const BOPAlgo_PaveFiller& thePF);
//! Performs the building of the result.
//! To build the result of any other operation
//! it will be necessary to override this method.
Standard_EXPORT virtual void PerformInternal1 (const BOPAlgo_PaveFiller& thePF);
//! Builds the result of operation.
//! The method is called for each of the arguments type and
//! adds into the result the splits of the arguments of that type.
Standard_EXPORT virtual void BuildResult (const TopAbs_ShapeEnum theType);
protected: //! @name Checking input arguments
//! Checks the input data.
Standard_EXPORT virtual void CheckData() Standard_OVERRIDE;
//! Checks if the intersection algorithm has Errors/Warnings
//! Checks if the intersection algorithm has Errors/Warnings.
Standard_EXPORT void CheckFiller();
//! Prepares the result shape by making it empty compound.
Standard_EXPORT virtual void Prepare();
protected: //! @name Fill Images of VERTICES
//! Fills the images of vertices.
Standard_EXPORT void FillImagesVertices();
protected: //! @name Fill Images of EDGES
//! Fills the images of edges.
Standard_EXPORT void FillImagesEdges();
Standard_EXPORT virtual void BuildResult (const TopAbs_ShapeEnum theType);
protected: //! @name Fill Images of CONTAINERS
//! Fills the images of containers (WIRES/SHELLS/COMPSOLID).
Standard_EXPORT void FillImagesContainers (const TopAbs_ShapeEnum theType);
Standard_EXPORT void FillImagesCompounds();
//! Builds the image of the given container using the splits
//! of its sub-shapes.
Standard_EXPORT void FillImagesContainer (const TopoDS_Shape& theS, const TopAbs_ShapeEnum theType);
Standard_EXPORT void FillImagesCompound (const TopoDS_Shape& theS, BOPCol_MapOfShape& theMF);
protected: //! @name Fill Images of FACES
//! Fills the images of faces.
//! The method consists of three steps:
//! 1. Build the splits of faces;
//! 2. Find SD faces;
//! 3. Add internal vertices (if any) to faces.
Standard_EXPORT void FillImagesFaces();
//! Builds the splits of faces using the information from the
//! intersection stage stored in Data Structure.
Standard_EXPORT virtual void BuildSplitFaces();
//! Looks for the same domain faces among the splits of the faces.
//! Updates the map of images with SD faces.
Standard_EXPORT void FillSameDomainFaces();
Standard_EXPORT void FillImagesFaces1();
//! Classifies the alone vertices on faces relatively its splits
//! and adds them as INTERNAL into the splits.
Standard_EXPORT void FillInternalVertices();
protected: //! @name Fill Images of SOLIDS
//! Fills the images of solids.
//! The method consists of four steps:
//! 1. Build the draft solid - just rebuild the solid using the splits of faces;
//! 2. Find faces from other arguments located inside the solids;
//! 3. Build splits of solid using the inside faces;
//! 4. Fill internal shapes for the splits (Wires and vertices).
Standard_EXPORT void FillImagesSolids();
Standard_EXPORT void BuildDraftSolid (const TopoDS_Shape& theSolid, TopoDS_Shape& theDraftSolid, BOPCol_ListOfShape& theLIF);
Standard_EXPORT virtual void FillIn3DParts (BOPCol_DataMapOfShapeListOfShape& theInParts, BOPCol_DataMapOfShapeShape& theDraftSolids, const BOPCol_BaseAllocator& theAllocator);
Standard_EXPORT void BuildSplitSolids (BOPCol_DataMapOfShapeListOfShape& theInParts, BOPCol_DataMapOfShapeShape& theDraftSolids, const BOPCol_BaseAllocator& theAllocator);
//! Builds the draft solid by rebuilding the shells of the solid
//! with the splits of faces.
Standard_EXPORT void BuildDraftSolid (const TopoDS_Shape& theSolid,
TopoDS_Shape& theDraftSolid,
BOPCol_ListOfShape& theLIF);
//! Finds faces located inside each solid.
Standard_EXPORT virtual void FillIn3DParts (BOPCol_DataMapOfShapeListOfShape& theInParts,
BOPCol_DataMapOfShapeShape& theDraftSolids,
const Handle(NCollection_BaseAllocator)& theAllocator);
//! Builds the splits of the solids using their draft versions
//! and faces located inside.
Standard_EXPORT void BuildSplitSolids (BOPCol_DataMapOfShapeListOfShape& theInParts,
BOPCol_DataMapOfShapeShape& theDraftSolids,
const Handle(NCollection_BaseAllocator)& theAllocator);
//! Classifies the vertices and edges from the arguments relatively
//! splits of solids and makes them INTERNAL for solids.
Standard_EXPORT void FillInternalShapes();
protected: //! @name Fill Images of COMPOUNDS
//! Fills the images of compounds.
Standard_EXPORT void FillImagesCompounds();
//! Builds the image of the given compound.
Standard_EXPORT void FillImagesCompound (const TopoDS_Shape& theS,
BOPCol_MapOfShape& theMF);
protected: //! @name Post treatment
//! Post treatment of the result of the operation.
//! The method checks validity of the sub-shapes of the result
//! and updates the tolerances to make them valid.
Standard_EXPORT virtual void PostTreat();
BOPCol_ListOfShape myArguments;
BOPCol_MapOfShape myMapFence;
BOPAlgo_PPaveFiller myPaveFiller;
BOPDS_PDS myDS;
Handle(IntTools_Context) myContext;
Standard_Integer myEntryPoint;
BOPCol_DataMapOfShapeListOfShape myImages;
BOPCol_DataMapOfShapeShape myShapesSD;
BOPCol_DataMapOfShapeListOfShape mySplits;
BOPCol_DataMapOfShapeListOfShape myOrigins;
Standard_Boolean myNonDestructive;
BOPAlgo_GlueEnum myGlue;
protected: //! @name Fields
private:
BOPCol_ListOfShape myArguments; //!< Arguments of the operation
BOPCol_MapOfShape myMapFence; //!< Fence map providing the uniqueness of the shapes in the list of arguments
BOPAlgo_PPaveFiller myPaveFiller; //!< Pave Filler - algorithm for sub-shapes intersection
BOPDS_PDS myDS; //!< Data Structure - holder of intersection information
Handle(IntTools_Context) myContext; //!< Context - tool for cashing heavy algorithms such as Projectors and Classifiers
Standard_Integer myEntryPoint; //!< EntryPoint - controls the deletion of the PaveFiller, which could live longer than the Builder
BOPCol_DataMapOfShapeListOfShape myImages; //!< Images - map of Images of the sub-shapes of arguments
BOPCol_DataMapOfShapeShape myShapesSD; //!< ShapesSD - map of SD Shapes
BOPCol_DataMapOfShapeListOfShape myOrigins; //!< Origins - map of Origins, back map of Images
Standard_Boolean myNonDestructive; //!< Safe processing option allows avoiding modification of the input shapes
BOPAlgo_GlueEnum myGlue; //!< Gluing option allows speeding up the intersection of the input shapes
Standard_Boolean myCheckInverted; //!< Check inverted option allows disabling the check of input solids on inverted status
};
#endif // _BOPAlgo_Builder_HeaderFile

View File

@@ -25,6 +25,7 @@
#include <BOPCol_DataMapOfShapeListOfShape.hxx>
#include <BOPCol_DataMapOfShapeShape.hxx>
#include <BOPCol_IndexedDataMapOfShapeListOfShape.hxx>
#include <BOPCol_IndexedDataMapOfShapeShape.hxx>
#include <BOPCol_ListOfShape.hxx>
#include <BOPCol_MapOfShape.hxx>
#include <BOPCol_MapOfOrientedShape.hxx>
@@ -50,6 +51,7 @@
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopLoc_Location.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Iterator.hxx>
@@ -69,65 +71,7 @@ static
static
void MakeInternalWires(const BOPCol_IndexedMapOfShape& ,
BOPCol_ListOfShape& );
static
void GetWire(const TopoDS_Shape& ,
TopoDS_Shape& );
//
//
//=======================================================================
//class : BOPAlgo_ShapeBox2D
//purpose : Auxiliary class
//=======================================================================
class BOPAlgo_ShapeBox2D {
public:
BOPAlgo_ShapeBox2D() {
myIsHole=Standard_False;
};
//
~BOPAlgo_ShapeBox2D() {
};
//
void SetShape(const TopoDS_Shape& aS) {
myShape=aS;
};
//
const TopoDS_Shape& Shape()const {
return myShape;
};
//
void SetBox2D(const Bnd_Box2d& aBox2D) {
myBox2D=aBox2D;
};
//
const Bnd_Box2d& Box2D()const {
return myBox2D;
};
//
void SetIsHole(const Standard_Boolean bFlag) {
myIsHole=bFlag;
};
//
Standard_Boolean IsHole()const {
return myIsHole;
};
//
protected:
Standard_Boolean myIsHole;
TopoDS_Shape myShape;
Bnd_Box2d myBox2D;
};
//
typedef NCollection_IndexedDataMap
<Standard_Integer,
BOPAlgo_ShapeBox2D,
TColStd_MapIntegerHasher> BOPAlgo_IndexedDataMapOfIntegerShapeBox2D;
typedef NCollection_IndexedDataMap
<TopoDS_Shape,
TopoDS_Shape,
TopTools_ShapeMapHasher> BOPCol_IndexedDataMapOfShapeShape;
//
//=======================================================================
//function :
//purpose :
@@ -436,239 +380,198 @@ void BOPAlgo_BuilderFace::PerformLoops()
//=======================================================================
void BOPAlgo_BuilderFace::PerformAreas()
{
Standard_Boolean bIsGrowth, bIsHole;
Standard_Integer k, aNbS, aNbHoles, aNbDMISB, m, aNbMSH, aNbInOutMap;
Standard_Real aTol;
TopLoc_Location aLoc;
Handle(Geom_Surface) aS;
BRep_Builder aBB;
TopoDS_Face aFace;
BOPCol_ListIteratorOfListOfInteger aItLI;
BOPCol_IndexedMapOfShape aMHE;
BOPCol_ListIteratorOfListOfShape aIt1;
BOPCol_IndexedDataMapOfShapeListOfShape aMSH;
BOPCol_IndexedDataMapOfShapeShape aInOutMap;
BOPAlgo_IndexedDataMapOfIntegerShapeBox2D aDMISB(100);
//
BOPCol_Box2DBndTreeSelector aSelector;
BOPCol_Box2DBndTree aBBTree;
NCollection_UBTreeFiller <Standard_Integer, Bnd_Box2d> aTreeFiller(aBBTree);
//
aNbHoles=0;
//
aTol=BRep_Tool::Tolerance(myFace);
aS=BRep_Tool::Surface(myFace, aLoc);
//
myAreas.Clear();
//
if (myLoops.IsEmpty()) {
if (myContext->IsInfiniteFace(myFace)) {
BRep_Builder aBB;
// Location of the myFace
TopLoc_Location aLoc;
// Get surface from myFace
const Handle(Geom_Surface)& aS = BRep_Tool::Surface(myFace, aLoc);
// Get tolerance of myFace
Standard_Real aTol = BRep_Tool::Tolerance(myFace);
// Check if there are no loops at all
if (myLoops.IsEmpty())
{
if (myContext->IsInfiniteFace(myFace))
{
TopoDS_Face aFace;
aBB.MakeFace(aFace, aS, aLoc, aTol);
if (BRep_Tool::NaturalRestriction(myFace)) {
if (BRep_Tool::NaturalRestriction(myFace))
aBB.NaturalRestriction(aFace, Standard_True);
}
myAreas.Append(aFace);
myAreas.Append(aFace);
}
return;
}
//
// 1. Growthes and Holes -> aDMISB: [Index/ShapeBox2D]
aIt1.Initialize(myLoops);
for (k=0 ; aIt1.More(); aIt1.Next(), ++k) {
Bnd_Box2d aBox2D;
//
const TopoDS_Shape& aWire=aIt1.Value();
//
// The new faces
BOPCol_ListOfShape aNewFaces;
// The hole faces which has to be classified relatively new faces
BOPCol_IndexedMapOfShape aHoleFaces;
// Map of the edges of the hole faces for quick check of the growths.
// If the analyzed wire contains any of the edges from the hole faces
// it is considered as growth.
BOPCol_IndexedMapOfShape aMHE;
// Analyze the new wires - classify them to be the holes and growths
BOPCol_ListIteratorOfListOfShape aItLL(myLoops);
for (; aItLL.More(); aItLL.Next())
{
const TopoDS_Shape& aWire = aItLL.Value();
TopoDS_Face aFace;
aBB.MakeFace(aFace, aS, aLoc, aTol);
aBB.Add (aFace, aWire);
BRepTools::AddUVBounds(aFace, aBox2D);
//
bIsGrowth=IsGrowthWire(aWire, aMHE);
if (bIsGrowth) {
bIsHole=Standard_False;
aBB.Add(aFace, aWire);
Standard_Boolean bIsGrowth = IsGrowthWire(aWire, aMHE);
if (!bIsGrowth)
{
// Fast check did not give the result, run classification
IntTools_FClass2d& aClsf = myContext->FClass2d(aFace);
bIsGrowth = !aClsf.IsHole();
}
else{
// check if a wire is a hole
IntTools_FClass2d& aClsf=myContext->FClass2d(aFace);
aClsf.Init(aFace, aTol);
//
bIsHole=aClsf.IsHole();
if (bIsHole) {
BOPTools::MapShapes(aWire, TopAbs_EDGE, aMHE);
//
bIsHole=Standard_True;
}
else {
bIsHole=Standard_False;
}
// Save the face
if (bIsGrowth)
{
aNewFaces.Append(aFace);
}
//
BOPAlgo_ShapeBox2D aSB2D;
//
aSB2D.SetShape(aFace);
aSB2D.SetBox2D(aBox2D);
aSB2D.SetIsHole(bIsHole);
//
aDMISB.Add(k, aSB2D);
}// for (k=0 ; aIt1.More(); aIt1.Next(), ++k) {
//
// 2. Prepare TreeFiller
aNbDMISB=aDMISB.Extent();
for (m=1; m<=aNbDMISB; ++m) {
k=aDMISB.FindKey(m);
const BOPAlgo_ShapeBox2D& aSB2D=aDMISB.FindFromIndex(m);
//
bIsHole=aSB2D.IsHole();
if (bIsHole) {
const Bnd_Box2d& aBox2D=aSB2D.Box2D();
aTreeFiller.Add(k, aBox2D);
++aNbHoles;
else
{
aHoleFaces.Add(aFace);
BOPTools::MapShapes(aWire, TopAbs_EDGE, aMHE);
}
}
//
// 3. Shake TreeFiller
if (aHoleFaces.IsEmpty())
{
// No holes, stop the analysis
myAreas.Append(aNewFaces);
}
// Classify holes relatively faces
// Prepare tree filler with the boxes of the hole faces
BOPCol_Box2DBndTree aBBTree;
NCollection_UBTreeFiller <Standard_Integer, Bnd_Box2d> aTreeFiller(aBBTree);
Standard_Integer i, aNbH = aHoleFaces.Extent();
for (i = 1; i <= aNbH; ++i)
{
const TopoDS_Face& aHFace = TopoDS::Face(aHoleFaces(i));
//
Bnd_Box2d aBox;
BRepTools::AddUVBounds(aHFace, aBox);
aTreeFiller.Add(i, aBox);
}
// Shake TreeFiller
aTreeFiller.Fill();
//
// 4. Find outer growth shell that is most close
// to each hole shell
for (m=1; m<=aNbDMISB; ++m) {
const BOPAlgo_ShapeBox2D& aSB2D=aDMISB.FindFromIndex(m);
bIsHole=aSB2D.IsHole();
if (bIsHole) {
continue;
}
//
const Bnd_Box2d& aBox2DF=aSB2D.Box2D();
const TopoDS_Shape aF=aSB2D.Shape();
//
aSelector.Clear();
aSelector.SetBox(aBox2DF);
//
aNbS = aBBTree.Select(aSelector);
if (!aNbS) {
continue;
}
//
const BOPCol_ListOfInteger& aLI=aSelector.Indices();
//
aItLI.Initialize(aLI);
for (; aItLI.More(); aItLI.Next()) {
k=aItLI.Value();
const BOPAlgo_ShapeBox2D& aSB2Dk=aDMISB.FindFromKey(k);
const TopoDS_Shape& aHole=aSB2Dk.Shape();
//
if (!IsInside(aHole, aF, myContext)){
// Find outer growth face that is most close to each hole face
BOPCol_IndexedDataMapOfShapeShape aHoleFaceMap;
BOPCol_ListIteratorOfListOfShape aItLS(aNewFaces);
for (; aItLS.More(); aItLS.Next())
{
const TopoDS_Face& aFace = TopoDS::Face(aItLS.Value());
// Build box
Bnd_Box2d aBox;
BRepTools::AddUVBounds(aFace, aBox);
BOPCol_Box2DBndTreeSelector aSelector;
aSelector.SetBox(aBox);
aBBTree.Select(aSelector);
const BOPCol_ListOfInteger& aLI = aSelector.Indices();
BOPCol_ListIteratorOfListOfInteger aItLI(aLI);
for (; aItLI.More(); aItLI.Next())
{
Standard_Integer k = aItLI.Value();
const TopoDS_Shape& aHole = aHoleFaces(k);
// Check if it is inside
if (!IsInside(aHole, aFace, myContext))
continue;
}
//
if (aInOutMap.Contains(aHole)){
TopoDS_Shape& aF2=aInOutMap.ChangeFromKey(aHole);
if (IsInside(aF, aF2, myContext)) {
aF2=aF;
// Save the relation
TopoDS_Shape* pFaceWas = aHoleFaceMap.ChangeSeek(aHole);
if (pFaceWas)
{
if (IsInside(aFace, *pFaceWas, myContext))
{
*pFaceWas = aFace;
}
}
else{
aInOutMap.Add(aHole, aF);
else
{
aHoleFaceMap.Add(aHole, aFace);
}
}
}// for (m=1; m<=aNbDMISB; ++m)
//
// 5.1 Map [Face/Holes] -> aMSH
aNbInOutMap=aInOutMap.Extent();
for (m=1; m<=aNbInOutMap; ++m) {
const TopoDS_Shape& aHole=aInOutMap.FindKey(m);
const TopoDS_Shape& aF=aInOutMap.FindFromIndex(m);
//
if (aMSH.Contains(aF)) {
BOPCol_ListOfShape& aLH=aMSH.ChangeFromKey(aF);
aLH.Append(aHole);
}
else {
BOPCol_ListOfShape aLH;
aLH.Append(aHole);
aMSH.Add(aF, aLH);
}
}
//
// 5.2. Add unused holes to the original face
if (aNbHoles != aNbInOutMap) {
// Make the back map from faces to holes
BOPCol_IndexedDataMapOfShapeListOfShape aFaceHolesMap;
aNbH = aHoleFaceMap.Extent();
for (i = 1; i <= aNbH; ++i)
{
const TopoDS_Shape& aHole = aHoleFaceMap.FindKey(i);
const TopoDS_Shape& aFace = aHoleFaceMap(i);
//
BOPCol_ListOfShape* pLHoles = aFaceHolesMap.ChangeSeek(aFace);
if (!pLHoles)
pLHoles = &aFaceHolesMap(aFaceHolesMap.Add(aFace, BOPCol_ListOfShape()));
pLHoles->Append(aHole);
}
// Add unused holes to the original face
if (aHoleFaces.Extent() != aHoleFaceMap.Extent())
{
Bnd_Box aBoxF;
BRepBndLib::Add(myFace, aBoxF);
if (aBoxF.IsOpenXmin() || aBoxF.IsOpenXmax() ||
aBoxF.IsOpenYmin() || aBoxF.IsOpenYmax() ||
aBoxF.IsOpenZmin() || aBoxF.IsOpenZmax()) {
//
BOPCol_ListOfShape anUnUsedHoles;
for (m = 1; m <= aNbDMISB; ++m) {
const BOPAlgo_ShapeBox2D& aSB2D=aDMISB.FindFromIndex(m);
if (aSB2D.IsHole()) {
const TopoDS_Shape& aHole = aSB2D.Shape();
if (!aInOutMap.Contains(aHole)) {
anUnUsedHoles.Append(aHole);
}
}
aBoxF.IsOpenZmin() || aBoxF.IsOpenZmax())
{
TopoDS_Face aFace;
aBB.MakeFace(aFace, aS, aLoc, aTol);
BOPCol_ListOfShape& anUnUsedHoles = aFaceHolesMap(aFaceHolesMap.Add(aFace, BOPCol_ListOfShape()));
aNbH = aHoleFaces.Extent();
for (i = 1; i <= aNbH; ++i)
{
const TopoDS_Shape& aHole = aHoleFaces(i);
if (!aHoleFaceMap.Contains(aHole))
anUnUsedHoles.Append(aHole);
}
//
if (anUnUsedHoles.Extent()) {
aBB.MakeFace(aFace, aS, aLoc, aTol);
aMSH.Add(aFace, anUnUsedHoles);
//
BOPAlgo_ShapeBox2D aSB2D;
//
aSB2D.SetShape(aFace);
aSB2D.SetIsHole(Standard_False);
//
aDMISB.Add(aNbDMISB, aSB2D);
++aNbDMISB;
// Save it
aNewFaces.Append(aFace);
}
}
// Add Holes to Faces and add them to myAreas
aItLS.Initialize(aNewFaces);
for ( ; aItLS.More(); aItLS.Next())
{
TopoDS_Face& aFace = *(TopoDS_Face*)&aItLS.Value();
const BOPCol_ListOfShape* pLHoles = aFaceHolesMap.Seek(aFace);
if (pLHoles)
{
// update faces with the holes
BOPCol_ListIteratorOfListOfShape aItLH(*pLHoles);
for (; aItLH.More(); aItLH.Next())
{
const TopoDS_Shape& aFHole = aItLH.Value();
// The hole face contains only one wire
TopoDS_Iterator aItW(aFHole);
aBB.Add(aFace, aItW.Value());
}
// update classifier
myContext->FClass2d(aFace).Init(aFace, aTol);
}
}
//
// 6. Add aHoles to Faces
aNbMSH=aMSH.Extent();
for (m=1; m<=aNbMSH; ++m) {
TopoDS_Face aF=(*(TopoDS_Face *)(&aMSH.FindKey(m)));
const BOPCol_ListOfShape& aLH=aMSH.FindFromIndex(m);
//
aIt1.Initialize(aLH);
for (; aIt1.More(); aIt1.Next()) {
TopoDS_Shape aWHole;
//
const TopoDS_Shape& aFHole=aIt1.Value();
GetWire(aFHole, aWHole);
aBB.Add (aF, aWHole);
}
//
// update classifier
aTol=BRep_Tool::Tolerance(aF);
IntTools_FClass2d& aClsf=myContext->FClass2d(aF);
aClsf.Init(aF, aTol);
}
//
// 7. Fill myAreas
// NB:These aNewFaces are draft faces that
// do not contain any internal shapes
for (m=1; m<=aNbDMISB; ++m) {
const BOPAlgo_ShapeBox2D& aSB2D=aDMISB.FindFromIndex(m);
bIsHole=aSB2D.IsHole();
if (!bIsHole) {
const TopoDS_Shape aF=aSB2D.Shape();
myAreas.Append(aF);
}
}
}
//=======================================================================
//function : GetWire
//purpose :
//=======================================================================
void GetWire(const TopoDS_Shape& aF, TopoDS_Shape& aW)
{
TopoDS_Shape aWx;
TopoDS_Iterator aIt;
//
aIt.Initialize(aF);
for (; aIt.More(); aIt.Next()) {
aW=aIt.Value();
// The face is just a draft that does not contain any internal shapes
myAreas.Append(aFace);
}
}
//=======================================================================
@@ -805,45 +708,53 @@ void MakeInternalWires(const BOPCol_IndexedMapOfShape& theME,
//function : IsInside
//purpose :
//=======================================================================
Standard_Boolean IsInside(const TopoDS_Shape& theHole,
const TopoDS_Shape& theF2,
Standard_Boolean IsInside(const TopoDS_Shape& theWire,
const TopoDS_Shape& theF,
Handle(IntTools_Context)& theContext)
{
Standard_Boolean bRet;
Standard_Real aT, aU, aV;
TopAbs_State aState;
TopExp_Explorer aExp;
BOPCol_IndexedMapOfShape aME2;
gp_Pnt2d aP2D;
//
bRet=Standard_False;
aState=TopAbs_UNKNOWN;
const TopoDS_Face& aF2=(*(TopoDS_Face *)(&theF2));
//
BOPTools::MapShapes(aF2, TopAbs_EDGE, aME2);//AA
//
aExp.Init(theHole, TopAbs_EDGE);
if (aExp.More()) {
const TopoDS_Edge& aE =(*(TopoDS_Edge *)(&aExp.Current()));
if (aME2.Contains(aE)) {
return bRet;
}
if (!BRep_Tool::Degenerated(aE)) {
//
aT=BOPTools_AlgoTools2D::IntermediatePoint(aE);
BOPTools_AlgoTools2D::PointOnSurface(aE, aF2, aT, aU, aV, theContext);
aP2D.SetCoord(aU, aV);
//
IntTools_FClass2d& aClsf=theContext->FClass2d(aF2);
aState=aClsf.Perform(aP2D);
bRet=(aState==TopAbs_IN);
}
}
//
return bRet;
}
// Check if the wire is located inside the face:
// take unique point from the wire and classify it relatively the face
// Avoid edges of the face
TopTools_IndexedMapOfShape aFaceEdgesMap;
TopExp::MapShapes(theF, TopAbs_EDGE, aFaceEdgesMap);
// Get classification tool from the context
const TopoDS_Face& aF = TopoDS::Face(theF);
IntTools_FClass2d& aClassifier = theContext->FClass2d(aF);
Standard_Boolean isInside = Standard_False;
// Iterate on wire edges until first classification is performed
TopExp_Explorer anExp(theWire, TopAbs_EDGE);
for (; anExp.More(); anExp.Next())
{
const TopoDS_Edge& aE = TopoDS::Edge(anExp.Current());
if (BRep_Tool::Degenerated(aE))
// Avoid checking degenerated edges.
continue;
if (aFaceEdgesMap.Contains(aE))
// Face contains the edge from the wire, thus the wire cannot be
// inside that face.
return isInside;
// Get 2d curve of the edge on the face
Standard_Real aT1, aT2;
const Handle(Geom2d_Curve)& aC2D = BRep_Tool::CurveOnSurface(aE, aF, aT1, aT2);
if (aC2D.IsNull())
continue;
// Get middle point on the curve
gp_Pnt2d aP2D = aC2D->Value((aT1 + aT2) / 2.);
// Classify the point
TopAbs_State aState = aClassifier.Perform(aP2D);
isInside = (aState == TopAbs_IN);
break;
}
return isInside;
}
//=======================================================================
//function : IsGrowthWire
//purpose :
@@ -851,18 +762,14 @@ Standard_Boolean IsInside(const TopoDS_Shape& theHole,
Standard_Boolean IsGrowthWire(const TopoDS_Shape& theWire,
const BOPCol_IndexedMapOfShape& theMHE)
{
Standard_Boolean bRet;
TopoDS_Iterator aIt;
//
bRet=Standard_False;
if (theMHE.Extent()) {
aIt.Initialize(theWire);
for(; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aE=aIt.Value();
if (theMHE.Contains(aE)) {
return !bRet;
}
if (theMHE.Extent())
{
TopoDS_Iterator aIt(theWire);
for(; aIt.More(); aIt.Next())
{
if (theMHE.Contains(aIt.Value()))
return Standard_True;
}
}
return bRet;
return Standard_False;
}

View File

@@ -122,6 +122,7 @@
{
myHistShapes.Clear();
myMapShape.Clear();
myImagesResult.Clear();
myHasDeleted=Standard_False;
myHasGenerated=Standard_False;
myHasModified=Standard_False;

View File

@@ -18,6 +18,7 @@
#include <BOPAlgo_BuilderSolid.hxx>
#include <BOPAlgo_ShellSplitter.hxx>
#include <BOPAlgo_Alerts.hxx>
#include <BOPAlgo_Tools.hxx>
#include <BOPCol_BoxBndTree.hxx>
#include <BOPCol_DataMapOfShapeListOfShape.hxx>
#include <BOPCol_DataMapOfShapeShape.hxx>
@@ -53,6 +54,7 @@
#include <TopAbs.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Compound.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
@@ -77,179 +79,6 @@ static
void MakeInternalShells(const BOPCol_IndexedMapOfShape& ,
BOPCol_ListOfShape& );
//=======================================================================
//class : BOPAlgo_BuilderSolid_ShapeBox
//purpose : Auxiliary class
//=======================================================================
class BOPAlgo_BuilderSolid_ShapeBox {
public:
BOPAlgo_BuilderSolid_ShapeBox() {
myIsHole=Standard_False;
};
//
~BOPAlgo_BuilderSolid_ShapeBox() {
};
//
void SetShape(const TopoDS_Shape& aS) {
myShape=aS;
};
//
const TopoDS_Shape& Shape()const {
return myShape;
};
//
void SetBox(const Bnd_Box& aBox) {
myBox=aBox;
};
//
const Bnd_Box& Box()const {
return myBox;
};
//
void SetIsHole(const Standard_Boolean bFlag) {
myIsHole=bFlag;
};
//
Standard_Boolean IsHole()const {
return myIsHole;
};
//
protected:
Standard_Boolean myIsHole;
TopoDS_Shape myShape;
Bnd_Box myBox;
};
//
typedef NCollection_DataMap
<Standard_Integer,
BOPAlgo_BuilderSolid_ShapeBox,
TColStd_MapIntegerHasher> BOPAlgo_DataMapOfIntegerBSSB;
//
typedef BOPAlgo_DataMapOfIntegerBSSB::Iterator
BOPAlgo_DataMapIteratorOfDataMapOfIntegerBSSB;
//
//=======================================================================
//function : BOPAlgo_FacePnt
//purpose :
//=======================================================================
class BOPAlgo_FacePnt {
public:
BOPAlgo_FacePnt() {
}
//
virtual ~BOPAlgo_FacePnt() {
}
//
void SetFace(const TopoDS_Face& aFace) {
myFace=aFace;
}
//
const TopoDS_Face& Face()const {
return myFace;
}
//
void SetPnt(const gp_Pnt& aPnt) {
myPnt=aPnt;
}
//
const gp_Pnt& Pnt()const {
return myPnt;
}
//
protected:
gp_Pnt myPnt;
TopoDS_Face myFace;
};
//
typedef BOPCol_NCVector
<BOPAlgo_FacePnt> BOPAlgo_VectorOfFacePnt;
//
//=======================================================================
//function : BOPAlgo_FaceSolid
//purpose :
//=======================================================================
class BOPAlgo_FaceSolid : public BOPAlgo_Algo {
public:
DEFINE_STANDARD_ALLOC
BOPAlgo_FaceSolid() :
myIsInternalFace(Standard_False) {
}
//
virtual ~BOPAlgo_FaceSolid() {
}
//
void SetFace(const TopoDS_Face& aFace) {
myFace=aFace;
}
//
const TopoDS_Face& Face()const {
return myFace;
}
//
void SetSolid(const TopoDS_Solid& aSolid) {
mySolid=aSolid;
}
//
const TopoDS_Solid& Solid()const {
return mySolid;
}
//
void SetPnt(const gp_Pnt& aPnt) {
myPnt=aPnt;
}
//
const gp_Pnt& Pnt()const {
return myPnt;
}
void SetContext(const Handle(IntTools_Context)& aContext) {
myContext=aContext;
}
//
const Handle(IntTools_Context)& Context()const {
return myContext;
}
//
Standard_Boolean IsInternalFace() const {
return myIsInternalFace;
}
//
virtual void Perform () {
TopAbs_State aState;
//
BOPAlgo_Algo::UserBreak();
//
aState=BOPTools_AlgoTools::ComputeState(myPnt, mySolid,
Precision::Confusion(),
myContext);
//
myIsInternalFace=(aState==TopAbs_IN);
}
//
protected:
Standard_Boolean myIsInternalFace;
gp_Pnt myPnt;
TopoDS_Face myFace;
TopoDS_Solid mySolid;
Handle(IntTools_Context) myContext;
};
//=======================================================================
typedef BOPCol_NCVector
<BOPAlgo_FaceSolid> BOPAlgo_VectorOfFaceSolid;
//
typedef BOPCol_ContextFunctor
<BOPAlgo_FaceSolid,
BOPAlgo_VectorOfFaceSolid,
Handle(IntTools_Context),
IntTools_Context> BOPAlgo_FaceSolidFunctor;
//
typedef BOPCol_ContextCnt
<BOPAlgo_FaceSolidFunctor,
BOPAlgo_VectorOfFaceSolid,
Handle(IntTools_Context)> BOPAlgo_FaceSolidCnt;
//
//=======================================================================
//=======================================================================
//function :
//purpose :
@@ -277,22 +106,6 @@ BOPAlgo_BuilderSolid::~BOPAlgo_BuilderSolid()
{
}
//=======================================================================
//function : SetSolid
//purpose :
//=======================================================================
void BOPAlgo_BuilderSolid::SetSolid(const TopoDS_Solid& aS)
{
mySolid=aS;
}
//=======================================================================
//function : Solid
//purpose :
//=======================================================================
const TopoDS_Solid& BOPAlgo_BuilderSolid::Solid()const
{
return mySolid;
}
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
@@ -300,10 +113,15 @@ void BOPAlgo_BuilderSolid::Perform()
{
GetReport()->Clear();
//
if (myShapes.IsEmpty())
return;
if (myContext.IsNull()) {
myContext=new IntTools_Context;
}
//
myBoxes.Clear();
TopoDS_Compound aC;
BRep_Builder aBB;
BOPCol_ListIteratorOfListOfShape aIt;
@@ -572,183 +390,182 @@ void BOPAlgo_BuilderSolid::PerformLoops()
//=======================================================================
void BOPAlgo_BuilderSolid::PerformAreas()
{
Standard_Boolean bIsGrowth, bIsHole;
Standard_Integer i, k, aNbInOut, aNbMSH;
BRep_Builder aBB;
BOPCol_ListIteratorOfListOfShape aItLS;
BOPCol_ListOfShape aNewSolids, aHoleShells;
BOPCol_IndexedDataMapOfShapeShape aInOutMap;
BOPCol_IndexedMapOfShape aMHF;
BOPCol_ListIteratorOfListOfInteger aItLI;
BOPCol_BoxBndTreeSelector aSelector;
BOPCol_BoxBndTree aBBTree;
NCollection_UBTreeFiller
<Standard_Integer, Bnd_Box> aTreeFiller(aBBTree);
BOPAlgo_DataMapOfIntegerBSSB aDMISB(100);
BOPCol_IndexedDataMapOfShapeListOfShape aMSH;
BOPAlgo_DataMapIteratorOfDataMapOfIntegerBSSB aItDMISB;
//
myAreas.Clear();
//
// Draft solids [aNewSolids]
aItLS.Initialize(myLoops);
for (k=0; aItLS.More(); aItLS.Next(), ++k) {
TopoDS_Solid aSolid;
Bnd_Box aBox;
BOPAlgo_BuilderSolid_ShapeBox aSB;
//
const TopoDS_Shape& aShell = aItLS.Value();
aSB.SetShape(aShell);
//
BRepBndLib::Add(aShell, aBox);
bIsHole=Standard_False;
//
bIsGrowth=IsGrowthShell(aShell, aMHF);
if (bIsGrowth) {
// make a growth solid from a shell
BRep_Builder aBB;
// The new solids
BOPCol_ListOfShape aNewSolids;
// The hole shells which has to be classified relatively new solids
BOPCol_IndexedMapOfShape aHoleShells;
// Map of the faces of the hole shells for quick check of the growths.
// If the analyzed shell contains any of the hole faces, it is considered as growth.
BOPCol_IndexedMapOfShape aMHF;
// Analyze the shells
BOPCol_ListIteratorOfListOfShape aItLL(myLoops);
for (; aItLL.More(); aItLL.Next())
{
const TopoDS_Shape& aShell = aItLL.Value();
Standard_Boolean bIsGrowth = IsGrowthShell(aShell, aMHF);
if (!bIsGrowth)
{
// Fast check did not give the result, run classification
bIsGrowth = !IsHole(aShell, myContext);
}
// Save the solid
if (bIsGrowth)
{
TopoDS_Solid aSolid;
aBB.MakeSolid(aSolid);
aBB.Add (aSolid, aShell);
//
aNewSolids.Append (aSolid);
aSB.SetShape(aSolid);
}
else{
// check if a shell is a hole
bIsHole=IsHole(aShell, myContext);
if (bIsHole) {
aHoleShells.Append(aShell);
BOPTools::MapShapes(aShell, TopAbs_FACE, aMHF);
aSB.SetShape(aShell);
}
else {
// make a growth solid from a shell
aBB.MakeSolid(aSolid);
aBB.Add (aSolid, aShell);
//
aNewSolids.Append (aSolid);
aSB.SetShape(aSolid);
}
}
//
aSB.SetBox(aBox);
aSB.SetIsHole(bIsHole);
aDMISB.Bind(k, aSB);
}
//
// 2. Prepare TreeFiller
aItDMISB.Initialize(aDMISB);
for (; aItDMISB.More(); aItDMISB.Next()) {
k=aItDMISB.Key();
const BOPAlgo_BuilderSolid_ShapeBox& aSB=aItDMISB.Value();
//
bIsHole=aSB.IsHole();
if (bIsHole) {
const Bnd_Box& aBox=aSB.Box();
aTreeFiller.Add(k, aBox);
else
{
aHoleShells.Add(aShell);
BOPTools::MapShapes(aShell, TopAbs_FACE, aMHF);
}
}
//
// 3. Shake TreeFiller
aTreeFiller.Fill();
//
// 4. Find outer growth shell that is most close
// to each hole shell
aItDMISB.Initialize(aDMISB);
for (; aItDMISB.More(); aItDMISB.Next()) {
k=aItDMISB.Key();
const BOPAlgo_BuilderSolid_ShapeBox& aSB=aItDMISB.Value();
bIsHole=aSB.IsHole();
if (bIsHole) {
continue;
if (aHoleShells.IsEmpty())
{
// No holes, stop the analysis
BOPCol_ListIteratorOfListOfShape aItLS(aNewSolids);
for (; aItLS.More(); aItLS.Next())
{
const TopoDS_Shape& aSol = aItLS.Value();
myAreas.Append(aSol);
// Build box
Bnd_Box aBox;
BRepBndLib::Add(aSol, aBox);
myBoxes.Bind(aSol, aBox);
}
return;
}
// Classify holes relatively solids
// Prepare tree filler with the boxes of the hole shells
BOPCol_BoxBndTree aBBTree;
NCollection_UBTreeFiller <Standard_Integer, Bnd_Box> aTreeFiller(aBBTree);
Standard_Integer i, aNbH = aHoleShells.Extent();
for (i = 1; i <= aNbH; ++i)
{
const TopoDS_Shape& aHShell = aHoleShells(i);
//
const TopoDS_Shape aSolid=aSB.Shape();
const Bnd_Box& aBoxSolid=aSB.Box();
//
aSelector.Clear();
aSelector.SetBox(aBoxSolid);
//
Bnd_Box aBox;
BRepBndLib::Add(aHShell, aBox);
aTreeFiller.Add(i, aBox);
myBoxes.Bind(aHShell, aBox);
}
// Shake TreeFiller
aTreeFiller.Fill();
// Find outer growth shell that is most close to each hole shell
BOPCol_IndexedDataMapOfShapeShape aHoleSolidMap;
BOPCol_ListIteratorOfListOfShape aItLS(aNewSolids);
for (; aItLS.More(); aItLS.Next())
{
const TopoDS_Shape& aSolid = aItLS.Value();
// Build box
Bnd_Box aBox;
BRepBndLib::Add(aSolid, aBox);
myBoxes.Bind(aSolid, aBox);
BOPCol_BoxBndTreeSelector aSelector;
aSelector.SetBox(aBox);
aBBTree.Select(aSelector);
//
const BOPCol_ListOfInteger& aLI=aSelector.Indices();
//
aItLI.Initialize(aLI);
for (; aItLI.More(); aItLI.Next()) {
k=aItLI.Value();
const BOPAlgo_BuilderSolid_ShapeBox& aSBk=aDMISB.Find(k);
const TopoDS_Shape& aHole=aSBk.Shape();
//
if (!IsInside(aHole, aSolid, myContext)){
const BOPCol_ListOfInteger& aLI = aSelector.Indices();
BOPCol_ListIteratorOfListOfInteger aItLI(aLI);
for (; aItLI.More(); aItLI.Next())
{
Standard_Integer k = aItLI.Value();
const TopoDS_Shape& aHole = aHoleShells(k);
// Check if it is inside
if (!IsInside(aHole, aSolid, myContext))
continue;
}
//
if (aInOutMap.Contains (aHole)){
const TopoDS_Shape& aSolidWas = aInOutMap.FindFromKey(aHole);
if (IsInside(aSolid, aSolidWas, myContext)) {
aInOutMap.ChangeFromKey(aHole) = aSolid;
// Save the relation
TopoDS_Shape* pSolidWas = aHoleSolidMap.ChangeSeek(aHole);
if (pSolidWas)
{
if (IsInside(aSolid, *pSolidWas, myContext))
{
*pSolidWas = aSolid;
}
}
else{
aInOutMap.Add(aHole, aSolid);
else
{
aHoleSolidMap.Add(aHole, aSolid);
}
}
}//for (i = 1; i <= aNbDMISB; ++i) {
//
// 5. Map [Solid/Holes] -> aMSH
aNbInOut = aInOutMap.Extent();
for (i = 1; i <= aNbInOut; ++i) {
const TopoDS_Shape& aHole = aInOutMap.FindKey(i);
const TopoDS_Shape& aSolid = aInOutMap(i);
//
if (aMSH.Contains(aSolid)) {
BOPCol_ListOfShape& aLH = aMSH.ChangeFromKey(aSolid);
aLH.Append(aHole);
}
else {
BOPCol_ListOfShape aLH;
aLH.Append(aHole);
aMSH.Add(aSolid, aLH);
}
}
//
// 6. Add aHoles to Solids
aNbMSH = aMSH.Extent();
for (i = 1; i <= aNbMSH; ++i) {
TopoDS_Solid aSolid=(*(TopoDS_Solid*)(&(aMSH.FindKey(i))));
const BOPCol_ListOfShape& aLH = aMSH(i);
//
aItLS.Initialize(aLH);
for (; aItLS.More(); aItLS.Next()) {
const TopoDS_Shape& aHole = aItLS.Value();
aBB.Add (aSolid, aHole);
}
//
// update classifier
BRepClass3d_SolidClassifier& aSC=
myContext->SolidClassifier(aSolid);
aSC.Load(aSolid);
// Make the back map from solids to holes
BOPCol_IndexedDataMapOfShapeListOfShape aSolidHolesMap;
aNbH = aHoleSolidMap.Extent();
for (i = 1; i <= aNbH; ++i)
{
const TopoDS_Shape& aHole = aHoleSolidMap.FindKey(i);
const TopoDS_Shape& aSolid = aHoleSolidMap(i);
//
BOPCol_ListOfShape* pLHoles = aSolidHolesMap.ChangeSeek(aSolid);
if (!pLHoles)
pLHoles = &aSolidHolesMap(aSolidHolesMap.Add(aSolid, BOPCol_ListOfShape()));
pLHoles->Append(aHole);
}
//
// 7. These aNewSolids are draft solids that
// do not contain any internal shapes
// Add Holes to Solids and add them to myAreas
aItLS.Initialize(aNewSolids);
for ( ; aItLS.More(); aItLS.Next()) {
const TopoDS_Shape& aSx=aItLS.Value();
myAreas.Append(aSx);
for ( ; aItLS.More(); aItLS.Next())
{
TopoDS_Solid& aSolid = *(TopoDS_Solid*)&aItLS.Value();
const BOPCol_ListOfShape* pLHoles = aSolidHolesMap.Seek(aSolid);
if (pLHoles)
{
// update solid
BOPCol_ListIteratorOfListOfShape aItLH(*pLHoles);
for (; aItLH.More(); aItLH.Next())
{
const TopoDS_Shape& aHole = aItLH.Value();
aBB.Add(aSolid, aHole);
}
// update classifier
myContext->SolidClassifier(aSolid).Load(aSolid);
}
myAreas.Append(aSolid);
}
// Add holes that outside the solids to myAreas
aItLS.Initialize(aHoleShells);
for (; aItLS.More(); aItLS.Next()) {
const TopoDS_Shape& aHole = aItLS.Value();
if (!aInOutMap.Contains(aHole)){
aNbH = aHoleShells.Extent();
for (i = 1; i <= aNbH; ++i)
{
const TopoDS_Shape& aHole = aHoleShells(i);
if (!aHoleSolidMap.Contains(aHole))
{
TopoDS_Solid aSolid;
//
aBB.MakeSolid(aSolid);
aBB.Add (aSolid, aHole);
//
myAreas.Append(aSolid);
// Make an infinite box for the hole
Bnd_Box aBox;
aBox.SetWhole();
myBoxes.Bind(aSolid, aBox);
}
myBoxes.UnBind(aHole);
}
}
//=======================================================================
@@ -757,216 +574,121 @@ void BOPAlgo_BuilderSolid::PerformAreas()
//=======================================================================
void BOPAlgo_BuilderSolid::PerformInternalShapes()
{
if (myAvoidInternalShapes) {
if (myAvoidInternalShapes)
// user-defined option to avoid internal parts is in force
return;
}
//
Standard_Integer aNbFI=myLoopsInternal.Extent();
if (!aNbFI) {// nothing to do
if (myLoopsInternal.IsEmpty())
// no internal parts
return;
}
//
Standard_Boolean bIsInternalFace;
Standard_Integer k, aNbVFS, aNbSLF, aNbVFP, aNbA;
BRep_Builder aBB;
TopoDS_Iterator aIt;
TopExp_Explorer aExp;
BOPCol_ListIteratorOfListOfShape aItLS;
// Get all faces to classify
BOPCol_IndexedMapOfShape aMFs;
BOPCol_ListOfShape aLSI;
BOPAlgo_VectorOfFaceSolid aVFS;
BOPAlgo_VectorOfFacePnt aVFP;
BOPCol_ListIteratorOfListOfInteger aItLI;
BOPCol_BoxBndTreeSelector aSelector;
BOPCol_BoxBndTree aBBTree;
NCollection_UBTreeFiller
<Standard_Integer, Bnd_Box> aTreeFiller(aBBTree);
//
aNbA=myAreas.Extent();
//
// 1. aVFP
aItLS.Initialize(myLoopsInternal);
for (; aItLS.More(); aItLS.Next()) {
const TopoDS_Shape& aShell=aItLS.Value();
aIt.Initialize(aShell);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Face& aF=*((TopoDS_Face*)&aIt.Value());
//
if (!aMFs.Contains(aF)) {
aMFs.Add(aF);
//
gp_Pnt aP;
gp_Pnt2d aP2D;
//
if (aNbA) {
BOPTools_AlgoTools3D::PointInFace(aF, aP, aP2D, myContext);
}
//
BOPAlgo_FacePnt& aFP=aVFP.Append1();
aFP.SetFace(aF);
aFP.SetPnt(aP);
}
}
BOPCol_ListIteratorOfListOfShape aItLS(myLoopsInternal);
for (; aItLS.More(); aItLS.Next())
{
const TopoDS_Shape& aShell = aItLS.Value();
TopoDS_Iterator aIt(aShell);
for (; aIt.More(); aIt.Next())
aMFs.Add(aIt.Value());
}
//
if (!aNbA) {
// 7b. "Rest" faces treatment
BRep_Builder aBB;
// Check existence of the growths solids
if (myAreas.IsEmpty())
{
// No areas.
// Just make solid of the faces
TopoDS_Solid aSolid;
aBB.MakeSolid(aSolid);
//
BOPCol_ListOfShape aLSI;
MakeInternalShells(aMFs, aLSI);
//
aItLS.Initialize(aLSI);
for (; aItLS.More(); aItLS.Next()) {
const TopoDS_Shape& aSI=aItLS.Value();
aBB.Add (aSolid, aSI);
}
for (; aItLS.More(); aItLS.Next())
aBB.Add(aSolid, aItLS.Value());
myAreas.Append(aSolid);
//
return; // =>
}//if (!aNbA) {
//
// 2. Prepare TreeFiller
aNbVFP=aVFP.Extent();
for(k=0; k<aNbVFP; ++k) {
Bnd_Box aBox;
//
const BOPAlgo_FacePnt& aFP=aVFP(k);
const TopoDS_Face& aF=aFP.Face();
//
BRepBndLib::Add(aF, aBox);
aTreeFiller.Add(k, aBox);
}
//
aTreeFiller.Fill();
//
// 3. Face/Solid candidates: aVFS
aItLS.Initialize(myAreas);
for (; aItLS.More(); aItLS.Next()) {
Bnd_Box aBox;
//
TopoDS_Solid& aSolid=(*(TopoDS_Solid*)(&aItLS.Value()));
BRepBndLib::Add(aSolid, aBox);
//
aMFs.Clear();
aExp.Init(aSolid, TopAbs_FACE);
for (; aExp.More(); aExp.Next()) {
const TopoDS_Shape& aFs=aExp.Current();
aMFs.Add(aFs);
}
//
aSelector.Clear();
aSelector.SetBox(aBox);
//
aBBTree.Select(aSelector);
//
const BOPCol_ListOfInteger& aLI=aSelector.Indices();
aItLI.Initialize(aLI);
for (; aItLI.More(); aItLI.Next()) {
k=aItLI.Value();
const BOPAlgo_FacePnt& aFP=aVFP(k);
const TopoDS_Face& aF=aFP.Face();
if (aMFs.Contains(aF)) {
continue;
}
//
const gp_Pnt& aP=aFP.Pnt();
//
BOPAlgo_FaceSolid& aFS=aVFS.Append1();
aFS.SetPnt(aP);
aFS.SetFace(aF);
aFS.SetSolid(aSolid);
}
}
//
aNbVFS=aVFS.Extent();
if (!aNbVFS) {
return;
}
// 4. Refine candidates
//=============================================================
BOPAlgo_FaceSolidCnt::Perform(myRunParallel, aVFS, myContext);
//=============================================================
//
// 5. Solid/Faces: aMSLF
// Classify faces relatively solids
// Prepare list of faces to classify
BOPCol_ListOfShape aLFaces;
Standard_Integer i, aNbF = aMFs.Extent();
for (i = 1; i <= aNbF; ++i)
aLFaces.Append(aMFs(i));
// Map of solids with IN faces
BOPCol_IndexedDataMapOfShapeListOfShape aMSLF;
BOPCol_MapOfShape aMFProcessed;
//
for (k=0; k < aNbVFS; ++k) {
const BOPAlgo_FaceSolid& aFS=aVFS(k);
//
const TopoDS_Solid& aSolid=aFS.Solid();
const TopoDS_Face& aF=aFS.Face();
//
bIsInternalFace=aFS.IsInternalFace();
if (!bIsInternalFace) {
// Perform classification
BOPAlgo_Tools::ClassifyFaces(aLFaces, myAreas, myRunParallel, myContext, aMSLF, myBoxes);
// Update Solids by internal Faces
BOPCol_MapOfShape aMFDone;
Standard_Integer aNbS = aMSLF.Extent();
for (i = 1; i <= aNbS; ++i)
{
const TopoDS_Shape& aSolid = aMSLF.FindKey(i);
TopoDS_Shape *pSolid = (TopoDS_Shape*)&aSolid;
const BOPCol_ListOfShape& aLF = aMSLF(i);
if (aLF.IsEmpty())
continue;
}
//
if (aMSLF.Contains(aSolid)) {
BOPCol_ListOfShape& aLF=aMSLF.ChangeFromKey(aSolid);
aLF.Append(aF);
}
else {
BOPCol_ListOfShape aLF;
//
aLF.Append(aF);
aMSLF.Add(aSolid, aLF);
}
}// for (k=0; k < aNbVE; ++k) {
//
// 6. Update Solids by internal Faces
aNbSLF=aMSLF.Extent();
for (k=1; k <= aNbSLF; ++k) {
const TopoDS_Shape& aSolid=aMSLF.FindKey(k);
TopoDS_Shape *pSolid=(TopoDS_Shape*)&aSolid;
//
const BOPCol_ListOfShape& aLF=aMSLF(k);
//
aMFs.Clear();
BOPCol_IndexedMapOfShape aMF;
aItLS.Initialize(aLF);
for (; aItLS.More(); aItLS.Next()) {
const TopoDS_Shape& aF=aItLS.Value();
aMFs.Add(aF);
aMFProcessed.Add(aF);
for (; aItLS.More(); aItLS.Next())
{
const TopoDS_Shape& aF = aItLS.Value();
aMF.Add(aF);
aMFDone.Add(aF);
}
//
aLSI.Clear();
MakeInternalShells(aMFs, aLSI);
BOPCol_ListOfShape aLSI;
MakeInternalShells(aMF, aLSI);
//
aItLS.Initialize(aLSI);
for (; aItLS.More(); aItLS.Next()) {
const TopoDS_Shape& aSI=aItLS.Value();
for (; aItLS.More(); aItLS.Next())
{
const TopoDS_Shape& aSI = aItLS.Value();
aBB.Add (*pSolid, aSI);
}
}
//
// 7. "Rest" faces treatment (if there are)
aMFs.Clear();
for (k=0; k < aNbVFS; ++k) {
const BOPAlgo_FaceSolid& aFS=aVFS(k);
//
const TopoDS_Face& aF=aFS.Face();
if (!aMFProcessed.Contains(aF)) {
aMFs.Add(aF);
}
// Find all unclassified faces and warn the user about them.
// Do not put such faces into result as they will form not closed solid.
BOPCol_IndexedMapOfShape aMFUnUsed;
for (i = 1; i <= aNbF; ++i)
{
const TopoDS_Shape& aF = aMFs(i);
if (!aMFDone.Contains(aF))
aMFUnUsed.Add(aF);
}
//
aNbFI=aMFs.Extent();
if (aNbFI) {
TopoDS_Solid aSolid;
aBB.MakeSolid(aSolid);
//
aLSI.Clear();
MakeInternalShells(aMFs, aLSI);
//
aItLS.Initialize(aLSI);
for (; aItLS.More(); aItLS.Next()) {
const TopoDS_Shape& aSI=aItLS.Value();
aBB.Add (aSolid, aSI);
if (aMFUnUsed.Extent())
{
BOPCol_ListOfShape aLSI;
MakeInternalShells(aMFUnUsed, aLSI);
TopoDS_Shape aWShape;
if (aLSI.Extent() == 1)
aWShape = aLSI.First();
else
{
aBB.MakeCompound(TopoDS::Compound(aWShape));
aItLS.Initialize(aLSI);
for (; aItLS.More(); aItLS.Next())
aBB.Add(aWShape, aItLS.Value());
}
myAreas.Append(aSolid);
}
AddWarning(new BOPAlgo_AlertSolidBuilderUnusedFaces(aWShape)); }
}
//=======================================================================
//function : MakeInternalShells
@@ -1073,18 +795,14 @@ Standard_Boolean IsInside(const TopoDS_Shape& theS1,
Standard_Boolean IsGrowthShell(const TopoDS_Shape& theShell,
const BOPCol_IndexedMapOfShape& theMHF)
{
Standard_Boolean bRet;
TopoDS_Iterator aIt;
//
bRet=Standard_False;
if (theMHF.Extent()) {
aIt.Initialize(theShell);
for(; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aF=aIt.Value();
if (theMHF.Contains(aF)) {
return !bRet;
}
if (theMHF.Extent())
{
TopoDS_Iterator aIt(theShell);
for(; aIt.More(); aIt.Next())
{
if (theMHF.Contains(aIt.Value()))
return Standard_True;
}
}
return bRet;
return Standard_False;
}

View File

@@ -22,70 +22,120 @@
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <TopoDS_Solid.hxx>
#include <BOPAlgo_BuilderArea.hxx>
#include <BOPCol_BaseAllocator.hxx>
class TopoDS_Solid;
#include <BOPCol_DataMapOfShapeBox.hxx>
//! The algorithm to build solids from set of faces
//! Solid Builder is the algorithm for building solids from set of faces.
//! The given faces should be non-intersecting, i.e. all coinciding parts
//! of the faces should be shared among them.
//!
//! The algorithm performs the following steps to build the solids:
//! 1. Find:
//! - faces orientated INTERNAL;
//! - alone faces given twice with different orientation;
//! 2. Build all possible closed shells from the rest of the faces
//! (*BOPAlgo_ShellSplitter* is used for that);
//! 3. Classify the obtained shells on the Holes and Growths;
//! 4. Build solids from the Growth shells, put Hole shells into closest Growth solids;
//! 5. Classify all unused faces relatively created solids and put them as internal
//! shells into the closest solids;
//! 6. Find all unclassified faces, i.e. faces outside of all created solids,
//! make internal shells from them and put these shells into a warning.
//!
//! It is possible to avoid all internal shells in the resulting solids.
//! For that it is necessary to use the method SetAvoidInternalShapes(true)
//! of the base class. In this case the steps 5 and 6 will not be performed at all.
//!
//! The algorithm may return the following warnings:
//! - *BOPAlgo_AlertShellSplitterFailed* in case the ShellSplitter algorithm has failed;
//! - *BOPAlgo_AlertSolidBuilderUnusedFaces* in case there are some faces outside of
//! created solids left.
//!
//! Example of usage of the algorithm:
//! ~~~~
//! const TopTools_ListOfShape& aFaces = ...; // Faces to build the solids
//! Standard_Boolean isAvoidInternals = ...; // Flag which defines whether to create the internal shells or not
//! BOPAlgo_BuilderSolid aBS; // Solid Builder tool
//! aBS.SetShapes(aFaces); // Set the faces
//! aBS.SetAvoidInternalShapes(isAvoidInternals); // Set the AvoidInternalShapesFlag
//! aBS.Perform(); // Perform the operation
//! if (!aBS.IsDone()) // Check for the errors
//! {
//! // error treatment
//! Standard_SStream aSStream;
//! aBS.DumpErrors(aSStream);
//! return;
//! }
//! if (aBS.HasWarnings()) // Check for the warnings
//! {
//! // warnings treatment
//! Standard_SStream aSStream;
//! aBS.DumpWarnings(aSStream);
//! }
//!
//! const TopTools_ListOfShape& aSolids = aBS.Areas(); // Obtaining the result solids
//! ~~~~
//!
class BOPAlgo_BuilderSolid : public BOPAlgo_BuilderArea
{
public:
DEFINE_STANDARD_ALLOC
public: //! @name Constructors
//! Empty constructor
Standard_EXPORT BOPAlgo_BuilderSolid();
Standard_EXPORT virtual ~BOPAlgo_BuilderSolid();
Standard_EXPORT virtual ~BOPAlgo_BuilderSolid();
//! Constructor with allocator
Standard_EXPORT BOPAlgo_BuilderSolid(const BOPCol_BaseAllocator& theAllocator);
//! Sets the source solid <theSolid>
Standard_EXPORT void SetSolid (const TopoDS_Solid& theSolid);
//! Returns the source solid
Standard_EXPORT const TopoDS_Solid& Solid() const;
//! Performs the algorithm
public: //! @name Performing the operation
//! Performs the construction of the solids from the given faces
Standard_EXPORT virtual void Perform() Standard_OVERRIDE;
protected:
//! Collect the faces that
//! a) are internal
//! b) are the same and have different orientation
public: //! @name Getting the bounding boxes of the created solids
//! For classification purposes the algorithm builds the bounding boxes
//! for all created solids. This method returns the data map of solid - box pairs.
const BOPCol_DataMapOfShapeBox& GetBoxesMap() const
{
return myBoxes;
}
protected: //! @name Protected methods performing the operation
//! Collect the faces:
//! - with INTERNAL orientation;
//! - that are alone but given twice with different orientation.
//! These faces will be put into the map *myShapesToAvoid* and will be
//! avoided in shells construction, but will be classified later on.
Standard_EXPORT virtual void PerformShapesToAvoid() Standard_OVERRIDE;
//! Build draft shells
//! a)myLoops - draft shells that consist of
//! boundary faces
//! b)myLoopsInternal - draft shells that contains
//! inner faces
//! Build all possible closed shells from the given faces.
//! The method fills the following maps:
//! - myLoops - Created closed shells;
//! - myLoopsInternal - The shells created from unused faces.
Standard_EXPORT virtual void PerformLoops() Standard_OVERRIDE;
//! Build draft solids that contains boundary faces
//! Classifies the created shells on the Holes and Growths.
//! Creates the solids from the Growths shells.
//! Puts the Hole shells into the closest Growths solids.
Standard_EXPORT virtual void PerformAreas() Standard_OVERRIDE;
//! Build finalized solids with internal shells
//! Classifies the unused faces relatively the created solids.
//! Puts the classified faces into the closest solids as internal shells.
//! Warns the user about unclassified faces if any.
Standard_EXPORT virtual void PerformInternalShapes() Standard_OVERRIDE;
TopoDS_Solid mySolid;
private:
BOPCol_DataMapOfShapeBox myBoxes; // Boxes of the produced solids
};
#endif // _BOPAlgo_BuilderSolid_HeaderFile

View File

@@ -40,28 +40,22 @@
//=======================================================================
void BOPAlgo_Builder::FillImagesVertices()
{
Standard_Integer nV, nVSD;
BOPCol_DataMapIteratorOfDataMapOfIntegerInteger aIt;
//
const BOPCol_DataMapOfIntegerInteger& aMSDV=myDS->ShapesSD();
aIt.Initialize(aMSDV);
for (; aIt.More(); aIt.Next()) {
nV=aIt.Key();
nVSD=aIt.Value();
const TopoDS_Shape& aV=myDS->Shape(nV);
const TopoDS_Shape& aVSD=myDS->Shape(nVSD);
//
BOPCol_ListOfShape aLVSD(myAllocator);
//
aLVSD.Append(aVSD);
myImages.Bind(aV, aLVSD);
//
BOPCol_DataMapIteratorOfDataMapOfIntegerInteger aIt(myDS->ShapesSD());
for (; aIt.More(); aIt.Next())
{
Standard_Integer nV = aIt.Key();
Standard_Integer nVSD = aIt.Value();
const TopoDS_Shape& aV = myDS->Shape(nV);
const TopoDS_Shape& aVSD = myDS->Shape(nVSD);
// Add to Images map
myImages.Bound(aV, BOPCol_ListOfShape(myAllocator))->Append(aVSD);
// Add to SD map
myShapesSD.Bind(aV, aVSD);
//
// Add to Origins map
BOPCol_ListOfShape* pLOr = myOrigins.ChangeSeek(aVSD);
if (!pLOr) {
if (!pLOr)
pLOr = myOrigins.Bound(aVSD, BOPCol_ListOfShape());
}
pLOr->Append(aV);
}
}
@@ -115,55 +109,38 @@ void BOPAlgo_Builder::FillImagesVertices()
}
}
//=======================================================================
// function: IsInterferred
// purpose:
//=======================================================================
Standard_Boolean BOPAlgo_Builder::IsInterferred(const TopoDS_Shape& theS)const
{
Standard_Boolean bInterferred;
TopoDS_Iterator aIt;
//
bInterferred=Standard_False;
aIt.Initialize(theS);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aSx=aIt.Value();
if (myImages.IsBound(aSx)) {
bInterferred=!bInterferred;
break;
}
}
return bInterferred;
}
//=======================================================================
//function : BuildResult
//purpose :
//=======================================================================
void BOPAlgo_Builder::BuildResult(const TopAbs_ShapeEnum theType)
void BOPAlgo_Builder::BuildResult(const TopAbs_ShapeEnum theType)
{
TopAbs_ShapeEnum aType;
BRep_Builder aBB;
BOPCol_MapOfShape aM;
BOPCol_ListIteratorOfListOfShape aIt, aItIm;
//
aIt.Initialize(myArguments);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aS=aIt.Value();
aType=aS.ShapeType();
if (aType==theType) {
if (myImages.IsBound(aS)){
const BOPCol_ListOfShape& aLSIm=myImages.Find(aS);
aItIm.Initialize(aLSIm);
for (; aItIm.More(); aItIm.Next()) {
const TopoDS_Shape& aSIm=aItIm.Value();
if (aM.Add(aSIm)) {
aBB.Add(myShape, aSIm);
}
}
}
else {
if (aM.Add(aS)) {
aBB.Add(myShape, aS);
}
// Fence map
BOPCol_MapOfShape aMFence;
// Iterate on all arguments of given type
// and add their images into result
BOPCol_ListIteratorOfListOfShape aItA(myArguments);
for (; aItA.More(); aItA.Next())
{
const TopoDS_Shape& aS = aItA.Value();
if (aS.ShapeType() != theType)
continue;
// Get images
const BOPCol_ListOfShape* pLSIm = myImages.Seek(aS);
if (!pLSIm)
{
// No images -> add the argument shape itself into result
if (aMFence.Add(aS))
BRep_Builder().Add(myShape, aS);
}
else
{
// Add images of the argument shape into result
BOPCol_ListIteratorOfListOfShape aItIm(*pLSIm);
for (; aItIm.More(); aItIm.Next())
{
const TopoDS_Shape& aSIm = aItIm.Value();
if (aMFence.Add(aSIm))
BRep_Builder().Add(myShape, aSIm);
}
}
}
@@ -211,45 +188,57 @@ void BOPAlgo_Builder::FillImagesVertices()
void BOPAlgo_Builder::FillImagesContainer(const TopoDS_Shape& theS,
const TopAbs_ShapeEnum theType)
{
Standard_Boolean bInterferred, bToReverse;
TopoDS_Iterator aIt;
BRep_Builder aBB;
BOPCol_ListIteratorOfListOfShape aItIm;
//
bInterferred=IsInterferred(theS);
if (!bInterferred){
// Check if any of the sub-shapes of the container have been modified
TopoDS_Iterator aIt(theS);
for (; aIt.More(); aIt.Next())
{
const TopoDS_Shape& aSS = aIt.Value();
const BOPCol_ListOfShape* pLFIm = myImages.Seek(aSS);
if (pLFIm && ((pLFIm->Extent() != 1) || !pLFIm->First().IsSame(aSS)))
break;
}
if (!aIt.More())
{
// Non of the sub-shapes have been modified.
// No need to create the new container.
return;
}
//
BRep_Builder aBB;
// Make the new container of the splits of its sub-shapes
TopoDS_Shape aCIm;
BOPTools_AlgoTools::MakeContainer(theType, aCIm);
//
aIt.Initialize(theS);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aSx=aIt.Value();
if (myImages.IsBound(aSx)) {
const BOPCol_ListOfShape& aLFIm=myImages.Find(aSx);
aItIm.Initialize(aLFIm);
for (; aItIm.More(); aItIm.Next()) {
TopoDS_Shape aSxIm=aItIm.Value();
//
bToReverse=BOPTools_AlgoTools::IsSplitToReverse(aSxIm, aSx, myContext);
if (bToReverse) {
aSxIm.Reverse();
}
aBB.Add(aCIm, aSxIm);
}
for (; aIt.More(); aIt.Next())
{
const TopoDS_Shape& aSS = aIt.Value();
const BOPCol_ListOfShape* pLSSIm = myImages.Seek(aSS);
if (!pLSSIm)
{
// No splits, add the sub-shape itself
aBB.Add(aCIm, aSS);
continue;
}
else {
aBB.Add(aCIm, aSx);
// Add the splits
BOPCol_ListIteratorOfListOfShape aItIm(*pLSSIm);
for (; aItIm.More(); aItIm.Next())
{
TopoDS_Shape aSSIm = aItIm.Value();
if (!aSSIm.IsEqual(aSS) &&
BOPTools_AlgoTools::IsSplitToReverse(aSSIm, aSS, myContext))
{
aSSIm.Reverse();
}
aBB.Add(aCIm, aSSIm);
}
}
//
aCIm.Closed(BRep_Tool::IsClosed(aCIm));
//
BOPCol_ListOfShape aLSIm(myAllocator);
aLSIm.Append(aCIm);
myImages.Bind(theS, aLSIm);
myImages.Bound(theS, BOPCol_ListOfShape(myAllocator))->Append(aCIm);
}
//=======================================================================
//function : FillImagesCompound

View File

@@ -45,32 +45,28 @@
#include <BOPTools_ListOfCoupleOfShape.hxx>
#include <BOPTools_MapOfSet.hxx>
#include <BRep_Builder.hxx>
#include <BRepLib.hxx>
#include <BRep_Tool.hxx>
#include <GeomAdaptor_Surface.hxx>
#include <GeomLib.hxx>
#include <NCollection_IncAllocator.hxx>
#include <Precision.hxx>
#include <IntTools_Context.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Compound.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Vertex.hxx>
#include <algorithm>
//
static
Standard_Boolean HasPaveBlocksOnIn(const BOPDS_FaceInfo& aFI1,
const BOPDS_FaceInfo& aFI2);
//
typedef BOPCol_NCVector<TopoDS_Shape> BOPAlgo_VectorOfShape;
//
typedef BOPCol_NCVector<BOPAlgo_VectorOfShape> \
BOPAlgo_VectorOfVectorOfShape;
//
typedef NCollection_IndexedDataMap\
<BOPTools_Set, Standard_Integer, BOPTools_SetMapHasher> \
BOPAlgo_IndexedDataMapOfSetInteger;
//
TopoDS_Face BuildDraftFace(const TopoDS_Face& theFace,
const BOPCol_DataMapOfShapeListOfShape& theImages,
Handle(IntTools_Context)& theCtx);
//=======================================================================
//class : BOPAlgo_PairOfShapeBoolean
//purpose :
@@ -161,7 +157,7 @@ class BOPAlgo_VFI : public BOPAlgo_Algo {
BOPAlgo_VFI() :
BOPAlgo_Algo(),
myFlag(-1) {
myIsInternal(Standard_False) {
}
//
virtual ~BOPAlgo_VFI(){
@@ -183,8 +179,8 @@ class BOPAlgo_VFI : public BOPAlgo_Algo {
return myF;
}
//
Standard_Integer Flag()const {
return myFlag;
Standard_Boolean IsInternal()const {
return myIsInternal;
}
//
void SetContext(const Handle(IntTools_Context)& aContext) {
@@ -199,11 +195,13 @@ class BOPAlgo_VFI : public BOPAlgo_Algo {
Standard_Real aT1, aT2, dummy;
//
BOPAlgo_Algo::UserBreak();
myFlag = myContext->ComputeVF(myV, myF, aT1, aT2, dummy, myFuzzyValue);
Standard_Integer iFlag =
myContext->ComputeVF(myV, myF, aT1, aT2, dummy, myFuzzyValue);
myIsInternal = (iFlag == 0);
}
//
protected:
Standard_Integer myFlag;
Standard_Boolean myIsInternal;
TopoDS_Vertex myV;
TopoDS_Face myF;
Handle(IntTools_Context) myContext;
@@ -230,7 +228,7 @@ void BOPAlgo_Builder::FillImagesFaces()
{
BuildSplitFaces();
FillSameDomainFaces();
FillImagesFaces1();
FillInternalVertices();
}
//=======================================================================
//function : BuildSplitFaces
@@ -240,7 +238,6 @@ void BOPAlgo_Builder::BuildSplitFaces()
{
Standard_Boolean bHasFaceInfo, bIsClosed, bIsDegenerated, bToReverse;
Standard_Integer i, j, k, aNbS, aNbPBIn, aNbPBOn, aNbPBSc, aNbAV, nSp;
Standard_Size aNbBF;
TopoDS_Face aFF, aFSD;
TopoDS_Edge aSp, aEE;
TopAbs_Orientation anOriF, anOriE;
@@ -249,7 +246,6 @@ void BOPAlgo_Builder::BuildSplitFaces()
BOPCol_ListOfInteger aLIAV;
BOPCol_MapOfShape aMFence;
Handle(NCollection_BaseAllocator) aAllocator;
BOPCol_ListOfShape aLFIm(myAllocator);
BOPAlgo_VectorOfBuilderFace aVBF;
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~scope f
@@ -259,6 +255,10 @@ void BOPAlgo_Builder::BuildSplitFaces()
BOPCol_ListOfShape aLE(aAllocator);
BOPCol_MapOfShape aMDE(100, aAllocator);
//
// Build temporary map of faces images to avoid rebuilding
// of the faces without any IN or section edges
NCollection_IndexedDataMap<Standard_Integer, BOPCol_ListOfShape> aFacesIm;
//
aNbS=myDS->NbSourceShapes();
//
for (i=0; i<aNbS; ++i) {
@@ -292,17 +292,46 @@ void BOPAlgo_Builder::BuildSplitFaces()
if (!aNbPBIn && !aNbPBOn && !aNbPBSc && !aNbAV) { // not compete
continue;
}
//
if (!aNbPBIn && !aNbPBSc)
{
if (!aNbAV)
{
// Check if any wires of the face have been modified.
// If not, there is no need to create the new face.
TopoDS_Iterator aItW(aF);
for (; aItW.More(); aItW.Next())
{
if (myImages.IsBound(aItW.Value()))
break;
}
if (!aItW.More())
continue;
}
// No internal parts for the face, so just build the draft face
// and keep it to pass directly into result.
// If the original face has any internal edges, the draft face
// will be null, as the internal edges may split the face on parts
// (as in the case "bugs modalg_5 bug25245_1").
// The BuilderFace algorithm will be called in this case.
TopoDS_Face aFD = BuildDraftFace(aF, myImages, myContext);
if (!aFD.IsNull())
{
aFacesIm(aFacesIm.Add(i, BOPCol_ListOfShape())).Append(aFD);
continue;
}
}
aMFence.Clear();
//
anOriF=aF.Orientation();
aFF=aF;
aFF.Orientation(TopAbs_FORWARD);
//
// 1. Fill the egdes set for the face aFF -> LE
// 1. Fill the edges set for the face aFF -> LE
aLE.Clear();
//
//
// 1.1 Bounding edges
aExp.Init(aFF, TopAbs_EDGE);
for (; aExp.More(); aExp.Next()) {
@@ -415,7 +444,7 @@ void BOPAlgo_Builder::BuildSplitFaces()
//
if (!myPaveFiller->NonDestructive()) {
// speed up for planar faces
BOPTools_AlgoTools2D::BuildPCurveForEdgesOnPlane (aLE, aFF);
BRepLib::BuildPCurveForEdgesOnPlane(aLE, aFF);
}
// 3 Build split faces
BOPAlgo_BuilderFace& aBF=aVBF.Append1();
@@ -426,208 +455,296 @@ void BOPAlgo_Builder::BuildSplitFaces()
//
}// for (i=0; i<aNbS; ++i) {
//
aNbBF=aVBF.Extent();
//
//===================================================
BOPAlgo_BuilderFaceCnt::Perform(myRunParallel, aVBF);
//===================================================
//
for (k=0; k<(Standard_Integer)aNbBF; ++k) {
aLFIm.Clear();
Standard_Integer aNbBF = aVBF.Extent();
for (k = 0; k < aNbBF; ++k)
{
BOPAlgo_BuilderFace& aBF = aVBF(k);
aFacesIm.Add(myDS->Index(aBF.Face()), aBF.Areas());
}
aNbBF = aFacesIm.Extent();
for (k = 1; k <= aNbBF; ++k)
{
const TopoDS_Face& aF = TopoDS::Face(myDS->Shape(aFacesIm.FindKey(k)));
anOriF = aF.Orientation();
const BOPCol_ListOfShape& aLFR = aFacesIm(k);
//
BOPAlgo_BuilderFace& aBF=aVBF(k);
TopoDS_Face aF=aBF.Face();
anOriF=aBF.Orientation();
aF.Orientation(anOriF);
//
const BOPCol_ListOfShape& aLFR=aBF.Areas();
BOPCol_ListOfShape* pLFIm = myImages.Bound(aF, BOPCol_ListOfShape());
aIt.Initialize(aLFR);
for (; aIt.More(); aIt.Next()) {
TopoDS_Shape& aFR=aIt.ChangeValue();
if (anOriF==TopAbs_REVERSED) {
if (anOriF==TopAbs_REVERSED)
aFR.Orientation(TopAbs_REVERSED);
}
//aFR.Orientation(anOriF);
aLFIm.Append(aFR);
pLFIm->Append(aFR);
}
//
mySplits.Bind(aF, aLFIm);
}// for (k=0; k<aNbBF; ++k) {
}
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~scope t
}
//=======================================================================
//function : AddEdgeSet
//purpose :
//=======================================================================
typedef
NCollection_IndexedDataMap<BOPTools_Set,
BOPCol_ListOfShape,
BOPTools_SetMapHasher> BOPAlgo_IndexedDataMapOfSetListOfShape;
static void AddEdgeSet(const TopoDS_Shape& theS,
BOPAlgo_IndexedDataMapOfSetListOfShape& theMap,
const Handle(NCollection_BaseAllocator)& theAllocator)
{
// Make set
BOPTools_Set aSE;
aSE.Add(theS, TopAbs_EDGE);
// Add set to the map, keeping connection to the shape
BOPCol_ListOfShape* pLF = theMap.ChangeSeek(aSE);
if (!pLF)
pLF = &theMap(theMap.Add(aSE, BOPCol_ListOfShape(theAllocator)));
pLF->Append(theS);
}
//=======================================================================
//function : FillSameDomainFaces
//purpose :
//=======================================================================
void BOPAlgo_Builder::FillSameDomainFaces()
{
Standard_Boolean bFlag;
Standard_Integer i, j, k, aNbFFs, nF1, nF2;
Handle(NCollection_BaseAllocator) aAllocator;
BOPCol_ListIteratorOfListOfShape aItF;
BOPCol_MapOfShape aMFence;
BOPAlgo_IndexedDataMapOfSetInteger aIDMSS;
BOPAlgo_VectorOfVectorOfShape aVVS;
//
const BOPDS_VectorOfInterfFF& aFFs=myDS->InterfFF();
//
aNbFFs=aFFs.Extent();
if (!aNbFFs) {
// It is necessary to analyze all Face/Face intersections
// and find all faces with equal sets of edges
const BOPDS_VectorOfInterfFF& aFFs = myDS->InterfFF();
Standard_Integer aNbFFs = aFFs.Extent();
if (!aNbFFs)
return;
Handle(NCollection_BaseAllocator) aAllocator = new NCollection_IncAllocator;
// Vector to store the indices of faces for future sorting
// for making the SD face for the group from the face with
// smallest index in Data structure
BOPCol_NCVector<Standard_Integer> aFIVec(256, aAllocator);
// Fence map to avoid repeated checks of the same face.
BOPCol_MapOfInteger aMFence(1, aAllocator);
// Fill the vector with indices of faces
for (Standard_Integer i = 0; i < aNbFFs; ++i)
{
const BOPDS_InterfFF& aFF = aFFs(i);
// get indices
Standard_Integer nF[2];
aFF.Indices(nF[0], nF[1]);
// store indices to the vector
for (Standard_Integer j = 0; j < 2; ++j)
{
if (!myDS->HasFaceInfo(nF[j]))
continue;
if (!aMFence.Add(nF[j]))
continue;
aFIVec.Append1() = nF[j];
}
}
//
for (i=0; i<aNbFFs; ++i) {
const BOPDS_InterfFF& aFF=aFFs(i);
aFF.Indices(nF1, nF2);
//
if (!myDS->HasFaceInfo(nF1) || !myDS->HasFaceInfo(nF2) ) {
continue;
}
//
const BOPDS_FaceInfo& aFI1=myDS->FaceInfo(nF1);
const BOPDS_FaceInfo& aFI2=myDS->FaceInfo(nF2);
//
const TopoDS_Shape& aF1=myDS->Shape(nF1);
const TopoDS_Shape& aF2=myDS->Shape(nF2);
//
bFlag=HasPaveBlocksOnIn(aFI1, aFI2);
bFlag=bFlag && (mySplits.IsBound(aF1) && mySplits.IsBound(aF2));
//
if (bFlag) {
for (k=0; k<2; ++k) {
const TopoDS_Shape& aF=(!k) ? aF1 : aF2;
const BOPCol_ListOfShape& aLF=mySplits.Find(aF);
//
aItF.Initialize(aLF);
for (; aItF.More(); aItF.Next()) {
const TopoDS_Shape& aFx=aItF.Value();
//
if (aMFence.Add(aFx)) {
BOPTools_Set aSTx;
//
aSTx.Add(aFx, TopAbs_EDGE);
//
if (!aIDMSS.Contains(aSTx)) {
BOPAlgo_VectorOfShape& aVS=aVVS.Append1();
aVS.Append(aFx);
//
j=aVVS.Extent()-1;
aIDMSS.Add (aSTx, j);
}
else {
j=aIDMSS.ChangeFromKey(aSTx);
BOPAlgo_VectorOfShape& aVS=aVVS(j);
aVS.Append(aFx);
}
}
}
// Sort the indices
std::sort(aFIVec.begin(), aFIVec.end());
// Data map of set of edges with all faces having this set
NCollection_IndexedDataMap<BOPTools_Set,
BOPCol_ListOfShape,
BOPTools_SetMapHasher> anESetFaces(1, aAllocator);
// Map of planar bounded faces. If such faces have the same Edge set
// they are considered Same domain, without additional check.
BOPCol_MapOfShape aMFPlanar(1, aAllocator);
Standard_Integer aNbF = aFIVec.Extent();
for (Standard_Integer i = 0; i < aNbF; ++i)
{
const Standard_Integer nF = aFIVec(i);
const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(nF);
const TopoDS_Shape& aF = aSI.Shape();
Standard_Boolean bCheckPlanar = Standard_False;
{
// At this stage, context should contain adaptor for all intersected faces,
// so getting a type of the underlying surface should be done at no cost.
if (myContext->SurfaceAdaptor(TopoDS::Face(aF)).GetType() == GeomAbs_Plane)
{
// Check bounding box of the face - it should not be open in any side
const Bnd_Box& aBox = aSI.Box();
bCheckPlanar = !(aBox.IsOpenXmin() || aBox.IsOpenXmax() ||
aBox.IsOpenYmin() || aBox.IsOpenYmax() ||
aBox.IsOpenZmin() || aBox.IsOpenZmax());
}
}// if (bFlag) {
else {// if (!bFlag)
BOPTools_Set aST1, aST2;
//
aST1.Add(aF1, TopAbs_EDGE);
aST2.Add(aF2, TopAbs_EDGE);
//
if (aST1.IsEqual(aST2)) {
if (!aIDMSS.Contains(aST1)) {
BOPAlgo_VectorOfShape& aVS=aVVS.Append1();
if (aMFence.Add(aF1)) {
aVS.Append(aF1);
}
if (aMFence.Add(aF2)) {
aVS.Append(aF2);
}
//
k=aVVS.Extent()-1;
aIDMSS.Add (aST1, k);
}
else {
k=aIDMSS.ChangeFromKey(aST1);
BOPAlgo_VectorOfShape& aVS=aVVS(k);
if (aMFence.Add(aF1)) {
aVS.Append(aF1);
}
if (aMFence.Add(aF2)) {
aVS.Append(aF2);
}
}
}//if (aST1.IsEqual(aST2)) {
}// else {// if (!bFlag)
//
}// for (i=0; i<aNbFFs; ++i) {
//
aIDMSS.Clear();
//
Standard_Boolean bFlagSD;
Standard_Integer aNbVPSB, aNbVVS, aNbF, aNbF1;
BOPAlgo_VectorOfPairOfShapeBoolean aVPSB;
//
aNbVVS=aVVS.Extent();
for (i=0; i<aNbVVS; ++i) {
const BOPAlgo_VectorOfShape& aVS=aVVS(i);
aNbF=aVS.Extent();
if (aNbF<2) {
continue;
}
//
aNbF1=aNbF-1;
for (j=0; j<aNbF1; ++j) {
const TopoDS_Shape& aFj=aVS(j);
for (k=j+1; k<aNbF; ++k) {
const TopoDS_Shape& aFk=aVS(k);
BOPAlgo_PairOfShapeBoolean& aPSB=aVPSB.Append1();
aPSB.Shape1()=aFj;
aPSB.Shape2()=aFk;
const BOPCol_ListOfShape* pLFSp = myImages.Seek(aF);
if (pLFSp)
{
BOPCol_ListIteratorOfListOfShape aItLF(*pLFSp);
for (; aItLF.More(); aItLF.Next())
{
AddEdgeSet(aItLF.Value(), anESetFaces, aAllocator);
if (bCheckPlanar)
aMFPlanar.Add(aItLF.Value());
}
}
else
{
AddEdgeSet(aF, anESetFaces, aAllocator);
if (bCheckPlanar)
aMFPlanar.Add(aF);
}
}
// Store pairs of faces with equal set of edges to check if they are really Same Domain
BOPAlgo_VectorOfPairOfShapeBoolean aVPSB;
// Back and forth map of SD faces to make the blocks
BOPCol_IndexedDataMapOfShapeListOfShape aDMSLS(1, aAllocator);
Standard_Integer aNbSets = anESetFaces.Extent();
for (Standard_Integer i = 1; i <= aNbSets; ++i)
{
const BOPCol_ListOfShape& aLF = anESetFaces(i);
if (aLF.Extent() < 2)
continue;
// All possible pairs from <aLF> should be checked
BOPCol_ListIteratorOfListOfShape aIt1(aLF);
for (; aIt1.More(); aIt1.Next())
{
const TopoDS_Shape& aF1 = aIt1.Value();
Standard_Boolean bCheckPlanar = aMFPlanar.Contains(aF1);
BOPCol_ListIteratorOfListOfShape aIt2 = aIt1;
for (aIt2.Next(); aIt2.More(); aIt2.Next())
{
const TopoDS_Shape& aF2 = aIt2.Value();
if (bCheckPlanar && aMFPlanar.Contains(aF2))
{
// Consider planar bounded faces as Same Domain without additional check
BOPAlgo_Tools::FillMap<TopoDS_Shape, TopTools_ShapeMapHasher>(aF1, aF2, aDMSLS, aAllocator);
continue;
}
// Add pair for analysis
BOPAlgo_PairOfShapeBoolean& aPSB = aVPSB.Append1();
aPSB.Shape1() = aF1;
aPSB.Shape2() = aF2;
aPSB.SetFuzzyValue(myFuzzyValue);
aPSB.SetProgressIndicator(myProgressIndicator);
}
}
}
//================================================================
// Perform analysis
BOPAlgo_BuilderSDFaceCnt::Perform(myRunParallel, aVPSB, myContext);
//================================================================
aAllocator=
NCollection_BaseAllocator::CommonBaseAllocator();
BOPCol_IndexedDataMapOfShapeListOfShape aDMSLS(100, aAllocator);
NCollection_List<BOPCol_ListOfShape> aMBlocks(aAllocator);
//
aNbVPSB=aVPSB.Extent();
for (i=0; i<aNbVPSB; ++i) {
BOPAlgo_PairOfShapeBoolean& aPSB=aVPSB(i);
bFlagSD=aPSB.Flag();
if (bFlagSD) {
const TopoDS_Shape& aFj=aPSB.Shape1();
const TopoDS_Shape& aFk=aPSB.Shape2();
BOPAlgo_Tools::FillMap<TopoDS_Shape, TopTools_ShapeMapHasher>(aFj, aFk, aDMSLS, aAllocator);
}
// Fill map with SD faces to make the blocks
Standard_Integer aNbPairs = aVPSB.Extent();
for (Standard_Integer i = 0; i < aNbPairs; ++i)
{
BOPAlgo_PairOfShapeBoolean& aPSB = aVPSB(i);
if (aPSB.Flag())
BOPAlgo_Tools::FillMap<TopoDS_Shape, TopTools_ShapeMapHasher>
(aPSB.Shape1(), aPSB.Shape2(), aDMSLS, aAllocator);
}
aVPSB.Clear();
//
// 2. Make blocks
BOPAlgo_Tools::MakeBlocks<TopoDS_Shape, TopTools_ShapeMapHasher>(aDMSLS, aMBlocks, aAllocator);
//
// 3. Fill same domain faces map -> aMSDF
// Make blocks of SD faces using the back and forth map
BOPAlgo_Tools::MakeBlocks<TopoDS_Shape, TopTools_ShapeMapHasher>
(aDMSLS, aMBlocks, aAllocator);
// Fill same domain faces map
NCollection_List<BOPCol_ListOfShape>::Iterator aItB(aMBlocks);
for (; aItB.More(); aItB.Next()) {
for (; aItB.More(); aItB.Next())
{
const BOPCol_ListOfShape& aLSD = aItB.Value();
//
const TopoDS_Shape& aFSD1=aLSD.First();
aItF.Initialize(aLSD);
for (; aItF.More(); aItF.Next()) {
const TopoDS_Shape& aFSD=aItF.Value();
myShapesSD.Bind(aFSD, aFSD1);
//
// If the face has no splits but are SD face,
// it is considered as splitted face
if (!mySplits.IsBound(aFSD)) {
BOPCol_ListOfShape aLS;
aLS.Append(aFSD);
mySplits.Bind(aFSD, aLS);
// If the group contains some original faces, the one with minimal
// index in the DS will be chosen as the SD for the whole group.
// If there are no original faces in the group, the first face from
// the group will be used as the SD face.
// Such SD face will be representative of the whole group in the result.
TopoDS_Face* pFSD = NULL;
Standard_Integer nFMin = ::IntegerLast();
BOPCol_ListIteratorOfListOfShape aItLF(aLSD);
for (; aItLF.More(); aItLF.Next())
{
const TopoDS_Shape& aF = aItLF.Value();
// Check the index of the face in DS
const Standard_Integer nF = myDS->Index(aF);
if (nF >= 0)
{
// The fact that the face is found in the DS, means that
// the face has not been change, and thus it is original one.
//
// Such face does not have any splits, but have an SD face.
// Consider it being split.
myImages.Bound(aF, BOPCol_ListOfShape())->Append(aF);
// For the SD face chose the one with minimal index
if (nF < nFMin)
{
nFMin = nF;
pFSD = (TopoDS_Face*)&aF;
}
}
}
if (!pFSD)
{
// No original faces in the group, take the first one
pFSD = (TopoDS_Face*)&aLSD.First();
}
// Save all SD connections
aItLF.Initialize(aLSD);
for (; aItLF.More(); aItLF.Next())
{
const TopoDS_Shape& aF = aItLF.Value();
myShapesSD.Bind(aF, *pFSD);
}
}
// Update the map of images with SD faces and
// fill the map of origins.
Standard_Integer aNbS = myDS->NbSourceShapes();
for (Standard_Integer i = 0; i < aNbS; ++i)
{
const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(i);
if (aSI.ShapeType() != TopAbs_FACE)
continue;
const TopoDS_Shape& aF = aSI.Shape();
BOPCol_ListOfShape* pLFIm = myImages.ChangeSeek(aF);
if (!pLFIm)
continue;
BOPCol_ListIteratorOfListOfShape aItLFIm(*pLFIm);
for (; aItLFIm.More(); aItLFIm.Next())
{
TopoDS_Shape& aFIm = aItLFIm.ChangeValue();
const TopoDS_Shape* pFSD = myShapesSD.Seek(aFIm);
if (pFSD)
// Update image with SD face
aFIm = *pFSD;
// Fill the map of origins
BOPCol_ListOfShape* pLFOr = myOrigins.ChangeSeek(aFIm);
if (!pLFOr)
pLFOr = myOrigins.Bound(aFIm, BOPCol_ListOfShape());
pLFOr->Append(aF);
}
}
aMBlocks.Clear();
aDMSLS.Clear();
}
@@ -635,138 +752,157 @@ void BOPAlgo_Builder::FillSameDomainFaces()
// function: FillImagesFaces1
// purpose:
//=======================================================================
void BOPAlgo_Builder::FillImagesFaces1()
void BOPAlgo_Builder::FillInternalVertices()
{
Standard_Integer i, aNbS, iSense, nVx, aNbVFI, iFlag;
TopoDS_Face aFSD;
TopoDS_Vertex aVx;
BRep_Builder aBB;
BOPCol_ListOfInteger aLIAV;
BOPCol_ListOfShape aLFIm;
BOPCol_ListIteratorOfListOfInteger aItV;
BOPCol_ListIteratorOfListOfShape aItLS, aItF;
// Vector of pairs of Vertex/Face for classification of the vertices
// relatively faces, and adding them as internal into the faces
BOPAlgo_VectorOfVFI aVVFI;
//
aNbS=myDS->NbSourceShapes();
for (i=0; i<aNbS; ++i) {
const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
if (aSI.ShapeType()!=TopAbs_FACE) {
Standard_Integer aNbS = myDS->NbSourceShapes();
for (Standard_Integer i = 0; i < aNbS; ++i)
{
const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(i);
if (aSI.ShapeType() != TopAbs_FACE)
continue;
}
//
const TopoDS_Face& aF=(*(TopoDS_Face*)(&aSI.Shape()));
//
if (!mySplits.IsBound(aF)) {
const TopoDS_Shape& aF = aSI.Shape();
const BOPCol_ListOfShape* pLFIm = myImages.Seek(aF);
if (!pLFIm)
continue;
}
//
// 1.
aLIAV.Clear();
// Find vertices to add as internal into the splits
BOPCol_ListOfInteger aLIAV;
myDS->AloneVertices(i, aLIAV);
aLFIm.Clear();
//
const BOPCol_ListOfShape& aLSp=mySplits.Find(aF);
aItLS.Initialize(aLSp);
for (; aItLS.More(); aItLS.Next()) {
const TopoDS_Face& aFSp=(*(TopoDS_Face*)(&aItLS.Value()));
if (!myShapesSD.IsBound(aFSp)) {
aLFIm.Append(aFSp);
}
else {
aFSD=(*(TopoDS_Face*)(&myShapesSD.Find(aFSp)));
iSense=BOPTools_AlgoTools::Sense(aFSp, aFSD, myContext);
if (iSense<0) {
aFSD.Reverse();
}
aLFIm.Append(aFSD);
}
}
//
//FillInternalVertices(aLFIm, aLIAV);
//
myImages.Bind(aF, aLFIm);
//
// 2. fill myOrigins
aItLS.Initialize(aLFIm);
for (; aItLS.More(); aItLS.Next()) {
const TopoDS_Face& aFSp=(*(TopoDS_Face*)(&aItLS.Value()));
//
BOPCol_ListOfShape* pLOr = myOrigins.ChangeSeek(aFSp);
if (!pLOr) {
pLOr = myOrigins.Bound(aFSp, BOPCol_ListOfShape());
}
pLOr->Append(aF);
}
//
// 3.
aItV.Initialize(aLIAV);
for (; aItV.More(); aItV.Next()) {
nVx=aItV.Value();
aVx=(*(TopoDS_Vertex*)(&myDS->Shape(nVx)));
aVx.Orientation(TopAbs_INTERNAL);
//
aItF.Initialize(aLFIm);
for (; aItF.More(); aItF.Next()) {
TopoDS_Face& aFy=(*(TopoDS_Face*)(&aItF.Value()));
//
BOPAlgo_VFI& aVFI=aVVFI.Append1();
aVFI.SetVertex(aVx);
aVFI.SetFace(aFy);
// Add vertices and faces for classification
BOPCol_ListIteratorOfListOfInteger aItLV(aLIAV);
for (; aItLV.More(); aItLV.Next())
{
TopoDS_Vertex aV = TopoDS::Vertex(myDS->Shape(aItLV.Value()));
aV.Orientation(TopAbs_INTERNAL);
BOPCol_ListIteratorOfListOfShape aItLFIm(*pLFIm);
for (; aItLFIm.More(); aItLFIm.Next())
{
const TopoDS_Face& aFIm = TopoDS::Face(aItLFIm.Value());
// Make the pair
BOPAlgo_VFI& aVFI = aVVFI.Append1();
aVFI.SetVertex(aV);
aVFI.SetFace(aFIm);
aVFI.SetFuzzyValue(myFuzzyValue);
aVFI.SetProgressIndicator(myProgressIndicator);
}
}
}// for (i=0; i<aNbS; ++i) {
//
// 4.
aNbVFI=aVVFI.Extent();
}
// Perform classification
//================================================================
BOPAlgo_VFICnt::Perform(myRunParallel, aVVFI, myContext);
//================================================================
//
for (i=0; i < aNbVFI; ++i) {
BOPAlgo_VFI& aVFI=aVVFI(i);
//
iFlag=aVFI.Flag();
if (!iFlag) {
TopoDS_Vertex& aVertex=aVFI.Vertex();
TopoDS_Face& aFy=aVFI.Face();
aBB.Add(aFy, aVertex);
Standard_Integer aNbVFI = aVVFI.Length();
for (Standard_Integer i = 0; i < aNbVFI; ++i)
{
BOPAlgo_VFI& aVFI = aVVFI(i);
if (aVFI.IsInternal())
{
TopoDS_Vertex& aV = aVFI.Vertex();
TopoDS_Face& aF = aVFI.Face();
BRep_Builder().Add(aF, aV);
}
}
}
//=======================================================================
//function :HasPaveBlocksOnIn
//purpose :
//function : BuildDraftFace
//purpose : Build draft faces, updating the bounding edges,
// according to the information stored into the <theImages> map
//=======================================================================
Standard_Boolean HasPaveBlocksOnIn(const BOPDS_FaceInfo& aFI1,
const BOPDS_FaceInfo& aFI2)
TopoDS_Face BuildDraftFace(const TopoDS_Face& theFace,
const BOPCol_DataMapOfShapeListOfShape& theImages,
Handle(IntTools_Context)& theCtx)
{
Standard_Boolean bRet;
Standard_Integer i, aNbPB;
//
bRet=Standard_False;
const BOPDS_IndexedMapOfPaveBlock& aMPBOn1 = aFI1.PaveBlocksOn();
const BOPDS_IndexedMapOfPaveBlock& aMPBIn1 = aFI1.PaveBlocksIn();
//
const BOPDS_IndexedMapOfPaveBlock& aMPBOn2 = aFI2.PaveBlocksOn();
aNbPB = aMPBOn2.Extent();
for (i = 1; i <= aNbPB; ++i) {
const Handle(BOPDS_PaveBlock)& aPB = aMPBOn2(i);
bRet = aMPBOn1.Contains(aPB) || aMPBIn1.Contains(aPB);
if (bRet) {
return bRet;
BRep_Builder aBB;
// Take the information from the original face
TopLoc_Location aLoc;
const Handle(Geom_Surface)& aS = BRep_Tool::Surface(theFace, aLoc);
const Standard_Real aTol = BRep_Tool::Tolerance(theFace);
// Make the new face, without any wires
TopoDS_Face aDraftFace;
aBB.MakeFace(aDraftFace, aS, aLoc, aTol);
// Update wires of the original face and add them to draft face
TopoDS_Iterator aItW(theFace.Oriented(TopAbs_FORWARD));
for (; aItW.More(); aItW.Next())
{
const TopoDS_Shape& aW = aItW.Value();
if (aW.ShapeType() != TopAbs_WIRE)
continue;
// Rebuild wire using images of edges
TopoDS_Iterator aItE(aW.Oriented(TopAbs_FORWARD));
if (!aItE.More())
continue;
TopoDS_Wire aNewWire;
aBB.MakeWire(aNewWire);
for (; aItE.More(); aItE.Next())
{
const TopoDS_Edge& aE = TopoDS::Edge(aItE.Value());
TopAbs_Orientation anOriE = aE.Orientation();
if (anOriE == TopAbs_INTERNAL)
{
// The internal edges could split the original face on halves.
// Thus, use the BuilderFace algorithm to build the new face.
TopoDS_Face aNull;
return aNull;
}
const BOPCol_ListOfShape* pLEIm = theImages.Seek(aE);
if (!pLEIm)
{
aBB.Add(aNewWire, aE);
continue;
}
// Check if the original edge is degenerated
Standard_Boolean bIsDegenerated = BRep_Tool::Degenerated(aE);
// Check if the original edge is closed on the face
Standard_Boolean bIsClosed = BRep_Tool::IsClosed(aE, theFace);
BOPCol_ListIteratorOfListOfShape aItLEIm(*pLEIm);
for (; aItLEIm.More(); aItLEIm.Next())
{
TopoDS_Edge& aSp = TopoDS::Edge(aItLEIm.Value());
aSp.Orientation(anOriE);
if (bIsDegenerated)
{
aBB.Add(aNewWire, aSp);
continue;
}
// Check closeness of the split edge and if it is not
// make the second PCurve
if (bIsClosed && !BRep_Tool::IsClosed(aSp, theFace))
BOPTools_AlgoTools3D::DoSplitSEAMOnFace(aSp, theFace);
// Check if the split should be reversed
if (BOPTools_AlgoTools::IsSplitToReverse(aSp, aE, theCtx))
aSp.Reverse();
aBB.Add(aNewWire, aSp);
}
}
aNewWire.Orientation(aW.Orientation());
aNewWire.Closed(BRep_Tool::IsClosed(aNewWire));
aBB.Add(aDraftFace, aNewWire);
}
//
const BOPDS_IndexedMapOfPaveBlock& aMPBIn2 = aFI2.PaveBlocksIn();
aNbPB = aMPBIn2.Extent();
for (i = 1; i <= aNbPB; ++i) {
const Handle(BOPDS_PaveBlock)& aPB = aMPBIn2(i);
bRet = aMPBOn1.Contains(aPB) || aMPBIn1.Contains(aPB);
if (bRet) {
return bRet;
}
}
return bRet;
if (theFace.Orientation() == TopAbs_REVERSED)
aDraftFace.Reverse();
return aDraftFace;
}

View File

@@ -19,8 +19,6 @@
//
#include <Precision.hxx>
//
#include <NCollection_UBTreeFiller.hxx>
//
#include <Bnd_Box.hxx>
#include <TopAbs_State.hxx>
//
@@ -39,13 +37,14 @@
#include <TopExp_Explorer.hxx>
//
#include <BRep_Builder.hxx>
#include <BRepTools.hxx>
#include <BRepClass3d_SolidClassifier.hxx>
#include <BRepBndLib.hxx>
//
#include <BOPAlgo_Tools.hxx>
#include <BOPAlgo_BuilderSolid.hxx>
//
#include <BOPCol_IndexedMapOfShape.hxx>
#include <BOPCol_MapOfShape.hxx>
#include <BOPCol_IndexedDataMapOfShapeListOfShape.hxx>
#include <BOPCol_IndexedDataMapOfShapeShape.hxx>
#include <BOPCol_ListOfShape.hxx>
#include <BOPCol_BoxBndTree.hxx>
#include <BOPCol_ListOfInteger.hxx>
@@ -63,437 +62,17 @@
#include <BOPTools_MapOfSet.hxx>
#include <BOPTools_Set.hxx>
//
#include <BOPAlgo_BuilderSolid.hxx>
#include <BOPAlgo_Tools.hxx>
#include <NCollection_Array1.hxx>
#include <NCollection_IncAllocator.hxx>
#include <algorithm>
#include <BOPAlgo_Algo.hxx>
static
void OwnInternalShapes(const TopoDS_Shape& ,
BOPCol_IndexedMapOfShape& );
static
void TreatCompound(const TopoDS_Shape& theS,
BOPCol_MapOfShape& aMFence,
BOPCol_ListOfShape& theLS);
//=======================================================================
// BOPAlgo_BuilderSolid
//
typedef BOPCol_NCVector
<BOPAlgo_BuilderSolid> BOPAlgo_VectorOfBuilderSolid;
//
typedef BOPCol_Functor
<BOPAlgo_BuilderSolid,
BOPAlgo_VectorOfBuilderSolid> BOPAlgo_BuilderSolidFunctor;
//
typedef BOPCol_Cnt
<BOPAlgo_BuilderSolidFunctor,
BOPAlgo_VectorOfBuilderSolid> BOPAlgo_BuilderSolidCnt;
//
//=======================================================================
// class: BOPAlgo_ShapeBox
//
//=======================================================================
//class : BOPAlgo_ShapeBox
//purpose : Auxiliary class
//=======================================================================
class BOPAlgo_ShapeBox {
public:
BOPAlgo_ShapeBox() {
};
//
~BOPAlgo_ShapeBox() {
};
//
void SetShape(const TopoDS_Shape& aS) {
myShape=aS;
};
//
const TopoDS_Shape& Shape()const {
return myShape;
};
//
void SetBox(const Bnd_Box& aBox) {
myBox=aBox;
};
//
const Bnd_Box& Box()const {
return myBox;
};
//
protected:
TopoDS_Shape myShape;
Bnd_Box myBox;
};
//
typedef BOPCol_NCVector<BOPAlgo_ShapeBox> BOPAlgo_VectorOfShapeBox;
//
//=======================================================================
// class: BOPAlgo_FillIn3DParts
//
//=======================================================================
//class : BOPAlgo_FillIn3DParts
//purpose :
//=======================================================================
class BOPAlgo_FillIn3DParts : public BOPAlgo_Algo {
public:
DEFINE_STANDARD_ALLOC
BOPAlgo_FillIn3DParts(){
myHasImage=Standard_False;
myBBTree=NULL;
myVSB=NULL;
};
//
virtual ~BOPAlgo_FillIn3DParts(){
};
//
void SetSolid(const TopoDS_Solid& aS) {
mySolid=aS;
};
//
const TopoDS_Solid& Solid()const {
return mySolid;
};
//
void SetDraftSolid(const TopoDS_Solid& aS) {
myDraftSolid=aS;
};
//
const TopoDS_Solid& DraftSolid()const {
return myDraftSolid;
};
//
void SetHasImage(const Standard_Boolean bFlag) {
myHasImage=bFlag;
};
//
Standard_Boolean HasImage()const {
return myHasImage;
};
//
void SetBoxS(const Bnd_Box& aBox) {
myBoxS=aBox;
};
//
const Bnd_Box& BoxS()const {
return myBoxS;
};
//
void SetLIF(const BOPCol_ListOfShape& aLIF) {
myLIF=aLIF;
};
//
const BOPCol_ListOfShape& LIF()const {
return myLIF;
};
//
void SetBBTree(const BOPCol_BoxBndTree& aBBTree) {
myBBTree=(BOPCol_BoxBndTree*)&aBBTree;
};
//
void SetVSB(const BOPAlgo_VectorOfShapeBox& aVSB) {
myVSB=(BOPAlgo_VectorOfShapeBox*)&aVSB;
};
//
//
void SetContext(const Handle(IntTools_Context)& aContext) {
myContext=aContext;
}
//
const Handle(IntTools_Context)& Context()const {
return myContext;
}
//
virtual void Perform();
//
//
const BOPCol_ListOfShape& LFIN()const {
return myLFIN;
};
protected:
void MapEdgesAndFaces
(const TopoDS_Shape& ,
BOPCol_IndexedDataMapOfShapeListOfShape& ,
const Handle(NCollection_BaseAllocator)& );
void MakeConnexityBlock
(const BOPCol_ListOfShape& ,
const BOPCol_IndexedMapOfShape& ,
const BOPCol_MapOfShape& ,
const BOPCol_IndexedDataMapOfShapeListOfShape& ,
BOPCol_ListOfShape& ,
const Handle(NCollection_BaseAllocator)& );
//
protected:
TopoDS_Solid mySolid;
TopoDS_Solid myDraftSolid;
Standard_Boolean myHasImage;
Bnd_Box myBoxS;
BOPCol_ListOfShape myLIF;
BOPCol_ListOfShape myLFIN;
//
BOPCol_BoxBndTree* myBBTree;
BOPAlgo_VectorOfShapeBox* myVSB;
//
TopoDS_Iterator myItF;
TopoDS_Iterator myItW;
Handle(IntTools_Context) myContext;
};
//=======================================================================
//function : BOPAlgo_FillIn3DParts::Perform
//purpose :
//=======================================================================
void BOPAlgo_FillIn3DParts::Perform()
{
Handle(NCollection_BaseAllocator) aAlr1;
BOPAlgo_Algo::UserBreak();
//
Standard_Integer aNbFP, k, nFP, iIsIN;
Standard_Real aTolPC;
BOPCol_ListIteratorOfListOfInteger aItLI, aItLI1;
BOPCol_ListIteratorOfListOfShape aItLS;
BOPCol_BoxBndTreeSelector aSelector;
//
aAlr1=
NCollection_BaseAllocator::CommonBaseAllocator();
//
BOPCol_ListOfShape aLFP(aAlr1);
BOPCol_ListOfShape aLCBF(aAlr1);
BOPCol_MapOfShape aMFDone(100, aAlr1);
BOPCol_IndexedMapOfShape aME(100, aAlr1);
BOPCol_IndexedMapOfShape aMF(100, aAlr1);
BOPCol_IndexedDataMapOfShapeListOfShape aMEFP(100, aAlr1);
BOPCol_IndexedDataMapOfShapeListOfShape aMEF(100, aAlr1);
//
aTolPC=Precision::Confusion();
myLFIN.Clear();
BOPAlgo_VectorOfShapeBox& aVSB=*myVSB;
//
// 1. aMEF - EF map for myDraftSolid
BOPTools::MapShapesAndAncestors(myDraftSolid,
TopAbs_EDGE,
TopAbs_FACE,
aMEF);
//
// 2. Faces from myDraftSolid and its own internal faces => aMF
BOPTools::MapShapes(myDraftSolid, TopAbs_FACE, aMF);
aItLS.Initialize(myLIF);
for (; aItLS.More(); aItLS.Next()) {
const TopoDS_Shape& aFI=aItLS.Value();
aMF.Add(aFI);
}
// aME - Edges from DraftSolid [i.e. edges to stop]
BOPTools::MapShapes(myDraftSolid, TopAbs_EDGE, aME);
//
// 3. Select boxes of faces that are not out of aBoxS
aSelector.Clear();
aSelector.SetBox(myBoxS);
//
aNbFP=myBBTree->Select(aSelector);
const BOPCol_ListOfInteger& aLIFPx=aSelector.Indices();
//
// 4. aIVec, aLIFP - faces to process
BOPCol_ListOfInteger aLIFP(aAlr1);
BOPCol_NCVector<Standard_Integer> aIVec(256, aAlr1);
//
k=0;
aItLI.Initialize(aLIFPx);
for (; aItLI.More(); aItLI.Next()) {
nFP=aItLI.Value();
const TopoDS_Shape& aFP=aVSB(nFP).Shape();
if (!aMF.Contains(aFP)) {
MapEdgesAndFaces(aFP, aMEFP, aAlr1);
aLIFP.Append(nFP);
aIVec.Append1()=nFP;
++k;
}
}
aNbFP=k;
//
// sort indices
std::sort(aIVec.begin(), aIVec.end());
//
// 5. Collect faces that are IN mySolid [ myLFIN ]
for (k=0; k<aNbFP; ++k) {
nFP = aIVec(k);
const BOPAlgo_ShapeBox& aSBF=aVSB(nFP);
const TopoDS_Face& aFP=(*(TopoDS_Face*)&aSBF.Shape());
//
if (!aMFDone.Add(aFP)) {
continue;
}
//
iIsIN=BOPTools_AlgoTools::IsInternalFace
(aFP, myDraftSolid, aMEF, aTolPC, myContext);
//
aLFP.Clear();
aLFP.Append(aFP);
//
aItLI1.Initialize(aLIFP);
for (; aItLI1.More(); aItLI1.Next()) {
const TopoDS_Shape& aFx=aVSB(aItLI1.Value()).Shape();
if (!aMFDone.Contains(aFx)) {
aLFP.Append(aFx);
}
}
//
aLCBF.Clear();
//
MakeConnexityBlock(aLFP, aME, aMFDone, aMEFP, aLCBF, aAlr1);
//
aItLS.Initialize(aLCBF);
for (; aItLS.More(); aItLS.Next()) {
const TopoDS_Shape& aFx=aItLS.Value();
aMFDone.Add(aFx);
if (iIsIN) {
myLFIN.Append(aFx);
}
}
} // for (k=0; k<aNbFP; ++k) {
}
//=======================================================================
// function: MapEdgesAndFaces
// purpose:
//=======================================================================
void BOPAlgo_FillIn3DParts::MapEdgesAndFaces
(const TopoDS_Shape& aF,
BOPCol_IndexedDataMapOfShapeListOfShape& aMEF,
const Handle(NCollection_BaseAllocator)& theAllocator)
{
myItF.Initialize(aF);
for (; myItF.More(); myItF.Next()) {
const TopoDS_Shape& aW=myItF.Value();
if (aW.ShapeType()!=TopAbs_WIRE) {
continue;
}
//
myItW.Initialize(aW);
for (; myItW.More(); myItW.Next()) {
const TopoDS_Shape& aE=myItW.Value();
//
if (aMEF.Contains(aE)) {
BOPCol_ListOfShape& aLF=aMEF.ChangeFromKey(aE);
aLF.Append(aF);
}
else {
BOPCol_ListOfShape aLS(theAllocator);
//
aLS.Append(aF);
aMEF.Add(aE, aLS);
}
}
}
}
//=======================================================================
// function: MakeConnexityBlock
// purpose:
//=======================================================================
void BOPAlgo_FillIn3DParts::MakeConnexityBlock
(const BOPCol_ListOfShape& theLFIn,
const BOPCol_IndexedMapOfShape& theMEAvoid,
const BOPCol_MapOfShape& aMFDone,
const BOPCol_IndexedDataMapOfShapeListOfShape& aMEF,
BOPCol_ListOfShape& theLCB,
const Handle(NCollection_BaseAllocator)& theAlr)
{
Standard_Integer aNbF, aNbAdd1, aNbAdd, i;
BOPCol_ListIteratorOfListOfShape aIt;
//
BOPCol_IndexedMapOfShape aMCB(100, theAlr);
BOPCol_IndexedMapOfShape aMAdd(100, theAlr);
BOPCol_IndexedMapOfShape aMAdd1(100, theAlr);
//
aNbF=theLFIn.Extent();
//
// 2. aMCB
const TopoDS_Shape& aF1=theLFIn.First();
aMAdd.Add(aF1);
//
for(;;) {
aMAdd1.Clear();
aNbAdd = aMAdd.Extent();
for (i=1; i<=aNbAdd; ++i) {
const TopoDS_Shape& aF=aMAdd(i);
//
myItF.Initialize(aF);
for (; myItF.More(); myItF.Next()) {
const TopoDS_Shape& aW=myItF.Value();
if (aW.ShapeType()!=TopAbs_WIRE) {
continue;
}
//
myItW.Initialize(aW);
for (; myItW.More(); myItW.Next()) {
const TopoDS_Shape& aE=myItW.Value();
if (theMEAvoid.Contains(aE)){
continue;
}
//
const BOPCol_ListOfShape& aLF=aMEF.FindFromKey(aE);
aIt.Initialize(aLF);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aFx=aIt.Value();
if (aFx.IsSame(aF)) {
continue;
}
if (aMCB.Contains(aFx)) {
continue;
}
if (aMFDone.Contains(aFx)) {
continue;
}
aMAdd1.Add(aFx);
}
}// for (; myItW.More(); myItW.Next()) {
}// for (; myItF.More(); myItF.Next()) {
aMCB.Add(aF);
}// for (i=1; i<=aNbAdd; ++i) {
//
aNbAdd1=aMAdd1.Extent();
if (!aNbAdd1) {
break;
}
//
aMAdd.Clear();
for (i=1; i<=aNbAdd1; ++i) {
const TopoDS_Shape& aFAdd=aMAdd1(i);
aMAdd.Add(aFAdd);
}
//
}//while(1) {
//
aNbF=aMCB.Extent();
for (i=1; i<=aNbF; ++i) {
const TopoDS_Shape& aF=aMCB(i);
theLCB.Append(aF);
}
}
//
typedef BOPCol_NCVector<BOPAlgo_FillIn3DParts> \
BOPAlgo_VectorOfFillIn3DParts;
//
typedef BOPCol_ContextFunctor
<BOPAlgo_FillIn3DParts,
BOPAlgo_VectorOfFillIn3DParts,
Handle(IntTools_Context),
IntTools_Context> BOPCol_FillIn3DPartsFunctor;
//
typedef BOPCol_ContextCnt
<BOPCol_FillIn3DPartsFunctor,
BOPAlgo_VectorOfFillIn3DParts,
Handle(IntTools_Context)> BOPAlgo_FillIn3DPartsCnt;
//
//=======================================================================
// class: BOPAlgo_Builder
//
//=======================================================================
//function : FillImagesSolids
//purpose :
@@ -540,156 +119,125 @@ void BOPAlgo_Builder::FillIn3DParts
BOPCol_DataMapOfShapeShape& theDraftSolids,
const BOPCol_BaseAllocator& )
{
Standard_Boolean bHasImage;
Standard_Integer i, k, aNbS, aNbLIF, aNbFIN, aNbVSB, aNbVFIP;
Handle(NCollection_BaseAllocator) aAlr0;
TopoDS_Solid aSD;
TopoDS_Iterator aIt;
BRep_Builder aBB;
//
BOPCol_ListIteratorOfListOfInteger aItLI, aItLI1;
BOPCol_ListIteratorOfListOfShape aItLS;
//
aAlr0=
NCollection_BaseAllocator::CommonBaseAllocator();
//
BOPCol_MapOfShape aMFence(100, aAlr0);
BOPAlgo_VectorOfShapeBox aVSB(256, aAlr0);
//
theDraftSolids.Clear();
//
// 1. aVSB vector Index/FaceBox
aNbS=myDS->NbSourceShapes();
for (i=0; i<aNbS; ++i) {
const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
if (aSI.ShapeType()!=TopAbs_FACE) {
Handle(NCollection_BaseAllocator) anAlloc = new NCollection_IncAllocator;
// Find all faces that are IN solids
// Store boxes of the shapes into a map
BOPCol_DataMapOfShapeBox aShapeBoxMap(1, anAlloc);
// Fence map
BOPCol_MapOfShape aMFence(1, anAlloc);
// Get all faces
BOPCol_ListOfShape aLFaces(anAlloc);
Standard_Integer i, aNbS = myDS->NbSourceShapes();
for (i = 0; i < aNbS; ++i)
{
const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(i);
if (aSI.ShapeType() != TopAbs_FACE)
continue;
}
//
const TopoDS_Shape& aS=aSI.Shape();
//
if (myImages.IsBound(aS)) {
const BOPCol_ListOfShape& aLS=myImages.Find(aS);
aItLS.Initialize(aLS);
for (; aItLS.More(); aItLS.Next()) {
const TopoDS_Shape& aSx=aItLS.Value();
if (!aMFence.Add(aSx)) {
continue;
}
Bnd_Box aBox;
BRepBndLib::Add(aSx, aBox);
aBox.SetGap(aBox.GetGap() + Precision::Confusion());
//
BOPAlgo_ShapeBox& aSB=aVSB.Append1();
aSB.SetShape(aSx);
aSB.SetBox(aBox);
const TopoDS_Shape& aS = aSI.Shape();
const BOPCol_ListOfShape* pLSIm = myImages.Seek(aS);
if (pLSIm)
{
BOPCol_ListIteratorOfListOfShape aItLSIm(*pLSIm);
for (; aItLSIm.More(); aItLSIm.Next())
{
const TopoDS_Shape& aSIm = aItLSIm.Value();
if (aMFence.Add(aSIm))
aLFaces.Append(aSIm);
}
}
else {
const Bnd_Box& aBox=aSI.Box();
//
BOPAlgo_ShapeBox& aSB=aVSB.Append1();
aSB.SetShape(aS);
aSB.SetBox(aBox);
else
{
aLFaces.Append(aS);
aShapeBoxMap.Bind(aS, aSI.Box());
}
}//for (i=0; i<aNbS; ++i) {
aMFence.Clear();
//
// 1.2. Prepare TreeFiller
BOPCol_BoxBndTree aBBTree;
NCollection_UBTreeFiller <Standard_Integer, Bnd_Box>
aTreeFiller(aBBTree);
//
aNbVSB=aVSB.Extent();
for (k=0; k<aNbVSB; ++k) {
const BOPAlgo_ShapeBox& aSBk=aVSB(k);
const Bnd_Box& aBk=aSBk.Box();
//
aTreeFiller.Add(k, aBk);
}
//
// 1.3. Shake TreeFiller
aTreeFiller.Fill();
//
//---------------------------------------------
// 2. Solids
BOPAlgo_VectorOfFillIn3DParts aVFIP;
//
for (i=0; i<aNbS; ++i) {
const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
if (aSI.ShapeType()!=TopAbs_SOLID) {
BRep_Builder aBB;
// Get all solids
BOPCol_ListOfShape aLSolids(anAlloc);
// Keep INTERNAL faces of the solids
BOPCol_DataMapOfShapeListOfShape aSolidsIF(1, anAlloc);
// Draft solids
BOPCol_IndexedDataMapOfShapeShape aDraftSolid(1, anAlloc);
for (i = 0; i < aNbS; ++i)
{
BOPDS_ShapeInfo& aSI = myDS->ChangeShapeInfo(i);
if (aSI.ShapeType() != TopAbs_SOLID)
continue;
}
const TopoDS_Shape& aS = aSI.Shape();
const TopoDS_Solid& aSolid = (*(TopoDS_Solid*)(&aS));
//
const TopoDS_Shape& aS=aSI.Shape();
const TopoDS_Solid& aSolid=(*(TopoDS_Solid*)(&aS));
//
// 2.0 Flag bHasImage
bHasImage=Standard_False;
aIt.Initialize(aS);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aShell=aIt.Value();
bHasImage=myImages.IsBound(aShell);
if (bHasImage){
break;
}
}
//
// 2.1 Bounding box for the solid aS [ aBoxS ]
Bnd_Box aBoxS;
aBoxS=aSI.Box();
//
// 2.2 Build Draft Solid [aSD]
// Bounding box for the solid aS
Bnd_Box& aBoxS = aSI.ChangeBox();
if (aBoxS.IsVoid())
myDS->BuildBndBoxSolid(i, aBoxS, myCheckInverted);
// Build Draft Solid
BOPCol_ListOfShape aLIF;
//
TopoDS_Solid aSD;
aBB.MakeSolid(aSD);
BuildDraftSolid(aSolid, aSD, aLIF);
//
BOPAlgo_FillIn3DParts& aFIP=aVFIP.Append1();
//
aFIP.SetSolid(aSolid);
aFIP.SetDraftSolid(aSD);
aFIP.SetHasImage(bHasImage);
aFIP.SetBoxS(aBoxS);
aFIP.SetLIF(aLIF);
aFIP.SetBBTree(aBBTree);
aFIP.SetVSB(aVSB);
}//for (i=0; i<aNbS; ++i) {
//
aNbVFIP=aVFIP.Extent();
//================================================================
BOPAlgo_FillIn3DPartsCnt::Perform(myRunParallel, aVFIP, myContext);
//================================================================
for (k=0; k<aNbVFIP; ++k) {
BOPAlgo_FillIn3DParts& aFIP=aVFIP(k);
bHasImage=aFIP.HasImage();
const TopoDS_Solid& aSolid=aFIP.Solid();
const TopoDS_Solid& aSDraft =aFIP.DraftSolid();
const BOPCol_ListOfShape& aLFIN=aFIP.LFIN();
const BOPCol_ListOfShape& aLIF=aFIP.LIF();
//
aNbLIF=aLIF.Extent();
//
// Store the results in theInParts, theDraftSolids
BOPCol_ListOfShape aLFINx;
//
aNbFIN=aLFIN.Extent();
if (aNbFIN || aNbLIF) {
aItLS.Initialize(aLFIN);
for (; aItLS.More(); aItLS.Next()) {
const TopoDS_Shape& aFI=aItLS.Value();
aLFINx.Append(aFI);
}
aItLS.Initialize(aLIF);
for (; aItLS.More(); aItLS.Next()) {
const TopoDS_Shape& aFI=aItLS.Value();
aLFINx.Append(aFI);
}
theInParts.Bind(aSolid, aLFINx);
aLSolids.Append(aSD);
aSolidsIF.Bind(aSD, aLIF);
aShapeBoxMap.Bind(aSD, aBoxS);
aDraftSolid.Add(aS, aSD);
}
// Perform classification of the faces
BOPCol_IndexedDataMapOfShapeListOfShape anInParts;
BOPAlgo_Tools::ClassifyFaces(aLFaces, aLSolids, myRunParallel,
myContext, anInParts, aShapeBoxMap, aSolidsIF);
// Analyze the results of classification
Standard_Integer aNbSol = aDraftSolid.Extent();
for (i = 1; i <= aNbSol; ++i)
{
const TopoDS_Solid& aSolid = TopoDS::Solid(aDraftSolid.FindKey(i));
const TopoDS_Solid& aSDraft = TopoDS::Solid(aDraftSolid(i));
const BOPCol_ListOfShape& aLInFaces = anInParts.FindFromKey(aSDraft);
const BOPCol_ListOfShape& aLInternal = aSolidsIF.Find(aSDraft);
Standard_Integer aNbIN = aLInFaces.Extent();
if (!aNbIN)
{
Standard_Boolean bHasImage = Standard_False;
// Check if the shells of the solid have image
for (TopoDS_Iterator it(aSolid); it.More() && !bHasImage; it.Next())
bHasImage = myImages.IsBound(it.Value());
if (!bHasImage)
// no need to split the solid
continue;
}
//
if (aNbFIN || bHasImage) {
theDraftSolids.Bind(aSolid, aSDraft);
theDraftSolids.Bind(aSolid, aSDraft);
Standard_Integer aNbInt = aLInternal.Extent();
if (aNbInt || aNbIN)
{
// Combine the lists
BOPCol_ListOfShape *pLIN = theInParts.Bound(aSolid, BOPCol_ListOfShape());
BOPCol_ListIteratorOfListOfShape aItLS(aLInFaces);
for (; aItLS.More(); aItLS.Next())
pLIN->Append(aItLS.Value());
aItLS.Initialize(aLInternal);
for (; aItLS.More(); aItLS.Next())
pLIN->Append(aItLS.Value());
}
}
}
@@ -706,7 +254,7 @@ void BOPAlgo_Builder::BuildDraftSolid(const TopoDS_Shape& theSolid,
TopAbs_Orientation aOrF, aOrSh, aOrSd;
TopoDS_Iterator aIt1, aIt2;
TopoDS_Shell aShD;
TopoDS_Shape aFSDx, aFx;
TopoDS_Shape aFx;
BRep_Builder aBB;
BOPCol_ListIteratorOfListOfShape aItS;
//
@@ -737,21 +285,20 @@ void BOPAlgo_Builder::BuildDraftSolid(const TopoDS_Shape& theSolid,
aFx=aItS.Value();
//
if (myShapesSD.IsBound(aFx)) {
aFSDx=myShapesSD.Find(aFx);
//
if (aOrF==TopAbs_INTERNAL) {
aFSDx.Orientation(aOrF);
theLIF.Append(aFSDx);
aFx.Orientation(aOrF);
theLIF.Append(aFx);
}
else {
bToReverse=BOPTools_AlgoTools::IsSplitToReverse
(aFSDx, aF, myContext);
(aFx, aF, myContext);
if (bToReverse) {
aFSDx.Reverse();
aFx.Reverse();
}
//
iFlag=1;
aBB.Add(aShD, aFSDx);
aBB.Add(aShD, aFx);
}
}//if (myShapesSD.IsBound(aFx)) {
else {
@@ -784,6 +331,36 @@ void BOPAlgo_Builder::BuildDraftSolid(const TopoDS_Shape& theSolid,
}
} //for (; aIt1.More(); aIt1.Next()) {
}
//=======================================================================
//=======================================================================
//class : BOPAlgo_SplitSolid
//purpose : Auxiliary class to extend the BOPAlgo_BuilderSolid with the solid to split
//=======================================================================
class BOPAlgo_SplitSolid : public BOPAlgo_BuilderSolid
{
public:
//! Sets the solid
void SetSolid(const TopoDS_Solid& theSolid) { mySolid = theSolid; }
//! Returns the solid
const TopoDS_Solid& Solid() const { return mySolid; }
private:
TopoDS_Solid mySolid; //!< Solid to split
};
// Vector of Solid Builders
typedef BOPCol_NCVector<BOPAlgo_SplitSolid> BOPAlgo_VectorOfBuilderSolid;
// Functors to split solids
typedef BOPCol_Functor<BOPAlgo_SplitSolid,
BOPAlgo_VectorOfBuilderSolid> BOPAlgo_BuilderSolidFunctor;
//
typedef BOPCol_Cnt<BOPAlgo_BuilderSolidFunctor,
BOPAlgo_VectorOfBuilderSolid> BOPAlgo_BuilderSolidCnt;
//=======================================================================
//=======================================================================
//function : BuildSplitSolids
//purpose :
@@ -806,7 +383,7 @@ void BOPAlgo_Builder::BuildSplitSolids
BOPTools_MapOfSet aMST(100, aAlr0);
BOPAlgo_VectorOfBuilderSolid aVBS;
//
// 0. Find same domain solids for non-interferred solids
// 0. Find same domain solids for non-interfered solids
aNbS=myDS->NbSourceShapes();
for (i=0; i<aNbS; ++i) {
const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
@@ -830,34 +407,41 @@ void BOPAlgo_Builder::BuildSplitSolids
//
} //for (i=1; i<=aNbS; ++i)
//
// 1. Build solids for interferred source solids
for (i=0; i<aNbS; ++i) {
const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
//
if (aSI.ShapeType()!=TopAbs_SOLID) {
// Build temporary map of solids images to avoid rebuilding
// of the solids without internal faces
BOPCol_IndexedDataMapOfShapeListOfShape aSolidsIm;
// 1. Build solids for interfered source solids
for (i = 0; i < aNbS; ++i) {
const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(i);
if (aSI.ShapeType() != TopAbs_SOLID)
continue;
}
//
const TopoDS_Shape& aS=aSI.Shape();
const TopoDS_Shape& aS = aSI.Shape();
const TopoDS_Solid& aSolid=(*(TopoDS_Solid*)(&aS));
if(!theDraftSolids.IsBound(aS)) {
if (!theDraftSolids.IsBound(aS))
continue;
const TopoDS_Shape& aSD = theDraftSolids.Find(aS);
const BOPCol_ListOfShape* pLFIN = theInParts.Seek(aS);
if (!pLFIN || pLFIN->IsEmpty())
{
aSolidsIm(aSolidsIm.Add(aS, BOPCol_ListOfShape())).Append(aSD);
continue;
}
const TopoDS_Shape& aSD=theDraftSolids.Find(aS);
const BOPCol_ListOfShape& aLFIN=
(theInParts.IsBound(aS)) ? theInParts.Find(aS) : aLSEmpty;
aSFS.Clear();
//
// 1.1 Fill Shell Faces Set
aSFS.Clear();
aExp.Init(aSD, TopAbs_FACE);
for (; aExp.More(); aExp.Next()) {
const TopoDS_Shape& aF=aExp.Current();
const TopoDS_Shape& aF = aExp.Current();
aSFS.Append(aF);
}
//
aIt.Initialize(aLFIN);
// 1.2 Fill internal faces
aIt.Initialize(*pLFIN);
for (; aIt.More(); aIt.Next()) {
TopoDS_Shape aF=aIt.Value();
TopoDS_Shape aF = aIt.Value();
//
aF.Orientation(TopAbs_FORWARD);
aSFS.Append(aF);
@@ -865,8 +449,8 @@ void BOPAlgo_Builder::BuildSplitSolids
aSFS.Append(aF);
}
//
// 1.3 Build new solids
BOPAlgo_BuilderSolid& aBS=aVBS.Append1();
// 1.3 Build new solids
BOPAlgo_SplitSolid& aBS=aVBS.Append1();
aBS.SetSolid(aSolid);
aBS.SetShapes(aSFS);
aBS.SetRunParallel(myRunParallel);
@@ -881,10 +465,19 @@ void BOPAlgo_Builder::BuildSplitSolids
BOPAlgo_BuilderSolidCnt::Perform(myRunParallel, aVBS);
//===================================================
//
for (k=0; k<aNbBS; ++k) {
BOPAlgo_BuilderSolid& aBS=aVBS(k);
const TopoDS_Solid& aS=aBS.Solid();
const BOPCol_ListOfShape& aLSR=aBS.Areas();
for (k = 0; k < aNbBS; ++k)
{
BOPAlgo_SplitSolid& aBS = aVBS(k);
aSolidsIm.Add(aBS.Solid(), aBS.Areas());
myReport->Merge(aBS.GetReport());
}
//
// Add new solids to images map
aNbBS = aSolidsIm.Extent();
for (k = 1; k <= aNbBS; ++k)
{
const TopoDS_Shape& aS = aSolidsIm.FindKey(k);
const BOPCol_ListOfShape& aLSR = aSolidsIm(k);
//
if (!myImages.IsBound(aS)) {
BOPCol_ListOfShape* pLSx = myImages.Bound(aS, BOPCol_ListOfShape());
@@ -951,7 +544,7 @@ void BOPAlgo_Builder::FillInternalShapes()
aIt.Initialize(aArguments);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aS=aIt.Value();
TreatCompound(aS, aMFence, aLSC);
BOPAlgo_Tools::TreatCompound(aS, aMFence, aLSC);
}
aIt.Initialize(aLSC);
for (; aIt.More(); aIt.Next()) {
@@ -1156,29 +749,3 @@ void OwnInternalShapes(const TopoDS_Shape& theS,
}
}
}
//=======================================================================
//function : TreatCompound
//purpose :
//=======================================================================
void TreatCompound(const TopoDS_Shape& theS,
BOPCol_MapOfShape& aMFence,
BOPCol_ListOfShape& theLS)
{
TopAbs_ShapeEnum aType;
//
aType = theS.ShapeType();
if (aType != TopAbs_COMPOUND) {
if (aMFence.Add(theS)) {
theLS.Append(theS);
}
return;
}
//
TopoDS_Iterator aIt;
//
aIt.Initialize(theS);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aS = aIt.Value();
TreatCompound(aS, aMFence, theLS);
}
}

View File

@@ -17,24 +17,128 @@
#include <BOPAlgo_Builder.hxx>
#include <BOPAlgo_PaveFiller.hxx>
#include <BOPCol_ListOfShape.hxx>
#include <BOPCol_MapOfShape.hxx>
#include <BOPDS_DS.hxx>
#include <BOPTools.hxx>
#include <BOPTools_AlgoTools.hxx>
#include <BOPTools_AlgoTools3D.hxx>
#include <IntTools_Context.hxx>
#include <TopExp.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopoDS_Shape.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_MapOfShape.hxx>
//=======================================================================
//function : Generated
//purpose :
//=======================================================================
const TopTools_ListOfShape& BOPAlgo_Builder::Generated
(const TopoDS_Shape&)
(const TopoDS_Shape& theS)
{
// The rules for Generated shapes are these:
// 1. The EDGE may be generated from the FACES as an intersection edge;
// 2. The VERTEX may be generated from the EDGES and FACES as an intersection vertex.
//
// The list of generated elements will contain only those which are contained
// in the result of the operation.
myHistShapes.Clear();
if (!myHasGenerated)
return myHistShapes;
if (theS.IsNull())
return myHistShapes;
// Only EDGES and FACES should be considered
TopAbs_ShapeEnum aType = theS.ShapeType();
if (aType != TopAbs_EDGE && aType != TopAbs_FACE)
// Wrong type
return myHistShapes;
// Check that DS contains the shape, i.e. it is from the arguments of the operation
Standard_Integer nS = myDS->Index(theS);
if (nS < 0)
// Unknown shape
return myHistShapes;
// Check that the shape has participated in any intersections
const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(nS);
if (!aSI.HasReference())
// Untouched shape
return myHistShapes;
// Analyze all types of Interferences which can produce
// new vertices - Edge/Edge and Edge/Face
BOPDS_VectorOfInterfEE& aEEs = myDS->InterfEE();
BOPDS_VectorOfInterfEF& aEFs = myDS->InterfEF();
// Fence map to avoid duplicates in the list of Generated;
BOPCol_MapOfInteger aMFence;
// Analyze each interference and find those in which the given shape has participated
// No need to analyze Edge/Edge interferences for the shapes of type FACE
Standard_Boolean isFace = (aType == TopAbs_FACE);
for (Standard_Integer k = (isFace ? 1 : 0); k < 2; ++k)
{
Standard_Integer aNbLines = !k ? aEEs.Length() : aEFs.Length();
for (Standard_Integer i = 0; i < aNbLines; ++i)
{
BOPDS_Interf *aInt = !k ? (BOPDS_Interf*)(&aEEs(i)) : (BOPDS_Interf*)(&aEFs(i));
if (!aInt->HasIndexNew())
// No new vertices created
continue;
if (!aInt->Contains(nS))
continue;
Standard_Integer nVNew = aInt->IndexNew();
myDS->HasShapeSD(nVNew, nVNew);
if (!aMFence.Add(nVNew))
continue;
// Get the new vertex
const TopoDS_Shape& aVNew = myDS->Shape(nVNew);
// Check that the result shape contains vertex
if (myMapShape.Contains(aVNew))
// Save the vertex as generated
myHistShapes.Append(aVNew);
}
}
if (!isFace)
return myHistShapes;
// For the FACE it is also necessary to collect all
// section elements created in FACE/FACE interferences.
// This information is available in the FaceInfo structure.
const BOPDS_FaceInfo& aFI = myDS->FaceInfo(nS);
// Section edges of the face
const BOPDS_IndexedMapOfPaveBlock& aMPBSc = aFI.PaveBlocksSc();
// Save section edges contained in the result shape
Standard_Integer aNb = aMPBSc.Extent();
for (Standard_Integer i = 1; i <= aNb; ++i)
{
const TopoDS_Shape& aENew = myDS->Shape(aMPBSc(i)->Edge());
if (myMapShape.Contains(aENew))
myHistShapes.Append(aENew);
}
// Section vertices of the face
const BOPCol_MapOfInteger& aMVSc = aFI.VerticesSc();
// Save section vertices contained in the result shape
BOPCol_MapOfInteger::Iterator aItM(aMVSc);
for (; aItM.More(); aItM.Next())
{
const TopoDS_Shape& aVNew = myDS->Shape(aItM.Value());
if (myMapShape.Contains(aVNew))
myHistShapes.Append(aVNew);
}
return myHistShapes;
}
//=======================================================================
@@ -44,99 +148,72 @@ const TopTools_ListOfShape& BOPAlgo_Builder::Generated
const TopTools_ListOfShape& BOPAlgo_Builder::Modified
(const TopoDS_Shape& theS)
{
Standard_Boolean bHasImage, bToReverse;
TopAbs_ShapeEnum aType;
BOPCol_ListIteratorOfListOfShape aIt;
//
myHistShapes.Clear();
//
if (theS.IsNull()) {
if (!myHasModified)
// No modified elements
return myHistShapes;
}
//
bHasImage=myImages.IsBound(theS);
if (!bHasImage) {
const TopTools_ListOfShape* pLSp = myImagesResult.Seek(theS);
if (!pLSp || pLSp->IsEmpty())
// No track in the result -> no modified
return myHistShapes;
// For modification check if the shape is not linked to itself
if (pLSp->Extent() == 1)
{
if (theS.IsSame(pLSp->First()) && !myImages.IsBound(theS))
// Shape is not modified
return myHistShapes;
}
//
aType=theS.ShapeType();
//
if (!(aType==TopAbs_EDGE || aType==TopAbs_FACE ||
aType==TopAbs_VERTEX || aType==TopAbs_SOLID)) {
return myHistShapes;
}
//
//PrepareHistory();
//
const BOPCol_ListOfShape& aLSp=myImages.Find(theS);
aIt.Initialize(aLSp);
for (; aIt.More(); aIt.Next()) {
TopoDS_Shape aSp=aIt.Value();
if (myShapesSD.IsBound(aSp)) {
aSp = myShapesSD.Find(aSp);
}
//
if (myMapShape.Contains(aSp)) {
//
if (aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
aSp.Orientation(theS.Orientation());
}
else {
bToReverse=
BOPTools_AlgoTools::IsSplitToReverse(aSp, theS, myContext);
if (bToReverse) {
aSp.Reverse();
}
}
//
myHistShapes.Append(aSp);
}
// Iterate on all splits and save them with proper orientation into the result list
TopTools_ListIteratorOfListOfShape aIt(*pLSp);
for (; aIt.More(); aIt.Next())
{
TopoDS_Shape aSp = aIt.Value();
// Use the orientation of the input shape
TopAbs_ShapeEnum aType = aSp.ShapeType();
if (aType == TopAbs_VERTEX || aType == TopAbs_SOLID)
aSp.Orientation(theS.Orientation());
else if (BOPTools_AlgoTools::IsSplitToReverse(aSp, theS, myContext))
aSp.Reverse();
myHistShapes.Append(aSp);
}
//
return myHistShapes;
}
//=======================================================================
//function : IsDeleted
//purpose :
//=======================================================================
Standard_Boolean BOPAlgo_Builder::IsDeleted
(const TopoDS_Shape& theS)
Standard_Boolean BOPAlgo_Builder::IsDeleted(const TopoDS_Shape& theS)
{
Standard_Boolean bRet;
TopAbs_ShapeEnum aType;
BOPCol_ListIteratorOfListOfShape aIt;
//
bRet = Standard_True;
//
if (theS.IsNull()) {
return bRet;
}
//
aType = theS.ShapeType();
if (!(aType==TopAbs_EDGE || aType==TopAbs_FACE ||
aType==TopAbs_VERTEX || aType==TopAbs_SOLID)) {
return bRet;
}
//
if (!myImages.IsBound(theS)) {
bRet = !myMapShape.Contains(theS);
return bRet;
}
//
const BOPCol_ListOfShape& aLSp = myImages.Find(theS);
aIt.Initialize(aLSp);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aSp = aIt.Value();
const TopoDS_Shape& aSpR = myShapesSD.IsBound(aSp) ?
myShapesSD.Find(aSp) : aSp;
//
if (myMapShape.Contains(aSpR)) {
bRet = Standard_False;
break;
}
}
//
return bRet;
// The shape is considered as Deleted if it has participated in the
// operation and the result shape does not contain the shape itself
// and none of its splits.
if (!myHasDeleted)
// Non of the shapes have been deleted during the operation
return Standard_False;
const TopTools_ListOfShape *pImages = myImagesResult.Seek(theS);
if (!pImages)
// No track about the shape, i.e. the shape has not participated
// in operation -> Not deleted
return Standard_False;
// Check if any parts of the shape has been kept in the result
return pImages->IsEmpty();
}
//=======================================================================
//function : LocModified
//purpose :
//=======================================================================
const TopTools_ListOfShape* BOPAlgo_Builder::LocModified(const TopoDS_Shape& theS)
{
return myImages.Seek(theS);
}
//=======================================================================
//function : PrepareHistory
@@ -144,85 +221,91 @@ Standard_Boolean BOPAlgo_Builder::IsDeleted
//=======================================================================
void BOPAlgo_Builder::PrepareHistory()
{
if (!myFlagHistory) {
if (!myFlagHistory)
{
// Clearing
BOPAlgo_BuilderShape::PrepareHistory();
return;
}
//
if(myShape.IsNull()) {
return;
}
//
Standard_Boolean bHasImage;
TopAbs_ShapeEnum aType;
BOPCol_MapOfShape aMS;
BOPCol_ListIteratorOfListOfShape aIt;
BOPCol_MapIteratorOfMapOfShape aItM;
//
// 1. Clearing
// Clearing from previous operations
BOPAlgo_BuilderShape::PrepareHistory();
//
// 2. myMapShape - all shapes of result with theirs sub-shapes
myFlagHistory = Standard_True;
// Map the result shape
BOPTools::MapShapes(myShape, myMapShape);
// Among all input shapes find those that have any trace in the result
// and save them into myImagesResult map with connection to parts
// kept in the result shape. If the input shape has no trace in the
// result shape, link it to the empty list in myImagesResult meaning
// that the shape has been removed.
//
// 3. MS - all argument shapes with theirs sub-shapes
const BOPCol_ListOfShape& aArguments=myDS->Arguments();
aIt.Initialize(aArguments);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aSx=aIt.Value();
BOPTools::MapShapes(aSx, aMS);
}
//
// 4. Treatment
aItM.Initialize(aMS);
for (; aItM.More(); aItM.Next()) {
const TopoDS_Shape& aSx=aItM.Key();
aType = aSx.ShapeType();
if (!(aType == TopAbs_VERTEX || aType == TopAbs_EDGE ||
aType == TopAbs_FACE || aType == TopAbs_SOLID)) {
// Also, set the proper values to the history flags:
// - myHasDeleted for Deleted shapes;
// - myHasModified for Modified shapes;
// - myHasGenerated for Generated shapes.
Standard_Integer aNbS = myDS->NbSourceShapes();
for (Standard_Integer i = 0; i < aNbS; ++i)
{
const TopoDS_Shape& aS = myDS->Shape(i);
// History information is only available for the shapes of type
// VERTEX, EDGE, FACE and SOLID. Skip all shapes of different type.
TopAbs_ShapeEnum aType = aS.ShapeType();
if (!(aType == TopAbs_VERTEX ||
aType == TopAbs_EDGE ||
aType == TopAbs_FACE ||
aType == TopAbs_SOLID))
continue;
// Track the modification of the shape
TopTools_ListOfShape* pImages = &myImagesResult(myImagesResult.Add(aS, TopTools_ListOfShape()));
// Check if the shape has any splits
const TopTools_ListOfShape* pLSp = LocModified(aS);
if (!pLSp)
{
// No splits, check if the result shape contains the shape itself
if (myMapShape.Contains(aS))
// Shape has passed into result without modifications -> link the shape to itself
pImages->Append(aS);
else
// No trace of the shape in the result -> Deleted element is found
myHasDeleted = Standard_True;
}
//
// 4.1 .myImagesResult
bHasImage=myImages.IsBound(aSx);
//
BOPCol_ListOfShape aLSx;
if (!bHasImage) {
if (myMapShape.Contains(aSx)) {
aLSx.Append(aSx);
myImagesResult.Add(aSx, aLSx);
}
}
else {
const BOPCol_ListOfShape& aLSp=myImages.Find(aSx);
aIt.Initialize(aLSp);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aSp=aIt.Value();
if (myMapShape.Contains(aSp)) {
aLSx.Append(aSp);
else
{
// Find all splits of the shape which are kept in the result
TopTools_ListIteratorOfListOfShape aIt(*pLSp);
for (; aIt.More(); aIt.Next())
{
const TopoDS_Shape& aSp = aIt.Value();
// Check if the result shape contains the split
if (myMapShape.Contains(aSp))
{
// Link the shape to the split
pImages->Append(aSp);
}
}
myImagesResult.Add(aSx, aLSx);
}
// <- A
//
// 4.2 As it was
if (!myHasDeleted) {
myHasDeleted=IsDeleted(aSx);
}
//
if (!myHasModified && bHasImage) {
if (aType==TopAbs_EDGE || aType==TopAbs_FACE ||
aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
if (!pImages->IsEmpty())
// Modified element is found
myHasModified = Standard_True;
}
else
// Deleted element is found
myHasDeleted = Standard_True;
}
//
if (!myHasGenerated) {
if (aType==TopAbs_FACE) {
const TopTools_ListOfShape& aLG = Generated(aSx);
myHasGenerated = aLG.Extent() > 0;
}
// Until first found, check if the shape has Generated elements
if (!myHasGenerated)
{
// Temporarily set the HasGenerated flag to TRUE to look for the shapes generated from aS.
// Otherwise, the method Generated will always be returning an empty list, assuming that the
// operation has no generated elements at all.
myHasGenerated = Standard_True;
myHasGenerated = (Generated(aS).Extent() > 0);
}
}
myFlagHistory=Standard_True;
}

View File

@@ -887,6 +887,8 @@ Standard_Boolean BOPAlgo_CellsBuilder::RemoveInternals(const BOPCol_ListOfShape&
continue;
}
//
myReport->Merge(aBS.GetReport());
//
TopoDS_Solid& aSNew = *(TopoDS_Solid*)&aBS.Areas().First();
//
// put all internal parts into new solid
@@ -899,118 +901,56 @@ Standard_Boolean BOPAlgo_CellsBuilder::RemoveInternals(const BOPCol_ListOfShape&
//
theLSNew.Append(aSNew);
bRemoved = Standard_True;
// Save information about the fuse of the solids into a history map
aItS.Initialize(aCB);
for (; aItS.More(); aItS.Next())
myMapModified.Bind(aItS.Value(), aSNew);
}
}
return bRemoved;
}
//=======================================================================
//function : IsDeleted
//function : LocModified
//purpose :
//=======================================================================
Standard_Boolean BOPAlgo_CellsBuilder::IsDeleted(const TopoDS_Shape& theS)
const TopTools_ListOfShape* BOPAlgo_CellsBuilder::LocModified(const TopoDS_Shape& theS)
{
Standard_Boolean bRet = Standard_True;
if (theS.IsNull()) {
return bRet;
}
//
TopAbs_ShapeEnum aType = theS.ShapeType();
if (!(aType==TopAbs_EDGE || aType==TopAbs_FACE ||
aType==TopAbs_VERTEX || aType==TopAbs_SOLID)) {
return bRet;
}
//
Standard_Boolean bHasImage, bHasModified;
//
bHasImage = myImages.IsBound(theS);
bHasModified = myMapModified.IsBound(theS);
if (!bHasImage && !bHasModified) {
bRet = !myMapShape.Contains(theS);
return bRet;
}
//
if (bHasModified) {
const TopoDS_Shape& aSG = myMapModified.Find(theS);
if (myMapShape.Contains(aSG)) {
bRet = Standard_False;
return bRet;
}
}
//
if (bHasImage) {
const BOPCol_ListOfShape& aLSp = myImages.Find(theS);
BOPCol_ListIteratorOfListOfShape aIt(aLSp);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aSp = aIt.Value();
const TopoDS_Shape& aSpR = myShapesSD.IsBound(aSp) ?
myShapesSD.Find(aSp) : aSp;
//
const TopoDS_Shape& aSpRG = myMapModified.IsBound(aSpR) ?
myMapModified.Find(aSpR) : aSpR;
if (myMapShape.Contains(aSpRG)) {
bRet = Standard_False;
break;
}
}
}
//
return bRet;
}
// Get shape's modification coming from GF operation
const TopTools_ListOfShape* pLSp = BOPAlgo_Builder::LocModified(theS);
if (myMapModified.IsEmpty())
// No local modifications
return pLSp;
//=======================================================================
//function : Modified
//purpose :
//=======================================================================
const TopTools_ListOfShape& BOPAlgo_CellsBuilder::Modified(const TopoDS_Shape& theS)
{
myHistShapes.Clear();
if (theS.IsNull()) {
return myHistShapes;
// Check if the shape (or its splits) has participated in unification
if (!pLSp)
{
// No splits from GF operation.
// Check if the shape has been unified with other shapes
const TopoDS_Shape* pSU = myMapModified.Seek(theS);
if (!pSU)
return NULL;
myHistShapes.Append(*pSU);
}
//
TopAbs_ShapeEnum aType = theS.ShapeType();
if (!(aType==TopAbs_EDGE || aType==TopAbs_FACE || aType==TopAbs_VERTEX)) {
return myHistShapes;
}
//
Standard_Boolean bHasModified = myMapModified.IsBound(theS);
if (bHasModified) {
const TopoDS_Shape& aSG = myMapModified.Find(theS);
if (myMapShape.Contains(aSG)) {
myHistShapes.Append(aSG);
}
return myHistShapes;
}
//
Standard_Boolean bHasImage = myImages.IsBound(theS);
if (!bHasImage) {
return myHistShapes;
}
//
BOPCol_MapOfShape aMFence;
const BOPCol_ListOfShape& aLSp = myImages.Find(theS);
BOPCol_ListIteratorOfListOfShape aIt(aLSp);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape aSp = aIt.Value();
const TopoDS_Shape& aSpR = myShapesSD.IsBound(aSp) ?
myShapesSD.Find(aSp) : aSp;
//
if (myMapModified.IsBound(aSpR)) {
const TopoDS_Shape& aSG = myMapModified.Find(aSpR);
if (myMapShape.Contains(aSG)) {
if (aMFence.Add(aSG)) {
myHistShapes.Append(aSG);
}
}
}
else if (aMFence.Add(aSpR))
else
{
TopTools_MapOfShape aMFence;
// Process all GF splits and check them for local unification with other shapes
TopTools_ListIteratorOfListOfShape aIt(*pLSp);
for (; aIt.More(); aIt.Next())
{
myHistShapes.Append(aSpR);
const TopoDS_Shape* pSp = &aIt.Value();
const TopoDS_Shape* pSU = myMapModified.Seek(*pSp);
if (pSU) pSp = pSU;
if (aMFence.Add(*pSp))
myHistShapes.Append(*pSp);
}
}
//
return myHistShapes;
return &myHistShapes;
}
//=======================================================================

View File

@@ -90,8 +90,6 @@
//! IsDeleted() and Modified().<br>
//! In DRAW Test Harness it is available through the same
//! commands as for Boolean Operations (bmodified, bgenerated and bisdeleted).<br>
//! There could be Generated shapes only after removing of the internal boundaries
//! between faces and edges, i.e. after using ShapeUpgrade_UnifySameDomain tool.<br>
//!
//! The algorithm can return the following Error Statuses:
//! - Error status acquired in the General Fuse algorithm.
@@ -238,15 +236,13 @@ class BOPAlgo_CellsBuilder : public BOPAlgo_Builder
//! Makes the Containers of proper type from the parts added to result.
Standard_EXPORT void MakeContainers();
//! Returns the list of shapes generated from the shape theS.
Standard_EXPORT virtual const TopTools_ListOfShape& Modified(const TopoDS_Shape& theS) Standard_OVERRIDE;
//! Returns true if the shape theS has been deleted.
Standard_EXPORT virtual Standard_Boolean IsDeleted (const TopoDS_Shape& theS) Standard_OVERRIDE;
protected:
//! Redefined method Prepare - no need to prepare history
//! Prepare information for history support taking into account
//! local modification map of unified elements - myMapModified.
Standard_EXPORT virtual const TopTools_ListOfShape* LocModified(const TopoDS_Shape& theS) Standard_OVERRIDE;
//! Redefined method Prepare - no need to prepare history
//! information on the default result as it is empty compound.
Standard_EXPORT virtual void Prepare() Standard_OVERRIDE;
@@ -268,13 +264,11 @@ class BOPAlgo_CellsBuilder : public BOPAlgo_Builder
BOPCol_ListOfShape& theLSNew);
// fields
TopoDS_Shape myAllParts;
BOPCol_IndexedDataMapOfShapeListOfShape myIndex;
BOPCol_DataMapOfIntegerListOfShape myMaterials;
BOPCol_DataMapOfShapeInteger myShapeMaterial;
BOPCol_DataMapOfShapeShape myMapModified;
private:
TopoDS_Shape myAllParts; //!< All split parts of the arguments
BOPCol_IndexedDataMapOfShapeListOfShape myIndex; //!< Connection map from all splits parts to the argument shapes from which they were created
BOPCol_DataMapOfIntegerListOfShape myMaterials; //!< Map of assigned materials (material -> list of shape)
BOPCol_DataMapOfShapeInteger myShapeMaterial; //!< Map of assigned materials (shape -> material)
BOPCol_DataMapOfShapeShape myMapModified; //!< Local modification map to track unification of the splits
};

View File

@@ -159,16 +159,16 @@ void BOPAlgo_CheckerSI::Init()
myDS->SetArguments(myArguments);
myDS->Init(myFuzzyValue);
//
// 2.myIterator
// 2 myContext
myContext=new IntTools_Context;
//
// 3.myIterator
BOPDS_PIteratorSI theIterSI=new BOPDS_IteratorSI(myAllocator);
theIterSI->SetDS(myDS);
theIterSI->Prepare();
theIterSI->Prepare(myContext, myUseOBB, myFuzzyValue);
theIterSI->UpdateByLevelOfCheck(myLevelOfCheck);
//
myIterator=theIterSI;
//
// 3 myContext
myContext=new IntTools_Context;
}
//=======================================================================
//function : Perform

View File

@@ -0,0 +1,305 @@
// Created on: 2018-03-29
// Created by: Eugeny MALTCHIKOV
// Copyright (c) 2018 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BOPAlgo_MakeConnected.hxx>
#include <BOPAlgo_Alerts.hxx>
#include <BOPAlgo_Builder.hxx>
#include <BOPAlgo_Tools.hxx>
#include <BOPTools_AlgoTools.hxx>
#include <BRep_Builder.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS_Iterator.hxx>
//=======================================================================
//function : Perform
//purpose : Makes the shapes connected
//=======================================================================
void BOPAlgo_MakeConnected::Perform()
{
// Check the input data
CheckData();
if (HasErrors())
return;
if (myHistory.IsNull())
myHistory = new BRepTools_History;
// Glue the arguments
MakeConnected();
if (HasErrors())
return;
// Perform material associations for the faces
AssociateMaterials();
if (HasErrors())
return;
}
//=======================================================================
//function : CheckData
//purpose : Check the validity of input data
//=======================================================================
void BOPAlgo_MakeConnected::CheckData()
{
// Check the number of arguments
if (myArguments.IsEmpty())
{
// Not enough arguments
AddError(new BOPAlgo_AlertTooFewArguments());
return;
}
// Check that all shapes in arguments are of the same type
// Extract the shapes from the compound arguments
TopTools_ListOfShape aLA;
// Fence map
TopTools_MapOfShape aMFence;
TopTools_ListIteratorOfListOfShape itLA(myArguments);
for (; itLA.More(); itLA.Next())
BOPAlgo_Tools::TreatCompound(itLA.Value(), aMFence, aLA);
if (aLA.IsEmpty())
{
// It seems that all argument shapes are empty compounds
AddError(new BOPAlgo_AlertTooFewArguments());
return;
}
// Check dimensions of the extracted non-compound shapes
itLA.Initialize(aLA);
Standard_Integer iDim = BOPTools_AlgoTools::Dimension(itLA.Value());
for (itLA.Next(); itLA.More(); itLA.Next())
{
if (iDim != BOPTools_AlgoTools::Dimension(itLA.Value()))
{
// The arguments are of different type
AddError(new BOPAlgo_AlertMultiDimensionalArguments());
return;
}
}
}
//=======================================================================
//function : MakeConnected
//purpose : Glues the argument shapes
//=======================================================================
void BOPAlgo_MakeConnected::MakeConnected()
{
// Initialize the history
if (myGlueHistory.IsNull())
myGlueHistory = new BRepTools_History;
if (myArguments.Extent() == 1)
{
// No need to glue the single shape
myShape = myArguments.First();
}
else
{
// Glue the shapes
BOPAlgo_Builder aGluer;
aGluer.SetArguments(myArguments);
aGluer.SetGlue(BOPAlgo_GlueShift);
aGluer.SetRunParallel(myRunParallel);
aGluer.SetNonDestructive(Standard_True);
aGluer.Perform();
if (aGluer.HasErrors())
{
// Unable to glue the shapes
TopoDS_Compound aCW;
BRep_Builder().MakeCompound(aCW);
for (TopTools_ListIteratorOfListOfShape it(myArguments); it.More(); it.Next())
BRep_Builder().Add(aCW, it.Value());
AddError(new BOPAlgo_AlertUnableToGlue(aCW));
return;
}
myShape = aGluer.Shape();
// Save the gluing history
myGlueHistory->Merge(aGluer.Arguments(), aGluer);
myHistory->Merge(myGlueHistory);
}
// Keep the glued shape
myGlued = myShape;
// Fill the map of origins
FillOrigins();
}
//=======================================================================
//function : FillOrigins
//purpose : Fills the map of origins
//=======================================================================
void BOPAlgo_MakeConnected::FillOrigins()
{
myOrigins.Clear();
// Map the history shapes of the arguments
if (myAllInputsMap.IsEmpty())
{
TopTools_ListIteratorOfListOfShape itLA(myArguments);
for (; itLA.More(); itLA.Next())
TopExp::MapShapes(itLA.Value(), myAllInputsMap);
}
const Standard_Integer aNbS = myAllInputsMap.Extent();
for (Standard_Integer i = 1; i <= aNbS; ++i)
{
const TopoDS_Shape& aS = myAllInputsMap(i);
if (!BRepTools_History::IsSupportedType(aS))
continue;
// Get Modified & Generated shapes
for (Standard_Integer j = 0; j < 2; ++j)
{
const TopTools_ListOfShape& aLH = !j ? myHistory->Modified(aS) : myHistory->Generated(aS);
TopTools_ListIteratorOfListOfShape itLH(aLH);
for (; itLH.More(); itLH.Next())
{
const TopoDS_Shape& aHS = itLH.Value();
TopTools_ListOfShape* pLOr = myOrigins.ChangeSeek(aHS);
if (!pLOr)
pLOr = myOrigins.Bound(aHS, TopTools_ListOfShape());
if (!pLOr->Contains(aS))
pLOr->Append(aS);
}
}
}
}
//=======================================================================
//function : AssociateMaterials
//purpose : Associates the materials for the first BRep sub-elements
//=======================================================================
void BOPAlgo_MakeConnected::AssociateMaterials()
{
myMaterials.Clear();
// Extract all non-compound shapes from the result
TopTools_ListOfShape aLShapes;
TopTools_MapOfShape aMFence;
BOPAlgo_Tools::TreatCompound(myShape, aMFence, aLShapes);
if (aLShapes.IsEmpty())
return;
// Define the element type and the material type
TopAbs_ShapeEnum anElemType;
const TopAbs_ShapeEnum aMaterialType = aLShapes.First().ShapeType();
if (aMaterialType == TopAbs_SOLID || aMaterialType == TopAbs_COMPSOLID)
anElemType = TopAbs_FACE;
else if (aMaterialType == TopAbs_FACE || aMaterialType == TopAbs_SHELL)
anElemType = TopAbs_EDGE;
else if (aMaterialType == TopAbs_EDGE || aMaterialType == TopAbs_WIRE)
anElemType = TopAbs_VERTEX;
else
return;
TopTools_ListIteratorOfListOfShape itLS(aLShapes);
for (; itLS.More(); itLS.Next())
{
const TopoDS_Shape& aS = itLS.Value();
const TopTools_ListOfShape& aLOr = GetOrigins(aS);
const TopoDS_Shape& aSOr = aLOr.IsEmpty() ? aS : aLOr.First();
TopExp_Explorer anExp(aS, anElemType);
for (; anExp.More(); anExp.Next())
{
const TopoDS_Shape& anElement = anExp.Current();
TopTools_ListOfShape* pLM = myMaterials.ChangeSeek(anElement);
if (!pLM)
pLM = myMaterials.Bound(anElement, TopTools_ListOfShape());
pLM->Append(aSOr);
}
}
}
//=======================================================================
//function : MakePeriodic
//purpose : Makes the shape periodic according to the given parameters
//=======================================================================
void BOPAlgo_MakeConnected::MakePeriodic(const BOPAlgo_MakePeriodic::PeriodicityParams& theParams)
{
if (HasErrors())
return;
// Make the shape periodic
myPeriodicityMaker.Clear();
myPeriodicityMaker.SetShape(myGlued);
myPeriodicityMaker.SetPeriodicityParameters(theParams);
myPeriodicityMaker.SetRunParallel(myRunParallel);
myPeriodicityMaker.Perform();
if (myPeriodicityMaker.HasErrors())
{
// Add warning informing the user that periodicity with
// given parameters is not possible
AddWarning(new BOPAlgo_AlertUnableToMakePeriodic(myShape));
return;
}
myShape = myPeriodicityMaker.Shape();
// Update history
myHistory->Clear();
if (!myGlueHistory.IsNull())
myHistory->Merge(myGlueHistory);
myHistory->Merge(myPeriodicityMaker.History());
// Fill the map of origins
FillOrigins();
// Update the material associations after making the shape periodic
AssociateMaterials();
}
//=======================================================================
//function : RepeatShape
//purpose : Repeats the shape in the given direction given number of times
//=======================================================================
void BOPAlgo_MakeConnected::RepeatShape(const Standard_Integer theDirectionID,
const Standard_Integer theTimes)
{
if (HasErrors())
return;
if (myPeriodicityMaker.Shape().IsNull() || myPeriodicityMaker.HasErrors())
{
// The shape has not been made periodic yet
AddWarning(new BOPAlgo_AlertShapeIsNotPeriodic(myShape));
return;
}
// Repeat the shape
myShape = myPeriodicityMaker.RepeatShape(theDirectionID, theTimes);
// Update history
myHistory->Clear();
if (!myGlueHistory.IsNull())
myHistory->Merge(myGlueHistory);
myHistory->Merge(myPeriodicityMaker.History());
// Fill the map of origins
FillOrigins();
// Update the material associations after shape repetitions
AssociateMaterials();
}

View File

@@ -0,0 +1,330 @@
// Created on: 2018-03-29
// Created by: Eugeny MALTCHIKOV
// Copyright (c) 2018 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BOPAlgo_MakeConnected_HeaderFile
#define _BOPAlgo_MakeConnected_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <BOPAlgo_Options.hxx>
#include <BOPAlgo_MakePeriodic.hxx>
#include <BRepTools_History.hxx>
#include <NCollection_DataMap.hxx>
#include <TopTools_OrientedShapeMapHasher.hxx>
//! BOPAlgo_MakeConnected is the algorithm for making the touching
//! shapes connected or glued, i.e. for making the coinciding geometries
//! be topologically shared among the shapes.
//!
//! The input shapes should be of the same dimension, otherwise
//! the gluing will not make any sense.
//!
//! After the shapes are made connected, the first sub-elements of input shapes
//! are associated with the shapes to which they belong. At that, the orientation of
//! the sub-element in the shape is taken into account.
//! The associations are made for the following types:
//! - For input SOLIDS, the resulting FACES are associated with the input solids;
//! - For input FACES, the resulting EDGES are associated with the input faces;
//! - For input EDGES, the resulting VERTICES are associated with the input edges.
//!
//! In frames of this algorithm the input shapes are called materials,
//! and the association process is called the material association.
//! The material association allows finding the coinciding elements for the opposite
//! input shapes. These elements will be associated to at least two materials.
//!
//! After making the shapes connected, it is possible to make the connected
//! shape periodic using the *BOPAlgo_MakePeriodic* tool.
//! After making the shape periodic, the material associations will be updated
//! to correspond to the actual state of the result shape.
//! Repetition of the periodic shape is also possible here. Material associations
//! are not going to be lost.
//!
//! The algorithm supports history of shapes modification, thus it is possible
//! to track the modification of the input shapes during the operations.
//! Additionally to standard history methods, the algorithm provides the
//! the method *GetOrigins()* which allows obtaining the input shapes from which
//! the resulting shape has been created.
//!
//! The algorithm supports the parallel processing mode, which allows faster
//! completion of the operations.
//!
//! The algorithm returns the following Error/Warning messages:
//! - *BOPAlgo_AlertTooFewArguments* - error alert is given on the attempt to run
//! the algorithm without the arguments;
//! - *BOPAlgo_AlertMultiDimensionalArguments* - error alert is given on the attempt
//! to run the algorithm on multi-dimensional arguments;
//! - *BOPAlgo_AlertUnableToGlue* - error alert is given if the gluer algorithm
//! is unable to glue the given arguments;
//! - *BOPAlgo_AlertUnableToMakePeriodic* - warning alert is given if the periodicity
//! maker is unable to make the connected shape periodic with given options;
//! - *BOPAlgo_AlertShapeIsNotPeriodic* - warning alert is given on the attempt to
//! repeat the shape before making it periodic.
//!
//! Here is the example of usage of the algorithm:
//! ~~~~
//! TopTools_ListOfShape anArguments = ...; // Shapes to make connected
//! Standard_Boolean bRunParallel = ...; // Parallel processing mode
//!
//! BOPAlgo_MakeConnected aMC; // Tool for making the shapes connected
//! aMC.SetArguments(anArguments); // Set the shapes
//! aMC.SetRunParallel(bRunParallel); // Set parallel processing mode
//! aMC.Perform(); // Perform the operation
//!
//! if (aMC.HasErrors()) // Check for the errors
//! {
//! // errors treatment
//! Standard_SStream aSStream;
//! aMC.DumpErrors(aSStream);
//! return;
//! }
//! if (aMC.HasWarnings()) // Check for the warnings
//! {
//! // warnings treatment
//! Standard_SStream aSStream;
//! aMC.DumpWarnings(aSStream);
//! }
//!
//! const TopoDS_Shape& aGluedShape = aMC.Shape(); // Connected shape
//!
//! // Checking material associations
//! TopAbs_ShapeEnum anElemType = ...; // Type of first BRep sub-element
//! TopExp_Explorer anExp(anArguments.First(), anElemType);
//! for (; anExp.More(); anExp.Next())
//! {
//! const TopoDS_Shape& anElement = anExp.Current();
//! const TopTools_ListOfShape& aNegativeM = aMC.MaterialsOnNegativeSide(anElement);
//! const TopTools_ListOfShape& aPositiveM = aMC.MaterialsOnPositiveSide(anElement);
//! }
//!
//! // Making the connected shape periodic
//! BOPAlgo_MakePeriodic::PeriodicityParams aParams = ...; // Options for periodicity of the connected shape
//! aMC.MakePeriodic(aParams);
//!
//! // Shape repetition after making it periodic
//! // Check if the shape has been made periodic successfully
//! if (aMC.PeriodicityTool().HasErrors())
//! {
//! // Periodicity maker error treatment
//! }
//!
//! // Shape repetition in periodic directions
//! aMC.RepeatShape(0, 2);
//!
//! const TopoDS_Shape& aShape = aMC.PeriodicShape(); // Periodic and repeated shape
//! ~~~~
//!
class BOPAlgo_MakeConnected : public BOPAlgo_Options
{
public:
DEFINE_STANDARD_ALLOC
public: //! @name Constructor
//! Empty constructor
BOPAlgo_MakeConnected() : BOPAlgo_Options()
{
}
public: //! @name Setters for the shapes to make connected
//! Sets the shape for making them connected.
//! @param theArgs [in] The arguments for the operation.
void SetArguments(const TopTools_ListOfShape& theArgs)
{
myArguments = theArgs;
}
//! Adds the shape to the arguments.
//! @param theS [in] One of the argument shapes.
void AddArgument(const TopoDS_Shape& theS)
{
myArguments.Append(theS);
}
//! Returns the list of arguments of the operation.
const TopTools_ListOfShape& Arguments() const
{
return myArguments;
}
public: //! @name Performing the operations
//! Performs the operation, i.e. makes the input shapes connected.
Standard_EXPORT void Perform();
public: //! @name Shape periodicity & repetition
//! Makes the connected shape periodic.
//! Repeated calls of this method overwrite the previous calls
//! working with the basis connected shape.
//! @param theParams [in] Periodic options.
Standard_EXPORT void MakePeriodic(const BOPAlgo_MakePeriodic::PeriodicityParams& theParams);
//! Performs repetition of the periodic shape in specified direction
//! required number of times.
//! @param theDirectionID [in] The direction's ID (0 for X, 1 for Y, 2 for Z);
//! @param theTimes [in] Requested number of repetitions (sign of the value defines
//! the side of the repetition direction (positive or negative)).
Standard_EXPORT void RepeatShape(const Standard_Integer theDirectionID,
const Standard_Integer theTimes);
//! Returns the periodicity tool.
const BOPAlgo_MakePeriodic& PeriodicityTool() const
{
return myPeriodicityMaker;
}
public: //! @name Material transitions
//! Returns the original shapes which images contain the
//! the given shape with FORWARD orientation.
//! @param theS [in] The shape for which the materials are necessary.
const TopTools_ListOfShape& MaterialsOnPositiveSide(const TopoDS_Shape& theS)
{
const TopTools_ListOfShape* pLM = myMaterials.Seek(theS.Oriented(TopAbs_FORWARD));
return (pLM ? *pLM : EmptyList());
}
//! Returns the original shapes which images contain the
//! the given shape with REVERSED orientation.
//! @param theS [in] The shape for which the materials are necessary.
const TopTools_ListOfShape& MaterialsOnNegativeSide(const TopoDS_Shape& theS)
{
const TopTools_ListOfShape* pLM = myMaterials.Seek(theS.Oriented(TopAbs_REVERSED));
return (pLM ? *pLM : EmptyList());
}
public: //! @name History methods
//! Returns the history of operations
const Handle(BRepTools_History)& History() const
{
return myHistory;
}
//! Returns the list of shapes modified from the given shape.
//! @param theS [in] The shape for which the modified shapes are necessary.
const TopTools_ListOfShape& GetModified(const TopoDS_Shape& theS)
{
return (myHistory.IsNull() ? EmptyList() : myHistory->Modified(theS));
}
//! Returns the list of original shapes from which the current shape has been created.
//! @param theS [in] The shape for which the origins are necessary.
const TopTools_ListOfShape& GetOrigins(const TopoDS_Shape& theS)
{
const TopTools_ListOfShape* pLOr = myOrigins.Seek(theS);
return (pLOr ? *pLOr : EmptyList());
}
public: //! @name Getting the result shapes
//! Returns the resulting connected shape
const TopoDS_Shape& Shape() const
{
return myGlued;
}
//! Returns the resulting periodic & repeated shape
const TopoDS_Shape& PeriodicShape() const
{
return myShape;
}
public: //! @name Clearing the contents of the algorithm from previous runs
//! Clears the contents of the algorithm.
void Clear()
{
BOPAlgo_Options::Clear();
myArguments.Clear();
myAllInputsMap.Clear();
myPeriodicityMaker.Clear();
myOrigins.Clear();
myMaterials.Clear();
if (!myGlueHistory.IsNull())
myGlueHistory->Clear();
if (!myHistory.IsNull())
myHistory->Clear();
myGlued.Nullify();
myShape.Nullify();
}
protected: //! @name Protected methods performing the operation
//! Checks the validity of input data.
Standard_EXPORT void CheckData();
//! Makes the argument shapes connected (or glued).
Standard_EXPORT void MakeConnected();
//! Associates the materials transitions for the first BRep sub-elements:
//! - For input Solids, associates the Faces to Solids;
//! - For input Faces, associates the Edges to Faces;
//! - For input Edges, associates the Vertices to Edges.
Standard_EXPORT void AssociateMaterials();
//! Fills the map of origins
Standard_EXPORT void FillOrigins();
private:
//! Returns an empty list.
const TopTools_ListOfShape& EmptyList()
{
static const TopTools_ListOfShape anEmptyList;
return anEmptyList;
}
protected: //! @name Fields
// Inputs
TopTools_ListOfShape myArguments; //!< Input shapes for making them connected
TopTools_IndexedMapOfShape myAllInputsMap; //!< Map of all BRep sub-elements of the input shapes
// Tools
BOPAlgo_MakePeriodic myPeriodicityMaker; //!< Tool for making the shape periodic
// Results
NCollection_DataMap
<TopoDS_Shape,
TopTools_ListOfShape,
TopTools_OrientedShapeMapHasher> myMaterials; //!< Map of the materials associations
//! for the first BRep sub-elements
TopTools_DataMapOfShapeListOfShape myOrigins; //!< Map of origins
//! (allows tracking the shape's ancestors)
Handle(BRepTools_History) myGlueHistory; //!< Gluing History
Handle(BRepTools_History) myHistory; //!< Final History of shapes modifications
//! (including making the shape periodic and repetitions)
TopoDS_Shape myGlued; //!< The resulting connected (glued) shape
TopoDS_Shape myShape; //!< The resulting shape
};
#endif // _BOPAlgo_MakeConnected_HeaderFile

View File

@@ -0,0 +1,610 @@
// Created on: 2018-03-16
// Created by: Eugeny MALTCHIKOV
// Copyright (c) 2018 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BOPAlgo_MakePeriodic.hxx>
#include <BOPAlgo_Alerts.hxx>
#include <Bnd_Box.hxx>
#include <BOPAlgo_Builder.hxx>
#include <BOPAlgo_PaveFiller.hxx>
#include <BRepAlgoAPI_Common.hxx>
#include <BRepAlgoAPI_Splitter.hxx>
#include <BRepBndLib.hxx>
#include <BRepBuilderAPI_Transform.hxx>
#include <BRepPrimAPI_MakeBox.hxx>
#include <gp_Pln.hxx>
#include <Precision.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Compound.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
//=======================================================================
//function : Perform
//purpose : Performs the operation
//=======================================================================
void BOPAlgo_MakePeriodic::Perform()
{
// Check the validity of input data
CheckData();
if (HasErrors())
return;
// Trim the shape to fit to the required period in
// required periodic directions
Trim();
if (HasErrors())
return;
// Make the shape identical on the opposite sides in
// required periodic directions
MakeIdentical();
if (HasErrors())
return;
}
//=======================================================================
//function : CheckData
//purpose : Checks the validity of input data
//=======================================================================
void BOPAlgo_MakePeriodic::CheckData()
{
if ( (!IsXPeriodic() || XPeriod() < Precision::Confusion())
&& (!IsYPeriodic() || YPeriod() < Precision::Confusion())
&& (!IsZPeriodic() || ZPeriod() < Precision::Confusion()))
{
// Add error informing the user that no periodicity is required
// or no valid period is set.
AddError(new BOPAlgo_AlertNoPeriodicityRequired());
return;
}
}
//=======================================================================
//function : AddToShape
//purpose : Adds the shape <theWhat> to the shape <theWhere>
//=======================================================================
static void AddToShape(const TopoDS_Shape& theWhat,
TopoDS_Shape& theWhere)
{
if (theWhere.IsNull())
BRep_Builder().MakeCompound(TopoDS::Compound(theWhere));
BRep_Builder().Add(theWhere, theWhat);
}
//=======================================================================
//function : AddToShape
//purpose : Adds the shape in the list <theLWhat> to the shape <theWhere>
//=======================================================================
static void AddToShape(const TopTools_ListOfShape& theLWhat,
TopoDS_Shape& theWhere)
{
TopTools_ListIteratorOfListOfShape it(theLWhat);
for (; it.More(); it.Next())
AddToShape(it.Value(), theWhere);
}
//=======================================================================
//function : Trim
//purpose : Make the trim of the shape to fit to the periodic bounds.
//=======================================================================
void BOPAlgo_MakePeriodic::Trim()
{
// Check if trim is required at all
if (IsInputXTrimmed() &&
IsInputYTrimmed() &&
IsInputZTrimmed())
return;
// Compute bounding box for the shape to find its center and use it
// as a reference point for trimming
Bnd_Box aBox;
BRepBndLib::Add(myInputShape, aBox);
aBox.Enlarge(1.);
// Get Corner points of the bounding box
gp_Pnt aPMin = aBox.CornerMin();
gp_Pnt aPMax = aBox.CornerMax();
// Update corner points according to the trim parameters
for (Standard_Integer i = 0; i < 3; ++i)
{
if (IsInputTrimmed(i))
continue;
aPMin.SetCoord(i + 1, PeriodFirst(i));
aPMax.SetCoord(i + 1, PeriodFirst(i) + Period(i));
}
// Build Trimming solid using corner points
BRepPrimAPI_MakeBox aMBox(aPMin, aPMax);
const TopoDS_Shape& aTrimBox = aMBox.Solid();
// Perform trimming of the shape by solid
BRepAlgoAPI_Common aCommon;
// Set Object
TopTools_ListOfShape anObj;
anObj.Append(myInputShape);
aCommon.SetArguments(anObj);
// Set Tool
TopTools_ListOfShape aTool;
aTool.Append(aTrimBox);
aCommon.SetTools(aTool);
// Set the parallel processing mode
aCommon.SetRunParallel(myRunParallel);
// Build
aCommon.Build();
if (aCommon.HasErrors())
{
// Unable to trim the shape
// Merge errors from Common operation
myReport->Merge(aCommon.GetReport());
// Add new error saving the shapes for analysis
TopoDS_Compound aWS;
AddToShape(myInputShape, aWS);
AddToShape(aTrimBox, aWS);
AddError(new BOPAlgo_AlertUnableToTrim(aWS));
return;
}
// Get the trimmed shape
myShape = aCommon.Shape();
// Fill the History for the object only
mySplitHistory = new BRepTools_History();
mySplitHistory->Merge(anObj, aCommon);
}
//=======================================================================
//function : MakeIdentical
//purpose : Make the shape look the same on the opposite sides in the
// required periodic directions.
//=======================================================================
void BOPAlgo_MakePeriodic::MakeIdentical()
{
if (myShape.IsNull())
myShape = myInputShape;
if (mySplitHistory.IsNull())
mySplitHistory = new BRepTools_History;
// Split the negative side of the shape with the geometry
// located on the positive side
SplitNegative();
if (HasErrors())
return;
// Split the positive side of the shape with the geometry
// located on the negative side.
// Make sure that the opposite sides have identical geometries.
// Make associations between identical opposite shapes.
SplitPositive();
myHistory = new BRepTools_History();
myHistory->Merge(mySplitHistory);
}
//=======================================================================
//function : SplitNegative
//purpose : Split the negative side of the shape with the geometry
// located on the positive side.
//=======================================================================
void BOPAlgo_MakePeriodic::SplitNegative()
{
// Copy geometry from positive side of the shape to the negative first.
// So, translate the shape in negative periodic directions only.
//
// To avoid conflicts when copying geometries from positive periodic sides
// perform split of each periodic side in a separate operation.
for (Standard_Integer i = 0; i < 3; ++i)
{
if (!IsPeriodic(i))
continue;
// Translate the shape to the negative side
gp_Trsf aNegTrsf;
aNegTrsf.SetTranslationPart(Period(i) * myDirections[i].Reversed());
BRepBuilderAPI_Transform aNegT(myShape, aNegTrsf, Standard_True);
// Split the negative side of the shape.
TopTools_ListOfShape aTools;
aTools.Append(aNegT.Shape());
SplitShape(aTools, mySplitHistory);
}
}
//=======================================================================
//function : AddTwin
//purpose : Associates the shape <theS> with the shape <theTwin> in the map.
//=======================================================================
static void AddTwin(const TopoDS_Shape& theS,
const TopoDS_Shape& theTwin,
TopTools_DataMapOfShapeListOfShape& theMap)
{
TopTools_ListOfShape *aTwins = theMap.ChangeSeek(theS);
if (!aTwins)
{
theMap.Bound(theS, TopTools_ListOfShape())->Append(theTwin);
return;
}
// Check if the twin shape is not yet present in the list
TopTools_ListIteratorOfListOfShape itLT(*aTwins);
for (; itLT.More(); itLT.Next())
{
if (theTwin.IsSame(itLT.Value()))
break;
}
if (!itLT.More())
aTwins->Append(theTwin);
}
//=======================================================================
//function : SplitPositive
//purpose : Split the positive side of the shape with the geometry of the
// negative side. Associate the identical opposite sub-shapes.
//=======================================================================
void BOPAlgo_MakePeriodic::SplitPositive()
{
// Prepare map of the sub-shapes of the input shape to make
// associations of the opposite shapes
TopTools_IndexedMapOfShape aSubShapesMap;
TopExp::MapShapes(myShape, aSubShapesMap);
const Standard_Integer aNbS = aSubShapesMap.Extent();
// Translate the shape to the positive periodic directions to make the
// shapes look identical on the opposite sides.
TopTools_ListOfShape aTools;
// Remember the history of shapes translation
TopTools_IndexedDataMapOfShapeListOfShape aTranslationHistMap;
// Make translations for all periodic directions
for (Standard_Integer i = 0; i < 3; ++i)
{
if (!IsPeriodic(i))
continue;
// Translate the shape to the positive side
gp_Trsf aPosTrsf;
aPosTrsf.SetTranslationPart(Period(i) * myDirections[i]);
BRepBuilderAPI_Transform aTranslator(myShape, aPosTrsf, Standard_True);
aTools.Append(aTranslator.Shape());
// Fill the translation history map
for (Standard_Integer i = 1; i <= aNbS; ++i)
{
const TopoDS_Shape& aS = aSubShapesMap(i);
if (BRepTools_History::IsSupportedType(aS))
{
const TopTools_ListOfShape& aSM = aTranslator.Modified(aS);
TopTools_ListOfShape* pTS = aTranslationHistMap.ChangeSeek(aS);
if (!pTS)
pTS = &aTranslationHistMap(aTranslationHistMap.Add(aS, TopTools_ListOfShape()));
pTS->Append(aSM.First());
}
}
}
// Keep the split shape history and history of tools modifications
// during the split for making association of the opposite identical shapes
Handle(BRepTools_History) aSplitShapeHist = new BRepTools_History,
aSplitToolsHist = new BRepTools_History;
// Split the positive side of the shape
SplitShape(aTools, aSplitShapeHist, aSplitToolsHist);
if (HasErrors())
return;
mySplitHistory->Merge(aSplitShapeHist);
// Make associations between identical opposite sub-shapes
const Standard_Integer aNbSH = aTranslationHistMap.Extent();
for (Standard_Integer i = 1; i <= aNbSH; ++i)
{
const TopoDS_Shape* pS = &aTranslationHistMap.FindKey(i);
const TopTools_ListOfShape& aSIm = aSplitShapeHist->Modified(*pS);
if (aSIm.Extent() == 1)
pS = &aSIm.First();
else if (aSIm.Extent() > 1)
continue;
const TopTools_ListOfShape& aLTranslated = aTranslationHistMap(i);
TopTools_ListIteratorOfListOfShape itLT(aLTranslated);
for (; itLT.More(); itLT.Next())
{
const TopoDS_Shape& aT = itLT.Value();
// Get shapes modifications during the split
const TopTools_ListOfShape& aTSplits = aSplitToolsHist->Modified(aT);
// Associate the shapes to each other
TopTools_ListIteratorOfListOfShape itSp(aTSplits);
for (; itSp.More(); itSp.Next())
{
const TopoDS_Shape& aSp = itSp.Value();
AddTwin(*pS, aSp, myTwins);
AddTwin(aSp, *pS, myTwins);
}
}
}
}
//=======================================================================
//function : SplitShape
//purpose : Splits the shape by the given tools
//=======================================================================
void BOPAlgo_MakePeriodic::SplitShape(const TopTools_ListOfShape& theTools,
Handle(BRepTools_History) theSplitShapeHistory,
Handle(BRepTools_History) theSplitToolsHistory)
{
// Make sure that the geometry from the tools will be copied to the split
// shape. For that, the tool shapes should be given to the Boolean Operations
// algorithm before the shape itself. This will make all coinciding parts
// use the geometry of the first argument.
// Intersection tool for passing ordered arguments
BOPAlgo_PaveFiller anIntersector;
anIntersector.SetArguments(theTools);
// Add the shape
anIntersector.AddArgument(myShape);
// Use gluing to speed-up intersections
anIntersector.SetGlue(BOPAlgo_GlueShift);
// Use safe input mode, to avoid reusing geometry of the shape
anIntersector.SetNonDestructive(Standard_True);
// Set parallel processing mode
anIntersector.SetRunParallel(myRunParallel);
// Perform Intersection of the arguments
anIntersector.Perform();
// Check for the errors
if (anIntersector.HasErrors())
{
// Unable to split the shape on opposite sides
// Copy the intersection errors
myReport->Merge(anIntersector.GetReport());
// Add new error saving the shapes for analysis
TopoDS_Compound aWS;
AddToShape(theTools, aWS);
AddToShape(myShape, aWS);
AddError(new BOPAlgo_AlertUnableToMakeIdentical(aWS));
return;
}
// Perform the splitting of the shape with the precomputed intersection results
BRepAlgoAPI_Splitter aSplitter(anIntersector);
// Set Object
TopTools_ListOfShape anObj;
anObj.Append(myShape);
aSplitter.SetArguments(anObj);
// Set Tools
aSplitter.SetTools(theTools);
// Use Gluing
aSplitter.SetGlue(BOPAlgo_GlueShift);
// Set parallel processing mode
aSplitter.SetRunParallel(myRunParallel);
// Perform splitting
aSplitter.Build();
// Check for the errors
if (aSplitter.HasErrors())
{
// Unable to split the shape on opposite sides
// Copy the splitter errors
myReport->Merge(aSplitter.GetReport());
// Add new error saving the shape for analysis
TopoDS_Compound aWS;
AddToShape(theTools, aWS);
AddToShape(myShape, aWS);
AddError(new BOPAlgo_AlertUnableToMakeIdentical(aWS));
return;
}
// Get the split shape
myShape = aSplitter.Shape();
// Remember the split history
if (!theSplitShapeHistory.IsNull())
theSplitShapeHistory->Merge(anObj, aSplitter);
if (!theSplitToolsHistory.IsNull())
theSplitToolsHistory->Merge(theTools, aSplitter);
}
//=======================================================================
//function : RepeatShape
//purpose : Repeats the shape in the required periodic direction
//=======================================================================
const TopoDS_Shape& BOPAlgo_MakePeriodic::RepeatShape(const Standard_Integer theDir,
const Standard_Integer theTimes)
{
if (myRepeatedShape.IsNull())
myRepeatedShape = myShape;
if (!IsPeriodic(theDir))
return myRepeatedShape;
if (theTimes == 0)
return myRepeatedShape;
// Get the shape's period in the required direction
const Standard_Integer id = BOPAlgo_MakePeriodic::ToDirectionID(theDir);
if (myRepeatPeriod[id] < Precision::Confusion())
myRepeatPeriod[id] = Period(id);
const Standard_Real aPeriod = myRepeatPeriod[id];
// Coefficient to define in which direction the repetition will be performed:
// theTimes is positive - in positive direction;
// theTimes is negative - in negative direction.
const Standard_Integer iDir = theTimes > 0 ? 1 : -1;
// Create the translation history - all translated shapes will be
// created as Generated from the shape.
BRepTools_History aTranslationHistory;
TopTools_IndexedMapOfShape aSubShapesMap;
TopExp::MapShapes(myRepeatedShape, aSubShapesMap);
const Standard_Integer aNbS = aSubShapesMap.Extent();
// Add shapes for gluing
TopTools_ListOfShape aShapes;
// Add the shape itself
aShapes.Append(myRepeatedShape);
for (Standard_Integer i = 1; i <= aNbS; ++i)
{
const TopoDS_Shape& aS = aSubShapesMap(i);
if (BRepTools_History::IsSupportedType(aS))
aTranslationHistory.AddGenerated(aS, aS);
}
// Create translated copies of the shape
for (Standard_Integer i = 1; i <= Abs(theTimes); ++i)
{
gp_Trsf aTrsf;
aTrsf.SetTranslationPart(iDir * i * aPeriod * myDirections[theDir]);
BRepBuilderAPI_Transform aTranslator(myRepeatedShape, aTrsf, Standard_True);
aShapes.Append(aTranslator.Shape());
// Fill the translation history
for (Standard_Integer i = 1; i <= aNbS; ++i)
{
const TopoDS_Shape& aS = aSubShapesMap(i);
if (BRepTools_History::IsSupportedType(aS))
{
const TopTools_ListOfShape& aLT = aTranslator.Modified(aS);
aTranslationHistory.AddGenerated(aS, aLT.First());
}
}
}
// Update the history with the translation History
myHistory->Merge(aTranslationHistory);
// Glue the translated shapes all together
BOPAlgo_Builder aGluer;
aGluer.SetArguments(aShapes);
// Avoid intersections of the sub-shapes
aGluer.SetGlue(BOPAlgo_GlueFull);
// Set parallel processing mode
aGluer.SetRunParallel(myRunParallel);
// Perform gluing
aGluer.Perform();
if (aGluer.HasErrors())
{
// Repetition in this direction is not possible
// Add warning saving the shapes for analysis
TopoDS_Compound aWS;
AddToShape(aShapes, aWS);
AddWarning(new BOPAlgo_AlertUnableToRepeat(aWS));
return myRepeatedShape;
}
// Get glued shape
myRepeatedShape = aGluer.Shape();
// Update repetition period for the next repetitions
myRepeatPeriod[id] += Abs(theTimes) * myRepeatPeriod[id];
// Update history with the Gluing history
BRepTools_History aGluingHistory(aShapes, aGluer);
myHistory->Merge(aGluingHistory);
// Update the map of twins after repetition
UpdateTwins(aTranslationHistory, aGluingHistory);
return myRepeatedShape;
}
//=======================================================================
//function : UpdateTwins
//purpose : Updates the map of twins after repetition
//=======================================================================
void BOPAlgo_MakePeriodic::UpdateTwins(const BRepTools_History& theTranslationHistory,
const BRepTools_History& theGluingHistory)
{
if (myTwins.IsEmpty())
return;
if (myRepeatedTwins.IsEmpty())
myRepeatedTwins = myTwins;
// New twins
TopTools_DataMapOfShapeListOfShape aNewTwinsMap;
// Fence map to avoid repeated fill for the twins
TopTools_MapOfShape aMTwinsDone;
// Update the map of twins with the new repeated shapes
TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itDMap(myRepeatedTwins);
for (; itDMap.More(); itDMap.Next())
{
const TopoDS_Shape& aS = itDMap.Key();
aMTwinsDone.Add(aS);
const TopTools_ListOfShape& aLTwins = itDMap.Value();
// Check if the twins have not been already processed
TopTools_ListIteratorOfListOfShape itLT(aLTwins);
for (; itLT.More(); itLT.Next())
{
if (aMTwinsDone.Contains(itLT.Value()))
break;
}
if (itLT.More())
// Group of twins has already been processed
continue;
// All shapes generated from the shape itself and generated
// from its twins will be the new twins for the shape
TopTools_IndexedMapOfShape aNewGroup;
itLT.Initialize(aLTwins);
for (Standard_Boolean bShape = Standard_True; itLT.More();)
{
const TopoDS_Shape& aTwin = bShape ? aS : itLT.Value();
const TopTools_ListOfShape& aLG = theTranslationHistory.Generated(aTwin);
TopTools_ListIteratorOfListOfShape itLG(aLG);
for (; itLG.More(); itLG.Next())
{
const TopoDS_Shape& aG = itLG.Value();
const TopTools_ListOfShape& aLM = theGluingHistory.Modified(aG);
if (aLM.IsEmpty())
aNewGroup.Add(aG);
else
{
TopTools_ListIteratorOfListOfShape itLM(aLM);
for (; itLM.More(); itLM.Next())
aNewGroup.Add(itLM.Value());
}
}
if (bShape)
bShape = Standard_False;
else
itLT.Next();
}
// Associate the twins to each other
const Standard_Integer aNbTwins = aNewGroup.Extent();
for (Standard_Integer i = 1; i <= aNbTwins; ++i)
{
TopTools_ListOfShape* pTwins = aNewTwinsMap.Bound(aNewGroup(i), TopTools_ListOfShape());
for (Standard_Integer j = 1; j <= aNbTwins; ++j)
if (i != j) pTwins->Append(aNewGroup(j));
}
}
myRepeatedTwins = aNewTwinsMap;
}

View File

@@ -0,0 +1,607 @@
// Created on: 2018-03-16
// Created by: Eugeny MALTCHIKOV
// Copyright (c) 2018 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BOPAlgo_MakePeriodic_HeaderFile
#define _BOPAlgo_MakePeriodic_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <BOPAlgo_Options.hxx>
#include <BRepTools_History.hxx>
#include <Standard_Boolean.hxx>
#include <TopoDS_Shape.hxx>
#include <TopTools_DataMapOfShapeShape.hxx>
//! BOPAlgo_MakePeriodic is the tool for making an arbitrary shape periodic
//! in 3D space in specified directions.
//!
//! Periodicity of the shape means that the shape can be repeated in any
//! periodic direction any number of times without creation of the new
//! geometry or splits.
//!
//! The idea is to make the shape look identical on the opposite sides of the
//! periodic directions, so when translating the copy of a shape on the period
//! there will be no coinciding parts of different dimensions.
//!
//! If necessary the algorithm will trim the shape to fit it into the
//! requested period by splitting it by the planes limiting the shape's
//! requested period.
//!
//! For making the shape periodic in certain direction the algorithm performs
//! the following steps:
//! * Creates the copy of the shape and moves it on the period into negative
//! side of the requested direction;
//! * Splits the negative side of the shape by the moved copy, ensuring copying
//! of the geometry from positive side to negative;
//! * Creates the copy of the shape (with already split negative side) and moves
//! it on the period into the positive side of the requested direction;
//! * Splits the positive side of the shape by the moved copy, ensuring copying
//! of the geometry from negative side to positive.
//!
//! The algorithm also associates the identical (or twin) shapes located
//! on the opposite sides of the result shape.
//! Using the *GetTwins()* method it is possible to get the twin shapes from
//! the opposite sides.
//!
//! Algorithm also provides the methods to repeat the periodic shape in
//! periodic directions. The subsequent repetitions are performed on the
//! repeated shape, thus repeating the shape two times in X direction will
//! create result in three shapes (original plus two copies).
//! Single subsequent repetition will result already in 6 shapes.
//! The repetitions can be cleared and started over.
//!
//! The algorithm supports History of shapes modifications, thus
//! it is possible to track how the shape has been changed to make it periodic
//! and what new shapes have been created during repetitions.
//!
//! The algorithm supports the parallel processing mode, which allows faster
//! completion of the operations.
//!
//! The algorithm supports the Error/Warning system and returns the following alerts:
//! - *BOPAlgo_AlertNoPeriodicityRequired* - Error alert is given if no periodicity
//! has been requested in any direction;
//! - *BOPAlgo_AlertUnableToTrim* - Error alert is given if the trimming of the shape
//! for fitting it into requested period has failed;
//! - *BOPAlgo_AlertUnableToMakeIdentical* - Error alert is given if splitting of the
//! shape by its moved copies has failed;
//! - *BOPAlgo_AlertUnableToRepeat* - Warning alert is given if the gluing of the repeated
//! shapes has failed.
//!
//! Example of usage of the algorithm:
//! ~~~~
//! TopoDS_Shape aShape = ...; // The shape to make periodic
//! Standard_Boolean bMakeXPeriodic = ...; // Flag for making or not the shape periodic in X direction
//! Standard_Real aXPeriod = ...; // X period for the shape
//! Standard_Boolean isXTrimmed = ...; // Flag defining whether it is necessary to trimming
//! // the shape to fit to X period
//! Standard_Real aXFirst = ...; // Start of the X period
//! // (really necessary only if the trimming is requested)
//! Standard_Boolean bRunParallel = ...; // Parallel processing mode or single
//!
//! BOPAlgo_MakePeriodic aPeriodicityMaker; // Periodicity maker
//! aPeriodicityMaker.SetShape(aShape); // Set the shape
//! aPeriodicityMaker.MakeXPeriodic(bMakePeriodic, aXPeriod); // Making the shape periodic in X direction
//! aPeriodicityMaker.SetTrimmed(isXTrimmed, aXFirst); // Trim the shape to fit X period
//! aPeriodicityMaker.SetRunParallel(bRunParallel); // Set the parallel processing mode
//! aPeriodicityMaker.Perform(); // Performing the operation
//!
//! if (aPeriodicityMaker.HasErrors()) // Check for the errors
//! {
//! // errors treatment
//! Standard_SStream aSStream;
//! aPeriodicityMaker.DumpErrors(aSStream);
//! return;
//! }
//! if (aPeriodicityMaker.HasWarnings()) // Check for the warnings
//! {
//! // warnings treatment
//! Standard_SStream aSStream;
//! aPeriodicityMaker.DumpWarnings(aSStream);
//! }
//! const TopoDS_Shape& aPeriodicShape = aPeriodicityMaker.Shape(); // Result periodic shape
//!
//!
//! aPeriodicityMaker.XRepeat(2); // Making repetitions
//! const TopoDS_Shape& aRepeat = aPeriodicityMaker.RepeatedShape(); // Getting the repeated shape
//! aPeriodicityMaker.ClearRepetitions(); // Clearing the repetitions
//! ~~~~
//!
class BOPAlgo_MakePeriodic : public BOPAlgo_Options
{
public:
DEFINE_STANDARD_ALLOC
public: //! @name Constructor
//! Empty constructor
BOPAlgo_MakePeriodic() : BOPAlgo_Options()
{
myDirections[0] = gp::DX();
myDirections[1] = gp::DY();
myDirections[2] = gp::DZ();
myRepeatPeriod[0] = myRepeatPeriod[1] = myRepeatPeriod[2] = 0.0;
}
public: //! @name Setting the shape to make it periodic
//! Sets the shape to make it periodic.
//! @param theShape [in] The shape to make periodic.
void SetShape(const TopoDS_Shape& theShape)
{
myInputShape = theShape;
}
public: //! @name Definition of the structure to keep all periodicity parameters
//! Structure to keep all periodicity parameters:
struct PeriodicityParams
{
PeriodicityParams()
{
Clear();
}
//! Returns all previously set parameters to default values
void Clear()
{
myPeriodic[0] = myPeriodic[1] = myPeriodic[2] = Standard_False;
myPeriod[0] = myPeriod[1] = myPeriod[2] = 0.0;
myIsTrimmed[0] = myIsTrimmed[1] = myIsTrimmed[2] = Standard_True;
myPeriodFirst[0] = myPeriodFirst[1] = myPeriodFirst[2] = 0.0;
}
Standard_Boolean myPeriodic[3]; //!< Array of flags defining whether the shape should be
//! periodic in XYZ directions
Standard_Real myPeriod[3]; //!< Array of XYZ period values. Defining the period for any
//! direction the corresponding flag for that direction in
//! myPeriodic should be set to true
Standard_Boolean myIsTrimmed[3]; //!< Array of flags defining whether the input shape has to be
//! trimmed to fit the required period in the required direction
Standard_Real myPeriodFirst[3]; //!< Array of start parameters of the XYZ periods: required for trimming
};
public: //! @name Setters/Getters for periodicity parameters structure
//! Sets the periodicity parameters.
//! @param theParams [in] Periodicity parameters
void SetPeriodicityParameters(const PeriodicityParams& theParams)
{
myPeriodicityParams = theParams;
}
const PeriodicityParams& PeriodicityParameters() const
{
return myPeriodicityParams;
}
public: //! @name Methods for setting/getting periodicity info using ID as a direction
//! Sets the flag to make the shape periodic in specified direction:
//! - 0 - X direction;
//! - 1 - Y direction;
//! - 2 - Z direction.
//!
//! @param theDirectionID [in] The direction's ID;
//! @param theIsPeriodic [in] Flag defining periodicity in given direction;
//! @param thePeriod [in] Required period in given direction.
void MakePeriodic(const Standard_Integer theDirectionID,
const Standard_Boolean theIsPeriodic,
const Standard_Real thePeriod = 0.0)
{
Standard_Integer id = ToDirectionID(theDirectionID);
myPeriodicityParams.myPeriodic[id] = theIsPeriodic;
myPeriodicityParams.myPeriod[id] = theIsPeriodic ? thePeriod : 0.0;
}
//! Returns the info about Periodicity of the shape in specified direction.
//! @param theDirectionID [in] The direction's ID.
Standard_Boolean IsPeriodic(const Standard_Integer theDirectionID) const
{
return myPeriodicityParams.myPeriodic[ToDirectionID(theDirectionID)];
}
//! Returns the Period of the shape in specified direction.
//! @param theDirectionID [in] The direction's ID.
Standard_Real Period(const Standard_Integer theDirectionID) const
{
Standard_Integer id = ToDirectionID(theDirectionID);
return myPeriodicityParams.myPeriodic[id] ? myPeriodicityParams.myPeriod[id] : 0.0;
}
public: //! @name Named methods for setting/getting info about shape's periodicity
//! Sets the flag to make the shape periodic in X direction.
//! @param theIsPeriodic [in] Flag defining periodicity in X direction;
//! @param thePeriod [in] Required period in X direction.
void MakeXPeriodic(const Standard_Boolean theIsPeriodic,
const Standard_Real thePeriod = 0.0)
{
MakePeriodic(0, theIsPeriodic, thePeriod);
}
//! Returns the info about periodicity of the shape in X direction.
Standard_Boolean IsXPeriodic() const { return IsPeriodic(0); }
//! Returns the XPeriod of the shape
Standard_Real XPeriod() const { return Period(0); }
//! Sets the flag to make the shape periodic in Y direction.
//! @param theIsPeriodic [in] Flag defining periodicity in Y direction;
//! @param thePeriod [in] Required period in Y direction.
void MakeYPeriodic(const Standard_Boolean theIsPeriodic,
const Standard_Real thePeriod = 0.0)
{
MakePeriodic(1, theIsPeriodic, thePeriod);
}
//! Returns the info about periodicity of the shape in Y direction.
Standard_Boolean IsYPeriodic() const { return IsPeriodic(1); }
//! Returns the YPeriod of the shape.
Standard_Real YPeriod() const { return Period(1); }
//! Sets the flag to make the shape periodic in Z direction.
//! @param theIsPeriodic [in] Flag defining periodicity in Z direction;
//! @param thePeriod [in] Required period in Z direction.
void MakeZPeriodic(const Standard_Boolean theIsPeriodic,
const Standard_Real thePeriod = 0.0)
{
MakePeriodic(2, theIsPeriodic, thePeriod);
}
//! Returns the info about periodicity of the shape in Z direction.
Standard_Boolean IsZPeriodic() const { return IsPeriodic(2); }
//! Returns the XPeriod of the shape.
Standard_Real ZPeriod() const { return Period(2); }
public: //! @name Methods for setting/getting trimming info taking Direction ID as a parameter
//! Defines whether the input shape is already trimmed in specified direction
//! to fit the period in this direction.
//! Direction is defined by an ID:
//! - 0 - X direction;
//! - 1 - Y direction;
//! - 2 - Z direction.
//!
//! If the shape is not trimmed it is required to set the first parameter
//! of the period in that direction.
//! The algorithm will make the shape fit into the period.
//!
//! Before calling this method, the shape has to be set to be periodic in this direction.
//!
//! @param theDirectionID [in] The direction's ID;
//! @param theIsTrimmed [in] The flag defining trimming of the shape in given direction;
//! @param theFirst [in] The first periodic parameter in the given direction.
void SetTrimmed(const Standard_Integer theDirectionID,
const Standard_Boolean theIsTrimmed,
const Standard_Real theFirst = 0.0)
{
Standard_Integer id = ToDirectionID(theDirectionID);
if (IsPeriodic(id))
{
myPeriodicityParams.myIsTrimmed[id] = theIsTrimmed;
myPeriodicityParams.myPeriodFirst[id] = !theIsTrimmed ? theFirst : 0.0;
}
}
//! Returns whether the input shape was trimmed in the specified direction.
//! @param theDirectionID [in] The direction's ID.
Standard_Boolean IsInputTrimmed(const Standard_Integer theDirectionID) const
{
return myPeriodicityParams.myIsTrimmed[ToDirectionID(theDirectionID)];
}
//! Returns the first periodic parameter in the specified direction.
//! @param theDirectionID [in] The direction's ID.
Standard_Real PeriodFirst(const Standard_Integer theDirectionID) const
{
Standard_Integer id = ToDirectionID(theDirectionID);
return !myPeriodicityParams.myIsTrimmed[id] ? myPeriodicityParams.myPeriodFirst[id] : 0.0;
}
public: //! @name Named methods for setting/getting trimming info
//! Defines whether the input shape is already trimmed by in X direction
//! to fit the X period. If the shape is not trimmed it is required
//! to set the first parameter for the X period.
//! The algorithm will make the shape fit into the period.
//!
//! Before calling this method, the shape has to be set to be periodic in this direction.
//!
//! @param theIsTrimmed [in] Flag defining whether the shape is already trimmed
//! in X direction to fit the X period;
//! @param theFirst [in] The first X periodic parameter.
void SetXTrimmed(const Standard_Boolean theIsTrimmed,
const Standard_Boolean theFirst = 0.0)
{
SetTrimmed(0, theIsTrimmed, theFirst);
}
//! Returns whether the input shape was already trimmed for X period.
Standard_Boolean IsInputXTrimmed() const
{
return IsInputTrimmed(0);
}
//! Returns the first parameter for the X period.
Standard_Real XPeriodFirst() const
{
return PeriodFirst(0);
}
//! Defines whether the input shape is already trimmed by in Y direction
//! to fit the Y period. If the shape is not trimmed it is required
//! to set the first parameter for the Y period.
//! The algorithm will make the shape fit into the period.
//!
//! Before calling this method, the shape has to be set to be periodic in this direction.
//!
//! @param theIsTrimmed [in] Flag defining whether the shape is already trimmed
//! in Y direction to fit the Y period;
//! @param theFirst [in] The first Y periodic parameter.
void SetYTrimmed(const Standard_Boolean theIsTrimmed,
const Standard_Boolean theFirst = 0.0)
{
SetTrimmed(1, theIsTrimmed, theFirst);
}
//! Returns whether the input shape was already trimmed for Y period.
Standard_Boolean IsInputYTrimmed() const
{
return IsInputTrimmed(1);
}
//! Returns the first parameter for the Y period.
Standard_Real YPeriodFirst() const
{
return PeriodFirst(1);
}
//! Defines whether the input shape is already trimmed by in Z direction
//! to fit the Z period. If the shape is not trimmed it is required
//! to set the first parameter for the Z period.
//! The algorithm will make the shape fit into the period.
//!
//! Before calling this method, the shape has to be set to be periodic in this direction.
//!
//! @param theIsTrimmed [in] Flag defining whether the shape is already trimmed
//! in Z direction to fit the Z period;
//! @param theFirst [in] The first Z periodic parameter.
void SetZTrimmed(const Standard_Boolean theIsTrimmed,
const Standard_Boolean theFirst = 0.0)
{
SetTrimmed(2, theIsTrimmed, theFirst);
}
//! Returns whether the input shape was already trimmed for Z period.
Standard_Boolean IsInputZTrimmed() const
{
return IsInputTrimmed(2);
}
//! Returns the first parameter for the Z period.
Standard_Real ZPeriodFirst() const
{
return PeriodFirst(2);
}
public: //! @name Performing the operation
//! Makes the shape periodic in necessary directions
Standard_EXPORT void Perform();
public: //! @name Using the algorithm to repeat the shape
//! Performs repetition of the shape in specified direction
//! required number of times.
//! Negative value of times means that the repetition should
//! be perform in negative direction.
//! Makes the repeated shape a base for following repetitions.
//!
//! @param theDirectionID [in] The direction's ID;
//! @param theTimes [in] Requested number of repetitions.
Standard_EXPORT const TopoDS_Shape& RepeatShape(const Standard_Integer theDirectionID,
const Standard_Integer theTimes);
//! Repeats the shape in X direction specified number of times.
//! Negative value of times means that the repetition should be
//! perform in negative X direction.
//! Makes the repeated shape a base for following repetitions.
//!
//! @param theTimes [in] Requested number of repetitions.
const TopoDS_Shape& XRepeat(const Standard_Integer theTimes)
{
return RepeatShape(0, theTimes);
}
//! Repeats the shape in Y direction specified number of times.
//! Negative value of times means that the repetition should be
//! perform in negative Y direction.
//! Makes the repeated shape a base for following repetitions.
//!
//! @param theTimes [in] Requested number of repetitions.
const TopoDS_Shape& YRepeat(const Standard_Integer theTimes)
{
return RepeatShape(1, theTimes);
}
//! Repeats the shape in Z direction specified number of times.
//! Negative value of times means that the repetition should be
//! perform in negative Z direction.
//! Makes the repeated shape a base for following repetitions.
//!
//! @param theTimes [in] Requested number of repetitions.
const TopoDS_Shape& ZRepeat(const Standard_Integer theTimes)
{
return RepeatShape(2, theTimes);
}
public: //! @name Starting the repetitions over
//! Returns the repeated shape
const TopoDS_Shape& RepeatedShape() const { return myRepeatedShape; }
//! Clears all performed repetitions.
//! The next repetition will be performed on the base shape.
void ClearRepetitions()
{
myRepeatPeriod[0] = myRepeatPeriod[1] = myRepeatPeriod[2] = 0.0;
myRepeatedShape.Nullify();
myRepeatedTwins.Clear();
if (!myHistory.IsNull())
{
myHistory->Clear();
if (!mySplitHistory.IsNull())
myHistory->Merge(mySplitHistory);
}
}
public: //! @name Obtaining the result shape
//! Returns the resulting periodic shape
const TopoDS_Shape& Shape() const { return myShape; }
public: //! @name Getting the identical shapes
//! Returns the identical shapes for the given shape located
//! on the opposite periodic side.
//! Returns empty list in case the shape has no twin.
//!
//! @param theS [in] Shape to get the twins for.
const TopTools_ListOfShape& GetTwins(const TopoDS_Shape& theS) const
{
static TopTools_ListOfShape empty;
const TopTools_ListOfShape* aTwins =
myRepeatedTwins.IsEmpty() ? myTwins.Seek(theS) : myRepeatedTwins.Seek(theS);
return (aTwins ? *aTwins : empty);
}
public: //! @name Getting the History of the algorithm
//! Returns the History of the algorithm
const Handle(BRepTools_History)& History() const
{
return myHistory;
}
public: //! @name Clearing the algorithm from previous runs
//! Clears the algorithm from previous runs
void Clear()
{
BOPAlgo_Options::Clear();
myPeriodicityParams.Clear();
myShape.Nullify();
if (!mySplitHistory.IsNull())
mySplitHistory->Clear();
if (!myHistory.IsNull())
myHistory->Clear();
ClearRepetitions();
}
public: //! @name Conversion of the integer to ID of periodic direction
//! Converts the integer to ID of periodic direction
static Standard_Integer ToDirectionID(const Standard_Integer theDirectionID)
{
return Abs(theDirectionID % 3);
}
protected: //! @name Protected methods performing the operation
//! Checks the validity of input data
Standard_EXPORT void CheckData();
//! Trims the shape to fit to the periodic bounds
Standard_EXPORT void Trim();
//! Makes the shape identical on opposite sides
Standard_EXPORT void MakeIdentical();
//! Splits the negative side of the shape with the geometry
//! located on the positive side copying the geometry from
//! positive side to the negative.
Standard_EXPORT void SplitNegative();
//! Splits the positive side of the shape with the geometry
//! located on the negative side of the shape.
//! Ensures that the geometries on the opposite sides will
//! be identical.
//! Associates the identical opposite sub-shapes.
Standard_EXPORT void SplitPositive();
//! Splits the shape by the given tools, copying the geometry of coinciding
//! parts from the given tools to the split shape.
//! @param theTools [in] The tools to split the shape and take the geometry
//! for coinciding parts.
//! @param theSplitShapeHistory [out] The history of shape split
//! @param theSplitToolsHistory [out] The history of tools modifications during the split
Standard_EXPORT void SplitShape(const TopTools_ListOfShape& theTools,
Handle(BRepTools_History) theSplitShapeHistory = NULL,
Handle(BRepTools_History) theSplitToolsHistory = NULL);
//! Updates the map of twins after periodic shape repetition.
//! @param theTranslationHistory [in] The history of translation of the periodic shape.
//! @param theGluingHistory [in] The history of gluing of the repeated shapes.
Standard_EXPORT void UpdateTwins(const BRepTools_History& theTranslationHistory,
const BRepTools_History& theGluingHistory);
protected: //! @name Fields
// Inputs
TopoDS_Shape myInputShape; //!< Input shape to make periodic
PeriodicityParams myPeriodicityParams; //!< Periodicity parameters
gp_Dir myDirections[3]; //!< Periodic directions
// Results
TopoDS_Shape myShape; //!< Resulting periodic shape (base for repetitions)
TopoDS_Shape myRepeatedShape; //!< Resulting shape after making repetitions of the base
Standard_Real myRepeatPeriod[3]; //!< XYZ repeat period
TopTools_DataMapOfShapeListOfShape myRepeatedTwins; //!< Map of associations of the identical sub-shapes
//! after repetition of the periodic shape
// Twins
TopTools_DataMapOfShapeListOfShape myTwins; //!< Map of associations of the identical sub-shapes
//! located on the opposite sides of the shape
// History
Handle(BRepTools_History) mySplitHistory; //!< Split history - history of shapes modification
//! after the split for making the shape periodic
Handle(BRepTools_History) myHistory; //!< Final history of shapes modifications
//! (to include the history of shape repetition)
};
#endif // _BOPAlgo_MakePeriodic_HeaderFile

View File

@@ -16,7 +16,9 @@
#include <BOPAlgo_BuilderSolid.hxx>
#include <BOPAlgo_MakerVolume.hxx>
#include <BOPAlgo_PaveFiller.hxx>
#include <BOPAlgo_Tools.hxx>
#include <BOPAlgo_Alerts.hxx>
#include <BOPAlgo_Tools.hxx>
#include <BOPCol_DataMapOfShapeListOfShape.hxx>
#include <BOPCol_ListOfShape.hxx>
#include <BOPDS_DS.hxx>
@@ -29,10 +31,6 @@
static
void AddFace(const TopoDS_Shape& theF,
BOPCol_ListOfShape& theLF);
static
void TreatCompound(const TopoDS_Shape& theS,
BOPCol_MapOfShape& aMFence,
BOPCol_ListOfShape& theLS);
//=======================================================================
//function : CheckData
@@ -94,6 +92,7 @@ void BOPAlgo_MakerVolume::Perform()
pPF->SetFuzzyValue(myFuzzyValue);
pPF->SetNonDestructive(myNonDestructive);
pPF->SetGlue(myGlue);
pPF->SetUseOBB(myUseOBB);
pPF->Perform();
//
myEntryPoint = 1;
@@ -257,7 +256,6 @@ void BOPAlgo_MakerVolume::BuildSolids(BOPCol_ListOfShape& theLSR)
//
BOPAlgo_BuilderSolid aBS;
//
aBS.SetSolid(mySBox);
aBS.SetShapes(myFaces);
aBS.SetRunParallel(myRunParallel);
aBS.SetAvoidInternalShapes(myAvoidInternalShapes);
@@ -268,6 +266,8 @@ void BOPAlgo_MakerVolume::BuildSolids(BOPCol_ListOfShape& theLSR)
return;
}
//
myReport->Merge(aBS.GetReport());
//
theLSR = aBS.Areas();
}
@@ -352,7 +352,7 @@ void BOPAlgo_MakerVolume::FillInternalShapes(const BOPCol_ListOfShape& theLSR)
aIt.Initialize(anArguments);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aS = aIt.Value();
TreatCompound(aS, aMFence, aLSC);
BOPAlgo_Tools::TreatCompound(aS, aMFence, aLSC);
}
//
aIt.Initialize(aLSC);
@@ -440,26 +440,3 @@ void AddFace(const TopoDS_Shape& theF,
aFF.Orientation(TopAbs_REVERSED);
theLF.Append(aFF);
}
//=======================================================================
//function : TreatCompound
//purpose :
//=======================================================================
void TreatCompound(const TopoDS_Shape& theS,
BOPCol_MapOfShape& aMFence,
BOPCol_ListOfShape& theLS)
{
TopAbs_ShapeEnum aType = theS.ShapeType();
if (aType != TopAbs_COMPOUND) {
if (aMFence.Add(theS)) {
theLS.Append(theS);
}
return;
}
//
TopoDS_Iterator aIt(theS);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aS = aIt.Value();
TreatCompound(aS, aMFence, theLS);
}
}

View File

@@ -50,7 +50,8 @@ BOPAlgo_Options::BOPAlgo_Options()
myAllocator(NCollection_BaseAllocator::CommonBaseAllocator()),
myReport(new Message_Report),
myRunParallel(myGlobalRunParallel),
myFuzzyValue(Precision::Confusion())
myFuzzyValue(Precision::Confusion()),
myUseOBB(Standard_False)
{
BOPAlgo_LoadMessages();
}
@@ -65,7 +66,8 @@ BOPAlgo_Options::BOPAlgo_Options
myAllocator(theAllocator),
myReport(new Message_Report),
myRunParallel(myGlobalRunParallel),
myFuzzyValue(Precision::Confusion())
myFuzzyValue(Precision::Confusion()),
myUseOBB(Standard_False)
{
BOPAlgo_LoadMessages();
}

View File

@@ -32,6 +32,8 @@ class Message_ProgressIndicator;
//! touching or coinciding cases;
//! - *Progress indicator* - provides interface to track the progress of
//! operation and stop the operation by user's break.
//! - *Using the Oriented Bounding Boxes* - Allows using the Oriented Bounding Boxes of the shapes
//! for filtering the intersections.
//!
class BOPAlgo_Options
{
@@ -156,6 +158,22 @@ public:
//! Set the Progress Indicator object.
Standard_EXPORT void SetProgressIndicator(const Handle(Message_ProgressIndicator)& theObj);
public:
//!@name Usage of Oriented Bounding boxes
//! Enables/Disables the usage of OBB
void SetUseOBB(const Standard_Boolean theUseOBB)
{
myUseOBB = theUseOBB;
}
//! Returns the flag defining usage of OBB
Standard_Boolean UseOBB() const
{
return myUseOBB;
}
protected:
//! Breaks the execution if the break signal
@@ -169,6 +187,7 @@ protected:
Standard_Boolean myRunParallel;
Standard_Real myFuzzyValue;
Handle(Message_ProgressIndicator) myProgressIndicator;
Standard_Boolean myUseOBB;
};

View File

@@ -169,22 +169,6 @@ void BOPAlgo_PaveFiller::SetSectionAttribute
mySectionAttribute = theSecAttr;
}
//=======================================================================
//function : SetArguments
//purpose :
//=======================================================================
void BOPAlgo_PaveFiller::SetArguments(const BOPCol_ListOfShape& theLS)
{
myArguments=theLS;
}
//=======================================================================
//function : Arguments
//purpose :
//=======================================================================
const BOPCol_ListOfShape& BOPAlgo_PaveFiller::Arguments()const
{
return myArguments;
}
//=======================================================================
// function: Init
// purpose:
//=======================================================================
@@ -211,14 +195,14 @@ void BOPAlgo_PaveFiller::Init()
myDS->SetArguments(myArguments);
myDS->Init(myFuzzyValue);
//
// 2.myIterator
// 2 myContext
myContext=new IntTools_Context;
//
// 3.myIterator
myIterator=new BOPDS_Iterator(myAllocator);
myIterator->SetRunParallel(myRunParallel);
myIterator->SetDS(myDS);
myIterator->Prepare();
//
// 3 myContext
myContext=new IntTools_Context;
myIterator->Prepare(myContext, myUseOBB, myFuzzyValue);
//
// 4 NonDestructive flag
SetNonDestructive();
@@ -285,6 +269,10 @@ void BOPAlgo_PaveFiller::PerformInternal()
}
UpdatePaveBlocksWithSDVertices();
UpdateInterfsWithSDVertices();
// Force intersection of edges after increase
// of the tolerance values of their vertices
ForceInterfEE();
//
// 22
PerformFF();

View File

@@ -87,13 +87,19 @@ class TopoDS_Face;
//! - *Gluing options* - allows to speed up the calculation on the special
//! cases, in which some sub-shapes are coincide.<br>
//!
//! The algorithm returns the following Warning statuses:<br>
//! - *BOPAlgo_AlertSelfInterferingShape* - in case some of the argument shapes are self-interfering shapes;<br>
//! - *BOPAlgo_AlertTooSmallEdge* - in case some edges of the input shapes have no valid range;<br>
//! The algorithm returns the following Warning statuses:
//! - *BOPAlgo_AlertSelfInterferingShape* - in case some of the argument shapes are self-interfering shapes;
//! - *BOPAlgo_AlertTooSmallEdge* - in case some edges of the input shapes have no valid range;
//! - *BOPAlgo_AlertNotSplittableEdge* - in case some edges of the input shapes has such a small
//! valid range so it cannot be split;<br>
//! valid range so it cannot be split;
//! - *BOPAlgo_AlertBadPositioning* - in case the positioning of the input shapes leads to creation
//! of small edges.<br>
//! of small edges;
//! - *BOPAlgo_AlertIntersectionOfPairOfShapesFailed* - in case intersection of some of the
//! sub-shapes has failed;
//! - *BOPAlgo_AlertAcquiredSelfIntersection* - in case some sub-shapes of the argument become connected
//! through other shapes;
//! - *BOPAlgo_AlertBuildingPCurveFailed* - in case building 2D curve for some of the edges
//! on the faces has failed.
//!
//! The algorithm returns the following Error alerts:
//! - *BOPAlgo_AlertTooFewArguments* - in case there are no enough arguments to
@@ -120,9 +126,23 @@ public:
Standard_EXPORT const BOPDS_PIterator& Iterator();
Standard_EXPORT void SetArguments (const BOPCol_ListOfShape& theLS);
Standard_EXPORT const BOPCol_ListOfShape& Arguments() const;
//! Sets the arguments for operation
void SetArguments (const BOPCol_ListOfShape& theLS)
{
myArguments = theLS;
}
//! Adds the argument for operation
void AddArgument(const TopoDS_Shape& theShape)
{
myArguments.Append(theShape);
}
//! Returns the list of arguments
const BOPCol_ListOfShape& Arguments() const
{
return myArguments;
}
Standard_EXPORT const Handle(IntTools_Context)& Context();
@@ -290,6 +310,7 @@ protected:
BOPDS_DataMapOfPaveBlockListOfPaveBlock& theDMExEdges,
BOPCol_DataMapOfIntegerInteger& theDMNewSD,
const BOPCol_IndexedMapOfShape& theMicroEdges,
const BOPCol_IndexedMapOfShape& theVertsOnRejectedPB,
const BOPCol_BaseAllocator& theAllocator);
Standard_EXPORT void FindPaveBlocks (const Standard_Integer theV, const Standard_Integer theF, BOPDS_ListOfPaveBlock& theLPB);
@@ -379,10 +400,11 @@ protected:
//! Updates tolerance of vertex with index <nV>
//! to make it interfere with edge
Standard_EXPORT void ForceInterfVE(const Standard_Integer nV,
Handle(BOPDS_PaveBlock)& aPB,
BOPCol_MapOfInteger& theMEdges);
//! to make it interfere with edge.
//! Returns TRUE if intersection happened.
Standard_EXPORT Standard_Boolean ForceInterfVE(const Standard_Integer nV,
Handle(BOPDS_PaveBlock)& aPB,
BOPCol_MapOfInteger& theMEdges);
//! Updates tolerance of vertex with index <nV>
//! to make it interfere with face with index <nF>
@@ -474,6 +496,14 @@ protected:
//! In case self-interference is found the warning is added.
Standard_EXPORT void CheckSelfInterference();
//! Adds the warning about failed intersection of pair of sub-shapes
Standard_EXPORT void AddIntersectionFailedWarning(const TopoDS_Shape& theS1, const TopoDS_Shape& theS2);
//! The method looks for the additional common blocks among pairs of edges
//! which did not participate in edges intersection (PerformEE() method)
//! due to being rejected by bounding boxes intersection.
Standard_EXPORT void ForceInterfEE();
BOPCol_ListOfShape myArguments;
BOPDS_PDS myDS;

View File

@@ -112,7 +112,8 @@ void BOPAlgo_PaveFiller::CheckSelfInterference()
}
//
if (aLE.Extent() > 1) {
// Add warning
// Add the acquired self-interference warning:
// The same common block contains several edges from one argument
TopoDS_Compound aWC;
aBB.MakeCompound(aWC);
//
@@ -122,7 +123,7 @@ void BOPAlgo_PaveFiller::CheckSelfInterference()
aBB.Add(aWC, aE1);
}
//
AddWarning (new BOPAlgo_AlertSelfInterferingShape (aWC));
AddWarning (new BOPAlgo_AlertAcquiredSelfIntersection (aWC));
}
}
}
@@ -168,7 +169,8 @@ void BOPAlgo_PaveFiller::CheckSelfInterference()
for (j = 1; j <= aNbC; ++j) {
const BOPCol_IndexedMapOfShape& aMCS = aMCSI(j);
if (aMCS.Extent() > 1) {
// Add self-interference warning
// Add acquired self-interference warning:
// Several faces from one argument contain the same vertex or edge
TopoDS_Compound aWC;
aBB.MakeCompound(aWC);
//
@@ -177,7 +179,7 @@ void BOPAlgo_PaveFiller::CheckSelfInterference()
const TopoDS_Shape& aSx = aMCS(iS);
aBB.Add(aWC, aSx);
}
AddWarning (new BOPAlgo_AlertSelfInterferingShape (aWC));
AddWarning (new BOPAlgo_AlertAcquiredSelfIntersection (aWC));
}
}
}

View File

@@ -17,6 +17,7 @@
#include <BOPAlgo_PaveFiller.hxx>
#include <BOPAlgo_Alerts.hxx>
#include <BOPAlgo_Tools.hxx>
#include <BOPCol_NCVector.hxx>
#include <BOPCol_Parallel.hxx>
@@ -27,6 +28,7 @@
#include <BOPDS_PaveBlock.hxx>
#include <BOPDS_VectorOfInterfVE.hxx>
#include <BOPTools_AlgoTools.hxx>
#include <BRep_Builder.hxx>
#include <BRep_Tool.hxx>
#include <gp_Pnt.hxx>
#include <IntTools_Context.hxx>
@@ -110,7 +112,16 @@ class BOPAlgo_VertexEdge : public BOPAlgo_Algo {
//
virtual void Perform() {
BOPAlgo_Algo::UserBreak();
myFlag=myContext->ComputeVE (myV, myE, myT, myTolVNew, myFuzzyValue);
try
{
OCC_CATCH_SIGNALS
myFlag=myContext->ComputeVE (myV, myE, myT, myTolVNew, myFuzzyValue);
}
catch (Standard_Failure)
{
AddError(new BOPAlgo_AlertIntersectionFailed);
}
};
//
protected:
@@ -267,6 +278,11 @@ void BOPAlgo_PaveFiller::IntersectVE
for (i = 0; i < aNbVE; ++i) {
const BOPAlgo_VertexEdge& aVESolver = aVVE(i);
if (aVESolver.Flag() != 0) {
if (aVESolver.HasErrors())
{
// Warn about failed intersection of sub-shapes
AddIntersectionFailedWarning(aVESolver.Vertex(), aVESolver.Edge());
}
continue;
}
//
@@ -491,3 +507,19 @@ void BOPAlgo_PaveFiller::SplitPaveBlocks(const BOPCol_MapOfInteger& theMEdges,
}
}
}
//=======================================================================
// function: AddIntersectionFailedWarning
// purpose:
//=======================================================================
void BOPAlgo_PaveFiller::AddIntersectionFailedWarning(const TopoDS_Shape& theS1,
const TopoDS_Shape& theS2)
{
// Create the warn shape
TopoDS_Compound aWC;
BRep_Builder().MakeCompound(aWC);
BRep_Builder().Add(aWC, theS1);
BRep_Builder().Add(aWC, theS2);
// Add the warning
AddWarning(new BOPAlgo_AlertIntersectionOfPairOfShapesFailed(aWC));
}

View File

@@ -45,6 +45,7 @@
#include <IntTools_SequenceOfRanges.hxx>
#include <IntTools_ShrunkRange.hxx>
#include <IntTools_Tools.hxx>
#include <NCollection_IncAllocator.hxx>
#include <Precision.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
@@ -93,7 +94,16 @@ class BOPAlgo_EdgeEdge :
//
virtual void Perform() {
BOPAlgo_Algo::UserBreak();
IntTools_EdgeEdge::Perform();
try
{
OCC_CATCH_SIGNALS
IntTools_EdgeEdge::Perform();
}
catch (Standard_Failure)
{
AddError(new BOPAlgo_AlertIntersectionFailed);
}
}
//
protected:
@@ -229,7 +239,11 @@ void BOPAlgo_PaveFiller::PerformEE()
Bnd_Box aBB1, aBB2;
//
BOPAlgo_EdgeEdge& anEdgeEdge=aVEdgeEdge(k);
if (!anEdgeEdge.IsDone()) {
if (!anEdgeEdge.IsDone() || anEdgeEdge.HasErrors()) {
// Warn about failed intersection of sub-shapes
const TopoDS_Shape& aE1 = myDS->Shape(anEdgeEdge.PaveBlock1()->OriginalEdge());
const TopoDS_Shape& aE2 = myDS->Shape(anEdgeEdge.PaveBlock2()->OriginalEdge());
AddIntersectionFailedWarning(aE1, aE2);
continue;
}
//
@@ -334,8 +348,7 @@ void BOPAlgo_PaveFiller::PerformEE()
if (bIsOnPave[j]) {
//add interf VE(nV[j], nE)
Handle(BOPDS_PaveBlock)& aPB = (j < 2) ? aPB2 : aPB1;
ForceInterfVE(nV[j], aPB, aMEdges);
bFlag = Standard_True;
bFlag = ForceInterfVE(nV[j], aPB, aMEdges);
break;
}
}
@@ -651,9 +664,9 @@ void BOPAlgo_PaveFiller::AnalyzeShrunkData(const Handle(BOPDS_PaveBlock)& thePB,
//function : ForceInterfVE
//purpose :
//=======================================================================
void BOPAlgo_PaveFiller::ForceInterfVE(const Standard_Integer nV,
Handle(BOPDS_PaveBlock)& aPB,
BOPCol_MapOfInteger& theMEdges)
Standard_Boolean BOPAlgo_PaveFiller::ForceInterfVE(const Standard_Integer nV,
Handle(BOPDS_PaveBlock)& aPB,
BOPCol_MapOfInteger& theMEdges)
{
Standard_Integer nE, nVx, nVSD, iFlag;
Standard_Real aT, aTolVNew;
@@ -662,20 +675,20 @@ void BOPAlgo_PaveFiller::ForceInterfVE(const Standard_Integer nV,
//
const BOPDS_ShapeInfo& aSIE=myDS->ShapeInfo(nE);
if (aSIE.HasSubShape(nV)) {
return;
return Standard_False;
}
//
if (myDS->HasInterf(nV, nE)) {
return;
return Standard_False;
}
//
if (myDS->HasInterfShapeSubShapes(nV, nE)) {
return;
return Standard_False;
}
//
if (aPB->Pave1().Index() == nV ||
aPB->Pave2().Index() == nV) {
return;
return Standard_False;
}
//
nVx = nV;
@@ -723,7 +736,9 @@ void BOPAlgo_PaveFiller::ForceInterfVE(const Standard_Integer nV,
BRep_Builder().Add(aWC, aE);
AddWarning (new BOPAlgo_AlertSelfInterferingShape (aWC));
}
return Standard_True;
}
return Standard_False;
}
//=======================================================================
@@ -768,3 +783,216 @@ Standard_Boolean BOPAlgo_PaveFiller::GetPBBox(const TopoDS_Edge& theE,
}
return bValid;
}
//=======================================================================
//function : ForceInterfEE
//purpose :
//=======================================================================
void BOPAlgo_PaveFiller::ForceInterfEE()
{
// Now that we have vertices increased and unified, try to find additional
// common blocks among the pairs of edges that did not participate in
// intersection (PerformEE() method) due to being rejected by bounding boxes.
// Here, we are interested in common blocks only, as all real intersections
// should have happened already. Thus, we need to look only for the same
// vertices in the pairs of pave blocks and check the coincidence of such pave blocks.
Handle(NCollection_IncAllocator) anAlloc = new NCollection_IncAllocator;
// Initialize pave blocks for all SD vertices
const Standard_Integer aNbS = myDS->NbSourceShapes();
for (Standard_Integer i = 0; i < aNbS; ++i)
{
const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(i);
if (aSI.ShapeType() == TopAbs_VERTEX)
{
Standard_Integer nVSD;
if (myDS->HasShapeSD(i, nVSD))
myDS->InitPaveBlocksForVertex(i);
}
}
// Find all Pave Blocks with both paves being SD vertices.
NCollection_IndexedDataMap<BOPDS_Pair,
BOPDS_ListOfPaveBlock,
BOPDS_PairMapHasher> aPBMap(1, anAlloc);
// Fence map of pave blocks
BOPDS_MapOfPaveBlock aMPBFence(1, anAlloc);
for (Standard_Integer i = 0; i < aNbS; ++i)
{
const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(i);
if (aSI.ShapeType() != TopAbs_EDGE)
// Not an edge
continue;
if (!aSI.HasReference())
// Edge has no pave blocks
continue;
if (aSI.HasFlag())
// Degenerated edge
continue;
const BOPDS_ListOfPaveBlock& aLPB = myDS->PaveBlocks(i);
BOPDS_ListIteratorOfListOfPaveBlock aItLPB(aLPB);
for (; aItLPB.More(); aItLPB.Next())
{
const Handle(BOPDS_PaveBlock)& aPB = aItLPB.Value();
const Handle(BOPDS_PaveBlock)& aPBR = myDS->RealPaveBlock(aPB);
if (!aMPBFence.Add(aPBR))
continue;
// Get indices
Standard_Integer nV1, nV2;
aPBR->Indices(nV1, nV2);
// Add pave block to a map
BOPDS_Pair aPair(nV1, nV2);
BOPDS_ListOfPaveBlock *pList = aPBMap.ChangeSeek(aPair);
if (!pList)
pList = &aPBMap(aPBMap.Add(aPair, BOPDS_ListOfPaveBlock(anAlloc)));
pList->Append(aPBR);
}
}
Standard_Integer aNbPB = aPBMap.Extent();
if (!aNbPB)
return;
// Find pairs of Pave Blocks having the same SD vertices
// and put them into the vector for parallel intersection.
BOPAlgo_VectorOfEdgeEdge aVEdgeEdge;
for (Standard_Integer i = 1; i <= aNbPB; ++i)
{
const BOPDS_ListOfPaveBlock& aLPB = aPBMap(i);
if (aLPB.Extent() < 2)
continue;
const BOPDS_Pair& aPair = aPBMap.FindKey(i);
Standard_Integer nV1, nV2;
aPair.Indices(nV1, nV2);
const TopoDS_Vertex& aV1 = TopoDS::Vertex(myDS->Shape(nV1));
const TopoDS_Vertex& aV2 = TopoDS::Vertex(myDS->Shape(nV2));
// Use the max tolerance of vertices as Fuzzy value for intersection
// of edges
Standard_Real aTolAdd = 2 * Max(BRep_Tool::Tolerance(aV1),
BRep_Tool::Tolerance(aV2));
// All possible pairs combined from the list <aLPB> should be checked
BOPDS_ListIteratorOfListOfPaveBlock aItLPB1(aLPB);
for (; aItLPB1.More(); aItLPB1.Next())
{
const Handle(BOPDS_PaveBlock)& aPB1 = aItLPB1.Value();
const Handle(BOPDS_CommonBlock)& aCB1 = myDS->CommonBlock(aPB1);
const Standard_Integer nE1 = aPB1->OriginalEdge();
const TopoDS_Edge& aE1 = TopoDS::Edge(myDS->Shape(nE1));
Standard_Real aT11, aT12;
aPB1->Range(aT11, aT12);
BOPDS_ListIteratorOfListOfPaveBlock aItLPB2 = aItLPB1;
for (aItLPB2.Next(); aItLPB2.More(); aItLPB2.Next())
{
const Handle(BOPDS_PaveBlock)& aPB2 = aItLPB2.Value();
const Handle(BOPDS_CommonBlock)& aCB2 = myDS->CommonBlock(aPB2);
const Standard_Integer nE2 = aPB2->OriginalEdge();
// Make sure that the edges came from different arguments
if (myDS->Rank(nE1) == myDS->Rank(nE2))
continue;
// Check that the Pave blocks do not form the Common block already
if (!aCB1.IsNull() && !aCB2.IsNull())
{
if (aCB1 == aCB2)
continue;
}
const TopoDS_Edge& aE2 = TopoDS::Edge(myDS->Shape(nE2));
Standard_Real aT21, aT22;
aPB2->Range(aT21, aT22);
// Add pair for intersection
BOPAlgo_EdgeEdge& anEdgeEdge = aVEdgeEdge.Append1();
anEdgeEdge.UseQuickCoincidenceCheck(Standard_True);
anEdgeEdge.SetPaveBlock1(aPB1);
anEdgeEdge.SetPaveBlock2(aPB2);
anEdgeEdge.SetEdge1(aE1, aT11, aT12);
anEdgeEdge.SetEdge2(aE2, aT21, aT22);
anEdgeEdge.SetFuzzyValue(myFuzzyValue + aTolAdd);
anEdgeEdge.SetProgressIndicator(myProgressIndicator);
}
}
}
Standard_Integer aNbPairs = aVEdgeEdge.Extent();
if (!aNbPairs)
return;
aPBMap.Clear();
aMPBFence.Clear();
anAlloc->Reset();
// Perform intersection of the found pairs
BOPAlgo_EdgeEdgeCnt::Perform(myRunParallel, aVEdgeEdge);
BOPDS_VectorOfInterfEE& aEEs = myDS->InterfEE();
if (aEEs.IsEmpty())
aEEs.SetIncrement(10);
// Analyze the results of intersection looking for TopAbs_EDGE
// intersection type only.
BOPDS_IndexedDataMapOfPaveBlockListOfPaveBlock aMPBLPB(1, anAlloc);
for (Standard_Integer i = 0; i < aNbPairs; ++i)
{
BOPAlgo_EdgeEdge& anEdgeEdge = aVEdgeEdge(i);
if (!anEdgeEdge.IsDone() || anEdgeEdge.HasErrors())
{
// Warn about failed intersection of sub-shapes
const TopoDS_Shape& aE1 = myDS->Shape(anEdgeEdge.PaveBlock1()->OriginalEdge());
const TopoDS_Shape& aE2 = myDS->Shape(anEdgeEdge.PaveBlock2()->OriginalEdge());
AddIntersectionFailedWarning(aE1, aE2);
continue;
}
const IntTools_SequenceOfCommonPrts& aCParts = anEdgeEdge.CommonParts();
if (aCParts.Length() != 1)
continue;
const IntTools_CommonPrt& aCP = aCParts(1);
if (aCP.Type() != TopAbs_EDGE)
continue;
Handle(BOPDS_PaveBlock) aPB[] = {anEdgeEdge.PaveBlock1(), anEdgeEdge.PaveBlock2()};
const Standard_Integer nE1 = aPB[0]->OriginalEdge();
const Standard_Integer nE2 = aPB[1]->OriginalEdge();
BOPDS_InterfEE& aEE = aEEs.Append1();
aEE.SetIndices(nE1, nE2);
aEE.SetCommonPart(aCP);
myDS->AddInterf(nE1, nE2);
// Fill map for common blocks creation
for (Standard_Integer j = 0; j < 2; ++j)
{
if (myDS->IsCommonBlock(aPB[j]))
{
const BOPDS_ListOfPaveBlock& aLPBCB = myDS->CommonBlock(aPB[j])->PaveBlocks();
BOPDS_ListIteratorOfListOfPaveBlock aItLPB(aLPBCB);
for (; aItLPB.More(); aItLPB.Next())
BOPAlgo_Tools::FillMap<Handle(BOPDS_PaveBlock),
TColStd_MapTransientHasher>(aPB[j], aItLPB.Value(), aMPBLPB, anAlloc);
}
}
BOPAlgo_Tools::FillMap<Handle(BOPDS_PaveBlock),
TColStd_MapTransientHasher>(aPB[0], aPB[1], aMPBLPB, anAlloc);
}
// Create new common blocks of coinciding pairs.
BOPAlgo_Tools::PerformCommonBlocks(aMPBLPB, anAlloc, myDS);
}

View File

@@ -17,6 +17,7 @@
#include <BOPAlgo_PaveFiller.hxx>
#include <BOPAlgo_Alerts.hxx>
#include <BOPAlgo_SectionAttribute.hxx>
#include <BOPCol_MapOfInteger.hxx>
#include <BOPCol_NCVector.hxx>
@@ -107,7 +108,16 @@ class BOPAlgo_VertexFace : public BOPAlgo_Algo {
//
virtual void Perform() {
BOPAlgo_Algo::UserBreak();
myFlag=myContext->ComputeVF(myV, myF, myT1, myT2, myTolVNew, myFuzzyValue);
try
{
OCC_CATCH_SIGNALS
myFlag=myContext->ComputeVF(myV, myF, myT1, myT2, myTolVNew, myFuzzyValue);
}
catch (Standard_Failure)
{
AddError(new BOPAlgo_AlertIntersectionFailed);
}
}
//
protected:
@@ -212,7 +222,12 @@ void BOPAlgo_PaveFiller::PerformVF()
const BOPAlgo_VertexFace& aVertexFace=aVVF(k);
//
iFlag=aVertexFace.Flag();
if (iFlag) {
if (iFlag != 0) {
if (aVertexFace.HasErrors())
{
// Warn about failed intersection of sub-shapes
AddIntersectionFailedWarning(aVertexFace.Vertex(), aVertexFace.Face());
}
continue;
}
//

View File

@@ -103,7 +103,16 @@ class BOPAlgo_EdgeFace :
//
virtual void Perform() {
BOPAlgo_Algo::UserBreak();
IntTools_EdgeFace::Perform();
try
{
OCC_CATCH_SIGNALS
IntTools_EdgeFace::Perform();
}
catch (Standard_Failure)
{
AddError(new BOPAlgo_AlertIntersectionFailed);
}
}
//
protected:
@@ -258,7 +267,9 @@ void BOPAlgo_PaveFiller::PerformEF()
//
for (k=0; k < aNbEdgeFace; ++k) {
BOPAlgo_EdgeFace& aEdgeFace=aVEdgeFace(k);
if (!aEdgeFace.IsDone()) {
if (!aEdgeFace.IsDone() || aEdgeFace.HasErrors()) {
// Warn about failed intersection of sub-shapes
AddIntersectionFailedWarning(aEdgeFace.Edge(), aEdgeFace.Face());
continue;
}
//

View File

@@ -48,6 +48,7 @@
#include <BRep_Builder.hxx>
#include <BRep_Tool.hxx>
#include <BRep_TEdge.hxx>
#include <BRepLib.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <BRepBndLib.hxx>
@@ -144,7 +145,16 @@ class BOPAlgo_FaceFace :
//
virtual void Perform() {
BOPAlgo_Algo::UserBreak();
IntTools_FaceFace::Perform(myF1, myF2);
try
{
OCC_CATCH_SIGNALS
IntTools_FaceFace::Perform(myF1, myF2);
}
catch (Standard_Failure)
{
AddError(new BOPAlgo_AlertIntersectionFailed);
}
}
//
protected:
@@ -198,34 +208,56 @@ void BOPAlgo_PaveFiller::PerformFF()
//
for (; myIterator->More(); myIterator->Next()) {
myIterator->Value(nF1, nF2);
//
const TopoDS_Face& aF1=(*(TopoDS_Face *)(&myDS->Shape(nF1)));
const TopoDS_Face& aF2=(*(TopoDS_Face *)(&myDS->Shape(nF2)));
//
if (aMIFence.Add(nF1)) {
myDS->UpdateFaceInfoOn(nF1);
myDS->UpdateFaceInfoIn(nF1);
}
if (aMIFence.Add(nF2)) {
myDS->UpdateFaceInfoOn(nF2);
myDS->UpdateFaceInfoIn(nF2);
}
//
const BRepAdaptor_Surface& aBAS1 = myContext->SurfaceAdaptor(aF1);
const BRepAdaptor_Surface& aBAS2 = myContext->SurfaceAdaptor(aF2);
if (aBAS1.GetType() == GeomAbs_Plane &&
aBAS2.GetType() == GeomAbs_Plane) {
// Check if the planes are really interfering
Standard_Boolean bToIntersect = CheckPlanes(nF1, nF2);
if (!bToIntersect) {
BOPDS_InterfFF& aFF=aFFs.Append1();
aFF.SetIndices(nF1, nF2);
aFF.Init(0, 0);
continue;
// Update/Initialize FaceInfo structure for first face
if (myDS->HasFaceInfo(nF1))
{
if (aMIFence.Add(nF1))
{
myDS->UpdateFaceInfoOn(nF1);
myDS->UpdateFaceInfoIn(nF1);
}
}
else if (myDS->HasInterfShapeSubShapes(nF2, nF1))
{
myDS->ChangeFaceInfo(nF1);
aMIFence.Add(nF1);
}
// Update/Initialize FaceInfo structure for second face
if (myDS->HasFaceInfo(nF2))
{
if (aMIFence.Add(nF2))
{
myDS->UpdateFaceInfoOn(nF2);
myDS->UpdateFaceInfoIn(nF2);
}
}
else if (myDS->HasInterfShapeSubShapes(nF1, nF2))
{
myDS->ChangeFaceInfo(nF2);
aMIFence.Add(nF2);
}
//
if (myGlue == BOPAlgo_GlueOff) {
if (myGlue == BOPAlgo_GlueOff)
{
const TopoDS_Face& aF1 = (*(TopoDS_Face *)(&myDS->Shape(nF1)));
const TopoDS_Face& aF2 = (*(TopoDS_Face *)(&myDS->Shape(nF2)));
//
const BRepAdaptor_Surface& aBAS1 = myContext->SurfaceAdaptor(aF1);
const BRepAdaptor_Surface& aBAS2 = myContext->SurfaceAdaptor(aF2);
if (aBAS1.GetType() == GeomAbs_Plane &&
aBAS2.GetType() == GeomAbs_Plane) {
// Check if the planes are really interfering
Standard_Boolean bToIntersect = CheckPlanes(nF1, nF2);
if (!bToIntersect) {
BOPDS_InterfFF& aFF = aFFs.Append1();
aFF.SetIndices(nF1, nF2);
aFF.Init(0, 0);
continue;
}
}
//
BOPAlgo_FaceFace& aFaceFace=aVFaceFace.Append1();
//
aFaceFace.SetIndices(nF1, nF2);
@@ -263,10 +295,12 @@ void BOPAlgo_PaveFiller::PerformFF()
for (k = 0; k < aNbFaceFace; ++k) {
BOPAlgo_FaceFace& aFaceFace = aVFaceFace(k);
aFaceFace.Indices(nF1, nF2);
if (!aFaceFace.IsDone()) {
if (!aFaceFace.IsDone() || aFaceFace.HasErrors()) {
BOPDS_InterfFF& aFF = aFFs.Append1();
aFF.SetIndices(nF1, nF2);
aFF.Init(0, 0);
// Warn about failed intersection of faces
AddIntersectionFailedWarning(aFaceFace.Face1(), aFaceFace.Face2());
continue;
}
//
@@ -373,6 +407,7 @@ void BOPAlgo_PaveFiller::MakeBlocks()
BOPCol_DataMapOfIntegerListOfInteger aDMBV(100, aAllocator);
BOPCol_DataMapIteratorOfDataMapOfIntegerReal aItMV;
BOPCol_IndexedMapOfShape aMicroEdges(100, aAllocator);
BOPCol_IndexedMapOfShape aVertsOnRejectedPB;
//
for (i=0; i<aNbFF; ++i) {
//
@@ -557,6 +592,19 @@ void BOPAlgo_PaveFiller::MakeBlocks()
if (!bInBothFaces) {
aMPBAdd.Add(aPBOut);
PreparePostTreatFF(i, j, aPBOut, aMSCPB, aMVI, aLPBC);
// Try fusing the vertices of the existing pave block
// with the vertices put on the real section curve (except
// for technological vertices, which will be removed)
Standard_Integer nVOut1, nVOut2;
aPBOut->Indices(nVOut1, nVOut2);
if (nV1 != nVOut1 && nV1 != nVOut2 && !aMVBounds.Contains(nV1))
{
aVertsOnRejectedPB.Add(aV1);
}
if (nV2 != nVOut1 && nV2 != nVOut2 && !aMVBounds.Contains(nV2))
{
aVertsOnRejectedPB.Add(aV2);
}
}
}
continue;
@@ -639,7 +687,7 @@ void BOPAlgo_PaveFiller::MakeBlocks()
//
// post treatment
MakeSDVerticesFF(aDMVLV, aDMNewSD);
PostTreatFF(aMSCPB, aDMExEdges, aDMNewSD, aMicroEdges, aAllocator);
PostTreatFF(aMSCPB, aDMExEdges, aDMNewSD, aMicroEdges, aVertsOnRejectedPB, aAllocator);
if (HasErrors()) {
return;
}
@@ -697,6 +745,7 @@ void BOPAlgo_PaveFiller::PostTreatFF
BOPDS_DataMapOfPaveBlockListOfPaveBlock& aDMExEdges,
BOPCol_DataMapOfIntegerInteger& aDMNewSD,
const BOPCol_IndexedMapOfShape& theMicroEdges,
const BOPCol_IndexedMapOfShape& theVertsOnRejectedPB,
const Handle(NCollection_BaseAllocator)& theAllocator)
{
Standard_Integer aNbS = theMSCPB.Extent();
@@ -724,8 +773,9 @@ void BOPAlgo_PaveFiller::PostTreatFF
BOPDS_VectorOfInterfFF& aFFs=myDS->InterfFF();
//
Standard_Integer aNbME = theMicroEdges.Extent();
Standard_Integer aNbVOnRPB = theVertsOnRejectedPB.Extent();
// 0
if (aNbS==1 && (aNbME == 0)) {
if (aNbS==1 && (aNbME == 0) && (aNbVOnRPB == 0)) {
const TopoDS_Shape& aS=theMSCPB.FindKey(1);
const BOPDS_CoupleOfPaveBlocks &aCPB=theMSCPB.FindFromIndex(1);
//
@@ -824,6 +874,20 @@ void BOPAlgo_PaveFiller::PostTreatFF
aBB.UpdateVertex(aVerts[1], aTolV2 + aDist);
}
}
// Add vertices put on the real section curves to unify them with the
// vertices of the edges, by which these sections curves have been rejected
for (Standard_Integer i = 1; i <= aNbVOnRPB; ++i)
{
TopoDS_Shape aVer = theVertsOnRejectedPB(i);
Standard_Integer iVer = myDS->Index(aVer);
const Standard_Integer* pSD = aDMNewSD.Seek(iVer);
if (pSD)
aVer = myDS->Shape(*pSD);
if (anAddedSD.Add(aVer))
aLS.Append(aVer);
}
//
// 2 Fuse shapes
aPF.SetProgressIndicator(myProgressIndicator);
@@ -1285,6 +1349,9 @@ Standard_Boolean BOPAlgo_PaveFiller::IsExistingPaveBlock
aTolCheck = Max(aTolE, aTol) + myFuzzyValue;
iFlag = myContext->ComputePE(aPm, aTolCheck, aE, aTx, aDist);
if (!iFlag) {
if (aDist > aTolE)
// Update tolerance of the edge
UpdateEdgeTolerance(nE, aDist);
return bRet;
}
}
@@ -2397,54 +2464,74 @@ void BOPAlgo_PaveFiller::UpdateExistingPaveBlocks
//=======================================================================
void BOPAlgo_PaveFiller::PutClosingPaveOnCurve(BOPDS_Curve& aNC)
{
Standard_Boolean bIsClosed, bHasBounds, bAdded;
Standard_Integer nVC, j;
Standard_Real aT[2], aTC, dT, aTx;
gp_Pnt aP[2] ;
BOPDS_Pave aPVx;
BOPDS_ListIteratorOfListOfPave aItLP;
//
const IntTools_Curve& aIC=aNC.Curve();
const Handle(Geom_Curve)& aC3D=aIC.Curve();
if(aC3D.IsNull()) {
const IntTools_Curve& aIC = aNC.Curve();
const Handle(Geom_Curve)& aC3D = aIC.Curve();
// check 3d curve
if (aC3D.IsNull())
return;
}
//
bIsClosed=IntTools_Tools::IsClosed(aC3D);
if (!bIsClosed) {
// check bounds
if (!aIC.HasBounds())
return;
}
//
bHasBounds=aIC.HasBounds ();
if (!bHasBounds){
return;
}
//
bAdded=Standard_False;
dT=Precision::PConfusion();
aIC.Bounds (aT[0], aT[1], aP[0], aP[1]);
//
Handle(BOPDS_PaveBlock)& aPB=aNC.ChangePaveBlock1();
BOPDS_ListOfPave& aLP=aPB->ChangeExtPaves();
//
aItLP.Initialize(aLP);
for (; aItLP.More() && !bAdded; aItLP.Next()) {
const BOPDS_Pave& aPC=aItLP.Value();
nVC=aPC.Index();
aTC=aPC.Parameter();
//
for (j=0; j<2; ++j) {
if (fabs(aTC-aT[j]) < dT) {
aTx=(!j) ? aT[1] : aT[0];
aPVx.SetIndex(nVC);
aPVx.SetParameter(aTx);
aLP.Append(aPVx);
//
bAdded=Standard_True;
// check closeness
Standard_Real aT[2];
gp_Pnt aP[2];
aIC.Bounds(aT[0], aT[1], aP[0], aP[1]);
// Find the pave which has been put at one of the ends
Standard_Integer nV = -1;
// Keep the opposite parameter
Standard_Real aTOp = 0.;
Standard_Boolean bFound = Standard_False;
Handle(BOPDS_PaveBlock)& aPB = aNC.ChangePaveBlock1();
BOPDS_ListOfPave& aLP = aPB->ChangeExtPaves();
BOPDS_ListIteratorOfListOfPave aItLP(aLP);
for (; aItLP.More() && !bFound; aItLP.Next())
{
const BOPDS_Pave& aPC = aItLP.Value();
Standard_Real aTC = aPC.Parameter();
for (Standard_Integer j = 0; j < 2; ++j)
{
if (Abs(aTC - aT[j]) < Precision::PConfusion())
{
nV = aPC.Index();
aTOp = (!j) ? aT[1] : aT[0];
bFound = Standard_True;
break;
}
}
}
if (!bFound)
return;
// Check if the curve is closed using the tolerance
// of found vertex
const TopoDS_Vertex& aV = TopoDS::Vertex(myDS->Shape(nV));
const Standard_Real aTolV = BRep_Tool::Tolerance(aV);
Standard_Real aDist = aP[0].Distance(aP[1]);
if (aDist > aTolV)
return;
// Check if there will be valid range on the curve
Standard_Real aFirst, aLast;
if (!BRepLib::FindValidRange(GeomAdaptor_Curve(aIC.Curve()), aIC.Tolerance(),
aT[0], aP[0], aTolV,
aT[1], aP[1], aTolV,
aFirst, aLast))
{
return;
}
// Add closing pave to the curve
BOPDS_Pave aPave;
aPave.SetIndex(nV);
aPave.SetParameter(aTOp);
aLP.Append(aPave);
}
//=======================================================================
//function : PreparePostTreatFF

View File

@@ -16,6 +16,7 @@
// commercial license or contractual agreement.
#include <BOPAlgo_PaveFiller.hxx>
#include <BOPAlgo_Alerts.hxx>
#include <BOPAlgo_SectionAttribute.hxx>
#include <BOPAlgo_Tools.hxx>
#include <BOPCol_IndexedMapOfShape.hxx>
@@ -28,6 +29,8 @@
#include <BOPDS_Interf.hxx>
#include <BOPDS_Iterator.hxx>
#include <BOPDS_ListOfPaveBlock.hxx>
#include <BOPDS_MapOfCommonBlock.hxx>
#include <BOPDS_MapOfPair.hxx>
#include <BOPDS_MapOfPaveBlock.hxx>
#include <BOPDS_Pave.hxx>
#include <BOPDS_PaveBlock.hxx>
@@ -38,6 +41,7 @@
#include <BOPDS_VectorOfListOfPaveBlock.hxx>
#include <BOPTools_AlgoTools.hxx>
#include <BOPTools_AlgoTools2D.hxx>
#include <BRepLib.hxx>
#include <BRep_Builder.hxx>
#include <BRep_Tool.hxx>
#include <BRepBndLib.hxx>
@@ -241,31 +245,78 @@ class BOPAlgo_MPC : public BOPAlgo_Algo {
}
//
virtual void Perform() {
Standard_Integer iErr;
//
iErr=1;
if (!myEz.IsNull()) {
TopoDS_Edge aSpz;
//
BOPTools_AlgoTools::MakeSplitEdge(myEz,myV1, myT1,
myV2, myT2, aSpz);
//
iErr=
BOPTools_AlgoTools2D::AttachExistingPCurve(aSpz,
myE,
myF,
myContext);
try
{
OCC_CATCH_SIGNALS
// Check if edge has pcurve. If no then make its copy to avoid data races,
// and use it to build pcurve.
TopoDS_Edge aCopyE = myE;
Standard_Real f, l;
Handle(Geom2d_Curve) aC2d = BRep_Tool::CurveOnSurface(aCopyE, myF, f, l);
if (aC2d.IsNull())
{
aCopyE = BOPTools_AlgoTools::CopyEdge(aCopyE);
Standard_Integer iErr = 1;
if (!myEz.IsNull())
{
// Attach pcurve from the original edge
TopoDS_Edge aSpz;
BOPTools_AlgoTools::MakeSplitEdge(myEz, myV1, myT1,
myV2, myT2, aSpz);
iErr = BOPTools_AlgoTools2D::AttachExistingPCurve(aSpz,
aCopyE,
myF,
myContext);
}
if (iErr)
BOPTools_AlgoTools2D::BuildPCurveForEdgeOnFace(aCopyE, myF, myContext);
myNewC2d = BRep_Tool::CurveOnSurface(aCopyE, myF, f, l);
if (myNewC2d.IsNull())
{
AddError(new BOPAlgo_AlertBuildingPCurveFailed(TopoDS_Shape()));
return;
}
else
myNewTol = BRep_Tool::Tolerance(aCopyE);
}
else
{
const BRepAdaptor_Surface& aBAS = myContext->SurfaceAdaptor(myF);
if (aBAS.IsUPeriodic() || aBAS.IsVPeriodic())
{
// The curve already exists. Adjust it for periodic cases.
BOPTools_AlgoTools2D::AdjustPCurveOnSurf
(myContext->SurfaceAdaptor(myF), f, l, aC2d, myNewC2d);
if (myNewC2d != aC2d)
myNewTol = BRep_Tool::Tolerance(aCopyE);
else
myNewC2d.Nullify();
}
}
if (myFlag) {
UpdateVertices(aCopyE, myF);
}
}
//
if (iErr) {
BOPTools_AlgoTools2D::BuildPCurveForEdgeOnFace(myE, myF, myContext);
}
//
if (myFlag) {
UpdateVertices(myE, myF);
catch (Standard_Failure)
{
AddError(new BOPAlgo_AlertBuildingPCurveFailed(TopoDS_Shape()));
}
}
//
const Handle(Geom2d_Curve)& GetNewPCurve() const
{
return myNewC2d;
}
Standard_Real GetNewTolerance() const
{
return myNewTol;
}
protected:
Standard_Boolean myFlag;
TopoDS_Edge myE;
@@ -275,6 +326,8 @@ class BOPAlgo_MPC : public BOPAlgo_Algo {
Standard_Real myT1;
TopoDS_Vertex myV2;
Standard_Real myT2;
Handle(Geom2d_Curve) myNewC2d;
Standard_Real myNewTol;
//
Handle(IntTools_Context) myContext;
};
@@ -328,7 +381,7 @@ class BOPAlgo_BPC {
}
//
void Perform() {
BOPTools_AlgoTools2D::BuildPCurveForEdgeOnPlane (myE, myF, myCurve, myToUpdate);
BRepLib::BuildPCurveForEdgeOnPlane(myE, myF, myCurve, myToUpdate);
};
//
protected:
@@ -362,12 +415,11 @@ void BOPAlgo_PaveFiller::MakeSplitEdges()
return;
}
//
Standard_Boolean bCB, bV1, bV2;
Standard_Integer i, nE, nV1, nV2, nSp, aNbPB, aNbVBSE, k;
Standard_Integer i, nE, nV1, nV2, nSp, aNbVBSE, k;
Standard_Real aT1, aT2;
BOPDS_ListIteratorOfListOfPaveBlock aItPB;
Handle(BOPDS_PaveBlock) aPB;
BOPDS_MapOfPaveBlock aMPB(100);
BOPDS_MapOfCommonBlock aMCB(100);
TopoDS_Vertex aV1, aV2;
TopoDS_Edge aE;
BOPAlgo_VectorOfSplitEdge aVBSE;
@@ -377,77 +429,96 @@ void BOPAlgo_PaveFiller::MakeSplitEdges()
//
aNbPBP=aPBP.Extent();
//
for (i=0; i<aNbPBP; ++i) {
BOPDS_ListOfPaveBlock& aLPB=aPBP(i);
//
aNbPB=aLPB.Extent();
if (aNbPB==1) {
aPB=aLPB.First();
aPB->Indices(nV1, nV2);
bV1=myDS->IsNewShape(nV1);
bV2=myDS->IsNewShape(nV2);
bCB=myDS->IsCommonBlock(aPB);
//
if (!(bV1 || bV2)) { // no new vertices here
if (!myNonDestructive || !bCB) {
if (bCB) {
if (!aPB->HasEdge()) {
const Handle(BOPDS_CommonBlock)& aCB = myDS->CommonBlock(aPB);
nE = aCB->PaveBlock1()->OriginalEdge();
aCB->SetEdge(nE);
// Compute tolerance of the common block and update the edge
Standard_Real aTol = BOPAlgo_Tools::ComputeToleranceOfCB(aCB, myDS, myContext);
myDS->UpdateEdgeTolerance(nE, aTol);
}
}
else {
nE = aPB->OriginalEdge();
aPB->SetEdge(nE);
}
continue;
}
}
}
for (i = 0; i < aNbPBP; ++i)
{
BOPDS_ListOfPaveBlock& aLPB = aPBP(i);
//
aItPB.Initialize(aLPB);
for (; aItPB.More(); aItPB.Next()) {
aPB=aItPB.Value();
nE=aPB->OriginalEdge();
const BOPDS_ShapeInfo& aSIE=myDS->ShapeInfo(nE);
if (aSIE.HasFlag()){
aPB = aItPB.Value();
nE = aPB->OriginalEdge();
const BOPDS_ShapeInfo& aSIE = myDS->ShapeInfo(nE);
if (aSIE.HasFlag())
{
// Skip degenerated edges
continue;
}
//
const Handle(BOPDS_CommonBlock)& aCB=myDS->CommonBlock(aPB);
bCB=!aCB.IsNull();
if (bCB) {
aPB=aCB->PaveBlock1();
}
//
if (aMPB.Add(aPB)) {
nE=aPB->OriginalEdge();
aPB->Indices(nV1, nV2);
aPB->Range(aT1, aT2);
//
aE=(*(TopoDS_Edge *)(&myDS->Shape(nE)));
aE.Orientation(TopAbs_FORWARD);
//
aV1=(*(TopoDS_Vertex *)(&myDS->Shape(nV1)));
aV1.Orientation(TopAbs_FORWARD);
//
aV2=(*(TopoDS_Vertex *)(&myDS->Shape(nV2)));
aV2.Orientation(TopAbs_REVERSED);
//
BOPAlgo_SplitEdge& aBSE=aVBSE.Append1();
//
aBSE.SetData(aE, aV1, aT1, aV2, aT2);
aBSE.SetPaveBlock(aPB);
if (bCB) {
aBSE.SetCommonBlock(aCB);
const Handle(BOPDS_CommonBlock)& aCB = myDS->CommonBlock(aPB);
Standard_Boolean bCB = !aCB.IsNull();
if (bCB && !aMCB.Add(aCB))
continue;
aPB->Indices(nV1, nV2);
// Check if it is necessary to make the split of the edge
{
Standard_Boolean bV1 = myDS->IsNewShape(nV1);
Standard_Boolean bV2 = myDS->IsNewShape(nV2);
Standard_Boolean bToSplit = Standard_True;
if (!bV1 && !bV2) // no new vertices here
{
if (!myNonDestructive || !bCB)
{
if (bCB)
{
// Find the edge with these vertices
BOPDS_ListIteratorOfListOfPaveBlock it(aCB->PaveBlocks());
for (; it.More(); it.Next())
{
nE = it.Value()->OriginalEdge();
if (myDS->PaveBlocks(nE).Extent() == 1)
break;
}
if (it.More())
{
// The pave block is found
bToSplit = Standard_False;
aCB->SetRealPaveBlock(it.Value());
aCB->SetEdge(nE);
// Compute tolerance of the common block and update the edge
Standard_Real aTol = BOPAlgo_Tools::ComputeToleranceOfCB(aCB, myDS, myContext);
myDS->UpdateEdgeTolerance(nE, aTol);
}
}
else if (aLPB.Extent() == 1)
{
bToSplit = Standard_False;
aPB->SetEdge(nE);
}
if (!bToSplit)
continue;
}
}
aBSE.SetDS(myDS);
aBSE.SetProgressIndicator(myProgressIndicator);
}
// Split the edge
if (bCB)
{
aPB = aCB->PaveBlock1();
nE = aPB->OriginalEdge();
aPB->Indices(nV1, nV2);
}
aPB->Range(aT1, aT2);
//
aE = (*(TopoDS_Edge *)(&myDS->Shape(nE)));
aE.Orientation(TopAbs_FORWARD);
//
aV1 = (*(TopoDS_Vertex *)(&myDS->Shape(nV1)));
aV1.Orientation(TopAbs_FORWARD);
//
aV2 = (*(TopoDS_Vertex *)(&myDS->Shape(nV2)));
aV2.Orientation(TopAbs_REVERSED);
//
BOPAlgo_SplitEdge& aBSE = aVBSE.Append1();
//
aBSE.SetData(aE, aV1, aT1, aV2, aT2);
aBSE.SetPaveBlock(aPB);
if (bCB) {
aBSE.SetCommonBlock(aCB);
}
aBSE.SetDS(myDS);
aBSE.SetProgressIndicator(myProgressIndicator);
} // for (; aItPB.More(); aItPB.Next()) {
} // for (i=0; i<aNbPBP; ++i) {
//
@@ -531,7 +602,7 @@ void BOPAlgo_PaveFiller::MakePCurves()
(!mySectionAttribute.PCurveOnS1() && !mySectionAttribute.PCurveOnS2()))
return;
Standard_Boolean bHasPC;
Standard_Integer i, nF1, nF2, aNbC, k, nE, aNbFF, aNbFI, nEx;
Standard_Integer i, nF1, aNbC, k, nE, aNbFF, aNbFI, nEx;
Standard_Integer j, aNbPBIn, aNbPBOn;
BOPDS_ListIteratorOfListOfPaveBlock aItLPB;
TopoDS_Face aF1F, aF2F;
@@ -627,44 +698,52 @@ void BOPAlgo_PaveFiller::MakePCurves()
}
}// for (i=0; i<aNbFI; ++i) {
//
// 2. Process section edges
// 2. Process section edges. P-curves on them must already be computed.
// However, we must provide the call to UpdateVertices.
Standard_Boolean bPCurveOnS[2];
Standard_Integer m;
TopoDS_Face aFf[2];
//
bPCurveOnS[0]=mySectionAttribute.PCurveOnS1();
bPCurveOnS[1]=mySectionAttribute.PCurveOnS2();
//
if (bPCurveOnS[0] || bPCurveOnS[1]) {
// container to remember already added edge-face pairs
BOPDS_MapOfPair anEFPairs;
BOPDS_VectorOfInterfFF& aFFs=myDS->InterfFF();
aNbFF=aFFs.Extent();
for (i=0; i<aNbFF; ++i) {
const BOPDS_InterfFF& aFF=aFFs(i);
aFF.Indices(nF1, nF2);
const BOPDS_VectorOfCurve& aVNC = aFF.Curves();
aNbC = aVNC.Extent();
if (aNbC == 0)
continue;
Standard_Integer nF[2];
aFF.Indices(nF[0], nF[1]);
//
aFf[0]=(*(TopoDS_Face *)(&myDS->Shape(nF1)));
TopoDS_Face aFf[2];
aFf[0] = (*(TopoDS_Face *)(&myDS->Shape(nF[0])));
aFf[0].Orientation(TopAbs_FORWARD);
//
aFf[1]=(*(TopoDS_Face *)(&myDS->Shape(nF2)));
aFf[1]=(*(TopoDS_Face *)(&myDS->Shape(nF[1])));
aFf[1].Orientation(TopAbs_FORWARD);
//
const BOPDS_VectorOfCurve& aVNC=aFF.Curves();
aNbC=aVNC.Extent();
for (k=0; k<aNbC; ++k) {
for (k=0; k<aNbC; ++k)
{
const BOPDS_Curve& aNC=aVNC(k);
const BOPDS_ListOfPaveBlock& aLPB=aNC.PaveBlocks();
aItLPB.Initialize(aLPB);
for(; aItLPB.More(); aItLPB.Next()) {
for(; aItLPB.More(); aItLPB.Next())
{
const Handle(BOPDS_PaveBlock)& aPB=aItLPB.Value();
nE=aPB->Edge();
const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&myDS->Shape(nE)));
//
for (m=0; m<2; ++m) {
if (bPCurveOnS[m]) {
BOPAlgo_MPC& aMPC=aVMPC.Append1();
for (Standard_Integer m = 0; m<2; ++m)
{
if (bPCurveOnS[m] && anEFPairs.Add(BOPDS_Pair(nE, nF[m])))
{
BOPAlgo_MPC& aMPC = aVMPC.Append1();
aMPC.SetEdge(aE);
aMPC.SetFace(aFf[m]);
aMPC.SetFlag(bPCurveOnS[m]);
aMPC.SetFlag(Standard_True);
aMPC.SetProgressIndicator(myProgressIndicator);
}
}
@@ -676,6 +755,29 @@ void BOPAlgo_PaveFiller::MakePCurves()
//======================================================
BOPAlgo_MPCCnt::Perform(myRunParallel, aVMPC, myContext);
//======================================================
// Add warnings of the failed projections and update edges with new pcurves
Standard_Integer aNb = aVMPC.Extent();
for (i = 0; i < aNb; ++i)
{
const BOPAlgo_MPC& aMPC = aVMPC(i);
if (aMPC.HasErrors())
{
TopoDS_Compound aWC;
BRep_Builder().MakeCompound(aWC);
BRep_Builder().Add(aWC, aMPC.Edge());
BRep_Builder().Add(aWC, aMPC.Face());
AddWarning(new BOPAlgo_AlertBuildingPCurveFailed(aWC));
}
else
{
const Handle(Geom2d_Curve)& aNewPC = aMPC.GetNewPCurve();
// if aNewPC is null we do not need to update the edge because it already contains
// valid p-curve, and only vertices have been updated.
if (!aNewPC.IsNull())
BRep_Builder().UpdateEdge(aMPC.Edge(), aNewPC, aMPC.Face(), aMPC.GetNewTolerance());
}
}
}
//=======================================================================
//function : UpdateVertices

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,315 @@
// Created by: Eugeny MALTCHIKOV
// Copyright (c) 2018 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BOPAlgo_RemoveFeatures_HeaderFile
#define _BOPAlgo_RemoveFeatures_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <BOPAlgo_Options.hxx>
#include <BRepTools_History.hxx>
#include <TopoDS_Shape.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_MapOfShape.hxx>
//! The RemoveFeatures algorithm is intended for reconstruction of
//! the shape by removal of the unwanted parts from it. These parts can
//! be holes, protrusions, spikes, fillets etc.
//! The shape itself is not modified, the new shape is built in
//! the result.
//!
//! Currently, only the shapes of type SOLID, COMPSOLID, and
//! COMPOUND of Solids are supported. And only the FACEs can be
//! removed from the shape.
//!
//! On the input the algorithm accepts the shape itself and the
//! faces which have to be removed. It does not matter how the faces
//! are given. It could be the separate faces or the collections of faces.
//! The faces should belong to the initial shape, and those that
//! do not belong will be ignored.
//! Before reconstructing the shape, the algorithm will sort all
//! the given faces on the connected blocks (features).
//!
//! The features will be removed from the shape one by one.
//! It will allow removing all possible features even if there
//! were problems with the removal of some of them.
//!
//! The removed feature is filled by the extension of the faces adjacent
//! to the feature. In general, the algorithm of removing of the single
//! feature from the shape looks as follows:
//! - Find the faces adjacent to the feature;
//! - Extend the adjacent faces to cover the feature;
//! - Trim the extended faces by the bounds of original face
//! (except for bounds common with the feature), so it will cover
//! the feature only;
//! - Rebuild the solids with reconstructed adjacent faces
//! avoiding the faces from the feature.
//!
//! If the removal is successful, the result is overwritten with the
//! new shape and the next feature is treated. Otherwise, the warning
//! will be given.
//!
//! The algorithm has the following options:
//! - History support;
//!
//! and the options available from base class:
//! - Error/Warning reporting system;
//! - Parallel processing mode.
//!
//! Please note that the other options of the base class are not supported
//! here and will have no effect.
//!
//! <b>History support</b> allows tracking modification of the input shape
//! in terms of Modified, IsDeleted and Generated. The history is
//! available through the methods of the history tool *BRepTools_History*,
//! which can be accessed here through the method *History()*.
//! By default, the history is collected, but it is possible to disable it
//! using the method *TrackHistory(false)*;
//!
//! <b>Error/Warning reporting system</b> - allows obtaining the extended overview
//! of the Errors/Warnings occurred during the operation. As soon as any error
//! appears the algorithm stops working. The warnings allow continuing the job,
//! informing the user that something went wrong.
//! The algorithm returns the following errors/warnings:
//! - *BOPAlgo_AlertTooFewArguments* - the error alert is given if the input
//! shape does not contain any solids;
//! - *BOPAlgo_AlertUnsupportedType* - the warning alert is given if the input
//! shape contains not only solids, but also other shapes;
//! - *BOPAlgo_AlertNoFacesToRemove* - the error alert is given in case
//! there are no faces to remove from the shape (nothing to do);
//! - *BOPAlgo_AlertUnableToRemoveTheFeature* - the warning alert is given to
//! inform the user the removal of the feature is not possible. The algorithm
//! will still try to remove the other features;
//! - *BOPAlgo_AlertRemoveFeaturesFailed* - the error alert is given in case if
//! the operation was aborted by the unknown reason.
//!
//! <b>Parallel processing mode</b> - allows running the algorithm in parallel mode
//! obtaining the result faster.
//!
//! The algorithm has certain limitations:
//! - Intersection of the connected faces adjacent to the feature should not be empty.
//! It means, that such faces should not be tangent to each other.
//! If the intersection of the adjacent faces will be empty, the algorithm will
//! be unable to trim the faces correctly and, most likely, the feature will not be removed.
//! - The algorithm does not process the INTERNAL parts of the solids, they are simply
//! removed during reconstruction.
//!
//! Note that for successful removal of the feature, the extended faces adjacent
//! to the feature should cover the feature completely, otherwise the solids will
//! not be rebuild.
//!
//! Here is the example of usage of the algorithm:
//! ~~~~
//! TopoDS_Shape aSolid = ...; // Input shape to remove the features from
//! TopTools_ListOfShape aFaces = ...; // Faces to remove from the shape
//! Standard_Boolean bRunParallel = ...; // Parallel processing mode
//! Standard_Boolean isHistoryNeeded = ...; // History support
//!
//! BOPAlgo_RemoveFeatures aRF; // Feature removal algorithm
//! aRF.SetShape(aSolid); // Set the shape
//! aRF.AddFacesToRemove(aFaces); // Add faces to remove
//! aRF.SetRunParallel(bRunParallel); // Define the processing mode (parallel or single)
//! aRF.TrackHistory(isHistoryNeeded); // Define whether to track the shapes modifications
//! aRF.Perform(); // Perform the operation
//! if (aRF.HasErrors()) // Check for the errors
//! {
//! // error treatment
//! return;
//! }
//! if (aRF.HasWarnings()) // Check for the warnings
//! {
//! // warnings treatment
//! }
//! const TopoDS_Shape& aResult = aRF.Shape(); // Result shape
//! ~~~~
//!
//! The algorithm preserves the type of the input shape in the result shape. Thus,
//! if the input shape is a COMPSOLID, the resulting solids will also be put into a COMPSOLID.
//!
//! When all possible features are removed, the shape is simplified by
//! removing extra edges and vertices, created during operation, from the result shape.
//!
class BOPAlgo_RemoveFeatures: public BOPAlgo_Options
{
public:
DEFINE_STANDARD_ALLOC
public: //! @name Constructors
//! Empty constructor
BOPAlgo_RemoveFeatures()
:
BOPAlgo_Options(),
myTrackHistory(Standard_True)
{
}
public: //! @name Setting input data for the algorithm
//! Sets the shape for processing.
//! @param theShape [in] The shape to remove the faces from.
//! It should either be the SOLID, COMPSOLID or COMPOUND of Solids.
void SetShape(const TopoDS_Shape& theShape)
{
myInputShape = theShape;
}
//! Returns the input shape
const TopoDS_Shape& InputShape() const
{
return myInputShape;
}
//! Adds the face to remove from the input shape.
//! @param theFace [in] The shape to extract the faces for removal.
void AddFaceToRemove(const TopoDS_Shape& theFace)
{
myFacesToRemove.Append(theFace);
}
//! Adds the faces to remove from the input shape.
//! @param theFaces [in] The list of shapes to extract the faces for removal.
void AddFacesToRemove(const TopTools_ListOfShape& theFaces)
{
TopTools_ListIteratorOfListOfShape it(theFaces);
for (; it.More(); it.Next())
myFacesToRemove.Append(it.Value());
}
//! Returns the list of faces which have been requested for removal
//! from the input shape.
const TopTools_ListOfShape& FacesToRemove() const
{
return myFacesToRemove;
}
public: //! @name Performing the operation
//! Performs the operation
Standard_EXPORT void Perform();
public: //! @name Clearing the contents of the algorithm
//! Clears the contents of the algorithm from previous run,
//! allowing reusing it for following removals.
void Clear()
{
BOPAlgo_Options::Clear();
myHistory.Nullify();
myInputShape.Nullify();
myShape.Nullify();
myFacesToRemove.Clear();
myFeatures.Clear();
myInputsMap.Clear();
myResultMap.Clear();
}
public: //! @name History support
//! Defines whether to track the modification of the shapes or not
void TrackHistory(const Standard_Boolean theFlag)
{
myTrackHistory = theFlag;
}
//! Gets the History object
Handle(BRepTools_History) History()
{
return (myTrackHistory ? myHistory : NULL);
}
public: //! @name Obtaining the results
//! Returns the resulting shape
const TopoDS_Shape& Shape() const
{
return myShape;
}
protected: //! @name Protected methods performing the removal
//! Checks the input data on validity for the algorithm:
//! - The input shape must be either a SOLID, COMPSOLID or COMPOUND of Solids.
//! If the input shape is not a solid, the method looks for the solids
//! in <myInputShape> and uses only them. All other shapes are simply removed.
//! If no solids were found, the Error of unsupported type is returned.
Standard_EXPORT void CheckData();
//! Prepares the faces to remove:
//! - Gets only faces contained in the input solids;
//! - Builds connected blocks of faces creating separate features to remove.
Standard_EXPORT void PrepareFeatures();
//! Removes the features and fills the created gaps by extension of the adjacent faces.
//! Processes each feature separately.
Standard_EXPORT void RemoveFeatures();
//! Remove the single feature from the shape.
//! @param theFeature [in] The feature to remove;
//! @param theSolids [in] The solids to be reconstructed after feature removal;
//! @param theFeatureFacesMap [in] The map of feature faces;
//! @param theHasAdjacentFaces [in] Shows whether the adjacent faces have been
//! found for the feature or not;
//! @param theAdjFaces [in] The reconstructed adjacent faces covering the feature;
//! @param theAdjFacesHistory [in] The history of the adjacent faces reconstruction;
//! @param theSolidsHistoryNeeded [in] Defines whether the history of solids
//! modifications should be tracked or not.
Standard_EXPORT void RemoveFeature(const TopoDS_Shape& theFeature,
const TopTools_IndexedMapOfShape& theSolids,
const TopTools_MapOfShape& theFeatureFacesMap,
const Standard_Boolean theHasAdjacentFaces,
const TopTools_IndexedDataMapOfShapeListOfShape& theAdjFaces,
const Handle(BRepTools_History)& theAdjFacesHistory,
const Standard_Boolean theSolidsHistoryNeeded);
//! Updates history with the removed features
Standard_EXPORT void UpdateHistory();
//! Simplifies the result by removing extra edges and vertices created
//! during removal of the features.
Standard_EXPORT void SimplifyResult();
//! Post treatment - restore the type of the initial shape
Standard_EXPORT void PostTreat();
protected: //! @name Fields
// Inputs
TopoDS_Shape myInputShape; //!< Input shape
TopTools_ListOfShape myFacesToRemove; //!< Faces to remove
Standard_Boolean myTrackHistory; //!< Defines whether to track the history of shapes
//! modifications or not (true by default)
// Intermediate
TopTools_ListOfShape myFeatures; //!< List of not connected features to remove
//! (each feature is a compound of faces)
TopTools_IndexedMapOfShape myInputsMap; //!< Map of all sub-shapes of the input shape
TopTools_MapOfShape myResultMap; //!< Map of all sub-shapes of the result shape
// Results
TopoDS_Shape myShape; //!< Result shape
Handle(BRepTools_History) myHistory; //!< History tool
};
#endif // _BOPAlgo_RemoveFeatures_HeaderFile

View File

@@ -13,7 +13,6 @@
// commercial license or contractual agreement.
#include <BOPAlgo_BuilderSolid.hxx>
#include <BOPAlgo_PaveFiller.hxx>
#include <BOPAlgo_Section.hxx>
#include <BOPAlgo_Alerts.hxx>
@@ -42,8 +41,6 @@
#include <TopoDS_Iterator.hxx>
#include <TopoDS_Shape.hxx>
//
//
//=======================================================================
//function :
//purpose :
@@ -357,44 +354,3 @@ void BOPAlgo_Section::BuildSection()
//
myShape=aRC;
}
//=======================================================================
//function : Generated
//purpose :
//=======================================================================
const TopTools_ListOfShape& BOPAlgo_Section::Generated
(const TopoDS_Shape& theS)
{
myHistShapes.Clear();
if (theS.IsNull()) {
return myHistShapes;
}
//
TopAbs_ShapeEnum aType = theS.ShapeType();
if (aType != TopAbs_FACE) {
return myHistShapes;
}
//
Standard_Integer nS = myDS->Index(theS);
if (nS < 0) {
return myHistShapes;
}
//
if (!myDS->HasFaceInfo(nS)) {
return myHistShapes;
}
//
//collect section edges of the face theS
Standard_Integer i, aNb, nSp;
//
const BOPDS_FaceInfo& aFI = myDS->FaceInfo(nS);
const BOPDS_IndexedMapOfPaveBlock& aMPBSc = aFI.PaveBlocksSc();
aNb = aMPBSc.Extent();
for (i = 1; i <= aNb; ++i) {
const Handle(BOPDS_PaveBlock)& aPB = aMPBSc(i);
nSp = aPB->Edge();
const TopoDS_Shape& aSp = myDS->Shape(nSp);
myHistShapes.Append(aSp);
}
//
return myHistShapes;
}

View File

@@ -43,26 +43,20 @@ public:
//! Empty constructor
Standard_EXPORT BOPAlgo_Section();
Standard_EXPORT virtual ~BOPAlgo_Section();
//! Empty constructor
//!
//! protected methods
Standard_EXPORT BOPAlgo_Section(const BOPCol_BaseAllocator& theAllocator);
Standard_EXPORT virtual void BuildSection();
//! Returns the list of shapes generated from the
//! shape theS.
Standard_EXPORT virtual const TopTools_ListOfShape& Generated (const TopoDS_Shape& theS) Standard_OVERRIDE;
//! Constructor with allocator
Standard_EXPORT BOPAlgo_Section(const BOPCol_BaseAllocator& theAllocator);
protected:
//! Checks the data before performing the operation
Standard_EXPORT virtual void CheckData() Standard_OVERRIDE;
//! Performs calculations using prepared Filler
//! object <thePF>
Standard_EXPORT virtual void PerformInternal1 (const BOPAlgo_PaveFiller& thePF) Standard_OVERRIDE;
//! Combine the result of section operation
Standard_EXPORT virtual void BuildSection();
//! Performs calculations using prepared Filler object <thePF>
Standard_EXPORT virtual void PerformInternal1(const BOPAlgo_PaveFiller& thePF) Standard_OVERRIDE;
private:

View File

@@ -42,12 +42,6 @@ static
void RefineShell(TopoDS_Shell& theShell,
const BOPCol_IndexedDataMapOfShapeListOfShape& theMEF,
BOPCol_ListOfShape& aLShX);
//
static
void MapEdgesAndFaces
(const TopoDS_Shape& aF,
BOPCol_IndexedDataMapOfShapeListOfShape& aMEF,
const Handle(NCollection_BaseAllocator)& theAllocator);
//=======================================================================
//class : BOPAlgo_CBK
@@ -152,162 +146,12 @@ void BOPAlgo_ShellSplitter::Perform()
{
GetReport()->Clear();
//
MakeConnexityBlocks();
if (HasErrors()) {
return;
}
BOPTools_AlgoTools::MakeConnexityBlocks
(myStartShapes, TopAbs_EDGE, TopAbs_FACE, myLCB);
//
MakeShells();
}
//=======================================================================
//function : MakeConnexityBlocks
//purpose :
//=======================================================================
void BOPAlgo_ShellSplitter::MakeConnexityBlocks()
{
Standard_Boolean bRegular;
Standard_Integer i, j, aNbE, aNbES, aNbEP, k, aNbCB;
TopoDS_Shape aFR;
TopoDS_Iterator aItF, aItW;
BOPCol_IndexedDataMapOfShapeListOfShape aMEF(100, myAllocator);
BOPCol_IndexedMapOfShape aMEP(100, myAllocator);
BOPCol_IndexedMapOfShape aMFC(100, myAllocator);
BOPCol_MapOfShape aMER(100, myAllocator);
BOPCol_MapOfShape aMFP(100, myAllocator);
BOPCol_IndexedMapOfShape aMEAdd(100, myAllocator);
BOPCol_MapOfShape aMES(100, myAllocator);
BOPCol_ListIteratorOfListOfShape aIt;
//
myLCB.Clear();
//
const BOPCol_ListOfShape& aLSE=myStartShapes;
aIt.Initialize(aLSE);
for (i=1; aIt.More(); aIt.Next(), ++i) {
const TopoDS_Shape& aSE=aIt.Value();
if (!aMEP.Contains(aSE)) {
aMEP.Add(aSE);
MapEdgesAndFaces(aSE, aMEF, myAllocator);
}
else {
aMER.Add(aSE);
}
}
//
// 2
aNbE=aMEF.Extent();
for (i=1; i<=aNbE; ++i) {
aNbES=aMES.Extent();
if (aNbES==aNbE) {
break;
}
//
const TopoDS_Shape& aE=aMEF.FindKey(i);
//
if (!aMES.Add(aE)) {
continue;
}
// aMES - globally processed edges
//
//------------------------------------- goal: aMEC
aMFC.Clear(); // aMEC - edges of CB
aMEP.Clear(); // aMVP - edges to process right now
aMEAdd.Clear(); // aMVAdd edges to process on next step of for(;;) {
//
aMEP.Add(aE);
//
for(;;) {
aNbEP=aMEP.Extent();
for (k=1; k<=aNbEP; ++k) {
const TopoDS_Shape& aEP=aMEP(k);
const BOPCol_ListOfShape& aLF=aMEF.FindFromKey(aEP);
aIt.Initialize(aLF);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aF=aIt.Value();
if (aMFC.Add(aF)) {
aItF.Initialize(aF);
while (aItF.More()) {
const TopoDS_Shape& aW=aItF.Value();
if (aW.ShapeType()!=TopAbs_WIRE) {
aItF.Next();
continue;
}
//
aItW.Initialize(aW);
while (aItW.More()) {
const TopoDS_Shape& aEF=aItW.Value();
//
if (aMES.Add(aEF)) {
aMEAdd.Add(aEF);
}
//
aItW.Next();
}
//
aItF.Next();
}
}
}
}
//
aNbEP=aMEAdd.Extent();
if (!aNbEP) {
break; // from for(;;) {
}
//
aMEP.Clear();
//
for (k=1; k<=aNbEP; ++k) {
const TopoDS_Shape& aEF=aMEAdd(k);
aMEP.Add(aEF);
}
aMEAdd.Clear();
}// for(;;) {
//
//-------------------------------------
BOPTools_ConnexityBlock aCB(myAllocator);
//
BOPCol_ListOfShape& aLECB=aCB.ChangeShapes();
BOPCol_IndexedDataMapOfShapeListOfShape aMEFR(100, myAllocator);
//
bRegular=Standard_True;
aNbCB = aMFC.Extent();
for (j=1; j<=aNbCB; ++j) {
aFR = aMFC(j);
//
if (aMER.Contains(aFR)) {
aFR.Orientation(TopAbs_FORWARD);
aLECB.Append(aFR);
aFR.Orientation(TopAbs_REVERSED);
aLECB.Append(aFR);
bRegular=Standard_False;
}
else {
aLECB.Append(aFR);
}
//
if (bRegular) {
MapEdgesAndFaces(aFR, aMEFR, myAllocator);
}
}
//
if (bRegular) {
Standard_Integer aNbER, aNbFR;
//
aNbER=aMEFR.Extent();
for (k=1; k<=aNbER; ++k) {
const BOPCol_ListOfShape& aLFR=aMEFR(k);
aNbFR=aLFR.Extent();
if (aNbFR>2) {
bRegular=!bRegular;
break;
}
}
}
//
aCB.SetRegular(bRegular);
myLCB.Append(aCB);
}
}
//=======================================================================
//function : SplitBlock
//purpose :
@@ -750,43 +594,3 @@ void MakeShell(const BOPCol_ListOfShape& aLS,
//
BOPTools_AlgoTools::OrientFacesOnShell(aShell);
}
//=======================================================================
// function: MapEdgesAndFaces
// purpose:
//=======================================================================
void MapEdgesAndFaces
(const TopoDS_Shape& aF,
BOPCol_IndexedDataMapOfShapeListOfShape& aMEF,
const Handle(NCollection_BaseAllocator)& theAllocator)
{
TopoDS_Iterator aItF, aItW;
//
aItF.Initialize(aF);
while (aItF.More()) {
const TopoDS_Shape& aW=aItF.Value();
if (aW.ShapeType()!=TopAbs_WIRE) {
aItF.Next();
continue;
}
//
aItW.Initialize(aW);
while (aItW.More()) {
const TopoDS_Shape& aE=aItW.Value();
//
if (aMEF.Contains(aE)) {
BOPCol_ListOfShape& aLF=aMEF.ChangeFromKey(aE);
aLF.Append(aF);
}
else {
BOPCol_ListOfShape aLS(theAllocator);
//
aLS.Append(aF);
aMEF.Add(aE, aLS);
}
//
aItW.Next();
}
//
aItF.Next();
}
}

View File

@@ -61,8 +61,6 @@ Standard_EXPORT virtual ~BOPAlgo_ShellSplitter();
protected:
Standard_EXPORT void MakeConnexityBlocks();
Standard_EXPORT void MakeShells();

View File

@@ -17,6 +17,8 @@
#include <BOPAlgo_PaveFiller.hxx>
#include <BOPAlgo_Alerts.hxx>
#include <TopoDS_Iterator.hxx>
//=======================================================================
//function :
//purpose :
@@ -131,9 +133,38 @@ void BOPAlgo_Splitter::Perform()
pPF->SetFuzzyValue(myFuzzyValue);
pPF->SetNonDestructive(myNonDestructive);
pPF->SetGlue(myGlue);
pPF->SetUseOBB(myUseOBB);
//
pPF->Perform();
//
myEntryPoint = 1;
PerformInternal(*pPF);
}
//=======================================================================
//function : BuildResult
//purpose :
//=======================================================================
void BOPAlgo_Splitter::BuildResult(const TopAbs_ShapeEnum theType)
{
BOPAlgo_Builder::BuildResult(theType);
if (theType == TopAbs_COMPOUND)
{
// The method is called for the last time for this operation.
// If there is only one argument shape and it has been modified into
// a single shape, or has not been modified at all, the result shape
// has to be overwritten to avoid the unnecessary enclosure into compound.
if (myArguments.Extent() == 1)
{
TopoDS_Iterator it(myShape);
if (it.More())
{
const TopoDS_Shape& aSFirst = it.Value();
it.Next();
if (!it.More())
myShape = aSFirst;
}
}
}
}

View File

@@ -83,6 +83,11 @@ protected:
//! Checks the input data
Standard_EXPORT virtual void CheckData() Standard_OVERRIDE;
//! Adds images of the argument shapes into result.
//! When called the for the last time (for compound) it rebuilds the result
//! shape to avoid multiple enclosure into compounds.
Standard_EXPORT virtual void BuildResult(const TopAbs_ShapeEnum theType) Standard_OVERRIDE;
BOPCol_ListOfShape myTools;
BOPCol_MapOfShape myMapTools;

View File

@@ -44,9 +44,12 @@
#include <BRepBuilderAPI_MakeFace.hxx>
#include <BRepLib.hxx>
#include <BRep_Tool.hxx>
#include <BRep_Builder.hxx>
#include <BRepBndLib.hxx>
#include <GeomAPI_ProjectPointOnCurve.hxx>
#include <GeomAPI_ProjectPointOnSurf.hxx>
@@ -65,9 +68,12 @@
#include <BOPTools_AlgoTools2D.hxx>
#include <NCollection_UBTreeFiller.hxx>
#include <NCollection_IncAllocator.hxx>
#include <IntTools_Context.hxx>
#include <algorithm>
typedef NCollection_IndexedDataMap
<TopoDS_Shape, gp_Dir, TopTools_ShapeMapHasher> BOPAlgo_IndexedDataMapOfShapeDir;
typedef NCollection_IndexedDataMap
@@ -128,25 +134,57 @@ void BOPAlgo_Tools::PerformCommonBlocks(BOPDS_IndexedDataMapOfPaveBlockListOfPav
if (!aNbCB) {
return;
}
//
Handle(BOPDS_CommonBlock) aCB;
// Make Blocks of the pave blocks
NCollection_List<BOPDS_ListOfPaveBlock> aMBlocks(aAllocator);
//
BOPAlgo_Tools::MakeBlocks<Handle(BOPDS_PaveBlock), TColStd_MapTransientHasher>(aMPBLPB, aMBlocks, aAllocator);
//
// Use temporary allocator for the local fence map
Handle(NCollection_IncAllocator) anAllocTmp = new NCollection_IncAllocator;
NCollection_List<BOPDS_ListOfPaveBlock>::Iterator aItB(aMBlocks);
for (; aItB.More(); aItB.Next()) {
const BOPDS_ListOfPaveBlock& aLPB = aItB.Value();
Standard_Integer aNbPB = aLPB.Extent();
if (aNbPB>1) {
aCB=new BOPDS_CommonBlock;
aCB->SetPaveBlocks(aLPB);
//
BOPDS_ListIteratorOfListOfPaveBlock aItLPB(aLPB);
for (; aItLPB.More(); aItLPB.Next()) {
pDS->SetCommonBlock(aItLPB.Value(), aCB);
if (aNbPB < 2)
continue;
// Reset the allocator
anAllocTmp->Reset();
// New common block
Handle(BOPDS_CommonBlock) aCB;
// Faces of the common block
BOPCol_ListOfInteger aLFaces;
// Fence map to avoid duplicates in the list of faces of the common block
BOPCol_MapOfInteger aMFaces(1, anAllocTmp);
BOPDS_ListIteratorOfListOfPaveBlock aItLPB(aLPB);
for (; aItLPB.More(); aItLPB.Next())
{
const Handle(BOPDS_PaveBlock)& aPB = aItLPB.Value();
if (pDS->IsCommonBlock(aPB))
{
const Handle(BOPDS_CommonBlock)& aCBx = pDS->CommonBlock(aPB);
// Move all faces to the new common block
BOPCol_ListIteratorOfListOfInteger aItLF(aCBx->Faces());
for (; aItLF.More(); aItLF.Next())
{
const Standard_Integer nF = aItLF.Value();
// Append to common list avoiding duplicates
if (aMFaces.Add(nF))
aLFaces.Append(nF);
}
if (aCB.IsNull())
aCB = aCBx;
}
}//if (aNbPB>1) {
}
if (aCB.IsNull())
aCB = new BOPDS_CommonBlock;
aCB->SetPaveBlocks(aLPB);
aCB->SetFaces(aLFaces);
for (aItLPB.Initialize(aLPB); aItLPB.More(); aItLPB.Next())
pDS->SetCommonBlock(aItLPB.Value(), aCB);
}
}
//=======================================================================
@@ -659,7 +697,7 @@ Standard_Boolean BOPAlgo_Tools::WiresToFaces(const TopoDS_Shape& theWires,
OCC_CATCH_SIGNALS
//
// build pcurves for edges on this face
BOPTools_AlgoTools2D::BuildPCurveForEdgesOnPlane(aLE, aFF);
BRepLib::BuildPCurveForEdgesOnPlane(aLE, aFF);
//
// split the face with the edges
BOPAlgo_BuilderFace aBF;
@@ -1088,3 +1126,522 @@ void BOPAlgo_Tools::IntersectVertices(const BOPCol_IndexedDataMapOfShapeReal& th
}
}
}
//=======================================================================
//function : TreatCompound
//purpose :
//=======================================================================
void BOPAlgo_Tools::TreatCompound(const TopoDS_Shape& theS,
BOPCol_MapOfShape& aMFence,
BOPCol_ListOfShape& theLS)
{
TopAbs_ShapeEnum aType = theS.ShapeType();
if (aType != TopAbs_COMPOUND)
{
if (aMFence.Add(theS))
theLS.Append(theS);
return;
}
TopoDS_Iterator aIt(theS);
for (; aIt.More(); aIt.Next())
{
const TopoDS_Shape& aS = aIt.Value();
TreatCompound(aS, aMFence, theLS);
}
}
//=======================================================================
// Classification of the faces relatively solids
//=======================================================================
//=======================================================================
//class : BOPAlgo_ShapeBox
//purpose : Auxiliary class defining ShapeBox structure
//=======================================================================
class BOPAlgo_ShapeBox
{
public:
//! Empty constructor
BOPAlgo_ShapeBox() {};
//! Sets the shape
void SetShape(const TopoDS_Shape& theS)
{
myShape = theS;
};
//! Returns the shape
const TopoDS_Shape& Shape() const
{
return myShape;
};
//! Sets the bounding box
void SetBox(const Bnd_Box& theBox)
{
myBox = theBox;
};
//! Returns the bounding box
const Bnd_Box& Box() const
{
return myBox;
};
private:
TopoDS_Shape myShape;
Bnd_Box myBox;
};
// Vector of ShapeBox
typedef BOPCol_NCVector<BOPAlgo_ShapeBox> BOPAlgo_VectorOfShapeBox;
//=======================================================================
//class : BOPAlgo_FillIn3DParts
//purpose : Auxiliary class for faces classification in parallel mode
//=======================================================================
class BOPAlgo_FillIn3DParts : public BOPAlgo_Algo
{
public:
DEFINE_STANDARD_ALLOC
//! Constructor
BOPAlgo_FillIn3DParts()
{
myBBTree = NULL;
myVShapeBox = NULL;
};
//! Destructor
virtual ~BOPAlgo_FillIn3DParts() {};
//! Sets the solid
void SetSolid(const TopoDS_Solid& theSolid)
{
mySolid = theSolid;
};
//! Returns the solid
const TopoDS_Solid& Solid() const
{
return mySolid;
};
//! Sets the box for the solid
void SetBoxS(const Bnd_Box& theBox)
{
myBoxS = theBox;
};
//! Returns the solid's box
const Bnd_Box& BoxS() const
{
return myBoxS;
};
//! Sets own INTERNAL faces of the solid
void SetOwnIF(const BOPCol_ListOfShape& theLIF)
{
myOwnIF = theLIF;
};
//! Returns own INTERNAL faces of the solid
const BOPCol_ListOfShape& OwnIF() const
{
return myOwnIF;
};
//! Sets the Bounding Box tree
void SetBBTree(const BOPCol_BoxBndTree& theBBTree)
{
myBBTree = (BOPCol_BoxBndTree*)&theBBTree;
};
//! Sets the ShapeBox structure
void SetShapeBoxVector(const BOPAlgo_VectorOfShapeBox& theShapeBox)
{
myVShapeBox = (BOPAlgo_VectorOfShapeBox*)&theShapeBox;
};
//! Sets the context
void SetContext(const Handle(IntTools_Context)& theContext)
{
myContext = theContext;
}
//! Returns the context
const Handle(IntTools_Context)& Context() const
{
return myContext;
}
//! Performs the classification
virtual void Perform();
//! Returns the faces classified as IN for solid
const BOPCol_ListOfShape& InFaces() const
{
return myInFaces;
};
private:
//! Prepares Edge-Face connection map of the given shape
void MapEdgesAndFaces(const TopoDS_Shape& theF,
BOPCol_IndexedDataMapOfShapeListOfShape& theEFMap,
const Handle(NCollection_BaseAllocator)& theAlloc);
//! Makes the connexity block of faces using the connection map
void MakeConnexityBlock(const TopoDS_Face& theF,
const BOPCol_IndexedMapOfShape& theMEToAvoid,
const BOPCol_IndexedDataMapOfShapeListOfShape& theEFMap,
BOPCol_MapOfShape& theMFDone,
BOPCol_ListOfShape& theLCB,
TopoDS_Face& theFaceToClassify);
TopoDS_Solid mySolid; //! Solid
Bnd_Box myBoxS; // Bounding box of the solid
BOPCol_ListOfShape myOwnIF; //! Own INTERNAL faces of the solid
BOPCol_ListOfShape myInFaces; //! Faces classified as IN
BOPCol_BoxBndTree* myBBTree; //! UB tree of bounding boxes
BOPAlgo_VectorOfShapeBox* myVShapeBox; //! ShapeBoxMap
TopoDS_Iterator myItF; //! Iterators
TopoDS_Iterator myItW;
Handle(IntTools_Context) myContext; //! Context
};
//=======================================================================
//function : BOPAlgo_FillIn3DParts::Perform
//purpose :
//=======================================================================
void BOPAlgo_FillIn3DParts::Perform()
{
BOPAlgo_Algo::UserBreak();
myInFaces.Clear();
// 1. Select boxes of faces that are not out of aBoxS
BOPCol_BoxBndTreeSelector aSelector;
aSelector.SetBox(myBoxS);
//
if (!myBBTree->Select(aSelector))
return;
const BOPCol_ListOfInteger& aLIFP = aSelector.Indices();
// 2. Fill maps of edges and faces of the solid
Handle(NCollection_BaseAllocator) anAlloc = new NCollection_IncAllocator;
BOPAlgo_VectorOfShapeBox& aVShapeBox = *myVShapeBox;
BOPCol_IndexedMapOfShape aMSE(1, anAlloc), aMSF(1, anAlloc);
BOPTools::MapShapes(mySolid, TopAbs_EDGE, aMSE);
BOPTools::MapShapes(mySolid, TopAbs_FACE, aMSF);
// Check if the Solid contains any faces
Standard_Boolean bIsEmpty = aMSF.IsEmpty();
// Add own internal faces of the solid into aMSF
BOPCol_ListIteratorOfListOfShape aItLS(myOwnIF);
for (; aItLS.More(); aItLS.Next())
aMSF.Add(aItLS.Value());
// 3. aIVec - faces to process.
// Filter the selected faces with faces of the solid.
BOPCol_NCVector<Standard_Integer> aIVec(256, anAlloc);
BOPCol_ListIteratorOfListOfInteger aItLI(aLIFP);
for (; aItLI.More(); aItLI.Next()) {
Standard_Integer nFP = aItLI.Value();
const TopoDS_Shape& aFP = aVShapeBox(nFP).Shape();
if (!aMSF.Contains(aFP))
aIVec.Append1() = nFP;
}
// 4. Classify faces relatively solid.
// Store faces that are IN mySolid into <myInFaces>
Standard_Integer k, aNbFP = aIVec.Extent();
// Sort indices if necessary
if (aNbFP > 1)
std::sort(aIVec.begin(), aIVec.end());
if (bIsEmpty)
{
// The solid is empty as it does not contain any faces.
// It could happen when the input solid consists of INTERNAL faces only.
// Classification of any point relatively empty solid would always give IN status.
// Thus, we consider all selected faces as IN without real classification.
for (k = 0; k < aNbFP; ++k)
myInFaces.Append(aVShapeBox(aIVec(k)).Shape());
return;
}
// Prepare EF map of faces to process for building connexity blocks
BOPCol_IndexedDataMapOfShapeListOfShape aMEFP(1, anAlloc);
if (aNbFP > 1)
{
for (k = 0; k < aNbFP; ++k)
MapEdgesAndFaces(aVShapeBox(aIVec(k)).Shape(), aMEFP, anAlloc);
}
// Map of Edge-Face connection, necessary for solid classification.
// It will be filled when first classification is performed.
BOPCol_IndexedDataMapOfShapeListOfShape aMEFDS(1, anAlloc);
// Fence map to avoid processing of the same faces twice
BOPCol_MapOfShape aMFDone(1, anAlloc);
for (k = 0; k < aNbFP; ++k)
{
Standard_Integer nFP = aIVec(k);
const TopoDS_Face& aFP = (*(TopoDS_Face*)&aVShapeBox(nFP).Shape());
if (!aMFDone.Add(aFP))
continue;
// Make connexity blocks of faces, avoiding passing through the
// borders of the solid. It helps to reduce significantly the
// number of classified faces.
BOPCol_ListOfShape aLCBF(anAlloc);
// The most appropriate face for classification
TopoDS_Face aFaceToClassify;
MakeConnexityBlock(aFP, aMSE, aMEFP, aMFDone, aLCBF, aFaceToClassify);
if (!myBoxS.IsWhole())
{
// First, try fast classification of the whole block by additional
// check on bounding boxes - check that bounding boxes of all vertices
// of the block interfere with the box of the solid.
// If not, the faces are out.
Standard_Boolean bOut = Standard_False;
aItLS.Initialize(aLCBF);
for (; aItLS.More() && !bOut; aItLS.Next())
{
TopExp_Explorer anExpV(aItLS.Value(), TopAbs_VERTEX);
for (; anExpV.More() && !bOut; anExpV.Next())
{
const TopoDS_Vertex& aV = TopoDS::Vertex(anExpV.Current());
Bnd_Box aBBV;
aBBV.Add(BRep_Tool::Pnt(aV));
aBBV.SetGap(BRep_Tool::Tolerance(aV));
bOut = myBoxS.IsOut(aBBV);
}
}
if (bOut)
continue;
}
if (aFaceToClassify.IsNull())
aFaceToClassify = aFP;
if (aMEFDS.IsEmpty())
// Fill EF map for Solid
BOPTools::MapShapesAndAncestors(mySolid, TopAbs_EDGE, TopAbs_FACE, aMEFDS);
// All vertices are interfere with the solids box, run classification.
Standard_Boolean bIsIN = BOPTools_AlgoTools::IsInternalFace
(aFaceToClassify, mySolid, aMEFDS, Precision::Confusion(), myContext);
if (bIsIN)
{
aItLS.Initialize(aLCBF);
for (; aItLS.More(); aItLS.Next())
myInFaces.Append(aItLS.Value());
}
}
}
//=======================================================================
// function: MapEdgesAndFaces
// purpose:
//=======================================================================
void BOPAlgo_FillIn3DParts::MapEdgesAndFaces(const TopoDS_Shape& theF,
BOPCol_IndexedDataMapOfShapeListOfShape& theEFMap,
const Handle(NCollection_BaseAllocator)& theAllocator)
{
myItF.Initialize(theF);
for (; myItF.More(); myItF.Next())
{
const TopoDS_Shape& aW = myItF.Value();
if (aW.ShapeType() != TopAbs_WIRE)
continue;
myItW.Initialize(aW);
for (; myItW.More(); myItW.Next())
{
const TopoDS_Shape& aE = myItW.Value();
BOPCol_ListOfShape* pLF = theEFMap.ChangeSeek(aE);
if (!pLF)
pLF = &theEFMap(theEFMap.Add(aE, BOPCol_ListOfShape(theAllocator)));
pLF->Append(theF);
}
}
}
//=======================================================================
// function: MakeConnexityBlock
// purpose:
//=======================================================================
void BOPAlgo_FillIn3DParts::MakeConnexityBlock(const TopoDS_Face& theFStart,
const BOPCol_IndexedMapOfShape& theMEAvoid,
const BOPCol_IndexedDataMapOfShapeListOfShape& theEFMap,
BOPCol_MapOfShape& theMFDone,
BOPCol_ListOfShape& theLCB,
TopoDS_Face& theFaceToClassify)
{
// Add start element
theLCB.Append(theFStart);
if (theEFMap.IsEmpty())
return;
BOPCol_ListIteratorOfListOfShape aItCB(theLCB);
for (; aItCB.More(); aItCB.Next())
{
const TopoDS_Shape& aF = aItCB.Value();
myItF.Initialize(aF);
for (; myItF.More(); myItF.Next())
{
const TopoDS_Shape& aW = myItF.Value();
if (aW.ShapeType() != TopAbs_WIRE)
continue;
myItW.Initialize(aW);
for (; myItW.More(); myItW.Next())
{
const TopoDS_Edge& aE = TopoDS::Edge(myItW.Value());
if (theMEAvoid.Contains(aE) || BRep_Tool::Degenerated(aE))
{
if (theFaceToClassify.IsNull())
theFaceToClassify = TopoDS::Face(aF);
continue;
}
const BOPCol_ListOfShape* pLF = theEFMap.Seek(aE);
if (!pLF)
continue;
BOPCol_ListIteratorOfListOfShape aItLF(*pLF);
for (; aItLF.More(); aItLF.Next())
{
const TopoDS_Shape& aFToAdd = aItLF.Value();
if (theMFDone.Add(aFToAdd))
theLCB.Append(aFToAdd);
}
}
}
}
}
// Vector of solid classifiers
typedef BOPCol_NCVector<BOPAlgo_FillIn3DParts> BOPAlgo_VectorOfFillIn3DParts;
// Functors to perform classification
typedef BOPCol_ContextFunctor<BOPAlgo_FillIn3DParts,
BOPAlgo_VectorOfFillIn3DParts,
Handle(IntTools_Context),
IntTools_Context> BOPCol_FillIn3DPartsFunctor;
typedef BOPCol_ContextCnt<BOPCol_FillIn3DPartsFunctor,
BOPAlgo_VectorOfFillIn3DParts,
Handle(IntTools_Context)> BOPAlgo_FillIn3DPartsCnt;
//=======================================================================
//function : ClassifyFaces
//purpose :
//=======================================================================
void BOPAlgo_Tools::ClassifyFaces(const BOPCol_ListOfShape& theFaces,
const BOPCol_ListOfShape& theSolids,
const Standard_Boolean theRunParallel,
Handle(IntTools_Context)& theContext,
BOPCol_IndexedDataMapOfShapeListOfShape& theInParts,
const BOPCol_DataMapOfShapeBox& theShapeBoxMap,
const BOPCol_DataMapOfShapeListOfShape& theSolidsIF)
{
Handle(NCollection_BaseAllocator) anAlloc = new NCollection_IncAllocator;
// Fill the vector of shape box with faces and its bounding boxes
BOPAlgo_VectorOfShapeBox aVSB(256, anAlloc);
BOPCol_ListIteratorOfListOfShape aItLF(theFaces);
for (; aItLF.More(); aItLF.Next())
{
const TopoDS_Shape& aF = aItLF.Value();
// Append face to the vector of shape box
BOPAlgo_ShapeBox& aSB = aVSB.Append1();
aSB.SetShape(aF);
// Get bounding box for the face
const Bnd_Box* pBox = theShapeBoxMap.Seek(aF);
if (pBox)
aSB.SetBox(*pBox);
else
{
// Build the bounding box
Bnd_Box aBox;
BRepBndLib::Add(aF, aBox);
aSB.SetBox(aBox);
}
}
// Prepare UB tree of bounding boxes of the faces to classify
// taking the bounding boxes from the just prepared vector
BOPCol_BoxBndTree aBBTree;
NCollection_UBTreeFiller <Standard_Integer, Bnd_Box> aTreeFiller(aBBTree);
Standard_Integer aNbF = aVSB.Extent();
for (Standard_Integer i = 0; i < aNbF; ++i)
{
aTreeFiller.Add(i, aVSB(i).Box());
}
// Shake tree filler
aTreeFiller.Fill();
// Prepare vector of solids to classify
BOPAlgo_VectorOfFillIn3DParts aVFIP;
BOPCol_ListIteratorOfListOfShape aItLS(theSolids);
for (; aItLS.More(); aItLS.Next())
{
const TopoDS_Solid& aSolid = TopoDS::Solid(aItLS.Value());
// Append solid to the vector
BOPAlgo_FillIn3DParts& aFIP = aVFIP.Append1();
aFIP.SetSolid(aSolid);
// Get bounding box for the solid
const Bnd_Box* pBox = theShapeBoxMap.Seek(aSolid);
if (pBox)
aFIP.SetBoxS(*pBox);
else
{
// Build the bounding box
Bnd_Box aBox;
BRepBndLib::Add(aSolid, aBox);
if (!aBox.IsWhole())
{
if (BOPTools_AlgoTools::IsInvertedSolid(aSolid))
aBox.SetWhole();
}
aFIP.SetBoxS(aBox);
}
const BOPCol_ListOfShape* pLIF = theSolidsIF.Seek(aSolid);
if (pLIF)
aFIP.SetOwnIF(*pLIF);
aFIP.SetBBTree(aBBTree);
aFIP.SetShapeBoxVector(aVSB);
}
// Perform classification
//================================================================
BOPAlgo_FillIn3DPartsCnt::Perform(theRunParallel, aVFIP, theContext);
//================================================================
// Analyze the results and fill the resulting map
Standard_Integer aNbS = aVFIP.Extent();
for (Standard_Integer i = 0; i < aNbS; ++i)
{
BOPAlgo_FillIn3DParts& aFIP = aVFIP(i);
const TopoDS_Shape& aS = aFIP.Solid();
const BOPCol_ListOfShape& aLFIn = aFIP.InFaces();
theInParts.Add(aS, aLFIn);
}
}

View File

@@ -20,11 +20,18 @@
#include <Standard_Handle.hxx>
#include <BOPCol_BaseAllocator.hxx>
#include <BOPDS_IndexedDataMapOfPaveBlockListOfInteger.hxx>
#include <BOPCol_DataMapOfShapeBox.hxx>
#include <BOPCol_DataMapOfShapeListOfShape.hxx>
#include <BOPCol_IndexedDataMapOfShapeListOfShape.hxx>
#include <BOPCol_IndexedDataMapOfShapeReal.hxx>
#include <BOPCol_ListOfListOfShape.hxx>
#include <BOPCol_MapOfShape.hxx>
#include <BOPCol_ListOfShape.hxx>
#include <BOPDS_IndexedDataMapOfPaveBlockListOfInteger.hxx>
#include <BOPDS_IndexedDataMapOfPaveBlockListOfPaveBlock.hxx>
#include <BOPDS_PDS.hxx>
#include <Standard_Integer.hxx>
class BOPDS_PaveBlock;
@@ -155,6 +162,34 @@ public:
const Standard_Real theFuzzyValue,
BOPCol_ListOfListOfShape& theChains);
//! Collect in the output list recursively all non-compound subshapes of the first level
//! of the given shape theS. If a shape presents in the map theMFence it is skipped.
//! All shapes put in the output are also added into theMFence.
Standard_EXPORT static void TreatCompound(const TopoDS_Shape& theS,
BOPCol_MapOfShape& theMFence,
BOPCol_ListOfShape& theLS);
//! Classifies the faces <theFaces> relatively solids <theSolids>.
//! The IN faces for solids are stored into output data map <theInParts>.
//!
//! The map <theSolidsIF> contains INTERNAL faces of the solids, to avoid
//! their additional classification.
//!
//! Firstly, it checks the intersection of bounding boxes of the shapes.
//! If the Box is not stored in the <theShapeBoxMap> map, it builds the box.
//! If the bounding boxes of solid and face are interfering the classification is performed.
//!
//! It is assumed that all faces and solids are already intersected and
//! do not have any geometrically coinciding parts without topological
//! sharing of these parts
Standard_EXPORT static void ClassifyFaces(const BOPCol_ListOfShape& theFaces,
const BOPCol_ListOfShape& theSolids,
const Standard_Boolean theRunParallel,
Handle(IntTools_Context)& theContext,
BOPCol_IndexedDataMapOfShapeListOfShape& theInParts,
const BOPCol_DataMapOfShapeBox& theShapeBoxMap = BOPCol_DataMapOfShapeBox(),
const BOPCol_DataMapOfShapeListOfShape& theSolidsIF = BOPCol_DataMapOfShapeListOfShape());
};
#endif // _BOPAlgo_Tools_HeaderFile

View File

@@ -24,6 +24,7 @@
#include <BOPCol_NCVector.hxx>
#include <BOPCol_Parallel.hxx>
#include <BOPTools.hxx>
#include <BOPTools_AlgoTools.hxx>
#include <BRep_Builder.hxx>
#include <BRep_Tool.hxx>
#include <TopoDS.hxx>
@@ -124,153 +125,12 @@ void BOPAlgo_WireSplitter::Perform()
myContext = new IntTools_Context;
}
//
MakeConnexityBlocks();
BOPTools_AlgoTools::MakeConnexityBlocks
(myWES->StartElements(), TopAbs_VERTEX, TopAbs_EDGE, myLCB);
MakeWires();
}
//=======================================================================
//function : MakeConnexityBlocks
//purpose :
//=======================================================================
void BOPAlgo_WireSplitter::MakeConnexityBlocks()
{
Standard_Boolean bRegular, bClosed;
Standard_Integer i, j, aNbV, aNbVS, aNbVP, k;
TopoDS_Iterator aItE;
TopoDS_Shape aER;
BOPCol_ListIteratorOfListOfShape aIt;
//
BOPCol_IndexedDataMapOfShapeListOfShape aMVE(100, myAllocator);
BOPCol_IndexedMapOfShape aMVP(100, myAllocator);
BOPCol_IndexedMapOfShape aMEC(100, myAllocator);
BOPCol_MapOfShape aMER(100, myAllocator);
BOPCol_MapOfShape aMEP(100, myAllocator);
BOPCol_IndexedMapOfShape aMVAdd(100, myAllocator);
BOPCol_MapOfShape aMVS(100, myAllocator);
//
myLCB.Clear();
//
const BOPCol_ListOfShape& aLSE=myWES->StartElements();
aIt.Initialize(aLSE);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aE=aIt.Value();
if (aMEP.Add(aE)) {
BOPTools::MapShapesAndAncestors(aE, TopAbs_VERTEX, TopAbs_EDGE, aMVE);
}
else {
aMER.Add(aE);
}
}
//
// 2
aNbV=aMVE.Extent();
for (i=1; i<=aNbV; ++i) {
aNbVS=aMVS.Extent();
if (aNbVS==aNbV) {
break;
}
//
const TopoDS_Shape& aV=aMVE.FindKey(i);
//
if (!aMVS.Add(aV)) {
continue;
}
// aMVS - globally processed vertices
//
//------------------------------------- goal: aMEC
aMEC.Clear(); // aMEC - edges of CB
aMVP.Clear(); // aMVP - vertices to process right now
aMVAdd.Clear(); // aMVAdd vertices to process on next step of while(1)
//
aMVP.Add(aV);
//
for(;;) {
aNbVP=aMVP.Extent();
for (k=1; k<=aNbVP; ++k) {
const TopoDS_Shape& aVP=aMVP(k);
const BOPCol_ListOfShape& aLE=aMVE.FindFromKey(aVP);
aIt.Initialize(aLE);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aE=aIt.Value();
if (aMEC.Add(aE)) {
aItE.Initialize(aE);
for (; aItE.More(); aItE.Next()) {
const TopoDS_Shape& aVE=aItE.Value();
if (aMVS.Add(aVE)) {
aMVAdd.Add(aVE);
}
}
}
}
}//for (k=1; k<=aNbVP; ++k) {
//
aNbVP=aMVAdd.Extent();
if (!aNbVP) {
break; // from while(1)
}
//
aMVP.Clear();
//
for (k=1; k<=aNbVP; ++k) {
const TopoDS_Shape& aVE=aMVAdd(k);
aMVP.Add(aVE);
}
aMVAdd.Clear();
}// while(1) {
//-------------------------------------
BOPTools_ConnexityBlock aCB(myAllocator);
BOPCol_ListOfShape& aLEC=aCB.ChangeShapes();
BOPCol_IndexedDataMapOfShapeListOfShape aMVER(100, myAllocator);
//
bRegular=Standard_True;
Standard_Integer aNbCB = aMEC.Extent();
for (j = 1; j <= aNbCB; j++) {
aER = aMEC(j);
//
if (aMER.Contains(aER)) {
aER.Orientation(TopAbs_FORWARD);
aLEC.Append(aER);
aER.Orientation(TopAbs_REVERSED);
aLEC.Append(aER);
bRegular=Standard_False;
}
else {
aLEC.Append(aER);
}
//
if (bRegular) {
BOPTools::MapShapesAndAncestors(aER, TopAbs_VERTEX, TopAbs_EDGE, aMVER);
}
}
//
if (bRegular) {
Standard_Integer aNbVR, aNbER;
//
aNbVR=aMVER.Extent();
for (k=1; k<=aNbVR; ++k) {
const BOPCol_ListOfShape& aLER=aMVER(k);
aNbER=aLER.Extent();
if (aNbER==1) {
const TopoDS_Edge& aEx=TopoDS::Edge(aER);
bClosed=BRep_Tool::IsClosed(aEx, myWES->Face());
if (!bClosed) {
bRegular=!bRegular;
break;
}
}
if (aNbER>2) {
bRegular=!bRegular;
break;
}
}
}
//
aCB.SetRegular(bRegular);
myLCB.Append(aCB);
}
}
/////////////////////////////////////////////////////////////////////////
class BOPAlgo_WS_ConnexityBlock {
public:

View File

@@ -70,8 +70,6 @@ protected:
Standard_EXPORT virtual void CheckData() Standard_OVERRIDE;
Standard_EXPORT void MakeConnexityBlocks();
Standard_EXPORT void MakeWires();
BOPAlgo_PWireEdgeSet myWES;

View File

@@ -26,6 +26,10 @@ BOPAlgo_CheckResult.cxx
BOPAlgo_CheckResult.hxx
BOPAlgo_CheckStatus.hxx
BOPAlgo_ListOfCheckResult.hxx
BOPAlgo_MakeConnected.cxx
BOPAlgo_MakeConnected.hxx
BOPAlgo_MakePeriodic.cxx
BOPAlgo_MakePeriodic.hxx
BOPAlgo_MakerVolume.cxx
BOPAlgo_MakerVolume.hxx
BOPAlgo_MakerVolume.lxx
@@ -51,6 +55,8 @@ BOPAlgo_PBuilder.hxx
BOPAlgo_PPaveFiller.hxx
BOPAlgo_PSection.hxx
BOPAlgo_PWireEdgeSet.hxx
BOPAlgo_RemoveFeatures.cxx
BOPAlgo_RemoveFeatures.hxx
BOPAlgo_Section.cxx
BOPAlgo_Section.hxx
BOPAlgo_SectionAttribute.cxx

View File

@@ -0,0 +1,26 @@
// Created by: Eugeny MALTCHIKOV
// Copyright (c) 2017 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef BOPCol_DataMapOfShapeBox_HeaderFile
#define BOPCol_DataMapOfShapeBox_HeaderFile
#include <Bnd_Box.hxx>
#include <TopoDS_Shape.hxx>
#include <TopTools_ShapeMapHasher.hxx>
#include <NCollection_DataMap.hxx>
typedef NCollection_DataMap<TopoDS_Shape, Bnd_Box, TopTools_ShapeMapHasher> BOPCol_DataMapOfShapeBox;
#endif

View File

@@ -10,6 +10,7 @@ BOPCol_DataMapOfIntegerMapOfInteger.hxx
BOPCol_DataMapOfIntegerReal.hxx
BOPCol_DataMapOfIntegerShape.hxx
BOPCol_DataMapOfShapeAddress.hxx
BOPCol_DataMapOfShapeBox.hxx
BOPCol_DataMapOfShapeInteger.hxx
BOPCol_DataMapOfShapeListOfShape.hxx
BOPCol_DataMapOfShapeReal.hxx

View File

@@ -116,6 +116,23 @@ void BOPDS_CommonBlock::AppendFaces(BOPCol_ListOfInteger& aLF)
return myPaveBlocks.First();
}
//=======================================================================
// function: SetRealPaveBlock
// purpose:
//=======================================================================
void BOPDS_CommonBlock::SetRealPaveBlock(const Handle(BOPDS_PaveBlock)& thePB)
{
BOPDS_ListIteratorOfListOfPaveBlock it(myPaveBlocks);
for (; it.More(); it.Next())
{
if (it.Value() == thePB)
{
myPaveBlocks.Prepend(thePB);
myPaveBlocks.Remove(it);
break;
}
}
}
//=======================================================================
// function: PaveBlockOnEdge
// purpose:
//=======================================================================

View File

@@ -149,29 +149,21 @@ public:
Standard_EXPORT void Dump() const;
//! Moves the pave blocks in the list to make the given
//! pave block to be the first.
//! It will be representative for the whole group.
Standard_EXPORT void SetRealPaveBlock(const Handle(BOPDS_PaveBlock)& thePB);
DEFINE_STANDARD_RTTIEXT(BOPDS_CommonBlock,Standard_Transient)
protected:
BOPDS_ListOfPaveBlock myPaveBlocks;
BOPCol_ListOfInteger myFaces;
private:
};
#endif // _BOPDS_CommonBlock_HeaderFile

View File

@@ -545,108 +545,98 @@ void BOPDS_DS::Init(const Standard_Real theFuzz)
}//if (aTS==TopAbs_FACE) {
}//for (j=0; j<myNbSourceShapes; ++j) {
//
// 2.4 Solids
for (j=0; j<myNbSourceShapes; ++j) {
BOPDS_ShapeInfo& aSI=ChangeShapeInfo(j);
//
aTS=aSI.ShapeType();
if (aTS!=TopAbs_SOLID) {
continue;
}
Bnd_Box& aBox=aSI.ChangeBox();
BuildBndBoxSolid(j, aBox);
//
//
// update sub-shapes by BRep comprising ones
aMI.Clear();
BOPCol_ListOfInteger& aLI1=aSI.ChangeSubShapes();
//
aIt1.Initialize(aLI1);
for (; aIt1.More(); aIt1.Next()) {
n1=aIt1.Value();
BOPDS_ShapeInfo& aSI1=ChangeShapeInfo(n1);
if (aSI1.ShapeType()!=TopAbs_SHELL) {
// For the check mode we need to compute the bounding box for solid.
// Otherwise, it will be computed on the building stage
Standard_Boolean bCheckMode = (myArguments.Extent() == 1);
if (bCheckMode)
{
// 2.4 Solids
for (j=0; j<myNbSourceShapes; ++j) {
BOPDS_ShapeInfo& aSI=ChangeShapeInfo(j);
//
aTS=aSI.ShapeType();
if (aTS!=TopAbs_SOLID) {
continue;
}
Bnd_Box& aBox=aSI.ChangeBox();
BuildBndBoxSolid(j, aBox);
//
const BOPCol_ListOfInteger& aLI2=aSI1.SubShapes();
aIt2.Initialize(aLI2);
for (; aIt2.More(); aIt2.Next()) {
n2=aIt2.Value();
BOPDS_ShapeInfo& aSI2=ChangeShapeInfo(n2);
if (aSI2.ShapeType()!=TopAbs_FACE) {
//
// update sub-shapes by BRep comprising ones
aMI.Clear();
BOPCol_ListOfInteger& aLI1=aSI.ChangeSubShapes();
//
aIt1.Initialize(aLI1);
for (; aIt1.More(); aIt1.Next()) {
n1=aIt1.Value();
BOPDS_ShapeInfo& aSI1=ChangeShapeInfo(n1);
if (aSI1.ShapeType()!=TopAbs_SHELL) {
continue;
}
//
aMI.Add(n2);
//
const BOPCol_ListOfInteger& aLI3=aSI2.SubShapes();
aIt3.Initialize(aLI3);
for (; aIt3.More(); aIt3.Next()) {
n3=aIt3.Value();
aMI.Add(n3);
const BOPCol_ListOfInteger& aLI2=aSI1.SubShapes();
aIt2.Initialize(aLI2);
for (; aIt2.More(); aIt2.Next()) {
n2=aIt2.Value();
BOPDS_ShapeInfo& aSI2=ChangeShapeInfo(n2);
if (aSI2.ShapeType()!=TopAbs_FACE) {
continue;
}
//
aMI.Add(n2);
//
const BOPCol_ListOfInteger& aLI3=aSI2.SubShapes();
aIt3.Initialize(aLI3);
for (; aIt3.More(); aIt3.Next()) {
n3=aIt3.Value();
aMI.Add(n3);
}
}
}
}
//
aLI1.Clear();
aItMI.Initialize(aMI);
for (; aItMI.More(); aItMI.Next()) {
n1=aItMI.Value();
aLI1.Append(n1);
}
aMI.Clear();
}//for (j=0; j<myNbSourceShapes; ++j) {
//
aLI1.Clear();
aItMI.Initialize(aMI);
for (; aItMI.More(); aItMI.Next()) {
n1=aItMI.Value();
aLI1.Append(n1);
}
aMI.Clear();
}//for (j=0; j<myNbSourceShapes; ++j) {
}
//
aMI.Clear();
//-----------------------------------------------------
//
for (nE=0; nE<myNbSourceShapes; ++nE) {
BOPDS_ShapeInfo& aSI=ChangeShapeInfo(nE);
if (aSI.ShapeType()!=TopAbs_EDGE) {
// Prepare Vertex-Edge connection map
for (nE = 0; nE < myNbSourceShapes; ++nE)
{
BOPDS_ShapeInfo& aSI = ChangeShapeInfo(nE);
if (aSI.ShapeType() != TopAbs_EDGE)
continue;
}
//
const BOPCol_ListOfInteger& aLV=aSI.SubShapes();
const BOPCol_ListOfInteger& aLV = aSI.SubShapes();
aIt1.Initialize(aLV);
for (; aIt1.More(); aIt1.Next()) {
nV=aIt1.Value();
if (myMapVE.IsBound(nV)) {
BOPCol_ListOfInteger& aLE=myMapVE.ChangeFind(nV);
aLE.Append(nE);
for (; aIt1.More(); aIt1.Next())
{
nV = aIt1.Value();
BOPCol_ListOfInteger* pLE = myMapVE.ChangeSeek(nV);
if (!pLE) {
pLE = myMapVE.Bound(nV, BOPCol_ListOfInteger(myAllocator));
pLE->Append(nE);
}
else {
BOPCol_ListOfInteger aLE(myAllocator);
//
aLE.Append(nE);
myMapVE.Bind(nV, aLE);
else
{
// provide uniqueness of the edges in the list
for (aIt2.Initialize(*pLE); aIt2.More(); aIt2.Next())
{
if (aIt2.Value() == nE)
break;
}
if (!aIt2.More())
pLE->Append(nE);
}
}
}
//
BOPCol_DataMapIteratorOfDataMapOfIntegerListOfInteger aItDMILI;
aItDMILI.Initialize(myMapVE);
for(; aItDMILI.More(); aItDMILI.Next()) {
BOPCol_MapOfInteger aMFence;
BOPCol_ListOfInteger aLEx;
//
nV=aItDMILI.Key();
BOPCol_ListOfInteger& aLE=aItDMILI.ChangeValue();
aIt1.Initialize(aLE);
for (; aIt1.More(); aIt1.Next()) {
nE=aIt1.Value();
if(aMFence.Add(nE)) {
aLEx.Append(nE);
}
}
//
aLE.Clear();
aIt1.Initialize(aLEx);
for (; aIt1.More(); aIt1.Next()) {
nE=aIt1.Value();
aLE.Append(nE);
}
}
//-----------------------------------------------------scope_1 t
// 3 myPaveBlocksPool
// 4. myFaceInfoPool
@@ -1866,7 +1856,8 @@ Standard_Real ComputeParameter(const TopoDS_Vertex& aV,
//purpose :
//=======================================================================
void BOPDS_DS::BuildBndBoxSolid(const Standard_Integer theIndex,
Bnd_Box& aBoxS)
Bnd_Box& aBoxS,
const Standard_Boolean theCheckInverted)
{
Standard_Boolean bIsOpenBox, bIsInverted;
Standard_Integer nSh, nFc;
@@ -1930,7 +1921,7 @@ void BOPDS_DS::BuildBndBoxSolid(const Standard_Integer theIndex,
if (bIsOpenBox) {
aBoxS.SetWhole();
}
else {
else if (theCheckInverted) {
bIsInverted=BOPTools_AlgoTools::IsInvertedSolid(aSolid);
if (bIsInverted) {
aBoxS.SetWhole();
@@ -2006,17 +1997,13 @@ void BOPDS_DS::UpdateCommonBlockWithSDVertices
//=======================================================================
void BOPDS_DS::InitPaveBlocksForVertex(const Standard_Integer theNV)
{
Standard_Integer nE;
BOPCol_ListIteratorOfListOfInteger aItLE;
//
if (myMapVE.IsBound(theNV)) {
const BOPCol_ListOfInteger& aLE=myMapVE.Find(theNV);
aItLE.Initialize(aLE);
for (; aItLE.More(); aItLE.Next()) {
nE=aItLE.Value();
ChangePaveBlocks(nE);
}
}
const BOPCol_ListOfInteger* pLE = myMapVE.Seek(theNV);
if (!pLE)
return;
BOPCol_ListIteratorOfListOfInteger aItLE(*pLE);
for (; aItLE.More(); aItLE.Next())
ChangePaveBlocks(aItLE.Value());
}
//=======================================================================

View File

@@ -468,6 +468,13 @@ Standard_EXPORT virtual ~BOPDS_DS();
//! of the existing vertices have been increased.
Standard_EXPORT Standard_Boolean IsValidShrunkData(const Handle(BOPDS_PaveBlock)& thePB);
//! Computes bounding box <theBox> for the solid with DS-index <theIndex>.
//! The flag <theCheckInverted> enables/disables the check of the solid
//! for inverted status. By default the solids will be checked.
Standard_EXPORT void BuildBndBoxSolid (const Standard_Integer theIndex,
Bnd_Box& theBox,
const Standard_Boolean theCheckInverted = Standard_True);
protected:
@@ -485,10 +492,6 @@ protected:
const Standard_Real theFuzz);
//! Computes bouding box <theBox> for the solid with DS-index <theIndex>
Standard_EXPORT void BuildBndBoxSolid (const Standard_Integer theIndex, Bnd_Box& theBox);
BOPCol_BaseAllocator myAllocator;
BOPCol_ListOfShape myArguments;
Standard_Integer myNbShapes;

View File

@@ -17,6 +17,7 @@
#include <Bnd_Box.hxx>
#include <Bnd_OBB.hxx>
#include <BOPCol_BoxBndTree.hxx>
#include <BOPCol_NCVector.hxx>
#include <BOPCol_Parallel.hxx>
@@ -26,6 +27,7 @@
#include <BOPDS_Pair.hxx>
#include <BOPDS_MapOfPair.hxx>
#include <BOPDS_Tools.hxx>
#include <IntTools_Context.hxx>
#include <NCollection_UBTreeFiller.hxx>
#include <TopoDS_Shape.hxx>
#include <algorithm>
@@ -240,7 +242,9 @@ void BOPDS_Iterator::Value(Standard_Integer& theI1,
// function: Prepare
// purpose:
//=======================================================================
void BOPDS_Iterator::Prepare()
void BOPDS_Iterator::Prepare(const Handle(IntTools_Context)& theCtx,
const Standard_Boolean theCheckOBB,
const Standard_Real theFuzzyValue)
{
Standard_Integer i, aNbInterfTypes;
//
@@ -253,14 +257,16 @@ void BOPDS_Iterator::Prepare()
if (myDS==NULL){
return;
}
Intersect();
Intersect(theCtx, theCheckOBB, theFuzzyValue);
}
//
//=======================================================================
// function: Intersect
// purpose:
//=======================================================================
void BOPDS_Iterator::Intersect()
void BOPDS_Iterator::Intersect(const Handle(IntTools_Context)& theCtx,
const Standard_Boolean theCheckOBB,
const Standard_Real theFuzzyValue)
{
Standard_Integer i, j, iX, i1, i2, iR, aNb, aNbR;
Standard_Integer iTi, iTj;
@@ -339,6 +345,16 @@ void BOPDS_Iterator::Intersect()
//
BOPDS_Pair aPair(i, j);
if (aMPFence.Add(aPair)) {
if (theCheckOBB)
{
// Check intersection of Oriented bounding boxes of the shapes
Bnd_OBB& anOBBi = theCtx->OBB(aSI.Shape(), theFuzzyValue);
Bnd_OBB& anOBBj = theCtx->OBB(aSJ.Shape(), theFuzzyValue);
if (anOBBi.IsOut(anOBBj))
continue;
}
iX = BOPDS_Tools::TypeToInteger(aTi, aTj);
myLists(iX).Append(aPair);
}// if (aMPFence.Add(aPair)) {

View File

@@ -27,10 +27,11 @@
#include <BOPDS_PDS.hxx>
#include <BOPDS_VectorOfPair.hxx>
#include <BOPDS_VectorOfVectorOfPair.hxx>
#include <Precision.hxx>
#include <Standard_Boolean.hxx>
#include <TopAbs_ShapeEnum.hxx>
class BOPDS_DS;
class IntTools_Context;
//! The class BOPDS_Iterator is
@@ -81,7 +82,9 @@ public:
//! Perform the intersection algorithm and prepare
//! the results to be used
Standard_EXPORT virtual void Prepare();
Standard_EXPORT virtual void Prepare(const Handle(IntTools_Context)& theCtx = Handle(IntTools_Context)(),
const Standard_Boolean theCheckOBB = Standard_False,
const Standard_Real theFuzzyValue = Precision::Confusion());
//! Returns the number of intersections founded
Standard_EXPORT Standard_Integer ExpectedLength() const;
@@ -99,7 +102,9 @@ public:
protected:
Standard_EXPORT virtual void Intersect();
Standard_EXPORT virtual void Intersect(const Handle(IntTools_Context)& theCtx = Handle(IntTools_Context)(),
const Standard_Boolean theCheckOBB = Standard_False,
const Standard_Real theFuzzyValue = Precision::Confusion());
BOPCol_BaseAllocator myAllocator;
Standard_Integer myLength;

View File

@@ -13,6 +13,7 @@
// commercial license or contractual agreement.
#include <Bnd_Box.hxx>
#include <Bnd_OBB.hxx>
#include <BOPCol_BoxBndTree.hxx>
#include <BOPCol_DataMapOfIntegerInteger.hxx>
#include <BOPCol_DataMapOfIntegerListOfInteger.hxx>
@@ -28,6 +29,7 @@
#include <BOPDS_Tools.hxx>
#include <BRep_Tool.hxx>
#include <gp_Pnt.hxx>
#include <IntTools_Context.hxx>
#include <NCollection_UBTreeFiller.hxx>
#include <TopAbs_ShapeEnum.hxx>
#include <TopoDS.hxx>
@@ -78,7 +80,9 @@ void BOPDS_IteratorSI::UpdateByLevelOfCheck(const Standard_Integer theLevel)
// function: Intersect
// purpose:
//=======================================================================
void BOPDS_IteratorSI::Intersect()
void BOPDS_IteratorSI::Intersect(const Handle(IntTools_Context)& theCtx,
const Standard_Boolean theCheckOBB,
const Standard_Real theFuzzyValue)
{
Standard_Integer i, j, iX, aNbS;
Standard_Integer iTi, iTj;
@@ -138,6 +142,16 @@ void BOPDS_IteratorSI::Intersect()
//
BOPDS_Pair aPair(i, j);
if (aMPFence.Add(aPair)) {
if (theCheckOBB)
{
// Check intersection of Oriented bounding boxes of the shapes
Bnd_OBB& anOBBi = theCtx->OBB(aSI.Shape(), theFuzzyValue);
Bnd_OBB& anOBBj = theCtx->OBB(aSJ.Shape(), theFuzzyValue);
if (anOBBi.IsOut(anOBBj))
continue;
}
iX = BOPDS_Tools::TypeToInteger(aTi, aTj);
myLists(iX).Append(aPair);
}// if (aMPKXB.Add(aPKXB)) {

Some files were not shown because too many files have changed in this diff Show More