The fix forces creation of new sub-shapes (vertex, edge) when the tolerance of some sub-shape of an argument is to be increased.
This new behavior is turned off by default. It can be turned on using two ways:
1) Setting 'locking' flag of the arguments.
2) Calling the method SetNonDestructive(Standard_True) of the API classes.
#include <TopoDS_Compound.hxx>
#include <BRep_Builder.hxx>
+#include <BOPCol_IndexedMapOfShape.hxx>
+
+#include <BOPDS_ShapeInfo.hxx>
+#include <BOPDS_DS.hxx>
+
#include <BOPTools_AlgoTools.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
+
//=======================================================================
//function :
//purpose :
PostTreat();
}
-//
-// myErrorStatus
-//
-// 0 - Ok
-//
//=======================================================================
//function : PostTreat
//purpose :
//=======================================================================
void BOPAlgo_Builder::PostTreat()
{
- BOPTools_AlgoTools::CorrectTolerances(myShape, 0.05, myRunParallel);
- BOPTools_AlgoTools::CorrectShapeTolerances(myShape, myRunParallel);
+ Standard_Integer i, aNbS;
+ TopAbs_ShapeEnum aType;
+ BOPCol_IndexedMapOfShape aMA;
+ if (myPaveFiller->NonDestructive()) {
+ // MapToAvoid
+ aNbS=myDS->NbSourceShapes();
+ for (i=0; i<aNbS; ++i) {
+ const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
+ aType=aSI.ShapeType();
+ if (aType==TopAbs_VERTEX ||
+ aType==TopAbs_EDGE||
+ aType==TopAbs_FACE) {
+ const TopoDS_Shape& aS=aSI.Shape();
+ aMA.Add(aS);
+}
+ }
+ }
+ //
+ BOPTools_AlgoTools::CorrectTolerances(myShape, aMA, 0.05, myRunParallel);
+ BOPTools_AlgoTools::CorrectShapeTolerances(myShape, aMA, myRunParallel);
}
aLE.Append(aSp);
}
//
- BOPTools_AlgoTools2D::BuildPCurveForEdgesOnPlane (aLE, aFF);
- //
+ if (!myPaveFiller->NonDestructive()) {
+ // speed up for planar faces
+ BOPTools_AlgoTools2D::BuildPCurveForEdgesOnPlane (aLE, aFF);
+ }
// 3 Build split faces
BOPAlgo_BuilderFace& aBF=aVBF.Append1();
aBF.SetFace(aF);
-- 4 - V/V, V/E, E/E, V/F and E/F;
-- 5 - all interferences, default value.
- SetNonDestructive(me:out;
- theFlag: Boolean from Standard);
- ---Purpose: Sets the flag <theFlag> that defines
- -- the mode of the treatment:
- -- the copy of the argument when theFlag is true
- -- the argument itself when theFlag is false
-
- NonDestructive(me)
- returns Boolean from Standard;
- ---Purpose: Returns the flag that defines the
- -- mode of the treatment:
- -- true when the copy of the argument is used
- -- false when the argument itself is used
-
PostTreat (me:out)
is protected;
---Purpose: Provides post-treatment actions
fields
myLevelOfCheck: Integer from Standard is protected;
- myNonDestructive: Boolean from Standard is protected;
myNewOldMap : DataMapOfShapeShape from BOPCol is protected;
end CheckerSI;
}
}
//=======================================================================
-//function : SetNonDestructive
-//purpose :
-//=======================================================================
-void BOPAlgo_CheckerSI::SetNonDestructive(const Standard_Boolean theFlag)
-{
- myNonDestructive=theFlag;
-}
-//=======================================================================
-//function : NonDestructive
-//purpose :
-//=======================================================================
-Standard_Boolean BOPAlgo_CheckerSI::NonDestructive() const
-{
- return myNonDestructive;
-}
-//=======================================================================
//function : Init
//purpose :
//=======================================================================
Iterator from BOPDS,
PIterator from BOPDS,
PaveBlock from BOPDS,
+ CommonBlock from BOPDS,
Curve from BOPDS,
IndexedDataMapOfShapeCoupleOfPaveBlocks from BOPDS,
MapOfPaveBlock from BOPDS,
returns Real from Standard;
---Purpose: Returns the additional tolerance
+ UpdateVertex(me:out;
+ nV : Integer from Standard;
+ aTolNew: Real from Standard)
+ returns Integer from Standard
+ is protected;
+ ---Purpose:
+ -- Updates tolerance vertex nV due to V/E interference;
+ -- It always creates new vertex if nV is from arguments
+ -- Returns: DS index of updated vertex.
+
+ ComputeTolerance(me:out;
+ theCB:CommonBlock from BOPDS)
+ returns Real from Standard
+ is protected;
+
+ UpdatePaveBlocksWithSDVertices(me:out)
+ is protected;
+
+ UpdateCommonBlocksWithSDVertices (me:out)
+ is protected;
+
+ UpdateBlocksWithSharedVertices (me:out)
+ is protected;
+
+ EstimatePaveOnCurve (me:out;
+ nV : Integer from Standard;
+ theNC : out Curve from BOPDS;
+ theTolR3D : Real from Standard)
+ returns Boolean from Standard
+ is protected;
+
+ UpdateEdgeTolerance(me:out;
+ nE : Integer from Standard;
+ aTolNew: Real from Standard)
+ is protected;
+
+ SetNonDestructive(me:out;
+ theFlag:Boolean from Standard);
+ ---Purpose: Sets the flag <theFlag> that defines
+ -- the mode of treatment: in non-destructive mode
+ -- the argument shapes are not modified: the copy of sub-shape
+ -- is created in the result if it is needed to be updated.
+
+ SetNonDestructive(me:out)
+ is protected;
+ ---Purpose: Sets non-destructive mode automatically if the argument
+ -- contains a locked shape (see TopoDS_Shape::Locked()).
+
+ NonDestructive(me)
+ returns Boolean from Standard;
+ ---Purpose: Returns the flag that defines
+ -- the mode of treatment: in non-destructive mode
+ -- the argument shapes are not modified: the copy of sub-shape
+ -- is created in the result if it is needed to be updated.
+
+ SetIsPrimary(me:out;
+ theFlag:Boolean from Standard)
+ is protected;
+
+ IsPrimary(me)
+ returns Boolean from Standard
+ is protected;
+
fields
myArguments : ListOfShape from BOPCol is protected;
myDS : PDS from BOPDS is protected;
myContext : Context from IntTools is protected;
mySectionAttribute : SectionAttribute from BOPAlgo is protected;
myFuzzyValue : Real from Standard is protected;
+ myNonDestructive : Boolean from Standard is protected;
+ myIsPrimary : Boolean from Standard is protected;
end PaveFiller;
{
myDS=NULL;
myIterator=NULL;
+ myNonDestructive=Standard_False;
+ myIsPrimary=Standard_True;
}
//=======================================================================
//function :
{
myDS=NULL;
myIterator=NULL;
+ myNonDestructive=Standard_False;
+ myIsPrimary=Standard_True;
}
//=======================================================================
//function : ~
Clear();
}
//=======================================================================
+//function : SetNonDestructive
+//purpose :
+//=======================================================================
+void BOPAlgo_PaveFiller::SetNonDestructive(const Standard_Boolean bFlag)
+{
+ myNonDestructive=bFlag;
+}
+//=======================================================================
+//function : NonDestructive
+//purpose :
+//=======================================================================
+Standard_Boolean BOPAlgo_PaveFiller::NonDestructive()const
+{
+ return myNonDestructive;
+}
+//=======================================================================
+//function : SetIsPrimary
+//purpose :
+//=======================================================================
+void BOPAlgo_PaveFiller::SetIsPrimary(const Standard_Boolean bFlag)
+{
+ myIsPrimary=bFlag;
+}
+//=======================================================================
+//function : IsPrimary
+//purpose :
+//=======================================================================
+Standard_Boolean BOPAlgo_PaveFiller::IsPrimary()const
+{
+ return myIsPrimary;
+}
+//=======================================================================
//function : Clear
//purpose :
//=======================================================================
//
// 0 Clear
Clear();
+
//
// 1.myDS
myDS=new BOPDS_DS(myAllocator);
// 3 myContext
myContext=new IntTools_Context;
//
+ // 4 NonDestructive flag
+ SetNonDestructive();
+ //
myErrorStatus=0;
}
//=======================================================================
return;
}
//
+ UpdatePaveBlocksWithSDVertices();
myDS->UpdatePaveBlocks();
// 11
PerformEE();
if (myErrorStatus) {
return;
}
+ UpdatePaveBlocksWithSDVertices();
// 02
PerformVF();
if (myErrorStatus) {
return;
}
+ UpdatePaveBlocksWithSDVertices();
// 12
PerformEF();
if (myErrorStatus) {
return;
}
+ UpdatePaveBlocksWithSDVertices();
//
- MakeSplitEdges();
+ // 22
+ PerformFF();
if (myErrorStatus) {
return;
}
//
- // 22
- PerformFF();
+ UpdateBlocksWithSharedVertices();
+ //
+ MakeSplitEdges();
if (myErrorStatus) {
return;
}
//
+ UpdatePaveBlocksWithSDVertices();
+ //
MakeBlocks();
if (myErrorStatus) {
return;
if (myErrorStatus) {
return;
}
- //
// 03
PerformVZ();
if (myErrorStatus) {
#include <TopoDS_Vertex.hxx>
#include <BRepBndLib.hxx>
+#include <BOPCol_DataMapOfIntegerInteger.hxx>
#include <BOPCol_DataMapOfIntegerListOfInteger.hxx>
#include <BOPCol_MapOfInteger.hxx>
#include <BOPCol_ListOfShape.hxx>
#include <BOPDS_DS.hxx>
#include <BOPDS_Iterator.hxx>
-#include <BOPTools_AlgoTools.hxx>
+
#include <BOPDS_VectorOfInterfVV.hxx>
#include <BOPDS_ShapeInfo.hxx>
-#include <BOPAlgo_Tools.hxx>
+#include <BOPTools_AlgoTools.hxx>
+#include <BOPAlgo_Tools.hxx>
//=======================================================================
// function: PerformVV
//
BOPTools_AlgoTools::MakeVertex(aLV, aVn);
//
- // Appennd new vertex to the DS
+ // Append new vertex to the DS
aSIn.SetShape(aVn);
n=myDS->Append(aSIn);
//
}
}
//
+ BOPCol_DataMapIteratorOfDataMapOfIntegerInteger aItDMII;
+ //
+ BOPCol_DataMapOfIntegerInteger& aDMII=myDS->ShapesSD();
+ aItDMII.Initialize(aDMII);
+ for (; aItDMII.More(); aItDMII.Next()) {
+ n1=aItDMII.Key();
+ myDS->InitPaveBlocksForVertex(n1);
+ }
+ //
//-----------------------------------------------------scope t
aLV.Clear();
aMBlocks.Clear();
--- /dev/null
+// Created by: Peter KURNEV
+// Copyright (c) 2010-2014 OPEN CASCADE SAS
+// Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT,
+// EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and / or modify it
+// under the terms of the GNU Lesser General Public version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <BOPAlgo_PaveFiller.ixx>
+
+#include <Precision.hxx>
+
+#include <gp_Pnt.hxx>
+#include <Bnd_Box.hxx>
+
+#include <TopoDS_Iterator.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Edge.hxx>
+
+#include <BRep_Tool.hxx>
+#include <BRep_Builder.hxx>
+#include <BRepBndLib.hxx>
+
+#include <BOPDS_ShapeInfo.hxx>
+#include <BOPDS_VectorOfListOfPaveBlock.hxx>
+#include <BOPDS_MapOfCommonBlock.hxx>
+#include <BOPDS_ListOfPaveBlock.hxx>
+#include <BOPDS_CommonBlock.hxx>
+#include <BOPDS_DS.hxx>
+
+//=======================================================================
+//function : SetNonDestructive
+//purpose :
+//=======================================================================
+void BOPAlgo_PaveFiller::SetNonDestructive()
+{
+ if (!myIsPrimary) {
+ return;
+ }
+ //
+ Standard_Boolean bFlag;
+ BOPCol_ListIteratorOfListOfShape aItLS;
+ //
+ bFlag=Standard_False;
+ aItLS.Initialize(myArguments);
+ for(; aItLS.More() && (!bFlag); aItLS.Next()) {
+ const TopoDS_Shape& aS=aItLS.Value();
+ bFlag=aS.Locked();
+ }
+ myNonDestructive=bFlag;
+}
+//=======================================================================
+//function : UpdateEdgeTolerance
+//purpose :
+//=======================================================================
+void BOPAlgo_PaveFiller::UpdateEdgeTolerance (const Standard_Integer nE,
+ const Standard_Real aTol)
+{
+ Standard_Boolean bIsNewShape, bHasShapeSD;
+ Standard_Integer nV, nVx;
+ Standard_Real aTolV;
+ BRep_Builder aBB;
+ BOPCol_ListIteratorOfListOfInteger aIt;
+ //
+ BOPDS_ShapeInfo& aSIE=myDS->ChangeShapeInfo(nE);
+ const BOPCol_ListOfInteger& aLI=aSIE.SubShapes();
+ //
+ if (myNonDestructive) {
+ bIsNewShape=myDS->IsNewShape(nE);
+ if (!bIsNewShape) {
+ return;
+ }
+ //
+ aIt.Initialize(aLI);
+ for (; aIt.More(); aIt.Next()) {
+ nV = aIt.Value();
+ bHasShapeSD=myDS->HasShapeSD(nV, nVx);
+ if (bHasShapeSD) {
+ continue;
+ }
+ bIsNewShape=myDS->IsNewShape(nV);
+ if (!bIsNewShape) {
+ return;
+ }
+ }
+ }
+ //
+ const TopoDS_Edge& aE = *(TopoDS_Edge*)&myDS->Shape(nE);
+ aBB.UpdateEdge(aE, aTol);
+ Bnd_Box& aBoxE=aSIE.ChangeBox();
+ BRepBndLib::Add(aE, aBoxE);
+ //
+ aIt.Initialize(aLI);
+ for (; aIt.More(); aIt.Next()) {
+ nV = aIt.Value();
+ bHasShapeSD=myDS->HasShapeSD(nV, nVx);
+ if (bHasShapeSD) {
+ nV=nVx;
+ }
+ const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&myDS->Shape(nV);
+ aTolV = BRep_Tool::Tolerance(aV);
+ if (aTolV < aTol) {
+ aBB.UpdateVertex(aV, aTol);
+ BOPDS_ShapeInfo& aSIV = myDS->ChangeShapeInfo(nV);
+ Bnd_Box& aBoxV = aSIV.ChangeBox();
+ BRepBndLib::Add(aV, aBoxV);
+ }
+ }
+}
+//=======================================================================
+//function : UpdateVertex
+//purpose :
+//=======================================================================
+Standard_Integer BOPAlgo_PaveFiller::UpdateVertex
+ (const Standard_Integer nV,
+ const Standard_Real aTolNew)
+{
+ Standard_Integer nVNew;
+ Standard_Real aTolV;
+ BRep_Builder aBB;
+
+ nVNew = nV;
+ if (myDS->IsNewShape(nVNew) ||
+ myDS->HasShapeSD(nV, nVNew) ||
+ !myNonDestructive) {
+ // nV is a new vertex, it has SD or non-destructive mode is not in force
+ const TopoDS_Vertex& aVSD = *(TopoDS_Vertex*)&myDS->Shape(nVNew);
+ aTolV = BRep_Tool::Tolerance(aVSD);
+ if (aTolV < aTolNew) {
+ aBB.UpdateVertex(aVSD, aTolNew);
+ BOPDS_ShapeInfo& aSIV = myDS->ChangeShapeInfo(nVNew);
+ Bnd_Box& aBoxV = aSIV.ChangeBox();
+ BRepBndLib::Add(aVSD, aBoxV);
+ }
+ return nVNew;
+ }
+ //
+ // nV is old vertex
+ const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&myDS->Shape(nV);
+ aTolV = BRep_Tool::Tolerance(aV);
+ //
+ // create new vertex
+ TopoDS_Vertex aVNew;
+ gp_Pnt aPV = BRep_Tool::Pnt(aV);
+ aBB.MakeVertex(aVNew, aPV, Max(aTolV, aTolNew));
+ //
+ // append new vertex to DS
+ BOPDS_ShapeInfo aSIV;
+ aSIV.SetShapeType(TopAbs_VERTEX);
+ aSIV.SetShape(aVNew);
+ nVNew = myDS->Append(aSIV);
+ //
+ // bounding box for the new vertex
+ BOPDS_ShapeInfo& aSIDS = myDS->ChangeShapeInfo(nVNew);
+ Bnd_Box& aBoxDS = aSIDS.ChangeBox();
+ BRepBndLib::Add(aVNew, aBoxDS);
+ //
+ // add vertex to SD map
+ myDS->AddShapeSD(nV, nVNew);
+ //
+ myDS->InitPaveBlocksForVertex(nV);
+ //
+ return nVNew;
+}
+//=======================================================================
+//function : UpdatePaveBlocksWithSDVertices
+//purpose :
+//=======================================================================
+void BOPAlgo_PaveFiller::UpdatePaveBlocksWithSDVertices()
+{
+ if (!myNonDestructive) {
+ return;
+ }
+ myDS->UpdatePaveBlocksWithSDVertices();
+}
+//=======================================================================
+//function : UpdateCommonBlocksWithSDVertices
+//purpose :
+//=======================================================================
+void BOPAlgo_PaveFiller::UpdateCommonBlocksWithSDVertices()
+{
+ if (!myNonDestructive) {
+ return;
+ }
+ Standard_Integer aNbPBP;
+ //
+ BOPDS_VectorOfListOfPaveBlock& aPBP=myDS->ChangePaveBlocksPool();
+ aNbPBP=aPBP.Extent();
+ if(!aNbPBP) {
+ return;
+ }
+ //
+ Standard_Integer i, nV1, nV2;
+ Standard_Real aTolV;
+ BOPDS_MapOfCommonBlock aMCB;
+ BOPDS_ListIteratorOfListOfPaveBlock aItPB;
+ Handle(BOPDS_PaveBlock) aPB;
+ //
+ aTolV = Precision::Confusion();
+ //
+ for (i=0; i<aNbPBP; ++i) {
+ BOPDS_ListOfPaveBlock& aLPB=aPBP(i);
+ aItPB.Initialize(aLPB);
+ for (; aItPB.More(); aItPB.Next()) {
+ aPB=aItPB.Value();
+ const Handle(BOPDS_CommonBlock)& aCB=myDS->CommonBlock(aPB);
+ if (aCB.IsNull()) {
+ continue;
+ }
+ //
+ if (aMCB.Add(aCB)) {
+ myDS->SortPaveBlocks(aCB);
+ aPB->Indices(nV1, nV2);
+ UpdateVertex(nV1, aTolV);
+ UpdateVertex(nV2, aTolV);
+ myDS->UpdateCommonBlockWithSDVertices(aCB);
+ }
+ }
+ }
+ UpdatePaveBlocksWithSDVertices();
+}
BOPAlgo_VertexEdge() :
BOPAlgo_Algo(),
- myIV(-1), myIE(-1), myIVx(-1), myFlag(-1), myT(-1.) {
+ myIV(-1), myIE(-1), myIVx(-1), myFlag(-1), myT(-1.), myTolVNew(-1.) {
};
//
virtual ~BOPAlgo_VertexEdge(){
myV=aV;
}
//
- const TopoDS_Vertex& Vertex()const {
- return myV;
- }
- //
void SetEdge(const TopoDS_Edge& aE) {
myE=aE;
}
//
- const TopoDS_Edge& Edge()const {
- return myE;
- }
- //
Standard_Integer Flag()const {
return myFlag;
}
return myT;
}
//
+ Standard_Real VertexNewTolerance()const {
+ return myTolVNew;
+ }
+ //
void SetContext(const Handle(IntTools_Context)& aContext) {
myContext=aContext;
}
//
virtual void Perform() {
BOPAlgo_Algo::UserBreak();
- myFlag=myContext->ComputeVE (myV, myE, myT);
+ myFlag=myContext->ComputeVE (myV, myE, myT, myTolVNew);
};
//
protected:
Standard_Integer myIVx;
Standard_Integer myFlag;
Standard_Real myT;
+ Standard_Real myTolVNew;
TopoDS_Vertex myV;
TopoDS_Edge myE;
Handle(IntTools_Context) myContext;
{
Standard_Boolean bJustAdd;
Standard_Integer iSize, nV, nE, nVSD, iFlag, nVx, k, aNbVE;
- Standard_Real aT, aTolE, aTolV;
+ Standard_Real aT;
BOPDS_Pave aPave;
BOPDS_PassKey aPK;
BOPDS_MapOfPassKey aMPK;
- BRep_Builder aBB;
BOPAlgo_VectorOfVertexEdge aVVE;
//
myErrorStatus=0;
if (!iFlag) {
aVESolver.Indices(nV, nE, nVx);
aT=aVESolver.Parameter();
- const TopoDS_Vertex& aV=aVESolver.Vertex();
- const TopoDS_Edge& aE=aVESolver.Edge();
// 1
BOPDS_InterfVE& aVE=aVEs.Append1();
aVE.SetIndices(nV, nE);
aVE.SetParameter(aT);
// 2
myDS->AddInterf(nV, nE);
- // 3
+ //
+ //
BOPDS_ListOfPaveBlock& aLPB=myDS->ChangePaveBlocks(nE);
Handle(BOPDS_PaveBlock)& aPB=*((Handle(BOPDS_PaveBlock)*)&aLPB.First());
//
+ // 3 update vertex V/E if necessary
+ Standard_Real aTolVNew = aVESolver.VertexNewTolerance();
+ nVx=UpdateVertex(nV, aTolVNew);
+ //4
+ if (myDS->IsNewShape(nVx)) {
+ aVE.SetIndexNew(nVx);
+ }
+ //5 append ext pave to pave block
aPave.SetIndex(nVx);
aPave.SetParameter(aT);
aPB->AppendExtPave(aPave);
- aTolV = BRep_Tool::Tolerance(aV);
- aTolE = BRep_Tool::Tolerance(aE);
- if ( aTolV < aTolE) {
- aBB.UpdateVertex(aV, aTolE);
- BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(nVx);
- Bnd_Box& aBoxDS=aSIDS.ChangeBox();
- BRepBndLib::Add(aV, aBoxDS);
}
- }
}//for (k=0; k < aNbVE; ++k) {
}
aMPBToUpdate.Clear();
}
//=======================================================================
-//function : PerformVertices
+//function : PerformVerticesEE
//purpose :
//=======================================================================
Standard_Integer BOPAlgo_PaveFiller::PerformVerticesEE
Handle(BOPDS_PaveBlock)& aPB,
BOPDS_MapOfPaveBlock& aMPBToUpdate)
{
- Standard_Integer aNbPnt, nE;
- gp_Pnt aP;
+ Standard_Integer nE, nVx, nVSD, iFlag;
+ Standard_Real aT, aTolVNew;
//
nE = aPB->OriginalEdge();
//
return;
}
//
- if (aPB->Pave1().Index() == nV || aPB->Pave2().Index() == nV) {
+ if (aPB->Pave1().Index() == nV ||
+ aPB->Pave2().Index() == nV) {
return;
}
//
- const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&myDS->Shape(nV);
- const TopoDS_Edge& aE = *(TopoDS_Edge*) &myDS->Shape(nE);
- aP=BRep_Tool::Pnt(aV);
+ nVx = nV;
+ if (myDS->HasShapeSD(nV, nVSD)) {
+ nVx = nVSD;
+ }
//
- GeomAPI_ProjectPointOnCurve& aProjector=myContext->ProjPC(aE);
- aProjector.Perform(aP);
+ const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&myDS->Shape(nVx);
+ const TopoDS_Edge& aE = *(TopoDS_Edge*) &myDS->Shape(nE);
//
- aNbPnt = aProjector.NbPoints();
- if (aNbPnt) {
- Standard_Real aT, aDist;
- //Standard_Integer i;
- BRep_Builder aBB;
+ iFlag = myContext->ComputeVE(aV, aE, aT, aTolVNew);
+ if (iFlag == 0 || iFlag == -4) {
BOPDS_Pave aPave;
//
- aDist=aProjector.LowerDistance();
- aT=aProjector.LowerDistanceParameter();
//
BOPDS_VectorOfInterfVE& aVEs=myDS->InterfVE();
aVEs.SetIncrement(10);
+ // 1
BOPDS_InterfVE& aVE=aVEs.Append1();
aVE.SetIndices(nV, nE);
aVE.SetParameter(aT);
- //
+ // 2
myDS->AddInterf(nV, nE);
//
- aBB.UpdateVertex(aV, aDist);
- BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(nV);
- Bnd_Box& aBox=aSIDS.ChangeBox();
- BRepBndLib::Add(aV, aBox);
- //
- aPave.SetIndex(nV);
+ // 3 update vertex V/E if necessary
+ nVx=UpdateVertex(nV, aTolVNew);
+ // 4
+ if (myDS->IsNewShape(nVx)) {
+ aVE.SetIndexNew(nVx);
+ }
+ // 5 append ext pave to pave block
+ aPave.SetIndex(nVx);
aPave.SetParameter(aT);
aPB->AppendExtPave(aPave);
//
aMPBToUpdate.Add(aPB);
}
}
-
- /*
- // DEBf
- {
- TopoDS_Compound aCx;
- BRep_Builder aBBx;
- aBBx.MakeCompound(aCx);
- aItMVCPB.Initialize(theMVCPB);
- for (; aItMVCPB.More(); aItMVCPB.Next()) {
- const TopoDS_Shape& aS=aItMVCPB.Key();
- aBBx.Add(aCx, aS);
- }
- BRepTools::Write(aCx, "cx");
- }
- // DEBt
- */
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Face.hxx>
#include <BRep_Tool.hxx>
-#include <BRep_Builder.hxx>
-#include <BRepBndLib.hxx>
//
#include <BOPCol_MapOfInteger.hxx>
#include <BOPCol_NCVector.hxx>
BOPAlgo_VertexFace() :
BOPAlgo_Algo(),
myIV(-1), myIF(-1), myIVx(-1),
- myFlag(-1), myT1(-1.), myT2(-1.) {
+ myFlag(-1), myT1(-1.), myT2(-1.), myTolVNew(-1.) {
}
//
virtual ~BOPAlgo_VertexFace(){
aT2=myT2;
}
//
+ Standard_Real VertexNewTolerance()const {
+ return myTolVNew;
+ }
+ //
void SetContext(const Handle(IntTools_Context)& aContext) {
myContext=aContext;
}
//
virtual void Perform() {
BOPAlgo_Algo::UserBreak();
- myFlag=myContext->ComputeVF(myV, myF, myT1, myT2);
+ myFlag=myContext->ComputeVF(myV, myF, myT1, myT2, myTolVNew);
}
//
protected:
Standard_Integer myFlag;
Standard_Real myT1;
Standard_Real myT2;
+ Standard_Real myTolVNew;
TopoDS_Vertex myV;
TopoDS_Face myF;
Handle(IntTools_Context) myContext;
{
Standard_Boolean bJustAdd;
Standard_Integer iSize, nV, nF, nVSD, iFlag, nVx, aNbVF, k;
- Standard_Real aT1, aT2, aTolF, aTolV;
- BRep_Builder aBB;
+ Standard_Real aT1, aT2;
BOPAlgo_VectorOfVertexFace aVVF;
//
myErrorStatus=0;
//
aVertexFace.Indices(nV, nF, nVx);
aVertexFace.Parameters(aT1, aT2);
- const TopoDS_Vertex& aV=aVertexFace.Vertex();
- const TopoDS_Face& aF=aVertexFace.Face();
// 1
BOPDS_InterfVF& aVF=aVFs.Append1();
aVF.SetIndices(nVx, nF);
aVF.SetUV(aT1, aT2);
// 2
myDS->AddInterf(nVx, nF);
- // 3
+ //
+ // 3 update vertex V/F if necessary
+ Standard_Real aTolVNew = aVertexFace.VertexNewTolerance();
+ nVx=UpdateVertex(nVx, aTolVNew);
+ //
+ // 4
+ if (myDS->IsNewShape(nVx)) {
+ aVF.SetIndexNew(nVx);
+ }
+ // 5 update FaceInfo
BOPDS_FaceInfo& aFI=myDS->ChangeFaceInfo(nF);
BOPCol_MapOfInteger& aMVIn=aFI.ChangeVerticesIn();
aMVIn.Add(nVx);
- // 4
- aTolV = BRep_Tool::Tolerance(aV);
- aTolF = BRep_Tool::Tolerance(aF);
- if (aTolV < aTolF) {
- aBB.UpdateVertex(aV, aTolF);
- BOPDS_ShapeInfo& aSIV = myDS->ChangeShapeInfo(nVx);
- Bnd_Box& aBoxV = aSIV.ChangeBox();
- BRepBndLib::Add(aV, aBoxV);
- }
}//for (k=0; k < aNbVF; ++k) {
}// if (iSize) {
else {
#include <GeomAPI_ProjectPointOnSurf.hxx>
//
+#include <Precision.hxx>
+
#include <Bnd_Box.hxx>
//
#include <TopoDS_Vertex.hxx>
if (bIsOnPave[j]) {
bV[j]=CheckFacePaves(nV[j], aMIFOn, aMIFIn);
if (bV[j]) {
- const TopoDS_Vertex& aV=
+ const TopoDS_Vertex& aV =
(*(TopoDS_Vertex *)(&myDS->Shape(nV[j])));
- BOPTools_AlgoTools::UpdateVertex(aE, aT, aV);
- BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(nV[j]);
- Bnd_Box& aBoxDS=aSIDS.ChangeBox();
- BRepBndLib::Add(aV, aBoxDS);
+ //
+ Standard_Real f, l, aTolVnew, aDistPP, aTolPC, aTolV;
+ //
+ const Handle(Geom_Curve)& aCur = BRep_Tool::Curve(aE, f, l);
+ //
+ gp_Pnt aP1 = BRep_Tool::Pnt(aV);
+ gp_Pnt aP2 = aCur->Value(aT);
+ //
+
+ aDistPP=aP1.Distance(aP2);
+
+ aTolPC=Precision::PConfusion();
+ aTolV=BRep_Tool::Tolerance(aV);
+ if (aDistPP > (aTolV+aTolPC)) {
+ aTolVnew=Max(aTolE, aDistPP);
+ UpdateVertex(nV[j], aTolVnew);
+ }
}
else {
bIsOnPave[j] = ForceInterfVF(nV[j], nF);
myDS->AddInterf(nE, nF);
break;
}
- //update tolerance of edge if needed
- if (aTolE < aTolF) {
- myDS->UpdateEdgeTolerance(nE, aTolF);
- aTolE = aTolF;
- }
aEF.SetCommonPart(aCPart);
// 2
myDS->AddInterf(nE, nF);
}
//
// 2 Fuse vertices
+ aPF.SetIsPrimary(Standard_False);
+ aPF.SetNonDestructive(myNonDestructive);
aPF.SetArguments(aLS);
aPF.Perform();
iErr=aPF.ErrorStatus();
}
}
}
- // 6 Split PaveBlocksa
+ // 6 Split PaveBlocks
for (i=1; i<=aNbPBLI; ++i) {
Handle(BOPDS_PaveBlock) aPB=aMPBLI.FindKey(i);
nE=aPB->OriginalEdge();
const Standard_Integer nF)
{
Standard_Boolean bRet;
+ Standard_Integer iFlag, nVx;
+ Standard_Real U, V, aTolVNew;
//
bRet = Standard_False;
const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&myDS->Shape(nV);
const TopoDS_Face& aF = *(TopoDS_Face*) &myDS->Shape(nF);
//
- GeomAPI_ProjectPointOnSurf& aProj = myContext->ProjPS(aF);
- const gp_Pnt& aP = BRep_Tool::Pnt(aV);
- aProj.Perform(aP);
- if (!aProj.IsDone()) {
- return bRet;
- }
- Standard_Real aDist, U, V;
- //
- aDist=aProj.LowerDistance();
- aProj.LowerDistanceParameters(U, V);
- //
- gp_Pnt2d aP2d(U, V);
- bRet = myContext->IsPointInFace (aF, aP2d);
- if (bRet) {
- //Standard_Integer i;
- BRep_Builder aBB;
+ iFlag = myContext->ComputeVF(aV, aF, U, V, aTolVNew);
+ if (iFlag == 0 || iFlag == -2) {
+ bRet=!bRet;
//
BOPDS_VectorOfInterfVF& aVFs=myDS->InterfVF();
aVFs.SetIncrement(10);
+ // 1
BOPDS_InterfVF& aVF=aVFs.Append1();
+ //
aVF.SetIndices(nV, nF);
aVF.SetUV(U, V);
- //
+ // 2
myDS->AddInterf(nV, nF);
//
- aBB.UpdateVertex(aV, aDist);
- BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(nV);
- Bnd_Box& aBoxDS=aSIDS.ChangeBox();
- BRepBndLib::Add(aV, aBoxDS);
+ // 3 update vertex V/F if necessary
+ nVx=UpdateVertex(nV, aTolVNew);
+ // 4
+ if (myDS->IsNewShape(nVx)) {
+ aVF.SetIndexNew(nVx);
+ }
//
BOPDS_FaceInfo& aFI=myDS->ChangeFaceInfo(nF);
BOPCol_MapOfInteger& aMVIn=aFI.ChangeVerticesIn();
- aMVIn.Add(nV);
+ aMVIn.Add(nVx);
}
- //
return bRet;
}
-
const TopoDS_Face& aF1=(*(TopoDS_Face *)(&myDS->Shape(nF1)));
const TopoDS_Face& aF2=(*(TopoDS_Face *)(&myDS->Shape(nF2)));
//
+ if (aMI.Add(nF1)) {
+ myDS->UpdateFaceInfoOn(nF1);
+ myDS->UpdateFaceInfoIn(nF1);
+ }
+ if (aMI.Add(nF2)) {
+ myDS->UpdateFaceInfoOn(nF2);
+ myDS->UpdateFaceInfoIn(nF2);
+ }
+ //
aBAS1.Initialize(aF1, Standard_False);
aBAS2.Initialize(aF2, Standard_False);
- //
if (aBAS1.GetType() == GeomAbs_Plane &&
aBAS2.GetType() == GeomAbs_Plane) {
Standard_Boolean bToIntersect;
//
- if (aMI.Add(nF1)) {
- myDS->UpdateFaceInfoOn(nF1);
- myDS->UpdateFaceInfoIn(nF1);
- }
- if (aMI.Add(nF2)) {
- myDS->UpdateFaceInfoOn(nF2);
- myDS->UpdateFaceInfoIn(nF2);
- }
- //
bToIntersect = CheckPlanes(nF1, nF2);
if (!bToIntersect) {
myDS->AddInterf(nF1, nF2);
const TopoDS_Edge& aE = *(TopoDS_Edge*)&myDS->Shape(nE);
aTolE = BRep_Tool::Tolerance(aE);
if (aTolR3D > aTolE) {
- myDS->UpdateEdgeTolerance(nE, aTolR3D);
+ UpdateEdgeTolerance(nE, aTolR3D);
}
bInBothFaces = Standard_False;
- } else {
+ }
+ else {
bInBothFaces = (aFI1.PaveBlocksOn().Contains(aPBOut) ||
aFI1.PaveBlocksIn().Contains(aPBOut))&&
(aFI2.PaveBlocksOn().Contains(aPBOut) ||
//
BOPCol_ListOfShape aLS(theAllocator);
BOPAlgo_PaveFiller aPF(theAllocator);
+ aPF.SetIsPrimary(Standard_False);
+ aPF.SetNonDestructive(myNonDestructive);
//
BOPDS_VectorOfInterfFF& aFFs=myDS->InterfFF();
//
//function : IsExistingVertex
//purpose :
//=======================================================================
- Standard_Boolean BOPAlgo_PaveFiller::IsExistingVertex
- (const gp_Pnt& aP,
- const Standard_Real theTolR3D,
- const BOPCol_MapOfInteger& aMVOnIn)const
+Standard_Boolean BOPAlgo_PaveFiller::IsExistingVertex
+ (const gp_Pnt& aP,
+ const Standard_Real theTolR3D,
+ const BOPCol_MapOfInteger& aMVOnIn)const
{
Standard_Boolean bRet;
Standard_Integer nV, iFlag;
//function : IsExistingPaveBlock
//purpose :
//=======================================================================
- Standard_Boolean BOPAlgo_PaveFiller::IsExistingPaveBlock
- (const Handle(BOPDS_PaveBlock)& thePB,
- const BOPDS_Curve& theNC,
- const Standard_Real theTolR3D,
- const BOPCol_ListOfInteger& theLSE)
+Standard_Boolean BOPAlgo_PaveFiller::IsExistingPaveBlock
+ (const Handle(BOPDS_PaveBlock)& thePB,
+ const BOPDS_Curve& theNC,
+ const Standard_Real theTolR3D,
+ const BOPCol_ListOfInteger& theLSE)
{
Standard_Boolean bRet=Standard_True;
//
aItLI.Initialize(theLSE);
for (; aItLI.More(); aItLI.Next()) {
nE=aItLI.Value();
+ if (nE < 0)
+ continue;
const BOPDS_ShapeInfo& aSIE=myDS->ChangeShapeInfo(nE);
const Bnd_Box& aBoxE=aSIE.Box();
if (!aBoxE.IsOut(aBoxPm)) {
const Handle(BOPDS_PaveBlock)& aPB = theMPBOnIn(i);
aPB->Indices(nV21, nV22);
nSp=aPB->Edge();
+ if (nSp < 0)
+ continue;
const BOPDS_ShapeInfo& aSISp=myDS->ChangeShapeInfo(nSp);
const TopoDS_Edge& aSp=(*(TopoDS_Edge *)(&aSISp.Shape()));
const Bnd_Box& aBoxSp=aSISp.Box();
//function : GetEFPnts
//purpose :
//=======================================================================
- void BOPAlgo_PaveFiller::GetEFPnts(const Standard_Integer nF1,
- const Standard_Integer nF2,
- IntSurf_ListOfPntOn2S& aListOfPnts)
+void BOPAlgo_PaveFiller::GetEFPnts
+ (const Standard_Integer nF1,
+ const Standard_Integer nF2,
+ IntSurf_ListOfPntOn2S& aListOfPnts)
{
Standard_Integer nE, nF, nFOpposite, aNbEFs, i;
Standard_Real U1, U2, V1, V2, f, l;
//function : GetStickVertices
//purpose :
//=======================================================================
- void BOPAlgo_PaveFiller::GetStickVertices(const Standard_Integer nF1,
- const Standard_Integer nF2,
- BOPCol_MapOfInteger& aMVStick,
- BOPCol_MapOfInteger& aMVEF,
- BOPCol_MapOfInteger& aMI)
+void BOPAlgo_PaveFiller::GetStickVertices(const Standard_Integer nF1,
+ const Standard_Integer nF2,
+ BOPCol_MapOfInteger& aMVStick,
+ BOPCol_MapOfInteger& aMVEF,
+ BOPCol_MapOfInteger& aMI)
{
Standard_Integer nS1, nS2, nVNew, aTypeInt, i;
//
//function : ProcessOldPaveBlocks
//purpose :
//=======================================================================
- void BOPAlgo_PaveFiller::ProcessExistingPaveBlocks
+void BOPAlgo_PaveFiller::ProcessExistingPaveBlocks
(const Standard_Integer theInt,
const BOPDS_IndexedMapOfPaveBlock& aMPBOnIn,
const BOPCol_DataMapOfIntegerListOfInteger& aDMBV,
//function : UpdateExistingPaveBlocks
//purpose :
//=======================================================================
- void BOPAlgo_PaveFiller::UpdateExistingPaveBlocks
- (const Handle(BOPDS_PaveBlock)& aPBf,
- BOPDS_ListOfPaveBlock& aLPB,
- const Standard_Integer nF1,
- const Standard_Integer nF2)
+void BOPAlgo_PaveFiller::UpdateExistingPaveBlocks
+ (const Handle(BOPDS_PaveBlock)& aPBf,
+ BOPDS_ListOfPaveBlock& aLPB,
+ const Standard_Integer nF1,
+ const Standard_Integer nF2)
{
Standard_Integer nE;
Standard_Boolean bCB;
// function: PutClosingPaveOnCurve
// purpose:
//=======================================================================
- void BOPAlgo_PaveFiller::PutClosingPaveOnCurve(BOPDS_Curve& aNC)
+void BOPAlgo_PaveFiller::PutClosingPaveOnCurve(BOPDS_Curve& aNC)
{
Standard_Boolean bIsClosed, bHasBounds, bAdded;
Standard_Integer nVC, j;
//function : PreparePostTreatFF
//purpose :
//=======================================================================
- void BOPAlgo_PaveFiller::PreparePostTreatFF
+void BOPAlgo_PaveFiller::PreparePostTreatFF
(const Standard_Integer aInt,
const Standard_Integer aCur,
const Handle(BOPDS_PaveBlock)& aPB,
aTolFF = Max(aTolFF, 5.e-6);
}
}
+//=======================================================================
+//function : UpdateBlocksWithSharedVertices
+//purpose :
+//=======================================================================
+void BOPAlgo_PaveFiller::UpdateBlocksWithSharedVertices()
+{
+ if (!myNonDestructive) {
+ return;
+ }
+ //
+ myErrorStatus=0;
+ //
+ Standard_Integer aNbFF;
+ //
+ BOPDS_VectorOfInterfFF& aFFs=myDS->InterfFF();
+ aNbFF=aFFs.Extent();
+ if (!aNbFF) {
+ return;
+ }
+ //
+ Standard_Boolean bOnCurve, bHasShapeSD;
+ Standard_Integer i, nF1, nF2, aNbC, j, nV, nVSD;
+ Standard_Real aTolR3D, aTolV;
+ BOPCol_MapOfInteger aMF;
+ //
+ for (i=0; i<aNbFF; ++i) {
+ BOPDS_InterfFF& aFF=aFFs(i);
+ //
+ BOPDS_VectorOfCurve& aVC=aFF.ChangeCurves();
+ aNbC=aVC.Extent();
+ if (!aNbC) {
+ continue;
+ }
+ //
+ aFF.Indices(nF1, nF2);
+ aTolR3D=aFF.TolR3D();
+ //
+ if (aMF.Add(nF1)) {
+ myDS->UpdateFaceInfoOn(nF1);
+ }
+ if (aMF.Add(nF2)) {
+ myDS->UpdateFaceInfoOn(nF2);
+ }
+ //
+ // Collect old vertices that are shared for nF1, nF2 ->aMI;
+ BOPCol_MapOfInteger aMI;
+ BOPCol_MapIteratorOfMapOfInteger aItMI;
+ //
+ BOPDS_FaceInfo& aFI1=myDS->ChangeFaceInfo(nF1);
+ BOPDS_FaceInfo& aFI2=myDS->ChangeFaceInfo(nF2);
+ //
+ const BOPCol_MapOfInteger& aMVOn1=aFI1.VerticesOn();
+ const BOPCol_MapOfInteger& aMVIn1=aFI1.VerticesIn();
+ const BOPCol_MapOfInteger& aMVOn2=aFI2.VerticesOn();
+ const BOPCol_MapOfInteger& aMVIn2=aFI2.VerticesIn();
+ //
+ for (j=0; j<2; ++j) {
+ const BOPCol_MapOfInteger& aMV1=(!j) ? aMVOn1 : aMVIn1;
+ aItMI.Initialize(aMV1);
+ for (; aItMI.More(); aItMI.Next()) {
+ nV=aItMI.Value();
+ if (myDS->IsNewShape(nV)) {
+ continue;
+ }
+ if (aMVOn2.Contains(nV) || aMVIn2.Contains(nV)) {
+ aMI.Add(nV);
+ }
+ }
+ }
+ //
+ // Try to put vertices aMI on curves
+ for (j=0; j<aNbC; ++j) {
+ BOPDS_Curve& aNC=aVC.ChangeValue(j);
+ //const IntTools_Curve& aIC=aNC.Curve();
+ //
+ aItMI.Initialize(aMI);
+ for (; aItMI.More(); aItMI.Next()) {
+ nV=aItMI.Value();
+ //
+ bHasShapeSD=myDS->HasShapeSD(nV, nVSD);
+ if (bHasShapeSD) {
+ continue;
+ }
+ //
+ bOnCurve=EstimatePaveOnCurve(nV, aNC, aTolR3D);
+ if (!bOnCurve) {
+ continue;
+ }
+ //
+ const TopoDS_Vertex& aV=*((TopoDS_Vertex *)&myDS->Shape(nV));
+ aTolV=BRep_Tool::Tolerance(aV);
+ //
+ UpdateVertex(nV, aTolV);
+ }
+ }//for (j=0; j<aNbC; ++j) {
+ }//for (i=0; i<aNbFF; ++i) {
+ //
+ UpdateCommonBlocksWithSDVertices();
+}
+//=======================================================================
+//function : EstimatePaveOnCurve
+//purpose :
+//=======================================================================
+Standard_Boolean BOPAlgo_PaveFiller::EstimatePaveOnCurve
+ (const Standard_Integer nV,
+ BOPDS_Curve& aNC,
+ const Standard_Real aTolR3D)
+{
+ Standard_Boolean bIsVertexOnLine;
+ Standard_Real aT;
+ //
+ const TopoDS_Vertex& aV=*((TopoDS_Vertex *)&myDS->Shape(nV));
+ const IntTools_Curve& aIC=aNC.Curve();
+ //
+ bIsVertexOnLine=myContext->IsVertexOnLine(aV, aIC, aTolR3D, aT);
+ return bIsVertexOnLine;
+}
#include <BOPDS_MapOfPaveBlock.hxx>
#include <BOPDS_Curve.hxx>
#include <BOPDS_Iterator.hxx>
+#include <Precision.hxx>
+#include <BOPDS_MapOfCommonBlock.hxx>
#include <BOPTools_AlgoTools.hxx>
#include <BOPTools_AlgoTools2D.hxx>
Standard_Boolean bCB, bV1, bV2;
Standard_Integer i, nE, nV1, nV2, nSp, aNbPB, aNbVBSE, k;
Standard_Real aT1, aT2;
- BOPDS_ListIteratorOfListOfPaveBlock aItPB, aItPBCB;
+ BOPDS_ListIteratorOfListOfPaveBlock aItPB;
Handle(BOPDS_PaveBlock) aPB;
BOPDS_MapOfPaveBlock aMPB(100);
TopoDS_Vertex aV1, aV2;
TopoDS_Edge aE;
BOPAlgo_VectorOfSplitEdge aVBSE;
+ //
+ UpdateCommonBlocksWithSDVertices();
+ //
+ aNbPBP=aPBP.Extent();
//
for (i=0; i<aNbPBP; ++i) {
BOPDS_ListOfPaveBlock& aLPB=aPBP(i);
aPB->Indices(nV1, nV2);
bV1=myDS->IsNewShape(nV1);
bV2=myDS->IsNewShape(nV2);
+ bCB=myDS->IsCommonBlock(aPB);
//
- if (!(bV1 || bV2)) {
- nE=aPB->OriginalEdge();
- aPB->SetEdge(nE);
- continue;
+ if (!(bV1 || bV2)) { // no new vertices here
+ if (!myNonDestructive || (myNonDestructive && !bCB)) {
+ nE=aPB->OriginalEdge();
+ aPB->SetEdge(nE);
+ continue;
+ }
}
}
//
aItPB.Initialize(aLPB);
for (; aItPB.More(); aItPB.Next()) {
aPB=aItPB.Value();
+ nE=aPB->OriginalEdge();
+ const BOPDS_ShapeInfo& aSIE=myDS->ShapeInfo(nE);
+ if (aSIE.HasFlag()){
+ continue;
+ }
+ //
const Handle(BOPDS_CommonBlock)& aCB=myDS->CommonBlock(aPB);
bCB=!aCB.IsNull();
if (bCB) {
nSp=myDS->Append(aSI);
//
if (!aCBk.IsNull()) {
+ Standard_Real aTolCB = ComputeTolerance(aCBk);
+ myDS->UpdateEdgeTolerance(nSp, aTolCB);
aCBk->SetEdge(nSp);
}
else {
}
}
//=======================================================================
+//function : ComputeTolerance
+//purpose :
+//=======================================================================
+Standard_Real BOPAlgo_PaveFiller::ComputeTolerance
+ (const Handle(BOPDS_CommonBlock)& theCB)
+{
+ Standard_Integer nE, nF;
+ Standard_Real aTol, aTolMax;
+ BOPDS_ListIteratorOfListOfPaveBlock aItPB;
+ BOPCol_ListIteratorOfListOfInteger aItLI;
+ //
+ const Handle(BOPDS_PaveBlock)& aPBR = theCB->PaveBlock1();
+ nE = aPBR->OriginalEdge();
+ const TopoDS_Edge& aEOr = *(TopoDS_Edge*)&myDS->Shape(nE);
+ aTolMax = BRep_Tool::Tolerance(aEOr);
+ //
+ const BOPDS_ListOfPaveBlock& aLPB = theCB->PaveBlocks();
+ aItPB.Initialize(aLPB);
+ for (; aItPB.More(); aItPB.Next()) {
+ const Handle(BOPDS_PaveBlock)& aPB = aItPB.Value();
+ if (aPB == aPBR) {
+ continue;
+ }
+ //
+ nE = aPB->OriginalEdge();
+ const TopoDS_Edge& aE = *(TopoDS_Edge*)&myDS->Shape(nE);
+ aTol = BRep_Tool::Tolerance(aE);
+ if (aTol > aTolMax) {
+ aTolMax=aTol;
+ }
+ }
+ //
+ const BOPCol_ListOfInteger& aLFI = theCB->Faces();
+ aItLI.Initialize(aLFI);
+ for (; aItLI.More(); aItLI.Next()) {
+ nF = aItLI.Value();
+ const TopoDS_Face& aF = *(TopoDS_Face*)&myDS->Shape(nF);
+ //
+ aTol=BRep_Tool::Tolerance(aF);
+ if (aTol > aTolMax) {
+ aTolMax=aTol;
+ }
+ }
+ return aTolMax;
+}
+//=======================================================================
// function: SplitEdge
// purpose:
//=======================================================================
//=======================================================================
void BOPAlgo_PaveFiller::Prepare()
{
+ if (myNonDestructive) {
+ // do not allow storing pcurves in original edges if non-destructive mode is on
+ return;
+ }
TopAbs_ShapeEnum aType[] = {
TopAbs_VERTEX,
TopAbs_EDGE,
const BOPCol_ListOfShape& myEdges=aCB.Shapes();
//
// 1.Filling mySmartMap
- BOPTools_AlgoTools2D::BuildPCurveForEdgesOnPlane(myEdges, myFace);
- //
aIt.Initialize(myEdges);
for(; aIt.More(); aIt.Next()) {
const TopoDS_Edge& aE=(*(TopoDS_Edge *)&aIt.Value());
BOPAlgo_Builder_4.cxx
BOPAlgo_WireSplitter_1.cxx
BOPAlgo_ListOfCheckResult.hxx
-
-
+BOPAlgo_PaveFiller_11.cxx
ListOfInteger from BOPCol,
MapOfInteger from BOPCol,
BaseAllocator from BOPCol,
+ DataMapOfIntegerListOfInteger from BOPCol,
--
ShapeInfo from BOPDS,
IndexRange from BOPDS,
---Purpose:
--- Updates tolerance of the sub-shapes of the shape with index <theIndex>.
---
-
+ UpdatePaveBlocksWithSDVertices(me:out);
+
+ UpdatePaveBlockWithSDVertices(me:out;
+ thePB:PaveBlock from BOPDS);
+
+ UpdateCommonBlockWithSDVertices(me:out;
+ theCB:CommonBlock from BOPDS);
+
+ InitPaveBlocksForVertex(me:out;
+ theNV:Integer from Standard);
+
BuildBndBoxSolid (me:out;
theIndex:Integer from Standard;
theBox:out Box from Bnd)
--same domain shapes
myShapesSD : DataMapOfIntegerInteger from BOPCol is protected;
--
+ myMapVE: DataMapOfIntegerListOfInteger from BOPCol is protected;
+ --
--interferences
myInterfTB : MapOfPassKey from BOPDS is protected;
myInterfVV : VectorOfInterfVV from BOPDS is protected;
#include <IntTools_Tools.hxx>
#include <BOPTools_AlgoTools.hxx>
#include <GeomAPI_ProjectPointOnCurve.hxx>
+#include <BOPCol_MapOfShape.hxx>
+#include <BOPCol_DataMapOfIntegerListOfInteger.hxx>
#include <algorithm>
//
-static
- inline void ResetShape(const TopoDS_Shape& aS);
-
-static
- inline void ResetShapes(const TopoDS_Shape& aS);
static
void TotalShapes(const TopoDS_Shape& aS,
- Standard_Integer& aNbS);
+ Standard_Integer& aNbS,
+ BOPCol_MapOfShape& aMS);
static
Standard_Real ComputeParameter(const TopoDS_Vertex& aV,
myMapPBCB(100, myAllocator),
myFaceInfoPool(0, myAllocator),
myShapesSD(100, myAllocator),
+ myMapVE(100, myAllocator),
myInterfTB(100, myAllocator),
myInterfVV(0, myAllocator),
myInterfVE(0, myAllocator),
myMapPBCB(100, myAllocator),
myFaceInfoPool(0, myAllocator),
myShapesSD(100, myAllocator),
+ myMapVE(100, myAllocator),
myInterfTB(100, myAllocator),
myInterfVV(0, myAllocator),
myInterfVE(0, myAllocator),
myPaveBlocksPool.Clear();
myFaceInfoPool.Clear();
myShapesSD.Clear();
+ myMapVE.Clear();
myMapPBCB.Clear();
myInterfTB.Clear();
myInterfVV.Clear();
}
return iRet;
}
-
//=======================================================================
//function : Init
//purpose :
BOPCol_ListIteratorOfListOfShape aIt;
BOPDS_IndexRange aR;
Handle(NCollection_BaseAllocator) aAllocator;
+ BOPCol_MapOfShape aMS;
//
// 1 Append Source Shapes
aNb=myArguments.Extent();
//
myRanges.SetIncrement(aNb);
//
- aIt.Initialize(myArguments);
- for (; aIt.More(); aIt.Next()) {
- const TopoDS_Shape& aSx=aIt.Value();
- ResetShapes(aSx);
- }
- //
aNbS=0;
aIt.Initialize(myArguments);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aSx=aIt.Value();
//
aNbSx=0;
- TotalShapes(aSx, aNbSx);
+ TotalShapes(aSx, aNbSx, aMS);
+ //
aNbS=aNbS+aNbSx;
}
+ aMS.Clear();
//
myLines.SetIncrement(2*aNbS);
//-----------------------------------------------------scope_1 f
BOPDS_ShapeInfo& aSI=ChangeShapeInfo(j);
//
const TopoDS_Shape& aS=aSI.Shape();
- ResetShape(aS);
//
aTS=aSI.ShapeType();
//
const Handle(BRep_TVertex)& TV =
*((Handle(BRep_TVertex)*)&aV.TShape());
aTol = TV->Tolerance();
- //
+ // TODO: non-destructive
myToleranceMap.Bind(j, aTol);
aTol += aFuzz;
TV->Tolerance(aTol);
const Handle(BRep_TEdge)& TE =
*((Handle(BRep_TEdge)*)&aE.TShape());
aTol = TE->Tolerance();
- //
+ // TODO: non-destructive
myToleranceMap.Bind(j, aTol);
aTol += aFuzz;
TE->Tolerance(aTol);
const Handle(BRep_TFace)& TF =
*((Handle(BRep_TFace)*)&aF.TShape());
aTol = TF->Tolerance();
- //
+ // TODO: non-destructive
myToleranceMap.Bind(j, aTol);
aTol += aFuzz;
TF->Tolerance(aTol);
}//for (j=0; j<myNbSourceShapes; ++j) {
//
aMI.Clear();
+ //-----------------------------------------------------
+ //
+ for (nE=0; nE<myNbSourceShapes; ++nE) {
+ BOPDS_ShapeInfo& aSI=ChangeShapeInfo(nE);
+ if (aSI.ShapeType()!=TopAbs_EDGE) {
+ continue;
+ }
+ //
+ const BOPCol_ListOfInteger& aLV=aSI.SubShapes();
+ aIt1.Initialize(aLV);
+ for (; aIt1.More(); aIt1.Next()) {
+ nV=aIt1.Value();
+ if (myMapVE.IsBound(nV)) {
+ BOPCol_ListOfInteger& aLE=myMapVE.ChangeFind(nV);
+ aLE.Append(nE);
+ }
+ else {
+ BOPCol_ListOfInteger aLE(myAllocator);
+ //
+ aLE.Append(nE);
+ myMapVE.Bind(nV, aLE);
+ }
+ }
+ }
+ //
+ BOPCol_DataMapIteratorOfDataMapOfIntegerListOfInteger aItDMILI;
+ aItDMILI.Initialize(myMapVE);
+ for(; aItDMILI.More(); aItDMILI.Next()) {
+ BOPCol_MapOfInteger aMFence;
+ BOPCol_ListOfInteger aLEx;
+ //
+ nV=aItDMILI.Key();
+ BOPCol_ListOfInteger& aLE=aItDMILI.ChangeValue();
+ aIt1.Initialize(aLE);
+ for (; aIt1.More(); aIt1.Next()) {
+ nE=aIt1.Value();
+ if(aMFence.Add(nE)) {
+ aLEx.Append(nE);
+ }
+ }
+ //
+ aLE.Clear();
+ aIt1.Initialize(aLEx);
+ for (; aIt1.More(); aIt1.Next()) {
+ nE=aIt1.Value();
+ aLE.Append(nE);
+ }
+ }
//-----------------------------------------------------scope_1 t
// 3 myPaveBlocksPool
// 4. myFaceInfoPool
}
return sLPB;
}
+
//=======================================================================
//function : ChangePaveBlocks
//purpose :
BOPDS_InterfVF& aVF=aVFs(i);
if(aVF.Contains(theF)) {
nV=aVF.OppositeIndex(theF);
+ if (HasShapeSD(nV, nVSD)) {
+ nV=nVSD;
+ }
theMI.Add(nV);
}
}
//purpose :
//=======================================================================
void BOPDS_DS::SharedEdges(const Standard_Integer nF1,
- const Standard_Integer nF2,
- BOPCol_ListOfInteger& theLI,
- const Handle(NCollection_BaseAllocator)& aAllocator)
+ const Standard_Integer nF2,
+ BOPCol_ListOfInteger& theLI,
+ const Handle(NCollection_BaseAllocator)& aAllocator)
{
Standard_Integer nE, nSp;
BOPCol_ListIteratorOfListOfInteger aItLI;
return bRet;
}
-
//=======================================================================
// function: Paves
// purpose:
theLP.Append(pPaves(i));
}
}
-
//=======================================================================
// function: UpdateTolerance
// purpose:
}
}
}
-
//=======================================================================
//function : TotalShapes
//purpose :
//=======================================================================
void TotalShapes(const TopoDS_Shape& aS,
- Standard_Integer& aNbS)
+ Standard_Integer& aNbS,
+ BOPCol_MapOfShape& aMS)
{
- TopoDS_Shape *pS;
- //
- pS=(TopoDS_Shape *)&aS;
- if (!pS->Checked()) {
+ if (aMS.Add(aS)) {
TopoDS_Iterator aIt;
- //
- pS->Checked(1);
++aNbS;
aIt.Initialize(aS);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aSx=aIt.Value();
- TotalShapes(aSx, aNbS);
+ TotalShapes(aSx, aNbS, aMS);
}
}
}
-//=======================================================================
-//function : ResetShape
-//purpose :
-//=======================================================================
-void ResetShape(const TopoDS_Shape& aS)
-{
- TopoDS_Shape *pS;
- //
- pS=(TopoDS_Shape *)&aS;
- pS->Checked(0);
-}
-//=======================================================================
-//function : ResetShape
-//purpose :
-//=======================================================================
-void ResetShapes(const TopoDS_Shape& aS)
-{
- TopoDS_Iterator aIt;
- //
- ResetShape(aS);
- aIt.Initialize(aS);
- for (; aIt.More(); aIt.Next()) {
- const TopoDS_Shape& aSx=aIt.Value();
- ResetShape(aSx);
- }
-}
+
//=======================================================================
//function : ComputeParameter
//purpose :
}
}
}
+
+//=======================================================================
+//function : UpdatePaveBlocksWithSDVertices
+//purpose :
+//=======================================================================
+void BOPDS_DS::UpdatePaveBlocksWithSDVertices()
+{
+ Standard_Integer i, aNbPBP;
+ BOPDS_ListIteratorOfListOfPaveBlock aItPB;
+ //
+ BOPDS_VectorOfListOfPaveBlock& aPBP=myPaveBlocksPool;
+ //
+ aNbPBP=aPBP.Size();
+ for (i = 0; i < aNbPBP; ++i) {
+ BOPDS_ListOfPaveBlock& aLPB = aPBP(i);
+ //
+ aItPB.Initialize(aLPB);
+ for (; aItPB.More(); aItPB.Next()) {
+ Handle(BOPDS_PaveBlock)& aPB = aItPB.ChangeValue();
+ UpdatePaveBlockWithSDVertices(aPB);
+ }// for (; aItPB.More(); aItPB.Next()) {
+ }// for (i = 0; i < aNbPBP; ++i) {
+}
+//=======================================================================
+//function : UpdatePaveBlockWithSDVertices
+//purpose :
+//=======================================================================
+void BOPDS_DS::UpdatePaveBlockWithSDVertices
+ (const Handle(BOPDS_PaveBlock)& thePB)
+{
+ Standard_Integer nV1, nV2;
+ BOPDS_Pave aPave1, aPave2;
+ //
+ aPave1 = thePB->Pave1();
+ aPave2 = thePB->Pave2();
+ //
+ nV1 = aPave1.Index();
+ nV2 = aPave2.Index();
+ //
+ if (HasShapeSD(nV1, nV1)) {
+ aPave1.SetIndex(nV1);
+ thePB->SetPave1(aPave1);
+ }
+ //
+ if (HasShapeSD(nV2, nV2)) {
+ aPave2.SetIndex(nV2);
+ thePB->SetPave2(aPave2);
+ }
+}
+//=======================================================================
+//function : UpdateCommonBlockWithSDVertices
+//purpose :
+//=======================================================================
+void BOPDS_DS::UpdateCommonBlockWithSDVertices
+ (const Handle(BOPDS_CommonBlock)& theCB)
+{
+ const BOPDS_ListOfPaveBlock& aLPB = theCB->PaveBlocks();
+ BOPDS_ListIteratorOfListOfPaveBlock aItPB(aLPB);
+ for (; aItPB.More(); aItPB.Next()) {
+ const Handle(BOPDS_PaveBlock)& aPB = aItPB.Value();
+ UpdatePaveBlockWithSDVertices(aPB);
+ }
+}
+//=======================================================================
+//function : InitPaveBlocksForVertex
+//purpose :
+//=======================================================================
+void BOPDS_DS::InitPaveBlocksForVertex(const Standard_Integer theNV)
+{
+ Standard_Integer nE;
+ BOPCol_ListIteratorOfListOfInteger aItLE;
+ //
+ if (myMapVE.IsBound(theNV)) {
+ const BOPCol_ListOfInteger& aLE=myMapVE.Find(theNV);
+ aItLE.Initialize(aLE);
+ for (; aItLE.More(); aItLE.Next()) {
+ nE=aItLE.Value();
+ ChangePaveBlocks(nE);
+ }
+ }
+}
theS :out Shape from TopoDS);
CorrectTolerances (myclass;
- theS: Shape from TopoDS;
- theTolMax: Real from Standard =0.0001;
- theRunParallel: Boolean from Standard=Standard_False);
-
+ theS: Shape from TopoDS;
+ theMapToAvoid:IndexedMapOfShape from BOPCol;
+ theTolMax: Real from Standard =0.0001;
+ theRunParallel: Boolean from Standard=Standard_False);
---Purpose:
-- Provides valid values of tolerances for the shape <theS>
-- <theTolMax> is max value of the tolerance that can be
-- perform.
CorrectCurveOnSurface (myclass;
- theS: Shape from TopoDS;
- theTolMax: Real from Standard =0.0001;
- theRunParallel: Boolean from Standard=Standard_False);
+ theS: Shape from TopoDS;
+ theMapToAvoid:IndexedMapOfShape from BOPCol;
+ theTolMax: Real from Standard =0.0001;
+ theRunParallel: Boolean from Standard=Standard_False);
---Purpose:
-- Provides valid values of tolerances for the shape <theS>
-- in terms of BRepCheck_InvalidCurveOnSurface.
CorrectPointOnCurve (myclass;
- theS: Shape from TopoDS;
- theTolMax: Real from Standard =0.0001;
- theRunParallel: Boolean from Standard=Standard_False);
+ theS: Shape from TopoDS;
+ theMapToAvoid:IndexedMapOfShape from BOPCol;
+ theTolMax: Real from Standard =0.0001;
+ theRunParallel: Boolean from Standard=Standard_False);
---Purpose:
-- Provides valid values of tolerances for the shape <theS>
-- in terms of BRepCheck_InvalidPointOnCurve.
-
+
MakeNewVertex (myclass;
aP1 : Pnt from gp;
aTol: Real from Standard;
CorrectShapeTolerances (myclass;
theS: Shape from TopoDS;
+ theMapToAvoid:IndexedMapOfShape from BOPCol;
theRunParallel: Boolean from Standard=Standard_False);
---Purpose:
-- Corrects tolerance values of the sub-shapes of the shape <theS> if needed.
static
void CheckEdge (const TopoDS_Edge& E,
- const Standard_Real aMaxTol);
+ const Standard_Real aMaxTol,
+ const BOPCol_IndexedMapOfShape& aMapToAvoid);
static
void CorrectEdgeTolerance (const TopoDS_Edge& myShape,
const TopoDS_Face& S,
- const Standard_Real aMaxTol);
+ const Standard_Real aMaxTol,
+ const BOPCol_IndexedMapOfShape& aMapToAvoid);
static
Standard_Boolean Validate(const Adaptor3d_Curve& CRef,
const Adaptor3d_Curve& Other,
Standard_Real& aNewTolerance);
static
- void CorrectVertexTolerance(const TopoDS_Edge& aE);
+ void CorrectVertexTolerance(const TopoDS_Edge& aE,
+ const BOPCol_IndexedMapOfShape& aMapToAvoid);
static
- void CorrectWires(const TopoDS_Face& aF);
+ void CorrectWires(const TopoDS_Face& aF,
+ const BOPCol_IndexedMapOfShape& aMapToAvoid);
static
- void UpdateEdges(const TopoDS_Face& aF);
+ void UpdateEdges(const TopoDS_Face& aF,
+ const BOPCol_IndexedMapOfShape& aMapToAvoid);
+
+static
+ void UpdateShape(const TopoDS_Shape& aS,
+ const Standard_Real aTol,
+ const BOPCol_IndexedMapOfShape& aMapToAvoid);
static
Standard_Real IntersectCurves2d(const gp_Pnt& aPV,
class BOPTools_CPC {
public:
BOPTools_CPC()
- : myMaxTol(1.e-7) {
+ : myMaxTol(1.e-7), mypMapToAvoid(0L) {
}
//
~BOPTools_CPC() {
return myMaxTol;
}
//
+ void SetMapToAvoid(const BOPCol_IndexedMapOfShape& aMapToAvoid) {
+ mypMapToAvoid = &aMapToAvoid;
+ }
+ //
void Perform() {
- CheckEdge(myEdge, myMaxTol);
+ Standard_ProgramError_Raise_if(!mypMapToAvoid, "mypMapToAvoid is null");
+ CheckEdge(myEdge, myMaxTol, *mypMapToAvoid);
}
protected:
Standard_Real myMaxTol;
TopoDS_Edge myEdge;
+ const BOPCol_IndexedMapOfShape* mypMapToAvoid;
};
//
//=======================================================================
//=======================================================================
class BOPTools_CWT {
public:
- BOPTools_CWT() {
+ BOPTools_CWT() : mypMapToAvoid(0L) {
}
//
~BOPTools_CWT() {
myFace=aF;
}
//
+ void SetMapToAvoid(const BOPCol_IndexedMapOfShape& aMapToAvoid) {
+ mypMapToAvoid = &aMapToAvoid;
+ }
+ //
void Perform() {
- CorrectWires(myFace);
+ Standard_ProgramError_Raise_if(!mypMapToAvoid, "mypMapToAvoid is null");
+ CorrectWires(myFace, *mypMapToAvoid);
}
//
protected:
TopoDS_Face myFace;
+ const BOPCol_IndexedMapOfShape* mypMapToAvoid;
};
//=======================================================================
typedef BOPCol_NCVector<BOPTools_CWT> BOPTools_VectorOfCWT;
class BOPTools_CDT {
public:
BOPTools_CDT()
- : myMaxTol(1.e-7) {
+ : myMaxTol(1.e-7), mypMapToAvoid(0L) {
}
//
~BOPTools_CDT() {
myMaxTol=aMaxTol;
}
//
+ void SetMapToAvoid(const BOPCol_IndexedMapOfShape& aMapToAvoid) {
+ mypMapToAvoid = &aMapToAvoid;
+ }
+ //
void Perform() {
- CorrectEdgeTolerance (myEdge, myFace, myMaxTol);
+ Standard_ProgramError_Raise_if(!mypMapToAvoid, "mypMapToAvoid is null");
+ CorrectEdgeTolerance (myEdge, myFace, myMaxTol, *mypMapToAvoid);
}
//
protected:
Standard_Real myMaxTol;
TopoDS_Edge myEdge;
TopoDS_Face myFace;
+ const BOPCol_IndexedMapOfShape* mypMapToAvoid;
};
//=======================================================================
typedef BOPCol_NCVector<BOPTools_CDT> BOPTools_VectorOfCDT;
//=======================================================================
class BOPTools_CVT {
public:
- BOPTools_CVT() {
+ BOPTools_CVT() : mypMapToAvoid(0L) {
}
//
~BOPTools_CVT() {
myEdge=aE;
}
//
+ void SetMapToAvoid(const BOPCol_IndexedMapOfShape& aMapToAvoid) {
+ mypMapToAvoid = &aMapToAvoid;
+ }
+ //
void Perform() {
- CorrectVertexTolerance(myEdge);
+ Standard_ProgramError_Raise_if(!mypMapToAvoid, "mypMapToAvoid is null");
+ CorrectVertexTolerance(myEdge, *mypMapToAvoid);
}
//
protected:
TopoDS_Edge myEdge;
+ const BOPCol_IndexedMapOfShape* mypMapToAvoid;
};
//
//=======================================================================
//=======================================================================
class BOPTools_CET {
public:
- BOPTools_CET() {
+ BOPTools_CET() : mypMapToAvoid(0L) {
}
//
~BOPTools_CET() {
myFace=aF;
}
//
+ void SetMapToAvoid(const BOPCol_IndexedMapOfShape& aMapToAvoid) {
+ mypMapToAvoid = &aMapToAvoid;
+ }
+ //
void Perform() {
- UpdateEdges(myFace);
+ Standard_ProgramError_Raise_if(!mypMapToAvoid, "mypMapToAvoid is null");
+ UpdateEdges(myFace, *mypMapToAvoid);
}
//
protected:
TopoDS_Face myFace;
+ const BOPCol_IndexedMapOfShape* mypMapToAvoid;
};
//=======================================================================
typedef BOPCol_NCVector<BOPTools_CET> BOPTools_VectorOfCET;
//=======================================================================
void BOPTools_AlgoTools::CorrectTolerances
(const TopoDS_Shape& aShape,
+ const BOPCol_IndexedMapOfShape& aMapToAvoid,
const Standard_Real aMaxTol,
const Standard_Boolean bRunParallel)
{
- BOPTools_AlgoTools::CorrectPointOnCurve(aShape, aMaxTol, bRunParallel);
- BOPTools_AlgoTools::CorrectCurveOnSurface(aShape, aMaxTol, bRunParallel);
+ BOPTools_AlgoTools::CorrectPointOnCurve(aShape, aMapToAvoid, aMaxTol, bRunParallel);
+ BOPTools_AlgoTools::CorrectCurveOnSurface(aShape, aMapToAvoid, aMaxTol, bRunParallel);
}
//
//=======================================================================
//=======================================================================
void BOPTools_AlgoTools::CorrectPointOnCurve
(const TopoDS_Shape& aS,
+ const BOPCol_IndexedMapOfShape& aMapToAvoid,
const Standard_Real aMaxTol,
const Standard_Boolean bRunParallel)
{
BOPTools_CPC& aCPC=aVCPC.Append1();
aCPC.SetEdge(aE);
aCPC.SetMaxTol(aMaxTol);
+ aCPC.SetMapToAvoid(aMapToAvoid);
}
//
//======================================================
//=======================================================================
void BOPTools_AlgoTools::CorrectCurveOnSurface
(const TopoDS_Shape& aS,
+ const BOPCol_IndexedMapOfShape& aMapToAvoid,
const Standard_Real aMaxTol,
const Standard_Boolean bRunParallel)
{
//
BOPTools_CWT& aCWT=aVCWT.Append1();
aCWT.SetFace(aF);
+ aCWT.SetMapToAvoid(aMapToAvoid);
//
aExpE.Init(aF, TopAbs_EDGE);
for (; aExpE.More(); aExpE.Next()) {
aCDT.SetEdge(aE);
aCDT.SetFace(aF);
aCDT.SetMaxTol(aMaxTol);
+ aCDT.SetMapToAvoid(aMapToAvoid);
}
}
//
//=======================================================================
void BOPTools_AlgoTools::CorrectShapeTolerances
(const TopoDS_Shape& aShape,
+ const BOPCol_IndexedMapOfShape& aMapToAvoid,
const Standard_Boolean bRunParallel)
{
TopExp_Explorer aExp;
const TopoDS_Edge& aE = *(TopoDS_Edge*)&aExp.Current();
BOPTools_CVT& aCVT=aVCVT.Append1();
aCVT.SetEdge(aE);
+ aCVT.SetMapToAvoid(aMapToAvoid);
}
//
//======================================================
const TopoDS_Face& aF = *(TopoDS_Face*)&aExp.Current();
BOPTools_CET& aCET=aVCET.Append1();
aCET.SetFace(aF);
+ aCET.SetMapToAvoid(aMapToAvoid);
}
//
//======================================================
// purpose : Correct tolerances for Vertices on Edge
//=======================================================================
void CheckEdge (const TopoDS_Edge& Ed,
- const Standard_Real aMaxTol)
+ const Standard_Real aMaxTol,
+ const BOPCol_IndexedMapOfShape& aMapToAvoid)
{
Standard_Real aTolE, aTol, aD2, aNewTolerance, dd;
gp_Pnt aPC;
if (aD2 > aTol) {
aNewTolerance=sqrt(aD2)+dd;
if (aNewTolerance<aMaxTol)
- TV->UpdateTolerance(aNewTolerance);
+ UpdateShape(aV, aNewTolerance, aMapToAvoid);
}
}
aItPR.Next();
if (aD2 > aTol) {
aNewTolerance=sqrt(aD2)+dd;
if (aNewTolerance<aMaxTol)
- TV->UpdateTolerance(aNewTolerance);
+ UpdateShape(aV, aNewTolerance, aMapToAvoid);
}
}
}
// Function : CorrectWires
// purpose :
//=======================================================================
-void CorrectWires(const TopoDS_Face& aFx)
+void CorrectWires(const TopoDS_Face& aFx,
+ const BOPCol_IndexedMapOfShape& aMapToAvoid)
{
Standard_Boolean bIsPeriodic;
Standard_Integer i, aNbV;
}// for (; aIt1.More(); aIt1.Next()) {
}// for (; aIt.More(); aIt.Next()) {
if (aD2max>aTol2) {
- BRep_Builder aBB;
- //
aTol=sqrt(aD2max);
- aBB.UpdateVertex(aV, aTol);
+ UpdateShape(aV, aTol, aMapToAvoid);
}
}// for (i=1; i<=aNbV; ++i) {
}
//=======================================================================
void CorrectEdgeTolerance (const TopoDS_Edge& myShape,
const TopoDS_Face& S,
- const Standard_Real aMaxTol)
+ const Standard_Real aMaxTol,
+ const BOPCol_IndexedMapOfShape& aMapToAvoid)
{
//
// 1. Minimum of conditions to Perform
Tol, SameParameter, aNewTol);
if (ok) {
if (aNewTol<aMaxTol) {
- TE->UpdateTolerance(aNewTol+Delta);
- //
- CorrectVertexTolerance(myShape);
+ UpdateShape(myShape, aNewTol+Delta, aMapToAvoid);
+ CorrectVertexTolerance(myShape, aMapToAvoid);
}
}
ok = Validate(myHCurve->Curve(),ACS,Tol,SameParameter, aNewTol);
if (ok) {
if (aNewTol<aMaxTol) {
- TE->UpdateTolerance(aNewTol+Delta);
- CorrectVertexTolerance(myShape);
+ UpdateShape(myShape, aNewTol+Delta, aMapToAvoid);
+ CorrectVertexTolerance(myShape, aMapToAvoid);
}
}
}
Tol,Standard_True, aNewTol);
if (okx) {
if (aNewTol<aMaxTol) {
- TE->UpdateTolerance(aNewTol+Delta);
- CorrectVertexTolerance(myShape);
+ UpdateShape(myShape, aNewTol+Delta, aMapToAvoid);
+ CorrectVertexTolerance(myShape, aMapToAvoid);
}
}
}
//function : CorrectVertexTolerance
//purpose :
//=======================================================================
-void CorrectVertexTolerance(const TopoDS_Edge& aE)
+void CorrectVertexTolerance(const TopoDS_Edge& aE,
+ const BOPCol_IndexedMapOfShape& aMapToAvoid)
{
Standard_Real aTolE, aTolV;
TopoDS_Iterator aIt;
const TopoDS_Vertex& aV=*((TopoDS_Vertex*)&aIt.Value());
aTolV=BRep_Tool::Tolerance(aV);
if (aTolV<aTolE) {
- Handle(BRep_TVertex)& aTV= *((Handle(BRep_TVertex)*)&aV.TShape());
- aTV->UpdateTolerance(aTolE);
+ UpdateShape(aV, aTolE, aMapToAvoid);
}
}
}
// Function : UpdateEdges
// purpose :
//=======================================================================
-void UpdateEdges(const TopoDS_Face& aF)
+void UpdateEdges(const TopoDS_Face& aF,
+ const BOPCol_IndexedMapOfShape& aMapToAvoid)
{
Standard_Real aTolF, aTolE, aTolV;
TopoDS_Iterator aItF, aItW, aItE;
- BRep_Builder aBB;
//
aTolE=aTolF= BRep_Tool::Tolerance(aF);
aItF.Initialize(aF);
const TopoDS_Edge& aE=*((TopoDS_Edge*)&aItW.Value());
aTolE = BRep_Tool::Tolerance(aE);
if (aTolE < aTolF) {
- aBB.UpdateEdge(aE, aTolF);
+ UpdateShape(aE, aTolF, aMapToAvoid);
aTolE = aTolF;
}
- //UpdateVertices(aE);
}
}
else {
const TopoDS_Vertex& aV=*(TopoDS_Vertex*)&aItF.Value();
aTolV = BRep_Tool::Tolerance(aV);
if (aTolV < aTolE) {
- aBB.UpdateVertex(aV, aTolF);
+ UpdateShape(aV, aTolF, aMapToAvoid);
}
}
}
}
//=======================================================================
+//function : UpdateShape
+//purpose :
+//=======================================================================
+void UpdateShape(const TopoDS_Shape& aS,
+ const Standard_Real aTol,
+ const BOPCol_IndexedMapOfShape& aMapToAvoid)
+{
+ if (aMapToAvoid.Contains(aS)) {
+ return;
+ }
+ //
+ TopAbs_ShapeEnum aType;
+ BRep_Builder aBB;
+ //
+ aType=aS.ShapeType();
+ if (aType==TopAbs_EDGE) {
+ const TopoDS_Edge& aE = *((TopoDS_Edge*)&aS);
+ aBB.UpdateEdge(aE, aTol);
+ }
+ else if (aType==TopAbs_VERTEX) {
+ const TopoDS_Vertex& aV = *((TopoDS_Vertex*)&aS);
+ aBB.UpdateVertex(aV, aTol);
+ }
+}
+//=======================================================================
// Function : ComputeTolerance
// purpose :
//=======================================================================
--- 2. the edge does not contain 3d curve and pcurves (-2)
--- 3. projection algorithm failed (-3)
---
-
+
+ ComputeVE (me:mutable;
+ aV : Vertex from TopoDS;
+ aE : Edge from TopoDS;
+ aT :out Real from Standard;
+ aTolVnew:out Real from Standard)
+ returns Integer from Standard;
+ ---Purpose:
+ --- Computes parameter of the vertex aV on
+ --- the edge aE.
+ --- Returns zero if the distance between vertex
+ --- and edge is less than sum of tolerances,
+ --- otherwise and for following conditions returns
+ --- negative value
+ --- 1. the edge is degenerated (-1)
+ --- 2. the edge does not contain 3d curve and pcurves (-2)
+ --- 3. projection algorithm failed (-3)
+
ComputeVF (me:mutable;
aV : Vertex from TopoDS;
aF : Face from TopoDS;
--- 2. distance is more than sum of tolerances (-2)
--- 3. projection point out or on the boundaries of face (-3)
---
+
+ ComputeVF (me:mutable;
+ aV : Vertex from TopoDS;
+ aF : Face from TopoDS;
+ U : out Real from Standard;
+ V : out Real from Standard;
+ aTolVnew:out Real from Standard)
+ returns Integer from Standard;
+ ---Purpose:
+ --- Computes UV parameters of the vertex aV on face aF
+ --- Returns zero if the distance between vertex and face is
+ --- less than or equal the sum of tolerances and the projection
+ --- point lays inside boundaries of the face.
+ --- For following conditions returns negative value
+ --- 1. projection algorithm failed (-1)
+ --- 2. distance is more than sum of tolerances (-2)
+ --- 3. projection point out or on the boundaries of face (-3)
StatePointFace(me:mutable;
aF : Face from TopoDS;
(const TopoDS_Vertex& aV1,
const TopoDS_Edge& aE2,
Standard_Real& aT)
+{
+ Standard_Real aTolVnew;
+ //
+ return ComputeVE(aV1, aE2, aT, aTolVnew);
+}
+//=======================================================================
+//function : ComputeVE
+//purpose :
+//=======================================================================
+Standard_Integer IntTools_Context::ComputeVE
+ (const TopoDS_Vertex& aV1,
+ const TopoDS_Edge& aE2,
+ Standard_Real& aT,
+ Standard_Real& aTolVnew)
{
if (BRep_Tool::Degenerated(aE2)) {
return -1;
aTolE2=BRep_Tool::Tolerance(aE2);
aTolSum = aTolV1 + aTolE2 + Precision::Confusion();
//
+ aTolVnew=aDist+aTolE2;
+ //
aT=aProjector.LowerDistanceParameter();
if (aDist > aTolSum) {
return -4;
return 0;
}
//=======================================================================
-//function : ComputeVS
+//function : ComputeVF
//purpose :
//=======================================================================
Standard_Integer IntTools_Context::ComputeVF
const TopoDS_Face& aF2,
Standard_Real& U,
Standard_Real& V)
+{
+ Standard_Real aTolVnew;
+ //
+ return ComputeVF(aV1, aF2, U, V, aTolVnew);
+}
+//=======================================================================
+//function : ComputeVF
+//purpose :
+//=======================================================================
+Standard_Integer IntTools_Context::ComputeVF
+ (const TopoDS_Vertex& aV1,
+ const TopoDS_Face& aF2,
+ Standard_Real& U,
+ Standard_Real& V,
+ Standard_Real& aTolVnew)
{
Standard_Real aTolV1, aTolF2, aTolSum, aDist;
gp_Pnt aP;
aTolV1=BRep_Tool::Tolerance(aV1);
aTolF2=BRep_Tool::Tolerance(aF2);
- aTolSum=aTolV1+aTolF2;
+ //
+ aTolSum=aTolV1 + aTolF2 + Precision::Confusion();
+ aTolVnew=aDist+aTolF2;
+ //
if (aDist > aTolSum) {
// the distance is too large
return -2;
return;
}
//
- aTol1 = aTolV1+aTolE;
- aTol2 = aTolV2+aTolE;
+ //aTol1 = aTolV1+aTolE;
+ //aTol2 = aTolV2+aTolE;
+ aTol1 = Max(aTolV1, aTolE);
+ aTol2 = Max(aTolV2, aTolE);
//
aCoeff1 = (aTolE>0.05) ? 1. : 2.;
aCoeff2 = aCoeff1;
}
int aNbEnters = 0;
- Standard_Real aPerfMeter_CPUtime = 0., aTimer_ElapsedTime = aTM.ElapsedTime();
+ Standard_Real aPerfMeter_CPUtime = 0., aTimer_CPUTime = 0., aS;
+ Standard_Integer aM, aH;
+ aTM.Show(aS, aM, aH, aTimer_CPUTime);
perf_get_meter("TestMeter", &aNbEnters, &aPerfMeter_CPUtime);
+ perf_init_meter("TestMeter");
- Standard_Real aTimeDiff = (fabs(aTimer_ElapsedTime - aPerfMeter_CPUtime) / aTimer_ElapsedTime);
+ Standard_Real aTimeDiff = (fabs(aTimer_CPUTime - aPerfMeter_CPUtime) / aTimer_CPUTime);
printf("\nMeasurement results (%d cycles):\n", count);
- printf("\nOSD_PerfMeter CPU time: %lf\nOSD_Timer elapsed time: %lf\n", aPerfMeter_CPUtime, aTimer_ElapsedTime);
+ printf("\nOSD_PerfMeter CPU time: %lf\nOSD_Timer CPU time: %lf\n",
+ aPerfMeter_CPUtime, aTimer_CPUTime);
printf("Time delta is: %.3lf %%\n", aTimeDiff * 100);
if (aTimeDiff > 0.2)
}
else
{
- theDI << "Info. Faulty shape if found in source shape\n";
+ theDI << "Info. Faulty shape is found in source shape\n";
}
}
}
}
else
{
- theDI << "Error. Problems are not detected. Test is not performed.";
+ theDI << "Problems are not detected. Test is not performed.";
}
return 0;
-puts "TODO #23876 ALL: Error : The bopcut cannot be built."
-
restore [locate_data_file case_9_edge.brep] a
restore [locate_data_file case_9_wire3.brep] b
settolerance a 0.1
puts "TODO OCC26018 ALL: Error : The area of the resulting shape is"
-puts "TODO OCC26018 Linux: Faulty shapes in variables faulty_1 to faulty_"
+puts "TODO OCC26018 ALL: Faulty shapes in variables faulty_1 to faulty_"
source [locate_data_file 20000_et3_401-ta6037.prt.2.gdml.tcl]
## image is differ from application
-puts "TODO ?OCC26017 Windows: Faulty shapes in variables faulty_1 to faulty_"
-puts "TODO ?OCC26017 Windows: Error : The area of the resulting shape is"
+puts "TODO ?OCC26017 ALL: Faulty shapes in variables faulty_1 to faulty_"
+puts "TODO ?OCC26017 ALL: Error : The area of the resulting shape is"
puts "TODO ?OCC26017 ALL: Error : The gdml is not valid. The area is"
source [locate_data_file 20000_et4_401-ta6319.prt.2.gdml.tcl]
puts "TODO OCC26020 ALL: Error: bopcheck failed"
puts "TODO OCC26020 Linux: Faulty shapes in variables faulty_1 to faulty_"
-puts "TODO OCC26020 Linux: Error : The area of the resulting shape is"
+puts "TODO OCC26020 ALL: Error : The area of the resulting shape is"
# planar face
plane pln_f1 590.6877421677151 -519.8775759738943 -93.555747452441423 0.64798185367609173 0.7547095802227719 -0.10263024323494339
puts "TODO OCC25917 ALL: Faulty shapes in variables faulty_1 to faulty_"
puts "TODO OCC25917 ALL: Error : The square of result shape is"
-if { [regexp {Debug mode} [dversion]] } {
- puts "TODO OCC25917 ALL: TEST INCOMPLETE"
- puts "TODO OCC25917 ALL: Tcl Exception"
-}
puts "========================"
puts " OCC472 "
-puts "TODO OCC25917 ALL: Error : The command is not valid. The square is"
-if { [regexp {Debug mode} [dversion]] } {
- puts "TODO OCC25917 ALL: TEST INCOMPLETE"
- puts "TODO OCC25917 ALL: Tcl Exception"
-}
+puts "TODO OCC25917 ALL: Faulty shapes in variables faulty_1 to faulty_"
+puts "TODO OCC25917 ALL: Error : The square of result shape is"
puts "========================"
puts " OCC472 "
puts "TODO OCC25917 ALL: Faulty shapes in variables faulty_1 to faulty_"
-if { [regexp {Debug mode} [dversion]] } {
- puts "TODO OCC25917 ALL: TEST INCOMPLETE"
- puts "TODO OCC25917 ALL: Tcl Exception"
-}
-
puts "========================"
puts " OCC472 "
puts "(case 3)"
bfuse result b1 b2
-set nb_v_good 66
-set nb_e_edge 107
-set square 31657.5
+set square 229.516
set 2dviewer 0
pload QAcommands
restore [locate_data_file bug25043.brep] a
+subshape a v 3
+settolerance a_3 0.0005
decho off
set info [OCC25043 a]
decho on
-if { [regexp "Faulty shape if found in source shape" ${info}] == 1 } {
+if { [regexp "Faulty shape is found in source shape" ${info}] == 1 } {
puts "OK : Good result"
-} else {
+} elseif { [regexp "Problems are not detected" $info] != 1 } {
puts "Error : Wrong result"
}