#include <NMTAlgo_Splitter.ixx>
-#include <TopoDS_Iterator.hxx>
-#include <TopTools_IndexedMapOfShape.hxx>
+
#include <TopoDS_Shape.hxx>
-#include <TopExp.hxx>
#include <TopoDS_Compound.hxx>
-#include <TopExp_Explorer.hxx>
#include <TopoDS_Solid.hxx>
#include <TopoDS_Shell.hxx>
-#include <TopTools_MapIteratorOfMapOfShape.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Wire.hxx>
+#include <TopoDS_Iterator.hxx>
+
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopTools_MapIteratorOfMapOfShape.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
-#include <NMTTools_DSFiller.hxx>
-#include <NMTDS_ShapesDataStructure.hxx>
-#include <NMTTools_PaveFiller.hxx>
+#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
+
#include <BOPTools_PInterferencePool.hxx>
#include <BOPTools_InterferencePool.hxx>
#include <BOPTools_CArray1OfEEInterference.hxx>
#include <BOPTools_CArray1OfESInterference.hxx>
#include <BOPTools_ESInterference.hxx>
+#include <NMTDS_ShapesDataStructure.hxx>
+#include <NMTTools_PaveFiller.hxx>
+#include <NMTTools_DSFiller.hxx>
+#include <NMTAlgo_Tools.hxx>
+
//=======================================================================
//function : KeepShapesInside
-//purpose : remove shapes that are outside of S from resul
+//purpose : remove shapes that are outside of S from result
//=======================================================================
void NMTAlgo_Splitter::KeepShapesInside (const TopoDS_Shape& S)
{
//=======================================================================
//function : RemoveShapesInside
-//purpose : remove shapes that are inside S from resul
+//purpose : remove shapes that are inside S from result
//=======================================================================
void NMTAlgo_Splitter::RemoveShapesInside (const TopoDS_Shape& S)
{
TopoDS_Iterator it;
if (S.ShapeType() < TopAbs_SOLID) { // compound or compsolid
- for (it.Initialize( S ); it.More(); it.Next())
+ it.Initialize( S );
+ for (; it.More(); it.Next()) {
RemoveShapesInside( it.Value());
+ }
return;
}
- Standard_Boolean isTool = Standard_False;
+ //
+ Standard_Boolean isTool;
+ TopoDS_Shape IntFacesComp;
+ TopoDS_Compound C;
+ TopTools_IndexedMapOfShape MIF; // map of internal faces
+ TopTools_MapOfShape RFM;
+ TopTools_MapIteratorOfMapOfShape itF;
+ //
+ isTool=myToolShapes.Contains(S);
+ //isTool = Standard_False;
if (!myImageShape.HasImage( S )) {
- //isTool = CheckTool( S );
- //if (!isTool) return;
return;
}
-
- TopoDS_Shape IntFacesComp = FindFacesInside( S, Standard_False, Standard_True);
- TopTools_IndexedMapOfShape MIF; // map of internal faces
+ //
+ IntFacesComp = FindFacesInside( S, Standard_False, Standard_True);
+ //
TopExp::MapShapes( IntFacesComp, TopAbs_FACE, MIF);
-
- if (MIF.IsEmpty()) return;
-
+ if (MIF.IsEmpty()) {
+ return;
+ }
// add to MIF split faces of S
- if (myImageShape.HasImage(S))
- TopExp::MapShapes( myImageShape.Image(S).First(), TopAbs_FACE, MIF);
-
+ const TopoDS_Shape& aSIm=myImageShape.Image(S).First();
+ TopExp::MapShapes(aSIm, TopAbs_FACE, MIF);
+ //
// leave in the result only those shapes not having all face in MIF
-
- TopoDS_Compound C;
myBuilder.MakeCompound(C);
-
- // RMF : faces of removed shapes that encounter once
- TopTools_MapOfShape RFM;
-
- for (it.Initialize( myShape ); it.More(); it.Next()) {
-
- TopExp_Explorer expResF( it.Value(), TopAbs_FACE );
- for (; expResF.More(); expResF.Next())
- if (!MIF.Contains( expResF.Current()))
+ //
+ // RFM : faces of removed shapes that encounter once
+ it.Initialize(myShape);
+ for (; it.More(); it.Next()) {
+ TopExp_Explorer expResF;
+ //
+ const TopoDS_Shape& aSR=it.Value();
+ //
+ expResF.Init(aSR, TopAbs_FACE);
+ for (; expResF.More(); expResF.Next()) {
+ const TopoDS_Shape& aFR=expResF.Current();
+ if (!MIF.Contains(aFR)) {
break;
-
- if (expResF.More())
+ }
+ }
+ //
+ if (expResF.More()) {
// add shape to result
- myBuilder.Add( C, it.Value() );
- else
+ myBuilder.Add(C, aSR);
+ }
+ else {
// add faces of a removed shape to RFM
for (expResF.ReInit(); expResF.More(); expResF.Next()) {
- const TopoDS_Shape& F = expResF.Current();
- if ( ! RFM.Remove ( F ))
- RFM.Add( F );
+ const TopoDS_Shape& aF = expResF.Current();
+ if (!RFM.Remove(aF)) {
+ RFM.Add(aF);
+ }
}
+ }
+ }// for (; it.More(); it.Next())
+ //
+ //
+ TopoDS_Compound aCx;
+ //
+ myBuilder.MakeCompound(aCx);
+ itF.Initialize (RFM);
+ for (; itF.More(); itF.Next()) {
+ const TopoDS_Shape& aF=itF.Key();
+ myBuilder.Add(aCx, aF);
}
-
+ //
if (!isTool) {
-
// rebuild S, it must remain in the result
-
Standard_Boolean isClosed = Standard_False;
switch (S.ShapeType()) {
case TopAbs_SOLID :
TopTools_IndexedDataMapOfShapeListOfShape MEF;
TopExp::MapShapesAndAncestors(S, TopAbs_EDGE, TopAbs_FACE, MEF);
Standard_Integer i;
- for (i=1; isClosed && i<=MEF.Extent(); ++i)
+ for (i=1; isClosed && i<=MEF.Extent(); ++i) {
isClosed = ( MEF(i).Extent() != 1 );
+ }
break;
}
default:
isClosed = Standard_False;
}
+ //
if (isClosed) {
-
// add to a new shape external faces of removed shapes, ie those in RFM
-
TopoDS_Shell Shell;
- myBuilder.MakeShell( Shell );
-
+ myBuilder.MakeShell(Shell);
// exclude redundant internal face with edges encounterd only once
TopTools_IndexedDataMapOfShapeListOfShape MEF;
- TopTools_MapIteratorOfMapOfShape itF (RFM);
- for ( ; itF.More(); itF.Next())
- TopExp::MapShapesAndAncestors(itF.Key(), TopAbs_EDGE, TopAbs_FACE, MEF);
-
+ //
+ itF.Initialize (RFM);
+ for ( ; itF.More(); itF.Next()) {
+ const TopoDS_Shape& aF=itF.Key();
+ TopExp::MapShapesAndAncestors(aF, TopAbs_EDGE, TopAbs_FACE, MEF);
+ }
// add only faces forming a closed shell
- for (itF.Reset() ; itF.More(); itF.Next())
- {
- TopExp_Explorer expE (itF.Key(), TopAbs_EDGE);
- for (; expE.More(); expE.Next())
- if (MEF.FindFromKey(expE.Current()).Extent() == 1)
+ for (itF.Reset() ; itF.More(); itF.Next()) {
+ const TopoDS_Shape& aF=itF.Key();
+ TopExp_Explorer expE (aF, TopAbs_EDGE);
+ for (; expE.More(); expE.Next()) {
+ if (MEF.FindFromKey(expE.Current()).Extent() == 1) {
break;
- if (!expE.More())
- myBuilder.Add( Shell, itF.Key());
+ }
+ }
+ if (!expE.More()) {
+ myBuilder.Add( Shell, aF);
+ }
+ else {
+ //int a=0;
+ }
}
-
+
if (S.ShapeType() == TopAbs_SOLID) {
TopoDS_Solid Solid;
myBuilder.MakeSolid( Solid );
myBuilder.Add (Solid, Shell);
myBuilder.Add (C, Solid);
}
- else
+ else {
myBuilder.Add (C, Shell);
- }
+ }
+ } // if (isClosed) {
else {
- if (myImageShape.HasImage( S )) {
- for (it.Initialize( myImageShape.Image(S).First()); it.More(); it.Next())
- myBuilder.Add (C, it.Value());
+ it.Initialize(aSIm);
+ for (; it.More(); it.Next()) {
+ myBuilder.Add (C, it.Value());
}
}
}
-
+ //
myShape = C;
}
-
+//
+//modified by NIZNHY-PKV Tue Feb 1 16:02:29 2005 f
//=======================================================================
//function : Modified
//purpose :
//=======================================================================
- const TopTools_ListOfShape& NMTAlgo_Splitter::Modified (const TopoDS_Shape& S)
+const TopTools_ListOfShape& NMTAlgo_Splitter::Modified (const TopoDS_Shape& S)
{
+ TopAbs_ShapeEnum aType;
+ //
myGenerated.Clear();
- TopTools_ListIteratorOfListOfShape it;
- TopTools_MapOfShape aMap;
- TopExp_Explorer anExp;
-
- if(S.ShapeType() == TopAbs_FACE || S.ShapeType() == TopAbs_EDGE) {
-
- if(S.ShapeType() == TopAbs_FACE) {
- if (myImagesFaces.HasImage( S )) {
- it.Initialize(myImagesFaces.Image(S));
- anExp.Init(myShape, TopAbs_FACE);
- }
- }
- else {
- if (myImagesEdges.HasImage( S )) {
- it.Initialize(myImagesEdges.Image(S));
- anExp.Init(myShape, TopAbs_EDGE);
- }
- }
-
- for(; anExp.More(); anExp.Next()) {
- aMap.Add(anExp.Current());
- }
-
- for (; it.More(); it.Next()) {
- if(aMap.Contains(it.Value())) {
- myGenerated.Append(it.Value());
- }
- }
-
- return myGenerated;
-
- }
-
- if(S.ShapeType() == TopAbs_VERTEX) {
+ //
+ aType=S.ShapeType();
+ //
+ switch (aType) {
+ case TopAbs_SOLID:
+ case TopAbs_FACE:
+ case TopAbs_EDGE:
+ case TopAbs_VERTEX:
+ FindImage(S, myGenerated);
+ break;
- const NMTTools_DSFiller& aDSF = Filler();
- const NMTTools_PaveFiller& aPF = aDSF.PaveFiller();
- const NMTDS_ShapesDataStructure& aDS = aDSF.DS();
-
- Standard_Integer aNbS = aDS.NumberOfSourceShapes();
- Standard_Integer anIndex = 0, i;
-
- for(i = 1; i <= aNbS; ++i) {
-
- const TopoDS_Shape& aS = aDS.Shape(i);
- if(S.IsSame(aS)) {
- anIndex = i;
- break;
- }
-
- }
+ case TopAbs_SHELL:
+ break;
+
+ case TopAbs_WIRE:
+ break;
+
+ default:
+ break;
+ }
+ //
+ return myGenerated;
+}
+//modified by NIZNHY-PKV Tue Feb 1 16:02:33 2005 t
+//=======================================================================
+//function : IsDeleted
+//purpose :
+//=======================================================================
+Standard_Boolean NMTAlgo_Splitter::IsDeleted (const TopoDS_Shape& S)
- if(anIndex == 0) return myGenerated;
+{
+ const TopTools_ListOfShape& aL = Modified(S);
+ if(aL.Extent() != 0) return Standard_False;
- Standard_Integer aSDVInd = aPF.FindSDVertex(anIndex);
+ TopTools_MapOfShape aMap;
+ TopExp_Explorer anExp;
- if(aSDVInd == 0) return myGenerated;
+ TopAbs_ShapeEnum aType = S.ShapeType();
- const TopoDS_Shape aSDV = aDS.Shape(aSDVInd);
+ if(aType == TopAbs_VERTEX ||
+ aType == TopAbs_EDGE ||
+ aType == TopAbs_FACE ) {
- anExp.Init(myShape, TopAbs_VERTEX);
+ anExp.Init(myShape, aType);
for(; anExp.More(); anExp.Next()) {
-
- if(aSDV.IsSame(anExp.Current())) {
- myGenerated.Append(aSDV);
- break;
- }
-
+ if(S.IsSame(anExp.Current())) return Standard_False;
}
-
- }
- return myGenerated;
+ }
+
+ return Standard_True;
}
//=======================================================================
//function : Generated
//purpose :
//=======================================================================
- const TopTools_ListOfShape& NMTAlgo_Splitter::Generated(const TopoDS_Shape& S)
+const TopTools_ListOfShape& NMTAlgo_Splitter::Generated(const TopoDS_Shape& S)
{
myGenerated.Clear();
TopTools_ListIteratorOfListOfShape it;
if(!aMap.Contains(it.Value())) {
myGenerated.Remove(it);
}
-
}
}
-
return myGenerated;
-
}
-
return myGenerated;
}
-
+//modified by NIZNHY-PKV Tue Feb 1 10:26:18 2005f
//=======================================================================
-//function : IsDeleted
+//function : FindImage
//purpose :
//=======================================================================
- Standard_Boolean NMTAlgo_Splitter::IsDeleted (const TopoDS_Shape& S)
-
+void NMTAlgo_Splitter::FindImage(const TopoDS_Shape& aS,
+ TopTools_ListOfShape& aLIms)
{
- const TopTools_ListOfShape& aL = Modified(S);
- if(aL.Extent() != 0) return Standard_False;
-
- TopTools_MapOfShape aMap;
- TopExp_Explorer anExp;
-
- TopAbs_ShapeEnum aType = S.ShapeType();
-
- if(aType == TopAbs_VERTEX ||
- aType == TopAbs_EDGE ||
- aType == TopAbs_FACE ) {
-
+ TopAbs_ShapeEnum aType;
+ //
+ aType=aS.ShapeType();
+ //
+ if (aType==TopAbs_SOLID) {
+ Standard_Boolean bHasImage, bHasInternalFaces;
+ Standard_Integer i, aNbSd;
+ TopTools_IndexedMapOfShape aMSo, aMSd;
+ TopoDS_Iterator aIt;
+ TopTools_IndexedDataMapOfShapeListOfShape aMFS;
+ TopTools_ListIteratorOfListOfShape aItLS;
+ //
+ bHasInternalFaces=myMapSIFC.IsBound(aS);
+ if (bHasInternalFaces){
+ TopExp::MapShapesAndAncestors(myShape, TopAbs_FACE, TopAbs_SOLID, aMFS);
+ //
+ const TopoDS_Shape& aIFC=myMapSIFC.Find(aS);
+ //
+ aIt.Initialize(aIFC);
+ for (; aIt.More(); aIt.Next()) {
+ const TopoDS_Shape& aIF=aIt.Value();
+ if (aMFS.Contains(aIF)) {
+ const TopTools_ListOfShape& aLS=aMFS.FindFromKey(aIF);
+ //
+ aItLS.Initialize(aLS);
+ for (; aItLS.More(); aItLS.Next()) {
+ const TopoDS_Shape& aSx=aItLS.Value();
+ aMSd.Add(aSx);
+ }
+ }
+ }
+ //
+ aNbSd=aMSd.Extent();
+ if (aNbSd) {
+ for (i=1; i<=aNbSd; ++i) {
+ const TopoDS_Shape& aSx=aMSd(i);
+ if (!aSx.IsSame(aS)) {
+ aLIms.Append(aSx);
+ }
+ }
+ return;
+ }
+ }
+ //
+ bHasImage=myImageShape.HasImage(aS);
+ if (!bHasImage) {
+ return;
+ }
+ //
+ TopoDS_Shape aSd;
+ //
+ TopExp::MapShapes(myShape, TopAbs_SOLID, aMSo);
+ //
+ const TopoDS_Shape& aFC=myImageShape.Image(aS).First();
+ bHasImage=NMTAlgo_Tools::FindImageSolid(aFC, aMSo, aSd);
+ if (bHasImage) {
+ if (!aSd.IsSame(aS)) {
+ aLIms.Append(aSd);
+ }
+ }
+ } //if (aType==TopAbs_SOLID) {
+ //==
+ else if (aType==TopAbs_FACE) {
+ TopTools_MapOfShape aMap;
+ TopTools_ListIteratorOfListOfShape aIt;
+ TopExp_Explorer anExp;
+ //
+ if (myModifiedFaces.IsBound(aS)) {
+ anExp.Init(myShape, aType);
+ for(; anExp.More(); anExp.Next()) {
+ aMap.Add(anExp.Current());
+ }
+ //
+ const TopTools_ListOfShape& aLS=myModifiedFaces.Find(aS);
+ aIt.Initialize(aLS);
+ for (; aIt.More(); aIt.Next()) {
+ const TopoDS_Shape& aFx=aIt.Value();
+ if (!aFx.IsSame(aS)) {
+ if (aMap.Contains(aFx)) {
+ aLIms.Append(aFx);
+ }
+ }
+ }
+ }
+ } // else if (aType==TopAbs_FACE)
+ //==
+ else if (aType==TopAbs_EDGE) {
+ TopTools_MapOfShape aMap;
+ TopTools_ListIteratorOfListOfShape aIt;
+ TopExp_Explorer anExp;
+ //
+ if (myImagesEdges.HasImage(aS)) {
+ anExp.Init(myShape, aType);
+ for(; anExp.More(); anExp.Next()) {
+ aMap.Add(anExp.Current());
+ }
+ //
+ const TopTools_ListOfShape& aLE=myImagesEdges.Image(aS);
+ aIt.Initialize(aLE);
+ for (; aIt.More(); aIt.Next()) {
+ const TopoDS_Shape& aEx=aIt.Value();
+ if (!aEx.IsSame(aS)) {
+ if(aMap.Contains(aEx)) {
+ aLIms.Append(aEx);
+ }
+ }
+ }
+ }
+ }// else if (aType==TopAbs_EDGE)
+ //==
+ else if (aType==TopAbs_VERTEX) {
+ Standard_Integer aNbS, anIndex, i, aSDVInd;
+ TopExp_Explorer anExp;
+ //
+ const NMTTools_DSFiller& aDSF = Filler();
+ const NMTTools_PaveFiller& aPF = aDSF.PaveFiller();
+ const NMTDS_ShapesDataStructure& aDS = aDSF.DS();
+ //
+ aNbS = aDS.NumberOfSourceShapes();
+ anIndex = 0;
+ //
+ for(i=1; i<=aNbS; ++i) {
+ const TopoDS_Shape& aSx = aDS.Shape(i);
+ if(aS.IsSame(aSx)) {
+ anIndex = i;
+ break;
+ }
+ }
+ //
+ if(!anIndex) {
+ return;
+ }
+ //
+ aSDVInd=aPF.FindSDVertex(anIndex);
+ if(!aSDVInd) {
+ return;
+ }
+ //
+ const TopoDS_Shape& aSDV=aDS.Shape(aSDVInd);
+ //
anExp.Init(myShape, aType);
for(; anExp.More(); anExp.Next()) {
- if(S.IsSame(anExp.Current())) return Standard_False;
+ const TopoDS_Shape& aVx=anExp.Current();
+ if(aSDV.IsSame(aVx)) {
+ aLIms.Append(aSDV);
+ break;
+ }
}
-
- }
-
- return Standard_True;
+ }// else if (aType==TopAbs_VERTEX)
}
+//modified by NIZNHY-PKV Tue Feb 1 10:26:22 2005t