From cd28f12078db3f221d1017eff3fc867112e31e6a Mon Sep 17 00:00:00 2001 From: vsr Date: Thu, 2 Dec 2010 08:07:07 +0000 Subject: [PATCH] 0021030: EDF 1599 GEOM: Bug in GetInPlace shell of the created group may be badly shaped --- src/GEOMAlgo/GEOMAlgo_BuilderSolid.cxx | 178 ++++++++++++++++++------- src/GEOMAlgo/GEOMAlgo_Builder_1.cxx | 19 ++- src/GEOMAlgo/GEOMAlgo_Builder_2.cxx | 99 ++++++++------ src/GEOMAlgo/GEOMAlgo_Builder_3.cxx | 50 ++----- src/GEOMAlgo/GEOMAlgo_ShapeSet.cdl | 9 +- src/GEOMAlgo/GEOMAlgo_ShapeSet.cxx | 52 +++++--- src/GEOMAlgo/GEOMAlgo_ShapeSet.hxx | 99 ++++++-------- 7 files changed, 286 insertions(+), 220 deletions(-) diff --git a/src/GEOMAlgo/GEOMAlgo_BuilderSolid.cxx b/src/GEOMAlgo/GEOMAlgo_BuilderSolid.cxx index 2bc49887d..07be8c7fb 100755 --- a/src/GEOMAlgo/GEOMAlgo_BuilderSolid.cxx +++ b/src/GEOMAlgo/GEOMAlgo_BuilderSolid.cxx @@ -95,10 +95,14 @@ static void MakeInternalShells(const TopTools_MapOfShape& , TopTools_ListOfShape& ); -//modified by NIZNHY-PKV Tue Aug 5 15:06:50 2008f static - Standard_Boolean IsClosedShell(const TopoDS_Shell& theShell); -//modified by NIZNHY-PKV Tue Aug 5 15:06:57 2008t + Standard_Boolean IsClosedShell(const TopoDS_Shell& ); + +//modified by NIZNHY-PKV Tue Oct 26 13:30:39 2010f +static + Standard_Boolean RefineShell(const TopoDS_Shell& , + TopoDS_Shell& ); +//modified by NIZNHY-PKV Tue Oct 26 13:30:42 2010t //======================================================================= //function : @@ -187,15 +191,17 @@ static if (!myShapesToAvoid.Contains(aF)) { TopExp::MapShapesAndAncestors(aF, TopAbs_EDGE, TopAbs_FACE, aMEF); } - else { - int a=0; + /* + else { + int a=0; } + */ } aNbE=aMEF.Extent(); // // 2. myFacesToAvoid for (i=1; i<=aNbE; ++i) { - const TopoDS_Edge& aE=TopoDS::Edge(aMEF.FindKey(i)); + const TopoDS_Edge& aE=*((TopoDS_Edge*)(&aMEF.FindKey(i))); if (BRep_Tool::Degenerated(aE)) { continue; } @@ -209,7 +215,7 @@ static // aOrE=aE.Orientation(); // - const TopoDS_Face& aF1=TopoDS::Face(aLF.First()); + const TopoDS_Face& aF1=*((TopoDS_Face*)(&aLF.First())); if (aNbF==1) { if (aOrE==TopAbs_INTERNAL) { continue; @@ -218,7 +224,7 @@ static myShapesToAvoid.Add(aF1); } else if (aNbF==2) { - const TopoDS_Face& aF2=TopoDS::Face(aLF.Last()); + const TopoDS_Face& aF2=*((TopoDS_Face*)(&aLF.Last())); if (aF2.IsSame(aF1)) { if (BRep_Tool::IsClosed(aE, aF1)) { continue; @@ -233,7 +239,7 @@ static myShapesToAvoid.Add(aF2); } } - //DEB + /*//DEB else { TopTools_ListIteratorOfListOfShape aItLF; // @@ -243,7 +249,7 @@ static int a=0; } } - //DEB + *///DEB }// for (i=1; i<=aNbE; ++i) { // if (!bFound) { @@ -262,12 +268,12 @@ static // myLoops.Clear(); // - Standard_Integer aNbLF, aNbOff, aNbFP, aNbFA; + Standard_Integer aNbLF, aNbOff, aNbFP; TopAbs_Orientation anOr; TopoDS_Edge aEL; BRep_Builder aBB; NMTTools_CoupleOfShape aCSOff; - TopTools_MapOfOrientedShape AddedFacesMap;//, aMFP; + TopTools_MapOfOrientedShape AddedFacesMap; TopTools_IndexedDataMapOfShapeListOfShape aEFMap, aMEFP; TopTools_ListIteratorOfListOfShape aItF, aIt; TopTools_MapIteratorOfMapOfOrientedShape aItM; @@ -304,12 +310,12 @@ static // loop on faces added to Shell; add their neighbor faces to Shell and so on TopoDS_Iterator aItAddedF (aShell); for (; aItAddedF.More(); aItAddedF.Next()) { - const TopoDS_Face& aF = TopoDS::Face(aItAddedF.Value()); + const TopoDS_Face& aF = *((TopoDS_Face*)(&aItAddedF.Value())); // // loop on edges of aF; find a good neighbor face of aF by aE TopExp_Explorer aEdgeExp(aF, TopAbs_EDGE); for (; aEdgeExp.More(); aEdgeExp.Next()) { - const TopoDS_Edge& aE = TopoDS::Edge(aEdgeExp.Current()); + const TopoDS_Edge& aE=*((TopoDS_Edge*)(&aEdgeExp.Current())); // //1 if (aMEFP.Contains(aE)) { @@ -344,7 +350,7 @@ static // aItLF.Initialize(aLF); for (; aItLF.More(); aItLF.Next()) { - const TopoDS_Face& aFL=TopoDS::Face(aItLF.Value()); + const TopoDS_Face& aFL=*((TopoDS_Face*)(&aItLF.Value())); if (myShapesToAvoid.Contains(aFL)) { continue; } @@ -372,7 +378,7 @@ static // TopoDS_Face aSelF; if (aNbOff==1) { - aSelF=TopoDS::Face(aLCSOff.First().Shape2()); + aSelF=*((TopoDS_Face*)(&aLCSOff.First().Shape2())); } else if (aNbOff>1){ GEOMAlgo_Tools3D::GetFaceOff(aE, aF, aLCSOff, aSelF); @@ -384,24 +390,22 @@ static } } // for (; aEdgeExp.More(); aEdgeExp.Next()) { } //for (; aItAddedF.More(); aItAddedF.Next()) { - //modified by NIZNHY-PKV Tue Aug 5 15:07:08 2008f - //myLoops.Append(aShell); + // if (IsClosedShell(aShell)) { myLoops.Append(aShell); } - /* + //modified by NIZNHY-PKV Wed Oct 27 07:10:41 2010f else { - TopoDS_Iterator aItS; - aItS.Initialize(aShell); - for (; aItS.More(); aItS.Next()) { - const TopoDS_Shape& aFs=aItS.Value(); - aMFP.Add(aFs); + Standard_Boolean bRefine; + TopoDS_Shell aShx; + // + bRefine=RefineShell(aShell, aShx); + if (bRefine) { + myLoops.Append(aShx); } } - */ - //modified by NIZNHY-PKV Tue Aug 5 15:07:30 2008t - } // for (; aItF.More(); aItF.Next()) { - //modified by NIZNHY-PKV Tue Aug 5 15:07:35 2008f + //modified by NIZNHY-PKV Wed Oct 27 07:10:44 2010t + } // for (; aItF.More(); aItF.Next()) { // // Post Treatment TopTools_MapOfOrientedShape aMP; @@ -417,14 +421,14 @@ static } } // - // b. collect all edges that are to avoid + // b. collect all faces that are to avoid aItM.Initialize(myShapesToAvoid); for (; aItM.More(); aItM.Next()) { const TopoDS_Shape& aF=aItM.Key(); aMP.Add(aF); } // - // c. add all edges that are not processed to myShapesToAvoid + // c. add all faces that are not processed to myShapesToAvoid aIt.Initialize (myShapes); for (; aIt.More(); aIt.Next()) { const TopoDS_Shape& aF=aIt.Value(); @@ -432,7 +436,6 @@ static myShapesToAvoid.Add(aF); } } - //modified by NIZNHY-PKV Tue Aug 5 15:07:44 2008t //================================================= // // 2.Internal Shells @@ -442,8 +445,6 @@ static aEFMap.Clear(); AddedFacesMap.Clear(); // - aNbFA=myShapesToAvoid.Extent(); - // aItM.Initialize(myShapesToAvoid); for (; aItM.More(); aItM.Next()) { const TopoDS_Shape& aFF=aItM.Key(); @@ -464,15 +465,15 @@ static // TopoDS_Iterator aItAddedF (aShell); for (; aItAddedF.More(); aItAddedF.Next()) { - const TopoDS_Face& aF = TopoDS::Face(aItAddedF.Value()); + const TopoDS_Face& aF = *((TopoDS_Face*)(&aItAddedF.Value())); // TopExp_Explorer aEdgeExp(aF, TopAbs_EDGE); for (; aEdgeExp.More(); aEdgeExp.Next()) { - const TopoDS_Edge& aE = TopoDS::Edge(aEdgeExp.Current()); + const TopoDS_Edge& aE = *((TopoDS_Edge*)(&aEdgeExp.Current())); const TopTools_ListOfShape& aLF=aEFMap.FindFromKey(aE); aItF.Initialize(aLF); for (; aItF.More(); aItF.Next()) { - const TopoDS_Face& aFL=TopoDS::Face(aItF.Value()); + const TopoDS_Face& aFL=*((TopoDS_Face*)(&aItF.Value())); if (AddedFacesMap.Add(aFL)){ aBB.Add(aShell, aFL); } @@ -518,10 +519,8 @@ static } else{ // check if a shell is a hole - //XX bIsHole=IsHole(aShell, myContext); - //bIsHole=GEOMAlgo_BuilderTools::IsHole(aShell); - //XX + // if (bIsHole) { aHoleShells.Append(aShell); TopExp::MapShapes(aShell, TopAbs_FACE, aMHF); @@ -581,7 +580,7 @@ static // 3. Add aHoles to Solids aItMSH.Initialize(aMSH); for (; aItMSH.More(); aItMSH.Next()) { - TopoDS_Solid aSolid=TopoDS::Solid(aItMSH.Key()); + TopoDS_Solid aSolid=*((TopoDS_Solid*)(&aItMSH.Key())); // const TopTools_ListOfShape& aLH=aItMSH.Value(); aShellIt.Initialize(aLH); @@ -637,7 +636,7 @@ static // 2 Process solids aSolidIt.Initialize(myAreas); for ( ; aSolidIt.More(); aSolidIt.Next()) { - TopoDS_Solid& aSolid=TopoDS::Solid(aSolidIt.Value()); + TopoDS_Solid& aSolid=*((TopoDS_Solid*)(&aSolidIt.Value())); // aMEF.Clear(); TopExp::MapShapesAndAncestors(aSolid, TopAbs_EDGE, TopAbs_FACE, aMEF); @@ -646,7 +645,7 @@ static aMFP.Clear(); aItMF.Initialize(aMF); for (; aItMF.More(); aItMF.Next()) { - const TopoDS_Face& aF=TopoDS::Face(aItMF.Key()); + const TopoDS_Face& aF=*((TopoDS_Face*)(&aItMF.Key())); if (GEOMAlgo_Tools3D::IsInternalFace(aF, aSolid, aMEF, 1.e-14, *myContext)) { aMFP.Add(aF); } @@ -792,7 +791,6 @@ Standard_Boolean IsGrowthShell(const TopoDS_Shape& theShell, } return bRet; } -//modified by NIZNHY-PKV Tue Aug 5 15:07:50 2008f //======================================================================= //function : IsClosedShell //purpose : @@ -811,18 +809,15 @@ Standard_Boolean IsClosedShell(const TopoDS_Shell& theShell) const TopoDS_Face& aF=TopoDS::Face(aIt.Value()); aExp.Init(aF, TopAbs_EDGE); for (; aExp.More(); aExp.Next()) { - const TopoDS_Edge& aE=TopoDS::Edge(aExp.Current()); + const TopoDS_Edge& aE=*((TopoDS_Edge*)(&aExp.Current())); if (BRep_Tool::Degenerated(aE)) { continue; } - /* - if (BRep_Tool::IsClosed(aE, aF)) { - continue; - } - */ + // if (aE.Orientation()==TopAbs_INTERNAL) { continue; } + // if (!aM.Add(aE)) { aM.Remove(aE); } @@ -835,8 +830,89 @@ Standard_Boolean IsClosedShell(const TopoDS_Shell& theShell) } return bRet; } -//modified by NIZNHY-PKV Tue Aug 5 15:08:07 2008t -//BRepTools::Write(aFF, "ff"); +//modified by NIZNHY-PKV Tue Oct 26 13:30:23 2010f +//======================================================================= +//function : RefineShell +//purpose : +//======================================================================= + Standard_Boolean RefineShell(const TopoDS_Shell& aShell, + TopoDS_Shell& aShx) + +{ + Standard_Boolean bRet; + Standard_Integer i, aNbE, aNbF; + TopAbs_Orientation aOrE; + TopTools_IndexedDataMapOfShapeListOfShape aMEF; + TopTools_MapOfOrientedShape aMFx; + // + bRet=Standard_False; + // + TopExp::MapShapesAndAncestors(aShell, TopAbs_EDGE, TopAbs_FACE, aMEF); + aNbE=aMEF.Extent(); + for (i=1; i<=aNbE; ++i) { + const TopoDS_Edge &aE=*((TopoDS_Edge*)(&aMEF.FindKey(i))); + // + if (BRep_Tool::Degenerated(aE)) { + continue; + } + // + aOrE=aE.Orientation(); + // + const TopTools_ListOfShape& aLF=aMEF(i); + aNbF=aLF.Extent(); + if (!aNbF) { + continue; + } + // + const TopoDS_Face& aF1=*((TopoDS_Face*)(&aLF.First())); + if (aNbF==1) { + if (aOrE==TopAbs_INTERNAL) { + continue; + } + aMFx.Add(aF1); + } + // + else if (aNbF==2) { + const TopoDS_Face& aF2=*((TopoDS_Face*)(&aLF.Last())); + if (aF2.IsSame(aF1)) { + if (BRep_Tool::IsClosed(aE, aF1)) { + continue; + } + if (aOrE==TopAbs_INTERNAL) { + continue; + } + aMFx.Add(aF1); + aMFx.Add(aF2); + } + } + } + // + aNbF=aMFx.Extent(); + if (!aNbF) { + return bRet; + } + // + BRep_Builder aBB; + TopoDS_Iterator aIt; + // + aNbF=0; + aBB.MakeShell(aShx); + aIt.Initialize(aShell); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aF=aIt.Value(); + if (!aMFx.Contains(aF)) { + aBB.Add(aShx, aF); + ++aNbF; + } + } + // + if (aNbF) { + bRet=IsClosedShell(aShx); + } + // + return bRet; +} +//modified by NIZNHY-PKV Tue Oct 26 13:30:26 2010t // // ErrorStatus : // 11 - Null Context diff --git a/src/GEOMAlgo/GEOMAlgo_Builder_1.cxx b/src/GEOMAlgo/GEOMAlgo_Builder_1.cxx index a6a2885ea..2c9f3d66e 100755 --- a/src/GEOMAlgo/GEOMAlgo_Builder_1.cxx +++ b/src/GEOMAlgo/GEOMAlgo_Builder_1.cxx @@ -116,7 +116,7 @@ static IntTools_Context& aCtx=pPF->ChangeContext(); // Standard_Boolean bToReverse; - Standard_Integer i, aNb, aNbSp, nSp, nSpR, nSpx, aIsCB; + Standard_Integer i, aNb, aNbSp, nSp, nSpR, nSpx, aIsCB, aNbLB; TColStd_ListIteratorOfListOfInteger aItLB; TColStd_ListOfInteger aLB; TopoDS_Edge aEE, aESpR; @@ -150,16 +150,17 @@ static nSp=aPB.Edge(); const TopoDS_Shape& aSp=aDS.Shape(nSp); // - //modified by NIZNHY-PKV Fri Nov 30 10:40:36 2007 f - //const BOPTools_PaveBlock& aPBR=pPF->RealPaveBlock(aPB, aLB); const BOPTools_PaveBlock& aPBR=pPF->RealPaveBlock(aPB, aLB, aIsCB); - //modified by NIZNHY-PKV Fri Nov 30 10:40:48 2007t + //modified by NIZNHY-PKV Wed Oct 27 11:19:30 2010f + aNbLB=aLB.Extent(); + if (aIsCB && aNbLB<2) { + aIsCB=0; + } + //modified by NIZNHY-PKV Wed Oct 27 11:19:34 2010t + // nSpR=aPBR.Edge(); const TopoDS_Shape& aSpR=aDS.Shape(nSpR); - //modified by NIZNHY-PKV Fri Nov 30 10:41:39 2007f - //if (aSpR.IsSame(aSp) && aSpR.IsSame(aE)) { if (aSpR.IsSame(aSp) && aSpR.IsSame(aE) && !aIsCB) { - //modified by NIZNHY-PKV Fri Nov 30 10:41:46 2007t continue; } // @@ -183,10 +184,7 @@ static aIt.Initialize(aLPB); for (; aIt.More(); aIt.Next()) { const BOPTools_PaveBlock& aPB=aIt.Value(); - //modified by NIZNHY-PKV Fri Nov 30 10:42:15 2007f - //const BOPTools_PaveBlock& aPBR=pPF->RealPaveBlock(aPB, aLB); const BOPTools_PaveBlock& aPBR=pPF->RealPaveBlock(aPB, aLB, aIsCB); - //modified by NIZNHY-PKV Fri Nov 30 10:42:20 2007t nSpR=aPBR.Edge(); const TopoDS_Shape& aSpR=aDS.Shape(nSpR); // @@ -203,7 +201,6 @@ static const TopoDS_Shape& aSpx=aDS.Shape(nSpx); mySameDomainShapes.Add(aSpx ,aSpR); } - // } } // diff --git a/src/GEOMAlgo/GEOMAlgo_Builder_2.cxx b/src/GEOMAlgo/GEOMAlgo_Builder_2.cxx index b35ec2975..2aa155bb5 100755 --- a/src/GEOMAlgo/GEOMAlgo_Builder_2.cxx +++ b/src/GEOMAlgo/GEOMAlgo_Builder_2.cxx @@ -70,6 +70,8 @@ #include #include +#include + #include #include #include @@ -84,7 +86,8 @@ #include #include #include -#include + +#include static void UpdateCandidates(const Standard_Integer , @@ -254,6 +257,9 @@ static aNbSE=aLSE.Extent(); if (aNbSE) { aMFP.Add(i); + //modified by NIZNHY-PKV Wed Oct 27 11:40:57 2010f + break; + //modified by NIZNHY-PKV Wed Oct 27 11:41:07 2010t } } } @@ -358,46 +364,35 @@ static } // // 2.2. Build images Faces - GEOMAlgo_BuilderFace aBF; + TopTools_ListOfShape aLFR; + GEOMAlgo_ShapeSet aS1, aS2; // - aBF.SetFace(aFF); - aBF.SetContext(aCtx); const TopTools_ListOfShape& aSE=aWES.StartElements(); - // - //DEB f - /* - { - TopoDS_Compound aCx; - BRep_Builder aBBx; - TopTools_ListIteratorOfListOfShape aItx; + //modified by NIZNHY-PKV Thu Oct 28 08:30:41 2010f + aS1.Add(aSE); + aS2.Add(aFF, TopAbs_EDGE); + if (aS1.IsEqual(aS2)) { + aLFR.Append(aF); + } + //modified by NIZNHY-PKV Thu Oct 28 08:30:42 2010t + else { + GEOMAlgo_BuilderFace aBF; // - aBBx.MakeCompound(aCx); - aBBx.Add(aCx, aFF); - aItx.Initialize(aSE); - for (; aItx.More(); aItx.Next()) { - TopoDS_Shape& aEx=aItx.Value(); - aBBx.Add(aCx, aEx); - } - int a=0; - } - */ - //DEB t - // - aBF.SetShapes(aSE); - // - aBF.Perform(); - // - const TopTools_ListOfShape& aLF=aBF.Areas(); - // - TopTools_ListOfShape aLFR; - // - aIt.Initialize(aLF); - for (; aIt.More(); aIt.Next()) { - TopoDS_Shape& aFR=aIt.Value(); - if (anOriF==TopAbs_REVERSED) { - aFR.Orientation(TopAbs_REVERSED); + aBF.SetFace(aFF); + aBF.SetContext(aCtx); + aBF.SetShapes(aSE); + // <-DEB + aBF.Perform(); + // + const TopTools_ListOfShape& aLF=aBF.Areas(); + aIt.Initialize(aLF); + for (; aIt.More(); aIt.Next()) { + TopoDS_Shape& aFR=aIt.Value(); + if (anOriF==TopAbs_REVERSED) { + aFR.Orientation(TopAbs_REVERSED); + } + aLFR.Append(aFR); } - aLFR.Append(aFR); } // // 2.3. Collect draft images Faces @@ -530,7 +525,7 @@ static //======================================================================= void GEOMAlgo_Builder::FillImagesFaces1() { - Standard_Integer i, aNb, iSense; + Standard_Integer i, aNb, iSense, aNbLFx; TopoDS_Face aF, aFSp, aFSD; TopTools_ListOfShape aLFx; TopTools_ListIteratorOfListOfShape aIt; @@ -568,7 +563,16 @@ static aLFx.Append(aFSD); } } - if (!myImages.HasImage(aF)) {//XX + if (!myImages.HasImage(aF)) { + //modified by NIZNHY-PKV Wed Oct 27 14:41:34 2010f + aNbLFx=aLFx.Extent(); + if (aNbLFx==1) { + const TopoDS_Shape& aFx=aLFx.First(); + if (aF.IsSame(aFx)) { + continue; + } + } + //modified by NIZNHY-PKV Wed Oct 27 14:41:36 2010t myImages.Bind(aF, aLFx); } } @@ -803,3 +807,20 @@ void UpdateCandidates(const Standard_Integer theNF, theMFMV.Add(theNF, aMV); } } + +/* + { + TopoDS_Compound aCx; + BRep_Builder aBBx; + TopTools_ListIteratorOfListOfShape aItx; + // + aBBx.MakeCompound(aCx); + aBBx.Add(aCx, aFF); + aItx.Initialize(aSE); + for (; aItx.More(); aItx.Next()) { + TopoDS_Shape& aEx=aItx.Value(); + aBBx.Add(aCx, aEx); + } + int a=0; + } + */ diff --git a/src/GEOMAlgo/GEOMAlgo_Builder_3.cxx b/src/GEOMAlgo/GEOMAlgo_Builder_3.cxx index ea602fe60..de2f35be8 100755 --- a/src/GEOMAlgo/GEOMAlgo_Builder_3.cxx +++ b/src/GEOMAlgo/GEOMAlgo_Builder_3.cxx @@ -193,7 +193,7 @@ static IntTools_Context& aCtx= pPF->ChangeContext(); // Standard_Boolean bIsIN, bHasImage; - Standard_Integer aNbS, aNbSolids, i, j, aNbFaces, aNbFP, aNbFPx, aNbFIN, aNbLIF;// k, + Standard_Integer aNbS, aNbSolids, i, j, aNbFaces, aNbFP, aNbFPx, aNbFIN, aNbLIF; TopAbs_ShapeEnum aType; TopAbs_State aState; TopTools_IndexedMapOfShape aMSolids, aMS, aMFaces, aMFIN; @@ -432,8 +432,6 @@ static GEOMAlgo_DataMapOfShapeShapeSet aMSS; GEOMAlgo_ShapeSet aSSi; // - //modified by NIZNHY-PKV Wed Dec 6 17:08:03 2006f - // // 0. Find same domain solids for non-interferred solids aNbS=aDS.NumberOfShapesOfTheObject(); for (i=1; i<=aNbS; ++i) { @@ -454,10 +452,7 @@ static aMSS.Bind(aS, aSSi); } //for (i=1; i<=aNbS; ++i) // - //modified by NIZNHY-PKV Wed Dec 6 17:08:09 2006t - // // 1. Build solids for interferred source solids - // aSB.SetContext(aCtx); aNbS=myDraftSolids.Extent(); for (i=1; i<=aNbS; ++i) { @@ -516,6 +511,11 @@ static } const TopTools_ListOfShape& aSFS1=aSSi.GetSet(); aNbSFS=aSFS1.Extent(); + //modified by NIZNHY-PKV Wed Oct 27 09:53:15 2010f + if (!aNbSFS) { + continue; + } + //modified by NIZNHY-PKV Wed Oct 27 09:53:18 2010t // // 1.3 Build new solids aSB.SetShapes(aSFS1); @@ -528,7 +528,7 @@ static // const TopTools_ListOfShape& aLSR=aSB.Areas(); // - // 1.4 Collect resulting solids and theirs set of faces + // 1.4 Collect resulting solids and theirs set of faces aIt.Initialize(aLSR); for (; aIt.More(); aIt.Next()) { const TopoDS_Shape& aSR=aIt.Value(); @@ -536,8 +536,8 @@ static aSSi.Clear(); aExp.Init(aSR, TopAbs_FACE); for (; aExp.More(); aExp.Next()) { - const TopoDS_Shape& aF=aExp.Current(); - aSSi.Add(aF); + const TopoDS_Shape& aF=aExp.Current(); + aSSi.Add(aF); } aMSS.Bind(aSR, aSSi); } @@ -550,38 +550,6 @@ static myImages.Bind(aS, aLSR); } } // for (i=1; i<=aNbS; ++i) { - //modified by NIZNHY-PKV Wed Dec 6 17:07:47 2006f - /* - // - // 2. Find same domain solids for non-interferred solids - aNbS=aDS.NumberOfShapesOfTheObject(); - for (i=1; i<=aNbS; ++i) { - const TopoDS_Shape& aS=aDS.Shape(i); - if (aS.ShapeType()!=TopAbs_SOLID) { - continue; - } - if (!aMFence.Add(aS)) { - continue; - } - if(myImages.HasImage(aS)) { - continue; - } - // - aSSi.Clear(); - aSSi.Add(aS, TopAbs_FACE); - // - aItSS.Initialize(aMSS); - for (; aItSS.More(); aItSS.Next()) { - const TopoDS_Shape& aSR=aItSS.Key(); - const GEOMAlgo_ShapeSet& aSSR=aItSS.Value(); - if (aSSi.Contains(aSSR)) { - myImages.Bind(aS, aSR); - break; - } - } - } //for (i=1; i<=aNbS; ++i) - */ - //modified by NIZNHY-PKV Wed Dec 6 17:07:55 2006t } //======================================================================= //function :FillInternalShapes diff --git a/src/GEOMAlgo/GEOMAlgo_ShapeSet.cdl b/src/GEOMAlgo/GEOMAlgo_ShapeSet.cdl index 14744f7f4..31c89d754 100755 --- a/src/GEOMAlgo/GEOMAlgo_ShapeSet.cdl +++ b/src/GEOMAlgo/GEOMAlgo_ShapeSet.cdl @@ -73,7 +73,14 @@ is ---Purpose: Returns the Set returns ListOfShape from TopTools; ---C++: return const & - + --modified by NIZNHY-PKV Wed Oct 28 13:51:45 2010f + IsEqual(me; + theOther: ShapeSet from GEOMAlgo) + ---Purpose: Returns True if the Set==theSet + returns Boolean from Standard; + ---C++: alias operator == + --modified by NIZNHY-PKV Wed Oct 28 13:51:50 2010t + fields myMap : MapOfOrientedShape from TopTools is protected; myList : ListOfShape from TopTools is protected; diff --git a/src/GEOMAlgo/GEOMAlgo_ShapeSet.cxx b/src/GEOMAlgo/GEOMAlgo_ShapeSet.cxx index 32f16eebd..2a1310070 100755 --- a/src/GEOMAlgo/GEOMAlgo_ShapeSet.cxx +++ b/src/GEOMAlgo/GEOMAlgo_ShapeSet.cxx @@ -96,17 +96,6 @@ //======================================================================= const TopTools_ListOfShape& GEOMAlgo_ShapeSet::GetSet()const { - /* - TopTools_ListOfShape *pL; - TopTools_MapIteratorOfMapOfOrientedShape aIt; - // - pL=(TopTools_ListOfShape *)&myList; - pL->Clear(); - aIt.Initialize(myMap); - for (; aIt.More(); aIt.Next()) { - pL->Append(aIt.Key()); - } - */ return myList; } //======================================================================= @@ -140,16 +129,6 @@ //======================================================================= void GEOMAlgo_ShapeSet::Subtract(const GEOMAlgo_ShapeSet& theOther) { - /* - TopTools_MapIteratorOfMapOfOrientedShape aIt; - // - aIt.Initialize(theOther.myMap); - for (; aIt.More(); aIt.Next()) { - const TopoDS_Shape& aS=aIt.Key(); - myMap.Remove(aS); - } - */ - // TopTools_ListIteratorOfListOfShape aIt; TopTools_ListOfShape aLS; // @@ -166,3 +145,34 @@ // myList=aLS; } +//modified by NIZNHY-PKV Wed Oct 28 13:51:36 2010f +//======================================================================= +//function : IsEqual +//purpose : +//======================================================================= + Standard_Boolean GEOMAlgo_ShapeSet::IsEqual(const GEOMAlgo_ShapeSet& theOther)const +{ + Standard_Boolean bRet; + Standard_Integer aNb1, aNb2; + TopAbs_Orientation aOr; + TopTools_ListIteratorOfListOfShape aIt; + // + bRet=Standard_True; + aNb1=myList.Extent(); + const TopTools_ListOfShape& aLS2=theOther.GetSet(); + aNb2=aLS2.Extent(); + if (aNb1!=aNb2) { + return !bRet; + } + // + aIt.Initialize(myList); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aS=aIt.Value(); + if(!theOther.myMap.Contains(aS)) { + bRet=!bRet; + break; + } + } + return bRet; +} +//modified by NIZNHY-PKV Wed Oct 28 13:51:38 2010t diff --git a/src/GEOMAlgo/GEOMAlgo_ShapeSet.hxx b/src/GEOMAlgo/GEOMAlgo_ShapeSet.hxx index 7c9136641..618a4dee3 100644 --- a/src/GEOMAlgo/GEOMAlgo_ShapeSet.hxx +++ b/src/GEOMAlgo/GEOMAlgo_ShapeSet.hxx @@ -23,6 +23,13 @@ #ifndef _GEOMAlgo_ShapeSet_HeaderFile #define _GEOMAlgo_ShapeSet_HeaderFile +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + #ifndef _TopTools_MapOfOrientedShape_HeaderFile #include #endif @@ -39,59 +46,48 @@ class TopTools_ListOfShape; class TopoDS_Shape; -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Standard_Macro_HeaderFile -#include -#endif - //! Implementation some formal
//! opereations with Set of shapes
class GEOMAlgo_ShapeSet { - public: - void* operator new(size_t,void* anAddress) - { - return anAddress; - } - void* operator new(size_t size) - { - return Standard::Allocate(size); - } - void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } - // Methods PUBLIC - // - -//! Empty constructor
-Standard_EXPORT GEOMAlgo_ShapeSet(); - -//! Adds shapes from the list theLS to the Set
-Standard_EXPORT void Add(const TopTools_ListOfShape& theLS) ; - -//! Adds shape theShape to the Set
-Standard_EXPORT void Add(const TopoDS_Shape& theShape) ; - -//! Adds sub-shapes of shape theShape,
+ void* operator new(size_t,void* anAddress) + { + return anAddress; + } + void* operator new(size_t size) + { + return Standard::Allocate(size); + } + void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + //! Empty constructor
+ Standard_EXPORT GEOMAlgo_ShapeSet(); + //! Adds shapes from the list theLS to the Set
+ Standard_EXPORT void Add(const TopTools_ListOfShape& theLS) ; + //! Adds shape theShape to the Set
+ Standard_EXPORT void Add(const TopoDS_Shape& theShape) ; + //! Adds sub-shapes of shape theShape,
//! that have type theType to the Set
-Standard_EXPORT void Add(const TopoDS_Shape& theShape,const TopAbs_ShapeEnum theType) ; - -//! Removes shapes of theSet from the Set
-Standard_EXPORT void Subtract(const GEOMAlgo_ShapeSet& theSet) ; - -//! Clears internal fields
-Standard_EXPORT void Clear() ; - -//! Returns True if the Set contains
+ Standard_EXPORT void Add(const TopoDS_Shape& theShape,const TopAbs_ShapeEnum theType) ; + //! Removes shapes of theSet from the Set
+ Standard_EXPORT void Subtract(const GEOMAlgo_ShapeSet& theSet) ; + //! Clears internal fields
+ Standard_EXPORT void Clear() ; + //! Returns True if the Set contains
//! all shapes of theSet
-Standard_EXPORT Standard_Boolean Contains(const GEOMAlgo_ShapeSet& theSet) const; - -//! Returns the Set
-Standard_EXPORT const TopTools_ListOfShape& GetSet() const; + Standard_EXPORT Standard_Boolean Contains(const GEOMAlgo_ShapeSet& theSet) const; + //! Returns the Set
+ Standard_EXPORT const TopTools_ListOfShape& GetSet() const; + //! Returns True if the Set==theSet
+ Standard_EXPORT Standard_Boolean IsEqual(const GEOMAlgo_ShapeSet& theOther) const; + Standard_Boolean operator ==(const GEOMAlgo_ShapeSet& theOther) const +{ + return IsEqual(theOther); +} @@ -99,24 +95,16 @@ Standard_EXPORT const TopTools_ListOfShape& GetSet() const; protected: - // Methods PROTECTED - // - // Fields PROTECTED - // TopTools_MapOfOrientedShape myMap; TopTools_ListOfShape myList; -private: +private: - // Methods PRIVATE - // - // Fields PRIVATE - // }; @@ -126,7 +114,6 @@ private: // other Inline functions and methods (like "C++: function call" methods) -// #endif -- 2.39.2