Update for new version of PartitionAlgo (unstable order of shapes in result).

This commit is contained in:
skl 2006-11-14 12:32:59 +00:00
parent 45553ea796
commit d3c5560ecd
2 changed files with 96 additions and 76 deletions

View File

@ -52,21 +52,25 @@
//======================================================================= //=======================================================================
void GEOMAlgo_ShapeSet::Add(const TopoDS_Shape& theShape) void GEOMAlgo_ShapeSet::Add(const TopoDS_Shape& theShape)
{ {
myMap.Add(theShape); if (myMap.Add(theShape)) {
myList.Append(theShape);
}
} }
//======================================================================= //=======================================================================
//function : Add //function : Add
//purpose : //purpose :
//======================================================================= //=======================================================================
void GEOMAlgo_ShapeSet::Add(const TopoDS_Shape& theShape, void GEOMAlgo_ShapeSet::Add(const TopoDS_Shape& theShape,
const TopAbs_ShapeEnum theType) const TopAbs_ShapeEnum theType)
{ {
TopExp_Explorer aExp; TopExp_Explorer aExp;
// //
aExp.Init(theShape, theType); aExp.Init(theShape, theType);
for (; aExp.More(); aExp.Next()) { for (; aExp.More(); aExp.Next()) {
const TopoDS_Shape& aS=aExp.Current(); const TopoDS_Shape& aS=aExp.Current();
myMap.Add(aS); if (myMap.Add(aS)) {
myList.Append(aS);
}
} }
} }
//======================================================================= //=======================================================================
@ -79,7 +83,10 @@
// //
aIt.Initialize(theLS); aIt.Initialize(theLS);
for (; aIt.More(); aIt.Next()) { for (; aIt.More(); aIt.Next()) {
myMap.Add(aIt.Value()); const TopoDS_Shape& aS=aIt.Value();
if (myMap.Add(aS)) {
myList.Append(aS);
}
} }
} }
//======================================================================= //=======================================================================
@ -88,6 +95,7 @@
//======================================================================= //=======================================================================
const TopTools_ListOfShape& GEOMAlgo_ShapeSet::GetSet()const const TopTools_ListOfShape& GEOMAlgo_ShapeSet::GetSet()const
{ {
/*
TopTools_ListOfShape *pL; TopTools_ListOfShape *pL;
TopTools_MapIteratorOfMapOfOrientedShape aIt; TopTools_MapIteratorOfMapOfOrientedShape aIt;
// //
@ -97,6 +105,7 @@
for (; aIt.More(); aIt.Next()) { for (; aIt.More(); aIt.Next()) {
pL->Append(aIt.Key()); pL->Append(aIt.Key());
} }
*/
return myList; return myList;
} }
//======================================================================= //=======================================================================
@ -115,7 +124,7 @@
for (; aIt.More(); aIt.Next()) { for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aF=aIt.Value(); const TopoDS_Shape& aF=aIt.Value();
aOr=aF.Orientation(); aOr=aF.Orientation();
if (aOr==TopAbs_FORWARD||aOr==TopAbs_REVERSED) { if (aOr==TopAbs_FORWARD || aOr==TopAbs_REVERSED) {
bRet=myMap.Contains(aF); bRet=myMap.Contains(aF);
if (!bRet) { if (!bRet) {
break; break;
@ -130,6 +139,7 @@
//======================================================================= //=======================================================================
void GEOMAlgo_ShapeSet::Subtract(const GEOMAlgo_ShapeSet& theOther) void GEOMAlgo_ShapeSet::Subtract(const GEOMAlgo_ShapeSet& theOther)
{ {
/*
TopTools_MapIteratorOfMapOfOrientedShape aIt; TopTools_MapIteratorOfMapOfOrientedShape aIt;
// //
aIt.Initialize(theOther.myMap); aIt.Initialize(theOther.myMap);
@ -137,4 +147,21 @@
const TopoDS_Shape& aS=aIt.Key(); const TopoDS_Shape& aS=aIt.Key();
myMap.Remove(aS); myMap.Remove(aS);
} }
*/
//
TopTools_ListIteratorOfListOfShape aIt;
TopTools_ListOfShape aLS;
//
myMap.Clear();
aIt.Initialize(myList);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aS=aIt.Value();
if (!theOther.myMap.Contains(aS)) {
if(myMap.Add(aS)){
aLS.Append(aS);
}
}
}
//
myList=aLS;
} }

View File

@ -53,12 +53,6 @@
#include <GEOMAlgo_WireSplitter.hxx> #include <GEOMAlgo_WireSplitter.hxx>
static
void Path(const TopoDS_Shape& aV1,
const TopTools_IndexedDataMapOfShapeListOfShape& aMVE,
TopTools_MapOfShape& aMVP,
TopTools_MapOfShape& aMEP,
TopTools_MapOfShape& aMEC);
static static
void MakeWire(const TopTools_ListOfShape& aLE, void MakeWire(const TopTools_ListOfShape& aLE,
TopoDS_Wire& newWire); TopoDS_Wire& newWire);
@ -122,20 +116,21 @@ static
void GEOMAlgo_WESCorrector::DoConnexityBlocks() void GEOMAlgo_WESCorrector::DoConnexityBlocks()
{ {
Standard_Boolean bRegular; Standard_Boolean bRegular;
Standard_Integer i, aNbV; Standard_Integer i, aNbV, j, aNbC, aNbVP, aNbVS;
TopTools_ListIteratorOfListOfShape aIt; TopTools_ListIteratorOfListOfShape aIt;
TopoDS_Iterator aItE; TopoDS_Iterator aItE;
TopoDS_Shape aER; TopoDS_Shape aER;
TopTools_MapOfShape aMER, aMEP, aMEC, aMVP; TopTools_IndexedMapOfShape aMER, aMEP, aMEC, aMVP;
TopTools_MapIteratorOfMapOfShape aItM; TopTools_IndexedMapOfShape aMVS, aMVAdd;
TopTools_IndexedDataMapOfShapeListOfShape aMVE; TopTools_IndexedDataMapOfShapeListOfShape aMVE;
// //
// 1. aMVE; // 1. aMVE;
const TopTools_ListOfShape& aLE=myWES->StartElements(); const TopTools_ListOfShape& aLSE=myWES->StartElements();
aIt.Initialize(aLE); aIt.Initialize(aLSE);
for (; aIt.More(); aIt.Next()) { for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aE=aIt.Value(); const TopoDS_Shape& aE=aIt.Value();
if (aMEP.Add(aE)) { if (!aMEP.Contains(aE)) {
aMEP.Add(aE);
TopExp::MapShapesAndAncestors(aE, TopAbs_VERTEX, TopAbs_EDGE, aMVE); TopExp::MapShapesAndAncestors(aE, TopAbs_VERTEX, TopAbs_EDGE, aMVE);
} }
else { else {
@ -143,42 +138,74 @@ static
} }
} }
// //
aMEP.Clear();
//
// 2. // 2.
aNbV=aMVE.Extent(); aNbV=aMVE.Extent();
for (i=1; i<=aNbV; ++i) { for (i=1; i<=aNbV; ++i) {
const TopoDS_Shape& aV=aMVE.FindKey(i); const TopoDS_Shape& aV=aMVE.FindKey(i);
if (aMVP.Contains(aV)) { //
aNbVS=aMVS.Extent();
if (aNbVS==aNbV) {
break;
}
//
if (aMVS.Contains(aV)) {
continue; continue;
} }
aMVS.Add(aV); // aMVS - globally processed vertices
//
//------------------------------------- goal: aMEC
aMEC.Clear(); // aMEC - edges of CB
aMVP.Clear(); // aMVP - vertices to process right now
aMVAdd.Clear(); // aMVAdd vertices to process on next step of while(1)
//
aMVP.Add(aV); aMVP.Add(aV);
// //
const TopTools_ListOfShape& aLEi=aMVE(i); while(1) {
aIt.Initialize(aLEi); aNbVP=aMVP.Extent();
for (; aIt.More(); aIt.Next()) { for (j=1; j<=aNbVP; ++j) {
const TopoDS_Shape& aE=aIt.Value(); const TopoDS_Shape& aVP=aMVP(j);
if (aMEP.Contains(aE)) { const TopTools_ListOfShape& aLE=aMVE.FindFromKey(aVP);
continue; aIt.Initialize(aLE);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aE=aIt.Value();
if (aMEC.Contains(aE)) {
continue;
}
aMEC.Add(aE);
//
aItE.Initialize(aE);
for (; aItE.More(); aItE.Next()) {
const TopoDS_Shape& aVE=aItE.Value();
if (!aMVS.Contains(aVE)) {
aMVS.Add(aVE);
aMVAdd.Add(aVE);
}
}
}
}//for (j=1; j<=aNbVP; ++j)
//
aNbVP=aMVAdd.Extent();
if (!aNbVP) {
break; // from while(1)
} }
// //
aMEP.Add(aE); aMVP.Clear();
aMEC.Add(aE); for (j=1; j<=aNbVP; ++j) {
aItE.Initialize(aE); const TopoDS_Shape& aVE=aMVAdd(j);
for (; aItE.More(); aItE.Next()) { aMVP.Add(aVE);
const TopoDS_Shape& aVE=aItE.Value();
Path(aVE, aMVE, aMVP, aMEP, aMEC);
} }
}//for (; aIt.More(); aIt.Next()) { aMVAdd.Clear();
// }// while(1) {
//-------------------------------------
BOP_ConnexityBlock aCB; BOP_ConnexityBlock aCB;
TopTools_ListOfShape aLEC; TopTools_ListOfShape aLEC;
TopTools_IndexedDataMapOfShapeListOfShape aMVER; TopTools_IndexedDataMapOfShapeListOfShape aMVER;
// //
bRegular=Standard_True; bRegular=Standard_True;
aItM.Initialize(aMEC);
for (; aItM.More(); aItM.Next()) { aNbC=aMEC.Extent();
aER=aItM.Key(); for (j=1; j<=aNbC; ++j) {
aER=aMEC(j);
// //
if (aMER.Contains(aER)) { if (aMER.Contains(aER)) {
Standard_Boolean bClosed; Standard_Boolean bClosed;
@ -200,14 +227,14 @@ static
if (bRegular) { if (bRegular) {
TopExp::MapShapesAndAncestors(aER, TopAbs_VERTEX, TopAbs_EDGE, aMVER); TopExp::MapShapesAndAncestors(aER, TopAbs_VERTEX, TopAbs_EDGE, aMVER);
} }
} }//for (j=1; j<=aNbC; ++j) {
// //
if (bRegular) { if (bRegular) {
Standard_Integer j, aNbVR, aNbER; Standard_Integer k, aNbVR, aNbER;
// //
aNbVR=aMVER.Extent(); aNbVR=aMVER.Extent();
for (j=1; j<=aNbVR; ++j) { for (k=1; k<=aNbVR; ++k) {
const TopTools_ListOfShape& aLER=aMVE(j); const TopTools_ListOfShape& aLER=aMVER(k);//?? it was aMVE(k)
aNbER=aLER.Extent(); aNbER=aLER.Extent();
if (aNbER==1) { if (aNbER==1) {
const TopoDS_Edge& aEx=TopoDS::Edge(aER); const TopoDS_Edge& aEx=TopoDS::Edge(aER);
@ -229,41 +256,7 @@ static
aMEC.Clear(); aMEC.Clear();
}//for (i=1; i<=aNbV; ++i) { }//for (i=1; i<=aNbV; ++i) {
} }
//=======================================================================
// function: Path
// purpose:
//=======================================================================
void Path(const TopoDS_Shape& aV1,
const TopTools_IndexedDataMapOfShapeListOfShape& aMVE,
TopTools_MapOfShape& aMVP,
TopTools_MapOfShape& aMEP,
TopTools_MapOfShape& aMEC)
{
TopoDS_Iterator aItE;
TopTools_ListIteratorOfListOfShape aIt;
//
if (aMVP.Contains(aV1)) {
return;
}
aMVP.Add(aV1);
//
const TopTools_ListOfShape& aLE=aMVE.FindFromKey(aV1);
aIt.Initialize(aLE);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aE=aIt.Value();
if (aMEP.Contains(aE)) {
continue;
}
aMEP.Add(aE);
aMEC.Add(aE);
//
aItE.Initialize(aE);
for (; aItE.More(); aItE.Next()) {
const TopoDS_Shape& aVE=aItE.Value();
Path(aVE, aMVE, aMVP, aMEP, aMEC);
}
}
}
//======================================================================= //=======================================================================
// function: DoCorrections // function: DoCorrections
// purpose: // purpose: