#include <Bnd_Box.hxx>
+#include <BRep_TVertex.hxx>
+#include <BRep_Tool.hxx>
+
+#include <TopoDS.hxx>
#include <TopoDS_Vertex.hxx>
#include <BRepBndLib.hxx>
// function: PerformVV
// purpose:
//=======================================================================
-void BOPAlgo_PaveFiller::PerformVV()
+ void BOPAlgo_PaveFiller::PerformVV()
{
Standard_Boolean bWithSubShape;
- Standard_Integer n1, n2, iFlag, nX, n, aSize, i, j, iX, k, aNbBlocks;
+ Standard_Integer n1, n2, iFlag, aSize, k, aNbBlocks;
Handle(NCollection_IncAllocator) aAllocator;
- //BOPCol_DataMapIteratorOfDataMapOfIntegerListOfInteger aItMILI;
- BOPCol_ListIteratorOfListOfInteger aItLI, aItLI2;
- TopoDS_Vertex aVn;
- BOPDS_ShapeInfo aSIn;
//
myErrorStatus=0;
//
return;
}
//
- aSIn.SetShapeType(TopAbs_VERTEX);
-
BOPDS_VectorOfInterfVV& aVVs=myDS->InterfVV();
aVVs.SetStartSize(aSize);
aVVs.SetIncrement(aSize);
aAllocator=new NCollection_IncAllocator();
BOPCol_IndexedDataMapOfIntegerListOfInteger aMILI(100, aAllocator);
BOPCol_DataMapOfIntegerListOfInteger aMBlocks(100, aAllocator);
- BOPCol_ListOfShape aLV(aAllocator);
//
// 1. Map V/LV
for (; myIterator->More(); myIterator->Next()) {
for (k=0; k<aNbBlocks; ++k) {
const BOPCol_ListOfInteger& aLI=aMBlocks.Find(k);
//
- aLV.Clear();
- aItLI.Initialize(aLI);
- for (; aItLI.More(); aItLI.Next()) {
- nX=aItLI.Value();
- const TopoDS_Shape& aV=myDS->Shape(nX);
- aLV.Append(aV);
- }
- //
- BOPTools_AlgoTools::MakeVertex(aLV, aVn);
- //
- // Append new vertex to the DS
- aSIn.SetShape(aVn);
- n=myDS->Append(aSIn);
- //
- BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(n);
- Bnd_Box& aBox=aSIDS.ChangeBox();
- BRepBndLib::Add(aVn, aBox);
- //
- // Fill ShapesSD
- aItLI.Initialize(aLI);
- for (i=0; aItLI.More(); aItLI.Next(), ++i) {
- n1=aItLI.Value();
- myDS->AddShapeSD(n1, n);
- //
- aItLI2.Initialize(aLI);
- for (j=0; aItLI2.More(); aItLI2.Next(), ++j) {
- if (j>i) {
- n2=aItLI2.Value();
- //
- myDS->AddInterf(n1, n2);
- iX=aVVs.Append()-1;
- BOPDS_InterfVV& aVV=aVVs(iX);
- aVV.SetIndices(n1, n2);
- aVV.SetIndexNew(n);
- }
- }
- }
+ MakeSDVertices(aLI);
}
//
BOPCol_DataMapIteratorOfDataMapOfIntegerInteger aItDMII;
}
//
//-----------------------------------------------------scope t
- aLV.Clear();
aMBlocks.Clear();
aMILI.Clear();
aAllocator.Nullify();
+}
+ //=======================================================================
+// function: MakeSDVertices
+// purpose:
+//=======================================================================
+Standard_Integer BOPAlgo_PaveFiller::MakeSDVertices
+ (const BOPCol_ListOfInteger& theVertIndices,
+ const Standard_Boolean theAddInterfs)
+{
+ TopoDS_Vertex aVSD, aVn;
+ Standard_Integer nSD = -1;
+ BOPCol_ListIteratorOfListOfInteger aItLI(theVertIndices);
+ BOPCol_ListOfShape aLV;
+ for (; aItLI.More(); aItLI.Next()) {
+ Standard_Integer nX = aItLI.Value(), nSD1;
+ if (myDS->HasShapeSD(nX, nSD1)) {
+ const TopoDS_Shape& aVSD1 = myDS->Shape(nSD1);
+ if (nSD == -1) {
+ aVSD = TopoDS::Vertex(aVSD1);
+ nSD = nSD1;
+ }
+ else {
+ aLV.Append(aVSD1);
+ }
+ }
+ const TopoDS_Shape& aV = myDS->Shape(nX);
+ aLV.Append(aV);
+ }
+ BOPTools_AlgoTools::MakeVertex(aLV, aVn);
+ Standard_Integer nV;
+ if (nSD != -1) {
+ // update old SD vertex with new value
+ Handle(BRep_TVertex)& aTVertex =
+ reinterpret_cast<Handle(BRep_TVertex)&>(const_cast<Handle(TopoDS_TShape)&>(aVSD.TShape()));
+ aTVertex->Pnt(BRep_Tool::Pnt(aVn));
+ aTVertex->Tolerance(BRep_Tool::Tolerance(aVn));
+ aVn = aVSD;
+ nV = nSD;
+ }
+ else {
+ // Append new vertex to the DS
+ BOPDS_ShapeInfo aSIn;
+ aSIn.SetShapeType(TopAbs_VERTEX);
+ aSIn.SetShape(aVn);
+ nV = myDS->Append(aSIn);
+ }
+ BOPDS_ShapeInfo& aSIDS = myDS->ChangeShapeInfo(nV);
+ Bnd_Box& aBox = aSIDS.ChangeBox();
+ BRepBndLib::Add(aVn, aBox);
+ aBox.SetGap(aBox.GetGap());
+ //
+ // Fill ShapesSD
+ BOPDS_VectorOfInterfVV& aVVs = myDS->InterfVV();
+ if (theAddInterfs)
+ aVVs.SetIncrement(theVertIndices.Extent());
+ //
+ aItLI.Initialize(theVertIndices);
+ for (; aItLI.More(); aItLI.Next()) {
+ Standard_Integer n1 = aItLI.Value();
+ myDS->AddShapeSD(n1, nV);
+ //
+ if (theAddInterfs) {
+ BOPCol_ListIteratorOfListOfInteger aItLI2 = aItLI;
+ aItLI2.Next();
+ for (; aItLI2.More(); aItLI2.Next()) {
+ Standard_Integer n2 = aItLI2.Value();
+ //
+ myDS->AddInterf(n1, n2);
+ //
+ Standard_Integer iX = aVVs.Append() - 1;
+ BOPDS_InterfVV& aVV = aVVs(iX);
+ aVV.SetIndices(n1, n2);
+ aVV.SetIndexNew(nV);
+ }
+ }
+ }
+ return nV;
}
#include <BOPCol_ListOfInteger.hxx>
#include <BOPCol_IndexedMapOfInteger.hxx>
#include <BOPCol_DataMapOfIntegerReal.hxx>
+#include <BOPCol_MapOfShape.hxx>
#include <BOPInt_Context.hxx>
#include <BOPInt_Tools.hxx>
BOPDS_DataMapOfPaveBlockListOfPaveBlock aDMExEdges(100, aAllocator);
BOPCol_DataMapOfIntegerReal aMVTol(100, aAllocator);
BOPCol_DataMapIteratorOfDataMapOfIntegerReal aItMV;
- BOPCol_DataMapOfIntegerInteger aDMI(100, aAllocator);
+ BOPCol_DataMapOfIntegerInteger aDMNewSD(100, aAllocator);
+ BOPCol_DataMapOfIntegerListOfInteger aDMVLV;
//
for (i=0; i<aNbFF; ++i) {
BOPDS_InterfFF& aFF=aFFs(i);
// DEBt
aNC.InitPaveBlock1();
//
- PutPavesOnCurve(aMVOnIn, aTolR3D, aNC, nF1, nF2, aMI, aMVEF, aMVTol);
+ PutPavesOnCurve(aMVOnIn, aTolR3D, aNC, nF1, nF2, aMI, aMVEF, aMVTol, aDMVLV);
//
- PutStickPavesOnCurve(aF1, aF2, aMI, aNC, aMVStick, aMVTol);
+ PutStickPavesOnCurve(aF1, aF2, aMI, aNC, aMVStick, aMVTol, aDMVLV);
//904/F7
if (aNbC == 1) {
- PutEFPavesOnCurve(aNC, aMI, aMVEF, aMVTol);
+ PutEFPavesOnCurve(aNC, aMI, aMVEF, aMVTol, aDMVLV);
}
//
if (aIC.HasBounds()) {
aLPBC.RemoveFirst();
}//for (j=0; j<aNbC; ++j) {
//back to previous tolerance values for unused vertices
- {
- BRep_Builder aBB;
+ aItMV.Initialize(aMVTol);
+ for (; aItMV.More(); aItMV.Next()) {
+ nV1 = aItMV.Key();
+ aTol = aItMV.Value();
//
- aItMV.Initialize(aMVTol);
- for (; aItMV.More(); aItMV.Next()) {
- nV1 = aItMV.Key();
- aTol = aItMV.Value();
- //
- const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&myDS->Shape(nV1);
- //
- aBB.UpdateVertex(aV, aTol);
- }
+ const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&myDS->Shape(nV1);
+ const Handle(BRep_TVertex)& TV =
+ *((Handle(BRep_TVertex)*)&aV.TShape());
+ TV->Tolerance(aTol);
+ // reset bnd box
+ BOPDS_ShapeInfo& aSIDS = myDS->ChangeShapeInfo(nV1);
+ Bnd_Box& aBoxDS = aSIDS.ChangeBox();
+ aBoxDS = Bnd_Box();
+ BRepBndLib::Add(aV, aBoxDS);
+ aBoxDS.SetGap(aBoxDS.GetGap() + Precision::Confusion());
+ //
+ if (aDMVLV.IsBound(nV1))
+ aDMVLV.UnBind(nV1);
}
//
ProcessExistingPaveBlocks(i, aMPBOnIn, aMSCPB, aMVI, aMVB, aMPBAdd);
}//for (i=0; i<aNbFF; ++i) {
//
// post treatment
- myErrorStatus=PostTreatFF(aMSCPB, aMVI, aDMExEdges, aDMI, aAllocator);
+ MakeSDVerticesFF(aDMVLV, aDMNewSD);
+ myErrorStatus=PostTreatFF(aMSCPB, aMVI, aDMExEdges, aDMNewSD, aAllocator);
if (myErrorStatus) {
return;
}
// update face info
UpdateFaceInfo(aDMExEdges);
//Update all pave blocks
- UpdatePaveBlocks(aDMI);
+ UpdatePaveBlocks(aDMNewSD);
//-----------------------------------------------------scope t
aMF.Clear();
aMVStick.Clear();
aMVOnIn.Clear();
aDMExEdges.Clear();
aMI.Clear();
- aDMI.Clear();
+ aDMNewSD.Clear();
aAllocator.Nullify();
}
+//=======================================================================
+//function : MakeSDVerticesFF
+//purpose :
+//=======================================================================
+void BOPAlgo_PaveFiller::MakeSDVerticesFF
+ (const BOPCol_DataMapOfIntegerListOfInteger& theDMVLV,
+ BOPCol_DataMapOfIntegerInteger& theDMNewSD)
+{
+ // Create a new SD vertex for each group of coinciding vertices
+ // and put new substitutions to theDMNewSD.
+ BOPCol_DataMapIteratorOfDataMapOfIntegerListOfInteger aItG(theDMVLV);
+ for (; aItG.More(); aItG.Next()) {
+ const BOPCol_ListOfInteger& aList = aItG.Value();
+ // make SD vertices w/o creation of interfs
+ Standard_Integer nSD = MakeSDVertices(aList, Standard_False);
+ // update theDMNewSD
+ BOPCol_ListIteratorOfListOfInteger aItL(aList);
+ for (; aItL.More(); aItL.Next()) {
+ Standard_Integer nV = aItL.Value();
+ theDMNewSD.Bind(nV, nSD);
+ }
+ }
+}
+
//=======================================================================
//function : PostTreatFF
//purpose :
(BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& theMSCPB,
BOPCol_DataMapOfShapeInteger& aMVI,
BOPDS_DataMapOfPaveBlockListOfPaveBlock& aDMExEdges,
- BOPCol_DataMapOfIntegerInteger& aDMI,
+ BOPCol_DataMapOfIntegerInteger& aDMNewSD,
Handle(NCollection_BaseAllocator)& theAllocator)
{
Standard_Integer iRet, aNbS;
}
//
// 1 prepare arguments
+ BOPCol_MapOfShape anAddedSD;
for (k=1; k<=aNbS; ++k) {
const TopoDS_Shape& aS=theMSCPB.FindKey(k);
aLS.Append(aS);
+ // add vertices-candidates for SD from the map aDMNewSD,
+ // so that they took part in fuse operation.
+ TopoDS_Iterator itV(aS);
+ for (; itV.More(); itV.Next()) {
+ const TopoDS_Shape& aVer = itV.Value();
+ Standard_Integer iVer = aMVI.Find(aVer);
+ if (aDMNewSD.IsBound(iVer)) {
+ Standard_Integer iSD = aDMNewSD.Find(iVer);
+ const TopoDS_Shape& aVSD = myDS->Shape(iSD);
+ if (anAddedSD.Add(aVSD)) {
+ aLS.Append(aVSD);
+ aMVI.Bind(aVSD, iSD);
+ }
+ }
+ }
}
//
// 2 Fuse shapes
aType=aSIx.ShapeType();
//
if (aType==TopAbs_VERTEX) {
+ Standard_Boolean bIntersectionPoint = theMSCPB.Contains(aSx);
+ //
if (aPDS->HasShapeSD(nSx, nVSD)) {
aV=aPDS->Shape(nVSD);
}
else {
iV=aMVI.Find(aV);
}
- // update FF interference
- const BOPDS_CoupleOfPaveBlocks &aCPB=theMSCPB.FindFromKey(aSx);
- iX=aCPB.IndexInterf();
- iP=aCPB.Index();
- BOPDS_InterfFF& aFF=aFFs(iX);
- BOPDS_VectorOfPoint& aVNP=aFF.ChangePoints();
- BOPDS_Point& aNP=aVNP(iP);
- aNP.SetIndex(iV);
+ //
+ if (!bIntersectionPoint) {
+ // save SD connection
+ nSx = aMVI.Find(aSx);
+ aDMNewSD.Bind(nSx, iV);
+ myDS->AddShapeSD(nSx, iV);
+ }
+ else {
+ // update FF interference
+ const BOPDS_CoupleOfPaveBlocks &aCPB=theMSCPB.FindFromKey(aSx);
+ iX=aCPB.IndexInterf();
+ iP=aCPB.Index();
+ BOPDS_InterfFF& aFF=aFFs(iX);
+ BOPDS_VectorOfPoint& aVNP=aFF.ChangePoints();
+ BOPDS_Point& aNP=aVNP(iP);
+ aNP.SetIndex(iV);
+ }
}//if (aType==TopAbs_VERTEX) {
//
else if (aType==TopAbs_EDGE) {
}
}
//
- if (!aNbLPBx) {
- aE=aSx;
- //
- if (!aMVI.IsBound(aE)) {
- aSI.SetShapeType(aType);
- aSI.SetShape(aE);
- iE=myDS->Append(aSI);
- aMVI.Bind(aE, iE);
- }
- else {
- iE=aMVI.Find(aE);
- }
- // append new PaveBlock to aLPBC
- aPB1->SetEdge(iE);
- aLPBC.Append(aPB1);
- } // if (!aNbLPBx) {
- //
- else {
+ if (aNbLPBx) {
aItLPB.Initialize(aLPBx);
if (bOld) {
aPave1[0] = aPB1->Pave1();
}
const BOPDS_Pave& aP1 = !j ? aPB1->Pave1() : aPB1->Pave2();
if (aP1.Parameter() == aPave[j].Parameter() && aP1.Index() != iV) {
- aDMI.Bind(aP1.Index(), iV);
+ aDMNewSD.Bind(aP1.Index(), iV);
}
//
aPave[j].SetIndex(iV);
}
}//else if (aType==TopAbs_EDGE)
}//for (; aItLS.More(); aItLS.Next()) {
+ //
+ // Update SD for vertices that did not participate in operation
+ BOPCol_DataMapOfIntegerInteger::Iterator itDM(aDMNewSD);
+ for (; itDM.More(); itDM.Next())
+ {
+ if (aDMNewSD.IsBound(itDM.Value())) {
+ Standard_Integer iSD = aDMNewSD.Find(itDM.Value());
+ itDM.ChangeValue() = iSD;
+ myDS->AddShapeSD(itDM.Key(), iSD);
+ }
+ }
return iRet;
}
const Standard_Integer nF2,
const BOPCol_MapOfInteger& aMI,
const BOPCol_MapOfInteger& aMVEF,
- BOPCol_DataMapOfIntegerReal& aMVTol)
+ BOPCol_DataMapOfIntegerReal& aMVTol,
+ BOPCol_DataMapOfIntegerListOfInteger& aDMVLV)
{
Standard_Boolean bInBothFaces;
Standard_Integer nV;
aIt.Initialize(aMVEF);
for (; aIt.More(); aIt.Next()) {
nV=aIt.Value();
- PutPaveOnCurve(nV, aTolR3D, aNC, aMI, aMVTol, 2);
+ PutPaveOnCurve(nV, aTolR3D, aNC, aMI, aMVTol, aDMVLV, 2);
}
//Put all other vertices
aIt.Initialize(aMVOnIn);
}
}
//
- PutPaveOnCurve(nV, aTolR3D, aNC, aMI, aMVTol, 1);
+ PutPaveOnCurve(nV, aTolR3D, aNC, aMI, aMVTol, aDMVLV, 1);
}
}
(BOPDS_Curve& aNC,
const BOPCol_MapOfInteger& aMI,
const BOPCol_MapOfInteger& aMVEF,
- BOPCol_DataMapOfIntegerReal& aMVTol)
+ BOPCol_DataMapOfIntegerReal& aMVTol,
+ BOPCol_DataMapOfIntegerListOfInteger& aDMVLV)
{
if (!aMVEF.Extent()) {
return;
Standard_Integer aNbPoints = aProjPT.NbPoints();
if (aNbPoints) {
aDist = aProjPT.LowerDistance();
- PutPaveOnCurve(nV, aDist, aNC, aMI, aMVTol);
+ PutPaveOnCurve(nV, aDist, aNC, aMI, aMVTol, aDMVLV);
}
}
}
const BOPCol_MapOfInteger& aMI,
BOPDS_Curve& aNC,
const BOPCol_MapOfInteger& aMVStick,
- BOPCol_DataMapOfIntegerReal& aMVTol)
+ BOPCol_DataMapOfIntegerReal& aMVTol,
+ BOPCol_DataMapOfIntegerListOfInteger& aDMVLV)
{
BOPCol_MapOfInteger aMV;
aMV.Assign(aMVStick);
// The intersection curve aIC is vanishing curve (the crease)
aD=sqrt(aD2);
//
- PutPaveOnCurve(nV, aD, aNC, aMI, aMVTol);
+ PutPaveOnCurve(nV, aD, aNC, aMI, aMVTol, aDMVLV);
}
}//for (jVU=1; jVU=aNbVU; ++jVU) {
}
BOPDS_Curve& aNC,
const BOPCol_MapOfInteger& aMI,
BOPCol_DataMapOfIntegerReal& aMVTol,
+ BOPCol_DataMapOfIntegerListOfInteger& aDMVLV,
const Standard_Integer iCheckExtend)
{
Standard_Boolean bIsVertexOnLine;
if (bIsVertexOnLine) {
// check if aPB contains the parameter aT
Standard_Boolean bExist;
- Standard_Integer nVToUpdate;
- Standard_Real aPTol, aDist, aTolVNew, aTolV2, aDTol;
- TopoDS_Vertex aVToUpdate;
- gp_Pnt aP1, aP2;
+ Standard_Integer nVUsed;
+ Standard_Real aPTol, aDTol;
//
- aTolV2 = 0.;
aDTol = 1.e-12;
//
GeomAdaptor_Curve aGAC(aIC.Curve());
aPTol = aGAC.Resolution(aTolR3D);
//
- bExist = aPB->ContainsParameter(aT, aPTol, nVToUpdate);
+ bExist = aPB->ContainsParameter(aT, aPTol, nVUsed);
if (bExist) {
// use existing pave
- aP1 = BRep_Tool::Pnt(aV);
- aTolV2 = BRep_Tool::Tolerance(aV);
- aVToUpdate = (*(TopoDS_Vertex *)(&myDS->Shape(nVToUpdate)));
+ if (!aDMVLV.IsBound(nVUsed)) {
+ BOPCol_ListOfInteger aList;
+ aList.Append(nVUsed);
+ aDMVLV.Bind(nVUsed, aList);
+ //
+ if (!aMVTol.IsBound(nVUsed)) {
+ const TopoDS_Vertex& aVUsed = (*(TopoDS_Vertex *)(&myDS->Shape(nVUsed)));
+ aTolV = BRep_Tool::Tolerance(aVUsed);
+ aMVTol.Bind(nVUsed, aTolV);
+ }
+ }
+ //
+ BOPCol_ListOfInteger& aList = aDMVLV.ChangeFind(nVUsed);
+ // avoid repeated elements in the list
+ BOPCol_ListIteratorOfListOfInteger aItLI(aList);
+ for (; aItLI.More(); aItLI.Next()) {
+ if (aItLI.Value() == nV) {
+ break;
+ }
+ }
+ if (!aItLI.More()) {
+ aList.Append(nV);
+ }
+ // save initial tolerance for the vertex
+ if (!aMVTol.IsBound(nV)) {
+ aTolV = BRep_Tool::Tolerance(aV);
+ aMVTol.Bind(nV, aTolV);
+ }
}
else {
// add new pave
aPave.SetParameter(aT);
aPB->AppendExtPave(aPave);
//
- aP1 = aGAC.Value(aT);
- nVToUpdate = nV;
- aVToUpdate = aV;
- }
- //
- aTolV = BRep_Tool::Tolerance(aVToUpdate);
- aP2 = BRep_Tool::Pnt(aVToUpdate);
- aDist = aP1.Distance(aP2);
- aTolVNew = aDist - aTolV2;
- //
- if (aTolVNew > aTolV) {
- BRep_Builder aBB;
- aBB.UpdateVertex(aVToUpdate, aTolVNew+aDTol);
- //
- if (!aMVTol.IsBound(nVToUpdate)) {
- aMVTol.Bind(nVToUpdate, aTolV);
+ gp_Pnt aP1 = aGAC.Value(aT);
+ aTolV = BRep_Tool::Tolerance(aV);
+ gp_Pnt aP2 = BRep_Tool::Pnt(aV);
+ Standard_Real aDist = aP1.Distance(aP2);
+ if (aDist > aTolV) {
+ BRep_Builder().UpdateVertex(aV, aDist + aDTol);
+ //
+ if (!aMVTol.IsBound(nV)) {
+ aMVTol.Bind(nV, aTolV);
+ }
+ //
+ BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(nV);
+ Bnd_Box& aBoxDS=aSIDS.ChangeBox();
+ BRepBndLib::Add(aV, aBoxDS);
+ aBoxDS.SetGap(aBoxDS.GetGap() + Precision::Confusion());
}
- //
- BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(nVToUpdate);
- Bnd_Box& aBoxDS=aSIDS.ChangeBox();
- BRepBndLib::Add(aVToUpdate, aBoxDS);
}
}
}
//purpose :
//=======================================================================
void BOPAlgo_PaveFiller::UpdatePaveBlocks
- (const BOPCol_DataMapOfIntegerInteger& aDMI)
+ (const BOPCol_DataMapOfIntegerInteger& aDMNewSD)
{
- if (aDMI.IsEmpty()) {
+ if (aDMNewSD.IsEmpty()) {
return;
}
//
aPB->Range(aT[0], aT[1]);
//
for (j = 0; j < 2; ++j) {
- if (aDMI.IsBound(nV[j])) {
+ if (aDMNewSD.IsBound(nV[j])) {
BOPDS_Pave aPave;
//
- nV[j] = aDMI.Find(nV[j]);
+ nV[j] = aDMNewSD.Find(nV[j]);
aPave.SetIndex(nV[j]);
aPave.SetParameter(aT[j]);
//