1. The methods PerformVZ, PerformEZ, PerformFZ and PerformZZ have been transferred from BOPAlgo_PaveFiller to BOPAlgo_CheckerSI class
to perform intersection of sub-shapes with solids only in self-intersection mode.
2. The checks for solids built from the same (shared) faces have been added into methods building the result of Boolean operations -
BOPAlgo_BOP::BuildRC() and BOPAlgo_BOP::BuildSolid().
3. Since the NonDestructive mode is now natively supported by the BOPAlgo_PaveFiller the methods providing the support of this mode by CheckerSI
(BOPAlgo_CheckerSI::PrepareCopy() and BOPAlgo_CheckerSI::PostTreatCopy()) are not needed and have been removed.
4. The pairs of sub-shapes with interfering bounding boxes are now sorted before real intersection to guarantee the constant order of
intersection of sub-shapes and produce more stable result. The class BOPDS_PassKey has been replaced with simpler class BOPDS_Pair.
5. The class BOPDS_SubIterator has been refactored.
6. Test cases for the issue.
7. Adjustment of the test case boolean volumemaker D2.
@subsection upgrade_720_Result_Of_BOP_On_Containers Result of Boolean operations on containers
-* The result of Boolean operations on arguments of collection types (WIRE/SHELL/COMPSOLID) is now filtered from duplicating containers.
\ No newline at end of file
+* The result of Boolean operations on arguments of collection types (WIRE/SHELL/COMPSOLID) is now filtered from duplicating containers.
+
+@subsection upgrade_720_BOP_DataStructure BOP - Pairs of interfering indices
+
+* The classes *BOPDS_PassKey* and *BOPDS_PassKeyBoolean* are too excessive and not used any more in Boolean Operations. To replace them the new *BOPDS_Pair* class has been implemented. Thus:
+ - The method *BOPDS_DS::Interferences()* now returns the *BOPDS_MapOfPair*;
+ - The method *BOPDS_Iterator::Value()* takes now only two parameters - the indices of interfering sub-shapes.
#include <BOPCol_IndexedMapOfShape.hxx>
#include <BOPCol_SequenceOfShape.hxx>
#include <BOPDS_DS.hxx>
-#include <BOPDS_MapOfPassKey.hxx>
+#include <BOPDS_MapOfPair.hxx>
#include <BOPTools.hxx>
#include <BOPTools_AlgoTools.hxx>
#include <BOPTools_AlgoTools3D.hxx>
}
//
Standard_Integer iErr, n1, n2;
- BOPDS_MapIteratorMapOfPassKey aItMPK;
+ BOPDS_MapIteratorOfMapOfPair aItMPK;
BOPCol_ListOfShape anArgs;
BOPAlgo_CheckerSI aChecker;
//
iErr=aChecker.ErrorStatus();
//
const BOPDS_DS& aDS=*(aChecker.PDS());
- const BOPDS_MapOfPassKey& aMPK=aDS.Interferences();
+ const BOPDS_MapOfPair& aMPK=aDS.Interferences();
//
aItMPK.Initialize(aMPK);
for (; aItMPK.More(); aItMPK.Next()) {
- const BOPDS_PassKey& aPK=aItMPK.Value();
- aPK.Ids(n1, n2);
+ const BOPDS_Pair& aPK=aItMPK.Value();
+ aPK.Indices(n1, n2);
if(aDS.IsNewShape(n1) || aDS.IsNewShape(n2)) {
continue;
}
static
Standard_Integer NbCommonItemsInMap(const BOPCol_MapOfShape& theM1,
const BOPCol_MapOfShape& theM2);
-
+//
+static
+ void MapFacesToBuildSolids(const TopoDS_Shape& theSol,
+ BOPCol_IndexedDataMapOfShapeListOfShape& theMFS,
+ BOPCol_IndexedMapOfShape& theMFI);
//=======================================================================
//function :
//
Standard_Integer i, j, aNb, iDim;
Standard_Boolean bCheckEdges, bContains, bCut21, bCommon;
- BOPCol_IndexedMapOfShape aMArgs, aMTools;
- BOPCol_IndexedMapOfShape aMArgsIm, aMToolsIm;
BOPCol_ListIteratorOfListOfShape aItLS;
//
+ // prepare the building elements of arguments to get its splits
+ BOPCol_IndexedMapOfShape aMArgs, aMTools;
for (i = 0; i < 2; ++i) {
const BOPCol_ListOfShape& aLS = !i ? myArguments : myTools;
BOPCol_IndexedMapOfShape& aMS = !i ? aMArgs : aMTools;
//
bCheckEdges = Standard_False;
//
+ // get splits of building elements
+ BOPCol_IndexedMapOfShape aMArgsIm, aMToolsIm;
+ BOPTools_IndexedDataMapOfSetShape aMSetArgs, aMSetTools;
+
for (i = 0; i < 2; ++i) {
const BOPCol_IndexedMapOfShape& aMS = !i ? aMArgs : aMTools;
BOPCol_IndexedMapOfShape& aMSIm = !i ? aMArgsIm : aMToolsIm;
+ BOPTools_IndexedDataMapOfSetShape& aMSet = !i ? aMSetArgs : aMSetTools;
//
aNb = aMS.Extent();
for (j = 1; j <= aNb; ++j) {
}
else {
aMSIm.Add(aS);
+ if (aS.ShapeType() == TopAbs_SOLID) {
+ BOPTools_Set aST;
+ aST.Add(aS, TopAbs_FACE);
+ if (!aMSet.Contains(aST)) {
+ aMSet.Add(aST, aS);
+ }
+ }
}
}
}
//
const BOPCol_IndexedMapOfShape& aMIt = bCut21 ? aMToolsIm : aMArgsIm;
const BOPCol_IndexedMapOfShape& aMCheck = bCut21 ? aMArgsIm : aMToolsIm;
+ const BOPTools_IndexedDataMapOfSetShape& aMSetCheck = bCut21 ? aMSetArgs : aMSetTools;
//
BOPCol_IndexedMapOfShape aMCheckExp, aMItExp;
//
const TopoDS_Shape& aS = aMItExp(i);
//
bContains = aMCheckExp.Contains(aS);
+ if (!bContains && aS.ShapeType() == TopAbs_SOLID) {
+ BOPTools_Set aST;
+ aST.Add(aS, TopAbs_FACE);
+ bContains = aMSetCheck.Contains(aST);
+ }
+ //
if (bCommon) {
if (bContains) {
aBB.Add(aC, aS);
//=======================================================================
void BOPAlgo_BOP::BuildSolid()
{
- Standard_Boolean bHasInterf, bHasSharedFaces;
- Standard_Integer i, aNbF, aNbSx, iX, iErr, aNbZ;
- TopAbs_Orientation aOr, aOr1;
- TopoDS_Iterator aIt;
- TopoDS_Shape aRC;
- BRep_Builder aBB;
- TopExp_Explorer aExp;
- BOPCol_IndexedMapOfShape aMFI;
- BOPCol_IndexedDataMapOfShapeListOfShape aMFS, aMEF;
- BOPCol_ListIteratorOfListOfShape aItLS;
- BOPCol_ListOfShape aSFS;
- BOPAlgo_BuilderSolid aSB;
- BOPCol_MapOfShape aMSA, aMZ;
- BOPTools_IndexedDataMapOfSetShape aDMSTS;
+ // Containers
BOPCol_ListOfShape aLSC;
//
+ BOPCol_ListIteratorOfListOfShape aItLS;
+ TopExp_Explorer aExp;
+ BRep_Builder aBB;
+ //
myErrorStatus=0;
//
- // Map of of Solids of Arguments
- for (i=0; i<2; ++i) {
- const BOPCol_ListOfShape& aLSA=(i) ? myArguments : myTools;
+ // Get solids from input arguments
+ BOPCol_MapOfShape aMSA;
+ // Map the arguments to find shared faces
+ BOPCol_IndexedDataMapOfShapeListOfShape aMFS;
+ for (Standard_Integer i = 0; i < 2; ++i) {
+ const BOPCol_ListOfShape& aLSA = (i) ? myArguments : myTools;
aItLS.Initialize(aLSA);
for (; aItLS.More(); aItLS.Next()) {
- const TopoDS_Shape& aSA=aItLS.Value();
- //
- CollectContainers(aSA, aLSC);
- //
+ const TopoDS_Shape& aSA = aItLS.Value();
aExp.Init(aSA, TopAbs_SOLID);
for (; aExp.More(); aExp.Next()) {
- const TopoDS_Shape& aZA=aExp.Current();
- aMSA.Add(aZA);
- //
- BOPTools::MapShapesAndAncestors(aZA,
- TopAbs_FACE,
- TopAbs_SOLID,
- aMFS);
+ const TopoDS_Shape& aSol = aExp.Current();
+ aMSA.Add(aSol);
+ BOPTools::MapShapesAndAncestors(aSol, TopAbs_FACE, TopAbs_SOLID, aMFS);
}
+ //
+ // get Compsolids from input arguments
+ CollectContainers(aSA, aLSC);
}
}
//
- aNbF=aMFS.Extent();
- for (i=1; i<aNbF; ++i) {
- //const TopoDS_Shape& aFA=aMFZA.FindKey(i);
- const BOPCol_ListOfShape& aLZA=aMFS(i);
- aNbZ=aLZA.Extent();
- if (aNbZ > 1) {
- aItLS.Initialize(aLZA);
+ // Find solids in input arguments sharing faces with other solids
+ BOPCol_MapOfShape aMTSols;
+ Standard_Integer i, aNb = aMFS.Extent();
+ for (i = 1; i < aNb; ++i) {
+ const BOPCol_ListOfShape& aLSols = aMFS(i);
+ if (aLSols.Extent() > 1) {
+ aItLS.Initialize(aLSols);
for(; aItLS.More(); aItLS.Next()) {
- const TopoDS_Shape& aZA=aItLS.Value();
- aMZ.Add(aZA);
+ aMTSols.Add(aItLS.Value());
}
}
}
//
+ // Possibly untouched solids - to be added to results as is
+ BOPCol_IndexedMapOfShape aMUSols;
+ // Use map to chose the most outer faces to build result solids
aMFS.Clear();
+ // Internal faces
+ BOPCol_IndexedMapOfShape aMFI;
//
- aIt.Initialize(myRC);
+ TopoDS_Iterator aIt(myRC);
for (; aIt.More(); aIt.Next()) {
- const TopoDS_Shape& aSx=aIt.Value();
+ const TopoDS_Shape& aSx = aIt.Value();
if (aMSA.Contains(aSx)) {
- iX=myDS->Index(aSx);
- bHasInterf=myDS->HasInterf(iX);
- bHasSharedFaces=aMZ.Contains(aSx);
- //
- if (!bHasInterf && !bHasSharedFaces) {
- // It means that the solid aSx will be added
- // to the result as is.
- // The solid aSx will not participate
- // in creation of a new solid(s).
- BOPTools_Set aST;
- //
- aST.Add(aSx, TopAbs_FACE);
- //
- if (!aDMSTS.Contains(aST)) {
- aDMSTS.Add(aST, aSx);
- }
-
- continue;
+ if (!aMTSols.Contains(aSx)) {
+ aMUSols.Add(aSx);
+ continue;
}
- }
+ }
+ //
+ MapFacesToBuildSolids(aSx, aMFS, aMFI);
+ } // for (; aIt.More(); aIt.Next()) {
+ //
+ // Process possibly untouched solids.
+ // Really untouched solids will be added into result as is.
+ // Others will be processed by BuilderSolid.
+ BOPTools_IndexedDataMapOfSetShape aDMSTS;
+ //
+ aNb = aMUSols.Extent();
+ for (i = 1; i <= aNb; ++i) {
+ const TopoDS_Shape& aSx = aMUSols(i);
//
aExp.Init(aSx, TopAbs_FACE);
for (; aExp.More(); aExp.Next()) {
- const TopoDS_Shape& aFx=aExp.Current();
- //
- aOr=aFx.Orientation();
- if (aOr==TopAbs_INTERNAL) {
- aMFI.Add(aFx);
- continue;
- }
- //
- if (!aMFS.Contains(aFx)) {
- BOPCol_ListOfShape aLSx;
- //
- aLSx.Append(aSx);
- aMFS.Add(aFx, aLSx);
+ if (aMFS.Contains(aExp.Current())) {
+ break;
}
- else {
- iX=aMFS.FindIndex(aFx);
- const TopoDS_Shape& aFx1=aMFS.FindKey(iX);
- aOr1=aFx1.Orientation();
- if (aOr1!=aOr) {
- BOPCol_ListOfShape& aLSx=aMFS.ChangeFromKey(aFx);
- aLSx.Append(aSx);
- aMFS.Add(aFx, aLSx);
- }
+ }
+ //
+ if (aExp.More()) {
+ MapFacesToBuildSolids(aSx, aMFS, aMFI);
+ }
+ else {
+ BOPTools_Set aST;
+ aST.Add(aSx, TopAbs_FACE);
+ if (!aDMSTS.Contains(aST)) {
+ aDMSTS.Add(aST, aSx);
}
}
- } // for (; aIt.More(); aIt.Next()) {
- //faces that will be added in the end;
- BOPCol_ListOfShape aLF, aLFx;
- // SFS
- aNbF=aMFS.Extent();
- for (i=1; i<=aNbF; ++i) {
- const TopoDS_Shape& aFx=aMFS.FindKey(i);
- const BOPCol_ListOfShape& aLSx=aMFS(i);
- aNbSx=aLSx.Extent();
- if (aNbSx==1) {
- BOPTools::MapShapesAndAncestors
- (aFx,TopAbs_EDGE, TopAbs_FACE, aMEF);
+ }
+ //
+ BOPCol_IndexedDataMapOfShapeListOfShape aMEF;
+ // Split faces will be added in the end
+ // to avoid errors in BuilderSolid algorithm
+ BOPCol_ListOfShape aLF, aLFx;
+ 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);
}
}
-
+ //
+ // Faces to build result solids
+ BOPCol_ListOfShape aSFS;
aItLS.Initialize(aLF);
for(; aItLS.More(); aItLS.Next()) {
- const TopoDS_Shape& aFx=aItLS.Value();
+ const TopoDS_Shape& aFx = aItLS.Value();
aSFS.Append(aFx);
}
- // add faces from aLFx to aSFS;
+ //
+ // Split faces
aItLS.Initialize(aLFx);
for (; aItLS.More(); aItLS.Next()) {
- const TopoDS_Shape& aFx=aItLS.Value();
- aSFS.Append(aFx);
- }
- //
- aNbF=aMFI.Extent();
- for (i=1; i<=aNbF; ++i) {
- TopoDS_Shape aFx;
- //
- aFx=aMFI.FindKey(i);
- aFx.Orientation(TopAbs_FORWARD);
- aSFS.Append(aFx);
- aFx.Orientation(TopAbs_REVERSED);
+ const TopoDS_Shape& aFx = aItLS.Value();
aSFS.Append(aFx);
}
//
- // BuilderSolid
- BOPTools_AlgoTools::MakeContainer(TopAbs_COMPOUND, aRC);
- //
- aSB.SetContext(myContext);
- aSB.SetShapes(aSFS);
- aSB.Perform();
- iErr=aSB.ErrorStatus();
- if (iErr) {
- myErrorStatus=30; // SolidBuilder failed
- return;
+ // Internal faces
+ aNb = aMFI.Extent();
+ for (i = 1; i <= aNb; ++i) {
+ TopoDS_Shape aFx = aMFI.FindKey(i);
+ aSFS.Append(aFx.Oriented(TopAbs_FORWARD));
+ aSFS.Append(aFx.Oriented(TopAbs_REVERSED));
}
//
- const BOPCol_ListOfShape& aLSR=aSB.Areas();
- //
- aItLS.Initialize(aLSR);
- for (; aItLS.More(); aItLS.Next()) {
- const TopoDS_Shape& aSR=aItLS.Value();
- aBB.Add(aRC, aSR);
+ TopoDS_Shape aRC;
+ 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.ErrorStatus()) {
+ myErrorStatus = 30; // SolidBuilder failed
+ return;
+ }
+ // new solids
+ const BOPCol_ListOfShape& aLSR = aSB.Areas();
+ //
+ // add new solids to result
+ aItLS.Initialize(aLSR);
+ for (; aItLS.More(); aItLS.Next()) {
+ const TopoDS_Shape& aSR = aItLS.Value();
+ aBB.Add(aRC, aSR);
+ }
}
//
- aNbSx = aDMSTS.Extent();
- for (i = 1; i <= aNbSx; ++i) {
+ // add untouched solids to result
+ aNb = aDMSTS.Extent();
+ for (i = 1; i <= aNb; ++i) {
const TopoDS_Shape& aSx = aDMSTS(i);
aBB.Add(aRC, aSx);
}
//
if (aLSC.IsEmpty()) {
// no Compsolids in arguments
- myShape=aRC;
+ myShape = aRC;
return;
}
//
TopoDS_Shape aResult;
BOPTools_AlgoTools::MakeContainer(TopAbs_COMPOUND, aResult);
//
+ aIt.Initialize(aRC);
+ if (!aIt.More()) {
+ // no solids in the result
+ myShape = aRC;
+ return;
+ }
+ //
+ const TopoDS_Shape& aSol1 = aIt.Value();
+ aIt.Next();
+ //
// optimization for one solid in the result
- if (aLSR.Extent() == 1 && !aNbSx) {
+ if (!aIt.More()) {
TopoDS_Shape aCS;
BOPTools_AlgoTools::MakeContainer(TopAbs_COMPSOLID, aCS);
- aBB.Add(aCS, aLSR.First());
+ aBB.Add(aCS, aSol1);
//
aBB.Add(aResult, aCS);
myShape = aResult;
}
return iCommon;
}
+//=======================================================================
+//function : MapFacesToBuildSolids
+//purpose : Stores the faces of the given solid into outgoing maps:
+// <theMFS> - not internal faces with reference to solid;
+// <theMFI> - internal faces.
+//=======================================================================
+void MapFacesToBuildSolids(const TopoDS_Shape& theSol,
+ BOPCol_IndexedDataMapOfShapeListOfShape& theMFS,
+ BOPCol_IndexedMapOfShape& theMFI)
+{
+ TopExp_Explorer aExp(theSol, TopAbs_FACE);
+ for (; aExp.More(); aExp.Next()) {
+ const TopoDS_Shape& aF = aExp.Current();
+ //
+ if (aF.Orientation() == TopAbs_INTERNAL) {
+ theMFI.Add(aF);
+ continue;
+ }
+ //
+ BOPCol_ListOfShape* pLSol = theMFS.ChangeSeek(aF);
+ if (!pLSol) {
+ pLSol = &theMFS(theMFS.Add(aF, BOPCol_ListOfShape()));
+ pLSol->Append(theSol);
+ }
+ else {
+ const TopoDS_Shape& aF1 = theMFS.FindKey(theMFS.FindIndex(aF));
+ if (aF1.Orientation() != aF.Orientation()) {
+ pLSol->Append(theSol);
+ }
+ }
+ }
+}
#include <BOPDS_DS.hxx>
#include <BOPDS_Interf.hxx>
#include <BOPDS_IteratorSI.hxx>
-#include <BOPDS_MapOfPassKey.hxx>
-#include <BOPDS_PassKey.hxx>
+#include <BOPDS_MapOfPair.hxx>
+#include <BOPDS_Pair.hxx>
#include <BOPDS_PIteratorSI.hxx>
#include <BOPDS_VectorOfInterfEF.hxx>
#include <BOPDS_VectorOfInterfFF.hxx>
void BOPAlgo_CheckerSI::Perform()
{
try {
- Standard_Integer iErr;
- //
OCC_CATCH_SIGNALS
//
- myErrorStatus=0;
- if (myArguments.Extent()!=1) {
- myErrorStatus=10;
+ myErrorStatus = 0;
+ if (myArguments.Extent() != 1) {
+ myErrorStatus = 10;
return;
}
//
- if (myNonDestructive) {
- PrepareCopy();
- if (myErrorStatus) {
- return;
- }
- }
- //
+ // Perform intersection of sub shapes
BOPAlgo_PaveFiller::Perform();
- iErr=myErrorStatus;
//
- PostTreat();
- if (myErrorStatus) {
- iErr=myErrorStatus;
- }
+ // Perform intersection with solids
+ if (!myErrorStatus)
+ PerformVZ();
//
- if (myNonDestructive) {
- PostTreatCopy();
- if (myErrorStatus) {
- iErr=myErrorStatus;
- }
- }
+ if (!myErrorStatus)
+ PerformEZ();
//
- if (iErr) {
- myErrorStatus=iErr;
- }
+ if (!myErrorStatus)
+ PerformFZ();
+ //
+ if (!myErrorStatus)
+ PerformZZ();
+ //
+ // Treat the intersection results
+ PostTreat();
}
//
catch (Standard_Failure) {
- if (myNonDestructive) {
- PostTreatCopy();
- }
- //
- myErrorStatus=11;
+ myErrorStatus = 11;
}
}
//=======================================================================
void BOPAlgo_CheckerSI::PostTreat()
{
Standard_Integer i, aNb, n1, n2;
- BOPDS_PassKey aPK;
+ BOPDS_Pair aPK;
//
myErrorStatus=0;
//
- BOPDS_MapOfPassKey& aMPK=
- *((BOPDS_MapOfPassKey*)&myDS->Interferences());
+ BOPDS_MapOfPair& aMPK=
+ *((BOPDS_MapOfPair*)&myDS->Interferences());
aMPK.Clear();
//
// 0
if (myDS->IsNewShape(n1) || myDS->IsNewShape(n2)) {
continue;
}
- aPK.SetIds(n1, n2);
+ aPK.SetIndices(n1, n2);
aMPK.Add(aPK);
}
//
if (myDS->IsNewShape(n1) || myDS->IsNewShape(n2)) {
continue;
}
- aPK.SetIds(n1, n2);
+ aPK.SetIndices(n1, n2);
aMPK.Add(aPK);
}
//
if (myDS->IsNewShape(n1) || myDS->IsNewShape(n2)) {
continue;
}
- aPK.SetIds(n1, n2);
+ aPK.SetIndices(n1, n2);
aMPK.Add(aPK);
}
//
if (myDS->IsNewShape(n1) || myDS->IsNewShape(n2)) {
continue;
}
- aPK.SetIds(n1, n2);
+ aPK.SetIndices(n1, n2);
aMPK.Add(aPK);
}
//
if (myDS->IsNewShape(n1) || myDS->IsNewShape(n2)) {
continue;
}
- aPK.SetIds(n1, n2);
+ aPK.SetIndices(n1, n2);
aMPK.Add(aPK);
}
//
continue;
}
//
- aPK.SetIds(n1, n2);
+ aPK.SetIndices(n1, n2);
aMPK.Add(aPK);
}
//
if (myDS->IsNewShape(n1) || myDS->IsNewShape(n2)) {
continue;
}
- aPK.SetIds(n1, n2);
+ aPK.SetIndices(n1, n2);
aMPK.Add(aPK);
}
//
//
const BOPDS_InterfEZ& aEZ=aEZs(i);
aEZ.Indices(n1, n2);
- aPK.SetIds(n1, n2);
+ aPK.SetIndices(n1, n2);
aMPK.Add(aPK);
}
//
//
const BOPDS_InterfFZ& aFZ=aFZs(i);
aFZ.Indices(n1, n2);
- aPK.SetIds(n1, n2);
+ aPK.SetIndices(n1, n2);
aMPK.Add(aPK);
}
//
//
const BOPDS_InterfZZ& aZZ=aZZs(i);
aZZ.Indices(n1, n2);
- aPK.SetIds(n1, n2);
+ aPK.SetIndices(n1, n2);
aMPK.Add(aPK);
}
}
-//=======================================================================
-//function : PrepareCopy
-//purpose :
-//=======================================================================
-void BOPAlgo_CheckerSI::PrepareCopy()
-{
- Standard_Boolean bIsDone;
- BRepBuilderAPI_Copy aCopier;
- BOPCol_MapOfShape aMSA;
- BOPCol_MapIteratorOfMapOfShape aItMS;
- //
- myErrorStatus=0;
- //
- myNewOldMap.Clear();
- //
- const TopoDS_Shape& aSA=myArguments.First();
- //
- BOPTools::MapShapes(aSA, aMSA);
- //
- aCopier.Perform(aSA, Standard_False);
- bIsDone=aCopier.IsDone();
- if (!bIsDone) {
- myErrorStatus=12;
- return;
- }
- //
- const TopoDS_Shape& aSC=aCopier.Shape();
- //
- aItMS.Initialize(aMSA);
- for(; aItMS.More(); aItMS.Next()) {
- const TopoDS_Shape& aSAx=aItMS.Value();
- const TopoDS_Shape& aSCx=aCopier.Modified(aSAx).First();
- myNewOldMap.Bind(aSCx, aSAx);
- }
- //
- myArguments.Clear();
- myArguments.Append(aSC);
-}
-//=======================================================================
-//function : PostTreatCopy
-//purpose :
-//=======================================================================
-void BOPAlgo_CheckerSI::PostTreatCopy()
-{
- Standard_Integer i, aNb;
- //
- myErrorStatus=0;
- //
- aNb=myDS->NbSourceShapes();
- for (i=0; i!=aNb; ++i) {
- BOPDS_ShapeInfo& aSI=myDS->ChangeShapeInfo(i);
- const TopoDS_Shape& aSCi=aSI.Shape();
- if (!myNewOldMap.IsBound(aSCi)) {
- myErrorStatus=13;
- return;
- }
- //
- const TopoDS_Shape& aSAi=myNewOldMap.Find(aSCi);
- aSI.SetShape(aSAi);
- }
-}
-//
-// myErrorStatus:
-//
-// 10 - The number of the arguments is not 1
-// 11 - Exception is caught
-// 12 - BRepBuilderAPI_Copy is not done
-// 13 - myNewOldMap doe not contain DS shape
-
#include <Standard_Integer.hxx>
#include <Standard_Boolean.hxx>
-#include <BOPCol_DataMapOfShapeShape.hxx>
#include <BOPAlgo_PaveFiller.hxx>
-//! Checks shape on self-interference.
+//! Checks the shape on self-interference.<br>
+//! In case of error the algorithm may return the following ErrorStatus:<br>
+//! 10 - The number of the input arguments is not one;<br>
+//! 11 - The check has been aborted during intersection of sub-shapes.<br>
+//! In case the error has occurred during intersection of sub-shapes, i.e.
+//! in BOPAlgo_PaveFiller::PerformInternal() method, the ErrorStatus from this method
+//! directly will be returned.
+
class BOPAlgo_CheckerSI : public BOPAlgo_PaveFiller
{
public:
DEFINE_STANDARD_ALLOC
-
+
Standard_EXPORT BOPAlgo_CheckerSI();
-Standard_EXPORT virtual ~BOPAlgo_CheckerSI();
+ Standard_EXPORT virtual ~BOPAlgo_CheckerSI();
Standard_EXPORT virtual void Perform() Standard_OVERRIDE;
- //! Sets the level of checking shape on self-interference.
- //! It defines which interferferences will be checked:
- //! 0 - only V/V;
- //! 1 - V/V and V/E;
- //! 2 - V/V, V/E and E/E;
- //! 3 - V/V, V/E, E/E and V/F;
- //! 4 - V/V, V/E, E/E, V/F and E/F;
- //! 5 - all interferences, default value.
+ //! Sets the level of checking shape on self-interference.<br>
+ //! It defines which interferences will be checked:<br>
+ //! 0 - only V/V;<br>
+ //! 1 - V/V and V/E;<br>
+ //! 2 - V/V, V/E and E/E;<br>
+ //! 3 - V/V, V/E, E/E and V/F;<br>
+ //! 4 - V/V, V/E, E/E, V/F and E/F;<br>
+ //! 5 - V/V, V/E, E/E, V/F, E/F and F/F;<br>
+ //! 6 - V/V, V/E, E/E, V/F, E/F, F/F and V/S;<br>
+ //! 7 - V/V, V/E, E/E, V/F, E/F, F/F, V/S and E/S;<br>
+ //! 8 - V/V, V/E, E/E, V/F, E/F, F/F, V/S, E/S and F/S;<br>
+ //! 9 - V/V, V/E, E/E, V/F, E/F, F/F, V/S, E/S, F/S and S/S - all interferences (Default value)
Standard_EXPORT void SetLevelOfCheck (const Standard_Integer theLevel);
protected:
-
Standard_EXPORT virtual void Init() Standard_OVERRIDE;
-
- //! Provides post-treatment actions
+
+ //! Treats the intersection results
Standard_EXPORT void PostTreat();
-
- Standard_EXPORT virtual void PrepareCopy();
-
- //! Provides post-treatment actions for the copy
- Standard_EXPORT void PostTreatCopy();
+ //! Methods for intersection with solids
- Standard_Integer myLevelOfCheck;
- BOPCol_DataMapOfShapeShape myNewOldMap;
+ //! Vertex/Solid intersection
+ Standard_EXPORT virtual void PerformVZ();
+ //! Edge/Solid intersection
+ Standard_EXPORT virtual void PerformEZ();
-private:
+ //! Face/Solid intersection
+ Standard_EXPORT virtual void PerformFZ();
+ //! Solid/Solid intersection
+ Standard_EXPORT virtual void PerformZZ();
+ //! Used for intersection of edges and faces with solids
+ Standard_EXPORT virtual void PerformSZ(const TopAbs_ShapeEnum aTS);
+ Standard_Integer myLevelOfCheck;
+private:
};
-
-
-
-
-
-
#endif // _BOPAlgo_CheckerSI_HeaderFile
--- /dev/null
+// Created by: Peter KURNEV
+// Copyright (c) 2010-2014 OPEN CASCADE SAS
+// Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT,
+// EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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_CheckerSI.hxx>
+
+#include <BOPDS_DS.hxx>
+#include <BOPDS_Interf.hxx>
+#include <BOPDS_IteratorSI.hxx>
+
+#include <BOPCol_NCVector.hxx>
+#include <BOPCol_Parallel.hxx>
+
+#include <BRep_Tool.hxx>
+#include <BRepClass3d_SolidClassifier.hxx>
+
+#include <IntTools_Context.hxx>
+
+#include <gp_Pnt.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopAbs_State.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Solid.hxx>
+
+/////////////////////////////////////////////////////////////////////////
+//=======================================================================
+//class : BOPAlgo_VertexSolid
+//purpose :
+//=======================================================================
+class BOPAlgo_VertexSolid {
+ public:
+ DEFINE_STANDARD_ALLOC
+
+ BOPAlgo_VertexSolid()
+ : myIV(-1), myIZ(-1), myState(TopAbs_UNKNOWN) {
+ };
+ //
+ virtual ~BOPAlgo_VertexSolid(){
+ };
+ //
+ void SetIndices(const Standard_Integer nV,
+ const Standard_Integer nZ){
+ myIV=nV;
+ myIZ=nZ;
+ }
+ //
+ void Indices(Standard_Integer& nV,
+ Standard_Integer& nZ) const {
+ nV=myIV;
+ nZ=myIZ;
+ }
+ //
+ void SetVertex(const TopoDS_Vertex& aV) {
+ myV=aV;
+ }
+ //
+ const TopoDS_Vertex& Vertex()const {
+ return myV;
+ }
+ //
+ void SetSolid(const TopoDS_Solid& aZ) {
+ myZ=aZ;
+ }
+ //
+ const TopoDS_Solid& Solid()const {
+ return myZ;
+ }
+ //
+ void SetContext(const Handle(IntTools_Context)& aContext) {
+ myContext=aContext;
+ }
+ //
+ const Handle(IntTools_Context)& Context()const {
+ return myContext;
+ }
+ //
+ TopAbs_State State() const{
+ return myState;
+ };
+ //
+ void Perform() {
+ Standard_Real aTol;
+ gp_Pnt aPV;
+ //
+ BRepClass3d_SolidClassifier& aSC=myContext->SolidClassifier(myZ);
+ //
+ aPV=BRep_Tool::Pnt(myV);
+ aTol=BRep_Tool::Tolerance(myV);
+ //
+ aSC.Perform(aPV, aTol);
+ //
+ myState=aSC.State();
+ };
+ //
+ protected:
+ Standard_Integer myIV;
+ Standard_Integer myIZ;
+ TopAbs_State myState;
+ TopoDS_Vertex myV;
+ TopoDS_Solid myZ;
+ Handle(IntTools_Context) myContext;
+};
+//=======================================================================
+typedef BOPCol_NCVector
+ <BOPAlgo_VertexSolid> BOPAlgo_VectorOfVertexSolid;
+//
+typedef BOPCol_ContextFunctor
+ <BOPAlgo_VertexSolid,
+ BOPAlgo_VectorOfVertexSolid,
+ Handle(IntTools_Context),
+ IntTools_Context> BOPAlgo_VertexSolidFunctor;
+//
+typedef BOPCol_ContextCnt
+ <BOPAlgo_VertexSolidFunctor,
+ BOPAlgo_VectorOfVertexSolid,
+ Handle(IntTools_Context)> BOPAlgo_VertexSolidCnt;
+/////////////////////////////////////////////////////////////////////////
+//=======================================================================
+//class : BOPAlgo_ShapeSolid
+//purpose :
+//=======================================================================
+class BOPAlgo_ShapeSolid {
+ public:
+ DEFINE_STANDARD_ALLOC
+
+ BOPAlgo_ShapeSolid() :
+ myIE(-1),
+ myIZ(-1),
+ myHasInterf(Standard_False),
+ myDS(NULL) {
+ };
+ //
+ virtual ~BOPAlgo_ShapeSolid(){
+ };
+ //
+ void SetIndices(const Standard_Integer nE,
+ const Standard_Integer nZ){
+ myIE=nE;
+ myIZ=nZ;
+ }
+ //
+ void Indices(Standard_Integer& nE,
+ Standard_Integer& nZ) const {
+ nE=myIE;
+ nZ=myIZ;
+ }
+ //
+ void SetDS(BOPDS_DS* pDS) {
+ myDS=pDS;
+ }
+ //
+ Standard_Boolean HasInterf() const{
+ return myHasInterf;
+ };
+ //
+ virtual void Perform() {
+ Standard_Boolean bHasInterf;
+ //
+ myHasInterf=Standard_False;
+ //
+ bHasInterf=myDS->HasInterfShapeSubShapes(myIE, myIZ);
+ if (!bHasInterf) {
+ myHasInterf=myDS->HasInterfShapeSubShapes(myIZ, myIE);
+ }
+ };
+ //
+ protected:
+ Standard_Integer myIE;
+ Standard_Integer myIZ;
+ Standard_Boolean myHasInterf;
+ BOPDS_DS* myDS;
+};
+//=======================================================================
+typedef BOPCol_NCVector
+ <BOPAlgo_ShapeSolid> BOPAlgo_VectorOfShapeSolid;
+//
+typedef BOPCol_Functor
+ <BOPAlgo_ShapeSolid,
+ BOPAlgo_VectorOfShapeSolid> BOPAlgo_ShapeSolidFunctor;
+//
+typedef BOPCol_Cnt
+ <BOPAlgo_ShapeSolidFunctor,
+ BOPAlgo_VectorOfShapeSolid> BOPAlgo_ShapeSolidCnt;
+//
+/////////////////////////////////////////////////////////////////////////
+//=======================================================================
+//class : BOPAlgo_SolidSolid
+//purpose :
+//=======================================================================
+class BOPAlgo_SolidSolid : public BOPAlgo_ShapeSolid {
+ public:
+ DEFINE_STANDARD_ALLOC
+
+ BOPAlgo_SolidSolid() :
+ BOPAlgo_ShapeSolid() {
+ };
+ //
+ virtual ~BOPAlgo_SolidSolid(){
+ };
+ //
+ virtual void Perform() {
+ Standard_Boolean bFlag;
+ //
+ bFlag=Standard_False;
+ myHasInterf=Standard_False;
+ //
+ myHasInterf=myDS->HasInterfShapeSubShapes(myIZ, myIE, bFlag);
+ if (!myHasInterf) {
+ myHasInterf=myDS->HasInterfShapeSubShapes(myIE, myIZ, bFlag);
+ }
+ };
+};
+//=======================================================================
+typedef BOPCol_NCVector
+ <BOPAlgo_SolidSolid> BOPAlgo_VectorOfSolidSolid;
+//
+typedef BOPCol_Functor
+ <BOPAlgo_SolidSolid,
+ BOPAlgo_VectorOfSolidSolid> BOPAlgo_SolidSolidFunctor;
+//
+typedef BOPCol_Cnt
+ <BOPAlgo_SolidSolidFunctor,
+ BOPAlgo_VectorOfSolidSolid> BOPAlgo_SolidSolidCnt;
+//
+/////////////////////////////////////////////////////////////////////////
+
+//=======================================================================
+//function : PerformVZ
+//purpose :
+//=======================================================================
+void BOPAlgo_CheckerSI::PerformVZ()
+{
+ Standard_Integer iSize, nV, nZ, k, aNbVVS;
+ TopAbs_State aState;
+ BOPDS_MapOfPair aMPK;
+ //
+ myErrorStatus=0;
+ //
+ myIterator->Initialize(TopAbs_VERTEX, TopAbs_SOLID);
+ iSize=myIterator->ExpectedLength();
+ if (!iSize) {
+ return;
+ }
+ //
+ BOPDS_VectorOfInterfVZ& aVZs=myDS->InterfVZ();
+ aVZs.SetIncrement(iSize);
+ //
+ BOPAlgo_VectorOfVertexSolid aVVS;
+ //
+ for (; myIterator->More(); myIterator->Next()) {
+ myIterator->Value(nV, nZ);
+ //
+ if (myDS->HasInterfShapeSubShapes(nV, nZ)) {
+ continue;
+ }
+ //
+ Standard_Integer nVSD = nV;
+ myDS->HasShapeSD(nV, nVSD);
+ //
+ BOPDS_Pair aPK;
+ aPK.SetIndices(nVSD, nZ);
+ if (!aMPK.Add(aPK)) {
+ continue;
+ }
+ //
+ const TopoDS_Vertex& aV=*((TopoDS_Vertex*)&myDS->Shape(nVSD));
+ const TopoDS_Solid& aZ=*((TopoDS_Solid*)&myDS->Shape(nZ));
+ //
+ BOPAlgo_VertexSolid& aVertexSolid=aVVS.Append1();
+ aVertexSolid.SetIndices(nV, nZ);
+ aVertexSolid.SetVertex(aV);
+ aVertexSolid.SetSolid(aZ);
+ }
+ //
+ aNbVVS=aVVS.Extent();
+ //=============================================================
+ BOPAlgo_VertexSolidCnt::Perform(myRunParallel, aVVS, myContext);
+ //=============================================================
+ for (k=0; k < aNbVVS; ++k) {
+ const BOPAlgo_VertexSolid& aVertexSolid=aVVS(k);
+ aState=aVertexSolid.State();
+ if (aState==TopAbs_IN) {
+ aVertexSolid.Indices(nV, nZ);
+ //
+ BOPDS_InterfVZ& aVZ=aVZs.Append1();
+ aVZ.SetIndices(nV, nZ);
+ //
+ myDS->AddInterf(nV, nZ);
+ }
+ }
+}
+//=======================================================================
+//function : PerformEZ
+//purpose :
+//=======================================================================
+void BOPAlgo_CheckerSI::PerformEZ()
+{
+ PerformSZ(TopAbs_EDGE);
+}
+//=======================================================================
+//function : PerformFZ
+//purpose :
+//=======================================================================
+void BOPAlgo_CheckerSI::PerformFZ()
+{
+ PerformSZ(TopAbs_FACE);
+}
+//=======================================================================
+//function : PerformZZ
+//purpose :
+//=======================================================================
+void BOPAlgo_CheckerSI::PerformZZ()
+{
+ Standard_Boolean bHasInterf;
+ Standard_Integer iSize, nZ1, nZ, k, aNbSolidSolid;
+ //
+ myErrorStatus=0;
+ //
+ myIterator->Initialize(TopAbs_SOLID, TopAbs_SOLID);
+ iSize=myIterator->ExpectedLength();
+ if (!iSize) {
+ return;
+ }
+ //
+ BOPAlgo_VectorOfSolidSolid aVSolidSolid;
+ //
+ for (; myIterator->More(); myIterator->Next()) {
+ myIterator->Value(nZ1, nZ);
+ //
+ BOPAlgo_SolidSolid& aSolidSolid=aVSolidSolid.Append1();
+ aSolidSolid.SetIndices(nZ1, nZ);
+ aSolidSolid.SetDS(myDS);
+ }
+ //
+ aNbSolidSolid=aVSolidSolid.Extent();
+ //======================================================
+ BOPAlgo_SolidSolidCnt::Perform(myRunParallel, aVSolidSolid);
+ //======================================================
+ //
+ BOPDS_VectorOfInterfZZ& aZZs=myDS->InterfZZ();
+ //
+ aZZs.SetIncrement(iSize);
+ //
+ for (k=0; k < aNbSolidSolid; ++k) {
+ const BOPAlgo_SolidSolid& aSolidSolid=aVSolidSolid(k);
+ bHasInterf=aSolidSolid.HasInterf();
+ if (bHasInterf) {
+ aSolidSolid.Indices(nZ1, nZ);
+ //
+ BOPDS_InterfZZ& aZZ=aZZs.Append1();
+ aZZ.SetIndices(nZ1, nZ);
+ //
+ myDS->AddInterf(nZ1, nZ);
+ }
+ }
+}
+//=======================================================================
+//function : PerformSZ
+//purpose :
+//=======================================================================
+void BOPAlgo_CheckerSI::PerformSZ(const TopAbs_ShapeEnum aTS)
+{
+ Standard_Boolean bHasInterf;
+ Standard_Integer iSize, nS, nZ, k, aNbShapeSolid;
+ //
+ myErrorStatus=0;
+ //
+ myIterator->Initialize(aTS, TopAbs_SOLID);
+ iSize=myIterator->ExpectedLength();
+ if (!iSize) {
+ return;
+ }
+ //
+ BOPAlgo_VectorOfShapeSolid aVShapeSolid;
+ //
+ for (; myIterator->More(); myIterator->Next()) {
+ myIterator->Value(nS, nZ);
+ //
+ BOPAlgo_ShapeSolid& aShapeSolid=aVShapeSolid.Append1();
+ aShapeSolid.SetIndices(nS, nZ);
+ aShapeSolid.SetDS(myDS);
+ }
+ //
+ aNbShapeSolid=aVShapeSolid.Extent();
+ //======================================================
+ BOPAlgo_ShapeSolidCnt::Perform(myRunParallel, aVShapeSolid);
+ //======================================================
+ //
+ BOPDS_VectorOfInterfEZ& aEZs=myDS->InterfEZ();
+ BOPDS_VectorOfInterfFZ& aFZs=myDS->InterfFZ();
+ //
+ if (aTS==TopAbs_EDGE) {
+ aEZs.SetIncrement(iSize);
+ }
+ else {//if (aTS==TopAbs_FACE)
+ aFZs.SetIncrement(iSize);
+ }
+ //
+ for (k=0; k < aNbShapeSolid; ++k) {
+ const BOPAlgo_ShapeSolid& aShapeSolid=aVShapeSolid(k);
+ bHasInterf=aShapeSolid.HasInterf();
+ if (bHasInterf) {
+ aShapeSolid.Indices(nS, nZ);
+ //
+ if (aTS==TopAbs_EDGE) {
+ BOPDS_InterfEZ& aEZ=aEZs.Append1();
+ aEZ.SetIndices(nS, nZ);
+ }
+ else {//if (aTS==TopAbs_FACE)
+ BOPDS_InterfFZ& aFZ=aFZs.Append1();
+ aFZ.SetIndices(nS, nZ);
+ }
+ //
+ myDS->AddInterf(nS, nZ);
+ }
+ }
+}
if (myErrorStatus) {
return;
}
- //
- if (myGlue != BOPAlgo_GlueOff) {
- return;
- }
- // 03
- PerformVZ();
- if (myErrorStatus) {
- return;
- }
- // 13
- PerformEZ();
- if (myErrorStatus) {
- return;
- }
- // 23
- PerformFZ();
- if (myErrorStatus) {
- return;
- }
- // 33
- PerformZZ();
- if (myErrorStatus) {
- return;
- }
-}
+}
Standard_EXPORT virtual void PerformFF();
- Standard_EXPORT virtual void PerformVZ();
-
- Standard_EXPORT virtual void PerformEZ();
-
- Standard_EXPORT virtual void PerformFZ();
-
- Standard_EXPORT virtual void PerformZZ();
-
- Standard_EXPORT virtual void PerformSZ(const TopAbs_ShapeEnum aTS);
-
Standard_EXPORT void TreatVerticesEE();
Standard_EXPORT void MakeSDVerticesFF(const BOPCol_DataMapOfIntegerListOfInteger& aDMVLV,
//=======================================================================
void BOPAlgo_PaveFiller::PerformVV()
{
- Standard_Boolean bWithSubShape;
Standard_Integer n1, n2, iFlag, aSize, k, aNbBlocks;
Handle(NCollection_BaseAllocator) aAllocator;
//
//
// 1. Map V/LV
for (; myIterator->More(); myIterator->Next()) {
- myIterator->Value(n1, n2, bWithSubShape);
+ myIterator->Value(n1, n2);
//
const TopoDS_Vertex& aV1=(*(TopoDS_Vertex *)(&myDS->Shape(n1)));
const TopoDS_Vertex& aV2=(*(TopoDS_Vertex *)(&myDS->Shape(n2)));
// commercial license or contractual agreement.
#include <BOPAlgo_PaveFiller.hxx>
-#include <BOPAlgo_SectionAttribute.hxx>
-#include <BOPDS_Curve.hxx>
-#include <BOPDS_DS.hxx>
-#include <BOPDS_Interf.hxx>
-#include <BOPDS_IteratorSI.hxx>
-#include <BOPDS_PaveBlock.hxx>
-#include <BRep_Tool.hxx>
-#include <BRepClass3d_SolidClassifier.hxx>
-#include <IntTools_Context.hxx>
-#include <TopoDS_Vertex.hxx>
+
+#include <Precision.hxx>
+
#include <gp_Pnt.hxx>
-#include <BOPCol_NCVector.hxx>
-#include <TopAbs_State.hxx>
-#include <BOPCol_Parallel.hxx>
-#include <TopoDS_Face.hxx>
-#include <TopoDS_Solid.hxx>
-/////////////////////////////////////////////////////////////////////////
+#include <Bnd_Box.hxx>
+
+#include <TopoDS_Iterator.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Edge.hxx>
+
+#include <BRep_Tool.hxx>
+#include <BRep_Builder.hxx>
+#include <BRepBndLib.hxx>
+
+#include <BOPDS_ShapeInfo.hxx>
+#include <BOPDS_VectorOfListOfPaveBlock.hxx>
+#include <BOPDS_MapOfCommonBlock.hxx>
+#include <BOPDS_ListOfPaveBlock.hxx>
+#include <BOPDS_CommonBlock.hxx>
+#include <BOPDS_DS.hxx>
+
//=======================================================================
-//class : BOPAlgo_VertexSolid
+//function : SetNonDestructive
//purpose :
//=======================================================================
-class BOPAlgo_VertexSolid {
- public:
- DEFINE_STANDARD_ALLOC
-
- BOPAlgo_VertexSolid()
- : myIV(-1), myIZ(-1), myState(TopAbs_UNKNOWN) {
- };
- //
- virtual ~BOPAlgo_VertexSolid(){
- };
- //
- void SetIndices(const Standard_Integer nV,
- const Standard_Integer nZ){
- myIV=nV;
- myIZ=nZ;
- }
- //
- void Indices(Standard_Integer& nV,
- Standard_Integer& nZ) const {
- nV=myIV;
- nZ=myIZ;
- }
- //
- void SetVertex(const TopoDS_Vertex& aV) {
- myV=aV;
- }
- //
- const TopoDS_Vertex& Vertex()const {
- return myV;
- }
- //
- void SetSolid(const TopoDS_Solid& aZ) {
- myZ=aZ;
+void BOPAlgo_PaveFiller::SetNonDestructive()
+{
+ if (!myIsPrimary || myNonDestructive) {
+ return;
}
//
- const TopoDS_Solid& Solid()const {
- return myZ;
- }
+ Standard_Boolean bFlag;
+ BOPCol_ListIteratorOfListOfShape aItLS;
//
- void SetContext(const Handle(IntTools_Context)& aContext) {
- myContext=aContext;
+ bFlag=Standard_False;
+ aItLS.Initialize(myArguments);
+ for(; aItLS.More() && (!bFlag); aItLS.Next()) {
+ const TopoDS_Shape& aS=aItLS.Value();
+ bFlag=aS.Locked();
}
- //
- const Handle(IntTools_Context)& Context()const {
- return myContext;
- }
- //
- TopAbs_State State() const{
- return myState;
- };
- //
- void Perform() {
- Standard_Real aTol;
- gp_Pnt aPV;
- //
- BRepClass3d_SolidClassifier& aSC=myContext->SolidClassifier(myZ);
- //
- aPV=BRep_Tool::Pnt(myV);
- aTol=BRep_Tool::Tolerance(myV);
- //
- aSC.Perform(aPV, aTol);
- //
- myState=aSC.State();
- };
- //
- protected:
- Standard_Integer myIV;
- Standard_Integer myIZ;
- TopAbs_State myState;
- TopoDS_Vertex myV;
- TopoDS_Solid myZ;
- Handle(IntTools_Context) myContext;
-};
-//=======================================================================
-typedef BOPCol_NCVector
- <BOPAlgo_VertexSolid> BOPAlgo_VectorOfVertexSolid;
-//
-typedef BOPCol_ContextFunctor
- <BOPAlgo_VertexSolid,
- BOPAlgo_VectorOfVertexSolid,
- Handle(IntTools_Context),
- IntTools_Context> BOPAlgo_VertexSolidFunctor;
-//
-typedef BOPCol_ContextCnt
- <BOPAlgo_VertexSolidFunctor,
- BOPAlgo_VectorOfVertexSolid,
- Handle(IntTools_Context)> BOPAlgo_VertexSolidCnt;
-/////////////////////////////////////////////////////////////////////////
+ myNonDestructive=bFlag;
+}
//=======================================================================
-//class : BOPAlgo_ShapeSolid
+//function : UpdateEdgeTolerance
//purpose :
//=======================================================================
-class BOPAlgo_ShapeSolid {
- public:
- DEFINE_STANDARD_ALLOC
-
- BOPAlgo_ShapeSolid() :
- myIE(-1),
- myIZ(-1),
- myHasInterf(Standard_False),
- myDS(NULL) {
- };
- //
- virtual ~BOPAlgo_ShapeSolid(){
- };
- //
- void SetIndices(const Standard_Integer nE,
- const Standard_Integer nZ){
- myIE=nE;
- myIZ=nZ;
- }
- //
- void Indices(Standard_Integer& nE,
- Standard_Integer& nZ) const {
- nE=myIE;
- nZ=myIZ;
- }
- //
- void SetDS(BOPDS_DS* pDS) {
- myDS=pDS;
- }
- //
- Standard_Boolean HasInterf() const{
- return myHasInterf;
- };
- //
- virtual void Perform() {
- Standard_Boolean bHasInterf;
- //
- myHasInterf=Standard_False;
+void BOPAlgo_PaveFiller::UpdateEdgeTolerance (const Standard_Integer nE,
+ const Standard_Real aTol)
+{
+ Standard_Boolean bIsNewShape, bHasShapeSD;
+ Standard_Integer nV, nVx;
+ Standard_Real aTolV;
+ BRep_Builder aBB;
+ BOPCol_ListIteratorOfListOfInteger aIt;
+ //
+ BOPDS_ShapeInfo& aSIE=myDS->ChangeShapeInfo(nE);
+ const BOPCol_ListOfInteger& aLI=aSIE.SubShapes();
+ //
+ if (myNonDestructive) {
+ bIsNewShape=myDS->IsNewShape(nE);
+ if (!bIsNewShape) {
+ return;
+ }
//
- bHasInterf=myDS->HasInterfShapeSubShapes(myIE, myIZ);
- if (!bHasInterf) {
- myHasInterf=myDS->HasInterfShapeSubShapes(myIZ, myIE);
+ aIt.Initialize(aLI);
+ for (; aIt.More(); aIt.Next()) {
+ nV = aIt.Value();
+ bHasShapeSD=myDS->HasShapeSD(nV, nVx);
+ if (bHasShapeSD) {
+ continue;
+ }
+ bIsNewShape=myDS->IsNewShape(nV);
+ if (!bIsNewShape) {
+ return;
+ }
}
- };
- //
- protected:
- Standard_Integer myIE;
- Standard_Integer myIZ;
- Standard_Boolean myHasInterf;
- BOPDS_DS* myDS;
-};
-//=======================================================================
-typedef BOPCol_NCVector
- <BOPAlgo_ShapeSolid> BOPAlgo_VectorOfShapeSolid;
-//
-typedef BOPCol_Functor
- <BOPAlgo_ShapeSolid,
- BOPAlgo_VectorOfShapeSolid> BOPAlgo_ShapeSolidFunctor;
-//
-typedef BOPCol_Cnt
- <BOPAlgo_ShapeSolidFunctor,
- BOPAlgo_VectorOfShapeSolid> BOPAlgo_ShapeSolidCnt;
-//
-/////////////////////////////////////////////////////////////////////////
-//=======================================================================
-//class : BOPAlgo_SolidSolid
-//purpose :
-//=======================================================================
-class BOPAlgo_SolidSolid : public BOPAlgo_ShapeSolid {
- public:
- DEFINE_STANDARD_ALLOC
-
- BOPAlgo_SolidSolid() :
- BOPAlgo_ShapeSolid() {
- };
- //
- virtual ~BOPAlgo_SolidSolid(){
- };
+ }
//
- virtual void Perform() {
- Standard_Boolean bFlag;
- //
- bFlag=Standard_False;
- myHasInterf=Standard_False;
- //
- myHasInterf=myDS->HasInterfShapeSubShapes(myIZ, myIE, bFlag);
- if (!myHasInterf) {
- myHasInterf=myDS->HasInterfShapeSubShapes(myIE, myIZ, bFlag);
+ const TopoDS_Edge& aE = *(TopoDS_Edge*)&myDS->Shape(nE);
+ aBB.UpdateEdge(aE, aTol);
+ Bnd_Box& aBoxE=aSIE.ChangeBox();
+ BRepBndLib::Add(aE, aBoxE);
+ aBoxE.SetGap(aBoxE.GetGap() + Precision::Confusion());
+ //
+ aIt.Initialize(aLI);
+ for (; aIt.More(); aIt.Next()) {
+ nV = aIt.Value();
+ bHasShapeSD=myDS->HasShapeSD(nV, nVx);
+ if (bHasShapeSD) {
+ nV=nVx;
}
- };
-};
-//=======================================================================
-typedef BOPCol_NCVector
- <BOPAlgo_SolidSolid> BOPAlgo_VectorOfSolidSolid;
-//
-typedef BOPCol_Functor
- <BOPAlgo_SolidSolid,
- BOPAlgo_VectorOfSolidSolid> BOPAlgo_SolidSolidFunctor;
-//
-typedef BOPCol_Cnt
- <BOPAlgo_SolidSolidFunctor,
- BOPAlgo_VectorOfSolidSolid> BOPAlgo_SolidSolidCnt;
-//
-/////////////////////////////////////////////////////////////////////////
-
+ const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&myDS->Shape(nV);
+ aTolV = BRep_Tool::Tolerance(aV);
+ if (aTolV < aTol) {
+ aBB.UpdateVertex(aV, aTol);
+ BOPDS_ShapeInfo& aSIV = myDS->ChangeShapeInfo(nV);
+ Bnd_Box& aBoxV = aSIV.ChangeBox();
+ BRepBndLib::Add(aV, aBoxV);
+ aBoxV.SetGap(aBoxV.GetGap() + Precision::Confusion());
+ }
+ }
+}
//=======================================================================
-//function : PerformVZ
+//function : UpdateVertex
//purpose :
//=======================================================================
-void BOPAlgo_PaveFiller::PerformVZ()
+Standard_Integer BOPAlgo_PaveFiller::UpdateVertex
+ (const Standard_Integer nV,
+ const Standard_Real aTolNew)
{
- Standard_Boolean bJustAdd;
- Standard_Integer iSize, nV, nZ, k, aNbVVS;
- TopAbs_State aState;
- BOPDS_MapOfPassKey aMPK;
+ Standard_Integer nVNew;
+ Standard_Real aTolV;
+ BRep_Builder aBB;
+
+ nVNew = nV;
+ if (myDS->IsNewShape(nVNew) ||
+ myDS->HasShapeSD(nV, nVNew) ||
+ !myNonDestructive) {
+ // nV is a new vertex, it has SD or non-destructive mode is not in force
+ const TopoDS_Vertex& aVSD = *(TopoDS_Vertex*)&myDS->Shape(nVNew);
+ aTolV = BRep_Tool::Tolerance(aVSD);
+ if (aTolV < aTolNew) {
+ aBB.UpdateVertex(aVSD, aTolNew);
+ BOPDS_ShapeInfo& aSIV = myDS->ChangeShapeInfo(nVNew);
+ Bnd_Box& aBoxV = aSIV.ChangeBox();
+ BRepBndLib::Add(aVSD, aBoxV);
+ aBoxV.SetGap(aBoxV.GetGap() + Precision::Confusion());
+ }
+ return nVNew;
+ }
//
- myErrorStatus=0;
+ // nV is old vertex
+ const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&myDS->Shape(nV);
+ aTolV = BRep_Tool::Tolerance(aV);
//
- myIterator->Initialize(TopAbs_VERTEX, TopAbs_SOLID);
- iSize=myIterator->ExpectedLength();
- if (!iSize) {
- return;
- }
+ // create new vertex
+ TopoDS_Vertex aVNew;
+ gp_Pnt aPV = BRep_Tool::Pnt(aV);
+ aBB.MakeVertex(aVNew, aPV, Max(aTolV, aTolNew));
//
- BOPDS_VectorOfInterfVZ& aVZs=myDS->InterfVZ();
- aVZs.SetIncrement(iSize);
+ // append new vertex to DS
+ BOPDS_ShapeInfo aSIV;
+ aSIV.SetShapeType(TopAbs_VERTEX);
+ aSIV.SetShape(aVNew);
+ nVNew = myDS->Append(aSIV);
//
- BOPAlgo_VectorOfVertexSolid aVVS;
+ // bounding box for the new vertex
+ BOPDS_ShapeInfo& aSIDS = myDS->ChangeShapeInfo(nVNew);
+ Bnd_Box& aBoxDS = aSIDS.ChangeBox();
+ BRepBndLib::Add(aVNew, aBoxDS);
+ aBoxDS.SetGap(aBoxDS.GetGap() + Precision::Confusion());
//
- for (; myIterator->More(); myIterator->Next()) {
- myIterator->Value(nV, nZ, bJustAdd);
- if(bJustAdd) {
- continue;
- }
- //
- if (myDS->HasInterfShapeSubShapes(nV, nZ)) {
- continue;
- }
- //
- Standard_Integer nVSD = nV;
- myDS->HasShapeSD(nV, nVSD);
- //
- BOPDS_PassKey aPK;
- aPK.SetIds(nVSD, nZ);
- if (!aMPK.Add(aPK)) {
- continue;
- }
- //
- const TopoDS_Vertex& aV=*((TopoDS_Vertex*)&myDS->Shape(nVSD));
- const TopoDS_Solid& aZ=*((TopoDS_Solid*)&myDS->Shape(nZ));
- //
- BOPAlgo_VertexSolid& aVertexSolid=aVVS.Append1();
- aVertexSolid.SetIndices(nV, nZ);
- aVertexSolid.SetVertex(aV);
- aVertexSolid.SetSolid(aZ);
- }
+ // add vertex to SD map
+ myDS->AddShapeSD(nV, nVNew);
//
- aNbVVS=aVVS.Extent();
- //=============================================================
- BOPAlgo_VertexSolidCnt::Perform(myRunParallel, aVVS, myContext);
- //=============================================================
- for (k=0; k < aNbVVS; ++k) {
- const BOPAlgo_VertexSolid& aVertexSolid=aVVS(k);
- aState=aVertexSolid.State();
- if (aState==TopAbs_IN) {
- aVertexSolid.Indices(nV, nZ);
- //
- BOPDS_InterfVZ& aVZ=aVZs.Append1();
- aVZ.SetIndices(nV, nZ);
- //
- myDS->AddInterf(nV, nZ);
- }
- }
-}
-//=======================================================================
-//function : PerformEZ
-//purpose :
-//=======================================================================
-void BOPAlgo_PaveFiller::PerformEZ()
-{
- PerformSZ(TopAbs_EDGE);
+ myDS->InitPaveBlocksForVertex(nV);
+ //
+ return nVNew;
}
//=======================================================================
-//function : PerformFZ
+//function : UpdatePaveBlocksWithSDVertices
//purpose :
//=======================================================================
-void BOPAlgo_PaveFiller::PerformFZ()
-{
- PerformSZ(TopAbs_FACE);
+void BOPAlgo_PaveFiller::UpdatePaveBlocksWithSDVertices()
+{
+ myDS->UpdatePaveBlocksWithSDVertices();
}
//=======================================================================
-//function : PerformZZ
+//function : UpdateCommonBlocksWithSDVertices
//purpose :
//=======================================================================
-void BOPAlgo_PaveFiller::PerformZZ()
+void BOPAlgo_PaveFiller::UpdateCommonBlocksWithSDVertices()
{
- Standard_Boolean bJustAdd, bHasInterf;
- Standard_Integer iSize, nZ1, nZ, k, aNbSolidSolid;
- //
- myErrorStatus=0;
- //
- myIterator->Initialize(TopAbs_SOLID, TopAbs_SOLID);
- iSize=myIterator->ExpectedLength();
- if (!iSize) {
- return;
+ if (!myNonDestructive) {
+ UpdatePaveBlocksWithSDVertices();
+ return;
}
+ Standard_Integer aNbPBP;
//
- BOPAlgo_VectorOfSolidSolid aVSolidSolid;
- //
- for (; myIterator->More(); myIterator->Next()) {
- myIterator->Value(nZ1, nZ, bJustAdd);
- if(bJustAdd) {
- continue;
- }
- //
- BOPAlgo_SolidSolid& aSolidSolid=aVSolidSolid.Append1();
- aSolidSolid.SetIndices(nZ1, nZ);
- aSolidSolid.SetDS(myDS);
+ BOPDS_VectorOfListOfPaveBlock& aPBP=myDS->ChangePaveBlocksPool();
+ aNbPBP=aPBP.Extent();
+ if(!aNbPBP) {
+ return;
}
//
- aNbSolidSolid=aVSolidSolid.Extent();
- //======================================================
- BOPAlgo_SolidSolidCnt::Perform(myRunParallel, aVSolidSolid);
- //======================================================
- //
- BOPDS_VectorOfInterfZZ& aZZs=myDS->InterfZZ();
- //
- aZZs.SetIncrement(iSize);
- //
- for (k=0; k < aNbSolidSolid; ++k) {
- const BOPAlgo_SolidSolid& aSolidSolid=aVSolidSolid(k);
- bHasInterf=aSolidSolid.HasInterf();
- if (bHasInterf) {
- aSolidSolid.Indices(nZ1, nZ);
- //
- BOPDS_InterfZZ& aZZ=aZZs.Append1();
- aZZ.SetIndices(nZ1, nZ);
+ Standard_Integer i, nV1, nV2;
+ Standard_Real aTolV;
+ BOPDS_MapOfCommonBlock aMCB;
+ BOPDS_ListIteratorOfListOfPaveBlock aItPB;
+ Handle(BOPDS_PaveBlock) aPB;
+ //
+ aTolV = Precision::Confusion();
+ //
+ for (i=0; i<aNbPBP; ++i) {
+ BOPDS_ListOfPaveBlock& aLPB=aPBP(i);
+ aItPB.Initialize(aLPB);
+ for (; aItPB.More(); aItPB.Next()) {
+ aPB=aItPB.Value();
+ const Handle(BOPDS_CommonBlock)& aCB=myDS->CommonBlock(aPB);
+ if (aCB.IsNull()) {
+ continue;
+ }
//
- myDS->AddInterf(nZ1, nZ);
+ if (aMCB.Add(aCB)) {
+ myDS->SortPaveBlocks(aCB);
+ aPB->Indices(nV1, nV2);
+ UpdateVertex(nV1, aTolV);
+ UpdateVertex(nV2, aTolV);
+ myDS->UpdateCommonBlockWithSDVertices(aCB);
+ }
}
}
+ UpdatePaveBlocksWithSDVertices();
}
-//=======================================================================
-//function : PerformSZ
-//purpose :
-//=======================================================================
-void BOPAlgo_PaveFiller::PerformSZ(const TopAbs_ShapeEnum aTS)
+
+namespace
{
- Standard_Boolean bJustAdd, bHasInterf;
- Standard_Integer iSize, nS, nZ, k, aNbShapeSolid;
- //
- myErrorStatus=0;
- //
- myIterator->Initialize(aTS, TopAbs_SOLID);
- iSize=myIterator->ExpectedLength();
- if (!iSize) {
- return;
- }
- //
- BOPAlgo_VectorOfShapeSolid aVShapeSolid;
- //
- for (; myIterator->More(); myIterator->Next()) {
- myIterator->Value(nS, nZ, bJustAdd);
- if(bJustAdd) {
- continue;
- }
- //
- BOPAlgo_ShapeSolid& aShapeSolid=aVShapeSolid.Append1();
- aShapeSolid.SetIndices(nS, nZ);
- aShapeSolid.SetDS(myDS);
- }
- //
- aNbShapeSolid=aVShapeSolid.Extent();
- //======================================================
- BOPAlgo_ShapeSolidCnt::Perform(myRunParallel, aVShapeSolid);
- //======================================================
- //
- BOPDS_VectorOfInterfEZ& aEZs=myDS->InterfEZ();
- BOPDS_VectorOfInterfFZ& aFZs=myDS->InterfFZ();
- //
- if (aTS==TopAbs_EDGE) {
- aEZs.SetIncrement(iSize);
- }
- else {//if (aTS==TopAbs_FACE)
- aFZs.SetIncrement(iSize);
- }
- //
- for (k=0; k < aNbShapeSolid; ++k) {
- const BOPAlgo_ShapeSolid& aShapeSolid=aVShapeSolid(k);
- bHasInterf=aShapeSolid.HasInterf();
- if (bHasInterf) {
- aShapeSolid.Indices(nS, nZ);
- //
- if (aTS==TopAbs_EDGE) {
- BOPDS_InterfEZ& aEZ=aEZs.Append1();
- aEZ.SetIndices(nS, nZ);
+ //=======================================================================
+ //function : UpdateInterfsWithSDVertices
+ //purpose :
+ //=======================================================================
+ template <class InterfType>
+ void UpdateIntfsWithSDVertices(BOPDS_PDS theDS, BOPCol_NCVector<InterfType>& theInterfs)
+ {
+ for (Standard_Integer i = 0; i < theInterfs.Length(); i++)
+ {
+ InterfType& anIntf = theInterfs(i);
+ Standard_Integer anInd;
+ if (anIntf.HasIndexNew(anInd))
+ {
+ Standard_Integer anIndSD;
+ if (theDS->HasShapeSD(anInd, anIndSD))
+ {
+ anIntf.SetIndexNew(anIndSD);
+ }
}
- else {//if (aTS==TopAbs_FACE)
- BOPDS_InterfFZ& aFZ=aFZs.Append1();
- aFZ.SetIndices(nS, nZ);
- }
- //
- myDS->AddInterf(nS, nZ);
}
}
}
+
+//=======================================================================
+//function : UpdateInterfsWithSDVertices
+//purpose :
+//=======================================================================
+void BOPAlgo_PaveFiller::UpdateInterfsWithSDVertices()
+{
+ UpdateIntfsWithSDVertices(myDS, myDS->InterfVV());
+ UpdateIntfsWithSDVertices(myDS, myDS->InterfVE());
+ UpdateIntfsWithSDVertices(myDS, myDS->InterfVF());
+ UpdateIntfsWithSDVertices(myDS, myDS->InterfEE());
+ UpdateIntfsWithSDVertices(myDS, myDS->InterfEF());
+}
+++ /dev/null
-// Created by: Peter KURNEV
-// Copyright (c) 2010-2014 OPEN CASCADE SAS
-// Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
-// Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT,
-// EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// 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_PaveFiller.hxx>
-
-#include <Precision.hxx>
-
-#include <gp_Pnt.hxx>
-#include <Bnd_Box.hxx>
-
-#include <TopoDS_Iterator.hxx>
-#include <TopoDS_Vertex.hxx>
-#include <TopoDS_Edge.hxx>
-
-#include <BRep_Tool.hxx>
-#include <BRep_Builder.hxx>
-#include <BRepBndLib.hxx>
-
-#include <BOPDS_ShapeInfo.hxx>
-#include <BOPDS_VectorOfListOfPaveBlock.hxx>
-#include <BOPDS_MapOfCommonBlock.hxx>
-#include <BOPDS_ListOfPaveBlock.hxx>
-#include <BOPDS_CommonBlock.hxx>
-#include <BOPDS_DS.hxx>
-
-//=======================================================================
-//function : SetNonDestructive
-//purpose :
-//=======================================================================
-void BOPAlgo_PaveFiller::SetNonDestructive()
-{
- if (!myIsPrimary || myNonDestructive) {
- return;
- }
- //
- Standard_Boolean bFlag;
- BOPCol_ListIteratorOfListOfShape aItLS;
- //
- bFlag=Standard_False;
- aItLS.Initialize(myArguments);
- for(; aItLS.More() && (!bFlag); aItLS.Next()) {
- const TopoDS_Shape& aS=aItLS.Value();
- bFlag=aS.Locked();
- }
- myNonDestructive=bFlag;
-}
-//=======================================================================
-//function : UpdateEdgeTolerance
-//purpose :
-//=======================================================================
-void BOPAlgo_PaveFiller::UpdateEdgeTolerance (const Standard_Integer nE,
- const Standard_Real aTol)
-{
- Standard_Boolean bIsNewShape, bHasShapeSD;
- Standard_Integer nV, nVx;
- Standard_Real aTolV;
- BRep_Builder aBB;
- BOPCol_ListIteratorOfListOfInteger aIt;
- //
- BOPDS_ShapeInfo& aSIE=myDS->ChangeShapeInfo(nE);
- const BOPCol_ListOfInteger& aLI=aSIE.SubShapes();
- //
- if (myNonDestructive) {
- bIsNewShape=myDS->IsNewShape(nE);
- if (!bIsNewShape) {
- return;
- }
- //
- aIt.Initialize(aLI);
- for (; aIt.More(); aIt.Next()) {
- nV = aIt.Value();
- bHasShapeSD=myDS->HasShapeSD(nV, nVx);
- if (bHasShapeSD) {
- continue;
- }
- bIsNewShape=myDS->IsNewShape(nV);
- if (!bIsNewShape) {
- return;
- }
- }
- }
- //
- const TopoDS_Edge& aE = *(TopoDS_Edge*)&myDS->Shape(nE);
- aBB.UpdateEdge(aE, aTol);
- Bnd_Box& aBoxE=aSIE.ChangeBox();
- BRepBndLib::Add(aE, aBoxE);
- aBoxE.SetGap(aBoxE.GetGap() + Precision::Confusion());
- //
- aIt.Initialize(aLI);
- for (; aIt.More(); aIt.Next()) {
- nV = aIt.Value();
- bHasShapeSD=myDS->HasShapeSD(nV, nVx);
- if (bHasShapeSD) {
- nV=nVx;
- }
- const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&myDS->Shape(nV);
- aTolV = BRep_Tool::Tolerance(aV);
- if (aTolV < aTol) {
- aBB.UpdateVertex(aV, aTol);
- BOPDS_ShapeInfo& aSIV = myDS->ChangeShapeInfo(nV);
- Bnd_Box& aBoxV = aSIV.ChangeBox();
- BRepBndLib::Add(aV, aBoxV);
- aBoxV.SetGap(aBoxV.GetGap() + Precision::Confusion());
- }
- }
-}
-//=======================================================================
-//function : UpdateVertex
-//purpose :
-//=======================================================================
-Standard_Integer BOPAlgo_PaveFiller::UpdateVertex
- (const Standard_Integer nV,
- const Standard_Real aTolNew)
-{
- Standard_Integer nVNew;
- Standard_Real aTolV;
- BRep_Builder aBB;
-
- nVNew = nV;
- if (myDS->IsNewShape(nVNew) ||
- myDS->HasShapeSD(nV, nVNew) ||
- !myNonDestructive) {
- // nV is a new vertex, it has SD or non-destructive mode is not in force
- const TopoDS_Vertex& aVSD = *(TopoDS_Vertex*)&myDS->Shape(nVNew);
- aTolV = BRep_Tool::Tolerance(aVSD);
- if (aTolV < aTolNew) {
- aBB.UpdateVertex(aVSD, aTolNew);
- BOPDS_ShapeInfo& aSIV = myDS->ChangeShapeInfo(nVNew);
- Bnd_Box& aBoxV = aSIV.ChangeBox();
- BRepBndLib::Add(aVSD, aBoxV);
- aBoxV.SetGap(aBoxV.GetGap() + Precision::Confusion());
- }
- return nVNew;
- }
- //
- // nV is old vertex
- const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&myDS->Shape(nV);
- aTolV = BRep_Tool::Tolerance(aV);
- //
- // create new vertex
- TopoDS_Vertex aVNew;
- gp_Pnt aPV = BRep_Tool::Pnt(aV);
- aBB.MakeVertex(aVNew, aPV, Max(aTolV, aTolNew));
- //
- // append new vertex to DS
- BOPDS_ShapeInfo aSIV;
- aSIV.SetShapeType(TopAbs_VERTEX);
- aSIV.SetShape(aVNew);
- nVNew = myDS->Append(aSIV);
- //
- // bounding box for the new vertex
- BOPDS_ShapeInfo& aSIDS = myDS->ChangeShapeInfo(nVNew);
- Bnd_Box& aBoxDS = aSIDS.ChangeBox();
- BRepBndLib::Add(aVNew, aBoxDS);
- aBoxDS.SetGap(aBoxDS.GetGap() + Precision::Confusion());
- //
- // add vertex to SD map
- myDS->AddShapeSD(nV, nVNew);
- //
- myDS->InitPaveBlocksForVertex(nV);
- //
- return nVNew;
-}
-//=======================================================================
-//function : UpdatePaveBlocksWithSDVertices
-//purpose :
-//=======================================================================
-void BOPAlgo_PaveFiller::UpdatePaveBlocksWithSDVertices()
-{
- myDS->UpdatePaveBlocksWithSDVertices();
-}
-//=======================================================================
-//function : UpdateCommonBlocksWithSDVertices
-//purpose :
-//=======================================================================
-void BOPAlgo_PaveFiller::UpdateCommonBlocksWithSDVertices()
-{
- if (!myNonDestructive) {
- UpdatePaveBlocksWithSDVertices();
- return;
- }
- Standard_Integer aNbPBP;
- //
- BOPDS_VectorOfListOfPaveBlock& aPBP=myDS->ChangePaveBlocksPool();
- aNbPBP=aPBP.Extent();
- if(!aNbPBP) {
- return;
- }
- //
- Standard_Integer i, nV1, nV2;
- Standard_Real aTolV;
- BOPDS_MapOfCommonBlock aMCB;
- BOPDS_ListIteratorOfListOfPaveBlock aItPB;
- Handle(BOPDS_PaveBlock) aPB;
- //
- aTolV = Precision::Confusion();
- //
- for (i=0; i<aNbPBP; ++i) {
- BOPDS_ListOfPaveBlock& aLPB=aPBP(i);
- aItPB.Initialize(aLPB);
- for (; aItPB.More(); aItPB.Next()) {
- aPB=aItPB.Value();
- const Handle(BOPDS_CommonBlock)& aCB=myDS->CommonBlock(aPB);
- if (aCB.IsNull()) {
- continue;
- }
- //
- if (aMCB.Add(aCB)) {
- myDS->SortPaveBlocks(aCB);
- aPB->Indices(nV1, nV2);
- UpdateVertex(nV1, aTolV);
- UpdateVertex(nV2, aTolV);
- myDS->UpdateCommonBlockWithSDVertices(aCB);
- }
- }
- }
- UpdatePaveBlocksWithSDVertices();
-}
-
-namespace
-{
- //=======================================================================
- //function : UpdateInterfsWithSDVertices
- //purpose :
- //=======================================================================
- template <class InterfType>
- void UpdateIntfsWithSDVertices(BOPDS_PDS theDS, BOPCol_NCVector<InterfType>& theInterfs)
- {
- for (Standard_Integer i = 0; i < theInterfs.Length(); i++)
- {
- InterfType& anIntf = theInterfs(i);
- Standard_Integer anInd;
- if (anIntf.HasIndexNew(anInd))
- {
- Standard_Integer anIndSD;
- if (theDS->HasShapeSD(anInd, anIndSD))
- {
- anIntf.SetIndexNew(anIndSD);
- }
- }
- }
- }
-}
-
-//=======================================================================
-//function : UpdateInterfsWithSDVertices
-//purpose :
-//=======================================================================
-void BOPAlgo_PaveFiller::UpdateInterfsWithSDVertices()
-{
- UpdateIntfsWithSDVertices(myDS, myDS->InterfVV());
- UpdateIntfsWithSDVertices(myDS, myDS->InterfVE());
- UpdateIntfsWithSDVertices(myDS, myDS->InterfVF());
- UpdateIntfsWithSDVertices(myDS, myDS->InterfEE());
- UpdateIntfsWithSDVertices(myDS, myDS->InterfEF());
-}
#include <BOPDS_DS.hxx>
#include <BOPDS_Interf.hxx>
#include <BOPDS_Iterator.hxx>
-#include <BOPDS_MapOfPassKey.hxx>
-#include <BOPDS_PassKey.hxx>
+#include <BOPDS_MapOfPair.hxx>
+#include <BOPDS_Pair.hxx>
#include <BOPDS_PaveBlock.hxx>
#include <BOPDS_VectorOfInterfVE.hxx>
#include <BOPTools_AlgoTools.hxx>
//=======================================================================
void BOPAlgo_PaveFiller::PerformVE()
{
- Standard_Boolean bJustAdd;
Standard_Integer iSize, nV, nE, nVSD, iFlag, nVx, k, aNbVE;
Standard_Real aT, aT1, aT2, aTS1, aTS2;
BOPDS_Pave aPave;
- BOPDS_PassKey aPK;
- BOPDS_MapOfPassKey aMPK;
+ BOPDS_Pair aPK;
+ BOPDS_MapOfPair aMPK;
BOPAlgo_VectorOfVertexEdge aVVE;
//
myErrorStatus=0;
aVEs.SetIncrement(iSize);
//
for (; myIterator->More(); myIterator->Next()) {
- myIterator->Value(nV, nE, bJustAdd);
- if(bJustAdd) {
- continue;
- }
+ myIterator->Value(nV, nE);
//
const BOPDS_ShapeInfo& aSIE=myDS->ShapeInfo(nE);
if (aSIE.HasSubShape(nV)) {
nVx=nVSD;
}
//
- aPK.SetIds(nVx, nE);
+ aPK.SetIndices(nVx, nE);
if (!aMPK.Add(aPK)) {
continue;
}
return;
}
//
- Standard_Boolean bJustAdd, bExpressCompute, bIsPBSplittable1, bIsPBSplittable2;
+ Standard_Boolean bExpressCompute, bIsPBSplittable1, bIsPBSplittable2;
Standard_Integer i, iX, nE1, nE2, aNbCPrts, k, aNbEdgeEdge;
Standard_Integer nV11, nV12, nV21, nV22;
Standard_Real aTS11, aTS12, aTS21, aTS22, aT11, aT12, aT21, aT22;
aEEs.SetIncrement(iSize);
//
for (; myIterator->More(); myIterator->Next()) {
- myIterator->Value(nE1, nE2, bJustAdd);
- if(bJustAdd) {
- continue;
- }
+ myIterator->Value(nE1, nE2);
//
const BOPDS_ShapeInfo& aSIE1=myDS->ShapeInfo(nE1);
if (aSIE1.HasFlag()){
myIterator->Initialize(TopAbs_VERTEX, TopAbs_FACE);
Standard_Integer iSize = myIterator->ExpectedLength();
//
- Standard_Boolean bJustAdd;
Standard_Integer nV, nF;
//
if (myGlue == BOPAlgo_GlueFull) {
// there is no need to intersect vertices with faces in this mode
// just initialize FaceInfo for all faces
for (; myIterator->More(); myIterator->Next()) {
- myIterator->Value(nV, nF, bJustAdd);
- if (!bJustAdd && !myDS->IsSubShape(nV, nF)) {
+ myIterator->Value(nV, nF);
+ if (!myDS->IsSubShape(nV, nF)) {
myDS->ChangeFaceInfo(nF);
}
}
aVFs.SetIncrement(iSize);
//
for (; myIterator->More(); myIterator->Next()) {
- myIterator->Value(nV, nF, bJustAdd);
- if(bJustAdd) {
- continue;
- }
+ myIterator->Value(nV, nF);
//
if (myDS->IsSubShape(nV, nF)) {
continue;
return;
}
//
- Standard_Boolean bJustAdd;
Standard_Integer nE, nF;
//
if (myGlue == BOPAlgo_GlueFull) {
// there is no need to intersect edges with faces in this mode
// just initialize FaceInfo for faces
for (; myIterator->More(); myIterator->Next()) {
- myIterator->Value(nE, nF, bJustAdd);
- if (!bJustAdd && !myDS->ShapeInfo(nE).HasFlag()) {
+ myIterator->Value(nE, nF);
+ if (!myDS->ShapeInfo(nE).HasFlag()) {
myDS->ChangeFaceInfo(nF);
}
}
aEFs.SetIncrement(iSize);
//
for (; myIterator->More(); myIterator->Next()) {
- myIterator->Value(nE, nF, bJustAdd);
- if(bJustAdd) {
- continue;
- }
+ myIterator->Value(nE, nF);
//
const BOPDS_ShapeInfo& aSIE=myDS->ShapeInfo(nE);
if (aSIE.HasFlag()){//degenerated
return;
}
//
- Standard_Boolean bJustAdd, bApp, bCompC2D1, bCompC2D2, bIsDone;
+ Standard_Boolean bApp, bCompC2D1, bCompC2D2, bIsDone;
Standard_Boolean bToSplit, bTangentFaces;
Standard_Integer nF1, nF2, aNbCurves, aNbPoints, i, aNbLP;
Standard_Integer aNbFaceFace, k;
bToSplit = Standard_False;
//
for (; myIterator->More(); myIterator->Next()) {
- myIterator->Value(nF1, nF2, bJustAdd);
- if(bJustAdd) {
- continue;
- }
+ myIterator->Value(nF1, nF2);
//
const TopoDS_Face& aF1=(*(TopoDS_Face *)(&myDS->Shape(nF1)));
const TopoDS_Face& aF2=(*(TopoDS_Face *)(&myDS->Shape(nF2)));
TopAbs_EDGE,
TopAbs_FACE
};
- Standard_Boolean bJustAdd, bIsBasedOnPlane;
+ Standard_Boolean bIsBasedOnPlane;
Standard_Integer i, aNb, n1, nF, aNbF;
TopExp_Explorer aExp;
BOPCol_IndexedMapOfShape aMF;
for(i=0; i<aNb; ++i) {
myIterator->Initialize(aType[i], aType[2]);
for (; myIterator->More(); myIterator->Next()) {
- myIterator->Value(n1, nF, bJustAdd);
+ myIterator->Value(n1, nF);
const TopoDS_Face& aF=(*(TopoDS_Face *)(&myDS->Shape(nF)));
//
bIsBasedOnPlane=IsBasedOnPlane(aF);
return;
}
//
- Standard_Boolean bJustAdd;
Standard_Integer i, nS[2], nE, nV1, nV2, aNbVSD, k;
Standard_Real aT1, aT2, aTS1, aTS2;
BOPDS_ListIteratorOfListOfPaveBlock aItLPB;
TopAbs_ShapeEnum aType[2] = { aType1, aType2 };
//
for (; myIterator->More(); myIterator->Next()) {
- myIterator->Value(nS[0], nS[1], bJustAdd);
- if(bJustAdd) {
- continue;
- }
+ myIterator->Value(nS[0], nS[1]);
//
for (i=0; i < 2; ++i) {
nE=nS[i];
BOPAlgo_BuilderSolid.hxx
BOPAlgo_CheckerSI.cxx
BOPAlgo_CheckerSI.hxx
+BOPAlgo_CheckerSI_1.cxx
BOPAlgo_CheckResult.cxx
BOPAlgo_CheckResult.hxx
BOPAlgo_CheckStatus.hxx
BOPAlgo_PaveFiller_8.cxx
BOPAlgo_PaveFiller_9.cxx
BOPAlgo_PaveFiller_10.cxx
-BOPAlgo_PaveFiller_11.cxx
BOPAlgo_PBOP.hxx
BOPAlgo_PBuilder.hxx
BOPAlgo_PPaveFiller.hxx
#include <BOPCol_ListOfInteger.hxx>
#include <BOPCol_MapOfInteger.hxx>
#include <BOPDS_CommonBlock.hxx>
-#include <BOPDS_DataMapOfPassKeyListOfPaveBlock.hxx>
#include <BOPDS_DS.hxx>
#include <BOPDS_FaceInfo.hxx>
#include <BOPDS_IndexRange.hxx>
#include <BOPDS_MapOfPave.hxx>
#include <BOPDS_MapOfPaveBlock.hxx>
-#include <BOPDS_PassKey.hxx>
+#include <BOPDS_Pair.hxx>
#include <BOPDS_PaveBlock.hxx>
#include <BOPDS_ShapeInfo.hxx>
#include <BOPDS_VectorOfPave.hxx>
{
Standard_Integer n1, n2;
Standard_Boolean bRet;
- BOPDS_MapIteratorMapOfPassKey aIt;
+ BOPDS_MapIteratorOfMapOfPair aIt;
//
bRet = Standard_False;
//
aIt.Initialize(myInterfTB);
for (; aIt.More(); aIt.Next()) {
- const BOPDS_PassKey& aPK = aIt.Value();
- aPK.Ids(n1, n2);
+ const BOPDS_Pair& aPK = aIt.Value();
+ aPK.Indices(n1, n2);
if (n1 == theI || n2 == theI) {
bRet = Standard_True;
break;
{
Standard_Integer nE, iRef, n1, n2;
BOPDS_ListIteratorOfListOfPaveBlock aItPB, aItPBCB, aItPBN;
- BOPDS_DataMapIteratorOfDataMapOfPassKeyListOfPaveBlock aItMPKLPB;
BOPDS_ListOfPaveBlock aLPBN;
- BOPDS_DataMapOfPassKeyListOfPaveBlock aMPKLPB;
+ NCollection_DataMap<BOPDS_Pair, BOPDS_ListOfPaveBlock, BOPDS_PairMapHasher> aMPKLPB;
+ NCollection_DataMap<BOPDS_Pair, BOPDS_ListOfPaveBlock, BOPDS_PairMapHasher>::Iterator aItMPKLPB;
Handle(BOPDS_PaveBlock) aPB;
Handle(BOPDS_CommonBlock) aCBx;
- BOPDS_PassKey aPK;
+ BOPDS_Pair aPK;
//
const BOPDS_ListOfPaveBlock& aLPBCB=theCB->PaveBlocks();
if (!aLPBCB.First()->IsToUpdate()){
aLPB.Append(aPBN);
//
aPBN->Indices(n1, n2);
- aPK.SetIds(n1, n2);
+ aPK.SetIndices(n1, n2);
if (aMPKLPB.IsBound(aPK)) {
BOPDS_ListOfPaveBlock& aLPBx=aMPKLPB.ChangeFind(aPK);
aLPBx.Append(aPBN);
aMPKLPB.Bind(aPK, aLPBx);
}
}
- aLPB.Remove(aItPB);
+ aLPB.Remove(aItPB);
break;
}
}
#include <BOPDS_VectorOfFaceInfo.hxx>
#include <BOPCol_DataMapOfIntegerInteger.hxx>
#include <BOPCol_DataMapOfIntegerListOfInteger.hxx>
-#include <BOPDS_MapOfPassKey.hxx>
+#include <BOPDS_MapOfPair.hxx>
#include <BOPDS_VectorOfInterfVV.hxx>
#include <BOPDS_VectorOfInterfVE.hxx>
#include <BOPDS_VectorOfInterfVF.hxx>
//! Returns the table of interferences
//!
//! debug
- const BOPDS_MapOfPassKey& Interferences() const;
+ const BOPDS_MapOfPair& Interferences() const;
Standard_EXPORT void Dump() const;
BOPDS_VectorOfFaceInfo myFaceInfoPool;
BOPCol_DataMapOfIntegerInteger myShapesSD;
BOPCol_DataMapOfIntegerListOfInteger myMapVE;
- BOPDS_MapOfPassKey myInterfTB;
+ BOPDS_MapOfPair myInterfTB;
BOPDS_VectorOfInterfVV myInterfVV;
BOPDS_VectorOfInterfVE myInterfVE;
BOPDS_VectorOfInterfVF myInterfVF;
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-#include <BOPDS_PassKey.hxx>
+#include <BOPDS_Pair.hxx>
//=======================================================================
//function : InterfVV
//purpose :
inline void BOPDS_DS::AddInterf(const Standard_Integer theI1,
const Standard_Integer theI2)
{
- BOPDS_PassKey aPK;
- //
- aPK.SetIds(theI1, theI2);
+ BOPDS_Pair aPK(theI1, theI2);
myInterfTB.Add(aPK);
}
//=======================================================================
(const Standard_Integer theI1,
const Standard_Integer theI2)const
{
- BOPDS_PassKey aPK;
- //
- aPK.SetIds(theI1, theI2);
+ BOPDS_Pair aPK(theI1, theI2);
return myInterfTB.Contains(aPK);
}
//=======================================================================
//function : Interferences
//purpose :
//=======================================================================
-inline const BOPDS_MapOfPassKey& BOPDS_DS::Interferences()const
+inline const BOPDS_MapOfPair& BOPDS_DS::Interferences()const
{
return myInterfTB;
}
#include <BOPDS_DS.hxx>
#include <BOPDS_IndexRange.hxx>
#include <BOPDS_Iterator.hxx>
-#include <BOPDS_MapOfPassKeyBoolean.hxx>
-#include <BOPDS_PassKeyBoolean.hxx>
+#include <BOPDS_Pair.hxx>
+#include <BOPDS_MapOfPair.hxx>
#include <BOPDS_Tools.hxx>
#include <NCollection_UBTreeFiller.hxx>
#include <TopoDS_Shape.hxx>
+#include <algorithm>
-//
-//
-//
-//
-//
/////////////////////////////////////////////////////////////////////////
//=======================================================================
//class : BOPDS_TreeSelector
myLength=0;
iX=BOPDS_Tools::TypeToInteger(aType1, aType2);
if (iX>=0) {
- myIterator.Initialize(myLists(iX));
- myLength=myLists(iX).Extent();
+ // sort interfering pairs for constant order of intersection
+ std::stable_sort(myLists(iX).begin(), myLists(iX).end());
+ // initialize iterator to access the pairs
+ myIterator.Init(myLists(iX));
+ myLength = myLists(iX).Extent();
}
}
//=======================================================================
// function: Value
// purpose:
//=======================================================================
-void BOPDS_Iterator::Value
- (Standard_Integer& theI1,
- Standard_Integer& theI2,
- Standard_Boolean& theWithSubShape) const
+void BOPDS_Iterator::Value(Standard_Integer& theI1,
+ Standard_Integer& theI2) const
{
Standard_Integer iT1, iT2, n1, n2;
//
- const BOPDS_PassKeyBoolean& aPKB=myIterator.Value();
- aPKB.Ids(n1, n2);
+ const BOPDS_Pair& aPair = myIterator.Value();
+ aPair.Indices(n1, n2);
//
iT1=(Standard_Integer)(myDS->ShapeInfo(n1).ShapeType());
iT2=(Standard_Integer)(myDS->ShapeInfo(n2).ShapeType());
theI1=n2;
theI2=n1;
}
- //
- theWithSubShape=aPKB.Flag();
}
//=======================================================================
// function: Prepare
//=======================================================================
void BOPDS_Iterator::Intersect()
{
- Standard_Boolean bFlag;
- Standard_Integer aNb, i, aNbR, iTi, iTj;
- Standard_Integer i1, i2, aNbSD, iX, j, iR;
+ Standard_Integer i, j, iX, i1, i2, iR, aNb, aNbR;
+ Standard_Integer iTi, iTj;
TopAbs_ShapeEnum aTi, aTj;
- Handle(NCollection_BaseAllocator) aAllocator;
- BOPCol_ListIteratorOfListOfInteger aIt;
- //
- //-----------------------------------------------------scope_1 f
- aAllocator=NCollection_BaseAllocator::CommonBaseAllocator();
- //
- BOPDS_MapOfPassKeyBoolean aMPKXB(100, aAllocator);
- BOPDS_PassKeyBoolean aPKXB;
//
BOPCol_BoxBndTree aBBTree;
NCollection_UBTreeFiller <Standard_Integer, Bnd_Box> aTreeFiller(aBBTree);
//
- aNb=myDS->NbSourceShapes();
- BOPDS_VectorOfTSR aVTSR(aNb, aAllocator);
+ aNb = myDS->NbSourceShapes();
+ BOPDS_VectorOfTSR aVTSR(aNb);
//
for (i=0; i<aNb; ++i) {
const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
- bFlag=aSI.IsInterfering();
+ Standard_Boolean bHasBrep = aSI.IsInterfering() && !(aSI.ShapeType() == TopAbs_SOLID);
//
BOPDS_TSR& aTSR=aVTSR.Append1();
//
- aTSR.SetHasBRep(bFlag);
- if (!bFlag) {
+ aTSR.SetHasBRep(bHasBrep);
+ if (!bHasBrep) {
continue;
}
//
BOPDS_TSRCnt::Perform(myRunParallel, aVTSR);
//===========================================
//
- aNbR=myDS->NbRanges()-1;
- for (iR=0; iR<aNbR; ++iR) {
- const BOPDS_IndexRange& aR=myDS->Range(iR);
- i1=aR.First();
- i2=aR.Last();
- for (i=i1; i<=i2; ++i) {
- const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
+ BOPDS_MapOfPair aMPFence;
+ //
+ aNbR = myDS->NbRanges() - 1;
+ for (iR = 0; iR < aNbR; ++iR) {
+ const BOPDS_IndexRange& aR = myDS->Range(iR);
+ i1 = aR.First();
+ i2 = aR.Last();
+ for (i = i1; i <= i2; ++i) {
+ const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(i);
//
- if (!aSI.IsInterfering()){
+ if (!aSI.IsInterfering() || (aSI.ShapeType() == TopAbs_SOLID)) {
continue;
}
//
- aTi=aSI.ShapeType();
- const Bnd_Box& aBoxi=aSI.Box();
- //
- BOPDS_TSR& aTSRi=aVTSR(i);
- const BOPCol_ListOfInteger& aLI=aTSRi.Indices();
- aNbSD=aLI.Extent();
- if (!aNbSD){
+ BOPDS_TSR& aTSRi = aVTSR(i);
+ const BOPCol_ListOfInteger& aLI = aTSRi.Indices();
+ Standard_Integer aNbSD = aLI.Extent();
+ if (!aNbSD) {
continue;
}
//
- aIt.Initialize(aLI);
+ aTi = aSI.ShapeType();
+ iTi = BOPDS_Tools::TypeToInteger(aTi);
+ //
+ BOPCol_ListIteratorOfListOfInteger aIt(aLI);
for (; aIt.More(); aIt.Next()) {
- j=aIt.Value(); // DS index
- if (j>=i1 && j<=i2) {
+ j = aIt.Value(); // DS index
+ if (j >= i1 && j <= i2) {
continue;// same range
}
//
- const BOPDS_ShapeInfo& aSIj=myDS->ShapeInfo(j);
- aTj=aSIj.ShapeType();
- iTi=BOPDS_Tools::TypeToInteger(aTi);
- iTj=BOPDS_Tools::TypeToInteger(aTj);
+ const BOPDS_ShapeInfo& aSJ = myDS->ShapeInfo(j);
+ aTj = aSJ.ShapeType();
+ iTj = BOPDS_Tools::TypeToInteger(aTj);
//
- bFlag=Standard_False;
- if (iTi<iTj) {
- bFlag=aSI.HasSubShape(j);
- }
- else if (iTj<iTi) {
- bFlag=aSIj.HasSubShape(i);
- }
- if (bFlag) {
- continue;
+ // avoid interfering of the same shapes and shape with its sub-shapes
+ if (((iTi < iTj) && aSI.HasSubShape(j)) ||
+ ((iTi > iTj) && aSJ.HasSubShape(i))) {
+ continue;
}
//
- aPKXB.SetIds(i, j);
- if (aMPKXB.Add(aPKXB)) {
- bFlag=Standard_False;// Bounding boxes are intersected
- const Bnd_Box& aBoxj=aSIj.Box();
- if (aBoxi.IsOut(aBoxj)) {
- bFlag=!bFlag; //Bounding boxes of Sub-shapes are intersected
- }
- //
- iX=BOPDS_Tools::TypeToInteger(aTi, aTj);
- aPKXB.SetFlag(bFlag);
- myLists(iX).Append(aPKXB);
- }// if (aMPKXB.Add(aPKXB)) {
+ BOPDS_Pair aPair(i, j);
+ if (aMPFence.Add(aPair)) {
+ iX = BOPDS_Tools::TypeToInteger(aTi, aTj);
+ myLists(iX).Append(aPair);
+ }// if (aMPFence.Add(aPair)) {
}// for (; aIt.More(); aIt.Next()) {
}//for (i=i1; i<=i2; ++i) {
}//for (iR=1; iR<aNbR; ++iR) {
//
- aMPKXB.Clear();
+ aMPFence.Clear();
aVTSR.Clear();
//-----------------------------------------------------scope_1 t
}
#include <BOPCol_BaseAllocator.hxx>
#include <Standard_Integer.hxx>
#include <BOPDS_PDS.hxx>
-#include <BOPDS_VectorOfListOfPassKeyBoolean.hxx>
-#include <BOPDS_ListIteratorOfListOfPassKeyBoolean.hxx>
+#include <BOPDS_VectorOfPair.hxx>
+#include <BOPDS_VectorOfVectorOfPair.hxx>
#include <Standard_Boolean.hxx>
#include <TopAbs_ShapeEnum.hxx>
class BOPDS_DS;
DEFINE_STANDARD_ALLOC
-
-
//! Empty contructor
Standard_EXPORT BOPDS_Iterator();
-Standard_EXPORT virtual ~BOPDS_Iterator();
-
+ Standard_EXPORT virtual ~BOPDS_Iterator();
//! Contructor
//! theAllocator - the allocator to manage the memory
Standard_EXPORT BOPDS_Iterator(const BOPCol_BaseAllocator& theAllocator);
-
//! Modifier
//! Sets the data structure <pDS> to process
Standard_EXPORT void SetDS (const BOPDS_PDS& pDS);
-
//! Selector
//! Returns the data structure
Standard_EXPORT const BOPDS_DS& DS() const;
-
//! Initializes the iterator
//! theType1 - the first type of shape
//! theType2 - the second type of shape
Standard_EXPORT void Initialize (const TopAbs_ShapeEnum theType1, const TopAbs_ShapeEnum theType2);
-
//! Returns true if still there are pairs
//! of intersected shapes
Standard_EXPORT Standard_Boolean More() const;
-
//! Moves iterations ahead
Standard_EXPORT void Next();
-
//! Returns indices (DS) of intersected shapes
//! theIndex1 - the index of the first shape
//! theIndex2 - the index of the second shape
- //! theWithSubShape - flag. True if the sub-shapes of
- //! shapes are intersected
- Standard_EXPORT void Value (Standard_Integer& theIndex1, Standard_Integer& theIndex2, Standard_Boolean& theWithSubShape) const;
-
+ Standard_EXPORT void Value (Standard_Integer& theIndex1,
+ Standard_Integer& theIndex2) const;
//! Perform the intersection algorithm and prepare
//! the results to be used
Standard_EXPORT virtual void Prepare();
-
//! Returns the number of intersections founded
Standard_EXPORT Standard_Integer ExpectedLength() const;
-
//! Returns the block length
Standard_EXPORT Standard_Integer BlockLength() const;
-
+
//! Set the flag of parallel processing
//! if <theFlag> is true the parallel processing is switched on
//! if <theFlag> is false the parallel processing is switched off
Standard_EXPORT void SetRunParallel (const Standard_Boolean theFlag);
-
+
//! Returns the flag of parallel processing
Standard_EXPORT Standard_Boolean RunParallel() const;
-
-
-
protected:
-
Standard_EXPORT virtual void Intersect();
-
BOPCol_BaseAllocator myAllocator;
Standard_Integer myLength;
BOPDS_PDS myDS;
- BOPDS_VectorOfListOfPassKeyBoolean myLists;
- BOPDS_ListIteratorOfListOfPassKeyBoolean myIterator;
+ BOPDS_VectorOfVectorOfPair myLists;
+ BOPDS_VectorOfPair::Iterator myIterator;
Standard_Boolean myRunParallel;
-
private:
-
-
-
-
};
-
-
-
-
-
-
#endif // _BOPDS_Iterator_HeaderFile
#include <BOPDS_DS.hxx>
#include <BOPDS_IndexRange.hxx>
#include <BOPDS_IteratorSI.hxx>
-#include <BOPDS_MapOfPassKeyBoolean.hxx>
-#include <BOPDS_PassKeyBoolean.hxx>
+#include <BOPDS_MapOfPair.hxx>
+#include <BOPDS_Pair.hxx>
#include <BOPDS_ShapeInfo.hxx>
#include <BOPDS_Tools.hxx>
#include <BRep_Tool.hxx>
//=======================================================================
void BOPDS_IteratorSI::Intersect()
{
- Standard_Boolean bFlag;
- Standard_Integer aNbS, i, aNbB;
- Standard_Integer aNbSD, iX, j, iDS, jB;
+ Standard_Integer i, j, iX, aNbS;
+ Standard_Integer iTi, iTj;
TopAbs_ShapeEnum aTi, aTj;
- Handle(NCollection_BaseAllocator) aAllocator;
- BOPCol_ListIteratorOfListOfInteger aIt;
- //
- //-----------------------------------------------------scope_1 f
- aAllocator=
- NCollection_BaseAllocator::CommonBaseAllocator();
- //
- BOPCol_DataMapOfShapeInteger aMSI(100, aAllocator);
- BOPCol_DataMapOfIntegerInteger aMII(100, aAllocator);
- BOPDS_MapOfPassKeyBoolean aMPA(100, aAllocator);
- BOPDS_MapOfPassKeyBoolean aMPKXB(100, aAllocator);
- BOPCol_IndexedDataMapOfShapeBox aMSB(100, aAllocator);
- BOPDS_PassKeyBoolean aPKXB;
//
BOPCol_BoxBndTreeSelector aSelector;
BOPCol_BoxBndTree aBBTree;
NCollection_UBTreeFiller <Standard_Integer, Bnd_Box> aTreeFiller(aBBTree);
//
- // myPairsAvoid, aMSI, aMSB
- aNbS=myDS->NbSourceShapes();
+ aNbS = myDS->NbSourceShapes();
for (i=0; i<aNbS; ++i) {
const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
- //
- if (!aSI.IsInterfering()) {
+ if (!aSI.IsInterfering()) {
continue;
}
//
- const TopoDS_Shape& aSi=aSI.Shape();
- aTi=aSI.ShapeType();
- if (aTi!=TopAbs_VERTEX) {
- const BOPCol_ListOfInteger& aLA=aSI.SubShapes();
- aIt.Initialize(aLA);
- for (; aIt.More(); aIt.Next()) {
- iX=aIt.Value();
- aPKXB.Clear();
- aPKXB.SetIds(i, iX);
- aMPA.Add(aPKXB);
- }
- }
- //
- aPKXB.Clear();
- aPKXB.SetIds(i, i);
- aMPA.Add(aPKXB);
- //
- const Bnd_Box& aBoxEx=aSI.Box();
- //
- aMSI.Bind(aSi, i);
- aMSB.Add(aSi, aBoxEx);
- } // for (i=0; i<aNbS; ++i) {
- //
- // aMII
- aNbB=aMSB.Extent();
- for (i=1; i<=aNbB; ++i) {
- const TopoDS_Shape& aS=aMSB.FindKey(i);
- const Bnd_Box& aBoxEx=aMSB(i);
- //
+ const Bnd_Box& aBoxEx = aSI.Box();
aTreeFiller.Add(i, aBoxEx);
- //
- iDS=aMSI.Find(aS);
- aMII.Bind(i, iDS);
}
//
aTreeFiller.Fill();
//
- for (i=0; i<aNbS; ++i) {
- const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
- aTi=aSI.ShapeType();
+ BOPDS_MapOfPair aMPFence;
+ //
+ for (i = 0; i < aNbS; ++i) {
+ const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(i);
if (!aSI.IsInterfering()){
continue;
}
//
- const TopoDS_Shape& aSi=myDS->Shape(i);
- aTi=aSi.ShapeType();
- const Bnd_Box& aBoxEx=aMSB.FindFromKey(aSi);
+ const Bnd_Box& aBoxEx = aSI.Box();
+ //
aSelector.Clear();
aSelector.SetBox(aBoxEx);
//
- aNbSD=aBBTree.Select(aSelector);
- if (!aNbSD){
+ Standard_Integer aNbSD = aBBTree.Select(aSelector);
+ if (!aNbSD) {
continue;
}
//
- const BOPCol_ListOfInteger& aLI=aSelector.Indices();
+ aTi = aSI.ShapeType();
+ iTi = BOPDS_Tools::TypeToInteger(aTi);
//
- aIt.Initialize(aLI);
+ const BOPCol_ListOfInteger& aLI = aSelector.Indices();
+ BOPCol_ListIteratorOfListOfInteger aIt(aLI);
for (; aIt.More(); aIt.Next()) {
- jB=aIt.Value(); // box index in MII
- j=aMII.Find(jB); // DS index
+ j = aIt.Value();
+ const BOPDS_ShapeInfo& aSJ = myDS->ShapeInfo(j);
+ aTj = aSJ.ShapeType();
+ iTj = BOPDS_Tools::TypeToInteger(aTj);
//
- aPKXB.SetIds(i, j);
- if (aMPA.Contains(aPKXB)) {
+ // avoid interfering of the same shapes and shape with its sub-shapes
+ if ((i == j) || ((iTi < iTj) && aSI.HasSubShape(j)) ||
+ ((iTi > iTj) && aSJ.HasSubShape(i))) {
continue;
}
//
- if (aMPKXB.Add(aPKXB)) {
- bFlag=Standard_False;// Bounding boxes are intersected
- const Bnd_Box& aBoxi=myDS->ShapeInfo(i).Box();
- const Bnd_Box& aBoxj=myDS->ShapeInfo(j).Box();
- if (aBoxi.IsOut(aBoxj)) {
- bFlag=!bFlag; //Bounding boxes of Sub-shapes are intersected
- }
- aTj=myDS->ShapeInfo(j).ShapeType();//
- iX=BOPDS_Tools::TypeToInteger(aTi, aTj);
- aPKXB.SetFlag(bFlag);
- myLists(iX).Append(aPKXB);
+ BOPDS_Pair aPair(i, j);
+ if (aMPFence.Add(aPair)) {
+ iX = BOPDS_Tools::TypeToInteger(aTi, aTj);
+ myLists(iX).Append(aPair);
}// if (aMPKXB.Add(aPKXB)) {
}// for (; aIt.More(); aIt.Next()) {
}//for (i=1; i<=aNbS; ++i) {
//
- aMSI.Clear();
- aMII.Clear();
- aMPA.Clear();
- aMPKXB.Clear();
- aMSB.Clear();
- //
- //-----------------------------------------------------scope_1 t
+ aMPFence.Clear();
}
--- /dev/null
+// 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 BOPDS_MapOfPair_HeaderFile
+#define BOPDS_MapOfPair_HeaderFile
+
+#include <NCollection_Map.hxx>
+#include <BOPDS_PairMapHasher.hxx>
+#include <BOPDS_Pair.hxx>
+
+typedef NCollection_Map<BOPDS_Pair, BOPDS_PairMapHasher> BOPDS_MapOfPair;
+typedef BOPDS_MapOfPair::Iterator BOPDS_MapIteratorOfMapOfPair;
+
+#endif
--- /dev/null
+// 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 _BOPDS_Pair_HeaderFile
+#define _BOPDS_Pair_HeaderFile
+
+#include <Standard.hxx>
+#include <Standard_DefineAlloc.hxx>
+#include <Standard_Handle.hxx>
+
+//! The class is to provide the pair of indices of interfering shapes.
+
+class BOPDS_Pair {
+ public:
+
+ DEFINE_STANDARD_ALLOC
+
+ BOPDS_Pair() : myIndex1(-1), myIndex2(-1) {}
+ //
+ BOPDS_Pair(const Standard_Integer theIndex1,
+ const Standard_Integer theIndex2) : myIndex1(theIndex1), myIndex2(theIndex2) {}
+
+ ~BOPDS_Pair(){}
+ //
+ //! Sets the indices
+ void SetIndices(const Standard_Integer theIndex1,
+ const Standard_Integer theIndex2)
+ {
+ myIndex1 = theIndex1;
+ myIndex2 = theIndex2;
+ }
+ //
+ //! Gets the indices
+ void Indices(Standard_Integer& theIndex1,
+ Standard_Integer& theIndex2) const
+ {
+ theIndex1 = myIndex1;
+ theIndex2 = myIndex2;
+ }
+ //
+ //! Operator less
+ Standard_Boolean operator < (const BOPDS_Pair& theOther) const
+ {
+ return ((myIndex1 != theOther.myIndex1) ?
+ (myIndex1 < theOther.myIndex1) : (myIndex2 < theOther.myIndex2));
+ }
+ //
+ //! Returns true if the Pair is equal to <the theOther>
+ Standard_Boolean IsEqual (const BOPDS_Pair& theOther) const
+ {
+ return (myIndex1 == theOther.myIndex1 && myIndex2 == theOther.myIndex2) ||
+ (myIndex1 == theOther.myIndex2 && myIndex2 == theOther.myIndex1);
+ }
+ //
+ //! Returns hash code
+ Standard_Integer HashCode (const Standard_Integer theUpper) const
+ {
+ return ::HashCode(myIndex1 + myIndex2, theUpper);
+ }
+
+ protected:
+ Standard_Integer myIndex1;
+ Standard_Integer myIndex2;
+};
+
+#endif // _BOPDS_Pair
\ No newline at end of file
--- /dev/null
+// 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 _BOPDS_PairMapHasher_HeaderFile
+#define _BOPDS_PairMapHasher_HeaderFile
+
+#include <Standard.hxx>
+#include <Standard_DefineAlloc.hxx>
+#include <Standard_Handle.hxx>
+
+#include <Standard_Integer.hxx>
+#include <Standard_Boolean.hxx>
+#include <BOPDS_Pair.hxx>
+
+class BOPDS_Pair;
+
+class BOPDS_PairMapHasher
+{
+public:
+
+ DEFINE_STANDARD_ALLOC
+
+ static Standard_Integer HashCode(const BOPDS_Pair& thePair,
+ const Standard_Integer Upper)
+ {
+ return thePair.HashCode(Upper);
+ }
+
+ static Standard_Boolean IsEqual(const BOPDS_Pair& thePair1,
+ const BOPDS_Pair& thePair2)
+ {
+ return thePair1.IsEqual(thePair2);
+ }
+
+protected:
+
+private:
+
+};
+
+#endif // _BOPDS_PairMapHasher_HeaderFile
// commercial license or contractual agreement.
+#include <BOPDS_SubIterator.hxx>
+
#include <Bnd_Box.hxx>
+
#include <BOPCol_BoxBndTree.hxx>
-#include <BOPCol_DataMapOfIntegerInteger.hxx>
-#include <BOPCol_DataMapOfIntegerMapOfInteger.hxx>
-#include <BOPCol_IndexedDataMapOfShapeBox.hxx>
-#include <BOPCol_MapOfInteger.hxx>
+
#include <BOPDS_DS.hxx>
-#include <BOPDS_IndexRange.hxx>
-#include <BOPDS_MapOfPassKeyBoolean.hxx>
-#include <BOPDS_PassKeyBoolean.hxx>
-#include <BOPDS_SubIterator.hxx>
-#include <BOPDS_Tools.hxx>
+#include <BOPDS_Pair.hxx>
+#include <BOPDS_MapOfPair.hxx>
+
#include <NCollection_UBTreeFiller.hxx>
-#include <TopoDS.hxx>
+
#include <TopoDS_Shape.hxx>
-#include <TopoDS_Vertex.hxx>
-//
-//
-//
-//
-//
+#include <algorithm>
+
//=======================================================================
-//function :
+//function : BOPDS_SubIterator
//purpose :
//=======================================================================
BOPDS_SubIterator::BOPDS_SubIterator()
:
myAllocator(NCollection_BaseAllocator::CommonBaseAllocator()),
- myList(myAllocator)
+ myList(1, myAllocator)
{
- myDS=NULL;
+ myDS=NULL;
}
//=======================================================================
-//function :
+//function : BOPDS_SubIterator
//purpose :
//=======================================================================
BOPDS_SubIterator::BOPDS_SubIterator(const Handle(NCollection_BaseAllocator)& theAllocator)
:
myAllocator(theAllocator),
- myList(myAllocator)
+ myList(1, myAllocator)
{
- myDS=NULL;
+ myDS=NULL;
}
//=======================================================================
//function : ~
{
}
//=======================================================================
-// function: SetDS
-// purpose:
-//=======================================================================
- void BOPDS_SubIterator::SetDS(const BOPDS_PDS& aDS)
-{
- myDS=aDS;
-}
-//=======================================================================
-// function: DS
-// purpose:
-//=======================================================================
- const BOPDS_DS& BOPDS_SubIterator::DS()const
-{
- return *myDS;
-}
-//=======================================================================
-//function : SetSubSet1
-//purpose :
-//=======================================================================
- void BOPDS_SubIterator::SetSubSet1(const BOPCol_ListOfInteger& theLI)
-{
- mySubSet1=(BOPCol_PListOfInteger)&theLI;
-}
-//=======================================================================
-//function : SubSet1
-//purpose :
-//=======================================================================
- const BOPCol_ListOfInteger& BOPDS_SubIterator::SubSet1()const
-{
- return *mySubSet1;
-}
-//=======================================================================
-//function : SetSubSet2
-//purpose :
-//=======================================================================
- void BOPDS_SubIterator::SetSubSet2(const BOPCol_ListOfInteger& theLI)
-{
- mySubSet2=(BOPCol_PListOfInteger)&theLI;
-}
-//=======================================================================
-//function : SubSet2
-//purpose :
-//=======================================================================
- const BOPCol_ListOfInteger& BOPDS_SubIterator::SubSet2()const
-{
- return *mySubSet2;
-}
-//=======================================================================
// function: Initialize
// purpose:
//=======================================================================
- void BOPDS_SubIterator::Initialize()
-{
- myIterator.Initialize(myList);
-}
-//=======================================================================
-// function: More
-// purpose:
-//=======================================================================
- Standard_Boolean BOPDS_SubIterator::More()const
-{
- return myIterator.More();
-}
-//=======================================================================
-// function: Next
-// purpose:
-//=======================================================================
- void BOPDS_SubIterator::Next()
+void BOPDS_SubIterator::Initialize()
{
- myIterator.Next();
+ // sort interfering pairs for constant order of intersection
+ std::stable_sort(myList.begin(), myList.end());
+ // initialize iterator to access the pairs
+ myIterator.Init(myList);
}
//=======================================================================
// function: Value
{
Standard_Integer iT1, iT2, n1, n2;
//
- const BOPDS_PassKeyBoolean& aPKB=myIterator.Value();
- aPKB.Ids(n1, n2);
+ const BOPDS_Pair& aPKB = myIterator.Value();
+ aPKB.Indices(n1, n2);
//
iT1=(Standard_Integer)(myDS->ShapeInfo(n1).ShapeType());
iT2=(Standard_Integer)(myDS->ShapeInfo(n2).ShapeType());
if (!myDS){
return;
}
+ //
if (!mySubSet1->Extent() || !mySubSet2->Extent()) {
return;
}
+ //
+ myList.SetIncrement(2 * (mySubSet1->Extent() + mySubSet2->Extent()));
+ //
Intersect();
}
//=======================================================================
//=======================================================================
void BOPDS_SubIterator::Intersect()
{
- Standard_Integer i, aNbB, aNbSD, j, iDS, jB;
- Handle(NCollection_BaseAllocator) aAllocator;
- BOPCol_ListIteratorOfListOfInteger aIt, aIt1, aIt2;
- BOPDS_PassKeyBoolean aPKXB;
- //
- //-----------------------------------------------------scope_1 f
- aAllocator=
- NCollection_BaseAllocator::CommonBaseAllocator();
- //
- BOPCol_DataMapOfShapeInteger aMSI(100, aAllocator);
- BOPCol_DataMapOfIntegerInteger aMII(100, aAllocator);
- BOPDS_MapOfPassKeyBoolean aMPKXB(100, aAllocator);
- BOPCol_IndexedDataMapOfShapeBox aMSB(100, aAllocator);
- //
- BOPCol_BoxBndTreeSelector aSelector;
+ Standard_Integer i, j, iTi, iTj;
BOPCol_BoxBndTree aBBTree;
NCollection_UBTreeFiller <Standard_Integer, Bnd_Box> aTreeFiller(aBBTree);
//
- aIt1.Initialize(*mySubSet1);
- for (; aIt1.More(); aIt1.Next()) {
- i=aIt1.Value();
- const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
- const TopoDS_Shape& aS=aSI.Shape();
- const Bnd_Box& aBoxEx=aSI.Box();
- aMSI.Bind(aS, i);
- aMSB.Add(aS, aBoxEx);
- }
- //
- aNbB=aMSB.Extent();
- for (i=1; i<=aNbB; ++i) {
- const TopoDS_Shape& aS=aMSB.FindKey(i);
- const Bnd_Box& aBoxEx=aMSB(i);
+ BOPCol_ListIteratorOfListOfInteger aIt(*mySubSet1);
+ for (; aIt.More(); aIt.Next()) {
+ i = aIt.Value();
//
- aTreeFiller.Add(i, aBoxEx);
+ const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(i);
+ const Bnd_Box& aBoxEx = aSI.Box();
//
- iDS=aMSI.Find(aS);
- aMII.Bind(i, iDS);
+ aTreeFiller.Add(i, aBoxEx);
}
//
aTreeFiller.Fill();
//
- aIt2.Initialize(*mySubSet2);
- for (; aIt2.More(); aIt2.Next()) {
- i=aIt2.Value();
+ BOPDS_MapOfPair aMPKFence;
+ //
+ aIt.Initialize(*mySubSet2);
+ for (; aIt.More(); aIt.Next()) {
+ i = aIt.Value();
//
- const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
- const Bnd_Box& aBoxEx=aSI.Box();
+ const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(i);
+ const Bnd_Box& aBoxEx = aSI.Box();
//
- aSelector.Clear();
+ BOPCol_BoxBndTreeSelector aSelector;
aSelector.SetBox(aBoxEx);
- aNbSD=aBBTree.Select(aSelector);
- if (!aNbSD){
+ Standard_Integer aNbSD = aBBTree.Select(aSelector);
+ if (!aNbSD) {
continue;
}
- //const Bnd_Box& aBoxi=myDS->ShapeInfo(i).Box();
//
- const BOPCol_ListOfInteger& aLI=aSelector.Indices();
- aIt.Initialize(aLI);
- for (; aIt.More(); aIt.Next()) {
- jB=aIt.Value(); // box index in MII
- j=aMII.Find(jB); // DS index
+ iTi = BOPDS_Tools::TypeToInteger(aSI.ShapeType());
+ //
+ const BOPCol_ListOfInteger& aLI = aSelector.Indices();
+ BOPCol_ListIteratorOfListOfInteger aItLI(aLI);
+ for (; aItLI.More(); aItLI.Next()) {
+ j = aItLI.Value();
+ //
+ const BOPDS_ShapeInfo& aSJ = myDS->ShapeInfo(j);
+ iTj = BOPDS_Tools::TypeToInteger(aSJ.ShapeType());
//
- aPKXB.SetIds(i, j);
- if (aMPKXB.Add(aPKXB)) {
- myList.Append(aPKXB);
- }// if (aMPKXB.Add(aPKXB)) {
- }// for (; aIt.More(); aIt.Next()) {
+ // avoid interfering of the same shapes and shape with its sub-shapes
+ if ((i == j) || ((iTi < iTj) && aSI.HasSubShape(j)) ||
+ ((iTi > iTj) && aSJ.HasSubShape(i))) {
+ continue;
+ }
+ //
+ BOPDS_Pair aPair(j, i);
+ if (aMPKFence.Add(aPair)) {
+ myList.Append(aPair);
+ }
+ }
}
- //
- aMSI.Clear();
- aMII.Clear();
- aMPKXB.Clear();
- aMSB.Clear();
- //
- //-----------------------------------------------------scope_1 t
}
#include <BOPCol_BaseAllocator.hxx>
#include <BOPDS_PDS.hxx>
-#include <BOPDS_ListOfPassKeyBoolean.hxx>
-#include <BOPDS_ListIteratorOfListOfPassKeyBoolean.hxx>
+#include <BOPDS_Pair.hxx>
+#include <BOPDS_VectorOfPair.hxx>
#include <BOPCol_PListOfInteger.hxx>
#include <BOPCol_ListOfInteger.hxx>
#include <Standard_Boolean.hxx>
class BOPDS_DS;
+//! The class BOPDS_SubIterator is used to compute intersections between
+//! bounding boxes of two sub-sets of BRep sub-shapes of arguments
+//! of an operation (see the class BOPDS_DS).
+//! The class provides interface to iterate the pairs of intersected sub-shapes.
-//! The class BOPDS_SubIterator is
-//! 1.to compute intersections between two sub-sets of
-//! BRep sub-shapes
-//! of arguments of an operation (see the class BOPDS_DS)
-//! in terms of theirs bounding boxes
-//! 2.provides interface to iterare the pairs of
-//! intersected sub-shapes of given type
class BOPDS_SubIterator
{
public:
DEFINE_STANDARD_ALLOC
-
-
- //! Empty contructor
+ //! Empty constructor
Standard_EXPORT BOPDS_SubIterator();
-Standard_EXPORT virtual ~BOPDS_SubIterator();
-
+ Standard_EXPORT virtual ~BOPDS_SubIterator();
- //! Contructor
+ //! Constructor
//! theAllocator - the allocator to manage the memory
Standard_EXPORT BOPDS_SubIterator(const BOPCol_BaseAllocator& theAllocator);
-
- //! Modifier
- //! Sets the data structure <pDS> to process
- Standard_EXPORT void SetDS (const BOPDS_PDS& pDS);
-
+ //! Sets the data structure <pDS> to process.
+ //! It is used to access the shapes and their bounding boxes.
+ void SetDS (const BOPDS_PDS& pDS)
+ {
+ myDS = pDS;
+ }
- //! Selector
//! Returns the data structure
- Standard_EXPORT const BOPDS_DS& DS() const;
-
+ const BOPDS_DS& DS() const
+ {
+ return *myDS;
+ }
- //! Modifier
- //! Sets the first set of indices <theLI> to process
- Standard_EXPORT void SetSubSet1 (const BOPCol_ListOfInteger& theLI);
-
+ //! Sets the first set of indices <theLI> to process
+ void SetSubSet1 (const BOPCol_ListOfInteger& theLI)
+ {
+ mySubSet1 = (BOPCol_PListOfInteger)&theLI;
+ }
- //! Selector
//! Returns the first set of indices to process
- Standard_EXPORT const BOPCol_ListOfInteger& SubSet1() const;
-
+ const BOPCol_ListOfInteger& SubSet1() const
+ {
+ return *mySubSet1;
+ }
- //! Modifier
- //! Sets the second set of indices <theLI> to process
- Standard_EXPORT void SetSubSet2 (const BOPCol_ListOfInteger& theLI);
-
+ //! Sets the second set of indices <theLI> to process
+ void SetSubSet2 (const BOPCol_ListOfInteger& theLI)
+ {
+ mySubSet2 = (BOPCol_PListOfInteger)&theLI;
+ }
- //! Selector
//! Returns the second set of indices to process
- Standard_EXPORT const BOPCol_ListOfInteger& SubSet2() const;
-
+ const BOPCol_ListOfInteger& SubSet2() const
+ {
+ return *mySubSet2;
+ }
- //! Initializes the iterator
+ //! Initializes the iterator
Standard_EXPORT void Initialize();
-
- //! Returns true if still there are pairs
- //! of intersected shapes
- Standard_EXPORT Standard_Boolean More() const;
-
+ //! Returns true if there are more pairs of intersected shapes
+ Standard_Boolean More() const
+ {
+ return myIterator.More();
+ }
//! Moves iterations ahead
- Standard_EXPORT void Next();
-
+ void Next()
+ {
+ myIterator.Next();
+ }
//! Returns indices (DS) of intersected shapes
//! theIndex1 - the index of the first shape
//! theIndex2 - the index of the second shape
Standard_EXPORT void Value (Standard_Integer& theIndex1, Standard_Integer& theIndex2) const;
-
//! Perform the intersection algorithm and prepare
//! the results to be used
Standard_EXPORT virtual void Prepare();
-
-
+ //! Returns the number of interfering pairs
+ Standard_Integer ExpectedLength() const
+ {
+ return myList.Extent();
+ }
protected:
-
+ //! Performs intersection of bounding boxes
Standard_EXPORT virtual void Intersect();
-
BOPCol_BaseAllocator myAllocator;
BOPDS_PDS myDS;
- BOPDS_ListOfPassKeyBoolean myList;
- BOPDS_ListIteratorOfListOfPassKeyBoolean myIterator;
+ BOPDS_VectorOfPair myList;
+ BOPDS_VectorOfPair::Iterator myIterator;
BOPCol_PListOfInteger mySubSet1;
BOPCol_PListOfInteger mySubSet2;
-
private:
-
-
-
-
};
-
-
-
-
-
-
#endif // _BOPDS_SubIterator_HeaderFile
--- /dev/null
+// 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 BOPDS_VectorOfPair_HeaderFile
+#define BOPDS_VectorOfPair_HeaderFile
+
+#include <BOPCol_NCVector.hxx>
+#include <BOPDS_Pair.hxx>
+
+typedef BOPCol_NCVector<BOPDS_Pair> BOPDS_VectorOfPair;
+
+#endif
--- /dev/null
+// 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 BOPDS_VectorOfVectorOfPair_HeaderFile
+#define BOPDS_VectorOfVectorOfPair_HeaderFile
+
+#include <BOPCol_NCVector.hxx>
+#include <BOPDS_VectorOfPair.hxx>
+
+typedef BOPCol_NCVector<BOPDS_VectorOfPair> BOPDS_VectorOfVectorOfPair;
+
+#endif
BOPDS_VectorOfPave.hxx
BOPDS_VectorOfPoint.hxx
BOPDS_VectorOfShapeInfo.hxx
+BOPDS_Pair.hxx
+BOPDS_PairMapHasher.hxx
+BOPDS_MapOfPair.hxx
+BOPDS_VectorOfPair.hxx
+BOPDS_VectorOfVectorOfPair.hxx
#include <BOPAlgo_CheckResult.hxx>
#include <BOPCol_ListOfShape.hxx>
#include <BOPDS_DS.hxx>
-#include <BOPDS_MapOfPassKey.hxx>
+#include <BOPDS_MapOfPair.hxx>
#include <BOPTest.hxx>
#include <BOPTest_Objects.hxx>
#include <BOPTools_AlgoTools.hxx>
TopAbs_ShapeEnum aType1, aType2;
BOPAlgo_CheckerSI aChecker;
BOPCol_ListOfShape aLS;
- BOPDS_MapIteratorMapOfPassKey aItMPK;
+ BOPDS_MapIteratorOfMapOfPair aItMPK;
//
if (aLevel < (aNbInterfTypes-1)) {
di << "Info:\nThe level of check is set to "
//
const BOPDS_DS& aDS=*(aChecker.PDS());
//
- const BOPDS_MapOfPassKey& aMPK=aDS.Interferences();
+ const BOPDS_MapOfPair& aMPK=aDS.Interferences();
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
using namespace std;
vector <BOPTest_Interf> aVec;
//
aItMPK.Initialize(aMPK);
for (; aItMPK.More(); aItMPK.Next()) {
- const BOPDS_PassKey& aPK=aItMPK.Value();
- aPK.Ids(n1, n2);
+ const BOPDS_Pair& aPK=aItMPK.Value();
+ aPK.Indices(n1, n2);
if(aDS.IsNewShape(n1) || aDS.IsNewShape(n2)) {
continue;
}
return 1;
}
//
- Standard_Boolean bFlag;
Standard_Integer n1, n2;
char buf[64], aST1[10], aST2[10];
BOPDS_Iterator aIt;
for (i = 0; i < 4; ++i) {
GetNameByType(aT[i], aST1);
//
- for (j = 0; j < 4; ++j) {
+ for (j = i; j < 4; ++j) {
GetNameByType(aT[j], aST2);
//
aIt.Initialize(aT[i], aT[j]);
for (; aIt.More(); aIt.Next()) {
- aIt.Value(n1, n2, bFlag);
+ aIt.Value(n1, n2);
//
Sprintf(buf, "%s/%s: (z%d z%d)\n", aST1, aST2, n1, n2);
di << buf;
//
aIt.Initialize(aT1, aT2);
for (; aIt.More(); aIt.Next()) {
- aIt.Value(n1, n2, bFlag);
+ aIt.Value(n1, n2);
//
Sprintf(buf, "%s/%s: (z%d z%d)\n", aST1, aST2, n1, n2);
di << buf;
# test script on make volume operation
# cylinder plane unstable
-puts "TODO OCC26020 ALL: Error: bopcheck failed"
-
# planar face
plane pln_f1 0 -232.5 3.8857805861880479e-015 0 -1 -1.1102230246251565e-016
erase pln_f1
bopsection result
puts "Finish boolean operation ..."
-checkprops result -l 3384.97
+checkprops result -l 3356.31
checkshape result
checksection result
checknbshapes result -vertex 1197 -edge 1182 -wire 0 -face 0 -shell 0 -solid 0 -compsolid 0 -compound 1 -shape 2380
--- /dev/null
+puts "========"
+puts "OCC28284"
+puts "========"
+puts ""
+#################################################
+# Avoid classification of sub-shapes of arguments of BOPs relatively solids during Intersection phase
+#################################################
+
+restore [locate_data_file bug28284.brep] b1
+plane p 0 9000 0 0 1 0
+mkface f p -1.e+6 1.e+6 -1.e+6 1.e+6
+halfspace b2 f 0 0 0
+
+bop b1 b2
+
+bopcommon result1
+checkshape result1
+checknbshapes result1 -solid 1
+checkprops result1 -s 5.828e+007 -v 5.50235e+008
+
+bopcut result
+checkshape result
+checknbshapes result -solid 1
+checkprops result -s 247149 -v 1.81425e+006
+
+checkview -display result -2d -path ${imagedir}/${test_image}.png
\ No newline at end of file
--- /dev/null
+puts "========"
+puts "OCC28284"
+puts "========"
+puts ""
+#################################################
+# Avoid classification of sub-shapes of arguments of BOPs relatively solids during Intersection phase
+#################################################
+
+restore [locate_data_file bug28284_1.brep] b1
+plane p 0 9000 0 0 1 0
+mkface f p -1.e+6 1.e+6 -1.e+6 1.e+6
+halfspace b2 f 0 0 0
+
+bop b1 b2
+
+bopcommon result1
+checkshape result1
+checknbshapes result1 -solid 1
+checkprops result1 -s 2.58352e+007 -v 2.43418e+008
+
+bopcut result
+checkshape result
+checknbshapes result -solid 1
+checkprops result -s 247149 -v 1.81425e+006
+
+checkview -display result -2d -path ${imagedir}/${test_image}.png
\ No newline at end of file
--- /dev/null
+puts "========"
+puts "OCC28284"
+puts "========"
+puts ""
+#################################################
+# Avoid classification of sub-shapes of arguments of BOPs relatively solids during Intersection phase
+#################################################
+
+box b1 10 10 10
+
+explode b1 sh
+shape b2 So
+add b1_1 b2
+
+bop b1 b2
+
+bopcommon rcom
+checknbshapes rcom -solid 1
+
+bopfuse rfuse
+checknbshapes rfuse -solid 1
+
+bopcut rcut
+checknbshapes rcut -solid 0
+
+boptuc rtuc
+checknbshapes rcut -solid 0
\ No newline at end of file