From: pkv Date: Fri, 25 Sep 2015 04:12:10 +0000 (+0300) Subject: 0026619: Tolerances of operands are modified using bop X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=571d2d532b0932b7ccd627e2afd38f2a2a8e39c8;p=occt-copy.git 0026619: Tolerances of operands are modified using bop 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 class BOPAlgo_PaveFiller. --- diff --git a/src/BOPAlgo/BOPAlgo_Builder.cxx b/src/BOPAlgo/BOPAlgo_Builder.cxx index 21377ff7f2..8fe713aaf2 100644 --- a/src/BOPAlgo/BOPAlgo_Builder.cxx +++ b/src/BOPAlgo/BOPAlgo_Builder.cxx @@ -22,9 +22,14 @@ #include #include +#include + +#include +#include #include + //======================================================================= //function : //purpose : @@ -36,7 +41,6 @@ BOPAlgo_Builder::BOPAlgo_Builder() myMapFence(100, myAllocator), myPaveFiller(NULL), myDS(NULL), - //myContext(NULL), myEntryPoint(0), myImages(100, myAllocator), myShapesSD(100, myAllocator), @@ -57,7 +61,6 @@ BOPAlgo_Builder::BOPAlgo_Builder myMapFence(100, myAllocator), myPaveFiller(NULL), myDS(NULL), - //myContext(NULL), myEntryPoint(0), myImages(100, myAllocator), myShapesSD(100, myAllocator), @@ -371,18 +374,30 @@ void BOPAlgo_Builder::PerformInternal(const BOPAlgo_PaveFiller& theFiller) PostTreat(); } -// -// myErrorStatus -// -// 0 - Ok -// //======================================================================= //function : PostTreat //purpose : //======================================================================= void BOPAlgo_Builder::PostTreat() { - //BRepLib::SameParameter(myShape, 1.e-7, Standard_True); - BOPTools_AlgoTools::CorrectTolerances(myShape, 0.05); - BOPTools_AlgoTools::CorrectShapeTolerances(myShape); + Standard_Integer i, aNbS; + TopAbs_ShapeEnum aType; + BOPCol_IndexedMapOfShape aMA; + if (myPaveFiller->NonDestructive()) { + // MapToAvoid + aNbS=myDS->NbSourceShapes(); + for (i=0; iShapeInfo(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); + BOPTools_AlgoTools::CorrectShapeTolerances(myShape, aMA); } diff --git a/src/BOPAlgo/BOPAlgo_Builder_2.cxx b/src/BOPAlgo/BOPAlgo_Builder_2.cxx index 83a93486a4..614c59f162 100644 --- a/src/BOPAlgo/BOPAlgo_Builder_2.cxx +++ b/src/BOPAlgo/BOPAlgo_Builder_2.cxx @@ -246,8 +246,6 @@ void BOPAlgo_Builder::BuildSplitFaces() aLE.Append(aSp); } // - BOPTools_AlgoTools2D::BuildPCurveForEdgesOnPlane (aLE, aFF); - // // 3 Build split faces BOPAlgo_BuilderFace& aBF=aVBF.Append1(); aBF.SetFace(aF); diff --git a/src/BOPAlgo/BOPAlgo_PaveFiller.cdl b/src/BOPAlgo/BOPAlgo_PaveFiller.cdl index 414c092700..e61e3d591c 100644 --- a/src/BOPAlgo/BOPAlgo_PaveFiller.cdl +++ b/src/BOPAlgo/BOPAlgo_PaveFiller.cdl @@ -46,6 +46,7 @@ uses Iterator from BOPDS, PIterator from BOPDS, PaveBlock from BOPDS, + CommonBlock from BOPDS, Curve from BOPDS, IndexedDataMapOfShapeCoupleOfPaveBlocks from BOPDS, MapOfPaveBlock from BOPDS, @@ -435,12 +436,67 @@ is ---Purpose: -- Updates pave blocks which have the paves with indices contained -- in the map . + + 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) + is protected; + + SetNonDestructive(me:out) + is protected; + + NonDestructive(me) + returns Boolean from Standard; + + 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; myIterator : PIterator from BOPDS is protected; myContext : Context from BOPInt is protected; mySectionAttribute : SectionAttribute from BOPAlgo is protected; - + myNonDestructive : Boolean from Standard is protected; + myIsPrimary : Boolean from Standard is protected; end PaveFiller; diff --git a/src/BOPAlgo/BOPAlgo_PaveFiller.cxx b/src/BOPAlgo/BOPAlgo_PaveFiller.cxx index cfa6b2d460..f868df9323 100644 --- a/src/BOPAlgo/BOPAlgo_PaveFiller.cxx +++ b/src/BOPAlgo/BOPAlgo_PaveFiller.cxx @@ -27,37 +27,74 @@ //function : //purpose : //======================================================================= - BOPAlgo_PaveFiller::BOPAlgo_PaveFiller() +BOPAlgo_PaveFiller::BOPAlgo_PaveFiller() : BOPAlgo_Algo() { myDS=NULL; myIterator=NULL; + myNonDestructive=Standard_False; + myIsPrimary=Standard_True; } //======================================================================= //function : //purpose : //======================================================================= - BOPAlgo_PaveFiller::BOPAlgo_PaveFiller(const Handle(NCollection_BaseAllocator)& theAllocator) +BOPAlgo_PaveFiller::BOPAlgo_PaveFiller + (const Handle(NCollection_BaseAllocator)& theAllocator) : BOPAlgo_Algo(theAllocator) { myDS=NULL; myIterator=NULL; + myNonDestructive=Standard_False; + myIsPrimary=Standard_True; } //======================================================================= //function : ~ //purpose : //======================================================================= - BOPAlgo_PaveFiller::~BOPAlgo_PaveFiller() +BOPAlgo_PaveFiller::~BOPAlgo_PaveFiller() { 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 : //======================================================================= - void BOPAlgo_PaveFiller::Clear() +void BOPAlgo_PaveFiller::Clear() { if (myIterator) { delete myIterator; @@ -73,7 +110,7 @@ //function : DS //purpose : //======================================================================= - const BOPDS_DS& BOPAlgo_PaveFiller::DS() +const BOPDS_DS& BOPAlgo_PaveFiller::DS() { return *myDS; } @@ -81,7 +118,7 @@ //function : PDS //purpose : //======================================================================= - BOPDS_PDS BOPAlgo_PaveFiller::PDS() +BOPDS_PDS BOPAlgo_PaveFiller::PDS() { return myDS; } @@ -89,7 +126,7 @@ //function : Context //purpose : //======================================================================= - Handle(BOPInt_Context) BOPAlgo_PaveFiller::Context() +Handle(BOPInt_Context) BOPAlgo_PaveFiller::Context() { return myContext; } @@ -97,7 +134,8 @@ //function : SectionAttribute //purpose : //======================================================================= - void BOPAlgo_PaveFiller::SetSectionAttribute(const BOPAlgo_SectionAttribute& theSecAttr) +void BOPAlgo_PaveFiller::SetSectionAttribute + (const BOPAlgo_SectionAttribute& theSecAttr) { mySectionAttribute = theSecAttr; } @@ -105,7 +143,7 @@ //function : SetArguments //purpose : //======================================================================= - void BOPAlgo_PaveFiller::SetArguments(const BOPCol_ListOfShape& theLS) +void BOPAlgo_PaveFiller::SetArguments(const BOPCol_ListOfShape& theLS) { myArguments=theLS; } @@ -113,7 +151,7 @@ //function : Arguments //purpose : //======================================================================= - const BOPCol_ListOfShape& BOPAlgo_PaveFiller::Arguments()const +const BOPCol_ListOfShape& BOPAlgo_PaveFiller::Arguments()const { return myArguments; } @@ -121,7 +159,7 @@ // function: Init // purpose: //======================================================================= - void BOPAlgo_PaveFiller::Init() +void BOPAlgo_PaveFiller::Init() { myErrorStatus=0; // @@ -132,6 +170,7 @@ // // 0 Clear Clear(); + // // 1.myDS myDS=new BOPDS_DS(myAllocator); @@ -145,6 +184,9 @@ // // 3 myContext myContext=new BOPInt_Context; + // + // 4 NonDestructive flag + SetNonDestructive(); // myErrorStatus=0; } @@ -152,7 +194,7 @@ // function: Perform // purpose: //======================================================================= - void BOPAlgo_PaveFiller::Perform() +void BOPAlgo_PaveFiller::Perform() { myErrorStatus=0; // @@ -171,34 +213,41 @@ 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) { @@ -216,5 +265,5 @@ if (myErrorStatus) { return; } - // } + diff --git a/src/BOPAlgo/BOPAlgo_PaveFiller_1.cxx b/src/BOPAlgo/BOPAlgo_PaveFiller_1.cxx index 117402d8b3..06cf485180 100644 --- a/src/BOPAlgo/BOPAlgo_PaveFiller_1.cxx +++ b/src/BOPAlgo/BOPAlgo_PaveFiller_1.cxx @@ -25,28 +25,30 @@ #include #include +#include #include #include #include #include #include -#include + #include #include -#include +#include +#include //======================================================================= // function: PerformVV // purpose: //======================================================================= - void BOPAlgo_PaveFiller::PerformVV() +void BOPAlgo_PaveFiller::PerformVV() { Standard_Boolean bWithSubShape; - Standard_Integer n1, n2, iFlag, nX, n, aSize, i, aNbVV, j, iX, k, aNbBlocks; + Standard_Integer n1, n2, iFlag, nX, n, aSize, i, j, iX, k, aNbBlocks; Handle(NCollection_IncAllocator) aAllocator; - BOPCol_DataMapIteratorOfDataMapOfIntegerListOfInteger aItMILI; + //BOPCol_DataMapIteratorOfDataMapOfIntegerListOfInteger aItMILI; BOPCol_ListIteratorOfListOfInteger aItLI, aItLI2; TopoDS_Vertex aVn; BOPDS_ShapeInfo aSIn; @@ -103,7 +105,7 @@ // BOPTools_AlgoTools::MakeVertex(aLV, aVn); // - // Appennd new vertex to the DS + // Append new vertex to the DS aSIn.SetShape(aVn); n=myDS->Append(aSIn); // @@ -131,7 +133,15 @@ } } } - aNbVV=aVVs.Extent(); + // + 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(); diff --git a/src/BOPAlgo/BOPAlgo_PaveFiller_11.cxx b/src/BOPAlgo/BOPAlgo_PaveFiller_11.cxx new file mode 100644 index 0000000000..775ac2220f --- /dev/null +++ b/src/BOPAlgo/BOPAlgo_PaveFiller_11.cxx @@ -0,0 +1,241 @@ +// 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 + +#include + +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +//======================================================================= +//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; + + if (!myNonDestructive) { + const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&myDS->Shape(nV); + aTolV = BRep_Tool::Tolerance(aV); + if (aTolV < aTolNew) { + aBB.UpdateVertex(aV, aTolNew); + BOPDS_ShapeInfo& aSIV = myDS->ChangeShapeInfo(nV); + Bnd_Box& aBoxV = aSIV.ChangeBox(); + BRepBndLib::Add(aV, aBoxV); + } + return nV; + } + // + nVNew = nV; + if (myDS->IsNewShape(nVNew) || + myDS->HasShapeSD(nV, nVNew)) { + // nV is new vertex + 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; iCommonBlock(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(); +} diff --git a/src/BOPAlgo/BOPAlgo_PaveFiller_2.cxx b/src/BOPAlgo/BOPAlgo_PaveFiller_2.cxx index 9d1b798521..ea6501aa7b 100644 --- a/src/BOPAlgo/BOPAlgo_PaveFiller_2.cxx +++ b/src/BOPAlgo/BOPAlgo_PaveFiller_2.cxx @@ -36,15 +36,14 @@ // function: PerformVE // purpose: //======================================================================= - void BOPAlgo_PaveFiller::PerformVE() +void BOPAlgo_PaveFiller::PerformVE() { - Standard_Boolean bJustAdd; + Standard_Boolean bJustAdd, bHasShapeSD; Standard_Integer iSize, nV, nE, nVSD, iFlag, nVx, i; - Standard_Real aT, aTolE, aTolV; + Standard_Real aT, aTolVnew; BOPDS_Pave aPave; BOPDS_PassKey aPK; BOPDS_MapOfPassKey aMPK; - BRep_Builder aBB; // myErrorStatus=0; // @@ -80,7 +79,8 @@ } // nVx=nV; - if (myDS->HasShapeSD(nV, nVSD)) { + bHasShapeSD=myDS->HasShapeSD(nV, nVSD); + if (bHasShapeSD) { nVx=nVSD; } // @@ -89,10 +89,10 @@ continue; } // - const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&aSIE.Shape())); - const TopoDS_Vertex& aV=(*(TopoDS_Vertex *)(&myDS->Shape(nVx))); + const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&aSIE.Shape())); + const TopoDS_Vertex& aVx=(*(TopoDS_Vertex *)(&myDS->Shape(nVx))); // - iFlag=myContext->ComputeVE (aV, aE, aT); + iFlag=myContext->ComputeVE (aVx, aE, aT, aTolVnew); if (!iFlag) { // 1 i=aVEs.Append()-1; @@ -101,21 +101,21 @@ 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 + 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 (; myIterator->More(); myIterator->Next()) { -} +} diff --git a/src/BOPAlgo/BOPAlgo_PaveFiller_3.cxx b/src/BOPAlgo/BOPAlgo_PaveFiller_3.cxx index 9143e7205b..64684682b8 100644 --- a/src/BOPAlgo/BOPAlgo_PaveFiller_3.cxx +++ b/src/BOPAlgo/BOPAlgo_PaveFiller_3.cxx @@ -59,13 +59,12 @@ #include #include -#include //======================================================================= // function: PerformEE // purpose: //======================================================================= - void BOPAlgo_PaveFiller::PerformEE() +void BOPAlgo_PaveFiller::PerformEE() { Standard_Boolean bJustAdd, bOrder; Standard_Integer i, iX, iSize, nE1, nE2, aDiscretize; @@ -156,10 +155,6 @@ continue; } // - // -----------f - //DEBft - //printf(" nE1=%d nE2=%d\n", nE1, nE2); - // IntTools_EdgeEdge aEdgeEdge; // aEdgeEdge.SetEdge1 (aE1); @@ -220,8 +215,10 @@ aPBn2=aPB1; } // - IntTools_Range aR11(aPBR1.First(), aSR1.First()), aR12(aSR1.Last(), aPBR1.Last()), - aR21(aPBR2.First(), aSR2.First()), aR22(aSR2.Last(), aPBR2.Last()); + IntTools_Range aR11(aPBR1.First(), aSR1.First()), + aR12(aSR1.Last(), aPBR1.Last()), + aR21(aPBR2.First(), aSR2.First()), + aR22(aSR2.Last(), aPBR2.Last()); // const IntTools_SequenceOfCommonPrts& aCPrts=aEdgeEdge.CommonParts(); // @@ -248,8 +245,10 @@ aPBn1->Indices(nV[0], nV[1]); aPBn2->Indices(nV[2], nV[3]); // - if((bIsOnPave[0] && bIsOnPave[2]) || (bIsOnPave[0] && bIsOnPave[3]) || - (bIsOnPave[1] && bIsOnPave[2]) || (bIsOnPave[1] && bIsOnPave[3])) { + if((bIsOnPave[0] && bIsOnPave[2]) || + (bIsOnPave[0] && bIsOnPave[3]) || + (bIsOnPave[1] && bIsOnPave[2]) || + (bIsOnPave[1] && bIsOnPave[3])) { continue; } // @@ -385,12 +384,12 @@ aAllocator.Nullify(); } //======================================================================= -//function : PerformVertices +//function : PerformVerticesEE //purpose : //======================================================================= - Standard_Integer BOPAlgo_PaveFiller::PerformVerticesEE - (BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& theMVCPB, - Handle(NCollection_BaseAllocator)& theAllocator) +Standard_Integer BOPAlgo_PaveFiller::PerformVerticesEE + (BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& theMVCPB, + Handle(NCollection_BaseAllocator)& theAllocator) { Standard_Integer aNbV, iRet; // @@ -523,9 +522,9 @@ //function : TreatNewVertices //purpose : //======================================================================= - void BOPAlgo_PaveFiller::TreatNewVertices( - const BOPCol_IndexedDataMapOfShapeInteger& aMapVI, - BOPCol_IndexedDataMapOfShapeListOfShape& myImages) +void BOPAlgo_PaveFiller::TreatNewVertices +(const BOPCol_IndexedDataMapOfShapeInteger& aMapVI, + BOPCol_IndexedDataMapOfShapeListOfShape& myImages) { Standard_Integer j, i, aNbV, aNbVSD; Standard_Real aTol; @@ -540,7 +539,8 @@ // BOPDS_BoxBndTreeSelector aSelector; BOPDS_BoxBndTree aBBTree; - NCollection_UBTreeFiller aTreeFiller(aBBTree); + NCollection_UBTreeFiller aTreeFiller(aBBTree); // aNbV = aMapVI.Extent(); for (i=1; i<=aNbV; ++i) { @@ -656,12 +656,11 @@ } } } - //======================================================================= //function : FillShrunkData //purpose : //======================================================================= - void BOPAlgo_PaveFiller::FillShrunkData(Handle(BOPDS_PaveBlock)& thePB) +void BOPAlgo_PaveFiller::FillShrunkData(Handle(BOPDS_PaveBlock)& thePB) { Standard_Integer nE, nV1, nV2, iErr; Standard_Real aT1, aT2, aTS1, aTS2; @@ -706,8 +705,8 @@ void BOPAlgo_PaveFiller::ForceInterfVE(const Standard_Integer nV, Handle(BOPDS_PaveBlock)& aPB, BOPDS_MapOfPaveBlock& aMPBToUpdate) { - Standard_Integer aNbPnt, nE; - gp_Pnt aP; + Standard_Integer nI, nE, nVx, nVSD, iFlag; + Standard_Real aT, aTolVNew; // nE = aPB->OriginalEdge(); // @@ -724,60 +723,45 @@ void BOPAlgo_PaveFiller::ForceInterfVE(const Standard_Integer nV, 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(); - i=aVEs.Append()-1; - BOPDS_InterfVE& aVE=aVEs(i); + aVEs.SetIncrement(10); + // 1 + nI=aVEs.Append()-1; + BOPDS_InterfVE& aVE=aVEs(nI); + // 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 - */ diff --git a/src/BOPAlgo/BOPAlgo_PaveFiller_4.cxx b/src/BOPAlgo/BOPAlgo_PaveFiller_4.cxx index 9e21a1941e..ea8d762ee0 100644 --- a/src/BOPAlgo/BOPAlgo_PaveFiller_4.cxx +++ b/src/BOPAlgo/BOPAlgo_PaveFiller_4.cxx @@ -22,8 +22,6 @@ #include #include #include -#include -#include #include @@ -41,12 +39,11 @@ // function: PerformVF // purpose: //======================================================================= - void BOPAlgo_PaveFiller::PerformVF() +void BOPAlgo_PaveFiller::PerformVF() { Standard_Boolean bJustAdd; Standard_Integer iSize, nV, nF, nVSD, iFlag, nVx, i; - Standard_Real aT1, aT2, aTolF, aTolV; - BRep_Builder aBB; + Standard_Real aT1, aT2, aTolF, aTolV, aTolVnew; // myErrorStatus=0; // @@ -89,27 +86,29 @@ aTolV = BRep_Tool::Tolerance(aV); aTolF = BRep_Tool::Tolerance(aF); // - iFlag=myContext->ComputeVF(aV, aF, aT1, aT2); - if (!iFlag) { - // 1 - i=aVFs.Append()-1; - BOPDS_InterfVF& aVF=aVFs(i); - aVF.SetIndices(nVx, nF); - aVF.SetUV(aT1, aT2); - // 2 - myDS->AddInterf(nVx, nF); - // - BOPDS_FaceInfo& aFI=myDS->ChangeFaceInfo(nF); - BOPCol_MapOfInteger& aMVIn=aFI.ChangeVerticesIn(); - aMVIn.Add(nVx); - // - if (aTolV < aTolF) { - aBB.UpdateVertex(aV, aTolF); - BOPDS_ShapeInfo& aSIV = myDS->ChangeShapeInfo(nVx); - Bnd_Box& aBoxV = aSIV.ChangeBox(); - BRepBndLib::Add(aV, aBoxV); - } + iFlag=myContext->ComputeVF(aV, aF, aT1, aT2, aTolVnew); + if (iFlag) { + continue; } + // 1 + i=aVFs.Append()-1; + BOPDS_InterfVF& aVF=aVFs(i); + aVF.SetIndices(nVx, nF); + aVF.SetUV(aT1, aT2); + // 2 + myDS->AddInterf(nVx, nF); + // + // 3 update vertex V/F if necessary + nVx=UpdateVertex(nVx, aTolVnew); + // + // 4 + if (myDS->IsNewShape(nVx)) { + aVF.SetIndexNew(nVx); + } + // update FaceInfo + BOPDS_FaceInfo& aFI=myDS->ChangeFaceInfo(nF); + BOPCol_MapOfInteger& aMVIn=aFI.ChangeVerticesIn(); + aMVIn.Add(nVx); }// for (; myIterator->More(); myIterator->Next()) { }// if (iSize) { else { @@ -122,13 +121,11 @@ // TreatVerticesEE(); } - - //======================================================================= //function : TreatVerticesEE //purpose : //======================================================================= - void BOPAlgo_PaveFiller::TreatVerticesEE() +void BOPAlgo_PaveFiller::TreatVerticesEE() { Standard_Integer i, aNbS, aNbEEs, nF, nV, iFlag; Standard_Real aT1, aT2; @@ -143,7 +140,6 @@ // myErrorStatus=0; // - aNbS=myDS->NbSourceShapes(); // BOPDS_VectorOfInterfEE& aEEs=myDS->InterfEE(); diff --git a/src/BOPAlgo/BOPAlgo_PaveFiller_5.cxx b/src/BOPAlgo/BOPAlgo_PaveFiller_5.cxx index 73f2b06a50..65e3005863 100644 --- a/src/BOPAlgo/BOPAlgo_PaveFiller_5.cxx +++ b/src/BOPAlgo/BOPAlgo_PaveFiller_5.cxx @@ -19,6 +19,8 @@ #include +#include + #include #include @@ -53,12 +55,11 @@ #include #include - //======================================================================= //function : PerformEF //purpose : //======================================================================= - void BOPAlgo_PaveFiller::PerformEF() +void BOPAlgo_PaveFiller::PerformEF() { Standard_Integer iSize; // @@ -213,11 +214,25 @@ if (bIsOnPave[j]) { bV[j]=CheckFacePaves(nV[j], aMIFOn, aMIFIn); if (bV[j]) { - 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); + const TopoDS_Vertex& aV = + (*(TopoDS_Vertex *)(&myDS->Shape(nV[j]))); + // + 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); @@ -268,11 +283,6 @@ 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); @@ -304,22 +314,19 @@ } // Refine FaceInfoOn to remove all formal pave blocks // made during EF processing - //myDS->RefineFaceInfoOn(); //-----------------------------------------------------scope t aMIEFC.Clear(); aMVCPB.Clear(); aMPBLI.Clear(); aAllocator.Nullify(); - // - } //======================================================================= //function : PerformVertices1 //purpose : //======================================================================= - Standard_Integer BOPAlgo_PaveFiller::PerformVerticesEF - (BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& theMVCPB, - Handle(NCollection_BaseAllocator)& theAllocator) +Standard_Integer BOPAlgo_PaveFiller::PerformVerticesEF + (BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& theMVCPB, + Handle(NCollection_BaseAllocator)& theAllocator) { Standard_Integer aNbV, iRet; // @@ -353,6 +360,8 @@ } // // 2 Fuse vertices + aPF.SetIsPrimary(Standard_False); + aPF.SetNonDestructive(myNonDestructive); aPF.SetArguments(aLS); aPF.Perform(); iErr=aPF.ErrorStatus(); @@ -432,7 +441,7 @@ } } } - // 6 Split PaveBlocksa + // 6 Split PaveBlocks for (i=1; i<=aNbPBLI; ++i) { Handle(BOPDS_PaveBlock) aPB=aMPBLI.FindKey(i); nE=aPB->OriginalEdge(); @@ -452,9 +461,10 @@ // function: CheckFacePaves // purpose: //======================================================================= - Standard_Boolean BOPAlgo_PaveFiller::CheckFacePaves (const Standard_Integer nVx, - const BOPCol_MapOfInteger& aMIFOn, - const BOPCol_MapOfInteger& aMIFIn) +Standard_Boolean BOPAlgo_PaveFiller::CheckFacePaves + (const Standard_Integer nVx, + const BOPCol_MapOfInteger& aMIFOn, + const BOPCol_MapOfInteger& aMIFIn) { Standard_Boolean bRet; Standard_Integer nV; @@ -485,8 +495,9 @@ // function: CheckFacePaves // purpose: //======================================================================= - Standard_Boolean BOPAlgo_PaveFiller::CheckFacePaves (const TopoDS_Vertex& aVnew, - const BOPCol_MapOfInteger& aMIF) +Standard_Boolean BOPAlgo_PaveFiller::CheckFacePaves + (const TopoDS_Vertex& aVnew, + const BOPCol_MapOfInteger& aMIF) { Standard_Boolean bRet; Standard_Integer nV, iFlag; @@ -510,50 +521,43 @@ //function : ForceInterfVF //purpose : //======================================================================= -Standard_Boolean BOPAlgo_PaveFiller::ForceInterfVF(const Standard_Integer nV, - const Standard_Integer nF) +Standard_Boolean BOPAlgo_PaveFiller::ForceInterfVF + (const Standard_Integer nV, + const Standard_Integer nF) { Standard_Boolean bRet; + Standard_Integer iFlag, nI, 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(); - i=aVFs.Append()-1; - BOPDS_InterfVF& aVF=aVFs(i); + aVFs.SetIncrement(10); + // 1 + nI=aVFs.Append()-1; + BOPDS_InterfVF& aVF=aVFs(nI); + // 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; } - diff --git a/src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx b/src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx index 528e8a4a1e..0551a62987 100644 --- a/src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx +++ b/src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx @@ -94,6 +94,7 @@ static void ToleranceFF(const BRepAdaptor_Surface& aBAS1, const BRepAdaptor_Surface& aBAS2, Standard_Real& aTolFF); + //======================================================================= //function : PerformFF //purpose : @@ -138,22 +139,21 @@ void BOPAlgo_PaveFiller::PerformFF() 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); @@ -319,7 +319,7 @@ void BOPAlgo_PaveFiller::MakeBlocks() if (aMF.Add(nF2)) { myDS->UpdateFaceInfoOn(nF2); } - + // BOPDS_FaceInfo& aFI1=myDS->ChangeFaceInfo(nF1); BOPDS_FaceInfo& aFI2=myDS->ChangeFaceInfo(nF2); // @@ -422,10 +422,11 @@ void BOPAlgo_PaveFiller::MakeBlocks() 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) || @@ -471,14 +472,18 @@ void BOPAlgo_PaveFiller::MakeBlocks() aLPBC.RemoveFirst(); }//for (j=0; jShape(nV1); - const Handle(BRep_TVertex)& TV = *((Handle(BRep_TVertex)*)&aV.TShape()); - TV->Tolerance(aTol); + 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); + } } // ProcessExistingPaveBlocks(i, aMPBOnIn, aMSCPB, aMVI, aMVB, aMPBAdd); @@ -509,7 +514,7 @@ void BOPAlgo_PaveFiller::MakeBlocks() //function : PostTreatFF //purpose : //======================================================================= - Standard_Integer BOPAlgo_PaveFiller::PostTreatFF +Standard_Integer BOPAlgo_PaveFiller::PostTreatFF (BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& theMSCPB, BOPCol_DataMapOfShapeInteger& aMVI, BOPDS_DataMapOfPaveBlockListOfPaveBlock& aDMExEdges, @@ -539,6 +544,8 @@ void BOPAlgo_PaveFiller::MakeBlocks() // BOPCol_ListOfShape aLS(theAllocator); BOPAlgo_PaveFiller aPF(theAllocator); + aPF.SetIsPrimary(Standard_False); + aPF.SetNonDestructive(myNonDestructive); // BOPDS_VectorOfInterfFF& aFFs=myDS->InterfFF(); // @@ -785,7 +792,8 @@ void BOPAlgo_PaveFiller::MakeBlocks() //function : UpdateFaceInfo //purpose : //======================================================================= -void BOPAlgo_PaveFiller::UpdateFaceInfo(BOPDS_DataMapOfPaveBlockListOfPaveBlock& theDME) +void BOPAlgo_PaveFiller::UpdateFaceInfo + (BOPDS_DataMapOfPaveBlockListOfPaveBlock& theDME) { Standard_Integer i, j, nV1, nF1, nF2, aNbFF, aNbC, aNbP, aNbS, aNbPBIn; @@ -875,10 +883,10 @@ void BOPAlgo_PaveFiller::UpdateFaceInfo(BOPDS_DataMapOfPaveBlockListOfPaveBlock& //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; @@ -916,11 +924,11 @@ void BOPAlgo_PaveFiller::UpdateFaceInfo(BOPDS_DataMapOfPaveBlockListOfPaveBlock& //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; // @@ -962,12 +970,12 @@ void BOPAlgo_PaveFiller::UpdateFaceInfo(BOPDS_DataMapOfPaveBlockListOfPaveBlock& //function : IsExistingPaveBlock //purpose : //======================================================================= - Standard_Boolean BOPAlgo_PaveFiller::IsExistingPaveBlock - (const Handle(BOPDS_PaveBlock)& thePB, - const BOPDS_Curve& theNC, - const Standard_Real theTolR3D, - const BOPDS_MapOfPaveBlock& theMPBOnIn, - Handle(BOPDS_PaveBlock&) aPBOut) +Standard_Boolean BOPAlgo_PaveFiller::IsExistingPaveBlock + (const Handle(BOPDS_PaveBlock)& thePB, + const BOPDS_Curve& theNC, + const Standard_Real theTolR3D, + const BOPDS_MapOfPaveBlock& theMPBOnIn, + Handle(BOPDS_PaveBlock&) aPBOut) { Standard_Boolean bRet; Standard_Real aT1, aT2, aTm, aTx; @@ -1033,12 +1041,13 @@ void BOPAlgo_PaveFiller::UpdateFaceInfo(BOPDS_DataMapOfPaveBlockListOfPaveBlock& //function : PutBoundPaveOnCurve //purpose : //======================================================================= - void BOPAlgo_PaveFiller::PutBoundPaveOnCurve(const TopoDS_Face& aF1, - const TopoDS_Face& aF2, - const Standard_Real aTolR3D, - BOPDS_Curve& aNC, - BOPCol_MapOfInteger& aMVOnIn, - BOPCol_MapOfInteger& aMVB) +void BOPAlgo_PaveFiller::PutBoundPaveOnCurve + (const TopoDS_Face& aF1, + const TopoDS_Face& aF2, + const Standard_Real aTolR3D, + BOPDS_Curve& aNC, + BOPCol_MapOfInteger& aMVOnIn, + BOPCol_MapOfInteger& aMVB) { Standard_Boolean bVF; Standard_Integer nV, iFlag, nVn, j, aNbEP; @@ -1136,14 +1145,15 @@ void BOPAlgo_PaveFiller::UpdateFaceInfo(BOPDS_DataMapOfPaveBlockListOfPaveBlock& //function : PutPavesOnCurve //purpose : //======================================================================= - void BOPAlgo_PaveFiller::PutPavesOnCurve(const BOPCol_MapOfInteger& aMVOnIn, - const Standard_Real aTolR3D, - BOPDS_Curve& aNC, - const Standard_Integer nF1, - const Standard_Integer nF2, - const BOPCol_MapOfInteger& aMI, - const BOPCol_MapOfInteger& aMVEF, - BOPCol_DataMapOfIntegerReal& aMVTol) +void BOPAlgo_PaveFiller::PutPavesOnCurve + (const BOPCol_MapOfInteger& aMVOnIn, + const Standard_Real aTolR3D, + BOPDS_Curve& aNC, + const Standard_Integer nF1, + const Standard_Integer nF2, + const BOPCol_MapOfInteger& aMI, + const BOPCol_MapOfInteger& aMVEF, + BOPCol_DataMapOfIntegerReal& aMVTol) { Standard_Boolean bInBothFaces; Standard_Integer nV; @@ -1192,10 +1202,11 @@ void BOPAlgo_PaveFiller::UpdateFaceInfo(BOPDS_DataMapOfPaveBlockListOfPaveBlock& //function : ExtendedTolerance //purpose : //======================================================================= -Standard_Boolean BOPAlgo_PaveFiller::ExtendedTolerance(const Standard_Integer nV, - const BOPCol_MapOfInteger& aMI, - Standard_Real& aTolVExt, - const Standard_Integer aType) +Standard_Boolean BOPAlgo_PaveFiller::ExtendedTolerance + (const Standard_Integer nV, + const BOPCol_MapOfInteger& aMI, + Standard_Real& aTolVExt, + const Standard_Integer aType) { Standard_Boolean bFound = Standard_False; if (!(myDS->IsNewShape(nV))) { @@ -1253,9 +1264,10 @@ Standard_Boolean BOPAlgo_PaveFiller::ExtendedTolerance(const Standard_Integer nV //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; @@ -1326,10 +1338,11 @@ Standard_Boolean BOPAlgo_PaveFiller::ExtendedTolerance(const Standard_Integer nV //function : ProcessUnUsedVertices //purpose : //======================================================================= - void BOPAlgo_PaveFiller::PutEFPavesOnCurve(BOPDS_Curve& aNC, - const BOPCol_MapOfInteger& aMI, - const BOPCol_MapOfInteger& aMVEF, - BOPCol_DataMapOfIntegerReal& aMVTol) +void BOPAlgo_PaveFiller::PutEFPavesOnCurve + (BOPDS_Curve& aNC, + const BOPCol_MapOfInteger& aMI, + const BOPCol_MapOfInteger& aMVEF, + BOPCol_DataMapOfIntegerReal& aMVTol) { if (!aMVEF.Extent()) { return; @@ -1376,12 +1389,13 @@ Standard_Boolean BOPAlgo_PaveFiller::ExtendedTolerance(const Standard_Integer nV //function : ProcessUnUsedVertices //purpose : //======================================================================= - void BOPAlgo_PaveFiller::PutStickPavesOnCurve(const TopoDS_Face& aF1, - const TopoDS_Face& aF2, - const BOPCol_MapOfInteger& aMI, - BOPDS_Curve& aNC, - const BOPCol_MapOfInteger& aMVStick, - BOPCol_DataMapOfIntegerReal& aMVTol) +void BOPAlgo_PaveFiller::PutStickPavesOnCurve + (const TopoDS_Face& aF1, + const TopoDS_Face& aF2, + const BOPCol_MapOfInteger& aMI, + BOPDS_Curve& aNC, + const BOPCol_MapOfInteger& aMVStick, + BOPCol_DataMapOfIntegerReal& aMVTol) { BOPCol_MapOfInteger aMV; aMV.Assign(aMVStick); @@ -1466,11 +1480,11 @@ Standard_Boolean BOPAlgo_PaveFiller::ExtendedTolerance(const Standard_Integer nV //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; // @@ -1565,12 +1579,12 @@ void BOPAlgo_PaveFiller::RemoveUsedVertices(BOPDS_Curve& aNC, //function : PutPaveOnCurve //purpose : //======================================================================= - void BOPAlgo_PaveFiller::PutPaveOnCurve(const Standard_Integer nV, - const Standard_Real aTolR3D, - BOPDS_Curve& aNC, - const BOPCol_MapOfInteger& aMI, - BOPCol_DataMapOfIntegerReal& aMVTol, - const Standard_Integer iCheckExtend) +void BOPAlgo_PaveFiller::PutPaveOnCurve(const Standard_Integer nV, + const Standard_Real aTolR3D, + BOPDS_Curve& aNC, + const BOPCol_MapOfInteger& aMI, + BOPCol_DataMapOfIntegerReal& aMVTol, + const Standard_Integer iCheckExtend) { Standard_Boolean bIsVertexOnLine; Standard_Real aT, aTolV; @@ -1644,7 +1658,7 @@ void BOPAlgo_PaveFiller::RemoveUsedVertices(BOPDS_Curve& aNC, //function : ProcessOldPaveBlocks //purpose : //======================================================================= - void BOPAlgo_PaveFiller::ProcessExistingPaveBlocks +void BOPAlgo_PaveFiller::ProcessExistingPaveBlocks (const Standard_Integer theInt, const BOPDS_MapOfPaveBlock& aMPBOnIn, BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& aMSCPB, @@ -1703,11 +1717,11 @@ void BOPAlgo_PaveFiller::RemoveUsedVertices(BOPDS_Curve& aNC, //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; @@ -1810,7 +1824,8 @@ void BOPAlgo_PaveFiller::RemoveUsedVertices(BOPDS_Curve& aNC, IntTools_Range aShrR(aPB->Pave1().Parameter(), aPB->Pave2().Parameter()); const TopoDS_Edge& aE = *(TopoDS_Edge*)&myDS->Shape(aPB->Edge()); // - Standard_Boolean bCom = BOPTools_AlgoTools::IsBlockInOnFace(aShrR, aF, aE, myContext); + Standard_Boolean bCom = + BOPTools_AlgoTools::IsBlockInOnFace(aShrR, aF, aE, myContext); if (bCom) { if (bCB) { aCB = myDS->CommonBlock(aPB); @@ -1853,7 +1868,7 @@ void BOPAlgo_PaveFiller::RemoveUsedVertices(BOPDS_Curve& aNC, // 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; @@ -1909,7 +1924,7 @@ void BOPAlgo_PaveFiller::RemoveUsedVertices(BOPDS_Curve& aNC, //function : PreparePostTreatFF //purpose : //======================================================================= - void BOPAlgo_PaveFiller::PreparePostTreatFF +void BOPAlgo_PaveFiller::PreparePostTreatFF (const Standard_Integer aInt, const Handle(BOPDS_PaveBlock)& aPB, BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& aMSCPB, @@ -1941,9 +1956,9 @@ void BOPAlgo_PaveFiller::RemoveUsedVertices(BOPDS_Curve& aNC, //function : CheckPlanes //purpose : //======================================================================= -Standard_Boolean - BOPAlgo_PaveFiller::CheckPlanes(const Standard_Integer nF1, - const Standard_Integer nF2)const +Standard_Boolean BOPAlgo_PaveFiller::CheckPlanes + (const Standard_Integer nF1, + const Standard_Integer nF2)const { Standard_Boolean bToIntersect; Standard_Integer i, nV2, iCnt; @@ -1981,7 +1996,8 @@ Standard_Boolean //function : UpdatePaveBlocks //purpose : //======================================================================= -void BOPAlgo_PaveFiller::UpdatePaveBlocks(const BOPCol_DataMapOfIntegerInteger& aDMI) +void BOPAlgo_PaveFiller::UpdatePaveBlocks + (const BOPCol_DataMapOfIntegerInteger& aDMI) { if (aDMI.IsEmpty()) { return; @@ -2075,3 +2091,120 @@ void BOPAlgo_PaveFiller::UpdatePaveBlocks(const BOPCol_DataMapOfIntegerInteger& 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; iUpdateFaceInfoOn(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; jHasShapeSD(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; jShape(nV)); + const IntTools_Curve& aIC=aNC.Curve(); + // + bIsVertexOnLine=myContext->IsVertexOnLine(aV, aIC, aTolR3D, aT); + return bIsVertexOnLine; +} diff --git a/src/BOPAlgo/BOPAlgo_PaveFiller_7.cxx b/src/BOPAlgo/BOPAlgo_PaveFiller_7.cxx index 07c5ab4e38..a9a130cd32 100644 --- a/src/BOPAlgo/BOPAlgo_PaveFiller_7.cxx +++ b/src/BOPAlgo/BOPAlgo_PaveFiller_7.cxx @@ -51,6 +51,8 @@ #include #include #include +#include +#include static void UpdateVertices(const TopoDS_Edge& aE, const TopoDS_Face& aF); @@ -59,7 +61,7 @@ static void UpdateVertices(const TopoDS_Edge& aE, // function: MakeSplitEdges // purpose: //======================================================================= - void BOPAlgo_PaveFiller::MakeSplitEdges() +void BOPAlgo_PaveFiller::MakeSplitEdges() { Standard_Integer aNbPBP; // @@ -72,48 +74,55 @@ static void UpdateVertices(const TopoDS_Edge& aE, } // Standard_Boolean bCB, bV1, bV2; - Standard_Integer i, nE, nV1, nV2, nSp, aNbPB, nOrE; + Standard_Integer i, nE, nV1, nV2, nSp, aNbPB; Standard_Real aT1, aT2; - Handle(NCollection_IncAllocator) aAllocator; - BOPDS_ListIteratorOfListOfPaveBlock aItPB, aItPBCB; + Handle(BOPDS_PaveBlock) aPB, aPBx; - //-----------------------------------------------------scope f + BOPDS_MapOfPaveBlock aMPB; + BOPDS_ListIteratorOfListOfPaveBlock aItPB; // - aAllocator=new NCollection_IncAllocator(); + UpdateCommonBlocksWithSDVertices(); // - BOPDS_MapOfPaveBlock aMPB(100,aAllocator); + aNbPBP=aPBP.Extent(); // for (i=0; iOriginalEdge(); - } - //DEBt + // if (aNbPB==1) { aPB=aLPB.First(); 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) { myDS->SortPaveBlocks(aCB); aPB=aCB->PaveBlock1(); + // + aPB->Indices(nV1, nV2); } // if (aMPB.Add(aPB)) { @@ -121,9 +130,13 @@ static void UpdateVertices(const TopoDS_Edge& aE, aPB->Indices(nV1, nV2); aPB->Range(aT1, aT2); // - nSp = SplitEdge(nE, nV1, aT1, nV2, aT2); - // + nSp=SplitEdge(nE, nV1, aT1, nV2, aT2); + // if (bCB) { + Standard_Real aTolCB; + // + aTolCB=ComputeTolerance(aCB); + myDS->UpdateEdgeTolerance(nSp, aTolCB); aCB->SetEdge(nSp); } else { @@ -132,12 +145,53 @@ static void UpdateVertices(const TopoDS_Edge& aE, }// if (aMPB.Add(aPB)) { }// for (; aItPB.More(); aItPB.Next()) { }// for (i=0; iPaveBlock1(); + 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: @@ -179,7 +233,7 @@ Standard_Integer BOPAlgo_PaveFiller::SplitEdge(const Standard_Integer nE, // function: MakePCurves // purpose: //======================================================================= - void BOPAlgo_PaveFiller::MakePCurves() +void BOPAlgo_PaveFiller::MakePCurves() { Standard_Integer i, nF1, nF2, aNbC, k, nE, aNbFF, aNbFI; BOPDS_ListIteratorOfListOfPaveBlock aItLPB; @@ -268,7 +322,7 @@ Standard_Integer BOPAlgo_PaveFiller::SplitEdge(const Standard_Integer nE, // function: RefineFaceInfoOn // purpose: //======================================================================= - void BOPAlgo_PaveFiller::RefineFaceInfoOn() +void BOPAlgo_PaveFiller::RefineFaceInfoOn() { Standard_Integer aNbPBP; // diff --git a/src/BOPAlgo/BOPAlgo_WireSplitter_1.cxx b/src/BOPAlgo/BOPAlgo_WireSplitter_1.cxx index 25ce4298d4..12d1db54c3 100644 --- a/src/BOPAlgo/BOPAlgo_WireSplitter_1.cxx +++ b/src/BOPAlgo/BOPAlgo_WireSplitter_1.cxx @@ -133,7 +133,7 @@ static //function : SplitBlock //purpose : //======================================================================= - void BOPAlgo_WireSplitter::SplitBlock(BOPTools_ConnexityBlock& aCB) +void BOPAlgo_WireSplitter::SplitBlock(BOPTools_ConnexityBlock& aCB) { Standard_Boolean bNothingToDo; Standard_Integer aIx, aNb, i, aCntIn, aCntOut; @@ -150,8 +150,6 @@ static 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()); diff --git a/src/BOPAlgo/FILES b/src/BOPAlgo/FILES index 01a0706439..e5e36a5370 100644 --- a/src/BOPAlgo/FILES +++ b/src/BOPAlgo/FILES @@ -15,3 +15,4 @@ BOPAlgo_WireSplitter_1.cxx BOPAlgo_ListOfCheckResult.hxx BOPAlgo_Builder_2Cnt.hxx +BOPAlgo_PaveFiller_11.cxx diff --git a/src/BOPDS/BOPDS_DS.cdl b/src/BOPDS/BOPDS_DS.cdl index ae9535bd62..4c0ddd945d 100644 --- a/src/BOPDS/BOPDS_DS.cdl +++ b/src/BOPDS/BOPDS_DS.cdl @@ -42,6 +42,7 @@ uses ListOfInteger from BOPCol, MapOfInteger from BOPCol, BaseAllocator from BOPCol, + DataMapOfIntegerListOfInteger from BOPCol, -- ShapeInfo from BOPDS, IndexRange from BOPDS, @@ -580,7 +581,17 @@ is ---Purpose: --- Updates tolerance of the sub-shapes of the shape with index . --- - + UpdatePaveBlocksWithSDVertices(me:out); + + UpdatePaveBlockWithSDVertices(me:out; + thePB:PaveBlock from BOPDS); + + UpdateCommonBlockWithSDVertices(me:out; + theCB:CommonBlock from BOPDS); + + InitPaveBlocksForVertex(me:out; + theNV:Integer from Standard); + fields myAllocator : BaseAllocator from BOPCol is protected; myArguments : ListOfShape from BOPCol is protected; @@ -597,6 +608,8 @@ fields -- --same domain shapes myShapesSD : DataMapOfIntegerInteger from BOPCol is protected; + -- + myMapVE: DataMapOfIntegerListOfInteger from BOPCol is protected; -- --interferences myInterfTB : MapOfPassKey from BOPDS is protected; diff --git a/src/BOPDS/BOPDS_DS.cxx b/src/BOPDS/BOPDS_DS.cxx index 58caf378c6..44810a1060 100644 --- a/src/BOPDS/BOPDS_DS.cxx +++ b/src/BOPDS/BOPDS_DS.cxx @@ -46,17 +46,15 @@ #include #include #include +#include +#include // -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, @@ -79,6 +77,7 @@ BOPDS_DS::BOPDS_DS() myMapPBCB(100, myAllocator), myFaceInfoPool(myAllocator), myShapesSD(100, myAllocator), + myMapVE(100, myAllocator), myInterfTB(100, myAllocator), myInterfVV(myAllocator), myInterfVE(myAllocator), @@ -105,6 +104,7 @@ BOPDS_DS::BOPDS_DS(const Handle(NCollection_BaseAllocator)& theAllocator) myMapPBCB(100, myAllocator), myFaceInfoPool(myAllocator), myShapesSD(100, myAllocator), + myMapVE(100, myAllocator), myInterfTB(100, myAllocator), myInterfVV(myAllocator), myInterfVE(myAllocator), @@ -140,6 +140,7 @@ void BOPDS_DS::Clear() myPaveBlocksPool.Clear(); myFaceInfoPool.Clear(); myShapesSD.Clear(); + myMapVE.Clear(); myMapPBCB.Clear(); myInterfTB.Clear(); myInterfVV.Clear(); @@ -148,6 +149,7 @@ void BOPDS_DS::Clear() myInterfEE.Clear(); myInterfEF.Clear(); myInterfFF.Clear(); + } //======================================================================= //function : SetArguments @@ -299,7 +301,6 @@ Standard_Integer BOPDS_DS::Index(const TopoDS_Shape& theS)const } return iRet; } - //======================================================================= //function : Init //purpose : @@ -308,11 +309,12 @@ void BOPDS_DS::Init() { Standard_Integer i1, i2, j, aI, aNb, aNbS, aNbE, aNbSx, nV, nW, nE, aNbF; Standard_Real aTol; + Handle(NCollection_IncAllocator) aAllocator; TopAbs_ShapeEnum aTS; + BOPDS_IndexRange aR; BOPCol_ListIteratorOfListOfInteger aIt1, aIt2, aIt3; BOPCol_ListIteratorOfListOfShape aIt; - BOPDS_IndexRange aR; - Handle(NCollection_IncAllocator) aAllocator; + BOPCol_MapOfShape aMS; // // 1 Append Source Shapes aNb=myArguments.Extent(); @@ -323,21 +325,17 @@ void BOPDS_DS::Init() myRanges.SetStartSize(aNb); myRanges.Init(); // - 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.SetStartSize(2*aNbS); myLines.SetIncrement(aNbS); @@ -376,7 +374,6 @@ void BOPDS_DS::Init() BOPDS_ShapeInfo& aSI=ChangeShapeInfo(j); // const TopoDS_Shape& aS=aSI.Shape(); - ResetShape(aS); // aTS=aSI.ShapeType(); // @@ -523,7 +520,56 @@ void BOPDS_DS::Init() }//for (j=0; jChecked()) { + 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); - } -} -#include - //======================================================================= //function : ComputeParameter //purpose : @@ -1832,3 +1866,83 @@ void SortShell(const int n, BOPDS_Pave *a) }//for (i=0; iPave1(); + 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); + } + } +} diff --git a/src/BOPInt/BOPInt_Context.cdl b/src/BOPInt/BOPInt_Context.cdl index 4403f4cfac..a507c6378c 100644 --- a/src/BOPInt/BOPInt_Context.cdl +++ b/src/BOPInt/BOPInt_Context.cdl @@ -150,16 +150,14 @@ is --- 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; - --bToUpdateVertex:out Boolean from Standard; - --aDist :out Real from Standard) - --returns Integer from Standard; - ---Purpose: - --- Computes parameter aT of the vertex aV on + 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, @@ -168,15 +166,7 @@ is --- 1. the edge is degenerated (-1) --- 2. the edge does not contain 3d curve and pcurves (-2) --- 3. projection algorithm failed (-3) - --- - --- Output parameters - --- bToUpdateVertex - the flag that indicates whether the - --- vertex tolerance should be modified or not - --- aDist - the value of the distance between the vertex - --- and the edge - - - + ComputeVF (me:mutable; aV : Vertex from TopoDS; aF : Face from TopoDS; @@ -192,8 +182,26 @@ is --- 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) + --- + + 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; aP2D : Pnt2d from gp) diff --git a/src/BOPInt/BOPInt_Context.cxx b/src/BOPInt/BOPInt_Context.cxx index 32692bbb1a..601d6f954e 100644 --- a/src/BOPInt/BOPInt_Context.cxx +++ b/src/BOPInt/BOPInt_Context.cxx @@ -432,13 +432,28 @@ } return 0; } + + //======================================================================= //function : ComputeVE //purpose : //======================================================================= - Standard_Integer BOPInt_Context::ComputeVE(const TopoDS_Vertex& aV1, - const TopoDS_Edge& aE2, - Standard_Real& aT) +Standard_Integer BOPInt_Context::ComputeVE(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 BOPInt_Context::ComputeVE(const TopoDS_Vertex& aV1, + const TopoDS_Edge& aE2, + Standard_Real& aT, + Standard_Real& aTolVnew) { if (BRep_Tool::Degenerated(aE2)) { return -1; @@ -469,6 +484,8 @@ aTolE2=BRep_Tool::Tolerance(aE2); aTolSum = aTolV1 + aTolE2 + Precision::Confusion(); // + aTolVnew=aDist+aTolE2; + // aT=aProjector.LowerDistanceParameter(); if (aDist > aTolSum) { return -4; @@ -476,13 +493,27 @@ return 0; } //======================================================================= -//function : ComputeVS +//function : ComputeVF //purpose : //======================================================================= - Standard_Integer BOPInt_Context::ComputeVF(const TopoDS_Vertex& aV1, - const TopoDS_Face& aF2, - Standard_Real& U, - Standard_Real& V) +Standard_Integer BOPInt_Context::ComputeVF(const TopoDS_Vertex& aV1, + 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 BOPInt_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; @@ -500,10 +531,13 @@ // 2. Check the distance between the projection point and // the original point aDist=aProjector.LowerDistance(); - + // 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; diff --git a/src/BOPTools/BOPTools_AlgoTools.cdl b/src/BOPTools/BOPTools_AlgoTools.cdl index e57cf4b653..9d7a981a4a 100644 --- a/src/BOPTools/BOPTools_AlgoTools.cdl +++ b/src/BOPTools/BOPTools_AlgoTools.cdl @@ -44,7 +44,7 @@ uses --raises is - ComputeVV(myclass; + ComputeVV(myclass; aV1:Vertex from TopoDS; aP2:Pnt from gp; aTolP2:Real from Standard) @@ -74,7 +74,7 @@ is theF2: Face from TopoDS; theCurve:Curve from IntTools; thePC1:Boolean from Standard; - thePC2:Boolean from Standard); + thePC2:Boolean from Standard); MakeContainer(myclass; theType:ShapeEnum from TopAbs; @@ -283,31 +283,7 @@ is OrientFacesOnShell (myclass; theS :out Shape from TopoDS); - CorrectTolerances (myclass; - theS: Shape from TopoDS; - theTolMax: Real from Standard =0.0001); - ---Purpose: - --- Provides valid values of tolerances for the shape - --- is max value of the tolerance that can be - --- accepted for correction. If real value of the tolerance - --- will be greater than , the correction does not - --- perform. - --- - CorrectCurveOnSurface (myclass; - theS: Shape from TopoDS; - theTolMax: Real from Standard =0.0001); - ---Purpose: - --- Provides valid values of tolerances for the shape - --- in terms of BRepCheck_InvalidCurveOnSurface. - --- - CorrectPointOnCurve (myclass; - theS: Shape from TopoDS; - theTolMax: Real from Standard =0.0001); - ---Purpose: - --- Provides valid values of tolerances for the shape - --- in terms of BRepCheck_InvalidPointOnCurve. - --- - --fields + --copy from BOPTools_AlgoTools.cdl MakeNewVertex (myclass; @@ -433,18 +409,61 @@ is returns Boolean from Standard; ---Purpose: --- Checks if it is possible to compute shrunk range for the edge . - --- - - CorrectShapeTolerances (myclass; - theS: Shape from TopoDS); - ---Purpose: - --- Corrects tolerance values of the sub-shapes of the shape if needed. - --- - + --- Dimension(myclass; theS:Shape from TopoDS) returns Integer from Standard; ---Purpose: --- Retutns dimension of the shape . + + CorrectTolerances (myclass; + theS: Shape from TopoDS; + theTolMax: Real from Standard =0.0001); + ---Purpose: + --- Provides valid values of tolerances for the shape + --- is max value of the tolerance that can be + --- accepted for correction. If real value of the tolerance + --- will be greater than , the correction does not + --- perform. + --- + CorrectCurveOnSurface (myclass; + theS: Shape from TopoDS; + theTolMax: Real from Standard =0.0001); + ---Purpose: + --- Provides valid values of tolerances for the shape + --- in terms of BRepCheck_InvalidCurveOnSurface. + --- + CorrectPointOnCurve (myclass; + theS: Shape from TopoDS; + theTolMax: Real from Standard =0.0001); + ---Purpose: + --- Provides valid values of tolerances for the shape + --- in terms of BRepCheck_InvalidPointOnCurve. + --- + CorrectShapeTolerances (myclass; + theS: Shape from TopoDS); + ---Purpose: + --- Corrects tolerance values of the sub-shapes of the shape if needed. + --- + + CorrectTolerances (myclass; + theS: Shape from TopoDS; + theMapToAvoid:IndexedMapOfShape from BOPCol; + theTolMax: Real from Standard =0.0001); + + CorrectCurveOnSurface (myclass; + theS: Shape from TopoDS; + theMapToAvoid:IndexedMapOfShape from BOPCol; + theTolMax: Real from Standard =0.0001); + + CorrectPointOnCurve (myclass; + theS: Shape from TopoDS; + theMapToAvoid:IndexedMapOfShape from BOPCol; + theTolMax: Real from Standard =0.0001); + + CorrectShapeTolerances (myclass; + theS: Shape from TopoDS; + theMapToAvoid:IndexedMapOfShape from BOPCol); + end AlgoTools; diff --git a/src/BOPTools/BOPTools_AlgoTools_1.cxx b/src/BOPTools/BOPTools_AlgoTools_1.cxx index a424ed7b45..73f3992cfb 100644 --- a/src/BOPTools/BOPTools_AlgoTools_1.cxx +++ b/src/BOPTools/BOPTools_AlgoTools_1.cxx @@ -81,11 +81,13 @@ 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, @@ -94,10 +96,12 @@ static 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 Standard_Real IntersectCurves2d(const gp_Pnt& aPV, @@ -106,28 +110,112 @@ static const TopoDS_Edge& aE2); static - void UpdateEdges(const TopoDS_Face& aF); + void UpdateEdges(const TopoDS_Face& aF, + const BOPCol_IndexedMapOfShape& aMapToAvoid); static - void UpdateVertices(const TopoDS_Edge& aE); + void UpdateVertices(const TopoDS_Edge& aE, + const BOPCol_IndexedMapOfShape& aMapToAvoid); + +static + void UpdateShape(const TopoDS_Shape& aS, + const Standard_Real aTol, + const BOPCol_IndexedMapOfShape& aMapToAvoid); //======================================================================= // Function : CorrectTolerances // purpose : //======================================================================= - void BOPTools_AlgoTools::CorrectTolerances(const TopoDS_Shape& aShape, - const Standard_Real aMaxTol) +void BOPTools_AlgoTools::CorrectTolerances(const TopoDS_Shape& aShape, + const Standard_Real aMaxTol) { - BOPTools_AlgoTools::CorrectPointOnCurve(aShape, aMaxTol); - BOPTools_AlgoTools::CorrectCurveOnSurface(aShape, aMaxTol); + BOPCol_IndexedMapOfShape aMapToAvoid; + // + CorrectTolerances(aShape, aMapToAvoid, aMaxTol); +} +//======================================================================= +// Function : CorrectShapeTolerances +// purpose : +//======================================================================= +void BOPTools_AlgoTools::CorrectShapeTolerances + (const TopoDS_Shape& aShape) +{ + BOPCol_IndexedMapOfShape aMapToAvoid; + // + BOPTools_AlgoTools::CorrectShapeTolerances(aShape, aMapToAvoid); +} +//======================================================================= +// Function : CorrectPointOnCurve +// purpose : +//======================================================================= +void BOPTools_AlgoTools::CorrectPointOnCurve + (const TopoDS_Shape& S, + const Standard_Real aMaxTol) +{ + BOPCol_IndexedMapOfShape aMapToAvoid; + // + BOPTools_AlgoTools::CorrectPointOnCurve(S, aMapToAvoid, aMaxTol); +} +//======================================================================= +// Function : CorrectCurveOnSurface +// purpose : +//======================================================================= +void BOPTools_AlgoTools::CorrectCurveOnSurface + (const TopoDS_Shape& S, + const Standard_Real aMaxTol) +{ + BOPCol_IndexedMapOfShape aMapToAvoid; + // + BOPTools_AlgoTools::CorrectCurveOnSurface(S, aMapToAvoid, aMaxTol); +} +//|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| +//======================================================================= +// Function : CorrectTolerances +// purpose : +//======================================================================= +void BOPTools_AlgoTools::CorrectTolerances + (const TopoDS_Shape& aShape, + const BOPCol_IndexedMapOfShape& aMapToAvoid, + const Standard_Real aMaxTol) +{ + BOPTools_AlgoTools::CorrectPointOnCurve(aShape, aMapToAvoid, aMaxTol); + BOPTools_AlgoTools::CorrectCurveOnSurface(aShape, aMapToAvoid,aMaxTol); +} +//======================================================================= +// Function : CorrectShapeTolerances +// purpose : +//======================================================================= +void BOPTools_AlgoTools::CorrectShapeTolerances + (const TopoDS_Shape& aShape, + const BOPCol_IndexedMapOfShape& aMapToAvoid) +{ + TopExp_Explorer aExp; + Standard_Integer aDim; + // + aDim=Dimension(aShape); + if (aDim == 1) { + aExp.Init(aShape, TopAbs_EDGE); + for (; aExp.More(); aExp.Next()) { + const TopoDS_Edge& aE = *(TopoDS_Edge*)&aExp.Current(); + UpdateVertices(aE, aMapToAvoid); + } + } + else { + aExp.Init(aShape, TopAbs_FACE); + for (; aExp.More(); aExp.Next()) { + const TopoDS_Face& aF = *(TopoDS_Face*)&aExp.Current(); + UpdateEdges(aF, aMapToAvoid); + } + } } - //======================================================================= // Function : CorrectPointOnCurve // purpose : //======================================================================= - void BOPTools_AlgoTools::CorrectPointOnCurve(const TopoDS_Shape& S, - const Standard_Real aMaxTol) +void BOPTools_AlgoTools::CorrectPointOnCurve + (const TopoDS_Shape& S, + const BOPCol_IndexedMapOfShape& aMapToAvoid, + const Standard_Real aMaxTol) { Standard_Integer i, aNb; TopTools_IndexedMapOfShape Edges; @@ -135,16 +223,17 @@ static aNb=Edges.Extent(); for (i=1; i<=aNb; i++) { const TopoDS_Edge& E= TopoDS::Edge(Edges(i)); - CheckEdge(E, aMaxTol); + CheckEdge(E, aMaxTol, aMapToAvoid); } } - //======================================================================= // Function : CorrectCurveOnSurface // purpose : //======================================================================= - void BOPTools_AlgoTools::CorrectCurveOnSurface(const TopoDS_Shape& S, - const Standard_Real aMaxTol) +void BOPTools_AlgoTools::CorrectCurveOnSurface + (const TopoDS_Shape& S, + const BOPCol_IndexedMapOfShape& aMapToAvoid, + const Standard_Real aMaxTol) { Standard_Integer i, aNbFaces, j, aNbEdges; TopTools_IndexedMapOfShape Faces; @@ -154,14 +243,14 @@ static for (i=1; i<=aNbFaces; i++) { const TopoDS_Face& F= TopoDS::Face(Faces(i)); // - CorrectWires(F); + CorrectWires(F, aMapToAvoid); // TopTools_IndexedMapOfShape Edges; TopExp::MapShapes (F, TopAbs_EDGE, Edges); aNbEdges=Edges.Extent(); for (j=1; j<=aNbEdges; j++) { const TopoDS_Edge& E= TopoDS::Edge(Edges(j)); - CorrectEdgeTolerance (E, F, aMaxTol); + CorrectEdgeTolerance (E, F, aMaxTol, aMapToAvoid); } } } @@ -169,14 +258,15 @@ static // Function : CorrectWires // purpose : //======================================================================= -void CorrectWires(const TopoDS_Face& aFx) +void CorrectWires(const TopoDS_Face& aFx, + const BOPCol_IndexedMapOfShape& aMapToAvoid) { Standard_Integer i, aNbV; Standard_Real aTol, aTol2, aD2, aD2max, aT1, aT2, aT, aTol2d; gp_Pnt aP, aPV; gp_Pnt2d aP2D; TopoDS_Face aF; - BRep_Builder aBB; + //BRep_Builder aBB; TopTools_IndexedDataMapOfShapeListOfShape aMVE; TopTools_ListIteratorOfListOfShape aIt, aIt1; // @@ -232,7 +322,8 @@ void CorrectWires(const TopoDS_Face& aFx) } if (aD2max>aTol2) { aTol=sqrt(aD2max); - aBB.UpdateVertex(aV, aTol); + UpdateShape(aV, aTol, aMapToAvoid); + //aBB.UpdateVertex(aV, aTol); } } } @@ -294,7 +385,8 @@ Standard_Real IntersectCurves2d(const gp_Pnt& aPV, //======================================================================= 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 @@ -435,9 +527,9 @@ void CorrectEdgeTolerance (const TopoDS_Edge& myShape, } // if (aNewTolUpdateTolerance(aNewTol+Delta); - // - CorrectVertexTolerance(myShape); + UpdateShape(myShape, aNewTol+Delta, aMapToAvoid); + //TE->UpdateTolerance(aNewTol+Delta); + CorrectVertexTolerance(myShape, aMapToAvoid); } } @@ -453,8 +545,9 @@ void CorrectEdgeTolerance (const TopoDS_Edge& myShape, //return;//BRepCheck::Add(lst,BRepCheck_InvalidSameParameterFlag); } if (aNewTolUpdateTolerance(aNewTol+Delta); - CorrectVertexTolerance(myShape); + UpdateShape(myShape, aNewTol+Delta, aMapToAvoid); + //TE->UpdateTolerance(aNewTol+Delta); + CorrectVertexTolerance(myShape, aMapToAvoid); } } } @@ -501,8 +594,9 @@ void CorrectEdgeTolerance (const TopoDS_Edge& myShape, if (okx) { //return;//BRepCheck::Add(lst,BRepCheck_InvalidCurveOnSurface); if (aNewTolUpdateTolerance(aNewTol+Delta); - CorrectVertexTolerance(myShape); + UpdateShape(myShape, aNewTol+Delta, aMapToAvoid); + //TE->UpdateTolerance(aNewTol+Delta); + CorrectVertexTolerance(myShape, aMapToAvoid); } } } @@ -511,37 +605,12 @@ void CorrectEdgeTolerance (const TopoDS_Edge& myShape, } // end of 2. Tolerances in InContext } - -//======================================================================= -// Function : CorrectShapeTolerances -// purpose : -//======================================================================= - void BOPTools_AlgoTools::CorrectShapeTolerances(const TopoDS_Shape& aShape) -{ - TopExp_Explorer aExp; - Standard_Integer aDim; - // - aDim=Dimension(aShape); - if (aDim == 1) { - aExp.Init(aShape, TopAbs_EDGE); - for (; aExp.More(); aExp.Next()) { - const TopoDS_Edge& aE = *(TopoDS_Edge*)&aExp.Current(); - UpdateVertices(aE); - } - } else { - aExp.Init(aShape, TopAbs_FACE); - for (; aExp.More(); aExp.Next()) { - const TopoDS_Face& aF = *(TopoDS_Face*)&aExp.Current(); - UpdateEdges(aF); - } - } -} - //======================================================================= //function : CorrectVertexTolerance //purpose : //======================================================================= -void CorrectVertexTolerance(const TopoDS_Edge& aE) +void CorrectVertexTolerance(const TopoDS_Edge& aE, + const BOPCol_IndexedMapOfShape& aMapToAvoid) { Standard_Integer k, aNbV; Standard_Real aTolE, aTolV; @@ -555,8 +624,9 @@ void CorrectVertexTolerance(const TopoDS_Edge& aE) const TopoDS_Vertex& aV=TopoDS::Vertex(aVMap(k)); aTolV=BRep_Tool::Tolerance(aV); if (aTolVUpdateTolerance(aTolE); + UpdateShape(aV, aTolE, aMapToAvoid); + //Handle(BRep_TVertex)& aTV = *((Handle(BRep_TVertex)*)&aV.TShape()); + //aTV->UpdateTolerance(aTolE); } } } @@ -677,12 +747,13 @@ Standard_Boolean Validate(const Adaptor3d_Curve& CRef, return aFlag; } - //======================================================================= // Function : CheckEdge // purpose : Correct tolerances for Vertices on Edge //======================================================================= -void CheckEdge (const TopoDS_Edge& Ed, const Standard_Real aMaxTol) +void CheckEdge (const TopoDS_Edge& Ed, + const Standard_Real aMaxTol, + const BOPCol_IndexedMapOfShape& aMapToAvoid) { TopoDS_Edge E=Ed; E.Orientation(TopAbs_FORWARD); @@ -726,8 +797,10 @@ void CheckEdge (const TopoDS_Edge& Ed, const Standard_Real aMaxTol) aD2=prep.SquareDistance(Controlp); if (aD2 > Tol) { aNewTolerance=sqrt(aD2)+dd; - if (aNewToleranceUpdateTolerance(aNewTolerance); + if (aNewToleranceUpdateTolerance(aNewTolerance); + } } } itpr.Next(); @@ -747,8 +820,10 @@ void CheckEdge (const TopoDS_Edge& Ed, const Standard_Real aMaxTol) if (aD2 > Tol) { aNewTolerance=sqrt(aD2)+dd; - if (aNewToleranceUpdateTolerance(aNewTolerance); + if (aNewToleranceUpdateTolerance(aNewTolerance); + } } } } @@ -757,16 +832,16 @@ void CheckEdge (const TopoDS_Edge& Ed, const Standard_Real aMaxTol) } } } - //======================================================================= // Function : UpdateVertices // purpose : //======================================================================= - void UpdateVertices(const TopoDS_Edge& aE) +void UpdateVertices(const TopoDS_Edge& aE, + const BOPCol_IndexedMapOfShape& aMapToAvoid) { Standard_Real aTolE, aTolV; TopoDS_Iterator aItE; - BRep_Builder aBB; + //BRep_Builder aBB; // aTolE = BRep_Tool::Tolerance(aE); aItE.Initialize(aE); @@ -774,7 +849,8 @@ void CheckEdge (const TopoDS_Edge& Ed, const Standard_Real aMaxTol) const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&aItE.Value(); aTolV = BRep_Tool::Tolerance(aV); if (aTolV < aTolE) { - aBB.UpdateVertex(aV, aTolE); + UpdateShape(aV, aTolE, aMapToAvoid); + //aBB.UpdateVertex(aV, aTolE); } } } @@ -782,11 +858,12 @@ void CheckEdge (const TopoDS_Edge& Ed, const Standard_Real aMaxTol) // 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; + //BRep_Builder aBB; // aTolE = aTolF = BRep_Tool::Tolerance(aF); aItF.Initialize(aF); @@ -798,18 +875,45 @@ void CheckEdge (const TopoDS_Edge& Ed, const Standard_Real aMaxTol) const TopoDS_Edge& aE = *(TopoDS_Edge*)&aItW.Value(); aTolE = BRep_Tool::Tolerance(aE); if (aTolE < aTolF) { - aBB.UpdateEdge(aE, aTolF); + UpdateShape(aE, aTolF,aMapToAvoid); + //aBB.UpdateEdge(aE, aTolF); aTolE = aTolF; } - UpdateVertices(aE); + UpdateVertices(aE, aMapToAvoid); } } 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); + //aBB.UpdateVertex(aV, aTolF); } } } } +//======================================================================= +//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); + } +} diff --git a/src/BRep/BRep_Builder.cxx b/src/BRep/BRep_Builder.cxx index 9aebd3427b..081ac5e632 100644 --- a/src/BRep/BRep_Builder.cxx +++ b/src/BRep/BRep_Builder.cxx @@ -424,6 +424,9 @@ void BRep_Builder::MakeFace(TopoDS_Face& F, const Standard_Real Tol) const { Handle(BRep_TFace) TF = new BRep_TFace(); + if(!F.IsNull() && F.Locked()) { + Standard_NullObject::Raise("BRep_Builder::MakeFace"); + } TF->Surface(S); TF->Tolerance(Tol); MakeShape(F,TF); @@ -439,6 +442,9 @@ void BRep_Builder::MakeFace(TopoDS_Face& F, const Handle(Poly_Triangulation)& T) const { Handle(BRep_TFace) TF = new BRep_TFace(); + if(!F.IsNull() && F.Locked()) { + Standard_NullObject::Raise("BRep_Builder::MakeFace"); + } TF->Triangulation(T); MakeShape(F, TF); } @@ -455,6 +461,9 @@ void BRep_Builder::MakeFace(TopoDS_Face& F, const Standard_Real Tol) const { Handle(BRep_TFace) TF = new BRep_TFace(); + if(!F.IsNull() && F.Locked()) { + Standard_NullObject::Raise("BRep_Builder::MakeFace"); + } TF->Surface(S); TF->Tolerance(Tol); TF->Location(L); @@ -473,6 +482,9 @@ void BRep_Builder::UpdateFace(const TopoDS_Face& F, const Standard_Real Tol) const { const Handle(BRep_TFace)& TF = *((Handle(BRep_TFace)*) &F.TShape()); + if(!F.IsNull() && F.Locked()) { + Standard_NullObject::Raise("BRep_Builder::UpdateFace"); + } TF->Surface(S); TF->Tolerance(Tol); TF->Location(L.Predivided(F.Location())); @@ -488,6 +500,11 @@ void BRep_Builder::UpdateFace(const TopoDS_Face& F, void BRep_Builder::UpdateFace(const TopoDS_Face& F, const Handle(Poly_Triangulation)& T) const { + const Handle(BRep_TFace)& TF = *((Handle(BRep_TFace)*) &F.TShape()); + if(TF->Locked()) + { + Standard_NullObject::Raise("BRep_Builder::UpdateFace"); + } (*((Handle(BRep_TFace)*) &F.TShape()))->Triangulation(T); F.TShape()->Modified(Standard_True); } @@ -501,6 +518,11 @@ void BRep_Builder::UpdateFace(const TopoDS_Face& F, void BRep_Builder::UpdateFace(const TopoDS_Face& F, const Standard_Real Tol) const { + const Handle(BRep_TFace)& TF = *((Handle(BRep_TFace)*) &F.TShape()); + if(TF->Locked()) + { + Standard_NullObject::Raise("BRep_Builder::UpdateFace"); + } (*((Handle(BRep_TFace)*) &F.TShape()))->Tolerance(Tol); F.TShape()->Modified(Standard_True); } @@ -514,6 +536,11 @@ void BRep_Builder::UpdateFace(const TopoDS_Face& F, void BRep_Builder::NaturalRestriction(const TopoDS_Face& F, const Standard_Boolean N) const { + const Handle(BRep_TFace)& TF = *((Handle(BRep_TFace)*) &F.TShape()); + if(TF->Locked()) + { + Standard_NullObject::Raise("BRep_Builder::NaturalRestriction"); + } (*((Handle(BRep_TFace)*) &F.TShape()))->NaturalRestriction(N); F.TShape()->Modified(Standard_True); } @@ -527,6 +554,10 @@ void BRep_Builder::NaturalRestriction(const TopoDS_Face& F, void BRep_Builder::MakeEdge(TopoDS_Edge& E) const { Handle(BRep_TEdge) TE = new BRep_TEdge(); + if(!E.IsNull() && E.Locked()) + { + Standard_NullObject::Raise("BRep_Builder::MakeEdge"); + } TE->Closed(Standard_False); MakeShape(E,TE); } @@ -544,7 +575,10 @@ void BRep_Builder::UpdateEdge(const TopoDS_Edge& E, { const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape()); const TopLoc_Location l = L.Predivided(E.Location()); - + if(TE->Locked()) + { + Standard_NullObject::Raise("BRep_Builder::UpdateEdge"); + } UpdateCurves(TE->ChangeCurves(),C,l); if (!C.IsNull()) TE->Closed(C->IsClosed()); @@ -565,6 +599,10 @@ void BRep_Builder::UpdateEdge(const TopoDS_Edge& E, const Standard_Real Tol) const { const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape()); + if(TE->Locked()) + { + Standard_NullObject::Raise("BRep_Builder::UpdateEdge"); + } const TopLoc_Location l = L.Predivided(E.Location()); UpdateCurves(TE->ChangeCurves(),C,S,l); @@ -588,6 +626,10 @@ void BRep_Builder::UpdateEdge(const TopoDS_Edge& E, const gp_Pnt2d& Pl) const { const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape()); + if(TE->Locked()) + { + Standard_NullObject::Raise("BRep_Builder::UpdateEdge"); + } const TopLoc_Location l = L.Predivided(E.Location()); UpdateCurves(TE->ChangeCurves(),C,S,l,Pf,Pl); @@ -610,6 +652,10 @@ void BRep_Builder::UpdateEdge(const TopoDS_Edge& E, const Standard_Real Tol) const { const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape()); + if(TE->Locked()) + { + Standard_NullObject::Raise("BRep_Builder::UpdateEdge"); + } const TopLoc_Location l = L.Predivided(E.Location()); UpdateCurves(TE->ChangeCurves(),C1,C2,S,l); @@ -636,6 +682,10 @@ void BRep_Builder::UpdateEdge(const TopoDS_Edge& E, const gp_Pnt2d& Pl) const { const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape()); + if(TE->Locked()) + { + Standard_NullObject::Raise("BRep_Builder::UpdateEdge"); + } const TopLoc_Location l = L.Predivided(E.Location()); UpdateCurves(TE->ChangeCurves(),C1,C2,S,l,Pf,Pl); @@ -657,7 +707,10 @@ void BRep_Builder::UpdateEdge(const TopoDS_Edge& E, const TopLoc_Location& L) const { const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape()); - + if(TE->Locked()) + { + Standard_NullObject::Raise("BRep_Builder::UpdateEdge"); + } BRep_ListOfCurveRepresentation& lcr = TE->ChangeCurves(); BRep_ListIteratorOfListOfCurveRepresentation itcr(lcr); @@ -694,6 +747,10 @@ void BRep_Builder::UpdateEdge(const TopoDS_Edge& E, const TopLoc_Location& L) const { const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape()); + if(TE->Locked()) + { + Standard_NullObject::Raise("BRep_Builder::UpdateEdge"); + } const TopLoc_Location l = L.Predivided(E.Location()); Standard_Boolean isModified = Standard_False; @@ -741,6 +798,10 @@ void BRep_Builder::UpdateEdge(const TopoDS_Edge& E, const TopLoc_Location& L) const { const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape()); + if(TE->Locked()) + { + Standard_NullObject::Raise("BRep_Builder::UpdateEdge"); + } const TopLoc_Location l = L.Predivided(E.Location()); Standard_Boolean isModified = Standard_False; @@ -800,6 +861,10 @@ void BRep_Builder::UpdateEdge(const TopoDS_Edge& E, const TopLoc_Location& L) const { const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape()); + if(TE->Locked()) + { + Standard_NullObject::Raise("BRep_Builder::UpdateEdge"); + } TopLoc_Location l = L.Predivided(E.Location()); BRep_ListOfCurveRepresentation& lcr = TE->ChangeCurves(); @@ -854,6 +919,10 @@ void BRep_Builder::UpdateEdge(const TopoDS_Edge& E, const TopLoc_Location& L) const { const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape()); + if(TE->Locked()) + { + Standard_NullObject::Raise("BRep_Builder::UpdateEdge"); + } TopLoc_Location l = L.Predivided(E.Location()); BRep_ListOfCurveRepresentation& lcr = TE->ChangeCurves(); @@ -890,6 +959,10 @@ void BRep_Builder::UpdateEdge(const TopoDS_Edge& E, const Standard_Real Tol) const { const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape()); + if(TE->Locked()) + { + Standard_NullObject::Raise("BRep_Builder::UpdateEdge"); + } TE->UpdateTolerance(Tol); TE->Modified(Standard_True); } @@ -924,7 +997,10 @@ void BRep_Builder::Continuity(const TopoDS_Edge& E, const GeomAbs_Shape C)const { const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape()); - + if(TE->Locked()) + { + Standard_NullObject::Raise("BRep_Builder::Continuity"); + } const TopLoc_Location l1 = L1.Predivided(E.Location()); const TopLoc_Location l2 = L2.Predivided(E.Location()); @@ -941,7 +1017,11 @@ void BRep_Builder::Continuity(const TopoDS_Edge& E, void BRep_Builder::SameParameter(const TopoDS_Edge& E, const Standard_Boolean S) const { - const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape()); + const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape()); + if(TE->Locked()) + { + Standard_NullObject::Raise("BRep_Builder::SameParameter"); + } TE->SameParameter(S); TE->Modified(Standard_True); } @@ -955,6 +1035,10 @@ void BRep_Builder::SameRange(const TopoDS_Edge& E, const Standard_Boolean S) const { const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape()); + if(TE->Locked()) + { + Standard_NullObject::Raise("BRep_Builder::SameRange"); + } TE->SameRange(S); TE->Modified(Standard_True); } @@ -968,6 +1052,10 @@ void BRep_Builder::Degenerated(const TopoDS_Edge& E, const Standard_Boolean D) const { const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape()); + if(TE->Locked()) + { + Standard_NullObject::Raise("BRep_Builder::Degenerated"); + } TE->Degenerated(D); if (D) { // set a null 3d curve @@ -989,7 +1077,10 @@ void BRep_Builder::Range(const TopoDS_Edge& E, { // set the range to all the representations if Only3d=FALSE const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape()); - + if(TE->Locked()) + { + Standard_NullObject::Raise("BRep_Builder::Range"); + } BRep_ListOfCurveRepresentation& lcr = TE->ChangeCurves(); BRep_ListIteratorOfListOfCurveRepresentation itcr(lcr); Handle(BRep_GCurve) GC; @@ -1032,6 +1123,10 @@ void BRep_Builder::Range(const TopoDS_Edge& E, const Standard_Real Last) const { const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape()); + if(TE->Locked()) + { + Standard_NullObject::Raise("BRep_Builder::Range"); + } const TopLoc_Location l = L.Predivided(E.Location()); BRep_ListOfCurveRepresentation& lcr = TE->ChangeCurves(); @@ -1074,7 +1169,10 @@ void BRep_Builder::Transfert(const TopoDS_Edge& Ein, const TopoDS_Edge& Eout) const { const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &Ein.TShape()); - + if(TE->Locked()) + { + Standard_NullObject::Raise("BRep_Builder::Transfert"); + } const Standard_Real tol = TE->Tolerance(); BRep_ListOfCurveRepresentation& lcr = TE->ChangeCurves(); @@ -1123,7 +1221,10 @@ void BRep_Builder::UpdateVertex(const TopoDS_Vertex& V, const Standard_Real Tol) const { const Handle(BRep_TVertex)& TV = *((Handle(BRep_TVertex)*) &V.TShape()); - + if(TV->Locked()) + { + Standard_NullObject::Raise("BRep_Builder::UpdateVertex"); + } TV->Pnt(P.Transformed(V.Location().Inverted().Transformation())); TV->UpdateTolerance(Tol); TV->Modified(Standard_True); @@ -1146,7 +1247,10 @@ void BRep_Builder::UpdateVertex(const TopoDS_Vertex& V, const Handle(BRep_TVertex)& TV = *((Handle(BRep_TVertex)*) &V.TShape()); const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape()); - + if(TV->Locked() || TE->Locked()) + { + Standard_NullObject::Raise("BRep_Builder::UpdateVertex"); + } TopLoc_Location L = E.Location().Predivided(V.Location()); // Search the vertex in the edge @@ -1227,8 +1331,10 @@ void BRep_Builder::UpdateVertex(const TopoDS_Vertex& V, const Handle(BRep_TVertex)& TV = *((Handle(BRep_TVertex)*) &V.TShape()); const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape()); - - + if(TV->Locked() || TE->Locked()) + { + Standard_NullObject::Raise("BRep_Builder::UpdateVertex"); + } // Search the vertex in the edge TopAbs_Orientation ori = TopAbs_INTERNAL; @@ -1294,7 +1400,10 @@ void BRep_Builder::UpdateVertex(const TopoDS_Vertex& Ve, const Standard_Real Tol) const { const Handle(BRep_TVertex)& TV = *((Handle(BRep_TVertex)*) &Ve.TShape()); - + if(TV->Locked()) + { + Standard_NullObject::Raise("BRep_Builder::UpdateVertex"); + } TopLoc_Location L; const Handle(Geom_Surface)& S = BRep_Tool::Surface(F,L); L = L.Predivided(Ve.Location()); @@ -1314,6 +1423,10 @@ void BRep_Builder::UpdateVertex(const TopoDS_Vertex& V, const Standard_Real Tol) const { const Handle(BRep_TVertex)& TV = *((Handle(BRep_TVertex)*) &V.TShape()); + if(TV->Locked()) + { + Standard_NullObject::Raise("BRep_Builder::UpdateVertex"); + } TV->UpdateTolerance(Tol); TV->Modified(Standard_True); } diff --git a/src/DBRep/DBRep.cxx b/src/DBRep/DBRep.cxx index 7ceb339868..b0aadf4e02 100644 --- a/src/DBRep/DBRep.cxx +++ b/src/DBRep/DBRep.cxx @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -968,6 +969,112 @@ static Standard_Integer countshapes(Draw_Interpretor& di, return 0; } +//======================================================================= +// +//======================================================================= +void setProp(TopoDS_Shape Sh, const char** a, Standard_Integer n) +{ + Standard_Integer i; + for(i = 2; i < n; i++) { + if (strstr ( a[i], "free" )) { + if(a[i][0] == '-') { + Sh.Free(Standard_False); + } + else { + Sh.Free(Standard_True); + } + } + if (strstr ( a[i], "modified" )) { + if(a[i][0] == '-') { + Sh.Modified(Standard_False); + } + else { + Sh.Modified(Standard_True); + } + } + if (strstr ( a[i], "checked" )) { + if(a[i][0] == '-') { + Sh.Checked(Standard_False); + } + else { + Sh.Checked(Standard_True); + } + } + if (strstr ( a[i], "orientable" )) { + if(a[i][0] == '-') { + Sh.Orientable(Standard_False); + } + else { + Sh.Orientable(Standard_True); + } + } + if (strstr ( a[i], "closed" )) { + if(a[i][0] == '-') { + Sh.Closed(Standard_False); + } + else { + Sh.Closed(Standard_True); + } + } + if (strstr ( a[i], "infinite" )) { + if(a[i][0] == '-') { + Sh.Infinite(Standard_False); + } + else { + Sh.Infinite(Standard_True); + } + } + if (strstr ( a[i], "convex" )) { + if(a[i][0] == '-') { + Sh.Convex(Standard_False); + } + else { + Sh.Convex(Standard_True); + } + } + if (strstr ( a[i], "locked" )) { + if(a[i][0] == '-') { + Sh.Locked(Standard_False); + } + else { + Sh.Locked(Standard_True); + } + } + } +} + +//======================================================================= +// +//======================================================================= +static Standard_Integer setFlags(Draw_Interpretor& , + Standard_Integer n, const char** a) +{ + if (n < 3) return 1; + + TopExp_Explorer ex; + TopoDS_Shape Sh = DBRep::Get(a[1]); + + if (Sh.IsNull()) return 1; + + setProp(Sh, a, n); + for (ex.Init (Sh,TopAbs_VERTEX); ex.More(); ex.Next()) { + TopoDS_Shape S = ex.Current(); + setProp(S, a, n); + } + + for (ex.Init (Sh,TopAbs_EDGE); ex.More(); ex.Next()) { + TopoDS_Shape S = ex.Current(); + setProp(S, a, n); + } + + for (ex.Init (Sh,TopAbs_FACE); ex.More(); ex.Next()) { + TopoDS_Shape S = ex.Current(); + setProp(S, a, n); + } + + return 0; +} + //======================================================================= //memory management //======================================================================= @@ -1200,6 +1307,9 @@ void DBRep::BasicCommands(Draw_Interpretor& theCommands) __FILE__,nbshapes,g); theCommands.Add("numshapes","numshapes s; size of shape",__FILE__,numshapes,g); theCommands.Add("countshapes","countshapes s; count of shape",__FILE__,countshapes,g); + theCommands.Add("setflags", + "setflags shape_name flag1[flag2...]\n sets flags for shape(free, modidfied, checked, orientable, closed, infinite, convex, locked), for exmple or if necessary unflag ", + __FILE__,setFlags,g); // theCommands.Add("dumpmmgt", // "dump le contenu du gestionnaire de memoire",__FILE__,dumpmmgt,g); diff --git a/src/TopoDS/TopoDS_Shape.cdl b/src/TopoDS/TopoDS_Shape.cdl index c74b40931b..ea6faffc19 100644 --- a/src/TopoDS/TopoDS_Shape.cdl +++ b/src/TopoDS/TopoDS_Shape.cdl @@ -344,7 +344,15 @@ is TShape(me : in out; T : TShape from TopoDS) ---C++: inline - is static; + is static; + + Locked(me:out; + bFlag:Boolean from Standard); + ---C++: inline + + Locked(me) + returns Boolean from Standard; + ---C++: inline fields myTShape : TShape from TopoDS; diff --git a/src/TopoDS/TopoDS_Shape.lxx b/src/TopoDS/TopoDS_Shape.lxx index 0493fdb3c8..3f254f4f7a 100644 --- a/src/TopoDS/TopoDS_Shape.lxx +++ b/src/TopoDS/TopoDS_Shape.lxx @@ -5,8 +5,8 @@ // // 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 +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License 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. @@ -152,6 +152,26 @@ inline void TopoDS_Shape::Free (const Standard_Boolean B) myTShape->Free(B); } +//======================================================================= +//function : Locked +//purpose : +//======================================================================= + +inline Standard_Boolean TopoDS_Shape::Locked () const +{ + return myTShape->Locked(); +} + +//======================================================================= +//function : Locked +//purpose : +//======================================================================= + +inline void TopoDS_Shape::Locked (const Standard_Boolean B) +{ + myTShape->Locked(B); +} + //======================================================================= //function : Modified //purpose : @@ -432,7 +452,7 @@ inline TopoDS_Shape TopoDS_Shape::EmptyCopied() const //purpose : //======================================================================= -inline void TopoDS_Shape::TShape (const Handle(TopoDS_TShape& TS)) +inline void TopoDS_Shape::TShape (const Handle(TopoDS_TShape)& TS) { myTShape = TS; } diff --git a/src/TopoDS/TopoDS_TShape.cdl b/src/TopoDS/TopoDS_TShape.cdl index b4b22089fc..d9e9f199c4 100644 --- a/src/TopoDS/TopoDS_TShape.cdl +++ b/src/TopoDS/TopoDS_TShape.cdl @@ -152,7 +152,16 @@ is ---C++: return & ---C++: inline is static private; - + + + Locked(me:mutable; + bFlag:Boolean from Standard); + ---C++: inline + + Locked(me) + returns Boolean from Standard; + ---C++: inline + fields myShapes : ListOfShape from TopoDS; myFlags : Integer from Standard; diff --git a/src/TopoDS/TopoDS_TShape.lxx b/src/TopoDS/TopoDS_TShape.lxx index 020176d17c..9bf1eebc51 100644 --- a/src/TopoDS/TopoDS_TShape.lxx +++ b/src/TopoDS/TopoDS_TShape.lxx @@ -5,8 +5,8 @@ // // 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 +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License 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. @@ -26,6 +26,7 @@ #define TopoDS_TShape_Flags_Closed (1<<4) #define TopoDS_TShape_Flags_Infinite (1<<5) #define TopoDS_TShape_Flags_Convex (1<<6) +#define TopoDS_TShape_Flags_Locked (1<<7) //======================================================================= @@ -61,6 +62,26 @@ inline void TopoDS_TShape::Free(const Standard_Boolean F) else myFlags &= ~TopoDS_TShape_Flags_Free; } +//======================================================================= +//function : Locked +//purpose : +//======================================================================= +inline Standard_Boolean TopoDS_TShape::Locked() const +{ + return ((myFlags & TopoDS_TShape_Flags_Locked) != 0); +} + +//======================================================================= +//function : Locked +//purpose : +//======================================================================= + +inline void TopoDS_TShape::Locked(const Standard_Boolean F) +{ + if (F) myFlags |= TopoDS_TShape_Flags_Locked; + else myFlags &= ~TopoDS_TShape_Flags_Locked; +} + //======================================================================= //function : Modified //purpose :