//=======================================================================
void GEOMAlgo_GetInPlace::Clear()
{
+ TopoDS_Shape aS;
+ //
myErrorStatus=0;
myWarningStatus=0;
//
myIterator.Clear();
myShapesIn.Clear();
myShapesOn.Clear();
+ myShapesInclusive.Clear();
myMapShapePnt.Clear();
+ myChecked.Clear();
+ myResult= aS;
}
//=======================================================================
//function : Perform
return;
}
//
- FillEdgesOn();
+ FillEdgesOn(myArgument);
+ FillEdgesOn(myShapeWhere);
if (myErrorStatus) {
return;
}
return;
}
//
- FillFacesOn();
+ FillFacesOn(myArgument);
+ FillFacesOn(myShapeWhere);
if (myErrorStatus) {
return;
}
return;
}
//
- FillSolidsOn();
+ FillSolidsOn(myArgument);
+ FillSolidsOn(myShapeWhere);
if (myErrorStatus) {
return;
}
return;
}
//
- FillImages();
+ myImages.Clear();
+ FillImages(myShapeWhere, Standard_True);
+ FillImages(myArgument, Standard_False);
+
if (myErrorStatus) {
return;
}
//
const TopoDS_Shape& aS1=aMS1(i);
BRepBndLib::Add(aS1, aBox1);
- //modified by NIZNHY-PKV Fri Jun 10 08:20:03 2011f
- //aBox1.SetGap(myTolerance);
aBox1.Enlarge(myTolerance);
- //modified by NIZNHY-PKV Fri Jun 10 08:20:06 2011t
//
aTreeFiller.Add(i, aBox1);
}
//
const TopoDS_Shape& aS2=aMS2(j);
BRepBndLib::Add(aS2, aBox2);
- //modified by NIZNHY-PKV Fri Jun 10 08:20:23 2011f
- //aBox2.SetGap(myTolerance);
aBox2.Enlarge(myTolerance);
- //modified by NIZNHY-PKV Fri Jun 10 08:20:25 2011t
//
aSelector.Clear();
aSelector.SetBox(aBox2);
const TopoDS_Shape& aV2=aCS.Shape2();
//
FillShapesOn(aV1, aV2);
+ FillShapesOn(aV2, aV1);
}
}
//=======================================================================
//function : FillEdgesOn
//purpose :
//=======================================================================
-void GEOMAlgo_GetInPlace::FillEdgesOn()
+void GEOMAlgo_GetInPlace::FillEdgesOn(const TopoDS_Shape &theShape)
{
Standard_Integer i, aNbE;
TopoDS_Iterator aIt;
TopTools_IndexedMapOfShape aME;
TopTools_MapIteratorOfMapOfShape aItMS;
//
- TopExp::MapShapes(myArgument, TopAbs_EDGE, aME);
+ TopExp::MapShapes(theShape, TopAbs_EDGE, aME);
aNbE=aME.Extent();
for (i=1; i<=aNbE; ++i) {
const TopoDS_Edge& aE1=*((TopoDS_Edge*)&aME(i));
//=======================================================================
void GEOMAlgo_GetInPlace::PerformEE()
{
- Standard_Boolean bHasOn, bHasIn, bFound;
- TopoDS_Iterator aIt;
- TopTools_MapOfShape aMSX;
- //
myErrorStatus=0;
myWarningStatus=0;
//
const GEOMAlgo_CoupleOfShapes& aCS=myIterator.Value();
const TopoDS_Shape& aE1=aCS.Shape1();
const TopoDS_Shape& aE2=aCS.Shape2();
- //
- bHasOn=myShapesOn.IsBound(aE1);
- bHasIn=myShapesIn.IsBound(aE1);
- const TopTools_MapOfShape& aMSOn=(bHasOn) ? myShapesOn.Find(aE1) : aMSX;
- const TopTools_MapOfShape& aMSIn=(bHasIn) ? myShapesIn.Find(aE1) : aMSX;
- //
- bFound=Standard_True;
- aIt.Initialize(aE2);
- for (; aIt.More(); aIt.Next()) {
- const TopoDS_Shape& aV2=aIt.Value();
- if (!(aMSOn.Contains(aV2) || aMSIn.Contains(aV2))) {
- bFound=!bFound;
- break;
- }
- }
- if (!bFound) {
- continue;
+
+ PerformEE(aE1, aE2);
+
+ if (myErrorStatus) {
+ return;
}
- //
- bFound=CheckCoincidence(aE1, aE2);
+
+ PerformEE(aE2, aE1);
+
if (myErrorStatus) {
return;
}
- if (bFound) {
- FillShapesIn(aE1, aE2);
+ }
+}
+//=======================================================================
+//function : PerformEE
+//purpose :
+//=======================================================================
+void GEOMAlgo_GetInPlace::PerformEE(const TopoDS_Shape &theE1,
+ const TopoDS_Shape &theE2)
+{
+ Standard_Boolean bHasOn, bHasIn, bFound;
+ TopoDS_Iterator aIt;
+ TopTools_MapOfShape aMSX;
+ //
+ bHasOn=myShapesOn.IsBound(theE1);
+ bHasIn=myShapesIn.IsBound(theE1);
+ const TopTools_MapOfShape& aMSOn=(bHasOn) ? myShapesOn.Find(theE1) : aMSX;
+ const TopTools_MapOfShape& aMSIn=(bHasIn) ? myShapesIn.Find(theE1) : aMSX;
+ //
+ bFound=Standard_True;
+ aIt.Initialize(theE2);
+ for (; aIt.More(); aIt.Next()) {
+ const TopoDS_Shape& aV2=aIt.Value();
+ if (!(aMSOn.Contains(aV2) || aMSIn.Contains(aV2))) {
+ bFound=!bFound;
+ break;
}
}
+ if (!bFound) {
+ return;
+ }
+ //
+ bFound=CheckCoincidence(theE1, theE2);
+ if (myErrorStatus) {
+ return;
+ }
+ if (bFound) {
+ FillShapesIn(theE1, theE2);
+ }
}
//=======================================================================
//function : PerformVF
//function : FillFacesOn
//purpose :
//=======================================================================
-void GEOMAlgo_GetInPlace::FillFacesOn()
+void GEOMAlgo_GetInPlace::FillFacesOn(const TopoDS_Shape &theShape)
{
Standard_Integer i, j, aNbF, aNbE;
TopoDS_Iterator aIt;
TopTools_IndexedMapOfShape aMF, aME;
TopTools_MapIteratorOfMapOfShape aItMS;
//
- TopExp::MapShapes(myArgument, TopAbs_FACE, aMF);
+ TopExp::MapShapes(theShape, TopAbs_FACE, aMF);
aNbF=aMF.Extent();
for (i=1; i<=aNbF; ++i) {
const TopoDS_Face& aF1=*((TopoDS_Face*)&aMF(i));
//=======================================================================
void GEOMAlgo_GetInPlace::PerformFF()
{
- Standard_Boolean bFound, bHasOnF, bHasInF;
- Standard_Integer i, aNbS2;
- TopTools_MapOfShape aMSX;
- TopTools_IndexedMapOfShape aMS2;
- //
myErrorStatus=0;
myWarningStatus=0;
//
const GEOMAlgo_CoupleOfShapes& aCS=myIterator.Value();
const TopoDS_Shape& aF1=aCS.Shape1();
const TopoDS_Shape& aF2=aCS.Shape2();
- //
- bHasOnF=myShapesOn.IsBound(aF1);
- const TopTools_MapOfShape& aMSOnF=(bHasOnF) ? myShapesOn.Find(aF1) : aMSX;
- //
- bHasInF=myShapesIn.IsBound(aF1);
- const TopTools_MapOfShape& aMSInF=(bHasInF) ? myShapesIn.Find(aF1) : aMSX;
- //
- aMS2.Clear();
- MapBRepShapes(aF2, aMS2);
- //
- bFound=Standard_False;
- aNbS2=aMS2.Extent();
- for (i=1; i<=aNbS2; ++i) {
- const TopoDS_Shape& aS2=aMS2(i);
- if (aS2.IsSame(aF2)) {
- continue;
- }
- bFound=(aMSOnF.Contains(aS2) || aMSInF.Contains(aS2));
- if (!bFound) {
- break;
- }
- }
- if (!bFound) {
- continue;
+
+ PerformFF(aF1, aF2);
+
+ if (myErrorStatus) {
+ return;
}
- //
- bFound=CheckCoincidence(aF1, aF2);
+
+ PerformFF(aF2, aF1);
+
if (myErrorStatus) {
return;
}
- if (bFound) {
- FillShapesIn(aF1, aF2);
+ }
+}
+//=======================================================================
+//function : PerformFF
+//purpose :
+//=======================================================================
+void GEOMAlgo_GetInPlace::PerformFF(const TopoDS_Shape &theF1,
+ const TopoDS_Shape &theF2)
+{
+ Standard_Boolean bFound, bHasOnF, bHasInF;
+ Standard_Integer i, aNbS2;
+ TopTools_MapOfShape aMSX;
+ TopTools_IndexedMapOfShape aMS2;
+ //
+ bHasOnF=myShapesOn.IsBound(theF1);
+ const TopTools_MapOfShape& aMSOnF=(bHasOnF) ? myShapesOn.Find(theF1) : aMSX;
+ //
+ bHasInF=myShapesIn.IsBound(theF1);
+ const TopTools_MapOfShape& aMSInF=(bHasInF) ? myShapesIn.Find(theF1) : aMSX;
+ //
+ MapBRepShapes(theF2, aMS2);
+ //
+ bFound=Standard_False;
+ aNbS2=aMS2.Extent();
+ for (i=1; i<=aNbS2; ++i) {
+ const TopoDS_Shape& aS2=aMS2(i);
+ if (aS2.IsSame(theF2)) {
+ continue;
+ }
+ bFound=(aMSOnF.Contains(aS2) || aMSInF.Contains(aS2));
+ if (!bFound) {
+ break;
}
}
+ if (!bFound) {
+ return;
+ }
+ //
+ bFound=CheckCoincidence(theF1, theF2);
+ if (myErrorStatus) {
+ return;
+ }
+ if (bFound) {
+ FillShapesIn(theF1, theF2);
+ }
}
//=======================================================================
//function : FillSolidsOn
//purpose :
//=======================================================================
-void GEOMAlgo_GetInPlace::FillSolidsOn()
+void GEOMAlgo_GetInPlace::FillSolidsOn(const TopoDS_Shape &theShape)
{
Standard_Integer i, j, aNbS, aNbF;
TopTools_IndexedMapOfShape aMS, aMF;
TopTools_MapIteratorOfMapOfShape aItMS;
//
- TopExp::MapShapes(myArgument, TopAbs_SOLID, aMS);
+ TopExp::MapShapes(theShape, TopAbs_SOLID, aMS);
//
aNbS=aMS.Extent();
for (i=1; i<=aNbS; ++i) {
//=======================================================================
void GEOMAlgo_GetInPlace::PerformZZ()
{
- Standard_Boolean bFound, bHasOn, bHasIn;
- Standard_Integer i, aNbS2, iCntOn, iCntIn, iCntOut;
- TopTools_MapOfShape aMSX;
- TopTools_IndexedMapOfShape aMS2;
- //
myErrorStatus=0;
myWarningStatus=0;
//
const GEOMAlgo_CoupleOfShapes& aCS=myIterator.Value();
const TopoDS_Shape& aSo1=aCS.Shape1();
const TopoDS_Shape& aSo2=aCS.Shape2();
- //
- bHasOn=myShapesOn.IsBound(aSo1);
- const TopTools_MapOfShape& aMSOn=(bHasOn) ? myShapesOn.Find(aSo1) : aMSX;
- //
- bHasIn=myShapesIn.IsBound(aSo1);
- const TopTools_MapOfShape& aMSIn=(bHasIn) ? myShapesIn.Find(aSo1) : aMSX;
- //
- aMS2.Clear();
- TopExp::MapShapes(aSo2, TopAbs_FACE, aMS2);
- //
- iCntIn=0;
- iCntOn=0;
- iCntOut=0;
- bFound=Standard_False;
- aNbS2=aMS2.Extent();
- for (i=1; i<=aNbS2; ++i) {
- const TopoDS_Shape& aF2=aMS2(i);
- //
- if (aMSIn.Contains(aF2)) {
- ++iCntIn;
- bFound=Standard_True;
- break;
- }
- else if (!aMSOn.Contains(aF2)) {
- ++iCntOut;
- bFound=Standard_False;// out
- break;
- }
- else {
- ++iCntOn; //on
- }
+
+ PerformZZ(aSo1, aSo2);
+
+ if (myErrorStatus) {
+ return;
}
- //
- if (!bFound && iCntOut) {
- continue;
+
+ PerformZZ(aSo2, aSo1);
+
+ if (myErrorStatus) {
+ return;
}
+ }// for (; myIterator.More(); myIterator.Next()) {
+}
+//=======================================================================
+//function : PerformZZ
+//purpose :
+//=======================================================================
+void GEOMAlgo_GetInPlace::PerformZZ(const TopoDS_Shape &theSo1,
+ const TopoDS_Shape &theSo2)
+{
+ Standard_Boolean bFound, bHasOn, bHasIn;
+ Standard_Integer i, aNbS2, iCntOn, iCntIn, iCntOut;
+ TopTools_MapOfShape aMSX;
+ TopTools_IndexedMapOfShape aMS2;
+ //
+ bHasOn=myShapesOn.IsBound(theSo1);
+ const TopTools_MapOfShape& aMSOn=(bHasOn) ? myShapesOn.Find(theSo1) : aMSX;
+ //
+ bHasIn=myShapesIn.IsBound(theSo1);
+ const TopTools_MapOfShape& aMSIn=(bHasIn) ? myShapesIn.Find(theSo1) : aMSX;
+ //
+ TopExp::MapShapes(theSo2, TopAbs_FACE, aMS2);
+ //
+ iCntIn=0;
+ iCntOn=0;
+ iCntOut=0;
+ bFound=Standard_False;
+ aNbS2=aMS2.Extent();
+ for (i=1; i<=aNbS2; ++i) {
+ const TopoDS_Shape& aF2=aMS2(i);
//
- if (!iCntIn) {
- bFound=CheckCoincidence(aSo1, aSo2);
- if (myErrorStatus) {
- return;
- }
+ if (aMSIn.Contains(aF2)) {
+ ++iCntIn;
+ bFound=Standard_True;
+ break;
}
- if (bFound) {
- FillShapesIn(aSo1, aSo2);
+ else if (!aMSOn.Contains(aF2)) {
+ ++iCntOut;
+ bFound=Standard_False;// out
+ break;
}
- }// for (; myIterator.More(); myIterator.Next()) {
+ else {
+ ++iCntOn; //on
+ }
+ }
+ //
+ if (!bFound && iCntOut) {
+ return;
+ }
+ //
+ if (!iCntIn) {
+ bFound=CheckCoincidence(theSo1, theSo2);
+ if (myErrorStatus) {
+ return;
+ }
+ }
+ if (bFound) {
+ FillShapesIn(theSo1, theSo2);
+ }
}
//=======================================================================
//function : FillImages
//purpose :
//=======================================================================
-void GEOMAlgo_GetInPlace::FillImages()
+void GEOMAlgo_GetInPlace::FillImages(const TopoDS_Shape &theShape,
+ const Standard_Boolean IsWhere)
{
- Standard_Integer i, aNbS, aNbSx, aNbSi;
- TopAbs_ShapeEnum aType;
- TopoDS_Iterator aIt;
- TopTools_ListOfShape aLSx;
- TopTools_ListIteratorOfListOfShape aItLS;
- TopTools_IndexedMapOfShape aMS;
- TopTools_MapIteratorOfMapOfShape aItMS;
//
myErrorStatus=0;
myWarningStatus=0;
//
- myImages.Clear();
- //
// 1. Vertices
- aMS.Clear();
- TopExp::MapShapes(myArgument, TopAbs_VERTEX, aMS);
- aNbS=aMS.Extent();
- for (i=1; i<=aNbS; ++i) {
- const TopoDS_Shape& aV=aMS(i);
- if (myShapesOn.IsBound(aV)) {
- const TopTools_MapOfShape& aMSx=myShapesOn.Find(aV);
- aNbSx=aMSx.Extent();
- //
- aLSx.Clear();
- aItMS.Initialize(aMSx);
- for (; aItMS.More(); aItMS.Next()) {
- const TopoDS_Shape& aVx=aItMS.Key();
- aLSx.Append(aVx);
- }
- //
- myImages.Bind(aV, aLSx);
- }
- }
+ FillImgSimple(theShape, TopAbs_VERTEX, IsWhere);
//
// 2. Edges
- aMS.Clear();
- TopExp::MapShapes(myArgument, TopAbs_EDGE, aMS);
- aNbS=aMS.Extent();
- for (i=1; i<=aNbS; ++i) {
- const TopoDS_Shape& aE=aMS(i);
- if (myShapesIn.IsBound(aE)) {
- const TopTools_MapOfShape& aMSx=myShapesIn.Find(aE);
- aNbSx=aMSx.Extent();
- //
- aLSx.Clear();
- aItMS.Initialize(aMSx);
- for (; aItMS.More(); aItMS.Next()) {
- const TopoDS_Shape& aEx=aItMS.Key();
- aType=aEx.ShapeType();
- if (aType==TopAbs_EDGE){
- aLSx.Append(aEx);
- }
- }
- //
- myImages.Bind(aE, aLSx);
- }
- }
+ FillImgSimple(theShape, TopAbs_EDGE, IsWhere);
//
// 3. Wires
- aMS.Clear();
- TopExp::MapShapes(myArgument, TopAbs_WIRE, aMS);
- aNbS=aMS.Extent();
- for (i=1; i<=aNbS; ++i) {
- const TopoDS_Shape& aW=aMS(i);
- aLSx.Clear();
- aIt.Initialize(aW);
- for(; aIt.More(); aIt.Next()) {
- const TopoDS_Shape& aE=aIt.Value();
- if (myImages.IsBound(aE)) {
- const TopTools_ListOfShape& aLSi=myImages.Find(aE);
- aNbSi=aLSi.Extent();
- //
- aItLS.Initialize(aLSi);
- for (; aItLS.More(); aItLS.Next()) {
- const TopoDS_Shape& aEi=aItLS.Value();
- aLSx.Append(aEi);
- }
- }
- }
- myImages.Bind(aW, aLSx);
- }
+ FillImgComplex(theShape, TopAbs_WIRE, IsWhere);
//
// 4. Faces
- aMS.Clear();
- TopExp::MapShapes(myArgument, TopAbs_FACE, aMS);
- aNbS=aMS.Extent();
- for (i=1; i<=aNbS; ++i) {
- const TopoDS_Shape& aF=aMS(i);
- if (myShapesIn.IsBound(aF)) {
- const TopTools_MapOfShape& aMSx=myShapesIn.Find(aF);
- aNbSx=aMSx.Extent();
- //
- aLSx.Clear();
- aItMS.Initialize(aMSx);
- for (; aItMS.More(); aItMS.Next()) {
- const TopoDS_Shape& aFx=aItMS.Key();
- aType=aFx.ShapeType();
- if (aType==TopAbs_FACE){
- aLSx.Append(aFx);
- }
- }
- //
- myImages.Bind(aF, aLSx);
- }
- }
+ FillImgSimple(theShape, TopAbs_FACE, IsWhere);
//
// 5. Shells
- aMS.Clear();
- TopExp::MapShapes(myArgument, TopAbs_SHELL, aMS);
- aNbS=aMS.Extent();
- for (i=1; i<=aNbS; ++i) {
- const TopoDS_Shape& aSh=aMS(i);
- aLSx.Clear();
- aIt.Initialize(aSh);
- for(; aIt.More(); aIt.Next()) {
- const TopoDS_Shape& aF=aIt.Value();
- if (myImages.IsBound(aF)) {
- const TopTools_ListOfShape& aLSi=myImages.Find(aF);
- aNbSi=aLSi.Extent();
- //
- aItLS.Initialize(aLSi);
- for (; aItLS.More(); aItLS.Next()) {
- const TopoDS_Shape& aFi=aItLS.Value();
- aLSx.Append(aFi);
- }
- }
- }
- myImages.Bind(aSh, aLSx);
- }
+ FillImgComplex(theShape, TopAbs_SHELL, IsWhere);
//
// 6. Solids
- aMS.Clear();
- TopExp::MapShapes(myArgument, TopAbs_SOLID, aMS);
- aNbS=aMS.Extent();
- for (i=1; i<=aNbS; ++i) {
- const TopoDS_Shape& aZ=aMS(i);
- if (myShapesIn.IsBound(aZ)) {
- const TopTools_MapOfShape& aMSx=myShapesIn.Find(aZ);
- aNbSx=aMSx.Extent();
- //
- aLSx.Clear();
- aItMS.Initialize(aMSx);
- for (; aItMS.More(); aItMS.Next()) {
- const TopoDS_Shape& aZx=aItMS.Key();
- aType=aZx.ShapeType();
- if (aType==TopAbs_SOLID){
- aLSx.Append(aZx);
- }
- }
- //
- myImages.Bind(aZ, aLSx);
- }
- }
+ FillImgSimple(theShape, TopAbs_SOLID, IsWhere);
//
// 7. CompSolids
- aMS.Clear();
- TopExp::MapShapes(myArgument, TopAbs_COMPSOLID, aMS);
- aNbS=aMS.Extent();
- for (i=1; i<=aNbS; ++i) {
- const TopoDS_Shape& aCs=aMS(i);
- aLSx.Clear();
- aIt.Initialize(aCs);
- for(; aIt.More(); aIt.Next()) {
- const TopoDS_Shape& aZ=aIt.Value();
- if (myImages.IsBound(aZ)) {
- const TopTools_ListOfShape& aLSi=myImages.Find(aZ);
- aNbSi=aLSi.Extent();
- //
- aItLS.Initialize(aLSi);
- for (; aItLS.More(); aItLS.Next()) {
- const TopoDS_Shape& aZi=aItLS.Value();
- aLSx.Append(aZi);
+ FillImgComplex(theShape, TopAbs_COMPSOLID, IsWhere);
+ //
+ // 8. Compounds
+ const TopAbs_ShapeEnum aType = theShape.ShapeType();
+
+ if (aType == TopAbs_COMPOUND) {
+ FillImgComplex(theShape, IsWhere);
+ }
+}
+
+//=======================================================================
+//function : FillImgSimple
+//purpose :
+//=======================================================================
+void GEOMAlgo_GetInPlace::FillImgSimple
+ (const TopoDS_Shape &theShape,
+ const TopAbs_ShapeEnum theSubShapeType,
+ const Standard_Boolean IsWhere)
+{
+ TopTools_IndexedMapOfShape aMS;
+
+ TopExp::MapShapes(theShape, theSubShapeType, aMS);
+
+ Standard_Integer i;
+ const Standard_Integer aNbS = aMS.Extent();
+ const GEOMAlgo_DataMapOfShapeMapOfShape &aShapesInOn =
+ (theSubShapeType == TopAbs_VERTEX ? myShapesOn : myShapesIn);
+
+ for (i = 1; i <= aNbS; i++) {
+ const TopoDS_Shape& aS = aMS(i);
+
+ if (aShapesInOn.IsBound(aS)) {
+ const TopTools_MapOfShape& aMSx = aShapesInOn.Find(aS);
+ TopTools_ListOfShape aLSx;
+ TopTools_MapIteratorOfMapOfShape aItMS(aMSx);
+
+ for (; aItMS.More(); aItMS.Next()) {
+ const TopoDS_Shape& aSx = aItMS.Key();
+ TopAbs_ShapeEnum aType = aSx.ShapeType();
+
+ if (aType == theSubShapeType){
+ aLSx.Append(aSx);
+
+ if (IsWhere) {
+ myShapesInclusive.Bind(aSx, aS);
+ }
}
}
+
+ myImages.Bind(aS, aLSx);
}
- myImages.Bind(aCs, aLSx);
- }
- //
- // 8. Compounds
- aType=myArgument.ShapeType();
- if (aType==TopAbs_COMPOUND) {
- FillImagesCompound(myArgument);
}
}
+
//=======================================================================
-//function : FillImagesCompound
+//function : FillImgComplex
//purpose :
//=======================================================================
-void GEOMAlgo_GetInPlace::FillImagesCompound(const TopoDS_Shape& aS)
+void GEOMAlgo_GetInPlace::FillImgComplex(const TopoDS_Shape &theShape,
+ const Standard_Boolean IsWhere)
{
- TopAbs_ShapeEnum aType;
- TopoDS_Iterator aIt;
+ TopTools_MapOfShape aMapRemaining;
+ TopoDS_Iterator aIt(theShape);
TopTools_ListOfShape aLSx;
- TopTools_ListIteratorOfListOfShape aItLS;
- //
- aIt.Initialize(aS);
+ TopTools_MapOfShape aMSx;
+
for(; aIt.More(); aIt.Next()) {
- const TopoDS_Shape& aSx=aIt.Value();
- aType=aSx.ShapeType();
- //
- if (aType==TopAbs_COMPOUND) {
- FillImagesCompound(aSx);
+ const TopoDS_Shape &aSubS = aIt.Value();
+ TopAbs_ShapeEnum aType = aSubS.ShapeType();
+
+ if (aType == TopAbs_COMPOUND) {
+ // Recursively treat compounds.
+ FillImgComplex(aSubS, IsWhere);
}
- //
- if (myImages.IsBound(aSx)) {
- const TopTools_ListOfShape& aLSi=myImages.Find(aSx);
- aItLS.Initialize(aLSi);
+
+ if (myImages.IsBound(aSubS)) {
+ const TopTools_ListOfShape& aLSi = myImages.Find(aSubS);
+ TopTools_ListIteratorOfListOfShape aItLS(aLSi);
+
for (; aItLS.More(); aItLS.Next()) {
- const TopoDS_Shape& aSi=aItLS.Value();
- aLSx.Append(aSi);
+ const TopoDS_Shape &aSubSi = aItLS.Value();
+
+ if (aMSx.Add(aSubSi)) {
+ aLSx.Append(aSubSi);
+ }
}
+ } else if (!IsWhere) {
+ aMapRemaining.Add(aSubS);
}
}
- myImages.Bind(aS, aLSx);
+
+ if (!(IsWhere || aMapRemaining.IsEmpty())) {
+ // Find the whole from parts.
+ while (!aMapRemaining.IsEmpty()) {
+ TopTools_MapIteratorOfMapOfShape anIter(aMapRemaining);
+ const TopoDS_Shape &aShape = anIter.Key();
+
+ if (myShapesInclusive.IsBound(aShape)) {
+ // This "what" shape is inclusive to the "where" shape.
+ // Get the other inclusive shapes.
+ const TopoDS_Shape &aSWhere = myShapesInclusive.Find(aShape);
+
+ if (myImages.IsBound(aSWhere)) {
+ // Remove inclusive shapes from aMapRemaining.
+ const TopTools_ListOfShape& aLWhat = myImages.Find(aSWhere);
+ TopTools_ListIteratorOfListOfShape aItLS(aLWhat);
+
+ for (; aItLS.More(); aItLS.Next()) {
+ const TopoDS_Shape &aSWhat = aItLS.Value();
+
+ aMapRemaining.Remove(aSWhat);
+ }
+
+ // Add "whole" shape to the list of images.
+ if (aMSx.Add(aSWhere)) {
+ aLSx.Append(aSWhere);
+ }
+ }
+ } else {
+ // This "what" shape is not inclusive to the "where" shape. Skip it.
+ aMapRemaining.Remove(aShape);
+ }
+ }
+ }
+
+ myImages.Bind(theShape, aLSx);
+}
+
+//=======================================================================
+//function : FillImgComplex
+//purpose :
+//=======================================================================
+void GEOMAlgo_GetInPlace::FillImgComplex
+ (const TopoDS_Shape &theShape,
+ const TopAbs_ShapeEnum theSubShapeType,
+ const Standard_Boolean IsWhere)
+{
+ TopTools_IndexedMapOfShape aMS;
+
+ TopExp::MapShapes(theShape, theSubShapeType, aMS);
+
+ Standard_Integer i;
+ const Standard_Integer aNbS = aMS.Extent();
+
+ for (i=1; i<=aNbS; ++i) {
+ const TopoDS_Shape &aS = aMS(i);
+
+ FillImgComplex(aS, IsWhere);
+ }
}
//=======================================================================
myShapesOn.Bind(aS1, aMS);
}
}
+
//=======================================================================
//function : MapBRepShapes
//purpose :
MapBRepShapes(aSx, aM);
}
}
+//=======================================================================
+//function : Result
+//purpose :
+//=======================================================================
+const TopoDS_Shape &GEOMAlgo_GetInPlace::Result()
+{
+ TopoDS_Shape aDummy;
+ //
+ myResult = aDummy;
+ //
+ Standard_Boolean bFound;
+ TopoDS_Compound aC;
+ BRep_Builder aBB;
+ TopTools_ListIteratorOfListOfShape aItLS;
+ //
+ bFound=myImages.IsBound(myArgument);
+ if (!bFound) {
+ return myResult;
+ }
+ //
+ aBB.MakeCompound(aC);
+ //
+ const TopTools_ListOfShape& aLS=myImages.Find(myArgument);
+ aItLS.Initialize(aLS);
+ for (; aItLS.More(); aItLS.Next()) {
+ const TopoDS_Shape& aSD=aItLS.Value();
+ aBB.Add(aC, aSD);
+ }
+ //
+ myResult = aC;
+ return myResult;
+}
#include <BRep_Builder.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_MapIteratorOfMapOfShape.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
//=======================================================================
void GEOMAlgo_GetInPlace::CheckGProps()
{
- myFound=Standard_False;
+ myFound=Standard_True;
CheckGProps(myArgument);
}
//=======================================================================
//function : CheckGProps
//purpose :
//=======================================================================
-void GEOMAlgo_GetInPlace::CheckGProps(const TopoDS_Shape& aS1)
+Standard_Integer GEOMAlgo_GetInPlace::CheckGProps(const TopoDS_Shape& theS)
{
- Standard_Boolean bOnlyClosed;
- Standard_Integer iDim, aNbS2;
- Standard_Real aMass1, aMass2, aD2, aTolCG2, dM;
- TopAbs_ShapeEnum aType1;
- gp_Pnt aCG1, aCG2;
- TopoDS_Iterator aIt;
- TopoDS_Compound aC2;
- BRep_Builder aBB;
- TopTools_ListIteratorOfListOfShape aItLS;
- //
- myErrorStatus=0;
- //
- aType1=aS1.ShapeType();
- if (aType1==TopAbs_COMPOUND) {
- aIt.Initialize(aS1);
- for(; aIt.More(); aIt.Next()) {
- const TopoDS_Shape& aS1x=aIt.Value();
- CheckGProps(aS1x);
- if (!myFound) {
- return;
+ TopAbs_ShapeEnum aType = theS.ShapeType();
+
+ if (aType == TopAbs_COMPOUND) {
+ TopoDS_Iterator anIt(theS);
+ TopTools_MapOfShape aMapInc;
+
+ for(; anIt.More(); anIt.Next()) {
+ const TopoDS_Shape &aS1x = anIt.Value();
+
+ aType = aS1x.ShapeType();
+
+ if (aType != TopAbs_COMPOUND && myShapesInclusive.IsBound(aS1x)) {
+ // This is a part of a whole.
+ aMapInc.Add(aS1x);
+ } else {
+ // Check this subshape.
+ const Standard_Integer iFound = CheckGProps(aS1x);
+
+ if (!iFound) {
+ UpdateChecked(theS, 0);
+ myFound = Standard_False;
+ return 0;
+ }
}
}
+
+ // Treat parts of a whole.
+ while (!aMapInc.IsEmpty()) {
+ TopTools_MapIteratorOfMapOfShape aMapIt(aMapInc);
+ const TopoDS_Shape &aWhole = myShapesInclusive.Find(aMapIt.Key());
+
+ if (!myImages.IsBound(aWhole)) {
+ // Should not be.
+ UpdateChecked(theS, 0);
+ myFound = Standard_False;
+ return 0;
+ }
+
+ const TopTools_ListOfShape& aLS1 = myImages.Find(aWhole);
+
+ if (aLS1.IsEmpty()) {
+ // Empty list of parts. Should not be.
+ UpdateChecked(theS, 0);
+ myFound = Standard_False;
+ return 0;
+ }
+
+ TopTools_ListIteratorOfListOfShape aItS1x(aLS1);
+
+ for (; aItS1x.More(); aItS1x.Next()) {
+ const TopoDS_Shape &aS1x = aItS1x.Value();
+
+ if (!aMapInc.Remove(aS1x)) {
+ // There is no aS1x in theS. Should not be.
+ UpdateChecked(theS, 0);
+ myFound = Standard_False;
+ return 0;
+ }
+ }
+
+ // Compare a shape with an image.
+ if (!CompareGProps(aWhole, aLS1)) {
+ // Image doesn't correspond to the shape.
+ UpdateChecked(theS, 0);
+ myFound = Standard_False;
+ return 0;
+ }
+ }
+
+ return myFound ? 1 : 0;
}
- //
- iDim=Dimension(aType1);
- //
- if (!myImages.IsBound(aS1)) {
+
+ // Check the simple shape.
+ if (!myImages.IsBound(theS)) {
// it should not be.
- return;
+ UpdateChecked(theS, 0);
+ myFound = Standard_False;
+ return 0;
}
- const TopTools_ListOfShape& aLS2=myImages.Find(aS1);
- aNbS2=aLS2.Extent();
- if (!aNbS2) {
+ //
+ const TopTools_ListOfShape &aLS2 = myImages.Find(theS);
+
+ if (aLS2.IsEmpty()) {
// it should not be.
- return;
+ UpdateChecked(theS, 0);
+ myFound = Standard_False;
+ return 0;
}
+
+ // Compare a shape with an image.
+ if (!CompareGProps(theS, aLS2)) {
+ // Image doesn't correspond to the shape.
+ UpdateChecked(theS, 0);
+ myFound = Standard_False;
+ return 0;
+ }
+
+ UpdateChecked(theS, 1);
//
- aBB.MakeCompound(aC2);
- aItLS.Initialize(aLS2);
- for (; aItLS.More(); aItLS.Next()) {
- const TopoDS_Shape& aS2x=aItLS.Value();
- aBB.Add(aC2, aS2x);
- }
- //-------------------------
- GProp_GProps aG1, aG2;
- //
- aTolCG2=myTolCG*myTolCG;
- bOnlyClosed=Standard_False;
- //
- if (iDim==0) {
- PointProperties(aS1, aG1);
- PointProperties(aC2, aG2);
+ return 1;
+}
+
+//=======================================================================
+//function : CompareGProps
+//purpose :
+//=======================================================================
+Standard_Boolean GEOMAlgo_GetInPlace::CompareGProps
+ (const TopoDS_Shape &theShape1,
+ const TopTools_ListOfShape &theListShape2) const
+{
+ Standard_Boolean aResult = Standard_True;
+ TopoDS_Compound aComp2;
+ BRep_Builder aBuilder;
+ TopTools_ListIteratorOfListOfShape anIt(theListShape2);
+
+ aBuilder.MakeCompound(aComp2);
+
+ for (; anIt.More(); anIt.Next()) {
+ const TopoDS_Shape &aShape2 = anIt.Value();
+
+ aBuilder.Add(aComp2, aShape2);
}
- else if (iDim==1) {
- BRepGProp::LinearProperties(aS1, aG1);
- BRepGProp::LinearProperties(aC2, aG2);
+
+ // Compute General Properties.
+ GProp_GProps aG1;
+ GProp_GProps aG2;
+ const Standard_Real aTolCG2 = myTolCG*myTolCG;
+ Standard_Boolean bOnlyClosed = Standard_False;
+ const TopAbs_ShapeEnum aType = theShape1.ShapeType();
+ const Standard_Integer iDim = Dimension(aType);
+
+ if (iDim == 0) {
+ PointProperties(theShape1, aG1);
+ PointProperties(aComp2, aG2);
}
- else if (iDim==2) {
- BRepGProp::SurfaceProperties(aS1, aG1);
- BRepGProp::SurfaceProperties(aC2, aG2);
+ else if (iDim == 1) {
+ BRepGProp::LinearProperties(theShape1, aG1);
+ BRepGProp::LinearProperties(aComp2, aG2);
}
- else if (iDim==3) {
- BRepGProp::VolumeProperties(aS1, aG1, bOnlyClosed);
- BRepGProp::VolumeProperties(aC2, aG2, bOnlyClosed);
+ else if (iDim == 2) {
+ BRepGProp::SurfaceProperties(theShape1, aG1);
+ BRepGProp::SurfaceProperties(aComp2, aG2);
}
- //
- aMass1=aG1.Mass();
- aMass2=aG2.Mass();
- aCG1=aG1.CentreOfMass();
- aCG2=aG2.CentreOfMass();
- //
- dM=fabs(aMass1-aMass2);
+ else if (iDim == 3) {
+ BRepGProp::VolumeProperties(theShape1, aG1, bOnlyClosed);
+ BRepGProp::VolumeProperties(aComp2, aG2, bOnlyClosed);
+ } else {
+ return Standard_False;
+ }
+
+ // Compare properties.
+ const Standard_Real aMass1 = aG1.Mass();
+ const Standard_Real aMass2 = aG2.Mass();
+ const gp_Pnt aCG1 = aG1.CentreOfMass();
+ const gp_Pnt aCG2 = aG2.CentreOfMass();
+ Standard_Real aDM = fabs(aMass1 - aMass2);
+ const Standard_Real aD2 = aCG1.SquareDistance(aCG2);
+
if (aMass1 > myTolMass) {
- dM=dM/aMass1;
+ aDM /= aMass1;
}
- //
- aD2=aCG1.SquareDistance(aCG2);
- //
- if ((dM > myTolMass) || (aD2 > aTolCG2)) {
- myFound=Standard_False;
- return;
+
+ if ((aDM > myTolMass) || (aD2 > aTolCG2)) {
+ aResult = Standard_False;
+ }
+
+ return aResult;
+}
+
+//=======================================================================
+//function : UpdateChecked
+//purpose :
+//=======================================================================
+void GEOMAlgo_GetInPlace::UpdateChecked(const TopoDS_Shape& theS1,
+ const Standard_Integer theFlag)
+{
+ if (myChecked.IsBound(theS1)) {
+ Standard_Integer& iChecked=myChecked.ChangeFind(theS1);
+ iChecked=theFlag;
+ }
+ else {
+ myChecked.Bind(theS1, theFlag);
}
- myFound=Standard_True;
}
//=======================================================================
//function : Dimension