From: emv Date: Wed, 17 Oct 2012 08:55:53 +0000 (+0400) Subject: 0021762: Integration of new Boolean Operation algorithm to OCCT. X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=3c8a88eac6b7e84aaeedebde44f4faa643791c60;p=occt-copy.git 0021762: Integration of new Boolean Operation algorithm to OCCT. BRepOffset/BRepOffset_Tool.cxx, Features and Fillets algorithms have been ported on new BO algorithm. Old BO algorithm, that was implemented in BOP, BooleanOperations and BOPTools packages, has been deleted. Porting SALOME algorithms to new BOP algorithm. Fixing regressions. Rebased on current master. --- diff --git a/adm/UDLIST b/adm/UDLIST index e8ec8abe6d..3c3698d0f2 100644 --- a/adm/UDLIST +++ b/adm/UDLIST @@ -92,7 +92,6 @@ t TKG3d t TKGeomBase p AppBlend p ApproxInt -p BOP p BOPTColStd p BOPTools p BRepAlgo @@ -124,7 +123,6 @@ p BiTgte p Bisector p Blend p BlendFunc -p BooleanOperations p ChFi2d p ChFi3d p ChFiDS @@ -502,3 +500,7 @@ t TKQADraw p QADNaming p QABugs p Font +p BOPAlgo +p BOPDS +p BOPCol +p BOPInt diff --git a/src/BOP/BOP.cdl b/src/BOP/BOP.cdl deleted file mode 100755 index 724d3a60f5..0000000000 --- a/src/BOP/BOP.cdl +++ /dev/null @@ -1,329 +0,0 @@ --- Created on: 2001-03-29 --- Created by: Peter KURNEV --- Copyright (c) 2001-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -package BOP - - ---Purpose: Contains main and auxiliary classes to provide boolean operations - -- (BO) Common, Cut, Fuse, Section between a couple BRep shapes. - -uses - Geom2dInt, - TopoDS, - TopAbs, - TopTools, - TopExp, - gp, - TColgp, - ProjLib, - Geom2d, - Geom, - TColStd, - TopTools, - TCollection, - BRepClass, - BRep, - BRepClass3d, - BooleanOperations, - IntTools, - BOPTools, - BOPTColStd - -is - --- - --- E n u m e r a t i o n s - --- - enumeration Operation is - COMMON, - FUSE, - CUT, - CUT21, - SECTION, - UNKNOWN - end Operation; - - enumeration LoopEnum is - ANYLOOP, - BOUNDARY, - BLOCK - end LoopEnum; - - enumeration CheckStatus is - CheckUnknown, - BadType, - SelfIntersect, - TooSmallEdge, - NonRecoverableFace, - IncompatibilityOfVertex, - IncompatibilityOfEdge, - IncompatibilityOfFace - end CheckStatus; - --- - --- T h e C l a s s e s - --- - - deferred class Builder; - ---Purpose: - --- Root class for performing a BO - --- - class WireWire; - ---Purpose: - --- Performs BO (Common,Cut,Fuse) for wires(edges) - --- - class WireShell; - ---Purpose: - --- Performs BO (Common,Cut,Fuse) for wire(edge)/shell(face) - --- - class WireSolid; - ---Purpose: - --- Performs BO (Common,Cut,Fuse) for wire(edge)/solid - --- - class WireShape; - ---Purpose: - --- Root class for Wire/... Biulders - --- - - class SolidSolid; - ---Purpose: - --- Performs BO (Common,Cut,Fuse) for solids - --- - class ShellShell; - ---Purpose: - --- Performs BO (Common,Cut,Fuse) for shell/shell arguments - --- - class ShellSolid; - ---Purpose: - --- Performs BO (Common,Cut,Fuse) for shell/solid arguments - --- - - class EmptyBuilder; - ---Purpose: - --- Performs BO (Common,Cut,Fuse) for shapes - --- in cases when one of arguments(or both) is(are) empty - --- - deferred class HistoryCollector; - - class SolidSolidHistoryCollector; - - class ShellSolidHistoryCollector; - - class WireSolidHistoryCollector; - - class SectionHistoryCollector; - - class BuilderTools; - ---Purpose: - --- Handy tools to help building a result - --- - class Section; - ---Purpose: - --- Performs the BO (Section) - --- for the shapes where it is valid one - --- - class Refiner; - ---Purpose: - --- Refines the result of the BO if necessary - --- - class ShapeSet; - ---Purpose: - --- Root auxiliary class for set of shapes - --- to build new faces from wires,new solids from shells - --- - class WireEdgeSet; - ---Purpose: - --- Class for set of edges and wires to build new faces - --- - class ShellFaceSet; - ---Purpose: - --- Class for set of faces and shells to build new solids - --- - class BlockBuilder; - ---Purpose: - --- Auxiliary class to storage and operate with data of - --- connexity blocks inside - --- - class BlockIterator; - ---Purpose: - --- Auxiliary class to iterate data inside the given - --- connexity block - --- - class Loop; - ---Purpose: - --- Auxiliary class containing data about an existing shape - --- (Shell,Wire)or a set of shapes (Faces,Edges) which are connex. - --- - class LoopSet; - ---Purpose: - --- Auxiliary class to storage and iterate on Loop(s) - --- - - deferred class LoopClassifier; - ---Purpose: - --- Root class to classify loops in order to build Areas - --- - deferred class CompositeClassifier; - ---Purpose: - --- Cclassify composite Loops, i.e, loops that can be - --- either a Shape, or a block of Elements - --- - class WireEdgeClassifier; - ---Purpose: - --- Classify loops that consist of edges and wires - --- - class ShellFaceClassifier; - ---Purpose: - --- Classify loops that consist of faces and shells - --- - class AreaBuilder; - ---Purpose: - --- Root class to provide building valid areas from - --- corresponding shape sets - --- - class Area2dBuilder; - ---Purpose: - --- Constructs areas for Faces from a WireEdgeSet - --- - class FaceAreaBuilder; - ---Purpose: - --- constructs Loops for Faces from a WireEdgeSet - --- - class FaceBuilder; - ---Purpose: - --- construct Faces from a WireEdgeSet - --- - class Area3dBuilder; - ---Purpose: - --- Constructs areas for Faces from a WireEdgeSet - --- - class SolidAreaBuilder; - ---Purpose: - --- Constructs areas for Solids from a ShellFaceSet - --- - class SolidBuilder; - ---Purpose: - --- Constructs Solids from a ShellFaceSet - --- - class EdgeInfo; - ---Purpose: - --- Auxiliary class to store data about edges on a face - --- that have common vertex - --- - class FaceInfo; - ---Purpose: - --- Auxiliary class to store data about faces on a shell - --- that have common edge - --- - class WireSplitter; - ---Purpose: - --- The algorithm to split invalid (multiconnexed) - --- wires on a face onto valid ones - --- - class ShellSplitter; - ---Purpose: - --- The algorithm to split invalid (multiconnexed) - --- shells on a solid onto valid ones - --- - class ConnexityBlock; - ---Purpose: - --- Auxiliary class to create and store data about a set - --- of connex shapes - --- - class WESCorrector; - ---Purpose: - --- The algorithm to change the WES contents - --- The NewWES will contain only wires instead of - --- wires and edges. - --- - class SFSCorrector; - ---Purpose: - --- The algorithm to change the SFS contents. - --- The NewSFS will contain only shells instead of - --- shells and faces. - --- - - class CorrectTolerances; - ---Purpose: - --- Auxiliary class to provide valid values for result's tolerances' - --- - class Draw; - ---Purpose: - --- Auxiliary class to display intermediate results in Draw's windows - --- for the debugging purposes - --- - class SDFWESFiller; - ---Purpose: - --- Fills a wire edges set for a couple of faces that are same domain - --- - - class CheckResult; - class ArgumentAnalyzer; - --- - --- P o i n t e r s - --- - pointer PWireEdgeSet to WireEdgeSet from BOP; - pointer PShellFaceSet to ShellFaceSet from BOP; - pointer PBuilder to Builder from BOP; - - --- - --- I n s t a n t i a t i o n s - --- - class ListOfConnexityBlock instantiates - List from TCollection(ConnexityBlock from BOP); - - class ListOfLoop instantiates - List from TCollection(Loop from BOP); - - class ListOfListOfLoop instantiates - List from TCollection(ListOfLoop from BOP); - - class ListOfEdgeInfo instantiates - List from TCollection(EdgeInfo from BOP); - - class IndexedDataMapOfVertexListEdgeInfo instantiates - IndexedDataMap from TCollection(Shape from TopoDS, - ListOfEdgeInfo from BOP, - ShapeMapHasher from TopTools); - class ListOfFaceInfo instantiates - List from TCollection(FaceInfo from BOP); - - class IndexedDataMapOfEdgeListFaceInfo instantiates - IndexedDataMap from TCollection(Shape from TopoDS, - ListOfFaceInfo from BOP, - ShapeMapHasher from TopTools); - class SeqOfSeqOfShape instantiates - Sequence from TCollection(SequenceOfShape from TopTools); - - --- - class SolidClassifier; - - pointer PSoClassif to SolidClassifier from BRepClass3d; - - class IndexedDataMapOfSolidClassifier instantiates - IndexedDataMap from TCollection (Shape from TopoDS, - PSoClassif from BOP, - ShapeMapHasher from TopTools); - - class ListOfCheckResult instantiates - List from TCollection(CheckResult from BOP); --- - - -end BOP; - diff --git a/src/BOP/BOP_Area2dBuilder.cdl b/src/BOP/BOP_Area2dBuilder.cdl deleted file mode 100755 index ea48cf4274..0000000000 --- a/src/BOP/BOP_Area2dBuilder.cdl +++ /dev/null @@ -1,65 +0,0 @@ --- Created on: 1995-12-21 --- Created by: Jean Yves LEBEY --- Copyright (c) 1995-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class Area2dBuilder from BOP inherits AreaBuilder from BOP - - ---Purpose: - - -- The algorithm is used to construct Faces from a LoopSet, - -- where the Loop is the composite topological object of the boundary, - -- here it is a wire(s) or block(s) of edges. - -- The LoopSet gives an iteration on Loops. - -- For each Loop it indicates if it is on the boundary (wire) or if it - -- results from an interference (block of edges). - -- The result of the algorithm is an iteration on areas. - -- An area is described by a set of Loops. - -uses - - LoopSet from BOP, - LoopClassifier from BOP - -is - Create returns Area2dBuilder; - ---Purpose: - --- Empty Constructor - --- - Create(LS :out LoopSet from BOP; - LC :out LoopClassifier from BOP; - ForceClass : Boolean from Standard = Standard_False) - returns Area2dBuilder; - ---Purpose: - --- Creates an object to build faces on - --- the (wires,blocks of edge) of , - --- using the classifier . - --- - InitAreaBuilder(me :out; - LS :out LoopSet from BOP; - LC :out LoopClassifier from BOP; - ForceClass : Boolean = Standard_False) - is redefined; - ---Purpose: - --- Initializes the object to find the areas of - --- the shapes described by , - --- using the classifier . - --- - -end Area2dBuilder; diff --git a/src/BOP/BOP_Area2dBuilder.cxx b/src/BOP/BOP_Area2dBuilder.cxx deleted file mode 100755 index d61c2bf5a9..0000000000 --- a/src/BOP/BOP_Area2dBuilder.cxx +++ /dev/null @@ -1,234 +0,0 @@ -// Created on: 1995-12-21 -// Created by: Jean Yves LEBEY -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -//modified by NIZNHY-PKV Tue Apr 3 15:50:23 2001 - -#include - -#include -#include - -//======================================================================= -//function : BOP_Area2dBuilder::BOP_Area2dBuilder -//purpose : -//======================================================================= -BOP_Area2dBuilder::BOP_Area2dBuilder() -{ -} - -//======================================================================= -//function : BOP_Area2dBuilder::BOP_Area2dBuilder -//purpose : -//======================================================================= - BOP_Area2dBuilder::BOP_Area2dBuilder(BOP_LoopSet& LS, - BOP_LoopClassifier& LC, - const Standard_Boolean ForceClass) -{ - InitAreaBuilder(LS,LC,ForceClass); -} - -//======================================================================= -//function : InitAreaBuilder -//purpose : -//======================================================================= - void BOP_Area2dBuilder::InitAreaBuilder(BOP_LoopSet& LS, - BOP_LoopClassifier& LC, - const Standard_Boolean ForceClass) -{ - TopAbs_State state; - Standard_Boolean Loopinside; - Standard_Boolean loopoutside; - - BOP_ListIteratorOfListOfListOfLoop AreaIter; - BOP_ListIteratorOfListOfLoop LoopIter; - // boundaryloops : list of boundary loops out of the areas. - BOP_ListOfLoop boundaryloops; - - myArea.Clear(); // Clear the list of Area to be built - - for (LS.InitLoop(); LS.MoreLoop(); LS.NextLoop()) { - - // process a new loop : L is the new current Loop - const Handle(BOP_Loop)& L = LS.Loop(); - Standard_Boolean boundaryL = L->IsShape(); - // - //const TopoDS_Shape& aSL=L->Shape(); - // - // L = shape et ForceClass : on traite L comme un block - // L = shape et !ForceClass : on traite L comme un pur shape - // L = !shape : on traite L comme un block - Standard_Boolean traitercommeblock = (!boundaryL) || ForceClass; - if ( !traitercommeblock ) { - // the loop L is a boundary loop : - // - try to insert it in an existing area, such as L is inside all - // the block loops. Only block loops of the area are compared. - // - if L could not be inserted, store it in list of boundary loops. - Loopinside = Standard_False; - AreaIter.Initialize(myArea); - for (; AreaIter.More(); AreaIter.Next()) { - BOP_ListOfLoop& aArea = AreaIter.Value(); - if ( aArea.IsEmpty() ) { - continue; - } - state = CompareLoopWithListOfLoop(LC,L,aArea,BOP_BLOCK ); - if (state == TopAbs_UNKNOWN){ - Atomize(state,TopAbs_IN); - } - Loopinside = ( state == TopAbs_IN); - if ( Loopinside ) { - break; - } - } // end of Area scan - - if ( Loopinside ) { - BOP_ListOfLoop& aArea = AreaIter.Value(); - ADD_Loop_TO_LISTOFLoop(L, aArea); - } - else if ( ! Loopinside ) { - ADD_Loop_TO_LISTOFLoop(L, boundaryloops); - } - } // end of boundary loop - - else { - // the loop L is a block loop - // if L is IN theArea : - // - stop area scan, insert L in theArea. - // - remove from the area all the loops outside L - // - make a new area with them, unless they are all boundary - // - if they are all boundary put them back in boundaryLoops - // else : - // - create a new area with L. - // - insert boundary loops that are IN the new area - // (and remove them from 'boundaryloops') - // - Standard_Integer aNbAreas, aNbLoops; - Loopinside = Standard_False; - // - aNbAreas=myArea.Extent(); - if (aNbAreas) { - AreaIter.Initialize(myArea); - for (; AreaIter.More(); AreaIter.Next()) { - BOP_ListOfLoop& aArea = AreaIter.Value(); - aNbLoops=aArea.Extent(); - if (!aNbLoops){ - continue; - } - // - state = CompareLoopWithListOfLoop(LC, L, aArea, BOP_ANYLOOP); - // - if (state == TopAbs_UNKNOWN){ - Atomize(state,TopAbs_IN); - } - // - Loopinside = (state==TopAbs_IN); - if ( Loopinside ){ - break; - } - } // end of Area scan - } - // - if ( Loopinside) { - BOP_ListOfLoop& aArea = AreaIter.Value(); - Standard_Boolean allShape = Standard_True; - BOP_ListOfLoop removedLoops; - LoopIter.Initialize(aArea); - while (LoopIter.More()) { - const Handle(BOP_Loop)& curL = LoopIter.Value(); - state = LC.Compare(curL, L); - if (state == TopAbs_UNKNOWN) { - Atomize(state,TopAbs_IN); // not OUT - } - // - loopoutside = ( state == TopAbs_OUT ); - // - if ( loopoutside ) { - // remove the loop from the area - ADD_Loop_TO_LISTOFLoop(curL, removedLoops); - - allShape = allShape && curL->IsShape(); - REM_Loop_FROM_LISTOFLoop(LoopIter, aArea); - } - else { - LoopIter.Next(); - } - }// while (LoopIter.More()) { - // - // insert the loop in the area - ADD_Loop_TO_LISTOFLoop(L, aArea); - if ( ! removedLoops.IsEmpty() ) { - if ( allShape ) { - ADD_LISTOFLoop_TO_LISTOFLoop (removedLoops,boundaryloops); - } - else { - // make a new area with the removed loops - BOP_ListOfLoop thelistofloop; - myArea.Append(thelistofloop); - ADD_LISTOFLoop_TO_LISTOFLoop(removedLoops, myArea.Last()); - } - } - } // Loopinside == True - - else { - Standard_Integer ashapeinside,ablockinside; - BOP_ListOfLoop thelistofloop1; - myArea.Append(thelistofloop1); - BOP_ListOfLoop& newArea0 = myArea.Last(); - ADD_Loop_TO_LISTOFLoop(L, newArea0); - - LoopIter.Initialize(boundaryloops); - while ( LoopIter.More() ) { - ashapeinside = ablockinside = Standard_False; - const Handle(BOP_Loop)& lb = LoopIter.Value(); - state = LC.Compare(lb,L); - if (state == TopAbs_UNKNOWN){ - Atomize(state,TopAbs_IN); - } - ashapeinside = (state == TopAbs_IN); - if (ashapeinside) { - state = LC.Compare(L,lb); - if (state == TopAbs_UNKNOWN){ - Atomize(state,TopAbs_IN); - } - ablockinside = (state == TopAbs_IN); - } - if ( ashapeinside && ablockinside ) { - const Handle(BOP_Loop)& curL = LoopIter.Value(); - ADD_Loop_TO_LISTOFLoop(curL, newArea0); - - REM_Loop_FROM_LISTOFLoop(LoopIter,boundaryloops); - } - else { - LoopIter.Next(); - } - } // end of boundaryloops scan - } // Loopinside == False - } // end of block loop - } // end of LoopSet LS scan - - if ( ! boundaryloops.IsEmpty() ) { - if ( myArea.IsEmpty() ) { - BOP_ListOfLoop newArea3; - newArea3.Append(boundaryloops); - myArea.Append(newArea3); - } - } - - InitArea(); -} diff --git a/src/BOP/BOP_Area3dBuilder.cdl b/src/BOP/BOP_Area3dBuilder.cdl deleted file mode 100755 index 0e736e2335..0000000000 --- a/src/BOP/BOP_Area3dBuilder.cdl +++ /dev/null @@ -1,65 +0,0 @@ --- Created on: 2001-06-25 --- Created by: Michael KLOKOV --- Copyright (c) 2001-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class Area3dBuilder from BOP inherits AreaBuilder from BOP - - ---Purpose: - - -- The algorithm is used to construct Solids from a LoopSet, - -- where the Loop is the composite topological object of the boundary, - -- here it is a Shell(s) or block(s) of Faces. - -- The LoopSet gives an iteration on Loops. - -- For each Loop it indicates if it is on the boundary (shell) or if it - -- results from an interference (block of faces). - -- The result of the algorithm is an iteration on areas. - -- An area is described by a set of Loops. - -uses - LoopSet from BOP, - LoopClassifier from BOP - -is - - Create returns Area3dBuilder from BOP; - ---Purpose: - --- Empty Constructor - --- - Create(LS:out LoopSet from BOP; - LC:out LoopClassifier from BOP; - ForceClass: Boolean from Standard = Standard_False) - returns Area3dBuilder from BOP; - ---Purpose: - --- Creates an object to build solids on - --- the (shells, blocks of faces) of , - --- using the classifier . - --- - - InitAreaBuilder(me: in out; - LS:out LoopSet from BOP; - LC:out LoopClassifier from BOP; - ForceClass: Boolean from Standard) - is redefined; - ---Purpose: - --- Initialize the object to find the areas of - --- the shapes described by , - --- using the classifier . - --- - -end Area3dBuilder from BOP; diff --git a/src/BOP/BOP_Area3dBuilder.cxx b/src/BOP/BOP_Area3dBuilder.cxx deleted file mode 100755 index f11598201d..0000000000 --- a/src/BOP/BOP_Area3dBuilder.cxx +++ /dev/null @@ -1,194 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include - -#include - -// ================================================================================== -// function: BOP_Area3dBuilder::BOP_Area3dBuilder -// purpose: -// ================================================================================== -BOP_Area3dBuilder::BOP_Area3dBuilder() -{ -} - -// ================================================================================== -// function: BOP_Area3dBuilder::BOP_Area3dBuilder -// purpose: -// ================================================================================== - BOP_Area3dBuilder::BOP_Area3dBuilder(BOP_LoopSet& theLS, - BOP_LoopClassifier& theLC, - const Standard_Boolean theForceClassFlag) -{ - InitAreaBuilder(theLS, theLC, theForceClassFlag); -} - -// ================================================================================== -// function: InitAreaBuilder -// purpose: -// ================================================================================== - void BOP_Area3dBuilder::InitAreaBuilder(BOP_LoopSet& theLS, - BOP_LoopClassifier& theLC, - const Standard_Boolean theForceClassFlag) -{ - TopAbs_State state; - Standard_Boolean Loopinside; - Standard_Boolean loopoutside; - - BOP_ListIteratorOfListOfListOfLoop AreaIter; - BOP_ListIteratorOfListOfLoop LoopIter; - // boundaryloops : list of boundary loops out of the areas. - BOP_ListOfLoop boundaryloops; - - myArea.Clear(); // Clear the list of Area to be built - - for (theLS.InitLoop(); theLS.MoreLoop(); theLS.NextLoop()) { - - // process a new loop : L is the new current Loop - const Handle(BOP_Loop)& L = theLS.Loop(); - Standard_Boolean boundaryL = L->IsShape(); - - // L = shape et theForceClassFlag : on traite L comme un block - // L = shape et !theForceClassFlag : on traite L comme un pur shape - // L = !shape : on traite L comme un block - Standard_Boolean traitercommeblock = (!boundaryL) || theForceClassFlag; - if ( ! traitercommeblock ) { - - // the loop L is a boundary loop : - // - try to insert it in an existing area, such as L is inside all - // the block loops. Only block loops of the area are compared. - // - if L could not be inserted, store it in list of boundary loops. - - Loopinside = Standard_False; - for (AreaIter.Initialize(myArea); AreaIter.More(); AreaIter.Next()) { - BOP_ListOfLoop& aArea = AreaIter.Value(); - if ( aArea.IsEmpty() ) continue; - state = CompareLoopWithListOfLoop(theLC,L,aArea,BOP_BLOCK ); - if (state == TopAbs_UNKNOWN) Atomize(state,TopAbs_IN); - Loopinside = ( state == TopAbs_IN); - if ( Loopinside ) break; - } // end of Area scan - - if ( Loopinside ) { - BOP_ListOfLoop& aArea = AreaIter.Value(); - ADD_Loop_TO_LISTOFLoop(L,aArea); - } - else if ( ! Loopinside ) { - ADD_Loop_TO_LISTOFLoop(L, boundaryloops); - } - - } // end of boundary loop - - else { - // the loop L is a block loop - // if L is IN theArea : - // - stop area scan, insert L in theArea. - // - remove from the area all the loops outside L - // - make a new area with them, unless they are all boundary - // - if they are all boundary put them back in boundaryLoops - // else : - // - create a new area with L. - // - insert boundary loops that are IN the new area - // (and remove them from 'boundaryloops') - - Loopinside = Standard_False; - for (AreaIter.Initialize(myArea); AreaIter.More(); AreaIter.Next() ) { - BOP_ListOfLoop& aArea = AreaIter.Value(); - if ( aArea.IsEmpty() ) continue; - state = CompareLoopWithListOfLoop(theLC,L,aArea,BOP_ANYLOOP); - if (state == TopAbs_UNKNOWN) Atomize(state,TopAbs_IN); - Loopinside = (state == TopAbs_IN); - if ( Loopinside ) break; - } // end of Area scan - - if ( Loopinside) { - BOP_ListOfLoop& aArea = AreaIter.Value(); - Standard_Boolean allShape = Standard_True; - BOP_ListOfLoop removedLoops; - LoopIter.Initialize(aArea); - while (LoopIter.More()) { - const Handle(BOP_Loop)& LLI1 = LoopIter.Value(); - state = theLC.Compare(LLI1,L); - if (state == TopAbs_UNKNOWN) Atomize(state,TopAbs_IN); // not OUT - loopoutside = ( state == TopAbs_OUT ); - if ( loopoutside ) { - const Handle(BOP_Loop)& curL = LoopIter.Value(); - // remove the loop from the area - ADD_Loop_TO_LISTOFLoop - (curL,removedLoops); - - allShape = allShape && curL->IsShape(); - REM_Loop_FROM_LISTOFLoop - (LoopIter, AreaIter.Value()); - } - else { - LoopIter.Next(); - } - } - // insert the loop in the area - ADD_Loop_TO_LISTOFLoop(L,aArea); - if ( ! removedLoops.IsEmpty() ) { - if ( allShape ) { - ADD_LISTOFLoop_TO_LISTOFLoop(removedLoops, boundaryloops); - } - else { - // make a new area with the removed loops - BOP_ListOfLoop thelistofloop; - myArea.Append(thelistofloop); - ADD_LISTOFLoop_TO_LISTOFLoop(removedLoops, myArea.Last()); - } - } - } // Loopinside == True - - else { - Standard_Integer ashapeinside,ablockinside; - BOP_ListOfLoop thelistofloop1; - myArea.Append(thelistofloop1); - BOP_ListOfLoop& newArea0 = myArea.Last(); - ADD_Loop_TO_LISTOFLoop(L, newArea0); - - LoopIter.Initialize(boundaryloops); - while ( LoopIter.More() ) { - ashapeinside = ablockinside = Standard_False; - const Handle(BOP_Loop)& LLI2 = LoopIter.Value(); - state = theLC.Compare(LLI2,L); - if (state == TopAbs_UNKNOWN) Atomize(state,TopAbs_IN); - ashapeinside = (state == TopAbs_IN); - if (ashapeinside) { - const Handle(BOP_Loop)& LLI3 = LoopIter.Value(); - state = theLC.Compare(L,LLI3); - if (state == TopAbs_UNKNOWN) Atomize(state,TopAbs_IN); - ablockinside = (state == TopAbs_IN); - } - if ( ashapeinside && ablockinside ) { - const Handle(BOP_Loop)& curL = LoopIter.Value(); - ADD_Loop_TO_LISTOFLoop(curL, newArea0); - - REM_Loop_FROM_LISTOFLoop(LoopIter, boundaryloops); - } - else { - LoopIter.Next(); - } - } // end of boundaryloops scan - } // Loopinside == False - } // end of block loop - } // end of LoopSet theLS scan - - InitArea(); -} - diff --git a/src/BOP/BOP_AreaBuilder.cdl b/src/BOP/BOP_AreaBuilder.cdl deleted file mode 100755 index a86d5485be..0000000000 --- a/src/BOP/BOP_AreaBuilder.cdl +++ /dev/null @@ -1,181 +0,0 @@ --- Created on: 1995-12-21 --- Created by: Jean Yves LEBEY --- Copyright (c) 1995-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class AreaBuilder from BOP - - ---Purpose: - - -- The Root class for the algorithms that are used to - - -- Reconstruct complex topological - -- objects as Faces or Solids. - -- Loop is the composite topological object of - -- the boundary. Wire for a Face. Shell for a Solid. - -- LoopSet is a tool describing the object to - -- build. It gives an iteration on Loops. For each - -- Loop it tells if it is on the boundary or if it is - -- an interference. - -- LoopClassifier is an algorithm used to test - -- if a Loop is inside another Loop. - -- The result of the reconstruction is an iteration - -- on the reconstructed areas. An area is described - -- by a set of Loops. - -- A AreaBuilder is built with : - -- - a LoopSet describing the object to reconstruct. - -- - a LoopClassifier providing the classification algorithm. - -uses - - State from TopAbs, - - Loop from BOP, - ListOfLoop from BOP, - ListIteratorOfListOfLoop from BOP, - ListOfListOfLoop from BOP, - LoopSet from BOP, - LoopClassifier from BOP, - LoopEnum from BOP, - ListIteratorOfListOfListOfLoop from BOP - -is - - Create - returns AreaBuilder; - ---Purpose: - --- Empty Constructor - --- - Create(LS :out LoopSet from BOP; - LC :out LoopClassifier from BOP; - ForceClass : Boolean = Standard_False) - returns AreaBuilder; - ---Purpose: - --- Creates the objectr to build the areas on - --- the shapes described by using the classifier . - --- - Delete(me:out) is virtual; - ---C++: alias "Standard_EXPORT virtual ~BOP_AreaBuilder(){Delete() ; }" - ---Purpose: - --- Destructor - --- - InitAreaBuilder(me :out; - LS :out LoopSet from BOP; - LC :out LoopClassifier; - ForceClass : Boolean from Standard = Standard_False) - is virtual; - ---Purpose: - --- Sets a AreaBuilder to find the areas on - --- the shapes described by using the classifier . - --- - CompareLoopWithListOfLoop(me; - LC : out LoopClassifier from BOP; - L : Loop from BOP; - LOL : ListOfLoop from BOP; - aWhat : LoopEnum from BOP) - returns State from TopAbs - is static protected; - ---Purpose: - --- Compare position of the Loop with the Area - --- using the Loop Classifier . - --- According to , Loops of are selected or not - --- during exploration. - --- - -- Result : TopAbs_OUT if is empty - --- TopAbs_UNKNOWN if position undefined - --- TopAbs_IN if is inside all the selected Loops of - --- TopAbs_OUT if is outside one of the selected Loops of - --- TopAbs_ON if is on one of the selected Loops of - --- - --- - - --- Iteration on Areas - -- - InitArea(me:out) - returns Integer from Standard is static; - ---Purpose: - --- Initialize iteration on areas. - --- - MoreArea(me) - returns Boolean from Standard is static; - - NextArea(me:out) - is static; - - -- - -- Iteration on Loops inside the Area - -- - InitLoop(me:out) - returns Integer from Standard is static; - ---Purpose: - --- Initialize iteration on loops of current Area. - --- - MoreLoop(me) - returns Boolean from Standard is static; - - NextLoop(me:out) - is static; - - Loop(me) - returns Loop from BOP is static; - ---C++: return const& - ---Purpose: - --- Returns the current Loop in the current area. - --- - --- - --- - --- Methods that are not for public usage - --- - ADD_Loop_TO_LISTOFLoop (me; - L : Loop from BOP; - LOL: out ListOfLoop from BOP) - is virtual; - ---Purpose: - --- Internal - --- - REM_Loop_FROM_LISTOFLoop(me; - ITLOL: out ListIteratorOfListOfLoop from BOP; - LOL : out ListOfLoop from BOP) - is virtual; - ---Purpose: - --- Internal - --- - ADD_LISTOFLoop_TO_LISTOFLoop(me; - LOL1 : out ListOfLoop from BOP; - LOL2 : out ListOfLoop from BOP) - is virtual; - ---Purpose: - --- Internal - --- - Atomize(me; - state : in out State from TopAbs; - newstate : State from TopAbs) - is static protected; - ---Purpose: - --- Internal - --- -fields - - myArea : ListOfListOfLoop from BOP is protected; - myAreaIterator : ListIteratorOfListOfListOfLoop from BOP is protected; - myLoopIterator : ListIteratorOfListOfLoop from BOP is protected; - myUNKNOWNRaise : Boolean from Standard is protected; - -end AreaBuilder; - diff --git a/src/BOP/BOP_AreaBuilder.cxx b/src/BOP/BOP_AreaBuilder.cxx deleted file mode 100755 index 7dc5873200..0000000000 --- a/src/BOP/BOP_AreaBuilder.cxx +++ /dev/null @@ -1,408 +0,0 @@ -// Created on: 1995-12-21 -// Created by: Jean Yves LEBEY -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -// " Voyager, c'est bien utile, ca fait travailler l'imagination. -// Tout le reste n'est que deceptions et fatigues. Notre voyage -// a nous est entierement imaginaire. Voila sa force. " -// Celine -// Voyage au bout de la nuit - -#include - -#include -#include - -//======================================================================= -//function : BOP_AreaBuilder::BOP_AreaBuilder -//purpose : -//======================================================================= -BOP_AreaBuilder::BOP_AreaBuilder() -: - myUNKNOWNRaise(Standard_False) -{ -} - -//======================================================================= -//function : TopOpeBRepBuild_AreaBuilder -//purpose : -//======================================================================= - BOP_AreaBuilder::BOP_AreaBuilder (BOP_LoopSet& LS, - BOP_LoopClassifier& LC, - const Standard_Boolean ForceClass) -: - myUNKNOWNRaise(Standard_False) -{ - InitAreaBuilder(LS, LC, ForceClass); -} -//======================================================================= -//function : Delete -//purpose : -//======================================================================= - void BOP_AreaBuilder::Delete() -{} - -//======================================================================= -//function : CompareLoopWithListOfLoop -//purpose : Compare position of the Loop with the Area -// using the Loop Classifier . -// According to , Loops of are selected or not -// during exploration. -//result : TopAbs_OUT if is empty -// TopAbs_UNKNOWN if position undefined -// TopAbs_IN if is inside all the selected Loops of -// TopAbs_OUT if is outside one of the selected Loops of -// TopAbs_ON if is on one of the selected Loops of -//======================================================================= - TopAbs_State BOP_AreaBuilder::CompareLoopWithListOfLoop (BOP_LoopClassifier &LC, - const Handle(BOP_Loop)& L, - const BOP_ListOfLoop &LOL, - const BOP_LoopEnum what) const -{ - TopAbs_State state = TopAbs_UNKNOWN; - Standard_Boolean totest; // L must or not be tested - BOP_ListIteratorOfListOfLoop LoopIter; - - if ( LOL.IsEmpty() ) { - return TopAbs_OUT; - } - - LoopIter.Initialize(LOL); - for (; LoopIter.More(); LoopIter.Next() ) { - const Handle(BOP_Loop)& curL = LoopIter.Value(); - switch ( what ) { - case BOP_ANYLOOP : - totest = Standard_True; - break; - case BOP_BOUNDARY : - totest = curL->IsShape(); - break; - case BOP_BLOCK : - totest = !curL->IsShape(); - break; - default: - totest = Standard_False; - break; - } - if ( totest ) { - state = LC.Compare(L,curL); - if (state == TopAbs_OUT) - // is out of at least one Loop - //of : stop to explore - break; - } - } - return state; -} - -//======================================================================= -//function : Atomize -//purpose : -//======================================================================= - void BOP_AreaBuilder::Atomize(TopAbs_State& state, - const TopAbs_State newstate) const -{ - if (myUNKNOWNRaise) { - Standard_DomainError_Raise_if((state == TopAbs_UNKNOWN), - "AreaBuilder : Position Unknown"); - } - else { - state = newstate; - } -} - - -//======================================================================= -//function : InitAreaBuilder -//purpose : -//======================================================================= - void BOP_AreaBuilder::InitAreaBuilder(BOP_LoopSet& LS, - BOP_LoopClassifier& LC, - const Standard_Boolean ForceClass) -{ - TopAbs_State state; - Standard_Boolean Loopinside; - Standard_Boolean loopoutside; - - BOP_ListIteratorOfListOfListOfLoop AreaIter; - BOP_ListIteratorOfListOfLoop LoopIter; - // boundaryloops : list of boundary loops out of the areas. - BOP_ListOfLoop boundaryloops; - - myArea.Clear(); // Clear the list of Area to be built - - for (LS.InitLoop(); LS.MoreLoop(); LS.NextLoop()) { - - // process a new loop : L is the new current Loop - const Handle(BOP_Loop)& L = LS.Loop(); - Standard_Boolean boundaryL = L->IsShape(); - - // L = Shape et ForceClass : on traite L comme un block - // L = Shape et !ForceClass : on traite L comme un pur Shape - // L = !Shape : on traite L comme un block - Standard_Boolean traitercommeblock = (!boundaryL) || ForceClass; - if ( ! traitercommeblock ) { - - // the loop L is a boundary loop : - // - try to insert it in an existing area, such as L is inside all - // the block loops. Only block loops of the area are compared. - // - if L could not be inserted, store it in list of boundary loops. - - Loopinside = Standard_False; - for (AreaIter.Initialize(myArea); AreaIter.More(); AreaIter.Next()) { - BOP_ListOfLoop& aArea = AreaIter.Value(); - if ( aArea.IsEmpty() ) continue; - state = CompareLoopWithListOfLoop(LC,L,aArea,BOP_BLOCK ); - if (state == TopAbs_UNKNOWN) { - Atomize(state,TopAbs_IN); - } - Loopinside = ( state == TopAbs_IN); - if ( Loopinside ) { - break; - } - } // end of Area scan - - if ( Loopinside ) { - BOP_ListOfLoop& aArea = AreaIter.Value(); - ADD_Loop_TO_LISTOFLoop(L,aArea); - } - else if ( ! Loopinside ) { - ADD_Loop_TO_LISTOFLoop(L,boundaryloops); - } - } // end of boundary loop - - else { - // the loop L is a block loop - // if L is IN theArea : - // - stop area scan, insert L in theArea. - // - remove from the area all the loops outside L - // - make a new area with them, unless they are all boundary - // - if they are all boundary put them back in boundaryLoops - // else : - // - create a new area with L. - // - insert boundary loops that are IN the new area - // (and remove them from 'boundaryloops') - - Loopinside = Standard_False; - - for (AreaIter.Initialize(myArea); AreaIter.More(); AreaIter.Next() ) { - BOP_ListOfLoop& aArea = AreaIter.Value(); - if ( aArea.IsEmpty() ) { - continue; - } - state = CompareLoopWithListOfLoop(LC,L,aArea,BOP_ANYLOOP); - if (state == TopAbs_UNKNOWN) Atomize(state,TopAbs_IN); - Loopinside = (state == TopAbs_IN); - if ( Loopinside ) { - break; - } - } // end of Area scan - - if ( Loopinside) { - BOP_ListOfLoop& aArea = AreaIter.Value(); - Standard_Boolean allShape = Standard_True; - BOP_ListOfLoop removedLoops; - - LoopIter.Initialize(aArea); - while (LoopIter.More()) { - state = LC.Compare(LoopIter.Value(),L); - if (state == TopAbs_UNKNOWN){ - Atomize(state,TopAbs_IN); // not OUT - } - - loopoutside = ( state == TopAbs_OUT ); - - if ( loopoutside ) { - const Handle(BOP_Loop)& curL = LoopIter.Value(); - // remove the loop from the area - ADD_Loop_TO_LISTOFLoop (curL,removedLoops); - - allShape = allShape && curL->IsShape(); - REM_Loop_FROM_LISTOFLoop(LoopIter,AreaIter.Value()); - } - else { - LoopIter.Next(); - } - } - // insert the loop in the area - ADD_Loop_TO_LISTOFLoop(L,aArea); - if ( ! removedLoops.IsEmpty() ) { - if ( allShape ) { - ADD_LISTOFLoop_TO_LISTOFLoop(removedLoops,boundaryloops); - } - else { - // make a new area with the removed loops - BOP_ListOfLoop thelistofloop; - myArea.Append(thelistofloop); - ADD_LISTOFLoop_TO_LISTOFLoop (removedLoops,myArea.Last()); - } - } - } // Loopinside == True - - else { - Standard_Integer ashapeinside,ablockinside; - BOP_ListOfLoop thelistofloop1; - myArea.Append(thelistofloop1); - BOP_ListOfLoop& newArea0 = myArea.Last(); - ADD_Loop_TO_LISTOFLoop(L, newArea0); - - LoopIter.Initialize(boundaryloops); - while ( LoopIter.More() ) { - ashapeinside = ablockinside = Standard_False; - state = LC.Compare(LoopIter.Value(),L); - if (state == TopAbs_UNKNOWN) { - Atomize(state,TopAbs_IN); - } - - ashapeinside = (state == TopAbs_IN); - if (ashapeinside) { - state = LC.Compare(L,LoopIter.Value()); - if (state == TopAbs_UNKNOWN){ - Atomize(state,TopAbs_IN); - } - ablockinside = (state == TopAbs_IN); - } - - if ( ashapeinside && ablockinside ) { - const Handle(BOP_Loop)& curL = LoopIter.Value(); - ADD_Loop_TO_LISTOFLoop(curL, newArea0); - - REM_Loop_FROM_LISTOFLoop(LoopIter,boundaryloops); - } - else { - LoopIter.Next(); - } - } // end of boundaryloops scan - } // Loopinside == False - } // end of block loop - } // end of LoopSet LS scan - - InitArea(); -} - -//======================================================================= -//function : InitArea -//purpose : -//======================================================================= - Standard_Integer BOP_AreaBuilder::InitArea() -{ - myAreaIterator.Initialize(myArea); - InitLoop(); - Standard_Integer n = myArea.Extent(); - return n; -} - -//======================================================================= -//function : MoreArea -//purpose : -//======================================================================= - Standard_Boolean BOP_AreaBuilder::MoreArea() const -{ - Standard_Boolean b = myAreaIterator.More(); - return b; -} - -//======================================================================= -//Function : NextArea -//Purpose : -//======================================================================= - void BOP_AreaBuilder::NextArea() -{ - myAreaIterator.Next(); - InitLoop(); -} - -//======================================================================= -//function : InitLoop -//purpose : -//======================================================================= - Standard_Integer BOP_AreaBuilder::InitLoop() -{ - Standard_Integer n = 0; - if (myAreaIterator.More()) { - const BOP_ListOfLoop& LAL = myAreaIterator.Value(); - myLoopIterator.Initialize(LAL); - n = LAL.Extent(); - } - else { // Create an empty ListIteratorOfListOfLoop - myLoopIterator = BOP_ListIteratorOfListOfLoop(); - } - return n; -} - -//======================================================================= -//function : MoreLoop -//purpose : -//======================================================================= - Standard_Boolean BOP_AreaBuilder::MoreLoop() const -{ - Standard_Boolean b = myLoopIterator.More(); - return b; -} - -//======================================================================= -//function : NextLoop -//purpose : -//======================================================================= - void BOP_AreaBuilder::NextLoop() -{ - myLoopIterator.Next(); -} - -//======================================================================= -//function : Loop -//purpose : -//======================================================================= - const Handle(BOP_Loop)& BOP_AreaBuilder::Loop() const -{ - const Handle(BOP_Loop)& L = myLoopIterator.Value(); - return L; -} - -//======================================================================= -//function : ADD_Loop_TO_LISTOFLoop -//purpose : -//======================================================================= - void BOP_AreaBuilder::ADD_Loop_TO_LISTOFLoop(const Handle(BOP_Loop)& L, - BOP_ListOfLoop& LOL) const -{ - LOL.Append(L); -} - -//======================================================================= -//function : REM_Loop_FROM_LISTOFLoop -//purpose : -//======================================================================= - void BOP_AreaBuilder::REM_Loop_FROM_LISTOFLoop(BOP_ListIteratorOfListOfLoop& ITA, - BOP_ListOfLoop& A) const -{ - A.Remove(ITA); -} - -//======================================================================= -//function : ADD_LISTOFLoop_TO_LISTOFLoop -//purpose : -//======================================================================= - void BOP_AreaBuilder::ADD_LISTOFLoop_TO_LISTOFLoop(BOP_ListOfLoop& A1, - BOP_ListOfLoop& A2) const - -{ - A2.Append(A1); -} diff --git a/src/BOP/BOP_ArgumentAnalyzer.cdl b/src/BOP/BOP_ArgumentAnalyzer.cdl deleted file mode 100755 index 124f5004db..0000000000 --- a/src/BOP/BOP_ArgumentAnalyzer.cdl +++ /dev/null @@ -1,184 +0,0 @@ --- Created on: 2004-09-03 --- Created by: Oleg FEDYAEV --- Copyright (c) 2004-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class ArgumentAnalyzer from BOP - ---Purpose: check the validity of argument(s) for Boolean Operations - -uses - Shape from TopoDS, - Operation from BOP, - CheckStatus from BOP, - Operation from BOP, - ShapeEnum from TopAbs, - ListOfCheckResult from BOP - -is - Create - returns ArgumentAnalyzer; - ---Purpose: empty constructor - - SetShape1(me: in out; TheShape: Shape from TopoDS); - ---Purpose: sets object shape - - SetShape2(me: in out; TheShape: Shape from TopoDS); - ---Purpose: sets tool shape - - GetShape1(me) - returns Shape from TopoDS; - ---C++: return const & - ---Purpose: returns object shape; - - GetShape2(me) - returns Shape from TopoDS; - ---C++: return const & - ---Purpose: returns tool shape - - --modified by NIZHNY-MKK Fri Sep 3 17:14:55 2004.BEGIN - ---options - OperationType(me: in out) - returns Operation from BOP; - ---C++: return & - ---Purpose: returns ref - - StopOnFirstFaulty(me: in out) - returns Boolean from Standard; - ---C++: return & - ---Purpose: returns ref - - ArgumentTypeMode(me: in out) - returns Boolean from Standard; - ---C++: return & - ---C++: inline - ---Purpose: Returns (modifiable) mode - -- that means checking types of shapes. - - SelfInterMode(me: in out) - returns Boolean from Standard; - ---C++: return & - ---C++: inline - ---Purpose: Returns (modifiable) mode that means - -- checking of self-intersection of shapes. - - SmallEdgeMode(me: in out) - returns Boolean from Standard; - ---C++: return & - ---C++: inline - ---Purpose: Returns (modifiable) mode that means - -- checking of small edges. - - RebuildFaceMode(me: in out) - returns Boolean from Standard; - ---C++: return & - ---C++: inline - ---Purpose: Returns (modifiable) mode that means - -- checking of possibility to split or rebuild faces. - - TangentMode(me: in out) - returns Boolean from Standard; - ---C++: return & - ---C++: inline - ---Purpose: Returns (modifiable) mode that means - -- checking of tangency between subshapes. - - MergeVertexMode(me: in out) - returns Boolean from Standard; - ---C++: return & - ---C++: inline - ---Purpose: Returns (modifiable) mode that means - -- checking of problem of merging vertices. - - MergeEdgeMode(me: in out) - returns Boolean from Standard; - ---C++: return & - ---C++: inline - ---Purpose: Returns (modifiable) mode that means - -- checking of problem of merging edges. - --- MergeFaceMode(me: in out) --- returns Boolean from Standard; --- ---C++: return & --- ---C++: inline --- ---Purpose: Returns (modifiable) mode that means --- -- checking of problem of merging faces. - - --modified by NIZHNY-MKK Fri Sep 3 17:15:02 2004.END - - --- - Perform(me: out); - ---Purpose: performs analysis - - HasFaulty(me) - returns Boolean from Standard; - ---Purpose: result of test - - GetCheckResult(me) - returns ListOfCheckResult from BOP; - ---C++: return const & - ---Purpose: returns a result of test - - --- protected - TestTypes(me: out) - is protected; - - TestSelfInterferences(me: out) - is protected; - - TestSmallEdge(me: out) - is protected; - - TestRebuildFace(me: out) - is protected; - - TestTangent(me: out) - is protected; - - TestMergeSubShapes(me: out; theType: ShapeEnum from TopAbs) - is protected; - - TestMergeVertex(me: out) - is protected; - - TestMergeEdge(me: out) - is protected; - --- TestMergeFace(me: out) --- is protected; - - -fields - - myShape1 : Shape from TopoDS; - myShape2 : Shape from TopoDS; - myStopOnFirst : Boolean from Standard; - --modified by NIZHNY-MKK Fri Sep 3 17:08:38 2004.BEGIN - myOperation : Operation from BOP; - myArgumentTypeMode : Boolean from Standard; - mySelfInterMode : Boolean from Standard; - mySmallEdgeMode : Boolean from Standard; - myRebuildFaceMode: Boolean from Standard; - myTangentMode : Boolean from Standard; - myMergeVertexMode: Boolean from Standard; - myMergeEdgeMode : Boolean from Standard; --- myMergeFaceMode : Boolean from Standard; - - --modified by NIZHNY-MKK Fri Sep 3 17:08:41 2004.END - myResult : ListOfCheckResult from BOP; - -end ArgumentAnalyzer; diff --git a/src/BOP/BOP_ArgumentAnalyzer.cxx b/src/BOP/BOP_ArgumentAnalyzer.cxx deleted file mode 100755 index e0e155982e..0000000000 --- a/src/BOP/BOP_ArgumentAnalyzer.cxx +++ /dev/null @@ -1,939 +0,0 @@ -// Created on: 2004-09-02 -// Copyright (c) 2004-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include - -static Standard_Boolean TestShapeType(const TopoDS_Shape & TheShape); - -static Standard_Boolean CheckEdge(const TopoDS_Edge& theEdge); - -static Standard_Boolean TestSubShapeType(const TopAbs_ShapeEnum theT1, - const TopAbs_ShapeEnum theT2, - const BOP_Operation theOP); - -// ================================================================================ -// function: Constructor -// purpose: -// ================================================================================ -BOP_ArgumentAnalyzer::BOP_ArgumentAnalyzer() : -myStopOnFirst(Standard_False), -myOperation(BOP_UNKNOWN), -myArgumentTypeMode(Standard_False), -mySelfInterMode(Standard_False), -mySmallEdgeMode(Standard_False), -myRebuildFaceMode(Standard_False), -myTangentMode(Standard_False), -myMergeVertexMode(Standard_False), -myMergeEdgeMode(Standard_False) -// myMergeFaceMode(Standard_False) -{ -} - -// ================================================================================ -// function: SetShape1 -// purpose: -// ================================================================================ -void BOP_ArgumentAnalyzer::SetShape1(const TopoDS_Shape & TheShape) -{ - myShape1 = TheShape; -} - -// ================================================================================ -// function: SetShape2 -// purpose: -// ================================================================================ -void BOP_ArgumentAnalyzer::SetShape2(const TopoDS_Shape & TheShape) -{ - myShape2 = TheShape; -} - -// ================================================================================ -// function: GetShape1 -// purpose: -// ================================================================================ -const TopoDS_Shape & BOP_ArgumentAnalyzer::GetShape1() const -{ - return myShape1; -} - -// ================================================================================ -// function: GetShape2 -// purpose: -// ================================================================================ -const TopoDS_Shape & BOP_ArgumentAnalyzer::GetShape2() const -{ - return myShape2; -} - -// ================================================================================ -// function: OperationType -// purpose: -// ================================================================================ -BOP_Operation& BOP_ArgumentAnalyzer::OperationType() -{ - return myOperation; -} - -// ================================================================================ -// function: StopOnFirstFaulty -// purpose: -// ================================================================================ -Standard_Boolean & BOP_ArgumentAnalyzer::StopOnFirstFaulty() -{ - return myStopOnFirst; -} - -// ================================================================================ -// function: Perform -// purpose: -// ================================================================================ -void BOP_ArgumentAnalyzer::Perform() -{ - try { - OCC_CATCH_SIGNALS - myResult.Clear(); - - if(myArgumentTypeMode) { - TestTypes(); - } - - if(mySelfInterMode) { - TestSelfInterferences(); - } - - if(mySmallEdgeMode) { - if(!(!myResult.IsEmpty() && myStopOnFirst)) - TestSmallEdge(); - } - - if(myRebuildFaceMode) { - if(!(!myResult.IsEmpty() && myStopOnFirst)) - TestRebuildFace(); - } - - if(myTangentMode) { - if(!(!myResult.IsEmpty() && myStopOnFirst)) - TestTangent(); - } - - if(myMergeVertexMode) { - if(!(!myResult.IsEmpty() && myStopOnFirst)) - TestMergeVertex(); - } - - if(myMergeEdgeMode) { - if(!(!myResult.IsEmpty() && myStopOnFirst)) - TestMergeEdge(); - } - -// if(myMergeFaceMode) { -// TestMergeFace(); -// } - } - catch(Standard_Failure) { - BOP_CheckResult aResult; - aResult.SetCheckStatus(BOP_CheckUnknown); - myResult.Append(aResult); - } -} - -// ================================================================================ -// function: HasFaulty -// purpose: -// ================================================================================ -Standard_Boolean BOP_ArgumentAnalyzer::HasFaulty() const -{ - return ( !myResult.IsEmpty()); -} - -// ================================================================================ -// function: GetCheckResult -// purpose: -// ================================================================================ -const BOP_ListOfCheckResult& BOP_ArgumentAnalyzer::GetCheckResult() const -{ - return myResult; -} - -// ================================================================================ -// function: TestTypes -// purpose: -// ================================================================================ -void BOP_ArgumentAnalyzer::TestTypes() -{ - Standard_Boolean isS1 = myShape1.IsNull(), isS2 = myShape2.IsNull(); - - if(isS1 && isS2) { - BOP_CheckResult aResult; - aResult.SetCheckStatus(BOP_BadType); - myResult.Append(aResult); - return; - } - - Standard_Boolean testS1 = TestShapeType(myShape1); - Standard_Boolean testS2 = TestShapeType(myShape2); - - // single shape check (begin) - if((isS1 && !isS2) || (!isS1 && isS2)) { -// Standard_Boolean testS = (isS1) ? testS1 : testS2; - Standard_Boolean testS = (isS1) ? testS2 : testS1; - - if(!testS) { - const TopoDS_Shape & aS = (isS1) ? myShape1 : myShape2; - BOP_CheckResult aResult; - aResult.SetShape1(aS); - aResult.SetCheckStatus(BOP_BadType); - myResult.Append(aResult); - return; - } - - } // single shape is set (end) - // two shapes check (begin) - else { - // test compounds and compsolids - if(!testS1 || !testS2) { - BOP_CheckResult aResult; - if(!testS1 && !testS2) { - aResult.SetShape1(myShape1); - aResult.SetShape2(myShape2); - } - else { - const TopoDS_Shape & aS = (!testS1) ? myShape1 : myShape2; - if(!testS1) - aResult.SetShape1(aS); - else - aResult.SetShape2(aS); - } - aResult.SetCheckStatus(BOP_BadType); - myResult.Append(aResult); - return; - } - // test faces, wires, edges - TopAbs_ShapeEnum aT1 = myShape1.ShapeType(), aT2 = myShape2.ShapeType(); - - if(aT1 != TopAbs_COMPOUND && aT2 != TopAbs_COMPOUND) { - Standard_Boolean aTestRes = TestSubShapeType(aT1,aT2,myOperation); - if(!aTestRes) { - BOP_CheckResult aResult; - aResult.SetShape1(myShape1); - aResult.SetShape2(myShape2); - aResult.SetCheckStatus(BOP_BadType); - myResult.Append(aResult); - return; - } - } - else { - Standard_Boolean aTestRes = Standard_True; - if(aT1 == TopAbs_COMPOUND && aT2 != TopAbs_COMPOUND) { - TopoDS_Iterator itS1(myShape1); - while(itS1.More()) { - aT1 = itS1.Value().ShapeType(); - aTestRes = TestSubShapeType(aT1,aT2,myOperation); - if(!aTestRes) - break; - itS1.Next(); - } - } - else if(aT1 != TopAbs_COMPOUND && aT2 == TopAbs_COMPOUND) { - TopoDS_Iterator itS2(myShape2); - while(itS2.More()) { - aT2 = itS2.Value().ShapeType(); - aTestRes = TestSubShapeType(aT1,aT2,myOperation); - if(!aTestRes) - break; - itS2.Next(); - } - } - else { - TopoDS_Iterator itS1(myShape1); - while(itS1.More()) { - aT1 = itS1.Value().ShapeType(); - TopoDS_Iterator itS2(myShape2); - while(itS2.More()) { - aT2 = itS2.Value().ShapeType(); - aTestRes = TestSubShapeType(aT1,aT2,myOperation); - if(!aTestRes) - break; - itS2.Next(); - } - if(!aTestRes) - break; - itS1.Next(); - } - } - - if(!aTestRes) { - BOP_CheckResult aResult; - aResult.SetShape1(myShape1); - aResult.SetShape2(myShape2); - aResult.SetCheckStatus(BOP_BadType); - myResult.Append(aResult); - return; - } - } - } // both shapes are set (end) -} - -// ================================================================================ -// function: TestSelfInterferences -// purpose: -// ================================================================================ -void BOP_ArgumentAnalyzer::TestSelfInterferences() -{ - Standard_Integer i = 0; - - for(i = 0; i < 2; i++) { - TopoDS_Shape aS = (i == 0) ? myShape1 : myShape2; - - if(aS.IsNull()) - continue; - BOPTools_Checker aChecker(aS); - aChecker.Perform(); - - if (aChecker.HasFaulty()) { - const BOPTools_ListOfCheckResults& aResultList = aChecker.GetCheckResult(); - BOPTools_ListIteratorOfListOfCheckResults anIt(aResultList); - - for(; anIt.More(); anIt.Next()) { - const BOPTools_CheckResult& aCheckResult = anIt.Value(); - - if((aCheckResult.GetCheckStatus() == BOPTools_CHKUNKNOWN) || - (aCheckResult.GetCheckStatus() == BOPTools_BADSHRANKRANGE) || - (aCheckResult.GetCheckStatus() == BOPTools_NULLSRANKRANGE)) { - continue; - } - BOP_CheckResult aResult; - if(i == 0) - aResult.SetShape1(myShape1); - else - aResult.SetShape2(myShape2); - TopTools_ListIteratorOfListOfShape anIt2(aCheckResult.GetShapes()); - - for(; anIt2.More(); anIt2.Next()) { - if(i == 0) - aResult.AddFaultyShape1(anIt2.Value()); - else - aResult.AddFaultyShape2(anIt2.Value()); - } - aResult.SetCheckStatus(BOP_SelfIntersect); - myResult.Append(aResult); - - if(myStopOnFirst) { - return; - } - } - } - } -} - -// ================================================================================ -// function: TestSmallEdge -// purpose: -// ================================================================================ -void BOP_ArgumentAnalyzer::TestSmallEdge() -{ - Standard_Integer i = 0; - BRepExtrema_DistShapeShape aDist; - - for(i = 0; i < 2; i++) { - TopoDS_Shape aS = (i == 0) ? myShape1 : myShape2; - - if(aS.IsNull()) - continue; - - TopExp_Explorer anExp(aS, TopAbs_EDGE); - - for(; anExp.More(); anExp.Next()) { - TopoDS_Edge anEdge = TopoDS::Edge(anExp.Current()); - - if(!CheckEdge(anEdge)) { - Standard_Boolean bKeepResult = Standard_True; - - if(myOperation == BOP_SECTION) { - TopoDS_Shape anOtherS = (i == 0) ? myShape2 : myShape1; - - if(!anOtherS.IsNull()) { -// BRepExtrema_DistShapeShape aDist; - aDist.LoadS2(anOtherS); - - Standard_Boolean bVertexIsOnShape = Standard_False; - Standard_Integer ii = 0; - TopExp_Explorer anExpV(anEdge, TopAbs_VERTEX); - - for(; anExpV.More(); anExpV.Next()) { - TopoDS_Shape aV = anExpV.Current(); - - aDist.LoadS1(aV); - aDist.Perform(); - - if(aDist.IsDone()) { - - for(ii = 1; ii <= aDist.NbSolution(); ii++) { - Standard_Real aTolerance = BRep_Tool::Tolerance(TopoDS::Vertex(aV)); - TopoDS_Shape aSupportShape = aDist.SupportOnShape2(ii); - - switch(aSupportShape.ShapeType()) { - case TopAbs_VERTEX: { - aTolerance += BRep_Tool::Tolerance(TopoDS::Vertex(aSupportShape)); - break; - } - case TopAbs_EDGE: { - aTolerance += BRep_Tool::Tolerance(TopoDS::Edge(aSupportShape)); - break; - } - case TopAbs_FACE: { - aTolerance += BRep_Tool::Tolerance(TopoDS::Face(aSupportShape)); - break; - } - default: - break; - } - - if(aDist.Value() < aTolerance) { - bVertexIsOnShape = Standard_True; - break; - } - } - } - } - - if(!bVertexIsOnShape) { - bKeepResult = Standard_False; - } - } - } - - if(bKeepResult) { - BOP_CheckResult aResult; - - if(i == 0) { - aResult.SetShape1(myShape1); - aResult.AddFaultyShape1(anEdge); - } - else { - aResult.SetShape2(myShape2); - aResult.AddFaultyShape2(anEdge); - } - - aResult.SetCheckStatus(BOP_TooSmallEdge); - myResult.Append(aResult); - - if(myStopOnFirst) { - return; - } - } - } - } - } -} - -// ================================================================================ -// function: TestRebuildFace -// purpose: -// ================================================================================ -void BOP_ArgumentAnalyzer::TestRebuildFace() -{ - if((myOperation == BOP_SECTION) || - (myOperation == BOP_UNKNOWN)) - return; - Standard_Integer i = 0; - - for(i = 0; i < 2; i++) { - TopoDS_Shape aS = (i == 0) ? myShape1 : myShape2; - - if(aS.IsNull()) - continue; - - TopExp_Explorer anExp(aS, TopAbs_FACE); - - for(; anExp.More(); anExp.Next()) { - TopoDS_Face aFace = TopoDS::Face(anExp.Current()); - - BOP_WireEdgeSet aWES (aFace); - TopExp_Explorer anExpE(aFace, TopAbs_EDGE); - Standard_Integer nbstartedges = 0; - - for(; anExpE.More(); anExpE.Next()) { - aWES.AddStartElement(anExpE.Current()); - nbstartedges++; - } - BOP_FaceBuilder aFB; - aFB.Do(aWES); - const TopTools_ListOfShape& aLF = aFB.NewFaces(); - Standard_Boolean bBadFace = Standard_False; - - if(aLF.Extent() != 1) { - bBadFace = Standard_True; - } - else { - Standard_Integer nbedgeused = 0; - anExpE.Init(aLF.First(), TopAbs_EDGE); - - for(; anExpE.More(); anExpE.Next(), nbedgeused++); - - if(nbstartedges != nbedgeused) { - bBadFace = Standard_True; - } - } - - if(bBadFace) { - BOP_CheckResult aResult; - - if(i == 0) { - aResult.SetShape1(myShape1); - aResult.AddFaultyShape1(aFace); - } - else { - aResult.SetShape2(myShape2); - aResult.AddFaultyShape2(aFace); - } - - aResult.SetCheckStatus(BOP_NonRecoverableFace); - myResult.Append(aResult); - - if(myStopOnFirst) { - return; - } - } - } - } -} - -// ================================================================================ -// function: TestTangent -// purpose: -// ================================================================================ -void BOP_ArgumentAnalyzer::TestTangent() -{ - // not implemented -} - -// ================================================================================ -// function: TestMergeSubShapes -// purpose: -// ================================================================================ - void BOP_ArgumentAnalyzer::TestMergeSubShapes(const TopAbs_ShapeEnum theType) -{ - if(myShape1.IsNull() || myShape2.IsNull()) - return; - - BOP_CheckStatus aStatus = BOP_CheckUnknown; - - switch(theType) { - case TopAbs_VERTEX: { - aStatus = BOP_IncompatibilityOfVertex; - break; - } - case TopAbs_EDGE: { - aStatus = BOP_IncompatibilityOfEdge; - break; - } - case TopAbs_FACE: { - aStatus = BOP_IncompatibilityOfFace; - break; - } - default: - return; - } - TopExp_Explorer anExp1(myShape1, theType); - TopExp_Explorer anExp2(myShape2, theType); - TopTools_SequenceOfShape aSeq1, aSeq2; - TopTools_MapOfShape aMap1, aMap2; - - for(; anExp1.More(); anExp1.Next()) { - TopoDS_Shape aS1 = anExp1.Current(); - - if(aMap1.Contains(aS1)) - continue; - aSeq1.Append(aS1); - aMap1.Add(aS1); - } - - for(; anExp2.More(); anExp2.Next()) { - TopoDS_Shape aS2 = anExp2.Current(); - if(aMap2.Contains(aS2)) - continue; - aSeq2.Append(aS2); - aMap2.Add(aS2); - } - - TColStd_Array2OfBoolean anArrayOfFlag(1, aSeq1.Length(), 1, aSeq2.Length()); - Standard_Integer i = 0, j = 0; - for(i = 1; i <= aSeq1.Length(); i++) - for(j = 1; j <= aSeq2.Length(); j++) - anArrayOfFlag.SetValue(i, j, Standard_False); - - for(i = 1; i <= aSeq1.Length(); i++) { - TopoDS_Shape aS1 = aSeq1.Value(i); - TopTools_ListOfShape aListOfS2; - Standard_Integer nbs = 0; - - for(j = 1; j <= aSeq2.Length(); j++) { - TopoDS_Shape aS2 = aSeq2.Value(j); - Standard_Boolean bIsEqual = Standard_False; - - if(theType == TopAbs_VERTEX) { - - TopoDS_Vertex aV1 = TopoDS::Vertex(aS1); - TopoDS_Vertex aV2 = TopoDS::Vertex(aS2); - gp_Pnt aP1 = BRep_Tool::Pnt(aV1); - gp_Pnt aP2 = BRep_Tool::Pnt(aV2); - Standard_Real aDist = aP1.Distance(aP2); - - if(aDist <= (BRep_Tool::Tolerance(aV1) + BRep_Tool::Tolerance(aV2))) { - bIsEqual = Standard_True; - } - } - else if(theType == TopAbs_EDGE) { - Standard_Integer aDiscretize = 30; - Standard_Real aDeflection = 0.01; - TopoDS_Edge aE1 = TopoDS::Edge(aS1); - TopoDS_Edge aE2 = TopoDS::Edge(aS2); - - IntTools_EdgeEdge aEE; - aEE.SetEdge1 (aE1); - aEE.SetEdge2 (aE2); - aEE.SetTolerance1 (BRep_Tool::Tolerance(aE1)); - aEE.SetTolerance2 (BRep_Tool::Tolerance(aE2)); - aEE.SetDiscretize (aDiscretize); - aEE.SetDeflection (aDeflection); - - Standard_Real f = 0., l = 0.; - BRep_Tool::Range(aE1, f, l); - aEE.SetRange1(f, l); - - BRep_Tool::Range(aE2, f, l); - aEE.SetRange2(f, l); - - aEE.Perform(); - - if (aEE.IsDone()) { - const IntTools_SequenceOfCommonPrts& aCPrts = aEE.CommonParts(); - Standard_Integer ii = 0; - - for (ii = 1; ii <= aCPrts.Length(); ii++) { - const IntTools_CommonPrt& aCPart = aCPrts(ii); - - if (aCPart.Type() == TopAbs_EDGE) { - bIsEqual = Standard_True; - } - } - } - } - else if(theType == TopAbs_FACE) { - // not yet implemented! - } - - if(bIsEqual) { - anArrayOfFlag.SetValue(i, j, Standard_True ); - aListOfS2.Append(aS2); - nbs++; - } - } - - if(nbs > 1) { - BOP_CheckResult aResult; - - aResult.SetShape1(myShape1); - aResult.SetShape2(myShape2); - aResult.AddFaultyShape1(aS1); - TopTools_ListIteratorOfListOfShape anIt(aListOfS2); - - for(; anIt.More(); anIt.Next()) { - aResult.AddFaultyShape2(anIt.Value()); - } - - aResult.SetCheckStatus(aStatus); - myResult.Append(aResult); - - if(myStopOnFirst) { - return; - } - } - } - - for(i = 1; i <= aSeq2.Length(); i++) { - TopoDS_Shape aS2 = aSeq2.Value(i); - TopTools_ListOfShape aListOfS1; - Standard_Integer nbs = 0; - - for(j = 1; j <= aSeq1.Length(); j++) { - TopoDS_Shape aS1 = aSeq1.Value(j); - - if(anArrayOfFlag.Value(j, i)) { - aListOfS1.Append(aS1); - nbs++; - } - } - - if(nbs > 1) { - BOP_CheckResult aResult; - - aResult.SetShape1(myShape1); - aResult.SetShape2(myShape2); - TopTools_ListIteratorOfListOfShape anIt(aListOfS1); - - for(; anIt.More(); anIt.Next()) { - aResult.AddFaultyShape1(anIt.Value()); - } - aResult.AddFaultyShape2(aS2); - - aResult.SetCheckStatus(aStatus); - myResult.Append(aResult); - - if(myStopOnFirst) { - return; - } - } - } -} - -// ================================================================================ -// function: TestMergeVertex -// purpose: -// ================================================================================ -void BOP_ArgumentAnalyzer::TestMergeVertex() -{ - TestMergeSubShapes(TopAbs_VERTEX); -} - -// ================================================================================ -// function: TestMergeEdge -// purpose: -// ================================================================================ -void BOP_ArgumentAnalyzer::TestMergeEdge() -{ - TestMergeSubShapes(TopAbs_EDGE); -} - -// ================================================================================ -// function: TestMergeFace -// purpose: -// ================================================================================ -// void BOP_ArgumentAnalyzer::TestMergeFace() -// { - // not implemented -// } - -// ---------------------------------------------------------------------- -// static function: TestShapeType -// purpose: -// ---------------------------------------------------------------------- -Standard_Boolean TestShapeType(const TopoDS_Shape & TheShape) -{ - if(TheShape.IsNull()) - return Standard_False; - - TopAbs_ShapeEnum aT = TheShape.ShapeType(); - - if(aT == TopAbs_COMPOUND && BOPTools_Tools3D::IsEmptyShape(TheShape)) - return Standard_False; - - TopoDS_Iterator anIt; - TopoDS_Shape aSTmp, aShape; - Standard_Integer aNbShapes, TreatRes = 0; - - if(aT==TopAbs_COMPOUND || aT==TopAbs_COMPSOLID) { - aNbShapes=0; - anIt.Initialize(TheShape); - for (; anIt.More(); anIt.Next()) { - if(!aNbShapes) { - aSTmp=anIt.Value(); - } - aNbShapes++; - if(aNbShapes>1) { - break; - } - } - if(aT == TopAbs_COMPOUND) { - if (aNbShapes==1) { - TreatRes = BOPTools_DSFiller::TreatCompound(TheShape, aSTmp); - if(TreatRes != 0) - return Standard_False; - aShape=aSTmp; - aT = aShape.ShapeType(); - } - else if (aNbShapes>1) { - TreatRes = BOPTools_DSFiller::TreatCompound(TheShape, aSTmp); - if(TreatRes != 0) - return Standard_False; - aShape=aSTmp; - aT=aShape.ShapeType(); - } - } - } - - if(aT==TopAbs_COMPOUND || aT==TopAbs_COMPSOLID) { - return Standard_False; - } - - return Standard_True; -} - -// ---------------------------------------------------------------------- -// static function: CheckEdge -// purpose: -// ---------------------------------------------------------------------- -Standard_Boolean CheckEdge(const TopoDS_Edge& theEdge) -{ - Handle(IntTools_Context) aContext; - TopoDS_Vertex aV1, aV2; - // - //modified by NIZNHY-PKV Tue Jan 31 15:07:13 2012f - aContext=new IntTools_Context; - ////modified by NIZNHY-PKV Tue Jan 31 15:07:16 2012t - TopExp::Vertices(theEdge, aV1, aV2); - - - if(aV1.IsNull() || aV2.IsNull() || BRep_Tool::Degenerated(theEdge)) - return Standard_True; - Standard_Real aFirst = 0., aLast = 0.; - BRep_Tool::Range(theEdge, aFirst, aLast); - IntTools_Range aRange(aFirst, aLast); - IntTools_ShrunkRange aSR(theEdge, aV1, aV2, aRange, aContext); - - if (!aSR.IsDone() || aSR.ErrorStatus() == 6) { - return Standard_False; - } - return Standard_True; -} - -// ---------------------------------------------------------------------- -// static function: TestSubShapeType -// purpose: -// ---------------------------------------------------------------------- -Standard_Boolean TestSubShapeType(const TopAbs_ShapeEnum theT1, - const TopAbs_ShapeEnum theT2, - const BOP_Operation theOP) -{ - TopAbs_ShapeEnum aT1 = theT1, aT2 = theT2; - - if(aT1==TopAbs_FACE) { - if(aT2==TopAbs_SOLID || aT2==TopAbs_SHELL || aT2==TopAbs_FACE || - aT2==TopAbs_WIRE || aT2==TopAbs_EDGE) { - aT1=TopAbs_SHELL; - } - } - if(aT2==TopAbs_FACE) { - if(aT1==TopAbs_SOLID || aT1==TopAbs_SHELL || - aT1==TopAbs_WIRE || aT1==TopAbs_EDGE) { - aT2=TopAbs_SHELL; - } - } - if(aT1==TopAbs_EDGE) { - if(aT2==TopAbs_SOLID || aT2==TopAbs_SHELL || - aT2==TopAbs_WIRE || aT2==TopAbs_EDGE) { - aT1=TopAbs_WIRE; - } - } - if(aT2==TopAbs_EDGE) { - if(aT1==TopAbs_SOLID || aT1==TopAbs_SHELL || aT1==TopAbs_WIRE) { - aT2=TopAbs_WIRE; - } - } - - // test operations - if(theOP!=BOP_UNKNOWN) { - Standard_Boolean opOk; - if(aT1==TopAbs_SHELL && aT2==TopAbs_SHELL) - opOk = Standard_True; - else if(aT1==TopAbs_SOLID && aT2==TopAbs_SOLID) - opOk = Standard_True; - else if((aT1==TopAbs_SOLID && aT2==TopAbs_SHELL) || - (aT2==TopAbs_SOLID && aT1==TopAbs_SHELL)) - opOk = Standard_True; - else if(aT1==TopAbs_WIRE && aT2==TopAbs_WIRE) - opOk = Standard_True; - else if((aT1==TopAbs_WIRE && aT2==TopAbs_SHELL) || - (aT2==TopAbs_WIRE && aT1==TopAbs_SHELL)) - opOk = Standard_True; - else if((aT1==TopAbs_WIRE && aT2==TopAbs_SOLID) || - (aT2==TopAbs_WIRE && aT1==TopAbs_SOLID)) - opOk = Standard_True; - else - opOk = Standard_False; - - if(!opOk) { - return Standard_False; - } - - if((aT1==TopAbs_SHELL && aT2==TopAbs_SOLID) || - (aT2==TopAbs_SHELL && aT1==TopAbs_SOLID)) { - if(!BOP_ShellSolid::CheckArgTypes(aT1,aT2,theOP)) { - return Standard_False; - } - } - if((aT1==TopAbs_WIRE && aT2==TopAbs_SOLID) || - (aT2==TopAbs_WIRE && aT1==TopAbs_SOLID)) { - if(!BOP_WireSolid::CheckArgTypes(aT1,aT2,theOP)) { - return Standard_False; - } - } - if((aT1==TopAbs_WIRE && aT2==TopAbs_SHELL) || - (aT2==TopAbs_WIRE && aT1==TopAbs_SHELL)) { - if(!BOP_WireShell::CheckArgTypes(aT1,aT2,theOP)) { - return Standard_False; - } - } - } - - return Standard_True; -} diff --git a/src/BOP/BOP_ArgumentAnalyzer.lxx b/src/BOP/BOP_ArgumentAnalyzer.lxx deleted file mode 100755 index 7918ffc5ee..0000000000 --- a/src/BOP/BOP_ArgumentAnalyzer.lxx +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -inline Standard_Boolean& BOP_ArgumentAnalyzer::ArgumentTypeMode() -{ - return myArgumentTypeMode; -} - - -inline Standard_Boolean& BOP_ArgumentAnalyzer::SelfInterMode() -{ - return mySelfInterMode; -} - - -inline Standard_Boolean& BOP_ArgumentAnalyzer::SmallEdgeMode() -{ - return mySmallEdgeMode; -} - - -inline Standard_Boolean& BOP_ArgumentAnalyzer::RebuildFaceMode() -{ - return myRebuildFaceMode; -} - - -inline Standard_Boolean& BOP_ArgumentAnalyzer::TangentMode() -{ - return myTangentMode; -} - - -inline Standard_Boolean& BOP_ArgumentAnalyzer::MergeVertexMode() -{ - return myMergeVertexMode; -} - - -inline Standard_Boolean& BOP_ArgumentAnalyzer::MergeEdgeMode() -{ - return myMergeEdgeMode; -} - -// inline Standard_Boolean& BOP_ArgumentAnalyzer::MergeFaceMode() -// { -// return myMergeFaceMode; -// } diff --git a/src/BOP/BOP_BlockBuilder.cdl b/src/BOP/BOP_BlockBuilder.cdl deleted file mode 100755 index 8eea71e131..0000000000 --- a/src/BOP/BOP_BlockBuilder.cdl +++ /dev/null @@ -1,142 +0,0 @@ --- Created on: 1993-02-25 --- Created by: Jean Yves LEBEY --- Copyright (c) 1993-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class BlockBuilder from BOP - - ---Purpose: - --- auxiliary class to storage and operate with data of - --- connexity blocks inside the given ShapeSet - --- - -uses - - Shape from TopoDS, - - ShapeSet from BOP, - BlockIterator from BOP, - - SequenceOfInteger from TColStd, - DataMapOfIntegerInteger from TColStd, - IndexedMapOfOrientedShape from TopTools - -is - - Create - returns BlockBuilder; - ---Purpose: - --- Empty Constructor - --- - Create(SS : in out ShapeSet) - returns BlockBuilder; - ---Purpose: - --- Create an object for given ShapeSet - --- - MakeBlock(me : in out; - SS : in out ShapeSet) - is static; - ---Purpose: - --- Compute the set of connexity blocks of elements - --- for of the ShapeSet SS - -- - -- - -- I t e r a t i o n o n b l o c k s made by MakeBlock - -- - InitBlock(me : in out) - is static; - - MoreBlock(me) - returns Boolean from Standard - is static; - - NextBlock(me : in out) - is static; - -- - -- I t e r a t i o n o n on shapes inside the current block - -- - BlockIterator(me) - returns BlockIterator from BOP - is static; - --- Purpose: - --- Returns the BlockIterator for the current block . - --- - Element(me; BI : BlockIterator from BOP) - returns Shape from TopoDS - is static; - ---C++: return const & - ---Purpose: - --- Returns the current element of . - --- - Element(me; I : Integer from Standard) - returns Shape from TopoDS - is static; - ---C++: return const & - ---Purpose: - --- Returns the current element with index . - --- - Element(me; S : Shape from TopoDS) - returns Integer from Standard; - ---Purpose: - --- Returns the index of the current element . - --- - ElementIsValid(me; BI : BlockIterator) - returns Boolean from Standard; - ---Purpose: - --- Internal - --- - ElementIsValid(me; I : Integer from Standard) - returns Boolean from Standard; - ---Purpose: - --- Internal - --- - AddElement(me : in out; S : Shape from TopoDS) - returns Integer from Standard; - ---Purpose: - --- Internal - --- - SetValid(me : in out; - BI : BlockIterator from BOP ; - IsValid : Boolean from Standard); - ---Purpose: - --- Internal - --- - SetValid(me : in out; - I : Integer from Standard; - IsValid : Boolean from Standard); - ---Purpose: - --- Internal - --- - CurrentBlockIsRegular(me : in out) - returns Boolean from Standard; - ---Purpose: - --- Returns TRUE if all elements inside the current block - --- are biconnexial - --- - -fields - - myOrientedShapeMapIsValid : DataMapOfIntegerInteger from TColStd; - myOrientedShapeMap : IndexedMapOfOrientedShape from TopTools; - myBlocks : SequenceOfInteger from TColStd; - myBlockIndex : Integer from Standard; - myIsDone : Boolean from Standard; - myBlocksIsRegular : SequenceOfInteger from TColStd; - -end BlockBuilder; diff --git a/src/BOP/BOP_BlockBuilder.cxx b/src/BOP/BOP_BlockBuilder.cxx deleted file mode 100755 index bdb7743883..0000000000 --- a/src/BOP/BOP_BlockBuilder.cxx +++ /dev/null @@ -1,319 +0,0 @@ -// Created on: 1993-03-11 -// Created by: Jean Yves LEBEY -// Copyright (c) 1993-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#include - -#include - -//======================================================================= -//function : BOP_BlockBuilder::BOP_BlockBuilder -//purpose : -//======================================================================= -BOP_BlockBuilder::BOP_BlockBuilder() -: - myIsDone(Standard_False) -{ -} - -//======================================================================= -//function : BOP_BlockBuilder::BOP_BlockBuilder -//purpose : -//======================================================================= - BOP_BlockBuilder::BOP_BlockBuilder (BOP_ShapeSet& SS) - :myIsDone(Standard_False) -{ - MakeBlock(SS); -} - -//======================================================================= -//function : MakeBlock -//purpose : -//======================================================================= - void BOP_BlockBuilder::MakeBlock(BOP_ShapeSet& SS) -{ - // Compute the set of connexity blocks of elements of element set SS - // - // Logic : - // - A block is a set of connex elements of SS - // - We assume that any element of SS appears in only 1 connexity block. - // - // Implementation : - // - All the elements of all the blocks are stored in map myOrientedShapeMap(M). - // - A connexity block is a segment [f,l] of element indices of M. - // - myBlocks is a sequence of integer; each integer is the index of the - // first element (in M) of a connexity block. - // - Bounds [f,l] of a connexity block are : - // f = myBlocks(i) - // l = myBlocks(i+1) - 1 - - myOrientedShapeMap.Clear(); - myOrientedShapeMapIsValid.Clear(); - myBlocks.Clear(); - myBlocksIsRegular.Clear(); - // - Standard_Boolean IsRegular, CurNei, Mextent, Eindex, - EnewinM, searchneighbours, condregu; - Standard_Integer iiregu; - // - // - SS.InitStartElements(); - for (; SS.MoreStartElements(); SS.NextStartElement()) { - const TopoDS_Shape& E = SS.StartElement(); - Mextent = myOrientedShapeMap.Extent(); - Eindex = AddElement(E); - - // E = current element of the element set SS - // Mextent = index of last element stored in map M, before E is added. - // Eindex = index of E added to M : Eindex > Mextent => E is new in M - - EnewinM = (Eindex > Mextent); - if (EnewinM) { - // - // make a new block starting at element Eindex - myBlocks.Append(Eindex); - IsRegular = Standard_True; CurNei = 0; - // put in current block all the elements connex to E : - // while an element E has been added to M - // - compute neighbours of E : N(E) - // - add each element N of N(E) to M - - Mextent = myOrientedShapeMap.Extent(); - searchneighbours = (Eindex <= Mextent); - while (searchneighbours) { - - // E = element of M on which neighbours must be searched - // first step : Eindex = index of starting element of SS - // next steps : Eindex = index of neighbours of starting element of SS - const TopoDS_Shape& anE = myOrientedShapeMap(Eindex); - CurNei = SS.MaxNumberSubShape(anE); - - condregu = (CurNei > 2) ? Standard_False : Standard_True; - - IsRegular = IsRegular && condregu; - // - // compute neighbours of E : add them to M to increase M.Extent(). - SS.InitNeighbours(anE); - - for (; SS.MoreNeighbours(); SS.NextNeighbour()) { - const TopoDS_Shape& N = SS.Neighbour(); - AddElement(N); - } - - Eindex++; - Mextent = myOrientedShapeMap.Extent(); - searchneighbours = (Eindex <= Mextent); - - } // while (searchneighbours) - - iiregu = IsRegular ? 1 : 0; - myBlocksIsRegular.Append(iiregu); - } // if (EnewinM) - } // for () - // - // To value the l bound of the last connexity block created above, - // we create an artificial block of value = myOrientedShapeMap.Extent() + 1 - // The real number of connexity blocks is myBlocks.Length() - 1 - Mextent = myOrientedShapeMap.Extent(); - myBlocks.Append(Mextent + 1); - - myIsDone = Standard_True; -} - -//======================================================================= -//function : InitBlock -//purpose : -//======================================================================= - void BOP_BlockBuilder::InitBlock() -{ - myBlockIndex = 1; -} - -//======================================================================= -//function : MoreBlock -//purpose : -//======================================================================= - Standard_Boolean BOP_BlockBuilder::MoreBlock() const -{ - // the length of myBlocks is 1 + number of connexity blocks - Standard_Integer l = myBlocks.Length(); - Standard_Boolean b = (myBlockIndex < l); - return b; -} - -//======================================================================= -//function : NextBlock -//purpose : -//======================================================================= - void BOP_BlockBuilder::NextBlock() -{ - myBlockIndex++; -} - -//======================================================================= -//function : BlockIterator -//purpose : -//======================================================================= - BOP_BlockIterator BOP_BlockBuilder::BlockIterator() const -{ - Standard_Integer lower, upper; - - lower = myBlocks(myBlockIndex); - upper = myBlocks(myBlockIndex+1)-1; - - return BOP_BlockIterator(lower,upper); -} - -//======================================================================= -//function : Element -//purpose : -//======================================================================= - const TopoDS_Shape& BOP_BlockBuilder::Element (const BOP_BlockIterator& BI) const -{ - Standard_Boolean isbound = BI.More(); - if (!isbound) { - Standard_Failure::Raise("OutOfRange"); - } - - Standard_Integer index = BI.Value(); - const TopoDS_Shape& E = myOrientedShapeMap(index); - return E; -} -//======================================================================= -//function : Element -//purpose : -//======================================================================= - const TopoDS_Shape& BOP_BlockBuilder::Element (const Standard_Integer index) const -{ - Standard_Boolean isbound = myOrientedShapeMapIsValid.IsBound(index); - if (!isbound) { - Standard_Failure::Raise("OutOfRange"); - } - const TopoDS_Shape& E = myOrientedShapeMap(index); - return E; -} -//======================================================================= -//function : Element -//purpose : -//======================================================================= - Standard_Integer BOP_BlockBuilder::Element (const TopoDS_Shape& E) const -{ - Standard_Boolean isbound = myOrientedShapeMap.Contains(E); - if (!isbound) { - Standard_Failure::Raise("OutOfRange"); - } - - Standard_Integer I = myOrientedShapeMap.FindIndex(E); - return I; -} - -//======================================================================= -//function : ElementIsValid -//purpose : -//======================================================================= - Standard_Boolean BOP_BlockBuilder::ElementIsValid (const BOP_BlockIterator& BI) const -{ - Standard_Boolean isvalid, isbound = BI.More(); - if (!isbound) { - return Standard_False; - } - Standard_Integer Sindex, isb; - - Sindex = BI.Value(); - isb = myOrientedShapeMapIsValid.Find(Sindex); - isvalid = (isb == 1)? Standard_True: Standard_False; - - return isvalid; -} -//======================================================================= -//function : ElementIsValid -//purpose : -//======================================================================= - Standard_Boolean BOP_BlockBuilder::ElementIsValid (const Standard_Integer Sindex) const -{ - Standard_Boolean isvalid, isbound = myOrientedShapeMapIsValid.IsBound(Sindex); - if (!isbound) return Standard_False; - - Standard_Integer isb = myOrientedShapeMapIsValid.Find(Sindex); - isvalid = (isb == 1)? Standard_True: Standard_False; - - return isvalid; -} - -//======================================================================= -//function : AddElement -//purpose : -//======================================================================= - Standard_Integer BOP_BlockBuilder::AddElement(const TopoDS_Shape& S) -{ - Standard_Integer Sindex = myOrientedShapeMap.Add(S); - myOrientedShapeMapIsValid.Bind(Sindex, 1); - - return Sindex; -} - -//======================================================================= -//function : SetValid -//purpose : -//======================================================================= - void BOP_BlockBuilder::SetValid(const BOP_BlockIterator& BI, - const Standard_Boolean isvalid) -{ - Standard_Boolean isbound = BI.More(); - if (!isbound) { - return; - } - Standard_Integer Sindex, i; - Sindex = BI.Value(); - i = (isvalid) ? 1 : 0; - myOrientedShapeMapIsValid.Bind(Sindex,i); -} -//======================================================================= -//function : SetValid -//purpose : -//======================================================================= - void BOP_BlockBuilder::SetValid(const Standard_Integer Sindex, - const Standard_Boolean isvalid) -{ - Standard_Boolean isbound = myOrientedShapeMapIsValid.IsBound(Sindex); - if (!isbound) { - return; - } - - Standard_Integer i = (isvalid) ? 1 : 0; - myOrientedShapeMapIsValid.Bind(Sindex,i); -} - -//======================================================================= -//function : CurrentBlockIsRegular -//purpose : -//======================================================================= - Standard_Boolean BOP_BlockBuilder::CurrentBlockIsRegular() -{ - Standard_Boolean b = Standard_False; - Standard_Integer i = myBlocksIsRegular.Value(myBlockIndex); - - if(i == 1) { - b = Standard_True; - } - return b; -} - - diff --git a/src/BOP/BOP_BlockIterator.cdl b/src/BOP/BOP_BlockIterator.cdl deleted file mode 100755 index 7737d7752d..0000000000 --- a/src/BOP/BOP_BlockIterator.cdl +++ /dev/null @@ -1,86 +0,0 @@ --- Created on: 1993-02-25 --- Created by: Jean Yves LEBEY --- Copyright (c) 1993-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class BlockIterator from BOP - - ---Purpose: - - -- Auxiliary class to provide - -- simple iteration on indexes that - -- belongs to the integer range [Lower,Upper] - -- with increment =1 - -raises - - NoMoreObject from Standard - -is - - Create - returns BlockIterator from BOP; - ---Purpose: - --- Empty Constructor - --- - Create(Lower,Upper : Integer from Standard) - returns BlockIterator from BOP; - ---Purpose: - --- Creates an object with initial range - --- of [Lower,Upper] - --- - - Initialize(me : in out) - is static; - ---Purpose: - --- Initialize an object with initial range - --- of [Lower,Upper] - --- - More(me) - returns Boolean from Standard - is static; - ---Purpose: - --- Support of Iteration - --- - Next(me : in out) - raises NoMoreObject - is static; - ---Purpose: - --- Support of Iteration - --- - Value(me) - returns Integer from Standard - is static; - ---Purpose: - --- Support of Iteration - --- - Extent(me) - returns Integer from Standard - is static; - ---Purpose: - --- Returns the extension=myUpper - myLower + 1; - --- - -fields - - myLower : Integer from Standard; - myUpper : Integer from Standard; - myValue : Integer from Standard; - -end BlockIterator; diff --git a/src/BOP/BOP_BlockIterator.cxx b/src/BOP/BOP_BlockIterator.cxx deleted file mode 100755 index b56a47ff0d..0000000000 --- a/src/BOP/BOP_BlockIterator.cxx +++ /dev/null @@ -1,92 +0,0 @@ -// Created on: 1993-03-23 -// Created by: Jean Yves LEBEY -// Copyright (c) 1993-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#include - -//======================================================================= -//function : BOP_BlockIterator::BOP_BlockIterator -//purpose : -//======================================================================= -BOP_BlockIterator::BOP_BlockIterator() -: - myLower(0), - myUpper(0), - myValue(1) -{ -} - -//======================================================================= -//function : BOP_BlockIterator::BOP_BlockIterator -//purpose : -//======================================================================= - BOP_BlockIterator::BOP_BlockIterator(const Standard_Integer Lower, - const Standard_Integer Upper) -: - myLower(Lower), - myUpper(Upper), - myValue(Lower) -{ -} -//======================================================================= -//function : Initialize -//purpose : -//======================================================================= - void BOP_BlockIterator::Initialize() -{ - myValue = myLower; -} -//======================================================================= -//function : More -//purpose : -//======================================================================= - Standard_Boolean BOP_BlockIterator::More() const -{ - Standard_Boolean b = (myValue <= myUpper); - return b; -} -//======================================================================= -//function : Next -//purpose : -//======================================================================= - void BOP_BlockIterator::Next() -{ - myValue++; -} -//======================================================================= -//function : Value -//purpose : -//======================================================================= - Standard_Integer BOP_BlockIterator::Value() const -{ - return myValue; -} -//======================================================================= -//function : Extent -//purpose : -//======================================================================= - Standard_Integer BOP_BlockIterator::Extent() const -{ - if (myLower != 0) { - Standard_Integer n = myUpper - myLower + 1; - return n; - } - return 0; -} diff --git a/src/BOP/BOP_Builder.cdl b/src/BOP/BOP_Builder.cdl deleted file mode 100755 index 6e7affa4cb..0000000000 --- a/src/BOP/BOP_Builder.cdl +++ /dev/null @@ -1,217 +0,0 @@ --- Created on: 2001-03-29 --- Created by: Peter KURNEV --- Copyright (c) 2001-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -deferred class Builder from BOP - - ---Purpose: - - -- The Root class to perform a Boolean Operations (BO) - -uses - - Shape from TopoDS, - Operation from BOP, - HistoryCollector from BOP, - ShapeEnum from TopAbs, - DSFiller from BOPTools, - PDSFiller from BOPTools, - - IndexedDataMapOfShapeListOfShape from TopTools, - ListOfShape from TopTools, - IndexedMapOfShape from TopTools - ---raises - -is - - Initialize - returns Builder from BOP; - ---Purpose: - --- Empty constructor; - --- - SetShapes (me:out; - aS1: Shape from TopoDS; - aS2: Shape from TopoDS); - ---Purpose: - -- Set shapes (arguments) to perform BO - --- - SetOperation (me:out; - anOp:Operation from BOP); - ---Purpose: - -- Set type of the BO to perform - -- - SetManifoldFlag (me:out; - aFlag:Boolean from Standard); - ---Purpose: Set the flag to allow the result - -- be manifold or non-manifold (not used) - -- - Shape1 (me) - returns Shape from TopoDS; - ---C++: return const & - ---Purpose: - -- Selector - -- - Shape2 (me) - returns Shape from TopoDS; - ---C++: return const & - ---Purpose: - -- Selector - -- - Operation (me) - returns Operation from BOP; - ---Purpose: - -- Selector - -- - ManifoldFlag(me) - returns Boolean from Standard; - ---Purpose: - -- Selector - -- - IsDone(me) - returns Boolean from Standard ; - ---Purpose: - -- Selector - -- - ErrorStatus (me) - returns Integer from Standard; - ---Purpose: - -- Selector - -- - Result(me) - returns Shape from TopoDS ; - ---C++: return const & - ---Purpose: - -- Returns the result of the BO - -- - Do (me:out) - is virtual; - ---Purpose: - -- Does the BO from the beggining to the end, - -- i.e. create new DataStructure, DSFiller, - -- compute all interferences, compute states, - -- build result etc - -- - DoWithFiller (me:out; - aDSF: DSFiller from BOPTools) - is virtual; - ---Purpose: - -- Does the BO using existing Filler to the end - -- - BuildResult (me:out) - is virtual; - ---Purpose: - -- Constructs the final result of the BO - -- - Destroy (me: in out) - is virtual; - ---C++: alias "Standard_EXPORT virtual ~BOP_Builder(){Destroy();}" - ---Purpose: - -- Destructor - -- - SortTypes (myclass; - aType1:out ShapeEnum from TopAbs; - aType2:out ShapeEnum from TopAbs); - ---Purpose: - -- Sort types of shapes as integers in increasing order - -- - Modified (me; - aS : Shape from TopoDS) - returns ListOfShape from TopTools; - ---C++: return const & - ---Purpose: - -- Returns the list of shapes modified from the shape aS - -- - IsDeleted(me; - aS : Shape from TopoDS) - returns Boolean from Standard; - ---Purpose: - -- Returns TRUE if the result does not contain the shape aS - -- - FillModified(me:out) - is protected; - ---Purpose: - -- Fill the list of shapes modified from the shape aS. - -- For Internal usage - -- - FillModified(me:out; - aS : Shape from TopoDS; - aL : ListOfShape from TopTools) - is protected; - ---Purpose: - -- Fill the list of shapes modified from the shape aS. - -- For Internal usage - -- - FillModified(me:out; - aE : Shape from TopoDS; - aSp: Shape from TopoDS) - is protected; - ---Purpose: - -- Fill the list of shapes modified from the shape aS - -- For Internal usage - -- - SectionEdges (me) - returns ListOfShape from TopTools; - ---C++: return const & - ---Purpose: - -- Returns the list of shapes that are parts of BO "Section" - -- for given arguments. - -- For Internal usage - -- - - SetHistoryCollector(me: in out; theHistory: HistoryCollector from BOP) - is virtual; - - GetHistoryCollector(me) - returns HistoryCollector from BOP; - -fields - - myShape1 : Shape from TopoDS - is protected; - myShape2 : Shape from TopoDS - is protected; - myOperation : Operation from BOP - is protected; - myManifoldFlag : Boolean from Standard - is protected; - myIsDone : Boolean from Standard - is protected; - myErrorStatus : Integer from Standard - is protected; - myResult : Shape from TopoDS - is protected; - myDraw : Integer from Standard - is protected; - myDSFiller : PDSFiller from BOPTools - is protected; - myResultMap : IndexedMapOfShape from TopTools - is protected; - myModifiedMap : IndexedDataMapOfShapeListOfShape from TopTools - is protected; - myEmptyList : ListOfShape from TopTools - is protected; - mySectionEdges : ListOfShape from TopTools - is protected; - - myHistory: HistoryCollector from BOP - is protected; -end Builder; - diff --git a/src/BOP/BOP_Builder.cxx b/src/BOP/BOP_Builder.cxx deleted file mode 100755 index 5061849d37..0000000000 --- a/src/BOP/BOP_Builder.cxx +++ /dev/null @@ -1,390 +0,0 @@ -// Created on: 2001-03-29 -// Created by: Peter KURNEV -// Copyright (c) 2001-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include - -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//======================================================================= -// function: BOP_Builder::BOP_Builder -// purpose: -//======================================================================= -BOP_Builder::BOP_Builder() -: myOperation(BOP_UNKNOWN), - myManifoldFlag(Standard_False), - myIsDone(Standard_False), - myErrorStatus(1), - myDraw(0) -{ -} -//======================================================================= -// function: Destroy -// purpose: -//======================================================================= - void BOP_Builder::Destroy() -{ -} - -//======================================================================= -// function: SetShapes -// purpose: -//======================================================================= - void BOP_Builder::SetShapes (const TopoDS_Shape& aS1, - const TopoDS_Shape& aS2) -{ - myShape1=aS1; - myShape2=aS2; -} -//======================================================================= -// function: SetOperation -// purpose: -//======================================================================= - void BOP_Builder::SetOperation (const BOP_Operation anOp) -{ - myOperation=anOp; -} - - -//======================================================================= -// function: SetManifoldFlag -// purpose: -//======================================================================= - void BOP_Builder::SetManifoldFlag (const Standard_Boolean aFlag) -{ - myManifoldFlag=aFlag; -} -//======================================================================= -// function: Shape1 -// purpose: -//======================================================================= - const TopoDS_Shape& BOP_Builder::Shape1()const -{ - return myShape1; -} - -//======================================================================= -// function: Shape2 -// purpose: -//======================================================================= - const TopoDS_Shape& BOP_Builder::Shape2()const -{ - return myShape2; -} -//======================================================================= -// function: Operation -// purpose: -//======================================================================= - BOP_Operation BOP_Builder::Operation () const -{ - return myOperation; -} - -//======================================================================= -// function: ManifoldFlag -// purpose: -//======================================================================= - Standard_Boolean BOP_Builder::ManifoldFlag () const -{ - return myManifoldFlag; -} -//======================================================================= -// function: IsDone -// purpose: -//======================================================================= - Standard_Boolean BOP_Builder::IsDone() const -{ - return myIsDone; -} -//======================================================================= -// function: ErrorStatus -// purpose: -//======================================================================= - Standard_Integer BOP_Builder::ErrorStatus() const -{ - return myErrorStatus; -} -//======================================================================= -// function: Result -// purpose: -//======================================================================= - const TopoDS_Shape& BOP_Builder::Result()const -{ - return myResult; -} - -//======================================================================= -// function: Do -// purpose: -//======================================================================= - void BOP_Builder::Do() -{ -} -//======================================================================= -// function: DoDoWithFiller -// purpose: -//======================================================================= - void BOP_Builder::DoWithFiller(const BOPTools_DSFiller& ) -{ -} - -//======================================================================= -// function: BuildResult -// purpose: -//======================================================================= - void BOP_Builder::BuildResult() -{ -} -// -// -//======================================================================= -// function: FillModified -// purpose: -//======================================================================= - void BOP_Builder::FillModified() -{ - // - // Prepare myResultMap - myResultMap.Clear(); - TopExp::MapShapes(myResult, TopAbs_FACE, myResultMap); - TopExp::MapShapes(myResult, TopAbs_EDGE, myResultMap); - // - // Fill Modified for Edges - Standard_Integer i, aNbSources, aNbPaveBlocks, nSp, nFace; - // - const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); - const BOPTools_SplitShapesPool& aSplitShapesPool= myDSFiller->SplitShapesPool(); - const BOPTools_CommonBlockPool& aCommonBlockPool= myDSFiller->CommonBlockPool(); - // - aNbSources=aDS.NumberOfSourceShapes(); - for (i=1; i<=aNbSources; i++) { - - if (aDS.GetShapeType(i) != TopAbs_EDGE){ - continue; - } - // - const TopoDS_Shape& aE=aDS.Shape(i); - // - const BOPTools_ListOfPaveBlock& aSplitEdges=aSplitShapesPool(aDS.RefEdge(i)); - const BOPTools_ListOfCommonBlock& aCBlocks =aCommonBlockPool(aDS.RefEdge(i)); - // - aNbPaveBlocks=aSplitEdges.Extent(); - if (!aNbPaveBlocks) { - continue; - } - // - TopTools_IndexedMapOfShape aM; - - BOPTools_ListIteratorOfListOfCommonBlock aCBIt(aCBlocks); - for (; aCBIt.More(); aCBIt.Next()) { - BOPTools_CommonBlock& aCB=aCBIt.Value(); - // - nFace=aCB.Face(); - // - if (nFace) { - BOPTools_PaveBlock& aPB=aCB.PaveBlock1(i); - nSp=aPB.Edge(); - const TopoDS_Shape& aSp=aDS.Shape(nSp); - // - if (aM.Contains(aSp)) { - continue; - } - aM.Add(aSp); - // - if (myResultMap.Contains(aSp)) { - FillModified(aE, aSp); - } - } - // - else { - const BOPTools_PaveBlock& aPB=aCB.PaveBlock1(); - nSp=aPB.Edge(); - const TopoDS_Shape& aSp=aDS.Shape(nSp); - // - if (aM.Contains(aSp)) { - continue; - } - aM.Add(aSp); - // - if (myResultMap.Contains(aSp)) { - FillModified(aE, aSp); - } - } - } // for (; aCBIt.More(); aCBIt.Next()) - - - BOPTools_ListIteratorOfListOfPaveBlock aPBIt(aSplitEdges); - for (; aPBIt.More(); aPBIt.Next()) { - const BOPTools_PaveBlock& aPB=aPBIt.Value(); - nSp=aPB.Edge(); - const TopoDS_Shape& aSp=aDS.Shape(nSp); - // - if (aM.Contains(aSp)) { - continue; - } - aM.Add(aSp); - // - if (myResultMap.Contains(aSp)) { - FillModified(aE, aSp); - } - }// for (; aPBIt.More(); aPBIt.Next()) - } -} -//======================================================================= -// function: FillModified -// purpose: -//======================================================================= - void BOP_Builder::FillModified(const TopoDS_Shape& aE, - const TopoDS_Shape& aSp) -{ - if (myModifiedMap.Contains(aE)) { - TopTools_ListOfShape& aLM=myModifiedMap.ChangeFromKey(aE); - aLM.Append(aSp); - } - else { - TopTools_ListOfShape aLM; - aLM.Append(aSp); - myModifiedMap.Add(aE, aLM); - } -} -//======================================================================= -// function: FillModified -// purpose: -//======================================================================= - void BOP_Builder::FillModified(const TopoDS_Shape& aS, - const TopTools_ListOfShape& aLFx) -{ - TopTools_ListIteratorOfListOfShape anIt(aLFx); - // - if (myModifiedMap.Contains(aS)) { - TopTools_ListOfShape& aLM=myModifiedMap.ChangeFromKey(aS); - anIt.Initialize(aLFx); - for (; anIt.More(); anIt.Next()) { - const TopoDS_Shape& aFx=anIt.Value(); - aLM.Append(aFx); - } - } - - else { - TopTools_ListOfShape aLM; - anIt.Initialize(aLFx); - for (; anIt.More(); anIt.Next()) { - const TopoDS_Shape& aFx=anIt.Value(); - aLM.Append(aFx); - } - myModifiedMap.Add(aS, aLM); - } -} -//======================================================================= -// function: Modified -// purpose: -//======================================================================= - const TopTools_ListOfShape& BOP_Builder::Modified(const TopoDS_Shape& aS)const -{ - if (myModifiedMap.Contains(aS)) { - const TopTools_ListOfShape& aLM=myModifiedMap.FindFromKey(aS); - return aLM; - } - else { - return myEmptyList; - } -} -//======================================================================= -// function: IsDeleted -// purpose: -//======================================================================= - Standard_Boolean BOP_Builder::IsDeleted(const TopoDS_Shape& aS)const -{ - Standard_Boolean bFlag=Standard_False; - // - if (myResultMap.Contains(aS)) { - return bFlag; - } - // - const TopTools_ListOfShape& aLM=Modified(aS); - if (aLM.Extent()) { - return bFlag; - } - // - return !bFlag; -} - - -//======================================================================= -//function : SortTypes -//purpose : -//======================================================================= - void BOP_Builder::SortTypes(TopAbs_ShapeEnum& aType1, - TopAbs_ShapeEnum& aType2) -{ - Standard_Integer iT1, iT2; - - if (aType1==aType2) - return; - - iT1=(Standard_Integer) aType1; - iT2=(Standard_Integer) aType2; - - if (iT1 < iT2) { - aType1=(TopAbs_ShapeEnum) iT2; - aType2=(TopAbs_ShapeEnum) iT1; - } -} - -//======================================================================= -// function: SectionEdges -// purpose: -//======================================================================= - const TopTools_ListOfShape& BOP_Builder::SectionEdges()const -{ - return mySectionEdges; -} - - -//======================================================================= -// function: SetHistoryCollector -// purpose: -//======================================================================= -void BOP_Builder::SetHistoryCollector(const Handle(BOP_HistoryCollector)& theHistory) -{ - myHistory = theHistory; -} - -//======================================================================= -// function: GetHistoryCollector -// purpose: -//======================================================================= -Handle(BOP_HistoryCollector) BOP_Builder::GetHistoryCollector() const -{ - return myHistory; -} diff --git a/src/BOP/BOP_BuilderTools.cdl b/src/BOP/BOP_BuilderTools.cdl deleted file mode 100755 index add4e24079..0000000000 --- a/src/BOP/BOP_BuilderTools.cdl +++ /dev/null @@ -1,105 +0,0 @@ --- Created on: 2001-11-02 --- Created by: Peter KURNEV --- Copyright (c) 2001-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class BuilderTools from BOP - - ---Purpose: - -- Some handy tools used by classes - -- BOP_ShellShell, - -- BOP_ShellSolid, - -- BOP_SolidSolid - -- to build a result - -uses - - IndexedMapOfInteger from TColStd, - - State from TopAbs, - ShapeEnum from TopAbs, - - Face from TopoDS, - Edge from TopoDS, - - ListOfShape from TopTools, - - StateOfShape from BooleanOperations, - - IndexedDataMapOfIntegerIndexedMapOfInteger from BOPTColStd, - - CArray1OfSSInterference from BOPTools, - - Operation from BOP, - ListOfConnexityBlock from BOP - - -is - - StateToCompare(myclass; - iRank :Integer from Standard; - anOp :Operation from BOP) - returns StateOfShape from BooleanOperations; - - ToReverseSection(myclass; - iRank :Integer from Standard; - anOp :Operation from BOP) - returns Boolean from Standard; - - ToReverseFace(myclass; - iRank :Integer from Standard; - anOp :Operation from BOP) - returns Boolean from Standard; - - OrientSectionEdgeOnF1(myclass; - aF1 :Face from TopoDS; - aF2 :Face from TopoDS; - iRank :Integer from Standard; - anOp :Operation from BOP; - aE :out Edge from TopoDS); - - IsSameDomainFaceWithF1(myclass; - nF1 :Integer from Standard; - nF2 :Integer from Standard; - aFFM:IndexedMapOfInteger from TColStd; - aFFs:out CArray1OfSSInterference from BOPTools) - returns Boolean from Standard; - - IsPartIN2DToKeep(myclass; - aSt :State from TopAbs; - iRank :Integer from Standard; - anOp :Operation from BOP) - returns Boolean from Standard; - - IsPartOn2dToKeep(myclass; - aSt :State from TopAbs; - iRank :Integer from Standard; - anOp :Operation from BOP) - returns Boolean from Standard; - - DoMap(myclass; - aFFs :out CArray1OfSSInterference from BOPTools; - aFFMap:out IndexedDataMapOfIntegerIndexedMapOfInteger from BOPTColStd); - - MakeConnexityBlocks(myclass; - aLE : ListOfShape from TopTools; - aType : ShapeEnum from TopAbs; - aLConBlks : out ListOfConnexityBlock from BOP); - -end BuilderTools; diff --git a/src/BOP/BOP_BuilderTools.cxx b/src/BOP/BOP_BuilderTools.cxx deleted file mode 100755 index 93a027f0cb..0000000000 --- a/src/BOP/BOP_BuilderTools.cxx +++ /dev/null @@ -1,427 +0,0 @@ -// Created on: 2001-11-02 -// Created by: Peter KURNEV -// Copyright (c) 2001-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#include - -#include - -#include - -#include -#include - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include - -//======================================================================= -// function: StateToCompare -// purpose: -//======================================================================= -BooleanOperations_StateOfShape - BOP_BuilderTools::StateToCompare(const Standard_Integer iRank, - const BOP_Operation anOp) -{ - BooleanOperations_StateOfShape aSt=BooleanOperations_UNKNOWN; - - if (iRank==1) { - if (anOp==BOP_COMMON) { - aSt=BooleanOperations_IN; - } - if (anOp==BOP_FUSE) { - aSt=BooleanOperations_OUT; - } - if (anOp==BOP_CUT) { - aSt=BooleanOperations_OUT; - } - if (anOp==BOP_CUT21) { - aSt=BooleanOperations_IN; - } - } - - if (iRank==2) { - if (anOp==BOP_COMMON) { - aSt=BooleanOperations_IN; - } - if (anOp==BOP_FUSE) { - aSt=BooleanOperations_OUT; - } - if (anOp==BOP_CUT) { - aSt=BooleanOperations_IN; - } - if (anOp==BOP_CUT21) { - aSt=BooleanOperations_OUT; - } - } - return aSt; -} -//======================================================================= -// function: ToReverseSection -// purpose: -//======================================================================= - Standard_Boolean BOP_BuilderTools::ToReverseSection(const Standard_Integer iRank, - const BOP_Operation anOp) -{ - Standard_Boolean bFlag=Standard_False; - - if (iRank==1) { - if (anOp==BOP_FUSE || anOp==BOP_CUT) { - bFlag=Standard_True; - } - } - - if (iRank==2) { - if (anOp==BOP_FUSE || anOp==BOP_CUT21) { - bFlag=Standard_True; - } - } - return bFlag; -} -//======================================================================= -// function: ToReverseFace -// purpose: -//======================================================================= - Standard_Boolean BOP_BuilderTools::ToReverseFace(const Standard_Integer iRank, - const BOP_Operation anOp) -{ - Standard_Boolean bFlag=Standard_False; - - if (iRank==1) { - if (anOp==BOP_CUT21) { - bFlag=Standard_True; - } - } - - if (iRank==2) { - if (anOp==BOP_CUT) { - bFlag=Standard_True; - } - } - return bFlag; -} - -//======================================================================= -// function: OrientSectionEdgeOnF1 -// purpose: -//======================================================================= - void BOP_BuilderTools::OrientSectionEdgeOnF1(const TopoDS_Face& aF1, - const TopoDS_Face& aF2, - const Standard_Integer iRankF1, - const BOP_Operation anOperation, - TopoDS_Edge& aE) -{ - TopAbs_Orientation anOr; - Standard_Boolean bToReverseSection; - - anOr=BOPTools_Tools3D::EdgeOrientation(aE, aF1, aF2); - aE.Orientation(anOr); - bToReverseSection=BOP_BuilderTools::ToReverseSection(iRankF1, anOperation); - if (bToReverseSection) { - aE.Reverse(); - } -} - -//======================================================================= -// function: IsSameDomainFaceWithF1 -// purpose: -//======================================================================= - Standard_Boolean - BOP_BuilderTools::IsSameDomainFaceWithF1(const Standard_Integer nF1, - const Standard_Integer nF2, - const TColStd_IndexedMapOfInteger& aFFIndicesMap, - BOPTools_CArray1OfSSInterference& aFFs) -{ - Standard_Boolean bIsSDF, bYes; - Standard_Integer j, aNbj, iFFx, nFx; - - bYes=Standard_False; - aNbj=aFFIndicesMap.Extent(); - - for (j=1; j<=aNbj; j++) { - iFFx=aFFIndicesMap(j); - BOPTools_SSInterference& aFFx=aFFs(iFFx); - bIsSDF=aFFx.IsTangentFaces(); - if (bIsSDF) { - nFx=aFFx.OppositeIndex(nF1); - if (nFx==nF2) { - return !bYes; - } - } - } - return bYes; -} - -//======================================================================= -// function: IsPartIN2DToKeep -// purpose: -//======================================================================= - Standard_Boolean - BOP_BuilderTools::IsPartIN2DToKeep(const TopAbs_State aST1, - const Standard_Integer iRankF1, - const BOP_Operation anOp) -{ - - - Standard_Boolean bRetFlag= (aST1==TopAbs_OUT); - // - // Same oriented - if (bRetFlag) { - if (anOp==BOP_CUT && iRankF1==2) { - return !bRetFlag; - } - - if (anOp==BOP_CUT21 && iRankF1==1) { - return !bRetFlag; - } - - if (anOp==BOP_COMMON && iRankF1==2) { - return !bRetFlag; - } - - if (anOp==BOP_COMMON && iRankF1==1) { - return !bRetFlag; - } - - return bRetFlag; - } - // - // Different oriented - else if (!bRetFlag) { - if (anOp==BOP_FUSE) { - return bRetFlag; - } - - if (anOp==BOP_CUT && iRankF1==1) { - return bRetFlag; - } - - if (anOp==BOP_CUT21 && iRankF1==2) { - return bRetFlag; - } - return !bRetFlag; - } - return !bRetFlag; -} -//======================================================================= -// function: IsPartOn2dToKeep -// purpose: -//======================================================================= - Standard_Boolean - BOP_BuilderTools::IsPartOn2dToKeep(const TopAbs_State aST1, - const Standard_Integer iRankF1, - const BOP_Operation anOp) -{ - Standard_Boolean bRetFlag=Standard_False; - // - // 1 OUT - if (aST1==TopAbs_OUT) { - if (anOp==BOP_FUSE) { - bRetFlag=Standard_True; - } - if (iRankF1==1) { - if (anOp==BOP_CUT) { - bRetFlag=Standard_True; - } - } - if (iRankF1==2) { - if (anOp==BOP_CUT21) { - bRetFlag=Standard_True; - } - } - } - // - // 2 IN - if (aST1==TopAbs_IN) { - if (anOp==BOP_COMMON) { - bRetFlag=Standard_True; - } - if (iRankF1==2) { - if (anOp==BOP_CUT) { - bRetFlag=Standard_True; - } - } - if (iRankF1==1) { - if (anOp==BOP_CUT21) { - bRetFlag=Standard_True; - } - } - } - return bRetFlag; -} - -//======================================================================= -// function: DoMap -// purpose: -//======================================================================= - void BOP_BuilderTools::DoMap - (BOPTools_CArray1OfSSInterference& aFFs, - BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aFFMap) -{ - Standard_Integer i, aNb, nF1, nF2; - // - // Intersection Map for Faces - - aFFMap.Clear(); - TColStd_IndexedMapOfInteger aFFIndices; - - aNb=aFFs.Extent(); - for (i=1; i<=aNb; i++) { - BOPTools_SSInterference& aFF=aFFs(i); - // Faces - nF1=aFF.Index1(); - nF2=aFF.Index2(); - // nF1 - if (!aFFMap.Contains(nF1)) { - aFFIndices.Clear(); - aFFIndices.Add(i); - aFFMap.Add(nF1, aFFIndices); - } - else { - TColStd_IndexedMapOfInteger& aMF=aFFMap.ChangeFromKey(nF1); - aMF.Add(i); - } - // nF2 - if (!aFFMap.Contains(nF2)) { - aFFIndices.Clear(); - aFFIndices.Add(i); - aFFMap.Add(nF2, aFFIndices); - } - else { - TColStd_IndexedMapOfInteger& aMF=aFFMap.ChangeFromKey(nF2); - aMF.Add(i); - } - } -} - -//======================================================================= -// -static - void Pathx(const TopoDS_Shape& aVx, - const TopoDS_Shape& aEx, - const TopAbs_ShapeEnum aType2, - const TopTools_IndexedDataMapOfShapeListOfShape& aVEMap, - TopTools_IndexedMapOfOrientedShape& aProcessedEdges, - TopTools_IndexedMapOfOrientedShape& aCBMap); - -//======================================================================= -// function: MakeConnexityBlocks -// purpose: -//======================================================================= - void BOP_BuilderTools::MakeConnexityBlocks(const TopTools_ListOfShape& aLEIn, - const TopAbs_ShapeEnum aType, - BOP_ListOfConnexityBlock& aLConBlks) -{ - Standard_Integer i, aNbV, aNbE; - TopTools_IndexedDataMapOfShapeListOfShape aVEMap; - TopTools_IndexedMapOfOrientedShape aProcessedEdges, aCBMap; - TopAbs_ShapeEnum aType2; - // - if (aType==TopAbs_EDGE) { - aType2=TopAbs_VERTEX; - } - else if (aType==TopAbs_FACE) { - aType2=TopAbs_EDGE; - } - else { - return; - } - // - TopTools_ListIteratorOfListOfShape anIt(aLEIn); - // - for (; anIt.More(); anIt.Next()) { - const TopoDS_Shape& aE=anIt.Value(); - TopExp::MapShapesAndAncestors(aE, aType2, aType, aVEMap); - } - // - aNbV=aVEMap.Extent(); - for (i=1; i<=aNbV; i++) { - aCBMap.Clear(); - - const TopoDS_Shape& aV=aVEMap.FindKey(i); - - const TopTools_ListOfShape& aLE=aVEMap(i); - anIt.Initialize(aLE); - for (; anIt.More(); anIt.Next()) { - const TopoDS_Shape& aE=anIt.Value(); - if (!aProcessedEdges.Contains(aE)) { - aProcessedEdges.Add(aE); - aCBMap.Add(aE); - Pathx (aV, aE, aType2, aVEMap, aProcessedEdges, aCBMap); - } - } - aNbE=aCBMap.Extent(); - if (aNbE) { - BOP_ConnexityBlock aConnexityBlock; - aConnexityBlock.SetShapes(aCBMap); - aLConBlks.Append(aConnexityBlock); - } - } -} - -//======================================================================= -// function: Pathx -// purpose: -//======================================================================= -void Pathx(const TopoDS_Shape& aVx, - const TopoDS_Shape& aEx, - const TopAbs_ShapeEnum aType2, - const TopTools_IndexedDataMapOfShapeListOfShape& aVEMap, - TopTools_IndexedMapOfOrientedShape& aProcessedEdges, - TopTools_IndexedMapOfOrientedShape& aCBMap) -{ - TopExp_Explorer anExp(aEx, aType2); - for (; anExp.More(); anExp.Next()){ - const TopoDS_Shape& aV=anExp.Current(); - - if (aV.IsSame(aVx)){ - continue; - } - - const TopTools_ListOfShape& aLE=aVEMap.FindFromKey(aV); - TopTools_ListIteratorOfListOfShape anIt(aLE); - for (; anIt.More(); anIt.Next()) { - const TopoDS_Shape& aE=anIt.Value(); - if (!aProcessedEdges.Contains(aE)) { - aProcessedEdges.Add(aE); - aCBMap.Add(aE); - - Pathx (aV, aE, aType2, aVEMap, aProcessedEdges, aCBMap); - } - } - } -} - - diff --git a/src/BOP/BOP_CheckResult.cdl b/src/BOP/BOP_CheckResult.cdl deleted file mode 100755 index eb37314618..0000000000 --- a/src/BOP/BOP_CheckResult.cdl +++ /dev/null @@ -1,84 +0,0 @@ --- Created on: 2004-09-03 --- Created by: Oleg FEDYAEV --- Copyright (c) 2004-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class CheckResult from BOP - ---Purpose: contains information about faulty shapes and faulty types - --- can't be processed by Boolean Operations - -uses - - Shape from TopoDS, - ListOfShape from TopTools, - CheckStatus from BOP - -is - - Create - returns CheckResult; - ---Purpose: empty constructor - - SetShape1(me: in out; TheShape : Shape from TopoDS); - ---Purpose: sets ancestor shape (object) for faulty sub-shapes - - AddFaultyShape1(me: in out; TheShape: Shape from TopoDS); - ---Purpose: adds faulty sub-shapes from object to a list - - SetShape2(me: in out; TheShape: Shape from TopoDS); - ---Purpose: sets ancestor shape (tool) for faulty sub-shapes - - AddFaultyShape2(me: in out; TheShape: Shape from TopoDS); - ---Purpose: adds faulty sub-shapes from tool to a list - - GetShape1(me) - returns Shape from TopoDS; - ---C++: return const & - ---Purpose: returns ancestor shape (object) for faulties - - GetShape2(me) - returns Shape from TopoDS; - ---C++: return const & - ---Purpose: returns ancestor shape (tool) for faulties - - GetFaultyShapes1(me) - returns ListOfShape from TopTools; - ---C++: return const & - ---Purpose: returns list of faulty shapes for object - - GetFaultyShapes2(me) - returns ListOfShape from TopTools; - ---C++: return const & - ---Purpose: returns list of faulty shapes for tool - - SetCheckStatus(me: in out; TheStatus: CheckStatus from BOP); - ---Purpose: set status of faulty - - GetCheckStatus(me) - returns CheckStatus from BOP; - ---Purpose: gets status of faulty - -fields - - myShape1 : Shape from TopoDS; - myShape2 : Shape from TopoDS; - myStatus : CheckStatus from BOP; - myFaulty1 : ListOfShape from TopTools; - myFaulty2 : ListOfShape from TopTools; - -end CheckResult; diff --git a/src/BOP/BOP_CheckResult.cxx b/src/BOP/BOP_CheckResult.cxx deleted file mode 100755 index 4807aac328..0000000000 --- a/src/BOP/BOP_CheckResult.cxx +++ /dev/null @@ -1,79 +0,0 @@ -// Created on: 2004-09-02 -// Created by: Oleg FEDYAEV -// Copyright (c) 2004-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#include - -//======================================================================= -// function: BOP_CheckResult() -// purpose: -//======================================================================= -BOP_CheckResult::BOP_CheckResult() : myStatus(BOP_CheckUnknown) -{ -} - -void BOP_CheckResult::SetShape1(const TopoDS_Shape& TheShape) -{ - myShape1 = TheShape; -} - -void BOP_CheckResult::AddFaultyShape1(const TopoDS_Shape& TheShape) -{ - myFaulty1.Append(TheShape); -} - -void BOP_CheckResult::SetShape2(const TopoDS_Shape& TheShape) -{ - myShape2 = TheShape; -} - -void BOP_CheckResult::AddFaultyShape2(const TopoDS_Shape& TheShape) -{ - myFaulty2.Append(TheShape); -} - -const TopoDS_Shape& BOP_CheckResult::GetShape1() const -{ - return myShape1; -} - -const TopoDS_Shape & BOP_CheckResult::GetShape2() const -{ - return myShape2; -} - -const TopTools_ListOfShape& BOP_CheckResult::GetFaultyShapes1() const -{ - return myFaulty1; -} - -const TopTools_ListOfShape& BOP_CheckResult::GetFaultyShapes2() const -{ - return myFaulty2; -} - -void BOP_CheckResult::SetCheckStatus(const BOP_CheckStatus TheStatus) -{ - myStatus = TheStatus; -} - -BOP_CheckStatus BOP_CheckResult::GetCheckStatus() const -{ - return myStatus; -} diff --git a/src/BOP/BOP_CompositeClassifier.cdl b/src/BOP/BOP_CompositeClassifier.cdl deleted file mode 100755 index 83c12042c5..0000000000 --- a/src/BOP/BOP_CompositeClassifier.cdl +++ /dev/null @@ -1,103 +0,0 @@ --- Created on: 1996-01-05 --- Created by: Jean Yves LEBEY --- Copyright (c) 1996-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -deferred class CompositeClassifier from BOP inherits LoopClassifier from BOP - - ---Purpose: - -- The Root class for algorithms - -- to classify composite Loops, i.e, Loops that - -- can be either a Shape, or a block of Elements. - -- - -uses - - ShapeEnum from TopAbs, - Shape from TopoDS, - State from TopAbs, - - Loop from BOP, - BlockBuilder from BOP - -is - - Initialize(BB : BlockBuilder from BOP); - ---Purpose: - --- Initializing the object with BlockBuilder; - --- - Compare(me :out; - L1 : Loop from BOP; - L2 : Loop from BOP) - returns State from TopAbs - is redefined; - ---Purpose: - --- Classify loop with - --- - CompareShapes(me :out; - B1 : Shape from TopoDS; - B2 : Shape from TopoDS) - ---Purpose: - --- Classify shape with shape - --- - returns State from TopAbs - is deferred; - - CompareElementToShape(me :out; - E : Shape from TopoDS; - B : Shape from TopoDS) - returns State from TopAbs - is deferred; - ---Purpose: - --- Classify element with shape - --- - ResetShape(me :out; - B : Shape from TopoDS) - is deferred; - ---Purpose: - --- Prepare classification involving shape - --- Calls ResetElement on first element of - --- - - ResetElement(me :out; - E : Shape from TopoDS) - is deferred; - ---Purpose: - --- Prepare classification involving element . - --- - CompareElement(me :out; - E : Shape from TopoDS) - is deferred; - ---Purpose: - --- Add element in the set of elements used in classification. - --- - State(me :out) - returns State from TopAbs - is deferred; - ---Purpose: - --- Returns state of classification of 2D point, defined by - --- ResetElement, with the current set of elements, - --- defined by Compare. - --- -fields - - myBlockBuilder : Address - is protected; - -end CompositeClassifier; diff --git a/src/BOP/BOP_CompositeClassifier.cxx b/src/BOP/BOP_CompositeClassifier.cxx deleted file mode 100755 index dd394ee519..0000000000 --- a/src/BOP/BOP_CompositeClassifier.cxx +++ /dev/null @@ -1,111 +0,0 @@ -// Created on: 1996-01-05 -// Created by: Jean Yves LEBEY -// Copyright (c) 1996-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#include - -//======================================================================= -//function : BOP_CompositeClassifier::BOP_CompositeClassifier -//purpose : -//======================================================================= -BOP_CompositeClassifier::BOP_CompositeClassifier (const BOP_BlockBuilder& BB) - : - myBlockBuilder((void*)&BB) -{} -//======================================================================= -//function : Compare -//purpose : -//======================================================================= - TopAbs_State BOP_CompositeClassifier::Compare(const Handle(BOP_Loop)& L1, - const Handle(BOP_Loop)& L2) -{ - TopAbs_State state = TopAbs_UNKNOWN; - - Standard_Boolean isshape1, isshape2, yena1 ; - - isshape1 = L1->IsShape(); - isshape2 = L2->IsShape(); - - if ( isshape2 && isshape1 ) { - // L1 is Shape , L2 is Shape - const TopoDS_Shape& s1 = L1->Shape(); - const TopoDS_Shape& s2 = L2->Shape(); - state = CompareShapes(s1,s2); - } - - else if ( isshape2 && !isshape1 ) { - // L1 is Block , L2 is Shape - BOP_BlockIterator Bit1 = L1->BlockIterator(); - Bit1.Initialize(); - yena1 = Bit1.More(); - while (yena1) { - const TopoDS_Shape& s1 = - ((BOP_BlockBuilder*)myBlockBuilder)->Element(Bit1); - const TopoDS_Shape& s2 = L2->Shape(); - - state = CompareElementToShape(s1,s2); - yena1 = Standard_False; - if (state == TopAbs_UNKNOWN) { - if (Bit1.More()) Bit1.Next(); - yena1 = Bit1.More(); - } - } - } - else if ( !isshape2 && isshape1 ) { - // L1 is Shape , L2 is Block - const TopoDS_Shape& s1 = L1->Shape(); - - ResetShape(s1); - BOP_BlockIterator Bit2 = L2->BlockIterator(); - for (Bit2.Initialize(); Bit2.More(); Bit2.Next()) { - const TopoDS_Shape& s2 = - ((BOP_BlockBuilder*)myBlockBuilder)->Element(Bit2); - CompareElement(s2); - } - state = State(); - } - - else if ( !isshape2 && !isshape1 ) { - // L1 is Block , L2 is Block - BOP_BlockIterator Bit1 = L1->BlockIterator(); - Bit1.Initialize(); - yena1 = Bit1.More(); - while (yena1) { - const TopoDS_Shape& s1 = - ((BOP_BlockBuilder*)myBlockBuilder)->Element(Bit1); - - ResetElement(s1); - BOP_BlockIterator Bit2 = L2->BlockIterator(); - for (Bit2.Initialize(); Bit2.More(); Bit2.Next()) { - const TopoDS_Shape& s2 = - ((BOP_BlockBuilder*)myBlockBuilder)->Element(Bit2); - CompareElement(s2); - } - - state = State(); - yena1 = Standard_False; - if (state == TopAbs_UNKNOWN) { - if (Bit1.More()) Bit1.Next(); - yena1 = Bit1.More(); - } - } - } - return state; -} diff --git a/src/BOP/BOP_ConnexityBlock.cdl b/src/BOP/BOP_ConnexityBlock.cdl deleted file mode 100755 index 2f7f246f5e..0000000000 --- a/src/BOP/BOP_ConnexityBlock.cdl +++ /dev/null @@ -1,73 +0,0 @@ --- Created on: 2001-04-13 --- Created by: Peter KURNEV --- Copyright (c) 2001-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class ConnexityBlock from BOP - - ---Purpose: - --- Auxiliary class to store data about set - --- of connex shapes - --- - -uses - ListOfShape from TopTools, - IndexedMapOfOrientedShape from TopTools - -is - Create - returns ConnexityBlock from BOP; - ---Purpose: - --- Empty constructor; - --- - SetShapes (me:out; - anEdges: ListOfShape from TopTools); - ---Purpose: - --- Modifier - --- - SetShapes (me:out; - nEdges: IndexedMapOfOrientedShape from TopTools); - ---Purpose: - --- Modifier - --- - SetRegularity(me:out; - aFlag:Boolean from Standard); - ---Purpose: - --- Modifier - --- - Shapes (me) - returns ListOfShape from TopTools; - ---C++: return const & - ---Purpose: - --- Selector - --- - IsRegular(me) - returns Boolean from Standard; - ---Purpose: - --- Selector - --- Returns TRUE if all elements in the block are - --- biconnexity - --- - -fields - - myRegularity : Boolean from Standard; - myShapes : ListOfShape from TopTools; - -end ConnexityBlock; diff --git a/src/BOP/BOP_ConnexityBlock.cxx b/src/BOP/BOP_ConnexityBlock.cxx deleted file mode 100755 index 007824dcfd..0000000000 --- a/src/BOP/BOP_ConnexityBlock.cxx +++ /dev/null @@ -1,89 +0,0 @@ -// Created on: 2001-04-13 -// Created by: Peter KURNEV -// Copyright (c) 2001-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include - -#include - -#include - -//======================================================================= -// function: BOP_ConnexityBlock::BOP_ConnexityBlock -// purpose: -//======================================================================= -BOP_ConnexityBlock::BOP_ConnexityBlock() -: - myRegularity(Standard_False) -{} -//======================================================================= -// function: SetRegularity -// purpose: -//======================================================================= - void BOP_ConnexityBlock::SetRegularity (const Standard_Boolean aFlag) -{ - myRegularity=aFlag; -} -//======================================================================= -// function: IsRegular -// purpose: -//======================================================================= - Standard_Boolean BOP_ConnexityBlock::IsRegular ()const -{ - return myRegularity; -} -//======================================================================= -// function: SetShapes -// purpose: -//======================================================================= - void BOP_ConnexityBlock::SetShapes(const TopTools_ListOfShape& anEdges) -{ - myShapes.Clear(); - TopTools_ListIteratorOfListOfShape anIt(anEdges); - for (; anIt.More(); anIt.Next()) { - const TopoDS_Shape& anE=anIt.Value(); - myShapes.Append(anE); - } -} - -//======================================================================= -// function: SetShapes -// purpose: -//======================================================================= - void BOP_ConnexityBlock::SetShapes(const TopTools_IndexedMapOfOrientedShape& anEdges) -{ - myShapes.Clear(); - Standard_Integer i, aNb; - - aNb=anEdges.Extent(); - for (i=1; i<=aNb; i++) { - const TopoDS_Shape& anE=anEdges(i); - myShapes.Append(anE); - } -} - -//======================================================================= -// function: Shapes -// purpose: -//======================================================================= - const TopTools_ListOfShape& BOP_ConnexityBlock::Shapes()const -{ - return myShapes; -} diff --git a/src/BOP/BOP_CorrectTolerances.cdl b/src/BOP/BOP_CorrectTolerances.cdl deleted file mode 100755 index b7bd0bef02..0000000000 --- a/src/BOP/BOP_CorrectTolerances.cdl +++ /dev/null @@ -1,58 +0,0 @@ --- Created on: 2001-04-17 --- Created by: Peter KURNEV --- Copyright (c) 2001-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class CorrectTolerances from BOP - - ---Purpose: - --- The Set of static functions to provide valid values of - --- tolerances for shapes. - --- Tolerances becomes valid in terms of the checkshape. - -uses - Shape from TopoDS - -is - CorrectTolerances (myclass; - aS: Shape from TopoDS; - aTolMax: 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; - aS: Shape from TopoDS; - aTolMax: Real from Standard =0.0001); - ---Purpose: - --- Provides valid values of tolerances for the shape - --- in terms of BRepCheck_InvalidCurveOnSurface. - --- - CorrectPointOnCurve (myclass; - aS: Shape from TopoDS; - aTolMax: Real from Standard =0.0001); - ---Purpose: - --- Provides valid values of tolerances for the shape - --- in terms of BRepCheck_InvalidPointOnCurve. - --- - -end CorrectTolerances; diff --git a/src/BOP/BOP_CorrectTolerances.cxx b/src/BOP/BOP_CorrectTolerances.cxx deleted file mode 100755 index 0c23a53b28..0000000000 --- a/src/BOP/BOP_CorrectTolerances.cxx +++ /dev/null @@ -1,593 +0,0 @@ -// Created on: 2001-04-17 -// Created by: Peter KURNEV -// Copyright (c) 2001-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include - -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include -#include -#include -#include - -#include -#include - -#include - -#include -#include -#include - - - -static - void CheckEdge (const TopoDS_Edge& E, - const Standard_Real aMaxTol); -static - void CorrectEdgeTolerance (const TopoDS_Edge& myShape, - const TopoDS_Face& S, - const Standard_Real aMaxTol); -static - Standard_Boolean Validate(const Adaptor3d_Curve& CRef, - const Adaptor3d_Curve& Other, - const Standard_Real Tol, - const Standard_Boolean SameParameter, - Standard_Real& aNewTolerance); - -// -static - void CorrectVertexTolerance(const TopoDS_Edge& aE); -// - -//======================================================================= -// Function : CorrectTolerances -// purpose : -//======================================================================= - void BOP_CorrectTolerances::CorrectTolerances(const TopoDS_Shape& aShape, - const Standard_Real aMaxTol) -{ - BOP_CorrectTolerances::CorrectPointOnCurve(aShape, aMaxTol); - BOP_CorrectTolerances::CorrectCurveOnSurface(aShape, aMaxTol); -} - -//======================================================================= -// Function : CorrectPointOnCurve -// purpose : -//======================================================================= - void BOP_CorrectTolerances::CorrectPointOnCurve(const TopoDS_Shape& S, - const Standard_Real aMaxTol) -{ - Standard_Integer i, aNb; - TopTools_IndexedMapOfShape Edges; - TopExp::MapShapes (S, TopAbs_EDGE, Edges); - aNb=Edges.Extent(); - for (i=1; i<=aNb; i++) { - const TopoDS_Edge& E= TopoDS::Edge(Edges(i)); - CheckEdge(E, aMaxTol); - } -} - -//======================================================================= -// Function : CorrectCurveOnSurface -// purpose : -//======================================================================= - void BOP_CorrectTolerances::CorrectCurveOnSurface(const TopoDS_Shape& S, - const Standard_Real aMaxTol) -{ - Standard_Integer i, aNbFaces, j, aNbEdges; - TopTools_IndexedMapOfShape Faces; - TopExp::MapShapes (S, TopAbs_FACE, Faces); - - aNbFaces=Faces.Extent(); - for (i=1; i<=aNbFaces; i++) { - const TopoDS_Face& F= TopoDS::Face(Faces(i)); - 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); - } - } -} - -//======================================================================= -// Function : CorrectEdgeTolerance -// purpose : Correct tolerances for Edge -//======================================================================= -void CorrectEdgeTolerance (const TopoDS_Edge& myShape, - const TopoDS_Face& S, - const Standard_Real aMaxTol) -{ - // - // 1. Minimum of conditions to Perform - Handle (BRep_CurveRepresentation) myCref; - Handle (Adaptor3d_HCurve) myHCurve; - - myCref.Nullify(); - - Handle(BRep_TEdge)& TEx = *((Handle(BRep_TEdge)*)&myShape.TShape()); - BRep_ListIteratorOfListOfCurveRepresentation itcrx(TEx->Curves()); - Standard_Boolean Degenerated, SameParameterx, SameRangex; - - Standard_Integer unique = 0; - - Degenerated = TEx->Degenerated(); - SameParameterx = TEx->SameParameter(); - SameRangex = TEx->SameRange(); - - if (!SameRangex && SameParameterx) { - return; - } - - Handle(Geom_Curve) C3d; - while (itcrx.More()) { - const Handle(BRep_CurveRepresentation)& cr = itcrx.Value(); - if (cr->IsCurve3D()) { - unique++; - if (myCref.IsNull() && !cr->Curve3D().IsNull()) { - myCref = cr; - } - } - itcrx.Next(); - } - - if (unique==0) { - return;//...No3DCurve - } - if (unique>1) { - return;//...Multiple3DCurve; - } - - if (myCref.IsNull() && !Degenerated) { - itcrx.Initialize(TEx->Curves()); - while (itcrx.More()) { - const Handle(BRep_CurveRepresentation)& cr = itcrx.Value(); - if (cr->IsCurveOnSurface()) { - myCref = cr; - break; - } - itcrx.Next(); - } - } - - else if (!myCref.IsNull() && Degenerated){ - return ;//...InvalidDegeneratedFlag; - } - - if (!myCref.IsNull()) { - const Handle(BRep_GCurve)& GCref = *((Handle(BRep_GCurve)*)&myCref); - Standard_Real First,Last; - GCref->Range(First,Last); - if (Last<=First) { - myCref.Nullify(); - return ;//InvalidRange; - } - - else { - if (myCref->IsCurve3D()) { - Handle(Geom_Curve) C3dx = Handle(Geom_Curve)::DownCast - (myCref->Curve3D()->Transformed (myCref->Location().Transformation())); - GeomAdaptor_Curve GAC3d(C3dx, First, Last); - myHCurve = new GeomAdaptor_HCurve(GAC3d); - } - else { // curve on surface - Handle(Geom_Surface) Sref = myCref->Surface(); - Sref = Handle(Geom_Surface)::DownCast(Sref->Transformed(myCref->Location().Transformation())); - const Handle(Geom2d_Curve)& PCref = myCref->PCurve(); - Handle(GeomAdaptor_HSurface) GAHSref = new GeomAdaptor_HSurface(Sref); - Handle(Geom2dAdaptor_HCurve) GHPCref = new Geom2dAdaptor_HCurve(PCref, First, Last); - Adaptor3d_CurveOnSurface ACSref(GHPCref,GAHSref); - myHCurve = new Adaptor3d_HCurveOnSurface(ACSref); - } - } - } - - //=============================================== - // 2. Tolerances in InContext - { - if (myCref.IsNull()) - return; - Standard_Boolean ok=Standard_True;; - - Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*)&myShape.TShape()); - Standard_Real Tol = BRep_Tool::Tolerance(TopoDS::Edge(myShape)); - Standard_Real aNewTol=Tol; - - Standard_Boolean SameParameter = TE->SameParameter(); - Standard_Boolean SameRange = TE->SameRange(); - Standard_Real First = myHCurve->FirstParameter(); - Standard_Real Last = myHCurve->LastParameter(); - Standard_Real Delta =1.e-14; - - Handle(BRep_TFace)& TF = *((Handle(BRep_TFace)*) &S.TShape()); - const TopLoc_Location& Floc = S.Location(); - const TopLoc_Location& TFloc = TF->Location(); - const Handle(Geom_Surface)& Su = TF->Surface(); - TopLoc_Location L = (Floc * TFloc).Predivided(myShape.Location()); - // Standard_Boolean checkclosed = Standard_False; - Standard_Boolean pcurvefound = Standard_False; - - BRep_ListIteratorOfListOfCurveRepresentation itcr(TE->Curves()); - while (itcr.More()) { - const Handle(BRep_CurveRepresentation)& cr = itcr.Value(); - if (cr != myCref && cr->IsCurveOnSurface(Su,L)) { - pcurvefound = Standard_True; - const Handle(BRep_GCurve)& GC = *((Handle(BRep_GCurve)*)&cr); - Standard_Real f,l; - GC->Range(f,l); - if (SameRange && (f != First || l != Last)) { - return ;//BRepCheck_InvalidSameRangeFlag); - if (SameParameter) { - return; //BRepCheck_InvalidSameParameterFlag); - } - } - - Handle(Geom_Surface) Sb = cr->Surface(); - Sb = Handle(Geom_Surface)::DownCast (Su->Transformed(L.Transformation())); - Handle(Geom2d_Curve) PC = cr->PCurve(); - Handle(GeomAdaptor_HSurface) GAHS = new GeomAdaptor_HSurface(Sb); - Handle(Geom2dAdaptor_HCurve) GHPC = new Geom2dAdaptor_HCurve(PC,f,l); - Adaptor3d_CurveOnSurface ACS(GHPC,GAHS); - ok = Validate(myHCurve->Curve(), ACS, Tol, SameParameter, aNewTol); - if (ok) { - if (cr->IsCurveOnClosedSurface()) { - //return ;// BRepCheck::Add(lst,BRepCheck_InvalidCurveOnClosedSurface); - } - else { - //return;//BRepCheck::Add(lst,BRepCheck_InvalidCurveOnSurface); - } - if (SameParameter) { - //return;//BRepCheck::Add(lst,BRepCheck_InvalidSameParameterFlag); - } - // - if (aNewTolUpdateTolerance(aNewTol+Delta); - // - CorrectVertexTolerance(myShape); - } - } - - if (cr->IsCurveOnClosedSurface()) { - // checkclosed = Standard_True; - GHPC->ChangeCurve2d().Load(cr->PCurve2(),f,l); // same bounds - ACS.Load(GAHS); // sans doute inutile - ACS.Load(GHPC); // meme remarque... - ok = Validate(myHCurve->Curve(),ACS,Tol,SameParameter, aNewTol); - if (ok) { - //return;//BRepCheck::Add(lst,BRepCheck_InvalidCurveOnClosedSurface); - if (SameParameter) { - //return;//BRepCheck::Add(lst,BRepCheck_InvalidSameParameterFlag); - } - if (aNewTolUpdateTolerance(aNewTol+Delta); - CorrectVertexTolerance(myShape); - } - } - } - } - itcr.Next(); - } - - if (!pcurvefound) { - Handle(Geom_Plane) P; - Handle(Standard_Type) styp = Su->DynamicType(); - if (styp == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) { - P = Handle(Geom_Plane)::DownCast(Handle(Geom_RectangularTrimmedSurface):: - DownCast(Su)->BasisSurface()); - } - else { - P = Handle(Geom_Plane)::DownCast(Su); - } - if (P.IsNull()) { // not a plane - return;//BRepCheck::Add(lst,BRepCheck_NoCurveOnSurface); - } - - else {// on fait la projection a la volee, comme BRep_Tool - P = Handle(Geom_Plane)::DownCast(P->Transformed(L.Transformation())); - //on projette Cref sur ce plan - Handle(GeomAdaptor_HSurface) GAHS = new GeomAdaptor_HSurface(P); - - // Dub - Normalement myHCurve est une GeomAdaptor_HCurve - GeomAdaptor_Curve& Gac = Handle(GeomAdaptor_HCurve)::DownCast(myHCurve)->ChangeCurve(); - Handle(Geom_Curve) C3dx = Gac.Curve(); - Handle(Geom_Curve) ProjOnPlane = GeomProjLib::ProjectOnPlane - (new Geom_TrimmedCurve(C3dx,First,Last), P, P->Position().Direction(), Standard_True); - - Handle(GeomAdaptor_HCurve) aHCurve = new GeomAdaptor_HCurve(ProjOnPlane); - - ProjLib_ProjectedCurve proj(GAHS,aHCurve); - Handle(Geom2d_Curve) PC = Geom2dAdaptor::MakeCurve(proj); - Handle(Geom2dAdaptor_HCurve) GHPC = - new Geom2dAdaptor_HCurve(PC, myHCurve->FirstParameter(), myHCurve->LastParameter()); - - Adaptor3d_CurveOnSurface ACS(GHPC,GAHS); - - Standard_Boolean okx = Validate(myHCurve->Curve(),ACS, - Tol,Standard_True, aNewTol); // voir dub... - if (okx) { - //return;//BRepCheck::Add(lst,BRepCheck_InvalidCurveOnSurface); - if (aNewTolUpdateTolerance(aNewTol+Delta); - CorrectVertexTolerance(myShape); - } - } - } - - }//end of if (!pcurvefound) { - } // end of 2. Tolerances in InContext - -} - -//======================================================================= -//function : CorrectVertexTolerance -//purpose : -//======================================================================= -void CorrectVertexTolerance(const TopoDS_Edge& aE) -{ - Standard_Integer k, aNbV; - Standard_Real aTolE, aTolV; - TopTools_IndexedMapOfShape aVMap; - - aTolE=BRep_Tool::Tolerance(aE); - - TopExp::MapShapes(aE, TopAbs_VERTEX, aVMap); - aNbV=aVMap.Extent(); - for (k=1; k<=aNbV; ++k) { - const TopoDS_Vertex& aV=TopoDS::Vertex(aVMap(k)); - aTolV=BRep_Tool::Tolerance(aV); - if (aTolVUpdateTolerance(aTolE); - } - } -} - - - -#define NCONTROL 23 -//======================================================================= -//function : Validate -//purpose : -//======================================================================= -Standard_Boolean Validate(const Adaptor3d_Curve& CRef, - const Adaptor3d_Curve& Other, - const Standard_Real Tol, - const Standard_Boolean SameParameter, - Standard_Real& aNewTolerance) -{ - Standard_Real First, Last, MaxDistance, aD, Tol2; - - First = CRef.FirstParameter(); - Last = CRef.LastParameter(); - MaxDistance = 0.; - Tol2 = Tol*Tol; - - Standard_Integer i, aNC1=NCONTROL-1; - - Standard_Boolean aFlag=Standard_False; - Standard_Boolean proj = (!SameParameter || - First != Other.FirstParameter() || - Last != Other.LastParameter()); - // - // 1. - if (!proj) { - for (i = 0; i < NCONTROL; i++) { - Standard_Real prm = ((aNC1-i)*First + i*Last)/aNC1; - gp_Pnt pref = CRef.Value(prm); - gp_Pnt pother = Other.Value(prm); - - aD=pref.SquareDistance(pother); - - if (aD > Tol2) { - if (aD>MaxDistance) { - MaxDistance=aD; - } - aFlag=Standard_True; - } - } - - if (aFlag) { - aNewTolerance=sqrt(MaxDistance); - } - return aFlag; - } - - // - // 2. - else { - Extrema_LocateExtPC refd,otherd; - Standard_Real OFirst, OLast; - OFirst = Other.FirstParameter(); - OLast = Other.LastParameter(); - - gp_Pnt pd = CRef.Value(First); - gp_Pnt pdo = Other.Value(OFirst); - - aD = pd.SquareDistance(pdo); - if (aD > Tol2) { - if (aD>MaxDistance) { - MaxDistance=aD; - } - aFlag=Standard_True; - } - - pd = CRef.Value(Last); - pdo = Other.Value(OLast); - aD = pd.SquareDistance(pdo); - if (aD > Tol2 && aD > MaxDistance) { - MaxDistance=aD; - aFlag=Standard_True; - } - - refd.Initialize(CRef, First, Last, CRef.Resolution(Tol)); - otherd.Initialize(Other, OFirst, OLast, Other.Resolution(Tol)); - - for (i = 2; i< aNC1; i++) { - Standard_Real rprm = ((aNC1-i)*First + i*Last)/aNC1; - gp_Pnt pref = CRef.Value(rprm); - - Standard_Real oprm = ((aNC1-i)*OFirst + i*OLast)/aNC1; - gp_Pnt pother = Other.Value(oprm); - - refd.Perform(pother,rprm); - if (!refd.IsDone() || refd.SquareDistance() > Tol2) { - if (refd.IsDone()) { - aD=refd.SquareDistance(); - if (aD > Tol2 && aD>MaxDistance) { - aFlag=Standard_True; - MaxDistance=aD; - } - } - } - - otherd.Perform(pref,oprm); - if (!otherd.IsDone() || otherd.SquareDistance() > Tol2) { - - if (otherd.IsDone()) { - aD=otherd.SquareDistance(); - if (aD > Tol2 && aD>MaxDistance) { - aFlag=Standard_True; - MaxDistance=aD; - } - } - } - } - } - - aD=sqrt (MaxDistance); - aNewTolerance=aD; - - return aFlag; - -} - -//======================================================================= -// Function : CheckEdge -// purpose : Correct tolerances for Vertices on Edge -//======================================================================= -void CheckEdge (const TopoDS_Edge& Ed, const Standard_Real aMaxTol) -{ - TopoDS_Edge E=Ed; - E.Orientation(TopAbs_FORWARD); - - gp_Pnt Controlp; - - TopExp_Explorer aVExp; - aVExp.Init(E, TopAbs_VERTEX); - for (; aVExp.More(); aVExp.Next()) { - TopoDS_Vertex aVertex= TopoDS::Vertex(aVExp.Current()); - - Handle(BRep_TVertex)& TV = *((Handle(BRep_TVertex)*) &aVertex.TShape()); - const gp_Pnt& prep = TV->Pnt(); - - Standard_Real Tol, aD2, aNewTolerance, dd; - - Tol =BRep_Tool::Tolerance(aVertex); - Tol = Max(Tol, BRep_Tool::Tolerance(E)); - dd=0.1*Tol; - Tol*=Tol; - - const TopLoc_Location& Eloc = E.Location(); - BRep_ListIteratorOfListOfPointRepresentation itpr; - - Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*)&E.TShape()); - BRep_ListIteratorOfListOfCurveRepresentation itcr(TE->Curves()); - while (itcr.More()) { - const Handle(BRep_CurveRepresentation)& cr = itcr.Value(); - const TopLoc_Location& loc = cr->Location(); - TopLoc_Location L = (Eloc * loc).Predivided(aVertex.Location()); - - if (cr->IsCurve3D()) { - const Handle(Geom_Curve)& C = cr->Curve3D(); - if (!C.IsNull()) { - itpr.Initialize(TV->Points()); - while (itpr.More()) { - const Handle(BRep_PointRepresentation)& pr = itpr.Value(); - if (pr->IsPointOnCurve(C,L)) { - Controlp = C->Value(pr->Parameter()); - Controlp.Transform(L.Transformation()); - aD2=prep.SquareDistance(Controlp); - if (aD2 > Tol) { - aNewTolerance=sqrt(aD2)+dd; - if (aNewToleranceUpdateTolerance(aNewTolerance); - } - } - itpr.Next(); - } - - TopAbs_Orientation orv = aVertex.Orientation(); - if (orv == TopAbs_FORWARD || orv == TopAbs_REVERSED) { - const Handle(BRep_GCurve)& GC = *((Handle(BRep_GCurve)*)&cr); - - if (orv==TopAbs_FORWARD) - Controlp = C->Value(GC->First()); - else - Controlp = C->Value(GC->Last()); - - Controlp.Transform(L.Transformation()); - aD2=prep.SquareDistance(Controlp); - - if (aD2 > Tol) { - aNewTolerance=sqrt(aD2)+dd; - if (aNewToleranceUpdateTolerance(aNewTolerance); - } - } - } - } - itcr.Next(); - } - } -} - diff --git a/src/BOP/BOP_Draw.cdl b/src/BOP/BOP_Draw.cdl deleted file mode 100755 index 2dbf13e7db..0000000000 --- a/src/BOP/BOP_Draw.cdl +++ /dev/null @@ -1,80 +0,0 @@ --- Created on: 2001-05-31 --- Created by: Peter KURNEV --- Copyright (c) 2001-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class Draw from BOP - - ---Purpose: - --- auxiliary class to display intermediate results - --- in Draw's winowds for the debugging purposes - --- - -uses - ListOfShape from TopTools, - Face from TopoDS, - Edge from TopoDS - -is - DrawListOfShape (myclass; - aList : ListOfShape from TopTools; - aName : CString from Standard); - ---Purpose: - --- Display in 3D-view shapes from the ListOfShape - --- aName is base name of shape. Actual name for each - --- subsequent shape will be aName+"_#", where - --- # - is ordered index of the shape in - --- - DrawListOfEdgesWithPC (myclass; - aFace : Face from TopoDS; - aList : ListOfShape from TopTools; - aName : CString from Standard); - ---Purpose: - --- Display in 2D-view the edges from the ListOfShape , - --- that have P-curves for the face - --- aName is base name of shape. Actual name for each - --- subsequent shape will be aName+"_#", where - --- # - is ordered index of the shape in - --- - DrawListOfEdgesWithPC (myclass; - aFace : Face from TopoDS; - aList : ListOfShape from TopTools; - anInd : Integer from Standard; - aName : CString from Standard); - ---Purpose: - --- Display in 2D-view the edges from the ListOfShape , - --- that have P-curves for the face - --- aName is base name of shape. Actual name for each - --- shape will be aName+"_anInd" - --- - DrawEdgeWithPC (myclass; - aFace : Face from TopoDS; - aEdge : Edge from TopoDS; - aName : CString from Standard); - ---Purpose: - --- Display in 2D-view the edge, - --- that has P-curve for the face - --- aName is the name of shape. - --- - Wait(myclass); - ---Purpose: - --- Wait for user's keystroke - --- - -end Draw; diff --git a/src/BOP/BOP_Draw.cxx b/src/BOP/BOP_Draw.cxx deleted file mode 100755 index 02579381b3..0000000000 --- a/src/BOP/BOP_Draw.cxx +++ /dev/null @@ -1,201 +0,0 @@ -// Created on: 2001-05-31 -// Created by: Peter KURNEV -// Copyright (c) 2001-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include - -#ifdef BOPDRAW - -#include - -#include - -#include - -#include - -#include -#include -#include - -#include -#include - -#include - -#include -#include -#include - - -Standard_IMPORT - Draw_Color DrawTrSurf_CurveColor(const Draw_Color col); - -Standard_IMPORT - Draw_Color DBRep_ColorOrientation (const TopAbs_Orientation Or); - -Standard_EXPORT - Draw_Interpretor theCommands; -//======================================================================= -// function: DrawListOfShape -// purpose: -//======================================================================= - void BOP_Draw::DrawListOfShape (const TopTools_ListOfShape& aListOfShape, - const Standard_CString aName) - -{ - Standard_Integer j; - TCollection_AsciiString aNm(aName); - - j=aListOfShape.Extent(); - if (!j) { - cout << " No shapes to draw" << flush; - return; - } - - TopTools_ListIteratorOfListOfShape anIt(aListOfShape); - for (j=1; anIt.More(); anIt.Next(), j++) { - const TopoDS_Shape& aEx=anIt.Value(); - - TCollection_AsciiString aN, jIndex(j); - aN=aNm+jIndex; - Standard_CString aTxt=aN.ToCString(); - cout << aTxt << " " << flush; - DBRep::Set(aTxt, aEx); - } - cout << endl << flush; -} -//======================================================================= -// function: DrawListOfEdgesWithPC -// purpose: -//======================================================================= - void BOP_Draw::DrawListOfEdgesWithPC (const TopoDS_Face& aFace, - const TopTools_ListOfShape& aListOfShape, - const Standard_Integer i, - const Standard_CString cName) - -{ - theCommands.Eval("2dclear"); - - TCollection_AsciiString aName, aIndex(i), aUndscr("_"), aNm(cName); - aName=aName+aNm; - aName=aName+aIndex; - aName=aName+aUndscr; - Standard_CString aCString=aName.ToCString(); - - DrawListOfEdgesWithPC(aFace, aListOfShape, aCString); -} - -//======================================================================= -// function: DrawListOfEdgesWithPC -// purpose: -//======================================================================= - void BOP_Draw::DrawListOfEdgesWithPC (const TopoDS_Face& aFace, - const TopTools_ListOfShape& aListOfShape, - const Standard_CString aName) - -{ - theCommands.Eval("2dclear"); - - Standard_Integer j; - TCollection_AsciiString aNm(aName); - - j=aListOfShape.Extent(); - if (!j) { - cout << " No shapes to draw" << flush; - return; - } - - TopTools_ListIteratorOfListOfShape anIt(aListOfShape); - for (j=1; anIt.More(); anIt.Next(), j++) { - const TopoDS_Edge& aEx=TopoDS::Edge(anIt.Value()); - - TCollection_AsciiString aN, jIndex(j); - aN=aNm+jIndex; - Standard_CString aTxt=aN.ToCString(); - BOP_Draw::DrawEdgeWithPC(aFace, aEx, aTxt); - cout << " " << aTxt << flush; - } - - theCommands.Eval("2dfit"); -} - -//======================================================================= -// function: DrawEdgeWithPC -// purpose: -//======================================================================= - void BOP_Draw::DrawEdgeWithPC (const TopoDS_Face& aFace, - const TopoDS_Edge& aEdge, - const Standard_CString aName) - -{ - Standard_Real f,l; - - // Edge 3D - DBRep::Set(aName, aEdge); - // PC - Draw_Color col, savecol; - savecol = DrawTrSurf_CurveColor(Draw_rouge); - - const Handle(Geom2d_Curve) c = - BRep_Tool::CurveOnSurface (aEdge, aFace, f, l); - - col = DBRep_ColorOrientation(aEdge.Orientation()); - DrawTrSurf_CurveColor(col); - - TCollection_AsciiString aNm(aName), aAdd("_p"); - aNm=aNm+aAdd; - Standard_CString aTxtPC=aNm.ToCString(); - - DrawTrSurf::Set(aTxtPC, new Geom2d_TrimmedCurve(c, f, l)); - - DrawTrSurf_CurveColor(savecol); -} - -//======================================================================= -// function: Wait -// purpose: -//======================================================================= - void BOP_Draw::Wait() -{ - char xx; - scanf ("%c", &xx); -} - -#endif - -#ifndef BOPDRAW - -void BOP_Draw::DrawListOfShape (const TopTools_ListOfShape& , - const Standard_CString ){} -void BOP_Draw::DrawListOfEdgesWithPC (const TopoDS_Face& , - const TopTools_ListOfShape& , - const Standard_Integer , - const Standard_CString ){} -void BOP_Draw::DrawListOfEdgesWithPC (const TopoDS_Face& , - const TopTools_ListOfShape& , - const Standard_CString ){} -void BOP_Draw::DrawEdgeWithPC (const TopoDS_Face& , - const TopoDS_Edge& , - const Standard_CString ){} -void BOP_Draw::Wait(){} - -#endif - diff --git a/src/BOP/BOP_EdgeInfo.cdl b/src/BOP/BOP_EdgeInfo.cdl deleted file mode 100755 index db0af3366b..0000000000 --- a/src/BOP/BOP_EdgeInfo.cdl +++ /dev/null @@ -1,87 +0,0 @@ --- Created on: 2001-04-09 --- Created by: Peter KURNEV --- Copyright (c) 2001-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class EdgeInfo from BOP - - ---Purpose: - --- The auxiliary class to store data about edges - --- that have common vertex - --- -uses - Edge from TopoDS - ---raises - -is - Create - returns EdgeInfo from BOP; - ---Purpose: - --- Empty constructor; - --- - SetEdge (me:out; - aE:Edge from TopoDS); - ---Purpose: - --- Modifier - --- - SetPassed (me:out; - aFlag:Boolean from Standard); - ---Purpose: - --- Modifier - --- - SetAngle (me:out; - anAngle:Real from Standard); - ---Purpose: - --- Modifier - --- - SetInFlag (me:out; - aFlag:Boolean from Standard); - ---Purpose: - --- Modifier - --- - Edge (me) - returns Edge from TopoDS; - ---C++: return const & - ---Purpose: - --- Selector - --- - Passed (me) - returns Boolean from Standard; - ---Purpose: - --- Selector - --- - Angle (me) - returns Real from Standard; - ---Purpose: - --- Selector - --- - IsIn (me) - returns Boolean from Standard; - ---Purpose: - --- Selector - --- -fields - - myEdge : Edge from TopoDS; - myPassed: Boolean from Standard; - myInFlag: Boolean from Standard; - myAngle : Real from Standard; - -end EdgeInfo; diff --git a/src/BOP/BOP_EdgeInfo.cxx b/src/BOP/BOP_EdgeInfo.cxx deleted file mode 100755 index bc6b2cc95c..0000000000 --- a/src/BOP/BOP_EdgeInfo.cxx +++ /dev/null @@ -1,102 +0,0 @@ -// Created on: 2001-04-09 -// Created by: Peter KURNEV -// Copyright (c) 2001-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#include - -//======================================================================= -// function: BOP_EdgeInfo::BOP_EdgeInfo -// purpose: -//======================================================================= -BOP_EdgeInfo::BOP_EdgeInfo() -: - myPassed(Standard_False), - myInFlag(Standard_False), - myAngle (-1.) -{} - -//======================================================================= -// function: SetEdge -// purpose: -//======================================================================= - void BOP_EdgeInfo::SetEdge(const TopoDS_Edge& anEdge) -{ - myEdge=anEdge; -} - -//======================================================================= -// function: SetPassed -// purpose: -//======================================================================= - void BOP_EdgeInfo::SetPassed(const Standard_Boolean aFlag) -{ - myPassed=aFlag; -} -//======================================================================= -// function: SetInFlag -// purpose: -//======================================================================= - void BOP_EdgeInfo::SetInFlag(const Standard_Boolean aFlag) -{ - myInFlag=aFlag; -} - -//======================================================================= -// function: SetAngle -// purpose: -//======================================================================= - void BOP_EdgeInfo::SetAngle(const Standard_Real anAngle) -{ - myAngle=anAngle; -} - -//======================================================================= -// function: Edge -// purpose: -//======================================================================= - const TopoDS_Edge& BOP_EdgeInfo::Edge()const -{ - return myEdge; -} - -//======================================================================= -// function: Passed -// purpose: -//======================================================================= - Standard_Boolean BOP_EdgeInfo::Passed()const -{ - return myPassed; -} -//======================================================================= -// function: IsIn -// purpose: -//======================================================================= - Standard_Boolean BOP_EdgeInfo::IsIn()const -{ - return myInFlag; -} - -//======================================================================= -// function: Angle -// purpose: -//======================================================================= - Standard_Real BOP_EdgeInfo::Angle()const -{ - return myAngle; -} diff --git a/src/BOP/BOP_EmptyBuilder.cdl b/src/BOP/BOP_EmptyBuilder.cdl deleted file mode 100755 index bb49819877..0000000000 --- a/src/BOP/BOP_EmptyBuilder.cdl +++ /dev/null @@ -1,67 +0,0 @@ --- Created on: 2002-02-01 --- Created by: Peter KURNEV --- Copyright (c) 2002-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class EmptyBuilder from BOP inherits Builder from BOP - - ---Purpose: - --- Performs Boolean Operation (BO) for shapes - --- in cases when one of arguments(or both) is(are) empty - --- -uses - DSFiller from BOPTools, - PDSFiller from BOPTools, - ListOfShape from TopTools - ---raises - -is - Create - returns EmptyBuilder from BOP; - ---Purpose: - --- Empty constructor; - --- - Do (me:out) - is redefined; - ---Purpose: - --- see base classes, please - --- - DoWithFiller (me:out; - aDSF: DSFiller from BOPTools) - is redefined; - ---Purpose: - --- see base classes, please - --- - Destroy (me: in out) - is redefined; - ---C++: alias "Standard_EXPORT virtual ~BOP_EmptyBuilder(){Destroy();}" - ---Purpose: - --- Destructor - --- - BuildResult (me:out) - is redefined; - ---Purpose: - --- see base classes, please - --- - ---fields - -end EmptyBuilder; - diff --git a/src/BOP/BOP_EmptyBuilder.cxx b/src/BOP/BOP_EmptyBuilder.cxx deleted file mode 100755 index 982b69c477..0000000000 --- a/src/BOP/BOP_EmptyBuilder.cxx +++ /dev/null @@ -1,136 +0,0 @@ -// Created on: 2002-02-01 -// Created by: Peter KURNEV -// Copyright (c) 2002-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#include - -#include -#include - -#include - -#include - -#include -#include -#include - - - - -//======================================================================= -// function: BOP_EmptyBuilder::BOP_EmptyBuilder -// purpose: -//======================================================================= -BOP_EmptyBuilder::BOP_EmptyBuilder() -{ -} -//======================================================================= -// function: Destroy -// purpose: -//======================================================================= - void BOP_EmptyBuilder::Destroy() -{ -} -//======================================================================= -// function: Do -// purpose: -//======================================================================= - void BOP_EmptyBuilder::Do() -{ - myErrorStatus=0; - myIsDone=Standard_False; - // - // Filling the DS - BOPTools_DSFiller aDSFiller; - aDSFiller.SetShapes (myShape1, myShape2); - // - aDSFiller.Perform (); - // - DoWithFiller(aDSFiller); -} - -//======================================================================= -// function: DoWithFiller -// purpose: -//======================================================================= - void BOP_EmptyBuilder::DoWithFiller(const BOPTools_DSFiller& aDSFiller) -{ - myErrorStatus=0; - myIsDone=Standard_False; - // - myResultMap.Clear(); - myModifiedMap.Clear(); - // - myDSFiller=(BOPTools_DSFiller*) &aDSFiller; - // - // - try { - OCC_CATCH_SIGNALS - Standard_Boolean bIsNewFiller; - bIsNewFiller=aDSFiller.IsNewFiller(); - - if (bIsNewFiller) { - aDSFiller.SetNewFiller(!bIsNewFiller); - } - // - BuildResult(); - // - // - //FillModified(); - myIsDone=Standard_True; - } - - catch ( Standard_Failure ) { - myErrorStatus = 1; - BOPTColStd_Dump::PrintMessage("Can not build result\n"); - } - // -} - -//======================================================================= -// function: BuildResult -// purpose: -//======================================================================= - void BOP_EmptyBuilder::BuildResult() -{ - Standard_Boolean bIsEmptyShape1, bIsEmptyShape2; - BRep_Builder aBB; - TopoDS_Compound aCompound; - - aBB.MakeCompound(aCompound); - // - bIsEmptyShape1=BOPTools_Tools3D::IsEmptyShape(myShape1); - bIsEmptyShape2=BOPTools_Tools3D::IsEmptyShape(myShape2); - // - if (!bIsEmptyShape1 && bIsEmptyShape2) { - if (myOperation==BOP_FUSE || myOperation==BOP_CUT) { - aBB.Add(aCompound, myShape1); - } - } - // - else if (bIsEmptyShape1 && !bIsEmptyShape2) { - if (myOperation==BOP_FUSE || myOperation==BOP_CUT21) { - aBB.Add(aCompound, myShape2); - } - } - // - myResult=aCompound; -} - diff --git a/src/BOP/BOP_FaceAreaBuilder.cdl b/src/BOP/BOP_FaceAreaBuilder.cdl deleted file mode 100755 index 191aa97647..0000000000 --- a/src/BOP/BOP_FaceAreaBuilder.cdl +++ /dev/null @@ -1,63 +0,0 @@ --- Created on: 1995-12-21 --- Created by: Jean Yves LEBEY --- Copyright (c) 1995-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - ---modified by NIZNHY-PKV Tue Apr 3 15:53:58 2001 - -class FaceAreaBuilder from BOP inherits Area2dBuilder from BOP - - ---Purpose: - -- The FaceAreaBuilder algorithm is used to construct Faces from a LoopSet, - -- where the Loop is the composite topological object of the boundary, - -- here wire or block of edges. - -- The LoopSet gives an iteration on Loops. - -- For each Loop it indicates if it is on the boundary (wire) or if it - -- results from an interference (block of edges). - -- The result of the FaceAreaBuilder is an iteration on areas. - -- An area is described by a set of Loops. - -uses - - LoopSet from BOP, - LoopClassifier from BOP - -is - - Create returns FaceAreaBuilder; - ---Purpose: - --- Empty constructor; - --- - Create(LS :out LoopSet from BOP; - LC :out LoopClassifier from BOP; - ForceClass : Boolean = Standard_False) - returns FaceAreaBuilder; - ---Purpose: - --- Creates the object to build faces on the (wires,blocks of edge) - --- of , using the classifier . - --- - InitFaceAreaBuilder(me :out; - LS :out LoopSet from BOP; - LC :out LoopClassifier from BOP; - ForceClass : Boolean = Standard_False) - is static; - ---Purpose: - --- Initializes the object to build faces on the (wires,blocks of edge) - --- of , using the classifier . - --- -end FaceAreaBuilder; diff --git a/src/BOP/BOP_FaceAreaBuilder.cxx b/src/BOP/BOP_FaceAreaBuilder.cxx deleted file mode 100755 index 306c5513cf..0000000000 --- a/src/BOP/BOP_FaceAreaBuilder.cxx +++ /dev/null @@ -1,53 +0,0 @@ -// Created on: 1995-12-21 -// Created by: Jean Yves LEBEY -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -//modified by NIZNHY-PKV Tue Apr 3 15:55:58 2001 - -#include - -//======================================================================= -//function : BOP_FaceAreaBuilder -//purpose : -//======================================================================= -BOP_FaceAreaBuilder::BOP_FaceAreaBuilder() -{ -} - -//======================================================================= -//function : BOP_FaceAreaBuilder -//purpose : -//======================================================================= - BOP_FaceAreaBuilder::BOP_FaceAreaBuilder(BOP_LoopSet& LS, - BOP_LoopClassifier& LC, - const Standard_Boolean ForceClass) -{ - InitFaceAreaBuilder(LS,LC,ForceClass); -} - -//======================================================================= -//function : InitFaceAreaBuilder -//purpose : -//======================================================================= - void BOP_FaceAreaBuilder::InitFaceAreaBuilder(BOP_LoopSet& LS, - BOP_LoopClassifier& LC, - const Standard_Boolean ForceClass) -{ - InitAreaBuilder(LS,LC,ForceClass); -} diff --git a/src/BOP/BOP_FaceBuilder.cdl b/src/BOP/BOP_FaceBuilder.cdl deleted file mode 100755 index 875df43bb7..0000000000 --- a/src/BOP/BOP_FaceBuilder.cdl +++ /dev/null @@ -1,225 +0,0 @@ --- Created on: 1995-12-21 --- Created by: Jean Yves LEBEY --- Copyright (c) 1995-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - --- modified by PKV Tue Apr 3 16:57:39 2001 - - -class FaceBuilder from BOP - - ---Purpose: - --- The algorithm to construct Faces from a WireEdgeSet - --- - -uses - - Shape from TopoDS, - Face from TopoDS, - Wire from TopoDS, - Edge from TopoDS, - Vertex from TopoDS, - ListOfShape from TopTools, - SequenceOfInteger from TColStd, - Context from IntTools, - WireEdgeSet from BOP, - PWireEdgeSet from BOP --- LoopSet from BOP, --- BlockIterator from BOP, --- BlockBuilder from BOP, --- FaceAreaBuilder from BOP, - - -is - - Create - returns FaceBuilder; - ---Purpose: - --- Empty constructor; - --- - Do(me :out; - aWES : WireEdgeSet from BOP; - aForceClass : Boolean from Standard =Standard_True); - ---Purpose: - --- Launches the algorithm consisting of four steps - --- 1. Split the WES on wires - --- 2. Make Loops from wires - --- 3. Make Areas from Loops - --- 4. Make Faces from Areas - --- - - --- --- BuildNewFaces (me :out) --- is private; - ---Purpose: - --- Make Faces from Areas - --- - ---modified by NIZNHY-PKV Wed Feb 29 10:57:40 2012f - SetContext(me:out; - aCtx:Context from IntTools); - ---Purpose: - -- Sets intersection context - - Context(me) - returns Context from IntTools; - ---C++: return const & - ---Purpose: - -- Returns intersection context ---modified by NIZNHY-PKV Wed Feb 29 10:57:52 2012t - - WES (me) - returns WireEdgeSet from BOP; - ---C++: return const & - ---Purpose: - --- Selector - --- - NewFaces (me) - returns ListOfShape from TopTools; - ---C++: return const & - ---Purpose: - --- Selector - --- - SetTreatment (me: out; - aTreatment: Integer from Standard); - ---Purpose: - --- Modifier - --- 0 -Treat internal edges, - --- 1 -Do not treat internal edges - --- - - SetTreatSDScales (me: out; - aTreatment: Integer from Standard); - ---Purpose: - --- Modifier - --- 1 -Treat scale configured same domain faces, - --- 0 -Do not treat them. - --- --- SetManifoldFlag(me: out; --- aMFlag: Boolean from Standard); - ---Purpose: - --- Modifier - --- --- ManifoldFlag(me) --- returns Boolean from Standard; - ---Purpose: - --- Selector - --- - Treatment (me) - returns Integer from Standard; - ---Purpose: - --- Selector - --- - TreatSDScales (me) - returns Integer from Standard; - ---Purpose: - --- Selector - --- - --- - --- - --- Faces' iterator - --- --- InitFace(me:out) --- returns Integer from Standard; - --- MoreFace(me) --- returns Boolean from Standard; - --- NextFace(me:out); - ---Purpose: - --- - --- - --- Wires' iterator - --- --- InitWire(me:out) --- returns Integer from Standard; - --- MoreWire(me) --- returns Boolean from Standard; - --- NextWire(me:out); - --- IsOldWire(me) --- returns Boolean from Standard; - --- OldWire(me) --- returns Shape from TopoDS; - -- ---C++: return const & - --- Wire(me) --- returns Wire from TopoDS; --- ---C++: return const & --- ---Purpose: --- --- - - --- - --- Edges' iterator - --- --- FindNextValidElement(me:out); - --- InitEdge(me:out) --- returns Integer from Standard; - --- MoreEdge(me) --- returns Boolean from Standard; - --- NextEdge(me : in out); - --- Edge(me) --- returns Edge from TopoDS; --- ---C++: return const & - ---Purpose: - --- - --- MakeLoops(me :out; --- SS :out WireEdgeSet from BOP) --- is protected; - ---Purpose: - --- Make Loops from wires - --- - DoInternalEdges (me :out) - is protected; - ---Purpose: - --- Processes internal edges if they exists - - SDScales(me :out) - is protected; - ---Purpose: - --- Treatment SD faces with a "scale" - --- - --modified by NIZNHY-PKV Wed Feb 29 09:12:17 2012f - PerformAreas(me :out; - SS :out WireEdgeSet from BOP) - is protected; - --modified by NIZNHY-PKV Wed Feb 29 09:12:20 2012t - -fields - - myFace : Face from TopoDS; --- myLoopSet : LoopSet from BOP; --- myBlockIterator : BlockIterator from BOP; --- myBlockBuilder : BlockBuilder from BOP; --- myFaceAreaBuilder : FaceAreaBuilder from BOP; - myWES : PWireEdgeSet from BOP; - myNewFaces : ListOfShape from TopTools; - myTreatment : Integer from Standard; --- myManifoldFlag : Boolean from Standard; - myTreatSDScales : Integer from Standard; - myNegatives : SequenceOfInteger from TColStd; - myContext : Context from IntTools; -end FaceBuilder; diff --git a/src/BOP/BOP_FaceBuilder.cxx b/src/BOP/BOP_FaceBuilder.cxx deleted file mode 100755 index 4de3ac8982..0000000000 --- a/src/BOP/BOP_FaceBuilder.cxx +++ /dev/null @@ -1,801 +0,0 @@ -// Created by: Mister Open CAS.CADE -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#include - -#include -#include -#include - -#include - -#include -#include - -#include - -#include -#include - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - - -static - Standard_Boolean IsGrowthWire(const TopoDS_Shape& theWire, - const TopTools_IndexedMapOfShape& theMHE); -static - Standard_Boolean IsHole(const TopoDS_Shape& aW, - const TopoDS_Shape& aFace); -static - Standard_Boolean IsInside(const TopoDS_Shape& theHole, - const TopoDS_Shape& theF2, - const Handle(IntTools_Context)& theContext); -static - void DoTopologicalVerification(TopoDS_Face& F); - -//======================================================================= -//function : BOP_FaceBuilder -//purpose : -//======================================================================= -BOP_FaceBuilder::BOP_FaceBuilder(): - myTreatment(0), -// myManifoldFlag(Standard_True), - myTreatSDScales(0) -{ -} -//======================================================================= -//function : SetContext -//purpose : -//======================================================================= -void BOP_FaceBuilder::SetContext(const Handle(IntTools_Context)& aCtx) -{ - myContext=aCtx; -} -//======================================================================= -//function : Context -//purpose : -//======================================================================= -const Handle(IntTools_Context)& BOP_FaceBuilder::Context()const -{ - return myContext; -} -//======================================================================= -//function : SetTreatment -//purpose : -//======================================================================= -void BOP_FaceBuilder::SetTreatment(const Standard_Integer aTreatment) -{ - myTreatment=aTreatment; -} -//======================================================================= -//function : Treatment -//purpose : -//======================================================================= -Standard_Integer BOP_FaceBuilder::Treatment()const -{ - return myTreatment; -} -//======================================================================= -//function : SetTreatSDScales -//purpose : -//======================================================================= -void BOP_FaceBuilder::SetTreatSDScales(const Standard_Integer aTreatment) -{ - myTreatSDScales=aTreatment; -} -//======================================================================= -//function : TreatSDScales -//purpose : -//======================================================================= -Standard_Integer BOP_FaceBuilder::TreatSDScales()const -{ - return myTreatSDScales; -} -//======================================================================= -//function : WES -//purpose : -//======================================================================= -const BOP_WireEdgeSet& BOP_FaceBuilder::WES() const -{ - return *myWES; -} -//======================================================================= -//function : NewFaces -//purpose : -//======================================================================= -const TopTools_ListOfShape& BOP_FaceBuilder::NewFaces() const -{ - return myNewFaces; -} -//======================================================================= -//function : Do -//purpose : -//======================================================================= -void BOP_FaceBuilder::Do(const BOP_WireEdgeSet& aWES, - const Standard_Boolean bForceClass) -{ - myFace=aWES.Face(); - myWES=(BOP_WireEdgeSet*) &aWES; - // - if (myContext.IsNull()) { - myContext=new IntTools_Context; - } - // - BOP_WESCorrector aWESCor; - aWESCor.SetWES(aWES); - aWESCor.Do(); - BOP_WireEdgeSet& aNewWES=aWESCor.NewWES(); - // - PerformAreas(aNewWES); - // - if (myTreatment==0) { - DoInternalEdges(); - } - if (myTreatSDScales) { - SDScales(); - } - - // do topological verification - TopTools_ListIteratorOfListOfShape anIt; - anIt.Initialize(myNewFaces); - for(anIt.Initialize(myNewFaces); anIt.More(); anIt.Next()) { - TopoDS_Face& aF = TopoDS::Face(anIt.Value()); - DoTopologicalVerification(aF); - } -} -//======================================================================= -//function : DoInternalEdges -//purpose : -//======================================================================= -void BOP_FaceBuilder::DoInternalEdges() -{ - Standard_Integer i, aNbE, aNbSE, aNb, aNbF; - TopTools_IndexedDataMapOfShapeListOfShape aDifferenceMap, aFLEMap; - TopTools_IndexedMapOfOrientedShape aStartElementsMap, anEdgesMap; - TopTools_IndexedMapOfShape anInternalEdges; - // - const TopTools_ListOfShape& aStartElements=myWES->StartElements(); - - TopTools_ListIteratorOfListOfShape anIt(aStartElements); - for (; anIt.More(); anIt.Next()) { - const TopoDS_Shape& aE=anIt.Value(); - aStartElementsMap.Add(aE); - } - - anIt.Initialize(myNewFaces); - for (; anIt.More(); anIt.Next()) { - const TopoDS_Shape& aF=anIt.Value(); - TopExp_Explorer anExp (aF, TopAbs_EDGE); - for (; anExp.More(); anExp.Next()) { - const TopoDS_Shape& aE=anExp.Current(); - anEdgesMap.Add(aE); - } - } - aNbSE=aStartElementsMap.Extent(); - aNbE=anEdgesMap.Extent(); - - if (aNbE==aNbSE) { - return; - } - - for (i=1; i<=aNbSE; i++) { - const TopoDS_Shape& aE=aStartElementsMap(i); - if (!anEdgesMap.Contains(aE)) { - if (!aDifferenceMap.Contains(aE)) { - TopTools_ListOfShape aLEx; - aLEx.Append(aE); - aDifferenceMap.Add(aE, aLEx); - } - else { - TopTools_ListOfShape& aLEx=aDifferenceMap.ChangeFromKey(aE); - aLEx.Append(aE); - } - } - } - - aNbE=aDifferenceMap.Extent(); - if(!aNbE) { - return; - } - - for (i=1; i<=aNbE; i++) { - const TopoDS_Shape& aE=aDifferenceMap.FindKey(i); - const TopTools_ListOfShape& aLE=aDifferenceMap(i); - aNb=aLE.Extent(); - if (aNb==2) { - const TopoDS_Edge& anEdge=TopoDS::Edge(aE); - if (!BRep_Tool::IsClosed(anEdge, myFace)) { - anInternalEdges.Add(aE); - } - } - // - if (aNb==1) { - const TopoDS_Edge& anEdge=TopoDS::Edge(aE); - if (anEdge.Orientation()==TopAbs_INTERNAL) { - anInternalEdges.Add(aE); - } - } - // - } - - aNbE=anInternalEdges.Extent(); - if(!aNbE) { - return; - } - - aFLEMap.Clear(); - - for (i=1; i<=aNbE; i++) { - const TopoDS_Edge& aEx=TopoDS::Edge(anInternalEdges(i)); - TopoDS_Edge aE=aEx; - - Standard_Real aT, aT1, aT2, aToler; - Standard_Boolean bHasCurveOnSurface, bIsPointInOnFace; - Handle(Geom2d_Curve)aC2D; - - bHasCurveOnSurface= - BOPTools_Tools2D::HasCurveOnSurface(aE, myFace, aC2D, aT1, aT2, aToler); - - if (bHasCurveOnSurface) { - aT=BOPTools_Tools2D::IntermediatePoint(aT1, aT2); - gp_Pnt2d aP2D; - aC2D->D0(aT, aP2D); - // - anIt.Initialize(myNewFaces); - - for (; anIt.More(); anIt.Next()) { - TopoDS_Face& aF=TopoDS::Face(anIt.Value()); - // - bIsPointInOnFace=myContext->IsPointInOnFace(aF, aP2D); - // - if (bIsPointInOnFace) { - // - if (!aFLEMap.Contains(aF)) { - TopTools_ListOfShape aLE; - aLE.Append(aEx); - aFLEMap.Add(aF, aLE); - } - else { - TopTools_ListOfShape& aLE=aFLEMap.ChangeFromKey(aF); - aLE.Append(aEx); - } - break; - } - } //for (; anIt.More(); anIt.Next()) - }// if (bHasCurveOnSurface) - } // for (i=1; i<=aNbE; i++) - // - // Make Wires from Internal Edges and Add the Wires to the faces - aNbF=aFLEMap.Extent(); - BRep_Builder aBB; - for (i=1; i<=aNbF; i++) { - const TopoDS_Face& aF=TopoDS::Face(aFLEMap.FindKey(i)); - TopoDS_Face* pF=(TopoDS_Face*)&aF; - - const TopTools_ListOfShape& aLE=aFLEMap(i); - // - BOP_ListOfConnexityBlock aLConBlks; - - BOP_BuilderTools::MakeConnexityBlocks(aLE, TopAbs_EDGE, aLConBlks); - - BOP_ListIteratorOfListOfConnexityBlock aConBlkIt(aLConBlks); - for (; aConBlkIt.More(); aConBlkIt.Next()) { - BOP_ConnexityBlock& aConnexityBlock=aConBlkIt.Value(); - const TopTools_ListOfShape& aLECB=aConnexityBlock.Shapes(); - - aNbE=aLECB.Extent(); - if (aNbE) { - TopoDS_Wire aW; - aBB.MakeWire(aW); - - anIt.Initialize(aLECB); - for (; anIt.More(); anIt.Next()) { - TopoDS_Edge& aE=TopoDS::Edge(anIt.Value()); - aE.Orientation(TopAbs_INTERNAL); - aBB.Add(aW, aE); - } - - aBB.Add(*pF, aW); - } - } - // - } -} -//======================================================================= -// function: TreatSDScales -// purpose : -//======================================================================= -void BOP_FaceBuilder::SDScales() -{ - - Standard_Integer iNegativeFlag, aNbFR, i, aNbEFOpen, iCnt; - - TopTools_ListOfShape aLFR; - TopTools_ListIteratorOfListOfShape anIt, anItFR; - TopTools_IndexedMapOfShape aMFR; - // - iCnt=myNewFaces.Extent(); - if (iCnt<2){ - return; - } - // - // 1. Collect all faces with negative (infinite) area - anIt.Initialize(myNewFaces); - for (i=1; anIt.More(); anIt.Next(), ++i) { - const TopoDS_Face& aF=TopoDS::Face(anIt.Value()); - - iNegativeFlag=myNegatives(i); - if (iNegativeFlag) { - aLFR.Append(aF); - } - } - // - aNbFR=aLFR.Extent(); - // - if (!aNbFR) { - return; - } - // - // - BOP_ListOfConnexityBlock aLCB; - BOP_ListIteratorOfListOfConnexityBlock aLCBIt; - // - BOP_BuilderTools::MakeConnexityBlocks (myNewFaces, TopAbs_FACE, aLCB); - // - anItFR.Initialize(aLFR); - for (; anItFR.More(); anItFR.Next()) { - const TopoDS_Face& aFR=TopoDS::Face(anItFR.Value()); - // - iCnt=1; - TopTools_IndexedMapOfShape aMEFOpen; - BOP_ConnexityBlock* pCBR=NULL; - // - TopExp::MapShapes(aFR, TopAbs_EDGE, aMEFOpen); - aNbEFOpen=aMEFOpen.Extent(); - // - // Look for ConnexityBlock to which aFR belongs to (pCBR) - aLCBIt.Initialize(aLCB); - for (; aLCBIt.More() && iCnt; aLCBIt.Next()) { - const BOP_ConnexityBlock& aCB=aLCBIt.Value(); - - const TopTools_ListOfShape& aLCF=aCB.Shapes(); - anIt.Initialize(aLCF); - for (; anIt.More() && iCnt; anIt.Next()) { - const TopoDS_Face& aF=TopoDS::Face(anIt.Value()); - TopTools_IndexedMapOfShape aMECB; - TopExp::MapShapes(aF, TopAbs_EDGE, aMECB); - - for (i=1; i<=aNbEFOpen; ++i) { - const TopoDS_Shape& aEFOpen= aMEFOpen(i); - if (aMECB.Contains(aEFOpen)) { - iCnt=0; - pCBR=(BOP_ConnexityBlock*) &aCB; - break; - } - } - } - } - // - if (iCnt) { - // it is strange - continue; - } - // - // Collect Faces to remove in the map aMFR - const TopTools_ListOfShape& aLCR=pCBR->Shapes(); - anIt.Initialize(aLCR); - for (; anIt.More(); anIt.Next()) { - const TopoDS_Face& aF=TopoDS::Face(anIt.Value()); - aMFR.Add(aF); - } - } // for (; anItFR.More(); anItFR.Next()) - // - // - iCnt=aMFR.Extent(); - if (!iCnt) { - // Nothing to remove - return; - } - // - TopTools_ListOfShape aLFOut; - anIt.Initialize(myNewFaces); - for (; anIt.More(); anIt.Next()) { - const TopoDS_Face& aF=TopoDS::Face(anIt.Value()); - if (!aMFR.Contains(aF)) { - aLFOut.Append(aF); - } - } - // - myNewFaces.Clear(); - anIt.Initialize(aLFOut); - for (; anIt.More(); anIt.Next()) { - const TopoDS_Face& aF=TopoDS::Face(anIt.Value()); - myNewFaces.Append(aF); - } -} -//======================================================================= -//function : PerformAreas -//purpose : -//======================================================================= -void BOP_FaceBuilder::PerformAreas(BOP_WireEdgeSet& aWES) -{ - Standard_Boolean bIsGrowth, bIsHole; - Standard_Real aTol; - TopTools_ListOfShape aNewFaces, aHoleWires, aLoops; - TopoDS_Shape anInfinitePointShape; - TopTools_DataMapOfShapeShape aInOutMap; - TopTools_DataMapOfShapeListOfShape aMSH; - TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItMSH; - TopTools_ListIteratorOfListOfShape aIt1, aIt2; - TopTools_IndexedMapOfShape aMHE; - BRep_Builder aBB; - Handle(Geom_Surface) aS; - TopLoc_Location aLoc; - // - aTol=BRep_Tool::Tolerance(myFace); - aS=BRep_Tool::Surface(myFace, aLoc); - // - myNewFaces.Clear(); - // - for(aWES.InitShapes(); aWES.MoreShapes(); aWES.NextShape()) { - const TopoDS_Shape& aW=aWES.Shape(); - aLoops.Append(aW); - } - // - // Draft faces [aNewFaces] - aIt1.Initialize(aLoops); - for ( ; aIt1.More(); aIt1.Next()) { - const TopoDS_Shape& aWire=aIt1.Value(); - // - bIsGrowth=IsGrowthWire(aWire, aMHE); - if (bIsGrowth) { - // make a growth face from a wire - TopoDS_Face aFace; - aBB.MakeFace(aFace, aS, aLoc, aTol); - aBB.Add (aFace, aWire); - // - aNewFaces.Append (aFace); - } - else{ - // check if a wire is a hole - bIsHole=IsHole(aWire, myFace); - //XX - if (bIsHole) { - aHoleWires.Append(aWire); - TopExp::MapShapes(aWire, TopAbs_EDGE, aMHE); - } - else { - // make a growth face from a wire - TopoDS_Face aFace; - aBB.MakeFace(aFace, aS, aLoc, aTol); - aBB.Add (aFace, aWire); - // - aNewFaces.Append (aFace); - } - } - } - // - // 2. Find outer growth shell that is most close to each hole shell - aIt2.Initialize(aHoleWires); - for (; aIt2.More(); aIt2.Next()) { - const TopoDS_Shape& aHole = aIt2.Value(); - // - aIt1.Initialize(aNewFaces); - for ( ; aIt1.More(); aIt1.Next()) { - const TopoDS_Shape& aF=aIt1.Value(); - // - if (!IsInside(aHole, aF, myContext)){ - continue; - } - // - if ( aInOutMap.IsBound (aHole)){ - const TopoDS_Shape& aF2=aInOutMap(aHole); - if (IsInside(aF, aF2, myContext)) { - aInOutMap.UnBind(aHole); - aInOutMap.Bind (aHole, aF); - } - } - else{ - aInOutMap.Bind (aHole, aF); - } - } - // - // Add aHole to a map Face/ListOfHoles [aMSH] - if (aInOutMap.IsBound(aHole)){ - const TopoDS_Shape& aF=aInOutMap(aHole); - if (aMSH.IsBound(aF)) { - TopTools_ListOfShape& aLH=aMSH.ChangeFind(aF); - aLH.Append(aHole); - } - else { - TopTools_ListOfShape aLH; - aLH.Append(aHole); - aMSH.Bind(aF, aLH); - } - } - }// for (; aIt2.More(); aIt2.Next()) - // - // 3. Add aHoles to Faces - aItMSH.Initialize(aMSH); - for (; aItMSH.More(); aItMSH.Next()) { - TopoDS_Face aF=TopoDS::Face(aItMSH.Key()); - // - const TopTools_ListOfShape& aLH=aItMSH.Value(); - aIt2.Initialize(aLH); - for (; aIt2.More(); aIt2.Next()) { - const TopoDS_Shape& aHole = aIt2.Value(); - aBB.Add (aF, aHole); - } - // - // update classifier - aTol=BRep_Tool::Tolerance(aF); - IntTools_FClass2d& aClsf=myContext->FClass2d(aF); - aClsf.Init(aF, aTol); - } - // - // These aNewFaces are draft faces that - // do not contain any internal shapes - // - Standard_Boolean bIsValidIn2D, bNegativeFlag; - Standard_Integer iNegativeFlag; - // - myNewFaces.Clear(); - myNegatives.Clear(); - // - aIt1.Initialize(aNewFaces); - for ( ; aIt1.More(); aIt1.Next()) { - const TopoDS_Face& aFx=TopoDS::Face(aIt1.Value()); - bIsValidIn2D=BOPTools_Tools3D::IsValidArea (aFx, bNegativeFlag); - if(bIsValidIn2D) { - myNewFaces.Append (aFx); - iNegativeFlag=(Standard_Integer)bNegativeFlag; - myNegatives.Append(iNegativeFlag); - } - } - // -} -//======================================================================= -//function : IsGrowthWire -//purpose : -//======================================================================= -Standard_Boolean IsGrowthWire(const TopoDS_Shape& theWire, - const TopTools_IndexedMapOfShape& theMHE) -{ - Standard_Boolean bRet; - TopoDS_Iterator aIt; - // - bRet=Standard_False; - if (theMHE.Extent()) { - aIt.Initialize(theWire); - for(; aIt.More(); aIt.Next()) { - const TopoDS_Shape& aE=aIt.Value(); - if (theMHE.Contains(aE)) { - return !bRet; - } - } - } - return bRet; -} -//======================================================================= -//function : IsHole -//purpose : -//======================================================================= -Standard_Boolean IsHole(const TopoDS_Shape& aW, - const TopoDS_Shape& aFace) -{ - Standard_Boolean bIsHole; - Standard_Real aTolF; - TopoDS_Face aFF, aFC; - BRep_Builder aBB; - IntTools_FClass2d aFClass2d; - // - aFF=TopoDS::Face(aFace.EmptyCopied()); - aFF.Orientation(TopAbs_FORWARD); - aBB.Add(aFF, aW); - // - BRepBuilderAPI_Copy aBC; - // - aBC.Perform(aFF); - aFC=TopoDS::Face(aBC.Shape()); - aFF=aFC; - // - aTolF=BRep_Tool::Tolerance(aFF); - //modified by NIZNHY-PKV Thu Aug 23 09:18:05 2012f - BRepLib::SameParameter(aFF, aTolF, Standard_True); - //modified by NIZNHY-PKV Thu Aug 23 09:18:08 2012t - // - aFClass2d.Init(aFF, aTolF); - // - bIsHole=aFClass2d.IsHole(); - // - return bIsHole; -} -//======================================================================= -//function : IsInside -//purpose : -//======================================================================= -Standard_Boolean IsInside(const TopoDS_Shape& theHole, - const TopoDS_Shape& theF2, - const Handle(IntTools_Context)& theContext) -{ - Standard_Boolean bRet; - Standard_Real aT, aU, aV; - - TopAbs_State aState; - TopExp_Explorer aExp; - TopTools_IndexedMapOfShape aME2; - gp_Pnt2d aP2D; - // - bRet=Standard_False; - aState=TopAbs_UNKNOWN; - const TopoDS_Face& aF2=TopoDS::Face(theF2); - // - TopExp::MapShapes(aF2, TopAbs_EDGE, aME2); - // - aExp.Init(theHole, TopAbs_EDGE); - if (aExp.More()) { - const TopoDS_Edge& aE = TopoDS::Edge(aExp.Current()); - if (aME2.Contains(aE)) { - return bRet; - } - // - aT=BOPTools_Tools2D::IntermediatePoint(aE); - BOPTools_Tools2D::PointOnSurface(aE, aF2, aT, aU, aV); - aP2D.SetCoord(aU, aV); - // - IntTools_FClass2d& aClsf=theContext->FClass2d(aF2); - aState=aClsf.Perform(aP2D); - bRet=(aState==TopAbs_IN); - } - // - return bRet; -} -//======================================================================= -//function : DoTopologicalVerification -//purpose : -//======================================================================= -void DoTopologicalVerification(TopoDS_Face& F) -{ - TopTools_IndexedDataMapOfShapeListOfShape mapVE; - mapVE.Clear(); - TopExp::MapShapesAndAncestors(F,TopAbs_VERTEX,TopAbs_EDGE,mapVE); - - Standard_Real pF1 = 0., pL1 = 0., pF2 = 0., pL2 = 0.; - Standard_Integer nbKeys = mapVE.Extent(), iKey = 0; - - for( iKey = 1; iKey <= nbKeys; iKey++ ) { - const TopoDS_Vertex& iV = TopoDS::Vertex(mapVE.FindKey(iKey)); - if( iV.IsNull() ) continue; - - Standard_Real TolV = BRep_Tool::Tolerance(iV); - - const TopTools_ListOfShape& iLE = mapVE.FindFromIndex(iKey); - Standard_Integer nbE = iLE.Extent(); - if( nbE != 2 ) break; - - const TopoDS_Edge& iE1 = TopoDS::Edge(iLE.First()); - const TopoDS_Edge& iE2 = TopoDS::Edge(iLE.Last()); - - if(BRep_Tool::Degenerated(iE1) || BRep_Tool::Degenerated(iE2) ) continue; - - Standard_Real iPE1 = BRep_Tool::Parameter(iV,iE1); - Standard_Real iPE2 = BRep_Tool::Parameter(iV,iE2); - - Handle(Geom_Curve) aC3D1 = BRep_Tool::Curve(iE1,pF1,pL1); - Handle(Geom_Curve) aC3D2 = BRep_Tool::Curve(iE2,pF2,pL2); - if( aC3D1.IsNull() || aC3D2.IsNull() ) break; - - Standard_Boolean is1F = (fabs(iPE1-pF1) < fabs(iPE1-pL1)); - Standard_Boolean is2F = (fabs(iPE2-pF2) < fabs(iPE2-pL2)); - - Standard_Real useP1 = iPE1; - if( is1F ) { - if( fabs(iPE1-pF1) > 1.e-7 ) useP1 = pF1; - } - else { - if( fabs(iPE1-pL1) > 1.e-7 ) useP1 = pL1; - } - - Standard_Real useP2 = iPE2; - if( is2F ) { - if( fabs(iPE2-pF2) > 1.e-7 ) useP2 = pF2; - } - else { - if( fabs(iPE2-pL2) > 1.e-7 ) useP2 = pL2; - } - - gp_Pnt aPnt1 = aC3D1->Value(useP1); - gp_Pnt aPnt2 = aC3D2->Value(useP2); - gp_Pnt aPntV = BRep_Tool::Pnt(iV); - - Standard_Real distV1 = aPntV.Distance(aPnt1); - Standard_Real distV2 = aPntV.Distance(aPnt2); - - // update vertex tolerance checking 3D curves - if( distV1 > TolV || distV2 > TolV ) { - Standard_Real distMax = Max(distV1,distV2); - Standard_Real delta = fabs(distMax-TolV); - Standard_Real newTol = TolV + delta + 2.e-7; - TopoDS_Vertex & aV = (TopoDS_Vertex &) iV; - BRep_Builder bb; - bb.UpdateVertex(aV,newTol); - TolV = newTol; - } - - gp_Pnt2d aPnt2dF, aPnt2dL; - BRep_Tool::UVPoints(iE1,F,aPnt2dF, aPnt2dL); - gp_Pnt2d aPnt2dE1 = (is1F) ? aPnt2dF : aPnt2dL; - BRep_Tool::UVPoints(iE2,F,aPnt2dF, aPnt2dL); - gp_Pnt2d aPnt2dE2 = (is2F) ? aPnt2dF : aPnt2dL; - - BRepAdaptor_Surface aFSurf (F,Standard_False); - aPnt1 = aFSurf.Value(aPnt2dE1.X(), aPnt2dE1.Y()); - aPnt2 = aFSurf.Value(aPnt2dE2.X(), aPnt2dE2.Y()); - distV1 = aPntV.Distance(aPnt1); - distV2 = aPntV.Distance(aPnt2); - - // update vertex tolerance checking 3D points on surface - if( distV1 > TolV || distV2 > TolV ) { - Standard_Real distMax = Max(distV1,distV2); - Standard_Real delta = fabs(distMax-TolV); - Standard_Real newTol = TolV + delta + 2.e-7; - TopoDS_Vertex & aV = (TopoDS_Vertex &) iV; - BRep_Builder bb; - bb.UpdateVertex(aV,newTol); - TolV = newTol; - } - } -} - diff --git a/src/BOP/BOP_FaceInfo.cdl b/src/BOP/BOP_FaceInfo.cdl deleted file mode 100755 index 337030ecfc..0000000000 --- a/src/BOP/BOP_FaceInfo.cdl +++ /dev/null @@ -1,130 +0,0 @@ --- Created on: 2001-08-02 --- Created by: Peter KURNEV --- Copyright (c) 2001-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class FaceInfo from BOP - - ---Purpose: - --- The auxiliary class to store data about faces on a shell - --- that have common edge - --- - -uses - Face from TopoDS, - Pnt from gp, - Dir from gp, - Pnt2d from gp - ---raises - -is - Create - returns FaceInfo from BOP; - ---Purpose: - --- Empty constructor; - --- - SetFace (me:out; - aF:Face from TopoDS); - ---Purpose: - --- Modifier - --- - SetPassed (me:out; - aFlag:Boolean from Standard); - ---Purpose: - --- Modifier - --- - SetPOnEdge (me:out; - aP:Pnt from gp); - ---Purpose: - --- Modifier - --- - SetPInFace (me:out; - aP:Pnt from gp); - ---Purpose: - --- Modifier - --- - SetPInFace2D (me:out; - aP:Pnt2d from gp); - ---Purpose: - --- Modifier - --- - SetNormal (me:out; - aD:Dir from gp); - ---Purpose: - --- Modifier - --- - SetAngle (me:out; - A:Real from Standard); - ---Purpose: - --- Modifier - --- - - Face (me) - returns Face from TopoDS; - ---C++: return const & - ---Purpose: - --- Selector - --- - POnEdge (me) - returns Pnt from gp; - ---C++: return const & - ---Purpose: - --- Selector - --- - PInFace (me) - returns Pnt from gp; - ---C++: return const & - ---Purpose: - --- Selector - --- - PInFace2D (me) - returns Pnt2d from gp; - ---C++: return const & - ---Purpose: - --- Selector - --- - - Normal (me) - returns Dir from gp; - ---C++: return const & - ---Purpose: - --- Selector - --- - IsPassed (me) - returns Boolean from Standard; - ---Purpose: - --- Selector - --- - Angle (me) - returns Real from Standard; - ---Purpose: - --- Selector - --- -fields - - myFace : Face from TopoDS; - myPassed: Boolean from Standard; - myPOnEdge : Pnt from gp; - myPInFace : Pnt from gp; - myPInFace2D: Pnt2d from gp; - myNormal : Dir from gp; - myAngle : Real from Standard; - -end FaceInfo; diff --git a/src/BOP/BOP_FaceInfo.cxx b/src/BOP/BOP_FaceInfo.cxx deleted file mode 100755 index 15029e48eb..0000000000 --- a/src/BOP/BOP_FaceInfo.cxx +++ /dev/null @@ -1,151 +0,0 @@ -// Created on: 2001-04-09 -// Created by: Peter KURNEV -// Copyright (c) 2001-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include - -//======================================================================= -// function: BOP_FaceInfo::BOP_FaceInfo -// purpose: -//======================================================================= -BOP_FaceInfo::BOP_FaceInfo() -: - myPassed(Standard_False), - myAngle(0.) -{} - -//======================================================================= -// function: SetFace -// purpose: -//======================================================================= - void BOP_FaceInfo::SetFace(const TopoDS_Face& aF) -{ - myFace=aF; -} -//======================================================================= -// function: Face -// purpose: -//======================================================================= - const TopoDS_Face& BOP_FaceInfo::Face()const -{ - return myFace; -} - -//======================================================================= -// function: SetPassed -// purpose: -//======================================================================= - void BOP_FaceInfo::SetPassed(const Standard_Boolean aFlag) -{ - myPassed=aFlag; -} - -//======================================================================= -// function: SetPOnEdge -// purpose: -//======================================================================= - void BOP_FaceInfo::SetPOnEdge(const gp_Pnt& aP) -{ - myPOnEdge=aP; -} - -//======================================================================= -// function: SetAngle -// purpose: -//======================================================================= - void BOP_FaceInfo::SetAngle(const Standard_Real A) -{ - myAngle=A; -} -//======================================================================= -// function: Angle -// purpose: -//======================================================================= - Standard_Real BOP_FaceInfo::Angle()const -{ - return myAngle; -} - -//======================================================================= -// function: POnEdge -// purpose: -//======================================================================= - const gp_Pnt& BOP_FaceInfo::POnEdge()const -{ - return myPOnEdge; -} -//======================================================================= -// function: SetPInFace -// purpose: -//======================================================================= - void BOP_FaceInfo::SetPInFace(const gp_Pnt& aP) -{ - myPInFace=aP; -} -//======================================================================= -// function: PInFace -// purpose: -//======================================================================= - const gp_Pnt& BOP_FaceInfo::PInFace()const -{ - return myPInFace; -} -//======================================================================= -// function: SetPInFace2D -// purpose: -//======================================================================= - void BOP_FaceInfo::SetPInFace2D(const gp_Pnt2d& aP) -{ - myPInFace2D=aP; -} -//======================================================================= -// function: PInFace2D -// purpose: -//======================================================================= - const gp_Pnt2d& BOP_FaceInfo::PInFace2D()const -{ - return myPInFace2D; -} - -//======================================================================= -// function: SetNormal -// purpose: -//======================================================================= - void BOP_FaceInfo::SetNormal(const gp_Dir& aD) -{ - myNormal=aD; -} -//======================================================================= -// function: Normal -// purpose: -//======================================================================= - const gp_Dir& BOP_FaceInfo::Normal()const -{ - return myNormal; -} - -//======================================================================= -// function: IsPassed -// purpose: -//======================================================================= - Standard_Boolean BOP_FaceInfo::IsPassed()const -{ - return myPassed; -} diff --git a/src/BOP/BOP_HistoryCollector.cdl b/src/BOP/BOP_HistoryCollector.cdl deleted file mode 100755 index 1dd0d9f1b7..0000000000 --- a/src/BOP/BOP_HistoryCollector.cdl +++ /dev/null @@ -1,76 +0,0 @@ --- Created on: 2003-03-20 --- Created by: Michael KLOKOV --- Copyright (c) 2003-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -deferred class HistoryCollector from BOP inherits TShared from MMgt -uses - Shape from TopoDS, - Operation from BOP, - ListOfShape from TopTools, - DataMapOfShapeListOfShape from TopTools, - PDSFiller from BOPTools - -is - Initialize; - - Initialize(theShape1 : Shape from TopoDS; - theShape2 : Shape from TopoDS; - theOperation: Operation from BOP); - - Generated (me: mutable; S : Shape from TopoDS) - returns ListOfShape from TopTools - is virtual; - ---C++: return const & - - SetResult(me: mutable; theResult: Shape from TopoDS; - theDSFiller: PDSFiller from BOPTools) - is virtual; - - Modified (me: mutable; S : Shape from TopoDS) - returns ListOfShape from TopTools - is virtual; - ---C++: return const & - - IsDeleted (me: mutable; S : Shape from TopoDS) - returns Boolean from Standard - is virtual; - - HasGenerated (me) - returns Boolean from Standard - is virtual; - - HasModified (me) - returns Boolean from Standard - is virtual; - - HasDeleted (me) - returns Boolean from Standard - is virtual; - -fields - myEmptyList: ListOfShape from TopTools is protected; - myOp : Operation from BOP is protected; - myGenMap : DataMapOfShapeListOfShape from TopTools is protected; - myModifMap: DataMapOfShapeListOfShape from TopTools is protected; - myS1 : Shape from TopoDS is protected; - myS2 : Shape from TopoDS is protected; - myResult : Shape from TopoDS is protected; - myHasDeleted : Boolean from Standard is protected; - -end HistoryCollector from BOP; diff --git a/src/BOP/BOP_HistoryCollector.cxx b/src/BOP/BOP_HistoryCollector.cxx deleted file mode 100755 index 817ebb312c..0000000000 --- a/src/BOP/BOP_HistoryCollector.cxx +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include - -#include - -BOP_HistoryCollector::BOP_HistoryCollector() -{ - myOp = BOP_UNKNOWN; - myHasDeleted = Standard_False; -} - -BOP_HistoryCollector::BOP_HistoryCollector(const TopoDS_Shape& theShape1, - const TopoDS_Shape& theShape2, - const BOP_Operation theOperation) -{ - myOp = theOperation; - myS1 = theShape1; - myS2 = theShape2; - myHasDeleted = Standard_False; -} - -void BOP_HistoryCollector::SetResult(const TopoDS_Shape& theResult, - const BOPTools_PDSFiller& theDSFiller) -{ - myResult = theResult; -} - -const TopTools_ListOfShape& BOP_HistoryCollector::Generated(const TopoDS_Shape& S) -{ - if(S.IsNull()) - return myEmptyList; - - if(myGenMap.IsBound(S)) { - return myGenMap.Find(S); - } - return myEmptyList; -} - -const TopTools_ListOfShape& BOP_HistoryCollector::Modified(const TopoDS_Shape& S) -{ - if(S.IsNull()) - return myEmptyList; - - if(myModifMap.IsBound(S)) { - return myModifMap.Find(S); - } - return myEmptyList; -} - -Standard_Boolean BOP_HistoryCollector::IsDeleted(const TopoDS_Shape& S) -{ - if(S.IsNull()) - return Standard_True; - - TopAbs_ShapeEnum aType = S.ShapeType(); - TopExp_Explorer anExp(myResult, aType); - - for(; anExp.More(); anExp.Next()) { - if(S.IsSame(anExp.Current())) - return Standard_False; - } - - if(myModifMap.IsBound(S)) { - if(!myModifMap(S).IsEmpty()) - return Standard_False; - } - - if(myGenMap.IsBound(S)) { - if(!myGenMap(S).IsEmpty()) - return Standard_False; - } - return Standard_True; -} - -Standard_Boolean BOP_HistoryCollector::HasGenerated() const -{ - if(!myGenMap.IsEmpty()) { - return Standard_True; - } - return Standard_False; -} - -Standard_Boolean BOP_HistoryCollector::HasModified() const -{ - if(!myModifMap.IsEmpty()) { - return Standard_True; - } - return Standard_False; -} - -Standard_Boolean BOP_HistoryCollector::HasDeleted() const -{ - return myHasDeleted; -} diff --git a/src/BOP/BOP_Loop.cdl b/src/BOP/BOP_Loop.cdl deleted file mode 100755 index 2d6401160b..0000000000 --- a/src/BOP/BOP_Loop.cdl +++ /dev/null @@ -1,77 +0,0 @@ --- Created on: 1995-12-19 --- Created by: Jean Yves LEBEY --- Copyright (c) 1995-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class Loop from BOP inherits TShared from MMgt - - ---Purpose: - -- A Loop is an existing shape (Shell,Wire) or a set - -- of shapes (Faces,Edges) which are connex. - -- a set of connex shape is represented by a BlockIterator - -uses - - Shape from TopoDS, - BlockIterator from BOP, - ShapeEnum from TopAbs - -is - - Create(S : Shape from TopoDS) - returns mutable Loop; - ---Purpose: - --- Creates the object using the shape S; - --- - Create(BI : BlockIterator from BOP) - returns mutable Loop; - ---Purpose: - --- Creates the object using the BlockIterator BI; - --- - IsShape(me) - returns Boolean from Standard - is virtual; - ---Purpose: - --- Returns TRUE if the object was created using shape - --- - Shape(me) - returns Shape from TopoDS - is virtual; - ---C++: return const & - ---Purpose: - --- Returns Shape from which the object was created - --- Valid only when IsShape() is TRUE - --- - BlockIterator(me) - returns BlockIterator - is static; - ---C++: return const & - --- Returns BlockIterator from which the object was created - --- Valid only when IsShape() is FALSE - --- - -fields - myIsShape : Boolean from Standard - is protected; - myShape : Shape from TopoDS - is protected; - myBlockIterator : BlockIterator from BOP - is protected; - -end Loop from BOP; diff --git a/src/BOP/BOP_Loop.cxx b/src/BOP/BOP_Loop.cxx deleted file mode 100755 index 580230590b..0000000000 --- a/src/BOP/BOP_Loop.cxx +++ /dev/null @@ -1,74 +0,0 @@ -// Created on: 1995-12-19 -// Created by: Jean Yves LEBEY -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#include - -//======================================================================= -//function : BOP_Loop -//purpose : -//======================================================================= -BOP_Loop::BOP_Loop (const TopoDS_Shape& S) -: - myIsShape(Standard_True), - myShape(S), - myBlockIterator(0,0) -{ -} - -//======================================================================= -//function : BOP_Loop -//purpose : -//======================================================================= - BOP_Loop::BOP_Loop (const BOP_BlockIterator& BI) -: - myIsShape(Standard_False), - myBlockIterator(BI) -{ -} - -//======================================================================= -//function : IsShape -//purpose : -//======================================================================= - Standard_Boolean BOP_Loop::IsShape() const -{ - return myIsShape; -} - -//======================================================================= -//function : Shape -//purpose : -//======================================================================= - const TopoDS_Shape& BOP_Loop::Shape() const -{ - return myShape; -} - -//======================================================================= -//function : BlockIterator -//purpose : -//======================================================================= - const BOP_BlockIterator& BOP_Loop::BlockIterator() const -{ - return myBlockIterator; -} - - diff --git a/src/BOP/BOP_LoopClassifier.cdl b/src/BOP/BOP_LoopClassifier.cdl deleted file mode 100755 index 600ad60653..0000000000 --- a/src/BOP/BOP_LoopClassifier.cdl +++ /dev/null @@ -1,47 +0,0 @@ --- Created on: 1993-03-03 --- Created by: Jean Yves LEBEY --- Copyright (c) 1993-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -deferred class LoopClassifier from BOP - - ---Purpose: - -- Root class to classify Loops in order to build Areas - -uses - - ShapeEnum from TopAbs, - State from TopAbs, - Loop from BOP - -is - - Delete(me:out) is virtual; - ---C++: alias "Standard_EXPORT virtual ~BOP_LoopClassifier(){Delete() ; }" - ---Purpose: - --- Destructor; - --- - Compare(me : in out; L1,L2 : Loop from BOP) - returns State from TopAbs - is deferred; - ---Purpose: - --- Returns the state of loop compared with loop . - --- - -end LoopClassifier; diff --git a/src/BOP/BOP_LoopClassifier.cxx b/src/BOP/BOP_LoopClassifier.cxx deleted file mode 100755 index 7c5086c534..0000000000 --- a/src/BOP/BOP_LoopClassifier.cxx +++ /dev/null @@ -1,28 +0,0 @@ -// Created on: 1993-03-11 -// Created by: Jean Yves LEBEY -// Copyright (c) 1993-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#include - -//======================================================================= -//function : NextLoop -//purpose : -//======================================================================= -void BOP_LoopClassifier::Delete(){} diff --git a/src/BOP/BOP_LoopSet.cdl b/src/BOP/BOP_LoopSet.cdl deleted file mode 100755 index d2866aae66..0000000000 --- a/src/BOP/BOP_LoopSet.cdl +++ /dev/null @@ -1,77 +0,0 @@ --- Created on: 1993-03-23 --- Created by: Jean Yves LEBEY --- Copyright (c) 1993-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class LoopSet from BOP - - ---Purpose: - -- The auxiliary class to store and iterate on Loop(s) -uses - - Loop from BOP, - ListOfLoop from BOP, - ListIteratorOfListOfLoop from BOP - -is - - Create - returns LoopSet; - ---Purpose: - --- Empty constructor; - --- - Delete(me:out) - is virtual; - ---C++: alias "Standard_EXPORT virtual ~BOP_LoopSet(){Delete() ; }" - ---Purpose: - --- Destructor; - --- - ChangeListOfLoop(me : in out) - returns ListOfLoop - is static; - ---C++: return & - ---Purpose: - --- Modifier; - - --- - --- Exploration of the loops - --- - InitLoop(me : in out) - is virtual; - - MoreLoop(me) - returns Boolean - is virtual; - - NextLoop(me : in out) - is virtual; - - Loop(me) - returns Loop from BOP - is virtual; - ---C++: return const & - -fields - - myListOfLoop : ListOfLoop from BOP; - myLoopIterator : ListIteratorOfListOfLoop from BOP; - myLoopIndex : Integer from Standard; - myNbLoop : Integer from Standard; - -end LoopSet; diff --git a/src/BOP/BOP_LoopSet.cxx b/src/BOP/BOP_LoopSet.cxx deleted file mode 100755 index 2bca6b7e8e..0000000000 --- a/src/BOP/BOP_LoopSet.cxx +++ /dev/null @@ -1,83 +0,0 @@ -// Created on: 1993-03-23 -// Created by: Jean Yves LEBEY -// Copyright (c) 1993-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#include - -//======================================================================= -//function : BOP_LoopSet::BOP_LoopSet -//purpose : -//======================================================================= -BOP_LoopSet::BOP_LoopSet() -: - myLoopIndex(1), - myNbLoop(0) -{} -//======================================================================= -//function : Delete -//purpose : -//======================================================================= - void BOP_LoopSet::Delete() -{} -//======================================================================= -//function : InitLoop -//purpose : -//======================================================================= - void BOP_LoopSet::InitLoop() -{ - myLoopIterator.Initialize(myListOfLoop); - myLoopIndex = 1; - myNbLoop = myListOfLoop.Extent(); -} -//======================================================================= -//function : MoreLoop -//purpose : -//======================================================================= - Standard_Boolean BOP_LoopSet::MoreLoop() const -{ - Standard_Boolean b = myLoopIterator.More(); - return b; -} -//======================================================================= -//function : NextLoop -//purpose : -//======================================================================= - void BOP_LoopSet::NextLoop() -{ - myLoopIndex++; - myLoopIterator.Next(); -} -//======================================================================= -//function : Loop -//purpose : -//======================================================================= - const Handle(BOP_Loop)& BOP_LoopSet::Loop() const -{ - const Handle(BOP_Loop)& L = myLoopIterator.Value(); - return L; -} -//======================================================================= -//function : ChangeListOfLoop -//purpose : -//======================================================================= - BOP_ListOfLoop& BOP_LoopSet::ChangeListOfLoop() -{ - return myListOfLoop; -} diff --git a/src/BOP/BOP_Refiner.cdl b/src/BOP/BOP_Refiner.cdl deleted file mode 100755 index ea7f3a9857..0000000000 --- a/src/BOP/BOP_Refiner.cdl +++ /dev/null @@ -1,103 +0,0 @@ --- Created on: 2001-12-24 --- Created by: Peter KURNEV --- Copyright (c) 2001-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class Refiner from BOP - - ---Purpose: - -- The algorithm to provide the refinition - -- for a resulting shape of Boolean Operation - -- algorithm. - -- (not completed yet) - - -uses - Shape from TopoDS, - ListOfShape from TopTools - ---raises - -is - Create - returns Refiner from BOP; - ---Purpose: - --- Empty constructor; - --- - Create(aS: Shape from TopoDS) - returns Refiner from BOP; - ---Purpose: - --- Constructor; - --- - SetShape(me:out; - aS: Shape from TopoDS); - ---Purpose: - --- Modifier - --- - SetInternals (me:out; - aLS:ListOfShape from TopTools); - ---Purpose: - --- Modifier - --- - Do(me:out); - ---Purpose: - --- Performs the algorithm - --- - IsDone(me) - returns Boolean from Standard; - ---Purpose: - --- Selector - --- - ErrorStatus(me) - returns Integer from Standard; - ---Purpose: - --- Selector - --- - Shape(me) - returns Shape from TopoDS; - ---C++: return const & - ---Purpose: - --- Selector - --- - NbRemovedVertices(me) - returns Integer from Standard; - ---Purpose: - --- Selector - --- - NbRemovedEdges(me) - returns Integer from Standard; - ---Purpose: - --- Selector - --- - DoInternals(me:out) is private; - ---Purpose: - --- Internal usage - --- - - -fields - - myShape : Shape from TopoDS; - myIsDone : Boolean from Standard; - myErrorStatus : Integer from Standard; - myNbRemovedVertices : Integer from Standard; - myNbRemovedEdges : Integer from Standard; - myInternals : ListOfShape from TopTools; - -end Refiner; diff --git a/src/BOP/BOP_Refiner.cxx b/src/BOP/BOP_Refiner.cxx deleted file mode 100755 index fb72599398..0000000000 --- a/src/BOP/BOP_Refiner.cxx +++ /dev/null @@ -1,314 +0,0 @@ -// Created on: 2001-12-24 -// Created by: Peter KURNEV -// Copyright (c) 2001-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include - -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include - - -//======================================================================= -// function: BOP_Refiner::BOP_Refiner -// purpose: -//======================================================================= -BOP_Refiner::BOP_Refiner() -: - myIsDone(Standard_False), - myErrorStatus(1), - myNbRemovedVertices(0), - myNbRemovedEdges(0) -{} -//======================================================================= -// function: BOP_Refiner::BOP_Refiner -// purpose: -//======================================================================= - BOP_Refiner::BOP_Refiner(const TopoDS_Shape& aS) -: - myIsDone(Standard_False), - myErrorStatus(1), - myNbRemovedVertices(0), - myNbRemovedEdges(0) -{ - myShape=aS; -} - -//======================================================================= -// function: SetShape -// purpose: -//======================================================================= - void BOP_Refiner::SetShape (const TopoDS_Shape& aS) -{ - myShape=aS; -} -//======================================================================= -// function: SetInternals -// purpose: -//======================================================================= - void BOP_Refiner::SetInternals (const TopTools_ListOfShape& aLS) -{ - myInternals.Clear(); - TopTools_ListIteratorOfListOfShape anIt(aLS); - for(; anIt.More(); anIt.Next()) { - const TopoDS_Shape& aS=anIt.Value(); - myInternals.Append(aS); - } -} -//======================================================================= -// function: IsDone -// purpose: -//======================================================================= - Standard_Boolean BOP_Refiner::IsDone() const -{ - return myIsDone; -} -//======================================================================= -// function: ErrorStatus -// purpose: -//======================================================================= - Standard_Integer BOP_Refiner::ErrorStatus() const -{ - return myErrorStatus; -} -//======================================================================= -// function: Shape -// purpose: -//======================================================================= - const TopoDS_Shape& BOP_Refiner::Shape() const -{ - return myShape; -} -//======================================================================= -// function: NbRemovedVertices -// purpose: -//======================================================================= - Standard_Integer BOP_Refiner::NbRemovedVertices() const -{ - return myNbRemovedVertices; -} -//======================================================================= -// function: NbRemovedEdges -// purpose: -//======================================================================= - Standard_Integer BOP_Refiner::NbRemovedEdges() const -{ - return myNbRemovedEdges; -} -//======================================================================= -// function: Do -// purpose: -//======================================================================= - void BOP_Refiner::Do() -{ - DoInternals(); -} -//======================================================================= -// function: DoInternals -// purpose: -//======================================================================= - void BOP_Refiner::DoInternals() -{ - Standard_Integer i, aNb, aNbF, aNbE; - BRep_Builder aBB; - TopTools_IndexedDataMapOfShapeListOfShape aMVF, aMFV, aMVE; - TopTools_IndexedMapOfShape aMInternals; - // - // 0. Source Internals - TopTools_ListIteratorOfListOfShape anItx(myInternals); - for(; anItx.More(); anItx.Next()) { - const TopoDS_Shape& aS=anItx.Value(); - aMInternals.Add(aS); - } - // - // 1. Vertices - TopExp::MapShapesAndAncestors(myShape, TopAbs_VERTEX, TopAbs_EDGE, aMVE); - TopExp::MapShapesAndAncestors(myShape, TopAbs_VERTEX, TopAbs_FACE, aMVF); - - aNb=aMVF.Extent(); - for (i=1; i<=aNb; ++i) { - const TopoDS_Vertex& aV=TopoDS::Vertex(aMVF.FindKey(i)); - - if (aV.Orientation()!=TopAbs_INTERNAL) { - continue; - } - // how many edges attached to the vertex ? - aNbE=aMVE.FindFromKey(aV).Extent(); - - if (aNbE) { - continue; - } - - const TopTools_ListOfShape& aLF=aMVF(i); - // how many edges attached to the vertex ? - aNbF=aLF.Extent(); - if (aNbF==1) { - const TopoDS_Face& aF=TopoDS::Face(aLF.First()); - - if (aMFV.Contains(aF)) { - TopTools_ListOfShape& aLFWithVertex=aMFV.ChangeFromKey(aF); - aLFWithVertex.Append(aV); - } - else { - TopTools_ListOfShape aLFWithVertex; - aLFWithVertex.Append(aV); - aMFV.Add(aF, aLFWithVertex); - } - }// if (aNbF==1) - }// for (i=1; i<=aNb; ++i) - - aNbF=aMFV.Extent(); - for (i=1; i<=aNbF; ++i) { - const TopoDS_Face& aF=TopoDS::Face(aMFV.FindKey(i)); - TopoDS_Face* pF=(TopoDS_Face*)&aF; - - const TopTools_ListOfShape& aLV=aMFV(i); - TopTools_ListIteratorOfListOfShape anIt(aLV); - for (; anIt.More(); anIt.Next()) { - const TopoDS_Vertex& aV=TopoDS::Vertex(anIt.Value()); - // - if (aMInternals.Contains(aV)) { - continue; - } - // - pF->Free(Standard_True); - aBB.Remove(*pF, aV); - myNbRemovedVertices++; - } - } - // - // 2. Edges - TopTools_IndexedDataMapOfShapeListOfShape aMEF, aMFE; - TopExp::MapShapesAndAncestors(myShape, TopAbs_EDGE, TopAbs_FACE, aMEF); - - aNb=aMEF.Extent(); - for (i=1; i<=aNb; ++i) { - const TopoDS_Edge& aE=TopoDS::Edge(aMEF.FindKey(i)); - if (aE.Orientation()!=TopAbs_INTERNAL) { - continue; - } - const TopTools_ListOfShape& aLF=aMEF(i); - aNbF=aLF.Extent(); - if (aNbF==1) { - const TopoDS_Face& aF=TopoDS::Face(aLF.First()); - - if (aMFE.Contains(aF)) { - TopTools_ListOfShape& aLFWithEdge=aMFE.ChangeFromKey(aF); - aLFWithEdge.Append(aE); - } - else { - TopTools_ListOfShape aLFWithEdge; - aLFWithEdge.Append(aE); - aMFE.Add(aF, aLFWithEdge); - } - }// if (aNbF==1) - }// for (i=1; i<=aNb; ++i) - // - //modified by NIZNHY-PKV Wed Nov 03 14:27:22 2010f - Standard_Boolean bFound; - TopoDS_Iterator aItS; - TopAbs_Orientation aOr; - //modified by NIZNHY-PKV Wed Nov 03 14:27:24 2010t - // - aNbF=aMFE.Extent(); - for (i=1; i<=aNbF; ++i) { - //modified by NIZNHY-PKV Wed Nov 03 14:29:03 2010f - TopoDS_Face aF=TopoDS::Face(aMFE.FindKey(i)); - aOr=aF.Orientation(); - if (aOr==TopAbs_INTERNAL) { - aF.Orientation(TopAbs_FORWARD); - } - //const TopoDS_Face& aF=TopoDS::Face(aMFE.FindKey(i)); - //modified by NIZNHY-PKV Wed Nov 03 14:29:06 2010t - TopoDS_Face* pF=(TopoDS_Face*)&aF; - - const TopTools_ListOfShape& aLE=aMFE(i); - TopTools_ListIteratorOfListOfShape anIt(aLE); - for (; anIt.More(); anIt.Next()) { - const TopoDS_Edge& aE=TopoDS::Edge(anIt.Value()); - // - if (aMInternals.Contains(aE)) { - continue; - } - // - TopTools_IndexedDataMapOfShapeListOfShape aMEW; - TopExp::MapShapesAndAncestors(aF, TopAbs_EDGE, TopAbs_WIRE, aMEW); - // - if (aMEW.Contains(aE)) { - const TopTools_ListOfShape& aLW=aMEW.FindFromKey(aE); - TopTools_ListIteratorOfListOfShape aWIt(aLW); - for (; aWIt.More(); aWIt.Next()) { - const TopoDS_Wire& aW=TopoDS::Wire(aWIt.Value()); - // - //modified by NIZNHY-PKV Wed Nov 03 14:12:48 2010f - bFound=Standard_False; - aItS.Initialize(aW); - for(; aItS.More(); aItS.Next()) { - const TopoDS_Shape& aEW=aItS.Value(); - if (aEW==aE) { - bFound=Standard_True; - break; - } - } - // - if (!bFound) { - continue; - } - //modified by NIZNHY-PKV Wed Nov 03 14:14:22 2010t - // - TopoDS_Wire* pW=(TopoDS_Wire*)&aW; - pW->Free(Standard_True); - // - TopExp_Explorer anExp(*pW, TopAbs_EDGE); - for (; anExp.More(); anExp.Next()) { - const TopoDS_Edge& anEdge=TopoDS::Edge(anExp.Current()); - aBB.Remove(*pW, anEdge); - anExp.Init(*pW, TopAbs_EDGE); - } - // - pF->Free(Standard_True); - aBB.Remove(*pF, aW); - //modified by NIZNHY-PKV Wed Nov 03 14:29:56 2010f - pF->Orientation(aOr); - //modified by NIZNHY-PKV Wed Nov 03 14:29:59 2010t - myNbRemovedEdges++; - } - } - }// next inernal edge - }// for (i=1; i<=aNbF; ++i) - myIsDone=!myIsDone; -} -// myErrorStatus: -// 0 - OK -// 1 - Nothing has been done after constructor -// diff --git a/src/BOP/BOP_SDFWESFiller.cdl b/src/BOP/BOP_SDFWESFiller.cdl deleted file mode 100755 index 60b0c94bff..0000000000 --- a/src/BOP/BOP_SDFWESFiller.cdl +++ /dev/null @@ -1,219 +0,0 @@ --- Created on: 2001-06-06 --- Created by: Peter KURNEV --- Copyright (c) 2001-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class SDFWESFiller from BOP - - ---Purpose: - -- The algorithm that fills a wire edges set (WES) - -- for a couple of faces that are same domain - --- - -uses - Face from TopoDS, - ListOfShape from TopTools, - DSFiller from BOPTools, - PDSFiller from BOPTools, - IndexedDataMapOfIntegerState from BOPTools, - - Operation from BOP, - WireEdgeSet from BOP, - PWireEdgeSet from BOP - - ---raises - -is - Create - returns SDFWESFiller from BOP; - ---Purpose: - --- Empty constructor - --- - Create (nF1: Integer from Standard; - nF2: Integer from Standard; - aDSF: DSFiller from BOPTools); - ---Purpose: - --- Constructor - --- nF1, nF2 - indices of faces in the DataStructue (DS) - --- - SetStatesMap(me:out; - aStatesMap: IndexedDataMapOfIntegerState from BOPTools); - ---Purpose: - --- Modifier - --- - SetFaces(me:out; - nF1: Integer from Standard; - nF2: Integer from Standard); - ---Purpose: - --- Modifier - --- - SetDSFiller(me:out; - aDSF: DSFiller from BOPTools); - ---Purpose: - --- Modifier - --- - SetOperation (me:out; - anOp:Operation from BOP); - ---Purpose: - --- Modifier - --- - SetSenseFlag (me:out; - aFlag:Integer from Standard); - ---Purpose: - --- Modifier - --- Assigns sensitivity flag for the faces in accordance - --- with scalar product between theirs normalls - --- 1 for same sense; -1 for different sense - --- - - Prepare(me:out); - ---Purpose: - --- Prepares data for the algorithm - --- - Do (me:out; - aWES:WireEdgeSet from BOP); - ---Purpose: - --- Performs the algorithm - --- - DSFiller(me) - returns DSFiller from BOPTools; - ---C++: return const & - ---Purpose: - --- Selector - --- - StatesMap(me) - returns IndexedDataMapOfIntegerState from BOPTools; - ---C++: return const & - ---Purpose: - --- Selector - --- - Faces(me; - nF1:out Integer from Standard; - nF2:out Integer from Standard); - ---Purpose: - --- Selector - --- - SenseFlag (me) - returns Integer from Standard; - ---Purpose: - --- Selector - --- - Operation (me) - returns Operation from BOP; - ---Purpose: - --- Selector - --- - AssignStates (me:out; - nF1: Integer from Standard; - nF2: Integer from Standard) - is private; - ---Purpose: - --- Assigns the 2D-State for split parts of - --- the edges having 3D-Curves of given faces - --- Internal Purpose - --- - PrepareOnParts(me:out) - is private; - ---Purpose: - --- Prepares ON 2D parts to filled the WES - --- Internal Purpose - --- - PrepareWESForZone(me:out; - nF1: Integer from Standard; - nF2: Integer from Standard) - is private; - ---Purpose: - --- Fills the WES by split parts of the edges for - --- the Common Zone - --- Internal Purpose - --- - PrepareWESForCut(me:out; - nF1: Integer from Standard; - nF2: Integer from Standard) - is private; - ---Purpose: - --- Fills the WES by split parts of the edges for - --- the Cut operation - --- Internal Purpose - --- - PrepareOnParts(me:out; - nF1: Integer from Standard; - nF2: Integer from Standard; - Op : Operation from BOP) - is private; - ---Purpose: - --- Fills the WES by split parts (ON 2D) of the edges - --- Internal Purpose - --- - PrepareFaces(me; - nF1: Integer from Standard; - nF2: Integer from Standard; - aF1:out Face from TopoDS; - aF2:out Face from TopoDS) - is private; - ---Purpose: - --- Make orientation of the faces consistent - --- Internal Purpose - --- - AssignDEStates (me:out; - nF1: Integer from Standard; - nF2: Integer from Standard) - is private; - ---Purpose: - --- Assigns the 2D-State for split parts of - --- the edges that do not have 3D-Curves of given faces - --- Internal Purpose - --- - AssignDEStates (me:out; - nF1: Integer from Standard; - nE1: Integer from Standard; - nF2: Integer from Standard) - is private; - ---Purpose: - --- Assigns the 2D-State for split parts of - --- the edge nE1 that do not have 3D-Curves from face nF1 - --- - --- Internal Purpose - --- - UpdateDEStates3D (me:out); - ---Purpose: - --- Update 3D-State for edges - --- - RejectedOnParts(me) - returns ListOfShape from TopTools; - ---C++: return const & - ---Purpose: - -- Returns all split edges of nF1 that are CB with - -- splis of nF1 but not included in myWES, - -fields - - myDSFiller : PDSFiller from BOPTools; - myOperation : Operation from BOP; - myNF1 : Integer from Standard; - myNF2 : Integer from Standard; - - myWES : PWireEdgeSet from BOP; - myStatesMap: IndexedDataMapOfIntegerState from BOPTools; - mySenseFlag: Integer from Standard; - myRejectedOnParts: ListOfShape from TopTools; - -end SDFWESFiller; - diff --git a/src/BOP/BOP_SDFWESFiller.cxx b/src/BOP/BOP_SDFWESFiller.cxx deleted file mode 100755 index 33e0c1f14a..0000000000 --- a/src/BOP/BOP_SDFWESFiller.cxx +++ /dev/null @@ -1,1367 +0,0 @@ -// Created on: 2001-06-06 -// Created by: Peter KURNEV -// Copyright (c) 2001-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#include - -#include - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -static Standard_Boolean IsValidSeam(const TopoDS_Edge& aE, - const TopoDS_Face& aF, - const Standard_Real aT, - const Handle(IntTools_Context)& aContext); - -static void CorrespondantSeam(const TopoDS_Edge& aSpE1Seam11, - const Standard_Real aT1, - const TopoDS_Edge& aSpE1Seam21, - const TopoDS_Edge& aSpE1Seam22, - const Standard_Real aT2, - const TopoDS_Face& aF1FWD, - TopoDS_Edge& aSS); - -static void TreatSDSeams (const TopoDS_Edge& aSpE1Seam11, - const Standard_Real aT1, - const TopoDS_Face& aF1FWD, - const TopoDS_Edge& aSpE1Seam21, - const Standard_Real aT2, - const TopoDS_Face& aF2FWD, - const Standard_Boolean bIsTakenSp1, - BOP_WireEdgeSet& aWES, - const Handle(IntTools_Context)& aContext); - -//modified by NIZNHY-PKV Tue Sep 25 14:26:14 2012f -static - Standard_Boolean IsClosed(const TopoDS_Edge& aE, - const TopoDS_Face& aF); -//modified by NIZNHY-PKV Tue Sep 25 14:26:17 2012t - -//======================================================================= -// function: BOP_SDFWESFiller::BOP_SDFWESFiller -// purpose: -//======================================================================= - BOP_SDFWESFiller::BOP_SDFWESFiller() -: - myDSFiller(NULL), - myOperation(BOP_UNKNOWN), - myNF1(0), - myNF2(0), - mySenseFlag(0) -{} - -//======================================================================= -// function: BOP_SDFWESFiller::BOP_SDFWESFiller -// purpose: -//======================================================================= - BOP_SDFWESFiller::BOP_SDFWESFiller(const Standard_Integer nF1, - const Standard_Integer nF2, - const BOPTools_DSFiller& aDSFiller) -: - myNF1(nF1), - myNF2(nF2), - mySenseFlag(0) -{ - myDSFiller=(BOPTools_DSFiller*) &aDSFiller; - Prepare(); -} -//======================================================================= -// function: SetStatesMap -// purpose: -//======================================================================= - void BOP_SDFWESFiller::SetStatesMap (const BOPTools_IndexedDataMapOfIntegerState& aMap) -{ - myStatesMap.Clear(); - myStatesMap=aMap; -} -//======================================================================= -// function: StatesMap -// purpose: -//======================================================================= - const BOPTools_IndexedDataMapOfIntegerState& BOP_SDFWESFiller::StatesMap ()const -{ - return myStatesMap; -} - -//======================================================================= -// function: SetFaces -// purpose: -//======================================================================= - void BOP_SDFWESFiller::SetFaces (const Standard_Integer nF1, - const Standard_Integer nF2) -{ - myNF1=nF1; - myNF2=nF2; -} -//======================================================================= -// function: SetSenseFlag -// purpose: -//======================================================================= - void BOP_SDFWESFiller::SetSenseFlag (const Standard_Integer iFlag) - -{ - mySenseFlag=iFlag; -} - -//======================================================================= -// function: SenseFlag -// purpose: -//======================================================================= - Standard_Integer BOP_SDFWESFiller::SenseFlag () const - -{ - return mySenseFlag; -} - -//======================================================================= -// function: Faces -// purpose: -//======================================================================= - void BOP_SDFWESFiller::Faces (Standard_Integer& nF1, - Standard_Integer& nF2) const -{ - nF1=myNF1; - nF2=myNF2; -} -//======================================================================= -// function: SetDSFiller -// purpose: -//======================================================================= - void BOP_SDFWESFiller::SetDSFiller(const BOPTools_DSFiller& aDSFiller) -{ - myDSFiller=(BOPTools_DSFiller*) &aDSFiller; -} - -//======================================================================= -// function: DSFiller -// purpose: -//======================================================================= - const BOPTools_DSFiller& BOP_SDFWESFiller::DSFiller()const -{ - return *myDSFiller; -} - -//======================================================================= -// function: SetOperation -// purpose: -//======================================================================= - void BOP_SDFWESFiller::SetOperation(const BOP_Operation anOp) -{ - myOperation=anOp; -} -//======================================================================= -// function: Operation -// purpose: -//======================================================================= - BOP_Operation BOP_SDFWESFiller::Operation()const -{ - return myOperation; -} -//xf -//======================================================================= -//function : RejectedOnParts -//purpose : -//======================================================================= - const TopTools_ListOfShape& BOP_SDFWESFiller::RejectedOnParts()const -{ - return myRejectedOnParts; -} -//xt -//======================================================================= -// function: Prepare -// purpose: -//======================================================================= - void BOP_SDFWESFiller::Prepare() -{ - if (!myNF1 || !myNF2) { - return; - } - // - // 1. Prepare States 2D for the Faces' entities (myStatesMap) - AssignStates(myNF1, myNF2); - AssignStates(myNF2, myNF1); - // - AssignDEStates(myNF1, myNF2); - AssignDEStates(myNF2, myNF1); - // - // - // 2. - PrepareOnParts(); - // -} - -//======================================================================= -// function: Do -// purpose: -//======================================================================= - void BOP_SDFWESFiller::Do(const BOP_WireEdgeSet& pWES) -{ - - myWES=(BOP_WireEdgeSet*) &pWES; - - if (!myNF1 || !myNF2) { - return; - } - - // - // WES - switch (myOperation) { - case BOP_COMMON: { - PrepareWESForZone (myNF1, myNF2); - break; - } - case BOP_CUT: { - PrepareWESForCut (myNF1, myNF2); - break; - } - case BOP_CUT21: { - PrepareWESForCut (myNF2, myNF1); - break; - } - default: { - return; - } - } -} - -//======================================================================= -// function: AssignStates -// purpose: -//======================================================================= - void BOP_SDFWESFiller::AssignStates(const Standard_Integer nF1, - const Standard_Integer nF2) -{ - const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); - const BOPTools_PaveFiller& aPaveFiller=myDSFiller->PaveFiller(); - BOPTools_PaveFiller* pPaveFiller=(BOPTools_PaveFiller*) &aPaveFiller; - const BOPTools_SplitShapesPool& aSplitShapesPool=aPaveFiller.SplitShapesPool(); - // - Standard_Integer aBid=0, nSplit, nE, nW, nSp, anEdgeFlag, aWireFlag, aNbPB, iRankF1; - TColStd_ListOfInteger aList1IN2, aList1ON2; - TColStd_IndexedMapOfInteger aSpMapIN, aSpMapON; - TColStd_ListIteratorOfListOfInteger anIt; - // - iRankF1=aDS.Rank(nF1); - // - const TopoDS_Face& aF1=TopoDS::Face(aDS.Shape(nF1)); - // - // Splits that are from nF2 and are IN2D for nF2 - pPaveFiller->SplitsInFace (aBid, nF1, nF2, aList1IN2); - - anIt.Initialize(aList1IN2); - for (; anIt.More(); anIt.Next()) { - nSplit=anIt.Value(); - aSpMapIN.Add(nSplit); - } - // - // that are from nF2 and are ON2D for nF2 - pPaveFiller->SplitsOnFace (aBid, nF1, nF2, aList1ON2); - - anIt.Initialize(aList1ON2); - for (; anIt.More(); anIt.Next()) { - nSplit=anIt.Value(); - aSpMapON.Add(nSplit); - } - // - // Treatment of the Face's entities - aWireFlag=1; - TopExp_Explorer anExpWire(aF1, TopAbs_WIRE); - for (; anExpWire.More(); anExpWire.Next()) { - const TopoDS_Shape& aWire=anExpWire.Current(); - nW=aDS.ShapeIndex(aWire, iRankF1); - anEdgeFlag=1; - - TopExp_Explorer anExpEdge (aWire, TopAbs_EDGE); - for (; anExpEdge.More(); anExpEdge.Next()) { - const TopoDS_Shape& anEdge=anExpEdge.Current(); - nE=aDS.ShapeIndex(anEdge, iRankF1); - - const BOPTools_ListOfPaveBlock& aLPB=aSplitShapesPool(aDS.RefEdge(nE)); - - aNbPB=aLPB.Extent(); - if (!aNbPB) { - // the whole edge is OUT - myStatesMap.Add(nE, BooleanOperations_OUT); - continue; - } - - BOPTools_ListIteratorOfListOfPaveBlock aPBIt(aLPB); - - for (; aPBIt.More(); aPBIt.Next()) { - const BOPTools_PaveBlock& aPB=aPBIt.Value(); - nSp=aPB.Edge(); - - if (aSpMapIN.Contains(nSp)) {// IN - myStatesMap.Add(nSp, BooleanOperations_IN); - anEdgeFlag=0; - } - else if (aSpMapON.Contains(nSp)) {// ON - myStatesMap.Add(nSp, BooleanOperations_ON); - anEdgeFlag=0; - } - else {// if (nSp!=nE) {// OUT - myStatesMap.Add(nSp, BooleanOperations_OUT); - } - } - } // enf of for (; anExpEdge.More(); anExpEdge.Next()) - - if (anEdgeFlag) {// all Wire is out - myStatesMap.Add(nW, BooleanOperations_OUT); - } - else { - aWireFlag=0; - } - } // enf of for (; anExpEdge.More(); anExpEdge.Next()) - - if (aWireFlag) { // all Face is out of nF2 - myStatesMap.Add(nF1, BooleanOperations_OUT); - } -} - -//======================================================================= -// function: PrepareOnParts -// purpose: -//======================================================================= - void BOP_SDFWESFiller::PrepareOnParts () -{ - const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); - const BOPTools_PaveFiller& aPaveFiller=myDSFiller->PaveFiller(); - BOPTools_PaveFiller* pPaveFiller=(BOPTools_PaveFiller*) &aPaveFiller; - BOPTools_CommonBlockPool& aCBPool=pPaveFiller->ChangeCommonBlockPool(); - // - Standard_Integer aBid=0, nE1, nE2, aNbSpON, nSp1, nSp2, iRankF1; - Standard_Real aT1, aT2, aT, aTs; /*, U, V;*/ - Standard_Boolean aFlag; - TColStd_ListOfInteger aLs; - TColStd_IndexedMapOfInteger aMap; - TopExp_Explorer anExpF1, anExpF2; - // - iRankF1=aDS.Rank(myNF1); - - gp_Pnt aPx1; - // - TopoDS_Face aF1FWD, aF2FWD; - PrepareFaces(myNF1, myNF2, aF1FWD, aF2FWD); - // - // Process - anExpF1.Init(aF1FWD, TopAbs_EDGE); - for (; anExpF1.More(); anExpF1.Next()) { - const TopoDS_Edge& anE1=TopoDS::Edge(anExpF1.Current()); - // - if (BRep_Tool::Degenerated(anE1)){ - continue; - } - // - nE1=aDS.ShapeIndex(anE1, iRankF1); - - aLs.Clear(); - pPaveFiller->SplitsOnFace(nE1, myNF2, aLs); - - aNbSpON=aLs.Extent(); - if (!aNbSpON) { - continue; - } - - aMap.Clear(); - TColStd_ListIteratorOfListOfInteger anItLs(aLs); - for (; anItLs.More(); anItLs.Next()) { - aBid=anItLs.Value(); - aMap.Add(aBid); - } - - BOPTools_ListOfCommonBlock& aLCB=aCBPool(aDS.RefEdge(nE1)); - BOPTools_ListIteratorOfListOfCommonBlock anItCB(aLCB); - for (; anItCB.More(); anItCB.Next()) { - BOPTools_CommonBlock& aCB=anItCB.Value(); - BOPTools_PaveBlock& aPB1=aCB.PaveBlock1(nE1); - nSp1=aPB1.Edge(); - if (aMap.Contains(nSp1)) { - // - // aPB1 - aPB1.Parameters(aT1, aT2); - aT=BOPTools_Tools2D::IntermediatePoint(aT1, aT2); - BOPTools_Tools::PointOnEdge(anE1, aT, aPx1); - - BOPTools_PointBetween aPointBetween; - aPointBetween.SetParameter(aT); - aPointBetween.SetPnt(aPx1); - - aPB1.SetPointBetween(aPointBetween); - // - // aPB2 - BOPTools_PaveBlock& aPB2=aCB.PaveBlock2(nE1); - nE2=aPB2.OriginalEdge(); - nSp2=aPB2.Edge(); - const TopoDS_Edge& anE2=TopoDS::Edge(aDS.GetShape(nE2)); - // - const Handle(IntTools_Context)& aContext=pPaveFiller->Context(); - aFlag=aContext->ProjectPointOnEdge(aPx1, anE2, aTs); - // - if (!aFlag) { - BOPTColStd_Dump::PrintMessage(" BOP_SDFWESFiller::PrepareOnParts() failed\n"); - return; - } - - aPointBetween.SetParameter(aTs); - aPointBetween.SetPnt(aPx1); - - aPB2.SetPointBetween(aPointBetween); - // - BOPTools_ListOfCommonBlock& aLCB2=aCBPool(aDS.RefEdge(nE2)); - BOPTools_ListIteratorOfListOfCommonBlock anItCB2(aLCB2); - for (; anItCB2.More(); anItCB2.Next()){ - BOPTools_CommonBlock& aCB2=anItCB2.Value(); - BOPTools_PaveBlock& aPB21=aCB2.PaveBlock1(nE2); - BOPTools_PaveBlock& aPB22=aCB2.PaveBlock2(nE2); - - if ((aPB21.IsEqual(aPB1) && aPB22.IsEqual(aPB2)) - || - (aPB21.IsEqual(aPB2) && aPB22.IsEqual(aPB1))) { - - aPointBetween.SetPnt(aPx1); - - aPointBetween.SetParameter(aTs); - aPB21.SetPointBetween(aPointBetween); - - aPointBetween.SetParameter(aT); - aPB22.SetPointBetween(aPointBetween); - - break; - } - } - // - } - } - } -} - -//======================================================================= -// function: PrepareWESForZone -// purpose: -//======================================================================= - void BOP_SDFWESFiller::PrepareWESForZone (const Standard_Integer nF1, - const Standard_Integer nF2) -{ - const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); - const BOPTools_PaveFiller& aPaveFiller=myDSFiller->PaveFiller(); - const BOPTools_SplitShapesPool& aSplitShapesPool=aPaveFiller.SplitShapesPool(); - BOP_WireEdgeSet& aWES=*myWES; - // - Standard_Integer nE, nSp, iRankF1, iRankF2; - - TopAbs_Orientation anOr; - BooleanOperations_StateOfShape aState; - TopTools_IndexedMapOfOrientedShape aMap; - // - iRankF1=aDS.Rank(nF1); - iRankF2=aDS.Rank(nF2); - // W E S - TopoDS_Face aF1FWD, aF2FWD; - PrepareFaces(nF1, nF2, aF1FWD, aF2FWD); - - TopExp_Explorer anExp; - // - // aF1FWD - anExp.Init(aF1FWD, TopAbs_EDGE); - for (; anExp.More(); anExp.Next()) { - const TopoDS_Shape& anE=anExp.Current(); - anOr=anE.Orientation(); - - nE=aDS.ShapeIndex(anE, iRankF1); - - const BOPTools_ListOfPaveBlock& aLPB=aSplitShapesPool(aDS.RefEdge(nE)); - BOPTools_ListIteratorOfListOfPaveBlock aPBIt(aLPB); - for (; aPBIt.More(); aPBIt.Next()) { - const BOPTools_PaveBlock& aPB=aPBIt.Value(); - nSp=aPB.Edge(); - //>>> - if (!myStatesMap.Contains(nSp)) { - continue; - } - //>>> - aState=myStatesMap.FindFromKey(nSp); - - if (aState==BooleanOperations_IN) { - - const TopoDS_Shape& aSplit=aDS.Shape(nSp); - TopoDS_Edge aSS=TopoDS::Edge(aSplit); - aSS.Orientation(anOr); - // - if (aMap.Contains(aSS)) { - continue; - } - // - aWES.AddStartElement (aSS); - aMap.Add(aSS); - - if (BRep_Tool::IsClosed(aSS, aF1FWD)){ - TopoDS_Shape EE=aSS.Reversed(); - aWES.AddStartElement (EE); - aMap.Add(EE); - } - } - } - } - // - // aF2FWD - aMap.Clear(); - anExp.Init(aF2FWD, TopAbs_EDGE); - for (; anExp.More(); anExp.Next()) { - const TopoDS_Shape& anE=anExp.Current(); - - anOr=anE.Orientation(); - - nE=aDS.ShapeIndex(anE, iRankF2); - - const BOPTools_ListOfPaveBlock& aLPB=aSplitShapesPool(aDS.RefEdge(nE)); - - BOPTools_ListIteratorOfListOfPaveBlock aPBIt(aLPB); - for (; aPBIt.More(); aPBIt.Next()) { - const BOPTools_PaveBlock& aPB=aPBIt.Value(); - nSp=aPB.Edge(); - //>>> - if (!myStatesMap.Contains(nSp)) { - continue; - } - //>>> - aState=myStatesMap.FindFromKey(nSp); - - if (aState==BooleanOperations_IN) { - const TopoDS_Shape& aSplit=aDS.Shape(nSp); - TopoDS_Edge aSS=TopoDS::Edge(aSplit); - // - if (!BOPTools_Tools2D::HasCurveOnSurface(aSS, aF1FWD)) { - continue; - } - // - aSS.Orientation(anOr); - // - if (aMap.Contains(aSS)) { - continue; - } - // - aWES.AddStartElement (aSS); - aMap.Add(aSS); - - if (BRep_Tool::IsClosed(aSS, aF2FWD)){ - TopoDS_Shape EE=aSS.Reversed(); - aWES.AddStartElement (EE); - aMap.Add(EE); - } - } - } - } - - PrepareOnParts(nF1, nF2, BOP_COMMON); -} - -//======================================================================= -// function: PrepareWESForCut -// purpose: -//======================================================================= - void BOP_SDFWESFiller::PrepareWESForCut (const Standard_Integer nF1, - const Standard_Integer nF2) -{ - const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); - const BOPTools_PaveFiller& aPaveFiller=myDSFiller->PaveFiller(); - const BOPTools_SplitShapesPool& aSplitShapesPool=aPaveFiller.SplitShapesPool(); - BOP_WireEdgeSet& aWES=*myWES; - // - Standard_Integer nE, nSp, nPB, iRankF2; - TopAbs_Orientation anOr; - BooleanOperations_StateOfShape aState; - - iRankF2=aDS.Rank(nF2); - // - // W E S - TopoDS_Face aF1FWD, aF2FWD; - PrepareFaces(nF1, nF2, aF1FWD, aF2FWD); - - aF2FWD.Reverse(); - - TopExp_Explorer anExp; - // - // aF2FWD - anExp.Init(aF2FWD, TopAbs_EDGE); - for (; anExp.More(); anExp.Next()) { - const TopoDS_Shape& anE=anExp.Current(); - anOr=anE.Orientation(); - - nE=aDS.ShapeIndex(anE, iRankF2); - - const BOPTools_ListOfPaveBlock& aLPB=aSplitShapesPool(aDS.RefEdge(nE)); - - nPB=aLPB.Extent(); - if (nPB) { - BOPTools_ListIteratorOfListOfPaveBlock aPBIt(aLPB); - for (; aPBIt.More(); aPBIt.Next()) { - const BOPTools_PaveBlock& aPB=aPBIt.Value(); - nSp=aPB.Edge(); - //>>> - if (!myStatesMap.Contains(nSp)) { - continue; - } - //>>> - aState=myStatesMap.FindFromKey(nSp); - - if (aState==BooleanOperations_IN) { - const TopoDS_Shape& aSplit=aDS.Shape(nSp); - TopoDS_Edge aSS=TopoDS::Edge(aSplit); - // - if (!BOPTools_Tools2D::HasCurveOnSurface(aSS, aF1FWD)) { - continue; - } - // - aSS.Orientation(anOr); - // - aWES.AddStartElement (aSS); - // - //modified by NIZNHY-PKV Tue Sep 25 14:25:13 2012f - if (IsClosed(aSS, aF2FWD)){ - //if (BRep_Tool::IsClosed(aSS, aF2FWD)){ - //modified by NIZNHY-PKV Tue Sep 25 14:25:35 2012t - TopoDS_Shape EE=aSS.Reversed(); - aWES.AddStartElement (EE); - } - } - } - } - else { - //>>> - if (!myStatesMap.Contains(nE)) { - continue; - } - //>>> - aState=myStatesMap.FindFromKey(nE); - if (aState==BooleanOperations_IN) { - TopoDS_Edge aSS=TopoDS::Edge(anE); - // - aWES.AddStartElement (aSS); - } - } - } // end of for (; anExp.More(); anExp.Next()) { - - PrepareOnParts(nF1, nF2, BOP_CUT); -} -//======================================================================= -// function: PrepareOnParts -// purpose: -//======================================================================= - void BOP_SDFWESFiller::PrepareOnParts (const Standard_Integer nF1, - const Standard_Integer nF2, - const BOP_Operation anOperation) -{ - const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); - const BOPTools_PaveFiller& aPaveFiller=myDSFiller->PaveFiller(); - BOPTools_PaveFiller* pPaveFiller=(BOPTools_PaveFiller*) &aPaveFiller; - BOPTools_CommonBlockPool& aCBPool=pPaveFiller->ChangeCommonBlockPool(); - BOP_WireEdgeSet& aWES=*myWES; - // - const Handle(IntTools_Context)& aContext=pPaveFiller->Context(); - // - Standard_Integer nE1, nE2, aNbSpON, nSp1, aBid, nSpTaken, nSp2, iRankF1, iRankF2; - Standard_Real aT1, aT2, aU, aV, aScPr; - Standard_Boolean bToReverse, bInternal1, bInternal2, bAdded; - - TopoDS_Edge aSS, aSSx; - TopoDS_Face aF1FWD, aF2FWD; - TopAbs_Orientation anOr, anOr2; - - TColStd_ListOfInteger aLs; - TColStd_IndexedMapOfInteger aMap; - TopTools_IndexedMapOfShape aM; - TopTools_MapOfShape aMFence;//xft - // - gp_Vec aN1, aN2, aTau1, aTau2, aBiN1, aBiN2; - TopExp_Explorer anExpF1, anExpF2; - // - // Source faces - iRankF1=aDS.Rank(nF1); - iRankF2=aDS.Rank(nF2); - // - PrepareFaces(nF1, nF2, aF1FWD, aF2FWD); - // - myRejectedOnParts.Clear();//xft - // - anExpF1.Init(aF1FWD, TopAbs_EDGE); - for (; anExpF1.More(); anExpF1.Next()) { - const TopoDS_Edge& anE1=TopoDS::Edge(anExpF1.Current()); - anOr=anE1.Orientation(); - // - if (BRep_Tool::Degenerated(anE1)){ - continue; - } - // - nE1=aDS.ShapeIndex(anE1, iRankF1); - - anExpF2.Init(aF2FWD, TopAbs_EDGE); - for (; anExpF2.More(); anExpF2.Next()) { - const TopoDS_Edge& anE2=TopoDS::Edge(anExpF2.Current()); - anOr2=anE2.Orientation(); - // - if (BRep_Tool::Degenerated(anE2)){ - continue; - } - // - nE2=aDS.ShapeIndex(anE2, iRankF2); - aLs.Clear(); - pPaveFiller->SplitsOnEdge(nE1, nE2, aLs); - - aNbSpON=aLs.Extent(); - if (!aNbSpON) { - continue; - } - - aMap.Clear(); - TColStd_ListIteratorOfListOfInteger anItLs(aLs); - for (; anItLs.More(); anItLs.Next()) { - aBid=anItLs.Value(); - aMap.Add(aBid); - } - - BOPTools_ListOfCommonBlock& aLCB=aCBPool(aDS.RefEdge(nE1)); - BOPTools_ListIteratorOfListOfCommonBlock anItCB(aLCB); - for (; anItCB.More(); anItCB.Next()) { - bAdded=Standard_False;//xft - BOPTools_CommonBlock& aCB=anItCB.Value(); - // Pave Block from which new edge will be taken - const BOPTools_PaveBlock& aPB=aCB.PaveBlock1(); - nSpTaken=aPB.Edge(); - const TopoDS_Shape& aSpTaken=aDS.Shape(nSpTaken); - // - BOPTools_PaveBlock& aPB1=aCB.PaveBlock1(nE1); - nSp1=aPB1.Edge(); - - if (aMap.Contains(nSp1)) { - BOPTools_PaveBlock& aPB2=aCB.PaveBlock2(nE1); - nSp2=aPB2.Edge(); - // - // - //iiiiiiiiiiiiiiiii Tue Dec 25 15:10:09 2001 iiiiii - // - // Internal eges' processing - bInternal1=(anOr ==TopAbs_INTERNAL); - bInternal2=(anOr2==TopAbs_INTERNAL); - // - if (bInternal1 || bInternal2) { - aSS=TopoDS::Edge(aDS.Shape(nSpTaken)); - // a. - if (bInternal1 && bInternal2) { - if (anOperation==BOP_COMMON) { - aWES.AddStartElement (aSS); - bAdded=Standard_True;//xft - } - } - // b. - else { // else x - if (bInternal1 && !bInternal2) { - if (nSpTaken==nSp1) { - aSS.Orientation(TopAbs_FORWARD); - aSSx=TopoDS::Edge(aDS.Shape(nSp2)); - aSSx.Orientation(anOr2); - // - bToReverse=BOPTools_Tools3D::IsSplitToReverse1 (aSSx, aSS, aContext); - // - if (bToReverse) { - aSS.Reverse(); - } - } - else {//nSpTaken!=nSp1 - aSS.Orientation(anOr2); - } - } - // c. - else if (!bInternal1 && bInternal2) { - if (nSpTaken==nSp2) { - aSS.Orientation(TopAbs_FORWARD); - aSSx=TopoDS::Edge(aDS.Shape(nSp1)); - aSSx.Orientation(anOr); - // - bToReverse=BOPTools_Tools3D::IsSplitToReverse1 (aSSx, aSS, aContext); - // - if (bToReverse) { - aSS.Reverse(); - } - } - else {//nSpTaken!=nSp2 - aSS.Orientation(anOr); - } - } - // writting - if (anOperation==BOP_COMMON) { - aWES.AddStartElement (aSS); - bAdded=Standard_True;//xft - } - if (anOperation==BOP_CUT) { - aSS.Reverse(); - aWES.AddStartElement (aSS); - bAdded=Standard_True;//xft - } - } // else x - continue; - } - // - //iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii - // - // - const BOPTools_PointBetween &aPbn1=aPB1.PointBetween(); - aT1=aPbn1.Parameter(); - BOPTools_Tools2D::EdgeTangent(anE1, aT1, aTau1); - - BOPTools_Tools2D::PointOnSurface(anE1, aF1FWD, aT1, aU, aV); - BOPTools_Tools2D::FaceNormal(aF1FWD, aU, aV, aN1); - aBiN1=aN1^aTau1; - - const BOPTools_PointBetween &aPbn2=aPB2.PointBetween(); - aT2=aPbn2.Parameter(); - BOPTools_Tools2D::EdgeTangent(anE2, aT2, aTau2); - - BOPTools_Tools2D::PointOnSurface(anE2, aF2FWD, aT2, aU, aV); - BOPTools_Tools2D::FaceNormal(aF2FWD, aU, aV, aN2); - aBiN2=aN2^aTau2; - - aScPr=aBiN1*aBiN2; - // - if (aScPr < 0.) { - if (anOperation==BOP_CUT) { - - if (nSpTaken==nSp1) { - aSS=TopoDS::Edge(aDS.GetShape(nSp1)); - aSS.Orientation(anOr); - } - - else { - const TopoDS_Shape& aSp1=aDS.Shape(nSp1); - TopoDS_Edge aSpE1=TopoDS::Edge(aSp1); - aSpE1.Orientation(anOr); - - const TopoDS_Shape& aSp2=aDS.Shape(nSp2); - TopoDS_Edge aSpE2=TopoDS::Edge(aSp2); - // - bToReverse=BOPTools_Tools3D::IsSplitToReverse1 (aSpE1, aSpE2, aContext); - // - if (bToReverse) { - aSpE2.Reverse(); - } - aSS=aSpE2; - } - // modified by NIZHNY-MKK Thu May 29 12:39:32 2003.BEGIN - if (BRep_Tool::IsClosed(anE1, aF1FWD) && (!aSS.IsSame(anE1))) { - Standard_Boolean areverse = Standard_False; - BOPTools_Tools3D::DoSplitSEAMOnFace(aSS, anE1, aF1FWD, areverse); - } - - if(BRep_Tool::IsClosed(anE2, aF2FWD) && (!aSS.IsSame(anE2))) { - Standard_Boolean areverse = Standard_False; - BOPTools_Tools3D::DoSplitSEAMOnFace(aSS, anE2, aF2FWD, areverse); - } - // modified by NIZHNY-MKK Thu May 29 12:39:35 2003.END - // - if (BRep_Tool::IsClosed(anE1, aF1FWD) && - BRep_Tool::IsClosed(anE2, aF2FWD)){ - // - Standard_Boolean bIsTakenSp1; - TopoDS_Edge aSpE1Seam11, aSpE1Seam21; - - bIsTakenSp1=(nSpTaken==nSp1); - aSpE1Seam11=TopoDS::Edge(aDS.Shape(nSp1)); - aSpE1Seam21=TopoDS::Edge(aDS.Shape(nSp2)); - // - if (aM.Contains(aSpE1Seam11)){ - continue; - } - aM.Add(aSpE1Seam11); - // - if (aM.Contains(aSpE1Seam21)){ - continue; - } - aM.Add(aSpE1Seam21); - // - TreatSDSeams (aSpE1Seam11, aT1, aF1FWD, - aSpE1Seam21, aT2, aF2FWD, - bIsTakenSp1, aWES, - aContext); - // - continue; - } - // - aWES.AddStartElement (aSS); - bAdded=Standard_True;//xft - } - - } - - else { - if (anOperation==BOP_COMMON) { - - if (nSpTaken==nSp1) { - aSS=TopoDS::Edge(aDS.GetShape(nSp1)); - aSS.Orientation(anOr); - } - - else { - const TopoDS_Shape& aSp1=aDS.Shape(nSp1); - TopoDS_Edge aSpE1=TopoDS::Edge(aSp1); - aSpE1.Orientation(anOr); - - const TopoDS_Shape& aSp2=aDS.Shape(nSp2); - TopoDS_Edge aSpE2=TopoDS::Edge(aSp2); - // - bToReverse=BOPTools_Tools3D::IsSplitToReverse1 (aSpE1, aSpE2, aContext); - // - if (bToReverse) { - aSpE2.Reverse(); - } - aSS=aSpE2; - // - if (BRep_Tool::IsClosed(aSpE1, aF1FWD)) { - // - if (aM.Contains(aSpE2)){ - continue; - } - aM.Add(aSpE2); - // - if (!BRep_Tool::IsClosed(aSpE2, aF1FWD)) { - BOPTools_Tools3D::DoSplitSEAMOnFace (aSpE2, aF1FWD); - } - aWES.AddStartElement (aSpE2); - aSpE2.Reverse(); - aWES.AddStartElement (aSpE2); - bAdded=Standard_True; //xft - continue; - } - // - } - // - aWES.AddStartElement (aSS); - bAdded=Standard_True; //xft - }// if (anOperation==BOP_COMMON) { - }// else { - if (!bAdded) { - if(aMFence.Add(aSpTaken)) { - myRejectedOnParts.Append(aSpTaken); - } - } - }// if (aMap.Contains(nSp1)) { - }// for (; anItCB.More(); anItCB.Next()) { - }// for (; anExpF2.More(); anExpF2.Next()) { - }//for (; anExpF1.More(); anExpF1.Next()) { -} - -//======================================================================= -// function: PrepareFaces -// purpose: -//======================================================================= - void BOP_SDFWESFiller::PrepareFaces (const Standard_Integer nF1, - const Standard_Integer nF2, - TopoDS_Face& aF1FWD, - TopoDS_Face& aF2FWD) const -{ - const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); - TopAbs_Orientation anOr1, anOr2; - - const TopoDS_Shape& aF1=aDS.GetShape(nF1); - aF1FWD=TopoDS::Face(aF1); - anOr1=aF1.Orientation(); - - const TopoDS_Shape& aF2=aDS.GetShape(nF2); - aF2FWD=TopoDS::Face(aF2); - anOr2=aF2.Orientation(); - - aF1FWD.Orientation(TopAbs_FORWARD); - - if (mySenseFlag==1) { - if (anOr1==TopAbs_FORWARD && anOr2==TopAbs_FORWARD) { - aF2FWD.Orientation(TopAbs_FORWARD); - } - else if (anOr1==TopAbs_REVERSED && anOr2==TopAbs_REVERSED) { - aF2FWD.Orientation(TopAbs_FORWARD); - } - else if (anOr1==TopAbs_FORWARD && anOr2==TopAbs_REVERSED) { - aF2FWD.Orientation(TopAbs_REVERSED); - } - else if (anOr1==TopAbs_REVERSED && anOr2==TopAbs_FORWARD) { - aF2FWD.Orientation(TopAbs_REVERSED); - } - } - - else{ - if (anOr1==TopAbs_FORWARD && anOr2==TopAbs_FORWARD) { - aF2FWD.Orientation(TopAbs_REVERSED); - } - else if (anOr1==TopAbs_REVERSED && anOr2==TopAbs_REVERSED) { - aF2FWD.Orientation(TopAbs_REVERSED); - } - else if (anOr1==TopAbs_FORWARD && anOr2==TopAbs_REVERSED) { - aF2FWD.Orientation(TopAbs_FORWARD); - } - else if (anOr1==TopAbs_REVERSED && anOr2==TopAbs_FORWARD) { - aF2FWD.Orientation(TopAbs_FORWARD); - } - } -} -// -//======================================================================= -// function: AssignDEStates -// purpose: -//======================================================================= - void BOP_SDFWESFiller::AssignDEStates(const Standard_Integer nF1, - const Standard_Integer nF2) -{ - const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); - - Standard_Integer nE1, iRankF1; - TopExp_Explorer anExpF1; - - iRankF1=aDS.Rank(nF1); - - const TopoDS_Face& aF1=TopoDS::Face(aDS.Shape(nF1)); - - anExpF1.Init(aF1, TopAbs_EDGE); - for (; anExpF1.More(); anExpF1.Next()) { - const TopoDS_Edge& anE1=TopoDS::Edge(anExpF1.Current()); - // - if (!BRep_Tool::Degenerated(anE1)){ - continue; - } - // - nE1=aDS.ShapeIndex(anE1, iRankF1); - AssignDEStates (nF1, nE1, nF2); - } -} - -//======================================================================= -// function: AssignDEStates -// purpose: -//======================================================================= - void BOP_SDFWESFiller::AssignDEStates(const Standard_Integer nFD, - const Standard_Integer nED, - const Standard_Integer nF2) -{ - const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); - const BOPTools_PaveFiller& aPaveFiller=myDSFiller->PaveFiller(); - BOPTools_PaveFiller* pPaveFiller=(BOPTools_PaveFiller*) &aPaveFiller; - const BOPTools_SplitShapesPool& aSplitShapesPool=aPaveFiller.SplitShapesPool(); - // - const BOPTools_ListOfPaveBlock& aSplitEdges=aSplitShapesPool(aDS.RefEdge(nED)); - // - const Handle(IntTools_Context)& aContext=pPaveFiller->Context(); - const TopoDS_Edge& aDE=TopoDS::Edge(aDS.Shape(nED)); - const TopoDS_Face& aDF=TopoDS::Face(aDS.Shape(nFD)); - const TopoDS_Face& aFaceReference=TopoDS::Face(aDS.Shape(nF2)); - // - Standard_Boolean bIsValidPoint; - Standard_Integer nSp; - Standard_Real aT, aT1, aT2; - TopAbs_State aState; - TopoDS_Face aF; - gp_Pnt2d aPx2DNear; - gp_Pnt aPxNear; - // - aF=aDF; - aF.Orientation(TopAbs_FORWARD); - - BOPTools_ListIteratorOfListOfPaveBlock aPBIt(aSplitEdges); - for (; aPBIt.More(); aPBIt.Next()) { - BOPTools_PaveBlock& aPB=aPBIt.Value(); - - nSp=aPB.Edge(); - const TopoDS_Edge& aSp=TopoDS::Edge(aDS.Shape(nSp)); - - aPB.Parameters(aT1, aT2); - aT=IntTools_Tools::IntermediatePoint(aT1, aT2); - - TopoDS_Edge aDERight, aSpRight; - aDERight=aDE; - aSpRight=aSp; - - BOPTools_Tools3D::OrientEdgeOnFace (aDE, aF, aDERight); - aSpRight.Orientation(aDERight.Orientation()); - // - BOPTools_Tools3D::PointNearEdge(aSpRight, aDF, aT, aPx2DNear, aPxNear); - // - aState=TopAbs_OUT; - // - bIsValidPoint=aContext->IsValidPointForFace(aPxNear, aFaceReference, 1.e-3); - // - if (bIsValidPoint) { - aState=TopAbs_IN; - } - // - BooleanOperations_StateOfShape aSt; - - aSt=BOPTools_SolidStateFiller::ConvertState(aState); - if (myStatesMap.Contains(nSp)) { - BooleanOperations_StateOfShape& aBooState=myStatesMap.ChangeFromKey(nSp); - aBooState=aSt; - } - else { - myStatesMap.Add(nSp, aSt); - } - } -} - -//======================================================================= -// function: UpdateDEStates3D -// purpose: -//======================================================================= - void BOP_SDFWESFiller::UpdateDEStates3D() -{ - BooleanOperations_ShapesDataStructure* pDS= - (BooleanOperations_ShapesDataStructure*)&myDSFiller->DS(); - - Standard_Integer i, aNb, nSp; - BooleanOperations_StateOfShape aSt; - - aNb=myStatesMap.Extent(); - for (i=1; i<=aNb; i++) { - nSp=myStatesMap.FindKey(i); - aSt=pDS->GetState(nSp); - aSt=BooleanOperations_UNKNOWN; - pDS->SetState(nSp, aSt); - } -} -// -#include -#include - -//======================================================================= -// function: TreatSDSeams -// purpose: -//======================================================================= -void TreatSDSeams (const TopoDS_Edge& aSpE1Seam11, - const Standard_Real aT1, - const TopoDS_Face& aF1FWD, - - const TopoDS_Edge& aSpE1Seam21, - const Standard_Real aT2, - const TopoDS_Face& aF2FWD, - - const Standard_Boolean bIsTakenSp1, - BOP_WireEdgeSet& aWES, - const Handle(IntTools_Context)& aContext) -{ - Standard_Boolean bIsValidSeam11, bIsValidSeam12, - bIsValidSeam21, bIsValidSeam22; - Standard_Real aScPr; - TopoDS_Edge aSS, aSpE1Seam12,aSpE1Seam22; - gp_Dir aDB11, aDB12, aDB21, aDB22; - - aSpE1Seam12=TopoDS::Edge(aSpE1Seam11.Reversed()); - aSpE1Seam22=TopoDS::Edge(aSpE1Seam21.Reversed()); - // - if (!bIsTakenSp1) { - BOPTools_Tools3D::DoSplitSEAMOnFace (aSpE1Seam21, aF1FWD); - aSpE1Seam22=TopoDS::Edge(aSpE1Seam21.Reversed()); - } - // - bIsValidSeam11=IsValidSeam(aSpE1Seam11, aF1FWD, aT1, aContext); - bIsValidSeam12=IsValidSeam(aSpE1Seam12, aF1FWD, aT1, aContext); - bIsValidSeam21=IsValidSeam(aSpE1Seam21, aF2FWD, aT2, aContext); - bIsValidSeam22=IsValidSeam(aSpE1Seam22, aF2FWD, aT2, aContext); - // 1 - if (bIsValidSeam11 && bIsValidSeam12) { - BOPTools_Tools3D::GetBiNormal(aSpE1Seam11, aF1FWD, aT1, aDB11); - BOPTools_Tools3D::GetBiNormal(aSpE1Seam12, aF1FWD, aT1, aDB12); - // 1.1 - if (bIsValidSeam21 && !bIsValidSeam22) { - BOPTools_Tools3D::GetBiNormal(aSpE1Seam21, aF2FWD, aT2, aDB21); - aScPr=aDB11*aDB21; - if (aScPr<0.) { - if (bIsTakenSp1) { - aSS=aSpE1Seam11; - } - else { - //aSS=aSpE1Seam21; - CorrespondantSeam(aSpE1Seam11, aT1, - aSpE1Seam21, aSpE1Seam22, aT2, - aF1FWD, aSS); - } - } - else { //if (aScPr>0.) - if (bIsTakenSp1) { - aSS=aSpE1Seam12; - } - else { - //aSS=aSpE1Seam22; - CorrespondantSeam(aSpE1Seam12, aT1, - aSpE1Seam21, aSpE1Seam22, aT2, - aF1FWD, aSS); - } - } - aWES.AddStartElement (aSS); - } //if (bIsValidSeam21 && !bIsValidSeam22) - // - // 1.2 - if (!bIsValidSeam21 && bIsValidSeam22) { - BOPTools_Tools3D::GetBiNormal(aSpE1Seam22, aF2FWD, aT2, aDB22); - aScPr=aDB11*aDB22; - if (aScPr<0.) { - if (bIsTakenSp1) { - aSS=aSpE1Seam11; - } - else { - //aSS=aSpE1Seam22; - CorrespondantSeam(aSpE1Seam11, aT1, - aSpE1Seam21, aSpE1Seam22, aT2, - aF1FWD, aSS); - } - } - else {//if (aScPr>0.) - if (bIsTakenSp1) { - aSS=aSpE1Seam12; - } - else { - //aSS=aSpE1Seam21; - CorrespondantSeam(aSpE1Seam12, aT1, - aSpE1Seam21, aSpE1Seam22, aT2, - aF1FWD, aSS); - } - } - aWES.AddStartElement (aSS); - }// if (!bIsValidSeam21 && bIsValidSeam22) - } //if (bIsValidSeam11 && bIsValidSeam12) -} - -//======================================================================= -// function: IsValidSeam -// purpose: -//======================================================================= - Standard_Boolean IsValidSeam(const TopoDS_Edge& aE, - const TopoDS_Face& aF, - const Standard_Real aT, - const Handle(IntTools_Context)& aContext) -{ - Standard_Boolean bIsPointInOnFace; - gp_Pnt2d aPx2DNear; - gp_Pnt aPxNear; - - BOPTools_Tools3D::PointNearEdge(aE, aF, aT, aPx2DNear, aPxNear); - // - bIsPointInOnFace=aContext->IsPointInOnFace(aF, aPx2DNear); - return bIsPointInOnFace; -} -//======================================================================= -// function: CorrespondantSeam -// purpose: -//======================================================================= - void CorrespondantSeam(const TopoDS_Edge& aSpE1Seam11, - const Standard_Real aT1, - const TopoDS_Edge& aSpE1Seam21, - const TopoDS_Edge& aSpE1Seam22, - const Standard_Real aT2, - const TopoDS_Face& aF1FWD, - TopoDS_Edge& aSS) - -{ - Standard_Real a, b, aD1121, aD1122, aTol=1.e-7; - Handle(Geom2d_Curve) aC2DSeam11, aC2DSeam21, aC2DSeam22; - gp_Pnt2d aP2D11, aP2D21, aP2D22; - - aC2DSeam11=BRep_Tool::CurveOnSurface(aSpE1Seam11, aF1FWD, a, b); - aC2DSeam11->D0(aT1, aP2D11); - - aC2DSeam21=BRep_Tool::CurveOnSurface(aSpE1Seam21, aF1FWD, a, b); - aC2DSeam21->D0(aT2, aP2D21); - - aC2DSeam22=BRep_Tool::CurveOnSurface(aSpE1Seam22, aF1FWD, a, b); - aC2DSeam22->D0(aT2, aP2D22); - - aD1121=aP2D11.Distance(aP2D21); - aD1122=aP2D11.Distance(aP2D22); - - aSS=aSpE1Seam22; - if (aD1121 - -#include -#include - -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include - - -static - void MakeShell (const TopTools_ListOfShape& aLE, - TopoDS_Shell& newShell); - -//======================================================================= -// function: BOP_SFSCorrector::BOP_SFSCorrector -// purpose: -//======================================================================= - BOP_SFSCorrector::BOP_SFSCorrector() -: - myIsDone(Standard_False), - myErrorStatus(1) -{} -//======================================================================= -// function: SetSFS -// purpose: -//======================================================================= - void BOP_SFSCorrector::SetSFS (const BOP_ShellFaceSet& aSFS) -{ - BOP_ShellFaceSet* pSFS=(BOP_ShellFaceSet*) &aSFS; - mySFS=pSFS; -} -//======================================================================= -// function: SFS -// purpose: -//======================================================================= - BOP_ShellFaceSet& BOP_SFSCorrector::SFS () -{ - return *mySFS; -} -//======================================================================= -// function: NewSFS -// purpose: -//======================================================================= - BOP_ShellFaceSet& BOP_SFSCorrector::NewSFS () -{ - return myNewSFS; -} -//======================================================================= -// function: IsDone -// purpose: -//======================================================================= - Standard_Boolean BOP_SFSCorrector::IsDone () const -{ - return myIsDone; -} -//======================================================================= -// function: ErrorStatus -// purpose: -//======================================================================= - Standard_Integer BOP_SFSCorrector::ErrorStatus () const -{ - return myErrorStatus; -} -//======================================================================= -// function: Do -// purpose: -//======================================================================= - void BOP_SFSCorrector::Do() -{ - DoConnexityBlocks(); - DoCorrections(); - myIsDone=Standard_True; -} -//======================================================================= -// function: DoConnexityBlocks -// purpose: -//======================================================================= - void BOP_SFSCorrector::DoConnexityBlocks() -{ - Standard_Boolean EnewinM, aGoOn; - Standard_Integer Mextent, IsRegular, aNbNeighbours, Eindex; - TopTools_IndexedMapOfOrientedShape myOrientedShapeMap, aMap; - // - mySFS->InitStartElements(); - for (; mySFS->MoreStartElements(); mySFS->NextStartElement()) { - const TopoDS_Shape& anE = mySFS->StartElement(); - Mextent = myOrientedShapeMap.Extent(); - - Eindex = myOrientedShapeMap.Add(anE); - - EnewinM = (Eindex > Mextent); - if (EnewinM) { - // - // make a new block starting at element Eindex - IsRegular=Standard_True; - aNbNeighbours=0; - Mextent = myOrientedShapeMap.Extent(); - // - aMap.Clear(); - aMap.Add(anE); - // - aGoOn = (Eindex <= Mextent); - while (aGoOn) { - const TopoDS_Shape& anEE = myOrientedShapeMap(Eindex); - aNbNeighbours = mySFS->MaxNumberSubShape(anEE); - - IsRegular = IsRegular && (aNbNeighbours == 2); - // - mySFS->InitNeighbours(anEE); - for (; mySFS->MoreNeighbours(); mySFS->NextNeighbour()) { - const TopoDS_Shape& aNeignbE = mySFS->Neighbour(); - myOrientedShapeMap.Add(aNeignbE); - // - aMap.Add(aNeignbE); - } - - Eindex++; - Mextent = myOrientedShapeMap.Extent(); - aGoOn = (Eindex <= Mextent); - } // end of while aGoOn - - BOP_ConnexityBlock aConnexityBlock; - aConnexityBlock.SetShapes(aMap); - aConnexityBlock.SetRegularity(IsRegular); - myConnexityBlocks.Append(aConnexityBlock); - } // end of if (EnewinM) - } // end of for (; mySFS->MoreStartElements();... -} - -//======================================================================= -// function: DoCorrections -// purpose: -//======================================================================= - void BOP_SFSCorrector::DoCorrections() -{ - Standard_Boolean anIsRegular, anIsNothingToDo, anIsDone; - TopoDS_Shell aShell; - BOP_ListIteratorOfListOfConnexityBlock aCBIt; - - //myNewSFS.Initialize(mySFS->Face()); - anIsDone=Standard_False; - anIsNothingToDo=Standard_True; - - aCBIt.Initialize(myConnexityBlocks); - for (; aCBIt.More(); aCBIt.Next()) { - const BOP_ConnexityBlock& aCB=aCBIt.Value(); - const TopTools_ListOfShape& aListOfEdges=aCB.Shapes(); - - anIsRegular=aCB.IsRegular(); - - if (anIsRegular) { - MakeShell(aListOfEdges, aShell); - myNewSFS.AddShape (aShell); - continue; - } - // - // Treatment of non regular Connexity Block - BOP_ShellSplitter aShellSplitter; - aShellSplitter.DoWithListOfEdges(aListOfEdges); - - anIsDone=aShellSplitter.IsDone(); - anIsNothingToDo=aShellSplitter.IsNothingToDo(); - - if (!anIsDone || anIsNothingToDo) { - MakeShell(aListOfEdges, aShell); - myNewSFS.AddShape (aShell); - continue; - } - - // - const BOPTColStd_ListOfListOfShape& aSSS=aShellSplitter.Shapes(); - - BOPTColStd_ListIteratorOfListOfListOfShape aShellIt(aSSS); - for (; aShellIt.More(); aShellIt.Next()) { - const TopTools_ListOfShape& aListF=aShellIt.Value(); - // - MakeShell(aListF, aShell); - myNewSFS.AddShape (aShell); - } - } -} - -//======================================================================= -// function: MakeShell -// purpose: -//======================================================================= - void MakeShell(const TopTools_ListOfShape& aLE, - TopoDS_Shell& newShell) -{ - BRep_Builder aBB; - aBB.MakeShell(newShell); - - TopTools_ListIteratorOfListOfShape anIt(aLE); - for (; anIt.More(); anIt.Next()){ - const TopoDS_Face& aF=TopoDS::Face(anIt.Value()); - aBB.Add(newShell, aF); - } -} -///////////////////////////////////////////////////////////////// -// -// myErrorStatus: -// -// 1 - Nothing is done because only constructor has been called -// -///////////////////////////////////////////////////////////////// diff --git a/src/BOP/BOP_Section.cdl b/src/BOP/BOP_Section.cdl deleted file mode 100755 index ec66ca94fa..0000000000 --- a/src/BOP/BOP_Section.cdl +++ /dev/null @@ -1,75 +0,0 @@ --- Created on: 2001-05-18 --- Created by: Peter KURNEV --- Copyright (c) 2001-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class Section from BOP inherits Builder from BOP - - ----Purpose: Performs the Boolean Operation (BO) Section - --- for the shapes - - -uses - DSFiller from BOPTools, - HistoryCollector from BOP - -is - Create - returns Section from BOP; - ---Purpose: - --- Empty constructor; - --- - Do (me:out) - is redefined; - ---Purpose: - --- Does the BO from the beggining to the end, - --- i.e. create new DataStructure, DSFiller, - --- compute all interferences, compute states, - --- build result etc - --- - Do (me:out;toApprox : Boolean from Standard; - toComputePCurve1 : Boolean from Standard; - toComputePCurve2 : Boolean from Standard); - ---Purpose: - --- Does the BO from the beggining to the end, - --- i.e. create new DataStructure, DSFiller, - --- compute all interferences, compute states, - --- build result etc - --- - - DoWithFiller (me:out; - aDSF: DSFiller from BOPTools) - is redefined; - ---Purpose: - --- Does the BO using existing Filler to the end - --- - - Destroy (me: in out) - is redefined; - ---C++: alias "Standard_EXPORT virtual ~BOP_Section(){Destroy();}" - ---Purpose: - --- Destructor - --- - - SetHistoryCollector(me: in out; theHistory: HistoryCollector from BOP) - is redefined virtual; - ---fields - -end Section; diff --git a/src/BOP/BOP_Section.cxx b/src/BOP/BOP_Section.cxx deleted file mode 100755 index 7d107206ac..0000000000 --- a/src/BOP/BOP_Section.cxx +++ /dev/null @@ -1,302 +0,0 @@ -// Created on: 2001-05-18 -// Created by: Peter KURNEV -// Copyright (c) 2001-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include - -#include - -#include - -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -#include - -#include -#include - -//======================================================================= -// function: BOP_Section::BOP_Section -// purpose: -//======================================================================= -BOP_Section::BOP_Section() -{ - SetOperation (BOP_SECTION); -} -//======================================================================= -// function: Destroy -// purpose: -//======================================================================= - void BOP_Section::Destroy() {} - -//======================================================================= -// function: Do -// purpose: -//======================================================================= - void BOP_Section::Do() -{ - myErrorStatus=0; - myIsDone=Standard_False; - - TopAbs_ShapeEnum aT1, aT2; - - aT1=myShape1.ShapeType(); - aT2=myShape2.ShapeType(); - - BOP_Builder::SortTypes (aT1, aT2); - // - // Filling the DS - BOPTools_DSFiller aDSFiller; - aDSFiller.SetShapes (myShape1, myShape2); - aDSFiller.Perform (); - DoWithFiller(aDSFiller); -} - -// -//======================================================================= -// function: Do -// purpose: -//======================================================================= - void BOP_Section::Do(const Standard_Boolean toApprox, - const Standard_Boolean toComputePCurve1, - const Standard_Boolean toComputePCurve2) -{ - myErrorStatus=0; - myIsDone=Standard_False; - - TopAbs_ShapeEnum aT1, aT2; - - aT1=myShape1.ShapeType(); - aT2=myShape2.ShapeType(); - - BOP_Builder::SortTypes (aT1, aT2); - // - // Filling the DS - BOPTools_DSFiller aDSFiller; - aDSFiller.SetShapes (myShape1, myShape2); - - BOPTools_SSIntersectionAttribute aSectionAttribute(toApprox, - toComputePCurve1, - toComputePCurve2); - aDSFiller.Perform (aSectionAttribute); - DoWithFiller(aDSFiller); -} -// - -//======================================================================= -// function: DoDoWithFiller -// purpose: -//======================================================================= - void BOP_Section::DoWithFiller(const BOPTools_DSFiller& aDSFiller) -{ - myErrorStatus=0; - myIsDone=Standard_False; - - // - myResultMap.Clear(); - myModifiedMap.Clear(); - myDSFiller=(BOPTools_DSFiller*) &aDSFiller; - // - - try { - OCC_CATCH_SIGNALS - Standard_Boolean addPCurve1 = aDSFiller.PaveFiller().SectionAttribute().PCurveOnS1(); - Standard_Boolean addPCurve2 = aDSFiller.PaveFiller().SectionAttribute().PCurveOnS2(); - - Standard_Integer i, j, nF1, nF2, aNbFFs, aNbS, aNbCurves, nSect; - - const BooleanOperations_ShapesDataStructure& aDS=aDSFiller.DS(); - const BOPTools_InterferencePool& anInterfPool=aDSFiller.InterfPool(); - BOPTools_InterferencePool* pInterfPool= - (BOPTools_InterferencePool*) &anInterfPool; - BOPTools_CArray1OfSSInterference& aFFs= - pInterfPool->SSInterferences(); - // - TopTools_IndexedMapOfShape aMap; - // - aNbFFs=aFFs.Extent(); - for (i=1; i<=aNbFFs; ++i) { - BOPTools_SSInterference& aFFi=aFFs(i); - // - nF1=aFFi.Index1(); - nF2=aFFi.Index2(); - - TopoDS_Face aF1FWD = TopoDS::Face(aDSFiller.DS().Shape(nF1)); - aF1FWD.Orientation(TopAbs_FORWARD); - TopoDS_Face aF2FWD = TopoDS::Face(aDSFiller.DS().Shape(nF2)); - aF2FWD.Orientation(TopAbs_FORWARD); - // - // Old Section Edges - const BOPTools_ListOfPaveBlock& aSectList=aFFi.PaveBlocks(); - aNbS=aSectList.Extent(); - BOPTools_ListIteratorOfListOfPaveBlock anIt(aSectList); - for (; anIt.More();anIt.Next()) { - const BOPTools_PaveBlock& aPB=anIt.Value(); - nSect=aPB.Edge(); - const TopoDS_Shape& aS=aDS.GetShape(nSect); - - const TopoDS_Edge& aE = TopoDS::Edge(aS); - - if(addPCurve1) { - BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aE, aF1FWD); - } - - if(addPCurve2) { - BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aE, aF2FWD); - } - aMap.Add(aS); - } - // - // New Section Edges - BOPTools_SequenceOfCurves& aBCurves=aFFi.Curves(); - aNbCurves=aBCurves.Length(); - for (j=1; j<=aNbCurves; j++) { - BOPTools_Curve& aBC=aBCurves(j); - const BOPTools_ListOfPaveBlock& aSectEdges=aBC.NewPaveBlocks(); - aNbS=aSectEdges.Extent(); - - BOPTools_ListIteratorOfListOfPaveBlock aPBIt(aSectEdges); - for (; aPBIt.More(); aPBIt.Next()) { - BOPTools_PaveBlock& aPB=aPBIt.Value(); - nSect=aPB.Edge(); - const TopoDS_Shape& aS=aDS.GetShape(nSect); - - if(addPCurve1 || addPCurve2) { - const IntTools_Curve& aIC = aBC.Curve(); - const TopoDS_Edge& aE = TopoDS::Edge(aS); - Standard_Real f, l; - const Handle(Geom_Curve)& aC3DE = BRep_Tool::Curve(aE, f, l); - Handle(Geom_TrimmedCurve) aC3DETrim; - - if(!aC3DE.IsNull()) { - aC3DETrim = new Geom_TrimmedCurve(aC3DE, f, l); - } - BRep_Builder aBB; - Standard_Real aTolEdge = BRep_Tool::Tolerance(aE); - Standard_Real aTolR2D = aFFi.TolR2D(); - Standard_Real aTolFact = Max(aTolEdge, aTolR2D); - - if(addPCurve1 && !BOPTools_Tools2D::HasCurveOnSurface(aE, aF1FWD)) { - Handle(Geom2d_Curve) aC2d = aIC.FirstCurve2d(); - - if(!aC3DETrim.IsNull()) { - Handle(Geom2d_Curve) aC2dNew; - - if(aC3DE->IsPeriodic()) { - BOPTools_Tools2D::AdjustPCurveOnFace(aF1FWD, f, l, aC2d, aC2dNew); - } - else { - BOPTools_Tools2D::AdjustPCurveOnFace(aF1FWD, aC3DETrim, aC2d, aC2dNew); - } - aC2d = aC2dNew; - } - aBB.UpdateEdge(aE, aC2d, aF1FWD, aTolFact); - } - - if(addPCurve2 && !BOPTools_Tools2D::HasCurveOnSurface(aE, aF2FWD)) { - Handle(Geom2d_Curve) aC2d = aIC.SecondCurve2d(); - - if(!aC3DETrim.IsNull()) { - Handle(Geom2d_Curve) aC2dNew; - - if(aC3DE->IsPeriodic()) { - BOPTools_Tools2D::AdjustPCurveOnFace(aF2FWD, f, l, aC2d, aC2dNew); - } - else { - BOPTools_Tools2D::AdjustPCurveOnFace(aF2FWD, aC3DETrim, aC2d, aC2dNew); - } - aC2d = aC2dNew; - } - aBB.UpdateEdge(aE, aC2d, aF2FWD, aTolFact); - } - } - aMap.Add(aS); - } - } - } - // - BRep_Builder BB; - TopoDS_Compound aCompound; - BB.MakeCompound(aCompound); - - aNbS=aMap.Extent(); - - for (i=1; i<=aNbS; i++) { - const TopoDS_Shape& aS=aMap(i); - BB.Add(aCompound, aS); - mySectionEdges.Append(aS); - } - myResult=aCompound; - BOP_CorrectTolerances::CorrectTolerances(myResult, 0.01); - // - if (!myErrorStatus) { - FillModified(); - - if(!myHistory.IsNull()) { - Handle(BOP_SectionHistoryCollector) aHistory = - Handle(BOP_SectionHistoryCollector)::DownCast(myHistory); - aHistory->SetResult(myResult, myDSFiller); - } - myIsDone=Standard_True; - } - } - catch ( Standard_Failure ) { - myErrorStatus = 1; - BOPTColStd_Dump::PrintMessage("Can not build result\n"); - } -} - -//======================================================================= -// function: SetHistoryCollector -// purpose: -//======================================================================= -void BOP_Section::SetHistoryCollector(const Handle(BOP_HistoryCollector)& theHistory) -{ - if(theHistory.IsNull() || - !theHistory->IsKind(STANDARD_TYPE(BOP_SectionHistoryCollector))) - myHistory.Nullify(); - else - myHistory = theHistory; -} diff --git a/src/BOP/BOP_SectionHistoryCollector.cdl b/src/BOP/BOP_SectionHistoryCollector.cdl deleted file mode 100755 index f32d695392..0000000000 --- a/src/BOP/BOP_SectionHistoryCollector.cdl +++ /dev/null @@ -1,53 +0,0 @@ --- Created on: 2003-04-29 --- Created by: Michael KLOKOV --- Copyright (c) 2003-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class SectionHistoryCollector from BOP inherits HistoryCollector from BOP - -uses - Shape from TopoDS, - Operation from BOP, - PDSFiller from BOPTools, - ListOfShape from TopTools, - IndexedMapOfShape from TopTools, - IndexedDataMapOfShapeListOfShape from TopTools - -is - Create(theShape1 : Shape from TopoDS; - theShape2 : Shape from TopoDS) - returns SectionHistoryCollector from BOP; - - SetResult(me: mutable; theResult: Shape from TopoDS; - theDSFiller: PDSFiller from BOPTools) - is redefined virtual; - - - -- private - FillFaceSection(me: mutable; theDSFiller : PDSFiller from BOPTools; - theResultMap: IndexedMapOfShape from TopTools) - is private; - - FillEdgeSection(me: mutable; theEdge : Shape from TopoDS; - theDSFiller : PDSFiller from BOPTools; - theResultMap: IndexedMapOfShape from TopTools; - theVEMapRes : IndexedDataMapOfShapeListOfShape from TopTools; - theEFMap : IndexedDataMapOfShapeListOfShape from TopTools) - is private; - -end SectionHistoryCollector from BOP; diff --git a/src/BOP/BOP_SectionHistoryCollector.cxx b/src/BOP/BOP_SectionHistoryCollector.cxx deleted file mode 100755 index 0989776b49..0000000000 --- a/src/BOP/BOP_SectionHistoryCollector.cxx +++ /dev/null @@ -1,605 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static Standard_Boolean AddNewShape(const TopoDS_Shape& theKey, - const TopoDS_Shape& theItem, - TopTools_DataMapOfShapeListOfShape& theMap); - -// ============================================================================================ -// function: Constructor -// purpose: -// ============================================================================================ -BOP_SectionHistoryCollector::BOP_SectionHistoryCollector(const TopoDS_Shape& theShape1, - const TopoDS_Shape& theShape2) : -BOP_HistoryCollector(theShape1,theShape2, BOP_SECTION) -{ -} - -// ============================================================================================ -// function: SetResult -// purpose: -// ============================================================================================ -void BOP_SectionHistoryCollector::SetResult(const TopoDS_Shape& theResult, - const BOPTools_PDSFiller& theDSFiller) -{ - myResult = theResult; - - if(myResult.IsNull()) - return; - - TopAbs_ShapeEnum aResultType = TopAbs_EDGE; - Standard_Boolean bcontainsface1 = Standard_False; - Standard_Boolean bcontainsface2 = Standard_False; - - Standard_Boolean bcontainsedge1 = Standard_False; - Standard_Boolean bcontainsedge2 = Standard_False; - - TopExp_Explorer anExp(myS1, TopAbs_FACE); - - if(anExp.More()) { - bcontainsface1 = Standard_True; - bcontainsedge1 = Standard_True; - } - else { - anExp.Init(myS1, TopAbs_EDGE); - - if(anExp.More()) { - bcontainsedge1 = Standard_True; - } - } - anExp.Init(myS2, TopAbs_FACE); - - if(anExp.More()) { - bcontainsface2 = Standard_True; - bcontainsedge2 = Standard_True; - } - else { - anExp.Init(myS2, TopAbs_EDGE); - - if(anExp.More()) { - bcontainsedge2 = Standard_True; - } - } - - if(bcontainsface1 && bcontainsface2) - aResultType = TopAbs_EDGE; - else if(bcontainsedge1 && bcontainsedge2) - aResultType = TopAbs_VERTEX; - else - return; - - myHasDeleted = Standard_True; - - - TopTools_IndexedMapOfShape aMap; - TopExp::MapShapes(myResult, aResultType, aMap); - - if(aResultType == TopAbs_EDGE) { - FillFaceSection(theDSFiller, aMap); - - TopTools_IndexedDataMapOfShapeListOfShape aEFMap; - TopTools_IndexedDataMapOfShapeListOfShape aVEMap; - - TopExp::MapShapesAndAncestors(myResult, TopAbs_VERTEX, TopAbs_EDGE, aVEMap); - TopExp::MapShapesAndAncestors(myS1, TopAbs_EDGE, TopAbs_FACE, aEFMap); - TopExp::MapShapesAndAncestors(myS2, TopAbs_EDGE, TopAbs_FACE, aEFMap); - - TopTools_IndexedMapOfShape aResultMap, aFreeBoundaryMap; - Standard_Integer i = 0; - - for(i = 1; i <= aEFMap.Extent(); i++) { - if(aEFMap.FindFromIndex(i).Extent() < 2) - aFreeBoundaryMap.Add(aEFMap.FindKey(i)); - } - - for(i = 1; i <= aFreeBoundaryMap.Extent(); i++) { - const TopoDS_Shape& anEdge = aFreeBoundaryMap.FindKey(i); - FillEdgeSection(anEdge, theDSFiller, aMap, aVEMap, aEFMap); - } - } -} - -// ============================================================================================ -// function: FillFaceSection -// purpose: -// ============================================================================================ -void BOP_SectionHistoryCollector::FillFaceSection(const BOPTools_PDSFiller& theDSFiller, - const TopTools_IndexedMapOfShape& theResultMap) -{ - const BooleanOperations_ShapesDataStructure& aDS = theDSFiller->DS(); - const BOPTools_InterferencePool& anInterfPool = theDSFiller->InterfPool(); - BOPTools_InterferencePool* pInterfPool = (BOPTools_InterferencePool*) &anInterfPool; - BOPTools_CArray1OfSSInterference& aFFs = pInterfPool->SSInterferences(); - // - TopTools_IndexedMapOfShape aMap; - Standard_Integer aNbFFs = aFFs.Extent(); - Standard_Integer i = 0, j = 0; - - for (i=1; i<=aNbFFs; ++i) { - BOPTools_SSInterference& aFFi = aFFs(i); - // - Standard_Integer nF1 = aFFi.Index1(); - Standard_Integer nF2 = aFFi.Index2(); - TopoDS_Shape aF1 = aDS.Shape(nF1); - TopoDS_Shape aF2 = aDS.Shape(nF2); - Standard_Integer nSect = 0; - - // Old Section Edges - const BOPTools_ListOfPaveBlock& aSectList = aFFi.PaveBlocks(); - BOPTools_ListIteratorOfListOfPaveBlock anIt(aSectList); - - for (; anIt.More();anIt.Next()) { - const BOPTools_PaveBlock& aPB=anIt.Value(); - nSect = aPB.Edge(); - const TopoDS_Shape& aS = aDS.GetShape(nSect); - - if(theResultMap.Contains(aS)) { - TopTools_ListOfShape thelist; - if(!myGenMap.IsBound(aF1)) - myGenMap.Bind(aF1, thelist ); - - if(!myGenMap.IsBound(aF2)) - myGenMap.Bind(aF2, thelist); - - for(Standard_Integer fit = 0; fit < 2; fit++) { - if(fit == 0) - AddNewShape(aF1, aS, myGenMap); - else - AddNewShape(aF2, aS, myGenMap); - } - } - } - - // New Section Edges - BOPTools_SequenceOfCurves& aBCurves = aFFi.Curves(); - Standard_Integer aNbCurves = aBCurves.Length(); - - for (j = 1; j <= aNbCurves; j++) { - BOPTools_Curve& aBC = aBCurves(j); - const BOPTools_ListOfPaveBlock& aSectEdges = aBC.NewPaveBlocks(); - - BOPTools_ListIteratorOfListOfPaveBlock aPBIt(aSectEdges); - - for (; aPBIt.More(); aPBIt.Next()) { - BOPTools_PaveBlock& aPB = aPBIt.Value(); - nSect = aPB.Edge(); - const TopoDS_Shape& aS = aDS.GetShape(nSect); - - if(theResultMap.Contains(aS) && !aMap.Contains(aS)) { - TopTools_ListOfShape thelist1; - - if(!myGenMap.IsBound(aF1)) { - myGenMap.Bind(aF1, thelist1); - } - myGenMap.ChangeFind(aF1).Append(aS); - - if(!myGenMap.IsBound(aF2)) - myGenMap.Bind(aF2, thelist1); - myGenMap.ChangeFind(aF2).Append(aS); - aMap.Add(aS); - } - } - } - } -} - -// Modified by skv - Wed Nov 5 15:52:48 2003 OCC3644 Begin -// ============================================================================================ -// function: IsEdgeToAdd -// purpose: -// ============================================================================================ - -static Standard_Boolean IsEdgeToAdd - (const TopoDS_Shape &theEdge, - const TopTools_IndexedMapOfShape &theResultMap, - const TopTools_IndexedDataMapOfShapeListOfShape &theVEMapRes, - const BOPTools_PDSFiller &theDSFiller) -{ - if (theEdge.ShapeType() != TopAbs_EDGE) - return Standard_True; - - const BooleanOperations_ShapesDataStructure &aDS=theDSFiller->DS(); - const BOPTools_PaveFiller &aPvFiller=theDSFiller->PaveFiller(); - const BOPTools_SplitShapesPool &aSplitShapesPool=aPvFiller.SplitShapesPool(); - Standard_Integer aNbE1 = aDS.ShapeIndex(theEdge, 1); - Standard_Integer aNbE2 = aDS.ShapeIndex(theEdge, 2); - Standard_Integer aNbE = (aNbE1 == 0) ? aNbE2 : aNbE1; - - if (aNbE == 0) - return Standard_False; - - const BOPTools_ListOfPaveBlock &aLPB=aSplitShapesPool(aDS.RefEdge(aNbE)); - BOPTools_ListIteratorOfListOfPaveBlock aPBIt(aLPB); - - for (; aPBIt.More(); aPBIt.Next()) { - const BOPTools_PaveBlock& aPB = aPBIt.Value(); - Standard_Integer aSplitNb = aPB.Edge(); - const TopoDS_Shape& aSplit = aDS.Shape(aSplitNb); - - if (theResultMap.Contains(aSplit)) { - TopoDS_Vertex aVf; - TopoDS_Vertex aVl; - TopoDS_Edge anEdge = TopoDS::Edge(aSplit); - - TopExp::Vertices(anEdge, aVf, aVl); - - if (theVEMapRes.FindFromKey(aVf).Extent() < 2 || - theVEMapRes.FindFromKey(aVl).Extent() < 2) - return Standard_False; - } - } - - return Standard_True; -} -// Modified by skv - Wed Nov 5 15:52:50 2003 OCC3644 End - -// ============================================================================================ -// function: FillEdgeSection -// purpose: -// ============================================================================================ -void BOP_SectionHistoryCollector::FillEdgeSection - (const TopoDS_Shape &theEdge, - const BOPTools_PDSFiller &theDSFiller, - const TopTools_IndexedMapOfShape &theResultMap, - const TopTools_IndexedDataMapOfShapeListOfShape &theVEMapRes, - const TopTools_IndexedDataMapOfShapeListOfShape &theEFMap) -{ - if(myResult.IsNull()) - return; - - TopTools_IndexedDataMapOfShapeListOfShape aMapOfOldNewVertex; - - BOPTools_InterferencePool* pIntrPool = (BOPTools_InterferencePool*)&theDSFiller->InterfPool(); - const BOPTools_PavePool& aPavePool = theDSFiller->PaveFiller().PavePool(); - const BooleanOperations_ShapesDataStructure& aDS = theDSFiller->DS(); - - Standard_Integer anIndex = 0; - const BooleanOperations_IndexedDataMapOfShapeInteger& aMap1 = theDSFiller->DS().ShapeIndexMap(1); - const BooleanOperations_IndexedDataMapOfShapeInteger& aMap2 = theDSFiller->DS().ShapeIndexMap(2); - - if(aMap1.Contains(theEdge)) - anIndex = aMap1.FindFromKey(theEdge); - else if(aMap2.Contains(theEdge)) - anIndex = aMap2.FindFromKey(theEdge); - else - return; - - const BOPTools_PaveSet& aPaveSet = aPavePool.Value(aDS.RefEdge(anIndex)); - const BOPTools_ListOfPave& aListOfPave = aPaveSet.Set(); - BOPTools_ListIteratorOfListOfPave anIt(aListOfPave); - - for(; anIt.More(); anIt.Next()) { - const BOPTools_Pave& aPave = anIt.Value(); - const BooleanOperations_KindOfInterference aPaveType = aPave.Type(); - - if((aPaveType == BooleanOperations_EdgeSurface)) { - BOPTools_PShapeShapeInterference anInter = pIntrPool->GetInterference(aPave.Interference(), aPaveType); - - if(anInter == NULL) - continue; - - const TopoDS_Shape& aS1 = aDS.Shape(anInter->Index1()); - const TopoDS_Shape& aS2 = aDS.Shape(anInter->Index2()); - const TopoDS_Shape& aNewShape = aDS.Shape(anInter->NewShape()); - - if((aNewShape.ShapeType() != TopAbs_VERTEX) || - (!theVEMapRes.Contains(aNewShape))) - continue; - - if(theVEMapRes.FindFromKey(aNewShape).Extent() >= 2) - continue; - - if(aS1.IsSame(aNewShape) || aS2.IsSame(aNewShape)) { - TopTools_ListOfShape thelist; - if(!aMapOfOldNewVertex.Contains(aNewShape)) - aMapOfOldNewVertex.Add(aNewShape, thelist); - aMapOfOldNewVertex.ChangeFromKey(aNewShape).Append(aNewShape); - continue; - } - Standard_Boolean addfirst = Standard_True; - Standard_Boolean addsecond = Standard_True; - - for(Standard_Integer sit = 0; sit < 2; sit++) { - if(((sit == 0) && !addfirst) || ((sit != 0) && !addsecond)) - continue; - const TopoDS_Shape& aS = (sit == 0) ? aS1 : aS2; -// Modified by skv - Wed Nov 5 17:11:41 2003 OCC3644 Begin -// AddNewShape(aS, aNewShape, myGenMap); - if (IsEdgeToAdd(aS, theResultMap, theVEMapRes, theDSFiller)) - AddNewShape(aS, aNewShape, myGenMap); -// Modified by skv - Wed Nov 5 17:11:49 2003 OCC3644 End - } - } else if (aPaveType == BooleanOperations_EdgeEdge || - aPaveType == BooleanOperations_VertexEdge) { - // Special treatment of case Edge-Edge and Edge-Vertex interference. - BOPTools_PShapeShapeInterference anInter = pIntrPool->GetInterference(aPave.Interference(), aPaveType); - - if(anInter == NULL) - continue; - - const TopoDS_Shape& aS1 = aDS.Shape(anInter->Index1()); - const TopoDS_Shape& aS2 = aDS.Shape(anInter->Index2()); - const TopoDS_Shape& aNewShape = aDS.Shape(anInter->NewShape()); - - if((aNewShape.ShapeType() != TopAbs_VERTEX) || - (!theVEMapRes.Contains(aNewShape))) - continue; - - if(theVEMapRes.FindFromKey(aNewShape).Extent() >= 2) - continue; - - Standard_Boolean isAddObj = IsEdgeToAdd(aS1, theResultMap, theVEMapRes, theDSFiller); - Standard_Boolean isAddTool = IsEdgeToAdd(aS2, theResultMap, theVEMapRes, theDSFiller); - - if (!isAddObj) { - if (!theEFMap.Contains(aS1)) - continue; - - AddNewShape(aS2, aNewShape, myGenMap); - - const TopTools_ListOfShape &aFaces = theEFMap.FindFromKey(aS1); - TopTools_ListIteratorOfListOfShape aFIter(aFaces); - - for (; aFIter.More(); aFIter.Next()) { - const TopoDS_Shape &anAncFace = aFIter.Value(); - - AddNewShape(anAncFace, aNewShape, myGenMap); - } - } else if (!isAddTool) { - if (!theEFMap.Contains(aS2)) - continue; - - AddNewShape(aS1, aNewShape, myGenMap); - - const TopTools_ListOfShape &aFaces = theEFMap.FindFromKey(aS2); - TopTools_ListIteratorOfListOfShape aFIter(aFaces); - - for (; aFIter.More(); aFIter.Next()) { - const TopoDS_Shape &anAncFace = aFIter.Value(); - - AddNewShape(anAncFace, aNewShape, myGenMap); - } - } else { - if (!theEFMap.Contains(aS1) || !theEFMap.Contains(aS2)) - continue; - - AddNewShape(aS1, aNewShape, myGenMap); - AddNewShape(aS2, aNewShape, myGenMap); - - const TopTools_ListOfShape &aFaces1 = theEFMap.FindFromKey(aS1); - const TopTools_ListOfShape &aFaces2 = theEFMap.FindFromKey(aS1); - TopTools_ListIteratorOfListOfShape aFIter(aFaces1); - - for (; aFIter.More(); aFIter.Next()) { - const TopoDS_Shape &anAncFace = aFIter.Value(); - - AddNewShape(anAncFace, aNewShape, myGenMap); - } - - for (aFIter.Initialize(aFaces2); aFIter.More(); aFIter.Next()) { - const TopoDS_Shape &anAncFace = aFIter.Value(); - - AddNewShape(anAncFace, aNewShape, myGenMap); - } - } - } - } - - Standard_Integer i = 0, j = 0; - - for(j = 1; j <= aDS.NumberOfSuccessors(anIndex); j++) { - Standard_Integer avindex = aDS.GetSuccessor(anIndex, j); - - BOPTools_CArray1OfVVInterference& VVs = pIntrPool->VVInterferences(); - Standard_Integer aNb = VVs.Extent(); - - for (i = 1; i <= aNb; i++) { - BOPTools_VVInterference& VV=VVs(i); - Standard_Integer anIndex1 = VV.Index1(); - Standard_Integer anIndex2 = VV.Index2(); - - if((avindex == anIndex1) || (avindex == anIndex2)) { - Standard_Integer aNewShapeIndex = VV.NewShape(); - TopoDS_Shape aNewShape = aDS.Shape(aNewShapeIndex); - - if(!theVEMapRes.Contains(aNewShape)) - continue; - - if(theVEMapRes.FindFromKey(aNewShape).Extent() >= 2) - continue; - - for(Standard_Integer vit = 0; vit < 2; vit++) { - TopoDS_Shape aShape = (vit == 0) ? aDS.Shape(anIndex1) : aDS.Shape(anIndex2); - TopTools_ListOfShape thelist1; - if(!aMapOfOldNewVertex.Contains(aShape)) - aMapOfOldNewVertex.Add(aShape, thelist1); - aMapOfOldNewVertex.ChangeFromKey(aShape).Append(aNewShape); - } - break; - } - } - - for(Standard_Integer aninterit = 0; aninterit < 2; aninterit++) { - - if(aninterit == 0) - aNb = pIntrPool->VEInterferences().Extent(); - else - aNb = pIntrPool->VSInterferences().Extent(); - - for (i = 1; i <= aNb; i++) { - BOPTools_ShapeShapeInterference* anInterference = NULL; - - if(aninterit == 0) - anInterference = (BOPTools_ShapeShapeInterference*)(&pIntrPool->VEInterferences().Value(i)); - else - anInterference = (BOPTools_ShapeShapeInterference*)(&pIntrPool->VSInterferences().Value(i)); - Standard_Integer anIndex1 = anInterference->Index1(); - Standard_Integer anIndex2 = anInterference->Index2(); - - if((avindex == anIndex1) || (avindex == anIndex2)) { - Standard_Integer aNewShapeIndex = anInterference->NewShape(); - TopoDS_Shape aNewShape = aDS.Shape(aNewShapeIndex); - - if(!theVEMapRes.Contains(aNewShape)) - continue; - - if(theVEMapRes.FindFromKey(aNewShape).Extent() >= 2) - continue; - TopoDS_Shape aShape1 = aDS.Shape(avindex); - TopoDS_Shape aShape2 = (avindex == anIndex1) ? aDS.Shape(anIndex2) : aDS.Shape(anIndex1); - - if(aninterit == 0) { - TopTools_ListOfShape thelist2; - if(!aMapOfOldNewVertex.Contains(aShape1)) - aMapOfOldNewVertex.Add(aShape1, thelist2); - aMapOfOldNewVertex.ChangeFromKey(aShape1).Append(aNewShape); - } else { - Standard_Integer aRank = 1; - Standard_Integer aVtxIndex = aDS.ShapeIndex(aShape1, aRank); - - if (aVtxIndex == 0) { - aRank = 2; - aVtxIndex = aDS.ShapeIndex(aShape1, aRank); - } - - if (aVtxIndex != 0) { - Standard_Integer aNbEdges = aDS.NumberOfAncestors(aVtxIndex); - Standard_Integer anEdgeInd; - TopTools_MapOfShape anAddedFaces; - - for (anEdgeInd = 1; anEdgeInd <= aNbEdges; anEdgeInd++) { - Standard_Integer anEdgeId = aDS.GetAncestor(aVtxIndex, anEdgeInd); - const TopoDS_Shape &anEdge = aDS.GetShape(anEdgeId); - - if (IsEdgeToAdd(anEdge, theResultMap, theVEMapRes, theDSFiller)) - AddNewShape(anEdge, aNewShape, myGenMap); - } - } - } - -// Modified by skv - Wed Nov 5 17:11:41 2003 OCC3644 Begin -// AddNewShape(aShape2, aNewShape, myGenMap); - if (IsEdgeToAdd(aShape2, theResultMap, theVEMapRes, theDSFiller)) - AddNewShape(aShape2, aNewShape, myGenMap); -// Modified by skv - Wed Nov 5 17:11:49 2003 OCC3644 End - } - } - } - } - - if(!aMapOfOldNewVertex.IsEmpty()) { - Standard_Integer vit = 0; - - for(vit = 1; vit <= aMapOfOldNewVertex.Extent(); vit++) { - const TopoDS_Shape& aV = aMapOfOldNewVertex.FindKey(vit); - Standard_Integer aRank = 1; - Standard_Integer aVtxIndex = aDS.ShapeIndex(aV, aRank); - - if (aVtxIndex == 0) { - aRank = 2; - aVtxIndex = aDS.ShapeIndex(aV, aRank); - } - - if (aVtxIndex == 0) - continue; - - Standard_Integer aNbEdges = aDS.NumberOfAncestors(aVtxIndex); - Standard_Integer anEdgeInd; - TopTools_MapOfShape anAddedFaces; - const TopTools_ListOfShape& aNewVList = aMapOfOldNewVertex.FindFromIndex(vit); - - if(aNewVList.IsEmpty()) - continue; - - TopoDS_Shape aNewShape = aNewVList.First(); - - for (anEdgeInd = 1; anEdgeInd <= aNbEdges; anEdgeInd++) { - Standard_Integer anEdgeId = aDS.GetAncestor(aVtxIndex, anEdgeInd); - const TopoDS_Shape &anEdge = aDS.GetShape(anEdgeId); - const TopTools_ListOfShape &aFaces = theEFMap.FindFromKey(anEdge); - - TopTools_ListIteratorOfListOfShape aFaceIter(aFaces); - - for (; aFaceIter.More(); aFaceIter.Next()) { - const TopoDS_Shape &aFace = aFaceIter.Value(); - - if (!anAddedFaces.Add(aFace)) - continue; - - AddNewShape(aFace, aNewShape, myGenMap); - } - } - } - } -} - -// -------------------------------------------------------------------------------- -// static function: AddNewShape -// purpose: -// -------------------------------------------------------------------------------- -Standard_Boolean AddNewShape(const TopoDS_Shape& theKey, - const TopoDS_Shape& theItem, - TopTools_DataMapOfShapeListOfShape& theMap) { - - - if(!theMap.IsBound(theKey)) { - TopTools_ListOfShape aList; - aList.Append(theItem); - theMap.Bind(theKey, aList); - return Standard_True; - } - - Standard_Boolean found = Standard_False; - TopTools_ListOfShape& aList = theMap.ChangeFind(theKey); - TopTools_ListIteratorOfListOfShape aVIt(aList); - - for(; aVIt.More(); aVIt.Next()) { - if(theItem.IsSame(aVIt.Value())) { - found = Standard_True; - break; - } - } - - if(!found) { - aList.Append(theItem); - } - return !found; -} diff --git a/src/BOP/BOP_ShapeSet.cdl b/src/BOP/BOP_ShapeSet.cdl deleted file mode 100755 index 43744c57c0..0000000000 --- a/src/BOP/BOP_ShapeSet.cdl +++ /dev/null @@ -1,242 +0,0 @@ --- Created on: 1993-06-16 --- Created by: Jean Yves LEBEY --- Copyright (c) 1993-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class ShapeSet from BOP - - ---Purpose: - - -- Auxiliary class providing an exploration of a set - -- of shapes to build faces or solids. - - -- To build faces : shapes are wires, elements are edges. - -- To build solids : shapes are shells, elements are faces. - - -- The ShapeSet stores a list of shapes, a list of elements - -- to start reconstructions, and a map to search neighbours. - -- The map stores the connection between elements through - -- subshapes of type given in constructor. - - -- is : - -- - TopAbs_VERTEX to connect edges - -- - TopAbs_EDGE to connect faces - -- - -uses - - ShapeEnum from TopAbs, - - Orientation from TopAbs, - Shape from TopoDS, - - ListOfShape from TopTools, - ListIteratorOfListOfShape from TopTools, - IndexedDataMapOfShapeListOfShape from TopTools, - IndexedMapOfOrientedShape from TopTools, - - Explorer from TopExp - -is - - Create (SubShapeType : ShapeEnum from TopAbs) - returns ShapeSet from BOP; - ---Purpose: - --- Creates a ShapeSet in order to build shapes connected - --- by shapes. - --- - - Delete(me:out) - is virtual; - ---C++: alias "Standard_EXPORT virtual ~BOP_ShapeSet(){Delete() ; }" - ---Purpose: - --- Destructor - --- - AddShape(me:out; - S:Shape from TopoDS) - is virtual; - ---Purpose: - --- Adds to the list of shapes. (wires or shells). - --- - AddStartElement(me:out; - S:Shape from TopoDS) - is virtual; - ---Purpose: - --- Add S to the list of starting shapes used for reconstructions. - --- apply AddElement(S). - --- - AddElement(me:out; - S:Shape from TopoDS) - is virtual; - ---Purpose: - --- For each subshape SE of S of type mySubShapeType - --- Add subshapes of S to the map of subshapes (mySubShapeMap) - --- Add S to the list of shape incident to subshapes of S. - --- - ProcessAddShape(me:out; - S:Shape from TopoDS) - is static protected; - ---Purpose: - --- Internal purpose - --- - ProcessAddStartElement(me:out; - S:Shape from TopoDS) - is static protected; - ---Purpose: - --- Internal purpose - --- - ProcessAddElement(me:out; - S:Shape from TopoDS) - is static protected; - ---Purpose: - --- Internal purpose - --- - StartElements(me) - returns ListOfShape from TopTools; - ---C++: return const & - ---Purpose: - --- Selector. - --- - -- - -- - -- Iteration on the shapes of AddShape() - -- - InitShapes(me:out); - ---Purpose: - --- Internal purpose - --- - MoreShapes(me) - returns Boolean from Standard; - ---Purpose: - --- Internal purpose - --- - NextShape(me:in out); - ---Purpose: - --- Internal purpose - --- - Shape(me) - returns Shape from TopoDS; - ---C++: return const & - - -- - -- Iteration on the start elements of AddStartElement() - -- - InitStartElements(me:out); - - MoreStartElements(me) - returns Boolean from Standard; - ---Purpose: - --- Internal purpose - --- - NextStartElement(me:out); - ---Purpose: - --- Internal purpose - --- - StartElement(me) - returns Shape; - ---C++: return const & - ---Purpose: - --- Iteration on the neighbours of a shape of type myShapeType - --- through its subshapes of type mySubShapeType. - --- - InitNeighbours(me:out; - S:Shape from TopoDS) - is virtual; - - MoreNeighbours(me:out) - returns Boolean from Standard; - ---Purpose: - --- Internal purpose - --- - NextNeighbour(me: out); - ---Purpose: - --- Internal purpose - --- - Neighbour(me) - returns Shape from TopoDS; - ---C++: return const & - ---Purpose: - --- Internal purpose - --- - ChangeStartShapes(me:out) - returns ListOfShape from TopTools; - ---C++: return & - ---Purpose: - --- Modifier - --- - - FindNeighbours(me:in out) - is virtual; - ---Purpose: - --- Build the list of neighbour shapes of myCurrentShape - --- (neighbour shapes and myCurrentShapes are of type t) - --- Initialize myIncidentShapesIter on neighbour shapes. - --- - - MakeNeighboursList(me:in out;E,V:Shape) - returns ListOfShape from TopTools - is virtual; - ---C++: return const & - - MaxNumberSubShape(me:in out;Shape:Shape) - returns Integer; - - - ClearContents(me:out); - ---Purpose: - --- Clears myStartShapes,mySubShapeMap,myShapes - --- -fields - - myShapeType : ShapeEnum from TopAbs is protected; - -- shape type : edge - - mySubShapeType : ShapeEnum from TopAbs is protected; - -- subshape type : vertex - - --mySubShapeExplorer : ShapeExplorer from BOP is protected; - mySubShapeExplorer : Explorer from TopExp is protected; - -- explorer of edge vertices - - myStartShapes : ListOfShape from TopTools is protected; - -- list of starting edges - - myStartShapesIter : ListIteratorOfListOfShape from TopTools is protected; - -- myStartShapes iterator - - mySubShapeMap : IndexedDataMapOfShapeListOfShape from TopTools is protected; - -- map of vertices - -- mySubShapeMap(vertex) = list of incident edges to a vertex - - myIncidentShapesIter : ListIteratorOfListOfShape from TopTools is protected; - -- iter on list L of edges incident to a vertex, L = mySubShapeMap(vertex) - - myShapes : ListOfShape from TopTools is protected; - -- list of wires which are not to be reconstructed - - myShapesIter : ListIteratorOfListOfShape from TopTools is protected; - -- myShapes iterator - - myCurrentShape : Shape from TopoDS is protected; - -- current edge which neighbours are searched, using FindNeighbours() - - myCurrentShapeNeighbours : ListOfShape from TopTools is protected; - -- list of edges neighbour of the edge myCurrentShape - -end ShapeSet; diff --git a/src/BOP/BOP_ShapeSet.cxx b/src/BOP/BOP_ShapeSet.cxx deleted file mode 100755 index 80079f5a65..0000000000 --- a/src/BOP/BOP_ShapeSet.cxx +++ /dev/null @@ -1,348 +0,0 @@ -// Created on: 1993-06-17 -// Created by: Jean Yves LEBEY -// Copyright (c) 1993-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#include - -#include - -#include - -#include - - -//======================================================================= -//function : BOP_ShapeSet::BOP_ShapeSet -//purpose : -//======================================================================= -BOP_ShapeSet::BOP_ShapeSet(const TopAbs_ShapeEnum SubShapeType) -: - mySubShapeType(SubShapeType) -{ - switch (SubShapeType) { - case TopAbs_EDGE: - myShapeType = TopAbs_FACE; - break; - case TopAbs_VERTEX: - myShapeType = TopAbs_EDGE; - break; - default: - Standard_ProgramError::Raise("ShapeSet : bad ShapeType"); - break; - } -} -//======================================================================= -//function : Delete -//purpose : -//======================================================================= - void BOP_ShapeSet::Delete() -{} - -//======================================================================= -//function : ClearContents -//purpose : -//======================================================================= - void BOP_ShapeSet::ClearContents() -{ - myStartShapes.Clear(); - mySubShapeMap.Clear(); - myShapes.Clear(); - myCurrentShapeNeighbours.Clear(); -} - -//======================================================================= -//function : AddShape -//purpose : -//======================================================================= - void BOP_ShapeSet::AddShape(const TopoDS_Shape& S) -{ - ProcessAddShape(S); -} - -//======================================================================= -//function : AddStartElement -//purpose : -//======================================================================= - void BOP_ShapeSet::AddStartElement(const TopoDS_Shape& S) -{ - ProcessAddStartElement(S); -} - -//======================================================================= -//function : AddElement -//purpose : -//======================================================================= - void BOP_ShapeSet::AddElement(const TopoDS_Shape& S) -{ - ProcessAddElement(S); -} - -//======================================================================= -//function : ProcessAddShape -//purpose : -//======================================================================= - void BOP_ShapeSet::ProcessAddShape(const TopoDS_Shape& S) -{ - myShapes.Append(S); -} - -//======================================================================= -//function : ProcessAddStartElement -//purpose : -//======================================================================= - void BOP_ShapeSet::ProcessAddStartElement(const TopoDS_Shape& S) -{ - TopTools_ListIteratorOfListOfShape anIt(myStartShapes); - for (; anIt.More(); anIt.Next()) { - const TopoDS_Shape& aSInner=anIt.Value(); - if (aSInner==S) { - return; - } - } - myStartShapes.Append(S); - ProcessAddElement(S); -} - -//======================================================================= -//function : ProcessAddElement -//purpose : -//======================================================================= - void BOP_ShapeSet::ProcessAddElement(const TopoDS_Shape& S) -{ - Standard_Boolean b; - TopTools_ListOfShape Lemp; - - TopExp_Explorer Ex(S, mySubShapeType); - for (; Ex.More(); Ex.Next()) { - const TopoDS_Shape& subshape = Ex.Current(); - b = ( ! mySubShapeMap.Contains(subshape) ); - if ( b ) { - mySubShapeMap.Add(subshape, Lemp); - } - mySubShapeMap.ChangeFromKey(subshape).Append(S); - } -} - -//======================================================================= -//function : StartElements -//purpose : -//======================================================================= - const TopTools_ListOfShape& BOP_ShapeSet::StartElements()const -{ - return myStartShapes; -} - -//======================================================================= -//function : InitShapes -//purpose : -//======================================================================= - void BOP_ShapeSet::InitShapes() -{ - myShapesIter.Initialize(myShapes); -} - -//======================================================================= -//function : MoreShapes -//purpose : -//======================================================================= - Standard_Boolean BOP_ShapeSet::MoreShapes()const -{ - Standard_Boolean b = myShapesIter.More(); - return b; -} - -//======================================================================= -//function : NextShape -//purpose : -//======================================================================= - void BOP_ShapeSet::NextShape() -{ - myShapesIter.Next(); -} - -//======================================================================= -//function : Shape -//purpose : -//======================================================================= - const TopoDS_Shape& BOP_ShapeSet::Shape()const -{ - const TopoDS_Shape& S = myShapesIter.Value(); - return S; -} - -//======================================================================= -//function : InitStartElements -//purpose : -//======================================================================= - void BOP_ShapeSet::InitStartElements() -{ - myStartShapesIter.Initialize(myStartShapes); -} - -//======================================================================= -//function : MoreStartElements -//purpose : -//======================================================================= - Standard_Boolean BOP_ShapeSet::MoreStartElements()const -{ - Standard_Boolean b = myStartShapesIter.More(); - return b; -} - -//======================================================================= -//function : NextStartElement -//purpose : -//======================================================================= - void BOP_ShapeSet::NextStartElement() -{ - myStartShapesIter.Next(); -} - -//======================================================================= -//function : StartElement -//purpose : -//======================================================================= - const TopoDS_Shape& BOP_ShapeSet::StartElement()const -{ - const TopoDS_Shape& S = myStartShapesIter.Value(); - return S; -} - -//======================================================================= -//function : InitNeighbours -//purpose : -//======================================================================= - void BOP_ShapeSet::InitNeighbours(const TopoDS_Shape& S) -{ - mySubShapeExplorer.Init(S, mySubShapeType); - myCurrentShape = S; - FindNeighbours(); -} - -//======================================================================= -//function : MoreNeighbours -//purpose : -//======================================================================= - Standard_Boolean BOP_ShapeSet::MoreNeighbours() -{ - Standard_Boolean b = myIncidentShapesIter.More(); - return b; -} - -//======================================================================= -//function : NextNeighbour -//purpose : -//======================================================================= - void BOP_ShapeSet::NextNeighbour() -{ - Standard_Boolean noisimore, ssemore; - - myIncidentShapesIter.Next(); - noisimore = ! myIncidentShapesIter.More(); - if ( noisimore ) { - ssemore = mySubShapeExplorer.More(); - if ( ssemore ) { - mySubShapeExplorer.Next(); - FindNeighbours(); - } - } -} - -//======================================================================= -//function : Neighbour -//purpose : -//======================================================================= - const TopoDS_Shape& BOP_ShapeSet::Neighbour()const -{ - const TopoDS_Shape& S = myIncidentShapesIter.Value(); - return S; -} - -//======================================================================= -//function : ChangeStartShapes -//purpose : -//======================================================================= - TopTools_ListOfShape& BOP_ShapeSet::ChangeStartShapes() -{ - return myStartShapes; -} - -//======================================================================= -//function : FindNeighbours -//purpose : -//======================================================================= - void BOP_ShapeSet::FindNeighbours() -{ - while (mySubShapeExplorer.More()) { - // l = list of edges neighbour of edge myCurrentShape trough - // the vertex mySubShapeExplorer.Current(), which is a vertex of the - // edge myCurrentShape. - const TopoDS_Shape& V = mySubShapeExplorer.Current(); - const TopTools_ListOfShape & l = MakeNeighboursList(myCurrentShape,V); - // myIncidentShapesIter iterates on the neighbour edges of the edge - // given as InitNeighbours() argument (this edge has been stored - // in the field myCurrentShape). - myIncidentShapesIter.Initialize(l); - if (myIncidentShapesIter.More()) { - break; - } - else { - mySubShapeExplorer.Next(); - } - } -} - -//======================================================================= -//function : MakeNeighboursList -//purpose : -//======================================================================= - const TopTools_ListOfShape & BOP_ShapeSet::MakeNeighboursList(const TopoDS_Shape& ,//Earg, - const TopoDS_Shape& Varg) -{ - const TopTools_ListOfShape& l = mySubShapeMap.FindFromKey(Varg); - return l; -} - -//======================================================================= -//function : MaxNumberSubShape -//purpose : -//======================================================================= - Standard_Integer BOP_ShapeSet::MaxNumberSubShape(const TopoDS_Shape& Shape) -{ - Standard_Integer i, m = 0; - - TopExp_Explorer SE(Shape, mySubShapeType); - - while(SE.More()) { - const TopoDS_Shape& SubShape = SE.Current(); - if(!mySubShapeMap.Contains(SubShape)) { - SE.Next(); - continue; - } - - const TopTools_ListOfShape& l = mySubShapeMap.FindFromKey(SubShape); - i=l.Extent(); - m = Max(m, i); - SE.Next(); - } - return m; -} - - diff --git a/src/BOP/BOP_ShellFaceClassifier.cdl b/src/BOP/BOP_ShellFaceClassifier.cdl deleted file mode 100755 index 9a659c4bd0..0000000000 --- a/src/BOP/BOP_ShellFaceClassifier.cdl +++ /dev/null @@ -1,107 +0,0 @@ --- Created on: 2001-06-25 --- Created by: Michael KLOKOV --- Copyright (c) 2001-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class ShellFaceClassifier from BOP inherits CompositeClassifier from BOP - - - ---Purpose: - - --- The algorithm is to classify loops that - -- consist of faces and shells - --- - -uses - - Shape from TopoDS, - Shell from TopoDS, - State from TopAbs, - Pnt from gp, - Builder from BRep, - BlockBuilder from BOP, - SolidClassifier from BOP, - DataMapOfShapeShape from TopTools - -is - Create(theBlockBuilder: BlockBuilder from BOP) - returns ShellFaceClassifier from BOP; - ---Purpose: - --- Creates a classifier in 3D space, to compare - --- a face with a set of faces, - --- a shell with a set of faces, - --- a shell with a shell - --- - Clear(me: in out); - ---Purpose: - --- Clears contents of internal state of the object - --- - CompareShapes(me : in out; - B1 : Shape from TopoDS; - B2 : Shape from TopoDS) - returns State from TopAbs - is redefined; - ---Purpose: - --- Classify shape with shape - --- - CompareElementToShape(me : in out; - E : Shape from TopoDS; - B : Shape from TopoDS) - - returns State from TopAbs - is redefined; - ---Purpose: - --- Classify element with shape - --- - ResetShape(me : in out; - B : Shape from TopoDS) - is redefined; - ---Purpose: - --- Prepare classification involving shape - --- Calls ResetElement on first element of - --- - ResetElement(me : in out; - E : Shape from TopoDS) - is redefined; - ---Purpose: - --- Prepare classification involving element . - --- - CompareElement(me : in out; - E : Shape from TopoDS); - ---Purpose: - --- Add element in the set of elements used in classification. - --- - State(me : in out) - returns State from TopAbs - is redefined; - ---Purpose: - --- Returns state of classification of 2D point, defined by - --- ResetElement, with the current set of elements, - --- defined by Compare. - --- - -fields - - myFirstCompare: Boolean from Standard; - myPoint: Pnt from gp; - myShell: Shell from TopoDS; - myBuilder: Builder from BRep; - mySolidClassifier: SolidClassifier from BOP; - myFaceShellMap : DataMapOfShapeShape from TopTools; - -end ShellFaceClassifier from BOP; diff --git a/src/BOP/BOP_ShellFaceClassifier.cxx b/src/BOP/BOP_ShellFaceClassifier.cxx deleted file mode 100755 index a9130c3178..0000000000 --- a/src/BOP/BOP_ShellFaceClassifier.cxx +++ /dev/null @@ -1,179 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// ================================================================== -// function: BOP_ShellFaceClassifier::BOP_ShellFaceClassifier -// purpose: -// ================================================================== -BOP_ShellFaceClassifier::BOP_ShellFaceClassifier - (const BOP_BlockBuilder& theBlockBuilder) -: - BOP_CompositeClassifier(theBlockBuilder) -{ -} - -// =============================================================================================== -// function: Clear -// purpose: -// =============================================================================================== - void BOP_ShellFaceClassifier::Clear() -{ - mySolidClassifier.Clear(); - myFaceShellMap.Clear(); -} - -// =============================================================================================== -// function: CompareShapes -// purpose: -// =============================================================================================== - TopAbs_State BOP_ShellFaceClassifier::CompareShapes(const TopoDS_Shape& theShape1, - const TopoDS_Shape& theShape2) -{ - ResetShape(theShape1); - myShell = TopoDS::Shell(theShape2); - mySolidClassifier.LoadShell(myShell); - TopAbs_State aState = State(); - return aState; -} - -// =============================================================================================== -// function: CompareElementToShape -// purpose: -// =============================================================================================== - TopAbs_State BOP_ShellFaceClassifier::CompareElementToShape(const TopoDS_Shape& theElement, - const TopoDS_Shape& theShape) -{ - ResetElement(theElement); - myShell = TopoDS::Shell(theShape); - mySolidClassifier.LoadShell(myShell); - TopAbs_State aState = State(); - return aState; -} - -// =============================================================================================== -// function: ResetShape -// purpose: -// =============================================================================================== - void BOP_ShellFaceClassifier::ResetShape(const TopoDS_Shape& theShape) -{ - TopExp_Explorer anExp(theShape, TopAbs_FACE); - const TopoDS_Face& aFace = TopoDS::Face(anExp.Current()); - ResetElement(aFace); -} - -// =============================================================================================== -// function: ResetElement -// purpose: -// =============================================================================================== -void BOP_ShellFaceClassifier::ResetElement(const TopoDS_Shape& theElement) -{ - Standard_Boolean bFound; - TopAbs_ShapeEnum aShapeType; - TopExp_Explorer anExp; - // - myFirstCompare=Standard_True; - aShapeType=theElement.ShapeType(); - // - bFound=Standard_False; - anExp.Init(theElement, TopAbs_EDGE); - for(; anExp.More(); anExp.Next()) { - const TopoDS_Edge& aE=*((TopoDS_Edge*)&anExp.Current()); - if (!BRep_Tool::Degenerated(aE)) { - Standard_Real aT, aT1, aT2; - Handle(Geom_Curve) aC; - // - aC=BRep_Tool::Curve(aE, aT1, aT2); - aT=IntTools_Tools::IntermediatePoint(aT1, aT2); - aC->D0(aT, myPoint); - bFound=Standard_True; - break; - } - } - if (bFound) { - return; - } - // - // initialize myPoint with first vertex of face - anExp.Init(theElement, TopAbs_VERTEX); - if(anExp.More()) { - const TopoDS_Vertex& aVertex = TopoDS::Vertex(anExp.Current()); - myPoint = BRep_Tool::Pnt(aVertex); - } - else { - - if(aShapeType == TopAbs_FACE) { - BRepAdaptor_Surface BAS(TopoDS::Face(theElement)); - myPoint = BAS.Value((BAS.FirstUParameter()+BAS.LastUParameter()) * 0.5, - (BAS.FirstVParameter()+BAS.LastVParameter()) * 0.5); - } - else { - myPoint.SetCoord(0., 0., 0.); - } - } -} - -// =============================================================================================== -// function: CompareElement -// purpose: -// =============================================================================================== - void BOP_ShellFaceClassifier::CompareElement(const TopoDS_Shape& theElement) -{ - - if(myFirstCompare) { - Standard_Boolean found = myFaceShellMap.IsBound(theElement); - - if(!found) { - myBuilder.MakeShell(myShell); - myBuilder.Add(myShell, theElement); - myFaceShellMap.Bind(theElement, myShell); - } - else { - TopoDS_Shape sbid = myFaceShellMap.Find(theElement); - myShell = TopoDS::Shell(sbid); - } - myFirstCompare = Standard_False; - } - else { - myBuilder.Add(myShell, theElement); - } -} - -// ================================================================== -// function: State -// purpose: -// ================================================================== - TopAbs_State BOP_ShellFaceClassifier::State() -{ - TopAbs_State aState = TopAbs_UNKNOWN; - Standard_Real aTolerance = Precision::Confusion(); - mySolidClassifier.Classify(myShell, myPoint, aTolerance); - aState = mySolidClassifier.State(); - return aState; -} - diff --git a/src/BOP/BOP_ShellFaceSet.cdl b/src/BOP/BOP_ShellFaceSet.cdl deleted file mode 100755 index 6f4193a4e2..0000000000 --- a/src/BOP/BOP_ShellFaceSet.cdl +++ /dev/null @@ -1,53 +0,0 @@ --- Created on: 2001-06-25 --- Created by: Michael KLOKOV --- Copyright (c) 2001-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class ShellFaceSet from BOP inherits ShapeSet from BOP - - ---Purpose: class for set of faces and shells - --- -uses - Solid from TopoDS - -is - - Create - returns ShellFaceSet from BOP; - ---Purpose: - --- Empty Consreuctor - --- - Create(theSolid: Solid from TopoDS) - returns ShellFaceSet from BOP; - ---Purpose: - --- Creates the object to build blocks of faces - --- connected by edges. - --- - Solid(me) - returns Solid from TopoDS; - ---C++: return const & - ---C++: inline - ---Purpose: - --- Selector - --- - -fields - - mySolid : Solid from TopoDS; - -end ShellFaceSet from BOP; diff --git a/src/BOP/BOP_ShellFaceSet.cxx b/src/BOP/BOP_ShellFaceSet.cxx deleted file mode 100755 index c60e4b84b9..0000000000 --- a/src/BOP/BOP_ShellFaceSet.cxx +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include - -// ============================================================================= -// function: BOP_ShellFaceSet::BOP_ShellFaceSet -// purpose: -// ============================================================================= -BOP_ShellFaceSet::BOP_ShellFaceSet() : - BOP_ShapeSet(TopAbs_EDGE) -{ -} - -// ============================================================================= -// function: BOP_ShellFaceSet::BOP_ShellFaceSet -// purpose: -// ============================================================================= - BOP_ShellFaceSet::BOP_ShellFaceSet(const TopoDS_Solid& theSolid) : - BOP_ShapeSet(TopAbs_EDGE) -{ - mySolid = theSolid; -} diff --git a/src/BOP/BOP_ShellFaceSet.lxx b/src/BOP/BOP_ShellFaceSet.lxx deleted file mode 100755 index 6437e29f11..0000000000 --- a/src/BOP/BOP_ShellFaceSet.lxx +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -// ============================================================================= -// function: Solid -// purpose: -// ============================================================================= -inline const TopoDS_Solid& BOP_ShellFaceSet::Solid() const -{ - return mySolid; -} - - diff --git a/src/BOP/BOP_ShellShell.cdl b/src/BOP/BOP_ShellShell.cdl deleted file mode 100755 index 217d68494e..0000000000 --- a/src/BOP/BOP_ShellShell.cdl +++ /dev/null @@ -1,67 +0,0 @@ --- Created on: 2001-10-29 --- Created by: Peter KURNEV --- Copyright (c) 2001-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class ShellShell from BOP inherits ShellSolid from BOP - - ---Purpose: - --- Performs Boolean Operations (BO) - --- Common,Cut,Fuse for arguments that - --- are of type shell/shell - --- - -uses - - DSFiller from BOPTools - ---raises - -is - Create - returns ShellShell from BOP; - ---Purpose: - --- Empty constructor; - --- - DoWithFiller (me:out; - aDSF: DSFiller from BOPTools) - is redefined; - ---Purpose: - --- see base classes, please - --- - Destroy (me: in out) - is redefined; - ---C++: alias "Standard_EXPORT virtual ~BOP_ShellShell(){Destroy();}" - ---Purpose: - --- Destructor - --- - BuildResult(me: out) - is redefined; - ---Purpose: - --- see base classes, please - --- - DoNewFaces(me: out) - is redefined; - ---Purpose: - --- see base classes, please - --- - ---fields - -end ShellShell; diff --git a/src/BOP/BOP_ShellShell.cxx b/src/BOP/BOP_ShellShell.cxx deleted file mode 100755 index 199dc76e65..0000000000 --- a/src/BOP/BOP_ShellShell.cxx +++ /dev/null @@ -1,471 +0,0 @@ -// Created on: 2001-10-29 -// Created by: Peter KURNEV -// Copyright (c) 2001-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#include - - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include - -#include -#include - -#include - -#include - -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - - -//======================================================================= -// function: BOP_ShellShell::BOP_ShellShell -// purpose: -//======================================================================= -BOP_ShellShell::BOP_ShellShell() -{ -} - -//======================================================================= -// function: Destroy -// purpose: -//======================================================================= -void BOP_ShellShell::Destroy() { -} - -//======================================================================= -// function: DoWithFiller -// purpose: -//======================================================================= -void BOP_ShellShell::DoWithFiller(const BOPTools_DSFiller& aDSFiller) -{ - myErrorStatus=0; - myIsDone=Standard_False; - // - myResultMap.Clear(); - myModifiedMap.Clear(); - // - myDSFiller=(BOPTools_DSFiller*) &aDSFiller; - // - try { - OCC_CATCH_SIGNALS - - if(!myDSFiller->IsDone()) { - myErrorStatus = 1; - BOPTColStd_Dump::PrintMessage("DSFiller is invalid: Can not build result\n"); - return; - } - // - Standard_Boolean bIsNewFiller; - bIsNewFiller=aDSFiller.IsNewFiller(); - - if (bIsNewFiller) { - Prepare(); - aDSFiller.SetNewFiller(!bIsNewFiller); - } - // - DoNewFaces(); - // - BuildResult(); - // - // Treat of internals - CollectInternals(); - BOP_Refiner aRefiner; - aRefiner.SetShape(myResult); - aRefiner.SetInternals(myInternals); - aRefiner.Do(); - // - BOP_CorrectTolerances::CorrectTolerances(myResult, 0.01); - // - FillModified(); - myIsDone=Standard_True; - } - catch ( Standard_Failure ) { - myErrorStatus = 1; - BOPTColStd_Dump::PrintMessage("Can not build result\n"); - } -} - -//================================================================================= -// function: BuildResult -// purpose: -//================================================================================= -void BOP_ShellShell::BuildResult() -{ - const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); - - Standard_Integer i, j, aNb, iRank, aNbFaces; - BooleanOperations_StateOfShape aState, aStateToCompare; - BRep_Builder aBB; - TopoDS_Compound aFCompound, aRes; - // - Standard_Boolean bHasInterference; - BOPTools_InterferencePool* pInterfPool= - (BOPTools_InterferencePool*) &myDSFiller->InterfPool(); - BOPTools_CArray1OfInterferenceLine* pTable= - (BOPTools_CArray1OfInterferenceLine*) &pInterfPool->InterferenceTable(); - // - aBB.MakeCompound(aRes); - // - // 1. Make aCompound containing all faces for thr Result - aBB.MakeCompound(aFCompound); - // - // 1.1. Old Faces with right 3D-state - aNb=aDS.NumberOfSourceShapes(); - for (i=1; i<=aNb; i++) { - const TopoDS_Shape& aS=aDS.Shape(i); - if (aS.ShapeType()==TopAbs_FACE){ - // - BOPTools_InterferenceLine& anInterfLine=pTable->ChangeValue(i); - bHasInterference=anInterfLine.HasInterference(); - if (bHasInterference) { - continue; - } - // - aState=aDS.GetState(i); - if (aState==BooleanOperations_IN || - aState==BooleanOperations_OUT) { - iRank=aDS.Rank(i); - aStateToCompare=BOP_BuilderTools::StateToCompare(iRank, myOperation); - if (aState==aStateToCompare) { - aBB.Add(aFCompound, aS); - } - } - } - } - // - // 1.2. aListOfNewFaces - TopTools_ListIteratorOfListOfShape anIt(myNewFaces); - for(; anIt.More(); anIt.Next()) { - aBB.Add(aFCompound, anIt.Value()); - } - // - // 2. - TopTools_IndexedDataMapOfShapeListOfShape aEFMap; - TopTools_IndexedMapOfShape aProcessedEdges; - - TopExp::MapShapesAndAncestors(aFCompound, TopAbs_EDGE, TopAbs_FACE, aEFMap); - aNb=aEFMap.Extent(); - for (i=1; i<=aNb; i++) { - const TopoDS_Shape& aE=aEFMap.FindKey(i); - TopTools_IndexedMapOfShape aFaces; - Path (aE, aEFMap, aFaces, aProcessedEdges); - - TopoDS_Shell aShell, aShellNew; - aBB.MakeShell(aShell); - - aNbFaces=aFaces.Extent(); - if (aNbFaces) { - for (j=1; j<=aNbFaces; j++) { - const TopoDS_Shape& aF=aFaces(j); - aBB.Add(aShell, aF); - } - - OrientFacesOnShell(aShell, aShellNew); - - aBB.Add(aRes, aShellNew); - } - } - myResult=aRes; -} -//======================================================================= -// function: DoNewFaces -// purpose: -//======================================================================= - void BOP_ShellShell::DoNewFaces() -{ - const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); - BOPTools_InterferencePool* pIntrPool=(BOPTools_InterferencePool*)&myDSFiller->InterfPool(); - BOPTools_CArray1OfSSInterference& aFFs=pIntrPool->SSInterferences(); - // - // vars - Standard_Boolean bIsTouchCase, bIsTouch; - Standard_Integer i, aNb, j, aNbj, iFF, nF1, iRank, nF2; - TopTools_ListOfShape aListOfNewFaces; - TopTools_IndexedMapOfShape anEMap; - TopAbs_Orientation anOriF1; - // - // DoMap - BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger aFFMap; - BOP_BuilderTools::DoMap(aFFs, aFFMap); - // - aNb=aFFMap.Extent(); - // - for (i=1; i<=aNb; i++) { - // - // a. Prepare info about the Face nF1 and create WES for nF1 - nF1=aFFMap.FindKey(i); - const TopoDS_Face& aF1=TopoDS::Face(aDS.Shape(nF1)); - - anOriF1=aF1.Orientation(); - iRank=aDS.Rank(nF1); - - myFace=aF1; - myFace.Orientation(TopAbs_FORWARD); - BOP_WireEdgeSet aWES (myFace); - - const TColStd_IndexedMapOfInteger& aFFIndicesMap=aFFMap.FindFromIndex(i); - aNbj=aFFIndicesMap.Extent(); - // - // b. The Switch: Same Domain Faces or Non-Same Domain Faces - bIsTouchCase=Standard_False; - for (j=1; j<=aNbj; j++) { - iFF=aFFIndicesMap(j); - BOPTools_SSInterference& aFF=aFFs(iFF); - bIsTouchCase=aFF.IsTangentFaces(); - if (bIsTouchCase) { - break; - } - } - // - // c. Filling the WES for nF1 - if (bIsTouchCase) { - // 1. Add Split Parts having states in accordance with operation - AddSplitPartsINOUT (nF1, aWES); - // 2. Add Section Edges to the WES - for (j=1; j<=aNbj; j++) { - iFF=aFFIndicesMap(j); - BOPTools_SSInterference& aFF=aFFs(iFF); - bIsTouch=aFF.IsTangentFaces(); - if (!bIsTouch) { - AddSectionPartsSh(nF1, iFF, aWES); - } - } - // 3. Add IN2D, ON2D Parts to the WES - // - //modified by NIZNHY-PKV Fri Sep 14 10:00:44 2012f - BOP_WireEdgeSet aWES1 (myFace); - // - for (j=1; j<=aNbj; j++) { - iFF=aFFIndicesMap(j); - BOPTools_SSInterference& aFF=aFFs(iFF); - bIsTouch=aFF.IsTangentFaces(); - if (bIsTouch) { - nF2=aFF.OppositeIndex(nF1); - AddINON2DPartsSh(nF1, iFF, aWES1); - } - } - // - if (iRank==2 || (iRank==1 && myOperation==BOP_CUT)) { - // #0023431 - // Refine WES to remove duplicated edges: - // - for the faces of the Object: Cut operation - // - for the faces of the Tool: all operations - // - // The duplications caused by the separated treatment - // the faces of an argument for the cases when: - // -these faces contain shared edges and - // -they are same domain faces with the faces of the other argument. - TopTools_DataMapOfShapeInteger aDMSI; - - //-- - aWES1.InitStartElements(); - for (; aWES1.MoreStartElements(); aWES1.NextStartElement()) { - const TopoDS_Edge& aE=*((TopoDS_Edge*)&aWES1.StartElement()); - if (!aDMSI.IsBound(aE)) { - Standard_Integer iCnt=1; - // - aDMSI.Bind(aE, iCnt); - } - else { - Standard_Integer& iCnt=aDMSI.ChangeFind(aE); - ++iCnt; - } - } - // - aWES1.InitStartElements(); - for (; aWES1.MoreStartElements(); aWES1.NextStartElement()) { - const TopoDS_Shape& aE=aWES1.StartElement(); - const Standard_Integer& iCnt=aDMSI.Find(aE); - if (iCnt==1) { - aWES.AddStartElement(aE); - } - } - } - else { - aWES1.InitStartElements(); - for (; aWES1.MoreStartElements(); aWES1.NextStartElement()) { - const TopoDS_Shape& aE=aWES1.StartElement(); - aWES.AddStartElement(aE); - } - } - //-- - /* - for (j=1; j<=aNbj; j++) { - iFF=aFFIndicesMap(j); - BOPTools_SSInterference& aFF=aFFs(iFF); - bIsTouch=aFF.IsTangentFaces(); - if (bIsTouch) { - Standard_Integer nF2; - nF2=aFF.OppositeIndex(nF1); - AddINON2DPartsSh(nF1, iFF, aWES); - } - } - */ - //modified by NIZNHY-PKV Fri Sep 14 10:00:48 2012t - // 4. Add EF parts (E (from F2) on F1 ), - // where F2 is non-same-domain face to F1 - anEMap.Clear(); - // - // anEMap will contain all Split parts that has already in aWES - const TopTools_ListOfShape& aLE=aWES.StartElements(); - - Standard_Integer aNbEdges1 = aLE.Extent(); - - TopTools_ListIteratorOfListOfShape anIt; - anIt.Initialize (aLE); - for (; anIt.More(); anIt.Next()) { - TopoDS_Shape& anE=anIt.Value(); - anEMap.Add(anE); - } - // - // IFV's workaround for occ13538: - // It is necessary to avoid building SD faces twice in case if SD faces of object and tool - // fully coincide and face of object has adjacent faces along all boundaries. - // For such cases WES for second SD faces are built from EE edges. - // The sence of workarond is to find such situation by checking of number of EF edges. - // If number of EF edges == 0, it means that SD faces fully coincide. - Standard_Integer aNbEF; - for (j=1; j<=aNbj; j++) { - iFF=aFFIndicesMap(j); - BOPTools_SSInterference& aFF=aFFs(iFF); - bIsTouch=aFF.IsTangentFaces(); - if (!bIsTouch) { - AddPartsEFNonSDSh (nF1, iFF, anEMap, aWES); - } - } - // - aNbEF = aWES.StartElements().Extent() - aNbEdges1; - // - if((aNbEdges1 > 0) && (aNbEF > 0)) { - for (j=1; j<=aNbj; j++) { - iFF=aFFIndicesMap(j); - BOPTools_SSInterference& aFF=aFFs(iFF); - bIsTouch=aFF.IsTangentFaces(); - if (!bIsTouch) { - AddPartsEENonSDSh (nF1, iFF, anEMap, aWES); - } - } - } - // IFV's workaround for occ13538 - end - // - }// end of if (bIsTouchCase) - else { - // 1. Add Split Parts having states in accordance with operation - AddSplitPartsINOUT (nF1, aWES); - // 2. Add Split Parts with state ON - AddSplitPartsONSh (nF1, aWES); - // 3. Add Section Edges to the WES - for (j=1; j<=aNbj; j++) { - iFF=aFFIndicesMap(j); - AddSectionPartsSh(nF1, iFF, aWES); - } - // 4. Add EF parts (E (from F2) on F1 ) - anEMap.Clear(); - for (j=1; j<=aNbj; j++) { - iFF=aFFIndicesMap(j); - AddPartsEFSh(nF1, iFF, anEMap, aWES); - } - }// end of (bIsTouchCase)'s else - // - // - // d. Build new Faces from myFace - BOP_FaceBuilder aFB; - aFB.SetTreatment(0); // 0-Do Internal Edges - aFB.SetTreatSDScales(1); - aFB.Do(aWES); - - const TopTools_ListOfShape& aLF=aFB.NewFaces(); - // - // e. Do Internal Vertices - // - DoInternalVertices(nF1, aLF); - // - // f. Orient new faces - TopTools_ListOfShape aLFx; - TopTools_ListIteratorOfListOfShape anIt; - anIt.Initialize(aLF); - for (; anIt.More(); anIt.Next()) { - TopoDS_Shape& aFx=anIt.Value(); - aFx.Orientation(anOriF1); - aListOfNewFaces.Append(aFx); - aLFx.Append(aFx); - } - // - // Fill "Modified" - FillModified(aF1, aLFx); - // - }// for (i=1; i<=aNb; i++) - // - - myNewFaces.Clear(); - myNewFaces.Append(aListOfNewFaces); -} -/* DEB - { - TopoDS_Compound aCx; - BRep_Builder aBB; - // - aBB.MakeCompound(aCx); - aBB.Add(aCx, myFace); - // - aWES.InitStartElements(); - for (; aWES.MoreStartElements(); aWES.NextStartElement()) { - const TopoDS_Shape& aE = aWES.StartElement(); - aBB.Add(aCx, aE); - } - int a=0; - } - -*/ diff --git a/src/BOP/BOP_ShellSolid.cdl b/src/BOP/BOP_ShellSolid.cdl deleted file mode 100755 index 784f4ee174..0000000000 --- a/src/BOP/BOP_ShellSolid.cdl +++ /dev/null @@ -1,329 +0,0 @@ --- Created on: 2001-11-02 --- Created by: Peter KURNEV --- Copyright (c) 2001-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class ShellSolid from BOP inherits Builder from BOP - - ---Purpose: - --- Performs Boolean Operations (BO) - -- Common,Cut,Fuse for arguments of - -- shell/solid type - --- -uses - - DSFiller from BOPTools, - - WireEdgeSet from BOP, - ShellFaceSet from BOP, - Operation from BOP, - HistoryCollector from BOP, - - Shape from TopoDS, - Edge from TopoDS, - Face from TopoDS, - Shell from TopoDS, - - ListOfShape from TopTools, - IndexedDataMapOfShapeListOfShape from TopTools, - IndexedMapOfShape from TopTools, - DataMapOfShapeInteger from TopTools, - - IndexedMapOfInteger from TColStd, - - StateOfShape from BooleanOperations, - State from TopAbs, - --modified by NIZHNY-MKK Tue Sep 7 11:37:57 2004 - ShapeEnum from TopAbs, - - Orientation from TopAbs - -is - - Create - returns ShellSolid from BOP; - ---Purpose: - --- Empty constructor; - --- - Do (me:out) - is redefined; - ---Purpose: - --- see base classes, please - --- - DoWithFiller (me:out; - aDSF: DSFiller from BOPTools) - is redefined; - ---Purpose: - --- see base classes, please - --- - Destroy (me: in out) - is redefined; - ---C++: alias "Standard_EXPORT virtual ~BOP_ShellSolid(){Destroy();}" - ---Purpose: - --- Destructor - --- - BuildResult (me:out) - is redefined ; - ---Purpose: - --- see base classes, please - --- - DoNewFaces(me: in out) - is virtual; - ---Purpose: - --- see base classes, please - --- - Prepare(me:out) - --modified by NIZNHY-PKV Wed Sep 11 17:55:29 2002 f - is virtual;--protected; - --modified by NIZNHY-PKV Wed Sep 11 17:55:32 2002 t - ---Purpose: - --- Provides some preparing steps of algorithm - --- 1. Compute the 3D-States - --- 2. Compute P-Curves for section- and split- edges - --- 3. Treat degenerated edges - --- 4 Detect Same Domain faces - --- - DetectSDFaces (me:out) - is protected; - ---Purpose: - --- The algo to find SameDomain Faces - --- among interferred ones - --- - ---------------------------------------------- - -- - -- W E S C O M P O N E N T S - -- - -- (for internal usage) - -- - -- - AddSplitPartsINOUT (me:out; - nF1 :Integer from Standard; - aWES :out WireEdgeSet from BOP) - is protected; - --- - --- WES components for an argument of SHELL type - --- - AddSectionPartsSh (me:out; - nF1 :Integer from Standard; - iFF :Integer from Standard; - aWES :out WireEdgeSet from BOP) - is protected ; - - AddSplitPartsONSh (me:out; - nF1 :Integer from Standard; - aWES :out WireEdgeSet from BOP) - is protected; - - AddPartsEFSh (me:out; - nF1 :Integer from Standard; - iFF :Integer from Standard; - anEMap : out IndexedMapOfShape from TopTools; - aWES :out WireEdgeSet from BOP) - is protected; - - AddINON2DPartsSh (me:out; - nF1 :Integer from Standard; - iFF :Integer from Standard; - aWES :out WireEdgeSet from BOP) - is protected; - - AddINON2DPartsSh (me:out; - nF1 :Integer from Standard; - iFF :Integer from Standard; - aWES :out WireEdgeSet from BOP; - anEMap : out IndexedMapOfShape from TopTools) - is protected; - -- - AddPartsEFNonSDSh (me:out; - nF1 :Integer from Standard; - iFF :Integer from Standard; - anEMap : out IndexedMapOfShape from TopTools; - aWES :out WireEdgeSet from BOP) - is protected; - - AddPartsEENonSDSh (me:out; - nF1 :Integer from Standard; - iFF :Integer from Standard; - anEMap : out IndexedMapOfShape from TopTools; - aWES :out WireEdgeSet from BOP) - is protected; - --- - --- WES components for an argument of SOLID type - --- - AddSectionPartsSo (me:out; - nF1 :Integer from Standard; - iFF :Integer from Standard; - aWES :out WireEdgeSet from BOP) - is protected; - - AddSplitPartsON3DSo (me:out; - nF1 :Integer from Standard; - iFF :Integer from Standard; - aWES :out WireEdgeSet from BOP) - is protected; - - AddSplitPartsONSo(me:out; - nF1 :Integer from Standard; - aMEFObj :IndexedDataMapOfShapeListOfShape from TopTools; - aMEFTool:IndexedDataMapOfShapeListOfShape from TopTools; - aWES :out WireEdgeSet from BOP) - is protected; - - AddPartsEFSo (me:out; - nF1 :Integer from Standard; - iFF :Integer from Standard; - aMEFObj :IndexedDataMapOfShapeListOfShape from TopTools; - aMEFTool:IndexedDataMapOfShapeListOfShape from TopTools; - anEMap : out IndexedMapOfShape from TopTools; - aWES :out WireEdgeSet from BOP) - is protected; - - AddINON2DPartsSo (me:out; - iFF :Integer from Standard; - nF1 :Integer from Standard; - nF2 :Integer from Standard; - aWES :out WireEdgeSet from BOP) - is protected; - - AddPartsEFSDSo (me:out; - nF1 :Integer from Standard; - iFF :Integer from Standard; - aMEFObj :IndexedDataMapOfShapeListOfShape from TopTools; - aMEFTool:IndexedDataMapOfShapeListOfShape from TopTools; - aWES :out WireEdgeSet from BOP) - is protected; - - AddPartsEFNonSDSo (me:out; - nF1 :Integer from Standard; - iFF :Integer from Standard; - aMEFObj :IndexedDataMapOfShapeListOfShape from TopTools; - aMEFTool:IndexedDataMapOfShapeListOfShape from TopTools; - aFFInMap:IndexedMapOfInteger from TColStd; - anEMap : out IndexedMapOfShape from TopTools; - aWES :out WireEdgeSet from BOP) - is protected; - - AddPartsEENonSDSo (me:out; - nF1 :Integer from Standard; - iFF :Integer from Standard; - aMEFObj :IndexedDataMapOfShapeListOfShape from TopTools; - aMEFTool:IndexedDataMapOfShapeListOfShape from TopTools; - aFFInMap:IndexedMapOfInteger from TColStd; - anEMap : out IndexedMapOfShape from TopTools; - aWES :out WireEdgeSet from BOP) - is protected; - - AddPartsEESDSo (me:out; - nF1 :Integer from Standard; - iFF :Integer from Standard; - aMEFObj :IndexedDataMapOfShapeListOfShape from TopTools; - aMEFTool:IndexedDataMapOfShapeListOfShape from TopTools; - aWES :out WireEdgeSet from BOP) - is protected; - ---modified by NIZHNY-MKK Tue Sep 7 11:38:00 2004 - CheckArgTypes(myclass; theType1, theType2: ShapeEnum from TopAbs; - theOperation: Operation from BOP) - returns Boolean from Standard; - ---Purpose: - --- Check the types of arguments. - --- Returns FALSE if types of arguments - --- are non-valid to be treated by the - --- agorithm - - CheckArgTypes(me) - returns Boolean from Standard; - ---Purpose: - --- Check the types of arguments. - --- Returns FALSE if types of arguments - --- are non-valid to be treated by the - --- agorithm - --- - Path(myclass; - aE:Shape from TopoDS; - aEFMap: IndexedDataMapOfShapeListOfShape from TopTools; - aFaces: out IndexedMapOfShape from TopTools; - aProcE: out IndexedMapOfShape from TopTools) - is protected; - ---Purpose: - --- Internal usage - --- - Orientation(myclass; - aE: Edge from TopoDS; - aF: Face from TopoDS) - returns Orientation from TopAbs - is protected; - ---Purpose: - --- Internal usage - --- - OrientFacesOnShell (myclass; - aShell: Shell from TopoDS; - aShellNew: out Shell from TopoDS) - is protected; - ---Purpose: - --- - --- Internal usage - --- - DoInternalVertices (me:out; - nF1:Integer from Standard; - aFaces: ListOfShape from TopTools) - is protected; - ---Purpose: - --- Internal usage - --- - Internals(me) - returns ListOfShape from TopTools - is protected; - ---C++: return const & - ---Purpose: - --- Internal usage - --- - CollectInternals(me:out) - is protected; - ---Purpose: - --- Internal usage - --- - - FillSectionEdges(me:out) - is protected; - ---Purpose: - --- Internal usage - --- - - - SplitFace(me; theFaceIndex: Integer from Standard; - theMapOfEdgeIndex: out DataMapOfShapeInteger from TopTools; - theListOfFace: out ListOfShape from TopTools) - returns Boolean from Standard; - - SetHistoryCollector(me: in out; theHistory: HistoryCollector from BOP) - is redefined virtual; - -fields - - myFace : Face from TopoDS - is protected; - myNewFaces : ListOfShape from TopTools - is protected; - myInternals : ListOfShape from TopTools - is protected; - myRank : Integer from Standard - is protected; - -end ShellSolid; diff --git a/src/BOP/BOP_ShellSolid.cxx b/src/BOP/BOP_ShellSolid.cxx deleted file mode 100755 index ac83bb443d..0000000000 --- a/src/BOP/BOP_ShellSolid.cxx +++ /dev/null @@ -1,1381 +0,0 @@ -// Created on: 2001-11-02 -// Created by: Peter KURNEV -// Copyright (c) 2001-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#include - -#include -#include -#include - -#include -#include - -#include - -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include -#include - -#include -#include -#include - -#include - -static Standard_Boolean CheckSameDomainFaceInside(const TopoDS_Face& theFace1, - const TopoDS_Face& theFace2); - -////// - -//======================================================================= -// function: BOP_ShellSolid::BOP_ShellSolid -// purpose: -//======================================================================= - BOP_ShellSolid::BOP_ShellSolid() -{ - char* xr=getenv("MDISP"); - if (xr!=NULL) { - myDraw=0; - if (!strcmp (xr, "yes")) { - myDraw=1; - } - } - else { - myDraw=0; - } - myRank=0; -} -//======================================================================= -// function: Destroy -// purpose: -//======================================================================= - void BOP_ShellSolid::Destroy() {} - -//======================================================================= -// function: Do -// purpose: -//======================================================================= - void BOP_ShellSolid::Do() -{ - myErrorStatus=0; - myIsDone=Standard_False; - // - // Filling the DS - BOPTools_DSFiller aDSFiller; - aDSFiller.SetShapes (myShape1, myShape2); - // - aDSFiller.Perform (); - // - DoWithFiller(aDSFiller); -} - -//======================================================================= -// function: DoWithFiller -// purpose: -//======================================================================= - void BOP_ShellSolid::DoWithFiller(const BOPTools_DSFiller& aDSFiller) -{ - myErrorStatus=0; - myIsDone=Standard_False; - // - myResultMap.Clear(); - myModifiedMap.Clear(); - // - myDSFiller=(BOPTools_DSFiller*) &aDSFiller; - // - - try { - OCC_CATCH_SIGNALS - if(!myDSFiller->IsDone()) { - myErrorStatus = 1; - BOPTColStd_Dump::PrintMessage("DSFiller is invalid: Can not build result\n"); - return; - } - Standard_Boolean bCheckTypes; - - bCheckTypes=CheckArgTypes(); - if (!bCheckTypes) { - myErrorStatus=10; - return; - } - // - Standard_Boolean bIsNewFiller; - bIsNewFiller=aDSFiller.IsNewFiller(); - - if (bIsNewFiller) { - Prepare(); - aDSFiller.SetNewFiller(!bIsNewFiller); - } - // - myRank=(myDSFiller->DS().Object().ShapeType()==TopAbs_SHELL) ? 1 : 2; - // - DoNewFaces(); - // - BuildResult(); - // - // Treat of internals - CollectInternals(); - BOP_Refiner aRefiner; - aRefiner.SetShape(myResult); - aRefiner.SetInternals(myInternals); - aRefiner.Do(); - // - // - BOP_CorrectTolerances::CorrectTolerances(myResult, 0.01); - // - FillModified(); - - if(!myHistory.IsNull()) { - Handle(BOP_ShellSolidHistoryCollector) aHistory = - Handle(BOP_ShellSolidHistoryCollector)::DownCast(myHistory); - aHistory->SetResult(myResult, myDSFiller); - } - myIsDone=Standard_True; - } - catch ( Standard_Failure ) { - myErrorStatus = 1; - BOPTColStd_Dump::PrintMessage("Can not build result\n"); - } -} - -//================================================================================= -// function: BuildResult -// purpose: -//================================================================================= - void BOP_ShellSolid::BuildResult() -{ - const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); - - Standard_Integer i, j, aNb, iRank, aNbFaces; - BooleanOperations_StateOfShape aState, aStateToCompare; - BRep_Builder aBB; - TopoDS_Compound aFCompound, aRes; - // - aBB.MakeCompound(aRes); - // - // 1. Make aCompound containing all faces for thr Result - aBB.MakeCompound(aFCompound); - // - // 1.1. Old Faces with right 3D-state - aNb=aDS.NumberOfSourceShapes(); - for (i=1; i<=aNb; i++) { - const TopoDS_Shape& aS=aDS.Shape(i); - - if (aS.ShapeType()==TopAbs_FACE){ - if (aDS.Rank(i)==myRank){ - aState=aDS.GetState(i); - if (aState==BooleanOperations_IN || - aState==BooleanOperations_OUT) { - iRank=aDS.Rank(i); - aStateToCompare=BOP_BuilderTools::StateToCompare(iRank, myOperation); - if (aState==aStateToCompare) { - aBB.Add(aFCompound, aS); - } - } - } - } - } - // - // 1.2. aListOfNewFaces - TopTools_ListIteratorOfListOfShape anIt(myNewFaces); - for(; anIt.More(); anIt.Next()) { - aBB.Add(aFCompound, anIt.Value()); - } - // - // 2. - TopTools_IndexedDataMapOfShapeListOfShape aEFMap; - TopTools_IndexedMapOfShape aProcessedEdges; - - TopExp::MapShapesAndAncestors(aFCompound, TopAbs_EDGE, TopAbs_FACE, aEFMap); - aNb=aEFMap.Extent(); - for (i=1; i<=aNb; i++) { - const TopoDS_Shape& aE=aEFMap.FindKey(i); - TopTools_IndexedMapOfShape aFaces; - Path (aE, aEFMap, aFaces, aProcessedEdges); - - TopoDS_Shell aShell, aShellNew; - aBB.MakeShell(aShell); - - aNbFaces=aFaces.Extent(); - if (aNbFaces) { - for (j=1; j<=aNbFaces; j++) { - const TopoDS_Shape& aF=aFaces(j); - aBB.Add(aShell, aF); - } - - OrientFacesOnShell(aShell, aShellNew); - - aBB.Add(aRes, aShellNew); - } - } - myResult=aRes; -} - -//======================================================================= -// function: DoNewFaces -// purpose: -//======================================================================= - void BOP_ShellSolid::DoNewFaces() -{ - const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); - BOPTools_InterferencePool* pIntrPool=(BOPTools_InterferencePool*)&myDSFiller->InterfPool(); - BOPTools_CArray1OfSSInterference& aFFs=pIntrPool->SSInterferences(); - // - // EF Maps - const TopoDS_Shape& anObj=aDS.Object(); - const TopoDS_Shape& aTool=aDS.Tool(); - - TopTools_IndexedMapOfShape anEMap; - TopTools_IndexedDataMapOfShapeListOfShape aMEFObj, aMEFTool; - TopExp::MapShapesAndAncestors (anObj, TopAbs_EDGE , TopAbs_FACE , aMEFObj); - TopExp::MapShapesAndAncestors (aTool, TopAbs_EDGE , TopAbs_FACE , aMEFTool); - // - // vars - Standard_Boolean bIsTouchCase, bIsTouch; - Standard_Integer i, aNb, j, aNbj, iFF, nF1, iRank; - TopTools_ListOfShape aListOfNewFaces; - TopAbs_Orientation anOriF1; - // - // DoMap - BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger aFFMap; - BOP_BuilderTools::DoMap(aFFs, aFFMap); - - // - aNb=aFFMap.Extent(); - for (i=1; i<=aNb; i++) { - // - // a. Prepare info about the Face nF1 and create WES for nF1 - nF1=aFFMap.FindKey(i); - const TopoDS_Face& aF1=TopoDS::Face(aDS.Shape(nF1)); - - anOriF1=aF1.Orientation(); - iRank=aDS.Rank(nF1); - - if (iRank!=myRank) { - continue; - } - - myFace=aF1; - myFace.Orientation(TopAbs_FORWARD); - BOP_WireEdgeSet aWES (myFace); - - const TColStd_IndexedMapOfInteger& aFFIndicesMap=aFFMap.FindFromIndex(i); - aNbj=aFFIndicesMap.Extent(); - // - // b. The Switch: Same Domain Faces or Non-Same Domain Faces - bIsTouchCase=Standard_False; - for (j=1; j<=aNbj; j++) { - iFF=aFFIndicesMap(j); - BOPTools_SSInterference& aFF=aFFs(iFF); - bIsTouchCase=aFF.IsTangentFaces(); - if (bIsTouchCase) { - break; - } - } - // - // c. Filling the WES for nF1 - if (bIsTouchCase) { - // 1. Add Split Parts having states in accordance with operation - AddSplitPartsINOUT (nF1, aWES); - // 2. Add Section Edges to the WES - for (j=1; j<=aNbj; j++) { - iFF=aFFIndicesMap(j); - BOPTools_SSInterference& aFF=aFFs(iFF); - bIsTouch=aFF.IsTangentFaces(); - if (!bIsTouch) { - AddSectionPartsSo(nF1, iFF, aWES); - } - } - // 3. Add IN2D, ON2D Parts to the WES - anEMap.Clear();// xft - for (j=1; j<=aNbj; j++) { - iFF=aFFIndicesMap(j); - BOPTools_SSInterference& aFF=aFFs(iFF); - bIsTouch=aFF.IsTangentFaces(); - if (bIsTouch) { - //xf - //AddINON2DPartsSh(nF1, iFF, aWES); - AddINON2DPartsSh(nF1, iFF, aWES, anEMap); - //xt - } - } - // 4. Add EF parts (E (from F2) on F1 ), - // where F2 is non-same-domain face to F1 - //anEMap.Clear();//xft - // - // anEMap will contain all Split parts that has already in aWES - const TopTools_ListOfShape& aLE=aWES.StartElements(); - TopTools_ListIteratorOfListOfShape anIt; - anIt.Initialize (aLE); - for (; anIt.More(); anIt.Next()) { - TopoDS_Shape& anE=anIt.Value(); - anEMap.Add(anE); - } - // - for (j=1; j<=aNbj; j++) { - iFF=aFFIndicesMap(j); - BOPTools_SSInterference& aFF=aFFs(iFF); - bIsTouch=aFF.IsTangentFaces(); - if (!bIsTouch) { - AddPartsEFNonSDSh (nF1, iFF, anEMap, aWES); - AddPartsEENonSDSh (nF1, iFF, anEMap, aWES); - } - } - // - }// end of if (bIsTouchCase) - else { - // 1. Add Split Parts having states in accordance with operation - AddSplitPartsINOUT (nF1, aWES); - // 2. Add Split Parts with state ON - AddSplitPartsONSo (nF1, aMEFObj, aMEFTool, aWES); - // 3. Add Section Edges to the WES - for (j=1; j<=aNbj; j++) { - iFF=aFFIndicesMap(j); - AddSectionPartsSo(nF1, iFF, aWES); - } - // 4. Add EF parts (E (from F2) on F1 ) - anEMap.Clear(); - for (j=1; j<=aNbj; j++) { - iFF=aFFIndicesMap(j); - AddPartsEFSo(nF1, iFF, aMEFObj, aMEFTool, anEMap, aWES); - } - - }// end of (bIsTouchCase)'s else - // - //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - // Display the WES - if (myDraw) { - const TopTools_ListOfShape& aWESL=aWES.StartElements(); - BOP_Draw::DrawListOfEdgesWithPC (myFace, aWESL, i, "ew_"); - BOP_Draw::Wait(); - } - //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - // - // d. Build new Faces from myFace - BOP_FaceBuilder aFB; - aFB.SetTreatSDScales(1); - aFB.SetTreatment(0); // 0-Do Internal Edges - aFB.Do(aWES); - - const TopTools_ListOfShape& aLF=aFB.NewFaces(); - // - // e. Do Internal Vertices - DoInternalVertices(nF1, aLF); - // - // f. Orient new faces - TopTools_ListOfShape aLFx; - TopTools_ListIteratorOfListOfShape anIt; - anIt.Initialize(aLF); - for (; anIt.More(); anIt.Next()) { - TopoDS_Shape& aFx=anIt.Value(); - aFx.Orientation(anOriF1); - aListOfNewFaces.Append(aFx); - aLFx.Append(aFx); - - if(!myHistory.IsNull()) { - Handle(BOP_ShellSolidHistoryCollector) aHistory = - Handle(BOP_ShellSolidHistoryCollector)::DownCast(myHistory); - - if(!aHistory.IsNull()) { - aHistory->AddNewFace(aF1, aFx, myDSFiller); - } - } - } - // - // Fill "Modified" - FillModified(aF1, aLFx); - // - }// for (i=1; i<=aNb; i++) - //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - // Display the new Faces - if (myDraw) { - BOP_Draw::DrawListOfShape(aListOfNewFaces, "fn_"); - } - //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - myNewFaces.Clear(); - myNewFaces.Append(aListOfNewFaces); -} - -//======================================================================= -// function: DetectSDFaces -// purpose: -//======================================================================= - void BOP_ShellSolid::DetectSDFaces() -{ - const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); - BOPTools_InterferencePool* pIntrPool=(BOPTools_InterferencePool*)&myDSFiller->InterfPool(); - BOPTools_CArray1OfSSInterference& aFFs=pIntrPool->SSInterferences(); - // - Standard_Boolean bFlag; - Standard_Integer i, aNb, nF1, nF2, iZone, aNbSps, iSenseFlag; - gp_Dir aDNF1, aDNF2; - - aNb=aFFs.Extent(); - for (i=1; i<=aNb; i++) { - bFlag=Standard_False; - - BOPTools_SSInterference& aFF=aFFs(i); - - nF1=aFF.Index1(); - nF2=aFF.Index2(); - const TopoDS_Face& aF1=TopoDS::Face(aDS.Shape(nF1)); - const TopoDS_Face& aF2=TopoDS::Face(aDS.Shape(nF2)); - // - // iSenseFlag; - const BOPTools_ListOfPaveBlock& aLPB=aFF.PaveBlocks(); - aNbSps=aLPB.Extent(); - - if (!aNbSps) { - continue; - } - - const BOPTools_PaveBlock& aPB=aLPB.First(); - const TopoDS_Edge& aSpE=TopoDS::Edge(aDS.Shape(aPB.Edge())); - - BOPTools_Tools3D::GetNormalToFaceOnEdge (aSpE, aF1, aDNF1); - BOPTools_Tools3D::GetNormalToFaceOnEdge (aSpE, aF2, aDNF2); - iSenseFlag=BOPTools_Tools3D::SenseFlag (aDNF1, aDNF2); - // - if (iSenseFlag==1 || iSenseFlag==-1) { - // - // - TopoDS_Face aF1FWD=aF1; - aF1FWD.Orientation (TopAbs_FORWARD); - - BOP_WireEdgeSet aWES (aF1FWD); - BOP_SDFWESFiller aWESFiller(nF1, nF2, *myDSFiller); - aWESFiller.SetSenseFlag(iSenseFlag); - aWESFiller.SetOperation(BOP_COMMON); - aWESFiller.Do(aWES); - - BOP_FaceBuilder aFB; - aFB.Do(aWES); - const TopTools_ListOfShape& aLF=aFB.NewFaces(); - - iZone=0; - TopTools_ListIteratorOfListOfShape anIt(aLF); - for (; anIt.More(); anIt.Next()) { - const TopoDS_Shape& aFR=anIt.Value(); - - if (aFR.ShapeType()==TopAbs_FACE) { - const TopoDS_Face& aFaceResult=TopoDS::Face(aFR); - // - Standard_Boolean bIsValidIn2D, bNegativeFlag; - bIsValidIn2D=BOPTools_Tools3D::IsValidArea (aFaceResult, bNegativeFlag); - if (bIsValidIn2D) { - - if(CheckSameDomainFaceInside(aFaceResult, aF2)) { - iZone=1; - break; - } - } - // - } - } - - if (iZone) { - bFlag=Standard_True; - aFF.SetStatesMap(aWESFiller.StatesMap()); - } - - }// if (iSenseFlag) - - aFF.SetTangentFacesFlag(bFlag); - aFF.SetSenseFlag (iSenseFlag); - }// end of for (i=1; i<=aNb; i++) -} - -//======================================================================= -// function: AddSplitPartsINOUT -// purpose: -//======================================================================= - void BOP_ShellSolid::AddSplitPartsINOUT(const Standard_Integer nF1, - BOP_WireEdgeSet& aWES) -{ - const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); - const BOPTools_PaveFiller& aPaveFiller=myDSFiller->PaveFiller(); - const BOPTools_SplitShapesPool& aSplitShapesPool=aPaveFiller.SplitShapesPool(); - - Standard_Integer nE, nSp, iRankF1, aNbPB; - BooleanOperations_StateOfShape aState, aStateCmp; - TopAbs_Orientation anOr; - TopExp_Explorer anExp; - TopoDS_Edge aSS; - // - iRankF1=aDS.Rank(nF1); - aStateCmp=BOP_BuilderTools::StateToCompare(iRankF1, myOperation); - - anExp.Init(myFace, TopAbs_EDGE); - for (; anExp.More(); anExp.Next()) { - const TopoDS_Shape& anE=anExp.Current(); - anOr=anE.Orientation(); - - nE=aDS.ShapeIndex(anE, iRankF1); - - const BOPTools_ListOfPaveBlock& aLPB=aSplitShapesPool(aDS.RefEdge(nE)); - aNbPB=aLPB.Extent(); - // case: No splits on Egde - if (!aNbPB) { - aState=aDS.GetState(nE); - if (aState==aStateCmp) { - aSS=TopoDS::Edge(anE); - //modified by NIZNHY-PKV Mon Sep 19 09:13:59 2011f - if (anOr==TopAbs_INTERNAL) { - aSS.Orientation(TopAbs_FORWARD); - aWES.AddStartElement (aSS); - aSS.Orientation(TopAbs_REVERSED); - aWES.AddStartElement (aSS); - } - else{ - aSS.Orientation(anOr); - aWES.AddStartElement (aSS); - } - //aSS.Orientation(anOr); - //aWES.AddStartElement (aSS); - //modified by NIZNHY-PKV Mon Sep 19 09:14:02 2011t - } - continue; - } - // case: There are splits on Egde - BOPTools_ListIteratorOfListOfPaveBlock aPBIt(aLPB); - for (; aPBIt.More(); aPBIt.Next()) { - const BOPTools_PaveBlock& aPB=aPBIt.Value(); - nSp=aPB.Edge(); - - aState=aDS.GetState(nSp); - if (aState==aStateCmp) { - const TopoDS_Shape& aSplit=aDS.Shape(nSp); - aSS=TopoDS::Edge(aSplit); - //modified by NIZNHY-PKV Mon Sep 19 08:58:23 2011f - if (anOr==TopAbs_INTERNAL) { - aSS.Orientation(TopAbs_FORWARD); - aWES.AddStartElement (aSS); - aSS.Orientation(TopAbs_REVERSED); - aWES.AddStartElement (aSS); - } - else{ - aSS.Orientation(anOr); - aWES.AddStartElement (aSS); - } - //aSS.Orientation(anOr); - //aWES.AddStartElement (aSS); - //modified by NIZNHY-PKV Mon Sep 19 08:58:33 2011t - } - } - } -} -//======================================================================= -// function: Prepare -// purpose: -//======================================================================= - void BOP_ShellSolid::Prepare() -{ - //... - const BOPTools_PaveFiller& aPaveFiller=myDSFiller->PaveFiller(); - // - // 1 States - BOPTools_SolidStateFiller aStateFiller(aPaveFiller); - aStateFiller.Do(); - // - // 2 Project section edges on corresp. faces -> P-Curves on edges. - BOPTools_PCurveMaker aPCurveMaker(aPaveFiller); - aPCurveMaker.Do(); - // - // 3. Degenerated Edges Processing - BOPTools_DEProcessor aDEProcessor(aPaveFiller); - aDEProcessor.Do(); - // - // 4. DetectSame Domain Faces - DetectSDFaces(); - // - // 5. FillSectionEdges - FillSectionEdges(); -} - -/////////////////// -//======================================================================= -// function: OrientFacesOnShell -// purpose: -//======================================================================= - void BOP_ShellSolid::OrientFacesOnShell (const TopoDS_Shell& aShell, - TopoDS_Shell& aShellNew) -{ - Standard_Boolean bIsProcessed1, bIsProcessed2; - Standard_Integer i, aNbE, aNbF, j; - TopAbs_Orientation anOrE1, anOrE2; - - TopTools_IndexedDataMapOfShapeListOfShape aEFMap; - TopTools_IndexedMapOfShape aProcessedFaces; - BRep_Builder aBB; - - aBB.MakeShell(aShellNew); - - TopExp::MapShapesAndAncestors(aShell, TopAbs_EDGE, TopAbs_FACE, aEFMap); - - aNbE=aEFMap.Extent(); - // - // One seam edge in aEFMap contains 2 equivalent faces. - for (i=1; i<=aNbE; i++) { - TopTools_ListOfShape& aLF=aEFMap.ChangeFromIndex(i); - - if (aLF.Extent()>1) { - TopTools_ListOfShape aLFTmp; - TopTools_IndexedMapOfShape aFM; - - TopTools_ListIteratorOfListOfShape anIt(aLF); - for (; anIt.More(); anIt.Next()) { - const TopoDS_Shape& aF=anIt.Value(); - if (!aFM.Contains(aF)) { - aFM.Add(aF); - aLFTmp.Append(aF); - } - } - aLF.Clear(); - aLF=aLFTmp; - } - } - // - // Do - for (i=1; i<=aNbE; i++) { - const TopoDS_Edge& aE=TopoDS::Edge(aEFMap.FindKey(i)); - - if (BRep_Tool::Degenerated(aE)) { - continue; - } - - const TopTools_ListOfShape& aLF=aEFMap.FindFromIndex(i); - aNbF=aLF.Extent(); - - if (aNbF==2) { - TopoDS_Face& aF1=TopoDS::Face(aLF.First()); - TopoDS_Face& aF2=TopoDS::Face(aLF.Last() ); - - - bIsProcessed1=aProcessedFaces.Contains(aF1); - bIsProcessed2=aProcessedFaces.Contains(aF2); - - if (bIsProcessed1 && bIsProcessed2) { - continue; - } - - if (!bIsProcessed1 && !bIsProcessed2) { - aProcessedFaces.Add(aF1); - aBB.Add(aShellNew, aF1); - - bIsProcessed1=!bIsProcessed1; - } - - // - TopoDS_Face aF1x, aF2x; - - aF1x=aF1; - if (bIsProcessed1) { - j=aProcessedFaces.FindIndex(aF1); - aF1x=TopoDS::Face(aProcessedFaces.FindKey(j)); - } - - aF2x=aF2; - if (bIsProcessed2) { - j=aProcessedFaces.FindIndex(aF2); - aF2x=TopoDS::Face(aProcessedFaces.FindKey(j)); - } - // - - anOrE1=Orientation(aE, aF1x); - anOrE2=Orientation(aE, aF2x); - - if (bIsProcessed1 && !bIsProcessed2) { - - if (anOrE1==anOrE2) { - if (!BRep_Tool::IsClosed(aE, aF1) && - !BRep_Tool::IsClosed(aE, aF2)) { - aF2.Reverse(); - } - } - aProcessedFaces.Add(aF2); - aBB.Add(aShellNew, aF2); - } - - else if (!bIsProcessed1 && bIsProcessed2) { - if (anOrE1==anOrE2) { - if (!BRep_Tool::IsClosed(aE, aF1) && - !BRep_Tool::IsClosed(aE, aF2)) { - aF1.Reverse(); - } - } - aProcessedFaces.Add(aF1); - aBB.Add(aShellNew, aF1); - } - } - } - // - // - for (i=1; i<=aNbE; i++) { - const TopoDS_Edge& aE=TopoDS::Edge(aEFMap.FindKey(i)); - - if (BRep_Tool::Degenerated(aE)) { - continue; - } - - const TopTools_ListOfShape& aLF=aEFMap.FindFromIndex(i); - aNbF=aLF.Extent(); - if (aNbF!=2) { - TopTools_ListIteratorOfListOfShape anIt(aLF); - for(; anIt.More(); anIt.Next()) { - const TopoDS_Face& aF=TopoDS::Face(anIt.Value()); - if (!aProcessedFaces.Contains(aF)) { - aProcessedFaces.Add(aF); - aBB.Add(aShellNew, aF); - } - } - } - } -} - -//======================================================================= -//function : Orientation -//purpose : -//======================================================================= - TopAbs_Orientation BOP_ShellSolid::Orientation(const TopoDS_Edge& anE, - const TopoDS_Face& aF) -{ - TopAbs_Orientation anOr=TopAbs_INTERNAL; - - TopExp_Explorer anExp; - anExp.Init(aF, TopAbs_EDGE); - for (; anExp.More(); anExp.Next()) { - const TopoDS_Edge& anEF1=TopoDS::Edge(anExp.Current()); - if (anEF1.IsSame(anE)) { - anOr=anEF1.Orientation(); - break; - } - } - return anOr; -} - -//======================================================================= -// function: Path -// purpose: -//======================================================================= - void BOP_ShellSolid::Path (const TopoDS_Shape& aE, - const TopTools_IndexedDataMapOfShapeListOfShape& aEFMap, - TopTools_IndexedMapOfShape& aFaces, - TopTools_IndexedMapOfShape& aProcessedEdges) -{ - if (!aProcessedEdges.Contains(aE)) { - aProcessedEdges.Add(aE); - - Standard_Integer i, aNbE; - const TopTools_ListOfShape& aFList=aEFMap.FindFromKey(aE); - - TopTools_ListIteratorOfListOfShape anIt(aFList); - for(; anIt.More(); anIt.Next()) { - const TopoDS_Shape& aF=anIt.Value(); - aFaces.Add(aF); - - TopTools_IndexedMapOfShape aME; - TopExp::MapShapes(aF, TopAbs_EDGE, aME); - aNbE=aME.Extent(); - for (i=1; i<=aNbE; i++) { - const TopoDS_Shape& aENext=aME(i); - Path(aENext, aEFMap, aFaces, aProcessedEdges); - } - } - } -} - -//======================================================================= -// function: CheckArgTypes -// purpose: -//======================================================================= -Standard_Boolean BOP_ShellSolid::CheckArgTypes(const TopAbs_ShapeEnum theType1, - const TopAbs_ShapeEnum theType2, - const BOP_Operation theOperation) -{ - Standard_Boolean bFlag=Standard_False; - - if (theType1==TopAbs_SHELL && theType2==TopAbs_SOLID) { - if (theOperation==BOP_FUSE || theOperation==BOP_CUT21) { - return bFlag; - } - } - // - if (theType1==TopAbs_SOLID && theType2==TopAbs_SHELL) { - if (theOperation==BOP_FUSE || theOperation==BOP_CUT) { - return bFlag; - } - } - // - return !bFlag; -} - - -//======================================================================= -// function: CheckArgTypes -// purpose: -//======================================================================= -Standard_Boolean BOP_ShellSolid::CheckArgTypes() const -{ -// Standard_Boolean bFlag=Standard_False; - - TopAbs_ShapeEnum aT1, aT2; - const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); - - aT1=aDS.Object().ShapeType(); - aT2=aDS.Tool().ShapeType(); - // -// if (aT1==TopAbs_SHELL && aT2==TopAbs_SOLID) { -// if (myOperation==BOP_FUSE || myOperation==BOP_CUT21) { -// return bFlag; -// } -// } -// // -// if (aT1==TopAbs_SOLID && aT2==TopAbs_SHELL) { -// if (myOperation==BOP_FUSE || myOperation==BOP_CUT) { -// return bFlag; -// } -// } - // -// return !bFlag; - return CheckArgTypes(aT1, aT2, myOperation); -} - - - -//======================================================================= -// function: DoInternalVertices -// purpose: -//======================================================================= - void BOP_ShellSolid::DoInternalVertices(const Standard_Integer nF1, - const TopTools_ListOfShape& aListOfFaces) -{ - - const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); - BOPTools_InterferencePool* pIntrPool=(BOPTools_InterferencePool*)&myDSFiller->InterfPool(); - BOPTools_CArray1OfVSInterference& aVFs=pIntrPool->VSInterferences(); - BOPTools_CArray1OfESInterference& aEFs=pIntrPool->ESInterferences(); - BOPTools_CArray1OfSSInterference& aFFs=pIntrPool->SSInterferences(); - - BOPTools_PaveFiller* pPaveFiller=(BOPTools_PaveFiller*) &(myDSFiller->PaveFiller()); - // - Standard_Integer i, j, nF, aNbFF, aNbVF, aWhat, aWith; - Standard_Integer nV, iRankF, nE, aNbE, nFx, iOppositeRank, iFlag, iBreakFlag ; - Standard_Integer aNbEF, nVx1, nVx2, aWh, aWt, aNbC, k; - Standard_Real U, V; - // - - nF=nF1; - iRankF=aDS.Rank(nF); - iOppositeRank=(iRankF==1) ? 2 : 1; - TopTools_IndexedDataMapOfShapeListOfShape aVEMap, aVFMap, aEFMap; - const TopoDS_Shape& aS=(iRankF==1) ? myShape2 : myShape1; - TopExp::MapShapesAndAncestors (aS, TopAbs_VERTEX, TopAbs_EDGE, aVEMap); - TopExp::MapShapesAndAncestors (aS, TopAbs_VERTEX, TopAbs_FACE, aVFMap); - TopExp::MapShapesAndAncestors (aS, TopAbs_EDGE , TopAbs_FACE, aEFMap); - - TopTools_ListIteratorOfListOfShape anIt; - /////////////////////////////////////////////////////////////// - // - // VF interferences processing - aNbVF=aVFs.Extent(); - for (i=1; i<=aNbVF; i++) { - iBreakFlag=0; - - BOPTools_VSInterference& aVF=aVFs(i); - - aWhat=aVF.Index1(); - aWith=aVF.Index2(); - - if (aWhat==nF || aWith==nF) { - TColStd_ListOfInteger aLs; - - nV=aVF.OppositeIndex(nF); - - Standard_Integer iRankV; - iRankV=aDS.Rank(nV); - - const TopoDS_Vertex& aV=TopoDS::Vertex(aDS.Shape(nV)); - - if (aVEMap.Contains(aV)) { - const TopTools_ListOfShape& aLE=aVEMap.FindFromKey(aV); - - anIt.Initialize (aLE); - for (; anIt.More() && !iBreakFlag; anIt.Next()) { - const TopoDS_Shape& aE=anIt.Value(); - - nE=aDS.ShapeIndex(aE, iRankV); - // - aLs.Clear(); - // - pPaveFiller->SplitsInFace(nE, nF, aLs); - aNbE=aLs.Extent(); - if (aNbE) { - iBreakFlag=1; // next i - // - break; - // - } - } - } - if (iBreakFlag) { - continue; - } - // - if (aVFMap.Contains(aV)) { - const TopTools_ListOfShape& aLF=aVFMap.FindFromKey(aV); - - anIt.Initialize (aLF); - for (; anIt.More()&& !iBreakFlag; anIt.Next()) { - const TopoDS_Shape& aFx=anIt.Value(); - - nFx=aDS.ShapeIndex(aFx, iRankV); - - aNbFF=aFFs.Extent(); - for (j=1; j<=aNbFF && !iBreakFlag ; j++) { - BOPTools_SSInterference& aFF=aFFs(j); - - aWh=aFF.Index1(); - aWt=aFF.Index2(); - if ((aWh==nF && aWt==nFx) || (aWh==nFx && aWt==nF)) { - BOPTools_SequenceOfCurves& aSCurves=aFF.Curves(); - aNbC=aSCurves.Length(); - for (k=1; k<=aNbC && !iBreakFlag; k++) { - const BOPTools_Curve& aC=aSCurves(k); - const BOPTools_ListOfPaveBlock& aLPB=aC.NewPaveBlocks(); - BOPTools_ListIteratorOfListOfPaveBlock anItLPB; - anItLPB.Initialize (aLPB); - for (; anItLPB.More() && !iBreakFlag; anItLPB.Next()) { - const BOPTools_PaveBlock& aPB=anItLPB.Value(); - // - nVx1=aPB.Pave1().Index(); - nVx2=aPB.Pave1().Index(); - if ((nVx1==nV) || (nVx2==nV)) { - iBreakFlag=1; - // - break; - // - } - } - } - } - } - } - } - // - if (iBreakFlag) { - continue; - } - // - // Put Vertex nV on Face j from aListOfFaces - Standard_Boolean bIsPointInFace; - - aVF.UV (U, V); - gp_Pnt2d aP2D (U, V); - - TopoDS_Vertex aVInternal=aV; - aVInternal.Orientation(TopAbs_INTERNAL); - - anIt.Initialize(aListOfFaces); - for (; anIt.More(); anIt.Next()) { - TopoDS_Face& aF=TopoDS::Face(anIt.Value()); - // - IntTools_Context aCtx; - bIsPointInFace=aCtx.IsPointInFace(aF, aP2D); - // - if (bIsPointInFace) { - BRep_Builder aBB; - aBB.Add(aF, aVInternal); - break; - } - } - }// if (aWhat==nF || aWith==nF) - }// for (i=1; i<=aNbVF; i++) - /////////////////////////////////////////////////////////////// - // - // EF interferences processing - aNbEF=aEFs.Extent(); - - for (i=1; i<=aNbEF; i++) { - iBreakFlag=0; - BOPTools_ESInterference& aEF=aEFs(i); - aWhat=aEF.Index1(); - aWith=aEF.Index2(); - // - if (aWhat!=nF) { - if (aWith!=nF) { - continue; - } - } - // - nE=aEF.OppositeIndex(nF); - - const TopoDS_Edge& aE=TopoDS::Edge(aDS.Shape(nE)); - - nV=aEF.NewShape(); - // - if(!nV){ - continue; - } - // - const TopoDS_Shape& aV=aDS.Shape(nV); - // - if (aV.ShapeType()!=TopAbs_VERTEX) { - continue; - } - // - BOPTools_ListOfPaveBlock aLPBSplits; - // - // check split parts in2D for F1 - pPaveFiller->SplitsInFace(nE, nF, aLPBSplits); - - BOPTools_ListIteratorOfListOfPaveBlock anItx(aLPBSplits); - for (; anItx.More() && !iBreakFlag; anItx.Next()) { - const BOPTools_PaveBlock& aPB=anItx.Value(); - nVx1=aPB.Pave1().Index(); - nVx2=aPB.Pave2().Index(); - if (nV==nVx1 || nV==nVx2) { - iBreakFlag=1; - break; - } - } - - if (iBreakFlag){ - continue; - } - // - // - if (aEFMap.Contains(aE)) { - const TopTools_ListOfShape& aLF=aEFMap.FindFromKey(aE); - - anIt.Initialize (aLF); - for (; anIt.More() && !iBreakFlag; anIt.Next()) { - const TopoDS_Shape& aFx=anIt.Value(); - nFx=aDS.ShapeIndex(aFx, iOppositeRank); - - aNbFF=aFFs.Extent(); - for (j=1; j<=aNbFF&& !iBreakFlag; j++) { - BOPTools_SSInterference& aFF=aFFs(j); - - aWh=aFF.Index1(); - aWt=aFF.Index2(); - if ((aWh==nF && aWt==nFx) || (aWt==nF && aWh==nFx)) { - BOPTools_SequenceOfCurves& aSCurves=aFF.Curves(); - aNbC=aSCurves.Length(); - for (k=1; k<=aNbC && !iBreakFlag; k++) { - const BOPTools_Curve& aC=aSCurves(k); - const BOPTools_ListOfPaveBlock& aLPB=aC.NewPaveBlocks(); - BOPTools_ListIteratorOfListOfPaveBlock anItLPB; - anItLPB.Initialize (aLPB); - for (; anItLPB.More()&& !iBreakFlag; anItLPB.Next()) { - const BOPTools_PaveBlock& aPB=anItLPB.Value(); - // - nVx1=aPB.Pave1().Index(); - nVx2=aPB.Pave2().Index(); - if (nV==nVx1 || nV==nVx2) { - iBreakFlag=1; - } - } - } - } - } - } - if (iBreakFlag){ - continue; - } - } - // - // Put Vertex nV on Face j from aListOfFaces - TopoDS_Vertex aVInternal=TopoDS::Vertex(aV); - aVInternal.Orientation(TopAbs_INTERNAL); - TopTools_ListIteratorOfListOfShape anItF; - anItF.Initialize(aListOfFaces); - for (; anItF.More(); anItF.Next()) { - TopoDS_Face& aFx=TopoDS::Face(anItF.Value()); - // - IntTools_Context aCtx; - iFlag=aCtx.ComputeVS(aVInternal, aFx, U, V); - // - if (!iFlag) { - BRep_Builder aBB; - aBB.Add(aFx, aVInternal); - break; - } - } - } - // - // Alone Vertices' processing - // - Standard_Integer aNbVx, nVx; - aNbFF=aFFs.Extent(); - for (i=1; i<=aNbFF; i++) { - BOPTools_SSInterference& aFF=aFFs(i); - aWh=aFF.Index1(); - aWt=aFF.Index2(); - if (aWh==nF || aWt==nF) { - TColStd_ListOfInteger& anAloneVertices=aFF.AloneVertices(); - aNbVx=anAloneVertices.Extent(); - if (aNbVx) { - TColStd_ListIteratorOfListOfInteger anItVx(anAloneVertices); - for (; anItVx.More(); anItVx.Next()) { - nVx=anItVx.Value(); - const TopoDS_Vertex& aVx=TopoDS::Vertex(aDS.Shape(nVx)); - // - TopoDS_Vertex aVInternal=aVx; - aVInternal.Orientation(TopAbs_INTERNAL); - // - anIt.Initialize(aListOfFaces); - for (; anIt.More(); anIt.Next()) { - TopoDS_Face& aF=TopoDS::Face(anIt.Value()); - // - IntTools_Context aCtx; - iFlag=aCtx.ComputeVS (aVInternal, aF, U, V); - // - if (!iFlag) { - BRep_Builder aBB; - aBB.Add(aF, aVInternal); - } - } - - } - } - } - } -} - -//======================================================================= -// function: CollectInternals -// purpose: -//======================================================================= - void BOP_ShellSolid::CollectInternals() -{ - Standard_Integer i, aNb, nSp; - TopAbs_ShapeEnum aType; - TopAbs_Orientation anOr; - TopTools_IndexedMapOfShape aMInternals; - - const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); - const BOPTools_SplitShapesPool& aSplitShapesPool=myDSFiller->SplitShapesPool(); - - aNb=aDS.NumberOfShapesOfTheObject()+aDS.NumberOfShapesOfTheTool(); - for (i=1; i<= aNb; ++i) { - const TopoDS_Shape& aS=aDS.Shape(i); - aType=aS.ShapeType(); - if (aType==TopAbs_EDGE || aType==TopAbs_VERTEX) { - anOr=aS.Orientation(); - if (anOr==TopAbs_INTERNAL) { - // - aMInternals.Add(aS); - // - if (aType==TopAbs_EDGE) { - - const BOPTools_ListOfPaveBlock& aSplits=aSplitShapesPool(aDS.RefEdge(i)); - BOPTools_ListIteratorOfListOfPaveBlock aPBIt(aSplits); - for (; aPBIt.More(); aPBIt.Next()) { - BOPTools_PaveBlock& aPB=aPBIt.Value(); - nSp=aPB.Edge(); - const TopoDS_Shape& aSp=aDS.Shape(nSp); - // - aMInternals.Add(aSp); - } - } - } - } - } - - aNb=aMInternals.Extent(); - for (i=1; i<= aNb; ++i) { - const TopoDS_Shape& aS=aMInternals(i); - myInternals.Append(aS); - } -} -//======================================================================= -// function: Internals -// purpose: -//======================================================================= - const TopTools_ListOfShape& BOP_ShellSolid::Internals()const -{ - return myInternals; -} -//======================================================================= -// function: FillSectionEdges -// purpose: -//======================================================================= - void BOP_ShellSolid::FillSectionEdges() -{ - Standard_Integer i, j, nF1, nF2, aNbFFs, aNbS, aNbCurves, nSect; - // - const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); - const BOPTools_InterferencePool& anInterfPool=myDSFiller->InterfPool(); - BOPTools_InterferencePool* pInterfPool=(BOPTools_InterferencePool*) &anInterfPool; - BOPTools_CArray1OfSSInterference& aFFs=pInterfPool->SSInterferences(); - // - TopTools_IndexedMapOfShape aMap; - // - aNbFFs=aFFs.Extent(); - for (i=1; i<=aNbFFs; ++i) { - BOPTools_SSInterference& aFFi=aFFs(i); - // - nF1=aFFi.Index1(); - nF2=aFFi.Index2(); - // - // Old Section Edges - const BOPTools_ListOfPaveBlock& aSectList=aFFi.PaveBlocks(); - aNbS=aSectList.Extent(); - BOPTools_ListIteratorOfListOfPaveBlock anIt(aSectList); - for (; anIt.More();anIt.Next()) { - const BOPTools_PaveBlock& aPB=anIt.Value(); - nSect=aPB.Edge(); - const TopoDS_Shape& aS=aDS.GetShape(nSect); - aMap.Add(aS); - } - // - // New Section Edges - BOPTools_SequenceOfCurves& aBCurves=aFFi.Curves(); - aNbCurves=aBCurves.Length(); - for (j=1; j<=aNbCurves; j++) { - BOPTools_Curve& aBC=aBCurves(j); - const BOPTools_ListOfPaveBlock& aSectEdges=aBC.NewPaveBlocks(); - aNbS=aSectEdges.Extent(); - - BOPTools_ListIteratorOfListOfPaveBlock aPBIt(aSectEdges); - for (; aPBIt.More(); aPBIt.Next()) { - BOPTools_PaveBlock& aPB=aPBIt.Value(); - nSect=aPB.Edge(); - const TopoDS_Shape& aS=aDS.GetShape(nSect); - aMap.Add(aS); - } - } - } - // - mySectionEdges.Clear(); - - aNbS=aMap.Extent(); - - for (i=1; i<=aNbS; i++) { - const TopoDS_Shape& aS=aMap(i); - mySectionEdges.Append(aS); - } -} - -void BOP_ShellSolid::SetHistoryCollector(const Handle(BOP_HistoryCollector)& theHistory) -{ - if(theHistory.IsNull() || - !theHistory->IsKind(STANDARD_TYPE(BOP_ShellSolidHistoryCollector))) - myHistory.Nullify(); - else - myHistory = theHistory; -} - -// ----------------------------------------------------------------- -// static function: CheckSameDomainFaceInside -// purpose: Check if distance between several points of theFace1 and -// theFace2 is not more than sum of maximum of tolerances of -// theFace1's edges and tolerance of theFace2 -// ----------------------------------------------------------------- -Standard_Boolean CheckSameDomainFaceInside(const TopoDS_Face& theFace1, - const TopoDS_Face& theFace2) { - - Standard_Real umin = 0., umax = 0., vmin = 0., vmax = 0.; - BRepTools::UVBounds(theFace1, umin, umax, vmin, vmax); - IntTools_Context aContext; - Handle(Geom_Surface) aSurface = BRep_Tool::Surface(theFace1); - Standard_Real aTolerance = BRep_Tool::Tolerance(theFace1); - - TopExp_Explorer anExpE(theFace1, TopAbs_EDGE); - - for(; anExpE.More(); anExpE.Next()) { - const TopoDS_Edge& anEdge = TopoDS::Edge(anExpE.Current()); - Standard_Real anEdgeTol = BRep_Tool::Tolerance(anEdge); - aTolerance = (aTolerance < anEdgeTol) ? anEdgeTol : aTolerance; - } - aTolerance += BRep_Tool::Tolerance(theFace2); - - Standard_Integer nbpoints = 5; - Standard_Real adeltau = (umax - umin) / (nbpoints + 1); - Standard_Real adeltav = (vmax - vmin) / (nbpoints + 1); - Standard_Real U = umin + adeltau; - GeomAPI_ProjectPointOnSurf& aProjector = aContext.ProjPS(theFace2); - - for(Standard_Integer i = 1; i <= nbpoints; i++, U+=adeltau) { - Standard_Real V = vmin + adeltav; - - for(Standard_Integer j = 1; j <= nbpoints; j++, V+=adeltav) { - gp_Pnt2d aPoint(U,V); - - if(aContext.IsPointInFace(theFace1, aPoint)) { - gp_Pnt aP3d = aSurface->Value(U, V); - aProjector.Perform(aP3d); - - if(aProjector.IsDone()) { - - if(aProjector.LowerDistance() > aTolerance) - return Standard_False; - } - } - } - } - - return Standard_True; -} - diff --git a/src/BOP/BOP_ShellSolidHistoryCollector.cdl b/src/BOP/BOP_ShellSolidHistoryCollector.cdl deleted file mode 100755 index f4cea18092..0000000000 --- a/src/BOP/BOP_ShellSolidHistoryCollector.cdl +++ /dev/null @@ -1,51 +0,0 @@ --- Created on: 2003-03-24 --- Created by: Michael KLOKOV --- Copyright (c) 2003-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class ShellSolidHistoryCollector from BOP - inherits HistoryCollector from BOP - -uses - Shape from TopoDS, - PDSFiller from BOPTools, - Operation from BOP, - ListOfShape from TopTools - -is - Create(theShape1 : Shape from TopoDS; - theShape2 : Shape from TopoDS; - theOperation: Operation from BOP) - returns ShellSolidHistoryCollector from BOP; - - AddNewFace(me: mutable; theOldShape: Shape from TopoDS; - theNewShape: Shape from TopoDS; - theDSFiller: PDSFiller from BOPTools); - - SetResult(me: mutable; theResult: Shape from TopoDS; - theDSFiller: PDSFiller from BOPTools) - is redefined virtual; - - --- private - FillSection(me: mutable; theDSFiller: PDSFiller from BOPTools) - is private; - - FillEdgeHistory(me: mutable; theDSFiller: PDSFiller from BOPTools) - is private; - -end ShellSolidHistoryCollector from BOP; diff --git a/src/BOP/BOP_ShellSolidHistoryCollector.cxx b/src/BOP/BOP_ShellSolidHistoryCollector.cxx deleted file mode 100755 index bcb38b5acb..0000000000 --- a/src/BOP/BOP_ShellSolidHistoryCollector.cxx +++ /dev/null @@ -1,408 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// ==================================================================================================== -// function: Constructor -// purpose: -// ==================================================================================================== -BOP_ShellSolidHistoryCollector::BOP_ShellSolidHistoryCollector(const TopoDS_Shape& theShape1, - const TopoDS_Shape& theShape2, - const BOP_Operation theOperation) : -BOP_HistoryCollector(theShape1, theShape2, theOperation) -{ -} - -// ==================================================================================================== -// function: AddNewFace -// purpose: -// ==================================================================================================== -void BOP_ShellSolidHistoryCollector::AddNewFace(const TopoDS_Shape& theOldShape, - const TopoDS_Shape& theNewShape, - const BOPTools_PDSFiller& theDSFiller) -{ - Standard_Boolean bAddAsGenerated = Standard_True; - - if(theOldShape.ShapeType() != theNewShape.ShapeType()) - return; - - const BooleanOperations_IndexedDataMapOfShapeInteger& aMap = theDSFiller->DS().ShapeIndexMap(1); - Standard_Boolean bIsObject = (myS1.ShapeType() == TopAbs_SHELL) ? aMap.Contains(theOldShape) : !aMap.Contains(theOldShape); - - if(bIsObject) { - bAddAsGenerated = Standard_False; - } - - TopTools_DataMapOfShapeListOfShape& aHistoryMap = (bAddAsGenerated) ? myGenMap : myModifMap; - - if(aHistoryMap.IsBound(theOldShape)) { - aHistoryMap.ChangeFind(theOldShape).Append(theNewShape); - } - else { - TopTools_ListOfShape aShapeList; - aShapeList.Append(theNewShape); - aHistoryMap.Bind(theOldShape, aShapeList); - } -} - -// ==================================================================================================== -// function: SetResult -// purpose: -// ==================================================================================================== -void BOP_ShellSolidHistoryCollector::SetResult(const TopoDS_Shape& theResult, - const BOPTools_PDSFiller& theDSFiller) -{ - myResult = theResult; - FillSection(theDSFiller); - FillEdgeHistory(theDSFiller); - - myHasDeleted = Standard_False; - Standard_Integer i = 0; - - TopTools_IndexedMapOfShape aFreeBoundaryMap; - TopTools_IndexedDataMapOfShapeListOfShape aEFMap; - - if(myS1.ShapeType() == TopAbs_SHELL) { - TopExp::MapShapesAndAncestors(myS1, TopAbs_EDGE, TopAbs_FACE, aEFMap); - } - else { - TopExp::MapShapesAndAncestors(myS2, TopAbs_EDGE, TopAbs_FACE, aEFMap); - } - - for(i = 1; i <= aEFMap.Extent(); i++) { - if(aEFMap.FindFromIndex(i).Extent() < 2) - aFreeBoundaryMap.Add(aEFMap.FindKey(i)); - } - aEFMap.Clear(); - - for(i = (Standard_Integer)TopAbs_FACE; !myHasDeleted && (i < (Standard_Integer)TopAbs_EDGE); i++) { - if(i == (Standard_Integer)TopAbs_WIRE) - continue; - - TopAbs_ShapeEnum aType = (TopAbs_ShapeEnum) i; - TopTools_IndexedMapOfShape aMap; - TopExp::MapShapes(myResult, aType, aMap); - - TopExp_Explorer anExpObj(myS1, aType); - - for(; anExpObj.More(); anExpObj.Next()) { - const TopoDS_Shape& aS = anExpObj.Current(); - - if((i == (Standard_Integer)TopAbs_EDGE) && !aFreeBoundaryMap.Contains(aS)) - continue; - - if(!aMap.Contains(aS)) { - - if((!myModifMap.IsBound(aS) || myModifMap(aS).IsEmpty()) && - (!myGenMap.IsBound(aS) || myGenMap(aS).IsEmpty())) { - myHasDeleted = Standard_True; - break; - } - } - } - TopExp_Explorer anExpTool(myS2, aType); - - for(; anExpTool.More(); anExpTool.Next()) { - const TopoDS_Shape& aS = anExpTool.Current(); - - if(!aMap.Contains(aS)) { - if((!myModifMap.IsBound(aS) || myModifMap(aS).IsEmpty()) && - (!myGenMap.IsBound(aS) || myGenMap(aS).IsEmpty())) { - myHasDeleted = Standard_True; - break; - } - } - } - } -} - -// ==================================================================================================== -// function: FillSection -// purpose: -// ==================================================================================================== -void BOP_ShellSolidHistoryCollector::FillSection(const BOPTools_PDSFiller& theDSFiller) -{ - BOPTools_InterferencePool* pIntrPool = (BOPTools_InterferencePool*)&theDSFiller->InterfPool(); - BOPTools_CArray1OfSSInterference& aFFs = pIntrPool->SSInterferences(); - Standard_Integer i = 0; - TopTools_IndexedDataMapOfShapeListOfShape aResultMap; - - if(!myResult.IsNull()) { - TopExp::MapShapesAndAncestors(myResult, TopAbs_EDGE, TopAbs_FACE, aResultMap); - } - - for(i = 1; i <= aFFs.Extent(); i++) { - BOPTools_SSInterference& aFF = aFFs(i); - Standard_Integer nF1 = aFF.Index1(); - Standard_Integer nF2 = aFF.Index2(); - - if(aFF.IsTangentFaces()) - continue; - TopoDS_Shape aF1 = theDSFiller->DS().Shape(nF1); - TopoDS_Shape aF2 = theDSFiller->DS().Shape(nF2); - - - BOPTools_SequenceOfCurves& aSeqOfCurves = aFF.Curves(); - Standard_Integer j = 0; - - for(j = 1; j <= aSeqOfCurves.Length(); j++) { - const BOPTools_Curve& aCurve = aSeqOfCurves.Value(j); - - const BOPTools_ListOfPaveBlock& aPBList = aCurve.NewPaveBlocks(); - BOPTools_ListIteratorOfListOfPaveBlock anIt(aPBList); - - for (; anIt.More();anIt.Next()) { - const BOPTools_PaveBlock& aPB = anIt.Value(); - Standard_Integer anindex = aPB.Edge(); - const TopoDS_Shape& aS = theDSFiller->DS().GetShape(anindex); - - if(aResultMap.Contains(aS)) { - TopTools_ListOfShape thelist; - if(!myGenMap.IsBound(aF1)) - myGenMap.Bind(aF1, thelist); - myGenMap.ChangeFind(aF1).Append(aS); - - if(!myGenMap.IsBound(aF2)) - myGenMap.Bind(aF2, thelist); - myGenMap.ChangeFind(aF2).Append(aS); - } - } - } - - // Old Section Edges - const BOPTools_ListOfPaveBlock& aSectList = aFF.PaveBlocks(); - BOPTools_ListIteratorOfListOfPaveBlock anIt(aSectList); - - for (; anIt.More();anIt.Next()) { - const BOPTools_PaveBlock& aPB=anIt.Value(); - Standard_Integer nSect = aPB.Edge(); - const TopoDS_Shape& aS = theDSFiller->DS().GetShape(nSect); - - if(aResultMap.Contains(aS)) { - if(aResultMap.FindFromKey(aS).Extent() >= 2) - continue; - - Standard_Boolean add1 = Standard_True; - TopTools_ListOfShape thelist1; - if(!myGenMap.IsBound(aF1)) - myGenMap.Bind(aF1, thelist1); - else { - TopTools_ListOfShape& aList = myGenMap.ChangeFind(aF1); - TopTools_ListIteratorOfListOfShape anItF1(aList); - - for(; anItF1.More(); anItF1.Next()) { - if(aS.IsSame(anItF1.Value())) { - add1 = Standard_False; - break; - } - } - } - - if(add1) { - myGenMap.ChangeFind(aF1).Append(aS); - } - Standard_Boolean add2 = Standard_True; - TopTools_ListOfShape thelist2; - if(!myGenMap.IsBound(aF2)) - myGenMap.Bind(aF2, thelist2); - else { - TopTools_ListOfShape& aList = myGenMap.ChangeFind(aF2); - TopTools_ListIteratorOfListOfShape anItF2(aList); - - for(; anItF2.More(); anItF2.Next()) { - if(aS.IsSame(anItF2.Value())) { - add2 = Standard_False; - break; - } - } - } - - if(add2) { - myGenMap.ChangeFind(aF2).Append(aS); - } - } - } - } - aResultMap.Clear(); - TopTools_IndexedMapOfShape aResultMapV; - - if(!myResult.IsNull()) { - TopExp::MapShapes(myResult, TopAbs_VERTEX, aResultMapV); - } - - for(i = 1; i <= aFFs.Extent(); i++) { - BOPTools_SSInterference& aFF = aFFs(i); - Standard_Integer nF1 = aFF.Index1(); - Standard_Integer nF2 = aFF.Index2(); - - if(aFF.IsTangentFaces()) - continue; - TopoDS_Shape aF1 = theDSFiller->DS().Shape(nF1); - TopoDS_Shape aF2 = theDSFiller->DS().Shape(nF2); - - TColStd_ListIteratorOfListOfInteger anIt(aFF.AloneVertices()); - - for(; anIt.More(); anIt.Next()) { - TopoDS_Shape aNewVertex = theDSFiller->DS().Shape(anIt.Value()); - - if(aResultMapV.Contains(aNewVertex)) { - TopTools_ListOfShape thelist3; - if(!myGenMap.IsBound(aF1)) - myGenMap.Bind(aF1, thelist3); - myGenMap.ChangeFind(aF1).Append(aNewVertex); - - if(!myGenMap.IsBound(aF2)) - myGenMap.Bind(aF2, thelist3); - myGenMap.ChangeFind(aF2).Append(aNewVertex); - } - } - } -} - -// ==================================================================================================== -// function: FillEdgeHistory -// purpose: -// ==================================================================================================== -void BOP_ShellSolidHistoryCollector::FillEdgeHistory(const BOPTools_PDSFiller& theDSFiller) -{ - const BooleanOperations_ShapesDataStructure& aDS = theDSFiller->DS(); - const BOPTools_PaveFiller& aPaveFiller = theDSFiller->PaveFiller(); - const BOPTools_SplitShapesPool& aSplitShapesPool = aPaveFiller.SplitShapesPool(); - TopTools_IndexedMapOfShape aResultMap, aFreeBoundaryMap; - - if(!myResult.IsNull()) { - TopExp::MapShapes(myResult, TopAbs_EDGE, aResultMap); - - TopTools_IndexedDataMapOfShapeListOfShape aEFMap; - - if(myS1.ShapeType() == TopAbs_SHELL) { - TopExp::MapShapesAndAncestors(myS1, TopAbs_EDGE, TopAbs_FACE, aEFMap); - } - else { - TopExp::MapShapesAndAncestors(myS2, TopAbs_EDGE, TopAbs_FACE, aEFMap); - } - Standard_Integer i = 0; - - for(i = 1; i <= aEFMap.Extent(); i++) { - if(aEFMap.FindFromIndex(i).Extent() < 2) - aFreeBoundaryMap.Add(aEFMap.FindKey(i)); - } - } - - Standard_Integer iRank = 1; - - for(; iRank <= 2; iRank++) { - BooleanOperations_StateOfShape aStateCmp, aState; - aStateCmp = BOP_BuilderTools::StateToCompare(iRank, myOp); - Standard_Integer i = 0; - Standard_Integer nb = aDS.NumberOfShapesOfTheObject(); - nb = (iRank == 1) ? nb : (nb + aDS.NumberOfShapesOfTheTool()); - Standard_Integer startindex = (iRank == 1) ? 1 : (aDS.NumberOfShapesOfTheObject() + 1); - - for(i = startindex; i <= nb; i++) { - if(aDS.GetShapeType(i) != TopAbs_EDGE) - continue; - const BOPTools_ListOfPaveBlock& aLPB = aSplitShapesPool(aDS.RefEdge(i)); - const TopoDS_Shape& anOldShape = aDS.Shape(i); - - if(!aFreeBoundaryMap.Contains(anOldShape)) { - continue; - } - - if(!aLPB.IsEmpty()) { - BOPTools_ListIteratorOfListOfPaveBlock aPBIt(aLPB); - - for(; aPBIt.More(); aPBIt.Next()) { - const BOPTools_PaveBlock& aPB = aPBIt.Value(); - Standard_Integer nSp = aPB.Edge(); - - if(nSp == i) - continue; - aState=aDS.GetState(nSp); - - if (aState == aStateCmp) { - const TopoDS_Shape& aNewShape = aDS.Shape(nSp); - - if(aResultMap.Contains(aNewShape)) { - TopTools_DataMapOfShapeListOfShape& aHistoryMap = myModifMap; - - if(aHistoryMap.IsBound(anOldShape)) { - aHistoryMap.ChangeFind(anOldShape).Append(aNewShape); - } - else { - TopTools_ListOfShape aShapeList; - aShapeList.Append(aNewShape); - aHistoryMap.Bind(anOldShape, aShapeList); - } - } - } - } - } - //end if(!aLPB.IsEmpty... - - const BOPTools_CommonBlockPool& aCBPool = aPaveFiller.CommonBlockPool(); - const BOPTools_ListOfCommonBlock& aLCB = aCBPool(aDS.RefEdge(i)); - BOPTools_ListIteratorOfListOfCommonBlock anItCB(aLCB); - - for (; anItCB.More(); anItCB.Next()) { - const BOPTools_CommonBlock& aCB = anItCB.Value(); - const BOPTools_PaveBlock& aPB = aCB.PaveBlock1(); - Standard_Integer nSp = aPB.Edge(); - TopoDS_Shape aNewShape = aDS.Shape(nSp); - - if(aResultMap.Contains(aNewShape)) { - TopTools_DataMapOfShapeListOfShape& aHistoryMap = myModifMap; - - if(aHistoryMap.IsBound(anOldShape)) { - aHistoryMap.ChangeFind(anOldShape).Append(aNewShape); - } - else { - TopTools_ListOfShape aShapeList; - aShapeList.Append(aNewShape); - aHistoryMap.Bind(anOldShape, aShapeList); - } - } - } - // end for (; anItCB.More... - } - } -} - diff --git a/src/BOP/BOP_ShellSolid_1.cxx b/src/BOP/BOP_ShellSolid_1.cxx deleted file mode 100755 index 5031e230b0..0000000000 --- a/src/BOP/BOP_ShellSolid_1.cxx +++ /dev/null @@ -1,933 +0,0 @@ -// Created on: 2001-11-02 -// Created by: Peter KURNEV -// Copyright (c) 2001-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include - -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include - -#include - -#include - -#include -#include - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -static - Standard_Boolean CheckSplitToAvoid(const TopoDS_Edge& theSplit, - const BOPTools_CommonBlock& theCB, - const Standard_Integer theEdgeIndex, - const Standard_Integer theFaceIndex, - const BOPTools_PDSFiller& theDSFiller, - const BOP_Operation& theOperation, - const Handle(IntTools_Context)& theContext); - -//======================================================================= -// -// the WES components for a shell -// -//======================================================================= -// function: AddSectionPartsSh -// purpose: -//======================================================================= - void BOP_ShellSolid::AddSectionPartsSh (const Standard_Integer nF1, - const Standard_Integer iFF, - BOP_WireEdgeSet& aWES) -{ - const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); - BOPTools_InterferencePool* pIntrPool=(BOPTools_InterferencePool*)&myDSFiller->InterfPool(); - BOPTools_CArray1OfSSInterference& aFFs=pIntrPool->SSInterferences(); - // - Standard_Integer i, aNbCurves, nF2, nE, iRankF1; - // - iRankF1=aDS.Rank(nF1); - // - BOPTools_SSInterference& aFF=aFFs(iFF); - nF2=aFF.OppositeIndex(nF1); - // - BOPTools_SequenceOfCurves& aSC=aFF.Curves(); - aNbCurves=aSC.Length(); - for (i=1; i<=aNbCurves; i++) { - const BOPTools_Curve& aBC=aSC(i); - const BOPTools_ListOfPaveBlock& aLPB=aBC.NewPaveBlocks(); - BOPTools_ListIteratorOfListOfPaveBlock anIt(aLPB); - for (; anIt.More(); anIt.Next()) { - const BOPTools_PaveBlock& aPB=anIt.Value(); - nE=aPB.Edge(); - const TopoDS_Edge& aE=TopoDS::Edge(aDS.Shape(nE)); - - TopoDS_Edge aES=aE; - - if (myOperation==BOP_FUSE) { - aWES.AddStartElement (aES); - aES.Reverse(); - aWES.AddStartElement (aES); - } - - } - } -} -//======================================================================= -// function: AddSplitPartsONSh -// purpose: -//======================================================================= - void BOP_ShellSolid::AddSplitPartsONSh(const Standard_Integer nF1, - BOP_WireEdgeSet& aWES) -{ - const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); - const BOPTools_PaveFiller& aPaveFiller=myDSFiller->PaveFiller(); - - BOPTools_PaveFiller* pPaveFiller=(BOPTools_PaveFiller*)&aPaveFiller; - BOPTools_CommonBlockPool& aCBPool=pPaveFiller->ChangeCommonBlockPool(); - // - const Handle(IntTools_Context)& aContext=pPaveFiller->Context(); - // - Standard_Integer nEF1, nF2, nSpF1, nSpF2, nEF2, nSpTaken, iRankF1; - Standard_Boolean bToReverse; - TopAbs_Orientation anOrEF1, anOrEF2; - TopExp_Explorer anExp; - TopTools_IndexedMapOfShape aM; - TopoDS_Edge aSSF1, aSSF2; - // - iRankF1=aDS.Rank(nF1); - // - anExp.Init(myFace, TopAbs_EDGE); - for (; anExp.More(); anExp.Next()) { - const TopoDS_Edge& anEF1=TopoDS::Edge(anExp.Current()); - anOrEF1=anEF1.Orientation(); - nEF1=aDS.ShapeIndex(anEF1, iRankF1); - - BOPTools_ListOfCommonBlock& aLCB=aCBPool(aDS.RefEdge(nEF1)); - - BOPTools_ListIteratorOfListOfCommonBlock anItCB(aLCB); - for (; anItCB.More(); anItCB.Next()) { - BOPTools_CommonBlock& aCB=anItCB.Value(); - - BOPTools_PaveBlock& aPBEF1=aCB.PaveBlock1(nEF1); - BOPTools_PaveBlock& aPBEF2=aCB.PaveBlock2(nEF1); - nF2=aCB.Face(); - if (nF2) { - // Splits that are ON (IN 2D) for other Face (aF2) - nSpF1=aPBEF1.Edge(); - const TopoDS_Shape& aSplit=aDS.Shape(nSpF1); - aSSF1=TopoDS::Edge(aSplit); - // - //iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii - // Internal edges treatment - { - if (anOrEF1==TopAbs_INTERNAL) { - if (myOperation==BOP_FUSE) { - aSSF1.Orientation(TopAbs_FORWARD); - aWES.AddStartElement (aSSF1); - aSSF1.Reverse(); - aWES.AddStartElement (aSSF1); - } - else if (myOperation==BOP_CUT) { - if (iRankF1==1) { - aWES.AddStartElement (aSSF1); - } - } - else if (myOperation==BOP_CUT21) { - if (iRankF1==2) { - aWES.AddStartElement (aSSF1); - } - } - continue; - } - } - //iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii - // - aSSF1.Orientation(anOrEF1); - aWES.AddStartElement (aSSF1); - } - - else { - // Splits that are ON other Edge from other Face - nSpF1=aPBEF1.Edge(); - nSpF2=aPBEF2.Edge(); - nEF2=aPBEF2.OriginalEdge(); - - const TopoDS_Edge& anEF2=TopoDS::Edge(aDS.Shape(nEF2)); - anOrEF2=anEF2.Orientation(); - - const TopoDS_Shape& aSpF1=aDS.Shape(nSpF1); - const TopoDS_Shape& aSpF2=aDS.Shape(nSpF2); - // - // Pave Block from which new edge will be taken - const BOPTools_PaveBlock& aPB=aCB.PaveBlock1(); - nSpTaken=aPB.Edge(); - // - //iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii - // Internal edges treatment - { - Standard_Boolean bInternal1, bInternal2; - bInternal1=(anOrEF1==TopAbs_INTERNAL); - bInternal2=(anOrEF2==TopAbs_INTERNAL); - - if (bInternal1) { - aSSF1=TopoDS::Edge(aDS.Shape(nSpTaken)); - - if (myOperation==BOP_FUSE) { - aSSF1.Orientation(TopAbs_FORWARD); - aWES.AddStartElement (aSSF1); - aSSF1.Reverse(); - aWES.AddStartElement (aSSF1); - continue; - } - - if (myOperation==BOP_CUT && iRankF1==1) { - aSSF1.Orientation(TopAbs_INTERNAL); - aWES.AddStartElement (aSSF1); - continue; - } - - if (myOperation==BOP_CUT21 && iRankF1==2) { - aSSF1.Orientation(TopAbs_INTERNAL); - aWES.AddStartElement (aSSF1); - continue; - } - } - - else if (!bInternal1 && bInternal2) { - if (nSpTaken!=nSpF1) { - - if ((myOperation==BOP_FUSE)|| - (myOperation==BOP_CUT && iRankF1==1) || - (myOperation==BOP_CUT21 && iRankF1==2)) { - - aSSF1=TopoDS::Edge(aSpF1); - aSSF1.Orientation(anOrEF1); - - aSSF2=TopoDS::Edge(aSpF2); - - aSSF2.Orientation(TopAbs_FORWARD); - bToReverse=BOPTools_Tools3D::IsSplitToReverse1 (aSSF1, aSSF2, aContext); - if (bToReverse) { - aSSF2.Reverse(); - } - - aWES.AddStartElement (aSSF2); - continue; - } - } - } - } - // - aSSF1=TopoDS::Edge(aSpF1); - aSSF1.Orientation(anOrEF1); - - if (nSpTaken==nSpF1) { - // Common Edge is from nEF1 - if(CheckSplitToAvoid(aSSF1, aCB, nEF1, nF1, myDSFiller, myOperation, aContext)){ - continue; - } - aWES.AddStartElement (aSSF1); - } - - else { - // Common Edge is from nEF2 nSpTaken!=nSpF2 - aSSF2=TopoDS::Edge(aSpF2); - - bToReverse=BOPTools_Tools3D::IsSplitToReverse1 (aSSF1, aSSF2, aContext); - if (bToReverse) { - aSSF2.Reverse(); - } - // - if (BRep_Tool::IsClosed(aSSF1, myFace)) { - if (aM.Contains(aSSF2)){ - continue; - } - aM.Add(aSSF2); - // - if (!BRep_Tool::IsClosed(aSSF2, myFace)) { - BOPTools_Tools3D::DoSplitSEAMOnFace (aSSF2, myFace); - } - - aWES.AddStartElement (aSSF2); - aSSF2.Reverse(); - aWES.AddStartElement (aSSF2); - continue; - } - // - if(CheckSplitToAvoid(aSSF2, aCB, nEF1, nF1, myDSFiller, myOperation, aContext)) { - continue; - } - aWES.AddStartElement (aSSF2); - } - } - } - } -} -//======================================================================= -// function: AddPartsEFSh -// purpose: -//======================================================================= - void BOP_ShellSolid::AddPartsEFSh (const Standard_Integer nF1, - const Standard_Integer iFF, - TopTools_IndexedMapOfShape& anEMap, - BOP_WireEdgeSet& aWES) -{ - const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); - BOPTools_InterferencePool* pIntrPool=(BOPTools_InterferencePool*)&myDSFiller->InterfPool(); - BOPTools_CArray1OfSSInterference& aFFs=pIntrPool->SSInterferences(); - - const BOPTools_PaveFiller& aPF=myDSFiller->PaveFiller(); - BOPTools_PaveFiller* pPaveFiller=(BOPTools_PaveFiller*)&aPF; - BOPTools_CommonBlockPool& aCBPool=pPaveFiller->ChangeCommonBlockPool(); - // - Standard_Integer iRankF1, iRankF2, nF2, nSpEF2, nEF2, nFace; - TopExp_Explorer anExp2; - TopAbs_Orientation anOrEF2; - // - BOPTools_SSInterference& aFF=aFFs(iFF); - nF2=aFF.OppositeIndex(nF1); - // - const TopoDS_Face& aF2=TopoDS::Face(aDS.Shape(nF2)); - // - iRankF1=aDS.Rank(nF1); - iRankF2=aDS.Rank(nF2); - // - // EF2\F1 Processing - anExp2.Init (aF2, TopAbs_EDGE); - for (; anExp2.More(); anExp2.Next()) { - const TopoDS_Edge& aEF2= TopoDS::Edge(anExp2.Current()); - anOrEF2=aEF2.Orientation(); - - nEF2=aDS.ShapeIndex (aEF2, iRankF2); - - BOPTools_ListOfCommonBlock& aLCB=aCBPool(aDS.RefEdge(nEF2)); - - BOPTools_ListIteratorOfListOfCommonBlock anItCB(aLCB); - for (; anItCB.More(); anItCB.Next()) { - BOPTools_CommonBlock& aCB=anItCB.Value(); - nFace=aCB.Face(); - if (nFace==nF1) { - BOPTools_PaveBlock& aPB=aCB.PaveBlock1(nEF2); - - nSpEF2=aPB.Edge(); - const TopoDS_Shape& aSpEF2=aDS.Shape(nSpEF2); - - if (anEMap.Contains(aSpEF2)) { - continue;// next CB - } - anEMap.Add(aSpEF2); - - TopoDS_Edge aSS=TopoDS::Edge(aSpEF2); - // - // - //iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii - // Internal edges treatment - { - if (anOrEF2==TopAbs_INTERNAL) { - aSS.Orientation(TopAbs_FORWARD); - } - } - //iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii - // - if (myOperation== BOP_FUSE) { - aWES.AddStartElement (aSS); - aSS.Reverse(); - aWES.AddStartElement (aSS); - } - } - } // next CB on nEF2 - } -} -//xf -//======================================================================= -// function: AddINON2DPartsSh -// purpose: -//======================================================================= - void BOP_ShellSolid::AddINON2DPartsSh(const Standard_Integer nF1, - const Standard_Integer iFF, - BOP_WireEdgeSet& aWES) -{ - TopTools_IndexedMapOfShape anEMap; - AddINON2DPartsSh(nF1, iFF, aWES, anEMap); -} -//xt -//======================================================================= -// function: AddINON2DPartsSh -// purpose: -//======================================================================= - void BOP_ShellSolid::AddINON2DPartsSh(const Standard_Integer nF1, - const Standard_Integer iFF, - BOP_WireEdgeSet& aWES, - TopTools_IndexedMapOfShape& anEMap) //xft -{ - const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); - BOPTools_InterferencePool* pIntrPool=(BOPTools_InterferencePool*)&myDSFiller->InterfPool(); - BOPTools_CArray1OfSSInterference& aFFs=pIntrPool->SSInterferences(); - // - Standard_Integer iRankF1, nF2, iSenseFlag; - - iRankF1=aDS.Rank(nF1); - - BOPTools_SSInterference& aFF=aFFs(iFF); - nF2=aFF.OppositeIndex(nF1); - // - iSenseFlag=aFF.SenseFlag(); - // - BOP_SDFWESFiller aWESFiller; - - aWESFiller.SetDSFiller(*myDSFiller); - aWESFiller.SetFaces(nF1, nF2); - aWESFiller.SetStatesMap(aFF.StatesMap()); - // - aWESFiller.SetSenseFlag(iSenseFlag); - - switch (myOperation) { - - case BOP_FUSE: - if (myRank==2) { - //shell\solid case when the solid is the first arg. - iRankF1=1; - } - if (iRankF1==1) { - aWESFiller.SetOperation(BOP_CUT); - aWESFiller.Do(aWES); - aWESFiller.SetOperation(BOP_COMMON); - aWESFiller.Do(aWES); - } - else { - aWESFiller.SetOperation(BOP_CUT); - aWESFiller.Do(aWES); - } - break; - - case BOP_COMMON: - if (myRank==2) { - //shell\solid case when the solid is the first arg. - iRankF1=1; - } - if (iRankF1==1) { - aWESFiller.SetOperation(BOP_COMMON); - aWESFiller.Do(aWES); - } - break; - - case BOP_CUT: - if (iRankF1==1) { - aWESFiller.SetOperation(BOP_CUT); - aWESFiller.Do(aWES); - } - break; - - case BOP_CUT21: - if (iRankF1==2) { - aWESFiller.SetOperation(BOP_CUT); - aWESFiller.Do(aWES); - } - break; - - default: - break; - } - // - //xf - // Collect all split edges of nF1 that are CB with - // splis of all SD faces to nFx, - // but not included in aWES (RejectedOnParts). - // This is necessary to prevent inclusion these splits in - // AddPartsEENonSDSh(...) - // see BOP_SDFWESFiller, BOP_ShellSolid::DoNewFaces() - // for more details; - TopTools_ListIteratorOfListOfShape aIt; - // - const TopTools_ListOfShape& aLRE=aWESFiller.RejectedOnParts(); - aIt.Initialize(aLRE); - for(; aIt.More(); aIt.Next()) { - const TopoDS_Shape& aE=aIt.Value(); - anEMap.Add(aE); - } - //xt -} -//======================================================================= -// function: AddPartsEFNonSDSh -// purpose: -//======================================================================= - void BOP_ShellSolid::AddPartsEFNonSDSh (const Standard_Integer nF1, - const Standard_Integer iFF, - TopTools_IndexedMapOfShape& anEMap, - BOP_WireEdgeSet& aWES) -{ - const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); - BOPTools_InterferencePool* pIntrPool=(BOPTools_InterferencePool*)&myDSFiller->InterfPool(); - BOPTools_CArray1OfSSInterference& aFFs=pIntrPool->SSInterferences(); - - const BOPTools_PaveFiller& aPF=myDSFiller->PaveFiller(); - BOPTools_PaveFiller* pPaveFiller=(BOPTools_PaveFiller*)&aPF; - BOPTools_CommonBlockPool& aCBPool=pPaveFiller->ChangeCommonBlockPool(); - // - Standard_Integer nF2, nSpEF2, nEF2, nFace, iRankF2; - TopExp_Explorer anExp2; - TopAbs_Orientation anOrEF2 = TopAbs_FORWARD; - // - BOPTools_SSInterference& aFF=aFFs(iFF); - nF2=aFF.OppositeIndex(nF1); - // - const TopoDS_Face& aF2=TopoDS::Face(aDS.Shape(nF2)); - - iRankF2=aDS.Rank(nF2); - // - TopTools_IndexedMapOfOrientedShape aWESMap; - { - const TopTools_ListOfShape& aWESList=aWES.StartElements(); - TopTools_ListIteratorOfListOfShape anIt(aWESList); - for (; anIt.More(); anIt.Next()) { - const TopoDS_Shape& aS=anIt.Value(); - aWESMap.Add(aS); - } - } - // - // EF2\F1 Processing - anExp2.Init (aF2, TopAbs_EDGE); - for (; anExp2.More(); anExp2.Next()) { - const TopoDS_Edge& aEF2= TopoDS::Edge(anExp2.Current()); - - nEF2=aDS.ShapeIndex(aEF2, iRankF2); - - BOPTools_ListOfCommonBlock& aLCB=aCBPool(aDS.RefEdge(nEF2)); - - BOPTools_ListIteratorOfListOfCommonBlock anItCB(aLCB); - for (; anItCB.More(); anItCB.Next()) { - BOPTools_CommonBlock& aCB=anItCB.Value(); - nFace=aCB.Face(); - - if (nFace==nF1) { - BOPTools_PaveBlock& aPB=aCB.PaveBlock1(nEF2); - - nSpEF2=aPB.Edge(); - const TopoDS_Shape& aSpEF2=aDS.Shape(nSpEF2); - // - if (anEMap.Contains(aSpEF2)) { - continue;// next CB - } - anEMap.Add(aSpEF2); - // - if (aWESMap.Contains(aSpEF2)) { - continue;// next CB - } - aWESMap.Add(aSpEF2); - // - TopoDS_Edge aSS=TopoDS::Edge(aSpEF2); - // - // - //iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii - // Internal edges treatment - { - if (anOrEF2==TopAbs_INTERNAL) { - aSS.Orientation(TopAbs_FORWARD); - } - } - //iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii - // - if (myOperation==BOP_FUSE) { - aWES.AddStartElement(aSS); - aSS.Reverse(); - aWES.AddStartElement(aSS); - } - // - } //if (nFace==nF1) { - } // next CB on nEF2 - } -} -//======================================================================= -// function: AddPartsEENonSDSh -// purpose: -//======================================================================= - void BOP_ShellSolid::AddPartsEENonSDSh (const Standard_Integer nF1, - const Standard_Integer iFF, - TopTools_IndexedMapOfShape& anEMap, - BOP_WireEdgeSet& aWES) -{ - const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); - BOPTools_InterferencePool* pIntrPool=(BOPTools_InterferencePool*)&myDSFiller->InterfPool(); - BOPTools_CArray1OfSSInterference& aFFs=pIntrPool->SSInterferences(); - - const BOPTools_PaveFiller& aPF=myDSFiller->PaveFiller(); - BOPTools_PaveFiller* pPaveFiller=(BOPTools_PaveFiller*)&aPF; - BOPTools_CommonBlockPool& aCBPool=pPaveFiller->ChangeCommonBlockPool(); - // - const Handle(IntTools_Context)& aContext=pPaveFiller->Context(); - // - Standard_Integer nEF1, nF2, nSpF1, nSpF2, nEF2, nSpTaken, nF2x, iRankF1; - Standard_Boolean bToReverse; - TopAbs_Orientation anOrEF1, anOrEF2; - TopExp_Explorer anExp; - TopTools_IndexedMapOfShape aM; - TColStd_ListOfInteger aSplitsOnF1; - TColStd_ListIteratorOfListOfInteger anItSp; - TColStd_IndexedMapOfInteger aMSplitsOnF1; - TopoDS_Edge aSSF1, aSSF2; - // - // nF1 - iRankF1=aDS.Rank(nF1); - // - // nF2 - BOPTools_SSInterference& aFF=aFFs(iFF); - nF2=aFF.OppositeIndex(nF1); - // - pPaveFiller->SplitsOnFace(0, nF1, nF2, aSplitsOnF1); - anItSp.Initialize(aSplitsOnF1); - for (; anItSp.More(); anItSp.Next()) { - nSpF1=anItSp.Value(); - aMSplitsOnF1.Add(nSpF1); - } - // - TopTools_IndexedMapOfOrientedShape aWESMap; - { - const TopTools_ListOfShape& aWESList=aWES.StartElements(); - TopTools_ListIteratorOfListOfShape anIt(aWESList); - for (; anIt.More(); anIt.Next()) { - const TopoDS_Shape& aS=anIt.Value(); - aWESMap.Add(aS); - } - } - // - anExp.Init(myFace, TopAbs_EDGE); - for (; anExp.More(); anExp.Next()) { - const TopoDS_Edge& anEF1=TopoDS::Edge(anExp.Current()); - anOrEF1=anEF1.Orientation(); - nEF1=aDS.ShapeIndex(anEF1, iRankF1); - - BOPTools_ListOfCommonBlock& aLCB=aCBPool(aDS.RefEdge(nEF1)); - - BOPTools_ListIteratorOfListOfCommonBlock anItCB(aLCB); - for (; anItCB.More(); anItCB.Next()) { - BOPTools_CommonBlock& aCB=anItCB.Value(); - - BOPTools_PaveBlock& aPBEF1=aCB.PaveBlock1(nEF1); - BOPTools_PaveBlock& aPBEF2=aCB.PaveBlock2(nEF1); - - nF2x=aCB.Face(); - if (nF2x) { - continue; - } - // Splits that are ON other Edge from other Face - nSpF1=aPBEF1.Edge(); - // - if (!aMSplitsOnF1.Contains(nSpF1)) { - continue;// next CB - } - // - nSpF2=aPBEF2.Edge(); - nEF2=aPBEF2.OriginalEdge(); - - const TopoDS_Edge& anEF2=TopoDS::Edge(aDS.Shape(nEF2)); - anOrEF2=anEF2.Orientation(); - - const TopoDS_Shape& aSpF1=aDS.Shape(nSpF1); - const TopoDS_Shape& aSpF2=aDS.Shape(nSpF2); - - // - if (anEMap.Contains(aSpF1)) { - continue;// next CB - } - anEMap.Add(aSpF1); - // - if (anEMap.Contains(aSpF2)) { - continue;// next CB - } - anEMap.Add(aSpF2); - // - - // Pave Block from which new edge will be taken - const BOPTools_PaveBlock& aPB=aCB.PaveBlock1(); - nSpTaken=aPB.Edge(); - // - //iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii - // Internal edges treatment - { - Standard_Boolean bInternal1, bInternal2; - bInternal1=(anOrEF1==TopAbs_INTERNAL); - bInternal2=(anOrEF2==TopAbs_INTERNAL); - - if (bInternal1) { - aSSF1=TopoDS::Edge(aDS.Shape(nSpTaken)); - - if (myOperation==BOP_FUSE) { - aSSF1.Orientation(TopAbs_FORWARD); - aWES.AddStartElement (aSSF1); - aSSF1.Reverse(); - aWES.AddStartElement (aSSF1); - continue; - } - - if (myOperation==BOP_CUT && iRankF1==1) { - aSSF1.Orientation(TopAbs_INTERNAL); - aWES.AddStartElement (aSSF1); - continue; - } - - if (myOperation==BOP_CUT21 && iRankF1==2) { - aSSF1.Orientation(TopAbs_INTERNAL); - aWES.AddStartElement (aSSF1); - continue; - } - } - - else if (!bInternal1 && bInternal2) { - if (nSpTaken!=nSpF1) { - - if ((myOperation==BOP_FUSE)|| - (myOperation==BOP_CUT && iRankF1==1) || - (myOperation==BOP_CUT21 && iRankF1==2)) { - - aSSF1=TopoDS::Edge(aSpF1); - aSSF1.Orientation(anOrEF1); - - aSSF2=TopoDS::Edge(aSpF2); - - aSSF2.Orientation(TopAbs_FORWARD); - bToReverse=BOPTools_Tools3D::IsSplitToReverse1 (aSSF1, aSSF2, aContext); - if (bToReverse) { - aSSF2.Reverse(); - } - - aWES.AddStartElement (aSSF2); - continue; - } - } - } - } - //iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii - // - aSSF1=TopoDS::Edge(aSpF1); - aSSF1.Orientation(anOrEF1); - - if (nSpTaken==nSpF1) { - // Common Edge is from nEF1 - aWES.AddStartElement (aSSF1); - } - else { - // Common Edge is from nEF2 nSpTaken!=nSpF2 - aSSF2=TopoDS::Edge(aSpF2); - - bToReverse=BOPTools_Tools3D::IsSplitToReverse1 (aSSF1, aSSF2, aContext); - if (bToReverse) { - aSSF2.Reverse(); - } - // - if (BRep_Tool::IsClosed(aSSF1, myFace)) { - if (aM.Contains(aSSF2)){ - continue; - } - aM.Add(aSSF2); - // - if (!BRep_Tool::IsClosed(aSSF2, myFace)) { - BOPTools_Tools3D::DoSplitSEAMOnFace (aSSF2, myFace); - } - aWES.AddStartElement (aSSF2); - aSSF2.Reverse(); - aWES.AddStartElement (aSSF2); - continue; - } - // - aWES.AddStartElement (aSSF2); - }// else /*if (nSpTaken==nSpF2)*/ { - }// for (; anItCB.More(); anItCB.Next()) - }// for (; anExp.More(); anExp.Next()) -} -//======================================================================= -//function : CheckSplitToAvoid -//purpose : -//======================================================================= -Standard_Boolean CheckSplitToAvoid(const TopoDS_Edge& theSplit, - const BOPTools_CommonBlock& theCB, - const Standard_Integer theEdgeIndex, - const Standard_Integer theFaceIndex, - const BOPTools_PDSFiller& theDSFiller, - const BOP_Operation& theOperation, - const Handle(IntTools_Context)& theContext) { - - Standard_Integer anE = -1; - - if(theCB.PaveBlock1().OriginalEdge() == theEdgeIndex) { - anE = theCB.PaveBlock2().OriginalEdge(); - } - else if(theCB.PaveBlock2().OriginalEdge() == theEdgeIndex) { - anE = theCB.PaveBlock1().OriginalEdge(); - } - - if(anE >= 0) { - const TopoDS_Shape& anEdge = theDSFiller->DS().Shape(anE); - TopoDS_Face aFaceCur = TopoDS::Face(theDSFiller->DS().Shape(theFaceIndex)); - aFaceCur.Orientation(TopAbs_FORWARD); - - TopTools_IndexedDataMapOfShapeListOfShape aMapEF; - Standard_Integer aRank = theDSFiller->DS().Rank(anE); - TopoDS_Shape aSource = (aRank == 1) ? theDSFiller->Shape1() : theDSFiller->Shape2(); - TopExp::MapShapesAndAncestors(aSource, TopAbs_EDGE, TopAbs_FACE, aMapEF); - - if(aMapEF.Contains(anEdge)) { - const TopTools_ListOfShape& aLF = aMapEF.FindFromKey(anEdge); - - if(!aLF.IsEmpty()) { - TopTools_ListIteratorOfListOfShape anIt(aLF); - Standard_Boolean avoid = Standard_True; - - for(; anIt.More(); anIt.Next()) { - const TopoDS_Face& aFace = TopoDS::Face(anIt.Value()); - Standard_Real f = 0., l = 0.; - Handle(Geom2d_Curve) aCurve = BRep_Tool::CurveOnSurface(theSplit, aFaceCur, f, l); - - if(!aCurve.IsNull()) { - Standard_Real amidpar = (f + l) * 0.5; - - if(theOperation == BOP_COMMON) { - gp_Pnt2d aPoint2d; - gp_Pnt aPoint3d; - Standard_Real aTolerance = BRep_Tool::Tolerance(theSplit); //??? - BOPTools_Tools3D::PointNearEdge(theSplit, aFaceCur, amidpar, aTolerance, aPoint2d, aPoint3d); - GeomAPI_ProjectPointOnSurf& aProjector = theContext->ProjPS(aFace); - aProjector.Perform(aPoint3d); - - if(aProjector.IsDone()) { - Standard_Real U = 0., V = 0.; - Standard_Real adist = aProjector.LowerDistance(); - - if(adist < BRep_Tool::Tolerance(aFace)) { - aProjector.LowerDistanceParameters(U, V); - - if(theContext->IsPointInFace(aFace, gp_Pnt2d(U, V))) { - avoid = Standard_False; - break; - } - else { - } - } - } - } - else if(theOperation == BOP_CUT) { - if(theDSFiller->DS().Rank(theFaceIndex) != 2) { - avoid = Standard_False; - continue; - } - gp_Pnt2d aPoint2d; - gp_Pnt aPoint3d; - Standard_Real aTolerance = BRep_Tool::Tolerance(theSplit); //??? - BOPTools_Tools3D::PointNearEdge(theSplit, aFaceCur, amidpar, aTolerance, aPoint2d, aPoint3d); - GeomAPI_ProjectPointOnSurf& aProjector = theContext->ProjPS(aFace); - aProjector.Perform(aPoint3d); - - if(aProjector.IsDone()) { - Standard_Real U = 0., V = 0.; - Standard_Real adist = aProjector.LowerDistance(); - - if(adist < BRep_Tool::Tolerance(aFace)) { - aProjector.LowerDistanceParameters(U, V); - - if(theContext->IsPointInFace(aFace, gp_Pnt2d(U, V))) { - avoid = Standard_False; - break; - } - else { - } - } - } - } - else if(theOperation == BOP_CUT21) { - if(theDSFiller->DS().Rank(theFaceIndex) != 1) { - avoid = Standard_False; - continue; - } - gp_Pnt2d aPoint2d; - gp_Pnt aPoint3d; - Standard_Real aTolerance = BRep_Tool::Tolerance(theSplit); //??? - BOPTools_Tools3D::PointNearEdge(theSplit, aFaceCur, amidpar, aTolerance, aPoint2d, aPoint3d); - GeomAPI_ProjectPointOnSurf& aProjector = theContext->ProjPS(aFace); - aProjector.Perform(aPoint3d); - - if(aProjector.IsDone()) { - Standard_Real U = 0., V = 0.; - Standard_Real adist = aProjector.LowerDistance(); - - if(adist < BRep_Tool::Tolerance(aFace)) { - aProjector.LowerDistanceParameters(U, V); - - if(theContext->IsPointInFace(aFace, gp_Pnt2d(U, V))) { - avoid = Standard_False; - break; - } - else { - } - } - } - } - // end if(theOperation == BOP_CUT21... - else { - avoid = Standard_False; - break; - } - } - } - - if(avoid) { - return Standard_True; - } - } - // end if(!aLF.IsEmpty... - } - } - - return Standard_False; -} diff --git a/src/BOP/BOP_ShellSolid_2.cxx b/src/BOP/BOP_ShellSolid_2.cxx deleted file mode 100755 index 678a7ac982..0000000000 --- a/src/BOP/BOP_ShellSolid_2.cxx +++ /dev/null @@ -1,1500 +0,0 @@ -// Created on: 2001-11-02 -// Created by: Peter KURNEV -// Copyright (c) 2001-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#include - -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - - -static - void AddPartsEF (const TopoDS_Edge& aSSin, - const TopoDS_Edge& aEF2, - const TopoDS_Face& aF2, - const TopoDS_Face& myFace, - const Standard_Integer iRankF1, - const BOP_Operation myOperation, - const TopTools_IndexedDataMapOfShapeListOfShape& aMEF, - BOP_WireEdgeSet& aWES); -static - void AddPartEF1INF2 (TopoDS_Edge& aSS, - const TopoDS_Face& myFace, - const TopoDS_Face& aF2, - const Standard_Integer iRankF1, - const BOP_Operation myOperation, - BOP_WireEdgeSet& aWES); -static - void BothInternals (TopoDS_Edge& aSS, - const TopoDS_Face& myFace, - const TopoDS_Face& aF2, - const Standard_Integer iRankF1, - const BOP_Operation myOperation, - BOP_WireEdgeSet& aWES); -static - void FirstInternal(TopoDS_Edge& aSS, - const TopoDS_Face& myFace, - const TopoDS_Face& aF2, - const TopoDS_Edge& anEF2, - TopoDS_Edge& aSSx, - const Standard_Integer iRankF1, - const BOP_Operation myOperation, - const TopTools_IndexedDataMapOfShapeListOfShape& aMEF, - BOP_WireEdgeSet& aWES, - const Handle(IntTools_Context)& aContext); - -static - void SecondInternal(TopoDS_Edge& aSS, - const TopoDS_Face& aF1, - const TopoDS_Face& aF2, - const TopoDS_Edge& anEF1, - TopoDS_Edge& aSSx, - const TopAbs_Orientation anOrEF1, - const Standard_Integer iRankF1, - const BOP_Operation myOperation, - BOP_WireEdgeSet& aWES, - const Handle(IntTools_Context)& aContext); - - -//======================================================================= -// -// the WES components for a solid -// -//======================================================================= -// function: AddSectionPartsSo -// purpose: -//======================================================================= - void BOP_ShellSolid::AddSectionPartsSo (const Standard_Integer nF1, - const Standard_Integer iFF, - BOP_WireEdgeSet& aWES) -{ - const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); - - BOPTools_InterferencePool* pIntrPool= - (BOPTools_InterferencePool*)&myDSFiller->InterfPool(); - - BOPTools_CArray1OfSSInterference& aFFs=pIntrPool->SSInterferences(); - // - Standard_Integer i, aNbCurves, nF2, nE, iRankF1; - Standard_Boolean bIsTouchCase; - // - iRankF1=aDS.Rank(nF1); - // - BOPTools_SSInterference& aFF=aFFs(iFF); - nF2=aFF.OppositeIndex(nF1); - // - const TopoDS_Face& aF2=TopoDS::Face(aDS.Shape(nF2)); - // - BOPTools_SequenceOfCurves& aSC=aFF.Curves(); - aNbCurves=aSC.Length(); - for (i=1; i<=aNbCurves; i++) { - const BOPTools_Curve& aBC=aSC(i); - const BOPTools_ListOfPaveBlock& aLPB=aBC.NewPaveBlocks(); - BOPTools_ListIteratorOfListOfPaveBlock anIt(aLPB); - for (; anIt.More(); anIt.Next()) { - const BOPTools_PaveBlock& aPB=anIt.Value(); - nE=aPB.Edge(); - const TopoDS_Edge& aE=TopoDS::Edge(aDS.Shape(nE)); - - TopoDS_Edge aES=aE; - bIsTouchCase=BOPTools_Tools3D::IsTouchCase(aES, myFace, aF2); - if (bIsTouchCase) { - aWES.AddStartElement (aES); - aES.Reverse(); - aWES.AddStartElement (aES); - } - else { - BOP_BuilderTools::OrientSectionEdgeOnF1 - (myFace, aF2, iRankF1, myOperation, aES); - aWES.AddStartElement (aES); - } - } - } -} -//======================================================================= -// function: AddSplitPartsON3DSo -// purpose: -//======================================================================= - void BOP_ShellSolid::AddSplitPartsON3DSo(const Standard_Integer nF1, - const Standard_Integer iFF, - BOP_WireEdgeSet& aWES) -{ - const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); - const BOPTools_PaveFiller& aPaveFiller=myDSFiller->PaveFiller(); - - BOPTools_PaveFiller* pPaveFiller=(BOPTools_PaveFiller*)&aPaveFiller; - BOPTools_CommonBlockPool& aCBPool=pPaveFiller->ChangeCommonBlockPool(); - - BOPTools_InterferencePool* pIntrPool=(BOPTools_InterferencePool*)&myDSFiller->InterfPool(); - BOPTools_CArray1OfSSInterference& aFFs=pIntrPool->SSInterferences(); - // - const Handle(IntTools_Context)& aContext=pPaveFiller->Context(); - // - Standard_Boolean bIsToKeep; - Standard_Integer nEF1, nF2, nF2x, nSpF1, iRankF1; - TopAbs_Orientation anOrEF1; - TopExp_Explorer anExp; - // - BOPTools_SSInterference& aFF=aFFs(iFF); - nF2=aFF.OppositeIndex(nF1); - - const TopoDS_Face& aF1=TopoDS::Face(aDS.Shape(nF1)); - const TopoDS_Face& aF2=TopoDS::Face(aDS.Shape(nF2)); - - iRankF1=aDS.Rank(nF1); - // - // - anExp.Init(myFace, TopAbs_EDGE); - for (; anExp.More(); anExp.Next()) { - const TopoDS_Edge& anEF1=TopoDS::Edge(anExp.Current()); - anOrEF1=anEF1.Orientation(); - - nEF1=aDS.ShapeIndex(anEF1, iRankF1); - - BOPTools_ListOfCommonBlock& aLCB=aCBPool(aDS.RefEdge(nEF1)); - - BOPTools_ListIteratorOfListOfCommonBlock anItCB(aLCB); - for (; anItCB.More(); anItCB.Next()) { - BOPTools_CommonBlock& aCB=anItCB.Value(); - - BOPTools_PaveBlock& aPBEF1=aCB.PaveBlock1(nEF1); - // - nF2x=aCB.Face(); - - if (nF2x==nF2) { - // Splits that are ON (IN 2D) for other Face (aF2) - nSpF1=aPBEF1.Edge(); - const TopoDS_Shape& aSplit=aDS.Shape(nSpF1); - TopoDS_Edge aSS=TopoDS::Edge(aSplit); - // - //iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii - // Internal edges treatment - { - if (anOrEF1==TopAbs_INTERNAL) { - AddPartEF1INF2(aSS, myFace, aF2, iRankF1, myOperation, aWES); - continue; - } - } - // - //iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii - // - aSS.Orientation(anOrEF1); - // - TopAbs_State aState1= - BOPTools_Tools3D::GetStatePartIN2D(aSS, anEF1, aF1, aF2, aContext); - // - bIsToKeep= - BOP_BuilderTools::IsPartIN2DToKeep(aState1, iRankF1, myOperation); - // - if (bIsToKeep) { - aWES.AddStartElement (aSS); - } - } - } - } -} -//======================================================================= -// function: AddSplitPartsONSo -// purpose: -//======================================================================= - void BOP_ShellSolid::AddSplitPartsONSo(const Standard_Integer nF1, - const TopTools_IndexedDataMapOfShapeListOfShape& aMEFObj, - const TopTools_IndexedDataMapOfShapeListOfShape& aMEFTool, - BOP_WireEdgeSet& aWES) -{ - const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); - const BOPTools_PaveFiller& aPaveFiller=myDSFiller->PaveFiller(); - - BOPTools_PaveFiller* pPaveFiller=(BOPTools_PaveFiller*)&aPaveFiller; - BOPTools_CommonBlockPool& aCBPool=pPaveFiller->ChangeCommonBlockPool(); - // - const Handle(IntTools_Context)& aContext=pPaveFiller->Context(); - // - Standard_Integer nEF1, nF2, nSpF1, nSpF2, nEF2, nSpTaken, iRankF1; - TopAbs_Orientation anOrEF1, anOrEF2; - TopExp_Explorer anExp; - TopTools_IndexedMapOfShape aM; - // - const TopoDS_Face& aF1=TopoDS::Face(aDS.Shape(nF1)); - iRankF1=aDS.Rank(nF1); - // - // - anExp.Init(myFace, TopAbs_EDGE); - for (; anExp.More(); anExp.Next()) { - const TopoDS_Edge& anEF1=TopoDS::Edge(anExp.Current()); - anOrEF1=anEF1.Orientation(); - - nEF1=aDS.ShapeIndex(anEF1, iRankF1); - - BOPTools_ListOfCommonBlock& aLCB=aCBPool(aDS.RefEdge(nEF1)); - - BOPTools_ListIteratorOfListOfCommonBlock anItCB(aLCB); - for (; anItCB.More(); anItCB.Next()) { - BOPTools_CommonBlock& aCB=anItCB.Value(); - - BOPTools_PaveBlock& aPBEF1=aCB.PaveBlock1(nEF1); - BOPTools_PaveBlock& aPBEF2=aCB.PaveBlock2(nEF1); - nF2=aCB.Face(); - if (nF2) { - // Splits that are ON (IN 2D) for other Face (aF2) - Standard_Boolean bIsToKeep; - - const TopoDS_Face& aF2=TopoDS::Face(aDS.Shape(nF2)); - - nSpF1=aPBEF1.Edge(); - const TopoDS_Shape& aSplit=aDS.Shape(nSpF1); - TopoDS_Edge aSS=TopoDS::Edge(aSplit); - // - //iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii - // Internal edges treatment - { - if (anOrEF1==TopAbs_INTERNAL) { - AddPartEF1INF2(aSS, myFace, aF2, iRankF1, myOperation, aWES); - continue; - } - } - // - //iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii - // - aSS.Orientation(anOrEF1); - // - TopAbs_State aState1= - BOPTools_Tools3D::GetStatePartIN2D(aSS, anEF1, aF1, aF2, aContext); - - bIsToKeep= - BOP_BuilderTools::IsPartIN2DToKeep(aState1, iRankF1, myOperation); - // - if (bIsToKeep) { - aWES.AddStartElement (aSS); - } - // - } - else {// else x - // Splits that are ON other Edge from other Face - nSpF1=aPBEF1.Edge(); - nSpF2=aPBEF2.Edge(); - nEF2=aPBEF2.OriginalEdge(); - // - // Pave Block from which new edge will be taken - const BOPTools_PaveBlock& aPB=aCB.PaveBlock1(); - nSpTaken=aPB.Edge(); - // - //iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii - // Internal edges treatment - { - Standard_Boolean bInternal1, bInternal2; - - const TopoDS_Edge& anEF2=TopoDS::Edge(aDS.Shape(nEF2)); - anOrEF2=anEF2.Orientation(); - - const TopTools_IndexedDataMapOfShapeListOfShape& aMEF= - (iRankF1==1) ? aMEFTool : aMEFObj; - const TopTools_ListOfShape& aLF2=aMEF.FindFromKey(anEF2); - const TopoDS_Face& aF2=TopoDS::Face(aLF2.First()); - // - bInternal1=(anOrEF1==TopAbs_INTERNAL); - bInternal2=(anOrEF2==TopAbs_INTERNAL); - // - if (bInternal1 || bInternal2) { - Standard_Integer nSpNotTaken; - // - nSpNotTaken=(nSpF1==nSpTaken) ? nSpF2 : nSpF1; - // - TopoDS_Edge aSS =TopoDS::Edge(aDS.Shape(nSpTaken)); - TopoDS_Edge aSSx=TopoDS::Edge(aDS.Shape(nSpNotTaken)); - - // a. Both parts are interlal edges - if (bInternal1 && bInternal2) { - BothInternals(aSS, myFace, aF2, iRankF1, myOperation, aWES); - } - - // b. The first is internal , the second is not - else if (bInternal1 && !bInternal2) { - FirstInternal(aSS, myFace, aF2, anEF2, aSSx, - iRankF1, myOperation, aMEF, aWES, aContext); - } - - // c. The first is no1 internal , the second is internal - else if (!bInternal1 && bInternal2) { - SecondInternal (aSS, aF1, aF2, anEF1, aSSx, - anOrEF1, iRankF1, myOperation, aWES, aContext); - } - continue; - } - } - // - //iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii - // - Standard_Boolean bIsON2DToKeep, bIsON2DToKeepSimm=Standard_False; - { - const TopoDS_Edge& anEFx=TopoDS::Edge(aDS.Shape(nEF2)); - TopoDS_Edge aSpFx=TopoDS::Edge(aDS.Shape(nSpF2)); - const TopTools_IndexedDataMapOfShapeListOfShape& aMEFx= - (iRankF1==1) ? aMEFTool : aMEFObj; - // - // anEF1 - TopAbs_State aST1; - BOPTools_Tools3D::GetPlanes(aSpFx, anEFx, aMEFx, anEF1, aF1, aST1, aContext); - bIsON2DToKeep= - BOP_BuilderTools::IsPartOn2dToKeep(aST1, iRankF1, myOperation); - - if (BRep_Tool::IsClosed(anEF1, aF1)) { - TopoDS_Edge anEF1Seam; - BOPTools_Tools3D::GetSeam (aF1, anEF1, anEF1Seam); - // - if (!anEF1Seam.IsNull()) { - TopAbs_State aSTSeam; - - BOPTools_Tools3D::GetPlanes(aSpFx, anEFx, aMEFx, anEF1Seam, aF1, aSTSeam, aContext); - bIsON2DToKeepSimm= - BOP_BuilderTools::IsPartOn2dToKeep(aSTSeam, iRankF1, myOperation); - } - bIsON2DToKeep=bIsON2DToKeep || bIsON2DToKeepSimm; - } - } - // - - if (nSpTaken==nSpF1) { - // Common Edge is from nEF1 - const TopoDS_Shape& aSp1=aDS.Shape(nSpF1); - TopoDS_Edge aSS=TopoDS::Edge(aSp1); - aSS.Orientation(anOrEF1); - // - if (bIsON2DToKeep) { - aWES.AddStartElement (aSS); - } - } - else /*if (nSpTaken==nSpF2)*/ { - // Common Edge is from nEF2 - - const TopoDS_Shape& aSp1=aDS.Shape(nSpF1); - TopoDS_Edge aSpF1=TopoDS::Edge(aSp1); - aSpF1.Orientation(anOrEF1); - - const TopoDS_Shape& aSp2=aDS.Shape(nSpF2); - TopoDS_Edge aSpF2=TopoDS::Edge(aSp2); - - Standard_Boolean bToReverse= - BOPTools_Tools3D::IsSplitToReverse1 (aSpF1, aSpF2, aContext); - if (bToReverse) { - aSpF2.Reverse(); - } - // - if (BRep_Tool::IsClosed(aSpF1, myFace)) { - if (aM.Contains(aSpF2)){ - continue; - } - aM.Add(aSpF2); - // - if (bIsON2DToKeep) { - if (!BRep_Tool::IsClosed(aSpF2, myFace)) { - // modified by NIZHNY-MKK Mon Feb 17 15:12:22 2003.BEGIN - // BOPTools_Tools3D::DoSplitSEAMOnFace (aSpF2, myFace); - Standard_Boolean bIsReversed = Standard_False; - - if(!BOPTools_Tools3D::DoSplitSEAMOnFace(aSpF2, aSpF1, myFace, bIsReversed)) - BOPTools_Tools3D::DoSplitSEAMOnFace (aSpF2, myFace); - // modified by NIZHNY-MKK Mon Feb 17 15:12:25 2003.END - } - - aWES.AddStartElement (aSpF2); - aSpF2.Reverse(); - aWES.AddStartElement (aSpF2); - } - continue; - } - // - if (bIsON2DToKeep) { - aWES.AddStartElement (aSpF2); - } - } - }// else x - }// for (; anItCB.More(); anItCB.Next()) - }// for (; anExp.More(); anExp.Next()) -} -//======================================================================= -// function: AddPartsEFSo -// purpose: -//======================================================================= - void BOP_ShellSolid::AddPartsEFSo (const Standard_Integer nF1, - const Standard_Integer iFF, - const TopTools_IndexedDataMapOfShapeListOfShape& aMEFObj, - const TopTools_IndexedDataMapOfShapeListOfShape& aMEFTool, - TopTools_IndexedMapOfShape& anEMap, - BOP_WireEdgeSet& aWES) -{ - const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); - BOPTools_InterferencePool* pIntrPool=(BOPTools_InterferencePool*)&myDSFiller->InterfPool(); - BOPTools_CArray1OfSSInterference& aFFs=pIntrPool->SSInterferences(); - - const BOPTools_PaveFiller& aPF=myDSFiller->PaveFiller(); - BOPTools_PaveFiller* pPaveFiller=(BOPTools_PaveFiller*)&aPF; - BOPTools_CommonBlockPool& aCBPool=pPaveFiller->ChangeCommonBlockPool(); - // - Standard_Integer iRankF1, iRankF2, nF2, nSpEF2, nEF2, nFace; - Standard_Boolean bIsKeepTwice, bIsAdjExists, bIsTouchCase; - TopExp_Explorer anExp2, anExp1; - // - BOPTools_SSInterference& aFF=aFFs(iFF); - nF2=aFF.OppositeIndex(nF1); - - - const TopoDS_Face& aF1=TopoDS::Face(aDS.Shape(nF1)); - const TopoDS_Face& aF2=TopoDS::Face(aDS.Shape(nF2)); - - iRankF1=aDS.Rank(nF1); - iRankF2=aDS.Rank(nF2); - - const TopTools_IndexedDataMapOfShapeListOfShape& aMEF=(iRankF2==1) ? aMEFObj : aMEFTool; - // - // EF2\F1 Processing - anExp2.Init (aF2, TopAbs_EDGE); - for (; anExp2.More(); anExp2.Next()) { - const TopoDS_Edge& aEF2= TopoDS::Edge(anExp2.Current()); - - nEF2=aDS.ShapeIndex(aEF2, iRankF2); - - BOPTools_ListOfCommonBlock& aLCB=aCBPool(aDS.RefEdge(nEF2)); - - BOPTools_ListIteratorOfListOfCommonBlock anItCB(aLCB); - for (; anItCB.More(); anItCB.Next()) { - BOPTools_CommonBlock& aCB=anItCB.Value(); - nFace=aCB.Face(); - if (nFace==nF1) { - BOPTools_PaveBlock& aPB=aCB.PaveBlock1(nEF2); - - nSpEF2=aPB.Edge(); - const TopoDS_Shape& aSpEF2=aDS.Shape(nSpEF2); - - if (anEMap.Contains(aSpEF2)) { - continue;// next CB - } - anEMap.Add(aSpEF2); - - TopoDS_Edge aSS=TopoDS::Edge(aSpEF2); - // - TopoDS_Face aF2Adj; - bIsAdjExists=BOPTools_Tools3D::GetAdjacentFace(aF2, aEF2, aMEF, aF2Adj); - - if (bIsAdjExists) { - bIsKeepTwice=BOPTools_Tools3D::IsKeepTwice(aF1, aF2, aF2Adj, aSS); - if (bIsKeepTwice) { - aWES.AddStartElement(aSS); - aSS.Reverse(); - aWES.AddStartElement(aSS); - } - else { - aSS.Orientation(TopAbs_FORWARD); - BOP_BuilderTools::OrientSectionEdgeOnF1 - (myFace, aF2, iRankF1, myOperation, aSS); - - aWES.AddStartElement(aSS); - } - } - else { - // No Adjacents - bIsTouchCase=BOPTools_Tools3D::IsTouchCase(aSS, myFace, aF2); - if (bIsTouchCase) { - aWES.AddStartElement(aSS); - aSS.Reverse(); - aWES.AddStartElement(aSS); - } - else { - aSS.Orientation(TopAbs_FORWARD); - BOP_BuilderTools::OrientSectionEdgeOnF1 - (myFace, aF2, iRankF1, myOperation, aSS); - - aWES.AddStartElement(aSS); - } - } - //continue; - } - - } // next CB on nEF2 - } -} -//======================================================================= -// function: AddINON2DPartsSo -// purpose: -//======================================================================= - void BOP_ShellSolid::AddINON2DPartsSo(const Standard_Integer iFF, - const Standard_Integer nF1, - const Standard_Integer nF2, - BOP_WireEdgeSet& aWES) -{ - const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); - BOPTools_InterferencePool* pIntrPool=(BOPTools_InterferencePool*)&myDSFiller->InterfPool(); - BOPTools_CArray1OfSSInterference& aFFs=pIntrPool->SSInterferences(); - // - Standard_Integer iSenseFlag, iRankF1; - // - iRankF1=aDS.Rank(nF1); - // - BOPTools_SSInterference& aFF=aFFs(iFF); - // - iSenseFlag=aFF.SenseFlag(); - // - BOP_SDFWESFiller aWESFiller; - aWESFiller.SetDSFiller(*myDSFiller); - aWESFiller.SetFaces(nF1, nF2); - aWESFiller.SetStatesMap(aFF.StatesMap()); - aWESFiller.SetSenseFlag(iSenseFlag); - - if (iSenseFlag==1) { - switch (myOperation) { - - case BOP_FUSE: - if (iRankF1==1) { - aWESFiller.SetOperation(BOP_CUT); - aWESFiller.Do(aWES); - aWESFiller.SetOperation(BOP_COMMON); - aWESFiller.Do(aWES); - } - else { - aWESFiller.SetOperation(BOP_CUT); - aWESFiller.Do(aWES); - } - break; - - case BOP_COMMON: - if (iRankF1==1) { - aWESFiller.SetOperation(BOP_COMMON); - aWESFiller.Do(aWES); - } - break; - - case BOP_CUT: - if (iRankF1==1) { - aWESFiller.SetOperation(BOP_CUT); - aWESFiller.Do(aWES); - } - break; - - case BOP_CUT21: - if (iRankF1==2) { - aWESFiller.SetOperation(BOP_CUT); - aWESFiller.Do(aWES); - } - break; - - default: - break; - } - } - - else if (iSenseFlag==-1) { // iSenseFlag<0 - switch (myOperation) { - - case BOP_FUSE: - aWESFiller.SetOperation(BOP_CUT); - aWESFiller.Do(aWES); - break; - - case BOP_COMMON: - break; - - case BOP_CUT: - if (iRankF1==1) { - aWESFiller.SetOperation(BOP_CUT); - aWESFiller.Do(aWES); - aWESFiller.SetOperation(BOP_COMMON); - aWESFiller.Do(aWES); - } - break; - - case BOP_CUT21: - if (iRankF1==2) { - aWESFiller.SetOperation(BOP_CUT); - aWESFiller.Do(aWES); - aWESFiller.SetOperation(BOP_COMMON); - aWESFiller.Do(aWES); - } - default: - break; - } - } -} -//======================================================================= -// function: AddPartsEFSDSo -// purpose: -//======================================================================= - void BOP_ShellSolid::AddPartsEFSDSo (const Standard_Integer nF1, - const Standard_Integer iFF, - const TopTools_IndexedDataMapOfShapeListOfShape& aMEFObj, - const TopTools_IndexedDataMapOfShapeListOfShape& aMEFTool, - BOP_WireEdgeSet& aWES) -{ - const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); - - BOPTools_InterferencePool* pIntrPool=(BOPTools_InterferencePool*)&myDSFiller->InterfPool(); - BOPTools_CArray1OfSSInterference& aFFs=pIntrPool->SSInterferences(); - - const BOPTools_PaveFiller& aPF=myDSFiller->PaveFiller(); - BOPTools_PaveFiller* pPaveFiller=(BOPTools_PaveFiller*)&aPF; - // - Standard_Integer iRankF1, iRankF2, nF2, bid=0, nSpEF2, nEF2, iSenseFlag; - Standard_Boolean bIsAdjExists, bKeptTwice; - TopExp_Explorer anExp2, anExp1; - // - BOPTools_SSInterference& aFF=aFFs(iFF); - nF2=aFF.OppositeIndex(nF1); - iSenseFlag=aFF.SenseFlag(); - - const TopoDS_Face& aF1=TopoDS::Face(aDS.Shape(nF1)); - const TopoDS_Face& aF2=TopoDS::Face(aDS.Shape(nF2)); - - iRankF1=aDS.Rank(nF1); - iRankF2=aDS.Rank(nF2); - - const TopTools_IndexedDataMapOfShapeListOfShape& aMEF=(iRankF2==1) ? aMEFObj : aMEFTool; - // - BOPTools_ListOfPaveBlock aLPB; - BOPTools_ListIteratorOfListOfPaveBlock anIt; - - pPaveFiller->SplitsInFace(bid, nF2, nF1, aLPB); - // - anIt.Initialize(aLPB); - for (; anIt.More(); anIt.Next()) { - const BOPTools_PaveBlock& aPBF2=anIt.Value(); - nEF2=aPBF2.OriginalEdge(); - nSpEF2=aPBF2.Edge(); - const TopoDS_Edge& aEF2=TopoDS::Edge(aDS.Shape(nEF2)); - const TopoDS_Edge& aSpEF2=TopoDS::Edge(aDS.Shape(nSpEF2)); - // - bKeptTwice=aWES.KeptTwice(aSpEF2); - - TopoDS_Face aF2Adj; - bIsAdjExists=BOPTools_Tools3D::GetAdjacentFace(aF2, aEF2, aMEF, aF2Adj); - - TopAbs_State aSt; - - if (bIsAdjExists) { - BOPTools_Tools3D::GetPointState(aSpEF2, aEF2, aF2Adj, aF1, aSt); - TopoDS_Edge aSS=aSpEF2; - aSS.Orientation(TopAbs_FORWARD); - Standard_Boolean bIsTouchCase; - - if (iSenseFlag==-1) { - if (aSt==TopAbs_IN) { - if (myOperation!=BOP_FUSE) { - if (bKeptTwice) { - aWES.RemoveEdgeFromWES(aSpEF2); - TopoDS_Edge aSpEF2R=TopoDS::Edge(aSpEF2.Reversed()); - aWES.RemoveEdgeFromWES(aSpEF2R); - } - - bIsTouchCase=BOPTools_Tools3D::IsTouchCase(aSS, myFace, aF2Adj); - if (bIsTouchCase) { - // - aWES.AddStartElement(aSS); - aSS.Reverse(); - aWES.AddStartElement(aSS); - // - } - else { - BOP_BuilderTools::OrientSectionEdgeOnF1 - (myFace, aF2Adj, iRankF1, myOperation, aSS); - aWES.AddStartElement(aSS); - } - } - else {//myOperation==BOP_FUSE && aSt==TopAbs_IN - aWES.RemoveEdgeFromWES(aSpEF2); - TopoDS_Edge aSpEF2R=TopoDS::Edge(aSpEF2.Reversed()); - aWES.RemoveEdgeFromWES(aSpEF2R); - } - } - - } - else {// if (iSenseFlag==1) - if (aSt==TopAbs_OUT) { - if (myOperation!=BOP_FUSE) { - if (bKeptTwice) { - aWES.RemoveEdgeFromWES(aSpEF2); - TopoDS_Edge aSpEF2R=TopoDS::Edge(aSpEF2.Reversed()); - aWES.RemoveEdgeFromWES(aSpEF2R); - } - bIsTouchCase=BOPTools_Tools3D::IsTouchCase(aSS, myFace, aF2Adj); - if (bIsTouchCase) { - // - aWES.AddStartElement(aSS); - aSS.Reverse(); - aWES.AddStartElement(aSS); - // - } - else { - BOP_BuilderTools::OrientSectionEdgeOnF1 - (myFace, aF2Adj, iRankF1, myOperation, aSS); - aWES.AddStartElement(aSS); - } - // - if ((myOperation==BOP_CUT && iRankF1==1)|| - (myOperation==BOP_CUT21 && iRankF1==2)) { - aWES.RemoveEdgeFromWES(aSpEF2); - TopoDS_Edge aSpEF2R=TopoDS::Edge(aSpEF2.Reversed()); - aWES.RemoveEdgeFromWES(aSpEF2R); - } - } - else {//myOperation!=BOP_FUSE at aSt==TopAbs_OUT - bIsTouchCase=BOPTools_Tools3D::IsTouchCase(aSS, myFace, aF2Adj); - if (!bIsTouchCase) { - aWES.RemoveEdgeFromWES(aSpEF2); - TopoDS_Edge aSpEF2R=TopoDS::Edge(aSpEF2.Reversed()); - aWES.RemoveEdgeFromWES(aSpEF2R); - - BOP_BuilderTools::OrientSectionEdgeOnF1 - (myFace, aF2Adj, iRankF1, myOperation, aSS); - aWES.AddStartElement(aSS); - } - } - } - } - } - } -} -//======================================================================= -// function: AddPartsEFNonSDSo -// purpose: -//======================================================================= - void BOP_ShellSolid::AddPartsEFNonSDSo (const Standard_Integer nF1, - const Standard_Integer iFF, - const TopTools_IndexedDataMapOfShapeListOfShape& aMEFObj, - const TopTools_IndexedDataMapOfShapeListOfShape& aMEFTool, - const TColStd_IndexedMapOfInteger& aFFIndicesMap, - TopTools_IndexedMapOfShape& anEMap, - BOP_WireEdgeSet& aWES) -{ - const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); - BOPTools_InterferencePool* pIntrPool=(BOPTools_InterferencePool*)&myDSFiller->InterfPool(); - BOPTools_CArray1OfSSInterference& aFFs=pIntrPool->SSInterferences(); - - const BOPTools_PaveFiller& aPF=myDSFiller->PaveFiller(); - BOPTools_PaveFiller* pPaveFiller=(BOPTools_PaveFiller*)&aPF; - BOPTools_CommonBlockPool& aCBPool=pPaveFiller->ChangeCommonBlockPool(); - // - Standard_Integer iRankF1, iRankF2, nF2, nSpEF2, nEF2, nFace; - Standard_Boolean bIsKeepTwice, bIsAdjExists, bIsTouchCase; - TopExp_Explorer anExp2, anExp1; - // - BOPTools_SSInterference& aFF=aFFs(iFF); - nF2=aFF.OppositeIndex(nF1); - - const TopoDS_Face& aF1=TopoDS::Face(aDS.Shape(nF1)); - const TopoDS_Face& aF2=TopoDS::Face(aDS.Shape(nF2)); - - iRankF1=aDS.Rank(nF1); - iRankF2=aDS.Rank(nF2); - - const TopTools_IndexedDataMapOfShapeListOfShape& aMEF=(iRankF2==1) ? aMEFObj : aMEFTool; - // - // EF2\F1 Processing - anExp2.Init (aF2, TopAbs_EDGE); - for (; anExp2.More(); anExp2.Next()) { - const TopoDS_Edge& aEF2= TopoDS::Edge(anExp2.Current()); - - nEF2=aDS.ShapeIndex(aEF2, iRankF2); - - BOPTools_ListOfCommonBlock& aLCB=aCBPool(aDS.RefEdge(nEF2)); - - BOPTools_ListIteratorOfListOfCommonBlock anItCB(aLCB); - for (; anItCB.More(); anItCB.Next()) { - BOPTools_CommonBlock& aCB=anItCB.Value(); - nFace=aCB.Face(); - - if (nFace==nF1) { - BOPTools_PaveBlock& aPB=aCB.PaveBlock1(nEF2); - - nSpEF2=aPB.Edge(); - const TopoDS_Shape& aSpEF2=aDS.Shape(nSpEF2); - - if (anEMap.Contains(aSpEF2)) { - continue;// next CB - } - anEMap.Add(aSpEF2); - - TopoDS_Edge aSS=TopoDS::Edge(aSpEF2); - // - TopoDS_Face aF2Adj; - bIsAdjExists=BOPTools_Tools3D::GetAdjacentFace(aF2, aEF2, aMEF, aF2Adj); - - if (bIsAdjExists) { - // - - Standard_Integer nF2Adj; - - nF2Adj=aDS.ShapeIndex(aF2Adj, iRankF2); - - Standard_Boolean bIsSameDomainFaceWithF1; - - bIsSameDomainFaceWithF1= - BOP_BuilderTools::IsSameDomainFaceWithF1(nF1, nF2Adj, aFFIndicesMap, aFFs); - - if (bIsSameDomainFaceWithF1) { - continue; - } - // - bIsKeepTwice=BOPTools_Tools3D::IsKeepTwice(aF1, aF2, aF2Adj, aSS); - if (bIsKeepTwice) { - aWES.AddStartElement(aSS); - aSS.Reverse(); - aWES.AddStartElement(aSS); - } - else { - aSS.Orientation(TopAbs_FORWARD); - BOP_BuilderTools::OrientSectionEdgeOnF1 - (myFace, aF2, iRankF1, myOperation, aSS); - - aWES.AddStartElement(aSS); - } - } - else { - // No Adjacents - bIsTouchCase=BOPTools_Tools3D::IsTouchCase(aSS, myFace, aF2); - if (bIsTouchCase) { - aWES.AddStartElement(aSS); - aSS.Reverse(); - aWES.AddStartElement(aSS); - } - else { - aSS.Orientation(TopAbs_FORWARD); - BOP_BuilderTools::OrientSectionEdgeOnF1 - (myFace, aF2, iRankF1, myOperation, aSS); - - aWES.AddStartElement(aSS); - } - } - } //if (nFace==nF1) { - } // next CB on nEF2 - } -} - -// -//======================================================================= -// function: AddPartsEENonSDSo -// purpose: -//======================================================================= - void BOP_ShellSolid::AddPartsEENonSDSo (const Standard_Integer nF1, - const Standard_Integer iFF, - const TopTools_IndexedDataMapOfShapeListOfShape& aMEFObj, - const TopTools_IndexedDataMapOfShapeListOfShape& aMEFTool, - const TColStd_IndexedMapOfInteger& aFFIndicesMap, - TopTools_IndexedMapOfShape& anEMap, - BOP_WireEdgeSet& aWES) -{ - const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); - BOPTools_InterferencePool* pIntrPool=(BOPTools_InterferencePool*)&myDSFiller->InterfPool(); - BOPTools_CArray1OfSSInterference& aFFs=pIntrPool->SSInterferences(); - - const BOPTools_PaveFiller& aPF=myDSFiller->PaveFiller(); - BOPTools_PaveFiller* pPaveFiller=(BOPTools_PaveFiller*)&aPF; - BOPTools_CommonBlockPool& aCBPool=pPaveFiller->ChangeCommonBlockPool(); - // - const Handle(IntTools_Context)& aContext=pPaveFiller->Context(); - // - Standard_Integer nEF1, nF2, nSpF1, nSpF2, nEF2, nSpTaken, iRankF1, nF2x, iRankF2; - TopAbs_Orientation anOrEF1, anOrEF2; - TopExp_Explorer anExp; - TopTools_IndexedMapOfShape aM; - TColStd_ListOfInteger aSplitsOnF1; - TColStd_ListIteratorOfListOfInteger anIt; - TColStd_IndexedMapOfInteger aMSplitsOnF1; - // - // nF1 - const TopoDS_Face& aF1=TopoDS::Face(aDS.Shape(nF1)); - iRankF1=aDS.Rank(nF1); - const TopTools_IndexedDataMapOfShapeListOfShape& aMEFx=(iRankF1==1) ? aMEFTool : aMEFObj; - // - // nF2 - BOPTools_SSInterference& aFF=aFFs(iFF); - nF2=aFF.OppositeIndex(nF1); - - iRankF2=aDS.Rank(nF2); - - const TopoDS_Face& aF2=TopoDS::Face(aDS.Shape(nF2)); - // - pPaveFiller->SplitsOnFace(0, nF1, nF2, aSplitsOnF1); - anIt.Initialize(aSplitsOnF1); - for (; anIt.More(); anIt.Next()) { - nSpF1=anIt.Value(); - aMSplitsOnF1.Add(nSpF1); - } - // - anExp.Init(myFace, TopAbs_EDGE); - for (; anExp.More(); anExp.Next()) { - const TopoDS_Edge& anEF1=TopoDS::Edge(anExp.Current()); - anOrEF1=anEF1.Orientation(); - - nEF1=aDS.ShapeIndex(anEF1, iRankF1); - - BOPTools_ListOfCommonBlock& aLCB=aCBPool(aDS.RefEdge(nEF1)); - - BOPTools_ListIteratorOfListOfCommonBlock anItCB(aLCB); - for (; anItCB.More(); anItCB.Next()) { - BOPTools_CommonBlock& aCB=anItCB.Value(); - - BOPTools_PaveBlock& aPBEF1=aCB.PaveBlock1(nEF1); - BOPTools_PaveBlock& aPBEF2=aCB.PaveBlock2(nEF1); - - nF2x=aCB.Face(); - if (nF2x) { - continue; - } - // Splits that are ON other Edge from other Face - nSpF1=aPBEF1.Edge(); - // - if (!aMSplitsOnF1.Contains(nSpF1)) { - continue;// next CB - } - // - nSpF2=aPBEF2.Edge(); - nEF2=aPBEF2.OriginalEdge(); - // - const TopoDS_Edge& aEF2=TopoDS::Edge(aDS.Shape(nEF2)); - TopoDS_Face aF2Adj; - - Standard_Boolean bIsAdjExists; - bIsAdjExists=BOPTools_Tools3D::GetAdjacentFace(aF2, aEF2, aMEFx, aF2Adj); - - if (bIsAdjExists) { - Standard_Boolean bIsSameDomainFaceWithF1; - Standard_Integer nF2Adj; - - nF2Adj=aDS.ShapeIndex(aF2Adj, iRankF2); - - bIsSameDomainFaceWithF1= - BOP_BuilderTools::IsSameDomainFaceWithF1(nF1, nF2Adj, aFFIndicesMap, aFFs); - - if (bIsSameDomainFaceWithF1) { - continue; - } - } - // - const TopoDS_Shape& aSp1=aDS.Shape(nSpF1); - const TopoDS_Shape& aSp2=aDS.Shape(nSpF2); - - // - if (anEMap.Contains(aSp1)) { - continue;// next CB - } - anEMap.Add(aSp1); - // - if (anEMap.Contains(aSp2)) { - continue;// next CB - } - anEMap.Add(aSp2); - // - - // Pave Block from which new edge will be taken - const BOPTools_PaveBlock& aPB=aCB.PaveBlock1(); - nSpTaken=aPB.Edge(); - // - //iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii - // Internal edges treatment - { - Standard_Boolean bInternal1, bInternal2; - - const TopoDS_Edge& anEF2=TopoDS::Edge(aDS.Shape(nEF2)); - anOrEF2=anEF2.Orientation(); - - const TopTools_IndexedDataMapOfShapeListOfShape& aMEF= - (iRankF1==1) ? aMEFTool : aMEFObj; - - bInternal1=(anOrEF1==TopAbs_INTERNAL); - bInternal2=(anOrEF2==TopAbs_INTERNAL); - - if (bInternal1 || bInternal2) { - Standard_Integer nSpNotTaken; - // - nSpNotTaken=(nSpF1==nSpTaken) ? nSpF2 : nSpF1; - - TopoDS_Edge aSS =TopoDS::Edge(aDS.Shape(nSpTaken)); - TopoDS_Edge aSSx=TopoDS::Edge(aDS.Shape(nSpNotTaken)); - // a. Both parts are interlal edges - if (bInternal1 && bInternal2) { - BothInternals(aSS, myFace, aF2, iRankF1, myOperation, aWES); - } - // b. The first is internal, the second is not - else if (bInternal1 && !bInternal2) { - FirstInternal(aSS, myFace, aF2, anEF2, aSSx, - iRankF1, myOperation, aMEF, aWES, aContext); - } - - // c. The first is no1 internal , the second is internal - else if (!bInternal1 && bInternal2) { - SecondInternal (aSS, aF1, aF2, anEF1, aSSx, - anOrEF1, iRankF1, myOperation, aWES, aContext); - } - continue; - } - } - // - //iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii - // - Standard_Boolean bIsON2DToKeep, bIsON2DToKeepSimm=Standard_False; - { - const TopoDS_Edge& anEFx=TopoDS::Edge(aDS.Shape(nEF2)); - TopoDS_Edge aSpFx=TopoDS::Edge(aDS.Shape(nSpF2)); - // - // anEF1 - TopAbs_State aST1; - BOPTools_Tools3D::GetPlanes(aSpFx, anEFx, aMEFx, anEF1, aF1, aST1, aContext); - bIsON2DToKeep= - BOP_BuilderTools::IsPartOn2dToKeep(aST1, iRankF1, myOperation); - - if (BRep_Tool::IsClosed(anEF1, aF1)) { - TopoDS_Edge anEF1Seam; - BOPTools_Tools3D::GetSeam (aF1, anEF1, anEF1Seam); - // - if (!anEF1Seam.IsNull()) { - TopAbs_State aSTSeam; - - BOPTools_Tools3D::GetPlanes(aSpFx, anEFx, aMEFx, anEF1Seam, aF1, aSTSeam, aContext); - bIsON2DToKeepSimm= - BOP_BuilderTools::IsPartOn2dToKeep(aSTSeam, iRankF1, myOperation); - } - bIsON2DToKeep=bIsON2DToKeep || bIsON2DToKeepSimm; - } - } - // - - if (nSpTaken==nSpF1) { - // Common Edge is from nEF1 - - TopoDS_Edge aSS=TopoDS::Edge(aSp1); - aSS.Orientation(anOrEF1); - // - if (bIsON2DToKeep) { - aWES.AddStartElement (aSS); - } - } - else /*if (nSpTaken==nSpF2)*/ { - // Common Edge is from nEF2 - TopoDS_Edge aSpF1=TopoDS::Edge(aSp1); - aSpF1.Orientation(anOrEF1); - - TopoDS_Edge aSpF2=TopoDS::Edge(aSp2); - - Standard_Boolean bToReverse= BOPTools_Tools3D::IsSplitToReverse1 (aSpF1, aSpF2, aContext); - if (bToReverse) { - aSpF2.Reverse(); - } - // - if (BRep_Tool::IsClosed(aSpF1, myFace)) { - if (aM.Contains(aSpF2)){ - continue; - } - aM.Add(aSpF2); - // - if (bIsON2DToKeep) { - if (!BRep_Tool::IsClosed(aSpF2, myFace)) { - BOPTools_Tools3D::DoSplitSEAMOnFace (aSpF2, myFace); - } - - aWES.AddStartElement (aSpF2); - aSpF2.Reverse(); - aWES.AddStartElement (aSpF2); - } - continue; - } - // - if (bIsON2DToKeep) { - aWES.AddStartElement (aSpF2); - } - - }// else /*if (nSpTaken==nSpF2)*/ { - }// for (; anItCB.More(); anItCB.Next()) - }// for (; anExp.More(); anExp.Next()) -} - -//======================================================================= -// function: AddPartsEF -// purpose: -//======================================================================= -void AddPartsEF (const TopoDS_Edge& aSSin, - const TopoDS_Edge& aEF2, - const TopoDS_Face& aF2, - const TopoDS_Face& myFace, - const Standard_Integer iRankF1, - const BOP_Operation myOperation, - const TopTools_IndexedDataMapOfShapeListOfShape& aMEF, - BOP_WireEdgeSet& aWES) -{ - Standard_Boolean bIsKeepTwice, bIsAdjExists, bIsTouchCase; - TopoDS_Face aF2Adj; - TopoDS_Edge aSS=aSSin; - // - bIsAdjExists=BOPTools_Tools3D::GetAdjacentFace(aF2, aEF2, aMEF, aF2Adj); - // - if (bIsAdjExists) { - bIsKeepTwice=BOPTools_Tools3D::IsKeepTwice(myFace, aF2, aF2Adj, aSS); - if (bIsKeepTwice) { - aWES.AddStartElement(aSS); - aSS.Reverse(); - aWES.AddStartElement(aSS); - } - else { - aSS.Orientation(TopAbs_FORWARD); - BOP_BuilderTools::OrientSectionEdgeOnF1 (myFace, aF2, iRankF1, myOperation, aSS); - aWES.AddStartElement(aSS); - } - } - else { - // No Adjacents - bIsTouchCase=BOPTools_Tools3D::IsTouchCase(aSS, myFace, aF2); - // - if (bIsTouchCase) { - aWES.AddStartElement(aSS); - aSS.Reverse(); - aWES.AddStartElement(aSS); - } - else { - aSS.Orientation(TopAbs_FORWARD); - BOP_BuilderTools::OrientSectionEdgeOnF1 (myFace, aF2, iRankF1, myOperation, aSS); - aWES.AddStartElement(aSS); - } - } -} - -//======================================================================= -// function: AddPartEF1INF2 -// purpose: -//======================================================================= -void AddPartEF1INF2 (TopoDS_Edge& aSS, - const TopoDS_Face& myFace, - const TopoDS_Face& aF2, - const Standard_Integer iRankF1, - const BOP_Operation myOperation, - BOP_WireEdgeSet& aWES) -{ - Standard_Boolean bIsTouchCase; - - aSS.Orientation(TopAbs_FORWARD); - - bIsTouchCase=BOPTools_Tools3D::IsTouchCase(aSS, myFace, aF2); - - if (bIsTouchCase) { - aWES.AddStartElement (aSS); - aSS.Reverse(); - aWES.AddStartElement (aSS); - } - else { - BOP_BuilderTools::OrientSectionEdgeOnF1(myFace, aF2, iRankF1, myOperation, aSS); - aWES.AddStartElement (aSS); - } -} -//======================================================================= -// function: BothInternals -// purpose: -//======================================================================= -void BothInternals (TopoDS_Edge& aSS, - const TopoDS_Face& myFace, - const TopoDS_Face& aF2, - const Standard_Integer iRankF1, - const BOP_Operation myOperation, - BOP_WireEdgeSet& aWES) -{ - Standard_Boolean bIsTouchCase; - // - aSS.Orientation(TopAbs_FORWARD); - // - bIsTouchCase=BOPTools_Tools3D::IsTouchCase(aSS, myFace, aF2); - // - if (bIsTouchCase) { - aWES.AddStartElement (aSS); - aSS.Reverse(); - aWES.AddStartElement (aSS); - } - else { - BOP_BuilderTools::OrientSectionEdgeOnF1(myFace, aF2, iRankF1, myOperation, aSS); - aWES.AddStartElement (aSS); - } -} -//======================================================================= -// function: FirstInternal -// purpose: -//======================================================================= -void FirstInternal(TopoDS_Edge& aSS, - const TopoDS_Face& myFace, - const TopoDS_Face& aF2, - const TopoDS_Edge& anEF2, - TopoDS_Edge& aSSx, - const Standard_Integer iRankF1, - const BOP_Operation myOperation, - const TopTools_IndexedDataMapOfShapeListOfShape& aMEF, - BOP_WireEdgeSet& aWES, - const Handle(IntTools_Context)& aContext) -{ - Standard_Boolean bToReverse; - TopAbs_Orientation anOrEF2; - TopoDS_Edge aEF2; - - BOPTools_Tools3D::OrientEdgeOnFace (anEF2, aF2, aEF2); - anOrEF2=aEF2.Orientation(); - - if (aSS.Orientation()==TopAbs_INTERNAL) { - aSS.Orientation(TopAbs_FORWARD); - aSSx.Orientation(anOrEF2); - bToReverse=BOPTools_Tools3D::IsSplitToReverse1 (aSSx, aSS, aContext); - if(bToReverse){ - aSS.Reverse(); - } - } - else { - aSS.Orientation(anOrEF2); - } - - AddPartsEF(aSS, aEF2, aF2, myFace, iRankF1, myOperation, aMEF, aWES); -} - -//======================================================================= -// function: SecondInternal -// purpose: -//======================================================================= -void SecondInternal(TopoDS_Edge& aSS, - const TopoDS_Face& aF1, - const TopoDS_Face& aF2, - const TopoDS_Edge& anEF1, - TopoDS_Edge& aSSx, - const TopAbs_Orientation anOrEF1, - const Standard_Integer iRankF1, - const BOP_Operation myOperation, - BOP_WireEdgeSet& aWES, - const Handle(IntTools_Context)& aContext) -{ - Standard_Boolean bToReverse, bIsToKeep; - if (aSS.Orientation()==TopAbs_INTERNAL) { - aSS.Orientation(TopAbs_FORWARD); - aSSx.Orientation(anOrEF1); - bToReverse=BOPTools_Tools3D::IsSplitToReverse1 (aSSx, aSS, aContext); - if(bToReverse){ - aSS.Reverse(); - } - } - else { - aSS.Orientation(anOrEF1); - } - // - TopAbs_State aState1= - BOPTools_Tools3D::GetStatePartIN2D(aSS, anEF1, aF1, aF2, aContext); - // - bIsToKeep= - BOP_BuilderTools::IsPartIN2DToKeep(aState1, iRankF1, myOperation); - // - if (bIsToKeep) { - aWES.AddStartElement (aSS); - } -} - -//======================================================================= -// function: AddPartsEESDSo -// purpose: -//======================================================================= - void BOP_ShellSolid::AddPartsEESDSo (const Standard_Integer nF1, - const Standard_Integer iFF, - const TopTools_IndexedDataMapOfShapeListOfShape& aMEFObj, - const TopTools_IndexedDataMapOfShapeListOfShape& aMEFTool, - BOP_WireEdgeSet& aWES) -{ - if (myOperation==BOP_FUSE) { - return; - } - // - const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); - BOPTools_InterferencePool* pIntrPool=(BOPTools_InterferencePool*)&myDSFiller->InterfPool(); - BOPTools_CArray1OfSSInterference& aFFs=pIntrPool->SSInterferences(); - - const BOPTools_PaveFiller& aPF=myDSFiller->PaveFiller(); - BOPTools_PaveFiller* pPaveFiller=(BOPTools_PaveFiller*)&aPF; - BOPTools_CommonBlockPool& aCBPool=pPaveFiller->ChangeCommonBlockPool(); - // - const Handle(IntTools_Context)& aContext=pPaveFiller->Context(); - // - Standard_Integer nEF1, nF2, nSpF1, nSpF2, nEF2, nSpTaken, iRankF1, nF2x, iRankF2, iSenseFlag; - TopAbs_Orientation anOrEF1; - TopExp_Explorer anExp; - TopTools_IndexedMapOfShape aM; - TColStd_ListOfInteger aSplitsOnF1; - TColStd_ListIteratorOfListOfInteger anIt; - TColStd_IndexedMapOfInteger aMSplitsOnF1; - // - // nF1 - const TopoDS_Face& aF1=TopoDS::Face(aDS.Shape(nF1)); - iRankF1=aDS.Rank(nF1); - const TopTools_IndexedDataMapOfShapeListOfShape& aMEFx=(iRankF1==1) ? aMEFTool : aMEFObj; - // - // nF2 - BOPTools_SSInterference& aFF=aFFs(iFF); - nF2=aFF.OppositeIndex(nF1); - iSenseFlag=aFF.SenseFlag(); - // - if (iSenseFlag==1) { - return ; - } - // - iRankF2=aDS.Rank(nF2); - // - pPaveFiller->SplitsOnFace(0, nF1, nF2, aSplitsOnF1); - // - anIt.Initialize(aSplitsOnF1); - for (; anIt.More(); anIt.Next()) { - nSpF1=anIt.Value(); - aMSplitsOnF1.Add(nSpF1); - } - // - anExp.Init(myFace, TopAbs_EDGE); - for (; anExp.More(); anExp.Next()) { - const TopoDS_Edge& anEF1=TopoDS::Edge(anExp.Current()); - anOrEF1=anEF1.Orientation(); - - nEF1=aDS.ShapeIndex(anEF1, iRankF1); - - BOPTools_ListOfCommonBlock& aLCB=aCBPool(aDS.RefEdge(nEF1)); - - BOPTools_ListIteratorOfListOfCommonBlock anItCB(aLCB); - for (; anItCB.More(); anItCB.Next()) { - BOPTools_CommonBlock& aCB=anItCB.Value(); - - BOPTools_PaveBlock& aPBEF1=aCB.PaveBlock1(nEF1); - BOPTools_PaveBlock& aPBEF2=aCB.PaveBlock2(nEF1); - - nF2x=aCB.Face(); - if (nF2x) { - continue; - } - // Splits that are ON other Edge from other Face - nSpF1=aPBEF1.Edge(); - // - if (!aMSplitsOnF1.Contains(nSpF1)) { - continue;// next CB - } - // - nSpF2=aPBEF2.Edge(); - nEF2=aPBEF2.OriginalEdge(); - // - const TopoDS_Shape& aSp1=aDS.Shape(nSpF1); - const TopoDS_Shape& aSp2=aDS.Shape(nSpF2); - // Pave Block from which new edge will be taken - const BOPTools_PaveBlock& aPB=aCB.PaveBlock1(); - nSpTaken=aPB.Edge(); - // - Standard_Boolean bIsON2DToKeep; - { - const TopoDS_Edge& anEFx=TopoDS::Edge(aDS.Shape(nEF2)); - TopoDS_Edge aSpFx=TopoDS::Edge(aDS.Shape(nSpF2)); - // - // anEF1 - TopAbs_State aST1; - BOPTools_Tools3D::GetPlanes(aSpFx, anEFx, aMEFx, anEF1, aF1, aST1, aContext); - - bIsON2DToKeep=BOP_BuilderTools::IsPartOn2dToKeep(aST1, iRankF1, myOperation); - if (bIsON2DToKeep) { - bIsON2DToKeep=!bIsON2DToKeep; - if (aST1==TopAbs_IN) { - if ( - (iRankF1==2 && (myOperation==BOP_COMMON || myOperation==BOP_CUT)) || - (iRankF1==1 && (myOperation==BOP_COMMON || myOperation==BOP_CUT21)) - ){ - bIsON2DToKeep=!bIsON2DToKeep; - } - } - } - } - if (bIsON2DToKeep) { - // - if (nSpTaken==nSpF1) { - // Common Edge is from nEF1 - TopoDS_Edge aSS=TopoDS::Edge(aSp1); - aSS.Orientation(anOrEF1); - // - aWES.AddStartElement (aSS); - } - else /*if (nSpTaken==nSpF2)*/ { - // Common Edge is from nEF2 - TopoDS_Edge aSpF1=TopoDS::Edge(aSp1); - aSpF1.Orientation(anOrEF1); - - TopoDS_Edge aSpF2=TopoDS::Edge(aSp2); - - Standard_Boolean bToReverse= BOPTools_Tools3D::IsSplitToReverse1 (aSpF1, aSpF2, aContext); - if (bToReverse) { - aSpF2.Reverse(); - } - // - if (BRep_Tool::IsClosed(aSpF1, myFace)) { - if (aM.Contains(aSpF2)){ - continue; - } - aM.Add(aSpF2); - // - - if (!BRep_Tool::IsClosed(aSpF2, myFace)) { - BOPTools_Tools3D::DoSplitSEAMOnFace (aSpF2, myFace); - } - - aWES.AddStartElement (aSpF2); - aSpF2.Reverse(); - aWES.AddStartElement (aSpF2); - - continue; - } - // - aWES.AddStartElement (aSpF2); - }// else /*if (nSpTaken==nSpF2)*/ { - }// if (bIsON2DToKeep) - }// for (; anItCB.More(); anItCB.Next()) - }// for (; anExp.More(); anExp.Next()) -} diff --git a/src/BOP/BOP_ShellSolid_3.cxx b/src/BOP/BOP_ShellSolid_3.cxx deleted file mode 100755 index e9880a3ad2..0000000000 --- a/src/BOP/BOP_ShellSolid_3.cxx +++ /dev/null @@ -1,551 +0,0 @@ -// Created on: 2004-06-09 -// Created by: Mikhail KLOKOV -// Copyright (c) 2004-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include - -#include - -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include -#include - -#include - -#include -#include - -// ===================================================================================================================== -// function: SplitFace -// purpose: -// ===================================================================================================================== -Standard_Boolean BOP_ShellSolid::SplitFace(const Standard_Integer theFaceIndex, - TopTools_DataMapOfShapeInteger& theMapOfEdgeIndex, - TopTools_ListOfShape& theListOfFace) const -{ - theListOfFace.Clear(); - - const BooleanOperations_ShapesDataStructure& aDS = myDSFiller->DS(); - const BOPTools_PaveFiller& aPaveFiller = myDSFiller->PaveFiller(); - BOPTools_PaveFiller* pPaveFiller = (BOPTools_PaveFiller*)&aPaveFiller; - BOPTools_CommonBlockPool& aCBPool = pPaveFiller->ChangeCommonBlockPool(); - const BOPTools_SplitShapesPool& aSplitShapesPool = aPaveFiller.SplitShapesPool(); - - BOPTools_InterferencePool* pIntrPool= - (BOPTools_InterferencePool*)&myDSFiller->InterfPool(); - - BOPTools_CArray1OfSSInterference& aFFs = pIntrPool->SSInterferences(); - - TopoDS_Face aFace = TopoDS::Face(aDS.Shape(theFaceIndex)); - aFace.Orientation(TopAbs_FORWARD); - - BOP_WireEdgeSet aWES (aFace); - - - Standard_Integer i = 0; - - for(i = 1; i <= aFFs.Length(); i++) { - BOPTools_SSInterference& aFF = aFFs(i); - - if((aFF.Index1() != theFaceIndex) && (aFF.Index2() != theFaceIndex)) - continue; - - BOPTools_SequenceOfCurves& aSC = aFF.Curves(); - Standard_Integer aNbCurves = aSC.Length(); - Standard_Integer j = 0; - - for(j = 1; j <= aNbCurves; j++) { - const BOPTools_Curve& aBC = aSC(j); - const BOPTools_ListOfPaveBlock& aLPB = aBC.NewPaveBlocks(); - BOPTools_ListIteratorOfListOfPaveBlock anIt(aLPB); - - for (; anIt.More(); anIt.Next()) { - const BOPTools_PaveBlock& aPB = anIt.Value(); - Standard_Integer nE = aPB.Edge(); - const TopoDS_Shape& aE = aDS.Shape(nE); - TopoDS_Edge aES = TopoDS::Edge(aE); - aWES.AddStartElement(aES); - aES.Reverse(); - aWES.AddStartElement(aES); - - if(!theMapOfEdgeIndex.IsBound(aES)) { - theMapOfEdgeIndex.Bind(aES, nE); - } - } - } - } - - Standard_Integer aFaceRank = aDS.Rank(theFaceIndex); - TopExp_Explorer anExpE(aFace, TopAbs_EDGE); - - for(; anExpE.More(); anExpE.Next()) { - const TopoDS_Shape& anOldEdge = anExpE.Current(); - TopAbs_Orientation anOr = anOldEdge.Orientation(); - Standard_Integer anEdgeIndex = aDS.ShapeIndex(anOldEdge, aFaceRank); - - if(anEdgeIndex <= 0) - continue; - - const BOPTools_ListOfPaveBlock& aLPB = aSplitShapesPool(aDS.RefEdge(anEdgeIndex)); - - if(aLPB.IsEmpty()) { - TopoDS_Edge aSS = TopoDS::Edge(anOldEdge); - // - aWES.AddStartElement (aSS); - - if(!theMapOfEdgeIndex.IsBound(aSS)) { - theMapOfEdgeIndex.Bind(aSS, anEdgeIndex); - } - } - else { - BOPTools_ListIteratorOfListOfPaveBlock aPBIt(aLPB); - - for (; aPBIt.More(); aPBIt.Next()) { - const BOPTools_PaveBlock& aPB = aPBIt.Value(); - Standard_Integer nSp = aPB.Edge(); - Standard_Integer nSpToAdd = nSp; - - BooleanOperations_StateOfShape aState = aDS.GetState(nSp); - Standard_Boolean bAddToWes = ((aState == BooleanOperations_IN) || - (aState == BooleanOperations_OUT)); - - if(aState == BooleanOperations_ON) { - bAddToWes = Standard_True; - - BOPTools_ListOfCommonBlock& aLCB = aCBPool(aDS.RefEdge(anEdgeIndex)); - - BOPTools_ListIteratorOfListOfCommonBlock anItCB(aLCB); - - for (; anItCB.More(); anItCB.Next()) { - BOPTools_CommonBlock& aCB = anItCB.Value(); - Standard_Integer iCBFace = aCB.Face(); - - if(iCBFace == 0) { - BOPTools_PaveBlock& aPBEF1 = aCB.PaveBlock1(anEdgeIndex); - BOPTools_PaveBlock& aPBEF2 = aCB.PaveBlock2(anEdgeIndex); - - const BOPTools_PaveBlock& aPB1 = aCB.PaveBlock1(); - Standard_Integer nSpTaken = aPB1.Edge(); - - if((nSp == aPBEF1.Edge()) || (nSp == aPBEF2.Edge())) { - nSpToAdd = nSpTaken; - break; - } - } - } - } - - if(bAddToWes) { - const TopoDS_Shape& aSplit = aDS.Shape(nSpToAdd); - TopoDS_Edge aSS=TopoDS::Edge(aSplit); - aSS.Orientation(anOr); - - if(nSpToAdd != nSp) { - const TopoDS_Shape& aSp1=aDS.Shape(nSp); - TopoDS_Edge aSpF1=TopoDS::Edge(aSp1); - aSpF1.Orientation(anOr); - - const TopoDS_Shape& aSp2 = aDS.Shape(nSpToAdd); - TopoDS_Edge aSpF2 = TopoDS::Edge(aSp2); - - Standard_Boolean bToReverse= - BOPTools_Tools3D::IsSplitToReverse1 (aSpF1, aSpF2, pPaveFiller->Context()); - - if (bToReverse) { - aSpF2.Reverse(); - } - - if (BRep_Tool::IsClosed(TopoDS::Edge(anOldEdge), aFace) && - !BRep_Tool::IsClosed(aSpF2, aFace)) { - Standard_Boolean bIsReversed = Standard_False; - - if(!BOPTools_Tools3D::DoSplitSEAMOnFace(aSpF2, aSpF1, aFace, bIsReversed)) - BOPTools_Tools3D::DoSplitSEAMOnFace (aSpF2, aFace); - } - - - aSS = aSpF2; - } - // - aWES.AddStartElement (aSS); - - if(!theMapOfEdgeIndex.IsBound(aSS)) { - theMapOfEdgeIndex.Bind(aSS, nSpToAdd); - } - } - } - } - } - - BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger aFFMap; - BOP_BuilderTools::DoMap(aFFs, aFFMap); - - Standard_Integer aNb = aFFMap.Extent(); - - for (i = 1; i <= aNb; i++) { - Standard_Integer nF1 = aFFMap.FindKey(i); - - if(nF1 != theFaceIndex) - continue; - - const TColStd_IndexedMapOfInteger& aFFIndicesMap=aFFMap.FindFromIndex(i); - Standard_Integer aNbj = aFFIndicesMap.Extent(); - Standard_Integer j = 0; - - for (j = 1; j <= aNbj; j++) { - Standard_Integer iFF = aFFIndicesMap(j); - BOPTools_SSInterference& aFF = aFFs(iFF); - // - Standard_Integer nF2 = aFF.OppositeIndex(nF1); - - if(nF2 <= 0) - continue; - // - Standard_Integer iRankF2 = aDS.Rank(nF2); - TopoDS_Shape aFace2 = aDS.Shape(nF2); - - anExpE.Init(aFace2, TopAbs_EDGE); - - for(; anExpE.More(); anExpE.Next()) { - Standard_Integer anEdgeIndex2 = aDS.ShapeIndex(anExpE.Current(), iRankF2); - - if(anEdgeIndex2 <= 0) - continue; - - BOPTools_ListOfCommonBlock& aLCB = aCBPool(aDS.RefEdge(anEdgeIndex2)); - - BOPTools_ListIteratorOfListOfCommonBlock anItCB(aLCB); - - for (; anItCB.More(); anItCB.Next()) { - BOPTools_CommonBlock& aCB = anItCB.Value(); - Standard_Integer iCBFace = aCB.Face(); - - if(iCBFace == theFaceIndex) { - BOPTools_PaveBlock& aPB = aCB.PaveBlock1(anEdgeIndex2); - Standard_Integer nSpEF2 = aPB.Edge(); - const TopoDS_Shape& aSpEF2 = aDS.Shape(nSpEF2); - - TopoDS_Edge aEF = TopoDS::Edge(aSpEF2); - - if(!theMapOfEdgeIndex.IsBound(aEF)) { - theMapOfEdgeIndex.Bind(aEF, nSpEF2); - } - - if(aEF.Orientation() == TopAbs_INTERNAL) { - aWES.AddStartElement(aEF); - } - else { - aEF.Orientation(TopAbs_FORWARD); - aWES.AddStartElement(aEF); - aEF.Reverse(); - aWES.AddStartElement(aEF); - } - } - } - } - } - } - - // process internal edges - BOP_WireEdgeSet aFilteredWES (aFace); - TopoDS_Compound aComp; - BRep_Builder aBB; - aBB.MakeCompound(aComp); - - for(aWES.InitStartElements(); aWES.MoreStartElements(); aWES.NextStartElement()) { - aBB.Add(aComp, aWES.StartElement()); - } - TopTools_IndexedDataMapOfShapeListOfShape aMapVE; - TopExp::MapShapesAndAncestors(aComp, TopAbs_VERTEX, TopAbs_EDGE, aMapVE); - - for(aWES.InitStartElements(); aWES.MoreStartElements(); aWES.NextStartElement()) { - const TopoDS_Shape& anEdge = aWES.StartElement(); - - if(anEdge.Orientation() != TopAbs_INTERNAL) { - aFilteredWES.AddStartElement(anEdge); - } - else { - TopoDS_Vertex aV1, aV2, aV; - - Standard_Boolean bFound1 = Standard_False; - Standard_Boolean bFound2 = Standard_False; - Standard_Boolean bIsClosed = Standard_False; - Standard_Integer vcounter = 0; - TopTools_IndexedMapOfShape aMapOfEInternal; - aMapOfEInternal.Add(anEdge); - - TopExp::Vertices(TopoDS::Edge(anEdge), aV1, aV2); - - if(!aV1.IsNull() && aV1.IsSame(aV2)) { - bIsClosed = Standard_True; - } - else { - TopExp_Explorer anExpV(anEdge, TopAbs_VERTEX); - - for(; anExpV.More(); anExpV.Next(), vcounter++) { - aV = TopoDS::Vertex(anExpV.Current()); - TopTools_MapOfShape aMapOfV; - - while(!aV.IsNull()) { - if(!aMapVE.Contains(aV)) - aV.Nullify(); - - if(aMapOfV.Contains(aV)) - break; - aMapOfV.Add(aV); - const TopTools_ListOfShape& aListOfE = aMapVE.FindFromKey(aV); - TopTools_ListIteratorOfListOfShape anIt(aListOfE); - Standard_Boolean bFound = Standard_False; - aV.Nullify(); - - for(; anIt.More(); anIt.Next()) { - const TopoDS_Shape& anAdjE = anIt.Value(); - - if(anEdge.IsSame(anAdjE)) - continue; - - if(anAdjE.Orientation() != TopAbs_INTERNAL) { - if(vcounter == 0) - bFound1 = Standard_True; - else - bFound2 = Standard_True; - bFound = Standard_True; - } - else { - aMapOfEInternal.Add(anAdjE); - } - } // end for - - if(!bFound) { - anIt.Initialize(aListOfE); - - for(; anIt.More(); anIt.Next()) { - const TopoDS_Shape& anAdjE = anIt.Value(); - - if(anEdge.IsSame(anAdjE)) - continue; - - if(anAdjE.Orientation() == TopAbs_INTERNAL) { - // - aMapOfEInternal.Add(anAdjE); - // - - TopExp_Explorer anExpV2(anAdjE, TopAbs_VERTEX); - - for(; anExpV2.More(); anExpV2.Next()) { - if(aMapOfV.Contains(anExpV2.Current())) - continue; - aV = TopoDS::Vertex(anExpV2.Current()); - } - } - } - } - // end if - } - // end while - } - } - - if(bIsClosed || - ((vcounter > 1) && bFound1 && bFound2) || - ((vcounter == 1) && bFound1)) { - TopoDS_Shape anOrientedEdge = anEdge; - anOrientedEdge.Orientation(TopAbs_FORWARD); - - aFilteredWES.AddStartElement(anOrientedEdge); - anOrientedEdge.Reverse(); - aFilteredWES.AddStartElement(anOrientedEdge); - } - else { - Standard_Integer aMapIt = 1, nbv = 0, nbe = 0; - TopTools_IndexedMapOfShape aMapOfFoundV; - - for(aMapIt = 1; aMapIt <= aMapOfEInternal.Extent(); aMapIt++) { - const TopoDS_Shape& aShape = aMapOfEInternal(aMapIt); - TopExp::MapShapes(aShape, TopAbs_VERTEX, aMapOfFoundV); - } - nbe = aMapOfEInternal.Extent(); - nbv = aMapOfFoundV.Extent(); - - if((nbe != 0) && (nbe == nbv)) { - TopoDS_Shape anOrientedEdge = anEdge; - anOrientedEdge.Orientation(TopAbs_FORWARD); - - aFilteredWES.AddStartElement(anOrientedEdge); - anOrientedEdge.Reverse(); - aFilteredWES.AddStartElement(anOrientedEdge); - } - else { - aFilteredWES.AddStartElement(anEdge); - } - } - } - } - - BOP_FaceBuilder aFB; - aFB.Do(aFilteredWES); - const TopTools_ListOfShape& aLF = aFB.NewFaces(); - - theListOfFace = aLF; - - Standard_Integer nbstartedges = aFilteredWES.StartElements().Extent(); - Standard_Integer nbedgeused = 0; - TopTools_ListIteratorOfListOfShape anItNewF(aLF); - - // was: - // ----------------------------------------------------------- -// for(; anItNewF.More(); anItNewF.Next()) { -// TopExp_Explorer anExp(anItNewF.Value(), TopAbs_EDGE); -// for(; anExp.More(); anExp.Next(), nbedgeused++); -// } -// if(nbedgeused != nbstartedges) { -// return Standard_False; -// } - // ----------------------------------------------------------- - // - // modified 6841: - // - if(aLF.Extent() != 2) { - for(; anItNewF.More(); anItNewF.Next()) { - TopExp_Explorer anExp(anItNewF.Value(), TopAbs_EDGE); - for(; anExp.More(); anExp.Next(), nbedgeused++); - } - if(nbedgeused != nbstartedges) { - return Standard_False; - } - } - else { // two faces analysis - TopTools_IndexedDataMapOfShapeListOfShape amFLIE; - TopTools_ListOfShape aLIntAll; - for(; anItNewF.More(); anItNewF.Next()) { - const TopoDS_Face & anF = TopoDS::Face(anItNewF.Value()); - TopExp_Explorer anExp(anItNewF.Value(), TopAbs_EDGE); - TopTools_ListOfShape aLInt; - for(; anExp.More(); anExp.Next(), nbedgeused++) { - const TopoDS_Edge & anE = TopoDS::Edge(anExp.Current()); - if(anE.Orientation() == TopAbs_INTERNAL) { - aLIntAll.Append(anE); - aLInt.Append(anE); - } - } - amFLIE.Add(anF,aLInt); - } - if(nbedgeused != nbstartedges) { - if(!aLIntAll.IsEmpty()) { - Standard_Integer nbUsed = nbedgeused; - TopTools_ListIteratorOfListOfShape anItInt(aLIntAll); - for(; anItInt.More(); anItInt.Next()) { - const TopoDS_Edge & aEInt = TopoDS::Edge(anItInt.Value()); - Standard_Integer nbFRE = 0; - TopTools_ListIteratorOfListOfShape anItWes(aFilteredWES.StartElements()); - for(; anItWes.More(); anItWes.Next()) { - const TopoDS_Edge & aEWes = TopoDS::Edge(anItWes.Value()); - if(aEWes.Orientation() != TopAbs_INTERNAL) { - if(aEInt.IsSame(aEWes)) - nbFRE++; - } - } - if(nbFRE > 1) - nbUsed += (nbFRE - 1); - } - if(nbUsed == nbstartedges && Abs(nbstartedges-nbedgeused) == 1) { - Standard_Integer iF = 0, nbFI = 0; - for(iF = 1; iF <= amFLIE.Extent(); iF++) { - const TopTools_ListOfShape& aLOfIE = amFLIE.FindFromIndex(iF); - if(!aLOfIE.IsEmpty()) nbFI++; - } - if(nbFI == 1) { - anItNewF.Initialize(aLF); - Standard_Boolean checkOk = Standard_False; - for(; anItNewF.More(); anItNewF.Next()) { - const TopoDS_Face & anF = TopoDS::Face(anItNewF.Value()); - const TopTools_ListOfShape& aLOfIE = amFLIE.FindFromKey(anF); - if(!aLOfIE.IsEmpty() && aLOfIE.Extent() == 1) { - const TopoDS_Edge & anIntE = TopoDS::Edge(aLOfIE.First()); - TopTools_IndexedDataMapOfShapeListOfShape aMapVE; - TopExp::MapShapesAndAncestors(anF,TopAbs_VERTEX,TopAbs_EDGE,aMapVE); - TopoDS_Vertex v1,v2; - TopExp::Vertices(anIntE,v1,v2); - Standard_Boolean hasSingle = Standard_False; - if(!v1.IsNull() && !v2.IsNull()) { - const TopTools_ListOfShape& aL1E = aMapVE.FindFromKey(v1); - const TopTools_ListOfShape& aL2E = aMapVE.FindFromKey(v2); - if((aL1E.Extent() == 1 && aL2E.Extent() != 1) || - (aL2E.Extent() == 1 && aL1E.Extent() != 1)) - hasSingle = Standard_True; - } - if(hasSingle) { - checkOk = Standard_True; - break; - } - } - } - if(checkOk) { - return Standard_True; - } - } - } // all edges are really used - } // has internals - return Standard_False; - } - } // two faces analysis - - return Standard_True; -} diff --git a/src/BOP/BOP_ShellSplitter.cdl b/src/BOP/BOP_ShellSplitter.cdl deleted file mode 100755 index 1f19e1a7b8..0000000000 --- a/src/BOP/BOP_ShellSplitter.cdl +++ /dev/null @@ -1,111 +0,0 @@ --- Created on: 2001-04-09 --- Created by: Peter KURNEV --- Copyright (c) 2001-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class ShellSplitter from BOP - - ---Purpose: - --- the algorithm to split (multiconnexed) - --- shells on a solid onto biconnexed shells - --- when each edge is shared by only two or one - -- faces - -uses - - Shell from TopoDS, - ListOfShape from TopTools, - - ListOfListOfShape from BOPTColStd, - - EdgeInfo from BOP, - IndexedDataMapOfEdgeListFaceInfo from BOP - - --raises - -is - Create - returns ShellSplitter from BOP; - ---Purpose: - --- Empty constructor; - --- - DoWithListOfEdges(me:out; - aLE:ListOfShape from TopTools); - ---Purpose: - --- Perform the algorithm using the list of shapes as data - --- - SetShell (me:out; - aShell:Shell from TopoDS); - ---Purpose: - --- Modifier - --- - Shell (me) - returns Shell from TopoDS; - ---C++: return const & - ---Purpose: - --- Selector - --- - DoWithShell (me:out); - ---Purpose: - --- Perform the algorithm using the shell as data - --- - Do (me:out) - is private; - ---Purpose: - --- Perform the algorithm - --- - IsNothingToDo (me) - returns Boolean from Standard; - ---Purpose: - --- Returns TRUE if the source shell is valid and - --- there is nothing to correct - --- - IsDone (me) - returns Boolean from Standard; - ---Purpose: - --- Returns TRUE if the algorithm was performed - --- successfuly - --- - Shapes (me) - returns ListOfListOfShape from BOPTColStd; - ---C++: return const & - ---Purpose: - --- Selector - --- - - -fields - myShell : Shell from TopoDS; - myIsDone : Boolean from Standard; - myNothingToDo: Boolean from Standard; - myShapes : ListOfListOfShape from BOPTColStd; - mySmartMap : IndexedDataMapOfEdgeListFaceInfo from BOP; - myFaces : ListOfShape from TopTools; - -end ShellSplitter; - - - - - - - - - - diff --git a/src/BOP/BOP_ShellSplitter.cxx b/src/BOP/BOP_ShellSplitter.cxx deleted file mode 100755 index 86c09b7259..0000000000 --- a/src/BOP/BOP_ShellSplitter.cxx +++ /dev/null @@ -1,914 +0,0 @@ -// Created on: 2001-04-09 -// Created by: Peter KURNEV -// Copyright (c) 2001-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -static - void RemoveInternals(const TopoDS_Face& , - TopoDS_Face& ); - -static - Standard_Boolean GetShells(TopTools_SequenceOfShape& , - const TopTools_MapOfShape& , - TopTools_SequenceOfShape& , - TopTools_DataMapOfShapeShape& , - TopTools_SequenceOfShape& ) ; - -static - Standard_Boolean AddMultiConexityFaces(TopTools_SequenceOfShape& , - const TopTools_MapOfShape& , - TopTools_SequenceOfShape& , - const TopTools_DataMapOfShapeShape& , - const TopTools_IndexedDataMapOfShapeListOfShape& , - TopTools_SequenceOfShape& ); - -static - Standard_Boolean SplitShell(const TopoDS_Shell& , - TopoDS_Shape& ); -static - void CreateClosedShell(TopTools_SequenceOfShape& , - const TopTools_MapOfShape& , - const TopTools_IndexedDataMapOfShapeListOfShape& ); -// -//======================================================================= -// function: BOP_ShellSplitter::BOP_ShellSplitter -// purpose: -//======================================================================= - BOP_ShellSplitter::BOP_ShellSplitter() -: - myIsDone(Standard_False), - myNothingToDo(Standard_False) -{ -} - -//======================================================================= -// function: IsNothingToDo -// purpose: -//======================================================================= - Standard_Boolean BOP_ShellSplitter::IsNothingToDo()const -{ - return myNothingToDo; -} - -//======================================================================= -// function: IsDone -// purpose: -//======================================================================= - Standard_Boolean BOP_ShellSplitter::IsDone()const -{ - return myIsDone; -} - -//======================================================================= -// function: Shapes -// purpose: -//======================================================================= - const BOPTColStd_ListOfListOfShape& BOP_ShellSplitter::Shapes()const -{ - return myShapes; -} - -//======================================================================= -// function: SetShell -// purpose: -//======================================================================= - void BOP_ShellSplitter::SetShell(const TopoDS_Shell& aShell) -{ - myShell=aShell; -} -//======================================================================= -// function: Shell -// purpose: -//======================================================================= - const TopoDS_Shell& BOP_ShellSplitter::Shell()const -{ - return myShell; -} - -//======================================================================= -// function: DoWithShell -// purpose: -//======================================================================= - void BOP_ShellSplitter::DoWithShell () -{ - myFaces.Clear(); - - TopExp_Explorer anExpFaces (myShell, TopAbs_FACE); - for (; anExpFaces.More(); anExpFaces.Next()) { - const TopoDS_Face& aF = TopoDS::Face(anExpFaces.Current()); - myFaces.Append(aF); - } - Do(); -} - -//======================================================================= -// function: DoWithListOfEdges -// purpose: -//======================================================================= - void BOP_ShellSplitter::DoWithListOfEdges(const TopTools_ListOfShape& aLE) -{ - myFaces.Clear(); - - TopTools_ListIteratorOfListOfShape anItList; - - anItList.Initialize(aLE); - for (; anItList.More(); anItList.Next()) { - const TopoDS_Face& aF = TopoDS::Face(anItList.Value()); - myFaces.Append(aF); - } - Do(); -} - -//======================================================================= -// function: Do -// purpose: -//======================================================================= - void BOP_ShellSplitter::Do() -{ - myIsDone=Standard_False; - myNothingToDo=Standard_False; - // - TopTools_ListIteratorOfListOfShape anItList; - TopTools_IndexedDataMapOfShapeShape aMFNewOld; - TopoDS_Shell aShell; - BRep_Builder aBB; - // - // insert the code about myNothingToDo - // - // 1. Make the formal shell - aBB.MakeShell(aShell); - // - anItList.Initialize(myFaces); - for (; anItList.More(); anItList.Next()) { - const TopoDS_Face& aF = TopoDS::Face(anItList.Value()); - TopoDS_Face aFNew; - RemoveInternals (aF, aFNew); - aMFNewOld.Add (aFNew, aF); - - aBB.Add(aShell, aFNew); - } - // - // 2. Split the Shell - - TopoDS_Shape aShape; - SplitShell (aShell, aShape); - // - // 3. Post-pro the result aShape - // and filling the myShapes field . - TopExp_Explorer aShellExp(aShape, TopAbs_SHELL); - for (; aShellExp.More(); aShellExp.Next()) { - const TopoDS_Shape& aSh= aShellExp.Current(); - - TopTools_ListOfShape aLF; - TopExp_Explorer aFaceExp(aSh, TopAbs_FACE); - for (; aFaceExp.More(); aFaceExp.Next()) { - const TopoDS_Shape& aFNew= aFaceExp.Current(); - - const TopoDS_Shape& aFOld=aMFNewOld.FindFromKey(aFNew); - aLF.Append(aFOld); - } - - if (aLF.Extent()) { - myShapes.Append(aLF); - } - } - - myIsDone=Standard_True; -} - -//======================================================================= -// function: RemoveInternals -// purpose: -//======================================================================= -void RemoveInternals(const TopoDS_Face& aF, - TopoDS_Face& aFNew) -{ - BRep_Builder aBB; - Standard_Integer iCnt; - Standard_Real aTol; - - - TopLoc_Location aLoc; - Handle(Geom_Surface) aSurface=BRep_Tool::Surface(aF, aLoc); - aTol=BRep_Tool::Tolerance(aF); - aBB.MakeFace (aFNew, aSurface, aLoc, aTol); - aFNew.Orientation(aF.Orientation()); - - TopExp_Explorer aFExp(aF, TopAbs_WIRE); - for (; aFExp.More(); aFExp.Next()) { - const TopoDS_Wire& aW= TopoDS::Wire(aFExp.Current()); - TopoDS_Wire aWNew; - aBB.MakeWire(aWNew); - aWNew.Orientation(aW.Orientation()); - - iCnt=0; - TopExp_Explorer aWExp(aW, TopAbs_EDGE); - for (; aWExp.More(); aWExp.Next()) { - const TopoDS_Edge& aE=TopoDS::Edge(aWExp.Current()); - if (aE.Orientation()!=TopAbs_INTERNAL) { - aBB.Add(aWNew, aE); - iCnt++; - } - } - if (iCnt) { - aBB.Add(aFNew, aWNew); - } - } -} - -//////// -// -//======================================================================= -// function : SplitShell -// purpose : -//======================================================================= - Standard_Boolean SplitShell (const TopoDS_Shell& aShellIn, - TopoDS_Shape& aShellsOut) -{ - Standard_Boolean done; - Standard_Integer i, j, aNumMultShell; - - TopTools_SequenceOfShape aSeqShells, aErrFaces, Lface; - TopTools_DataMapOfShapeShape aMapFaceShells; - TopTools_IndexedDataMapOfShapeListOfShape aMapEdgeFaces; - TopTools_MapOfShape aMapMultiConnectEdges; - TopoDS_Compound aCmpErrFaces; - // - done = Standard_False; - aNumMultShell =0; - aShellsOut = aShellIn; - - TopoDS_Iterator iter(aShellIn); - for (; iter.More(); iter.Next()) { - Lface.Append(iter.Value()); - } - // - TopExp::MapShapesAndAncestors(aShellIn, TopAbs_EDGE, TopAbs_FACE, aMapEdgeFaces); - // - //Finds multishared edges - Standard_Integer aNbEdges, aNbFaces; - aNbEdges=aMapEdgeFaces.Extent(); - for(j=1; j<=aNbEdges; j++) { - const TopTools_ListOfShape& aLF=aMapEdgeFaces(j); - aNbFaces=aLF.Extent(); - if(aNbFaces>2) { - const TopoDS_Shape& aE=aMapEdgeFaces.FindKey(j); - aMapMultiConnectEdges.Add(aE); - } - } - // - //Gets shells without taking in account of multiconnexity. - Standard_Boolean isGetShells = Standard_True; - - while(isGetShells && Lface.Length()) { - TopTools_SequenceOfShape aTmpSeqShells; - Standard_Boolean bGetShells; - - bGetShells=GetShells(Lface, - aMapMultiConnectEdges, - aTmpSeqShells, - aMapFaceShells, - aErrFaces); - if(bGetShells) { - done = Standard_True; - } - - isGetShells = !aTmpSeqShells.IsEmpty(); - if(isGetShells) { - aSeqShells.Append(aTmpSeqShells); - } - } // while(...) - // - // - Standard_Boolean aIsDone = Standard_False; - Standard_Integer aLfaceLength, aErrFacesLength; - - aLfaceLength=Lface.Length(); - aNumMultShell=aSeqShells.Length(); - - if(aLfaceLength && aNumMultShell) { - //Crating shells in the case of compsolid - aIsDone = AddMultiConexityFaces(Lface, - aMapMultiConnectEdges, - aSeqShells, - aMapFaceShells, - aMapEdgeFaces, - aErrFaces); - } - // - aNumMultShell = aSeqShells.Length(); - aErrFacesLength=aErrFaces.Length(); - // - if (aErrFacesLength) { - BRep_Builder B; - TopoDS_Compound aCompShells; - - B.MakeCompound (aCmpErrFaces); - B.MakeCompound(aCompShells); - - for(j =1; j <= aErrFacesLength; j++){ - B.Add(aCmpErrFaces, aErrFaces.Value(j)); - } - - if(aNumMultShell) { - - if(aNumMultShell == 1) { - aShellsOut = aSeqShells.Value(1); - B.Add(aCompShells, aSeqShells.Value(1)); - - for(j=1; j <= aErrFacesLength; j++) { - TopoDS_Shell aSh; - B.MakeShell(aSh); - B.Add(aSh, aErrFaces.Value(j)); - B.Add(aCompShells, aSh); - } - aShellsOut = aCompShells; - } - - else { - for(i=1; i <= aNumMultShell; i++) { - B.Add(aCompShells, aSeqShells.Value(i)); - } - - for(j=1; j<= aErrFacesLength; j++) { - TopoDS_Shell aSh; - B.MakeShell(aSh); - B.Add(aSh,aErrFaces.Value(j)); - B.Add(aCompShells, aSh); - } - aShellsOut = aCompShells; - } - } //if(aNumMultShell) - - done = Standard_True; - return done; - } // if (aErrFacesLength) - // - // - if(aNumMultShell>1) { - TopTools_SequenceOfShape OpenShells; - - for(i=1; i <= aSeqShells.Length(); i++) { - TopoDS_Shape aShell = aSeqShells.Value(i); - if(!BRep_Tool::IsClosed(aShell)) { - OpenShells.Append(aShell); - aSeqShells.Remove(i--); - } - } - - j=OpenShells.Length(); - if(j>1) { - // Attempt of creation closed shell from open shells - // with taking into account multiconnexity. - // - CreateClosedShell(OpenShells, aMapMultiConnectEdges, aMapEdgeFaces); - aSeqShells.Append(OpenShells); - } - } //if(aNumMultShell>1) - // - // - j=Lface.Length(); - if(j) { - for(i=1; i <= j; i++) { - BRep_Builder aB; - TopoDS_Shell OneShell; - aB.MakeShell(OneShell); - aB.Add(OneShell, Lface.Value(i)); - aSeqShells.Append(OneShell); - } - } - // - // - aNumMultShell = aSeqShells.Length(); - if(!done) { - done = (aNumMultShell>1 || aIsDone); - } - - BRep_Builder B; - TopoDS_Compound aCompShells; - B.MakeCompound(aCompShells); - for(i=1; i <= aNumMultShell; i++){ - B.Add(aCompShells, aSeqShells.Value(i)); - } - aShellsOut = aCompShells; - // - return done; -} - -//======================================================================= -// function : GetShells -// purpose : -//======================================================================= -Standard_Boolean GetShells(TopTools_SequenceOfShape& Lface, - const TopTools_MapOfShape& aMapMultiConnectEdges, - TopTools_SequenceOfShape& aSeqShells, - TopTools_DataMapOfShapeShape& aMapFaceShells, - TopTools_SequenceOfShape& ErrFaces) -{ - Standard_Boolean done = Standard_False; - Standard_Integer i, j, aNbLfaceLength; - - j=Lface.Length(); - if(!j) { - return done; - } - - Standard_Boolean isMultiConnex; - TopoDS_Shell nshell; - TopTools_MapOfShape dire, reve; - BRep_Builder B; - TopTools_SequenceOfShape aSeqUnconnectFaces; - - B.MakeShell(nshell); - isMultiConnex = !aMapMultiConnectEdges.IsEmpty(); - i=1; - j=1; - // - for(; i<=Lface.Length(); i++) { - aNbLfaceLength=Lface.Length(); - TopTools_MapOfShape dtemp, rtemp; - Standard_Integer nbbe=0, nbe = 0; - - TopoDS_Face aF = TopoDS::Face(Lface.Value(i)); - - TopExp_Explorer anExpe(aF, TopAbs_EDGE); - for(; anExpe.More(); anExpe.Next()) { - const TopoDS_Edge& aE = TopoDS::Edge(anExpe.Current()); - - if(isMultiConnex && aMapMultiConnectEdges.Contains(aE)){ - continue; - } - - if (BRep_Tool::Degenerated (aE)) { - continue; - } - - if (BRep_Tool::IsClosed(aE, aF)) { - continue; - } - - TopAbs_Orientation anEOr; - anEOr=aE.Orientation(); - - Standard_Boolean bDireContains, bReveContains; - - bDireContains=dire.Contains(aE); - bReveContains=reve.Contains(aE); - - if((anEOr == TopAbs_FORWARD && bDireContains) || - (anEOr == TopAbs_REVERSED && bReveContains)) { - nbbe++; - } - else if((anEOr == TopAbs_FORWARD && bReveContains) || - (anEOr == TopAbs_REVERSED && bDireContains)) { - nbe++; - } - - if(bDireContains) { - dire.Remove(aE); - } - else if(bReveContains) { - reve.Remove(aE); - } - else { - if(anEOr == TopAbs_FORWARD) { - dtemp.Add(aE); - } - if(anEOr == TopAbs_REVERSED) { - rtemp.Add(aE); - } - } - } // for(; expe.More(); expe.Next()) - // - // - if(!nbbe && !nbe && dtemp.IsEmpty() && rtemp.IsEmpty()) { - continue; - } - // - if( nbe != 0 && nbbe != 0) { - ErrFaces.Append(aF); - Lface.Remove(i); - aNbLfaceLength=Lface.Length(); - j++; - continue; - } - // - if((nbe != 0 || nbbe != 0) || j == 1) { - TopTools_MapIteratorOfMapOfShape ite; - if(nbbe != 0) { - aF.Reverse(); - - ite.Initialize(dtemp); - for(; ite.More(); ite.Next()) { - reve.Add(ite.Key()); - } - - ite.Initialize(rtemp); - for(; ite.More(); ite.Next()){ - dire.Add(ite.Key()); - } - done = Standard_True; - } - else { - ite.Initialize(dtemp); - for(; ite.More(); ite.Next()) { - dire.Add(ite.Key()); - } - - ite.Initialize(rtemp); - for(; ite.More(); ite.Next()){ - reve.Add(ite.Key()); - } - } - - j++; - B.Add(nshell, aF); - aMapFaceShells.Bind(aF, nshell); - Lface.Remove(i); - aNbLfaceLength=Lface.Length(); - if(isMultiConnex && BRep_Tool::IsClosed(nshell)) { - aSeqShells.Append(nshell); - TopoDS_Shell nshellnext; - B.MakeShell(nshellnext); - nshell = nshellnext; - j=1; - } - i=0; - } // if((nbe != 0 || nbbe != 0) || j == 1) - // - // - if(Lface.Length() && i == Lface.Length() && j <=2) { - TopoDS_Iterator aItf(nshell,Standard_False); - if(aItf.More()){ - aSeqUnconnectFaces.Append(aItf.Value()); - } - TopoDS_Shell nshellnext; - B.MakeShell(nshellnext); - nshell = nshellnext; - i=0; - j=1; - } - }//for(; i<=Lface.Length(); i++) - - Standard_Boolean isContains = Standard_False; - j=aSeqShells.Length(); - for(i=1 ; i <= j; i++){ - isContains = nshell.IsSame(aSeqShells.Value(i)); - if (isContains) { - break; - } - } - - if(!isContains) { - Standard_Integer numFace =0; - TopoDS_Shape aFace; - - TopoDS_Iterator aItf(nshell, Standard_False) ; - for(; aItf.More(); aItf.Next()) { - aFace = aItf.Value(); - numFace++; - } - - if(numFace >1) { - aSeqShells.Append(nshell); - } - else if(numFace == 1) { - Lface.Append(aFace); - } - } - - for(i=1; i<= aSeqUnconnectFaces.Length(); i++){ - Lface.Append(aSeqUnconnectFaces); - } - return done; -} - -//======================================================================= -// function : AddMultiConexityFaces -// purpose : -//======================================================================= -Standard_Boolean AddMultiConexityFaces(TopTools_SequenceOfShape& Lface, - const TopTools_MapOfShape& aMapMultiConnectEdges, - TopTools_SequenceOfShape& SeqShells, - const TopTools_DataMapOfShapeShape& aMapFaceShells, - const TopTools_IndexedDataMapOfShapeListOfShape& aMapEdgeFaces, - TopTools_SequenceOfShape& ErrFaces) -{ - Standard_Boolean done = Standard_False; - BRep_Builder aB; - Standard_Integer i1; - - for(i1 = 1 ; i1<=Lface.Length(); ) { - TopTools_MapOfShape dire, reve; - TopTools_IndexedMapOfShape MapOtherShells; - Standard_Integer aNbOtherShells; - - const TopoDS_Face& aFace = TopoDS::Face(Lface.Value(i1)); - // - //Finds shells containg multishared edges from this face - TopExp_Explorer aExpEdges(aFace, TopAbs_EDGE); - for(; aExpEdges.More(); aExpEdges.Next()) { - const TopoDS_Shape& aE = aExpEdges.Current(); - - if(!aMapMultiConnectEdges.Contains(aE)) { - continue; - } - - if( aE.Orientation() == TopAbs_FORWARD) { - dire.Add(aE); - } - else { - reve.Add(aE); - } - - const TopTools_ListOfShape& aLF = aMapEdgeFaces.FindFromKey(aE); - TopTools_ListIteratorOfListOfShape aItl(aLF); - for(; aItl.More(); aItl.Next()) { - const TopoDS_Shape& aF = aItl.Value(); - - if(aF.IsSame(aFace)) { - continue; - } - - TopoDS_Shape aOthershell; - if(aMapFaceShells.IsBound(aF)) { - aOthershell = aMapFaceShells.Find(aF); - if(!MapOtherShells.Contains(aOthershell)) { - MapOtherShells.Add(aOthershell); - } - } - } - }//for(; aExpEdges.More(); aExpEdges.Next()) - // - // - aNbOtherShells=MapOtherShells.Extent(); - // - if(!aNbOtherShells) { - i1++; - continue; - } - - else { - //Adds face to open shells containg the same multishared edges. - //For nonmanifold mode creation ine shell from face and shells - // containing the same multishared edges. - done = Standard_True; - - Standard_Integer j, k; - - TColStd_SequenceOfInteger SeqOtherShells; - for(j =1; j <= aNbOtherShells; j++) { - Standard_Integer index=0; - for(k =1; k <= SeqShells.Length() && !index; k++) { - if(SeqShells.Value(k) == MapOtherShells.FindKey(j)){ - index = k; - } - } - SeqOtherShells.Append(index); - } - - aNbOtherShells= SeqOtherShells.Length(); - - for(j =1; j <= aNbOtherShells; j++) { - Standard_Integer nbdir =0,nbrev =0; - TopTools_MapOfShape mapEdges; - - k = SeqOtherShells.Value(j); - const TopoDS_Shape& aShk=SeqShells.Value(k); - - TopExp_Explorer aExpF(aShk, TopAbs_FACE); - for(; aExpF.More(); aExpF.Next()) { - const TopoDS_Shape& aFC=aExpF.Current(); - - TopExp_Explorer aExpE(aFC,TopAbs_EDGE); - for(; aExpE.More(); aExpE.Next()) { - - const TopoDS_Shape& aEC = aExpE.Current(); - if(!mapEdges.Contains(aEC)){ - mapEdges.Add(aEC); - } - else { - mapEdges.Remove(aEC); - } - - }// for(; aExpE.More(); aExpE.Next()) - }// for(; aExpF.More(); aExpF.Next()) { - // - // - TopTools_MapIteratorOfMapOfShape aIte(mapEdges); - for(;aIte.More(); aIte.Next()) { - const TopoDS_Shape& aEC = aIte.Key(); - TopAbs_Orientation anOrEC=aEC.Orientation(); - - Standard_Boolean bDireContains, bReveContains; - - bDireContains=dire.Contains(aEC); - bReveContains=reve.Contains(aEC); - - if((anOrEC == TopAbs_FORWARD && bDireContains) || - (anOrEC == TopAbs_REVERSED && bReveContains)) { - nbrev++; - } - else if((anOrEC == TopAbs_FORWARD && bReveContains)|| - (anOrEC == TopAbs_REVERSED && bDireContains)) { - nbdir++; - } - }// for(;aIte.More(); aIte.Next()) - - if(nbdir && nbrev) { - ErrFaces.Append(aFace); - } - - else if(nbdir || nbrev) { - // for manifold mode face containing multiconnexity - // edges will be added in the each shell - // containing the same edges. ??? - - TopoDS_Shape aShell; - aShell = SeqShells.Value(k); - if (!nbrev) { - aB.Add(aShell, aFace); - SeqShells.ChangeValue(k) = aShell; - } - }// else if(nbdir || nbrev) - }// for(j =1; j <= aNbOtherShells; j++) - // - dire.Clear(); - reve.Clear(); - Lface.Remove(i1); - } - } - return done; -} -//======================================================================= -// function : CreateClosedShell -// purpose : -//======================================================================= -void CreateClosedShell(TopTools_SequenceOfShape& OpenShells, - const TopTools_MapOfShape& aMapMultiConnectEdges, - const TopTools_IndexedDataMapOfShapeListOfShape& aMapEdgeFaces) -{ - TopTools_MapOfShape amapFaces; - - TopTools_MapIteratorOfMapOfShape aItEdg(aMapMultiConnectEdges); - for(; aItEdg.More(); aItEdg.Next()) { - const TopTools_ListOfShape& aLF = aMapEdgeFaces.FindFromKey(aItEdg.Key()); - TopTools_ListIteratorOfListOfShape aItF(aLF); - for(; aItF.More(); aItF.Next()) { - amapFaces.Add(aItF.Value()); - } - } - // - // Creating new shells if some open shells contain the same edges. - Standard_Integer i, j; - Standard_Boolean isClosedShell; - - for(i=1; i <= OpenShells.Length(); i++) { - TopTools_MapOfShape dire, reve; - - isClosedShell = Standard_False; - const TopoDS_Shape& anOpenShelli=OpenShells.Value(i); - TopExp_Explorer aExpF(anOpenShelli, TopAbs_FACE); - - for(; aExpF.More(); aExpF.Next()) { - const TopoDS_Shape& aFace = aExpF.Current(); - - if(!amapFaces.Contains(aFace)) { - continue; - } - - TopExp_Explorer aExpEdges(aFace, TopAbs_EDGE); - for(; aExpEdges.More(); aExpEdges.Next()) { - const TopoDS_Shape& aE = aExpEdges.Current(); - - if(!aMapMultiConnectEdges.Contains(aE)) { - continue; - } - - TopAbs_Orientation anOrE; - anOrE=aE.Orientation(); - - if(anOrE == TopAbs_FORWARD) { - dire.Add(aE); - } - else if(anOrE == TopAbs_REVERSED) { - reve.Add(aE); - } - } - }// for(; aExpF.More(); aExpF.Next()) - // - // - for(j=i+1; j<=OpenShells.Length(); j++) { - Standard_Integer nbedge =0; - Standard_Boolean isReversed = Standard_False; - - const TopoDS_Shape& anOpenShellj=OpenShells.Value(j); - - TopExp_Explorer aExpF2(anOpenShellj, TopAbs_FACE); - for(; aExpF2.More() && !nbedge; aExpF2.Next()) { - - const TopoDS_Shape& aFace2 = aExpF2.Current(); - - if(!amapFaces.Contains(aFace2)) { - continue; - } - - TopExp_Explorer aExpEdges2(aFace2, TopAbs_EDGE); - for(; aExpEdges2.More()&& !nbedge; aExpEdges2.Next()) { - const TopoDS_Shape& aE2 = aExpEdges2.Current(); - - if(!aMapMultiConnectEdges.Contains(aE2)) { - continue; - } - - Standard_Boolean bDireContains, bReveContains; - - bDireContains=dire.Contains(aE2); - bReveContains=reve.Contains(aE2); - - if(!bDireContains && !bReveContains) { - continue; - } - - isClosedShell = Standard_True; - - TopAbs_Orientation anOrE2; - anOrE2=aE2.Orientation(); - if((anOrE2 == TopAbs_FORWARD && bDireContains) || - (anOrE2 == TopAbs_REVERSED && bReveContains)) { - isReversed = Standard_True; - } - nbedge++; - } - }// for(; aExpF2.More() && !nbedge; aExpF2.Next()) - - if(!isClosedShell){ - continue; - } - - BRep_Builder aB; - TopoDS_Shape aShell = OpenShells.Value(i); - - TopExp_Explorer aExpF21(anOpenShellj, TopAbs_FACE); - for(; aExpF21.More(); aExpF21.Next()) { - const TopoDS_Shape& aFace = aExpF21.Current(); - //if(isReversed) { - // aFace.Reverse(); - //} - aB.Add(aShell, aFace); - } - - OpenShells.ChangeValue(i) = aShell; - OpenShells.Remove(j--); - }// for(j=i+1 ; j<=OpenShells.Length();j++ ) - }//for(i=1; i <= OpenShells.Length(); i++) -} diff --git a/src/BOP/BOP_SolidAreaBuilder.cdl b/src/BOP/BOP_SolidAreaBuilder.cdl deleted file mode 100755 index fdcc9caefe..0000000000 --- a/src/BOP/BOP_SolidAreaBuilder.cdl +++ /dev/null @@ -1,54 +0,0 @@ --- Created on: 2001-06-25 --- Created by: Michael KLOKOV --- Copyright (c) 2001-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class SolidAreaBuilder from BOP inherits Area3dBuilder from BOP - - ---Purpose: - --- construct Areas for Solids from a Shell Faces Set - --- -uses - LoopSet from BOP, - LoopClassifier from BOP - -is - Create returns SolidAreaBuilder from BOP; - ---Purpose: - --- Empty constructor; - --- - Create(LS:out LoopSet from BOP; - LC:out LoopClassifier from BOP; - ForceClassFlag: Boolean from Standard = Standard_False) - returns SolidAreaBuilder from BOP; - ---Purpose: - --- Creates an object to build solids on - --- the (shells, blocks of faces) of , - --- using the classifier . - - InitSolidAreaBuilder(me: in out; - LS:out LoopSet from BOP; - LC:out LoopClassifier from BOP; - ForceClassFlag: Boolean from Standard); - ---Purpose: - ---Purpose: - --- Initialize the object to find the areas of - --- the shapes described by , - --- using the classifier . - --- -end SolidAreaBuilder from BOP; diff --git a/src/BOP/BOP_SolidAreaBuilder.cxx b/src/BOP/BOP_SolidAreaBuilder.cxx deleted file mode 100755 index c59b387bfb..0000000000 --- a/src/BOP/BOP_SolidAreaBuilder.cxx +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include - -// ===================================================================== -// function: BOP_SolidAreaBuilder::BOP_SolidAreaBuilder -// purpose: -// ===================================================================== -BOP_SolidAreaBuilder::BOP_SolidAreaBuilder() -{ -} - -// ===================================================================== -// function: BOP_SolidAreaBuilder -// purpose: -// ===================================================================== - BOP_SolidAreaBuilder::BOP_SolidAreaBuilder(BOP_LoopSet& theLS, - BOP_LoopClassifier& theLC, - const Standard_Boolean theForceClassFlag) -{ - InitSolidAreaBuilder(theLS, theLC, theForceClassFlag); -} - -// ===================================================================== -// function: InitSolidAreaBuilder -// purpose: -// ===================================================================== - void BOP_SolidAreaBuilder::InitSolidAreaBuilder(BOP_LoopSet& theLS, - BOP_LoopClassifier& theLC, - const Standard_Boolean theForceClassFlag) -{ - InitAreaBuilder(theLS, theLC, theForceClassFlag); -} - diff --git a/src/BOP/BOP_SolidBuilder.cdl b/src/BOP/BOP_SolidBuilder.cdl deleted file mode 100755 index ca3aa61db1..0000000000 --- a/src/BOP/BOP_SolidBuilder.cdl +++ /dev/null @@ -1,119 +0,0 @@ --- Created on: 2001-06-25 --- Created by: Michael KLOKOV --- Copyright (c) 2001-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class SolidBuilder from BOP - - ---Purpose: - --- Construct Solids from a Shell Faces Set (SFS) - --- -uses - - Shell from TopoDS, - Face from TopoDS, - ShapeSet from BOP, - LoopSet from BOP, - ShellFaceSet from BOP, - BlockBuilder from BOP, - BlockIterator from BOP, - SolidAreaBuilder from BOP - -is - - Create returns SolidBuilder from BOP; - ---Purpose: - --- Empty constructor; - --- - Create(theSFS: in out ShellFaceSet from BOP; - theForceClassFlag: Boolean from Standard = Standard_False) - returns SolidBuilder from BOP; - ---Purpose: - --- The constructor that just calls the method - --- InitSolidBuilder() below - --- - InitSolidBuilder(me : in out; - theSFS: in out ShellFaceSet from BOP; - theForceClassFlag: Boolean from Standard); - ---Purpose: - --- Launches the algorithm consisting of four steps - --- 1. Split the SFS on shells ( BOP_SFSCorrector object) - --- 2. Make Loops from shells ( this->MakeLoops() ) - --- 3. Make Areas from Loops ( BOP_SolidAreaBuilder object) - --- 4. Make Solids from Areas ( see methods below ) - --- - - --- - --- O u t p u t m e t h o d s - --- - --- Iterator on Solids - --- - InitSolid(me: in out) - returns Integer from Standard; - - MoreSolid(me) - returns Boolean from Standard; - - NextSolid(me : in out); - --- - --- Iterator on Shells - --- - InitShell(me : in out) - returns Integer from Standard; - - MoreShell(me) - returns Boolean from Standard; - - NextShell(me : in out); - - IsOldShell(me) - returns Boolean from Standard; - - OldShell(me) returns Shell from TopoDS; - --- - --- Iterator on Shells - --- - InitFace(me : in out) - returns Integer from Standard; - - MoreFace(me) - returns Boolean from Standard; - - NextFace(me : in out); - - Face(me) - returns Face from TopoDS; - ---C++: return const & - ---Purpose: - --- Returns current new face of current new shell. - --- - - ------------------------------------------------------ - -- P r i v a t e b l o c k - -- - MakeLoops(me: in out; theSFS: in out ShapeSet from BOP) - is private; - -fields - - myLoopSet : LoopSet from BOP; - myBlockIterator : BlockIterator from BOP; - myBlockBuilder : BlockBuilder from BOP; - mySolidAreaBuilder: SolidAreaBuilder from BOP; - -end SolidBuilder from BOP; diff --git a/src/BOP/BOP_SolidBuilder.cxx b/src/BOP/BOP_SolidBuilder.cxx deleted file mode 100755 index 8484abc36c..0000000000 --- a/src/BOP/BOP_SolidBuilder.cxx +++ /dev/null @@ -1,212 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include - -#include - -#include -#include -#include - - - -// ============================================================== -// function: BOP_SolidBuilder -// purpose: -// ============================================================== -BOP_SolidBuilder::BOP_SolidBuilder() -{ -} - -// ============================================================== -// function: BOP_SolidBuilder -// purpose: -// ============================================================== - BOP_SolidBuilder::BOP_SolidBuilder(BOP_ShellFaceSet& theSFS, - const Standard_Boolean theForceClassFlag) -{ - InitSolidBuilder(theSFS, theForceClassFlag); -} - -// ============================================================== -// function: InitSolidBuilder -// purpose: -// ============================================================== - void BOP_SolidBuilder::InitSolidBuilder(BOP_ShellFaceSet& theSFS, - const Standard_Boolean theForceClassFlag) -{ - // - BOP_SFSCorrector aSFSCor; - aSFSCor.SetSFS(theSFS); - aSFSCor.Do(); - BOP_ShellFaceSet& aNewSFS=aSFSCor.NewSFS(); - // - //MakeLoops(theSFS); - - MakeLoops(aNewSFS); - BOP_ShellFaceClassifier SFC(myBlockBuilder); - // - mySolidAreaBuilder.InitSolidAreaBuilder(myLoopSet, SFC, theForceClassFlag); -} - -// ============================================================== -// function: InitSolid -// purpose: -// ============================================================== - Standard_Integer BOP_SolidBuilder::InitSolid() -{ - return mySolidAreaBuilder.InitArea(); -} - -// ============================================================== -// function: MoreSolid -// purpose: -// ============================================================== - Standard_Boolean BOP_SolidBuilder::MoreSolid() const -{ - return mySolidAreaBuilder.MoreArea(); -} - -// ============================================================== -// function: NextSolid -// purpose: -// ============================================================== - void BOP_SolidBuilder::NextSolid() -{ - mySolidAreaBuilder.NextArea(); -} - -// ============================================================== -// function: InitShell -// purpose: -// ============================================================== - Standard_Integer BOP_SolidBuilder::InitShell() -{ - return mySolidAreaBuilder.InitLoop(); -} - -// ============================================================== -// function: MoreShell -// purpose: -// ============================================================== - Standard_Boolean BOP_SolidBuilder::MoreShell() const -{ - return mySolidAreaBuilder.MoreLoop(); -} - -// ============================================================== -// function: NextShell -// purpose: -// ============================================================== - void BOP_SolidBuilder::NextShell() -{ - mySolidAreaBuilder.NextLoop(); -} - -// ============================================================== -// function: IsOldShell -// purpose: -// ============================================================== - Standard_Boolean BOP_SolidBuilder::IsOldShell() const -{ - return mySolidAreaBuilder.Loop()->IsShape(); -} - -// ============================================================== -// function: OldShell -// purpose: -// ============================================================== - TopoDS_Shell BOP_SolidBuilder::OldShell() const -{ - if(!IsOldShell()) { - Standard_DomainError::Raise("BOP_SolidBuilder::OldShell"); - } - - return TopoDS::Shell(mySolidAreaBuilder.Loop()->Shape()); -} - -// ============================================================== -// function: InitFace -// purpose: -// ============================================================== - Standard_Integer BOP_SolidBuilder::InitFace() -{ - const Handle(BOP_Loop)& aLoop = mySolidAreaBuilder.Loop(); - - if(aLoop->IsShape()) - Standard_DomainError::Raise("BOP_SolidBuilder::InitFace"); - else { - myBlockIterator = aLoop->BlockIterator(); - myBlockIterator.Initialize(); - } - return myBlockIterator.Extent(); -} - -// ============================================================== -// function: MoreFace -// purpose: -// ============================================================== - Standard_Boolean BOP_SolidBuilder::MoreFace() const -{ - return myBlockIterator.More(); -} - -// ============================================================== -// function: NextFace -// purpose: -// ============================================================== - void BOP_SolidBuilder::NextFace() -{ - myBlockIterator.Next(); -} - -// ============================================================== -// function: Face -// purpose: -// ============================================================== - const TopoDS_Face& BOP_SolidBuilder::Face() const -{ - const TopoDS_Shape& aShape = myBlockBuilder.Element(myBlockIterator); - return TopoDS::Face(aShape); -} - -// ============================================================== -// function: MakeLoops -// purpose: -// ============================================================== - void BOP_SolidBuilder::MakeLoops(BOP_ShapeSet& theSFS) -{ - myBlockBuilder.MakeBlock(theSFS); - - BOP_ListOfLoop& aList = myLoopSet.ChangeListOfLoop(); - aList.Clear(); - - // Add shapes of theSFS as shape loops - for(theSFS.InitShapes(); theSFS.MoreShapes(); theSFS.NextShape()) { - Handle(BOP_Loop) aShapeLoop = new BOP_Loop(theSFS.Shape()); - aList.Append(aShapeLoop); - } - - // Add blocks of myBlockBuilder as block loops - for(myBlockBuilder.InitBlock(); myBlockBuilder.MoreBlock(); myBlockBuilder.NextBlock()) { - BOP_BlockIterator aBlockIterator = myBlockBuilder.BlockIterator(); - Handle(BOP_Loop) aShapeLoop = new BOP_Loop(aBlockIterator); - aList.Append(aShapeLoop); - } -} - diff --git a/src/BOP/BOP_SolidClassifier.cdl b/src/BOP/BOP_SolidClassifier.cdl deleted file mode 100755 index 95f0cf4ab4..0000000000 --- a/src/BOP/BOP_SolidClassifier.cdl +++ /dev/null @@ -1,102 +0,0 @@ --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class SolidClassifier from BOP - - ---Purpose: - -- The auxiliary class to classify points with - -- a solid - -- -uses - - State from TopAbs, - Shell from TopoDS, - Solid from TopoDS, - Pnt from gp, - PSoClassif from BOP, - IndexedDataMapOfSolidClassifier from BOP, - Builder from BRep - -is - - Create - returns SolidClassifier from BOP; - ---Purpose: - --- Empty Constructor - --- - Clear(me:out) - is static; - ---Purpose: - --- Clear internal state - --- - LoadSolid(me: out; - aS : Solid from TopoDS) - is static; - ---Purpose: - --- Modifier - --- - Classify(me:out; - aS : Solid from TopoDS; - aP : Pnt from gp; - aTol: Real from Standard) - returns State from TopAbs - is static; - ---Purpose: - --- Compute the position of point

regarding with the - --- geometric domain of the solid . - --- - - - LoadShell(me:out; - S : Shell from TopoDS) - is static; - ---Purpose: - --- Modifier - --- - Classify(me:out; - aS : Shell from TopoDS; - aP : Pnt from gp; - aTol : Real from Standard) - returns State from TopAbs - is static; - ---Purpose: - --- Compute the position of point

regarding with the - --- geometric domain of the shell . - --- - State(me) - returns State from TopAbs - is static; - ---Purpose: - --- Returns computed 3D-State - --- - Destroy (me:out); - ---C++: alias "Standard_EXPORT virtual ~BOP_SolidClassifier(){Destroy();}" - ---Purpose: - --- Destructor - --- - -fields - - myPClassifier : PSoClassif from BOP; - myClassifierMap : IndexedDataMapOfSolidClassifier from BOP; - myState : State from TopAbs; - myShell : Shell from TopoDS; - mySolid : Solid from TopoDS; - myBuilder : Builder from BRep; - -end SolidClassifier from BOP; diff --git a/src/BOP/BOP_SolidClassifier.cxx b/src/BOP/BOP_SolidClassifier.cxx deleted file mode 100755 index 33443f590c..0000000000 --- a/src/BOP/BOP_SolidClassifier.cxx +++ /dev/null @@ -1,197 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -// NIZNHY-PKV Thu Apr 11 10:42:14 2002 - -#include - -#include - -//======================================================================= -//function : -//purpose : -//======================================================================= -BOP_SolidClassifier::BOP_SolidClassifier() -{ - Clear(); -} - -//======================================================================= -//function : Clear -//purpose : -//======================================================================= - void BOP_SolidClassifier::Clear() -{ - myPClassifier = NULL; - myClassifierMap.Clear(); - myState = TopAbs_UNKNOWN; - myShell.Nullify(); - mySolid.Nullify(); -} - -//======================================================================= -//function : LoadSolid -//purpose : -//======================================================================= - void BOP_SolidClassifier::LoadSolid(const TopoDS_Solid& SOL) -{ - Standard_Boolean found; - - found = myClassifierMap.Contains(SOL); - if ( !found ) { - myPClassifier = new BRepClass3d_SolidClassifier(SOL); - myClassifierMap.Add(SOL, myPClassifier); - } - else { - myPClassifier = myClassifierMap.ChangeFromKey(SOL); - } -} - -//======================================================================= -//function : Classify -//purpose : -//======================================================================= - TopAbs_State BOP_SolidClassifier::Classify (const TopoDS_Solid& SOL, - const gp_Pnt& P, - const Standard_Real Tol) -{ - myPClassifier = NULL; - myState = TopAbs_UNKNOWN; - - LoadSolid(SOL); - - if (myPClassifier == NULL) { - return myState; - } - - myPClassifier->Perform(P,Tol); - myState = myPClassifier->State(); - const TopoDS_Shape& fres = myPClassifier->Face(); - if (fres.IsNull()) { - // NYI : in case of removal of EXTERNAL and INTERNAL faces by the - // classifier BRepClass3d_SolidClassifier, process these faces - // to generate state ON/Solid when the point is IN/face INTERNAL or EXTERNAL - return myState; - } - - TopAbs_Orientation ofres; - - ofres = fres.Orientation(); - - if ( ofres == TopAbs_EXTERNAL ) { - if ( myState == TopAbs_IN ) { - myState = TopAbs_OUT; - } - else if ( myState == TopAbs_OUT ){ - myState = TopAbs_OUT; - } - else if ( myState == TopAbs_ON ){ - myState = TopAbs_ON; - } - else if ( myState == TopAbs_UNKNOWN ){ - myState = TopAbs_OUT; - } - } - - else if ( ofres == TopAbs_INTERNAL ) { - if ( myState == TopAbs_IN ) { - myState = TopAbs_IN; - } - else if ( myState == TopAbs_OUT) { - myState = TopAbs_IN; - } - else if ( myState == TopAbs_ON ) { - myState = TopAbs_ON; - } - else if ( myState == TopAbs_UNKNOWN ) { - myState = TopAbs_IN; - } - } - return myState; -} - - -//======================================================================= -//function : LoadShell -//purpose : -//======================================================================= - void BOP_SolidClassifier::LoadShell(const TopoDS_Shell& SHE) -{ - Standard_Boolean found; - - found = myClassifierMap.Contains (SHE); - - if ( !found ) { - myBuilder.MakeSolid(mySolid); - myBuilder.Add(mySolid,SHE); - TopoDS_Shell* pshe = (TopoDS_Shell*)&SHE; - (*pshe).Free(Standard_True); - - myPClassifier = new BRepClass3d_SolidClassifier(mySolid); - myClassifierMap.Add(SHE, myPClassifier); - } - else { - myPClassifier = myClassifierMap.ChangeFromKey(SHE); - } -} - -//======================================================================= -//function : Classify -//purpose : -//======================================================================= - TopAbs_State BOP_SolidClassifier::Classify (const TopoDS_Shell& SHE, - const gp_Pnt& P, - const Standard_Real Tol) -{ - myPClassifier = NULL; - myState = TopAbs_UNKNOWN; - - LoadShell(SHE); - // - if (myPClassifier == NULL) { - return myState; - } - - myPClassifier->Perform(P,Tol); - myState = myPClassifier->State(); - return myState; -} - -//======================================================================= -//function : State -//purpose : -//======================================================================= - TopAbs_State BOP_SolidClassifier::State() const -{ - return myState; -} - -//======================================================================= -//function : Destroy -//purpose : -//======================================================================= - void BOP_SolidClassifier::Destroy() -{ - Standard_Integer i, aNb; - - aNb=myClassifierMap.Extent(); - for (i=1; i<=aNb; ++i) { - BRepClass3d_SolidClassifier* pC=myClassifierMap(i); - delete pC; - } - myClassifierMap.Clear(); -} diff --git a/src/BOP/BOP_SolidSolid.cdl b/src/BOP/BOP_SolidSolid.cdl deleted file mode 100755 index ee9a4a6a97..0000000000 --- a/src/BOP/BOP_SolidSolid.cdl +++ /dev/null @@ -1,107 +0,0 @@ --- Created on: 2001-05-25 --- Created by: Peter KURNEV --- Copyright (c) 2001-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class SolidSolid from BOP inherits ShellSolid from BOP - - ---Purpose: - --- Performs Boolean Operations (BO) - --- Common,Cut,Fuse for solids as - --- arguments - --- -uses - DSFiller from BOPTools, - - WireEdgeSet from BOP, - ShellFaceSet from BOP, - - HistoryCollector from BOP, - IndexedDataMapOfIntegerIndexedMapOfInteger from BOPTColStd, - DataMapOfShapeInteger from TopTools, - Shape from TopoDS, - State from TopAbs, - - ListOfShape from TopTools - - -is - Create - returns SolidSolid from BOP; - ---Purpose: - --- Empty constructor; - --- - DoWithFiller (me:out; - aDSF: DSFiller from BOPTools) - is redefined; - ---Purpose: - --- See base classes, please - --- - Destroy (me: in out) - is redefined; - ---C++: alias "Standard_EXPORT virtual ~BOP_SolidSolid(){Destroy();}" - ---Purpose: - --- Destructor - --- - DoNewFaces(me: out) - is redefined; - ---Purpose: - --- See base classes, please - --- - BuildResult (me: out) - is redefined; - ---Purpose: - --- See base classes, please - --- - - SetHistoryCollector(me: in out; theHistory: HistoryCollector from BOP) - is redefined virtual; - - --- - --- P r i v a t e b l o c k - --- - PrepareSFS (me:out; - aFaces: ListOfShape from TopTools; - aSFS : out ShellFaceSet from BOP) - is private; - - PrepareFaceSplits(me: out) - is private; - - PropagateFaceStateByEdges(me: in out; theFace: Shape from TopoDS; - theMapOfEdgeIndex: DataMapOfShapeInteger from TopTools; - theState: out State from TopAbs) - returns Boolean from Standard - is private; - - ComputeStateByInsidePoints(me: in out; theFaceIndex: Integer from Standard; - theBaseFaceIndex: Integer from Standard; - theFaceRank: Integer from Standard; - theFFMap: IndexedDataMapOfIntegerIndexedMapOfInteger from BOPTColStd; - theState: out State from TopAbs) - returns Boolean from Standard - is private; - - TakeOnSplit(me; theFaceIndex: Integer from Standard; - theBaseFaceIndex: Integer from Standard) - returns Boolean from Standard - is private; - ---fields -end SolidSolid; diff --git a/src/BOP/BOP_SolidSolid.cxx b/src/BOP/BOP_SolidSolid.cxx deleted file mode 100755 index 0298f11462..0000000000 --- a/src/BOP/BOP_SolidSolid.cxx +++ /dev/null @@ -1,1404 +0,0 @@ -// Created on: 2001-05-25 -// Created by: Peter KURNEV -// Copyright (c) 2001-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include - -#include -#include - - -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -static Standard_Boolean CheckFaceIntersection(const Standard_Integer theFaceIndex, - const BOPTools_DSFiller* theDSFiller); - -static Standard_Boolean BuildWESForCommonZone(const Standard_Integer theFaceIndex, - const TColStd_IndexedMapOfInteger& theFFIndicesMap, - const BOPTools_DSFiller* theDSFiller, - const BOP_Operation& theOperation, - BOP_WireEdgeSet& theWES, - BOP_WireEdgeSet& theWESAvoid); - -static void LocalAddPartsEFSo (const Standard_Integer nF1, - const Standard_Integer iFF, - const TopTools_IndexedDataMapOfShapeListOfShape& aMEFObj, - const TopTools_IndexedDataMapOfShapeListOfShape& aMEFTool, - const BOPTools_DSFiller* theDSFiller, - const BOP_Operation& theOperation, - const TopTools_ListOfShape& theListOfSDFace, - TopTools_IndexedMapOfShape& anEMap, - BOP_WireEdgeSet& aWES); - -static Standard_Boolean LocalIsKeepTwice(const TopoDS_Face& aF1, - const TopoDS_Face& aF2, - const TopoDS_Face& aF2Adj, - const TopoDS_Edge& aSpEF2, - const TopTools_ListOfShape& theFacesToAvoid2, - const TopTools_ListOfShape& theFacesToAvoidAdj); - -//======================================================================= -// function: BOP_SolidSolid::BOP_SolidSolid -// purpose: -//======================================================================= - BOP_SolidSolid::BOP_SolidSolid() -{ -} -//======================================================================= -// function: Destroy -// purpose: -//======================================================================= - void BOP_SolidSolid::Destroy() {} - -//======================================================================= -// function: DoDoWithFiller -// purpose: -//======================================================================= - void BOP_SolidSolid::DoWithFiller(const BOPTools_DSFiller& aDSFiller) -{ - myErrorStatus=0; - myIsDone=Standard_False; - // - myResultMap.Clear(); - myModifiedMap.Clear(); - // - myDSFiller=(BOPTools_DSFiller*) &aDSFiller; - // - try { - OCC_CATCH_SIGNALS - - // modified by NIZHNY-MKK Fri Sep 3 15:14:17 2004.BEGIN - if(!myDSFiller->IsDone()) { - myErrorStatus = 1; - BOPTColStd_Dump::PrintMessage("DSFiller is invalid: Can not build result\n"); - return; - } - // modified by NIZHNY-MKK Fri Sep 3 15:14:20 2004.END - Standard_Boolean bIsNewFiller; - bIsNewFiller=aDSFiller.IsNewFiller(); - - if (bIsNewFiller) { - Prepare(); - - PrepareFaceSplits(); - - aDSFiller.SetNewFiller(!bIsNewFiller); - } - // - DoNewFaces(); - // - BuildResult(); - // - // Treat of internals - CollectInternals(); - BOP_Refiner aRefiner; - aRefiner.SetShape(myResult); - aRefiner.SetInternals(myInternals); - aRefiner.Do(); - // - BOP_CorrectTolerances::CorrectTolerances(myResult, 0.01); - // - FillModified(); - - if(!myHistory.IsNull()) { - Handle(BOP_SolidSolidHistoryCollector) aSolidHistory = - Handle(BOP_SolidSolidHistoryCollector)::DownCast(myHistory); - aSolidHistory->SetResult(myResult, myDSFiller); - } - - myIsDone=Standard_True; - } - catch ( Standard_Failure ) { - myErrorStatus = 1; - BOPTColStd_Dump::PrintMessage("Can not build result\n"); - } -} - -//================================================================================= -// function: BuildResult -// purpose: -//================================================================================= - void BOP_SolidSolid::BuildResult() -{ - BOP_ShellFaceSet theSFS(TopoDS::Solid(myShape1)); - - PrepareSFS(myNewFaces, theSFS); - // - BOP_SolidBuilder aSOBU; - - BRep_Builder aBB; - TopoDS_Solid aNewSolid; - TopoDS_Shell aNewShell; - TopTools_ListOfShape aListOfResult; - - aSOBU.InitSolidBuilder(theSFS, Standard_True); - for(aSOBU.InitSolid(); aSOBU.MoreSolid(); aSOBU.NextSolid()) { - aBB.MakeSolid(aNewSolid); - - for(aSOBU.InitShell(); aSOBU.MoreShell(); aSOBU.NextShell()) { - - if(aSOBU.IsOldShell()) { - aNewShell = aSOBU.OldShell(); - } - else { - aBB.MakeShell(aNewShell); - - for(aSOBU.InitFace(); aSOBU.MoreFace(); aSOBU.NextFace()) { - TopoDS_Face aFace = aSOBU.Face(); - aBB.Add(aNewShell, aFace); - } - - Standard_Boolean isclosed = Standard_False; - TopTools_IndexedDataMapOfShapeListOfShape aMap; - TopExp::MapShapesAndAncestors(aNewShell, TopAbs_EDGE, TopAbs_FACE, aMap); - Standard_Integer nbedge = aMap.Extent(); - - for(Standard_Integer eiterator = 1; eiterator <= nbedge; eiterator++) { - const TopoDS_Shape& aShape = aMap.FindKey(eiterator); - TopAbs_Orientation anOrientation = aShape.Orientation(); - - if((anOrientation == TopAbs_INTERNAL) || - (anOrientation == TopAbs_EXTERNAL) || - (BRep_Tool::Degenerated(TopoDS::Edge(aShape)))) - continue; - Standard_Integer nbface = aMap(eiterator).Extent(); - - if(nbface < 2) { // (here should be additional condition) - isclosed = Standard_False; - break; - } - } - aNewShell.Closed(isclosed); - } // end else of if(aSOBU.IsOldShell()) - aBB.Add(aNewSolid, aNewShell); - } - aListOfResult.Append(aNewSolid); - } - - TopoDS_Compound aCompound; - aBB.MakeCompound(aCompound); - - TopTools_ListIteratorOfListOfShape aResultIt(aListOfResult); - - for(; aResultIt.More(); aResultIt.Next()) { - aBB.Add(aCompound, aResultIt.Value()); - } - - myResult=aCompound; -} - -//======================================================================= -// function: DoNewFaces -// purpose: -//======================================================================= - void BOP_SolidSolid::DoNewFaces() -{ - const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); - BOPTools_InterferencePool* pIntrPool=(BOPTools_InterferencePool*)&myDSFiller->InterfPool(); - BOPTools_CArray1OfSSInterference& aFFs=pIntrPool->SSInterferences(); - // - // EF Maps - const TopoDS_Shape& anObj=aDS.Object(); - const TopoDS_Shape& aTool=aDS.Tool(); - - TopTools_IndexedMapOfShape anEMap; - TopTools_IndexedDataMapOfShapeListOfShape aMEFObj, aMEFTool; - TopExp::MapShapesAndAncestors (anObj, TopAbs_EDGE , TopAbs_FACE , aMEFObj); - TopExp::MapShapesAndAncestors (aTool, TopAbs_EDGE , TopAbs_FACE , aMEFTool); - // - Standard_Boolean bIsTouchCase, bIsTouch, bToReverseFace; - Standard_Integer i, aNb, j, aNbj, iFF, nF1, iRank; - TopTools_ListOfShape aListOfNewFaces; - TopAbs_Orientation anOriF1; - TopTools_ListIteratorOfListOfShape anIt; - - const TColStd_DataMapOfIntegerListOfInteger& aMapOfFaceSplits = myDSFiller->SplitFacePool(); - - // - // DoMap - BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger aFFMap; - BOP_BuilderTools::DoMap(aFFs, aFFMap); - // - aNb=aFFMap.Extent(); - for (i=1; i<=aNb; i++) { - // - // a. Prepare info about the Face nF1 and create WES for nF1 - nF1=aFFMap.FindKey(i); - const TopoDS_Face& aF1=TopoDS::Face(aDS.Shape(nF1)); - - anOriF1=aF1.Orientation(); - iRank=aDS.Rank(nF1); - - if(aMapOfFaceSplits.IsBound(nF1)) { - TopoDS_Face aFace = aF1; - TopTools_ListOfShape aLF; - - const TColStd_ListOfInteger& aListOfSplitIndex = aMapOfFaceSplits.Find(nF1); - TColStd_ListIteratorOfListOfInteger aSplIt(aListOfSplitIndex); - - for(; aSplIt.More(); aSplIt.Next()) { - Standard_Integer nFSpl = aSplIt.Value(); - Standard_Boolean bAddFace = Standard_False; - - BooleanOperations_StateOfShape aSt = aDS.GetState(nFSpl); - - if(aSt != BooleanOperations_ON) { - BooleanOperations_StateOfShape aStateComp = BOP_BuilderTools::StateToCompare(iRank, myOperation); - - if(aStateComp == aSt) { - bAddFace = Standard_True; - } - } - else { - if(iRank == 1) { - bAddFace = TakeOnSplit(nFSpl, nF1); - } - } - - if(bAddFace) { - const TopoDS_Shape& aFaceSpl = aDS.Shape(nFSpl); - aLF.Append(aFaceSpl); - } - } - - TopTools_ListOfShape aLFx; - anIt.Initialize(aLF); - - for (; anIt.More(); anIt.Next()) { - TopoDS_Shape& aFx=anIt.Value(); - aFx.Orientation(anOriF1); - bToReverseFace=BOP_BuilderTools::ToReverseFace(iRank, myOperation); - - if (bToReverseFace) { - aFx.Reverse(); - } - aListOfNewFaces.Append(aFx); - aLFx.Append(aFx); - - if(!myHistory.IsNull()) { - Handle(BOP_SolidSolidHistoryCollector) aSolidHistory = - Handle(BOP_SolidSolidHistoryCollector)::DownCast(myHistory); - aSolidHistory->AddNewShape(aFace, aFx, myDSFiller); - } - } - // - // Fill "Modified" - FillModified(aFace, aLFx); - continue; - } - - myFace=aF1; - myFace.Orientation(TopAbs_FORWARD); - BOP_WireEdgeSet aWES (myFace); - - const TColStd_IndexedMapOfInteger& aFFIndicesMap=aFFMap.FindFromIndex(i); - aNbj=aFFIndicesMap.Extent(); - // - // b. The Switch: Same Domain Faces or Non-Same Domain Faces - bIsTouchCase=Standard_False; - for (j=1; j<=aNbj; j++) { - iFF=aFFIndicesMap(j); - BOPTools_SSInterference& aFF=aFFs(iFF); - bIsTouchCase=aFF.IsTangentFaces(); - if (bIsTouchCase) { - break; - } - } - - // modified by NIZHNY-MKK Tue Sep 16 11:11:22 2003.BEGIN - Standard_Boolean bIsCommonalgo = CheckFaceIntersection(nF1, myDSFiller); - BOP_WireEdgeSet atmpWES (myFace); - BOP_WireEdgeSet atmpWESAvoid (myFace); - - if(!bIsCommonalgo) { - bIsCommonalgo = !BuildWESForCommonZone(nF1, aFFIndicesMap, myDSFiller, - myOperation, atmpWES, atmpWESAvoid); - } - - if(bIsCommonalgo) { - // - // c. Filling the WES for nF1 - if (bIsTouchCase) { - // XXXXXXXXXXXXXXXXXXXXXXXXXX - // X nF1 has SD face(s) X - // XXXXXXXXXXXXXXXXXXXXXXXXXX - // - // 1. Add Split Parts having states in accordance with operation - AddSplitPartsINOUT (nF1, aWES); - // - // 2. Add Section Edges to the WES - for (j=1; j<=aNbj; j++) { - iFF=aFFIndicesMap(j); - BOPTools_SSInterference& aFF=aFFs(iFF); - bIsTouch=aFF.IsTangentFaces(); - - if (!bIsTouch) { - AddSectionPartsSo(nF1, iFF, aWES); - } - } - // - // 3. Add IN2D, ON2D Parts to the WES - for (j=1; j<=aNbj; j++) { - iFF = aFFIndicesMap(j); - BOPTools_SSInterference& aFF=aFFs(iFF); - bIsTouch = aFF.IsTangentFaces(); - - if (bIsTouch) { - Standard_Integer nF2; - nF2 = aFF.OppositeIndex(nF1); - AddINON2DPartsSo(iFF, nF1, nF2, aWES); - AddPartsEFSDSo(nF1, iFF, aMEFObj, aMEFTool, aWES); - AddPartsEESDSo(nF1, iFF, aMEFObj, aMEFTool, aWES); - } - } - // - // 4. On3D parts - for (j=1; j<=aNbj; j++) { - iFF=aFFIndicesMap(j); - BOPTools_SSInterference& aFF=aFFs(iFF); - bIsTouch=aFF.IsTangentFaces(); - - if (!bIsTouch) { - AddSplitPartsON3DSo (nF1, iFF, aWES); - } - } - - // 5. Add EF parts (E (from F2) on F1 ), - // where F2 is non-same-domain face to F1 - anEMap.Clear(); - // - // anEMap will contain all Split parts that has already in aWES - const TopTools_ListOfShape& aLE=aWES.StartElements(); - anIt.Initialize (aLE); - - for (; anIt.More(); anIt.Next()) { - TopoDS_Shape& anE=anIt.Value(); - anEMap.Add(anE); - } - // - for (j=1; j<=aNbj; j++) { - iFF = aFFIndicesMap(j); - BOPTools_SSInterference& aFF=aFFs(iFF); - bIsTouch = aFF.IsTangentFaces(); - - if (!bIsTouch) { - AddPartsEFNonSDSo (nF1, iFF, aMEFObj, aMEFTool, aFFIndicesMap, anEMap, aWES); - AddPartsEENonSDSo (nF1, iFF, aMEFObj, aMEFTool, aFFIndicesMap, anEMap, aWES); - } - } - } // end of if (bIsTouchCase) - // - else { - // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX - // X nF1 does not have SD face(s) X - // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX - // - // 1. Add Split Parts having states in accordance with operation - AddSplitPartsINOUT (nF1, aWES); - // - // 2. Add Split Parts with state ON - AddSplitPartsONSo (nF1, aMEFObj, aMEFTool, aWES); - // - // 3. Add Section Edges to the WES - - for (j=1; j<=aNbj; j++) { - iFF=aFFIndicesMap(j); - AddSectionPartsSo(nF1, iFF, aWES); - } - // - // 4. Add EF parts (E (from F2) on F1 ) - anEMap.Clear(); - for (j=1; j<=aNbj; j++) { - iFF=aFFIndicesMap(j); - AddPartsEFSo(nF1, iFF, aMEFObj, aMEFTool, anEMap, aWES); - } - } - } // end of if(bIsCommonalgo) - else { - TopTools_IndexedMapOfOrientedShape aMapOfSDFaceEdges; - BOP_WireEdgeSet aSDWES(myFace); - - if (bIsTouchCase) { - // Add IN2D, ON2D Parts to the WES - for (j=1; j<=aNbj; j++) { - iFF = aFFIndicesMap(j); - BOPTools_SSInterference& aFF = aFFs(iFF); - bIsTouch = aFF.IsTangentFaces(); - - if (bIsTouch) { - Standard_Integer nF2 = aFF.OppositeIndex(nF1); - AddINON2DPartsSo(iFF, nF1, nF2, aSDWES); - AddPartsEFSDSo(nF1, iFF, aMEFObj, aMEFTool, aSDWES); - AddPartsEESDSo(nF1, iFF, aMEFObj, aMEFTool, aSDWES); - } - } - // - // On3D parts - for (j=1; j<=aNbj; j++) { - iFF = aFFIndicesMap(j); - BOPTools_SSInterference& aFF = aFFs(iFF); - bIsTouch = aFF.IsTangentFaces(); - - if (!bIsTouch) { - AddSplitPartsON3DSo (nF1, iFF, aSDWES); - } - } - - TopTools_IndexedMapOfOrientedShape aMapOfWESEdges; - - for(aSDWES.InitStartElements(); aSDWES.MoreStartElements(); aSDWES.NextStartElement()) { - aMapOfWESEdges.Add(aSDWES.StartElement()); - } - - // Build SameDomain faces. - // Only edges from aMapOfWESEdges are represented in these faces - TopTools_ListOfShape aListOfSDFaces; - - for (j = 1; j <= aNbj; j++) { - iFF = aFFIndicesMap(j); - BOPTools_SSInterference& aFF = aFFs(iFF); - bIsTouch = aFF.IsTangentFaces(); - - if (bIsTouch) { - - Standard_Integer nF2 = aFF.OppositeIndex(nF1); - TopoDS_Face aF1FWD = aF1; - aF1FWD.Orientation (TopAbs_FORWARD); - - BOP_WireEdgeSet aWEScommon (aF1FWD); - BOP_SDFWESFiller aWESFiller(nF1, nF2, *myDSFiller); - aWESFiller.SetSenseFlag(aFF.SenseFlag()); - aWESFiller.SetOperation(BOP_COMMON); - aWESFiller.Do(aWEScommon); - - BOP_FaceBuilder aFB; - aFB.Do(aWEScommon); - const TopTools_ListOfShape& aLF = aFB.NewFaces(); - TopTools_ListIteratorOfListOfShape anItLF(aLF); - - for (; anItLF.More(); anItLF.Next()) { - const TopoDS_Shape& aFR = anItLF.Value(); - - if (aFR.ShapeType()==TopAbs_FACE) { - const TopoDS_Face& aFaceResult=TopoDS::Face(aFR); - // - Standard_Boolean bIsValidIn2D = Standard_False; - Standard_Boolean bNegativeFlag = Standard_False; - bIsValidIn2D = BOPTools_Tools3D::IsValidArea (aFaceResult, bNegativeFlag); - - if (bIsValidIn2D) { - - // if(CheckSameDomainFaceInside(aFaceResult, aF2)) { - Standard_Boolean bfound = Standard_True; - TopExp_Explorer anExp(aFaceResult, TopAbs_EDGE); - - for(; anExp.More(); anExp.Next()) { - if(!aMapOfWESEdges.Contains(anExp.Current())) { - bfound = Standard_False; - break; - } - } - - if(bfound) - aListOfSDFaces.Append(aFaceResult); - // } - } - } - } - } - } - // end for (j = 1; j <= aNbj... - - TopTools_ListIteratorOfListOfShape anItSD(aListOfSDFaces); - - for(; anItSD.More(); anItSD.Next()) { - const TopoDS_Shape& aShape = anItSD.Value(); - TopoDS_Face aFx = TopoDS::Face(aShape); - TopExp_Explorer anExp(aFx, TopAbs_EDGE); - - for(; anExp.More(); anExp.Next()) { - aMapOfSDFaceEdges.Add(anExp.Current()); - } - aFx.Orientation(anOriF1); - bToReverseFace=BOP_BuilderTools::ToReverseFace(iRank, myOperation); - - if (bToReverseFace) { - aFx.Reverse(); - } - aListOfNewFaces.Append(aFx); - } - } - - // Build Common Zone faces, based on intersection lines and - // splits with state ON (see BuildWESForCommonZone()). - TopTools_ListOfShape aListOfCommonZoneFace; - Standard_Integer awesit = 0; - - for(awesit = 0; awesit < 2; awesit++) { - BOP_WireEdgeSet& aCurWEStmp = (awesit == 0) ? atmpWES : atmpWESAvoid; - BOP_WireEdgeSet aCurWES(myFace); - - for(aCurWEStmp.InitStartElements(); aCurWEStmp.MoreStartElements(); aCurWEStmp.NextStartElement()) { - if(!aMapOfSDFaceEdges.Contains(aCurWEStmp.StartElement())) { - aCurWES.AddStartElement(aCurWEStmp.StartElement()); - } - } - - if(!aCurWES.StartElements().IsEmpty()) { - BOP_FaceBuilder aFB; - - aFB.SetTreatment(0); // 0 -Do internal edges, 1 -No Internal Edges - aFB.SetTreatSDScales(1); - aFB.Do(aCurWES); - const TopTools_ListOfShape& aLF = aFB.NewFaces(); - anIt.Initialize(aLF); - - for (; anIt.More(); anIt.Next()) { - TopoDS_Shape& aFx=anIt.Value(); - aFx.Orientation(anOriF1); - - if(awesit == 0) { - bToReverseFace=BOP_BuilderTools::ToReverseFace(iRank, myOperation); - - if (bToReverseFace) { - aFx.Reverse(); - } - aListOfNewFaces.Append(aFx); - } - aListOfCommonZoneFace.Append(aFx); - } - } - } - // end for(awesit = ... - - // Construct WES to build faces out of common zone - BOP_WireEdgeSet aWES2 (myFace); - AddSplitPartsINOUT (nF1, aWES2); - // - - if(!bIsTouchCase) { - AddSplitPartsONSo (nF1, aMEFObj, aMEFTool, aWES2); - } - // - for (j=1; j<=aNbj; j++) { - iFF=aFFIndicesMap(j); - AddSectionPartsSo(nF1, iFF, aWES2); - } - anEMap.Clear(); - - if(bIsTouchCase) { - for(aSDWES.InitStartElements(); aSDWES.MoreStartElements(); aSDWES.NextStartElement()) { - aWES2.AddStartElement(aSDWES.StartElement()); - } - - for(aWES2.InitStartElements(); aWES2.MoreStartElements(); aWES2.NextStartElement()) { - anEMap.Add(aWES2.StartElement()); - } - } - - for (j=1; j<=aNbj; j++) { - iFF = aFFIndicesMap(j); - - if(!bIsTouchCase) { - LocalAddPartsEFSo(nF1, iFF, aMEFObj, aMEFTool, myDSFiller, - myOperation, aListOfCommonZoneFace, anEMap, aWES2); - } - else { - BOPTools_SSInterference& aFF = aFFs(iFF); - bIsTouch = aFF.IsTangentFaces(); - - if (!bIsTouch) { - AddPartsEFNonSDSo (nF1, iFF, aMEFObj, aMEFTool, aFFIndicesMap, anEMap, aWES2); - AddPartsEENonSDSo (nF1, iFF, aMEFObj, aMEFTool, aFFIndicesMap, anEMap, aWES2); - } - } - } - - aWES.ClearContents(); - - aWES2.InitStartElements(); - - for (; aWES2.MoreStartElements(); aWES2.NextStartElement()) { - if(aMapOfSDFaceEdges.Contains(aWES2.StartElement())) - continue; - Standard_Boolean bisequal = Standard_False; - Standard_Integer wesit = 0; - - for(wesit = 0; wesit < 2; wesit++) { - BOP_WireEdgeSet& acurwes = (wesit == 0) ? atmpWES : atmpWESAvoid; - acurwes.InitStartElements(); - - for (; !bisequal && acurwes.MoreStartElements(); acurwes.NextStartElement()) { - const TopoDS_Shape& anE = acurwes.StartElement(); - bisequal = anE.IsEqual(aWES2.StartElement()); - } - } - - if(!bisequal) { - aWES.AddStartElement(aWES2.StartElement()); - } - } - //end for (; aWES2.MoreStartElements... - } - // modified by NIZHNY-MKK Tue Sep 16 11:11:33 2003.END - - // - //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - // Display the WES - if (myDraw) { - const TopTools_ListOfShape& aWESL=aWES.StartElements(); - BOP_Draw::DrawListOfEdgesWithPC (myFace, aWESL, i, "ew_"); - BOP_Draw::Wait(); - } - //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - // - // d. Build new Faces from myFace - BOP_FaceBuilder aFB; - - aFB.SetTreatment(0); // 0 -Do internal edges, 1 -No Internal Edges - aFB.SetTreatSDScales(1); - aFB.Do(aWES); - - const TopTools_ListOfShape& aLF=aFB.NewFaces(); - // - // e. Do Internal Vertices - DoInternalVertices(nF1, aLF); - // - // f. Orient new faces - TopTools_ListOfShape aLFx; - anIt.Initialize(aLF); - for (; anIt.More(); anIt.Next()) { - TopoDS_Shape& aFx=anIt.Value(); - aFx.Orientation(anOriF1); - bToReverseFace=BOP_BuilderTools::ToReverseFace(iRank, myOperation); - if (bToReverseFace) { - aFx.Reverse(); - } - aListOfNewFaces.Append(aFx); - aLFx.Append(aFx); - - if(!myHistory.IsNull()) { - Handle(BOP_SolidSolidHistoryCollector) aSolidHistory = - Handle(BOP_SolidSolidHistoryCollector)::DownCast(myHistory); - aSolidHistory->AddNewShape(aF1, aFx, myDSFiller); - } - } - // - // Fill "Modified" - FillModified(aF1, aLFx); - // - }// for (i=1; i<=aNb; i++) - - //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - // Display the new Faces - if (myDraw) { - BOP_Draw::DrawListOfShape(aListOfNewFaces, "fn_"); - } - //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - myNewFaces.Clear(); - myNewFaces.Append(aListOfNewFaces); -} - -//================================================================================= -// function: PrepareSFS -// purpose: -//================================================================================= - void BOP_SolidSolid::PrepareSFS(const TopTools_ListOfShape& theNewFaces, - BOP_ShellFaceSet& theSFS) -{ - - const BooleanOperations_ShapesDataStructure& theDS=myDSFiller->DS(); - - Standard_Integer iRank, lastindex, firstindex, i, a; - BooleanOperations_StateOfShape aChoosenState; - - for(iRank = 1; iRank <= 2; iRank++) { - aChoosenState = BOP_BuilderTools::StateToCompare(iRank, myOperation); - // - const TopoDS_Shape& aSolid = (iRank==1) ? myShape1 : myShape2; - - firstindex=1; - lastindex=theDS.NumberOfShapesOfTheObject(); - if (iRank==2) { - firstindex=lastindex+1; - lastindex=theDS.NumberOfSourceShapes(); - } - - for(i = firstindex; i <= lastindex; i++) { - - if((theDS.GetShapeType(i) != TopAbs_FACE) || (theDS.GetState(i) != aChoosenState)) - continue; - - - // compute orientation - TopoDS_Shape aFace=theDS.Shape(i); - - TopAbs_Orientation anOri = TopAbs_FORWARD; - - for(a = 1; a <= theDS.NumberOfAncestors(i); a++) { - const TopoDS_Shape& aShell = theDS.GetShape(theDS.GetAncestor(i, a)); - - TopAbs_Orientation anAncestorOrientation = aShell.Orientation(); - Standard_Boolean found = Standard_False; - - TopExp_Explorer aSolidExp(aSolid, TopAbs_SHELL); - for(; !found && aSolidExp.More(); aSolidExp.Next()) { - - if(aShell.IsSame(aSolidExp.Current())) { - anAncestorOrientation = aSolidExp.Current().Orientation(); - found = Standard_True; - } - } - - if(!found) { - // raise the exception: programming error - BOPTColStd_Dump::PrintMessage - ("BOP_SolidSolid::PrepareSFS(). Raises the exception: programming error...\n"); - continue; - } - - TopoDS_Shape anOrientedShell = aShell; - anOrientedShell.Orientation(anAncestorOrientation); - - TopExp_Explorer aShellExp(anOrientedShell, TopAbs_FACE); - for(; aShellExp.More(); aShellExp.Next()) { - - if(!aFace.IsSame(aShellExp.Current())) - continue; - - anOri = aShellExp.Current().Orientation(); - - if(BOP_BuilderTools::ToReverseFace(iRank, myOperation)) { - anOri = TopAbs::Complement(anOri); - } - aFace.Orientation(anOri); - - theSFS.AddStartElement(aFace); - } // end shell explorer - } - } // end source shapes explorer - } - - TopTools_ListIteratorOfListOfShape anIt(theNewFaces); - - for(;anIt.More(); anIt.Next()) { - theSFS.AddStartElement(anIt.Value()); - } -} - -// -------------------------------------------------------------------------------------------------------- -// static function: CheckFaceIntersection -// purpose: Returns Standard_True if there are no any common zone for given face, -// Returns Standard_False if there are common zones or probability of existance of the common zone -// is high. -// -------------------------------------------------------------------------------------------------------- -Standard_Boolean CheckFaceIntersection(const Standard_Integer theFaceIndex, - const BOPTools_DSFiller* theDSFiller) { - - const BooleanOperations_ShapesDataStructure& aDS = theDSFiller->DS(); - const BOPTools_PaveFiller& aPaveFiller = theDSFiller->PaveFiller(); - BOPTools_PaveFiller* pPaveFiller = (BOPTools_PaveFiller*)&aPaveFiller; - BOPTools_CommonBlockPool& aCBPool = pPaveFiller->ChangeCommonBlockPool(); -// const BOPTools_SplitShapesPool& aSplitShapesPool = aPaveFiller.SplitShapesPool(); - - BOPTools_InterferencePool* pIntrPool= - (BOPTools_InterferencePool*)&theDSFiller->InterfPool(); - - BOPTools_CArray1OfSSInterference& aFFs = pIntrPool->SSInterferences(); - Standard_Integer i = 0; - - for(i = 1; i <= aFFs.Length(); i++) { - BOPTools_SSInterference& aFF = aFFs(i); - - if((aFF.Index1() != theFaceIndex) && (aFF.Index2() != theFaceIndex)) - continue; - - Standard_Integer otherindex = aFF.OppositeIndex(theFaceIndex); - - BOPTools_SequenceOfCurves& aSC = aFF.Curves(); - Standard_Integer aNbCurves = aSC.Length(); - - if(aNbCurves > 0) { - TopoDS_Shape aF1 = aDS.Shape(theFaceIndex); - TopoDS_Shape aF2 = aDS.Shape(otherindex); - TopExp_Explorer anExp; - - for(Standard_Integer j = 0; j < 2; j++) { - Standard_Integer afaceindextocompare = (j == 0) ? otherindex : theFaceIndex; - Standard_Integer aFaceRank = 1; - if(j == 0) { - anExp.Init(aF1, TopAbs_EDGE); - aFaceRank = aDS.Rank(theFaceIndex); - } - else { - anExp.Init(aF2, TopAbs_EDGE); - aFaceRank = aDS.Rank(otherindex); - } - - for(; anExp.More(); anExp.Next()) { - const TopoDS_Edge& aEF = TopoDS::Edge(anExp.Current()); - Standard_Integer nEF = aDS.ShapeIndex(aEF, aFaceRank); - BOPTools_ListOfCommonBlock& aLCB = aCBPool(aDS.RefEdge(nEF)); - BOPTools_ListIteratorOfListOfCommonBlock anItCB(aLCB); - - for (; anItCB.More(); anItCB.Next()) { - BOPTools_CommonBlock& aCB=anItCB.Value(); - Standard_Integer nFace = aCB.Face(); - - if(nFace == afaceindextocompare) - return Standard_False; - } - } - } - } - } - - return Standard_True; -} - -// ---------------------------------------------------------------------------------------------------------------- -// static function: BuildWESForCommonZone -// purpose: Finds common zones which contains boundaries represented by new geometry -// Fills theWES if zones could be included in result, -// Fills theWESAvoid if zones could not be included in result. -// Returns true if common zones are found, otherwise returns false. -// ---------------------------------------------------------------------------------------------------------------- -Standard_Boolean BuildWESForCommonZone(const Standard_Integer theFaceIndex, - const TColStd_IndexedMapOfInteger& theFFIndicesMap, - const BOPTools_DSFiller* theDSFiller, - const BOP_Operation& theOperation, - BOP_WireEdgeSet& theWES, - BOP_WireEdgeSet& theWESAvoid) { - - const BooleanOperations_ShapesDataStructure& aDS = theDSFiller->DS(); -// const BOPTools_PaveFiller& aPaveFiller = theDSFiller->PaveFiller(); -// BOPTools_PaveFiller* pPaveFiller = (BOPTools_PaveFiller*)&aPaveFiller; -// BOPTools_CommonBlockPool& aCBPool = pPaveFiller->ChangeCommonBlockPool(); -// const BOPTools_SplitShapesPool& aSplitShapesPool = aPaveFiller.SplitShapesPool(); - - BOPTools_InterferencePool* pIntrPool= - (BOPTools_InterferencePool*)&theDSFiller->InterfPool(); - - BOPTools_CArray1OfSSInterference& aFFs = pIntrPool->SSInterferences(); - - TopoDS_Face aFace = TopoDS::Face(aDS.Shape(theFaceIndex)); - TopoDS_Face myFace = aFace; - myFace.Orientation(TopAbs_FORWARD); -// Standard_Integer iFaceRank = aDS.Rank(theFaceIndex); - TopTools_IndexedDataMapOfShapeListOfShape aMapFCommonZones, aMapFCommonZones2; - Standard_Integer j = 0, k = 0; - - for (j = 1; j <= theFFIndicesMap.Extent(); j++) { - BOP_WireEdgeSet atmpWES(myFace); - - Standard_Integer iFF= theFFIndicesMap(j); - BOPTools_SSInterference& aFF = aFFs(iFF); - Standard_Integer aFaceIndex2 = aFF.OppositeIndex(theFaceIndex); - TopoDS_Face aFace2 = TopoDS::Face(aDS.Shape(aFaceIndex2)); -// Standard_Integer iFaceRank2 = aDS.Rank(aFaceIndex2); - - BOPTools_SequenceOfCurves& aSC = aFF.Curves(); - Standard_Integer aNbCurves = aSC.Length(); - Standard_Integer i = 0; - - for (i = 1; i <= aNbCurves; i++) { - const BOPTools_Curve& aBC = aSC(i); - const BOPTools_ListOfPaveBlock& aLPB = aBC.NewPaveBlocks(); - BOPTools_ListIteratorOfListOfPaveBlock anIt(aLPB); - - for (; anIt.More(); anIt.Next()) { - const BOPTools_PaveBlock& aPB=anIt.Value(); - Standard_Integer nE = aPB.Edge(); - const TopoDS_Edge& aE = TopoDS::Edge(aDS.Shape(nE)); - - TopoDS_Edge aES=aE; - atmpWES.AddStartElement(aES); - aES.Reverse(); - atmpWES.AddStartElement(aES); - } - } - BOP_SDFWESFiller aWESFiller(theFaceIndex, aFaceIndex2, *theDSFiller); - Standard_Integer iSenseFlag = 0; - Standard_Integer iRankF1 = aDS.Rank(theFaceIndex); - - // compute iSenseFlag. begin - gp_Dir aDNF1, aDNF2; - const BOPTools_ListOfPaveBlock& aLPB = aFF.PaveBlocks(); - - if (aLPB.IsEmpty()) { - continue; - } - const BOPTools_PaveBlock& aPB = aLPB.First(); - const TopoDS_Edge& aSpE = TopoDS::Edge(aDS.Shape(aPB.Edge())); - BOPTools_Tools3D::GetNormalToFaceOnEdge (aSpE, aFace, aDNF1); - BOPTools_Tools3D::GetNormalToFaceOnEdge (aSpE, aFace2, aDNF2); - Standard_Real aScPr = aDNF1*aDNF2; - - if (aScPr<0.) { - iSenseFlag = -1; - } - else if (aScPr>0.) { - iSenseFlag = 1; - } - // compute iSenseFlag. end - - aWESFiller.SetSenseFlag(iSenseFlag); - aWESFiller.SetOperation(BOP_COMMON); - aWESFiller.Do(atmpWES); - - BOP_FaceBuilder aFB; - aFB.Do(atmpWES); - const TopTools_ListOfShape& aLF = aFB.NewFaces(); - - if(aLF.IsEmpty()) { - continue; - } - - TopTools_ListIteratorOfListOfShape anIt(aLF); - - for(; anIt.More(); anIt.Next()) { - const TopoDS_Face& aCurFace = TopoDS::Face(anIt.Value()); - // check common zone.begin - Standard_Boolean IsSameDomain = Standard_True; - Standard_Boolean bIsValidIn2D = Standard_False, bNegativeFlag = Standard_False; - bIsValidIn2D = BOPTools_Tools3D::IsValidArea (aCurFace, bNegativeFlag); - - if(bIsValidIn2D) { - Handle(Geom_Surface) aSurface = BRep_Tool::Surface(aCurFace); - Standard_Real aTolerance = BRep_Tool::Tolerance(aFace) + BRep_Tool::Tolerance(aFace2); - IntTools_Context aContext; - Standard_Real umin, umax, vmin, vmax; - BRepTools::UVBounds(aCurFace, umin, umax, vmin, vmax); - Standard_Real deltau = (umax - umin) * 0.1; - Standard_Real deltav = (vmax - vmin) * 0.1; - - for(Standard_Integer uit = 1; IsSameDomain && (uit < 9); uit++) { - Standard_Real U = umin + uit * deltau; - - for(Standard_Integer vit = 1; vit < 9; vit++) { - Standard_Real V = vmin + vit * deltav; - - if(aContext.IsPointInOnFace(aCurFace, gp_Pnt2d(U, V))) { - gp_Pnt aCurPoint = aSurface->Value(U, V); - - if(!aContext.IsValidPointForFace(aCurPoint, aFace2, aTolerance)) { - IsSameDomain = Standard_False; - break; - } - } - } - } - } - // check common zone.end - - if(IsSameDomain) { - Standard_Integer addcommonzone = Standard_False; - - if (iSenseFlag==1) { - switch (theOperation) { - - case BOP_FUSE: - if (iRankF1==1) { - addcommonzone = Standard_True; - } - break; - - case BOP_COMMON: - if (iRankF1==1) { - addcommonzone = Standard_True; - } - break; - - case BOP_CUT: - case BOP_CUT21: - break; - - default: - break; - } - } - else if (iSenseFlag==-1) { // iSenseFlag<0 - switch (theOperation) { - - case BOP_FUSE: - case BOP_COMMON: - break; - - case BOP_CUT: - if (iRankF1==1) { - addcommonzone = Standard_True; - } - break; - - case BOP_CUT21: - if (iRankF1==2) { - addcommonzone = Standard_True; - } - default: - break; - } - } - TopTools_ListOfShape thelist; - if(addcommonzone) { - if(!aMapFCommonZones.Contains(aFace2)) - aMapFCommonZones.Add(aFace2, thelist); - aMapFCommonZones.ChangeFromKey(aFace2).Append(aCurFace); - } - else { - if(!aMapFCommonZones2.Contains(aFace2)) - aMapFCommonZones2.Add(aFace2, thelist); - aMapFCommonZones2.ChangeFromKey(aFace2).Append(aCurFace); - } - } - } - } - - if(aMapFCommonZones.IsEmpty() && aMapFCommonZones2.IsEmpty()) { - return Standard_False; - } - Standard_Integer amapit = 0; - - for(amapit = 0; amapit < 2; amapit++) { - const TopTools_IndexedDataMapOfShapeListOfShape& aMap = - (amapit == 0) ? aMapFCommonZones : aMapFCommonZones2; - BOP_WireEdgeSet& aWES = (amapit == 0) ? theWES : theWESAvoid; - - for(k = 1; k <= aMap.Extent(); k++) { - const TopTools_ListOfShape& alf = aMap(k); - TopTools_ListIteratorOfListOfShape anIt(alf); - - for(; anIt.More(); anIt.Next()) { - TopExp_Explorer anExp(anIt.Value(), TopAbs_EDGE); - - for(; anExp.More(); anExp.Next()) { - aWES.AddStartElement(anExp.Current()); - } - } - } - } - //end for(amapit = ... - - return Standard_True; -} - -// ---------------------------------------------------------------------------------------------------------------- -// static function: LocalAddPartsEFSo -// purpose: Adds split parts of edges, which lay on face nF1, to theWES. -// It uses found common zones (theListOfSDFace) to check -// if a split part should be represented in theWES twice or not. -// ---------------------------------------------------------------------------------------------------------------- -void LocalAddPartsEFSo (const Standard_Integer nF1, - const Standard_Integer iFF, - const TopTools_IndexedDataMapOfShapeListOfShape& theMEFObj, - const TopTools_IndexedDataMapOfShapeListOfShape& theMEFTool, - const BOPTools_DSFiller* theDSFiller, - const BOP_Operation& theOperation, - const TopTools_ListOfShape& theListOfSDFace, - TopTools_IndexedMapOfShape& theEMap, - BOP_WireEdgeSet& theWES) { - - const BooleanOperations_ShapesDataStructure& aDS = theDSFiller->DS(); - BOPTools_InterferencePool* pIntrPool=(BOPTools_InterferencePool*)&theDSFiller->InterfPool(); - BOPTools_CArray1OfSSInterference& aFFs=pIntrPool->SSInterferences(); - - const BOPTools_PaveFiller& aPF = theDSFiller->PaveFiller(); - BOPTools_PaveFiller* pPaveFiller =(BOPTools_PaveFiller*)&aPF; - BOPTools_CommonBlockPool& aCBPool = pPaveFiller->ChangeCommonBlockPool(); - BOPTools_SSInterference& aFF=aFFs(iFF); - Standard_Integer nF2 = aFF.OppositeIndex(nF1); - const TopoDS_Face& aFace =TopoDS::Face(aDS.Shape(nF1)); - const TopoDS_Face& aFace2 =TopoDS::Face(aDS.Shape(nF2)); - - Standard_Integer anindextocompare = nF1; - Standard_Integer iFaceRank1, iFaceRank2; - iFaceRank1 = aDS.Rank(nF1); - iFaceRank2 = aDS.Rank(nF2); - Standard_Integer aFaceRank = iFaceRank2; - const TopTools_IndexedDataMapOfShapeListOfShape& aMEF = (aFaceRank == 1) ? theMEFObj : theMEFTool; - TopExp_Explorer anExp(aFace2, TopAbs_EDGE); - - for(; anExp.More(); anExp.Next()) { - const TopoDS_Edge& aEF = TopoDS::Edge(anExp.Current()); - Standard_Integer nEF = aDS.ShapeIndex(aEF, aFaceRank); - BOPTools_ListOfCommonBlock& aLCB = aCBPool(aDS.RefEdge(nEF)); - BOPTools_ListIteratorOfListOfCommonBlock anItCB(aLCB); - - for (; anItCB.More(); anItCB.Next()) { - BOPTools_CommonBlock& aCB=anItCB.Value(); - Standard_Integer nFace = aCB.Face(); - - if (nFace == anindextocompare) { - BOPTools_PaveBlock& aPB = aCB.PaveBlock1(nEF); - - Standard_Integer nSplit = aPB.Edge(); - const TopoDS_Shape& aSplit = aDS.Shape(nSplit); - - if (theEMap.Contains(aSplit)) { - continue;// next CB - } - theEMap.Add(aSplit); - TopoDS_Edge aSS = TopoDS::Edge(aSplit); - // - TopoDS_Face aFAdj; - Standard_Boolean bIsAdjExists = Standard_False; - - bIsAdjExists = BOPTools_Tools3D::GetAdjacentFace(aFace2, aEF, aMEF, aFAdj); - Standard_Boolean bIsKeepTwice = Standard_False; - - if(bIsAdjExists) { - bIsKeepTwice = LocalIsKeepTwice(aFace, aFace2, aFAdj, aSS, theListOfSDFace, theListOfSDFace); - } - else { - bIsKeepTwice = BOPTools_Tools3D::IsTouchCase(aSS, aFace, aFace2); - } - - if(bIsKeepTwice) { - theWES.AddStartElement(aSS); - aSS.Reverse(); - theWES.AddStartElement(aSS); - } - else { - aSS.Orientation(TopAbs_FORWARD); - TopoDS_Face myFace = aFace; - myFace.Orientation(TopAbs_FORWARD); - BOP_BuilderTools::OrientSectionEdgeOnF1 - (myFace, aFace2, iFaceRank1, theOperation, aSS); - - theWES.AddStartElement(aSS); - } - } - } - } -} - -// -------------------------------------------------------------------------------------------------------- -// static function: LocalIsKeepTwice -// purpose: -// -------------------------------------------------------------------------------------------------------- -Standard_Boolean LocalIsKeepTwice(const TopoDS_Face& aF1, - const TopoDS_Face& aF2, - const TopoDS_Face& aF2Adj, - const TopoDS_Edge& aSpEF2, - const TopTools_ListOfShape& theFacesToAvoid2, - const TopTools_ListOfShape& theFacesToAvoidAdj) { - - Standard_Real aT1, aT2, aT, dt=1.e-7, A, B, C, D, d2, d2Adj; - gp_Dir aDNF1, aDNF2, DBF2, aDNF2Adj, DBF2Adj; - gp_Vec aD1Sp; - gp_Pnt aP, aPF2, aPF2Adj; - - Handle(Geom_Curve) aC3D=BRep_Tool::Curve(aSpEF2, aT1, aT2); - aT=BOPTools_Tools2D::IntermediatePoint(aT1, aT2); - BOPTools_Tools3D::GetNormalToFaceOnEdge (aSpEF2, aF1, aT, aDNF1); - - // - aC3D->D1(aT, aP, aD1Sp); - gp_Dir aDD1Sp(aD1Sp); - - if (aSpEF2.Orientation()==TopAbs_REVERSED) { - aDD1Sp.Reverse(); - } - // Split Normal on F2 - BOPTools_Tools3D::GetNormalToFaceOnEdge (aSpEF2, aF2, aT, aDNF2); - if (aF2.Orientation()==TopAbs_REVERSED) { - aDNF2.Reverse(); - } - // Binormal on F2 - DBF2=aDNF2^aDD1Sp; - - TopTools_ListIteratorOfListOfShape anIt; - IntTools_Context aContext; - Standard_Boolean dtfound = Standard_False; - Standard_Real acurdt = dt; - - while(!dtfound) { - dtfound = Standard_True; - - aPF2.SetCoord(aP.X() + acurdt*DBF2.X(), - aP.Y() + acurdt*DBF2.Y(), - aP.Z() + acurdt*DBF2.Z()); - - for(anIt.Initialize(theFacesToAvoid2); anIt.More(); anIt.Next()) { - const TopoDS_Face& aFace = TopoDS::Face(anIt.Value()); - - if(aContext.IsValidPointForFace(aPF2, aFace, BRep_Tool::Tolerance(aFace))) { - dtfound = Standard_False; - break; - } - } - - if(!aContext.IsValidPointForFace(aPF2, aF2, BRep_Tool::Tolerance(aF2))) { - acurdt = dt; - break; - } - acurdt *= 2.; - } - - if(!dtfound) { - dt = 1.e-07; - // Point near aP - aPF2.SetCoord(aP.X()+dt*DBF2.X(), - aP.Y()+dt*DBF2.Y(), - aP.Z()+dt*DBF2.Z()); - } - // - aDD1Sp.Reverse(); - - // Split Normal on F2Adj - BOPTools_Tools3D::GetNormalToFaceOnEdge (aSpEF2, aF2Adj, aT, aDNF2Adj); - if (aF2Adj.Orientation()==TopAbs_REVERSED) { - aDNF2Adj.Reverse(); - } - // Binormal on F2Adj - DBF2Adj=aDNF2Adj^aDD1Sp; - - dt = 1.e-07; - acurdt = dt; - dtfound = Standard_False; - - while(!dtfound) { - dtfound = Standard_True; - aPF2Adj.SetCoord(aP.X() + acurdt*DBF2Adj.X(), - aP.Y() + acurdt*DBF2Adj.Y(), - aP.Z() + acurdt*DBF2Adj.Z()); - - for(anIt.Initialize(theFacesToAvoidAdj); anIt.More(); anIt.Next()) { - const TopoDS_Face& aFace = TopoDS::Face(anIt.Value()); - - if(aContext.IsValidPointForFace(aPF2Adj, aFace, BRep_Tool::Tolerance(aFace))) { - dtfound = Standard_False; - break; - } - } - - if(!aContext.IsValidPointForFace(aPF2Adj, aF2Adj, BRep_Tool::Tolerance(aF2Adj))) { - acurdt = dt; - break; - } - acurdt *= 2.; - } - - if(!dtfound) { - dt = 1.e-07; - aPF2Adj.SetCoord(aP.X()+dt*DBF2Adj.X(), - aP.Y()+dt*DBF2Adj.Y(), - aP.Z()+dt*DBF2Adj.Z()); - } - // - // Tangent Plane on F1 - gp_Pln aPlnN1(aP, aDNF1); - aPlnN1.Coefficients(A, B, C, D); - // - d2 = A*aPF2.X() + B*aPF2.Y() + C*aPF2.Z() + D; - d2Adj= A*aPF2Adj.X() + B*aPF2Adj.Y()+ C*aPF2Adj.Z() + D; - // - if (fabs(d2)<1.e-10) { - d2=0.; - } - if (fabs(d2Adj)<1.e-10) { - d2Adj=0.; - } - // - aT=d2*d2Adj; - // - return (aT >= 0.); -} - -//================================================================================= -// function: SetHistoryCollector -// purpose: -//================================================================================= -void BOP_SolidSolid::SetHistoryCollector(const Handle(BOP_HistoryCollector)& theHistory) -{ - if(theHistory.IsNull() || - !theHistory->IsKind(STANDARD_TYPE(BOP_SolidSolidHistoryCollector))) - myHistory.Nullify(); - else - myHistory = theHistory; -} diff --git a/src/BOP/BOP_SolidSolidHistoryCollector.cdl b/src/BOP/BOP_SolidSolidHistoryCollector.cdl deleted file mode 100755 index 9b2e63e48c..0000000000 --- a/src/BOP/BOP_SolidSolidHistoryCollector.cdl +++ /dev/null @@ -1,43 +0,0 @@ --- Created on: 2003-03-20 --- Created by: Michael KLOKOV --- Copyright (c) 2003-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class SolidSolidHistoryCollector from BOP - inherits HistoryCollector from BOP - -uses - Shape from TopoDS, - Operation from BOP, - PDSFiller from BOPTools, - ListOfShape from TopTools -is - Create(theShape1 : Shape from TopoDS; - theShape2 : Shape from TopoDS; - theOperation: Operation from BOP) - returns SolidSolidHistoryCollector from BOP; - - AddNewShape(me: mutable; theOldShape: Shape from TopoDS; - theNewShape: Shape from TopoDS; - theDSFiller: PDSFiller from BOPTools); - - SetResult(me: mutable; theResult: Shape from TopoDS; - theDSFiller: PDSFiller from BOPTools) - is redefined virtual; - -end SolidSolidHistoryCollector from BOP; diff --git a/src/BOP/BOP_SolidSolidHistoryCollector.cxx b/src/BOP/BOP_SolidSolidHistoryCollector.cxx deleted file mode 100755 index 88087f5a81..0000000000 --- a/src/BOP/BOP_SolidSolidHistoryCollector.cxx +++ /dev/null @@ -1,144 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// ====================================================================================================== -// function: Constructor -// purpose: -// ====================================================================================================== -BOP_SolidSolidHistoryCollector::BOP_SolidSolidHistoryCollector(const TopoDS_Shape& theShape1, - const TopoDS_Shape& theShape2, - const BOP_Operation theOperation): -BOP_HistoryCollector(theShape1, theShape2, theOperation) -{ -} - -// ====================================================================================================== -// function: AddNewShape -// purpose: -// warning: Treats only faces -// ====================================================================================================== -void BOP_SolidSolidHistoryCollector::AddNewShape(const TopoDS_Shape& theOldShape, - const TopoDS_Shape& theNewShape, - const BOPTools_PDSFiller& theDSFiller) -{ - if(theOldShape.ShapeType() != theNewShape.ShapeType()) - return; - - if(theOldShape.ShapeType() != TopAbs_FACE) { - return; - } - Standard_Integer iRank = 0; - const BooleanOperations_IndexedDataMapOfShapeInteger& aMap1 = - theDSFiller->DS().ShapeIndexMap(1); - - const BooleanOperations_IndexedDataMapOfShapeInteger& aMap2 = - theDSFiller->DS().ShapeIndexMap(2); - - if(aMap1.Contains(theOldShape)) - iRank = 1; - else { - if(aMap2.Contains(theOldShape)) - iRank = 2; - } - - if(iRank == 0) - return; - - TopTools_DataMapOfShapeListOfShape& aHistoryMap = myModifMap; - - if(aHistoryMap.IsBound(theOldShape)) { - aHistoryMap.ChangeFind(theOldShape).Append(theNewShape); - } - else { - TopTools_ListOfShape aShapeList; - aShapeList.Append(theNewShape); - aHistoryMap.Bind(theOldShape, aShapeList); - } -} - -// ====================================================================================================== -// function: SetResult -// purpose: -// ====================================================================================================== -void BOP_SolidSolidHistoryCollector::SetResult(const TopoDS_Shape& theResult, - const BOPTools_PDSFiller& theDSFiller) -{ - myResult = theResult; - myHasDeleted = Standard_False; - - TopAbs_ShapeEnum aType = TopAbs_FACE; - TopTools_IndexedMapOfShape aMap; - TopExp::MapShapes(myResult, aType, aMap); - - TopExp_Explorer anExpObj(myS1, aType); - - for(; anExpObj.More(); anExpObj.Next()) { - const TopoDS_Shape& aS = anExpObj.Current(); - - if(!aMap.Contains(aS)) { - - if(!myModifMap.IsBound(aS) || myModifMap(aS).IsEmpty()) { - - if(!myGenMap.IsBound(aS) || myGenMap(aS).IsEmpty()) { - myHasDeleted = Standard_True; - break; - } - } - } - } - - if(!myHasDeleted) { - TopExp_Explorer anExpTool(myS2, aType); - - for(; anExpTool.More(); anExpTool.Next()) { - const TopoDS_Shape& aS = anExpTool.Current(); - - if(!aMap.Contains(aS)) { - if(!myModifMap.IsBound(aS) || myModifMap(aS).IsEmpty()) { - - if(!myGenMap.IsBound(aS) || myGenMap(aS).IsEmpty()) { - myHasDeleted = Standard_True; - break; - } - } - } - } - } -} diff --git a/src/BOP/BOP_SolidSolid_1.cxx b/src/BOP/BOP_SolidSolid_1.cxx deleted file mode 100755 index caf2e65668..0000000000 --- a/src/BOP/BOP_SolidSolid_1.cxx +++ /dev/null @@ -1,713 +0,0 @@ -// Created on: 2004-06-29 -// Created by: Mikhail KLOKOV -// Copyright (c) 2004-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -#include - -#include -#include - -#include -#include -#include -#include -#include - -static -Standard_Integer GetIndex(const TopoDS_Shape& theShape, - const BooleanOperations_ShapesDataStructure& theDS); - -static -void GetAttachedFaces(const Standard_Integer theEdgeIndex, - const Standard_Integer theFaceIndex, - const BOPTools_DSFiller& theDSFiller, - TColStd_ListOfInteger& theListOfFaces); - -static -void GetStatesOfAdjacentFaces(const TColStd_ListOfInteger& theListOfFacesToCheck, - const BOPTools_DSFiller& theDSFiller, - TColStd_MapOfInteger& theMapOfUsedIndices, - Standard_Boolean& bFoundINOUT, - Standard_Boolean& bFoundININ, - Standard_Boolean& bFoundOUTOUT); - -static -Standard_Boolean ComputeStateForAnalyticalSurfaces(const Standard_Integer theFaceIndex, - const Standard_Integer theBaseFaceIndex, - const BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& theFFMap, - const BOPTools_DSFiller& theDSFiller, - TopAbs_State& theState); - -static -Standard_Boolean IsEdgeValidForFace(const Standard_Integer theEdgeIndex, - const Standard_Integer theFaceIndex, - BOPTools_SSInterference& theFF, - const BOPTools_DSFiller& theDSFiller); - -//================================================================================= -// function: PrepareFaceSplits -// purpose: -//================================================================================= -void BOP_SolidSolid::PrepareFaceSplits() -{ - const BooleanOperations_ShapesDataStructure& aDS = myDSFiller->DS(); - BooleanOperations_ShapesDataStructure* pDS = (BooleanOperations_ShapesDataStructure*)&aDS; - BOPTools_InterferencePool* pIntrPool = (BOPTools_InterferencePool*)&myDSFiller->InterfPool(); - BOPTools_CArray1OfSSInterference& aFFs = pIntrPool->SSInterferences(); - - Standard_Integer i, aNb, nF1, iRank; - BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger aFFMap; - BOP_BuilderTools::DoMap(aFFs, aFFMap); - TopTools_ListOfShape aListOfNewFaces; - TopAbs_Orientation anOriF1 = TopAbs_FORWARD; - - TColStd_DataMapOfIntegerListOfInteger& aMapOfFaceSplits = myDSFiller->ChangeSplitFacePool(); - - aNb=aFFMap.Extent(); - - for (i=1; i<=aNb; i++) { - // - - nF1 = aFFMap.FindKey(i); - TopoDS_Face aF1 = TopoDS::Face(aDS.Shape(nF1)); - - anOriF1 = aF1.Orientation(); - iRank = aDS.Rank(nF1); - - TopTools_DataMapOfShapeInteger aMapOfEdgeIndex; - TopTools_ListOfShape aListOfSplits; - - if(SplitFace(nF1, aMapOfEdgeIndex, aListOfSplits)) { - - DoInternalVertices(nF1, aListOfSplits); - - TopTools_ListIteratorOfListOfShape aFaceIt(aListOfSplits); - - for(; aFaceIt.More(); aFaceIt.Next()) { - TopoDS_Shape aShapeF = aFaceIt.Value(); - BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq; - pDS->InsertShapeAndAncestorsSuccessors(aShapeF, anASSeq); - // - Standard_Integer aNewFaceIndex = pDS->NumberOfInsertedShapes(); - // - pDS->SetState(aNewFaceIndex, BooleanOperations_ON); - - if(!aMapOfFaceSplits.IsBound(nF1)) { - TColStd_ListOfInteger thelist; - aMapOfFaceSplits.Bind(nF1, thelist); - } - aMapOfFaceSplits.ChangeFind(nF1).Append(aNewFaceIndex); - - TopAbs_State aState = TopAbs_ON; - Standard_Boolean bFoundFaceState = Standard_False; - - if(PropagateFaceStateByEdges(aShapeF, aMapOfEdgeIndex, aState)) { - - if(aState != TopAbs_ON) { // can not determine correctly ON state - BooleanOperations_StateOfShape aConvertedState = BOPTools_StateFiller::ConvertState(aState); - - pDS->SetState(aNewFaceIndex, aConvertedState); - - bFoundFaceState = Standard_True; - } - } - - if(!bFoundFaceState) { - // - if(ComputeStateByInsidePoints(aNewFaceIndex, nF1, iRank, aFFMap, aState)) { - - if(aState != TopAbs_ON) { - BooleanOperations_StateOfShape aConvertedState = BOPTools_StateFiller::ConvertState(aState); - - pDS->SetState(aNewFaceIndex, aConvertedState); - } - bFoundFaceState = Standard_True; - } - } - - if(!bFoundFaceState) { - - if(ComputeStateForAnalyticalSurfaces(aNewFaceIndex, nF1, aFFMap, *myDSFiller, aState)) { - if(aState != TopAbs_ON) { - BooleanOperations_StateOfShape aConvertedState = BOPTools_StateFiller::ConvertState(aState); - - pDS->SetState(aNewFaceIndex, aConvertedState); - bFoundFaceState = Standard_True; - } - } - } - } - } - } - // end for -} - -// ===================================================================================================================== -// function: PropagateFaceStateByEdges -// purpose: -// ===================================================================================================================== -Standard_Boolean BOP_SolidSolid::PropagateFaceStateByEdges(const TopoDS_Shape& theFace, - const TopTools_DataMapOfShapeInteger& theMapOfEdgeIndex, - TopAbs_State& theState) -{ - TopAbs_State aState = TopAbs_UNKNOWN; - - const BooleanOperations_ShapesDataStructure& aDS = myDSFiller->DS(); - - if(theFace.IsNull() || (theFace.ShapeType() != TopAbs_FACE)) - return Standard_False; - TopoDS_Face aF1 = TopoDS::Face(theFace); - - Standard_Boolean bFoundNotON = Standard_False; - BooleanOperations_StateOfShape aFoundState = BooleanOperations_ON; - Standard_Boolean bIsINOUT = Standard_False; - - TopExp_Explorer anExpE(aF1, TopAbs_EDGE); - - for(; anExpE.More(); anExpE.Next()) { - const TopoDS_Shape& anEdge = anExpE.Current(); - - Standard_Integer nE = 0; - - if(theMapOfEdgeIndex.IsBound(anEdge)) { - nE = theMapOfEdgeIndex(anEdge); - } - else { - nE = aDS.ShapeIndex(anEdge, 1); - nE = (nE == 0) ? aDS.ShapeIndex(anEdge, 2) : nE; - } - - if(nE == 0) - continue; - - BooleanOperations_StateOfShape anEdgeState = aDS.GetState(nE); - - if((anEdgeState == BooleanOperations_IN) || - (anEdgeState == BooleanOperations_OUT)) { - - if(!bFoundNotON) { - bFoundNotON = Standard_True; - aFoundState = anEdgeState; - } - - if(aFoundState != anEdgeState) { - bIsINOUT = Standard_True; - break; - } - } - } - - if(!bIsINOUT && bFoundNotON) { - if(aFoundState == BooleanOperations_IN) - aState = TopAbs_IN; - else if(aFoundState == BooleanOperations_OUT) - aState = TopAbs_OUT; - } - - if(aState == TopAbs_UNKNOWN) - return Standard_False; - - theState = aState; - - return Standard_True; -} - -// ===================================================================================================================== -// function: ComputeStateByInsidePoints -// purpose: -// ===================================================================================================================== -Standard_Boolean BOP_SolidSolid::ComputeStateByInsidePoints(const Standard_Integer theFaceIndex, - const Standard_Integer theBaseFaceIndex, - const Standard_Integer theFaceRank, - const BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& theFFMap, - TopAbs_State& theState) - -{ - TopAbs_State aState = TopAbs_ON; - const BooleanOperations_ShapesDataStructure& aDS = myDSFiller->DS(); - BOPTools_InterferencePool* pIntrPool=(BOPTools_InterferencePool*)&myDSFiller->InterfPool(); - const BOPTools_PaveFiller& aPaveFiller = myDSFiller->PaveFiller(); - BOPTools_PaveFiller* pPaveFiller = (BOPTools_PaveFiller*)&aPaveFiller; - BOPTools_CArray1OfSSInterference& aFFs=pIntrPool->SSInterferences(); - - if(theFaceIndex == 0) - return Standard_False; - - const TopoDS_Shape& aS = aDS.Shape(theFaceIndex); - - if(aS.IsNull()) - return Standard_False; - TopoDS_Face aFace = TopoDS::Face(aS); - // - // - Standard_Integer i = 0, j = 0, aNb = 0; - aNb = theFFMap.Extent(); - - for (i=1; i<=aNb; i++) { - // - Standard_Integer nF1 = theFFMap.FindKey(i); - - if(nF1 != theBaseFaceIndex) - continue; - - const TColStd_IndexedMapOfInteger& aFFIndicesMap=theFFMap.FindFromIndex(i); - Standard_Integer aNbj = aFFIndicesMap.Extent(); - - for (j=1; j<=aNbj; j++) { - Standard_Integer iFF = aFFIndicesMap(j); - BOPTools_SSInterference& aFF = aFFs(iFF); - Standard_Boolean bIsTouchCase = aFF.IsTangentFaces(); - - if (bIsTouchCase) { - Standard_Integer nF2 = aFF.OppositeIndex(nF1); - const TopoDS_Face& aF2 = TopoDS::Face(aDS.Shape(nF2)); - - if(BOPTools_Tools3D::CheckSameDomainFaceInside(aFace, aF2, pPaveFiller->Context())) { - theState = TopAbs_ON; - return Standard_True; - } - } - } - } - const TopoDS_Shape& aTool = (theFaceRank == 1) ? aDS.Tool() : aDS.Object(); - TopoDS_Solid aRefSolid; - - if(aTool.ShapeType() == TopAbs_SOLID) - aRefSolid = TopoDS::Solid(aTool); - else { - BRep_Builder aBB; - aBB.MakeSolid(aRefSolid); - - TopExp_Explorer anExpSH(aTool, TopAbs_SHELL); - - for(; anExpSH.More(); anExpSH.Next()) { - TopoDS_Shape aShell = anExpSH.Current(); - aBB.Add(aShell, aRefSolid); - } - } - - if(!BOPTools_Tools3D::ComputeFaceState(aFace, aRefSolid, pPaveFiller->Context(), aState)) { - return Standard_False; - } - theState = aState; - - return Standard_True; -} - -// ===================================================================================================================== -// function: TakeOnSplit -// purpose: -// ===================================================================================================================== -Standard_Boolean BOP_SolidSolid::TakeOnSplit(const Standard_Integer theFaceIndex, - const Standard_Integer theBaseFaceIndex) const -{ - Standard_Boolean bTake = Standard_False; - - Standard_Boolean binout = Standard_False; - Standard_Boolean binin = Standard_False; - Standard_Boolean boutout = Standard_False; - - TColStd_MapOfInteger aMapOfUsedIndices; - TColStd_ListOfInteger aListOfFacesToCheck; - aListOfFacesToCheck.Append(theFaceIndex); - - GetStatesOfAdjacentFaces(aListOfFacesToCheck, *myDSFiller, aMapOfUsedIndices, binout, binin, boutout); - - switch(myOperation) { - case BOP_FUSE: { - if(binout || (!binin && !boutout)) { - bTake = Standard_True; - } - break; - } - case BOP_COMMON: { - if(binout || (!binin && !boutout)) { - bTake = Standard_True; - } - break; - } - case BOP_CUT: { - if((binin || boutout) && !binout) { - bTake = Standard_True; - } - break; - } - case BOP_CUT21: { - if((binin || boutout) && !binout) { - bTake = Standard_True; - } - break; - } - default: { - break; - } - } - return bTake; -} - -// ------------------------------------------------------------------------------------ -// static function: GetIndex -// purpose: -// ------------------------------------------------------------------------------------ -Standard_Integer GetIndex(const TopoDS_Shape& theShape, - const BooleanOperations_ShapesDataStructure& theDS) -{ - Standard_Integer anIndex = 0, i = 0; - - anIndex = theDS.ShapeIndex(theShape, 1); - anIndex = (anIndex == 0) ? theDS.ShapeIndex(theShape, 2) : anIndex; - - if(anIndex == 0) { - - for (i = theDS.NumberOfSourceShapes() + 1; i <= theDS.NumberOfInsertedShapes(); i++) { - if(theShape.IsSame(theDS.Shape(i))) { - anIndex = i; - break; - } - } - } - - return anIndex; -} - -// ------------------------------------------------------------------------------------ -// static function: GetAttachedFaces -// purpose: -// ------------------------------------------------------------------------------------ -void GetAttachedFaces(const Standard_Integer theEdgeIndex, - const Standard_Integer theFaceIndex, - const BOPTools_DSFiller& theDSFiller, - TColStd_ListOfInteger& theListOfFaces) -{ - theListOfFaces.Clear(); - const BooleanOperations_ShapesDataStructure& aDS = theDSFiller.DS(); - const TColStd_DataMapOfIntegerListOfInteger& aMap = theDSFiller.SplitFacePool(); - - Standard_Integer i = 0; - - for(i = 1; i <= aDS.NumberOfInsertedShapes(); i++) { - - if(aDS.GetShapeType(i) == TopAbs_FACE) { - TColStd_ListOfInteger aListOfFaceIndex; - - if(!aMap.IsBound(i)) { - if(theFaceIndex == i) - continue; - aListOfFaceIndex.Append(i); - } - else { - TColStd_ListIteratorOfListOfInteger anIttmp(aMap.Find(i)); - - for(; anIttmp.More(); anIttmp.Next()) { - if(theFaceIndex == anIttmp.Value()) - continue; - aListOfFaceIndex.Append(anIttmp.Value()); - } - } - - TColStd_ListIteratorOfListOfInteger anIt(aListOfFaceIndex); - - for(; anIt.More(); anIt.Next()) { - if(anIt.Value() <= 0) - continue; - const TopoDS_Shape& aFace = aDS.Shape(anIt.Value()); - TopExp_Explorer anExpE(aFace, TopAbs_EDGE); - - for(; anExpE.More(); anExpE.Next()) { - const TopoDS_Shape& anEdge = anExpE.Current(); - Standard_Integer nE = GetIndex(anEdge, aDS); - - if(theEdgeIndex == nE) { - theListOfFaces.Append(anIt.Value()); - break; - } - } - } - } - } -} - -// ------------------------------------------------------------------------------------ -// static function: GetStatesOfAdjacentFaces -// purpose: -// ------------------------------------------------------------------------------------ -void GetStatesOfAdjacentFaces(const TColStd_ListOfInteger& theListOfFacesToCheck, - const BOPTools_DSFiller& theDSFiller, - TColStd_MapOfInteger& theMapOfUsedIndices, - Standard_Boolean& bFoundINOUT, - Standard_Boolean& bFoundININ, - Standard_Boolean& bFoundOUTOUT) -{ - - const BooleanOperations_ShapesDataStructure& aDS = theDSFiller.DS(); - TColStd_ListOfInteger aLisOfON; - TColStd_ListIteratorOfListOfInteger anItF(theListOfFacesToCheck); - - for(; anItF.More(); anItF.Next()) { - Standard_Integer nF = anItF.Value(); - - if(theMapOfUsedIndices.Contains(nF)) { - continue; - } - theMapOfUsedIndices.Add(nF); - - TopoDS_Shape aFace = aDS.Shape(nF); - - TopExp_Explorer anExpE(aFace, TopAbs_EDGE); - - for(; anExpE.More(); anExpE.Next()) { - const TopoDS_Shape& anEdge = anExpE.Current(); - Standard_Integer nE = 0; - nE = GetIndex(anEdge, aDS); - - if(nE <= 0) - continue; - - if(theMapOfUsedIndices.Contains(nE)) - continue; - theMapOfUsedIndices.Add(nE); - TColStd_ListOfInteger aListOfFaces, aListOfIN, aListOfOUT; - GetAttachedFaces(nE, nF, theDSFiller, aListOfFaces); - - TColStd_ListIteratorOfListOfInteger anIt(aListOfFaces); - - for(; anIt.More(); anIt.Next()) { - if(theMapOfUsedIndices.Contains(anIt.Value())) - continue; - - // if((aDS.GetState(anIt.Value()) != BooleanOperations_IN) && - // (aDS.GetState(anIt.Value()) != BooleanOperations_OUT)) - if(aDS.GetState(anIt.Value()) == BooleanOperations_ON) - aLisOfON.Append(anIt.Value()); - - if(aDS.GetState(anIt.Value()) == BooleanOperations_IN) - aListOfIN.Append(anIt.Value()); - else if(aDS.GetState(anIt.Value()) == BooleanOperations_OUT) - aListOfOUT.Append(anIt.Value()); - } - bFoundINOUT = bFoundINOUT || (!aListOfIN.IsEmpty() && !aListOfOUT.IsEmpty()); - bFoundININ = bFoundININ || (!aListOfIN.IsEmpty() && aListOfOUT.IsEmpty()); - bFoundOUTOUT = bFoundOUTOUT || (aListOfIN.IsEmpty() && !aListOfOUT.IsEmpty()); - } - } - - if(!aLisOfON.IsEmpty() && (theMapOfUsedIndices.Extent() <= aDS.NumberOfInsertedShapes())) { - GetStatesOfAdjacentFaces(aLisOfON, theDSFiller, theMapOfUsedIndices, bFoundINOUT, bFoundININ, bFoundOUTOUT); - } -} - -// ------------------------------------------------------------------------------------ -// static function: ComputeStateForAnalyticalSurfaces -// purpose: -// ------------------------------------------------------------------------------------ -Standard_Boolean ComputeStateForAnalyticalSurfaces(const Standard_Integer theFaceIndex, - const Standard_Integer theBaseFaceIndex, - const BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& theFFMap, - const BOPTools_DSFiller& theDSFiller, - TopAbs_State& theState) -{ - TopAbs_State aState = TopAbs_ON; - const BooleanOperations_ShapesDataStructure& aDS = theDSFiller.DS(); - BOPTools_InterferencePool* pIntrPool=(BOPTools_InterferencePool*)&theDSFiller.InterfPool(); - const BOPTools_PaveFiller& aPaveFiller = theDSFiller.PaveFiller(); - BOPTools_PaveFiller* pPaveFiller = (BOPTools_PaveFiller*)&aPaveFiller; - BOPTools_CArray1OfSSInterference& aFFs=pIntrPool->SSInterferences(); - - if(theFaceIndex == 0) - return Standard_False; - - const TopoDS_Shape& aS = aDS.Shape(theFaceIndex); - - if(aS.IsNull()) - return Standard_False; - TopoDS_Face aFace = TopoDS::Face(aS); - - Standard_Integer j = 0; - Standard_Boolean bFound = Standard_False; - - if (theFFMap.Contains(theBaseFaceIndex)) { - // - Standard_Integer nF1 = theBaseFaceIndex; - - const TColStd_IndexedMapOfInteger& aFFIndicesMap=theFFMap.FindFromKey(theBaseFaceIndex); - Standard_Integer aNbj = aFFIndicesMap.Extent(); - - for (j=1; (!bFound) && (j<=aNbj); j++) { - Standard_Integer iFF = aFFIndicesMap(j); - BOPTools_SSInterference& aFF = aFFs(iFF); - Standard_Boolean bIsTouchCase = aFF.IsTangentFaces(); - - if (!bIsTouchCase) { - Standard_Integer nF2 = aFF.OppositeIndex(nF1); - const TopoDS_Face& aF2 = TopoDS::Face(aDS.Shape(nF2)); - // - TopExp_Explorer anExpE(aFace, TopAbs_EDGE); - - for(; anExpE.More(); anExpE.Next()) { - TopoDS_Edge aSp = TopoDS::Edge(anExpE.Current()); - - Standard_Boolean bTestEdge = Standard_False; - - Standard_Integer nE = GetIndex(aSp, aDS); - bTestEdge = IsEdgeValidForFace(nE, nF2, aFF, theDSFiller); - - if(bTestEdge) { - TopAbs_State aStPF = TopAbs_ON; - - Standard_Boolean bAnalytic = Standard_False; - Standard_Real aTolTangent, aTolR; - // - aTolTangent=0.002; - aTolR=0.0000001; - - bAnalytic = BOPTools_Tools3D::TreatedAsAnalytic(aF2, aSp, aFace, - aTolTangent, aTolR, - aStPF, pPaveFiller->Context()); - if(bAnalytic) { - aState = aStPF; - bFound = Standard_True; - break; - } - else { - gp_Dir aDBF1, aDNF2; - - BOPTools_Tools3D::GetBiNormal (aSp, aFace, aDBF1); - BOPTools_Tools3D::GetNormalToFaceOnEdge (aSp, aF2, aDNF2); - - Standard_Real aTolScPr, aScPr; - - aTolScPr=1.e-7; - aScPr=aDBF1*aDNF2; - - if (fabs(aScPr) > aTolScPr) { - aStPF=TopAbs_OUT; - - if (aScPr<0.) { - aStPF=TopAbs_IN; - } - aState = aStPF; - bFound = Standard_True; - break; - } - } - } - // end if(bTestEdge) - } - } - } - } - - if(!bFound) { - return Standard_False; - } - theState = aState; - return Standard_True; -} - -// ------------------------------------------------------------------------------------ -// static function: IsEdgeValidForFace -// purpose: -// ------------------------------------------------------------------------------------ -Standard_Boolean IsEdgeValidForFace(const Standard_Integer theEdgeIndex, - const Standard_Integer theFaceIndex, - BOPTools_SSInterference& theFF, - const BOPTools_DSFiller& theDSFiller) -{ - - const BOPTools_PaveFiller& aPaveFiller = theDSFiller.PaveFiller(); - BOPTools_PaveFiller* pPaveFiller = (BOPTools_PaveFiller*)&aPaveFiller; - BOPTools_CommonBlockPool& aCBPool = pPaveFiller->ChangeCommonBlockPool(); - - BOPTools_SequenceOfCurves& aSCvs=theFF.Curves(); - Standard_Integer aNbCurves=aSCvs.Length(); - Standard_Integer i = 0; - - for (i=1; i<=aNbCurves; i++) { - BOPTools_Curve& aBC=aSCvs(i); - const BOPTools_ListOfPaveBlock& aSectEdges=aBC.NewPaveBlocks(); - - BOPTools_ListIteratorOfListOfPaveBlock aPBIt(aSectEdges); - - for (; aPBIt.More(); aPBIt.Next()) { - BOPTools_PaveBlock& aPB = aPBIt.Value(); - - if(theEdgeIndex == aPB.Edge()) - return Standard_True; - } - } - - - for(i = 1; i <= aCBPool.Length(); i++) { - const BOPTools_ListOfCommonBlock& aCBList = aCBPool.Value(i); - BOPTools_ListIteratorOfListOfCommonBlock anItCB(aCBList); - - for (; anItCB.More(); anItCB.Next()) { - BOPTools_CommonBlock& aCB=anItCB.Value(); - Standard_Integer nFace = aCB.Face(); - - if(nFace == theFaceIndex) { - const BOPTools_PaveBlock& aPB1 = aCB.PaveBlock1(); - const BOPTools_PaveBlock& aPB2 = aCB.PaveBlock2(); - - if((theEdgeIndex == aPB1.Edge()) || - (theEdgeIndex == aPB2.Edge())) { - return Standard_True; - } - } - } - } - - - return Standard_False; -} diff --git a/src/BOP/BOP_WESCorrector.cdl b/src/BOP/BOP_WESCorrector.cdl deleted file mode 100755 index 5178eb6582..0000000000 --- a/src/BOP/BOP_WESCorrector.cdl +++ /dev/null @@ -1,88 +0,0 @@ --- Created on: 2001-04-13 --- Created by: Peter KURNEV --- Copyright (c) 2001-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class WESCorrector from BOP - - ---Purpose: - --- The algorithm to change the Wire Edges Set (WES) contents. - -- The NewWES will contain only wires instead of wires and edges. - -- -uses - WireEdgeSet from BOP, - PWireEdgeSet from BOP, - ListOfConnexityBlock from BOP - -is - Create - returns WESCorrector from BOP; - ---Purpose: - --- Empty constructor; - --- - SetWES (me:out; - aWES: WireEdgeSet from BOP); - ---Purpose: - --- Modifier - --- - Do (me:out); - ---Purpose: - --- Performs the algorithm that consists of two steps - --- 1. Make conexity blocks ( DoConnexityBlocks() ) - --- 2. Make corrections ( DoCorrections() ) - --- - DoConnexityBlocks(me:out) - is private; - - DoCorrections(me:out) - is private; - - IsDone(me) - returns Boolean from Standard; - ---Purpose: - --- Selector - --- - ErrorStatus (me) - returns Integer from Standard; - ---Purpose: - --- Selector - --- contents see BOP_WESCorrector.cxx - --- - WES (me:out) - returns WireEdgeSet from BOP; - ---C++: return & - ---Purpose: - --- Selector - --- - NewWES (me:out) - returns WireEdgeSet from BOP; - ---C++: return & - ---Purpose: - --- Selector - --- - -fields - - myWES : PWireEdgeSet from BOP; - myNewWES : WireEdgeSet from BOP; - myConnexityBlocks : ListOfConnexityBlock from BOP; - myIsDone : Boolean from Standard; - myErrorStatus : Integer from Standard; - -end WESCorrector; diff --git a/src/BOP/BOP_WESCorrector.cxx b/src/BOP/BOP_WESCorrector.cxx deleted file mode 100755 index 0b91a360bb..0000000000 --- a/src/BOP/BOP_WESCorrector.cxx +++ /dev/null @@ -1,258 +0,0 @@ -// Created on: 2001-04-13 -// Created by: Peter KURNEV -// Copyright (c) 2001-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include - -static - void MakeWire(const TopTools_ListOfShape& aLE, - TopoDS_Wire& newWire); - -//======================================================================= -// function: BOP_WESCorrector::BOP_WESCorrector -// purpose: -//======================================================================= - BOP_WESCorrector::BOP_WESCorrector() -: - myIsDone(Standard_False), - myErrorStatus(1) -{} -//======================================================================= -// function: SetWES -// purpose: -//======================================================================= - void BOP_WESCorrector::SetWES (const BOP_WireEdgeSet& aWES) -{ - BOP_WireEdgeSet* pWES=(BOP_WireEdgeSet*) &aWES; - myWES=pWES; -} -//======================================================================= -// function: WES -// purpose: -//======================================================================= - BOP_WireEdgeSet& BOP_WESCorrector::WES () -{ - return *myWES; -} -//======================================================================= -// function: NewWES -// purpose: -//======================================================================= - BOP_WireEdgeSet& BOP_WESCorrector::NewWES () -{ - return myNewWES; -} -//======================================================================= -// function: IsDone -// purpose: -//======================================================================= - Standard_Boolean BOP_WESCorrector::IsDone () const -{ - return myIsDone; -} -//======================================================================= -// function: ErrorStatus -// purpose: -//======================================================================= - Standard_Integer BOP_WESCorrector::ErrorStatus () const -{ - return myErrorStatus; -} - -//======================================================================= -// function: Do -// purpose: -//======================================================================= - void BOP_WESCorrector::Do() -{ - DoConnexityBlocks(); - - DoCorrections(); - - myIsDone=Standard_True; -} -//======================================================================= -// function: DoConnexityBlocks -// purpose: -//======================================================================= - void BOP_WESCorrector::DoConnexityBlocks() -{ - Standard_Boolean EnewinM, aGoOn; - Standard_Integer Mextent, IsRegular, aNbNeighbours, Eindex; - TopTools_IndexedMapOfOrientedShape myOrientedShapeMap, aMap; - // - myWES->InitStartElements(); - for (; myWES->MoreStartElements(); myWES->NextStartElement()) { - const TopoDS_Shape& anE = myWES->StartElement(); - Mextent = myOrientedShapeMap.Extent(); - - Eindex = myOrientedShapeMap.Add(anE); - - EnewinM = (Eindex > Mextent); - if (EnewinM) { - // - // make a new block starting at element Eindex - IsRegular=Standard_True; - aNbNeighbours=0; - Mextent = myOrientedShapeMap.Extent(); - // - aMap.Clear(); - aMap.Add(anE); - // - aGoOn = (Eindex <= Mextent); - while (aGoOn) { - const TopoDS_Shape& anEE = myOrientedShapeMap(Eindex); - aNbNeighbours = myWES->MaxNumberSubShape(anEE); - - IsRegular = IsRegular && (aNbNeighbours == 2); - // - myWES->InitNeighbours(anEE); - for (; myWES->MoreNeighbours(); myWES->NextNeighbour()) { - const TopoDS_Shape& aNeignbE = myWES->Neighbour(); - myOrientedShapeMap.Add(aNeignbE); - // - aMap.Add(aNeignbE); - } - - Eindex++; - Mextent = myOrientedShapeMap.Extent(); - aGoOn = (Eindex <= Mextent); - } // end of while aGoOn - - // - //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX - { - Standard_Integer aNbE; - - aNbE=aMap.Extent(); - if (aNbE==2) { - const TopoDS_Edge& aEB1=TopoDS::Edge(aMap(1)); - const TopoDS_Edge& aEB2=TopoDS::Edge(aMap(2)); - if (aEB1.IsSame(aEB2)) { - if (!BRep_Tool::IsClosed(aEB1, myWES->Face())) { - IsRegular=Standard_False; - } - } - } - } - //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX - // - BOP_ConnexityBlock aConnexityBlock; - aConnexityBlock.SetShapes(aMap); - aConnexityBlock.SetRegularity(IsRegular); - myConnexityBlocks.Append(aConnexityBlock); - } // end of if (EnewinM) - } // end of for (; myWES->MoreStartElements();... -} - -//======================================================================= -// function: DoCorrections -// purpose: -//======================================================================= - void BOP_WESCorrector::DoCorrections() -{ - Standard_Boolean anIsRegular, anIsNothingToDo, anIsDone; - - TopoDS_Wire aW; - BOP_ListIteratorOfListOfConnexityBlock aCBIt; - - myNewWES.Initialize(myWES->Face()); - - aCBIt.Initialize(myConnexityBlocks); - for (; aCBIt.More(); aCBIt.Next()) { - const BOP_ConnexityBlock& aCB=aCBIt.Value(); - const TopTools_ListOfShape& aListOfEdges=aCB.Shapes(); - - anIsRegular=aCB.IsRegular(); - - if (anIsRegular) { - MakeWire(aListOfEdges, aW); - myNewWES.AddShape (aW); - continue; - } - // - // Treatment of non regular Connexity Block - const TopoDS_Face& aF=myWES->Face(); - BOP_WireSplitter aWireSplitter; - aWireSplitter.SetFace(aF); - aWireSplitter.DoWithListOfEdges(aListOfEdges); - - anIsDone=aWireSplitter.IsDone(); - anIsNothingToDo=aWireSplitter.IsNothingToDo(); - - if (!anIsDone || anIsNothingToDo) { - MakeWire(aListOfEdges, aW); - myNewWES.AddShape (aW); - continue; - } - // - const BOPTColStd_ListOfListOfShape& aSSS=aWireSplitter.Shapes(); - - BOPTColStd_ListIteratorOfListOfListOfShape aWireIt(aSSS); - for (; aWireIt.More(); aWireIt.Next()) { - const TopTools_ListOfShape& aListEd=aWireIt.Value(); - // - MakeWire(aListEd, aW); - myNewWES.AddShape (aW); - } - } -} - -//======================================================================= -// function: MakeWire -// purpose: -//======================================================================= - void MakeWire(const TopTools_ListOfShape& aLE, - TopoDS_Wire& newWire) -{ - BRep_Builder aBB; - aBB.MakeWire(newWire); - - TopTools_ListIteratorOfListOfShape anIt(aLE); - for (; anIt.More(); anIt.Next()){ - const TopoDS_Edge& aE=TopoDS::Edge(anIt.Value()); - aBB.Add(newWire, aE); - } -} -///////////////////////////////////////////////////////////////// -// -// myErrorStatus: -// -// 1 - Nothing is done because only constructor has been invoked -// -///////////////////////////////////////////////////////////////// diff --git a/src/BOP/BOP_WireEdgeClassifier.cdl b/src/BOP/BOP_WireEdgeClassifier.cdl deleted file mode 100755 index ed54f406a4..0000000000 --- a/src/BOP/BOP_WireEdgeClassifier.cdl +++ /dev/null @@ -1,118 +0,0 @@ --- Created on: 1993-06-17 --- Created by: Jean Yves LEBEY --- Copyright (c) 1993-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class WireEdgeClassifier from BOP inherits CompositeClassifier from BOP - - ---Purpose: - -- The algorithm is to classify loops that - -- shapes are Wires, Element are Edge. - -uses - - ShapeEnum from TopAbs, - State from TopAbs, - - Shape from TopoDS, - Face from TopoDS, - - Pnt2d from gp, - - Edge from BRepClass, - FacePassiveClassifier from BRepClass, - BlockBuilder from BOP, - Loop from BOP - -is - - Create(F : Face from TopoDS; - BB : BlockBuilder) - returns WireEdgeClassifier; - ---Purpose: - --- Creates a classifier on edge . - --- Used to compare edges and wires on the edge . - --- - - Compare(me : in out; - L1 : Loop from BOP; - L2 : Loop from BOP) - returns State from TopAbs - is redefined; - ---Purpose: - --- Classify loop with - --- - LoopToShape(me : in out; - L : Loop from BOP) - returns Shape from TopoDS; - ---Purpose: - --- Internal usage - --- - CompareShapes(me : in out; - B1 : Shape from TopoDS; - B2 : Shape from TopoDS) - returns State from TopAbs; - ---Purpose: - --- Classify wire with wire - --- - CompareElementToShape(me : in out; - E : Shape from TopoDS; - W : Shape from TopoDS) - returns State from TopAbs; - ---Purpose: - --- Classify edge with wire - --- - ResetShape(me : in out; - B : Shape from TopoDS); - ---Purpose: - --- Prepare classification involving wire - --- calls ResetElement on first edge of - --- - - ResetElement(me : in out; - E : Shape from TopoDS); - ---Purpose: - --- Prepare classification involving edge - --- define 2D point (later used in Compare()) - --- on first vertex of edge . - --- - - CompareElement(me : in out; - E : Shape from TopoDS); - ---Purpose: - --- Add the edge in the set of edges used in 2D point - --- classification. - --- - - State(me : in out) - returns State from TopAbs; - ---Purpose: - --- Returns state of classification of 2D point, defined by - --- ResetElement, with the current set of edges, defined by Compare. - --- - -fields - - myFirstCompare : Boolean from Standard; - myPoint2d : Pnt2d from gp; - myBCEdge : Edge from BRepClass; - myFPC : FacePassiveClassifier from BRepClass; - myShape : Shape from TopoDS; - -end WireEdgeClassifier; diff --git a/src/BOP/BOP_WireEdgeClassifier.cxx b/src/BOP/BOP_WireEdgeClassifier.cxx deleted file mode 100755 index 154ad35107..0000000000 --- a/src/BOP/BOP_WireEdgeClassifier.cxx +++ /dev/null @@ -1,472 +0,0 @@ -// Created on: 1993-06-17 -// Created by: Jean Yves LEBEY -// Copyright (c) 1993-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -// modified by PKV -// ... and nobody played synthesizer . - -// Modified by skv - Thu Jul 6 12:01:17 2006 OCC12627 - -#include - -#include - -#include - -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include -#include - - - -static - Standard_Real MinStepIn2d(const TopoDS_Edge& aE, - const TopoDS_Face& aF); - -//======================================================================= -//function : BOP_WireEdgeClassifier::BOP_WireEdgeClassifier -//purpose : -//======================================================================= - BOP_WireEdgeClassifier::BOP_WireEdgeClassifier (const TopoDS_Face& F, - const BOP_BlockBuilder& BB) -: - BOP_CompositeClassifier(BB) -{ - myBCEdge.Face() = F; -} - -//======================================================================= -//function : Compare -//purpose : -//======================================================================= - TopAbs_State BOP_WireEdgeClassifier::Compare (const Handle(BOP_Loop)& L1, - const Handle(BOP_Loop)& L2) -{ - TopAbs_State state = TopAbs_UNKNOWN; - - Standard_Boolean isshape1, isshape2, yena1 ; - - isshape1 = L1->IsShape(); - isshape2 = L2->IsShape(); - - if ( isshape2 && isshape1 ) { - // L1 is Shape , L2 is Shape - const TopoDS_Shape& s1 = L1->Shape(); - const TopoDS_Shape& s2 = L2->Shape(); - state = CompareShapes(s1,s2); - } - - else if ( isshape2 && !isshape1 ) { - // L1 is Block , L2 is Shape - BOP_BlockIterator Bit1 = L1->BlockIterator(); - Bit1.Initialize(); - yena1 = Bit1.More(); - while (yena1) { - const TopoDS_Shape& s1 = - ((BOP_BlockBuilder*)myBlockBuilder)->Element(Bit1); - const TopoDS_Shape& s2 = L2->Shape(); - state = CompareElementToShape(s1,s2); - yena1 = Standard_False; - if (state == TopAbs_UNKNOWN) { - if (Bit1.More()) Bit1.Next(); - yena1 = Bit1.More(); - } - } - } - - else if ( !isshape2 && isshape1 ) { - // L1 is Shape , L2 is Block - const TopoDS_Shape& s1 = L1->Shape(); - ResetShape(s1); - BOP_BlockIterator Bit2 = L2->BlockIterator(); - for (Bit2.Initialize(); Bit2.More(); Bit2.Next()) { - const TopoDS_Shape& s2 = - ((BOP_BlockBuilder*)myBlockBuilder)->Element(Bit2); - CompareElement(s2); - } - state = State(); - } - else if ( !isshape2 && !isshape1 ) { - // L1 is Block , L2 is Block - if (state == TopAbs_UNKNOWN) { - BOP_BlockIterator Bit1 = L1->BlockIterator(); - Bit1.Initialize(); - yena1 = Bit1.More(); - while (yena1) { - const TopoDS_Shape& s1 = - ((BOP_BlockBuilder*)myBlockBuilder)->Element(Bit1); - ResetElement(s1); - BOP_BlockIterator Bit2 = L2->BlockIterator(); - for (Bit2.Initialize(); Bit2.More(); Bit2.Next()) { - const TopoDS_Shape& s2 = - ((BOP_BlockBuilder*)myBlockBuilder)->Element(Bit2); - CompareElement(s2); - } - state = State(); - yena1 = Standard_False; - if (state == TopAbs_UNKNOWN) { - if (Bit1.More()) Bit1.Next(); - yena1 = Bit1.More(); - } - } - } // if (state == TopAbs_UNKNOWN) - - if (state == TopAbs_UNKNOWN) { - // - TopoDS_Shape s1 = LoopToShape(L1); - if (s1.IsNull()) { - return state; - } - TopoDS_Shape s2 = LoopToShape(L2); - if (s2.IsNull()) { - return state; - } - } // if (state == TopAbs_UNKNOWN) - - } // else if ( !isshape2 && !isshape1 ) - return state; -} - -//======================================================================= -//function : LoopToShape -//purpose : -//======================================================================= - TopoDS_Shape BOP_WireEdgeClassifier::LoopToShape(const Handle(BOP_Loop)& L) -{ - myShape.Nullify(); - - BOP_BlockIterator Bit = L->BlockIterator(); - Bit.Initialize(); - if ( !Bit.More() ) { - return myShape; - } - - TopoDS_Shape aLocalShape = myBCEdge.Face(); - const TopoDS_Face& F1 = TopoDS::Face(aLocalShape); - // - aLocalShape = F1.EmptyCopied(); - TopoDS_Face F = TopoDS::Face(aLocalShape); - // - BRep_Builder BB; - TopoDS_Wire W; - BB.MakeWire(W); - - Standard_Real tolE, f,l,tolpc, tol; - Standard_Boolean haspc ; - - for (; Bit.More(); Bit.Next()) { - const TopoDS_Edge& E = - TopoDS::Edge(((BOP_BlockBuilder*)myBlockBuilder)->Element(Bit)); - - tolE = BRep_Tool::Tolerance(E); - - haspc = BOPTools_Tools2D::HasCurveOnSurface (E, F); - if (!haspc) { - Handle(Geom2d_Curve) C2D; - BOPTools_Tools2D::CurveOnSurface (E, F, C2D, f, l, tolpc, Standard_False); - - if (!C2D.IsNull()) { - tol = Max(tolpc,tolE); - BB.UpdateEdge(E,C2D,F,tol); - } - } - BB.Add(W,E); - } - BB.Add(F, W); - - myShape = F; - return myShape; -} - -//======================================================================= -//function : CompareShapes -//purpose : -//======================================================================= - TopAbs_State BOP_WireEdgeClassifier::CompareShapes (const TopoDS_Shape& B1, - const TopoDS_Shape& B2) -{ - Standard_Boolean bBothWires; - TopAbs_State aSt; - TopExp_Explorer anExp1; - - aSt = TopAbs_UNKNOWN; - bBothWires= (B2.ShapeType()==TopAbs_WIRE) && (B1.ShapeType()==TopAbs_WIRE); - - anExp1.Init (B1, TopAbs_EDGE); - if ( !anExp1.More() ) { - return aSt; - } - // - for (; anExp1.More(); anExp1.Next() ) { - const TopoDS_Edge& anE1 = TopoDS::Edge(anExp1.Current()); - ResetShape(anE1); - // - TopExp_Explorer anExp2(B2, TopAbs_EDGE); - for(; anExp2.More(); anExp2.Next()) { - const TopoDS_Edge& anE2 = TopoDS::Edge(anExp2.Current()); - // - if(anE2.IsSame(anE1)) { - //const TopoDS_Face& aF=myBCEdge.Face(); - if (bBothWires) { - aSt = TopAbs_OUT; - return aSt; - } - } - } - } - // - TopoDS_Face aFN1, aFN2; - gp_Pnt2d aP2DNear; - gp_Pnt aPNear; - - const TopoDS_Face& theFace = myBCEdge.Face(); - const TopoDS_Wire& aW1=TopoDS::Wire(B1); - const TopoDS_Wire& aW2=TopoDS::Wire(B2); - - IntTools_Tools::MakeFaceFromWireAndFace (aW1, theFace, aFN1); - IntTools_Tools::MakeFaceFromWireAndFace (aW2, theFace, aFN2); - - anExp1.Init (aFN1, TopAbs_EDGE); - for (; anExp1.More(); anExp1.Next()){ - const TopoDS_Edge& aE1=TopoDS::Edge(anExp1.Current()); - // - // The block that choises step in 2D taking into account - // tolerances of the Face and Edge on the Face in order to - // obtain 2D point exactly INside of the Face - // pkv207/A5 - // PKV Thu Jun 13 09:09:53 2002 - { - Standard_Real aT, aT1, aT2, dt2D; - - BRep_Tool::Range(aE1, aT1, aT2); - aT=BOPTools_Tools2D::IntermediatePoint(aT1, aT2); - // - TopoDS_Face aFF=aFN1; - TopoDS_Edge aERight; - - aFF.Orientation(TopAbs_FORWARD); - BOPTools_Tools3D::OrientEdgeOnFace (aE1, aFF, aERight); - - dt2D=MinStepIn2d(aERight, aFF); - BOPTools_Tools3D::PointNearEdge (aERight, aFF, aT, dt2D, aP2DNear, aPNear); - } - - // -// Modified by skv - Thu Jul 6 12:01:17 2006 OCC12627 Begin -// aSt=IntTools_Tools::ClassifyPointByFace (aFN2, aP2DNear); - Standard_Real aTol = Precision::PConfusion(); - IntTools_FClass2d aClass2d(aFN2, aTol); - - aSt = aClass2d.Perform(aP2DNear); -// Modified by skv - Thu Jul 6 12:01:19 2006 OCC12627 End - - return aSt; - } - return aSt; -} - - -//======================================================================= -//function : CompareElementToShape -//purpose : -//======================================================================= - TopAbs_State BOP_WireEdgeClassifier::CompareElementToShape (const TopoDS_Shape& EE, - const TopoDS_Shape& B) -{ - // isEdge : edge E inits myPoint2d - ResetElement(EE); - TopExp_Explorer Ex; - Ex.Init(B,TopAbs_EDGE); - for(; Ex.More(); Ex.Next()) { - const TopoDS_Shape& E = Ex.Current(); - CompareElement(E); - } - TopAbs_State state = State(); - return state; -} - -//======================================================================= -//function : ResetShape -//purpose : -//======================================================================= - void BOP_WireEdgeClassifier::ResetShape(const TopoDS_Shape& B) -{ - if (B.ShapeType() == TopAbs_EDGE) { - ResetElement(B); - } - - else { - TopExp_Explorer ex(B,TopAbs_EDGE); - if (ex.More()) { - const TopoDS_Shape& E = ex.Current(); - ResetElement(E); - } - } -} -//======================================================================= -//function : ResetElement -//purpose : -//======================================================================= - void BOP_WireEdgeClassifier::ResetElement(const TopoDS_Shape& EE) -{ - const TopoDS_Edge& E = TopoDS::Edge(EE); - const TopoDS_Face& F = myBCEdge.Face(); - - Standard_Boolean haspc; - Standard_Real f2, l2, tolpc, tolE, tol, par ; - Handle(Geom2d_Curve) C2D; - BRep_Builder BB; - - haspc = BOPTools_Tools2D::HasCurveOnSurface(E, F); - if (!haspc) { - BOPTools_Tools2D::CurveOnSurface(E, F, C2D, f2, l2, tolpc, Standard_True); - tolE = BRep_Tool::Tolerance(E); - tol = Max(tolE,tolpc); - BB.UpdateEdge(E,C2D,F,tol); - } - - - BOPTools_Tools2D::CurveOnSurface(E, F, C2D, f2, l2, tolpc, Standard_False); - if (C2D.IsNull()) { - Standard_ProgramError::Raise("WEC : ResetElement"); - } - - par = BOPTools_Tools2D::IntermediatePoint (f2, l2); - myPoint2d = C2D->Value(par); - - myFirstCompare = Standard_True; -} - - -//======================================================================= -//function : CompareElement -//purpose : -//======================================================================= - void BOP_WireEdgeClassifier::CompareElement(const TopoDS_Shape& EE) -{ - const TopoDS_Edge& E = TopoDS::Edge(EE); - const TopoDS_Face& F = myBCEdge.Face(); - - Standard_Real f2, l2, tolpc, tolE, tol, par, dist, tol2d; - Standard_Boolean haspc; - - if (myFirstCompare) { - - Handle(Geom2d_Curve) C2D; - BRep_Builder BB; - - haspc = BOPTools_Tools2D::HasCurveOnSurface(E, F); - if (!haspc) { - BOPTools_Tools2D::CurveOnSurface(E, F, C2D, f2, l2, tolpc, Standard_True); - tolE = BRep_Tool::Tolerance(E); - tol = Max(tolE, tolpc); - BB.UpdateEdge(E,C2D,F,tol); - } - - BOPTools_Tools2D::CurveOnSurface(E, F, C2D, f2, l2, tolpc, Standard_False); - - par = BOPTools_Tools2D::IntermediatePoint (f2, l2); - - gp_Pnt2d p2d = C2D->Value(par); - - gp_Vec2d v2d(myPoint2d,p2d); - gp_Lin2d l2d(myPoint2d,v2d); - dist = myPoint2d.Distance(p2d); - tol2d = Precision::PConfusion(); - - myFPC.Reset(l2d,dist,tol2d); - myFirstCompare = Standard_False; - - } // end of if (myFirstCompare) - - myBCEdge.Edge() = E; - TopAbs_Orientation Eori = E.Orientation(); - myFPC.Compare(myBCEdge,Eori); - //ZZ TopAbs_State state = myFPC.State(); -} - - -//======================================================================= -//function : State -//purpose : -//======================================================================= - TopAbs_State BOP_WireEdgeClassifier::State() -{ - TopAbs_State state = myFPC.State(); - return state; -} - -//======================================================================= -//function : MinStepIn2d -//purpose : -//======================================================================= -Standard_Real MinStepIn2d(const TopoDS_Edge& aE, - const TopoDS_Face& aF) -{ - Standard_Real aDt2dMin, aDt2D, aTolE, aURes, aVRes; - // - aDt2dMin=1.e-5; - // - aTolE=BRep_Tool::Tolerance(aE); - // - Handle(Geom_Surface) aS=BRep_Tool::Surface(aF); - GeomAdaptor_Surface aGAS(aS); - if (aGAS.GetType()==GeomAbs_Plane) { - aURes=aGAS.UResolution(aTolE); - aVRes=aGAS.VResolution(aTolE); - aDt2D=(aURes>aVRes) ? aURes : aVRes; - // - if (aDt2D > aDt2dMin) { - aDt2D=aDt2dMin; - } - } - else { - aDt2D=aDt2dMin; - } - return aDt2D; -} diff --git a/src/BOP/BOP_WireEdgeSet.cdl b/src/BOP/BOP_WireEdgeSet.cdl deleted file mode 100755 index d0a4b46b96..0000000000 --- a/src/BOP/BOP_WireEdgeSet.cdl +++ /dev/null @@ -1,199 +0,0 @@ --- Created on: 1993-06-16 --- Created by: Jean Yves LEBEY --- Copyright (c) 1993-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class WireEdgeSet from BOP inherits ShapeSet from BOP - - ---Purpose: The class containing data and methods - -- for a set of edges and wires - -- - -- Bound is a wire, - -- Boundelement is an edge. - -- - -- The ShapeSet stores : - -- - a list of wire (bounds), - -- - a list of edge (boundelements) to start reconstructions, - -- - a map of vertex giving the list of edge incident to a vertex. - -uses - - Orientation from TopAbs, - - Shape from TopoDS, - Face from TopoDS, - Edge from TopoDS, - Vertex from TopoDS, - - ListOfShape from TopTools, - - Pnt2d from gp, - Vec2d from gp - - -is - Create - returns WireEdgeSet from BOP; - ---Purpose: - --- Empty constructor; - --- - Create (F: Face from TopoDS) - returns WireEdgeSet from BOP; - ---Purpose: - --- Creates a WES to build edges connected by vertices - --- on face F. Edges of the WireEdgeSet must have a representation - --- on surface of face F. - --- - Initialize(me:out; - F: Face from TopoDS); - ---Purpose: - --- Initialize a WES to build edges connected by vertices - --- on face F. Edges of the WireEdgeSet must have a representation - --- on surface of face F. - --- - Face(me) - returns Face from TopoDS; - ---C++: return const & - ---Purpose: - --- Selector - --- - AddShape(me:out; - S:Shape from TopoDS) - is redefined; - ---Purpose: - --- See in base class, please - --- - AddStartElement(me:out; - S:Shape from TopoDS) - is redefined; - ---Purpose: - --- See in base class, please - --- - AddElement(me:out; - S:Shape from TopoDS) - is redefined; - ---Purpose: - --- See in base class, please - --- - InitNeighbours(me:out; - E:Shape from TopoDS) - is redefined; - ---Purpose: - --- Internal usage - --- - FindNeighbours(me:out) - is redefined; - ---Purpose: - --- Build the list of neighbour edges of edge myCurrentShape - --- Initialize iterator of neighbour edges to edge myCurrentShape - --- - MakeNeighboursList(me:out; - E,V:Shape from TopoDS) - returns ListOfShape from TopTools - is redefined; - ---C++: return const & - - VertexConnectsEdges(me; - V,E1,E2:Shape from TopoDS; - O1,O2:out Orientation from TopAbs) - returns Boolean from Standard - is private; - ---Purpose: - --- Indicates whether vertex V is a good connexity vertex between - --- edges E1 and E2. - --- i.e, returns True if V is shared by E1 and E2 and if V has different - --- orientations on E1 and E2. - --- If V is shared by E1 and E2, returns the orientation of V on E1 and E2 - --- - - VertexConnectsEdgesClosing(me; - V,E1,E2:Shape from TopoDS) - returns Boolean from Standard - is private; - ---Purpose: - --- Internal usage - --- - NbClosingShapes(me; - L:ListOfShape from TopTools) - returns Integer from Standard - is private; - ---Purpose: - --- Internal usage - --- - LocalD1(me; - F : Face from TopoDS; - E : Edge from TopoDS; - V : Vertex from TopoDS; - P2: out Pnt2d from gp; - V2: out Vec2d from gp) - is private; - ---Purpose: - --- Internal usage - --- - IsClosed(me; - E:Shape from TopoDS) - returns Boolean from Standard - is private; - ---Purpose: - --- indicates if the edge is a closing edge of myFace - --- Internal usage - --- - IsUClosed(me; - E:Shape from TopoDS) - returns Boolean from Standard - is private; - ---Purpose: - --- indicates if the edge is a closing edge on U of myFace - --- Internal usage - --- - IsVClosed(me; - E:Shape from TopoDS) - returns Boolean from Standard - is private; - ---Purpose: - --- indicates if the edge is a closing edge on V of myFace - --- Internal usage - --- - IsUVISO(myclass; - E:Edge from TopoDS; - F:Face from TopoDS; - uiso,viso:out Boolean from Standard); - ---Purpose: - --- Internal usage - --- - - RemoveEdgeFromWES (me:out; - aE : Edge from TopoDS); - ---Purpose: - --- Removes the edge aE from the WES - --- - KeptTwice(me; - aE : Edge from TopoDS) - returns Boolean from Standard; - ---Purpose: - --- Returns TRUE if the edge aE has been kept twice - --- in the WES - --- - -fields - - myFace:Face from TopoDS; - myDEBVertexIndex:Integer from Standard; - -end WireEdgeSet from BOP; diff --git a/src/BOP/BOP_WireEdgeSet.cxx b/src/BOP/BOP_WireEdgeSet.cxx deleted file mode 100755 index d211b635ec..0000000000 --- a/src/BOP/BOP_WireEdgeSet.cxx +++ /dev/null @@ -1,608 +0,0 @@ -// Created on: 1993-06-17 -// Created by: Jean Yves LEBEY -// Copyright (c) 1993-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -// modified by NIZNHY-PKV - -#include - -#include - -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include - -// modified by NIZHNY-MKK Fri May 30 10:18:01 2003.BEGIN -#include -#include -#include - -static void GetOrientationVOnE(const TopoDS_Shape& V, - const TopoDS_Shape& E1, - const TopoDS_Shape& E2, - TopAbs_Orientation& o1, - TopAbs_Orientation& o2); -// modified by NIZHNY-MKK Fri May 30 10:18:03 2003.END - -//======================================================================= -//function : BOP_WireEdgeSet::BOP_WireEdgeSet -//purpose : -//======================================================================= - BOP_WireEdgeSet::BOP_WireEdgeSet() -: - BOP_ShapeSet(TopAbs_VERTEX) -{ -} -//======================================================================= -//function : BOP_WireEdgeSet::BOP_WireEdgeSet -//purpose : -//======================================================================= - BOP_WireEdgeSet::BOP_WireEdgeSet(const TopoDS_Face& F) -: - BOP_ShapeSet(TopAbs_VERTEX), - myFace(F) -{ -} - -//======================================================================= -//function : Initialize -//purpose : -//======================================================================= - void BOP_WireEdgeSet::Initialize(const TopoDS_Face& F) -{ - myFace=F; -} - -//======================================================================= -//function : AddShape -//purpose : -//======================================================================= - void BOP_WireEdgeSet::AddShape(const TopoDS_Shape& S) -{ - ProcessAddShape(S); -} - -//======================================================================= -//function : AddStartElement -//purpose : -//======================================================================= - void BOP_WireEdgeSet::AddStartElement(const TopoDS_Shape& S) -{ - ProcessAddStartElement(S); -} - -//======================================================================= -//function : AddElement -//purpose : -//======================================================================= - void BOP_WireEdgeSet::AddElement(const TopoDS_Shape& S) -{ - BOP_ShapeSet::AddElement(S); -} - -//======================================================================= -//function : InitNeighbours -//purpose : -//======================================================================= - void BOP_WireEdgeSet::InitNeighbours(const TopoDS_Shape& E) -{ - mySubShapeExplorer.Init(E,mySubShapeType); - myCurrentShape = E; - - FindNeighbours(); -} - - -//======================================================================= -//function : FindNeighbours -//purpose : -//======================================================================= - void BOP_WireEdgeSet::FindNeighbours() -{ - while (mySubShapeExplorer.More()) { - - // l = list of edges neighbour of edge myCurrentShape trough - // the vertex mySubShapeExplorer.Current(), which is a vertex of the - // edge myCurrentShape. - const TopoDS_Shape& V = mySubShapeExplorer.Current(); - - const TopTools_ListOfShape & l = - MakeNeighboursList(myCurrentShape, V); - - // myIncidentShapesIter iterates on the neighbour edges of the edge - // given as InitNeighbours() argument (this edge has been stored - // in the field myCurrentShape). - - myIncidentShapesIter.Initialize(l); - if (myIncidentShapesIter.More()) { - break; - } - else{ - mySubShapeExplorer.Next(); - } - } -} - -//======================================================================= -//function : MakeNeighboursList -//purpose : find edges connected to Earg by Varg -//======================================================================= - const TopTools_ListOfShape & BOP_WireEdgeSet::MakeNeighboursList(const TopoDS_Shape& Earg, - const TopoDS_Shape& Varg) -{ - const TopoDS_Edge& E = TopoDS::Edge(Earg); - const TopoDS_Vertex& V = TopoDS::Vertex(Varg); - - const TopTools_ListOfShape& l = mySubShapeMap.FindFromKey(Varg); - - Standard_Integer nclosing = NbClosingShapes(l); - if (nclosing) { - // build myCurrentShapeNeighbours = - // edge list made of connected shapes to Earg through Varg - myCurrentShapeNeighbours.Clear(); - - Standard_Integer iapp = 0; - for (TopTools_ListIteratorOfListOfShape it(l); it.More(); it.Next()) { - iapp++; - const TopoDS_Shape& curn = it.Value(); // current neighbour - Standard_Boolean k = VertexConnectsEdgesClosing(Varg, Earg, curn); - if (k) { - myCurrentShapeNeighbours.Append(curn); - } - } - - Standard_Integer newn = NbClosingShapes(myCurrentShapeNeighbours); - if (newn >= 2 ) { - - const TopoDS_Face& F = myFace; - // several sewing edges connected to E by V such as : - // orientation of V in E # orientation of V in its edges. - // one leaves among the connected sewing edges, - // only edge A that checks tg(E) ^ tg(A) > 0 - - TopAbs_Orientation Eori; - gp_Vec2d d1E; gp_Pnt2d pE; - Standard_Real fiE, laE, tolpc, parE; - - parE = BRep_Tool::Parameter(V,E); - - Handle(Geom2d_Curve) PCE; - BOPTools_Tools2D::CurveOnSurface(E, F, PCE, fiE, laE, tolpc, Standard_False); - - if (!PCE.IsNull()){ - PCE->D1(parE, pE, d1E); - } - else { - LocalD1 (F, E, V, pE, d1E); - } - - Eori = E.Orientation(); - if (Eori == TopAbs_REVERSED) { - d1E.Reverse(); - } - - TopTools_ListIteratorOfListOfShape lclo(myCurrentShapeNeighbours); - Standard_Integer rang = 0; - while (lclo.More()) { - rang++; - - if ( ! IsClosed(lclo.Value()) ) { - lclo.Next(); - continue; - } - - const TopoDS_Edge& EE = TopoDS::Edge(lclo.Value()); - Standard_Real parEE, fiEE, laEE, tolpcc; - gp_Vec2d d1EE; gp_Pnt2d pEE; - - parEE = BRep_Tool::Parameter(V,EE); - - Handle(Geom2d_Curve) PCEE; - BOPTools_Tools2D::CurveOnSurface (EE, F, PCEE, fiEE, laEE, tolpcc, Standard_False);// - // - if (!PCEE.IsNull()) { - PCEE->D1(parEE,pEE,d1EE); - - } - else { - LocalD1(F, EE, V, pEE, d1EE); - } - - TopAbs_Orientation EEori = EE.Orientation(); - if (EEori == TopAbs_REVERSED) d1EE.Reverse(); - - Standard_Real cross = d1E.Crossed(d1EE); - TopAbs_Orientation oVE,oVEE; - - // modified by NIZHNY-MKK Fri May 30 10:17:10 2003.BEGIN - GetOrientationVOnE(V,E,EE,oVE,oVEE); -// VertexConnectsEdges(V,E,EE,oVE,oVEE); - // modified by NIZHNY-MKK Fri May 30 10:17:13 2003.END - - Standard_Boolean t2 = ( (cross > 0) && oVE == TopAbs_REVERSED ) || - ( (cross < 0) && oVE == TopAbs_FORWARD ); - - if ( t2 ) { //-- t1 - // this is proper IsClosed, only it is preserved among IsClosed - lclo.Next(); - } - else { - // edge IsClosed is suspended - myCurrentShapeNeighbours.Remove(lclo); - } - }// end of while (lclo.More()) - }// end of if (newn >= 2 ) - return myCurrentShapeNeighbours; - }// end of if (nclosing) - - else { - return l; - } -} // MakeNeighoursList - -//======================================================================= -//function : VertexConnectsEdges -//purpose : -//======================================================================= - Standard_Boolean BOP_WireEdgeSet::VertexConnectsEdges(const TopoDS_Shape& V, - const TopoDS_Shape& E1, - const TopoDS_Shape& E2, - TopAbs_Orientation& o1, - TopAbs_Orientation& o2) const -{ - TopExp_Explorer ex1, ex2; - ex1.Init(E1,TopAbs_VERTEX); - for(; ex1.More(); ex1.Next()) { - - if (V.IsSame(ex1.Current())) { - ex2.Init(E2,TopAbs_VERTEX); - for(; ex2.More(); ex2.Next()) { - - if (V.IsSame(ex2.Current())) { - o1 = ex1.Current().Orientation(); - o2 = ex2.Current().Orientation(); - if ( o1 != o2 ) { - return Standard_True; - } - } - } - } - } - return Standard_False; -} - - -//======================================================================= -//function : VertexConnectEdgesClosing -//purpose : -//======================================================================= - Standard_Boolean BOP_WireEdgeSet::VertexConnectsEdgesClosing(const TopoDS_Shape& V, - const TopoDS_Shape& E1, - const TopoDS_Shape& E2) const -{ -// Let S the set of incident edges on vertex V. -// S contains at least one closed edge on the periodic face to build. -// (the face implied in closing test of edge is myFace) -// E1,E2 are S shapes (sharing V). -// -// if E1 and E2 are not closed : edges are NOT connected -// if E1 or E2 is/are closed : -// if V changes of relative orientation between E1,E2 : edges are connected -// else : edges are NOT connected -// -// example with E1 NOT closed, E2 closed : -// -// E1 FORWARD, V REVERSED on E1 -// E2 FORWARD, V FORWARD on E2 --> edges are connected -// -// E1 FORWARD, V REVERSED on E1 -// E2 REVERSED, V FORWARD on E2 --> edges are NOT connected -//----------------------------------------------------------------------- - - Standard_Boolean c1 = IsClosed(E1); - Standard_Boolean c2 = IsClosed(E2); - - Standard_Boolean testconnect = c1 || c2; - Standard_Boolean resu = Standard_False; - TopAbs_Orientation o1,o2; - - // SSCONNEX = False ==> E2 is selected to create as many - // (default) faces as there are components connected in UV. - // SSCONNEX = True ==> the entire edge E2 sharing V with E1 is taken - // so that orientation(V/E1) # orientation(V/E2) - // ==> face of part and other sewings - if ((c1 && c2)) { - Standard_Boolean u1 = c1 ? IsUClosed(E1) : Standard_False; - Standard_Boolean v1 = c1 ? IsVClosed(E1) : Standard_False; - Standard_Boolean u2 = c2 ? IsUClosed(E2) : Standard_False; - Standard_Boolean v2 = c2 ? IsVClosed(E2) : Standard_False; - Standard_Boolean uvdiff = (u1 && v2) || (u2 && v1); - testconnect = uvdiff; - } - - if (testconnect) { - resu = VertexConnectsEdges(V,E1,E2,o1,o2); - } - else { - // cto 012 O2 sewing edge of cylindric face - // chain of components split ON and OUT of the same orientation - TopAbs_Orientation oe1 = E1.Orientation(); - TopAbs_Orientation oe2 = E2.Orientation(); - Standard_Boolean iseq = E1.IsEqual(E2); - if ( (c1 && c2) && (oe1 == oe2) && (!iseq) ) { - resu = VertexConnectsEdges(V,E1,E2,o1,o2); - } - } - return resu; -} - -//======================================================================= -//function : NbClosingShapes -//purpose : -//======================================================================= - Standard_Integer BOP_WireEdgeSet::NbClosingShapes(const TopTools_ListOfShape & L) const -{ - Standard_Integer n = 0; - TopTools_ListIteratorOfListOfShape it(L); - for ( ; it.More(); it.Next()) { - const TopoDS_Shape& S = it.Value(); - if ( IsClosed(S) ) { - n++; - } - } - return n; -} - -//======================================================================= -//function : LocalD1 -//purpose : -//======================================================================= - void BOP_WireEdgeSet::LocalD1(const TopoDS_Face& F, - const TopoDS_Edge& E, - const TopoDS_Vertex& V, - gp_Pnt2d& ,//pE, - gp_Vec2d& d1E) const -{ - TopLoc_Location Loc; - Standard_Real parE, fiE, laE, u, v; - - parE = BRep_Tool::Parameter(V,E); - - Handle(Geom_Curve) CE = BRep_Tool::Curve(E, Loc, fiE, laE); - CE = Handle(Geom_Curve)::DownCast(CE->Transformed(Loc.Transformation())); - - gp_Pnt p3dE; gp_Vec d3dE; - CE->D1(parE, p3dE, d3dE); - - Handle(Geom_Surface) S = BRep_Tool::Surface(F); - GeomAPI_ProjectPointOnSurf proj(p3dE,S); - - proj.LowerDistanceParameters(u,v); - gp_Pnt bid; - gp_Vec d1u,d1v; - S->D1(u,v,bid,d1u,d1v); - u = d3dE.Dot(d1u); - v = d3dE.Dot(d1v); - d1E.SetCoord(u,v); -} - -//======================================================================= -//function : IsClosed -//purpose : -//======================================================================= - Standard_Boolean BOP_WireEdgeSet::IsClosed(const TopoDS_Shape& E) const -{ - const TopoDS_Edge& EE = TopoDS::Edge(E); - Standard_Boolean closed = BRep_Tool::IsClosed(EE,myFace); - - // modified by NIZHNY-MKK Wed May 12 15:44:10 2004.BEGIN - if(closed) { - TopoDS_Edge aE1, aE2; - BOPTools_Tools3D::GetSeam (myFace, aE1, aE2); - - if(aE1.IsNull() || aE2.IsNull()) { - closed = Standard_False; - } - } - // modified by NIZHNY-MKK Wed May 12 15:44:14 2004.END - - return closed; -} - -//======================================================================= -//function : IsUVISO -//purpose : -//======================================================================= - void BOP_WireEdgeSet::IsUVISO(const TopoDS_Edge& E, - const TopoDS_Face& F, - Standard_Boolean& uiso, - Standard_Boolean& viso) -{ - uiso = viso = Standard_False; - Standard_Real fE, lE,tolpc; - - Handle(Geom2d_Curve) PC; - BOPTools_Tools2D::CurveOnSurface (E, F, PC, fE, lE, tolpc, Standard_False);// - - if (PC.IsNull()) { - Standard_ProgramError::Raise("BOP_WireEdgeSet::IsUVISO"); - } - - Handle(Standard_Type) TheType = PC->DynamicType(); - if (TheType == STANDARD_TYPE(Geom2d_Line)) { - const Handle(Geom2d_Line)& HL = *((Handle(Geom2d_Line)*)&PC); - const gp_Dir2d& D = HL->Direction(); - Standard_Real tol = Precision::Angular(); - if (D.IsParallel(gp_Dir2d(0.,1.),tol)) { - uiso = Standard_True; - } - else if (D.IsParallel(gp_Dir2d(1.,0.),tol)) { - viso = Standard_True; - } - } -} - -//======================================================================= -//function : IsUClosed -//purpose : -//======================================================================= - Standard_Boolean BOP_WireEdgeSet::IsUClosed(const TopoDS_Shape& E) const -{ - const TopoDS_Edge& EE = TopoDS::Edge(E); - - Standard_Boolean bid, closed; - IsUVISO(EE, myFace, closed, bid); - return closed; -} - - -//======================================================================= -//function : IsVClosed -//purpose : -//======================================================================= - Standard_Boolean BOP_WireEdgeSet::IsVClosed(const TopoDS_Shape& E) const -{ - const TopoDS_Edge& EE = TopoDS::Edge(E); - - Standard_Boolean bid, closed; - IsUVISO (EE, myFace, bid, closed); - return closed; -} - -//======================================================================= -//function : Face -//purpose : -//======================================================================= - const TopoDS_Face& BOP_WireEdgeSet::Face() const -{ - return myFace; -} -//======================================================================= -//function : BOP_Tools::KeptTwice -//purpose : -//======================================================================= - Standard_Boolean BOP_WireEdgeSet::KeptTwice (const TopoDS_Edge& aSpEF2) const - - -{ - Standard_Integer iCnt=0; - - const TopTools_ListOfShape& aWESList=StartElements(); - - TopTools_ListIteratorOfListOfShape anIt(aWESList); - for (; anIt.More(); anIt.Next()) { - const TopoDS_Shape& aSS=anIt.Value(); - if (aSpEF2.IsSame(aSS)) { - iCnt++; - if (iCnt > 1) { - return Standard_True; - } - } - } - return Standard_False; -} -//======================================================================= -//function : BOP_Tools::RemoveEdgeFromWES -//purpose : -//======================================================================= - void BOP_WireEdgeSet::RemoveEdgeFromWES(const TopoDS_Edge& aSpEF2) - -{ - TopTools_ListOfShape aTmpList; - aTmpList=StartElements(); - - ClearContents(); - - TopTools_ListIteratorOfListOfShape anIt(aTmpList); - for (; anIt.More(); anIt.Next()) { - const TopoDS_Shape& aSS=anIt.Value(); - if (!aSpEF2.IsEqual(aSS)) { - AddStartElement(aSS); - } - } -} - - -// modified by NIZHNY-MKK Fri May 30 10:18:38 2003.BEGIN -void GetOrientationVOnE(const TopoDS_Shape& V, - const TopoDS_Shape& E1, - const TopoDS_Shape& E2, - TopAbs_Orientation& o1, - TopAbs_Orientation& o2) { - TopTools_IndexedMapOfShape aMap; - - TopExp::MapShapes(E1, TopAbs_VERTEX, aMap); - TopExp::MapShapes(E2, TopAbs_VERTEX, aMap); - - if(aMap.Extent() > 1) { - TopExp_Explorer ex1, ex2; - ex1.Init(E1,TopAbs_VERTEX); - - for(; ex1.More(); ex1.Next()) { - - if (V.IsSame(ex1.Current())) { - ex2.Init(E2,TopAbs_VERTEX); - - for(; ex2.More(); ex2.Next()) { - - if (V.IsSame(ex2.Current())) { - o1 = ex1.Current().Orientation(); - o2 = ex2.Current().Orientation(); - - if ( o1 != o2 ) { - return; - } - } - } - } - } - } - else { - TopoDS_Shape VV = V; - - if(E1.Orientation() == TopAbs_REVERSED) - VV.Reverse(); - o1 = VV.Orientation(); - VV.Reverse(); - o2 = VV.Orientation(); - } - return; -} -// modified by NIZHNY-MKK Fri May 30 10:18:40 2003.END diff --git a/src/BOP/BOP_WireShape.cdl b/src/BOP/BOP_WireShape.cdl deleted file mode 100755 index 5bf18edfeb..0000000000 --- a/src/BOP/BOP_WireShape.cdl +++ /dev/null @@ -1,62 +0,0 @@ --- Created on: 2002-02-04 --- Created by: Peter KURNEV --- Copyright (c) 2002-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class WireShape from BOP inherits Builder from BOP - - ---Purpose: - -- The Root class to perform a Boolean Operations (BO) - -- Common,Cut,Fuse between arguments when one of them is - -- a wire - -uses --- Wire from TopoDS, - ListOfShape from TopTools - -is - Create - returns WireShape from BOP; - ---Purpose: - --- Empty constructor; - --- - - ---------------------------------------------- - -- - -- W E S C O M P O N E N T S - -- - -- (for internal usage) - -- - -- - AddSplitPartsINOUT(me:out); - - AddSplitPartsON(me:out); - - MakeResult(me:out); - ---Purpose: - --- Constructs the result of the BO - --- - - -fields - - myLS : ListOfShape from TopTools - is protected; - -end WireShape; diff --git a/src/BOP/BOP_WireShape.cxx b/src/BOP/BOP_WireShape.cxx deleted file mode 100755 index b277163e4a..0000000000 --- a/src/BOP/BOP_WireShape.cxx +++ /dev/null @@ -1,358 +0,0 @@ -// Created on: 2002-02-04 -// Created by: Peter KURNEV -// Copyright (c) 2002-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#include - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include -#include -#include -#include - - -static - Standard_Integer InOrOut(const TopoDS_Vertex& , - const TopoDS_Edge& ); -static - TopAbs_Orientation Orientation(const TopoDS_Vertex& , - const TopoDS_Edge& ); -static - void OrientEdgesOnWire(const TopoDS_Wire& , - TopoDS_Wire& ); - -//======================================================================= -// function: BOP_WireShape::BOP_WireShape -// purpose: -//======================================================================= - BOP_WireShape::BOP_WireShape() -{ -} -//======================================================================= -// function: MakeResult -// purpose: -//======================================================================= - void BOP_WireShape::MakeResult() -{ - BRep_Builder aBB; - TopoDS_Compound aCompound; - - aBB.MakeCompound(aCompound); - - TopoDS_Wire aWNew; - BOP_ListOfConnexityBlock aLCB; - BOP_BuilderTools::MakeConnexityBlocks(myLS, TopAbs_EDGE, aLCB); - BOP_ListIteratorOfListOfConnexityBlock aLCBIt(aLCB); - for (; aLCBIt.More(); aLCBIt.Next()) { - const BOP_ConnexityBlock& aCB=aLCBIt.Value(); - const TopTools_ListOfShape& aLE=aCB.Shapes(); - TopoDS_Wire aW; - aBB.MakeWire(aW); - TopTools_ListIteratorOfListOfShape anIt(aLE); - for (; anIt.More(); anIt.Next()) { - const TopoDS_Edge& aE=TopoDS::Edge(anIt.Value()); - aBB.Add(aW, aE); - } - OrientEdgesOnWire(aW, aWNew); - aBB.Add(aCompound, aWNew); - } - myResult=aCompound; -} - -//======================================================================= -// function: AddSplitPartsINOUT -// purpose: -//======================================================================= - void BOP_WireShape::AddSplitPartsINOUT() -{ - const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); - const BOPTools_PaveFiller& aPaveFiller=myDSFiller->PaveFiller(); - const BOPTools_SplitShapesPool& aSplitShapesPool=aPaveFiller.SplitShapesPool(); - // - Standard_Integer i, aNbPB, iRank, nSp, iBeg, iEnd; - TopAbs_ShapeEnum aType, aTypeArg1, aTypeArg2; - BooleanOperations_StateOfShape aState, aStateCmp; - // - aTypeArg1=aDS.Object().ShapeType(); - aTypeArg2=aDS.Tool().ShapeType(); - - iBeg=1; - iEnd=aDS.NumberOfShapesOfTheObject(); - - if (aTypeArg1!=TopAbs_WIRE && aTypeArg2==TopAbs_WIRE) { - iBeg=iEnd+1; - iEnd=aDS.NumberOfSourceShapes(); - } - else if (aTypeArg1==TopAbs_WIRE && aTypeArg2==TopAbs_WIRE){ - iBeg=1; - iEnd=aDS.NumberOfSourceShapes(); - } - // - - for (i=iBeg; i<=iEnd; ++i) { - aType=aDS.GetShapeType(i); - if (aType!=TopAbs_EDGE) { - continue; - } - const TopoDS_Edge& aE=TopoDS::Edge(aDS.Shape(i)); - - iRank=aDS.Rank(i); - aStateCmp=BOP_BuilderTools::StateToCompare(iRank, myOperation); - - const BOPTools_ListOfPaveBlock& aLPB=aSplitShapesPool(aDS.RefEdge(i)); - aNbPB=aLPB.Extent(); - // - if (!aNbPB) { - aState=aDS.GetState(i); - if (aState==aStateCmp) { - myLS.Append(aE); - } - } - // - else { - BOPTools_ListIteratorOfListOfPaveBlock aPBIt(aLPB); - for (; aPBIt.More(); aPBIt.Next()) { - const BOPTools_PaveBlock& aPB=aPBIt.Value(); - nSp=aPB.Edge(); - const TopoDS_Edge& aSS=TopoDS::Edge(aDS.Shape(nSp)); - aState=aDS.GetState(nSp); - if (aState==aStateCmp) { - myLS.Append(aSS); - } - } - } - } -} - -//======================================================================= -// function: AddSplitPartsON -// purpose: -//======================================================================= - void BOP_WireShape::AddSplitPartsON() -{ - if (myOperation==BOP_CUT || myOperation==BOP_CUT21) { - return; - } - - const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); - const BOPTools_PaveFiller& aPaveFiller=myDSFiller->PaveFiller(); - const BOPTools_CommonBlockPool& aCommonBlockPool=aPaveFiller.CommonBlockPool(); - - Standard_Integer i, aNbCB, nSpTaken, iBeg, iEnd; - TopAbs_ShapeEnum aType, aTypeArg1, aTypeArg2; - BOPTools_ListIteratorOfListOfCommonBlock anItCB; - // - aTypeArg1=aDS.Object().ShapeType(); - aTypeArg2=aDS.Tool().ShapeType(); - - iBeg=1; - iEnd=aDS.NumberOfShapesOfTheObject(); - if (aTypeArg1!=TopAbs_WIRE && aTypeArg2==TopAbs_WIRE) { - iBeg=iEnd+1; - iEnd=aDS.NumberOfSourceShapes(); - } - else if (aTypeArg1==TopAbs_WIRE && aTypeArg2==TopAbs_WIRE){ - iEnd=aDS.NumberOfSourceShapes(); - } - // - for (i=iBeg; i<=iEnd; ++i) { - aType=aDS.GetShapeType(i); - if (aType!=TopAbs_EDGE) { - continue; - } - // - const BOPTools_ListOfCommonBlock& aLCB=aCommonBlockPool(aDS.RefEdge(i)); - aNbCB=aLCB.Extent(); - - anItCB.Initialize(aLCB); - for (; anItCB.More(); anItCB.Next()) { - BOPTools_CommonBlock& aCB=anItCB.Value(); - const BOPTools_PaveBlock& aPB=aCB.PaveBlock1(); - nSpTaken=aPB.Edge(); - const TopoDS_Edge& aSS=TopoDS::Edge(aDS.Shape(nSpTaken)); - myLS.Append(aSS); - } - } -} - -//======================================================================= -// function: OrientEdgesOnWire -// purpose: -//======================================================================= -void OrientEdgesOnWire(const TopoDS_Wire& aWire, - TopoDS_Wire& aWireNew) -{ - Standard_Integer i, aNbV, aNbE, j, iCnt, iInOrOut, aNbRest; - - TopTools_IndexedDataMapOfShapeListOfShape aVEMap; - TopTools_IndexedMapOfShape aProcessedEdges, aRestEdges, aEMap; - TopTools_ListIteratorOfListOfShape anIt; - BRep_Builder aBB; - - aBB.MakeWire(aWireNew); - - TopExp::MapShapesAndAncestors(aWire, TopAbs_VERTEX, TopAbs_EDGE, aVEMap); - - aNbV=aVEMap.Extent(); - // - // Do - for (i=1; i<=aNbV; i++) { - const TopoDS_Vertex& aV=TopoDS::Vertex(aVEMap.FindKey(i)); - - const TopTools_ListOfShape& aLE=aVEMap.FindFromIndex(i); - aNbE=aLE.Extent(); - - if (aNbE>=2) { - iCnt=0; - anIt.Initialize(aLE); - for(; anIt.More(); anIt.Next()) { - const TopoDS_Edge& aE=TopoDS::Edge(anIt.Value()); - if (aProcessedEdges.Contains(aE)) { - iInOrOut=InOrOut(aV, aE); - iCnt+=iInOrOut; - } - else { - aRestEdges.Add(aE); - } - } - - TopoDS_Edge* pE; - aNbRest=aRestEdges.Extent(); - for (j=1; j<=aNbRest; j++) { - const TopoDS_Edge& aE=TopoDS::Edge(aRestEdges(j)); - pE=(TopoDS_Edge*)&aE; - - iInOrOut=InOrOut(aV, aE); - if (iCnt>0) { - if (iInOrOut>0) { - pE->Reverse(); - } - --iCnt; - } - else if (iCnt<=0){ - if (iInOrOut<0) { - pE->Reverse(); - } - ++iCnt; - } - aProcessedEdges.Add(*pE); - } - }//if (aNbE>=2) - } - // - // - aNbE=aProcessedEdges.Extent(); - for (i=1; i<=aNbE; i++) { - const TopoDS_Edge& aE=TopoDS::Edge(aProcessedEdges(i)); - aBB.Add(aWireNew, aE); - } - - TopExp::MapShapes(aWire, TopAbs_EDGE, aEMap); - - aNbE=aEMap.Extent(); - for (i=1; i<=aNbE; i++) { - const TopoDS_Edge& aE=TopoDS::Edge(aEMap(i)); - if (!aProcessedEdges.Contains(aE)) { - aProcessedEdges.Add(aE); - aBB.Add(aWireNew, aE); - } - } -} - -//======================================================================= -//function : Orientation -//purpose : -//======================================================================= - TopAbs_Orientation Orientation(const TopoDS_Vertex& aV, - const TopoDS_Edge& aE) -{ - TopAbs_Orientation anOr=TopAbs_INTERNAL; - - TopExp_Explorer anExp; - anExp.Init(aE, TopAbs_VERTEX); - for (; anExp.More(); anExp.Next()) { - const TopoDS_Vertex& aVE1=TopoDS::Vertex(anExp.Current()); - if (aVE1.IsSame(aV)) { - anOr=aVE1.Orientation(); - break; - } - } - return anOr; -} - -///======================================================================= -//function : InOrOut -//purpose : -//======================================================================= - Standard_Integer InOrOut(const TopoDS_Vertex& aV, - const TopoDS_Edge& aE) -{ - TopAbs_Orientation anOrV, anOrE; - anOrV=aV.Orientation(); - anOrE=aE.Orientation(); - if (anOrV==TopAbs_INTERNAL){ - return 0; - } - - anOrV=Orientation(aV, aE); - - if (anOrV==anOrE) { - return -1; // escape - } - else { - return 1; // entry - } -} diff --git a/src/BOP/BOP_WireShell.cdl b/src/BOP/BOP_WireShell.cdl deleted file mode 100755 index f0333e3751..0000000000 --- a/src/BOP/BOP_WireShell.cdl +++ /dev/null @@ -1,83 +0,0 @@ --- Created on: 2002-02-04 --- Created by: Peter KURNEV --- Copyright (c) 2002-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class WireShell from BOP inherits WireShape from BOP - - ---Purpose: - -- The class to perform a Boolean Operations (BO) - -- Common,Cut,Fuse between arguments when one of them is - -- a wire and other argument is a shell - -- -uses - DSFiller from BOPTools, - PDSFiller from BOPTools, - --modified by NIZHNY-MKK Tue Sep 7 11:46:27 2004 - ShapeEnum from TopAbs, - Operation from BOP, - ListOfShape from TopTools -is - Create - returns WireShell from BOP; - ---Purpose: - --- Empty constructor; - --- - Do (me:out) - is redefined; - ---Purpose: - --- See base classes, please - --- - DoWithFiller (me:out; - aDSF: DSFiller from BOPTools) - is redefined; - ---Purpose: - --- See base classes, please - --- - Destroy (me: in out) - is redefined; - ---C++: alias "Standard_EXPORT virtual ~BOP_WireShell(){Destroy();}" - ---Purpose: - --- Destructor - --- - BuildResult (me:out) - is redefined; - ---Purpose: - --- See base classes, please - --- - --modified by NIZHNY-MKK Tue Sep 7 11:46:00 2004 - CheckArgTypes(myclass; theType1, theType2: ShapeEnum from TopAbs; - theOperation: Operation from BOP) - returns Boolean from Standard; - ---Purpose: - --- Check the types of arguments. - --- Returns FALSE if types of arguments - --- are non-valid to be treated by the - --- agorithm - - CheckArgTypes(me) - returns Boolean from Standard - is private; - ---Purpose: - --- Internal usage - --- - ---fields - -end WireShell; diff --git a/src/BOP/BOP_WireShell.cxx b/src/BOP/BOP_WireShell.cxx deleted file mode 100755 index 17cc4163a8..0000000000 --- a/src/BOP/BOP_WireShell.cxx +++ /dev/null @@ -1,195 +0,0 @@ -// Created on: 2002-02-04 -// Created by: Peter KURNEV -// Copyright (c) 2002-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include - -#include -#include - -#include - -#include - -#include - -#include -#include -#include - -#include - -//======================================================================= -// function: BOP_WireShell::BOP_WireShell -// purpose: -//======================================================================= -BOP_WireShell::BOP_WireShell() -{ -} -//======================================================================= -// function: Destroy -// purpose: -//======================================================================= - void BOP_WireShell::Destroy() -{ -} -//======================================================================= -// function: Do -// purpose: -//======================================================================= - void BOP_WireShell::Do() -{ - myErrorStatus=0; - myIsDone=Standard_False; - // - // Filling the DS - BOPTools_DSFiller aDSFiller; - aDSFiller.SetShapes (myShape1, myShape2); - // - aDSFiller.Perform (); - // - DoWithFiller(aDSFiller); -} - -//======================================================================= -// function: DoWithFiller -// purpose: -//======================================================================= - void BOP_WireShell::DoWithFiller(const BOPTools_DSFiller& aDSFiller) -{ - myErrorStatus=0; - myIsDone=Standard_False; - // - myResultMap.Clear(); - myModifiedMap.Clear(); - // - myDSFiller=(BOPTools_DSFiller*) &aDSFiller; - // - try { - OCC_CATCH_SIGNALS - - if(!myDSFiller->IsDone()) { - myErrorStatus = 1; - BOPTColStd_Dump::PrintMessage("DSFiller is invalid: Can not build result\n"); - return; - } - - Standard_Boolean bCheckTypes; - // - bCheckTypes=CheckArgTypes(); - if (!bCheckTypes) { - myErrorStatus=10; - return; - } - // - Standard_Boolean bIsNewFiller; - bIsNewFiller=aDSFiller.IsNewFiller(); - - if (bIsNewFiller) { - // - // Preparing the States - const BOPTools_PaveFiller& aPaveFiller=myDSFiller->PaveFiller(); - BOPTools_WireStateFiller aStateFiller(aPaveFiller); - aStateFiller.Do(); - - aDSFiller.SetNewFiller(!bIsNewFiller); - } - // - BuildResult(); - // - BOP_CorrectTolerances::CorrectTolerances(myResult, 0.01); - // - FillModified(); - myIsDone=Standard_True; - } - catch ( Standard_Failure ) { - myErrorStatus = 1; - BOPTColStd_Dump::PrintMessage("Can not build result\n"); - } -} - -//======================================================================= -// function: BuildResult -// purpose: -//======================================================================= - void BOP_WireShell::BuildResult() -{ - AddSplitPartsINOUT(); - AddSplitPartsON(); - // - MakeResult(); -} - -//======================================================================= -// function: CheckArgTypes -// purpose: -//======================================================================= -Standard_Boolean BOP_WireShell::CheckArgTypes(const TopAbs_ShapeEnum theType1, - const TopAbs_ShapeEnum theType2, - const BOP_Operation theOperation) -{ - Standard_Boolean bFlag=Standard_False; - - // - if (theType1==TopAbs_WIRE && theType2==TopAbs_SHELL) { - if (theOperation==BOP_FUSE || theOperation==BOP_CUT21) { - return bFlag; - } - } - // - if (theType1==TopAbs_SHELL && theType2==TopAbs_WIRE) { - if (theOperation==BOP_FUSE || theOperation==BOP_CUT) { - return bFlag; - } - } - // - return !bFlag; -} - - -//======================================================================= -// function: CheckArgTypes -// purpose: -//======================================================================= - Standard_Boolean BOP_WireShell::CheckArgTypes() const -{ -// Standard_Boolean bFlag=Standard_False; - - TopAbs_ShapeEnum aT1, aT2; - const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); - - aT1=aDS.Object().ShapeType(); - aT2=aDS.Tool().ShapeType(); - // -// if (aT1==TopAbs_WIRE && aT2==TopAbs_SHELL) { -// if (myOperation==BOP_FUSE || myOperation==BOP_CUT21) { -// return bFlag; -// } -// } -// // -// if (aT1==TopAbs_SHELL && aT2==TopAbs_WIRE) { -// if (myOperation==BOP_FUSE || myOperation==BOP_CUT) { -// return bFlag; -// } -// } -// // -// return !bFlag; - return CheckArgTypes(aT1, aT2, myOperation); -} diff --git a/src/BOP/BOP_WireSolid.cdl b/src/BOP/BOP_WireSolid.cdl deleted file mode 100755 index 1a8a80d299..0000000000 --- a/src/BOP/BOP_WireSolid.cdl +++ /dev/null @@ -1,95 +0,0 @@ --- Created on: 2002-02-04 --- Created by: Peter KURNEV --- Copyright (c) 2002-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class WireSolid from BOP inherits WireShape from BOP - - ---Purpose: - -- The class is to perform a Boolean Operations (BO) - -- Common,Cut,Fuse between arguments when one of them is - -- a wire and other argument is a solid - -- - -uses - DSFiller from BOPTools, - PDSFiller from BOPTools, - HistoryCollector from BOP, - --modified by NIZHNY-MKK Tue Sep 7 11:42:36 2004 - ShapeEnum from TopAbs, - Operation from BOP, - ListOfShape from TopTools - - -is - Create - returns WireSolid from BOP; - ---Purpose: - --- Empty constructor; - --- - Do (me:out) - is redefined; - ---Purpose: - --- (See base classes, please) - --- - DoWithFiller (me:out; - aDSF: DSFiller from BOPTools) - is redefined; - ---Purpose: - --- (See base classes, please) - --- - Destroy (me: in out) - is redefined; - ---C++: alias "Standard_EXPORT virtual ~BOP_WireSolid(){Destroy();}" - ---Purpose: - --- Destructor - --- - BuildResult (me:out) - is redefined; - ---Purpose: - --- (See base classes, please) - --- - --modified by NIZHNY-MKK Tue Sep 7 11:41:46 2004 - CheckArgTypes(myclass; theType1, theType2: ShapeEnum from TopAbs; - theOperation: Operation from BOP) - returns Boolean from Standard; - ---Purpose: - --- Check the types of arguments. - --- Returns FALSE if types of arguments - --- are non-valid to be treated by the - --- agorithm - - CheckArgTypes(me) - returns Boolean from Standard - is private; - ---Purpose: - --- Internal usage - --- - AddSplitParts(me:out) - is private; - ---Purpose: - --- Internal usage - --- - - SetHistoryCollector(me: in out; theHistory: HistoryCollector from BOP) - is redefined virtual; - ---fields - -end WireSolid; diff --git a/src/BOP/BOP_WireSolid.cxx b/src/BOP/BOP_WireSolid.cxx deleted file mode 100755 index 3ae677baee..0000000000 --- a/src/BOP/BOP_WireSolid.cxx +++ /dev/null @@ -1,282 +0,0 @@ -// Created on: 2002-02-04 -// Created by: Peter KURNEV -// Copyright (c) 2002-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include - -#include -#include - -#include -#include - -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - - -#include -#include -#include - -//======================================================================= -// function: BOP_WireSolid::BOP_WireSolid -// purpose: -//======================================================================= -BOP_WireSolid::BOP_WireSolid() -{ -} -//======================================================================= -// function: Destroy -// purpose: -//======================================================================= - void BOP_WireSolid::Destroy() -{ -} -//======================================================================= -// function: Do -// purpose: -//======================================================================= - void BOP_WireSolid::Do() -{ - myErrorStatus=0; - myIsDone=Standard_False; - // - // Filling the DS - BOPTools_DSFiller aDSFiller; - aDSFiller.SetShapes (myShape1, myShape2); - // - aDSFiller.Perform (); - // - DoWithFiller(aDSFiller); -} - -//======================================================================= -// function: DoWithFiller -// purpose: -//======================================================================= - void BOP_WireSolid::DoWithFiller(const BOPTools_DSFiller& aDSFiller) -{ - myErrorStatus=0; - myIsDone=Standard_False; - myResultMap.Clear(); - myModifiedMap.Clear(); - myDSFiller=(BOPTools_DSFiller*) &aDSFiller; - // - try { - OCC_CATCH_SIGNALS - - if(!myDSFiller->IsDone()) { - myErrorStatus = 1; - BOPTColStd_Dump::PrintMessage("DSFiller is invalid: Can not build result\n"); - return; - } - - Standard_Boolean bCheckTypes; - // - bCheckTypes=CheckArgTypes(); - if (!bCheckTypes) { - myErrorStatus=10; - return; - } - // - Standard_Boolean bIsNewFiller; - bIsNewFiller=aDSFiller.IsNewFiller(); - - if (bIsNewFiller) { - // - // Preparing the States - const BOPTools_PaveFiller& aPaveFiller=myDSFiller->PaveFiller(); - BOPTools_WireStateFiller aStateFiller(aPaveFiller); - aStateFiller.Do(); - - aDSFiller.SetNewFiller(!bIsNewFiller); - } - // - BuildResult(); - // - BOP_CorrectTolerances::CorrectTolerances(myResult, 0.01); - // - FillModified(); - - if(!myHistory.IsNull()) { - Handle(BOP_WireSolidHistoryCollector) aHistory = - Handle(BOP_WireSolidHistoryCollector)::DownCast(myHistory); - aHistory->SetResult(myResult, myDSFiller); - } - myIsDone=Standard_True; - } - catch ( Standard_Failure ) { - myErrorStatus = 1; - BOPTColStd_Dump::PrintMessage("Can not build result\n"); - } -} - -//======================================================================= -// function: BuildResult -// purpose: -//======================================================================= - void BOP_WireSolid::BuildResult() -{ - - AddSplitParts(); - // - MakeResult(); -} - -//======================================================================= -// function: CheckArgTypes -// purpose: -//======================================================================= -Standard_Boolean BOP_WireSolid::CheckArgTypes(const TopAbs_ShapeEnum theType1, - const TopAbs_ShapeEnum theType2, - const BOP_Operation theOperation) -{ - Standard_Boolean bFlag=Standard_False; - - if (theType1==TopAbs_WIRE && theType2==TopAbs_SOLID) { - if (theOperation==BOP_FUSE || theOperation==BOP_CUT21) { - return bFlag; - } - } - // - if (theType1==TopAbs_SOLID && theType2==TopAbs_WIRE) { - if (theOperation==BOP_FUSE || theOperation==BOP_CUT) { - return bFlag; - } - } - // - return !bFlag; -} - -//======================================================================= -// function: CheckArgTypes -// purpose: -//======================================================================= - Standard_Boolean BOP_WireSolid::CheckArgTypes() const -{ -// Standard_Boolean bFlag=Standard_False; - - TopAbs_ShapeEnum aT1, aT2; - const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); - - aT1=aDS.Object().ShapeType(); - aT2=aDS.Tool().ShapeType(); - // -// if (aT1==TopAbs_WIRE && aT2==TopAbs_SOLID) { -// if (myOperation==BOP_FUSE || myOperation==BOP_CUT21) { -// return bFlag; -// } -// } -// // -// if (aT1==TopAbs_SOLID && aT2==TopAbs_WIRE) { -// if (myOperation==BOP_FUSE || myOperation==BOP_CUT) { -// return bFlag; -// } -// } -// // -// return !bFlag; - return CheckArgTypes(aT1, aT2, myOperation); -} - -//======================================================================= -// function: AddSplitParts -// purpose: -//======================================================================= - void BOP_WireSolid::AddSplitParts() -{ - - const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); - const BOPTools_PaveFiller& aPaveFiller=myDSFiller->PaveFiller(); - const BOPTools_SplitShapesPool& aSplitShapesPool=aPaveFiller.SplitShapesPool(); - // - Standard_Integer i, aNbPB, iRank, nSp, iBeg, iEnd; - TopAbs_ShapeEnum aType; - BooleanOperations_StateOfShape aState, aStateCmp; - - iBeg=1; - iEnd=aDS.NumberOfShapesOfTheObject(); - if (aDS.Tool().ShapeType()==TopAbs_WIRE) { - iBeg=iEnd+1; - iEnd=aDS.NumberOfSourceShapes(); - } - - for (i=iBeg; i<=iEnd; ++i) { - aType=aDS.GetShapeType(i); - if (aType!=TopAbs_EDGE) { - continue; - } - const TopoDS_Edge& aE=TopoDS::Edge(aDS.Shape(i)); - iRank=aDS.Rank(i); - - aStateCmp=BOP_BuilderTools::StateToCompare(iRank, myOperation); - - const BOPTools_ListOfPaveBlock& aLPB=aSplitShapesPool(aDS.RefEdge(i)); - aNbPB=aLPB.Extent(); - // - if (!aNbPB) { - aState=aDS.GetState(i); - if (aState==aStateCmp) { - myLS.Append(aE); - } - if (myOperation==BOP_COMMON && aState==BooleanOperations_ON) { - myLS.Append(aE); - } - } - // - else { - BOPTools_ListIteratorOfListOfPaveBlock aPBIt(aLPB); - for (; aPBIt.More(); aPBIt.Next()) { - const BOPTools_PaveBlock& aPB=aPBIt.Value(); - nSp=aPB.Edge(); - const TopoDS_Edge& aSS=TopoDS::Edge(aDS.Shape(nSp)); - aState=aDS.GetState(nSp); - if (aState==aStateCmp) { - myLS.Append(aSS); - } - if (myOperation==BOP_COMMON && aState==BooleanOperations_ON) { - myLS.Append(aSS); - } - } - } - } -} - -//======================================================================= -// function: SetHistoryCollector -// purpose: -//======================================================================= -void BOP_WireSolid::SetHistoryCollector(const Handle(BOP_HistoryCollector)& theHistory) -{ - if(theHistory.IsNull() || - !theHistory->IsKind(STANDARD_TYPE(BOP_WireSolidHistoryCollector))) - myHistory.Nullify(); - else - myHistory = theHistory; -} diff --git a/src/BOP/BOP_WireSolidHistoryCollector.cdl b/src/BOP/BOP_WireSolidHistoryCollector.cdl deleted file mode 100755 index 46e9b106ca..0000000000 --- a/src/BOP/BOP_WireSolidHistoryCollector.cdl +++ /dev/null @@ -1,45 +0,0 @@ --- Created on: 2003-04-24 --- Created by: Michael KLOKOV --- Copyright (c) 2003-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class WireSolidHistoryCollector from BOP inherits HistoryCollector from BOP - -uses - Shape from TopoDS, - Operation from BOP, - PDSFiller from BOPTools, - ListOfShape from TopTools -is - Create(theShape1 : Shape from TopoDS; - theShape2 : Shape from TopoDS; - theOperation: Operation from BOP) - returns WireSolidHistoryCollector from BOP; - - SetResult(me: mutable; theResult: Shape from TopoDS; - theDSFiller: PDSFiller from BOPTools) - is redefined virtual; - - --- private - FillSection(me: mutable; theDSFiller: PDSFiller from BOPTools) - is private; - - FillEdgeHistory(me: mutable; theDSFiller: PDSFiller from BOPTools) - is private; - -end WireSolidHistoryCollector from BOP; diff --git a/src/BOP/BOP_WireSolidHistoryCollector.cxx b/src/BOP/BOP_WireSolidHistoryCollector.cxx deleted file mode 100755 index 5185bb4e38..0000000000 --- a/src/BOP/BOP_WireSolidHistoryCollector.cxx +++ /dev/null @@ -1,664 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -static Standard_Boolean AddNewShape(const TopoDS_Shape& theKey, - const TopoDS_Shape& theItem, - TopTools_DataMapOfShapeListOfShape& theMap); - -static void GetAncestorFaces(const Standard_Integer theShapeIndex, - const BooleanOperations_ShapesDataStructure& theDS, - TopTools_IndexedMapOfShape& theFaces); - -static Standard_Integer GetShapeWire(const BooleanOperations_ShapesDataStructure& theDS, - const TopoDS_Shape& S1, - const TopoDS_Shape& S2, - TopoDS_Shape& WS); - -// ==================================================================================================== -// function: Constructor -// purpose: -// ==================================================================================================== -BOP_WireSolidHistoryCollector::BOP_WireSolidHistoryCollector(const TopoDS_Shape& theShape1, - const TopoDS_Shape& theShape2, - const BOP_Operation theOperation) : -BOP_HistoryCollector(theShape1, theShape2, theOperation) -{ -} - -// ==================================================================================================== -// function: SetResult -// purpose: -// ==================================================================================================== -void BOP_WireSolidHistoryCollector::SetResult(const TopoDS_Shape& theResult, - const BOPTools_PDSFiller& theDSFiller) -{ - myResult = theResult; - - FillSection(theDSFiller); - FillEdgeHistory(theDSFiller); - - myHasDeleted = Standard_False; - - TopExp_Explorer anExp(myS1, TopAbs_FACE); - - if(!anExp.More()) { - anExp.Init(myS2, TopAbs_FACE); - - if(anExp.More()) { - myHasDeleted = Standard_True; - return; - } - } - else { - myHasDeleted = Standard_True; - return; - } - - Standard_Integer i = 0; - - for(i = (Standard_Integer)TopAbs_EDGE; !myHasDeleted && (i < (Standard_Integer)TopAbs_VERTEX); i++) { - TopAbs_ShapeEnum aType = (TopAbs_ShapeEnum) i; - TopTools_IndexedMapOfShape aMap; - TopExp::MapShapes(myResult, aType, aMap); - - TopExp_Explorer anExpObj(myS1, aType); - - for(; anExpObj.More(); anExpObj.Next()) { - const TopoDS_Shape& aS = anExpObj.Current(); - - if(!aMap.Contains(aS)) { - - if((!myModifMap.IsBound(aS) || myModifMap(aS).IsEmpty()) && - (!myGenMap.IsBound(aS) || myGenMap(aS).IsEmpty())) { - myHasDeleted = Standard_True; - break; - } - } - } - TopExp_Explorer anExpTool(myS2, aType); - - for(; anExpTool.More(); anExpTool.Next()) { - const TopoDS_Shape& aS = anExpTool.Current(); - - if(!aMap.Contains(aS)) { - if((!myModifMap.IsBound(aS) || myModifMap(aS).IsEmpty()) && - (!myGenMap.IsBound(aS) || myGenMap(aS).IsEmpty())) { - myHasDeleted = Standard_True; - break; - } - } - } - } -} - -// ==================================================================================================== -// function: FillSection -// purpose: -// ==================================================================================================== -void BOP_WireSolidHistoryCollector::FillSection(const BOPTools_PDSFiller& theDSFiller) -{ - // for edges - BOPTools_InterferencePool* pIntrPool = (BOPTools_InterferencePool*)&theDSFiller->InterfPool(); - const BOPTools_PavePool& aPavePool = theDSFiller->PaveFiller().PavePool(); - const BooleanOperations_ShapesDataStructure& aDS = theDSFiller->DS(); - Standard_Integer nb = aDS.NumberOfShapesOfTheObject() + aDS.NumberOfShapesOfTheTool(); - Standard_Integer i = 0; - TopTools_IndexedMapOfShape aResultMap; - - if(!myResult.IsNull()) { - TopExp::MapShapes(myResult, TopAbs_VERTEX, aResultMap); - } - - for(i = 1; i <= nb; i++) { - if(aDS.GetShapeType(i) != TopAbs_EDGE) - continue; - const BOPTools_PaveSet& aPaveSet = aPavePool.Value(aDS.RefEdge(i)); - const BOPTools_ListOfPave& aListOfPave = aPaveSet.Set(); - BOPTools_ListIteratorOfListOfPave anIt(aListOfPave); - TopTools_IndexedMapOfShape aMapOfVertex; - - for(; anIt.More(); anIt.Next()) { - const BOPTools_Pave& aPave = anIt.Value(); - - if((aPave.Type() == BooleanOperations_EdgeSurface) || - (aPave.Type() == BooleanOperations_EdgeEdge) || - (aPave.Type() == BooleanOperations_VertexEdge)) { - BOPTools_PShapeShapeInterference anInter = pIntrPool->GetInterference(aPave.Interference(), aPave.Type()); - - if(anInter != NULL) { - const TopoDS_Shape& aS1 = aDS.Shape(anInter->Index1()); - const TopoDS_Shape& aS2 = aDS.Shape(anInter->Index2()); - const TopoDS_Shape& aNewShape = aDS.Shape(anInter->NewShape()); - - if(aNewShape.ShapeType() != TopAbs_VERTEX) - continue; - - Standard_Boolean addfirst = Standard_False; - Standard_Boolean addsecond = Standard_False; - - if(aResultMap.Contains(aNewShape)) { - if(i == anInter->Index1()) { - addfirst = Standard_True; - - if(aS1.IsSame(aNewShape)) { - aMapOfVertex.Add(aNewShape); - continue; - } - - if(aPave.Type() != BooleanOperations_EdgeEdge) { - addsecond = Standard_True; - - if(aS2.IsSame(aNewShape)) { - aMapOfVertex.Add(aNewShape); - continue; - } - } - } - else { - addsecond = Standard_True; - - if(aS2.IsSame(aNewShape)) { - aMapOfVertex.Add(aNewShape); - continue; - } - - if(aPave.Type() != BooleanOperations_EdgeEdge) { - addfirst = Standard_True; - - if(aS1.IsSame(aNewShape)) { - aMapOfVertex.Add(aNewShape); - continue; - } - } - } - TopTools_ListOfShape thelist; - if(addfirst) { - // modified by NIZHNY-3643 Thu Nov 13 17:33:38 2003 .b - if( aPave.Type() == BooleanOperations_EdgeEdge) { - TopTools_IndexedMapOfShape aSharedFaces; - aSharedFaces.Clear(); - GetAncestorFaces(i,aDS,aSharedFaces); - Standard_Integer anbFaces = aSharedFaces.Extent(); - if( anbFaces != 0 ) { - Standard_Integer iFace = 0; - for( iFace = 1; iFace <= anbFaces; iFace++ ) { - if(!myGenMap.IsBound(aSharedFaces.FindKey(iFace))) - myGenMap.Bind(aSharedFaces.FindKey(iFace), thelist); - myGenMap.ChangeFind(aSharedFaces.FindKey(iFace)).Append(aNewShape); - } - } - else { - if(!myGenMap.IsBound(aS1)) - myGenMap.Bind(aS1, thelist); - myGenMap.ChangeFind(aS1).Append(aNewShape); - } - } - else { - if(!myGenMap.IsBound(aS1)) - myGenMap.Bind(aS1, thelist); - myGenMap.ChangeFind(aS1).Append(aNewShape); - } - // modified by NIZHNY-3643 Thu Nov 13 17:34:45 2003 .e - } - - if(addsecond) { - // modified by NIZHNY-3643 Thu Nov 13 17:33:38 2003 .b - if( aPave.Type() == BooleanOperations_EdgeEdge) { - TopTools_IndexedMapOfShape aSharedFaces; - aSharedFaces.Clear(); - GetAncestorFaces(i,aDS,aSharedFaces); - Standard_Integer anbFaces = aSharedFaces.Extent(); - if( anbFaces != 0 ) { - Standard_Integer iFace = 0; - for( iFace = 1; iFace <= anbFaces; iFace++ ) { - if(!myGenMap.IsBound(aSharedFaces.FindKey(iFace))) - myGenMap.Bind(aSharedFaces.FindKey(iFace), thelist); - myGenMap.ChangeFind(aSharedFaces.FindKey(iFace)).Append(aNewShape); - } - } - else { - if(!myGenMap.IsBound(aS2)) - myGenMap.Bind(aS2, thelist); - myGenMap.ChangeFind(aS2).Append(aNewShape); - } - } - else { - if(!myGenMap.IsBound(aS2)) - myGenMap.Bind(aS2, thelist); - myGenMap.ChangeFind(aS2).Append(aNewShape); - } - // modified by NIZHNY-3643 Thu Nov 13 19:01:19 2003 .e - } - } - } - } - } - // end for(; anIt.More... - - // fill history for edges which vertices are on other shape.begin - TopTools_IndexedDataMapOfShapeListOfShape aMapOfOldNewVertex, aVEMap; - TopExp::MapShapesAndAncestors(myResult, TopAbs_VERTEX, TopAbs_EDGE, aVEMap); - Standard_Integer j = 0, k = 0; - TopTools_ListOfShape thelist1; - for(j = 1; j <= aDS.NumberOfSuccessors(i); j++) { - Standard_Integer avindex = aDS.GetSuccessor(i, j); - - BOPTools_CArray1OfVVInterference& VVs = pIntrPool->VVInterferences(); - Standard_Integer aNb = VVs.Extent(); - - for (k = 1; k <= aNb; k++) { - BOPTools_VVInterference& VV=VVs(k); - Standard_Integer anIndex1 = VV.Index1(); - Standard_Integer anIndex2 = VV.Index2(); - - if((avindex == anIndex1) || (avindex == anIndex2)) { - Standard_Integer aNewShapeIndex = VV.NewShape(); - TopoDS_Shape aNewShape = aDS.Shape(aNewShapeIndex); - - if(!aVEMap.Contains(aNewShape)) - continue; - - if(aVEMap.FindFromKey(aNewShape).Extent() >= 2) - continue; - - for(Standard_Integer vit = 0; vit < 2; vit++) { - TopoDS_Shape aShape = (vit == 0) ? aDS.Shape(anIndex1) : aDS.Shape(anIndex2); - - if(!aMapOfOldNewVertex.Contains(aShape)) - aMapOfOldNewVertex.Add(aShape, thelist1); - aMapOfOldNewVertex.ChangeFromKey(aShape).Append(aNewShape); - } - break; - } - } - - for(Standard_Integer aninterit = 0; aninterit < 2; aninterit++) { - - if(aninterit == 0) - aNb = pIntrPool->VEInterferences().Extent(); - else - aNb = pIntrPool->VSInterferences().Extent(); - - for (k = 1; k <= aNb; k++) { - BOPTools_ShapeShapeInterference* anInterference = NULL; - - if(aninterit == 0) - anInterference = (BOPTools_ShapeShapeInterference*)(&pIntrPool->VEInterferences().Value(k)); - else - anInterference = (BOPTools_ShapeShapeInterference*)(&pIntrPool->VSInterferences().Value(k)); - Standard_Integer anIndex1 = anInterference->Index1(); - Standard_Integer anIndex2 = anInterference->Index2(); - - if((avindex == anIndex1) || (avindex == anIndex2)) { - Standard_Integer aNewShapeIndex = anInterference->NewShape(); - TopoDS_Shape aNewShape = aDS.Shape(aNewShapeIndex); - - if(!aVEMap.Contains(aNewShape)) - continue; - - if(aVEMap.FindFromKey(aNewShape).Extent() >= 2) - continue; - TopoDS_Shape aShape1 = aDS.Shape(avindex); - TopoDS_Shape aShape2 = (avindex == anIndex1) ? aDS.Shape(anIndex2) : aDS.Shape(anIndex1); - - if(!aMapOfOldNewVertex.Contains(aShape1)) - aMapOfOldNewVertex.Add(aShape1, thelist1); - aMapOfOldNewVertex.ChangeFromKey(aShape1).Append(aNewShape); - - AddNewShape(aShape2, aNewShape, myGenMap); - } - } - } - } - - // modified by NIZHNY-3643 Fri Nov 14 09:59:47 2003 .b - TopoDS_Shape WShape; - Standard_Integer wRank = GetShapeWire(aDS,myS1,myS2,WShape); - // modified by NIZHNY-3643 Fri Nov 14 09:59:53 2003 .e - - if(!aMapOfOldNewVertex.IsEmpty()) { - TopTools_IndexedDataMapOfShapeListOfShape aMapVE; - - // modified by NIZHNY-3643 Fri Nov 14 10:01:32 2003 .b - Standard_Integer iSh = 0; - TopoDS_Shape aCShape; - for( iSh = 1; iSh <= 2; iSh ++ ) { - - if( iSh == 1 ) { - TopExp::MapShapesAndAncestors(myS1, TopAbs_VERTEX, TopAbs_EDGE, aMapVE); - aCShape = myS1; - } - else { - aMapVE.Clear(); - TopExp::MapShapesAndAncestors(myS2, TopAbs_VERTEX, TopAbs_EDGE, aMapVE); - aCShape = myS2; - } - - Standard_Integer vit = 0; - - for(vit = 1; vit <= aMapOfOldNewVertex.Extent(); vit++) { - const TopoDS_Shape& aV = aMapOfOldNewVertex.FindKey(vit); - - if(!aMapVE.Contains(aV)) - continue; - TopTools_ListIteratorOfListOfShape aEIt(aMapVE.FindFromKey(aV)); - const TopTools_ListOfShape& aNewVList = aMapOfOldNewVertex.FindFromIndex(vit); - - if(aNewVList.IsEmpty()) - continue; - TopoDS_Shape aNewShape = aNewVList.First(); - - // for wire old - if( aCShape.IsSame(WShape) ) { - for(; aEIt.More(); aEIt.Next()) { - const TopoDS_Shape& aE = aEIt.Value(); - AddNewShape(aE, aNewShape, myGenMap); - } - // avoid shared edges from solids here - Standard_Integer eRank = aDS.Rank(i); - if( eRank != wRank ) { - TopTools_IndexedMapOfShape aSharedFaces; - aSharedFaces.Clear(); - GetAncestorFaces(i,aDS,aSharedFaces); - if( aSharedFaces.Extent() == 1 ) { - TopoDS_Shape aE = aDS.Shape(i); - AddNewShape(aE, aNewShape, myGenMap); - } - } - else { - TopoDS_Shape aE = aDS.Shape(i); - AddNewShape(aE, aNewShape, myGenMap); - } - } - else { - // for solid new - TopTools_IndexedMapOfShape aSharedFaces; - aSharedFaces.Clear(); - Standard_Integer sRank = (wRank == 1) ? 2 : 1; - for(; aEIt.More(); aEIt.Next()) { - const TopoDS_Shape& aE = aEIt.Value(); - Standard_Integer iE = aDS.ShapeIndex(aE,sRank); - if( iE != 0 ) - GetAncestorFaces(iE,aDS,aSharedFaces); - } - TopoDS_Shape aE = aDS.Shape(i); - Standard_Integer iE = aDS.ShapeIndex(aE,sRank); - if( iE != 0 ) - GetAncestorFaces(iE,aDS,aSharedFaces); - if( aSharedFaces.Extent() != 0 ) { - Standard_Integer anbFaces = aSharedFaces.Extent(); - Standard_Integer iFace = 0; - for( iFace = 1; iFace <= anbFaces; iFace++ ) { - AddNewShape(aSharedFaces.FindKey(iFace), aNewShape, myGenMap); - } - } - } - } - } - // modified by NIZHNY-3643 Fri Nov 14 10:02:19 2003 .e - } - // fill history for edges which vertices are on other shape.end - - if(!aMapOfVertex.IsEmpty()) { - if(!myResult.IsNull()) { - TopTools_IndexedDataMapOfShapeListOfShape aMapVE; - TopExp::MapShapesAndAncestors(myS1, TopAbs_VERTEX, TopAbs_EDGE, aMapVE); - TopExp::MapShapesAndAncestors(myS2, TopAbs_VERTEX, TopAbs_EDGE, aMapVE); - Standard_Integer vit = 0; - - for(vit = 1; vit <= aMapOfVertex.Extent(); vit++) { - const TopoDS_Shape& aV = aMapOfVertex(vit); - - if(!aMapVE.Contains(aV)) - continue; - TopTools_ListIteratorOfListOfShape aEIt(aMapVE.FindFromKey(aV)); - - for(; aEIt.More(); aEIt.Next()) { - const TopoDS_Shape& aE = aEIt.Value(); - AddNewShape(aE, aV, myGenMap); - } - TopoDS_Shape aE = aDS.Shape(i); - AddNewShape(aE, aV, myGenMap); - } - } - } - } -} - -// ==================================================================================================== -// function: FillEdgeHistory -// purpose: Fills modified map for edges, -// fills generated map for edges (vertex type of intersection, edge type of intersection) -// ==================================================================================================== -void BOP_WireSolidHistoryCollector::FillEdgeHistory(const BOPTools_PDSFiller& theDSFiller) -{ - const BooleanOperations_ShapesDataStructure& aDS = theDSFiller->DS(); - const BOPTools_PaveFiller& aPaveFiller = theDSFiller->PaveFiller(); - const BOPTools_SplitShapesPool& aSplitShapesPool = aPaveFiller.SplitShapesPool(); - TopTools_IndexedMapOfShape aResultMap; - - if(!myResult.IsNull()) { - TopExp::MapShapes(myResult, TopAbs_EDGE, aResultMap); - } - - Standard_Integer iRank = 1; - - for(; iRank <= 2; iRank++) { - BooleanOperations_StateOfShape aStateCmp, aState; - aStateCmp = BOP_BuilderTools::StateToCompare(iRank, myOp); - Standard_Integer i = 0; - Standard_Integer nb = aDS.NumberOfShapesOfTheObject(); - nb = (iRank == 1) ? nb : (nb + aDS.NumberOfShapesOfTheTool()); - Standard_Integer startindex = (iRank == 1) ? 1 : (aDS.NumberOfShapesOfTheObject() + 1); - - for(i = startindex; i <= nb; i++) { - if(aDS.GetShapeType(i) != TopAbs_EDGE) - continue; - const BOPTools_ListOfPaveBlock& aLPB = aSplitShapesPool(aDS.RefEdge(i)); - const TopoDS_Shape& anOldShape = aDS.Shape(i); - - if(!aLPB.IsEmpty()) { - BOPTools_ListIteratorOfListOfPaveBlock aPBIt(aLPB); - - for(; aPBIt.More(); aPBIt.Next()) { - const BOPTools_PaveBlock& aPB = aPBIt.Value(); - Standard_Integer nSp = aPB.Edge(); - - if(nSp == i) - continue; - aState=aDS.GetState(nSp); - - if ((aState == aStateCmp) || (myOp==BOP_COMMON && (aState == BooleanOperations_ON))) { - const TopoDS_Shape& aNewShape = aDS.Shape(nSp); - - if(aResultMap.Contains(aNewShape)) { - Standard_Integer bIsGenerated = Standard_True; - - if((myOp == BOP_CUT) || (myOp == BOP_FUSE)) { - bIsGenerated = (iRank == 2); - } - else { - if(myOp == BOP_CUT21) { - bIsGenerated = (iRank == 1); - } - else if(myOp == BOP_COMMON) { - bIsGenerated = Standard_False; - } - } - TopTools_DataMapOfShapeListOfShape& aHistoryMap = (bIsGenerated) ? myGenMap : myModifMap; - - if(aHistoryMap.IsBound(anOldShape)) { - aHistoryMap.ChangeFind(anOldShape).Append(aNewShape); - } - else { - TopTools_ListOfShape aShapeList; - aShapeList.Append(aNewShape); - aHistoryMap.Bind(anOldShape, aShapeList); - } - } - } - } - } - //end if(!aLPB.IsEmpty... - - const BOPTools_CommonBlockPool& aCBPool = aPaveFiller.CommonBlockPool(); - const BOPTools_ListOfCommonBlock& aLCB = aCBPool(aDS.RefEdge(i)); - BOPTools_ListIteratorOfListOfCommonBlock anItCB(aLCB); - Standard_Boolean bWireIsObject = (myS1.ShapeType() == TopAbs_WIRE); - Standard_Boolean bFillWithCommonPart = bWireIsObject ? (iRank == 1) : (iRank == 2); - - for (; bFillWithCommonPart && anItCB.More(); anItCB.Next()) { - const BOPTools_CommonBlock& aCB = anItCB.Value(); - const BOPTools_PaveBlock& aPB = aCB.PaveBlock1(); - Standard_Integer nSp = aPB.Edge(); - TopoDS_Shape aNewShape = aDS.Shape(nSp); - - Standard_Boolean found = Standard_True; - - if(!aResultMap.Contains(aNewShape)) { - nSp = aCB.PaveBlock2().Edge(); - found = Standard_False; - - if(nSp) { - aNewShape = aDS.Shape(nSp); - found = aResultMap.Contains(aNewShape); - } - } - - if(found) { - TopTools_DataMapOfShapeListOfShape& aHistoryMap = myModifMap; - - if(aHistoryMap.IsBound(anOldShape)) { - aHistoryMap.ChangeFind(anOldShape).Append(aNewShape); - } - else { - TopTools_ListOfShape aShapeList; - aShapeList.Append(aNewShape); - aHistoryMap.Bind(anOldShape, aShapeList); - } - } - } - } - // end for(i = startindex... - } -} - -// -------------------------------------------------------------------------------- -// static function: AddNewShape -// purpose: -// -------------------------------------------------------------------------------- -Standard_Boolean AddNewShape(const TopoDS_Shape& theKey, - const TopoDS_Shape& theItem, - TopTools_DataMapOfShapeListOfShape& theMap) { - - - if(!theMap.IsBound(theKey)) { - TopTools_ListOfShape aList; - aList.Append(theItem); - theMap.Bind(theKey, aList); - return Standard_True; - } - - Standard_Boolean found = Standard_False; - TopTools_ListOfShape& aList = theMap.ChangeFind(theKey); - TopTools_ListIteratorOfListOfShape aVIt(aList); - - for(; aVIt.More(); aVIt.Next()) { - if(theItem.IsSame(aVIt.Value())) { - found = Standard_True; - break; - } - } - - if(!found) { - aList.Append(theItem); - } - return !found; -} - -void GetAncestorFaces(const Standard_Integer theShapeIndex, - const BooleanOperations_ShapesDataStructure& theDS, - TopTools_IndexedMapOfShape& theFaces) -{ - // find ancestors for the edge - Standard_Integer nbeA = theDS.NumberOfAncestors(theShapeIndex); - if( nbeA == 0 ) return; - Standard_Integer ieA = 0; - for( ieA = 1; ieA <= nbeA; ieA++ ) { - Standard_Integer indxA = theDS.GetAncestor(theShapeIndex,ieA); - TopAbs_ShapeEnum aShapeType = theDS.GetShapeType(indxA); - if( aShapeType == TopAbs_FACE ) { - theFaces.Add(theDS.Shape(indxA)); - } - else if( aShapeType == TopAbs_WIRE ) { - GetAncestorFaces(indxA,theDS,theFaces); - } - else { - return; - } - } -} - -Standard_Integer GetShapeWire(const BooleanOperations_ShapesDataStructure& theDS, - const TopoDS_Shape& S1, - const TopoDS_Shape& S2, - TopoDS_Shape& WS) -{ - Standard_Integer wRank = 0; - if( S1.ShapeType() == TopAbs_WIRE ) { - if( S1.IsSame(theDS.Object()) ) - wRank = 1; - else - wRank = 2; - WS = S1; - } - else { - if( S2.IsSame(theDS.Object()) ) - wRank = 1; - else - wRank = 2; - WS = S2; - } - return wRank; -} diff --git a/src/BOP/BOP_WireSplitter.cdl b/src/BOP/BOP_WireSplitter.cdl deleted file mode 100755 index e6f8c978c2..0000000000 --- a/src/BOP/BOP_WireSplitter.cdl +++ /dev/null @@ -1,110 +0,0 @@ --- Created on: 2001-04-09 --- Created by: Peter KURNEV --- Copyright (c) 2001-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class WireSplitter from BOP - - ---Purpose: - --- the algorithm to split multiconnexed - --- wires on a face onto biconnexed ones - --- . -uses - Face from TopoDS, - Vertex from TopoDS, - Edge from TopoDS, - - SequenceOfPnt2d from TColgp, - SequenceOfShape from TopTools, - ListOfShape from TopTools, - - ListOfListOfShape from BOPTColStd, - - EdgeInfo from BOP, - IndexedDataMapOfVertexListEdgeInfo from BOP - ---raises - -is - Create - returns WireSplitter from BOP; - ---C++: inline - ---Purpose: - --- Empty constructor; - --- - SetFace (me:out; - aF: Face from TopoDS); - ---C++: inline - ---Purpose: - --- Modifier - --- - DoWithListOfEdges(me:out; - aLE:ListOfShape from TopTools); - ---Purpose: - --- Perform the algorithm using the list of shapes as data - --- - DoWithFace (me:out); - ---Purpose: - --- Perform the algorithm using the face as data - --- - Do (me:out) - is private; - ---Purpose: - --- Perform the algorithm - --- - IsNothingToDo (me) - returns Boolean from Standard; - ---C++: inline - ---Purpose: - --- Returns TRUE if the source wire is biconnexed and - --- there is nothing to correct - --- - IsDone (me) - returns Boolean from Standard; - ---C++: inline - ---Purpose: - --- Returns TRUE if the algorithm was performed - --- successfuly - --- - Face (me) - returns Face from TopoDS; - ---C++: return const & - ---C++: inline - ---Purpose: - --- Selector - --- - Shapes (me) - returns ListOfListOfShape from BOPTColStd; - ---C++: return const & - ---C++: inline - ---Purpose: - --- Selector - --- - - -fields - - myFace : Face from TopoDS; - myIsDone : Boolean from Standard; - myNothingToDo: Boolean from Standard; - myShapes : ListOfListOfShape from BOPTColStd; - mySmartMap : IndexedDataMapOfVertexListEdgeInfo from BOP; - myEdges : ListOfShape from TopTools; - -end WireSplitter; diff --git a/src/BOP/BOP_WireSplitter.cxx b/src/BOP/BOP_WireSplitter.cxx deleted file mode 100755 index 200dc3cf6e..0000000000 --- a/src/BOP/BOP_WireSplitter.cxx +++ /dev/null @@ -1,1031 +0,0 @@ -// Created on: 2001-04-09 -// Created by: Peter KURNEV -// Copyright (c) 2001-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#include - -#include -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include - -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include -#include -#include -#include - - -#include -#include -#include -#include -#include - -static - void Path (const GeomAdaptor_Surface& aGAS, - const TopoDS_Face& myFace, - const TopoDS_Vertex& aVa, - const TopoDS_Edge& aEOuta, - BOP_EdgeInfo& anEdgeInfo, - TopTools_SequenceOfShape& aLS, - TopTools_SequenceOfShape& aVertVa, - TColgp_SequenceOfPnt2d& aCoordVa, - BOPTColStd_ListOfListOfShape& myShapes, - BOP_IndexedDataMapOfVertexListEdgeInfo& mySmartMap); - - -static - Standard_Real Angle (const gp_Dir2d& aDir2D); - - -static - void GetNextVertex(const TopoDS_Vertex& aV, - const TopoDS_Edge& aE, - TopoDS_Vertex& aV1); -static - Standard_Real ClockWiseAngle(const Standard_Real aAngleIn, - const Standard_Real aAngleOut); - -static - Standard_Real AngleIn(const TopoDS_Edge& aEIn, - const BOP_ListOfEdgeInfo& aLEInfo); - -static - Standard_Real Angle2D (const TopoDS_Vertex& aV, - const TopoDS_Edge& anEdge, - const TopoDS_Face& myFace, - const GeomAdaptor_Surface& aGAS, - const Standard_Boolean aFlag); -static - gp_Pnt2d Coord2d (const TopoDS_Vertex& aV1, - const TopoDS_Edge& aE1, - const TopoDS_Face& aF); -static - gp_Pnt2d Coord2dVf (const TopoDS_Edge& aE, - const TopoDS_Face& aF); -static - Standard_Real Tolerance2D (const TopoDS_Vertex& aV, - const GeomAdaptor_Surface& aGAS); - -static -Standard_Real UTolerance2D (const TopoDS_Vertex& aV, - const GeomAdaptor_Surface& aGAS); -static -Standard_Real VTolerance2D (const TopoDS_Vertex& aV, - const GeomAdaptor_Surface& aGAS); - -static -Standard_Boolean RecomputeAngles(const BOP_ListOfEdgeInfo& aLEInfo, - const TopoDS_Face& theFace, - const gp_Pnt2d& thePb, - const TopoDS_Vertex& theVb, - const GeomAdaptor_Surface& theGAS, - const TopoDS_Edge& theEOuta, - const Standard_Boolean& bHasClosed, - const Standard_Real& theTol2D, - TColStd_SequenceOfReal& theRecomputedAngles); -// -static - Standard_Integer NbWaysOut(const BOP_ListOfEdgeInfo& ); -// - -//======================================================================= -// function: DoWithFace -// purpose: -//======================================================================= - void BOP_WireSplitter::DoWithFace() -{ - myEdges.Clear(); - - TopExp_Explorer anExpEdges (myFace, TopAbs_EDGE); - for (; anExpEdges.More(); anExpEdges.Next()) { - const TopoDS_Edge& anEdge = TopoDS::Edge(anExpEdges.Current()); - // - if (anEdge.Orientation()==TopAbs_INTERNAL){ - continue; - } - // - myEdges.Append(anEdge); - } - Do(); -} -//======================================================================= -// function: DoWithListOfEdges -// purpose: -//======================================================================= - void BOP_WireSplitter::DoWithListOfEdges(const TopTools_ListOfShape& aLE) -{ - myEdges.Clear(); - - TopTools_ListIteratorOfListOfShape anItList; - - anItList.Initialize(aLE); - for (; anItList.More(); anItList.Next()) { - const TopoDS_Edge& anEdge = TopoDS::Edge(anItList.Value()); - // - if (anEdge.Orientation()==TopAbs_INTERNAL){ - continue; - } - // - myEdges.Append(anEdge); - } - Do(); -} -//======================================================================= -// function: Do -// purpose: -//======================================================================= - void BOP_WireSplitter::Do() -{ - myIsDone=Standard_False; - myNothingToDo=Standard_True; - - Standard_Integer index, i, aNb, aCntIn, aCntOut; - Standard_Boolean anIsIn; - Standard_Real anAngle; - - BOP_ListOfEdgeInfo emptyInfo; - TopTools_ListIteratorOfListOfShape anItList; - // - // 1.Filling mySmartMap - mySmartMap.Clear(); - - anItList.Initialize(myEdges); - for (; anItList.More(); anItList.Next()) { - const TopoDS_Edge& anEdge = TopoDS::Edge(anItList.Value()); - // - if (!BOPTools_Tools2D::HasCurveOnSurface (anEdge, myFace)) { - continue; - } - // - TopExp_Explorer anExpVerts (anEdge, TopAbs_VERTEX); - for (; anExpVerts.More(); anExpVerts.Next()) { - const TopoDS_Shape& aVertex= anExpVerts.Current(); - - index = mySmartMap.FindIndex(aVertex); - if (!index) { - index=mySmartMap.Add(aVertex, emptyInfo); - } - - BOP_ListOfEdgeInfo& aListOfEInfo=mySmartMap(index); - - BOP_EdgeInfo aEInfo; - aEInfo.SetEdge(anEdge); - - TopAbs_Orientation anOr=aVertex.Orientation(); - - if (anOr==TopAbs_FORWARD) { - aEInfo.SetInFlag(Standard_False); - } - - else if (anOr==TopAbs_REVERSED) { - aEInfo.SetInFlag(Standard_True); - } - - aListOfEInfo.Append(aEInfo); - } - } - // - aNb=mySmartMap.Extent(); - // - // 2. myNothingToDo - myNothingToDo=Standard_True; - - for (i=1; i<=aNb; i++) { - aCntIn=0; - aCntOut=0; - const BOP_ListOfEdgeInfo& aLEInfo= mySmartMap(i); - BOP_ListIteratorOfListOfEdgeInfo anIt(aLEInfo); - for (; anIt.More(); anIt.Next()) { - const BOP_EdgeInfo& anEdgeInfo=anIt.Value(); - anIsIn=anEdgeInfo.IsIn(); - if (anIsIn) { - aCntIn++; - } - else { - aCntOut++; - } - } - if (aCntIn!=1 || aCntOut!=1) { - myNothingToDo=Standard_False; - break; - } - } - // - // Each vertex has one edge In and one - Out. Good. But it is not enought - // to consider that nothing to do with this. We must check edges on TShape - // coinsidence. If there are such edges there is something to do with. - // - if (myNothingToDo) { - Standard_Integer aNbE, aNbMapEE; - TopTools_IndexedDataMapOfShapeListOfShape aMapEE; - aNbE=myEdges.Extent(); - - anItList.Initialize(myEdges); - for (; anItList.More(); anItList.Next()) { - const TopoDS_Shape& aE = anItList.Value(); - - if (!aMapEE.Contains(aE)) { - TopTools_ListOfShape aLEx; - aLEx.Append(aE); - aMapEE.Add(aE, aLEx); - } - else { - TopTools_ListOfShape& aLEx=aMapEE.ChangeFromKey(aE); - aLEx.Append(aE); - } - } - - Standard_Boolean bFlag; - bFlag=Standard_True; - aNbMapEE=aMapEE.Extent(); - for (i=1; i<=aNbMapEE; i++) { - const TopTools_ListOfShape& aLEx=aMapEE(i); - aNbE=aLEx.Extent(); - if (aNbE==1) { - // usual case - continue; - } - else if (aNbE==2){ - const TopoDS_Shape& aE1=aLEx.First(); - const TopoDS_Shape& aE2=aLEx.Last(); - if (aE1.IsSame(aE2)) { - bFlag=Standard_False; - break; - } - } - else { - bFlag=Standard_False; - break; - } - } - myNothingToDo=myNothingToDo && bFlag; - } - // - // - if (myNothingToDo) { - myIsDone=Standard_True; - return; - } - // - // 3. Angles in mySmartMap - BRepAdaptor_Surface aBAS(myFace); - const GeomAdaptor_Surface& aGAS=aBAS.Surface(); - for (i=1; i<=aNb; i++) { - const TopoDS_Vertex& aV=TopoDS::Vertex (mySmartMap.FindKey(i)); - const BOP_ListOfEdgeInfo& aLEInfo= mySmartMap(i); - - BOP_ListIteratorOfListOfEdgeInfo anIt(aLEInfo); - for (; anIt.More(); anIt.Next()) { - BOP_EdgeInfo& anEdgeInfo=anIt.Value(); - const TopoDS_Edge& aE=anEdgeInfo.Edge(); - // - TopoDS_Vertex aVV=aV; - // - anIsIn=anEdgeInfo.IsIn(); - if (anIsIn) { - // - aVV.Orientation(TopAbs_REVERSED); - anAngle=Angle2D (aVV, aE, myFace, aGAS, Standard_True); - } - // - else { // OUT - // - aVV.Orientation(TopAbs_FORWARD); - anAngle=Angle2D (aVV, aE, myFace, aGAS, Standard_False); - } - anEdgeInfo.SetAngle(anAngle); - - } - } - // - // 4. Do - // - Standard_Boolean anIsOut, anIsNotPassed; - - TopTools_SequenceOfShape aLS, aVertVa; - TColgp_SequenceOfPnt2d aCoordVa; - - BOP_ListIteratorOfListOfEdgeInfo anIt; - - for (i=1; i<=aNb; i++) { - const TopoDS_Vertex aVa=TopoDS::Vertex (mySmartMap.FindKey(i)); - const BOP_ListOfEdgeInfo& aLEInfo=mySmartMap(i); - - anIt.Initialize(aLEInfo); - for (; anIt.More(); anIt.Next()) { - BOP_EdgeInfo& anEdgeInfo=anIt.Value(); - const TopoDS_Edge& aEOuta=anEdgeInfo.Edge(); - - anIsOut=!anEdgeInfo.IsIn(); - anIsNotPassed=!anEdgeInfo.Passed(); - - if (anIsOut && anIsNotPassed) { - // - aLS.Clear(); - aVertVa.Clear(); - aCoordVa.Clear(); - // - Path(aGAS, myFace, aVa, aEOuta, anEdgeInfo, aLS, - aVertVa, aCoordVa, myShapes, mySmartMap); - } - } - } - // - { - Standard_Integer aNbV, aNbE; - TopoDS_Vertex aV1, aV2; - BOPTColStd_ListOfListOfShape aShapes; - BOPTColStd_ListIteratorOfListOfListOfShape anItW(myShapes); - - for (; anItW.More(); anItW.Next()) { - TopTools_IndexedMapOfShape aMV, aME; - const TopTools_ListOfShape& aLE=anItW.Value(); - TopTools_ListIteratorOfListOfShape anItE(aLE); - for (; anItE.More(); anItE.Next()) { - const TopoDS_Edge& aE=TopoDS::Edge(anItE.Value()); - aME.Add(aE); - TopExp::Vertices(aE, aV1, aV2); - aMV.Add(aV1); - aMV.Add(aV2); - } - aNbV=aMV.Extent(); - aNbE=aME.Extent(); - if (aNbV<=aNbE) { - aShapes.Append(aLE); - } - } - // - myShapes.Clear(); - anItW.Initialize(aShapes); - for (; anItW.More(); anItW.Next()) { - const TopTools_ListOfShape& aLE=anItW.Value(); - myShapes.Append(aLE); - } - } - // - myIsDone=Standard_True; -} -//======================================================================= -// function: Path -// purpose: -//======================================================================= - void Path (const GeomAdaptor_Surface& aGAS, - const TopoDS_Face& myFace, - const TopoDS_Vertex& aVa, - const TopoDS_Edge& aEOuta, - BOP_EdgeInfo& anEdgeInfo, - TopTools_SequenceOfShape& aLS, - TopTools_SequenceOfShape& aVertVa, - TColgp_SequenceOfPnt2d& aCoordVa, - BOPTColStd_ListOfListOfShape& myShapes, - BOP_IndexedDataMapOfVertexListEdgeInfo& mySmartMap) - -{ - Standard_Integer i,j, aNb, aNbj; - Standard_Real aD, aTol=1.e-7, anAngleIn, anAngleOut, anAngle, aMinAngle; - Standard_Real aTol2D, aTolVb, aTolVPrev; - Standard_Boolean anIsSameV2d, anIsSameV, anIsFound, anIsOut, anIsNotPassed; - BOP_ListIteratorOfListOfEdgeInfo anIt; - - TopoDS_Vertex aVb; - TopoDS_Edge aEOutb; - // - // append block - // - // Do not escape through edge from which you enter - aNb=aLS.Length(); - if (aNb==1) { - const TopoDS_Shape& anEPrev=aLS(aNb); - - if (anEPrev.IsSame(aEOuta)) { - return; - } - } - // - // - anEdgeInfo.SetPassed(Standard_True); - aLS.Append(aEOuta); - aVertVa.Append(aVa); - - TopoDS_Vertex pVa=aVa; - pVa.Orientation(TopAbs_FORWARD); - gp_Pnt2d aPa=Coord2d(pVa, aEOuta, myFace); - aCoordVa.Append(aPa); - - GetNextVertex (pVa, aEOuta, aVb); - - gp_Pnt2d aPb=Coord2d(aVb, aEOuta, myFace); - - const BOP_ListOfEdgeInfo& aLEInfoVb=mySmartMap.FindFromKey(aVb); - - TopoDS_Vertex aV1, aV2; - TopExp::Vertices(aEOuta, aV1, aV2); - Standard_Boolean bHasClosedEdge = aV1.IsNull() || aV2.IsNull() || aV1.IsSame(aV2); - Standard_Boolean bHasDegenerated = BRep_Tool::Degenerated(aEOuta); - Standard_Boolean bHasSeam = BRep_Tool::IsClosed(aEOuta, myFace); - anIt.Initialize(aLEInfoVb); - - for (; anIt.More(); anIt.Next()) { - BOP_EdgeInfo& anEI=anIt.Value(); - const TopoDS_Edge& aE=anEI.Edge(); - bHasDegenerated = bHasDegenerated || BRep_Tool::Degenerated(aE); - bHasSeam = bHasSeam || BRep_Tool::IsClosed(aE, myFace); - aV1.Nullify(); - aV2.Nullify(); - TopExp::Vertices(aE, aV1, aV2); - bHasClosedEdge = bHasClosedEdge || aV1.IsNull() || aV2.IsNull() || aV1.IsSame(aV2); - } - - aNb=aLS.Length(); - if (aNb>0) { - // - TopTools_ListOfShape aBuf; - for (i=aNb; i>0; i--) { - const TopoDS_Shape& aVPrev=aVertVa(i); - const gp_Pnt2d& aPaPrev=aCoordVa(i); - const TopoDS_Shape& aEPrev=aLS(i); - - aBuf.Append(aEPrev); - - anIsSameV=aVPrev.IsSame(aVb); - anIsSameV2d = Standard_False; - - if (anIsSameV) { - anIsSameV2d = Standard_True; - - if(bHasDegenerated || bHasSeam || bHasClosedEdge) { - aTolVb =BRep_Tool::Tolerance(TopoDS::Vertex(aVb)); - aTolVPrev=BRep_Tool::Tolerance(TopoDS::Vertex(aVPrev)); - aTol=aTolVb+aTolVPrev; - // - aTol=2.*Tolerance2D(aVb, aGAS); - aD=aPaPrev.Distance(aPb); - anIsSameV2d = (aD < aTol); - - if(anIsSameV2d) { - Standard_Real udist = fabs(aPaPrev.X() - aPb.X()); - Standard_Real vdist = fabs(aPaPrev.Y() - aPb.Y()); - Standard_Real aTolU = 2. * UTolerance2D(aVb, aGAS); - Standard_Real aTolV = 2. * VTolerance2D(aVb, aGAS); - - if((udist > aTolU) || - (vdist > aTolV)) { - anIsSameV2d = Standard_False; - } - } - } - } - - // - if (anIsSameV && anIsSameV2d) { - myShapes.Append(aBuf); - // - TopTools_SequenceOfShape aLSt, aVertVat; - TColgp_SequenceOfPnt2d aCoordVat; - // - aNbj=i-1; - if (aNbj<1) { - // - aLS.Clear(); - aVertVa.Clear(); - aCoordVa.Clear(); - // - return; - } - - aVb=TopoDS::Vertex(aVertVa(i)); - - for (j=1; j<=aNbj; j++) { - aLSt.Append(aLS(j)); - aVertVat.Append(aVertVa(j)); - aCoordVat.Append(aCoordVa(j)); - } - // - aLS.Clear(); - aVertVa.Clear(); - aCoordVa.Clear(); - - aLS=aLSt; - aVertVa=aVertVat; - aCoordVa=aCoordVat; - // - break; - } - } - } - // - aTol2D=2.*Tolerance2D(aVb, aGAS); - // - // anAngleIn in Vb from edge aEOuta - const BOP_ListOfEdgeInfo& aLEInfo=mySmartMap.FindFromKey(aVb); - // - anAngleIn=AngleIn(aEOuta, aLEInfo); - // - // aEOutb - BOP_EdgeInfo *pEdgeInfo=NULL; - - aMinAngle=100.; - anIsFound=Standard_False; - - TColStd_SequenceOfReal aRecomputedAngles; - - Standard_Boolean bRecomputeAngle = - RecomputeAngles(aLEInfo, myFace, aPb, aVb, aGAS, aEOuta, - (bHasDegenerated || bHasSeam || bHasClosedEdge), - aTol2D, aRecomputedAngles); - - Standard_Integer aCurIndexE = 0; - - anIt.Initialize(aLEInfo); - for (; anIt.More(); anIt.Next()) { - BOP_EdgeInfo& anEI=anIt.Value(); - const TopoDS_Edge& aE=anEI.Edge(); - anIsOut=!anEI.IsIn(); - anIsNotPassed=!anEI.Passed(); - - if (anIsOut && anIsNotPassed) { - aCurIndexE++; - // - // Is there one way to go out of the vertex - // we have to use it only. - Standard_Integer iCnt; - iCnt=NbWaysOut (aLEInfo); - // - if (!iCnt) { - // no way to go . (Error) - return ; - } - // - if (iCnt==1) { - // the one and only way to go out . - pEdgeInfo=&anEI; - anIsFound=Standard_True; - break; - } - // - // Look for minimal angle and make the choice. - gp_Pnt2d aP2Dx; - // - aP2Dx=Coord2dVf(aE, myFace); - // - aD=aP2Dx.Distance(aPb); - if (aD > aTol2D){ - continue; - } - // - // - anAngleOut=anEI.Angle(); - // - if(bRecomputeAngle) { - if(aCurIndexE <= aRecomputedAngles.Length()) { - anAngleOut = aRecomputedAngles.Value(aCurIndexE); - } - } - // - anAngle=ClockWiseAngle(anAngleIn, anAngleOut); - if (anAngle < aMinAngle) { - aMinAngle=anAngle; - pEdgeInfo=&anEI; - anIsFound=Standard_True; - } - } - } // for (; anIt.More(); anIt.Next()) - // - if (!anIsFound) { - // no way to go . (Error) - return; - } - - aEOutb=pEdgeInfo->Edge(); - Path (aGAS, myFace, aVb, aEOutb, *pEdgeInfo, aLS, - aVertVa, aCoordVa, myShapes, mySmartMap); -} -//======================================================================= -// function: Coord2dVf -// purpose: -//======================================================================= - gp_Pnt2d Coord2dVf (const TopoDS_Edge& aE, - const TopoDS_Face& aF) -{ - TopExp_Explorer anExp(aE, TopAbs_VERTEX); - for (; anExp.More(); anExp.Next()) { - const TopoDS_Vertex& aVx=TopoDS::Vertex(anExp.Current()); - if (aVx.Orientation()==TopAbs_FORWARD) - return Coord2d(aVx, aE, aF); - } - const Standard_Real aCoord=99.; - const gp_Pnt2d aP2D1(aCoord, aCoord); - return aP2D1; -} -//======================================================================= -// function: Tolerance2D -// purpose: -//======================================================================= - Standard_Real Tolerance2D (const TopoDS_Vertex& aV, - const GeomAdaptor_Surface& aGAS) -{ - const GeomAbs_SurfaceType aType=aGAS.GetType(); - const Standard_Real aTolV3D=BRep_Tool::Tolerance(aV); - const Standard_Real aUr=aGAS.UResolution(aTolV3D); - const Standard_Real aVr=aGAS.VResolution(aTolV3D); - // - Standard_Real aTol2D=(aVr>aUr) ? aVr : aUr; - // - if (aType==GeomAbs_BSplineSurface || aType==GeomAbs_Sphere) { - if (aTol2D < aTolV3D) - aTol2D=aTolV3D; - } - //modified by NIZNHY-PKV Wed Jul 5 16:44:59 2006f - else if (aType==GeomAbs_BSplineSurface) { - aTol2D=1.1*aTol2D; - } - //modified by NIZNHY-PKV Wed Jul 5 16:45:02 2006t - // - return aTol2D; -} - -//======================================================================= -// function: Coord2d -// purpose: -//======================================================================= - gp_Pnt2d Coord2d (const TopoDS_Vertex& aV1, - const TopoDS_Edge& aE1, - const TopoDS_Face& aF) -{ - const Standard_Real t=BRep_Tool::Parameter (aV1, aE1, aF); - - Standard_Real aFirst, aLast, aToler; - Handle(Geom2d_Curve) aC2D; - BOPTools_Tools2D::CurveOnSurface - (aE1, aF, aC2D, aFirst, aLast, aToler, Standard_True); - - gp_Pnt2d aP2D1; - aC2D->D0 (t, aP2D1); - - return aP2D1; -} -//======================================================================= -// function: AngleIn -// purpose: -//======================================================================= -Standard_Real AngleIn(const TopoDS_Edge& aEIn, - const BOP_ListOfEdgeInfo& aLEInfo) -{ - BOP_ListIteratorOfListOfEdgeInfo anIt(aLEInfo); - for (; anIt.More(); anIt.Next()) { - const BOP_EdgeInfo& anEdgeInfo=anIt.Value(); - const TopoDS_Edge& aE=anEdgeInfo.Edge(); - const Standard_Boolean anIsIn=anEdgeInfo.IsIn(); - // - if (anIsIn && aE==aEIn) - return anEdgeInfo.Angle(); - } - return 0.; -} -//======================================================================= -// function: ClockWiseAngle -// purpose: -//======================================================================= -Standard_Real ClockWiseAngle(const Standard_Real aAngleIn, - const Standard_Real aAngleOut) -{ - const Standard_Real aTwoPi = M_PI + M_PI; - Standard_Real dA, A1, A2, AIn, AOut ; - - AIn=aAngleIn; - AOut=aAngleOut; - if (AIn >= aTwoPi) { - AIn=AIn-aTwoPi; - } - - if (AOut >= aTwoPi) { - AOut=AOut-aTwoPi; - } - - A1 = AIn + M_PI; - - if (A1 >= aTwoPi) { - A1=A1-aTwoPi; - } - - A2=AOut; - - dA=A1-A2; - if (dA <= 0.) { - dA=aTwoPi+dA; - } - //xx - //else if (dA <= 1.e-15) { - else if (dA <= 1.e-14) { - dA=aTwoPi; - } - return dA; -} -//======================================================================= -// function: GetNextVertex -// purpose: -//======================================================================= - void GetNextVertex(const TopoDS_Vertex& aV, - const TopoDS_Edge& aE, - TopoDS_Vertex& aV1) -{ - TopExp_Explorer anExp(aE, TopAbs_VERTEX); - for (; anExp.More(); anExp.Next()) { - const TopoDS_Vertex& aVx=TopoDS::Vertex(anExp.Current()); - if (!aVx.IsEqual(aV)) { - aV1=aVx; - return ; - } - } - aV1=aV; -} -//======================================================================= -// function: Angle2D -// purpose: -//======================================================================= -Standard_Real Angle2D (const TopoDS_Vertex& aV, - const TopoDS_Edge& anEdge, - const TopoDS_Face& myFace, - const GeomAdaptor_Surface& aGAS, - const Standard_Boolean aFlag) -{ - const Standard_Real aTV=BRep_Tool::Parameter (aV, anEdge, myFace); - if (Precision::IsInfinite(aTV)) - return 0.; - - Handle(Geom2d_Curve) aC2D; - Standard_Real aFirst, aLast, aToler; - BOPTools_Tools2D::CurveOnSurface (anEdge, myFace, aC2D, aFirst, aLast, aToler, Standard_True); - if (aC2D.IsNull()) - return 0.; - - //dt=1.e-7; - Standard_Real dt=Tolerance2D(aV, aGAS); - const Standard_Real dtmax=(aLast - aFirst) * 0.25; - if(dt > dtmax) { - // to save direction of the curve as much as it possible - // in the case of big tolerances - dt = dtmax; - } - const Standard_Real aTV1 = (fabs (aTV-aFirst) < fabs(aTV - aLast))? aTV + dt : aTV - dt; - // - gp_Pnt2d aPV, aPV1; - aC2D->D0 (aTV, aPV); - aC2D->D0 (aTV1, aPV1); - const gp_XY aV2D( aFlag? (aPV.XY()-aPV1.XY()) : (aPV1.XY()-aPV.XY()) ); - - //See http://www.opencascade.org/org/forum/thread_17712/ - if (aV2D.SquareModulus() <= gp::Resolution()*gp::Resolution()) - return 0.; - - const gp_Dir2d aDir2D(aV2D); - - return Angle(aDir2D); -} -//======================================================================= -// function: Angle -// purpose: -//======================================================================= -Standard_Real Angle (const gp_Dir2d& aDir2D) -{ - const Standard_Real anAngle = gp_Dir2d(1.,0.).Angle(aDir2D); - return ((anAngle < 0.)? anAngle + M_PI + M_PI : anAngle); -} - -//======================================================================= -// function: NbWaysOut -// purpose: -//======================================================================= -Standard_Integer NbWaysOut(const BOP_ListOfEdgeInfo& aLEInfo) -{ - Standard_Integer iCnt=0; - // - BOP_ListIteratorOfListOfEdgeInfo anIt(aLEInfo); - for (; anIt.More(); anIt.Next()) { - const BOP_EdgeInfo& anEI=anIt.Value(); - // - //const TopoDS_Edge& aE=anEI.Edge(); - const Standard_Boolean bIsOut=!anEI.IsIn(); - const Standard_Boolean bIsNotPassed=!anEI.Passed(); - if (bIsOut && bIsNotPassed) - iCnt++; - } - return iCnt; -} - -//======================================================================= -//function : UTolerance2D -//purpose : -//======================================================================= -Standard_Real UTolerance2D (const TopoDS_Vertex& aV, - const GeomAdaptor_Surface& aGAS) -{ - const Standard_Real aTolV3D = BRep_Tool::Tolerance(aV); - const Standard_Real anUr = aGAS.UResolution(aTolV3D); - // - return anUr; -} - -//======================================================================= -//function : VTolerance2D -//purpose : -//======================================================================= -Standard_Real VTolerance2D (const TopoDS_Vertex& aV, - const GeomAdaptor_Surface& aGAS) -{ - const Standard_Real aTolV3D = BRep_Tool::Tolerance(aV); - const Standard_Real anVr = aGAS.VResolution(aTolV3D); - // - return anVr; -} -//======================================================================= -// function: RecomputeAngles -// purpose: -//======================================================================= -Standard_Boolean RecomputeAngles(const BOP_ListOfEdgeInfo& aLEInfo, - const TopoDS_Face& theFace, - const gp_Pnt2d& thePb, - const TopoDS_Vertex& theVb, - const GeomAdaptor_Surface& theGAS, - const TopoDS_Edge& theEOuta, - const Standard_Boolean& bHasClosed, - const Standard_Real& theTol2D, - TColStd_SequenceOfReal& theRecomputedAngles) -{ - Standard_Boolean bRecomputeAngle = Standard_False; - BOP_ListIteratorOfListOfEdgeInfo anIt; - anIt.Initialize(aLEInfo); - - for (; anIt.More(); anIt.Next()) { - BOP_EdgeInfo& anEI=anIt.Value(); - const TopoDS_Edge& aE=anEI.Edge(); - Standard_Boolean anIsOut=!anEI.IsIn(); - Standard_Boolean anIsNotPassed=!anEI.Passed(); - - if (anIsOut && anIsNotPassed) { - theRecomputedAngles.Append(anEI.Angle()); - Standard_Integer acurindex = theRecomputedAngles.Length(); - - Standard_Boolean bRecomputeAngleLocal = Standard_False; - TopExp_Explorer anExp1(aE, TopAbs_VERTEX); - - for(; anExp1.More(); anExp1.Next()) { - TopExp_Explorer anExp2(theEOuta, TopAbs_VERTEX); - Standard_Boolean existsInEdge = Standard_False; - - for(; anExp2.More(); anExp2.Next()) { - if(anExp1.Current().IsSame(anExp2.Current())) { - existsInEdge = Standard_True; - break; - } - } - - if(!existsInEdge) { - bRecomputeAngleLocal = Standard_False; - break; - } - bRecomputeAngleLocal = Standard_True; - } - bRecomputeAngle = bRecomputeAngle || bRecomputeAngleLocal; - - if(!bRecomputeAngle) { - BOP_ListIteratorOfListOfEdgeInfo anIt2(aLEInfo); - - for(; anIt2.More(); anIt2.Next()) { - BOP_EdgeInfo& anEI2=anIt2.Value(); - const TopoDS_Edge& aE2=anEI2.Edge(); - - if(aE2.IsSame(aE)) - continue; - Standard_Boolean anIsOut2=!anEI2.IsIn(); - Standard_Boolean anIsNotPassed2=!anEI2.Passed(); - - if (anIsOut2 && anIsNotPassed2) { - anExp1.Init(aE, TopAbs_VERTEX); - - for(; anExp1.More(); anExp1.Next()) { - TopExp_Explorer anExp2(aE2, TopAbs_VERTEX); - Standard_Boolean existsInEdge = Standard_False; - - for(; anExp2.More(); anExp2.Next()) { - if(anExp1.Current().IsSame(anExp2.Current())) { - existsInEdge = Standard_True; - break; - } - } - - if(!existsInEdge) { - bRecomputeAngleLocal = Standard_False; - break; - } - bRecomputeAngleLocal = Standard_True; - } - bRecomputeAngle = bRecomputeAngle || bRecomputeAngleLocal; - } - } - } - - bRecomputeAngle = bRecomputeAngle || bRecomputeAngleLocal; - - if(bRecomputeAngle) { - gp_Pnt2d aP2Dx; - // - aP2Dx=Coord2dVf(aE, theFace); - Standard_Real aD = aP2Dx.Distance(thePb); - - TopoDS_Vertex aVf; - TopExp_Explorer anExp(aE, TopAbs_VERTEX); - - for (; anExp.More(); anExp.Next()) { - const TopoDS_Vertex& aVx=TopoDS::Vertex(anExp.Current()); - if (aVx.Orientation()==TopAbs_FORWARD) { - aVf = aVx; - } - } - Standard_Boolean bIgnore = Standard_False; - - if(bHasClosed || aVf.IsNull() || !aVf.IsSame(theVb)) { - bIgnore = (aD > theTol2D); - } - - if(!bIgnore && (theTol2D > M_PI)) { - Standard_Real udist = fabs(aP2Dx.X() - thePb.X()); - Standard_Real vdist = fabs(aP2Dx.Y() - thePb.Y()); - Standard_Real aTolU = 2. * UTolerance2D(theVb, theGAS); - Standard_Real aTolV = 2. * VTolerance2D(theVb, theGAS); - - if((udist > aTolU) || - (vdist > aTolV)) { - bIgnore = Standard_True; - } - } - - if((aD > Precision::Confusion()) && !bIgnore) { - Standard_Real f1, l1; - Handle(Geom2d_Curve) ac1 = BRep_Tool::CurveOnSurface(aE, theFace, f1, l1); - - Standard_Real aTV1 = BRep_Tool::Parameter (aVf, aE, theFace); - Standard_Real aTV12 = 0.; - Standard_Real dt1 = (l1 - f1) * 0.5; - - if (fabs (aTV1-f1) < fabs(aTV1 - l1)) { - aTV12 = aTV1 + dt1; - } - else { - aTV12 = aTV1 - dt1; - } - - gp_Pnt2d aPointNew = ac1->Value(aTV12); - gp_Vec2d aV2DOut(thePb, aPointNew); - - gp_Dir2d aDir2D(aV2DOut); - Standard_Real anAngleOut = Angle(aDir2D); - theRecomputedAngles.ChangeValue(acurindex) = anAngleOut; - } - } - } - } - return bRecomputeAngle; -} diff --git a/src/BOP/BOP_WireSplitter.lxx b/src/BOP/BOP_WireSplitter.lxx deleted file mode 100755 index 4cef69189d..0000000000 --- a/src/BOP/BOP_WireSplitter.lxx +++ /dev/null @@ -1,74 +0,0 @@ -// Created on: 2009-12-15 -// Created by: Sergey ZERCHANINOV -// Copyright (c) 2009-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -//======================================================================= -// function: BOP_WireSplitter::BOP_WireSplitter -// purpose: -//======================================================================= -inline BOP_WireSplitter::BOP_WireSplitter() -: myIsDone(Standard_False), - myNothingToDo(Standard_False) -{ -} - -//======================================================================= -// function: SetFace -// purpose: -//======================================================================= -inline void BOP_WireSplitter::SetFace(const TopoDS_Face& aFace) -{ - myFace=aFace; -} - -//======================================================================= -// function: Face -// purpose: -//======================================================================= -inline const TopoDS_Face& BOP_WireSplitter::Face() const -{ - return myFace; -} - -//======================================================================= -// function: IsNothingToDo -// purpose: -//======================================================================= -inline Standard_Boolean BOP_WireSplitter::IsNothingToDo() const -{ - return myNothingToDo; -} - -//======================================================================= -// function: IsDone -// purpose: -//======================================================================= -inline Standard_Boolean BOP_WireSplitter::IsDone() const -{ - return myIsDone; -} - -//======================================================================= -// function: Shapes -// purpose: -//======================================================================= -inline const BOPTColStd_ListOfListOfShape& BOP_WireSplitter::Shapes() const -{ - return myShapes; -} diff --git a/src/BOP/BOP_WireWire.cdl b/src/BOP/BOP_WireWire.cdl deleted file mode 100755 index 95dfc1215f..0000000000 --- a/src/BOP/BOP_WireWire.cdl +++ /dev/null @@ -1,67 +0,0 @@ --- Created on: 2002-02-01 --- Created by: Peter KURNEV --- Copyright (c) 2002-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class WireWire from BOP inherits WireShape from BOP - - ---Purpose: - --- - --- Performs Boolean Operations (BO) - --- Common,Cut,Fuse for wires as - --- arguments -uses - DSFiller from BOPTools, - PDSFiller from BOPTools, - ListOfShape from TopTools - ---raises - -is - Create - returns WireWire from BOP; - ---Purpose: - --- Empty constructor; - --- - Do (me:out) - is redefined; - ---Purpose: - --- (See base classes, please) - --- - DoWithFiller (me:out; - aDSF: DSFiller from BOPTools) - is redefined; - ---Purpose: - --- (See base classes, please) - --- - Destroy (me: in out) - is redefined; - ---C++: alias "Standard_EXPORT virtual ~BOP_WireWire(){Destroy();}" - ---Purpose: - --- Destructor - --- - BuildResult (me:out) - is redefined; - ---Purpose: - --- See base classes, please - --- - ---fields - -end WireWire; diff --git a/src/BOP/BOP_WireWire.cxx b/src/BOP/BOP_WireWire.cxx deleted file mode 100755 index b49c241229..0000000000 --- a/src/BOP/BOP_WireWire.cxx +++ /dev/null @@ -1,133 +0,0 @@ -// Created on: 2002-02-01 -// Created by: Peter KURNEV -// Copyright (c) 2002-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#include - -#include -#include - -#include - -#include - -#include -#include -#include - -#include - - -//======================================================================= -// function: BOP_WireWire::BOP_WireWire -// purpose: -//======================================================================= -BOP_WireWire::BOP_WireWire() -{ -} -//======================================================================= -// function: Destroy -// purpose: -//======================================================================= - void BOP_WireWire::Destroy() -{ -} -//======================================================================= -// function: Do -// purpose: -//======================================================================= - void BOP_WireWire::Do() -{ - myErrorStatus=0; - myIsDone=Standard_False; - // - // Filling the DS - BOPTools_DSFiller aDSFiller; - aDSFiller.SetShapes (myShape1, myShape2); - // - aDSFiller.Perform (); - // - DoWithFiller(aDSFiller); -} - -//======================================================================= -// function: DoWithFiller -// purpose: -//======================================================================= - void BOP_WireWire::DoWithFiller(const BOPTools_DSFiller& aDSFiller) -{ - myErrorStatus=0; - myIsDone=Standard_False; - // - myResultMap.Clear(); - myModifiedMap.Clear(); - // - myDSFiller=(BOPTools_DSFiller*) &aDSFiller; - // - try { - OCC_CATCH_SIGNALS - // modified by NIZHNY-MKK Fri Sep 3 15:14:17 2004.BEGIN - if(!myDSFiller->IsDone()) { - myErrorStatus = 1; - BOPTColStd_Dump::PrintMessage("DSFiller is invalid: Can not build result\n"); - return; - } - // modified by NIZHNY-MKK Fri Sep 3 15:14:20 2004.END - - Standard_Boolean bIsNewFiller; - bIsNewFiller=aDSFiller.IsNewFiller(); - - if (bIsNewFiller) { - // - // Preparing; - // 1 States - const BOPTools_PaveFiller& aPaveFiller=myDSFiller->PaveFiller(); - BOPTools_WireStateFiller aStateFiller(aPaveFiller); - aStateFiller.Do(); - - aDSFiller.SetNewFiller(!bIsNewFiller); - } - // - //DoNewFaces(); - // - BuildResult(); - // - BOP_CorrectTolerances::CorrectTolerances(myResult, 0.01); - // - FillModified(); - myIsDone=Standard_True; - } - catch ( Standard_Failure ) { - myErrorStatus = 1; - BOPTColStd_Dump::PrintMessage("Can not build result\n"); - } -} - -//======================================================================= -// function: BuildResult -// purpose: -//======================================================================= - void BOP_WireWire::BuildResult() -{ - AddSplitPartsINOUT(); - AddSplitPartsON(); - // - MakeResult(); -} - diff --git a/src/BOP/FILES b/src/BOP/FILES deleted file mode 100755 index 851b3237b9..0000000000 --- a/src/BOP/FILES +++ /dev/null @@ -1,4 +0,0 @@ -BOP_SolidSolid_1.cxx -BOP_ShellSolid_1.cxx -BOP_ShellSolid_2.cxx -BOP_ShellSolid_3.cxx diff --git a/src/BOPAlgo/BOPAlgo.cdl b/src/BOPAlgo/BOPAlgo.cdl new file mode 100644 index 0000000000..03664a2a66 --- /dev/null +++ b/src/BOPAlgo/BOPAlgo.cdl @@ -0,0 +1,90 @@ +-- Created by: Peter KURNEV +-- Copyright (c) 1999-2012 OPEN CASCADE SAS +-- +-- The content of this file is subject to the Open CASCADE Technology Public +-- License Version 6.5 (the "License"). You may not use the content of this file +-- except in compliance with the License. Please obtain a copy of the License +-- at http://www.opencascade.org and read it completely before using this file. +-- +-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +-- +-- The Original Code and all software distributed under the License is +-- distributed on an "AS IS" basis, without warranty of any kind, and the +-- Initial Developer hereby disclaims all such warranties, including without +-- limitation, any warranties of merchantability, fitness for a particular +-- purpose or non-infringement. Please see the License for the specific terms +-- and conditions governing the rights and limitations under the License. + + +package BOPAlgo +---Purpose: + +uses + gp, + TopAbs, + Geom, + GeomAPI, + BRepClass3d, + TopoDS, + TopTools, + IntTools, + IntSurf, + -- + BOPDS, + BOPInt, + BOPCol, + BOPTools +is + enumeration Operation is + COMMON, + FUSE, + CUT, + CUT21, + SECTION, + UNKNOWN + end Operation; + + enumeration CheckStatus is + CheckUnknown, + BadType, + SelfIntersect, + TooSmallEdge, + NonRecoverableFace, + IncompatibilityOfVertex, + IncompatibilityOfEdge, + IncompatibilityOfFace, + OperationAborted + end CheckStatus; + + -- + -- classes + -- + deferred class Algo; + deferred class BuilderShape; + class PaveFiller; + class Builder; + class BOP; + -- + deferred class BuilderArea; + class BuilderFace; + class WireEdgeSet; + class WireSplitter; + class BuilderSolid; + class Tools; + class SectionAttribute; + class CheckerSI; + class ArgumentAnalyzer; + class CheckResult; + -- + -- pointers + -- + pointer PPaveFiller to PaveFiller from BOPAlgo; + pointer PWireEdgeSet to WireEdgeSet from BOPAlgo; + pointer PBOP to BOP from BOPAlgo; + pointer PBuilder to Builder from BOPAlgo; + + -- + imported ListOfCheckResult; + +end BOPAlgo; diff --git a/src/BOPAlgo/BOPAlgo_Algo.cdl b/src/BOPAlgo/BOPAlgo_Algo.cdl new file mode 100644 index 0000000000..be4deb9a42 --- /dev/null +++ b/src/BOPAlgo/BOPAlgo_Algo.cdl @@ -0,0 +1,63 @@ +-- Created by: Peter KURNEV +-- Copyright (c) 2010-2012 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 +-- +-- The content of this file is subject to the Open CASCADE Technology Public +-- License Version 6.5 (the "License"). You may not use the content of this file +-- except in compliance with the License. Please obtain a copy of the License +-- at http://www.opencascade.org and read it completely before using this file. +-- +-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +-- +-- The Original Code and all software distributed under the License is +-- distributed on an "AS IS" basis, without warranty of any kind, and the +-- Initial Developer hereby disclaims all such warranties, including without +-- limitation, any warranties of merchantability, fitness for a particular +-- purpose or non-infringement. Please see the License for the specific terms +-- and conditions governing the rights and limitations under the License. + + +deferred class Algo from BOPAlgo + ---Purpose: provides the root interface for algorithms + +uses + BaseAllocator from BOPCol + +--raises + +is + Initialize + returns Algo from BOPAlgo; + ---C++: alias "Standard_EXPORT virtual ~BOPAlgo_Algo();" + + Initialize (theAllocator: BaseAllocator from BOPCol) + returns Algo from BOPAlgo; + + Perform(me:out) + is deferred; + + ErrorStatus (me) + returns Integer from Standard; + + WarningStatus (me) + returns Integer from Standard; + + CheckData(me:out) + is virtual protected; + + CheckResult(me:out) + is virtual protected; + + Allocator(me) + returns BaseAllocator from BOPCol; + ---C++: return const & + +fields + myAllocator : BaseAllocator from BOPCol is protected; + myErrorStatus : Integer from Standard is protected; + myWarningStatus : Integer from Standard is protected; + +end Algo; diff --git a/src/BOPAlgo/BOPAlgo_Algo.cxx b/src/BOPAlgo/BOPAlgo_Algo.cxx new file mode 100644 index 0000000000..6447eed954 --- /dev/null +++ b/src/BOPAlgo/BOPAlgo_Algo.cxx @@ -0,0 +1,97 @@ +// Created by: Peter KURNEV +// Copyright (c) 2010-2012 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 +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#include + +#include + +//======================================================================= +// function: +// purpose: +//======================================================================= + BOPAlgo_Algo::BOPAlgo_Algo() +: + myAllocator(NCollection_BaseAllocator::CommonBaseAllocator()), + myErrorStatus(1), + myWarningStatus(0) +{} +//======================================================================= +// function: +// purpose: +//======================================================================= + BOPAlgo_Algo::BOPAlgo_Algo(const Handle(NCollection_BaseAllocator)& theAllocator) +: + myAllocator(theAllocator), + myErrorStatus(1), + myWarningStatus(0) +{} + +//======================================================================= +// function: ~ +// purpose: +//======================================================================= + BOPAlgo_Algo::~BOPAlgo_Algo() +{ +} +//======================================================================= +//function : Allocator +//purpose : +//======================================================================= + const Handle(NCollection_BaseAllocator)& BOPAlgo_Algo::Allocator()const +{ + return myAllocator; +} +//======================================================================= +// function: CheckData +// purpose: +//======================================================================= + void BOPAlgo_Algo::CheckData() +{ + myErrorStatus=0; +} +//======================================================================= +// function: CheckResult +// purpose: +//======================================================================= + void BOPAlgo_Algo::CheckResult() +{ + myErrorStatus=0; +} +//======================================================================= +// function: ErrorStatus +// purpose: +//======================================================================= + Standard_Integer BOPAlgo_Algo::ErrorStatus()const +{ + return myErrorStatus; +} +//======================================================================= +// function: WarningStatus +// purpose: +//======================================================================= + Standard_Integer BOPAlgo_Algo::WarningStatus()const +{ + return myWarningStatus; +} +// myErrorStatus +// +// 1 - object is just initialized diff --git a/src/BOPAlgo/BOPAlgo_ArgumentAnalyzer.cdl b/src/BOPAlgo/BOPAlgo_ArgumentAnalyzer.cdl new file mode 100644 index 0000000000..f9d11dce40 --- /dev/null +++ b/src/BOPAlgo/BOPAlgo_ArgumentAnalyzer.cdl @@ -0,0 +1,185 @@ +-- Created on: 2004-09-03 +-- Created by: Oleg FEDYAEV +-- Copyright (c) 2004-2012 OPEN CASCADE SAS +-- +-- The content of this file is subject to the Open CASCADE Technology Public +-- License Version 6.5 (the "License"). You may not use the content of this file +-- except in compliance with the License. Please obtain a copy of the License +-- at http://www.opencascade.org and read it completely before using this file. +-- +-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +-- +-- The Original Code and all software distributed under the License is +-- distributed on an "AS IS" basis, without warranty of any kind, and the +-- Initial Developer hereby disclaims all such warranties, including without +-- limitation, any warranties of merchantability, fitness for a particular +-- purpose or non-infringement. Please see the License for the specific terms +-- and conditions governing the rights and limitations under the License. + + +class ArgumentAnalyzer from BOPAlgo + ---Purpose: check the validity of argument(s) for Boolean Operations + +uses + Shape from TopoDS, + Operation from BOPAlgo, + CheckStatus from BOPAlgo, + ShapeEnum from TopAbs, + ListOfCheckResult from BOPAlgo + +is + Create + returns ArgumentAnalyzer; + ---Purpose: empty constructor + + SetShape1(me: in out; TheShape: Shape from TopoDS); + ---Purpose: sets object shape + + SetShape2(me: in out; TheShape: Shape from TopoDS); + ---Purpose: sets tool shape + + GetShape1(me) + returns Shape from TopoDS; + ---C++: return const & + ---Purpose: returns object shape; + + GetShape2(me) + returns Shape from TopoDS; + ---C++: return const & + ---Purpose: returns tool shape + + --modified by NIZHNY-MKK Fri Sep 3 17:14:55 2004.BEGIN + ---options + OperationType(me: in out) + returns Operation from BOPAlgo; + ---C++: return & + ---Purpose: returns ref + + StopOnFirstFaulty(me: in out) + returns Boolean from Standard; + ---C++: return & + ---Purpose: returns ref + + ArgumentTypeMode(me: in out) + returns Boolean from Standard; + ---C++: return & + ---C++: inline + ---Purpose: Returns (modifiable) mode + -- that means checking types of shapes. + + Prepare(me: in out) + is protected; + ---Purpose: Prepares data; + + SelfInterMode(me: in out) + returns Boolean from Standard; + ---C++: return & + ---C++: inline + ---Purpose: Returns (modifiable) mode that means + -- checking of self-intersection of shapes. + + SmallEdgeMode(me: in out) + returns Boolean from Standard; + ---C++: return & + ---C++: inline + ---Purpose: Returns (modifiable) mode that means + -- checking of small edges. + + RebuildFaceMode(me: in out) + returns Boolean from Standard; + ---C++: return & + ---C++: inline + ---Purpose: Returns (modifiable) mode that means + -- checking of possibility to split or rebuild faces. + + TangentMode(me: in out) + returns Boolean from Standard; + ---C++: return & + ---C++: inline + ---Purpose: Returns (modifiable) mode that means + -- checking of tangency between subshapes. + + MergeVertexMode(me: in out) + returns Boolean from Standard; + ---C++: return & + ---C++: inline + ---Purpose: Returns (modifiable) mode that means + -- checking of problem of merging vertices. + + MergeEdgeMode(me: in out) + returns Boolean from Standard; + ---C++: return & + ---C++: inline + ---Purpose: Returns (modifiable) mode that means + -- checking of problem of merging edges. + +-- MergeFaceMode(me: in out) +-- returns Boolean from Standard; +-- ---C++: return & +-- ---C++: inline +-- ---Purpose: Returns (modifiable) mode that means +-- -- checking of problem of merging faces. + + --modified by NIZHNY-MKK Fri Sep 3 17:15:02 2004.END + + --- + Perform(me: out); + ---Purpose: performs analysis + + HasFaulty(me) + returns Boolean from Standard; + ---Purpose: result of test + + GetCheckResult(me) + returns ListOfCheckResult from BOPAlgo; + ---C++: return const & + ---Purpose: returns a result of test + + --- protected + TestTypes(me: out) + is protected; + + TestSelfInterferences(me: out) + is protected; + + TestSmallEdge(me: out) + is protected; + + TestRebuildFace(me: out) + is protected; + + TestTangent(me: out) + is protected; + + TestMergeSubShapes(me: out; theType: ShapeEnum from TopAbs) + is protected; + + TestMergeVertex(me: out) + is protected; + + TestMergeEdge(me: out) + is protected; + +-- TestMergeFace(me: out) +-- is protected; + + +fields + + myShape1 : Shape from TopoDS; + myShape2 : Shape from TopoDS; + myStopOnFirst : Boolean from Standard; + myOperation : Operation from BOPAlgo; + myArgumentTypeMode : Boolean from Standard; + mySelfInterMode : Boolean from Standard; + mySmallEdgeMode : Boolean from Standard; + myRebuildFaceMode : Boolean from Standard; + myTangentMode : Boolean from Standard; + myMergeVertexMode : Boolean from Standard; + myMergeEdgeMode : Boolean from Standard; + myEmpty1,myEmpty2 : Boolean from Standard; + myResult : ListOfCheckResult from BOPAlgo; + + +end ArgumentAnalyzer; diff --git a/src/BOPAlgo/BOPAlgo_ArgumentAnalyzer.cxx b/src/BOPAlgo/BOPAlgo_ArgumentAnalyzer.cxx new file mode 100644 index 0000000000..a9e98a7341 --- /dev/null +++ b/src/BOPAlgo/BOPAlgo_ArgumentAnalyzer.cxx @@ -0,0 +1,849 @@ +// Created on: 2004-09-02 +// Copyright (c) 2004-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +static Standard_Boolean CheckEdge(const TopoDS_Edge& theEdge); + +// ================================================================================ +// function: Constructor +// purpose: +// ================================================================================ +BOPAlgo_ArgumentAnalyzer::BOPAlgo_ArgumentAnalyzer() : +myStopOnFirst(Standard_False), +myOperation(BOPAlgo_UNKNOWN), +myArgumentTypeMode(Standard_False), +mySelfInterMode(Standard_False), +mySmallEdgeMode(Standard_False), +myRebuildFaceMode(Standard_False), +myTangentMode(Standard_False), +myMergeVertexMode(Standard_False), +myMergeEdgeMode(Standard_False), +myEmpty1(Standard_False), +myEmpty2(Standard_False) +// myMergeFaceMode(Standard_False) +{ +} + +// ================================================================================ +// function: SetShape1 +// purpose: +// ================================================================================ +void BOPAlgo_ArgumentAnalyzer::SetShape1(const TopoDS_Shape & TheShape) +{ + myShape1 = TheShape; +} + +// ================================================================================ +// function: SetShape2 +// purpose: +// ================================================================================ +void BOPAlgo_ArgumentAnalyzer::SetShape2(const TopoDS_Shape & TheShape) +{ + myShape2 = TheShape; +} + +// ================================================================================ +// function: GetShape1 +// purpose: +// ================================================================================ +const TopoDS_Shape & BOPAlgo_ArgumentAnalyzer::GetShape1() const +{ + return myShape1; +} + +// ================================================================================ +// function: GetShape2 +// purpose: +// ================================================================================ +const TopoDS_Shape & BOPAlgo_ArgumentAnalyzer::GetShape2() const +{ + return myShape2; +} + +// ================================================================================ +// function: OperationType +// purpose: +// ================================================================================ +BOPAlgo_Operation& BOPAlgo_ArgumentAnalyzer::OperationType() +{ + return myOperation; +} + +// ================================================================================ +// function: StopOnFirstFaulty +// purpose: +// ================================================================================ +Standard_Boolean & BOPAlgo_ArgumentAnalyzer::StopOnFirstFaulty() +{ + return myStopOnFirst; +} + +// ================================================================================ +// function: Prepare +// purpose: +// ================================================================================ +void BOPAlgo_ArgumentAnalyzer::Prepare() +{ + Standard_Boolean isS1 = myShape1.IsNull(), isS2 = myShape2.IsNull(); + if (!isS1 && !isS2) { + myEmpty1 = BOPTools_AlgoTools3D::IsEmptyShape(myShape1); + myEmpty2 = BOPTools_AlgoTools3D::IsEmptyShape(myShape2); + } +} +// ================================================================================ +// function: Perform +// purpose: +// ================================================================================ +void BOPAlgo_ArgumentAnalyzer::Perform() +{ + try { + OCC_CATCH_SIGNALS + myResult.Clear(); + + Prepare(); + + if(myArgumentTypeMode) { + TestTypes(); + } + + if(mySelfInterMode) { + TestSelfInterferences(); + } + + if(mySmallEdgeMode) { + if(!(!myResult.IsEmpty() && myStopOnFirst)) + TestSmallEdge(); + } + + if(myRebuildFaceMode) { + if(!(!myResult.IsEmpty() && myStopOnFirst)) + TestRebuildFace(); + } + + if(myTangentMode) { + if(!(!myResult.IsEmpty() && myStopOnFirst)) + TestTangent(); + } + + if(myMergeVertexMode) { + if(!(!myResult.IsEmpty() && myStopOnFirst)) + TestMergeVertex(); + } + + if(myMergeEdgeMode) { + if(!(!myResult.IsEmpty() && myStopOnFirst)) + TestMergeEdge(); + } + } + catch(Standard_Failure) { + BOPAlgo_CheckResult aResult; + aResult.SetCheckStatus(BOPAlgo_CheckUnknown); + myResult.Append(aResult); + } +} + +// ================================================================================ +// function: HasFaulty +// purpose: +// ================================================================================ +Standard_Boolean BOPAlgo_ArgumentAnalyzer::HasFaulty() const +{ + return ( !myResult.IsEmpty()); +} + +// ================================================================================ +// function: GetCheckResult +// purpose: +// ================================================================================ +const BOPAlgo_ListOfCheckResult& BOPAlgo_ArgumentAnalyzer::GetCheckResult() const +{ + return myResult; +} + +// ================================================================================ +// function: TestTypes +// purpose: +// ================================================================================ +void BOPAlgo_ArgumentAnalyzer::TestTypes() +{ + Standard_Boolean isS1 = myShape1.IsNull(), isS2 = myShape2.IsNull(); + + if(isS1 && isS2) { + BOPAlgo_CheckResult aResult; + aResult.SetCheckStatus(BOPAlgo_BadType); + myResult.Append(aResult); + return; + } + + //single shape check + if((isS1 && !isS2) || (!isS1 && isS2)) { + Standard_Boolean bIsEmpty = (isS1) ? myEmpty1 : myEmpty2; + + if(bIsEmpty) { + const TopoDS_Shape & aS = (isS1) ? myShape1 : myShape2; + BOPAlgo_CheckResult aResult; + aResult.SetShape1(aS); + aResult.SetCheckStatus(BOPAlgo_BadType); + myResult.Append(aResult); + return; + } + } + // two shapes check (begin) + else { + if(myEmpty1 || myEmpty2) { + BOPAlgo_CheckResult aResult; + if(myEmpty1 && myEmpty2) { + aResult.SetShape1(myShape1); + aResult.SetShape2(myShape2); + } + else { + const TopoDS_Shape & aS = myEmpty1 ? myShape1 : myShape2; + if(myEmpty1) + aResult.SetShape1(aS); + else + aResult.SetShape2(aS); + } + aResult.SetCheckStatus(BOPAlgo_BadType); + myResult.Append(aResult); + return; + } + // + Standard_Integer aDim1, aDim2; + Standard_Boolean bBadTypes = Standard_False; + // + aDim1 = BOPAlgo_BOP::Dimension(myShape1); + aDim2 = BOPAlgo_BOP::Dimension(myShape2); + if (aDim1 < aDim2) { + if (myOperation == BOPAlgo_FUSE || + myOperation == BOPAlgo_CUT21) { + bBadTypes = Standard_True; + } + } + else if (aDim1 > aDim2) { + if (myOperation == BOPAlgo_FUSE || + myOperation == BOPAlgo_CUT) { + bBadTypes = Standard_True; + } + } + if (bBadTypes) { + BOPAlgo_CheckResult aResult; + aResult.SetShape1(myShape1); + aResult.SetShape2(myShape2); + aResult.SetCheckStatus(BOPAlgo_BadType); + myResult.Append(aResult); + } + } +} + +// ================================================================================ +// function: TestSelfInterferences +// purpose: +// ================================================================================ +void BOPAlgo_ArgumentAnalyzer::TestSelfInterferences() +{ + Standard_Integer ii = 0, j; + Standard_Boolean bSelfInt; + + for(ii = 0; ii < 2; ii++) { + TopoDS_Shape aS = (ii == 0) ? myShape1 : myShape2; + + if(aS.IsNull()) + continue; + + Standard_Boolean bIsEmpty = (ii == 0) ? myEmpty1 : myEmpty2; + if (bIsEmpty) { + continue; + } + + BOPAlgo_CheckerSI aChecker; + BOPCol_ListOfShape anArgs; + anArgs.Append(aS); + anArgs.Append(aS); + aChecker.SetArguments(anArgs); + // + aChecker.Perform(); + Standard_Integer iErr = aChecker.ErrorStatus(); + // + const BOPDS_PDS& theDS = aChecker.PDS(); + BOPDS_VectorOfInterfVV& aVVs=theDS->InterfVV(); + BOPDS_VectorOfInterfVE& aVEs=theDS->InterfVE(); + BOPDS_VectorOfInterfEE& aEEs=theDS->InterfEE(); + BOPDS_VectorOfInterfVF& aVFs=theDS->InterfVF(); + BOPDS_VectorOfInterfEF& aEFs=theDS->InterfEF(); + BOPDS_VectorOfInterfFF& aFFs=theDS->InterfFF(); + // + Standard_Integer aNb[6] = {aVVs.Extent(), aVEs.Extent(), aEEs.Extent(), + aVFs.Extent(), aEFs.Extent(), aFFs.Extent()}; + // + Standard_Integer ind = 0; + for (Standard_Integer aTypeInt = 0; aTypeInt < 6; ++aTypeInt) { + for (Standard_Integer i = 0; i < aNb[aTypeInt]; ++i) { + BOPDS_Interf* aInt = (aTypeInt==0) ? (BOPDS_Interf*)(&aVVs(i)) : + ((aTypeInt==1) ? (BOPDS_Interf*)(&aVEs(i)) : + ((aTypeInt==2) ? (BOPDS_Interf*)(&aEEs(i)) : + ((aTypeInt==3) ? (BOPDS_Interf*)(&aVFs(i)) : + ((aTypeInt==4) ? (BOPDS_Interf*)(&aEFs(i)) : (BOPDS_Interf*)(&aFFs(i)))))); + // + Standard_Integer nI1 = aInt->Index1(); + Standard_Integer nI2 = aInt->Index2(); + if (nI1 == nI2) { + continue; + } + // + const TopoDS_Shape& aS1 = theDS->Shape(nI1); + const TopoDS_Shape& aS2 = theDS->Shape(nI2); + // + if (aTypeInt == 5) { + bSelfInt = Standard_False; + BOPDS_InterfFF& aFF = aFFs(i); + BOPDS_VectorOfPoint& aVP=aFF.ChangePoints(); + Standard_Integer aNbP=aVP.Extent(); + BOPDS_VectorOfCurve& aVC=aFF.ChangeCurves(); + Standard_Integer aNbC=aVC.Extent(); + if (!aNbP && !aNbC) { + continue; + } + for (j=0; j 1) { + BOPAlgo_CheckResult aResult; + + aResult.SetShape1(myShape1); + aResult.SetShape2(myShape2); + aResult.AddFaultyShape1(aS1); + TopTools_ListIteratorOfListOfShape anIt(aListOfS2); + + for(; anIt.More(); anIt.Next()) { + aResult.AddFaultyShape2(anIt.Value()); + } + + aResult.SetCheckStatus(aStatus); + myResult.Append(aResult); + + if(myStopOnFirst) { + return; + } + } + } + + for(i = 1; i <= aSeq2.Length(); i++) { + TopoDS_Shape aS2 = aSeq2.Value(i); + TopTools_ListOfShape aListOfS1; + Standard_Integer nbs = 0; + + for(j = 1; j <= aSeq1.Length(); j++) { + TopoDS_Shape aS1 = aSeq1.Value(j); + + if(anArrayOfFlag.Value(j, i)) { + aListOfS1.Append(aS1); + nbs++; + } + } + + if(nbs > 1) { + BOPAlgo_CheckResult aResult; + + aResult.SetShape1(myShape1); + aResult.SetShape2(myShape2); + TopTools_ListIteratorOfListOfShape anIt(aListOfS1); + + for(; anIt.More(); anIt.Next()) { + aResult.AddFaultyShape1(anIt.Value()); + } + aResult.AddFaultyShape2(aS2); + + aResult.SetCheckStatus(aStatus); + myResult.Append(aResult); + + if(myStopOnFirst) { + return; + } + } + } +} + +// ================================================================================ +// function: TestMergeVertex +// purpose: +// ================================================================================ +void BOPAlgo_ArgumentAnalyzer::TestMergeVertex() +{ + TestMergeSubShapes(TopAbs_VERTEX); +} + +// ================================================================================ +// function: TestMergeEdge +// purpose: +// ================================================================================ +void BOPAlgo_ArgumentAnalyzer::TestMergeEdge() +{ + TestMergeSubShapes(TopAbs_EDGE); +} + +// ================================================================================ +// function: TestMergeFace +// purpose: +// ================================================================================ +// void BOPAlgo_ArgumentAnalyzer::TestMergeFace() +// { + // not implemented +// } + +// ---------------------------------------------------------------------- +// static function: CheckEdge +// purpose: +// ---------------------------------------------------------------------- +Standard_Boolean CheckEdge(const TopoDS_Edge& theEdge) +{ + Handle(IntTools_Context) aContext; + TopoDS_Vertex aV1, aV2; + + aContext=new IntTools_Context; + TopExp::Vertices(theEdge, aV1, aV2); + + + if(aV1.IsNull() || aV2.IsNull() || BRep_Tool::Degenerated(theEdge)) + return Standard_True; + Standard_Real aFirst = 0., aLast = 0.; + BRep_Tool::Range(theEdge, aFirst, aLast); + IntTools_Range aRange(aFirst, aLast); + IntTools_ShrunkRange aSR(theEdge, aV1, aV2, aRange, aContext); + + if (!aSR.IsDone() || aSR.ErrorStatus() == 6) { + return Standard_False; + } + return Standard_True; +} diff --git a/src/BOPAlgo/BOPAlgo_ArgumentAnalyzer.lxx b/src/BOPAlgo/BOPAlgo_ArgumentAnalyzer.lxx new file mode 100644 index 0000000000..90d94444a3 --- /dev/null +++ b/src/BOPAlgo/BOPAlgo_ArgumentAnalyzer.lxx @@ -0,0 +1,62 @@ +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + +inline Standard_Boolean& BOPAlgo_ArgumentAnalyzer::ArgumentTypeMode() +{ + return myArgumentTypeMode; +} + + +inline Standard_Boolean& BOPAlgo_ArgumentAnalyzer::SelfInterMode() +{ + return mySelfInterMode; +} + + +inline Standard_Boolean& BOPAlgo_ArgumentAnalyzer::SmallEdgeMode() +{ + return mySmallEdgeMode; +} + + +inline Standard_Boolean& BOPAlgo_ArgumentAnalyzer::RebuildFaceMode() +{ + return myRebuildFaceMode; +} + + +inline Standard_Boolean& BOPAlgo_ArgumentAnalyzer::TangentMode() +{ + return myTangentMode; +} + + +inline Standard_Boolean& BOPAlgo_ArgumentAnalyzer::MergeVertexMode() +{ + return myMergeVertexMode; +} + + +inline Standard_Boolean& BOPAlgo_ArgumentAnalyzer::MergeEdgeMode() +{ + return myMergeEdgeMode; +} + +// inline Standard_Boolean& BOPAlgo_ArgumentAnalyzer::MergeFaceMode() +// { +// return myMergeFaceMode; +// } diff --git a/src/BOPAlgo/BOPAlgo_BOP.cdl b/src/BOPAlgo/BOPAlgo_BOP.cdl new file mode 100644 index 0000000000..0f7bbce43c --- /dev/null +++ b/src/BOPAlgo/BOPAlgo_BOP.cdl @@ -0,0 +1,128 @@ +-- Created by: Peter KURNEV +-- Copyright (c) 1999-2012 OPEN CASCADE SAS +-- +-- The content of this file is subject to the Open CASCADE Technology Public +-- License Version 6.5 (the "License"). You may not use the content of this file +-- except in compliance with the License. Please obtain a copy of the License +-- at http://www.opencascade.org and read it completely before using this file. +-- +-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +-- +-- The Original Code and all software distributed under the License is +-- distributed on an "AS IS" basis, without warranty of any kind, and the +-- Initial Developer hereby disclaims all such warranties, including without +-- limitation, any warranties of merchantability, fitness for a particular +-- purpose or non-infringement. Please see the License for the specific terms +-- and conditions governing the rights and limitations under the License. + +class BOP from BOPAlgo + inherits Builder from BOPAlgo +---Purpose: + +uses + Shape from TopoDS, + BaseAllocator from BOPCol, + ListOfShape from BOPCol, + MapOfShape from BOPCol, + --modified by NIZHNY-EMV Fri Sep 02 08:38:28 2011 + IndexedDataMapOfShapeListOfShape from BOPCol, + --modified by NIZHNY-EMV Fri Sep 02 08:38:30 2011 + Operation from BOPAlgo, + PaveFiller from BOPAlgo + +--raises + +is + Create + ---Purpose: Empty constructor + returns BOP from BOPAlgo; + ---C++: alias "Standard_EXPORT virtual ~BOPAlgo_BOP();" + + Create (theAllocator: BaseAllocator from BOPCol) + returns BOP from BOPAlgo; + + Clear(me:out) + is redefined; + ---Purpose: Clears internal fields and arguments + + AddArgument (me:out; + theShape: Shape from TopoDS) + ---Purpose: Adds Object argument of the operation + is redefined; + + AddTool (me:out; + theShape: Shape from TopoDS) + ---Purpose: Adds Tool argument of the operation + is virtual; + + Object(me) + returns Shape from TopoDS; + ---C++: return const & + + Tool(me) + returns Shape from TopoDS; + ---C++: return const & + + SetOperation(me:out; + theOperation: Operation from BOPAlgo); + + Operation(me) + returns Operation from BOPAlgo; + -- + -- protected methods + -- + CheckData(me:out) + is redefined protected; + + Prepare(me:out) + is redefined protected; + ---Purpose: Provides preparing actions + + PerformInternal(me:out; + thePF:PaveFiller from BOPAlgo) + is redefined protected; + ---Purpose: Performs calculations using prepared Filler + -- object theDSF + + BuildShape(me:out) + is protected; + + BuildRC(me:out) + is protected; + + BuildSolid(me:out) + is protected; + + BuildSection(me:out) + is protected; + + Dimension(myclass; + theS:Shape from TopoDS) + returns Integer from Standard; + --is protected; + + TreatCompound(myclass; + theS:Shape from TopoDS; + theLS:out ListOfShape from BOPCol) + is protected; + + --modified by NIZHNY-EMV Fri Sep 02 08:34:17 2011 + IsBoundSplits(me:out; + theS:Shape from TopoDS; + theMEF:out IndexedDataMapOfShapeListOfShape from BOPCol) + returns Boolean from Standard + is protected; + --modified by NIZHNY-EMV Fri Sep 02 08:34:19 2011 + +fields + myNbArgs : Integer from Standard is protected; + myOperation : Operation from BOPAlgo is protected; + myArgs : Shape from TopoDS[2] is protected; + myDims : Integer from Standard[2] is protected; + -- + myRC : Shape from TopoDS is protected; + myTools : ListOfShape from BOPCol is protected; + myMapTools : MapOfShape from BOPCol is protected; + +end BOP; diff --git a/src/BOPAlgo/BOPAlgo_BOP.cxx b/src/BOPAlgo/BOPAlgo_BOP.cxx new file mode 100644 index 0000000000..1ca5cef4c5 --- /dev/null +++ b/src/BOPAlgo/BOPAlgo_BOP.cxx @@ -0,0 +1,906 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#include + +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +//modified by NIZHNY-EMV Fri Sep 02 08:43:02 2011 +#include +//modified by NIZHNY-EMV Fri Sep 02 08:43:03 2011 + +static + TopAbs_ShapeEnum TypeToExplore(const Standard_Integer theDim); + +//======================================================================= +//function : +//purpose : +//======================================================================= + BOPAlgo_BOP::BOPAlgo_BOP() +: + BOPAlgo_Builder(), + myTools(myAllocator), + myMapTools(100, myAllocator) +{ + myNbArgs=2; + Clear(); +} +//======================================================================= +//function : +//purpose : +//======================================================================= + BOPAlgo_BOP::BOPAlgo_BOP(const Handle(NCollection_BaseAllocator)& theAllocator) +: + BOPAlgo_Builder(theAllocator), + myTools(myAllocator), + myMapTools(100, myAllocator) +{ + myNbArgs=2; + Clear(); +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= + BOPAlgo_BOP::~BOPAlgo_BOP() +{ +} +//======================================================================= +//function : Clear +//purpose : +//======================================================================= + void BOPAlgo_BOP::Clear() +{ + myOperation=BOPAlgo_UNKNOWN; + myTools.Clear(); + myMapTools.Clear(); + myDims[0]=-1; + myDims[1]=-1; + // + BOPAlgo_Builder::Clear(); +} +//======================================================================= +//function : AddArgument +//purpose : +//======================================================================= + void BOPAlgo_BOP::AddArgument(const TopoDS_Shape& theShape) +{ + if (myMapFence.Add(theShape)) { + myArguments.Append(theShape); + myArgs[0]=theShape; + } +} +//======================================================================= +//function : AddTool +//purpose : +//======================================================================= + void BOPAlgo_BOP::AddTool(const TopoDS_Shape& theShape) +{ + if (myMapTools.Add(theShape)) { + myTools.Append(theShape); + myArgs[1]=theShape; + // + if (myMapFence.Add(theShape)) { + myArguments.Append(theShape); + } + } +} +//======================================================================= +//function : Object +//purpose : +//======================================================================= + const TopoDS_Shape& BOPAlgo_BOP::Object()const +{ + return myArgs[0]; +} +//======================================================================= +//function : Tool +//purpose : +//======================================================================= + const TopoDS_Shape& BOPAlgo_BOP::Tool()const +{ + return myArgs[1]; +} +//======================================================================= +//function : SetOperation +//purpose : +//======================================================================= + void BOPAlgo_BOP::SetOperation(const BOPAlgo_Operation theOperation) +{ + myOperation=theOperation; +} +//======================================================================= +//function : Operation +//purpose : +//======================================================================= + BOPAlgo_Operation BOPAlgo_BOP::Operation()const +{ + return myOperation; +} +//======================================================================= +//function : CheckData +//purpose : +//======================================================================= + void BOPAlgo_BOP::CheckData() +{ + Standard_Integer i, aNb; + Standard_Boolean bFlag; + // + myErrorStatus=0; + // + aNb=myArguments.Extent(); + if (aNb!=myNbArgs) { + myErrorStatus=10; // invalid number of arguments + return; + } + // + BOPAlgo_Builder::CheckData(); + if (myErrorStatus) { + return; + } + // + //modified by NIZHNY-EMV Fri Feb 04 15:14:47 2011 + for (i=0; imyDims[1]) { + if (myOperation==BOPAlgo_FUSE || + myOperation==BOPAlgo_CUT) { + myErrorStatus=14; // non-licit oprtation for the arguments + return; + } + } +} +//======================================================================= +//function : Prepare +//purpose : +//======================================================================= + void BOPAlgo_BOP::Prepare() +{ + //modified by NIZHNY-EMV Fri Feb 04 14:46:24 2011 + Standard_Integer i; + BRep_Builder aBB; + // + BOPAlgo_Builder::Prepare(); + // + if(myWarningStatus == 2) { + switch(myOperation) { + case BOPAlgo_FUSE: + for ( i = 0; i < myNbArgs; i++ ) { + aBB.Add(myShape, myArgs[i]); + } + break; + case BOPAlgo_COMMON: + case BOPAlgo_SECTION: + break; + case BOPAlgo_CUT: + if(BOPTools_AlgoTools3D::IsEmptyShape(myArgs[0])) { + break; + } else { + aBB.Add(myShape, myArgs[0]); + } + break; + case BOPAlgo_CUT21: + if(BOPTools_AlgoTools3D::IsEmptyShape(myArgs[1])) { + break; + } else { + aBB.Add(myShape, myArgs[1]); + } + break; + default: + break; + } + } + //modified by NIZHNY-EMV Fri Feb 04 14:46:30 2011 +} +//======================================================================= +//function : PerformInternal +//purpose : +//======================================================================= + void BOPAlgo_BOP::PerformInternal(const BOPAlgo_PaveFiller& theFiller) +{ + myErrorStatus=0; + myWarningStatus=0; + // + myPaveFiller=(BOPAlgo_PaveFiller*)&theFiller; + myDS=myPaveFiller->PDS(); + myContext=myPaveFiller->Context(); + // + // 1. CheckData + CheckData(); + if (myErrorStatus && !myWarningStatus) { + return; + } + // + // 2. Prepare + Prepare(); + if (myErrorStatus) { + return; + } + //modified by NIZHNY-EMV Fri Feb 04 15:14:02 2011 + if(myWarningStatus == 2) { + return; + } + //modified by NIZHNY-EMV Fri Feb 04 15:14:11 2011 + // + // 3. Fill Images + // 3.1 Vertices + FillImagesVertices(); + if (myErrorStatus) { + return; + } + // + BuildResult(TopAbs_VERTEX); + if (myErrorStatus) { + return; + } + // 3.2 Edges + FillImagesEdges(); + if (myErrorStatus) { + return; + } + + BuildResult(TopAbs_EDGE); + if (myErrorStatus) { + return; + } + //-------------------------------- SECTION f + if (myOperation==BOPAlgo_SECTION) { + BuildSection(); + PrepareHistory(); + PostTreat(); + return; + } + //-------------------------------- SECTION t + // + // 3.3 Wires + FillImagesContainers(TopAbs_WIRE); + if (myErrorStatus) { + return; + } + + BuildResult(TopAbs_WIRE); + if (myErrorStatus) { + return; + } + + // 3.4 Faces + FillImagesFaces(); + if (myErrorStatus) { + return; + } + + BuildResult(TopAbs_FACE); + if (myErrorStatus) { + return; + } + // 3.5 Shells + + FillImagesContainers(TopAbs_SHELL); + if (myErrorStatus) { + return; + } + + BuildResult(TopAbs_SHELL); + if (myErrorStatus) { + return; + } + // 3.6 Solids + FillImagesSolids(); + if (myErrorStatus) { + return; + } + + BuildResult(TopAbs_SOLID); + if (myErrorStatus) { + return; + } + // 3.7 CompSolids + FillImagesContainers(TopAbs_COMPSOLID); + if (myErrorStatus) { + return; + } + + BuildResult(TopAbs_COMPSOLID); + if (myErrorStatus) { + return; + } + // 3.8 Compounds + //modified by NIZNHY-PKV Tue May 12 12:27:28 2009f + //FillImagesContainers(TopAbs_COMPOUND); + //modified by NIZNHY-PKV Tue May 12 12:27:30 2009t + FillImagesCompounds(); + if (myErrorStatus) { + return; + } + + BuildResult(TopAbs_COMPOUND); + if (myErrorStatus) { + return; + } + // + // 6.BuildShape; + BuildShape(); + // + // 4.History + PrepareHistory(); + + // + // 5 Post-treatment + PostTreat(); +} +//======================================================================= +//function : BuildShape +//purpose : +//======================================================================= + void BOPAlgo_BOP::BuildShape() +{ + Standard_Integer aDmin, aNbLCB; + TopAbs_ShapeEnum aT1, aT2, aTR; + TopoDS_Shape aR, aRC; + TopoDS_Iterator aIt; + BRep_Builder aBB; + BOPCol_ListOfShape aLCB; + BOPCol_ListIteratorOfListOfShape aItLCB; + // + myErrorStatus=0; + // + BuildRC(); + //myShape=myRC; + // + aDmin=myDims[1]; + if (myDims[0]aNb[1])? 1 : 0; + iY=(iX+1)%2; + } + else if (myOperation==BOPAlgo_CUT) { + iX=0; + iY=1; + } + else if (myOperation==BOPAlgo_CUT21) { + iX=1; + iY=0; + } + for (i=1; i<=aNb[iX]; ++i) { + const TopoDS_Shape& aSx=aMS[iX].FindKey(i); + bFlag=aMS[iY].Contains(aSx); + //modified by NIZHNY-EMV Mon Oct 10 15:39:27 2011 + if (aTmin == TopAbs_EDGE) { + const TopoDS_Edge& aE = (*(TopoDS_Edge*)(&aSx)); + if (BRep_Tool::Degenerated(aE)) { + TopExp_Explorer aExpE(aE, TopAbs_VERTEX); + TopoDS_Shape aSx1 = aExpE.Current(); + TopoDS_Shape aSIm; + if (myImages.IsBound(aSx1)) { + const BOPCol_ListOfShape& aLSIm=myImages.Find(aSx1); + aSIm=aLSIm.First(); + } else { + aSIm = aSx1; + } + bFlag=aMSV[iY].Contains(aSIm); + } + } + //modified by NIZHNY-EMV Mon Oct 10 15:39:30 2011 + // + if (myOperation!=BOPAlgo_COMMON) { + bFlag=!bFlag; + } + // + if (bFlag) { + aBB.Add(aC, aSx); + } + } + // + myRC=aC; +} +// +//======================================================================= +//function : Dimension +//purpose : +//======================================================================= + Standard_Integer BOPAlgo_BOP::Dimension(const TopoDS_Shape& theS) +{ + Standard_Integer i, iRet, iRx0, iRx; + TopAbs_ShapeEnum aTS; + BOPCol_ListOfShape aLS; + BOPCol_ListIteratorOfListOfShape aIt; + // + aTS=theS.ShapeType(); + if (aTS!=TopAbs_COMPOUND) { + switch (aTS) { + case TopAbs_EDGE: + case TopAbs_WIRE: + iRet=1; + break; + case TopAbs_FACE: + case TopAbs_SHELL: + iRet=2; + break; + case TopAbs_SOLID: + case TopAbs_COMPSOLID: + iRet=3; + break; + default: + iRet=0; + } + return iRet; + } + // + iRet=-1; + TreatCompound(theS, aLS); + //modified by NIZHNY-EMV Fri Feb 04 11:51:48 2011 + if(aLS.IsEmpty()) { + iRet = -2; //empty compound + return iRet; + } + //modified by NIZHNY-EMV Fri Feb 04 11:51:50 2011 + aIt.Initialize(aLS); + for (i=0; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aSx=aIt.Value(); + iRx=Dimension(aSx); + if (!i) { + iRx0=iRx; + i=1; + continue; + } + if (iRx!=iRx0) { + return iRet;// -1 + } + } + return iRx; +} +//======================================================================= +//function : TreatCompound +//purpose : +//======================================================================= + void BOPAlgo_BOP::TreatCompound(const TopoDS_Shape& theC1, + BOPCol_ListOfShape& theLSX) +{ + Standard_Integer aNbC1; + TopAbs_ShapeEnum aType; + BOPCol_ListOfShape aLC, aLC1; + BOPCol_ListIteratorOfListOfShape aIt, aIt1; + TopoDS_Iterator aItC; + // + aLC.Append (theC1); + while(1) { + aLC1.Clear(); + aIt.Initialize(aLC); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aC=aIt.Value(); //C is compound + // + aItC.Initialize(aC); + for (; aItC.More(); aItC.Next()) { + const TopoDS_Shape& aS=aItC.Value(); + aType=aS.ShapeType(); + if (aType==TopAbs_COMPOUND) { + aLC1.Append(aS); + } + else { + theLSX.Append(aS); + } + } + } + // + aNbC1=aLC1.Extent(); + if (!aNbC1) { + break; + } + // + aLC.Clear(); + aIt.Initialize(aLC1); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aSC=aIt.Value(); + aLC.Append(aSC); + } + }// while(1) +} +//======================================================================= +//function : TypeToExplore +//purpose : +//======================================================================= +TopAbs_ShapeEnum TypeToExplore(const Standard_Integer theDim) +{ + TopAbs_ShapeEnum aRet; + // + switch(theDim) { + case 0: + aRet=TopAbs_VERTEX; + break; + case 1: + aRet=TopAbs_EDGE; + break; + case 2: + aRet=TopAbs_FACE; + break; + case 3: + aRet=TopAbs_SOLID; + break; + default: + aRet=TopAbs_SHAPE; + break; + } + return aRet; +} +//======================================================================= +//function : BuildSolid +//purpose : +//======================================================================= + void BOPAlgo_BOP::BuildSolid() +{ + Standard_Integer i, aNbF, aNbSx, iX, iErr; + TopAbs_Orientation aOr, aOr1; + TopoDS_Iterator aIt; + TopoDS_Shape aRC; + BRep_Builder aBB; + TopExp_Explorer aExp; + BOPCol_IndexedMapOfShape aMFI; + BOPCol_IndexedDataMapOfShapeListOfShape aMFS, aMEF; + BOPCol_ListIteratorOfListOfShape aItLS; + BOPCol_ListOfShape aSFS; + BOPAlgo_BuilderSolid aSB; + // + myErrorStatus=0; + // + aIt.Initialize(myRC); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aSx=aIt.Value(); + aExp.Init(aSx, TopAbs_FACE); + for (; aExp.More(); aExp.Next()) { + const TopoDS_Shape& aFx=aExp.Current(); + // + aOr=aFx.Orientation(); + if (aOr==TopAbs_INTERNAL) { + aMFI.Add(aFx); + continue; + } + // + if (!aMFS.Contains(aFx)) { + BOPCol_ListOfShape aLSx; + // + aLSx.Append(aSx); + aMFS.Add(aFx, aLSx); + } + else { + iX=aMFS.FindIndex(aFx); + const TopoDS_Shape& aFx1=aMFS.FindKey(iX); + aOr1=aFx1.Orientation(); + if (aOr1!=aOr) { + BOPCol_ListOfShape& aLSx=aMFS.ChangeFromKey(aFx); + aLSx.Append(aSx); + aMFS.Add(aFx, aLSx); + } + } + } + } + // + //modified by NIZHNY-EMV Fri Sep 02 08:03:11 2011 + BOPCol_ListOfShape aLF, aLFx; //faces that will be added in the end; + //modified by NIZHNY-EMV Fri Sep 02 08:03:13 2011 + // SFS + aNbF=aMFS.Extent(); + for (i=1; i<=aNbF; ++i) { + const TopoDS_Shape& aFx=aMFS.FindKey(i); + const BOPCol_ListOfShape& aLSx=aMFS(i); + aNbSx=aLSx.Extent(); + if (aNbSx==1) { + //modified by NIZHNY-EMV Fri Sep 02 08:02:11 2011 + BOPTools::MapShapesAndAncestors(aFx, TopAbs_EDGE, TopAbs_FACE, aMEF); + if (IsBoundSplits(aFx, aMEF)){ + aLFx.Append(aFx); + continue; + } + aLF.Append(aFx); + //modified by NIZHNY-EMV Fri Sep 02 08:04:49 2011 + } + } + + //modified by NIZHNY-EMV Fri Sep 02 08:04:57 2011 + aItLS.Initialize(aLF); + for(; aItLS.More(); aItLS.Next()) { + const TopoDS_Shape& aFx=aItLS.Value(); + aSFS.Append(aFx); + } + // add faces from aLFx to aSFS; + aItLS.Initialize(aLFx); + for (; aItLS.More(); aItLS.Next()) { + const TopoDS_Shape& aFx=aItLS.Value(); + aSFS.Append(aFx); + } + //modified by NIZHNY-EMV Fri Sep 02 08:04:58 2011 + // + aNbF=aMFI.Extent(); + for (i=1; i<=aNbF; ++i) { + TopoDS_Shape aFx; + // + //modified by NIZHNY-EMV Fri Sep 23 08:52:31 2011 + aFx=aMFI.FindKey(i); + //modified by NIZHNY-EMV Fri Sep 23 08:52:33 2011 + aFx.Orientation(TopAbs_FORWARD); + aSFS.Append(aFx); + aFx.Orientation(TopAbs_REVERSED); + aSFS.Append(aFx); + } + // + // BuilderSolid + BOPTools_AlgoTools::MakeContainer(TopAbs_COMPOUND, aRC); + // + aSB.SetContext(myContext); + aSB.SetShapes(aSFS); + aSB.Perform(); + iErr=aSB.ErrorStatus(); + if (iErr) { + myErrorStatus=30; // SolidBuilder failed + return; + } + // + const BOPCol_ListOfShape& aLSR=aSB.Areas(); + // + aItLS.Initialize(aLSR); + for (; aItLS.More(); aItLS.Next()) { + const TopoDS_Shape& aSR=aItLS.Value(); + aBB.Add(aRC, aSR); + } + myShape=aRC; +} + +//modified by NIZHNY-EMV Fri Sep 02 08:21:45 2011 +//======================================================================= +//function : IsBoundImages +//purpose : +//======================================================================= + Standard_Boolean BOPAlgo_BOP::IsBoundSplits(const TopoDS_Shape& aS, + BOPCol_IndexedDataMapOfShapeListOfShape& aMEF) +{ + Standard_Boolean bRet = Standard_False; + if (mySplits.IsBound(aS) || myOrigins.IsBound(aS)) { + return !bRet; + } + + BOPCol_ListIteratorOfListOfShape aIt; + Standard_Integer aNbLS; + TopAbs_Orientation anOr; + // + //check face aF may be connected to face from mySplits + TopExp_Explorer aExp(aS, TopAbs_EDGE); + for (; aExp.More(); aExp.Next()) { + const TopoDS_Edge& aE = (*(TopoDS_Edge*)(&aExp.Current())); + // + anOr = aE.Orientation(); + if (anOr==TopAbs_INTERNAL) { + continue; + } + // + if (BRep_Tool::Degenerated(aE)) { + continue; + } + // + const BOPCol_ListOfShape& aLS=aMEF.FindFromKey(aE); + aNbLS = aLS.Extent(); + if (!aNbLS) { + continue; + } + // + aIt.Initialize(aLS); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aSx = aIt.Value(); + if (mySplits.IsBound(aSx) || myOrigins.IsBound(aS)) { + return !bRet; + } + } + } + + return bRet; +} +//modified by NIZHNY-EMV Fri Sep 02 08:21:47 2011 diff --git a/src/BOPAlgo/BOPAlgo_BOP_1.cxx b/src/BOPAlgo/BOPAlgo_BOP_1.cxx new file mode 100644 index 0000000000..6c202ec6e7 --- /dev/null +++ b/src/BOPAlgo/BOPAlgo_BOP_1.cxx @@ -0,0 +1,111 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include + + +//======================================================================= +//function : BuildSection +//purpose : +//======================================================================= + void BOPAlgo_BOP::BuildSection() +{ + + Standard_Integer i, aNb, nE; + TopoDS_Shape aRC; + BRep_Builder aBB; + BOPCol_MapOfShape aME; + BOPDS_ListIteratorOfListOfPaveBlock aItLPB; + BOPDS_MapIteratorOfMapOfPaveBlock aItMPB; + // + myErrorStatus=0; + // + BOPTools_AlgoTools::MakeContainer(TopAbs_COMPOUND, aRC); + //1. Common Blocks + const BOPDS_VectorOfListOfPaveBlock& aPBP=myDS->PaveBlocksPool(); + aNb=aPBP.Extent(); + for (i=0; iIsCommonBlock()) { + const Handle(BOPDS_CommonBlock)& aCB=aPB->CommonBlock(); + const Handle(BOPDS_PaveBlock)& aPB1=aCB->PaveBlock1(); + nE=aPB1->Edge(); + const TopoDS_Shape& aE=myDS->Shape(nE); + if (aME.Add(aE)) { + aBB.Add(aRC, aE); + } + } + } + } + //2. Section Edges + const BOPDS_VectorOfFaceInfo& aFIP=myDS->FaceInfoPool(); + aNb=aFIP.Extent(); + for (i=0; iEdge(); + const TopoDS_Shape& aE=myDS->Shape(nE); + if (aME.Add(aE)) { + aBB.Add(aRC, aE); + } + } + } + //3. Shared Edges + BOPCol_IndexedMapOfShape aMEO, aMET; + BOPCol_MapIteratorOfMapOfShape aItME; + // + BOPTools::MapShapes(myArgs[0], TopAbs_EDGE, aMEO); + BOPTools::MapShapes(myArgs[1], TopAbs_EDGE, aMET); + // + aItME.Initialize(aMEO); + for (; aItME.More(); aItME.Next()) { + const TopoDS_Shape& aE = aItME.Value(); + if (aMET.Contains(aE)) { + if (aME.Add(aE)) { + aBB.Add(aRC, aE); + } + } + } + + myShape=aRC; +} diff --git a/src/BOPAlgo/BOPAlgo_Builder.cdl b/src/BOPAlgo/BOPAlgo_Builder.cdl new file mode 100644 index 0000000000..aa070e47b4 --- /dev/null +++ b/src/BOPAlgo/BOPAlgo_Builder.cdl @@ -0,0 +1,242 @@ +-- Created by: Peter KURNEV +-- Copyright (c) 2010-2012 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 +-- +-- The content of this file is subject to the Open CASCADE Technology Public +-- License Version 6.5 (the "License"). You may not use the content of this file +-- except in compliance with the License. Please obtain a copy of the License +-- at http://www.opencascade.org and read it completely before using this file. +-- +-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +-- +-- The Original Code and all software distributed under the License is +-- distributed on an "AS IS" basis, without warranty of any kind, and the +-- Initial Developer hereby disclaims all such warranties, including without +-- limitation, any warranties of merchantability, fitness for a particular +-- purpose or non-infringement. Please see the License for the specific terms +-- and conditions governing the rights and limitations under the License. + +class Builder from BOPAlgo + inherits BuilderShape from BOPAlgo + +---Purpose: + +uses + ShapeEnum from TopAbs, + Shape from TopoDS, + ListOfShape from TopTools, + -- + BaseAllocator from BOPCol, + ListOfInteger from BOPCol, + ListOfShape from BOPCol, + MapOfShape from BOPCol, + DataMapOfShapeShape from BOPCol, + DataMapOfShapeListOfShape from BOPCol, + Context from BOPInt, + PDS from BOPDS, + PaveFiller from BOPAlgo, + PPaveFiller from BOPAlgo + + +--raises + +is + + Create + returns Builder from BOPAlgo; + ---C++: alias "Standard_EXPORT virtual ~BOPAlgo_Builder();" + + Create (theAllocator: BaseAllocator from BOPCol) + returns Builder from BOPAlgo; + + Clear(me:out) + is virtual; + + PPaveFiller(me:out) + returns PPaveFiller from BOPAlgo; + + PDS(me:out) + returns PDS from BOPDS; + + AddArgument (me:out; + theShape: Shape from TopoDS) + is virtual; + + Arguments(me) + returns ListOfShape from BOPCol; + ---C++: return const & + + + Perform(me:out) + is redefined; + + PerformWithFiller(me:out; + theFiller: PaveFiller from BOPAlgo) + is virtual; + + -- + -- History support + -- + PrepareHistory (me:out) + ---Purpose: Prepare information for history support + is redefined protected; + + Generated (me:out; + theS : Shape from TopoDS) + ---Purpose: Returns the list of shapes generated from the + -- shape theS. + returns ListOfShape from TopTools + is redefined; + ---C++: return const & + + Modified (me:out; + theS : Shape from TopoDS) + ---Purpose: Returns the list of shapes modified from the shape + -- theS. + returns ListOfShape from TopTools + is redefined; + ---C++: return const & + + IsDeleted (me:out; + theS : Shape from TopoDS) + ---Purpose: Returns true if the shape theS has been deleted. + returns Boolean from Standard + is redefined; + + -- + -- Debug + -- + Images(me) + returns DataMapOfShapeListOfShape from BOPCol; + ---C++: return const & + + + -- + -- protected methods + -- + PerformInternal(me:out; + thePF: PaveFiller from BOPAlgo) + is virtual protected; + + CheckData(me:out) + is redefined protected; + + Prepare(me:out) + is virtual protected; + + FillImagesVertices(me:out) + is protected; + + FillImagesEdges(me:out) + is protected; + + + BuildResult(me:out; + theType: ShapeEnum from TopAbs) + is virtual protected; + + IsInterferred(me; + theS:Shape from TopoDS) + returns Boolean from Standard; + + FillImagesContainers(me:out; + theType:ShapeEnum from TopAbs) + is protected; + + FillImagesCompounds(me:out) + is protected; + + FillImagesContainer(me:out; + theS:Shape from TopoDS; + theType:ShapeEnum from TopAbs) + is protected; + + FillImagesCompound(me:out; + theS:Shape from TopoDS; + theMF:out MapOfShape from BOPCol) + is protected; + + FillImagesFaces (me:out) + is protected; + + BuildSplitFaces (me:out) + is virtual protected; + + FillSameDomainFaces (me:out) + is protected; + + --modified by NIZNHY-PKV Thu Jul 08 07:19:22 2010f + FillImagesFaces1 (me:out) + is protected; + --modified by NIZNHY-PKV Thu Jul 08 07:19:28 2010t + + FillInternalVertices(me:out; + theLF:out ListOfShape from BOPCol; + theLIV:out ListOfInteger from BOPCol) + is protected; + -- + -- solids + -- + FillImagesSolids(me:out) + is protected; + + BuildDraftSolid(me:out; + theSolid:Shape from TopoDS; + theDraftSolid:out Shape from TopoDS; + theLIF:out ListOfShape from BOPCol) + is protected; + + FillIn3DParts(me:out; + theInParts:out DataMapOfShapeListOfShape from BOPCol; + theDraftSolids:out DataMapOfShapeShape from BOPCol; + theAllocator:BaseAllocator from BOPCol) + is virtual protected; + + BuildSplitSolids(me:out; + theInParts:out DataMapOfShapeListOfShape from BOPCol; + theDraftSolids:out DataMapOfShapeShape from BOPCol; + theAllocator:BaseAllocator from BOPCol) + is protected; + + FillInternalShapes(me:out) + is protected; + -- + -- misc + -- + PostTreat (me:out) + is virtual protected; + + Origins(me) + returns DataMapOfShapeShape from BOPCol; + ---C++: return const & + ---Purpose: Returns myOrigins. + + ShapesSD(me) + returns DataMapOfShapeShape from BOPCol; + ---C++: return const & + ---Purpose: Returns myShapesSD. + + Splits (me) + returns DataMapOfShapeListOfShape from BOPCol; + ---C++: return const & + ---Purpose: Returns mySplits. + +fields + myArguments : ListOfShape from BOPCol is protected; + myMapFence : MapOfShape from BOPCol is protected; + myPaveFiller : PPaveFiller from BOPAlgo is protected; + myDS : PDS from BOPDS is protected; + myContext : Context from BOPInt is protected; + myEntryPoint : Integer from Standard is protected; + -- + myImages : DataMapOfShapeListOfShape from BOPCol is protected; + myShapesSD : DataMapOfShapeShape from BOPCol is protected; + -- + mySplits : DataMapOfShapeListOfShape from BOPCol is protected; + myOrigins : DataMapOfShapeShape from BOPCol is protected; + +end Builder; + diff --git a/src/BOPAlgo/BOPAlgo_Builder.cxx b/src/BOPAlgo/BOPAlgo_Builder.cxx new file mode 100644 index 0000000000..a6c9350616 --- /dev/null +++ b/src/BOPAlgo/BOPAlgo_Builder.cxx @@ -0,0 +1,381 @@ +// Created by: Peter KURNEV +// Copyright (c) 2010-2012 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 +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#include + +#include + +#include +#include + + +#include + +//======================================================================= +//function : +//purpose : +//======================================================================= + BOPAlgo_Builder::BOPAlgo_Builder() +: + BOPAlgo_BuilderShape(), + myArguments(myAllocator), + myMapFence(100, myAllocator), + myPaveFiller(NULL), + myDS(NULL), + //myContext(NULL), + myEntryPoint(0), + myImages(100, myAllocator), + myShapesSD(100, myAllocator), + mySplits(100, myAllocator), + //modified by NIZHNY-EMV Fri Sep 02 09:55:04 2011 + myOrigins(100, myAllocator) + //modified by NIZHNY-EMV Fri Sep 02 09:55:06 2011 +{ +} +//======================================================================= +//function : +//purpose : +//======================================================================= + BOPAlgo_Builder::BOPAlgo_Builder(const Handle(NCollection_BaseAllocator)& theAllocator) +: + BOPAlgo_BuilderShape(theAllocator), + myArguments(myAllocator), + myMapFence(100, myAllocator), + myPaveFiller(NULL), + myDS(NULL), + //myContext(NULL), + myEntryPoint(0), + myImages(100, myAllocator), + myShapesSD(100, myAllocator), + mySplits(100, myAllocator), + //modified by NIZHNY-EMV Fri Sep 02 09:55:04 2011 + myOrigins(100, myAllocator) + //modified by NIZHNY-EMV Fri Sep 02 09:55:06 2011 +{ +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= + BOPAlgo_Builder::~BOPAlgo_Builder() +{ + if (myEntryPoint==1) { + if (myPaveFiller) { + delete myPaveFiller; + myPaveFiller=NULL; + } + } +} +//======================================================================= +//function : Clear +//purpose : +//======================================================================= + void BOPAlgo_Builder::Clear() +{ + myArguments.Clear(); + myMapFence.Clear(); + myImages.Clear(); + myShapesSD.Clear(); + mySplits.Clear(); + //modified by NIZHNY-EMV Fri Sep 02 09:55:30 2011 + myOrigins.Clear(); + //modified by NIZHNY-EMV Fri Sep 02 09:55:34 2011 +} +//======================================================================= +//function : AddArgument +//purpose : +//======================================================================= + void BOPAlgo_Builder::AddArgument(const TopoDS_Shape& theShape) +{ + if (myMapFence.Add(theShape)) { + myArguments.Append(theShape); + } +} +//======================================================================= +//function : Arguments +//purpose : +//======================================================================= + const BOPCol_ListOfShape& BOPAlgo_Builder::Arguments()const +{ + return myArguments; +} +//======================================================================= +//function : Images +//purpose : +//======================================================================= + const BOPCol_DataMapOfShapeListOfShape& BOPAlgo_Builder::Images()const +{ + return myImages; +} +//modified by NIZHNY-EMV Wed Sep 14 10:16:14 2011 +//======================================================================= +//function : Origins +//purpose : +//======================================================================= + const BOPCol_DataMapOfShapeShape& BOPAlgo_Builder::Origins()const +{ + return myOrigins; +} + +//======================================================================= +//function : ShapesSd +//purpose : +//======================================================================= + const BOPCol_DataMapOfShapeShape& BOPAlgo_Builder::ShapesSD()const +{ + return myShapesSD; +} +//======================================================================= +//function : Splits +//purpose : +//======================================================================= + const BOPCol_DataMapOfShapeListOfShape& BOPAlgo_Builder::Splits()const +{ + return mySplits; +} +//======================================================================= +//function : PPaveFiller +//purpose : +//======================================================================= + BOPAlgo_PPaveFiller BOPAlgo_Builder::PPaveFiller() +{ + return myPaveFiller; +} +//======================================================================= +//function : PDS +//purpose : +//======================================================================= + BOPDS_PDS BOPAlgo_Builder::PDS() +{ + return myDS; +} +//modified by NIZHNY-EMV Wed Sep 14 10:16:16 2011 +//======================================================================= +// function: CheckData +// purpose: +//======================================================================= + void BOPAlgo_Builder::CheckData() +{ + Standard_Integer aNb; + // + myErrorStatus=0; + // + aNb=myArguments.Extent(); + if (aNb<2) { + myErrorStatus=100; // too few arguments to process + return; + } + // + // myPaveFiller + if (!myPaveFiller) { + myErrorStatus=101; + return; + } + // + myErrorStatus=myPaveFiller->ErrorStatus(); + if (myErrorStatus) { + myErrorStatus=102; // PaveFiller is failed + return; + } +} +//======================================================================= +//function : Prepare +//purpose : +//======================================================================= + void BOPAlgo_Builder::Prepare() +{ + myErrorStatus=0; + // + BRep_Builder aBB; + TopoDS_Compound aC; + // + // 1. myShape is empty compound + aBB.MakeCompound(aC); + myShape=aC; + myFlagHistory=Standard_True; +} +//======================================================================= +//function : Perform +//purpose : +//======================================================================= + void BOPAlgo_Builder::Perform() +{ + myErrorStatus=0; + // + if (myEntryPoint==1) { + if (myPaveFiller) { + delete myPaveFiller; + myPaveFiller=NULL; + } + } + // + Handle(NCollection_BaseAllocator) aAllocator=new NCollection_IncAllocator; + // + BOPAlgo_PaveFiller* pPF=new BOPAlgo_PaveFiller(aAllocator); + // + pPF->SetArguments(myArguments); + // + pPF->Perform(); + // + myEntryPoint=1; + PerformInternal(*pPF); +} +//======================================================================= +//function : PerformWithFiller +//purpose : +//======================================================================= + void BOPAlgo_Builder::PerformWithFiller(const BOPAlgo_PaveFiller& theFiller) +{ + myEntryPoint=0; + PerformInternal(theFiller); +} +//======================================================================= +//function : PerformInternal +//purpose : +//======================================================================= + void BOPAlgo_Builder::PerformInternal(const BOPAlgo_PaveFiller& theFiller) +{ + myErrorStatus=0; + // + myPaveFiller=(BOPAlgo_PaveFiller*)&theFiller; + myDS=myPaveFiller->PDS(); + myContext=myPaveFiller->Context(); + // + // 1. CheckData + CheckData(); + if (myErrorStatus) { + return; + } + // + // 2. Prepare + Prepare(); + if (myErrorStatus) { + return; + } + // + // 3. Fill Images + // 3.1 Vertice + FillImagesVertices(); + if (myErrorStatus) { + return; + } + // + BuildResult(TopAbs_VERTEX); + if (myErrorStatus) { + return; + } + // 3.2 Edges + FillImagesEdges(); + if (myErrorStatus) { + return; + } + // + BuildResult(TopAbs_EDGE); + if (myErrorStatus) { + return; + } + // + // 3.3 Wires + FillImagesContainers(TopAbs_WIRE); + if (myErrorStatus) { + return; + } + // + BuildResult(TopAbs_WIRE); + if (myErrorStatus) { + return; + } + + // 3.4 Faces + FillImagesFaces(); + if (myErrorStatus) { + return; + } + // + BuildResult(TopAbs_FACE); + if (myErrorStatus) { + return; + } + // 3.5 Shells + FillImagesContainers(TopAbs_SHELL); + if (myErrorStatus) { + return; + } + + BuildResult(TopAbs_SHELL); + if (myErrorStatus) { + return; + } + // 3.6 Solids + FillImagesSolids(); + if (myErrorStatus) { + return; + } + + BuildResult(TopAbs_SOLID); + if (myErrorStatus) { + return; + } + // 3.7 CompSolids + FillImagesContainers(TopAbs_COMPSOLID); + if (myErrorStatus) { + return; + } + + BuildResult(TopAbs_COMPSOLID); + if (myErrorStatus) { + return; + } + + // 3.8 Compounds + FillImagesCompounds(); + if (myErrorStatus) { + return; + } + + BuildResult(TopAbs_COMPOUND); + if (myErrorStatus) { + return; + } + // + // 4.History + PrepareHistory(); + // + // + // 5 Post-treatment + PostTreat(); + +} +// +// myErrorStatus +// +// 0 - Ok +// +//======================================================================= +//function : PostTreat +//purpose : +//======================================================================= + void BOPAlgo_Builder::PostTreat() +{ + //BRepLib::SameParameter(myShape, 1.e-7, Standard_True); + BOPTools_AlgoTools::CorrectTolerances(myShape, 0.01); +} diff --git a/src/BOPAlgo/BOPAlgo_BuilderArea.cdl b/src/BOPAlgo/BOPAlgo_BuilderArea.cdl new file mode 100644 index 0000000000..7fbc0b9b2e --- /dev/null +++ b/src/BOPAlgo/BOPAlgo_BuilderArea.cdl @@ -0,0 +1,85 @@ +-- Created by: Peter KURNEV +-- Copyright (c) 2010-2012 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 +-- +-- The content of this file is subject to the Open CASCADE Technology Public +-- License Version 6.5 (the "License"). You may not use the content of this file +-- except in compliance with the License. Please obtain a copy of the License +-- at http://www.opencascade.org and read it completely before using this file. +-- +-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +-- +-- The Original Code and all software distributed under the License is +-- distributed on an "AS IS" basis, without warranty of any kind, and the +-- Initial Developer hereby disclaims all such warranties, including without +-- limitation, any warranties of merchantability, fitness for a particular +-- purpose or non-infringement. Please see the License for the specific terms +-- and conditions governing the rights and limitations under the License. + +deferred class BuilderArea from BOPAlgo + inherits Algo from BOPAlgo + + ---Purpose: The root class for algorithms to build + -- faces/solids from set of edges/faces + +uses + Shape from TopoDS, + BaseAllocator from BOPCol, + ListOfShape from BOPCol, + MapOfOrientedShape from BOPCol, + Context from BOPInt + +--raises + +is + Initialize + returns BuilderArea from BOPAlgo; + ---C++: alias "Standard_EXPORT virtual ~BOPAlgo_BuilderArea();" + + Initialize(theAllocator: BaseAllocator from BOPCol) + returns BuilderArea from BOPAlgo; + + SetContext(me:out; + theContext:Context from BOPInt); + + Shapes(me) + returns ListOfShape from BOPCol; + ---C++: return const & + ---C++: alias "Standard_EXPORT void SetShapes(const BOPCol_ListOfShape& theLS);" + + Loops(me) + returns ListOfShape from BOPCol; + ---C++: return const & + + Areas(me) + returns ListOfShape from BOPCol; + ---C++: return const & + + PerformShapesToAvoid(me:out) + is deferred protected; + + PerformLoops(me:out) + is deferred protected; + + PerformAreas(me:out) + is deferred protected; + + PerformInternalShapes(me:out) + is deferred protected; + +fields + myContext : Context from BOPInt is protected; + myShapes : ListOfShape from BOPCol is protected; + myLoops : ListOfShape from BOPCol is protected; + myLoopsInternal : ListOfShape from BOPCol is protected; + + myAreas : ListOfShape from BOPCol is protected; + myShapesToAvoid : MapOfOrientedShape from BOPCol is protected; + -- + + +end BuilderArea; + diff --git a/src/BOPAlgo/BOPAlgo_BuilderArea.cxx b/src/BOPAlgo/BOPAlgo_BuilderArea.cxx new file mode 100644 index 0000000000..6246f63cec --- /dev/null +++ b/src/BOPAlgo/BOPAlgo_BuilderArea.cxx @@ -0,0 +1,142 @@ +// Created by: Peter KURNEV +// Copyright (c) 2010-2012 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 +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#include + +#include +#include +#include + +//======================================================================= +//function : +//purpose : +//======================================================================= + BOPAlgo_BuilderArea::BOPAlgo_BuilderArea() +: + BOPAlgo_Algo(), + //myContext(NULL), + myShapes(myAllocator), + myLoops(myAllocator), + myLoopsInternal(myAllocator), + myAreas(myAllocator), + myShapesToAvoid(100, myAllocator) +{ +} +//======================================================================= +//function : +//purpose : +//======================================================================= + BOPAlgo_BuilderArea::BOPAlgo_BuilderArea(const Handle(NCollection_BaseAllocator)& theAllocator) +: + BOPAlgo_Algo(theAllocator), + //myContext(NULL), + myShapes(myAllocator), + myLoops(myAllocator), + myLoopsInternal(myAllocator), + myAreas(myAllocator), + myShapesToAvoid(100, myAllocator) +{ +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= + BOPAlgo_BuilderArea::~BOPAlgo_BuilderArea() +{ +} +//======================================================================= +//function : SetContext +//purpose : +//======================================================================= + void BOPAlgo_BuilderArea::SetContext(const Handle(BOPInt_Context)& theContext) +{ + myContext=theContext; +} +//======================================================================= +//function : SetShapes +//purpose : +//======================================================================= + void BOPAlgo_BuilderArea::SetShapes(const BOPCol_ListOfShape& theLF) +{ + BOPCol_ListIteratorOfListOfShape aIt; + // + myShapes.Clear(); + aIt.Initialize(theLF); + for(; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aF=aIt.Value(); + myShapes.Append(aF); + } +} +//======================================================================= +//function : Shapes +//purpose : +//======================================================================= + const BOPCol_ListOfShape& BOPAlgo_BuilderArea::Shapes()const +{ + return myShapes; +} +//======================================================================= +//function : Loops +//purpose : +//======================================================================= + const BOPCol_ListOfShape& BOPAlgo_BuilderArea::Loops()const +{ + return myLoops; +} +//======================================================================= +//function : Areas +//purpose : +//======================================================================= + const BOPCol_ListOfShape& BOPAlgo_BuilderArea::Areas()const +{ + return myAreas; +} +/* +//======================================================================= +//function :PerformShapesToAvoid +//purpose : +//======================================================================= + void BOPAlgo_BuilderArea::PerformShapesToAvoid() +{ +} +//======================================================================= +//function : PerformLoops +//purpose : +//======================================================================= + void BOPAlgo_BuilderArea::PerformLoops() +{ +} +//======================================================================= +//function : PerformAreas +//purpose : +//======================================================================= + void BOPAlgo_BuilderArea::PerformAreas() +{ +} +//======================================================================= +//function : PerformInternalShapes +//purpose : +//======================================================================= + void BOPAlgo_BuilderArea::PerformInternalShapes() +{ +} +*/ diff --git a/src/BOPAlgo/BOPAlgo_BuilderFace.cdl b/src/BOPAlgo/BOPAlgo_BuilderFace.cdl new file mode 100644 index 0000000000..ac99e8d03f --- /dev/null +++ b/src/BOPAlgo/BOPAlgo_BuilderFace.cdl @@ -0,0 +1,84 @@ +-- Created by: Peter KURNEV +-- Copyright (c) 2010-2012 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 +-- +-- The content of this file is subject to the Open CASCADE Technology Public +-- License Version 6.5 (the "License"). You may not use the content of this file +-- except in compliance with the License. Please obtain a copy of the License +-- at http://www.opencascade.org and read it completely before using this file. +-- +-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +-- +-- The Original Code and all software distributed under the License is +-- distributed on an "AS IS" basis, without warranty of any kind, and the +-- Initial Developer hereby disclaims all such warranties, including without +-- limitation, any warranties of merchantability, fitness for a particular +-- purpose or non-infringement. Please see the License for the specific terms +-- and conditions governing the rights and limitations under the License. + + + +class BuilderFace from BOPAlgo + inherits BuilderArea from BOPAlgo + + ---Purpose: The algorithm to build faces from set of edges + +uses + Face from TopoDS, + BaseAllocator from BOPCol +--raises + +is + Create + returns BuilderFace from BOPAlgo; + ---C++: alias "Standard_EXPORT virtual ~BOPAlgo_BuilderFace();" + + Create (theAllocator: BaseAllocator from BOPCol) + returns BuilderFace from BOPAlgo; + + SetFace(me:out; + theFace:Face from TopoDS); + ---Purpose: Sets the face generatix + + Face(me) + ---Purpose: Returns the face generatix + returns Face from TopoDS; + ---C++: return const & + + Perform(me:out) + ---Purpose: Performs the algorithm + is redefined; + + PerformShapesToAvoid(me:out) + ---Purpose: Collect the edges that + -- a) are internal + -- b) are the same and have different orientation + is redefined protected; + + PerformLoops(me:out) + ---Purpose: Build draft wires + -- a)myLoops - draft wires that consist of + -- boundary edges + -- b)myLoopsInternal - draft wires that contains + -- inner edges + is redefined protected; + + PerformAreas(me:out) + ---Purpose: Build draft faces that contains boundary edges + is redefined protected; + + PerformInternalShapes(me:out) + ---Purpose: Build finalized faces with internals + is redefined protected; + + CheckData(me:out) + is redefined protected; + +fields + myFace : Face from TopoDS is protected; + +end BuilderFace; + diff --git a/src/BOPAlgo/BOPAlgo_BuilderFace.cxx b/src/BOPAlgo/BOPAlgo_BuilderFace.cxx new file mode 100644 index 0000000000..f9e0a5da29 --- /dev/null +++ b/src/BOPAlgo/BOPAlgo_BuilderFace.cxx @@ -0,0 +1,708 @@ +// Created by: Peter KURNEV +// Copyright (c) 2010-2012 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 +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + +#include + +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include +#include + +// +#include +#include +#include +// +#include +#include +#include +#include +#include +#include +#include + + +static + Standard_Boolean IsGrowthWire(const TopoDS_Shape& , + const BOPCol_IndexedMapOfShape& ); + +static + Standard_Boolean IsInside(const TopoDS_Shape& , + const TopoDS_Shape& , + Handle(BOPInt_Context)& ); +static + void MakeInternalWires(const BOPCol_MapOfShape& , + BOPCol_ListOfShape& ); + +//======================================================================= +//function : +//purpose : +//======================================================================= + BOPAlgo_BuilderFace::BOPAlgo_BuilderFace() +: + BOPAlgo_BuilderArea() +{ +} +//======================================================================= +//function : +//purpose : +//======================================================================= + BOPAlgo_BuilderFace::BOPAlgo_BuilderFace(const Handle(NCollection_BaseAllocator)& theAllocator) +: + BOPAlgo_BuilderArea(theAllocator) +{ +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= + BOPAlgo_BuilderFace::~BOPAlgo_BuilderFace() +{ +} +//======================================================================= +//function : SetFace +//purpose : +//======================================================================= + void BOPAlgo_BuilderFace::SetFace(const TopoDS_Face& theFace) +{ + myFace=theFace; +} +//======================================================================= +//function : Face +//purpose : +//======================================================================= + const TopoDS_Face& BOPAlgo_BuilderFace::Face()const +{ + return myFace; +} +//======================================================================= +//function : CheckData +//purpose : +//======================================================================= + void BOPAlgo_BuilderFace::CheckData() +{ + myErrorStatus=0; + // + if (myContext.IsNull()) { + //myErrorStatus=11;// Null Context + //return; + myContext = new BOPInt_Context; + } + // + if (myFace.IsNull()) { + myErrorStatus=12;// Null face generix + return; + } +} +//======================================================================= +//function : Perform +//purpose : +//======================================================================= + void BOPAlgo_BuilderFace::Perform() +{ + myErrorStatus=0; + // + CheckData(); + if (myErrorStatus) { + return; + } + // + PerformShapesToAvoid(); + if (myErrorStatus) { + return; + } + // + PerformLoops(); + if (myErrorStatus) { + return; + } + // + PerformAreas(); + if (myErrorStatus) { + return; + } + // + PerformInternalShapes(); + if (myErrorStatus) { + return; + } +} +//======================================================================= +//function :PerformShapesToAvoid +//purpose : +//======================================================================= + void BOPAlgo_BuilderFace::PerformShapesToAvoid() +{ + Standard_Boolean bFound; + Standard_Integer i, iCnt, aNbV, aNbE; + BOPCol_IndexedDataMapOfShapeListOfShape aMVE; + BOPCol_ListIteratorOfListOfShape aIt; + // + myShapesToAvoid.Clear(); + // + iCnt=0; + while (1) { + ++iCnt; + bFound=Standard_False; + // + // 1. MEF + aMVE.Clear(); + aIt.Initialize (myShapes); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aE=aIt.Value(); + if (!myShapesToAvoid.Contains(aE)) { + BOPTools::MapShapesAndAncestors(aE, TopAbs_VERTEX, TopAbs_EDGE, aMVE); + } + //else { + //int a=0; + //} + } + aNbV=aMVE.Extent(); + // + // 2. myEdgesToAvoid + for (i=1; i<=aNbV; ++i) { + const TopoDS_Vertex& aV=(*(TopoDS_Vertex *)(&aMVE.FindKey(i))); + // + BOPCol_ListOfShape& aLE=aMVE.ChangeFromKey(aV); + aNbE=aLE.Extent(); + if (!aNbE) { + continue; + } + // + const TopoDS_Edge& aE1=(*(TopoDS_Edge *)(&aLE.First())); + if (aNbE==1) { + if (BRep_Tool::Degenerated(aE1)) { + continue; + } + if (aV.Orientation()==TopAbs_INTERNAL) { + continue; + } + bFound=Standard_True; + myShapesToAvoid.Add(aE1); + } + else if (aNbE==2) { + const TopoDS_Edge& aE2=(*(TopoDS_Edge *)(&aLE.Last())); + if (aE2.IsSame(aE1)) { + TopoDS_Vertex aV1x, aV2x; + // + TopExp::Vertices(aE1, aV1x, aV2x); + if (aV1x.IsSame(aV2x)) { + continue; + } + bFound=Standard_True; + myShapesToAvoid.Add(aE1); + myShapesToAvoid.Add(aE2); + } + } + }// for (i=1; i<=aNbE; ++i) { + // + if (!bFound) { + break; + } + // + }//while (1) + //printf(" EdgesToAvoid=%d, iCnt=%d\n", EdgesToAvoid.Extent(), iCnt); +} +//======================================================================= +//function : PerformLoops +//purpose : +//======================================================================= + void BOPAlgo_BuilderFace::PerformLoops() +{ + myErrorStatus=0; + // + Standard_Boolean bFlag; + Standard_Integer iErr, aNbEA; + BOPCol_ListIteratorOfListOfShape aIt; + BOPCol_MapIteratorOfMapOfOrientedShape aItM; + BOPCol_IndexedDataMapOfShapeListOfShape aVEMap; + BOPCol_MapOfOrientedShape aMAdded; + TopoDS_Iterator aItW; + BRep_Builder aBB; + BOPAlgo_WireEdgeSet aWES(myAllocator); + BOPAlgo_WireSplitter aWSp(myAllocator); + // + // 1. + myLoops.Clear(); + aWES.SetFace(myFace); + // + aIt.Initialize(myShapes); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aE=aIt.Value(); + if (!myShapesToAvoid.Contains(aE)) { + aWES.AddStartElement(aE); + } + } + // + aWSp.SetWES(aWES); + aWSp.Perform(); + iErr=aWSp.ErrorStatus(); + if (iErr) { + return; + } + // + const BOPCol_ListOfShape& aLW=aWES.Shapes(); + aIt.Initialize (aLW); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aW=aIt.Value(); + myLoops.Append(aW); + } + // Post Treatment + BOPCol_MapOfOrientedShape aMEP; + // + // a. collect all edges that are in loops + aIt.Initialize (myLoops); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aW=aIt.Value(); + aItW.Initialize(aW); + for (; aItW.More(); aItW.Next()) { + const TopoDS_Shape& aE=aItW.Value(); + aMEP.Add(aE); + } + } + // + // b. collect all edges that are to avoid + aItM.Initialize(myShapesToAvoid); + for (; aItM.More(); aItM.Next()) { + const TopoDS_Shape& aE=aItM.Key(); + aMEP.Add(aE); + } + // + // c. add all edges that are not processed to myShapesToAvoid + aIt.Initialize (myShapes); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aE=aIt.Value(); + if (!aMEP.Contains(aE)) { + myShapesToAvoid.Add(aE); + } + } + // + // 2. Internal Wires + myLoopsInternal.Clear(); + // + aNbEA=myShapesToAvoid.Extent(); + aItM.Initialize(myShapesToAvoid); + for (; aItM.More(); aItM.Next()) { + const TopoDS_Shape& aEE=aItM.Key(); + BOPTools::MapShapesAndAncestors(aEE, TopAbs_VERTEX, TopAbs_EDGE, aVEMap); + } + // + bFlag=Standard_True; + aItM.Initialize(myShapesToAvoid); + for (; aItM.More()&&bFlag; aItM.Next()) { + const TopoDS_Shape& aEE=aItM.Key(); + if (!aMAdded.Add(aEE)) { + continue; + } + // + // make new wire + TopoDS_Wire aW; + aBB.MakeWire(aW); + aBB.Add(aW, aEE); + // + aItW.Initialize(aW); + for (; aItW.More()&&bFlag; aItW.Next()) { + const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&aItW.Value())); + // + TopoDS_Iterator aItE(aE); + for (; aItE.More()&&bFlag; aItE.Next()) { + const TopoDS_Vertex& aV = (*(TopoDS_Vertex *)(&aItE.Value())); + const BOPCol_ListOfShape& aLE=aVEMap.FindFromKey(aV); + aIt.Initialize(aLE); + for (; aIt.More()&&bFlag; aIt.Next()) { + const TopoDS_Shape& aEx=aIt.Value(); + if (aMAdded.Add(aEx)) { + aBB.Add(aW, aEx); + if(aMAdded.Extent()==aNbEA) { + bFlag=!bFlag; + } + } + }//for (; aIt.More(); aIt.Next()) { + }//for (; aItE.More(); aItE.Next()) { + }//for (; aItW.More(); aItW.Next()) { + myLoopsInternal.Append(aW); + }//for (; aItM.More(); aItM.Next()) { +} +//======================================================================= +//function : PerformAreas +//purpose : +//======================================================================= + void BOPAlgo_BuilderFace::PerformAreas() +{ + myErrorStatus=0; + // + Standard_Boolean bIsGrowth, bIsHole; + Standard_Real aTol; + TopoDS_Shape anInfinitePointShape; + // + BOPCol_ListOfShape aNewFaces, aHoleWires; + BOPCol_DataMapOfShapeShape aInOutMap; + BOPCol_DataMapOfShapeListOfShape aMSH; + BOPCol_IndexedMapOfShape aMHE; + + BOPCol_DataMapIteratorOfDataMapOfShapeListOfShape aItMSH; + BOPCol_ListIteratorOfListOfShape aIt1, aIt2; + BRep_Builder aBB; + Handle(Geom_Surface) aS; + TopLoc_Location aLoc; + // + aTol=BRep_Tool::Tolerance(myFace); + aS=BRep_Tool::Surface(myFace, aLoc); + // + myAreas.Clear(); + // + // Draft faces [aNewFaces] + aIt1.Initialize(myLoops); + for ( ; aIt1.More(); aIt1.Next()) { + const TopoDS_Shape& aWire=aIt1.Value(); + // + bIsGrowth=IsGrowthWire(aWire, aMHE); + if (bIsGrowth) { + // make a growth face from a wire + TopoDS_Face aFace; + aBB.MakeFace(aFace, aS, aLoc, aTol); + aBB.Add (aFace, aWire); + // + aNewFaces.Append (aFace); + } + else{ + // check if a wire is a hole + //XX + //modified by NIZNHY-PKV Thu Jun 03 09:53:09 2010f + TopoDS_Face aFace; + aBB.MakeFace(aFace, aS, aLoc, aTol); + aBB.Add (aFace, aWire); + // + IntTools_FClass2d& aClsf=myContext->FClass2d(aFace); + aClsf.Init(aFace, aTol); + // + bIsHole=aClsf.IsHole(); + // + //bIsHole=BOPTools_AlgoTools::IsHole(aWire, myFace); + //modified by NIZNHY-PKV Thu Jun 03 09:53:13 2010t + //XX + if (bIsHole) { + aHoleWires.Append(aWire); + BOPTools::MapShapes(aWire, TopAbs_EDGE, aMHE); + } + else { + // make a growth face from a wire + TopoDS_Face aFace; + aBB.MakeFace(aFace, aS, aLoc, aTol); + aBB.Add (aFace, aWire); + // + aNewFaces.Append (aFace); + } + } + } + // + // 2. Find outer growth shell that is most close to each hole shell + aIt2.Initialize(aHoleWires); + for (; aIt2.More(); aIt2.Next()) { + const TopoDS_Shape& aHole = aIt2.Value(); + // + aIt1.Initialize(aNewFaces); + for ( ; aIt1.More(); aIt1.Next()) { + const TopoDS_Shape& aF=aIt1.Value(); + // + if (!IsInside(aHole, aF, myContext)){ + continue; + } + // + if ( aInOutMap.IsBound (aHole)){ + const TopoDS_Shape& aF2=aInOutMap(aHole); + if (IsInside(aF, aF2, myContext)) { + aInOutMap.UnBind(aHole); + aInOutMap.Bind (aHole, aF); + } + } + else{ + aInOutMap.Bind (aHole, aF); + } + } + // + // Add aHole to a map Face/ListOfHoles [aMSH] + if (aInOutMap.IsBound(aHole)){ + const TopoDS_Shape& aF=aInOutMap(aHole); + if (aMSH.IsBound(aF)) { + BOPCol_ListOfShape& aLH=aMSH.ChangeFind(aF); + aLH.Append(aHole); + } + else { + BOPCol_ListOfShape aLH; + aLH.Append(aHole); + aMSH.Bind(aF, aLH); + } + } + }// for (; aIt2.More(); aIt2.Next()) + // + // 3. Add aHoles to Faces + aItMSH.Initialize(aMSH); + for (; aItMSH.More(); aItMSH.Next()) { + TopoDS_Face aF=(*(TopoDS_Face *)(&aItMSH.Key())); + // + const BOPCol_ListOfShape& aLH=aItMSH.Value(); + aIt2.Initialize(aLH); + for (; aIt2.More(); aIt2.Next()) { + const TopoDS_Shape& aHole = aIt2.Value(); + aBB.Add (aF, aHole); + } + // + // update classifier + aTol=BRep_Tool::Tolerance(aF); + IntTools_FClass2d& aClsf=myContext->FClass2d(aF); + aClsf.Init(aF, aTol); + } + // + // These aNewFaces are draft faces that + // do not contain any internal shapes + // + aIt1.Initialize(aNewFaces); + for ( ; aIt1.More(); aIt1.Next()) { + const TopoDS_Shape& aF=aIt1.Value(); + myAreas.Append(aF); + } +} +//======================================================================= +//function : PerformInternalShapes +//purpose : +//======================================================================= + void BOPAlgo_BuilderFace::PerformInternalShapes() +{ + myErrorStatus=0; + // + Standard_Integer aNbWI=myLoopsInternal.Extent(); + if (!aNbWI) {// nothing to do + return; + } + // + //Standard_Real aTol; + BRep_Builder aBB; + BOPCol_ListIteratorOfListOfShape aIt1, aIt2; + TopoDS_Iterator aIt; + BOPCol_MapOfShape aME, aMEP; + BOPCol_MapIteratorOfMapOfShape aItME; + BOPCol_IndexedDataMapOfShapeListOfShape aMVE; + BOPCol_ListOfShape aLSI; + // + // 1. All internal edges + aIt1.Initialize(myLoopsInternal); + for (; aIt1.More(); aIt1.Next()) { + const TopoDS_Shape& aWire=aIt1.Value(); + aIt.Initialize(aWire); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aE=aIt.Value(); + aME.Add(aE); + } + } + aNbWI=aME.Extent(); + // + // 2 Process faces + aIt2.Initialize(myAreas); + for ( ; aIt2.More(); aIt2.Next()) { + TopoDS_Face& aF=(*(TopoDS_Face *)(&aIt2.Value())); + // + aMVE.Clear(); + BOPTools::MapShapesAndAncestors(aF, TopAbs_VERTEX, TopAbs_EDGE, aMVE); + // + // 2.1 Separate faces to process aMEP + aMEP.Clear(); + aItME.Initialize(aME); + for (; aItME.More(); aItME.Next()) { + const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&aItME.Key())); + if (IsInside(aE, aF, myContext)) { + aMEP.Add(aE); + } + } + // + // 2.2 Make Internal Wires + aLSI.Clear(); + MakeInternalWires(aMEP, aLSI); + // + // 2.3 Add them to aF + aIt1.Initialize(aLSI); + for (; aIt1.More(); aIt1.Next()) { + const TopoDS_Shape& aSI=aIt1.Value(); + aBB.Add (aF, aSI); + } + // + // 2.4 Remove faces aMFP from aMF + aItME.Initialize(aMEP); + for (; aItME.More(); aItME.Next()) { + const TopoDS_Shape& aE=aItME.Key(); + aME.Remove(aE); + } + // + aNbWI=aME.Extent(); + if (!aNbWI) { + break; + } + } //for ( ; aIt2.More(); aIt2.Next()) { +} +//======================================================================= +//function : MakeInternalWires +//purpose : +//======================================================================= +void MakeInternalWires(const BOPCol_MapOfShape& theME, + BOPCol_ListOfShape& theWires) +{ + BOPCol_MapIteratorOfMapOfShape aItM; + BOPCol_MapOfShape aAddedMap; + BOPCol_ListIteratorOfListOfShape aItE; + BOPCol_IndexedDataMapOfShapeListOfShape aMVE; + BRep_Builder aBB; + // + aItM.Initialize(theME); + for (; aItM.More(); aItM.Next()) { + const TopoDS_Shape& aE=aItM.Key(); + BOPTools::MapShapesAndAncestors(aE, TopAbs_VERTEX, TopAbs_EDGE, aMVE); + } + // + aItM.Initialize(theME); + for (; aItM.More(); aItM.Next()) { + TopoDS_Shape aEE=aItM.Key(); + if (!aAddedMap.Add(aEE)) { + continue; + } + // + // make a new shell + TopoDS_Wire aW; + aBB.MakeWire(aW); + aEE.Orientation(TopAbs_INTERNAL); + aBB.Add(aW, aEE); + // + TopoDS_Iterator aItAdded (aW); + for (; aItAdded.More(); aItAdded.Next()) { + const TopoDS_Shape& aE =aItAdded.Value(); + // + TopExp_Explorer aExp(aE, TopAbs_VERTEX); + for (; aExp.More(); aExp.Next()) { + const TopoDS_Shape& aV =aExp.Current(); + const BOPCol_ListOfShape& aLE=aMVE.FindFromKey(aV); + aItE.Initialize(aLE); + for (; aItE.More(); aItE.Next()) { + TopoDS_Shape aEL=aItE.Value(); + if (aAddedMap.Add(aEL)){ + aEL.Orientation(TopAbs_INTERNAL); + aBB.Add(aW, aEL); + } + } + } + } + theWires.Append(aW); + } +} +//======================================================================= +//function : IsInside +//purpose : +//======================================================================= +Standard_Boolean IsInside(const TopoDS_Shape& theHole, + const TopoDS_Shape& theF2, + Handle(BOPInt_Context)& theContext) +{ + Standard_Boolean bRet; + Standard_Real aT, aU, aV; + + TopAbs_State aState; + TopExp_Explorer aExp; + BOPCol_IndexedMapOfShape aME2; + gp_Pnt2d aP2D; + // + bRet=Standard_False; + aState=TopAbs_UNKNOWN; + const TopoDS_Face& aF2=(*(TopoDS_Face *)(&theF2)); + // + BOPTools::MapShapes(aF2, TopAbs_EDGE, aME2);//AA + // + aExp.Init(theHole, TopAbs_EDGE); + if (aExp.More()) { + const TopoDS_Edge& aE =(*(TopoDS_Edge *)(&aExp.Current())); + if (aME2.Contains(aE)) { + return bRet; + } + //modified by NIZHNY-EMV Fri Oct 15 09:21:23 2010 + if (!BRep_Tool::Degenerated(aE)) { + // + aT=BOPTools_AlgoTools2D::IntermediatePoint(aE); + BOPTools_AlgoTools2D::PointOnSurface(aE, aF2, aT, aU, aV); + aP2D.SetCoord(aU, aV); + // + IntTools_FClass2d& aClsf=theContext->FClass2d(aF2); + aState=aClsf.Perform(aP2D); + bRet=(aState==TopAbs_IN); + } + //modified by NIZHNY-EMV Fri Oct 15 09:21:37 2010 + } + // + return bRet; +} + +//======================================================================= +//function : IsGrowthWire +//purpose : +//======================================================================= +Standard_Boolean IsGrowthWire(const TopoDS_Shape& theWire, + const BOPCol_IndexedMapOfShape& theMHE) +{ + Standard_Boolean bRet; + TopoDS_Iterator aIt; + // + bRet=Standard_False; + if (theMHE.Extent()) { + aIt.Initialize(theWire); + for(; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aE=aIt.Value(); + if (theMHE.Contains(aE)) { + return !bRet; + } + } + } + return bRet; +} + +//BRepTools::Write(aFF, "ff"); +// +// ErrorStatus : +// 11 - Null Context +// 12 - Null face generix diff --git a/src/BOPAlgo/BOPAlgo_BuilderShape.cdl b/src/BOPAlgo/BOPAlgo_BuilderShape.cdl new file mode 100644 index 0000000000..857fbf0116 --- /dev/null +++ b/src/BOPAlgo/BOPAlgo_BuilderShape.cdl @@ -0,0 +1,113 @@ +-- Created by: Peter KURNEV +-- Copyright (c) 2010-2012 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 +-- +-- The content of this file is subject to the Open CASCADE Technology Public +-- License Version 6.5 (the "License"). You may not use the content of this file +-- except in compliance with the License. Please obtain a copy of the License +-- at http://www.opencascade.org and read it completely before using this file. +-- +-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +-- +-- The Original Code and all software distributed under the License is +-- distributed on an "AS IS" basis, without warranty of any kind, and the +-- Initial Developer hereby disclaims all such warranties, including without +-- limitation, any warranties of merchantability, fitness for a particular +-- purpose or non-infringement. Please see the License for the specific terms +-- and conditions governing the rights and limitations under the License. + + +deferred class BuilderShape from BOPAlgo + inherits Algo from BOPAlgo + + ---Purpose: Root class for algorithms that has shape as result + +uses + Shape from TopoDS, + ListOfShape from TopTools, + BaseAllocator from BOPCol, + MapOfShape from BOPCol, + IndexedDataMapOfShapeListOfShape from BOPCol + +--raises + +is + Initialize + returns BuilderShape from BOPAlgo; + ---C++: alias "Standard_EXPORT virtual ~BOPAlgo_BuilderShape();" + + Initialize (theAllocator: BaseAllocator from BOPCol) + returns BuilderShape from BOPAlgo; + + Shape(me) + ---Purpose: Returns the result of algorithm + returns Shape from TopoDS; + ---C++: return const & + + ------------------------------------------------------------------ + --- The following methods are not implemented at this level. + -- An empty list is returned. + --- They are optional and can be redefined. + ------------------------------------------------------------------ + Generated (me:out; + theS : Shape from TopoDS) + ---Purpose: Returns the list of shapes generated from the + -- shape theS. + returns ListOfShape from TopTools + is virtual; + ---C++: return const & + + Modified (me:out; + theS : Shape from TopoDS) + ---Purpose: Returns the list of shapes modified from the + -- shape theS. + returns ListOfShape from TopTools + is virtual; + ---C++: return const & + + IsDeleted (me:out; + theS : Shape from TopoDS) + ---Purpose: Returns true if the shape theS has been deleted. + returns Boolean from Standard + is virtual; + + HasDeleted (me) + ---Purpose: Returns true if the at least one shape(or subshape) + -- of arguments has been deleted. + returns Boolean from Standard; + + HasGenerated (me) + ---Purpose: Returns true if the at least one shape(or subshape) + -- of arguments has generated shapes. + returns Boolean from Standard; + + HasModified (me) + ---Purpose: Returns true if the at least one shape(or subshape) + -- of arguments has modified shapes. + returns Boolean from Standard; + + PrepareHistory (me:out) + ---Purpose: Prepare information for history support + is virtual protected; + + ImagesResult(me) + returns IndexedDataMapOfShapeListOfShape from BOPCol; + ---C++: return const & + +fields + myShape : Shape from TopoDS is protected; + -- + myHistShapes : ListOfShape from TopTools is protected; + myMapShape : MapOfShape from BOPCol is protected; + myHasDeleted : Boolean from Standard is protected; + myHasGenerated : Boolean from Standard is protected; + myHasModified : Boolean from Standard is protected; + myImagesResult : IndexedDataMapOfShapeListOfShape from BOPCol is protected; + myFlagHistory : Boolean from Standard is protected; + +end BuilderShape; + + diff --git a/src/BOPAlgo/BOPAlgo_BuilderShape.cxx b/src/BOPAlgo/BOPAlgo_BuilderShape.cxx new file mode 100644 index 0000000000..b82e287342 --- /dev/null +++ b/src/BOPAlgo/BOPAlgo_BuilderShape.cxx @@ -0,0 +1,142 @@ +// Created by: Peter KURNEV +// Copyright (c) 2010-2012 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 +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#include +//======================================================================= +//function : +//purpose : +//======================================================================= + BOPAlgo_BuilderShape::BOPAlgo_BuilderShape() +: + BOPAlgo_Algo() +{ + myHasDeleted=Standard_False; + myHasGenerated=Standard_False; + myHasModified=Standard_False; + myFlagHistory=Standard_False; +} +//======================================================================= +//function : +//purpose : +//======================================================================= + BOPAlgo_BuilderShape::BOPAlgo_BuilderShape(const Handle(NCollection_BaseAllocator)& theAllocator) +: + BOPAlgo_Algo(theAllocator) +{ + myHasDeleted=Standard_False; + myHasGenerated=Standard_False; + myHasModified=Standard_False; + myFlagHistory=Standard_False; +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= + BOPAlgo_BuilderShape::~BOPAlgo_BuilderShape() +{ +} +//======================================================================= +//function : Shape +//purpose : +//======================================================================= + const TopoDS_Shape& BOPAlgo_BuilderShape::Shape() const +{ + return myShape; +} +// +//======================================================================= +//function : Generated +//purpose : +//======================================================================= + const TopTools_ListOfShape& BOPAlgo_BuilderShape::Generated(const TopoDS_Shape& ) +{ + myHistShapes.Clear(); + return myHistShapes; +} +//======================================================================= +//function : Modified +//purpose : +//======================================================================= + const TopTools_ListOfShape& BOPAlgo_BuilderShape::Modified(const TopoDS_Shape& ) +{ + myHistShapes.Clear(); + return myHistShapes; +} +//======================================================================= +//function : IsDeleted +//purpose : +//======================================================================= + Standard_Boolean BOPAlgo_BuilderShape::IsDeleted(const TopoDS_Shape& theS) +{ + Standard_Boolean bRet; + // + bRet=!myMapShape.Contains(theS); + return bRet; +} +//======================================================================= +//function : HasDeleted +//purpose : +//======================================================================= + Standard_Boolean BOPAlgo_BuilderShape::HasDeleted()const +{ + return myHasDeleted; +} +//======================================================================= +//function : HasGenerated +//purpose : +//======================================================================= + Standard_Boolean BOPAlgo_BuilderShape::HasGenerated()const +{ + return myHasGenerated; +} +//======================================================================= +//function : HasModified +//purpose : +//======================================================================= + Standard_Boolean BOPAlgo_BuilderShape::HasModified()const +{ + return myHasModified; +} +//======================================================================= +//function : PrepareHistory +//purpose : +//======================================================================= + void BOPAlgo_BuilderShape::PrepareHistory() +{ + myHistShapes.Clear(); + myMapShape.Clear(); + myHasDeleted=Standard_False; + myHasGenerated=Standard_False; + myHasModified=Standard_False; + myFlagHistory=Standard_False; +} + +//======================================================================= +//function : ImagesResult +//purpose : +//======================================================================= + const BOPCol_IndexedDataMapOfShapeListOfShape& + BOPAlgo_BuilderShape::ImagesResult()const +{ + return myImagesResult; +} + diff --git a/src/BOPAlgo/BOPAlgo_BuilderSolid.cdl b/src/BOPAlgo/BOPAlgo_BuilderSolid.cdl new file mode 100644 index 0000000000..62062e4c4b --- /dev/null +++ b/src/BOPAlgo/BOPAlgo_BuilderSolid.cdl @@ -0,0 +1,69 @@ +-- Created by: Peter KURNEV +-- Copyright (c) 2010-2012 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 +-- +-- The content of this file is subject to the Open CASCADE Technology Public +-- License Version 6.5 (the "License"). You may not use the content of this file +-- except in compliance with the License. Please obtain a copy of the License +-- at http://www.opencascade.org and read it completely before using this file. +-- +-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +-- +-- The Original Code and all software distributed under the License is +-- distributed on an "AS IS" basis, without warranty of any kind, and the +-- Initial Developer hereby disclaims all such warranties, including without +-- limitation, any warranties of merchantability, fitness for a particular +-- purpose or non-infringement. Please see the License for the specific terms +-- and conditions governing the rights and limitations under the License. + +class BuilderSolid from BOPAlgo + inherits BuilderArea from BOPAlgo + +---Purpose: The algorithm to build solids from set of faces + +uses + BaseAllocator from BOPCol + +--raises + +is + Create + returns BuilderSolid from BOPAlgo; + ---C++: alias "Standard_EXPORT virtual ~BOPAlgo_BuilderSolid();" + + + Create (theAllocator: BaseAllocator from BOPCol) + returns BuilderSolid from BOPAlgo; + + Perform(me:out) + ---Purpose: Performs the algorithm + is redefined; + + PerformShapesToAvoid(me:out) + ---Purpose: Collect the faces that + -- a) are internal + -- b) are the same and have different orientation + is redefined protected; + + PerformLoops(me:out) + ---Purpose: Build draft shells + -- a)myLoops - draft shells that consist of + -- boundary faces + -- b)myLoopsInternal - draft shells that contains + -- inner faces + is redefined protected; + + PerformAreas(me:out) + ---Purpose: Build draft solids that contains boundary faces + is redefined protected; + + PerformInternalShapes(me:out) + ---Purpose: Build finalized solids with internal shells + is redefined protected; + +--fields + +end BuilderSolid; diff --git a/src/BOPAlgo/BOPAlgo_BuilderSolid.cxx b/src/BOPAlgo/BOPAlgo_BuilderSolid.cxx new file mode 100644 index 0000000000..ab9573158d --- /dev/null +++ b/src/BOPAlgo/BOPAlgo_BuilderSolid.cxx @@ -0,0 +1,855 @@ +// Created by: Peter KURNEV +// Copyright (c) 2010-2012 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 +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#include + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +// +#include +#include +#include +#include +#include +// +#include +// +#include +#include +#include +#include +#include + +static + Standard_Boolean IsGrowthShell(const TopoDS_Shape& , + const BOPCol_IndexedMapOfShape& ); +static + Standard_Boolean IsHole(const TopoDS_Shape& , + Handle(BOPInt_Context)& ); +static + Standard_Boolean IsInside(const TopoDS_Shape& , + const TopoDS_Shape& , + Handle(BOPInt_Context)& ); +static + void MakeInternalShells(const BOPCol_MapOfShape& , + BOPCol_ListOfShape& ); + +static + Standard_Boolean IsClosedShell(const TopoDS_Shell& theShell); + +//======================================================================= +//function : +//purpose : +//======================================================================= + BOPAlgo_BuilderSolid::BOPAlgo_BuilderSolid() +: + BOPAlgo_BuilderArea() +{ +} +//======================================================================= +//function : +//purpose : +//======================================================================= + BOPAlgo_BuilderSolid::BOPAlgo_BuilderSolid(const Handle(NCollection_BaseAllocator)& theAllocator) +: + BOPAlgo_BuilderArea(theAllocator) +{ +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= + BOPAlgo_BuilderSolid::~BOPAlgo_BuilderSolid() +{ +} +//======================================================================= +//function : Perform +//purpose : +//======================================================================= + void BOPAlgo_BuilderSolid::Perform() +{ + myErrorStatus=0; + // + if (myContext.IsNull()) { + //myErrorStatus=11;// Null Context + //return; + myContext=new BOPInt_Context; + } + // + TopoDS_Compound aC; + BRep_Builder aBB; + BOPCol_ListIteratorOfListOfShape aIt; + // + aBB.MakeCompound(aC); + aIt.Initialize(myShapes); + for(; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aF=aIt.Value(); + aBB.Add(aC, aF); + } + // + // + PerformShapesToAvoid(); + if (myErrorStatus) { + return; + } + // + PerformLoops(); + if (myErrorStatus) { + return; + } + PerformAreas(); + if (myErrorStatus) { + return; + } + PerformInternalShapes(); + if (myErrorStatus) { + return; + } +} +//======================================================================= +//function :PerformShapesToAvoid +//purpose : +//======================================================================= + void BOPAlgo_BuilderSolid::PerformShapesToAvoid() +{ + Standard_Boolean bFound; + Standard_Integer i, iCnt, aNbE, aNbF; + TopAbs_Orientation aOrE; + BOPCol_IndexedDataMapOfShapeListOfShape aMEF; + BOPCol_ListIteratorOfListOfShape aIt; + // + myShapesToAvoid.Clear(); + // + iCnt=0; + while (1) { + ++iCnt; + bFound=Standard_False; + // + // 1. MEF + aMEF.Clear(); + aIt.Initialize (myShapes); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aF=aIt.Value(); + if (!myShapesToAvoid.Contains(aF)) { + BOPTools::MapShapesAndAncestors(aF, TopAbs_EDGE, TopAbs_FACE, aMEF); + } + else { + int a=0; + } + } + aNbE=aMEF.Extent(); + // + // 2. myFacesToAvoid + for (i=1; i<=aNbE; ++i) { + const TopoDS_Edge& aE=(*(TopoDS_Edge*)(&aMEF.FindKey(i))); + if (BRep_Tool::Degenerated(aE)) { + continue; + } + // + BOPCol_ListOfShape& aLF=aMEF.ChangeFromKey(aE); + aNbF=aLF.Extent(); + if (!aNbF) { + continue; + } + // + aOrE=aE.Orientation(); + // + const TopoDS_Face& aF1=(*(TopoDS_Face*)(&aLF.First())); + if (aNbF==1) { + if (aOrE==TopAbs_INTERNAL) { + continue; + } + bFound=Standard_True; + myShapesToAvoid.Add(aF1); + } + else if (aNbF==2) { + const TopoDS_Face& aF2=(*(TopoDS_Face*)(&aLF.Last())); + if (aF2.IsSame(aF1)) { + if (BRep_Tool::IsClosed(aE, aF1)) { + continue; + } + // + if (aOrE==TopAbs_INTERNAL) { + continue; + } + // + bFound=Standard_True; + myShapesToAvoid.Add(aF1); + myShapesToAvoid.Add(aF2); + } + } + }// for (i=1; i<=aNbE; ++i) { + // + if (!bFound) { + break; + } + // + }//while (1) +} +//======================================================================= +//function : PerformLoops +//purpose : +//======================================================================= + void BOPAlgo_BuilderSolid::PerformLoops() +{ + myErrorStatus=0; + // + myLoops.Clear(); + // + Standard_Integer aNbLF, aNbOff, aNbFP, aNbFA; + Standard_Integer i; + TopAbs_Orientation anOr; + TopoDS_Edge aEL; + BRep_Builder aBB; + TopoDS_Iterator aItS; + // + BOPCol_ListIteratorOfListOfShape aItF, aIt; + BOPCol_MapIteratorOfMapOfOrientedShape aItM; + BOPTools_CoupleOfShape aCSOff; + // + BOPCol_MapOfOrientedShape AddedFacesMap; + BOPCol_IndexedDataMapOfShapeListOfShape aEFMap, aMEFP; + // + //================================================= + // + // 1. Shells Usual + // + aItF.Initialize (myShapes); + for (; aItF.More(); aItF.Next()) { + const TopoDS_Shape& aFF = aItF.Value(); + BOPTools::MapShapesAndAncestors(aFF, TopAbs_EDGE, TopAbs_FACE, aEFMap); + } + // + aItF.Initialize (myShapes); + for (i=1; aItF.More(); aItF.Next(), ++i) { + const TopoDS_Shape& aFF = aItF.Value(); + if (myShapesToAvoid.Contains(aFF)) { + continue; + } + if (!AddedFacesMap.Add(aFF)) { + continue; + } + // + // make a new shell + TopoDS_Shell aShell; + aBB.MakeShell(aShell); + aBB.Add(aShell, aFF); + // + aMEFP.Clear(); + BOPTools::MapShapesAndAncestors(aFF, TopAbs_EDGE, TopAbs_FACE, aMEFP); + // + // loop on faces added to Shell; add their neighbor faces to Shell and so on + TopoDS_Iterator aItAddedF (aShell); + for (; aItAddedF.More(); aItAddedF.Next()) { + const TopoDS_Face& aF = (*(TopoDS_Face*)(&aItAddedF.Value())); + // + // loop on edges of aF; find a good neighbor face of aF by aE + TopExp_Explorer aEdgeExp(aF, TopAbs_EDGE); + for (; aEdgeExp.More(); aEdgeExp.Next()) { + const TopoDS_Edge& aE = (*(TopoDS_Edge*)(&aEdgeExp.Current())); + // + //1 + if (aMEFP.Contains(aE)) { + const BOPCol_ListOfShape& aLFP=aMEFP.FindFromKey(aE); + aNbFP=aLFP.Extent(); + if (aNbFP>1) { + continue; + } + } + //2 + anOr=aE.Orientation(); + if (anOr==TopAbs_INTERNAL) { + continue; + } + //3 + if (BRep_Tool::Degenerated(aE)) { + continue; + } + // + // candidate faces list + const BOPCol_ListOfShape& aLF=aEFMap.FindFromKey(aE); + aNbLF=aLF.Extent(); + if (!aNbLF) { + continue; + } + // + // try to select one of neighbors + // check if a face already added to Shell shares E + Standard_Boolean bFound; + BOPCol_ListIteratorOfListOfShape aItLF; + BOPTools_ListOfCoupleOfShape aLCSOff; + // + aItLF.Initialize(aLF); + for (; aItLF.More(); aItLF.Next()) { + const TopoDS_Face& aFL=(*(TopoDS_Face*)(&aItLF.Value())); + if (myShapesToAvoid.Contains(aFL)) { + continue; + } + if (aF.IsSame(aFL)) { + continue; + } + if (AddedFacesMap.Contains(aFL)){ + continue; + } + // + bFound=BOPTools_AlgoTools::GetEdgeOff(aE, aFL, aEL); + if (!bFound) { + continue; + } + // + aCSOff.SetShape1(aEL); + aCSOff.SetShape2(aFL); + aLCSOff.Append(aCSOff); + }//for (; aItLF.More(); aItLF.Next()) { + // + aNbOff=aLCSOff.Extent(); + if (!aNbOff){ + continue; + } + // + TopoDS_Face aSelF; + if (aNbOff==1) { + aSelF=(*(TopoDS_Face*)(&aLCSOff.First().Shape2())); + } + else if (aNbOff>1){ + BOPTools_AlgoTools::GetFaceOff(aE, aF, aLCSOff, aSelF); + } + // + if (!aSelF.IsNull() && AddedFacesMap.Add(aSelF)) { + aBB.Add(aShell, aSelF); + BOPTools::MapShapesAndAncestors(aSelF, TopAbs_EDGE, TopAbs_FACE, aMEFP); + } + } // for (; aEdgeExp.More(); aEdgeExp.Next()) { + } //for (; aItAddedF.More(); aItAddedF.Next()) { + // + if (IsClosedShell(aShell)) { + myLoops.Append(aShell); + } + } // for (; aItF.More(); aItF.Next()) { + + // + // Post Treatment + BOPCol_MapOfOrientedShape aMP; + // + // a. collect all edges that are in loops + aIt.Initialize (myLoops); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aS=aIt.Value(); + aItS.Initialize(aS); + for (; aItS.More(); aItS.Next()) { + const TopoDS_Shape& aF=aItS.Value(); + aMP.Add(aF); + } + } + // + // b. collect all edges that are to avoid + aItM.Initialize(myShapesToAvoid); + for (; aItM.More(); aItM.Next()) { + const TopoDS_Shape& aF=aItM.Key(); + aMP.Add(aF); + } + // + // c. add all edges that are not processed to myShapesToAvoid + aIt.Initialize (myShapes); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aF=aIt.Value(); + if (!aMP.Contains(aF)) { + myShapesToAvoid.Add(aF); + } + } + //================================================= + // + // 2.Internal Shells + // + myLoopsInternal.Clear(); + // + aEFMap.Clear(); + AddedFacesMap.Clear(); + // + aNbFA=myShapesToAvoid.Extent(); + // + aItM.Initialize(myShapesToAvoid); + for (; aItM.More(); aItM.Next()) { + const TopoDS_Shape& aFF=aItM.Key(); + BOPTools::MapShapesAndAncestors(aFF, TopAbs_EDGE, TopAbs_FACE, aEFMap); + } + // + aItM.Initialize(myShapesToAvoid); + for (; aItM.More(); aItM.Next()) { + const TopoDS_Shape& aFF=aItM.Key(); + if (!AddedFacesMap.Add(aFF)) { + continue; + } + // + // make a new shell + TopoDS_Shell aShell; + aBB.MakeShell(aShell); + aBB.Add(aShell, aFF); + // + TopoDS_Iterator aItAddedF (aShell); + for (; aItAddedF.More(); aItAddedF.Next()) { + const TopoDS_Face& aF = (*(TopoDS_Face*)(&aItAddedF.Value())); + // + TopExp_Explorer aEdgeExp(aF, TopAbs_EDGE); + for (; aEdgeExp.More(); aEdgeExp.Next()) { + const TopoDS_Edge& aE = (*(TopoDS_Edge*)(&aEdgeExp.Current())); + const BOPCol_ListOfShape& aLF=aEFMap.FindFromKey(aE); + aItF.Initialize(aLF); + for (; aItF.More(); aItF.Next()) { + const TopoDS_Face& aFL=(*(TopoDS_Face*)(&aItF.Value())); + if (AddedFacesMap.Add(aFL)){ + aBB.Add(aShell, aFL); + } + } + } + } + myLoopsInternal.Append(aShell); + } +} +//======================================================================= +//function : PerformAreas +//purpose : +//======================================================================= + void BOPAlgo_BuilderSolid::PerformAreas() +{ + myErrorStatus=0; + // + Standard_Boolean bIsGrowthShell, bIsHole; + BRep_Builder aBB; + TopoDS_Shape anInfinitePointShape; + BOPCol_DataMapIteratorOfDataMapOfShapeListOfShape aItMSH; + BOPCol_ListIteratorOfListOfShape aShellIt, aSolidIt; + // + BOPCol_ListOfShape aNewSolids, aHoleShells; + BOPCol_DataMapOfShapeShape aInOutMap; + BOPCol_DataMapOfShapeListOfShape aMSH; + BOPCol_IndexedMapOfShape aMHF; + // + myAreas.Clear(); + // + // Draft solids [aNewSolids] + aShellIt.Initialize(myLoops); + for ( ; aShellIt.More(); aShellIt.Next()) { + const TopoDS_Shape& aShell = aShellIt.Value(); + // + bIsGrowthShell=IsGrowthShell(aShell, aMHF); + if (bIsGrowthShell) { + // make a growth solid from a shell + TopoDS_Solid Solid; + aBB.MakeSolid(Solid); + aBB.Add (Solid, aShell); + // + aNewSolids.Append (Solid); + } + else{ + // check if a shell is a hole + //XX + bIsHole=IsHole(aShell, myContext); + //XX + if (bIsHole) { + aHoleShells.Append(aShell); + BOPTools::MapShapes(aShell, TopAbs_FACE, aMHF); + } + else { + // make a growth solid from a shell + TopoDS_Solid Solid; + aBB.MakeSolid(Solid); + aBB.Add (Solid, aShell); + // + aNewSolids.Append (Solid); + } + } + } + // + // 2. Find outer growth shell that is most close to each hole shell + aShellIt.Initialize(aHoleShells); + for (; aShellIt.More(); aShellIt.Next()) { + const TopoDS_Shape& aHole = aShellIt.Value(); + // + aSolidIt.Initialize(aNewSolids); + for ( ; aSolidIt.More(); aSolidIt.Next()) { + const TopoDS_Shape& aSolid = aSolidIt.Value(); + // + if (!IsInside(aHole, aSolid, myContext)){ + continue; + } + // + if ( aInOutMap.IsBound (aHole)){ + const TopoDS_Shape& aSolid2 = aInOutMap(aHole); + if (IsInside(aSolid, aSolid2, myContext)) { + aInOutMap.UnBind(aHole); + aInOutMap.Bind (aHole, aSolid); + } + } + else{ + aInOutMap.Bind (aHole, aSolid); + } + } + // + // Add aHole to a map Solid/ListOfHoles [aMSH] + if (aInOutMap.IsBound(aHole)){ + const TopoDS_Shape& aSolid=aInOutMap(aHole); + if (aMSH.IsBound(aSolid)) { + BOPCol_ListOfShape& aLH=aMSH.ChangeFind(aSolid); + aLH.Append(aHole); + } + else { + BOPCol_ListOfShape aLH; + aLH.Append(aHole); + aMSH.Bind(aSolid, aLH); + } + //aBB.Add (aSolid, aHole); + } + }// for (; aShellIt.More(); aShellIt.Next()) { + // + // 3. Add aHoles to Solids + aItMSH.Initialize(aMSH); + for (; aItMSH.More(); aItMSH.Next()) { + TopoDS_Solid aSolid=(*(TopoDS_Solid*)(&aItMSH.Key())); + // + const BOPCol_ListOfShape& aLH=aItMSH.Value(); + aShellIt.Initialize(aLH); + for (; aShellIt.More(); aShellIt.Next()) { + const TopoDS_Shape& aHole = aShellIt.Value(); + aBB.Add (aSolid, aHole); + } + // + // update classifier + BRepClass3d_SolidClassifier& aSC=myContext->SolidClassifier(aSolid); + aSC.Load(aSolid); + // + } + // + // These aNewSolids are draft solids that + // do not contain any internal shapes + // + aShellIt.Initialize(aNewSolids); + for ( ; aShellIt.More(); aShellIt.Next()) { + const TopoDS_Shape& aSx = aShellIt.Value(); + myAreas.Append(aSx); + } + + //modified by NIZHNY-EMV Tue Apr 24 09:20:09 2012 + // Add holes that outside the solids to myAreas + aShellIt.Initialize(aHoleShells); + for (; aShellIt.More(); aShellIt.Next()) { + const TopoDS_Shape& aHole = aShellIt.Value(); + if (!aInOutMap.IsBound(aHole)){ + TopoDS_Solid aSolid; + aBB.MakeSolid(aSolid); + aBB.Add (aSolid, aHole); + // + myAreas.Append(aSolid); + } + } + //modified by NIZHNY-EMV Tue Apr 24 09:20:11 2012 +} +//======================================================================= +//function : PerformInternalShapes +//purpose : +//======================================================================= + void BOPAlgo_BuilderSolid::PerformInternalShapes() +{ + myErrorStatus=0; + // + Standard_Integer aNbFI=myLoopsInternal.Extent(); + if (!aNbFI) {// nothing to do + return; + } + // + BRep_Builder aBB; + TopoDS_Iterator aIt; + BOPCol_ListIteratorOfListOfShape aShellIt, aSolidIt; + BOPCol_MapIteratorOfMapOfShape aItMF; + // + BOPCol_MapOfShape aMF, aMFP, aMFx; + BOPCol_IndexedDataMapOfShapeListOfShape aMEF; + BOPCol_ListOfShape aLSI; + // + // 1. All internal faces + aShellIt.Initialize(myLoopsInternal); + for (; aShellIt.More(); aShellIt.Next()) { + const TopoDS_Shape& aShell=aShellIt.Value(); + aIt.Initialize(aShell); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aF=aIt.Value(); + aMF.Add(aF); + } + } + aNbFI=aMF.Extent(); + // + // 2 Process solids + aSolidIt.Initialize(myAreas); + for ( ; aSolidIt.More(); aSolidIt.Next()) { + TopoDS_Solid& aSolid=(*(TopoDS_Solid*)(&aSolidIt.Value())); + // + //modified by NIZHNY-EMV Fri Oct 07 12:06:37 2011 + TopExp_Explorer anExpSol(aSolid, TopAbs_FACE);; + for (; anExpSol.More(); anExpSol.Next()) { + const TopoDS_Shape& aF = anExpSol.Current(); + TopoDS_Shape aFF=aF; + // + aFF.Orientation(TopAbs_FORWARD); + aMFx.Add(aFF); + aFF.Orientation(TopAbs_REVERSED); + aMFx.Add(aFF); + } + //modified by NIZHNY-EMV Fri Oct 07 12:06:40 2011 + aMEF.Clear(); + BOPTools::MapShapesAndAncestors(aSolid, TopAbs_EDGE, TopAbs_FACE, aMEF); + // + // 2.1 Separate faces to process aMFP + aMFP.Clear(); + aItMF.Initialize(aMF); + //modified by NIZHNY-EMV Fri Oct 07 11:43:20 2011 + for (; aItMF.More(); aItMF.Next()) { + const TopoDS_Face& aF=(*(TopoDS_Face*)(&aItMF.Key())); + if (!aMFx.Contains(aF)) { + if (BOPTools_AlgoTools::IsInternalFace(aF, aSolid, aMEF, 1.e-14, myContext)) { + aMFP.Add(aF); + } + } + } + aMFx.Clear(); + //modified by NIZHNY-EMV Fri Oct 07 11:43:22 2011 + // + // 2.2 Make Internal Shells + aLSI.Clear(); + MakeInternalShells(aMFP, aLSI); + // + // 2.3 Add them to aSolid + aShellIt.Initialize(aLSI); + for (; aShellIt.More(); aShellIt.Next()) { + const TopoDS_Shape& aSI=aShellIt.Value(); + aBB.Add (aSolid, aSI); + } + // + // 2.4 Remove faces aMFP from aMF + aItMF.Initialize(aMFP); + for (; aItMF.More(); aItMF.Next()) { + const TopoDS_Shape& aF=aItMF.Key(); + aMF.Remove(aF); + } + // + aNbFI=aMF.Extent(); + if (!aNbFI) { + break; + } + } //for ( ; aSolidIt.More(); aSolidIt.Next()) { + //modified by NIZHNY-EMV Fri Oct 07 11:53:56 2011 + if (aNbFI) { + TopoDS_Solid aSolid; + aBB.MakeSolid(aSolid); + // + MakeInternalShells(aMF, aLSI); + aShellIt.Initialize(aLSI); + for (; aShellIt.More(); aShellIt.Next()) { + const TopoDS_Shape& aSI=aShellIt.Value(); + aBB.Add (aSolid, aSI); + } + myAreas.Append(aSolid); + } + //modified by NIZHNY-EMV Fri Oct 07 11:53:58 2011 +} + +//======================================================================= +//function : MakeInternalShells +//purpose : +//======================================================================= +void MakeInternalShells(const BOPCol_MapOfShape& theMF, + BOPCol_ListOfShape& theShells) +{ + BOPCol_ListIteratorOfListOfShape aItF; + BRep_Builder aBB; + // + BOPCol_IndexedDataMapOfShapeListOfShape aMEF; + BOPCol_MapIteratorOfMapOfShape aItM; + BOPCol_MapOfShape aAddedFacesMap; + // + aItM.Initialize(theMF); + for (; aItM.More(); aItM.Next()) { + const TopoDS_Shape& aF=aItM.Key(); + BOPTools::MapShapesAndAncestors(aF, TopAbs_EDGE, TopAbs_FACE, aMEF); + } + // + aItM.Initialize(theMF); + for (; aItM.More(); aItM.Next()) { + TopoDS_Shape aFF=aItM.Key(); + if (!aAddedFacesMap.Add(aFF)) { + continue; + } + // + // make a new shell + TopoDS_Shell aShell; + aBB.MakeShell(aShell); + aFF.Orientation(TopAbs_INTERNAL); + aBB.Add(aShell, aFF); + // + TopoDS_Iterator aItAddedF (aShell); + for (; aItAddedF.More(); aItAddedF.Next()) { + const TopoDS_Shape& aF =aItAddedF.Value(); + // + TopExp_Explorer aEdgeExp(aF, TopAbs_EDGE); + for (; aEdgeExp.More(); aEdgeExp.Next()) { + const TopoDS_Shape& aE =aEdgeExp.Current(); + const BOPCol_ListOfShape& aLF=aMEF.FindFromKey(aE); + aItF.Initialize(aLF); + for (; aItF.More(); aItF.Next()) { + TopoDS_Shape aFL=aItF.Value(); + if (aAddedFacesMap.Add(aFL)){ + aFL.Orientation(TopAbs_INTERNAL); + aBB.Add(aShell, aFL); + } + } + } + } + theShells.Append(aShell); + } +} +//======================================================================= +//function : IsHole +//purpose : +//======================================================================= +Standard_Boolean IsHole(const TopoDS_Shape& theS2, + Handle(BOPInt_Context)& theContext) +{ + TopoDS_Solid *pS2=(TopoDS_Solid *)&theS2; + BRepClass3d_SolidClassifier& aClsf=theContext->SolidClassifier(*pS2); + // + aClsf.PerformInfinitePoint(::RealSmall()); + // + return (aClsf.State()==TopAbs_IN); +} +//======================================================================= +//function : IsInside +//purpose : +//======================================================================= +Standard_Boolean IsInside(const TopoDS_Shape& theS1, + const TopoDS_Shape& theS2, + Handle(BOPInt_Context)& theContext) +{ + TopExp_Explorer aExp; + TopAbs_State aState; + // + TopoDS_Solid *pS2=(TopoDS_Solid *)&theS2; + // + aExp.Init(theS1, TopAbs_FACE); + if (!aExp.More()){ + BRepClass3d_SolidClassifier& aClsf=theContext->SolidClassifier(*pS2); + aClsf.PerformInfinitePoint(::RealSmall()); + aState=aClsf.State(); + } + else { + BOPCol_IndexedMapOfShape aBounds; + BOPTools::MapShapes(*pS2, TopAbs_EDGE, aBounds); + const TopoDS_Face& aF = (*(TopoDS_Face*)(&aExp.Current())); + aState=BOPTools_AlgoTools::ComputeState(aF, *pS2, 1.e-14, aBounds, theContext); + } + return (aState==TopAbs_IN); +} +//======================================================================= +//function : IsGrowthShell +//purpose : +//======================================================================= +Standard_Boolean IsGrowthShell(const TopoDS_Shape& theShell, + const BOPCol_IndexedMapOfShape& theMHF) +{ + Standard_Boolean bRet; + TopoDS_Iterator aIt; + // + bRet=Standard_False; + if (theMHF.Extent()) { + aIt.Initialize(theShell); + for(; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aF=aIt.Value(); + if (theMHF.Contains(aF)) { + return !bRet; + } + } + } + return bRet; +} +//======================================================================= +//function : IsClosedShell +//purpose : +//======================================================================= +Standard_Boolean IsClosedShell(const TopoDS_Shell& theShell) +{ + Standard_Integer aNbE; + Standard_Boolean bRet; + TopoDS_Iterator aIt; + TopExp_Explorer aExp; + // + BOPCol_MapOfShape aM; + // + bRet=Standard_False; + aIt.Initialize(theShell); + for(; aIt.More(); aIt.Next()) { + const TopoDS_Face& aF=(*(TopoDS_Face*)(&aIt.Value())); + aExp.Init(aF, TopAbs_EDGE); + for (; aExp.More(); aExp.Next()) { + const TopoDS_Edge& aE=(*(TopoDS_Edge*)(&aExp.Current())); + if (BRep_Tool::Degenerated(aE)) { + continue; + } + // + if (aE.Orientation()==TopAbs_INTERNAL) { + continue; + } + if (!aM.Add(aE)) { + aM.Remove(aE); + } + } + } + // + aNbE=aM.Extent(); + if (!aNbE) { + bRet=!bRet; + } + return bRet; +} diff --git a/src/BOPAlgo/BOPAlgo_Builder_1.cxx b/src/BOPAlgo/BOPAlgo_Builder_1.cxx new file mode 100644 index 0000000000..6394a3b75f --- /dev/null +++ b/src/BOPAlgo/BOPAlgo_Builder_1.cxx @@ -0,0 +1,311 @@ +// Created by: Peter KURNEV +// Copyright (c) 2010-2012 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 +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#include + +#include +#include +#include +#include + + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +//======================================================================= +//function : FillImagesVertices +//purpose : +//======================================================================= + void BOPAlgo_Builder::FillImagesVertices() +{ + myErrorStatus=0; + // + Standard_Integer nV, nVSD; + BOPCol_DataMapIteratorOfDataMapOfIntegerInteger aIt; + // + const BOPCol_DataMapOfIntegerInteger& aMSDV=myDS->ShapesSD(); + aIt.Initialize(aMSDV); + for (; aIt.More(); aIt.Next()) { + nV=aIt.Key(); + nVSD=aIt.Value(); + const TopoDS_Shape& aV=myDS->Shape(nV); + const TopoDS_Shape& aVSD=myDS->Shape(nVSD); + // + BOPCol_ListOfShape aLVSD(myAllocator); + // + aLVSD.Append(aVSD); + myImages.Bind(aV, aLVSD); + // + myShapesSD.Bind(aV, aVSD); + } +} +//======================================================================= +//function : FillImagesEdges +//purpose : +//======================================================================= + void BOPAlgo_Builder::FillImagesEdges() +{ + myErrorStatus=0; + // + Standard_Integer i, aNbPBP, nE, nSp, nSpR; + BOPDS_ListIteratorOfListOfPaveBlock aItPB; + // + const BOPDS_VectorOfListOfPaveBlock& aPBP=myDS->PaveBlocksPool(); + aNbPBP=aPBP.Extent(); + for (i=0; iOriginalEdge(); + const TopoDS_Shape& aE=myDS->Shape(nE); + // + aItPB.Initialize(aLPB); + for (; aItPB.More(); aItPB.Next()) { + const Handle(BOPDS_PaveBlock)& aPB=aItPB.Value(); + const Handle(BOPDS_PaveBlock)& aPBR=aPB->RealPaveBlock(); + // + nSpR=aPBR->Edge(); + const TopoDS_Shape& aSpR=myDS->Shape(nSpR); + aLS.Append(aSpR); + myOrigins.Bind(aSpR, aE); + // + if (aPB->IsCommonBlockOnEdge()) { + nSp=aPB->Edge(); + const TopoDS_Shape& aSp=myDS->Shape(nSp); + myShapesSD.Bind(aSp, aSpR); + } + } + myImages.Bind(aE, aLS); + } + } +} +//======================================================================= +// function: IsInterferred +// purpose: +//======================================================================= + Standard_Boolean BOPAlgo_Builder::IsInterferred(const TopoDS_Shape& theS)const +{ + Standard_Boolean bInterferred; + TopoDS_Iterator aIt; + // + bInterferred=Standard_False; + aIt.Initialize(theS); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aSx=aIt.Value(); + if (myImages.IsBound(aSx)) { + bInterferred=!bInterferred; + break; + } + } + return bInterferred; +} +//======================================================================= +//function : BuildResult +//purpose : +//======================================================================= + void BOPAlgo_Builder::BuildResult(const TopAbs_ShapeEnum theType) +{ + myErrorStatus=0; + // + TopAbs_ShapeEnum aType; + BRep_Builder aBB; + BOPCol_MapOfShape aM; + BOPCol_ListIteratorOfListOfShape aIt, aItIm; + // + aIt.Initialize(myArguments); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aS=aIt.Value(); + aType=aS.ShapeType(); + if (aType==theType) { + if (myImages.IsBound(aS)){ + const BOPCol_ListOfShape& aLSIm=myImages.Find(aS); + aItIm.Initialize(aLSIm); + for (; aItIm.More(); aItIm.Next()) { + const TopoDS_Shape& aSIm=aItIm.Value(); + if (aM.Add(aSIm)) { + aBB.Add(myShape, aSIm); + } + } + } + else { + if (aM.Add(aS)) { + aBB.Add(myShape, aS); + } + } + } + } +} +//======================================================================= +// function: FillImagesContainers +// purpose: +//======================================================================= + void BOPAlgo_Builder::FillImagesContainers(const TopAbs_ShapeEnum theType) +{ + myErrorStatus=0; + // + Standard_Integer i, aNbS; + BOPCol_MapOfShape aMFP(100, myAllocator); + // + aNbS=myDS->NbSourceShapes(); + for (i=0; iShapeInfo(i); + if (aSI.ShapeType()==theType) { + const TopoDS_Shape& aC=aSI.Shape(); + FillImagesContainer(aC, theType); + } + }// for (; aItS.More(); aItS.Next()) { +} +//======================================================================= +// function: FillImagesCompounds +// purpose: +//======================================================================= + void BOPAlgo_Builder::FillImagesCompounds() +{ + myErrorStatus=0; + // + Standard_Integer i, aNbS; + BOPCol_MapOfShape aMFP(100, myAllocator); + // + aNbS=myDS->NbSourceShapes(); + for (i=0; iShapeInfo(i); + if (aSI.ShapeType()==TopAbs_COMPOUND) { + const TopoDS_Shape& aC=aSI.Shape(); + FillImagesCompound(aC, aMFP); + } + }// for (; aItS.More(); aItS.Next()) { +} +//======================================================================= +//function : FillImagesContainer +//purpose : +//======================================================================= + void BOPAlgo_Builder::FillImagesContainer(const TopoDS_Shape& theS, + const TopAbs_ShapeEnum theType) +{ + Standard_Boolean bInterferred, bToReverse; + TopoDS_Iterator aIt; + BRep_Builder aBB; + BOPCol_ListIteratorOfListOfShape aItIm; + // + bInterferred=IsInterferred(theS); + if (!bInterferred){ + return; + } + // + TopoDS_Shape aCIm; + BOPTools_AlgoTools::MakeContainer(theType, aCIm); + // + aIt.Initialize(theS); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aSx=aIt.Value(); + if (myImages.IsBound(aSx)) { + const BOPCol_ListOfShape& aLFIm=myImages.Find(aSx); + aItIm.Initialize(aLFIm); + for (; aItIm.More(); aItIm.Next()) { + TopoDS_Shape aSxIm=aItIm.Value(); + // + //modified by NIZNHY-PKV Thu Apr 30 07:52:10 2009f + bToReverse=BOPTools_AlgoTools::IsSplitToReverse(aSxIm, aSx, myContext); + if (bToReverse) { + aSxIm.Reverse(); + } + //modified by NIZNHY-PKV Thu Apr 30 07:52:14 2009t + aBB.Add(aCIm, aSxIm); + } + } + else { + aBB.Add(aCIm, aSx); + } + } + // + BOPCol_ListOfShape aLSIm(myAllocator); + aLSIm.Append(aCIm); + myImages.Bind(theS, aLSIm); +} +//======================================================================= +//function : FillImagesCompound +//purpose : +//======================================================================= + void BOPAlgo_Builder::FillImagesCompound(const TopoDS_Shape& theS, + BOPCol_MapOfShape& theMFP) +{ + Standard_Boolean bInterferred; + TopAbs_Orientation aOrX; + TopoDS_Iterator aIt; + BRep_Builder aBB; + BOPCol_ListIteratorOfListOfShape aItIm; + // + if (!theMFP.Add(theS)) { + return; + } + // + bInterferred=Standard_False; + aIt.Initialize(theS); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aSx=aIt.Value(); + if (aSx.ShapeType()==TopAbs_COMPOUND) { + FillImagesCompound(aSx, theMFP); + } + if (myImages.IsBound(aSx)) { + bInterferred=Standard_True; + } + } + if (!bInterferred){ + return; + } + // + TopoDS_Shape aCIm; + BOPTools_AlgoTools::MakeContainer(TopAbs_COMPOUND, aCIm); + // + aIt.Initialize(theS); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aSX=aIt.Value(); + aOrX=aSX.Orientation(); + if (myImages.IsBound(aSX)) { + const BOPCol_ListOfShape& aLFIm=myImages.Find(aSX); + aItIm.Initialize(aLFIm); + for (; aItIm.More(); aItIm.Next()) { + TopoDS_Shape aSXIm=aItIm.Value(); + aSXIm.Orientation(aOrX); + aBB.Add(aCIm, aSXIm); + } + } + else { + aBB.Add(aCIm, aSX); + } + } + // + BOPCol_ListOfShape aLSIm(myAllocator); + aLSIm.Append(aCIm); + myImages.Bind(theS, aLSIm); +} diff --git a/src/BOPAlgo/BOPAlgo_Builder_2.cxx b/src/BOPAlgo/BOPAlgo_Builder_2.cxx new file mode 100644 index 0000000000..cc9814dba3 --- /dev/null +++ b/src/BOPAlgo/BOPAlgo_Builder_2.cxx @@ -0,0 +1,734 @@ +// Created by: Peter KURNEV +// Copyright (c) 2010-2012 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 +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + +#include + +#include + +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +static + Standard_Boolean HasPaveBlocksOnIn(const BOPDS_FaceInfo& aFI1, + const BOPDS_FaceInfo& aFI2); +static + void FillMap(const TopoDS_Shape& aS1, + const TopoDS_Shape& aS2, + BOPCol_DataMapOfShapeListOfShape& aDMSLS, + Handle(NCollection_IncAllocator)& aAllocator); +static + void MakeBlocksCnx(const BOPCol_DataMapOfShapeListOfShape& aMILI, + BOPCol_DataMapOfIntegerListOfShape& aMBlocks, + Handle(NCollection_IncAllocator)& aAllocator); + +//======================================================================= +//function : FillImagesFaces +//purpose : +//======================================================================= + void BOPAlgo_Builder::FillImagesFaces() +{ + myErrorStatus=0; + // + BuildSplitFaces(); + FillSameDomainFaces(); + //modified by NIZNHY-PKV Thu Jul 08 07:20:41 2010f + FillImagesFaces1(); + //modified by NIZNHY-PKV Thu Jul 08 07:20:44 2010t +} +//======================================================================= +//function : BuildSplitFaces +//purpose : +//======================================================================= + void BOPAlgo_Builder::BuildSplitFaces() +{ + Standard_Boolean bHasFaceInfo, bIsClosed, bIsDegenerated, bToReverse; + Standard_Integer i, aNbS, aNbPBIn, aNbPBOn, aNbPBSc, aNbAV, nSp; + TopoDS_Face aFF, aFSD; + TopoDS_Edge aSp, aEE; + TopAbs_Orientation anOriF, anOriE; + TopExp_Explorer aExp; + BOPCol_ListIteratorOfListOfShape aIt; + BOPDS_MapIteratorOfMapOfPaveBlock aItMPB; + BOPCol_ListOfInteger aLIAV; + BOPCol_MapOfShape aMFence; + Handle(NCollection_IncAllocator) aAllocator; + BOPCol_ListOfShape aLFIm(myAllocator); + BOPCol_MapIteratorOfMapOfShape aItMS; + // + myErrorStatus=0; + // + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~scope f + aAllocator=new NCollection_IncAllocator(); + // + BOPCol_ListOfShape aLE(aAllocator); + BOPCol_MapOfShape aMDE(100, aAllocator); + // + aNbS=myDS->NbSourceShapes(); + for (i=0; iShapeInfo(i); + if (aSI.ShapeType()!=TopAbs_FACE) { + continue; + } + // + const TopoDS_Face& aF=(*(TopoDS_Face*)(&aSI.Shape())); + // + bHasFaceInfo=myDS->HasFaceInfo(i); + if(!bHasFaceInfo) { + continue; + } + // + // aLFIm will contain images of aF + aLFIm.Clear(); + // + const BOPDS_FaceInfo& aFI=myDS->FaceInfo(i); + // + const BOPDS_MapOfPaveBlock& aMPBIn=aFI.PaveBlocksIn(); + const BOPDS_MapOfPaveBlock& aMPBOn=aFI.PaveBlocksOn(); + const BOPDS_MapOfPaveBlock& aMPBSc=aFI.PaveBlocksSc(); + aLIAV.Clear(); + myDS->AloneVertices(i, aLIAV); + + aNbPBIn=aMPBIn.Extent(); + aNbPBOn=aMPBOn.Extent(); + aNbPBSc=aMPBSc.Extent(); + aNbAV=aLIAV.Extent(); + if (!aNbPBIn && !aNbPBOn && !aNbPBSc && !aNbAV) { // not compete + continue; + } + // + aMFence.Clear(); + // + anOriF=aF.Orientation(); + aFF=aF; + aFF.Orientation(TopAbs_FORWARD); + // + + // + // 1. Fill the egdes set for the face aFF -> LE + aLE.Clear(); + // + // + // 1.1 Bounding edges + aExp.Init(aFF, TopAbs_EDGE); + for (; aExp.More(); aExp.Next()) { + const TopoDS_Edge& aE=(*(TopoDS_Edge*)(&aExp.Current())); + anOriE=aE.Orientation(); + bIsDegenerated=BRep_Tool::Degenerated(aE); + bIsClosed=BRep_Tool::IsClosed(aE, aF); + // + if (!myImages.IsBound(aE)) { + if (anOriE==TopAbs_INTERNAL) { + aEE=aE; + aEE.Orientation(TopAbs_FORWARD); + aLE.Append(aEE); + aEE.Orientation(TopAbs_REVERSED); + aLE.Append(aEE); + } + else { + aLE.Append(aE); + } + } + else {//else 1 + const BOPCol_ListOfShape& aLIE=myImages.Find(aE); + aIt.Initialize(aLIE); + for (; aIt.More(); aIt.Next()) { + aSp=(*(TopoDS_Edge*)(&aIt.Value())); + if (bIsDegenerated) { + aSp.Orientation(anOriE); + aLE.Append(aSp); + continue; + } + // + if (anOriE==TopAbs_INTERNAL) { + aSp.Orientation(TopAbs_FORWARD); + aLE.Append(aSp); + aSp.Orientation(TopAbs_REVERSED); + aLE.Append(aSp); + continue; + } + // + if (bIsClosed) { + if (aMFence.Add(aSp)) { + if (!BRep_Tool::IsClosed(aSp, aF)){ + BOPTools_AlgoTools3D::DoSplitSEAMOnFace(aSp, aF); + } + // + aSp.Orientation(TopAbs_FORWARD); + aLE.Append(aSp); + aSp.Orientation(TopAbs_REVERSED); + aLE.Append(aSp); + }// if (aMFence.Add(aSp)) + continue; + }// if (bIsClosed){ + // + aSp.Orientation(anOriE); + bToReverse=BOPTools_AlgoTools::IsSplitToReverse(aSp, aE, myContext); + if (bToReverse) { + aSp.Reverse(); + } + aLE.Append(aSp); + }// for (; aIt.More(); aIt.Next()) { + }// else 1 + }// for (; aExp.More(); aExp.Next()) { + // + // + // 1.2 In edges + aItMPB.Initialize(aMPBIn); + for (; aItMPB.More(); aItMPB.Next()) { + const Handle(BOPDS_PaveBlock)& aPB=aItMPB.Value(); + nSp=aPB->Edge(); + aSp=(*(TopoDS_Edge*)(&myDS->Shape(nSp))); + // + aSp.Orientation(TopAbs_FORWARD); + aLE.Append(aSp); + aSp.Orientation(TopAbs_REVERSED); + aLE.Append(aSp); + } + // + // + // 1.3 Section edges + aItMPB.Initialize(aMPBSc); + for (; aItMPB.More(); aItMPB.Next()) { + const Handle(BOPDS_PaveBlock)& aPB=aItMPB.Value(); + nSp=aPB->Edge(); + aSp=(*(TopoDS_Edge*)(&myDS->Shape(nSp))); + // + aSp.Orientation(TopAbs_FORWARD); + aLE.Append(aSp); + aSp.Orientation(TopAbs_REVERSED); + aLE.Append(aSp); + } + // + // 3 Build split faces + BOPAlgo_BuilderFace aBF(aAllocator); + // + aBF.SetFace(aFF); + aBF.SetContext(myContext); + // + // <-DEB ft + // + aBF.SetShapes(aLE); + // + aBF.Perform(); + // + const BOPCol_ListOfShape& aLFR=aBF.Areas(); + aIt.Initialize(aLFR); + for (; aIt.More(); aIt.Next()) { + TopoDS_Shape& aFR=aIt.ChangeValue(); + //modified by NIZNHY-PKV Wed Jun 10 13:25:24 2009f + if (anOriF==TopAbs_REVERSED) { + aFR.Orientation(TopAbs_REVERSED); + } + //aFR.Orientation(anOriF); + //modified by NIZNHY-PKV Wed Jun 10 13:25:33 2009t + aLFIm.Append(aFR); + //modified by NIZHNY-EMV Fri Sep 02 09:56:23 2011 + myOrigins.Bind(aFR, aF); + //modified by NIZHNY-EMV Fri Sep 02 09:56:25 2011 + } + // + mySplits.Bind(aF, aLFIm); + }// for (i=0; iInterfFF(); + // + aNbFFs=aFFs.Extent(); + if (!aNbFFs) { + return; + } + //-----------------------------------------------------scope f + aAllocator=new NCollection_IncAllocator(); + BOPCol_DataMapOfShapeListOfShape aDMSLS(100, aAllocator); + BOPCol_DataMapOfIntegerListOfShape aMBlocks(100, aAllocator); + BOPTools_DataMapOfShapeSet aMSST(100, aAllocator); + // + BOPCol_ListOfShape aLFIm; + // + for (i=0; iHasFaceInfo(nF1) || !myDS->HasFaceInfo(nF2) ) { + continue; + } + // + const BOPDS_FaceInfo& aFI1=myDS->FaceInfo(nF1); + const BOPDS_FaceInfo& aFI2=myDS->FaceInfo(nF2); + bFlag=HasPaveBlocksOnIn(aFI1, aFI2); + if (!bFlag) { + continue; + } + // + const TopoDS_Face& aF1=(*(TopoDS_Face*)(&myDS->Shape(nF1))); + const TopoDS_Face& aF2=(*(TopoDS_Face*)(&myDS->Shape(nF2))); + bFlag=mySplits.IsBound(aF1) && mySplits.IsBound(aF2); + if (!bFlag) { + continue; + } + // + const BOPCol_ListOfShape& aLF1=mySplits.Find(aF1); + const BOPCol_ListOfShape& aLF2=mySplits.Find(aF2); + // + aItF1.Initialize(aLF1); + for (; aItF1.More(); aItF1.Next()) { + const TopoDS_Face& aF1x=(*(TopoDS_Face*)(&aItF1.Value())); + if (!aMSST.IsBound(aF1x)) { + BOPTools_Set aST1(aAllocator); + // + aMSST.Bind(aF1x, aST1); + BOPTools_Set& aST=aMSST.ChangeFind(aF1x); + aST.AddEdges(aF1x); + } + // + aItF2.Initialize(aLF2); + for (; aItF2.More(); aItF2.Next()) { + const TopoDS_Face& aF2y=(*(TopoDS_Face*)(&aItF2.Value())); + if (!aMSST.IsBound(aF2y)) { + BOPTools_Set aST2(aAllocator); + // + aMSST.Bind(aF2y, aST2); + BOPTools_Set& aST=aMSST.ChangeFind(aF2y); + aST.AddEdges(aF2y); + } + // + const BOPTools_Set& aST1=aMSST.Find(aF1x); + const BOPTools_Set& aST2=aMSST.Find(aF2y); + // + if (aST1.IsEqual(aST2)) { + bFlag=BOPTools_AlgoTools::AreFacesSameDomain(aF1x, aF2y, myContext); + if (bFlag) { + FillMap(aF1x, aF2y, aDMSLS, aAllocator); + } + } + } + } + } // for (i=0; i aMSDF + aItBlocks.Initialize(aMBlocks); + for (; aItBlocks.More(); aItBlocks.Next()) { + const BOPCol_ListOfShape& aLSD=aItBlocks.Value(); + if (aLSD.Extent()) { + const TopoDS_Shape& aFSD1=aLSD.First(); + aItLS.Initialize(aLSD); + for (; aItLS.More(); aItLS.Next()) { + const TopoDS_Shape& aFSD=aItLS.Value(); + myShapesSD.Bind(aFSD, aFSD1); + } + } + } + //modified by NIZNHY-PKV Thu Jul 08 07:17:23 2010f + /* + // + // 4. Fill Images faces + BOPCol_ListOfInteger aLIAV; + // + aNbS=myDS->NbSourceShapes(); + for (i=0; iShapeInfo(i); + if (aSI.ShapeType()!=TopAbs_FACE) { + continue; + } + // + const TopoDS_Face& aF=(*(TopoDS_Face*)(&aSI.Shape())); + // + if (!mySplits.IsBound(aF)) { + continue; + } + // + aLIAV.Clear(); + myDS->AloneVertices(i, aLIAV); + aLFIm.Clear(); + // + const BOPCol_ListOfShape& aLSp=mySplits.Find(aF); + aItLS.Initialize(aLSp); + for (; aItLS.More(); aItLS.Next()) { + const TopoDS_Face& aFSp=(*(TopoDS_Face*)(&aItLS.Value())); + if (!myShapesSD.IsBound(aFSp)) { + aLFIm.Append(aFSp); + } + else { + TopoDS_Face aFSD; + // + aFSD=(*(TopoDS_Face*)(&myShapesSD.Find(aFSp))); + iSense=BOPTools_AlgoTools::Sense(aFSp, aFSD); + if (iSense<0) { + aFSD.Reverse(); + } + aLFIm.Append(aFSD); + } + } + // + FillInternalVertices(aLFIm, aLIAV); + // + myImages.Bind(aF, aLFIm); + }// for (i=0; iNbSourceShapes(); + for (i=0; iShapeInfo(i); + if (aSI.ShapeType()!=TopAbs_FACE) { + continue; + } + // + const TopoDS_Face& aF=(*(TopoDS_Face*)(&aSI.Shape())); + // + if (!mySplits.IsBound(aF)) { + continue; + } + // + aLIAV.Clear(); + myDS->AloneVertices(i, aLIAV); + aLFIm.Clear(); + // + const BOPCol_ListOfShape& aLSp=mySplits.Find(aF); + aItLS.Initialize(aLSp); + for (; aItLS.More(); aItLS.Next()) { + const TopoDS_Face& aFSp=(*(TopoDS_Face*)(&aItLS.Value())); + if (!myShapesSD.IsBound(aFSp)) { + aLFIm.Append(aFSp); + } + else { + aFSD=(*(TopoDS_Face*)(&myShapesSD.Find(aFSp))); + iSense=BOPTools_AlgoTools::Sense(aFSp, aFSD); + if (iSense<0) { + aFSD.Reverse(); + } + aLFIm.Append(aFSD); + } + } + // + FillInternalVertices(aLFIm, aLIAV); + // + myImages.Bind(aF, aLFIm); + }// for (i=0; iShape(nV))); + aV.Orientation(TopAbs_INTERNAL); + // + aItF.Initialize(aLFIm); + for (; aItF.More(); aItF.Next()) { + TopoDS_Face& aF=(*(TopoDS_Face*)(&aItF.Value())); + iFlag=myContext->ComputeVF(aV, aF, aU1, aU2); + if (!iFlag) { + aBB.Add(aF, aV); + break; + } + } + } +} +//======================================================================= +//function : MakeBlocksCnx +//purpose : +//======================================================================= +void MakeBlocksCnx(const BOPCol_DataMapOfShapeListOfShape& aMILI, + BOPCol_DataMapOfIntegerListOfShape& aMBlocks, + Handle(NCollection_IncAllocator)& aAllocator) +{ + Standard_Integer aNbV, aNbVS, aNbVP, k; + BOPCol_DataMapIteratorOfDataMapOfShapeListOfShape aItMILI; + BOPCol_MapIteratorOfMapOfShape aItMVP; + BOPCol_ListIteratorOfListOfShape aItLI; + // + BOPCol_MapOfShape aMVS(100, aAllocator); + BOPCol_MapOfShape aMEC(100, aAllocator); + BOPCol_MapOfShape aMVP(100, aAllocator); + BOPCol_MapOfShape aMVAdd(100, aAllocator); + // + aNbV=aMILI.Extent(); + // + aItMILI.Initialize(aMILI); + for (k=0; aItMILI.More(); aItMILI.Next()) { + aNbVS=aMVS.Extent(); + if (aNbVS==aNbV) { + break; + } + // + const TopoDS_Shape& nV=aItMILI.Key(); + if (aMVS.Contains(nV)){ + continue; + } + aMVS.Add(nV); + // + aMEC.Clear(); + aMVP.Clear(); + aMVAdd.Clear(); + // + aMVP.Add(nV); + while(1) { + aNbVP=aMVP.Extent(); + aItMVP.Initialize(aMVP); + for (; aItMVP.More(); aItMVP.Next()) { + const TopoDS_Shape& nVP=aItMVP.Value(); + const BOPCol_ListOfShape& aLV=aMILI.Find(nVP); + aItLI.Initialize(aLV); + for (; aItLI.More(); aItLI.Next()) { + const TopoDS_Shape& nVx=aItLI.Value(); + if (aMEC.Contains(nVx)) { + continue; + } + // + aMVS.Add(nVx); + aMEC.Add(nVx); + aMVAdd.Add(nVx); + } + } + // + aNbVP=aMVAdd.Extent(); + if (!aNbVP) { + break; // from while(1) + } + // + aMVP.Clear(); + aItMVP.Initialize(aMVAdd); + for (; aItMVP.More(); aItMVP.Next()) { + aMVP.Add(aItMVP.Value()); + } + aMVAdd.Clear(); + }//while(1) { + // + BOPCol_ListOfShape aLIx(aAllocator); + // + //aLIx.Append(nV); + aItMVP.Initialize(aMEC); + for (; aItMVP.More(); aItMVP.Next()) { + const TopoDS_Shape& nVx=aItMVP.Value(); + aLIx.Append(nVx); + } + // + aMBlocks.Bind(k, aLIx); + ++k; + }//for (; aItMILI.More(); aItMILI.Next()) { + aMVAdd.Clear(); + aMVP.Clear(); + aMEC.Clear(); + aMVS.Clear(); +} + +//======================================================================= +//function : FillMap +//purpose : +//======================================================================= +void FillMap(const TopoDS_Shape& aS1, + const TopoDS_Shape& aS2, + BOPCol_DataMapOfShapeListOfShape& aDMSLS, + Handle(NCollection_IncAllocator)& aAllocator) +{ + if (aDMSLS.IsBound(aS1)) { + BOPCol_ListOfShape& aLS=aDMSLS.ChangeFind(aS1); + aLS.Append(aS2); + } + else { + BOPCol_ListOfShape aLS(aAllocator); + aLS.Append(aS2); + aDMSLS.Bind(aS1, aLS); + } + // + if (aDMSLS.IsBound(aS2)) { + BOPCol_ListOfShape& aLS=aDMSLS.ChangeFind(aS2); + aLS.Append(aS1); + } + else { + BOPCol_ListOfShape aLS(aAllocator); + aLS.Append(aS1); + aDMSLS.Bind(aS2, aLS); + } +} +//======================================================================= +//function :HasPaveBlocksOnIn +//purpose : +//======================================================================= +Standard_Boolean HasPaveBlocksOnIn(const BOPDS_FaceInfo& aFI1, + const BOPDS_FaceInfo& aFI2) +{ + Standard_Boolean bRet; + BOPDS_MapIteratorOfMapOfPaveBlock aItMPB; + // + bRet=Standard_False; + const BOPDS_MapOfPaveBlock& aMPBOn1=aFI1.PaveBlocksOn(); + const BOPDS_MapOfPaveBlock& aMPBIn1=aFI1.PaveBlocksIn(); + // + const BOPDS_MapOfPaveBlock& aMPBOn2=aFI2.PaveBlocksOn(); + aItMPB.Initialize(aMPBOn2); + for (; aItMPB.More(); aItMPB.Next()) { + const Handle(BOPDS_PaveBlock)& aPB=aItMPB.Value(); + bRet=aMPBOn1.Contains(aPB) || aMPBIn1.Contains(aPB); + if (bRet) { + return bRet; + } + } + // + const BOPDS_MapOfPaveBlock& aMPBIn2=aFI2.PaveBlocksIn(); + aItMPB.Initialize(aMPBIn2); + for (; aItMPB.More(); aItMPB.Next()) { + const Handle(BOPDS_PaveBlock)& aPB=aItMPB.Value(); + bRet=aMPBOn1.Contains(aPB) || aMPBIn1.Contains(aPB); + if (bRet) { + return bRet; + } + } + return bRet; +} + +/* +//DEBf + { + TopoDS_Compound aCx; + BRep_Builder aBBx; + BOPCol_ListIteratorOfListOfShape aItx; + // + aBBx.MakeCompound(aCx); + aBBx.Add(aCx, aFF); + aItx.Initialize(aLE); + for (; aItx.More(); aItx.Next()) { + const TopoDS_Shape& aEx=aItx.Value(); + aBBx.Add(aCx, aEx); + } + int a=0; + } + //DEBt +*/ diff --git a/src/BOPAlgo/BOPAlgo_Builder_3.cxx b/src/BOPAlgo/BOPAlgo_Builder_3.cxx new file mode 100644 index 0000000000..bc5ef1c15e --- /dev/null +++ b/src/BOPAlgo/BOPAlgo_Builder_3.cxx @@ -0,0 +1,797 @@ +// Created by: Peter KURNEV +// Copyright (c) 2010-2012 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 +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + +#include + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +// +#include +#include +#include +#include +// +#include +#include +// +#include +#include +// +#include +#include +// +#include + + +static + void OwnInternalShapes(const TopoDS_Shape& , + BOPCol_IndexedMapOfShape& ); + +//======================================================================= +//function : FillImagesSolids +//purpose : +//======================================================================= + void BOPAlgo_Builder::FillImagesSolids() +{ + myErrorStatus=0; + // + Handle(NCollection_IncAllocator) aAllocator; + //-----------------------------------------------------scope_1 f + aAllocator=new NCollection_IncAllocator(); + // + BOPCol_DataMapOfShapeListOfShape theInParts(100, aAllocator); + BOPCol_DataMapOfShapeShape theDraftSolids(100, aAllocator); + // + FillIn3DParts(theInParts, theDraftSolids, aAllocator); + BuildSplitSolids(theInParts, theDraftSolids, aAllocator); + FillInternalShapes(); + // + theInParts.Clear(); + theDraftSolids.Clear(); + //-----------------------------------------------------scope_1 t +} +//======================================================================= +//function : FillIn3DParts +//purpose : +//======================================================================= + void BOPAlgo_Builder::FillIn3DParts(BOPCol_DataMapOfShapeListOfShape& theInParts, + BOPCol_DataMapOfShapeShape& theDraftSolids, + const Handle(NCollection_BaseAllocator)& theAllocator) +{ + myErrorStatus=0; + // + Standard_Boolean bIsIN, bHasImage; + Standard_Integer aNbS, aNbSolids, i, j, aNbFaces, aNbFP, aNbFPx, aNbFIN, aNbLIF, aNbEFP; + TopAbs_ShapeEnum aType; + TopAbs_State aState; + TopoDS_Iterator aIt, aItF; + BRep_Builder aBB; + TopoDS_Solid aSolidSp; + TopoDS_Face aFP; + BOPCol_ListIteratorOfListOfShape aItS, aItFP, aItEx; + BOPCol_MapIteratorOfMapOfShape aItMS, aItMS1; + // + BOPCol_ListOfShape aLIF(theAllocator); + BOPCol_MapOfShape aMFDone(100, theAllocator); + BOPCol_MapOfShape aMSolids(100, theAllocator); + BOPCol_MapOfShape aMFaces(100, theAllocator); + BOPCol_MapOfShape aMFIN(100, theAllocator); + BOPCol_IndexedMapOfShape aMS(100, theAllocator); + BOPCol_IndexedDataMapOfShapeListOfShape aMEF(100, theAllocator); + // + theDraftSolids.Clear(); + // + aNbS=myDS->NbSourceShapes(); + for (i=0; iShapeInfo(i); + const TopoDS_Shape& aS=aSI.Shape(); + // + aType=aSI.ShapeType(); + switch(aType) { + case TopAbs_SOLID: { + aMSolids.Add(aS); + break; + } + // + case TopAbs_FACE: { + // all faces (originals or images) + if (myImages.IsBound(aS)) { + const BOPCol_ListOfShape& aLS=myImages.Find(aS); + aItS.Initialize(aLS); + for (; aItS.More(); aItS.Next()) { + const TopoDS_Shape& aFx=aItS.Value(); + aMFaces.Add(aFx); + } + } + else { + aMFaces.Add(aS); + } + break; + } + // + default: + break; + } + } + // + aNbFaces=aMFaces.Extent(); + aNbSolids=aMSolids.Extent(); + // + aItMS.Initialize(aMSolids); + for (; aItMS.More(); aItMS.Next()) { + const TopoDS_Solid& aSolid=(*(TopoDS_Solid*)(&aItMS.Value())); + // + aMFDone.Clear(); + aMFIN.Clear(); + aMEF.Clear(); + // + aBB.MakeSolid(aSolidSp); + // + // Draft solid and its pure internal faces => aSolidSp, aLIF + aLIF.Clear(); + BuildDraftSolid(aSolid, aSolidSp, aLIF); + aNbLIF=aLIF.Extent(); + // + // 1 all faces/edges from aSolid [ aMS ] + bHasImage=Standard_False; + aMS.Clear(); + aIt.Initialize(aSolid); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aShell=aIt.Value(); + // + if (myImages.IsBound(aShell)) { + bHasImage=Standard_True; + // + const BOPCol_ListOfShape& aLS=myImages.Find(aShell); + aItS.Initialize(aLS); + for (; aItS.More(); aItS.Next()) { + const TopoDS_Shape& aSx=aItS.Value(); + aMS.Add(aSx); + BOPTools::MapShapes(aSx, TopAbs_FACE, aMS); + BOPTools::MapShapes(aSx, TopAbs_EDGE, aMS); + BOPTools::MapShapesAndAncestors(aSx, TopAbs_EDGE, TopAbs_FACE, aMEF); + } + } + else { + //aMS.Add(aShell); + BOPTools::MapShapes(aShell, TopAbs_FACE, aMS); + BOPTools::MapShapesAndAncestors(aShell, TopAbs_EDGE, TopAbs_FACE, aMEF); + } + } + // + // 2 all faces that are not from aSolid [ aLFP1 ] + BOPCol_IndexedDataMapOfShapeListOfShape aMEFP(100, theAllocator); + BOPCol_ListOfShape aLFP1(theAllocator); + BOPCol_ListOfShape aLFP(theAllocator); + BOPCol_ListOfShape aLCBF(theAllocator); + BOPCol_ListOfShape aLFIN(theAllocator); + BOPCol_ListOfShape aLEx(theAllocator); + // + // for all non-solid faces build EF map [ aMEFP ] + aItMS1.Initialize(aMFaces); + for (; aItMS1.More(); aItMS1.Next()) { + const TopoDS_Shape& aFace=aItMS1.Value(); + if (!aMS.Contains(aFace)) { + BOPTools::MapShapesAndAncestors(aFace, TopAbs_EDGE, TopAbs_FACE, aMEFP); + } + } + // + // among all faces from aMEFP select these that have same edges + // with the solid (i.e aMEF). These faces will be treated first + // to prevent the usage of 3D classifier. + // The full list of faces to process is aLFP1. + aNbEFP=aMEFP.Extent(); + for (j=1; j<=aNbEFP; ++j) { + const TopoDS_Shape& aE=aMEFP.FindKey(j); + // + if (aMEF.Contains(aE)) { // !! + const BOPCol_ListOfShape& aLF=aMEFP(j); + aItFP.Initialize(aLF); + for (; aItFP.More(); aItFP.Next()) { + const TopoDS_Shape& aF=aItFP.Value(); + if (aMFDone.Add(aF)) { + aLFP1.Append(aF); + } + } + } + else { + aLEx.Append(aE); + } + } + // + aItEx.Initialize(aLEx); + for (; aItEx.More(); aItEx.Next()) { + const TopoDS_Shape& aE=aItEx.Value(); + const BOPCol_ListOfShape& aLF=aMEFP.FindFromKey(aE); + aItFP.Initialize(aLF); + for (; aItFP.More(); aItFP.Next()) { + const TopoDS_Shape& aF=aItFP.Value(); + if (aMFDone.Add(aF)) { + //aLFP2.Append(aF); + aLFP1.Append(aF); + } + } + } + // + //========== + // + // 3 Process faces aLFP1 + aMFDone.Clear(); + aNbFP=aLFP1.Extent(); + aItFP.Initialize(aLFP1); + for (; aItFP.More(); aItFP.Next()) { + const TopoDS_Shape& aSP=aItFP.Value(); + if (!aMFDone.Add(aSP)) { + continue; + } + + // + // first face to process + aFP=(*(TopoDS_Face*)(&aSP)); + bIsIN=BOPTools_AlgoTools::IsInternalFace(aFP, aSolidSp, aMEF, 1.e-14, myContext); + aState=(bIsIN) ? TopAbs_IN : TopAbs_OUT; + // + // collect faces to process [ aFP is the first ] + aLFP.Clear(); + aLFP.Append(aFP); + aItS.Initialize(aLFP1); + for (; aItS.More(); aItS.Next()) { + const TopoDS_Shape& aSk=aItS.Value(); + if (!aMFDone.Contains(aSk)) { + aLFP.Append(aSk); + } + } + // + // Connexity Block that spreads from aFP the Bound + // or till the end of the block itself + aLCBF.Clear(); + BOPTools_AlgoTools::MakeConnexityBlock(aLFP, aMS, aLCBF, theAllocator); + // + // fill states for the Connexity Block + aItS.Initialize(aLCBF); + for (; aItS.More(); aItS.Next()) { + const TopoDS_Shape& aSx=aItS.Value(); + aMFDone.Add(aSx); + if (aState==TopAbs_IN) { + aMFIN.Add(aSx); + } + } + // + aNbFPx=aMFDone.Extent(); + if (aNbFPx==aNbFP) { + break; + } + }//for (; aItFP.More(); aItFP.Next()) + // + // faces Inside aSolid + aLFIN.Clear(); + aNbFIN=aMFIN.Extent(); + if (aNbFIN || aNbLIF) { + aItMS1.Initialize(aMFIN); + for (; aItMS1.More(); aItMS1.Next()) { + const TopoDS_Shape& aFIn=aItMS1.Value(); + aLFIN.Append(aFIn); + } + // + aItS.Initialize(aLIF); + for (; aItS.More(); aItS.Next()) { + const TopoDS_Shape& aFIN=aItS.Value(); + aLFIN.Append(aFIN); + } + // + theInParts.Bind(aSolid, aLFIN); + } + if (aNbFIN || bHasImage) { + theDraftSolids.Bind(aSolid, aSolidSp); + } + }// for (; aItMS.More(); aItMS.Next()) { +} +//======================================================================= +//function : BuildDraftSolid +//purpose : +//======================================================================= + void BOPAlgo_Builder::BuildDraftSolid(const TopoDS_Shape& theSolid, + TopoDS_Shape& theDraftSolid, + BOPCol_ListOfShape& theLIF) +{ + myErrorStatus=0; + // + Standard_Boolean bToReverse; + Standard_Integer iFlag; + TopAbs_Orientation aOrF, aOrSh, aOrSd; + TopoDS_Iterator aIt1, aIt2; + TopoDS_Shell aShD; + TopoDS_Shape aFSDx, aFx; + BRep_Builder aBB; + BOPCol_ListIteratorOfListOfShape aItS; + // + aOrSd=theSolid.Orientation(); + theDraftSolid.Orientation(aOrSd); + // + aIt1.Initialize(theSolid); + for (; aIt1.More(); aIt1.Next()) { + const TopoDS_Shape& aSh=aIt1.Value(); + if(aSh.ShapeType()!=TopAbs_SHELL) { + continue; // mb internal edges,vertices + } + // + aOrSh=aSh.Orientation(); + aBB.MakeShell(aShD); + aShD.Orientation(aOrSh); + iFlag=0; + // + aIt2.Initialize(aSh); + for (; aIt2.More(); aIt2.Next()) { + const TopoDS_Shape& aF=aIt2.Value(); + aOrF=aF.Orientation(); + // + if (myImages.IsBound(aF)) { + const BOPCol_ListOfShape& aLSp=myImages.Find(aF); + aItS.Initialize(aLSp); + for (; aItS.More(); aItS.Next()) { + aFx=aItS.Value(); + // + if (myShapesSD.IsBound(aFx)) { + aFSDx=myShapesSD.Find(aFx); + // + if (aOrF==TopAbs_INTERNAL) { + aFSDx.Orientation(aOrF); + theLIF.Append(aFSDx); + } + else { + bToReverse=BOPTools_AlgoTools::IsSplitToReverse(aFSDx, aF, myContext); + if (bToReverse) { + aFSDx.Reverse(); + } + // + iFlag=1; + aBB.Add(aShD, aFSDx); + } + }//if (myShapesSD.IsBound(aFx)) { + else { + aFx.Orientation(aOrF); + if (aOrF==TopAbs_INTERNAL) { + theLIF.Append(aFx); + } + else{ + iFlag=1; + aBB.Add(aShD, aFx); + } + } + } + } // if (myImages.IsBound(aF)) { + // + else { + if (aOrF==TopAbs_INTERNAL) { + theLIF.Append(aF); + } + else{ + iFlag=1; + aBB.Add(aShD, aF); + } + } + } //for (; aIt2.More(); aIt2.Next()) { + // + if (iFlag) { + aBB.Add(theDraftSolid, aShD); + } + } //for (; aIt1.More(); aIt1.Next()) { +} +//======================================================================= +//function : BuildSplitSolids +//purpose : +//======================================================================= + void BOPAlgo_Builder::BuildSplitSolids(BOPCol_DataMapOfShapeListOfShape& theInParts, + BOPCol_DataMapOfShapeShape& theDraftSolids, + const Handle(NCollection_BaseAllocator)& theAllocator) +{ + myErrorStatus=0; + // + Standard_Boolean bFlagSD; + Standard_Integer i, aNbS, iErr, aNbSFS; + TopExp_Explorer aExp; + BOPCol_ListIteratorOfListOfShape aIt; + BOPCol_DataMapIteratorOfDataMapOfShapeShape aIt1; + // + BOPCol_ListOfShape aSFS(theAllocator), aLSEmpty(theAllocator); + BOPCol_MapOfShape aMFence(100, theAllocator); + BOPTools_MapOfSet aMST(100, theAllocator); + // + // 0. Find same domain solids for non-interferred solids + aNbS=myDS->NbSourceShapes(); + for (i=0; iShapeInfo(i); + // + if (aSI.ShapeType()!=TopAbs_SOLID) { + continue; + } + // + const TopoDS_Shape& aS=aSI.Shape(); + if (!aMFence.Add(aS)) { + continue; + } + if(theDraftSolids.IsBound(aS)) { + continue; + } + // + BOPTools_Set aST; + // + aST.Add(aS, TopAbs_FACE); + aMST.Add(aST); + // + } //for (i=1; i<=aNbS; ++i) + // + // 1. Build solids for interferred source solids + aNbS=theDraftSolids.Extent(); + aIt1.Initialize(theDraftSolids); + for (; aIt1.More(); aIt1.Next()) { + const TopoDS_Shape& aS =aIt1.Key(); + const TopoDS_Shape& aSD=aIt1.Value(); + const BOPCol_ListOfShape& aLFIN= + (theInParts.IsBound(aS)) ? theInParts.Find(aS) : aLSEmpty; + // + // 1.1 Fill Shell Faces Set + aSFS.Clear(); + aExp.Init(aSD, TopAbs_FACE); + for (; aExp.More(); aExp.Next()) { + const TopoDS_Shape& aF=aExp.Current(); + aSFS.Append(aF); + } + // + aIt.Initialize(aLFIN); + for (; aIt.More(); aIt.Next()) { + TopoDS_Shape aF=aIt.Value(); + // + aF.Orientation(TopAbs_FORWARD); + aSFS.Append(aF); + aF.Orientation(TopAbs_REVERSED); + aSFS.Append(aF); + } + // + aNbSFS=aSFS.Extent(); + //DEB f + // <-A + //DEB t + // + // 1.3 Build new solids + BOPAlgo_BuilderSolid aSB(theAllocator); + // + aSB.SetContext(myContext); + aSB.SetShapes(aSFS); + aSB.Perform(); + iErr=aSB.ErrorStatus(); + if (iErr) { + myErrorStatus=30; // SolidBuilder failed + return; + } + // + const BOPCol_ListOfShape& aLSR=aSB.Areas(); + // + // 1.4 Collect resulting solids and theirs set of faces. + // Update Images. + if (!myImages.IsBound(aS)) { + BOPCol_ListOfShape aLSx; + // + myImages.Bind(aS, aLSx); + BOPCol_ListOfShape& aLSIm=myImages.ChangeFind(aS); + // + aIt.Initialize(aLSR); + for (; aIt.More(); aIt.Next()) { + BOPTools_Set aST; + // + const TopoDS_Shape& aSR=aIt.Value(); + aST.Add(aSR, TopAbs_FACE); + // + bFlagSD=aMST.Contains(aST); + // + const BOPTools_Set& aSTx=aMST.Added(aST); + const TopoDS_Shape& aSx=aSTx.Shape(); + aLSIm.Append(aSx); + // + if (bFlagSD) { + myShapesSD.Bind(aSR, aSx); + } + } + } + } // for (; aIt1.More(); aIt1.Next()) { +} + +//======================================================================= +//function :FillInternalShapes +//purpose : +//======================================================================= + void BOPAlgo_Builder::FillInternalShapes() +{ + myErrorStatus=0; + // + Standard_Integer i, j, aNbS, aNbSI, aNbSx, aNbSd; + TopAbs_ShapeEnum aType; + TopAbs_State aState; + TopoDS_Iterator aItS; + BRep_Builder aBB; + BOPCol_MapIteratorOfMapOfShape aItM; + BOPCol_ListIteratorOfListOfShape aIt, aIt1; + // + Handle(NCollection_IncAllocator) aAllocator; + //-----------------------------------------------------scope f + aAllocator=new NCollection_IncAllocator(); + // + BOPCol_IndexedDataMapOfShapeListOfShape aMSx(100, aAllocator); + BOPCol_IndexedMapOfShape aMx(100, aAllocator); + BOPCol_MapOfShape aMSI(100, aAllocator); + BOPCol_MapOfShape aMFence(100, aAllocator); + BOPCol_MapOfShape aMSOr(100, aAllocator); + BOPCol_ListOfShape aLSd(aAllocator); + //modified by NIZNHY-PKV Thu Jul 08 07:57:33 2010f + BOPCol_ListOfShape aLArgs(aAllocator); + //modified by NIZNHY-PKV Thu Jul 08 07:57:35 2010t + // + // 1. Shapes to process + // + // 1.1 Shapes from pure arguments aMSI + // 1.1.1 vertex, edge, wire + // + //modified by NIZNHY-PKV Thu Jul 08 07:59:23 2010f + aIt.Initialize(myArguments); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aS=aIt.Value(); + if (!aMFence.Add(aS)) { + continue; + } + // + aType=aS.ShapeType(); + if (aType==TopAbs_WIRE) { + aItS.Initialize(aS); + for(; aItS.More(); aItS.Next()) { + const TopoDS_Shape& aE=aItS.Value(); + if (aMFence.Add(aE)) { + aLArgs.Append(aE); + } + } + } + else if (aType==TopAbs_VERTEX || aType==TopAbs_EDGE){ + aLArgs.Append(aS); + } + } + aMFence.Clear(); + //modified by NIZNHY-PKV Thu Jul 08 07:59:28 2010t + // + //modified by NIZNHY-PKV Thu Jul 08 08:01:43 2010f + //aIt.Initialize(myArguments); + //modified by NIZNHY-PKV Thu Jul 08 08:01:46 2010t + aIt.Initialize(aLArgs); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aS=aIt.Value(); + aType=aS.ShapeType(); + if (aType==TopAbs_VERTEX || aType==TopAbs_EDGE ||aType==TopAbs_WIRE) { + if (aMFence.Add(aS)) { + if (myImages.IsBound(aS)) { + const BOPCol_ListOfShape &aLSp=myImages.Find(aS); + aIt1.Initialize(aLSp); + for (; aIt1.More(); aIt1.Next()) { + const TopoDS_Shape& aSp=aIt1.Value(); + aMSI.Add(aSp); + } + } + else { + aMSI.Add(aS); + } + } + } + } + + aNbSI=aMSI.Extent(); + // + // 2. Internal vertices, edges from source solids + aMFence.Clear(); + aLSd.Clear(); + // + aNbS=myDS->NbSourceShapes(); + for (i=0; iShapeInfo(i); + // + if (aSI.ShapeType()!=TopAbs_SOLID) { + continue; + } + // + const TopoDS_Shape& aS=aSI.Shape(); + // + aMx.Clear(); + OwnInternalShapes(aS, aMx); + // + aNbSx=aMx.Extent(); + for (j=1; j<=aNbSx; ++j) { + const TopoDS_Shape& aSi=aMx(j); + if (myImages.IsBound(aSi)) { + const BOPCol_ListOfShape &aLSp=myImages.Find(aSi); + aIt1.Initialize(aLSp); + for (; aIt1.More(); aIt1.Next()) { + const TopoDS_Shape& aSp=aIt1.Value(); + aMSI.Add(aSp); + } + } + else { + aMSI.Add(aSi); + } + } + // + // build aux map from splits of solids + if (myImages.IsBound(aS)) { + const BOPCol_ListOfShape &aLSp=myImages.Find(aS); + aIt.Initialize(aLSp); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aSp=aIt.Value(); + if (aMFence.Add(aSp)) { + BOPTools::MapShapesAndAncestors(aSp, TopAbs_VERTEX, TopAbs_EDGE, aMSx); + BOPTools::MapShapesAndAncestors(aSp, TopAbs_VERTEX, TopAbs_FACE, aMSx); + BOPTools::MapShapesAndAncestors(aSp, TopAbs_EDGE , TopAbs_FACE, aMSx); + aLSd.Append(aSp); + } + } + } + else { + if (aMFence.Add(aS)) { + BOPTools::MapShapesAndAncestors(aS, TopAbs_VERTEX, TopAbs_EDGE, aMSx); + BOPTools::MapShapesAndAncestors(aS, TopAbs_VERTEX, TopAbs_FACE, aMSx); + BOPTools::MapShapesAndAncestors(aS, TopAbs_EDGE , TopAbs_FACE, aMSx); + aLSd.Append(aS); + aMSOr.Add(aS); + } + } + }// for (i=0; i + +#include + +#include +#include + +#include +#include + +//======================================================================= +//function : Generated +//purpose : +//======================================================================= + const TopTools_ListOfShape& BOPAlgo_Builder::Generated(const TopoDS_Shape& theS) +{ + Standard_Boolean bHasImage, bToReverse; + TopAbs_ShapeEnum aType; + BOPCol_ListIteratorOfListOfShape aIt; + // + myHistShapes.Clear(); + // + if (theS.IsNull()) { + return myHistShapes; + } + // + bHasImage=myImages.IsBound(theS); + if (!bHasImage) { + return myHistShapes; + } + // + aType=theS.ShapeType(); + // + if (!(aType==TopAbs_EDGE || aType==TopAbs_FACE || + aType==TopAbs_VERTEX || aType==TopAbs_SOLID)) { + return myHistShapes; + } + // + //PrepareHistory(); + // + const BOPCol_ListOfShape& aLSp=myImages.Find(theS); + aIt.Initialize(aLSp); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aSp=aIt.Value(); + if (myShapesSD.IsBound(aSp)) { + if (myMapShape.Contains(aSp)) { + TopoDS_Shape aSpR=myShapesSD.Find(aSp); + // + if (aType==TopAbs_VERTEX || aType==TopAbs_SOLID) { + aSpR.Orientation(theS.Orientation()); + } + else { + bToReverse=BOPTools_AlgoTools::IsSplitToReverse(aSpR, theS, myContext); + if (bToReverse) { + aSpR.Reverse(); + } + } + // + myHistShapes.Append(aSpR); + } + } + } + // + return myHistShapes; +} +//======================================================================= +//function : Modified +//purpose : +//======================================================================= + const TopTools_ListOfShape& BOPAlgo_Builder::Modified(const TopoDS_Shape& theS) +{ + Standard_Boolean bHasImage, bToReverse; + TopAbs_ShapeEnum aType; + BOPCol_ListIteratorOfListOfShape aIt; + // + myHistShapes.Clear(); + // + if (theS.IsNull()) { + return myHistShapes; + } + // + bHasImage=myImages.IsBound(theS); + if (!bHasImage) { + return myHistShapes; + } + // + aType=theS.ShapeType(); + // + if (!(aType==TopAbs_EDGE || aType==TopAbs_FACE || + aType==TopAbs_VERTEX || aType==TopAbs_SOLID)) { + return myHistShapes; + } + // + //PrepareHistory(); + // + const BOPCol_ListOfShape& aLSp=myImages.Find(theS); + aIt.Initialize(aLSp); + for (; aIt.More(); aIt.Next()) { + TopoDS_Shape aSp=aIt.Value(); + if (!myShapesSD.IsBound(aSp)) { + if (myMapShape.Contains(aSp)) { + // + if (aType==TopAbs_VERTEX || aType==TopAbs_SOLID) { + aSp.Orientation(theS.Orientation()); + } + else { + bToReverse=BOPTools_AlgoTools::IsSplitToReverse(aSp, theS, myContext); + if (bToReverse) { + aSp.Reverse(); + } + } + // + myHistShapes.Append(aSp); + } + } + } + // + return myHistShapes; +} +//======================================================================= +//function : IsDeleted +//purpose : +//======================================================================= + Standard_Boolean BOPAlgo_Builder::IsDeleted(const TopoDS_Shape& theS) +{ + Standard_Boolean bRet, bHasImage, bContains; + TopAbs_ShapeEnum aType; + BOPCol_ListIteratorOfListOfShape aIt; + // + bRet=Standard_False; + // + if (theS.IsNull()) { + return !bRet; //true + } + // + aType=theS.ShapeType(); + if (!(aType==TopAbs_EDGE || aType==TopAbs_FACE || + aType==TopAbs_VERTEX || aType==TopAbs_SOLID)) { + return !bRet; + } + // + bHasImage=myImages.IsBound(theS); + if (!bHasImage) { + return !bRet; //true + } + // + //PrepareHistory(); + // + bContains=myMapShape.Contains(theS); + if (bContains) { + return bRet; //false + } + // + const BOPCol_ListOfShape& aLSp=myImages.Find(theS); + aIt.Initialize(aLSp); + for (; aIt.More(); aIt.Next()) { + TopoDS_Shape aSp=aIt.Value(); + // + if (!myShapesSD.IsBound(aSp)) { + if (myMapShape.Contains(aSp)) { + return bRet; //false + } + } + else { + TopoDS_Shape aSpR=myShapesSD.Find(aSp); + if (myMapShape.Contains(aSpR)) { + return bRet; //false + } + } + } + return !bRet; // true +} +//======================================================================= +//function : PrepareHistory +//purpose : +//======================================================================= + void BOPAlgo_Builder::PrepareHistory() +{ + if (!myFlagHistory) { + return; + } + // + if(myShape.IsNull()) { + return; + } + // + Standard_Boolean bHasImage, bContainsSD; + TopAbs_ShapeEnum aType; + BOPCol_MapOfShape aMS; + BOPCol_ListIteratorOfListOfShape aIt; + BOPCol_MapIteratorOfMapOfShape aItM; + // + // 1. Clearing + BOPAlgo_BuilderShape::PrepareHistory(); + // + // 2. myMapShape - all shapes of result with theirs sub-shapes + BOPTools::MapShapes(myShape, myMapShape); + // + // 3. MS - all argument shapes with theirs sub-shapes + aIt.Initialize(myArguments); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aSx=aIt.Value(); + BOPTools::MapShapes(aSx, aMS); + } + // + // 4. Treatment + aItM.Initialize(aMS); + for (; aItM.More(); aItM.Next()) { + const TopoDS_Shape& aSx=aItM.Key(); + aType=aSx.ShapeType(); + // + // 4.1 .myImagesResult + bHasImage=myImages.IsBound(aSx); + // + BOPCol_ListOfShape aLSx; + if (!bHasImage) { + if (myMapShape.Contains(aSx)) { + aLSx.Append(aSx); + myImagesResult.Add(aSx, aLSx); + } + } + else { + const BOPCol_ListOfShape& aLSp=myImages.Find(aSx); + aIt.Initialize(aLSp); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aSp=aIt.Value(); + if (myMapShape.Contains(aSp)) { + aLSx.Append(aSp); + } + } + myImagesResult.Add(aSx, aLSx); + } + // <- A + // + // 4.2 As it was + if (!myHasDeleted) { + myHasDeleted=IsDeleted(aSx); + } + // + if (!myHasGenerated || !myHasModified) { + if (aType==TopAbs_EDGE || aType==TopAbs_FACE || + aType==TopAbs_VERTEX || aType==TopAbs_SOLID) { + if (bHasImage) { + const BOPCol_ListOfShape& aLSp=myImages.Find(aSx); + aIt.Initialize(aLSp); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aSp=aIt.Value(); + // + if (myMapShape.Contains(aSp)) { + bContainsSD=myShapesSD.IsBound(aSp); + // + if (!myHasGenerated) { + if (bContainsSD) { + myHasGenerated=Standard_True; + } + } + if (!myHasModified) { + if (!bContainsSD) { + myHasModified=Standard_True; + } + } + } // if (myMapShape.Contains(aSp)) + } + } + } + } + } + myFlagHistory=Standard_True; +} + +// <- A + /* + BOPCol_ListOfShape aLSx; + if (!bHasImage) { + if (myMapShape.Contains(aSx)) { + aLSx.Append(aSx); + myImagesResult.Add(aSx, aLSx); + } + } + else { + const BOPCol_ListOfShape& aLSp=myImages.Find(aSx); + aIt.Initialize(aLSp); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aSp=aIt.Value(); + if (myMapShape.Contains(aSp)) { + aLSx.Append(aSp); + } + } + myImagesResult.Add(aSx, aLSx); + } + */ diff --git a/src/BOPAlgo/BOPAlgo_CheckResult.cdl b/src/BOPAlgo/BOPAlgo_CheckResult.cdl new file mode 100644 index 0000000000..b031342d82 --- /dev/null +++ b/src/BOPAlgo/BOPAlgo_CheckResult.cdl @@ -0,0 +1,84 @@ +-- Created on: 2004-09-03 +-- Created by: Oleg FEDYAEV +-- Copyright (c) 2004-2012 OPEN CASCADE SAS +-- +-- The content of this file is subject to the Open CASCADE Technology Public +-- License Version 6.5 (the "License"). You may not use the content of this file +-- except in compliance with the License. Please obtain a copy of the License +-- at http://www.opencascade.org and read it completely before using this file. +-- +-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +-- +-- The Original Code and all software distributed under the License is +-- distributed on an "AS IS" basis, without warranty of any kind, and the +-- Initial Developer hereby disclaims all such warranties, including without +-- limitation, any warranties of merchantability, fitness for a particular +-- purpose or non-infringement. Please see the License for the specific terms +-- and conditions governing the rights and limitations under the License. + + +class CheckResult from BOPAlgo + ---Purpose: contains information about faulty shapes and faulty types + --- can't be processed by Boolean Operations + +uses + + Shape from TopoDS, + CheckStatus from BOPAlgo, + ListOfShape from TopTools + +is + + Create + returns CheckResult; + ---Purpose: empty constructor + + SetShape1(me: in out; TheShape : Shape from TopoDS); + ---Purpose: sets ancestor shape (object) for faulty sub-shapes + + AddFaultyShape1(me: in out; TheShape: Shape from TopoDS); + ---Purpose: adds faulty sub-shapes from object to a list + + SetShape2(me: in out; TheShape: Shape from TopoDS); + ---Purpose: sets ancestor shape (tool) for faulty sub-shapes + + AddFaultyShape2(me: in out; TheShape: Shape from TopoDS); + ---Purpose: adds faulty sub-shapes from tool to a list + + GetShape1(me) + returns Shape from TopoDS; + ---C++: return const& + ---Purpose: returns ancestor shape (object) for faulties + + GetShape2(me) + returns Shape from TopoDS; + ---C++: return const& + ---Purpose: returns ancestor shape (tool) for faulties + + GetFaultyShapes1(me) + returns ListOfShape from TopTools; + ---C++: return const& + ---Purpose: returns list of faulty shapes for object + + GetFaultyShapes2(me) + returns ListOfShape from TopTools; + ---C++: return const& + ---Purpose: returns list of faulty shapes for tool + + SetCheckStatus(me: in out; TheStatus: CheckStatus from BOPAlgo); + ---Purpose: set status of faulty + + GetCheckStatus(me) + returns CheckStatus from BOPAlgo; + ---Purpose: gets status of faulty + +fields + + myShape1 : Shape from TopoDS; + myShape2 : Shape from TopoDS; + myStatus : CheckStatus from BOPAlgo; + myFaulty1 : ListOfShape from TopTools; + myFaulty2 : ListOfShape from TopTools; + +end CheckResult; diff --git a/src/BOPAlgo/BOPAlgo_CheckResult.cxx b/src/BOPAlgo/BOPAlgo_CheckResult.cxx new file mode 100644 index 0000000000..f7db74584f --- /dev/null +++ b/src/BOPAlgo/BOPAlgo_CheckResult.cxx @@ -0,0 +1,79 @@ +// Created on: 2004-09-02 +// Created by: Oleg FEDYAEV +// Copyright (c) 2004-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#include + +//======================================================================= +// function: BOPAlgo_CheckResult() +// purpose: +//======================================================================= +BOPAlgo_CheckResult::BOPAlgo_CheckResult() : myStatus(BOPAlgo_CheckUnknown) +{ +} + +void BOPAlgo_CheckResult::SetShape1(const TopoDS_Shape& TheShape) +{ + myShape1 = TheShape; +} + +void BOPAlgo_CheckResult::AddFaultyShape1(const TopoDS_Shape& TheShape) +{ + myFaulty1.Append(TheShape); +} + +void BOPAlgo_CheckResult::SetShape2(const TopoDS_Shape& TheShape) +{ + myShape2 = TheShape; +} + +void BOPAlgo_CheckResult::AddFaultyShape2(const TopoDS_Shape& TheShape) +{ + myFaulty2.Append(TheShape); +} + +const TopoDS_Shape& BOPAlgo_CheckResult::GetShape1() const +{ + return myShape1; +} + +const TopoDS_Shape & BOPAlgo_CheckResult::GetShape2() const +{ + return myShape2; +} + +const TopTools_ListOfShape& BOPAlgo_CheckResult::GetFaultyShapes1() const +{ + return myFaulty1; +} + +const TopTools_ListOfShape& BOPAlgo_CheckResult::GetFaultyShapes2() const +{ + return myFaulty2; +} + +void BOPAlgo_CheckResult::SetCheckStatus(const BOPAlgo_CheckStatus TheStatus) +{ + myStatus = TheStatus; +} + +BOPAlgo_CheckStatus BOPAlgo_CheckResult::GetCheckStatus() const +{ + return myStatus; +} diff --git a/src/BOPAlgo/BOPAlgo_CheckerSI.cdl b/src/BOPAlgo/BOPAlgo_CheckerSI.cdl new file mode 100644 index 0000000000..7cab5935cc --- /dev/null +++ b/src/BOPAlgo/BOPAlgo_CheckerSI.cdl @@ -0,0 +1,35 @@ +-- Created by: Peter Kurnev +-- Copyright (c) 2010-2012 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 +-- +-- The content of this file is subject to the Open CASCADE Technology Public +-- License Version 6.5 (the "License"). You may not use the content of this file +-- except in compliance with the License. Please obtain a copy of the License +-- at http://www.opencascade.org and read it completely before using this file. +-- +-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +-- +-- The Original Code and all software distributed under the License is +-- distributed on an "AS IS" basis, without warranty of any kind, and the +-- Initial Developer hereby disclaims all such warranties, including without +-- limitation, any warranties of merchantability, fitness for a particular +-- purpose or non-infringement. Please see the License for the specific terms +-- and conditions governing the rights and limitations under the License. +-- +class CheckerSI from BOPAlgo + inherits PaveFiller from BOPAlgo + + ---Purpose: Checks shape on self-interference. + +is + Create + returns CheckerSI from BOPAlgo; + ---C++: alias "Standard_EXPORT virtual ~BOPAlgo_CheckerSI();" + + Init (me:out) + is redefined protected; + +end CheckerSI; diff --git a/src/BOPAlgo/BOPAlgo_CheckerSI.cxx b/src/BOPAlgo/BOPAlgo_CheckerSI.cxx new file mode 100644 index 0000000000..6a8da68098 --- /dev/null +++ b/src/BOPAlgo/BOPAlgo_CheckerSI.cxx @@ -0,0 +1,73 @@ +// Created by: Peter KURNEV +// Copyright (c) 2010-2012 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 +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. +// +#include + +#include +#include +#include + +//======================================================================= +//function : +//purpose : +//======================================================================= + BOPAlgo_CheckerSI::BOPAlgo_CheckerSI() +: + BOPAlgo_PaveFiller() +{ +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= + BOPAlgo_CheckerSI::~BOPAlgo_CheckerSI() +{ +} +//======================================================================= +//function : Init +//purpose : +//======================================================================= + void BOPAlgo_CheckerSI::Init() +{ + myErrorStatus = 0; + // + if (!myArguments.Extent()) { + myErrorStatus=10; + return; + } + // + Clear(); + // + // 1. myDS + myDS=new BOPDS_DS(myAllocator); + myDS->SetArguments(myArguments); + myDS->Init(); + // + // 2.myIterator + myIterator=new BOPDS_IteratorSI(myAllocator); + myIterator->SetDS(myDS); + myIterator->Prepare(); + // + // 3 myContext + myContext=new BOPInt_Context; + // + myErrorStatus=0; +} diff --git a/src/BOPAlgo/BOPAlgo_ListOfCheckResult.hxx b/src/BOPAlgo/BOPAlgo_ListOfCheckResult.hxx new file mode 100644 index 0000000000..ece817e849 --- /dev/null +++ b/src/BOPAlgo/BOPAlgo_ListOfCheckResult.hxx @@ -0,0 +1,27 @@ +// Copyright (c) 20010-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + +#ifndef BOPAlgo_ListOfCheckResult_HeaderFile +#define BOPAlgo_ListOfCheckResult_HeaderFile + +#include +#include + +typedef NCollection_List BOPAlgo_ListOfCheckResult; +typedef BOPAlgo_ListOfCheckResult::Iterator BOPAlgo_ListIteratorOfListOfCheckResult; + +#endif diff --git a/src/BOPAlgo/BOPAlgo_PaveFiller.cdl b/src/BOPAlgo/BOPAlgo_PaveFiller.cdl new file mode 100644 index 0000000000..5039f753e3 --- /dev/null +++ b/src/BOPAlgo/BOPAlgo_PaveFiller.cdl @@ -0,0 +1,355 @@ +-- Created by: Peter KURNEV +-- Copyright (c) 2010-2012 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 +-- +-- The content of this file is subject to the Open CASCADE Technology Public +-- License Version 6.5 (the "License"). You may not use the content of this file +-- except in compliance with the License. Please obtain a copy of the License +-- at http://www.opencascade.org and read it completely before using this file. +-- +-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +-- +-- The Original Code and all software distributed under the License is +-- distributed on an "AS IS" basis, without warranty of any kind, and the +-- Initial Developer hereby disclaims all such warranties, including without +-- limitation, any warranties of merchantability, fitness for a particular +-- purpose or non-infringement. Please see the License for the specific terms +-- and conditions governing the rights and limitations under the License. + + +class PaveFiller from BOPAlgo + inherits Algo from BOPAlgo + ---Purpose: + +uses + Pnt from gp, + Vertex from TopoDS, + Face from TopoDS, + Edge from TopoDS, + + BaseAllocator from BOPCol, + ListOfShape from BOPCol, + MapOfInteger from BOPCol, + ListOfInteger from BOPCol, + DataMapOfShapeInteger from BOPCol, + DataMapOfIntegerListOfInteger from BOPCol, + DataMapOfShapeListOfShape from BOPCol, + -- + Context from BOPInt, + -- + SectionAttribute from BOPAlgo, + + DS from BOPDS, + PDS from BOPDS, + Iterator from BOPDS, + PIterator from BOPDS, + PaveBlock from BOPDS, + Curve from BOPDS, + DataMapOfShapeCoupleOfPaveBlocks from BOPDS, + MapOfPaveBlock from BOPDS, + ListOfPaveBlock from BOPDS, + ListOfPave from BOPDS, + ListOfPntOn2S from IntSurf, + Curve from IntTools, + + DataMapOfPaveBlockListOfPaveBlock from BOPDS, + VectorOfCurve from BOPDS + +--raises + +is + Create + returns PaveFiller from BOPAlgo; + ---C++: alias "Standard_EXPORT virtual ~BOPAlgo_PaveFiller();" + + Create (theAllocator: BaseAllocator from BOPCol) + returns PaveFiller from BOPAlgo; + + DS(me:out) + returns DS from BOPDS; + ---C++:return const & + + + PDS(me:out) + returns PDS from BOPDS; + + Iterator(me:out) + returns PIterator from BOPDS; + ---C++:return const & + + Arguments(me) + returns ListOfShape from BOPCol; + ---C++: return const & + ---C++: alias "Standard_EXPORT void SetArguments(const BOPCol_ListOfShape& theLS);" + + Context(me:out) + returns Context from BOPInt; + + SetSectionAttribute(me:out; + theSecAttr : SectionAttribute from BOPAlgo); + + Perform(me:out) + is redefined; + -- + -- protected methods + -- + Clear(me:out) + is virtual protected; + + Init(me:out) + is virtual protected; + + PerformVV(me:out) + is virtual protected; + + PerformVE(me:out) + is virtual protected; + + PerformVF(me:out) + is virtual protected; + + PerformEE(me:out) + is virtual protected; + + PerformEF(me:out) + is virtual protected; + + PerformFF(me:out) + is virtual protected; + + + TreatVerticesEE(me:out) + is protected; + + MakeSplitEdges(me:out) + is protected; + + MakeBlocks(me:out) + is protected; + + MakePCurves(me:out) + is protected; + + ProcessDE(me:out) + is protected; + + FillShrunkData(me:out; + thePB:out PaveBlock from BOPDS) + is protected; + + PerformVertices(me:out; + theMVCPB:out DataMapOfShapeCoupleOfPaveBlocks from BOPDS; + theAllocator:out BaseAllocator from BOPCol) + returns Integer from Standard + is protected; + + PerformVertices1(me:out; + theMVCPB:out DataMapOfShapeCoupleOfPaveBlocks from BOPDS; + theAllocator:out BaseAllocator from BOPCol) + returns Integer from Standard + is protected; + + CheckFacePaves(me:out; + theVnew:Vertex from TopoDS; + theMIF:MapOfInteger from BOPCol) + returns Boolean from Standard + is protected; + + CheckFacePaves(myclass; + theN:Integer from Standard; + theMIFOn:MapOfInteger from BOPCol; + theMIFIn:MapOfInteger from BOPCol) + returns Boolean from Standard + is protected; + + IsExistingVertex(me; + theP:Pnt from gp; + theTol:Real from Standard; + theMVOn:MapOfInteger from BOPCol) + returns Boolean from Standard + is protected; + +-- PutPaveOnCurve(me:out; +-- theMVOn:MapOfInteger from BOPCol; +-- theTolR3D:Real from Standard; +-- theNC:out Curve from BOPDS) +-- is protected; + PutPaveOnCurve(me:out; + theMVOn:MapOfInteger from BOPCol; + theTolR3D:Real from Standard; + theNC:out Curve from BOPDS; + nF1:Integer from Standard; + nF2:Integer from Standard) + is protected; + + ExtendedTolerance(me:out; + nV:Integer from Standard; + aMI:MapOfInteger from BOPCol; + aTolVExt:out Real from Standard) + returns Boolean from Standard + is protected; + + PutBoundPaveOnCurve(me:out; + theF1: Face from TopoDS; + theF2: Face from TopoDS; + theTolR3D:Real from Standard; + theNC:out Curve from BOPDS; + --modified by NIZHNY-EMV Thu Mar 31 14:40:58 2011 + theMVOnIn:out MapOfInteger from BOPCol; + theMVB:out MapOfInteger from BOPCol) + --modified by NIZHNY-EMV Thu Mar 31 14:41:02 2011 + is protected; + + IsExistingPaveBlock(me:out; + thePB:PaveBlock from BOPDS; + theNC:Curve from BOPDS; + theTolR3D:Real from Standard; + theMPB:MapOfPaveBlock from BOPDS) + returns Boolean from Standard + is protected; + + IsExistingPaveBlock(me:out; + thePB:PaveBlock from BOPDS; + theNC:Curve from BOPDS; + theTolR3D:Real from Standard; + theLSE:ListOfInteger from BOPCol) + returns Boolean from Standard + is protected; + + PostTreatFF(me:out; + theMSCPB:out DataMapOfShapeCoupleOfPaveBlocks from BOPDS; + theMVI:out DataMapOfShapeInteger from BOPCol; + theAllocator:out BaseAllocator from BOPCol) + returns Integer from Standard + is protected; + -- + -- Treatment of degenerated edges + -- + FindPaveBlocks(me:out; + theV:Integer from Standard; + theF:Integer from Standard; + theLPB:out ListOfPaveBlock from BOPDS) + is protected; + + FillPaves(me:out; + theV:Integer from Standard; + theE:Integer from Standard; + theF:Integer from Standard; + theLPB: ListOfPaveBlock from BOPDS; + thePB: PaveBlock from BOPDS) + is protected; + + MakeSplitEdge(me:out; + theV:Integer from Standard; + theF:Integer from Standard) + is protected; + + GetListOfEFPnts(me:out; + nF1 : Integer from Standard; + nF2 : Integer from Standard; + aListOfPnts: out ListOfPntOn2S from IntSurf) + is protected; + + --modified by NIZHNY-EMV Thu Jun 16 15:06:44 2011 + ProcessUnUsedVertices(me:out; + nF1 : Integer from Standard; + nF2 : Integer from Standard; + theNC : out Curve from BOPDS; + theMStickV : out MapOfInteger from BOPCol) + is protected; + --modified by NIZHNY-EMV Thu Jun 16 15:06:52 2011 + + --modified by NIZHNY-EMV Fri Sep 23 11:18:13 2011 + GetInterfs(me:out; + nF1 : Integer from Standard; + nF2 : Integer from Standard; + theMSticksV : out MapOfInteger from BOPCol; + theMInterfs : out DataMapOfIntegerListOfInteger from BOPCol; + iFlag : Integer from Standard); + -- is protected; + --modified by NIZHNY-EMV Fri Sep 23 11:18:19 2011 + + --modified by NIZHNY-EMV Fri Sep 23 12:13:43 2011 + GetFullFaceMap(me:out; + nF : Integer from Standard; + theMI : out MapOfInteger from BOPCol) + is protected; + + ProcessUnUsedVertices(me:out; + nF1 : Integer from Standard; + nF2 : Integer from Standard; + theNC : out Curve from BOPDS; + theLIEF : ListOfInteger from BOPCol) + is protected; + + RemoveUsedVertices(me:out; + theNC : out Curve from BOPDS; + theMV : out MapOfInteger from BOPCol) + is protected; + --modified by NIZHNY-EMV Fri Sep 23 12:13:45 2011 + + --modified by NIZHNY-EMV Fri Sep 23 13:31:08 2011 + PutPaveOnCurve(me:out; + nV : Integer from Standard; + theTolR3D : Real from Standard; + theNC : Curve from BOPDS; + thePB : out PaveBlock from BOPDS) + is protected; + --modified by NIZHNY-EMV Fri Sep 23 13:31:10 2011 + + --modified by NIZHNY-EMV Fri Dec 23 15:40:05 2011 + ProcessExistingPaveBlocks(me:out; + theInt : Integer from Standard; + theMPBOnIn : MapOfPaveBlock from BOPDS; + theMV : MapOfInteger from BOPCol; + theMPB : out MapOfPaveBlock from BOPDS; + theMSCPB : out DataMapOfShapeCoupleOfPaveBlocks from BOPDS; + theMVI : out DataMapOfShapeInteger from BOPCol) + is protected; + --modified by NIZHNY-EMV Fri Dec 23 15:40:06 2011 + + --modified by NIZHNY-EMV Tue Dec 13 10:21:47 2011 + UpdateExistingPaveBlocks(me:out; + theLPB : out ListOfPaveBlock from BOPDS; + nF1 : Integer from Standard; + nF2 : Integer from Standard) + is protected; + --modified by NIZHNY-EMV Tue Dec 13 10:21:48 2011 + + --modified by NIZHNY-EMV Wed Jan 11 10:59:32 2012 + TreatNewVertices(me:out; + theMVI : DataMapOfShapeInteger from BOPCol; + theImages : out DataMapOfShapeListOfShape from BOPCol) + is protected; + --modified by NIZHNY-EMV Wed Jan 11 10:59:33 2012 + + --modified by NIZHNY-EMV Wed Feb 15 08:40:01 2012 + PutClosingPaveOnCurve (me:out; + aNC :out Curve from BOPDS) + is protected; + ---Purpose: + --- Put paves on the curve in case when + --- is closed 3D-curve + --modified by NIZHNY-EMV Wed Feb 15 08:40:02 2012 + + IsCommonBlockOnFaces(me:out; + aPB : PaveBlock from BOPDS; + nF1 : Integer from Standard; + nF2 : Integer from Standard) + returns Boolean from Standard + is protected; + ---Purpose: + --- Checks if the PaveBlock aPB is common block + --- for faces with indices nF1 and nF2 + +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; + +end PaveFiller; diff --git a/src/BOPAlgo/BOPAlgo_PaveFiller.cxx b/src/BOPAlgo/BOPAlgo_PaveFiller.cxx new file mode 100644 index 0000000000..e9f2ad2bef --- /dev/null +++ b/src/BOPAlgo/BOPAlgo_PaveFiller.cxx @@ -0,0 +1,224 @@ +// Created by: Peter KURNEV +// Copyright (c) 2010-2012 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 +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#include + +#include + +#include +#include +#include + +//======================================================================= +//function : +//purpose : +//======================================================================= + BOPAlgo_PaveFiller::BOPAlgo_PaveFiller() +: + BOPAlgo_Algo() +{ + myDS=NULL; + myIterator=NULL; +} +//======================================================================= +//function : +//purpose : +//======================================================================= + BOPAlgo_PaveFiller::BOPAlgo_PaveFiller(const Handle(NCollection_BaseAllocator)& theAllocator) +: + BOPAlgo_Algo(theAllocator) +{ + myDS=NULL; + myIterator=NULL; +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= + BOPAlgo_PaveFiller::~BOPAlgo_PaveFiller() +{ + Clear(); +} +//======================================================================= +//function : Clear +//purpose : +//======================================================================= + void BOPAlgo_PaveFiller::Clear() +{ + if (myIterator) { + delete myIterator; + myIterator=NULL; + } + if (myDS) { + delete myDS; + myDS=NULL; + } + myErrorStatus=2; +} +//======================================================================= +//function : DS +//purpose : +//======================================================================= + const BOPDS_DS& BOPAlgo_PaveFiller::DS() +{ + return *myDS; +} +//======================================================================= +//function : PDS +//purpose : +//======================================================================= + BOPDS_PDS BOPAlgo_PaveFiller::PDS() +{ + return myDS; +} +//======================================================================= +//function : Context +//purpose : +//======================================================================= + Handle(BOPInt_Context) BOPAlgo_PaveFiller::Context() +{ + return myContext; +} +//======================================================================= +//function : SectionAttribute +//purpose : +//======================================================================= + void BOPAlgo_PaveFiller::SetSectionAttribute(const BOPAlgo_SectionAttribute& theSecAttr) +{ + mySectionAttribute = theSecAttr; +} +//======================================================================= +//function : SetArguments +//purpose : +//======================================================================= + void BOPAlgo_PaveFiller::SetArguments(const BOPCol_ListOfShape& theLS) +{ + myArguments=theLS; +} +//======================================================================= +//function : Arguments +//purpose : +//======================================================================= + const BOPCol_ListOfShape& BOPAlgo_PaveFiller::Arguments()const +{ + return myArguments; +} +//======================================================================= +// function: Init +// purpose: +//======================================================================= + void BOPAlgo_PaveFiller::Init() +{ + myErrorStatus=0; + // + if (!myArguments.Extent()) { + myErrorStatus=10; + return; + } + // + // 0 Clear + Clear(); + // + // 1.myDS + myDS=new BOPDS_DS(myAllocator); + myDS->SetArguments(myArguments); + myDS->Init(); + // + // 2.myIterator + myIterator=new BOPDS_Iterator(myAllocator); + myIterator->SetDS(myDS); + myIterator->Prepare(); + // + // 3 myContext + myContext=new BOPInt_Context; + // + myErrorStatus=0; +} +//======================================================================= +// function: Perform +// purpose: +//======================================================================= + void BOPAlgo_PaveFiller::Perform() +{ + myErrorStatus=0; + // + Init(); + if (myErrorStatus) { + return; + } + // 00 + PerformVV(); + if (myErrorStatus) { + return; + } + // 01 + PerformVE(); + if (myErrorStatus) { + return; + } + // + myDS->UpdatePaveBlocks(); + // 11 + PerformEE(); + if (myErrorStatus) { + return; + } + // 02 + PerformVF(); + if (myErrorStatus) { + return; + } + // 12 + PerformEF(); + if (myErrorStatus) { + return; + } + // + MakeSplitEdges(); + if (myErrorStatus) { + return; + } + // + myDS->RefineFaceInfoOn(); + // + // 22 + PerformFF(); + if (myErrorStatus) { + return; + } + // + MakeBlocks(); + if (myErrorStatus) { + return; + } + // + MakePCurves(); + if (myErrorStatus) { + return; + } + // + ProcessDE(); + if (myErrorStatus) { + return; + } + // +} diff --git a/src/BOPAlgo/BOPAlgo_PaveFiller_1.cxx b/src/BOPAlgo/BOPAlgo_PaveFiller_1.cxx new file mode 100644 index 0000000000..23dcfa87ba --- /dev/null +++ b/src/BOPAlgo/BOPAlgo_PaveFiller_1.cxx @@ -0,0 +1,146 @@ +// Created by: Peter KURNEV +// Copyright (c) 2010-2012 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 +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#include + +#include +#include + +#include + +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + + +//======================================================================= +// function: PerformVV +// purpose: +//======================================================================= + void BOPAlgo_PaveFiller::PerformVV() +{ + Standard_Boolean bWithSubShape; + Standard_Integer n1, n2, iFlag, nX, n, aSize, i, aNbVV, j, iX; + Handle(NCollection_IncAllocator) aAllocator; + BOPCol_DataMapIteratorOfDataMapOfIntegerListOfInteger aItMILI; + BOPCol_ListIteratorOfListOfInteger aItLI, aItLI2; + TopoDS_Vertex aVn; + BOPDS_ShapeInfo aSIn; + // + myErrorStatus=0; + // + myIterator->Initialize(TopAbs_VERTEX, TopAbs_VERTEX); + aSize=myIterator->ExpectedLength(); + if (!aSize) { + return; + } + // + aSIn.SetShapeType(TopAbs_VERTEX); + + BOPDS_VectorOfInterfVV& aVVs=myDS->InterfVV(); + aVVs.SetStartSize(aSize); + aVVs.SetIncrement(aSize); + aVVs.Init(); + // + //-----------------------------------------------------scope f + aAllocator=new NCollection_IncAllocator(); + BOPCol_DataMapOfIntegerListOfInteger aMILI(100, aAllocator); + BOPCol_DataMapOfIntegerListOfInteger aMBlocks(100, aAllocator); + BOPCol_ListOfShape aLV(aAllocator); + // + // 1. Map V/LV + for (; myIterator->More(); myIterator->Next()) { + myIterator->Value(n1, n2, bWithSubShape); + // + const TopoDS_Vertex& aV1=(*(TopoDS_Vertex *)(&myDS->Shape(n1))); + const TopoDS_Vertex& aV2=(*(TopoDS_Vertex *)(&myDS->Shape(n2))); + // + iFlag=BOPTools_AlgoTools::ComputeVV(aV1, aV2); + if (!iFlag) { + BOPAlgo_Tools::FillMap(n1, n2, aMILI, aAllocator); + } + } + // + // 2. Make blocks + BOPAlgo_Tools::MakeBlocksCnx(aMILI, aMBlocks, aAllocator); + // + // 3. Make vertices + aItMILI.Initialize(aMBlocks); + for (; aItMILI.More(); aItMILI.Next()) { + const BOPCol_ListOfInteger& aLI=aItMILI.Value(); + // + aLV.Clear(); + aItLI.Initialize(aLI); + for (; aItLI.More(); aItLI.Next()) { + nX=aItLI.Value(); + const TopoDS_Shape& aV=myDS->Shape(nX); + aLV.Append(aV); + } + // + BOPTools_AlgoTools::MakeVertex(aLV, aVn); + // + // Appennd new vertex to the DS + aSIn.SetShape(aVn); + n=myDS->Append(aSIn); + // + BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(n); + Bnd_Box& aBox=aSIDS.ChangeBox(); + BRepBndLib::Add(aVn, aBox); + // + // Fill ShapesSD + aItLI.Initialize(aLI); + for (i=0; aItLI.More(); aItLI.Next(), ++i) { + n1=aItLI.Value(); + myDS->AddShapeSD(n1, n); + // + aItLI2.Initialize(aLI); + for (j=0; aItLI2.More(); aItLI2.Next(), ++j) { + if (j>i) { + n2=aItLI2.Value(); + // + myDS->AddInterf(n1, n2); + iX=aVVs.Append()-1; + BOPDS_InterfVV& aVV=aVVs(iX); + aVV.SetIndices(n1, n2); + aVV.SetIndexNew(n); + } + } + } + } + aNbVV=aVVs.Extent(); + // + //-----------------------------------------------------scope t + aLV.Clear(); + aMBlocks.Clear(); + aMILI.Clear(); + aAllocator.Nullify(); +} diff --git a/src/BOPAlgo/BOPAlgo_PaveFiller_2.cxx b/src/BOPAlgo/BOPAlgo_PaveFiller_2.cxx new file mode 100644 index 0000000000..6d0d7bc0ee --- /dev/null +++ b/src/BOPAlgo/BOPAlgo_PaveFiller_2.cxx @@ -0,0 +1,127 @@ +// Created by: Peter KURNEV +// Copyright (c) 2010-2012 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 +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#include + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + + +//======================================================================= +// function: PerformVE +// purpose: +//======================================================================= + void BOPAlgo_PaveFiller::PerformVE() +{ + Standard_Boolean bJustAdd; + Standard_Integer iSize, nV, nE, nVSD, iFlag, nVx, i; + Standard_Real aT, aTolE, aTolV; + BOPDS_Pave aPave; + BOPDS_PassKey aPK; + BOPDS_MapOfPassKey aMPK; + BRep_Builder aBB; + // + myErrorStatus=0; + // + myIterator->Initialize(TopAbs_VERTEX, TopAbs_EDGE); + iSize=myIterator->ExpectedLength(); + if (!iSize) { + return; + } + // + BOPDS_VectorOfInterfVE& aVEs=myDS->InterfVE(); + aVEs.SetStartSize(iSize); + aVEs.SetIncrement(iSize); + aVEs.Init(); + // + for (; myIterator->More(); myIterator->Next()) { + myIterator->Value(nV, nE, bJustAdd); + if(bJustAdd) { + continue; + } + // + const BOPDS_ShapeInfo& aSIE=myDS->ShapeInfo(nE); + if (aSIE.HasSubShape(nV)) { + continue; + } + // + if (aSIE.HasFlag()){ + continue; + } + // + if (myDS->HasInterfSubShapes(nV, nE)) { + continue; + } + // + nVx=nV; + if (myDS->HasShapeSD(nV, nVSD)) { + nVx=nVSD; + } + // + aPK.SetIds(nVx, nE); + if (!aMPK.Add(aPK)) { + continue; + } + // + const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&aSIE.Shape())); + const TopoDS_Vertex& aV=(*(TopoDS_Vertex *)(&myDS->Shape(nVx))); + // + iFlag=myContext->ComputeVE (aV, aE, aT); + if (!iFlag) { + // 1 + i=aVEs.Append()-1; + BOPDS_InterfVE& aVE=aVEs(i); + aVE.SetIndices(nV, nE); + aVE.SetParameter(aT); + // 2 + myDS->AddInterf(nV, nE); + // 3 + BOPDS_ListOfPaveBlock& aLPB=myDS->ChangePaveBlocks(nE); + Handle(BOPDS_PaveBlock)& aPB=*((Handle_BOPDS_PaveBlock*)&aLPB.First()); + // + aPave.SetIndex(nVx); + aPave.SetParameter(aT); + aPB->AppendExtPave(aPave); + //modified by NIZHNY-EMV Wed Dec 07 10:59:42 2011 + 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); + } + //modified by NIZHNY-EMV Wed Dec 07 10:59:43 2011 + } + }//for (; myIterator->More(); myIterator->Next()) { +} diff --git a/src/BOPAlgo/BOPAlgo_PaveFiller_3.cxx b/src/BOPAlgo/BOPAlgo_PaveFiller_3.cxx new file mode 100644 index 0000000000..fe1acfc107 --- /dev/null +++ b/src/BOPAlgo/BOPAlgo_PaveFiller_3.cxx @@ -0,0 +1,708 @@ +// Created by: Peter KURNEV +// Copyright (c) 2010-2012 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 +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#include + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +// +#include +#include +#include +#include +#include +// +#include +// +#include +#include +#include +// +#include +#include +#include +// +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +//======================================================================= +// function: PerformEE +// purpose: +//======================================================================= + void BOPAlgo_PaveFiller::PerformEE() +{ + Standard_Boolean bJustAdd, bOrder; + Standard_Integer i, iX, iSize, nE1, nE2, aDiscretize; + Standard_Integer aNbCPrts, nWhat, nWith; + Standard_Real aTS11, aTS12, aTS21, aTS22; + Standard_Real aTolE1, aTolE2, aDeflection; + TopAbs_ShapeEnum aType; + TopoDS_Edge aEWhat, aEWith; + BOPDS_ListIteratorOfListOfPaveBlock aIt1, aIt2; + Handle(NCollection_IncAllocator) aAllocator; + // + myErrorStatus=0; + // + myIterator->Initialize(TopAbs_EDGE, TopAbs_EDGE); + iSize=myIterator->ExpectedLength(); + if (!iSize) { + return; + } + // + //-----------------------------------------------------scope f + aAllocator=new NCollection_IncAllocator(); + BOPDS_DataMapOfPaveBlockListOfPaveBlock aMPBLPB(100, aAllocator); + BOPDS_DataMapOfShapeCoupleOfPaveBlocks aMVCPB(100, aAllocator); + // + aDiscretize=30; + aDeflection=0.01; + // + BOPDS_VectorOfInterfEE& aEEs=myDS->InterfEE(); + aEEs.SetStartSize(iSize); + aEEs.SetIncrement(iSize); + aEEs.Init(); + // + for (; myIterator->More(); myIterator->Next()) { + myIterator->Value(nE1, nE2, bJustAdd); + if(bJustAdd) { + continue; + } + // + const BOPDS_ShapeInfo& aSIE1=myDS->ShapeInfo(nE1); + if (aSIE1.HasFlag()){ + continue; + } + const BOPDS_ShapeInfo& aSIE2=myDS->ShapeInfo(nE2); + if (aSIE2.HasFlag()){ + continue; + } + // + const TopoDS_Edge& aE1=(*(TopoDS_Edge *)(&aSIE1.Shape())); + const TopoDS_Edge& aE2=(*(TopoDS_Edge *)(&aSIE2.Shape())); + // + aTolE1=BRep_Tool::Tolerance(aE1); + aTolE2=BRep_Tool::Tolerance(aE2); + // + BOPDS_ListOfPaveBlock& aLPB1=myDS->ChangePaveBlocks(nE1); + BOPDS_ListOfPaveBlock& aLPB2=myDS->ChangePaveBlocks(nE2); + // + aIt1.Initialize(aLPB1); + for (; aIt1.More(); aIt1.Next()) { + Bnd_Box aBB1; + // + Handle(BOPDS_PaveBlock)& aPB1=aIt1.ChangeValue(); + if (!aPB1->HasShrunkData()) { + FillShrunkData(aPB1); + if (myErrorStatus) { + return; + } + } + aPB1->ShrunkData(aTS11, aTS12, aBB1); + // + aIt2.Initialize(aLPB2); + for (; aIt2.More(); aIt2.Next()) { + Bnd_Box aBB2; + // + Handle(BOPDS_PaveBlock)& aPB2=aIt2.ChangeValue(); + if (!aPB2->HasShrunkData()) { + FillShrunkData(aPB2); + if (myErrorStatus) { + return; + } + } + aPB2->ShrunkData(aTS21, aTS22, aBB2); + // + if (aBB1.IsOut(aBB2)) { + continue; + } + // + // -----------f + //DEBft + //printf(" nE1=%d nE2=%d\n", nE1, nE2); + // + IntTools_EdgeEdge aEdgeEdge; + // + aEdgeEdge.SetEdge1 (aE1); + aEdgeEdge.SetEdge2 (aE2); + aEdgeEdge.SetTolerance1 (aTolE1); + aEdgeEdge.SetTolerance2 (aTolE2); + aEdgeEdge.SetDiscretize (aDiscretize); + aEdgeEdge.SetDeflection (aDeflection); + // + IntTools_Range aSR1(aTS11, aTS12); + IntTools_Range aSR2(aTS21, aTS22); + IntTools_Range anewSR1 = aSR1; + IntTools_Range anewSR2 = aSR2; + // + BOPTools_AlgoTools::CorrectRange (aE1, aE2, aSR1, anewSR1); + BOPTools_AlgoTools::CorrectRange (aE2, aE1, aSR2, anewSR2); + // + aEdgeEdge.SetRange1(anewSR1); + aEdgeEdge.SetRange2(anewSR2); + // + aEdgeEdge.Perform(); + if (!aEdgeEdge.IsDone()) { + continue; + } + // + bOrder=aEdgeEdge.Order(); + if (!bOrder) { + aEWhat=aE1; + aEWith=aE2; + nWhat=nE1; + nWith=nE2; + } + else { + nWhat=nE2; + nWith=nE1; + aEWhat=aE2; + aEWith=aE1; + } + // + const IntTools_SequenceOfCommonPrts& aCPrts=aEdgeEdge.CommonParts(); + // + aNbCPrts=aCPrts.Length(); + //modified by NIZHNY-EMV Wed Dec 07 14:13:15 2011 + if (aNbCPrts) { + if (myWarningStatus) { + myErrorStatus = 40; + return; + } + } + //modified by NIZHNY-EMV Wed Dec 07 14:13:16 2011 + for (i=1; i<=aNbCPrts; ++i) { + const IntTools_CommonPrt& aCPart=aCPrts(i); + aType=aCPart.Type(); + switch (aType) { + case TopAbs_VERTEX: { + Standard_Boolean bIsOnPave1, bIsOnPave2; + Standard_Real aT1, aT2, aTol; + IntTools_Range aR1, aR2; + TopoDS_Vertex aVnew; + // + BOPInt_Tools::VertexParameters(aCPart, aT1, aT2); + //modified by NIZHNY-EMV Tue Oct 25 10:37:05 2011 + //aTol=10.*Precision::PConfusion(); // Cf=1; 904/C8 + aTol=Precision::Confusion(); + //modified by NIZHNY-EMV Tue Oct 25 10:37:09 2011 + // + //decide to keep the pave or not + aR1 = (bOrder) ? anewSR2 : anewSR1; + aR2 = (bOrder) ? anewSR1 : anewSR2; + // + bIsOnPave1=BOPInt_Tools::IsOnPave(aT1, aR1, aTol); + bIsOnPave2=BOPInt_Tools::IsOnPave(aT2, aR2, aTol); + // + if(bIsOnPave1 || bIsOnPave2) { + continue; + } + // + BOPTools_AlgoTools::MakeNewVertex(aEWhat, aT1, aEWith, aT2, aVnew); + // <-LXBR + { + Standard_Integer nV11, nV12, nV21, nV22, nVS[2], k, j, iFound; + Standard_Real aTolVx, aTolVnew, aD2, aDT2; + BOPCol_MapOfInteger aMV; + gp_Pnt aPnew, aPx; + // + iFound=0; + j=-1; + nV11=aPB1->Pave1().Index(); + nV12=aPB1->Pave2().Index(); + nV21=aPB2->Pave1().Index(); + nV22=aPB2->Pave2().Index(); + aMV.Add(nV11); + aMV.Add(nV12); + // + if (aMV.Contains(nV21)) { + ++j; + nVS[j]=nV21; + } + if (aMV.Contains(nV22)) { + ++j; + nVS[j]=nV22; + } + // + aTolVnew=BRep_Tool::Tolerance(aVnew); + aPnew=BRep_Tool::Pnt(aVnew); + // + for (k=0; k<=j; ++k) { + const TopoDS_Vertex& aVx= *(TopoDS_Vertex*)&(myDS->Shape(nVS[k])); + aTolVx=BRep_Tool::Tolerance(aVx); + aPx=BRep_Tool::Pnt(aVx); + aD2=aPnew.SquareDistance(aPx); + // + aDT2=100.*(aTolVnew+aTolVx)*(aTolVnew+aTolVx); + // + if (aD2AddInterf(nWhat, nWith); + // + BOPDS_CoupleOfPaveBlocks aCPB; + // + aCPB.SetPaveBlocks(aPB1, aPB2); + aCPB.SetIndexInterf(iX); + aMVCPB.Bind(aVnew, aCPB); + }//case TopAbs_VERTEX: + break; + // + case TopAbs_EDGE: { + Standard_Boolean bHasSameBounds; + Standard_Integer aNbComPrt2; + // + aNbComPrt2=aCPart.Ranges2().Length(); + if (aNbComPrt2>1){ + break; + } + //// <-LXBR + bHasSameBounds=aPB1->HasSameBounds(aPB2); + if (!bHasSameBounds) { + break; + } + // 1 + iX=aEEs.Append()-1; + BOPDS_InterfEE& aEE=aEEs(iX); + aEE.SetIndices(nWhat, nWith); + aEE.SetCommonPart(aCPart); + // 2 + myDS->AddInterf(nWhat, nWith); + // + BOPAlgo_Tools::FillMap(aPB1, aPB2, aMPBLPB, aAllocator); + }//case TopAbs_EDGE + break; + default: + break; + }//switch (aType) { + }//for (i=1; i<=aNbCPrts; i++) { + // -----------t + // + }// for (; aIt2.More(); aIt2.Next()) { + }// for (; aIt1.More(); aIt1.Next()) { + } + // + //========================================= + // post treatment + //========================================= + BOPAlgo_Tools::PerformCommonBlocks(aMPBLPB, aAllocator); + PerformVertices(aMVCPB, aAllocator); + //-----------------------------------------------------scope t + aMPBLPB.Clear(); + aMVCPB.Clear(); + aAllocator.Nullify(); +} +//======================================================================= +//function : PerformVertices +//purpose : +//======================================================================= + Standard_Integer BOPAlgo_PaveFiller::PerformVertices + (BOPDS_DataMapOfShapeCoupleOfPaveBlocks& theMVCPB, + Handle(NCollection_BaseAllocator)& theAllocator) +{ + Standard_Integer aNbV, iRet; + // + iRet=0; + aNbV=theMVCPB.Extent(); + if (!aNbV) { + return iRet; + } + // + Standard_Integer nVx, iV, j, nE, iFlag, iX; + Standard_Real aT; + TopoDS_Shape aV; + BOPCol_ListIteratorOfListOfShape aItLS; + BOPCol_ListIteratorOfListOfInteger aItLI; + BOPCol_DataMapIteratorOfDataMapOfShapeListOfShape aItImag; + BOPDS_DataMapIteratorOfDataMapOfShapeCoupleOfPaveBlocks aItMVCPB; + BOPDS_DataMapIteratorOfDataMapOfPaveBlockListOfInteger aItMPBLI; + BOPDS_ListIteratorOfListOfPaveBlock aItLPB; + BOPDS_ShapeInfo aSI; + BOPDS_Pave aPave; + // + BOPDS_DataMapOfPaveBlockListOfInteger aMPBLI(100, theAllocator); + BOPCol_ListOfShape aLS(theAllocator); + BOPCol_DataMapOfShapeInteger aMVI(100, theAllocator); + BOPCol_DataMapOfShapeListOfShape aImages; + // + aSI.SetShapeType(TopAbs_VERTEX); + BOPDS_VectorOfInterfEE& aEEs=myDS->InterfEE(); + // + // 1 prepare arguments + // + // <- DEB + aItMVCPB.Initialize(theMVCPB); + for (; aItMVCPB.More(); aItMVCPB.Next()) { + const TopoDS_Shape& aS=aItMVCPB.Key(); + const BOPDS_CoupleOfPaveBlocks& aCPB=aItMVCPB.Value(); + iV=aCPB.IndexInterf(); + aMVI.Bind(aS, iV); + } + // + // 2 Fuse vertices + TreatNewVertices(aMVI, aImages); + // + // 3 Add new vertices to myDS; + // connect indices to CPB structure + aItImag.Initialize(aImages); + for (; aItImag.More(); aItImag.Next()) { + const TopoDS_Vertex& aV=(*(TopoDS_Vertex*)(&aItImag.Key())); + const BOPCol_ListOfShape& aLVSD=aItImag.Value(); + // + aSI.SetShape(aV); + iV=myDS->Append(aSI); + // + BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(iV); + Bnd_Box& aBox=aSIDS.ChangeBox(); + BRepBndLib::Add(aV, aBox); + // + aItLS.Initialize(aLVSD); + for (; aItLS.More(); aItLS.Next()) { + const TopoDS_Shape& aVx = aItLS.Value(); + BOPDS_CoupleOfPaveBlocks &aCPB=theMVCPB.ChangeFind(aVx); + aCPB.SetIndex(iV); + // update EE interference + iX=aCPB.IndexInterf(); + BOPDS_InterfEE& aEE=aEEs(iX); + aEE.SetIndexNew(iV); + } + } + // + // 4 Map PaveBlock/ListOfVertices to add to this PaveBlock ->aMPBLI + { + Handle(BOPDS_PaveBlock) aPB[2]; + // + aItMVCPB.Initialize(theMVCPB); + for (; aItMVCPB.More(); aItMVCPB.Next()) { + const BOPDS_CoupleOfPaveBlocks& aCPB=aItMVCPB.Value(); + iV=aCPB.Index(); + aCPB.PaveBlocks(aPB[0], aPB[1]); + for (j=0; j<2; ++j) { + if (aMPBLI.IsBound(aPB[j])) { + BOPCol_ListOfInteger& aLI=aMPBLI.ChangeFind(aPB[j]); + aLI.Append(iV); + } + else { + BOPCol_ListOfInteger aLI(theAllocator); + aLI.Append(iV); + aMPBLI.Bind(aPB[j], aLI); + } + } + } + } + // + // 5 + // 5.1 Compute Extra Paves and + // 5.2. Add Extra Paves to the PaveBlocks + aItMPBLI.Initialize(aMPBLI); + for (; aItMPBLI.More(); aItMPBLI.Next()) { + Handle(BOPDS_PaveBlock) aPB=aItMPBLI.Key(); + nE=aPB->OriginalEdge(); + const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&myDS->Shape(nE))); + // 1,2 + const BOPCol_ListOfInteger& aLI=aItMPBLI.Value(); + aItLI.Initialize(aLI); + for (; aItLI.More(); aItLI.Next()) { + nVx=aItLI.Value(); + const TopoDS_Vertex& aVx=(*(TopoDS_Vertex *)(&myDS->Shape(nVx))); + // + iFlag=myContext->ComputeVE (aVx, aE, aT); + if (!iFlag) { + aPave.SetIndex(nVx); + aPave.SetParameter(aT); + aPB->AppendExtPave(aPave); + } + } + } + // 6 Split PaveBlocksa + aItMPBLI.Initialize(aMPBLI); + for (; aItMPBLI.More(); aItMPBLI.Next()) { + Handle(BOPDS_PaveBlock) aPB=aItMPBLI.Key(); + nE=aPB->OriginalEdge(); + // 3 + if (!aPB->IsCommonBlock()) { + myDS->UpdatePaveBlock(aPB); + } + else { + const Handle(BOPDS_CommonBlock)& aCB=aPB->CommonBlock(); + myDS->UpdateCommonBlock(aCB); + } + }//for (; aItMPBLI.More(); aItMPBLI.Next()) { + // + return iRet; +} + +//======================================================================= +//function : TreatNewVertices +//purpose : +//======================================================================= + void BOPAlgo_PaveFiller::TreatNewVertices( + const BOPCol_DataMapOfShapeInteger& aMapVI, + BOPCol_DataMapOfShapeListOfShape& myImages) +{ + Standard_Integer j, i, aNbV, aNbVSD; + Standard_Real aTol; + TopoDS_Shape aVF; + TopoDS_Vertex aVnew; + BOPCol_IndexedMapOfShape aMV, aMVProcessed; + + BOPCol_ListIteratorOfListOfInteger aIt; + BOPCol_DataMapIteratorOfDataMapOfShapeListOfShape aItIm; + BOPCol_DataMapIteratorOfDataMapOfShapeInteger aItMVI; + BOPCol_DataMapOfShapeListOfShape aMVV; + BOPCol_DataMapOfIntegerShape aMIS; + BOPCol_IndexedDataMapOfShapeBox aMSB; + // + BOPDS_BoxBndTreeSelector aSelector; + BOPDS_BoxBndTree aBBTree; + NCollection_UBTreeFiller aTreeFiller(aBBTree); + // + aItMVI.Initialize(aMapVI); + for (; aItMVI.More(); aItMVI.Next()) { + const TopoDS_Shape& aV=aItMVI.Key(); + aMV.Add(aV); + } + // + aNbV = aMV.Extent(); + for (i=1; i<=aNbV; ++i) { + const TopoDS_Shape& aV=aMV(i); + Bnd_Box aBox; + // + aTol=BRep_Tool::Tolerance(*(TopoDS_Vertex*)(&aV)); + aBox.SetGap(aTol); + BRepBndLib::Add(aV, aBox); + // + aTreeFiller.Add(i, aBox); + // + aMIS.Bind(i, aV); + aMSB.Add(aV, aBox); + } + // + aTreeFiller.Fill(); + + // Chains + for (i=1; i<=aNbV; ++i) { + const TopoDS_Shape& aV=aMV(i); + // + if (aMVProcessed.Contains(aV)) { + continue; + } + // + Standard_Integer aNbIP, aIP, aNbIP1, aIP1; + BOPCol_ListOfShape aLVSD; + BOPCol_MapOfInteger aMIP, aMIP1, aMIPC; + BOPCol_MapIteratorOfMapOfInteger aIt1; + // + aMIP.Add(i); + while(1) { + aNbIP=aMIP.Extent(); + aIt1.Initialize(aMIP); + for(; aIt1.More(); aIt1.Next()) { + aIP=aIt1.Key(); + if (aMIPC.Contains(aIP)) { + continue; + } + // + const TopoDS_Shape& aVP=aMIS.Find(aIP); + const Bnd_Box& aBoxVP=aMSB.FindFromKey(aVP); + // + aSelector.Clear(); + aSelector.SetBox(aBoxVP); + // + aNbVSD=aBBTree.Select(aSelector); + if (!aNbVSD) { + continue; // it must not be + } + // + const BOPCol_ListOfInteger& aLI=aSelector.Indices(); + aIt.Initialize(aLI); + for (; aIt.More(); aIt.Next()) { + aIP1=aIt.Value(); + if (aMIP.Contains(aIP1)) { + continue; + } + aMIP1.Add(aIP1); + } //for (; aIt.More(); aIt.Next()) { + }//for(; aIt1.More(); aIt1.Next()) { + // + aNbIP1=aMIP1.Extent(); + if (!aNbIP1) { + break; // from while(1) + } + // + aIt1.Initialize(aMIP); + for(; aIt1.More(); aIt1.Next()) { + aIP=aIt1.Key(); + aMIPC.Add(aIP); + } + // + aMIP.Clear(); + aIt1.Initialize(aMIP1); + for(; aIt1.More(); aIt1.Next()) { + aIP=aIt1.Key(); + aMIP.Add(aIP); + } + aMIP1.Clear(); + }// while(1) + //... + aNbIP=aMIPC.Extent(); + if (!aNbIP) { + aMIPC.Add(i); + } + // + aIt1.Initialize(aMIPC); + for(j=0; aIt1.More(); aIt1.Next(), ++j) { + aIP=aIt1.Key(); + const TopoDS_Shape& aVP=aMIS.Find(aIP); + if (!j) { + aVF=aVP; + } + aLVSD.Append(aVP); + aMVProcessed.Add(aVP); + } + myImages.Bind(aVF, aLVSD); + }// for (i=1; i<=aNbV; ++i) { + + // Make new vertices + aMV.Clear(); + aItIm.Initialize(myImages); + for (; aItIm.More(); aItIm.Next()) { + const TopoDS_Shape& aV=aItIm.Key(); + BOPCol_ListOfShape& aLVSD=aItIm.ChangeValue(); + aNbVSD=aLVSD.Extent(); + if (aNbVSD>1) { + aMV.Add(aV); + BOPTools_AlgoTools::MakeVertex(aLVSD, aVnew); + aMVV.Bind(aVnew, aLVSD); + } + } + // + // UnBind old vertices + aNbV=aMV.Extent(); + for (i=1; i<=aNbV; ++i) { + const TopoDS_Shape& aV=aMV(i); + myImages.UnBind(aV); + } + // + // Bind new vertices + aItIm.Initialize(aMVV); + for (; aItIm.More(); aItIm.Next()) { + const TopoDS_Shape& aV=aItIm.Key(); + const BOPCol_ListOfShape& aLVSD=aItIm.Value(); + myImages.Bind(aV, aLVSD); + } +} + +//======================================================================= +//function : FillShrunkData +//purpose : +//======================================================================= + void BOPAlgo_PaveFiller::FillShrunkData(Handle(BOPDS_PaveBlock)& thePB) +{ + Standard_Integer nE, nV1, nV2, iErr; + Standard_Real aT1, aT2, aTS1, aTS2; + BOPInt_ShrunkRange aSR; + // + myErrorStatus=0; + myWarningStatus = 0; + // + const BOPDS_Pave& aPave1=thePB->Pave1(); + nV1=aPave1.Index(); + aT1=aPave1.Parameter(); + const TopoDS_Vertex& aV1=(*(TopoDS_Vertex *)(&myDS->Shape(nV1))); + // + const BOPDS_Pave& aPave2=thePB->Pave2(); + nV2=aPave2.Index(); + aT2=aPave2.Parameter(); + const TopoDS_Vertex& aV2=(*(TopoDS_Vertex *)(&myDS->Shape(nV2))); + // + nE=thePB->OriginalEdge(); + const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&myDS->Shape(nE))); + // + aSR.SetData(aE, aT1, aT2, aV1, aV2, myContext); + // + aSR.Perform(); + iErr=aSR.ErrorStatus(); + if (iErr) { + //modified by NIZHNY-EMV Wed Dec 07 14:12:10 2011 + if (iErr==6) { + myWarningStatus = 1; + } + //modified by NIZHNY-EMV Wed Dec 07 14:12:12 2011 + //myErrorStatus=40; + return; + } + // + aSR.ShrunkRange(aTS1, aTS2); + const Bnd_Box& aBox=aSR.BndBox(); + // + thePB->SetShrunkData(aTS1, aTS2, aBox); +} + /* + // 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 new file mode 100644 index 0000000000..2afa573c3f --- /dev/null +++ b/src/BOPAlgo/BOPAlgo_PaveFiller_4.cxx @@ -0,0 +1,202 @@ +// Created by: Peter KURNEV +// Copyright (c) 2010-2012 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 +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#include + +#include + +#include +#include +#include + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +//======================================================================= +// function: PerformVF +// purpose: +//======================================================================= + void BOPAlgo_PaveFiller::PerformVF() +{ + Standard_Boolean bJustAdd; + Standard_Integer iSize, nV, nF, nVSD, iFlag, nVx, i; + Standard_Real aT1, aT2; + // + myErrorStatus=0; + // + myIterator->Initialize(TopAbs_VERTEX, TopAbs_FACE); + iSize=myIterator->ExpectedLength(); + if (iSize) { + // + BOPDS_VectorOfInterfVF& aVFs=myDS->InterfVF(); + aVFs.SetStartSize(iSize); + aVFs.SetIncrement(iSize); + aVFs.Init(); + // + for (; myIterator->More(); myIterator->Next()) { + myIterator->Value(nV, nF, bJustAdd); + if(bJustAdd) { + continue; + } + // + if (myDS->IsSubShape(nV, nF)) { + continue; + } + // + if (myDS->HasInterfSubShapes(nV, nF)) { + continue; + } + // + nVx=nV; + if (myDS->HasShapeSD(nV, nVSD)) { + nVx=nVSD; + } + //modified by NIZHNY-EMV Mon Dec 05 10:44:20 2011 + // + if (myDS->HasInterf(nVx, nF)) { + continue; + } + //modified by NIZHNY-EMV Mon Dec 05 10:44:22 2011 + // + const TopoDS_Vertex& aV=(*(TopoDS_Vertex *)(&myDS->Shape(nVx))); + const TopoDS_Face& aF=(*(TopoDS_Face *)(&myDS->Shape(nF))); + // + 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); + } + }// for (; myIterator->More(); myIterator->Next()) { + }// if (iSize) { + else { + iSize=10; + BOPDS_VectorOfInterfVF& aVFs=myDS->InterfVF(); + aVFs.SetStartSize(iSize); + aVFs.SetIncrement(iSize); + aVFs.Init(); + } + // + TreatVerticesEE(); +} + + +//======================================================================= +//function : TreatVerticesEE +//purpose : +//======================================================================= + void BOPAlgo_PaveFiller::TreatVerticesEE() +{ + Standard_Integer i, aNbS, aNbEEs, nF, nV, iFlag; + Standard_Real aT1, aT2; + BOPCol_ListIteratorOfListOfInteger aItLI; + Handle(NCollection_IncAllocator) aAllocator; + // + //-----------------------------------------------------scope_1 f + aAllocator=new NCollection_IncAllocator(); + BOPCol_ListOfInteger aLIV(aAllocator), aLIF(aAllocator); + BOPCol_MapOfInteger aMI(100, aAllocator); + BOPDS_MapOfPaveBlock aMPBF(100, aAllocator); + // + myErrorStatus=0; + // + + aNbS=myDS->NbSourceShapes(); + // + BOPDS_VectorOfInterfEE& aEEs=myDS->InterfEE(); + aNbEEs=aEEs.Extent(); + for (i=0; iNbSourceShapes(); + for (nF=0; nFShapeInfo(nF); + if (aSI.ShapeType()==TopAbs_FACE) { + aLIF.Append(nF); + } + } + if (!aLIF.Extent()) { + aAllocator.Nullify(); + return; + } + //------------------------------------------------------------- + BOPDS_VectorOfInterfVF& aVFs=myDS->InterfVF(); + // + BOPDS_SubIterator aIt(aAllocator); + // + aIt.SetDS(myDS); + aIt.SetSubSet1(aLIF); + aIt.SetSubSet2(aLIV); + aIt.Prepare(); + aIt.Initialize(); + for (; aIt.More(); aIt.Next()) { + aIt.Value(nV, nF); + // + BOPDS_FaceInfo& aFI=myDS->ChangeFaceInfo(nF); + const BOPCol_MapOfInteger& aMVOn=aFI.VerticesOn(); + // + if (!aMVOn.Contains(nV)) { + const TopoDS_Vertex& aV=(*(TopoDS_Vertex *)(&myDS->Shape(nV))); + const TopoDS_Face& aF=(*(TopoDS_Face *)(&myDS->Shape(nF))); + iFlag=myContext->ComputeVF(aV, aF, aT1, aT2); + if (!iFlag) { + // 1 + i=aVFs.Append()-1; + BOPDS_InterfVF& aVF=aVFs(i); + aVF.SetIndices(nV, nF); + aVF.SetUV(aT1, aT2); + // 2 + myDS->AddInterf(nV, nF); + // + BOPCol_MapOfInteger& aMVIn=aFI.ChangeVerticesIn(); + aMVIn.Add(nV); + } + } + } + // + aAllocator.Nullify(); + //-----------------------------------------------------scope_1 t +} diff --git a/src/BOPAlgo/BOPAlgo_PaveFiller_5.cxx b/src/BOPAlgo/BOPAlgo_PaveFiller_5.cxx new file mode 100644 index 0000000000..7cce7405ea --- /dev/null +++ b/src/BOPAlgo/BOPAlgo_PaveFiller_5.cxx @@ -0,0 +1,541 @@ +// Created by: Peter KURNEV +// Copyright (c) 2010-2012 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 +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#include + +#include + +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + + +//======================================================================= +//function : PerformEF +//purpose : +//======================================================================= + void BOPAlgo_PaveFiller::PerformEF() +{ + Standard_Integer iSize; + // + myErrorStatus=0; + // + myIterator->Initialize(TopAbs_EDGE, TopAbs_FACE); + iSize=myIterator->ExpectedLength(); + if (!iSize) { + return; + } + //---------------------------------------------------------------------- + Standard_Boolean bJustAdd; + Standard_Integer nE, nF, aDiscretize, i, aNbCPrts, iX; + Standard_Real aTolE, aTolF, aTS1, aTS2, aDeflection; + Handle(NCollection_IncAllocator) aAllocator; + TopAbs_ShapeEnum aType; + Handle(IntTools_Context) aCtx; + BOPDS_ListIteratorOfListOfPaveBlock aIt; + //-----------------------------------------------------scope f + // + //modified by NIZHNY-EMV Wed Nov 30 12:01:10 2011 + BRep_Builder aBB; + //modified by NIZHNY-EMV Wed Nov 30 12:01:12 2011 + // + aAllocator=new NCollection_IncAllocator(); + + BOPCol_MapOfInteger aMIEFC(100, aAllocator); + BOPDS_DataMapOfShapeCoupleOfPaveBlocks aMVCPB(100, aAllocator); + BOPDS_DataMapOfPaveBlockListOfInteger aMPBLI(100, aAllocator); + // + aDiscretize=35; + aDeflection=0.01; + // + BOPDS_VectorOfInterfEF& aEFs=myDS->InterfEF(); + aEFs.SetStartSize(iSize); + aEFs.SetIncrement(iSize); + aEFs.Init(); + // + for (; myIterator->More(); myIterator->Next()) { + myIterator->Value(nE, nF, bJustAdd); + if(bJustAdd) { + continue; + } + // + const BOPDS_ShapeInfo& aSIE=myDS->ShapeInfo(nE); + if (aSIE.HasFlag()){//degenerated + continue; + } + // + const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&aSIE.Shape())); + const TopoDS_Face& aF=(*(TopoDS_Face *)(&myDS->Shape(nF))); + const Bnd_Box& aBBF=myDS->ShapeInfo(nF).Box(); + // + BOPDS_FaceInfo& aFI=myDS->ChangeFaceInfo(nF); + const BOPDS_MapOfPaveBlock& aMPBF=aFI.PaveBlocksOn(); + const BOPCol_MapOfInteger& aMIFOn=aFI.VerticesOn(); + const BOPCol_MapOfInteger& aMIFIn=aFI.VerticesIn(); + // + aTolE=BRep_Tool::Tolerance(aE); + aTolF=BRep_Tool::Tolerance(aF); + //modified by NIZHNY-EMV Fri Oct 21 14:38:48 2011 + if (aTolE < 1.e-5) { + BRepAdaptor_Curve aBAC(aE); + if (aBAC.GetType() == GeomAbs_BSplineCurve) { + aTolE = 1.e-5; + } + } + //modified by NIZHNY-EMV Fri Oct 21 14:38:50 2011 + // + BOPDS_ListOfPaveBlock& aLPB=myDS->ChangePaveBlocks(nE); + aIt.Initialize(aLPB); + for (; aIt.More(); aIt.Next()) { + Handle(BOPDS_PaveBlock)& aPB=aIt.ChangeValue(); + // + const Handle(BOPDS_PaveBlock)& aPBR=aPB->RealPaveBlock(); + if (aMPBF.Contains(aPBR)) { + continue; + } + // + if (!aPB->HasShrunkData()) { + FillShrunkData(aPB); + if (myErrorStatus) { + return; + } + } + // + Bnd_Box aBBE; + aPB->ShrunkData(aTS1, aTS2, aBBE); + // + if (aBBF.IsOut (aBBE)) { + continue; + } + // + // -----------f + IntTools_EdgeFace aEdgeFace; + // + aEdgeFace.SetEdge (aE); + aEdgeFace.SetFace (aF); + aEdgeFace.SetTolE (aTolE); + aEdgeFace.SetTolF (aTolF); + aEdgeFace.SetDiscretize (aDiscretize); + aEdgeFace.SetDeflection (aDeflection); + aEdgeFace.SetContext(aCtx); + // + IntTools_Range aSR(aTS1, aTS2); + IntTools_Range anewSR=aSR; + // + BOPTools_AlgoTools::CorrectRange(aE, aF, aSR, anewSR); + aEdgeFace.SetRange (anewSR); + // + aEdgeFace.Perform(); + if (!aEdgeFace.IsDone()) { + continue; + } + // + const IntTools_SequenceOfCommonPrts& aCPrts=aEdgeFace.CommonParts(); + aNbCPrts=aCPrts.Length(); + //modified by NIZHNY-EMV Wed Dec 07 14:17:07 2011 + /*if (aNbCPrts) { + if (myWarningStatus) { + myErrorStatus = 40; + return; + } + }*/ + //modified by NIZHNY-EMV Wed Dec 07 14:17:09 2011 + for (i=1; i<=aNbCPrts; ++i) { + const IntTools_CommonPrt& aCPart=aCPrts(i); + aType=aCPart.Type(); + switch (aType) { + case TopAbs_VERTEX: { + Standard_Boolean bIsOnPave1, bIsOnPave2, bV1, bV2; + Standard_Integer nV1, nV2; + Standard_Real aT, aTolToDecide; + TopoDS_Vertex aVnew; + + BOPInt_Tools::VertexParameter(aCPart, aT); + BOPTools_AlgoTools::MakeNewVertex(aE, aT, aF, aVnew); + // + const IntTools_Range& aR=aCPart.Range1(); + aTolToDecide=5.e-8; + bIsOnPave1=BOPInt_Tools::IsOnPave1(anewSR.First(), aR, aTolToDecide); + bIsOnPave2=BOPInt_Tools::IsOnPave1(anewSR.Last() , aR, aTolToDecide); + // + aPB->Indices(nV1, nV2); + // + + //modified by NIZHNY-EMV Thu Mar 31 16:29:33 2011 + if (bIsOnPave1 && bIsOnPave2) { + bV1=CheckFacePaves(nV1, aMIFOn, aMIFIn); + bV2=CheckFacePaves(nV2, aMIFOn, aMIFIn); + if (bV1 && bV2) { + iX=aEFs.Append()-1; + IntTools_CommonPrt aCP = aCPart; + aCP.SetType(TopAbs_EDGE); + BOPDS_InterfEF& aEF=aEFs(iX); + aEF.SetIndices(nE, nF); + aEF.SetCommonPart(aCP); + myDS->AddInterf(nE, nF); + // 3 + BOPAlgo_Tools::FillMap(aPB, nF, aMPBLI, aAllocator); + break; + } + } + //modified by NIZHNY-EMV Thu Mar 31 16:29:34 2011 + if (bIsOnPave1) { + bV1=CheckFacePaves(nV1, aMIFOn, aMIFIn); + if (bV1) { + //modified by NIZHNY-EMV Fri Feb 18 16:37:29 2011 + const TopoDS_Vertex& aV = (*(TopoDS_Vertex *)(&myDS->Shape(nV1))); + BOPTools_AlgoTools::UpdateVertex(aE, aT, aV); + //modified by NIZHNY-EMV Tue Sep 13 11:14:27 2011 + BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(nV1); + Bnd_Box& aBoxDS=aSIDS.ChangeBox(); + BRepBndLib::Add(aV, aBoxDS); + //modified by NIZHNY-EMV Tue Sep 13 11:14:29 2011 + //modified by NIZHNY-EMV Fri Feb 18 16:37:45 2011 + continue; + } + bIsOnPave1=!bIsOnPave1; + } + // + if (bIsOnPave2) { + bV2=CheckFacePaves(nV2, aMIFOn, aMIFIn); + if (bV2) { + //modified by NIZHNY-EMV Fri Feb 18 16:38:34 2011 + const TopoDS_Vertex& aV = (*(TopoDS_Vertex *)(&myDS->Shape(nV2))); + BOPTools_AlgoTools::UpdateVertex(aE, aT, aV); + //modified by NIZHNY-EMV Tue Sep 13 11:14:33 2011 + BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(nV2); + Bnd_Box& aBoxDS=aSIDS.ChangeBox(); + BRepBndLib::Add(aV, aBoxDS); + //modified by NIZHNY-EMV Tue Sep 13 11:14:34 2011 + //modified by NIZHNY-EMV Fri Feb 18 16:38:39 2011 + continue; + } + bIsOnPave2=!bIsOnPave2; + } + // + if (!bIsOnPave1 && !bIsOnPave2) { + if (CheckFacePaves(aVnew, aMIFOn)) { + continue; + } + //modified by NIZHNY-EMV Wed Nov 30 12:01:34 2011 + aBB.UpdateVertex(aVnew, aTolE); + //modified by NIZHNY-EMV Wed Nov 30 12:01:36 2011 + // + aMIEFC.Add(nF); + // 1 + iX=aEFs.Append()-1; + BOPDS_InterfEF& aEF=aEFs(iX); + aEF.SetIndices(nE, nF); + aEF.SetCommonPart(aCPart); + // 2 + myDS->AddInterf(nE, nF); + // 3 + BOPDS_CoupleOfPaveBlocks aCPB; + // + aCPB.SetPaveBlocks(aPB, aPB); + aCPB.SetIndexInterf(iX); + aMVCPB.Bind(aVnew, aCPB); + } + } + break; + case TopAbs_EDGE: { + aMIEFC.Add(nF); + // + // 1 + iX=aEFs.Append()-1; + BOPDS_InterfEF& aEF=aEFs(iX); + aEF.SetIndices(nE, nF); + // + Standard_Boolean aCoinsideFlag; + aCoinsideFlag=BOPTools_AlgoTools::IsBlockInOnFace(anewSR, aF, aE, myContext); + if (!aCoinsideFlag) { + myDS->AddInterf(nE, nF); + break; + } + + aEF.SetCommonPart(aCPart); + // 2 + myDS->AddInterf(nE, nF); + // 3 + BOPAlgo_Tools::FillMap(aPB, nF, aMPBLI, aAllocator); + + } + break; + default: + break; + }//switch (aType) { + }//for (i=1; i<=aNbCPrts; ++i) { + // -----------t + }//for (; aIt.More(); aIt.Next()) { + }//for (; myIterator->More(); myIterator->Next()) { + // + //========================================= + // post treatment + //========================================= + BOPAlgo_Tools::PerformCommonBlocks(aMPBLI, aAllocator); + PerformVertices1(aMVCPB, aAllocator); + // + // Update FaceInfoIn for all faces having EF common parts + BOPCol_MapIteratorOfMapOfInteger aItMI; + aItMI.Initialize(aMIEFC); + for (; aItMI.More(); aItMI.Next()) { + nF=aItMI.Value(); + myDS->UpdateFaceInfoIn(nF); + } + // 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::PerformVertices1 + (BOPDS_DataMapOfShapeCoupleOfPaveBlocks& theMVCPB, + Handle(NCollection_BaseAllocator)& theAllocator) +{ + Standard_Integer aNbV, iRet; + // + iRet=0; + aNbV=theMVCPB.Extent(); + if (!aNbV) { + return iRet; + } + // + Standard_Integer nVx, nVSD, iV, iErr, nE, iFlag, iX; + Standard_Real aT; + TopoDS_Shape aV; + BOPCol_ListIteratorOfListOfShape aItLS; + BOPCol_ListIteratorOfListOfInteger aItLI; + BOPDS_DataMapIteratorOfDataMapOfShapeCoupleOfPaveBlocks aItMVCPB; + BOPDS_DataMapIteratorOfDataMapOfPaveBlockListOfInteger aItMPBLI; + BOPDS_PDS aPDS; + BOPDS_ShapeInfo aSI; + BOPDS_Pave aPave; + // + BOPCol_ListOfShape aLS(theAllocator); + BOPCol_DataMapOfShapeInteger aMVI(100, theAllocator); + BOPDS_DataMapOfPaveBlockListOfInteger aMPBLI(100, theAllocator); + BOPAlgo_PaveFiller aPF(theAllocator); + // + aSI.SetShapeType(TopAbs_VERTEX); + BOPDS_VectorOfInterfEF& aEFs=myDS->InterfEF(); + // + // 1 prepare arguments + aItMVCPB.Initialize(theMVCPB); + for (; aItMVCPB.More(); aItMVCPB.Next()) { + const TopoDS_Shape& aS=aItMVCPB.Key(); + aLS.Append(aS); + } + // + // 2 Fuse vertices + aPF.SetArguments(aLS); + aPF.Perform(); + iErr=aPF.ErrorStatus(); + if (iErr) { + iRet=1; + return iRet; + } + aPDS=aPF.PDS(); + // + // 3 Add new vertices to theDS; + // 4 Map PaveBlock/ListOfVertices to add to this PaveBlock ->aMPBLI + aItLS.Initialize(aLS); + for (; aItLS.More(); aItLS.Next()) { + const TopoDS_Shape& aVx=aItLS.Value(); + nVx=aPDS->Index(aVx); + // + if (aPDS->HasShapeSD(nVx, nVSD)) { + aV=aPDS->Shape(nVSD); + } + else { + aV=aVx; + } + // index of new vertex in theDS -> iV + if (!aMVI.IsBound(aV)) { + aSI.SetShape(aV); + iV=myDS->Append(aSI); + // + BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(iV); + Bnd_Box& aBox=aSIDS.ChangeBox(); + BRepBndLib::Add(aV, aBox); + // + aMVI.Bind(aV, iV); + } + else { + iV=aMVI.Find(aV); + } + // + BOPDS_CoupleOfPaveBlocks &aCPB=theMVCPB.ChangeFind(aVx); + aCPB.SetIndex(iV); + // update EF interference + iX=aCPB.IndexInterf(); + BOPDS_InterfEF& aEF=aEFs(iX); + aEF.SetIndexNew(iV); + // map aMPBLI + const Handle(BOPDS_PaveBlock)& aPB=aCPB.PaveBlock1(); + if (aMPBLI.IsBound(aPB)) { + BOPCol_ListOfInteger& aLI=aMPBLI.ChangeFind(aPB); + aLI.Append(iV); + } + else { + BOPCol_ListOfInteger aLI(theAllocator); + aLI.Append(iV); + aMPBLI.Bind(aPB, aLI); + } + } + // + // 5 + // 5.1 Compute Extra Paves and + // 5.2. Add Extra Paves to the PaveBlocks + aItMPBLI.Initialize(aMPBLI); + for (; aItMPBLI.More(); aItMPBLI.Next()) { + Handle(BOPDS_PaveBlock) aPB=aItMPBLI.Key(); + nE=aPB->OriginalEdge(); + const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&myDS->Shape(nE))); + // + const BOPCol_ListOfInteger& aLI=aItMPBLI.Value(); + aItLI.Initialize(aLI); + for (; aItLI.More(); aItLI.Next()) { + nVx=aItLI.Value(); + const TopoDS_Vertex& aVx=(*(TopoDS_Vertex *)(&myDS->Shape(nVx))); + // + iFlag=myContext->ComputeVE (aVx, aE, aT); + if (!iFlag) { + aPave.SetIndex(nVx); + aPave.SetParameter(aT); + aPB->AppendExtPave(aPave); + } + } + } + // 6 Split PaveBlocksa + aItMPBLI.Initialize(aMPBLI); + for (; aItMPBLI.More(); aItMPBLI.Next()) { + Handle(BOPDS_PaveBlock) aPB=aItMPBLI.Key(); + nE=aPB->OriginalEdge(); + // 3 + if (!aPB->IsCommonBlock()) { + myDS->UpdatePaveBlock(aPB); + } + else { + const Handle(BOPDS_CommonBlock)& aCB=aPB->CommonBlock(); + myDS->UpdateCommonBlock(aCB); + } + }//for (; aItMPBLI.More(); aItMPBLI.Next()) { + // + return iRet; +} +//======================================================================= +// function: CheckFacePaves +// purpose: +//======================================================================= + Standard_Boolean BOPAlgo_PaveFiller::CheckFacePaves (const Standard_Integer nVx, + const BOPCol_MapOfInteger& aMIFOn, + const BOPCol_MapOfInteger& aMIFIn) +{ + Standard_Boolean bRet; + Standard_Integer nV; + BOPCol_MapIteratorOfMapOfInteger aIt; + // + bRet=Standard_False; + // + aIt.Initialize(aMIFOn); + for (; aIt.More(); aIt.Next()) { + nV=aIt.Value(); + if (nV==nVx) { + bRet=!bRet; + return bRet; + } + } + aIt.Initialize(aMIFIn); + for (; aIt.More(); aIt.Next()) { + nV=aIt.Value(); + if (nV==nVx) { + bRet=!bRet; + return bRet; + } + } + // + return bRet; +} +//======================================================================= +// function: CheckFacePaves +// purpose: +//======================================================================= + Standard_Boolean BOPAlgo_PaveFiller::CheckFacePaves (const TopoDS_Vertex& aVnew, + const BOPCol_MapOfInteger& aMIF) +{ + Standard_Boolean bRet; + Standard_Integer nV, iFlag; + BOPCol_MapIteratorOfMapOfInteger aIt; + // + bRet=Standard_True; + // + aIt.Initialize(aMIF); + for (; aIt.More(); aIt.Next()) { + nV=aIt.Value(); + const TopoDS_Vertex& aV=(*(TopoDS_Vertex *)(&myDS->Shape(nV))); + iFlag=BOPTools_AlgoTools::ComputeVV(aVnew, aV); + if (!iFlag) { + return bRet; + } + } + // + return !bRet; +} diff --git a/src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx b/src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx new file mode 100644 index 0000000000..017e7af138 --- /dev/null +++ b/src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx @@ -0,0 +1,1994 @@ +// Created by: Peter KURNEV +// Copyright (c) 2010-2012 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 +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#include + +#include +#include +#include + +#include +#include + +#include +#include + +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + + +static void FindPaveBlocksByFirst(BOPDS_ListOfPaveBlock& aLPBC, + BOPDS_ListOfPaveBlock& aLPB); + +static Standard_Boolean IsMicroEdge(const TopoDS_Edge& aE, + const Handle(BOPInt_Context)& aCtx); + +//======================================================================= +//function : PerformFF +//purpose : +//======================================================================= + void BOPAlgo_PaveFiller::PerformFF() +{ + Standard_Integer iSize; + Standard_Boolean bValid; + // + myErrorStatus=0; + // + myIterator->Initialize(TopAbs_FACE, TopAbs_FACE); + iSize=myIterator->ExpectedLength(); + if (!iSize) { + return; + } + // + Standard_Boolean bJustAdd, bApp, bCompC2D1, bCompC2D2, bIsDone; + Standard_Boolean bToSplit; + Standard_Integer nF1, nF2, aNbCurves, aNbPoints, iX, i, iP, iC, aNbLP; + Standard_Real aApproxTol, aTolR3D, aTolR2D; + // + BOPDS_VectorOfInterfFF& aFFs=myDS->InterfFF(); + aFFs.SetStartSize(iSize); + aFFs.SetIncrement(iSize); + aFFs.Init(); + // + bApp=mySectionAttribute.Approximation(); + bCompC2D1=mySectionAttribute.PCurveOnS1(); + bCompC2D2=mySectionAttribute.PCurveOnS2(); + aApproxTol=1.e-7; + bToSplit = Standard_False; + // + for (; myIterator->More(); myIterator->Next()) { + myIterator->Value(nF1, nF2, bJustAdd); + if(bJustAdd) { + continue; + } + // + const TopoDS_Face& aF1=(*(TopoDS_Face *)(&myDS->Shape(nF1))); + const TopoDS_Face& aF2=(*(TopoDS_Face *)(&myDS->Shape(nF2))); + // + //modified by NIZHNY-EMV Thu Jan 20 16:15:59 2011 + IntTools_FaceFace aFaceFace; + // + IntSurf_ListOfPntOn2S aListOfPnts; + GetListOfEFPnts(nF1, nF2, aListOfPnts); + aNbLP = aListOfPnts.Extent(); + if (aNbLP) { + aFaceFace.SetList(aListOfPnts); + } + //modified by NIZHNY-EMV Thu Jan 20 16:16:06 2011 + + aFaceFace.SetParameters(bApp, bCompC2D1, bCompC2D2, aApproxTol); + // + aFaceFace.Perform(aF1, aF2); + // + bIsDone=aFaceFace.IsDone(); + if (bIsDone) { + aTolR3D=aFaceFace.TolReached3d(); + aTolR2D=aFaceFace.TolReached2d(); + if (aTolR3D < 1.e-7){ + aTolR3D=1.e-7; + } + if (aTolR2D < 1.e-7){ + aTolR2D=1.e-7; + } + // + aFaceFace.PrepareLines3D(bToSplit); + // + const IntTools_SequenceOfCurves& aCvsX=aFaceFace.Lines(); + const IntTools_SequenceOfPntOn2Faces& aPntsX=aFaceFace.Points(); + // + aNbCurves=aCvsX.Length(); + aNbPoints=aPntsX.Length(); + // + myDS->AddInterf(nF1, nF2); + // + iX=aFFs.Append()-1; + BOPDS_InterfFF& aFF=aFFs(iX); + aFF.SetIndices(nF1, nF2); + // + aFF.SetTolR3D(aTolR3D); + aFF.SetTolR2D(aTolR2D); + // + // Curves, Points + aFF.Init(aNbCurves, aNbPoints); + // + // Curves + BOPDS_VectorOfCurve& aVNC=aFF.ChangeCurves(); + for (i=1; i<=aNbCurves; ++i) { + Bnd_Box aBox; + // + const IntTools_Curve& aIC=aCvsX(i); + const Handle(Geom_Curve)& aC3D= aIC.Curve(); + bValid=BOPInt_Tools::CheckCurve(aC3D, aTolR3D, aBox); + if (bValid) { + iC=aVNC.Append()-1; + BOPDS_Curve& aNC=aVNC(iC); + aNC.SetCurve(aIC); + aNC.SetBox(aBox); + } + } + // + // Points + BOPDS_VectorOfPoint& aVNP=aFF.ChangePoints(); + for (i=1; i<=aNbPoints; ++i) { + const IntTools_PntOn2Faces& aPi=aPntsX(i); + const gp_Pnt& aP=aPi.P1().Pnt(); + // + iP=aVNP.Append()-1; + BOPDS_Point& aNP=aVNP(iP); + aNP.SetPnt(aP); + } + //}// if (aNbCs || aNbPs) + }// if (bIsDone) { + else {// 904/L1 + iX=aFFs.Append()-1; + BOPDS_InterfFF& aFF=aFFs(iX); + aFF.SetIndices(nF1, nF2); + aNbCurves=0; + aNbPoints=0; + aFF.Init(aNbCurves, aNbPoints); + } + }// for (; myIterator->More(); myIterator->Next()) { +} +//modified by NIZHNY-EMV Thu Mar 31 14:39:52 2011 +//======================================================================= +//function : MakeBlocks +//purpose : +//======================================================================= + + void BOPAlgo_PaveFiller::MakeBlocks() +{ + Standard_Integer aNbFF; + // + myErrorStatus=0; + // + BOPDS_VectorOfInterfFF& aFFs=myDS->InterfFF(); + aNbFF=aFFs.Extent(); + if (!aNbFF) { + return; + } + // + Standard_Boolean bExist, bValid2D; + Standard_Integer i, nF1, nF2, aNbC, aNbP, j, aSC; + Standard_Integer nV1, nV2, iFlag; + Standard_Real aTolR3D, aTolR2D, aT1, aT2; + Handle(NCollection_IncAllocator) aAllocator; + BOPDS_ListIteratorOfListOfPaveBlock aItLPB; + TopoDS_Edge aES; + // + //-----------------------------------------------------scope f + aAllocator=new NCollection_IncAllocator(); + // + BOPCol_ListOfInteger aLSE(aAllocator); + BOPCol_MapOfInteger aMVOnIn(100, aAllocator), aMF(100, aAllocator), + aMVStick(100,aAllocator); + BOPDS_MapOfPaveBlock aMPBOnIn(100, aAllocator), + aMPBAdd(100, aAllocator); + BOPDS_ListOfPaveBlock aLPB(aAllocator); + BOPDS_DataMapOfShapeCoupleOfPaveBlocks aMSCPB(100, aAllocator); + BOPCol_DataMapOfShapeInteger aMVI(100, aAllocator); + //modified by NIZHNY-EMV Tue Sep 27 08:26:45 2011 + BOPCol_MapOfInteger aMVB; + BOPCol_DataMapOfIntegerListOfInteger aMInterfs; + BOPCol_ListOfInteger aLIEF; + iFlag = 1 + 2 + 4 + 8 + 16; // 2^0 + 2^1 + 2^2 + 2^3 + 2^4 + //modified by NIZHNY-EMV Tue Sep 27 08:26:46 2011 + // + for (i=0; iShape(nF1))); + const TopoDS_Face& aF2=(*(TopoDS_Face *)(&myDS->Shape(nF2))); + // + aTolR3D=aFF.TolR3D(); + aTolR2D=aFF.TolR2D(); + // + // Update face info + if (aMF.Add(nF1)) { + myDS->UpdateFaceInfoOn(nF1); + } + if (aMF.Add(nF2)) { + myDS->UpdateFaceInfoOn(nF2); + } + + BOPDS_FaceInfo& aFI1=myDS->ChangeFaceInfo(nF1); + BOPDS_FaceInfo& aFI2=myDS->ChangeFaceInfo(nF2); + // + aMVOnIn.Clear(); + aMPBOnIn.Clear(); + aMVB.Clear(); + // + myDS->VerticesOnIn(nF1, nF2, aMVOnIn, aMPBOnIn); + myDS->SharedEdges(nF1, nF2, aLSE, aAllocator); + + // 1. Treat Points + for (j=0; jUpdate(aLPB, Standard_False); + //modified by NIZHNY-EMV Tue Oct 25 11:11:23 2011 + Standard_Real aCurveTol; + aCurveTol = aTolR3D; + if (aCurveTol < 1.e-5) { + if (aIC.Type() == GeomAbs_BSplineCurve) { + aCurveTol = 1.e-5; + } + } + //modified by NIZHNY-EMV Tue Oct 25 11:11:25 2011 + // + aItLPB.Initialize(aLPB); + for (; aItLPB.More(); aItLPB.Next()) { + Handle(BOPDS_PaveBlock)& aPB=aItLPB.ChangeValue(); + aPB->Indices(nV1, nV2); + aPB->Range (aT1, aT2); + //modified by NIZHNY-EMV Mon Apr 09 11:36:30 2012 + if (fabs(aT1 - aT2) < Precision::PConfusion()) { + continue; + } + //modified by NIZHNY-EMV Mon Apr 09 11:36:31 2012 + bExist=IsExistingPaveBlock(aPB, aNC, aCurveTol, aMPBOnIn); + if (bExist) { + continue; + } + // + //bExist=IsExistingPaveBlock(aPB, aNC, aTolR3D, aLSE); + bExist=IsExistingPaveBlock(aPB, aNC, aCurveTol, aLSE); + if (bExist) { + continue; + } + // + bValid2D=myContext->IsValidBlockForFaces(aT1, aT2, aIC, aF1, aF2, aTolR3D); + if (!bValid2D) { + continue; + } + // + // Make Edge + const TopoDS_Vertex& aV1=(*(TopoDS_Vertex *)(&myDS->Shape(nV1))); + const TopoDS_Vertex& aV2=(*(TopoDS_Vertex *)(&myDS->Shape(nV2))); + // + BOPTools_AlgoTools::MakeEdge (aIC, aV1, aT1, aV2, aT2, aTolR3D, aES); + if (mySectionAttribute.PCurveOnS1() && mySectionAttribute.PCurveOnS2()) { + BOPTools_AlgoTools::MakePCurve(aES, aF1, aF2, aIC); + } + // + if (IsMicroEdge(aES, myContext)) { + continue; + } + // + // Append the Pave Block to the Curve j + aLPBC.Append(aPB); + // + // Keep info for post treatment + BOPDS_CoupleOfPaveBlocks aCPB; + aCPB.SetIndexInterf(i); + aCPB.SetIndex(j); + aCPB.SetPaveBlock1(aPB); + // + aMSCPB.Bind(aES, aCPB); + aMVI.Bind(aV1, nV1); + aMVI.Bind(aV2, nV2); + aSC++; + } + // + aLPBC.RemoveFirst(); + }//for (j=0; jChangeFaceInfo(nF1); + BOPDS_FaceInfo& aFI2=myDS->ChangeFaceInfo(nF2); + // PaveBlocksSc + BOPDS_VectorOfCurve& aVNC=aFF.ChangeCurves(); + aNbC=aVNC.Extent(); + for (j=0; jInterfFF(); + // + // <-DEB f + // + // 0 + if (aNbS==1) { + aIt.Initialize(theMSCPB); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aS=aIt.Key(); + const BOPDS_CoupleOfPaveBlocks &aCPB=aIt.Value(); + + // + aType=aS.ShapeType(); + if (aType==TopAbs_VERTEX) { + aSI.SetShapeType(aType); + aSI.SetShape(aS); + iV=myDS->Append(aSI); + // + iX=aCPB.IndexInterf(); + iP=aCPB.Index(); + BOPDS_InterfFF& aFF=aFFs(iX); + BOPDS_VectorOfPoint& aVNP=aFF.ChangePoints(); + BOPDS_Point& aNP=aVNP(iP); + aNP.SetIndex(iV); + } + else if (aType==TopAbs_EDGE) { + //modified by NIZHNY-EMV Thu Dec 15 08:32:11 2011 + aPB1=aCPB.PaveBlock1(); + // + if (aPB1->HasEdge()) { + BOPDS_InterfFF& aFF=aFFs(aCPB.IndexInterf()); + BOPDS_VectorOfCurve& aVNC=aFF.ChangeCurves(); + BOPDS_Curve& aNC=aVNC(aCPB.Index()); + BOPDS_ListOfPaveBlock& aLPBC=aNC.ChangePaveBlocks(); + aLPBC.Clear(); + } else { + aSI.SetShapeType(aType); + aSI.SetShape(aS); + iE=myDS->Append(aSI); + // + aPB1->SetEdge(iE); + } + //modified by NIZHNY-EMV Thu Dec 15 08:32:13 2011 + } + return iRet; + } + } + // + // 1 prepare arguments + aIt.Initialize(theMSCPB); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aS=aIt.Key(); + aLS.Append(aS); + } + // + // 2 Fuse shapes + aPF.SetArguments(aLS); + aPF.Perform(); + iErr=aPF.ErrorStatus(); + if (iErr) { + iRet=1; + return iRet; + } + aPDS=aPF.PDS(); + // + aItLS.Initialize(aLS); + for (; aItLS.More(); aItLS.Next()) { + const TopoDS_Shape& aSx=aItLS.Value(); + nSx=aPDS->Index(aSx); + const BOPDS_ShapeInfo& aSIx=aPDS->ShapeInfo(nSx); + // + aType=aSIx.ShapeType(); + // + if (aType==TopAbs_VERTEX) { + if (aPDS->HasShapeSD(nSx, nVSD)) { + aV=aPDS->Shape(nVSD); + } + else { + aV=aSx; + } + // index of new vertex in theDS -> iV + if (!aMVI.IsBound(aV)) { + aSI.SetShapeType(aType); + aSI.SetShape(aV); + iV=myDS->Append(aSI); + // + aMVI.Bind(aV, iV); + } + else { + iV=aMVI.Find(aV); + } + // update FF interference + const BOPDS_CoupleOfPaveBlocks &aCPB=theMSCPB.Find(aSx); + iX=aCPB.IndexInterf(); + iP=aCPB.Index(); + BOPDS_InterfFF& aFF=aFFs(iX); + BOPDS_VectorOfPoint& aVNP=aFF.ChangePoints(); + BOPDS_Point& aNP=aVNP(iP); + aNP.SetIndex(iV); + }//if (aType==TopAbs_VERTEX) { + // + else if (aType==TopAbs_EDGE) { + bHasPaveBlocks=aPDS->HasPaveBlocks(nSx); + if (!bHasPaveBlocks) { + const BOPDS_CoupleOfPaveBlocks &aCPB=theMSCPB.Find(aSx); + aPB1=aCPB.PaveBlock1(); + // + if (aPB1->HasEdge()) { + BOPDS_InterfFF& aFF=aFFs(aCPB.IndexInterf()); + BOPDS_VectorOfCurve& aVNC=aFF.ChangeCurves(); + BOPDS_Curve& aNC=aVNC(aCPB.Index()); + BOPDS_ListOfPaveBlock& aLPBC=aNC.ChangePaveBlocks(); + aItLPB.Initialize(aLPBC); + for (; aItLPB.More(); aItLPB.Next()) { + const Handle(BOPDS_PaveBlock)& aPBC=aItLPB.Value(); + if (aPBC==aPB1) { + aLPBC.Remove(aItLPB); + break; + } + } + } else { + aSI.SetShapeType(aType); + aSI.SetShape(aSx); + iE=myDS->Append(aSI); + // + aPB1->SetEdge(iE); + } + } + else { + const BOPDS_CoupleOfPaveBlocks &aCPB=theMSCPB.Find(aSx); + iX=aCPB.IndexInterf(); + iC=aCPB.Index(); + aPB1=aCPB.PaveBlock1(); + //modified by NIZHNY-EMV Tue Dec 13 15:49:29 2011 + bOld = Standard_False; + if (aPB1->HasEdge()) { + bOld = Standard_True; + } + //modified by NIZHNY-EMV Tue Dec 13 15:49:31 2011 + // + BOPDS_InterfFF& aFF=aFFs(iX); + BOPDS_VectorOfCurve& aVNC=aFF.ChangeCurves(); + BOPDS_Curve& aNC=aVNC(iC); + BOPDS_ListOfPaveBlock& aLPBC=aNC.ChangePaveBlocks(); + // + const BOPDS_ListOfPaveBlock& aLPBx=aPDS->PaveBlocks(nSx); + aNbLPBx=aLPBx.Extent(); + // + if (!bOld || !aNbLPBx) { + aItLPB.Initialize(aLPBC); + for (; aItLPB.More(); aItLPB.Next()) { + const Handle(BOPDS_PaveBlock)& aPBC=aItLPB.Value(); + if (aPBC==aPB1) { + aLPBC.Remove(aItLPB); + break; + } + } + } + // + if (!aNbLPBx) { + //modified by NIZHNY-EMV Mon Dec 12 15:08:01 2011 + if (bOld) { + continue; + } + //modified by NIZHNY-EMV Mon Dec 12 15:08:03 2011 + aE=aSx; + // + if (!aMVI.IsBound(aE)) { + aSI.SetShapeType(aType); + aSI.SetShape(aE); + iE=myDS->Append(aSI); + aMVI.Bind(aE, iE); + } + else { + iE=aMVI.Find(aE); + } + // append new PaveBlock to aLPBC + Handle(BOPDS_PaveBlock) aPBC=new BOPDS_PaveBlock(); + // + aPB1->SetEdge(iE); + aLPBC.Append(aPB1); + } // if (!aNbLPBx) { + // + else { + aItLPB.Initialize(aLPBx); + //modified by NIZHNY-EMV Mon Dec 12 15:08:01 2011 + if (bOld) { + aPave1[0] = aPB1->Pave1(); + aPave1[1] = aPB1->Pave2(); + } + //modified by NIZHNY-EMV Tue Dec 13 16:00:05 2011 + for (; aItLPB.More(); aItLPB.Next()) { + const Handle(BOPDS_PaveBlock)& aPBx=aItLPB.Value(); + const Handle(BOPDS_PaveBlock)& aPBRx=aPBx->RealPaveBlock(); + // + // update vertices of paves + aPave[0]=aPBx->Pave1(); + aPave[1]=aPBx->Pave2(); + for (j=0; j<2; ++j) { + //modified by NIZHNY-EMV Tue Dec 13 15:53:55 2011 + jx = 0; + if (bOld) { + aT = aPave[j].Parameter(); + if (aT == aPave1[0].Parameter()) { + jx = 1; + } else if (aT == aPave1[1].Parameter()) { + jx = 2; + } + // + if (jx) { + iV = aPave1[jx-1].Index(); + } + } + if (!jx) { + //modified by NIZHNY-EMV Tue Dec 13 15:55:35 2011 + nV=aPave[j].Index(); + aV=aPDS->Shape(nV); + // + if (!aMVI.IsBound(aV)) {// index of new vertex in theDS -> iV + aSI.SetShapeType(TopAbs_VERTEX); + aSI.SetShape(aV); + iV=myDS->Append(aSI); + aMVI.Bind(aV, iV); + } + else { + iV=aMVI.Find(aV); + } + } + aPave[j].SetIndex(iV); + } + // + // add edge + aE=aPDS->Shape(aPBRx->Edge()); + // + if (!aMVI.IsBound(aE)) { + aSI.SetShapeType(aType); + aSI.SetShape(aE); + iE=myDS->Append(aSI); + aMVI.Bind(aE, iE); + } + else { + iE=aMVI.Find(aE); + } + // append new PaveBlock to aLPBC + Handle(BOPDS_PaveBlock) aPBC=new BOPDS_PaveBlock(); + // + aPBC->SetPave1(aPave[0]); + aPBC->SetPave2(aPave[1]); + aPBC->SetEdge(iE); + if (bOld) { + aPBC->SetOriginalEdge(aPB1->OriginalEdge()); + } + // + aLPBC.Append(aPBC); + } + } + } + }//else if (aType==TopAbs_EDGE) + }//for (; aItLS.More(); aItLS.Next()) { + return iRet; +} +//======================================================================= +//function : IsExistingVertex +//purpose : +//======================================================================= + 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; + Standard_Real aTolV; + gp_Pnt aPV; + Bnd_Box aBoxP; + BOPCol_MapIteratorOfMapOfInteger aIt; + // + bRet=Standard_True; + // + aBoxP.Add(aP); + aBoxP.Enlarge(theTolR3D); + // + aIt.Initialize(aMVOnIn); + for (; aIt.More(); aIt.Next()) { + Bnd_Box aBoxV; + // + nV=aIt.Value(); + const TopoDS_Vertex& aV=(*(TopoDS_Vertex *)(&myDS->Shape(nV))); + aPV=BRep_Tool::Pnt(aV); + aTolV=BRep_Tool::Tolerance(aV); + aBoxV.Add(aP); + aBoxV.Enlarge(aTolV); + // + if (!aBoxP.IsOut(aBoxV)) { + iFlag=BOPTools_AlgoTools::ComputeVV(aV, aP, theTolR3D); + if (!iFlag) { + return bRet; + } + } + } + return !bRet; +} +//======================================================================= +//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 bRet=Standard_True; + // + if (theLSE.IsEmpty()) { + return !bRet; + } + // + Standard_Real aT1, aT2, aTm, aTx, aTol; + Standard_Integer nE, iFlag; + gp_Pnt aPm; + Bnd_Box aBoxPm; + BOPCol_ListIteratorOfListOfInteger aItLI; + // + thePB->Range(aT1, aT2); + aTm=IntTools_Tools::IntermediatePoint (aT1, aT2); + theNC.Curve().D0(aTm, aPm); + aBoxPm.Add(aPm); + aBoxPm.Enlarge(theTolR3D); + // + aItLI.Initialize(theLSE); + for (; aItLI.More(); aItLI.Next()) { + nE=aItLI.Value(); + const BOPDS_ShapeInfo& aSIE=myDS->ChangeShapeInfo(nE); + const Bnd_Box& aBoxE=aSIE.Box(); + if (!aBoxE.IsOut(aBoxPm)) { + const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&aSIE.Shape())); + //modified by NIZHNY-EMV Tue Dec 27 14:21:07 2011 + aTol = BRep_Tool::Tolerance(aE); + aTol = aTol > theTolR3D ? aTol : theTolR3D; + iFlag=myContext->ComputePE(aPm, aTol, aE, aTx); + //modified by NIZHNY-EMV Tue Dec 27 14:21:08 2011 + if (!iFlag) { + return bRet; + } + } + } + return !bRet; +} + +//modified by NIZHNY-EMV Tue Jul 26 12:47:52 2011 +//======================================================================= +//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) +{ + Standard_Boolean bRet; + Standard_Real aT1, aT2, aTm, aTx; + Standard_Integer nSp, iFlag, nV11, nV12, nV21, nV22; + gp_Pnt aP1, aPm, aP2; + Bnd_Box aBoxP1, aBoxPm, aBoxP2; + BOPDS_MapIteratorOfMapOfPaveBlock aIt; + // + bRet=Standard_True; + const IntTools_Curve& aIC=theNC.Curve(); + // + thePB->Range(aT1, aT2); + thePB->Indices(nV11, nV12); + //first point + aIC.D0(aT1, aP1); + aBoxP1.Add(aP1); + aBoxP1.Enlarge(theTolR3D); + //intermediate point + aTm=IntTools_Tools::IntermediatePoint (aT1, aT2); + aIC.D0(aTm, aPm); + aBoxPm.Add(aPm); + aBoxPm.Enlarge(theTolR3D); + //last point + aIC.D0(aT2, aP2); + aBoxP2.Add(aP2); + aBoxP2.Enlarge(theTolR3D); + // + aIt.Initialize(theMPBOnIn); + for (; aIt.More(); aIt.Next()) { + const Handle(BOPDS_PaveBlock)& aPB=aIt.Value(); + aPB->Indices(nV21, nV22); + nSp=aPB->Edge(); + const BOPDS_ShapeInfo& aSISp=myDS->ChangeShapeInfo(nSp); + const Bnd_Box& aBoxSp=aSISp.Box(); + if (!aBoxSp.IsOut(aBoxP1) && !aBoxSp.IsOut(aBoxPm) && !aBoxSp.IsOut(aBoxP2)) { + const TopoDS_Edge& aSp=(*(TopoDS_Edge *)(&aSISp.Shape())); + iFlag=(nV11 == nV21 || nV11 == nV22) ? 0 : + myContext->ComputePE(aP1, theTolR3D, aSp, aTx); + if (!iFlag) { + iFlag=(nV12 == nV21 || nV12 == nV22) ? 0 : + myContext->ComputePE(aP2, theTolR3D, aSp, aTx); + if (!iFlag) { + iFlag=myContext->ComputePE(aPm, theTolR3D, aSp, aTx); + if (!iFlag) { + return bRet; + } + } + } + } + } + return !bRet; +} +//modified by NIZHNY-EMV Tue Jul 26 12:47:54 2011 + +//======================================================================= +//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) +{ + Standard_Boolean bVF; + Standard_Integer nV, iFlag, nVn, j, aNbEP; + Standard_Real aT[2], aTmin, aTmax, aTV, aTol; + gp_Pnt aP[2]; + TopoDS_Vertex aVn; + BOPDS_ListIteratorOfListOfPave aItLP; + BOPDS_Pave aPn, aPMM[2]; + // + const IntTools_Curve& aIC=aNC.Curve(); + aIC.Bounds(aT[0], aT[1], aP[0], aP[1]); + // + Handle(BOPDS_PaveBlock)& aPB=aNC.ChangePaveBlock1(); + const BOPDS_ListOfPave& aLP=aPB->ExtPaves(); + // + aNbEP=aLP.Extent(); + if (aNbEP) { + aTmin=1.e10; + aTmax=-aTmin; + // + aItLP.Initialize(aLP); + for (; aItLP.More(); aItLP.Next()) { + const BOPDS_Pave& aPv=aItLP.Value(); + aPv.Contents(nV, aTV); + if (aTVaTmax) { + aPMM[1]=aPv; + aTmax=aTV; + } + } + } + // + for (j=0; j<2; ++j) { + //if curve is closed, process only one bound + if (j && aP[1].IsEqual(aP[0], Precision::Confusion())) { + continue; + } + // + iFlag=1; + // + if (aNbEP) { + Bnd_Box aBoxP; + // + aBoxP.Set(aP[j]); + //modified by NIZHNY-EMV Tue Apr 26 15:09:15 2011 + aTol = aTolR3D+Precision::Confusion(); + aBoxP.Enlarge(aTol); + //modified by NIZHNY-EMV Tue Apr 26 15:09:17 2011 + const BOPDS_Pave& aPV=aPMM[j]; + nV=aPV.Index(); + const BOPDS_ShapeInfo& aSIV=myDS->ShapeInfo(nV); + const TopoDS_Vertex& aV=(*(TopoDS_Vertex *)(&aSIV.Shape())); + const Bnd_Box& aBoxV=aSIV.Box(); + if (!aBoxP.IsOut(aBoxV)){ + iFlag=BOPTools_AlgoTools::ComputeVV(aV, aP[j], aTol); + } + } + if (iFlag) { + // 900/L5 + //modified by NIZNHY-PKV Wed Jul 8 13:16:18 2009f + bVF=myContext->IsValidPointForFaces (aP[j], aF1, aF2, aTolR3D); + if (!bVF) { + continue; + } + //modified by NIZNHY-PKV Wed Jul 8 13:16:22 2009t + // + BOPDS_ShapeInfo aSIVn; + // + BOPTools_AlgoTools::MakeNewVertex(aP[j], aTolR3D, aVn); + aSIVn.SetShapeType(TopAbs_VERTEX); + aSIVn.SetShape(aVn); + // + nVn=myDS->Append(aSIVn); + // + aPn.SetIndex(nVn); + aPn.SetParameter(aT[j]); + aPB->AppendExtPave(aPn); + // + aVn=(*(TopoDS_Vertex *)(&myDS->Shape(nVn))); + BOPTools_AlgoTools::UpdateVertex (aIC, aT[j], aVn); + // + BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(nVn); + Bnd_Box& aBoxDS=aSIDS.ChangeBox(); + BRepBndLib::Add(aVn, aBoxDS); + //modified by NIZHNY-EMV Wed Mar 16 13:46:01 2011 + aMVOnIn.Add(nVn); + aMVB.Add(nVn); + //modified by NIZHNY-EMV Tue Apr 12 10:01:51 2011 + } + } +} + +//======================================================================= +//function : PutPaveOnCurve +//purpose : +//======================================================================= + void BOPAlgo_PaveFiller::PutPaveOnCurve(const BOPCol_MapOfInteger& aMVOnIn, + const Standard_Real aTolR3D, + BOPDS_Curve& aNC, + const Standard_Integer nF1, + const Standard_Integer nF2) +{ + Standard_Boolean bIsVertexOnLine, bInBothFaces; + Standard_Integer nV; + Standard_Real aT; + BOPDS_Pave aPave; + // + BOPCol_MapIteratorOfMapOfInteger aIt; + // + Handle(BOPDS_PaveBlock)& aPB=aNC.ChangePaveBlock1(); + const IntTools_Curve& aIC=aNC.Curve(); + const Bnd_Box& aBoxC=aNC.Box(); + // + aIt.Initialize(aMVOnIn); + for (; aIt.More(); aIt.Next()) { + nV=aIt.Value(); + const BOPDS_ShapeInfo& aSIV=myDS->ShapeInfo(nV); + const TopoDS_Vertex& aV=(*(TopoDS_Vertex *)(&aSIV.Shape())); + const Bnd_Box& aBoxV=aSIV.Box(); + + if (aBoxC.IsOut(aBoxV)){ + continue; + } + //modified by NIZHNY-EMV Wed Mar 16 15:38:53 2011 + if (!myDS->IsNewShape(nV)) { + const BOPDS_FaceInfo& aFI1 = myDS->FaceInfo(nF1); + const BOPDS_FaceInfo& aFI2 = myDS->FaceInfo(nF2); + // + bInBothFaces = (aFI1.VerticesOn().Contains(nV) || + aFI1.VerticesIn().Contains(nV))&& + (aFI2.VerticesOn().Contains(nV) || + aFI2.VerticesIn().Contains(nV)); + if (!bInBothFaces) { + continue; + } + } + //modified by NIZHNY-EMV Fri Sep 23 13:20:38 2011 + bIsVertexOnLine=myContext->IsVertexOnLine(aV, aIC, aTolR3D, aT); + if (!bIsVertexOnLine) { + Standard_Real aTolVExt; + BOPCol_MapOfInteger aMI; + // + aTolVExt = BRep_Tool::Tolerance(aV); + // + GetFullFaceMap(nF1, aMI); + GetFullFaceMap(nF2, aMI); + // + ExtendedTolerance(nV, aMI, aTolVExt); + bIsVertexOnLine=myContext->IsVertexOnLine(aV, aTolVExt, aIC, aTolR3D, aT); + } + // + if (bIsVertexOnLine) { + aPave.SetIndex(nV); + aPave.SetParameter(aT); + // + aPB->AppendExtPave(aPave); + // + BOPTools_AlgoTools::UpdateVertex (aIC, aT, aV); + // + BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(nV); + Bnd_Box& aBoxDS=aSIDS.ChangeBox(); + BRepBndLib::Add(aV, aBoxDS); + } + //modified by NIZHNY-EMV Fri Sep 23 13:35:49 2011 + } +} + +//======================================================================= +//function : ExtendedTolerance +//purpose : +//======================================================================= + Standard_Boolean BOPAlgo_PaveFiller::ExtendedTolerance(const Standard_Integer nV, + const BOPCol_MapOfInteger& aMI, + Standard_Real& aTolVExt) +{ + Standard_Boolean bFound = Standard_False; + if (!(myDS->IsNewShape(nV))) { + return bFound; + } + + Standard_Integer i, k, aNbLines; + Standard_Real aT11, aT12, aD1, aD2, aD; + TopoDS_Vertex aV; + gp_Pnt aPV, aP11, aP12; + + aV = (*(TopoDS_Vertex *)(&myDS->Shape(nV))); + aPV=BRep_Tool::Pnt(aV); + // + BOPDS_VectorOfInterfEE& aEEs=myDS->InterfEE(); + BOPDS_VectorOfInterfEF& aEFs=myDS->InterfEF(); + + for (k=0; k<2; ++k) { + aNbLines = !k ? aEEs.Extent() : aEFs.Extent(); + for (i = 0; i < aNbLines; ++i) { + BOPDS_Interf *aInt = !k ? (BOPDS_Interf*) (&aEEs(i)) : + (BOPDS_Interf*) (&aEFs(i)); + if (aInt->IndexNew() == nV) { + if (aMI.Contains(aInt->Index1()) && aMI.Contains(aInt->Index2())) { + const IntTools_CommonPrt& aComPrt = !k ? aEEs(i).CommonPart() : + aEFs(i).CommonPart(); + // + const TopoDS_Edge& aE1=aComPrt.Edge1(); + aComPrt.Range1(aT11, aT12); + BOPTools_AlgoTools::PointOnEdge(aE1, aT11, aP11); + BOPTools_AlgoTools::PointOnEdge(aE1, aT12, aP12); + aD1=aPV.Distance(aP11); + aD2=aPV.Distance(aP12); + aD=(aD1>aD2)? aD1 : aD2; + if (aD>aTolVExt) { + aTolVExt=aD; + } + return !bFound; + }//if (aMI.Contains(aEF.Index1()) && aMI.Contains(aEF.Index2())) { + }//if (aInt->IndexNew() == nV) { + }//for (i = 0; i < aNbLines; ++i) { + }//for (k=0; k<2; ++k) { + + return bFound; +} + +//======================================================================= +//function : GetListOfEFPnts +//purpose : +//======================================================================= + void BOPAlgo_PaveFiller::GetListOfEFPnts(const Standard_Integer nF1, + const Standard_Integer nF2, + IntSurf_ListOfPntOn2S& aListOfPnts) +{ + Standard_Real U1, U2, V1, V2, f, l; + BOPCol_ListOfInteger aLIEF; + BOPCol_ListIteratorOfListOfInteger anItLI; + BOPDS_VectorOfInterfEF& aEFs=myDS->InterfEF(); + + BOPCol_MapOfInteger aMVStick, aMVToCheck; + BOPCol_DataMapOfIntegerListOfInteger aMInterfs; + BOPDS_ListIteratorOfListOfPave aItLP; + Standard_Integer iFlag; + iFlag = 16; //EF only + GetInterfs(nF1, nF2, aMVStick, aMInterfs, iFlag); + if (!aMVStick.Extent()) { + return; + } + + aLIEF = aMInterfs(4); + if (!aLIEF.Extent()) { + return; + } + + anItLI.Initialize(aLIEF); + for (; anItLI.More(); anItLI.Next()) { + Standard_Integer interf = anItLI.Value(); + const BOPDS_InterfEF& aEF = aEFs(interf); + Standard_Integer nE = aEF.Index1(); + Standard_Integer nFOpposite = aEF.Index2(); + IntTools_CommonPrt aCP = aEF.CommonPart(); + Standard_Real aPar = aCP.VertexParameter1(); + + const TopoDS_Edge& aE = (*(TopoDS_Edge*)(&myDS->Shape(nE))); + const TopoDS_Face& aFOpposite = (*(TopoDS_Face*)(&myDS->Shape(nFOpposite))); + + Handle(Geom_Curve) aCurve = BRep_Tool::Curve(aE, f, l); + // + Standard_Integer nF = (nFOpposite == nF1) ? nF2 : nF1; + const TopoDS_Face& aF = (*(TopoDS_Face*)(&myDS->Shape(nF))); + Handle(Geom2d_Curve) aPCurve = BRep_Tool::CurveOnSurface(aE, aF, f, l); + // + GeomAPI_ProjectPointOnSurf& aProj = myContext->ProjPS(aFOpposite); + // + gp_Pnt aPoint; + aCurve->D0(aPar, aPoint); + IntSurf_PntOn2S aPnt; + if(!aPCurve.IsNull()) { + gp_Pnt2d aP2d = aPCurve->Value(aPar); + aProj.Perform(aPoint); + if(aProj.IsDone()) { + aProj.LowerDistanceParameters(U1,V1); + if (nF == nF1) { + aPnt.SetValue(aP2d.X(),aP2d.Y(),U1,V1); + } else { + aPnt.SetValue(U1,V1,aP2d.X(),aP2d.Y()); + } + aListOfPnts.Append(aPnt); + } + } + else { + GeomAPI_ProjectPointOnSurf& aProj1 = myContext->ProjPS(aF); + aProj1.Perform(aPoint); + aProj.Perform(aPoint); + if(aProj1.IsDone() && aProj.IsDone()){ + aProj1.LowerDistanceParameters(U1,V1); + aProj.LowerDistanceParameters(U2,V2); + if (nF == nF1) { + aPnt.SetValue(U1,V1,U2,V2); + } else { + aPnt.SetValue(U2,V2,U1,V1); + } + aListOfPnts.Append(aPnt); + } + } + } +} + +//modified by NIZHNY-EMV Thu Jun 16 15:09:46 2011 +//======================================================================= +//function : ProcessUnUsedVertices +//purpose : +//======================================================================= + void BOPAlgo_PaveFiller::ProcessUnUsedVertices(const Standard_Integer nF1, + const Standard_Integer nF2, + BOPDS_Curve& aNC, + const BOPCol_ListOfInteger& aLIEF) +{ + if (!aLIEF.Extent()) { + return; + } + // + const IntTools_Curve& aIC=aNC.Curve(); + GeomAbs_CurveType aTypeC; + aTypeC=aIC.Type(); + if (!(aTypeC==GeomAbs_BezierCurve || aTypeC==GeomAbs_BSplineCurve)) { + return; + } + // + Standard_Integer nV, interf; + BOPCol_MapOfInteger aMV; + BOPCol_ListIteratorOfListOfInteger aItLI; + // + BOPDS_VectorOfInterfEF& aEFs=myDS->InterfEF(); + aItLI.Initialize(aLIEF); + for (; aItLI.More(); aItLI.Next()) { + interf = aItLI.Value(); + const BOPDS_InterfEF& aEF = aEFs(interf); + nV = aEF.IndexNew(); + aMV.Add(nV); + } + // + RemoveUsedVertices(aNC, aMV); + if (!aMV.Extent()) { + return; + } + // + Standard_Real aDist; + BOPDS_Pave aPave; + + const Handle(Geom_Curve)& aC3D=aIC.Curve(); + Handle(BOPDS_PaveBlock)& aPB = aNC.ChangePaveBlock1(); + + GeomAPI_ProjectPointOnCurve& aProjPT = myContext->ProjPT(aC3D); + + BOPCol_MapIteratorOfMapOfInteger aItMI; + aItMI.Initialize(aMV); + for (; aItMI.More(); aItMI.Next()) { + nV = aItMI.Value(); + const TopoDS_Vertex& aV = (*(TopoDS_Vertex *)(&myDS->Shape(nV))); + gp_Pnt aPV = BRep_Tool::Pnt(aV); + aProjPT.Perform(aPV); + Standard_Integer aNbPoints = aProjPT.NbPoints(); + if (aNbPoints) { + aDist = aProjPT.LowerDistance(); + PutPaveOnCurve(nV, aDist, aNC, aPB); + } + } +} +//modified by NIZHNY-EMV Thu Jun 16 15:09:47 2011 + +//modified by NIZHNY-EMV Fri Sep 23 11:24:21 2011 +//======================================================================= +//function : ProcessUnUsedVertices +//purpose : +//======================================================================= + void BOPAlgo_PaveFiller::ProcessUnUsedVertices(const Standard_Integer nF1, + const Standard_Integer nF2, + BOPDS_Curve& aNC, + BOPCol_MapOfInteger& aMVStick) +{ + RemoveUsedVertices(aNC, aMVStick); + // + if (!aMVStick.Extent()) { + return; + } + // + GeomAbs_SurfaceType aType1, aType2; + const TopoDS_Face& aF1 = (*(TopoDS_Face*)(&myDS->Shape(nF1))); + const TopoDS_Face& aF2 = (*(TopoDS_Face*)(&myDS->Shape(nF2))); + Handle(Geom_Surface) aS1=BRep_Tool::Surface(aF1); + Handle(Geom_Surface) aS2=BRep_Tool::Surface(aF2); + GeomAdaptor_Surface aGAS1(aS1); + GeomAdaptor_Surface aGAS2(aS2); + + // + aType1=aGAS1.GetType(); + aType2=aGAS2.GetType(); + // + if(aType1==GeomAbs_Torus || aType2==GeomAbs_Torus) { + Standard_Integer nV, m, n; + Standard_Real aTC[2], aD, aD2, u, v, aDT2, aScPr, aDScPr; + GeomAbs_CurveType aTypeC; + gp_Pnt aPC[2], aPV; + gp_Dir aDN[2]; + gp_Pnt2d aP2D; + + Handle(Geom2d_Curve) aC2D[2]; + // + aDT2=2e-7; // the rich criteria + aDScPr=5.e-9; // the creasing criteria + // + const IntTools_Curve& aIC=aNC.Curve(); + //Handle(Geom_Curve) aC3D=aIC.Curve(); //DEB + aTypeC=aIC.Type(); + if (aTypeC==GeomAbs_BezierCurve || aTypeC==GeomAbs_BSplineCurve) { + // + aIC.Bounds(aTC[0], aTC[1], aPC[0], aPC[1]); + aC2D[0]=aIC.FirstCurve2d(); + aC2D[1]=aIC.SecondCurve2d(); + if (!aC2D[0].IsNull() && !aC2D[1].IsNull()) { + BOPCol_MapIteratorOfMapOfInteger aItMI, aItMI1; + aItMI.Initialize(aMVStick); + for (; aItMI.More(); aItMI.Next()) { + nV = aItMI.Value(); + const TopoDS_Vertex& aV=*((TopoDS_Vertex*)&myDS->Shape(nV)); + aPV=BRep_Tool::Pnt(aV); + // + for (m=0; m<2; ++m) { + aD2=aPC[m].SquareDistance(aPV); + if (aD2>aDT2) {// no rich + continue; + } + // + for (n=0; n<2; ++n) { + Handle(Geom_Surface)& aS=(!n)? aS1 : aS2; + aC2D[n]->D0(aTC[m], aP2D); + aP2D.Coord(u, v); + BOPTools_AlgoTools3D::GetNormalToSurface(aS, u, v, aDN[n]); + } + // + aScPr=aDN[0]*aDN[1]; + if (aScPr<0.) { + aScPr=-aScPr; + } + aScPr=1.-aScPr; + // + if (aScPr>aDScPr) { + continue; + } + // + // The intersection curve aIC is vanishing curve (the crease) + aD=sqrt(aD2); + // + Handle(BOPDS_PaveBlock)& aPB=aNC.ChangePaveBlock1(); + PutPaveOnCurve(nV, aD, aNC, aPB); + } + }//for (jVU=1; jVU=aNbVU; ++jVU) { + } + }//if (aTypeC==GeomAbs_BezierCurve || aTypeC==GeomAbs_BSplineCurve) { + }//if(aType1==GeomAbs_Torus || aType2==GeomAbs_Torus) { +} +//modified by NIZHNY-EMV Fri Sep 23 11:24:25 2011 + +//modified by NIZHNY-EMV Fri Sep 23 11:19:34 2011 +//======================================================================= +//function : GetInterfs +//purpose : +//======================================================================= + void BOPAlgo_PaveFiller::GetInterfs (const Standard_Integer nF1, + const Standard_Integer nF2, + BOPCol_MapOfInteger& aMVStick, + BOPCol_DataMapOfIntegerListOfInteger& aMInterfs, + const Standard_Integer iFlag) +{ + BOPCol_MapOfInteger aMIF1, aMIF2; + Standard_Integer nV1, nV2, nE1, nE2, nV, nE, nF, nVNew; + // + BOPDS_VectorOfInterfVV& aVVs=myDS->InterfVV(); + BOPDS_VectorOfInterfVE& aVEs=myDS->InterfVE(); + BOPDS_VectorOfInterfEE& aEEs=myDS->InterfEE(); + BOPDS_VectorOfInterfVF& aVFs=myDS->InterfVF(); + BOPDS_VectorOfInterfEF& aEFs=myDS->InterfEF(); + // + Standard_Integer aNbVVs, aNbVEs, aNbEEs, aNbVFs, aNbEFs; + aNbVVs = aVVs.Extent(); + aNbVEs = aVEs.Extent(); + aNbEEs = aEEs.Extent(); + aNbVFs = aVFs.Extent(); + aNbEFs = aEFs.Extent(); + + //collect indexes of all shapes from nF1 and nF2. + GetFullFaceMap(nF1, aMIF1); + GetFullFaceMap(nF2, aMIF2); + //collect VV interferences + if (iFlag & 1) { + BOPCol_ListOfInteger aLVV; + for(Standard_Integer aInt = 0; aInt < aNbVVs; ++aInt) { + const BOPDS_InterfVV& aVV = aVVs(aInt); + nV1 = aVV.Index1(); + nV2 = aVV.Index2(); + if(aMIF1.Contains(nV1) && aMIF2.Contains(nV2) || + aMIF1.Contains(nV2) && aMIF2.Contains(nV1)) { + if (aVV.HasIndexNew()) { + nVNew = aVV.IndexNew(); + aMVStick.Add(nVNew); + aLVV.Append(aInt); + } + } + } + aMInterfs.Bind(0, aLVV); + } + //collect VE interferences + if (iFlag & 2) { + BOPCol_ListOfInteger aLVE; + for(Standard_Integer aInt = 0; aInt < aNbVEs; ++aInt) { + const BOPDS_InterfVE& aVE = aVEs(aInt); + nV = aVE.Index1(); + nE = aVE.Index2(); + if(aMIF1.Contains(nV) && aMIF2.Contains(nE) || + aMIF1.Contains(nE) && aMIF2.Contains(nV)) { + aMVStick.Add(nV); + aLVE.Append(aInt); + } + } + aMInterfs.Bind(1, aLVE); + } + //collect EE interferences + if (iFlag & 4) { + BOPCol_ListOfInteger aLEE; + for(Standard_Integer aInt = 0; aInt < aNbEEs; ++aInt) { + const BOPDS_InterfEE& aEE = aEEs(aInt); + nE1 = aEE.Index1(); + nE2 = aEE.Index2(); + if(aMIF1.Contains(nE1) && aMIF2.Contains(nE2) || + aMIF1.Contains(nE2) && aMIF2.Contains(nE1)) { + IntTools_CommonPrt aCP = aEE.CommonPart(); + if(aCP.Type() == TopAbs_VERTEX) { + nVNew = aEE.IndexNew(); + aMVStick.Add(nVNew); + aLEE.Append(aInt); + } + } + } + aMInterfs.Bind(2, aLEE); + } + //collect VF interferences + if (iFlag & 8) { + BOPCol_ListOfInteger aLVF; + for(Standard_Integer aInt = 0; aInt < aNbVFs; ++aInt) { + const BOPDS_InterfVF& aVF = aVFs(aInt); + nV = aVF.Index1(); + nF = aVF.Index2(); + if(aMIF1.Contains(nV) && aMIF2.Contains(nF) || + aMIF1.Contains(nF) && aMIF2.Contains(nV)) { + aMVStick.Add(nV); + aLVF.Append(aInt); + } + } + aMInterfs.Bind(3, aLVF); + } + //collect EF interferences + if (iFlag & 16) { + BOPCol_ListOfInteger aLEF; + for(Standard_Integer aInt = 0; aInt < aNbEFs; ++aInt) { + const BOPDS_InterfEF& aEF = aEFs(aInt); + nE = aEF.Index1(); + nF = aEF.Index2(); + if(aMIF1.Contains(nE) && aMIF2.Contains(nF) || + aMIF1.Contains(nF) && aMIF2.Contains(nE)) { + IntTools_CommonPrt aCP = aEF.CommonPart(); + if(aCP.Type() == TopAbs_VERTEX) { + nVNew = aEF.IndexNew(); + aMVStick.Add(nVNew); + aLEF.Append(aInt); + } + } + } + aMInterfs.Bind(4, aLEF); + } +} +//modified by NIZHNY-EMV Fri Sep 23 11:19:38 2011 + +//modified by NIZHNY-EMV Fri Sep 23 11:45:24 2011 +//======================================================================= +// function: GetFullFaceMap +// purpose: +//======================================================================= +void BOPAlgo_PaveFiller::GetFullFaceMap(const Standard_Integer nF, + BOPCol_MapOfInteger& aMI) +{ + Standard_Integer nV, nE; + TopoDS_Edge aE; + TopoDS_Vertex aV; + //face + aMI.Add(nF); + //edges + const TopoDS_Face& aF = (*(TopoDS_Face*)(&myDS->Shape(nF))); + TopExp_Explorer anExp(aF, TopAbs_EDGE); + for (; anExp.More(); anExp.Next()) { + aE = (*(TopoDS_Edge *)(&anExp.Current())); + nE = myDS->Index(aE); + aMI.Add(nE); + } + //vertices + TopExp_Explorer anExpV(aF, TopAbs_VERTEX); + for (; anExpV.More(); anExpV.Next()) { + aV = (*(TopoDS_Vertex *)(&anExpV.Current())); + nV = myDS->Index(aV); + aMI.Add(nV); + } +} +//modified by NIZHNY-EMV Fri Sep 23 11:45:20 2011 +//======================================================================= +// function: RemoveUsedVertices +// purpose: +//======================================================================= +void BOPAlgo_PaveFiller::RemoveUsedVertices(BOPDS_Curve& aNC, + BOPCol_MapOfInteger& aMV) +{ + if (!aMV.Extent()) { + return; + } + Standard_Integer nV; + BOPDS_Pave aPave; + BOPDS_ListIteratorOfListOfPave aItLP; + // + Handle(BOPDS_PaveBlock)& aPB=aNC.ChangePaveBlock1(); + const BOPDS_ListOfPave& aLP = aPB->ExtPaves(); + aItLP.Initialize(aLP); + for (;aItLP.More();aItLP.Next()) { + aPave = aItLP.Value(); + nV = aPave.Index(); + aMV.Remove(nV); + } +} +//modified by NIZHNY-EMV Fri Sep 23 12:05:10 2011 +//modified by NIZHNY-EMV Fri Sep 23 13:27:31 2011 +//======================================================================= +//function : PutPaveOnCurve +//purpose : +//======================================================================= + void BOPAlgo_PaveFiller::PutPaveOnCurve(const Standard_Integer nV, + const Standard_Real aTolR3D, + const BOPDS_Curve& aNC, + Handle(BOPDS_PaveBlock)& aPB) +{ + Standard_Boolean bIsVertexOnLine; + Standard_Real aT; + BOPDS_Pave aPave; + // + const TopoDS_Vertex aV = (*(TopoDS_Vertex *)(&myDS->Shape(nV))); + const IntTools_Curve& aIC = aNC.Curve(); + // + bIsVertexOnLine=myContext->IsVertexOnLine(aV, aIC, aTolR3D, aT); + if (bIsVertexOnLine) { + aPave.SetIndex(nV); + aPave.SetParameter(aT); + // + aPB->AppendExtPave(aPave); + // + BOPTools_AlgoTools::UpdateVertex (aIC, aT, aV); + // + BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(nV); + Bnd_Box& aBoxDS=aSIDS.ChangeBox(); + BRepBndLib::Add(aV, aBoxDS); + } +} +//modified by NIZHNY-EMV Fri Sep 23 13:27:32 2011 + +//======================================================================= +//function : ProcessOldPaveBlocks +//purpose : +//======================================================================= + void BOPAlgo_PaveFiller::ProcessExistingPaveBlocks + (const Standard_Integer theInt, + const BOPDS_MapOfPaveBlock& aMPBOnIn, + const BOPCol_MapOfInteger& aMV, + BOPDS_MapOfPaveBlock& aMPB, + BOPDS_DataMapOfShapeCoupleOfPaveBlocks& aMSCPB, + BOPCol_DataMapOfShapeInteger& aMVI) +{ + Standard_Integer nV, nV1, nV2, nE, iFlag, iC; + Standard_Real aT; + BOPCol_MapIteratorOfMapOfInteger aIt; + BOPDS_MapIteratorOfMapOfPaveBlock aItPB; + // + BOPDS_VectorOfInterfFF& aFFs=myDS->InterfFF(); + BOPDS_InterfFF& aFF = aFFs(theInt); + BOPDS_VectorOfCurve& aVC=aFF.ChangeCurves(); + // + aIt.Initialize(aMV); + for (; aIt.More(); aIt.Next()) { + nV = aIt.Value(); + const BOPDS_ShapeInfo& aSIV=myDS->ShapeInfo(nV); + const Bnd_Box& aBoxV=aSIV.Box(); + const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&aSIV.Shape(); + // + aItPB.Initialize(aMPBOnIn); + for (; aItPB.More(); aItPB.Next()) { + const Handle(BOPDS_PaveBlock)& aPB = aItPB.Value(); + if (aMPB.Contains(aPB)) { + continue; + } + nE=aPB->Edge(); + const BOPDS_ShapeInfo& aSIE=myDS->ShapeInfo(nE); + const Bnd_Box& aBoxE=aSIE.Box(); + // + if (!aBoxV.IsOut(aBoxE)) { + const TopoDS_Edge& aE = *(TopoDS_Edge*)&aSIE.Shape(); + // + iFlag=myContext->ComputeVE (aV, aE, aT); + if (!iFlag) { + iC=aVC.Append()-1; + BOPDS_Curve& aNC=aVC(iC); + BOPDS_ListOfPaveBlock& aLPBC = aNC.ChangePaveBlocks(); + // + aMPB.Add(aPB); + aLPBC.Append(aPB); + // + aPB->Indices(nV1, nV2); + const TopoDS_Vertex& aV1=(*(TopoDS_Vertex *)(&myDS->Shape(nV1))); + const TopoDS_Vertex& aV2=(*(TopoDS_Vertex *)(&myDS->Shape(nV2))); + // Keep info for post treatment + BOPDS_CoupleOfPaveBlocks aCPB; + aCPB.SetIndexInterf(theInt); + aCPB.SetIndex(iC); + aCPB.SetPaveBlock1(aPB); + // + aMSCPB.Bind(aE, aCPB); + aMVI.Bind(aV1, nV1); + aMVI.Bind(aV2, nV2); + } + } + } + } +} + +//======================================================================= +//function : UpdateExistingPaveBlocks +//purpose : +//======================================================================= + void BOPAlgo_PaveFiller::UpdateExistingPaveBlocks + (BOPDS_ListOfPaveBlock& aLPBC, + const Standard_Integer nF1, + const Standard_Integer nF2) +{ + if (!aLPBC.Extent()) { + return; + } + // + Standard_Integer nE; + Handle(BOPDS_PaveBlock) aPBf; + aPBf = aLPBC.First(); + nE = aPBf->OriginalEdge(); + if (nE == -1) { + return; + } + // + Handle(BOPDS_PaveBlock) aPB, aPB1, aPB2, aPB2n; + Handle(BOPDS_CommonBlock) aCB; + BOPDS_ListOfPaveBlock aLPB; + BOPDS_ListIteratorOfListOfPaveBlock aIt, aIt1, aIt2; + // + FindPaveBlocksByFirst(aLPBC, aLPB); + if (aLPB.Extent() == 1) { + return; + } + // + aPBf = aLPB.First(); + if (aPBf->IsCommonBlock()) { + const Handle(BOPDS_CommonBlock)& aCB1 = aPBf->CommonBlock(); + const BOPDS_ListOfPaveBlock& aLPB2 = aCB1->PaveBlocks(); + // + // remove old pave blocks + aIt2.Initialize(aLPB2); + for (; aIt2.More(); aIt2.Next()) { + aPB2 = aIt2.Value(); + nE = aPB2->OriginalEdge(); + // + BOPDS_ListOfPaveBlock& aLPB1 = myDS->ChangePaveBlocks(nE); + aIt1.Initialize(aLPB1); + for (; aIt1.More(); aIt1.Next()) { + aPB1 = aIt1.Value(); + if (aPB2 == aPB1) { + aLPB1.Remove(aIt1); + break; + } + } + } + // + //create new pave blocks + aIt.Initialize(aLPB); + for (aIt.Next(); aIt.More(); aIt.Next()) { + aPB = aIt.Value(); + // + aCB = new BOPDS_CommonBlock; + aIt2.Initialize(aLPB2); + for (; aIt2.More(); aIt2.Next()) { + aPB2 = aIt2.Value(); + nE = aPB2->OriginalEdge(); + // + aPB2n = new BOPDS_PaveBlock; + aPB2n->SetPave1(aPB->Pave1()); + aPB2n->SetPave2(aPB->Pave2()); + aPB2n->SetEdge(aPB->Edge()); + aPB2n->SetOriginalEdge(nE); + aCB->AddPaveBlock(aPB2n); + aPB2n->SetCommonBlock(aCB); + myDS->ChangePaveBlocks(nE).Append(aPB2n); + } + aCB->AddFace(nF1); + aCB->AddFace(nF2); + myDS->SortPaveBlocks(aCB); + } + } + // + else { + BOPDS_ListOfPaveBlock& aLPB1 = myDS->ChangePaveBlocks(nE); + aIt1.Initialize(aLPB1); + for (; aIt1.More(); aIt1.Next()) { + aPB1 = aIt1.Value(); + if (aPBf == aPB1) { + aLPB1.Remove(aIt1); + break; + } + } + // + aIt.Initialize(aLPB); + for (aIt.Next(); aIt.More(); aIt.Next()) { + aPB = aIt.Value(); + // + if (IsCommonBlockOnFaces(aPB, nF1, nF2)) { + aCB = new BOPDS_CommonBlock; + aCB->AddPaveBlock(aPB); + aCB->AddFace(nF1); + aCB->AddFace(nF2); + // + aPB->SetCommonBlock(aCB); + } + aLPB1.Append(aPB); + } + } + //update face info + myDS->UpdateFaceInfoOn(nF1); + myDS->UpdateFaceInfoIn(nF1); + // + myDS->UpdateFaceInfoOn(nF2); + myDS->UpdateFaceInfoIn(nF2); +} + +//modified by NIZHNY-EMV Wed Feb 15 10:08:44 2012 +//======================================================================= +// function: PutClosingPaveOnCurve +// purpose: +//======================================================================= + void BOPAlgo_PaveFiller::PutClosingPaveOnCurve(BOPDS_Curve& aNC) +{ + Standard_Boolean bIsClosed, bHasBounds, bAdded; + Standard_Integer nVC, j; + Standard_Real aT[2], aTC, dT, aTx; + gp_Pnt aP[2] ; + BOPDS_Pave aPVx; + BOPDS_ListIteratorOfListOfPave aItLP; + // + const IntTools_Curve& aIC=aNC.Curve(); + const Handle(Geom_Curve)& aC3D=aIC.Curve(); + if(aC3D.IsNull()) { + return; + } + // + bIsClosed=IntTools_Tools::IsClosed(aC3D); + if (!bIsClosed) { + return; + } + // + bHasBounds=aIC.HasBounds (); + if (!bHasBounds){ + return; + } + // + bAdded=Standard_False; + dT=Precision::PConfusion(); + aIC.Bounds (aT[0], aT[1], aP[0], aP[1]); + // + Handle(BOPDS_PaveBlock)& aPB=aNC.ChangePaveBlock1(); + BOPDS_ListOfPave& aLP=aPB->ChangeExtPaves(); + // + aItLP.Initialize(aLP); + for (; aItLP.More() && !bAdded; aItLP.Next()) { + const BOPDS_Pave& aPC=aItLP.Value(); + nVC=aPC.Index(); + aTC=aPC.Parameter(); + // + for (j=0; j<2; ++j) { + if (fabs(aTC-aT[j]) < dT) { + aTx=(!j) ? aT[1] : aT[0]; + aPVx.SetIndex(nVC); + aPVx.SetParameter(aTx); + aLP.Append(aPVx); + // + bAdded=Standard_True; + break; + } + } + } +} +//modified by NIZHNY-EMV Wed Feb 15 10:08:34 2012 + +//======================================================================= +// function: IsCommonOnFaces +// purpose: +//======================================================================= + Standard_Boolean BOPAlgo_PaveFiller::IsCommonBlockOnFaces(const Handle(BOPDS_PaveBlock)& aPB, + const Standard_Integer nF1, + const Standard_Integer nF2) +{ + Standard_Boolean bRet; + Standard_Integer i, j, nV1, nV2; + Standard_Real aT1, aT2, aTm, f, l; + gp_Pnt aP1, aP2, aPm; + BRep_Builder aBB; + // + bRet = Standard_True; + aPB->Indices(nV1, nV2); + // + const TopoDS_Edge& aE = *(TopoDS_Edge*)&myDS->Shape(aPB->Edge()); + Handle(Geom_Curve) aC3D = BRep_Tool::Curve(aE, aT1, aT2); + aTm=IntTools_Tools::IntermediatePoint (aT1, aT2); + // + const TopoDS_Vertex& aV1 = *(TopoDS_Vertex*)&myDS->Shape(nV1); + const TopoDS_Vertex& aV2 = *(TopoDS_Vertex*)&myDS->Shape(nV2); + aC3D->D0(aTm, aPm); + // + TopoDS_Vertex aVm = BRepBuilderAPI_MakeVertex(aPm); + aBB.UpdateVertex(aVm, BRep_Tool::Tolerance(aE)); + // + TopoDS_Vertex aV[3] = {aV1, aVm, aV2}; + // + const TopoDS_Face& aF1=(*(TopoDS_Face *)(&myDS->Shape(nF1))); + const TopoDS_Face& aF2=(*(TopoDS_Face *)(&myDS->Shape(nF2))); + // + for (i = 0; i < 2; ++i) { + const TopoDS_Face& aF = (i == 0) ? aF1 : aF2; + for (j = 0; j < 3; ++j) { + if (bRet) { + bRet = !myContext->ComputeVF(aV[i], aF, f, l) ? bRet : !bRet; + } + } + } + // + return bRet; +} + +//======================================================================= +//function : FindPaveBlocksByFirst +//purpose : +//======================================================================= +void FindPaveBlocksByFirst(BOPDS_ListOfPaveBlock& aLPBC, + BOPDS_ListOfPaveBlock& aLPB) +{ + Standard_Integer nE; + BOPDS_ListIteratorOfListOfPaveBlock aIt; + // + const Handle(BOPDS_PaveBlock)& aPB1 = aLPBC.First(); + nE = aPB1->OriginalEdge(); + aLPB.Append(aPB1); + // + aLPBC.RemoveFirst(); + // + aIt.Initialize(aLPBC); + for (;aIt.More();) { + const Handle(BOPDS_PaveBlock)& aPB = aIt.Value(); + if (aPB->OriginalEdge() == nE) { + aLPB.Append(aPB); + aLPBC.Remove(aIt); + continue; + } + aIt.Next(); + } +} + +//======================================================================= +//function : IsMicroEdge +//purpose : Checks if it is possible to compute shrunk range for the edge . +//======================================================================= +Standard_Boolean IsMicroEdge(const TopoDS_Edge& aE, + const Handle(BOPInt_Context)& aCtx) +{ + Standard_Boolean bRet; + Standard_Integer iErr; + Standard_Real aT1, aT2, aTmp; + Handle(Geom_Curve) aC3D; + TopoDS_Vertex aV1, aV2; + // + bRet=(BRep_Tool::Degenerated(aE) || + !BRep_Tool::IsGeometric(aE)); + if (bRet) { + return bRet; + } + // + aC3D=BRep_Tool::Curve(aE, aT1, aT2); + TopExp::Vertices(aE, aV1, aV2); + aT1=BRep_Tool::Parameter(aV1, aE); + aT2=BRep_Tool::Parameter(aV2, aE); + if (aT2 + +#include + +#include +#include +#include + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +//======================================================================= +// function: MakeSplitEdges +// purpose: +//======================================================================= + void BOPAlgo_PaveFiller::MakeSplitEdges() +{ + Standard_Integer aNbPBP; + // + myErrorStatus=0; + // + BOPDS_VectorOfListOfPaveBlock& aPBP=myDS->ChangePaveBlocksPool(); + aNbPBP=aPBP.Extent(); + if(!aNbPBP) { + return; + } + // + Standard_Boolean bCB,bV1, bV2; + Standard_Integer i, nE, nV1, nV2, nSp, aNbPB, nOrE; + Standard_Real aT1, aT2; + TopoDS_Vertex aV1, aV2; + TopoDS_Edge aE, aSp; + Handle(NCollection_IncAllocator) aAllocator; + BOPDS_ListIteratorOfListOfPaveBlock aItPB, aItPBCB; + Handle(BOPDS_PaveBlock) aPB, aPBx; + + BOPDS_ShapeInfo aSI; + // + aSI.SetShapeType(TopAbs_EDGE); + //-----------------------------------------------------scope f + // + aAllocator=new NCollection_IncAllocator(); + // + BOPDS_MapOfPaveBlock aMPB(100,aAllocator); + // + for (i=0; iOriginalEdge(); + } + //DEBt + if (aNbPB==1) { + aPB=aLPB.First(); + aPB->Indices(nV1, nV2); + bV1=myDS->IsNewShape(nV1); + bV2=myDS->IsNewShape(nV2); + // + if (!(bV1 || bV2)) { + nE=aPB->OriginalEdge(); + aPB->SetEdge(nE); + continue; + } + } + // + aItPB.Initialize(aLPB); + for (; aItPB.More(); aItPB.Next()) { + aPB=aItPB.Value(); + const Handle(BOPDS_CommonBlock)& aCB=aPB->CommonBlock(); + bCB=!aCB.IsNull(); + if (bCB) { + //modified by NIZHNY-EMV Tue Nov 22 10:27:54 2011 + myDS->SortPaveBlocks(aCB); + //modified by NIZHNY-EMV Tue Nov 22 10:27:56 2011 + aPB=aCB->PaveBlock1(); + } + // + if (aMPB.Add(aPB)) { + nE=aPB->OriginalEdge(); + // + const BOPDS_Pave& aPave1=aPB->Pave1(); + aPave1.Contents(nV1, aT1); + // + const BOPDS_Pave& aPave2=aPB->Pave2(); + aPave2.Contents(nV2, aT2); + // + aE=(*(TopoDS_Edge *)(&myDS->Shape(nE))); + aE.Orientation(TopAbs_FORWARD); + // + aV1=(*(TopoDS_Vertex *)(&myDS->Shape(nV1))); + aV1.Orientation(TopAbs_FORWARD); + // + aV2=(*(TopoDS_Vertex *)(&myDS->Shape(nV2))); + aV2.Orientation(TopAbs_REVERSED); + // + BOPTools_AlgoTools::MakeSplitEdge(aE, aV1, aT1, aV2, aT2, aSp); + // + aSI.SetShape(aSp); + // + Bnd_Box& aBox=aSI.ChangeBox(); + BRepBndLib::Add(aSp, aBox); + // + nSp=myDS->Append(aSI); + // + if (bCB) { + aCB->SetEdge(nSp); + } + else { + aPB->SetEdge(nSp); + } + }// if (aMPB.Add(aPB)) { + }// for (; aItPB.More(); aItPB.Next()) { + }// for (i=0; iFaceInfoPool(); + // + aNbFI=aFIP.Extent(); + for (i=0; iShape(nF1))); + aF1F.Orientation(TopAbs_FORWARD); + // In + const BOPDS_MapOfPaveBlock& aMPBIn=aFI.PaveBlocksIn(); + aItMPB.Initialize(aMPBIn); + for(; aItMPB.More(); aItMPB.Next()) { + const Handle(BOPDS_PaveBlock)& aPB=aItMPB.Value(); + nE=aPB->Edge(); + const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&myDS->Shape(nE))); + // + BOPTools_AlgoTools2D::BuildPCurveForEdgeOnFace(aE, aF1F); + } + // On + const BOPDS_MapOfPaveBlock& aMPBOn=aFI.PaveBlocksOn(); + aItMPB.Initialize(aMPBOn); + for(; aItMPB.More(); aItMPB.Next()) { + const Handle(BOPDS_PaveBlock)& aPB=aItMPB.Value(); + if (aPB->IsCommonBlockOnEdge()) { + nE=aPB->Edge(); + const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&myDS->Shape(nE))); + // + BOPTools_AlgoTools2D::BuildPCurveForEdgeOnFace(aE, aF1F); + } + } + } + // + if (!mySectionAttribute.PCurveOnS1() && + !mySectionAttribute.PCurveOnS2()) { + return; + } + // + // 2. Process section edges + BOPDS_VectorOfInterfFF& aFFs=myDS->InterfFF(); + aNbFF=aFFs.Extent(); + for (i=0; iShape(nF1))); + aF1F.Orientation(TopAbs_FORWARD); + aF2F=(*(TopoDS_Face *)(&myDS->Shape(nF2))); + aF2F.Orientation(TopAbs_FORWARD); + // + const BOPDS_VectorOfCurve& aVNC=aFF.Curves(); + aNbC=aVNC.Extent(); + for (k=0; kEdge(); + const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&myDS->Shape(nE))); + // + if (mySectionAttribute.PCurveOnS1()) + BOPTools_AlgoTools2D::BuildPCurveForEdgeOnFace(aE, aF1F); + // + if (mySectionAttribute.PCurveOnS2()) + BOPTools_AlgoTools2D::BuildPCurveForEdgeOnFace(aE, aF2F); + } + } + } +} diff --git a/src/BOPAlgo/BOPAlgo_PaveFiller_8.cxx b/src/BOPAlgo/BOPAlgo_PaveFiller_8.cxx new file mode 100644 index 0000000000..20ed082725 --- /dev/null +++ b/src/BOPAlgo/BOPAlgo_PaveFiller_8.cxx @@ -0,0 +1,379 @@ +// Created by: Peter KURNEV +// Copyright (c) 2010-2012 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 +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#include + +#include + +#include + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + +static + void MakeSplitEdge1 (const TopoDS_Edge& aE, + const TopoDS_Face& aF, + const TopoDS_Vertex& aV1, + const Standard_Real aP1, + const TopoDS_Vertex& aV2, + const Standard_Real aP2, + TopoDS_Edge& aNewEdge); + +//======================================================================= +//function : ProcessDE +//purpose : +//======================================================================= + void BOPAlgo_PaveFiller::ProcessDE() +{ + Standard_Integer nF, aNb, nE, nV, nVSD, aNbPB; + Handle(NCollection_IncAllocator) aAllocator; + Handle(BOPDS_PaveBlock) aPBD; + BOPCol_ListIteratorOfListOfInteger aItLI; + // + myErrorStatus=0; + // + // 1. Find degnerated edges + //-----------------------------------------------------scope f + // + aAllocator=new NCollection_IncAllocator(); + BOPDS_ListOfPaveBlock aLPBOut(aAllocator); + // + aNb=myDS->NbSourceShapes(); + for (nE=0; nEShapeInfo(nE); + if (aSIE.ShapeType()==TopAbs_EDGE) { + if (aSIE.HasFlag(nF)) { + const BOPDS_ShapeInfo& aSIF=myDS->ShapeInfo(nF); + nV=aSIE.SubShapes().First(); + if (myDS->HasShapeSD(nV, nVSD)) { + nV=nVSD; + } + //nV,nE,nF + // + //modified by NIZHNY-EMV Mon Oct 10 08:38:16 2011 + if (aSIF.ShapeType() == TopAbs_FACE) { + //modified by NIZHNY-EMV Mon Oct 10 08:38:16 2011 + // 1. Find PaveBlocks that are go through nV for nF + FindPaveBlocks(nV, nF, aLPBOut); + aNbPB=aLPBOut.Extent(); + if (!aNbPB) { + continue; + } + // + // 2. + BOPDS_ListOfPaveBlock& aLPBD=myDS->ChangePaveBlocks(nE); + aPBD=aLPBD.First(); + // + FillPaves(nV, nE, nF, aLPBOut, aPBD); + // + myDS->UpdatePaveBlock(aPBD); + // + MakeSplitEdge(nE, nF); + // + aLPBOut.Clear(); + } + //modified by NIZHNY-EMV Mon Oct 10 08:39:58 2011 + if (aSIF.ShapeType() == TopAbs_EDGE) { + Standard_Real aTol=1.e-7; + Standard_Integer nEn; + BRep_Builder BB; + const TopoDS_Edge& aDE=(*(TopoDS_Edge *)(&myDS->Shape(nE))); + const TopoDS_Vertex& aVn = (*(TopoDS_Vertex *)(&myDS->Shape(nV))); + // + TopoDS_Edge aE=aDE; + aE.EmptyCopy(); + BB.Add(aE, aVn); + BB.Degenerated(aE, Standard_True); + BB.UpdateEdge(aE, aTol); + BOPDS_ShapeInfo aSI; + aSI.SetShapeType(TopAbs_EDGE); + aSI.SetShape(aE); + nEn=myDS->Append(aSI); + BOPDS_ListOfPaveBlock& aLPBD=myDS->ChangePaveBlocks(nE); + aPBD=aLPBD.First(); + aPBD->SetEdge(nEn); + } + //modified by NIZHNY-EMV Mon Oct 10 08:40:00 2011 + } + } + } +} + +//======================================================================= +//function : FindPaveBlocks +//purpose : +//======================================================================= + void BOPAlgo_PaveFiller::FindPaveBlocks(const Standard_Integer nV, + const Standard_Integer nF, + BOPDS_ListOfPaveBlock& aLPBOut) +{ + Standard_Integer nV1, nV2; + BOPDS_MapIteratorOfMapOfPaveBlock aItMPB; + // + const BOPDS_FaceInfo& aFI=myDS->ChangeFaceInfo(nF); + // In + const BOPDS_MapOfPaveBlock& aMPBIn=aFI.PaveBlocksIn(); + aItMPB.Initialize(aMPBIn); + for(; aItMPB.More(); aItMPB.Next()) { + const Handle(BOPDS_PaveBlock)& aPB=aItMPB.Value(); + aPB->Indices(nV1, nV2); + if (nV==nV1 || nV==nV2) { + aLPBOut.Append(aPB); + } + } + // On + const BOPDS_MapOfPaveBlock& aMPBOn=aFI.PaveBlocksOn(); + aItMPB.Initialize(aMPBOn); + for(; aItMPB.More(); aItMPB.Next()) { + const Handle(BOPDS_PaveBlock)& aPB=aItMPB.Value(); + aPB->Indices(nV1, nV2); + if (nV==nV1 || nV==nV2) { + aLPBOut.Append(aPB); + } + } + // Sections + const BOPDS_MapOfPaveBlock& aMPBSc=aFI.PaveBlocksSc(); + aItMPB.Initialize(aMPBSc); + for(; aItMPB.More(); aItMPB.Next()) { + const Handle(BOPDS_PaveBlock)& aPB=aItMPB.Value(); + aPB->Indices(nV1, nV2); + if (nV==nV1 || nV==nV2) { + aLPBOut.Append(aPB); + } + } +} + +//======================================================================= +//function : MakeSplitEdge +//purpose : +//======================================================================= + void BOPAlgo_PaveFiller::MakeSplitEdge (const Standard_Integer nDE, + const Standard_Integer nDF) +{ + Standard_Integer nSp, nV1, nV2, aNbPB; + Standard_Real aT1, aT2; + TopoDS_Edge aDE, aSp; + TopoDS_Vertex aV1, aV2; + BOPDS_ListIteratorOfListOfPaveBlock aItLPB; + BOPDS_ShapeInfo aSI; + // + aSI.SetShapeType(TopAbs_EDGE); + // + aDE=(*(TopoDS_Edge *)(&myDS->Shape(nDE))); + aDE.Orientation(TopAbs_FORWARD); + // + const TopoDS_Face& aDF=(*(TopoDS_Face *)(&myDS->Shape(nDF))); + // + BOPDS_ListOfPaveBlock& aLPB=myDS->ChangePaveBlocks(nDE); + aNbPB=aLPB.Extent(); + // + aItLPB.Initialize(aLPB); + for (; aItLPB.More(); aItLPB.Next()) { + Handle(BOPDS_PaveBlock)& aPB=aItLPB.ChangeValue(); + // + const BOPDS_Pave& aPave1=aPB->Pave1(); + aPave1.Contents(nV1, aT1); + // + const BOPDS_Pave& aPave2=aPB->Pave2(); + aPave2.Contents(nV2, aT2); + // + if (myDS->IsNewShape(nV1) || aNbPB>1) { + aV1=(*(TopoDS_Vertex *)(&myDS->Shape(nV1))); + aV1.Orientation(TopAbs_FORWARD); + // + aV2=(*(TopoDS_Vertex *)(&myDS->Shape(nV2))); + aV2.Orientation(TopAbs_REVERSED); + // + MakeSplitEdge1(aDE, aDF, aV1, aT1, aV2, aT2, aSp); + // + aSI.SetShape(aSp); + nSp=myDS->Append(aSI); + aPB->SetEdge(nSp); + } + else { + //aPB->SetEdge(nDE); + aLPB.Clear(); + break; + } + } +} + +//======================================================================= +//function : FillPaves +//purpose : +//======================================================================= + void BOPAlgo_PaveFiller::FillPaves(const Standard_Integer nVD, + const Standard_Integer nED, + const Standard_Integer nFD, + const BOPDS_ListOfPaveBlock& aLPBOut, + const Handle(BOPDS_PaveBlock)& aPBD) +{ + Standard_Boolean bXDir, bIsDone, bReject; + Standard_Integer nE, aNbPoints, j; + Standard_Real aTD1, aTD2, aT1, aT2, aTolInter, aX, aDT; + Standard_Real aTolCmp; + gp_Pnt2d aP2d1, aP2d2, aP2D; + gp_Lin2d aLDE; + Handle(Geom2d_Line) aCLDE; + Handle(Geom2d_Curve) aC2DDE1, aC2D; + Handle(Geom2d_TrimmedCurve)aC2DDE; + BOPDS_ListIteratorOfListOfPaveBlock aItLPB; + BOPDS_Pave aPave; + // + aDT=Precision::PConfusion(); + // + aPave.SetIndex(nVD); + // + const TopoDS_Edge& aDE=(*(TopoDS_Edge *)(&myDS->Shape(nED))); + const TopoDS_Face& aDF=(*(TopoDS_Face *)(&myDS->Shape(nFD))); + //aC2DDE + aC2DDE1=BRep_Tool::CurveOnSurface(aDE, aDF, aTD1, aTD2); + aC2DDE=new Geom2d_TrimmedCurve(aC2DDE1, aTD1, aTD2); + //aCLDE + Handle(Geom2d_TrimmedCurve) aCLDET1=Handle(Geom2d_TrimmedCurve)::DownCast(aC2DDE1); + if (aCLDET1.IsNull()) { + aCLDE=Handle(Geom2d_Line)::DownCast(aC2DDE1); + } + else { + Handle(Geom2d_Curve) aBasisCurve=aCLDET1->BasisCurve(); + aCLDE=Handle(Geom2d_Line)::DownCast(aBasisCurve); + } + // + // Choose direction for degenerated edge + aC2DDE->D0(aTD1, aP2d1); + aC2DDE->D0(aTD2, aP2d2); + // + bXDir=Standard_False; + if (fabs(aP2d1.Y()-aP2d2.Y()) < aDT){ + bXDir=!bXDir; + } + // + aItLPB.Initialize(aLPBOut); + for (; aItLPB.More(); aItLPB.Next()) { + const Handle(BOPDS_PaveBlock)& aPB=aItLPB.Value(); + nE=aPB->Edge(); + const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&myDS->Shape(nE))); + aC2D=BRep_Tool::CurveOnSurface(aE, aDF, aT1, aT2); + if (aC2D.IsNull()) { + continue; + } + // + // Intersection + Geom2dAdaptor_Curve aGAC1, aGAC2; + aGAC1.Load(aC2DDE, aTD1, aTD2); + // + Handle(Geom2d_Line) aL2D= Handle(Geom2d_Line)::DownCast(aC2D); + if (!aL2D.IsNull()) { + aGAC2.Load(aC2D); + } + else { + aGAC2.Load(aC2D, aT1, aT2); + } + // + aTolInter=0.001; + aTolCmp=1.414213562*aTolInter+aDT; + Geom2dInt_GInter aGInter(aGAC1, aGAC2, aTolInter, aTolInter); + bIsDone=aGInter.IsDone(); + if(!bIsDone) { + continue; + } + // + aNbPoints=aGInter.NbPoints(); + if (!aNbPoints){ + continue; + } + // + for (j=1; j<=aNbPoints; ++j) { + aP2D=aGInter.Point(j).Value(); + aX=aGInter.Point(j).ParamOnFirst(); + // + if (fabs (aX-aTD1) < aTolCmp || fabs (aX-aTD2) < aTolCmp) { + continue; + } + if (aX < aTD1 || aX > aTD2) { + continue; + } + // + bReject=Standard_False; + if (aPBD->ContainsParameter(aX, aDT)) { + continue; + } + aPave.SetParameter(aX); + aPBD->AppendExtPave1(aPave); + } + }//for (; aItLPB.More(); aItLPB.Next()) { + // + myDS->UpdatePaveBlock(aPBD); +} +//======================================================================= +// function: MakeSplitEdge1 +// purpose: +//======================================================================= + void MakeSplitEdge1 (const TopoDS_Edge& aE, + const TopoDS_Face& aF, + const TopoDS_Vertex& aV1, + const Standard_Real aP1, + const TopoDS_Vertex& aV2, + const Standard_Real aP2, + TopoDS_Edge& aNewEdge) +{ + Standard_Real aTol=1.e-7; + + TopoDS_Edge E=aE; + + E.EmptyCopy(); + BRep_Builder BB; + BB.Add (E, aV1); + BB.Add (E, aV2); + + BB.Range(E, aF, aP1, aP2); + + BB.Degenerated(E, Standard_True); + + BB.UpdateEdge(E, aTol); + aNewEdge=E; +} diff --git a/src/BOPAlgo/BOPAlgo_SectionAttribute.cdl b/src/BOPAlgo/BOPAlgo_SectionAttribute.cdl new file mode 100644 index 0000000000..47ddb39fda --- /dev/null +++ b/src/BOPAlgo/BOPAlgo_SectionAttribute.cdl @@ -0,0 +1,76 @@ +-- Created on: 2002-03-04 +-- Created by: Michael KLOKOV +-- Copyright (c) 2002-2012 OPEN CASCADE SAS +-- +-- The content of this file is subject to the Open CASCADE Technology Public +-- License Version 6.5 (the "License"). You may not use the content of this file +-- except in compliance with the License. Please obtain a copy of the License +-- at http://www.opencascade.org and read it completely before using this file. +-- +-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +-- +-- The Original Code and all software distributed under the License is +-- distributed on an "AS IS" basis, without warranty of any kind, and the +-- Initial Developer hereby disclaims all such warranties, including without +-- limitation, any warranties of merchantability, fitness for a particular +-- purpose or non-infringement. Please see the License for the specific terms +-- and conditions governing the rights and limitations under the License. + + +class SectionAttribute from BOPAlgo + ---Purpose: Class is a container of three flags used + --- by intersection algorithm + --- + +is + + Create(Aproximation : Boolean from Standard = Standard_True; + PCurveOnS1 : Boolean from Standard = Standard_True; + PCurveOnS2 : Boolean from Standard = Standard_True) + returns SectionAttribute from BOPAlgo; + ---Purpose: + --- Initializes me by flags + + Approximation(me: in out; theFlag: Boolean from Standard); + ---Purpose: + --- Modifier + --- + + PCurveOnS1(me: in out; theFlag: Boolean from Standard); + ---Purpose: + --- Modifier + --- + + PCurveOnS2(me: in out; theFlag: Boolean from Standard); + ---Purpose: + --- Modifier + --- + + Approximation(me) + returns Boolean from Standard; + ---C++: inline + ---Purpose: + --- Selector + --- + + PCurveOnS1(me) + returns Boolean from Standard; + ---C++: inline + ---Purpose: + --- Selector + --- + + PCurveOnS2(me) + returns Boolean from Standard; + ---C++: inline + ---Purpose: + --- Selector + --- + +fields + myApproximation : Boolean from Standard; + myPCurve1 : Boolean from Standard; + myPCurve2 : Boolean from Standard; + +end SectionAttribute from BOPAlgo; diff --git a/src/BOPAlgo/BOPAlgo_SectionAttribute.cxx b/src/BOPAlgo/BOPAlgo_SectionAttribute.cxx new file mode 100644 index 0000000000..c394624104 --- /dev/null +++ b/src/BOPAlgo/BOPAlgo_SectionAttribute.cxx @@ -0,0 +1,59 @@ +// Created on: 2002-03-04 +// Created by: Michael KLOKOV +// Copyright (c) 2002-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + + +#include +//======================================================================= +// function: BOPAlgo_SectionAttribute +// purpose: +//======================================================================= +BOPAlgo_SectionAttribute::BOPAlgo_SectionAttribute(const Standard_Boolean Aproximation, + const Standard_Boolean PCurveOnS1, + const Standard_Boolean PCurveOnS2) +{ + myApproximation = Aproximation; + myPCurve1 = PCurveOnS1; + myPCurve2 = PCurveOnS2; +} +//======================================================================= +// function: Approximation +// purpose: +//======================================================================= +void BOPAlgo_SectionAttribute::Approximation(const Standard_Boolean theFlag) +{ + myApproximation = theFlag; +} +//======================================================================= +// function: PCurveOnS1 +// purpose: +//======================================================================= +void BOPAlgo_SectionAttribute::PCurveOnS1(const Standard_Boolean theFlag) +{ + myPCurve1 = theFlag; +} +//======================================================================= +// function: PCurveOnS2 +// purpose: +//======================================================================= +void BOPAlgo_SectionAttribute::PCurveOnS2(const Standard_Boolean theFlag) +{ + myPCurve2 = theFlag; +} + diff --git a/src/BOPAlgo/BOPAlgo_SectionAttribute.lxx b/src/BOPAlgo/BOPAlgo_SectionAttribute.lxx new file mode 100644 index 0000000000..f245a1b105 --- /dev/null +++ b/src/BOPAlgo/BOPAlgo_SectionAttribute.lxx @@ -0,0 +1,45 @@ +// Created on: 2002-03-04 +// Created by: Michael KLOKOV +// Copyright (c) 2002-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + +//======================================================================= +// function:Approximation +// purpose: +//======================================================================= +inline Standard_Boolean BOPAlgo_SectionAttribute::Approximation() const +{ + return myApproximation; +} +//======================================================================= +// function:PCurveOnS1 +// purpose: +//======================================================================= +inline Standard_Boolean BOPAlgo_SectionAttribute::PCurveOnS1() const +{ + return myPCurve1; +} +//======================================================================= +// function:PCurveOnS2 +// purpose: +//======================================================================= +inline Standard_Boolean BOPAlgo_SectionAttribute::PCurveOnS2() const +{ + return myPCurve2; +} + + diff --git a/src/BOPAlgo/BOPAlgo_Tools.cdl b/src/BOPAlgo/BOPAlgo_Tools.cdl new file mode 100644 index 0000000000..526cfe9c5d --- /dev/null +++ b/src/BOPAlgo/BOPAlgo_Tools.cdl @@ -0,0 +1,74 @@ +-- Created by: Peter KURNEV +-- Copyright (c) 1999-2012 OPEN CASCADE SAS +-- +-- The content of this file is subject to the Open CASCADE Technology Public +-- License Version 6.5 (the "License"). You may not use the content of this file +-- except in compliance with the License. Please obtain a copy of the License +-- at http://www.opencascade.org and read it completely before using this file. +-- +-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +-- +-- The Original Code and all software distributed under the License is +-- distributed on an "AS IS" basis, without warranty of any kind, and the +-- Initial Developer hereby disclaims all such warranties, including without +-- limitation, any warranties of merchantability, fitness for a particular +-- purpose or non-infringement. Please see the License for the specific terms +-- and conditions governing the rights and limitations under the License. + + +class Tools from BOPAlgo + + ---Purpose: + +uses + BaseAllocator from BOPCol, + DataMapOfIntegerListOfInteger from BOPCol, + PaveBlock from BOPDS, + DataMapOfPaveBlockListOfPaveBlock from BOPDS, + DataMapOfPaveBlockListOfInteger from BOPDS +--raises + +is + --- + --- static methods + --- + MakeBlocksCnx(myclass; + theMILI :DataMapOfIntegerListOfInteger from BOPCol; + theMBlocks :out DataMapOfIntegerListOfInteger from BOPCol; + theAllocator:out BaseAllocator from BOPCol); + + MakeBlocks(myclass; + theMILI :DataMapOfPaveBlockListOfPaveBlock from BOPDS; + theMBlocks :out DataMapOfPaveBlockListOfPaveBlock from BOPDS; + theAllocator:out BaseAllocator from BOPCol); + + PerformCommonBlocks(myclass; + theMBlocks :out DataMapOfPaveBlockListOfPaveBlock from BOPDS; + theAllocator:out BaseAllocator from BOPCol); + + FillMap(myclass; + tneN1:Integer from Standard; + tneN2:Integer from Standard; + theMILI : out DataMapOfIntegerListOfInteger from BOPCol; + theAllocator: out BaseAllocator from BOPCol); + + + FillMap(myclass; + tnePB1:PaveBlock from BOPDS; + tnePB2:PaveBlock from BOPDS; + theMILI : out DataMapOfPaveBlockListOfPaveBlock from BOPDS; + theAllocator: out BaseAllocator from BOPCol); + + FillMap(myclass; + tnePB1:PaveBlock from BOPDS; + tneF:Integer from Standard; + theMILI : out DataMapOfPaveBlockListOfInteger from BOPDS; + theAllocator: out BaseAllocator from BOPCol); + + PerformCommonBlocks(myclass; + theMBlocks :DataMapOfPaveBlockListOfInteger from BOPDS; + theAllocator:out BaseAllocator from BOPCol); +--fields + +end Tools; diff --git a/src/BOPAlgo/BOPAlgo_Tools.cxx b/src/BOPAlgo/BOPAlgo_Tools.cxx new file mode 100644 index 0000000000..e446043704 --- /dev/null +++ b/src/BOPAlgo/BOPAlgo_Tools.cxx @@ -0,0 +1,349 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + +#include +#include +#include +#include + +//======================================================================= +//function : MakeBlocksCnx +//purpose : +//======================================================================= + void BOPAlgo_Tools::MakeBlocksCnx(const BOPCol_DataMapOfIntegerListOfInteger& aMILI, + BOPCol_DataMapOfIntegerListOfInteger& aMBlocks, + Handle(NCollection_BaseAllocator)& aAllocator) +{ + Standard_Integer aNbV, nV, aNbVS, nVP, nVx, aNbVP, k; + BOPCol_DataMapIteratorOfDataMapOfIntegerListOfInteger aItMILI; + BOPCol_MapIteratorOfMapOfInteger aItMVP; + BOPCol_ListIteratorOfListOfInteger aItLI; + // + BOPCol_MapOfInteger aMVS(100, aAllocator); + BOPCol_MapOfInteger aMEC(100, aAllocator); + BOPCol_MapOfInteger aMVP(100, aAllocator); + BOPCol_MapOfInteger aMVAdd(100, aAllocator); + // + aNbV=aMILI.Extent(); + // + aItMILI.Initialize(aMILI); + for (k=0; aItMILI.More(); aItMILI.Next()) { + aNbVS=aMVS.Extent(); + if (aNbVS==aNbV) { + break; + } + // + nV=aItMILI.Key(); + if (aMVS.Contains(nV)){ + continue; + } + aMVS.Add(nV); + // + aMEC.Clear(); + aMVP.Clear(); + aMVAdd.Clear(); + // + aMVP.Add(nV); + while(1) { + aNbVP=aMVP.Extent(); + aItMVP.Initialize(aMVP); + for (; aItMVP.More(); aItMVP.Next()) { + nVP=aItMVP.Value(); + const BOPCol_ListOfInteger& aLV=aMILI.Find(nVP); + aItLI.Initialize(aLV); + for (; aItLI.More(); aItLI.Next()) { + nVx=aItLI.Value(); + if (aMEC.Contains(nVx)) { + continue; + } + // + aMVS.Add(nVx); + aMEC.Add(nVx); + aMVAdd.Add(nVx); + } + } + // + aNbVP=aMVAdd.Extent(); + if (!aNbVP) { + break; // from while(1) + } + // + aMVP.Clear(); + aItMVP.Initialize(aMVAdd); + for (; aItMVP.More(); aItMVP.Next()) { + aMVP.Add(aItMVP.Value()); + } + aMVAdd.Clear(); + }//while(1) { + // + BOPCol_ListOfInteger aLIx(aAllocator); + // + //aLIx.Append(nV); + aItMVP.Initialize(aMEC); + for (; aItMVP.More(); aItMVP.Next()) { + nVx=aItMVP.Value(); + aLIx.Append(nVx); + } + // + aMBlocks.Bind(k, aLIx); + ++k; + }//for (; aItMILI.More(); aItMILI.Next()) { + aMVAdd.Clear(); + aMVP.Clear(); + aMEC.Clear(); + aMVS.Clear(); +} +//======================================================================= +//function : FillMap +//purpose : +//======================================================================= + void BOPAlgo_Tools::FillMap(const Standard_Integer n1, + const Standard_Integer n2, + BOPCol_DataMapOfIntegerListOfInteger& aMILI, + Handle(NCollection_BaseAllocator)& aAllocator) +{ + if (aMILI.IsBound(n1)) { + BOPCol_ListOfInteger& aLI=aMILI.ChangeFind(n1); + aLI.Append(n2); + } + else { + BOPCol_ListOfInteger aLI(aAllocator); + aLI.Append(n2); + aMILI.Bind(n1, aLI); + } + if (aMILI.IsBound(n2)) { + BOPCol_ListOfInteger& aLI=aMILI.ChangeFind(n2); + aLI.Append(n1); + } + else { + BOPCol_ListOfInteger aLI(aAllocator); + aLI.Append(n1); + aMILI.Bind(n2, aLI); + } +} +//======================================================================= +//function : FillMap +//purpose : +//======================================================================= + void BOPAlgo_Tools::FillMap(const Handle(BOPDS_PaveBlock)& aPB1, + const Handle(BOPDS_PaveBlock)& aPB2, + BOPDS_DataMapOfPaveBlockListOfPaveBlock& aMPBLPB, + Handle(NCollection_BaseAllocator)& aAllocator) +{ + if (aMPBLPB.IsBound(aPB1)) { + BOPDS_ListOfPaveBlock& aLPB=aMPBLPB.ChangeFind(aPB1); + aLPB.Append(aPB2); + } + else { + BOPDS_ListOfPaveBlock aLPB(aAllocator); + aLPB.Append(aPB2); + aMPBLPB.Bind(aPB1, aLPB); + } + if (aMPBLPB.IsBound(aPB2)) { + BOPDS_ListOfPaveBlock& aLPB=aMPBLPB.ChangeFind(aPB2); + aLPB.Append(aPB1); + } + else { + BOPDS_ListOfPaveBlock aLPB(aAllocator); + aLPB.Append(aPB1); + aMPBLPB.Bind(aPB2, aLPB); + } +} +//======================================================================= +//function : FillMap +//purpose : +//======================================================================= + void BOPAlgo_Tools::FillMap(const Handle(BOPDS_PaveBlock)& aPB, + const Standard_Integer nF, + BOPDS_DataMapOfPaveBlockListOfInteger& aMPBLI, + Handle(NCollection_BaseAllocator)& aAllocator) +{ + if (aMPBLI.IsBound(aPB)) { + BOPCol_ListOfInteger& aLI=aMPBLI.ChangeFind(aPB); + aLI.Append(nF); + } + else { + BOPCol_ListOfInteger aLI(aAllocator); + aLI.Append(nF); + aMPBLI.Bind(aPB, aLI); + } +} +//======================================================================= +//function : MakeBlocks +//purpose : +//======================================================================= + void BOPAlgo_Tools::MakeBlocks(const BOPDS_DataMapOfPaveBlockListOfPaveBlock& aMILI, + BOPDS_DataMapOfPaveBlockListOfPaveBlock& aMBlocks, + Handle(NCollection_BaseAllocator)& aAllocator) +{ + Standard_Integer aNbV, aNbVS, aNbVP, k;//nV,nVx,nVP + BOPDS_DataMapIteratorOfDataMapOfPaveBlockListOfPaveBlock aItMILI; + BOPDS_MapIteratorOfMapOfPaveBlock aItMVP; + BOPDS_ListIteratorOfListOfPaveBlock aItLI; + // + BOPDS_MapOfPaveBlock aMVS(100, aAllocator); + BOPDS_MapOfPaveBlock aMEC(100, aAllocator); + BOPDS_MapOfPaveBlock aMVP(100, aAllocator); + BOPDS_MapOfPaveBlock aMVAdd(100, aAllocator); + // + aNbV=aMILI.Extent(); + // + aItMILI.Initialize(aMILI); + for (k=0; aItMILI.More(); aItMILI.Next()) { + aNbVS=aMVS.Extent(); + if (aNbVS==aNbV) { + break; + } + // + const Handle(BOPDS_PaveBlock)& nV=aItMILI.Key(); + if (aMVS.Contains(nV)){ + continue; + } + aMVS.Add(nV); + // + aMEC.Clear(); + aMVP.Clear(); + aMVAdd.Clear(); + // + aMVP.Add(nV); + while(1) { + aNbVP=aMVP.Extent(); + aItMVP.Initialize(aMVP); + for (; aItMVP.More(); aItMVP.Next()) { + const Handle(BOPDS_PaveBlock)& nVP=aItMVP.Value(); + const BOPDS_ListOfPaveBlock& aLV=aMILI.Find(nVP); + aItLI.Initialize(aLV); + for (; aItLI.More(); aItLI.Next()) { + const Handle(BOPDS_PaveBlock)& nVx=aItLI.Value(); + if (aMEC.Contains(nVx)) { + continue; + } + // + aMVS.Add(nVx); + aMEC.Add(nVx); + aMVAdd.Add(nVx); + } + } + // + aNbVP=aMVAdd.Extent(); + if (!aNbVP) { + break; // from while(1) + } + // + aMVP.Clear(); + aItMVP.Initialize(aMVAdd); + for (; aItMVP.More(); aItMVP.Next()) { + aMVP.Add(aItMVP.Value()); + } + aMVAdd.Clear(); + }//while(1) { + // + BOPDS_ListOfPaveBlock aLIx(aAllocator); + // + //aLIx.Append(nV); + aItMVP.Initialize(aMEC); + for (; aItMVP.More(); aItMVP.Next()) { + const Handle(BOPDS_PaveBlock)& nVx=aItMVP.Value(); + aLIx.Append(nVx); + } + // + aMBlocks.Bind(aLIx.First(), aLIx); + ++k; + }//for (; aItMILI.More(); aItMILI.Next()) { + aMVAdd.Clear(); + aMVP.Clear(); + aMEC.Clear(); + aMVS.Clear(); +} +//======================================================================= +//function : PerformCommonBlocks +//purpose : +//======================================================================= + void BOPAlgo_Tools::PerformCommonBlocks(BOPDS_DataMapOfPaveBlockListOfPaveBlock& aMPBLPB, + Handle(NCollection_BaseAllocator)& aAllocator) +{ + Standard_Integer aNbCB; + // + aNbCB=aMPBLPB.Extent(); + if (!aNbCB) { + return; + } + // + Standard_Integer aNbPB; + BOPDS_DataMapIteratorOfDataMapOfPaveBlockListOfPaveBlock aItMPBLPB; + BOPDS_ListIteratorOfListOfPaveBlock aItLPB; + Handle(BOPDS_CommonBlock) aCB; + BOPDS_DataMapOfPaveBlockListOfPaveBlock aMBlocks(100, aAllocator); + // + BOPAlgo_Tools::MakeBlocks(aMPBLPB, aMBlocks, aAllocator); + // + aItMPBLPB.Initialize(aMBlocks); + for (; aItMPBLPB.More(); aItMPBLPB.Next()) { + const Handle(BOPDS_PaveBlock)& aPB=aItMPBLPB.Key(); + const BOPDS_ListOfPaveBlock& aLPB=aItMPBLPB.Value(); + aNbPB=aLPB.Extent(); + if (aNbPB>1) { + aCB=new BOPDS_CommonBlock; + // + aItLPB.Initialize(aLPB); + for (; aItLPB.More(); aItLPB.Next()) { + const Handle(BOPDS_PaveBlock)& aPBx=aItLPB.Value(); + aCB->AddPaveBlock(aPBx); + } + // + aItLPB.Initialize(aLPB); + for (; aItLPB.More(); aItLPB.Next()) { + const Handle(BOPDS_PaveBlock)& aPBx=aItLPB.Value(); + aPBx->SetCommonBlock(aCB); + } + }//if (aNbPB>1) { + } +} +//======================================================================= +//function : PerformCommonBlocks +//purpose : +//======================================================================= + void BOPAlgo_Tools::PerformCommonBlocks(const BOPDS_DataMapOfPaveBlockListOfInteger& aMPBLI, + Handle(NCollection_BaseAllocator)& )//aAllocator) +{ + Standard_Integer nF; + BOPDS_DataMapIteratorOfDataMapOfPaveBlockListOfInteger aItMPBLI; + BOPCol_ListIteratorOfListOfInteger aItLI; + Handle(BOPDS_PaveBlock) aPB; + Handle(BOPDS_CommonBlock) aCB; + // + aItMPBLI.Initialize(aMPBLI); + for (; aItMPBLI.More(); aItMPBLI.Next()) { + aPB=aItMPBLI.Key(); + if (aPB->IsCommonBlock()) { + aCB=aPB->CommonBlock(); + } + else { + aCB=new BOPDS_CommonBlock; + aCB->AddPaveBlock(aPB); + } + // + const BOPCol_ListOfInteger& aLI=aItMPBLI.Value(); + aItLI.Initialize(aLI); + for (; aItLI.More(); aItLI.Next()) { + nF=aItLI.Value(); + aCB->AddFace(nF); + } + aPB->SetCommonBlock(aCB); + } +} diff --git a/src/BOPAlgo/BOPAlgo_WireEdgeSet.cdl b/src/BOPAlgo/BOPAlgo_WireEdgeSet.cdl new file mode 100644 index 0000000000..521b443a60 --- /dev/null +++ b/src/BOPAlgo/BOPAlgo_WireEdgeSet.cdl @@ -0,0 +1,80 @@ +-- Created by: Peter KURNEV +-- Copyright (c) 2010-2012 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 +-- +-- The content of this file is subject to the Open CASCADE Technology Public +-- License Version 6.5 (the "License"). You may not use the content of this file +-- except in compliance with the License. Please obtain a copy of the License +-- at http://www.opencascade.org and read it completely before using this file. +-- +-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +-- +-- The Original Code and all software distributed under the License is +-- distributed on an "AS IS" basis, without warranty of any kind, and the +-- Initial Developer hereby disclaims all such warranties, including without +-- limitation, any warranties of merchantability, fitness for a particular +-- purpose or non-infringement. Please see the License for the specific terms +-- and conditions governing the rights and limitations under the License. + + +class WireEdgeSet from BOPAlgo + + ---Purpose: + +uses + Face from TopoDS, + Shape from TopoDS, + ListOfShape from BOPCol, + BaseAllocator from BOPCol + +--raises + +is + Create + returns WireEdgeSet from BOPAlgo; + ---C++: inline + ---C++: alias " virtual ~BOPAlgo_WireEdgeSet();" + + Create (theAllocator: BaseAllocator from BOPCol) + returns WireEdgeSet from BOPAlgo; + ---C++: inline + + Clear(me:out); + ---C++: inline + + SetFace(me:out; + aF:Face from TopoDS); + ---C++: inline + + Face(me) + returns Face from TopoDS; + ---C++: return const & + ---C++: inline + + AddStartElement(me:out; + sS: Shape from TopoDS); + ---C++: inline + + StartElements(me) + returns ListOfShape from BOPCol; + ---C++: return const & + ---C++: inline + + AddShape(me:out; + sS:Shape from TopoDS); + ---C++: inline + + Shapes(me) + returns ListOfShape from BOPCol; + ---C++: return const & + ---C++: inline + +fields + myFace : Face from TopoDS is protected; + myStartShapes : ListOfShape from BOPCol is protected; + myShapes : ListOfShape from BOPCol is protected; + +end WireEdgeSet; diff --git a/src/BOPAlgo/BOPAlgo_WireEdgeSet.cxx b/src/BOPAlgo/BOPAlgo_WireEdgeSet.cxx new file mode 100644 index 0000000000..466af6d01f --- /dev/null +++ b/src/BOPAlgo/BOPAlgo_WireEdgeSet.cxx @@ -0,0 +1,22 @@ +// Created by: Peter KURNEV +// Copyright (c) 2010-2012 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 +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + +#include diff --git a/src/BOPAlgo/BOPAlgo_WireEdgeSet.lxx b/src/BOPAlgo/BOPAlgo_WireEdgeSet.lxx new file mode 100644 index 0000000000..c8d9374bc2 --- /dev/null +++ b/src/BOPAlgo/BOPAlgo_WireEdgeSet.lxx @@ -0,0 +1,103 @@ +// Created by: Peter KURNEV +// Copyright (c) 2010-2012 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 +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +//======================================================================= +//function : +//purpose : +//======================================================================= + inline BOPAlgo_WireEdgeSet::BOPAlgo_WireEdgeSet() +{ +} +//======================================================================= +//function : +//purpose : +//======================================================================= + inline BOPAlgo_WireEdgeSet::BOPAlgo_WireEdgeSet(const Handle(NCollection_BaseAllocator)& theAllocator) +: + myStartShapes(theAllocator), + myShapes(theAllocator) +{ +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= + inline BOPAlgo_WireEdgeSet::~BOPAlgo_WireEdgeSet() +{ +} +//======================================================================= +//function : Clear +//purpose : +//======================================================================= + inline void BOPAlgo_WireEdgeSet::Clear() +{ + myStartShapes.Clear(); + myShapes.Clear(); +} +//======================================================================= +//function : SetFace +//purpose : +//======================================================================= + inline void BOPAlgo_WireEdgeSet::SetFace(const TopoDS_Face& aF) +{ + myFace=aF; +} +//======================================================================= +//function : Face +//purpose : +//======================================================================= + inline const TopoDS_Face& BOPAlgo_WireEdgeSet::Face()const +{ + return myFace; +} +//======================================================================= +//function : AddStartElement +//purpose : +//======================================================================= + inline void BOPAlgo_WireEdgeSet::AddStartElement(const TopoDS_Shape& aE) +{ + myStartShapes.Append(aE); +} +//======================================================================= +//function : StartElements +//purpose : +//======================================================================= + inline const BOPCol_ListOfShape& BOPAlgo_WireEdgeSet::StartElements()const +{ + return myStartShapes; +} +//======================================================================= +//function : AddShape +//purpose : +//======================================================================= + inline void BOPAlgo_WireEdgeSet::AddShape(const TopoDS_Shape& aW) +{ + myShapes.Append(aW); +} +//======================================================================= +//function : Shapes +//purpose : +//======================================================================= + inline const BOPCol_ListOfShape& BOPAlgo_WireEdgeSet::Shapes()const +{ + return myShapes; +} diff --git a/src/BOPAlgo/BOPAlgo_WireSplitter.cdl b/src/BOPAlgo/BOPAlgo_WireSplitter.cdl new file mode 100644 index 0000000000..16b74d6efa --- /dev/null +++ b/src/BOPAlgo/BOPAlgo_WireSplitter.cdl @@ -0,0 +1,77 @@ +-- Created by: Peter KURNEV +-- Copyright (c) 1999-2012 OPEN CASCADE SAS +-- +-- The content of this file is subject to the Open CASCADE Technology Public +-- License Version 6.5 (the "License"). You may not use the content of this file +-- except in compliance with the License. Please obtain a copy of the License +-- at http://www.opencascade.org and read it completely before using this file. +-- +-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +-- +-- The Original Code and all software distributed under the License is +-- distributed on an "AS IS" basis, without warranty of any kind, and the +-- Initial Developer hereby disclaims all such warranties, including without +-- limitation, any warranties of merchantability, fitness for a particular +-- purpose or non-infringement. Please see the License for the specific terms +-- and conditions governing the rights and limitations under the License. + +class WireSplitter from BOPAlgo + inherits Algo from BOPAlgo + + ---Purpose: + +uses + Wire from TopoDS, + BaseAllocator from BOPCol, + ListOfShape from BOPCol, + WireEdgeSet from BOPAlgo, + PWireEdgeSet from BOPAlgo, + ConnexityBlock from BOPTools, + ListOfConnexityBlock from BOPTools + + +--raises + +is + Create + returns WireSplitter from BOPAlgo; + ---C++: alias "Standard_EXPORT virtual ~BOPAlgo_WireSplitter();" + + Create(theAllocator: BaseAllocator from BOPCol) + returns WireSplitter from BOPAlgo; + + SetWES(me:out; + theWES: WireEdgeSet from BOPAlgo); + + + WES(me:out) + returns WireEdgeSet from BOPAlgo; + ---C++: return & + + Perform(me:out) + is redefined; + + MakeWire(myclass; + theLE:out ListOfShape from BOPCol; + theW :out Wire from TopoDS); + ---C++: inline + + CheckData(me:out) + is redefined protected; + + MakeConnexityBlocks(me:out) + is protected; + + MakeWires(me:out) + is protected; + + SplitBlock(me:out; + theCB:out ConnexityBlock from BOPTools) + is protected; + +fields + myWES : PWireEdgeSet from BOPAlgo is protected; + myLCB : ListOfConnexityBlock from BOPTools is protected; + +end WireSplitter; diff --git a/src/BOPAlgo/BOPAlgo_WireSplitter.cxx b/src/BOPAlgo/BOPAlgo_WireSplitter.cxx new file mode 100644 index 0000000000..d59f3cc6ef --- /dev/null +++ b/src/BOPAlgo/BOPAlgo_WireSplitter.cxx @@ -0,0 +1,295 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#include + +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include + +#include + + +//======================================================================= +//function : +//purpose : +//======================================================================= + BOPAlgo_WireSplitter::BOPAlgo_WireSplitter() +: + BOPAlgo_Algo(), + myWES(NULL), + myLCB(myAllocator) +{ +} +//======================================================================= +//function : +//purpose : +//======================================================================= + BOPAlgo_WireSplitter::BOPAlgo_WireSplitter(const Handle(NCollection_BaseAllocator)& theAllocator) +: + BOPAlgo_Algo(theAllocator), + myWES(NULL), + myLCB(myAllocator) +{ +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= + BOPAlgo_WireSplitter::~BOPAlgo_WireSplitter() +{ +} +//======================================================================= +//function : SetWES +//purpose : +//======================================================================= + void BOPAlgo_WireSplitter::SetWES(const BOPAlgo_WireEdgeSet& theWES) +{ + myWES=(BOPAlgo_WireEdgeSet*)&theWES; +} +//======================================================================= +//function : WES +//purpose : +//======================================================================= + BOPAlgo_WireEdgeSet& BOPAlgo_WireSplitter::WES() +{ + return *myWES; +} +//======================================================================= +// function: CheckData +// purpose: +//======================================================================= + void BOPAlgo_WireSplitter::CheckData() +{ + myErrorStatus=0; + if (!myWES) { + myErrorStatus=10; + return; + } +} +//======================================================================= +//function : Perform +//purpose : +//======================================================================= + void BOPAlgo_WireSplitter::Perform() +{ + myErrorStatus=0; + // + CheckData(); + if (myErrorStatus) { + return; + } + // + MakeConnexityBlocks(); + MakeWires(); +} +//======================================================================= +//function : MakeWires +//purpose : +//======================================================================= + void BOPAlgo_WireSplitter::MakeWires() +{ + Standard_Boolean bIsRegular; + TopoDS_Wire aW; + BOPTools_ListIteratorOfListOfConnexityBlock aItCB; + BOPCol_ListIteratorOfListOfShape aIt; + // + aItCB.Initialize(myLCB); + for (; aItCB.More(); aItCB.Next()) { + BOPTools_ConnexityBlock& aCB=aItCB.ChangeValue(); + bIsRegular=aCB.IsRegular(); + if (bIsRegular) { + BOPCol_ListOfShape& aLE=aCB.ChangeShapes(); + BOPAlgo_WireSplitter::MakeWire(aLE, aW); + myWES->AddShape(aW); + } + else { + SplitBlock(aCB); + // + const BOPCol_ListOfShape& aLW=aCB.Loops(); + aIt.Initialize(aLW); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aWx=aIt.Value(); + myWES->AddShape(aWx); + } + } + } +} +//======================================================================= +//function : MakeConnexityBlocks +//purpose : +//======================================================================= + void BOPAlgo_WireSplitter::MakeConnexityBlocks() +{ + Standard_Boolean bRegular, bClosed; + Standard_Integer i, j, aNbV, aNbVS, aNbVP; + TopoDS_Iterator aItE; + TopoDS_Shape aER; + BOPCol_ListIteratorOfListOfShape aIt; + BOPCol_MapIteratorOfMapOfShape aItM; + // + BOPCol_IndexedDataMapOfShapeListOfShape aMVE(100, myAllocator); + BOPCol_MapOfShape aMVP(100, myAllocator); + //modified by NIZHNY-EMV Wed Oct 06 10:17:57 2010 + BOPCol_IndexedMapOfShape aMEC(100, myAllocator); + //modified by NIZHNY-EMV Wed Oct 06 10:18:02 2010 + BOPCol_MapOfShape aMER(100, myAllocator); + BOPCol_MapOfShape aMEP(100, myAllocator); + BOPCol_MapOfShape aMVAdd(100, myAllocator); + BOPCol_MapOfShape aMVS(100, myAllocator); + // + myLCB.Clear(); + // + const BOPCol_ListOfShape& aLSE=myWES->StartElements(); + aIt.Initialize(aLSE); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aE=aIt.Value(); + if (aMEP.Add(aE)) { + BOPTools::MapShapesAndAncestors(aE, TopAbs_VERTEX, TopAbs_EDGE, aMVE); + } + else { + aMER.Add(aE); + } + } + // + // 2 + aNbV=aMVE.Extent(); + for (i=1; i<=aNbV; ++i) { + aNbVS=aMVS.Extent(); + if (aNbVS==aNbV) { + break; + } + // + const TopoDS_Shape& aV=aMVE.FindKey(i); + // + if (!aMVS.Add(aV)) { + continue; + } + // aMVS - globally processed vertices + // + //------------------------------------- goal: aMEC + aMEC.Clear(); // aMEC - edges of CB + aMVP.Clear(); // aMVP - vertices to process right now + aMVAdd.Clear(); // aMVAdd vertices to process on next step of while(1) + // + aMVP.Add(aV); + // + while(1) { + aNbVP=aMVP.Extent(); + aItM.Initialize(aMVP); + for (; aItM.More(); aItM.Next()) { + const TopoDS_Shape& aVP=aItM.Value(); + const BOPCol_ListOfShape& aLE=aMVE.FindFromKey(aVP); + aIt.Initialize(aLE); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aE=aIt.Value(); + //modified by NIZHNY-EMV Wed Oct 06 10:18:19 2010 + if (aMEC.Add(aE)) { + //modified by NIZHNY-EMV Wed Oct 06 10:18:25 2010 + aItE.Initialize(aE); + for (; aItE.More(); aItE.Next()) { + const TopoDS_Shape& aVE=aItE.Value(); + if (aMVS.Add(aVE)) { + aMVAdd.Add(aVE); + } + } + } + } + }//for (; aItM.More(); aItM.Next()) { + // + aNbVP=aMVAdd.Extent(); + if (!aNbVP) { + break; // from while(1) + } + // + aMVP.Clear(); + // + aItM.Initialize(aMVAdd); + for (; aItM.More(); aItM.Next()) { + const TopoDS_Shape& aVE=aItM.Value(); + aMVP.Add(aVE); + } + aMVAdd.Clear(); + }// while(1) { + + //------------------------------------- + BOPTools_ConnexityBlock aCB(myAllocator); + BOPCol_ListOfShape& aLEC=aCB.ChangeShapes(); + + BOPCol_IndexedDataMapOfShapeListOfShape aMVER(100, myAllocator); + // + bRegular=Standard_True; + //modified by NIZHNY-EMV Wed Oct 06 10:18:45 2010 + Standard_Integer aNbCB = aMEC.Extent(); + for (j = 1; j <= aNbCB; j++) { + aER = aMEC(j); + //modified by NIZHNY-EMV Wed Oct 06 10:18:50 2010 + // + if (aMER.Contains(aER)) { + aER.Orientation(TopAbs_FORWARD); + aLEC.Append(aER); + aER.Orientation(TopAbs_REVERSED); + aLEC.Append(aER); + bRegular=Standard_False; + } + else { + aLEC.Append(aER); + } + // + if (bRegular) { + BOPTools::MapShapesAndAncestors(aER, TopAbs_VERTEX, TopAbs_EDGE, aMVER); + } + } + // + if (bRegular) { + Standard_Integer k, aNbVR, aNbER; + // + aNbVR=aMVER.Extent(); + for (k=1; k<=aNbVR; ++k) { + const BOPCol_ListOfShape& aLER=aMVER(k); + aNbER=aLER.Extent(); + if (aNbER==1) { + const TopoDS_Edge& aEx=TopoDS::Edge(aER); + bClosed=BRep_Tool::IsClosed(aEx, myWES->Face()); + if (!bClosed) { + bRegular=!bRegular; + break; + } + } + if (aNbER>2) { + bRegular=!bRegular; + break; + } + } + } + // + aCB.SetRegular(bRegular); + myLCB.Append(aCB); + } +} diff --git a/src/BOPAlgo/BOPAlgo_WireSplitter.lxx b/src/BOPAlgo/BOPAlgo_WireSplitter.lxx new file mode 100644 index 0000000000..bdb5f0692e --- /dev/null +++ b/src/BOPAlgo/BOPAlgo_WireSplitter.lxx @@ -0,0 +1,105 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#include + +#include + +//======================================================================= +//function : BOPAlgo_EdgeInfo +//purpose : +//======================================================================= +class BOPAlgo_EdgeInfo { + public: + // + BOPAlgo_EdgeInfo() : + myPassed(Standard_False), + myInFlag(Standard_False), + myAngle (-1.) { + }; + // + void SetEdge(const TopoDS_Edge& theE) { + myEdge=theE; + }; + // + const TopoDS_Edge& Edge() const{ + return myEdge; + }; + // + void SetPassed(const Standard_Boolean theFlag) { + myPassed=theFlag; + }; + // + Standard_Boolean Passed()const { + return myPassed; + }; + // + void SetInFlag(const Standard_Boolean theFlag) { + myInFlag=theFlag; + }; + // + Standard_Boolean IsIn()const { + return myInFlag; + }; + // + void SetAngle(const Standard_Real theAngle) { + myAngle=theAngle; + }; + // + Standard_Real Angle()const { + return myAngle; + }; + // + protected: + TopoDS_Edge myEdge; + Standard_Boolean myPassed; + Standard_Boolean myInFlag; + Standard_Real myAngle; +}; + + +#include +typedef NCollection_List BOPAlgo_ListOfEdgeInfo; +typedef BOPAlgo_ListOfEdgeInfo::Iterator BOPAlgo_ListIteratorOfListOfEdgeInfo; + +#define _NCollection_MapHasher +#include +#include + +typedef NCollection_IndexedDataMap BOPAlgo_IndexedDataMapOfShapeListOfEdgeInfo; +#undef _NCollection_MapHasher + + +//======================================================================= +//function : MakeWire +//purpose : +//======================================================================= + inline void BOPAlgo_WireSplitter::MakeWire(BOPCol_ListOfShape& aLE, + TopoDS_Wire& aWire) +{ + BRep_Builder aBB; + aBB.MakeWire(aWire); + // + BOPCol_ListIteratorOfListOfShape aIt(aLE); + for (; aIt.More(); aIt.Next()){ + aBB.Add(aWire, aIt.Value()); + } +} diff --git a/src/BOPAlgo/BOPAlgo_WireSplitter_1.cxx b/src/BOPAlgo/BOPAlgo_WireSplitter_1.cxx new file mode 100644 index 0000000000..e0dfec065a --- /dev/null +++ b/src/BOPAlgo/BOPAlgo_WireSplitter_1.cxx @@ -0,0 +1,1034 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + +#include + +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +// +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +// + +static + Standard_Real Angle (const gp_Dir2d& aDir2D); + +static + Standard_Real Angle2D (const TopoDS_Vertex& aV, + const TopoDS_Edge& anEdge, + const TopoDS_Face& myFace, + const GeomAdaptor_Surface& aGAS, + const Standard_Boolean aFlag); + +static + void GetNextVertex(const TopoDS_Vertex& aV, + const TopoDS_Edge& aE, + TopoDS_Vertex& aV1); + +static + Standard_Real AngleIn(const TopoDS_Edge& aEIn, + const BOPAlgo_ListOfEdgeInfo& aLEInfo); + +static + Standard_Integer NbWaysOut(const BOPAlgo_ListOfEdgeInfo& aLEInfo); + +static + gp_Pnt2d Coord2dVf (const TopoDS_Edge& aE, + const TopoDS_Face& aF); + +static + gp_Pnt2d Coord2d (const TopoDS_Vertex& aV1, + const TopoDS_Edge& aE1, + const TopoDS_Face& aF); + + +static + Standard_Real ClockWiseAngle(const Standard_Real aAngleIn, + const Standard_Real aAngleOut); + +static + void Path (const GeomAdaptor_Surface& aGAS, + const TopoDS_Face& myFace, + const TopoDS_Vertex& aVa, + const TopoDS_Edge& aEOuta, + BOPAlgo_EdgeInfo& anEdgeInfo, + BOPCol_SequenceOfShape& aLS, + BOPCol_SequenceOfShape& aVertVa, + BOPCol_SequenceOfPnt2d& aCoordVa, + BOPTools_ConnexityBlock& aCB, + BOPAlgo_IndexedDataMapOfShapeListOfEdgeInfo& mySmartMap); + +static + Standard_Real Angle2D (const TopoDS_Vertex& aV, + const TopoDS_Edge& anEdge, + const TopoDS_Face& myFace, + const GeomAdaptor_Surface& aGAS, + const Standard_Boolean aFlag); +static + Standard_Real Angle (const gp_Dir2d& aDir2D); + +static + Standard_Real Tolerance2D (const TopoDS_Vertex& aV, + const GeomAdaptor_Surface& aGAS); + +static + void BuildPCurveForPlane (const BOPCol_ListOfShape myEdges, + const TopoDS_Face& myFace); + +//modified by NIZHNY-EMV Thu Oct 13 10:27:33 2011 +static + Standard_Real UTolerance2D (const TopoDS_Vertex& aV, + const GeomAdaptor_Surface& aGAS); +static + Standard_Real VTolerance2D (const TopoDS_Vertex& aV, + const GeomAdaptor_Surface& aGAS); + +static + Standard_Boolean RecomputeAngles(const BOPAlgo_ListOfEdgeInfo& aLEInfo, + const TopoDS_Face& theFace, + const gp_Pnt2d& thePb, + const TopoDS_Vertex& theVb, + const GeomAdaptor_Surface& theGAS, + const TopoDS_Edge& theEOuta, + const Standard_Boolean& bHasClosed, + const Standard_Real& theTol2D, + BOPCol_SequenceOfReal& theRecomputedAngles); +//modified by NIZHNY-EMV Thu Oct 13 10:27:35 2011 + +//======================================================================= +//function : SplitBlock +//purpose : +//======================================================================= + void BOPAlgo_WireSplitter::SplitBlock(BOPTools_ConnexityBlock& aCB) +{ + Standard_Boolean bNothingToDo; + Standard_Integer aIx, aNb, i, aCntIn, aCntOut; + Standard_Real aAngle; + TopAbs_Orientation aOr; + TopoDS_Iterator aItS; + TopoDS_Vertex aVV; + BOPCol_ListIteratorOfListOfShape aIt; + BOPAlgo_ListIteratorOfListOfEdgeInfo aItLEI; + // + BOPAlgo_IndexedDataMapOfShapeListOfEdgeInfo mySmartMap(100, myAllocator); + // + const TopoDS_Face& myFace=myWES->Face(); + const BOPCol_ListOfShape& myEdges=aCB.Shapes(); + // + // 1.Filling mySmartMap + //modified by NIZNHY-PKV Thu Jun 25 10:47:26 2009f + BuildPCurveForPlane(myEdges, myFace); + //modified by NIZNHY-PKV Thu Jun 25 10:47:29 2009t + aIt.Initialize(myEdges); + for(; aIt.More(); aIt.Next()) { + const TopoDS_Edge& aE=(*(TopoDS_Edge *)&aIt.Value()); + if (!BOPTools_AlgoTools2D::HasCurveOnSurface (aE, myFace)) { + continue; + } + // + aItS.Initialize(aE); + for(; aItS.More(); aItS.Next()) { + const TopoDS_Shape& aV=aItS.Value(); + aIx=mySmartMap.FindIndex(aV); + if (!aIx) { + BOPAlgo_ListOfEdgeInfo aLEIx(myAllocator); + aIx=mySmartMap.Add(aV, aLEIx); + } + // + BOPAlgo_ListOfEdgeInfo& aLEI=mySmartMap(aIx); + // + BOPAlgo_EdgeInfo aEI; + // + aEI.SetEdge(aE); + aOr=aV.Orientation(); + if (aOr==TopAbs_FORWARD) { + aEI.SetInFlag(Standard_False); + } + else if (aOr==TopAbs_REVERSED) { + aEI.SetInFlag(Standard_True); + } + aLEI.Append(aEI); + } + } + // + aNb=mySmartMap.Extent(); + // + bNothingToDo=Standard_True; + for (i=1; i<=aNb; i++) { + aCntIn=0; + aCntOut=0; + const BOPAlgo_ListOfEdgeInfo& aLEInfo= mySmartMap(i); + BOPAlgo_ListIteratorOfListOfEdgeInfo anIt(aLEInfo); + for (; anIt.More(); anIt.Next()) { + const BOPAlgo_EdgeInfo& aEI=anIt.Value(); + if (aEI.IsIn()) { + aCntIn++; + } + else { + aCntOut++; + } + } + if (aCntIn!=1 || aCntOut!=1) { + bNothingToDo=Standard_False; + break; + } + } + // + // Each vertex has one edge In and one - Out. Good. But it is not enought + // to consider that nothing to do with this. We must check edges on TShape + // coinsidence. If there are such edges there is something to do with. + if (bNothingToDo) { + Standard_Integer aNbE, aNbMapEE; + Standard_Boolean bFlag; + // + BOPCol_IndexedDataMapOfShapeListOfShape aMapEE(100, myAllocator); + aNbE=myEdges.Extent(); + // + aIt.Initialize(myEdges); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aE = aIt.Value(); + if (!aMapEE.Contains(aE)) { + BOPCol_ListOfShape aLEx(myAllocator); + aLEx.Append(aE); + aMapEE.Add(aE, aLEx); + } + else { + BOPCol_ListOfShape& aLEx=aMapEE.ChangeFromKey(aE); + aLEx.Append(aE); + } + } + // + bFlag=Standard_True; + aNbMapEE=aMapEE.Extent(); + for (i=1; i<=aNbMapEE; ++i) { + const BOPCol_ListOfShape& aLEx=aMapEE(i); + aNbE=aLEx.Extent(); + if (aNbE==1) {// usual case + continue; + } + else if (aNbE==2){ + const TopoDS_Shape& aE1=aLEx.First(); + const TopoDS_Shape& aE2=aLEx.Last(); + if (aE1.IsSame(aE2)) { + bFlag=Standard_False; + break; + } + } + else { + bFlag=Standard_False; + break; + } + } + bNothingToDo=bNothingToDo && bFlag; + } // if (bNothingToDo) { + if (bNothingToDo) { + TopoDS_Wire aW; + // + BOPCol_ListOfShape& aLECB=aCB.ChangeShapes(); + BOPAlgo_WireSplitter::MakeWire(aLECB, aW); + BOPCol_ListOfShape& aLoops=aCB.ChangeLoops(); + aLoops.Append(aW); + // + myErrorStatus=0; + return; + } + // + // 3. Angles in mySmartMap + BRepAdaptor_Surface aBAS(myFace); + const GeomAdaptor_Surface& aGAS=aBAS.Surface(); + // + for (i=1; i<=aNb; i++) { + const TopoDS_Vertex& aV=(*(TopoDS_Vertex *)(&mySmartMap.FindKey(i))); + const BOPAlgo_ListOfEdgeInfo& aLEI= mySmartMap(i); + + aItLEI.Initialize(aLEI); + for (; aItLEI.More(); aItLEI.Next()) { + BOPAlgo_EdgeInfo& aEI=aItLEI.ChangeValue(); + const TopoDS_Edge& aE=aEI.Edge(); + // + aVV=aV; + if (aEI.IsIn()) { + aVV.Orientation(TopAbs_REVERSED); + aAngle=Angle2D (aVV, aE, myFace, aGAS, Standard_True); + } + else { // OUT + aVV.Orientation(TopAbs_FORWARD); + aAngle=Angle2D (aVV, aE, myFace, aGAS, Standard_False); + } + aEI.SetAngle(aAngle); + } + }// for (i=1; i<=aNb; i++) { + // + // 4. Do + // + Standard_Boolean bIsOut, bIsNotPassed; + BOPCol_SequenceOfShape aLS, aVertVa; + BOPCol_SequenceOfPnt2d aCoordVa; + // + for (i=1; i<=aNb; ++i) { + const TopoDS_Vertex& aVa=(*(TopoDS_Vertex *)(&mySmartMap.FindKey(i))); + const BOPAlgo_ListOfEdgeInfo& aLEI=mySmartMap(i); + aItLEI.Initialize(aLEI); + for (; aItLEI.More(); aItLEI.Next()) { + BOPAlgo_EdgeInfo& aEI=aItLEI.ChangeValue(); + const TopoDS_Edge& aEOuta=aEI.Edge(); + // + bIsOut=!aEI.IsIn(); + bIsNotPassed=!aEI.Passed(); + if (bIsOut && bIsNotPassed) { + // + aLS.Clear(); + aVertVa.Clear(); + aCoordVa.Clear(); + // + Path(aGAS, myFace, aVa, aEOuta, aEI, aLS, + aVertVa, aCoordVa, aCB, mySmartMap); + } + } + }// for (i=1; i<=aNb; ++i) { +} +//======================================================================= +// function: Path +// purpose: +//======================================================================= +void Path (const GeomAdaptor_Surface& aGAS, + const TopoDS_Face& myFace, + const TopoDS_Vertex& aVa, + const TopoDS_Edge& aEOuta, + BOPAlgo_EdgeInfo& anEdgeInfo, + BOPCol_SequenceOfShape& aLS, + BOPCol_SequenceOfShape& aVertVa, + BOPCol_SequenceOfPnt2d& aCoordVa, + BOPTools_ConnexityBlock& aCB, + BOPAlgo_IndexedDataMapOfShapeListOfEdgeInfo& mySmartMap) + +{ + Standard_Integer i, j, aNb, aNbj; + Standard_Real aTol, anAngleIn, anAngleOut, anAngle, aMinAngle; + Standard_Real aTol2D, aTol2D2; + Standard_Real aTol2, aD2; + Standard_Boolean anIsSameV2d, anIsSameV, anIsFound, anIsOut, anIsNotPassed; + TopoDS_Vertex aVb; + TopoDS_Edge aEOutb; + BOPAlgo_ListIteratorOfListOfEdgeInfo anIt; + // + aTol=1.e-7; + // + // append block + // + // Do not escape through edge from which you enter + aNb=aLS.Length(); + if (aNb==1) { + const TopoDS_Shape& anEPrev=aLS(aNb); + if (anEPrev.IsSame(aEOuta)) { + return; + } + } + // + anEdgeInfo.SetPassed(Standard_True); + aLS.Append(aEOuta); + aVertVa.Append(aVa); + + TopoDS_Vertex pVa=aVa; + pVa.Orientation(TopAbs_FORWARD); + gp_Pnt2d aPa=Coord2d(pVa, aEOuta, myFace); + aCoordVa.Append(aPa); + + GetNextVertex (pVa, aEOuta, aVb); + + gp_Pnt2d aPb=Coord2d(aVb, aEOuta, myFace); + + const BOPAlgo_ListOfEdgeInfo& aLEInfoVb=mySmartMap.FindFromKey(aVb); + // + aTol=2.*Tolerance2D(aVb, aGAS); + aTol2=10.*aTol*aTol; + + //modified by NIZHNY-EMV Thu Oct 13 10:34:54 2011 + TopoDS_Vertex aV1, aV2; + TopExp::Vertices(aEOuta, aV1, aV2); + Standard_Boolean bIsClosedEdge = aV1.IsNull() || aV2.IsNull() || aV1.IsSame(aV2); + Standard_Boolean bIsDegenerated = BRep_Tool::Degenerated(aEOuta); + Standard_Boolean bIsSeam = BRep_Tool::IsClosed(aEOuta, myFace); + + anIt.Initialize(aLEInfoVb); + for (; anIt.More(); anIt.Next()) { + const BOPAlgo_EdgeInfo& anEI = anIt.Value(); + const TopoDS_Edge& aE = anEI.Edge(); + bIsDegenerated = bIsDegenerated || BRep_Tool::Degenerated(aE); + bIsSeam = bIsSeam || BRep_Tool::IsClosed(aE, myFace); + aV1.Nullify(); + aV2.Nullify(); + TopExp::Vertices(aE, aV1, aV2); + bIsClosedEdge = bIsClosedEdge || aV1.IsNull() || aV2.IsNull() || aV1.IsSame(aV2); + } + //modified by NIZHNY-EMV Thu Oct 13 10:34:55 2011 + // + aNb=aLS.Length(); + if (aNb>0) { + // + BOPCol_ListOfShape aBuf; + // + for (i=aNb; i>0; --i) { + const TopoDS_Shape& aVPrev=aVertVa(i); + const gp_Pnt2d& aPaPrev=aCoordVa(i); + const TopoDS_Shape& aEPrev=aLS(i); + + aBuf.Append(aEPrev); + + anIsSameV=aVPrev.IsSame(aVb); + anIsSameV2d=Standard_False; + + if (anIsSameV) { + anIsSameV2d = Standard_True; + // + aD2=aPaPrev.SquareDistance(aPb); + anIsSameV2d =aD2 aTol2D2){ + continue; + } + // + // + anAngleOut=anEI.Angle(); + // + //modified by NIZHNY-EMV Thu Oct 13 10:39:46 2011 + if(bRecomputeAngle) { + if(aCurIndexE <= aRecomputedAngles.Length()) { + anAngleOut = aRecomputedAngles.Value(aCurIndexE); + } + } + + //modified by NIZHNY-EMV Thu Oct 13 10:39:47 2011 + anAngle=ClockWiseAngle(anAngleIn, anAngleOut); + if (anAngle < aMinAngle) { + aMinAngle=anAngle; + pEdgeInfo=&anEI; + anIsFound=Standard_True; + } + } + } // for (; anIt.More(); anIt.Next()) + // + if (!anIsFound) { + // no way to go . (Error) + return; + } + + aEOutb=pEdgeInfo->Edge(); + // + Path (aGAS, myFace, aVb, aEOutb, *pEdgeInfo, aLS, + aVertVa, aCoordVa, aCB, mySmartMap); +} +//======================================================================= +// function: ClockWiseAngle +// purpose: +//======================================================================= + Standard_Real ClockWiseAngle(const Standard_Real aAngleIn, + const Standard_Real aAngleOut) +{ + Standard_Real aTwoPi=M_PI+M_PI; + Standard_Real dA, A1, A2, AIn, AOut ; + + AIn=aAngleIn; + AOut=aAngleOut; + if (AIn >= aTwoPi) { + AIn=AIn-aTwoPi; + } + + if (AOut >= aTwoPi) { + AOut=AOut-aTwoPi; + } + + A1=AIn+M_PI; + + if (A1 >= aTwoPi) { + A1=A1-aTwoPi; + } + + A2=AOut; + + dA=A1-A2; + if (dA <= 0.) { + dA=aTwoPi+dA; + } + //xx + //else if (dA <= 1.e-15) { + else if (dA <= 1.e-14) { + dA=aTwoPi; + } + return dA; +} +//======================================================================= +// function: Coord2d +// purpose: +//======================================================================= + gp_Pnt2d Coord2d (const TopoDS_Vertex& aV1, + const TopoDS_Edge& aE1, + const TopoDS_Face& aF) +{ + Standard_Real aT, aFirst, aLast; + Handle(Geom2d_Curve) aC2D; + gp_Pnt2d aP2D1; + // + aT=BRep_Tool::Parameter (aV1, aE1, aF); + aC2D=BRep_Tool::CurveOnSurface(aE1, aF, aFirst, aLast); + aC2D->D0 (aT, aP2D1); + // + return aP2D1; +} +//======================================================================= +// function: Coord2dVf +// purpose: +//======================================================================= + gp_Pnt2d Coord2dVf (const TopoDS_Edge& aE, + const TopoDS_Face& aF) +{ + Standard_Real aCoord=99.; + gp_Pnt2d aP2D1(aCoord, aCoord); + TopoDS_Iterator aIt; + // + aIt.Initialize(aE); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aVx=aIt.Value(); + if (aVx.Orientation()==TopAbs_FORWARD) { + + const TopoDS_Vertex& aVxx=(*(TopoDS_Vertex *)(&aVx));// TopoDS::Vertex(aVx); + aP2D1=Coord2d(aVxx, aE, aF); + return aP2D1; + } + } + return aP2D1; +} + +//======================================================================= +// function: NbWaysOut +// purpose: +//======================================================================= +Standard_Integer NbWaysOut(const BOPAlgo_ListOfEdgeInfo& aLEInfo) +{ + Standard_Boolean bIsOut, bIsNotPassed; + Standard_Integer iCnt=0; + BOPAlgo_ListIteratorOfListOfEdgeInfo anIt; + // + anIt.Initialize(aLEInfo); + for (; anIt.More(); anIt.Next()) { + const BOPAlgo_EdgeInfo& anEI=anIt.Value(); + // + bIsOut=!anEI.IsIn(); + bIsNotPassed=!anEI.Passed(); + if (bIsOut && bIsNotPassed) { + iCnt++; + } + } + return iCnt; +} + +//======================================================================= +// function: AngleIn +// purpose: +//======================================================================= + Standard_Real AngleIn(const TopoDS_Edge& aEIn, + const BOPAlgo_ListOfEdgeInfo& aLEInfo) +{ + Standard_Real anAngleIn; + Standard_Boolean anIsIn; + BOPAlgo_ListIteratorOfListOfEdgeInfo anIt; + + anIt.Initialize(aLEInfo); + for (; anIt.More(); anIt.Next()) { + const BOPAlgo_EdgeInfo& anEdgeInfo=anIt.Value(); + const TopoDS_Edge& aE=anEdgeInfo.Edge(); + anIsIn=anEdgeInfo.IsIn(); + // + if (anIsIn && aE==aEIn) { + anAngleIn=anEdgeInfo.Angle(); + return anAngleIn; + } + } + anAngleIn=0.; + return anAngleIn; +} +//======================================================================= +// function: GetNextVertex +// purpose: +//======================================================================= + void GetNextVertex(const TopoDS_Vertex& aV, + const TopoDS_Edge& aE, + TopoDS_Vertex& aV1) +{ + TopoDS_Iterator aIt; + // + aIt.Initialize(aE); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aVx=aIt.Value(); + if (!aVx.IsEqual(aV)) { + aV1=(*(TopoDS_Vertex *)(&aVx)); + return ; + } + } + aV1=aV; +} +//======================================================================= +// function: Angle2D +// purpose: +//======================================================================= + Standard_Real Angle2D (const TopoDS_Vertex& aV, + const TopoDS_Edge& anEdge, + const TopoDS_Face& myFace, + const GeomAdaptor_Surface& aGAS, + const Standard_Boolean aFlag) +{ + Standard_Real aFirst, aLast, aToler, dt, aTV, aTV1, anAngle, aTX; + gp_Pnt2d aPV, aPV1; + gp_Vec2d aV2D; + Handle(Geom2d_Curve) aC2D; + // + aTV=BRep_Tool::Parameter (aV, anEdge, myFace); + if (Precision::IsInfinite(aTV)) { + return 0.; + } + // + BOPTools_AlgoTools2D::CurveOnSurface (anEdge, myFace, aC2D, + aFirst, aLast, aToler, Standard_True); + dt=2.*Tolerance2D(aV, aGAS); + // + //modified by NIZHNY-EMV Wed Aug 03 11:34:58 2011 + //for case chl/927/r9 + aTX=0.05*(aLast - aFirst);//aTX=0.25*(aLast - aFirst); + if (aTX < 5.e-5) { + aTX = 5.e-5; + } + //modified by NIZHNY-EMV Wed Aug 03 11:35:00 2011 + if(dt > aTX) { + // to save direction of the curve as much as it possible + // in the case of big tolerances + dt = aTX; + } + // + if (fabs (aTV-aFirst) < fabs(aTV - aLast)) { + aTV1=aTV + dt; + } + else { + aTV1=aTV - dt; + } + // + aC2D->D0 (aTV, aPV); + aC2D->D0 (aTV1, aPV1); + // + if (aFlag) {//IN + gp_Vec2d aV2DIn(aPV1, aPV); + aV2D=aV2DIn; + } + else { + gp_Vec2d aV2DOut(aPV, aPV1); + aV2D=aV2DOut; + } + // + gp_Dir2d aDir2D(aV2D); + anAngle=Angle(aDir2D); + // + return anAngle; +} +//======================================================================= +// function: Angle +// purpose: +//======================================================================= +Standard_Real Angle (const gp_Dir2d& aDir2D) +{ + gp_Dir2d aRefDir(1., 0.); + Standard_Real anAngle; + + anAngle = aRefDir.Angle(aDir2D); + if (anAngle < 0.) + anAngle += M_PI + M_PI; + return anAngle; +} +//======================================================================= +// function: Tolerance2D +// purpose: +//======================================================================= + Standard_Real Tolerance2D (const TopoDS_Vertex& aV, + const GeomAdaptor_Surface& aGAS) +{ + Standard_Real aTol2D, anUr, aVr, aTolV3D; + GeomAbs_SurfaceType aType; + // + aType=aGAS.GetType(); + aTolV3D=BRep_Tool::Tolerance(aV); + + anUr=aGAS.UResolution(aTolV3D); + aVr =aGAS.VResolution(aTolV3D); + aTol2D=(aVr>anUr) ? aVr : anUr; + // + if (aType==GeomAbs_BSplineSurface|| + aType==GeomAbs_Sphere|| + GeomAbs_SurfaceOfRevolution) { + if (aTol2D < aTolV3D) { + aTol2D=aTolV3D; + } + } + if (aType==GeomAbs_BSplineSurface) { + aTol2D=1.1*aTol2D; + } + // + return aTol2D; +} +//======================================================================= +// function: BuildPCurvesForPlane +// purpose: +//======================================================================= + void BuildPCurveForPlane (const BOPCol_ListOfShape myEdges, + const TopoDS_Face& myFace) +{ + TopLoc_Location aLoc; + Handle(Geom2d_Curve) aC2D; + Handle(Geom_Plane) aGP; + Handle(Geom_RectangularTrimmedSurface) aGRTS; + // + const Handle(Geom_Surface)& aS = BRep_Tool::Surface(myFace, aLoc); + aGRTS=Handle(Geom_RectangularTrimmedSurface)::DownCast(aS); + if(!aGRTS.IsNull()){ + aGP=Handle(Geom_Plane)::DownCast(aGRTS->BasisSurface()); + } + else { + aGP=Handle(Geom_Plane)::DownCast(aS); + } + // + if (aGP.IsNull()) { + return; + } + // + Standard_Real aTolE; + BOPCol_ListIteratorOfListOfShape aIt; + BRep_Builder aBB; + // + aIt.Initialize(myEdges); + for(; aIt.More(); aIt.Next()) { + const TopoDS_Edge& aE=(*(TopoDS_Edge *)&aIt.Value()); + BOPTools_AlgoTools2D::CurveOnSurface(aE, myFace, aC2D, aTolE, Standard_True); + aBB.UpdateEdge(aE, aC2D, myFace, aTolE); + } +} +//modified by NIZHNY-EMV Thu Oct 13 10:43:44 2011 +//======================================================================= +//function : UTolerance2D +//purpose : +//======================================================================= +Standard_Real UTolerance2D (const TopoDS_Vertex& aV, + const GeomAdaptor_Surface& aGAS) +{ + const Standard_Real aTolV3D = BRep_Tool::Tolerance(aV); + const Standard_Real anUr = aGAS.UResolution(aTolV3D); + // + return anUr; +} + +//======================================================================= +//function : VTolerance2D +//purpose : +//======================================================================= +Standard_Real VTolerance2D (const TopoDS_Vertex& aV, + const GeomAdaptor_Surface& aGAS) +{ + const Standard_Real aTolV3D = BRep_Tool::Tolerance(aV); + const Standard_Real anVr = aGAS.VResolution(aTolV3D); + // + return anVr; +} + +//======================================================================= +// function: RecomputeAngles +// purpose: +//======================================================================= +Standard_Boolean RecomputeAngles(const BOPAlgo_ListOfEdgeInfo& aLEInfo, + const TopoDS_Face& theFace, + const gp_Pnt2d& thePb, + const TopoDS_Vertex& theVb, + const GeomAdaptor_Surface& theGAS, + const TopoDS_Edge& theEOuta, + const Standard_Boolean& bIsClosed, + const Standard_Real& theTol2D, + BOPCol_SequenceOfReal& theRecomputedAngles) +{ + Standard_Boolean bRecomputeAngle = Standard_False; + BOPAlgo_ListIteratorOfListOfEdgeInfo anIt; + anIt.Initialize(aLEInfo); + + for (; anIt.More(); anIt.Next()) { + const BOPAlgo_EdgeInfo& anEI=anIt.Value(); + const TopoDS_Edge& aE=anEI.Edge(); + Standard_Boolean anIsOut=!anEI.IsIn(); + Standard_Boolean anIsNotPassed=!anEI.Passed(); + + if (anIsOut && anIsNotPassed) { + theRecomputedAngles.Append(anEI.Angle()); + Standard_Integer acurindex = theRecomputedAngles.Length(); + + Standard_Boolean bRecomputeAngleLocal = Standard_False; + TopExp_Explorer anExp1(aE, TopAbs_VERTEX); + + for(; anExp1.More(); anExp1.Next()) { + TopExp_Explorer anExp2(theEOuta, TopAbs_VERTEX); + Standard_Boolean existsInEdge = Standard_False; + + for(; anExp2.More(); anExp2.Next()) { + if(anExp1.Current().IsSame(anExp2.Current())) { + existsInEdge = Standard_True; + break; + } + } + + if(!existsInEdge) { + bRecomputeAngleLocal = Standard_False; + break; + } + bRecomputeAngleLocal = Standard_True; + } + bRecomputeAngle = bRecomputeAngle || bRecomputeAngleLocal; + + if(!bRecomputeAngle) { + BOPAlgo_ListIteratorOfListOfEdgeInfo anIt2(aLEInfo); + + for(; anIt2.More(); anIt2.Next()) { + const BOPAlgo_EdgeInfo& anEI2=anIt2.Value(); + const TopoDS_Edge& aE2=anEI2.Edge(); + + if(aE2.IsSame(aE)) + continue; + Standard_Boolean anIsOut2=!anEI2.IsIn(); + Standard_Boolean anIsNotPassed2=!anEI2.Passed(); + + if (anIsOut2 && anIsNotPassed2) { + anExp1.Init(aE, TopAbs_VERTEX); + + for(; anExp1.More(); anExp1.Next()) { + TopExp_Explorer anExp2(aE2, TopAbs_VERTEX); + Standard_Boolean existsInEdge = Standard_False; + + for(; anExp2.More(); anExp2.Next()) { + if(anExp1.Current().IsSame(anExp2.Current())) { + existsInEdge = Standard_True; + break; + } + } + + if(!existsInEdge) { + bRecomputeAngleLocal = Standard_False; + break; + } + bRecomputeAngleLocal = Standard_True; + } + bRecomputeAngle = bRecomputeAngle || bRecomputeAngleLocal; + } + } + } + + bRecomputeAngle = bRecomputeAngle || bRecomputeAngleLocal; + + if(bRecomputeAngle) { + gp_Pnt2d aP2Dx; + // + aP2Dx=Coord2dVf(aE, theFace); + Standard_Real aD = aP2Dx.Distance(thePb); + + TopoDS_Vertex aVf; + TopExp_Explorer anExp(aE, TopAbs_VERTEX); + + for (; anExp.More(); anExp.Next()) { + const TopoDS_Vertex& aVx=*(TopoDS_Vertex*)(&anExp.Current()); + if (aVx.Orientation()==TopAbs_FORWARD) { + aVf = aVx; + } + } + Standard_Boolean bIgnore = Standard_False; + + if(bIsClosed || aVf.IsNull() || !aVf.IsSame(theVb)) { + bIgnore = (aD > theTol2D); + } + + if(!bIgnore && (theTol2D > M_PI)) { + Standard_Real udist = fabs(aP2Dx.X() - thePb.X()); + Standard_Real vdist = fabs(aP2Dx.Y() - thePb.Y()); + Standard_Real aTolU = 2. * UTolerance2D(theVb, theGAS); + Standard_Real aTolV = 2. * VTolerance2D(theVb, theGAS); + + if((udist > aTolU) || + (vdist > aTolV)) { + bIgnore = Standard_True; + } + } + + if((aD > Precision::Confusion()) && !bIgnore) { + Standard_Real f1, l1; + Handle(Geom2d_Curve) ac1 = BRep_Tool::CurveOnSurface(aE, theFace, f1, l1); + + Standard_Real aTV1 = BRep_Tool::Parameter (aVf, aE, theFace); + Standard_Real aTV12 = 0.; + Standard_Real dt1 = (l1 - f1) * 0.5; + + if (fabs (aTV1-f1) < fabs(aTV1 - l1)) { + aTV12 = aTV1 + dt1; + } + else { + aTV12 = aTV1 - dt1; + } + + gp_Pnt2d aPointNew = ac1->Value(aTV12); + gp_Vec2d aV2DOut(thePb, aPointNew); + + gp_Dir2d aDir2D(aV2DOut); + Standard_Real anAngleOut = Angle(aDir2D); + theRecomputedAngles.ChangeValue(acurindex) = anAngleOut; + } + } + } + } + return bRecomputeAngle; +} +//modified by NIZHNY-EMV Thu Oct 13 10:43:46 2011 diff --git a/src/BOPAlgo/FILES b/src/BOPAlgo/FILES new file mode 100644 index 0000000000..f2caa5c223 --- /dev/null +++ b/src/BOPAlgo/FILES @@ -0,0 +1,15 @@ +BOPAlgo_PaveFiller_1.cxx +BOPAlgo_PaveFiller_2.cxx +BOPAlgo_PaveFiller_3.cxx +BOPAlgo_PaveFiller_4.cxx +BOPAlgo_PaveFiller_5.cxx +BOPAlgo_PaveFiller_6.cxx +BOPAlgo_PaveFiller_7.cxx +BOPAlgo_PaveFiller_8.cxx +BOPAlgo_Builder_1.cxx +BOPAlgo_Builder_2.cxx +BOPAlgo_Builder_3.cxx +BOPAlgo_Builder_4.cxx +BOPAlgo_BOP_1.cxx +BOPAlgo_WireSplitter_1.cxx +BOPAlgo_ListOfCheckResult.hxx diff --git a/src/BOPCol/BOPCol.cdl b/src/BOPCol/BOPCol.cdl new file mode 100644 index 0000000000..9307635833 --- /dev/null +++ b/src/BOPCol/BOPCol.cdl @@ -0,0 +1,55 @@ +-- Created by: Peter KURNEV +-- Copyright (c) 1999-2012 OPEN CASCADE SAS +-- +-- The content of this file is subject to the Open CASCADE Technology Public +-- License Version 6.5 (the "License"). You may not use the content of this file +-- except in compliance with the License. Please obtain a copy of the License +-- at http://www.opencascade.org and read it completely before using this file. +-- +-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +-- +-- The Original Code and all software distributed under the License is +-- distributed on an "AS IS" basis, without warranty of any kind, and the +-- Initial Developer hereby disclaims all such warranties, including without +-- limitation, any warranties of merchantability, fitness for a particular +-- purpose or non-infringement. Please see the License for the specific terms +-- and conditions governing the rights and limitations under the License. + + +package BOPCol + + ---Purpose: + -- The package contains collection classes + -- that are used by + -- partition and boolean operation algorithms +uses + TCollection + +is + imported BaseAllocator from BOPCol; + imported DataMapOfShapeInteger from BOPCol; + imported MapOfInteger from BOPCol; + imported ListOfInteger from BOPCol; + imported PInteger from BOPCol; + imported DataMapOfIntegerInteger from BOPCol; + imported DataMapOfIntegerListOfInteger from BOPCol; + imported IndexedDataMapOfShapeBox from BOPCol; + imported IndexedMapOfInteger from BOPCol; + imported ListOfShape from BOPCol; + imported DataMapOfShapeAddress from BOPCol; + imported DataMapOfTransientAddress from BOPCol; + imported PListOfInteger from BOPCol; + imported VectorOfInteger from BOPCol; + imported MapOfShape from BOPCol; + imported DataMapOfShapeShape from BOPCol; + imported DataMapOfShapeListOfShape from BOPCol; + imported MapOfOrientedShape from BOPCol; + imported IndexedDataMapOfShapeListOfShape from BOPCol; + imported IndexedMapOfShape from BOPCol; + imported ListOfListOfShape from BOPCol; + imported SequenceOfShape from BOPCol; + imported SequenceOfPnt2d from BOPCol; + imported DataMapOfIntegerListOfShape from BOPCol; + +end BOPCol; diff --git a/src/BOPCol/BOPCol_Array1.hxx b/src/BOPCol/BOPCol_Array1.hxx new file mode 100644 index 0000000000..67842a98bb --- /dev/null +++ b/src/BOPCol/BOPCol_Array1.hxx @@ -0,0 +1,433 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + +#ifndef BOPCol_Array1_HeaderFile +#define BOPCol_Array1_HeaderFile + +#include +#include +#include + +/** +* Class BOPCol_Array1 (dynamic array of objects) +* +* 1. The Array1 uses the allocator (in terms of NCollection_BaseAllocator) +* to allocate the memory. +* 2. The memory is allocated as a list of memory blocks. The size of the first +* block is myStartSize. The size of the other blocks is myIncrement +* 3 The Array1 is created with 0 length. +* 4. The Array1 must be initiated by invoke the method Init(). +* Init() allocates the memory block for initial myStartSize elements. +* 5. The elements can be added by the method Append(theElement). the method +* Append(theElement) arranges theElement in +* a) previously allocated memory block (if it is possible) +* b) new allocated memory block (otherwise). The size of new blocks to +* allocate can be set [once only] by the method SetIncrement(theSize). +* 6. The contents of the element with index "i" can be queried or modified +* by the methods +* SetValue(i, theElement), Value(i), ChangeValue(i), operator()(i) +*/ + +//======================================================================= +//class : MemBlock +// +//======================================================================= +template class BOPCol_MemBlock { + + public: + // Ctor + BOPCol_MemBlock(const Handle(NCollection_BaseAllocator)& theAllocator) { + myI1=0; + myI2=0; + mySize=0; + myData=NULL; + myAllocator=theAllocator; + myNext=NULL; + } + // ~ + ~BOPCol_MemBlock(){ + Clear(); + } + // Clear + void Clear() { + if (myData) { + //Standard_Integer i; + Standard_Size i; + // + for (i=0; iFree((Standard_Address&)myData); + // + myData=NULL; + mySize=0; + myNext=NULL; + } + } + // Allocate + void Allocate(const Standard_Size theSize) { + //Standard_Integer i; + Standard_Size i; + // + Clear(); + mySize=theSize; + myData=(Type*)myAllocator->Allocate(theSize*sizeof(Type)); + for (i=0; i=myI1 && theIndex<=myI2); + } + // SetValue + void SetValue(const Standard_Integer theIndex, + const Type& theValue) { + *(myData+theIndex-myI1)=theValue; + } + // Value + const Type& Value(const Standard_Integer theIndex)const { + return *(myData+theIndex-myI1); + } + // ChangeValue + Type& ChangeValue(const Standard_Integer theIndex) { + return *(myData+theIndex-myI1); + } + // SetNext + void SetNext(BOPCol_MemBlock* pNext) { + myNext=pNext; + } + // Next + BOPCol_MemBlock* Next() { + return myNext; + } + // + public: + BOPCol_MemBlock* myNext; + protected: + Standard_Integer myI1; + Standard_Integer myI2; + Standard_Size mySize; + Type *myData; + Handle(NCollection_BaseAllocator) myAllocator; +}; + +//======================================================================= +//class : BOPCol_Array1 +// +//======================================================================= +template class BOPCol_Array1 { + + public: + typedef BOPCol_MemBlock* BOPCol_PMemBlock; + typedef BOPCol_MemBlock BOPCol_XMemBlock; + //========= + // Ctor + BOPCol_Array1(const Handle(NCollection_BaseAllocator)& theAllocator=0L) { + myStartSize=32; + myIncrement=8; + myExtent=0; + myPBlock=NULL; + myPBlock1=NULL; + // + if (theAllocator.IsNull()) { + myAllocator = NCollection_BaseAllocator::CommonBaseAllocator(); + } + else { + myAllocator=theAllocator; + } + } + // ~ + ~BOPCol_Array1() { + Clear(); + } + //=========== + // Clear + void Clear() { + BOPCol_PMemBlock pBlock, pNext; + // + pBlock=myPBlock1; + while(pBlock) { + pNext=pBlock->Next(); + // + //pBlock->~BOPCol_MemBlock (); + pBlock->~BOPCol_XMemBlock(); + //pBlock->Clear(); + myAllocator->Free((Standard_Address&)pBlock); + // + pBlock=pNext; + } + myPBlock1=NULL; + myPBlock=NULL; + myExtent=0; + } + // SetStartSize + void SetStartSize(const Standard_Size theSize) { + if (theSize>0) { + myStartSize=theSize; + } + } + // SetIncrement + void SetIncrement(const Standard_Size theSize){ + if (theSize>0) { + myIncrement=theSize; + } + } + // Increment + Standard_Size Increment()const { + return myIncrement; + } + // Extent + Standard_Size Extent()const { + return myExtent; + } + // Size + Standard_Size Size()const { + return myExtent; + } + // Size + Standard_Size Length()const { + return myExtent; + } + // Init + void Init(); + // Append(const Type& theValue) + Standard_Integer Append(const Type& theValue); + // Append() + Standard_Integer Append(); + // SetValue + void SetValue(const Standard_Integer theIndex, + const Type& theValue); + // Value + const Type& operator()(const Standard_Integer theIndex)const; + // + const Type& Value(const Standard_Integer theIndex)const; + // ChangeValue + Type& operator()(const Standard_Integer theIndex); + // + Type& ChangeValue(const Standard_Integer theIndex); + // + // protected + protected: + //=========== + //FindBlock + Standard_Boolean FindBlock(const Standard_Integer theIndex)const ; + //Copy ctor + BOPCol_Array1(const BOPCol_Array1&); + //Assign operator + BOPCol_Array1& operator =(const BOPCol_Array1& theOther); + //========== + // fields + protected: + Standard_Size myStartSize; + Standard_Size myIncrement; + Standard_Size myExtent; + Type myDfltItem; + BOPCol_MemBlock * myPBlock; + BOPCol_MemBlock * myPBlock1; + Handle(NCollection_BaseAllocator) myAllocator; +}; +// +//======================================================================= +//function : Init +//purpose : +//======================================================================= +template + void BOPCol_Array1::Init() { + BOPCol_PMemBlock pBlock; + // + pBlock=(BOPCol_PMemBlock)myAllocator->Allocate(sizeof(BOPCol_MemBlock)); + new (pBlock) BOPCol_MemBlock(myAllocator); + // + pBlock->Allocate(myStartSize); + pBlock->SetRange(0, myStartSize-1); + myPBlock1=pBlock; + myPBlock=pBlock; + } +//======================================================================= +//function : Append +//purpose : +//======================================================================= +template + Standard_Integer BOPCol_Array1::Append(const Type& theValue) { + BOPCol_PMemBlock pBlock, pNext; + // + pBlock=myPBlock1; + while(1) { + pNext=pBlock->myNext; + if(!pNext) { + myPBlock=pBlock; + break; + } + pBlock=pNext; + } + // + if (!myPBlock->Contains(myExtent)) { + // + pBlock=(BOPCol_PMemBlock)myAllocator->Allocate(sizeof(BOPCol_MemBlock)); + new (pBlock) BOPCol_MemBlock(myAllocator); + // + pBlock->Allocate(myIncrement); + pBlock->SetRange(myExtent, myExtent+myIncrement-1); + // + myPBlock->myNext=pBlock; + // + myPBlock=pBlock; + } + // + myPBlock->SetValue(myExtent, theValue); + // + ++myExtent; + // + return myExtent; + } +//======================================================================= +//function : Append +//purpose : +//======================================================================= +template + Standard_Integer BOPCol_Array1::Append() { + BOPCol_PMemBlock pBlock, pNext; + // + pBlock=myPBlock1; + while(1) { + pNext=pBlock->myNext; + if(!pNext) { + myPBlock=pBlock; + break; + } + pBlock=pNext; + } + // + if (!myPBlock->Contains(myExtent)) { + // + pBlock=(BOPCol_PMemBlock)myAllocator->Allocate(sizeof(BOPCol_MemBlock)); + new (pBlock) BOPCol_MemBlock(myAllocator); + // + pBlock->Allocate(myIncrement); + pBlock->SetRange(myExtent, myExtent+myIncrement-1); + // + myPBlock->myNext=pBlock; + // + myPBlock=pBlock; + } + ++myExtent; + // + return myExtent; + } +//======================================================================= +//function : SetValue +//purpose : +//======================================================================= +template + void BOPCol_Array1::SetValue(const Standard_Integer theIndex, + const Type& theValue) { + if (FindBlock(theIndex)) { + myPBlock->SetValue(theIndex, theValue); + } + } +//======================================================================= +//function : operator() +//purpose : +//======================================================================= +template + const Type& BOPCol_Array1::operator()(const Standard_Integer theIndex)const { + if (FindBlock(theIndex)) { + return myPBlock->Value(theIndex); + } + return myDfltItem; + } +//======================================================================= +//function : Value +//purpose : +//======================================================================= +template + const Type& BOPCol_Array1::Value(const Standard_Integer theIndex)const { + return operator()(theIndex); + } +//======================================================================= +//function : operator +//purpose : +//======================================================================= +template + Type& BOPCol_Array1::operator()(const Standard_Integer theIndex) { + if (FindBlock(theIndex)) { + return myPBlock->ChangeValue(theIndex); + } + return myDfltItem; + } +//======================================================================= +//function : ChangeValue +//purpose : +//======================================================================= +template + Type& BOPCol_Array1::ChangeValue(const Standard_Integer theIndex) { + return operator()(theIndex); + } +//======================================================================= +//function : FindBlock +//purpose : +//======================================================================= +template + Standard_Boolean BOPCol_Array1::FindBlock(const Standard_Integer theIndex)const { + Standard_Boolean bRet; + // + bRet=myPBlock->Contains(theIndex); + if(bRet) { + return bRet; + } + // + Standard_Integer i1, i2; + BOPCol_PMemBlock pBlock, *xPBlock; + // + xPBlock=(BOPCol_PMemBlock*)&myPBlock; + pBlock=myPBlock1; + // + i1=0; + i2=myStartSize-1; + do { + if (theIndex>=i1 && theIndex<=i2) { + *xPBlock=pBlock; + return !bRet; + } + // + i1=i2+1; + i2=i1+myIncrement-1; + pBlock=pBlock->myNext; + } while(pBlock); + // + return bRet; + } + +#endif diff --git a/src/BOPCol/BOPCol_BaseAllocator.hxx b/src/BOPCol/BOPCol_BaseAllocator.hxx new file mode 100644 index 0000000000..33525f406d --- /dev/null +++ b/src/BOPCol/BOPCol_BaseAllocator.hxx @@ -0,0 +1,27 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPCol_BaseAllocator_HeaderFile +#define BOPCol_BaseAllocator_HeaderFile + +#include + +typedef Handle_NCollection_BaseAllocator BOPCol_BaseAllocator; + +#endif diff --git a/src/BOPCol/BOPCol_DataMapOfIntegerInteger.hxx b/src/BOPCol/BOPCol_DataMapOfIntegerInteger.hxx new file mode 100644 index 0000000000..173058397c --- /dev/null +++ b/src/BOPCol/BOPCol_DataMapOfIntegerInteger.hxx @@ -0,0 +1,32 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPCol_DataMapOfIntegerInteger_HeaderFile +#define BOPCol_DataMapOfIntegerInteger_HeaderFile + +#include + +#include + +typedef NCollection_DataMap BOPCol_DataMapOfIntegerInteger; +typedef BOPCol_DataMapOfIntegerInteger::Iterator BOPCol_DataMapIteratorOfDataMapOfIntegerInteger; + +#undef _NCollection_MapHasher + +#endif diff --git a/src/BOPCol/BOPCol_DataMapOfIntegerListOfInteger.hxx b/src/BOPCol/BOPCol_DataMapOfIntegerListOfInteger.hxx new file mode 100644 index 0000000000..d531627c6e --- /dev/null +++ b/src/BOPCol/BOPCol_DataMapOfIntegerListOfInteger.hxx @@ -0,0 +1,34 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPCol_DataMapOfIntegerListOfInteger_HeaderFile +#define BOPCol_DataMapOfIntegerListOfInteger_HeaderFile + + +#include + +#include +#include + +typedef NCollection_DataMap BOPCol_DataMapOfIntegerListOfInteger; +typedef BOPCol_DataMapOfIntegerListOfInteger::Iterator BOPCol_DataMapIteratorOfDataMapOfIntegerListOfInteger; + +#undef _NCollection_MapHasher + +#endif diff --git a/src/BOPCol/BOPCol_DataMapOfIntegerListOfShape.hxx b/src/BOPCol/BOPCol_DataMapOfIntegerListOfShape.hxx new file mode 100644 index 0000000000..837d90810f --- /dev/null +++ b/src/BOPCol/BOPCol_DataMapOfIntegerListOfShape.hxx @@ -0,0 +1,34 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPCol_DataMapOfIntegerListOfShape_HeaderFile +#define BOPCol_DataMapOfIntegerListOfShape_HeaderFile + +#include + +#include +#include + +typedef NCollection_DataMap BOPCol_DataMapOfIntegerListOfShape; +typedef BOPCol_DataMapOfIntegerListOfShape::Iterator BOPCol_DataMapIteratorOfDataMapOfIntegerListOfShape; + +#undef _NCollection_MapHasher + + +#endif diff --git a/src/BOPCol/BOPCol_DataMapOfIntegerMapOfInteger.hxx b/src/BOPCol/BOPCol_DataMapOfIntegerMapOfInteger.hxx new file mode 100644 index 0000000000..7bf0de0c7c --- /dev/null +++ b/src/BOPCol/BOPCol_DataMapOfIntegerMapOfInteger.hxx @@ -0,0 +1,34 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPCol_DataMapOfIntegerMapOfInteger_HeaderFile +#define BOPCol_DataMapOfIntegerMapOfInteger_HeaderFile + + +#include + +#include +#include + +typedef NCollection_DataMap BOPCol_DataMapOfIntegerMapOfInteger; +typedef BOPCol_DataMapOfIntegerMapOfInteger::Iterator BOPCol_DataMapIteratorOfDataMapOfIntegerMapOfInteger; + +#undef _NCollection_MapHasher + +#endif diff --git a/src/BOPCol/BOPCol_DataMapOfIntegerShape.hxx b/src/BOPCol/BOPCol_DataMapOfIntegerShape.hxx new file mode 100644 index 0000000000..c065dd0df1 --- /dev/null +++ b/src/BOPCol/BOPCol_DataMapOfIntegerShape.hxx @@ -0,0 +1,39 @@ +// Created by: Eugeny MALTCHIKOV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + +#ifndef BOPCol_DataMapOfIntegerShape_HeaderFile +#define BOPCol_DataMapOfIntegerShape_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +#include +#include + +#include + +typedef NCollection_DataMap BOPCol_DataMapOfIntegerShape; +typedef BOPCol_DataMapOfIntegerShape::Iterator BOPCol_DataMapIteratorOfDataMapOfIntegerShape; + +#undef _NCollection_MapHasher + +#endif diff --git a/src/BOPCol/BOPCol_DataMapOfShapeAddress.hxx b/src/BOPCol/BOPCol_DataMapOfShapeAddress.hxx new file mode 100644 index 0000000000..b972aaa031 --- /dev/null +++ b/src/BOPCol/BOPCol_DataMapOfShapeAddress.hxx @@ -0,0 +1,41 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPCol_DataMapOfShapeAddress_HeaderFile +#define BOPCol_DataMapOfShapeAddress_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +#include +#include + +#include + +typedef NCollection_DataMap BOPCol_DataMapOfShapeAddress; +typedef BOPCol_DataMapOfShapeAddress::Iterator BOPCol_DataMapIteratorOfDataMapOfShapeAddress; + +#undef _NCollection_MapHasher + + +#endif diff --git a/src/BOPCol/BOPCol_DataMapOfShapeInteger.hxx b/src/BOPCol/BOPCol_DataMapOfShapeInteger.hxx new file mode 100644 index 0000000000..1b9146cdef --- /dev/null +++ b/src/BOPCol/BOPCol_DataMapOfShapeInteger.hxx @@ -0,0 +1,40 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPCol_DataMapOfShapeInteger_HeaderFile +#define BOPCol_DataMapOfShapeInteger_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +#include +#include + +#include + +typedef NCollection_DataMap BOPCol_DataMapOfShapeInteger; +typedef BOPCol_DataMapOfShapeInteger::Iterator BOPCol_DataMapIteratorOfDataMapOfShapeInteger; + +#undef _NCollection_MapHasher + +#endif diff --git a/src/BOPCol/BOPCol_DataMapOfShapeListOfShape.hxx b/src/BOPCol/BOPCol_DataMapOfShapeListOfShape.hxx new file mode 100644 index 0000000000..95fba60a51 --- /dev/null +++ b/src/BOPCol/BOPCol_DataMapOfShapeListOfShape.hxx @@ -0,0 +1,36 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPCol_DataMapOfShapeListOfShape_HeaderFile +#define BOPCol_DataMapOfShapeListOfShape_HeaderFile + +#include +#include +#include + +#include + + + +typedef NCollection_DataMap BOPCol_DataMapOfShapeListOfShape; +typedef BOPCol_DataMapOfShapeListOfShape::Iterator BOPCol_DataMapIteratorOfDataMapOfShapeListOfShape; + +#undef _NCollection_MapHasher + +#endif diff --git a/src/BOPCol/BOPCol_DataMapOfShapeShape.hxx b/src/BOPCol/BOPCol_DataMapOfShapeShape.hxx new file mode 100644 index 0000000000..e290424691 --- /dev/null +++ b/src/BOPCol/BOPCol_DataMapOfShapeShape.hxx @@ -0,0 +1,34 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPCol_DataMapOfShapeShape_HeaderFile +#define BOPCol_DataMapOfShapeShape_HeaderFile + +#include +#include + +#include + +typedef NCollection_DataMap BOPCol_DataMapOfShapeShape; +typedef BOPCol_DataMapOfShapeShape::Iterator BOPCol_DataMapIteratorOfDataMapOfShapeShape; + +#undef _NCollection_MapHasher + + +#endif diff --git a/src/BOPCol/BOPCol_DataMapOfTransientAddress.hxx b/src/BOPCol/BOPCol_DataMapOfTransientAddress.hxx new file mode 100644 index 0000000000..6a6f7d5184 --- /dev/null +++ b/src/BOPCol/BOPCol_DataMapOfTransientAddress.hxx @@ -0,0 +1,40 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPCol_DataMapOfTransientAddress_HeaderFile +#define BOPCol_DataMapOfTransientAddress_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + + +#include +#include + +typedef NCollection_DataMap BOPCol_DataMapOfTransientAddress; +typedef BOPCol_DataMapOfTransientAddress::Iterator BOPCol_DataMapIteratorOfDataMapOfTransientAddress; + +#undef _NCollection_MapHasher + + +#endif diff --git a/src/BOPCol/BOPCol_IndexedDataMapOfShapeBox.hxx b/src/BOPCol/BOPCol_IndexedDataMapOfShapeBox.hxx new file mode 100644 index 0000000000..22fa2c9438 --- /dev/null +++ b/src/BOPCol/BOPCol_IndexedDataMapOfShapeBox.hxx @@ -0,0 +1,35 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPCol_IndexedDataMapOfShapeBox_HeaderFile +#define BOPCol_IndexedDataMapOfShapeBox_HeaderFile + +#include +#include +#include + +#include + + +typedef NCollection_IndexedDataMap BOPCol_IndexedDataMapOfShapeBox; + +#undef _NCollection_MapHasher + + +#endif diff --git a/src/BOPCol/BOPCol_IndexedDataMapOfShapeListOfShape.hxx b/src/BOPCol/BOPCol_IndexedDataMapOfShapeListOfShape.hxx new file mode 100644 index 0000000000..68317f90bf --- /dev/null +++ b/src/BOPCol/BOPCol_IndexedDataMapOfShapeListOfShape.hxx @@ -0,0 +1,34 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPCol_IndexedDataMapOfShapeListOfShape_HeaderFile +#define BOPCol_IndexedDataMapOfShapeListOfShape_HeaderFile + + +#include +#include +#include + +#include + +typedef NCollection_IndexedDataMap BOPCol_IndexedDataMapOfShapeListOfShape; +#undef _NCollection_MapHasher + + +#endif diff --git a/src/BOPCol/BOPCol_IndexedMapOfInteger.hxx b/src/BOPCol/BOPCol_IndexedMapOfInteger.hxx new file mode 100644 index 0000000000..f7461605c1 --- /dev/null +++ b/src/BOPCol/BOPCol_IndexedMapOfInteger.hxx @@ -0,0 +1,30 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPCol_IndexedMapOfInteger_HeaderFile +#define BOPCol_IndexedMapOfInteger_HeaderFile + +#include +#include + +typedef NCollection_IndexedMap BOPCol_IndexedMapOfInteger; + +#undef _NCollection_MapHasher + +#endif diff --git a/src/BOPCol/BOPCol_IndexedMapOfShape.hxx b/src/BOPCol/BOPCol_IndexedMapOfShape.hxx new file mode 100644 index 0000000000..8ac8df1678 --- /dev/null +++ b/src/BOPCol/BOPCol_IndexedMapOfShape.hxx @@ -0,0 +1,34 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPCol_IndexedMapOfShape_HeaderFile +#define BOPCol_IndexedMapOfShape_HeaderFile + +#include +#include + + +#include + +typedef NCollection_IndexedMap BOPCol_IndexedMapOfShape; + +#undef _NCollection_MapHasher + + +#endif diff --git a/src/BOPCol/BOPCol_ListOfInteger.hxx b/src/BOPCol/BOPCol_ListOfInteger.hxx new file mode 100644 index 0000000000..4e2c0aa143 --- /dev/null +++ b/src/BOPCol/BOPCol_ListOfInteger.hxx @@ -0,0 +1,36 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPCol_ListOfInteger_HeaderFile +#define BOPCol_ListOfInteger_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +#include + +typedef NCollection_List BOPCol_ListOfInteger; +typedef BOPCol_ListOfInteger::Iterator BOPCol_ListIteratorOfListOfInteger; +typedef BOPCol_ListOfInteger* BOPCol_PListOfInteger; + +#endif diff --git a/src/BOPCol/BOPCol_ListOfListOfShape.hxx b/src/BOPCol/BOPCol_ListOfListOfShape.hxx new file mode 100644 index 0000000000..cbf766c687 --- /dev/null +++ b/src/BOPCol/BOPCol_ListOfListOfShape.hxx @@ -0,0 +1,31 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPCol_ListOfListOfShape_HeaderFile +#define BOPCol_ListOfListOfShape_HeaderFile + + +#include +#include + +typedef NCollection_List BOPCol_ListOfListOfShape; +typedef BOPCol_ListOfListOfShape::Iterator BOPCol_ListIteratorOfListOfListOfShape; + + +#endif diff --git a/src/BOPCol/BOPCol_ListOfShape.hxx b/src/BOPCol/BOPCol_ListOfShape.hxx new file mode 100644 index 0000000000..1872c0fa8c --- /dev/null +++ b/src/BOPCol/BOPCol_ListOfShape.hxx @@ -0,0 +1,30 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPCol_ListOfShape_HeaderFile +#define BOPCol_ListOfShape_HeaderFile + +#include +#include + +typedef NCollection_List BOPCol_ListOfShape; +typedef BOPCol_ListOfShape::Iterator BOPCol_ListIteratorOfListOfShape; + + +#endif diff --git a/src/BOPCol/BOPCol_MapOfInteger.hxx b/src/BOPCol/BOPCol_MapOfInteger.hxx new file mode 100644 index 0000000000..6e8aa11aab --- /dev/null +++ b/src/BOPCol/BOPCol_MapOfInteger.hxx @@ -0,0 +1,40 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPCol_MapOfInteger_HeaderFile +#define BOPCol_MapOfInteger_HeaderFile + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +#include + +#include + +typedef NCollection_Map BOPCol_MapOfInteger; +typedef BOPCol_MapOfInteger::Iterator BOPCol_MapIteratorOfMapOfInteger; + +#undef _NCollection_MapHasher + +#endif diff --git a/src/BOPCol/BOPCol_MapOfOrientedShape.hxx b/src/BOPCol/BOPCol_MapOfOrientedShape.hxx new file mode 100644 index 0000000000..2dee3e707b --- /dev/null +++ b/src/BOPCol/BOPCol_MapOfOrientedShape.hxx @@ -0,0 +1,34 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPCol_MapOfOrientedShape_HeaderFile +#define BOPCol_MapOfOrientedShape_HeaderFile + +#include +#include + +#include + +typedef NCollection_Map BOPCol_MapOfOrientedShape; +typedef BOPCol_MapOfOrientedShape::Iterator BOPCol_MapIteratorOfMapOfOrientedShape; + +#undef _NCollection_MapHasher + + +#endif diff --git a/src/BOPCol/BOPCol_MapOfShape.hxx b/src/BOPCol/BOPCol_MapOfShape.hxx new file mode 100644 index 0000000000..1a62a065f0 --- /dev/null +++ b/src/BOPCol/BOPCol_MapOfShape.hxx @@ -0,0 +1,33 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPCol_MapOfShape_HeaderFile +#define BOPCol_MapOfShape_HeaderFile + +#include +#include + +#include + +typedef NCollection_Map BOPCol_MapOfShape; +typedef BOPCol_MapOfShape::Iterator BOPCol_MapIteratorOfMapOfShape; + +#undef _NCollection_MapHasher + +#endif diff --git a/src/BOPCol/BOPCol_PInteger.hxx b/src/BOPCol/BOPCol_PInteger.hxx new file mode 100644 index 0000000000..49fd7b4efb --- /dev/null +++ b/src/BOPCol/BOPCol_PInteger.hxx @@ -0,0 +1,28 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPCol_PInteger_HeaderFile +#define BOPCol_PInteger_HeaderFile + +#include +#include + +typedef Standard_Integer* BOPCol_PInteger; + +#endif diff --git a/src/BOPCol/BOPCol_PListOfInteger.hxx b/src/BOPCol/BOPCol_PListOfInteger.hxx new file mode 100644 index 0000000000..57279ba563 --- /dev/null +++ b/src/BOPCol/BOPCol_PListOfInteger.hxx @@ -0,0 +1,25 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPCol_PListOfInteger_HeaderFile +#define BOPCol_PListOfInteger_HeaderFile + +#include + +#endif diff --git a/src/BOPCol/BOPCol_SequenceOfPnt2d.hxx b/src/BOPCol/BOPCol_SequenceOfPnt2d.hxx new file mode 100644 index 0000000000..e239c5bcad --- /dev/null +++ b/src/BOPCol/BOPCol_SequenceOfPnt2d.hxx @@ -0,0 +1,30 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPCol_SequenceOfPnt2d_HeaderFile +#define BOPCol_SequenceOfPnt2d_HeaderFile + + +#include +#include + +typedef NCollection_Sequence BOPCol_SequenceOfPnt2d; + + +#endif diff --git a/src/BOPCol/BOPCol_SequenceOfReal.hxx b/src/BOPCol/BOPCol_SequenceOfReal.hxx new file mode 100644 index 0000000000..f0ac31cccc --- /dev/null +++ b/src/BOPCol/BOPCol_SequenceOfReal.hxx @@ -0,0 +1,29 @@ +// Created by: Eugeny MALTCHIKOV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPCol_SequenceOfReal_HeaderFile +#define BOPCol_SequenceOfReal_HeaderFile + +#include +#include + +typedef NCollection_Sequence BOPCol_SequenceOfReal; + + +#endif diff --git a/src/BOPCol/BOPCol_SequenceOfShape.hxx b/src/BOPCol/BOPCol_SequenceOfShape.hxx new file mode 100644 index 0000000000..94e3a54e0d --- /dev/null +++ b/src/BOPCol/BOPCol_SequenceOfShape.hxx @@ -0,0 +1,29 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPCol_SequenceOfShape_HeaderFile +#define BOPCol_SequenceOfShape_HeaderFile + +#include +#include + +typedef NCollection_Sequence BOPCol_SequenceOfShape; + + +#endif diff --git a/src/BOPCol/BOPCol_VectorOfInteger.hxx b/src/BOPCol/BOPCol_VectorOfInteger.hxx new file mode 100644 index 0000000000..f37ef48bbc --- /dev/null +++ b/src/BOPCol/BOPCol_VectorOfInteger.hxx @@ -0,0 +1,35 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPCol_VectorOfInteger_HeaderFile +#define BOPCol_VectorOfInteger_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +#include + +typedef BOPCol_Array1 BOPDS_VectorOfInteger; + + +#endif diff --git a/src/BOPCol/FILES b/src/BOPCol/FILES new file mode 100644 index 0000000000..21f91fabff --- /dev/null +++ b/src/BOPCol/FILES @@ -0,0 +1,28 @@ +BOPCol_Array1.hxx +BOPCol_DataMapOfShapeInteger.hxx +BOPCol_MapOfInteger.hxx +BOPCol_ListOfInteger.hxx +BOPCol_PInteger.hxx +BOPCol_DataMapOfIntegerListOfInteger.hxx +BOPCol_IndexedDataMapOfShapeBox.hxx +BOPCol_DataMapOfIntegerInteger.hxx +BOPCol_DataMapOfIntegerMapOfInteger.hxx +BOPCol_IndexedMapOfInteger.hxx +BOPCol_ListOfShape.hxx +BOPCol_DataMapOfShapeAddress.hxx +BOPCol_DataMapOfTransientAddress.hxx +BOPCol_PListOfInteger.hxx +BOPCol_VectorOfInteger.hxx +BOPCol_MapOfShape.hxx +BOPCol_DataMapOfShapeShape.hxx +BOPCol_DataMapOfShapeListOfShape.hxx +BOPCol_MapOfOrientedShape.hxx +BOPCol_IndexedDataMapOfShapeListOfShape.hxx +BOPCol_IndexedMapOfShape.hxx +BOPCol_ListOfListOfShape.hxx +BOPCol_SequenceOfShape.hxx +BOPCol_SequenceOfPnt2d.hxx +BOPCol_BaseAllocator.hxx +BOPCol_DataMapOfIntegerListOfShape.hxx +BOPCol_SequenceOfReal.hxx +BOPCol_DataMapOfIntegerShape.hxx diff --git a/src/BOPDS/BOPDS.cdl b/src/BOPDS/BOPDS.cdl new file mode 100644 index 0000000000..883c1dc30e --- /dev/null +++ b/src/BOPDS/BOPDS.cdl @@ -0,0 +1,108 @@ +-- Created by: Peter KURNEV +-- Copyright (c) 1999-2012 OPEN CASCADE SAS +-- +-- The content of this file is subject to the Open CASCADE Technology Public +-- License Version 6.5 (the "License"). You may not use the content of this file +-- except in compliance with the License. Please obtain a copy of the License +-- at http://www.opencascade.org and read it completely before using this file. +-- +-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +-- +-- The Original Code and all software distributed under the License is +-- distributed on an "AS IS" basis, without warranty of any kind, and the +-- Initial Developer hereby disclaims all such warranties, including without +-- limitation, any warranties of merchantability, fitness for a particular +-- purpose or non-infringement. Please see the License for the specific terms +-- and conditions governing the rights and limitations under the License. + + +package BOPDS + + ---Purpose: + -- The package contains classes that implements + -- the data structure for + -- general fuse and boolean operation algorithms + +uses + MMgt, + TCollection, + TColStd, + gp, + Bnd, + TopAbs, + TopoDS, + TopTools, + IntTools, + -- + BOPCol +is + -- + -- classes + -- + class ShapeInfo; + class IndexRange; + class DS; + class PassKey; + class PassKeyBoolean; + class PassKeyMapHasher; + class Tools; + class Iterator; + class Pave; + class PaveMapHasher; + class PaveBlock; + class CommonBlock; + class SubIterator; + class Point; + class Curve; + class FaceInfo; + class IteratorSI; + -- + -- pointers + -- + pointer PDS to DS from BOPDS; + pointer PIterator to Iterator from BOPDS; + -- + -- primitives + -- + imported VectorOfShapeInfo from BOPDS; + imported VectorOfIndexRange from BOPDS; + imported ListOfPassKeyBoolean from BOPDS; + imported ListIteratorOfListOfPassKeyBoolean from BOPDS; + imported DataMapOfIntegerListOfInteger from BOPDS; + imported MapOfPassKey from BOPDS; + imported MapOfPassKeyBoolean from BOPDS; + imported VectorOfListOfPassKeyBoolean from BOPDS; + imported ListOfPave from BOPDS; + imported ListOfPaveBlock from BOPDS; + imported VectorOfListOfPaveBlock from BOPDS; + imported DataMapOfPaveBlockListOfPaveBlock from BOPDS; + imported MapOfPaveBlock from BOPDS; + imported DataMapOfPaveBlockListOfInteger from BOPDS; + imported DataMapOfPassKeyListOfPaveBlock from BOPDS; + imported CoupleOfPaveBlocks from BOPDS; + imported DataMapOfShapeCoupleOfPaveBlocks from BOPDS; + imported MapOfCommonBlock from BOPDS; + imported VectorOfFaceInfo from BOPDS; + imported MapOfPave from BOPDS; + -- + imported Interf from BOPDS; + imported InterfVV from BOPDS; + imported InterfVE from BOPDS; + imported InterfVF from BOPDS; + imported InterfEE from BOPDS; + imported InterfEF from BOPDS; + imported InterfFF from BOPDS; + -- + imported VectorOfInterfVV from BOPDS; + imported VectorOfInterfVE from BOPDS; + imported VectorOfInterfVF from BOPDS; + imported VectorOfInterfEE from BOPDS; + imported VectorOfInterfEF from BOPDS; + imported VectorOfInterfFF from BOPDS; + -- + imported VectorOfPoint from BOPDS; + imported VectorOfCurve from BOPDS; + -- +end BOPDS; + diff --git a/src/BOPDS/BOPDS_BoxBndTree.cxx b/src/BOPDS/BOPDS_BoxBndTree.cxx new file mode 100644 index 0000000000..133ff5de9b --- /dev/null +++ b/src/BOPDS/BOPDS_BoxBndTree.cxx @@ -0,0 +1,84 @@ +// Created by: Peter KURNEV +// Copyright (c) 2010-2012 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 +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#include +//======================================================================= +//function : +//purpose : +//======================================================================= + BOPDS_BoxBndTreeSelector::BOPDS_BoxBndTreeSelector() +{ +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= + BOPDS_BoxBndTreeSelector::~BOPDS_BoxBndTreeSelector() +{ +} +//======================================================================= +//function : Reject +//purpose : +//======================================================================= + Standard_Boolean BOPDS_BoxBndTreeSelector::Reject (const Bnd_Box& aBox) const +{ + return myBox.IsOut(aBox); +} +//======================================================================= +//function : Accept +//purpose : +//======================================================================= + Standard_Boolean BOPDS_BoxBndTreeSelector::Accept (const Standard_Integer& aIndex) +{ + Standard_Boolean bRet=Standard_False; + // + //if (myFence.Add(aIndex)) { + myIndices.Append(aIndex); + bRet=!bRet; + //} + return bRet; +} +//======================================================================= +//function : SetBox +//purpose : +//======================================================================= + void BOPDS_BoxBndTreeSelector::SetBox(const Bnd_Box& aBox) +{ + myBox=aBox; +} +//======================================================================= +//function : Clear +//purpose : +//======================================================================= + void BOPDS_BoxBndTreeSelector::Clear() +{ + //myFence.Clear(); + myIndices.Clear(); +} +//======================================================================= +//function : Indices +//purpose : +//======================================================================= + const BOPCol_ListOfInteger& BOPDS_BoxBndTreeSelector::Indices() const +{ + return myIndices; +} diff --git a/src/BOPDS/BOPDS_BoxBndTree.hxx b/src/BOPDS/BOPDS_BoxBndTree.hxx new file mode 100644 index 0000000000..3867fc1a0a --- /dev/null +++ b/src/BOPDS/BOPDS_BoxBndTree.hxx @@ -0,0 +1,53 @@ +// Created by: Peter KURNEV +// Copyright (c) 2010-2012 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 +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef NMTDS_BoxBndTree_HeaderFile +#define NMTDS_BoxBndTree_HeaderFile + +#include +#include +#include +/** + * The instantiation of the algorithm of unbalanced binary tree + * of overlapped bounding boxes. + * +*/ +typedef NCollection_UBTree BOPDS_BoxBndTree; + + class BOPDS_BoxBndTreeSelector : public BOPDS_BoxBndTree::Selector { + public: + Standard_EXPORT BOPDS_BoxBndTreeSelector(); + Standard_EXPORT virtual Standard_Boolean Reject(const Bnd_Box&) const; + Standard_EXPORT virtual Standard_Boolean Accept(const Standard_Integer &); + Standard_EXPORT virtual ~BOPDS_BoxBndTreeSelector(); + + Standard_EXPORT void Clear(); + Standard_EXPORT void SetBox(const Bnd_Box&); + Standard_EXPORT const BOPCol_ListOfInteger& Indices() const; + + protected: + Bnd_Box myBox; + BOPCol_ListOfInteger myIndices; + + }; + +#endif diff --git a/src/BOPDS/BOPDS_CommonBlock.cdl b/src/BOPDS/BOPDS_CommonBlock.cdl new file mode 100644 index 0000000000..e1fe43bfe1 --- /dev/null +++ b/src/BOPDS/BOPDS_CommonBlock.cdl @@ -0,0 +1,180 @@ +-- Created by: Peter KURNEV +-- Copyright (c) 1999-2012 OPEN CASCADE SAS +-- +-- The content of this file is subject to the Open CASCADE Technology Public +-- License Version 6.5 (the "License"). You may not use the content of this file +-- except in compliance with the License. Please obtain a copy of the License +-- at http://www.opencascade.org and read it completely before using this file. +-- +-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +-- +-- The Original Code and all software distributed under the License is +-- distributed on an "AS IS" basis, without warranty of any kind, and the +-- Initial Developer hereby disclaims all such warranties, including without +-- limitation, any warranties of merchantability, fitness for a particular +-- purpose or non-infringement. Please see the License for the specific terms +-- and conditions governing the rights and limitations under the License. + + + +class CommonBlock from BOPDS + inherits TShared from MMgt + ---Purpose: + + ---Purpose: + -- The class BOPDS_CommonBlock is to store + -- the information about pave blocks that have + -- geometry coincidence (in terms of a tolerance) with + -- a) other pave block(s) + -- b) face(s) + +uses + ListOfInteger from BOPCol, + BaseAllocator from BOPCol, + PaveBlock from BOPDS, + ListOfPaveBlock from BOPDS + +--raises + +is + Create + returns CommonBlock from BOPDS; + ---Purpose: + --- Empty contructor + --- + + Create (theAllocator: BaseAllocator from BOPCol) + returns CommonBlock from BOPDS; + ---Purpose: + --- Contructor + --- - the allocator to manage the memory + --- + + AddPaveBlock(me:mutable; + aPB : PaveBlock from BOPDS); + ---Purpose: + --- Modifier + --- Adds the pave block to the list of pave blocks + --- of the common block + + AddPaveBlocks(me:mutable; + aLPB:ListOfPaveBlock from BOPDS); + ---Purpose: + --- Modifier + --- Adds the list of pave blocks + --- to the list of pave blocks + --- of the common block + + AddFace(me:mutable; + aF : Integer from Standard); + ---Purpose: + --- Modifier + --- Adds the index of the face + --- to the list of indices of faces + --- of the common block + + AddFaces (me:mutable; + aLF:ListOfInteger from BOPCol); + ---Purpose: + --- Modifier + --- Adds the list of indices of faces + --- to the list of indices of faces + --- of the common block + + PaveBlocks(me) + returns ListOfPaveBlock from BOPDS; + ---C++: return const & + ---Purpose: + --- Selector + --- Returns the list of pave blocks + --- of the common block + + Faces (me) + returns ListOfInteger from BOPCol; + ---C++: return const & + ---Purpose: + --- Selector + --- Returns the list of indices of faces + --- of the common block + + PaveBlock1 (me) + returns PaveBlock from BOPDS; + ---C++: return const & + ---Purpose: + --- Selector + --- Returns the first pave block + --- of the common block + + PaveBlockOnEdge (me:mutable; + theIndex: Integer from Standard) + returns PaveBlock from BOPDS; + ---C++: return & + ---Purpose: + --- Selector + --- Returns the pave block that belongs + --- to the edge with index + + IsPaveBlockOnFace (me; + theIndex: Integer from Standard) + returns Boolean from Standard; + ---Purpose: + --- Query + --- Returns true if the common block contains + -- a pave block that belongs + --- to the face with index + + IsPaveBlockOnEdge (me; + theIndex: Integer from Standard) + returns Boolean from Standard; + ---Purpose: + --- Query + --- Returns true if the common block contains + -- a pave block that belongs + --- to the edge with index + + Contains(me; + thePB:PaveBlock from BOPDS) + returns Boolean from Standard; + ---Purpose: + --- Query + --- Returns true if the common block contains + -- a pave block that is equal to + + Contains(me; + theF: Integer from Standard) + returns Boolean from Standard; + ---Purpose: + --- Query + --- Returns true if the common block contains + -- the face with index equal to + + SetEdge(me:mutable; + theEdge:Integer from Standard); + ---Purpose: + --- Modifier + --- Assign the index as the edge index + --- to all pave blocks of the common block + + Edge(me) + returns Integer from Standard; + ---Purpose: + --- Selector + --- Returns the index of the edge + --- of all pave blocks of the common block + + Dump(me); + +fields + myPaveBlocks: ListOfPaveBlock from BOPDS is protected; + myFaces : ListOfInteger from BOPCol is protected; + +end CommonBlock; + + + + + + + + diff --git a/src/BOPDS/BOPDS_CommonBlock.cxx b/src/BOPDS/BOPDS_CommonBlock.cxx new file mode 100644 index 0000000000..934920cac4 --- /dev/null +++ b/src/BOPDS/BOPDS_CommonBlock.cxx @@ -0,0 +1,254 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#include + +//======================================================================= +// function: +// purpose: +//======================================================================= + BOPDS_CommonBlock::BOPDS_CommonBlock() +{ +} +//======================================================================= +// function: +// purpose: +//======================================================================= + BOPDS_CommonBlock::BOPDS_CommonBlock(const Handle(NCollection_BaseAllocator)& theAllocator) +: + myPaveBlocks(theAllocator), + myFaces(theAllocator) +{ +} +//======================================================================= +// function: AddPaveBlock +// purpose: +//======================================================================= + void BOPDS_CommonBlock::AddPaveBlock(const Handle(BOPDS_PaveBlock)& aPB) +{ + myPaveBlocks.Append(aPB); +} +//======================================================================= +// function: AddPaveBlocks +// purpose: +//======================================================================= + void BOPDS_CommonBlock::AddPaveBlocks(const BOPDS_ListOfPaveBlock& aLPB) +{ + myPaveBlocks=aLPB; +} +//======================================================================= +// function: PaveBlocks +// purpose: +//======================================================================= + const BOPDS_ListOfPaveBlock& BOPDS_CommonBlock::PaveBlocks()const +{ + return myPaveBlocks; +} +//======================================================================= +// function: AddFace +// purpose: +//======================================================================= + void BOPDS_CommonBlock::AddFace(const Standard_Integer aF) +{ + myFaces.Append(aF); +} +//======================================================================= +// function: AddFaces +// purpose: +//======================================================================= + void BOPDS_CommonBlock::AddFaces(const BOPCol_ListOfInteger& aLF) +{ + myFaces=aLF; +} +//======================================================================= +// function: Faces +// purpose: +//======================================================================= + const BOPCol_ListOfInteger& BOPDS_CommonBlock::Faces()const +{ + return myFaces; +} +//======================================================================= +// function: PaveBlock1 +// purpose: +//======================================================================= + const Handle(BOPDS_PaveBlock)& BOPDS_CommonBlock::PaveBlock1()const +{ + return myPaveBlocks.First(); +} +//======================================================================= +// function: PaveBlockOnEdge +// purpose: +//======================================================================= + Handle(BOPDS_PaveBlock)& BOPDS_CommonBlock::PaveBlockOnEdge(const Standard_Integer aIx) +{ + static Handle(BOPDS_PaveBlock) aPBs; + // + Standard_Integer aIOr; + BOPDS_ListIteratorOfListOfPaveBlock anIt; + // + anIt.Initialize(myPaveBlocks); + for (; anIt.More(); anIt.Next()) { + Handle(BOPDS_PaveBlock)& aPB=anIt.ChangeValue(); + aIOr=aPB->OriginalEdge(); + if (aIOr==aIx){ + return aPB; + } + } + return aPBs; +} +//======================================================================= +// function: IsPaveBlockOnFace +// purpose: +//======================================================================= + Standard_Boolean BOPDS_CommonBlock::IsPaveBlockOnFace(const Standard_Integer aIx)const +{ + Standard_Boolean bFound; + Standard_Integer nF; + BOPCol_ListIteratorOfListOfInteger anIt; + // + bFound=Standard_False; + anIt.Initialize(myFaces); + for (; anIt.More(); anIt.Next()) { + nF=anIt.Value(); + if (nF==aIx){ + return !bFound; + } + } + return bFound; +} +//======================================================================= +// function: IsPaveBlockOnEdge +// purpose: +//======================================================================= + Standard_Boolean BOPDS_CommonBlock::IsPaveBlockOnEdge(const Standard_Integer aIx)const +{ + Standard_Boolean bFound; + Standard_Integer aIOr; + BOPDS_ListIteratorOfListOfPaveBlock anIt; + // + bFound=Standard_False; + anIt.Initialize(myPaveBlocks); + for (; anIt.More(); anIt.Next()) { + const Handle(BOPDS_PaveBlock)& aPB=anIt.Value(); + aIOr=aPB->OriginalEdge(); + if (aIOr==aIx){ + return !bFound; + } + } + return bFound; +} +//======================================================================= +//function : SetEdge +//purpose : +//======================================================================= + void BOPDS_CommonBlock::SetEdge(const Standard_Integer theEdge) +{ + BOPDS_ListIteratorOfListOfPaveBlock anIt; + // + anIt.Initialize(myPaveBlocks); + for (; anIt.More(); anIt.Next()) { + Handle(BOPDS_PaveBlock)& aPB=anIt.ChangeValue(); + aPB->SetEdge(theEdge); + } +} +//======================================================================= +//function : Edge +//purpose : +//======================================================================= + Standard_Integer BOPDS_CommonBlock::Edge()const +{ + const Handle(BOPDS_PaveBlock)& aPB1=myPaveBlocks.First(); + if(!aPB1.IsNull()) { + return aPB1->Edge(); + } + return -1; +} +//======================================================================= +// function: Contains +// purpose: +//======================================================================= + Standard_Boolean BOPDS_CommonBlock::Contains(const Handle(BOPDS_PaveBlock)& aPBx)const +{ + Standard_Boolean bFound; + Standard_Integer aNb1; + BOPDS_ListIteratorOfListOfPaveBlock anIt; + // + bFound=Standard_False; + aNb1=myPaveBlocks.Extent(); + // + if (!aNb1) { + return bFound; + } + // + anIt.Initialize(myPaveBlocks); + for (; anIt.More(); anIt.Next()) { + const Handle(BOPDS_PaveBlock)& aPB=anIt.Value(); + if (aPB==aPBx) { + return !bFound; + } + } + return bFound; +} +//======================================================================= +// function: Contains +// purpose: +//======================================================================= + Standard_Boolean BOPDS_CommonBlock::Contains(const Standard_Integer theF)const +{ + Standard_Boolean bFound; + BOPCol_ListIteratorOfListOfInteger aIt; + // + bFound=Standard_False; + aIt.Initialize(myFaces); + for (; aIt.More(); aIt.Next()) { + if (aIt.Value()==theF) { + return !bFound; + } + } + return bFound; +} +//======================================================================= +// function: Dump +// purpose: +//======================================================================= + void BOPDS_CommonBlock::Dump()const +{ + Standard_Integer nF; + BOPCol_ListIteratorOfListOfInteger aIt; + BOPDS_ListIteratorOfListOfPaveBlock aItPB; + // + printf(" -- CB:\n"); + aItPB.Initialize(myPaveBlocks); + for (; aItPB.More(); aItPB.Next()) { + const Handle(BOPDS_PaveBlock)& aPB=aItPB.Value(); + aPB->Dump(); + printf("\n"); + } + // + if (myFaces.Extent()) { + printf(" Faces:"); + aIt.Initialize(myFaces); + for (; aIt.More(); aIt.Next()) { + nF=aIt.Value(); + printf(" %d", nF); + } + printf("\n"); + } +} diff --git a/src/BOPDS/BOPDS_CoupleOfPaveBlocks.hxx b/src/BOPDS/BOPDS_CoupleOfPaveBlocks.hxx new file mode 100644 index 0000000000..46652f89a2 --- /dev/null +++ b/src/BOPDS/BOPDS_CoupleOfPaveBlocks.hxx @@ -0,0 +1,168 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPDS_CoupleOfPaveBlocks_HeaderFile +#define BOPDS_CoupleOfPaveBlocks_HeaderFile + +#include + +/** + * The Class BOPDS_CoupleOfPaveBlocks is to store + * the information about two pave blocks + * and some satellite information + * +*/ +//======================================================================= +//class : BOPDS_CoupleOfPaveBlocks +//purpose : +//======================================================================= +class BOPDS_CoupleOfPaveBlocks { + public: + /** + * Constructor + */ + BOPDS_CoupleOfPaveBlocks() { + myIndex=-1; + myIndexInterf=-1; + }; + // + /** + * Constructor + * @param thePB1 + * first pave block + * @param thePB2 + * secondt pave block + */ + BOPDS_CoupleOfPaveBlocks(const Handle(BOPDS_PaveBlock)& thePB1, + const Handle(BOPDS_PaveBlock)& thePB2) { + myIndex=-1; + myIndexInterf=-1; + SetPaveBlocks(thePB1, thePB2); + }; + // + /** + * Destructor + */ + ~BOPDS_CoupleOfPaveBlocks() { + }; + // + /** + * Sets an index + * @param theIndex + * index + */ + void SetIndex(const Standard_Integer theIndex) { + myIndex=theIndex; + } + // + /** + * Returns the index + * @return + * index + */ + Standard_Integer Index()const { + return myIndex; + } + // + /** + * Sets an index of an interference + * @param theIndex + * index of an interference + */ + void SetIndexInterf(const Standard_Integer theIndex) { + myIndexInterf=theIndex; + } + // + /** + * Returns the index of an interference + * @return + * index of an interference + */ + Standard_Integer IndexInterf()const { + return myIndexInterf; + } + // + /** + * Sets pave blocks + * @param thePB1 + * first pave block + * @param thePB2 + * secondt pave block + */ + void SetPaveBlocks(const Handle(BOPDS_PaveBlock)& thePB1, + const Handle(BOPDS_PaveBlock)& thePB2) { + myPB[0]=thePB1; + myPB[1]=thePB2; + } + // + /** + * Returns pave blocks + * @param thePB1 + * the first pave block + * @param thePB2 + * the second pave block + */ + void PaveBlocks(Handle(BOPDS_PaveBlock)& thePB1, + Handle(BOPDS_PaveBlock)& thePB2) const { + thePB1=myPB[0]; + thePB2=myPB[1]; + } + // + /** + * Sets the first pave block + * @param thePB + * the first pave block + */ + void SetPaveBlock1(const Handle(BOPDS_PaveBlock)& thePB) { + myPB[0]=thePB; + } + /** + * Returns the first pave block + * @return + * the first pave block + */ + const Handle(BOPDS_PaveBlock)& PaveBlock1()const { + return myPB[0]; + } + // + /** + * Sets the second pave block + * @param thePB + * the second pave block + */ + void SetPaveBlock2(const Handle(BOPDS_PaveBlock)& thePB) { + myPB[1]=thePB; + } + // + /** + * Returns the second pave block + * @return + * the second pave block + */ + const Handle(BOPDS_PaveBlock)& PaveBlock2()const { + return myPB[1]; + } + // + protected: + Standard_Integer myIndexInterf; + Standard_Integer myIndex; + Handle(BOPDS_PaveBlock) myPB[2]; +}; +// +#endif diff --git a/src/BOPDS/BOPDS_Curve.cdl b/src/BOPDS/BOPDS_Curve.cdl new file mode 100644 index 0000000000..12a9fab223 --- /dev/null +++ b/src/BOPDS/BOPDS_Curve.cdl @@ -0,0 +1,157 @@ +-- Created by: Peter KURNEV +-- Copyright (c) 1999-2012 OPEN CASCADE SAS +-- +-- The content of this file is subject to the Open CASCADE Technology Public +-- License Version 6.5 (the "License"). You may not use the content of this file +-- except in compliance with the License. Please obtain a copy of the License +-- at http://www.opencascade.org and read it completely before using this file. +-- +-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +-- +-- The Original Code and all software distributed under the License is +-- distributed on an "AS IS" basis, without warranty of any kind, and the +-- Initial Developer hereby disclaims all such warranties, including without +-- limitation, any warranties of merchantability, fitness for a particular +-- purpose or non-infringement. Please see the License for the specific terms +-- and conditions governing the rights and limitations under the License. + + +class Curve from BOPDS + + ---Purpose: + -- The class BOPDS_Curve is to store + -- the information about intersection curve + +uses + Box from Bnd, + Curve from IntTools, + ListOfInteger from BOPCol, + BaseAllocator from BOPCol, + ListOfPaveBlock from BOPDS, + PaveBlock from BOPDS + +--raises + +is + Create + returns Curve from BOPDS; + ---C++: alias "virtual ~BOPDS_Curve();" + ---C++: inline + ---Purpose: + --- Empty contructor + --- + Create (theAllocator: BaseAllocator from BOPCol) + returns Curve from BOPDS; + ---C++: inline + ---Purpose: + --- Contructor + --- - the allocator to manage the memory + --- + + SetCurve(me:out; + theC:Curve from IntTools); + ---C++: inline + ---Purpose: + --- Modifier + --- Sets the curve + + Curve(me) + returns Curve from IntTools; + ---C++: return const & + ---C++: inline + ---Purpose: + --- Selector + --- Returns the curve + + SetBox(me:out; + theBox:Box from Bnd); + ---C++: inline + ---Purpose: + --- Modifier + --- Sets the bounding box of the curve + + Box(me) + returns Box from Bnd; + ---C++: return const & + ---C++: inline + ---Purpose: + --- Selector + --- Returns the bounding box of the curve + + ChangeBox(me:out) + returns Box from Bnd; + ---C++: return & + ---C++: inline + ---Purpose: + --- Selector/Modifier + --- Returns the bounding box of the curve + SetPaveBlocks(me:out; + theLPB:ListOfPaveBlock from BOPDS); + + PaveBlocks (me) + returns ListOfPaveBlock from BOPDS; + ---C++: return const & + ---C++: inline + ---Purpose: + --- Selector + --- Returns the list of pave blocks + --- of the curve + + ChangePaveBlocks (me:out) + returns ListOfPaveBlock from BOPDS; + ---C++: return & + ---C++: inline + ---Purpose: + --- Selector/Modifier + --- Returns the list of pave blocks + --- of the curve + + InitPaveBlock1(me:out); + ---C++: inline + ---Purpose: + --- Creates initial pave block + --- of the curve + + ChangePaveBlock1(me:out) + returns PaveBlock from BOPDS; + ---C++: return & + ---C++: inline + ---Purpose: + --- Selector/Modifier + --- Returns initial pave block + --- of the curve + + TechnoVertices (me) + returns ListOfInteger from BOPCol; + ---C++: return const & + ---C++: inline + ---Purpose: + --- Selector + --- Returns list of indices of technologic vertices + --- of the curve + + ChangeTechnoVertices (me:out) + returns ListOfInteger from BOPCol; + ---C++: return & + ---C++: inline + ---Purpose: + --- Selector/Modifier + --- Returns list of indices of technologic vertices + --- of the curve + + HasEdge(me) + returns Boolean from Standard; + ---C++: inline + ---Purpose: + --- Query + --- Returns true if at least one pave block of the curve + -- has edge +fields + myAllocator : BaseAllocator from BOPCol is protected; + myCurve : Curve from IntTools is protected; + myPaveBlocks : ListOfPaveBlock from BOPDS is protected; + myTechnoVertices : ListOfInteger from BOPCol is protected; + myBox : Box from Bnd is protected; + +end Curve; diff --git a/src/BOPDS/BOPDS_Curve.cxx b/src/BOPDS/BOPDS_Curve.cxx new file mode 100644 index 0000000000..7e5e014eb5 --- /dev/null +++ b/src/BOPDS/BOPDS_Curve.cxx @@ -0,0 +1,20 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#include diff --git a/src/BOPDS/BOPDS_Curve.lxx b/src/BOPDS/BOPDS_Curve.lxx new file mode 100644 index 0000000000..f2979581c9 --- /dev/null +++ b/src/BOPDS/BOPDS_Curve.lxx @@ -0,0 +1,173 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + +//======================================================================= +//function : +//purpose : +//======================================================================= + inline BOPDS_Curve::BOPDS_Curve() +: + myAllocator(NCollection_BaseAllocator::CommonBaseAllocator()), + myPaveBlocks(myAllocator), + myTechnoVertices(myAllocator) +{ +} +//======================================================================= +//function : +//purpose : +//======================================================================= + inline BOPDS_Curve::BOPDS_Curve(const Handle(NCollection_BaseAllocator)& theAllocator) +: + myAllocator(theAllocator), + myPaveBlocks(myAllocator), + myTechnoVertices(myAllocator) +{ +} +//======================================================================= +//function : +//purpose : +//======================================================================= + inline BOPDS_Curve::~BOPDS_Curve() +{ +} +//======================================================================= +//function : SetCurve +//purpose : +//======================================================================= + inline void BOPDS_Curve::SetCurve(const IntTools_Curve& theCurve) +{ + myCurve=theCurve; +} +//======================================================================= +//function : Curve +//purpose : +//======================================================================= + inline const IntTools_Curve& BOPDS_Curve::Curve()const +{ + return myCurve; +} +//======================================================================= +//function : SetPaveBlocks +//purpose : +//======================================================================= + inline void BOPDS_Curve::SetPaveBlocks(const BOPDS_ListOfPaveBlock& theLPB) +{ + BOPDS_ListIteratorOfListOfPaveBlock aIt; + // + myPaveBlocks.Clear(); + aIt.Initialize(theLPB); + for (; aIt.More(); aIt.Next()) { + myPaveBlocks.Append(aIt.Value()); + } +} +//======================================================================= +//function : PaveBlocks +//purpose : +//======================================================================= + inline const BOPDS_ListOfPaveBlock& BOPDS_Curve::PaveBlocks()const +{ + return myPaveBlocks; +} +//======================================================================= +//function : ChangePaveBlocks +//purpose : +//======================================================================= + inline BOPDS_ListOfPaveBlock& BOPDS_Curve::ChangePaveBlocks() +{ + return myPaveBlocks; +} +//======================================================================= +//function : InitPaveBlock1 +//purpose : +//======================================================================= + inline void BOPDS_Curve::InitPaveBlock1() +{ + if (!myPaveBlocks.Extent()) { + Handle(BOPDS_PaveBlock) aPB=new BOPDS_PaveBlock; + myPaveBlocks.Append(aPB); + } +} +//======================================================================= +//function : ChangePaveBlock1 +//purpose : +//======================================================================= + inline Handle(BOPDS_PaveBlock)& BOPDS_Curve::ChangePaveBlock1() +{ + Handle_BOPDS_PaveBlock* pPB=(Handle_BOPDS_PaveBlock*)&myPaveBlocks.First(); + return *pPB; +} +//======================================================================= +//function : TechnoVertices +//purpose : +//======================================================================= + inline const BOPCol_ListOfInteger& BOPDS_Curve::TechnoVertices()const +{ + return myTechnoVertices; +} +//======================================================================= +//function : ChangeTechnoVertices +//purpose : +//======================================================================= + inline BOPCol_ListOfInteger& BOPDS_Curve::ChangeTechnoVertices() +{ + return myTechnoVertices; +} +//======================================================================= +//function : SetBox +//purpose : +//======================================================================= + inline void BOPDS_Curve::SetBox(const Bnd_Box& theBox) +{ + myBox=theBox; +} +//======================================================================= +//function : Box +//purpose : +//======================================================================= + inline const Bnd_Box& BOPDS_Curve::Box()const +{ + return myBox; +} +//======================================================================= +//function : ChangeBox +//purpose : +//======================================================================= + inline Bnd_Box& BOPDS_Curve::ChangeBox() +{ + return myBox; +} +//======================================================================= +//function : HasEdge +//purpose : +//======================================================================= + inline Standard_Boolean BOPDS_Curve::HasEdge()const +{ + Standard_Boolean bFlag; + BOPDS_ListIteratorOfListOfPaveBlock aItPB; + // + bFlag=Standard_False; + aItPB.Initialize(myPaveBlocks); + for (; aItPB.More(); aItPB.Next()) { + const Handle(BOPDS_PaveBlock)& aPB=aItPB.Value(); + bFlag=aPB->HasEdge(); + if (bFlag) { + break; + } + } + return bFlag; +} diff --git a/src/BOPDS/BOPDS_DS.cdl b/src/BOPDS/BOPDS_DS.cdl new file mode 100644 index 0000000000..db2a38a489 --- /dev/null +++ b/src/BOPDS/BOPDS_DS.cdl @@ -0,0 +1,559 @@ +-- Created by: Peter KURNEV +-- Copyright (c) 1999-2012 OPEN CASCADE SAS +-- +-- The content of this file is subject to the Open CASCADE Technology Public +-- License Version 6.5 (the "License"). You may not use the content of this file +-- except in compliance with the License. Please obtain a copy of the License +-- at http://www.opencascade.org and read it completely before using this file. +-- +-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +-- +-- The Original Code and all software distributed under the License is +-- distributed on an "AS IS" basis, without warranty of any kind, and the +-- Initial Developer hereby disclaims all such warranties, including without +-- limitation, any warranties of merchantability, fitness for a particular +-- purpose or non-infringement. Please see the License for the specific terms +-- and conditions governing the rights and limitations under the License. + + +class DS from BOPDS + + ---Purpose: + -- The class BOPDS_DS provides the control + -- the data structure for + -- partition and boolean operation algorithms + -- + -- The data structure has the following contents: + -- 1. the arguments of an operation [myArguments]; + -- 2 the information about arguments/new shapes + -- and their sub-shapes (type of the shape, + -- bounding box, etc) [myLines]; + -- 3. each argument shape(and its subshapes) + -- has/have own range of indices (rank) + -- 4. pave blocks on source edges [myPaveBlocksPool]; + -- 5. the state of source faces [myFaceInfoPool] + -- 6 the collection of same domain shapes [myShapesSD] + -- 7 the collection of interferences [myInterfTB, + -- myInterfVV,..myInterfFF] + +uses + ShapeEnum from TopAbs, + Shape from TopoDS, + -- + ListOfShape from BOPCol, + DataMapOfIntegerInteger from BOPCol, + DataMapOfShapeInteger from BOPCol, + ListOfInteger from BOPCol, + MapOfInteger from BOPCol, + BaseAllocator from BOPCol, + -- + ShapeInfo from BOPDS, + IndexRange from BOPDS, + VectorOfIndexRange from BOPDS, + VectorOfShapeInfo from BOPDS, + VectorOfListOfPaveBlock from BOPDS, + ListOfPaveBlock from BOPDS, + ListOfPave from BOPDS, + PaveBlock from BOPDS, + CommonBlock from BOPDS, + MapOfPaveBlock from BOPDS, + VectorOfFaceInfo from BOPDS, + FaceInfo from BOPDS, + -- + MapOfPassKey from BOPDS, + -- + VectorOfInterfVV from BOPDS, + VectorOfInterfVE from BOPDS, + VectorOfInterfVF from BOPDS, + VectorOfInterfEE from BOPDS, + VectorOfInterfEF from BOPDS, + VectorOfInterfFF from BOPDS + +--raises + +is + Create + returns DS from BOPDS; + ---C++: alias "Standard_EXPORT virtual ~BOPDS_DS();" + ---Purpose: + --- Empty contructor + --- + Create (theAllocator: BaseAllocator from BOPCol) + returns DS from BOPDS; + ---Purpose: + --- Contructor + --- theAllocator - the allocator to manage the memory + --- + + Clear(me:out); + ---Purpose: + -- Clears the contents + + Allocator(me) + returns BaseAllocator from BOPCol; + ---C++: return const & + ---Purpose: + --- Selector + --- + + SetArguments(me:out; + theLS:ListOfShape from BOPCol); + ---Purpose: + --- Modifier + --- Sets the arguments [theLS] of an operation + + Arguments(me) + returns ListOfShape from BOPCol; + ---C++: return const & + ---Purpose: + --- Selector + --- Returns the arguments of an operation + + Init(me:out); + ---Purpose: + --- Initializes the data structure for + -- the arguments + + NbShapes(me) + returns Integer from Standard; + ---Purpose: + --- Selector + --- Returns the total number of shapes stored + + NbSourceShapes(me) + returns Integer from Standard; + ---Purpose: + --- Selector + --- Returns the total number of source shapes stored + + NbRanges(me) + returns Integer from Standard; + ---Purpose: + --- Selector + --- Returns the number of index ranges + + Range(me; + theIndex:Integer from Standard) + returns IndexRange from BOPDS; + ---C++: return const & + ---Purpose: + --- Selector + --- Returns the index range "i" + + Rank (me; + theIndex:Integer from Standard) + returns Integer from Standard; + ---Purpose: + --- Selector + --- Returns the rank of the shape of index "i" + + IsNewShape(me; + theIndex:Integer from Standard) + returns Boolean from Standard; + ---Purpose: + --- Returns true if the shape of index "i" is not + --- the source shape/sub-shape + + -- + -- shapes and auxiliary info + -- + Append(me:out; + theSI:ShapeInfo from BOPDS) + returns Integer from Standard; + ---Purpose: + --- Modifier + --- Appends the information about the shape [theSI] + --- to the data structure + --- Returns the index of theSI in the data structure + + Append(me:out; + theS:Shape from TopoDS) + returns Integer from Standard; + ---Purpose: + --- Modifier + --- Appends the default information about the shape [theS] + --- to the data structure + --- Returns the index of theS in the data structure + + ShapeInfo(me; + theIndex:Integer from Standard) + returns ShapeInfo from BOPDS; + ---C++: return const & + ---Purpose: + --- Selector + --- Returns the information about the shape + --- with index theIndex + + ChangeShapeInfo(me:out; + theIndex:Integer from Standard) + returns ShapeInfo from BOPDS; + ---C++: return & + ---Purpose: + --- Selector/Modifier + --- Returns the information about the shape + --- with index theIndex + + Shape(me; + theIndex:Integer from Standard) + returns Shape from TopoDS; + ---C++: return const & + ---Purpose: + --- Selector + --- Returns the shape + -- with index theIndex + + Index(me; + theS:Shape from TopoDS) + returns Integer from Standard; + ---Purpose: + --- Selector + --- Returns the index of the shape theS + + -- + -- pave blocks + -- + PaveBlocksPool(me) + returns VectorOfListOfPaveBlock from BOPDS; + ---C++: return const & + ---Purpose: + --- Selector + --- Returns the information about pave blocks on source edges + + ChangePaveBlocksPool(me:out) + returns VectorOfListOfPaveBlock from BOPDS; + ---C++: return & + ---Purpose: + --- Selector/Modifier + --- Returns the information about pave blocks on source edges + + HasPaveBlocks(me; + theIndex:Integer from Standard) + returns Boolean from Standard; + ---Purpose: + --- Query + --- Returns true if the shape with index theIndex has the + --- information about pave blocks + + PaveBlocks (me; + theIndex:Integer from Standard) + returns ListOfPaveBlock from BOPDS; + ---C++: return const & + ---Purpose: + --- Selector + --- Returns the pave blocks for the shape with index theIndex + + ChangePaveBlocks (me:out; + theIndex:Integer from Standard) + returns ListOfPaveBlock from BOPDS; + ---C++: return & + ---Purpose: + --- Selector/Modifier + --- Returns the pave blocks for the shape with index theIndex + + InitPaveBlocks(me:out; + theIndex:Integer from Standard) + is protected; + ---Purpose: + --- Initializes the pave blocks for the shape with index theIndex + + UpdatePaveBlocks(me:out); + ---Purpose: + --- Update the pave blocks for the all shapes in data structure + + UpdatePaveBlock(me:out; + thePB:PaveBlock from BOPDS); + ---Purpose: + --- Update the pave block thePB + + UpdateCommonBlock(me:out; + theCB:CommonBlock from BOPDS); + ---Purpose: + --- Update the common block theCB + -- + -- face info + -- + FaceInfoPool(me) + returns VectorOfFaceInfo from BOPDS; + ---C++: return const & + ---Purpose: + --- Selector + --- Returns the information about state of faces + + HasFaceInfo(me; + theIndex:Integer from Standard) + returns Boolean from Standard; + ---Purpose: + --- Query + --- Returns true if the shape with index theIndex has the + --- information about state of face + + FaceInfo(me; + theIndex:Integer from Standard) + returns FaceInfo from BOPDS; + ---C++: return const & + ---Purpose: + --- Selector + --- Returns the state of face with index theIndex + + ChangeFaceInfo(me:out; + theIndex:Integer from Standard) + returns FaceInfo from BOPDS; + ---C++: return & + ---Purpose: + --- Selector/Modifier + --- Returns the state of face with index theIndex + + InitFaceInfo(me:out; + theIndex:Integer from Standard) + is protected; + ---Purpose: + --- Initializes the state of face with index theIndex + + UpdateFaceInfoIn(me:out; + theIndex:Integer from Standard); + ---Purpose: + --- Update the state In of face with index theIndex + + UpdateFaceInfoOn(me:out; + theIndex:Integer from Standard); + ---Purpose: + --- Update the state On of face with index theIndex + + FaceInfoOn(me:out; + theIndex:Integer from Standard; + theMPB:out MapOfPaveBlock from BOPDS; + theMVP:out MapOfInteger from BOPCol); + ---Purpose: + --- Selector + --- Returns the state On + --- [theMPB,theMVP] of face with index theIndex + + FaceInfoIn(me:out; + theIndex:Integer from Standard; + theMPB:out MapOfPaveBlock from BOPDS; + theMVP:out MapOfInteger from BOPCol); + ---Purpose: + --- Selector + --- Returns the state In + --- [theMPB,theMVP] of face with index theIndex + + AloneVertices(me; + theF:Integer from Standard; + theLI:out ListOfInteger from BOPCol); + ---Purpose: + --- Selector + --- Returns the indices of alone vertices + --- for the face with index theIndex + + RefineFaceInfoOn(me:out); + ---Purpose: + --- Refine the state On for the all faces having + --- state information + -- + -- ++ + -- + VerticesOnIn(me; + theF1:Integer from Standard; + theF2:Integer from Standard; + theMI:out MapOfInteger from BOPCol; + aMPB: out MapOfPaveBlock from BOPDS); + ---Purpose: + --- Returns the indices of vertices and pave blocks + --- that are On/In for the faces with indices theF1, theF2 + + SharedEdges(me:out; + theF1:Integer from Standard; + theF2:Integer from Standard; + theLI:out ListOfInteger from BOPCol; + theAllocator:BaseAllocator from BOPCol); + ---Purpose: + --- Returns the indices of edges that are shared + --- for the faces with indices theF1, theF2 + -- + -- same domain shapes + -- + ShapesSD (me:out) + returns DataMapOfIntegerInteger from BOPCol; + ---C++: return & + ---Purpose: + --- Selector + --- Returns the collection same domain shapes + + AddShapeSD(me:out; + theIndex:Integer from Standard; + theIndexSD:Integer from Standard); + ---Purpose: + --- Modifier + --- Adds the information about same domain shapes + --- with indices theIndex, theIndexSD + + HasShapeSD(me; + theIndex:Integer from Standard; + theIndexSD:out Integer from Standard) + returns Boolean from Standard; + ---Purpose: + --- Query + --- Returns true if the shape with index theIndex has the + --- same domain shape. In this case theIndexSD will contain + -- the index of same domain shape found + -- + -- interferences + -- + InterfVV(me:out) + returns VectorOfInterfVV from BOPDS; + ---C++: return & + ---C++: inline + ---Purpose: + --- Selector/Modifier + --- Returns the collection of interferences Vertex/Vertex + + InterfVE(me:out) + returns VectorOfInterfVE from BOPDS; + ---C++: return & + ---C++: inline + ---Purpose: + --- Selector/Modifier + --- Returns the collection of interferences Vertex/Edge + + InterfVF(me:out) + returns VectorOfInterfVF from BOPDS; + ---C++: return & + ---C++: inline + ---Purpose: + --- Selector/Modifier + --- Returns the collection of interferences Vertex/Face + + InterfEE(me:out) + returns VectorOfInterfEE from BOPDS; + ---C++: return & + ---C++: inline + ---Purpose: + --- Selector/Modifier + --- Returns the collection of interferences Edge/Edge + + InterfEF(me:out) + returns VectorOfInterfEF from BOPDS; + ---C++: return & + ---C++: inline + ---Purpose: + --- Selector/Modifier + --- Returns the collection of interferences Edge/Face + + InterfFF(me:out) + returns VectorOfInterfFF from BOPDS; + ---C++: return & + ---C++: inline + ---Purpose: + --- Selector/Modifier + --- Returns the collection of interferences Face/Face + + AddInterf(me:out; + theI1:Integer from Standard; + theI2:Integer from Standard); + ---C++: inline + ---Purpose: + --- Modifier + --- Adds the information about an interference between + --- shapes with indices theI1, theI2 to the summary + --- table of interferences + + HasInterf(me; + theI:Integer from Standard) + returns Boolean from Standard; + ---Purpose: + --- Query + --- Returns true if the shape with index theI + --- is interferred + + HasInterf(me; + theI1:Integer from Standard; + theI2:Integer from Standard) + returns Boolean from Standard; + ---C++: inline + ---Purpose: + --- Query + --- Returns true if the shapes with indices theI1, theI2 + --- are interferred + + HasInterfSubShapes(me; + theI1:Integer from Standard; + theI2:Integer from Standard) + returns Boolean from Standard; + ---Purpose: + --- Query + --- Returns true if the shapes with indices theI1, theI2 + --- have interferred sub-shapes + + Interferences(me) + returns MapOfPassKey from BOPDS; + ---C++: return const & + ---C++: inline + ---Purpose: + --- Selector + --- Returns the table of interferences + -- + -- debug + -- + Dump(me); + -- + -- protected methods + -- + InitShape(me:out; + theIndex:Integer from Standard; + theS:Shape from TopoDS; + theAllocator:out BaseAllocator from BOPCol; + theMSI:out DataMapOfShapeInteger from BOPCol) + is protected; + + CheckCoincidence(me:out; + thePB1:PaveBlock from BOPDS; + thePB2:PaveBlock from BOPDS) + returns Boolean from Standard + is protected; + + SortPaveBlocks(me:out; + theCB:CommonBlock from BOPDS); + + IsToSort(me:out; + theCB:CommonBlock from BOPDS; + theI:out Integer from Standard) + returns Boolean from Standard; + + IsSubShape(me:out; + theI1:Integer from Standard; + theI2:Integer from Standard) + returns Boolean from Standard; + + Paves(me:out; + theIndex:Integer from Standard; + theLP:out ListOfPave from BOPDS); + ---Purpose: Fills theLP with sorted paves + -- of the shape with index theIndex + +fields + myAllocator : BaseAllocator from BOPCol is protected; + myArguments : ListOfShape from BOPCol is protected; + --contents + myNbShapes : Integer from Standard is protected; + myNbSourceShapes : Integer from Standard is protected; + myRanges : VectorOfIndexRange from BOPDS is protected; + myLines : VectorOfShapeInfo from BOPDS is protected; + myMapShapeIndex : DataMapOfShapeInteger from BOPCol is protected; + -- + myPaveBlocksPool : VectorOfListOfPaveBlock from BOPDS is protected; + myFaceInfoPool : VectorOfFaceInfo from BOPDS is protected; + -- + --same domain shapes + myShapesSD : DataMapOfIntegerInteger from BOPCol is protected; + -- + --interferences + myInterfTB : MapOfPassKey from BOPDS is protected; + myInterfVV : VectorOfInterfVV from BOPDS is protected; + myInterfVE : VectorOfInterfVE from BOPDS is protected; + myInterfVF : VectorOfInterfVF from BOPDS is protected; + myInterfEE : VectorOfInterfEE from BOPDS is protected; + myInterfEF : VectorOfInterfEF from BOPDS is protected; + myInterfFF : VectorOfInterfFF from BOPDS is protected; + +end DS; diff --git a/src/BOPDS/BOPDS_DS.cxx b/src/BOPDS/BOPDS_DS.cxx new file mode 100644 index 0000000000..880b3fcfd9 --- /dev/null +++ b/src/BOPDS/BOPDS_DS.cxx @@ -0,0 +1,1776 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#include +// + +#include +#include + +#include +#include +// +#include +#include +#include +#include +#include +#include +// +#include +// +#include +#include +#include +// +#include +#include +#include +#include +#include + +#include +#include +#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); + +//modified by NIZNHY-PKV Mon Jul 12 11:23:36 2010f +static + Standard_Real ComputeParameter(const TopoDS_Vertex& aV, + const TopoDS_Edge& aE); +//modified by NIZNHY-PKV Mon Jul 12 11:23:40 2010t +static + void SortShell(const int n, BOPDS_Pave *a); + +//======================================================================= +//function : +//purpose : +//======================================================================= + BOPDS_DS::BOPDS_DS() +: + myAllocator(NCollection_BaseAllocator::CommonBaseAllocator()), + myArguments(myAllocator), + myRanges(myAllocator), + myLines(myAllocator), + myMapShapeIndex(100, myAllocator), + myPaveBlocksPool(myAllocator), + myFaceInfoPool(myAllocator), + myShapesSD(100, myAllocator), + myInterfTB(100, myAllocator), + myInterfVV(myAllocator), + myInterfVE(myAllocator), + myInterfVF(myAllocator), + myInterfEE(myAllocator), + myInterfEF(myAllocator), + myInterfFF(myAllocator) +{ + myNbShapes=0; + myNbSourceShapes=0; +} +//======================================================================= +//function : +//purpose : +//======================================================================= + BOPDS_DS::BOPDS_DS(const Handle(NCollection_BaseAllocator)& theAllocator) +: + myAllocator(theAllocator), + myArguments(myAllocator), + myRanges(myAllocator), + myLines(myAllocator), + myMapShapeIndex(100, myAllocator), + myPaveBlocksPool(myAllocator), + myFaceInfoPool(myAllocator), + myShapesSD(100, myAllocator), + myInterfTB(100, myAllocator), + myInterfVV(myAllocator), + myInterfVE(myAllocator), + myInterfVF(myAllocator), + myInterfEE(myAllocator), + myInterfEF(myAllocator), + myInterfFF(myAllocator) +{ + myNbShapes=0; + myNbSourceShapes=0; +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= + BOPDS_DS::~BOPDS_DS() +{ + Clear(); +} +//======================================================================= +//function : Clear +//purpose : +//======================================================================= + void BOPDS_DS::Clear() +{ + myNbShapes=0; + myNbSourceShapes=0; + // + myArguments.Clear(); + myRanges.Clear(); + myLines.Clear(); + myMapShapeIndex.Clear(); + myPaveBlocksPool.Clear(); + myFaceInfoPool.Clear(); + myShapesSD.Clear(); + myInterfTB.Clear(); + myInterfVV.Clear(); + myInterfVE.Clear(); + myInterfVF.Clear(); + myInterfEE.Clear(); + myInterfEF.Clear(); + myInterfFF.Clear(); +} +//======================================================================= +//function : SetArguments +//purpose : +//======================================================================= + void BOPDS_DS::SetArguments(const BOPCol_ListOfShape& theLS) +{ + myArguments=theLS; +} +//======================================================================= +//function : Arguments +//purpose : +//======================================================================= + const BOPCol_ListOfShape& BOPDS_DS::Arguments()const +{ + return myArguments; +} +//======================================================================= +//function : Allocator +//purpose : +//======================================================================= + const Handle(NCollection_BaseAllocator)& BOPDS_DS::Allocator()const +{ + return myAllocator; +} + +//======================================================================= +//function : NbShapes +//purpose : +//======================================================================= + Standard_Integer BOPDS_DS::NbShapes()const +{ + return myLines.Size(); +} +//======================================================================= +//function : NbSourceShapes +//purpose : +//======================================================================= + Standard_Integer BOPDS_DS::NbSourceShapes()const +{ + return myNbSourceShapes; +} +//======================================================================= +//function : NbRanges +//purpose : +//======================================================================= + Standard_Integer BOPDS_DS::NbRanges()const +{ + return myRanges.Size(); +} +//======================================================================= +//function : Range +//purpose : +//======================================================================= + const BOPDS_IndexRange& BOPDS_DS::Range(const Standard_Integer theI)const +{ + return myRanges(theI); +} +//======================================================================= +//function : Rank +//purpose : +//======================================================================= + Standard_Integer BOPDS_DS::Rank(const Standard_Integer theI)const +{ + Standard_Integer i, aNb, iErr; + // + iErr=-1; + aNb=NbRanges(); + for(i=0; i=NbSourceShapes(); +} +//======================================================================= +//function : Append +//purpose : +//======================================================================= + Standard_Integer BOPDS_DS::Append(const BOPDS_ShapeInfo& theSI) +{ + Standard_Integer iX; + // + iX=myLines.Append()-1; + myLines(iX)=theSI; + return iX; +} +//======================================================================= +//function : Append +//purpose : +//======================================================================= + Standard_Integer BOPDS_DS::Append(const TopoDS_Shape& theS) +{ + Standard_Integer iX; + // + iX=myLines.Append()-1; + myLines(iX).SetShape(theS); + return iX; +} +//======================================================================= +//function : ShapeInfo +//purpose : +//======================================================================= + const BOPDS_ShapeInfo& BOPDS_DS::ShapeInfo(const Standard_Integer theI)const +{ + return myLines(theI); +} +//======================================================================= +//function : ChangeShapeInfo +//purpose : +//======================================================================= + BOPDS_ShapeInfo& BOPDS_DS::ChangeShapeInfo(const Standard_Integer theI) +{ + BOPDS_ShapeInfo *pSI; + // + const BOPDS_ShapeInfo& aSI=ShapeInfo(theI); + pSI=(BOPDS_ShapeInfo *)&aSI; + return *pSI; +} +//======================================================================= +//function : Shape +//purpose : +//======================================================================= + const TopoDS_Shape& BOPDS_DS::Shape(const Standard_Integer theI)const +{ + const TopoDS_Shape& aS=ShapeInfo(theI).Shape(); + return aS; +} +//======================================================================= +//function : Index +//purpose : +//======================================================================= + Standard_Integer BOPDS_DS::Index(const TopoDS_Shape& theS)const +{ + Standard_Integer iRet; + // + iRet=-1; + if (myMapShapeIndex.IsBound(theS)) { + iRet=myMapShapeIndex.Find(theS); + } + return iRet; +} + +//======================================================================= +//function : Init +//purpose : +//======================================================================= + void BOPDS_DS::Init() +{ + Standard_Integer i1, i2, j, aI, aNb, aNbS, aNbE, aNbSx, nV, nW, nE, aNbF; + Standard_Real aTol; + TopAbs_ShapeEnum aTS; + BOPCol_ListIteratorOfListOfInteger aIt1, aIt2, aIt3; + BOPCol_ListIteratorOfListOfShape aIt; + BOPDS_IndexRange aR; + Handle(NCollection_IncAllocator) aAllocator; + // + // 1 Append Source Shapes + aNb=myArguments.Extent(); + if (!aNb) { + return; + } + // + 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); + aNbS=aNbS+aNbSx; + } + // + myLines.SetStartSize(2*aNbS); + myLines.SetIncrement(aNbS); + myLines.Init(); + // + //-----------------------------------------------------scope_1 f + aAllocator=new NCollection_IncAllocator(); + // + BOPCol_DataMapOfShapeInteger& aMSI=myMapShapeIndex; + // + i1=0; + i2=0; + aIt.Initialize(myArguments); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aS=aIt.Value(); + aI=Append(aS); + aMSI.Bind(aS, aI); + // + InitShape(aI, aS, aAllocator, aMSI); + // + i2=NbShapes()-1; + aR.SetIndices(i1, i2); + myRanges.Append(aR); + i1=i2+1; + } + // + //aMSI.Clear(); + // + myNbSourceShapes=NbShapes(); + // + // 2 Bounding Boxes + // + // 2.1 Vertex + for (j=0; jD0(aT1, aPx); + aBB.MakeVertex(aVx, aPx, aTol); + aVx.Orientation(TopAbs_FORWARD); + // + aSIx.SetShape(aVx); + aSIx.SetShapeType(TopAbs_VERTEX); + aSIx.SetFlag(1); //infinite flag + // + aIx=Append(aSIx); + aLI.Append(aIx); + } + if (bInf2) { + aC3D->D0(aT2, aPx); + aBB.MakeVertex(aVx, aPx, aTol); + aVx.Orientation(TopAbs_REVERSED); + // + aSIx.SetShape(aVx); + aSIx.SetShapeType(TopAbs_VERTEX); + aSIx.SetFlag(1);//infinite flag + // + aIx=Append(aSIx); + aLI.Append(aIx); + } + } + //modified by NIZHNY-EMV Fri Oct 07 14:46:32 2011 + else { + aSI.SetFlag(j); + } + //modified by NIZHNY-EMV Fri Oct 07 14:46:35 2011 + //modified by NIZNHY-PKV Mon Jul 12 07:46:12 2010t + // + Bnd_Box& aBox=aSI.ChangeBox(); + BRepBndLib::Add(aE, aBox); + // + const BOPCol_ListOfInteger& aLV=aSI.SubShapes(); + aIt1.Initialize(aLV); + for (; aIt1.More(); aIt1.Next()) { + nV=aIt1.Value(); + BOPDS_ShapeInfo& aSIV=ChangeShapeInfo(nV); + Bnd_Box& aBx=aSIV.ChangeBox(); + aBox.Add(aBx); + } + //modified by NIZHNY-EMV Thu May 12 09:58:56 2011 + //aBox.SetGap(aTol); + //modified by NIZHNY-EMV Thu May 12 09:58:59 2011 + ++aNbE; + } + } + // 2.3 Face + BOPCol_MapOfInteger aMI(100, aAllocator); + BOPCol_MapIteratorOfMapOfInteger aItMI; + // + aNbF=0; + for (j=0; jSetOriginalEdge(theI); + // + aIt.Initialize(aLV); + for (i=0; aIt.More(); aIt.Next(), ++i) { + nV=aIt.Value(); + // + const BOPDS_ShapeInfo& aSIV=ShapeInfo(nV); + aV=*(TopoDS_Vertex*)(&aSIV.Shape()); + if (aSIV.HasFlag()) { + aT=ComputeParameter(aV, aE); + } + else { + aT=BRep_Tool::Parameter(aV, aE); + } + // + if (HasShapeSD(nV, nVSD)) { + nV=nVSD; + } + aPave.SetIndex(nV); + aPave.SetParameter(aT); + aPB->AppendExtPave(aPave); + } + // + if (aNbV==1) { + aV.Reverse(); + aT=BRep_Tool::Parameter(aV, aE); + aPave.SetIndex(nV); + aPave.SetParameter(aT); + aPB->AppendExtPave1(aPave); + } + // + iRef=myPaveBlocksPool.Append()-1; + BOPDS_ListOfPaveBlock &aLPB=myPaveBlocksPool(iRef); + // + aPB->Update(aLPB, Standard_False); + // + aSI.SetReference(iRef); +} +//modified by NIZNHY-PKV Thu Jul 15 10:23:07 2010t +//======================================================================= +//function : UpdatePaveBlocks +//purpose : +//======================================================================= + void BOPDS_DS::UpdatePaveBlocks() +{ + Standard_Boolean bIsToUpdate; + Standard_Integer i, aNbPBP; + BOPDS_ListOfPaveBlock aLPBN(myAllocator); + BOPDS_ListIteratorOfListOfPaveBlock aItPB, aItPBN; + // + BOPDS_VectorOfListOfPaveBlock& aPBP=myPaveBlocksPool; + // + aNbPBP=aPBP.Size(); + for (i=0; iIsToUpdate(); + if (bIsToUpdate){ + aLPBN.Clear(); + aPB->Update(aLPBN); + + aItPBN.Initialize(aLPBN); + for (; aItPBN.More(); aItPBN.Next()) { + Handle(BOPDS_PaveBlock)& aPBN=aItPBN.ChangeValue(); + aLPB.Append(aPBN); + } + aLPB.Remove(aItPB); + } + }// for (; aItPB.More(); aItPB.Next()) { + }// for (i=0; iIsToUpdate()){ + return; + } + // + Standard_Integer nE, iRef; + BOPDS_ListIteratorOfListOfPaveBlock aItPB, aItPBN; + BOPDS_ListOfPaveBlock aLPBN(myAllocator); + Handle(BOPDS_PaveBlock) aPB; + // + BOPDS_VectorOfListOfPaveBlock& aPBP=myPaveBlocksPool; + // + nE=thePB->OriginalEdge(); + BOPDS_ShapeInfo& aSI=ChangeShapeInfo(nE); + iRef=aSI.Reference(); + BOPDS_ListOfPaveBlock& aLPB=aPBP(iRef); + // + aItPB.Initialize(aLPB); + for (; aItPB.More(); aItPB.Next()) { + aPB=aItPB.ChangeValue(); + if (aPB==thePB) { + aPB->Update(aLPBN); + // + aItPBN.Initialize(aLPBN); + for (; aItPBN.More(); aItPBN.Next()) { + Handle(BOPDS_PaveBlock)& aPBN=aItPBN.ChangeValue(); + aLPB.Append(aPBN); + } + aLPB.Remove(aItPB); + break; + } + } +} +//======================================================================= +//function : UpdateCommonBlock +//purpose : +//======================================================================= + void BOPDS_DS::UpdateCommonBlock(const Handle(BOPDS_CommonBlock)& theCB) +{ + Standard_Integer nE, iRef, n1, n2; + BOPDS_ListIteratorOfListOfPaveBlock aItPB, aItPBCB, aItPBN; + BOPDS_DataMapIteratorOfDataMapOfPassKeyListOfPaveBlock aItMPKLPB; + BOPDS_ListOfPaveBlock aLPBN; + BOPDS_DataMapOfPassKeyListOfPaveBlock aMPKLPB; + Handle(BOPDS_PaveBlock) aPB; + Handle(BOPDS_CommonBlock) aCBx; + BOPDS_PassKey aPK; + // + const BOPDS_ListOfPaveBlock& aLPBCB=theCB->PaveBlocks(); + if (!aLPBCB.First()->IsToUpdate()){ + return; + } + // + const BOPCol_ListOfInteger& aLF=theCB->Faces(); + // + BOPDS_VectorOfListOfPaveBlock& aPBP=myPaveBlocksPool; + // + aItPBCB.Initialize(aLPBCB); + for (; aItPBCB.More(); aItPBCB.Next()) { + const Handle(BOPDS_PaveBlock)& aPBCB=aItPBCB.ChangeValue(); + // + nE=aPBCB->OriginalEdge(); + iRef=ChangeShapeInfo(nE).Reference(); + BOPDS_ListOfPaveBlock& aLPB=aPBP(iRef); + // + aItPB.Initialize(aLPB); + for (; aItPB.More(); aItPB.Next()) { + aPB=aItPB.ChangeValue(); + if (aPB==aPBCB) { + // + aLPBN.Clear(); + aPB->Update(aLPBN); + // + aItPBN.Initialize(aLPBN); + for (; aItPBN.More(); aItPBN.Next()) { + Handle(BOPDS_PaveBlock)& aPBN=aItPBN.ChangeValue(); + aLPB.Append(aPBN); + // + aPBN->Indices(n1, n2); + aPK.SetIds(n1, n2); + if (aMPKLPB.IsBound(aPK)) { + BOPDS_ListOfPaveBlock& aLPBx=aMPKLPB.ChangeFind(aPK); + aLPBx.Append(aPBN); + } + else { + BOPDS_ListOfPaveBlock aLPBx; + aLPBx.Append(aPBN); + aMPKLPB.Bind(aPK, aLPBx); + } + } + aLPB.Remove(aItPB); + break; + } + } + } + // + aItMPKLPB.Initialize(aMPKLPB); + for (; aItMPKLPB.More(); aItMPKLPB.Next()) { + //modified by NIZHNY-EMV Mon Nov 21 12:17:46 2011 + BOPDS_ListOfPaveBlock& aLPBx=aItMPKLPB.ChangeValue(); + // + while (aLPBx.Extent()) { + Standard_Boolean bCoinside; + Standard_Real aTol, aTolMax(0.); + BOPDS_ListOfPaveBlock aLPBxN; + // + aItPB.Initialize(aLPBx); + for(; aItPB.More(); ) { + const Handle(BOPDS_PaveBlock)& aPBx=aItPB.Value(); + if (aLPBxN.Extent()) { + const Handle(BOPDS_PaveBlock)& aPBCx = aLPBxN.First(); + bCoinside = CheckCoincidence(aPBx, aPBCx); + if (bCoinside) { + nE = aPBx->OriginalEdge(); + const TopoDS_Edge& aE = *(TopoDS_Edge*)&Shape(nE); + aTol = BRep_Tool::Tolerance(aE); + // + //pave block with the max tolerance of the original edge + //must be the first in the common block + if (aTolMax < aTol) { + aTolMax = aTol; + aLPBxN.Prepend(aPBx); + } else { + aLPBxN.Append(aPBx); + } + aLPBx.Remove(aItPB); + continue; + }//if (bCoinside) { + }//if (aLPBxN.Extent()) { + else { + nE = aPBx->OriginalEdge(); + const TopoDS_Edge& aE = *(TopoDS_Edge*)&Shape(nE); + aTolMax = BRep_Tool::Tolerance(aE); + // + aLPBxN.Append(aPBx); + aLPBx.Remove(aItPB); + continue; + } + aItPB.Next(); + }//for(; aItPB.More(); ) { + // + aCBx=new BOPDS_CommonBlock; + aCBx->AddPaveBlocks(aLPBxN); + aCBx->AddFaces(aLF); + // + aItPB.Initialize(aLPBxN); + for (; aItPB.More(); aItPB.Next()) { + aPB=aItPB.ChangeValue(); + aPB->SetCommonBlock(aCBx); + } + } + //modified by NIZHNY-EMV Mon Nov 21 12:17:48 2011 + } +} +// +// FaceInfo +// + +//======================================================================= +//function : FaceInfoPool +//purpose : +//======================================================================= + const BOPDS_VectorOfFaceInfo& BOPDS_DS::FaceInfoPool()const +{ + return myFaceInfoPool; +} +//======================================================================= +//function : HasFaceInfo +//purpose : +//======================================================================= + Standard_Boolean BOPDS_DS::HasFaceInfo(const Standard_Integer theI)const +{ + return ShapeInfo(theI).HasReference(); +} +//======================================================================= +//function : FaceInfo +//purpose : +//======================================================================= + const BOPDS_FaceInfo& BOPDS_DS::FaceInfo(const Standard_Integer theI)const +{ + static BOPDS_FaceInfo sFI; + Standard_Integer aRef; + // + if (HasFaceInfo(theI)) { + aRef=ShapeInfo(theI).Reference(); + const BOPDS_FaceInfo& aFI=myFaceInfoPool(aRef); + return aFI; + } + return sFI; +} +//======================================================================= +//function : ChangeFaceInfo +//purpose : +//======================================================================= + BOPDS_FaceInfo& BOPDS_DS::ChangeFaceInfo(const Standard_Integer theI) +{ + Standard_Boolean bHasReference; + Standard_Integer aRef; + BOPDS_FaceInfo* pFI; + // + BOPDS_ShapeInfo& aSI=ChangeShapeInfo(theI); + bHasReference=aSI.HasReference(); + if (!bHasReference) { + InitFaceInfo(theI); + } + // + aRef=aSI.Reference(); + const BOPDS_FaceInfo& aFI=myFaceInfoPool(aRef); + pFI=(BOPDS_FaceInfo*)&aFI; + return *pFI; +} +//======================================================================= +//function : InitFaceInfo +//purpose : +//======================================================================= + void BOPDS_DS::InitFaceInfo(const Standard_Integer theI) +{ + Standard_Integer iRef; + // + BOPDS_ShapeInfo& aSI=ChangeShapeInfo(theI); + iRef=myFaceInfoPool.Append()-1; + BOPDS_FaceInfo &aFI=myFaceInfoPool(iRef); + aSI.SetReference(iRef); + // + aFI.SetIndex(theI); + UpdateFaceInfoIn(theI); + UpdateFaceInfoOn(theI); +} +//======================================================================= +//function : UpdateFaceInfoIn +//purpose : +//======================================================================= + void BOPDS_DS::UpdateFaceInfoIn(const Standard_Integer theI) +{ + Standard_Integer iRef; + // + BOPDS_ShapeInfo& aSI=ChangeShapeInfo(theI); + if (aSI.HasReference()) { + iRef=aSI.Reference(); + BOPDS_FaceInfo &aFI=myFaceInfoPool(iRef); + // + BOPDS_MapOfPaveBlock& aMPBIn=aFI.ChangePaveBlocksIn(); + BOPCol_MapOfInteger& aMVIn=aFI.ChangeVerticesIn(); + aMPBIn.Clear(); + aMVIn.Clear(); + FaceInfoIn(theI, aMPBIn, aMVIn); + } +} +//======================================================================= +//function : UpdateFaceInfoOn +//purpose : +//======================================================================= + void BOPDS_DS::UpdateFaceInfoOn(const Standard_Integer theI) +{ + Standard_Integer iRef; + // + BOPDS_ShapeInfo& aSI=ChangeShapeInfo(theI); + if (aSI.HasReference()) { + iRef=aSI.Reference(); + BOPDS_FaceInfo &aFI=myFaceInfoPool(iRef); + // + BOPDS_MapOfPaveBlock& aMPBOn=aFI.ChangePaveBlocksOn(); + BOPCol_MapOfInteger& aMVOn=aFI.ChangeVerticesOn(); + aMPBOn.Clear(); + aMVOn.Clear(); + FaceInfoOn(theI, aMPBOn, aMVOn); + } +} +//======================================================================= +//function : FaceInfoOn +//purpose : +//======================================================================= + void BOPDS_DS::FaceInfoOn(const Standard_Integer theF, + BOPDS_MapOfPaveBlock& theMPB, + BOPCol_MapOfInteger& theMI) +{ + Standard_Integer nS, nSD, nV1, nV2; + BOPCol_ListIteratorOfListOfInteger aIt; + BOPDS_ListIteratorOfListOfPaveBlock aItPB; + // + const BOPDS_ShapeInfo& aSI=ShapeInfo(theF); + const BOPCol_ListOfInteger& aLI=aSI.SubShapes(); + aIt.Initialize(aLI); + for (; aIt.More(); aIt.Next()) { + nS=aIt.Value(); + const BOPDS_ShapeInfo& aSIE=ShapeInfo(nS); + if (aSIE.ShapeType()==TopAbs_EDGE) { + const BOPDS_ListOfPaveBlock& aLPB=PaveBlocks(nS); + aItPB.Initialize(aLPB); + for (; aItPB.More(); aItPB.Next()) { + const Handle(BOPDS_PaveBlock)& aPB=aItPB.Value(); + aPB->Indices(nV1, nV2); + theMI.Add(nV1); + theMI.Add(nV2); + if (aPB->IsCommonBlock()) { + const Handle(BOPDS_CommonBlock)& aCB=aPB->CommonBlock(); + const Handle(BOPDS_PaveBlock)& aPB1=aCB->PaveBlock1(); + theMPB.Add(aPB1); + } + else { + theMPB.Add(aPB); + } + } + }//if (aSIE.ShapeType()==TopAbs_EDGE) + else { + // nE is TopAbs_VERTEX + if (HasShapeSD(nS, nSD)) { + nS=nSD; + } + theMI.Add(nS); + } + } +} +//======================================================================= +//function : FaceInfoIn +//purpose : +//======================================================================= + void BOPDS_DS::FaceInfoIn(const Standard_Integer theF, + BOPDS_MapOfPaveBlock& theMPB, + BOPCol_MapOfInteger& theMI) +{ + Standard_Integer i, aNbVF, aNbEF, nV, nE; + BOPDS_ListIteratorOfListOfPaveBlock aItPB; + // + BOPDS_VectorOfInterfVF& aVFs=InterfVF(); + aNbVF=aVFs.Extent(); + for (i=0; iIsCommonBlock()) { + const Handle(BOPDS_CommonBlock)& aCB=aPB->CommonBlock(); + if (aCB->Contains(theF)) { + const Handle(BOPDS_PaveBlock)& aPB1=aCB->PaveBlock1(); + theMPB.Add(aPB1); + } + } + }// for (; aItPB.More(); aItPB.Next()) { + }// else { + }// if(aEF.Contains(theF)) { + }// for (i=0; iHasEdge()) { + aMPBOn.Remove(aPB); + } + } + } +} +//======================================================================= +//function : AloneVertices +//purpose : +//======================================================================= + void BOPDS_DS::AloneVertices(const Standard_Integer theI, + BOPCol_ListOfInteger& theLI)const +{ + if (HasFaceInfo(theI)) { + // + Standard_Integer i, nV1, nV2, nV; + BOPDS_MapIteratorOfMapOfPaveBlock aItMPB; + BOPCol_MapIteratorOfMapOfInteger aItMI; + // + BOPCol_MapOfInteger aMI(100, myAllocator); + // + const BOPDS_FaceInfo& aFI=FaceInfo(theI); + // + for (i=0; i<2; ++i) { + const BOPDS_MapOfPaveBlock& aMPB=(!i) ? aFI.PaveBlocksIn() : aFI.PaveBlocksSc(); + aItMPB.Initialize(aMPB); + for (; aItMPB.More(); aItMPB.Next()) { + const Handle(BOPDS_PaveBlock)& aPB=aItMPB.Value(); + aPB->Indices(nV1, nV2); + aMI.Add(nV1); + aMI.Add(nV2); + } + } + // + for (i=0; i<2; ++i) { + const BOPCol_MapOfInteger& aMIV=(!i) ? aFI.VerticesIn() : aFI.VerticesSc(); + aItMI.Initialize(aMIV); + for (; aItMI.More(); aItMI.Next()) { + nV=aItMI.Value(); + if (nV>0) { + if (aMI.Add(nV)) { + theLI.Append(nV); + } + } + } + } + } +} + +//======================================================================= +//function : VerticesOnIn +//purpose : +//======================================================================= + void BOPDS_DS::VerticesOnIn(const Standard_Integer nF1, + const Standard_Integer nF2, + BOPCol_MapOfInteger& aMI, + BOPDS_MapOfPaveBlock& aMPB)const +{ + Standard_Integer nV, nV1, nV2; + BOPCol_MapIteratorOfMapOfInteger aIt; + BOPDS_MapIteratorOfMapOfPaveBlock aItMPB; + // + const BOPDS_FaceInfo& aFI1=FaceInfo(nF1); + const BOPDS_FaceInfo& aFI2=FaceInfo(nF2); + // + const BOPDS_MapOfPaveBlock& aMPBOn1=aFI1.PaveBlocksOn(); + aItMPB.Initialize(aMPBOn1); + for (; aItMPB.More(); aItMPB.Next()) { + const Handle(BOPDS_PaveBlock)& aPB=aItMPB.Value(); + aMPB.Add(aPB); + aPB->Indices(nV1, nV2); + aMI.Add(nV1); + aMI.Add(nV2); + } + // + const BOPDS_MapOfPaveBlock& aMPBIn1=aFI1.PaveBlocksIn(); + aItMPB.Initialize(aMPBIn1); + for (; aItMPB.More(); aItMPB.Next()) { + const Handle(BOPDS_PaveBlock)& aPB=aItMPB.Value(); + aMPB.Add(aPB); + aPB->Indices(nV1, nV2); + aMI.Add(nV1); + aMI.Add(nV2); + } + // + const BOPDS_MapOfPaveBlock& aMPBOn2=aFI2.PaveBlocksOn(); + aItMPB.Initialize(aMPBOn2); + for (; aItMPB.More(); aItMPB.Next()) { + const Handle(BOPDS_PaveBlock)& aPB=aItMPB.Value(); + aMPB.Add(aPB); + aPB->Indices(nV1, nV2); + aMI.Add(nV1); + aMI.Add(nV2); + } + // + const BOPDS_MapOfPaveBlock& aMPBIn2=aFI2.PaveBlocksIn(); + aItMPB.Initialize(aMPBIn2); + for (; aItMPB.More(); aItMPB.Next()) { + const Handle(BOPDS_PaveBlock)& aPB=aItMPB.Value(); + aMPB.Add(aPB); + aPB->Indices(nV1, nV2); + aMI.Add(nV1); + aMI.Add(nV2); + } + // + const BOPCol_MapOfInteger& aMVOn1=aFI1.VerticesOn(); + aIt.Initialize(aMVOn1); + for (; aIt.More(); aIt.Next()) { + nV=aIt.Value(); + aMI.Add(nV); + } + // + const BOPCol_MapOfInteger& aMVIn1=aFI1.VerticesIn(); + aIt.Initialize(aMVOn1); + for (; aIt.More(); aIt.Next()) { + nV=aIt.Value(); + aMI.Add(nV); + } + // + const BOPCol_MapOfInteger& aMVOn2=aFI2.VerticesOn(); + aIt.Initialize(aMVOn2); + for (; aIt.More(); aIt.Next()) { + nV=aIt.Value(); + aMI.Add(nV); + } + // + const BOPCol_MapOfInteger& aMVIn2=aFI2.VerticesIn(); + aIt.Initialize(aMVOn1); + for (; aIt.More(); aIt.Next()) { + nV=aIt.Value(); + aMI.Add(nV); + } +} +//======================================================================= +//function : SharedEdges +//purpose : +//======================================================================= + void BOPDS_DS::SharedEdges(const Standard_Integer nF1, + const Standard_Integer nF2, + BOPCol_ListOfInteger& theLI, + const Handle(NCollection_BaseAllocator)& aAllocator) +{ + Standard_Integer nE, nSp; + BOPCol_ListIteratorOfListOfInteger aItLI; + BOPDS_ListIteratorOfListOfPaveBlock aItLPB; + BOPCol_MapOfInteger aMI(100, aAllocator); + // + const BOPDS_ShapeInfo& aSI1=ShapeInfo(nF1); + const BOPCol_ListOfInteger& aLI1=aSI1.SubShapes(); + aItLI.Initialize(aLI1); + for (; aItLI.More(); aItLI.Next()) { + nE=aItLI.Value(); + const BOPDS_ShapeInfo& aSIE=ChangeShapeInfo(nE); + if(aSIE.ShapeType()==TopAbs_EDGE) { + const BOPDS_ListOfPaveBlock& aLPB=PaveBlocks(nE); + if (aLPB.IsEmpty()) { + aMI.Add(nE); + } + else { + aItLPB.Initialize(aLPB); + for (; aItLPB.More(); aItLPB.Next()) { + const Handle(BOPDS_PaveBlock)& aPB=aItLPB.Value()->RealPaveBlock(); + nSp=aPB->Edge(); + aMI.Add(nSp); + } + } + } + } + // + const BOPDS_ShapeInfo& aSI2=ShapeInfo(nF2); + const BOPCol_ListOfInteger& aLI2=aSI2.SubShapes(); + aItLI.Initialize(aLI2); + for (; aItLI.More(); aItLI.Next()) { + nE=aItLI.Value(); + const BOPDS_ShapeInfo& aSIE=ChangeShapeInfo(nE); + if(aSIE.ShapeType()==TopAbs_EDGE) { + const BOPDS_ListOfPaveBlock& aLPB=PaveBlocks(nE); + if (aLPB.IsEmpty()) { + if (aMI.Contains(nE)) { + theLI.Append(nE); + } + } + else { + aItLPB.Initialize(aLPB); + for (; aItLPB.More(); aItLPB.Next()) { + const Handle(BOPDS_PaveBlock)& aPB=aItLPB.Value()->RealPaveBlock(); + nSp=aPB->Edge(); + if (aMI.Contains(nSp)) { + theLI.Append(nSp); + } + } + } + } + } +} + +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// same domain shapes +// +//======================================================================= +//function : ShapesSD +//purpose : +//======================================================================= + BOPCol_DataMapOfIntegerInteger& BOPDS_DS::ShapesSD() +{ + return myShapesSD; +} +//======================================================================= +//function : AddShapeSD +//purpose : +//======================================================================= + void BOPDS_DS::AddShapeSD(const Standard_Integer theIndex, + const Standard_Integer theIndexSD) +{ + myShapesSD.Bind(theIndex, theIndexSD); +} +//======================================================================= +//function : HasShapeSD +//purpose : +//======================================================================= + Standard_Boolean BOPDS_DS::HasShapeSD(const Standard_Integer theIndex, + Standard_Integer& theIndexSD)const +{ + Standard_Boolean bRet; + // + bRet=myShapesSD.IsBound(theIndex); + if (bRet) { + theIndexSD=myShapesSD.Find(theIndex); + } + return bRet; +} +//======================================================================= +//function : Dump +//purpose : +//======================================================================= + void BOPDS_DS::Dump()const +{ + Standard_Integer i, aNb, aNbSS; + // + printf(" *** DS ***\n"); + aNb=NbRanges(); + printf(" Ranges:%d\n", aNb); + for (i=0; iRange(aT11, aT12); + aT1m=IntTools_Tools::IntermediatePoint (aT11, aT12); + nE1=aPB1->OriginalEdge(); + const TopoDS_Edge& aE1=(*(TopoDS_Edge*)(&Shape(nE1))); + BOPTools_AlgoTools::PointOnEdge(aE1, aT1m, aP1m); + // + aPB2->Range(aT21, aT22); + nE2=aPB2->OriginalEdge(); + const TopoDS_Edge& aE2=(*(TopoDS_Edge*)(&Shape(nE2))); + // + Standard_Real f, l; + Handle(Geom_Curve)aC2 = BRep_Tool::Curve (aE2, f, l); + GeomAPI_ProjectPointOnCurve aPPC; + aPPC.Init(aC2, f, l); + aPPC.Perform(aP1m); + aNbPoints=aPPC.NbPoints(); + if (aNbPoints) { + aD=aPPC.LowerDistance(); + // + aTol=BRep_Tool::Tolerance(aE1); + aTol=aTol+BRep_Tool::Tolerance(aE2); + if (aDaT21 && aT2xPaveBlocks(); + BOPDS_ListOfPaveBlock aLPBN = aLPB; + + Handle(BOPDS_PaveBlock) aPB; + BOPDS_ListIteratorOfListOfPaveBlock aIt; + // + aIt.Initialize(aLPBN); + for (aIt.Next(); aIt.More(); ) { + i++; + if(i == theI) { + aPB = aIt.Value(); + aLPBN.Remove(aIt); + aLPBN.Prepend(aPB); + break; + } + aIt.Next(); + } + // + aCB->AddPaveBlocks(aLPBN); +} + +//======================================================================= +// function: IsToSort +// purpose: +//======================================================================= + Standard_Boolean BOPDS_DS::IsToSort(const Handle(BOPDS_CommonBlock)& aCB, + Standard_Integer& theI) +{ + Standard_Boolean bRet; + bRet = Standard_False; + const BOPDS_ListOfPaveBlock& aLPB = aCB->PaveBlocks(); + if (aLPB.Extent()==1) { + return bRet; + } + + Standard_Integer nE; + Standard_Real aTolMax, aTol; + Handle(BOPDS_PaveBlock) aPB; + TopoDS_Edge aE; + BOPDS_ListIteratorOfListOfPaveBlock aIt; + // + aPB = aLPB.First(); + nE = aPB->OriginalEdge(); + aE = (*(TopoDS_Edge *)(&Shape(nE))); + aTolMax = BRep_Tool::Tolerance(aE); + // + theI = 0; + aIt.Initialize(aLPB); + for (aIt.Next(); aIt.More(); aIt.Next()) { + theI++; + aPB = aIt.Value(); + nE = aPB->OriginalEdge(); + aE = (*(TopoDS_Edge *)(&Shape(nE))); + aTol = BRep_Tool::Tolerance(aE); + if (aTolMax < aTol) { + aTolMax = aTol; + bRet = Standard_True; + } + } + + return bRet; +} + +//======================================================================= +// function: IsSubShape +// purpose: +//======================================================================= + Standard_Boolean BOPDS_DS::IsSubShape(const Standard_Integer theI1, + const Standard_Integer theI2) +{ + Standard_Boolean bRet; + Standard_Integer nS; + bRet = Standard_False; + // + BOPCol_ListIteratorOfListOfInteger aItLI; + // + const BOPDS_ShapeInfo& aSI = ShapeInfo(theI2); + const BOPCol_ListOfInteger& aLI = aSI.SubShapes(); + aItLI.Initialize(aLI); + for(;aItLI.More(); aItLI.Next()) { + nS = aItLI.Value(); + if (nS == theI1) { + bRet = Standard_True; + break; + } + } + + return bRet; +} + +//======================================================================= +// function: Paves +// purpose: +//======================================================================= + void BOPDS_DS::Paves(const Standard_Integer theEdge, + BOPDS_ListOfPave& theLP) +{ + Standard_Integer aNb, i; + BOPDS_Pave *pPaves; + BOPDS_ListIteratorOfListOfPaveBlock aIt; + BOPDS_MapOfPave aMP; + // + const BOPDS_ListOfPaveBlock& aLPB = PaveBlocks(theEdge); + aNb = aLPB.Extent(); + aNb = (aNb==0) ? 0 : (aNb+1); + // + pPaves=(BOPDS_Pave *)myAllocator->Allocate(aNb*sizeof(BOPDS_Pave)); + for (i=0; iPave1())){ + pPaves[i] = aPB->Pave1(); + ++i; + } + if (aMP.Add(aPB->Pave2())){ + pPaves[i] = aPB->Pave2(); + ++i; + } + } + // + SortShell(aNb, pPaves); + // + for (i = 0; i < aNb; ++i) { + theLP.Append(pPaves[i]); + } +} + +//======================================================================= +//function : TotalShapes +//purpose : +//======================================================================= +void TotalShapes(const TopoDS_Shape& aS, + Standard_Integer& aNbS) +{ + TopoDS_Shape *pS; + // + pS=(TopoDS_Shape *)&aS; + if (!pS->Checked()) { + TopoDS_Iterator aIt; + // + pS->Checked(1); + ++aNbS; + aIt.Initialize(aS); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aSx=aIt.Value(); + TotalShapes(aSx, aNbS); + } + } +} +//======================================================================= +//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); + } +} +//modified by NIZNHY-PKV Mon Jul 12 11:15:30 2010f +#include + +//======================================================================= +//function : ComputeParameter +//purpose : +//======================================================================= +Standard_Real ComputeParameter(const TopoDS_Vertex& aV, + const TopoDS_Edge& aE) +{ + Standard_Real aT1, aT2, aTRet, aTolE2, aD2; + gp_Pnt aPC, aPV; + Handle(Geom_Curve) aC3D; + TopoDS_Edge aEE; + // + aEE=aE; + aEE.Orientation(TopAbs_FORWARD); + // + aTRet=0.; + // + aTolE2=BRep_Tool::Tolerance(aE); + aTolE2=aTolE2*aTolE2; + // + aPV=BRep_Tool::Pnt(aV); + // + aC3D=BRep_Tool::Curve (aEE, aT1, aT2); + // + aC3D->D0(aT1, aPC); + aD2=aPC.SquareDistance(aPV); + if (aD2D0(aT2, aPC); + aD2=aPC.SquareDistance(aPV); + if (aD2 -1) goto m30; + }//if (a[l] < a[j]){ + }//for (i=0; i +//======================================================================= +//function : InterfVV +//purpose : +//======================================================================= + inline BOPDS_VectorOfInterfVV& BOPDS_DS::InterfVV() +{ + return myInterfVV; +} +//======================================================================= +//function : InterfVE +//purpose : +//======================================================================= + inline BOPDS_VectorOfInterfVE& BOPDS_DS::InterfVE() +{ + return myInterfVE; +} +//======================================================================= +//function : InterfVF +//purpose : +//======================================================================= + inline BOPDS_VectorOfInterfVF& BOPDS_DS::InterfVF() +{ + return myInterfVF; +}//======================================================================= +//function : InterfEE +//purpose : +//======================================================================= + inline BOPDS_VectorOfInterfEE& BOPDS_DS::InterfEE() +{ + return myInterfEE; +} +//======================================================================= +//function : InterfEF +//purpose : +//======================================================================= + inline BOPDS_VectorOfInterfEF& BOPDS_DS::InterfEF() +{ + return myInterfEF; +} +//======================================================================= +//function : InterfFF +//purpose : +//======================================================================= + inline BOPDS_VectorOfInterfFF& BOPDS_DS::InterfFF() +{ + return myInterfFF; +} +//======================================================================= +//function : AddInterf +//purpose : +//======================================================================= + inline void BOPDS_DS::AddInterf(const Standard_Integer theI1, + const Standard_Integer theI2) +{ + BOPDS_PassKey aPK; + // + aPK.SetIds(theI1, theI2); + myInterfTB.Add(aPK); +} +//======================================================================= +//function : HasInterf +//purpose : +//======================================================================= + inline Standard_Boolean BOPDS_DS::HasInterf(const Standard_Integer theI1, + const Standard_Integer theI2)const +{ + BOPDS_PassKey aPK; + // + aPK.SetIds(theI1, theI2); + return myInterfTB.Contains(aPK); +} +//======================================================================= +//function : Interferences +//purpose : +//======================================================================= + inline const BOPDS_MapOfPassKey& BOPDS_DS::Interferences()const +{ + return myInterfTB; +} diff --git a/src/BOPDS/BOPDS_DataMapOfPassKeyListOfPaveBlock.hxx b/src/BOPDS/BOPDS_DataMapOfPassKeyListOfPaveBlock.hxx new file mode 100644 index 0000000000..ab4f29ba51 --- /dev/null +++ b/src/BOPDS/BOPDS_DataMapOfPassKeyListOfPaveBlock.hxx @@ -0,0 +1,36 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPDS_DataMapOfPassKeyListOfPaveBlock_HeaderFile +#define BOPDS_DataMapOfPassKeyListOfPaveBlock_HeaderFile + + +#define _NCollection_MapHasher +#include + +#include +#include +#include + +typedef NCollection_DataMap BOPDS_DataMapOfPassKeyListOfPaveBlock; +typedef BOPDS_DataMapOfPassKeyListOfPaveBlock::Iterator BOPDS_DataMapIteratorOfDataMapOfPassKeyListOfPaveBlock; + +#undef _NCollection_MapHasher + +#endif diff --git a/src/BOPDS/BOPDS_DataMapOfPaveBlockListOfInteger.hxx b/src/BOPDS/BOPDS_DataMapOfPaveBlockListOfInteger.hxx new file mode 100644 index 0000000000..683a80af6d --- /dev/null +++ b/src/BOPDS/BOPDS_DataMapOfPaveBlockListOfInteger.hxx @@ -0,0 +1,34 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPDS_DataMapOfPaveBlockListOfInteger_HeaderFile +#define BOPDS_DataMapOfPaveBlockListOfInteger_HeaderFile + +#define _NCollection_MapHasher +#include +#include +#include + +typedef NCollection_DataMap BOPDS_DataMapOfPaveBlockListOfInteger; +typedef BOPDS_DataMapOfPaveBlockListOfInteger::Iterator BOPDS_DataMapIteratorOfDataMapOfPaveBlockListOfInteger; + +#undef _NCollection_MapHasher + + +#endif diff --git a/src/BOPDS/BOPDS_DataMapOfPaveBlockListOfPaveBlock.hxx b/src/BOPDS/BOPDS_DataMapOfPaveBlockListOfPaveBlock.hxx new file mode 100644 index 0000000000..fdc570a546 --- /dev/null +++ b/src/BOPDS/BOPDS_DataMapOfPaveBlockListOfPaveBlock.hxx @@ -0,0 +1,35 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPDS_DataMapOfPaveBlockListOfPaveBlock_HeaderFile +#define BOPDS_DataMapOfPaveBlockListOfPaveBlock_HeaderFile + +#define _NCollection_MapHasher +#include +#include +#include +#include + +typedef NCollection_DataMap BOPDS_DataMapOfPaveBlockListOfPaveBlock; +typedef BOPDS_DataMapOfPaveBlockListOfPaveBlock::Iterator BOPDS_DataMapIteratorOfDataMapOfPaveBlockListOfPaveBlock; + +#undef _NCollection_MapHasher + + +#endif diff --git a/src/BOPDS/BOPDS_DataMapOfShapeCoupleOfPaveBlocks.hxx b/src/BOPDS/BOPDS_DataMapOfShapeCoupleOfPaveBlocks.hxx new file mode 100644 index 0000000000..03325b0f31 --- /dev/null +++ b/src/BOPDS/BOPDS_DataMapOfShapeCoupleOfPaveBlocks.hxx @@ -0,0 +1,34 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPDS_DataMapOfShapeCoupleOfPaveBlocks_HeaderFile +#define BOPDS_DataMapOfShapeCoupleOfPaveBlocks_HeaderFile + +#include + +#define _NCollection_MapHasher +#include +#include + +typedef NCollection_DataMap BOPDS_DataMapOfShapeCoupleOfPaveBlocks; +typedef BOPDS_DataMapOfShapeCoupleOfPaveBlocks::Iterator BOPDS_DataMapIteratorOfDataMapOfShapeCoupleOfPaveBlocks; +#undef _NCollection_MapHasher + + +#endif diff --git a/src/BOPDS/BOPDS_FaceInfo.cdl b/src/BOPDS/BOPDS_FaceInfo.cdl new file mode 100644 index 0000000000..b17be40b26 --- /dev/null +++ b/src/BOPDS/BOPDS_FaceInfo.cdl @@ -0,0 +1,203 @@ +-- Created by: Peter KURNEV +-- Copyright (c) 2010-2012 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 +-- +-- The content of this file is subject to the Open CASCADE Technology Public +-- License Version 6.5 (the "License"). You may not use the content of this file +-- except in compliance with the License. Please obtain a copy of the License +-- at http://www.opencascade.org and read it completely before using this file. +-- +-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +-- +-- The Original Code and all software distributed under the License is +-- distributed on an "AS IS" basis, without warranty of any kind, and the +-- Initial Developer hereby disclaims all such warranties, including without +-- limitation, any warranties of merchantability, fitness for a particular +-- purpose or non-infringement. Please see the License for the specific terms +-- and conditions governing the rights and limitations under the License. + + +class FaceInfo from BOPDS + + ---Purpose: + -- The class BOPDS_FaceInfo is to store + -- handy information about state of face +uses + BaseAllocator from BOPCol, + MapOfInteger from BOPCol, + MapOfPaveBlock from BOPDS + +--raises + +is + Create + returns FaceInfo from BOPDS; + ---C++: inline + ---C++: alias "virtual ~BOPDS_FaceInfo();" + ---Purpose: + --- Empty contructor + --- + + Create (theAllocator: BaseAllocator from BOPCol) + returns FaceInfo from BOPDS; + ---C++: inline + ---Purpose: + --- Contructor + --- theAllocator - the allocator to manage the memory + --- + + Clear(me:out); + ---Purpose: + --- Clears the contents + + SetIndex(me:out; + theI: Integer from Standard); + ---C++: inline + ---Purpose: + --- Modifier + --- Sets the index of the face + + Index(me) + returns Integer from Standard; + ---C++: inline + ---Purpose: + --- Selector + --- Returns the index of the face + -- + -- In + -- + PaveBlocksIn(me) + returns MapOfPaveBlock from BOPDS; + ---C++: return const & + ---C++: inline + ---Purpose: + --- Selector + --- Returns the pave blocks of the face + --- that have state In + + ChangePaveBlocksIn(me:out) + returns MapOfPaveBlock from BOPDS; + ---C++: return & + ---C++: inline + ---Purpose: + --- Selector/Modifier + --- Returns the pave blocks + -- of the face + --- that have state In + + VerticesIn(me) + returns MapOfInteger from BOPCol; + ---C++: return const & + ---C++: inline + ---Purpose: + --- Selector + --- Returns the list of indices for vertices + -- of the face + --- that have state In + + ChangeVerticesIn(me:out) + returns MapOfInteger from BOPCol; + ---C++: return & + ---C++: inline + ---Purpose: + --- Selector/Modifier + --- Returns the list of indices for vertices + -- of the face + --- that have state In + -- + -- On + -- + PaveBlocksOn(me) + returns MapOfPaveBlock from BOPDS; + ---C++: return const & + ---C++: inline + ---Purpose: + --- Selector + --- Returns the pave blocks of the face + --- that have state On + + ChangePaveBlocksOn(me:out) + returns MapOfPaveBlock from BOPDS; + ---C++: return & + ---C++: inline + ---Purpose: + --- Selector/Modifier + --- Returns the pave blocks + -- of the face + --- that have state On + VerticesOn(me) + returns MapOfInteger from BOPCol; + ---C++: return const & + ---C++: inline + ---Purpose: + --- Selector + --- Returns the list of indices for vertices + -- of the face + --- that have state On + + ChangeVerticesOn(me:out) + returns MapOfInteger from BOPCol; + ---C++: return & + ---C++: inline + ---Purpose: + --- Selector/Modifier + --- Returns the list of indices for vertices + -- of the face + --- that have state On + -- + -- Sections + -- + PaveBlocksSc(me) + returns MapOfPaveBlock from BOPDS; + ---C++: return const & + ---C++: inline + ---Purpose: + --- Selector + --- Returns the pave blocks of the face + --- that are pave blocks of section edges + + ChangePaveBlocksSc(me:out) + returns MapOfPaveBlock from BOPDS; + ---C++: return & + ---C++: inline + --- Selector/Modifier + --- Returns the pave blocks of the face + --- that are pave blocks of section edges + + VerticesSc(me) + returns MapOfInteger from BOPCol; + ---C++: return const & + ---C++: inline + ---Purpose: + --- Selector + --- Returns the list of indices for section vertices + -- of the face + + ChangeVerticesSc(me:out) + returns MapOfInteger from BOPCol; + ---C++: return & + ---C++: inline + ---Purpose: + --- Selector/Modifier + --- Returns the list of indices for section vertices + -- of the face + -- + -- Others + -- + --Update(me:out) + -- is protected; + +fields + myAllocator : BaseAllocator from BOPCol is protected; + myIndex : Integer from Standard is protected; + myPaveBlocksIn: MapOfPaveBlock from BOPDS is protected; + myVerticesIn : MapOfInteger from BOPCol is protected; + myPaveBlocksOn: MapOfPaveBlock from BOPDS is protected; + myVerticesOn : MapOfInteger from BOPCol is protected; + myPaveBlocksSc: MapOfPaveBlock from BOPDS is protected; + myVerticesSc : MapOfInteger from BOPCol is protected; + +end FaceInfo; diff --git a/src/BOPDS/BOPDS_FaceInfo.cxx b/src/BOPDS/BOPDS_FaceInfo.cxx new file mode 100644 index 0000000000..b0478ba3c4 --- /dev/null +++ b/src/BOPDS/BOPDS_FaceInfo.cxx @@ -0,0 +1,23 @@ +// Created by: Peter KURNEV +// Copyright (c) 2010-2012 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 +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#include diff --git a/src/BOPDS/BOPDS_FaceInfo.lxx b/src/BOPDS/BOPDS_FaceInfo.lxx new file mode 100644 index 0000000000..bccf835b45 --- /dev/null +++ b/src/BOPDS/BOPDS_FaceInfo.lxx @@ -0,0 +1,186 @@ +// Created by: Peter KURNEV +// Copyright (c) 2010-2012 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 +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + +//======================================================================= +//function : +//purpose : +//======================================================================= + inline BOPDS_FaceInfo::BOPDS_FaceInfo() +: + myAllocator(NCollection_BaseAllocator::CommonBaseAllocator()), + myIndex(-1), + myPaveBlocksIn(100, myAllocator), + myVerticesIn(100, myAllocator), + myPaveBlocksOn(100, myAllocator), + myVerticesOn(100, myAllocator), + myPaveBlocksSc(100, myAllocator), + myVerticesSc(100, myAllocator) +{ +} +//======================================================================= +//function : +//purpose : +//======================================================================= + inline BOPDS_FaceInfo::BOPDS_FaceInfo(const Handle(NCollection_BaseAllocator)& theAllocator) +: + myAllocator(theAllocator), + myIndex(-1), + myPaveBlocksIn(100, myAllocator), + myVerticesIn(100, myAllocator), + myPaveBlocksOn(100, myAllocator), + myVerticesOn(100, myAllocator), + myPaveBlocksSc(100, myAllocator), + myVerticesSc(100, myAllocator) +{ +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= + inline BOPDS_FaceInfo::~BOPDS_FaceInfo() +{ + Clear(); +} +//======================================================================= +//function : Clear +//purpose : +//======================================================================= + inline void BOPDS_FaceInfo::Clear() +{ + myPaveBlocksIn.Clear(); + myVerticesIn.Clear(); + myPaveBlocksOn.Clear(); + myVerticesOn.Clear(); +} +//======================================================================= +//function : SetIndex +//purpose : +//======================================================================= + inline void BOPDS_FaceInfo::SetIndex(const Standard_Integer theI) +{ + myIndex=theI; +} +//======================================================================= +//function : Index +//purpose : +//======================================================================= + inline Standard_Integer BOPDS_FaceInfo::Index()const +{ + return myIndex; +} +//======================================================================= +//function : PaveBlockIn +//purpose : +//======================================================================= + inline const BOPDS_MapOfPaveBlock& BOPDS_FaceInfo::PaveBlocksIn()const +{ + return myPaveBlocksIn; +} +//======================================================================= +//function : ChangePaveBlocksIn +//purpose : +//======================================================================= + inline BOPDS_MapOfPaveBlock& BOPDS_FaceInfo::ChangePaveBlocksIn() +{ + return myPaveBlocksIn; +} +//======================================================================= +//function : VerticesIn +//purpose : +//======================================================================= + inline const BOPCol_MapOfInteger& BOPDS_FaceInfo::VerticesIn()const +{ + return myVerticesIn; +} +//======================================================================= +//function : ChangeVerticesIn +//purpose : +//======================================================================= + inline BOPCol_MapOfInteger& BOPDS_FaceInfo::ChangeVerticesIn() +{ + return myVerticesIn; +} +// On +//======================================================================= +//function : PaveBlocksOn +//purpose : +//======================================================================= + inline const BOPDS_MapOfPaveBlock& BOPDS_FaceInfo::PaveBlocksOn()const +{ + return myPaveBlocksOn; +} +//======================================================================= +//function : ChangePaveBlocksOn +//purpose : +//======================================================================= + inline BOPDS_MapOfPaveBlock& BOPDS_FaceInfo::ChangePaveBlocksOn() +{ + return myPaveBlocksOn; +} +//======================================================================= +//function : VerticesOn +//purpose : +//======================================================================= + inline const BOPCol_MapOfInteger& BOPDS_FaceInfo::VerticesOn()const +{ + return myVerticesOn; +} +//======================================================================= +//function : ChangeVerticesOn +//purpose : +//======================================================================= + inline BOPCol_MapOfInteger& BOPDS_FaceInfo::ChangeVerticesOn() +{ + return myVerticesOn; +} +// Sc +//======================================================================= +//function : PaveBlocksSc +//purpose : +//======================================================================= + inline const BOPDS_MapOfPaveBlock& BOPDS_FaceInfo::PaveBlocksSc()const +{ + return myPaveBlocksSc; +} +//======================================================================= +//function : ChangePaveBlocksSc +//purpose : +//======================================================================= + inline BOPDS_MapOfPaveBlock& BOPDS_FaceInfo::ChangePaveBlocksSc() +{ + return myPaveBlocksSc; +} +//======================================================================= +//function : VerticesSc +//purpose : +//======================================================================= + inline const BOPCol_MapOfInteger& BOPDS_FaceInfo::VerticesSc()const +{ + return myVerticesSc; +} +//======================================================================= +//function : ChangeVerticesSc +//purpose : +//======================================================================= + inline BOPCol_MapOfInteger& BOPDS_FaceInfo::ChangeVerticesSc() +{ + return myVerticesSc; +} diff --git a/src/BOPDS/BOPDS_IndexRange.cdl b/src/BOPDS/BOPDS_IndexRange.cdl new file mode 100644 index 0000000000..81cb218e36 --- /dev/null +++ b/src/BOPDS/BOPDS_IndexRange.cdl @@ -0,0 +1,98 @@ +-- Created by: Peter KURNEV +-- Copyright (c) 1999-2012 OPEN CASCADE SAS +-- +-- The content of this file is subject to the Open CASCADE Technology Public +-- License Version 6.5 (the "License"). You may not use the content of this file +-- except in compliance with the License. Please obtain a copy of the License +-- at http://www.opencascade.org and read it completely before using this file. +-- +-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +-- +-- The Original Code and all software distributed under the License is +-- distributed on an "AS IS" basis, without warranty of any kind, and the +-- Initial Developer hereby disclaims all such warranties, including without +-- limitation, any warranties of merchantability, fitness for a particular +-- purpose or non-infringement. Please see the License for the specific terms +-- and conditions governing the rights and limitations under the License. + +class IndexRange from BOPDS + + ---Purpose: + -- The class BOPDS_IndexRange is to store + -- the information about range of two indices +--uses +--raises + +is + Create + returns IndexRange from BOPDS; + ---C++: alias "Standard_EXPORT virtual ~BOPDS_IndexRange();" + ---C++: inline + ---Purpose: + --- Empty contructor + --- + + SetFirst(me:out; + theI1:Integer from Standard); + ---C++: inline + ---Purpose: + --- Modifier + --- Sets the first index of the range + + SetLast(me:out; + theI2:Integer from Standard); + ---C++: inline + ---Purpose: + --- Modifier + --- Sets the second index of the range + + First(me) + returns Integer from Standard; + ---C++: inline + ---Purpose: + --- Selector + --- Returns the first index of the range + + Last(me) + returns Integer from Standard; + ---C++: inline + ---Purpose: + --- Selector + --- Returns the second index of the range + + SetIndices(me:out; + theI1:Integer from Standard; + theI2:Integer from Standard); + ---C++: inline + ---Purpose: + --- Modifier + --- Sets the first index of the range + --- Sets the second index of the range + + Indices(me; + theI1:out Integer from Standard; + theI2:out Integer from Standard); + ---C++: inline + ---Purpose: + --- Selector + --- Returns the first index of the range + --- Returns the second index of the range + + Contains(me; + theIndex:Integer from Standard) + returns Boolean from Standard; + ---C++: inline + ---Purpose: + --- Query + --- Returns true if the range contains + + Dump(me); + + + +fields + myFirst : Integer from Standard is protected; + myLast : Integer from Standard is protected; + +end IndexRange; diff --git a/src/BOPDS/BOPDS_IndexRange.cxx b/src/BOPDS/BOPDS_IndexRange.cxx new file mode 100644 index 0000000000..461d5d1cd5 --- /dev/null +++ b/src/BOPDS/BOPDS_IndexRange.cxx @@ -0,0 +1,30 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#include +#include + +//======================================================================= +//function : Dump +//purpose : +//======================================================================= + void BOPDS_IndexRange::Dump()const +{ + printf(" range: %d %d", myFirst, myLast); +} diff --git a/src/BOPDS/BOPDS_IndexRange.lxx b/src/BOPDS/BOPDS_IndexRange.lxx new file mode 100644 index 0000000000..702400fac9 --- /dev/null +++ b/src/BOPDS/BOPDS_IndexRange.lxx @@ -0,0 +1,97 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +//======================================================================= +//function : +//purpose : +//======================================================================= + inline BOPDS_IndexRange::BOPDS_IndexRange() +: + myFirst(0), + myLast(0) +{ +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= + inline BOPDS_IndexRange::~BOPDS_IndexRange() +{ +} +//======================================================================= +//function : SetFirst +//purpose : +//======================================================================= + inline void BOPDS_IndexRange::SetFirst(const Standard_Integer aFirst) +{ + myFirst=aFirst; +} +//======================================================================= +//function : First +//purpose : +//======================================================================= + inline Standard_Integer BOPDS_IndexRange::First()const +{ + return myFirst; +} +//======================================================================= +//function : SetLast +//purpose : +//======================================================================= + inline void BOPDS_IndexRange::SetLast(const Standard_Integer aLast) +{ + myLast=aLast; +} +//======================================================================= +//function :Last +//purpose : +//======================================================================= + inline Standard_Integer BOPDS_IndexRange::Last()const +{ + return myLast; +} +//======================================================================= +//function : SetIndices +//purpose : +//======================================================================= + inline void BOPDS_IndexRange::SetIndices(const Standard_Integer theI1, + const Standard_Integer theI2) +{ + myFirst=theI1; + myLast=theI2; +} +//======================================================================= +//function : Indices +//purpose : +//======================================================================= + inline void BOPDS_IndexRange::Indices(Standard_Integer& theI1, + Standard_Integer& theI2)const +{ + theI1=myFirst; + theI2=myLast; +} + +//======================================================================= +//function : Contains +//purpose : +//======================================================================= + inline Standard_Boolean BOPDS_IndexRange::Contains(const Standard_Integer aIndex)const +{ + return (Standard_Boolean)(aIndex>=myFirst && aIndex<=myLast); +} diff --git a/src/BOPDS/BOPDS_Interf.hxx b/src/BOPDS/BOPDS_Interf.hxx new file mode 100644 index 0000000000..eb848db5bd --- /dev/null +++ b/src/BOPDS/BOPDS_Interf.hxx @@ -0,0 +1,649 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPDS_Interf_HeaderFile +#define BOPDS_Interf_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +#ifndef _Standard_Integer_HeaderFile +#include +#endif + +#ifndef _IntTools_CommonPrt_HeaderFile +#include +#endif + +#include +#include +#include +/** + * The class BOPDS_Interf is is to store the information about + * the interference between two shapes. + * The class BOPDS_Interf is root class + * +*/ +//======================================================================= +//function : BOPDS_Interf +//purpose : +//======================================================================= +class BOPDS_Interf { + public: + // + /** + * Sets the indices of interferred shapes + * @param theIndex1 + * index of the first shape + * @param theIndex2 + * index of the second shape + */ + void SetIndices(const Standard_Integer theIndex1, + const Standard_Integer theIndex2) { + myIndex1=theIndex1; + myIndex2=theIndex2; + }; + // + /** + * Returns the indices of interferred shapes + * @param theIndex1 + * index of the first shape + * @param theIndex2 + * index of the second shape + */ + void Indices(Standard_Integer& theIndex1, + Standard_Integer& theIndex2) const { + theIndex1=myIndex1; + theIndex2=myIndex2; + }; + // + /** + * Sets the index of the first interferred shape + * @param theIndex + * index of the first shape + */ + void SetIndex1(const Standard_Integer theIndex) { + myIndex1=theIndex; + }; + // + /** + * Sets the index of the second interferred shape + * @param theIndex + * index of the second shape + */ + void SetIndex2(const Standard_Integer theIndex) { + myIndex2=theIndex; + }; + // + /** + * Returns the index of the first interferred shape + * @return + * index of the first shape + */ + Standard_Integer Index1() const { + return myIndex1; + }; + // + /** + * Returns the index of the second interferred shape + * @return + * index of the second shape + */ + Standard_Integer Index2() const { + return myIndex2; + }; + // + /** + * Returns the index of that are opposite to the given index + * @param theI + * the index + * @return + * index of opposite shape + */ + Standard_Integer OppositeIndex(const Standard_Integer theI) const { + if (theI==myIndex1) { + return myIndex2; + } + else if(theI==myIndex2) { + return myIndex1; + } + else { + return -1; + } + }; + // + /** + * Returns true if the interference contains given index + * @param theIndex + * the index + * @return + * true if the interference contains given index + */ + Standard_Boolean Contains(const Standard_Integer theIndex)const { + return (myIndex1==theIndex || myIndex2==theIndex); + } + // + /** + * Sets the index of new shape + * @param theIndex + * the index + */ + void SetIndexNew(const Standard_Integer theIndex) { + myIndexNew=theIndex; + }; + // + // + /** + * Returns the index of new shape + * @return theIndex + * the index of new shape + */ + Standard_Integer IndexNew() const { + return myIndexNew; + }; + // + /** + * Returns true if the interference has index of new shape + * that is equal to the given index + * @param theIndex + * the index + * @return true if the interference has index of new shape + * that is equal to the given index + */ + Standard_Boolean HasIndexNew(Standard_Integer& theIndex) const { + theIndex=myIndexNew; + return (myIndexNew>=0); + }; + // + /** + * Returns true if the interference has index of new shape + * the index + * @return true if the interference has index of new shape + */ + Standard_Boolean HasIndexNew() const { + return (myIndexNew>=0); + }; + // + protected: + BOPDS_Interf() : + myIndex1(-1), + myIndex2(-1), + myIndexNew(-1), + myAllocator(NCollection_BaseAllocator::CommonBaseAllocator()) { + }; + // + BOPDS_Interf(const Handle(NCollection_BaseAllocator)& theAllocator) : + myIndex1(-1), + myIndex2(-1), + myIndexNew(-1), + myAllocator(theAllocator) { + }; + // + virtual ~BOPDS_Interf() { + }; + + protected: + Standard_Integer myIndex1; + Standard_Integer myIndex2; + Standard_Integer myIndexNew; + Handle(NCollection_BaseAllocator) myAllocator; +}; +/** + * The class BOPDS_InterfVV is is to store the information about + * the interference of the type vertex/vertex. +*/ +//======================================================================= +//function : BOPDS_InterfVV +//purpose : +//======================================================================= +class BOPDS_InterfVV : public BOPDS_Interf { + public: + // + /** + * Constructor + */ + BOPDS_InterfVV() : BOPDS_Interf() { + }; + // + /** + * Constructor + * @param theAllocator + * allocator to manage the memory + */ + BOPDS_InterfVV(const Handle(NCollection_BaseAllocator)& theAllocator) + : BOPDS_Interf(theAllocator) { + }; + // + /** + * Destructor + */ + virtual ~BOPDS_InterfVV() { + }; + // +}; +/** + * The class BOPDS_InterfVE is is to store the information about + * the interference of the type vertex/edge. +*/ +//======================================================================= +//function : BOPDS_InterfVE +//purpose : +//======================================================================= +class BOPDS_InterfVE : public BOPDS_Interf { + public: + // + /** + * Constructor + */ + BOPDS_InterfVE() + : + BOPDS_Interf(), + myParameter(0.) { + }; + // + /** + * Constructor + * @param theAllocator + * allocator to manage the memory + */ + BOPDS_InterfVE(const Handle(NCollection_BaseAllocator)& theAllocator) + : + BOPDS_Interf(theAllocator), + myParameter(0.) { + }; + // + /** + * Destructor + */ + virtual ~BOPDS_InterfVE() { + }; + // + /** + * Modifier + * Sets the value of parameter + * of the point of the vertex + * on the curve of the edge + * @param theT + * value of parameter + */ + void SetParameter(const Standard_Real theT) { + myParameter=theT; + }; + // + /** + * Selector + * Returrns the value of parameter + * of the point of the vertex + * on the curve of the edge + * @return + * value of parameter + */ + Standard_Real Parameter() const { + return myParameter; + }; + + protected: + Standard_Real myParameter; + +}; +/** + * The class BOPDS_InterfVF is is to store the information about + * the interference of the type vertex/face +*/ +//======================================================================= +//function : BOPDS_InterfVF +//purpose : +//======================================================================= +class BOPDS_InterfVF : public BOPDS_Interf { + public: + // + /** + * Constructor + */ + BOPDS_InterfVF() + : BOPDS_Interf(), + myU(0.), + myV(0.) { + }; + // + /** + * Constructor + * @param theAllocator + * allocator to manage the memory + */ + BOPDS_InterfVF(const Handle(NCollection_BaseAllocator)& theAllocator) + : BOPDS_Interf(theAllocator), + myU(0.), + myV(0.) { + }; + // + /** + * Destructor + */ + virtual ~BOPDS_InterfVF() { + }; + // + /** + * Modifier + * Sets the value of parameters + * of the point of the vertex + * on the surface of of the face + * @param theU + * value of U parameter + * @param theV + * value of U parameter + */ + void SetUV(const Standard_Real theU, + const Standard_Real theV) { + myU=theU; + myV=theV; + }; + // + /** + * Selector + * Returns the value of parameters + * of the point of the vertex + * on the surface of of the face + * @param theU + * value of U parameter + * @param theV + * value of U parameter + */ + void UV(Standard_Real& theU,Standard_Real& theV) const { + theU=myU; + theV=myV; + }; + + protected: + Standard_Real myU; + Standard_Real myV; + +}; +/** + * The class BOPDS_InterfEE is is to store the information about + * the interference of the type edge/edge. +*/ +//======================================================================= +//function : BOPDS_InterfEE +//purpose : +//======================================================================= +class BOPDS_InterfEE : public BOPDS_Interf { + public: + // + /** + * Constructor + */ + BOPDS_InterfEE() : BOPDS_Interf() { + }; + // + /** + * Constructor + * @param theAllocator + * allocator to manage the memory + */ + BOPDS_InterfEE(const Handle(NCollection_BaseAllocator)& theAllocator) + : BOPDS_Interf(theAllocator) { + }; + // + /** + * Destructor + */ + virtual ~BOPDS_InterfEE() { + }; + // + /** + * Modifier + * Sets the info of common part + * @param theCP + * common part + */ + void SetCommonPart(const IntTools_CommonPrt& theCP) { + myCommonPart=theCP; + }; + // + /** + * Selector + * Returns the info of common part + * @return + * common part + */ + const IntTools_CommonPrt& CommonPart() const { + return myCommonPart; + }; + + protected: + IntTools_CommonPrt myCommonPart; +}; +/** + * The class BOPDS_InterfEF is is to store the information about + * the interference of the type edge/face. +*/ +//======================================================================= +//function : BOPDS_InterfEF +//purpose : +//======================================================================= +class BOPDS_InterfEF : public BOPDS_Interf { + public: + // + /** + * Constructor + */ + BOPDS_InterfEF(): BOPDS_Interf() { + }; + // + /** + * Constructor + * @param theAllocator + * allocator to manage the memory + */ + /** + * Constructor + * @param theAllocator + * allocator to manage the memory + */ + BOPDS_InterfEF(const Handle(NCollection_BaseAllocator)& theAllocator) + : BOPDS_Interf(theAllocator) { + }; + // + /** + * Destructor + */ + virtual ~BOPDS_InterfEF() { + }; + // + /** + * Modifier + * Sets the info of common part + * @param theCP + * common part + */ + void SetCommonPart(const IntTools_CommonPrt& theCP){ + myCommonPart=theCP; + }; + // + /** + * Selector + * Returns the info of common part + * @return + * common part + */ + const IntTools_CommonPrt& CommonPart() const { + return myCommonPart; + }; + // + protected: + IntTools_CommonPrt myCommonPart; +} +/** + * The class BOPDS_InterfFF is is to store the information about + * the interference of the type face/face. +*/; +//======================================================================= +//function : BOPDS_InterfFF +//purpose : +//======================================================================= +class BOPDS_InterfFF : public BOPDS_Interf { + public: + // + /** + * Constructor + */ + BOPDS_InterfFF() + : + BOPDS_Interf(), + myTolR3D(1.e-7), + myTolR2D(1.e-7), + myCurves(myAllocator), + myPoints(myAllocator) { + }; + // + /** + * Constructor + * @param theAllocator + * allocator to manage the memory + */ + /** + BOPDS_InterfFF(const Handle(NCollection_BaseAllocator)& theAllocator) + : + BOPDS_Interf(theAllocator), + myTolR3D(1.e-7), + myTolR2D(1.e-7), + myCurves(myAllocator), + myPoints(myAllocator) { + }; + // + /** + * Destructor + */ + virtual ~BOPDS_InterfFF() { + }; + // + /** + * Initializer + * @param theNbCurves + * number of intersection curves + * @param theNbPoints + * number of intersection points + */ + void Init(const Standard_Size theNbCurves, + const Standard_Size theNbPoints) { + if (theNbCurves) { + myCurves.SetStartSize(theNbCurves); + myCurves.SetIncrement(theNbCurves); + myCurves.Init(); + } + if (theNbPoints) { + myPoints.SetStartSize(theNbPoints); + myPoints.SetIncrement(theNbPoints); + myPoints.Init(); + } + } + // + /** + * Modifier + * Sets the value of 3D tolerance + * @param theTol + * 3D tolerance + */ + void SetTolR3D(const Standard_Real theTol) { + myTolR3D=theTol; + } + // + /** + * Selector + * Returns the value of 3D tolerance + * @return + * 3D tolerance + */ + Standard_Real TolR3D()const { + return myTolR3D; + } + // + /** + * Modifier + * Sets the value of 2D tolerance + * @param theTol + * 2D tolerance + */ + void SetTolR2D(const Standard_Real theTol) { + myTolR2D=theTol;; + } + // + /** + * Selector + * Returns the value of 2D tolerance + * @return + * 2D tolerance + */ + Standard_Real TolR2D()const { + return myTolR2D; + } + // + /** + * Selector + * Returns the intersection curves + * @return + * intersection curves + */ + const BOPDS_VectorOfCurve& Curves()const{ + return myCurves; + }; + // + /** + * Selector/Modifier + * Returns the intersection curves + * @return + * intersection curves + */ + BOPDS_VectorOfCurve& ChangeCurves(){ + return myCurves; + }; + // + /** + * Selector + * Returns the intersection points + * @return + * intersection points + */ + const BOPDS_VectorOfPoint& Points()const{ + return myPoints; + }; + // + /** + * Selector/Modifier + * Returns the intersection points + * @return + * intersection points + */ + BOPDS_VectorOfPoint& ChangePoints(){ + return myPoints; + }; + // + protected: + Standard_Real myTolR3D; + Standard_Real myTolR2D; + BOPDS_VectorOfCurve myCurves; + BOPDS_VectorOfPoint myPoints; +}; + +#endif diff --git a/src/BOPDS/BOPDS_Iterator.cdl b/src/BOPDS/BOPDS_Iterator.cdl new file mode 100644 index 0000000000..6bc0b41988 --- /dev/null +++ b/src/BOPDS/BOPDS_Iterator.cdl @@ -0,0 +1,129 @@ +-- Created by: Peter KURNEV +-- Copyright (c) 2010-2012 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 +-- +-- The content of this file is subject to the Open CASCADE Technology Public +-- License Version 6.5 (the "License"). You may not use the content of this file +-- except in compliance with the License. Please obtain a copy of the License +-- at http://www.opencascade.org and read it completely before using this file. +-- +-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +-- +-- The Original Code and all software distributed under the License is +-- distributed on an "AS IS" basis, without warranty of any kind, and the +-- Initial Developer hereby disclaims all such warranties, including without +-- limitation, any warranties of merchantability, fitness for a particular +-- purpose or non-infringement. Please see the License for the specific terms +-- and conditions governing the rights and limitations under the License. + + + +class Iterator from BOPDS + + ---Purpose: + -- The class BOPDS_Iterator is + -- 1.to compute intersections between BRep sub-shapes + -- of arguments of an operation (see the class BOPDS_DS) + -- in terms of theirs bounding boxes + -- 2.provides interface to iterare the pairs of + -- intersected sub-shapes of given type + +uses + BaseAllocator from BOPCol, + ShapeEnum from TopAbs, + DS from BOPDS, + PDS from BOPDS, + PassKeyBoolean from BOPDS, + ListOfPassKeyBoolean from BOPDS, + ListIteratorOfListOfPassKeyBoolean from BOPDS, + VectorOfListOfPassKeyBoolean from BOPDS + +--raises + +is + Create + returns Iterator from BOPDS; + ---C++: alias "Standard_EXPORT virtual ~BOPDS_Iterator();" + ---Purpose: + --- Empty contructor + --- + + Create (theAllocator: BaseAllocator from BOPCol) + returns Iterator from BOPDS; + ---Purpose: + --- Contructor + --- theAllocator - the allocator to manage the memory + --- + + SetDS(me:out; + pDS:PDS from BOPDS); + ---Purpose: + --- Modifier + --- Sets the data structure to process + + DS(me) + returns DS from BOPDS; + ---C++:return const & + ---Purpose: + --- Selector + --- Returns the data structure + + Initialize(me: out; + theType1: ShapeEnum from TopAbs; + theType2: ShapeEnum from TopAbs); + ---Purpose: + --- Initializes the iterator + --- theType1 - the first type of shape + --- theType2 - the second type of shape + + More(me) + returns Boolean from Standard; + ---Purpose: + --- Returns true if still there are pairs + -- of intersected shapes + + Next(me:out); + ---Purpose: + --- Moves iterations ahead + + Value(me; + theIndex1:out Integer from Standard; + theIndex2:out Integer from Standard; + theWithSubShape: out Boolean from Standard); + ---Purpose: + --- Returns indices (DS) of intersected shapes + --- theIndex1 - the index of the first shape + --- theIndex2 - the index of the second shape + --- theWithSubShape - flag. True if the sub-shapes of + --- shapes are intersected + + Prepare(me:out) + is virtual; + ---Purpose: + --- Perform the intersection algorithm and prepare + --- the results to be used + + ExpectedLength(me) + returns Integer from Standard; + ---Purpose: + --- Returns the number of intersections founded + + BlockLength(me) + returns Integer from Standard; + ---Purpose: + --- Returns the block length + + Intersect(me:out) + is virtual protected; + +fields + myAllocator: BaseAllocator from BOPCol is protected; + myLength : Integer from Standard is protected; + myDS : PDS from BOPDS is protected; + myLists : VectorOfListOfPassKeyBoolean from BOPDS is protected; + myIterator : ListIteratorOfListOfPassKeyBoolean from BOPDS is protected; + +end Iterator; diff --git a/src/BOPDS/BOPDS_Iterator.cxx b/src/BOPDS/BOPDS_Iterator.cxx new file mode 100644 index 0000000000..71c798a6b9 --- /dev/null +++ b/src/BOPDS/BOPDS_Iterator.cxx @@ -0,0 +1,310 @@ +// Created by: Peter KURNEV +// Copyright (c) 2010-2012 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 +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#include +// +#include +// +#include +#include +// +#include +#include +#include +// +#include +#include +#include +#include +// +#include +#include +#include +#include +#include +#include + + +//======================================================================= +//function : +//purpose : +//======================================================================= + BOPDS_Iterator::BOPDS_Iterator() +: + myAllocator(NCollection_BaseAllocator::CommonBaseAllocator()) +{ + myDS=NULL; + myLength=0; + // + myLists.SetStartSize(6); + myLists.Init(); +} +//======================================================================= +//function : +//purpose : +//======================================================================= + BOPDS_Iterator::BOPDS_Iterator(const Handle(NCollection_BaseAllocator)& theAllocator) +: + myAllocator(theAllocator), + myLists(theAllocator) +{ + myDS=NULL; + myLength=0; + // + myLists.SetStartSize(6); + myLists.Init(); +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= + BOPDS_Iterator::~BOPDS_Iterator() +{ +} +//======================================================================= +// function: SetDS +// purpose: +//======================================================================= + void BOPDS_Iterator::SetDS(const BOPDS_PDS& aDS) +{ + myDS=aDS; +} +//======================================================================= +// function: DS +// purpose: +//======================================================================= + const BOPDS_DS& BOPDS_Iterator::DS()const +{ + return *myDS; +} +//======================================================================= +// function: ExpectedLength +// purpose: +//======================================================================= + Standard_Integer BOPDS_Iterator::ExpectedLength() const +{ + return myLength; +} +//======================================================================= +// function: BlockLength +// purpose: +//======================================================================= + Standard_Integer BOPDS_Iterator::BlockLength() const +{ + Standard_Integer aNbIIs; + Standard_Real aCfPredict=.5; + + aNbIIs=ExpectedLength(); + + if (aNbIIs<=1) { + return 1; + } + // + aNbIIs=(Standard_Integer) (aCfPredict*(Standard_Real)aNbIIs); + return aNbIIs; +} +//======================================================================= +// function: Initialize +// purpose: +//======================================================================= + void BOPDS_Iterator::Initialize(const TopAbs_ShapeEnum aType1, + const TopAbs_ShapeEnum aType2) +{ + Standard_Integer iX; + // + myLength=0; + iX=BOPDS_Tools::TypeToInteger(aType1, aType2); + if (iX>=0) { + myIterator.Initialize(myLists(iX)); + myLength=myLists(iX).Extent(); + } +} +//======================================================================= +// function: More +// purpose: +//======================================================================= + Standard_Boolean BOPDS_Iterator::More()const +{ + return myIterator.More(); +} +//======================================================================= +// function: Next +// purpose: +//======================================================================= + void BOPDS_Iterator::Next() +{ + myIterator.Next(); +} +//======================================================================= +// function: Value +// purpose: +//======================================================================= + void BOPDS_Iterator::Value(Standard_Integer& theI1, + Standard_Integer& theI2, + Standard_Boolean& theWithSubShape) const +{ + Standard_Integer iT1, iT2, n1, n2; + // + const BOPDS_PassKeyBoolean& aPKB=myIterator.Value(); + aPKB.Ids(n1, n2); + // + iT1=(Standard_Integer)(myDS->ShapeInfo(n1).ShapeType()); + iT2=(Standard_Integer)(myDS->ShapeInfo(n2).ShapeType()); + // + theI1=n1; + theI2=n2; + if (iT1 aTreeFiller(aBBTree); + // + aNb=myDS->NbSourceShapes(); + for (i=0; iShapeInfo(i); + if (aSI.HasBRep()) { + const TopoDS_Shape& aS=aSI.Shape(); + const Bnd_Box& aBoxEx=aSI.Box(); + aMSI.Bind(aS, i); + aMSB.Add(aS, aBoxEx); + } + } + // + aNbB=aMSB.Extent(); + for (i=1; i<=aNbB; ++i) { + const TopoDS_Shape& aS=aMSB.FindKey(i); + const Bnd_Box& aBoxEx=aMSB(i); + // + aTreeFiller.Add(i, aBoxEx); + // + iDS=aMSI.Find(aS); + aMII.Bind(i, iDS); + } + // + aTreeFiller.Fill(); + // + aNbR=myDS->NbRanges()-1; + for (iR=0; iRRange(iR); + i1=aR.First(); + i2=aR.Last(); + for (i=i1; i<=i2; ++i) { + const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i); + // + if (!aSI.HasBRep()){ + continue; + } + // + aTi=aSI.ShapeType(); + const TopoDS_Shape& aSi=aSI.Shape(); + const Bnd_Box& aBoxEx=aMSB.FindFromKey(aSi); + aSelector.Clear(); + aSelector.SetBox(aBoxEx); + // + aNbSD=aBBTree.Select(aSelector); + if (!aNbSD){ + continue; + } + // + const Bnd_Box& aBoxi=myDS->ShapeInfo(i).Box(); + // + const BOPCol_ListOfInteger& aLI=aSelector.Indices(); + aIt.Initialize(aLI); + for (; aIt.More(); aIt.Next()) { + jB=aIt.Value(); // box index in MII + j=aMII.Find(jB); // DS index + if (j>=i1 && j<=i2) { + continue;// same range + } + // + aPKXB.SetIds(i, j); + if (aMPKXB.Add(aPKXB)) { + bFlag=Standard_False;// Bounding boxes are intersected + const Bnd_Box& aBoxj=myDS->ShapeInfo(j).Box(); + if (aBoxi.IsOut(aBoxj)) { + bFlag=!bFlag; //Bounding boxes of Sub-shapes are intersected + } + // + aTj=myDS->ShapeInfo(j).ShapeType(); + iX=BOPDS_Tools::TypeToInteger(aTi, aTj); + aPKXB.SetFlag(bFlag); + myLists(iX).Append(aPKXB); + }// if (aMPKXB.Add(aPKXB)) { + }// for (; aIt.More(); aIt.Next()) { + }//for (i=i1; i<=i2; ++i) { + }//for (iR=1; iR + +#include +#include +#include +// +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//======================================================================= +//function : +//purpose : +//======================================================================= + BOPDS_IteratorSI::BOPDS_IteratorSI() +: + BOPDS_Iterator() +{ +} +//======================================================================= +//function : +//purpose : +//======================================================================= + BOPDS_IteratorSI::BOPDS_IteratorSI(const Handle(NCollection_BaseAllocator)& theAllocator) +: + BOPDS_Iterator(theAllocator) +{ +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= + BOPDS_IteratorSI::~BOPDS_IteratorSI() +{ +} +//======================================================================= +// function: Intersect +// purpose: +//======================================================================= + void BOPDS_IteratorSI::Intersect() +{ + Standard_Boolean bFlag; + Standard_Integer aNbS, i, aNbB;//, iFlag, aNbLV, aNbA + Standard_Integer aNbSD, iX, j, iDS, jB, k;; + TopAbs_ShapeEnum aTi, aTj; + Handle(NCollection_IncAllocator) aAllocator; + BOPCol_ListIteratorOfListOfInteger aIt; + BOPCol_DataMapIteratorOfDataMapOfIntegerListOfInteger aItVSD; + // + //-----------------------------------------------------scope_1 f + aAllocator=new NCollection_IncAllocator(); + // + BOPCol_DataMapOfShapeInteger aMSI(100, aAllocator); + BOPCol_DataMapOfIntegerInteger aMII(100, aAllocator); + BOPDS_MapOfPassKeyBoolean aMPA(100, aAllocator); + BOPDS_MapOfPassKeyBoolean aMPKXB(100, aAllocator); + BOPCol_IndexedDataMapOfShapeBox aMSB(100, aAllocator); + BOPDS_PassKeyBoolean aPKXB; + // + BOPDS_BoxBndTreeSelector aSelector; + BOPDS_BoxBndTree aBBTree; + NCollection_UBTreeFiller aTreeFiller(aBBTree); + // + // myPairsAvoid, aMSI, aMSB + aNbS=myDS->NbSourceShapes(); + for (i=0; iShapeInfo(i); + // + if (aSI.HasBRep()) { + const TopoDS_Shape& aSi=aSI.Shape(); + aTi=aSI.ShapeType(); + if (aTi!=TopAbs_VERTEX) { + //-- + const BOPCol_ListOfInteger& aLA=aSI.SubShapes(); + aIt.Initialize(aLA); + for (; aIt.More(); aIt.Next()) { + iX=aIt.Value(); + aPKXB.Clear(); + aPKXB.SetIds(i, iX); + aMPA.Add(aPKXB); + } + //--t + } + else { + aPKXB.Clear(); + aPKXB.SetIds(i, i); + aMPA.Add(aPKXB); + } + // + const Bnd_Box& aBoxEx=aSI.Box(); + // + aMSI.Bind(aSi, i); + aMSB.Add(aSi, aBoxEx); + } + } // for (i=0; iShapeInfo(i); + aTi=aSI.ShapeType(); + if (!aSI.HasBRep()){ + continue; + } + // + const TopoDS_Shape& aSi=myDS->Shape(i); + aTi=aSi.ShapeType(); + const Bnd_Box& aBoxEx=aMSB.FindFromKey(aSi); + aSelector.Clear(); + aSelector.SetBox(aBoxEx); + // + aNbSD=aBBTree.Select(aSelector); + if (!aNbSD){ + continue; + } + // + const BOPCol_ListOfInteger& aLI=aSelector.Indices(); + // + k=0; + // + aIt.Initialize(aLI); + for (; aIt.More(); aIt.Next()) { + jB=aIt.Value(); // box index in MII + j=aMII.Find(jB); // DS index + // + aPKXB.SetIds(i, j); + if (aMPA.Contains(aPKXB)) { + continue; + } + // + if (aMPKXB.Add(aPKXB)) { + bFlag=Standard_False;// Bounding boxes are intersected + const Bnd_Box& aBoxi=myDS->ShapeInfo(i).Box(); + const Bnd_Box& aBoxj=myDS->ShapeInfo(j).Box(); + if (aBoxi.IsOut(aBoxj)) { + bFlag=!bFlag; //Bounding boxes of Sub-shapes are intersected + } + aTj=myDS->ShapeInfo(j).ShapeType();// + iX=BOPDS_Tools::TypeToInteger(aTi, aTj); + aPKXB.SetFlag(bFlag); + myLists(iX).Append(aPKXB); + }// if (aMPKXB.Add(aPKXB)) { + }// for (; aIt.More(); aIt.Next()) { + }//for (i=1; i<=aNbS; ++i) { + // + aMSI.Clear(); + aMII.Clear(); + aMPA.Clear(); + aMPKXB.Clear(); + aMSB.Clear(); + // + aAllocator.Nullify(); + //-----------------------------------------------------scope_1 t +} + diff --git a/src/BOPDS/BOPDS_ListIteratorOfListOfPassKeyBoolean.hxx b/src/BOPDS/BOPDS_ListIteratorOfListOfPassKeyBoolean.hxx new file mode 100644 index 0000000000..e6292033d5 --- /dev/null +++ b/src/BOPDS/BOPDS_ListIteratorOfListOfPassKeyBoolean.hxx @@ -0,0 +1,25 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPDS_ListIteratorOfListOfPassKeyBoolean_HeaderFile +#define BOPDS_ListIteratorOfListOfPassKeyBoolean_HeaderFile + +#include + +#endif diff --git a/src/BOPDS/BOPDS_ListOfPassKeyBoolean.hxx b/src/BOPDS/BOPDS_ListOfPassKeyBoolean.hxx new file mode 100644 index 0000000000..1b3860e069 --- /dev/null +++ b/src/BOPDS/BOPDS_ListOfPassKeyBoolean.hxx @@ -0,0 +1,29 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPDS_ListOfPassKeyBoolean_HeaderFile +#define BOPDS_ListOfPassKeyBoolean_HeaderFile + +#include +#include + +typedef NCollection_List BOPDS_ListOfPassKeyBoolean; +typedef BOPDS_ListOfPassKeyBoolean::Iterator BOPDS_ListIteratorOfListOfPassKeyBoolean; + +#endif diff --git a/src/BOPDS/BOPDS_ListOfPave.hxx b/src/BOPDS/BOPDS_ListOfPave.hxx new file mode 100644 index 0000000000..87dbfc21b2 --- /dev/null +++ b/src/BOPDS/BOPDS_ListOfPave.hxx @@ -0,0 +1,30 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPDS_ListOfPave_HeaderFile +#define BOPDS_ListOfPave_HeaderFile + +#include +#include + +typedef NCollection_List BOPDS_ListOfPave; +typedef BOPDS_ListOfPave::Iterator BOPDS_ListIteratorOfListOfPave; + + +#endif diff --git a/src/BOPDS/BOPDS_ListOfPaveBlock.hxx b/src/BOPDS/BOPDS_ListOfPaveBlock.hxx new file mode 100644 index 0000000000..2a25e07119 --- /dev/null +++ b/src/BOPDS/BOPDS_ListOfPaveBlock.hxx @@ -0,0 +1,31 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPDS_ListOfPaveBlock_HeaderFile +#define BOPDS_ListOfPaveBlock_HeaderFile + +#include +#include +class BOPDS_PaveBlock; + +typedef NCollection_List BOPDS_ListOfPaveBlock; +typedef BOPDS_ListOfPaveBlock::Iterator BOPDS_ListIteratorOfListOfPaveBlock; + + +#endif diff --git a/src/BOPDS/BOPDS_MapOfCommonBlock.hxx b/src/BOPDS/BOPDS_MapOfCommonBlock.hxx new file mode 100644 index 0000000000..73425b975f --- /dev/null +++ b/src/BOPDS/BOPDS_MapOfCommonBlock.hxx @@ -0,0 +1,34 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPDS_MapOfCommonBlock_HeaderFile +#define BOPDS_MapOfCommonBlock_HeaderFile + +#define _NCollection_MapHasher +#include +#include +#include + +typedef NCollection_Map BOPDS_MapOfCommonBlock; +typedef BOPDS_MapOfCommonBlock::Iterator BOPDS_MapIteratorOfMapOfCommonBlock; + +#undef _NCollection_MapHasher + + +#endif diff --git a/src/BOPDS/BOPDS_MapOfPassKey.hxx b/src/BOPDS/BOPDS_MapOfPassKey.hxx new file mode 100644 index 0000000000..0199ec6349 --- /dev/null +++ b/src/BOPDS/BOPDS_MapOfPassKey.hxx @@ -0,0 +1,35 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPDS_MapOfPassKey_HeaderFile +#define BOPDS_MapOfPassKey_HeaderFile + +#define _NCollection_MapHasher +#include +#include +#include + + +typedef NCollection_Map BOPDS_MapOfPassKey; +typedef BOPDS_MapOfPassKey::Iterator BOPDS_MapIteratorMapOfPassKey; + +#undef _NCollection_MapHasher + + +#endif diff --git a/src/BOPDS/BOPDS_MapOfPassKeyBoolean.hxx b/src/BOPDS/BOPDS_MapOfPassKeyBoolean.hxx new file mode 100644 index 0000000000..ad9cbc7e9c --- /dev/null +++ b/src/BOPDS/BOPDS_MapOfPassKeyBoolean.hxx @@ -0,0 +1,33 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPDS_MapOfPassKeyBoolean_HeaderFile +#define BOPDS_MapOfPassKeyBoolean_HeaderFile + +#define _NCollection_MapHasher +#include +#include +#include + +typedef NCollection_Map BOPDS_MapOfPassKeyBoolean; +typedef BOPDS_MapOfPassKeyBoolean::Iterator BOPDS_MapIteratorMapOfPassKeyBoolean; + +#undef _NCollection_MapHasher + +#endif diff --git a/src/BOPDS/BOPDS_MapOfPave.hxx b/src/BOPDS/BOPDS_MapOfPave.hxx new file mode 100644 index 0000000000..58887cd789 --- /dev/null +++ b/src/BOPDS/BOPDS_MapOfPave.hxx @@ -0,0 +1,34 @@ +// Created by: Eugeny MALTCHIKOV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + +#ifndef BOPDS_MapOfPave_HeaderFile +#define BOPDS_MapOfPave_HeaderFile + +#define _NCollection_MapHasher +#include +#include +#include + + +typedef NCollection_Map BOPDS_MapOfPave; +typedef BOPDS_MapOfPave::Iterator BOPDS_MapIteratorMapOfPave; + +#undef _NCollection_MapHasher + + +#endif diff --git a/src/BOPDS/BOPDS_MapOfPaveBlock.hxx b/src/BOPDS/BOPDS_MapOfPaveBlock.hxx new file mode 100644 index 0000000000..43c5fb35fe --- /dev/null +++ b/src/BOPDS/BOPDS_MapOfPaveBlock.hxx @@ -0,0 +1,34 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPDS_MapOfPaveBlock_HeaderFile +#define BOPDS_MapOfPaveBlock_HeaderFile + +#define _NCollection_MapHasher +#include +#include +#include + +typedef NCollection_Map BOPDS_MapOfPaveBlock; +typedef BOPDS_MapOfPaveBlock::Iterator BOPDS_MapIteratorOfMapOfPaveBlock; + +#undef _NCollection_MapHasher + + +#endif diff --git a/src/BOPDS/BOPDS_PassKey.cdl b/src/BOPDS/BOPDS_PassKey.cdl new file mode 100644 index 0000000000..1603f4d8d9 --- /dev/null +++ b/src/BOPDS/BOPDS_PassKey.cdl @@ -0,0 +1,159 @@ +-- Created by: Peter KURNEV +-- Copyright (c) 2010-2012 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 +-- +-- The content of this file is subject to the Open CASCADE Technology Public +-- License Version 6.5 (the "License"). You may not use the content of this file +-- except in compliance with the License. Please obtain a copy of the License +-- at http://www.opencascade.org and read it completely before using this file. +-- +-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +-- +-- The Original Code and all software distributed under the License is +-- distributed on an "AS IS" basis, without warranty of any kind, and the +-- Initial Developer hereby disclaims all such warranties, including without +-- limitation, any warranties of merchantability, fitness for a particular +-- purpose or non-infringement. Please see the License for the specific terms +-- and conditions governing the rights and limitations under the License. + + +class PassKey from BOPDS + + ---Purpose: + -- The class BOPDS_PassKey is to provide + -- possibility to map objects that + -- have a set of integer IDs as a base + +uses + Shape from TopoDS, + ListOfInteger from BOPCol, + PInteger from BOPCol, + BaseAllocator from BOPCol + +--raises + +is + Create + returns PassKey from BOPDS; + ---C++: inline + ---C++: alias "virtual ~BOPDS_PassKey();" + ---Purpose: + --- Empty contructor + --- + + Create (theAllocator: BaseAllocator from BOPCol) + returns PassKey from BOPDS; + ---C++: inline + ---Purpose: + --- Contructor + --- theAllocator - the allocator to manage the memory + --- + + Create(Other:PassKey from BOPDS) + returns PassKey from BOPDS; + ---C++: inline + ---C++: alias "BOPDS_PassKey& operator =(const BOPDS_PassKey& Other);" + ---Purpose: + --- Copy Contructor + + Clear(me:out); + ---C++: inline + ---Purpose: + --- Clear the contents + + SetIds(me:out; + theI1 :Integer from Standard); + ---C++: inline + ---Purpose: + --- Modifier + --- Sets one Id + + SetIds(me:out; + theI1 :Integer from Standard; + theI2 :Integer from Standard); + ---C++: inline + ---Purpose: + --- Modifier + --- Sets two Id , + + SetIds(me:out; + theI1 :Integer from Standard; + theI2 :Integer from Standard; + theI3 :Integer from Standard); + ---C++: inline + ---Purpose: + --- Modifier + --- Sets three Id ,, + SetIds(me:out; + theI1 :Integer from Standard; + theI2 :Integer from Standard; + theI3 :Integer from Standard; + theI4 :Integer from Standard); + ---C++: inline + ---Purpose: + --- Modifier + --- Sets four Id ,,, + SetIds(me:out; + theLI:ListOfInteger from BOPCol); + ---Purpose: + --- Modifier + --- Sets the list of Id + + NbIds(me) + returns Integer from Standard; + ---C++: inline + ---Purpose: + --- Selector + --- Returns the number of Ids> + + IsEqual(me; + theOther:PassKey from BOPDS) + returns Boolean from Standard; + ---C++: inline + ---Purpose: + --- Query + --- Returns true if the PassKey is equal to + + HashCode(me; + theUpper : Integer from Standard) + returns Integer from Standard; + ---C++: inline + ---Purpose: + --- Query + --- Returns hash code + + Id(me; + theIndex: Integer from Standard) + returns Integer from Standard; + ---C++: inline + ---Purpose: + --- Selector + --- Returns Id of index + + Ids(me; + theI1 :out Integer from Standard; + theI2 :out Integer from Standard); + ---C++: inline + ---Purpose: + --- Selector + --- Returns the first two Ids , + + Dump(me; + aHex:Integer from Standard=0); + + Allocate(me:out; + theSize:Integer from Standard) + returns PInteger from BOPCol + is protected; + ---C++: inline + +fields + myAllocator : BaseAllocator from BOPCol is protected; + myNbIds: Integer from Standard is protected; + mySum : Integer from Standard is protected; + myPtr : PInteger from BOPCol is protected; + +end PassKey; diff --git a/src/BOPDS/BOPDS_PassKey.cxx b/src/BOPDS/BOPDS_PassKey.cxx new file mode 100644 index 0000000000..339e485c21 --- /dev/null +++ b/src/BOPDS/BOPDS_PassKey.cxx @@ -0,0 +1,38 @@ +// Created by: Peter KURNEV +// Copyright (c) 2010-2012 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 +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#include + +#include + +#ifdef WNT +#pragma warning( disable : 4101) +#endif + + +//======================================================================= +//function : Dump +//purpose : +//======================================================================= + void BOPDS_PassKey::Dump(const Standard_Integer )const +{ +} diff --git a/src/BOPDS/BOPDS_PassKey.lxx b/src/BOPDS/BOPDS_PassKey.lxx new file mode 100644 index 0000000000..b9150c7546 --- /dev/null +++ b/src/BOPDS/BOPDS_PassKey.lxx @@ -0,0 +1,350 @@ +// Created by: Peter KURNEV +// Copyright (c) 2010-2012 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 +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + +static + inline Standard_Integer NormalizedId(const Standard_Integer aId, + const Standard_Integer aDiv); +static + inline void SortShell(const Standard_Integer n, + Standard_Integer* a); + +//======================================================================= +//function : +//purpose : +//======================================================================= + inline BOPDS_PassKey::BOPDS_PassKey() +{ + myAllocator=NCollection_BaseAllocator::CommonBaseAllocator(); + myPtr=NULL; + Clear(); +} +//======================================================================= +//function : +//purpose : +//======================================================================= + inline BOPDS_PassKey::BOPDS_PassKey(const Handle(NCollection_BaseAllocator)& theAllocator) +{ + myAllocator=theAllocator; + myPtr=NULL; + Clear(); +} +//======================================================================= +//function : +//purpose : +//======================================================================= + inline BOPDS_PassKey::BOPDS_PassKey(const BOPDS_PassKey& aOther) +{ + Standard_Integer i; + // + myPtr=NULL; + Clear(); + // + myAllocator=aOther.myAllocator; + myNbIds=aOther.myNbIds; + mySum=aOther.mySum; + // + if (myNbIds) { + myPtr=Allocate(myNbIds); + for (i=0; iAllocate(theSize*sizeof(Standard_Integer)); + return pPtr; +} + +//======================================================================= +//function :Clear +//purpose : +//======================================================================= + inline void BOPDS_PassKey::Clear() +{ + myNbIds=0; + mySum=0; + if (myPtr) { + myAllocator->Free((Standard_Address)myPtr); + myPtr=NULL; + } +} +//======================================================================= +//function :SetIds +//purpose : +//======================================================================= + inline void BOPDS_PassKey::SetIds(const Standard_Integer aId1) +{ + Clear(); + myNbIds=1; + myPtr=Allocate(myNbIds); + myPtr[0]=aId1; + mySum=NormalizedId(aId1, myNbIds); +} + +//======================================================================= +//function :SetIds +//purpose : +//======================================================================= + inline void BOPDS_PassKey::SetIds(const Standard_Integer aId1, + const Standard_Integer aId2) +{ + Clear(); + // + myNbIds=2; + myPtr=Allocate(myNbIds); + // + if (aId1myNbIds-1) { + return -1; + } + return myPtr[aIndex]; +} +//======================================================================= +//function :Ids +//purpose : +//======================================================================= + inline void BOPDS_PassKey::Ids(Standard_Integer& aId1, + Standard_Integer& aId2) const +{ + aId1=0; + aId2=0; + if (myNbIds>1) { + aId1=myPtr[0]; + aId2=myPtr[1]; + } +} +//======================================================================= +//function :IsEqual +//purpose : +//======================================================================= + inline Standard_Boolean BOPDS_PassKey::IsEqual(const BOPDS_PassKey& aOther) const +{ + Standard_Boolean bRet; + Standard_Integer i; + // + bRet=Standard_False; + // + if (myNbIds!=aOther.myNbIds) { + return bRet; + } + for (i=0; iaTresh) { + aIdRet=aId%aTresh; + } + return aIdRet; +} +//======================================================================= +// function: SortShell +// purpose : +//======================================================================= +inline void SortShell(const Standard_Integer n, + Standard_Integer* a) +{ + Standard_Integer nd, i, j, l, d=1; + Standard_Integer x; + // + while(d<=n) { + d*=2; + } + // + while (d) { + d=(d-1)/2; + // + nd=n-d; + for (i=0; i -1) { + goto m30; + } + }//if (a[l] < a[j]){ + }//for (i=0; i diff --git a/src/BOPDS/BOPDS_PassKeyBoolean.lxx b/src/BOPDS/BOPDS_PassKeyBoolean.lxx new file mode 100644 index 0000000000..48b0654db6 --- /dev/null +++ b/src/BOPDS/BOPDS_PassKeyBoolean.lxx @@ -0,0 +1,85 @@ +// Created by: Peter KURNEV +// Copyright (c) 2010-2012 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 +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + +//======================================================================= +//function : +//purpose : +//======================================================================= + inline BOPDS_PassKeyBoolean::BOPDS_PassKeyBoolean() +: + BOPDS_PassKey(), + myFlag(Standard_False) +{ +} +//======================================================================= +//function : +//purpose : +//======================================================================= + inline BOPDS_PassKeyBoolean::BOPDS_PassKeyBoolean + (const Handle(NCollection_BaseAllocator)& theAllocator) +: + BOPDS_PassKey(theAllocator), + myFlag(Standard_False) +{ +} +//======================================================================= +//function : +//purpose : +//======================================================================= + inline BOPDS_PassKeyBoolean::BOPDS_PassKeyBoolean(const BOPDS_PassKeyBoolean& aOther) +{ + myPtr=NULL; + BOPDS_PassKey::operator =(aOther); + myFlag=aOther.myFlag; +} +//======================================================================= +//function :~ +//purpose : +//======================================================================= + inline BOPDS_PassKeyBoolean::~BOPDS_PassKeyBoolean() +{ +} +//======================================================================= +//function :operator = +//purpose : +//======================================================================= + inline BOPDS_PassKeyBoolean& BOPDS_PassKeyBoolean::operator =(const BOPDS_PassKeyBoolean& aOther) +{ + BOPDS_PassKey::operator =(aOther); + myFlag=aOther.myFlag; + return *this; +} +//======================================================================= +//function :SetFlag +//purpose : +//======================================================================= + inline void BOPDS_PassKeyBoolean::SetFlag(const Standard_Boolean aFlag) +{ + myFlag=aFlag; +} +//======================================================================= +//function :Flag +//purpose : +//======================================================================= + inline Standard_Boolean BOPDS_PassKeyBoolean::Flag()const +{ + return myFlag; +} diff --git a/src/BOPDS/BOPDS_PassKeyMapHasher.cdl b/src/BOPDS/BOPDS_PassKeyMapHasher.cdl new file mode 100644 index 0000000000..288fea2c7c --- /dev/null +++ b/src/BOPDS/BOPDS_PassKeyMapHasher.cdl @@ -0,0 +1,45 @@ +-- Created by: Peter KURNEV +-- Copyright (c) 2010-2012 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 +-- +-- The content of this file is subject to the Open CASCADE Technology Public +-- License Version 6.5 (the "License"). You may not use the content of this file +-- except in compliance with the License. Please obtain a copy of the License +-- at http://www.opencascade.org and read it completely before using this file. +-- +-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +-- +-- The Original Code and all software distributed under the License is +-- distributed on an "AS IS" basis, without warranty of any kind, and the +-- Initial Developer hereby disclaims all such warranties, including without +-- limitation, any warranties of merchantability, fitness for a particular +-- purpose or non-infringement. Please see the License for the specific terms +-- and conditions governing the rights and limitations under the License. + + +class PassKeyMapHasher from BOPDS + + ---Purpose: + +uses + PassKey from BOPDS + +--raises + +is + HashCode(myclass; + aPKey : PassKey from BOPDS; + Upper : Integer from Standard) + returns Integer from Standard; + ---C++: inline + + IsEqual(myclass; + aPKey1 : PassKey from BOPDS; + aPKey2 : PassKey from BOPDS) + returns Boolean from Standard; + ---C++: inline + +end PassKeyMapHasher; diff --git a/src/BOPDS/BOPDS_PassKeyMapHasher.cxx b/src/BOPDS/BOPDS_PassKeyMapHasher.cxx new file mode 100644 index 0000000000..39282c9c67 --- /dev/null +++ b/src/BOPDS/BOPDS_PassKeyMapHasher.cxx @@ -0,0 +1,24 @@ +// Created by: Peter KURNEV +// Copyright (c) 2010-2012 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 +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#include + diff --git a/src/BOPDS/BOPDS_PassKeyMapHasher.lxx b/src/BOPDS/BOPDS_PassKeyMapHasher.lxx new file mode 100644 index 0000000000..ea6f5cf057 --- /dev/null +++ b/src/BOPDS/BOPDS_PassKeyMapHasher.lxx @@ -0,0 +1,43 @@ +// Created by: Peter KURNEV +// Copyright (c) 2010-2012 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 +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + +#include + +//======================================================================= +//function : HashCode +//purpose : +//======================================================================= +inline + Standard_Integer BOPDS_PassKeyMapHasher::HashCode(const BOPDS_PassKey& aPK, + const Standard_Integer Upper) +{ + return aPK.HashCode(Upper); +} +//======================================================================= +//function :IsEqual +//purpose : +//======================================================================= +inline + Standard_Boolean BOPDS_PassKeyMapHasher::IsEqual(const BOPDS_PassKey& aPK1, + const BOPDS_PassKey& aPK2) +{ + return aPK1.IsEqual(aPK2); +} diff --git a/src/BOPDS/BOPDS_Pave.cdl b/src/BOPDS/BOPDS_Pave.cdl new file mode 100644 index 0000000000..66497efbaf --- /dev/null +++ b/src/BOPDS/BOPDS_Pave.cdl @@ -0,0 +1,97 @@ +-- Created by: Peter KURNEV +-- Copyright (c) 1999-2012 OPEN CASCADE SAS +-- +-- The content of this file is subject to the Open CASCADE Technology Public +-- License Version 6.5 (the "License"). You may not use the content of this file +-- except in compliance with the License. Please obtain a copy of the License +-- at http://www.opencascade.org and read it completely before using this file. +-- +-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +-- +-- The Original Code and all software distributed under the License is +-- distributed on an "AS IS" basis, without warranty of any kind, and the +-- Initial Developer hereby disclaims all such warranties, including without +-- limitation, any warranties of merchantability, fitness for a particular +-- purpose or non-infringement. Please see the License for the specific terms +-- and conditions governing the rights and limitations under the License. + +class Pave from BOPDS + + ---Purpose: + -- The class BOPDS_Pave is to store + -- information about vertex on an edge +--uses +--raises + +is + Create + returns Pave from BOPDS; + ---C++: alias "Standard_EXPORT virtual ~BOPDS_Pave();" + ---C++: inline + ---Purpose: + --- Empty contructor + --- + + SetIndex(me:out; + theIndex: Integer from Standard); + ---C++: inline + ---Purpose: + --- Modifier + --- Sets the index of vertex + + Index(me) + returns Integer from Standard; + ---C++: inline + ---Purpose: + --- Selector + --- Returns the index of vertex + SetParameter(me:out; + theParameter: Real from Standard); + ---C++: inline + ---Purpose: + --- Modifier + --- Sets the parameter of vertex + + Parameter(me) + returns Real from Standard; + ---C++: inline + ---Purpose: + --- Selector + --- Returns the parameter of vertex + Contents(me; + theIndex:out Integer from Standard; + theParameter:out Real from Standard); + ---C++: inline + ---Purpose: + --- Selector + --- Returns the index of vertex + --- Returns the parameter of vertex + + IsLess(me; + theOther: Pave from BOPDS) + returns Boolean from Standard; + ---C++: alias operator < + ---C++: inline + ---Purpose: + --- Query + --- Returns true if thr parameter od this is less + -- than the parameter of + + IsEqual(me; + theOther: Pave from BOPDS) + returns Boolean from Standard; + ---C++: alias operator == + ---C++: inline + ---Purpose: + --- Query + --- Returns true if thr parameter od this is equal + -- to the parameter of + + Dump(me); + +fields + myIndex : Integer from Standard is protected; + myParameter: Real from Standard is protected; + +end Pave; diff --git a/src/BOPDS/BOPDS_Pave.cxx b/src/BOPDS/BOPDS_Pave.cxx new file mode 100644 index 0000000000..c633b4d480 --- /dev/null +++ b/src/BOPDS/BOPDS_Pave.cxx @@ -0,0 +1,29 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#include +#include +//======================================================================= +//function : Dump +//purpose : +//======================================================================= + void BOPDS_Pave::Dump()const +{ + printf(" { %-d %-7.3lf}", myIndex, myParameter); +} diff --git a/src/BOPDS/BOPDS_Pave.lxx b/src/BOPDS/BOPDS_Pave.lxx new file mode 100644 index 0000000000..e919ec9d07 --- /dev/null +++ b/src/BOPDS/BOPDS_Pave.lxx @@ -0,0 +1,98 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +//======================================================================= +//function : +//purpose : +//======================================================================= + inline BOPDS_Pave::BOPDS_Pave() +{ + myIndex=-1; + myParameter=99.; +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= + inline BOPDS_Pave::~BOPDS_Pave() +{ +} +//======================================================================= +//function : SetIndex +//purpose : +//======================================================================= + inline void BOPDS_Pave::SetIndex(const Standard_Integer theIndex) +{ + myIndex=theIndex; +} +//======================================================================= +//function : Index +//purpose : +//======================================================================= + inline Standard_Integer BOPDS_Pave::Index()const +{ + return myIndex; +} +//======================================================================= +//function : SetParameter +//purpose : +//======================================================================= + inline void BOPDS_Pave::SetParameter(const Standard_Real theParameter) +{ + myParameter=theParameter; +} + +//======================================================================= +//function : Parameter +//purpose : +//======================================================================= + inline Standard_Real BOPDS_Pave::Parameter()const +{ + return myParameter; +} +//======================================================================= +//function : Contents +//purpose : +//======================================================================= + inline void BOPDS_Pave::Contents(Standard_Integer& theIndex, + Standard_Real& theParameter)const +{ + theIndex=myIndex; + theParameter=myParameter; +} +//======================================================================= +//function : IsLess +//purpose : +//======================================================================= + inline Standard_Boolean BOPDS_Pave::IsLess(const BOPDS_Pave& theOther)const +{ + return myParameter - the allocator to manage the memory + --- + + SetPave1(me:mutable; + thePave:Pave from BOPDS); + ---Purpose: + --- Modifier + --- Sets the first pave + + Pave1(me) + returns Pave from BOPDS; + ---C++: return const & + ---Purpose: + --- Selector + --- Returns the first pave + + SetPave2(me:mutable; + thePave:Pave from BOPDS); + ---Purpose: + --- Modifier + --- Sets the second pave + + Pave2(me) + returns Pave from BOPDS; + ---C++: return const & + ---Purpose: + --- Selector + --- Returns the second pave + + SetEdge(me:mutable; + theEdge:Integer from Standard); + ---Purpose: + --- Modifier + --- Sets the index of edge of pave block + Edge(me) + returns Integer from Standard; + ---Purpose: + --- Selector + --- Returns the index of edge of pave block + + HasEdge(me) + returns Boolean from Standard; + ---Purpose: + --- Query + --- Returns true if the pave block has edge + + HasEdge(me; + theEdge:out Integer from Standard) + returns Boolean from Standard; + ---Purpose: + --- Query + --- Returns true if the pave block has edge + --- Returns the index of edge + + SetOriginalEdge (me:mutable; + theEdge:Integer from Standard); + ---Purpose: + --- Modifier + --- Sets the index of original edge + --- of the pave block + + OriginalEdge(me) + returns Integer from Standard; + ---Purpose: + --- Selector + --- Returns the index of original edge of pave block + + IsSplitEdge(me) + returns Boolean from Standard; + ---Purpose: + --- Query + --- Returns true if the edge is equal to the original edge + --- of the pave block + + Range(me; + theT1:out Real from Standard; + theT2:out Real from Standard); + ---Purpose: + --- Selector + --- Returns the parametric range + --- of the pave block + + HasSameBounds(me; + theOther: PaveBlock from BOPDS) + returns Boolean from Standard; + ---Purpose: + --- Query + --- Returns true if the pave block has pave indices + --- that equal to the pave indices of the pave block + --- + + Indices(me; + theIndex1:out Integer from Standard; + theIndex2:out Integer from Standard); + ---Purpose: + --- Selector + --- Returns the pave indices + --- of the pave block + + -- + -- extras + -- + IsToUpdate(me) + returns Boolean from Standard; + ---Purpose: + --- Query + --- Returns true if the pave block contains extra paves + + AppendExtPave(me:mutable; + theLP:Pave from BOPDS); + ---Purpose: + --- Modifier + --- Appends extra paves + + AppendExtPave1(me:mutable; + thePave:Pave from BOPDS); + ---Purpose: + --- Modifier + --- Appends extra pave + + ExtPaves(me) + returns ListOfPave from BOPDS; + ---C++: return const & + ---Purpose: + --- Selector + --- Returns the extra paves + + --modified by NIZHNY-EMV Thu Aug 11 13:32:20 2011 + ChangeExtPaves(me:mutable) + returns ListOfPave from BOPDS; + ---C++: return & + ---Purpose: + --- Selector / Modifier + --- Returns the extra paves + --modified by NIZHNY-EMV Thu Aug 11 13:32:22 2011 + + Update(me:mutable; + theLPB : out ListOfPaveBlock from BOPDS; + theFlag : Boolean from Standard=Standard_True); + ---Purpose: + --- Modifier + --- Updates the pave block. The extra paves are used + --- to create new pave blocks . + --- - if true, the first pave and the second + --- pave are used to produce new pave blocks. + + ContainsParameter(me; + thePrm:Real from Standard; + theTol:Real from Standard) + returns Boolean from Standard; + ---Purpose: + --- Query + --- Returns true if the extra paves contain the pave + --- with given value of the parameter + --- - the value of the tolerance to compare + + -- + -- common block + -- + SetCommonBlock(me:mutable; + theCB:CommonBlock from BOPDS); + ---Purpose: + --- Modifier + --- Sets the common block + + CommonBlock(me) + returns CommonBlock from BOPDS; + ---C++: return const & + ---Purpose: + --- Selector + --- Returns the common block + + IsCommonBlock(me) + returns Boolean from Standard; + ---Purpose: + --- Query + --- Returns true if the pave block is common block + + IsCommonBlockOnEdge(me) + returns Boolean from Standard; + ---Purpose: + --- Query + --- Returns true if the pave block is common block + --- that contains at least one pave block + + RealPaveBlock(me) + returns PaveBlock from BOPDS; + ---C++: return const & + ---Purpose: + --- Selector + --- Returns the real common block + -- + -- shrunk data + -- + SetShrunkData(me:mutable; + theTS1:Real from Standard; + theTS2:Real from Standard; + theBox:Box from Bnd); + ---Purpose: + --- Modifier + --- Sets the shrunk data for the pave block + --- , - shrunk range + --- - the bounding box + + ShrunkData(me; + theTS1:out Real from Standard; + theTS2:out Real from Standard; + theBox:out Box from Bnd); + ---Purpose: + --- Selector + --- Returns the shrunk data for the pave block + --- , - shrunk range + --- - the bounding box + + HasShrunkData(me) + returns Boolean from Standard; + ---Purpose: + --- Query + --- Returns true if the pave block contains + --- the shrunk data + + Dump(me); + + +fields + --general + myAllocator : BaseAllocator from BOPCol is protected; + myEdge : Integer from Standard is protected; + myOriginalEdge : Integer from Standard is protected; + myPave1 : Pave from BOPDS is protected; + myPave2 : Pave from BOPDS is protected; + --extras + myExtPaves : ListOfPave from BOPDS is protected; + --common block + myCommonBlock : CommonBlock from BOPDS is protected; + --shrunk data + myTS1 : Real from Standard is protected; + myTS2 : Real from Standard is protected; + myShrunkBox : Box from Bnd is protected; + --dummies + myPB : PaveBlock from BOPDS is protected; + myMFence : MapOfInteger from BOPCol is protected; + +end PaveBlock; + diff --git a/src/BOPDS/BOPDS_PaveBlock.cxx b/src/BOPDS/BOPDS_PaveBlock.cxx new file mode 100644 index 0000000000..fd3fada33c --- /dev/null +++ b/src/BOPDS/BOPDS_PaveBlock.cxx @@ -0,0 +1,460 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#include +#include +#include +#include + + +#ifdef WNT +#pragma warning ( disable : 4291 ) +#endif + +static + void SortShell(const int n, BOPDS_Pave *a); + +//======================================================================= +//function : +//purpose : +//======================================================================= + BOPDS_PaveBlock::BOPDS_PaveBlock() +: + myAllocator(NCollection_BaseAllocator::CommonBaseAllocator()), + myExtPaves(myAllocator) +{ + myEdge=-1; + myOriginalEdge=-1; + myTS1=-99.; + myTS2=myTS1; +} +//======================================================================= +//function : +//purpose : +//======================================================================= + BOPDS_PaveBlock::BOPDS_PaveBlock(const Handle(NCollection_BaseAllocator)& theAllocator) +: + myAllocator(theAllocator), + myExtPaves(theAllocator), + myMFence(100, theAllocator) +{ + myEdge=-1; + myOriginalEdge=-1; + myTS1=-99.; + myTS2=myTS1; +} + +//======================================================================= +//function : SetEdge +//purpose : +//======================================================================= + void BOPDS_PaveBlock::SetEdge(const Standard_Integer theEdge) +{ + myEdge=theEdge; +} +//======================================================================= +//function : Edge +//purpose : +//======================================================================= + Standard_Integer BOPDS_PaveBlock::Edge()const +{ + return myEdge; +} +//======================================================================= +//function : HasEdge +//purpose : +//======================================================================= + Standard_Boolean BOPDS_PaveBlock::HasEdge()const +{ + return (myEdge>=0); +} +//======================================================================= +//function : HasEdge +//purpose : +//======================================================================= + Standard_Boolean BOPDS_PaveBlock::HasEdge(Standard_Integer& theEdge)const +{ + theEdge=myEdge; + return (myEdge>=0); +} + +//======================================================================= +//function : SetOriginalEdge +//purpose : +//======================================================================= + void BOPDS_PaveBlock::SetOriginalEdge(const Standard_Integer theEdge) +{ + myOriginalEdge=theEdge; +} +//======================================================================= +//function : OriginalEdge +//purpose : +//======================================================================= + Standard_Integer BOPDS_PaveBlock::OriginalEdge()const +{ + return myOriginalEdge; +} +//======================================================================= +//function : IsSplitEdge +//purpose : +//======================================================================= + Standard_Boolean BOPDS_PaveBlock::IsSplitEdge()const +{ + return (myEdge!=myOriginalEdge); +} +//======================================================================= +//function : SetPave1 +//purpose : +//======================================================================= + void BOPDS_PaveBlock::SetPave1(const BOPDS_Pave& thePave) +{ + myPave1=thePave; +} +//======================================================================= +//function : Pave1 +//purpose : +//======================================================================= + const BOPDS_Pave& BOPDS_PaveBlock::Pave1()const +{ + return myPave1; +} +//======================================================================= +//function : SetPave2 +//purpose : +//======================================================================= + void BOPDS_PaveBlock::SetPave2(const BOPDS_Pave& thePave) +{ + myPave2=thePave; +} +//======================================================================= +//function : Pave2 +//purpose : +//======================================================================= + const BOPDS_Pave& BOPDS_PaveBlock::Pave2()const +{ + return myPave2; +} +//======================================================================= +//function : Range +//purpose : +//======================================================================= + void BOPDS_PaveBlock::Range(Standard_Real& theT1, + Standard_Real& theT2)const +{ + theT1=myPave1.Parameter(); + theT2=myPave2.Parameter(); +} +//======================================================================= +//function : Indices +//purpose : +//======================================================================= + void BOPDS_PaveBlock::Indices(Standard_Integer& theIndex1, + Standard_Integer& theIndex2)const +{ + theIndex1=myPave1.Index(); + theIndex2=myPave2.Index(); +} +//======================================================================= +//function : HasSameBounds +//purpose : +//======================================================================= + Standard_Boolean BOPDS_PaveBlock::HasSameBounds(const Handle(BOPDS_PaveBlock)& theOther)const +{ + Standard_Boolean bFlag1, bFlag2; + Standard_Integer n11, n12, n21, n22; + // + Indices(n11, n12); + theOther->Indices(n21, n22); + // + bFlag1=(n11==n21) && (n12==n22); + bFlag2=(n11==n22) && (n12==n21); + // + return (bFlag1 || bFlag2); +} + + +// +// Extras +// +//======================================================================= +//function : AppendExtPave +//purpose : +//======================================================================= + void BOPDS_PaveBlock::AppendExtPave(const BOPDS_Pave& thePave) +{ + if (myMFence.Add(thePave.Index())) { + myExtPaves.Append(thePave); + } +} +//======================================================================= +//function : AppendExtPave1 +//purpose : +//======================================================================= + void BOPDS_PaveBlock::AppendExtPave1(const BOPDS_Pave& thePave) +{ + myExtPaves.Append(thePave); +} +//======================================================================= +//function : ExtPaves +//purpose : +//======================================================================= + const BOPDS_ListOfPave& BOPDS_PaveBlock::ExtPaves()const +{ + return myExtPaves; +} +//modified by NIZHNY-EMV Thu Aug 11 13:36:53 2011 +//======================================================================= +//function : ChangeExtPaves +//purpose : +//======================================================================= + BOPDS_ListOfPave& BOPDS_PaveBlock::ChangeExtPaves() +{ + return myExtPaves; +} +//modified by NIZHNY-EMV Thu Aug 11 13:36:55 2011 +//======================================================================= +//function : IsToUpdate +//purpose : +//======================================================================= + Standard_Boolean BOPDS_PaveBlock::IsToUpdate()const +{ + return !myExtPaves.IsEmpty(); +} +//======================================================================= +//function : ContainsParameter +//purpose : +//======================================================================= + Standard_Boolean BOPDS_PaveBlock::ContainsParameter(const Standard_Real theT, + const Standard_Real theTol)const +{ + Standard_Boolean bRet; + Standard_Real dT; + BOPDS_ListIteratorOfListOfPave aIt; + // + bRet=Standard_False; + aIt.Initialize(myExtPaves); + for (; aIt.More(); aIt.Next()) { + dT=aIt.Value().Parameter()-theT; + if (dT<0.) { + dT=-dT; + } + if (dTAllocate(aNb*sizeof(BOPDS_Pave)); + for (i=0; iSetOriginalEdge(myOriginalEdge); + aPB->SetPave1(aPave1); + aPB->SetPave2(aPave2); + // + theLPB.Append(aPB); + // + aPave1=aPave2; + } + // + for (i=0; iFree((Standard_Address&)pPaves); +} + +//======================================================================= +// function: SortShell +// purpose : +//======================================================================= +void SortShell(const int n, BOPDS_Pave *a) +{ + int nd, i, j, l, d=1; + BOPDS_Pave x; + // + while(d<=n) { + d*=2; + } + // + while (d) { + d=(d-1)/2; + // + nd=n-d; + for (i=0; i -1) goto m30; + }//if (a[l] < a[j]){ + }//for (i=0; iPaveBlocks().Extent()>1); + } + return Standard_False; +} +//======================================================================= +//function : RealPaveBlock +//purpose : +//======================================================================= + const Handle(BOPDS_PaveBlock)& BOPDS_PaveBlock::RealPaveBlock()const +{ + if (IsCommonBlock()) { + const Handle(BOPDS_PaveBlock)& aPB1=myCommonBlock->PaveBlock1(); + return aPB1; + } + // + Handle_BOPDS_PaveBlock* pPB=(Handle_BOPDS_PaveBlock*)&myPB; + *pPB=this; + return myPB; +} +// ShrunkData +//======================================================================= +//function : HasShrunkData +//purpose : +//======================================================================= + Standard_Boolean BOPDS_PaveBlock::HasShrunkData()const +{ + return (!myShrunkBox.IsVoid()); +} +//======================================================================= +//function : SetShrunkData +//purpose : +//======================================================================= + void BOPDS_PaveBlock::SetShrunkData(const Standard_Real theT1, + const Standard_Real theT2, + const Bnd_Box& theBox) +{ + myTS1=theT1; + myTS2=theT2; + myShrunkBox=theBox; +} +//======================================================================= +//function : ShrunkData +//purpose : +//======================================================================= + void BOPDS_PaveBlock::ShrunkData(Standard_Real& theT1, + Standard_Real& theT2, + Bnd_Box& theBox)const +{ + theT1=myTS1; + theT2=myTS2; + theBox=myShrunkBox; +} +//======================================================================= +//function : Dump +//purpose : +//======================================================================= + void BOPDS_PaveBlock::Dump()const +{ + printf(" PB:{ E:%d orE:%d", myEdge, myOriginalEdge); + printf(" Pave1:"); + myPave1.Dump(); + printf(" Pave2:"); + myPave2.Dump(); + printf(" }"); +} + diff --git a/src/BOPDS/BOPDS_PaveMapHasher.cdl b/src/BOPDS/BOPDS_PaveMapHasher.cdl new file mode 100644 index 0000000000..7f0915a338 --- /dev/null +++ b/src/BOPDS/BOPDS_PaveMapHasher.cdl @@ -0,0 +1,41 @@ +-- Created by: Eugeny MALTCHIKOV +-- Copyright (c) 1999-2012 OPEN CASCADE SAS +-- +-- The content of this file is subject to the Open CASCADE Technology Public +-- License Version 6.5 (the "License"). You may not use the content of this file +-- except in compliance with the License. Please obtain a copy of the License +-- at http://www.opencascade.org and read it completely before using this file. +-- +-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +-- +-- The Original Code and all software distributed under the License is +-- distributed on an "AS IS" basis, without warranty of any kind, and the +-- Initial Developer hereby disclaims all such warranties, including without +-- limitation, any warranties of merchantability, fitness for a particular +-- purpose or non-infringement. Please see the License for the specific terms +-- and conditions governing the rights and limitations under the License. + +class PaveMapHasher from BOPDS + +---Purpose: + +uses + Pave from BOPDS + +--raises + +is + HashCode(myclass; + aPave : Pave from BOPDS; + Upper : Integer from Standard) + returns Integer from Standard; + ---C++: inline + + IsEqual(myclass; + aPave1 : Pave from BOPDS; + aPave2 : Pave from BOPDS) + returns Boolean from Standard; + ---C++: inline + +end PaveMapHasher; diff --git a/src/BOPDS/BOPDS_PaveMapHasher.cxx b/src/BOPDS/BOPDS_PaveMapHasher.cxx new file mode 100644 index 0000000000..072d1c5325 --- /dev/null +++ b/src/BOPDS/BOPDS_PaveMapHasher.cxx @@ -0,0 +1,20 @@ +// Created by: Eugeny MALTCHIKOV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + +#include + diff --git a/src/BOPDS/BOPDS_PaveMapHasher.lxx b/src/BOPDS/BOPDS_PaveMapHasher.lxx new file mode 100644 index 0000000000..add7c36379 --- /dev/null +++ b/src/BOPDS/BOPDS_PaveMapHasher.lxx @@ -0,0 +1,40 @@ +// Created by: Eugeny MALTCHIKOV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + +#include + +//======================================================================= +//function : HashCode +//purpose : +//======================================================================= +inline + Standard_Integer BOPDS_PaveMapHasher::HashCode(const BOPDS_Pave& aPave, + const Standard_Integer Upper) +{ + return ::HashCode(aPave.Index(), Upper); +} +//======================================================================= +//function :IsEqual +//purpose : +//======================================================================= +inline + Standard_Boolean BOPDS_PaveMapHasher::IsEqual(const BOPDS_Pave& aPave1, + const BOPDS_Pave& aPave2) +{ + return aPave1.IsEqual(aPave2); +} diff --git a/src/BOPDS/BOPDS_Point.cdl b/src/BOPDS/BOPDS_Point.cdl new file mode 100644 index 0000000000..ecf651591e --- /dev/null +++ b/src/BOPDS/BOPDS_Point.cdl @@ -0,0 +1,103 @@ +-- Created by: Peter KURNEV +-- Copyright (c) 1999-2012 OPEN CASCADE SAS +-- +-- The content of this file is subject to the Open CASCADE Technology Public +-- License Version 6.5 (the "License"). You may not use the content of this file +-- except in compliance with the License. Please obtain a copy of the License +-- at http://www.opencascade.org and read it completely before using this file. +-- +-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +-- +-- The Original Code and all software distributed under the License is +-- distributed on an "AS IS" basis, without warranty of any kind, and the +-- Initial Developer hereby disclaims all such warranties, including without +-- limitation, any warranties of merchantability, fitness for a particular +-- purpose or non-infringement. Please see the License for the specific terms +-- and conditions governing the rights and limitations under the License. + + +class Point from BOPDS + + ---Purpose: + -- The class BOPDS_Point is to store + -- the information about intersection point +uses + Pnt from gp, + Pnt2d from gp + +--raises + +is + Create + returns Point from BOPDS; + ---C++: alias "virtual ~BOPDS_Point();" + ---C++: inline + ---Purpose: + --- Empty contructor + --- + + SetPnt(me:out; + thePnt:Pnt from gp); + ---C++: inline + ---Purpose: + --- Modifier + --- Sets 3D point + + Pnt(me) + returns Pnt from gp; + ---C++: return const & + ---C++: inline + ---Purpose: + --- Selector + --- Returns 3D point + + SetPnt2D1(me:out; + thePnt:Pnt2d from gp); + ---C++: inline + ---Purpose: + --- Modifier + --- Sets 2D point on the first face + + Pnt2D1(me) + returns Pnt2d from gp; + ---C++: return const & + ---C++: inline + ---Purpose: + --- Selector + --- Returns 2D point on the first face + SetPnt2D2(me:out; + thePnt:Pnt2d from gp); + ---C++: inline + ---Purpose: + --- Modifier + --- Sets 2D point on the second face + + Pnt2D2(me) + returns Pnt2d from gp; + ---C++: return const & + ---C++: inline + ---Purpose: + --- Selector + --- Returns 2D point on the second face + + SetIndex(me:out; + theIndex: Integer from Standard); + ---C++: inline + ---Purpose: + --- Modifier + --- Sets the index of the vertex + Index(me) + returns Integer from Standard; + ---C++: inline + ---Purpose: + --- Selector + --- Returns index of the vertex + +fields + myPnt :Pnt from gp is protected; + myPnt2D1:Pnt2d from gp is protected; + myPnt2D2:Pnt2d from gp is protected; + myIndex : Integer from Standard is protected; + +end Point; diff --git a/src/BOPDS/BOPDS_Point.cxx b/src/BOPDS/BOPDS_Point.cxx new file mode 100644 index 0000000000..d4c80dd7ff --- /dev/null +++ b/src/BOPDS/BOPDS_Point.cxx @@ -0,0 +1,20 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#include diff --git a/src/BOPDS/BOPDS_Point.lxx b/src/BOPDS/BOPDS_Point.lxx new file mode 100644 index 0000000000..2d075c05be --- /dev/null +++ b/src/BOPDS/BOPDS_Point.lxx @@ -0,0 +1,100 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + +//======================================================================= +//function : +//purpose : +//======================================================================= + inline BOPDS_Point::BOPDS_Point() +{ + myPnt.SetCoord(99.,99.,99.); + myPnt2D1.SetCoord(99.,99.); + myPnt2D2=myPnt2D1; + myIndex=-1; +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= + inline BOPDS_Point::~BOPDS_Point() +{ +} +//======================================================================= +//function : SetIndex +//purpose : +//======================================================================= + inline void BOPDS_Point::SetIndex(const Standard_Integer theIndex) +{ + myIndex=theIndex; +} +//======================================================================= +//function : Index +//purpose : +//======================================================================= + inline Standard_Integer BOPDS_Point::Index()const +{ + return myIndex; +} +//======================================================================= +//function : SetPnt +//purpose : +//======================================================================= + inline void BOPDS_Point::SetPnt(const gp_Pnt& thePnt) +{ + myPnt=thePnt; +} +//======================================================================= +//function : Pnt +//purpose : +//======================================================================= + inline const gp_Pnt& BOPDS_Point::Pnt()const +{ + return myPnt; +} +//======================================================================= +//function : SetPnt2D1 +//purpose : +//======================================================================= + inline void BOPDS_Point::SetPnt2D1(const gp_Pnt2d& thePnt) +{ + myPnt2D1=thePnt; +} +//======================================================================= +//function : Pnt2D1 +//purpose : +//======================================================================= + inline const gp_Pnt2d& BOPDS_Point::Pnt2D1()const +{ + return myPnt2D1; +} +//======================================================================= +//function : SetPnt2D2 +//purpose : +//======================================================================= + inline void BOPDS_Point::SetPnt2D2(const gp_Pnt2d& thePnt) +{ + myPnt2D2=thePnt; +} +//======================================================================= +//function : Pnt2D2 +//purpose : +//======================================================================= + inline const gp_Pnt2d& BOPDS_Point::Pnt2D2()const +{ + return myPnt2D2; +} diff --git a/src/BOPDS/BOPDS_ShapeInfo.cdl b/src/BOPDS/BOPDS_ShapeInfo.cdl new file mode 100644 index 0000000000..69ae252cf1 --- /dev/null +++ b/src/BOPDS/BOPDS_ShapeInfo.cdl @@ -0,0 +1,193 @@ +-- Created by: Peter KURNEV +-- Copyright (c) 1999-2012 OPEN CASCADE SAS +-- +-- The content of this file is subject to the Open CASCADE Technology Public +-- License Version 6.5 (the "License"). You may not use the content of this file +-- except in compliance with the License. Please obtain a copy of the License +-- at http://www.opencascade.org and read it completely before using this file. +-- +-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +-- +-- The Original Code and all software distributed under the License is +-- distributed on an "AS IS" basis, without warranty of any kind, and the +-- Initial Developer hereby disclaims all such warranties, including without +-- limitation, any warranties of merchantability, fitness for a particular +-- purpose or non-infringement. Please see the License for the specific terms +-- and conditions governing the rights and limitations under the License. + + +class ShapeInfo from BOPDS + + ---Purpose: + -- The class BOPDS_ShapeInfo is to store + -- handy information about shape +uses + Box from Bnd, + Shape from TopoDS, + BaseAllocator from BOPCol, + ListOfInteger from BOPCol, + ShapeEnum from TopAbs + +--raises + +is + Create + returns ShapeInfo from BOPDS; + ---C++: alias "virtual ~BOPDS_ShapeInfo();" + ---C++: inline + ---Purpose: + --- Empty contructor + --- + Create (theAllocator: BaseAllocator from BOPCol) + returns ShapeInfo from BOPDS; + ---C++: inline + ---Purpose: + --- Contructor + --- theAllocator - the allocator to manage the memory + --- + SetShape(me:out; + theS: Shape from TopoDS); + ---C++: inline + ---Purpose: + --- Modifier + --- Sets the shape + Shape(me) + returns Shape from TopoDS; + ---C++: return const & + ---C++: inline + ---Purpose: + --- Selector + --- Returns the shape + + SetShapeType(me:out; + theType: ShapeEnum from TopAbs); + ---C++: inline + ---Purpose: + --- Modifier + --- Sets the type of shape theType + + ShapeType(me) + returns ShapeEnum from TopAbs; + ---C++: inline + ---Purpose: + --- Selector + --- Returns the type of shape + + SetBox(me:out; + theBox:Box from Bnd); + ---C++: inline + ---Purpose: + --- Modifier + --- Sets the boundung box of the shape theBox + + + Box(me) + returns Box from Bnd; + ---C++: return const & + ---C++: inline + ---Purpose: + --- Selector + --- Returns the boundung box of the shape + + ChangeBox(me:out) + returns Box from Bnd; + ---C++: return & + ---C++: inline + ---Purpose: + --- Selector/Modifier + --- Returns the boundung box of the shape + + SubShapes(me) + returns ListOfInteger from BOPCol; + ---C++: return const & + ---C++: inline + ---Purpose: + --- Selector + --- Returns the list of indices of sub-shapes + + ChangeSubShapes(me:out) + returns ListOfInteger from BOPCol; + ---C++: return & + ---C++: inline + ---Purpose: + --- Selector/ Modifier + --- Returns the list of indices of sub-shapes + + HasSubShape(me; + theI:Integer from Standard) + returns Boolean from Standard; + ---C++: inline + ---Purpose: + --- Query + --- Returns true if the shape has sub-shape with + --- index theI + + HasReference(me) + returns Boolean from Standard; + ---C++: inline + --- Query + --- Returns true if the shape has a reference information + + SetReference(me:out; + theI: Integer from Standard); + ---C++: inline + ---Purpose: + --- Modifier + --- Sets the index of a reference information + + Reference(me) + returns Integer from Standard; + ---C++: inline + ---Purpose: + --- Selector + --- Returns the index of a reference information + + HasBRep(me) + returns Boolean from Standard; + ---C++: inline + ---Purpose: + --- Query + --- Returns true if the shape has boundary representation + -- + --- Flag + -- + HasFlag(me) + returns Boolean from Standard; + ---C++: inline + ---Purpose: + --- Query + --- Returns true if there is flag. + + HasFlag(me; + theFlag:out Integer from Standard) + returns Boolean from Standard; + ---C++: inline + ---Purpose: + --- Query + --- Returns true if there is flag. + --- Returns the the flag theFlag + + SetFlag(me:out; + theI:Integer from Standard); + ---C++: inline + ---Purpose: + --- Modifier + --- Sets the flag + Flag(me) + returns Integer from Standard; + ---C++: inline + ---Purpose: + --- Returns the flag + + Dump(me); + +fields + myShape : Shape from TopoDS is protected; + myType : ShapeEnum from TopAbs is protected; + myBox : Box from Bnd is protected; + mySubShapes: ListOfInteger from BOPCol is protected; + myReference: Integer from Standard is protected; + myFlag : Integer from Standard is protected; + +end ShapeInfo; diff --git a/src/BOPDS/BOPDS_ShapeInfo.cxx b/src/BOPDS/BOPDS_ShapeInfo.cxx new file mode 100644 index 0000000000..316509a5b6 --- /dev/null +++ b/src/BOPDS/BOPDS_ShapeInfo.cxx @@ -0,0 +1,67 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#include + +#include +#include + +static + void DumpType(const TopAbs_ShapeEnum aTS); + +//======================================================================= +//function : Dump +//purpose : +//======================================================================= + void BOPDS_ShapeInfo::Dump()const +{ + Standard_Integer n; + TopAbs_ShapeEnum aTS; + BOPCol_ListIteratorOfListOfInteger aIt; + // + aTS=ShapeType(); + DumpType(aTS); + // + printf(" {"); + aIt.Initialize(mySubShapes); + for (; aIt.More(); aIt.Next()) { + n=aIt.Value(); + printf(" %d", n); + } + printf(" }"); +} +//======================================================================= +//function : DumpType +//purpose : +//======================================================================= +void DumpType(const TopAbs_ShapeEnum aTS) +{ + const char *pT[]={ + "COMPOUND", + "COMPSOLID", + "SOLID", + "SHELL", + "FACE", + "WIRE", + "EDGE", + "VERTEX", + "SHAPE" + }; + printf(" %s", pT[(int)aTS]); +} diff --git a/src/BOPDS/BOPDS_ShapeInfo.lxx b/src/BOPDS/BOPDS_ShapeInfo.lxx new file mode 100644 index 0000000000..d4cbb3fd8d --- /dev/null +++ b/src/BOPDS/BOPDS_ShapeInfo.lxx @@ -0,0 +1,208 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + +//======================================================================= +//function : +//purpose : +//======================================================================= + inline BOPDS_ShapeInfo::BOPDS_ShapeInfo() +: + + myType(TopAbs_SHAPE), + myReference(-1), + myFlag(-1) +{ +} +//======================================================================= +//function : +//purpose : +//======================================================================= + inline BOPDS_ShapeInfo::BOPDS_ShapeInfo(const Handle(NCollection_BaseAllocator)& theAllocator) +: + mySubShapes(theAllocator), + myType(TopAbs_SHAPE), + myReference(-1), + myFlag(-1) +{ +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= + inline BOPDS_ShapeInfo::~BOPDS_ShapeInfo() +{ +} +//======================================================================= +//function : SetShape +//purpose : +//======================================================================= + inline void BOPDS_ShapeInfo::SetShape(const TopoDS_Shape& theS) +{ + myShape=theS; +} +//======================================================================= +//function : Shape +//purpose : +//======================================================================= + inline const TopoDS_Shape& BOPDS_ShapeInfo::Shape()const +{ + return myShape; +} +//======================================================================= +//function : SetShapeType +//purpose : +//======================================================================= + inline void BOPDS_ShapeInfo::SetShapeType(const TopAbs_ShapeEnum theType) +{ + myType=theType; +} +//======================================================================= +//function : ShapeType +//purpose : +//======================================================================= + inline TopAbs_ShapeEnum BOPDS_ShapeInfo::ShapeType()const +{ + return myType; +} +//======================================================================= +//function : SetBox +//purpose : +//======================================================================= + inline void BOPDS_ShapeInfo::SetBox(const Bnd_Box& theBox) +{ + myBox=theBox; +} +//======================================================================= +//function : Box +//purpose : +//======================================================================= + inline const Bnd_Box& BOPDS_ShapeInfo::Box()const +{ + return myBox; +} +//======================================================================= +//function : ChangeBox +//purpose : +//======================================================================= + inline Bnd_Box& BOPDS_ShapeInfo::ChangeBox() +{ + return myBox; +} + +//======================================================================= +//function : SubShapes +//purpose : +//======================================================================= + inline const BOPCol_ListOfInteger& BOPDS_ShapeInfo::SubShapes()const +{ + return mySubShapes; +} +//======================================================================= +//function : ChangeSubShapes +//purpose : +//======================================================================= + inline BOPCol_ListOfInteger& BOPDS_ShapeInfo::ChangeSubShapes() +{ + return mySubShapes; +} +//======================================================================= +//function : HasSubShape +//purpose : +//======================================================================= + inline Standard_Boolean BOPDS_ShapeInfo::HasSubShape(const Standard_Integer theI)const +{ + Standard_Boolean bRet; + BOPCol_ListIteratorOfListOfInteger aIt; + // + bRet=Standard_False; + aIt.Initialize(mySubShapes); + for (; aIt.More(); aIt.Next()) { + bRet=(theI==aIt.Value()); + if (bRet) { + return bRet; + } + } + return bRet; +} +//======================================================================= +//function : HasReference +//purpose : +//======================================================================= + inline Standard_Boolean BOPDS_ShapeInfo::HasReference()const +{ + return (myReference>=0); +} +//======================================================================= +//function : SetReference +//purpose : +//======================================================================= + inline void BOPDS_ShapeInfo::SetReference(const Standard_Integer theI) +{ + myReference=theI; +} +//======================================================================= +//function : Reference +//purpose : +//======================================================================= + inline Standard_Integer BOPDS_ShapeInfo::Reference()const +{ + return myReference; +} +//======================================================================= +//function : HasBRep +//purpose : +//======================================================================= + inline Standard_Boolean BOPDS_ShapeInfo::HasBRep()const +{ + return (myType==TopAbs_VERTEX || + myType==TopAbs_EDGE || + myType==TopAbs_FACE); +} +//======================================================================= +//function : HasFlag +//purpose : +//======================================================================= + inline Standard_Boolean BOPDS_ShapeInfo::HasFlag()const +{ + return (myFlag>=0); +} +//======================================================================= +//function : HasFlag +//purpose : +//======================================================================= + inline Standard_Boolean BOPDS_ShapeInfo::HasFlag(Standard_Integer& theFlag)const +{ + theFlag=myFlag; + return (myFlag>=0); +} +//======================================================================= +//function : SetFlag +//purpose : +//======================================================================= + inline void BOPDS_ShapeInfo::SetFlag(const Standard_Integer theFlag) +{ + myFlag=theFlag; +} +//======================================================================= +//function : Flag +//purpose : +//======================================================================= + inline Standard_Integer BOPDS_ShapeInfo::Flag()const +{ + return myFlag; +} diff --git a/src/BOPDS/BOPDS_SubIterator.cdl b/src/BOPDS/BOPDS_SubIterator.cdl new file mode 100644 index 0000000000..1f80d94368 --- /dev/null +++ b/src/BOPDS/BOPDS_SubIterator.cdl @@ -0,0 +1,138 @@ +-- Created by: Peter KURNEV +-- Copyright (c) 1999-2012 OPEN CASCADE SAS +-- +-- The content of this file is subject to the Open CASCADE Technology Public +-- License Version 6.5 (the "License"). You may not use the content of this file +-- except in compliance with the License. Please obtain a copy of the License +-- at http://www.opencascade.org and read it completely before using this file. +-- +-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +-- +-- The Original Code and all software distributed under the License is +-- distributed on an "AS IS" basis, without warranty of any kind, and the +-- Initial Developer hereby disclaims all such warranties, including without +-- limitation, any warranties of merchantability, fitness for a particular +-- purpose or non-infringement. Please see the License for the specific terms +-- and conditions governing the rights and limitations under the License. + +class SubIterator from BOPDS + + ---Purpose: + -- The class BOPDS_SubIterator is + -- 1.to compute intersections between two sub-sets of + -- BRep sub-shapes + -- of arguments of an operation (see the class BOPDS_DS) + -- in terms of theirs bounding boxes + -- 2.provides interface to iterare the pairs of + -- intersected sub-shapes of given type + +uses + ShapeEnum from TopAbs, + BaseAllocator from BOPCol, + ListOfInteger from BOPCol, + PListOfInteger from BOPCol, + DS from BOPDS, + PDS from BOPDS, + PassKeyBoolean from BOPDS, + ListOfPassKeyBoolean from BOPDS, + ListIteratorOfListOfPassKeyBoolean from BOPDS, + VectorOfListOfPassKeyBoolean from BOPDS + + +--raises + +is + Create + returns SubIterator from BOPDS; + ---C++: alias "Standard_EXPORT virtual ~BOPDS_SubIterator();" + ---Purpose: + --- Empty contructor + --- + + Create (theAllocator: BaseAllocator from BOPCol) + returns SubIterator from BOPDS; + ---Purpose: + --- Contructor + --- theAllocator - the allocator to manage the memory + --- + + SetDS(me:out; + pDS:PDS from BOPDS); + ---Purpose: + --- Modifier + --- Sets the data structure to process + + DS(me) + returns DS from BOPDS; + ---C++:return const & + ---Purpose: + --- Selector + --- Returns the data structure + + SetSubSet1(me:out; + theLI:ListOfInteger from BOPCol); + ---Purpose: + --- Modifier + --- Sets the first set of indices to process + + SubSet1(me) + returns ListOfInteger from BOPCol; + ---C++:return const & + ---Purpose: + --- Selector + --- Returns the first set of indices to process + + SetSubSet2(me:out; + theLI:ListOfInteger from BOPCol); + ---Purpose: + --- Modifier + --- Sets the second set of indices to process + SubSet2(me) + returns ListOfInteger from BOPCol; + ---C++:return const & + ---Purpose: + --- Selector + --- Returns the second set of indices to process + + Initialize(me:out); + ---Purpose: + --- Initializes the iterator + + More(me) + returns Boolean from Standard; + ---Purpose: + --- Returns true if still there are pairs + -- of intersected shapes + + Next(me:out); + ---Purpose: + --- Moves iterations ahead + + Value(me; + theIndex1:out Integer from Standard; + theIndex2:out Integer from Standard); + ---Purpose: + --- Returns indices (DS) of intersected shapes + --- theIndex1 - the index of the first shape + --- theIndex2 - the index of the second shape + + Prepare(me:out) + is virtual; + ---Purpose: + --- Perform the intersection algorithm and prepare + --- the results to be used + + Intersect(me:out) + is virtual protected; + + +fields + myAllocator: BaseAllocator from BOPCol is protected; + myDS : PDS from BOPDS is protected; + myList : ListOfPassKeyBoolean from BOPDS is protected; + myIterator : ListIteratorOfListOfPassKeyBoolean from BOPDS is protected; + mySubSet1 : PListOfInteger from BOPCol is protected; + mySubSet2 : PListOfInteger from BOPCol is protected; + +end SubIterator; diff --git a/src/BOPDS/BOPDS_SubIterator.cxx b/src/BOPDS/BOPDS_SubIterator.cxx new file mode 100644 index 0000000000..e10c1fe634 --- /dev/null +++ b/src/BOPDS/BOPDS_SubIterator.cxx @@ -0,0 +1,264 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#include +// +#include +// +#include +#include +// +#include +#include +#include +// +#include +#include +#include +#include +// +#include +#include +#include +#include +#include +#include + +//======================================================================= +//function : +//purpose : +//======================================================================= + BOPDS_SubIterator::BOPDS_SubIterator() +: + myAllocator(NCollection_BaseAllocator::CommonBaseAllocator()), + myList(myAllocator) +{ + myDS=NULL; +} +//======================================================================= +//function : +//purpose : +//======================================================================= + BOPDS_SubIterator::BOPDS_SubIterator(const Handle(NCollection_BaseAllocator)& theAllocator) +: + myAllocator(theAllocator), + myList(myAllocator) +{ + myDS=NULL; +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= + BOPDS_SubIterator::~BOPDS_SubIterator() +{ +} +//======================================================================= +// function: SetDS +// purpose: +//======================================================================= + void BOPDS_SubIterator::SetDS(const BOPDS_PDS& aDS) +{ + myDS=aDS; +} +//======================================================================= +// function: DS +// purpose: +//======================================================================= + const BOPDS_DS& BOPDS_SubIterator::DS()const +{ + return *myDS; +} +//======================================================================= +//function : SetSubSet1 +//purpose : +//======================================================================= + void BOPDS_SubIterator::SetSubSet1(const BOPCol_ListOfInteger& theLI) +{ + mySubSet1=(BOPCol_PListOfInteger)&theLI; +} +//======================================================================= +//function : SubSet1 +//purpose : +//======================================================================= + const BOPCol_ListOfInteger& BOPDS_SubIterator::SubSet1()const +{ + return *mySubSet1; +} +//======================================================================= +//function : SetSubSet2 +//purpose : +//======================================================================= + void BOPDS_SubIterator::SetSubSet2(const BOPCol_ListOfInteger& theLI) +{ + mySubSet2=(BOPCol_PListOfInteger)&theLI; +} +//======================================================================= +//function : SubSet2 +//purpose : +//======================================================================= + const BOPCol_ListOfInteger& BOPDS_SubIterator::SubSet2()const +{ + return *mySubSet2; +} +//======================================================================= +// function: Initialize +// purpose: +//======================================================================= + void BOPDS_SubIterator::Initialize() +{ + myIterator.Initialize(myList); +} +//======================================================================= +// function: More +// purpose: +//======================================================================= + Standard_Boolean BOPDS_SubIterator::More()const +{ + return myIterator.More(); +} +//======================================================================= +// function: Next +// purpose: +//======================================================================= + void BOPDS_SubIterator::Next() +{ + myIterator.Next(); +} +//======================================================================= +// function: Value +// purpose: +//======================================================================= + void BOPDS_SubIterator::Value(Standard_Integer& theI1, + Standard_Integer& theI2) const +{ + Standard_Integer iT1, iT2, n1, n2; + // + const BOPDS_PassKeyBoolean& aPKB=myIterator.Value(); + aPKB.Ids(n1, n2); + // + iT1=(Standard_Integer)(myDS->ShapeInfo(n1).ShapeType()); + iT2=(Standard_Integer)(myDS->ShapeInfo(n2).ShapeType()); + // + theI1=n1; + theI2=n2; + if (iT1Extent() || !mySubSet2->Extent()) { + return; + } + Intersect(); +} +//======================================================================= +// function: Intersect +// purpose: +//======================================================================= + void BOPDS_SubIterator::Intersect() +{ + Standard_Integer i, aNbB, aNbSD, j, iDS, jB; + Handle(NCollection_IncAllocator) aAllocator; + BOPCol_ListIteratorOfListOfInteger aIt, aIt1, aIt2; + BOPDS_PassKeyBoolean aPKXB; + // + //-----------------------------------------------------scope_1 f + aAllocator=new NCollection_IncAllocator(); + // + BOPCol_DataMapOfShapeInteger aMSI(100, aAllocator); + BOPCol_DataMapOfIntegerInteger aMII(100, aAllocator); + BOPDS_MapOfPassKeyBoolean aMPKXB(100, aAllocator); + BOPCol_IndexedDataMapOfShapeBox aMSB(100, aAllocator); + // + BOPDS_BoxBndTreeSelector aSelector; + BOPDS_BoxBndTree aBBTree; + NCollection_UBTreeFiller aTreeFiller(aBBTree); + // + aIt1.Initialize(*mySubSet1); + for (; aIt1.More(); aIt1.Next()) { + i=aIt1.Value(); + const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i); + const TopoDS_Shape& aS=aSI.Shape(); + const Bnd_Box& aBoxEx=aSI.Box(); + aMSI.Bind(aS, i); + aMSB.Add(aS, aBoxEx); + } + // + aNbB=aMSB.Extent(); + for (i=1; i<=aNbB; ++i) { + const TopoDS_Shape& aS=aMSB.FindKey(i); + const Bnd_Box& aBoxEx=aMSB(i); + // + aTreeFiller.Add(i, aBoxEx); + // + iDS=aMSI.Find(aS); + aMII.Bind(i, iDS); + } + // + aTreeFiller.Fill(); + // + aIt2.Initialize(*mySubSet2); + for (; aIt2.More(); aIt2.Next()) { + i=aIt2.Value(); + // + const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i); + const TopoDS_Shape& aSi=aSI.Shape(); + const Bnd_Box& aBoxEx=aSI.Box(); + // + aSelector.Clear(); + aSelector.SetBox(aBoxEx); + aNbSD=aBBTree.Select(aSelector); + if (!aNbSD){ + continue; + } + //const Bnd_Box& aBoxi=myDS->ShapeInfo(i).Box(); + // + const BOPCol_ListOfInteger& aLI=aSelector.Indices(); + aIt.Initialize(aLI); + for (; aIt.More(); aIt.Next()) { + jB=aIt.Value(); // box index in MII + j=aMII.Find(jB); // DS index + // + aPKXB.SetIds(i, j); + if (aMPKXB.Add(aPKXB)) { + myList.Append(aPKXB); + }// if (aMPKXB.Add(aPKXB)) { + }// for (; aIt.More(); aIt.Next()) { + } + // + aMSI.Clear(); + aMII.Clear(); + aMPKXB.Clear(); + aMSB.Clear(); + // + aAllocator.Nullify(); + //-----------------------------------------------------scope_1 t +} diff --git a/src/BOPDS/BOPDS_Tools.cdl b/src/BOPDS/BOPDS_Tools.cdl new file mode 100644 index 0000000000..e3160894b7 --- /dev/null +++ b/src/BOPDS/BOPDS_Tools.cdl @@ -0,0 +1,51 @@ +-- Created by: Peter KURNEV +-- Copyright (c) 1999-2012 OPEN CASCADE SAS +-- +-- The content of this file is subject to the Open CASCADE Technology Public +-- License Version 6.5 (the "License"). You may not use the content of this file +-- except in compliance with the License. Please obtain a copy of the License +-- at http://www.opencascade.org and read it completely before using this file. +-- +-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +-- +-- The Original Code and all software distributed under the License is +-- distributed on an "AS IS" basis, without warranty of any kind, and the +-- Initial Developer hereby disclaims all such warranties, including without +-- limitation, any warranties of merchantability, fitness for a particular +-- purpose or non-infringement. Please see the License for the specific terms +-- and conditions governing the rights and limitations under the License. + + +class Tools from BOPDS + + ---Purpose: + -- The class BOPDS_Tools contains + -- a set auxiliary static functions + -- of the package BOPDS + +uses + ShapeEnum from TopAbs + +--raises + +is + TypeToInteger(myclass; + theT1: ShapeEnum from TopAbs; + theT2: ShapeEnum from TopAbs) + returns Integer from Standard; + ---C++: inline + ---Purpose: + --- Converts the conmbination of two types + -- of shape , + --- to the one integer value, that is returned + + HasBRep(myclass; + theT: ShapeEnum from TopAbs) + returns Boolean from Standard; + ---C++: inline + ---Purpose: + --- Returns true if the type correspond + --- to a shape having boundary representation + +end Tools; diff --git a/src/BOPDS/BOPDS_Tools.cxx b/src/BOPDS/BOPDS_Tools.cxx new file mode 100644 index 0000000000..3f8e1d4adf --- /dev/null +++ b/src/BOPDS/BOPDS_Tools.cxx @@ -0,0 +1,20 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#include diff --git a/src/BOPDS/BOPDS_Tools.lxx b/src/BOPDS/BOPDS_Tools.lxx new file mode 100644 index 0000000000..30657d22ba --- /dev/null +++ b/src/BOPDS/BOPDS_Tools.lxx @@ -0,0 +1,66 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + +//======================================================================= +// function: HasBRep +// purpose: +//======================================================================= + inline Standard_Boolean BOPDS_Tools::HasBRep(const TopAbs_ShapeEnum aTi) +{ + return (aTi==TopAbs_VERTEX || aTi==TopAbs_EDGE || aTi==TopAbs_FACE); +}//======================================================================= +//function : TypeToInteger +//purpose : +//======================================================================= + inline Standard_Integer BOPDS_Tools::TypeToInteger(const TopAbs_ShapeEnum aType1, + const TopAbs_ShapeEnum aType2) +{ + Standard_Integer iRet, iT1, iT2, iX; + // + iRet=-1; + iT1=(Standard_Integer)aType1; + iT2=(Standard_Integer)aType2; + // + iX=iT2*10+iT1; + switch (iX) { + case 77: + iRet=5; // VV + break; + case 76: + case 67: + iRet=4; // VE + break; + case 74: + case 47: + iRet=2; // VF + break; + case 66: + iRet=3; // EE + break; + case 64: + case 46: + iRet=1; // EF + break; + case 44: + iRet=0; // FF + break; + default: + break; + } + return iRet; +} diff --git a/src/BOPDS/BOPDS_VectorOfCurve.hxx b/src/BOPDS/BOPDS_VectorOfCurve.hxx new file mode 100644 index 0000000000..4b4837cc31 --- /dev/null +++ b/src/BOPDS/BOPDS_VectorOfCurve.hxx @@ -0,0 +1,33 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPDS_VectorOfCurve_HeaderFile +#define BOPDS_VectorOfCurve_HeaderFile + +#include +#include + +#define BOPCol_Array1_Use_Allocator + +typedef BOPCol_Array1 BOPDS_VectorOfCurve; + +#undef BOPCol_Array1_Use_Allocator + + +#endif diff --git a/src/BOPDS/BOPDS_VectorOfFaceInfo.hxx b/src/BOPDS/BOPDS_VectorOfFaceInfo.hxx new file mode 100644 index 0000000000..cebe041a1e --- /dev/null +++ b/src/BOPDS/BOPDS_VectorOfFaceInfo.hxx @@ -0,0 +1,32 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPDS_VectorOfFaceInfo_HeaderFile +#define BOPDS_VectorOfFaceInfo_HeaderFile + +#include +#include + +#define BOPCol_Array1_Use_Allocator + +typedef BOPCol_Array1 BOPDS_VectorOfFaceInfo; + +#undef BOPCol_Array1_Use_Allocator + +#endif diff --git a/src/BOPDS/BOPDS_VectorOfIndexRange.hxx b/src/BOPDS/BOPDS_VectorOfIndexRange.hxx new file mode 100644 index 0000000000..8ef5f36e7d --- /dev/null +++ b/src/BOPDS/BOPDS_VectorOfIndexRange.hxx @@ -0,0 +1,28 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPDS_VectorOfIndexRange_HeaderFile +#define BOPDS_VectorOfIndexRange_HeaderFile + +#include +#include + +typedef BOPCol_Array1 BOPDS_VectorOfIndexRange; + +#endif diff --git a/src/BOPDS/BOPDS_VectorOfInterfEE.hxx b/src/BOPDS/BOPDS_VectorOfInterfEE.hxx new file mode 100644 index 0000000000..388c9ebbd7 --- /dev/null +++ b/src/BOPDS/BOPDS_VectorOfInterfEE.hxx @@ -0,0 +1,30 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPDS_VectorOfInterfEE_HeaderFile +#define BOPDS_VectorOfInterfEE_HeaderFile + +#include +#include + +#define BOPCol_Array1_Use_Allocator +typedef BOPCol_Array1 BOPDS_VectorOfInterfEE; +#undef BOPCol_Array1_Use_Allocator + +#endif diff --git a/src/BOPDS/BOPDS_VectorOfInterfEF.hxx b/src/BOPDS/BOPDS_VectorOfInterfEF.hxx new file mode 100644 index 0000000000..481cddb5f8 --- /dev/null +++ b/src/BOPDS/BOPDS_VectorOfInterfEF.hxx @@ -0,0 +1,31 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPDS_VectorOfInterfEF_HeaderFile +#define BOPDS_VectorOfInterfEF_HeaderFile + +#include +#include + +#define BOPCol_Array1_Use_Allocator +typedef BOPCol_Array1 BOPDS_VectorOfInterfEF; +#undef BOPCol_Array1_Use_Allocator + + +#endif diff --git a/src/BOPDS/BOPDS_VectorOfInterfFF.hxx b/src/BOPDS/BOPDS_VectorOfInterfFF.hxx new file mode 100644 index 0000000000..e15a9f340f --- /dev/null +++ b/src/BOPDS/BOPDS_VectorOfInterfFF.hxx @@ -0,0 +1,31 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPDS_VectorOfInterfFF_HeaderFile +#define BOPDS_VectorOfInterfFF_HeaderFile + +#include +#include + +#define BOPCol_Array1_Use_Allocator +typedef BOPCol_Array1 BOPDS_VectorOfInterfFF; +#undef BOPCol_Array1_Use_Allocator + + +#endif diff --git a/src/BOPDS/BOPDS_VectorOfInterfVE.hxx b/src/BOPDS/BOPDS_VectorOfInterfVE.hxx new file mode 100644 index 0000000000..9e4c28add5 --- /dev/null +++ b/src/BOPDS/BOPDS_VectorOfInterfVE.hxx @@ -0,0 +1,30 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPDS_VectorOfInterfVE_HeaderFile +#define BOPDS_VectorOfInterfVE_HeaderFile + +#include +#include + +#define BOPCol_Array1_Use_Allocator +typedef BOPCol_Array1 BOPDS_VectorOfInterfVE; +#undef BOPCol_Array1_Use_Allocator + +#endif diff --git a/src/BOPDS/BOPDS_VectorOfInterfVF.hxx b/src/BOPDS/BOPDS_VectorOfInterfVF.hxx new file mode 100644 index 0000000000..925f5b0339 --- /dev/null +++ b/src/BOPDS/BOPDS_VectorOfInterfVF.hxx @@ -0,0 +1,30 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPDS_VectorOfInterfVF_HeaderFile +#define BOPDS_VectorOfInterfVF_HeaderFile + +#include +#include + +#define BOPCol_Array1_Use_Allocator +typedef BOPCol_Array1 BOPDS_VectorOfInterfVF; +#undef BOPCol_Array1_Use_Allocator + +#endif diff --git a/src/BOPDS/BOPDS_VectorOfInterfVV.hxx b/src/BOPDS/BOPDS_VectorOfInterfVV.hxx new file mode 100644 index 0000000000..ffe844401e --- /dev/null +++ b/src/BOPDS/BOPDS_VectorOfInterfVV.hxx @@ -0,0 +1,30 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPDS_VectorOfInterfVV_HeaderFile +#define BOPDS_VectorOfInterfVV_HeaderFile + +#include +#include + +#define BOPCol_Array1_Use_Allocator +typedef BOPCol_Array1 BOPDS_VectorOfInterfVV; +#undef BOPCol_Array1_Use_Allocator + +#endif diff --git a/src/BOPDS/BOPDS_VectorOfListOfPassKeyBoolean.hxx b/src/BOPDS/BOPDS_VectorOfListOfPassKeyBoolean.hxx new file mode 100644 index 0000000000..60aa5f9693 --- /dev/null +++ b/src/BOPDS/BOPDS_VectorOfListOfPassKeyBoolean.hxx @@ -0,0 +1,32 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPDS_VectorOfListOfPassKeyBoolean_HeaderFile +#define BOPDS_VectorOfListOfPassKeyBoolean_HeaderFile + +#include +#include + +#define BOPCol_Array1_Use_Allocator + +typedef BOPCol_Array1 BOPDS_VectorOfListOfPassKeyBoolean; + +#undef BOPCol_Array1_Use_Allocator + +#endif diff --git a/src/BOPDS/BOPDS_VectorOfListOfPaveBlock.hxx b/src/BOPDS/BOPDS_VectorOfListOfPaveBlock.hxx new file mode 100644 index 0000000000..e01ab37282 --- /dev/null +++ b/src/BOPDS/BOPDS_VectorOfListOfPaveBlock.hxx @@ -0,0 +1,33 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPDS_VectorOfListOfPaveBlock_HeaderFile +#define BOPDS_VectorOfListOfPaveBlock_HeaderFile + +#include +#include +#include + +#define BOPCol_Array1_Use_Allocator + +typedef BOPCol_Array1 BOPDS_VectorOfListOfPaveBlock; + +#undef BOPCol_Array1_Use_Allocator + +#endif diff --git a/src/BOPDS/BOPDS_VectorOfPoint.hxx b/src/BOPDS/BOPDS_VectorOfPoint.hxx new file mode 100644 index 0000000000..7be6615218 --- /dev/null +++ b/src/BOPDS/BOPDS_VectorOfPoint.hxx @@ -0,0 +1,33 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPDS_VectorOfPnt_HeaderFile +#define BOPDS_VectorOfPnt_HeaderFile + +#include +#include + +#define BOPCol_Array1_Use_Allocator + +typedef BOPCol_Array1 BOPDS_VectorOfPoint; + +#undef BOPCol_Array1_Use_Allocator + + +#endif diff --git a/src/BOPDS/BOPDS_VectorOfShapeInfo.hxx b/src/BOPDS/BOPDS_VectorOfShapeInfo.hxx new file mode 100644 index 0000000000..86103bbc83 --- /dev/null +++ b/src/BOPDS/BOPDS_VectorOfShapeInfo.hxx @@ -0,0 +1,32 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPDS_VectorOfShapeInfo_HeaderFile +#define BOPDS_VectorOfShapeInfo_HeaderFile + +#include +#include + +#define BOPCol_Array1_Use_Allocator + +typedef BOPCol_Array1 BOPDS_VectorOfShapeInfo; + +#undef BOPCol_Array1_Use_Allocator + +#endif diff --git a/src/BOPDS/FILES b/src/BOPDS/FILES new file mode 100644 index 0000000000..5b86cddb77 --- /dev/null +++ b/src/BOPDS/FILES @@ -0,0 +1,30 @@ +BOPDS_VectorOfShapeInfo.hxx +BOPDS_VectorOfIndexRange.hxx +BOPDS_ListOfPassKeyBoolean.hxx +BOPDS_BoxBndTree.cxx +BOPDS_BoxBndTree.hxx +BOPDS_MapOfPassKeyBoolean.hxx +BOPDS_MapOfPassKey.hxx +BOPDS_ListIteratorOfListOfPassKeyBoolean.hxx +BOPDS_VectorOfListOfPassKeyBoolean.hxx +BOPDS_ListOfPave.hxx +BOPDS_ListOfPaveBlock.hxx +BOPDS_VectorOfListOfPaveBlock.hxx +BOPDS_VectorOfInterfVV.hxx +BOPDS_VectorOfInterfVE.hxx +BOPDS_VectorOfInterfVF.hxx +BOPDS_VectorOfInterfEE.hxx +BOPDS_VectorOfInterfEF.hxx +BOPDS_VectorOfInterfFF.hxx +BOPDS_Interf.hxx +BOPDS_DataMapOfPaveBlockListOfPaveBlock.hxx +BOPDS_MapOfPaveBlock.hxx +BOPDS_DataMapOfPaveBlockListOfInteger.hxx +BOPDS_DataMapOfPassKeyListOfPaveBlock.hxx +BOPDS_CoupleOfPaveBlocks.hxx +BOPDS_MapOfCommonBlock.hxx +BOPDS_VectorOfFaceInfo.hxx +BOPDS_VectorOfCurve.hxx +BOPDS_VectorOfPoint.hxx +BOPDS_DataMapOfShapeCoupleOfPaveBlocks.hxx +BOPDS_MapOfPave.hxx diff --git a/src/BOPInt/BOPInt.cdl b/src/BOPInt/BOPInt.cdl new file mode 100644 index 0000000000..ba6ff2331b --- /dev/null +++ b/src/BOPInt/BOPInt.cdl @@ -0,0 +1,50 @@ +-- Created by: Peter KURNEV +-- Copyright (c) 1999-2012 OPEN CASCADE SAS +-- +-- The content of this file is subject to the Open CASCADE Technology Public +-- License Version 6.5 (the "License"). You may not use the content of this file +-- except in compliance with the License. Please obtain a copy of the License +-- at http://www.opencascade.org and read it completely before using this file. +-- +-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +-- +-- The Original Code and all software distributed under the License is +-- distributed on an "AS IS" basis, without warranty of any kind, and the +-- Initial Developer hereby disclaims all such warranties, including without +-- limitation, any warranties of merchantability, fitness for a particular +-- purpose or non-infringement. Please see the License for the specific terms +-- and conditions governing the rights and limitations under the License. + + +package BOPInt + + ---Purpose: + +uses + + gp, + Bnd, + TopAbs, + Geom, + GeomAPI, + BRepClass3d, + TopoDS, + TopTools, + IntTools, + -- + BOPCol + +is + -- + -- classes + -- + class Context; + --class Range; + class ShrunkRange; + class Tools; + -- + -- pointers + -- + +end BOPInt; diff --git a/src/BOPInt/BOPInt_Context.cdl b/src/BOPInt/BOPInt_Context.cdl new file mode 100644 index 0000000000..14903bb06b --- /dev/null +++ b/src/BOPInt/BOPInt_Context.cdl @@ -0,0 +1,189 @@ +-- Created by: Peter KURNEV +-- Copyright (c) 1999-2012 OPEN CASCADE SAS +-- +-- The content of this file is subject to the Open CASCADE Technology Public +-- License Version 6.5 (the "License"). You may not use the content of this file +-- except in compliance with the License. Please obtain a copy of the License +-- at http://www.opencascade.org and read it completely before using this file. +-- +-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +-- +-- The Original Code and all software distributed under the License is +-- distributed on an "AS IS" basis, without warranty of any kind, and the +-- Initial Developer hereby disclaims all such warranties, including without +-- limitation, any warranties of merchantability, fitness for a particular +-- purpose or non-infringement. Please see the License for the specific terms +-- and conditions governing the rights and limitations under the License. + + +class Context from BOPInt + inherits TShared from MMgt + + +---Purpose: + -- The intersection Context contains geometrical + -- and topological toolkit (classifiers, projectors, etc). + -- The intersection Context is for caching the tools + -- to increase the performance. + + +uses + + Pnt2d from gp, + Pnt from gp, + State from TopAbs, + Curve from Geom, + ProjectPointOnCurve from GeomAPI, + ProjectPointOnSurf from GeomAPI, + Vertex from TopoDS, + Face from TopoDS, + Edge from TopoDS, + Solid from TopoDS, + SolidClassifier from BRepClass3d, + FClass2d from IntTools, + Curve from IntTools, + BaseAllocator from BOPCol, + DataMapOfShapeAddress from BOPCol, + DataMapOfTransientAddress from BOPCol + +--raises + +is + Create + returns mutable Context from BOPInt; + ---C++: alias "Standard_EXPORT virtual ~BOPInt_Context();" + + Create (theAllocator: BaseAllocator from BOPCol) + returns Context from BOPInt; + + FClass2d(me:mutable; + aF: Face from TopoDS) + returns FClass2d from IntTools; + ---C++: return & + + ProjPS (me:mutable; + aF: Face from TopoDS) + returns ProjectPointOnSurf from GeomAPI; + ---C++: return & + + ProjPC (me:mutable; + aE: Edge from TopoDS) + returns ProjectPointOnCurve from GeomAPI; + ---C++: return & + + ProjPT (me:mutable; + aC: Curve from Geom) + returns ProjectPointOnCurve from GeomAPI; + ---C++: return & + + SolidClassifier(me:mutable; + aSolid: Solid from TopoDS) + returns SolidClassifier from BRepClass3d; + ---C++: return & + + ComputePE (me:mutable; + theP : Pnt from gp; + theTolP: Real from Standard; + theE : Edge from TopoDS; + theT :out Real from Standard) + returns Integer from Standard; + + ComputeVE (me:mutable; + aV : Vertex from TopoDS; + aE : Edge from TopoDS; + aT :out Real from Standard) + returns Integer from Standard; + ---Purpose: + + ComputeVF (me:mutable; + aV : Vertex from TopoDS; + aF : Face from TopoDS; + U : out Real from Standard; + V : out Real from Standard) + returns Integer from Standard; + + StatePointFace(me:mutable; + aF : Face from TopoDS; + aP2D : Pnt2d from gp) + returns State from TopAbs; + + IsPointInFace(me:mutable; + aF : Face from TopoDS; + aP2D : Pnt2d from gp) + returns Boolean from Standard; + + IsPointInOnFace(me:mutable; + aF : Face from TopoDS; + aP2D : Pnt2d from gp) + returns Boolean from Standard; + + IsValidPointForFace(me:mutable; + aP3D : Pnt from gp; + aF : Face from TopoDS; + aTol : Real from Standard) + returns Boolean from Standard; + + IsValidPointForFaces(me:mutable; + aP3D : Pnt from gp; + aF1 : Face from TopoDS; + aF2 : Face from TopoDS; + aTol : Real from Standard) + returns Boolean from Standard; + + IsValidBlockForFace (me:mutable; + aT1 : Real from Standard; + aT2 : Real from Standard; + aIC : Curve from IntTools; + aF : Face from TopoDS; + aTol : Real from Standard) + returns Boolean from Standard; + + IsValidBlockForFaces (me:mutable; + aT1 : Real from Standard; + aT2 : Real from Standard; + aIC : Curve from IntTools; + aF1 : Face from TopoDS; + aF2 : Face from TopoDS; + aTol : Real from Standard) + returns Boolean from Standard; + + IsVertexOnLine(me:mutable; + aV : Vertex from TopoDS; + aIC : Curve from IntTools; + aTolC: Real from Standard; + aT :out Real from Standard) + returns Boolean from Standard; + + IsVertexOnLine(me:mutable; + aV : Vertex from TopoDS; + aTolV: Real from Standard; + aIC : Curve from IntTools; + aTolC: Real from Standard; + aT :out Real from Standard) + returns Boolean from Standard; + + ProjectPointOnEdge (me:mutable; + aP : Pnt from gp; + aE : Edge from TopoDS; + aT :out Real from Standard) + returns Boolean from Standard; + + --modified by NIZHNY-EMV Tue Apr 12 09:50:14 2011 + StatePointFace (me:mutable; + aF : Face from TopoDS; + aP : Pnt from gp) + returns State from TopAbs; + --modified by NIZHNY-EMV Tue Apr 12 09:50:16 2011 + +fields + myAllocator : BaseAllocator from BOPCol is protected; + myFClass2dMap:DataMapOfShapeAddress from BOPCol is protected; + myProjPSMap :DataMapOfShapeAddress from BOPCol is protected; + myProjPCMap :DataMapOfShapeAddress from BOPCol is protected; + mySClassMap :DataMapOfShapeAddress from BOPCol is protected; + myProjPTMap :DataMapOfTransientAddress from BOPCol is protected; + myCreateFlag :Integer from Standard is protected; + +end Context; + diff --git a/src/BOPInt/BOPInt_Context.cxx b/src/BOPInt/BOPInt_Context.cxx new file mode 100644 index 0000000000..de30086ec3 --- /dev/null +++ b/src/BOPInt/BOPInt_Context.cxx @@ -0,0 +1,744 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#include + +#include + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include +#include +// +#include + +#include +#include + + +//======================================================================= +//function : +//purpose : +//======================================================================= + BOPInt_Context::BOPInt_Context() +: + myAllocator(new NCollection_IncAllocator()), + myFClass2dMap(100, myAllocator), + myProjPSMap(100, myAllocator), + myProjPCMap(100, myAllocator), + mySClassMap(100, myAllocator), + myProjPTMap(100, myAllocator), + myCreateFlag(0) +{ +} +//======================================================================= +//function : +//purpose : +//======================================================================= + BOPInt_Context::BOPInt_Context(const Handle(NCollection_BaseAllocator)& theAllocator) +: + myAllocator(theAllocator), + myFClass2dMap(100, myAllocator), + myProjPSMap(100, myAllocator), + myProjPCMap(100, myAllocator), + mySClassMap(100, myAllocator), + myProjPTMap(100, myAllocator), + myCreateFlag(1) +{ +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= + BOPInt_Context::~BOPInt_Context() +{ + Standard_Address anAdr; + BOPCol_DataMapIteratorOfDataMapOfShapeAddress aIt; + BOPCol_DataMapIteratorOfDataMapOfTransientAddress aIt1; + // + IntTools_FClass2d* pFClass2d; + // + aIt.Initialize(myFClass2dMap); + for (; aIt.More(); aIt.Next()) { + anAdr=aIt.Value(); + pFClass2d=(IntTools_FClass2d*)anAdr; + (*pFClass2d).~IntTools_FClass2d(); + myAllocator->Free(anAdr); + } + myFClass2dMap.Clear(); + // + GeomAPI_ProjectPointOnSurf* pProjPS; + aIt.Initialize(myProjPSMap); + for (; aIt.More(); aIt.Next()) { + anAdr=aIt.Value(); + pProjPS=(GeomAPI_ProjectPointOnSurf*)anAdr; + (*pProjPS).~GeomAPI_ProjectPointOnSurf(); + myAllocator->Free(anAdr); + } + myProjPSMap.Clear(); + // + GeomAPI_ProjectPointOnCurve* pProjPC; + aIt.Initialize(myProjPCMap); + for (; aIt.More(); aIt.Next()) { + anAdr=aIt.Value(); + pProjPC=(GeomAPI_ProjectPointOnCurve*)anAdr; + (*pProjPC).~GeomAPI_ProjectPointOnCurve(); + myAllocator->Free(anAdr); + } + myProjPCMap.Clear(); + // + // + BRepClass3d_SolidClassifier* pSC; + aIt.Initialize(mySClassMap); + for (; aIt.More(); aIt.Next()) { + anAdr=aIt.Value(); + pSC=(BRepClass3d_SolidClassifier*)anAdr; + (*pSC).~BRepClass3d_SolidClassifier(); + myAllocator->Free(anAdr); + } + mySClassMap.Clear(); + // + GeomAPI_ProjectPointOnCurve* pProjPT; + aIt1.Initialize(myProjPTMap); + for (; aIt1.More(); aIt1.Next()) { + anAdr=aIt1.Value(); + pProjPT=(GeomAPI_ProjectPointOnCurve*)anAdr; + (*pProjPT).~GeomAPI_ProjectPointOnCurve(); + myAllocator->Free(anAdr); + } + myProjPTMap.Clear(); +} +//======================================================================= +//function : FClass2d +//purpose : +//======================================================================= + IntTools_FClass2d& BOPInt_Context::FClass2d(const TopoDS_Face& aF) +{ + Standard_Address anAdr; + IntTools_FClass2d* pFClass2d; + // + if (!myFClass2dMap.IsBound(aF)) { + Standard_Real aTolF; + TopoDS_Face aFF; + // + aFF=aF; + aFF.Orientation(TopAbs_FORWARD); + aTolF=BRep_Tool::Tolerance(aFF); + // + pFClass2d=(IntTools_FClass2d*)myAllocator->Allocate(sizeof(IntTools_FClass2d)); + new (pFClass2d) IntTools_FClass2d(aFF, aTolF); + // + anAdr=(Standard_Address)pFClass2d; + myFClass2dMap.Bind(aFF, anAdr); + } + else { + anAdr=myFClass2dMap.Find(aF); + pFClass2d=(IntTools_FClass2d*)anAdr; + } + return *pFClass2d; +} +//======================================================================= +//function : ProjPS +//purpose : +//======================================================================= + GeomAPI_ProjectPointOnSurf& BOPInt_Context::ProjPS(const TopoDS_Face& aF) +{ + Standard_Address anAdr; + GeomAPI_ProjectPointOnSurf* pProjPS; + + if (!myProjPSMap.IsBound(aF)) { + Standard_Real Umin, Usup, Vmin, Vsup, anEpsT=1.e-12 ; + BRepAdaptor_Surface aBAS; + // + const Handle(Geom_Surface)& aS=BRep_Tool::Surface(aF); + aBAS.Initialize (aF, Standard_True); + // + Umin=aBAS.FirstUParameter(); + Usup=aBAS.LastUParameter (); + Vmin=aBAS.FirstVParameter(); + Vsup=aBAS.LastVParameter (); + // + pProjPS=(GeomAPI_ProjectPointOnSurf*)myAllocator->Allocate(sizeof(GeomAPI_ProjectPointOnSurf)); + new (pProjPS) GeomAPI_ProjectPointOnSurf(); + pProjPS->Init(aS ,Umin, Usup, Vmin, Vsup, anEpsT); + // + anAdr=(Standard_Address)pProjPS; + myProjPSMap.Bind(aF, anAdr); + } + + else { + anAdr=myProjPSMap.Find(aF); + pProjPS=(GeomAPI_ProjectPointOnSurf*)anAdr; + } + return *pProjPS; +} +//======================================================================= +//function : ProjPC +//purpose : +//======================================================================= + GeomAPI_ProjectPointOnCurve& BOPInt_Context::ProjPC(const TopoDS_Edge& aE) +{ + Standard_Address anAdr; + GeomAPI_ProjectPointOnCurve* pProjPC; + + if (!myProjPCMap.IsBound(aE)) { + Standard_Real f, l; + // + Handle(Geom_Curve)aC3D=BRep_Tool::Curve (aE, f, l); + // + pProjPC=(GeomAPI_ProjectPointOnCurve*)myAllocator->Allocate(sizeof(GeomAPI_ProjectPointOnCurve)); + new (pProjPC) GeomAPI_ProjectPointOnCurve(); + pProjPC->Init(aC3D, f, l); + // + anAdr=(Standard_Address)pProjPC; + myProjPCMap.Bind(aE, anAdr); + } + + else { + anAdr=myProjPCMap.Find(aE); + pProjPC=(GeomAPI_ProjectPointOnCurve*)anAdr; + } + return *pProjPC; +} + +//======================================================================= +//function : ProjPT +//purpose : +//======================================================================= + GeomAPI_ProjectPointOnCurve& BOPInt_Context::ProjPT(const Handle(Geom_Curve)& aC3D) + +{ + Standard_Address anAdr; + GeomAPI_ProjectPointOnCurve* pProjPT; + + if (!myProjPTMap.IsBound(aC3D)) { + Standard_Real f, l; + f=aC3D->FirstParameter(); + l=aC3D->LastParameter(); + // + pProjPT=(GeomAPI_ProjectPointOnCurve*)myAllocator->Allocate(sizeof(GeomAPI_ProjectPointOnCurve)); + new (pProjPT) GeomAPI_ProjectPointOnCurve(); + pProjPT->Init(aC3D, f, l); + // + anAdr=(Standard_Address)pProjPT; + myProjPTMap.Bind(aC3D, anAdr); + } + + else { + anAdr=myProjPTMap.Find(aC3D); + pProjPT=(GeomAPI_ProjectPointOnCurve*)anAdr; + } + return *pProjPT; +} +//======================================================================= +//function : SolidClassifier +//purpose : +//======================================================================= + BRepClass3d_SolidClassifier& BOPInt_Context::SolidClassifier(const TopoDS_Solid& aSolid) +{ + Standard_Address anAdr; + BRepClass3d_SolidClassifier* pSC; + + if (!mySClassMap.IsBound(aSolid)) { + // + pSC=(BRepClass3d_SolidClassifier*)myAllocator->Allocate(sizeof(BRepClass3d_SolidClassifier)); + new (pSC) BRepClass3d_SolidClassifier(aSolid); + // + anAdr=(Standard_Address)pSC; + mySClassMap.Bind(aSolid, anAdr); + } + + else { + anAdr=mySClassMap.Find(aSolid); + pSC =(BRepClass3d_SolidClassifier*)anAdr; + } + return *pSC; +} +//======================================================================= +//function : ComputePE +//purpose : +//======================================================================= + Standard_Integer BOPInt_Context::ComputePE(const gp_Pnt& aP1, + const Standard_Real aTolP1, + const TopoDS_Edge& aE2, + Standard_Real& aT) +{ + if (!BRep_Tool::IsGeometric(aE2)) { + return -2; + } + Standard_Real aDist, aTolE2, aTolSum; + Standard_Integer aNbProj; + // + GeomAPI_ProjectPointOnCurve& aProjector=ProjPC(aE2); + aProjector.Perform(aP1); + + aNbProj=aProjector.NbPoints(); + if (!aNbProj) { + return -3; + } + // + aDist=aProjector.LowerDistance(); + // + aTolE2=BRep_Tool::Tolerance(aE2); + aTolSum=aTolP1+aTolE2; + // + aT=aProjector.LowerDistanceParameter(); + if (aDist > aTolSum) { + return -4; + } + return 0; +} +//======================================================================= +//function : ComputeVE +//purpose : +//======================================================================= + Standard_Integer BOPInt_Context::ComputeVE(const TopoDS_Vertex& aV1, + const TopoDS_Edge& aE2, + Standard_Real& aT) +{ + if (BRep_Tool::Degenerated(aE2)) { + return -1; + } + if (!BRep_Tool::IsGeometric(aE2)) { + return -2; + } + Standard_Real aDist, aTolV1, aTolE2, aTolSum; + Standard_Integer aNbProj; + gp_Pnt aP; + // + aP=BRep_Tool::Pnt(aV1); + // + GeomAPI_ProjectPointOnCurve& aProjector=ProjPC(aE2); + aProjector.Perform(aP); + + aNbProj=aProjector.NbPoints(); + if (!aNbProj) { + return -3; + } + // + aDist=aProjector.LowerDistance(); + // + aTolV1=BRep_Tool::Tolerance(aV1); + aTolE2=BRep_Tool::Tolerance(aE2); + aTolSum=aTolV1+aTolE2; + // + aT=aProjector.LowerDistanceParameter(); + if (aDist > aTolSum) { + return -4; + } + return 0; +} +//======================================================================= +//function : ComputeVS +//purpose : +//======================================================================= + Standard_Integer BOPInt_Context::ComputeVF(const TopoDS_Vertex& aV1, + const TopoDS_Face& aF2, + Standard_Real& U, + Standard_Real& V) +{ + Standard_Real aTolV1, aTolF2, aTolSum, aDist; + gp_Pnt aP; + + aP=BRep_Tool::Pnt(aV1); + // + // 1. Check if the point is projectable on the surface + GeomAPI_ProjectPointOnSurf& aProjector=ProjPS(aF2); + aProjector.Perform(aP); + // + if (!aProjector.IsDone()) { // the point is not projectable on the surface + return -1; + } + // + // 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; + if (aDist > aTolSum) { + // the distance is too large + return -2; + } + aProjector.LowerDistanceParameters(U, V); + // + gp_Pnt2d aP2d(U, V); + Standard_Boolean pri=IsPointInFace (aF2, aP2d); + if (!pri) {// the point lays on the surface but out of the face + return -3; + } + return 0; +} +//======================================================================= +//function : StatePointFace +//purpose : +//======================================================================= + TopAbs_State BOPInt_Context::StatePointFace(const TopoDS_Face& aF, + const gp_Pnt2d& aP2d) +{ + TopAbs_State aState; + IntTools_FClass2d& aClass2d=FClass2d(aF); + aState=aClass2d.Perform(aP2d); + return aState; +} +//======================================================================= +//function : IsPointInFace +//purpose : +//======================================================================= + Standard_Boolean BOPInt_Context::IsPointInFace(const TopoDS_Face& aF, + const gp_Pnt2d& aP2d) +{ + TopAbs_State aState=StatePointFace(aF, aP2d); + if (aState==TopAbs_OUT || aState==TopAbs_ON) { + return Standard_False; + } + return Standard_True; +} +//======================================================================= +//function : IsPointInOnFace +//purpose : +//======================================================================= + Standard_Boolean BOPInt_Context::IsPointInOnFace(const TopoDS_Face& aF, + const gp_Pnt2d& aP2d) +{ + TopAbs_State aState=StatePointFace(aF, aP2d); + if (aState==TopAbs_OUT) { + return Standard_False; + } + return Standard_True; +} +//======================================================================= +//function : IsValidPointForFace +//purpose : +//======================================================================= + Standard_Boolean BOPInt_Context::IsValidPointForFace(const gp_Pnt& aP, + const TopoDS_Face& aF, + const Standard_Real aTol) +{ + Standard_Boolean bFlag; + Standard_Real Umin, myEpsT, U, V; + myEpsT=1.e-12; + + GeomAPI_ProjectPointOnSurf& aProjector=ProjPS(aF); + aProjector.Perform(aP); + + bFlag=aProjector.IsDone(); + if (bFlag) { + + Umin=aProjector.LowerDistance(); + //if (Umin > 1.e-3) { // it was + if (Umin > aTol) { + return !bFlag; + } + // + aProjector.LowerDistanceParameters(U, V); + gp_Pnt2d aP2D(U, V); + //modified by NIZHNY-EMV Tue Apr 12 10:57:52 2011 + //modified by NIZNHY-PKV Wed Jul 8 14:56:39 2009f + bFlag=IsPointInOnFace (aF, aP2D); + //bFlag=IsPointInFace (aF, aP2D); + //modified by NIZNHY-PKV Wed Jul 8 14:56:42 2009t + //modified by NIZHNY-EMV Tue Apr 12 10:58:02 2011 + } + return bFlag; +} +//======================================================================= +//function : IsValidPointForFaces +//purpose : +//======================================================================= + Standard_Boolean BOPInt_Context::IsValidPointForFaces (const gp_Pnt& aP, + const TopoDS_Face& aF1, + const TopoDS_Face& aF2, + const Standard_Real aTol) +{ + Standard_Boolean bFlag1, bFlag2; + + bFlag1=IsValidPointForFace(aP, aF1, aTol); + if (!bFlag1) { + return bFlag1; + } + bFlag2=IsValidPointForFace(aP, aF2, aTol); + return bFlag2; +} +//======================================================================= +//function : IsValidBlockForFace +//purpose : +//======================================================================= + Standard_Boolean BOPInt_Context::IsValidBlockForFace (const Standard_Real aT1, + const Standard_Real aT2, + const IntTools_Curve& aC, + const TopoDS_Face& aF, + const Standard_Real aTol) +{ + Standard_Boolean bFlag; + Standard_Real aTInterm, aFirst, aLast; + gp_Pnt aPInterm; + + aTInterm=IntTools_Tools::IntermediatePoint(aT1, aT2); + + Handle(Geom_Curve) aC3D=aC.Curve(); + aFirst=aC3D->FirstParameter(); + aLast =aC3D->LastParameter(); + // point 3D + aC3D->D0(aTInterm, aPInterm); + // + bFlag=IsValidPointForFace (aPInterm, aF, aTol); + return bFlag; +} +//======================================================================= +//function : IsValidBlockForFaces +//purpose : +//======================================================================= + Standard_Boolean BOPInt_Context::IsValidBlockForFaces (const Standard_Real aT1, + const Standard_Real aT2, + const IntTools_Curve& aC, + const TopoDS_Face& aF1, + const TopoDS_Face& aF2, + const Standard_Real aTol) +{ + Standard_Boolean bFlag1, bFlag2; + // + Handle(Geom2d_Curve) aPC1 = aC.FirstCurve2d(); + Handle(Geom2d_Curve) aPC2 = aC.SecondCurve2d(); + if( !aPC1.IsNull() && !aPC2.IsNull() ) { + Standard_Real aMidPar = IntTools_Tools::IntermediatePoint(aT1, aT2); + gp_Pnt2d aPnt2D; + + + aPC1->D0(aMidPar, aPnt2D); + bFlag1 = IsPointInOnFace(aF1, aPnt2D); + + if( !bFlag1 ) + return bFlag1; + + aPC2->D0(aMidPar, aPnt2D); + bFlag2 = IsPointInOnFace(aF2, aPnt2D); + return bFlag2; + } + // + + bFlag1=IsValidBlockForFace (aT1, aT2, aC, aF1, aTol); + if (!bFlag1) { + return bFlag1; + } + bFlag2=IsValidBlockForFace (aT1, aT2, aC, aF2, aTol); + return bFlag2; +} +//======================================================================= +//function : IsVertexOnLine +//purpose : +//======================================================================= + Standard_Boolean BOPInt_Context::IsVertexOnLine (const TopoDS_Vertex& aV, + const IntTools_Curve& aC, + const Standard_Real aTolC, + Standard_Real& aT) +{ + Standard_Boolean bRet; + Standard_Real aTolV; + // + aTolV=BRep_Tool::Tolerance(aV); + bRet=BOPInt_Context::IsVertexOnLine(aV, aTolV, aC, aTolC , aT); + // + return bRet; +} +//======================================================================= +//function : IsVertexOnLine +//purpose : +//======================================================================= + Standard_Boolean BOPInt_Context::IsVertexOnLine (const TopoDS_Vertex& aV, + const Standard_Real aTolV, + const IntTools_Curve& aC, + const Standard_Real aTolC, + Standard_Real& aT) +{ + Standard_Real aFirst, aLast, aDist, aTolSum; + Standard_Integer aNbProj; + gp_Pnt aPv; + + aPv=BRep_Tool::Pnt(aV); + + Handle(Geom_Curve) aC3D=aC.Curve(); + + + aTolSum=aTolV+aTolC; + // + GeomAdaptor_Curve aGAC(aC3D); + GeomAbs_CurveType aType=aGAC.GetType(); + if (aType==GeomAbs_BSplineCurve || + aType==GeomAbs_BezierCurve) { + aTolSum=2.*aTolSum; + if (aTolSum<1.e-5) { + aTolSum=1.e-5; + } + } + else { + aTolSum=2.*aTolSum;//xft + if(aTolSum < 1.e-6) + aTolSum = 1.e-6; + } + // + aFirst=aC3D->FirstParameter(); + aLast =aC3D->LastParameter(); + // + //Checking extermities first + if (!Precision::IsInfinite(aFirst)) { + gp_Pnt aPCFirst=aC3D->Value(aFirst); + aDist=aPv.Distance(aPCFirst); + if (aDist < aTolSum) { + aT=aFirst; + // + if(aDist > aTolV) { + Extrema_LocateExtPC anExt(aPv, aGAC, aFirst, 1.e-10); + + if(anExt.IsDone()) { + Extrema_POnCurv aPOncurve = anExt.Point(); + aT = aPOncurve.Parameter(); + + if((aT > (aLast + aFirst) * 0.5) || + (aPv.Distance(aPOncurve.Value()) > aTolSum) || + (aPCFirst.Distance(aPOncurve.Value()) < Precision::Confusion())) + aT = aFirst; + } + } + // + return Standard_True; + } + } + // + //modified by NIZNHY-PKV Thu Nov 30 14:45:52 2006f + //if (!Precision::IsInfinite(aFirst)) { + if (!Precision::IsInfinite(aLast)) { + //modified by NIZNHY-PKV Thu Nov 30 14:45:55 2006t + gp_Pnt aPCLast=aC3D->Value(aLast); + aDist=aPv.Distance(aPCLast); + if (aDist < aTolSum) { + aT=aLast; + // + if(aDist > aTolV) { + Extrema_LocateExtPC anExt(aPv, aGAC, aLast, 1.e-10); + + if(anExt.IsDone()) { + Extrema_POnCurv aPOncurve = anExt.Point(); + aT = aPOncurve.Parameter(); + + if((aT < (aLast + aFirst) * 0.5) || + (aPv.Distance(aPOncurve.Value()) > aTolSum) || + (aPCLast.Distance(aPOncurve.Value()) < Precision::Confusion())) + aT = aLast; + } + } + // + return Standard_True; + } + } + // + GeomAPI_ProjectPointOnCurve& aProjector=ProjPT(aC3D); + aProjector.Perform(aPv); + + aNbProj=aProjector.NbPoints(); + if (!aNbProj) { + Handle(Geom_BoundedCurve) aBC= + Handle(Geom_BoundedCurve)::DownCast(aC3D); + if (!aBC.IsNull()) { + gp_Pnt aPStart=aBC->StartPoint(); + gp_Pnt aPEnd =aBC->EndPoint(); + + aDist=aPv.Distance(aPStart); + if (aDist < aTolSum) { + aT=aFirst; + return Standard_True; + } + + aDist=aPv.Distance(aPEnd); + if (aDist < aTolSum) { + aT=aLast; + return Standard_True; + } + } + + return Standard_False; + } + + aDist=aProjector.LowerDistance(); + + if (aDist > aTolSum) { + return Standard_False; + } + + aT=aProjector.LowerDistanceParameter(); + + return Standard_True; +} +//======================================================================= +//function : ProjectPointOnEdge +//purpose : +//======================================================================= + Standard_Boolean BOPInt_Context::ProjectPointOnEdge(const gp_Pnt& aP, + const TopoDS_Edge& anEdge, + Standard_Real& aT) +{ + Standard_Integer aNbPoints; + + GeomAPI_ProjectPointOnCurve& aProjector=ProjPC(anEdge); + aProjector.Perform(aP); + + aNbPoints=aProjector.NbPoints(); + if (aNbPoints) { + aT=aProjector.LowerDistanceParameter(); + return Standard_True; + } + return Standard_False; +} + +//modified by NIZHNY-EMV Tue Apr 12 09:54:56 2011 +//======================================================================= +//function : StatePointFace +//purpose : +//======================================================================= + TopAbs_State BOPInt_Context::StatePointFace(const TopoDS_Face& aF, + const gp_Pnt& aP) +{ + Standard_Real u, v; + TopAbs_State aState = TopAbs_OUT; + GeomAPI_ProjectPointOnSurf& aProjector=ProjPS(aF); + aProjector.Perform(aP); + if (!aProjector.IsDone()) { + return aState; + } + + aProjector.LowerDistanceParameters(u,v); + gp_Pnt2d aP2d(u,v); + + // + aState = StatePointFace(aF, aP2d); + return aState; +} +//modified by NIZHNY-EMV Tue Apr 12 10:01:04 2011 diff --git a/src/BOPInt/BOPInt_ShrunkRange.cdl b/src/BOPInt/BOPInt_ShrunkRange.cdl new file mode 100644 index 0000000000..016112715c --- /dev/null +++ b/src/BOPInt/BOPInt_ShrunkRange.cdl @@ -0,0 +1,93 @@ +-- Created by: Peter KURNEV +-- Copyright (c) 1999-2012 OPEN CASCADE SAS +-- +-- The content of this file is subject to the Open CASCADE Technology Public +-- License Version 6.5 (the "License"). You may not use the content of this file +-- except in compliance with the License. Please obtain a copy of the License +-- at http://www.opencascade.org and read it completely before using this file. +-- +-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +-- +-- The Original Code and all software distributed under the License is +-- distributed on an "AS IS" basis, without warranty of any kind, and the +-- Initial Developer hereby disclaims all such warranties, including without +-- limitation, any warranties of merchantability, fitness for a particular +-- purpose or non-infringement. Please see the License for the specific terms +-- and conditions governing the rights and limitations under the License. + + +class ShrunkRange from BOPInt + + ---Purpose: + --- The class provides the computation of + --- a working (shrunk) range [t1, t2] for + --- the 3D-curve of the edge. + +uses + Box from Bnd, + Edge from TopoDS, + Vertex from TopoDS, + Context from BOPInt + +--raises + +is + Create + returns ShrunkRange from BOPInt; + + SetData (me:out; + aE : Edge from TopoDS; + aT1 : Real from Standard; + aT2 : Real from Standard; + aV1 : Vertex from TopoDS; + aV2 : Vertex from TopoDS; + ICtx: Context from BOPInt); + + SetShrunkRange(me:out; + aT1 : Real from Standard; + aT2 : Real from Standard); + + ShrunkRange(me; + aT1 :out Real from Standard; + aT2 :out Real from Standard); + + BndBox (me) + returns Box from Bnd; + ---C++: return const & + + Edge (me) + returns Edge from TopoDS; + ---C++: return const & + + Perform(me:out); + + ErrorStatus(me) + returns Integer from Standard; + ---Purpose: + --- Returns code of computing shrunk range + --- completion + --- 0 - means successful completion + --- 1 - nothing has been done + --- 2 - initial range is out of edge's range + --- 3 - first boundary of initial range is more than + --- last boundary + --- 4 - projection of first vertex failed + --- 5 - projection of second vertex failed + --- 6 - shrunk range can not be computed + --- shrunk range is setted to initial range + --- + +fields + myEdge : Edge from TopoDS is protected; + myV1 : Vertex from TopoDS is protected; + myV2 : Vertex from TopoDS is protected; + myT1 : Real from Standard is protected; + myT2 : Real from Standard is protected; + myTS1 : Real from Standard is protected; + myTS2 : Real from Standard is protected; + myBndBox : Box from Bnd is protected; + myCtx : Context from BOPInt is protected; + myErrorStatus : Integer from Standard is protected; + +end ShrunkRange; diff --git a/src/BOPInt/BOPInt_ShrunkRange.cxx b/src/BOPInt/BOPInt_ShrunkRange.cxx new file mode 100644 index 0000000000..5056acfd64 --- /dev/null +++ b/src/BOPInt/BOPInt_ShrunkRange.cxx @@ -0,0 +1,743 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + +#include + +#include + +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +//======================================================================= +//function : +//purpose : +//======================================================================= + BOPInt_ShrunkRange::BOPInt_ShrunkRange () +{ + myT1=-99; + myT2=myT1; + myTS1=myT1; + myTS2=myT1; + myErrorStatus=1; +} +//======================================================================= +//function : SetData +//purpose : +//======================================================================= + void BOPInt_ShrunkRange::SetData(const TopoDS_Edge& aE, + const Standard_Real aT1, + const Standard_Real aT2, + const TopoDS_Vertex& aV1, + const TopoDS_Vertex& aV2, + const Handle(BOPInt_Context)& aCtx) +{ + myEdge=aE; + myV1=aV1; + myV2=aV2; + myT1=aT1; + myT2=aT2; + //myRange=aR; + myCtx=aCtx; + myErrorStatus=1; +} +//======================================================================= +//function : Edge +//purpose : +//======================================================================= + const TopoDS_Edge& BOPInt_ShrunkRange::Edge() const +{ + return myEdge; +} +//======================================================================= +//function : ShrunkRange +//purpose : +//======================================================================= + void BOPInt_ShrunkRange::ShrunkRange(Standard_Real& aT1, + Standard_Real& aT2) const +{ + aT1=myTS1; + aT2=myTS2; +} +//======================================================================= +//function : BndBox +//purpose : +//======================================================================= + const Bnd_Box& BOPInt_ShrunkRange::BndBox() const +{ + return myBndBox; +} +//======================================================================= +//function : ErrorStatus +//purpose : +//======================================================================= + Standard_Integer BOPInt_ShrunkRange::ErrorStatus() const +{ + return myErrorStatus; +} + +//======================================================================= +//function : SetShrunkRange +//purpose : +//======================================================================= + void BOPInt_ShrunkRange::SetShrunkRange(const Standard_Real aT1, + const Standard_Real aT2) +{ + myTS1=aT1; + myTS2=aT2; + // + BRepAdaptor_Curve aBAC(myEdge); + BndLib_Add3dCurve::Add (aBAC, aT1, aT2, 0., myBndBox); +} + +//======================================================================= +//function : Perform +//purpose : +//======================================================================= + void BOPInt_ShrunkRange::Perform() +{ + Standard_Real aCF, aCL, aTolE, aTolV1, aTolV2, t1, t11, t1C, t2, t12, t2C; + Standard_Real aCoeff, dt1, dt2, aR; + Standard_Integer pri; + Standard_Boolean bInf1, bInf2; + GeomAbs_CurveType aCurveType; + Handle(Geom_Curve) aC; + // + myErrorStatus=0; + myTS1=-99; + myTS2=myTS1; + // + aTolE =BRep_Tool::Tolerance(myEdge); + aTolV1=BRep_Tool::Tolerance(myV1); + aTolV2=BRep_Tool::Tolerance(myV2); + //modified by NIZHNY-EMV Thu Feb 02 14:44:35 2012 + //for edges with the tolerance value + //more than the tolerance value of vertices + if (aTolV1 < aTolE) { + aTolV1 = aTolE; + } + // + if (aTolV2 < aTolE) { + aTolV2 = aTolE; + } + //modified by NIZHNY-EMV Thu Feb 02 14:44:37 2012 + // + t1=myT1; + t2=myT2; + // + BRepAdaptor_Curve aBAC(myEdge); + aCurveType=aBAC.GetType(); + // + aC=BRep_Tool::Curve(myEdge, aCF, aCL); + BRep_Tool::Range(myEdge, aCF, aCL); + // + if (t1 < aCF || t2 > aCL) { + myErrorStatus=2; + return; + } + // + if (t1 > t2) { + myErrorStatus=3; + return; + } + // + aCoeff=2.; + // xf + if (aCurveType==GeomAbs_Line) { + Standard_Real aTV1, aTV2, aEps; + gp_Pnt aPV1, aPV2, aPC1, aPC2; + gp_Lin aL; + // + aEps=Precision::Confusion(); + aEps=aEps*aEps;//1.e-14; + aL=aBAC.Line(); + // + aPV1=BRep_Tool::Pnt(myV1); + aTV1=ElCLib::Parameter(aL, aPV1); + // + aPV2=BRep_Tool::Pnt(myV2); + aTV2=ElCLib::Parameter(aL, aPV2); + // + if (fabs(aTV1-aCF)t2 || t12 t1C + gp_Pnt aP1,aP11; + aC->D0 (t1, aP1); + // + bInf1=Precision::IsNegativeInfinite(t1); + if (bInf1) { + t1C=t1; + } + // + else { + Standard_Real d1 = aCoeff*(aTolV1+aTolE); + // dt1 = aBAC.Resolution(d1); + // + gp_Vec aD1vec1; + gp_Pnt aPoint; + aBAC.D1(t1, aPoint, aD1vec1); + Standard_Real ad1length1 = aD1vec1.Magnitude(); + Standard_Boolean bTryOtherPoints = Standard_False; + dt1 = (t2 - t1) * 0.5; + + if(ad1length1 > 1.e-12) { + dt1 = d1 / ad1length1; + + if(dt1 > (t2 - t1)) { + // bad parametrization, big tolerance or too small range + bTryOtherPoints = Standard_True; + } + } + else { + bTryOtherPoints = Standard_True; + } + + if(bTryOtherPoints) { + Standard_Integer nbsamples = 5; + Standard_Integer ii = 0; + Standard_Real adelta = (t2 - t1) / (nbsamples + 1); + Standard_Boolean bFound = Standard_False; + + for(ii = 1; ii <= nbsamples; ii++) { + Standard_Real aparameter = t1 + (adelta * ii); + gp_Pnt aPoint2; + aBAC.D1(aparameter, aPoint2, aD1vec1); + + if(aPoint.Distance(aPoint2) < d1) + dt1 = adelta * ii; + ad1length1 = aD1vec1.Magnitude(); + + if(ad1length1 > 1.e-12) { + dt1 = d1 / ad1length1; + + if(dt1 < (t2 - t1)) { + bFound = Standard_True; + break; + } + } + } + + if(!bFound) { + if(dt1 > (t2 - t1)) { + dt1 = aBAC.Resolution(d1); + } + } + } + // + + t11=t1+dt1; + aC->D0 (t11, aP11); + + gp_Vec aV11(aP1, aP11); + // avoid exception if aP1 == aP11 + if (aV11.SquareMagnitude() < gp::Resolution()) + t1C = t1; + else { + gp_Dir aD11(aV11); + + gp_Pnt aP1L; + // + aP1L.SetCoord (aP1.X()+d1*aD11.X(), + aP1.Y()+d1*aD11.Y(), + aP1.Z()+d1*aD11.Z()); + + BRepBuilderAPI_MakeVertex aMV1(aP1L); + const TopoDS_Vertex& aV1L=aMV1.Vertex(); + // + pri=myCtx->ComputeVE (aV1L, myEdge, t1C); + // + if (pri==-3) { + //modified by NIZHNY-EMV Mon Nov 28 14:55:00 2011 + t1C = t1; + myErrorStatus=6; + //myErrorStatus=4; + //return; + //modified by NIZHNY-EMV Mon Nov 28 14:55:03 2011 + } + } + } + // + // Vertex2 => t2C + gp_Pnt aP2, aP12; + aC->D0 (t2, aP2); + // + bInf2=Precision::IsPositiveInfinite(t2); + if (bInf2) { + t2C=t2; + } + // + else { + Standard_Real d2 = aCoeff*(aTolV2+aTolE); + // dt2 = aBAC.Resolution(d2); + + // + gp_Vec aD1vec2; + gp_Pnt aPoint; + aBAC.D1(t2, aPoint, aD1vec2); + Standard_Real ad1length2 = aD1vec2.Magnitude(); + Standard_Boolean bTryOtherPoints = Standard_False; + dt2 = (t2 - t1) * 0.5; + + if(ad1length2 > 1.e-12) { + dt2 = d2 / ad1length2; + + if(dt2 > (t2 - t1)) { + bTryOtherPoints = Standard_True; + } + } + else { + bTryOtherPoints = Standard_True; + } + + if(bTryOtherPoints) { + Standard_Integer nbsamples = 5; + Standard_Integer ii = 0; + Standard_Real adelta = (t2 - t1) / (nbsamples + 1); + Standard_Boolean bFound = Standard_False; + + for(ii = 1; ii <= nbsamples; ii++) { + Standard_Real aparameter = t2 - (adelta * ii); + gp_Pnt aPoint2; + aBAC.D1(aparameter, aPoint2, aD1vec2); + + if(aPoint.Distance(aPoint2) < d2) + dt2 = adelta * ii; + ad1length2 = aD1vec2.Magnitude(); + + if(ad1length2 > 1.e-12) { + dt2 = d2 / ad1length2; + + if(dt2 < (t2 - t1)) { + bFound = Standard_True; + break; + } + } + } + + if(!bFound) { + if(dt2 > (t2 - t1)) { + dt2 = aBAC.Resolution(d2); + } + } + } + // + + t12=t2-dt2; + aC->D0 (t12, aP12); + + gp_Vec aV12(aP2, aP12); + // avoid exception if aP1 == aP11 + if (aV12.SquareMagnitude() < gp::Resolution()) + t2C = t2; + else { + gp_Dir aD12(aV12); + + gp_Pnt aP2L; + // + aP2L.SetCoord (aP2.X()+d2*aD12.X(), + aP2.Y()+d2*aD12.Y(), + aP2.Z()+d2*aD12.Z()); + + BRepBuilderAPI_MakeVertex aMV2(aP2L); + const TopoDS_Vertex& aV2L=aMV2.Vertex(); + // + pri=myCtx->ComputeVE (aV2L, myEdge, t2C); + // + if (pri==-3) { + //modified by NIZHNY-EMV Mon Nov 28 14:55:32 2011 + t2C = t2; + myErrorStatus=6; + //myErrorStatus=5; + //return; + //modified by NIZHNY-EMV Mon Nov 28 14:55:34 2011 + } + } + } + } // else { + + + if (t1C>t2){ + t1C=0.5*(t2+t1); + t2C=t1C+0.1*(t2-t1C); + } + + if (t1C>t2C) { + t2C=t1C+0.1*(t2-t1C); + } + // + myTS1=t1C; + myTS2=t2C; + // + // BndBox + Standard_Real ddx=aTolE;//1.e-12; + BndLib_Add3dCurve::Add (aBAC, t1C, t2C, ddx, myBndBox); + // + // Ok + //modified by NIZHNY-EMV Wed Dec 07 14:58:14 2011 + //myErrorStatus=0; + //modified by NIZHNY-EMV Wed Dec 07 14:58:20 2011 +} +///////////////////////////////////////////////////////////////////////// +// +// myErrorStatus : +// +// 1- Nothing has been done +// 2- The source range is out of the edge's range +// 3- t1 < t2 for source range +// 4- Can not project V1L to the Edge; +// 5- Can not project V2L to the Edge; +// 6- for obtained shrunk range [t11, t12] -> t11>t2 || t12 aCL) { + myErrorStatus=2; + return; + } + + if (t1 > t2 ) { + myErrorStatus=3; + return; + } + // + if (aCurveType==GeomAbs_Line) { + Standard_Real dt1x, dt2x; + + dt1x = aBAC.Resolution(dt1); + t11=t1+dt1x; + + dt2x = aBAC.Resolution(dt2); + t12=t2-dt2x; + + if (t11>t2 || t12 t1C + gp_Pnt aP1,aP11; + aC->D0 (t1, aP1); + // + bInf1=Precision::IsNegativeInfinite(t1); + if (bInf1) { + t1C=t1; + } + // + else { + Standard_Real d1 = aCoeff*(aTolV1+aTolE); + // dt1 = aBAC.Resolution(d1); + // + gp_Vec aD1vec1; + gp_Pnt aPoint; + aBAC.D1(t1, aPoint, aD1vec1); + Standard_Real ad1length1 = aD1vec1.Magnitude(); + Standard_Boolean bTryOtherPoints = Standard_False; + dt1 = (t2 - t1) * 0.5; + + if(ad1length1 > 1.e-12) { + dt1 = d1 / ad1length1; + + if(dt1 > (t2 - t1)) { + // bad parametrization, big tolerance or too small range + bTryOtherPoints = Standard_True; + } + } + else { + bTryOtherPoints = Standard_True; + } + + if(bTryOtherPoints) { + Standard_Integer nbsamples = 5; + Standard_Integer ii = 0; + Standard_Real adelta = (t2 - t1) / (nbsamples + 1); + Standard_Boolean bFound = Standard_False; + + for(ii = 1; ii <= nbsamples; ii++) { + Standard_Real aparameter = t1 + (adelta * ii); + gp_Pnt aPoint2; + aBAC.D1(aparameter, aPoint2, aD1vec1); + + if(aPoint.Distance(aPoint2) < d1) + dt1 = adelta * ii; + ad1length1 = aD1vec1.Magnitude(); + + if(ad1length1 > 1.e-12) { + dt1 = d1 / ad1length1; + + if(dt1 < (t2 - t1)) { + bFound = Standard_True; + break; + } + } + } + + if(!bFound) { + if(dt1 > (t2 - t1)) { + dt1 = aBAC.Resolution(d1); + } + } + } + // + + t11=t1+dt1; + aC->D0 (t11, aP11); + + gp_Vec aV11(aP1, aP11); + // avoid exception if aP1 == aP11 + if (aV11.SquareMagnitude() < gp::Resolution()) + t1C = t1; + else { + gp_Dir aD11(aV11); + + gp_Pnt aP1L; + // + aP1L.SetCoord (aP1.X()+d1*aD11.X(), + aP1.Y()+d1*aD11.Y(), + aP1.Z()+d1*aD11.Z()); + + BRepBuilderAPI_MakeVertex aMV1(aP1L); + const TopoDS_Vertex& aV1L=aMV1.Vertex(); + // + pri=myCtx->ComputeVE (aV1L, myEdge, t1C); + // + if (pri==-3) { + myErrorStatus=4; + return; + } + } + } + // + // Vertex2 => t2C + gp_Pnt aP2, aP12; + aC->D0 (t2, aP2); + // + bInf2=Precision::IsPositiveInfinite(t2); + if (bInf2) { + t2C=t2; + } + // + else { + Standard_Real d2 = aCoeff*(aTolV2+aTolE); + // dt2 = aBAC.Resolution(d2); + + // + gp_Vec aD1vec2; + gp_Pnt aPoint; + aBAC.D1(t2, aPoint, aD1vec2); + Standard_Real ad1length2 = aD1vec2.Magnitude(); + Standard_Boolean bTryOtherPoints = Standard_False; + dt2 = (t2 - t1) * 0.5; + + if(ad1length2 > 1.e-12) { + dt2 = d2 / ad1length2; + + if(dt2 > (t2 - t1)) { + bTryOtherPoints = Standard_True; + } + } + else { + bTryOtherPoints = Standard_True; + } + + if(bTryOtherPoints) { + Standard_Integer nbsamples = 5; + Standard_Integer ii = 0; + Standard_Real adelta = (t2 - t1) / (nbsamples + 1); + Standard_Boolean bFound = Standard_False; + + for(ii = 1; ii <= nbsamples; ii++) { + Standard_Real aparameter = t2 - (adelta * ii); + gp_Pnt aPoint2; + aBAC.D1(aparameter, aPoint2, aD1vec2); + + if(aPoint.Distance(aPoint2) < d2) + dt2 = adelta * ii; + ad1length2 = aD1vec2.Magnitude(); + + if(ad1length2 > 1.e-12) { + dt2 = d2 / ad1length2; + + if(dt2 < (t2 - t1)) { + bFound = Standard_True; + break; + } + } + } + + if(!bFound) { + if(dt2 > (t2 - t1)) { + dt2 = aBAC.Resolution(d2); + } + } + } + // + + t12=t2-dt2; + aC->D0 (t12, aP12); + + gp_Vec aV12(aP2, aP12); + // avoid exception if aP1 == aP11 + if (aV12.SquareMagnitude() < gp::Resolution()) + t2C = t2; + else { + gp_Dir aD12(aV12); + + gp_Pnt aP2L; + // + aP2L.SetCoord (aP2.X()+d2*aD12.X(), + aP2.Y()+d2*aD12.Y(), + aP2.Z()+d2*aD12.Z()); + + BRepBuilderAPI_MakeVertex aMV2(aP2L); + const TopoDS_Vertex& aV2L=aMV2.Vertex(); + // + pri=myCtx->ComputeVE (aV2L, myEdge, t2C); + // + if (pri==-3) { + myErrorStatus=5; + return; + } + } + } + } // else { + + + if (t1C>t2){ + t1C=0.5*(t2+t1); + t2C=t1C+0.1*(t2-t1C); + } + + if (t1C>t2C) { + t2C=t1C+0.1*(t2-t1C); + } + myTS1=t1C; + myTS2=t2C; + //myShrunkRange.SetRange(t1C, t2C); + // + // BndBox + Standard_Real ddx=aTolE;//1.e-12; + BndLib_Add3dCurve::Add (aBAC, t1C, t2C, ddx, myBndBox); + // + // Ok + myErrorStatus=0; +} +*/ diff --git a/src/BOPInt/BOPInt_Tools.cdl b/src/BOPInt/BOPInt_Tools.cdl new file mode 100644 index 0000000000..64ec3aa548 --- /dev/null +++ b/src/BOPInt/BOPInt_Tools.cdl @@ -0,0 +1,83 @@ +-- Created by: Peter KURNEV +-- Copyright (c) 1999-2012 OPEN CASCADE SAS +-- +-- The content of this file is subject to the Open CASCADE Technology Public +-- License Version 6.5 (the "License"). You may not use the content of this file +-- except in compliance with the License. Please obtain a copy of the License +-- at http://www.opencascade.org and read it completely before using this file. +-- +-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +-- +-- The Original Code and all software distributed under the License is +-- distributed on an "AS IS" basis, without warranty of any kind, and the +-- Initial Developer hereby disclaims all such warranties, including without +-- limitation, any warranties of merchantability, fitness for a particular +-- purpose or non-infringement. Please see the License for the specific terms +-- and conditions governing the rights and limitations under the License. + + +class Tools from BOPInt + + ---Purpose: + +uses + Box from Bnd, + Lin from gp, + Pln from gp, + Pnt from gp, + Curve from Geom, + + Edge from TopoDS, + Face from TopoDS, + Range from IntTools, + CommonPrt from IntTools +--raises + +is + + + CheckCurve(myclass; + theC:Curve from Geom; + theTol:Real from Standard; + theBox:out Box from Bnd) + returns Boolean from Standard; + + IsOnPave(myclass; + theT:Real from Standard; + theRange:Range from IntTools; + theTol: Real from Standard) + returns Boolean from Standard; + + + VertexParameters(myclass; + theCP:CommonPrt from IntTools; + theT1:out Real from Standard; + theT2:out Real from Standard); + + VertexParameter(myclass; + theCP:CommonPrt from IntTools; + theT:out Real from Standard); + + IsOnPave1(myclass; + theT:Real from Standard; + theRange:Range from IntTools; + theTol: Real from Standard) + returns Boolean from Standard; + + SegPln(myclass; + theLin : Lin from gp; + theTLin1 : Real from Standard; + theTLin2 : Real from Standard; + theTolLin: Real from Standard; + thePln : Pln from gp; + theTolPln: Real from Standard; + theP :out Pnt from gp; + theT :out Real from Standard; + theTolP :out Real from Standard; + theTmin :out Real from Standard; + theTmax :out Real from Standard) + returns Integer from Standard; +--fields + +end Tools; diff --git a/src/BOPInt/BOPInt_Tools.cxx b/src/BOPInt/BOPInt_Tools.cxx new file mode 100644 index 0000000000..b4a1d9b41d --- /dev/null +++ b/src/BOPInt/BOPInt_Tools.cxx @@ -0,0 +1,213 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#include + +#include +#include +#include +#include +#include + +//======================================================================= +//function : CheckCurve +//purpose : +//======================================================================= + Standard_Boolean BOPInt_Tools::CheckCurve(const Handle (Geom_Curve)& aC3D, + const Standard_Real aTolR3D, + Bnd_Box& aBox) +{ + Standard_Boolean bRet; + Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax, dX, dY, dZ; + Standard_Real dS, aTol; + GeomAdaptor_Curve aGAC; + // + aGAC.Load(aC3D); + BndLib_Add3dCurve::Add(aGAC, aTolR3D, aBox); + //modified by NIZNHY-PKV Thu May 21 09:49:28 2009f + // 910/B1 + aBox.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax); + dX=aXmax-aXmin; + dY=aYmax-aYmin; + dZ=aZmax-aZmin; + dS=1.e-12; + aTol=2.*aTolR3D+dS; + bRet=(dX>aTol || dY>aTol || dZ>aTol); + // + return bRet; + //modified by NIZNHY-PKV Thu May 21 09:50:15 2009t +} + + +//======================================================================= +//function : IsOnPave +//purpose : +//======================================================================= + Standard_Boolean BOPInt_Tools::IsOnPave(const Standard_Real aT1, + const IntTools_Range& aRange, + const Standard_Real aTolerance) +{ + Standard_Boolean firstisonpave1, firstisonpave2, bIsOnPave; + // + firstisonpave1 = (Abs(aRange.First() - aT1) < aTolerance); + firstisonpave2 = (Abs(aRange.Last() - aT1) < aTolerance); + bIsOnPave=(firstisonpave1 || firstisonpave2); + return bIsOnPave; +} +//======================================================================= +// function: VertexParameters +// purpose: +//======================================================================= + void BOPInt_Tools::VertexParameters(const IntTools_CommonPrt& aCPart, + Standard_Real& aT1, + Standard_Real& aT2) +{ + const IntTools_Range& aR1=aCPart.Range1(); + aT1=0.5*(aR1.First()+aR1.Last()); + // + if((aCPart.VertexParameter1() >= aR1.First()) && + (aCPart.VertexParameter1() <= aR1.Last())) { + aT1 = aCPart.VertexParameter1(); + } + // + const IntTools_SequenceOfRanges& aRanges2=aCPart.Ranges2(); + const IntTools_Range& aR2=aRanges2(1); + aT2=0.5*(aR2.First()+aR2.Last()); + // + if((aCPart.VertexParameter2() >= aR2.First()) && + (aCPart.VertexParameter2() <= aR2.Last())) { + aT2 = aCPart.VertexParameter2(); + } +} +//======================================================================= +// function: VertexParameter +// purpose: +//======================================================================= + void BOPInt_Tools::VertexParameter(const IntTools_CommonPrt& aCPart, + Standard_Real& aT) +{ + const IntTools_Range& aR=aCPart.Range1(); + aT=0.5*(aR.First()+aR.Last()); + if((aCPart.VertexParameter1() >= aR.First()) && + (aCPart.VertexParameter1() <= aR.Last())) { + aT = aCPart.VertexParameter1(); + } +} +//======================================================================= +// function: IsOnPave1 +// purpose: +//======================================================================= + Standard_Boolean BOPInt_Tools::IsOnPave1(const Standard_Real aTR, + const IntTools_Range& aCPRange, + const Standard_Real aTolerance) +{ + Standard_Boolean bIsOnPave; + Standard_Real aT1, aT2, dT1, dT2; + // + aT1=aCPRange.First(); + aT2=aCPRange.Last(); + bIsOnPave=(aTR>=aT1 && aTR<=aT1); + if (bIsOnPave) { + return bIsOnPave; + } + // + dT1=Abs(aTR-aT1); + dT2=Abs(aTR-aT2); + bIsOnPave=(dT1<=aTolerance || dT2<=aTolerance); + return bIsOnPave; +} + + + + + + + + + + + + +//======================================================================= +//function : SegPln +//purpose : +//======================================================================= + Standard_Integer BOPInt_Tools::SegPln(const gp_Lin& theLin, + const Standard_Real theTLin1, + const Standard_Real theTLin2, + const Standard_Real theTolLin, + const gp_Pln& thePln, + const Standard_Real theTolPln, + gp_Pnt& theP, + Standard_Real& theTP, + Standard_Real& theTolP, + Standard_Real& theTPmin, + Standard_Real& theTPmax) +{ + Standard_Integer iRet; + Standard_Real aTol, aA, aB, aC, aD, aE, aH, aTP, aDist1, aDist2; + gp_Pnt aP1, aP2; + // + iRet=0; + aTol=theTolLin+theTolPln; + // + const gp_Ax3& aPosPln=thePln.Position(); + const gp_Dir& aDirPln=aPosPln.Direction(); + const gp_Pnt& aLocPln=aPosPln.Location(); + // + const gp_Dir& aDirLin=theLin.Direction(); + const gp_Pnt& aLocLin=theLin.Location(); + // + aP1.SetXYZ(aLocLin.XYZ()+theTLin1*aDirLin.XYZ()); + aDist1=aDirPln.X()*(aP1.X()-aLocPln.X())+ + aDirPln.Y()*(aP1.Y()-aLocPln.Y())+ + aDirPln.Z()*(aP1.Z()-aLocPln.Z()); + // + aP2.SetXYZ(aLocLin.XYZ()+theTLin2*aDirLin.XYZ()); + aDist2=aDirPln.X()*(aP2.X()-aLocPln.X())+ + aDirPln.Y()*(aP2.Y()-aLocPln.Y())+ + aDirPln.Z()*(aP2.Z()-aLocPln.Z()); + // + if (aDist1 0.) { + iRet=2; // segment lays on one side to the Plane + return iRet; + } + // + thePln.Coefficients(aA, aB, aC, aD); + aE=aA*aLocLin.X()+aB*aLocLin.Y()+aC*aLocLin.Z()+aD; + aH=aA*aDirLin.X()+aB*aDirLin.Y()+aC*aDirLin.Z(); + aTP=-aE/aH; + if (aTP < theTLin1-aTol || aTP > theTLin2+aTol) { + iRet=3; // no intersections due to range of the Line + return iRet; + } + // + theTP=aTP; + theP.SetXYZ(aLocLin.XYZ()+aTP*aDirLin.XYZ()); + theTolP=aTol; + theTPmin=theTP-theTolPln; + theTPmax=theTP+theTolPln; + iRet=0; // intersection point + return iRet; +} diff --git a/src/BOPTest/BOPTest.cdl b/src/BOPTest/BOPTest.cdl index bb6aaf816d..afe9f82989 100755 --- a/src/BOPTest/BOPTest.cdl +++ b/src/BOPTest/BOPTest.cdl @@ -17,43 +17,32 @@ -- purpose or non-infringement. Please see the License for the specific terms -- and conditions governing the rights and limitations under the License. - package BOPTest +---Purpose: - ---Purpose: - -- uses + gp, Draw, - TCollection, - gp, + DBRep, + TopAbs, TopoDS, - DBRep -is - class DrawableShape; - - AllCommands(DI : in out Interpretor from Draw); - ---Purpose: Defines all commands. - - MTestCommands(DI : in out Interpretor from Draw); - - TSTCommands (DI : in out Interpretor from Draw); - - EFCommands (DI : in out Interpretor from Draw); - - LowCommands (DI : in out Interpretor from Draw); - - BOPCommands (DI : in out Interpretor from Draw); - - WSplitCommands(DI : in out Interpretor from Draw); - - CurveCommands(DI : in out Interpretor from Draw); - - TolerCommands(DI : in out Interpretor from Draw); - - CheckCommands(DI : in out Interpretor from Draw); + TopTools, + BOPCol, + BOPDS, + BOPAlgo + +is - Factory (theDI : in out Interpretor from Draw); - ---Purpose: Loads all Draw commands for Geometry & Topology. Used for plugin. - -end BOPTest; - + class Objects; + class DrawableShape; + -- + AllCommands (aDI:out Interpretor from Draw); + BOPCommands (aDI:out Interpretor from Draw); + CheckCommands (aDI:out Interpretor from Draw); + TolerCommands (aDI:out Interpretor from Draw); + LowCommands (aDI:out Interpretor from Draw); + ObjCommands (aDI:out Interpretor from Draw); + PartitionCommands (aDI:out Interpretor from Draw); + Factory (aDI:out Interpretor from Draw); + +end BOPTest; diff --git a/src/BOPTest/BOPTest.cxx b/src/BOPTest/BOPTest.cxx index 3a6d0a5b02..639558f947 100755 --- a/src/BOPTest/BOPTest.cxx +++ b/src/BOPTest/BOPTest.cxx @@ -18,7 +18,6 @@ // and conditions governing the rights and limitations under the License. - #include #include #include @@ -28,6 +27,7 @@ #include //#include #include +//#include //======================================================================= //function : AllCommands @@ -37,40 +37,35 @@ void BOPTest::AllCommands(Draw_Interpretor& theCommands) { static Standard_Boolean done = Standard_False; if (done) return; - done = Standard_True; - - BOPTest::MTestCommands (theCommands); - BOPTest::TSTCommands(theCommands); - BOPTest::EFCommands (theCommands); - BOPTest::LowCommands(theCommands); - BOPTest::BOPCommands(theCommands); - BOPTest::WSplitCommands(theCommands); - BOPTest::CurveCommands(theCommands); - BOPTest::TolerCommands(theCommands); - BOPTest::CheckCommands(theCommands); + // + BOPTest::BOPCommands (theCommands); + BOPTest::CheckCommands (theCommands); + BOPTest::LowCommands (theCommands); + BOPTest::TolerCommands (theCommands); + BOPTest::ObjCommands (theCommands); + BOPTest::PartitionCommands (theCommands); } - -//============================================================================== -// BOPTest::Factory -//============================================================================== -void BOPTest::Factory(Draw_Interpretor& theDI) +//======================================================================= +//function : Factory +//purpose : +//======================================================================= + void BOPTest::Factory(Draw_Interpretor& theCommands) { static Standard_Boolean FactoryDone = Standard_False; if (FactoryDone) return; FactoryDone = Standard_True; - - DBRep::BasicCommands(theDI); - GeomliteTest::AllCommands(theDI); - GeometryTest::AllCommands(theDI); - BRepTest::AllCommands(theDI); - MeshTest::Commands(theDI); - //CorrectTest::CorrectCommands(theDI); - HLRTest::Commands(theDI); - BOPTest::AllCommands(theDI); -#ifdef DEB - theDI << "Draw Plugin : All Geometry & Topology commands are loaded" << "\n"; -#endif + DBRep::BasicCommands(theCommands); + GeomliteTest::AllCommands(theCommands); + GeometryTest::AllCommands(theCommands); + BRepTest::AllCommands(theCommands); + MeshTest::Commands(theCommands); + //CorrectTest::CorrectCommands(theCommands); + HLRTest::Commands(theCommands); + BOPTest::AllCommands(theCommands); + //printf(" BOP Plugin is loaded\n"); } +//#include +//DPLUGIN(BOPTest) diff --git a/src/BOPTest/BOPTest_BOPCommands.cxx b/src/BOPTest/BOPTest_BOPCommands.cxx index 83ccddd5ae..ded55b3691 100755 --- a/src/BOPTest/BOPTest_BOPCommands.cxx +++ b/src/BOPTest/BOPTest_BOPCommands.cxx @@ -18,371 +18,407 @@ // and conditions governing the rights and limitations under the License. - #include #include #include -#include - -#include -#include -#include +#include +#include -#include -#include #include -#include - -#include -#include - +#include #include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - +#include +#include +#include +#include +#include #include +#include -#include -#include -#include -#include -#include - -#include -#include - -static OSD_Chronometer DRAW_BOP_CHRONO; -static void StartChrono(); -static void StopChrono(Draw_Interpretor&); -Standard_Integer btimesum (Draw_Interpretor& , Standard_Integer n, const char** a); -//XX +#include +#include +#include +#include +#include +#include // -static Standard_Integer bop (Draw_Interpretor&, Standard_Integer, const char**); +static BOPAlgo_PaveFiller* pPF=NULL; // -static Standard_Integer bcommon (Draw_Interpretor& , Standard_Integer , const char**); -static Standard_Integer bfuse (Draw_Interpretor& , Standard_Integer , const char**); -static Standard_Integer bcut (Draw_Interpretor& , Standard_Integer , const char**); -static Standard_Integer bsection (Draw_Interpretor& , Standard_Integer , const char**); -static Standard_Integer bFillDS (Draw_Interpretor& , Standard_Integer , const char**); +static + Standard_Integer bopsmt(Draw_Interpretor& di, + Standard_Integer n, + const char** a, + const BOPAlgo_Operation aOp); +static + Standard_Integer bsmt (Draw_Interpretor& di, + Standard_Integer n, + const char** a, + const BOPAlgo_Operation aOp); // -static Standard_Integer bopcommon (Draw_Interpretor& , Standard_Integer , const char**); -static Standard_Integer bopfuse (Draw_Interpretor& , Standard_Integer , const char**); -static Standard_Integer bopcut (Draw_Interpretor& , Standard_Integer , const char**); -static Standard_Integer boptuc (Draw_Interpretor& , Standard_Integer , const char**); -static Standard_Integer bopsection (Draw_Interpretor& , Standard_Integer , const char**); - -static Standard_Integer boperationFiller (Standard_Integer n, const char** a, const BOP_Operation anOp, - Draw_Interpretor&); +static Standard_Integer bop (Draw_Interpretor&, Standard_Integer, const char**); +static Standard_Integer bopsection(Draw_Interpretor&, Standard_Integer, const char**); +static Standard_Integer boptuc (Draw_Interpretor&, Standard_Integer, const char**); +static Standard_Integer bopcut (Draw_Interpretor&, Standard_Integer, const char**); +static Standard_Integer bopfuse (Draw_Interpretor&, Standard_Integer, const char**); +static Standard_Integer bopcommon (Draw_Interpretor&, Standard_Integer, const char**); // -static Standard_Integer bopstates (Draw_Interpretor& , Standard_Integer , const char**); +static Standard_Integer bsection (Draw_Interpretor&, Standard_Integer, const char**); +static Standard_Integer btuc (Draw_Interpretor&, Standard_Integer, const char**); +static Standard_Integer bcut (Draw_Interpretor&, Standard_Integer, const char**); +static Standard_Integer bfuse (Draw_Interpretor&, Standard_Integer, const char**); +static Standard_Integer bcommon (Draw_Interpretor&, Standard_Integer, const char**); // -static Standard_Integer bopwho (Draw_Interpretor& , Standard_Integer , const char**); -static Standard_Integer bopsticks (Draw_Interpretor& , Standard_Integer , const char**); - +static Standard_Integer bopcurves (Draw_Interpretor&, Standard_Integer, const char**); +static Standard_Integer bopnews (Draw_Interpretor&, Standard_Integer, const char**); -static - void UnUsedMap(BOPTools_SequenceOfCurves& , - const BOPTools_PaveSet& , - TColStd_IndexedMapOfInteger& ); //======================================================================= //function : BOPCommands //purpose : //======================================================================= - void BOPTest::BOPCommands(Draw_Interpretor& theCommands) + void BOPTest::BOPCommands(Draw_Interpretor& theCommands) { static Standard_Boolean done = Standard_False; - if (done) - return; - + if (done) return; done = Standard_True; // Chapter's name - const char* g = "CCR commands"; - // - // Using DSFiller that is ready. - theCommands.Add("bop" , "Use >bop Shape1 Shape2", __FILE__, bop, g); - theCommands.Add("bopcommon" , "Use >bopcommon R" , __FILE__, bopcommon , g); - theCommands.Add("bopfuse" , "Use >bopfuse R" , __FILE__, bopfuse , g); - theCommands.Add("bopcut" , "Use >bopcut R" , __FILE__, bopcut , g); - theCommands.Add("boptuc" , "Use >boptuc R" , __FILE__, boptuc , g); - theCommands.Add("bopsection", "Use >bopsection R", __FILE__, bopsection, g); - // - // States - theCommands.Add("bopstates", "Use bopstates [-f] [-t] [-out]", __FILE__, bopstates, g); - // - theCommands.Add("bcommon" , "Use >bcommon R a b" , __FILE__, bcommon , g); - theCommands.Add("bfuse" , "Use >bfuse R a b" , __FILE__, bfuse , g); - theCommands.Add("bcut" , "Use >bcut R a b" , __FILE__, bcut , g); - // - // bsection - theCommands.Add("bsection", "Use >bsection Result s1 s2 [-2d/-2d1/-2d2] [-a]" - , __FILE__, bsection, g); + const char* g = "BOP commands"; + // Commands + + theCommands.Add("bop" , "use bop s1 s2" , __FILE__, bop, g); + theCommands.Add("bopcommon" , "use bopcommon r" , __FILE__, bopcommon, g); + theCommands.Add("bopfuse" , "use bopfuse r" , __FILE__,bopfuse, g); + theCommands.Add("bopcut" , "use bopcut" , __FILE__,bopcut, g); + theCommands.Add("boptuc" , "use boptuc" , __FILE__,boptuc, g); + theCommands.Add("bopsection", "use bopsection" , __FILE__,bopsection, g); // - theCommands.Add("btimesum" , "Use >btimesum FileName" , __FILE__, btimesum, g); - theCommands.Add("bopwho" , "Use >bopwho Index" , __FILE__, bopwho, g); - theCommands.Add("bopsticks" , "Use >bopsticks" , __FILE__, bopsticks, g); + theCommands.Add("bcommon" , "use bcommon r s1 s2" , __FILE__,bcommon, g); + theCommands.Add("bfuse" , "use bfuse r s1 s2" , __FILE__,bfuse, g); + theCommands.Add("bcut" , "use bcut r s1 s2" , __FILE__,bcut, g); + theCommands.Add("btuc" , "use btuc r s1 s2" , __FILE__,btuc, g); + theCommands.Add("bsection", "Use >bsection r s1 s2 [-n2d/-n2d1/-n2d2] [-na]", + __FILE__, bsection, g); // + theCommands.Add("bopcurves", "use bopcurves F1 F2", __FILE__, bopcurves, g); + theCommands.Add("bopnews", "use bopnews -v[e,f]" , __FILE__, bopnews, g); } -// -////////////////////////////////// -// -// The one and only global variable -// -BOPTools_DSFiller *pDF; -// -////////////////////////////////// -// + //======================================================================= //function : bop //purpose : //======================================================================= -Standard_Integer bop (Draw_Interpretor& di, - Standard_Integer n, - const char** a) +Standard_Integer bop (Draw_Interpretor& di, Standard_Integer n, const char** a) { - StartChrono(); - - if (n<3) { - di << " Use >bop Shape1 Shape2\n"; - StopChrono(di); + char buf[32]; + Standard_Integer iErr; + TopoDS_Shape aS1, aS2; + BOPCol_ListOfShape aLC; + // + if (n!=3) { + di << " use bop Shape1 Shape2\n"; return 1; } - - TopoDS_Shape S1 = DBRep::Get(a[1]); - TopoDS_Shape S2 = DBRep::Get(a[2]); - - if (S1.IsNull() || S2.IsNull()) { - di << " Null shapes are not allowed \n"; - StopChrono(di); + // + aS1=DBRep::Get(a[1]); + aS2=DBRep::Get(a[2]); + // + if (aS1.IsNull() || aS2.IsNull()) { + di << " null shapes are not allowed \n"; return 1; } - if (pDF!=NULL) { - delete pDF; - pDF=NULL; + // + aLC.Append(aS1); + aLC.Append(aS2); + // + if (!pPF) { + delete pPF; + Handle(NCollection_BaseAllocator)aAL=new NCollection_IncAllocator; + pPF=new BOPAlgo_PaveFiller(aAL); } - - pDF=new BOPTools_DSFiller; - - pDF->SetShapes (S1, S2); - if (!pDF->IsDone()) { - di << "Check types of the arguments, please\n"; - if (pDF!=NULL) { - delete pDF; - pDF=NULL; - } - StopChrono(di); - return 1; + // + pPF->SetArguments(aLC); + // + pPF->Perform(); + iErr=pPF->ErrorStatus(); + if (iErr) { + sprintf(buf, " error: %d\n", iErr); + di << buf; + return 0; } - - pDF->Perform(); - //printf(" BOPTools_DSFiller is Ready to use\n"); - - StopChrono(di); - + // return 0; } - //======================================================================= -//function : bFillDS +//function : bopcommon //purpose : //======================================================================= -Standard_Integer bFillDS (Draw_Interpretor& di, - Standard_Integer n, - const char** a) +Standard_Integer bopcommon (Draw_Interpretor& di, Standard_Integer n, const char** a) { - if (n!=4) { - di << " Usage: >command Result Shape1 Shape2\n"; - return 1; + return bopsmt(di, n, a, BOPAlgo_COMMON); +} +//======================================================================= +//function : bopfuse +//purpose : +//======================================================================= +Standard_Integer bopfuse(Draw_Interpretor& di, Standard_Integer n, const char** a) +{ + return bopsmt(di, n, a, BOPAlgo_FUSE); +} +//======================================================================= +//function : bopcut +//purpose : +//======================================================================= +Standard_Integer bopcut(Draw_Interpretor& di, Standard_Integer n, const char** a) +{ + return bopsmt(di, n, a, BOPAlgo_CUT); +} +//======================================================================= +//function : boptuc +//purpose : +//======================================================================= +Standard_Integer boptuc(Draw_Interpretor& di, Standard_Integer n, const char** a) +{ + return bopsmt(di, n, a, BOPAlgo_CUT21); +} +//======================================================================= +//function : bopsection +//purpose : +//======================================================================= +Standard_Integer bopsection(Draw_Interpretor& di, Standard_Integer n, const char** a) +{ + return bopsmt(di, n, a, BOPAlgo_SECTION); +} +//======================================================================= +//function : bopsmt +//purpose : +//======================================================================= +Standard_Integer bopsmt(Draw_Interpretor& di, + Standard_Integer n, + const char** a, + const BOPAlgo_Operation aOp) +{ + if (n<2) { + di << " use bopsmt r\n"; + return 0; } - - return bop(di, n, a+1); + // + if (!pPF) { + di << " prepare PaveFiller first\n"; + return 0; + } + // + if (pPF->ErrorStatus()) { + di << " PaveFiller has not been done\n"; + return 0; + } + // + char buf[64]; + Standard_Integer aNb, iErr; + BOPAlgo_BOP aBOP; + // + const BOPCol_ListOfShape& aLC=pPF->Arguments(); + aNb=aLC.Extent(); + if (aNb!=2) { + sprintf (buf, " wrong number of arguments %s\n", aNb); + di << buf; + return 0; + } + // + const TopoDS_Shape& aS1=aLC.First(); + const TopoDS_Shape& aS2=aLC.Last(); + // + aBOP.AddArgument(aS1); + aBOP.AddTool(aS2); + aBOP.SetOperation(aOp); + // + aBOP.PerformWithFiller(*pPF); + iErr=aBOP.ErrorStatus(); + if (iErr) { + sprintf(buf, " error: %d\n", iErr); + di << buf; + return 0; + } + // + const TopoDS_Shape& aR=aBOP.Shape(); + if (aR.IsNull()) { + di << " null shape\n"; + return 0; + } + // + DBRep::Set(a[1], aR); + return 0; } - //======================================================================= //function : bcommon //purpose : //======================================================================= -Standard_Integer bcommon (Draw_Interpretor& di, - Standard_Integer n, - const char** a) +Standard_Integer bcommon (Draw_Interpretor& di, Standard_Integer n, const char** a) { - Standard_Integer iFlag; - - iFlag =bFillDS (di, n, a); - - if (iFlag) { - return iFlag; - } - - return bopcommon(di, n, a); + return bsmt(di, n, a, BOPAlgo_COMMON); } //======================================================================= //function : bfuse //purpose : //======================================================================= -Standard_Integer bfuse(Draw_Interpretor& di, - Standard_Integer n, - const char** a) +Standard_Integer bfuse (Draw_Interpretor& di, Standard_Integer n, const char** a) { - Standard_Integer iFlag; - - iFlag =bFillDS (di, n, a); - - if (iFlag) { - return iFlag; - } - - return bopfuse(di, n, a); + return bsmt(di, n, a, BOPAlgo_FUSE); } - //======================================================================= //function : bcut //purpose : //======================================================================= -Standard_Integer bcut(Draw_Interpretor& di, - Standard_Integer n, - const char** a) +Standard_Integer bcut (Draw_Interpretor& di, Standard_Integer n, const char** a) { - Standard_Integer iFlag; - - iFlag =bFillDS (di, n, a); - - if (iFlag) { - return iFlag; - } - - return bopcut(di, n, a); + return bsmt(di, n, a, BOPAlgo_CUT); +} +//======================================================================= +//function : btuc +//purpose : +//======================================================================= +Standard_Integer btuc (Draw_Interpretor& di, Standard_Integer n, const char** a) +{ + return bsmt(di, n, a, BOPAlgo_CUT21); } //======================================================================= //function : bsection //purpose : //======================================================================= Standard_Integer bsection(Draw_Interpretor& di, - Standard_Integer n, - const char** a) + Standard_Integer n, + const char** a) { - const char* usage = " Usage: bsection Result s1 s2 [-2d/-2d1/-2d2] [-a]\n"; + const char* usage = " Usage: bsection Result s1 s2 [-n2d/-n2d1/-n2d2] [-na]\n"; if (n < 4) { di << usage; return 1; } - TopoDS_Shape S1 = DBRep::Get(a[2]); - TopoDS_Shape S2 = DBRep::Get(a[3]); + TopoDS_Shape aS1 = DBRep::Get(a[2]); + TopoDS_Shape aS2 = DBRep::Get(a[3]); - if (S1.IsNull() || S2.IsNull()) { + if (aS1.IsNull() || aS2.IsNull()) { di << " Null shapes are not allowed \n"; return 1; } - - BRepAlgoAPI_Section aSec(S1, S2, Standard_False); - aSec.Approximation(Standard_False); - aSec.ComputePCurveOn1(Standard_False); - aSec.ComputePCurveOn2(Standard_False); + BOPAlgo_SectionAttribute aSec(Standard_True, Standard_True, Standard_True); Standard_Boolean isbadparameter = Standard_False; if(n > 4) { const char* key1 = a[4]; const char* key2 = (n > 5) ? a[5] : NULL; const char* pcurveconf = NULL; - Standard_Boolean approx = Standard_False; + Standard_Boolean approx = Standard_True; #ifdef WNT - if (key1 && !strcasecmp(key1,"-2d")) { + if (key1 && (!strcasecmp(key1,"-n2d") || !strcasecmp(key1,"-n2d1") || !strcasecmp(key1,"-n2d2"))) { #else - if (key1 && !strncasecmp(key1,"-2d", 3)) { + if (key1 && (!strncasecmp(key1,"-n2d", 4) || !strncasecmp(key1,"-n2d1", 5) || !strncasecmp(key1,"-n2d2", 5))) { #endif pcurveconf = key1; } else { - if (!strcasecmp(key1,"-a")) { - approx = Standard_True; +#ifdef WNT + if (!strcasecmp(key1,"-na")) { +#else + if(!strncasecmp(key1,"-na", 3)) { +#endif + approx = Standard_False; } else { - isbadparameter = Standard_True; + isbadparameter = Standard_True; } } + if (key2) { #ifdef WNT - if (key2 && !strcasecmp(key2,"-2d")) { + if(!strcasecmp(key2,"-na")) { #else - if (key2 && !strncasecmp(key2,"-2d", 3)) { + if (!strncasecmp(key2,"-na", 3)) { #endif - if(pcurveconf) { - isbadparameter = Standard_True; + approx = Standard_False; } else { - pcurveconf = key2; + isbadparameter = Standard_True; } } - else { - if(key2) { - if (!strcasecmp(key2,"-a")) { - approx = Standard_True; - } - else { - isbadparameter = Standard_True; - } - } - } - - if(!isbadparameter && pcurveconf) { - if (strcasecmp(pcurveconf, "-2d") == 0) { - aSec.ComputePCurveOn1(Standard_True); - aSec.ComputePCurveOn2(Standard_True); + if(!isbadparameter && pcurveconf) { +#ifdef WNT + if (!strcasecmp(pcurveconf, "-n2d1")) { +#else + if (!strncasecmp(pcurveconf, "-n2d1", 5)) { +#endif + aSec.PCurveOnS1(Standard_False); } else { - if (strcasecmp(pcurveconf, "-2d1") == 0) { - aSec.ComputePCurveOn1(Standard_True); - } - else { - if (strcasecmp(pcurveconf, "-2d2") == 0) { - aSec.ComputePCurveOn2(Standard_True); - } - } +#ifdef WNT + if (!strcasecmp(pcurveconf, "-n2d2")) { +#else + if (!strncasecmp(pcurveconf, "-n2d2", 5)) { +#endif + aSec.PCurveOnS2(Standard_False); + } + else { +#ifdef WNT + if (!strcasecmp(pcurveconf, "-n2d")) { +#else + if (!strncasecmp(pcurveconf, "-n2d", 4)) { +#endif + aSec.PCurveOnS1(Standard_False); + aSec.PCurveOnS2(Standard_False); + } + } } } aSec.Approximation(approx); } if(!isbadparameter) { - aSec.Build(); - Standard_Boolean anIsDone = aSec.IsDone(); - - if (anIsDone) { - const TopoDS_Shape& aR = aSec.Shape(); - DBRep::Set (a[1], aR); + BOPCol_ListOfShape aLC; + Handle(NCollection_BaseAllocator)aAL=new NCollection_IncAllocator; + Standard_Integer iErr; + char buf[80]; + // + aLC.Append(aS1); + aLC.Append(aS2); + BOPAlgo_PaveFiller aPF(aAL); + aPF.SetArguments(aLC); + aPF.SetSectionAttribute(aSec); + // + aPF.Perform(); + iErr=aPF.ErrorStatus(); + if (iErr) { + sprintf(buf, " error: %d\n", iErr); + di << buf; + return 0; } - else { - di << "not done ErrorStatus()="<< aSec.ErrorStatus() <<"\n"; + // + BOPAlgo_BOP aBOP; + aBOP.AddArgument(aS1); + aBOP.AddTool(aS2); + aBOP.SetOperation(BOPAlgo_SECTION); + // + aBOP.PerformWithFiller(aPF); + iErr=aBOP.ErrorStatus(); + if (iErr) { + sprintf(buf, " error: %d\n", iErr); + di << buf; + return 0; } + // + const TopoDS_Shape& aR=aBOP.Shape(); + if (aR.IsNull()) { + di << " null shape\n"; + return 0; + } + DBRep::Set(a[1], aR); + return 0; } else { di << usage; @@ -390,1553 +426,245 @@ Standard_Integer bsection(Draw_Interpretor& di, } return 0; } - -//======================================================================= -//function : bopcommon -//purpose : -//======================================================================= -Standard_Integer bopcommon (Draw_Interpretor& di, - Standard_Integer n, - const char** a) -{ - return boperationFiller (n, a, BOP_COMMON, di); -} - -//======================================================================= -//function : bopfuse -//purpose : -//======================================================================= -Standard_Integer bopfuse(Draw_Interpretor& di, - Standard_Integer n, - const char** a) -{ - return boperationFiller (n, a, BOP_FUSE, di); -} - -//======================================================================= -//function : bopcut -//purpose : -//======================================================================= -Standard_Integer bopcut (Draw_Interpretor& di, - Standard_Integer n, - const char** a) -{ - return boperationFiller (n, a, BOP_CUT, di); -} -//======================================================================= -//function : boptuc -//purpose : -//======================================================================= -Standard_Integer boptuc (Draw_Interpretor& di, - Standard_Integer n, - const char** a) -{ - return boperationFiller (n, a, BOP_CUT21, di); -} -//======================================================================= -//function : bopsection -//purpose : -//======================================================================= -Standard_Integer bopsection (Draw_Interpretor& di, - Standard_Integer n, - const char** a) -{ - return boperationFiller (n, a, BOP_SECTION, di); -} - //======================================================================= -//function : boperationFiller +//function : bsmt //purpose : //======================================================================= -Standard_Integer boperationFiller (Standard_Integer n, - const char** a, - const BOP_Operation anOp, - Draw_Interpretor& di) +Standard_Integer bsmt (Draw_Interpretor& di, + Standard_Integer n, + const char** a, + const BOPAlgo_Operation aOp) { - //XX - StartChrono(); - //XX - - if (n<2) { - di << " Use oper> Result [-mf]\n"; - StopChrono(di); - return 1; + char buf[32]; + Standard_Integer iErr; + TopoDS_Shape aS1, aS2; + BOPCol_ListOfShape aLC; + // + if (aOp==BOPAlgo_SECTION) { + if (n<4) { + di << " use bsection r s1 s2\n"; + return 1; + } } - - if (pDF==NULL) { - di << " Prepare BOPTools_DSFiller first >bop S1 S2\n"; - StopChrono(di); + // + else if (n!=4) { + di << " use bx r s1 s2\n"; return 1; } - - const TopoDS_Shape& S1 = pDF->Shape1(); - const TopoDS_Shape& S2 = pDF->Shape2(); - - if (S1.IsNull() || S2.IsNull()) { - di << " Null shapes are not allowed \n"; - StopChrono(di); + // + aS1=DBRep::Get(a[2]); + aS2=DBRep::Get(a[3]); + // + if (aS1.IsNull() || aS2.IsNull()) { + di << " null shapes are not allowed \n"; return 1; } - - Standard_Boolean aMFlag, anIsDone; - - aMFlag=Standard_False; // - BRepAlgoAPI_BooleanOperation* pBuilder=NULL; - // - // SECTION - if (anOp==BOP_SECTION) { - pBuilder=new BRepAlgoAPI_Section(S1, S2, *pDF); - } - else if (anOp==BOP_COMMON) { - pBuilder=new BRepAlgoAPI_Common(S1, S2, *pDF); - } - else if (anOp==BOP_FUSE) { - pBuilder=new BRepAlgoAPI_Fuse(S1, S2, *pDF); - } - else if (anOp==BOP_CUT) { - pBuilder=new BRepAlgoAPI_Cut (S1, S2, *pDF); - } - else if (anOp==BOP_CUT21) { - pBuilder=new BRepAlgoAPI_Cut(S1, S2, *pDF, Standard_False); + aLC.Append(aS1); + aLC.Append(aS2); + // + Handle(NCollection_BaseAllocator)aAL=new NCollection_IncAllocator; + BOPAlgo_PaveFiller aPF(aAL); + // + aPF.SetArguments(aLC); + // + aPF.Perform(); + iErr=aPF.ErrorStatus(); + if (iErr) { + sprintf(buf, " error: %d\n", iErr); + di << buf; + return 0; } // - anIsDone=pBuilder->IsDone(); - if (anIsDone) { - const TopoDS_Shape& aR=pBuilder->Shape(); - DBRep::Set (a[1], aR); + BOPAlgo_BOP aBOP; + // + aBOP.AddArgument(aS1); + aBOP.AddTool(aS2); + aBOP.SetOperation(aOp); + // + aBOP.PerformWithFiller(aPF); + iErr=aBOP.ErrorStatus(); + if (iErr) { + sprintf(buf, " error: %d\n", iErr); + di << buf; + return 0; } - else { - di << "not done ErrorStatus()=" << pBuilder->ErrorStatus() << "\n"; + // + const TopoDS_Shape& aR=aBOP.Shape(); + if (aR.IsNull()) { + di << " null shape\n"; + return 0; } - - delete pBuilder; - - StopChrono(di); - + DBRep::Set(a[1], aR); return 0; } //======================================================================= -// OTHER FUNCTIONS -// -static - void GetName (const BooleanOperations_StateOfShape aState, - TCollection_AsciiString& aNm); -static - TopAbs_ShapeEnum ChooseShapeType(const char* a1); - -static - BooleanOperations_StateOfShape ChooseShapeState(const char* a3); - -//======================================================================= -//function : bopstates +//function : bopnews //purpose : //======================================================================= -Standard_Integer bopstates(Draw_Interpretor& di, - Standard_Integer n, - const char** a) +Standard_Integer bopnews (Draw_Interpretor& di, + Standard_Integer n, + const char** a) { - if (n>4) { - di << " Use bopstates [-f] [-t] [-out]\n"; - return 1; + if (n!=2) { + di << " use bopnews -v[e,f]\n"; + return 0; } - - if (pDF==NULL) { - di << " Prepare BOPTools_DSFiller first >bop S1 S2\n"; + // + if (pPF==NULL) { + di << " Prepare BOPAlgo_PaveFiller first >bop S1 S2\n"; return 0; } - - Standard_Integer i, aNbLines, aIsSmtToDraw=0; - BooleanOperations_StateOfShape aState, aChooseState; - aChooseState=BooleanOperations_UNKNOWN; - TopAbs_ShapeEnum aEnumToDisplay = TopAbs_COMPOUND; + // + char buf[32]; + Standard_CString aText; + Standard_Integer i, i1, i2, iFound; Draw_Color aTextColor(Draw_cyan); + TopAbs_ShapeEnum aT; + Handle(BOPTest_DrawableShape) aDShape; // - const BooleanOperations_ShapesDataStructure& aDS=pDF->DS(); + const BOPDS_PDS& pDS=pPF->PDS(); // - // Choose Object or Tool or All - i=1; - aNbLines=aDS.NumberOfSourceShapes(); - if (n>=3) { - if (!strcmp (a[2], "-o")) { - aDS.ObjectRange(i, aNbLines); - } - if (!strcmp (a[2], "-t")) { - aDS.ToolRange(i, aNbLines); - } + aT=TopAbs_SHAPE; + if (!strcmp (a[1], "-f")) { + aT=TopAbs_FACE; } - // - // ChooseShapeState - if (n==4) { - aChooseState=ChooseShapeState(a[3]); + else if (!strcmp (a[1], "-e")){ + aT=TopAbs_EDGE; } - // - // ChooseShapeType - if (n==1) { - aEnumToDisplay=TopAbs_EDGE; + else if (!strcmp (a[1], "-v")){ + aT=TopAbs_VERTEX; } - else if (n>1) { - aEnumToDisplay=ChooseShapeType(a[1]); + else { + di << " use bopnews -v[e,f]\n"; + return 0; } // - // Presentation - for (; i<=aNbLines; ++i) { - const TopoDS_Shape& aS=aDS.GetShape(i); - TopAbs_ShapeEnum aCurrentType=aS.ShapeType(); - if (aCurrentType==aEnumToDisplay) { - aState=aDS.GetState(i); - TCollection_AsciiString aNm, aInd(i); - GetName(aState, aNm); - - if (aState==BooleanOperations_INTERSECTED && aCurrentType==TopAbs_EDGE) { - - const BOPTools_SplitShapesPool& aSpPool=pDF->SplitShapesPool(); - const BOPTools_ListOfPaveBlock& aSplitsList=aSpPool(aDS.RefEdge(i)); - BOPTools_ListIteratorOfListOfPaveBlock anIt(aSplitsList); - for (; anIt.More();anIt.Next()) { - const BOPTools_PaveBlock& aPB=anIt.Value(); - Standard_Integer nSplit=aPB.Edge(); - const TopoDS_Shape& aSplit=aDS.GetShape(nSplit); - aState=aDS.GetState(nSplit); - GetName(aState, aNm); - aNm=aNm+aInd; - TCollection_AsciiString aNmx, anUnd("_"), aIndx(nSplit); - aNmx=aNm+anUnd; - aNmx=aNmx+aIndx; - - Standard_CString aTxt=aNmx.ToCString(); - - if (aChooseState!=BooleanOperations_UNKNOWN) { - if (aState!=aChooseState) { - continue; - } - } - aIsSmtToDraw++; - //printf("%s ", aTxt); - di << aTxt << " "; - Handle(BOPTest_DrawableShape) aDSh= - new BOPTest_DrawableShape (aSplit, aTxt, aTextColor); - Draw::Set (aTxt, aDSh); - } - continue; - } - - aNm=aNm+aInd; - Standard_CString aText=aNm.ToCString(); - - if (aChooseState!=BooleanOperations_UNKNOWN) { - if (aState!=aChooseState) { - continue; - } - } - aIsSmtToDraw++; - //printf("%s ", aText); - di << aText << " "; - Handle(BOPTest_DrawableShape) aDShape= - new BOPTest_DrawableShape (aS, aText, aTextColor); + iFound=0; + i1=pDS->NbSourceShapes(); + i2=pDS->NbShapes(); + for (i=i1; iShapeInfo(i); + if (aSI.ShapeType()==aT) { + const TopoDS_Shape& aS=aSI.Shape(); + // + sprintf (buf, "z%d", i); + aText=buf; + aDShape=new BOPTest_DrawableShape (aS, aText, aTextColor); Draw::Set (aText, aDShape); + // + sprintf (buf, " z%d", i); + di << buf; + // + iFound=1; } } - - if (!aIsSmtToDraw) { - di << " No specified shapes\n"; - } - else { + // + if (iFound) { di << "\n"; } - - - return 0; -} - -//======================================================================= -//function : GetName -//purpose : -//======================================================================= -void GetName (const BooleanOperations_StateOfShape aState, - TCollection_AsciiString& aNm) -{ - TCollection_AsciiString aNmOut("ou_"), aNmIn("in_"), - aNmOn("on_"), aNmUn("un_"), aNmInter("intr_"); - - switch (aState) { - case BooleanOperations_OUT: - aNm=aNmOut; - break; - case BooleanOperations_IN: - aNm=aNmIn; - break; - case BooleanOperations_ON: - aNm=aNmOn; - break; - case BooleanOperations_INTERSECTED: - aNm=aNmInter; - break; - default: - aNm=aNmUn; - break; - } -} - -//======================================================================= -//function : ChooseShapeType -//purpose : -//======================================================================= -TopAbs_ShapeEnum ChooseShapeType(const char* a1) -{ - TopAbs_ShapeEnum aEnumToDisplay; - - if (!strcmp (a1, "-c")) { - aEnumToDisplay=TopAbs_COMPOUND; - } - else if (!strcmp (a1, "-cs")) { - aEnumToDisplay=TopAbs_COMPSOLID; - } - else if (!strcmp (a1, "-s")) { - aEnumToDisplay=TopAbs_SOLID; - } - else if (!strcmp (a1, "-sh")) { - aEnumToDisplay=TopAbs_SHELL; - } - else if (!strcmp (a1, "-f")) { - aEnumToDisplay=TopAbs_FACE; - } - else if (!strcmp (a1, "-w")) { - aEnumToDisplay=TopAbs_WIRE; - } - else if (!strcmp (a1, "-e")) { - aEnumToDisplay=TopAbs_EDGE; - } - else if (!strcmp (a1, "-v")) { - aEnumToDisplay=TopAbs_VERTEX; - } else { - aEnumToDisplay=TopAbs_EDGE; + di << " not found\n"; } - return aEnumToDisplay; -} - -//======================================================================= -//function : ChooseShapeState -//purpose : -//======================================================================= -BooleanOperations_StateOfShape ChooseShapeState(const char* a3) -{ - BooleanOperations_StateOfShape aChooseState=BooleanOperations_UNKNOWN; - - if (!strcmp (a3, "-out")) { - aChooseState=BooleanOperations_OUT; - } - if (!strcmp (a3, "-in")) { - aChooseState=BooleanOperations_IN; - } - if (!strcmp (a3, "-on")) { - aChooseState=BooleanOperations_ON; - } - return aChooseState; -} -//XX -// CHRONOMETER -// -#include -#include -#include -#include -#include -#include - -static void SaveTimeInFile(const Standard_CString aFileName, - const Standard_Real aChrono, - Draw_Interpretor& di); - -//======================================================================= -//function : StartChrono -//purpose : -//======================================================================= -void StartChrono() -{ - char *xr=getenv ("BOPCHRONO"); - if (xr!=NULL){ - if (!strcmp (xr, "yes")){ - DRAW_BOP_CHRONO.Reset(); - DRAW_BOP_CHRONO.Start(); - } - } -} - -//======================================================================= -//function : StopChrono -//purpose : -//======================================================================= -void StopChrono(Draw_Interpretor& di) -{ - char *xr=getenv ("BOPCHRONO"); - if (xr!=NULL){ - if (!strcmp (xr, "yes")) { - Standard_Real Chrono; - DRAW_BOP_CHRONO.Stop(); - DRAW_BOP_CHRONO.Show(Chrono); - // - char *aFileName=getenv("BOPCHRONOFILE"); - if (aFileName!=NULL){ - SaveTimeInFile(aFileName, Chrono, di); - } - else { - di << "Tps: " << Chrono << "\n"; - } - // - } - } -} -//======================================================================= -//function : SaveTimeInFile -//purpose : -//======================================================================= -void SaveTimeInFile(const Standard_CString aFileName, - const Standard_Real aChrono, - Draw_Interpretor& di) -{ - OSD_OpenMode aMode = OSD_ReadWrite; - OSD_Protection aProtect(OSD_RW,OSD_RW,OSD_RW,OSD_RW); - TCollection_AsciiString anASName(aFileName); - OSD_Path aPath (anASName); - OSD_File aFile (aPath); - aFile.Append(aMode, aProtect); - if (!( aFile.Exists() && aFile.IsOpen())) { - Standard_CString aStr=anASName.ToCString(); - di << "Can not open the file: " << aStr << "\n"; - return; - } - TCollection_AsciiString aASTime(aChrono), aASendl("\n"); - aASTime=aASTime+aASendl; - aFile.Write (aASTime, aASTime.Length()); - aFile.Close(); -} -//XX -//======================================================================= -//function : btimesum -//purpose : -//======================================================================= -Standard_Integer btimesum (Draw_Interpretor& di, - Standard_Integer n, - const char** a) -{ - if (n!=2) { - di << " Use >btimesum FileName\n"; - return 1; - } - - TCollection_AsciiString anASName(a[1]); - OSD_OpenMode aMode = OSD_ReadWrite; - OSD_Protection aProtect(OSD_RW,OSD_RW,OSD_RW,OSD_RW); - OSD_Path aPath (anASName); - OSD_File aFile (aPath); - aFile.Open(aMode, aProtect); - - if (!( aFile.Exists() && aFile.IsOpen())) { - Standard_CString aStr=anASName.ToCString(); - di << "Can not open the file: " << aStr << "\n"; - return 1; - } - - Standard_Integer aNbyteRead, aNByte=256, pos; - Standard_Real aTC, aTime=0.; - while (1) { - if (aFile.IsAtEnd()) { - break; - } - - TCollection_AsciiString aStr(aNByte); - aFile.ReadLine(aStr, aNByte, aNbyteRead); - //Standard_CString pStr=aStr.ToCString(); - - pos=aStr.Search("\n"); - if (pos>0){ - aStr.Trunc(pos-1); - } - - if (aStr.IsRealValue()) { - aTC=aStr.RealValue(); - aTime=aTime+aTC; - } - } - aFile.Close(); // - aFile.Append(aMode, aProtect); - - TCollection_AsciiString aASLine("----------\n"), aASTime(aTime), aASendl("\n"); - aASTime=aASTime+aASendl; - aFile.Write (aASLine, aASLine.Length()); - aFile.Write (aASTime, aASTime.Length()); - aFile.Close(); - return 0; } - -//======================================================================= -// -// ex. BOPTest_TSTCommands -// -#include - -#include - -#include -#include - -#include -#include - -#include - -#include -#include - - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - - -static Standard_Integer bopinterf (Draw_Interpretor&, Standard_Integer, const char**); -static Standard_Integer bopds (Draw_Interpretor&, Standard_Integer, const char**); -static Standard_Integer bopsplits (Draw_Interpretor&, Standard_Integer, const char**); -static Standard_Integer bopscts (Draw_Interpretor&, Standard_Integer, const char**); -static Standard_Integer bopsamedomain(Draw_Interpretor&, Standard_Integer, const char**); -static Standard_Integer bopaves (Draw_Interpretor&, Standard_Integer, const char**); -static Standard_Integer bopsinf (Draw_Interpretor&, Standard_Integer, const char**); -static Standard_Integer bopsonf (Draw_Interpretor&, Standard_Integer, const char**); -static Standard_Integer bopnews (Draw_Interpretor& ,Standard_Integer, const char**); - //======================================================================= -//function : TSTCommands +//function : bopcurves //purpose : //======================================================================= - void BOPTest::TSTCommands(Draw_Interpretor& theCommands) +Standard_Integer bopcurves (Draw_Interpretor& di, + Standard_Integer n, + const char** a) { - static Standard_Boolean done = Standard_False; - if (done) return; - done = Standard_True; - // Chapter's name - const char* g = "CCR commands"; - // - theCommands.Add("bopinterf" , "", __FILE__, bopinterf, g); - theCommands.Add("bopds" , "Use bopds [-sw]", __FILE__, bopds, g); - - theCommands.Add("bopsplits" , "", __FILE__, bopsplits, g); - theCommands.Add("bopscts" , "", __FILE__, bopscts, g); - - theCommands.Add("bopsamedomain" , "", __FILE__, bopsamedomain, g);//SameDomain Edges - theCommands.Add("bopaves" , "", __FILE__, bopaves, g); - theCommands.Add("bopnews" , "bopnews [-f,w,e,v]", __FILE__, bopnews, g); - // - // All Splits of face1 IN face2 - theCommands.Add("bopsinf" , "Use bopsinf #F1 #F2", __FILE__, bopsinf, g); - // - // All Splits of face1 ON face2 - theCommands.Add("bopsonf" , "Use bopsinf #F1 #F2", __FILE__, bopsonf, g); -} - - -//======================================================================= -//function : bopinterf -//purpose : -//======================================================================= -Standard_Integer bopinterf (Draw_Interpretor& di, - Standard_Integer /*n*/, - const char** /*a*/) -{ - if (pDF==NULL) { - di << " Prepare BOPTools_DSFiller first >bop S1 S2\n"; - return 0; + if (n<3) { + di << " use bopcurves F1 F2\n"; + return 1; } - Standard_Integer i, aNbLines; - // - // InterferenceTable - Standard_Integer aWith, anIndex, aFst, aLF; - BooleanOperations_KindOfInterference aType; + TopoDS_Shape S1 = DBRep::Get(a[1]); + TopoDS_Shape S2 = DBRep::Get(a[2]); + TopAbs_ShapeEnum aType; - const BOPTools_InterferencePool& anInterferencePool=pDF->InterfPool(); - const BOPTools_CArray1OfInterferenceLine& aTableIL=anInterferencePool.InterferenceTable(); - - aNbLines=aTableIL.Extent(); - for (i=1; i<=aNbLines; ++i) { - aFst=0; - aLF=0; - const BOPTools_InterferenceLine& aIL=aTableIL(i); - const BOPTools_ListOfInterference& aIList=aIL.List(); - BOPTools_ListIteratorOfListOfInterference anIt(aIList); - for (; anIt.More(); anIt.Next()) { - const BOPTools_Interference& anInterf=anIt.Value(); - aWith=anInterf.With(); - aType=anInterf.Type(); - anIndex=anInterf.Index(); - if (anIndex) { - if (aFst==0){ - //printf(" #%d ", i); - di << " #" << i << " "; - aFst=1; - } - aLF=1; - //printf("(%d, %d, %d),", aWith, aType, anIndex); - di << "(" << aWith << ", " << aType << ", " << anIndex << "),"; - } - } - if (aLF) { - //printf("\n"); - di << "\n"; - } + if (S1.IsNull() || S2.IsNull()) { + di << " Null shapes is not allowed \n"; + return 1; } - return 0; -} -//======================================================================= -//function : bopds -//purpose : -//======================================================================= -Standard_Integer bopds (Draw_Interpretor& di, - Standard_Integer n, - const char** a) -{ - if (pDF==NULL) { - di << " Prepare BOPTools_DSFiller first >bop S1 S2\n"; - return 0; + aType=S1.ShapeType(); + if (aType != TopAbs_FACE) { + di << " Type mismatch F1\n"; + return 1; } - - const BooleanOperations_ShapesDataStructure& aDS=pDF->DS(); - Standard_Integer i, aNbLines; - - i=1; - aNbLines=aDS.NumberOfSourceShapes(); - - if (n==3) { - if (!strcmp (a[2], "-o")) { - aDS.ObjectRange(i, aNbLines); - } - if (!strcmp (a[2], "-t")) { - aDS.ToolRange(i, aNbLines); - } + aType=S2.ShapeType(); + if (aType != TopAbs_FACE) { + di << " Type mismatch F2\n"; + return 1; } - Draw_Color aTextColor(Draw_cyan); - TCollection_AsciiString aNm("z"); - - for (; i<=aNbLines; ++i) { - - const TopoDS_Shape& aS=aDS.GetShape(i); - // - // Prestentation - TopAbs_ShapeEnum aType=aS.ShapeType(); - if (n==1) { - if (aType==TopAbs_COMPOUND || - aType==TopAbs_COMPSOLID || - aType==TopAbs_SOLID || - aType==TopAbs_SHELL || - aType==TopAbs_FACE || - aType==TopAbs_WIRE) { - continue; - } - } - - if (n>=2) { - if (!strcmp (a[1], "-c")) { - if (aType!=TopAbs_COMPOUND) { - continue; - } - } - else if (!strcmp (a[1], "-cs")) { - if (aType!=TopAbs_COMPSOLID) { - continue; - } - } - else if (!strcmp (a[1], "-s")) { - if (aType!=TopAbs_SOLID) { - continue; - } - } - else if (!strcmp (a[1], "-sh")) { - if (aType!=TopAbs_SHELL) { - continue; - } - } - else if (!strcmp (a[1], "-f")) { - if (aType!=TopAbs_FACE) { - continue; - } - } - else if (!strcmp (a[1], "-w")) { - if (aType!=TopAbs_WIRE) { - continue; - } - } - else if (!strcmp (a[1], "-e")) { - if (aType!=TopAbs_EDGE) { - continue; - } - } - else if (!strcmp (a[1], "-v")) { - if (aType!=TopAbs_VERTEX) { - continue; - } - } - else { - continue; - } - } - - TCollection_AsciiString aInd(i), aName; - aName=aNm+aInd; - Standard_CString aText=aName.ToCString(); - Handle(BOPTest_DrawableShape) aDShape= - new BOPTest_DrawableShape (aS, aText, aTextColor); - Draw::Set (aText, aDShape); - } - return 0; -} + const TopoDS_Face& aF1=*(TopoDS_Face*)(&S1); + const TopoDS_Face& aF2=*(TopoDS_Face*)(&S2); -//======================================================================= -//function : bopaves -//purpose : -//======================================================================= -Standard_Integer bopaves(Draw_Interpretor& di, - Standard_Integer /*n*/, - const char** /*a*/) -{ - if (pDF==NULL) { - di << " Prepare BOPTools_DSFiller first >bop S1 S2\n"; - return 0; - } - Standard_Integer i, aNbLines, anIndex; - Standard_Real aParam; + Standard_Boolean aToApproxC3d, aToApproxC2dOnS1, aToApproxC2dOnS2, anIsDone; + Standard_Integer i, aNbCurves; + Standard_Real anAppTol, aTolR; + TCollection_AsciiString aNm("c_"); - const BooleanOperations_ShapesDataStructure& aDS=pDF->DS(); - const BOPTools_PavePool& aPavePool=pDF->PavePool(); + aToApproxC3d=Standard_True; + aToApproxC2dOnS1=Standard_False; + aToApproxC2dOnS2=Standard_False; + anAppTol=0.0000001; - aNbLines=aDS.NumberOfSourceShapes(); - for (i=1; i<=aNbLines; ++i) { - const TopoDS_Shape& aS=aDS.GetShape(i); - if (aS.ShapeType()==TopAbs_EDGE) { - //printf(" Edge#%d\n", i); - di << " Edge#" << i << "\n"; - const BOPTools_PaveSet& aPaveSet=aPavePool(aDS.RefEdge(i)); - const BOPTools_ListOfPave& aLP= aPaveSet.Set(); - BOPTools_ListIteratorOfListOfPave anIt(aLP); - for (; anIt.More(); anIt.Next()){ - const BOPTools_Pave& aPave=anIt.Value(); - anIndex=aPave.Index(); - aParam =aPave.Param(); - //printf(" VertIndex=%d, aParam=%f\n", anIndex, aParam); - di << " VertIndex=" << anIndex << ", aParam=" << aParam << "\n"; - } - } - } - return 0; -} -//======================================================================= -//function : bopsd -//purpose : SameDomain Edges -//======================================================================= -Standard_Integer bopsamedomain (Draw_Interpretor& di, - Standard_Integer /*n*/, - const char** /*a*/) -{ - if (pDF==NULL) { - di << " Prepare BOPTools_DSFiller first >bop S1 S2\n"; - return 0; - } - TCollection_AsciiString aNm("s"); + IntTools_FaceFace aFF; - const BooleanOperations_ShapesDataStructure& aDS=pDF->DS(); - const BOPTools_CommonBlockPool& aCommonBlockPool=pDF->CommonBlockPool(); - - Standard_Integer i, aNbLines, nFSD, nESD1, nESD2, nOriginal2; - - aNbLines=aDS.NumberOfSourceShapes(); - for (i=1; i<=aNbLines; ++i) { - const TopoDS_Shape& aSE=aDS.GetShape(i); - TopAbs_ShapeEnum aType=aSE.ShapeType(); - if (aType==TopAbs_EDGE) { - - const BOPTools_ListOfCommonBlock& aLCB=aCommonBlockPool(aDS.RefEdge(i)); - - if (aLCB.Extent()) { - // - BOPTools_ListIteratorOfListOfCommonBlock anIt(aLCB); - for (; anIt.More(); anIt.Next()) { - const BOPTools_CommonBlock& aCB=anIt.Value(); - nFSD=aCB.Face(); - if (nFSD) { - const BOPTools_PaveBlock& aPB1=aCB.PaveBlock1(); - nESD1=aPB1.Edge(); - - TCollection_AsciiString aInd(i), anUnd("_"), aName; - aName=aNm+aInd; - aName=aName+anUnd; - aName=aName+nESD1; - Standard_CString aText=aName.ToCString(); - - //printf(" (EF %s %df),", aText, nFSD); - di << " (EF " << aText << " " << nFSD << "f),"; - } - - else { - const BOPTools_PaveBlock& aPB1=aCB.PaveBlock1(); - nESD1=aPB1.Edge(); - - TCollection_AsciiString aInd(i), anUnd("_"), aName; - aName=aNm+aInd; - aName=aName+anUnd; - aName=aName+nESD1; - Standard_CString aText=aName.ToCString(); - - const BOPTools_PaveBlock& aPB2=aCB.PaveBlock2(); - nESD2=aPB2.Edge(); - nOriginal2=aPB2.OriginalEdge(); - - TCollection_AsciiString aInd2(nOriginal2), aName2; - aName2=aNm+aInd2; - aName2=aName2+anUnd; - aName2=aName2+nESD2; - Standard_CString aText2=aName2.ToCString(); - - //printf(" (EE %s %s ),", aText, aText2); - di << " (EE " << aText << " " << aText2 << " ),"; - } - } - //printf("\n"); - di << "\n"; - } - } - } - return 0; -} -//======================================================================= -//function : bopnews -//purpose : -//======================================================================= -Standard_Integer bopnews (Draw_Interpretor& di, - Standard_Integer n, - const char** a) - -{ - if (pDF==NULL) { - di << " Prepare BOPTools_DSFiller first >bop S1 S2\n"; - return 0; - } - - const BooleanOperations_ShapesDataStructure& aDS=pDF->DS(); - - Standard_Integer i, iStart, aNbLinesTotal; - Draw_Color aTextColor(Draw_cyan); - TCollection_AsciiString aNm("z"); - // - - TopAbs_ShapeEnum aType=TopAbs_EDGE; - if (n>1) { - if (!strcmp (a[1], "-f")) { - aType=TopAbs_FACE; - } - else if (!strcmp (a[1], "-w")) { - aType=TopAbs_WIRE; - } - else if (!strcmp (a[1], "-e")) { - aType=TopAbs_EDGE; - } - else if (!strcmp (a[1], "-v")) { - aType=TopAbs_VERTEX; - } - } + aFF.SetParameters (aToApproxC3d, + aToApproxC2dOnS1, + aToApproxC2dOnS2, + anAppTol); - // - iStart=aDS.NumberOfSourceShapes()+1; - aNbLinesTotal =aDS.NumberOfInsertedShapes(); - - for (i=iStart; i<=aNbLinesTotal; ++i) { - const TopoDS_Shape& aS=aDS.Shape(i); - TopAbs_ShapeEnum aTypeCurrent=aS.ShapeType(); - if (aTypeCurrent==aType) { - TCollection_AsciiString aName, aInd(i); - aName=aNm+aInd; - Standard_CString aText=aName.ToCString(); - - Handle(BOPTest_DrawableShape) aDShape= - new BOPTest_DrawableShape (aS, aText, aTextColor); - Draw::Set (aText, aDShape); - //printf("%s ", aText); - di << aText << " "; - } - } + aFF.Perform (aF1, aF2); - if (iStart>aNbLinesTotal) { - di << " No new shapes occured"; + anIsDone=aFF.IsDone(); + if (!anIsDone) { + di << " anIsDone=" << (Standard_Integer) anIsDone << "\n"; + return 1; } - di << "\n"; - return 0; -} + aFF.PrepareLines3D(); + const IntTools_SequenceOfCurves& aSCs=aFF.Lines(); -//======================================================================= -//function : bopsplits -//purpose : -//======================================================================= -Standard_Integer bopsplits (Draw_Interpretor& di, - Standard_Integer /*n*/, - const char** /*a*/) + // + aTolR=aFF.TolReached3d(); + di << "Tolerance Reached=" << aTolR << "\n"; -{ - if (pDF==NULL) { - di << " Prepare BOPTools_DSFiller first >bop S1 S2\n"; - return 0; + aNbCurves=aSCs.Length(); + if (!aNbCurves) { + di << " has no 3d curve\n"; + return 1; } - const BOPTools_SplitShapesPool& aSpPool=pDF->SplitShapesPool(); - const BooleanOperations_ShapesDataStructure& aDS=pDF->DS(); + for (i=1; i<=aNbCurves; i++) { + const IntTools_Curve& anIC=aSCs(i); - Standard_Integer i, aNbLines, aNbSplits, aSplitExist=0; - Draw_Color aTextColor(Draw_cyan); - TCollection_AsciiString aNm("s"); + Handle (Geom_Curve) aC3D=anIC.Curve(); - aNbLines=aDS.NumberOfSourceShapes(); - for (i=1; i<=aNbLines; ++i) { - const TopoDS_Shape& aSE=aDS.GetShape(i); - TopAbs_ShapeEnum aType=aSE.ShapeType(); - if (aType==TopAbs_EDGE) { - // - // Splits' Prestentation - const BOPTools_ListOfPaveBlock& aSplitsList=aSpPool(aDS.RefEdge(i)); - aNbSplits=aSplitsList.Extent(); - if (aNbSplits) { - if (!aSplitExist) { - di << " Splits: "; - aSplitExist=1; - } - - BOPTools_ListIteratorOfListOfPaveBlock anIt(aSplitsList); - for (; anIt.More();anIt.Next()) { - const BOPTools_PaveBlock& aPB=anIt.Value(); - Standard_Integer nSplit=aPB.Edge(); - const TopoDS_Shape& aS=aDS.GetShape(nSplit); - - TCollection_AsciiString aInd(i), anUnd("_"), aName; - aName=aNm+aInd; - aName=aName+anUnd; - aName=aName+nSplit; - Standard_CString aText=aName.ToCString(); - - Handle(BOPTest_DrawableShape) aDShape= - new BOPTest_DrawableShape (aS, aText, aTextColor); - Draw::Set (aText, aDShape); - di << aText << " "; - } - } + if (aC3D.IsNull()) { + di << " has Null 3d curve# " << i << "%d\n"; + continue; } - } - - if (!aSplitExist) { - di << " No splits occured"; - } - di << "\n"; - return 0; -} - -//======================================================================= -//function : bopscts -//purpose : -//======================================================================= -Standard_Integer bopscts (Draw_Interpretor& di, - Standard_Integer /*n*/, - const char** /*a*/) -{ - if (pDF==NULL) { - di << " Prepare BOPTools_DSFiller first >bop S1 S2\n"; - return 0; + TCollection_AsciiString anIndx(i), aNmx; + aNmx=aNm+anIndx; + Standard_CString name= aNmx.ToCString(); + DrawTrSurf::Set(name, aC3D); + di << name << " "; } - Standard_Integer i, nF1, nF2, aNbFFs, aNbOldSects, aSectExist=0, nSect; - Standard_Integer j, aNbCurves, aNbPaveBlocks, nNewEdge; - Draw_Color aTextColor(Draw_cyan); - TCollection_AsciiString aNm("t"); - - const BooleanOperations_ShapesDataStructure& aDS=pDF->DS(); - const BOPTools_InterferencePool& anInterfPool=pDF->InterfPool(); - BOPTools_InterferencePool* pInterfPool= (BOPTools_InterferencePool*) &anInterfPool; - BOPTools_CArray1OfSSInterference& aFFs=pInterfPool->SSInterferences(); - - aNbFFs=aFFs.Extent(); - for (i=1; i<=aNbFFs; ++i) { - BOPTools_SSInterference& aFFi=aFFs(i); - // - nF1=aFFi.Index1(); - nF2=aFFi.Index2(); - TCollection_AsciiString aInd(nF1), anUnd("_"); - // - // Old Section Edges - const BOPTools_ListOfPaveBlock& aSectList=aFFi.PaveBlocks(); - aNbOldSects=aSectList.Extent(); - if (aNbOldSects) { - if (!aSectExist) { - di << " Sects: "; - aSectExist=1; - } - BOPTools_ListIteratorOfListOfPaveBlock anIt(aSectList); - for (; anIt.More();anIt.Next()) { - const BOPTools_PaveBlock& aPB=anIt.Value(); - nSect=aPB.Edge(); - const TopoDS_Shape& aS=aDS.GetShape(nSect); - - TCollection_AsciiString aName; - aName=aNm+aInd; - aName=aName+anUnd; - aName=aName+nSect; - Standard_CString aText=aName.ToCString(); - - Handle(BOPTest_DrawableShape) aDShape= - new BOPTest_DrawableShape (aS, aText, aTextColor); - Draw::Set (aText, aDShape); - di << aText << " "; - } - } - // - // New Section Edges - BOPTools_SequenceOfCurves& aBCurves=aFFi.Curves(); - aNbCurves=aBCurves.Length(); - for (j=1; j<=aNbCurves; j++) { - BOPTools_Curve& aBC=aBCurves(j); - const BOPTools_ListOfPaveBlock& aSectEdges=aBC.NewPaveBlocks(); - aNbPaveBlocks=aSectEdges.Extent(); - if (aNbPaveBlocks) { - if (!aSectExist) { - di << " Sects: "; - aSectExist=1; - } - } - BOPTools_ListIteratorOfListOfPaveBlock aPBIt(aSectEdges); - for (; aPBIt.More(); aPBIt.Next()) { - BOPTools_PaveBlock& aPB=aPBIt.Value(); - nNewEdge=aPB.Edge(); - const TopoDS_Shape& aSectEdge=aDS.GetShape(nNewEdge); - - TCollection_AsciiString aName; - aName=aNm+aInd; - aName=aName+anUnd; - aName=aName+nNewEdge; - Standard_CString aText=aName.ToCString(); - - Handle(BOPTest_DrawableShape) aDShape= - new BOPTest_DrawableShape (aSectEdge, aText, aTextColor); - Draw::Set (aText, aDShape); - di << aText << " "; - } - } - } - - if (!aSectExist) { - di << " No section edges"; - } di << "\n"; - return 0; -} - -//======================================================================= -//function : bopsinf -//purpose : -//======================================================================= -Standard_Integer bopsinf (Draw_Interpretor& di, - Standard_Integer n, - const char** a) -{ - if (pDF==NULL) { - di << " Prepare BOPTools_DSFiller first >bop S1 S2\n"; - return 0; - } - - if (n!=3) { - di << " Use: bopsinf> #F1 #F2\n"; - return 0; - } - - const BooleanOperations_ShapesDataStructure& aDS=pDF->DS(); - - Standard_Integer nSp=0, nF1, nF2, anExistFlag=0; - nF1=atoi(a[1]); - nF2=atoi(a[2]); - - const TopoDS_Shape& aS1=aDS.GetShape(nF1); - const TopoDS_Shape& aS2=aDS.GetShape(nF2); - if (aS1.IsNull() || aS2.IsNull()) { - //printf(" Null shapes #%d #%d\n", nF1, nF2 ); - di << " Null shapes #" << nF1 << " #" << nF2 << "\n"; - return 0; - } - - if (aS1.ShapeType()!=TopAbs_FACE || - aS2.ShapeType()!=TopAbs_FACE ) { - //printf(" Shapes #%d #%d are not faces\n", nF1, nF2 ); - di << " Shapes #" << nF1 << " #" << nF2 << " are not faces\n"; - return 0; - } - - TColStd_ListOfInteger aSplList; - const BOPTools_PaveFiller& aPF=pDF->PaveFiller(); - BOPTools_PaveFiller* pPF=(BOPTools_PaveFiller*)&aPF; - - pPF->SplitsInFace (nSp, nF1, nF2, aSplList); - - TColStd_ListIteratorOfListOfInteger anIt (aSplList); - for (; anIt.More(); anIt.Next()) { - anExistFlag=1; - nSp=anIt.Value(); - //printf("%d, ", nSp); - di << nSp << ", "; - } - - if(anExistFlag) { - di << "\n"; - } - else { - di << "No splits of Face" << nF1 << " IN Face " << nF2 << "\n"; - } - -return 0; -} -//======================================================================= -//function : bopsonf -//purpose : -//======================================================================= -Standard_Integer bopsonf (Draw_Interpretor& di, - Standard_Integer n, - const char** a) -{ - if (pDF==NULL) { - di << " Prepare BOPTools_DSFiller first >bop S1 S2\n"; - return 0; - } - - if (n!=3) { - di << " Use: bopsonf> #F1 #F2\n"; - return 0; - } - - const BooleanOperations_ShapesDataStructure& aDS=pDF->DS(); - - Standard_Integer nSp=0, nF1, nF2, anExistFlag=0; - nF1=atoi(a[1]); - nF2=atoi(a[2]); - - const TopoDS_Shape& aS1=aDS.GetShape(nF1); - const TopoDS_Shape& aS2=aDS.GetShape(nF2); - if (aS1.IsNull() || aS2.IsNull()) { - //printf(" Null shapes #%d #%d\n", nF1, nF2 ); - di << " Null shapes #" << nF1 << " #" << nF2 << "\n"; - return 0; - } - if (aS1.ShapeType()!=TopAbs_FACE || - aS2.ShapeType()!=TopAbs_FACE ) { - //printf(" Shapes #%d #%d are not faces\n", nF1, nF2 ); - di << " Shapes #" << nF1 << " #" << nF2 << " are not faces\n"; - return 0; - } - - TColStd_ListOfInteger aSplList; - const BOPTools_PaveFiller& aPF=pDF->PaveFiller(); - BOPTools_PaveFiller* pPF=(BOPTools_PaveFiller*)&aPF; - - pPF->SplitsOnFace (nSp, nF1, nF2, aSplList); - - TColStd_ListIteratorOfListOfInteger anIt (aSplList); - for (; anIt.More(); anIt.Next()) { - anExistFlag=1; - nSp=anIt.Value(); - //printf("%d, ", nSp); - di << nSp << ", "; - } - - if(anExistFlag) { - di << "\n"; - } - else { - di << "No splits of Face" << nF1 << " ON Face " << nF2 << "\n"; - } - - return 0; -} - -//======================================================================= -//function : bopwho -//purpose : -//======================================================================= -Standard_Integer bopwho (Draw_Interpretor& di, - Standard_Integer n, - const char** a) -{ - if (pDF==NULL) { - di << " Prepare BOPTools_DSFiller first >bop S1 S2\n"; - return 0; - } - - if (n!=2) { - di << " Use >bopwho Index\n"; - return 1; - } - // - Standard_Boolean bIsNewShape; - Standard_Integer iNum, i, aNbLines, aNbObj, aNewShape, aWhat, aWith; - // - iNum=atoi(a[1]); - if (iNum<=0) { - di << " Shape Index must be >0 .\n"; - return 1; - } - // - //printf("Shape #%d is ", iNum); - di << "Shape #" << iNum << " is "; - - const BooleanOperations_ShapesDataStructure& aDS=pDF->DS(); - aNbLines=aDS.NumberOfSourceShapes(); - // - // - // Old shapes processing - // - if (iNum>0 && iNum<=aNbLines) { - di << "from the "; - // Old Shape - aNbObj=aDS.NumberOfShapesOfTheObject(); - if (iNum<=aNbObj) { - di << "Object "; - } - else { - di << "Tool "; - } - di << ".\n"; - return 0; - } - // - bIsNewShape=aDS.IsNewShape(iNum); - if (bIsNewShape) { - di << "new.\n"; - } - - else { - di << "undefined.\n"; - return 0; - } - // - // New shapes processing - // - const TopoDS_Shape& aShapeToFind=aDS.Shape(iNum); - TopAbs_ShapeEnum aTypeOfShapeToFind=aShapeToFind.ShapeType(); - // - // Interferences - const BOPTools_InterferencePool& anInterferencePool=pDF->InterfPool(); - // - const BOPTools_CArray1OfVVInterference& aVVInterfs=anInterferencePool.VVInterfs(); - const BOPTools_CArray1OfVEInterference& aVEInterfs=anInterferencePool.VEInterfs(); - const BOPTools_CArray1OfVSInterference& aVSInterfs=anInterferencePool.VSInterfs(); - const BOPTools_CArray1OfEEInterference& aEEInterfs=anInterferencePool.EEInterfs(); - const BOPTools_CArray1OfESInterference& aESInterfs=anInterferencePool.ESInterfs(); - // - // VV - aNbLines=aVVInterfs.Extent(); - for (i=1; i<=aNbLines; ++i) { - aNewShape=aVVInterfs(i).NewShape(); - if (aNewShape==iNum) { - aVVInterfs(i).Indices(aWhat, aWith); - //printf(" VV: (%d, %d)\n", aWhat, aWith); - di << " VV: (" << aWhat << ", " << aWith << ")\n"; - } - } - // - // VE - aNbLines=aVEInterfs.Extent(); - for (i=1; i<=aNbLines; ++i) { - aNewShape=aVEInterfs(i).NewShape(); - if (aNewShape==iNum) { - aVEInterfs(i).Indices(aWhat, aWith); - //printf(" VE: (%d, %d)\n", aWhat, aWith); - di << " VE: (" << aWhat << ", " << aWith << ")\n"; - } - } - // - // VF - aNbLines=aVSInterfs.Extent(); - for (i=1; i<=aNbLines; ++i) { - aNewShape=aVSInterfs(i).NewShape(); - if (aNewShape==iNum) { - aVSInterfs(i).Indices(aWhat, aWith); - //printf(" VF: (%d, %d)\n", aWhat, aWith); - di << " VF: (" << aWhat << ", " << aWith << ")\n"; - } - } - // - // EE - aNbLines=aEEInterfs.Extent(); - for (i=1; i<=aNbLines; ++i) { - aNewShape=aEEInterfs(i).NewShape(); - if (aNewShape==iNum) { - aEEInterfs(i).Indices(aWhat, aWith); - //printf(" EE: (%d, %d)\n", aWhat, aWith); - di << " EE: (" << aWhat << ", " << aWith << ")\n"; - } - } - // - // EF - aNbLines=aESInterfs.Extent(); - for (i=1; i<=aNbLines; ++i) { - aNewShape=aESInterfs(i).NewShape(); - if (aNewShape==iNum) { - aESInterfs(i).Indices(aWhat, aWith); - //printf(" EF: (%d, %d)\n", aWhat, aWith); - di << " EF: (" << aWhat << ", " << aWith << ")\n"; - } - } - // - // FF - Standard_Integer j, aNbCurves; - // - BOPTools_InterferencePool* pInterPool=(BOPTools_InterferencePool*)&pDF->InterfPool(); - BOPTools_CArray1OfSSInterference& aSSInterfs=pInterPool->SSInterferences(); - // - aNbLines=aSSInterfs.Extent(); - for (i=1; i<=aNbLines; ++i) { - BOPTools_SSInterference& aFF=aSSInterfs(i); - aWhat=aFF.Index1(); - aWith=aFF.Index2(); - - - BOPTools_SequenceOfCurves& aSC=aFF.Curves(); - - aNbCurves=aSC.Length(); - for (j=1; j<=aNbCurves; ++j) { - const BOPTools_Curve& aBC=aSC(j); - - if (aTypeOfShapeToFind==TopAbs_EDGE) { - const BOPTools_ListOfPaveBlock& aLPB=aBC.NewPaveBlocks(); - BOPTools_ListIteratorOfListOfPaveBlock anIt(aLPB); - for (; anIt.More(); anIt.Next()) { - const BOPTools_PaveBlock& aPB=anIt.Value(); - aNewShape=aPB.Edge(); - if (aNewShape==iNum) { - //printf(" FF: (%d, %d) [Section Edge]\n", aWhat, aWith); - di << " FF: (" << aWhat << ", " << aWith << ") [Section Edge]\n"; - } - } - } - // - if (aTypeOfShapeToFind==TopAbs_VERTEX) { - BOPTools_Curve* pBC=(BOPTools_Curve*)&aBC; - TColStd_ListOfInteger& aTVList=pBC->TechnoVertices(); - TColStd_ListIteratorOfListOfInteger aTVIt(aTVList); - for (; aTVIt.More(); aTVIt.Next()) { - aNewShape=aTVIt.Value(); - if (aNewShape==iNum) { - //printf(" FF: (%d, %d) [Techno Vertex]\n", aWhat, aWith); - di << " FF: (" << aWhat << ", " << aWith << ") [Techno Vertex]\n"; - } - } - } - } - // - if (aTypeOfShapeToFind==TopAbs_VERTEX) { - TColStd_ListOfInteger& anAVList=aFF.AloneVertices(); - TColStd_ListIteratorOfListOfInteger anAVIt(anAVList); - for (; anAVIt.More(); anAVIt.Next()) { - aNewShape=anAVIt.Value(); - if (aNewShape==iNum) { - //printf(" FF: (%d, %d) [Alone Vertex]\n", aWhat, aWith); - di << " FF: (" << aWhat << ", " << aWith << ") [Alone Vertex]\n"; - } - } - } - } - // - // - // PaveBlocks - if (aTypeOfShapeToFind==TopAbs_EDGE) { - // - Standard_Integer aNbPaveBlocks, nE, nOriginalEdge, aNbCommonBlocks; - Standard_Integer nFace, nE2, nOriginalEdge2; - // - const BOPTools_CommonBlockPool& aCommonBlockPool=pDF->CommonBlockPool(); - const BOPTools_SplitShapesPool& aSplitShapesPool=pDF->SplitShapesPool(); - aNbLines=aSplitShapesPool.Extent(); - for (i=1; i<=aNbLines; ++i) { - const BOPTools_ListOfPaveBlock& aSplitEdges=aSplitShapesPool(i); - aNbPaveBlocks=aSplitEdges.Extent(); - - BOPTools_ListIteratorOfListOfPaveBlock aPBIt(aSplitEdges); - for (; aPBIt.More(); aPBIt.Next()) { - const BOPTools_PaveBlock& aPB=aPBIt.Value(); - nE=aPB.Edge(); - nOriginalEdge=aPB.OriginalEdge(); - if (nE==iNum) { - //printf(" PaveBlock [Base Edge #%d]\n", nOriginalEdge); - di << " PaveBlock [Base Edge #" << nOriginalEdge << "]\n"; - const BOPTools_ListOfCommonBlock& aLCB= - aCommonBlockPool(aDS.RefEdge(nOriginalEdge)); - aNbCommonBlocks=aLCB.Extent(); - - BOPTools_ListIteratorOfListOfCommonBlock aCBIt(aLCB); - for (; aCBIt.More(); aCBIt.Next()) { - BOPTools_CommonBlock& aCB=aCBIt.Value(); - nFace=aCB.Face(); - if (nFace) { - //printf(" CommonBlock with Face #%d\n", nFace); - di << " CommonBlock with Face #" << nFace << "\n"; - } - else { - BOPTools_PaveBlock& aPB2=aCB.PaveBlock2(nOriginalEdge); - nE2=aPB2.Edge(); - nOriginalEdge2=aPB2.OriginalEdge(); - //printf(" CommonBlock with Edge #%d [Base Edge #%d]\n", - // nE2, nOriginalEdge2); - di << " CommonBlock with Edge #" << nE2 << " [Base Edge #" << nOriginalEdge2 << "]\n"; - } - } - - } - } - } - - } - return 0; -} - -//======================================================================= -//function : bopsticks -//purpose : -//======================================================================= -Standard_Integer bopsticks (Draw_Interpretor& di, - Standard_Integer n, - const char** ) -{ - if (pDF==NULL) { - di << " Prepare BOPTools_DSFiller first >bop S1 S2\n"; - return 1; - } - // - if (n!=1) { - di << " Use >bopsticks\n"; - return 1; - } - // - Standard_Integer i, j, aNbLines, nF1, nF2, aNbVtx, nV; - // - const BooleanOperations_ShapesDataStructure& aDS=pDF->DS(); - const BOPTools_PaveFiller& aPF=pDF->PaveFiller(); - BOPTools_PaveFiller* pPF=(BOPTools_PaveFiller*)&aPF; - BOPTools_InterferencePool* pInterPool=(BOPTools_InterferencePool*)&pDF->InterfPool(); - BOPTools_CArray1OfSSInterference& aSSInterfs=pInterPool->SSInterferences(); - // - aNbLines=aSSInterfs.Extent(); - // - for (i=1; i<=aNbLines; ++i) { - TColStd_IndexedMapOfInteger aMapUnUsed; - BOPTools_PaveSet aPSF; - // - BOPTools_SSInterference& aFF=aSSInterfs(i); - BOPTools_SequenceOfCurves& aSCvs=aFF.Curves(); - - nF1=aFF.Index1(); - nF2=aFF.Index2(); - - pPF->PrepareSetForFace(nF1, nF2, aPSF); - UnUsedMap(aSCvs, aPSF, aMapUnUsed); - aNbVtx=aMapUnUsed.Extent(); - for (j=1; j<=aNbVtx; ++j) { - nV=aMapUnUsed(j); - if (aDS.IsNewShape(nV)) { - //printf(" Vertex #%d [FF:(%d, %d)]\n", nV, nF1, nF2); - di << " Vertex #" << nV << " [FF:(" << nF1 << ", " << nF2 << ")]\n"; - } - } - } - return 0; -} - -//======================================================================= -// function: UnUsedMap -// purpose: -//======================================================================= -void UnUsedMap(BOPTools_SequenceOfCurves& aSCvs, - const BOPTools_PaveSet& aPSF, - TColStd_IndexedMapOfInteger& aMapUnUsed) -{ - // - // What stick/non-stick vertices we used - TColStd_IndexedMapOfInteger aMapUsed, aMapMustBeUsed; - Standard_Integer j, aNbCurves, aNbVtx, nV1;//, nV2; - BOPTools_ListIteratorOfListOfPave anLPIt; - - aNbCurves=aSCvs.Length(); - for (j=1; j<=aNbCurves; ++j) { - BOPTools_Curve& aBC=aSCvs(j); - //const IntTools_Curve& aC= aBC.Curve();// Wng in Gcc 3.0 - - const BOPTools_PaveSet& aPaveSet=aBC.Set(); - const BOPTools_ListOfPave& aLPAlreadyUsed=aPaveSet.Set(); - anLPIt.Initialize(aLPAlreadyUsed); - for (; anLPIt.More(); anLPIt.Next()) { - const BOPTools_Pave& aPave=anLPIt.Value(); - nV1=aPave.Index(); - aMapUsed.Add(nV1); - } - } - // - // 2. Stick vertices that must be used - const BOPTools_ListOfPave& aLPMustUsed=aPSF.Set(); - anLPIt.Initialize(aLPMustUsed); - for (; anLPIt.More(); anLPIt.Next()) { - const BOPTools_Pave& aPave=anLPIt.Value(); - nV1=aPave.Index(); - aMapMustBeUsed.Add(nV1); - } - // - // 3.Unused Stick vertices . - aNbVtx=aMapMustBeUsed.Extent(); - for (j=1; j<=aNbVtx; ++j) { - nV1=aMapMustBeUsed(j); - if (!aMapUsed.Contains(nV1)) { - aMapUnUsed.Add(nV1); - } - } - // + return 0; } diff --git a/src/BOPTest/BOPTest_CheckCommands.cxx b/src/BOPTest/BOPTest_CheckCommands.cxx old mode 100755 new mode 100644 index 2051ef634d..362a7d5b56 --- a/src/BOPTest/BOPTest_CheckCommands.cxx +++ b/src/BOPTest/BOPTest_CheckCommands.cxx @@ -1,6 +1,5 @@ -// Created on: 2002-08-05 // Created by: Peter KURNEV -// Copyright (c) 2002-2012 OPEN CASCADE SAS +// Copyright (c) 2010-2012 OPEN CASCADE SAS // // The content of this file is subject to the Open CASCADE Technology Public // License Version 6.5 (the "License"). You may not use the content of this file @@ -27,31 +26,26 @@ #include #include -#include - -#include -#include -// modified by NIZHNY-MKK Fri Sep 3 17:50:06 2004 -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - #include #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include static Standard_Integer bopcheck (Draw_Interpretor&, Standard_Integer, const char** ); @@ -90,128 +84,110 @@ Standard_Integer bopcheck (Draw_Interpretor& di, Standard_Integer n, const char return 1; } - TopoDS_Shape aS = DBRep::Get(a[1]); + TopoDS_Shape aS1 = DBRep::Get(a[1]); + if (aS1.IsNull()) { + di << "null shapes are not allowed here!"; + return 1; + } + TopoDS_Shape aS = BRepBuilderAPI_Copy(aS1); // - BOPTools_Checker aChecker(aS); - - aChecker.Perform(); + Standard_Integer iErr, aTypeInt, i, ind, j; + Standard_Integer nI1, nI2; + Standard_Boolean bSelfInt, bFFInt; + char buf[256]; - if (aChecker.HasFaulty()) { - const BOPTools_ListOfCheckResults& aResultList = aChecker.GetCheckResult(); -// const TopoDS_Shape& aSF1=aChecker.FaultyShape1(); -// const TopoDS_Shape& aSF2=aChecker.FaultyShape2(); - Standard_Integer shapeit = 1; - BOPTools_ListIteratorOfListOfCheckResults anIt(aResultList); - - for(; anIt.More(); anIt.Next()) { - const BOPTools_CheckResult& aCheckResult = anIt.Value(); - switch(aCheckResult.GetCheckStatus()) { - case BOPTools_CHKUNKNOWN: { - di << "Unknown status" << "\n"; - break; - } - case BOPTools_VERTEXVERTEX: { - di << "Self-intersection near vertices" << "\n"; - break; - } - case BOPTools_VERTEXEDGE: { - di << "Self-intersection near vertex and edge" << "\n"; - break; - } - case BOPTools_VERTEXFACE: { - di << "Self-intersection near vertex and face" << "\n"; - break; - } - case BOPTools_EDGEEDGE: { - di << "Self-intersection near edges" << "\n"; - break; - } - case BOPTools_EDGEEDGECOMBLK: { - di << "Coincidance of edges" << "\n"; - break; - } - case BOPTools_EDGEFACE: { - di << "Self-intersection near edge and face" << "\n"; - break; - } - case BOPTools_EDGEFACECOMBLK: { - di << "Edge belong to face not topologically but geometrically" << "\n"; - break; - } - case BOPTools_FACEFACE: { - di << "Self-intersection near faces" << "\n"; - break; - } - case BOPTools_BADSHRANKRANGE: { - di << "Can not obtain shrunk range: too small edge" << "\n"; - break; - } - case BOPTools_NULLSRANKRANGE: { - di << "Shrunk range is empty: too small edge" << "\n"; - break; - } - default: { - di << "Program error" << "\n"; - break; - } - } + BOPAlgo_CheckerSI aChecker; + BOPCol_ListOfShape anArgs; + anArgs.Append(aS); + anArgs.Append(aS); + aChecker.SetArguments(anArgs); + // + aChecker.Perform(); + iErr = aChecker.ErrorStatus(); + // + const BOPDS_PDS& theDS = aChecker.PDS(); + BOPDS_VectorOfInterfVV& aVVs=theDS->InterfVV(); + BOPDS_VectorOfInterfVE& aVEs=theDS->InterfVE(); + BOPDS_VectorOfInterfEE& aEEs=theDS->InterfEE(); + BOPDS_VectorOfInterfVF& aVFs=theDS->InterfVF(); + BOPDS_VectorOfInterfEF& aEFs=theDS->InterfEF(); + BOPDS_VectorOfInterfFF& aFFs=theDS->InterfFF(); + // + Standard_Integer aNb[6] = {aVVs.Extent(), aVEs.Extent(), aEEs.Extent(), + aVFs.Extent(), aEFs.Extent(), aFFs.Extent()}; + char type[6][5] = {"V/V:", "V/E:", "E/E:","V/F:", "E/F:", "F/F:"}; - TopTools_ListIteratorOfListOfShape anIt2(aCheckResult.GetShapes()); - TCollection_AsciiString aBaseName("x"); - TopoDS_Shape aSF1; - - for(; anIt2.More(); anIt2.Next()) { - TopoDS_Shape aSF2 = anIt2.Value(); - Standard_Boolean bPrint = Standard_False; - - if(aSF1.IsNull()) { - bPrint = Standard_True; - } - else if (!aSF2.IsSame(aSF1)) { - bPrint = Standard_True; - } - - if(bPrint) { - TCollection_AsciiString anumbername(shapeit); - TCollection_AsciiString aXName = aBaseName + anumbername; - //char* aname = aXName.ToCString(); - Standard_CString aname=aXName.ToCString(); - DBRep::Set (aname, aSF2); - //printf(aname); - di << aname << " "; - //printf(" "); - shapeit++; - } - aSF1 = aSF2; + // + bSelfInt = Standard_False; + ind = 0; + for (aTypeInt = 0; aTypeInt < 6; ++aTypeInt) { + for (i = 0; i < aNb[aTypeInt]; ++i) { + BOPDS_Interf* aInt = (aTypeInt==0) ? (BOPDS_Interf*)(&aVVs(i)) : + ((aTypeInt==1) ? (BOPDS_Interf*)(&aVEs(i)) : + ((aTypeInt==2) ? (BOPDS_Interf*)(&aEEs(i)) : + ((aTypeInt==3) ? (BOPDS_Interf*)(&aVFs(i)) : + ((aTypeInt==4) ? (BOPDS_Interf*)(&aEFs(i)) : (BOPDS_Interf*)(&aFFs(i)))))); + // + nI1 = aInt->Index1(); + nI2 = aInt->Index2(); + if (nI1 == nI2) { + continue; } - //printf("\n"); - di << "\n"; // - const Handle(Geom_Geometry)& aGG=aCheckResult.GetInterferenceGeometry(); - - if (!aGG.IsNull()) { - - TCollection_AsciiString aNmx("x0"); - Standard_CString name= aNmx.ToCString(); - // - Handle (Geom_CartesianPoint) aGCP= - Handle (Geom_CartesianPoint)::DownCast(aGG); - // - if (!aGCP.IsNull()) { - const gp_Pnt& aP3D=aGCP->Pnt(); - DrawTrSurf::Set(name, aP3D); - } - else { - DrawTrSurf::Set(name, aGG); - } + const TopoDS_Shape& aS1 = theDS->Shape(nI1); + const TopoDS_Shape& aS2 = theDS->Shape(nI2); + // + if (aTypeInt == 5) { + bFFInt = Standard_False; + BOPDS_InterfFF& aFF = aFFs(i); + BOPDS_VectorOfPoint& aVP=aFF.ChangePoints(); + Standard_Integer aNbP=aVP.Extent(); + BOPDS_VectorOfCurve& aVC=aFF.ChangeCurves(); + Standard_Integer aNbC=aVC.Extent(); + if (!aNbP && !aNbC) { + continue; + } + for (j=0; jbopargcheck Shape1 [[Shape2] [-F/O/C/T/S/U] [+R|F|T|V|E|I|P]] [#BF]" << endl << endl; di << " Use >bopargcheck Shape1 [[Shape2] [-F/O/C/T/S/U] [/R|F|T|V|E|I|P]] [#BF]" << "\n" << "\n"; di << " -" << "\n"; di << " F (fuse)" << "\n"; @@ -255,17 +230,11 @@ Standard_Integer bopargcheck (Draw_Interpretor& di, Standard_Integer n, const c di << " U (unknown)" << "\n"; di << " For example: \"bopargcheck s1 s2 -F\" enables checking for Fuse operation" << "\n"; di << " default - section" << "\n" << "\n"; -// cout << " +" << endl; di << " /" << "\n"; -// cout << " R (enable small edges (shrank range) test)" << endl; di << " R (disable small edges (shrank range) test)" << "\n"; -// cout << " F (enable faces verification test)" << endl; di << " F (disable faces verification test)" << "\n"; -// cout << " T (enable tangent faces searching test)" << endl; di << " T (disable tangent faces searching test)" << "\n"; -// cout << " V (test possibility to merge vertices)" << endl; di << " V (disable test possibility to merge vertices)" << "\n"; -// cout << " E (test possibility to merge edges)" << endl; di << " E (disable test possibility to merge edges)" << "\n"; di << " I (disable self-interference test)" << "\n"; di << " P (disable shape type test)" << "\n"; @@ -280,13 +249,15 @@ Standard_Integer bopargcheck (Draw_Interpretor& di, Standard_Integer n, const c return 1; } - TopoDS_Shape aS1 = DBRep::Get(a[1]); + TopoDS_Shape aS11 = DBRep::Get(a[1]); - if(aS1.IsNull()) { + if(aS11.IsNull()) { di << "Error: null shape not allowed!" << "\n"; di << "Type bopargcheck without arguments for more information" << "\n"; return 1; } + TopoDS_Shape aS1 = BRepBuilderAPI_Copy(aS11); + Standard_Boolean isBO = Standard_False; Standard_Integer indxBO = 0; @@ -324,7 +295,7 @@ Standard_Integer bopargcheck (Draw_Interpretor& di, Standard_Integer n, const c } // set & test second shape - TopoDS_Shape aS2; + TopoDS_Shape aS22, aS2; if(isS2) { if(indxS2 != 2) { di << "Error: second shape should follow the first one!" << "\n"; @@ -332,8 +303,8 @@ Standard_Integer bopargcheck (Draw_Interpretor& di, Standard_Integer n, const c return 1; } else { - aS2 = DBRep::Get(a[2]); - if(aS2.IsNull()) { + aS22 = DBRep::Get(a[2]); + if(aS22.IsNull()) { di << "Error: second shape is null!" << "\n"; di << "Type bopargcheck without arguments for more information" << "\n"; return 1; @@ -342,7 +313,7 @@ Standard_Integer bopargcheck (Draw_Interpretor& di, Standard_Integer n, const c } // init checker - BOP_ArgumentAnalyzer aChecker; + BOPAlgo_ArgumentAnalyzer aChecker; aChecker.SetShape1(aS1); // set default options (always tested!) for single and couple shapes @@ -350,27 +321,28 @@ Standard_Integer bopargcheck (Draw_Interpretor& di, Standard_Integer n, const c aChecker.SelfInterMode() = Standard_True; // test & set options and operation for two shapes - if(!aS2.IsNull()) { + if(!aS22.IsNull()) { + aS2 = BRepBuilderAPI_Copy(aS22); aChecker.SetShape2(aS2); // set operation (default - Section) if(isBO) { if(a[indxBO][1] == 'F' || a[indxBO][1] == 'f') { - aChecker.OperationType() = BOP_FUSE; + aChecker.OperationType() = BOPAlgo_FUSE; } else if(a[indxBO][1] == 'O' || a[indxBO][1] == 'o') { - aChecker.OperationType() = BOP_COMMON; + aChecker.OperationType() = BOPAlgo_COMMON; } else if(a[indxBO][1] == 'C' || a[indxBO][1] == 'c') { - aChecker.OperationType() = BOP_CUT; + aChecker.OperationType() = BOPAlgo_CUT; } else if(a[indxBO][1] == 'T' || a[indxBO][1] == 't') { - aChecker.OperationType() = BOP_CUT21; + aChecker.OperationType() = BOPAlgo_CUT21; } else if(a[indxBO][1] == 'S' || a[indxBO][1] == 's') { - aChecker.OperationType() = BOP_SECTION; + aChecker.OperationType() = BOPAlgo_SECTION; } else if(a[indxBO][1] == 'U' || a[indxBO][1] == 'u') { - aChecker.OperationType() = BOP_UNKNOWN; + aChecker.OperationType() = BOPAlgo_UNKNOWN; } else { di << "Error: invalid boolean operation type!" << "\n"; @@ -379,7 +351,7 @@ Standard_Integer bopargcheck (Draw_Interpretor& di, Standard_Integer n, const c } } else - aChecker.OperationType() = BOP_SECTION; + aChecker.OperationType() = BOPAlgo_SECTION; aChecker.SmallEdgeMode() = Standard_True; aChecker.RebuildFaceMode() = Standard_True; @@ -393,23 +365,23 @@ Standard_Integer bopargcheck (Draw_Interpretor& di, Standard_Integer n, const c while(a[indxOP][ind] != 0) { if(a[indxOP][ind] == 'R' || a[indxOP][ind] == 'r') { //aChecker.SmallEdgeMode() = Standard_True; - aChecker.SmallEdgeMode() = Standard_False; + aChecker.SmallEdgeMode() = Standard_False; } else if(a[indxOP][ind] == 'F' || a[indxOP][ind] == 'f') { //aChecker.RebuildFaceMode() = Standard_True; - aChecker.RebuildFaceMode() = Standard_False; + aChecker.RebuildFaceMode() = Standard_False; } else if(a[indxOP][ind] == 'T' || a[indxOP][ind] == 't') { //aChecker.TangentMode() = Standard_True; - aChecker.TangentMode() = Standard_False; + aChecker.TangentMode() = Standard_False; } else if(a[indxOP][ind] == 'V' || a[indxOP][ind] == 'v') { //aChecker.MergeVertexMode() = Standard_True; - aChecker.MergeVertexMode() = Standard_False; + aChecker.MergeVertexMode() = Standard_False; } else if(a[indxOP][ind] == 'E' || a[indxOP][ind] == 'e') { //aChecker.MergeEdgeMode() = Standard_True; - aChecker.MergeEdgeMode() = Standard_False; + aChecker.MergeEdgeMode() = Standard_False; } else if(a[indxOP][ind] == 'I' || a[indxOP][ind] == 'i') { aChecker.SelfInterMode() = Standard_False; @@ -501,13 +473,14 @@ Standard_Integer bopargcheck (Draw_Interpretor& di, Standard_Integer n, const c di << "Faulties, that can not be treated by BOP, are detected." << "\n"; } else { - const BOP_ListOfCheckResult& aResultList = aChecker.GetCheckResult(); - BOP_ListIteratorOfListOfCheckResult anIt(aResultList); + const BOPAlgo_ListOfCheckResult& aResultList = aChecker.GetCheckResult(); + BOPAlgo_ListIteratorOfListOfCheckResult anIt(aResultList); Standard_Integer S1_BadType = 0, S1_SelfInt = 0, S1_SmalE = 0, S1_BadF = 0, S1_BadV = 0, S1_BadE = 0; Standard_Integer S1_SelfIntAll = 0, S1_SmalEAll = 0, S1_BadFAll = 0, S1_BadVAll = 0, S1_BadEAll = 0; Standard_Integer S2_BadType = 0, S2_SelfInt = 0, S2_SmalE = 0, S2_BadF = 0, S2_BadV = 0, S2_BadE = 0; Standard_Integer S2_SelfIntAll = 0, S2_SmalEAll = 0, S2_BadFAll = 0, S2_BadVAll = 0, S2_BadEAll = 0; + Standard_Integer S1_OpAb = 0, S2_OpAb = 0; Standard_Boolean hasUnknown = Standard_False; TCollection_AsciiString aS1SIBaseName("s1si_"); @@ -522,7 +495,7 @@ Standard_Integer bopargcheck (Draw_Interpretor& di, Standard_Integer n, const c TCollection_AsciiString aS2BEBaseName("s2be_"); for(; anIt.More(); anIt.Next()) { - const BOP_CheckResult& aResult = anIt.Value(); + const BOPAlgo_CheckResult& aResult = anIt.Value(); const TopoDS_Shape & aSS1 = aResult.GetShape1(); const TopoDS_Shape & aSS2 = aResult.GetShape2(); const TopTools_ListOfShape & aLS1 = aResult.GetFaultyShapes1(); @@ -531,12 +504,12 @@ Standard_Integer bopargcheck (Draw_Interpretor& di, Standard_Integer n, const c Standard_Boolean isL2 = !aLS2.IsEmpty(); switch(aResult.GetCheckStatus()) { - case BOP_BadType: { + case BOPAlgo_BadType: { if(!aSS1.IsNull()) S1_BadType++; if(!aSS2.IsNull()) S2_BadType++; } - break; - case BOP_SelfIntersect: { + break; + case BOPAlgo_SelfIntersect: { if(!aSS1.IsNull()) { S1_SelfInt++; if(isL1) @@ -548,8 +521,8 @@ Standard_Integer bopargcheck (Draw_Interpretor& di, Standard_Integer n, const c MakeShapeForFullOutput(aS2SIBaseName, S2_SelfInt, aLS2, S2_SelfIntAll, di); } } - break; - case BOP_TooSmallEdge: { + break; + case BOPAlgo_TooSmallEdge: { if(!aSS1.IsNull()) { S1_SmalE++; if(isL1) @@ -561,8 +534,8 @@ Standard_Integer bopargcheck (Draw_Interpretor& di, Standard_Integer n, const c MakeShapeForFullOutput(aS2SEBaseName, S2_SmalE, aLS2, S2_SmalEAll, di); } } - break; - case BOP_NonRecoverableFace: { + break; + case BOPAlgo_NonRecoverableFace: { if(!aSS1.IsNull()) { S1_BadF++; if(isL1) @@ -574,52 +547,57 @@ Standard_Integer bopargcheck (Draw_Interpretor& di, Standard_Integer n, const c MakeShapeForFullOutput(aS2BFBaseName, S2_BadF, aLS2, S2_BadFAll, di); } } - break; - case BOP_IncompatibilityOfVertex: { + break; + case BOPAlgo_IncompatibilityOfVertex: { if(!aSS1.IsNull()) { S1_BadV++; if(isL1) { MakeShapeForFullOutput(aS1BVBaseName, S1_BadV, aLS1, S1_BadVAll, di); - } + } } if(!aSS2.IsNull()) { S2_BadV++; if(isL2){ MakeShapeForFullOutput(aS2BVBaseName, S2_BadV, aLS2, S2_BadVAll, di); - } + } } } - break; - case BOP_IncompatibilityOfEdge: { + break; + case BOPAlgo_IncompatibilityOfEdge: { if(!aSS1.IsNull()) { S1_BadE++; if(isL1) { MakeShapeForFullOutput(aS1BEBaseName, S1_BadE, aLS1, S1_BadEAll, di); - } + } } if(!aSS2.IsNull()) { S2_BadE++; if(isL2) { MakeShapeForFullOutput(aS2BEBaseName, S2_BadE, aLS2, S2_BadEAll, di); - } + } } } - break; - case BOP_IncompatibilityOfFace: { + break; + case BOPAlgo_IncompatibilityOfFace: { // not yet implemented } - break; - case BOP_CheckUnknown: + break; + case BOPAlgo_OperationAborted: { + if(!aSS1.IsNull()) S1_OpAb++; + if(!aSS2.IsNull()) S2_OpAb++; + } + break; + case BOPAlgo_CheckUnknown: default: { hasUnknown = Standard_True; } - break; + break; } // switch }// faulties - Standard_Integer FS1 = S1_SelfInt + S1_SmalE + S1_BadF + S1_BadV + S1_BadE; + Standard_Integer FS1 = S1_SelfInt + S1_SmalE + S1_BadF + S1_BadV + S1_BadE + S1_OpAb; FS1 += (S1_BadType != 0) ? 1 : 0; - Standard_Integer FS2 = S2_SelfInt + S2_SmalE + S2_BadF + S2_BadV + S2_BadE; + Standard_Integer FS2 = S2_SelfInt + S2_SmalE + S2_BadF + S2_BadV + S2_BadE + S2_OpAb; FS2 += (S2_BadType != 0) ? 1 : 0; // output for first shape @@ -627,56 +605,62 @@ Standard_Integer bopargcheck (Draw_Interpretor& di, Standard_Integer n, const c if(FS1 != 0) { di << "---------------------------------" << "\n"; Standard_CString CString1; - if (S1_BadType != 0) - CString1="YES"; - else - CString1="NO"; + if (S1_BadType != 0) + CString1="YES"; + else + CString1="NO"; di << "Shapes are not suppotrted by BOP: " << CString1 << "\n"; Standard_CString CString2; - if (S1_SelfInt != 0) - CString2="YES"; - else - CString2="NO"; + if (S1_SelfInt != 0) + CString2="YES"; + else + CString2="NO"; di << "Self-Intersections : " << CString2; if(S1_SelfInt != 0) di << " Cases(" << S1_SelfInt << ") Total shapes(" << S1_SelfIntAll << ")" << "\n"; else di << "\n"; + Standard_CString CString13; + if (S1_OpAb != 0) + CString13="YES"; + else + CString13="NO"; + di << "Check for SI has been aborted : " << CString13 << "\n"; Standard_CString CString3; - if (S1_SmalE != 0) - CString3="YES"; - else - CString3="NO"; + if (S1_SmalE != 0) + CString3="YES"; + else + CString3="NO"; di << "Too small edges : " << CString3; if(S1_SmalE != 0) di << " Cases(" << S1_SmalE << ") Total shapes(" << S1_SmalEAll << ")" << "\n"; else di << "\n"; Standard_CString CString4; - if (S1_BadF != 0) - CString4="YES"; - else - CString4="NO"; + if (S1_BadF != 0) + CString4="YES"; + else + CString4="NO"; di << "Bad faces : " << CString4; if(S1_BadF != 0) di << " Cases(" << S1_BadF << ") Total shapes(" << S1_BadFAll << ")" << "\n"; else di << "\n"; Standard_CString CString5; - if (S1_BadV != 0) - CString5="YES"; - else - CString5="NO"; + if (S1_BadV != 0) + CString5="YES"; + else + CString5="NO"; di << "Too close vertices : " << CString5; if(S1_BadV != 0) di << " Cases(" << S1_BadV << ") Total shapes(" << S1_BadVAll << ")" << "\n"; else di << "\n"; Standard_CString CString6; - if (S1_BadE != 0) - CString6="YES"; - else - CString6="NO"; + if (S1_BadE != 0) + CString6="YES"; + else + CString6="NO"; di << "Too close edges : " << CString6; if(S1_BadE != 0) di << " Cases(" << S1_BadE << ") Total shapes(" << S1_BadEAll << ")" << "\n"; @@ -690,56 +674,63 @@ Standard_Integer bopargcheck (Draw_Interpretor& di, Standard_Integer n, const c if(FS2 != 0) { di << "---------------------------------" << "\n"; Standard_CString CString7; - if (S2_BadType != 0) - CString7="YES"; - else - CString7="NO"; + if (S2_BadType != 0) + CString7="YES"; + else + CString7="NO"; di << "Shapes are not suppotrted by BOP: " << CString7 << "\n"; Standard_CString CString8; - if (S2_SelfInt != 0) - CString8="YES"; - else - CString8="NO"; + if (S2_SelfInt != 0) + CString8="YES"; + else + CString8="NO"; di << "Self-Intersections : " << CString8; if(S2_SelfInt != 0) di << " Cases(" << S2_SelfInt << ") Total shapes(" << S2_SelfIntAll << ")" << "\n"; else di << "\n"; + + Standard_CString CString14; + if (S2_OpAb != 0) + CString14="YES"; + else + CString14="NO"; + di << "Check for SI has been aborted : " << CString14 << "\n"; Standard_CString CString9; - if (S2_SmalE != 0) - CString9="YES"; - else - CString9="NO"; + if (S2_SmalE != 0) + CString9="YES"; + else + CString9="NO"; di << "Too small edges : " << CString9; if(S2_SmalE != 0) di << " Cases(" << S2_SmalE << ") Total shapes(" << S2_SmalEAll << ")" << "\n"; else di << "\n"; Standard_CString CString10; - if (S2_BadF != 0) - CString10="YES"; - else - CString10="NO"; + if (S2_BadF != 0) + CString10="YES"; + else + CString10="NO"; di << "Bad faces : " << CString10; if(S2_BadF != 0) di << " Cases(" << S2_BadF << ") Total shapes(" << S2_BadFAll << ")" << "\n"; else di << "\n"; Standard_CString CString11; - if (S2_BadV != 0) - CString11="YES"; - else - CString11="NO"; + if (S2_BadV != 0) + CString11="YES"; + else + CString11="NO"; di << "Too close vertices : " << CString11; if(S2_BadV != 0) di << " Cases(" << S2_BadV << ") Total shapes(" << S2_BadVAll << ")" << "\n"; else di << "\n"; Standard_CString CString12; - if (S2_BadE != 0) - CString12="YES"; - else - CString12="NO"; + if (S2_BadE != 0) + CString12="YES"; + else + CString12="NO"; di << "Too close edges : " << CString12; if(S2_BadE != 0) di << " Cases(" << S2_BadE << ") Total shapes(" << S2_BadEAll << ")" << "\n"; diff --git a/src/BOPTest/BOPTest_CurveCommands.cxx b/src/BOPTest/BOPTest_CurveCommands.cxx deleted file mode 100755 index 03da536ce2..0000000000 --- a/src/BOPTest/BOPTest_CurveCommands.cxx +++ /dev/null @@ -1,196 +0,0 @@ -// Created on: 2000-03-16 -// Created by: Peter KURNEV -// Copyright (c) 2000-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include - -#include - -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include -#include -#include - - -static Standard_Integer bopcurves (Draw_Interpretor&, Standard_Integer, const char** ); -static Standard_Integer bcurtolerance (Draw_Interpretor& di, Standard_Integer n, const char** a); - -//======================================================================= -//function : BOPTest::CurveCommands -//purpose : -//======================================================================= - void BOPTest::CurveCommands(Draw_Interpretor& theCommands) -{ - static Standard_Boolean done = Standard_False; - if (done) return; - done = Standard_True; - // Chapter's name - const char* g = "CCR commands"; - - theCommands.Add("bopcurves" , "Use bopcurves> F1 F2", __FILE__, bopcurves, g); - theCommands.Add("bcurtolerance" , " use >bcurtolerance C3Dtrim, Tol\n", __FILE__, bcurtolerance, g); -} - -//======================================================================= -//function : bopcurves -//purpose : -//======================================================================= -Standard_Integer bopcurves (Draw_Interpretor& di, - Standard_Integer n, - const char** a) -{ - if (n<3) { - di << " Use bopcurves> F1 F2\n"; - return 1; - } - - TopoDS_Shape S1 = DBRep::Get(a[1]); - TopoDS_Shape S2 = DBRep::Get(a[2]); - TopAbs_ShapeEnum aType; - - if (S1.IsNull() || S2.IsNull()) { - di << " Null shapes is not allowed \n"; - return 1; - } - - aType=S1.ShapeType(); - if (aType != TopAbs_FACE) { - di << " Type mismatch F1\n"; - return 1; - } - aType=S2.ShapeType(); - if (aType != TopAbs_FACE) { - di << " Type mismatch F2\n"; - return 1; - } - - - const TopoDS_Face& aF1=TopoDS::Face(S1); - const TopoDS_Face& aF2=TopoDS::Face(S2); - - Standard_Boolean aToApproxC3d, aToApproxC2dOnS1, aToApproxC2dOnS2, anIsDone; - Standard_Boolean bToSplit; - Standard_Integer i, aNbCurves; - Standard_Real anAppTol, aTolR; - TCollection_AsciiString aNm("c_"); - // - bToSplit=Standard_False; - aToApproxC3d=Standard_True; - aToApproxC2dOnS1=Standard_False; - aToApproxC2dOnS2=Standard_False; - anAppTol=0.0000001; - - - IntTools_FaceFace aFF; - - aFF.SetParameters (aToApproxC3d, - aToApproxC2dOnS1, - aToApproxC2dOnS2, - anAppTol); - - aFF.Perform (aF1, aF2); - - anIsDone=aFF.IsDone(); - if (!anIsDone) { - //printf(" anIsDone=%d\n", anIsDone); - di << " anIsDone=" << (Standard_Integer) anIsDone << "\n"; - return 1; - } - - aFF.PrepareLines3D(bToSplit); - const IntTools_SequenceOfCurves& aSCs=aFF.Lines(); - - // - aTolR=aFF.TolReached3d(); - di << "Tolerance Reached=" << aTolR << "\n"; - - aNbCurves=aSCs.Length(); - if (!aNbCurves) { - di << " has no 3d curve\n"; - return 1; - } - - for (i=1; i<=aNbCurves; i++) { - const IntTools_Curve& anIC=aSCs(i); - - Handle (Geom_Curve) aC3D=anIC.Curve(); - - if (aC3D.IsNull()) { - di << " has Null 3d curve# " << i << "%d\n"; - continue; - } - - TCollection_AsciiString anIndx(i), aNmx; - aNmx=aNm+anIndx; - Standard_CString name= aNmx.ToCString(); - DrawTrSurf::Set(name, aC3D); - di << name << " "; - } - - di << "\n"; - - return 0; -} - -//======================================================================= -//function : bcurtolerance -//purpose : -//======================================================================= - Standard_Integer bcurtolerance (Draw_Interpretor& di, - Standard_Integer n, - const char** a) -{ - if(n < 2) { - di << " use >bcurtolerance C3D [Tol=1.e-7]\n"; - return 1; - } - - Handle(Geom_Curve) aC3D = DrawTrSurf::GetCurve(a[1]); - if ( aC3D.IsNull()) { - di << " Null Curve is not allowed here\n"; - return 1; - } - // - Standard_Real aTolMax, aTol; - - aTol=1.e-7; - if (n>2) { - aTol=atof(a[2]); - if (aTol<=0.) { - aTol=1.e-7; - } - } - // - aTolMax=IntTools_Tools::CurveTolerance(aC3D, aTol); - //printf(" aTolMax=%16.11f\n", aTolMax); - di << " aTolMax=" << aTolMax << "\n"; - - return 0; -} diff --git a/src/BOPTest/BOPTest_DrawableShape.cxx b/src/BOPTest/BOPTest_DrawableShape.cxx index 6fdd788e1f..489e46ffbe 100755 --- a/src/BOPTest/BOPTest_DrawableShape.cxx +++ b/src/BOPTest/BOPTest_DrawableShape.cxx @@ -18,8 +18,8 @@ // and conditions governing the rights and limitations under the License. - #include +#include #include #include @@ -57,10 +57,8 @@ #include #include - - //======================================================================= -//function : BOPTest_DrawableShape::BOPTest_DrawableShape +//function : //purpose : //======================================================================= BOPTest_DrawableShape::BOPTest_DrawableShape (const TopoDS_Shape& aShape, @@ -81,7 +79,7 @@ BOPTest_DrawableShape::BOPTest_DrawableShape (const TopoDS_Shape& aShape, } //======================================================================= -//function : BOPTest_DrawableShape::BOPTest_DrawableShape +//function : //purpose : //======================================================================= BOPTest_DrawableShape::BOPTest_DrawableShape (const TopoDS_Shape& aShape, diff --git a/src/BOPTest/BOPTest_EFCommands.cxx b/src/BOPTest/BOPTest_EFCommands.cxx deleted file mode 100755 index 96211054de..0000000000 --- a/src/BOPTest/BOPTest_EFCommands.cxx +++ /dev/null @@ -1,148 +0,0 @@ -// Created on: 2001-02-26 -// Created by: Peter KURNEV -// Copyright (c) 2001-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include - -#include - -#include - -#include -#include -#include -#include - -#include - -#include -#include -#include -#include - -//======================================================================= -//function :bedge -//purpose : -//======================================================================= -static Standard_Integer bef (Draw_Interpretor& di, - Standard_Integer n, - const char** a) -{ - if (n<3) { - di << " Use bef> Edge Face Discr[33] Tol[1.e-7] Deflection[0.01]\n"; - return 1; - } - - TopoDS_Shape S1 = DBRep::Get(a[1]); - TopoDS_Shape S2 = DBRep::Get(a[2]); - - if (S1.IsNull() || S2.IsNull()) { - di << " Null shapes is not allowed \n"; - return 1; - } - - if (S1.ShapeType()!=TopAbs_EDGE && S2.ShapeType()!=TopAbs_FACE) { - di << " Shapes must be EDGE and FACE type\n"; - return 1; - } - - TopoDS_Edge E=TopoDS::Edge(S1); - TopoDS_Face F=TopoDS::Face(S2); - - Standard_Integer aDiscr=33; - Standard_Real aTol=.0000001, aDeflection=.01, aFrom, aTo; - - if (n>=4) { - aDiscr=atoi (a[3]); - } - - if (n>=5) { - aTol=atof (a[4]); - } - - if (n>=6) { - aDeflection=atof (a[5]); - } - - di << " bef: ===Begin===\n"; - di << " bef: Discretize=" << aDiscr << "%d\n"; - di << " bef: Tolerance =" << aTol << "\n"; - di << " bef: Deflection=" << aDeflection << "\n"; - - IntTools_EdgeFace aEF; - - aEF.SetEdge(E); - aEF.SetFace(F); - aEF.SetTolE(aTol); - aEF.SetTolF(aTol); - - aEF.SetDiscretize(aDiscr); - aEF.SetDeflection(aDeflection); - - BRep_Tool::Range(E, aFrom, aTo); - aEF.SetRange (aFrom, aTo); - - aEF.Perform(); - // - // Results treatment - Standard_Boolean anIsDone=aEF.IsDone(); - - di << "\n aEF.IsDone()=" << (Standard_Integer) anIsDone << ", aEF.ErrorStatus()=" << aEF.ErrorStatus() << "\n"; - - if (anIsDone) { - Standard_Integer i, aNb; - Standard_Real tF, tL; - - const IntTools_SequenceOfCommonPrts& aCPs=aEF.CommonParts(); - aNb=aCPs.Length(); - di << " aNb Common Parts=" << aNb << "\n"; - for (i=1; i<=aNb; i++) { - const IntTools_CommonPrt& aCP=aCPs(i); - TopAbs_ShapeEnum aType=aCP.Type(); - if (aType==TopAbs_VERTEX) - di << " aCP => Type=Vertex\n"; - else if (aType==TopAbs_EDGE) - di << " aCP => Type=Edge\n"; - else - di << " aCP => Type=Unknown\n"; - - aCP.Range1(tF, tL); - di << " Part " << i << " Edge#1 (" << tF << ", " << tL << ")\n"; - } - } - - di << " bef: ===End===\n"; - return 0; -} - -//======================================================================= -//function : EFCommands -//purpose : -//======================================================================= - void BOPTest::EFCommands(Draw_Interpretor& theCommands) -{ - static Standard_Boolean done = Standard_False; - if (done) return; - done = Standard_True; - // Chapter's name - const char* g = "Mtest commands"; - - theCommands.Add("bef", "Use bef> Edge Face Discr[33] Tol[1.e-7] Deflection[0.01]", __FILE__, bef, g); -} diff --git a/src/BOPTest/BOPTest_LowCommands.cxx b/src/BOPTest/BOPTest_LowCommands.cxx old mode 100755 new mode 100644 index 83871d5c12..540044d3e6 --- a/src/BOPTest/BOPTest_LowCommands.cxx +++ b/src/BOPTest/BOPTest_LowCommands.cxx @@ -22,94 +22,29 @@ #include -#include #include #include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include - #include -#include -#include #include -#include -#include - -#include - -#include +#include -#include +#include -#include -#include +#include +#include +#include #include - #include -#include -#include - -#include - -#include - -#include -#include -#include -#include -#include - -#include -#include - -static - Handle(Geom2d_Curve) CurveOnSurface(const TopoDS_Edge& E, - const TopoDS_Face& F, - Standard_Real& First, - Standard_Real& Last); -static - Handle(Geom2d_Curve) CurveOnSurface(const TopoDS_Edge& E, - const Handle(Geom_Surface)& S, - const TopLoc_Location& L, - Standard_Real& First, - Standard_Real& Last); static void PrintState (Draw_Interpretor& aDI, - const TopAbs_State& aState); + const TopAbs_State& aState); -//modified by NIZNHY-PKV Thu Nov 10 12:11:15 2011f -static - void DumpArray(const BOPTColStd_CArray1OfInteger& aC, - Draw_Interpretor& aDI); -//modified by NIZNHY-PKV Thu Nov 10 12:11:18 2011t - -static Standard_Integer bhaspc (Draw_Interpretor& , Standard_Integer , const char** ); -static Standard_Integer baddve (Draw_Interpretor& , Standard_Integer , const char** ); -static Standard_Integer bisclosed (Draw_Interpretor& , Standard_Integer , const char** ); -static Standard_Integer bexplode (Draw_Interpretor& , Standard_Integer , const char** ); -static Standard_Integer bupdateedge (Draw_Interpretor& , Standard_Integer , const char**); -static Standard_Integer bremovesim (Draw_Interpretor& , Standard_Integer , const char** ); -static Standard_Integer bopsetdisp (Draw_Interpretor& , Standard_Integer , const char** ); -static Standard_Integer bfaceprepare(Draw_Interpretor& , Standard_Integer , const char** ); -static Standard_Integer brefine (Draw_Interpretor& , Standard_Integer , const char** ); static Standard_Integer bclassify (Draw_Interpretor& , Standard_Integer , const char** ); static Standard_Integer b2dclassify (Draw_Interpretor& , Standard_Integer , const char** ); -static Standard_Integer bhole (Draw_Interpretor& , Standard_Integer , const char** ); -static Standard_Integer bxhole (Draw_Interpretor& , Standard_Integer , const char** ); //======================================================================= //function : LowCommands //purpose : @@ -121,510 +56,20 @@ static Standard_Integer bxhole (Draw_Interpretor& , Standard_Integer , con done = Standard_True; // Chapter's name const char* g = "CCR commands"; - // - // Whether Edge has PCurve on Face - theCommands.Add("bhaspc" , "Use >bhaspc Edge Face" , __FILE__, bhaspc , g); - theCommands.Add("baddve" , "Use >addve E V1 V2 p1 p2", __FILE__, baddve , g); - theCommands.Add("bisclosed" , "Use >bisclosed Edge Face" , __FILE__, bisclosed , g); - theCommands.Add("bexplode" , "" , __FILE__, bexplode , g); - theCommands.Add("bupdateedge" , "Use bupdateedge Edge Face", __FILE__, bupdateedge , g); - theCommands.Add("bremovesim" , "Use bremovesim Face" , __FILE__, bremovesim , g); - theCommands.Add("bopsetdisp" , "Use bopsetdisp" , __FILE__, bopsetdisp , g); - - - theCommands.Add("bfaceprepare" , "Use bfaceprepare F1 " , __FILE__, bfaceprepare, g); - - theCommands.Add("brefine" , "Use brefine Shape " , __FILE__, brefine , g); theCommands.Add("bclassify" , "Use >bclassify Solid Point [Tolerance=1.e-7]", - __FILE__, bclassify , g); + __FILE__, bclassify , g); theCommands.Add("b2dclassify" , "Use >bclassify Face Point2d [Tol2D=Tol(Face)] ", - __FILE__, b2dclassify , g); - theCommands.Add("bhole" , "Use bhole" , __FILE__, bhole , g); - theCommands.Add("bxhole" , "Use bxhole" , __FILE__, bxhole , g); -} - -//======================================================================= -//function : brefine -//purpose : -//======================================================================= -Standard_Integer brefine (Draw_Interpretor& di, - Standard_Integer n, - const char** a) -{ - if (n<2) { - di << " Use >brefine Shape1\n"; - return 1; - } - - TopoDS_Shape aS = DBRep::Get(a[1]); - - - if (aS.IsNull()) { - di << " Null shape is not allowed \n"; - return 1; - } - - Standard_Boolean bIsDone; - BOP_Refiner aRefiner; - aRefiner.SetShape(aS); - - aRefiner.Do(); - - bIsDone=aRefiner.IsDone(); - - if (bIsDone) { - Standard_Integer aNbRemovedVertices, aNbRemovedEdges, iFlag=0; - aNbRemovedVertices=aRefiner.NbRemovedVertices(); - aNbRemovedEdges=aRefiner.NbRemovedEdges(); - - if (aNbRemovedVertices) { - di << " Vertices removed=" << aNbRemovedVertices << "%d\n"; - iFlag++; - } - - if (aNbRemovedEdges) { - di << " Edges removed=" << aNbRemovedEdges << "\n"; - iFlag++; - } - - // REFRESH - if (iFlag) { - TCollection_AsciiString aNm(a[1]); - Standard_CString pstr; - - pstr=aNm.ToCString(); - DBRep::Set(pstr, aS); - } - } - - else { - di << "Not Done, err=" << aRefiner.ErrorStatus() << "\n"; - } - return 0; -} -//======================================================================= -//function : bfaceprepare -//purpose : -//======================================================================= -Standard_Integer bfaceprepare(Draw_Interpretor& di, Standard_Integer n, const char** a) -{ - if (n<2) { - di << " Use bfaceprepare> F1\n"; - return 1; - } - - TopoDS_Shape S1 = DBRep::Get(a[1]); - - - if (S1.IsNull()) { - di << " Null shape is not allowed \n"; - return 1; - } - if (S1.ShapeType()!=TopAbs_FACE) { - di << " Type mismatch\n"; - return 1; - } - - const TopoDS_Face& aF1=TopoDS::Face(S1); - - TopAbs_Orientation anOr; - anOr=aF1.Orientation(); - if (anOr==TopAbs_FORWARD) { - return 0; - } - // - Standard_Real aTol; - TopoDS_Face newFace; - BRep_Builder aBB; - - Handle(Geom_Surface) aS1=BRep_Tool::Surface(aF1); - Handle(Geom_Surface) aS=Handle(Geom_Surface)::DownCast(aS1->Copy()); - aS->VReverse(); - - aTol=BRep_Tool::Tolerance(aF1); - - aBB.MakeFace (newFace, aS, aTol); - - TopExp_Explorer anExp(aF1, TopAbs_WIRE); - for (; anExp.More(); anExp.Next()) { - const TopoDS_Shape& newWire=anExp.Current(); - aBB.Add(newFace, newWire); - } - - TCollection_AsciiString aNm(a[1]), aNmNew("_r"); - aNm=aNm+aNmNew; - Standard_CString an=aNm.ToCString(); - di << an << "\n"; - DBRep::Set(an, newFace); - return 0; -} -//======================================================================= -//function : bopsetdisp -//purpose : -//======================================================================= -Standard_Integer bopsetdisp (Draw_Interpretor& di, Standard_Integer , const char** ) -{ - Standard_Integer aFlag; - - char* xr=getenv("MDISP"); - if (xr==NULL) { - aFlag=putenv((char*)"MDISP=yes"); - di << " MDISP=yes. Return code=" << aFlag << "\n"; - } - else if (!strcmp (xr, "yes")) { - aFlag=putenv((char*)"MDISP=no"); - di << " MDISP=no. Return code=" << aFlag << "\n"; - } - else { - aFlag=putenv((char*)"MDISP=yes"); - di << " MDISP=yes. Return code=" << aFlag << "\n"; - } - - - return 0; -} -//======================================================================= -//function : bremovesim -//purpose : -//======================================================================= -Standard_Integer bremovesim (Draw_Interpretor& di, Standard_Integer n, const char** a) -{ - if (n<2) { - di << " Use bremovesim> Face\n"; - return 1; - } - - TopoDS_Shape S1 = DBRep::Get(a[1]); - - - if (S1.IsNull()) { - di << " Null shapes are not allowed \n"; - return 1; - } - if (S1.ShapeType()!=TopAbs_FACE) { - di << " Type mismatch\n"; - return 1; - } - - - const TopoDS_Face& aF=TopoDS::Face(S1); - // - Handle(IntTools_Context) aCtx=new IntTools_Context; - BOPTools_Tools3D::RemoveSims (aF, aCtx); - // - di << " Ok\n"; - return 0; -} -//======================================================================= -//function : bupdateedge -//purpose : -//======================================================================= -Standard_Integer bupdateedge (Draw_Interpretor& di, Standard_Integer n, const char** a) -{ - if (n<3) { - di << " Use bupdateedge> Edge Face\n"; - return 1; - } - - TopoDS_Shape S1 = DBRep::Get(a[1]); - TopoDS_Shape S2 = DBRep::Get(a[2]); - - if (S1.IsNull() || S2.IsNull()) { - di << " Null shapes are not allowed \n"; - return 1; - } - if (S1.ShapeType()!=TopAbs_EDGE || S2.ShapeType()!=TopAbs_FACE) { - di << " Type mismatch\n"; - return 1; - } - - const TopoDS_Edge& aE=TopoDS::Edge(S1); - const TopoDS_Face& aF=TopoDS::Face(S2); - Handle(Geom2d_Curve) aC2D; - - Standard_Real aTol; - aTol=BRep_Tool::Tolerance(aE); - BRep_Builder BB; - BB.UpdateEdge(aE, aC2D, aF, aTol); - di << " Ok\n"; - return 0; -} - -//======================================================================= -//function : bisclosed -//purpose : -//======================================================================= -Standard_Integer bisclosed (Draw_Interpretor& di, Standard_Integer n, const char** a) -{ - if (n<3) { - di << " Use bisclosed> Edge Face\n"; - return 1; - } - - TopoDS_Shape S1 = DBRep::Get(a[1]); - TopoDS_Shape S2 = DBRep::Get(a[2]); - - if (S1.IsNull() || S2.IsNull()) { - di << " Null shapes are not allowed \n"; - return 1; - } - if (S1.ShapeType()!=TopAbs_EDGE || S2.ShapeType()!=TopAbs_FACE) { - di << " Type mismatch\n"; - return 1; - } - - const TopoDS_Edge& aE=TopoDS::Edge(S1); - const TopoDS_Face& aF=TopoDS::Face(S2); - - Standard_Boolean anIsClosed; - anIsClosed=BRep_Tool::IsClosed(aE, aF); - - if (!anIsClosed) { - di << " Edge is not closed on this face\n"; - } - else { - di << " Edge is closed on this face\n"; - } - return 0; -} - -//======================================================================= -//function : bhaspc -//purpose : -//======================================================================= -Standard_Integer bhaspc (Draw_Interpretor& di, Standard_Integer n, const char** a) -{ - if (n<3) { - di << " Use bhaspc> Edge Face [do]\n"; - return 1; - } - - TopoDS_Shape S1 = DBRep::Get(a[1]); - TopoDS_Shape S2 = DBRep::Get(a[2]); - - if (S1.IsNull() || S2.IsNull()) { - di << " Null shapes are not allowed \n"; - return 1; - } - if (S1.ShapeType()!=TopAbs_EDGE || S2.ShapeType()!=TopAbs_FACE) { - di << " Type mismatch\n"; - return 1; - } - - const TopoDS_Edge& aE=TopoDS::Edge(S1); - const TopoDS_Face& aF=TopoDS::Face(S2); - Standard_Real f2D, l2D; - - Handle(Geom2d_Curve) C2D=CurveOnSurface(aE, aF, f2D, l2D); - - if (C2D.IsNull()) { - di << " No 2D Curves detected\n"; - } - else { - di << " Ok Edge has P-Curve on this Face\n"; - } - - if (n==4) { - if (!strcmp(a[3], "do")) { - BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aE, aF); - } - } - - return 0; + __FILE__, b2dclassify , g); } - -//======================================================================= -//function : baddve -//purpose : -//======================================================================= -Standard_Integer baddve (Draw_Interpretor& di, Standard_Integer n, const char** a) -{ - if (n<6) { - di << " Use baddve> E V1 V2 p1 p2\n"; - return 1; - } - - TopoDS_Shape S1 = DBRep::Get(a[1]); - TopoDS_Shape S2 = DBRep::Get(a[2]); - TopoDS_Shape S3 = DBRep::Get(a[3]); - if (S1.IsNull() || S2.IsNull() || S3.IsNull()) { - di << " Null shapes are not allowed \n"; - return 1; - } - - if (S1.ShapeType()!=TopAbs_EDGE || - S2.ShapeType()!=TopAbs_VERTEX || - S3.ShapeType()!=TopAbs_VERTEX ) { - di << " Type mismatch\n"; - return 1; - } - const TopoDS_Edge& aE=TopoDS::Edge(S1); - const TopoDS_Vertex& aV1=TopoDS::Vertex(S2); - const TopoDS_Vertex& aV2=TopoDS::Vertex(S3); - Standard_Real p1, p2; - p1=atof(a[4]); - p2=atof(a[5]); - - TopoDS_Edge E=aE; - E.EmptyCopy(); - - BRep_Builder BB; - BB.Add (E, aV1); - BB.Add (E, aV2); - BB.Range(E, p1, p2); - - DBRep::Set("ne", E); - return 0; -} - -static Handle(Geom2d_Curve) nullPCurve; -//======================================================================= -//function : CurveOnSurface -//purpose : -//======================================================================= -Handle(Geom2d_Curve) CurveOnSurface(const TopoDS_Edge& E, - const TopoDS_Face& F, - Standard_Real& First, - Standard_Real& Last) -{ - TopLoc_Location l; - const Handle(Geom_Surface)& S = BRep_Tool::Surface(F,l); - TopoDS_Edge aLocalEdge = E; - if (F.Orientation() == TopAbs_REVERSED) { - aLocalEdge.Reverse(); - } - return CurveOnSurface(aLocalEdge,S,l,First,Last); -} - -//======================================================================= -//function : CurveOnSurface -//purpose : -//======================================================================= -Handle(Geom2d_Curve) CurveOnSurface(const TopoDS_Edge& E, - const Handle(Geom_Surface)& S, - const TopLoc_Location& L, - Standard_Real& First, - Standard_Real& Last) -{ - TopLoc_Location l = L.Predivided(E.Location()); - Standard_Boolean Eisreversed = (E.Orientation() == TopAbs_REVERSED); - - // find the representation - BRep_ListIteratorOfListOfCurveRepresentation itcr - ((*((Handle(BRep_TEdge)*)&E.TShape()))->ChangeCurves()); - - while (itcr.More()) { - const Handle(BRep_CurveRepresentation)& cr = itcr.Value(); - if (cr->IsCurveOnSurface(S,l)) { - const Handle(BRep_GCurve)& GC = *((Handle(BRep_GCurve)*)&cr); - GC->Range(First,Last); - if (GC->IsCurveOnClosedSurface() && Eisreversed) - return GC->PCurve2(); - else - return GC->PCurve(); - } - itcr.Next(); - } - return nullPCurve; -} - -//======================================================================= -//function : bexplode -//purpose : -//======================================================================= -static Standard_Integer bexplode(Draw_Interpretor& di, - Standard_Integer n, - const char** a) -{ - if (n <= 1) return 1; - TopoDS_Shape S = DBRep::Get(a[1]); - if (S.IsNull()) return 0; - char newname[1024]; - strcpy(newname,a[1]); - char* p = newname; - while (*p != '\0') p++; - *p = '_'; - p++; - Standard_Integer i = 0; - if (n == 2) { - TopoDS_Iterator itr(S); - while (itr.More()) { - i++; - sprintf(p,"%d",i); - DBRep::Set(newname,itr.Value()); - di.AppendElement(newname); - itr.Next(); - } - } - else { - // explode a type - TopAbs_ShapeEnum typ; - switch (a[2][0]) { - - case 'C' : - case 'c' : - if ((a[2][1] == 'd')||(a[2][1] == 'D')) - typ = TopAbs_COMPOUND; - else - typ = TopAbs_COMPSOLID; - break; - - case 'S' : - case 's' : - if ((a[2][1] == 'O')||(a[2][1] == 'o')) - typ = TopAbs_SOLID; - else if ((a[2][1] == 'H')||(a[2][1] == 'h')) - typ = TopAbs_SHELL; - else - return 1; - break; - - case 'F' : - case 'f' : - typ = TopAbs_FACE; - break; - - case 'W' : - case 'w' : - typ = TopAbs_WIRE; - break; - - case 'E' : - case 'e' : - typ = TopAbs_EDGE; - break; - - case 'V' : - case 'v' : - typ = TopAbs_VERTEX; - break; - - default : - return 1; - } - - - TopExp_Explorer ex(S,typ); - for (; ex.More(); ex.Next()) { - const TopoDS_Shape& aS = ex.Current(); - i++; - sprintf(p,"%d",i); - DBRep::Set(newname,aS); - di.AppendElement(newname); - } - } - return 0; -} - //======================================================================= //function : bclassify //purpose : //======================================================================= Standard_Integer bclassify (Draw_Interpretor& aDI, - Standard_Integer n, - const char** a) + Standard_Integer n, + const char** a) { char sbf[512]; @@ -673,8 +118,8 @@ Standard_Integer bclassify (Draw_Interpretor& aDI, //purpose : //======================================================================= Standard_Integer b2dclassify (Draw_Interpretor& aDI, - Standard_Integer n, - const char** a) + Standard_Integer n, + const char** a) { char sbf[512]; @@ -718,12 +163,13 @@ Standard_Integer b2dclassify (Draw_Interpretor& aDI, // return 0; } + //======================================================================= //function : PrintState //purpose : //======================================================================= void PrintState (Draw_Interpretor& aDI, - const TopAbs_State& aState) + const TopAbs_State& aState) { char sbf[512]; TCollection_AsciiString sIN("IN"), sOUT("OUT of"), sON("ON"), sUNKNOWN("UNKNOWN"); @@ -731,16 +177,16 @@ void PrintState (Draw_Interpretor& aDI, sprintf(sbf, "The point is "); aDI< - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//======================================================================= -//function :bbedge -//purpose : -//======================================================================= -static Standard_Integer bbedge (Draw_Interpretor& di, - Standard_Integer n, - const char** a) -{ - if (n<7) { - di << " Use bbedge> Edge1 Edge2 f1 l1 f2 l2\n"; - return 1; - } - - TopoDS_Shape S1 = DBRep::Get(a[1]); - TopoDS_Shape S2 = DBRep::Get(a[2]); - - if (S1.IsNull() || S2.IsNull()) { - di << " Null shapes is not allowed \n"; - return 1; - } - - if (S1.ShapeType()!=TopAbs_EDGE && S2.ShapeType()!=TopAbs_EDGE) { - di << " Shapes must be EDGE type\n"; - return 1; - } - - TopoDS_Edge E1=TopoDS::Edge(S1); - TopoDS_Edge E2=TopoDS::Edge(S2); - - Standard_Integer aDiscr=30; - Standard_Real aTol=.0000001, aDeflection=.01; - Standard_Real f1, l1, f2, l2; - - f1=atof (a[3]); - l1=atof (a[4]); - f2=atof (a[5]); - l2=atof (a[6]); - - IntTools_Range aR1, aR2; - aR1.SetFirst(f1); aR1.SetLast(l1); - aR2.SetFirst(f2); aR2.SetLast(l2); - - di << " bbedge: ===Begin===\n"; - di << " bbedge: Discretize=" << aDiscr << "\n"; - di << " bbedge: Tolerance =" << aTol << "\n"; - di << " bbedge: Deflection=" << aDeflection << "\n"; - - IntTools_EdgeEdge aEE; - - - aEE.SetEdge1(E1); - aEE.SetEdge2(E2); - aEE.SetTolerance1(aTol); - aEE.SetTolerance2(aTol); - - aEE.SetDiscretize(aDiscr); - aEE.SetDeflection(aDeflection); - - aEE.SetRange1(aR1); - aEE.SetRange2(aR2); - - aEE.Perform(); - // - // Results treatment - Standard_Boolean anIsDone=aEE.IsDone(); - di << "\n aEE.IsDone()=" << (Standard_Integer) anIsDone << ", aEE.ErrorStatus()=" << aEE.ErrorStatus() << "\n"; - - if (anIsDone) { - const IntTools_SequenceOfCommonPrts& aSCp=aEE.CommonParts (); - - Standard_Integer i,j, aNbRanges, aNbRanges2; - Standard_Real t1, t2; - - aNbRanges=aSCp.Length(); - for (i=1; i<=aNbRanges; i++) { - const IntTools_CommonPrt& aCommonPrt=aSCp(i); - - di << " CommonPrt#" << i << " , Type=" << aCommonPrt.Type() << "\n"; - const IntTools_Range& aRange1=aCommonPrt.Range1(); - aRange1.Range(t1, t2); - di << "Range 1: [" << t1 << ", " << t2 << "]\n"; - - const IntTools_SequenceOfRanges& aSeqOfRanges2=aCommonPrt.Ranges2(); - aNbRanges2=aSeqOfRanges2.Length(); - for (j=1; j<=aNbRanges2; j++) { - const IntTools_Range& aRange2=aSeqOfRanges2(j); - aRange2.Range(t1, t2); - di << "Range 2: [" << t1 << ", " << t2 << "] (# " << j << ")\n"; - } - } - } - - - di << " bedge: ===End===\n"; - return 0; -} - -//======================================================================= -//function :bedge -//purpose : -//======================================================================= -static Standard_Integer bedge (Draw_Interpretor& di, - Standard_Integer n, - const char** a) -{ - if (n<3) { - di << " Use bedge> Edge1 Edge2 Discr[30] Tol[1.e-7] Deflection[0.01]\n"; - return 1; - } - - TopoDS_Shape S1 = DBRep::Get(a[1]); - TopoDS_Shape S2 = DBRep::Get(a[2]); - - if (S1.IsNull() || S2.IsNull()) { - di << " Null shapes is not allowed \n"; - return 1; - } - - if (S1.ShapeType()!=TopAbs_EDGE && S2.ShapeType()!=TopAbs_EDGE) { - di << " Shapes must be EDGE type\n"; - return 1; - } - - TopoDS_Edge E1=TopoDS::Edge(S1); - TopoDS_Edge E2=TopoDS::Edge(S2); - - Standard_Integer aDiscr=30; - Standard_Real aTol=.0000001, aDeflection=.01; - Standard_Real f1, l1, f2, l2; - - BRep_Tool::Range(E1, f1, l1); - BRep_Tool::Range(E2, f2, l2); - - IntTools_Range aR1, aR2; - aR1.SetFirst(f1); aR1.SetLast(l1); - aR2.SetFirst(f2); aR2.SetLast(l2); - - if (n>=4) { - aDiscr=atoi (a[3]); - } - - if (n>=5) { - aTol=atof (a[4]); - } - - if (n>=6) { - aDeflection=atof (a[5]); - } - - di << " bedge: ===Begin===\n"; - di << " bedge: Discretize=" << aDiscr << "\n"; - di << " bedge: Tolerance =" << aTol << "\n"; - di << " bedge: Deflection=" << aDeflection << "\n"; - - IntTools_EdgeEdge aEE; - - - aEE.SetEdge1(E1); - aEE.SetEdge2(E2); - aEE.SetTolerance1(aTol); - aEE.SetTolerance2(aTol); - - aEE.SetDiscretize(aDiscr); - aEE.SetDeflection(aDeflection); - - aEE.SetRange1(aR1); - aEE.SetRange2(aR2); - - aEE.Perform(); - // - // Results treatment - Standard_Boolean anIsDone=aEE.IsDone(); - di << "\n aEE.IsDone()=" << (Standard_Integer) anIsDone << ", aEE.ErrorStatus()=" << aEE.ErrorStatus() << "\n"; - - if (anIsDone) { - const IntTools_SequenceOfCommonPrts& aSCp=aEE.CommonParts (); - - Standard_Integer i,j, aNbRanges, aNbRanges2; - Standard_Real t1, t2; - - aNbRanges=aSCp.Length(); - for (i=1; i<=aNbRanges; i++) { - const IntTools_CommonPrt& aCommonPrt=aSCp(i); - - di << " CommonPrt#" << i << " , Type=" << aCommonPrt.Type() << "\n"; - const IntTools_Range& aRange1=aCommonPrt.Range1(); - aRange1.Range(t1, t2); - di << "Range 1: [" << t1 << ", " << t2 << "]\n"; - - const IntTools_SequenceOfRanges& aSeqOfRanges2=aCommonPrt.Ranges2(); - aNbRanges2=aSeqOfRanges2.Length(); - for (j=1; j<=aNbRanges2; j++) { - const IntTools_Range& aRange2=aSeqOfRanges2(j); - aRange2.Range(t1, t2); - di << "Range 2: [" << t1 << ", " << t2 << "] (# " << j << ")\n"; - } - } - } - - - di << " bedge: ===End===\n"; - return 0; -} - -//======================================================================= -//function : MTestCommands -//purpose : -//======================================================================= - void BOPTest::MTestCommands(Draw_Interpretor& theCommands) -{ - static Standard_Boolean done = Standard_False; - if (done) return; - done = Standard_True; - // Chapter's name - const char* g = "Mtest commands"; - - theCommands.Add("bedge" , "Use bedge> Edge1 Edge2 Discr[30] Tol[1.e-7] Deflection[0.01]", __FILE__, bedge,g); - theCommands.Add("bbedge", "Use bbedge> Edge1 Edge2 f1 l1 f2 l2", __FILE__, bbedge,g); -} diff --git a/src/BOPTest/BOPTest_ObjCommands.cxx b/src/BOPTest/BOPTest_ObjCommands.cxx new file mode 100644 index 0000000000..af568c1086 --- /dev/null +++ b/src/BOPTest/BOPTest_ObjCommands.cxx @@ -0,0 +1,156 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#include +#include + +#include +#include +// +#include +#include +// +#include +// +#include + +static Standard_Integer baddobjects (Draw_Interpretor& , Standard_Integer , const char** ); +static Standard_Integer bclearobjects (Draw_Interpretor& , Standard_Integer , const char** ); +static Standard_Integer baddtools (Draw_Interpretor& , Standard_Integer , const char** ); +static Standard_Integer bcleartools (Draw_Interpretor& , Standard_Integer , const char** ); +static Standard_Integer baddcompound(Draw_Interpretor& , Standard_Integer , const char** ); +// +//======================================================================= +//function :ObjCommands +//purpose : +//======================================================================= + void BOPTest::ObjCommands(Draw_Interpretor& theCommands) +{ + static Standard_Boolean done = Standard_False; + if (done) return; + done = Standard_True; + // Chapter's name + const char* g = "BOP commands"; + // Commands + theCommands.Add("baddobjects" , "baddobjects s1 s2 ..." , __FILE__, baddobjects, g); + theCommands.Add("bclearobjects" , "bclearobjects" , __FILE__, bclearobjects, g); + theCommands.Add("baddtools" , "baddtools s1 s2 ..." , __FILE__, baddtools, g); + theCommands.Add("bcleartools" , "bcleartools" , __FILE__, bcleartools, g); + theCommands.Add("baddcompound" , "baddcompound c" , __FILE__, baddcompound, g); +} +//======================================================================= +//function : baddcompound +//purpose : +//======================================================================= +Standard_Integer baddcompound (Draw_Interpretor& , Standard_Integer n, const char** a) +{ + if (n<2) { + printf(" Use baddcompound c\n"); + return 0; + } + // + TopoDS_Iterator aIt; + TopoDS_Shape aS; + // + aS=DBRep::Get(a[1]); + // + BOPCol_ListOfShape& aLS=BOPTest_Objects::Shapes(); + aIt.Initialize(aS); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aSx=aIt.Value(); + aLS.Append(aSx); + } + // + return 0; +} +// +//======================================================================= +//function :baddobjects +//purpose : +//======================================================================= +Standard_Integer baddobjects (Draw_Interpretor& , Standard_Integer n, const char** a) +{ + if (n<2) { + printf(" Use baddobjects s1 s2 ...\n"); + return 0; + } + // + Standard_Integer i; + TopoDS_Shape aS; + // + BOPCol_ListOfShape& aLS=BOPTest_Objects::Shapes(); + for (i = 1; i < n; ++i) { + aS=DBRep::Get(a[i]); + aLS.Append(aS); + } + // + return 0; +} +//======================================================================= +//function : bclearobjects +//purpose : +//======================================================================= +Standard_Integer bclearobjects (Draw_Interpretor& , Standard_Integer n, const char** ) +{ + if (n!=1) { + printf(" Use bclearobjects\n"); + return 0; + } + BOPCol_ListOfShape& aLS=BOPTest_Objects::Shapes(); + aLS.Clear(); + // + return 0; +} +//======================================================================= +//function : baddtools +//purpose : +//======================================================================= +Standard_Integer baddtools (Draw_Interpretor& , Standard_Integer n, const char** a) +{ + if (n<2) { + printf(" Use baddtools s1 s2 ...\n"); + return 0; + } + // + Standard_Integer i; + TopoDS_Shape aS; + // + BOPCol_ListOfShape& aLS=BOPTest_Objects::Tools(); + for (i = 1; i < n; ++i) { + aS=DBRep::Get(a[i]); + aLS.Append(aS); + } + // + return 0; +} +//======================================================================= +//function : bcleartools +//purpose : +//======================================================================= +Standard_Integer bcleartools (Draw_Interpretor& , Standard_Integer n, const char** ) +{ + if (n!=1) { + printf(" Use bcleartools\n"); + return 0; + } + BOPCol_ListOfShape& aLS=BOPTest_Objects::Tools(); + aLS.Clear(); + // + return 0; +} diff --git a/src/BOPTest/BOPTest_Objects.cdl b/src/BOPTest/BOPTest_Objects.cdl new file mode 100644 index 0000000000..4954aa6dc7 --- /dev/null +++ b/src/BOPTest/BOPTest_Objects.cdl @@ -0,0 +1,68 @@ +-- Created by: Peter KURNEV +-- Copyright (c) 1999-2012 OPEN CASCADE SAS +-- +-- The content of this file is subject to the Open CASCADE Technology Public +-- License Version 6.5 (the "License"). You may not use the content of this file +-- except in compliance with the License. Please obtain a copy of the License +-- at http://www.opencascade.org and read it completely before using this file. +-- +-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +-- +-- The Original Code and all software distributed under the License is +-- distributed on an "AS IS" basis, without warranty of any kind, and the +-- Initial Developer hereby disclaims all such warranties, including without +-- limitation, any warranties of merchantability, fitness for a particular +-- purpose or non-infringement. Please see the License for the specific terms +-- and conditions governing the rights and limitations under the License. + + +class Objects from BOPTest + + ---Purpose: + +uses + ListOfShape from BOPCol, + PaveFiller from BOPAlgo, + Builder from BOPAlgo, + PBuilder from BOPAlgo, + BOP from BOPAlgo, + PDS from BOPDS +--raises + +is + PaveFiller(myclass) + returns PaveFiller from BOPAlgo; + ---C++: return & + + Init(myclass); + + Clear(myclass); + + PDS(myclass) + returns PDS from BOPDS; + + Builder(myclass) + returns Builder from BOPAlgo; + ---C++: return & + + BOP(myclass) + returns BOP from BOPAlgo; + ---C++: return & + + Shapes(myclass) + returns ListOfShape from BOPCol; + ---C++: return & + + Tools(myclass) + returns ListOfShape from BOPCol; + ---C++: return & + -- + SetBuilder(myclass; + theBuilder:PBuilder from BOPAlgo); + + SetBuilderDefault(myclass); + +--fields + +end Objects; diff --git a/src/BOPTest/BOPTest_Objects.cxx b/src/BOPTest/BOPTest_Objects.cxx new file mode 100644 index 0000000000..58eb8055a5 --- /dev/null +++ b/src/BOPTest/BOPTest_Objects.cxx @@ -0,0 +1,208 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#include + +#include +#include + +static Handle(NCollection_BaseAllocator)& Allocator1(); + +//======================================================================= +//function : BOPTest_Session +//purpose : +//======================================================================= +class BOPTest_Session { + public: + // + BOPTest_Session() { + Init(); + }; + // + ~BOPTest_Session(){ + Clear(); + }; + // + // Init + void Init() { + Handle(NCollection_BaseAllocator) pA1, pA2; + // + pA1=new NCollection_IncAllocator; + pA2=new NCollection_IncAllocator; + // + myPaveFiller=new BOPAlgo_PaveFiller(pA1); + myBuilderDefault=new BOPAlgo_Builder(pA2); + // + myBuilder=myBuilderDefault; + }; + // + // Clear + void Clear() { + if (myPaveFiller) { + delete myPaveFiller; + myPaveFiller=NULL; + } + // + if (myBuilderDefault) { + delete myBuilderDefault; + myBuilderDefault=NULL; + } + }; + // + // IsValid + Standard_Boolean IsValid() const { + return (myPaveFiller!=NULL); + } + // PaveFiller + BOPAlgo_PaveFiller& PaveFiller() { + return *myPaveFiller; + }; + // + // Builder + BOPAlgo_Builder& Builder() { + return *myBuilder; + }; + // + // SetBuilder + void SetBuilder(BOPAlgo_Builder* pBuilder) { + myBuilder=pBuilder; + }; + // + // SetBuilderDef + void SetBuilderDefault() { + myBuilder=myBuilderDefault; + }; + // + protected: + // + BOPAlgo_PaveFiller* myPaveFiller; + BOPAlgo_Builder* myBuilder; + BOPAlgo_Builder* myBuilderDefault; +}; +// +//======================================================================= +//function : GetSession +//purpose : +//======================================================================= +static BOPTest_Session& GetSession() +{ + static BOPTest_Session* pSession=new BOPTest_Session; + // + if (!pSession->IsValid()) { + pSession->Init(); + } + return *pSession; +} +// +//======================================================================= +//function : Init +//purpose : +//======================================================================= +void BOPTest_Objects::Init() +{ + GetSession().Init(); +} +//======================================================================= +//function : Clear +//purpose : +//======================================================================= +void BOPTest_Objects::Clear() +{ + GetSession().Clear(); +} +//======================================================================= +//function : PaveFiller +//purpose : +//======================================================================= +BOPAlgo_PaveFiller& BOPTest_Objects::PaveFiller() +{ + return GetSession().PaveFiller(); +} +//======================================================================= +//function : PDS +//purpose : +//======================================================================= +BOPDS_PDS BOPTest_Objects::PDS() +{ + return BOPTest_Objects::PaveFiller().PDS(); +} +//======================================================================= +//function : Builder +//purpose : +//======================================================================= +BOPAlgo_Builder& BOPTest_Objects::Builder() +{ + return GetSession().Builder(); +} +//======================================================================= +//function : SetBuilder +//purpose : +//======================================================================= +void BOPTest_Objects::SetBuilder(const BOPAlgo_PBuilder& theBuilder) +{ + BOPAlgo_Builder* pB; + // + pB=(BOPAlgo_Builder*)theBuilder; + GetSession().SetBuilder(pB); +} +//======================================================================= +//function : SetBuilderDefault +//purpose : +//======================================================================= +void BOPTest_Objects::SetBuilderDefault() +{ + GetSession().SetBuilderDefault(); +} +//======================================================================= +//function : BOP +//purpose : +//======================================================================= +BOPAlgo_BOP& BOPTest_Objects::BOP() +{ + static BOPAlgo_BOP sBOP(Allocator1()); + return sBOP; +} +//======================================================================= +//function : Shapes +//purpose : +//======================================================================= +BOPCol_ListOfShape& BOPTest_Objects::Shapes() +{ + static BOPCol_ListOfShape s_Shapes; + return s_Shapes; +} +//======================================================================= +//function : Tools +//purpose : +//======================================================================= +BOPCol_ListOfShape& BOPTest_Objects::Tools() +{ + static BOPCol_ListOfShape s_Tools; + return s_Tools; +} +//======================================================================= +//function : Allocator1 +//purpose : +//======================================================================= +Handle(NCollection_BaseAllocator)& Allocator1() +{ + static Handle(NCollection_BaseAllocator) sAL1= + new NCollection_IncAllocator; + return sAL1; +} diff --git a/src/BOPTest/BOPTest_PartitionCommands.cxx b/src/BOPTest/BOPTest_PartitionCommands.cxx new file mode 100644 index 0000000000..288d80f90b --- /dev/null +++ b/src/BOPTest/BOPTest_PartitionCommands.cxx @@ -0,0 +1,255 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#include + +#include + +#include + +#include +#include +#include +#include + +#include +// +#include +#include +#include +#include +// +#include +#include + +// +static Standard_Integer bfillds (Draw_Interpretor&, Standard_Integer, const char**); +static Standard_Integer bbuild (Draw_Interpretor&, Standard_Integer, const char**); +static Standard_Integer bbop (Draw_Interpretor&, Standard_Integer, const char**); +static Standard_Integer bclear (Draw_Interpretor&, Standard_Integer, const char**); +//======================================================================= +//function : PartitionCommands +//purpose : +//======================================================================= + void BOPTest::PartitionCommands(Draw_Interpretor& theCommands) +{ + static Standard_Boolean done = Standard_False; + if (done) return; + done = Standard_True; + // Chapter's name + const char* g = "Partition commands"; + // Commands + theCommands.Add("bfillds" , "use bfillds" , __FILE__, bfillds , g); + theCommands.Add("bbuild" , "use bbuild r" , __FILE__, bbuild, g); + theCommands.Add("bbop" , "use bbop r op" , __FILE__, bbop, g); + theCommands.Add("bclear" , "use bclear" , __FILE__, bclear, g); +} + +//======================================================================= +//function : bclear +//purpose : +//======================================================================= +Standard_Integer bclear(Draw_Interpretor& di, Standard_Integer n, const char** ) +{ + if (n!=1) { + di << " use bclear\n"; + return 0; + } + // + BOPTest_Objects::Clear(); + return 0; +} +//======================================================================= +//function : bfillds +//purpose : +//======================================================================= +Standard_Integer bfillds(Draw_Interpretor& di, Standard_Integer n, const char** ) +{ + if (n!=1) { + di << " Use bfillds\n"; + return 0; + } + // + char buf[32]; + Standard_Integer aNbS, aNbT, iErr; + BOPCol_ListIteratorOfListOfShape aIt; + BOPCol_ListOfShape aLC; + + BOPCol_ListOfShape& aLS=BOPTest_Objects::Shapes(); + aNbS=aLS.Extent(); + if (!aNbS) { + di << " no objects to process\n"; + return 0; + } + // + BOPCol_ListOfShape& aLT=BOPTest_Objects::Tools(); + aNbT=aLT.Extent(); + // + aIt.Initialize(aLS); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aS=aIt.Value(); + aLC.Append(aS); + } + // + aIt.Initialize(aLT); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aS=aIt.Value(); + aLC.Append(aS); + } + // + BOPAlgo_PaveFiller& aPF=BOPTest_Objects::PaveFiller(); + // + aPF.SetArguments(aLC); + // + aPF.Perform(); + iErr=aPF.ErrorStatus(); + if (iErr) { + sprintf(buf, " error: %d\n", iErr); + di << buf; + return 0; + } + // + return 0; +} + +//======================================================================= +//function : bbuild +//purpose : +//======================================================================= +Standard_Integer bbuild(Draw_Interpretor& di, Standard_Integer n, const char** a) +{ + if (n!=2) { + di << " Use bbuild r\n"; + return 0; + } + // + BOPDS_PDS pDS=BOPTest_Objects::PDS(); + if (!pDS) { + di << " prepare PaveFiller first\n"; + return 0; + } + // + char buf[32]; + Standard_Integer iErr; + BOPCol_ListIteratorOfListOfShape aIt; + // + BOPAlgo_PaveFiller& aPF=BOPTest_Objects::PaveFiller(); + // + BOPAlgo_Builder& aBuilder=BOPTest_Objects::Builder(); + aBuilder.Clear(); + // + BOPCol_ListOfShape& aLSObj=BOPTest_Objects::Shapes(); + aIt.Initialize(aLSObj); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aS=aIt.Value(); + aBuilder.AddArgument(aS); + } + // + BOPCol_ListOfShape& aLSTool=BOPTest_Objects::Tools(); + aIt.Initialize(aLSTool); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aS=aIt.Value(); + aBuilder.AddArgument(aS); + } + // + aBuilder.PerformWithFiller(aPF); + iErr=aBuilder.ErrorStatus(); + if (iErr) { + sprintf(buf, " error: %d\n", iErr); + di << buf; + return 0; + } + // + const TopoDS_Shape& aR=aBuilder.Shape(); + if (aR.IsNull()) { + di << " null shape\n"; + return 0; + } + // + DBRep::Set(a[1], aR); + return 0; +} + +//======================================================================= +//function : bbop +//purpose : +//======================================================================= +Standard_Integer bbop(Draw_Interpretor& di, Standard_Integer n, const char** a) +{ + if (n!=3) { + di << " use bbop r op\n"; + return 0; + } + // + BOPDS_PDS pDS=BOPTest_Objects::PDS(); + if (!pDS) { + di << " prepare PaveFiller first\n"; + return 0; + } + // + char buf[32]; + Standard_Integer iErr, iOp; + BOPAlgo_Operation aOp; + BOPCol_ListIteratorOfListOfShape aIt; + // + iOp=atoi(a[2]); + if (iOp<0 || iOp>4) { + di << " invalid operation type\n"; + } + aOp=(BOPAlgo_Operation)iOp; + // + BOPAlgo_PaveFiller& aPF=BOPTest_Objects::PaveFiller(); + // + BOPAlgo_BOP& aBOP=BOPTest_Objects::BOP(); + aBOP.Clear(); + // + BOPCol_ListOfShape& aLSObj=BOPTest_Objects::Shapes(); + aIt.Initialize(aLSObj); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aS=aIt.Value(); + aBOP.AddArgument(aS); + } + // + BOPCol_ListOfShape& aLSTools=BOPTest_Objects::Tools(); + aIt.Initialize(aLSTools); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aS=aIt.Value(); + aBOP.AddTool(aS); + } + // + aBOP.SetOperation(aOp); + // + aBOP.PerformWithFiller(aPF); + iErr=aBOP.ErrorStatus(); + if (iErr) { + sprintf(buf, " error: %d\n", iErr); + di << buf; + return 0; + } + // + const TopoDS_Shape& aR=aBOP.Shape(); + if (aR.IsNull()) { + di << " null shape\n"; + return 0; + } + // + DBRep::Set(a[1], aR); + return 0; +} + diff --git a/src/BOPTest/BOPTest_TSTCommands.cxx b/src/BOPTest/BOPTest_TSTCommands.cxx deleted file mode 100755 index efb0643710..0000000000 --- a/src/BOPTest/BOPTest_TSTCommands.cxx +++ /dev/null @@ -1,21 +0,0 @@ -// Created on: 2000-03-16 -// Created by: Peter KURNEV -// Copyright (c) 2000-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#include diff --git a/src/BOPTest/BOPTest_TolerCommands.cxx b/src/BOPTest/BOPTest_TolerCommands.cxx old mode 100755 new mode 100644 index b5ff0933af..5e832472f4 --- a/src/BOPTest/BOPTest_TolerCommands.cxx +++ b/src/BOPTest/BOPTest_TolerCommands.cxx @@ -1,5 +1,4 @@ // Created on: 2000-03-16 -// Created by: Peter KURNEV // Copyright (c) 2000-2012 OPEN CASCADE SAS // // The content of this file is subject to the Open CASCADE Technology Public @@ -70,8 +69,8 @@ static // static void ProcessVertex(const TopoDS_Vertex&, - const TopTools_ListOfShape&, - const TopTools_ListOfShape&); + const TopTools_ListOfShape&, + const TopTools_ListOfShape&); static void ProcessEdge(const TopoDS_Edge&, const Standard_Real); diff --git a/src/BOPTest/BOPTest_WSplitCommands.cxx b/src/BOPTest/BOPTest_WSplitCommands.cxx deleted file mode 100755 index bf499d2e00..0000000000 --- a/src/BOPTest/BOPTest_WSplitCommands.cxx +++ /dev/null @@ -1,228 +0,0 @@ -// Created on: 2000-03-16 -// Created by: Peter KURNEV -// Copyright (c) 2000-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include - -#include - -#include - -#include -#include - -#include -#include - -#include - -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include - -#include -#include - -#include -#include - - - - -static Standard_Integer bwsplit (Draw_Interpretor&, Standard_Integer, const char** ); -static Standard_Integer bssplit (Draw_Interpretor&, Standard_Integer, const char** ); - - -//======================================================================= -//function : WSplitCommands -//purpose : -//======================================================================= - void BOPTest::WSplitCommands(Draw_Interpretor& theCommands) -{ - static Standard_Boolean done = Standard_False; - if (done) - return; - - done = Standard_True; - // Chapter's name - const char* g = "CCR commands"; - - theCommands.Add("bwsplit" , "Use bwsplit> Face" , __FILE__, bwsplit , g); - theCommands.Add("bssplit" , "Use bssplit> Shell" , __FILE__, bssplit , g); -} - -//======================================================================= -//function : bssplit -//purpose : -//======================================================================= -Standard_Integer bssplit (Draw_Interpretor& di, - Standard_Integer n, - const char** a) -{ - if (n!=2) { - di << " Use bssplit> Shell\n"; - return 1; - } - - TopoDS_Shape S = DBRep::Get(a[1]); - - if (S.IsNull()) { - di << " Null shape is not allowed \n"; - return 1; - } - - Standard_Boolean anIsDone, anIsNothingToDo ; - - TopAbs_ShapeEnum aT; - aT=S.ShapeType(); - if (aT!=TopAbs_SHELL) { - di << " Shape Type must be SHELL\n"; - return 1; - } - - const TopoDS_Shell& aSh = TopoDS::Shell(S); - - BOP_ShellSplitter aShellSplitter; - aShellSplitter.SetShell(aSh); - aShellSplitter.DoWithShell (); - anIsDone=aShellSplitter.IsDone(); - di << " aShellSplitter.IsDone=" << (Standard_Integer) anIsDone << "\n"; - - anIsNothingToDo=aShellSplitter.IsNothingToDo(); - di << " IsNothingToDo=" << (Standard_Integer) anIsNothingToDo << "\n"; - - if (!anIsDone) { - return 0; - } - if (anIsNothingToDo) { - return 0; - } - // - Standard_Integer i=1; - BRep_Builder BB; - const BOPTColStd_ListOfListOfShape& aSSS=aShellSplitter.Shapes(); - BOPTColStd_ListIteratorOfListOfListOfShape aWireIt(aSSS); - for (; aWireIt.More(); aWireIt.Next(), ++i) { - TopoDS_Compound aCompound; - BB.MakeCompound(aCompound); - - const TopTools_ListOfShape& aListEd=aWireIt.Value(); - - TopTools_ListIteratorOfListOfShape anIt(aListEd); - for (; anIt.More(); anIt.Next()) { - const TopoDS_Shape& aE=anIt.Value(); - BB.Add(aCompound, aE); - } - TCollection_AsciiString aName(a[1]), aDef("_"), anI(i), aRName; - aRName=aName; - aRName=aRName+aDef; - aRName=aRName+anI; - - DBRep::Set (aRName.ToCString(), aCompound); - di << aRName.ToCString() << "\n"; - } - - return 0; -} - -//======================================================================= -//function : bwsplit -//purpose : -//======================================================================= -Standard_Integer bwsplit (Draw_Interpretor& di, - Standard_Integer n, - const char** a) -{ - if (n!=2) { - di << " Use bwsplit> Face\n"; - return 1; - } - - TopoDS_Shape S = DBRep::Get(a[1]); - - if (S.IsNull()) { - di << " Null shape is not allowed \n"; - return 1; - } - - Standard_Boolean anIsDone, anIsNothingToDo ; - - TopAbs_ShapeEnum aT; - aT=S.ShapeType(); - if (aT!=TopAbs_FACE) { - di << " Shape Type must be FACE\n"; - return 1; - } - - const TopoDS_Face& aF = TopoDS::Face(S); - - BOP_WireSplitter aWireSplitter; - aWireSplitter.SetFace(aF); - aWireSplitter.DoWithFace (); - anIsDone=aWireSplitter.IsDone(); - di << " aWireSplitter.IsDone=" << (Standard_Integer) anIsDone << "\n"; - - anIsNothingToDo=aWireSplitter.IsNothingToDo(); - di << " IsNothingToDo=" << (Standard_Integer) anIsNothingToDo << "\n"; - - if (!anIsDone) { - return 0; - } - if (anIsNothingToDo) { - return 0; - } - // - Standard_Integer i=1; - BRep_Builder BB; - const BOPTColStd_ListOfListOfShape& aSSS=aWireSplitter.Shapes(); - BOPTColStd_ListIteratorOfListOfListOfShape aWireIt(aSSS); - for (; aWireIt.More(); aWireIt.Next(), ++i) { - TopoDS_Compound aCompound; - BB.MakeCompound(aCompound); - - const TopTools_ListOfShape& aListEd=aWireIt.Value(); - - TopTools_ListIteratorOfListOfShape anIt(aListEd); - for (; anIt.More(); anIt.Next()) { - const TopoDS_Shape& aE=anIt.Value(); - BB.Add(aCompound, aE); - } - TCollection_AsciiString aName(a[1]), aDef("_"), anI(i), aRName; - aRName=aName; - aRName=aRName+aDef; - aRName=aRName+anI; - - DBRep::Set (aRName.ToCString(), aCompound); - di << aRName.ToCString() << "\n"; - } - return 0; -} - - diff --git a/src/BOPTest/FILES b/src/BOPTest/FILES index 2a9c16b0b9..f94d8f11a2 100755 --- a/src/BOPTest/FILES +++ b/src/BOPTest/FILES @@ -1,10 +1,6 @@ -BOPTest_MTestCommands.cxx -BOPTest_TSTCommands.cxx -BOPTest_EFCommands.cxx -BOPTest_LowCommands.cxx BOPTest_BOPCommands.cxx -BOPTest_WSplitCommands.cxx -BOPTest_CurveCommands.cxx -BOPTest_TolerCommands.cxx +BOPTest_PartitionCommands.cxx +BOPTest_LowCommands.cxx BOPTest_CheckCommands.cxx - +BOPTest_TolerCommands.cxx +BOPTest_ObjCommands.cxx diff --git a/src/BOPTools/BOPTools.cdl b/src/BOPTools/BOPTools.cdl index 887461747c..cd9171a128 100755 --- a/src/BOPTools/BOPTools.cdl +++ b/src/BOPTools/BOPTools.cdl @@ -1,4 +1,3 @@ --- Created on: 2000-11-16 -- Created by: Peter KURNEV -- Copyright (c) 2000-2012 OPEN CASCADE SAS -- @@ -17,372 +16,67 @@ -- purpose or non-infringement. Please see the License for the specific terms -- and conditions governing the rights and limitations under the License. +package BOPTools -package BOPTools + ---Purpose: - ---Purpose: - --- Contains main and auxiliary classes to fill the - --- Data Structure (DS) to provide boolean - --- operations between a couple BRep shapes. - --- - -uses +uses gp, Bnd, - TopAbs, + TopAbs, + Geom, + Geom2d, + GeomAPI, + BRepClass3d, TopoDS, TopTools, - TCollection, - TColStd, - SortTools, - Geom, - Geom2d, + IntTools, ProjLib, - BooleanOperations, - BOPTColStd, - IntTools + -- + BOPCol, + BOPInt +is + + -- + -- classes + -- + class ShapeSet; + class EdgeSet; + class AlgoTools; + class Set; + class SetMapHasher; + class AlgoTools2D; + class AlgoTools3D; + -- + imported MapOfSet; + imported DataMapOfShapeSet; + -- + -- primitives + -- + imported ListOfShapeSet from BOPTools; + imported ListOfEdgeSet from BOPTools; + imported ConnexityBlock from BOPTools; + imported ListOfConnexityBlock from BOPTools; + imported CoupleOfShape from BOPTools; + imported ListOfCoupleOfShape from BOPTools; + -- + -- static methods + -- + MapShapes(S : Shape from TopoDS; + M : in out MapOfShape from BOPCol); + + MapShapes(S : Shape from TopoDS; + M : in out IndexedMapOfShape from BOPCol); + + MapShapes(S : Shape from TopoDS; + T : ShapeEnum from TopAbs; + M : in out IndexedMapOfShape from BOPCol); + + + MapShapesAndAncestors + (S : Shape from TopoDS; + TS : ShapeEnum from TopAbs; + TA : ShapeEnum from TopAbs; + M : in out IndexedDataMapOfShapeListOfShape from BOPCol); -is - --- - --- E n u m e r a t i o n s - --- - enumeration IntersectionStatus is - INTERSECTED, - BOUNDINGBOXINTERSECTED, - BOUNDINGBOXOFSUBSHAPESINTERSECTED, - NONINTERSECTED, - UNKNOWN - end IntersectionStatus; - - enumeration CheckStatus is - CHKUNKNOWN, - VERTEXVERTEX, - VERTEXEDGE, - VERTEXFACE, - EDGEEDGE, - EDGEEDGECOMBLK, - EDGEFACE, - EDGEFACECOMBLK, - FACEFACE, - BADSHRANKRANGE, - NULLSRANKRANGE - end CheckStatus; - --- - --- T h e C l a s s e s - --- - - --- +==========================+ - --- ! Fillers and friends ! - --- +==========================+ - class PaveFiller; - ---Purpose: - --- Class that provides - --- 1. computation of interferences of all types - --- 2. storing the interferences in interferences' pool - --- 3. building new vertices, edges and storing them in the DS - --- 4. preparing the information about PaveBlocks, CommonBlocks - --- - class DSFiller; - ---Purpose: - --- Class that provides - --- 1. creation of the data structure (DS) - --- 2. creation of the interferences' pool - --- 3. invokation of PaveFiller->Perform() to fill the DS - --- - --- - class DEProcessor; - ---Purpose: - --- Class to compute and store in interferences' pool - --- and DS the following values - --- for degenerated edges - --- 1. Paves/Pave set(s) - --- 2. Split parts - --- 3. States (3D) for split parts - --- - class PCurveMaker; - ---Purpose: - --- Class to compute p-curves for the edges and theirs - --- split parts - --- - - class SolidStateFiller; - ---Purpose: - --- Class to compute states (3D) for the edges (and theirs - --- split parts), vertices, wires, faces, shells - --- - class StateFiller; - ---Purpose: - --- Root class for state fillers - --- - class WireStateFiller; - ---Purpose: - --- Class to compute states (3D) for the edges (and theirs - --- split parts), vertices, wires - --- - --- +================================+ - --- ! Paves and Blocks of Paves ! - --- +================================+ - class Pave; - ---Purpose: - --- Class for storing info about a vertex on an edge - --- - class PaveBlock; - ---Purpose: - --- Class for storing info about a couple - --- of neighbouring paves on an edge - --- - class PaveSet; - ---Purpose: - --- Class for storing/sorting paves that belong to an edge - --- - - class PaveBlockIterator; - ---Purpose: - --- Class providing iterations for PaveSet to - --- have the right order of paves along the edge - --- - class ComparePave; - ---Purpose: - --- Class providing interface necessary for sorting - --- paves along the edge - --- - class CommonBlock; - ---Purpose: - --- Class for storing info about a couple - --- of pave blocks that are considered as common - --- - class CommonBlockAPI; - ---Purpose: - --- Class that provide useful tools to manage with - --- List Of Common Block-s - --- - - - - --- +==============+ - --- ! Intrferences ! - --- +==============+ - class ShapeShapeInterference; - ---Purpose: - --- Root class for storing an Interference - --- between a couple BRep shapes - --- - class VVInterference; - ---Purpose: - --- Class for storing an Verex/Vertex - --- interference - --- - class VSInterference; - ---Purpose: - --- Class for storing an Verex/Face - --- interference - --- - class VEInterference; - ---Purpose: - --- Class for storing an Verex/Edge - --- interference - --- - class EEInterference; - ---Purpose: - --- Class for storing an Edge/Edge - --- interference - --- - class ESInterference; - ---Purpose: - --- Class for storing an Edge/Face - --- interference - --- - class SSInterference; - ---Purpose: - --- Class for storing an Face/Face - --- interference - --- - class Interference; - ---Purpose: - --- Class for storing information about an - --- interference - --- - class InterferenceLine; - ---Purpose: - --- Class for storing information about all - --- interferences for given shape - --- - class InterferencePool; - ---Purpose: - --- Class for storing information about - --- results of all interferences for all shapes - --- - - --- +=======+ - --- ! Tools ! - --- +=======+ - class Tools; - class Tools2D; - class Tools3D; - --- +=============+ - --- ! Miscellanea ! - --- +=============+ - - - class DEInfo; - ---Purpose: - --- Class for storing information about - --- a degenerated edge - --- - class PointBetween; - ---Purpose: - --- Class for storing geometry information about - --- a point between neighbouring paves along - --- an edge - --- - class Curve; - ---Purpose: - --- Class for storing information about - --- intersection curve and set of paves on it - --- - class CoupleOfInteger; - - - class Checker; - ---Purpose: - --- Class that provides the algorithm - --- to check a shape on self-interference. - --- - - class CheckResult; - ---Purpose: provides a container to store faulty - --- sub - shapes in tested shape with type of - --- detected faulty - - --- - --- P o i n t e r s - --- - pointer PInterferencePool to InterferencePool from BOPTools; - pointer PPaveFiller to PaveFiller from BOPTools; - pointer PDSFiller to DSFiller from BOPTools; - pointer PShapeShapeInterference to ShapeShapeInterference from BOPTools; - --- - --- I n s t a n t i a t i o n s - --- - class ListOfCoupleOfInteger instantiates - List from TCollection (CoupleOfInteger from BOPTools); - - class ListOfInterference instantiates - List from TCollection (Interference from BOPTools); - - class CArray1OfInterferenceLine instantiates - CArray1 from BOPTColStd(InterferenceLine from BOPTools); - - class CArray1OfSSInterference instantiates - CArray1 from BOPTColStd(SSInterference from BOPTools); - - class CArray1OfESInterference instantiates - CArray1 from BOPTColStd(ESInterference from BOPTools); - - class CArray1OfVSInterference instantiates - CArray1 from BOPTColStd(VSInterference from BOPTools); - - class CArray1OfEEInterference instantiates - CArray1 from BOPTColStd(EEInterference from BOPTools); - - class CArray1OfVEInterference instantiates - CArray1 from BOPTColStd(VEInterference from BOPTools); - - class CArray1OfVVInterference instantiates - CArray1 from BOPTColStd(VVInterference from BOPTools); - - class PavePool instantiates - CArray1 from BOPTColStd(PaveSet from BOPTools); - - class ListOfPave instantiates - List from TCollection(Pave); - - class ListOfCommonBlock instantiates - List from TCollection(CommonBlock from BOPTools); - - class ListOfPaveBlock instantiates - List from TCollection(PaveBlock from BOPTools); - - class CommonBlockPool instantiates - CArray1 from BOPTColStd (ListOfCommonBlock from BOPTools); - - class SplitShapesPool instantiates - CArray1 from BOPTColStd (ListOfPaveBlock from BOPTools); - - class Array1OfPave instantiates - Array1 from TCollection (Pave from BOPTools); - - class CArray1OfPave instantiates - CArray1 from BOPTColStd (Pave from BOPTools); - - class QuickSortPave instantiates - QuickSort from SortTools (Pave from BOPTools, - Array1OfPave from BOPTools, - ComparePave from BOPTools); - - class IndexedDataMapOfIntegerState instantiates - IndexedDataMap from TCollection (Integer from Standard, - StateOfShape from BooleanOperations, - MapIntegerHasher from TColStd); - - class SequenceOfCurves instantiates - Sequence from TCollection(Curve from BOPTools); - - class IndexedDataMapOfShapeWithState instantiates - IndexedDataMap from TCollection (Shape from TopoDS, - StateOfShape from BooleanOperations, - ShapeMapHasher from TopTools); - class ListOfShapeEnum instantiates - List from TCollection(ShapeEnum from TopAbs); - - class IndexedDataMapOfIntegerDEInfo instantiates - IndexedDataMap from TCollection (Integer from Standard, - DEInfo from BOPTools, - MapIntegerHasher from TColStd); - - class Array2OfIntersectionStatus instantiates - Array2 from TCollection (IntersectionStatus from BOPTools); - - class HArray2OfIntersectionStatus instantiates - HArray2 from TCollection (IntersectionStatus from BOPTools, - Array2OfIntersectionStatus from BOPTools); - - class ListOfCheckResults instantiates - List from TCollection (CheckResult from BOPTools); - - class RoughShapeIntersector; - class IteratorOfCoupleOfShape; - class SSIntersectionAttribute; - --- --- additions --- - class CoupleOfIntegerMapHasher; - class PaveBlockMapHasher; - - class IndexedMapOfCoupleOfInteger instantiates - IndexedMap from TCollection(CoupleOfInteger from BOPTools, - CoupleOfIntegerMapHasher from BOPTools); - - class IndexedDataMapOfIntegerPaveSet instantiates - IndexedDataMap from TCollection (Integer from Standard, - PaveSet from BOPTools, - MapIntegerHasher from TColStd); - class IMapOfPaveBlock instantiates - IndexedMap from TCollection(PaveBlock from BOPTools, - PaveBlockMapHasher from BOPTools); - - class IDMapOfPaveBlockIMapOfPaveBlock instantiates - IndexedDataMap from TCollection (PaveBlock from BOPTools , - IMapOfPaveBlock from BOPTools, - PaveBlockMapHasher from BOPTools); - - class IDMapOfPaveBlockIMapOfInteger instantiates - IndexedDataMap from TCollection (PaveBlock from BOPTools , - IndexedMapOfInteger from TColStd, - PaveBlockMapHasher from BOPTools); - - class SequenceOfPaveBlock instantiates - Sequence from TCollection(PaveBlock from BOPTools); - -end BOPTools; +end BOPTools; diff --git a/src/BOPTools/BOPTools.cxx b/src/BOPTools/BOPTools.cxx new file mode 100644 index 0000000000..8d0198fdd2 --- /dev/null +++ b/src/BOPTools/BOPTools.cxx @@ -0,0 +1,105 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#include +#include +#include + +//======================================================================= +//function : MapShapes +//purpose : +//======================================================================= + void BOPTools::MapShapes(const TopoDS_Shape& S, + BOPCol_MapOfShape& M) +{ + M.Add(S); + TopoDS_Iterator It(S); + while (It.More()) { + MapShapes(It.Value(),M); + It.Next(); + } +} + + +//======================================================================= +//function : MapShapes +//purpose : +//======================================================================= + void BOPTools::MapShapes(const TopoDS_Shape& S, + BOPCol_IndexedMapOfShape& M) +{ + M.Add(S); + TopoDS_Iterator It(S); + while (It.More()) { + MapShapes(It.Value(),M); + It.Next(); + } +} + +//======================================================================= +//function : MapShapes +//purpose : +//======================================================================= + void BOPTools::MapShapes(const TopoDS_Shape& S, + const TopAbs_ShapeEnum T, + BOPCol_IndexedMapOfShape& M) +{ + TopExp_Explorer Ex(S,T); + while (Ex.More()) { + M.Add(Ex.Current()); + Ex.Next(); + } +} + + + +//======================================================================= +//function : MapShapesAndAncestors +//purpose : +//======================================================================= + void BOPTools::MapShapesAndAncestors(const TopoDS_Shape& S, + const TopAbs_ShapeEnum TS, + const TopAbs_ShapeEnum TA, + BOPCol_IndexedDataMapOfShapeListOfShape& M) +{ + BOPCol_ListOfShape empty; + + // visit ancestors + TopExp_Explorer exa(S,TA); + while (exa.More()) { + // visit shapes + const TopoDS_Shape& anc = exa.Current(); + TopExp_Explorer exs(anc,TS); + while (exs.More()) { + Standard_Integer index = M.FindIndex(exs.Current()); + if (index == 0) index = M.Add(exs.Current(),empty); + M(index).Append(anc); + exs.Next(); + } + exa.Next(); + } + + // visit shapes not under ancestors + TopExp_Explorer ex(S,TS,TA); + while (ex.More()) { + Standard_Integer index = M.FindIndex(ex.Current()); + if (index == 0) index = M.Add(ex.Current(),empty); + ex.Next(); + } +} diff --git a/src/BOPTools/BOPTools_AlgoTools.cdl b/src/BOPTools/BOPTools_AlgoTools.cdl new file mode 100644 index 0000000000..ea64d3d978 --- /dev/null +++ b/src/BOPTools/BOPTools_AlgoTools.cdl @@ -0,0 +1,450 @@ +-- Created by: Peter KURNEV +-- Copyright (c) 2010-2012 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 +-- +-- The content of this file is subject to the Open CASCADE Technology Public +-- License Version 6.5 (the "License"). You may not use the content of this file +-- except in compliance with the License. Please obtain a copy of the License +-- at http://www.opencascade.org and read it completely before using this file. +-- +-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +-- +-- The Original Code and all software distributed under the License is +-- distributed on an "AS IS" basis, without warranty of any kind, and the +-- Initial Developer hereby disclaims all such warranties, including without +-- limitation, any warranties of merchantability, fitness for a particular +-- purpose or non-infringement. Please see the License for the specific terms +-- and conditions governing the rights and limitations under the License. + +class AlgoTools from BOPTools + ---Purpose: + +uses + Pnt from gp, + --modified by NIZHNY-EMV Wed May 25 10:03:15 2011 + Pnt2d from gp, + Dir from gp, + Plane from Geom, + --modified by NIZHNY-EMV Wed May 25 10:03:17 2011 + State from TopAbs, + ShapeEnum from TopAbs, + Curve from IntTools, + Shape from TopoDS, + Vertex from TopoDS, + Edge from TopoDS, + Face from TopoDS, + Wire from TopoDS, + Solid from TopoDS, + -- + BaseAllocator from BOPCol, + ListOfShape from BOPCol, + IndexedMapOfShape from BOPCol, + IndexedDataMapOfShapeListOfShape from BOPCol, + Context from BOPInt, + ListOfCoupleOfShape from BOPTools, + Range from IntTools + +--raises + +is + ComputeVV(myclass; + aV1:Vertex from TopoDS; + aP2:Pnt from gp; + aTolP2:Real from Standard) + returns Integer from Standard; + + ComputeVV(myclass; + aV1:Vertex from TopoDS; + aV2:Vertex from TopoDS) + returns Integer from Standard; + + MakeVertex (myclass; + aLV: out ListOfShape from BOPCol; + aV : out Vertex from TopoDS); + + MakeEdge(myclass; + theCurve:Curve from IntTools; + theV1: Vertex from TopoDS; + theT1: Real from Standard; + theV2: Vertex from TopoDS; + theT2: Real from Standard; + theTolR3D: Real from Standard; + theE :out Edge from TopoDS); + + MakePCurve(myclass; + theE : Edge from TopoDS; + theF1: Face from TopoDS; + theF2: Face from TopoDS; + theCurve:Curve from IntTools); + + MakeContainer(myclass; + theType:ShapeEnum from TopAbs; + theShape:out Shape from TopoDS); + + + IsHole(myclass; + aW: Shape from TopoDS; + aF: Shape from TopoDS) + returns Boolean from Standard; + + IsSplitToReverse(myclass; + theSplit : Shape from TopoDS; + theShape : Shape from TopoDS; + theContext:out Context from BOPInt) + ---Purpose: Returns True if the shape theSplit has opposite + -- direction than theShape + -- theContext - cashed geometrical tools + returns Boolean from Standard; + + IsSplitToReverse(myclass; + theSplit : Face from TopoDS; + theShape : Face from TopoDS; + theContext:out Context from BOPInt) + ---Purpose: Returns True if normal direction of the face + -- theShape is not the same as for the face + -- theSplit + -- theContext - cashed geometrical tools + returns Boolean from Standard; + + IsSplitToReverse (myclass; + aE1: Edge from TopoDS; + aE2: Edge from TopoDS; + aContext:out Context from BOPInt) + returns Boolean from Standard; + + + AreFacesSameDomain(myclass; + theF1: Face from TopoDS; + theF2: Face from TopoDS; + theContext:out Context from BOPInt) + returns Boolean from Standard; + + CheckSameGeom (myclass; + theF1: Face from TopoDS; + theF2: Face from TopoDS; + theContext:out Context from BOPInt) + returns Boolean from Standard; + + Sense (myclass; + theF1: Face from TopoDS; + theF2: Face from TopoDS) + returns Integer from Standard; + + GetEdgeOff (myclass; + theEdge :Edge from TopoDS; + theFace :Face from TopoDS; + theEdgeOff :out Edge from TopoDS) + ---Purpose: Returns True if the face theFace contains + -- the edge theEdge but with opposite orientation. + -- If the method returns True theEdgeOff is the + -- edge founded + returns Boolean from Standard; + + GetFaceOff(myclass; + theEdge :Edge from TopoDS; + theFace :Face from TopoDS; + theLCEF :out ListOfCoupleOfShape from BOPTools; + theFaceOff :out Face from TopoDS); + ---Purpose: For the face theFace and its edge theEdge + -- finds the face suitable to produce shell. + -- theLCEF - set of faces to search. All faces + -- from theLCEF must share edge theEdge + + IsInternalFace(myclass; + theFace :Face from TopoDS; + theEdge :Edge from TopoDS; + theFace1 :Face from TopoDS; + theFace2 :Face from TopoDS; + theContext:out Context from BOPInt) + ---Purpose: Returns True if the face theFace is inside of the + -- couple of faces theFace1, theFace2. + -- The faces theFace, theFace1, theFace2 must + -- share the edge theEdge + returns Boolean from Standard; + + IsInternalFace(myclass; + theFace :Face from TopoDS; + theEdge :Edge from TopoDS; + theLF :out ListOfShape from BOPCol; + theContext:out Context from BOPInt) + ---Purpose: Returns True if the face theFace is inside of the + -- appropriate couple of faces (from the set theLF) . + -- The faces of the set theLF and theFace must + -- share the edge theEdge + returns Boolean from Standard; + + IsInternalFace(myclass; + theFace :Face from TopoDS; + theSolid :Solid from TopoDS; + theMEF :out IndexedDataMapOfShapeListOfShape from BOPCol; + theTol :Real from Standard; + theContext:out Context from BOPInt) + ---Purpose: Returns True if the face theFace is inside the + -- solid theSolid. + -- theMEF - Map Edge/Faces for theSolid + -- theTol - value of precision of computation + -- theContext- cahed geometrical tools + returns Boolean from Standard; + + + GetEdgeOnFace (myclass; + theEdge :Edge from TopoDS; + theFace :Face from TopoDS; + theEdgeOnF :out Edge from TopoDS) + ---Purpose: For the face theFace gets the edge theEdgeOnF + -- that is the same as theEdge + -- Returns True if such edge exists + -- Returns False if there is no such edge + returns Boolean from Standard; + + ComputeState(myclass; + thePoint :Pnt from gp; + theSolid :Solid from TopoDS; + theTol :Real from Standard; + theContext:out Context from BOPInt) + ---Purpose: Computes the 3-D state of the point thePoint + -- toward solid theSolid. + -- theTol - value of precision of computation + -- theContext- cahed geometrical tools + -- Returns 3-D state. + returns State from TopAbs; + + ComputeState(myclass; + theVertex:Vertex from TopoDS; + theSolid :Solid from TopoDS; + theTol :Real from Standard; + theContext:out Context from BOPInt) + ---Purpose: Computes the 3-D state of the vertex theVertex + -- toward solid theSolid. + -- theTol - value of precision of computation + -- theContext- cahed geometrical tools + -- Returns 3-D state. + returns State from TopAbs; + + ComputeState(myclass; + theEdge :Edge from TopoDS; + theSolid :Solid from TopoDS; + theTol :Real from Standard; + theContext:out Context from BOPInt) + ---Purpose: Computes the 3-D state of the edge theEdge + -- toward solid theSolid. + -- theTol - value of precision of computation + -- theContext- cahed geometrical tools + -- Returns 3-D state. + returns State from TopAbs; + + ComputeState(myclass; + theFace :Face from TopoDS; + theSolid :Solid from TopoDS; + theTol :Real from Standard; + theBounds:out IndexedMapOfShape from BOPCol; + theContext:out Context from BOPInt) + ---Purpose: Computes the 3-D state of the face theFace + -- toward solid theSolid. + -- theTol - value of precision of computation + -- theBounds - set of edges of theFace to avoid + -- theContext- cahed geometrical tools + -- Returns 3-D state. + returns State from TopAbs; + + ComputeStateByOnePoint(myclass; + theShape :Shape from TopoDS; + theSolid :Solid from TopoDS; + theTol :Real from Standard; + theContext:out Context from BOPInt) + ---Purpose: Computes the 3-D state of the shape theShape + -- toward solid theSolid. + -- theTol - value of precision of computation + -- theContext- cahed geometrical tools + -- Returns 3-D state. + returns State from TopAbs; + + MakeConnexityBlock(myclass; + theLS :out ListOfShape from BOPCol; + theMapAvoid:out IndexedMapOfShape from BOPCol; + theLSCB :out ListOfShape from BOPCol; + theAllocator:BaseAllocator from BOPCol); + ---Purpose: For the list of faces theLS build block + -- theLSCB in terms of connexity by edges + -- theMapAvoid - set of edges to avoid for + -- the treatment + + MakeConnexityBlocks(myclass; + theS :Shape from TopoDS; + theType1 :ShapeEnum from TopAbs; + theType2 :ShapeEnum from TopAbs; + theLCB :out ListOfShape from BOPCol); + ---Purpose: For the compound theS build the blocks + -- theLCB (as list of compounds) + -- in terms of connexity by the shapes of theType + + 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 + + --modified by NIZHNY-EMV Wed Sep 21 13:27:40 2011 + CorrectPoint (myclass; + thePnt:Pnt from gp; + thePL:Plane from Geom; + theNewPnt:out Pnt from gp); + --modified by NIZHNY-EMV Wed Sep 21 13:27:42 2011 + + --copy from BOPTools_AlgoTools.cdl + MakeNewVertex (myclass; + aP1 : Pnt from gp; + aTol: Real from Standard; + aNewVertex:out Vertex from TopoDS); + ---Purpose: + --- Make a vertex using 3D-point and 3D-tolerance value + --- + MakeNewVertex (myclass; + aV1,aV2: Vertex from TopoDS; + aNewVertex:out Vertex from TopoDS); + ---Purpose: + --- Make a vertex using couple of vertices + --- + MakeNewVertex (myclass; + aE1: Edge from TopoDS; + aP1: Real from Standard; + aE2: Edge from TopoDS; + aP2: Real from Standard; + aNewVertex:out Vertex from TopoDS); + ---Purpose: + --- Make a vertex in place of intersection between two edges + --- with parameters + --- + MakeNewVertex (myclass; + aE1: Edge from TopoDS; + aP1: Real from Standard; + aF2: Face from TopoDS; + aNewVertex:out Vertex from TopoDS); + ---Purpose: + --- Make a vertex in place of intersection between the edge + --- with parameter and the face + --- + PointOnEdge (myclass; + aEdge: Edge from TopoDS; + aPrm: Real from Standard; + aP:out Pnt from gp); + ---Purpose: + --- Compute a 3D-point on the edge at parameter + --- + MakeSplitEdge (myclass; + aE1: Edge from TopoDS; + aV1: Vertex from TopoDS; + aP1: Real from Standard; + aV2: Vertex from TopoDS; + aP2: Real from Standard; + aNewEdge:out Edge from TopoDS); + ---Purpose: + --- Make the edge from base edge and two vertices + --- at parameters + --- + MakeSectEdge (myclass; + aIC: Curve from IntTools; + aV1: Vertex from TopoDS; + aP1: Real from Standard; + aV2: Vertex from TopoDS; + aP2: Real from Standard; + aNewEdge:out Edge from TopoDS); + ---Purpose: + --- Make the edge from 3D-Curve and two vertices + --- at parameters + --- + UpdateVertex (myclass; + aIC: Curve from IntTools; + aT : Real from Standard; + aV : Vertex from TopoDS); + ---Purpose: + --- Update the tolerance value for vertex + --- taking into account the fact that lays on + --- the curve + --- + UpdateVertex (myclass; + aE : Edge from TopoDS; + aT : Real from Standard; + aV : Vertex from TopoDS); + ---Purpose: + --- Update the tolerance value for vertex + --- taking into account the fact that lays on + --- the edge + --- + UpdateVertex (myclass; + aVF : Vertex from TopoDS; + aVN : Vertex from TopoDS); + ---Purpose: + --- Update the tolerance value for vertex + --- taking into account the fact that should + --- cover tolerance zone of + --- + + CorrectRange (myclass; + aE1: Edge from TopoDS; + aE2: Edge from TopoDS; + aSR: Range from IntTools; + aNewSR:out Range from IntTools); + ---Purpose: + --- Correct shrunk range taking into account 3D-curve + --- resolution and corresp. tolerances' values of , + --- + CorrectRange (myclass; + aE: Edge from TopoDS; + aF: Face from TopoDS; + aSR: Range from IntTools; + aNewSR:out Range from IntTools); + ---Purpose: + --- Correct shrunk range taking into account 3D-curve + --- resolution and corresp. tolerances' values of , + --- + + IsBlockInOnFace(myclass; + aShR : Range from IntTools; + aF : Face from TopoDS; + aE : Edge from TopoDS; + aContext:out Context from BOPInt) + returns Boolean from Standard; + ---Purpose: + --- Returns TRUE if PaveBlock lays on the face , i.e + --- the is IN or ON in 2D of + + + GetProjectPoint(myclass; + aF : Face from TopoDS; + aPF : Pnt from gp; + aF1 : Face from TopoDS; + aPF1 : out Pnt from gp; + aDNF1 : out Dir from gp; + theContext : out Context from BOPInt) + returns Boolean from Standard; + ---Purpose: + --- Computes projection of the point on the face . + --- Returns TRUE if projection is done. +end AlgoTools; diff --git a/src/BOPTools/BOPTools_AlgoTools.cxx b/src/BOPTools/BOPTools_AlgoTools.cxx new file mode 100644 index 0000000000..8ae6e55860 --- /dev/null +++ b/src/BOPTools/BOPTools_AlgoTools.cxx @@ -0,0 +1,1892 @@ +// Created by: Peter KURNEV +// Copyright (c) 2010-2012 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 +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#include +// +#include +// +#include +#include +#include +// +#include +#include +#include +#include +#include +#include +// +#include +// +#include +#include +#include +#include +#include +// +#include +#include +#include +#include +#include +#include +#include +// +#include +// +#include +#include +// +#include +#include +// +#include +#include +#include +#include +#include +#include +#include +#include + +static + Standard_Real AngleWithRef(const gp_Dir& theD1, + const gp_Dir& theD2, + const gp_Dir& theDRef); +static + inline Standard_Real fsqrt(Standard_Real val); + +static + Standard_Boolean FindFacePairs (const TopoDS_Edge& theE, + const BOPCol_ListOfShape& thLF, + BOPTools_ListOfCoupleOfShape& theLCFF); +static + TopAbs_Orientation Orientation(const TopoDS_Edge& anE, + const TopoDS_Face& aF); + + + +//======================================================================= +// function: MakeConnexityBlocks +// purpose: +//======================================================================= + void BOPTools_AlgoTools::MakeConnexityBlocks (const TopoDS_Shape& theS, + const TopAbs_ShapeEnum theType1, + const TopAbs_ShapeEnum theType2, + BOPCol_ListOfShape& theLCB) +{ + Standard_Integer aNbF, aNbAdd1; + BRep_Builder aBB; + TopoDS_Compound aC; + TopoDS_Iterator aIt; + TopExp_Explorer aExp; + BOPCol_MapOfShape aMCB, aMAdd, aMAdd1, aMP; + BOPCol_IndexedDataMapOfShapeListOfShape aMEF; + BOPCol_ListIteratorOfListOfShape aItLF; + BOPCol_MapIteratorOfMapOfShape aItM;//, aItM1; + // + // 1. aMEF + BOPTools::MapShapesAndAncestors(theS, theType1, theType2, aMEF); + // + // 2. aMCB + aIt.Initialize(theS); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aF1=aIt.Value(); + if (aMP.Contains(aF1)) { + continue; + } + // + aMCB.Clear(); + aMAdd.Clear(); + aMAdd.Add(aF1); + // + while(1) { + aMAdd1.Clear(); + // + aItM.Initialize(aMAdd); + for (; aItM.More(); aItM.Next()) { + const TopoDS_Shape& aF=aItM.Key(); + // + aExp.Init(aF, theType1); + for (; aExp.More(); aExp.Next()) { + const TopoDS_Shape& aE=aExp.Current(); + // + const BOPCol_ListOfShape& aLF=aMEF.FindFromKey(aE); + aItLF.Initialize(aLF); + for (; aItLF.More(); aItLF.Next()) { + const TopoDS_Shape& aFx=aItLF.Value(); + if (aFx.IsSame(aF)) { + continue; + } + if (aMCB.Contains(aFx)) { + continue; + } + aMAdd1.Add(aFx); + } + }//for (; aExp.More(); aExp.Next()){ + aMCB.Add(aF); + }// for (; aItM.More(); aItM.Next()) { + // + aNbAdd1=aMAdd1.Extent(); + if (!aNbAdd1) { + break;// ->make new CB from aMCB + } + // + aMAdd.Clear(); + aItM.Initialize(aMAdd1); + for (; aItM.More(); aItM.Next()) { + const TopoDS_Shape& aFAdd=aItM.Key(); + aMAdd.Add(aFAdd); + } + }//while(1) { + // + aNbF=aMCB.Extent(); + if (aNbF) { + aBB.MakeCompound(aC); + // + aItM.Initialize(aMCB); + for (; aItM.More(); aItM.Next()) { + const TopoDS_Shape& aF=aItM.Key(); + aBB.Add(aC, aF); + aMP.Add(aF); + } + theLCB.Append(aC); + } + }// for (; aIt.More(); aIt.Next()) +} +//======================================================================= +// function: OrientFacesOnShell +// purpose: +//======================================================================= + void BOPTools_AlgoTools::OrientFacesOnShell (TopoDS_Shape& aShell) +{ + Standard_Boolean bIsProcessed1, bIsProcessed2; + Standard_Integer i, aNbE, aNbF, j; + TopAbs_Orientation anOrE1, anOrE2; + TopoDS_Face aF1x, aF2x; + TopoDS_Shape aShellNew; + BOPCol_IndexedDataMapOfShapeListOfShape aEFMap; + BOPCol_IndexedMapOfShape aProcessedFaces; + BRep_Builder aBB; + // + BOPTools_AlgoTools::MakeContainer(TopAbs_SHELL, aShellNew); + // + BOPTools::MapShapesAndAncestors(aShell, TopAbs_EDGE, TopAbs_FACE, aEFMap); + aNbE=aEFMap.Extent(); + // + // One seam edge in aEFMap contains 2 equivalent faces. + for (i=1; i<=aNbE; ++i) { + BOPCol_ListOfShape& aLF=aEFMap.ChangeFromIndex(i); + aNbF=aLF.Extent(); + if (aNbF>1) { + BOPCol_ListOfShape aLFTmp; + BOPCol_IndexedMapOfShape aFM; + // + BOPCol_ListIteratorOfListOfShape anIt(aLF); + for (; anIt.More(); anIt.Next()) { + const TopoDS_Shape& aF=anIt.Value(); + if (!aFM.Contains(aF)) { + aFM.Add(aF); + aLFTmp.Append(aF); + } + } + aLF.Clear(); + aLF=aLFTmp; + } + } + // + // Do + for (i=1; i<=aNbE; ++i) { + const TopoDS_Edge& aE=(*(TopoDS_Edge*)(&aEFMap.FindKey(i))); + if (BRep_Tool::Degenerated(aE)) { + continue; + } + // + const BOPCol_ListOfShape& aLF=aEFMap.FindFromIndex(i); + aNbF=aLF.Extent(); + if (aNbF!=2) { + continue; + } + // + TopoDS_Face& aF1=(*(TopoDS_Face*)(&aLF.First())); + TopoDS_Face& aF2=(*(TopoDS_Face*)(&aLF.Last())); + // + bIsProcessed1=aProcessedFaces.Contains(aF1); + bIsProcessed2=aProcessedFaces.Contains(aF2); + if (bIsProcessed1 && bIsProcessed2) { + continue; + } + + if (!bIsProcessed1 && !bIsProcessed2) { + aProcessedFaces.Add(aF1); + aBB.Add(aShellNew, aF1); + bIsProcessed1=!bIsProcessed1; + } + // + aF1x=aF1; + if (bIsProcessed1) { + j=aProcessedFaces.FindIndex(aF1); + aF1x=(*(TopoDS_Face*)(&aProcessedFaces.FindKey(j))); + } + // + aF2x=aF2; + if (bIsProcessed2) { + j=aProcessedFaces.FindIndex(aF2); + aF2x=(*(TopoDS_Face*)(&aProcessedFaces.FindKey(j))); + } + // + anOrE1=Orientation(aE, aF1x); + anOrE2=Orientation(aE, aF2x); + // + if (bIsProcessed1 && !bIsProcessed2) { + if (anOrE1==anOrE2) { + if (!BRep_Tool::IsClosed(aE, aF1) && + !BRep_Tool::IsClosed(aE, aF2)) { + aF2.Reverse(); + } + } + aProcessedFaces.Add(aF2); + aBB.Add(aShellNew, aF2); + } + else if (!bIsProcessed1 && bIsProcessed2) { + if (anOrE1==anOrE2) { + if (!BRep_Tool::IsClosed(aE, aF1) && + !BRep_Tool::IsClosed(aE, aF2)) { + aF1.Reverse(); + } + } + aProcessedFaces.Add(aF1); + aBB.Add(aShellNew, aF1); + } + } + // + // + for (i=1; i<=aNbE; ++i) { + const TopoDS_Edge& aE=(*(TopoDS_Edge*)(&aEFMap.FindKey(i))); + if (BRep_Tool::Degenerated(aE)) { + continue; + } + // + const BOPCol_ListOfShape& aLF=aEFMap.FindFromIndex(i); + aNbF=aLF.Extent(); + if (aNbF!=2) { + BOPCol_ListIteratorOfListOfShape anIt(aLF); + for(; anIt.More(); anIt.Next()) { + const TopoDS_Face& aF=(*(TopoDS_Face*)(&anIt.Value())); + if (!aProcessedFaces.Contains(aF)) { + aProcessedFaces.Add(aF); + aBB.Add(aShellNew, aF); + } + } + } + } + aShell=aShellNew; +} +//======================================================================= +//function : Orientation +//purpose : +//======================================================================= + TopAbs_Orientation Orientation(const TopoDS_Edge& anE, + const TopoDS_Face& aF) +{ + TopAbs_Orientation anOr=TopAbs_INTERNAL; + + TopExp_Explorer anExp; + anExp.Init(aF, TopAbs_EDGE); + for (; anExp.More(); anExp.Next()) { + const TopoDS_Edge& anEF1=(*(TopoDS_Edge*)(&anExp.Current())); + if (anEF1.IsSame(anE)) { + anOr=anEF1.Orientation(); + break; + } + } + return anOr; +} + +//////////// + + +//======================================================================= +// function: MakeConnexityBlock. +// purpose: +//======================================================================= + void BOPTools_AlgoTools::MakeConnexityBlock (BOPCol_ListOfShape& theLFIn, + BOPCol_IndexedMapOfShape& theMEAvoid, + BOPCol_ListOfShape& theLCB, + const Handle(NCollection_BaseAllocator)& theAllocator) +{ + Standard_Integer aNbF, aNbAdd1; + TopExp_Explorer aExp; + BOPCol_MapIteratorOfMapOfShape aItM, aItM1; + BOPCol_ListIteratorOfListOfShape aIt; + // + BOPCol_MapOfShape aMCB(100, theAllocator); + BOPCol_MapOfShape aMAdd(100, theAllocator); + BOPCol_MapOfShape aMAdd1(100, theAllocator); + BOPCol_IndexedDataMapOfShapeListOfShape aMEF(100, theAllocator); + // + // 1. aMEF + aNbF=theLFIn.Extent(); + aIt.Initialize(theLFIn); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aF=aIt.Value(); + BOPTools::MapShapesAndAncestors(aF, TopAbs_EDGE, TopAbs_FACE, aMEF); + } + // + // 2. aMCB + const TopoDS_Shape& aF1=theLFIn.First(); + aMAdd.Add(aF1); + // + while(1) { + aMAdd1.Clear(); + aItM.Initialize(aMAdd); + for (; aItM.More(); aItM.Next()) { + const TopoDS_Shape& aF=aItM.Key(); + // + //aMAdd1.Clear(); + aExp.Init(aF, TopAbs_EDGE); + for (; aExp.More(); aExp.Next()) { + const TopoDS_Shape& aE=aExp.Current(); + if (theMEAvoid.Contains(aE)){ + continue; + } + // + const BOPCol_ListOfShape& aLF=aMEF.FindFromKey(aE); + aIt.Initialize(aLF); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aFx=aIt.Value(); + if (aFx.IsSame(aF)) { + continue; + } + if (aMCB.Contains(aFx)) { + continue; + } + aMAdd1.Add(aFx); + } + }//for (; aExp.More(); aExp.Next()){ + aMCB.Add(aF); + }// for (; aItM.More(); aItM.Next()) { + // + aNbAdd1=aMAdd1.Extent(); + if (!aNbAdd1) { + break; + } + // + aMAdd.Clear(); + aItM1.Initialize(aMAdd1); + for (; aItM1.More(); aItM1.Next()) { + const TopoDS_Shape& aFAdd=aItM1.Key(); + aMAdd.Add(aFAdd); + } + // + }//while(1) { + + // + aNbF=aMCB.Extent(); + aItM.Initialize(aMCB); + for (; aItM.More(); aItM.Next()) { + const TopoDS_Shape& aF=aItM.Key(); + theLCB.Append(aF); + } +} +//======================================================================= +// function: ComputeStateByOnePoint +// purpose: +//======================================================================= + TopAbs_State BOPTools_AlgoTools::ComputeStateByOnePoint(const TopoDS_Shape& theS, + const TopoDS_Solid& theRef, + const Standard_Real theTol, + Handle(BOPInt_Context)& theContext) +{ + TopAbs_State aState; + TopAbs_ShapeEnum aType; + // + aState=TopAbs_UNKNOWN; + aType=theS.ShapeType(); + if (aType==TopAbs_VERTEX) { + const TopoDS_Vertex& aV=(*(TopoDS_Vertex*)(&theS)); + aState=BOPTools_AlgoTools::ComputeState(aV, theRef, theTol, theContext); + } + else if (aType==TopAbs_EDGE) { + const TopoDS_Edge& aE=(*(TopoDS_Edge*)(&theS)); + aState=BOPTools_AlgoTools::ComputeState(aE, theRef, theTol, theContext); + } + return aState; +} + +//======================================================================= +// function: ComputeState +// purpose: +//======================================================================= + TopAbs_State BOPTools_AlgoTools::ComputeState(const TopoDS_Face& theF, + const TopoDS_Solid& theRef, + const Standard_Real theTol, + BOPCol_IndexedMapOfShape& theBounds, + Handle(BOPInt_Context)& theContext) +{ + TopAbs_State aState; + TopExp_Explorer aExp; + TopoDS_Edge aE1; + gp_Pnt2d aP2D; + gp_Pnt aP3D; + // + aState=TopAbs_UNKNOWN; + // + aExp.Init(theF, TopAbs_EDGE); + for (; aExp.More(); aExp.Next()) { + const TopoDS_Edge& aSE=(*(TopoDS_Edge*)(&aExp.Current())); + if (BRep_Tool::Degenerated(aSE)) { + continue; + } + // + if (!theBounds.Contains(aSE)) { + const TopoDS_Edge& aE=(*(TopoDS_Edge*)(&aSE)); + aState=BOPTools_AlgoTools::ComputeState(aE, theRef, theTol, theContext); + return aState; + } + if (aE1.IsNull()) { + aE1=(*(TopoDS_Edge*)(&aSE)); + } + } + // !!<- process edges that are all on theRef + if (!aE1.IsNull()) { + BOPTools_AlgoTools3D::PointNearEdge(aE1, theF, aP2D, aP3D); + aState=BOPTools_AlgoTools::ComputeState(aP3D, theRef, theTol, theContext); + } + // + return aState; +} +//======================================================================= +// function: ComputeState +// purpose: +//======================================================================= + TopAbs_State BOPTools_AlgoTools::ComputeState(const TopoDS_Vertex& theV, + const TopoDS_Solid& theRef, + const Standard_Real theTol, + Handle(BOPInt_Context)& theContext) +{ + TopAbs_State aState; + gp_Pnt aP3D; + // + aP3D=BRep_Tool::Pnt(theV); + aState=BOPTools_AlgoTools::ComputeState(aP3D, theRef, theTol, theContext); + return aState; +} +//======================================================================= +// function: ComputeState +// purpose: +//======================================================================= + TopAbs_State BOPTools_AlgoTools::ComputeState(const TopoDS_Edge& theE, + const TopoDS_Solid& theRef, + const Standard_Real theTol, + Handle(BOPInt_Context)& theContext) +{ + Standard_Real aT1, aT2, aT = 0.; + TopAbs_State aState; + Handle(Geom_Curve) aC3D; + gp_Pnt aP3D; + // + aC3D = BRep_Tool::Curve(theE, aT1, aT2); + // + if(aC3D.IsNull()) { + //it means that we are in degenerated edge + const TopoDS_Vertex& aV = TopExp::FirstVertex(theE); + if(aV.IsNull()){ + return TopAbs_UNKNOWN; + } + aP3D=BRep_Tool::Pnt(aV); + } + else {//usual case + Standard_Boolean bF2Inf, bL2Inf; + Standard_Real dT=10.; + // + bF2Inf = Precision::IsNegativeInfinite(aT1); + bL2Inf = Precision::IsPositiveInfinite(aT2); + // + if (bF2Inf && !bL2Inf) { + aT=aT2-dT; + } + else if (!bF2Inf && bL2Inf) { + aT=aT1+dT; + } + else if (bF2Inf && bL2Inf) { + aT=0.; + } + else { + aT=IntTools_Tools::IntermediatePoint(aT1, aT2); + } + aC3D->D0(aT, aP3D); + } + // + aState=BOPTools_AlgoTools::ComputeState(aP3D, theRef, theTol, theContext); + // + return aState; +} +//======================================================================= +// function: ComputeState +// purpose: +//======================================================================= + TopAbs_State BOPTools_AlgoTools::ComputeState(const gp_Pnt& theP, + const TopoDS_Solid& theRef, + const Standard_Real theTol, + Handle(BOPInt_Context)& theContext) +{ + TopAbs_State aState; + // + BRepClass3d_SolidClassifier& aSC=theContext->SolidClassifier(theRef); + aSC.Perform(theP, theTol); + // + aState=aSC.State(); + // + return aState; +} +//======================================================================= +//function : IsInternalFace +//purpose : +//======================================================================= + Standard_Boolean BOPTools_AlgoTools::IsInternalFace(const TopoDS_Face& theFace, + const TopoDS_Solid& theSolid, + BOPCol_IndexedDataMapOfShapeListOfShape& theMEF, + const Standard_Real theTol, + Handle(BOPInt_Context)& theContext) +{ + Standard_Boolean bRet, bDegenerated; + Standard_Integer aNbF; + TopAbs_Orientation aOr; + TopoDS_Edge aEL; + TopExp_Explorer aExp; + BOPCol_ListIteratorOfListOfShape aItF; + // + bRet=Standard_False; + // + // 1 Try to find an edge from theFace in theMEF + aExp.Init(theFace, TopAbs_EDGE); + for(; aExp.More(); aExp.Next()) { + const TopoDS_Edge& aE=(*(TopoDS_Edge*)(&aExp.Current())); + if (!theMEF.Contains(aE)) { + continue; + } + // + aOr=aE.Orientation(); + if (aOr==TopAbs_INTERNAL) { + continue; + } + //modified by NIZNHY-PKV Wed Jul 07 08:31:41 2010f + bDegenerated=BRep_Tool::Degenerated(aE); + if (bDegenerated){ + continue; + } + //modified by NIZNHY-PKV Wed Jul 07 08:31:43 2010t + // aE + BOPCol_ListOfShape& aLF=theMEF.ChangeFromKey(aE); + aNbF=aLF.Extent(); + if (!aNbF) { + return bRet; // it can not be so + } + else if (aNbF==1) { + // aE is internal edge on aLF.First() + const TopoDS_Face& aF1=(*(TopoDS_Face*)(&aLF.First())); + bRet=BOPTools_AlgoTools::IsInternalFace(theFace, aE, aF1, aF1, theContext); + return bRet; + } + else if (aNbF==2) { + const TopoDS_Face& aF1=(*(TopoDS_Face*)(&aLF.First())); + const TopoDS_Face& aF2=(*(TopoDS_Face*)(&aLF.Last())); + // + if (aF2.IsSame(aF1) && BRep_Tool::IsClosed(aE, aF1)) { + // treat as it was for 1 face + bRet=BOPTools_AlgoTools::IsInternalFace(theFace, aE, aF1, aF2, theContext); + return bRet; + } + } + if (aNbF%2) { + return bRet; // it can not be so + } + else { // aNbF=2,4,6,8,... + bRet=BOPTools_AlgoTools::IsInternalFace(theFace, aE, aLF, theContext); + return bRet; + } + }//for(; aExp.More(); aExp.Next()) { + // + //======================================== + // 2. Classify face using classifier + // + TopAbs_State aState; + BOPCol_IndexedMapOfShape aBounds; + // + aState=BOPTools_AlgoTools::ComputeState(theFace, theSolid, theTol, aBounds, theContext); + bRet=(aState==TopAbs_IN); + // + return bRet; +} +//======================================================================= +//function : IsInternalFace +//purpose : +//======================================================================= + Standard_Boolean BOPTools_AlgoTools::IsInternalFace(const TopoDS_Face& theFace, + const TopoDS_Edge& theEdge, + BOPCol_ListOfShape& theLF, + Handle(BOPInt_Context)& theContext) +{ + Standard_Boolean bRet; + Standard_Boolean aNbF; + // + bRet=Standard_False; + // + aNbF=theLF.Extent(); + if (aNbF==2) { + const TopoDS_Face& aF1=(*(TopoDS_Face*)(&theLF.First())); + const TopoDS_Face& aF2=(*(TopoDS_Face*)(&theLF.Last())); + bRet=BOPTools_AlgoTools::IsInternalFace(theFace, theEdge, aF1, aF2, theContext); + return bRet; + } + // + else { + BOPTools_ListOfCoupleOfShape aLCFF; + BOPTools_ListIteratorOfListOfCoupleOfShape aIt; + // + FindFacePairs(theEdge, theLF, aLCFF); + // + aIt.Initialize(aLCFF); + for (; aIt.More(); aIt.Next()) { + BOPTools_CoupleOfShape& aCSFF=aIt.ChangeValue(); + // + const TopoDS_Face& aF1=(*(TopoDS_Face*)(&aCSFF.Shape1())); + const TopoDS_Face& aF2=(*(TopoDS_Face*)(&aCSFF.Shape2())); + bRet=BOPTools_AlgoTools::IsInternalFace(theFace, theEdge, aF1, aF2, theContext); + if (bRet) { + return bRet; + } + } + } + return bRet; +} +//======================================================================= +//function : IsInternalFace +//purpose : +//======================================================================= + Standard_Boolean BOPTools_AlgoTools::IsInternalFace(const TopoDS_Face& theFace, + const TopoDS_Edge& theEdge, + const TopoDS_Face& theFace1, + const TopoDS_Face& theFace2, + Handle(BOPInt_Context)& theContext) +{ + Standard_Boolean bRet; + Standard_Real aT1, aT2, aT;//aD1, aD2, + gp_Pnt aPx, aPF, aPF1, aPF2; + gp_Pnt2d aP2D, aPF2D; + gp_Dir aDNF1, aDNF2; + TopoDS_Edge aE1, aE2; + Handle(Geom_Curve)aC3D; + gp_Vec aVTgt; + // + aC3D =BRep_Tool::Curve(theEdge, aT1, aT2); + aT=BOPTools_AlgoTools2D::IntermediatePoint(aT1, aT2); + aC3D->D0(aT, aPx); + //modified by NIZHNY-EMV Wed Sep 21 13:20:31 2011 + BOPTools_AlgoTools2D::EdgeTangent(theEdge, aT, aVTgt); + gp_Dir aDTtgt(aVTgt); + aDTtgt.Reverse(); + Handle(Geom_Plane) aPL; + aPL = new Geom_Plane(aPx, aDTtgt); + //modified by NIZHNY-EMV Wed Sep 21 13:20:33 2011 + // + // 1. PF + //modified by NIZHNY-EMV Wed Oct 12 08:13:43 2011 + BOPTools_AlgoTools3D::PointNearEdge (theEdge, theFace, aT, aPF2D, aPF); + //modified by NIZHNY-EMV Wed Oct 12 08:13:47 2011 + // + // 2. E1, E2 + BOPTools_AlgoTools::GetEdgeOnFace(theEdge, theFace1, aE1); + if (aE1.Orientation()==TopAbs_INTERNAL) { + aE2=aE1; + aE1.Orientation(TopAbs_FORWARD); + aE2.Orientation(TopAbs_REVERSED); + } + else if (theFace1==theFace2) { + aE2=aE1; + aE1.Orientation(TopAbs_FORWARD); + aE2.Orientation(TopAbs_REVERSED); + } + else { + BOPTools_AlgoTools::GetEdgeOnFace(theEdge, theFace2, aE2); + } + // + // 3 + bRet=Standard_False; + // + //modified by NIZHNY-EMV Wed May 25 10:01:51 2011 + if (!GetProjectPoint(theFace, aPF, theFace1, aPF1, aDNF1, theContext)) { + BOPTools_AlgoTools3D::GetApproxNormalToFaceOnEdge (aE1, theFace1, aT, aPF1, aDNF1); + } + if (!GetProjectPoint(theFace, aPF1, theFace2, aPF2, aDNF2, theContext)) { + BOPTools_AlgoTools3D::GetApproxNormalToFaceOnEdge (aE2, theFace2, aT, aPF2, aDNF2); + } + //modified by NIZHNY-EMV Wed May 25 10:01:53 2011 + //modified by NIZHNY-EMV Wed Sep 21 13:25:27 2011 + //get projects of the points aPF, aPF1, aPF2 on the plane aPL + //927/R7 + gp_Pnt aPFx, aPF1x, aPF2x; + CorrectPoint(aPF, aPL, aPFx); + CorrectPoint(aPF1, aPL, aPF1x); + CorrectPoint(aPF2, aPL, aPF2x); + // + aPF = aPFx; aPF1 = aPF1x; aPF2 = aPF2x; + //modified by NIZHNY-EMV Wed Sep 21 13:25:29 2011 + // + { + Standard_Real aA12, aA1x, aTwoPI; + // + aTwoPI=2.*M_PI; + gp_Vec aVBF (aPx, aPF ); + gp_Vec aVBF1(aPx, aPF1); + gp_Vec aVBF2(aPx, aPF2); + // + gp_Dir aDTF1; + gp_Dir aDBF (aVBF); + gp_Dir aDBF1(aVBF1); + gp_Dir aDBF2(aVBF2); + // + aDTF1=aDNF1^aDBF1; + //aA12=aDBF1.AngleWithRef(aDBF2, aDTF1); + aA12=AngleWithRef(aDBF1, aDBF2, aDTF1); + if (aA12<0.) { + aA12=aA12+aTwoPI; + } + //aA1x=aDBF1.AngleWithRef(aDBF , aDTF1); + aA1x=AngleWithRef(aDBF1, aDBF , aDTF1); + if (aA1x<0.) { + aA1x=aA1x+aTwoPI; + } + // + if (aA1xD0(aT, aPx); + // Ref + BOPTools_AlgoTools2D::EdgeTangent(theE1, aT, aVTgt); + gp_Dir aDTtgt(aVTgt); + aDTtgt.Reverse(); + Handle(Geom_Plane) aPL; + aPL = new Geom_Plane(aPx, aDTtgt); + // N1 + BOPTools_AlgoTools3D::GetApproxNormalToFaceOnEdge(theE1, theF1, aT, aPn1, aDN1); + // + gp_Pnt aPFx, aPF2x; + CorrectPoint(aPn1, aPL, aPFx); + gp_Vec aVBF (aPx, aPFx ); + gp_Dir aDTF; + gp_Dir aDBF (aVBF); + aDTF=aDN1^aDBF; + // + aIt.Initialize(theLCSOff); + for (; aIt.More(); aIt.Next()) { + const BOPTools_CoupleOfShape& aCS=aIt.Value(); + const TopoDS_Edge& aE2=(*(TopoDS_Edge*)(&aCS.Shape1())); + const TopoDS_Face& aF2=(*(TopoDS_Face*)(&aCS.Shape2())); + // + if (aF2==theF1) { + aAngle=M_PI; + } + else if (aF2.IsSame(theF1)) { + aAngle=aTwoPI; + } + else { + //modified by NIZHNY-EMV Tue Sep 06 10:49:54 2011 + BOPTools_AlgoTools3D::GetApproxNormalToFaceOnEdge (aE2, aF2, aT, aPn2, aDN2); + CorrectPoint(aPn2, aPL, aPF2x); + gp_Vec aVBF2(aPx, aPF2x); + gp_Dir aDBF2(aVBF2); + //modified by NIZHNY-EMV Tue Sep 06 10:49:56 2011 + //aDN2.Reverse(); + // Angle + //aAngle=AngleWithRef(aDN1, aDN2, aDTtgt); + aAngle=AngleWithRef(aDBF, aDBF2, aDTF); + //modified by NIZHNY-EMV Fri Oct 14 09:39:45 2011 + // + if(aAngle<0.) { + aAngle=aTwoPI+aAngle; + } + } + + if (aAngle aTolF1) ? aTolE : aTolF1; + } + } + if (!iP) { + return bFlag; + } + // + // 2 + aTolF2=BRep_Tool::Tolerance(aF2); + aTol=aTolF1+aTolF2; + // + BOPTools_AlgoTools3D::PointNearEdge(aE1, aF1, aP2D, aP); + bFlag=theContext->IsValidPointForFace(aP, aF2, aTol); + // + return bFlag; +} + +//======================================================================= +//function : CheckSameGeom +//purpose : +//======================================================================= + Standard_Boolean BOPTools_AlgoTools::CheckSameGeom(const TopoDS_Face& theF1, + const TopoDS_Face& theF2, + Handle(BOPInt_Context)& theContext) +{ + Standard_Boolean bRet; + Standard_Real aTolF1, aTolF2, aTol; + gp_Pnt2d aP2D; + gp_Pnt aP; + TopExp_Explorer aExp; + // + bRet=Standard_False; + aExp.Init(theF1, TopAbs_EDGE); + for (; aExp.More(); aExp.Next()) { + const TopoDS_Edge& aE=(*(TopoDS_Edge*)(&aExp.Current())); + if (!BRep_Tool::Degenerated(aE)) { + aTolF1=BRep_Tool::Tolerance(theF1); + aTolF2=BRep_Tool::Tolerance(theF2); + aTol=aTolF1+aTolF2; + BOPTools_AlgoTools3D::PointNearEdge(aE, theF1, aP2D, aP); + bRet=theContext->IsValidPointForFace(aP, theF2, aTol); + break; + } + } + return bRet; +} +//======================================================================= +// function: Sense +// purpose: +//======================================================================= + Standard_Integer BOPTools_AlgoTools::Sense (const TopoDS_Face& theF1, + const TopoDS_Face& theF2) +{ + Standard_Integer iSense=0; + gp_Dir aDNF1, aDNF2; + TopoDS_Edge aE1, aE2; + TopExp_Explorer aExp; + // + aExp.Init(theF1, TopAbs_EDGE); + for (; aExp.More(); aExp.Next()) { + aE1=(*(TopoDS_Edge*)(&aExp.Current())); + if (!BRep_Tool::Degenerated(aE1)) { + if (!BRep_Tool::IsClosed(aE1, theF1)) { + break; + } + } + } + // + aExp.Init(theF2, TopAbs_EDGE); + for (; aExp.More(); aExp.Next()) { + aE2=(*(TopoDS_Edge*)(&aExp.Current())); + if (!BRep_Tool::Degenerated(aE2)) { + if (!BRep_Tool::IsClosed(aE2, theF2)) { + if (aE2.IsSame(aE1)) { + iSense=1; + break; + } + } + } + } + // + if (!iSense) { + return iSense; + } + // + BOPTools_AlgoTools3D::GetNormalToFaceOnEdge(aE1, theF1, aDNF1); + BOPTools_AlgoTools3D::GetNormalToFaceOnEdge(aE2, theF2, aDNF2); + // + iSense=BOPTools_AlgoTools3D::SenseFlag(aDNF1, aDNF2); + // + return iSense; +} +//======================================================================= +// function: IsSplitToReverse +// purpose: +//======================================================================= + Standard_Boolean BOPTools_AlgoTools::IsSplitToReverse(const TopoDS_Shape& theSp, + const TopoDS_Shape& theSr, + Handle(BOPInt_Context)& theContext) +{ + Standard_Boolean bRet; + TopAbs_ShapeEnum aType; + // + bRet=Standard_False; + // + aType=theSp.ShapeType(); + switch (aType) { + case TopAbs_EDGE: { + const TopoDS_Edge& aESp=(*(TopoDS_Edge*)(&theSp)); + const TopoDS_Edge& aESr=(*(TopoDS_Edge*)(&theSr)); + bRet=BOPTools_AlgoTools::IsSplitToReverse(aESp, aESr, theContext); + } + break; + // + case TopAbs_FACE: { + const TopoDS_Face& aFSp=(*(TopoDS_Face*)(&theSp)); + const TopoDS_Face& aFSr=(*(TopoDS_Face*)(&theSr)); + bRet=BOPTools_AlgoTools::IsSplitToReverse(aFSp, aFSr, theContext); + } + break; + // + default: + break; + } + return bRet; +} +//======================================================================= +//function :IsSplitToReverse +//purpose : +//======================================================================= + Standard_Boolean BOPTools_AlgoTools::IsSplitToReverse(const TopoDS_Face& theFSp, + const TopoDS_Face& theFSr, + Handle(BOPInt_Context)& theContext) +{ + Standard_Boolean bRet, bFound, bInFace; + Standard_Real aT1, aT2, aT, aU, aV, aScPr; + gp_Pnt aPFSp, aPFSr; + gp_Dir aDNFSp; + gp_Vec aD1U, aD1V; + Handle(Geom_Surface) aSr, aSp; + TopAbs_Orientation aOrSr, aOrSp; + TopExp_Explorer anExp; + TopoDS_Edge aESp; + // + bRet=Standard_False; + // + aSr=BRep_Tool::Surface(theFSr); + aSp=BRep_Tool::Surface(theFSp); + if (aSr==aSp) { + aOrSr=theFSr.Orientation(); + aOrSp=theFSp.Orientation(); + bRet=(aOrSr!=aOrSp); + return bRet; + } + // + bFound=Standard_False; + anExp.Init(theFSp, TopAbs_EDGE); + for (; anExp.More(); anExp.Next()) { + aESp=(*(TopoDS_Edge*)(&anExp.Current())); + if (!BRep_Tool::Degenerated(aESp)) { + if (!BRep_Tool::IsClosed(aESp, theFSp)) { + bFound=!bFound; + break; + } + } + } + if (!bFound) { + return bRet; + } + // + BRep_Tool::Range(aESp, aT1, aT2); + aT=BOPTools_AlgoTools2D::IntermediatePoint(aT1, aT2); + BOPTools_AlgoTools3D::GetApproxNormalToFaceOnEdge(aESp, theFSp, aT, aPFSp, aDNFSp); + // + // Parts of theContext->ComputeVS(..) + GeomAPI_ProjectPointOnSurf& aProjector=theContext->ProjPS(theFSr); + aProjector.Perform(aPFSp); + if (!aProjector.IsDone()) { + return bRet; + } + // + aProjector.LowerDistanceParameters(aU, aV); + gp_Pnt2d aP2D(aU, aV); + bInFace=theContext->IsPointInFace (theFSr, aP2D); + if (!bInFace) { + return bRet; + } + // + aSr->D1(aU, aV, aPFSr, aD1U, aD1V); + gp_Dir aDD1U(aD1U); + gp_Dir aDD1V(aD1V); + gp_Dir aDNFSr=aDD1U^aDD1V; + if (theFSr.Orientation()==TopAbs_REVERSED){ + aDNFSr.Reverse(); + } + // + aScPr=aDNFSp*aDNFSr; + bRet=(aScPr<0.); + // + return bRet; +} +//======================================================================= +//function :IsSplitToReverse +//purpose : +//======================================================================= + Standard_Boolean BOPTools_AlgoTools::IsSplitToReverse(const TopoDS_Edge& aEF1, + const TopoDS_Edge& aEF2, + Handle(BOPInt_Context)& theContext) +{ + Standard_Boolean bRet, bIsDegenerated; + // + bRet=Standard_False; + bIsDegenerated=(BRep_Tool::Degenerated(aEF1) || + BRep_Tool::Degenerated(aEF2)); + if (bIsDegenerated) { + return bRet; + } + // + Standard_Real a, b; + TopAbs_Orientation aOrE, aOrSp; + Handle(Geom_Curve)aC1, aC2; + // + aC2=BRep_Tool::Curve(aEF2, a, b); + aC1=BRep_Tool::Curve(aEF1, a, b); + // + if (aC1==aC2) { + aOrE=aEF2.Orientation(); + aOrSp=aEF1.Orientation(); + bRet=(aOrE!=aOrSp); + return bRet; + } + // + Standard_Real aT1, aT2, aScPr; + gp_Vec aV1, aV2; + gp_Pnt aP; + // + aT1=BOPTools_AlgoTools2D::IntermediatePoint(a, b); + aC1->D0(aT1, aP); + BOPTools_AlgoTools2D::EdgeTangent(aEF1, aT1, aV1); + gp_Dir aDT1(aV1); + // + theContext->ProjectPointOnEdge(aP, aEF2, aT2); + // + BOPTools_AlgoTools2D::EdgeTangent(aEF2, aT2, aV2); + gp_Dir aDT2(aV2); + // + aScPr=aDT1*aDT2; + bRet=(aScPr<0.); + // + return bRet; +} + +//======================================================================= +//function : IsHole +//purpose : +//======================================================================= + Standard_Boolean BOPTools_AlgoTools::IsHole(const TopoDS_Shape& aW, + const TopoDS_Shape& aFace) +{ + Standard_Boolean bIsHole; + Standard_Integer i, aNbS; + Standard_Real aT1, aT2, aS; + Standard_Real aU1, aU2, aU, dU; + Standard_Real aX1, aY1, aX0, aY0; + TopAbs_Orientation aOr; + + gp_Pnt2d aP2D0, aP2D1; + Handle(Geom2d_Curve) aC2D; + TopoDS_Face aF, aFF; + TopoDS_Iterator aItW; + // + bIsHole=Standard_False; + // + aF=(*(TopoDS_Face *)(&aFace)); + aFF=aF; + aFF.Orientation(TopAbs_FORWARD); + // + aS=0.; + aItW.Initialize(aW); + for (; aItW.More(); aItW.Next()) { + const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&aItW.Value())); + aOr=aE.Orientation(); + if (!(aOr==TopAbs_FORWARD || + aOr==TopAbs_REVERSED)) { + continue; + } + // + aC2D=BRep_Tool::CurveOnSurface(aE, aFF, aT1, aT2); + if (aC2D.IsNull()) { + break; //xx + } + // + BRepAdaptor_Curve2d aBAC2D(aE, aFF); + aNbS=Geom2dInt_Geom2dCurveTool::NbSamples(aBAC2D); + if (aNbS>2) { + aNbS*=4; + } + // + dU=(aT2-aT1)/(Standard_Real)(aNbS-1); + aU =aT1; + aU1=aT1; + aU2=aT2; + if (aOr==TopAbs_REVERSED) { + aU =aT2; + aU1=aT2; + aU2=aT1; + dU=-dU; + } + // + aC2D->D0(aU, aP2D0); + for(i=2; i<=aNbS; i++) { + aU=aU1+(i-1)*dU; + aC2D->D0(aU, aP2D1); + aP2D0.Coord(aX0, aY0); + aP2D1.Coord(aX1, aY1); + // + aS=aS+(aY0+aY1)*(aX1-aX0); + // + aP2D0=aP2D1; + } + }//for (; aItW.More(); aItW.Next()) { + bIsHole=(aS>0.); + return bIsHole; +} + +//======================================================================= +// function: MakeContainer +// purpose: +//======================================================================= + void BOPTools_AlgoTools::MakeContainer(const TopAbs_ShapeEnum theType, + TopoDS_Shape& theC) +{ + BRep_Builder aBB; + // + switch(theType) { + case TopAbs_COMPOUND:{ + TopoDS_Compound aC; + aBB.MakeCompound(aC); + theC=aC; + } + break; + // + case TopAbs_COMPSOLID:{ + TopoDS_CompSolid aCS; + aBB.MakeCompSolid(aCS); + theC=aCS; + } + break; + // + case TopAbs_SOLID:{ + TopoDS_Solid aSolid; + aBB.MakeSolid(aSolid); + theC=aSolid; + } + break; + // + // + case TopAbs_SHELL:{ + TopoDS_Shell aShell; + aBB.MakeShell(aShell); + theC=aShell; + } + break; + // + case TopAbs_WIRE: { + TopoDS_Wire aWire; + aBB.MakeWire(aWire); + theC=aWire; + } + break; + // + default: + break; + } +} +//======================================================================= +// function: MakePCurve +// purpose: +//======================================================================= + void BOPTools_AlgoTools::MakePCurve(const TopoDS_Edge& aE, + const TopoDS_Face& aF1, + const TopoDS_Face& aF2, + const IntTools_Curve& aIC) + +{ + Standard_Integer i; + Standard_Real aTolE, aT1, aT2, aOutFirst, aOutLast, aOutTol; + Handle(Geom2d_Curve) aC2D, aC2DA, aC2Dx1; + TopoDS_Face aFFWD; + BRep_Builder aBB; + // + aTolE=BRep_Tool::Tolerance(aE); + // + const Handle(Geom_Curve)& aC3DE=BRep_Tool::Curve(aE, aT1, aT2); + Handle(Geom_TrimmedCurve)aC3DETrim=new Geom_TrimmedCurve(aC3DE, aT1, aT2); + // + for (i=0; i<2; ++i) { + if (!i) { + aFFWD=aF1; + aC2Dx1=aIC.FirstCurve2d(); + } + else { + aFFWD=aF2; + aC2Dx1=aIC.SecondCurve2d(); + } + // + aFFWD.Orientation(TopAbs_FORWARD); + // + aC2D=aC2Dx1; + if (aC2D.IsNull()) { + BOPTools_AlgoTools2D::BuildPCurveForEdgeOnFace(aE, aFFWD); + BOPTools_AlgoTools2D::CurveOnSurface(aE, aFFWD, aC2D, + aOutFirst, aOutLast, + aOutTol, Standard_True); + } + // + if (aC3DE->IsPeriodic()) { + BOPTools_AlgoTools2D::AdjustPCurveOnFace(aFFWD, aT1, aT2, aC2D, aC2DA); + } + else { + BOPTools_AlgoTools2D::AdjustPCurveOnFace(aFFWD, aC3DETrim, aC2D, aC2DA); + } + // + aBB.UpdateEdge(aE, aC2DA, aFFWD, aTolE); + //BRepLib::SameParameter(aE); + } + BRepLib::SameParameter(aE); +} +//======================================================================= +// function: MakeEdge +// purpose: +//======================================================================= + void BOPTools_AlgoTools::MakeEdge(const IntTools_Curve& theIC, + const TopoDS_Vertex& theV1, + const Standard_Real theT1, + const TopoDS_Vertex& theV2, + const Standard_Real theT2, + const Standard_Real theTolR3D, + TopoDS_Edge& theE) +{ + Standard_Real aTolV; + BRep_Builder aBB; + // + BOPTools_AlgoTools::MakeSectEdge (theIC, theV1, theT1, theV2, theT2, theE); + // + aBB.UpdateEdge(theE, theTolR3D); + // + aTolV=BRep_Tool::Tolerance(theV1); + if (aTolVaTolSum2) { + return 1; + } + return 0; +} +//======================================================================= +// function: ComputeVV +// purpose: +//======================================================================= + Standard_Integer BOPTools_AlgoTools::ComputeVV(const TopoDS_Vertex& aV1, + const TopoDS_Vertex& aV2) +{ + Standard_Real aTolV1, aTolV2, aTolSum, aTolSum2, aD2; + gp_Pnt aP1, aP2; + // + aTolV1=BRep_Tool::Tolerance(aV1); + aTolV2=BRep_Tool::Tolerance(aV2); + aTolSum=aTolV1+aTolV2; + aTolSum2=aTolSum*aTolSum; + // + aP1=BRep_Tool::Pnt(aV1); + aP2=BRep_Tool::Pnt(aV2); + // + aD2=aP1.SquareDistance(aP2); + if (aD2>aTolSum2) { + return 1; + } + return 0; +} +//======================================================================= +// function: MakeVertex +// purpose : +//======================================================================= + void BOPTools_AlgoTools::MakeVertex(BOPCol_ListOfShape& aLV, + TopoDS_Vertex& aVnew) +{ + Standard_Integer aNb; + Standard_Real aTi, aDi, aDmax; + gp_Pnt aPi, aP; + gp_XYZ aXYZ(0.,0.,0.), aXYZi; + BOPCol_ListIteratorOfListOfShape aIt; + // + aNb=aLV.Extent(); + if (aNb) { + aIt.Initialize(aLV); + for (; aIt.More(); aIt.Next()) { + TopoDS_Vertex& aVi=*((TopoDS_Vertex*)(&aIt.Value())); + aPi=BRep_Tool::Pnt(aVi); + aXYZi=aPi.XYZ(); + aXYZ=aXYZ+aXYZi; + } + // + aXYZ.Divide((Standard_Real)aNb); + aP.SetXYZ(aXYZ); + // + aDmax=-1.; + aIt.Initialize(aLV); + for (; aIt.More(); aIt.Next()) { + TopoDS_Vertex& aVi=*((TopoDS_Vertex*)(&aIt.Value())); + aPi=BRep_Tool::Pnt(aVi); + aTi=BRep_Tool::Tolerance(aVi); + aDi=aP.SquareDistance(aPi); + aDi=fsqrt(aDi); + aDi=aDi+aTi; + if (aDi > aDmax) { + aDmax=aDi; + } + } + // + BRep_Builder aBB; + aBB.MakeVertex (aVnew, aP, aDmax); + } +} +//======================================================================= +//function : GetEdgeOnFace +//purpose : +//======================================================================= + Standard_Boolean BOPTools_AlgoTools::GetEdgeOnFace(const TopoDS_Edge& theE1, + const TopoDS_Face& theF2, + TopoDS_Edge& theE2) +{ + Standard_Boolean bFound; + TopoDS_Iterator aItF, aItW; + // + bFound=Standard_False; + // + aItF.Initialize(theF2); + for (; aItF.More(); aItF.Next()) { + const TopoDS_Shape& aW=aItF.Value(); + aItW.Initialize(aW); + for (; aItW.More(); aItW.Next()) { + const TopoDS_Shape& aE=aItW.Value(); + if (aE.IsSame(theE1)) { + theE2=(*(TopoDS_Edge*)(&aE)); + bFound=!bFound; + return bFound; + } + } + } + return bFound; +} +//======================================================================= +//function : FindFacePairs +//purpose : +//======================================================================= +Standard_Boolean FindFacePairs (const TopoDS_Edge& theE, + const BOPCol_ListOfShape& thLF, + BOPTools_ListOfCoupleOfShape& theLCFF) +{ + Standard_Boolean bFound; + Standard_Integer i, aNbCEF; + TopAbs_Orientation aOr, aOrC; + BOPCol_MapOfShape aMFP; + TopoDS_Face aF1, aF2; + TopoDS_Edge aEL, aE1; + BOPCol_ListIteratorOfListOfShape aItLF; + BOPTools_CoupleOfShape aCEF, aCFF; + BOPTools_ListOfCoupleOfShape aLCEF, aLCEFx; + BOPTools_ListIteratorOfListOfCoupleOfShape aIt; + // + bFound=Standard_True; + // + // Preface aLCEF + aItLF.Initialize(thLF); + for (; aItLF.More(); aItLF.Next()) { + const TopoDS_Face& aFL=(*(TopoDS_Face*)(&aItLF.Value())); + // + bFound=BOPTools_AlgoTools::GetEdgeOnFace(theE, aFL, aEL); + if (!bFound) { + return bFound; // it can not be so + } + // + aCEF.SetShape1(aEL); + aCEF.SetShape2(aFL); + aLCEF.Append(aCEF); + } + // + aNbCEF=aLCEF.Extent(); + while(aNbCEF) { + // + // aLCEFx + aLCEFx.Clear(); + aIt.Initialize(aLCEF); + for (i=0; aIt.More(); aIt.Next(), ++i) { + const BOPTools_CoupleOfShape& aCSx=aIt.Value(); + const TopoDS_Shape& aEx=aCSx.Shape1(); + const TopoDS_Shape& aFx=aCSx.Shape2(); + // + aOr=aEx.Orientation(); + // + if (!i) { + aOrC=TopAbs::Reverse(aOr); + aE1=(*(TopoDS_Edge*)(&aEx)); + aF1=(*(TopoDS_Face*)(&aFx)); + aMFP.Add(aFx); + continue; + } + // + if (aOr==aOrC) { + aLCEFx.Append(aCSx); + aMFP.Add(aFx); + } + } + // + // F2 + BOPTools_AlgoTools::GetFaceOff(aE1, aF1, aLCEFx, aF2); + // + aCFF.SetShape1(aF1); + aCFF.SetShape2(aF2); + theLCFF.Append(aCFF); + // + aMFP.Add(aF1); + aMFP.Add(aF2); + // + // refine aLCEF + aLCEFx.Clear(); + aLCEFx=aLCEF; + aLCEF.Clear(); + aIt.Initialize(aLCEFx); + for (; aIt.More(); aIt.Next()) { + const BOPTools_CoupleOfShape& aCSx=aIt.Value(); + const TopoDS_Shape& aFx=aCSx.Shape2(); + if (!aMFP.Contains(aFx)) { + aLCEF.Append(aCSx); + } + } + // + aNbCEF=aLCEF.Extent(); + }//while(aNbCEF) { + // + return bFound; +} +//======================================================================= +//function : AngleWithRef +//purpose : +//======================================================================= +Standard_Real AngleWithRef(const gp_Dir& theD1, + const gp_Dir& theD2, + const gp_Dir& theDRef) +{ + Standard_Real aCosinus, aSinus, aBeta, aHalfPI, aScPr; + gp_XYZ aXYZ; + // + aHalfPI=0.5*M_PI; + // + const gp_XYZ& aXYZ1=theD1.XYZ(); + const gp_XYZ& aXYZ2=theD2.XYZ(); + aXYZ=aXYZ1.Crossed(aXYZ2); + aSinus=aXYZ.Modulus(); + aCosinus=theD1*theD2; + // + aBeta=0.; + if (aSinus>=0.) { + aBeta=aHalfPI*(1.-aCosinus); + } + else { + aBeta=2.*M_PI-aHalfPI*(3.+aCosinus); + } + // + aScPr=aXYZ.Dot(theDRef.XYZ()); + if (aScPr<0.) { + aBeta=-aBeta; + } + return aBeta; +} +//======================================================================= +//function : fsqrt +//purpose : +//======================================================================= +Standard_Real fsqrt(Standard_Real val) +{ + union { + int tmp; + float val; + } u; + // + u.val = (float)val; + u.tmp -= 1<<23; /* Remove last bit so 1.0 gives 1.0 */ + /* tmp is now an approximation to logbase2(val) */ + u.tmp >>= 1; /* divide by 2 */ + u.tmp += 1<<29; /* add 64 to exponent: (e+127)/2 =(e/2)+63, */ + /* that represents (e/2)-64 but we want e/2 */ + return (double)u.val; +} + +//modified by NIZHNY-EMV Wed Sep 21 15:15:08 2011 +//======================================================================= +//function : CorrectPoint +//purpose : +//======================================================================= + void BOPTools_AlgoTools::CorrectPoint(const gp_Pnt& thePnt, + const Handle(Geom_Plane)& thePL, + gp_Pnt& theNewPnt) +{ + theNewPnt = thePnt; + GeomAPI_ProjectPointOnSurf aProjector; + aProjector.Init(thePnt, thePL); + if (aProjector.NbPoints()) { + theNewPnt = aProjector.NearestPoint(); + } +} +//modified by NIZHNY-EMV Wed Sep 21 15:15:10 2011 + +//======================================================================= +// function: IsBlockInOnFace +// purpose: +//======================================================================= + Standard_Boolean BOPTools_AlgoTools::IsBlockInOnFace (const IntTools_Range& aShrR, + const TopoDS_Face& aF, + const TopoDS_Edge& aE1, + Handle(BOPInt_Context)& aContext) +{ + Standard_Boolean bFlag; + Standard_Real f1, l1, ULD, VLD; + gp_Pnt2d aP2D; + gp_Pnt aP11, aP12; + // + aShrR.Range(f1, l1); + Standard_Real dt=0.0075, k;//dt=0.001, k; + k=dt*(l1-f1); + f1=f1+k; + l1=l1-k; + // + // Treatment P11 + BOPTools_AlgoTools::PointOnEdge(aE1, f1, aP11); + // + GeomAPI_ProjectPointOnSurf& aProjector=aContext->ProjPS(aF); + aProjector.Perform(aP11); + // + bFlag=aProjector.IsDone(); + if (!bFlag) { + return bFlag; + } + + aProjector.LowerDistanceParameters(ULD, VLD); + aP2D.SetCoord(ULD, VLD); + // + bFlag=aContext->IsPointInOnFace (aF, aP2D); + // + if (!bFlag) { + return bFlag; + } + // + // Treatment P12 + BOPTools_AlgoTools::PointOnEdge(aE1, l1, aP12); + // + aProjector.Perform(aP12); + // + bFlag=aProjector.IsDone(); + if (!bFlag) { + return bFlag; + } + + aProjector.LowerDistanceParameters(ULD, VLD); + aP2D.SetCoord(ULD, VLD); + // + bFlag=aContext->IsPointInOnFace (aF, aP2D); + // + if (!bFlag) { + return bFlag; + } + // + // Treatment intemediate + Standard_Real m1, aTolF, aTolE, aTol, aDist; + m1=IntTools_Tools::IntermediatePoint(f1, l1); + BOPTools_AlgoTools::PointOnEdge(aE1, m1, aP12); + // + aProjector.Perform(aP12); + // + bFlag=aProjector.IsDone(); + if (!bFlag) { + return bFlag; + } + // + aTolE=BRep_Tool::Tolerance(aE1); + aTolF=BRep_Tool::Tolerance(aF); + aTol=aTolE+aTolF; + aDist=aProjector.LowerDistance(); + if (aDist > aTol){ + return Standard_False; + } + + aProjector.LowerDistanceParameters(ULD, VLD); + aP2D.SetCoord(ULD, VLD); + // + bFlag=aContext->IsPointInOnFace (aF, aP2D); + // + if (!bFlag) { + return bFlag; + } + return bFlag; +} + +//======================================================================= +//function : GetProjectPoint +//purpose : +//======================================================================= + Standard_Boolean BOPTools_AlgoTools::GetProjectPoint(const TopoDS_Face& aF, + const gp_Pnt& aPF, + const TopoDS_Face& aF1, + gp_Pnt& aPF1, + gp_Dir& aDNF1, + Handle(BOPInt_Context)& aContext) +{ + Standard_Boolean bRet = Standard_False; + Handle(Geom_Surface) aS, aS1; + GeomAbs_SurfaceType aTS, aTS1; + Handle(Geom_CylindricalSurface) aCS, aCS1; + Standard_Real aR, aR1, dR, aU, aV; + // + aS = BRep_Tool::Surface(aF); + aS1 = BRep_Tool::Surface(aF1); + GeomAdaptor_Surface aGAS(aS), aGAS1(aS1); + // + aTS = aGAS.GetType(); + aTS1 = aGAS1.GetType(); + // + if (!(aTS == GeomAbs_Cylinder && aTS1 == GeomAbs_Cylinder)) { + return bRet; + } + // + aCS = Handle(Geom_CylindricalSurface)::DownCast(aS); + aCS1 = Handle(Geom_CylindricalSurface)::DownCast(aS1); + // + if (aCS.IsNull() || aCS1.IsNull()) { + return bRet; + } + // + if (!aCS->Axis().IsParallel(aCS1->Axis(), Precision::Angular())) { + return bRet; + } + // + aR = aCS->Radius(); + aR1 = aCS1->Radius(); + dR = Abs(aR - aR1); + // + if (dR == 0) { + return bRet; + } + + gp_Lin aL(aCS->Axis()), aL1(aCS1->Axis()); + if (Abs(aL.Distance(aL1) - dR) < Precision::Confusion()) { + GeomAPI_ProjectPointOnSurf& aProjector=aContext->ProjPS(aF1); + aProjector.Perform(aPF); + if (!aProjector.IsDone()) { + return bRet; + } + aProjector.LowerDistanceParameters(aU, aV); + Handle(Geom_Surface) aS = BRep_Tool::Surface(aF1); + BOPTools_AlgoTools3D::GetNormalToSurface (aS, aU, aV, aDNF1); + aS->D0(aU, aV, aPF1); + bRet = !bRet; + } + return bRet; +} +/* +//======================================================================= +//function : AreFacesSameDomain +//purpose : +//======================================================================= + Standard_Boolean BOPTools_AlgoTools::AreFacesSameDomain(const TopoDS_Face& theF1, + const TopoDS_Face& theF2, + Handle(BOPInt_Context)& theContext) + { + Standard_Boolean bFlag; + + Standard_Integer aNbE1, aNbE2; + Standard_Real aTolF1, aTolF2, aTol; + gp_Pnt2d aP2D; + gp_Pnt aP; + TopoDS_Face aF1, aF2; + TopExp_Explorer aExp; + BOPCol_MapOfShape aME1, aME2; + BOPCol_MapIteratorOfMapOfShape aIt; + // + bFlag=Standard_False; + // + aF1=theF1; + aF1.Orientation(TopAbs_FORWARD); + aF2=theF2; + aF2.Orientation(TopAbs_FORWARD); + // + // 1 + aExp.Init(aF1, TopAbs_EDGE); + for (; aExp.More(); aExp.Next()) { + const TopoDS_Edge& aE=(*(TopoDS_Edge*)(&aExp.Current())); + if (!BRep_Tool::Degenerated(aE)) { + aME1.Add(aE); + } + } + // + aExp.Init(aF2, TopAbs_EDGE); + for (; aExp.More(); aExp.Next()) { + const TopoDS_Edge& aE=(*(TopoDS_Edge*)(&aExp.Current())); + if (!BRep_Tool::Degenerated(aE)) { + if (!aME1.Contains(aE)) { + return bFlag; + } + aME2.Add(aE); + } + } + // + aNbE1=aME1.Extent(); + aNbE2=aME2.Extent(); + // + if(!aNbE1 || !aNbE2){ + return bFlag; + } + // + if(aNbE1!=aNbE2) { + return bFlag; + } + // + // 2 + aTolF1=BRep_Tool::Tolerance(aF1); + aTolF2=BRep_Tool::Tolerance(aF2); + aTol=aTolF1+aTolF2; + // + aIt.Initialize(aME1); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Edge& aE=(*(TopoDS_Edge*)(&aIt.Key())); + BOPTools_AlgoTools3D::PointNearEdge(aE, aF1, aP2D, aP); + bFlag=theContext->IsValidPointForFace(aP, aF2, aTol); + break; + } + // + return bFlag; +} +*/ diff --git a/src/BOPTools/BOPTools_AlgoTools2D.cdl b/src/BOPTools/BOPTools_AlgoTools2D.cdl new file mode 100644 index 0000000000..74c2bc7b8a --- /dev/null +++ b/src/BOPTools/BOPTools_AlgoTools2D.cdl @@ -0,0 +1,262 @@ +-- Created by: Peter KURNEV +-- Copyright (c) 1999-2012 OPEN CASCADE SAS +-- +-- The content of this file is subject to the Open CASCADE Technology Public +-- License Version 6.5 (the "License"). You may not use the content of this file +-- except in compliance with the License. Please obtain a copy of the License +-- at http://www.opencascade.org and read it completely before using this file. +-- +-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +-- +-- The Original Code and all software distributed under the License is +-- distributed on an "AS IS" basis, without warranty of any kind, and the +-- Initial Developer hereby disclaims all such warranties, including without +-- limitation, any warranties of merchantability, fitness for a particular +-- purpose or non-infringement. Please see the License for the specific terms +-- and conditions governing the rights and limitations under the License. + + +class AlgoTools2D from BOPTools + + ---Purpose: + --- The class contains handy static functions + --- dealing with the topology + --- This is the copy of the BOPTools_AlgoTools2D.cdl +uses + Vec from gp, + Dir from gp, + Vertex from TopoDS, + Edge from TopoDS, + Face from TopoDS, + + Curve from Geom2d, + Curve from Geom, + ProjectedCurve from ProjLib + +is + + BuildPCurveForEdgeOnFace (myclass; + aE: Edge from TopoDS; + aF: Face from TopoDS); + ---Purpose: + --- Compute P-Curve for the edge on the face + --- + EdgeTangent (myclass; + anE : Edge from TopoDS; + aT : Real from Standard; + Tau : out Vec from gp) + returns Boolean from Standard; + ---Purpose: + --- Compute tangent for the edge [in 3D] at parameter + --- + + PointOnSurface (myclass; + aE: Edge from TopoDS; + aF: Face from TopoDS; + aT: Real from Standard; + U : out Real from Standard; + V : out Real from Standard); + ---Purpose: + --- Compute surface parameters of the face + --- for the point from the edge at parameter . + --- + CurveOnSurface (myclass; + aE: Edge from TopoDS; + aF: Face from TopoDS; + aC : out Curve from Geom2d; + aToler: out Real from Standard; + aTrim3d:Boolean from Standard); + ---Purpose: + --- Get P-Curve for the edge on surface . + --- If the P-Curve does not exist, build it using Make2D(). + --- [aToler] - reached tolerance + --- [aTrim3d] - trimming flag. + --- + CurveOnSurface (myclass; + aE: Edge from TopoDS; + aF: Face from TopoDS; + aC : out Curve from Geom2d; + aFirst: out Real from Standard; + aLast : out Real from Standard; + aToler: out Real from Standard; + aTrim3d:Boolean from Standard); + + ---Purpose: + --- Get P-Curve for the edge on surface . + --- If the P-Curve does not exist, build it using Make2D(). + --- [aFirst, aLast] - range of the P-Curve + --- [aToler] - reached tolerance + --- [aTrim3d] - trimming flag. + --- + HasCurveOnSurface (myclass; + aE: Edge from TopoDS; + aF: Face from TopoDS; + aC : out Curve from Geom2d; + aFirst: out Real from Standard; + aLast : out Real from Standard; + aToler: out Real from Standard) + returns Boolean from Standard; + ---Purpose: + --- Returns TRUE if the edge has P-Curve + --- on surface . + --- [aFirst, aLast] - range of the P-Curve + --- [aToler] - reached tolerance + --- If the P-Curve does not exist, aC.IsNull()=TRUE. + --- + HasCurveOnSurface (myclass; + aE: Edge from TopoDS; + aF: Face from TopoDS) + returns Boolean from Standard; + ---Purpose: + --- Returns TRUE if the edge has P-Curve + --- on surface . + --- If the P-Curve does not exist, aC.IsNull()=TRUE. + --- + + AdjustPCurveOnFace (myclass; + aF : Face from TopoDS; + C3D : Curve from Geom; + aC2D : Curve from Geom2d; + aC2DA : out Curve from Geom2d); + ---Purpose: + --- Adjust P-Curve (3D-curve ) on surface . + --- + AdjustPCurveOnFace (myclass; + aF : Face from TopoDS; + aT1 : Real from Standard; + aT2 : Real from Standard; + aC2D : Curve from Geom2d; + aC2DA : out Curve from Geom2d); + ---Purpose: + --- Adjust P-Curve (3D-curve ) on surface . + --- [aT1, aT2] - range to adjust + --- + + IntermediatePoint (myclass; + aFirst: Real from Standard; + aLast : Real from Standard) + returns Real from Standard; + ---Purpose: + --- Compute intermediate value in between [aFirst, aLast] . + --- + IntermediatePoint (myclass; + anE : Edge from TopoDS) + returns Real from Standard; + ---Purpose: + --- Compute intermediate value of parameter for the edge . + --- + BuildPCurveForEdgeOnPlane(myclass; + theE : Edge from TopoDS; + theF : Face from TopoDS); + + Make2D (myclass; + aE: Edge from TopoDS; + aF: Face from TopoDS; + aC : out Curve from Geom2d; + aFirst: out Real from Standard; + aLast : out Real from Standard; + aToler: out Real from Standard; + aTrim3d:Boolean from Standard); + ---Purpose: + --- Make P-Curve for the edge on surface . + --- [aFirst, aLast] - range of the P-Curve + --- [aToler] - reached tolerance + --- [aTrim3d] - trimming flag. + --- + + MakeCurveOnSurface (myclass; + aE: Edge from TopoDS; + aF: Face from TopoDS; + aC : out Curve from Geom2d; + aFirst: out Real from Standard; + aLast : out Real from Standard; + aToler: out Real from Standard; + aTrim3d:Boolean from Standard); + ---Purpose: + --- Same as Make2D() + --- + MakePCurveOnFace (myclass; + aF: Face from TopoDS; + C3D : Curve from Geom; + aC : out Curve from Geom2d; + aToler: out Real from Standard) ; + ---Purpose: + --- Make P-Curve for the 3D-curve on surface . + --- [aToler] - reached tolerance + --- + MakePCurveOnFace (myclass; + aF: Face from TopoDS; + C3D : Curve from Geom; + aT1 : Real from Standard; + aT2 : Real from Standard; + aC : out Curve from Geom2d; + aToler: out Real from Standard) ; + ---Purpose: + --- Make P-Curve for the 3D-curve on surface . + --- [aT1, aT2] - range to build + --- [aToler] - reached tolerance + --- + MakePCurveOfType (myclass; + PC : ProjectedCurve from ProjLib; + aC : out Curve from Geom2d); + ---Purpose: + --- Make empty P-Curve of relevant to type + --- + + + + + + + + +-- RemovePCurveForEdgeOnFace (myclass; +-- aE: Edge from TopoDS; +-- aF: Face from TopoDS); + ---Purpose: + --- Remove P-Curve of the edge on the face + --- +-- FaceNormal (myclass; +-- aF: Face from TopoDS; +-- U : Real from Standard; +-- V : Real from Standard; +-- aN: out Vec from gp); + ---Purpose: + --- Compute normal for the face at parameters + --- of the corresp. surface. + --- +-- TangentOnEdge (myclass; +-- aParm: Real from Standard; +-- anE : Edge from TopoDS; +-- aTang: out Vec from gp) +-- returns Boolean from Standard; +-- ---Purpose: + --- Compute tangent for the edge at parameter + --- +-- TangentOnEdge (myclass; +-- anE : Edge from TopoDS; +-- aDTang: out Dir from gp) +-- returns Boolean from Standard; + ---Purpose: + --- Compute tangent for the edge at arbitrary intermediate parameter. + --- +-- TangentOnVertex (myclass; +-- aVF : Vertex from TopoDS; +-- aVL : Vertex from TopoDS; +-- anE : Edge from TopoDS; +-- aTang: out Vec from gp) +-- returns Boolean from Standard; + ---Purpose: + --- Compute tangent for the vertex point for the edge . + --- is opposite vertex of the edge + --- +-- EdgeBounds (myclass; +-- anE : Edge from TopoDS; +-- aFirst: out Real from Standard; +-- aLast : out Real from Standard); + ---Purpose: + --- Returns parametric range for the edge . + --- + +end AlgoTools2D; diff --git a/src/BOPTools/BOPTools_AlgoTools2D.cxx b/src/BOPTools/BOPTools_AlgoTools2D.cxx new file mode 100755 index 0000000000..93bd916ad4 --- /dev/null +++ b/src/BOPTools/BOPTools_AlgoTools2D.cxx @@ -0,0 +1,810 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#include + +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +static + Standard_Boolean CheckEdgeLength (const TopoDS_Edge& E); + +//======================================================================= +//function : BuildPCurveForEdgeOnFace +//purpose : +//======================================================================= + void BOPTools_AlgoTools2D::BuildPCurveForEdgeOnFace (const TopoDS_Edge& aE, + const TopoDS_Face& aF) +{ + BRep_Builder aBB; + Handle(Geom2d_Curve) aC2D; + Standard_Real aTolPC, aTolFact, aTolEdge, aFirst, aLast; + + Standard_Boolean aHasOld; + aHasOld=BOPTools_AlgoTools2D::HasCurveOnSurface (aE, aF, aC2D, aFirst, aLast, aTolEdge); + if (aHasOld) { + return; + } + + + BOPTools_AlgoTools2D::CurveOnSurface(aE, aF, aC2D, aTolPC, Standard_True); + + aTolEdge=BRep_Tool::Tolerance(aE); + + aTolFact=Max(aTolEdge, aTolPC); + + aBB.UpdateEdge(aE, aC2D, aF, aTolFact); + return; +} + +//======================================================================= +//function : EdgeTangent +//purpose : +//======================================================================= + Standard_Boolean BOPTools_AlgoTools2D::EdgeTangent(const TopoDS_Edge& anEdge, + const Standard_Real aT, + gp_Vec& aTau) +{ + Standard_Boolean isdgE; + Standard_Real first, last; + + isdgE = BRep_Tool::Degenerated(anEdge); + if (isdgE) { + return Standard_False; + } + if (!CheckEdgeLength(anEdge)) { + return Standard_False; + } + + Handle(Geom_Curve) aC=BRep_Tool::Curve(anEdge, first, last); + gp_Pnt aP; + aC->D1(aT, aP, aTau); + Standard_Real mod = aTau.Magnitude(); + if(mod > gp::Resolution()) { + aTau /= mod; + } + else { + return Standard_False; + } + //aTau.Normalize(); + if (anEdge.Orientation() == TopAbs_REVERSED){ + aTau.Reverse(); + } + return Standard_True; +} + +//======================================================================= +//function : PointOnOnSurface +//purpose : +//======================================================================= + void BOPTools_AlgoTools2D::PointOnSurface (const TopoDS_Edge& aE, + const TopoDS_Face& aF, + const Standard_Real aParameter, + Standard_Real& U, + Standard_Real& V) +{ + gp_Pnt2d aP2D; + Handle(Geom2d_Curve) aC2D; + Standard_Real aToler, aFirst, aLast; + + BOPTools_AlgoTools2D::CurveOnSurface (aE, aF, aC2D, aFirst, aLast, aToler, Standard_True); + aC2D->D0(aParameter, aP2D); + U=aP2D.X(); + V=aP2D.Y(); + return; +} + +//======================================================================= +//function : CurveOnSurface +//purpose : +//======================================================================= + void BOPTools_AlgoTools2D::CurveOnSurface (const TopoDS_Edge& aE, + const TopoDS_Face& aF, + Handle(Geom2d_Curve)& aC2D, + Standard_Real& aToler, + const Standard_Boolean trim3d) +{ + Standard_Real aFirst, aLast; + + BOPTools_AlgoTools2D::CurveOnSurface (aE, aF, aC2D, aFirst, aLast, aToler, trim3d); + + return; +} +//======================================================================= +//function : CurveOnSurface +//purpose : +//======================================================================= + void BOPTools_AlgoTools2D::CurveOnSurface (const TopoDS_Edge& aE, + const TopoDS_Face& aF, + Handle(Geom2d_Curve)& aC2D, + Standard_Real& aFirst, + Standard_Real& aLast, + Standard_Real& aToler, + const Standard_Boolean trim3d) +{ + Standard_Boolean aHasOld; + Handle(Geom2d_Curve) C2D; + + aHasOld=BOPTools_AlgoTools2D::HasCurveOnSurface (aE, aF, C2D, aFirst, aLast, aToler); + if (aHasOld) { + aC2D=C2D; + return; + } + + BOPTools_AlgoTools2D::Make2D(aE, aF, C2D, aFirst, aLast, aToler, trim3d); + aC2D=C2D; + return; +} + +//======================================================================= +//function : HasCurveOnSurface +//purpose : +//======================================================================= + Standard_Boolean BOPTools_AlgoTools2D::HasCurveOnSurface (const TopoDS_Edge& aE, + const TopoDS_Face& aF, + Handle(Geom2d_Curve)& aC2D, + Standard_Real& aFirst, + Standard_Real& aLast, + Standard_Real& aToler) +{ + Standard_Boolean aHasOld; + + aToler=BRep_Tool::Tolerance(aE); + BRep_Tool::Range(aE, aFirst, aLast); + + if((aLast - aFirst) < Precision::PConfusion()) { + return Standard_False; + } + + aC2D =BRep_Tool::CurveOnSurface(aE, aF, aFirst, aLast); + aHasOld=!aC2D.IsNull(); + return aHasOld; +} +//======================================================================= +//function : HasCurveOnSurface +//purpose : +//======================================================================= + Standard_Boolean BOPTools_AlgoTools2D::HasCurveOnSurface (const TopoDS_Edge& aE, + const TopoDS_Face& aF) + +{ + Standard_Boolean aHasOld; + Handle(Geom2d_Curve) aC2D; + Standard_Real aFirst, aLast; + BRep_Tool::Range(aE, aFirst, aLast); + + if((aLast - aFirst) < Precision::PConfusion()) { + return Standard_False; + } + + aC2D =BRep_Tool::CurveOnSurface(aE, aF, aFirst, aLast); + aHasOld=!aC2D.IsNull(); + return aHasOld; +} + +//======================================================================= +//function : AdjustPCurveOnFace +//purpose : +//======================================================================= + void BOPTools_AlgoTools2D::AdjustPCurveOnFace (const TopoDS_Face& aF, + const Handle(Geom_Curve)& aC3D, + const Handle(Geom2d_Curve)& aC2D, + Handle(Geom2d_Curve)& aC2DA) +{ + Standard_Real first, last; + + first = aC3D -> FirstParameter(); + last = aC3D -> LastParameter(); + + BOPTools_AlgoTools2D::AdjustPCurveOnFace (aF, first, last, aC2D, aC2DA); +} +//======================================================================= +//function : AdjustPCurveOnFace +//purpose : +//======================================================================= + void BOPTools_AlgoTools2D::AdjustPCurveOnFace (const TopoDS_Face& aF, + const Standard_Real aFirst, + const Standard_Real aLast, + const Handle(Geom2d_Curve)& aC2D, + Handle(Geom2d_Curve)& aC2DA) +{ + Standard_Boolean mincond, maxcond, decalu, decalv; + Standard_Integer k, iCnt; + Standard_Real UMin, UMax, VMin, VMax, aT, u2, v2, du, dv, aDelta; + Standard_Real aUPeriod, aUP2, aUP1, aUNew, aDif, aUx; + // + aDelta=Precision::PConfusion(); + + BRepAdaptor_Surface aBAS(aF, Standard_False); + + BRepTools::UVBounds(aF, UMin, UMax, VMin, VMax); + + aT =.5*(aFirst+aLast); + + gp_Pnt2d pC2D; + aC2D->D0(aT, pC2D); + + u2 = pC2D.X(); + v2 = pC2D.Y(); + + du = 0.; + if (aBAS.IsUPeriodic()) { + aUPeriod=aBAS.UPeriod(); + mincond = (u2 < UMin-aDelta); + maxcond = (u2 > UMax+aDelta); + + decalu = mincond || maxcond; + if (decalu) { + //modified by NIZNHY-PKV Mon Mar 25 16:44:46 2008f + //du = ( mincond ) ? UPeriod : -UPeriod; + // + iCnt=1; + aUP2=aUPeriod+aUPeriod+aDelta; + aUP1=aUPeriod+aDelta; + // + if (u2 > aUP2) { + for(k=1; 1; ++k) { + aUx=u2-k*aUPeriod; + if (aUx < aUP1) { + iCnt=k; + break; + } + } + } + else if (u2 < -aUP2) { + for(k=1; 1; ++k) { + aUx=u2+k*aUPeriod; + if (aUx > -aUP1) { + iCnt=k; + break; + } + } + } + du = ( mincond ) ? aUPeriod : -aUPeriod; + du=iCnt*du; + //modified by NIZNHY-PKV Mon Mar 25 16:44:49 2008t + } + // + aUNew=u2+du; + if (aUNew<(UMin-aDelta) || + aUNew>(UMax+aDelta)) { + // So previous correction was wrong. + // Try to be closer to UMin or UMax. + du=0.; + if (u2>UMax){ + aDif=u2-UMax; + if (aDif < 4.e-7) { + du=-aDif; + } + } + } + } // if (BAHS->IsUPeriodic()) + // + // dv + dv = 0.; + if (aBAS.IsVPeriodic()) { + Standard_Real aVPeriod, aVm, aVr, aVmid, dVm, dVr; + // + aVPeriod=aBAS.VPeriod(); + mincond = (VMin - v2 > aDelta); + maxcond = (v2 - VMax > aDelta); + decalv = mincond || maxcond; + if (decalv) { + dv = ( mincond ) ? aVPeriod : -aVPeriod; + } + // + //xf + if ((VMax-VMinCopy()); + gp_Vec2d aV2D(du,dv); + PCT->Translate(aV2D); + aC2Dx = PCT; + } + + aC2DA=aC2Dx; +} + +//======================================================================= +//function : IntermediatePoint +//purpose : +//======================================================================= + Standard_Real BOPTools_AlgoTools2D::IntermediatePoint (const Standard_Real aFirst, + const Standard_Real aLast) +{ + //define parameter division number as 10*e^(-PI) = 0.43213918 + const Standard_Real PAR_T = 0.43213918; + Standard_Real aParm; + aParm=(1.-PAR_T)*aFirst + PAR_T*aLast; + return aParm; +} +//======================================================================= +//function : IntermediatePoint +//purpose : +//======================================================================= + Standard_Real BOPTools_AlgoTools2D::IntermediatePoint (const TopoDS_Edge& aE) + +{ + Standard_Real aT, aT1, aT2; + + Handle(Geom_Curve)aC1=BRep_Tool::Curve(aE, aT1, aT2); + if (aC1.IsNull()) + BRep_Tool::Range(aE, aT1, aT2); + + aT=BOPTools_AlgoTools2D::IntermediatePoint(aT1, aT2); + return aT; +} + +//======================================================================= +//function : BuildPCurveForEdgeOnPlane +//purpose : +//======================================================================= + void BOPTools_AlgoTools2D::BuildPCurveForEdgeOnPlane (const TopoDS_Edge& aE, + const TopoDS_Face& aF) +{ + Standard_Real aTolE; + TopLoc_Location aLoc; + Handle(Geom2d_Curve) aC2D; + Handle(Geom_Plane) aGP; + Handle(Geom_RectangularTrimmedSurface) aGRTS; + BRep_Builder aBB; + // + const Handle(Geom_Surface)& aS = BRep_Tool::Surface(aF, aLoc); + aGRTS=Handle(Geom_RectangularTrimmedSurface)::DownCast(aS); + if(!aGRTS.IsNull()){ + aGP=Handle(Geom_Plane)::DownCast(aGRTS->BasisSurface()); + } + else { + aGP=Handle(Geom_Plane)::DownCast(aS); + } + // + if (aGP.IsNull()) { + return; + } + // + BOPTools_AlgoTools2D::CurveOnSurface(aE, aF, aC2D, aTolE, Standard_True); + aBB.UpdateEdge(aE, aC2D, aF, aTolE); + // + return; +} + +//======================================================================= +//function : Make2D +//purpose : +//======================================================================= + void BOPTools_AlgoTools2D::Make2D (const TopoDS_Edge& aE, + const TopoDS_Face& aF, + Handle(Geom2d_Curve)& aC2D, + Standard_Real& aFirst, + Standard_Real& aLast, + Standard_Real& aToler, + const Standard_Boolean trim3d) +{ + Standard_Boolean aLocIdentity; + Standard_Real f3d, l3d; + TopLoc_Location aLoc; + + Handle(Geom2d_Curve) C2D; + + + C2D=BRep_Tool::CurveOnSurface(aE, aF, aFirst, aLast); + + if (!C2D.IsNull()) { + aC2D=C2D; + return; + } + + Handle(Geom_Curve) C3D3, C3D2, C3D; + C3D = BRep_Tool::Curve(aE, aLoc, f3d, l3d); + // + if (C3D.IsNull()) { + // aE has no 3D curve, so nothing is done + } + // + aLocIdentity=aLoc.IsIdentity(); + + if (aLocIdentity) { + C3D2 = C3D; + } + else { + C3D2 = Handle(Geom_Curve):: + DownCast(C3D->Transformed(aLoc.Transformation())); + } + + if (trim3d) { + + C3D3=C3D2; + } + + else { + C3D3=C3D2; + } + // + aToler=.5*BRep_Tool::Tolerance(aE); + BOPTools_AlgoTools2D::MakePCurveOnFace(aF, C3D3, f3d, l3d, aC2D, aToler); + // + aFirst = f3d; + aLast = l3d; +} + +//======================================================================= +//function : MakePCurveOnFace +//purpose : +//======================================================================= + void BOPTools_AlgoTools2D::MakePCurveOnFace (const TopoDS_Face& aF, + const Handle(Geom_Curve)& aC3D, + Handle(Geom2d_Curve)& aC2D, //-> + Standard_Real& TolReached2d) +{ + Standard_Real aFirst, aLast; + + aFirst = aC3D -> FirstParameter(); + aLast = aC3D -> LastParameter(); + // + TolReached2d=0.; + // + BOPTools_AlgoTools2D::MakePCurveOnFace (aF, aC3D, aFirst, aLast, aC2D, TolReached2d); +} + +//======================================================================= +//function : MakePCurveOnFace +//purpose : +//======================================================================= + void BOPTools_AlgoTools2D::MakePCurveOnFace (const TopoDS_Face& aF, + const Handle(Geom_Curve)& aC3D, + const Standard_Real aFirst, + const Standard_Real aLast, + Handle(Geom2d_Curve)& aC2D, + Standard_Real& TolReached2d) +{ + Standard_Real aTolR; + Handle(Geom2d_Curve) aC2DA; + + BRepAdaptor_Surface aBAS(aF, Standard_False); + Handle(BRepAdaptor_HSurface) aBAHS = new BRepAdaptor_HSurface(aBAS); + Handle(GeomAdaptor_HCurve) aBAHC = new GeomAdaptor_HCurve(aC3D, aFirst, aLast); + + //modified by NIZHNY-EMV Thu Nov 24 12:16:31 2011 + //when the type of surface is GeomAbs_SurfaceOfRevolution + if (aBAS.GetType() == GeomAbs_SurfaceOfRevolution) { + Standard_Real aTR = 1.e-7; + ProjLib_ProjectedCurve aProj1(aBAHS, aBAHC, aTR); + BOPTools_AlgoTools2D::MakePCurveOfType(aProj1, aC2D); + aTolR = aProj1.GetTolerance(); + } else { + ProjLib_ProjectedCurve aProjCurv(aBAHS, aBAHC);// 1 + BOPTools_AlgoTools2D::MakePCurveOfType(aProjCurv, aC2D); + aTolR=aProjCurv.GetTolerance(); + } + //modified by NIZHNY-EMV Thu Nov 24 12:16:35 2011 + // + if (aC2D.IsNull()) { + ProjLib_ProjectedCurve aProjCurvAgain(aBAHS, aBAHC, TolReached2d);// 2 + BOPTools_AlgoTools2D::MakePCurveOfType(aProjCurvAgain, aC2D); + aTolR = aProjCurvAgain.GetTolerance(); + // + if (aC2D.IsNull()) { + Standard_Real aTR=0.0001; + ProjLib_ProjectedCurve aProj3(aBAHS, aBAHC, aTR);// 3 + BOPTools_AlgoTools2D::MakePCurveOfType(aProj3, aC2D); + aTolR = aProj3.GetTolerance(); + } + } + TolReached2d=aTolR; + + BOPTools_AlgoTools2D::AdjustPCurveOnFace (aF, aFirst, aLast, aC2D, aC2DA); + aC2D=aC2DA; +} + +//======================================================================= +//function : MakePCurveOfType +//purpose : +//======================================================================= + void BOPTools_AlgoTools2D::MakePCurveOfType(const ProjLib_ProjectedCurve& PC, + Handle(Geom2d_Curve)& C2D) +{ + + switch (PC.GetType()) { + + case GeomAbs_Line : + C2D = new Geom2d_Line(PC.Line()); + break; + case GeomAbs_Circle : + C2D = new Geom2d_Circle(PC.Circle()); + break; + case GeomAbs_Ellipse : + C2D = new Geom2d_Ellipse(PC.Ellipse()); + break; + case GeomAbs_Parabola : + C2D = new Geom2d_Parabola(PC.Parabola()); + break; + case GeomAbs_Hyperbola : + C2D = new Geom2d_Hyperbola(PC.Hyperbola()); + break; + case GeomAbs_BSplineCurve : + C2D = PC.BSpline(); + break; + case GeomAbs_BezierCurve : + case GeomAbs_OtherCurve : + default : + Standard_NotImplemented::Raise("BOPTools_AlgoTools2D::MakePCurveOfType"); + break; + } +} + +//======================================================================= +//function : CheckEdgeLength +//purpose : +//======================================================================= +Standard_Boolean CheckEdgeLength (const TopoDS_Edge& E) +{ + BRepAdaptor_Curve BC(E); + + BOPCol_IndexedMapOfShape aM; + BOPTools::MapShapes(E, TopAbs_VERTEX, aM); + Standard_Integer i, anExtent, aN=10; + Standard_Real ln=0., d, t, f, l, dt; + anExtent=aM.Extent(); + + if (anExtent!=1) + return Standard_True; + + gp_Pnt p1, p2; + f = BC.FirstParameter(); + l = BC.LastParameter(); + dt=(l-f)/aN; + + BC.D0(f, p1); + for (i=1; i<=aN; i++) { + t=f+i*dt; + + if (i==aN) + BC.D0(l, p2); + else + BC.D0(t, p2); + + d=p1.Distance(p2); + ln+=d; + p1=p2; + } + + return (ln > Precision::Confusion()); +} + + + + + + + + +/* +//======================================================================= +//function : FaceNormal +//purpose : +//======================================================================= + void BOPTools_AlgoTools2D::FaceNormal (const TopoDS_Face& aF, + const Standard_Real U, + const Standard_Real V, + gp_Vec& aN) +{ + gp_Pnt aPnt ; + gp_Vec aD1U, aD1V; + Handle(Geom_Surface) aSurface; + + aSurface=BRep_Tool::Surface(aF); + aSurface->D1 (U, V, aPnt, aD1U, aD1V); + aN=aD1U.Crossed(aD1V); + aN.Normalize(); + if (aF.Orientation() == TopAbs_REVERSED){ + aN.Reverse(); + } + return; +} +//======================================================================= +//function : RemovePCurveForEdgeOnFace +//purpose : +//======================================================================= + void BOPTools_AlgoTools2D::RemovePCurveForEdgeOnFace (const TopoDS_Edge& aE, + const TopoDS_Face& aF) +{ + BRep_Builder aBB; + Handle(Geom2d_Curve) aC2D; + Standard_Real aTol; + + aTol=BRep_Tool::Tolerance(aE); + aBB.UpdateEdge(aE, aC2D, aF, aTol); +} +//======================================================================= +//function : MakeCurveOnSurface +//purpose : +//======================================================================= + void BOPTools_AlgoTools2D::MakeCurveOnSurface (const TopoDS_Edge& aE, + const TopoDS_Face& aF, + Handle(Geom2d_Curve)& aC2D, + Standard_Real& aFirst, + Standard_Real& aLast, + Standard_Real& aToler, + const Standard_Boolean trim3d) +{ + BOPTools_AlgoTools2D::Make2D(aE, aF, aC2D, aFirst, aLast, aToler, trim3d); +} + +//======================================================================= +//function : TangentOnEdge +//purpose : +//======================================================================= + Standard_Boolean BOPTools_AlgoTools2D::TangentOnEdge(const Standard_Real par, + const TopoDS_Edge& E, + gp_Vec& Tg) +{ + Standard_Boolean isdgE; + + isdgE = BRep_Tool::Degenerated(E); + if (isdgE) { + return Standard_False; + } + if (!CheckEdgeLength(E)) { + return Standard_False; + } + + BRepAdaptor_Curve BC(E); + // + // Body + Standard_Real f, l, tolE, tolp; + Standard_Boolean onf, onl, inbounds; + + f = BC.FirstParameter(); + l = BC.LastParameter(); + tolE = BC.Tolerance(); + tolp = BC.Resolution(tolE); + + onf = Abs(f-par) seam edge for the face + -- + + GetNormalToFaceOnEdge (myclass; + aE: Edge from TopoDS; + aF: Face from TopoDS; + aT: Real from Standard; + aD:out Dir from gp); + ---Purpose: + --- Computes normal to the face for the point on the edge + --- at parameter + --- + GetNormalToFaceOnEdge (myclass; + aE: Edge from TopoDS; + aF: Face from TopoDS; + aD:out Dir from gp); + ---Purpose: + --- Computes normal to the face for the point on the edge + --- at arbitrary intermediate parameter + --- + + SenseFlag (myclass; + aNF1 : Dir from gp; + aNF2 : Dir from gp) + returns Integer from Standard; + ---Purpose: + --- Returns 1 if scalar product aNF1* aNF2>0. + --- Returns 0 if directions aNF1 aNF2 coinside + --- Returns -1 if scalar product aNF1* aNF2<0. + --- + GetNormalToSurface (myclass; + aS: Surface from Geom; + U : Real from Standard; + V : Real from Standard; + aD:out Dir from gp) + returns Boolean from Standard; + ---Purpose: + --- Compute normal to surface in point (U,V) + --- Returns TRUE if directions aD1U, aD1V coinside + --- + + GetApproxNormalToFaceOnEdge (myclass; + aE: Edge from TopoDS; + aF: Face from TopoDS; + aT: Real from Standard; + aPx:out Pnt from gp; + aD:out Dir from gp); + ---Purpose: + --- Computes normal to the face for the 3D-point that + --- belonds to the edge at parameter . + -- Output: + --- aPx - the 3D-point where the normal computed + --- aD - the normal; + --- + -- Warning: + --- The normal is computed not exactly in the point on the + --- edge, but in point that is near to the edge towards to + --- the face material (so, we'll have approx. normal) + --- + + --modified by NIZHNY-EMV Wed May 25 09:52:22 2011 + GetApproxNormalToFaceOnEdge(myclass; + theE : Edge from TopoDS; + theF : Face from TopoDS; + aT : Real from Standard; + aP : out Pnt from gp; + aDNF : out Dir from gp; + aDt2D: Real from Standard); + --modified by NIZHNY-EMV Wed May 25 09:52:24 2011 + + PointNearEdge (myclass; + aE : Edge from TopoDS; + aF : Face from TopoDS; + aT : Real from Standard; + aDt2D: Real from Standard; + aP2D :out Pnt2d from gp; + aPx :out Pnt from gp); + ---Purpose: + --- Compute the point , () that is near to + --- the edge at parameter towards to the + --- material of the face . The value of shifting in + --- 2D is + --- + PointNearEdge (myclass; + aE: Edge from TopoDS; + aF: Face from TopoDS; + aT: Real from Standard; + aP2D:out Pnt2d from gp; + aPx:out Pnt from gp); + ---Purpose: + --- Computes the point , () that is near to + --- the edge at parameter towards to the + --- material of the face . The value of shifting in + -- 2D is dt2D=BOPTools_AlgoTools3D::MinStepIn2d() + --- + PointNearEdge (myclass; + aE: Edge from TopoDS; + aF: Face from TopoDS; + aP2D:out Pnt2d from gp; + aPx:out Pnt from gp); + ---Purpose: + --- Compute the point , () that is near to + --- the edge at arbitrary parameter towards to the + --- material of the face . The value of shifting in + -- 2D is dt2D=BOPTools_AlgoTools3D::MinStepIn2d() + --- + + MinStepIn2d(myclass) + returns Real from Standard; + ---Purpose: + --- Returns simple step value that is used in 2D-computations + --- = 1.e-5 + --- + IsEmptyShape(myclass; + aS: Shape from TopoDS) + returns Boolean from Standard; + ---Purpose: + --- Returns TRUE if the shape does not contain + --- geometry information (e.g. empty compound) + --- + + OrientEdgeOnFace (myclass; + aE : Edge from TopoDS; + aF : Face from TopoDS; + aER : out Edge from TopoDS); + ---Purpose: + --- Get the edge from the face that is the same as + --- the edge + --- + + + + + + --modified by NIZHNY-MKK Mon Feb 17 15:02:01 2003.BEGIN +-- DoSplitSEAMOnFace (myclass; +-- theSplit : Edge from TopoDS; +-- theSeam : Edge from TopoDS; +-- theFace : Face from TopoDS; +-- IsReversed: out Boolean from Standard) +-- returns Boolean from Standard; + ---Purpose: + -- Make the edge seam edge for the face + -- It uses pcurves of to make seam edge. + -- IsReversed is true if pcurves of and are + -- reversed according to each other. + -- Returns true if was made seam edge for + -- + --modified by NIZHNY-MKK Mon Feb 17 15:02:04 2003.END + +-- SubShapesAmount (myclass; +-- aS: Shape from TopoDS; +-- aT: ShapeEnum from TopAbs) +-- returns Integer from Standard ; + ---Purpose: + -- Returns amount of sub-shapes of type + -- for the shape + -- +-- IsConvexWire (myclass; +-- aW: Wire from TopoDS) +-- returns Boolean from Standard ; + ---Purpose: + -- Returns TRUE if + -- amount of the vertices <= amount of the edges> + -- for the wire + -- + +-- RemoveSims (myclass; +-- aF: Face from TopoDS; +-- aContext:out Context from IntTools); +-- ---Purpose: + -- Remove seam edges from face + -- +-- RemoveSims (myclass; +-- aS: Shape from TopoDS; +-- aContext:out Context from IntTools); + ---Purpose: + -- Remove seam edges from all faces of shape + -- +-- EdgeOrientation (myclass; +-- aEx: Edge from TopoDS; +-- aF1: Face from TopoDS; +-- aF2: Face from TopoDS) +-- returns Orientation from TopAbs; + ---Purpose: + -- For the draft section edge computes orientation + -- in accordance with vector product between normals to + -- the faces , + -- +-- IsSplitToReverse1 (myclass; +-- aE1: Edge from TopoDS; +-- aE2: Edge from TopoDS; +-- aContext:out Context from IntTools) +-- returns Boolean from Standard; + ---Purpose: + -- Returns TRUE if direction of the edge is not + -- the same as for the edge + -- (using projection) + -- +-- IsTouchCase (myclass; +-- aEx: Edge from TopoDS; +-- aF1: Face from TopoDS; +-- aF2: Face from TopoDS) +-- returns Boolean from Standard; + ---Purpose: + -- Returns TRUE if the edge is section edge + -- between touching faces , + -- +-- GetTangentToEdge (myclass; +-- aE: Edge from TopoDS; +-- aT: Real from Standard; +-- aD:out Dir from gp) +-- returns Boolean from Standard; + ---Purpose: + -- Computes tangent (3D) for the edge + -- at parameter + -- Returns TRUE if the edge is not degenerated. + -- +-- GetTangentToEdge (myclass; +-- aE: Edge from TopoDS; +-- aD:out Dir from gp) +-- returns Boolean from Standard; + ---Purpose: + --- Computes tangent (3D) for the edge + --- at arbitrary intermediate parameter + --- Returns TRUE if the edge is not degenerated. + --- +-- GetBiNormal (myclass; +-- aE: Edge from TopoDS; +-- aF: Face from TopoDS; +-- aT: Real from Standard; +-- aD:out Dir from gp); + ---Purpose: + --- Computes binormal to the face for the point on the edge + --- at parameter + --- +-- GetBiNormal (myclass; +-- aE: Edge from TopoDS; +-- aF: Face from TopoDS; +-- aD:out Dir from gp); + ---Purpose: + --- Computes binormal to the face for the point on the edge + --- at arbitrary intermediate parameter + --- +-- IsSplitToReverse(myclass; +-- aE : Edge from TopoDS; +-- aSp: Edge from TopoDS) +-- returns Boolean from Standard; + ---Purpose: + --- Returns TRUE if direction of the edge is not + --- the same as for the edge + --- +-- GetAdjacentFace (myclass; +-- aF : Face from TopoDS; +-- aE : Edge from TopoDS; +-- aEFMap: IndexedDataMapOfShapeListOfShape from BOPCol; +-- anAdjF:out Face from TopoDS) +-- returns Boolean from Standard; + ---Purpose: + --- Get face that is adjacent to the face through + --- the edge (using map EF ) + --- Returns FALSE if adjacent face is not found + --- +-- IsKeepTwice (myclass; +-- aF1 : Face from TopoDS; +-- aF2 : Face from TopoDS; +-- aF2Adj: Face from TopoDS; +-- aSpEF2: Edge from TopoDS) +-- returns Boolean from Standard; + ---Purpose: + --- Returns TRUE if pair of faces and + --- that are adjacent faces through the edge + --- crosses the face by + --- +-- GetPlanes (myclass; +-- aSp : Edge from TopoDS; +-- aE2 : Edge from TopoDS; +-- aEFMap2: IndexedDataMapOfShapeListOfShape from BOPCol; +-- aE1 : Edge from TopoDS; +-- aF1 : Face from TopoDS; +-- aST1:out State from TopAbs; +-- aContext:out Context from IntTools); + ---Purpose: + --- Internal usage + --- +-- Orientation (myclass; +-- aE : Edge from TopoDS; +-- aF : Face from TopoDS) +-- returns Orientation from TopAbs; + ---Purpose: + --- Get the orientation for the edge on the face + --- Returns TopAbs_INTERNAL if the edge is not found + --- on the face + --- +-- SignDistance (myclass; +-- aP : Pnt from gp; +-- aPL: Pln from gp) +-- returns Real from Standard; + ---Purpose: + --- Computes signed distance between the 3D-point + --- and the plane . + --- + -- Warning: + --- The distance is not divided by sqrt(A*A+B*B+C*C) + --- +-- PointToCompare (myclass; +-- aP1: Pnt from gp; +-- aP2: Pnt from gp; +-- aF: Face from TopoDS; +-- aPx:out Pnt from gp; +-- aContext:out Context from IntTools); + ---Purpose: + --- For 3D-point find projection point on the face . + --- If the distance (, ) > TolF => + --- For 3D-point find projection point on the face . + --- If the distance (, ) > TolF => returns + --- +-- GetPlane (myclass; +-- aSp : Edge from TopoDS; +-- aE1 : Edge from TopoDS; +-- aF1 : Face from TopoDS; +-- aF2 : Face from TopoDS; +-- aST:out State from TopAbs; +-- aContext:out Context from IntTools); + ---Purpose: + --- Compute 3D-state for the point on the split edge + --- (with base edge and the face ) comparing with + --- the face + --- +-- GetPointState (myclass; +-- aSp : Edge from TopoDS; +-- aEF2 : Edge from TopoDS; +-- aF2Adj : Face from TopoDS; +-- aF1 : Face from TopoDS; +-- aST:out State from TopAbs); + ---Purpose: + --- Compute 3D-state for the point on the split edge + --- (with base edge and the adjacent face ) comparing with + --- the face + --- + +-- OrientTouchEdgeOnF1 (myclass; +-- aSp: Edge from TopoDS; +-- aEx: Edge from TopoDS; +-- aF1: Face from TopoDS; +-- aF2: Face from TopoDS) +-- returns Orientation from TopAbs; + ---Purpose: + --- Computes orientation for the split edge + --- [with base edge and face ] on the + --- face + --- +-- GetSeams (myclass; +-- aF : Face from TopoDS; +-- aSimm1 : out Edge from TopoDS; +-- aSimm2 : out Edge from TopoDS); + ---Purpose: + --- Get seam edges , for the face + --- +-- GetSeam (myclass; +-- aF : Face from TopoDS; +-- aS1: Edge from TopoDS; +-- aS2: out Edge from TopoDS); + ---Purpose: + --- Get opposite seam edge for the face with + --- known seam edge + --- +-- IsValidArea (myclass; +-- aF : Face from TopoDS; +-- aNegativeFlag : out Boolean from Standard) +-- returns Boolean from Standard; + ---Purpose: + --- Check validity of the area of face . + --- Returns TRUE if the Abs. value of the area + --- is greater than 1.e-16 + --- +-- InvertShape(myclass; +-- aS : Shape from TopoDS; +-- aSInv:out Shape from TopoDS); + ---Purpose: + --- Change orientations to opposite for the shape + --- and all its sub-shapes. Returns + --- +-- GetStatePartIN2D(myclass; +-- aSp :Edge from TopoDS; +-- aEF1 :Edge from TopoDS; +-- aF1 :Face from TopoDS; +-- aF2 :Face from TopoDS; +-- aContext:out Context from IntTools) +-- returns State from TopAbs; + ---Purpose: + --- Used in touch case + --- Compute the 3D-state for the point on the split + --- edge (with base edge on face ) + --- comparing with . + --- Used in touch case / + --- +-- CheckSameDomainFaceInside(myclass; +-- theFace1: Face from TopoDS; +-- theFace2: Face from TopoDS; +-- theContext: in out Context from IntTools) +-- returns Boolean from Standard; + +-- ComputeFaceState(myclass; +-- theFace: Face from TopoDS; +-- theRef : Solid from TopoDS; +-- theContext: in out Context from IntTools; +-- theState: out State from TopAbs) +-- returns Boolean from Standard; + +-- TreatedAsAnalytic(myclass; +-- aTx :Real from Standard; +-- aPx :Pnt from gp; +-- aEx :Edge from TopoDS; +-- aFx :Face from TopoDS; +-- aE1 :Edge from TopoDS; +-- aF1 :Face from TopoDS; +-- aTolTangent:Real from Standard; +-- aTolRadius :Real from Standard; +-- aState :out State from TopAbs; +-- aContext:out Context from IntTools) +-- returns Boolean from Standard; + +-- TreatedAsAnalytic (myclass; +-- aFx :Face from TopoDS; +-- aSpE1 :Edge from TopoDS; +-- aF1 :Face from TopoDS; +-- aTolTangent:Real from Standard; +-- aTolRadius :Real from Standard; +-- aState :out State from TopAbs; +-- aContext:out Context from IntTools) +-- returns Boolean from Standard; + +-- HasAnalyticSurfaceType (myclass; +-- aF: Face from TopoDS) +-- returns Boolean from Standard; + +end AlgoTools3D; diff --git a/src/BOPTools/BOPTools_AlgoTools3D.cxx b/src/BOPTools/BOPTools_AlgoTools3D.cxx new file mode 100644 index 0000000000..e1513e89d7 --- /dev/null +++ b/src/BOPTools/BOPTools_AlgoTools3D.cxx @@ -0,0 +1,701 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + +#include + +#include +#include + +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static void Add(const TopoDS_Shape& aS, + BOPCol_IndexedMapOfShape& myShapes, + Standard_Boolean& bHasGeometry); +static + Standard_Boolean HasGeometry(const TopoDS_Shape& aS); + +//======================================================================= +//function : DoSplitSEAMOnFace +//purpose : +//======================================================================= + void BOPTools_AlgoTools3D::DoSplitSEAMOnFace (const TopoDS_Edge& aSplit, + const TopoDS_Face& aF) +{ + Standard_Boolean bIsUPeriodic, bIsLeft; + Standard_Real aTol, a, b, anUPeriod, aT, anU, dU=1.e-7, anU1; + Standard_Real aScPr; + gp_Pnt2d aP2D; + gp_Vec2d aVec2D; + Handle(Geom2d_Curve) aTmpC1, aTmpC2; + Handle(Geom2d_Curve) C2D1; + Handle(Geom2d_Line) aLD1; + Handle(Geom_Surface) aS; + BRep_Builder BB; + TopoDS_Edge aSp; + // + aSp=aSplit; + aSp.Orientation(TopAbs_FORWARD); + + aTol=BRep_Tool::Tolerance(aSp); + + aS=BRep_Tool::Surface(aF); + bIsUPeriodic=aS->IsUPeriodic(); + + anUPeriod=0.; + if (bIsUPeriodic) { + anUPeriod=aS->UPeriod(); + } + else { + //modified by NIZNHY-PKV Fri Jul 11 09:54:43 2008f + Standard_Boolean bIsUClosed; + Standard_Real aUmin, aUmax, aVmin, aVmax; + Handle(Geom_BSplineSurface) aBS; + Handle(Geom_BezierSurface) aBZ; + // + bIsUClosed=Standard_False; + aBS=Handle(Geom_BSplineSurface)::DownCast(aS); + aBZ=Handle(Geom_BezierSurface) ::DownCast(aS); + // + if (!aBS.IsNull()) { + bIsUClosed=aBS->IsUClosed(); + aBS->Bounds(aUmin, aUmax, aVmin, aVmax); + } + else if (!aBZ.IsNull()) { + bIsUClosed=aBZ->IsUClosed(); + aBZ->Bounds(aUmin, aUmax, aVmin, aVmax); + } + if (!bIsUClosed) { + return; + } + // + anUPeriod=aUmax-aUmin; + //modified by NIZNHY-PKV Fri Jul 11 09:54:49 2008t + } + // + C2D1=BRep_Tool::CurveOnSurface(aSp, aF, a, b); + //modified by NIZNHY-PKV Fri Jul 11 09:55:10 2008f + /* + aLD1=Handle(Geom2d_Line)::DownCast(C2D1); + if (aLD1.IsNull()) { + return; + } + */ + //modified by NIZNHY-PKV Fri Jul 11 09:55:14 2008t + // + aT=BOPTools_AlgoTools2D::IntermediatePoint(a, b); + C2D1->D1(aT, aP2D, aVec2D); + gp_Dir2d aDir2D1(aVec2D); + + // + gp_Dir2d aDOY(0.,1.); + aScPr=aDir2D1*aDOY; + // + // + anU=aP2D.X(); + if (fabs (anU) < dU) { + bIsLeft=Standard_True; + anU1=anU+anUPeriod; + } + else if (fabs (anU-anUPeriod) < dU) { + bIsLeft=Standard_False; + anU1=anU-anUPeriod; + } + else { + return; + } + // + + + aTmpC1=Handle(Geom2d_Curve)::DownCast(C2D1->Copy()); + Handle(Geom2d_TrimmedCurve) aC1 = new Geom2d_TrimmedCurve(aTmpC1, a, b); + + aTmpC2=Handle(Geom2d_Curve)::DownCast(C2D1->Copy()); + Handle(Geom2d_TrimmedCurve) aC2 = new Geom2d_TrimmedCurve(aTmpC2, a, b); + gp_Vec2d aTrV(anU1-anU, 0.); + aC2->Translate(aTrV); + // + if (!bIsLeft) { + if (aScPr<0.) { + BB.UpdateEdge(aSp, aC2, aC1, aF, aTol); + } + else { + BB.UpdateEdge(aSp, aC1, aC2, aF, aTol); + } + } + else { + if (aScPr<0.) { + BB.UpdateEdge(aSp, aC1, aC2, aF, aTol); + } + else { + BB.UpdateEdge(aSp, aC2, aC1, aF, aTol); + } + } + // +} + +//======================================================================= +//function : GetNormalToFaceOnEdge +//purpose : +//======================================================================= + void BOPTools_AlgoTools3D::GetNormalToFaceOnEdge (const TopoDS_Edge& aE, + const TopoDS_Face& aF, + gp_Dir& aDNF) +{ + Standard_Real aT, aT1, aT2; + + BRep_Tool::CurveOnSurface(aE, aF, aT1, aT2); + aT=BOPTools_AlgoTools2D::IntermediatePoint(aT1, aT2); + + BOPTools_AlgoTools3D::GetNormalToFaceOnEdge (aE, aF, aT, aDNF); + + if (aF.Orientation()==TopAbs_REVERSED){ + aDNF.Reverse(); + } +} + +//======================================================================= +//function : GetNormalToFaceOnEdge +//purpose : +//======================================================================= + void BOPTools_AlgoTools3D::GetNormalToFaceOnEdge (const TopoDS_Edge& aE, + const TopoDS_Face& aF1, + const Standard_Real aT, + gp_Dir& aDNF1) +{ + Standard_Real U, V, aTolPC; + gp_Pnt2d aP2D; + gp_Pnt aP; + gp_Vec aD1U, aD1V; + + Handle(Geom_Surface) aS1=BRep_Tool::Surface(aF1); + + Handle(Geom2d_Curve)aC2D1; + BOPTools_AlgoTools2D::CurveOnSurface(aE, aF1, aC2D1, aTolPC, Standard_True); + + aC2D1->D0(aT, aP2D); + U=aP2D.X(); + V=aP2D.Y(); + + aS1->D1(U, V, aP, aD1U, aD1V); + gp_Dir aDD1U(aD1U); + gp_Dir aDD1V(aD1V); + + aDNF1=aDD1U^aDD1V; +} + +//======================================================================= +//function : SenseFlag +//purpose : +//======================================================================= + Standard_Integer BOPTools_AlgoTools3D::SenseFlag (const gp_Dir& aDNF1, + const gp_Dir& aDNF2) +{ + Standard_Boolean bIsDirsCoinside; + bIsDirsCoinside=IntTools_Tools::IsDirsCoinside(aDNF1, aDNF2); + if (!bIsDirsCoinside) { + return 0; + } + + Standard_Real aScPr; + + aScPr=aDNF1*aDNF2; + if (aScPr<0.) { + return -1; + } + else if (aScPr>0.) { + return 1; + } + return -1; +} + +//======================================================================= +//function : GetNormalToSurface +//purpose : +//======================================================================= + Standard_Boolean BOPTools_AlgoTools3D::GetNormalToSurface (const Handle(Geom_Surface)& aS, + const Standard_Real U, + const Standard_Real V, + gp_Dir& aDNS) +{ + Standard_Boolean bFlag; + + gp_Pnt aP; + gp_Vec aD1U, aD1V; + + aS->D1(U, V, aP, aD1U, aD1V); + + gp_Dir aDD1U(aD1U); + gp_Dir aDD1V(aD1V); + + bFlag=IntTools_Tools::IsDirsCoinside(aDD1U, aDD1U); + if (!bFlag) { + return bFlag; + } + + aDNS=aDD1U^aDD1V; + return bFlag; +} + +//======================================================================= +//function : GetApproxNormalToFaceOnEdge +//purpose : +//======================================================================= + + void BOPTools_AlgoTools3D::GetApproxNormalToFaceOnEdge(const TopoDS_Edge& aE, + const TopoDS_Face& aF, + const Standard_Real aT, + gp_Pnt& aPNear, + gp_Dir& aDNF, + Standard_Real aDt2D) +{ + Standard_Real aFirst, aLast; + Handle(Geom2d_Curve) aC2D= BRep_Tool::CurveOnSurface (aE, aF, aFirst, aLast); + + if (aC2D.IsNull()) { + return; + } + gp_Pnt2d aPx2DNear; + //modified by NIZHNY-EMV Wed Oct 12 08:21:12 2011 + //BOPTools_AlgoTools3D::PointNearEdge (aE, aF, aT, aDt2D, aPx2DNear, aPNear); + PointNearEdge (aE, aF, aT, aDt2D, aPx2DNear, aPNear); + //modified by NIZHNY-EMV Wed Oct 12 08:21:15 2011 + Handle(Geom_Surface) aS=BRep_Tool::Surface(aF); + + BOPTools_AlgoTools3D::GetNormalToSurface (aS, aPx2DNear.X(), aPx2DNear.Y(), aDNF); + + if (aF.Orientation()==TopAbs_REVERSED){ + aDNF.Reverse(); + } +} + + +//======================================================================= +//function : GetApproxNormalToFaceOnEdge +//purpose : +//======================================================================= + void BOPTools_AlgoTools3D::GetApproxNormalToFaceOnEdge (const TopoDS_Edge& aE, + const TopoDS_Face& aF, + const Standard_Real aT, + gp_Pnt& aPNear, + gp_Dir& aDNF) +{ + Standard_Real aFirst, aLast; + Handle(Geom2d_Curve) aC2D= BRep_Tool::CurveOnSurface (aE, aF, aFirst, aLast); + + if (aC2D.IsNull()) { + return; + } + //gp_Pnt aPNear; + gp_Pnt2d aPx2DNear; + BOPTools_AlgoTools3D::PointNearEdge (aE, aF, aT, aPx2DNear, aPNear); + + Handle(Geom_Surface) aS=BRep_Tool::Surface(aF); + + BOPTools_AlgoTools3D::GetNormalToSurface (aS, aPx2DNear.X(), aPx2DNear.Y(), aDNF); + + if (aF.Orientation()==TopAbs_REVERSED){ + aDNF.Reverse(); + } +} + +//======================================================================= +//function : PointNearEdge +//purpose : +//======================================================================= + void BOPTools_AlgoTools3D::PointNearEdge (const TopoDS_Edge& aE, + const TopoDS_Face& aF, + const Standard_Real aT, + const Standard_Real aDt2D, + gp_Pnt2d& aPx2DNear, + gp_Pnt& aPxNear) +{ + Standard_Real aFirst, aLast, aETol, aFTol, transVal; + GeomAbs_SurfaceType aTS; + Handle(Geom2d_Curve) aC2D; + Handle(Geom_Surface) aS; + // + aC2D= BRep_Tool::CurveOnSurface (aE, aF, aFirst, aLast); + if (aC2D.IsNull()) { + aPx2DNear.SetCoord (99., 99); + return; + } + // + aS=BRep_Tool::Surface(aF); + // + gp_Pnt2d aPx2D; + gp_Vec2d aVx2D; + aC2D->D1 (aT, aPx2D, aVx2D); + gp_Dir2d aDx2D(aVx2D); + + gp_Dir2d aDP; + aDP.SetCoord (-aDx2D.Y(), aDx2D.X()); + + if (aE.Orientation()==TopAbs_REVERSED){ + aDP.Reverse(); + } + + if (aF.Orientation()==TopAbs_REVERSED) { + aDP.Reverse(); + } + // + aETol = BRep_Tool::Tolerance(aE); + aFTol = BRep_Tool::Tolerance(aF); + // pkv NPAL19220 + GeomAdaptor_Surface aGAS(aS); + aTS=aGAS.GetType(); + if (aTS==GeomAbs_BSplineSurface) { + if (aETol > 1.e-5) { + aFTol=aETol; + } + } + //modified by NIZNHY-PKV Thu Mar 19 14:15:15 2009f + if( aETol > 1.e-5 || aFTol > 1.e-5 ) { + //if( aETol > 1.e-5 && aFTol > 1.e-5 ) { + //modified by NIZNHY-PKV Thu Mar 19 14:15:24 2009t + //pkv/103/D7 + if(aTS!=GeomAbs_Sphere) { + gp_Vec2d transVec( aDP ); + transVal = aDt2D + aETol + aFTol; + if (aTS==GeomAbs_Cylinder) {// pkv/909/F8 + Standard_Real aR, dT; + // + gp_Cylinder aCyl=aGAS.Cylinder(); + aR=aCyl.Radius(); + dT=1.-transVal/aR; + dT=acos(dT); + transVal=dT; + } + // + transVec.Multiply(transVal); + // + aPx2DNear = aPx2D.Translated( transVec ); + //modified by NIZHNY-EMV Wed Oct 12 07:57:53 2011 + //chl/902/m4,m5 + Standard_Real uRes, vRes; + uRes = aGAS.UResolution(transVal); + vRes = aGAS.VResolution(transVal); + if (fabs(aPx2D.X() - aPx2DNear.X()) > uRes) { + aPx2DNear.SetCoord (aPx2D.X()+uRes*aDP.X(), aPx2DNear.Y()); + } + if (fabs(aPx2D.Y() - aPx2DNear.Y()) > vRes) { + aPx2DNear.SetCoord (aPx2DNear.X(), aPx2DNear.Y()+vRes*aDP.Y()); + } + //modified by NIZHNY-EMV Wed Oct 12 07:57:55 2011 + } + else { + aPx2DNear.SetCoord (aPx2D.X()+aDt2D*aDP.X(), aPx2D.Y()+aDt2D*aDP.Y()); + } + } + else { + aPx2DNear.SetCoord (aPx2D.X()+aDt2D*aDP.X(), aPx2D.Y()+aDt2D*aDP.Y()); + } + // + aS->D0(aPx2DNear.X(), aPx2DNear.Y(), aPxNear); +} + +//======================================================================= +//function : PointNearEdge +//purpose : +//======================================================================= + void BOPTools_AlgoTools3D::PointNearEdge (const TopoDS_Edge& aE, + const TopoDS_Face& aF, + const Standard_Real aT, + gp_Pnt2d& aPx2DNear, + gp_Pnt& aPxNear) +{ + Standard_Real dt2D=BOPTools_AlgoTools3D::MinStepIn2d();//~1.e-5; + //modified by NIZHNY-EMV Mon Sep 17 14:31:13 2012 + Standard_Real aTolE, aTolF, dtx; + // + Handle(Geom_Surface) aS = BRep_Tool::Surface(aF); + GeomAdaptor_Surface aGAS(aS); + if (aGAS.GetType()==GeomAbs_Cylinder || + aGAS.GetType()==GeomAbs_Sphere) { + dt2D *= 100; + } else { + dt2D *= 10; + } + aTolE = BRep_Tool::Tolerance(aE); + aTolF = BRep_Tool::Tolerance(aF); + dtx = 2*(aTolE + aTolF); + dt2D = (dtx > dt2D) ? dtx : dt2D; + //modified by NIZHNY-EMV Mon Sep 17 14:31:17 2012 + BOPTools_AlgoTools3D::PointNearEdge (aE, aF, aT, dt2D, aPx2DNear, aPxNear); +} + +//======================================================================= +// function: PointNearEdge +// purpose: +//======================================================================= + void BOPTools_AlgoTools3D::PointNearEdge (const TopoDS_Edge& aE, + const TopoDS_Face& aF, + gp_Pnt2d& aPInFace2D, + gp_Pnt& aPInFace) +{ + Standard_Real aT, aT1, aT2; + // + // 1. + BRep_Tool::Range(aE, aT1, aT2); + aT=BOPTools_AlgoTools2D::IntermediatePoint(aT1, aT2); + // + // 2. a Point inside Face near aPOnEdge aPInFace; + TopoDS_Face aFF=aF; + TopoDS_Edge aERight; + aFF.Orientation(TopAbs_FORWARD); + BOPTools_AlgoTools3D::OrientEdgeOnFace (aE, aFF, aERight); + + BOPTools_AlgoTools3D::PointNearEdge (aERight, aFF, aT, aPInFace2D, aPInFace); +} + +//======================================================================= +//function : MinStepIn2d +//purpose : +//======================================================================= + Standard_Real BOPTools_AlgoTools3D::MinStepIn2d() +{ + Standard_Real dt=1.e-5; + return dt; +} + +//======================================================================= +//function : IsEmptyShape +//purpose : +//======================================================================= + Standard_Boolean BOPTools_AlgoTools3D::IsEmptyShape(const TopoDS_Shape& aS) +{ + Standard_Boolean bHasGeometry=Standard_False; + // + BOPCol_IndexedMapOfShape myShapes; + // + Add(aS, myShapes, bHasGeometry); + + return !bHasGeometry; +} + +//======================================================================= +//function : Add +//purpose : +//======================================================================= +void Add(const TopoDS_Shape& aS, + BOPCol_IndexedMapOfShape& myShapes, + Standard_Boolean& bHasGeometry) +{ + Standard_Integer anIndex; + // + if (bHasGeometry) { + return; + } + // + if (aS.IsNull()) { + return; + } + // + TopoDS_Shape aSx = aS; + // + anIndex=myShapes.FindIndex(aSx); + if (!anIndex) { + bHasGeometry=HasGeometry (aSx); + if (bHasGeometry) { + return; + } + // + TopoDS_Iterator anIt(aSx, Standard_False, Standard_False); + for(; anIt.More(); anIt.Next()) { + const TopoDS_Shape& aSy=anIt.Value(); + Add(aSy, myShapes, bHasGeometry); + // + if (bHasGeometry) { + return; + } + // + myShapes.Add(aSx); + } + } +} + +//======================================================================= +//function : HasGeometry +//purpose : +//======================================================================= + Standard_Boolean HasGeometry(const TopoDS_Shape& aS) +{ + Standard_Boolean bHasGeometry=Standard_True; + TopAbs_ShapeEnum aType= aS.ShapeType(); + + if (aType == TopAbs_VERTEX) { + + Handle(BRep_TVertex) TV = Handle(BRep_TVertex)::DownCast(aS.TShape()); + BRep_ListIteratorOfListOfPointRepresentation itrp(TV->Points()); + + while (itrp.More()) { + const Handle(BRep_PointRepresentation)& PR = itrp.Value(); + + if (PR->IsPointOnCurve()) { + return bHasGeometry; + } + + else if (PR->IsPointOnCurveOnSurface()) { + return bHasGeometry; + } + + else if (PR->IsPointOnSurface()) { + return bHasGeometry; + } + itrp.Next(); + } + } + + // + else if (aType == TopAbs_EDGE) { + Handle(BRep_TEdge) TE = Handle(BRep_TEdge)::DownCast(aS.TShape()); + BRep_ListIteratorOfListOfCurveRepresentation itrc(TE->Curves()); + + while (itrc.More()) { + const Handle(BRep_CurveRepresentation)& CR = itrc.Value(); + if (CR->IsCurve3D()) { + if (!CR->Curve3D().IsNull()) { + return bHasGeometry; + } + } + else if (CR->IsCurveOnSurface()) { + return bHasGeometry; + } + else if (CR->IsRegularity()) { + return bHasGeometry; + } + else if (!CR->Polygon3D().IsNull()) { + return bHasGeometry; + } + else if (CR->IsPolygonOnTriangulation()) { + return bHasGeometry; + } + else if (CR->IsPolygonOnSurface()) { + return bHasGeometry; + } + itrc.Next(); + } + } + // + else if (aType == TopAbs_FACE) { + Handle(BRep_TFace) TF = Handle(BRep_TFace)::DownCast(aS.TShape()); + if (!TF->Surface().IsNull()) { + return bHasGeometry; + } + Handle(Poly_Triangulation) Tr = TF->Triangulation(); + if (!Tr.IsNull()) { + return bHasGeometry; + } + } + + return !bHasGeometry; +} + + +//======================================================================= +//function : OrientEdgeOnFace +//purpose : +//======================================================================= + void BOPTools_AlgoTools3D::OrientEdgeOnFace (const TopoDS_Edge& aE, + const TopoDS_Face& aF, + TopoDS_Edge& aERight) +{ + if (BRep_Tool::IsClosed(aE, aF)) { + aERight=aE; + aERight.Orientation(aE.Orientation()); + + Standard_Integer iFoundCount = 0; + TopoDS_Edge anEdge = aE; + TopExp_Explorer anExp(aF, TopAbs_EDGE); + + for (; anExp.More(); anExp.Next()) { + const TopoDS_Shape& aSS=anExp.Current(); + + if (aSS.IsSame(aE)) { + anEdge = TopoDS::Edge(aSS); + iFoundCount++; + } + } + + if(iFoundCount == 1) { + aERight = anEdge; + } + return; + } + + TopExp_Explorer anExp(aF, TopAbs_EDGE); + for (; anExp.More(); anExp.Next()) { + const TopoDS_Shape& aSS=anExp.Current(); + if (aSS.IsSame(aE)) { + aERight=aE; + aERight.Orientation(aSS.Orientation()); + return; + } + } + aERight=aE; + aERight.Orientation(aE.Orientation()); +} diff --git a/src/BOPTools/BOPTools_AlgoTools_1.cxx b/src/BOPTools/BOPTools_AlgoTools_1.cxx new file mode 100644 index 0000000000..9c30a8ed91 --- /dev/null +++ b/src/BOPTools/BOPTools_AlgoTools_1.cxx @@ -0,0 +1,672 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#include + +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include +#include +// +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + +static + void CheckEdge (const TopoDS_Edge& E, + const Standard_Real aMaxTol); +static + void CorrectEdgeTolerance (const TopoDS_Edge& myShape, + const TopoDS_Face& S, + const Standard_Real aMaxTol); +static + Standard_Boolean Validate(const Adaptor3d_Curve& CRef, + const Adaptor3d_Curve& Other, + const Standard_Real Tol, + const Standard_Boolean SameParameter, + Standard_Real& aNewTolerance); + +static + void CorrectVertexTolerance(const TopoDS_Edge& aE); + +static + void CorrectWires(const TopoDS_Face& aF); + +//======================================================================= +// Function : CorrectTolerances +// purpose : +//======================================================================= + void BOPTools_AlgoTools::CorrectTolerances(const TopoDS_Shape& aShape, + const Standard_Real aMaxTol) +{ + BOPTools_AlgoTools::CorrectPointOnCurve(aShape, aMaxTol); + BOPTools_AlgoTools::CorrectCurveOnSurface(aShape, aMaxTol); +} + +//======================================================================= +// Function : CorrectPointOnCurve +// purpose : +//======================================================================= + void BOPTools_AlgoTools::CorrectPointOnCurve(const TopoDS_Shape& S, + const Standard_Real aMaxTol) +{ + Standard_Integer i, aNb; + TopTools_IndexedMapOfShape Edges; + TopExp::MapShapes (S, TopAbs_EDGE, Edges); + aNb=Edges.Extent(); + for (i=1; i<=aNb; i++) { + const TopoDS_Edge& E= TopoDS::Edge(Edges(i)); + CheckEdge(E, aMaxTol); + } +} + +//======================================================================= +// Function : CorrectCurveOnSurface +// purpose : +//======================================================================= + void BOPTools_AlgoTools::CorrectCurveOnSurface(const TopoDS_Shape& S, + const Standard_Real aMaxTol) +{ + Standard_Integer i, aNbFaces, j, aNbEdges; + TopTools_IndexedMapOfShape Faces; + TopExp::MapShapes (S, TopAbs_FACE, Faces); + + aNbFaces=Faces.Extent(); + for (i=1; i<=aNbFaces; i++) { + const TopoDS_Face& F= TopoDS::Face(Faces(i)); + // + CorrectWires(F); + // + 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); + } + } +} +//modified by NIZNHY-PKV Fri May 22 10:33:12 2009f +//======================================================================= +// Function : CorrectWires +// purpose : +//======================================================================= +void CorrectWires(const TopoDS_Face& aFx) +{ + GeomAbs_SurfaceType aType; + // + const Handle(Geom_Surface)& aS=BRep_Tool::Surface(aFx); + //BRepAdaptor_Surface aBAS (aFx, Standard_False); + GeomAdaptor_Surface aGAS (aS); + aType=aGAS.GetType(); + if (aType!=GeomAbs_Cylinder) { + return; + } + // + Standard_Integer i, aNbV; + Standard_Real aTol, aTol2, aD2, aD2max, aT1, aT2, aT; + TopoDS_Edge aE1, aE2, aEi, aEj; + gp_Pnt aP, aPV; + gp_Pnt2d aP2D; + TopoDS_Face aF; + BRep_Builder aBB; + TopTools_IndexedDataMapOfShapeListOfShape aMVE; + TopTools_ListIteratorOfListOfShape aIt; + // + aF=aFx; + aF.Orientation(TopAbs_FORWARD); + // + TopExp::MapShapesAndAncestors(aF, TopAbs_VERTEX, TopAbs_EDGE, aMVE); + aNbV=aMVE.Extent(); + for (i=1; i<=aNbV; ++i) { + const TopoDS_Vertex& aV=TopoDS::Vertex(aMVE.FindKey(i)); + aPV=BRep_Tool::Pnt(aV); + aTol=BRep_Tool::Tolerance(aV); + aTol2=aTol*aTol; + // + aD2max=-1.; + const TopTools_ListOfShape& aLE=aMVE.FindFromIndex(i); + aIt.Initialize(aLE); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Edge& aE=TopoDS::Edge(aIt.Value()); + aT=BRep_Tool::Parameter(aV, aE); + const Handle(Geom2d_Curve)& aC2D=BRep_Tool::CurveOnSurface(aE, aF, aT1, aT2); + aC2D->D0(aT, aP2D); + //aP=aBAS.Value(aP2D.X(), aP2D.Y()); + aS->D0(aP2D.X(), aP2D.Y(), aP); + aD2=aPV.SquareDistance(aP); + if (aD2>aD2max) { + aD2max=aD2; + } + } + if (aD2max>aTol2) { + aTol=sqrt(aD2max); + aBB.UpdateVertex(aV, aTol); + } + } +} +//modified by NIZNHY-PKV Fri May 22 10:33:15 2009t +//======================================================================= +// Function : CorrectEdgeTolerance +// purpose : Correct tolerances for Edge +//======================================================================= +void CorrectEdgeTolerance (const TopoDS_Edge& myShape, + const TopoDS_Face& S, + const Standard_Real aMaxTol) +{ + // + // 1. Minimum of conditions to Perform + Handle (BRep_CurveRepresentation) myCref; + Handle (Adaptor3d_HCurve) myHCurve; + + myCref.Nullify(); + + Handle(BRep_TEdge)& TEx = *((Handle(BRep_TEdge)*)&myShape.TShape()); + BRep_ListIteratorOfListOfCurveRepresentation itcrx(TEx->Curves()); + Standard_Boolean Degenerated, SameParameterx, SameRangex; + + Standard_Integer unique = 0; + + Degenerated = TEx->Degenerated(); + SameParameterx = TEx->SameParameter(); + SameRangex = TEx->SameRange(); + + if (!SameRangex && SameParameterx) { + return; + } + + Handle(Geom_Curve) C3d; + while (itcrx.More()) { + const Handle(BRep_CurveRepresentation)& cr = itcrx.Value(); + if (cr->IsCurve3D()) { + unique++; + if (myCref.IsNull() && !cr->Curve3D().IsNull()) { + myCref = cr; + } + } + itcrx.Next(); + } + + if (unique==0) { + return;//...No3DCurve + } + if (unique>1) { + return;//...Multiple3DCurve; + } + + if (myCref.IsNull() && !Degenerated) { + itcrx.Initialize(TEx->Curves()); + while (itcrx.More()) { + const Handle(BRep_CurveRepresentation)& cr = itcrx.Value(); + if (cr->IsCurveOnSurface()) { + myCref = cr; + break; + } + itcrx.Next(); + } + } + + else if (!myCref.IsNull() && Degenerated){ + return ;//...InvalidDegeneratedFlag; + } + + if (!myCref.IsNull()) { + const Handle(BRep_GCurve)& GCref = *((Handle(BRep_GCurve)*)&myCref); + Standard_Real First,Last; + GCref->Range(First,Last); + if (Last<=First) { + myCref.Nullify(); + return ;//InvalidRange; + } + + else { + if (myCref->IsCurve3D()) { + Handle(Geom_Curve) C3dx = Handle(Geom_Curve)::DownCast + (myCref->Curve3D()->Transformed (myCref->Location().Transformation())); + GeomAdaptor_Curve GAC3d(C3dx, First, Last); + myHCurve = new GeomAdaptor_HCurve(GAC3d); + } + else { // curve on surface + Handle(Geom_Surface) Sref = myCref->Surface(); + Sref = Handle(Geom_Surface)::DownCast(Sref->Transformed(myCref->Location().Transformation())); + const Handle(Geom2d_Curve)& PCref = myCref->PCurve(); + Handle(GeomAdaptor_HSurface) GAHSref = new GeomAdaptor_HSurface(Sref); + Handle(Geom2dAdaptor_HCurve) GHPCref = new Geom2dAdaptor_HCurve(PCref, First, Last); + Adaptor3d_CurveOnSurface ACSref(GHPCref,GAHSref); + myHCurve = new Adaptor3d_HCurveOnSurface(ACSref); + } + } + } + + //=============================================== + // 2. Tolerances in InContext + { + if (myCref.IsNull()) + return; + Standard_Boolean ok=Standard_True;; + + Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*)&myShape.TShape()); + Standard_Real Tol = BRep_Tool::Tolerance(TopoDS::Edge(myShape)); + Standard_Real aNewTol=Tol; + + Standard_Boolean SameParameter = TE->SameParameter(); + Standard_Boolean SameRange = TE->SameRange(); + Standard_Real First = myHCurve->FirstParameter(); + Standard_Real Last = myHCurve->LastParameter(); + //modified by NIZNHY-PKV Wed May 20 10:42:50 2009f + //Standard_Real Delta =1.e-14; + Standard_Real Delta =1.e-12; + //modified by NIZNHY-PKV Wed May 20 10:42:52 2009t + + Handle(BRep_TFace)& TF = *((Handle(BRep_TFace)*) &S.TShape()); + const TopLoc_Location& Floc = S.Location(); + const TopLoc_Location& TFloc = TF->Location(); + const Handle(Geom_Surface)& Su = TF->Surface(); + TopLoc_Location L = (Floc * TFloc).Predivided(myShape.Location()); + // Standard_Boolean checkclosed = Standard_False; + Standard_Boolean pcurvefound = Standard_False; + + BRep_ListIteratorOfListOfCurveRepresentation itcr(TE->Curves()); + while (itcr.More()) { + const Handle(BRep_CurveRepresentation)& cr = itcr.Value(); + if (cr != myCref && cr->IsCurveOnSurface(Su,L)) { + pcurvefound = Standard_True; + const Handle(BRep_GCurve)& GC = *((Handle(BRep_GCurve)*)&cr); + Standard_Real f,l; + GC->Range(f,l); + if (SameRange && (f != First || l != Last)) { + return ;//BRepCheck_InvalidSameRangeFlag); + if (SameParameter) { + return; //BRepCheck_InvalidSameParameterFlag); + } + } + + Handle(Geom_Surface) Sb = cr->Surface(); + Sb = Handle(Geom_Surface)::DownCast (Su->Transformed(L.Transformation())); + Handle(Geom2d_Curve) PC = cr->PCurve(); + Handle(GeomAdaptor_HSurface) GAHS = new GeomAdaptor_HSurface(Sb); + Handle(Geom2dAdaptor_HCurve) GHPC = new Geom2dAdaptor_HCurve(PC,f,l); + Adaptor3d_CurveOnSurface ACS(GHPC,GAHS); + ok = Validate(myHCurve->Curve(), ACS, Tol, SameParameter, aNewTol); + if (ok) { + if (cr->IsCurveOnClosedSurface()) { + //return ;// BRepCheck::Add(lst,BRepCheck_InvalidCurveOnClosedSurface); + } + else { + //return;//BRepCheck::Add(lst,BRepCheck_InvalidCurveOnSurface); + } + if (SameParameter) { + //return;//BRepCheck::Add(lst,BRepCheck_InvalidSameParameterFlag); + } + // + if (aNewTolUpdateTolerance(aNewTol+Delta); + // + CorrectVertexTolerance(myShape); + } + } + + if (cr->IsCurveOnClosedSurface()) { + // checkclosed = Standard_True; + GHPC->ChangeCurve2d().Load(cr->PCurve2(),f,l); // same bounds + ACS.Load(GAHS); // sans doute inutile + ACS.Load(GHPC); // meme remarque... + ok = Validate(myHCurve->Curve(),ACS,Tol,SameParameter, aNewTol); + if (ok) { + //return;//BRepCheck::Add(lst,BRepCheck_InvalidCurveOnClosedSurface); + if (SameParameter) { + //return;//BRepCheck::Add(lst,BRepCheck_InvalidSameParameterFlag); + } + if (aNewTolUpdateTolerance(aNewTol+Delta); + CorrectVertexTolerance(myShape); + } + } + } + } + itcr.Next(); + } + + if (!pcurvefound) { + Handle(Geom_Plane) P; + Handle(Standard_Type) styp = Su->DynamicType(); + if (styp == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) { + P = Handle(Geom_Plane)::DownCast(Handle(Geom_RectangularTrimmedSurface):: + DownCast(Su)->BasisSurface()); + } + else { + P = Handle(Geom_Plane)::DownCast(Su); + } + if (P.IsNull()) { // not a plane + return;//BRepCheck::Add(lst,BRepCheck_NoCurveOnSurface); + } + + else {// on fait la projection a la volee, comme BRep_Tool + P = Handle(Geom_Plane)::DownCast(P->Transformed(L.Transformation())); + //on projette Cref sur ce plan + Handle(GeomAdaptor_HSurface) GAHS = new GeomAdaptor_HSurface(P); + + // Dub - Normalement myHCurve est une GeomAdaptor_HCurve + GeomAdaptor_Curve& Gac = Handle(GeomAdaptor_HCurve)::DownCast(myHCurve)->ChangeCurve(); + Handle(Geom_Curve) C3dx = Gac.Curve(); + Handle(Geom_Curve) ProjOnPlane = GeomProjLib::ProjectOnPlane + (new Geom_TrimmedCurve(C3dx,First,Last), P, P->Position().Direction(), Standard_True); + + Handle(GeomAdaptor_HCurve) aHCurve = new GeomAdaptor_HCurve(ProjOnPlane); + + ProjLib_ProjectedCurve proj(GAHS,aHCurve); + Handle(Geom2d_Curve) PC = Geom2dAdaptor::MakeCurve(proj); + Handle(Geom2dAdaptor_HCurve) GHPC = + new Geom2dAdaptor_HCurve(PC, myHCurve->FirstParameter(), myHCurve->LastParameter()); + + Adaptor3d_CurveOnSurface ACS(GHPC,GAHS); + + Standard_Boolean okx = Validate(myHCurve->Curve(),ACS, + Tol,Standard_True, aNewTol); // voir dub... + if (okx) { + //return;//BRepCheck::Add(lst,BRepCheck_InvalidCurveOnSurface); + if (aNewTolUpdateTolerance(aNewTol+Delta); + CorrectVertexTolerance(myShape); + } + } + } + + }//end of if (!pcurvefound) { + } // end of 2. Tolerances in InContext + +} + +//======================================================================= +//function : CorrectVertexTolerance +//purpose : +//======================================================================= +void CorrectVertexTolerance(const TopoDS_Edge& aE) +{ + Standard_Integer k, aNbV; + Standard_Real aTolE, aTolV; + TopTools_IndexedMapOfShape aVMap; + + aTolE=BRep_Tool::Tolerance(aE); + + TopExp::MapShapes(aE, TopAbs_VERTEX, aVMap); + aNbV=aVMap.Extent(); + for (k=1; k<=aNbV; ++k) { + const TopoDS_Vertex& aV=TopoDS::Vertex(aVMap(k)); + aTolV=BRep_Tool::Tolerance(aV); + if (aTolVUpdateTolerance(aTolE); + } + } +} + + + +#define NCONTROL 23 +//======================================================================= +//function : Validate +//purpose : +//======================================================================= +Standard_Boolean Validate(const Adaptor3d_Curve& CRef, + const Adaptor3d_Curve& Other, + const Standard_Real Tol, + const Standard_Boolean SameParameter, + Standard_Real& aNewTolerance) +{ + Standard_Real First, Last, MaxDistance, aD, Tol2; + + First = CRef.FirstParameter(); + Last = CRef.LastParameter(); + MaxDistance = 0.; + Tol2 = Tol*Tol; + + Standard_Integer i, aNC1=NCONTROL-1; + + Standard_Boolean aFlag=Standard_False; + Standard_Boolean proj = (!SameParameter || + First != Other.FirstParameter() || + Last != Other.LastParameter()); + // + // 1. + if (!proj) { + for (i = 0; i < NCONTROL; i++) { + Standard_Real prm = ((aNC1-i)*First + i*Last)/aNC1; + gp_Pnt pref = CRef.Value(prm); + gp_Pnt pother = Other.Value(prm); + + aD=pref.SquareDistance(pother); + + if (aD > Tol2) { + if (aD>MaxDistance) { + MaxDistance=aD; + } + aFlag=Standard_True; + } + } + + if (aFlag) { + aNewTolerance=sqrt(MaxDistance); + } + return aFlag; + } + + // + // 2. + else { + Extrema_LocateExtPC refd,otherd; + Standard_Real OFirst, OLast; + OFirst = Other.FirstParameter(); + OLast = Other.LastParameter(); + + gp_Pnt pd = CRef.Value(First); + gp_Pnt pdo = Other.Value(OFirst); + + aD = pd.SquareDistance(pdo); + if (aD > Tol2) { + if (aD>MaxDistance) { + MaxDistance=aD; + } + aFlag=Standard_True; + } + + pd = CRef.Value(Last); + pdo = Other.Value(OLast); + aD = pd.SquareDistance(pdo); + if (aD > Tol2 && aD > MaxDistance) { + MaxDistance=aD; + aFlag=Standard_True; + } + + refd.Initialize(CRef, First, Last, CRef.Resolution(Tol)); + otherd.Initialize(Other, OFirst, OLast, Other.Resolution(Tol)); + + for (i = 2; i< aNC1; i++) { + Standard_Real rprm = ((aNC1-i)*First + i*Last)/aNC1; + gp_Pnt pref = CRef.Value(rprm); + + Standard_Real oprm = ((aNC1-i)*OFirst + i*OLast)/aNC1; + gp_Pnt pother = Other.Value(oprm); + + refd.Perform(pother,rprm); + if (!refd.IsDone() || refd.SquareDistance() > Tol2) { + if (refd.IsDone()) { + aD=refd.SquareDistance(); + if (aD > Tol2 && aD>MaxDistance) { + aFlag=Standard_True; + MaxDistance=aD; + } + } + } + + otherd.Perform(pref,oprm); + if (!otherd.IsDone() || otherd.SquareDistance() > Tol2) { + + if (otherd.IsDone()) { + aD=otherd.SquareDistance(); + if (aD > Tol2 && aD>MaxDistance) { + aFlag=Standard_True; + MaxDistance=aD; + } + } + } + } + } + + aD=sqrt (MaxDistance); + aNewTolerance=aD; + + return aFlag; + +} + +//======================================================================= +// Function : CheckEdge +// purpose : Correct tolerances for Vertices on Edge +//======================================================================= +void CheckEdge (const TopoDS_Edge& Ed, const Standard_Real aMaxTol) +{ + TopoDS_Edge E=Ed; + E.Orientation(TopAbs_FORWARD); + + gp_Pnt Controlp; + + TopExp_Explorer aVExp; + aVExp.Init(E, TopAbs_VERTEX); + for (; aVExp.More(); aVExp.Next()) { + TopoDS_Vertex aVertex= TopoDS::Vertex(aVExp.Current()); + + Handle(BRep_TVertex)& TV = *((Handle(BRep_TVertex)*) &aVertex.TShape()); + const gp_Pnt& prep = TV->Pnt(); + + Standard_Real Tol, aD2, aNewTolerance, dd; + + Tol =BRep_Tool::Tolerance(aVertex); + Tol = Max(Tol, BRep_Tool::Tolerance(E)); + dd=0.1*Tol; + Tol*=Tol; + + const TopLoc_Location& Eloc = E.Location(); + BRep_ListIteratorOfListOfPointRepresentation itpr; + + Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*)&E.TShape()); + BRep_ListIteratorOfListOfCurveRepresentation itcr(TE->Curves()); + while (itcr.More()) { + const Handle(BRep_CurveRepresentation)& cr = itcr.Value(); + const TopLoc_Location& loc = cr->Location(); + TopLoc_Location L = (Eloc * loc).Predivided(aVertex.Location()); + + if (cr->IsCurve3D()) { + const Handle(Geom_Curve)& C = cr->Curve3D(); + if (!C.IsNull()) { + itpr.Initialize(TV->Points()); + while (itpr.More()) { + const Handle(BRep_PointRepresentation)& pr = itpr.Value(); + if (pr->IsPointOnCurve(C,L)) { + Controlp = C->Value(pr->Parameter()); + Controlp.Transform(L.Transformation()); + aD2=prep.SquareDistance(Controlp); + if (aD2 > Tol) { + aNewTolerance=sqrt(aD2)+dd; + if (aNewToleranceUpdateTolerance(aNewTolerance); + } + } + itpr.Next(); + } + + TopAbs_Orientation orv = aVertex.Orientation(); + if (orv == TopAbs_FORWARD || orv == TopAbs_REVERSED) { + const Handle(BRep_GCurve)& GC = *((Handle(BRep_GCurve)*)&cr); + + if (orv==TopAbs_FORWARD) + Controlp = C->Value(GC->First()); + else + Controlp = C->Value(GC->Last()); + + Controlp.Transform(L.Transformation()); + aD2=prep.SquareDistance(Controlp); + + if (aD2 > Tol) { + aNewTolerance=sqrt(aD2)+dd; + if (aNewToleranceUpdateTolerance(aNewTolerance); + } + } + } + } + itcr.Next(); + } + } +} + diff --git a/src/BOPTools/BOPTools_AlgoTools_2.cxx b/src/BOPTools/BOPTools_AlgoTools_2.cxx new file mode 100644 index 0000000000..9ba618a567 --- /dev/null +++ b/src/BOPTools/BOPTools_AlgoTools_2.cxx @@ -0,0 +1,414 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#include + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include + +#include +#include + + +//======================================================================= +// function: UpdateVertex +// purpose: +//======================================================================= + void BOPTools_AlgoTools::UpdateVertex (const TopoDS_Vertex& aVF, + const TopoDS_Vertex& aNewVertex) +{ + Standard_Real aTolVF, aTolNewVertex, aDist, aDTol=1.e-12, aNewTol; + // + gp_Pnt aPVF=BRep_Tool::Pnt(aVF); + gp_Pnt aPNewVertex=BRep_Tool::Pnt(aNewVertex); + aTolVF=BRep_Tool::Tolerance(aVF); + aTolNewVertex=BRep_Tool::Tolerance(aNewVertex); + + aDist=aPVF.Distance(aPNewVertex); + aNewTol=aDist+aTolNewVertex; + + if (aNewTol>aTolVF) { + BRep_Builder BB; + BB.UpdateVertex (aVF, aNewTol+aDTol); + } +} + +//======================================================================= +// function: UpdateVertex +// purpose: +//======================================================================= + void BOPTools_AlgoTools::UpdateVertex (const TopoDS_Edge& aE, + const Standard_Real aT, + const TopoDS_Vertex& aV) +{ + Standard_Real aTolV, aDist, aDTol=1.e-12, aFirst, aLast; + gp_Pnt aPc; + + gp_Pnt aPv=BRep_Tool::Pnt(aV); + aTolV=BRep_Tool::Tolerance(aV); + + Handle(Geom_Curve) aC3D=BRep_Tool::Curve(aE, aFirst, aLast); + aC3D->D0(aT, aPc); + aDist=aPv.Distance(aPc); + if (aDist>aTolV) { + BRep_Builder BB; + BB.UpdateVertex (aV, aDist+aDTol); + } +} +// +//======================================================================= +// function: UpdateVertex +// purpose: +//======================================================================= + void BOPTools_AlgoTools::UpdateVertex (const IntTools_Curve& aC, + const Standard_Real aT, + const TopoDS_Vertex& aV) +{ + Standard_Real aTolV, aDist, aDTol=1.e-12; + gp_Pnt aPc; + + gp_Pnt aPv=BRep_Tool::Pnt(aV); + aTolV=BRep_Tool::Tolerance(aV); + + Handle(Geom_Curve) aC3D=aC.Curve(); + aC3D->D0(aT, aPc); + aDist=aPv.Distance(aPc); + if (aDist>aTolV) { + BRep_Builder BB; + BB.UpdateVertex (aV, aDist+aDTol); + } +} +//======================================================================= +// function: MakeSectEdge +// purpose: +//======================================================================= + void BOPTools_AlgoTools::MakeSectEdge(const IntTools_Curve& aIC, + const TopoDS_Vertex& aV1, + const Standard_Real aP1, + const TopoDS_Vertex& aV2, + const Standard_Real aP2, + TopoDS_Edge& aNewEdge) +{ + Handle(Geom_Curve) aC=aIC.Curve (); + + BRepBuilderAPI_MakeEdge aMakeEdge(aC, aV1, aV2, aP1, aP2); + + const TopoDS_Edge& aE=TopoDS::Edge(aMakeEdge.Shape()); + // + // Range must be as it was ! + BRep_Builder aBB; + aBB.Range (aE, aP1, aP2); + // + aNewEdge=aE; + +} + +//======================================================================= +// function: MakeSplitEdge +// purpose: +//======================================================================= + void BOPTools_AlgoTools::MakeSplitEdge(const TopoDS_Edge& aE, + const TopoDS_Vertex& aV1, + const Standard_Real aP1, + const TopoDS_Vertex& aV2, + const Standard_Real aP2, + TopoDS_Edge& aNewEdge) +{ + Standard_Real f, l, aTol; + Handle(Geom_Curve) aC=BRep_Tool::Curve (aE, f, l); + aTol=BRep_Tool::Tolerance(aE); + // + // MakeEdge is used for chechking all input data only + BRepBuilderAPI_MakeEdge aMakeEdge(aC, aV1, aV2, aP1, aP2); + //ZZ const TopoDS_Edge& E1=TopoDS::Edge(aMakeEdge.Shape()); + TopoDS_Edge E=aE; + E.EmptyCopy(); + + BRep_Builder BB; + BB.Add (E, aV1); + BB.Add (E, aV2); + BB.Range(E, aP1, aP2); + BB.UpdateEdge(E, aTol); + aNewEdge=E; +} + +//======================================================================= +// function: MakeNewVertex +// purpose: +//======================================================================= + void BOPTools_AlgoTools::MakeNewVertex(const TopoDS_Vertex& aV1, + const TopoDS_Vertex& aV2, + TopoDS_Vertex& aNewVertex) +{ + gp_Pnt aPnt1=BRep_Tool::Pnt(aV1); + Standard_Real aTol1=BRep_Tool::Tolerance(aV1); + + gp_Pnt aPnt2=BRep_Tool::Pnt(aV2); + Standard_Real aTol2=BRep_Tool::Tolerance(aV2); + + Standard_Real aMaxTol, aDist; + + aDist=aPnt1.Distance(aPnt2); + aMaxTol=(aTol1>aTol2)? aTol1 : aTol2; + aMaxTol=aMaxTol+0.5*aDist; + + const gp_XYZ& aXYZ1=aPnt1.XYZ(); + const gp_XYZ& aXYZ2=aPnt2.XYZ(); + gp_XYZ aNewXYZ=0.5*(aXYZ1+aXYZ2); + + gp_Pnt aNewPnt(aNewXYZ); + BRep_Builder aBB; + aBB.MakeVertex (aNewVertex, aNewPnt, aMaxTol); +} + //======================================================================= +// function: MakeNewVertex +// purpose: +//======================================================================= + void BOPTools_AlgoTools::MakeNewVertex(const gp_Pnt& aP, + const Standard_Real aTol, + TopoDS_Vertex& aNewVertex) +{ + BRep_Builder aBB; + aBB.MakeVertex (aNewVertex, aP, aTol); +} + +//======================================================================= +// function: MakeNewVertex +// purpose: +//======================================================================= + void BOPTools_AlgoTools::MakeNewVertex(const TopoDS_Edge& aE1, + const Standard_Real aParm1, + const TopoDS_Edge& aE2, + const Standard_Real aParm2, + TopoDS_Vertex& aNewVertex) +{ + Standard_Real aTol1, aTol2, aMaxTol, aDist; + gp_Pnt aPnt1, aPnt2; + + PointOnEdge (aE1, aParm1, aPnt1); + PointOnEdge (aE2, aParm2, aPnt2); + + aTol1=BRep_Tool::Tolerance(aE1); + aTol2=BRep_Tool::Tolerance(aE2); + + aDist=aPnt1.Distance(aPnt2); + aMaxTol=(aTol1>aTol2)? aTol1 : aTol2; + aMaxTol=aMaxTol+0.5*aDist; + + const gp_XYZ& aXYZ1=aPnt1.XYZ(); + const gp_XYZ& aXYZ2=aPnt2.XYZ(); + gp_XYZ aNewXYZ=0.5*(aXYZ1+aXYZ2); + + gp_Pnt aNewPnt(aNewXYZ); + BRep_Builder aBB; + aBB.MakeVertex (aNewVertex, aNewPnt, aMaxTol); +} +//======================================================================= +// function: MakeNewVertex +// purpose: +//======================================================================= + void BOPTools_AlgoTools::MakeNewVertex(const TopoDS_Edge& aE1, + const Standard_Real aParm1, + const TopoDS_Face& aF1, + TopoDS_Vertex& aNewVertex) +{ + Standard_Real aTol1, aTol2, aMaxTol, delta=1.e-12; + gp_Pnt aPnt; + + PointOnEdge (aE1, aParm1, aPnt); + + aTol1=BRep_Tool::Tolerance(aE1); + aTol2=BRep_Tool::Tolerance(aF1); + // + //aMaxTol=(aTol1>aTol2)? aTol1 : aTol2; + aMaxTol=aTol1+aTol2+delta; + // + BRep_Builder aBB; + aBB.MakeVertex (aNewVertex, aPnt, aMaxTol); +} + +//======================================================================= +// function: PointOnEdge +// purpose: +//======================================================================= + void BOPTools_AlgoTools::PointOnEdge(const TopoDS_Edge& aE, + const Standard_Real aParm, + gp_Pnt& aPnt) +{ + Standard_Real f, l; + Handle(Geom_Curve) C1=BRep_Tool::Curve(aE, f, l); + C1->D0(aParm, aPnt); +} + +//======================================================================= +//function : CorrectRange +//purpose : +//======================================================================= + void BOPTools_AlgoTools::CorrectRange(const TopoDS_Edge& aE1, + const TopoDS_Edge& aE2, + const IntTools_Range& aSR, + IntTools_Range& aNewSR) +{ + Standard_Integer i; + Standard_Real aRes, aTolE1, aTolE2, aTF, aTL, dT; + BRepAdaptor_Curve aBC; + GeomAbs_CurveType aCT; + gp_Pnt aP; + gp_Vec aDer; + // + aNewSR=aSR; + // + //modified by NIZNHY-PKV Tue Feb 10 08:47:03 2009f + aBC.Initialize(aE1); + aCT=aBC.GetType(); + if (aCT==GeomAbs_Line) { + return; + } + //modified by NIZNHY-PKV Tue Feb 10 08:47:06 2009t + // + dT=Precision::PConfusion(); + aTF=aSR.First(); + aTL=aSR.Last(); + // + //modified by NIZNHY-PKV Tue Feb 10 08:47:39 2009f + /* + aBC.Initialize(aE1); + aCT=aBC.GetType(); + */ + //modified by NIZNHY-PKV Tue Feb 10 08:47:43 2009t + // + aTolE1=BRep_Tool::Tolerance(aE1); + aTolE2=BRep_Tool::Tolerance(aE2); + // + for(i=0; i<2; ++i) { + aRes = 2.*(aTolE1 + aTolE2); + // + if (aCT==GeomAbs_BezierCurve || + aCT==GeomAbs_BSplineCurve|| + aCT==GeomAbs_OtherCurve) { + + if(!i){ + aBC.D1 (aTF, aP, aDer); + } + else { + aBC.D1 (aTL, aP, aDer); + } + // + Standard_Real aMgn = aDer.Magnitude(); + + if(aMgn > 1.e-12) { + aRes = aRes/aMgn ; + } + else { + aRes = aBC.Resolution(aRes); + } + } // if (aCT==GeomAbs_BezierCurve||... + else { + aRes = aBC.Resolution(aRes); + } + // + if(!i) { + aNewSR.SetFirst (aTF+aRes); + } + else { + aNewSR.SetLast (aTL-aRes); + } + // + if ((aNewSR.Last()-aNewSR.First()) < dT) { + aNewSR=aSR; + } + //aNewSR=((aNewSR.Last()-aNewSR.First()) < dT) ? aSR : aNewSR; + } +} + +//======================================================================= +//function : CorrectRange +//purpose : +//======================================================================= + void BOPTools_AlgoTools::CorrectRange(const TopoDS_Edge& aE, + const TopoDS_Face& aF, + const IntTools_Range& aSR, + IntTools_Range& aNewSR) +{ + Standard_Integer i; + Standard_Real aRes, aTolF, aTF, aTL, dT; + BRepAdaptor_Curve aBC; + GeomAbs_CurveType aCT; + gp_Pnt aP; + gp_Vec aDer; + // + aNewSR=aSR; + // + dT=Precision::PConfusion(); + aTF=aSR.First(); + aTL=aSR.Last(); + // + aBC.Initialize(aE); + aCT=aBC.GetType(); + // + aTolF=BRep_Tool::Tolerance(aF); + // + for(i=0; i<2; ++i) { + aRes =aTolF; + + if (aCT==GeomAbs_BezierCurve || + aCT==GeomAbs_BSplineCurve|| + aCT==GeomAbs_OtherCurve) { + + if(!i){ + aBC.D1 (aTF, aP, aDer); + } + else { + aBC.D1 (aTL, aP, aDer); + } + // + Standard_Real aMgn = aDer.Magnitude(); + + if(aMgn > 1.e-12) { + aRes = aRes/aMgn ; + } + else { + aRes = aBC.Resolution(aRes); + } + } // if (aCT==GeomAbs_BezierCurve||... + else { + aRes = aBC.Resolution(aRes); + } + // + if(!i) { + aNewSR.SetFirst (aTF+aRes); + } + else { + aNewSR.SetLast (aTL-aRes); + } + // + if ((aNewSR.Last()-aNewSR.First()) < dT) { + aNewSR=aSR; + } + } +} diff --git a/src/BOPTools/BOPTools_CheckResult.cdl b/src/BOPTools/BOPTools_CheckResult.cdl deleted file mode 100755 index 6ddbbe1aca..0000000000 --- a/src/BOPTools/BOPTools_CheckResult.cdl +++ /dev/null @@ -1,66 +0,0 @@ --- Created on: 2004-09-02 --- Created by: Oleg FEDYAEV --- Copyright (c) 2004-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class CheckResult from BOPTools - ---Purpose: contains information about faulty shapes - -- and faulty types -uses - - Shape from TopoDS, - ListOfShape from TopTools, - CheckStatus from BOPTools, - Geometry from Geom - -is - - Create - returns CheckResult; - ---Purpose: empty constructor - - AddShape(me: in out; TheShape: Shape from TopoDS); - ---Purpose: adds a shape with faulty to a list - - GetShapes(me) - returns ListOfShape from TopTools; - ---C++: return const & - ---Purpose: gets access to faulty shapes in a list const - - SetCheckStatus(me:in out; TheStatus: CheckStatus from BOPTools); - ---Purpose: sets faulty status for shapes - - GetCheckStatus(me) - returns CheckStatus from BOPTools; - ---Purpose: gets faulty status for shapes - - SetInterferenceGeometry(me: in out; TheGeometry: Geometry from Geom); - ---Purpose: sets an attached geometry to faulty shapes if any - - GetInterferenceGeometry(me) - returns Geometry from Geom; - ---C++: return const & - ---Purpose: gets an attached geometry to shapes if any - -fields - - myStatus : CheckStatus from BOPTools; - myShapes : ListOfShape from TopTools; - myGeometry : Geometry from Geom; - -end CheckResult; diff --git a/src/BOPTools/BOPTools_CheckResult.cxx b/src/BOPTools/BOPTools_CheckResult.cxx deleted file mode 100755 index 9792a72792..0000000000 --- a/src/BOPTools/BOPTools_CheckResult.cxx +++ /dev/null @@ -1,90 +0,0 @@ -// Created on: 2004-09-02 -// Created by: Oleg FEDYAEV -// Copyright (c) 2004-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#include - -//======================================================================= -//function : BOPTools_CheckResult() -//purpose : -//======================================================================= - -BOPTools_CheckResult::BOPTools_CheckResult() : myStatus(BOPTools_CHKUNKNOWN), myGeometry(0) -{ -} - -//======================================================================= -//function : AddShape() -//purpose : -//======================================================================= - -void BOPTools_CheckResult::AddShape(const TopoDS_Shape & TheShape) -{ - myShapes.Append(TheShape); -} - -//======================================================================= -//function : GetShapes() -//purpose : -//======================================================================= - -const TopTools_ListOfShape & BOPTools_CheckResult::GetShapes() const -{ - return myShapes; -} - -//======================================================================= -//function : SetCheckStatus() -//purpose : -//======================================================================= - -void BOPTools_CheckResult::SetCheckStatus(const BOPTools_CheckStatus TheStatus) -{ - myStatus = TheStatus; -} - -//======================================================================= -//function : GetCheckStatus() -//purpose : -//======================================================================= - -BOPTools_CheckStatus BOPTools_CheckResult::GetCheckStatus() const -{ - return myStatus; -} - -//======================================================================= -//function : SetGeometry() -//purpose : -//======================================================================= - -void BOPTools_CheckResult::SetInterferenceGeometry(const Handle(Geom_Geometry)& TheGeometry) -{ - myGeometry = TheGeometry; -} - -//======================================================================= -//function : GetGeometry() -//purpose : -//======================================================================= - -const Handle(Geom_Geometry)& BOPTools_CheckResult::GetInterferenceGeometry() const -{ - return myGeometry; -} diff --git a/src/BOPTools/BOPTools_Checker.cdl b/src/BOPTools/BOPTools_Checker.cdl deleted file mode 100755 index fd9cdf9e2a..0000000000 --- a/src/BOPTools/BOPTools_Checker.cdl +++ /dev/null @@ -1,145 +0,0 @@ --- Created on: 2002-08-05 --- Created by: Peter KURNEV --- Copyright (c) 2002-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class Checker from BOPTools inherits PaveFiller from BOPTools - - ---Purpose: - -- class that provides the algorithm - -- to check a shape on self-interference. - - -uses - ListOfCheckResults from BOPTools, - InterferencePool from BOPTools, - Shape from TopoDS, - ShapeEnum from TopAbs, - Geometry from Geom - -is - Create - returns Checker from BOPTools; - ---Purpose: - --- Empty Contructor - --- - Create (aS:Shape from TopoDS) - returns Checker from BOPTools; - ---Purpose: - --- Contructs the object using the shape to check - --- - Create (aIP: InterferencePool from BOPTools) - returns Checker from BOPTools; - ---Purpose: - --- Contructs the object using the - --- - Destroy (me:out) - is redefined; - ---C++: alias "Standard_EXPORT virtual ~BOPTools_Checker(){Destroy();}" - ---Purpose: - --- Destructor - --- - - SetPerformType(me: in out; StopOnFirstFaulty: Boolean from Standard); - ---Purpose: if the process stops - -- and the exception throws; otherwise all faulties are searched - - Perform (me:out) - is redefined; - ---Purpose: - --- Launches the algorithm - --- - SetShape(me:out; - aS:Shape from TopoDS); - ---Purpose: - --- Selector - --- - Shape(me) - returns Shape from TopoDS; - ---C++:return const & - ---Purpose: - --- Selector - --- - - GetCheckResult(me) - returns ListOfCheckResults from BOPTools; - ---C++: return const & - ---Purpose: returnes a result of check - - HasFaulty(me) - returns Boolean from Standard; - ---Purpose: - --- Selector. - --- Retrns TRUE if there is interferred sub-shapes . - --- - PerformVV (me:out) - is redefined protected ; - ---Purpose: - --- See in base classe, please - --- - PerformVE (me:out) - is redefined protected ; - ---Purpose: - --- See in base classe, please - --- - PerformVF (me:out) - is redefined protected ; - ---Purpose: - --- See in base classe, please - --- - PerformEE (me:out) - is redefined protected ; - ---Purpose: - --- See in base classe, please - --- - PerformEF (me:out) - is redefined protected ; - ---Purpose: - --- See in base classe, please - --- - PerformFF (me:out) - is redefined protected ; - ---Purpose: - --- See in base classe, please - --- - PrepareEdges (me:out) - is redefined protected ; - ---Purpose: - --- Prepare end paves for each edge - --- - PreparePaveBlocks (me:out; - aType1: ShapeEnum from TopAbs; - aType2: ShapeEnum from TopAbs) - is redefined protected ; - ---Purpose: - --- Internal usage - --- - PreparePaveBlocks (me:out; - anE:Integer from Standard) - is redefined protected ; - ---Purpose: - --- Prepare end paves for the edge - --- -fields - myShape : Shape from TopoDS; - myCheckResults : ListOfCheckResults from BOPTools; - myStopOnFirst : Boolean from Standard; - myEntryType : Integer from Standard; - -end Checker; diff --git a/src/BOPTools/BOPTools_Checker.cxx b/src/BOPTools/BOPTools_Checker.cxx deleted file mode 100755 index 2a9ae48e20..0000000000 --- a/src/BOPTools/BOPTools_Checker.cxx +++ /dev/null @@ -1,1103 +0,0 @@ -// Created on: 2002-08-05 -// Created by: Peter KURNEV -// Copyright (c) 2002-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include - -#include -#include - -#include - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include - -#include - -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -// modified by NIZHNY-MKK Fri Sep 3 16:00:15 2004.BEGIN -#include -// modified by NIZHNY-MKK Fri Sep 3 16:00:18 2004.END - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -//======================================================================= -// function: BOPTools_Checker::BOPTools_Checker -// purpose: -//======================================================================= -BOPTools_Checker::BOPTools_Checker() : BOPTools_PaveFiller() -{ - myEntryType=1; - myStopOnFirst = Standard_False; -} -//======================================================================= -// function: BOPTools_Checker::BOPTools_Checker -// purpose: -//======================================================================= -BOPTools_Checker::BOPTools_Checker(const TopoDS_Shape& aS) : BOPTools_PaveFiller() -{ - myEntryType=1; - myStopOnFirst = Standard_False; - SetShape(aS); -} -//======================================================================= -// function: BOPTools_Checker::BOPTools_Checker -// purpose: -//======================================================================= -BOPTools_Checker::BOPTools_Checker(const BOPTools_InterferencePool& aPool) : BOPTools_PaveFiller(aPool) -{ - myStopOnFirst = Standard_False; - myEntryType=0; - myIsDone=Standard_False; - void* p=(void*) &aPool; - myIntrPool=(BOPTools_InterferencePool*) p; - myDS=myIntrPool->DS(); - myNbSources=myDS->NumberOfShapesOfTheObject()+myDS->NumberOfShapesOfTheTool(); - myNbEdges=myDS->NbEdges(); -} - -//======================================================================= -// function: SetShape -// purpose: -//======================================================================= -void BOPTools_Checker::SetShape(const TopoDS_Shape& aS) -{ - myShape=aS; - - Destroy(); - myDS = new BooleanOperations_ShapesDataStructure (aS, aS); - - myIntrPool = new BOPTools_InterferencePool (*myDS); - - myNbSources=myDS->NumberOfShapesOfTheObject()+myDS->NumberOfShapesOfTheTool(); - myNbEdges=myDS->NbEdges(); -} - -//======================================================================= -// function: Destroy -// purpose: -//======================================================================= -void BOPTools_Checker::Destroy() -{ - if (myEntryType) { - // - if (myIntrPool!=NULL) { - delete myIntrPool; myIntrPool = NULL; - } - if (myDS!=NULL) { - delete myDS; myDS = NULL; - } - } - myCheckResults.Clear(); -} - -//======================================================================= -// function: SetPerformType -// purpose: -//======================================================================= - -void BOPTools_Checker::SetPerformType(const Standard_Boolean StopOnFirstFaulty) -{ - myStopOnFirst = StopOnFirstFaulty; -} - -//======================================================================= -// function: Perform -// purpose: -//======================================================================= -void BOPTools_Checker::Perform() -{ - myCheckResults.Clear(); - try { - // - if (myContext.IsNull()) { - myContext=new IntTools_Context; - } - // - // 0. Prepare the IteratorOfCoupleOfShape - myDSIt.SetDataStructure(myDS); - // - // 1.VV - PerformVV(); - // - // 2.VE - myPavePool.Resize (myNbEdges); - PrepareEdges(); - PerformVE(); - // - // 3.VF - PerformVF(); - // - // 4.EE - myCommonBlockPool.Resize (myNbEdges); - mySplitShapesPool.Resize (myNbEdges); - myPavePoolNew .Resize (myNbEdges); - - PreparePaveBlocks(TopAbs_VERTEX, TopAbs_EDGE); - PreparePaveBlocks(TopAbs_EDGE, TopAbs_EDGE); - - PerformEE(); - // - // 5.EF - PreparePaveBlocks(TopAbs_EDGE, TopAbs_FACE); - - PerformEF(); - // - // 6. FF - PerformFF (); - }// end of try block - // - catch (BOPTColStd_Failure& x) { - cout << x.Message() << endl << flush; - } -} -//======================================================================= -// function: PerformVV -// purpose: -//======================================================================= -void BOPTools_Checker::PerformVV() -{ - myIsDone=Standard_False; - Standard_Boolean bJustAddInterference; - Standard_Integer n1, n2, aFlag; - // - // V/V BooleanOperations_VertexVertex - myDSIt.Initialize(TopAbs_VERTEX, TopAbs_VERTEX); - // - for (; myDSIt.More(); myDSIt.Next()) { - bJustAddInterference = Standard_False; - myDSIt.Current(n1, n2, bJustAddInterference); - // - const TopoDS_Shape& aS1=myDS->Shape(n1); - const TopoDS_Shape& aS2=myDS->Shape(n2); - // - if (aS1.IsSame(aS2)){ - continue; - } - // - if(bJustAddInterference) { - continue; - } - // - const TopoDS_Vertex& aV1=TopoDS::Vertex(aS1); - const TopoDS_Vertex& aV2=TopoDS::Vertex(aS2); - - aFlag=IntTools_Tools::ComputeVV (aV1, aV2); - - if (!aFlag) { - char buf[512]; - sprintf (buf, "VV: (%d, %d)", n1, n2); - - BOPTools_CheckResult aChRes; - aChRes.AddShape(aV1); - aChRes.AddShape(aV2); - aChRes.SetCheckStatus(BOPTools_VERTEXVERTEX); - myCheckResults.Append(aChRes); - - if(myStopOnFirst) - throw BOPTColStd_Failure(buf) ; - } - } - myIsDone=Standard_True; -} - -//======================================================================= -// function: PerformVE -// purpose: -//======================================================================= -void BOPTools_Checker::PerformVE() -{ - myIsDone=Standard_False; - Standard_Boolean bSameFlag, bJustAddInterference; - Standard_Integer n1, n2, aFlag, aWhat, aWith; - Standard_Real aT; - // - // V/E Interferences [BooleanOperations_VertexEdge] - myDSIt.Initialize (TopAbs_VERTEX, TopAbs_EDGE); - // - for (; myDSIt.More(); myDSIt.Next()) { - bJustAddInterference = Standard_False; - myDSIt.Current(n1, n2, bJustAddInterference); - // - aWhat=n1; // Vertex - aWith=n2; // Edge - - SortTypes(aWhat, aWith); - - const TopoDS_Shape& aS1=myDS->Shape(aWhat); - const TopoDS_Shape& aS2=myDS->Shape(aWith); - - const TopoDS_Vertex& aV1=TopoDS::Vertex(aS1); - const TopoDS_Edge& aE2=TopoDS::Edge (aS2); - - if (BRep_Tool::Degenerated(aE2)){ - continue; - } - // - TopTools_IndexedMapOfShape aM2; - // - bSameFlag=Standard_False; - // - BOPTools_Tools::MapShapes(aE2, aM2); - // - if (aM2.Contains(aV1)) { - bSameFlag=Standard_True; - } - // - if (bSameFlag){ - continue; - } - // - aFlag=myContext->ComputeVE (aV1, aE2, aT); - // - if (!aFlag) { - char buf[512]; - sprintf (buf, "VE: (%d, %d)", aWhat, aWith); - - BOPTools_CheckResult aChRes; - aChRes.AddShape(aV1); - aChRes.AddShape(aE2); - aChRes.SetCheckStatus(BOPTools_VERTEXEDGE); - myCheckResults.Append(aChRes); - // - if(myStopOnFirst) - throw BOPTColStd_Failure(buf) ; - } - } - myIsDone=Standard_True; -} - -//======================================================================= -// function: PerformVF -// purpose: -//======================================================================= -void BOPTools_Checker::PerformVF() -{ - myIsDone=Standard_False; - Standard_Boolean justaddinterference, bSameFlag; - Standard_Integer n1, n2, aFlag, aWhat, aWith; - Standard_Real aU, aV; - // - // V/V BooleanOperations_VertexFace - myDSIt.Initialize(TopAbs_VERTEX, TopAbs_FACE); - // - for (; myDSIt.More(); myDSIt.Next()) { - justaddinterference = Standard_False; - myDSIt.Current(n1, n2, justaddinterference); - // - aWhat=n1; // Vertex - aWith=n2; // Face - SortTypes(aWhat, aWith); - - const TopoDS_Shape& aS1=myDS->Shape(aWhat); - const TopoDS_Shape& aS2=myDS->Shape(aWith); - - const TopoDS_Vertex& aV1=TopoDS::Vertex(aS1); - const TopoDS_Face& aF2=TopoDS::Face (aS2); - // - TopTools_IndexedMapOfShape aM2; - // - bSameFlag=Standard_False; - // - BOPTools_Tools::MapShapes(aF2, aM2); - // - if (aM2.Contains(aV1)) { - bSameFlag=Standard_True; - } - // - if (bSameFlag){ - continue; - } - // - aFlag=myContext->ComputeVS (aV1, aF2, aU, aV); - // - if (!aFlag) { - char buf[512]; - sprintf (buf, "VF: (%d, %d)", aWhat, aWith); - - BOPTools_CheckResult aChRes; - aChRes.AddShape(aV1); - aChRes.AddShape(aF2); - aChRes.SetCheckStatus(BOPTools_VERTEXFACE); - myCheckResults.Append(aChRes); - - if(myStopOnFirst) - throw BOPTColStd_Failure(buf) ; - } - } - myIsDone=Standard_True; -} - -//======================================================================= -// function: PerformEE -// purpose: -//======================================================================= -void BOPTools_Checker::PerformEE() -{ - myIsDone=Standard_False; - - Standard_Boolean justaddinterference; - Standard_Integer n1, n2, anIndexIn=0, nE1, nE2; - Standard_Integer aTmp, aWhat, aWith; - Standard_Integer i, aNbCPrts; - // - // E/E Interferences [BooleanOperations_EdgeEdge] - myDSIt.Initialize(TopAbs_EDGE, TopAbs_EDGE); - // - for (; myDSIt.More(); myDSIt.Next()) { - justaddinterference = Standard_False; - myDSIt.Current(n1, n2, justaddinterference); - // - nE1=n1; - nE2=n2; - SortTypes(nE1, nE2); - // - Standard_Real aTolE1, aTolE2, aDeflection=0.01; - Standard_Integer aDiscretize=30; - - const TopoDS_Edge& aE1=TopoDS::Edge(myDS->GetShape(nE1)); - const TopoDS_Edge& aE2=TopoDS::Edge(myDS->GetShape(nE2)); - // - if (BRep_Tool::Degenerated(aE1)){ - continue; - } - if (BRep_Tool::Degenerated(aE2)){ - continue; - } - // - // - Standard_Boolean bSameFlag; - TopTools_IndexedMapOfShape aM1, aM2; - // - bSameFlag=aE1.IsSame(aE2); - // - if (bSameFlag){ - continue; - } - // - aTolE1=BRep_Tool::Tolerance(aE1); - aTolE2=BRep_Tool::Tolerance(aE2); - // - BOPTools_ListOfPaveBlock& aLPB1=mySplitShapesPool(myDS->RefEdge(nE1)); - BOPTools_ListIteratorOfListOfPaveBlock anIt1(aLPB1); - - for (; anIt1.More(); anIt1.Next()) { - BOPTools_PaveBlock& aPB1=anIt1.Value(); - const IntTools_ShrunkRange& aShrunkRange1=aPB1.ShrunkRange(); - - const IntTools_Range& aSR1=aShrunkRange1.ShrunkRange(); - const Bnd_Box& aBB1=aShrunkRange1.BndBox(); - - BOPTools_ListOfPaveBlock& aLPB2=mySplitShapesPool(myDS->RefEdge(nE2)); - BOPTools_ListIteratorOfListOfPaveBlock anIt2(aLPB2); - - for (; anIt2.More(); anIt2.Next()) { - BOPTools_PaveBlock& aPB2=anIt2.Value(); - const IntTools_ShrunkRange& aShrunkRange2=aPB2.ShrunkRange(); - - const IntTools_Range& aSR2=aShrunkRange2.ShrunkRange(); - const Bnd_Box& aBB2=aShrunkRange2.BndBox(); - - ////////////////////////////////////////////// - if (aBB1.IsOut (aBB2)) { - continue; - } - // - // EE - IntTools_EdgeEdge aEE; - aEE.SetEdge1 (aE1); - aEE.SetEdge2 (aE2); - aEE.SetTolerance1 (aTolE1); - aEE.SetTolerance2 (aTolE2); - aEE.SetDiscretize (aDiscretize); - aEE.SetDeflection (aDeflection); - // - IntTools_Range anewSR1 = aSR1; - IntTools_Range anewSR2 = aSR2; - // - BOPTools_Tools::CorrectRange (aE1, aE2, aSR1, anewSR1); - BOPTools_Tools::CorrectRange (aE2, aE1, aSR2, anewSR2); - // - aEE.SetRange1(anewSR1); - aEE.SetRange2(anewSR2); - - aEE.Perform(); - // - anIndexIn=0; - // - if (aEE.IsDone()) { - // - // reverse order if it is necessary - TopoDS_Edge aEWhat, aEWith; - aEWhat=aE1; - aEWith=aE2; - aWhat=nE1; - aWith=nE2; - if (aEE.Order()) { - aTmp=aWhat; - aWhat=aWith; - aWith=aTmp; - aEWhat=aE2; - aEWith=aE1; - } - // - const IntTools_SequenceOfCommonPrts& aCPrts=aEE.CommonParts(); - - aNbCPrts=aCPrts.Length(); - for (i=1; i<=aNbCPrts; i++) { - const IntTools_CommonPrt& aCPart=aCPrts(i); - // - anIndexIn=0; - // - TopAbs_ShapeEnum aType=aCPart.Type(); - switch (aType) { - - case TopAbs_VERTEX: { - - Standard_Real aT1, aT2; - - const IntTools_Range& aR1=aCPart.Range1(); - aT1=0.5*(aR1.First()+aR1.Last()); - - if((aCPart.VertexParameter1() >= aR1.First()) && - (aCPart.VertexParameter1() <= aR1.Last())) { - aT1 = aCPart.VertexParameter1(); - } - - const IntTools_SequenceOfRanges& aRanges2=aCPart.Ranges2(); - const IntTools_Range& aR2=aRanges2(1); - aT2=0.5*(aR2.First()+aR2.Last()); - - if((aCPart.VertexParameter2() >= aR2.First()) && - (aCPart.VertexParameter2() <= aR2.Last())) { - aT2 = aCPart.VertexParameter2(); - } - // - char buf[512]; - sprintf (buf, "EE: (%d, %d), vertex at t1=%f, t2=%f", aWhat, aWith, aT1, aT2); - // - gp_Pnt aPnt; - BOPTools_Tools::PointOnEdge(aEWhat, aT1, aPnt); - Handle (Geom_CartesianPoint) aCPnt= new Geom_CartesianPoint(aPnt); -// myInerference=aCPnt; - - BOPTools_CheckResult aChRes; - aChRes.AddShape(aE1); - aChRes.AddShape(aE2); - aChRes.SetCheckStatus(BOPTools_EDGEEDGE); -// modified by NIZHNY-MKK Fri Sep 3 16:01:52 2004 -// aChRes.SetInterferenceGeometry(myInerference); - aChRes.SetInterferenceGeometry(aCPnt); - myCheckResults.Append(aChRes); - - if(myStopOnFirst) - throw BOPTColStd_Failure(buf) ; - // - } - break; - - case TopAbs_EDGE: { - - const IntTools_SequenceOfRanges& aRanges2=aCPart.Ranges2(); - Standard_Integer aNbComPrt2=aRanges2.Length(); - - if (aNbComPrt2>1) { - break; - } - - Standard_Boolean aCoinsideFlag; - - aCoinsideFlag=IsBlocksCoinside(aPB1, aPB2); - // - if (!aCoinsideFlag) { - break; - } - // - char buf[512]; - sprintf (buf, "EE: (%d, %d), common block ", aWhat, aWith); - - BOPTools_CheckResult aChRes; - aChRes.AddShape(aE1); - aChRes.AddShape(aE2); - aChRes.SetCheckStatus(BOPTools_EDGEEDGECOMBLK); - myCheckResults.Append(aChRes); - - if(myStopOnFirst) - throw BOPTColStd_Failure(buf) ; - // - } - break; - - default: - break; - } // switch (aType) - } // for (i=1; i<=aNbCPrts; i++) - }// if (aEE.IsDone()) - - ////////////////////////////////////////////// - } // for (; anIt2.More(); anIt2.Next()) - } // for (; anIt1.More(); anIt1.Next()) - }// for (; myDSIt.More(); myDSIt.Next()) - myIsDone=Standard_True; -} - -//======================================================================= -// function: PerformEF -// purpose: -//======================================================================= -void BOPTools_Checker::PerformEF() -{ - myIsDone=Standard_False; - // - Standard_Boolean justaddinterference, bSameFlag; - Standard_Integer n1, n2, nE, nF, i, aNbCPrts; - // - // E/F Interferences [BooleanOperations_EdgeFace] - myDSIt.Initialize(TopAbs_EDGE, TopAbs_FACE); - // - for (; myDSIt.More(); myDSIt.Next()) { - justaddinterference = Standard_True; - myDSIt.Current(n1, n2, justaddinterference); - // - nE=n1; - nF=n2; - SortTypes(nE, nF); - // - Standard_Real aTolE, aTolF, aDeflection=0.01; - Standard_Integer aDiscretize=35; - - const TopoDS_Edge& aE=TopoDS::Edge(myDS->GetShape(nE)); - const TopoDS_Face& aF=TopoDS::Face(myDS->GetShape(nF)); - // - if (BRep_Tool::Degenerated(aE)){ - continue; - } - // - TopTools_IndexedMapOfShape aMF; - // - bSameFlag=Standard_False; - // - TopExp::MapShapes(aF, TopAbs_EDGE, aMF); - if (aMF.Contains(aE)) { - bSameFlag=Standard_True; - } - // - if (bSameFlag){ - continue; - } - // - aTolE=BRep_Tool::Tolerance(aE); - aTolF=BRep_Tool::Tolerance(aF); - // - const Bnd_Box& aBBF=myDS->GetBoundingBox(nF); - // - BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(nE)); - BOPTools_ListIteratorOfListOfPaveBlock anIt(aLPB); - - for (; anIt.More(); anIt.Next()) { - BOPTools_PaveBlock& aPB=anIt.Value(); - const IntTools_ShrunkRange& aShrunkRange=aPB.ShrunkRange(); - const IntTools_Range& aSR =aShrunkRange.ShrunkRange(); - const Bnd_Box& aBBE=aShrunkRange.BndBox(); - // - if (aBBF.IsOut (aBBE)) { - continue; - } - // - // EF - IntTools_EdgeFace aEF; - aEF.SetEdge (aE); - aEF.SetFace (aF); - aEF.SetTolE (aTolE); - aEF.SetTolF (aTolF); - aEF.SetDiscretize (aDiscretize); - aEF.SetDeflection (aDeflection); - - IntTools_Range anewSR = aSR; - // - BOPTools_Tools::CorrectRange(aE, aF, aSR, anewSR); - // - aEF.SetRange (anewSR); - // - aEF.Perform(); - // - if (aEF.IsDone()) { - // - const IntTools_SequenceOfCommonPrts& aCPrts=aEF.CommonParts(); - aNbCPrts=aCPrts.Length(); - for (i=1; i<=aNbCPrts; i++) { - const IntTools_CommonPrt& aCPart=aCPrts(i); - // - TopAbs_ShapeEnum aType=aCPart.Type(); - switch (aType) { - - case TopAbs_VERTEX: { - - Standard_Real aT; - - const IntTools_Range& aR=aCPart.Range1(); - - Standard_Real aRFirst, aRLast; - - aR.Range(aRFirst, aRLast); - aT=0.5*(aRFirst+aRLast); - - if((aCPart.VertexParameter1() >= aRFirst) && - (aCPart.VertexParameter1() <= aRLast)) { - aT = aCPart.VertexParameter1(); - } - // - char buf[512]; - sprintf (buf, "EF: (%d, %d), vertex at t=%f", nE, nF, aT); - // - gp_Pnt aPnt; - BOPTools_Tools::PointOnEdge(aE, aT, aPnt); - Handle (Geom_CartesianPoint) aCPnt= new Geom_CartesianPoint(aPnt); -// myInerference=aCPnt; - - BOPTools_CheckResult aChRes; - aChRes.AddShape(aE); - aChRes.AddShape(aF); - aChRes.SetCheckStatus(BOPTools_EDGEFACE); -// modified by NIZHNY-MKK Fri Sep 3 16:02:10 2004 -// aChRes.SetInterferenceGeometry(myInerference); - aChRes.SetInterferenceGeometry(aCPnt); - myCheckResults.Append(aChRes); - - if(myStopOnFirst) - throw BOPTColStd_Failure(buf) ; - }// case TopAbs_VERTEX: - break; - - case TopAbs_EDGE: { - - Standard_Boolean aCoinsideFlag; - aCoinsideFlag=BOPTools_Tools::IsBlockInOnFace(aPB, aF, myContext); - if (!aCoinsideFlag) { - break; - } - // - char buf[512]; - sprintf (buf, "EF: (%d, %d), common block ", nE, nF); - - BOPTools_CheckResult aChRes; - aChRes.AddShape(aE); - aChRes.AddShape(aF); - aChRes.SetCheckStatus(BOPTools_EDGEFACECOMBLK); - myCheckResults.Append(aChRes); - - if(myStopOnFirst) - throw BOPTColStd_Failure(buf) ; - }// case TopAbs_EDGE: - break; - - default: - break; - } // switch (aType) - } // for (i=1; i<=aNbCPrts; i++) - } //if (aEF.IsDone()) - } // for (; anIt.More(); anIt.Next()) - }// for (; myDSIt.More(); myDSIt.Next()) - myIsDone=Standard_True; -} - -//======================================================================= -// function: PerformFF -// purpose: -//======================================================================= - void BOPTools_Checker::PerformFF() -{ - myIsDone=Standard_False; - // - Standard_Boolean justaddinterference, bSameFlag; - Standard_Integer n1, n2, nF1, nF2, i, aNbS1; - // - // F/F Interferences [BooleanOperations_SurfaceSurface] - myDSIt.Initialize(TopAbs_FACE, TopAbs_FACE); - // - for (; myDSIt.More(); myDSIt.Next()) { - justaddinterference = Standard_True; - myDSIt.Current(n1, n2, justaddinterference); - // - nF1=n1; - nF2=n2; - if (nF1 > nF2) { - Standard_Integer iTmp; - iTmp=nF1; - nF1=nF2; - nF2=iTmp; - } - // - const TopoDS_Face& aF1=TopoDS::Face(myDS->Shape(nF1)); - const TopoDS_Face& aF2=TopoDS::Face(myDS->Shape(nF2)); - // - TopTools_IndexedMapOfShape aM1, aM2; - // - bSameFlag=Standard_False; - // - TopExp::MapShapes(aF1, TopAbs_EDGE, aM1); - TopExp::MapShapes(aF2, TopAbs_EDGE, aM2); - // - aNbS1=aM1.Extent(); - - for (i=1; i<=aNbS1; ++i) { - const TopoDS_Shape& aS1=aM1(i); - if (aM2.Contains(aS1)) { - bSameFlag=Standard_True; - break; - } - } - // - if (bSameFlag){ - continue; - } - // - // FF - Standard_Boolean bToApproxC3d, bToApproxC2dOnS1, bToApproxC2dOnS2; - Standard_Real anApproxTol, aTolR3D, aTolR2D; - // - bToApproxC3d = mySectionAttribute.Approximation(); - bToApproxC2dOnS1 = mySectionAttribute.PCurveOnS1(); - bToApproxC2dOnS2 = mySectionAttribute.PCurveOnS2(); - // - anApproxTol=1.e-7; - - IntTools_FaceFace aFF; - aFF.SetParameters (bToApproxC3d, - bToApproxC2dOnS1, - bToApproxC2dOnS2, - anApproxTol); - - aFF.Perform(aF1, aF2); - - if (aFF.IsDone()) { - // Add Interference to the Pool - aTolR3D=aFF.TolReached3d(); - aTolR2D=aFF.TolReached2d(); - if (aTolR3D < 1.e-7){ - aTolR3D=1.e-7; - } - aFF.PrepareLines3D(); - // - // - Standard_Integer j, aNbCurves, aNbPoints; - // - const IntTools_SequenceOfCurves& aCvs=aFF.Lines(); - aNbCurves=aCvs.Length(); - // - const IntTools_SequenceOfPntOn2Faces& aPnts=aFF.Points(); - aNbPoints=aPnts.Length(); - - if (aNbPoints) { - char buf[512]; - sprintf (buf, "FF: (%d, %d) ", nF1, nF2); - // - const IntTools_PntOn2Faces& aPntOn2Faces=aPnts(1); - const IntTools_PntOnFace& aPntOnFace=aPntOn2Faces.P1(); - const gp_Pnt& aPnt=aPntOnFace.Pnt(); - Handle (Geom_CartesianPoint) aCPnt= new Geom_CartesianPoint(aPnt); -// myInerference=aCPnt; - - BOPTools_CheckResult aChRes; - aChRes.AddShape(aF1); - aChRes.AddShape(aF2); - aChRes.SetCheckStatus(BOPTools_FACEFACE); -// modified by NIZHNY-MKK Fri Sep 3 16:02:25 2004 -// aChRes.SetInterferenceGeometry(myInerference); - aChRes.SetInterferenceGeometry(aCPnt); - myCheckResults.Append(aChRes); - - if(myStopOnFirst) - throw BOPTColStd_Failure(buf) ; - } - - if (aNbCurves) { - for (j=1; j<=aNbCurves; j++) { - const IntTools_Curve& aC=aCvs(j); - if (aC.HasBounds()) { - Standard_Real aT1, aT2; - Standard_Boolean bValid; - gp_Pnt aP1, aP2; - - aC.Bounds(aT1, aT2, aP1, aP2); - // - bValid=myContext->IsValidBlockForFaces(aT1, aT2, aC, aF1, aF2, 1.e-3); - // - if (bValid) { - char buf[512]; - sprintf (buf, "FF: (%d, %d) ", nF1, nF2); - // - Handle (Geom_Curve) aC3D=aC.Curve(); - Handle (Geom_TrimmedCurve) aTC3D=Handle (Geom_TrimmedCurve)::DownCast(aC3D); -// myInerference=aTC3D; - - BOPTools_CheckResult aChRes; - aChRes.AddShape(aF1); - aChRes.AddShape(aF2); - aChRes.SetCheckStatus(BOPTools_FACEFACE); -// modified by NIZHNY-MKK Fri Sep 3 16:02:40 2004 -// aChRes.SetInterferenceGeometry(myInerference); - aChRes.SetInterferenceGeometry(aTC3D); - myCheckResults.Append(aChRes); - - if(myStopOnFirst) - throw BOPTColStd_Failure(buf) ; - } - } - } - }// if (aNbCurves) - - }// if (aFF.IsDone()) - }// for (; myDSIt.More(); myDSIt.Next()) - myIsDone=Standard_True; -} -//======================================================================= -// function: PrepareEdges -// purpose: -//======================================================================= - void BOPTools_Checker::PrepareEdges() -{ - Standard_Integer i, nV, ii, aNBSuc; - Standard_Real aT; - TopAbs_Orientation anOr; - TopoDS_Edge aE; - TopoDS_Vertex aV; - - for (i=1; i<=myNbSources; i++) { - if (myDS->GetShapeType(i)==TopAbs_EDGE) { - aE=TopoDS::Edge(myDS->GetShape(i)); - // - if (BRep_Tool::Degenerated(aE)){ - continue; - } - // - BOPTools_PaveSet& aPaveSet= myPavePool(myDS->RefEdge(i)); - // - // cto900/M2 - // Some of Edges can be [Semi] Infinite. Such Edges have no - // vertices on correspondant INF ends. So we must provide - // these vertices formally (to obtain Shrunk Ranges for e.g). - // In reality this vertex(-es) does not belong to the INF Edge. - // It just has reference in the DS. - // PKV Tue Apr 23 10:21:45 2002 - { - Standard_Real aT1, aT2, aTolE; - Standard_Boolean bInf1, bInf2; - gp_Pnt aPx; - TopoDS_Vertex aVx; - BRep_Builder aBB; - BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq; - // - aTolE=BRep_Tool::Tolerance(aE); - Handle(Geom_Curve) aC3D=BRep_Tool::Curve (aE, aT1, aT2); - bInf1=Precision::IsNegativeInfinite(aT1); - bInf2=Precision::IsPositiveInfinite(aT2); - - if (bInf1) { - aC3D->D0(aT1, aPx); - aBB.MakeVertex(aVx, aPx, aTolE); - myDS->InsertShapeAndAncestorsSuccessors(aVx, anASSeq); - nV=myDS->NumberOfInsertedShapes(); - BOPTools_Pave aPave(nV, aT1); - aPaveSet.Append (aPave); - } - - if (bInf2) { - aC3D->D0(aT2, aPx); - aBB.MakeVertex(aVx, aPx, aTolE); - myDS->InsertShapeAndAncestorsSuccessors(aVx, anASSeq); - nV=myDS->NumberOfInsertedShapes(); - BOPTools_Pave aPave(nV, aT2); - aPaveSet.Append (aPave); - } - } - // - aNBSuc=myDS->NumberOfSuccessors(i); - for (ii=1; ii <= aNBSuc; ii++) { - nV=myDS->GetSuccessor(i, ii); - anOr=myDS->GetOrientation(i, ii); - - aV=TopoDS::Vertex(myDS->GetShape(nV)); - aV.Orientation(anOr); - aT=BRep_Tool::Parameter(aV, aE); - // - BOPTools_Pave aPave(nV, aT); - aPaveSet.Append (aPave); - } - } - } -} -//======================================================================= -// function: PreparePaveBlocks -// purpose: -//======================================================================= - void BOPTools_Checker::PreparePaveBlocks(const TopAbs_ShapeEnum aType1, - const TopAbs_ShapeEnum aType2) -{ - BOPTools_PaveFiller::PreparePaveBlocks(aType1, aType2); -} -//======================================================================= -// function: PreparePaveBlocks -// purpose: -//======================================================================= - void BOPTools_Checker::PreparePaveBlocks(const Standard_Integer nE) -{ - myIsDone=Standard_False; - - Standard_Integer nV1, nV2; - - TopoDS_Edge aE; - TopoDS_Vertex aV1, aV2; - - // SplitShapesPool - BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(nE)); - // Edge - aE=TopoDS::Edge(myDS->GetShape(nE)); - // - if (!BRep_Tool::Degenerated(aE)){ - // - BOPTools_PaveSet& aPS=myPavePool(myDS->RefEdge(nE)); - - BOPTools_PaveBlockIterator aPBIt(nE, aPS); - for (; aPBIt.More(); aPBIt.Next()) { - BOPTools_PaveBlock& aPB=aPBIt.Value(); - - const IntTools_Range& aRange=aPB.Range(); - - const BOPTools_Pave& aPave1=aPB.Pave1(); - nV1=aPave1.Index(); - aV1=TopoDS::Vertex(myDS->GetShape(nV1)); - - const BOPTools_Pave& aPave2=aPB.Pave2(); - nV2=aPave2.Index(); - aV2=TopoDS::Vertex(myDS->GetShape(nV2)); - // - // ShrunkRange - IntTools_ShrunkRange aSR (aE, aV1, aV2, aRange, myContext); - // - Standard_Integer anErrorStatus; - anErrorStatus=aSR.ErrorStatus(); - - char buf[512]; - if (!aSR.IsDone()) { - sprintf (buf, "Can not obtain ShrunkRange for Edge %d", nE); - - BOPTools_CheckResult aChRes; - aChRes.AddShape(aE); - aChRes.SetCheckStatus(BOPTools_BADSHRANKRANGE); - myCheckResults.Append(aChRes); - - if(myStopOnFirst) - throw BOPTColStd_Failure(buf) ; - } - // - if (anErrorStatus==6) { - sprintf(buf, - "Warning: [PreparePaveBlocks()] Max.Dummy Shrunk Range for Edge %d\n", nE); - - BOPTools_CheckResult aChRes; - aChRes.AddShape(aE); - aChRes.SetCheckStatus(BOPTools_NULLSRANKRANGE); - myCheckResults.Append(aChRes); - - if(myStopOnFirst) - throw BOPTColStd_Failure(buf); - } - else { - // Check left paves and correct ShrunkRange if it is necessary - CorrectShrunkRanges (0, aPave1, aSR); - CorrectShrunkRanges (1, aPave2, aSR); - } - // - aPB.SetShrunkRange(aSR); - aLPB.Append(aPB); - } //for (; aPBIt1.More(); aPBIt1.Next()) - } - myIsDone=Standard_True; -} - -//======================================================================= -// function: GetCheckResult -// purpose: -//======================================================================= -const BOPTools_ListOfCheckResults& BOPTools_Checker::GetCheckResult() const -{ - return myCheckResults; -} - -//======================================================================= -// function: HasFaulty -// purpose: -//======================================================================= - Standard_Boolean BOPTools_Checker::HasFaulty()const -{ - return (!myIsDone || !myCheckResults.IsEmpty()); -} - -//======================================================================= -// function: Shape -// purpose: -//======================================================================= - const TopoDS_Shape& BOPTools_Checker::Shape()const -{ - return myShape; -} - - - diff --git a/src/BOPTools/BOPTools_CommonBlock.cdl b/src/BOPTools/BOPTools_CommonBlock.cdl deleted file mode 100755 index e8355b412b..0000000000 --- a/src/BOPTools/BOPTools_CommonBlock.cdl +++ /dev/null @@ -1,108 +0,0 @@ --- Created on: 2001-02-15 --- Created by: Peter KURNEV --- Copyright (c) 2001-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class CommonBlock from BOPTools - - ---Purpose: - -- The class hold a structure for storing info about a couple - -- of pave blocks that are considered as common - -uses - PaveBlock from BOPTools - - -is - Create - returns CommonBlock from BOPTools; - ---Purpose: - --- Empty constructor - --- - Create (aPB1:PaveBlock from BOPTools; - aPB2:PaveBlock from BOPTools); - ---Purpose: - --- Constructor that uses couple of pave blocks - --- - Create (aPB1:PaveBlock from BOPTools; - aF:Integer from Standard); - ---Purpose: - --- Constructor that uses a pave block and a face - --- - SetPaveBlock1 (me:out; aPB1:PaveBlock from BOPTools); - ---Purpose: - --- Modifier - --- Sets first block - --- - SetPaveBlock2 (me:out; aPB2:PaveBlock from BOPTools); - ---Purpose: - --- Modifier - --- Sets second block - --- - SetFace (me:out; aF: Integer from Standard); - ---Purpose: - --- Modifier - --- Sets DS-index of the face (if it exists) with which the - --- CommonBlock is common. 0 is default value - --- - PaveBlock1 (me) - returns PaveBlock from BOPTools; - ---C++: return const & - ---Purpose: - --- Selector - --- Always returns first block myPB1 - --- - PaveBlock1 (me:out; anIndex: Integer from Standard) - returns PaveBlock from BOPTools; - ---C++: return & - ---Purpose: - --- Selector - --- Returns block that belongs to the original edge with - --- DS-index=anIndex - --- - PaveBlock2 (me) - returns PaveBlock from BOPTools; - ---C++: return const & - ---Purpose: - --- Selector - --- Always returns first block myPB2 - --- - PaveBlock2 (me:out; anIndex: Integer from Standard) - returns PaveBlock from BOPTools; - ---C++: return & - ---Purpose: - --- Selector - --- Returns block that does not belong to the original edge with - --- DS-index=anIndex - --- - Face(me) - returns Integer from Standard; - ---Purpose: - --- Selector - --- Returns the DS-index of the face (if exists) - --- with which the CommonBlock is common. - --- Otherwise it returns 0. - --- - -fields - myPB1 : PaveBlock from BOPTools; - myPB2 : PaveBlock from BOPTools; - myFace : Integer from Standard; - -end CommonBlock; diff --git a/src/BOPTools/BOPTools_CommonBlock.cxx b/src/BOPTools/BOPTools_CommonBlock.cxx deleted file mode 100755 index e6e03b9da0..0000000000 --- a/src/BOPTools/BOPTools_CommonBlock.cxx +++ /dev/null @@ -1,130 +0,0 @@ -// Created on: 2001-02-15 -// Created by: Peter KURNEV -// Copyright (c) 2001-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include - -//======================================================================= -// function: BOPTools_CommonBlock::BOPTools_CommonBlock -// purpose: -//======================================================================= -BOPTools_CommonBlock::BOPTools_CommonBlock() -: - myFace(0) -{} -//======================================================================= -// function: BOPTools_CommonBlock::BOPTools_CommonBlock -// purpose: -//======================================================================= - BOPTools_CommonBlock::BOPTools_CommonBlock(const BOPTools_PaveBlock& thePB1, - const BOPTools_PaveBlock& thePB2) -{ - myPB1=thePB1; - myPB2=thePB2; - myFace=0; -} -//======================================================================= -// function: BOPTools_CommonBlock::BOPTools_CommonBlock -// purpose: -//======================================================================= - BOPTools_CommonBlock::BOPTools_CommonBlock(const BOPTools_PaveBlock& thePB1, - const Standard_Integer aF) -{ - myPB1=thePB1; - myFace=aF; -} -//======================================================================= -// function: SetFace -// purpose: -//======================================================================= - void BOPTools_CommonBlock::SetFace(const Standard_Integer aF) -{ - myFace=aF; -} -//======================================================================= -// function: SetPaveBlock1 -// purpose: -//======================================================================= - void BOPTools_CommonBlock::SetPaveBlock1(const BOPTools_PaveBlock& thePB1) -{ - myPB1=thePB1; -} -//======================================================================= -// function: SetPaveBlock2 -// purpose: -//======================================================================= - void BOPTools_CommonBlock::SetPaveBlock2(const BOPTools_PaveBlock& thePB2) -{ - myPB2=thePB2; -} -//======================================================================= -// function: PaveBlock1 -// purpose: -//======================================================================= - const BOPTools_PaveBlock& BOPTools_CommonBlock::PaveBlock1() const -{ - return myPB1; -} -//======================================================================= -// function: Face -// purpose: -//======================================================================= - Standard_Integer BOPTools_CommonBlock::Face() const -{ - return myFace; -} - -//======================================================================= -// function: PaveBlock1 -// purpose: -//======================================================================= - BOPTools_PaveBlock& BOPTools_CommonBlock::PaveBlock1(const Standard_Integer anIndex) -{ - Standard_Integer anOriginalEdge; - - anOriginalEdge=myPB1.OriginalEdge(); - if (anIndex==anOriginalEdge) { - return myPB1; - } - return myPB2; -} -//======================================================================= -// function: PaveBlock2 -// purpose: -//======================================================================= - const BOPTools_PaveBlock& BOPTools_CommonBlock::PaveBlock2() const -{ - return myPB2; -} - -//======================================================================= -// function: PaveBlock2 -// purpose: -//======================================================================= - BOPTools_PaveBlock& BOPTools_CommonBlock::PaveBlock2(const Standard_Integer anIndex) -{ - Standard_Integer anOriginalEdge; - - anOriginalEdge=myPB1.OriginalEdge(); - if (anIndex==anOriginalEdge) { - return myPB2; - } - return myPB1; -} diff --git a/src/BOPTools/BOPTools_CommonBlockAPI.cdl b/src/BOPTools/BOPTools_CommonBlockAPI.cdl deleted file mode 100755 index e1dca7b3a6..0000000000 --- a/src/BOPTools/BOPTools_CommonBlockAPI.cdl +++ /dev/null @@ -1,64 +0,0 @@ --- Created on: 2001-03-14 --- Created by: Peter KURNEV --- Copyright (c) 2001-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class CommonBlockAPI from BOPTools - - ---Purpose: - --- class that provide some useful tools - --- to manage with a List Of Common Block-s - -uses - ListOfCommonBlock from BOPTools, - ListOfPaveBlock from BOPTools, - PaveBlock from BOPTools - -is - Create (aList:ListOfCommonBlock from BOPTools) - returns CommonBlockAPI from BOPTools; - ---Purpose: - --- Constructor - --- - List(me) - returns ListOfCommonBlock from BOPTools; - ---C++: return const & - ---Purpose: - --- Selector - --- - CommonPaveBlocks(me; - anE:Integer from Standard) - returns ListOfPaveBlock from BOPTools; - ---C++: return const & - ---Purpose: - --- Returns all PaveBlock-s (from the list) that are - --- common for the given edge with DS-index - --- - IsCommonBlock (me; - aPB: PaveBlock from BOPTools) - returns Boolean from Standard; - ---Purpose: - --- Returns TRUE if given PaveBlock is - --- common for the Blocks from the list - --- -fields - myListOfCommonBlock :Address from Standard; - myListOfPaveBlock :ListOfPaveBlock from BOPTools; - -end CommonBlockAPI; diff --git a/src/BOPTools/BOPTools_CommonBlockAPI.cxx b/src/BOPTools/BOPTools_CommonBlockAPI.cxx deleted file mode 100755 index 1a6b674e27..0000000000 --- a/src/BOPTools/BOPTools_CommonBlockAPI.cxx +++ /dev/null @@ -1,106 +0,0 @@ -// Created on: 2001-03-14 -// Created by: Peter KURNEV -// Copyright (c) 2001-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include - -#include -#include -#include -#include -#include -#include - - -//======================================================================= -// function: BOPTools_CommonBlockAPI::BOPTools_CommonBlockAPI -// purpose: -//======================================================================= -BOPTools_CommonBlockAPI::BOPTools_CommonBlockAPI - (const BOPTools_ListOfCommonBlock& aLCB) -{ - myListOfCommonBlock=(void *)&aLCB; -} -//======================================================================= -// function: List -// purpose: -//======================================================================= - const BOPTools_ListOfCommonBlock& BOPTools_CommonBlockAPI::List () const -{ - BOPTools_ListOfCommonBlock* pListOfCommonBlock= - (BOPTools_ListOfCommonBlock*)myListOfCommonBlock; - return *pListOfCommonBlock; -} -//======================================================================= -// function: CommonPaveBlocks -// purpose: get all CommonPaveBlocks -//======================================================================= - const BOPTools_ListOfPaveBlock& - BOPTools_CommonBlockAPI::CommonPaveBlocks - (const Standard_Integer anE) const -{ - Standard_Integer anECurrent, i; - - BOPTools_ListOfPaveBlock* pmyListOfPaveBlock= - (BOPTools_ListOfPaveBlock*) &myListOfPaveBlock; - pmyListOfPaveBlock->Clear(); - - BOPTools_ListOfCommonBlock* pListOfCommonBlock= - (BOPTools_ListOfCommonBlock*)myListOfCommonBlock; - - BOPTools_ListIteratorOfListOfCommonBlock anIt(*pListOfCommonBlock); - for (; anIt.More(); anIt.Next()) { - const BOPTools_CommonBlock& aCB=anIt.Value(); - - for (i=0; i<2; i++) { - const BOPTools_PaveBlock& aPB=(!i) ? aCB.PaveBlock1() : aCB.PaveBlock2(); - anECurrent=aPB.OriginalEdge(); - if (anECurrent==anE) { - pmyListOfPaveBlock->Append(aPB); - break; - } - } - } - - return myListOfPaveBlock; -} -//======================================================================= -// function: IsCommonBlock -// purpose: -//======================================================================= - Standard_Boolean BOPTools_CommonBlockAPI::IsCommonBlock - (const BOPTools_PaveBlock& aPB) const -{ - Standard_Integer anE; - - anE=aPB.OriginalEdge(); - - CommonPaveBlocks(anE); - - BOPTools_ListIteratorOfListOfPaveBlock anIt(myListOfPaveBlock); - for (; anIt.More(); anIt.Next()) { - const BOPTools_PaveBlock& aPB1=anIt.Value(); - if (aPB1.IsEqual(aPB)) { - return Standard_True; - } - } - return Standard_False; -} - diff --git a/src/BOPTools/BOPTools_ComparePave.cdl b/src/BOPTools/BOPTools_ComparePave.cdl deleted file mode 100755 index fa885622ff..0000000000 --- a/src/BOPTools/BOPTools_ComparePave.cdl +++ /dev/null @@ -1,63 +0,0 @@ --- Created on: 2001-02-16 --- Created by: Peter KURNEV --- Copyright (c) 2001-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class ComparePave from BOPTools - - ---Purpose: - --- - --- Auxiliary class for sorting paves along the edge - --- in acoordance with increasing order of parameter - -uses - Pave from BOPTools - -is - Create - returns ComparePave from BOPTools; - ---Purpose: - --- Empty constructor - --- Default comparing tolerance value=1.e-12 - --- - Create (aTol:Real from Standard) - returns ComparePave from BOPTools; - ---Purpose: - --- Constructor that use comparing tolerance value as parameter. - --- - IsLower (me; Left, Right: Pave from BOPTools) - returns Boolean ; - ---Purpose: - --- Returns True if is lower than . - --- - IsGreater (me; Left, Right: Pave from BOPTools) - returns Boolean from Standard ; - ---Purpose: - --- Returns True if is greater than . - --- - IsEqual(me; Left, Right: Pave from BOPTools) - returns Boolean from Standard ; - ---Purpose: - --- Returns True when and are equal. - --- - -fields - myTol: Real from Standard; - -end ComparePave; diff --git a/src/BOPTools/BOPTools_ComparePave.cxx b/src/BOPTools/BOPTools_ComparePave.cxx deleted file mode 100755 index 5aaa84e92a..0000000000 --- a/src/BOPTools/BOPTools_ComparePave.cxx +++ /dev/null @@ -1,69 +0,0 @@ -// Created on: 2001-02-16 -// Created by: Peter KURNEV -// Copyright (c) 2001-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include - -//======================================================================= -// function: BOPTools_ComparePave::BOPTools_ComparePave -// purpose: -//======================================================================= -BOPTools_ComparePave::BOPTools_ComparePave() - :myTol(1.e-12) - {} - -//======================================================================= -// function: BOPTools_ComparePave::BOPTools_ComparePave -// purpose: -//======================================================================= - BOPTools_ComparePave::BOPTools_ComparePave(const Standard_Real aTol) -{ - myTol=aTol; -} -//======================================================================= -// function: IsLower -// purpose: -//======================================================================= - Standard_Boolean BOPTools_ComparePave::IsLower(const BOPTools_Pave& aLeft, - const BOPTools_Pave& aRight)const -{ - return aLeft.Param()aRight.Param(); -} -//======================================================================= -// function: IsEqual -// purpose: -//======================================================================= - Standard_Boolean BOPTools_ComparePave::IsEqual(const BOPTools_Pave& aLeft, - const BOPTools_Pave& aRight)const -{ - Standard_Real a, b; - a=aLeft.Param(); - b=aRight.Param(); - return fabs(a-b) < myTol; -} diff --git a/src/BOPTools/BOPTools_ConnexityBlock.hxx b/src/BOPTools/BOPTools_ConnexityBlock.hxx new file mode 100644 index 0000000000..5be56d888c --- /dev/null +++ b/src/BOPTools/BOPTools_ConnexityBlock.hxx @@ -0,0 +1,85 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPTools_ConnexityBlock_HeaderFile +#define BOPTools_ConnexityBlock_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +#include +#include + +//======================================================================= +//class : ConnexityBlock +//purpose : +//======================================================================= +class BOPTools_ConnexityBlock { + public: + BOPTools_ConnexityBlock() : + myAllocator(NCollection_BaseAllocator::CommonBaseAllocator()), + myRegular(Standard_True), + myShapes(myAllocator), + myLoops(myAllocator) { + }; + // + BOPTools_ConnexityBlock(const Handle(NCollection_BaseAllocator)& theAllocator): + myRegular(Standard_True), + myAllocator(theAllocator), + myShapes(myAllocator), + myLoops(myAllocator) { + }; + // + const BOPCol_ListOfShape& Shapes()const { + return myShapes; + }; + // + BOPCol_ListOfShape& ChangeShapes() { + return myShapes; + }; + // + void SetRegular(const Standard_Boolean theFlag) { + myRegular=theFlag; + } + // + Standard_Boolean IsRegular()const { + return myRegular; + } + // + const BOPCol_ListOfShape& Loops()const { + return myLoops; + }; + // + BOPCol_ListOfShape& ChangeLoops() { + return myLoops; + }; + // + protected: + Standard_Boolean myRegular; + Handle(NCollection_BaseAllocator) myAllocator; + BOPCol_ListOfShape myShapes; + BOPCol_ListOfShape myLoops; +}; + + +#endif diff --git a/src/BOPTools/BOPTools_CoupleOfInteger.cdl b/src/BOPTools/BOPTools_CoupleOfInteger.cdl deleted file mode 100755 index ead7aad85e..0000000000 --- a/src/BOPTools/BOPTools_CoupleOfInteger.cdl +++ /dev/null @@ -1,88 +0,0 @@ --- Created on: 2002-04-01 --- Created by: Peter KURNEV --- Copyright (c) 2002-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class CoupleOfInteger from BOPTools - - ---Purpose: - -- Auxiliary class providing structure to - -- store info about a couple of integers - ---uses ---raises - -is - Create - returns CoupleOfInteger from BOPTools; - ---Purpose: - --- Empty Constructor - --- - Create(aFirst : Integer from Standard; - aSecond : Integer from Standard) - returns CoupleOfInteger from BOPTools; - ---Purpose: - --- Constructor - --- - SetCouple(me:out; - aFirst : Integer from Standard; - aSecond : Integer from Standard); - ---Purpose: - --- Modifier - --- - SetFirst(me:out; - aFirst : Integer from Standard); - ---Purpose: - --- Modifier - --- - SetSecond(me:out; - aSecond : Integer from Standard); - ---Purpose: - --- Modifier - --- - Couple (me; - aFirst :out Integer from Standard; - aSecond :out Integer from Standard); - ---Purpose: - --- Selector - --- - First(me) - returns Integer from Standard; - ---Purpose: - --- Selector - --- - Second(me) - returns Integer from Standard; - ---Purpose: - --- Selector - --- - - IsEqual(me; - aOther:like me) - returns Boolean from Standard; - - HashCode(me; - Upper : Integer from Standard) - returns Integer from Standard; - -fields - myFirst : Integer from Standard; - mySecond : Integer from Standard; - -end CoupleOfInteger; diff --git a/src/BOPTools/BOPTools_CoupleOfInteger.cxx b/src/BOPTools/BOPTools_CoupleOfInteger.cxx deleted file mode 100755 index e53ba7af8e..0000000000 --- a/src/BOPTools/BOPTools_CoupleOfInteger.cxx +++ /dev/null @@ -1,119 +0,0 @@ -// Created on: 2002-04-01 -// Created by: Peter KURNEV -// Copyright (c) 2002-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#include - -//======================================================================= -// function: BOPTools_CoupleOfInteger::BOPTools_CoupleOfInteger -// purpose: -//======================================================================= -BOPTools_CoupleOfInteger::BOPTools_CoupleOfInteger() -: - myFirst(99), - mySecond(99) -{} - -//======================================================================= -// function: BOPTools_CoupleOfInteger::BOPTools_CoupleOfInteger -// purpose: -//======================================================================= - BOPTools_CoupleOfInteger::BOPTools_CoupleOfInteger(const Standard_Integer aFirst, - const Standard_Integer aSecond) -: - myFirst(aFirst), - mySecond(aSecond) -{} - -//======================================================================= -// function: SetCouple -// purpose: -//======================================================================= - void BOPTools_CoupleOfInteger::SetCouple(const Standard_Integer aFirst, - const Standard_Integer aSecond) -{ - myFirst=aFirst; - mySecond=aSecond; -} - -//======================================================================= -// function: SetFirst -// purpose: -//======================================================================= - void BOPTools_CoupleOfInteger::SetFirst(const Standard_Integer aFirst) -{ - myFirst=aFirst; -} - - -//======================================================================= -// function: SetSecond -// purpose: -//======================================================================= - void BOPTools_CoupleOfInteger::SetSecond(const Standard_Integer aSecond) -{ - mySecond=aSecond; -} - -//======================================================================= -// function: Couple -// purpose: -//======================================================================= - void BOPTools_CoupleOfInteger::Couple(Standard_Integer& aFirst, - Standard_Integer& aSecond)const -{ - aFirst=myFirst; - aSecond=mySecond; -} -//======================================================================= -// function: First -// purpose: -//======================================================================= - Standard_Integer BOPTools_CoupleOfInteger::First()const -{ - return myFirst; -} -//======================================================================= -// function: Second -// purpose: -//======================================================================= - Standard_Integer BOPTools_CoupleOfInteger::Second()const -{ - return mySecond; -} -//======================================================================= -// function: IsEqual -// purpose: -//======================================================================= - Standard_Boolean BOPTools_CoupleOfInteger::IsEqual(const BOPTools_CoupleOfInteger& aOther)const -{ - Standard_Boolean b1, b2; - // - b1=(Standard_Boolean)((myFirst==aOther.myFirst ) && (mySecond==aOther.mySecond)); - b2=(Standard_Boolean)((myFirst==aOther.mySecond) && (mySecond==aOther.myFirst )); - return (Standard_Boolean)(b1||b2); -} -//======================================================================= -// function: HashCode -// purpose: -//======================================================================= - Standard_Integer BOPTools_CoupleOfInteger::HashCode(const Standard_Integer aUpper)const -{ - return (myFirst+mySecond)%aUpper; -} diff --git a/src/BOPTools/BOPTools_CoupleOfIntegerMapHasher.cdl b/src/BOPTools/BOPTools_CoupleOfIntegerMapHasher.cdl deleted file mode 100755 index 7e25e5d983..0000000000 --- a/src/BOPTools/BOPTools_CoupleOfIntegerMapHasher.cdl +++ /dev/null @@ -1,46 +0,0 @@ --- Created on: 2003-12-05 --- Created by: Peter KURNEV --- Copyright (c) 2003-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class CoupleOfIntegerMapHasher from BOPTools - - ---Purpose: - -uses - CoupleOfInteger from BOPTools - ---raises - -is - HashCode(myclass; - aPKey : CoupleOfInteger from BOPTools; - Upper : Integer from Standard) - returns Integer from Standard; - - - IsEqual(myclass; - aPKey1 : CoupleOfInteger from BOPTools; - aPKey2 : CoupleOfInteger from BOPTools) - returns Boolean from Standard; - - ---fields - -end CoupleOfIntegerMapHasher; diff --git a/src/BOPTools/BOPTools_CoupleOfIntegerMapHasher.cxx b/src/BOPTools/BOPTools_CoupleOfIntegerMapHasher.cxx deleted file mode 100755 index 27a19e1d7f..0000000000 --- a/src/BOPTools/BOPTools_CoupleOfIntegerMapHasher.cxx +++ /dev/null @@ -1,41 +0,0 @@ -// Created on: 2003-12-05 -// Created by: Peter KURNEV -// Copyright (c) 2003-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include - -//======================================================================= -//function : HashCode -//purpose : -//======================================================================= -Standard_Integer BOPTools_CoupleOfIntegerMapHasher::HashCode(const BOPTools_CoupleOfInteger& aPKey, - const Standard_Integer Upper) -{ - return aPKey.HashCode(Upper); -} -//======================================================================= -//function :IsEqual -//purpose : -//======================================================================= - Standard_Boolean BOPTools_CoupleOfIntegerMapHasher::IsEqual(const BOPTools_CoupleOfInteger& aPKey1, - const BOPTools_CoupleOfInteger& aPKey2) -{ - return aPKey1.IsEqual(aPKey2); -} diff --git a/src/BOPTools/BOPTools_CoupleOfShape.hxx b/src/BOPTools/BOPTools_CoupleOfShape.hxx new file mode 100644 index 0000000000..4aded4e6bd --- /dev/null +++ b/src/BOPTools/BOPTools_CoupleOfShape.hxx @@ -0,0 +1,57 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPTools_CoupleOfShape_HeaderFile +#define BOPTools_CoupleOfShape_HeaderFile + +//======================================================================= +//class : +//purpose : +//======================================================================= +class BOPTools_CoupleOfShape { + public: + BOPTools_CoupleOfShape() { + }; + // + ~BOPTools_CoupleOfShape() { + }; + // + void SetShape1(const TopoDS_Shape& theShape) { + myShape1=theShape; + } + // + const TopoDS_Shape& Shape1()const{ + return myShape1; + } + // + void SetShape2(const TopoDS_Shape& theShape) { + myShape2=theShape; + } + // + const TopoDS_Shape& Shape2()const{ + return myShape2; + } + // + protected: + TopoDS_Shape myShape1; + TopoDS_Shape myShape2; +}; + + +#endif diff --git a/src/BOPTools/BOPTools_Curve.cdl b/src/BOPTools/BOPTools_Curve.cdl deleted file mode 100755 index 2e2b116a5f..0000000000 --- a/src/BOPTools/BOPTools_Curve.cdl +++ /dev/null @@ -1,89 +0,0 @@ --- Created on: 2001-05-08 --- Created by: Peter KURNEV --- Copyright (c) 2001-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class Curve from BOPTools - - ---Purpose: - -- Class holds the structure for storing information about - --- intersection curve and set of paves on it - --- - -uses - ListOfInteger from TColStd, - Curve from IntTools, - PaveSet from BOPTools, - PaveBlock from BOPTools, - ListOfPaveBlock from BOPTools - - -is - Create - returns Curve from BOPTools; - ---Purpose: - --- Empty constructor - --- - Create (aIC:Curve from IntTools) - returns Curve from BOPTools; - ---Purpose: - --- Constructor - --- - SetCurve(me:out; - aIC:Curve from IntTools); - ---Purpose: - --- Modifier - --- - Curve(me) - returns Curve from IntTools; - ---C++: return const & - ---Purpose: - --- Selector - --- - Set(me:out) - returns PaveSet from BOPTools; - ---C++: return & - ---Purpose: - --- Selector - --- - AppendNewBlock(me:out; - aPB:PaveBlock from BOPTools); - ---Purpose: - --- Adds the PaveBlock to the pave set - --- - NewPaveBlocks(me) - returns ListOfPaveBlock from BOPTools; - ---C++: return const & - ---Purpose: - --- Returns the PaveBlock-s attached to the curve - --- - TechnoVertices (me:out) - returns ListOfInteger from TColStd; - ---C++: return & - ---Purpose: - --- Returns indices TechnoVertices attached to the curve - --- - -fields - myCurve : Curve from IntTools; - myPaveSet: PaveSet from BOPTools; - myNewPBs : ListOfPaveBlock from BOPTools; - myTechnoVertices : ListOfInteger from TColStd; - -end Curve; diff --git a/src/BOPTools/BOPTools_Curve.cxx b/src/BOPTools/BOPTools_Curve.cxx deleted file mode 100755 index b29de35c3b..0000000000 --- a/src/BOPTools/BOPTools_Curve.cxx +++ /dev/null @@ -1,87 +0,0 @@ -// Created on: 2001-05-08 -// Created by: Peter KURNEV -// Copyright (c) 2001-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include - -//======================================================================= -// function: BOPTools_Curve::BOPTools_Curve -// purpose: -//======================================================================= -BOPTools_Curve::BOPTools_Curve() -{} -//======================================================================= -// function: BOPTools_Curve::BOPTools_Curve -// purpose: -//======================================================================= - BOPTools_Curve::BOPTools_Curve (const IntTools_Curve& aIC) -{ - myCurve=aIC; -} -//======================================================================= -// function: SetCurve -// purpose: -//======================================================================= - void BOPTools_Curve::SetCurve (const IntTools_Curve& aIC) -{ - myCurve=aIC; -} -//======================================================================= -// function: Curve -// purpose: -//======================================================================= - const IntTools_Curve& BOPTools_Curve::Curve () const -{ - return myCurve; -} -//======================================================================= -// function: Set -// purpose: -//======================================================================= - BOPTools_PaveSet& BOPTools_Curve::Set() -{ - return myPaveSet; -} - -//======================================================================= -//function : AppendNewBlock -//purpose : -//======================================================================= - void BOPTools_Curve::AppendNewBlock(const BOPTools_PaveBlock& aPB) -{ - myNewPBs.Append(aPB); -} - -//======================================================================= -//function : NewPaveBlocks -//purpose : -//======================================================================= - const BOPTools_ListOfPaveBlock& BOPTools_Curve::NewPaveBlocks() const -{ - return myNewPBs; -} -//======================================================================= -//function : TechnoVertices -//purpose : -//======================================================================= - TColStd_ListOfInteger& BOPTools_Curve::TechnoVertices() -{ - return myTechnoVertices; -} diff --git a/src/BOPTools/BOPTools_DEInfo.cdl b/src/BOPTools/BOPTools_DEInfo.cdl deleted file mode 100755 index 7d62a4afb2..0000000000 --- a/src/BOPTools/BOPTools_DEInfo.cdl +++ /dev/null @@ -1,74 +0,0 @@ --- Created on: 2001-09-12 --- Created by: Peter KURNEV --- Copyright (c) 2001-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class DEInfo from BOPTools - - ---Purpose: - -- Auxiliary class for storing information about - --- a degenerated edge - --- - -uses - ListOfInteger from TColStd - -is - Create - returns DEInfo from BOPTools; - ---Purpose: - --- Empty constructor - --- - SetVertex (me:out; - nV:Integer from Standard); - ---Purpose: - --- Modifier - --- Sets DS-index for the vertex to which - --- degenerated edge belongs to - --- - SetFaces (me:out; - aLF: ListOfInteger from TColStd); - ---Purpose: - --- Modifier - --- Sets DS-indices for the faces to which - --- degenerated edge belongs to - --- - Faces(me) - returns ListOfInteger from TColStd; - ---C++: return const & - ---Purpose: - --- Selector - --- - ChangeFaces(me:out) - returns ListOfInteger from TColStd; - ---C++: return & - ---Purpose: - --- Selector/Modifier - --- - Vertex(me) - returns Integer from Standard; - ---Purpose: - --- Selector - --- - -fields - myFaces : ListOfInteger from TColStd; - myVertex : Integer from Standard; - -end DEInfo; diff --git a/src/BOPTools/BOPTools_DEInfo.cxx b/src/BOPTools/BOPTools_DEInfo.cxx deleted file mode 100755 index d58ab986ce..0000000000 --- a/src/BOPTools/BOPTools_DEInfo.cxx +++ /dev/null @@ -1,80 +0,0 @@ -// Created on: 2001-09-12 -// Created by: Peter KURNEV -// Copyright (c) 2001-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include -#include - -//======================================================================= -// function: BOPTools_DEInfo::BOPTools_DEInfo -// purpose: -//======================================================================= -BOPTools_DEInfo::BOPTools_DEInfo() -{} - -//======================================================================= -// function: SetVertex -// purpose: -//======================================================================= - void BOPTools_DEInfo::SetVertex(const Standard_Integer nV) -{ - myVertex=nV; -} - -//======================================================================= -// function: Vertex -// purpose: -//======================================================================= - Standard_Integer BOPTools_DEInfo::Vertex()const -{ - return myVertex; -} -//======================================================================= -// function: SetFaces -// purpose: -//======================================================================= - void BOPTools_DEInfo::SetFaces(const TColStd_ListOfInteger& aLI) -{ - myFaces.Clear(); - - TColStd_ListIteratorOfListOfInteger anIt(aLI); - for (; anIt.More(); anIt.Next()) { - Standard_Integer nF=anIt.Value(); - myFaces.Append(nF); - } -} -//======================================================================= -// function: Faces -// purpose: -//======================================================================= - const TColStd_ListOfInteger& BOPTools_DEInfo::Faces()const -{ - return myFaces; -} -//======================================================================= -// function: ChangeFaces -// purpose: -//======================================================================= - TColStd_ListOfInteger& BOPTools_DEInfo::ChangeFaces() -{ - return myFaces; -} - - diff --git a/src/BOPTools/BOPTools_DEProcessor.cdl b/src/BOPTools/BOPTools_DEProcessor.cdl deleted file mode 100755 index 1c583a4c93..0000000000 --- a/src/BOPTools/BOPTools_DEProcessor.cdl +++ /dev/null @@ -1,128 +0,0 @@ --- Created on: 2001-09-12 --- Created by: Peter KURNEV --- Copyright (c) 2001-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class DEProcessor from BOPTools - - ---Purpose: - -- - -- The Algorithm to compute and store in interferences' pool - --- and in the Data Structure the following values - --- for degenerated edges - --- 1. Paves/Pave set(s) - --- 2. Split parts - --- 3. States (3D) for split parts - --- - -uses - - Vertex from TopoDS, - Edge from TopoDS, - Face from TopoDS, - - PPaveFiller from BOPTools, - PaveFiller from BOPTools, - ListOfPaveBlock from BOPTools, - - PShapesDataStructure from BooleanOperations, - - IndexedDataMapOfIntegerDEInfo from BOPTools - - - -is - Create (aFiller: PaveFiller from BOPTools; - aDim : Integer from Standard=3) - returns DEProcessor from BOPTools; - ---Purpose: - --- Constructor - --- - Do(me:out); - ---Purpose: - --- Launches the processor - --- - IsDone(me) - returns Boolean from Standard; - ---Purpose: - --- Returns TRUE if it is Ok - --- - --- - --- Private block - --- - --- - FindDegeneratedEdges (me:out) - is private; - - DoPaves (me:out) - is private; - - FindPaveBlocks (me:out; - nED:Integer from Standard; - nVD:Integer from Standard; - nFD:Integer from Standard; - aLPB:out ListOfPaveBlock from BOPTools) - is private; - - FillPaveSet (me:out; - nED:Integer from Standard; - nVD:Integer from Standard; - nFD:Integer from Standard; - aLPB:out ListOfPaveBlock from BOPTools) - is private; - - FillSplitEdgesPool(me:out; - nED:Integer from Standard) - is private; - - MakeSplitEdges(me:out; - nED:Integer from Standard; - nFD:Integer from Standard) - is private; - - MakeSplitEdge (me:out; - aS1: Edge from TopoDS; - aF : Face from TopoDS; - aV1: Vertex from TopoDS; - aP1: Real from Standard; - aV2: Vertex from TopoDS; - aP2: Real from Standard; - aNewEdge:out Edge from TopoDS) - is private; - - DoStates (me:out; - nED:Integer from Standard; - nFD:Integer from Standard) - is private; - - DoStates2D (me:out; - nED:Integer from Standard; - nFD:Integer from Standard) - is private; - -fields - myDim : Integer from Standard; - - myFiller : PPaveFiller from BOPTools; - myDS : PShapesDataStructure from BooleanOperations; - myIsDone : Boolean from Standard; - myDEMap : IndexedDataMapOfIntegerDEInfo from BOPTools; - - -end DEProcessor; diff --git a/src/BOPTools/BOPTools_DEProcessor.cxx b/src/BOPTools/BOPTools_DEProcessor.cxx deleted file mode 100755 index 3be784a8b1..0000000000 --- a/src/BOPTools/BOPTools_DEProcessor.cxx +++ /dev/null @@ -1,713 +0,0 @@ -// Created on: 2001-09-12 -// Created by: Peter KURNEV -// Copyright (c) 2001-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#include - - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//======================================================================= -// function: BOPTools_DEProcessor::BOPTools_DEProcessor -// purpose: -//======================================================================= -BOPTools_DEProcessor::BOPTools_DEProcessor(const BOPTools_PaveFiller& aFiller, - const Standard_Integer aDim) -: - myIsDone(Standard_False) -{ - myFiller=(BOPTools_PaveFiller*) &aFiller; - myDS=myFiller->DS(); - - myDim=aDim; - if (aDim<2 || aDim>3) { - myDim=3; - } - -} - -//======================================================================= -// function: IsDone -// purpose: -//======================================================================= - Standard_Boolean BOPTools_DEProcessor::IsDone() const -{ - return myIsDone; -} -//======================================================================= -// function: Do -// purpose: -//======================================================================= - void BOPTools_DEProcessor::Do() -{ - Standard_Integer aNbE; - myIsDone=Standard_False; - - FindDegeneratedEdges(); - aNbE=myDEMap.Extent(); - - if (!aNbE) { - myIsDone=Standard_True; - return; - } - - DoPaves(); -} - -//======================================================================= -// function: FindDegeneratedEdges -// purpose: -//======================================================================= - void BOPTools_DEProcessor::FindDegeneratedEdges() -{ - const BooleanOperations_ShapesDataStructure& aDS=*myDS; - const BOPTools_PaveFiller& aPaveFiller=*myFiller; - - Standard_Integer i, aNbSourceShapes, nV, nF, nVx, ip, iRankE; - TopAbs_ShapeEnum aType; - - const TopoDS_Shape& anObj=aDS.Object(); - const TopoDS_Shape& aTool=aDS.Tool(); - - TopTools_IndexedDataMapOfShapeListOfShape aMEF; - TopExp::MapShapesAndAncestors (anObj, TopAbs_EDGE, TopAbs_FACE, aMEF); - TopExp::MapShapesAndAncestors (aTool, TopAbs_EDGE, TopAbs_FACE, aMEF); - - aNbSourceShapes=aDS.NumberOfSourceShapes(); - for (i=1; i<=aNbSourceShapes; i++) { - const TopoDS_Shape& aS=aDS.Shape(i); - aType=aS.ShapeType(); - if (aType==TopAbs_EDGE) { - const TopoDS_Edge& aE=TopoDS::Edge(aS); - if (BRep_Tool::Degenerated(aE)) { - - iRankE=aDS.Rank(i); - - TopoDS_Vertex aV=TopExp::FirstVertex(aE); - - nVx=aDS.ShapeIndex(aV, iRankE); - // - nV=nVx; - ip=aPaveFiller.FindSDVertex(nV); - if (ip) { - nV=ip; - } - // - TColStd_ListOfInteger aLFn; - const TopTools_ListOfShape& aLF=aMEF.FindFromKey(aE); - TopTools_ListIteratorOfListOfShape anIt(aLF); - for (; anIt.More(); anIt.Next()) { - const TopoDS_Shape& aF=anIt.Value(); - - nF=aDS.ShapeIndex(aF, iRankE); - - aLFn.Append(nF); - } - BOPTools_DEInfo aDEInfo; - aDEInfo.SetVertex(nV); - aDEInfo.SetFaces(aLFn); - - myDEMap.Add (i, aDEInfo); - - } - } - } - -} -//======================================================================= -// function: DoPaves -// purpose: -//======================================================================= - void BOPTools_DEProcessor::DoPaves() -{ - - Standard_Integer i, aNbE, nED, nVD, nFD=0; - - aNbE=myDEMap.Extent(); - for (i=1; i<=aNbE; i++) { - nED=myDEMap.FindKey(i); - - const BOPTools_DEInfo& aDEInfo=myDEMap(i); - nVD=aDEInfo.Vertex(); - // Fill PaveSet for the edge nED - const TColStd_ListOfInteger& nLF=aDEInfo.Faces(); - TColStd_ListIteratorOfListOfInteger anIt(nLF); - for (; anIt.More(); anIt.Next()) { - nFD=anIt.Value(); - - BOPTools_ListOfPaveBlock aLPB; - FindPaveBlocks(nED, nVD, nFD, aLPB); - FillPaveSet (nED, nVD, nFD, aLPB); - } - // - // Fill aSplitEdges for the edge nED - FillSplitEdgesPool(nED); - // - // MakeSplitEdges - MakeSplitEdges(nED, nFD); - // - // Compute States for Split parts - if (myDim==3) { - DoStates(nED, nFD); - } - if (myDim==2) { - DoStates2D(nED, nFD); - } - }// next nED -} - -//======================================================================= -// function: DoStates -// purpose: -//======================================================================= - void BOPTools_DEProcessor::DoStates (const Standard_Integer nED, - const Standard_Integer nFD) -{ - - - const BOPTools_SplitShapesPool& aSplitShapesPool=myFiller->SplitShapesPool(); - const BOPTools_ListOfPaveBlock& aSplitEdges=aSplitShapesPool(myDS->RefEdge(nED)); - - const TopoDS_Edge& aDE=TopoDS::Edge(myDS->Shape(nED)); - const TopoDS_Face& aDF=TopoDS::Face(myDS->Shape(nFD)); - - Standard_Integer nSp, iRank; - Standard_Real aT, aT1, aT2, aTol=1e-7; - TopoDS_Face aF; - gp_Pnt2d aPx2DNear; - gp_Pnt aPxNear; - - iRank=myDS->Rank(nED); - const TopoDS_Shape& aReference=(iRank==1) ? myDS->Tool() : myDS->Object(); - - BRepExtrema_DistShapeShape aDSS; - aDSS.LoadS1(aReference); - - aF=aDF; - aF.Orientation(TopAbs_FORWARD); - - BOPTools_ListIteratorOfListOfPaveBlock aPBIt(aSplitEdges); - - for (; aPBIt.More(); aPBIt.Next()) { - BOPTools_PaveBlock& aPB=aPBIt.Value(); - - nSp=aPB.Edge(); - const TopoDS_Edge& aSp=TopoDS::Edge(myDS->Shape(nSp)); - - aPB.Parameters(aT1, aT2); - aT=IntTools_Tools::IntermediatePoint(aT1, aT2); - - TopoDS_Edge aDERight, aSpRight; - aDERight=aDE; - aSpRight=aSp; - - BOPTools_Tools3D::OrientEdgeOnFace (aDE, aF, aDERight); - aSpRight.Orientation(aDERight.Orientation()); - // - { - BRepAdaptor_Surface aBAS; - aBAS.Initialize (aDF, Standard_False); - - if (aBAS.GetType()==GeomAbs_Sphere) { - Standard_Real aDt2D, aR, aDelta=1.e-14; - - gp_Sphere aSphere=aBAS.Sphere(); - aR=aSphere.Radius(); - // - aDt2D=acos (1.-4.*aTol/aR)+aDelta ; - // - BOPTools_Tools3D::PointNearEdge(aSpRight, aF, aT, aDt2D, aPx2DNear, aPxNear); - } - else { - BOPTools_Tools3D::PointNearEdge(aSpRight, aF, aT, aPx2DNear, aPxNear); - } - } - // - TopAbs_State aState; - // - TopAbs_ShapeEnum aTypeReference; - aTypeReference=aReference.ShapeType(); - - if (aTypeReference==TopAbs_SOLID) { - // ... \ Solid processing - const Handle(IntTools_Context)& aContext=myFiller->Context(); - const TopoDS_Solid& aReferenceSolid=TopoDS::Solid(aReference); - BRepClass3d_SolidClassifier& SC=aContext->SolidClassifier(aReferenceSolid); - // - SC.Perform(aPxNear, aTol); - // - aState=SC.State(); - } - // - - else if (aTypeReference==TopAbs_SHELL || - aTypeReference==TopAbs_FACE) { - // ... \ Shell processing - TopoDS_Vertex aVxNear; - BRep_Builder BB; - - BB.MakeVertex(aVxNear, aPxNear, aTol); - - aDSS.LoadS2(aVxNear); - aDSS.Perform(); - - aState=TopAbs_OUT; - if (aDSS.IsDone()) { - Standard_Real aDist=aDSS.Value(); - if (aDist < aTol) { - aState=TopAbs_ON; - } - } - } - else { - // unknown aTypeReference - aState=TopAbs_OUT; - } - // - BooleanOperations_StateOfShape aSt; - - aSt=BOPTools_StateFiller::ConvertState(aState); - - myDS->SetState(nSp, aSt); - } -} -//======================================================================= -// function: DoStates2D -// purpose: -//======================================================================= - void BOPTools_DEProcessor::DoStates2D (const Standard_Integer nED, - const Standard_Integer nFD) -{ - - - const BOPTools_SplitShapesPool& aSplitShapesPool=myFiller->SplitShapesPool(); - const BOPTools_ListOfPaveBlock& aSplitEdges=aSplitShapesPool(myDS->RefEdge(nED)); - - const TopoDS_Edge& aDE=TopoDS::Edge(myDS->Shape(nED)); - const TopoDS_Face& aDF=TopoDS::Face(myDS->Shape(nFD)); - - Standard_Integer nSp, iRank; - Standard_Real aT, aT1, aT2; - TopoDS_Face aF; - gp_Pnt2d aPx2DNear; - gp_Pnt aPxNear; - - iRank=myDS->Rank(nED); - const TopoDS_Shape& aReference=(iRank==1) ? myDS->Tool() : myDS->Object(); - const TopoDS_Face& aFaceReference=TopoDS::Face(aReference); - - aF=aDF; - aF.Orientation(TopAbs_FORWARD); - - BOPTools_ListIteratorOfListOfPaveBlock aPBIt(aSplitEdges); - - for (; aPBIt.More(); aPBIt.Next()) { - BOPTools_PaveBlock& aPB=aPBIt.Value(); - - nSp=aPB.Edge(); - const TopoDS_Edge& aSp=TopoDS::Edge(myDS->Shape(nSp)); - - aPB.Parameters(aT1, aT2); - aT=IntTools_Tools::IntermediatePoint(aT1, aT2); - - TopoDS_Edge aDERight, aSpRight; - aDERight=aDE; - aSpRight=aSp; - - BOPTools_Tools3D::OrientEdgeOnFace (aDE, aF, aDERight); - aSpRight.Orientation(aDERight.Orientation()); - // - BOPTools_Tools3D::PointNearEdge(aSpRight, aDF, aT, aPx2DNear, aPxNear); - // - Standard_Boolean bIsValidPoint; - TopAbs_State aState=TopAbs_OUT; - // - const Handle(IntTools_Context)& aContext=myFiller->Context(); - bIsValidPoint=aContext->IsValidPointForFace(aPxNear, aFaceReference, 1.e-3); - // - if (bIsValidPoint) { - aState=TopAbs_IN; - } - // - BooleanOperations_StateOfShape aSt; - - aSt=BOPTools_StateFiller::ConvertState(aState); - - myDS->SetState(nSp, aSt); - } -} - -//======================================================================= -// function: FillSplitEdgesPool -// purpose: -//======================================================================= - void BOPTools_DEProcessor::FillSplitEdgesPool (const Standard_Integer nED) -{ - BOPTools_SplitShapesPool& aSplitShapesPool=myFiller->ChangeSplitShapesPool(); - // - BOPTools_ListOfPaveBlock& aSplitEdges=aSplitShapesPool.ChangeValue(myDS->RefEdge(nED)); - // - aSplitEdges.Clear(); - // - const BOPTools_PavePool& aPavePool=myFiller->PavePool(); - BOPTools_PavePool* pPavePool=(BOPTools_PavePool*) &aPavePool; - BOPTools_PaveSet& aPaveSet= pPavePool->ChangeValue(myDS->RefEdge(nED)); - - BOPTools_PaveBlockIterator aPBIt(nED, aPaveSet); - for (; aPBIt.More(); aPBIt.Next()) { - BOPTools_PaveBlock& aPB=aPBIt.Value(); - aSplitEdges.Append(aPB); - } -} - -//======================================================================= -// function: MakeSplitEdges -// purpose: -//======================================================================= - void BOPTools_DEProcessor::MakeSplitEdges (const Standard_Integer nED, - const Standard_Integer nFD) -{ - const BOPTools_SplitShapesPool& aSplitShapesPool=myFiller->SplitShapesPool(); - const BOPTools_ListOfPaveBlock& aSplitEdges=aSplitShapesPool(myDS->RefEdge(nED)); - - Standard_Integer nV1, nV2, aNewShapeIndex; - Standard_Real t1, t2; - TopoDS_Edge aE, aESplit; - TopoDS_Vertex aV1, aV2; - - const TopoDS_Edge aDE=TopoDS::Edge(myDS->Shape(nED)); - const TopoDS_Face aDF=TopoDS::Face(myDS->Shape(nFD)); - - BOPTools_ListIteratorOfListOfPaveBlock aPBIt(aSplitEdges); - - for (; aPBIt.More(); aPBIt.Next()) { - BOPTools_PaveBlock& aPB=aPBIt.Value(); - - const BOPTools_Pave& aPave1=aPB.Pave1(); - nV1=aPave1.Index(); - t1=aPave1.Param(); - aV1=TopoDS::Vertex(myDS->GetShape(nV1)); - aV1.Orientation(TopAbs_FORWARD); - - const BOPTools_Pave& aPave2=aPB.Pave2(); - nV2=aPave2.Index(); - t2=aPave2.Param(); - aV2=TopoDS::Vertex(myDS->GetShape(nV2)); - aV2.Orientation(TopAbs_REVERSED); - - MakeSplitEdge(aDE, aDF, aV1, t1, aV2, t2, aESplit); - // - // Add Split Part of the Original Edge to the DS - BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq; - - anASSeq.SetNewSuccessor(nV1); - anASSeq.SetNewOrientation(aV1.Orientation()); - - anASSeq.SetNewSuccessor(nV2); - anASSeq.SetNewOrientation(aV2.Orientation()); - - myDS->InsertShapeAndAncestorsSuccessors(aESplit, anASSeq); - aNewShapeIndex=myDS->NumberOfInsertedShapes(); - myDS->SetState(aNewShapeIndex, BooleanOperations_UNKNOWN); - // - // Fill Split Set for the Original Edge - aPB.SetEdge(aNewShapeIndex); - // - } -} -//======================================================================= -// function: MakeSplitEdge -// purpose: -//======================================================================= - void BOPTools_DEProcessor::MakeSplitEdge (const TopoDS_Edge& aE, - const TopoDS_Face& aF, - const TopoDS_Vertex& aV1, - const Standard_Real aP1, - const TopoDS_Vertex& aV2, - const Standard_Real aP2, - TopoDS_Edge& aNewEdge) -{ - Standard_Real aTol=1.e-7; - - TopoDS_Edge E=aE; - - E.EmptyCopy(); - BRep_Builder BB; - BB.Add (E, aV1); - BB.Add (E, aV2); - - BB.Range(E, aF, aP1, aP2); - - BB.Degenerated(E, Standard_True); - - BB.UpdateEdge(E, aTol); - aNewEdge=E; -} - - - -//======================================================================= -// function: FillPaveSet -// purpose: -//======================================================================= - void BOPTools_DEProcessor::FillPaveSet (const Standard_Integer nED, - const Standard_Integer nVD, - const Standard_Integer nFD, - BOPTools_ListOfPaveBlock& aLPB) -{ - Standard_Boolean bIsDone, bXDir; - Standard_Integer nE, aNbPoints, j; - Standard_Real aTD1, aTD2, aT1, aT2, aTolInter, aX, aDT; - // - aDT=Precision::PConfusion(); - // - BOPTools_PaveSet& aPaveSet= (myFiller->ChangePavePool()).ChangeValue(myDS->RefEdge(nED)); - // - // Clear aPaveSet, aSplitEdges - aPaveSet.ChangeSet().Clear(); - // - const TopoDS_Edge& aDE=TopoDS::Edge(myDS->Shape(nED)); - const TopoDS_Face& aDF=TopoDS::Face(myDS->Shape(nFD)); - // - // 2D Curve of degenerated edge on the face aDF - Handle(Geom2d_Curve) aC2DDE=BRep_Tool::CurveOnSurface(aDE, aDF, aTD1, aTD2); - // - // Choose direction for Degenerated Edge - gp_Pnt2d aP2d1, aP2d2; - aC2DDE->D0(aTD1, aP2d1); - aC2DDE->D0(aTD2, aP2d2); - - bXDir=Standard_False; - if (fabs(aP2d1.Y()-aP2d2.Y()) < aDT){ - bXDir=!bXDir; - } - // - // Prepare bounding Paves - BOPTools_Pave aPave1 (nVD, aTD1, BooleanOperations_UnknownInterference); - aPaveSet.Append(aPave1); - BOPTools_Pave aPave2 (nVD, aTD2, BooleanOperations_UnknownInterference); - aPaveSet.Append(aPave2); - // - // Fill other paves - BOPTools_ListIteratorOfListOfPaveBlock anIt(aLPB); - for (; anIt.More(); anIt.Next()) { - const BOPTools_PaveBlock& aPB=anIt.Value(); - nE=aPB.Edge(); - const TopoDS_Edge& aE=TopoDS::Edge(myDS->Shape(nE)); - - Handle(Geom2d_Curve) aC2D=BRep_Tool::CurveOnSurface(aE, aDF, aT1, aT2); - // - // Intersection - aTolInter=0.001; - - - Geom2dAdaptor_Curve aGAC1, aGAC2; - - aGAC1.Load(aC2DDE, aTD1, aTD2); - Handle(Geom2d_Line) aL2D= Handle(Geom2d_Line)::DownCast(aC2D); - if (!aL2D.IsNull()) { - aGAC2.Load(aC2D); - } - else { - aGAC2.Load(aC2D, aT1, aT2); - } - - Geom2dInt_GInter aGInter(aGAC1, aGAC2, aTolInter, aTolInter); - - bIsDone=aGInter.IsDone(); - if(bIsDone) { - aNbPoints=aGInter.NbPoints(); - if (aNbPoints) { - for (j=1; j<=aNbPoints; ++j) { - gp_Pnt2d aP2D=aGInter.Point(j).Value(); - // - aX=(bXDir) ? aP2D.X(): aP2D.Y(); - // - if (fabs (aX-aTD1) < aDT || fabs (aX-aTD2) < aDT) { - continue; - } - if (aX < aTD1 || aX > aTD2) { - continue; - } - // - Standard_Boolean bRejectFlag=Standard_False; - const BOPTools_ListOfPave& aListOfPave=aPaveSet.Set(); - BOPTools_ListIteratorOfListOfPave aPaveIt(aListOfPave); - for (; aPaveIt.More(); aPaveIt.Next()) { - const BOPTools_Pave& aPavex=aPaveIt.Value(); - Standard_Real aXx=aPavex.Param(); - if (fabs (aX-aXx) < aDT) { - bRejectFlag=Standard_True; - break; - } - } - if (bRejectFlag) { - continue; - } - // - BOPTools_Pave aPave(nVD, aX, BooleanOperations_UnknownInterference); - aPaveSet.Append(aPave); - } - } - } - } -} - -//======================================================================= -// function: FindPaveBlocks -// purpose: -//======================================================================= - void BOPTools_DEProcessor::FindPaveBlocks(const Standard_Integer , - const Standard_Integer nVD, - const Standard_Integer nFD, - BOPTools_ListOfPaveBlock& aLPBOut) -{ - - BOPTools_CArray1OfSSInterference& aFFs=(myFiller->InterfPool())->SSInterferences(); - - BOPTools_ListIteratorOfListOfPaveBlock anIt; - Standard_Integer i, aNb, nF2, nSp, nV; - - //ZZ const TopoDS_Edge& aDE=TopoDS::Edge(myDS->Shape(nED)); - - aNb=aFFs.Extent(); - for (i=1; i<=aNb; i++) { - BOPTools_SSInterference& aFF=aFFs(i); - // - nF2=aFF.OppositeIndex(nFD); - if (!nF2) { - continue; - } - // - // Split Parts - const BOPTools_ListOfPaveBlock& aLPBSplits=aFF.PaveBlocks(); - anIt.Initialize(aLPBSplits); - for (; anIt.More(); anIt.Next()) { - const BOPTools_PaveBlock& aPBSp=anIt.Value(); - nSp=aPBSp.Edge(); - - const BOPTools_Pave& aPave1=aPBSp.Pave1(); - nV=aPave1.Index(); - if (nV==nVD) { - aLPBOut.Append(aPBSp); - continue; - } - - const BOPTools_Pave& aPave2=aPBSp.Pave2(); - nV=aPave2.Index(); - if (nV==nVD) { - aLPBOut.Append(aPBSp); - continue; - } - } - // - // Section Parts - Standard_Integer j, aNbCurves; - BOPTools_SequenceOfCurves& aSC=aFF.Curves(); - aNbCurves=aSC.Length(); - - for (j=1; j<=aNbCurves; j++) { - const BOPTools_Curve& aBC=aSC(j); - const BOPTools_ListOfPaveBlock& aLPBSe=aBC.NewPaveBlocks(); - - anIt.Initialize(aLPBSe); - for (; anIt.More(); anIt.Next()) { - const BOPTools_PaveBlock& aPBSe=anIt.Value(); - - const BOPTools_Pave& aPv1=aPBSe.Pave1(); - nV=aPv1.Index(); - if (nV==nVD) { - aLPBOut.Append(aPBSe); - continue; - } - - const BOPTools_Pave& aPv2=aPBSe.Pave2(); - nV=aPv2.Index(); - if (nV==nVD) { - aLPBOut.Append(aPBSe); - continue; - } - } - } - - } // for (i=1; i<=aNb; i++) Next FF interference - -} diff --git a/src/BOPTools/BOPTools_DSFiller.cdl b/src/BOPTools/BOPTools_DSFiller.cdl deleted file mode 100755 index cd6edb187f..0000000000 --- a/src/BOPTools/BOPTools_DSFiller.cdl +++ /dev/null @@ -1,178 +0,0 @@ --- Created on: 2001-02-20 --- Created by: Peter KURNEV --- Copyright (c) 2001-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class DSFiller from BOPTools - - ---Purpose: - --- class that provides - --- 1. creation of the data structure (DS) - --- 2. creation of the interferences' pool - --- 3. invokation of PaveFiller->Perform() to fill the DS - --- -uses - Shape from TopoDS, - ShapesDataStructure from BooleanOperations, - PShapesDataStructure from BooleanOperations, - InterferencePool from BOPTools, - PInterferencePool from BOPTools, - PavePool from BOPTools, - PPaveFiller from BOPTools, - PaveFiller from BOPTools, - SSIntersectionAttribute from BOPTools, - SplitShapesPool from BOPTools, - CommonBlockPool from BOPTools, - DataMapOfIntegerListOfInteger from TColStd, - SetOfInteger from TColStd - -is - Create - returns DSFiller from BOPTools; - ---Purpose: - --- Empty constructor - --- - Destroy (me:out); - ---C++: alias ~ - ---Purpose: Destructor - --- - SetShapes (me:out; aS1, aS2: Shape from TopoDS); - ---Purpose: - --- Modifier - --- Sets the arguments of boolean operation - --- - Shape1(me) - returns Shape from TopoDS; - ---C++: return const& - ---Purpose: - --- Selector - --- - Shape2(me) - returns Shape from TopoDS; - ---C++: return const& - ---Purpose: - --- Selector - --- - Perform (me:out); - ---Purpose: - --- Performs the filling of the DS - --- - - InitFillersAndPools(me:out); - - PartialPerform(me:out; anObjSubSet, aToolSubSet: SetOfInteger from TColStd); - - ToCompletePerform(me:out); - - Perform (me:out; theSectionAttribute: SSIntersectionAttribute from BOPTools); - ---Purpose: - --- Performs the filling of the DS - --- - DS (me) - returns ShapesDataStructure from BooleanOperations; - ---C++: return const& - ---Purpose: - --- Selector - --- - InterfPool (me) - returns InterferencePool from BOPTools; - ---C++: return const & - ---Purpose: - --- Selector - --- - PavePool (me) - returns PavePool from BOPTools; - ---C++: return const& - ---Purpose: - --- Selector - --- - CommonBlockPool(me) - returns CommonBlockPool from BOPTools; - ---C++:return const & - ---Purpose: - --- Selector - --- - SplitShapesPool(me) - returns SplitShapesPool from BOPTools; - ---C++:return const & - ---Purpose: - --- Selector - --- - PaveFiller (me) - returns PaveFiller from BOPTools; - ---C++:return const & - ---Purpose: - --- Selector - --- - Clear (me:out) - is private; - ---Purpose: - --- Clear contents of the DS and the interferences' pool - --- - IsNewFiller(me) - returns Boolean from Standard; - ---Purpose: - --- Returns TRUE if new DS and the interferences' pool has been created - --- - SetNewFiller(me; - aFlag:Boolean from Standard); - ---Purpose: - --- Modifier - --- - IsDone(me) - returns Boolean from Standard; - ---Purpose: - --- Selector - --- - SplitFacePool(me) - ---C++: return const& - ---C++: inline - returns DataMapOfIntegerListOfInteger from TColStd; - - ChangeSplitFacePool(me: out) - ---C++: return & - ---C++: inline - returns DataMapOfIntegerListOfInteger from TColStd; - - --modified by NIZHNY-MKK Tue Sep 7 12:03:34 2004 - TreatCompound(myclass; theShape: Shape from TopoDS; - theShapeResult: out Shape from TopoDS) - returns Integer from Standard; - ---Purpose: Finds sub-shapes of theShape having equal type - -- and store them in theShapeResult. - -- Returns the following status codes: - -- 0 - OK - -- 1 - Error: theShape is a COMPSOLID - -- 2 - Error: theShape is not a COMPOUND - -- 3 - Error: theShape contains shapes of COMPSOLID type - -- 4 - Error: Subshape of theShape have unkown type - -- 5 - Error: theShape contains shapes of different type - -fields - myShape1 : Shape from TopoDS; - myShape2 : Shape from TopoDS; - myDS : PShapesDataStructure from BooleanOperations; - myInterfPool : PInterferencePool from BOPTools; - myPaveFiller : PPaveFiller from BOPTools; - myIsDone : Boolean from Standard; - mySplitFacePool: DataMapOfIntegerListOfInteger from TColStd; - - myNewFiller : Boolean from Standard; - -end DSFiller; diff --git a/src/BOPTools/BOPTools_DSFiller.cxx b/src/BOPTools/BOPTools_DSFiller.cxx deleted file mode 100755 index 58a7b2d6df..0000000000 --- a/src/BOPTools/BOPTools_DSFiller.cxx +++ /dev/null @@ -1,696 +0,0 @@ -// Created on: 2001-02-20 -// Created by: Peter KURNEV -// Copyright (c) 2001-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#include -#include - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -static - void FillList(const TopoDS_Shape& aS, - Standard_Boolean& bCompSolidFound, - TopTools_ListOfShape& aResultList); -static - void BuildSolid(const TopTools_ListOfShape& aRL, TopoDS_Shape& aS); -static - void BuildShell(const TopTools_ListOfShape& aRL, TopoDS_Shape& aS); -static - void BuildWire (const TopTools_ListOfShape& aRL, TopoDS_Shape& aS); -static - TopAbs_ShapeEnum GetTypeCurrent(const TopAbs_ShapeEnum aTypeX); - -// static -// Standard_Integer TreatCompound(const TopoDS_Shape& aS, -// TopoDS_Shape& aShapeResult); - -// Peter KURNEV -// p-kurnev@opencascade.com -//======================================================================= -// function: BOPTools_PoolsFiller -// purpose: -//======================================================================= - BOPTools_DSFiller::BOPTools_DSFiller() -{ - myPaveFiller=NULL; - myInterfPool=NULL; - myDS=NULL; - myNewFiller=Standard_True; - myIsDone=Standard_False; -} -//======================================================================= -// function: Clear -// purpose: -//======================================================================= - void BOPTools_DSFiller::Clear() -{ - if (myPaveFiller!=NULL) { - delete myPaveFiller; - } - if (myInterfPool!=NULL) { - delete myInterfPool; - } - if (myDS!=NULL) { - delete myDS; - } - myPaveFiller=NULL; - myInterfPool=NULL; - myDS=NULL; -} - -//======================================================================= -// function: Perform -// purpose: -//======================================================================= - void BOPTools_DSFiller::Perform() -{ - myIsDone=Standard_False; - - if (myShape1.IsNull() || myShape2.IsNull()) { - return; - } - // - // Clear contents of the DS if it was before - Clear(); - // - myNewFiller=Standard_True; - // - myDS = new BooleanOperations_ShapesDataStructure (myShape1, myShape2); - myInterfPool= new BOPTools_InterferencePool (*myDS); - // - // Build Vertices, Paves, splits, - myPaveFiller = new BOPTools_PaveFiller(*myInterfPool); - myPaveFiller->Perform(); - myIsDone=myPaveFiller->IsDone(); -} - -//======================================================================= -// function: InitFillersAndPools -// purpose: -//======================================================================= - void BOPTools_DSFiller::InitFillersAndPools() -{ - myIsDone=Standard_False; - - if (myShape1.IsNull() || myShape2.IsNull()) { - return; - } - // - // Clear contents of the DS if it was before - Clear(); - // - myNewFiller=Standard_True; - // - myDS = new BooleanOperations_ShapesDataStructure (myShape1, myShape2); - myInterfPool= new BOPTools_InterferencePool (*myDS); - // - myPaveFiller = new BOPTools_PaveFiller(*myInterfPool); -} - -//======================================================================= -// function: PartialPerform -// purpose: -//======================================================================= - void BOPTools_DSFiller::PartialPerform(const TColStd_SetOfInteger& anObjSubSet, - const TColStd_SetOfInteger& aToolSubSet) -{ - myIsDone=Standard_False; - - // - // Build Vertices, Paves, splits, - myPaveFiller->PartialPerform(anObjSubSet, aToolSubSet); - myIsDone=myPaveFiller->IsDone(); - -} - -//======================================================================= -// function: ToCompletePerform -// purpose: -//======================================================================= - void BOPTools_DSFiller::ToCompletePerform() -{ - if(myIsDone) { - myIsDone=Standard_False; - // - myPaveFiller->ToCompletePerform(); - myIsDone=myPaveFiller->IsDone(); - if(myIsDone) { - // Check if any interference exists - myIsDone=Standard_False; - - Standard_Integer nbs = myDS->NumberOfNewShapes(); - if(nbs > 0) { - myIsDone=Standard_True; - return; - } - - } - } -} - -//======================================================================= -// function: Perform -// purpose: -//======================================================================= - void BOPTools_DSFiller::Perform(const BOPTools_SSIntersectionAttribute& theSectionAttribute) -{ - myIsDone=Standard_False; - - if (myShape1.IsNull() || myShape2.IsNull()) { - return; - } - // - // Clear contents of the DS if it was before - Clear(); - // - myNewFiller=Standard_True; - // - myDS = new BooleanOperations_ShapesDataStructure (myShape1, myShape2); - myInterfPool= new BOPTools_InterferencePool (*myDS); - // - // Build Vertices, Paves, splits, - myPaveFiller = new BOPTools_PaveFiller(*myInterfPool, theSectionAttribute); - myPaveFiller->Perform(); - myIsDone=myPaveFiller->IsDone(); -} - -//======================================================================= -// function:Destroy -// purpose: -//======================================================================= - void BOPTools_DSFiller::Destroy() -{ - Clear(); -} - -//======================================================================= -// function: SetShapes -// purpose: -//======================================================================= - void BOPTools_DSFiller::SetShapes (const TopoDS_Shape& aS1, - const TopoDS_Shape& aS2) -{ - myShape1=aS1; - myShape2=aS2; - // - Standard_Integer aNbShapes; - TopAbs_ShapeEnum aT1, aT2; - aT1=aS1.ShapeType(); - aT2=aS2.ShapeType(); - // - if (aT1==TopAbs_COMPOUND || aT2==TopAbs_COMPOUND) { - Standard_Boolean bIsEmptyShape1, bIsEmptyShape2; - - bIsEmptyShape1=BOPTools_Tools3D::IsEmptyShape(myShape1); - bIsEmptyShape2=BOPTools_Tools3D::IsEmptyShape(myShape2); - if (bIsEmptyShape1 || bIsEmptyShape2) { - myIsDone=Standard_True; - return; - } - } - // - // 1.1 - TopoDS_Iterator anIt; - TopoDS_Shape aSTmp; - - if (aT1==TopAbs_COMPOUND || aT1==TopAbs_COMPSOLID) { - aNbShapes=0; - anIt.Initialize(aS1); - for (; anIt.More(); anIt.Next()) { - if (!aNbShapes) { - aSTmp=anIt.Value(); - } - aNbShapes++; - if (aNbShapes>1) { - break; - } - } - // - if (aT1==TopAbs_COMPOUND) { - if (aNbShapes==1) { - TreatCompound(aS1, aSTmp); - myShape1=aSTmp; - aT1=myShape1.ShapeType(); - } - else if (aNbShapes>1) { - TreatCompound(aS1, aSTmp); - myShape1=aSTmp; - aT1=myShape1.ShapeType(); - } - } - } - // - - if (aT1==TopAbs_COMPOUND || aT1==TopAbs_COMPSOLID) { - myIsDone=Standard_False; - return; - } - // - // 1.2 aS2 - if (aT2==TopAbs_COMPOUND || aT2==TopAbs_COMPSOLID) { - aNbShapes=0; - anIt.Initialize(aS2); - for (; anIt.More(); anIt.Next()) { - if (!aNbShapes) { - aSTmp=anIt.Value(); - } - aNbShapes++; - if (aNbShapes>1) { - break; - } - } - // - if (aT2==TopAbs_COMPOUND) { - if (aNbShapes==1) { - TreatCompound(aS2, aSTmp); - myShape2=aSTmp; - aT2=myShape2.ShapeType(); - } - else if (aNbShapes>1) { - TreatCompound(aS2, aSTmp); - myShape2=aSTmp; - aT2=myShape2.ShapeType(); - } - } - } - // - - if (aT2==TopAbs_COMPOUND || aT2==TopAbs_COMPSOLID) { - myIsDone=Standard_False; - return; - } - // - // 2.1 - BRep_Builder BB; - TopoDS_Shell aSh1, aSh2; - TopoDS_Wire aW1, aW2; - - if (aT1==TopAbs_FACE) { - if (aT2==TopAbs_SOLID || - aT2==TopAbs_SHELL || - aT2==TopAbs_FACE || - aT2==TopAbs_WIRE || - aT2==TopAbs_EDGE) { - BB.MakeShell(aSh1); - BB.Add(aSh1, myShape1); - myShape1=aSh1; - aT1=TopAbs_SHELL; - } - } - // - // 2.2 - if (aT2==TopAbs_FACE) { - if (aT1==TopAbs_SOLID || - aT1==TopAbs_SHELL || - aT1==TopAbs_WIRE || - aT1==TopAbs_EDGE) { - BB.MakeShell(aSh2); - BB.Add(aSh2, myShape2); - myShape2=aSh2; - aT2=TopAbs_SHELL; - } - } - // 3.1 - if (aT1==TopAbs_EDGE) { - if (aT2==TopAbs_SOLID || - aT2==TopAbs_SHELL || - aT2==TopAbs_WIRE || - aT2==TopAbs_EDGE) { - BB.MakeWire (aW1); - BB.Add(aW1, myShape1); - myShape1=aW1; - aT1=TopAbs_WIRE; - } - } - // 3.2 - if (aT2==TopAbs_EDGE) { - if (aT1==TopAbs_SOLID || - aT1==TopAbs_SHELL || - aT1==TopAbs_WIRE) { - BB.MakeWire (aW2); - BB.Add(aW2, myShape2); - myShape2=aW2; - aT2=TopAbs_WIRE; - } - } - - myIsDone=Standard_True; -} - -//======================================================================= -// function: Shape1 -// purpose: -//======================================================================= - const TopoDS_Shape& BOPTools_DSFiller::Shape1 () const -{ - return myShape1; -} - -//======================================================================= -// function: Shape2 -// purpose: -//======================================================================= - const TopoDS_Shape& BOPTools_DSFiller::Shape2 () const -{ - return myShape2; -} -//======================================================================= -// function: DS -// purpose: -//======================================================================= - const BooleanOperations_ShapesDataStructure& BOPTools_DSFiller::DS () const -{ - return *myDS; -} -//======================================================================= -// function: InterfPool -// purpose: -//======================================================================= - const BOPTools_InterferencePool& BOPTools_DSFiller::InterfPool () const -{ - return *myInterfPool; -} -//======================================================================= -// function: PavePool -// purpose: -//======================================================================= - const BOPTools_PavePool& BOPTools_DSFiller::PavePool () const -{ - return myPaveFiller->PavePool(); -} - -//======================================================================= -// function: CommonBlockPool -// purpose: -//======================================================================= - const BOPTools_CommonBlockPool& BOPTools_DSFiller::CommonBlockPool () const -{ - return myPaveFiller->CommonBlockPool(); -} - -//======================================================================= -// function: SplitShapesPool -// purpose: -//======================================================================= - const BOPTools_SplitShapesPool& BOPTools_DSFiller::SplitShapesPool() const -{ - return myPaveFiller->SplitShapesPool(); -} - -//======================================================================= -// function: PaveFiller -// purpose: -//======================================================================= - const BOPTools_PaveFiller& BOPTools_DSFiller::PaveFiller() const -{ - return *myPaveFiller; -} - -//======================================================================= -// function: IsNewFiller -// purpose: -//======================================================================= - Standard_Boolean BOPTools_DSFiller::IsNewFiller() const -{ - return myNewFiller; -} - - -//======================================================================= -// function: SetNewFiller -// purpose: -//======================================================================= - void BOPTools_DSFiller::SetNewFiller(const Standard_Boolean aFlag) const -{ - BOPTools_DSFiller* pDSFiller=(BOPTools_DSFiller*)this; - pDSFiller->myNewFiller=aFlag; -} -//======================================================================= -// function: IsDone -// purpose: -//======================================================================= - Standard_Boolean BOPTools_DSFiller::IsDone()const -{ - return myIsDone; -} -// -//======================================================================= -//function :TreatCompound -//purpose : -//======================================================================= -// Standard_Integer TreatCompound(const TopoDS_Shape& aS, -// TopoDS_Shape& aShapeResult) -Standard_Integer BOPTools_DSFiller::TreatCompound(const TopoDS_Shape& aS, - TopoDS_Shape& aShapeResult) -{ - // - TopAbs_ShapeEnum aType, aTypeX; - // - aType=aS.ShapeType(); - // - if (aType==TopAbs_COMPSOLID) { - aShapeResult=aS; - return 1; - } - // - if (aType!=TopAbs_COMPOUND) { - // Nothing to do - aShapeResult=aS; - return 2; - } - // - // 1 Fill the list by real shapes (solids, shells, wires, edges) - Standard_Boolean bCompSolidFound=Standard_False; - TopTools_ListOfShape aRL1, aRL; - FillList (aS, bCompSolidFound, aRL1); - if (bCompSolidFound) { - aShapeResult=aS; - return 3; - } - // 2 - // Analyse the list and find the type - Standard_Integer i=0; - TopExp_Explorer anExp; - TopAbs_ShapeEnum aTypeCurrent=TopAbs_SHAPE, - aType0=TopAbs_SHAPE; - - //aTypeCurrent=TopAbs_SHAPE; - TopTools_ListIteratorOfListOfShape anItL(aRL1); - for (; anItL.More(); anItL.Next(), i++) { - const TopoDS_Shape& aSX=anItL.Value(); - aTypeX=aSX.ShapeType(); - - aTypeCurrent=GetTypeCurrent(aTypeX); - - if (i==0) { - aType0=aTypeCurrent; - if (aType0==TopAbs_SHAPE) { - // Unknown shape type; - aShapeResult=aS; - return 4; - } - } - - else { - if (aTypeCurrent!=aType0) { - // Heterogenous types occured; - aShapeResult=aS; - return 5; - } - } - // - // Fill the RL - if (aTypeCurrent==TopAbs_SOLID) { - anExp.Init(aSX, TopAbs_SHELL); - for (; anExp.More(); anExp.Next()) { - const TopoDS_Shape& aSY=anExp.Current(); - aRL.Append(aSY); - } - } - // - else if (aTypeCurrent==TopAbs_SHELL) { - if (aTypeX==TopAbs_FACE) { - aRL.Append(aSX); - } - else { - anExp.Init(aSX, TopAbs_FACE); - for (; anExp.More(); anExp.Next()) { - const TopoDS_Shape& aSY=anExp.Current(); - aRL.Append(aSY); - } - } - } - // - else if (aTypeCurrent==TopAbs_WIRE) { - if (aTypeX==TopAbs_EDGE) { - aRL.Append(aSX); - } - else { - anExp.Init(aSX, TopAbs_EDGE); - for (; anExp.More(); anExp.Next()) { - const TopoDS_Shape& aSY=anExp.Current(); - aRL.Append(aSY); - } - } - } - } - // - // Make Composite shape - //BRep_Builder aBB; - - if (aType0==TopAbs_SOLID) { - BuildSolid(aRL, aShapeResult); - } - if (aType0==TopAbs_SHELL) { - BuildShell(aRL, aShapeResult); - } - if (aType0==TopAbs_WIRE) { - BuildWire(aRL, aShapeResult); - } - //OK - return 0; -} -//======================================================================= -//function : BuildSolid -//purpose : -//======================================================================= -void BuildSolid(const TopTools_ListOfShape& aRL, - TopoDS_Shape& aS) -{ - BRep_Builder aBB; - TopoDS_Solid aSolid; - aBB.MakeSolid(aSolid); - TopTools_ListIteratorOfListOfShape anItL; - anItL.Initialize(aRL); - for (; anItL.More(); anItL.Next()) { - const TopoDS_Shape& aSX=anItL.Value(); - aBB.Add(aSolid, TopoDS::Shell(aSX)); - } - aS=aSolid; -} -//======================================================================= -//function : BuildShell -//purpose : -//======================================================================= -void BuildShell(const TopTools_ListOfShape& aRL, - TopoDS_Shape& aS) -{ - BRep_Builder aBB; - TopoDS_Shell aShell; - aBB.MakeShell(aShell); - TopTools_ListIteratorOfListOfShape anItL; - anItL.Initialize(aRL); - for (; anItL.More(); anItL.Next()) { - const TopoDS_Shape& aSX=anItL.Value(); - aBB.Add(aShell, aSX); - } - aS=aShell; -} -//======================================================================= -//function : BuildWire -//purpose : -//======================================================================= -void BuildWire(const TopTools_ListOfShape& aRL, - TopoDS_Shape& aS) -{ - BRep_Builder aBB; - TopoDS_Wire aWire; - aBB.MakeWire(aWire); - TopTools_ListIteratorOfListOfShape anItL; - anItL.Initialize(aRL); - for (; anItL.More(); anItL.Next()) { - const TopoDS_Shape& aSX=anItL.Value(); - aBB.Add(aWire, aSX); - } - aS=aWire; -} -//======================================================================= -//function :FillList -//purpose : -//======================================================================= -void FillList(const TopoDS_Shape& aS, - Standard_Boolean& bCompSolidFound, - TopTools_ListOfShape& aResultList) -{ - if (bCompSolidFound) { - return; - } - TopAbs_ShapeEnum aTypeX; - TopoDS_Iterator anIt; - anIt.Initialize(aS); - for (; anIt.More(); anIt.Next()) { - const TopoDS_Shape& aSX=anIt.Value(); - aTypeX=aSX.ShapeType(); - // - if (aTypeX==TopAbs_COMPSOLID) { - bCompSolidFound=Standard_True; - return; - } - // - if (aTypeX==TopAbs_COMPOUND) { - FillList(aSX, bCompSolidFound, aResultList); - if (bCompSolidFound) { - return; - } - } - if (aTypeX!=TopAbs_COMPOUND) { - aResultList.Append(aSX); - } - - } -} -//======================================================================= -//function :GetTypeCurrent -//purpose : -//======================================================================= -TopAbs_ShapeEnum GetTypeCurrent(const TopAbs_ShapeEnum aTypeX) -{ - TopAbs_ShapeEnum aTypeCurrent=TopAbs_SHAPE; - - if (aTypeX==TopAbs_SOLID) { - aTypeCurrent=TopAbs_SOLID; - } - - if (aTypeX==TopAbs_SHELL || aTypeX==TopAbs_FACE ) { - aTypeCurrent=TopAbs_SHELL; - } - - if (aTypeX==TopAbs_WIRE || aTypeX==TopAbs_EDGE ) { - aTypeCurrent=TopAbs_WIRE; - } - return aTypeCurrent; -} -// diff --git a/src/BOPTools/BOPTools_DSFiller.lxx b/src/BOPTools/BOPTools_DSFiller.lxx deleted file mode 100755 index 3d525092e3..0000000000 --- a/src/BOPTools/BOPTools_DSFiller.lxx +++ /dev/null @@ -1,31 +0,0 @@ -// Created on: 2004-06-11 -// Created by: Mikhail KLOKOV -// Copyright (c) 2004-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -inline const TColStd_DataMapOfIntegerListOfInteger& BOPTools_DSFiller::SplitFacePool() const -{ - return mySplitFacePool; -} - -inline TColStd_DataMapOfIntegerListOfInteger& BOPTools_DSFiller::ChangeSplitFacePool() -{ - return mySplitFacePool; -} - diff --git a/src/BOPTools/BOPTools_DataMapOfShapeSet.hxx b/src/BOPTools/BOPTools_DataMapOfShapeSet.hxx new file mode 100644 index 0000000000..d2edf69a1f --- /dev/null +++ b/src/BOPTools/BOPTools_DataMapOfShapeSet.hxx @@ -0,0 +1,35 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPTools_DataMapOfShapeSet_HeaderFile +#define BOPTools_DataMapOfShapeSet_HeaderFile + +#include +#include + +#define _NCollection_MapHasher +#include + +typedef NCollection_DataMap BOPTools_DataMapOfShapeSet; +typedef BOPTools_DataMapOfShapeSet::Iterator BOPCol_DataMapIteratorOfDataMapOfShapeSet; + +#undef _NCollection_MapHasher + + +#endif diff --git a/src/BOPTools/BOPTools_EEInterference.cdl b/src/BOPTools/BOPTools_EEInterference.cdl deleted file mode 100755 index 1797e3cff1..0000000000 --- a/src/BOPTools/BOPTools_EEInterference.cdl +++ /dev/null @@ -1,58 +0,0 @@ --- Created on: 2000-11-21 --- Created by: Peter KURNEV --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class EEInterference from BOPTools - inherits ShapeShapeInterference from BOPTools - - - ---Purpose: - -- class for storing an Edge/Edge - --- interference - --- - -uses - CommonPrt from IntTools - -is - Create - returns EEInterference from BOPTools; - ---Purpose: - --- Empty constructor - --- - Create (anIndex1, anIndex2: Integer from Standard; - aCPart:CommonPrt from IntTools) - returns EEInterference from BOPTools; - ---Purpose: - --- Constructor - --- anIndex1, - --- anIndex2 see BOPTools_ShapeShapeInterference for details - --- aCPart see IntTools_CommonPrt for details - --- - CommonPrt(me) - returns CommonPrt from IntTools; - ---C++: return const & - ---Purpose: - --- Selector - --- -fields - myCommonPart: CommonPrt from IntTools; - -end EEInterference; diff --git a/src/BOPTools/BOPTools_EEInterference.cxx b/src/BOPTools/BOPTools_EEInterference.cxx deleted file mode 100755 index 010a827aef..0000000000 --- a/src/BOPTools/BOPTools_EEInterference.cxx +++ /dev/null @@ -1,53 +0,0 @@ -// Created on: 2000-11-21 -// Created by: Peter KURNEV -// Copyright (c) 2000-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include - -//======================================================================= -//function : BOPTools_EEInterference -//purpose : -//======================================================================= -BOPTools_EEInterference::BOPTools_EEInterference() -: - BOPTools_ShapeShapeInterference(0,0) -{} - -//======================================================================= -//function : BOPTools_ESInterference -//purpose : -//======================================================================= - BOPTools_EEInterference::BOPTools_EEInterference - (const Standard_Integer anIndex1, - const Standard_Integer anIndex2, - const IntTools_CommonPrt& aCPart) -: - BOPTools_ShapeShapeInterference(anIndex1,anIndex2) -{ - myCommonPart=aCPart; -} -//======================================================================= -//function : CommonPrt -//purpose : -//======================================================================= - const IntTools_CommonPrt& BOPTools_EEInterference::CommonPrt() const -{ - return myCommonPart; -} diff --git a/src/BOPTools/BOPTools_ESInterference.cdl b/src/BOPTools/BOPTools_ESInterference.cdl deleted file mode 100755 index 6835263409..0000000000 --- a/src/BOPTools/BOPTools_ESInterference.cdl +++ /dev/null @@ -1,56 +0,0 @@ --- Created on: 2000-11-21 --- Created by: Peter KURNEV --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class ESInterference from BOPTools - inherits ShapeShapeInterference from BOPTools - - ---Purpose: class for storing an Edge/Face - --- interference - --- -uses - CommonPrt from IntTools - -is - Create - returns ESInterference from BOPTools; - ---Purpose: - --- Empty constructor - --- - Create (anIndex1: Integer from Standard; - anIndex2: Integer from Standard; - aCPart:CommonPrt from IntTools) - returns ESInterference from BOPTools; - ---Purpose: - --- Constructor - --- anIndex1, - --- anIndex2 see BOPTools_ShapeShapeInterference for details - --- aCPart see IntTools_CommonPrt for details - --- - CommonPrt(me) - returns CommonPrt from IntTools; - ---C++: return const & - ---Purpose: - --- Selector - --- -fields - myCommonPart: CommonPrt from IntTools; - -end ESInterference; diff --git a/src/BOPTools/BOPTools_ESInterference.cxx b/src/BOPTools/BOPTools_ESInterference.cxx deleted file mode 100755 index b7887320b5..0000000000 --- a/src/BOPTools/BOPTools_ESInterference.cxx +++ /dev/null @@ -1,54 +0,0 @@ -// Created on: 2000-11-21 -// Created by: Peter KURNEV -// Copyright (c) 2000-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include - -//======================================================================= -//function : BOPTools_ESInterference -//purpose : -//======================================================================= -BOPTools_ESInterference::BOPTools_ESInterference() -: - BOPTools_ShapeShapeInterference(0,0) -{} - -//======================================================================= -//function : BOPTools_ESInterference -//purpose : -//======================================================================= - BOPTools_ESInterference::BOPTools_ESInterference - (const Standard_Integer anIndex1, - const Standard_Integer anIndex2, - const IntTools_CommonPrt& aCPart) -: - BOPTools_ShapeShapeInterference(anIndex1,anIndex2) -{ - myCommonPart=aCPart; -} - -//======================================================================= -//function : CommonPrt -//purpose : -//======================================================================= - const IntTools_CommonPrt& BOPTools_ESInterference::CommonPrt() const -{ - return myCommonPart; -} diff --git a/src/BOPTools/BOPTools_EdgeSet.cdl b/src/BOPTools/BOPTools_EdgeSet.cdl new file mode 100644 index 0000000000..70f778edd0 --- /dev/null +++ b/src/BOPTools/BOPTools_EdgeSet.cdl @@ -0,0 +1,80 @@ +-- Created by: Peter KURNEV +-- Copyright (c) 1999-2012 OPEN CASCADE SAS +-- +-- The content of this file is subject to the Open CASCADE Technology Public +-- License Version 6.5 (the "License"). You may not use the content of this file +-- except in compliance with the License. Please obtain a copy of the License +-- at http://www.opencascade.org and read it completely before using this file. +-- +-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +-- +-- The Original Code and all software distributed under the License is +-- distributed on an "AS IS" basis, without warranty of any kind, and the +-- Initial Developer hereby disclaims all such warranties, including without +-- limitation, any warranties of merchantability, fitness for a particular +-- purpose or non-infringement. Please see the License for the specific terms +-- and conditions governing the rights and limitations under the License. + +class EdgeSet from BOPTools + + +uses + Shape from TopoDS, + Edge from TopoDS, + ShapeEnum from TopAbs, + BaseAllocator from BOPCol, + MapOfShape from BOPCol, + ListOfShape from BOPCol + +--raises + +is + Create + returns EdgeSet from BOPTools; + ---C++: alias "virtual ~BOPTools_EdgeSet();" + ---C++: inline + + Create (theAllocator: BaseAllocator from BOPCol) + returns EdgeSet from BOPTools; + ---C++: inline + + SetShape(me:out; + theS:Shape from TopoDS); + ---C++: inline + + Shape(me) + returns Shape from TopoDS; + ---C++: return const & + ---C++: inline + + AddEdge(me:out; + theEdge:Edge from TopoDS); + ---C++: inline + + AddEdges(me:out; + theLS:ListOfShape from BOPCol); + + AddEdges(me:out; + theFace:Shape from TopoDS); + ---C++: inline + + Clear(me:out); + ---C++: inline + + Get(me; + theLS:out ListOfShape from BOPCol); + ---C++: inline + + Contains(me; + theSet:EdgeSet from BOPTools) + returns Boolean from Standard; + ---C++: inline + + +fields + myShape : Shape from TopoDS is protected; + myMap : MapOfShape from BOPCol is protected; + myEdges : ListOfShape from BOPCol is protected; + +end EdgeSet; diff --git a/src/BOPTools/BOPTools_EdgeSet.cxx b/src/BOPTools/BOPTools_EdgeSet.cxx new file mode 100644 index 0000000000..ca371ddb03 --- /dev/null +++ b/src/BOPTools/BOPTools_EdgeSet.cxx @@ -0,0 +1,20 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#include diff --git a/src/BOPTools/BOPTools_EdgeSet.lxx b/src/BOPTools/BOPTools_EdgeSet.lxx new file mode 100644 index 0000000000..64caedc6f6 --- /dev/null +++ b/src/BOPTools/BOPTools_EdgeSet.lxx @@ -0,0 +1,147 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + +#include +#include +#include + +//======================================================================= +//function : +//purpose : +//======================================================================= + inline BOPTools_EdgeSet::BOPTools_EdgeSet() +{ +} +//======================================================================= +//function : +//purpose : +//======================================================================= + inline BOPTools_EdgeSet::BOPTools_EdgeSet(const Handle(NCollection_BaseAllocator)& theObj) +: + myMap(100, theObj), + myEdges(theObj) +{ +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= + inline BOPTools_EdgeSet::~BOPTools_EdgeSet() +{ +} +//======================================================================= +//function : Clear +//purpose : +//======================================================================= + inline void BOPTools_EdgeSet::Clear() +{ + myMap.Clear(); + myEdges.Clear(); +} +//======================================================================= +//function : SetShape +//purpose : +//======================================================================= + inline void BOPTools_EdgeSet::SetShape(const TopoDS_Shape& theShape) +{ + myShape=theShape; +} +//======================================================================= +//function : Shape +//purpose : +//======================================================================= + inline const TopoDS_Shape& BOPTools_EdgeSet::Shape()const +{ + return myShape; +} +//======================================================================= +//function : AddEdge +//purpose : +//======================================================================= + inline void BOPTools_EdgeSet::AddEdge(const TopoDS_Edge& theEdge) +{ + if (!BRep_Tool::Degenerated(theEdge)){ + myEdges.Append(theEdge); + myMap.Add(theEdge); + } +} +//======================================================================= +//function : AddEdges +//purpose : +//======================================================================= + inline void BOPTools_EdgeSet::AddEdges(const BOPCol_ListOfShape& theLS) +{ + BOPCol_ListIteratorOfListOfShape aIt; + // + aIt.Initialize(theLS); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Edge& aE=(*(TopoDS_Edge*)&aIt.Value()); + AddEdge(aE); + } +} +//======================================================================= +//function : AddEdges +//purpose : +//======================================================================= + inline void BOPTools_EdgeSet::AddEdges(const TopoDS_Shape& theFace) +{ + TopExp_Explorer aExp(theFace, TopAbs_EDGE); + for(; aExp.More(); aExp.Next()) { + const TopoDS_Edge& aE=(*(TopoDS_Edge*)&aExp.Current()); + AddEdge(aE); + } +} +//======================================================================= +//function : Get +//purpose : +//======================================================================= + inline void BOPTools_EdgeSet::Get(BOPCol_ListOfShape& theLS)const +{ + BOPCol_ListIteratorOfListOfShape aIt; + // + aIt.Initialize(myEdges); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aS=aIt.Value(); + theLS.Append(aS); + } +} +//======================================================================= +//function : Contains +//purpose : +//======================================================================= + inline Standard_Boolean BOPTools_EdgeSet::Contains(const BOPTools_EdgeSet& theOther)const +{ + Standard_Integer aNbEOther, aNbE; + Standard_Boolean bRet; + BOPCol_ListIteratorOfListOfShape aIt; + // + aNbE=0; + aNbEOther=theOther.myEdges.Extent(); + aIt.Initialize(theOther.myEdges); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aS=aIt.Value(); + bRet=myMap.Contains(aS); + if (!bRet) { + return bRet; + } + ++aNbE; + } + bRet=(aNbE==aNbEOther); + // + return bRet; +} diff --git a/src/BOPTools/BOPTools_Interference.cdl b/src/BOPTools/BOPTools_Interference.cdl deleted file mode 100755 index 0cded0e3b9..0000000000 --- a/src/BOPTools/BOPTools_Interference.cdl +++ /dev/null @@ -1,83 +0,0 @@ --- Created on: 2000-11-21 --- Created by: Peter KURNEV --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class Interference from BOPTools - - ---Purpose: class for storing information about an interference - --- that takes place between given shape and shape - --- with DS-index =aWith - - -uses - KindOfInterference from BooleanOperations - -is - Create - returns Interference from BOPTools; - ---Purpose: - --- Empty constructor - --- - Create (aWith :Integer from Standard; - aType :KindOfInterference from BooleanOperations; - anIndex :Integer from Standard) - returns Interference from BOPTools; - ---Purpose: constructor - --- aWith - DS-index for the opposite shape - --- aType - the type of the interference - --- anIndex- the index of the result in corresponding - --- interference table (if the result is computed - --- but there is no result -> anIndex=0) - --- - SetWith (me:out; aWith :Integer from Standard); - ---Purpose: - --- Modifier - --- - SetType (me:out; aType : KindOfInterference from BooleanOperations); - ---Purpose: - --- Modifier - --- - SetIndex (me:out; anIndex :Integer from Standard); - ---Purpose: - --- Modifier - --- - With (me) - returns Integer from Standard; - ---Purpose: - --- Selector - --- - Type (me) - returns KindOfInterference from BooleanOperations; - ---Purpose: - --- Selector - --- - Index (me) - returns Integer from Standard; - ---Purpose: - --- Selector - --- - -fields - myWith : Integer from Standard; - myType : KindOfInterference from BooleanOperations; - myIndex : Integer from Standard; --< index in corresp.interference table - - -end Interference; diff --git a/src/BOPTools/BOPTools_Interference.cxx b/src/BOPTools/BOPTools_Interference.cxx deleted file mode 100755 index 546638d5ee..0000000000 --- a/src/BOPTools/BOPTools_Interference.cxx +++ /dev/null @@ -1,100 +0,0 @@ -// Created on: 2000-11-21 -// Created by: Peter KURNEV -// Copyright (c) 2000-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#include - -//======================================================================= -//function : BOPTools_Interference::BOPTools_Interference -//purpose : -//======================================================================= -BOPTools_Interference::BOPTools_Interference() -: - myWith(0), - myType(BooleanOperations_UnknownInterference), - myIndex(0) -{ -} - -//======================================================================= -//function : BOPTools_Interference::BOPTools_Interference -//purpose : -//======================================================================= - BOPTools_Interference::BOPTools_Interference(const Standard_Integer aWith, - const BooleanOperations_KindOfInterference aType, - const Standard_Integer anIndex) -: - myWith(aWith), - myType(aType), - myIndex(anIndex) -{ -} -//======================================================================= -//function : SetWith -//purpose : -//======================================================================= - void BOPTools_Interference::SetWith(const Standard_Integer aWith) -{ - myWith=aWith; -} - -//======================================================================= -//function : SetType -//purpose : -//======================================================================= - void BOPTools_Interference::SetType(const BooleanOperations_KindOfInterference aType) -{ - myType=aType; -} - -//======================================================================= -//function : SetIndex -//purpose : -//======================================================================= - void BOPTools_Interference::SetIndex(const Standard_Integer anIndex) -{ - myIndex=anIndex; -} - -//======================================================================= -//function : With -//purpose : -//======================================================================= - Standard_Integer BOPTools_Interference::With() const -{ - return myWith; -} - -//======================================================================= -//function : Type -//purpose : -//======================================================================= - BooleanOperations_KindOfInterference BOPTools_Interference::Type() const -{ - return myType; -} - -//======================================================================= -//function : Index -//purpose : -//======================================================================= - Standard_Integer BOPTools_Interference::Index() const -{ - return myIndex; -} diff --git a/src/BOPTools/BOPTools_InterferenceLine.cdl b/src/BOPTools/BOPTools_InterferenceLine.cdl deleted file mode 100755 index d403ea8ecc..0000000000 --- a/src/BOPTools/BOPTools_InterferenceLine.cdl +++ /dev/null @@ -1,103 +0,0 @@ --- Created on: 2000-11-21 --- Created by: Peter KURNEV --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class InterferenceLine from BOPTools - - ---Purpose: class for storing information about all - --- interferences for given shape. - --- So, for each shape in the DS, we will have - --- the following interference list - --- (i1, t1, r1), (i2, t2, r2),...(iN, tN, rN), - --- where - --- (iN, tN, rN) - object of type BOPTools_Interference - --- The class BOPTools_InterferenceLine is dedicated - --- to provide convinient tools to manage this info. - --- - -uses - KindOfInterference from BooleanOperations, - ListOfInterference from BOPTools, - Interference from BOPTools - - -is - Create - returns InterferenceLine from BOPTools; - ---Purpose: - --- Empty constructor - --- - GetOnType(me; - aType :KindOfInterference from BooleanOperations) - returns ListOfInterference from BOPTools; - ---C++: return const & - ---Purpose: - --- Returns info. list for interferences of given type - --- - IsComputed(me; - aWith :Integer from Standard; - aType :KindOfInterference from BooleanOperations) - returns Boolean from Standard; - ---Purpose: - --- Returns TRUE if the interference of type - --- with the shape has already been computed. - --- - AddInterference (me:out; - anInterference :Interference from BOPTools); - ---Purpose: - --- Adds info. about the Interference to the list - --- - AddInterference (me:out; - aWith :Integer from Standard; - aType :KindOfInterference from BooleanOperations; - anIndex:Integer from Standard); - ---Purpose: - --- Adds info. about the Interference to the list - --- - List(me) - returns ListOfInterference from BOPTools; - ---C++: return const & - ---Purpose: - --- Selector - --- - RealList(me) - returns ListOfInterference from BOPTools; - ---C++: return const & - ---Purpose: - --- Selector - --- - HasInterference(me) - returns Boolean from Standard; - ---Purpose: - --- Returns TRUE if the list contains at least one interference - --- with non-empty result - --- -fields - - myList : ListOfInterference from BOPTools; - mySSList : ListOfInterference from BOPTools; - myESList : ListOfInterference from BOPTools; - myVSList : ListOfInterference from BOPTools; - myEEList : ListOfInterference from BOPTools; - myVEList : ListOfInterference from BOPTools; - myVVList : ListOfInterference from BOPTools; - myEmptyList : ListOfInterference from BOPTools; - -end InterferenceLine; diff --git a/src/BOPTools/BOPTools_InterferenceLine.cxx b/src/BOPTools/BOPTools_InterferenceLine.cxx deleted file mode 100755 index 9a17b9f50e..0000000000 --- a/src/BOPTools/BOPTools_InterferenceLine.cxx +++ /dev/null @@ -1,222 +0,0 @@ -// Created on: 2000-11-21 -// Created by: Peter KURNEV -// Copyright (c) 2000-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include -#include - -//======================================================================= -//function : BOPTools_InterferenceLine::BOPTools_InterferenceLine -//purpose : -//======================================================================= -BOPTools_InterferenceLine::BOPTools_InterferenceLine() {} - -//======================================================================= -//function : RealList -//purpose : -//======================================================================= - const BOPTools_ListOfInterference& BOPTools_InterferenceLine::RealList() const -{ - Standard_Integer anInd; - List(); - BOPTools_ListOfInterference aTmpList; - BOPTools_ListIteratorOfListOfInterference anIt; - - anIt.Initialize(myList); - for (; anIt.More(); anIt.Next()) { - const BOPTools_Interference& anInterference=anIt.Value(); - aTmpList.Append(anInterference); - } - // - BOPTools_ListOfInterference* pList=(BOPTools_ListOfInterference*)&myList; - pList->Clear(); - // - anIt.Initialize(aTmpList); - for (; anIt.More(); anIt.Next()) { - const BOPTools_Interference& anInterference=anIt.Value(); - anInd=anInterference.Index(); - if (anInd) { - pList->Append(anInterference); - } - } - return myList; -} - -//======================================================================= -//function : List -//purpose : -//======================================================================= - const BOPTools_ListOfInterference& BOPTools_InterferenceLine::List () const -{ - BOPTools_ListOfInterference* pList=(BOPTools_ListOfInterference*)&myList; - - pList->Clear(); - - BOPTools_ListIteratorOfListOfInterference anIt; - - anIt.Initialize(mySSList); - for (; anIt.More(); anIt.Next()) { - const BOPTools_Interference& anInterference=anIt.Value(); - pList->Append(anInterference); - } - - anIt.Initialize(myESList); - for (; anIt.More(); anIt.Next()) { - const BOPTools_Interference& anInterference=anIt.Value(); - pList->Append(anInterference); - } - - anIt.Initialize(myVSList); - for (; anIt.More(); anIt.Next()) { - const BOPTools_Interference& anInterference=anIt.Value(); - pList->Append(anInterference); - } - - anIt.Initialize(myEEList); - for (; anIt.More(); anIt.Next()) { - const BOPTools_Interference& anInterference=anIt.Value(); - pList->Append(anInterference); - } - - anIt.Initialize(myVEList); - for (; anIt.More(); anIt.Next()) { - const BOPTools_Interference& anInterference=anIt.Value(); - pList->Append(anInterference); - } - - anIt.Initialize(myVVList); - for (; anIt.More(); anIt.Next()) { - const BOPTools_Interference& anInterference=anIt.Value(); - pList->Append(anInterference); - } - - return myList; -} - -//======================================================================= -//function : GetOnType -//purpose : -//======================================================================= - const BOPTools_ListOfInterference& BOPTools_InterferenceLine::GetOnType - (const BooleanOperations_KindOfInterference theType) const -{ - switch (theType) { - case BooleanOperations_SurfaceSurface: - return mySSList; - - case BooleanOperations_EdgeSurface: - return myESList; - - case BooleanOperations_VertexSurface: - return myVSList; - - case BooleanOperations_EdgeEdge: - return myEEList; - - case BooleanOperations_VertexEdge: - return myVEList; - - case BooleanOperations_VertexVertex: - return myVVList; - default: - return myEmptyList; - } - -} - -//======================================================================= -//function : HasInterference -//purpose : -//======================================================================= - Standard_Boolean BOPTools_InterferenceLine::HasInterference () const -{ - Standard_Integer anInd; - Standard_Boolean bFlag=Standard_False; - BOPTools_ListIteratorOfListOfInterference anIt; - // - List(); - // - anIt.Initialize(myList); - for (; anIt.More(); anIt.Next()) { - const BOPTools_Interference& anInterference=anIt.Value(); - anInd=anInterference.Index(); - if (anInd) { - return !bFlag; - } - } - return bFlag; -} - -//======================================================================= -//function : IsComputed -//purpose : -//======================================================================= - Standard_Boolean BOPTools_InterferenceLine::IsComputed - (const Standard_Integer theWith, - const BooleanOperations_KindOfInterference theType)const -{ - BooleanOperations_KindOfInterference aType; - Standard_Integer aWith, anInd; - - const BOPTools_ListOfInterference& aList=GetOnType(theType); - BOPTools_ListIteratorOfListOfInterference anIt(aList); - for (; anIt.More(); anIt.Next()) { - const BOPTools_Interference& anInterference=anIt.Value(); - aType=anInterference.Type(); - aWith=anInterference.With(); - // - anInd=anInterference.Index(); - // - if ((aType==theType && aWith==theWith) && anInd) { - return Standard_True; - } - } - return Standard_False; -} -//======================================================================= -//function : AddInterference -//purpose : -//======================================================================= - void BOPTools_InterferenceLine::AddInterference(const BOPTools_Interference& anInterference) -{ - Standard_Integer aWith, anInd; - BooleanOperations_KindOfInterference aType; - - aWith=anInterference.With(); - aType=anInterference.Type(); - anInd=anInterference.Index(); - AddInterference(aWith, aType, anInd); -} - - -//======================================================================= -//function : AddInterference -//purpose : -//======================================================================= - void BOPTools_InterferenceLine::AddInterference(const Standard_Integer aWith, - const BooleanOperations_KindOfInterference aType, - const Standard_Integer anIndex) -{ - BOPTools_Interference anInterference(aWith, aType, anIndex); - const BOPTools_ListOfInterference& aList=GetOnType(aType); - BOPTools_ListOfInterference* pList=(BOPTools_ListOfInterference*) &aList; - pList->Append(anInterference); -} - diff --git a/src/BOPTools/BOPTools_InterferencePool.cdl b/src/BOPTools/BOPTools_InterferencePool.cdl deleted file mode 100755 index 6cb0f23419..0000000000 --- a/src/BOPTools/BOPTools_InterferencePool.cdl +++ /dev/null @@ -1,186 +0,0 @@ --- Created on: 2001-01-26 --- Created by: Peter KURNEV --- Copyright (c) 2001-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class InterferencePool from BOPTools - - ---Purpose: - -- Class for storing information about - --- results of all interferences for all shapes - -uses - ShapesDataStructure from BooleanOperations, - PShapesDataStructure from BooleanOperations, - KindOfInterference from BooleanOperations, - - CArray1OfInterferenceLine from BOPTools, - CArray1OfSSInterference from BOPTools, - CArray1OfESInterference from BOPTools, - CArray1OfVSInterference from BOPTools, - CArray1OfEEInterference from BOPTools, - CArray1OfVEInterference from BOPTools, - CArray1OfVVInterference from BOPTools, - PShapeShapeInterference from BOPTools -is - Create - returns InterferencePool from BOPTools ; - ---Purpose: - --- Empty constructor - --- - Create (aDS:ShapesDataStructure from BooleanOperations) - returns InterferencePool from BOPTools ; - ---Purpose: - --- Constructor - --- - SetDS (me:out;aDS:ShapesDataStructure from BooleanOperations); - ---Purpose: - --- Modifier - --- - DS(me) - returns PShapesDataStructure from BooleanOperations; - ---Purpose: - --- Selector - --- - HasInterference (me; - anInd :Integer from Standard) - returns Boolean from Standard; - ---Purpose: - --- Returns TRUE if the shape with DS_index - --- has at least one interference with non-empty result - --- - IsComputed (me; - anInd1 : Integer from Standard; - anInd2 : Integer from Standard) - returns Boolean from Standard; - ---Purpose: - --- Returns TRUE if the interference between shapes - --- and has already been computed. - --- - SortTypes (me; - anInd1:in out Integer from Standard; - anInd2:in out Integer from Standard); - ---Purpose: - --- Sorts types of shapes and in increasing order - --- - InterferenceType (me; - anInd1: Integer from Standard; - anInd2: Integer from Standard) - returns KindOfInterference from BooleanOperations; - ---Purpose: - --- Gets the type of interference in accordance with the types of - --- shapes and - --- - AddInterference (me:out; - anInd1: Integer from Standard; - anInd2: Integer from Standard; - aType: KindOfInterference from BooleanOperations; - anIndex: Integer from Standard); - ---Purpose: - --- Adds the info about interference in InterferenceLine-s for - --- shapes and - --- - InterferenceTable (me) - returns CArray1OfInterferenceLine from BOPTools; - ---C++: return const& - ---Purpose: - --- Returns the reference to complete array of interference line-s - --- - SSInterferences (me:out) - returns CArray1OfSSInterference from BOPTools; - ---C++: return & - ---Purpose: - --- Returns the reference to array Of F/F interferences - --- - ESInterferences (me:out) - returns CArray1OfESInterference from BOPTools; - ---C++: return & - ---Purpose: - --- Returns the reference to array Of E/F interferences - --- - VSInterferences (me:out) - returns CArray1OfVSInterference from BOPTools; - ---C++: return & - ---Purpose: - --- Returns the reference to array Of V/F interferences - --- - EEInterferences (me:out) - returns CArray1OfEEInterference from BOPTools; - ---C++: return & - ---Purpose: - --- Returns the reference to arrray Of E/E interferences - --- - VEInterferences (me:out) - returns CArray1OfVEInterference from BOPTools; - ---C++: return & - ---Purpose: - --- Returns the reference to arrray Of V/E interferences - --- - VVInterferences (me:out) - returns CArray1OfVVInterference from BOPTools; - ---C++: return & - ---Purpose: - --- Returns the reference to arrray Of V/V interferences - --- - -------------- - SSInterfs (me) - returns CArray1OfSSInterference from BOPTools; - ---C++: return const & - - ESInterfs (me) - returns CArray1OfESInterference from BOPTools; - ---C++: return const & - - VSInterfs (me) - returns CArray1OfVSInterference from BOPTools; - ---C++: return const & - - EEInterfs (me) - returns CArray1OfEEInterference from BOPTools; - ---C++: return const & - - VEInterfs (me) - returns CArray1OfVEInterference from BOPTools; - ---C++: return const & - - VVInterfs (me) - returns CArray1OfVVInterference from BOPTools; - ---C++: return const & - - - GetInterference (me; - anIndex: Integer from Standard; - aType : KindOfInterference from BooleanOperations) - returns PShapeShapeInterference from BOPTools; - - -fields - - myDS : PShapesDataStructure from BooleanOperations; - myNbSourceShapes : Integer from Standard; - - myInterferenceTable: CArray1OfInterferenceLine from BOPTools; - mySSInterferences : CArray1OfSSInterference from BOPTools; - myESInterferences : CArray1OfESInterference from BOPTools; - myVSInterferences : CArray1OfVSInterference from BOPTools; - myEEInterferences : CArray1OfEEInterference from BOPTools; - myVEInterferences : CArray1OfVEInterference from BOPTools; - myVVInterferences : CArray1OfVVInterference from BOPTools; - -end InterferencePool; diff --git a/src/BOPTools/BOPTools_InterferencePool.cxx b/src/BOPTools/BOPTools_InterferencePool.cxx deleted file mode 100755 index 8e8f4d6d91..0000000000 --- a/src/BOPTools/BOPTools_InterferencePool.cxx +++ /dev/null @@ -1,377 +0,0 @@ -// Created on: 2001-01-26 -// Created by: Peter KURNEV -// Copyright (c) 2001-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include - -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - - -//======================================================================= -//function : BOPTools_InterferencePool -//purpose : -//======================================================================= -BOPTools_InterferencePool::BOPTools_InterferencePool() -{ - myDS=NULL; - myNbSourceShapes=0; -} -//======================================================================= -//function : BOPTools_InterferencePool -//purpose : -//======================================================================= - BOPTools_InterferencePool::BOPTools_InterferencePool (const BooleanOperations_ShapesDataStructure& aDS) -{ - SetDS(aDS); -} -//======================================================================= -//function : SetDS -//purpose : -//======================================================================= - void BOPTools_InterferencePool::SetDS(const BooleanOperations_ShapesDataStructure& aDS) -{ - void* p=(void*) &aDS; - myDS=(BooleanOperations_ShapesDataStructure*) p; - myNbSourceShapes= myDS->NumberOfShapesOfTheObject()+myDS->NumberOfShapesOfTheTool(); - myInterferenceTable.Resize (myNbSourceShapes); -} -//======================================================================= -//function : DS -//purpose : -//======================================================================= - BooleanOperations_PShapesDataStructure BOPTools_InterferencePool::DS() const -{ - return myDS; -} -//======================================================================= -//function : HasInterference -//purpose : -//======================================================================= - Standard_Boolean BOPTools_InterferencePool::HasInterference(const Standard_Integer anInd1)const -{ - const BOPTools_InterferenceLine& aWhatLine=myInterferenceTable(anInd1); - Standard_Boolean bFlag=aWhatLine.HasInterference(); - return bFlag; -} -//======================================================================= -//function : IsComputed -//purpose : -//======================================================================= - Standard_Boolean BOPTools_InterferencePool::IsComputed(const Standard_Integer anInd1, - const Standard_Integer anInd2) const -{ - BooleanOperations_KindOfInterference theType; - - theType=InterferenceType(anInd1, anInd2); - - if (theType==BooleanOperations_UnknownInterference) { - return Standard_False; - } - - const BOPTools_InterferenceLine& aWhatLine=myInterferenceTable(anInd1); - Standard_Boolean aFlag=aWhatLine.IsComputed(anInd2, theType); - return aFlag; -} - - -//=========================================================================== -//function : AddInterference -//purpose : -//=========================================================================== - void BOPTools_InterferencePool::AddInterference (const Standard_Integer theWhat, - const Standard_Integer theWith, - const BooleanOperations_KindOfInterference theType, - const Standard_Integer theIndexOfInterference) -{ - BOPTools_InterferenceLine& aWhatLine=myInterferenceTable(theWhat); - aWhatLine.AddInterference(theWith, theType, theIndexOfInterference); - - BOPTools_InterferenceLine& aWithLine=myInterferenceTable(theWith); - aWithLine.AddInterference(theWhat, theType, theIndexOfInterference); -} - -//======================================================================= -//function : InterferenceType -//purpose : -//======================================================================= - BooleanOperations_KindOfInterference - BOPTools_InterferencePool::InterferenceType(const Standard_Integer theWhat, - const Standard_Integer theWith) const -{ - BooleanOperations_KindOfInterference theType; - Standard_Integer aWhat, aWith; - TopAbs_ShapeEnum aType1, aType2; - - aWhat=theWhat; - aWith=theWith; - SortTypes(aWhat, aWith); - - aType1= myDS->GetShapeType(aWhat), - aType2= myDS->GetShapeType(aWith); - - if (aType1==TopAbs_VERTEX && aType2==TopAbs_VERTEX) { - theType=BooleanOperations_VertexVertex; - } - else if (aType1==TopAbs_VERTEX && aType2==TopAbs_EDGE) { - theType=BooleanOperations_VertexEdge; - } - else if (aType1==TopAbs_VERTEX && aType2==TopAbs_FACE) { - theType=BooleanOperations_VertexSurface; - } - else if (aType1==TopAbs_EDGE && aType2==TopAbs_EDGE) { - theType=BooleanOperations_EdgeEdge; - } - else if (aType1==TopAbs_EDGE && aType2==TopAbs_FACE) { - theType=BooleanOperations_EdgeSurface; - } - else if (aType1==TopAbs_FACE && aType2==TopAbs_FACE) { - theType=BooleanOperations_SurfaceSurface; - } - else { - theType=BooleanOperations_UnknownInterference; - } - - return theType; -} - -//======================================================================= -//function : SortTypes -//purpose : -//======================================================================= - void BOPTools_InterferencePool::SortTypes(Standard_Integer& theWhat, - Standard_Integer& theWith) const -{ - Standard_Boolean aReverseFlag=Standard_True; - - TopAbs_ShapeEnum aType1= myDS->GetShapeType(theWhat), - aType2= myDS->GetShapeType(theWith); - - if (aType1==aType2) - return; - - if (aType1==TopAbs_EDGE && aType2==TopAbs_FACE){ - aReverseFlag=Standard_False; - } - - if (aType1==TopAbs_VERTEX && - (aType2==TopAbs_FACE || aType2==TopAbs_EDGE)) { - aReverseFlag=Standard_False; - } - - Standard_Integer aWhat, aWith; - aWhat=(aReverseFlag) ? theWith : theWhat; - aWith=(aReverseFlag) ? theWhat : theWith; - - theWhat=aWhat; - theWith=aWith; -} - -//=========================================================================== -//function : InterferenceTable -//purpose : -//=========================================================================== -const BOPTools_CArray1OfInterferenceLine& - BOPTools_InterferencePool::InterferenceTable()const -{ - return myInterferenceTable; -} - -//=========================================================================== -//function : SSInterferences -//purpose : -//=========================================================================== - BOPTools_CArray1OfSSInterference& BOPTools_InterferencePool::SSInterferences() -{ - return mySSInterferences; -} -//=========================================================================== -//function : ESInterferences -//purpose : -//=========================================================================== - BOPTools_CArray1OfESInterference& BOPTools_InterferencePool::ESInterferences() -{ - return myESInterferences; -} -//=========================================================================== -//function : VSInterferences -//purpose : -//=========================================================================== - BOPTools_CArray1OfVSInterference& BOPTools_InterferencePool::VSInterferences() -{ - return myVSInterferences; -} -//=========================================================================== -//function : EEInterferences -//purpose : -//=========================================================================== - BOPTools_CArray1OfEEInterference& BOPTools_InterferencePool::EEInterferences() -{ - return myEEInterferences; -} -//=========================================================================== -//function : VEInterferences -//purpose : -//=========================================================================== - BOPTools_CArray1OfVEInterference& BOPTools_InterferencePool::VEInterferences() -{ - return myVEInterferences; -} - -//=========================================================================== -//function : VVInterferences -//purpose : -//=========================================================================== - BOPTools_CArray1OfVVInterference& BOPTools_InterferencePool::VVInterferences() -{ - return myVVInterferences; -} -//////////////////////// - -//=========================================================================== -//function : SSInterfs -//purpose : -//=========================================================================== - const BOPTools_CArray1OfSSInterference& BOPTools_InterferencePool::SSInterfs()const -{ - return mySSInterferences; -} -//=========================================================================== -//function : ESInterfs -//purpose : -//=========================================================================== - const BOPTools_CArray1OfESInterference& BOPTools_InterferencePool::ESInterfs()const -{ - return myESInterferences; -} -//=========================================================================== -//function : VSInterfs -//purpose : -//=========================================================================== - const BOPTools_CArray1OfVSInterference& BOPTools_InterferencePool::VSInterfs()const -{ - return myVSInterferences; -} -//=========================================================================== -//function : EEInterfs -//purpose : -//=========================================================================== - const BOPTools_CArray1OfEEInterference& BOPTools_InterferencePool::EEInterfs()const -{ - return myEEInterferences; -} -//=========================================================================== -//function : VEInterfs -//purpose : -//=========================================================================== - const BOPTools_CArray1OfVEInterference& BOPTools_InterferencePool::VEInterfs()const -{ - return myVEInterferences; -} - -//=========================================================================== -//function : VVInterfs -//purpose : -//=========================================================================== - const BOPTools_CArray1OfVVInterference& BOPTools_InterferencePool::VVInterfs()const -{ - return myVVInterferences; -} -//=========================================================================== -//function : GetInterference -//purpose : -//=========================================================================== -BOPTools_PShapeShapeInterference - BOPTools_InterferencePool::GetInterference(const Standard_Integer anIndex, - const BooleanOperations_KindOfInterference aType)const -{ - Standard_Integer aNb; - BOPTools_PShapeShapeInterference pI=NULL; - - switch (aType) { - // - case BooleanOperations_SurfaceSurface: - aNb=mySSInterferences.Extent(); - if (anIndex > 0 && anIndex <= aNb) { - pI=(BOPTools_PShapeShapeInterference)&mySSInterferences(anIndex); - } - break; - // - case BooleanOperations_EdgeSurface: - aNb=myESInterferences.Extent(); - if (anIndex > 0 && anIndex <= aNb) { - pI=(BOPTools_PShapeShapeInterference)&myESInterferences(anIndex); - } - break; - // - case BooleanOperations_VertexSurface: - aNb=myVSInterferences.Extent(); - if (anIndex > 0 && anIndex <= aNb) { - pI=(BOPTools_PShapeShapeInterference)&myVSInterferences(anIndex); - } - break; - // - case BooleanOperations_EdgeEdge: - aNb=myEEInterferences.Extent(); - if (anIndex > 0 && anIndex <= aNb) { - pI=(BOPTools_PShapeShapeInterference)&myEEInterferences(anIndex); - } - break; - // - case BooleanOperations_VertexEdge: - aNb=myVEInterferences.Extent(); - if (anIndex > 0 && anIndex <= aNb) { - pI=(BOPTools_PShapeShapeInterference)&myVEInterferences(anIndex); - } - break; - // - case BooleanOperations_VertexVertex: - aNb=myVVInterferences.Extent(); - if (anIndex > 0 && anIndex <= aNb) { - pI=(BOPTools_PShapeShapeInterference)&myVVInterferences(anIndex); - } - break; - // - case BooleanOperations_UnknownInterference: - default: - break; - } - return pI; -} - diff --git a/src/BOPTools/BOPTools_IteratorOfCoupleOfShape.cdl b/src/BOPTools/BOPTools_IteratorOfCoupleOfShape.cdl deleted file mode 100755 index 6945968728..0000000000 --- a/src/BOPTools/BOPTools_IteratorOfCoupleOfShape.cdl +++ /dev/null @@ -1,160 +0,0 @@ --- Created on: 2000-11-27 --- Created by: Michael KLOKOV --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class IteratorOfCoupleOfShape from BOPTools - - ---Purpose: The class IteratorOfCoupleOfShape provides the iteration - --- on the couples of shapes stored in ShapesDataStructure - --- according to the given types of shapes and - --- status of their intersection. - --- The statuses are stored in 2 dimension array. - -uses - ShapeEnum from TopAbs, - HArray2OfIntersectionStatus from BOPTools, - PShapesDataStructure from BooleanOperations, - IntersectionStatus from BOPTools, - ListOfCoupleOfInteger from BOPTools, - ListIteratorOfListOfCoupleOfInteger from BOPTools, - NoSuchObject from Standard - -raises NoSuchObject from Standard - -is - - Create - returns IteratorOfCoupleOfShape from BOPTools; - ---Purpose: - --- Empty Constructor - --- - - Create(PDS: PShapesDataStructure from BooleanOperations; - Type1: ShapeEnum from TopAbs; - Type2: ShapeEnum from TopAbs) - returns IteratorOfCoupleOfShape from BOPTools; - ---Purpose: - --- Initializes iterator by ShapesDataStructure and - --- shape types - --- - - Destroy(me: in out) is virtual; - ---C++: alias "Standard_EXPORT virtual ~BOPTools_IteratorOfCoupleOfShape(){Destroy();}" - - Initialize(me: in out; Type1: ShapeEnum from TopAbs; - Type2: ShapeEnum from TopAbs) - - raises NoSuchObject from Standard - is virtual; - ---Purpose: - --- Initializes iterator with shape types. - --- The iterator uses PDS assigned in constructor or in SetDataStructure(). - --- Raises the exception if myPDS is null. - --- - - - SetDataStructure(me: in out; PDS: PShapesDataStructure from BooleanOperations) - raises - NoSuchObject from Standard; - ---Purpose: - --- Initialize iterator with ShapeDataStructure. - --- - - - More(me) - returns Boolean from Standard - is virtual; - ---Purpose: - --- Returns True if there are still not - --- treated couples of shapes - --- - - Next(me: in out) - is virtual; - ---Purpose: - --- Moves to the next couple of iteration - --- - - Current(me; Index1: in out Integer from Standard; - Index2: in out Integer from Standard; - WithSubShape: out Boolean from Standard) - is virtual; - ---Purpose: - --- Returns current couple of indices and - --- flag WithSubShape which is true - --- if bounding boxes of subshapes - --- are intersected - --- - - ListOfCouple(me) - returns ListOfCoupleOfInteger from BOPTools; - ---C++: return const & - ---Purpose: - --- Returns a list of couples of shape indices - --- according to shape types by which - --- the iterator was initialized - --- - - MoreP(me) - returns Boolean from Standard - is protected; - - NextP(me: in out) - is protected; - - CurrentP(me;Index1: in out Integer from Standard; - Index2: in out Integer from Standard) - raises NoSuchObject from Standard - is protected; - - SetIntersectionStatus(me: in out; Index1: Integer from Standard; - Index2: Integer from Standard; - theStatus: IntersectionStatus from BOPTools); - ---Purpose: - --- Sets status to array according to Index1 and Index2 - --- - - GetTableOfIntersectionStatus(me) - returns HArray2OfIntersectionStatus from BOPTools; - ---C++: return const & - ---Purpose: - --- Returns 2 dimension array of intersection statuses - --- - - DumpTableOfIntersectionStatus(me); - ---Purpose: - --- For internal use - --- - -fields - myPDS: PShapesDataStructure from BooleanOperations is protected; - myTableOfStatus: HArray2OfIntersectionStatus from BOPTools is protected; - myCurrentIndex1: Integer from Standard is protected; - myCurrentIndex2: Integer from Standard is protected; - myType1: ShapeEnum from TopAbs is protected; - myType2: ShapeEnum from TopAbs is protected; --- - myFirstLowerIndex :Integer from Standard is protected; - myFirstUpperIndex :Integer from Standard is protected; - mySecondLowerIndex:Integer from Standard is protected; - mySecondUpperIndex:Integer from Standard is protected; - myListOfCouple :ListOfCoupleOfInteger from BOPTools is protected; - myIterator :ListIteratorOfListOfCoupleOfInteger from BOPTools is protected; --- -end IteratorOfCoupleOfShape from BOPTools; diff --git a/src/BOPTools/BOPTools_IteratorOfCoupleOfShape.cxx b/src/BOPTools/BOPTools_IteratorOfCoupleOfShape.cxx deleted file mode 100755 index 3fa8b84095..0000000000 --- a/src/BOPTools/BOPTools_IteratorOfCoupleOfShape.cxx +++ /dev/null @@ -1,296 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#include - -#include -#include -#include - -// ================================================================================================ -// function: Constructor -// ================================================================================================ -BOPTools_IteratorOfCoupleOfShape::BOPTools_IteratorOfCoupleOfShape() -: - myCurrentIndex1(-1), - myCurrentIndex2(-1), - myType1(TopAbs_SHAPE), - myType2(TopAbs_SHAPE), - myFirstLowerIndex(1), - myFirstUpperIndex(0), - mySecondLowerIndex(1), - mySecondUpperIndex(0) -{ - myPDS = NULL; -} - -// ================================================================================================ -// function: Constructor -// ================================================================================================ - BOPTools_IteratorOfCoupleOfShape::BOPTools_IteratorOfCoupleOfShape(const BooleanOperations_PShapesDataStructure& PDS, - const TopAbs_ShapeEnum Type1, - const TopAbs_ShapeEnum Type2) - : - myCurrentIndex1(-1), - myCurrentIndex2(-1), - myType1(TopAbs_SHAPE), - myType2(TopAbs_SHAPE) -{ - SetDataStructure(PDS); - - Initialize(Type1, Type2); -} - -// ================================================================================================ -// function: virtual destructor -// ================================================================================================ -void BOPTools_IteratorOfCoupleOfShape::Destroy() -{ -} - -// ================================================================================================ -// function: SetDataStructure -// ================================================================================================ - void BOPTools_IteratorOfCoupleOfShape::SetDataStructure(const BooleanOperations_PShapesDataStructure& PDS) -{ - if(PDS==NULL) { - Standard_NoSuchObject::Raise("BOPTools_IteratorOfCoupleOfShape::SetDataStructure: PDS==NULL"); - } - - myListOfCouple.Clear(); - - myPDS = PDS; - - BOPTools_RoughShapeIntersector aRoughIntersector(myPDS); - aRoughIntersector.Perform(); - if(aRoughIntersector.IsDone()) { - myTableOfStatus = aRoughIntersector.TableOfStatus(); - } else { - Handle(BOPTools_HArray2OfIntersectionStatus) anemptyhandle; - myTableOfStatus = anemptyhandle; - } -} - - -// ================================================================================================ -// function: Initialize -// ================================================================================================ - void BOPTools_IteratorOfCoupleOfShape::Initialize(const TopAbs_ShapeEnum Type1, - const TopAbs_ShapeEnum Type2) -{ - - if(myPDS==NULL) { - Standard_NoSuchObject::Raise("BOPTools_IteratorOfCoupleOfShape::Initialize: myPDS==NULL"); - } - myType1 = Type1; - myType2 = Type2; - myCurrentIndex1 = -1; - myCurrentIndex2 = -1; - // - myFirstLowerIndex=1; - myFirstUpperIndex=myPDS->NumberOfShapesOfTheObject(); - mySecondLowerIndex=myFirstUpperIndex+1; - mySecondUpperIndex=myFirstUpperIndex+myPDS->NumberOfShapesOfTheTool(); - - NextP(); - - Standard_Integer n1, n2; - - myListOfCouple.Clear(); - for (; MoreP(); NextP()) { - CurrentP(n1, n2); - BOPTools_CoupleOfInteger aCouple(n1, n2); - myListOfCouple.Append(aCouple); - } - myIterator.Initialize(myListOfCouple); -} - -//======================================================================= -// function: More -// purpose: -//======================================================================= - Standard_Boolean BOPTools_IteratorOfCoupleOfShape::More()const -{ - return myIterator.More(); -} -//======================================================================= -// function: Next -// purpose: -//======================================================================= - void BOPTools_IteratorOfCoupleOfShape::Next() -{ - myIterator.Next(); -} -//======================================================================= -// function: Current -// purpose: -//======================================================================= - void BOPTools_IteratorOfCoupleOfShape::Current(Standard_Integer& Index1, - Standard_Integer& Index2, - Standard_Boolean& WithSubShape) const -{ - WithSubShape = Standard_False; - - const BOPTools_CoupleOfInteger& aCouple=myIterator.Value(); - aCouple.Couple(Index1, Index2); - - BOPTools_IntersectionStatus aStatus = myTableOfStatus->Value(Index1, Index2); - - if(aStatus == BOPTools_BOUNDINGBOXOFSUBSHAPESINTERSECTED) { - WithSubShape = Standard_True; - } -} - -//======================================================================= -// function: ListOfCouple -// purpose: -//======================================================================= - const BOPTools_ListOfCoupleOfInteger& BOPTools_IteratorOfCoupleOfShape::ListOfCouple() const -{ - return myListOfCouple; -} - -// ================================================================================================ -// function: NextP -// ================================================================================================ - void BOPTools_IteratorOfCoupleOfShape::NextP() -{ - if(myPDS==NULL) { - myCurrentIndex1 = -1; - myCurrentIndex2 = -1; - return; - } - - Standard_Boolean couplefound, IsValidTableOfStatus = Standard_False; - Standard_Integer stopedindex1, stopedindex2, starti, i, startj, j; - TopAbs_ShapeEnum aTypei, aTypej; - - stopedindex1 = myCurrentIndex1; - stopedindex2 = myCurrentIndex2; - - if(!myTableOfStatus.IsNull()) { - IsValidTableOfStatus = Standard_True; - } - - myCurrentIndex1 = -1; - myCurrentIndex2 = -1; - - couplefound = Standard_False; - starti = stopedindex1; - if(starti < 0){ - starti = myFirstLowerIndex; - } - for(i = starti; !couplefound && i<=myFirstUpperIndex; i++) { - startj = mySecondLowerIndex; - if(i==stopedindex1 && (stopedindex2 >= 0)) { - startj = stopedindex2 + 1; - } - for(j = startj; !couplefound && j<=mySecondUpperIndex; j++) { - aTypei=myPDS->GetShapeType(i); - aTypej=myPDS->GetShapeType(j); - - if(((aTypei == myType1) && (aTypej == myType2)) || - ((aTypei == myType2) && (aTypej == myType1))) { - myCurrentIndex1 = i; - myCurrentIndex2 = j; - // - couplefound = Standard_True; - if(IsValidTableOfStatus) { - BOPTools_IntersectionStatus aStatus = myTableOfStatus->Value(i, j); - if(aStatus==BOPTools_INTERSECTED || aStatus==BOPTools_NONINTERSECTED) { - myCurrentIndex1 = -1; - myCurrentIndex2 = -1; - couplefound = Standard_False; - } - } - } - } - } - //} -} - -// ================================================================================================ -// function: More -// ================================================================================================ - Standard_Boolean BOPTools_IteratorOfCoupleOfShape::MoreP() const -{ - if((myCurrentIndex1 < 0) || (myCurrentIndex2 < 0)) - return Standard_False; - return Standard_True; -} - -// ================================================================================================ -// function: Current -// ================================================================================================ - void BOPTools_IteratorOfCoupleOfShape::CurrentP(Standard_Integer& Index1, - Standard_Integer& Index2) const -{ - if((myCurrentIndex1 < 0) || (myCurrentIndex2 < 0)) { - Standard_NoSuchObject::Raise("BOPTools_IteratorOfCoupleOfShape::Current"); - } - Index1 = myCurrentIndex1; - Index2 = myCurrentIndex2; -} - - -// ================================================================================================ -// function: SetIntersectionStatus -// ================================================================================================ - void BOPTools_IteratorOfCoupleOfShape::SetIntersectionStatus(const Standard_Integer Index1, - const Standard_Integer Index2, - const BOPTools_IntersectionStatus theStatus) -{ - if((Index1 >= myTableOfStatus->LowerRow()) && - (Index1 <= myTableOfStatus->UpperRow()) && - (Index2 >= myTableOfStatus->LowerCol()) && - (Index2 <= myTableOfStatus->UpperCol())) { - myTableOfStatus->ChangeValue(Index1, Index2) = theStatus; - } -} - -// ================================================================================================ -// function: GetTableOfIntersectionStatus -// ================================================================================================ - const Handle(BOPTools_HArray2OfIntersectionStatus)& - BOPTools_IteratorOfCoupleOfShape::GetTableOfIntersectionStatus() const -{ - return myTableOfStatus; -} - -// ================================================================================================ -// function: DumpTableOfIntersectionStatus -// ================================================================================================ - void BOPTools_IteratorOfCoupleOfShape::DumpTableOfIntersectionStatus() const -{ - cout << "*BOPTools_IteratorOfCoupleOfShape::DumpTableOfIntersectionStatus.BEGIN*" << endl; - cout << "myTableOfStatus.LowerRow="<< myTableOfStatus->LowerRow() << endl; - cout << "myTableOfStatus.UpperRow="<< myTableOfStatus->UpperRow() << endl; - cout << "myTableOfStatus.LowerCol()="<< myTableOfStatus->LowerCol() << endl; - cout << "myTableOfStatus.UpperCol()="<< myTableOfStatus->UpperCol() << endl; - for(Standard_Integer k=myTableOfStatus->LowerCol(); k<=myTableOfStatus->UpperCol(); k++) { - cout << k << " "; - } - cout << endl; - for(Standard_Integer i=myTableOfStatus->LowerRow(); i<=myTableOfStatus->UpperRow(); i++) { - for(Standard_Integer j=myTableOfStatus->LowerCol(); j<=myTableOfStatus->UpperCol(); j++) { - cout << myTableOfStatus->Value(i, j) << " "; - } - cout << endl; - } - cout << "*BOPTools_IteratorOfCoupleOfShape::DumpTableOfIntersectionStatus.END*" << endl; -} diff --git a/src/BOPTools/BOPTools_ListOfConnexityBlock.hxx b/src/BOPTools/BOPTools_ListOfConnexityBlock.hxx new file mode 100644 index 0000000000..87f4027822 --- /dev/null +++ b/src/BOPTools/BOPTools_ListOfConnexityBlock.hxx @@ -0,0 +1,30 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPTools_ListOfConnexityBlock_HeaderFile +#define BOPTools_ListOfConnexityBlock_HeaderFile + +#include +#include + +typedef NCollection_List BOPTools_ListOfConnexityBlock; +typedef BOPTools_ListOfConnexityBlock::Iterator BOPTools_ListIteratorOfListOfConnexityBlock; + + +#endif diff --git a/src/BOPTools/BOPTools_ListOfCoupleOfShape.hxx b/src/BOPTools/BOPTools_ListOfCoupleOfShape.hxx new file mode 100644 index 0000000000..49b4ea1e04 --- /dev/null +++ b/src/BOPTools/BOPTools_ListOfCoupleOfShape.hxx @@ -0,0 +1,29 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPTools_ListOfCoupleOfShape_HeaderFile +#define BOPTools_ListOfCoupleOfShape_HeaderFile + +#include +#include + +typedef NCollection_List BOPTools_ListOfCoupleOfShape; +typedef BOPTools_ListOfCoupleOfShape::Iterator BOPTools_ListIteratorOfListOfCoupleOfShape; + +#endif diff --git a/src/BOPTools/BOPTools_ListOfEdgeSet.hxx b/src/BOPTools/BOPTools_ListOfEdgeSet.hxx new file mode 100644 index 0000000000..db17503cf3 --- /dev/null +++ b/src/BOPTools/BOPTools_ListOfEdgeSet.hxx @@ -0,0 +1,30 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPTools_ListOfEdgeSet_HeaderFile +#define BOPTools_ListOfEdgeSet_HeaderFile + +#include +#include + +typedef NCollection_List BOPTools_ListOfEdgeSet; +typedef BOPTools_ListOfEdgeSet::Iterator BOPTools_ListIteratorOfListOfEdgeSet; + + +#endif diff --git a/src/BOPTools/BOPTools_ListOfShapeSet.hxx b/src/BOPTools/BOPTools_ListOfShapeSet.hxx new file mode 100644 index 0000000000..6ca9460a08 --- /dev/null +++ b/src/BOPTools/BOPTools_ListOfShapeSet.hxx @@ -0,0 +1,31 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPTools_ListOfShapeSet_HeaderFile +#define BOPTools_ListOfShapeSet_HeaderFile + + +#include +#include + +typedef NCollection_List BOPTools_ListOfShapeSet; +typedef BOPTools_ListOfShapeSet::Iterator BOPTools_ListIteratorOfListOfShapeSet; + + +#endif diff --git a/src/BOPTools/BOPTools_MapOfSet.hxx b/src/BOPTools/BOPTools_MapOfSet.hxx new file mode 100644 index 0000000000..480e5cf90d --- /dev/null +++ b/src/BOPTools/BOPTools_MapOfSet.hxx @@ -0,0 +1,34 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef BOPTest_MapOfShapeSet_HeaderFile +#define BOPTest_MapOfShapeSet_HeaderFile + +#include +#include + +#define _NCollection_MapHasher +#include + +typedef NCollection_Map BOPTools_MapOfSet; +typedef BOPTools_MapOfSet::Iterator BOPTools_MapIteratorOfMapOfSet; + +#undef _NCollection_MapHasher + +#endif diff --git a/src/BOPTools/BOPTools_PCurveMaker.cdl b/src/BOPTools/BOPTools_PCurveMaker.cdl deleted file mode 100755 index 3dec0441d9..0000000000 --- a/src/BOPTools/BOPTools_PCurveMaker.cdl +++ /dev/null @@ -1,55 +0,0 @@ --- Created on: 2001-05-30 --- Created by: Peter KURNEV --- Copyright (c) 2001-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class PCurveMaker from BOPTools - - ---Purpose: - -- Class provides computation p-curves for the edges and theirs - --- split parts - -uses - PPaveFiller from BOPTools, - PaveFiller from BOPTools, - PInterferencePool from BOPTools, - PShapesDataStructure from BooleanOperations - -is - Create (aFiller: PaveFiller from BOPTools) - returns PCurveMaker from BOPTools; - ---Purpose: - --- Constructor - --- - Do(me:out); - ---Purpose: - --- Launch the processor - --- - IsDone(me) - returns Boolean from Standard; - ---Purpose: - --- Returns TRUE if Ok - --- - -fields - myFiller : PPaveFiller from BOPTools; - myDS : PShapesDataStructure from BooleanOperations; - myIsDone : Boolean from Standard; - -end PCurveMaker; diff --git a/src/BOPTools/BOPTools_PCurveMaker.cxx b/src/BOPTools/BOPTools_PCurveMaker.cxx deleted file mode 100755 index 5e9ccac86e..0000000000 --- a/src/BOPTools/BOPTools_PCurveMaker.cxx +++ /dev/null @@ -1,262 +0,0 @@ -// Created on: 2001-05-30 -// Created by: Peter KURNEV -// Copyright (c) 2001-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include - -#include -#include - -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - -#include -#include -#include - -#include -#include - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//modified by NIZNHY-PKV Tue Jun 28 13:24:42 2011f -static - void UpdateVertices(const TopoDS_Edge& aE, const TopoDS_Face& aF); -//modified by NIZNHY-PKV Tue Jun 28 13:24:46 2011t - -//======================================================================= -// function: BOPTools_PCurveMaker -// purpose: -//======================================================================= - BOPTools_PCurveMaker::BOPTools_PCurveMaker(const BOPTools_PaveFiller& aFiller) -: - myIsDone(Standard_False) -{ - myFiller=(BOPTools_PaveFiller*) &aFiller; - myDS=myFiller->DS(); -} -//======================================================================= -// function: IsDone -// purpose: -//======================================================================= - Standard_Boolean BOPTools_PCurveMaker::IsDone() const -{ - return myIsDone; -} -//======================================================================= -// function: Do -// purpose: -//======================================================================= - void BOPTools_PCurveMaker::Do() -{ - BOPTools_CArray1OfSSInterference& aFFs=(myFiller->InterfPool())->SSInterferences(); - - Standard_Integer i, aNb, nF1, nF2, nE; - BOPTools_ListIteratorOfListOfPaveBlock anIt; - - aNb=aFFs.Extent(); - for (i=1; i<=aNb; i++) { - BOPTools_SSInterference& aFF=aFFs(i); - // Faces - nF1=aFF.Index1(); - const TopoDS_Face& aF1=TopoDS::Face(myDS->Shape(nF1)); - nF2=aFF.Index2(); - const TopoDS_Face& aF2=TopoDS::Face(myDS->Shape(nF2)); - // - // 1.Forwarding the Faces - TopoDS_Face aF1FWD=aF1; - aF1FWD.Orientation(TopAbs_FORWARD); - TopoDS_Face aF2FWD=aF2; - aF2FWD.Orientation(TopAbs_FORWARD); - // - // 2. In, On parts processing - const BOPTools_ListOfPaveBlock& aLPBInOn=aFF.PaveBlocks(); - anIt.Initialize(aLPBInOn); - for (; anIt.More(); anIt.Next()) { - const BOPTools_PaveBlock& aPBInOn=anIt.Value(); - nE=aPBInOn.Edge(); - const TopoDS_Edge& aE=TopoDS::Edge(myDS->Shape(nE)); - - BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aE, aF1FWD); - BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aE, aF2FWD); - } - // - // 3. Section Edges processing - Standard_Integer j, aNbCurves, k, aNbV; - BOPTools_SequenceOfCurves& aSC=aFF.Curves(); - aNbCurves=aSC.Length(); - for (j=1; j<=aNbCurves; j++) { - const BOPTools_Curve& aBC=aSC(j); - const BOPTools_ListOfPaveBlock& aLPB=aBC.NewPaveBlocks(); - anIt.Initialize(aLPB); - for (; anIt.More(); anIt.Next()) { - const BOPTools_PaveBlock& aPB=anIt.Value(); - nE=aPB.Edge(); - const TopoDS_Edge& aE=TopoDS::Edge(myDS->Shape(nE)); - // - Standard_Real aTolEdge, aTolR2D, aTolFact, aTolV, aTolVmax; - // - aTolEdge=BRep_Tool::Tolerance(aE); - aTolR2D=aFF.TolR2D(); - aTolFact=Max(aTolEdge, aTolR2D); - // - // Check vertices tolerances and correct them if necessary - // to prevent situation when TolE > TolV - // - TopTools_IndexedMapOfShape aVMap; - TopExp::MapShapes(aE, TopAbs_VERTEX, aVMap); - - aTolVmax=-1.; - aNbV=aVMap.Extent(); - for (k=1; k<=aNbV; ++k) { - const TopoDS_Vertex& aV=TopoDS::Vertex(aVMap(k)); - aTolV=BRep_Tool::Tolerance(aV); - if (aTolV>aTolVmax) { - aTolVmax=aTolV; - } - } - // - if (aTolFact>aTolVmax) { - aTolFact=aTolVmax; - } - // - BRep_Builder aBB; - const IntTools_Curve& aIC=aBC.Curve(); - - //ZZ const Handle(Geom_Curve)& aC3D=aIC.Curve(); - // - Standard_Real aTFirst, aTLast, aOutFirst, aOutLast, aOutTol; - const Handle(Geom_Curve)& aC3DE=BRep_Tool::Curve(aE, aTFirst, aTLast); - Handle(Geom_TrimmedCurve)aC3DETrim=new Geom_TrimmedCurve(aC3DE, aTFirst, aTLast); - // - Handle(Geom2d_Curve) aC2D1, aC2D1A, aC2D2, aC2D2A; - // - aC2D1=aIC.FirstCurve2d(); - if (aC2D1.IsNull()) { - BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aE, aF1FWD); - BOPTools_Tools2D::CurveOnSurface(aE, aF1FWD, aC2D1, aOutFirst, aOutLast, aOutTol, Standard_True); - } - // - if (aC3DE->IsPeriodic()) { - BOPTools_Tools2D::AdjustPCurveOnFace(aF1FWD, aTFirst, aTLast, aC2D1, aC2D1A); - } - else { - BOPTools_Tools2D::AdjustPCurveOnFace(aF1FWD, aC3DETrim, aC2D1, aC2D1A); - } - // - aBB.UpdateEdge(aE, aC2D1A, aF1FWD, aTolFact); - //modified by NIZNHY-PKV Tue Jun 28 07:52:55 2011f - UpdateVertices(aE, aF1FWD); - //modified by NIZNHY-PKV Tue Jun 28 07:52:57 2011t - - aC2D2=aIC.SecondCurve2d(); - if (aC2D2.IsNull()) { - BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aE, aF2FWD); - BOPTools_Tools2D::CurveOnSurface(aE, aF2FWD, aC2D2, aOutFirst, aOutLast, aOutTol, Standard_True); - } - // - if (aC3DE->IsPeriodic()) { - BOPTools_Tools2D::AdjustPCurveOnFace(aF2FWD, aTFirst, aTLast, aC2D2, aC2D2A); - } - else { - BOPTools_Tools2D::AdjustPCurveOnFace(aF2FWD, aC3DETrim, aC2D2, aC2D2A); - } - // - aBB.UpdateEdge(aE, aC2D2A, aF2FWD, aTolFact); - //modified by NIZNHY-PKV Tue Jun 28 07:52:55 2011f - UpdateVertices(aE, aF2FWD); - //modified by NIZNHY-PKV Tue Jun 28 07:52:57 2011t - } - }// for (j=1; j<=aNbCurves; j++) - - } // for (i=1; i<=aNb; i++) - myIsDone=Standard_True; -} - -//modified by NIZNHY-PKV Tue Jun 28 07:37:47 2011f -//======================================================================= -//function : UpdateVertices -//purpose : update tolerances of vertices comparing extremities of -// 3d and 2d curves -//======================================================================= -void UpdateVertices(const TopoDS_Edge& aE, const TopoDS_Face& aF) -{ - Standard_Integer j; - Standard_Real aT[2], aUx, aVx, aTolV2, aD2, aD; - gp_Pnt aP3D, aP3Dx; - gp_Pnt2d aP2Dx; - Handle(Geom_Surface) aS; - Handle(Geom_Curve) aC3D; - Handle(Geom2d_Curve) aC2D; - TopoDS_Edge aEf; - TopoDS_Vertex aV[2]; - BRep_Builder aBB; - // - aEf=aE; - aEf.Orientation(TopAbs_FORWARD); - // - TopExp::Vertices(aEf, aV[0], aV[1]); - // - aS=BRep_Tool::Surface(aF); - aC3D=BRep_Tool::Curve(aEf, aT[0], aT[1]); - aC2D=BRep_Tool::CurveOnSurface(aEf, aF, aT[0], aT[1]); - // - for (j=0; j<2; ++j) { - aTolV2=BRep_Tool::Tolerance(aV[j]); - aTolV2=aTolV2*aTolV2; - // - aC3D->D0(aT[j], aP3D); - aC2D->D0(aT[j], aP2Dx); - aP2Dx.Coord(aUx, aVx); - aS->D0(aUx, aVx, aP3Dx); - aD2=aP3D.SquareDistance(aP3Dx); - if (aD2>aTolV2) { - aD=sqrt(aD2); - aBB.UpdateVertex(aV[j], aD); - } - } -} -//modified by NIZNHY-PKV Tue Jun 28 07:37:50 2011t diff --git a/src/BOPTools/BOPTools_Pave.cdl b/src/BOPTools/BOPTools_Pave.cdl deleted file mode 100755 index 344be52a0b..0000000000 --- a/src/BOPTools/BOPTools_Pave.cdl +++ /dev/null @@ -1,96 +0,0 @@ --- Created on: 2001-02-08 --- Created by: Peter KURNEV --- Copyright (c) 2001-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class Pave from BOPTools - - ---Purpose: - -- Class for storing info about a vertex on an edge - -uses - KindOfInterference from BooleanOperations - -is - Create - returns Pave from BOPTools; - ---Purpose: - --- Empty constructor - --- - Create (Index: Integer from Standard; - aParam:Real from Standard; - aType: KindOfInterference from BooleanOperations - =BooleanOperations_UnknownInterference) - returns Pave from BOPTools; - ---Purpose: - --- Constructor - --- Index - DS-index of the vertex - --- aParam - value of the parameter of the vertex on an edge - --- aType - the type of interference from which the pave comes from - --- - SetParam (me:out; aParam:Real from Standard); - ---Purpose: - --- Modifier - --- - SetIndex (me:out; Index: Integer from Standard); - ---Purpose: - --- Modifier - --- - SetType (me:out; aType:KindOfInterference from BooleanOperations); - ---Purpose: - --- Modifier - --- - SetInterference (me:out; Index: Integer from Standard); - ---Purpose: - --- Modifier - --- Sets the index of the interference in corresponding table - --- - Param (me) - returns Real from Standard; - ---Purpose: - --- Selector - --- - Index (me) - returns Integer from Standard; - ---Purpose: - --- Selector - --- - Type (me) - returns KindOfInterference from BooleanOperations; - ---Purpose: - --- Selector - --- - Interference(me) - returns Integer from Standard; - ---Purpose: - --- Selector - --- - IsEqual(me; Other:Pave from BOPTools) - returns Boolean from Standard; - ---Purpose: - --- Returns TRUE if ==me - --- -fields - myParam: Real from Standard; - myIndex: Integer from Standard; - myType : KindOfInterference from BooleanOperations; - myInterf: Integer from Standard; -end Pave; - - diff --git a/src/BOPTools/BOPTools_Pave.cxx b/src/BOPTools/BOPTools_Pave.cxx deleted file mode 100755 index 13cf6623d8..0000000000 --- a/src/BOPTools/BOPTools_Pave.cxx +++ /dev/null @@ -1,130 +0,0 @@ -// Created on: 2001-02-08 -// Created by: Peter KURNEV -// Copyright (c) 2001-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#include - -//======================================================================= -// function: BOPTools_Pave::BOPTools_Pave -// purpose: -//======================================================================= -BOPTools_Pave::BOPTools_Pave() - : - myParam(0.), - myIndex(0), - myType(BooleanOperations_UnknownInterference), - myInterf(0) -{} -//======================================================================= -// function: BOPTools_Pave::BOPTools_Pave -// purpose: -//======================================================================= - BOPTools_Pave::BOPTools_Pave(const Standard_Integer anIndex, - const Standard_Real aParam, - const BooleanOperations_KindOfInterference aType) - : - myParam(aParam), - myIndex(anIndex), - myType(aType), - myInterf(0) -{} -//======================================================================= -// function: SetParam -// purpose: -//======================================================================= - void BOPTools_Pave::SetParam(const Standard_Real aParam) -{ - myParam=aParam; -} -//======================================================================= -// function: SetIndex -// purpose: -//======================================================================= - void BOPTools_Pave::SetIndex(const Standard_Integer anIndex) -{ - myIndex=anIndex; -} -//======================================================================= -// function: SetType -// purpose: -//======================================================================= - void BOPTools_Pave::SetType(const BooleanOperations_KindOfInterference aType) -{ - myType=aType; -} -//======================================================================= -// function: SetInterference -// purpose: -//======================================================================= - void BOPTools_Pave::SetInterference(const Standard_Integer anIndex) -{ - myInterf=anIndex; -} -//======================================================================= -// function: Param -// purpose: -//======================================================================= - Standard_Real BOPTools_Pave::Param() const -{ - return myParam; -} -//======================================================================= -// function: Index -// purpose: -//======================================================================= - Standard_Integer BOPTools_Pave::Index() const -{ - return myIndex; -} -//======================================================================= -// function: Type -// purpose: -//======================================================================= - BooleanOperations_KindOfInterference BOPTools_Pave::Type() const -{ - return myType; -} -//======================================================================= -// function: Interference -// purpose: -//======================================================================= - Standard_Integer BOPTools_Pave::Interference() const -{ - return myInterf; -} -//======================================================================= -// function: IsEqual -// purpose: -//======================================================================= - Standard_Boolean BOPTools_Pave::IsEqual(const BOPTools_Pave& Other) const -{ - Standard_Integer anIndOther; - Standard_Real aParamOther, dt=1.e-14; - - anIndOther=Other.Index(); - if (anIndOther!=myIndex) { - return Standard_False; - } - - aParamOther=Other.Param(); - if (fabs (aParamOther-myParam) > dt){ - return Standard_False; - } - return Standard_True; -} diff --git a/src/BOPTools/BOPTools_PaveBlock.cdl b/src/BOPTools/BOPTools_PaveBlock.cdl deleted file mode 100755 index ca92cc32a3..0000000000 --- a/src/BOPTools/BOPTools_PaveBlock.cdl +++ /dev/null @@ -1,197 +0,0 @@ --- Created on: 2001-02-15 --- Created by: Peter KURNEV --- Copyright (c) 2001-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class PaveBlock from BOPTools - - ---Purpose: - -- Class for storing info about a couple - --- of neighbouring paves on an edge - -uses - Pave from BOPTools, - PointBetween from BOPTools, - Range from IntTools, - ShrunkRange from IntTools, - Curve from IntTools - - - -is - Create - returns PaveBlock from BOPTools; - ---Purpose: - --- Empty constructor - --- - Create (anEdge: Integer from Standard; - aPave1: Pave from BOPTools; - aPave2: Pave from BOPTools); - ---Purpose: - --- Constructor - --- Index - DS-index of the edge - --- aPave1 - one pave - --- aPave2 - other pave - --- - SetEdge (me:out; - anEdge:Integer from Standard); - ---Purpose: - --- Modifier - --- Sets DS-index for the edge that is between aPave1 and aPave2 - --- - SetOriginalEdge (me:out; - anEdge:Integer from Standard); - ---Purpose: - --- Modifier - --- Sets DS-index for the edge from which this pave block comes from - --- - SetPave1(me:out; - aPave: Pave from BOPTools); - ---Purpose: - --- Modifier - --- - SetPave2(me:out; - aPave: Pave from BOPTools); - ---Purpose: - --- Modifier - --- - SetShrunkRange (me:out; - aSR:ShrunkRange from IntTools); - ---Purpose: - --- Modifier - --- Sets the Shrunk Range for the pave block - --- - SetPointBetween (me:out; - aP: PointBetween from BOPTools); - ---Purpose: - --- Modifier - --- Sets the point between the paves for the pave block - --- - - --- Case of Face/Face Pave Block - --- - SetCurve (me:out; - aC:Curve from IntTools); - ---Purpose: - --- Modifier - --- Sets the intersection curve to which the pave block belongs to - --- - SetFace1 (me:out; - nF1:Integer from Standard); - ---Purpose: - --- Modifier - --- Sets the DS-index of the first face - --- - SetFace2 (me:out; - nF2:Integer from Standard); - ---Purpose: - --- Modifier - --- Sets the DS-index of the second face - --- - Edge (me) - returns Integer from Standard; - ---Purpose: - --- Selector - --- - OriginalEdge(me) - returns Integer from Standard; - ---Purpose: - --- Selector - --- - Pave1(me) - returns Pave from BOPTools; - ---C++: return const & - ---Purpose: - --- Selector - --- - Pave2(me) - returns Pave from BOPTools; - ---C++: return const & - ---Purpose: - --- Selector - --- - IsValid(me) - returns Boolean from Standard; - ---Purpose: - --- Returns TRUE if both paves have vertex index !=0 - --- - IsEqual(me; - Other:PaveBlock from BOPTools) - returns Boolean from Standard; - ---Purpose: - --- Returns TRUE if is equal to me - --- - Parameters (me; - aT1:out Real from Standard; - aT2:out Real from Standard); - ---Purpose: - --- Returns values for paves' parameters - --- - Range (me) - returns Range from IntTools; - ---C++: return const & - ---Purpose: - --- Returns parmetric range for paves' parameters - --- - ShrunkRange(me) - returns ShrunkRange from IntTools; - ---C++: return const & - ---Purpose: - --- Selector - --- - PointBetween (me) - returns PointBetween from BOPTools; - ---C++: return const & - ---Purpose: - --- Selector - --- - Curve(me) - returns Curve from IntTools; - ---C++: return const & - ---Purpose: - --- Selector - --- - Face1(me) - returns Integer from Standard; - ---Purpose: - --- Selector - --- - Face2(me) - returns Integer from Standard; - ---Purpose: - --- Selector - --- - IsInBlock(me; - aPaveX: Pave from BOPTools) - returns Boolean from Standard; - -fields - - myEdge : Integer from Standard; - myOriginalEdge : Integer from Standard; - myPave1 : Pave from BOPTools; - myPave2 : Pave from BOPTools; - myRange : Range from IntTools; - myShrunkRange : ShrunkRange from IntTools; - myCurve : Curve from IntTools; - myFace1 : Integer from Standard; - myFace2 : Integer from Standard; - myPointBetween : PointBetween from BOPTools; - -end PaveBlock; diff --git a/src/BOPTools/BOPTools_PaveBlock.cxx b/src/BOPTools/BOPTools_PaveBlock.cxx deleted file mode 100755 index 1efcdbc805..0000000000 --- a/src/BOPTools/BOPTools_PaveBlock.cxx +++ /dev/null @@ -1,303 +0,0 @@ -// Created on: 2001-02-15 -// Created by: Peter KURNEV -// Copyright (c) 2001-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include - -//======================================================================= -// function: BOPTools_PaveBlock::BOPTools_PaveBlock -// purpose: -//======================================================================= -BOPTools_PaveBlock::BOPTools_PaveBlock() - : - myEdge(0), - myOriginalEdge(0), - myFace1(0), - myFace2(0) -{} -//======================================================================= -// function: BOPTools_PaveBlock::BOPTools_PaveBlock -// purpose: -//======================================================================= - BOPTools_PaveBlock::BOPTools_PaveBlock(const Standard_Integer theEdge, - const BOPTools_Pave& thePave1, - const BOPTools_Pave& thePave2) -{ - myOriginalEdge=theEdge; - myPave1=thePave1; - myPave2=thePave2; - myFace1=0; - myFace2=0; -} - -//======================================================================= -// function: SetCurve -// purpose: -//======================================================================= - void BOPTools_PaveBlock::SetCurve(const IntTools_Curve& aC) -{ - myCurve=aC; -} -//======================================================================= -// function: SetFace1 -// purpose: -//======================================================================= - void BOPTools_PaveBlock::SetFace1(const Standard_Integer theFace1) -{ - myFace1=theFace1; -} -//======================================================================= -// function: SetFace2 -// purpose: -//======================================================================= - void BOPTools_PaveBlock::SetFace2(const Standard_Integer theFace2) -{ - myFace2=theFace2; -} - -//======================================================================= -// function: Face1 -// purpose: -//======================================================================= - Standard_Integer BOPTools_PaveBlock::Face1() const -{ - return myFace1; -} -//======================================================================= -// function: Face2 -// purpose: -//======================================================================= - Standard_Integer BOPTools_PaveBlock::Face2() const -{ - return myFace2; -} -//======================================================================= -// function: Curve -// purpose: -//======================================================================= - const IntTools_Curve& BOPTools_PaveBlock::Curve() const -{ - return myCurve; -} - -//======================================================================= -// function: SetEdge -// purpose: -//======================================================================= - void BOPTools_PaveBlock::SetEdge(const Standard_Integer theEdge) -{ - myEdge=theEdge; -} -//======================================================================= -// function: SetOriginalEdge -// purpose: -//======================================================================= - void BOPTools_PaveBlock::SetOriginalEdge(const Standard_Integer theEdge) -{ - myOriginalEdge=theEdge; -} - -//======================================================================= -// function: SetPave1 -// purpose: -//======================================================================= - void BOPTools_PaveBlock::SetPave1(const BOPTools_Pave& thePave1) -{ - myPave1=thePave1; - -} -//======================================================================= -// function: SetPave2 -// purpose: -//======================================================================= - void BOPTools_PaveBlock::SetPave2(const BOPTools_Pave& thePave2) -{ - myPave2=thePave2; -} - -//======================================================================= -// function: SetShrunkRange -// purpose: -//======================================================================= - void BOPTools_PaveBlock::SetShrunkRange(const IntTools_ShrunkRange& theSR) -{ - myShrunkRange=theSR; -} - -//======================================================================= -// function: SetPointBetween -// purpose: -//======================================================================= - void BOPTools_PaveBlock::SetPointBetween (const BOPTools_PointBetween& thePB) -{ - myPointBetween=thePB; -} - -//======================================================================= -// function: PointBetween -// purpose: -//======================================================================= - const BOPTools_PointBetween& BOPTools_PaveBlock::PointBetween ()const -{ - return myPointBetween; -} - -//======================================================================= -// function: Pave1 -// purpose: -//======================================================================= - const BOPTools_Pave& BOPTools_PaveBlock::Pave1() const -{ - Standard_Real t1, t2; - - t1=myPave1.Param(); - t2=myPave2.Param(); - - if (t1t2) { - return myPave1; - } - return myPave2; -} - -//======================================================================= -// function: Edge -// purpose: -//======================================================================= - Standard_Integer BOPTools_PaveBlock::Edge() const -{ - return myEdge; -} - -//======================================================================= -// function: OriginalEdge -// purpose: -//======================================================================= - Standard_Integer BOPTools_PaveBlock::OriginalEdge() const -{ - return myOriginalEdge; -} - -//======================================================================= -// function: IsValid -// purpose: -//======================================================================= - Standard_Boolean BOPTools_PaveBlock::IsValid() const -{ - Standard_Integer anInd1, anInd2; - anInd1=myPave1.Index(); - anInd2=myPave2.Index(); - - return (anInd1 && anInd2); -} -//======================================================================= -// function: IsEqual -// purpose: -//======================================================================= - Standard_Boolean BOPTools_PaveBlock::IsEqual(const BOPTools_PaveBlock& Other) const -{ - if (myOriginalEdge==Other.myOriginalEdge) { - - const BOPTools_Pave& aP11=Pave1(); - const BOPTools_Pave& aP12=Pave2(); - const BOPTools_Pave& aP21=Other.Pave1(); - const BOPTools_Pave& aP22=Other.Pave2(); - - if (aP11.IsEqual(aP21)) { - if (aP12.IsEqual(aP22)) { - return Standard_True; - } - } - } - return Standard_False; -} -//======================================================================= -// function: Parameters -// purpose: -//======================================================================= - void BOPTools_PaveBlock::Parameters(Standard_Real& aT1, - Standard_Real& aT2) const -{ - Standard_Real t1, t2; - t1=myPave1.Param(); - t2=myPave2.Param(); - aT1= (t1t2) ? t1 : t2; -} -//======================================================================= -// function: Range -// purpose: -//======================================================================= - const IntTools_Range& BOPTools_PaveBlock::Range() const -{ - Standard_Real t1, t2; - t1=myPave1.Param(); - t2=myPave2.Param(); - - IntTools_Range* pRange=(IntTools_Range*) &myRange; - - if (t1SetFirst (t1); - pRange->SetLast (t2); - } - else { - pRange->SetFirst (t2); - pRange->SetLast (t1); - } - return myRange; -} - -//======================================================================= -// function: ShrunkRange -// purpose: -//======================================================================= - const IntTools_ShrunkRange& BOPTools_PaveBlock::ShrunkRange()const -{ - return myShrunkRange; -} -//======================================================================= -// function: IsInBlock -// purpose: -//======================================================================= - Standard_Boolean BOPTools_PaveBlock::IsInBlock(const BOPTools_Pave& thePaveX) const -{ - Standard_Boolean bIsInBlock; - Standard_Real aT1, aT2, aTx; - // - aTx=thePaveX.Param(); - Parameters(aT1, aT2); - bIsInBlock=(aTx > aT1 && aTx < aT2); - return bIsInBlock; -} diff --git a/src/BOPTools/BOPTools_PaveBlockIterator.cdl b/src/BOPTools/BOPTools_PaveBlockIterator.cdl deleted file mode 100755 index 7dff61ca39..0000000000 --- a/src/BOPTools/BOPTools_PaveBlockIterator.cdl +++ /dev/null @@ -1,75 +0,0 @@ --- Created on: 2001-03-07 --- Created by: Peter KURNEV --- Copyright (c) 2001-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class PaveBlockIterator from BOPTools - - ---Purpose: - --- class providing iterations for PaveSet to - --- have the right order of paves along the edge - --- -uses - PaveSet from BOPTools, - CArray1OfPave from BOPTools, - PaveBlock from BOPTools - -is - Create - returns PaveBlockIterator from BOPTools; - ---Purpose: - --- Empty constructor - --- - Create (aEdge : Integer from Standard; - aPaveSet: PaveSet from BOPTools) - returns PaveBlockIterator from BOPTools; - ---Purpose: - --- Constructor - --- aEdge - DS-index of the edge - --- aPaveSet - a set of paves for the edge - --- - Initialize(me:out;aEdge : Integer from Standard; - aPaveSet: PaveSet from BOPTools); - ---Purpose: - --- Resets the iterator on the PaveSet - --- - More(me) - returns Boolean from Standard; - ---Purpose: - --- Returns True if there is a current Pave in - --- the iteration. - --- - Next(me:out); - ---Purpose: - --- Moves to the next Pave in the PaveSet - --- - Value(me:out) - returns PaveBlock from BOPTools; - ---C++: return & - ---Purpose: - --- Returns the current Pave - --- -fields - myEdge : Integer from Standard; - myIndex : Integer from Standard; - myPaveSet : PaveSet from BOPTools; - myPaves : CArray1OfPave from BOPTools; - myPaveBlock: PaveBlock from BOPTools; - -end PaveBlockIterator; diff --git a/src/BOPTools/BOPTools_PaveBlockIterator.cxx b/src/BOPTools/BOPTools_PaveBlockIterator.cxx deleted file mode 100755 index ac6ce2e30c..0000000000 --- a/src/BOPTools/BOPTools_PaveBlockIterator.cxx +++ /dev/null @@ -1,117 +0,0 @@ -// Created on: 2001-03-07 -// Created by: Peter KURNEV -// Copyright (c) 2001-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include - -#include -#include -#include - -//======================================================================= -// function:BOPTools_PaveBlockIterator -// purpose: -//======================================================================= -BOPTools_PaveBlockIterator::BOPTools_PaveBlockIterator() - : - myEdge(0), - myIndex(1) -{ -} -//======================================================================= -// function:BOPTools_PaveBlockIterator -// purpose: -//======================================================================= - BOPTools_PaveBlockIterator::BOPTools_PaveBlockIterator (const Standard_Integer anEdge, - const BOPTools_PaveSet& aPaveSet) -{ - Initialize (anEdge, aPaveSet); -} -//======================================================================= -// function:Initialize -// purpose: -//======================================================================= - void BOPTools_PaveBlockIterator::Initialize(const Standard_Integer anEdge, - const BOPTools_PaveSet& aPaveSet) -{ - Standard_Integer i, aNb; - - myPaveSet=aPaveSet; - myIndex=1; - myEdge=anEdge; - myPaveBlock.SetOriginalEdge(myEdge); - - myPaveSet.SortSet(); - BOPTools_ListOfPave& aLP=myPaveSet.ChangeSet(); - aNb=aLP.Extent(); - myPaves.Resize(aNb); - BOPTools_ListIteratorOfListOfPave anIt(aLP); - for (i=1; anIt.More(); anIt.Next(), i++) { - const BOPTools_Pave& aPave=anIt.Value(); - myPaves(i)=aPave; - } -} - -//======================================================================= -// function:More -// purpose: -//======================================================================= - Standard_Boolean BOPTools_PaveBlockIterator::More() const -{ - Standard_Integer aNb; - aNb=myPaves.Extent(); - return (myIndex < aNb); -} -//======================================================================= -// function:Next -// purpose: -//======================================================================= - void BOPTools_PaveBlockIterator::Next() -{ - myIndex++; -} -//======================================================================= -// function:Value -// purpose: -//======================================================================= - BOPTools_PaveBlock& BOPTools_PaveBlockIterator::Value() -{ - Standard_Integer i1, i2; - Standard_Real aT1, aT2; - BOPTools_PaveBlock* pPB= (BOPTools_PaveBlock*) &myPaveBlock; - - i1=myIndex; - i2=i1+1; - const BOPTools_Pave& aPave1=myPaves(i1); - const BOPTools_Pave& aPave2=myPaves(i2); - aT1=aPave1.Param(); - aT2=aPave2.Param(); - - if (aT1 > aT2) { - pPB->SetPave1(aPave1); - pPB->SetPave2(aPave2); - } - else { - pPB->SetPave1(aPave2); - pPB->SetPave2(aPave1); - } - return myPaveBlock; -} - diff --git a/src/BOPTools/BOPTools_PaveBlockMapHasher.cdl b/src/BOPTools/BOPTools_PaveBlockMapHasher.cdl deleted file mode 100755 index 2b4fdde1d6..0000000000 --- a/src/BOPTools/BOPTools_PaveBlockMapHasher.cdl +++ /dev/null @@ -1,43 +0,0 @@ --- Created on: 2003-12-11 --- Created by: Peter KURNEV --- Copyright (c) 2003-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class PaveBlockMapHasher from BOPTools - - ---Purpose: - -uses - PaveBlock from BOPTools - ---raises - -is - HashCode(myclass; - aPB : PaveBlock from BOPTools; - Upper : Integer from Standard) - returns Integer from Standard; - - IsEqual(myclass; - aPB1 : PaveBlock from BOPTools; - aPB2 : PaveBlock from BOPTools) - returns Boolean from Standard; ---fields - -end PaveBlockMapHasher; diff --git a/src/BOPTools/BOPTools_PaveBlockMapHasher.cxx b/src/BOPTools/BOPTools_PaveBlockMapHasher.cxx deleted file mode 100755 index efd6d3f9bc..0000000000 --- a/src/BOPTools/BOPTools_PaveBlockMapHasher.cxx +++ /dev/null @@ -1,51 +0,0 @@ -// Created on: 2003-12-11 -// Created by: Peter KURNEV -// Copyright (c) 2003-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include - -#include -#include - -//======================================================================= -//function : HashCode -//purpose : -//======================================================================= -Standard_Integer BOPTools_PaveBlockMapHasher::HashCode(const BOPTools_PaveBlock& aPB, - const Standard_Integer aUpper) -{ - Standard_Integer aS, nV1, nV2, nE; - // - nV1=aPB.Pave1().Index(); - nV2=aPB.Pave2().Index(); - nE=aPB.OriginalEdge(); - aS=nV1+nV2+nE; - return aS%aUpper; -} - -//======================================================================= -//function :IsEqual -//purpose : -//======================================================================= - Standard_Boolean BOPTools_PaveBlockMapHasher::IsEqual(const BOPTools_PaveBlock& aPB1, - const BOPTools_PaveBlock& aPB2) -{ - return aPB1.IsEqual(aPB2); -} diff --git a/src/BOPTools/BOPTools_PaveFiller.cdl b/src/BOPTools/BOPTools_PaveFiller.cdl deleted file mode 100755 index 8d03afad5a..0000000000 --- a/src/BOPTools/BOPTools_PaveFiller.cdl +++ /dev/null @@ -1,627 +0,0 @@ --- Created on: 2001-02-08 --- Created by: Peter KURNEV --- Copyright (c) 2001-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class PaveFiller from BOPTools - - ---Purpose: The algorithm that provides - --- 1. creation of the data structure (DS) - --- 2. creation of the interferences' pool - --- 3. invocation of Perform() to fill the DS - --- - --- -uses - - PShapesDataStructure from BooleanOperations, - - InterferencePool from BOPTools, - PInterferencePool from BOPTools, - PavePool from BOPTools, - CommonBlockPool from BOPTools, - SplitShapesPool from BOPTools, - - Pave from BOPTools, - PaveBlock from BOPTools, - PaveSet from BOPTools, - Curve from BOPTools, - SSInterference from BOPTools, - ListOfPaveBlock from BOPTools, - IteratorOfCoupleOfShape from BOPTools, - SSInterference from BOPTools, - SSIntersectionAttribute from BOPTools, - ShrunkRange from IntTools, - Context from IntTools, - - ShapeEnum from TopAbs, - ListOfInteger from TColStd, - IndexedMapOfInteger from TColStd, - - Pnt from gp, - Vertex from TopoDS, - SetOfInteger from TColStd - - -is - - Create - returns PaveFiller from BOPTools; - ---Purpose: - --- Empty Contructor - --- - Create (aIP: InterferencePool from BOPTools) - returns PaveFiller from BOPTools; - ---Purpose: - --- Constructor - --- - Create (theIP : InterferencePool from BOPTools; - theSectionAttribute: SSIntersectionAttribute from BOPTools) - returns PaveFiller from BOPTools; - ---Purpose: - --- Constructor - --- - Destroy (me: in out) - is virtual; - ---C++: alias "Standard_EXPORT virtual ~BOPTools_PaveFiller(){Destroy();}" - ---Purpose: - --- Destructor - --- - Perform (me:out) - is virtual; - ---Purpose: - --- Fills the DS - --- - - PartialPerform(me:out; anObjSubSet, aToolSubSet: SetOfInteger from TColStd) - is virtual; - - ToCompletePerform(me:out) - is virtual; - - PerformVV (me:out) - is virtual protected; - ---Purpose: - --- Computes Vertex/Vertex interferences - --- - PerformVE (me:out) - is virtual protected; - ---Purpose: - --- Computes Vertex/Edge interferences - --- - PerformVF (me:out) - is virtual protected; - ---Purpose: - --- Computes Vertex/Face interferences - --- - PerformEE (me:out) - is virtual protected; - ---Purpose: - --- Computes Edge/Edge interferences - --- - PerformEF (me:out) - is virtual protected; - ---Purpose: - --- Computes Edge/Face interferences - --- - PerformFF (me:out) - is virtual protected; - ---Purpose: - --- Computes Face/Face interferences - --- - - -------------------------------------------------------------- - --- - --- Selectors - --- - --- - SetContext(me:out; - aContext: Context from IntTools); - ---Purpose: - --- Sets the intersecton context - --- - Context(me) - returns Context from IntTools; - ---C++:return const & - ---Purpose: - --- Selector - --- --- ChangeContext(me:out) --- returns Context from IntTools; - -- C++:return & - ---Purpose: - --- Selector - --- - SetInterferencePool(me:out; - aPool:InterferencePool from BOPTools); - ---Purpose: - --- Selector - --- - IsDone(me) - returns Boolean from Standard; - ---Purpose: - --- Selector - --- - PavePool(me) - returns PavePool from BOPTools; - ---C++:return const & - ---Purpose: - --- Selector - --- - ChangePavePool(me:out) - returns PavePool from BOPTools; - ---C++:return & - ---Purpose: - --- Selector - --- - CommonBlockPool(me) - returns CommonBlockPool from BOPTools; - ---C++:return const & - ---Purpose: - --- Selector - --- - ChangeCommonBlockPool(me:out) - returns CommonBlockPool from BOPTools; - ---C++:return & - ---Purpose: - --- Selector - --- - SplitShapesPool(me) - returns SplitShapesPool from BOPTools; - ---C++:return const & - ---Purpose: - --- Selector - --- - - ChangeSplitShapesPool(me:out) - returns SplitShapesPool from BOPTools; - ---C++:return & - ---Purpose: - --- Selector - --- - DS(me:out) - returns PShapesDataStructure from BooleanOperations; - ---Purpose: - --- Selector - --- - InterfPool(me:out) - returns PInterferencePool from BOPTools; - ---Purpose: - --- Selector - --- - - IteratorOfCoupleOfShape(me) - returns IteratorOfCoupleOfShape from BOPTools; - ---C++:return const & - ---Purpose: - --- Selector - --- - - SectionAttribute(me) - returns SSIntersectionAttribute from BOPTools; - ---C++: return const & - ---Purpose: - --- Selector - --- - - SetSectionAttribute(me:out; - anAtt : SSIntersectionAttribute from BOPTools); - ---Purpose: - --- Selector - --- - -------------------------------------------------------------- - --- - --- PaveBlocks for Split Parts of Edges. - --- - --- - SortTypes (me; - anInd1:in out Integer from Standard; - anInd2:in out Integer from Standard) - is protected; - ---Purpose: - --- Sorts the types of shapes with DS-indices - --- and in increasing order of - --- types of the shapes - --- - PerformNewVertices (me:out) - is protected; - - IsSuccesstorsComputed (me; - iF1:Integer from Standard; - iF2:Integer from Standard) - returns Boolean from Standard - is protected; - - PrepareEdges (me:out) - is virtual protected; - ---Purpose: - --- Prepare end paves for each edge - --- - PreparePaveBlocks (me:out; - aType1: ShapeEnum from TopAbs; - aType2: ShapeEnum from TopAbs) - is virtual protected; - ---Purpose: - --- Prepare PaveBlocks for each edge (EE-interferences) - --- - PreparePaveBlocks (me:out; - anE:Integer from Standard) - is virtual protected; - ---Purpose: - --- Prepare PaveBlocks for given edge (EE-interferences) - --- - RefinePavePool(me:out) - is protected; - ---Purpose: - --- Refines myPavePool taking into account new Paves obtained from EE algo - --- - MakeSplitEdges(me:out) - is protected; - ---Purpose: - --- Makes split edges from source edges - --- - DoSDEdges(me:out) - is protected; - ---Purpose: - --- Update Lists of PaveBlocks with info about - --- indices of split edges that are Same Domain - --- with other splits or faces - --- - CorrectShrunkRanges(me:out; - aSide: Integer from Standard; - aPave: Pave from BOPTools; - aSR : out ShrunkRange from IntTools) - is protected; - ---Purpose: - --- Update Shrunk Range for Pave - --- - SplitIndex (me:out; aPB:PaveBlock from BOPTools) - returns Integer from Standard - is protected; - ---Purpose: - --- Returns the Index of Split edge for the PaveBlock - --- in DS. - --- If the PaveBlock is not found, returns 0; - --- - IsBlocksCoinside (me; - aPB1:PaveBlock from BOPTools; - aPB2:PaveBlock from BOPTools) - returns Boolean from Standard - is protected; - ---Purpose: - --- Returns TRUE if the two PaveBlocks have vertices - --- that touch each other in terms of Tolerances of - --- the vertices - --- - -------------------------------------------------------------- - --- - --- Some of API FUNCTIONS - --- - --- - SplitsInFace(me:out; - aBid:Integer from Standard; - nF1 :Integer from Standard; - nF2 :Integer from Standard; - aLs :out ListOfInteger from TColStd) - returns Integer from Standard; - ---Purpose: - --- For the face get all splits that are IN-2D - --- to the face ; The result is in - --- Returns 0 if OK; - --- - SplitsInFace(me:out; - nE1 :Integer from Standard; - nF2 :Integer from Standard; - aLs :out ListOfInteger from TColStd) - returns Integer from Standard; - ---Purpose: - --- For the edge get all splits that are IN-2D - --- to the face ; The result is in - --- Returns 0 if OK; - --- - SplitsOnEdge(me:out; - nE1 :Integer from Standard; - nE2 :Integer from Standard; - aLs :out ListOfInteger from TColStd) - returns Integer from Standard; - ---Purpose: - --- For the edge get all splits that are ON-3D - --- to the edge ; The result is in - --- Returns 0 if OK; - --- - SplitsOnFace(me:out; - nE1 :Integer from Standard; - nF2 :Integer from Standard; - aLs :out ListOfInteger from TColStd) - returns Integer from Standard; - ---Purpose: - --- For the edge get all splits that are ON-3D - --- to the face ; The result is in - --- Returns 0 if OK; - --- - SplitsOnFace(me:out; - aBid:Integer from Standard; - nF1 :Integer from Standard; - nF2 :Integer from Standard; - aLs :out ListOfInteger from TColStd) - returns Integer from Standard; - ---Purpose: - --- For the face get all splits that are ON-3D - --- to the face ; The result is in - --- Returns 0 if OK; - --- - - SplitsInFace(me:out; - aBid:Integer from Standard; - nF1 :Integer from Standard; - nF2 :Integer from Standard; - aLs :out ListOfPaveBlock from BOPTools) - returns Integer from Standard; - ---Purpose: - --- For the face get all PaveBlocks that are IN-2D - --- to the face ; The result is in - --- Returns 0 if OK; - --- - - SplitsInFace(me:out; - nE1 :Integer from Standard; - nF2 :Integer from Standard; - aLs :out ListOfPaveBlock from BOPTools) - returns Integer from Standard; - ---Purpose: - --- For the edge get all PaveBlocks that are IN-2D - --- to the face ; The result is in - --- Returns 0 if OK; - --- - - SplitsOnEdge(me:out; - nE1 :Integer from Standard; - nE2 :Integer from Standard; - aLs :out ListOfPaveBlock from BOPTools) - returns Integer from Standard; - ---Purpose: - --- For the edge get all PaveBlocks that are ON-3D - --- to the edge ; The result is in - --- Returns 0 if OK; - --- - - SplitsOnFace(me:out; - nE1 :Integer from Standard; - nF2 :Integer from Standard; - aLs :out ListOfPaveBlock from BOPTools) - returns Integer from Standard; - ---Purpose: - --- For the edge get all PaveBlocks that are ON-3D - --- to the face ; The result is in - --- Returns 0 if OK; - --- - - SplitsOnFace(me:out; - aBid:Integer from Standard; - nF1 :Integer from Standard; - nF2 :Integer from Standard; - aLs :out ListOfPaveBlock from BOPTools) - returns Integer from Standard; - ---Purpose: - --- For the face get all PaveBlocks that are ON-3D - --- to the face ; The result is in - --- Returns 0 if OK; - --- - FindSDVertex (me; - nV: Integer from Standard) - returns Integer from Standard; - ---Purpose: - --- Find for the vertex SD-vertex (if possible) and return - --- its DS-index. Otherwise it returns 0. - --- - - --------------------------------------------------------------- - --- - --- Section Edges. Protected Block. - --- - --- - MakeBlocks(me:out) - is protected; - ---Purpose: - --- Make Pave Blocks for intersection curves - --- - MakeAloneVertices(me:out) - is protected; - ---Purpose: - --- Make vertices that are place of intersection - --- between faces - --- - PutPaveOnCurve(me:out; - aPaveSet: PaveSet from BOPTools; - aTolR3D : Real from Standard; - aBCurve :out Curve from BOPTools) - is protected; - ---Purpose: - --- Among Paves from find ones that belong - --- to intersection curve with 3D-tolerance - --- value - --- - PutPaveOnCurve(me:out; - aPave : Pave from BOPTools; - aTolR3D : Real from Standard; - aBCurve :out Curve from BOPTools) - is protected; - ---Purpose: - --- Try to put Pave on intersection curve - --- with 3D-tolerance value - --- - - PutPavesOnCurves(me:out) - is protected; - - PrepareSetForFace(me:out; - nF1 :Integer from Standard; - nF2 :Integer from Standard; - aPaveSet:out PaveSet from BOPTools); - ---Purpose: - --- For couple of faces , prepare set of all paves - --- of all edges - --- - MakeSectionEdges(me:out) - is protected; - ---Purpose: - --- For all inrefered faces make section edges from - --- intersection curves and corresp. Paves on them - --- - PutBoundPaveOnCurve (me:out; - aBC :out Curve from BOPTools; - aFF :out SSInterference from BOPTools) - is protected; - ---Purpose: - --- Try to put own bounds of the curve on the curve - --- - PutBoundPaveOnCurve (me:out; - aP : Pnt from gp; - aT : Real from Standard; - aBC :out Curve from BOPTools; - aFF :out SSInterference from BOPTools) - is protected; - ---Purpose: - --- Try to put 3D-point (parameter aT) on the curve - --- - PutBoundPaveOnCurveSpec (me:out; - aBC :out Curve from BOPTools; - aFF :out SSInterference from BOPTools) - is protected; - ---Purpose: - --- Try to put own bounds of the curve on the curve - --- - PutBoundPaveOnCurveSpec (me:out; - aP : Pnt from gp; - aT : Real from Standard; - aBC :out Curve from BOPTools; - aFF :out SSInterference from BOPTools) - is protected; - ---Purpose: - --- Try to put 3D-point (parameter aT) on the curve - --- - ---modified by NIZNHY-PKV Thu Oct 20 07:17:11 2011f - PutClosingPaveOnCurve (me:out; - aBC :out Curve from BOPTools; - aFF :out SSInterference from BOPTools) - is protected; - ---Purpose: - --- Put paves on the curve in case when - -- is closed 3D-curve - --- ---modified by NIZNHY-PKV Thu Oct 20 07:17:11 2011t - - FindPave (me:out; - aP :Pnt from gp; - aTpV: Real from Standard; - aPS: PaveSet from BOPTools; - aPV:out Pave from BOPTools) - returns Boolean from Standard - is protected; - ---Purpose: - --- Returns TRUE if 3D-point coinsides with some Pave - --- from (with 3D-tolerance value ); - --- In TRUE case will contain the Pave . - --- - CheckCoincidence(me:out; - aPB: PaveBlock from BOPTools; - aFF: SSInterference from BOPTools) - returns Boolean from Standard - is protected; - ---Purpose: - --- Returns TRUE if PaveBlock lays on the faces - --- from FF-interference - --- - CheckIntermediatePoint(me:out; - aPB : PaveBlock from BOPTools; - aPBR: PaveBlock from BOPTools; - aTol: Real from Standard) - returns Integer from Standard - is protected; - ---Purpose: - --- Returns 0 if some arbitrary intermediate point from - --- PaveBlock lays on the PaveBlock - --- (with 3D-tolerance value ) - --- - - CheckFacePaves(me:out; - aV : Vertex from TopoDS; - nF: Integer from Standard) - returns Integer from Standard - is protected; - ---Purpose: - --- Internal usage - --- - StickVertices (me:out; - nF1: Integer from Standard; - nF2: Integer from Standard; - aMV:out IndexedMapOfInteger from TColStd) - is protected; - ---Purpose: - --- Internal usage - --- - ExpectedPoolLength(me) - returns Integer from Standard - is protected; - ---Purpose: - --- Returns the value of expected length of array of interferences - --- - - RestrictCurveIn2d(me: in out; nE, nF1, nF2 : Integer from Standard; - theTolerance: Real from Standard; - theBC : in out Curve from BOPTools) - is private; - - RecomputeCommonBlocks(me: in out; nE: Integer from Standard) - is private; - - ExtendedTolerance(me:out; - nV : Integer from Standard; - aTolExt : out Real from Standard) - returns Boolean from Standard - is protected; - -fields - - myIntrPool : PInterferencePool from BOPTools - is protected; - myDS : PShapesDataStructure from BooleanOperations - is protected; - myPavePool : PavePool from BOPTools - is protected; - myPavePoolNew : PavePool from BOPTools - is protected; - myCommonBlockPool : CommonBlockPool from BOPTools - is protected; - mySplitShapesPool : SplitShapesPool from BOPTools - is protected; - mySectionAttribute : SSIntersectionAttribute from BOPTools - is protected; - myNbSources : Integer from Standard - is protected; - myNbEdges : Integer from Standard - is protected; - myIsDone : Boolean from Standard - is protected; - myDSIt : IteratorOfCoupleOfShape from BOPTools - is protected; - myContext : Context from IntTools - is protected; - -end PaveFiller; diff --git a/src/BOPTools/BOPTools_PaveFiller.cxx b/src/BOPTools/BOPTools_PaveFiller.cxx deleted file mode 100755 index 820b075236..0000000000 --- a/src/BOPTools/BOPTools_PaveFiller.cxx +++ /dev/null @@ -1,1794 +0,0 @@ -// Created on: 2001-03-07 -// Created by: Peter KURNEV -// Copyright (c) 2001-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include - -#include - -#include -#include - -#include - -#include - -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -//======================================================================= -// function: BOPTools_PavePoolFiller::BOPTools_PavePoolFiller -// purpose: -//======================================================================= -BOPTools_PaveFiller::BOPTools_PaveFiller() -{ - myIsDone=Standard_False; - myIntrPool=NULL; - myDS=NULL; - myNbSources=0; - myNbEdges=0; -} - -//======================================================================= -// function: BOPTools_PavePoolFiller::BOPTools_PavePoolFiller -// purpose: -//======================================================================= -BOPTools_PaveFiller::BOPTools_PaveFiller(const BOPTools_InterferencePool& aPool) -{ - myIsDone=Standard_False; - void* p=(void*) &aPool; - myIntrPool=(BOPTools_InterferencePool*) p; - myDS=myIntrPool->DS(); - myNbSources=myDS->NumberOfShapesOfTheObject()+myDS->NumberOfShapesOfTheTool(); - myNbEdges=myDS->NbEdges(); -} - -//======================================================================= -// function: Constructor -// purpose: -//======================================================================= -BOPTools_PaveFiller::BOPTools_PaveFiller - (const BOPTools_InterferencePool& theIP, - const BOPTools_SSIntersectionAttribute& theSectionAttribute) -{ - myIsDone=Standard_False; - myIntrPool = (BOPTools_PInterferencePool) &theIP; - myDS = myIntrPool->DS(); - myNbSources=myDS->NumberOfShapesOfTheObject()+myDS->NumberOfShapesOfTheTool(); - myNbEdges=myDS->NbEdges(); - mySectionAttribute = theSectionAttribute; -} - -//======================================================================= -// function: SetInterferencePool -// purpose: -//======================================================================= -void BOPTools_PaveFiller::SetInterferencePool(const BOPTools_InterferencePool& aPool) -{ - myIsDone=Standard_False; - void* p=(void*) &aPool; - myIntrPool=(BOPTools_InterferencePool*) p; - myDS=myIntrPool->DS(); - myNbSources=myDS->NumberOfShapesOfTheObject()+myDS->NumberOfShapesOfTheTool(); - myNbEdges=myDS->NbEdges(); -} - -//======================================================================= -// function: Destroy -// purpose: -//======================================================================= -void BOPTools_PaveFiller::Destroy() -{ -} - -//======================================================================= -// function: SetSectionAttribute -// purpose: -//======================================================================= -void BOPTools_PaveFiller::SetSectionAttribute - (const BOPTools_SSIntersectionAttribute& anAtt) -{ - mySectionAttribute=anAtt; -} -//======================================================================= -// function: SectionAttribute -// purpose: -//======================================================================= -const BOPTools_SSIntersectionAttribute& - BOPTools_PaveFiller::SectionAttribute() const -{ - return mySectionAttribute; -} -//======================================================================= -// function: SetContext -// purpose: -//======================================================================= -void BOPTools_PaveFiller::SetContext(const Handle(IntTools_Context)& aContext) -{ - myContext=aContext; -} -//======================================================================= -// function: Context -// purpose: -//======================================================================= -const Handle(IntTools_Context)& BOPTools_PaveFiller::Context() const -{ - return myContext; -} -//======================================================================= -// function: Perform -// purpose: -//======================================================================= -void BOPTools_PaveFiller::Perform() -{ - try { - // - if (myContext.IsNull()) { - myContext=new IntTools_Context; - } - // - // 0. Prepare the IteratorOfCoupleOfShape - myDSIt.SetDataStructure(myDS); - // - // 1.VV - PerformVV(); - PerformNewVertices(); - // - // 2.VE - myPavePool.Resize (myNbEdges); - PrepareEdges(); - PerformVE(); - // - // 3.VF - PerformVF(); - // - // 4.EE - myCommonBlockPool.Resize (myNbEdges); - mySplitShapesPool.Resize (myNbEdges); - myPavePoolNew .Resize (myNbEdges); - - PreparePaveBlocks(TopAbs_VERTEX, TopAbs_EDGE); - PreparePaveBlocks(TopAbs_EDGE, TopAbs_EDGE); - - PerformEE(); - - RefinePavePool (); - myPavePoolNew.Destroy(); - myPavePoolNew .Resize (myNbEdges); - // - // 5.EF - PreparePaveBlocks(TopAbs_EDGE, TopAbs_FACE); - - PerformEF(); - RefinePavePool(); - // - myPavePoolNew.Destroy(); - - // MakeSplitEdges (); - // DoSDEdges(); - // - // 6. FF - PerformFF (); - - PutPavesOnCurves(); - - MakeSplitEdges (); - DoSDEdges(); - - MakeBlocks(); - - MakeSectionEdges(); - // - MakeAloneVertices(); - // - } // end of try block - - catch (BOPTColStd_Failure& x) { - cout << x.Message() << endl << flush; - } - -} - -//======================================================================= -// function: PartialPerform -// purpose: -//======================================================================= -void BOPTools_PaveFiller::PartialPerform - (const TColStd_SetOfInteger& anObjSubSet, - const TColStd_SetOfInteger& aToolSubSet) -{ - try { - // - if (myContext.IsNull()) { - myContext=new IntTools_Context; - } - // - // - // 0. Prepare the IteratorOfCoupleOfShape - myDSIt.SetDataStructure(myDS); - //Fill TableOfIntersectionStatus - Standard_Integer i, j; - Standard_Integer iObjF, iObjL, iToolF, iToolL; - myDS->ObjectRange(iObjF, iObjL); - myDS->ToolRange(iToolF, iToolL); - for(i = iObjF; i <= iObjL; ++i) { - for(j = iToolF; j <= iToolL; ++j) { - if(!anObjSubSet.Contains(i) || !aToolSubSet.Contains(j)) { - myDSIt.SetIntersectionStatus(i, j, BOPTools_NONINTERSECTED); - } - } - } - // - // 1.VV - PerformVV(); - PerformNewVertices(); - // - // 2.VE - myPavePool.Resize (myNbEdges); - PrepareEdges(); - PerformVE(); - // - // 3.VF - PerformVF(); - // - // 4.EE - myCommonBlockPool.Resize (myNbEdges); - mySplitShapesPool.Resize (myNbEdges); - myPavePoolNew .Resize (myNbEdges); - - PreparePaveBlocks(TopAbs_VERTEX, TopAbs_EDGE); - PreparePaveBlocks(TopAbs_EDGE, TopAbs_EDGE); - - PerformEE(); - - RefinePavePool (); - myPavePoolNew.Destroy(); - myPavePoolNew .Resize (myNbEdges); - // - // 5.EF - PreparePaveBlocks(TopAbs_EDGE, TopAbs_FACE); - - PerformEF(); - RefinePavePool(); - // - myPavePoolNew.Destroy(); - - // MakeSplitEdges (); - // DoSDEdges(); - // - // 6. FF - PerformFF (); - - // - } // end of try block - - catch (BOPTColStd_Failure& x) { - cout << x.Message() << endl << flush; - } - -} - -//======================================================================= -// function: ToCompletePerform -// purpose: -//======================================================================= -void BOPTools_PaveFiller::ToCompletePerform() -{ - try { - // - if (myContext.IsNull()) { - myContext=new IntTools_Context; - } - // - PutPavesOnCurves(); - - MakeSplitEdges (); - DoSDEdges(); - - MakeBlocks(); - - MakeSectionEdges(); - // - MakeAloneVertices(); - } // end of try block - - catch (BOPTColStd_Failure& x) { - cout << x.Message() << endl << flush; - } -} - -//======================================================================= -// function: PerformVE -// purpose: -//======================================================================= -void BOPTools_PaveFiller::PerformVE() -{ - myIsDone=Standard_False; - - Standard_Integer n1, n2, anIndexIn, aFlag, aWhat, aWith, aNbVEs, aBlockLength; - Standard_Real aT; - // - BOPTools_CArray1OfVEInterference& aVEs=myIntrPool->VEInterferences(); - // - // V/E Interferences [BooleanOperations_VertexEdge] - myDSIt.Initialize (TopAbs_VERTEX, TopAbs_EDGE); - // - // - // BlockLength correction - aNbVEs=ExpectedPoolLength(); - aBlockLength=aVEs.BlockLength(); - if (aNbVEs > aBlockLength) { - aVEs.SetBlockLength(aNbVEs); - } - // - for (; myDSIt.More(); myDSIt.Next()) { - Standard_Boolean justaddinterference = Standard_False; - myDSIt.Current(n1, n2, justaddinterference); - - if(justaddinterference) { - if (!myIntrPool->IsComputed(n1, n2) && !IsSuccesstorsComputed(n1, n2)) { - anIndexIn = 0; - aWhat = n1; // Vertex - aWith = n2; // Edge - SortTypes(aWhat, aWith); - myIntrPool->AddInterference(aWhat, aWith, BooleanOperations_VertexEdge, anIndexIn); - } - continue; - } - // - if (! myIntrPool->IsComputed(n1, n2)) { - if (! IsSuccesstorsComputed(n1, n2)) { - anIndexIn=0; - aWhat=n1; // Vertex - aWith=n2; // Edge - SortTypes(aWhat, aWith); - - const TopoDS_Shape& aS1=myDS->GetShape(aWhat); - const TopoDS_Shape& aS2=myDS->GetShape(aWith); - - const TopoDS_Vertex& aV1=TopoDS::Vertex(aS1); - const TopoDS_Edge& aE2=TopoDS::Edge (aS2); - - if (BRep_Tool::Degenerated(aE2)){ - continue; - } - // - aFlag=myContext->ComputeVE (aV1, aE2, aT); - // - if (!aFlag) { - // - // Add Interference to the Pool - BOPTools_VEInterference anInterf (aWhat, aWith, aT); - anIndexIn=aVEs.Append(anInterf); - // - // Add Pave to the Edge's myPavePool - BOPTools_Pave aPave(aWhat, aT, BooleanOperations_VertexEdge); - aPave.SetInterference(anIndexIn); - BOPTools_PaveSet& aPaveSet= myPavePool(myDS->RefEdge(aWith)); - aPaveSet.Append(aPave); - - // - // State for the Vertex in DS; - myDS->SetState (aWhat, BooleanOperations_ON); - // Insert Vertex in Interference Object - BOPTools_VEInterference& aVE=aVEs(anIndexIn); - aVE.SetNewShape(aWhat); - } - myIntrPool->AddInterference(aWhat, aWith, BooleanOperations_VertexEdge, anIndexIn); - //myIntrPool->ComputeResult(n1, n2); - } - } - } - myIsDone=Standard_True; -} -//======================================================================= -// function: PerformVF -// purpose: -//======================================================================= -void BOPTools_PaveFiller::PerformVF() -{ - myIsDone=Standard_False; - - Standard_Integer n1, n2, anIndexIn, aFlag, aWhat, aWith, aNbVSs, aBlockLength; - Standard_Real aU, aV; - // - BOPTools_CArray1OfVSInterference& aVSs=myIntrPool->VSInterferences(); - // - // V/E Interferences [BooleanOperations_VertexEdge] - myDSIt.Initialize(TopAbs_VERTEX, TopAbs_FACE); - // - // BlockLength correction - aNbVSs=ExpectedPoolLength(); - aBlockLength=aVSs.BlockLength(); - if (aNbVSs > aBlockLength) { - aVSs.SetBlockLength(aNbVSs); - } - // - for (; myDSIt.More(); myDSIt.Next()) { - Standard_Boolean justaddinterference = Standard_False; - myDSIt.Current(n1, n2, justaddinterference); - - if(justaddinterference) { - if (!myIntrPool->IsComputed(n1, n2) && !IsSuccesstorsComputed(n1, n2)) { - anIndexIn = 0; - aWhat = n1; // Vertex - aWith = n2; // Face - SortTypes(aWhat, aWith); - myIntrPool->AddInterference(aWhat, aWith, BooleanOperations_VertexSurface, anIndexIn); - } - continue; - } - // - if (! myIntrPool->IsComputed(n1, n2)) { - if (! IsSuccesstorsComputed(n1, n2)) { - anIndexIn=0; - aWhat=n1; // Vertex - aWith=n2; // Face - SortTypes(aWhat, aWith); - - const TopoDS_Shape& aS1=myDS->GetShape(aWhat); - const TopoDS_Shape& aS2=myDS->GetShape(aWith); - - const TopoDS_Vertex& aV1=TopoDS::Vertex(aS1); - const TopoDS_Face& aF2=TopoDS::Face (aS2); - // - aFlag=myContext->ComputeVS (aV1, aF2, aU, aV); - // - if (!aFlag) { - // - // Add Interference to the Pool - BOPTools_VSInterference anInterf (aWhat, aWith, aU, aV); - anIndexIn=aVSs.Append(anInterf); - // - // SetState for Vertex in DS; - myDS->SetState (aWhat, BooleanOperations_ON); - // Insert Vertex in Interference Object - BOPTools_VSInterference& aVS=aVSs(anIndexIn); - aVS.SetNewShape(aWhat); - } - myIntrPool->AddInterference(aWhat, aWith, BooleanOperations_VertexSurface, anIndexIn); - //myIntrPool->ComputeResult(n1, n2); - } - } - } - myIsDone=Standard_True; -} - -//======================================================================= -// function: PerformEE -// purpose: -//======================================================================= -void BOPTools_PaveFiller::PerformEE() -{ - myIsDone=Standard_False; - - Standard_Integer n1, n2, anIndexIn=0, nE1, nE2, aNbVEs, aBlockLength; - Standard_Integer aTmp, aWhat, aWith; - // - BOPTools_CArray1OfEEInterference& aEEs=myIntrPool->EEInterferences(); - // - // E/E Interferences [BooleanOperations_EdgeEdge] - myDSIt.Initialize(TopAbs_EDGE, TopAbs_EDGE); - // - // - // BlockLength correction - aNbVEs=ExpectedPoolLength(); - aBlockLength=aEEs.BlockLength(); - if (aNbVEs > aBlockLength) { - aEEs.SetBlockLength(aNbVEs); - } - // - for (; myDSIt.More(); myDSIt.Next()) { - Standard_Boolean justaddinterference = Standard_False; - myDSIt.Current(n1, n2, justaddinterference); - - if(justaddinterference) { - if (!myIntrPool->IsComputed(n1, n2)) { - anIndexIn = 0; - nE1 = n1; - nE2 = n2; - SortTypes(nE1, nE2); - myIntrPool->AddInterference (nE1, nE2, BooleanOperations_EdgeEdge, anIndexIn); - } - continue; - } - // - if (myIntrPool->IsComputed(n1, n2)) { - continue; - } - // - nE1=n1; - nE2=n2; - SortTypes(nE1, nE2); - // - Standard_Real aTolE1, aTolE2, aDeflection=0.01; - Standard_Integer aDiscretize=30; - TopoDS_Edge aE1, aE2; - // - aE1=TopoDS::Edge(myDS->GetShape(nE1)); - aE2=TopoDS::Edge(myDS->GetShape(nE2)); - // - if (BRep_Tool::Degenerated(aE1)){ - continue; - } - if (BRep_Tool::Degenerated(aE2)){ - continue; - } - // - aTolE1=BRep_Tool::Tolerance(aE1); - aTolE2=BRep_Tool::Tolerance(aE2); - // - BOPTools_ListOfPaveBlock& aLPB1=mySplitShapesPool(myDS->RefEdge(nE1)); - BOPTools_ListIteratorOfListOfPaveBlock anIt1(aLPB1); - - for (; anIt1.More(); anIt1.Next()) { - BOPTools_PaveBlock& aPB1=anIt1.Value(); - const IntTools_ShrunkRange& aShrunkRange1=aPB1.ShrunkRange(); - - const IntTools_Range& aSR1=aShrunkRange1.ShrunkRange(); - const Bnd_Box& aBB1=aShrunkRange1.BndBox(); - - BOPTools_ListOfPaveBlock& aLPB2=mySplitShapesPool(myDS->RefEdge(nE2)); - BOPTools_ListIteratorOfListOfPaveBlock anIt2(aLPB2); - - for (; anIt2.More(); anIt2.Next()) { - BOPTools_PaveBlock& aPB2=anIt2.Value(); - const IntTools_ShrunkRange& aShrunkRange2=aPB2.ShrunkRange(); - - const IntTools_Range& aSR2=aShrunkRange2.ShrunkRange(); - const Bnd_Box& aBB2=aShrunkRange2.BndBox(); - - ////////////////////////////////////////////// - if (aBB1.IsOut (aBB2)) { - continue; - } - // - // EE - IntTools_EdgeEdge aEE; - aEE.SetEdge1 (aE1); - aEE.SetEdge2 (aE2); - aEE.SetTolerance1 (aTolE1); - aEE.SetTolerance2 (aTolE2); - aEE.SetDiscretize (aDiscretize); - aEE.SetDeflection (aDeflection); - // - IntTools_Range anewSR1 = aSR1; - IntTools_Range anewSR2 = aSR2; - // - aEE.SetRange1(anewSR1); - aEE.SetRange2(anewSR2); - - aEE.Perform(); - // - anIndexIn=0; - // - if (aEE.IsDone()) { - // - // reverse order if it is necessary - TopoDS_Edge aEWhat, aEWith; - aEWhat=aE1; - aEWith=aE2; - aWhat=nE1; - aWith=nE2; - if (aEE.Order()) { - aTmp=aWhat; - aWhat=aWith; - aWith=aTmp; - aEWhat=aE2; - aEWith=aE1; - } - // - const IntTools_SequenceOfCommonPrts& aCPrts=aEE.CommonParts(); - Standard_Integer i, aNbCPrts; - aNbCPrts=aCPrts.Length(); - // - if(aNbCPrts != 0) { - char buf[512]; - - if(!aShrunkRange1.IsDone()) { - sprintf (buf, "Can not obtain ShrunkRange for Edge %d", nE1); - throw BOPTColStd_Failure(buf) ; - } - - if(!aShrunkRange2.IsDone()) { - sprintf (buf, "Can not obtain ShrunkRange for Edge %d", nE2); - throw BOPTColStd_Failure(buf) ; - } - } - // - for (i=1; i<=aNbCPrts; i++) { - const IntTools_CommonPrt& aCPart=aCPrts(i); - // - anIndexIn=0; - // - TopAbs_ShapeEnum aType=aCPart.Type(); - switch (aType) { - - case TopAbs_VERTEX: { - - Standard_Real aT1, aT2; - Standard_Integer aNewShape; - - const IntTools_Range& aR1=aCPart.Range1(); - aT1=0.5*(aR1.First()+aR1.Last()); - - if((aCPart.VertexParameter1() >= aR1.First()) && - (aCPart.VertexParameter1() <= aR1.Last())) { - aT1 = aCPart.VertexParameter1(); - } - - const IntTools_SequenceOfRanges& aRanges2=aCPart.Ranges2(); - const IntTools_Range& aR2=aRanges2(1); - aT2=0.5*(aR2.First()+aR2.Last()); - - if((aCPart.VertexParameter2() >= aR2.First()) && - (aCPart.VertexParameter2() <= aR2.Last())) { - aT2 = aCPart.VertexParameter2(); - } - - TopoDS_Vertex aNewVertex; - BOPTools_Tools::MakeNewVertex(aEWhat, aT1, aEWith, aT2, aNewVertex); - // - //decide to add pave or not - Standard_Real aTolerance = Precision::PConfusion(); - IntTools_Range aRange = (aEE.Order()) ? anewSR2 : anewSR1; - Standard_Boolean firstisonpave1 = (Abs(aRange.First() - aT1) < aTolerance); - if(!firstisonpave1) firstisonpave1 = (Abs(aRange.First() - aR1.First()) < aTolerance); - - Standard_Boolean firstisonpave2 = (Abs(aRange.Last() - aT1) < aTolerance); - if(!firstisonpave2) firstisonpave2 = (Abs(aRange.Last() - aR1.Last()) < aTolerance); - - aRange = (aEE.Order()) ? anewSR1 : anewSR2; - Standard_Boolean secondisonpave1 = (Abs(aRange.First() - aT2) < aTolerance); - if(!secondisonpave1) secondisonpave1 = (Abs(aRange.First() - aR2.First()) < aTolerance); - - Standard_Boolean secondisonpave2 = (Abs(aRange.Last() - aT2) < aTolerance); - if(!secondisonpave2) secondisonpave2 = (Abs(aRange.Last() - aR2.Last()) < aTolerance); - - if(firstisonpave1 || - firstisonpave2 || - secondisonpave1 || - secondisonpave2) { - // - myIntrPool->AddInterference (aWhat, aWith, BooleanOperations_EdgeEdge, anIndexIn); - continue; - } - // - else { - Standard_Integer eit = 0; - Standard_Boolean bisoldvertex = Standard_False; - BOPTools_PaveBlock* aPPB1 = (aEE.Order()) ? (BOPTools_PaveBlock*)&aPB2 : (BOPTools_PaveBlock*)&aPB1; - BOPTools_PaveBlock* aPPB2 = (aEE.Order()) ? (BOPTools_PaveBlock*)&aPB1 : (BOPTools_PaveBlock*)&aPB2; - - for(eit = 0; eit < 2; eit++) { - if(aEE.Order()) - aRange = (eit == 0) ? anewSR2 : anewSR1; - else - aRange = (eit == 0) ? anewSR1 : anewSR2; - const TopoDS_Edge& aE = (eit == 0) ? aEWhat : aEWith; - - BOPTools_PaveBlock* aPB = (eit == 0) ? aPPB1 : aPPB2; - TopoDS_Vertex aV1; - TopoDS_Vertex aV2; - Standard_Boolean bisfirst = Standard_False; - Standard_Real aT = (eit == 0) ? aT1 : aT2; - Standard_Real adist1 = fabs(aRange.First() - aT); - Standard_Real adist2 = fabs(aRange.Last() - aT); - bisfirst = (adist1 < adist2); - IntTools_Range aRangeCur; - - if(bisfirst) { - aV2 = aNewVertex; - aV1 = TopoDS::Vertex(myDS->Shape(aPB->Pave1().Index())); - aRangeCur = IntTools_Range(aPB->Pave1().Param(), aT); - } - else { - aV1 = aNewVertex; - aV2 = TopoDS::Vertex(myDS->Shape(aPB->Pave2().Index())); - aRangeCur = IntTools_Range(aT, aPB->Pave2().Param()); - } - Standard_Real aroughtoler = BRep_Tool::Tolerance(aV1) + BRep_Tool::Tolerance(aV2); - aroughtoler *=10.; - - if((adist1 > aroughtoler) && (adist2 > aroughtoler)) - continue; - IntTools_ShrunkRange aSR (aE, aV1, aV2, aRangeCur, myContext); - - if (!aSR.IsDone()) { - bisoldvertex = Standard_True; - break; - } - } - - if(bisoldvertex) { - myIntrPool->AddInterference (aWhat, aWith, BooleanOperations_EdgeEdge, anIndexIn); - continue; - } - } - // - // Add Interference to the Pool - BOPTools_EEInterference anInterf (aWhat, aWith, aCPart); - anIndexIn=aEEs.Append(anInterf); - myIntrPool->AddInterference (aWhat, aWith, BooleanOperations_EdgeEdge, anIndexIn); - // - // Insert New Vertex in DS; - // aNewShape is # of DS-line, where aNewVertex is kept - BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq; - myDS->InsertShapeAndAncestorsSuccessors(aNewVertex, anASSeq); - aNewShape=myDS->NumberOfInsertedShapes(); - // State of the new Vertex is ON - myDS->SetState (aNewShape, BooleanOperations_ON); - // - // Insert New Vertex in EE Interference - BOPTools_EEInterference& aEEInterf= aEEs(anIndexIn); - aEEInterf.SetNewShape(aNewShape); - // - // Add Paves to the myPavePoolNew - BOPTools_Pave aPave; - aPave.SetInterference(anIndexIn); - aPave.SetType (BooleanOperations_EdgeEdge); - aPave.SetIndex(aNewShape); - - aPave.SetParam(aT1); - BOPTools_PaveSet& aPaveSet1=myPavePoolNew(myDS->RefEdge(aWhat)); - aPaveSet1.Append(aPave); - - aPave.SetParam(aT2); - BOPTools_PaveSet& aPaveSet2=myPavePoolNew(myDS->RefEdge(aWith)); - aPaveSet2.Append(aPave); - } - break; - - case TopAbs_EDGE: { - - const IntTools_SequenceOfRanges& aRanges2=aCPart.Ranges2(); - Standard_Integer aNbComPrt2=aRanges2.Length(); - - if (aNbComPrt2>1) { - // - myIntrPool->AddInterference (aWhat, aWith, BooleanOperations_EdgeEdge, anIndexIn); - break; - } - - Standard_Boolean aCoinsideFlag; - // - aCoinsideFlag=IsBlocksCoinside(aPB1, aPB2); - // - if (!aCoinsideFlag) { - // - myIntrPool->AddInterference (aWhat, aWith, BooleanOperations_EdgeEdge, anIndexIn); - break; - } - // - // Add Interference to the Pool - BOPTools_EEInterference anInterf (aWhat, aWith, aCPart); - anIndexIn=aEEs.Append(anInterf); - myIntrPool->AddInterference (aWhat, aWith, BooleanOperations_EdgeEdge, anIndexIn); - // - BOPTools_CommonBlock aCB; - if (aTolE1>=aTolE2) { - aCB.SetPaveBlock1(aPB1); - aCB.SetPaveBlock2(aPB2); - } - else { - aCB.SetPaveBlock1(aPB2); - aCB.SetPaveBlock2(aPB1); - } - BOPTools_ListOfCommonBlock& aLCB1=myCommonBlockPool(myDS->RefEdge(aWhat)); - aLCB1.Append(aCB); - BOPTools_ListOfCommonBlock& aLCB2=myCommonBlockPool(myDS->RefEdge(aWith)); - aLCB2.Append(aCB); - } - break; - - default: - break; - } // switch (aType) - } // for (i=1; i<=aNbCPrts; i++) - }// if (aEE.IsDone()) - - ////////////////////////////////////////////// - } // for (; anIt2.More(); anIt2.Next()) - } // for (; anIt1.More(); anIt1.Next()) - }// for (; myDSIt.More(); myDSIt.Next()) - myIsDone=Standard_True; -} - -//======================================================================= -// function: MakeSplitEdges -// purpose: -//======================================================================= -void BOPTools_PaveFiller::MakeSplitEdges() -{ - myIsDone=Standard_False; - - Standard_Integer i, nV1, nV2, aNbPaveBlocks, aNewShapeIndex;; - Standard_Real t1, t2; - TopoDS_Edge aE, aESplit; - TopoDS_Vertex aV1, aV2; - - for (i=1; i<=myNbSources; i++) { - - if (myDS->GetShapeType(i) != TopAbs_EDGE) - continue; - // - // Original Edge - aE=TopoDS::Edge(myDS->GetShape(i)); - // - TopoDS_Edge anEdgeOriginal=aE; - TopAbs_Orientation anOrientationOriginal=anEdgeOriginal.Orientation(); - // - if (BRep_Tool::Degenerated(aE)){ - continue; - } - // - aE.Orientation(TopAbs_FORWARD); - // - // Making Split Edges - // - // Split Set for the Original Edge i - BOPTools_ListOfPaveBlock& aSplitEdges=mySplitShapesPool(myDS->RefEdge(i)); - BOPTools_ListIteratorOfListOfPaveBlock aPBIt(aSplitEdges); - - aNbPaveBlocks=aSplitEdges.Extent(); - - if (aNbPaveBlocks==1) { - Standard_Boolean IsNewVertex1, IsNewVertex2; - // the split is equal to the original Edge - if (aPBIt.More()) { - BOPTools_PaveBlock& aPB1=aPBIt.Value(); - - // 1 - const BOPTools_Pave& aPave1=aPB1.Pave1(); - nV1=aPave1.Index(); - t1=aPave1.Param(); - aV1=TopoDS::Vertex(myDS->GetShape(nV1)); - aV1.Orientation(TopAbs_FORWARD); - // 2 - const BOPTools_Pave& aPave2=aPB1.Pave2(); - nV2=aPave2.Index(); - t2=aPave2.Param(); - aV2=TopoDS::Vertex(myDS->GetShape(nV2)); - aV2.Orientation(TopAbs_REVERSED); - // 3 - IsNewVertex1=myDS->IsNewShape (nV1); - IsNewVertex2=myDS->IsNewShape (nV2); - - if (IsNewVertex1 || IsNewVertex2) { - - BOPTools_Tools::MakeSplitEdge(aE, aV1, t1, aV2, t2, aESplit); - BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq; - - anASSeq.SetNewSuccessor(nV1); - anASSeq.SetNewOrientation(aV1.Orientation()); - - anASSeq.SetNewSuccessor(nV2); - anASSeq.SetNewOrientation(aV2.Orientation()); - // - if (anOrientationOriginal==TopAbs_INTERNAL) { - anASSeq.SetNewAncestor(i); - aESplit.Orientation(anOrientationOriginal); - } - // - myDS->InsertShapeAndAncestorsSuccessors(aESplit, anASSeq); - aNewShapeIndex=myDS->NumberOfInsertedShapes(); - myDS->SetState(aNewShapeIndex, BooleanOperations_UNKNOWN); - // - // Fill Split Set for the Original Edge - aPB1.SetEdge(aNewShapeIndex); - } - - else { - aPB1.SetEdge(i); - } - // - continue; - } - } // if (aNbPaveBlocks==1) - - for (; aPBIt.More(); aPBIt.Next()) { - BOPTools_PaveBlock& aPB=aPBIt.Value(); - - const BOPTools_Pave& aPave1=aPB.Pave1(); - nV1=aPave1.Index(); - t1=aPave1.Param(); - aV1=TopoDS::Vertex(myDS->GetShape(nV1)); - aV1.Orientation(TopAbs_FORWARD); - - const BOPTools_Pave& aPave2=aPB.Pave2(); - nV2=aPave2.Index(); - t2=aPave2.Param(); - aV2=TopoDS::Vertex(myDS->GetShape(nV2)); - aV2.Orientation(TopAbs_REVERSED); - - BOPTools_Tools::MakeSplitEdge(aE, aV1, t1, aV2, t2, aESplit); - // - // Add Split Part of the Original Edge to the DS - BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq; - - anASSeq.SetNewSuccessor(nV1); - anASSeq.SetNewOrientation(aV1.Orientation()); - - anASSeq.SetNewSuccessor(nV2); - anASSeq.SetNewOrientation(aV2.Orientation()); - // - if (anOrientationOriginal==TopAbs_INTERNAL) { - anASSeq.SetNewAncestor(i); - aESplit.Orientation(anOrientationOriginal); - } - // - myDS->InsertShapeAndAncestorsSuccessors(aESplit, anASSeq); - aNewShapeIndex=myDS->NumberOfInsertedShapes(); - myDS->SetState(aNewShapeIndex, BooleanOperations_UNKNOWN); - // - // Fill Split Set for the Original Edge - aPB.SetEdge(aNewShapeIndex); - // - } - - } //for (i=1; i<=myNbSources; i++) { - myIsDone=Standard_True; -} -//======================================================================= -// function: PreparePaveBlocks -// purpose: -//======================================================================= -void BOPTools_PaveFiller::PreparePaveBlocks(const TopAbs_ShapeEnum aType1, - const TopAbs_ShapeEnum aType2) -{ - myIsDone=Standard_False; - - Standard_Boolean Ok1, Ok2, Ok3; - Ok1= (aType1==TopAbs_VERTEX) && (aType2==TopAbs_EDGE) ; - Ok2= (aType1==TopAbs_EDGE) && (aType2==TopAbs_EDGE) ; - Ok3= (aType1==TopAbs_EDGE) && (aType2==TopAbs_FACE) ; - if (!Ok1 && !Ok2 && !Ok3) { - // error: Type mismatch - return; - } - - Standard_Integer n1, n2, nE1, nE2, aNbSplits; - TColStd_MapOfInteger aMap; - - myDSIt.Initialize(aType1, aType2); - - for (; myDSIt.More(); myDSIt.Next()) { - Standard_Boolean aFlag = Standard_False; - myDSIt.Current(n1, n2, aFlag); - nE1=n1; - nE2=n2; - SortTypes(nE1, nE2); - - if (aType1==TopAbs_EDGE) { - BOPTools_ListOfPaveBlock& aLPB1=mySplitShapesPool(myDS->RefEdge(nE1)); - aNbSplits=aLPB1.Extent(); - if (!aNbSplits) { - if (!aMap.Contains(nE1)) { - aMap.Add(nE1); - PreparePaveBlocks(nE1); - - if (!myIsDone) { - return; - } - } - } - } - - if (aType2==TopAbs_EDGE) { - BOPTools_ListOfPaveBlock& aLPB2=mySplitShapesPool(myDS->RefEdge(nE2)); - aNbSplits=aLPB2.Extent(); - if (!aNbSplits) { - if (!aMap.Contains(nE2)) { - aMap.Add(nE2); - PreparePaveBlocks(nE2); - - if (!myIsDone) { - return; - } - } - } - }// if (aType2==TopAbs_EDGE) - }// for (; myDSIt.More(); myDSIt.Next()) - - myIsDone=Standard_True; -} - -//======================================================================= -// function: PreparePaveBlocks -// purpose: -//======================================================================= -void BOPTools_PaveFiller::PreparePaveBlocks(const Standard_Integer nE) -{ - myIsDone=Standard_False; - - Standard_Integer nV1, nV2; - - TopoDS_Edge aE; - TopoDS_Vertex aV1, aV2; - - // SplitShapesPool - BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(nE)); - aLPB.Clear(); - // Edge - aE=TopoDS::Edge(myDS->GetShape(nE)); - // - if (!BRep_Tool::Degenerated(aE)){ - // - BOPTools_PaveSet& aPS=myPavePool(myDS->RefEdge(nE)); - - BOPTools_PaveBlockIterator aPBIt(nE, aPS); - for (; aPBIt.More(); aPBIt.Next()) { - BOPTools_PaveBlock& aPB=aPBIt.Value(); - - const IntTools_Range& aRange=aPB.Range(); - - const BOPTools_Pave& aPave1=aPB.Pave1(); - nV1=aPave1.Index(); - aV1=TopoDS::Vertex(myDS->GetShape(nV1)); - - const BOPTools_Pave& aPave2=aPB.Pave2(); - nV2=aPave2.Index(); - aV2=TopoDS::Vertex(myDS->GetShape(nV2)); - // - // ShrunkRange - IntTools_ShrunkRange aSR (aE, aV1, aV2, aRange, myContext); - // - Standard_Integer anErrorStatus; - anErrorStatus=aSR.ErrorStatus(); - - char buf[512]; - if (!aSR.IsDone()) { - Standard_Boolean bThrow = Standard_True; - Standard_Integer iRank = myDS->Rank(nE); - TopoDS_Shape aRef = (iRank == 1) ? myDS->Tool() : myDS->Object(); - Standard_Integer aRefIndex = (iRank == 1) ? myDS->ShapeIndex(aRef, 2) : myDS->ShapeIndex(aRef, 1); - - Standard_Boolean bCheckDistance = Standard_True; - - if(myDS->IsNewShape(nV1) || myDS->IsNewShape(nV2)) { - bCheckDistance = Standard_False; - } - else { - const BOPTools_CArray1OfInterferenceLine& aTable = myIntrPool->InterferenceTable(); - Standard_Integer tmpIt = 0; - - for(tmpIt = 0; tmpIt < 3; tmpIt++) { - Standard_Integer acurindex = (tmpIt == 0) ? nE : ((tmpIt == 1) ? nV1 : nV2); - const BOPTools_InterferenceLine& anInterfLine = aTable(acurindex); - - if(!anInterfLine.RealList().IsEmpty()) - bCheckDistance = Standard_False; - } - } - - if(bCheckDistance) { - BRepExtrema_DistShapeShape aDist; - Standard_Integer bRefLoaded = Standard_False; - - Standard_Boolean bVertexIsOnShape = Standard_False; - Standard_Integer ii = 0, jj = 0; - - for(jj = 0; !bVertexIsOnShape && (jj < 2); jj++) { - Standard_Integer currentNV = (jj == 0) ? nV1 : nV2; - - Standard_Integer aVertexRank = myDS->Rank(currentNV); - - if(aVertexRank != iRank) { - bVertexIsOnShape = Standard_True; - break; - } - BOPTools_IntersectionStatus aStatus = BOPTools_UNKNOWN; - - if(aVertexRank == 1) - aStatus = myDSIt.GetTableOfIntersectionStatus()->Value(currentNV, aRefIndex); - else - aStatus = myDSIt.GetTableOfIntersectionStatus()->Value(aRefIndex, currentNV); - - if(aStatus == BOPTools_NONINTERSECTED) { - continue; - } - - if(jj == 0) { - aDist.LoadS1(aV1); - - if(!bRefLoaded) - aDist.LoadS2(aRef); - bRefLoaded = Standard_True; - } - else { - aDist.LoadS1(aV2); - - if(!bRefLoaded) - aDist.LoadS2(aRef); - bRefLoaded = Standard_True; - } - aDist.Perform(); - - if(aDist.IsDone()) { - - for(ii = 1; ii <= aDist.NbSolution(); ii++) { - Standard_Real aTolerance = (jj == 0) ? BRep_Tool::Tolerance(aV1) : BRep_Tool::Tolerance(aV2); - TopoDS_Shape aSupportShape = aDist.SupportOnShape2(ii); - - switch(aSupportShape.ShapeType()) { - case TopAbs_VERTEX: { - aTolerance += BRep_Tool::Tolerance(TopoDS::Vertex(aSupportShape)); - break; - } - case TopAbs_EDGE: { - aTolerance += BRep_Tool::Tolerance(TopoDS::Edge(aSupportShape)); - break; - } - case TopAbs_FACE: { - aTolerance += BRep_Tool::Tolerance(TopoDS::Face(aSupportShape)); - break; - } - default: - break; - } - - if(aDist.Value() < aTolerance) { - bVertexIsOnShape = Standard_True; - break; - } - } - } - } - - if(!bVertexIsOnShape) { - aSR.SetShrunkRange(aRange); - bThrow = Standard_False; - } - } - - if(bThrow) { - - sprintf (buf, "Can not obtain ShrunkRange for Edge %d\n", nE); - BOPTColStd_Dump::PrintMessage(buf); - sprintf (buf, "Can not obtain ShrunkRange for Edge %d", nE); - throw - BOPTColStd_Failure(buf) ; - } - } - // - if (anErrorStatus==6) { - sprintf(buf, - "Warning: [PreparePaveBlocks()] Max.Dummy Shrunk Range for Edge %d\n", nE); - BOPTColStd_Dump::PrintMessage(buf); - } - else { - // Check left paves and correct ShrunkRange if it is necessary - CorrectShrunkRanges (0, aPave1, aSR); - CorrectShrunkRanges (1, aPave2, aSR); - } - // - aPB.SetShrunkRange(aSR); - aLPB.Append(aPB); - } //for (; aPBIt1.More(); aPBIt1.Next()) - } - myIsDone=Standard_True; -} - -//======================================================================= -// function: CorrectShrunkRanges -// purpose: -//======================================================================= -void BOPTools_PaveFiller::CorrectShrunkRanges(const Standard_Integer aSide, - const BOPTools_Pave& aPave, - IntTools_ShrunkRange& aShrunkRange) -{ - BooleanOperations_KindOfInterference aType; - - aType=aPave.Type(); - if (aType!=BooleanOperations_EdgeEdge) { - return; - } - - Standard_Integer anIndexInterf ; - anIndexInterf=aPave.Interference(); - BOPTools_CArray1OfEEInterference& aEEs=myIntrPool->EEInterferences(); - const BOPTools_EEInterference& aEE=aEEs(anIndexInterf); - const IntTools_CommonPrt& aCP=aEE.CommonPrt(); - const TopoDS_Edge& aE1=aCP.Edge1(); - const TopoDS_Edge& aE2=aCP.Edge2(); - - const IntTools_Range& aSR=aShrunkRange.ShrunkRange(); - const TopoDS_Edge& aE=aShrunkRange.Edge(); - - IntTools_Range aNewRange; - IntTools_Range aCPRange; - - if (aE1.IsSame(aE)) { - const IntTools_Range& aR1=aCP.Range1(); - aCPRange=aR1; - } - if (aE2.IsSame(aE)) { - const IntTools_SequenceOfRanges& aSeqR=aCP.Ranges2(); - const IntTools_Range& aR2=aSeqR(1); - aCPRange=aR2; - } - - - Standard_Real aCoeff=1.05, tV, tNV, t2, t1; - tV=aPave.Param(); - if (aSide==0) { // Left - if (aCPRange.Last() > aSR.First()) { - tNV=aCPRange.Last(); - tNV=tV+aCoeff*(tNV-tV); - aNewRange.SetFirst(tNV); - t2=aSR.Last(); - aNewRange.SetLast (t2); - if(tNV < t2) { - //if(aNewRange.First() > aNewRange.Last()) { - aShrunkRange.SetShrunkRange(aNewRange); - } - } - } - else { // Right - if (aCPRange.First() < aSR.Last()) { - tNV=aCPRange.First(); - tNV=tV-aCoeff*(tV-tNV); - t1=aSR.First(); - aNewRange.SetFirst(t1); - aNewRange.SetLast (tNV); - if(tNV > t1) { - //if(aNewRange.First() < aNewRange.Last()) { - aShrunkRange.SetShrunkRange(aNewRange); - } - } - } -} - -//======================================================================= -// function: RefinePavePool -// purpose: -//======================================================================= -void BOPTools_PaveFiller::RefinePavePool() -{ - Standard_Integer i, aNbNew; - - for (i=1; i<=myNbSources; i++) { - - if ((myDS->GetShape(i)).ShapeType()==TopAbs_EDGE) { - BOPTools_PaveSet& aPS= myPavePool(myDS->RefEdge(i)); - //ZZ BOPTools_ListOfPave& aLP=aPS.ChangeSet(); - - BOPTools_PaveSet& aNewPS= myPavePoolNew(myDS->RefEdge(i)); - BOPTools_ListOfPave& aNewLP=aNewPS.ChangeSet(); - - aNbNew=aNewLP.Extent(); - if (aNbNew) { - BOPTools_ListIteratorOfListOfPave anIt(aNewLP); - for (; anIt.More(); anIt.Next()) { - const BOPTools_Pave& aPave=anIt.Value(); - aPS.Append(aPave); - } - // Clear the ListOfPaveBlock - BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(i)); - aLPB.Clear(); - // Prepare the paveBlocks for that egde again - PreparePaveBlocks(i); - } - aNewLP.Clear(); - } - } -} - -//======================================================================= -// function: PrepareEdges -// purpose: -//======================================================================= -void BOPTools_PaveFiller::PrepareEdges() -{ - Standard_Integer i, nV, ii, aNBSuc, ip; - Standard_Real aT; - TopAbs_Orientation anOr; - TopoDS_Edge aE; - TopoDS_Vertex aV; - - for (i=1; i<=myNbSources; i++) { - if (myDS->GetShapeType(i)==TopAbs_EDGE) { - aE=TopoDS::Edge(myDS->GetShape(i)); - // - if (BRep_Tool::Degenerated(aE)){ - continue; - } - // - BOPTools_PaveSet& aPaveSet= myPavePool(myDS->RefEdge(i)); - // - // cto900/M2 - // Some of Edges can be [Semi] Infinite. Such Edges have no - // vertices on correspondant INF ends. So we must provide - // these vertices formally (to obtain Shrunk Ranges for e.g). - // In reality this vertex(-es) does not belong to the INF Edge. - // It just has reference in the DS. - { - Standard_Real aT1, aT2, aTolE; - Standard_Boolean bInf1, bInf2; - gp_Pnt aPx; - TopoDS_Vertex aVx; - BRep_Builder aBB; - BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq; - // - aTolE=BRep_Tool::Tolerance(aE); - Handle(Geom_Curve) aC3D=BRep_Tool::Curve (aE, aT1, aT2); - bInf1=Precision::IsNegativeInfinite(aT1); - bInf2=Precision::IsPositiveInfinite(aT2); - - if (bInf1) { - aC3D->D0(aT1, aPx); - aBB.MakeVertex(aVx, aPx, aTolE); - myDS->InsertShapeAndAncestorsSuccessors(aVx, anASSeq); - nV=myDS->NumberOfInsertedShapes(); - BOPTools_Pave aPave(nV, aT1); - aPaveSet.Append (aPave); - } - - if (bInf2) { - aC3D->D0(aT2, aPx); - aBB.MakeVertex(aVx, aPx, aTolE); - myDS->InsertShapeAndAncestorsSuccessors(aVx, anASSeq); - nV=myDS->NumberOfInsertedShapes(); - BOPTools_Pave aPave(nV, aT2); - aPaveSet.Append (aPave); - } - } - // - aNBSuc=myDS->NumberOfSuccessors(i); - for (ii=1; ii <= aNBSuc; ii++) { - nV=myDS->GetSuccessor(i, ii); - anOr=myDS->GetOrientation(i, ii); - - aV=TopoDS::Vertex(myDS->GetShape(nV)); - aV.Orientation(anOr); - aT=BRep_Tool::Parameter(aV, aE); - // - ip=FindSDVertex(nV); - if (ip) { - aV=TopoDS::Vertex(myDS->GetShape(ip)); - aV.Orientation(anOr); - nV=ip; - } - // - BOPTools_Pave aPave(nV, aT); - aPaveSet.Append (aPave); - } - } - } -} -//======================================================================= -// function: PerformVV -// purpose: -//======================================================================= -void BOPTools_PaveFiller::PerformVV() -{ - myIsDone=Standard_False; - - Standard_Integer n1, n2,anIndexIn, aFlag, aWhat, aWith, aNbVVs, aBlockLength; - // - BOPTools_CArray1OfVVInterference& aVVs=myIntrPool->VVInterferences(); - // - // V/V BooleanOperations_VertexVertex - myDSIt.Initialize(TopAbs_VERTEX, TopAbs_VERTEX); - // - // - // BlockLength correction - aNbVVs=ExpectedPoolLength(); - aBlockLength=aVVs.BlockLength(); - if (aNbVVs > aBlockLength) { - aVVs.SetBlockLength(aNbVVs); - } - // - // - for (; myDSIt.More(); myDSIt.Next()) { - Standard_Boolean justaddinterference = Standard_False; - myDSIt.Current(n1, n2, justaddinterference); - - if(justaddinterference) { - if (! myIntrPool->IsComputed(n1, n2)) { - anIndexIn=0; - aWhat=n1; - aWith=n2; - SortTypes(aWhat, aWith); - myIntrPool->AddInterference(aWhat, aWith, BooleanOperations_VertexVertex, anIndexIn); - } - continue; - } - // - if (! myIntrPool->IsComputed(n1, n2)) { - anIndexIn=0; - aWhat=n1; - aWith=n2; - SortTypes(aWhat, aWith); - const TopoDS_Shape& aS1=myDS->GetShape(aWhat); - const TopoDS_Shape& aS2=myDS->GetShape(aWith); - - const TopoDS_Vertex& aV1=TopoDS::Vertex(aS1); - const TopoDS_Vertex& aV2=TopoDS::Vertex(aS2); - aFlag=IntTools_Tools::ComputeVV (aV1, aV2); - - if (!aFlag) { - BOPTools_VVInterference anInterf (aWhat, aWith); - anIndexIn=aVVs.Append(anInterf); - } - myIntrPool->AddInterference(aWhat, aWith, BooleanOperations_VertexVertex, anIndexIn); - //myIntrPool->ComputeResult(n1, n2); - } - } - - myIsDone=Standard_True; -} -//======================================================================= -// function: PerformNewVertices -// purpose: -//======================================================================= -void BOPTools_PaveFiller::PerformNewVertices() -{ - myIsDone=Standard_False; - - Standard_Integer i, aNb, anIndex1, anIndex2, aNewShape; - TopoDS_Vertex aV1, aV2, aNewVertex; - BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq; - // - // 1. VV Interferences - BOPTools_CArray1OfVVInterference& VVs=myIntrPool->VVInterferences(); - aNb=VVs.Extent(); - for (i=1; i<=aNb; i++) { - BOPTools_VVInterference& VV=VVs(i); - anIndex1=VV.Index1(); - anIndex2=VV.Index2(); - // - // Make New Vertex - aV1=TopoDS::Vertex(myDS->GetShape(anIndex1)); - aV2=TopoDS::Vertex(myDS->GetShape(anIndex2)); - BOPTools_Tools::MakeNewVertex(aV1, aV2, aNewVertex); - // - // Insert New Vertex in DS; - // aNewShape is # of DS-line, where aNewVertex is kept - myDS->InsertShapeAndAncestorsSuccessors(aNewVertex, anASSeq); - aNewShape=myDS->NumberOfInsertedShapes(); - // State of New Vertex is ON - myDS->SetState (aNewShape, BooleanOperations_ON); - // Insert New Vertex in Interference - VV.SetNewShape(aNewShape); - } - - myIsDone=Standard_True; -} -//======================================================================= -// function: FindSDVertex -// purpose: -//======================================================================= -Standard_Integer BOPTools_PaveFiller::FindSDVertex - (const Standard_Integer nV)const -{ - Standard_Integer i, aNb, anIndex1, anIndex2, aNewShape=0; - - BOPTools_CArray1OfVVInterference& VVs=myIntrPool->VVInterferences(); - aNb=VVs.Extent(); - - for (i=1; i<=aNb; i++) { - const BOPTools_VVInterference& VV=VVs(i); - anIndex1=VV.Index1(); - anIndex2=VV.Index2(); - if (nV==anIndex1 || nV==anIndex2) { - aNewShape=VV.NewShape(); - return aNewShape; - } - } - return aNewShape; -} - -//======================================================================= -// function:IsSuccesstorsComputed -// purpose: -//======================================================================= -Standard_Boolean BOPTools_PaveFiller::IsSuccesstorsComputed - (const Standard_Integer aN1, - const Standard_Integer aN2)const -{ - Standard_Integer nSuc, n1, n2; - - BooleanOperations_OnceExplorer aExp(*myDS); - TopAbs_ShapeEnum aType=myDS->GetShapeType(aN1); - - n1=aN1; - n2=aN2; - - if (aType!=TopAbs_VERTEX) { - Standard_Integer ntmp=n1; - n1=n2; - n2=ntmp; - } - - aType=myDS->GetShapeType(n2); - if (aType==TopAbs_EDGE) { - aExp.Init(n2, TopAbs_VERTEX); - for (; aExp.More(); aExp.Next()) { - nSuc=aExp.Current(); - if (myIntrPool->IsComputed(n1, nSuc)) { - return Standard_True; - } - } - return Standard_False; - } - - else if (aType==TopAbs_FACE) { - aExp.Init(n2, TopAbs_VERTEX); - for (; aExp.More(); aExp.Next()) { - nSuc=aExp.Current(); - if (myIntrPool->IsComputed(n1, nSuc)) { - return Standard_True; - } - } - - aExp.Init(n2, TopAbs_EDGE); - for (; aExp.More(); aExp.Next()) { - nSuc=aExp.Current(); - if (myIntrPool->IsComputed(n1, nSuc)) { - return Standard_True; - } - } - return Standard_False; - } - - return Standard_False; -} - -//======================================================================= -//function : SortTypes -//purpose : -//======================================================================= -void BOPTools_PaveFiller::SortTypes(Standard_Integer& theWhat, - Standard_Integer& theWith)const -{ - Standard_Boolean aReverseFlag=Standard_True; - - TopAbs_ShapeEnum aType1= myDS->GetShapeType(theWhat), - aType2= myDS->GetShapeType(theWith); - - if (aType1==aType2) - return; - - if (aType1==TopAbs_EDGE && aType2==TopAbs_FACE){ - aReverseFlag=Standard_False; - } - - if (aType1==TopAbs_VERTEX && - (aType2==TopAbs_FACE || aType2==TopAbs_EDGE)) { - aReverseFlag=Standard_False; - } - - Standard_Integer aWhat, aWith; - aWhat=(aReverseFlag) ? theWith : theWhat; - aWith=(aReverseFlag) ? theWhat : theWith; - - theWhat=aWhat; - theWith=aWith; -} - -//======================================================================= -// function:IsDone -// purpose: -//======================================================================= -Standard_Boolean BOPTools_PaveFiller::IsDone() const -{ - return myIsDone; -} - -//======================================================================= -// function: PavePool -// purpose: -//======================================================================= -const BOPTools_PavePool& BOPTools_PaveFiller::PavePool() const -{ - return myPavePool; -} -//======================================================================= -// function: ChangePavePool -// purpose: -//======================================================================= -BOPTools_PavePool& BOPTools_PaveFiller::ChangePavePool() -{ - return myPavePool; -} - -//======================================================================= -// function: CommonBlockPool -// purpose: -//======================================================================= -const BOPTools_CommonBlockPool& BOPTools_PaveFiller::CommonBlockPool() const -{ - return myCommonBlockPool; -} -//======================================================================= -// function: ChangeCommonBlockPool -// purpose: -//======================================================================= -BOPTools_CommonBlockPool& BOPTools_PaveFiller::ChangeCommonBlockPool() -{ - return myCommonBlockPool; -} -//======================================================================= -// function: SplitShapesPool -// purpose: -//======================================================================= -const BOPTools_SplitShapesPool& BOPTools_PaveFiller::SplitShapesPool() const -{ - return mySplitShapesPool; -} - -//======================================================================= -// function: ChangeSplitShapesPool -// purpose: -//======================================================================= -BOPTools_SplitShapesPool& BOPTools_PaveFiller::ChangeSplitShapesPool() -{ - return mySplitShapesPool; -} -//======================================================================= -// function: DS -// purpose: -//======================================================================= -BooleanOperations_PShapesDataStructure BOPTools_PaveFiller::DS() -{ - return myDS; -} -//======================================================================= -// function: InterfPool -// purpose: -//======================================================================= -BOPTools_PInterferencePool BOPTools_PaveFiller::InterfPool() -{ - return myIntrPool; -} - -// -//======================================================================= -// function: IteratorOfCoupleOfShape -// purpose: -//======================================================================= -const BOPTools_IteratorOfCoupleOfShape& - BOPTools_PaveFiller::IteratorOfCoupleOfShape() const -{ - return myDSIt; -} -// -//======================================================================= -// function: ExpectedPoolLength -// purpose: -//======================================================================= -Standard_Integer BOPTools_PaveFiller::ExpectedPoolLength()const -{ - Standard_Integer aNbIIs; - Standard_Real aCfPredict=.5; - - const BOPTools_ListOfCoupleOfInteger& aLC=myDSIt.ListOfCouple(); - aNbIIs=aLC.Extent(); - // - if (aNbIIs==1) { - return aNbIIs; - } - // - aNbIIs=(Standard_Integer) (aCfPredict*(Standard_Real)aNbIIs); - - return aNbIIs; -} -// -//======================================================================= -// function: IsBlocksCoinside -// purpose: -//======================================================================= -Standard_Boolean - BOPTools_PaveFiller::IsBlocksCoinside(const BOPTools_PaveBlock& aPB1, - const BOPTools_PaveBlock& aPB2) const -{ - Standard_Boolean bRetFlag=Standard_True; - Standard_Real aTolV11, aTolV12, aTolV21, aTolV22; - Standard_Real d1121, d1122, d1222, d1221, aTolSum, aCoeff=1.05; - gp_Pnt aP11, aP12, aP21, aP22; - - const TopoDS_Vertex& aV11=TopoDS::Vertex(myDS->Shape(aPB1.Pave1().Index())); - const TopoDS_Vertex& aV12=TopoDS::Vertex(myDS->Shape(aPB1.Pave2().Index())); - const TopoDS_Vertex& aV21=TopoDS::Vertex(myDS->Shape(aPB2.Pave1().Index())); - const TopoDS_Vertex& aV22=TopoDS::Vertex(myDS->Shape(aPB2.Pave2().Index())); - - aTolV11=BRep_Tool::Tolerance(aV11); - aTolV12=BRep_Tool::Tolerance(aV12); - aTolV21=BRep_Tool::Tolerance(aV21); - aTolV22=BRep_Tool::Tolerance(aV22); - - aP11=BRep_Tool::Pnt(aV11); - aP12=BRep_Tool::Pnt(aV12); - aP21=BRep_Tool::Pnt(aV21); - aP22=BRep_Tool::Pnt(aV22); - - d1121=aP11.Distance(aP21); - aTolSum=aCoeff*(aTolV11+aTolV21); - if (d1121 - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -//======================================================================= -// function: PerformEF -// purpose: -//======================================================================= -void BOPTools_PaveFiller::PerformEF() -{ - myIsDone=Standard_False; - - Standard_Integer n1, n2, anIndexIn=0, nE, nF, aNbEFs, aBlockLength; - - BOPTools_CArray1OfESInterference& aEFs=myIntrPool->ESInterferences(); - // - // E/F Interferences [BooleanOperations_EdgeFace] - myDSIt.Initialize(TopAbs_EDGE, TopAbs_FACE); - // - // BlockLength correction - aNbEFs=ExpectedPoolLength(); - aBlockLength=aEFs.BlockLength(); - if (aNbEFs > aBlockLength) { - aEFs.SetBlockLength(aNbEFs); - } - // - for (; myDSIt.More(); myDSIt.Next()) { - Standard_Boolean justaddinterference = Standard_True; - myDSIt.Current(n1, n2, justaddinterference); - - if(justaddinterference) { - if (!myIntrPool->IsComputed(n1, n2)) { - anIndexIn = 0; - nE=n1; - nF=n2; - SortTypes(nE, nF); - myIntrPool->AddInterference (nE, nF, BooleanOperations_EdgeSurface, anIndexIn); - } - continue; - } - // - if (myIntrPool->IsComputed(n1, n2)) { - continue; - } - // - nE=n1; - nF=n2; - SortTypes(nE, nF); - // - // ListOfCommonBlock for nE and CommonBlockAPI object to avoid - // CommonBlocks processing - BOPTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE)); - BOPTools_CommonBlockAPI aCBAPI(aLCB); - // - Standard_Real aTolE, aTolF, aDeflection=0.01; - Standard_Integer aDiscretize=35; - - // modified by NIZHNY-MKK Thu Oct 27 12:31:45 2005 -// const TopoDS_Edge& aE=TopoDS::Edge(myDS->GetShape(nE)); - TopoDS_Edge aE=TopoDS::Edge(myDS->GetShape(nE)); - // - if (BRep_Tool::Degenerated(aE)){ - continue; - } - // - aTolE=BRep_Tool::Tolerance(aE); - - // modified by NIZHNY-MKK Thu Oct 27 12:31:52 2005 -// const TopoDS_Face& aF=TopoDS::Face(myDS->GetShape(nF)); - TopoDS_Face aF=TopoDS::Face(myDS->GetShape(nF)); - aTolF=BRep_Tool::Tolerance(aF); -// modified by NIZHNY-MKK Thu Oct 27 12:32:02 2005 -// const Bnd_Box& aBBF=myDS->GetBoundingBox(nF); - Bnd_Box aBBF=myDS->GetBoundingBox(nF); - // - BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(nE)); - BOPTools_ListIteratorOfListOfPaveBlock anIt(aLPB); - - for (; anIt.More(); anIt.Next()) { - - BOPTools_PaveBlock& aPB=anIt.Value(); - - if (aCBAPI.IsCommonBlock(aPB)) { - // avoid CommonBlocks processing - continue; - } - - const IntTools_ShrunkRange& aShrunkRange=aPB.ShrunkRange(); - const IntTools_Range& aSR =aShrunkRange.ShrunkRange(); - const Bnd_Box& aBBE=aShrunkRange.BndBox(); - - ////////////////////////////////////////////// - if (aBBF.IsOut (aBBE)) { - continue; - } - // - // EF - IntTools_EdgeFace aEF; - aEF.SetEdge (aE); - aEF.SetFace (aF); - aEF.SetTolE (aTolE); - aEF.SetTolF (aTolF); - aEF.SetDiscretize (aDiscretize); - aEF.SetDeflection (aDeflection); - // - aEF.SetContext(myContext); - // - - BRepAdaptor_Curve aCurve(aE); - IntTools_Range anewSR = aSR; - // - // Correction of the Shrunk Range - // - BOPTools_Tools::CorrectRange(aE, aF, aSR, anewSR); - // - aEF.SetRange (anewSR); - // - aEF.Perform(); - // - anIndexIn=0; - // - if (aEF.IsDone()) { - // - const IntTools_SequenceOfCommonPrts& aCPrts=aEF.CommonParts(); - Standard_Integer i, aNbCPrts; - aNbCPrts=aCPrts.Length(); - - // modified by NIZHNY-MKK Thu Aug 26 17:37:07 2004.BEGIN - if(aNbCPrts != 0) { - char buf[512]; - - if(!aShrunkRange.IsDone()) { - sprintf (buf, "Can not obtain ShrunkRange for Edge %d", nE); - throw BOPTColStd_Failure(buf) ; - } - } - // modified by NIZHNY-MKK Thu Aug 26 17:37:09 2004.END - - for (i=1; i<=aNbCPrts; i++) { - const IntTools_CommonPrt& aCPart=aCPrts.Value(i); - // - anIndexIn=0; - // - TopAbs_ShapeEnum aType=aCPart.Type(); - switch (aType) { - - case TopAbs_VERTEX: { - - Standard_Real aT; - Standard_Integer aNewShape; - - const IntTools_Range& aR=aCPart.Range1(); - - Standard_Real aRFirst, aRLast; - - aR.Range(aRFirst, aRLast); - aT=0.5*(aRFirst+aRLast); - - if((aCPart.VertexParameter1() >= aRFirst) && - (aCPart.VertexParameter1() <= aRLast)) { - aT = aCPart.VertexParameter1(); - } - - TopoDS_Vertex aNewVertex; - BOPTools_Tools::MakeNewVertex(aE, aT, aF,aNewVertex); - // - Standard_Boolean isonpave1, isonpave2; - Standard_Real aTolToDecide; - aTolToDecide=5.e-8; - - // modified by NIZHNY-IFV Feb 15 2007 - // for occ11565 - //Check that whole edge belongs face - isonpave1 = (Abs(anewSR.First() - aRFirst) < aTolToDecide); - isonpave2 = (Abs(anewSR.Last() - aRLast) < aTolToDecide); - //++ - if(isonpave1 && isonpave2) { - //Seems whole edge belongs face - - Standard_Boolean aCoinsideFlag = - BOPTools_Tools::IsBlockInOnFace(aPB, aF, myContext); - if (aCoinsideFlag) { - // - // Add Interference to the Pool - - IntTools_CommonPrt aCP = aCPart; - aCP.SetType(TopAbs_EDGE); - BOPTools_ESInterference anInterf (nE, nF, aCP); - anIndexIn=aEFs.Append(anInterf); - myIntrPool->AddInterference (nE, nF, BooleanOperations_EdgeSurface, anIndexIn); - // - BOPTools_CommonBlock aCB(aPB, nF); - - aLCB.Append(aCB); - break; - } - } - // modified by NIZHNY-IFV Feb 15 2007. end - // - //decide to add pave or not.begin - isonpave1 = (Abs(anewSR.First() - aT) < aTolToDecide); - isonpave2 = (Abs(anewSR.Last() - aT) < aTolToDecide); - - // modified by NIZHNY-MKK Wed Nov 6 14:43:07 2002.BEGIN - if(!isonpave1 && !isonpave2) { - isonpave1 = (Abs(anewSR.First() - aR.First()) < aTolToDecide); - isonpave2 = (Abs(anewSR.Last() - aR.Last()) < aTolToDecide); - } - // modified by NIZHNY-MKK Wed Nov 6 14:43:11 2002.END - //++ - { - Standard_Integer nVP1, nVP2; - Standard_Boolean bIsComputed; - - // Pave 1 - const BOPTools_Pave& aPave1=aPB.Pave1(); - nVP1=aPave1.Index(); - - bIsComputed=Standard_True; - if (nVP1 <= myNbSources) { - - if(((nVP1 <= myDS->NumberOfShapesOfTheObject()) && - (nF <= myDS->NumberOfShapesOfTheObject())) || - ((nVP1 > myDS->NumberOfShapesOfTheObject()) && - (nF > myDS->NumberOfShapesOfTheObject()))) { - bIsComputed=myIntrPool->IsComputed(nVP1, nE); - - if (!bIsComputed) { - bIsComputed=IsSuccesstorsComputed(nVP1, nE); - } - } - else { - bIsComputed=myIntrPool->IsComputed(nVP1, nF); - if (!bIsComputed) { - bIsComputed=IsSuccesstorsComputed(nVP1, nF); - } - } - } - - if (bIsComputed && isonpave1) { - // - myIntrPool->AddInterference (nE, nF, BooleanOperations_EdgeSurface, anIndexIn); - const TopoDS_Vertex& aVF = TopoDS::Vertex(myDS->Shape(nVP1)); - BOPTools_Tools::UpdateVertex(aE, aT, aVF); - continue; - } - // Pave 2 - const BOPTools_Pave& aPave2=aPB.Pave2(); - nVP2=aPave2.Index(); - - bIsComputed=Standard_True; - if (nVP2 <= myNbSources) { - - if((nVP2 <= myDS->NumberOfShapesOfTheObject() && - nF <= myDS->NumberOfShapesOfTheObject()) || - (nVP2 > myDS->NumberOfShapesOfTheObject() && - nF > myDS->NumberOfShapesOfTheObject())) { - bIsComputed=myIntrPool->IsComputed(nVP2, nE); - - if (!bIsComputed) { - bIsComputed=IsSuccesstorsComputed(nVP2, nE); - } - } - else { - bIsComputed=myIntrPool->IsComputed(nVP2, nF); - if (!bIsComputed) { - bIsComputed=IsSuccesstorsComputed(nVP2, nF); - } - } - } - - if (bIsComputed && isonpave2) { - // - myIntrPool->AddInterference (nE, nF, BooleanOperations_EdgeSurface, anIndexIn); - const TopoDS_Vertex& aVF = TopoDS::Vertex(myDS->Shape(nVP2)); - BOPTools_Tools::UpdateVertex(aE, aT, aVF); - continue; - } - } - //decide to add pave or not.end - // - // Insert New Vertex in DS; - // aNewShape is # of DS-line, where aNewVertex is kept - // - BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq; - // - Standard_Integer nVF, iFlag; - nVF=CheckFacePaves(aNewVertex, nF); - if (nVF) { - const TopoDS_Vertex& aVF=TopoDS::Vertex(myDS->Shape(nVF)); - - Standard_Real aTNew; - // - iFlag=myContext->ComputeVE(aVF, aE, aTNew); - // - aT=aTNew; - aNewShape=nVF; - BOPTools_Tools::UpdateVertex(aVF, aNewVertex); - } - // - else { - myDS->InsertShapeAndAncestorsSuccessors(aNewVertex, anASSeq); - aNewShape=myDS->NumberOfInsertedShapes(); - } - // - // Add Interference to the Pool - BOPTools_ESInterference anInterf (nE, nF, aCPart); - anIndexIn=aEFs.Append(anInterf); - myIntrPool->AddInterference (nE, nF, BooleanOperations_EdgeSurface, anIndexIn); - // - // State of the new Vertex is ON - myDS->SetState (aNewShape, BooleanOperations_ON); - // - // Insert New Vertex in EE Interference - BOPTools_ESInterference& aESInterf= aEFs(anIndexIn); - aESInterf.SetNewShape(aNewShape); - // - // Add Pave to the myPavePoolNew - BOPTools_Pave aPave; - aPave.SetInterference(anIndexIn); - aPave.SetType (BooleanOperations_EdgeSurface); - aPave.SetIndex(aNewShape); - - aPave.SetParam(aT); - BOPTools_PaveSet& aPaveSet=myPavePoolNew(myDS->RefEdge(nE)); - aPaveSet.Append(aPave); - - }// case TopAbs_VERTEX: - break; - - case TopAbs_EDGE: { - - Standard_Boolean aCoinsideFlag; - aCoinsideFlag=BOPTools_Tools::IsBlockInOnFace(aPB, aF, myContext); - if (!aCoinsideFlag) { - // - myIntrPool->AddInterference (nE, nF, BooleanOperations_EdgeSurface, anIndexIn); - break; - } - // Add Interference to the Pool - BOPTools_ESInterference anInterf (nE, nF, aCPart); - anIndexIn=aEFs.Append(anInterf); - myIntrPool->AddInterference (nE, nF, BooleanOperations_EdgeSurface, anIndexIn); - // - BOPTools_CommonBlock aCB(aPB, nF); - - aLCB.Append(aCB); - - }// case TopAbs_EDGE: - break; - - default: - break; - } // switch (aType) - } // for (i=1; i<=aNbCPrts; i++) - } //if (aEF.IsDone()) - } // for (; anIt.More(); anIt.Next()) - }// for (; myDSIt.More(); myDSIt.Next()) - myIsDone=Standard_True; -} - - -//======================================================================= -// function: DoSDEdges -// purpose: -//======================================================================= - void BOPTools_PaveFiller::DoSDEdges() -{ - myIsDone=Standard_False; - - Standard_Integer aNbObj, nEObj, nETool, aSplitIndexObj, aSplitIndexTool; - TopAbs_ShapeEnum aType; - - aNbObj=myDS->NumberOfShapesOfTheObject(); - - for (nEObj=1; nEObj<=aNbObj; nEObj++) { - // modified by NIZHNY-MKK Thu Oct 27 12:32:37 2005 -// const TopoDS_Shape& aS=myDS->GetShape(nEObj); - TopoDS_Shape aS=myDS->GetShape(nEObj); - aType=aS.ShapeType(); - if (aType==TopAbs_EDGE) { - //ZZ const TopoDS_Edge& aE=TopoDS::Edge(myDS->GetShape(nEObj)); - - BOPTools_ListOfCommonBlock& aLCBObj=myCommonBlockPool(myDS->RefEdge(nEObj)); - BOPTools_ListIteratorOfListOfCommonBlock anItCBObj(aLCBObj); - for (; anItCBObj.More(); anItCBObj.Next()) { - BOPTools_CommonBlock& aCBObj=anItCBObj.Value(); - - if (aCBObj.Face()) { - continue; - } - - BOPTools_PaveBlock& aPBObj1=aCBObj.PaveBlock1(nEObj); - BOPTools_PaveBlock& aPBObj2=aCBObj.PaveBlock2(nEObj); - // - // Tool - nETool=aPBObj2.OriginalEdge(); - - BOPTools_ListOfCommonBlock& aLCBTool=myCommonBlockPool(myDS->RefEdge(nETool)); - BOPTools_ListIteratorOfListOfCommonBlock anItCBTool(aLCBTool); - for (; anItCBTool.More(); anItCBTool.Next()) { - BOPTools_CommonBlock& aCBTool=anItCBTool.Value(); - - BOPTools_PaveBlock& aPBTool1=aCBTool.PaveBlock1(nETool); - BOPTools_PaveBlock& aPBTool2=aCBTool.PaveBlock2(nETool); - - if (aPBTool1.IsEqual(aPBObj2) && aPBTool2.IsEqual(aPBObj1)) { - // - // That is aCBObj==aCBTool - // Find SplitIndices in DS for aPBObj1 and aPBTool1 - aSplitIndexObj =SplitIndex(aPBObj1); - aSplitIndexTool=SplitIndex(aPBTool1); - if (aSplitIndexObj && aSplitIndexTool) { - - aPBObj1. SetEdge(aSplitIndexObj); - aPBObj2. SetEdge(aSplitIndexTool); - aPBTool1.SetEdge(aSplitIndexTool); - aPBTool2.SetEdge(aSplitIndexObj); - break; - } - else { - //error: can not find SplitIndex - throw - BOPTColStd_Failure(" BOPTools_PaveFiller::DoSDEdges()=> can not find SplitIndex"); - - myIsDone=Standard_False; - return; - } - - } // if (aPBTool1.IsEqual(aPBObj2) && aPBTool2.IsEqual(aPBObj1)) - } // for (; anItCBTool.More(); anItCBTool.Next()) - } // for (; anItCBObj.More(); anItCBObj.Next()) - } // if (aType==TopAbs_EDGE) - } // for (nEObj=1; nEObj<=aNbObj; nEObj++) - - // - // 2. EF CommonBlocks - // - Standard_Integer nE, aSplitIndex; - for (nE=1; nE<=myNbSources; nE++) { - // modified by NIZHNY-MKK Thu Oct 27 12:32:57 2005 -// const TopoDS_Shape& aS=myDS->GetShape(nE); - TopoDS_Shape aS=myDS->GetShape(nE); - aType=aS.ShapeType(); - if (aType==TopAbs_EDGE) { - //ZZ const TopoDS_Edge& aE=TopoDS::Edge(myDS->GetShape(nE)); - - BOPTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE)); - BOPTools_ListIteratorOfListOfCommonBlock anItCB(aLCB); - - for (; anItCB.More(); anItCB.Next()) { - BOPTools_CommonBlock& aCB=anItCB.Value(); - if (aCB.Face()) { - BOPTools_PaveBlock& aPB=aCB.PaveBlock1(nE); - aSplitIndex =SplitIndex(aPB); - if (aSplitIndex) { - aPB.SetEdge(aSplitIndex); - //break; - } - else { - //error: can not find SplitIndex - throw - BOPTColStd_Failure(" BOPTools_PaveFiller::DoSDEdges()=> can not find SplitIndex"); - myIsDone=Standard_False; - return; - } - } - } - } - } - myIsDone=Standard_True; -} - -//======================================================================= -// function: SplitIndex -// purpose: -//======================================================================= - Standard_Integer BOPTools_PaveFiller::SplitIndex(const BOPTools_PaveBlock& aPBx) -{ - Standard_Integer anOriginalEdge, anEdgeIndex=0; - - anOriginalEdge=aPBx.OriginalEdge(); - - BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(anOriginalEdge)); - BOPTools_ListIteratorOfListOfPaveBlock anIt(aLPB); - - for (; anIt.More(); anIt.Next()) { - BOPTools_PaveBlock& aPB=anIt.Value(); - if (aPB.IsEqual(aPBx)) { - anEdgeIndex=aPB.Edge(); - return anEdgeIndex; - } - } - return anEdgeIndex; -} -//======================================================================= -// function: CheckFacePaves -// purpose: -//======================================================================= - Standard_Integer BOPTools_PaveFiller::CheckFacePaves (const TopoDS_Vertex& aNewVertex, - const Standard_Integer nF) -{ - Standard_Integer nEF, nVF, iFlag; - BOPTools_ListIteratorOfListOfPave anIt; - // 1. - BooleanOperations_OnceExplorer aExp(*myDS); - aExp.Init(nF, TopAbs_EDGE); - for (; aExp.More(); aExp.Next()) { - nEF=aExp.Current(); - BOPTools_PaveSet& aPaveSet=myPavePoolNew(myDS->RefEdge(nEF)); - const BOPTools_ListOfPave& aLP=aPaveSet.Set(); - anIt.Initialize(aLP); - for (; anIt.More(); anIt.Next()) { - const BOPTools_Pave& aPave=anIt.Value(); - nVF=aPave.Index(); - const TopoDS_Vertex& aVF=TopoDS::Vertex(myDS->Shape(nVF)); - iFlag=IntTools_Tools::ComputeVV(aNewVertex, aVF); - if (!iFlag) { - return nVF; - } - } - } - // - // 2. - aExp.Init(nF, TopAbs_EDGE); - for (; aExp.More(); aExp.Next()) { - nEF=aExp.Current(); - BOPTools_PaveSet& aPaveSet=myPavePool(myDS->RefEdge(nEF)); - const BOPTools_ListOfPave& aLP=aPaveSet.Set(); - anIt.Initialize(aLP); - for (; anIt.More(); anIt.Next()) { - const BOPTools_Pave& aPave=anIt.Value(); - nVF=aPave.Index(); - const TopoDS_Vertex& aVF=TopoDS::Vertex(myDS->Shape(nVF)); - iFlag=IntTools_Tools::ComputeVV(aNewVertex, aVF); - if (!iFlag) { - return nVF; - } - } - } - - return 0; -} -// - - diff --git a/src/BOPTools/BOPTools_PaveFiller_2.cxx b/src/BOPTools/BOPTools_PaveFiller_2.cxx deleted file mode 100755 index accb653317..0000000000 --- a/src/BOPTools/BOPTools_PaveFiller_2.cxx +++ /dev/null @@ -1,339 +0,0 @@ -// Created on: 2001-03-27 -// Created by: Peter KURNEV -// Copyright (c) 2001-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include - -#include - -#include -#include - -#include -#include -#include - -//======================================================================= -// A P I F U N C T I O N S -//======================================================================= -// function: SplitsInFace -// purpose: splits of edges from nF1 in nF2 -//======================================================================= -Standard_Integer BOPTools_PaveFiller::SplitsInFace(const Standard_Integer ,//for overriding - const Standard_Integer nF1, - const Standard_Integer nF2, - TColStd_ListOfInteger& aSplits) -{ - Standard_Integer nE1; - TopAbs_ShapeEnum aT1, aT2; - - aT1=myDS->GetShapeType(nF1); - aT2=myDS->GetShapeType(nF2); - - if (aT1!=TopAbs_FACE || aT2!=TopAbs_FACE) { - return 1; // Type mismatch - } - - BooleanOperations_OnceExplorer aExp(*myDS); - aExp.Init(nF1, TopAbs_EDGE); - for (; aExp.More(); aExp.Next()) { - nE1=aExp.Current(); - SplitsInFace (nE1, nF2, aSplits); - } - return 0; //Ok -} -//======================================================================= -// function: SplitsInFace -// purpose: splits of edge nE1 in aFace2 -//======================================================================= - Standard_Integer BOPTools_PaveFiller::SplitsInFace(const Standard_Integer nE1, - const Standard_Integer nF2, - TColStd_ListOfInteger& aSplits) -{ - Standard_Integer nF1, nSp; - TopAbs_ShapeEnum aT1, aT2; - - aT1=myDS->GetShapeType(nE1); - aT2=myDS->GetShapeType(nF2); - - if (aT1!=TopAbs_EDGE || aT2!=TopAbs_FACE) { - return 1; // Type mismatch - } - - const BOPTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE1)); - BOPTools_ListIteratorOfListOfCommonBlock anItCB(aLCB); - for (; anItCB.More(); anItCB.Next()) { - BOPTools_CommonBlock& aCB=anItCB.Value(); - BOPTools_PaveBlock& aPB1=aCB.PaveBlock1(nE1); - - nF1=aCB.Face(); - if (nF1==nF2) { - nSp=aPB1.Edge(); - aSplits.Append(nSp); - } - } - return 0; //Ok -} - -//======================================================================= -// function: SplitsOnEdge -// purpose: splits of edge nE1 on nE2 -//======================================================================= - Standard_Integer BOPTools_PaveFiller::SplitsOnEdge(const Standard_Integer nE1, - const Standard_Integer nE2, - TColStd_ListOfInteger& aSplits) -{ - Standard_Integer nE, nSp; - TopAbs_ShapeEnum aT1, aT2; - - aT1=myDS->GetShapeType(nE1); - aT2=myDS->GetShapeType(nE2); - - if (aT1!=TopAbs_EDGE || aT2!=TopAbs_EDGE) { - return 1; // Type mismatch - } - - const BOPTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE1)); - BOPTools_ListIteratorOfListOfCommonBlock anItCB(aLCB); - for (; anItCB.More(); anItCB.Next()) { - BOPTools_CommonBlock& aCB=anItCB.Value(); - BOPTools_PaveBlock& aPB1=aCB.PaveBlock1(nE1); - BOPTools_PaveBlock& aPB2=aCB.PaveBlock2(nE1); - nE=aPB2.OriginalEdge(); - if (nE==nE2) { - nSp=aPB1.Edge(); - aSplits.Append(nSp); - } - } - return 0; //Ok -} -//======================================================================= -// function: SplitsOnFace -// purpose: splits of edge nE1 on face nF2 -//======================================================================= - Standard_Integer BOPTools_PaveFiller::SplitsOnFace(const Standard_Integer nE1, - const Standard_Integer nF2, - TColStd_ListOfInteger& aSplits) -{ - Standard_Integer nE2, ip; - TopAbs_ShapeEnum aT1, aT2; - - aT1=myDS->GetShapeType(nE1); - aT2=myDS->GetShapeType(nF2); - - if (aT1!=TopAbs_EDGE || aT2!=TopAbs_FACE) { - return 1; // Type mismatch - } - - BooleanOperations_OnceExplorer aExp(*myDS); - aExp.Init(nF2, TopAbs_EDGE); - for (; aExp.More(); aExp.Next()) { - nE2=aExp.Current(); - ip=SplitsOnEdge(nE1, nE2, aSplits); - if (ip) { - return ip; - } - } - return 0; //Ok -} -//======================================================================= -// function: SplitsOnFace -// purpose: splits of edges from face nF1 on face nF2 -//======================================================================= - Standard_Integer BOPTools_PaveFiller::SplitsOnFace(const Standard_Integer ,//for overriding - const Standard_Integer nF1, - const Standard_Integer nF2, - TColStd_ListOfInteger& aSplits) -{ - Standard_Integer nE1, ip; - TopAbs_ShapeEnum aT1, aT2; - - aT1=myDS->GetShapeType(nF1); - aT2=myDS->GetShapeType(nF2); - - if (aT1!=TopAbs_FACE || aT2!=TopAbs_FACE) { - return 1; // Type mismatch - } - - BooleanOperations_OnceExplorer aExp(*myDS); - aExp.Init(nF1, TopAbs_EDGE); - for (; aExp.More(); aExp.Next()) { - nE1=aExp.Current(); - ip=SplitsOnFace(nE1, nF2, aSplits); - if (ip) { - return ip; - } - } - return 0; //Ok -} -/////////////////////////////////////////////////////////////////////////////////// -//======================================================================= -// function: SplitsInFace -// purpose: splits of edges from nF1 in nF2 -//======================================================================= - Standard_Integer BOPTools_PaveFiller::SplitsInFace(const Standard_Integer ,//for overriding - const Standard_Integer nF1, - const Standard_Integer nF2, - BOPTools_ListOfPaveBlock& aLPB) -{ - Standard_Integer nE1; - TopAbs_ShapeEnum aT1, aT2; - - aT1=myDS->GetShapeType(nF1); - aT2=myDS->GetShapeType(nF2); - - if (aT1!=TopAbs_FACE || aT2!=TopAbs_FACE) { - return 1; // Type mismatch - } - - BooleanOperations_OnceExplorer aExp(*myDS); - aExp.Init(nF1, TopAbs_EDGE); - for (; aExp.More(); aExp.Next()) { - nE1=aExp.Current(); - SplitsInFace (nE1, nF2, aLPB); - } - return 0; //Ok -} -//======================================================================= -// function: SplitsInFace -// purpose: splits of edge nE1 in aFace2 -//======================================================================= - Standard_Integer BOPTools_PaveFiller::SplitsInFace(const Standard_Integer nE1, - const Standard_Integer nF2, - BOPTools_ListOfPaveBlock& aLPB) -{ - Standard_Integer nF1; - TopAbs_ShapeEnum aT1, aT2; - - aT1=myDS->GetShapeType(nE1); - aT2=myDS->GetShapeType(nF2); - - if (aT1!=TopAbs_EDGE || aT2!=TopAbs_FACE) { - return 1; // Type mismatch - } - - const BOPTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE1)); - BOPTools_ListIteratorOfListOfCommonBlock anItCB(aLCB); - for (; anItCB.More(); anItCB.Next()) { - BOPTools_CommonBlock& aCB=anItCB.Value(); - BOPTools_PaveBlock& aPB1=aCB.PaveBlock1(nE1); - - nF1=aCB.Face(); - if (nF1==nF2) { - aLPB.Append(aPB1); - } - } - return 0; //Ok -} - -//======================================================================= -// function: SplitsOnEdge -// purpose: splits of edge nE1 on nE2 -//======================================================================= - Standard_Integer BOPTools_PaveFiller::SplitsOnEdge(const Standard_Integer nE1, - const Standard_Integer nE2, - BOPTools_ListOfPaveBlock& aLPB) -{ - Standard_Integer nE; - TopAbs_ShapeEnum aT1, aT2; - - aT1=myDS->GetShapeType(nE1); - aT2=myDS->GetShapeType(nE2); - - if (aT1!=TopAbs_EDGE || aT2!=TopAbs_EDGE) { - return 1; // Type mismatch - } - - const BOPTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE1)); - BOPTools_ListIteratorOfListOfCommonBlock anItCB(aLCB); - for (; anItCB.More(); anItCB.Next()) { - BOPTools_CommonBlock& aCB=anItCB.Value(); - //BOPTools_PaveBlock& aPB1=aCB.PaveBlock1(nE1); - BOPTools_PaveBlock& aPB2=aCB.PaveBlock2(nE1); - nE=aPB2.OriginalEdge(); - if (nE==nE2) { - //modified by NIZNHY-PKV Tue Apr 4 16:59:24 2006f - //aLPB.Append(aPB1); - const BOPTools_PaveBlock& aPB1R=aCB.PaveBlock1(); - aLPB.Append(aPB1R); - //modified by NIZNHY-PKV Tue Apr 4 16:59:28 2006t - } - } - return 0; //Ok -} -//======================================================================= -// function: SplitsOnFace -// purpose: splits of edge nE1 on face nF2 -//======================================================================= - Standard_Integer BOPTools_PaveFiller::SplitsOnFace(const Standard_Integer nE1, - const Standard_Integer nF2, - BOPTools_ListOfPaveBlock& aLPB) -{ - Standard_Integer nE2, ip; - TopAbs_ShapeEnum aT1, aT2; - - aT1=myDS->GetShapeType(nE1); - aT2=myDS->GetShapeType(nF2); - - if (aT1!=TopAbs_EDGE || aT2!=TopAbs_FACE) { - return 1; // Type mismatch - } - - BooleanOperations_OnceExplorer aExp(*myDS); - aExp.Init(nF2, TopAbs_EDGE); - for (; aExp.More(); aExp.Next()) { - nE2=aExp.Current(); - ip=SplitsOnEdge(nE1, nE2, aLPB); - if (ip) { - return ip; - } - } - return 0; //Ok -} -//======================================================================= -// function: SplitsOnFace -// purpose: splits of edges from face nF1 on face nF2 -//======================================================================= - Standard_Integer BOPTools_PaveFiller::SplitsOnFace(const Standard_Integer ,//for overriding - const Standard_Integer nF1, - const Standard_Integer nF2, - BOPTools_ListOfPaveBlock& aLPB) -{ - Standard_Integer nE1, ip; - TopAbs_ShapeEnum aT1, aT2; - - aT1=myDS->GetShapeType(nF1); - aT2=myDS->GetShapeType(nF2); - - if (aT1!=TopAbs_FACE || aT2!=TopAbs_FACE) { - return 1; // Type mismatch - } - - BooleanOperations_OnceExplorer aExp(*myDS); - aExp.Init(nF1, TopAbs_EDGE); - for (; aExp.More(); aExp.Next()) { - nE1=aExp.Current(); - ip=SplitsOnFace(nE1, nF2, aLPB); - if (ip) { - return ip; - } - } - return 0; //Ok -} diff --git a/src/BOPTools/BOPTools_PaveFiller_3.cxx b/src/BOPTools/BOPTools_PaveFiller_3.cxx deleted file mode 100755 index e81ba3fbf5..0000000000 --- a/src/BOPTools/BOPTools_PaveFiller_3.cxx +++ /dev/null @@ -1,3441 +0,0 @@ -// Created on: 2001-03-13 -// Created by: Peter KURNEV -// Copyright (c) 2001-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include -#include - - -static - Standard_Boolean IsPaveBlock(const Standard_Integer nV1, - const Standard_Integer nV2, - const BOPTools_ListOfPaveBlock& aLPBExisting); -static - Standard_Boolean IsFound(const TColStd_IndexedMapOfInteger& aMapWhat, - const TColStd_IndexedMapOfInteger& aMapWith); -static - void FMapWith(const Standard_Integer nF, - BOPTools_InterferencePool* myIntrPool, - TColStd_IndexedMapOfInteger& aMapWith); -static - void FMapWhat(const Standard_Integer nF, - BOPTools_InterferencePool* myIntrPool, - TColStd_IndexedMapOfInteger& aMapWhat); - -//wkar OCC334 f -static - void UnUsedMap(BOPTools_SequenceOfCurves& aSCvs, - const BOPTools_PaveSet& aPSF, - TColStd_IndexedMapOfInteger& aMapUnUsed); -static - Standard_Boolean VertexRangeTolerance(const Standard_Integer nV, - const Standard_Integer nF1, - const Standard_Integer nF2, - const BOPTools_InterferencePool& anIntrPool, - Standard_Real& aTolV); -static - void FaceAndEdgeMap(const Standard_Integer nF, - const BOPTools_InterferencePool& anIntrPool, - TColStd_IndexedMapOfInteger& aMEF); -static - void ProcessAloneStickVertices(const Standard_Integer nF1, - const Standard_Integer nF2, - const BOPTools_PaveSet& aPSF, - BOPTools_SequenceOfCurves& aSCvs, - const BOPTools_InterferencePool& anIntrPool, - BOPTools_PaveFiller& aPF, - TColStd_SequenceOfInteger& aSeqVx, - TColStd_SequenceOfReal& aSeqTolVx); -static - void ProcessAloneStickVertices(const Standard_Integer nF1, - const Standard_Integer nF2, - const BOPTools_PaveSet& aPSF, - BOPTools_SequenceOfCurves& aSCvs, - BOPTools_PaveFiller& aPF, - TColStd_SequenceOfInteger& aSeqVx, - TColStd_SequenceOfReal& aSeqTolVx); -//wkar OCC334 t - -static - Standard_Boolean IsPairFound(const Standard_Integer nF1, - const Standard_Integer nF2, - BOPTools_InterferencePool* myIntrPool, - BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMapWhat, - BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMapWith); - -static Standard_Boolean CheckNewVertexAndUpdateData(const TopoDS_Vertex& theVertex, - const Standard_Real theParamOnE, - const TopoDS_Edge& theEdge, - const Standard_Real theParamOnCurve, - const Standard_Integer theIndexF1, - const Standard_Integer theIndexF2, - const Standard_Real theTolerance, - const BOPTools_PInterferencePool& theIntrPool, - const BooleanOperations_PShapesDataStructure& theDS, - const Handle(IntTools_Context)& theContext, - const BOPTools_PaveSet& theEdgePaveSet, - const Standard_Boolean bAddNewVertex, - const Standard_Boolean bAddOldVertex, - BOPTools_Curve& theBC, - BOPTools_Pave& thePaveToPut, - Standard_Boolean& bAddNewVertexOut, - Standard_Boolean& bAddOldVertexOut); - -static void AddInterfForAdjacentFace(const Standard_Integer theEdgeIndex, - const Standard_Integer theIndexF1, - const Standard_Integer theIndexF2, - BOPTools_PInterferencePool theIntrPool, - const BooleanOperations_PShapesDataStructure& theDS); - -static Standard_Boolean RejectPaveBlock(const IntTools_Curve& theC, - const Standard_Real theT1, - const Standard_Real theT2, - const TopoDS_Vertex& theV, - Standard_Real& theRT); - -static Standard_Boolean ModifFFTol(const TopoDS_Face& theF1, - const TopoDS_Face& theF2, - Standard_Real& theTF); - -static Standard_Integer RejectBuildingEdge(const IntTools_Curve& theC, - const TopoDS_Vertex& theV1, - const TopoDS_Vertex& theV2, - const Standard_Real theT1, - const Standard_Real theT2, - const TopTools_ListOfShape& theL, - Standard_Real& theTF); - -static - void CorrectTolR3D(BOPTools_PaveFiller& aPF, - const BOPTools_SSInterference& aFF, - const TColStd_MapOfInteger& aMVStick, - Standard_Real& aTolR3D); - -//======================================================================= -// function: PerformFF -// purpose: -//======================================================================= - void BOPTools_PaveFiller::PerformFF() -{ - myIsDone=Standard_False; - Standard_Boolean bIsFound, bToSplit; - Standard_Integer n1, n2, anIndexIn=0, nF1, nF2, aNbFFs, aBlockLength; - BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger aMapWhat, aMapWith; - // - BOPTools_CArray1OfSSInterference& aFFs=myIntrPool->SSInterferences(); - // - // F/F Interferences [BooleanOperations_SurfaceSurface] - myDSIt.Initialize(TopAbs_FACE, TopAbs_FACE); - // - // BlockLength correction - aNbFFs=ExpectedPoolLength(); - aBlockLength=aFFs.BlockLength(); - if (aNbFFs > aBlockLength) { - aFFs.SetBlockLength(aNbFFs); - } - // - bToSplit=Standard_False; - - for (; myDSIt.More(); myDSIt.Next()) { - Standard_Boolean justaddinterference = Standard_True; - myDSIt.Current(n1, n2, justaddinterference); - - if(justaddinterference) { - if (!myIntrPool->IsComputed(n1, n2)) { - - if(n1 < n2) { - nF1 = n1; - nF2 = n2; - } - else { - nF1 = n2; - nF2 = n1; - } - // - bIsFound=IsPairFound(nF1, nF2, myIntrPool, aMapWhat, aMapWith); - // - if (!bIsFound) { - myIntrPool->AddInterference (nF1, nF2, BooleanOperations_SurfaceSurface, anIndexIn); - } - else { - IntTools_SequenceOfPntOn2Faces aPnts; - IntTools_SequenceOfCurves aCvs; - - BOPTools_SSInterference anInterf (nF1, nF2, 1.e-07, 1.e-07, aCvs, aPnts); - anIndexIn=aFFs.Append(anInterf); - myIntrPool->AddInterference (nF1, nF2, BooleanOperations_SurfaceSurface, anIndexIn); - } - } - continue; - } - // - if (myIntrPool->IsComputed(n1, n2)) { - continue; - } - // - nF1=n1; - nF2=n2; - if (nF1 > nF2) { - Standard_Integer iTmp; - iTmp=nF1; - nF1=nF2; - nF2=iTmp; - } - // - TopoDS_Face aF1=TopoDS::Face(myDS->GetShape(nF1)); - TopoDS_Face aF2=TopoDS::Face(myDS->GetShape(nF2)); - // - IntSurf_ListOfPntOn2S aListOfPnts; - GeomAPI_ProjectPointOnSurf& aProj1 = myContext->ProjPS(aF1); - GeomAPI_ProjectPointOnSurf& aProj2 = myContext->ProjPS(aF2); - - BOPTools_CArray1OfESInterference& aEFs=myIntrPool->ESInterferences(); - TColStd_MapOfInteger aMapEdgeIndex1, aMapEdgeIndex2; - for(Standard_Integer fIt = 0; fIt < 2; fIt++) { - Standard_Integer nF = (fIt == 0) ? nF1 : nF2; - for(Standard_Integer sIt1 = 1; sIt1 <= myDS->NumberOfSuccessors(nF); sIt1++) { - Standard_Integer nIndexS1 = myDS->GetSuccessor(nF, sIt1); - if(myDS->GetShapeType(nIndexS1) == TopAbs_EDGE) { - if(fIt == 0) - aMapEdgeIndex1.Add(nIndexS1); - else - aMapEdgeIndex2.Add(nIndexS1); - } - else { - for(Standard_Integer sIt2 = 1; sIt2 <= myDS->NumberOfSuccessors(nIndexS1); sIt2++) { - Standard_Integer nIndexS2 = myDS->GetSuccessor(nIndexS1, sIt2); - - if(myDS->GetShapeType(nIndexS2) == TopAbs_EDGE) { - if(fIt == 0) - aMapEdgeIndex1.Add(nIndexS2); - else - aMapEdgeIndex2.Add(nIndexS2); - } - } - } - } - - TColStd_MapIteratorOfMapOfInteger anIt; - if(fIt == 0) - anIt.Initialize(aMapEdgeIndex1); - else - anIt.Initialize(aMapEdgeIndex2); - - Standard_Integer nFOpposite = (fIt == 0) ? nF2 : nF1; - - for(; anIt.More(); anIt.Next()) { - Standard_Integer nIndexE = anIt.Key(); - - for(Standard_Integer interIt = 1; interIt <= aEFs.Length(); interIt++) { - const BOPTools_ESInterference& aEF = aEFs(interIt); - - if((aEF.Index1() == nIndexE) && (nFOpposite == aEF.Index2())) { - IntTools_CommonPrt aCP = aEF.CommonPrt(); - - if(aCP.Type() == TopAbs_VERTEX) { - Standard_Real aPar = aCP.VertexParameter1(); - // compute points and add to the list - Standard_Real f,l; - Handle(Geom_Curve) aCurve = BRep_Tool::Curve(TopoDS::Edge(myDS->GetShape(nIndexE)), f,l); - Handle(Geom2d_Curve) aPCurve; - if(fIt == 0) { - aPCurve = BRep_Tool::CurveOnSurface(TopoDS::Edge(myDS->GetShape(nIndexE)), - aF1, f, l); - } - else { - aPCurve = BRep_Tool::CurveOnSurface(TopoDS::Edge(myDS->GetShape(nIndexE)), - aF2, f, l); - } - - gp_Pnt aPoint; - aCurve->D0(aPar, aPoint); - Standard_Real U1,V1,U2,V2; - IntSurf_PntOn2S aPnt; - if(!aPCurve.IsNull()) { - gp_Pnt2d aP2d = aPCurve->Value(aPar); - if(fIt == 0) { - aProj2.Perform(aPoint); - if(aProj2.IsDone()) { - aProj2.LowerDistanceParameters(U2,V2); - aPnt.SetValue(aP2d.X(),aP2d.Y(),U2,V2); - aListOfPnts.Append(aPnt); - } - } - else { - aProj1.Perform(aPoint); - if(aProj1.IsDone()) { - aProj1.LowerDistanceParameters(U1,V1); - aPnt.SetValue(U1,V1,aP2d.X(),aP2d.Y()); - aListOfPnts.Append(aPnt); - } - } - } - else { - aProj1.Perform(aPoint); - aProj2.Perform(aPoint); - if(aProj1.IsDone() && aProj2.IsDone()){ - aProj1.LowerDistanceParameters(U1,V1); - aProj2.LowerDistanceParameters(U2,V2); - aPnt.SetValue(U1,V1,U2,V2); - aListOfPnts.Append(aPnt); - } - } - } - } - } - } - } - // - // FF - Standard_Boolean bToApproxC3d, bToApproxC2dOnS1, bToApproxC2dOnS2, bIsDone; - Standard_Real anApproxTol, aTolR3D, aTolR2D; - // - bToApproxC3d = mySectionAttribute.Approximation(); - bToApproxC2dOnS1 = mySectionAttribute.PCurveOnS1(); - bToApproxC2dOnS2 = mySectionAttribute.PCurveOnS2(); - // - anApproxTol=1.e-7; - - IntTools_FaceFace aFF; - // - aFF.SetContext(myContext); - // - aFF.SetParameters (bToApproxC3d, - bToApproxC2dOnS1, - bToApproxC2dOnS2, - anApproxTol); - // - if (!aListOfPnts.IsEmpty()) { - aFF.SetList(aListOfPnts); - } - // - aFF.Perform(aF1, aF2); - // - bIsDone=aFF.IsDone(); - if (bIsDone) { - // Add Interference to the Pool - aTolR3D=aFF.TolReached3d(); - aTolR2D=aFF.TolReached2d(); - if (aTolR3D < 1.e-7){ - aTolR3D=1.e-7; - } - aFF.PrepareLines3D(bToSplit); - // - anIndexIn=0; - Standard_Integer aNbCurves, aNbPoints; - - const IntTools_SequenceOfCurves& aCvs=aFF.Lines(); - aNbCurves=aCvs.Length(); - // - const IntTools_SequenceOfPntOn2Faces& aPnts=aFF.Points(); - aNbPoints=aPnts.Length(); - - if (!aNbCurves && !aNbPoints) { - // - bIsFound=IsPairFound(nF1, nF2, myIntrPool, aMapWhat, aMapWith); - // - if (!bIsFound) { - myIntrPool->AddInterference (nF1, nF2, BooleanOperations_SurfaceSurface, anIndexIn); - continue; - } - } - // - BOPTools_SSInterference anInterf (nF1, nF2, aTolR3D, aTolR2D, aCvs, aPnts); - anIndexIn=aFFs.Append(anInterf); - - myIntrPool->AddInterference (nF1, nF2, BooleanOperations_SurfaceSurface, anIndexIn); - } //if (bIsDone) - // - else { - anIndexIn=0; - // - bIsFound=IsPairFound(nF1, nF2, myIntrPool, aMapWhat, aMapWith); - // - if (!bIsFound) { - myIntrPool->AddInterference (nF1, nF2, BooleanOperations_SurfaceSurface, anIndexIn); - } - else { - IntTools_SequenceOfPntOn2Faces aPnts; - IntTools_SequenceOfCurves aCvs; - - BOPTools_SSInterference anInterf (nF1, nF2, 1.e-07, 1.e-07, aCvs, aPnts); - anIndexIn=aFFs.Append(anInterf); - myIntrPool->AddInterference (nF1, nF2, BooleanOperations_SurfaceSurface, anIndexIn); - } - } - }// for (; myDSIt.More(); myDSIt.Next()) - myIsDone=Standard_True; -} -//======================================================================= -// function: MakeBlocks -// purpose: -//======================================================================= - void BOPTools_PaveFiller::MakeBlocks() -{ - Standard_Integer i, j, aNbCurves, aNbFFs, nF1, nF2, aBid=0, nV1, nV2; - Standard_Real aTolR3D, aT1, aT2; - Standard_Boolean bValid, bCoincide; - - BOPTools_CArray1OfSSInterference& aFFs=myIntrPool->SSInterferences(); - - aNbFFs=aFFs.Extent(); - - for (i=1; i<=aNbFFs; i++) { - BOPTools_SSInterference& aFFi=aFFs(i); - // - nF1=aFFi.Index1(); - nF2=aFFi.Index2(); - // - // Curves' tolerance - aTolR3D=aFFi.TolR3D(); - // - // Faces - const TopoDS_Face& aF1=TopoDS::Face(myDS->GetShape(nF1)); - const TopoDS_Face& aF2=TopoDS::Face(myDS->GetShape(nF2)); - - TColStd_MapOfInteger aMap; - BOPTools_ListOfPaveBlock aLPB; - SplitsInFace (aBid, nF1, nF2, aLPB); - SplitsInFace (aBid, nF2, nF1, aLPB); - SplitsOnFace (aBid, nF1, nF2, aLPB); - - BOPTools_ListIteratorOfListOfPaveBlock anIt(aLPB); - for (; anIt.More(); anIt.Next()) { - const BOPTools_PaveBlock& aPB=anIt.Value(); - aFFi.AppendBlock(aPB); - nV1=aPB.Pave1().Index(); - nV2=aPB.Pave2().Index(); - aMap.Add(nV1); - aMap.Add(nV2); - } - // Put existing paves on curves - // BOPTools_PaveSet aPSF; - // PrepareSetForFace (nF1, nF2, aPSF); - - BOPTools_SequenceOfCurves& aSCvs = aFFi.Curves(); - aNbCurves=aSCvs.Length(); - - // - // Pave Blocks On Curves - // - Standard_Boolean bIsPaveBlock; - Standard_Integer iCheckIntermediatePoint; - // - for (j=1; j<=aNbCurves; j++) { - BOPTools_Curve& aBC=aSCvs(j); - const IntTools_Curve& aC= aBC.Curve(); - - BOPTools_PaveSet& aPaveSet=aBC.Set(); - BOPTools_PaveBlockIterator aPBIter(0, aPaveSet); - for (; aPBIter.More(); aPBIter.Next()) { - BOPTools_PaveBlock& aPBNew=aPBIter.Value(); - aPBNew.SetCurve(aC); - aPBNew.SetFace1(nF1); - aPBNew.SetFace2(nF2); - // - nV1=aPBNew.Pave1().Index(); - nV2=aPBNew.Pave2().Index(); - - if (aMap.Contains(nV1) && aMap.Contains(nV2)) { - // - const BOPTools_ListOfPaveBlock& aLPBExisting=aFFi.PaveBlocks(); - bIsPaveBlock=IsPaveBlock(nV1, nV2, aLPBExisting); - // - iCheckIntermediatePoint=1; - if (bIsPaveBlock) { - BOPTools_ListIteratorOfListOfPaveBlock anItLPB(aLPBExisting); - - for (; anItLPB.More(); anItLPB.Next()) { - const BOPTools_PaveBlock& aPBR=anItLPB.Value(); - iCheckIntermediatePoint= - CheckIntermediatePoint(aPBNew, aPBR, aTolR3D); - if (!iCheckIntermediatePoint) { - break; - } - } - bIsPaveBlock=bIsPaveBlock && !iCheckIntermediatePoint; - } - // - if (bIsPaveBlock) { - continue; - } - } - // - else { - iCheckIntermediatePoint=0; - } - // - aT1=aPBNew.Pave1().Param(); - aT2=aPBNew.Pave2().Param(); - // - if((nV1 == nV2) && (Abs(aT2 - aT1) < Precision::PConfusion())) { - continue; - } - // - // Checking of validity in 2D - // - Standard_Real aTolerance = (aTolR3D < 1.e-3) ? 1.e-3 : aTolR3D; - bValid=myContext->IsValidBlockForFaces(aT1, aT2, aC, aF1, aF2, aTolerance); - // - if (!bValid) { - continue; - } - // - // Checking the paveblocks for coinsidence with aLPB - bCoincide=CheckCoincidence (aPBNew, aFFi); - // - bCoincide=bCoincide && !iCheckIntermediatePoint; - // - if (bCoincide) { - continue; - } - // - // reject pave block (FF) v1==v2 for too small sect. edge - TopoDS_Vertex aV1=TopoDS::Vertex(myDS->GetShape(nV1)); - TopoDS_Vertex aV2=TopoDS::Vertex(myDS->GetShape(nV2)); - Standard_Boolean rejectPaveBlock = Standard_False; - if(aV1.IsSame(aV2)) { - Standard_Real aRT = 1.e-7; - rejectPaveBlock = RejectPaveBlock(aC,aT1,aT2,aV1,aRT); - if(rejectPaveBlock) { - if(aRT > 1.e-7) { - BRep_Builder BB; - BB.UpdateVertex( aV1, 2*aRT ); - } - continue; - } - } - // - aBC.AppendNewBlock(aPBNew); - } - } // end of for (j=1; j<=aNbCurves; j++) - }// end of for (i=1; i<=aNbFFs; i++) -} -//======================================================================= -// function: MakeAloneVertices -// purpose: -//======================================================================= - void BOPTools_PaveFiller::MakeAloneVertices() -{ - Standard_Integer i, j, k, aNbFFs, aNbCurves, nF1, nF2, nV, aNbAlone, aNbV; - Standard_Boolean bFlag=Standard_False; - - BOPTools_ListIteratorOfListOfPave anIt; - TColStd_IndexedMapOfInteger aMap; - BOPTools_CArray1OfSSInterference& aFFs=myIntrPool->SSInterferences(); - - aNbFFs=aFFs.Extent(); - for (i=1; i<=aNbFFs; i++) { - BOPTools_SSInterference& aFFi=aFFs(i); - - const IntTools_SequenceOfPntOn2Faces& aSeqAlonePnts=aFFi.AlonePnts(); - aNbAlone=aSeqAlonePnts.Length(); - - if (!aNbAlone) { - continue; - } - - nF1=aFFi.Index1(); - nF2=aFFi.Index2(); - // - TopoDS_Face aF1=TopoDS::Face(myDS->Shape(nF1)); - TopoDS_Face aF2=TopoDS::Face(myDS->Shape(nF2)); - // - // 1. fill aMap where all indices for (F/F) vertices are - aMap.Clear(); - - BOPTools_PaveSet aPSF; - - PrepareSetForFace (nF1, nF2, aPSF); - const BOPTools_ListOfPave& aLPaves=aPSF.Set(); - anIt.Initialize(aLPaves); - for (; anIt.More(); anIt.Next()) { - const BOPTools_Pave& aPave=anIt.Value(); - nV=aPave.Index(); - aMap.Add(nV); - } - - BOPTools_SequenceOfCurves& aSCvs=aFFi.Curves(); - aNbCurves=aSCvs.Length(); - for (j=1; j<=aNbCurves; j++) { - BOPTools_Curve& aBC=aSCvs(j); - const BOPTools_PaveSet& aCPSF=aBC.Set(); - const BOPTools_ListOfPave& aLPs=aCPSF.Set(); - anIt.Initialize(aLPs); - for (; anIt.More(); anIt.Next()) { - const BOPTools_Pave& aPv=anIt.Value(); - nV=aPv.Index(); - aMap.Add(nV); - } - } - // - // 2. check alone points on closure with aMap's vertices - Standard_Integer iVV; - Standard_Real aTolVAlone, aTolF1, aTolF2; - TopoDS_Vertex aVAlone; - BRep_Builder aBB; - - aTolF1=BRep_Tool::Tolerance(aF1); - aTolF2=BRep_Tool::Tolerance(aF2); - aTolVAlone=aTolF1+aTolF2; - - aNbV=aMap.Extent(); - for (j=1; j<=aNbAlone; ++j) { - const IntTools_PntOn2Faces& aP2F=aSeqAlonePnts(j); - const IntTools_PntOnFace& aPF1=aP2F.P1(); - const gp_Pnt& aPAlone=aPF1.Pnt(); - aBB.MakeVertex(aVAlone, aPAlone, aTolVAlone); - // - bFlag=Standard_True; - // - for (k=1; k<=aNbV; ++k) { - nV=aMap(k); - const TopoDS_Vertex& aV=TopoDS::Vertex(myDS->Shape(nV)); - - iVV= IntTools_Tools::ComputeVV (aVAlone, aV); - if (!iVV) { - // It means that aVAlone and aV coinsided so - // we do not need to insert aVAlone into the DS - bFlag=Standard_False; - break; - } - - } - if (bFlag) { - Standard_Boolean bVF; - Standard_Integer aNewShape; - // - bVF=myContext->IsValidPointForFaces (aPAlone, aF1, aF2, 1.e-3); - // - if (bVF) { - BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq; - myDS->InsertShapeAndAncestorsSuccessors(aVAlone, anASSeq); - aNewShape=myDS->NumberOfInsertedShapes(); - myDS->SetState (aNewShape, BooleanOperations_ON); - // - TColStd_ListOfInteger& anAloneVertices=aFFi.AloneVertices(); - anAloneVertices.Append(aNewShape); - } - } - } - - } -} -//======================================================================= -// function: CheckCoincidence -// purpose: -//======================================================================= - Standard_Boolean BOPTools_PaveFiller::CheckCoincidence(const BOPTools_PaveBlock& aPB, - const BOPTools_SSInterference& aFFi) - -{ - Standard_Real aTolC, aTE, aT11, aT12; - Standard_Integer nV11, nV12, nV21, nV22, iVV, iVE, nE2, iCount=0, iCountExt=1; - Standard_Integer iV; - - aTolC=aFFi.TolR3D(); - // V11 - const BOPTools_Pave& aPave11=aPB.Pave1(); - nV11=aPave11.Index(); - const TopoDS_Vertex& aV11=TopoDS::Vertex(myDS->GetShape(nV11)); - aT11=aPave11.Param(); - // V12 - const BOPTools_Pave& aPave12=aPB.Pave2(); - nV12=aPave12.Index(); - const TopoDS_Vertex& aV12=TopoDS::Vertex(myDS->GetShape(nV12)); - aT12=aPave12.Param(); - // - const BOPTools_ListOfPaveBlock& aLPB=aFFi.PaveBlocks(); - BOPTools_ListIteratorOfListOfPaveBlock anIt(aLPB); - for (; anIt.More(); anIt.Next()) { - - iCount=0; - - const BOPTools_PaveBlock& aPBR=anIt.Value(); - // V21 - const BOPTools_Pave& aPave21=aPBR.Pave1(); - nV21=aPave21.Index(); - const TopoDS_Vertex& aV21=TopoDS::Vertex(myDS->GetShape(nV21)); - // V22 - const BOPTools_Pave& aPave22=aPBR.Pave2(); - nV22=aPave22.Index(); - const TopoDS_Vertex& aV22=TopoDS::Vertex(myDS->GetShape(nV22)); - // E2 - nE2=aPBR.Edge(); - const TopoDS_Edge& aE2=TopoDS::Edge(myDS->GetShape(nE2)); - // - // VV - iV=0; - iVV=IntTools_Tools::ComputeVV (aV11, aV21); - if (!iVV) { - iCount++; - iV++; - if (iCount>iCountExt) { - break; - } - } - - iVV=IntTools_Tools::ComputeVV (aV11, aV22); - if (!iVV) { - iCount++; - iV++; - if (iCount>iCountExt) { - break; - } - } - - // VE - if (!iV) { - iVE=myContext->ComputeVE (aV11, aE2, aTE); - if (!iVE) { - iCount++; - if (iCount>iCountExt) { - break; - } - } - } - // - // VV - iV=0; - iVV=IntTools_Tools::ComputeVV (aV12, aV21); - if (!iVV) { - iCount++; - iV++; - if (iCount>iCountExt) { - break; - } - } - - iVV=IntTools_Tools::ComputeVV (aV12, aV22); - if (!iVV) { - iCount++; - iV++; - if (iCount>iCountExt) { - break; - } - } - // VE - if (!iV) { - // - iVE=myContext->ComputeVE (aV12, aE2, aTE); - // - if (!iVE) { - iCount++; - if (iCount>iCountExt) { - break; - } - } - } - - } // next aPBR - return (iCount>iCountExt); -} -//======================================================================= -// function: CheckIntermediatePoint -// purpose: -//======================================================================= - Standard_Integer BOPTools_PaveFiller::CheckIntermediatePoint(const BOPTools_PaveBlock& aPB, - const BOPTools_PaveBlock& aPBR, - const Standard_Real aTolC) - -{ - Standard_Real aT11, aT12, aTM, aTmp; - Standard_Integer iVM, nE2; - - gp_Pnt aPM; - BRep_Builder aBB; - TopoDS_Vertex aVM; - // - // Vertex - const BOPTools_Pave& aPave11=aPB.Pave1(); - aT11=aPave11.Param(); - // - const BOPTools_Pave& aPave12=aPB.Pave2(); - aT12=aPave12.Param(); - // - aTM=IntTools_Tools::IntermediatePoint (aT11, aT12); - // - const IntTools_Curve& aIC=aPB.Curve(); - aIC.D0(aTM, aPM); - // - aBB.MakeVertex (aVM, aPM, aTolC); - // - //Edge - nE2=aPBR.Edge(); - const TopoDS_Edge& aE2=TopoDS::Edge(myDS->GetShape(nE2)); - // VE - iVM=myContext->ComputeVE(aVM, aE2, aTmp); - // - return iVM; -} -//======================================================================= -// function: PutBoundPaveOnCurve -// purpose: -//======================================================================= - void BOPTools_PaveFiller::PutBoundPaveOnCurve(BOPTools_Curve& aBC, - BOPTools_SSInterference& aFFi) -{ - Standard_Boolean bHasBounds, bVF; - - - const IntTools_Curve& aIC=aBC.Curve(); - bHasBounds=aIC.HasBounds (); - - if (!bHasBounds){ - return; - } - - Standard_Integer nF1, nF2; - Standard_Real aT1, aT2, aTolR3D; - gp_Pnt aP1, aP2; - // - // Bounds - aIC.Bounds (aT1, aT2, aP1, aP2); - // - // Faces - nF1=aFFi.Index1(); - nF2=aFFi.Index2(); - // - aTolR3D=aFFi.TolR3D(); - // - TopoDS_Face aF1=TopoDS::Face(myDS->GetShape(nF1)); - TopoDS_Face aF2=TopoDS::Face(myDS->GetShape(nF2)); - // - bVF=myContext->IsValidPointForFaces (aP1, aF1, aF2, aTolR3D); - // - if (bVF) { - PutBoundPaveOnCurve (aP1, aT1, aBC, aFFi); - } - // - bVF=myContext->IsValidPointForFaces (aP2, aF1, aF2, aTolR3D); - // - if (bVF) { - PutBoundPaveOnCurve (aP2, aT2, aBC, aFFi); - } -} -//======================================================================= -// function: PutBoundPaveOnCurve -// purpose: -//======================================================================= - void BOPTools_PaveFiller::PutBoundPaveOnCurve(const gp_Pnt& aP, - const Standard_Real aT, - BOPTools_Curve& aBC, - BOPTools_SSInterference& aFFi) -{ - Standard_Boolean bFound1, bFound2; - Standard_Integer nV; - Standard_Real aTolV=aFFi.TolR3D(); - - BOPTools_Pave aPave1, aPave2, aPave; - BOPTools_PaveSet& aCPS=aBC.Set(); - BOPTools_PaveSet& aFFiPS=aFFi.NewPaveSet(); - const IntTools_Curve& aIC=aBC.Curve(); - - bFound1=FindPave(aP, aTolV, aCPS , aPave1); - bFound2=FindPave(aP, aTolV, aFFiPS, aPave2); - - if (!bFound1 && !bFound2) { - TopoDS_Vertex aNewVertex; - BOPTools_Tools::MakeNewVertex(aP, aTolV, aNewVertex); - // - BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq; - myDS->InsertShapeAndAncestorsSuccessors(aNewVertex, anASSeq); - nV=myDS->NumberOfInsertedShapes(); - aPave.SetIndex(nV); - aPave.SetParam(aT); - - aCPS.Append(aPave); - aFFiPS.Append(aPave); - // - // Append Techno Vertex to the Curve - TColStd_ListOfInteger& aTVs=aBC.TechnoVertices(); - aTVs.Append(nV); - } - - if (bFound1 && !bFound2) { - nV=aPave1.Index(); - aPave.SetIndex(nV); - aPave.SetParam(aT); - aFFiPS.Append(aPave); - // - const TopoDS_Vertex& aV=TopoDS::Vertex(myDS->Shape(nV)); - BOPTools_Tools::UpdateVertex (aIC, aT, aV); - } - - if (!bFound1 && bFound2) { - nV=aPave2.Index(); - aPave.SetIndex(nV); - aPave.SetParam(aT); - aCPS.Append(aPave); - // - const TopoDS_Vertex& aV=TopoDS::Vertex(myDS->Shape(nV)); - BOPTools_Tools::UpdateVertex (aIC, aT, aV); - } -} - -//======================================================================= -// function: PutBoundPaveOnCurveSpec -// purpose: -//======================================================================= - void BOPTools_PaveFiller::PutBoundPaveOnCurveSpec(BOPTools_Curve& aBC, - BOPTools_SSInterference& aFFi) -{ - Standard_Boolean bHasBounds, bVF; - - - const IntTools_Curve& aIC=aBC.Curve(); - bHasBounds=aIC.HasBounds (); - - if (!bHasBounds){ - return; - } - - Standard_Integer nF1, nF2; - Standard_Real aT1, aT2, aTolR3D; - gp_Pnt aP1, aP2; - // - // Bounds - aIC.Bounds (aT1, aT2, aP1, aP2); - // - // Faces - nF1=aFFi.Index1(); - nF2=aFFi.Index2(); - // - aTolR3D=aFFi.TolR3D(); - // - TopoDS_Face aF1=TopoDS::Face(myDS->GetShape(nF1)); - TopoDS_Face aF2=TopoDS::Face(myDS->GetShape(nF2)); - // - bVF=myContext->IsValidPointForFaces (aP1, aF1, aF2, aTolR3D); - // - if (bVF) { - PutBoundPaveOnCurveSpec (aP1, aT1, aBC, aFFi); - } - // - bVF=myContext->IsValidPointForFaces (aP2, aF1, aF2, aTolR3D); - // - if (bVF) { - PutBoundPaveOnCurveSpec (aP2, aT2, aBC, aFFi); - } -} -//======================================================================= -// function: PutBoundPaveOnCurveSpec -// purpose: -//======================================================================= - void BOPTools_PaveFiller::PutBoundPaveOnCurveSpec(const gp_Pnt& aP, - const Standard_Real aT, - BOPTools_Curve& aBC, - BOPTools_SSInterference& aFFi) -{ - Standard_Boolean bFound1, bFound2; - Standard_Integer nV; - Standard_Real aTolV=aFFi.TolR3D(); - - BOPTools_Pave aPave1, aPave2, aPave; - BOPTools_PaveSet& aCPS=aBC.Set(); - BOPTools_PaveSet& aFFiPS=aFFi.NewPaveSet(); - const IntTools_Curve& aIC=aBC.Curve(); - - bFound1=FindPave(aP, aTolV, aCPS , aPave1); - bFound2=FindPave(aP, aTolV, aFFiPS, aPave2); - - if (!bFound1 && !bFound2) { - TopoDS_Vertex aNewVertex; - BOPTools_Tools::MakeNewVertex(aP, aTolV, aNewVertex); - // - BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq; - myDS->InsertShapeAndAncestorsSuccessors(aNewVertex, anASSeq); - nV=myDS->NumberOfInsertedShapes(); - aPave.SetIndex(nV); - aPave.SetParam(aT); - - aCPS.Append(aPave); - aFFiPS.Append(aPave); - // - // Append Techno Vertex to the Curve - TColStd_ListOfInteger& aTVs=aBC.TechnoVertices(); - aTVs.Append(nV); - // - //To check, if face boundary must be split by new vertex - TopTools_MapOfShape aMap; - Standard_Real aPar; - Standard_Integer anErrStat; - Standard_Integer aWhat, aWith, anIndexIn; - BOPTools_CArray1OfVEInterference& aVEs=myIntrPool->VEInterferences(); - // Faces - Standard_Integer nF1=aFFi.Index1(); - const TopoDS_Shape aF1 = myDS->GetShape(nF1); - // - Standard_Integer nF2=aFFi.Index2(); - const TopoDS_Shape aF2 = myDS->GetShape(nF2); - // - // - Standard_Integer aRank = myDS->Rank(nF1); - TopExp_Explorer anExp(aF1, TopAbs_EDGE); - for(; anExp.More(); anExp.Next()) { - - const TopoDS_Shape& anE = anExp.Current(); - if (BRep_Tool::Degenerated(TopoDS::Edge(anE))){ - continue; - } - - if(!aMap.Add(anE)) continue; - - anErrStat = - myContext->ComputeVE(aNewVertex, TopoDS::Edge(anE), aPar); - if(anErrStat) continue; - // - Standard_Real aT1, aT2; - gp_Pnt aP1, aP2; - aIC.Bounds(aT1, aT2, aP1, aP2); - //Check if any other point on curve belongs edge - aT1 = 0.5*(aT1+aT2); - aIC.D0(aT1, aP1); - TopoDS_Vertex aNewVertex1; - BOPTools_Tools::MakeNewVertex(aP1, aTolV, aNewVertex1); - anErrStat = - myContext->ComputeVE(aNewVertex1, TopoDS::Edge(anE), aT1); - if(!anErrStat) continue; //curve and edge seem to be coincide - - aWhat = nV; - aWith = myDS->ShapeIndex(anE, aRank); - BOPTools_VEInterference anInterf (aWhat, aWith, aPar); - anIndexIn=aVEs.Append(anInterf); - // - // Add Pave to the Edge's myPavePool - BOPTools_Pave aPave3(aWhat, aPar, BooleanOperations_VertexEdge); - aPave3.SetInterference(anIndexIn); - BOPTools_PaveSet& aPaveSet= myPavePool(myDS->RefEdge(aWith)); - aPaveSet.Append(aPave3); - - // - // State for the Vertex in DS; - myDS->SetState (aWhat, BooleanOperations_ON); - // Insert Vertex in Interference Object - BOPTools_VEInterference& aVE=aVEs(anIndexIn); - aVE.SetNewShape(aWhat); - - PreparePaveBlocks(aWith); - RecomputeCommonBlocks(aWith); - } - // - aRank = myDS->Rank(nF2); - anExp.Init(aF2, TopAbs_EDGE); - for(; anExp.More(); anExp.Next()) { - const TopoDS_Shape& anE = anExp.Current(); - if (BRep_Tool::Degenerated(TopoDS::Edge(anE))){ - continue; - } - - if(!aMap.Add(anE)) continue; - - anErrStat = - myContext->ComputeVE(aNewVertex, TopoDS::Edge(anE), aPar); - if(anErrStat) continue; - // - Standard_Real aT1, aT2; - gp_Pnt aP1, aP2; - aIC.Bounds(aT1, aT2, aP1, aP2); - //Check if any other point on curve belongs edge - aT1 = 0.5*(aT1+aT2); - aIC.D0(aT1, aP1); - TopoDS_Vertex aNewVertex1; - BOPTools_Tools::MakeNewVertex(aP1, aTolV, aNewVertex1); - anErrStat = - myContext->ComputeVE(aNewVertex1, TopoDS::Edge(anE), aT1); - if(!anErrStat) continue; //curve and edge seem to be coincide - - aWhat = nV; - aWith = myDS->ShapeIndex(anE, aRank); - BOPTools_VEInterference anInterf (aWhat, aWith, aPar); - anIndexIn=aVEs.Append(anInterf); - // - // Add Pave to the Edge's myPavePool - BOPTools_Pave aPave3(aWhat, aPar, BooleanOperations_VertexEdge); - aPave3.SetInterference(anIndexIn); - BOPTools_PaveSet& aPaveSet= myPavePool(myDS->RefEdge(aWith)); - aPaveSet.Append(aPave3); - - // - // State for the Vertex in DS; - myDS->SetState (aWhat, BooleanOperations_ON); - // Insert Vertex in Interference Object - BOPTools_VEInterference& aVE=aVEs(anIndexIn); - aVE.SetNewShape(aWhat); - - PreparePaveBlocks(aWith); - RecomputeCommonBlocks(aWith); - } - // - } - - if (bFound1 && !bFound2) { - nV=aPave1.Index(); - aPave.SetIndex(nV); - aPave.SetParam(aT); - aFFiPS.Append(aPave); - // - const TopoDS_Vertex& aV=TopoDS::Vertex(myDS->Shape(nV)); - BOPTools_Tools::UpdateVertex (aIC, aT, aV); - } - - if (!bFound1 && bFound2) { - nV=aPave2.Index(); - aPave.SetIndex(nV); - aPave.SetParam(aT); - aCPS.Append(aPave); - // - const TopoDS_Vertex& aV=TopoDS::Vertex(myDS->Shape(nV)); - BOPTools_Tools::UpdateVertex (aIC, aT, aV); - } -} -//======================================================================= -// function: FindPave -// purpose: -//======================================================================= - Standard_Boolean BOPTools_PaveFiller::FindPave(const gp_Pnt& aP, - const Standard_Real aTolPV, - const BOPTools_PaveSet& aPS, - BOPTools_Pave& aPave) -{ - Standard_Integer nV; - Standard_Boolean bIsVertex=Standard_False; - - const BOPTools_ListOfPave& aLP=aPS.Set(); - BOPTools_ListIteratorOfListOfPave anIt(aLP); - for (; anIt.More(); anIt.Next()) { - const BOPTools_Pave& aPC=anIt.Value(); - nV=aPC.Index(); - const TopoDS_Vertex& aV=TopoDS::Vertex(myDS->GetShape(nV)); - bIsVertex=IntTools_Tools::IsVertex (aP, aTolPV, aV); - if (bIsVertex) { - aPave=aPC; - return bIsVertex; - } - } - return bIsVertex; -} -//======================================================================= -// function: MakeSectionEdges -// purpose: -//======================================================================= - void BOPTools_PaveFiller::MakeSectionEdges() -{ - Standard_Integer i, j, aNbCurves, aNbFFs, nF1, nF2, nV1, nV2, aNbPaveBlocks, - aNewShapeIndex ; - Standard_Real t1, t2; - TopoDS_Edge aESect; - TopoDS_Vertex aV1, aV2; - BRep_Builder BB; - - Standard_Integer pbi = 0; - - - BOPTools_CArray1OfSSInterference& aFFs=myIntrPool->SSInterferences(); - - aNbFFs=aFFs.Extent(); - for (i=1; i<=aNbFFs; i++) { - BOPTools_SSInterference& aFFi=aFFs(i); - nF1=aFFi.Index1(); - nF2=aFFi.Index2(); - // - Standard_Real aTF = 1.e-7; - TopoDS_Face aF1=TopoDS::Face(myDS->GetShape(nF1)); - TopoDS_Face aF2=TopoDS::Face(myDS->GetShape(nF2)); - Standard_Boolean isModT = ModifFFTol(aF1,aF2,aTF); - Standard_Real aTolFF = (isModT) ? Max(aTF,aFFi.TolR3D()) : aFFi.TolR3D(); - BOPTools_ListOfPaveBlock aFFPBL; - TopTools_ListOfShape aFFSEL; - // - BOPTools_SequenceOfCurves& aSCvs=aFFi.Curves(); - aNbCurves=aSCvs.Length(); - for (j=1; j<=aNbCurves; j++) { - BOPTools_Curve& aBC=aSCvs(j); - const IntTools_Curve& aIC=aBC.Curve(); - // - const BOPTools_ListOfPaveBlock& aSectEdges=aBC.NewPaveBlocks(); - aNbPaveBlocks=aSectEdges.Extent(); - BOPTools_ListIteratorOfListOfPaveBlock aPBIt(aSectEdges); - pbi = 0; - for (; aPBIt.More(); aPBIt.Next()) { - pbi++; - BOPTools_PaveBlock& aPB=aPBIt.Value(); - // - // Pave1 - const BOPTools_Pave& aPave1=aPB.Pave1(); - nV1=aPave1.Index(); - t1=aPave1.Param(); - aV1=TopoDS::Vertex(myDS->GetShape(nV1)); - aV1.Orientation(TopAbs_FORWARD); - // - // Pave2 - const BOPTools_Pave& aPave2=aPB.Pave2(); - nV2=aPave2.Index(); - t2=aPave2.Param(); - aV2=TopoDS::Vertex(myDS->GetShape(nV2)); - aV2.Orientation(TopAbs_REVERSED); - // - // MakeSplitEdge - // - // reject building parallel sect. edge on the same pave block, - // if distance between created and this edges is too small - if(IsPaveBlock(nV1,nV2,aFFPBL)) { - Standard_Real diffTol = 1.e-7; - Standard_Integer eI = RejectBuildingEdge(aIC,aV1,aV2,t1,t2,aFFSEL,diffTol); - if(eI != 0) { - Standard_Integer eIndex = 0; - TopTools_ListIteratorOfListOfShape aSEIt(aFFSEL); - for(; aSEIt.More(); aSEIt.Next()) { - eIndex++; - if(eIndex == eI) { - const TopoDS_Edge & aE = TopoDS::Edge(aSEIt.Value()); - TopoDS_Edge& anEdge = (TopoDS_Edge &) aE; - BOPTools_ListOfPaveBlock& aListPB = (BOPTools_ListOfPaveBlock&) aSectEdges; - aListPB.Remove(aPBIt); - BB.UpdateEdge( anEdge, 2*(aTolFF+diffTol) ); - BB.UpdateVertex( aV1, 2*(aTolFF+diffTol) ); - BB.UpdateVertex( aV2, 2*(aTolFF+diffTol) ); - break; - } - } - if(aPBIt.More()) - continue; - else - break; - } - } - - if(fabs(t1-t2) <= 1.e-10) continue; - BOPTools_Tools::MakeSectEdge (aIC, aV1, t1, aV2, t2, aESect); - // - BB.UpdateEdge( aESect, aTolFF ); - BB.UpdateVertex( aV1, aTolFF ); - BB.UpdateVertex( aV2, aTolFF ); - /////////////////////////////////// - // Add Sect Part to the DS - BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq; - - anASSeq.SetNewSuccessor(nV1); - anASSeq.SetNewOrientation(aV1.Orientation()); - - anASSeq.SetNewSuccessor(nV2); - anASSeq.SetNewOrientation(aV2.Orientation()); - // - myDS->InsertShapeAndAncestorsSuccessors(aESect, anASSeq); - aNewShapeIndex=myDS->NumberOfInsertedShapes(); - // - aPB.SetEdge(aNewShapeIndex); - // - aFFSEL.Append(aESect); - aFFPBL.Append(aPB); - } - } - } - -} -//======================================================================= -// function: PutPaveOnCurve -// purpose: -//======================================================================= - void BOPTools_PaveFiller::PutPaveOnCurve(const BOPTools_PaveSet& aPaveSet, - const Standard_Real aTolR3D, - BOPTools_Curve& aBC) -{ - const BOPTools_ListOfPave& aLP=aPaveSet.Set(); - BOPTools_ListIteratorOfListOfPave anIt(aLP); - for (; anIt.More(); anIt.Next()) { - const BOPTools_Pave& aPave=anIt.Value(); - PutPaveOnCurve (aPave, aTolR3D, aBC); - } -} -//======================================================================= -// function: PutPaveOnCurve -// purpose: -//======================================================================= - void BOPTools_PaveFiller::PutPaveOnCurve (const BOPTools_Pave& aPave, - const Standard_Real aTolR3D, - BOPTools_Curve& aBC) -{ - Standard_Integer nV; - Standard_Boolean bIsVertexOnLine; - Standard_Real aT, aTolVExt, aTolTresh; - BRep_Builder aBB; - // - aTolTresh=0.01; - nV=aPave.Index(); - const TopoDS_Vertex& aV=TopoDS::Vertex(myDS->Shape(nV)); - const IntTools_Curve& aC=aBC.Curve(); - Handle (Geom_Curve) aC3D= aC.Curve(); - // - aTolVExt=BRep_Tool::Tolerance(aV); - ExtendedTolerance(nV, aTolVExt); - bIsVertexOnLine=myContext->IsVertexOnLine(aV, aTolVExt, aC, aTolR3D, aT); - // - if (bIsVertexOnLine) { - BOPTools_Pave aPaveNew(nV, aT, BooleanOperations_SurfaceSurface); - BOPTools_PaveSet& aPaveSet=aBC.Set(); - aPaveSet.Append(aPaveNew); - //<-B - BOPTools_Tools::UpdateVertex (aC, aT, aV); - if(aTolR3DIsNewShape(nV); - if (!bIsNewShape) { - return bFound; - } - // - aV=TopoDS::Vertex(myDS->Shape(nV)); - aPV=BRep_Tool::Pnt(aV); - // - const BOPTools_InterferencePool& anInterferencePool=*myIntrPool; - const BOPTools_CArray1OfEEInterference& aEEInterfs=anInterferencePool.EEInterfs(); - const BOPTools_CArray1OfESInterference& aESInterfs=anInterferencePool.ESInterfs(); - // - for (k=0; k<2; ++k) { - aNbLines=(!k) ? aEEInterfs.Extent() : aESInterfs.Extent(); - for (i=1; i<=aNbLines; ++i) { - BOPTools_ShapeShapeInterference *pI=(!k) ? - (BOPTools_ShapeShapeInterference *)&aEEInterfs(i): - (BOPTools_ShapeShapeInterference *)&aESInterfs(i); - // - aNewShape=pI->NewShape(); - if (aNewShape==nV) { - const IntTools_CommonPrt& aCPart=(!k) ? - aEEInterfs(i).CommonPrt() : - aESInterfs(i).CommonPrt(); - // - const TopoDS_Edge& aE1=aCPart.Edge1(); - aCPart.Range1(aT11, aT12); - BOPTools_Tools::PointOnEdge(aE1, aT11, aP11); - BOPTools_Tools::PointOnEdge(aE1, aT12, aP12); - aD1=aPV.Distance(aP11); - aD2=aPV.Distance(aP12); - aD=(aD1>aD2)? aD1 : aD2; - if (aD>aTolVExt) { - aTolVExt=aD; - } - bFound=!bFound; - return bFound; - } - } - } - // - return bFound; -} -// -//======================================================================= -// function: PutPavesOnCurves -// purpose: -//======================================================================= - void BOPTools_PaveFiller::PutPavesOnCurves () -{ - Standard_Integer i, j, aNbCurves, aNbFFs, nF1, nF2, nV; - Standard_Real aTolR3D = 0.; - - BOPTools_CArray1OfSSInterference& aFFs=myIntrPool->SSInterferences(); - - aNbFFs=aFFs.Extent(); - - for (i=1; i<=aNbFFs; i++) { - BOPTools_SSInterference& aFFi=aFFs(i); - // - // Curves' tolerance - aTolR3D=aFFi.TolR3D(); - // - // Faces - nF1=aFFi.Index1(); - nF2=aFFi.Index2(); - - // - // Put existing paves on curves - BOPTools_PaveSet aPSF; - PrepareSetForFace (nF1, nF2, aPSF); - // - //f - { - Standard_Integer nVX; - BOPTools_ListIteratorOfListOfPave aItLP; - TColStd_MapOfInteger aMVStick; - // - const BOPTools_ListOfPave& aLPX=aPSF.Set(); - aItLP.Initialize(aLPX); - for (; aItLP.More(); aItLP.Next()) { - const BOPTools_Pave& aPX=aItLP.Value(); - nVX=aPX.Index(); - aMVStick.Add(nVX); - } - // - CorrectTolR3D(*this, aFFi, aMVStick, aTolR3D); - } - //t - // - BOPTools_SequenceOfCurves& aSCvs=aFFi.Curves(); - aNbCurves=aSCvs.Length(); - for (j=1; j<=aNbCurves; j++) { - BOPTools_Curve& aBC=aSCvs(j); - // DEBUG - const IntTools_Curve& aC=aBC.Curve(); - Handle (Geom_Curve) aC3D= aC.Curve(); - // - PutPaveOnCurve (aPSF, aTolR3D, aBC); - } - //f - { - Standard_Integer aNbVtx, jx; - Standard_Real aTolVRange; - TColStd_SequenceOfInteger aSeqVx; - TColStd_SequenceOfReal aSeqTolVx; - // - ProcessAloneStickVertices(nF1, - nF2, - aPSF, - aSCvs, - *this, - aSeqVx, - aSeqTolVx); - // - aNbVtx=aSeqVx.Length(); - for (jx=1; jx<=aNbVtx; ++jx) { - BOPTools_PaveSet aPSFx; - BOPTools_Pave aPVx; - - nV=aSeqVx(jx); - aTolVRange=aSeqTolVx(jx); - - aPVx.SetIndex(nV); - aPSFx.Append(aPVx); - - for (j=1; j<=aNbCurves; j++) { - BOPTools_Curve& aBC=aSCvs(j); - // DEBUG - const IntTools_Curve& aC=aBC.Curve(); - Handle (Geom_Curve) aC3D= aC.Curve(); - // - PutPaveOnCurve (aPSFx, aTolVRange, aBC); - } - } - } - //t - // - // Put bounding paves on curves - //Check very specific case of cone-cone intersection (OCC13211) - - Standard_Boolean bIsSpecific = Standard_False; - if(aNbCurves >= 4) { - const TopoDS_Shape aF1 = myDS->GetShape(nF1); - BRepAdaptor_Surface aS1(TopoDS::Face(aF1), Standard_False); - GeomAbs_SurfaceType aSType = aS1.GetType(); - if(aSType == GeomAbs_Cone) { - const TopoDS_Shape aF2 = myDS->GetShape(nF2); - BRepAdaptor_Surface aS2(TopoDS::Face(aF2), Standard_False); - aSType = aS2.GetType(); - if(aSType == GeomAbs_Cone) { - bIsSpecific = Standard_True; - } - } - } - // - if(bIsSpecific) { - for (j=1; j<=aNbCurves; j++) { - BOPTools_Curve& aBC=aSCvs(j); - PutBoundPaveOnCurveSpec (aBC, aFFi); - } - } - else { - for (j=1; j<=aNbCurves; j++) { - BOPTools_Curve& aBC=aSCvs(j); - PutBoundPaveOnCurve (aBC, aFFi); - } - } - // - // Put closing pave if needded - for (j=1; j<=aNbCurves; ++j) { - BOPTools_Curve& aBC=aSCvs(j); - PutClosingPaveOnCurve (aBC, aFFi); - } - // - // xxx - for (j=1; j<=aNbCurves; j++) { - BOPTools_Curve& aBC=aSCvs(j); - BOPTools_ListOfPave anOldList; - anOldList = aBC.Set().Set(); - - if (aBC.NewPaveBlocks().IsEmpty()) { - continue; - } - // - - BOPTools_CArray1OfESInterference& aESs = myIntrPool->ESInterferences(); - Standard_Integer k, fit; - // - // Among all aESs find those that are between nE1 from nF1(nE2 from nF2) and nF2(nF1) - for(k = 1; k <= aESs.Length(); k++) { - BOPTools_ESInterference& aES = aESs(k); - - if(aES.Index1() == nF1 || aES.Index2() == nF2) { - Standard_Integer nE = (aES.Index1() == nF1) ? aES.Index2() : aES.Index1(); - - // check if it belongs to F1 or F2.begin - Standard_Boolean edgefound = Standard_False; - - for(fit = 0; !edgefound && (fit < 2); fit++) { - Standard_Integer nF = (fit == 0) ? nF1 : nF2; - Standard_Integer sit1 = 0, sit2 = 0; - - for(sit1 = 1; !edgefound && (sit1 <= myDS->NumberOfSuccessors(nF)); sit1++) { - Standard_Integer asuccessor = myDS->GetSuccessor(nF, sit1); - - for(sit2 = 1; sit2 <= myDS->NumberOfSuccessors(asuccessor); sit2++) { - if(nE == myDS->GetSuccessor(asuccessor, sit2)) { - edgefound = Standard_True; - break; - } - } - } - } - // check if it belongs to F1 or F2.end - - if(edgefound) { - RestrictCurveIn2d (nE, nF1, nF2, aTolR3D, aBC);// -> - } - } - }// for(k = 1; k <= aESs.Length(); k++) - - for(fit = 1; fit <= 2; fit++) { - Standard_Integer nF = (fit == 1) ? nF1 : nF2; - Standard_Integer nFOpposite = (fit == 1) ? nF2 : nF1; - TopExp_Explorer anExp(myDS->Shape(nF), TopAbs_EDGE); - - for(; anExp.More(); anExp.Next()) { - Standard_Integer nE = myDS->ShapeIndex(anExp.Current(), fit); - - if(nE) { - const BOPTools_ListOfInterference& aList = - myIntrPool->InterferenceTable().Value(nE).GetOnType(BooleanOperations_EdgeSurface); - BOPTools_ListIteratorOfListOfInterference anIt2(aList); - Standard_Boolean bProcessed = Standard_False; - - for(; anIt2.More(); anIt2.Next()) { - if(anIt2.Value().With() == nFOpposite) { - if(!bProcessed) { - RestrictCurveIn2d (nE, nF1, nF2, aTolR3D, aBC); - bProcessed = Standard_True; - break; - } - } - } - - if(!myCommonBlockPool(myDS->RefEdge(nE)).IsEmpty() && - !bProcessed) { - RestrictCurveIn2d (nE, nF1, nF2, aTolR3D, aBC); - } - } - } - } - // end for(fit = 1... - - // put new paves on other curves.begin - BOPTools_ListOfPave aListOfNewPave; - BOPTools_ListIteratorOfListOfPave anIt1, anIt2; - - for(anIt1.Initialize(aBC.Set().Set()); anIt1.More(); anIt1.Next()) { - Standard_Boolean bfound = Standard_False; - for(anIt2.Initialize(anOldList); anIt2.More(); anIt2.Next()) { - if(anIt1.Value().IsEqual(anIt2.Value())) { - bfound = Standard_True; - break; - } - } - - if(!bfound) { - aListOfNewPave.Append(anIt1.Value()); - } - } - - Standard_Integer m = 0, n = 0; - for (m=1; m<=aNbFFs; m++) { - BOPTools_SSInterference& aFFm = aFFs(m); - // - // Curves' tolerance - Standard_Real aTolR3D2 = aFFm.TolR3D(); - - BOPTools_SequenceOfCurves& aSCvs2 = aFFm.Curves(); - Standard_Integer aNbCurves2 = aSCvs2.Length(); - - for(n = 1; n <= aNbCurves2; n++) { - if((n == j) && (m == i)) - continue; - BOPTools_Curve& aBC2 = aSCvs2(n); - - for(anIt1.Initialize(aListOfNewPave); anIt1.More(); anIt1.Next()) { - Standard_Boolean bfound = Standard_False; - for(anIt2.Initialize(aBC2.Set().Set()); anIt2.More(); anIt2.Next()) { - if(anIt1.Value().Index() == anIt2.Value().Index()) { - bfound = Standard_True; - break; - } - } - - if(!bfound) { - PutPaveOnCurve (anIt1.Value(), aTolR3D2, aBC2); - } - } - } - } - // put new paves on other curves.end - } // xxx for (j=1; j<=aNbCurves; j++) - - //wkar OCC334 f - { - Standard_Integer aNbVtx, jx; - Standard_Real aTolVRange; - TColStd_SequenceOfInteger aSeqVx; - TColStd_SequenceOfReal aSeqTolVx; - // - ProcessAloneStickVertices(nF1, - nF2, - aPSF, - aSCvs, - *myIntrPool, - *this, - aSeqVx, - aSeqTolVx); - // - aNbVtx=aSeqVx.Length(); - for (jx=1; jx<=aNbVtx; ++jx) { - BOPTools_PaveSet aPSFx; - BOPTools_Pave aPVx; - - nV=aSeqVx(jx); - aTolVRange=aSeqTolVx(jx); - - aPVx.SetIndex(nV); - aPSFx.Append(aPVx); - - for (j=1; j<=aNbCurves; j++) { - BOPTools_Curve& aBC=aSCvs(j); - // DEBUG - const IntTools_Curve& aC=aBC.Curve(); - Handle (Geom_Curve) aC3D= aC.Curve(); - // - PutPaveOnCurve (aPSFx, aTolVRange, aBC); - } - } - } - //wkar OCC334 t - } -} -//======================================================================= -// function: PrepareSetForFace -// purpose: -//======================================================================= - void BOPTools_PaveFiller::PrepareSetForFace(const Standard_Integer nF1, - const Standard_Integer nF2, - BOPTools_PaveSet& aPaveSet) -{ - Standard_Integer i, aNbV, nV; - TColStd_IndexedMapOfInteger aMV; - // - StickVertices(nF1, nF2, aMV); - // - aNbV=aMV.Extent(); - for (i=1; i<=aNbV; ++i) { - nV=aMV(i); - BOPTools_Pave aPV; - aPV.SetIndex(nV); - aPaveSet.Append(aPV); - } -} -//======================================================================= -// function: IsPaveBlock -// purpose: -//======================================================================= -Standard_Boolean IsPaveBlock(const Standard_Integer nV1, - const Standard_Integer nV2, - const BOPTools_ListOfPaveBlock& aLPBExisting) -{ - Standard_Boolean bFlag=Standard_True; - Standard_Integer nVE1, nVE2; - - BOPTools_ListIteratorOfListOfPaveBlock anIt(aLPBExisting); - for (; anIt.More(); anIt.Next()) { - const BOPTools_PaveBlock& aPBR=anIt.Value(); - // - nVE1=aPBR.Pave1().Index(); - // - nVE2=aPBR.Pave2().Index(); - // - if ((nVE1==nV1 && nVE2==nV2) || (nVE2==nV1 && nVE1==nV2)) { - return bFlag; - } - } - return !bFlag; -} - -//======================================================================= -// function: FMapWhat -// purpose: -//======================================================================= - void FMapWhat(const Standard_Integer nF, - BOPTools_InterferencePool* myIntrPool, - TColStd_IndexedMapOfInteger& aMapWhat) - -{ - Standard_Integer nE, nV; - - - - BooleanOperations_ShapesDataStructure* myDS=myIntrPool->DS(); - BooleanOperations_OnceExplorer aExp(*myDS); - // - // What - aMapWhat.Add(nF); - aExp.Init(nF, TopAbs_VERTEX); - for (; aExp.More(); aExp.Next()) { - nV=aExp.Current(); - aMapWhat.Add(nV); - } - // - aExp.Init(nF, TopAbs_EDGE); - for (; aExp.More(); aExp.Next()) { - nE=aExp.Current(); - aMapWhat.Add(nE); - } -} - -//======================================================================= -// function: FMapWith -// purpose: -//======================================================================= - void FMapWith(const Standard_Integer nF, - BOPTools_InterferencePool* myIntrPool, - TColStd_IndexedMapOfInteger& aMapWith) -{ - TColStd_IndexedMapOfInteger aMapWhat; - - FMapWhat(nF, myIntrPool, aMapWhat); - // - // With - Standard_Integer i, aNb, anIndex, aWhat, aWith; - BOPTools_ListIteratorOfListOfInterference anIt; - - const BOPTools_CArray1OfInterferenceLine& anArrIL= myIntrPool->InterferenceTable(); - - aNb=aMapWhat.Extent(); - for (i=1; i<=aNb; i++) { - aWhat=aMapWhat(i); - - const BOPTools_InterferenceLine& aWithLine=anArrIL(aWhat); - - const BOPTools_ListOfInterference& aLI=aWithLine.List(); - anIt.Initialize(aLI); - for (; anIt.More(); anIt.Next()) { - const BOPTools_Interference& anIntf=anIt.Value(); - anIndex=anIntf.Index(); - if (anIndex) { - aWith=anIntf.With(); - aMapWith.Add(aWith); - } - } - } -} - -//======================================================================= -// function: IsFound -// purpose: -//======================================================================= -Standard_Boolean IsFound(const TColStd_IndexedMapOfInteger& aMapWhat, - const TColStd_IndexedMapOfInteger& aMapWith) -{ - Standard_Boolean bFlag=Standard_False; - Standard_Integer i, aNb, aWhat; - - aNb=aMapWhat.Extent(); - for (i=1; i<=aNb; i++) { - aWhat=aMapWhat(i); - if (aMapWith.Contains(aWhat)) { - return !bFlag; - } - } - return bFlag; -} - - -//wkar OCC334 f -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//======================================================================= -// function: ProcessAloneStickVertices -// purpose: -//======================================================================= -void ProcessAloneStickVertices(const Standard_Integer nF1, - const Standard_Integer nF2, - const BOPTools_PaveSet& aPSF, - BOPTools_SequenceOfCurves& aSCvs, - const BOPTools_InterferencePool& anIntrPool, - BOPTools_PaveFiller& aPF, - TColStd_SequenceOfInteger& aSeqVx, - TColStd_SequenceOfReal& aSeqTolVx) -{ - Standard_Boolean bFound, bIsClosed; - Standard_Integer aNbVtx, jx, nV; - Standard_Real aTolVRange; - TColStd_IndexedMapOfInteger aMapUnUsed; - GeomAbs_SurfaceType aType1, aType2; - // - BooleanOperations_PShapesDataStructure pDS=anIntrPool.DS(); - // - const TopoDS_Face& aF1= TopoDS::Face(pDS->Shape(nF1)); - const TopoDS_Face& aF2= TopoDS::Face(pDS->Shape(nF2)); - Handle(Geom_Surface) aS1=BRep_Tool::Surface(aF1); - Handle(Geom_Surface) aS2=BRep_Tool::Surface(aF2); - GeomAdaptor_Surface aGAS1(aS1); - GeomAdaptor_Surface aGAS2(aS2); - - aType1=aGAS1.GetType(); - aType2=aGAS2.GetType(); - - if((aType1==GeomAbs_Cylinder && aType2==GeomAbs_Cylinder) - || - (aType1==GeomAbs_Plane && aType2==GeomAbs_Plane)) { - // - UnUsedMap(aSCvs, aPSF, aMapUnUsed); - // - aNbVtx=aMapUnUsed.Extent(); - for (jx=1; jx<=aNbVtx; ++jx) { - nV=aMapUnUsed(jx); - if (pDS->IsNewShape(nV)) { - bFound=VertexRangeTolerance(nV, nF1, nF2, anIntrPool, aTolVRange); - if (bFound) { - aSeqVx.Append(nV); - aSeqTolVx.Append(aTolVRange); - } - } - } - } - // - //wkar pkv/904/F7 - if((aType1==GeomAbs_Torus && aType2==GeomAbs_Plane) || - (aType1==GeomAbs_Plane && aType2==GeomAbs_Torus)) { - Standard_Integer aNbSCvs, aNbPoints; - Standard_Real aDist, aTolV; - gp_Pnt aPV; - // - UnUsedMap(aSCvs, aPSF, aMapUnUsed); - aNbVtx=aMapUnUsed.Extent(); - if (aNbVtx) { - const Handle(IntTools_Context)& aCtx=aPF.Context(); - // - aNbSCvs=aSCvs.Length(); - if (aNbSCvs==1) { - BOPTools_Curve& aBC=aSCvs(1); - const IntTools_Curve& aIC=aBC.Curve(); - Handle (Geom_Curve) aC3D= aIC.Curve(); - // - bIsClosed=IntTools_Tools::IsClosed(aC3D); - if (bIsClosed) { - return; - } - GeomAPI_ProjectPointOnCurve& aProjPT=aCtx->ProjPT(aC3D); - // - for (jx=1; jx<=aNbVtx; ++jx) { - nV=aMapUnUsed(jx); - if (pDS->IsNewShape(nV)) { - const TopoDS_Vertex& aV=*((TopoDS_Vertex*)&pDS->Shape(nV)); - aTolV=BRep_Tool::Tolerance(aV); - aPV=BRep_Tool::Pnt(aV); - // - aProjPT.Perform(aPV); - aNbPoints=aProjPT.NbPoints(); - if (aNbPoints) { - aDist=aProjPT.LowerDistance(); - aDist=(aDist>aTolV)? aDist : aTolV; - aSeqVx.Append(nV); - aSeqTolVx.Append(aDist); - } - } - } - } - } - } -} -//======================================================================= -// function: ProcessAloneStickVertices -// purpose: -//======================================================================= -void ProcessAloneStickVertices(const Standard_Integer nF1, - const Standard_Integer nF2, - const BOPTools_PaveSet& aPSF, - BOPTools_SequenceOfCurves& aSCvs, - BOPTools_PaveFiller& aPF, - TColStd_SequenceOfInteger& aSeqVx, - TColStd_SequenceOfReal& aSeqTolVx) -{ - GeomAbs_SurfaceType aType1, aType2; - // - BooleanOperations_PShapesDataStructure pDS=aPF.DS(); - // - const TopoDS_Face& aF1= TopoDS::Face(pDS->Shape(nF1)); - const TopoDS_Face& aF2= TopoDS::Face(pDS->Shape(nF2)); - Handle(Geom_Surface) aS1=BRep_Tool::Surface(aF1); - Handle(Geom_Surface) aS2=BRep_Tool::Surface(aF2); - GeomAdaptor_Surface aGAS1(aS1); - GeomAdaptor_Surface aGAS2(aS2); - // - aType1=aGAS1.GetType(); - aType2=aGAS2.GetType(); - // - if(aType1==GeomAbs_Torus || aType2==GeomAbs_Torus) { - Standard_Integer aNbSCvs, jVU, aNbVU, nVU, k, m, n; - Standard_Real aTC[2], aD, aD2, aDT2, aU, aV, aScPr, aDScPr; - TColStd_IndexedMapOfInteger aMVU; - GeomAbs_CurveType aTypeC; - gp_Pnt aPC[2], aPVU; - gp_Dir aDN[2]; - gp_Pnt2d aP2D; - - Handle(Geom2d_Curve) aC2D[2]; - // - aDT2=2e-7; // the rich criteria - aDScPr=5.e-9; // the creasing criteria - // - UnUsedMap(aSCvs, aPSF, aMVU); - // - aNbVU=aMVU.Extent(); - for (jVU=1; jVU<=aNbVU; ++jVU) { - nVU=aMVU(jVU); - const TopoDS_Vertex& aVU=*((TopoDS_Vertex*)&pDS->Shape(nVU)); - aPVU=BRep_Tool::Pnt(aVU); - // - aNbSCvs=aSCvs.Length(); - for (k=1; k<=aNbSCvs; ++k) { - BOPTools_Curve& aBC=aSCvs(k); - const IntTools_Curve& aIC=aBC.Curve(); - //Handle(Geom_Curve) aC3D=aIC.Curve(); //DEB - aTypeC=aIC.Type(); - if (!(aTypeC==GeomAbs_BezierCurve || aTypeC==GeomAbs_BSplineCurve)) { - continue; - } - // - aIC.Bounds(aTC[0], aTC[1], aPC[0], aPC[1]); - aC2D[0]=aIC.FirstCurve2d(); - aC2D[1]=aIC.SecondCurve2d(); - if (aC2D[0].IsNull() || aC2D[1].IsNull()) { - continue; - } - // - for (m=0; m<2; ++m) { - aD2=aPC[m].SquareDistance(aPVU); - if (aD2>aDT2) {// no rich - continue; - } - // - for (n=0; n<2; ++n) { - Handle(Geom_Surface)& aS=(!n)? aS1 : aS2; - aC2D[n]->D0(aTC[m], aP2D); - aP2D.Coord(aU, aV); - BOPTools_Tools3D::GetNormalToSurface(aS, aU, aV, aDN[n]); - } - // - aScPr=aDN[0]*aDN[1]; - if (aScPr<0.) { - aScPr=-aScPr; - } - aScPr=1.-aScPr; - // - if (aScPr>aDScPr) { - continue; - } - // - // The intersection curve aIC is vanishing curve (the crease) - aD=sqrt(aD2); - // - aSeqVx.Append(nVU); - aSeqTolVx.Append(aD); - } - }//for (k=1; k<=aNbSCvs; ++k) { - }//for (jVU=1; jVU=aNbVU; ++jVU) { - }//if(aType1==GeomAbs_Torus || aType2==GeomAbs_Torus) { -} -//======================================================================= -// function: UnUsedMap -// purpose: -//======================================================================= -void UnUsedMap(BOPTools_SequenceOfCurves& aSCvs, - const BOPTools_PaveSet& aPSF, - TColStd_IndexedMapOfInteger& aMapUnUsed) -{ - // - // What stick/non-stick vertices we used - TColStd_IndexedMapOfInteger aMapUsed, aMapMustBeUsed; - Standard_Integer j, aNbCurves, aNbVtx, nV1;//, nV2; - BOPTools_ListIteratorOfListOfPave anLPIt; - - aNbCurves=aSCvs.Length(); - for (j=1; j<=aNbCurves; ++j) { - BOPTools_Curve& aBC=aSCvs(j); - //const IntTools_Curve& aC= aBC.Curve();// Wng in Gcc 3.0 - - const BOPTools_PaveSet& aPaveSet=aBC.Set(); - const BOPTools_ListOfPave& aLPAlreadyUsed=aPaveSet.Set(); - anLPIt.Initialize(aLPAlreadyUsed); - for (; anLPIt.More(); anLPIt.Next()) { - const BOPTools_Pave& aPave=anLPIt.Value(); - nV1=aPave.Index(); - aMapUsed.Add(nV1); - } - } - // - // 2. Stick vertices that must be used - const BOPTools_ListOfPave& aLPMustUsed=aPSF.Set(); - anLPIt.Initialize(aLPMustUsed); - for (; anLPIt.More(); anLPIt.Next()) { - const BOPTools_Pave& aPave=anLPIt.Value(); - nV1=aPave.Index(); - aMapMustBeUsed.Add(nV1); - } - // - // 3.Unused Stick vertices . - aNbVtx=aMapMustBeUsed.Extent(); - for (j=1; j<=aNbVtx; ++j) { - nV1=aMapMustBeUsed(j); - if (!aMapUsed.Contains(nV1)) { - aMapUnUsed.Add(nV1); - } - } - // -} -//======================================================================= -// function: VertexRangeTolerance -// purpose: -//======================================================================= -Standard_Boolean VertexRangeTolerance(const Standard_Integer nV, - const Standard_Integer nF1, - const Standard_Integer nF2, - const BOPTools_InterferencePool& anIntrPool, - Standard_Real& aTolV) -{ - Standard_Boolean bFound=Standard_False; - Standard_Integer i, aNbEFs, iWhat, iWith, iNewShape ; - TColStd_IndexedMapOfInteger aMEF; - // - BooleanOperations_PShapesDataStructure pDS=anIntrPool.DS(); - // - const TopoDS_Vertex& aV=TopoDS::Vertex(pDS->Shape(nV)); - // - FaceAndEdgeMap(nF1, anIntrPool, aMEF); - FaceAndEdgeMap(nF2, anIntrPool, aMEF); - // - // EF Interferences - const BOPTools_CArray1OfESInterference& aEFs=anIntrPool.ESInterfs(); - - aNbEFs=aEFs.Extent(); - for (i=1; i<=aNbEFs; ++i) { - const BOPTools_ESInterference& aEF=aEFs(i); - iNewShape=aEF.NewShape(); - if (iNewShape==nV) { - aEF.Indices(iWhat, iWith); - if (aMEF.Contains(iWhat) && aMEF.Contains(iWith)) { - //... - Standard_Real aTolVWas, aD1, aD2, aDMax; - gp_Pnt aP3DV, aP3DV1, aP3DV2; - // - const IntTools_CommonPrt& aCommonPrt=aEF.CommonPrt(); - //const TopoDS_Edge& aE1= aCommonPrt.Edge1();// Wng in Gcc 3.0 - - aP3DV=BRep_Tool::Pnt(aV); - aTolVWas=BRep_Tool::Tolerance(aV); - - aCommonPrt.BoundingPoints(aP3DV1, aP3DV2); - aD1=aP3DV.Distance(aP3DV1); - aD2=aP3DV.Distance(aP3DV2); - - aDMax=Max(aD1, aD2); - - aTolV=aTolVWas; - if (aDMax>aTolVWas) { - aTolV=aDMax; - } - return !bFound; - } - } - } - // - // EE Interferences - /* - const BOPTools_CArray1OfEEInterference& aEEs=anIntrPool.EEInterfs(); - aNbEEs=aEEs.Extent(); - for (i=1; i<=aNbEEs; ++i) { - const BOPTools_EEInterference& aEE=aEEs(i); - iNewShape=aEE.NewShape(); - if (iNewShape==nV) { - aEE.Indices(iWhat, iWith); - if (aMEF.Contains(iWhat) && aMEF.Contains(iWith)) { - //... - aTolV=0.; - return !bFound; - } - } - } - */ - // - return bFound; -} - -//======================================================================= -// function: FaceAndEdgeMap -// purpose: -//======================================================================= -void FaceAndEdgeMap(const Standard_Integer nF, - const BOPTools_InterferencePool& anIntrPool, - TColStd_IndexedMapOfInteger& aMEF) -{ - Standard_Integer nEF; - aMEF.Add(nF); - BooleanOperations_PShapesDataStructure myDS=anIntrPool.DS(); - BooleanOperations_OnceExplorer aExp(*myDS); - aExp.Init(nF, TopAbs_EDGE); - for (; aExp.More(); aExp.Next()) { - nEF=aExp.Current(); - aMEF.Add(nEF); - } -} -//wkar OCC334 t - -//======================================================================= -// function: IsPairFound -// purpose: -//======================================================================= -Standard_Boolean IsPairFound(const Standard_Integer nF1, - const Standard_Integer nF2, - BOPTools_InterferencePool* myIntrPool, - BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMapWhat, - BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMapWith) -{ - Standard_Boolean bIsFound; - // - if (!aMapWhat.Contains(nF1)) { - TColStd_IndexedMapOfInteger aMWhat; - FMapWhat(nF1, myIntrPool, aMWhat); - aMapWhat.Add(nF1, aMWhat); - } - // - if (!aMapWith.Contains(nF2)) { - TColStd_IndexedMapOfInteger aMWith; - FMapWith(nF2, myIntrPool, aMWith); - aMapWith.Add(nF2, aMWith); - } - // - const TColStd_IndexedMapOfInteger& aMWht=aMapWhat.FindFromKey(nF1); - const TColStd_IndexedMapOfInteger& aMWit=aMapWith.FindFromKey(nF2); - // - bIsFound=IsFound(aMWht, aMWit); - // - return bIsFound; -} - -//======================================================================= -// function: RestrictCurveIn2d -// purpose: Intersects 2d curve of edge nE and 2d curve of theBC. -// Splits theBC by new vertex, also splits nE by new vertex. -// If nE has same domain with another edge, the same domain -// edge is splitted too. -//======================================================================= - void BOPTools_PaveFiller::RestrictCurveIn2d(const Standard_Integer nE, - const Standard_Integer nF1, - const Standard_Integer nF2, - const Standard_Real theTolerance, - BOPTools_Curve& theBC) -{ - myPavePoolNew.Resize (myNbEdges); - TopoDS_Shape atmpShape; - - BOPTools_CArray1OfESInterference& aESs = myIntrPool->ESInterferences(); - - BOPTools_PaveSet& aPS = myPavePool(myDS->RefEdge(nE)); - Standard_Boolean bSearchInter = Standard_True; - - // 6841 - Standard_Integer pvVrtIndex = 0; - // - - BOPTools_ListIteratorOfListOfPave anIt1(aPS.Set()); - BOPTools_ListIteratorOfListOfPave anIt2; - - for(; bSearchInter && anIt1.More(); anIt1.Next()) { - - for(anIt2.Initialize(theBC.Set().Set()); anIt2.More(); anIt2.Next()) { - - if(anIt1.Value().Index() == anIt2.Value().Index()) { // too hard condition for the algorithm - // 6841 - pvVrtIndex = anIt1.Value().Index(); - // - bSearchInter = Standard_False; - break; - } - } - } - // -- 6841: test 2d intersection any way, but update vertex only - if((!bSearchInter && pvVrtIndex != 0)) { - Standard_Boolean OnFirst = (myDS->Rank(nE) == 1); - TopoDS_Edge aE = TopoDS::Edge(myDS->Shape(nE)); - TopoDS_Face aF = (OnFirst) ? TopoDS::Face(myDS->Shape(nF1)) : TopoDS::Face(myDS->Shape(nF2)); - Standard_Real pf2 = 0., pl2 = 0.; - Handle(Geom_Curve) aC2D3 = BRep_Tool::Curve(aE, pf2, pl2); - Handle(Geom2d_Curve) aC2D2 = BRep_Tool::CurveOnSurface(aE, aF, pf2, pl2); - Handle(Geom2d_Curve) aC1D2 = (OnFirst) ? theBC.Curve().FirstCurve2d() : theBC.Curve().SecondCurve2d(); - Handle(Geom_Curve) aC1D3 = theBC.Curve().Curve(); - if((!aC2D3.IsNull() && !aC2D2.IsNull()) && (!aC1D2.IsNull() && !aC1D3.IsNull())) { - Standard_Real pf1 = aC1D2->FirstParameter(); - Standard_Real pl1 = aC1D2->LastParameter(); - Geom2dAPI_InterCurveCurve aInt(aC1D2, aC2D2, Precision::PConfusion()); - if(aInt.NbPoints() > 0) { - Standard_Integer jj = 1; - for(; jj <= aInt.NbPoints(); jj++) { - Standard_Real t1 = aInt.Intersector().Point(jj).ParamOnFirst(); - Standard_Real t2 = aInt.Intersector().Point(jj).ParamOnSecond(); - if((t1 >= pf1) && (t1 <= pl1) && (t2 >= pf2) && (t2 <= pl2)) { -// gp_Pnt2d aP2d = aInt.Point(jj); - gp_Pnt aP3d = aC2D3->Value(t2); - gp_Pnt aP3d2 = aC1D3->Value(t1); - TopoDS_Vertex & aVrt = (TopoDS_Vertex &) myDS->Shape(pvVrtIndex); - gp_Pnt aVP = BRep_Tool::Pnt(aVrt); - Standard_Real aVTol = BRep_Tool::Tolerance(aVrt); - Standard_Real aD1 = aP3d.Distance(aVP); - Standard_Real aD2 = aP3d2.Distance(aVP); - Standard_Real aFD1 = fabs(aVTol-aD1); - Standard_Real aFD2 = fabs(aVTol-aD2); - if(aD1 > aVTol || aD2 > aVTol) { - if(Max(aFD1,aFD2) <= 1.e-2) { - Standard_Real nTol = aVTol + 2. * Max(aFD1,aFD2) + 1.e-7; - BRep_Builder bb; - bb.UpdateVertex(aVrt, nTol); - } - } - } - } - } - } - } - //-- 6841 - - if(bSearchInter) { - // search intersection in 2d. begin - BOPTools_ListOfPave aPavesOnCurve, aPavesOnEdge; - Standard_Boolean bIsOnFirst = (myDS->Rank(nE) == 1); - - Handle(Geom2d_Curve) aC1 = (bIsOnFirst) ? theBC.Curve().FirstCurve2d() : theBC.Curve().SecondCurve2d(); - - if(aC1.IsNull()) - return; - Standard_Real f1 = aC1->FirstParameter(); - Standard_Real l1 = aC1->LastParameter(); - - // f1 and l1 may not correspond - // to boundary parameters of 3d curve - if(theBC.Curve().HasBounds()) { - gp_Pnt tmpp1, tmpp2; - theBC.Curve().Bounds(f1, l1, tmpp1, tmpp2); - } - - atmpShape = myDS->Shape(nE); - TopoDS_Edge anEdge = TopoDS::Edge(atmpShape); - TopoDS_Shape aFace = (bIsOnFirst) ? myDS->Shape(nF1) : myDS->Shape(nF2); - Standard_Real f2=0., l2=0.; - Handle(Geom2d_Curve) aC2 = BRep_Tool::CurveOnSurface(anEdge, TopoDS::Face(aFace), f2, l2); - Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anEdge, f2, l2); - - if(aC2.IsNull() || aCurve.IsNull()) - return; - - Geom2dAPI_InterCurveCurve anIntersector(aC1, aC2, Precision::PConfusion()); - - if(anIntersector.NbPoints() > 0) { - Standard_Integer j = 0; - - for(j = 1; j <= anIntersector.NbPoints(); j++) { - Standard_Real t1 = anIntersector.Intersector().Point(j).ParamOnFirst(); - Standard_Real t2 = anIntersector.Intersector().Point(j).ParamOnSecond(); - - if((t1 >= f1) && (t1 <= l1) && - (t2 >= f2) && (t2 <= l2)) { - gp_Pnt2d aP2dOnFace = anIntersector.Point(j); - atmpShape = (!bIsOnFirst) ? myDS->Shape(nF1) : myDS->Shape(nF2); - TopoDS_Face anOtherFace = TopoDS::Face(atmpShape); - gp_Pnt aP3d = aCurve->Value(t2); - - if(myContext->IsPointInOnFace(TopoDS::Face(aFace), aP2dOnFace) && - myContext->IsValidPointForFace(aP3d, anOtherFace, BRep_Tool::Tolerance(anEdge))) { - BOPTools_Pave aPave1; - aPave1.SetParam(t1); - aPave1.SetIndex(-1); - aPavesOnCurve.Append(aPave1); - BOPTools_Pave aPave2; - aPave2.SetParam(t2); - aPave2.SetIndex(-1); - aPavesOnEdge.Append(aPave2); - } - } - } - } // (anIntersector.NbPoints()) - // search intersection in 2d. end - - - BOPTools_ListIteratorOfListOfPave aPaveIt1(aPavesOnCurve); - BOPTools_ListIteratorOfListOfPave aPaveIt2(aPavesOnEdge); - - // test common blocks. begin - Standard_Boolean bFaceCBFound = Standard_False; - Standard_Boolean bEdgeCBFound = Standard_False; - const BOPTools_ListOfCommonBlock& aLCBTest = myCommonBlockPool(myDS->RefEdge(nE)); - BOPTools_ListIteratorOfListOfCommonBlock aCBListIt(aLCBTest); - Standard_Boolean bHasCBOnFace = Standard_False; - Standard_Boolean bHasCBOnEdge = Standard_False; - - for(; aCBListIt.More(); aCBListIt.Next()) { - if((aCBListIt.Value().Face() == nF1) || - (aCBListIt.Value().Face() == nF2)) { - bHasCBOnFace = Standard_True; - } - - if(aCBListIt.Value().Face() == 0) { - bHasCBOnEdge = Standard_True; - } - } - - if(!bHasCBOnFace || !bHasCBOnEdge) { - BOPTools_PaveSet aTestPaveSet; - aTestPaveSet.ChangeSet() = aPS.Set(); - - for(; aPaveIt2.More(); aPaveIt2.Next()) { - aTestPaveSet.Append(aPaveIt2.Value()); - } - BOPTools_PaveBlockIterator aPBIter(0, aTestPaveSet); - - for (; aPBIter.More(); aPBIter.Next()) { - const BOPTools_PaveBlock& aPB = aPBIter.Value(); - Standard_Real aT1=aPB.Pave1().Param(); - Standard_Real aT2=aPB.Pave2().Param(); - gp_Pnt aPMid = aCurve->Value((aT1 + aT2) * 0.5); - Standard_Integer nFOpposite = (bIsOnFirst) ? nF2 : nF1; - TopoDS_Shape aOppFace = myDS->Shape(nFOpposite); - - if(!bHasCBOnFace && !bFaceCBFound && - myContext->IsValidPointForFace(aPMid, TopoDS::Face(aOppFace), - BRep_Tool::Tolerance(anEdge) + - BRep_Tool::Tolerance(TopoDS::Face(aOppFace)))) { - bFaceCBFound = Standard_True; - } - - if(!bHasCBOnEdge && !bEdgeCBFound) { - TopoDS_Vertex aVMid; - BRep_Builder aBB; - aBB.MakeVertex(aVMid, aPMid, BRep_Tool::Tolerance(anEdge)); - TopExp_Explorer anExpE(aOppFace, TopAbs_EDGE); - - for(; anExpE.More(); anExpE.Next()) { - TopoDS_Shape aTmpEdge = anExpE.Current(); - Standard_Real aParameter = 0.; - - if(myContext->ComputeVE(aVMid, TopoDS::Edge(aTmpEdge), aParameter) == 0) { - bEdgeCBFound = Standard_True; - break; - } - } - } - } - aPaveIt2.Initialize(aPavesOnEdge); - } - // test common blocks. end - - Standard_Boolean bChecknAddPaves = Standard_True; - - if(bEdgeCBFound) { - bChecknAddPaves = Standard_False; - } - else { - if(!bHasCBOnEdge) { - bChecknAddPaves = !bFaceCBFound; - } - } - - if(bChecknAddPaves) { - // add paves chaking if new pave is equal to existent. begin - for(; aPaveIt1.More() && aPaveIt2.More(); aPaveIt1.Next(), aPaveIt2.Next()) { - BOPTools_Pave& aPaveOnCurve = aPaveIt1.Value(); - BOPTools_Pave& aPaveOnEdge = aPaveIt2.Value(); - - gp_Pnt aP1 = theBC.Curve().Curve()->Value(aPaveOnCurve.Param()); - gp_Pnt aP2 = aCurve->Value(aPaveOnEdge.Param()); - - Standard_Boolean bAddNewVertex = Standard_True; - Standard_Boolean bAddOldVertex = Standard_False; - Standard_Integer oldvertexindex = 0; - - for(anIt2.Initialize(theBC.Set().Set()); anIt2.More(); anIt2.Next()) { - atmpShape = myDS->Shape(anIt2.Value().Index()); - TopoDS_Vertex aVertex = TopoDS::Vertex(atmpShape); - gp_Pnt aPoint = BRep_Tool::Pnt(aVertex); - Standard_Real aTolerance = theTolerance + BRep_Tool::Tolerance(aVertex); - if((aPoint.Distance(aP1) < aTolerance) || - (aPoint.Distance(aP2) < aTolerance)) { - bAddNewVertex = Standard_False; - bAddOldVertex = Standard_True; - oldvertexindex = anIt2.Value().Index(); - break; - } - } - - // treat equality with other vertices.begin - if(bAddNewVertex || bAddOldVertex) { - TopoDS_Vertex aNewVertex; - BOPTools_Tools::MakeNewVertex(anEdge, aPaveOnEdge.Param(), - TopoDS::Face(aFace), aNewVertex); - - BOPTools_Pave aPaveToPut; - Standard_Boolean bAddNewVertextmp = bAddNewVertex, bAddOldVertextmp = bAddOldVertex; - - if(!CheckNewVertexAndUpdateData(aNewVertex, aPaveOnEdge.Param(), anEdge, aPaveOnCurve.Param(), - nF1, nF2, theTolerance, myIntrPool, myDS, myContext, aPS, - bAddNewVertextmp, bAddOldVertextmp, theBC, aPaveToPut, - bAddNewVertex, bAddOldVertex)) { - bAddNewVertex = Standard_False; - bAddOldVertex = Standard_False; - } - else { - if((aPaveToPut.Index() != 0) && (aPaveToPut.Param() != 0.) && - aPaveToPut.Interference() != 0) { - PutPaveOnCurve(aPaveToPut, theTolerance, theBC); - } - } - // end for(anIt1.Initialize... - } - // treat equality with other vertices.end - - if(bAddNewVertex || (bAddOldVertex && oldvertexindex)) { - TopoDS_Vertex aNewVertex; - - Standard_Integer aNewShapeIndex = 0; - - // reject creation new vertex if there is a created one at a too small distance - BOPTools_Tools::MakeNewVertex(anEdge,aPaveOnEdge.Param(),TopoDS::Face(aFace),aNewVertex); - Standard_Real nvTol = BRep_Tool::Tolerance(aNewVertex); - Standard_Integer chShNb = myDS->NumberOfInsertedShapes(), chShInd = 0; - Standard_Boolean completeSearching = Standard_False; - for(chShInd = 1; chShInd <= chShNb; chShInd++) { - if(myDS->GetShapeType(chShInd) != TopAbs_VERTEX) - continue; - TopoDS_Vertex chV = TopoDS::Vertex(myDS->Shape(chShInd)); - Standard_Real distVV = BRep_Tool::Pnt(chV).Distance(BRep_Tool::Pnt(aNewVertex)); - if(distVV <= 1.e-5) { - for(anIt1.Initialize(aPS.Set()); anIt1.More(); anIt1.Next()) { - if(anIt1.Value().Index() == chShInd) { - Standard_Real dParam = fabs(aPaveOnEdge.Param()-anIt1.Value().Param()); - if(dParam <= 1.e-7) { - bAddNewVertex = Standard_False; - bAddOldVertex = Standard_True; - oldvertexindex = anIt1.Value().Index(); - nvTol += BRep_Tool::Tolerance(chV) + distVV; - completeSearching = Standard_True; - break; - } - } - } - } - if(completeSearching) - break; - } - // -&& - - - if(!bAddOldVertex) { - BOPTools_Tools::MakeNewVertex(anEdge, aPaveOnEdge.Param(), - TopoDS::Face(aFace), aNewVertex); - BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq; - myDS->InsertShapeAndAncestorsSuccessors(aNewVertex, anASSeq); - aNewShapeIndex = myDS->NumberOfInsertedShapes(); - } - else { - aNewShapeIndex = oldvertexindex; - aNewVertex = TopoDS::Vertex(myDS->Shape(aNewShapeIndex)); - BRep_Builder aBB; - // - aBB.UpdateVertex(aNewVertex, aPaveOnEdge.Param(), anEdge, nvTol); - } - - BOPTools_ListIteratorOfListOfPave anItAll; - Standard_Boolean samePFound = Standard_False; - for(anItAll.Initialize(aPS.Set()); anItAll.More(); anItAll.Next()) { - if(anItAll.Value().Index() == aNewShapeIndex) { - BOPTools_Pave& aPV = anItAll.Value(); - aPV.SetParam(aPaveOnEdge.Param()); - samePFound = Standard_True; - break; - } - } - if(samePFound) - continue; - - - myDS->SetState (aNewShapeIndex, BooleanOperations_ON); - - IntTools_CommonPrt aCPart; - aCPart.SetEdge1(anEdge); - aCPart.SetType(TopAbs_VERTEX); - aCPart.SetRange1(IntTools_Range(aPaveOnEdge.Param(), aPaveOnEdge.Param())); - aCPart.SetVertexParameter1(aPaveOnEdge.Param()); - - Standard_Integer nFOpposite = (bIsOnFirst) ? nF2 : nF1; - BOPTools_ESInterference anInterf (nE, nFOpposite, aCPart); - Standard_Integer anIndexIn = aESs.Append(anInterf); - myIntrPool->AddInterference (nE, nFOpposite, BooleanOperations_EdgeSurface, anIndexIn); - - BOPTools_ESInterference& aESInterf = aESs(anIndexIn); - aESInterf.SetNewShape(aNewShapeIndex); - - // put pave on edge. begin - aPaveOnEdge.SetInterference(anIndexIn); - aPaveOnEdge.SetType (BooleanOperations_EdgeSurface); - aPaveOnEdge.SetIndex(aNewShapeIndex); - - BOPTools_PaveSet& aPaveSet1 = myPavePoolNew(myDS->RefEdge(nE)); - aPaveSet1.Append(aPaveOnEdge); - // put pave on edge. end - - // put pave on curve. begin - aPaveOnCurve.SetIndex(aNewShapeIndex); - aPaveOnCurve.SetType(BooleanOperations_SurfaceSurface); - BOPTools_PaveSet& aPaveSet = theBC.Set(); - aPaveSet.Append(aPaveOnCurve); - - BOPTools_Tools::UpdateVertex (theBC.Curve(), aPaveOnCurve.Param(), aNewVertex); - - // put pave on curve. end - - BOPTools_ListOfCommonBlock& aLCB1 = myCommonBlockPool(myDS->RefEdge(nE)); - - BOPTools_ListIteratorOfListOfCommonBlock anIt(aLCB1); - - for(; anIt.More(); anIt.Next()) { - BOPTools_CommonBlock& aCB = anIt.Value(); - - if(aCB.Face()) { - continue; - } - - Standard_Integer anOppIndex = aCB.PaveBlock2().OriginalEdge(); - IntTools_Range aRange = aCB.PaveBlock2().Range(); - - if(anOppIndex == nE) { - anOppIndex = aCB.PaveBlock1().OriginalEdge(); - aRange = aCB.PaveBlock1().Range(); - } - TopoDS_Edge anOppEdge = TopoDS::Edge(myDS->Shape(anOppIndex)); - Standard_Real aOppParameter = 0.; - - if(myContext->ComputeVE(aNewVertex, anOppEdge, aOppParameter) == 0) { - - if((aOppParameter > aRange.First()) && (aOppParameter < aRange.Last())) { - // put pave on same domain edge. begin - BRep_Builder aBB; - aBB.UpdateVertex(aNewVertex, aOppParameter, anOppEdge, BRep_Tool::Tolerance(aNewVertex)); - BOPTools_Pave aPaveOpp; - aPaveOpp.SetParam(aOppParameter); - aPaveOpp.SetIndex(aNewShapeIndex); - BOPTools_PaveSet& aPaveSetOpp = myPavePoolNew(myDS->RefEdge(anOppIndex)); - aPaveSetOpp.Append(aPaveOpp); - // put pave on same domain edge. end - } - } - } - - // add SS interference for adjacent face.begin - if(aLCB1.IsEmpty()) { - AddInterfForAdjacentFace(nE, nF1, nF2, myIntrPool, myDS); - } - // add SS interference for adjacent face.end - - RefinePavePool(); - myPavePoolNew.Resize(myNbEdges); - // - - RecomputeCommonBlocks(nE); - - } - } // end for(; aPaveIt1.More() && aPaveIt2.More()... - // add paves chaking if new pave is equal to existent. end - } - } //(bSearchInter) - myPavePoolNew.Destroy(); -} -//======================================================================= -//function : RecomputeCommonBlocks -//purpose : -//======================================================================= - void BOPTools_PaveFiller::RecomputeCommonBlocks(const Standard_Integer nE) -{ - TopoDS_Shape atmpShape = myDS->Shape(nE); - TopoDS_Edge anEdge = TopoDS::Edge(atmpShape); - BOPTools_ListOfCommonBlock& aLCB1 = myCommonBlockPool(myDS->RefEdge(nE)); - - BOPTools_ListOfCommonBlock anOldLCB; - anOldLCB = aLCB1; - aLCB1.Clear(); - BOPTools_ListOfCommonBlock aNewLCB1; - Standard_Boolean bReverse = Standard_False; - BOPTools_ListIteratorOfListOfCommonBlock anIt(anOldLCB); - - for(; anIt.More(); anIt.Next()) { - BOPTools_CommonBlock& anOldCB = anIt.Value(); - - Standard_Integer anIndex = anOldCB.PaveBlock1().OriginalEdge(); - Standard_Integer anIndexOpp = anOldCB.PaveBlock2().OriginalEdge(); - IntTools_Range aCBRange = anOldCB.PaveBlock1().Range(); - - if(anIndex != nE) { - aCBRange = anOldCB.PaveBlock2().Range(); - anIndex = anOldCB.PaveBlock2().OriginalEdge(); - anIndexOpp = anOldCB.PaveBlock1().OriginalEdge(); - bReverse = Standard_True; - } - - BOPTools_ListOfPaveBlock& aSplitEdges1 = mySplitShapesPool(myDS->RefEdge(nE)); - BOPTools_ListIteratorOfListOfPaveBlock aLPBIt1(aSplitEdges1); - Standard_Boolean found = Standard_False; - BOPTools_ListOfCommonBlock aNewListOfCommonBlock; - - for(; aLPBIt1.More(); aLPBIt1.Next()) { - BOPTools_PaveBlock& aPBCurrent1 = aLPBIt1.Value(); - IntTools_Range aCurRange1 = aPBCurrent1.Range(); - - if((aCurRange1.First() > aCBRange.First() && aCurRange1.First() < aCBRange.Last()) || - (aCurRange1.Last() > aCBRange.First() && aCurRange1.Last() < aCBRange.Last())) { - BOPTools_CommonBlock aNewCB; - - if(!bReverse) - aNewCB.SetPaveBlock1(aPBCurrent1); - else - aNewCB.SetPaveBlock2(aPBCurrent1); - - Standard_Boolean foundpaveblock2 = Standard_False; - - if(anOldCB.Face()) { - foundpaveblock2 = Standard_True; - aNewCB.SetFace(anOldCB.Face()); - } - else { - if(anIndexOpp <= 0) - continue; - BOPTools_ListIteratorOfListOfPaveBlock aLPBIt2(mySplitShapesPool(myDS->RefEdge(anIndexOpp))); - - for(; aLPBIt2.More(); aLPBIt2.Next()) { - BOPTools_PaveBlock& aPBCurrent2 = aLPBIt2.Value(); - IntTools_Range aCurRange2 = aPBCurrent2.Range(); - - if(((aPBCurrent1.Pave1().Index() == aPBCurrent2.Pave1().Index()) && - (aPBCurrent1.Pave2().Index() == aPBCurrent2.Pave2().Index())) || - ((aPBCurrent1.Pave1().Index() == aPBCurrent2.Pave2().Index()) && - (aPBCurrent1.Pave2().Index() == aPBCurrent2.Pave1().Index()))) { - Standard_Real f = 0., l = 0.; - Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anEdge, f, l); - Standard_Real aMidPar = (aCurRange1.First() + aCurRange1.Last()) * 0.5; - gp_Pnt aMidPnt = aCurve->Value(aMidPar); - Standard_Real aProjPar = 0.; - TopoDS_Vertex aTestpVertex; - TopoDS_Edge aOppEdge = TopoDS::Edge(myDS->Shape(anIndexOpp)); - BRep_Builder aBB; - aBB.MakeVertex(aTestpVertex, aMidPnt, BRep_Tool::Tolerance(anEdge)); - - if(myContext->ComputeVE(aTestpVertex, aOppEdge, aProjPar) == 0) { - if(aProjPar > aCurRange2.First() && aProjPar < aCurRange2.Last()) { - if(!bReverse) - aNewCB.SetPaveBlock2(aPBCurrent2); - else - aNewCB.SetPaveBlock1(aPBCurrent2); - foundpaveblock2 = Standard_True; - break; - } - } - } - } - } - - if(foundpaveblock2) { - found = Standard_True; - aNewListOfCommonBlock.Append(aNewCB); - } - } - } - // end for(; aLPBIt1.More()... - - if(!found) { - aNewLCB1.Append(anOldCB); - } - else { - BOPTools_ListOfCommonBlock tmplst; - tmplst = aNewListOfCommonBlock; - aNewLCB1.Append(tmplst); - - if((anOldCB.Face() == 0) && (anIndexOpp > 0)) { - tmplst = aNewListOfCommonBlock; - BOPTools_ListOfCommonBlock& aLCB2 = myCommonBlockPool(myDS->RefEdge(anIndexOpp)); - - BOPTools_ListIteratorOfListOfCommonBlock anItLCB2(aLCB2); - - for(; anItLCB2.More(); anItLCB2.Next()) { - BOPTools_CommonBlock& anOldCB2 = anItLCB2.Value(); - - if(anOldCB2.Face()) - continue; - - if(anOldCB.PaveBlock1().IsEqual(anOldCB2.PaveBlock1()) && - anOldCB.PaveBlock2().IsEqual(anOldCB2.PaveBlock2())) { - aLCB2.Remove(anItLCB2); - aLCB2.Append(tmplst); - break; - } - } - } - } - } - // end for(; anIt.More()... - aLCB1 = aNewLCB1; -} -//======================================================================= -//function : CheckNewVertexAndUpdateData -//purpose : -//======================================================================= -Standard_Boolean CheckNewVertexAndUpdateData(const TopoDS_Vertex& theVertex, - const Standard_Real theParamOnE, - const TopoDS_Edge& theEdge, - const Standard_Real theParamOnCurve, - const Standard_Integer theIndexF1, - const Standard_Integer theIndexF2, - const Standard_Real theTolerance, - const BOPTools_PInterferencePool& theIntrPool, - const BooleanOperations_PShapesDataStructure& theDS, - const Handle(IntTools_Context)& theContext, - const BOPTools_PaveSet& theEdgePaveSet, - const Standard_Boolean bAddNewVertex, - const Standard_Boolean bAddOldVertex, - BOPTools_Curve& theBC, - BOPTools_Pave& thePaveToPut, - Standard_Boolean& bAddNewVertexOut, - Standard_Boolean& bAddOldVertexOut) { - - thePaveToPut.SetParam(0.); - thePaveToPut.SetIndex(0); - thePaveToPut.SetInterference(0); - - bAddNewVertexOut = bAddNewVertex; - bAddOldVertexOut = bAddOldVertex; - TopoDS_Shape atmpShape; - gp_Pnt aP1 = theBC.Curve().Curve()->Value(theParamOnCurve); - Standard_Real f = 0., l = 0.; - Handle(Geom_Curve) aCurve = BRep_Tool::Curve(theEdge, f, l); - - if(aCurve.IsNull()) - return Standard_False; - gp_Pnt aP2 = aCurve->Value(theParamOnE); - - BOPTools_ListIteratorOfListOfPave anIt1, anIt2; - - for(anIt1.Initialize(theEdgePaveSet.Set()); anIt1.More(); anIt1.Next()) { - atmpShape = theDS->Shape(anIt1.Value().Index()); - TopoDS_Vertex aVertex = TopoDS::Vertex(atmpShape); - gp_Pnt aPoint = BRep_Tool::Pnt(aVertex); - Standard_Real aTolerance = theTolerance + BRep_Tool::Tolerance(aVertex); - aTolerance *= 4.; - - if((aPoint.Distance(aP1) < aTolerance) || - (aPoint.Distance(aP2) < aTolerance)) { - IntTools_Range aRange(anIt1.Value().Param(), theParamOnE); - TopoDS_Vertex aV1 = aVertex; - TopoDS_Vertex aV2 = theVertex; - - if(anIt1.Value().Param() > theParamOnE) { - aRange.SetFirst(theParamOnE); - aRange.SetLast(anIt1.Value().Param()); - aV1 = theVertex; - aV2 = aVertex; - } - gp_Pnt ptest1 = aCurve->Value(aRange.First()); - gp_Pnt ptest2 = aCurve->Value(aRange.Last()); - Standard_Boolean bUpdateVertex = Standard_True; - - if(ptest1.Distance(ptest2) > (BRep_Tool::Tolerance(aVertex) + BRep_Tool::Tolerance(theEdge))) { - IntTools_ShrunkRange aSR (theEdge, aV1, aV2, aRange, theContext); - bUpdateVertex = !aSR.IsDone() || (aSR.ErrorStatus() != 0); - } - - if(bUpdateVertex) { - bAddNewVertexOut = Standard_False; - - if(bAddOldVertexOut) { - bAddOldVertexOut = Standard_False; - break; - } - BOPTools_Tools::UpdateVertex (theBC.Curve(), theParamOnCurve, aVertex); - - Standard_Boolean bPutPave = Standard_True; - - for(anIt2.Initialize(theBC.Set().Set()); anIt2.More(); anIt2.Next()) { - if(anIt1.Value().Index() == anIt2.Value().Index()) { - bPutPave = Standard_False; - break; - } - } - - Standard_Integer nbbefore = theBC.Set().Set().Extent(); - - if(bPutPave) { - thePaveToPut = anIt1.Value(); - } - - if(anIt1.Value().Index() > theDS->NumberOfSourceShapes()) - break; - - Standard_Integer nbafter = theBC.Set().Set().Extent(); - - if(nbbefore < nbafter) { - // update interferences.begin - Standard_Integer nF = theIndexF1; - - if(theDS->Rank(anIt1.Value().Index()) != theDS->Rank(theIndexF1)) { - nF = theIndexF2; - } - atmpShape = theDS->Shape(nF); - TopoDS_Face aF = TopoDS::Face (atmpShape); - BOPTools_CArray1OfVSInterference& aVSs = theIntrPool->VSInterferences(); - Standard_Integer vsit = 0; - Standard_Boolean interffound = Standard_False; - - for(vsit = 1; vsit <= aVSs.Length(); vsit++) { - if((aVSs.Value(vsit).Index1() == anIt1.Value().Index()) && - (aVSs.Value(vsit).Index2() == nF)) { - interffound = Standard_True; - break; - } - } - - if(!interffound) { - BOPTools_CArray1OfVEInterference& aVEs = theIntrPool->VEInterferences(); - - for(vsit = 1; vsit <= aVEs.Length(); vsit++) { - if((aVEs.Value(vsit).Index1() == anIt1.Value().Index())) { - interffound = Standard_True; - break; - } - } - } - - if(!interffound) { - BOPTools_CArray1OfVVInterference& aVVs = theIntrPool->VVInterferences(); - - for(vsit = 1; vsit <= aVVs.Length(); vsit++) { - if((aVVs.Value(vsit).Index1() == anIt1.Value().Index())) { - interffound = Standard_True; - break; - } - } - } - - if(!interffound) { - Standard_Real aU = 0., aV = 0.; - Standard_Integer aFlag = theContext->ComputeVS (aVertex, aF, aU, aV); - Standard_Integer anIndexIn = 0; - - if (!aFlag) { - // - // Add Interference to the Pool - BOPTools_VSInterference anInterf (anIt1.Value().Index(), nF, aU, aV); - anIndexIn=aVSs.Append(anInterf); - // - // SetState for Vertex in DS; - theDS->SetState (anIt1.Value().Index(), BooleanOperations_ON); - // Insert Vertex in Interference Object - BOPTools_VSInterference& aVS = aVSs(anIndexIn); - aVS.SetNewShape(anIt1.Value().Index()); - - interffound = Standard_False; - const BOPTools_ListOfInterference& aList1 = - theIntrPool->InterferenceTable().Value(anIt1.Value().Index()).GetOnType(BooleanOperations_EdgeSurface); - BOPTools_ListOfInterference& amodifList1 = *((BOPTools_ListOfInterference*)&aList1); // not very good approach - BOPTools_ListIteratorOfListOfInterference anInterfIt(amodifList1); - - for(; anInterfIt.More(); anInterfIt.Next()) { - if(anInterfIt.Value().With() == nF) { - anInterfIt.Value().SetIndex(anIndexIn); - interffound = Standard_True; - } - } - const BOPTools_ListOfInterference& aList2 = - theIntrPool->InterferenceTable().Value(nF).GetOnType(BooleanOperations_EdgeSurface); - BOPTools_ListOfInterference& amodifList2 = *((BOPTools_ListOfInterference*)&aList2); // not very good approach - anInterfIt.Initialize(amodifList2); - - for(; anInterfIt.More(); anInterfIt.Next()) { - if(anInterfIt.Value().With() == anIt1.Value().Index()) { - anInterfIt.Value().SetIndex(anIndexIn); - interffound = Standard_True; - } - } - - if(!interffound) - theIntrPool->AddInterference(anIt1.Value().Index(), nF, BooleanOperations_VertexSurface, anIndexIn); - } - } - // update interferences.end - } - break; - } - } - } - // end for(anIt1.Initialize... - return Standard_True; -} -//======================================================================= -//function : AddInterfForAdjacentFace -//purpose : -//======================================================================= -void AddInterfForAdjacentFace(const Standard_Integer theEdgeIndex, - const Standard_Integer theIndexF1, - const Standard_Integer theIndexF2, - BOPTools_PInterferencePool theIntrPool, - const BooleanOperations_PShapesDataStructure& theDS) { - Standard_Boolean bIsOnFirst = (theDS->Rank(theEdgeIndex) == 1); - - IntTools_SequenceOfPntOn2Faces aPnts; - IntTools_SequenceOfCurves aCvs; - Standard_Integer index1 = (bIsOnFirst) ? theIndexF1 : theIndexF2; - Standard_Integer index2 = (bIsOnFirst) ? theIndexF2 : theIndexF1; - Standard_Integer nbw = theDS->NumberOfAncestors(theEdgeIndex); - Standard_Integer ancwit = 0, ancfit = 0; - Standard_Boolean badjacentfound = Standard_False; - - for(ancwit = 1; (!badjacentfound) && (ancwit <= nbw); ancwit++) { - Standard_Integer ancestor1 = theDS->GetAncestor(theEdgeIndex, ancwit); - - if(ancestor1 == index1) - continue; - - if(theDS->GetShapeType(ancestor1) == TopAbs_WIRE) { - Standard_Integer nbf = theDS->NumberOfAncestors(ancestor1); - - for(ancfit = 1; ancfit <= nbf; ancfit++) { - Standard_Integer ancestor2 = theDS->GetAncestor(ancestor1, ancfit); - - if(ancestor2 != index1) { - index1 = ancestor2; - badjacentfound = Standard_True; - break; - } - } - } - } - - if(index1 > index2) { - Standard_Integer tmp = index1; - index1 = index2; - index2 = tmp; - } - Standard_Boolean bAddInterference = Standard_True; - Standard_Integer ffit = 0; - BOPTools_CArray1OfSSInterference& aFFs = theIntrPool->SSInterferences(); - - for(ffit = 1; ffit <= aFFs.Extent(); ffit++) { - BOPTools_SSInterference& aFFi3 = aFFs(ffit); - - if((index1 == aFFi3.Index1()) && (index2 == aFFi3.Index2())) { - bAddInterference = Standard_False; - } - } - - if(bAddInterference) { - BOPTools_SSInterference anInterfSS (index1, index2, 1.e-07, 1.e-07, aCvs, aPnts); - Standard_Integer anIndexInSS = aFFs.Append(anInterfSS); - theIntrPool->AddInterference (index1, index2, BooleanOperations_SurfaceSurface, anIndexInSS); - } -} - -//======================================================================= -//function : RejectPaveBlock -//purpose : -//======================================================================= -Standard_Boolean RejectPaveBlock(const IntTools_Curve& theC, - const Standard_Real theT1, - const Standard_Real theT2, - const TopoDS_Vertex& theV, - Standard_Real& theRT) -{ - Standard_Boolean bIsPeriodic, bClosed, isp, c3d; - Standard_Real aPeriod, dt, pf, pl, dp, aTol; - Handle(Geom_Curve) aC; - // - theRT = BRep_Tool::Tolerance(theV); - aC = theC.Curve(); - // - pf = aC->FirstParameter(); - pl = aC->LastParameter(); - dp = fabs(pl-pf); - aTol=1.e-9; - bIsPeriodic=aC->IsPeriodic(); - bClosed=IntTools_Tools::IsClosed(aC); - // - isp=Standard_False; - if (bIsPeriodic) { - aPeriod=aC->Period(); - isp=(fabs(aPeriod-dp) <= aTol); - dt = fabs(theT2-theT1); - isp = (isp || fabs(aPeriod-dt) <= aTol); - } - c3d=(bClosed || isp); - // - /* - Standard_Boolean isp = (aC->IsPeriodic() && fabs(aC->Period()-dp) <= 1.e-9); - Standard_Real dt = fabs(theT2-theT1); - isp = (isp || (aC->IsPeriodic() && fabs(aC->Period()-dt) <= 1.e-9)); - Standard_Boolean c3d = (aC->IsClosed() || isp); - */ - if(c3d) { - return !c3d; - } - // - Standard_Real p1, p2, tp, d3d2, aRT2;; - // - p1 = Max(pf,theT1); - p2 = Min(pl,theT2); - if(p2 != p1) { - if(p2 < p1) { - tp = p1; - p1 = p2; - p2 = tp; - } - gp_Pnt pntf, pntl; - aC->D0(p1,pntf); - aC->D0(p2,pntl); - // - aRT2=theRT*theRT; - d3d2 = pntf.SquareDistance(pntl); - if(d3d2 > aRT2) { - theRT=sqrt(d3d2); - } - } - return Standard_True; -} - -//======================================================================= -//function : ModifFFTol -//purpose : -//======================================================================= -Standard_Boolean ModifFFTol(const TopoDS_Face& theF1, - const TopoDS_Face& theF2, - Standard_Real& theTF) -{ - Standard_Real t1 = BRep_Tool::Tolerance(theF1), t2 = BRep_Tool::Tolerance(theF2); - theTF = 2* (t1 + t2); - BRepAdaptor_Surface BAS1(theF1); - BRepAdaptor_Surface BAS2(theF2); - - Standard_Boolean isAna1 = (BAS1.GetType() == GeomAbs_Plane || - BAS1.GetType() == GeomAbs_Cylinder || - BAS1.GetType() == GeomAbs_Cone || - BAS1.GetType() == GeomAbs_Sphere); - Standard_Boolean isAna2 = (BAS2.GetType() == GeomAbs_Plane || - BAS2.GetType() == GeomAbs_Cylinder || - BAS2.GetType() == GeomAbs_Cone || - BAS2.GetType() == GeomAbs_Sphere); - - isAna1=isAna1||(BAS1.GetType() == GeomAbs_Torus); - isAna2=isAna2||(BAS2.GetType() == GeomAbs_Torus); - - if(isAna1 && isAna2) - return Standard_False; - - theTF = Max(theTF, 5.e-6); - return Standard_True; -} - - -//======================================================================= -//function : RejectBuildingEdge -//purpose : -//======================================================================= -Standard_Integer RejectBuildingEdge(const IntTools_Curve& theC, - const TopoDS_Vertex& theV1, - const TopoDS_Vertex& theV2, - const Standard_Real theT1, - const Standard_Real theT2, - const TopTools_ListOfShape& theL, - Standard_Real& theTF) -{ - theTF = 1.e-7; - if(theL.Extent() == 0) - return 0; - - Handle(Geom_Curve) aTCurve; - Standard_Real aTT; - - Standard_Integer eIndex = 0; - Standard_Boolean edgeFound = Standard_False; - Handle(Geom_Curve) aCurve = theC.Curve(); - TopTools_ListIteratorOfListOfShape anIt(theL); - for(; anIt.More(); anIt.Next()) { - eIndex++; - const TopoDS_Edge & aE = TopoDS::Edge(anIt.Value()); - if(aE.IsNull()) continue; - TopExp_Explorer ee(aE,TopAbs_VERTEX); - Standard_Boolean v1Found = Standard_False; - Standard_Boolean v2Found = Standard_False; - Standard_Real v1P = 0., v2P = 0; - for(; ee.More(); ee.Next()) { - const TopoDS_Vertex aV = TopoDS::Vertex(ee.Current()); - if(aV.IsNull()) continue; - if(aV.IsEqual(theV1)) { - v1Found = Standard_True; - v1P = BRep_Tool::Parameter(aV,aE); - } - if(aV.IsEqual(theV2)) { - v2Found = Standard_True; - v2P = BRep_Tool::Parameter(aV,aE); - } - } - Standard_Boolean sameParam = Standard_False; - if(v1Found && v2Found) { - if(fabs(theT1-v1P) <= 1.e-8 && fabs(theT2-v2P) <= 1.e-8) - sameParam = Standard_True; - } - if(sameParam) { - Standard_Real f,l; - aTCurve = BRep_Tool::Curve(aE,f,l); - aTT = BRep_Tool::Tolerance(aE); - edgeFound = Standard_True; - } - if(edgeFound) - break; - } - - if(!edgeFound) - return 0; - - gp_Pnt p1 = aTCurve->Value(theT1); - gp_Pnt p2 = aCurve->Value(theT1); - Standard_Real dpf = p1.Distance(p2); - p1 = aTCurve->Value(theT2); - p2 = aCurve->Value(theT2); - Standard_Real dpl = p1.Distance(p2); - Standard_Real dplf = fabs(dpl-dpf); - Standard_Real dpp = Max(dpl,dpf); - - if(dplf > 1.e-7) - return 0; - - Standard_Real maxD = Max(dpl,dpf); - Standard_Boolean inTol = Standard_True; - Standard_Real dp = fabs(theT2-theT1)/23.; - Standard_Integer di = 0; - for(di = 1; di <= 21; di++) { - Standard_Real cp = theT1 + dp*((Standard_Real)di); - p1 = aTCurve->Value(cp); - p2 = aCurve->Value(cp); - Standard_Real d12 = p1.Distance(p2); - maxD = Max(maxD,d12); - if(fabs(d12-dpp) > 1.e-7) { - inTol = Standard_False; - break; - } - } - - if(!inTol) - return 0; - - theTF = maxD; - return eIndex; -} -//======================================================================= -//function : CorrectTolR3D -//purpose : -//======================================================================= -void CorrectTolR3D(BOPTools_PaveFiller& aPF, - const BOPTools_SSInterference& aFF, - const TColStd_MapOfInteger& aMVStick, - Standard_Real& aTolR3D) -{ - Standard_Boolean bHasBounds; - Standard_Integer i, nF[2], nV, aNbCurves; - Standard_Real aT1, aT2, aU, aV, aT, aA, aTolV, aTolVmax; - Standard_Real aTolR, aTolTresh, aAmin, aAmax; - TColStd_MapIteratorOfMapOfInteger aIt; - gp_Pnt aP, aP1, aP2; - gp_Dir aDN[2]; - gp_Vec aVT; - Handle(Geom_Surface) aS[2]; - Handle(Geom_Curve) aC3D; - GeomAdaptor_Surface aGAS; - GeomAbs_SurfaceType aType; - TopoDS_Face aF[2]; - // - BooleanOperations_PShapesDataStructure myDS=aPF.DS(); - const Handle(IntTools_Context)& myContext=aPF.Context(); - // - aTolTresh=0.0005; - aAmin=0.012;// 0.7-7 deg - aAmax=0.12; - // - if (!aMVStick.Extent()) { - return; - } - // - BOPTools_SSInterference& aFFi=*((BOPTools_SSInterference*)&aFF); - BOPTools_SequenceOfCurves& aSCvs=aFFi.Curves(); - aNbCurves=aSCvs.Length(); - if (aNbCurves!=1){ - return; - } - // - aFFi.Indices(nF[0], nF[1]); - for (i=0; i<2; ++i) { - aF[i]=*((TopoDS_Face*)(&myDS->Shape(nF[i]))); - aS[i]=BRep_Tool::Surface(aF[i]); - aGAS.Load(aS[i]); - aType=aGAS.GetType(); - if (aType!=GeomAbs_BSplineSurface) { - return; - } - } - // - BOPTools_Curve& aBC=aSCvs(1); - const IntTools_Curve& aIC=aBC.Curve(); - bHasBounds=aIC.HasBounds(); - if (!bHasBounds){ - return; - } - // - aIC.Bounds (aT1, aT2, aP1, aP2); - aT=IntTools_Tools::IntermediatePoint(aT1, aT2); - aC3D=aIC.Curve(); - aC3D->D0(aT, aP); - // - for (i=0; i<2; ++i) { - GeomAPI_ProjectPointOnSurf& aPPS=myContext->ProjPS(aF[i]); - aPPS.Perform(aP); - aPPS.LowerDistanceParameters(aU, aV); - BOPTools_Tools3D::GetNormalToSurface(aS[i], aU, aV, aDN[i]); - } - // - aA=aDN[0].Angle(aDN[1]); - aA=fabs(aA); - if (aA>0.5*M_PI) { - aA=M_PI-aA; - } - // - if (aAaAmax) { - return; - } - // - aTolVmax=-1.; - aIt.Initialize(aMVStick); - for (; aIt.More(); aIt.Next()) { - nV=aIt.Key(); - const TopoDS_Vertex& aV=*((TopoDS_Vertex*)(&myDS->Shape(nV))); - aTolV=BRep_Tool::Tolerance(aV); - if (aTolV>aTolVmax) { - aTolVmax=aTolV; - } - } - // - aTolR=aTolVmax/aA; - if (aTolRShape(nVC)); - aTC=aPC.Param(); - // - for (j=0; j<2; ++j) { - if (fabs(aTC-aT[j]) < dT) { - aTx=(!j) ? aT[1] : aT[0]; - aPVx.SetIndex(nVC); - aPVx.SetParam(aTx); - // - aCPS.Append(aPVx); - aFFiPS.Append(aPVx); - // - bAdded=Standard_True; - break; - } - } - } -} diff --git a/src/BOPTools/BOPTools_PaveFiller_4.cxx b/src/BOPTools/BOPTools_PaveFiller_4.cxx deleted file mode 100755 index 68ef1e79aa..0000000000 --- a/src/BOPTools/BOPTools_PaveFiller_4.cxx +++ /dev/null @@ -1,150 +0,0 @@ -// Created on: 2002-02-22 -// Created by: Peter KURNEV -// Copyright (c) 2002-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#include -#include - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - - - -static - void GetFullFaceMap(const Standard_Integer nF2, - const BOPTools_InterferencePool& myIntrPool, - TColStd_IndexedMapOfInteger& aMF2); - -static - void GetInterferedVertices(const Standard_Integer nF1, - const TColStd_IndexedMapOfInteger& aMF2, - const BOPTools_InterferencePool& myIntrPool, - TColStd_IndexedMapOfInteger& aMV); - -//======================================================================= -// function: StickVertices -// purpose: -//======================================================================= - void BOPTools_PaveFiller::StickVertices(const Standard_Integer nF1, - const Standard_Integer nF2, - TColStd_IndexedMapOfInteger& aMV) -{ - Standard_Integer i, aNb, iEntity; - TColStd_IndexedMapOfInteger aMF1, aMF2; - // - GetFullFaceMap(nF1, *myIntrPool, aMF1); - GetFullFaceMap(nF2, *myIntrPool, aMF2); - // - aNb=aMF1.Extent(); - for (i=1; i<=aNb; ++i) { - iEntity=aMF1(i); - GetInterferedVertices(iEntity, aMF2, *myIntrPool, aMV); - } - // - aNb=aMF2.Extent(); - for (i=1; i<=aNb; ++i) { - iEntity=aMF2(i); - GetInterferedVertices(iEntity, aMF1, *myIntrPool, aMV); - } -} - -//======================================================================= -// function: GetFullFaceMap -// purpose: -//======================================================================= -void GetFullFaceMap(const Standard_Integer nF2, - const BOPTools_InterferencePool& anIntrPool, - TColStd_IndexedMapOfInteger& aMF2) -{ - Standard_Integer nEF2, nVF2; - // - aMF2.Add(nF2); - BooleanOperations_PShapesDataStructure myDS=anIntrPool.DS(); - BooleanOperations_OnceExplorer aExp(*myDS); - aExp.Init(nF2, TopAbs_EDGE); - for (; aExp.More(); aExp.Next()) { - nEF2=aExp.Current(); - aMF2.Add(nEF2); - } - // - aExp.Init(nF2, TopAbs_VERTEX); - for (; aExp.More(); aExp.Next()) { - nVF2=aExp.Current(); - aMF2.Add(nVF2); - } -} -//======================================================================= -// function: GetInterferedVertices -// purpose: -//======================================================================= -void GetInterferedVertices(const Standard_Integer nF1, - const TColStd_IndexedMapOfInteger& aMF2, - const BOPTools_InterferencePool& anIntrPool, - TColStd_IndexedMapOfInteger& aMV) -{ - Standard_Integer aIndex, aNewShape, aWith; - BooleanOperations_KindOfInterference aType; - TopAbs_ShapeEnum aShapeType; - BOPTools_ListIteratorOfListOfInterference anIt; - BOPTools_PShapeShapeInterference pI; - // - BooleanOperations_PShapesDataStructure myDS=anIntrPool.DS(); - const BOPTools_CArray1OfInterferenceLine& aITable= anIntrPool.InterferenceTable(); - const BOPTools_InterferenceLine& aILineF1=aITable(nF1); - const BOPTools_ListOfInterference& aLIF1=aILineF1.RealList(); - - // - anIt.Initialize(aLIF1); - for (; anIt.More(); anIt.Next()) { - const BOPTools_Interference& anInterference=anIt.Value(); - aWith=anInterference.With(); - if (aMF2.Contains(aWith)) { - aIndex=anInterference.Index(); - aType= anInterference.Type(); - pI=anIntrPool.GetInterference(aIndex, aType); - if (pI!=NULL) { - //aNewShape=anIntrPool.NewShape(aIndex, aType); - aNewShape=pI->NewShape(); - if (aNewShape) { - const TopoDS_Shape& aS=myDS->Shape(aNewShape); - aShapeType=aS.ShapeType(); - if (aShapeType==TopAbs_VERTEX) { - aMV.Add(aNewShape); - } - } - } - } - } -} - - - - - diff --git a/src/BOPTools/BOPTools_PaveSet.cdl b/src/BOPTools/BOPTools_PaveSet.cdl deleted file mode 100755 index bacc54d42d..0000000000 --- a/src/BOPTools/BOPTools_PaveSet.cdl +++ /dev/null @@ -1,62 +0,0 @@ --- Created on: 2001-02-08 --- Created by: Peter KURNEV --- Copyright (c) 2001-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class PaveSet from BOPTools - - ---Purpose: - -- class for storing/sorting paves that - -- belong to an edge - -uses - ListOfPave from BOPTools, - Pave from BOPTools - -is - Create - returns PaveSet from BOPTools; - ---Purpose: - --- Empty constructor - --- - ChangeSet(me:out) - returns ListOfPave from BOPTools; - ---C++: return & - ---Purpose: - --- Access to the list - --- - Set(me) - returns ListOfPave from BOPTools; - ---C++: return const & - ---Purpose: - --- Access to the list const - --- - Append (me:out; aPave:Pave from BOPTools); - ---Purpose: - --- Appends to the list - --- - SortSet (me:out); - ---Purpose: - --- Sorts list in increasing order of paves' parameters - --- - -fields - myPaveList: ListOfPave from BOPTools; - -end PaveSet; diff --git a/src/BOPTools/BOPTools_PaveSet.cxx b/src/BOPTools/BOPTools_PaveSet.cxx deleted file mode 100755 index f4736b8451..0000000000 --- a/src/BOPTools/BOPTools_PaveSet.cxx +++ /dev/null @@ -1,95 +0,0 @@ -// Created on: 2001-02-08 -// Created by: Peter KURNEV -// Copyright (c) 2001-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include - -#include -#include -#include -#include - -#ifdef WNT -#pragma warning ( disable : 4101 ) -#endif - -//======================================================================= -// function: BOPTools_PaveSet::BOPTools_PaveSet -// purpose: -//======================================================================= - BOPTools_PaveSet::BOPTools_PaveSet() {} - -//======================================================================= -// function: ChangeSet -// purpose: -//======================================================================= - BOPTools_ListOfPave& BOPTools_PaveSet::ChangeSet() -{ - return myPaveList; -} -//======================================================================= -// function: Set -// purpose: -//======================================================================= - const BOPTools_ListOfPave& BOPTools_PaveSet::Set() const -{ - return myPaveList; -} -//======================================================================= -// function: Append -// purpose: -//======================================================================= - void BOPTools_PaveSet::Append(const BOPTools_Pave& aPave) -{ - myPaveList.Append(aPave); -} -//======================================================================= -// function: SortSet -// purpose: -//======================================================================= - void BOPTools_PaveSet::SortSet() -{ - // Not implemented yet - Standard_Integer aNbPaves, i; - aNbPaves=myPaveList.Extent(); - if (aNbPaves>1) { - BOPTools_Array1OfPave anArray1OfPave (1, aNbPaves); - - BOPTools_ListIteratorOfListOfPave anIt(myPaveList); - - for (i=1; anIt.More(); anIt.Next(), i++) { - const BOPTools_Pave& aPave=anIt.Value(); - anArray1OfPave(i)=aPave; - } - - BOPTools_QuickSortPave aQuickSortPave; - BOPTools_ComparePave aComparePave; - aQuickSortPave.Sort (anArray1OfPave, aComparePave); - - myPaveList.Clear(); - for (i=1; i<=aNbPaves; i++){ - const BOPTools_Pave& aPave=anArray1OfPave(i); - myPaveList.Append (aPave); - } - } -} -#ifdef WNT -#pragma warning ( default : 4101 ) -#endif diff --git a/src/BOPTools/BOPTools_PointBetween.cdl b/src/BOPTools/BOPTools_PointBetween.cdl deleted file mode 100755 index 5e1068dbe1..0000000000 --- a/src/BOPTools/BOPTools_PointBetween.cdl +++ /dev/null @@ -1,84 +0,0 @@ --- Created on: 2001-04-19 --- Created by: Peter KURNEV --- Copyright (c) 2001-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class PointBetween from BOPTools - - ---Purpose: - -- class for storing geometry information about - -- a point between neighbouring paves along - -- an edge - --- -uses - Pnt from gp - - - -is - Create - returns PointBetween from BOPTools; - ---Purpose: - --- Empty constructor - --- - SetParameter (me:out; - T:Real from Standard); - ---Purpose: - --- Modifier - --- sets value of the point's parameter on the edge - --- - SetUV (me:out; - U:Real from Standard; - V:Real from Standard); - ---Purpose: - --- Modifier - --- sets values of the point's parameter on the face - --- - SetPnt (me:out; - aP:Pnt from gp); - ---Purpose: - --- Modifier - --- sets the 3D-point - --- - Parameter (me) - returns Real from Standard ; - ---Purpose: - --- Selector - --- - UV (me; - U:out Real from Standard; - V:out Real from Standard); - ---Purpose: - --- Selector - --- - Pnt (me) - returns Pnt from gp; - ---C++: return const & - ---Purpose: - --- Selector - --- - -fields - - myT : Real from Standard; - myU : Real from Standard; - myV : Real from Standard; - myPnt: Pnt from gp; - -end PointBetween; diff --git a/src/BOPTools/BOPTools_PointBetween.cxx b/src/BOPTools/BOPTools_PointBetween.cxx deleted file mode 100755 index d676012afd..0000000000 --- a/src/BOPTools/BOPTools_PointBetween.cxx +++ /dev/null @@ -1,90 +0,0 @@ -// Created on: 2001-04-19 -// Created by: Peter KURNEV -// Copyright (c) 2001-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include - -//======================================================================= -// function: BOPTools_PointBetween:: BOPTools_PointBetween -// purpose: -//======================================================================= -BOPTools_PointBetween::BOPTools_PointBetween() -: - myT(0.), - myU(0.), - myV(0.) -{} - -//======================================================================= -// function: SetParameter -// purpose: -//======================================================================= - void BOPTools_PointBetween::SetParameter(const Standard_Real aT) -{ - myT=aT; -} - -//======================================================================= -// function: Parameter -// purpose: -//======================================================================= - Standard_Real BOPTools_PointBetween::Parameter()const -{ - return myT; -} - -//======================================================================= -// function: SetUV -// purpose: -//======================================================================= - void BOPTools_PointBetween::SetUV(const Standard_Real aU, - const Standard_Real aV) -{ - myU=aU; - myV=aV; -} -//======================================================================= -// function: UV -// purpose: -//======================================================================= - void BOPTools_PointBetween::UV(Standard_Real& aU, - Standard_Real& aV) const -{ - aU=myU; - aV=myV; -} - -//======================================================================= -// function: SetPnt -// purpose: -//======================================================================= - void BOPTools_PointBetween::SetPnt (const gp_Pnt& aP) -{ - myPnt=aP; -} - -//======================================================================= -// function: Pnt -// purpose: -//======================================================================= - const gp_Pnt& BOPTools_PointBetween::Pnt () const -{ - return myPnt; -} diff --git a/src/BOPTools/BOPTools_RoughShapeIntersector.cdl b/src/BOPTools/BOPTools_RoughShapeIntersector.cdl deleted file mode 100755 index acc8f74722..0000000000 --- a/src/BOPTools/BOPTools_RoughShapeIntersector.cdl +++ /dev/null @@ -1,97 +0,0 @@ --- Created on: 2000-11-24 --- Created by: Michael KLOKOV --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class RoughShapeIntersector from BOPTools - - ---Purpose: The class RoughShapeIntersector describes the algorithm of - -- intersection of bounding boxes of - -- shapes stored in ShapesDataStructure. - -- It stores statuses of intersection in 2 dimension array. - -uses - Array1OfListOfInteger from TColStd, - ListOfInteger from TColStd, - HArray2OfIntersectionStatus from BOPTools, - IntersectionStatus from BOPTools, - HArray1OfBox from Bnd, - PShapesDataStructure from BooleanOperations -is - - Create(PDS: PShapesDataStructure from BooleanOperations) - returns RoughShapeIntersector from BOPTools; - ---Purpose: - -- Initializes algorithm by shapes data structure - -- - - Perform(me: in out); - ---Purpose: - -- Perform computations. - -- - -- Warning: - -- Using this function, after the destructor of - -- the object pointed by PDS (see constructor) - -- was invoked, lead to crash. - -- - - TableOfStatus(me) - returns HArray2OfIntersectionStatus from BOPTools; - ---C++: return const & - ---Purpose: - -- Returns 2 dimension array of status flags. - -- First indices of the array corresponds to indices of - -- subshapes of Object of myPDS. - -- Second indices of array corresponds to indices of - -- subshapes of Tool of myPDS. - -- - - IsDone(me) returns Boolean from Standard; - ---Purpose: - -- Returns False if some errors occured during - -- computations or method Perform - -- was not invoked before, - -- otherwise returns True. - -- - - -- private methods - Prepare(me: in out) - is private; - - PropagateForSuccessors1(me: in out; AncestorsIndex1: Integer from Standard; - AncestorsIndex2: Integer from Standard; - theStatus : IntersectionStatus from BOPTools) - is private; - - PropagateForSuccessors2(me: in out; AncestorsIndex1: Integer from Standard; - AncestorsIndex2: Integer from Standard; - theStatus : IntersectionStatus from BOPTools) - is private; - -fields - myPDS: PShapesDataStructure from BooleanOperations; - myBoundingBoxes: HArray1OfBox from Bnd; - - myTableOfStatus: HArray2OfIntersectionStatus from BOPTools; - ---Purpose: First indices of array corresponds to indices of subshapes of Object of myPDS. - -- Second indices of array corresponds to indices of subshapes of Tool of myPDS. - - myIsDone: Boolean from Standard; - -end RoughShapeIntersector from BOPTools; - diff --git a/src/BOPTools/BOPTools_RoughShapeIntersector.cxx b/src/BOPTools/BOPTools_RoughShapeIntersector.cxx deleted file mode 100755 index 205afb9d1f..0000000000 --- a/src/BOPTools/BOPTools_RoughShapeIntersector.cxx +++ /dev/null @@ -1,239 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include - -#include -#include -#include -#include -#include -#include - -static Standard_Integer TypeToIndex(const TopAbs_ShapeEnum& theType); - -static Bnd_Box GetBoxEnlargedBySubShape(const Standard_Integer theIndex, - const BooleanOperations_PShapesDataStructure& PDS); - - -// ============================================================================================= -// function: Constructor -// ============================================================================================= - BOPTools_RoughShapeIntersector::BOPTools_RoughShapeIntersector(const BooleanOperations_PShapesDataStructure& PDS) -: - myIsDone(Standard_False) -{ - myPDS = PDS; -} - -// ============================================================================================= -// function: Perform -// ============================================================================================= - void BOPTools_RoughShapeIntersector::Perform() -{ - myIsDone = Standard_True; - - Prepare(); - - // check flag myIsDone after Prepare() function - if(!myIsDone) - return; - TColStd_ListOfInteger thelist; - TColStd_Array1OfListOfInteger aSortedByTypeShapes1(TypeToIndex(TopAbs_COMPOUND), TypeToIndex(TopAbs_VERTEX)); - aSortedByTypeShapes1.Init(thelist); - - TColStd_ListOfInteger thelist1; - TColStd_Array1OfListOfInteger aSortedByTypeShapes2(TypeToIndex(TopAbs_COMPOUND), TypeToIndex(TopAbs_VERTEX)); - aSortedByTypeShapes2.Init(thelist1); - - Standard_Integer k = 0; - - for(k = myTableOfStatus->LowerRow(); k <= myTableOfStatus->UpperRow(); k++) { - aSortedByTypeShapes1(TypeToIndex(myPDS->GetShapeType(k))).Append(k); - } - - for(k = myTableOfStatus->LowerCol(); k <= myTableOfStatus->UpperCol(); k++) { - aSortedByTypeShapes2(TypeToIndex(myPDS->GetShapeType(k))).Append(k); - } - - // - Standard_Integer aStartIndex = TypeToIndex(TopAbs_COMPOUND); - Standard_Integer anEndIndex = TypeToIndex(TopAbs_VERTEX); - - for(Standard_Integer index1 = aStartIndex; index1 <= anEndIndex; index1++) { - // - if(aSortedByTypeShapes1(index1).IsEmpty()) - continue; - - for(Standard_Integer index2 = aStartIndex; index2 <= anEndIndex; index2++) { - if(aSortedByTypeShapes2(index2).IsEmpty()) - continue; - - TColStd_ListIteratorOfListOfInteger anIt1; - TColStd_ListIteratorOfListOfInteger anIt2; - - for(anIt1.Initialize(aSortedByTypeShapes1.Value(index1)); anIt1.More(); anIt1.Next()) { - for(anIt2.Initialize(aSortedByTypeShapes2.Value(index2)); anIt2.More(); anIt2.Next()) { - - // - BOPTools_IntersectionStatus aStatus = myTableOfStatus->Value(anIt1.Value(), anIt2.Value()); - - if(aStatus != BOPTools_UNKNOWN && aStatus != BOPTools_BOUNDINGBOXOFSUBSHAPESINTERSECTED) - continue; - - const Bnd_Box& B1 = myBoundingBoxes->Value(anIt1.Value()); - const Bnd_Box& B2 = myBoundingBoxes->Value(anIt2.Value()); - // - BOPTools_IntersectionStatus aNewValue = BOPTools_BOUNDINGBOXINTERSECTED; - - if(B1.IsOut(B2)) { - aNewValue = BOPTools_NONINTERSECTED; - // - PropagateForSuccessors1(anIt1.Value(), anIt2.Value(), aNewValue); - // - } - else { - aNewValue = BOPTools_BOUNDINGBOXINTERSECTED; - const Bnd_Box& BB1 = myPDS->GetBoundingBox(anIt1.Value()); - const Bnd_Box& BB2 = myPDS->GetBoundingBox(anIt2.Value()); - - if(BB1.IsOut(BB2)) { - aNewValue = BOPTools_BOUNDINGBOXOFSUBSHAPESINTERSECTED; - } - } - // It is important to place this line after Propagation - myTableOfStatus->ChangeValue(anIt1.Value(), anIt2.Value()) = aNewValue; - } - } - } - } -} - -// ============================================================================================= -// function: TableOfStatus -// ============================================================================================= -const Handle(BOPTools_HArray2OfIntersectionStatus)& BOPTools_RoughShapeIntersector::TableOfStatus() const -{ - return myTableOfStatus; -} - -// ============================================================================================= -// function: Prepare -// ============================================================================================= -void BOPTools_RoughShapeIntersector::Prepare() -{ - myIsDone = Standard_False; - - if(!myTableOfStatus.IsNull() && - (myPDS != NULL) && - (myTableOfStatus->LowerRow() == 1) && - (myTableOfStatus->UpperRow() == myPDS->NumberOfShapesOfTheObject()) && - (myTableOfStatus->LowerCol() == myPDS->NumberOfShapesOfTheObject() + 1) && - (myTableOfStatus->UpperCol() == myPDS->NumberOfShapesOfTheObject() + myPDS->NumberOfShapesOfTheTool())) { - myIsDone = Standard_True; - } - else { - if(myPDS != NULL) { - Standard_Integer firstlowerindex = 1; - Standard_Integer firstupperindex = myPDS->NumberOfShapesOfTheObject(); - Standard_Integer secondlowerindex = myPDS->NumberOfShapesOfTheObject() + 1; - Standard_Integer secondupperindex = myPDS->NumberOfShapesOfTheTool() + myPDS->NumberOfShapesOfTheObject(); - myTableOfStatus = new BOPTools_HArray2OfIntersectionStatus(firstlowerindex, firstupperindex, - secondlowerindex, secondupperindex); - myIsDone = Standard_True; - } - } - if(!myIsDone) - return; - - myTableOfStatus->Init(BOPTools_UNKNOWN); - // - myBoundingBoxes = new Bnd_HArray1OfBox(1, myPDS->NumberOfSourceShapes()); - - for(Standard_Integer i = 1; i <= myPDS->NumberOfSourceShapes(); i++) { - const Bnd_Box& aBox = GetBoxEnlargedBySubShape(i, myPDS); - myBoundingBoxes->SetValue(i, aBox); - } -} - -// ============================================================================================= -// function: IsDone -// ============================================================================================= - Standard_Boolean BOPTools_RoughShapeIntersector::IsDone() const -{ - return myIsDone; -} - -// ============================================================================================= -// function: PropagateForSuccessors1 -// ============================================================================================= -void BOPTools_RoughShapeIntersector::PropagateForSuccessors1(const Standard_Integer AncestorsIndex1, - const Standard_Integer AncestorsIndex2, - const BOPTools_IntersectionStatus theStatus) -{ - if(myTableOfStatus->Value(AncestorsIndex1, AncestorsIndex2) != BOPTools_UNKNOWN) - return; - - myTableOfStatus->ChangeValue(AncestorsIndex1, AncestorsIndex2) = theStatus; - - PropagateForSuccessors2(AncestorsIndex1, AncestorsIndex2, theStatus); - Standard_Integer i = 1; - - for(i = 1; i <= myPDS->NumberOfSuccessors(AncestorsIndex1); i++) { - Standard_Integer asuccessor1 = myPDS->GetSuccessor(AncestorsIndex1, i); - PropagateForSuccessors1(asuccessor1, AncestorsIndex2, theStatus); - } -} - -// ============================================================================================= -// function: PropagateForSuccessors2 -// ============================================================================================= -void BOPTools_RoughShapeIntersector::PropagateForSuccessors2(const Standard_Integer AncestorsIndex1, - const Standard_Integer AncestorsIndex2, - const BOPTools_IntersectionStatus theStatus) -{ - for(Standard_Integer j = 1; j <= myPDS->NumberOfSuccessors(AncestorsIndex2); j++) { - Standard_Integer asuccessor2 = myPDS->GetSuccessor(AncestorsIndex2, j); - - if(myTableOfStatus->Value(AncestorsIndex1, asuccessor2) == BOPTools_UNKNOWN) { - myTableOfStatus->ChangeValue(AncestorsIndex1, asuccessor2) = theStatus; - - PropagateForSuccessors2(AncestorsIndex1, asuccessor2, theStatus); - } - } -} - -// ============================================================================================= -// function: TypeToIndex -// ============================================================================================= - Standard_Integer TypeToIndex(const TopAbs_ShapeEnum& theType) { - return (Standard_Integer) theType; -} - -// ============================================================================================= -// function: GetBoxEnlargedBySubShape -// ============================================================================================= -Bnd_Box GetBoxEnlargedBySubShape(const Standard_Integer theIndex, - const BooleanOperations_PShapesDataStructure& PDS) { - Bnd_Box aBox = PDS->GetBoundingBox(theIndex); - - for(Standard_Integer i=1; i<= PDS->NumberOfSuccessors(theIndex); i++) { - Standard_Integer asuccessorindex = PDS->GetSuccessor(theIndex, i); - aBox.Add(GetBoxEnlargedBySubShape(asuccessorindex, PDS)); - } - return aBox; -} diff --git a/src/BOPTools/BOPTools_SSInterference.cdl b/src/BOPTools/BOPTools_SSInterference.cdl deleted file mode 100755 index 897d8e3f17..0000000000 --- a/src/BOPTools/BOPTools_SSInterference.cdl +++ /dev/null @@ -1,187 +0,0 @@ --- Created on: 2000-11-21 --- Created by: Peter KURNEV --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class SSInterference from BOPTools - inherits ShapeShapeInterference from BOPTools - - ---Purpose: class for storing a Face/Face interference - --- Each F/F interference contains information about - --- 1. myPBs - PaveBlocks (made from edges from the faces - --- that are IN-2D or ON-2D; - --- 2. myCurves- Sequence of curves of intersection; - --- 3. myTangentFacesFlag - The BOOL flag indicates that - --- the faces are SD in terms of the F/F Intersector. - --- 4. mySenseFlag - value that is equal +1 or -1 depending - --- on scalar product between normals to each face. This - --- valie is valid for the SDF only. - --- 5. myAlonePnts - contains 3D-points that are place - --- of intersection between the two faces - --- 6. myAloneVertices - contains indices of vertices - --- that correspond to the points myAlonePnts; - --- - -uses - - PaveBlock from BOPTools, - PaveSet from BOPTools, - ListOfPaveBlock from BOPTools, - SequenceOfCurves from BOPTools, - IndexedDataMapOfIntegerState from BOPTools, - - SequenceOfCurves from IntTools, - SequenceOfPntOn2Faces from IntTools, - - ListOfInteger from TColStd - -- -is - Create - returns SSInterference from BOPTools; - ---Purpose: - --- Empty constructor - --- - Create (anIndex1: Integer from Standard; - anIndex2: Integer from Standard; - aTolR3D : Real from Standard; - aTolR2D : Real from Standard; - aCurves : SequenceOfCurves from IntTools; - aPnts : SequenceOfPntOn2Faces from IntTools) - returns SSInterference from BOPTools; - ---Purpose: - --- Constructor - --- anIndex1, - --- anIndex2 see BOPTools_ShapeShapeInterference for details - --- aTolR3D - value of tolerance to reach in 3D-space - --- aTolR2D - value of tolerance to reach in 2D-space - --- aCurves see IntTools_Curve for details, please - --- - AppendBlock(me:out; - aPB:PaveBlock from BOPTools); - ---Purpose: - --- Modifier - --- - PaveBlocks(me) - returns ListOfPaveBlock from BOPTools; - ---C++: return const & - ---Purpose: - --- Selector - --- - NewPaveSet(me:out) - returns PaveSet from BOPTools; - ---C++: return & - ---Purpose: - --- Selector - --- - TolR3D (me) - returns Real from Standard; - ---Purpose: - --- Selector - --- - TolR2D (me) - returns Real from Standard; - ---Purpose: - --- Selector - --- - Curves(me:out) - returns SequenceOfCurves from BOPTools; - ---C++: return & - ---Purpose: - --- Selector - --- - SetTangentFacesFlag(me:out; - aFlag:Boolean from Standard); - ---Purpose: - --- Modifier - --- - IsTangentFaces(me) - returns Boolean from Standard; - ---Purpose: - --- Selector - --- - SetSenseFlag (me:out; - aFlag:Integer from Standard); - ---Purpose: - --- Modifier - --- - SenseFlag (me) - returns Integer from Standard; - ---Purpose: - --- Selector - --- - SetStatesMap(me:out; - aStatesMap: IndexedDataMapOfIntegerState from BOPTools); - ---Purpose: - --- Modifier - --- - StatesMap(me) - returns IndexedDataMapOfIntegerState from BOPTools; - ---C++: return const & - ---Purpose: - --- Selector - --- - SetAlonePnts(me:out; - aPnts:SequenceOfPntOn2Faces from IntTools); - ---Purpose: - --- Modifier - --- - AlonePnts(me) - returns SequenceOfPntOn2Faces from IntTools; - ---C++: return const & - ---Purpose: - --- Selector - --- - AloneVertices(me:out) - returns ListOfInteger from TColStd; - ---C++: return & - ---Purpose: - --- Selector - --- - --modified by NIZNHY-PKV Fri Jun 30 10:05:36 2006f - SetSharedEdges(me:out; - aLS:ListOfInteger from TColStd); - ---Purpose: - --- Modifier - --- - SharedEdges(me) - returns ListOfInteger from TColStd; - ---C++: return const & - ---Purpose: - --- Selector - --- - --modified by NIZNHY-PKV Fri Jun 30 10:05:41 2006t - -fields - - myPBs : ListOfPaveBlock from BOPTools is protected; - myNewPaveSet : PaveSet from BOPTools is protected; - myTolR3D : Real from Standard is protected; - myTolR2D : Real from Standard is protected; - - myCurves : SequenceOfCurves from BOPTools is protected; - myAlonePnts : SequenceOfPntOn2Faces from IntTools is protected; - myAloneVertices : ListOfInteger from TColStd is protected; - - myTangentFacesFlag : Boolean from Standard is protected; - mySenseFlag : Integer from Standard is protected; - myStatesMap : IndexedDataMapOfIntegerState from BOPTools is protected; ---modified by NIZNHY-PKV Fri Jun 30 10:02:27 2006f - mySharedEdges : ListOfInteger from TColStd is protected; ---modified by NIZNHY-PKV Fri Jun 30 10:02:34 2006 -end SSInterference; diff --git a/src/BOPTools/BOPTools_SSInterference.cxx b/src/BOPTools/BOPTools_SSInterference.cxx deleted file mode 100755 index a6dfbf6628..0000000000 --- a/src/BOPTools/BOPTools_SSInterference.cxx +++ /dev/null @@ -1,265 +0,0 @@ -// Created on: 2000-11-21 -// Created by: Peter KURNEV -// Copyright (c) 2000-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include - -#include -#include -#include -#include - -#include -//modified by NIZNHY-PKV Fri Jun 30 10:08:51 2006 -#include -#include -#include -#include - - -//======================================================================= -//function : BOPTools_SSInterference -//purpose : -//======================================================================= -BOPTools_SSInterference::BOPTools_SSInterference() -: - BOPTools_ShapeShapeInterference(0, 0), - myTangentFacesFlag(Standard_False), - mySenseFlag(0) -{} - -//======================================================================= -//function : BOPTools_SSInterference::BOPTools_SSInterference -//purpose : -//======================================================================= - BOPTools_SSInterference::BOPTools_SSInterference - (const Standard_Integer anIndex1, - const Standard_Integer anIndex2, - const Standard_Real aTolR3D, - const Standard_Real aTolR2D, - const IntTools_SequenceOfCurves& aCvs, - const IntTools_SequenceOfPntOn2Faces& aPnts) -: - BOPTools_ShapeShapeInterference(anIndex1, anIndex2), - myTangentFacesFlag(Standard_False), - mySenseFlag(0) -{ - myTolR3D=aTolR3D; - myTolR2D=aTolR2D; - - myCurves.Clear(); - Standard_Integer i, aNbCurves; - aNbCurves=aCvs.Length(); - for (i=1; i<=aNbCurves; i++) { - const IntTools_Curve& aIC=aCvs(i); - BOPTools_Curve aBC(aIC); - myCurves.Append(aBC); - } - // - SetAlonePnts(aPnts); -} -//======================================================================= -//function : AppendBlock -//purpose : -//======================================================================= - void BOPTools_SSInterference::AppendBlock(const BOPTools_PaveBlock& aPB) -{ - myPBs.Append(aPB); -} - -//======================================================================= -//function : PaveBlocks -//purpose : -//======================================================================= - const BOPTools_ListOfPaveBlock& BOPTools_SSInterference::PaveBlocks() const -{ - return myPBs; -} - -//======================================================================= -//function : TolR3D -//purpose : -//======================================================================= - Standard_Real BOPTools_SSInterference::TolR3D() const -{ - return myTolR3D; -} - -//======================================================================= -//function : TolR2D -//purpose : -//======================================================================= - Standard_Real BOPTools_SSInterference::TolR2D() const -{ - return myTolR2D; -} - -//======================================================================= -//function : Curves -//purpose : -//======================================================================= - BOPTools_SequenceOfCurves& BOPTools_SSInterference::Curves() -{ - return myCurves; -} - -//======================================================================= -//function : NewPaveSet -//purpose : -//======================================================================= - BOPTools_PaveSet& BOPTools_SSInterference::NewPaveSet() -{ - return myNewPaveSet; -} - -//======================================================================= -//function : SetTangentFacesFlag -//purpose : -//======================================================================= - void BOPTools_SSInterference::SetTangentFacesFlag(const Standard_Boolean aFlag) -{ - myTangentFacesFlag=aFlag; -} -//======================================================================= -//function : IsTangentFaces -//purpose : -//======================================================================= - Standard_Boolean BOPTools_SSInterference::IsTangentFaces()const -{ - return myTangentFacesFlag; -} - -//======================================================================= -// function: SetSenseFlag -// purpose: -//======================================================================= - void BOPTools_SSInterference::SetSenseFlag (const Standard_Integer iFlag) - -{ - mySenseFlag=iFlag; -} -//======================================================================= -// function: SenseFlag -// purpose: -//======================================================================= - Standard_Integer BOPTools_SSInterference::SenseFlag () const - -{ - return mySenseFlag; -} -//======================================================================= -// function: SetStatesMap -// purpose: -//======================================================================= - void BOPTools_SSInterference::SetStatesMap (const BOPTools_IndexedDataMapOfIntegerState& aMap) -{ - myStatesMap=aMap; -} -//======================================================================= -// function: StatesMap -// purpose: -//======================================================================= - const BOPTools_IndexedDataMapOfIntegerState& BOPTools_SSInterference::StatesMap () const -{ - return myStatesMap; -} - -//======================================================================= -// function: SetAlonePnts -// purpose: -//======================================================================= - void BOPTools_SSInterference::SetAlonePnts (const IntTools_SequenceOfPntOn2Faces& aPnts) -{ - Standard_Integer i, aNb; - myAlonePnts.Clear(); - - aNb=aPnts.Length(); - for (i=1; i<=aNb; ++i) { - const IntTools_PntOn2Faces& aPntOn2Faces=aPnts(i); - myAlonePnts.Append(aPntOn2Faces); - } -} - -//======================================================================= -// function: AlonePnts -// purpose: -//======================================================================= - const IntTools_SequenceOfPntOn2Faces& BOPTools_SSInterference::AlonePnts ()const -{ - return myAlonePnts; -} - -//======================================================================= -// function: AloneVertices -// purpose: -//======================================================================= - TColStd_ListOfInteger& BOPTools_SSInterference::AloneVertices () -{ - return myAloneVertices; -} -//modified by NIZNHY-PKV Fri Jun 30 10:06:12 2006f -//======================================================================= -// function: SetSharedEdges -// purpose: -//======================================================================= - void BOPTools_SSInterference::SetSharedEdges (const TColStd_ListOfInteger& aLS) -{ - Standard_Integer nE; - TColStd_ListIteratorOfListOfInteger aIt; - // - aIt.Initialize(aLS); - for(; aIt.More(); aIt.Next()) { - nE=aIt.Value(); - mySharedEdges.Append(nE); - } -} -//======================================================================= -// function: SharedEdges -// purpose: -//======================================================================= - const TColStd_ListOfInteger& BOPTools_SSInterference::SharedEdges()const -{ - return mySharedEdges; -} -/* -//======================================================================= -// function: SetSharedEdges -// purpose: -//======================================================================= - void BOPTools_SSInterference::SetSharedEdges (const TopTools_ListOfShape& aLS) -{ - TopTools_ListIteratorOfListOfShape aIt; - // - aIt.Initialize(aLS); - for(; aIt.More(); aIt.Next()) { - const TopoDS_Shape& aE=aIt.Value(); - mySharedEdges.Append(aE); - } -} -//======================================================================= -// function: SharedEdges -// purpose: -//======================================================================= - const TopTools_ListOfShape& BOPTools_SSInterference::SharedEdges()const -{ - return mySharedEdges; -} -*/ -//modified by NIZNHY-PKV Fri Jun 30 10:06:14 2006t diff --git a/src/BOPTools/BOPTools_SSIntersectionAttribute.cdl b/src/BOPTools/BOPTools_SSIntersectionAttribute.cdl deleted file mode 100755 index 1b65c18af5..0000000000 --- a/src/BOPTools/BOPTools_SSIntersectionAttribute.cdl +++ /dev/null @@ -1,78 +0,0 @@ --- Created on: 2002-03-04 --- Created by: Michael KLOKOV --- Copyright (c) 2002-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class SSIntersectionAttribute from BOPTools - - ---Purpose: Class is a container of three flags used - --- by intersection algorithm - --- - -is - - Create(Aproximation : Boolean from Standard = Standard_True; - PCurveOnS1 : Boolean from Standard = Standard_True; - PCurveOnS2 : Boolean from Standard = Standard_True) - returns SSIntersectionAttribute from BOPTools; - ---Purpose: - --- Initializes me by flags - --- - - Approximation(me: in out; theFlag: Boolean from Standard); - ---Purpose: - --- Modifier - --- - - PCurveOnS1(me: in out; theFlag: Boolean from Standard); - ---Purpose: - --- Modifier - --- - - PCurveOnS2(me: in out; theFlag: Boolean from Standard); - ---Purpose: - --- Modifier - --- - - Approximation(me) - returns Boolean from Standard; - ---C++: inline - ---Purpose: - --- Selector - --- - - PCurveOnS1(me) - returns Boolean from Standard; - ---C++: inline - ---Purpose: - --- Selector - --- - - PCurveOnS2(me) - returns Boolean from Standard; - ---C++: inline - ---Purpose: - --- Selector - --- - -fields - myApproximation : Boolean from Standard; - myPCurve1 : Boolean from Standard; - myPCurve2 : Boolean from Standard; - -end SSIntersectionAttribute from BOPTools; diff --git a/src/BOPTools/BOPTools_SSIntersectionAttribute.cxx b/src/BOPTools/BOPTools_SSIntersectionAttribute.cxx deleted file mode 100755 index 6ce0900c81..0000000000 --- a/src/BOPTools/BOPTools_SSIntersectionAttribute.cxx +++ /dev/null @@ -1,59 +0,0 @@ -// Created on: 2002-03-04 -// Created by: Michael KLOKOV -// Copyright (c) 2002-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include -//======================================================================= -// function: BOPTools_SSIntersectionAttribute -// purpose: -//======================================================================= -BOPTools_SSIntersectionAttribute::BOPTools_SSIntersectionAttribute(const Standard_Boolean Aproximation, - const Standard_Boolean PCurveOnS1, - const Standard_Boolean PCurveOnS2) -{ - myApproximation = Aproximation; - myPCurve1 = PCurveOnS1; - myPCurve2 = PCurveOnS2; -} -//======================================================================= -// function: Approximation -// purpose: -//======================================================================= -void BOPTools_SSIntersectionAttribute::Approximation(const Standard_Boolean theFlag) -{ - myApproximation = theFlag; -} -//======================================================================= -// function: PCurveOnS1 -// purpose: -//======================================================================= -void BOPTools_SSIntersectionAttribute::PCurveOnS1(const Standard_Boolean theFlag) -{ - myPCurve1 = theFlag; -} -//======================================================================= -// function: PCurveOnS2 -// purpose: -//======================================================================= -void BOPTools_SSIntersectionAttribute::PCurveOnS2(const Standard_Boolean theFlag) -{ - myPCurve2 = theFlag; -} - diff --git a/src/BOPTools/BOPTools_SSIntersectionAttribute.lxx b/src/BOPTools/BOPTools_SSIntersectionAttribute.lxx deleted file mode 100755 index 91c85e4f2c..0000000000 --- a/src/BOPTools/BOPTools_SSIntersectionAttribute.lxx +++ /dev/null @@ -1,45 +0,0 @@ -// Created on: 2002-03-04 -// Created by: Michael KLOKOV -// Copyright (c) 2002-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -//======================================================================= -// function:Approximation -// purpose: -//======================================================================= -inline Standard_Boolean BOPTools_SSIntersectionAttribute::Approximation() const -{ - return myApproximation; -} -//======================================================================= -// function:PCurveOnS1 -// purpose: -//======================================================================= -inline Standard_Boolean BOPTools_SSIntersectionAttribute::PCurveOnS1() const -{ - return myPCurve1; -} -//======================================================================= -// function:PCurveOnS2 -// purpose: -//======================================================================= -inline Standard_Boolean BOPTools_SSIntersectionAttribute::PCurveOnS2() const -{ - return myPCurve2; -} - - diff --git a/src/BOPTools/BOPTools_Set.cdl b/src/BOPTools/BOPTools_Set.cdl new file mode 100644 index 0000000000..7bc338b1f3 --- /dev/null +++ b/src/BOPTools/BOPTools_Set.cdl @@ -0,0 +1,89 @@ +-- Created by: Peter KURNEV +-- Copyright (c) 1999-2012 OPEN CASCADE SAS +-- +-- The content of this file is subject to the Open CASCADE Technology Public +-- License Version 6.5 (the "License"). You may not use the content of this file +-- except in compliance with the License. Please obtain a copy of the License +-- at http://www.opencascade.org and read it completely before using this file. +-- +-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +-- +-- The Original Code and all software distributed under the License is +-- distributed on an "AS IS" basis, without warranty of any kind, and the +-- Initial Developer hereby disclaims all such warranties, including without +-- limitation, any warranties of merchantability, fitness for a particular +-- purpose or non-infringement. Please see the License for the specific terms +-- and conditions governing the rights and limitations under the License. + + +class Set from BOPTools + + ---Purpose: + +uses + ShapeEnum from TopAbs, + Shape from TopoDS, + ListOfShape from BOPCol, + BaseAllocator from BOPCol + +--raises + +is + Create + returns Set from BOPTools; + ---C++: alias "virtual ~BOPTools_Set();" + ---C++: inline + + Create (theAllocator: BaseAllocator from BOPCol) + returns Set from BOPTools; + ---C++: inline + + Assign(me:out; + Other : Set from BOPTools) + returns Set from BOPTools; + ---C++: alias operator = + ---C++: return & + ---C++: inline + + Clear(me:out) + is protected; + ---C++: inline + + Shape(me) + returns Shape from TopoDS; + ---C++: return const & + ---C++: inline + + Add(me:out; + theS:Shape from TopoDS; + theType: ShapeEnum from TopAbs); + ---C++: inline + + AddEdges(me:out; + theS:Shape from TopoDS); + ---C++: inline + + NbShapes(me) + returns Integer from Standard; + ---C++: inline + + IsEqual(me; + aOther:Set from BOPTools) + returns Boolean from Standard; + ---C++: inline + + HashCode(me; + Upper : Integer from Standard) + returns Integer from Standard; + ---C++: inline + +fields + myAllocator : BaseAllocator from BOPCol is protected; + myShapes : ListOfShape from BOPCol is protected; + myShape : Shape from TopoDS is protected; + myNbShapes : Integer from Standard is protected; + mySum : Integer from Standard is protected; + myUpper : Integer from Standard is protected; + +end Set; diff --git a/src/BOPTools/BOPTools_Set.cxx b/src/BOPTools/BOPTools_Set.cxx new file mode 100644 index 0000000000..5ea9eae0b3 --- /dev/null +++ b/src/BOPTools/BOPTools_Set.cxx @@ -0,0 +1,20 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#include diff --git a/src/BOPTools/BOPTools_Set.lxx b/src/BOPTools/BOPTools_Set.lxx new file mode 100644 index 0000000000..c7e6e8e443 --- /dev/null +++ b/src/BOPTools/BOPTools_Set.lxx @@ -0,0 +1,330 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +//#include + +#include +#include + + +static + inline Standard_Boolean operator<(const TopoDS_Shape& theS1, + const TopoDS_Shape& theS2); +static + inline void SortShell(const int n, TopoDS_Shape *a); + +static + inline Standard_Integer NormalizedIds(const Standard_Integer aId, + const Standard_Integer aDiv); +//======================================================================= +//function : +//purpose : +//======================================================================= + inline BOPTools_Set::BOPTools_Set() +: + myAllocator(NCollection_BaseAllocator::CommonBaseAllocator()), + myShapes(myAllocator) +{ + myNbShapes=0; + mySum=0; + myUpper=432123; +} +//======================================================================= +//function : +//purpose : +//======================================================================= + inline BOPTools_Set::BOPTools_Set(const Handle(NCollection_BaseAllocator)& theAllocator) +: + myAllocator(theAllocator), + myShapes(myAllocator) +{ + myNbShapes=0; + mySum=0; + myUpper=432123; +} +//======================================================================= +//function :~ +//purpose : +//======================================================================= + inline BOPTools_Set::~BOPTools_Set() +{ + Clear(); +} +//======================================================================= +//function : Clear +//purpose : +//======================================================================= + inline void BOPTools_Set::Clear() +{ + myNbShapes=0; + mySum=0; + myShapes.Clear(); +} +//======================================================================= +//function : NbShapes +//purpose : +//======================================================================= + inline Standard_Integer BOPTools_Set::NbShapes()const +{ + return myNbShapes; +} +//======================================================================= +//function :Assign +//purpose : +//======================================================================= + inline BOPTools_Set& BOPTools_Set::Assign(const BOPTools_Set& theOther) +{ + BOPCol_ListIteratorOfListOfShape aIt; + // + myShape=theOther.myShape; + myNbShapes=theOther.myNbShapes; + mySum=theOther.mySum; + myUpper=theOther.myUpper; + myAllocator=theOther.myAllocator; + // + myShapes.Clear(); + aIt.Initialize(theOther.myShapes); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aSx=aIt.Value(); + myShapes.Append(aSx); + } + return *this; +} +//======================================================================= +//function : Shape +//purpose : +//======================================================================= + inline const TopoDS_Shape& BOPTools_Set::Shape()const +{ + return myShape; +} +//======================================================================= +//function : Add +//purpose : +//======================================================================= + inline void BOPTools_Set::Add(const TopoDS_Shape& theS, + const TopAbs_ShapeEnum theType) +{ + if (theType==TopAbs_EDGE) { + AddEdges(theS); + return; + } + // + Standard_Integer i, aNb, aId, aIdN; + TopoDS_Shape *pShapes; + TopExp_Explorer aExp; + // + myNbShapes=0; + mySum=0; + myShape=theS; + // + aExp.Init(theS, theType); + for (aNb=0; aExp.More(); aExp.Next(), ++aNb) { + } + // + if (!aNb) { + return; + } + // + myNbShapes=aNb; + pShapes=(TopoDS_Shape *)myAllocator->Allocate(aNb*sizeof(TopoDS_Shape)); + // + aExp.ReInit(); + for (i=0; aExp.More(); aExp.Next(),++i) { + const TopoDS_Shape& aSx=aExp.Current(); + new (pShapes+i) TopoDS_Shape(); + pShapes[i]=aSx; + } + // + SortShell(aNb, pShapes); + // + myShapes.Clear(); + for (i=0; iFree((Standard_Address&)pShapes); +} +//======================================================================= +//function : AddEdges +//purpose : +//======================================================================= + inline void BOPTools_Set::AddEdges(const TopoDS_Shape& theS) +{ + Standard_Integer i, aNb, aId, aIdN; + TopoDS_Shape *pShapes; + TopExp_Explorer aExp; + // + myNbShapes=0; + mySum=0; + myShape=theS; + // + aExp.Init(theS, TopAbs_EDGE); + for (aNb=0; aExp.More(); aExp.Next()) { + const TopoDS_Edge& aE=(*(TopoDS_Edge*)(&aExp.Current())); + if (!BRep_Tool::Degenerated(aE)) { + ++aNb; + } + } + // + if (!aNb) { + return; + } + // + myNbShapes=aNb; + pShapes=(TopoDS_Shape *)myAllocator->Allocate(aNb*sizeof(TopoDS_Shape)); + // + i=0; + aExp.ReInit(); + for (; aExp.More(); aExp.Next()) { + const TopoDS_Shape& aSx=aExp.Current(); + const TopoDS_Edge& aE=(*(TopoDS_Edge*)(&aSx)); + if (!BRep_Tool::Degenerated(aE)) { + new (pShapes+i) TopoDS_Shape(); + pShapes[i]=aSx; + ++i; + } + } + // + SortShell(aNb, pShapes); + // + myShapes.Clear(); + for (i=0; iFree((Standard_Address&)pShapes); +} +//======================================================================= +//function : IsEqual +//purpose : +//======================================================================= + inline Standard_Boolean BOPTools_Set::IsEqual(const BOPTools_Set& theOther)const +{ + Standard_Boolean bRet; + // + bRet=Standard_False; + // + if (theOther.myNbShapes!=myNbShapes) { + return bRet; + } + // + BOPCol_ListIteratorOfListOfShape aIt1, aIt2; + // + aIt1.Initialize(myShapes); + aIt2.Initialize(theOther.myShapes); + for (; aIt1.More()||aIt2.More(); aIt1.Next(), aIt2.Next()) { + const TopoDS_Shape& aSx1=aIt1.Value(); + const TopoDS_Shape& aSx2=aIt2.Value(); + if (aSx1.TShape().operator->() != aSx2.TShape().operator->()) { + return bRet; + } + } + return !bRet; +} +//======================================================================= +//function : HashCode +//purpose : +//======================================================================= + inline Standard_Integer BOPTools_Set::HashCode(const Standard_Integer theUpper)const +{ + return ::HashCode(mySum, theUpper); +} +//======================================================================= +// function: NormalizedIds +// purpose : +//======================================================================= +Standard_Integer NormalizedIds(const Standard_Integer aId, + const Standard_Integer aDiv) +{ + Standard_Integer aMax, aTresh, aIdRet; + // + aIdRet=aId; + aMax=::IntegerLast(); + aTresh=aMax/aDiv; + if (aId>aTresh) { + aIdRet=aId%aTresh; + } + return aIdRet; +} + +//======================================================================= +//function : operator< +//purpose : +//======================================================================= +Standard_Boolean operator<(const TopoDS_Shape& theS1, + const TopoDS_Shape& theS2) +{ + Standard_Address aAddr1, aAddr2; + // + const Handle(TopoDS_TShape)& aTS1=theS1.TShape(); + aAddr1=aTS1.operator->(); + // + const Handle(TopoDS_TShape)& aTS2=theS2.TShape(); + aAddr2=aTS2.operator->(); + // + return (aAddr1 -1) goto m30; + }//if (a[l] < a[j]){ + }//for (i=0; i diff --git a/src/BOPTools/BOPTools_SetMapHasher.lxx b/src/BOPTools/BOPTools_SetMapHasher.lxx new file mode 100644 index 0000000000..df9ce7ff29 --- /dev/null +++ b/src/BOPTools/BOPTools_SetMapHasher.lxx @@ -0,0 +1,38 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +//#include +//======================================================================= +//function : HashCode +//purpose : +//======================================================================= +inline Standard_Integer BOPTools_SetMapHasher::HashCode(const BOPTools_Set& theSS, + const Standard_Integer Upper) +{ + return theSS.HashCode(Upper); +} +//======================================================================= +//function :IsEqual +//purpose : +//======================================================================= +inline Standard_Boolean BOPTools_SetMapHasher::IsEqual(const BOPTools_Set& theSS1, + const BOPTools_Set& theSS2) +{ + return theSS1.IsEqual(theSS2); +} diff --git a/src/BOPTools/BOPTools_ShapeSet.cdl b/src/BOPTools/BOPTools_ShapeSet.cdl new file mode 100644 index 0000000000..752fc20be1 --- /dev/null +++ b/src/BOPTools/BOPTools_ShapeSet.cdl @@ -0,0 +1,98 @@ +-- Created by: Peter KURNEV +-- Copyright (c) 1999-2012 OPEN CASCADE SAS +-- +-- The content of this file is subject to the Open CASCADE Technology Public +-- License Version 6.5 (the "License"). You may not use the content of this file +-- except in compliance with the License. Please obtain a copy of the License +-- at http://www.opencascade.org and read it completely before using this file. +-- +-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +-- +-- The Original Code and all software distributed under the License is +-- distributed on an "AS IS" basis, without warranty of any kind, and the +-- Initial Developer hereby disclaims all such warranties, including without +-- limitation, any warranties of merchantability, fitness for a particular +-- purpose or non-infringement. Please see the License for the specific terms +-- and conditions governing the rights and limitations under the License. + + +class ShapeSet from BOPTools + + ---Purpose: Implementation of some formal + -- opereations with a set of shapes + +uses + Shape from TopoDS, + Edge from TopoDS, + ShapeEnum from TopAbs, + BaseAllocator from BOPCol, + MapOfOrientedShape from BOPCol, + ListOfShape from BOPCol + +--raises + +is + Create + returns ShapeSet from BOPTools; + ---C++: alias "virtual ~BOPTools_ShapeSet();" + ---C++: inline + + Create (theAllocator: BaseAllocator from BOPCol) + returns ShapeSet from BOPTools; + ---C++: inline + + SetShape(me:out; + theS:Shape from TopoDS); + ---C++: inline + + Shape(me) + returns Shape from TopoDS; + ---C++: return const & + ---C++: inline + + Add(me:out; + theLS:ListOfShape from BOPCol); + + Add(me:out; + theShape:Shape from TopoDS); + ---C++: inline + + Add(me:out; + theShape:Shape from TopoDS; + theType: ShapeEnum from TopAbs); + + AddEdge(me:out; + theEdge:Edge from TopoDS); + ---C++: inline + + AddEdges(me:out; + theLS:ListOfShape from BOPCol); + + AddEdges(me:out; + theFace:Shape from TopoDS); + ---C++: inline + + Subtract(me:out; + theSet:ShapeSet from BOPTools); + ---C++: alias operator -= + ---C++: inline + + Clear(me:out); + ---C++: inline + + Get(me; + theLS:out ListOfShape from BOPCol); + ---C++: inline + + Contains(me; + theSet:ShapeSet from BOPTools) + returns Boolean from Standard; + ---C++: inline + + +fields + myShape: Shape from TopoDS is protected; + myMap : MapOfOrientedShape from BOPCol is protected; + +end ShapeSet; diff --git a/src/BOPTools/BOPTools_ShapeSet.cxx b/src/BOPTools/BOPTools_ShapeSet.cxx new file mode 100644 index 0000000000..43c03f0247 --- /dev/null +++ b/src/BOPTools/BOPTools_ShapeSet.cxx @@ -0,0 +1,19 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + +#include diff --git a/src/BOPTools/BOPTools_ShapeSet.lxx b/src/BOPTools/BOPTools_ShapeSet.lxx new file mode 100644 index 0000000000..9265d5b4ef --- /dev/null +++ b/src/BOPTools/BOPTools_ShapeSet.lxx @@ -0,0 +1,190 @@ +// Created by: Peter KURNEV +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + +#include +#include +#include + +//======================================================================= +//function : +//purpose : +//======================================================================= + inline BOPTools_ShapeSet::BOPTools_ShapeSet() +{ +} +//======================================================================= +//function : +//purpose : +//======================================================================= + inline BOPTools_ShapeSet::BOPTools_ShapeSet(const Handle(NCollection_BaseAllocator)& theObj) +: + myMap(100, theObj) +{ +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= + inline BOPTools_ShapeSet::~BOPTools_ShapeSet() +{ +} +//======================================================================= +//function : Clear +//purpose : +//======================================================================= + inline void BOPTools_ShapeSet::Clear() +{ + myMap.Clear(); +} +//======================================================================= +//function : SetShape +//purpose : +//======================================================================= + inline void BOPTools_ShapeSet::SetShape(const TopoDS_Shape& theShape) +{ + myShape=theShape; +} +//======================================================================= +//function : Shape +//purpose : +//======================================================================= + inline const TopoDS_Shape& BOPTools_ShapeSet::Shape()const +{ + return myShape; +} + +//======================================================================= +//function : Add +//purpose : +//======================================================================= + inline void BOPTools_ShapeSet::Add(const TopoDS_Shape& theShape) +{ + myMap.Add(theShape); +} +//======================================================================= +//function : Add +//purpose : +//======================================================================= + inline void BOPTools_ShapeSet::Add(const TopoDS_Shape& theShape, + const TopAbs_ShapeEnum theType) +{ + TopExp_Explorer aExp(theShape, theType); + for(; aExp.More(); aExp.Next()) { + const TopoDS_Shape& aS=aExp.Current(); + myMap.Add(aS); + } +} +//======================================================================= +//function : Add +//purpose : +//======================================================================= + inline void BOPTools_ShapeSet::Add(const BOPCol_ListOfShape& theLS) +{ + BOPCol_ListIteratorOfListOfShape aIt; + // + aIt.Init(theLS); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aS=aIt.Value(); + myMap.Add(aS); + } +} +//======================================================================= +//function : AddEdge +//purpose : +//======================================================================= + inline void BOPTools_ShapeSet::AddEdge(const TopoDS_Edge& theEdge) +{ + if (!BRep_Tool::Degenerated(theEdge)){ + myMap.Add(theEdge); + } +} +//======================================================================= +//function : AddEdges +//purpose : +//======================================================================= + inline void BOPTools_ShapeSet::AddEdges(const BOPCol_ListOfShape& theLS) +{ + BOPCol_ListIteratorOfListOfShape aIt; + // + aIt.Initialize(theLS); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Edge& aE=(*(TopoDS_Edge*)&aIt.Value()); + AddEdge(aE); + } +} +//======================================================================= +//function : AddEdges +//purpose : +//======================================================================= + inline void BOPTools_ShapeSet::AddEdges(const TopoDS_Shape& theFace) +{ + TopExp_Explorer aExp(theFace, TopAbs_EDGE); + for(; aExp.More(); aExp.Next()) { + const TopoDS_Edge& aE=(*(TopoDS_Edge*)&aExp.Current()); + AddEdge(aE); + } +} +//======================================================================= +//function : Get +//purpose : +//======================================================================= + inline void BOPTools_ShapeSet::Get(BOPCol_ListOfShape& theLS)const +{ + BOPCol_MapIteratorOfMapOfOrientedShape aIt; + // + aIt.Initialize(myMap); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aS=aIt.Value(); + theLS.Append(aS); + } +} +//======================================================================= +//function : Contains +//purpose : +//======================================================================= + inline Standard_Boolean BOPTools_ShapeSet::Contains(const BOPTools_ShapeSet& theOther)const +{ + Standard_Boolean bRet; + BOPCol_MapIteratorOfMapOfOrientedShape aIt; + // + aIt.Initialize(theOther.myMap); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aS=aIt.Value(); + bRet=myMap.Contains(aS); + if (!bRet) { + break; + } + } + return bRet; +} +//======================================================================= +//function : Subtract +//purpose : +//======================================================================= + inline void BOPTools_ShapeSet::Subtract(const BOPTools_ShapeSet& theOther) +{ + BOPCol_MapIteratorOfMapOfOrientedShape aIt; + // + aIt.Initialize(theOther.myMap); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aS=aIt.Value(); + if (myMap.Contains(aS)) { + myMap.Remove(aS); + } + } +} diff --git a/src/BOPTools/BOPTools_ShapeShapeInterference.cdl b/src/BOPTools/BOPTools_ShapeShapeInterference.cdl deleted file mode 100755 index c4646ad5c3..0000000000 --- a/src/BOPTools/BOPTools_ShapeShapeInterference.cdl +++ /dev/null @@ -1,91 +0,0 @@ --- Created on: 2000-11-21 --- Created by: Peter KURNEV --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class ShapeShapeInterference from BOPTools - - ---Purpose: - -- Root class for storing an Interference - -- between a couple BRep shapes -is - Create - returns ShapeShapeInterference from BOPTools; - ---Purpose: - --- Empty constructor - --- - Create (anIndex1: Integer from Standard; - anIndex2: Integer from Standard) - returns ShapeShapeInterference from BOPTools; - ---Purpose: - --- Constructor - --- - SetIndex1(me:out; anIndex1:Integer from Standard); - ---Purpose: - --- Modifier - --- Sets DS-index for the first shape from the couple - --- - SetIndex2(me:out; anIndex2:Integer from Standard); - ---Purpose: - --- Modifier - --- Sets DS-index for the second shape from the couple - --- - SetNewShape(me:out; anIndex:Integer from Standard); - ---Purpose: - --- Modifier - --- Sets DS-index for the new shape - --- - Index1(me) - returns Integer from Standard; - ---Purpose: - --- Selector - --- - Index2(me) - returns Integer from Standard; - ---Purpose: - --- Selector - --- - Indices(me; - anIndex1:out Integer from Standard; - anIndex2:out Integer from Standard); - ---Purpose: - --- Selector - --- - OppositeIndex(me; - anIndex:Integer from Standard) - returns Integer from Standard; - ---Purpose: - --- Selector - --- Gets the value of index - --- if anIndex==myIndex1 it returns myIndex2; - --- if anIndex==myIndex2 it returns myIndex1; - --- otherwise it returns 0; - --- - NewShape(me) - returns Integer from Standard; - ---Purpose: - --- Selector - --- - -fields - myIndex1 : Integer from Standard; - myIndex2 : Integer from Standard; - myNewShape: Integer from Standard; - -end ShapeShapeInterference; diff --git a/src/BOPTools/BOPTools_ShapeShapeInterference.cxx b/src/BOPTools/BOPTools_ShapeShapeInterference.cxx deleted file mode 100755 index 54e97c01de..0000000000 --- a/src/BOPTools/BOPTools_ShapeShapeInterference.cxx +++ /dev/null @@ -1,126 +0,0 @@ -// Created on: 2000-11-21 -// Created by: Peter KURNEV -// Copyright (c) 2000-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include - -//======================================================================= -//function : BOPTools_ShapeShapeInterference::BOPTools_ShapeShapeInterference -//purpose : -//======================================================================= -BOPTools_ShapeShapeInterference::BOPTools_ShapeShapeInterference() -: - myIndex1(0), myIndex2(0), myNewShape(0) -{} - -//======================================================================= -//function : BOPTools_ShapeShapeInterference::BOPTools_ShapeShapeInterference -//purpose : -//======================================================================= - BOPTools_ShapeShapeInterference::BOPTools_ShapeShapeInterference - (const Standard_Integer anIndex1, - const Standard_Integer anIndex2) -: - myIndex1(anIndex1), - myIndex2(anIndex2), - myNewShape(0) -{} - -//======================================================================= -//function : SetIndex1 -//purpose : -//======================================================================= - void BOPTools_ShapeShapeInterference::SetIndex1(const Standard_Integer anIndex1) -{ - myIndex1=anIndex1; -} - -//======================================================================= -//function : SetIndex2 -//purpose : -//======================================================================= - void BOPTools_ShapeShapeInterference::SetIndex2(const Standard_Integer anIndex2) -{ - myIndex2=anIndex2; -} - -//======================================================================= -//function : SetNewShape -//purpose : -//======================================================================= - void BOPTools_ShapeShapeInterference::SetNewShape(const Standard_Integer anIndex) -{ - myNewShape=anIndex; -} - -//======================================================================= -//function : Index1 -//purpose : -//======================================================================= - Standard_Integer BOPTools_ShapeShapeInterference::Index1() const -{ - return myIndex1; -} - -//======================================================================= -//function : Index2 -//purpose : -//======================================================================= - Standard_Integer BOPTools_ShapeShapeInterference::Index2() const -{ - return myIndex2; -} -//======================================================================= -//function : OppositeIndex -//purpose : -//======================================================================= - Standard_Integer BOPTools_ShapeShapeInterference::OppositeIndex - (const Standard_Integer anIndex) const -{ - if (anIndex==myIndex1) { - return myIndex2; - } - else if(anIndex==myIndex2) { - return myIndex1; - } - else { - return 0; - } -} - -//======================================================================= -//function : Indices -//purpose : -//======================================================================= - void BOPTools_ShapeShapeInterference::Indices(Standard_Integer& i1, - Standard_Integer& i2) const -{ - i1=myIndex1; - i2=myIndex2; -} - -//======================================================================= -//function : NewShape -//purpose : -//======================================================================= - Standard_Integer BOPTools_ShapeShapeInterference::NewShape() const -{ - return myNewShape; -} diff --git a/src/BOPTools/BOPTools_SolidStateFiller.cdl b/src/BOPTools/BOPTools_SolidStateFiller.cdl deleted file mode 100755 index 82b096f68e..0000000000 --- a/src/BOPTools/BOPTools_SolidStateFiller.cdl +++ /dev/null @@ -1,73 +0,0 @@ --- Created on: 2001-05-28 --- Created by: Peter KURNEV --- Copyright (c) 2001-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class SolidStateFiller from BOPTools inherits StateFiller from BOPTools - - ---Purpose: - -- class to compute states (3D) for the edges (and theirs - --- split parts), vertices, wires, faces, shells - --- - - -uses - PPaveFiller from BOPTools, - PaveFiller from BOPTools, - PShapesDataStructure from BooleanOperations, - StateOfShape from BooleanOperations, - - Shape from TopoDS, - Edge from TopoDS, - - State from TopAbs, - - ShapeEnum from TopAbs - -is - Create (aFiller: PaveFiller from BOPTools) - returns SolidStateFiller from BOPTools; - ---Purpose: - --- Constructor - --- - Do(me:out) - is redefined; - ---Purpose: - --- Launch the Filler - --- - --- - --- - --- private block - --- - DoNonSections (me:out; - iRankShape: Integer from Standard) - is private; - DoShellNonSections (me:out; - iRankShape: Integer from Standard) - is private; - - DoSections (me:out) - is private; - - IsFaceIntersected(me:out; - nF: Integer from Standard) - returns Boolean from Standard - is private; - -end SolidStateFiller; diff --git a/src/BOPTools/BOPTools_SolidStateFiller.cxx b/src/BOPTools/BOPTools_SolidStateFiller.cxx deleted file mode 100755 index b26eb4f465..0000000000 --- a/src/BOPTools/BOPTools_SolidStateFiller.cxx +++ /dev/null @@ -1,932 +0,0 @@ -// Created on: 2001-05-28 -// Created by: Peter KURNEV -// Copyright (c) 2001-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include - -#include -#include - -#include - -#include -#include -#include - -#include - -#include - -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static - void IntersectionStates(const TopoDS_Shape& aE, - const TopTools_IndexedDataMapOfShapeListOfShape& aM, - TopTools_IndexedMapOfShape& anIntersectedShapes); -static - void PropagateState(const TopoDS_Shape& aS, - const BooleanOperations_StateOfShape aState, - BooleanOperations_ShapesDataStructure* pDS, - const Standard_Integer iRank, - BOPTools_IndexedDataMapOfShapeWithState& aSWS, - TopTools_IndexedMapOfShape& aProcessedShapes); -static - void PropagateState(const TopoDS_Shape& aF, - const BooleanOperations_StateOfShape aState, - BooleanOperations_ShapesDataStructure* pDS, - const Standard_Integer iRank, - BOPTools_IndexedDataMapOfShapeWithState& aSWS, - const TopTools_IndexedDataMapOfShapeListOfShape& aEFMap, - TopTools_IndexedMapOfShape& aProcessedShapes); -static - Standard_Boolean HasConnexity(const TopoDS_Shape& aS, - const BOPTools_IndexedDataMapOfShapeWithState& aSWS, - const TopTools_IndexedDataMapOfShapeListOfShape& aMVE, - BooleanOperations_StateOfShape& aState); - -// Peter KURNEV -// p-kurnev@opencascade.com - -//======================================================================= -// function: BOPTools_SolidStateFiller::BOPTools_SolidStateFiller -// purpose: -//======================================================================= - BOPTools_SolidStateFiller::BOPTools_SolidStateFiller(const BOPTools_PaveFiller& aFiller) -: - BOPTools_StateFiller(aFiller) -{ -} - -//======================================================================= -// function: Do -// purpose: -//======================================================================= - void BOPTools_SolidStateFiller::Do() -{ - const TopoDS_Shape& anObj=myDS->Object(); - const TopoDS_Shape& aTool=myDS->Tool(); - // - myIsDone=Standard_True; - // - TopAbs_ShapeEnum aT1, aT2; - aT1=anObj.ShapeType(); - aT2=aTool.ShapeType(); - - if (aT1==TopAbs_FACE) { - aT1=TopAbs_SHELL; - } - if (aT2==TopAbs_FACE) { - aT2=TopAbs_SHELL; - } - - if (aT1==TopAbs_SOLID && aT2==TopAbs_SOLID) { - DoNonSections(1); - DoNonSections(2); - DoSections(); - } - - else if (aT1==TopAbs_SHELL && aT2==TopAbs_SHELL) { - DoShellNonSections(1); - DoShellNonSections(2); - DoSections(); - } - - else if (aT1==TopAbs_SHELL && aT2==TopAbs_SOLID) { - DoNonSections(1); - DoShellNonSections(2); - DoSections(); - } - else if (aT1==TopAbs_SOLID && aT2==TopAbs_SHELL) { - DoShellNonSections(1); - DoNonSections(2); - DoSections(); - } - else { - myIsDone=!myIsDone; - } -} - -//======================================================================= -// function: DoNonSections -// purpose: -//======================================================================= - void BOPTools_SolidStateFiller::DoNonSections(const Standard_Integer iRankObj) -{ - // - // 0. Restore data and preparing - - const TopoDS_Shape& anObj=(iRankObj==1) ? myDS->Object() : myDS->Tool(); - const TopoDS_Shape& aTool=(iRankObj==1) ? myDS->Tool() : myDS->Object(); - - const BooleanOperations_IndexedDataMapOfShapeInteger& aDSMap=myDS->ShapeIndexMap(iRankObj); - const BOPTools_SplitShapesPool& aSplitShapesPool=myFiller->SplitShapesPool(); - const BOPTools_CommonBlockPool& aCommonBlockPool=myFiller->CommonBlockPool(); - - Standard_Integer i, nE, nF, aNbPaveBlocks, aNb; - BooleanOperations_StateOfShape aState; - TopTools_IndexedMapOfShape aEM, anIntersectedShapes, aNonIntersectedShapes; - TopTools_IndexedDataMapOfShapeListOfShape aM, aMVE, aMEF; - // - // aM Map - TopExp::MapShapesAndAncestors (anObj, TopAbs_EDGE , TopAbs_WIRE , aM); - TopExp::MapShapesAndAncestors (anObj, TopAbs_WIRE , TopAbs_FACE , aM); - TopExp::MapShapesAndAncestors (anObj, TopAbs_FACE , TopAbs_SHELL, aM); - TopExp::MapShapesAndAncestors (anObj, TopAbs_SHELL, TopAbs_SOLID, aM); - // - // VE Map - TopExp::MapShapesAndAncestors (anObj, TopAbs_VERTEX, TopAbs_EDGE, aMVE); - // - // 1. anIntersectedShapes - // - // 1.1. Check EF FF interferences with nF - TopExp::MapShapes(anObj, TopAbs_FACE, aEM); - aNb=aEM.Extent(); - for (i=1; i<=aNb; i++) { - const TopoDS_Shape& aF=aEM(i); - nF=aDSMap.FindFromKey(aF); - Standard_Boolean bExists=IsFaceIntersected(nF); - if (bExists) { - anIntersectedShapes.Add(aF); - IntersectionStates (aF, aM, anIntersectedShapes); - } - } - // - aEM.Clear(); - TopExp::MapShapes(anObj, TopAbs_EDGE, aEM); - // - // 1.2. Edges that have Split parts - aNb=aEM.Extent(); - for (i=1; i<=aNb; i++) { - const TopoDS_Shape& aE=aEM(i); - nE=aDSMap.FindFromKey(aE); - const BOPTools_ListOfPaveBlock& aSplitEdges=aSplitShapesPool(myDS->RefEdge(nE)); - aNbPaveBlocks=aSplitEdges.Extent(); - // - if (!aNbPaveBlocks) { - continue; - } - // - if (aNbPaveBlocks==1) { - const BOPTools_ListOfCommonBlock& aCBlocks=aCommonBlockPool(myDS->RefEdge(nE)); - if (!aCBlocks.Extent()) { - const BOPTools_PaveBlock& aPB=aSplitEdges.First(); - Standard_Integer nEB=aPB.Edge(); - if (nEB==aPB.OriginalEdge()) { - Standard_Boolean bHasInterference=//; - Standard_False; //LNX - Standard_Integer j, aNbSuc, nV; - - aNbSuc=myDS->NumberOfSuccessors(nEB); - for (j=1; j<=aNbSuc; j++) { - nV=myDS->GetSuccessor(nE, j); - bHasInterference=myIntrPool->HasInterference(nV); - if (bHasInterference) { - break; - } - } - if (!bHasInterference) { - continue; - } - } - } - } - // - anIntersectedShapes.Add(aE); - IntersectionStates (aE, aM, anIntersectedShapes); - } // for (i=1; i<=aNb; i++) - - // - // 1.3. Write Intersected state for anIntersectedShapes to the DS - aNb=anIntersectedShapes.Extent(); - for (i=1; i<=aNb; i++) { - const TopoDS_Shape& aS=anIntersectedShapes(i); - nE=aDSMap.FindFromKey(aS); - myDS->SetState(nE, BooleanOperations_INTERSECTED); - } - // - // 2. aNonIntersectedShapes - // - aNb=aM.Extent(); - for (i=1; i<=aNb; i++) { - const TopoDS_Shape& aS=aM.FindKey(i); - if (!anIntersectedShapes.Contains(aS)) { - aNonIntersectedShapes.Add(aS); - } - } - // - // 2.1. Processing of Non-intersected shapes - BRep_Builder BB; - TopoDS_Compound aCompound; - BB.MakeCompound(aCompound); - aNb=aNonIntersectedShapes.Extent(); - for (i=1; i<=aNb; i++) { - const TopoDS_Shape& aS=aNonIntersectedShapes(i); - BB.Add(aCompound, aS); - } - - TopExp::MapShapesAndAncestors (aCompound, TopAbs_EDGE, TopAbs_FACE, aMEF); - // - TopTools_IndexedMapOfShape aProcessedShapes; - BOPTools_IndexedDataMapOfShapeWithState aSWS; - Standard_Boolean bHasConnexity; - // - BOPTools_ListOfShapeEnum aEnumList; - aEnumList.Append(TopAbs_SHELL); - aEnumList.Append(TopAbs_FACE); - aEnumList.Append(TopAbs_WIRE); - aEnumList.Append(TopAbs_EDGE); - - BOPTools_ListIteratorOfListOfShapeEnum anIt(aEnumList); - for (; anIt.More(); anIt.Next()) { - TopAbs_ShapeEnum anEnum=anIt.Value(); - aEM.Clear(); - TopExp::MapShapes(aCompound, anEnum, aEM); - aNb=aEM.Extent(); - for (i=1; i<=aNb; i++) { - const TopoDS_Shape& aS=aEM(i); - // - // DEBUG - //nE=aDSMap.FindFromKey(aS); - // - if (!aProcessedShapes.Contains(aS)) { - bHasConnexity=HasConnexity(aS, aSWS, aMVE, aState); - if (!bHasConnexity) { - aState=BOPTools_StateFiller::ClassifyShapeByRef (aS, aTool); - } - aSWS.Add(aS, aState); - aProcessedShapes.Add(aS); - if (anEnum==TopAbs_FACE) { - PropagateState(aS, aState, myDS, iRankObj, aSWS, aMEF, aProcessedShapes); - } - else { - PropagateState(aS, aState, myDS, iRankObj, aSWS, aProcessedShapes); - } - } - } - } - // - // 2.2. Write Stats for Non-intersected Shapes to the DS - aNb=aSWS.Extent(); - for (i=1; i<=aNb; i++) { - const TopoDS_Shape& aS=aSWS.FindKey(i); - aState=aSWS.FindFromIndex(i); - nE=aDSMap.FindFromKey(aS); - myDS->SetState(nE, aState); - } - - //--------------------------------------------------- - // - // 3. Intersected Edges' Processing - // - //--------------------------------------------------- - Standard_Integer nSp, aNBVertices, nV1, nV2; - BooleanOperations_StateOfShape aStV1, aStV2; - - aNb=anIntersectedShapes.Extent(); - for (i=1; i<=aNb; i++) { - const TopoDS_Shape& aS=anIntersectedShapes(i); - if (aS.ShapeType()==TopAbs_EDGE) { - nE=aDSMap.FindFromKey(aS); - // - // 3.1. On Parts Processing - const BOPTools_ListOfCommonBlock& aLCB=aCommonBlockPool(myDS->RefEdge(nE)); - BOPTools_ListIteratorOfListOfCommonBlock anItCB(aLCB); - for (; anItCB.More(); anItCB.Next()) { - const BOPTools_CommonBlock& aCB=anItCB.Value(); - BOPTools_CommonBlock* pCB=(BOPTools_CommonBlock*) &aCB; - BOPTools_PaveBlock& aPB=pCB->PaveBlock1(nE); - nSp=aPB.Edge(); - myDS->SetState(nSp, BooleanOperations_ON); - } - // - // 3.2. IN, OUT Parts Processing - const BOPTools_ListOfPaveBlock& aSplits=aSplitShapesPool(myDS->RefEdge(nE)); - BOPTools_ListIteratorOfListOfPaveBlock anItPB(aSplits); - for (; anItPB.More(); anItPB.Next()) { - const BOPTools_PaveBlock& aPB=anItPB.Value(); - nSp=aPB.Edge(); - const TopoDS_Shape& aSplit=myDS->Shape(nSp); - - aState=myDS->GetState(nSp); - if (aState==BooleanOperations_UNKNOWN|| aState==BooleanOperations_INTERSECTED){ - aNBVertices=myDS->NumberOfSuccessors(nE); - if (aNBVertices==2) { - nV1=myDS->GetSuccessor(nSp, 1); - aStV1=myDS->GetState(nV1); - nV2=myDS->GetSuccessor(nSp, 2); - aStV2=myDS->GetState(nV2); - if ((aStV1==BooleanOperations_IN || aStV1==BooleanOperations_OUT) - && (aStV2==BooleanOperations_ON)) { - myDS->SetState(nSp, aStV1); - } - else if ((aStV2==BooleanOperations_IN || aStV2==BooleanOperations_OUT) - && (aStV1==BooleanOperations_ON)) { - myDS->SetState(nSp, aStV2); - } - else { - aState=BOPTools_StateFiller::ClassifyShapeByRef(aSplit, aTool); - myDS->SetState(nSp, aState); - if (aStV1==BooleanOperations_UNKNOWN) { - myDS->SetState(nV1, aState); - } - if (aStV2==BooleanOperations_UNKNOWN) { - myDS->SetState(nV2, aState); - } - } - }// if (aNBVertices==2) - else { - aState=BOPTools_StateFiller::ClassifyShapeByRef(aSplit, aTool); - myDS->SetState(nSp, aState); - } - - }// if (aState==BooleanOperations_UNKNOWN || BooleanOperations_INTERSECTED) - }//for (; anItPB.More(); anItPB.Next()) - }// if (aS.ShapeType()==TopAbs_EDGE) - }// next "Intersected" Edge -} -// -//======================================================================= -// function: DoShellNonSections -// purpose: -//======================================================================= - void BOPTools_SolidStateFiller::DoShellNonSections(const Standard_Integer iRankObj) -{ - - const TopoDS_Shape& anObj=(iRankObj==1) ? myDS->Object() : myDS->Tool(); - // - // 0. Restore data and preparing - const BooleanOperations_IndexedDataMapOfShapeInteger& aDSMap=myDS->ShapeIndexMap(iRankObj); - - const BOPTools_SplitShapesPool& aSplitShapesPool=myFiller->SplitShapesPool(); - const BOPTools_CommonBlockPool& aCommonBlockPool=myFiller->CommonBlockPool(); - - Standard_Integer i, nE, aNbPaveBlocks, aNb, nF1, nF2, iRank, nFx; - BooleanOperations_StateOfShape aState; - TopTools_IndexedMapOfShape aEM, anIntersectedShapes, aNonIntersectedShapes; - TopTools_IndexedDataMapOfShapeListOfShape aM; - // - // aM Map - TopExp::MapShapesAndAncestors (anObj, TopAbs_EDGE , TopAbs_WIRE , aM); - TopExp::MapShapesAndAncestors (anObj, TopAbs_WIRE , TopAbs_FACE , aM); - TopExp::MapShapesAndAncestors (anObj, TopAbs_FACE , TopAbs_SHELL, aM); - TopExp::MapShapesAndAncestors (anObj, TopAbs_SHELL, TopAbs_SOLID, aM); - // - // 1. anIntersectedShapes - // - // 1.1. Check EF FF interferences with nF - const BOPTools_CArray1OfSSInterference& aFFs=myIntrPool->SSInterferences(); - - aNb=aFFs.Extent(); - for (i=1; i<=aNb; i++) { - const BOPTools_SSInterference& aFF=aFFs(i); - // nF1 - nF1=aFF.Index1(); - nF2=aFF.Index2(); - - iRank=myDS->Rank(nF1); - nFx=(iRank==myDS->Rank(nF1)) ? nF1 : nF2; - - const TopoDS_Shape& aFx=myDS->Shape(nFx); - anIntersectedShapes.Add(aFx); - IntersectionStates (aFx, aM, anIntersectedShapes); - } - - // - TopExp::MapShapes(anObj, TopAbs_EDGE, aEM); - // - // 1.2. Edges that have Split parts - aNb=aEM.Extent(); - for (i=1; i<=aNb; i++) { - const TopoDS_Shape& aE=aEM(i); - nE=aDSMap.FindFromKey(aE); - const BOPTools_ListOfPaveBlock& aSplitEdges=aSplitShapesPool(myDS->RefEdge(nE)); - aNbPaveBlocks=aSplitEdges.Extent(); - // - if (!aNbPaveBlocks) { - continue; - } - // - if (aNbPaveBlocks==1) { - const BOPTools_ListOfCommonBlock& aCBlocks=aCommonBlockPool(myDS->RefEdge(nE)); - if (!aCBlocks.Extent()) { - const BOPTools_PaveBlock& aPB=aSplitEdges.First(); - Standard_Integer nEB=aPB.Edge(); - if (nEB==aPB.OriginalEdge()) { - Standard_Boolean bHasInterference=//; LNX - Standard_False;//LNX - Standard_Integer j, aNbSuc, nV; - - aNbSuc=myDS->NumberOfSuccessors(nEB); - for (j=1; j<=aNbSuc; j++) { - nV=myDS->GetSuccessor(nE, j); - bHasInterference=myIntrPool->HasInterference(nV); - if (bHasInterference) { - break; - } - } - if (!bHasInterference) { - continue; - } - } - } - } - // - anIntersectedShapes.Add(aE); - IntersectionStates (aE, aM, anIntersectedShapes); - } // for (i=1; i<=aNb; i++) - // - // 1.3. Write Intersected state for anIntersectedShapes to the DS - aNb=anIntersectedShapes.Extent(); - for (i=1; i<=aNb; i++) { - const TopoDS_Shape& aS=anIntersectedShapes(i); - if (aDSMap.Contains(aS)) { - nE=aDSMap.FindFromKey(aS); - myDS->SetState(nE, BooleanOperations_INTERSECTED); - } - } - // - // 2. aNonIntersectedShapes - // - aNb=aM.Extent(); - for (i=1; i<=aNb; i++) { - const TopoDS_Shape& aS=aM.FindKey(i); - if (!anIntersectedShapes.Contains(aS)) { - aNonIntersectedShapes.Add(aS); - } - } - // - // 2.1. Write Stats for Non-intersected Shapes to the DS - aNb=aNonIntersectedShapes.Extent(); - for (i=1; i<=aNb; i++) { - const TopoDS_Shape& aS=aNonIntersectedShapes(i); - nE=aDSMap.FindFromKey(aS); - myDS->SetState(nE, BooleanOperations_OUT); - } - //--------------------------------------------------- - // - // 3. Intersected Edges' Processing - // - //--------------------------------------------------- - Standard_Integer nSp; - - - aNb=anIntersectedShapes.Extent(); - for (i=1; i<=aNb; i++) { - const TopoDS_Shape& aS=anIntersectedShapes(i); - if (aS.ShapeType()==TopAbs_EDGE) { - nE=aDSMap.FindFromKey(aS); - // - // 3.1. On Parts Processing - const BOPTools_ListOfCommonBlock& aLCB=aCommonBlockPool(myDS->RefEdge(nE)); - BOPTools_ListIteratorOfListOfCommonBlock anItCB(aLCB); - for (; anItCB.More(); anItCB.Next()) { - const BOPTools_CommonBlock& aCB=anItCB.Value(); - BOPTools_CommonBlock* pCB=(BOPTools_CommonBlock*) &aCB; - BOPTools_PaveBlock& aPB=pCB->PaveBlock1(nE); - nSp=aPB.Edge(); - myDS->SetState(nSp, BooleanOperations_ON); - } - // - // 3.2. IN, OUT Parts Processing - const BOPTools_ListOfPaveBlock& aSplits=aSplitShapesPool(myDS->RefEdge(nE)); - BOPTools_ListIteratorOfListOfPaveBlock anItPB(aSplits); - for (; anItPB.More(); anItPB.Next()) { - const BOPTools_PaveBlock& aPB=anItPB.Value(); - nSp=aPB.Edge(); - //const TopoDS_Shape& aSplit=myDS->Shape(nSp);//LNX - - aState=myDS->GetState(nSp); - if (aState==BooleanOperations_UNKNOWN|| aState==BooleanOperations_INTERSECTED){ - myDS->SetState(nSp, BooleanOperations_OUT); - - }// if (aState==BooleanOperations_UNKNOWN || BooleanOperations_INTERSECTED) - }//for (; anItPB.More(); anItPB.Next()) - }// if (aS.ShapeType()==TopAbs_EDGE) - }// next "Intersected" Edge -} -// -//======================================================================= -// function: DoSections -// purpose: -//======================================================================= - void BOPTools_SolidStateFiller::DoSections() -{ - Standard_Integer i, j, aNb, aNbCurves, n1, n2, nE; - - BOPTools_CArray1OfSSInterference& aFFs=myIntrPool->SSInterferences(); - - aNb=aFFs.Extent(); - for (i=1; i<=aNb; i++) { - BOPTools_SSInterference& aFF=aFFs(i); - n1=aFF.Index1(); - n2=aFF.Index2(); - BOPTools_SequenceOfCurves& aSC=aFF.Curves(); - aNbCurves=aSC.Length(); - for (j=1; j<=aNbCurves; j++) { - const BOPTools_Curve& aBC=aSC(j); - const BOPTools_ListOfPaveBlock& aLPB=aBC.NewPaveBlocks(); - BOPTools_ListIteratorOfListOfPaveBlock anIt(aLPB); - for (; anIt.More(); anIt.Next()) { - const BOPTools_PaveBlock& aPB=anIt.Value(); - nE=aPB.Edge(); - myDS->SetState(nE, BooleanOperations_ON); - } - } - } -} - -//======================================================================= -// function: IsFaceIntersected -// purpose: -//======================================================================= - Standard_Boolean BOPTools_SolidStateFiller::IsFaceIntersected(const Standard_Integer nF) -{ - Standard_Boolean bFlag=Standard_False; - Standard_Integer i, aNb, n1, n2; - - const BOPTools_CArray1OfESInterference& aEFs=myIntrPool->ESInterferences(); - aNb=aEFs.Extent(); - for (i=1; i<=aNb; i++) { - const BOPTools_ESInterference& aEF=aEFs(i); - n1=aEF.Index1(); - n2=aEF.Index2(); - if (n1==nF || n2==nF) { - return !bFlag; - } - } - - const BOPTools_CArray1OfSSInterference& aFFs=myIntrPool->SSInterferences(); - aNb=aFFs.Extent(); - for (i=1; i<=aNb; i++) { - const BOPTools_SSInterference& aFF=aFFs(i); - n1=aFF.Index1(); - n2=aFF.Index2(); - if (n1==nF || n2==nF) { - return !bFlag; - } - } - return bFlag; -} - - - - - -//======================================================================= -// function: PropagateState [for faces] -// purpose: -//======================================================================= - void PropagateState(const TopoDS_Shape& aF, - const BooleanOperations_StateOfShape aState, - BooleanOperations_ShapesDataStructure* pDS, - const Standard_Integer iRank, - BOPTools_IndexedDataMapOfShapeWithState& aSWS, - const TopTools_IndexedDataMapOfShapeListOfShape& aEFMap, - TopTools_IndexedMapOfShape& aProcessedShapes) -{ - // PropagateState for Sub-Shapes - PropagateState (aF, aState, pDS, iRank, aSWS, aProcessedShapes); - // PropagateState for connected Faces; - TopTools_IndexedMapOfShape anEdgeMap; - TopExp::MapShapes(aF, TopAbs_EDGE, anEdgeMap); - - Standard_Integer i, aNbE; - aNbE=anEdgeMap.Extent(); - - for (i=1; i<=aNbE; i++) { - const TopoDS_Shape& aE=anEdgeMap(i); - // - const TopTools_ListOfShape& aFacesList=aEFMap.FindFromKey(aE); - // - TopTools_ListIteratorOfListOfShape anIt(aFacesList); - for (; anIt.More(); anIt.Next()) { - const TopoDS_Shape& aFi=anIt.Value(); - if (!aProcessedShapes.Contains(aFi)) { - if (!aFi.IsSame(aF)) { - aSWS.Add(aFi, aState); - aProcessedShapes.Add(aFi); - PropagateState(aFi, aState, pDS, iRank, aSWS, aEFMap, aProcessedShapes); - } - } - } - } -} - -//======================================================================= -// function: PropagateState -// purpose: -//======================================================================= -void PropagateState(const TopoDS_Shape& aSS, - const BooleanOperations_StateOfShape aState, - BooleanOperations_ShapesDataStructure* pDS, - const Standard_Integer iRank, - BOPTools_IndexedDataMapOfShapeWithState& aSWS, - TopTools_IndexedMapOfShape& aProcessedShapes) -{ - TopAbs_ShapeEnum aSubType; - - aSubType=BOPTools_StateFiller::SubType(aSS); - - if (aSubType==TopAbs_SHAPE) { - return; - } - - const BooleanOperations_IndexedDataMapOfShapeInteger& aDSMap= pDS->ShapeIndexMap(iRank); - - TopTools_IndexedMapOfShape aSubMap; - TopExp::MapShapes(aSS, aSubType, aSubMap); - - Standard_Integer i, aNb, nV; - aNb=aSubMap.Extent(); - for (i=1; i<=aNb; i++) { - const TopoDS_Shape& aS=aSubMap(i); - if (!aProcessedShapes.Contains(aS)) { - if (aSubType==TopAbs_VERTEX) { - nV=aDSMap.FindFromKey(aS); - BooleanOperations_StateOfShape aSt=pDS->GetState(nV); - if (aSt!=BooleanOperations_UNKNOWN){ - aProcessedShapes.Add(aS); - continue; - } - } - aSWS.Add(aS, aState); - aProcessedShapes.Add(aS); - PropagateState (aS, aState, pDS, iRank, aSWS, aProcessedShapes); - } - } -} -//======================================================================= -// function: IntersectionStates -// purpose: -//======================================================================= -void IntersectionStates(const TopoDS_Shape& aE, - const TopTools_IndexedDataMapOfShapeListOfShape& aM, - TopTools_IndexedMapOfShape& anIntersectedShapes) -{ - if (aM.Contains(aE)) { - const TopTools_ListOfShape& anAncesstors=aM.FindFromKey(aE); - TopTools_ListIteratorOfListOfShape anIt(anAncesstors); - for (; anIt.More(); anIt.Next()) { - const TopoDS_Shape& anAnc=anIt.Value(); - anIntersectedShapes.Add(anAnc); - IntersectionStates(anAnc, aM, anIntersectedShapes); - } - } -} -//======================================================================= -// function: HasConnexity -// purpose: -//======================================================================= - Standard_Boolean HasConnexity(const TopoDS_Shape& aS, - const BOPTools_IndexedDataMapOfShapeWithState& aSWS, - const TopTools_IndexedDataMapOfShapeListOfShape& aMVE, - BooleanOperations_StateOfShape& aState) -{ - TopAbs_ShapeEnum aType; - BooleanOperations_StateOfShape aSt; - aType=aS.ShapeType(); - if (aType!=TopAbs_EDGE) { - Standard_Integer i, aNb; - TopTools_IndexedMapOfShape aME; - TopExp::MapShapes(aS, TopAbs_EDGE, aME); - aNb=aME.Extent(); - for (i=1; i<=aNb; i++) { - const TopoDS_Shape& aE=aME(i); - if (aSWS.Contains(aE)){ - aSt=aSWS.FindFromKey(aE); - aState=aSt; - return Standard_True; - } - } - } - else { - TopExp_Explorer anExp (aS, TopAbs_VERTEX); - for (; anExp.More(); anExp.Next()) { - const TopoDS_Shape& aV=anExp.Current(); - if (aMVE.Contains(aV)) { - const TopTools_ListOfShape& anEdgesList=aMVE.FindFromKey(aV); - TopTools_ListIteratorOfListOfShape anIt(anEdgesList); - for (; anIt.More(); anIt.Next()) { - const TopoDS_Shape& aEx=anIt.Value(); - if (aSWS.Contains(aEx)) { - aSt=aSWS.FindFromKey(aEx); - aState=aSt; - return Standard_True; - } - } - } - } - } - - aState=BooleanOperations_UNKNOWN; - return Standard_False; -} - -/* -//======================================================================= -// function: ConvertState -// purpose: -//======================================================================= -BooleanOperations_StateOfShape - BOPTools_SolidStateFiller::ConvertState(const TopAbs_State aSt) -{ - BooleanOperations_StateOfShape aState; - switch (aSt) { - case TopAbs_IN: - aState=BooleanOperations_IN; - break; - case TopAbs_OUT: - aState=BooleanOperations_OUT; - break; - case TopAbs_ON: - aState=BooleanOperations_ON; - break; - case TopAbs_UNKNOWN: - aState=BooleanOperations_UNKNOWN; - break; - default: - aState=BooleanOperations_UNKNOWN; - break; - } - return aState; -} - -//======================================================================= -// function: ConvertState -// purpose: -//======================================================================= -TopAbs_State - BOPTools_SolidStateFiller::ConvertState(const BooleanOperations_StateOfShape aSt) -{ - TopAbs_State aState; - - switch (aSt) { - case BooleanOperations_IN: - aState=TopAbs_IN; - break; - case BooleanOperations_OUT: - aState=TopAbs_OUT; - break; - case BooleanOperations_ON: - aState=TopAbs_ON; - break; - case BooleanOperations_UNKNOWN: - aState=TopAbs_UNKNOWN; - break; - default: - aState=TopAbs_UNKNOWN; - break; - } - return aState; -} -//======================================================================= -// function: ClassifyShapeByRef -// purpose: -//======================================================================= - BooleanOperations_StateOfShape - BOPTools_SolidStateFiller::ClassifyShapeByRef (const TopoDS_Shape& aS, - const TopoDS_Shape& aRef) -{ - TopAbs_ShapeEnum aType; - aType=aS.ShapeType(); - - TopoDS_Edge aE; - if (aType!=TopAbs_EDGE) { - TopTools_IndexedMapOfShape aME; - TopExp::MapShapes(aS, TopAbs_EDGE, aME); - aE=TopoDS::Edge(aME(1)); - } - else { - aE=TopoDS::Edge(aS); - } - - TopAbs_State aSt=BOPTools_SolidStateFiller::ClassifyEdgeToSolidByOnePoint(aE, aRef); - BooleanOperations_StateOfShape aState=BOPTools_SolidStateFiller::ConvertState(aSt) ; - - return aState; -} - -//======================================================================= -// function: ClassifyEdgeToSolidByOnePoint -// purpose: -//======================================================================= -TopAbs_State - BOPTools_SolidStateFiller::ClassifyEdgeToSolidByOnePoint(const TopoDS_Edge& E, - const TopoDS_Shape& Ref) -{ - Standard_Real f2 = 0., l2 = 0., par = 0.; - - Handle(Geom_Curve) C3D = BRep_Tool::Curve(E, f2, l2); - gp_Pnt aP3d; - - - - if(C3D.IsNull()) { - //it means that we are in degenerated edge - const TopoDS_Vertex& fv = TopExp::FirstVertex(E); - if(fv.IsNull()){ - return TopAbs_UNKNOWN; - } - aP3d = BRep_Tool::Pnt(fv); - } - else {//usual case - par=IntTools_Tools::IntermediatePoint(f2, l2); - C3D -> D0(par, aP3d); - } - - BRepClass3d_SolidClassifier SC(Ref); - SC.Perform(aP3d, 1e-7); - - TopAbs_State aState=SC.State(); - - return aState; -} -//======================================================================= -// function: SubType -// purpose: -//======================================================================= - TopAbs_ShapeEnum BOPTools_SolidStateFiller::SubType(const TopoDS_Shape& aS) -{ - TopAbs_ShapeEnum aSourceType, aReturnType; - aSourceType=aS.ShapeType(); - - switch (aSourceType) { - case TopAbs_SOLID: - aReturnType=TopAbs_SHELL; - break; - case TopAbs_SHELL: - aReturnType=TopAbs_FACE; - break; - case TopAbs_FACE: - aReturnType=TopAbs_WIRE; - break; - case TopAbs_WIRE: - aReturnType=TopAbs_EDGE; - break; - case TopAbs_EDGE: - aReturnType=TopAbs_VERTEX; - break; - default: - aReturnType=TopAbs_SHAPE; - break; - } - return aReturnType; -} -*/ diff --git a/src/BOPTools/BOPTools_StateFiller.cdl b/src/BOPTools/BOPTools_StateFiller.cdl deleted file mode 100755 index 0200a54517..0000000000 --- a/src/BOPTools/BOPTools_StateFiller.cdl +++ /dev/null @@ -1,102 +0,0 @@ --- Created on: 2002-02-04 --- Created by: Peter KURNEV --- Copyright (c) 2002-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class StateFiller from BOPTools - - ---Purpose: - --- root class to compute states (3D) - --- - -uses - PaveFiller from BOPTools, - PPaveFiller from BOPTools, - PInterferencePool from BOPTools, - PShapesDataStructure from BooleanOperations, - - Shape from TopoDS, - Edge from TopoDS, - State from TopAbs, - ShapeEnum from TopAbs, - StateOfShape from BooleanOperations ---raises - -is - Create (aFiller: PaveFiller from BOPTools) - returns StateFiller from BOPTools; - ---Purpose: - --- Constructor - --- - Do(me:out) - is virtual; - ---Purpose: - --- Launch the Filler - --- - IsDone(me) - returns Boolean from Standard; - ---Purpose: - --- Returns true if Ok - --- - - ConvertState (myclass; - aSt: State from TopAbs) - returns StateOfShape from BooleanOperations; - ---Purpose: - --- Convert conventional states to VDS-states - --- - ConvertState (myclass; - aSt: StateOfShape from BooleanOperations) - returns State from TopAbs; - ---Purpose: - --- Convert VDS-states to conventional states - --- - ClassifyEdgeToSolidByOnePoint (me:out; - anEdge: Edge from TopoDS; - aRef : Shape from TopoDS) - returns State from TopAbs; - ---Purpose: - --- Computation the 3D-state of the edge - --- to solid - --- - ClassifyShapeByRef (me:out; - aShape: Shape from TopoDS; - aRef : Shape from TopoDS) - returns StateOfShape from BooleanOperations; - ---Purpose: - --- Computation the 3D-state of the shape - --- to solid - --- - SubType (myclass; - aShape: Shape from TopoDS) - returns ShapeEnum from TopAbs; - ---Purpose: - --- Returns first subtype of - --- -fields - myFiller : PPaveFiller from BOPTools - is protected; - myDS : PShapesDataStructure from BooleanOperations - is protected; - myIntrPool: PInterferencePool from BOPTools - is protected; - myIsDone : Boolean from Standard - is protected; - -end StateFiller; diff --git a/src/BOPTools/BOPTools_StateFiller.cxx b/src/BOPTools/BOPTools_StateFiller.cxx deleted file mode 100755 index fe9f5f47fa..0000000000 --- a/src/BOPTools/BOPTools_StateFiller.cxx +++ /dev/null @@ -1,321 +0,0 @@ -// Created on: 2002-02-04 -// Created by: Peter KURNEV -// Copyright (c) 2002-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -// Modified by skv - Tue Aug 24 12:31:16 2004 OCC6450 - -#include - -#include - -#include -#include - -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include - -#include -#include -#include - -//======================================================================= -// function: BOPTools_StateFiller::BOPTools_StateFiller -// purpose: -//======================================================================= -BOPTools_StateFiller::BOPTools_StateFiller(const BOPTools_PaveFiller& aFiller) -: - myIsDone(Standard_False) -{ - myFiller=(BOPTools_PaveFiller*) &aFiller; - myDS=myFiller->DS(); - myIntrPool=myFiller->InterfPool(); -} -//======================================================================= -// function: Do -// purpose: -//======================================================================= - void BOPTools_StateFiller::Do() -{ -} -//======================================================================= -// function: IsDone -// purpose: -//======================================================================= - Standard_Boolean BOPTools_StateFiller::IsDone() const -{ - return myIsDone; -} - -//======================================================================= -// function: ConvertState -// purpose: -//======================================================================= - BooleanOperations_StateOfShape BOPTools_StateFiller::ConvertState(const TopAbs_State aSt) -{ - BooleanOperations_StateOfShape aState; - switch (aSt) { - case TopAbs_IN: - aState=BooleanOperations_IN; - break; - case TopAbs_OUT: - aState=BooleanOperations_OUT; - break; - case TopAbs_ON: - aState=BooleanOperations_ON; - break; - case TopAbs_UNKNOWN: - aState=BooleanOperations_UNKNOWN; - break; - default: - aState=BooleanOperations_UNKNOWN; - break; - } - return aState; -} - -//======================================================================= -// function: ConvertState -// purpose: -//======================================================================= - TopAbs_State BOPTools_StateFiller::ConvertState(const BooleanOperations_StateOfShape aSt) -{ - TopAbs_State aState; - - switch (aSt) { - case BooleanOperations_IN: - aState=TopAbs_IN; - break; - case BooleanOperations_OUT: - aState=TopAbs_OUT; - break; - case BooleanOperations_ON: - aState=TopAbs_ON; - break; - case BooleanOperations_UNKNOWN: - aState=TopAbs_UNKNOWN; - break; - default: - aState=TopAbs_UNKNOWN; - break; - } - return aState; -} - -//======================================================================= -// function: ClassifyShapeByRef -// purpose: -//======================================================================= - BooleanOperations_StateOfShape BOPTools_StateFiller::ClassifyShapeByRef (const TopoDS_Shape& aS, - const TopoDS_Shape& aRef) -{ - TopAbs_ShapeEnum aType; - aType=aS.ShapeType(); - -// Modified by skv - Tue Aug 24 12:31:16 2004 OCC6450 Begin - Standard_Boolean hasEdge = Standard_True; -// Modified by skv - Tue Aug 24 12:31:17 2004 OCC6450 End - TopoDS_Edge aE; - if (aType!=TopAbs_EDGE) { - TopTools_IndexedMapOfShape aME; - TopExp::MapShapes(aS, TopAbs_EDGE, aME); - -// Modified by skv - Tue Aug 24 12:31:16 2004 OCC6450 Begin - if (aME.Extent() == 0) - hasEdge = Standard_False; - else -// Modified by skv - Tue Aug 24 12:31:16 2004 OCC6450 End - aE=TopoDS::Edge(aME(1)); - } - else { - aE=TopoDS::Edge(aS); - } - -// Modified by skv - Tue Aug 24 12:31:16 2004 OCC6450 Begin -// TopAbs_State aSt=ClassifyEdgeToSolidByOnePoint(aE, aRef); - TopAbs_State aSt; - - if (hasEdge) { - aSt = ClassifyEdgeToSolidByOnePoint(aE, aRef); - } else { - TopTools_IndexedMapOfShape aMF; - Standard_Boolean hasFace = Standard_True; - TopoDS_Face aF; - - TopExp::MapShapes(aS, TopAbs_FACE, aMF); - -// Modified by skv - Tue Aug 24 12:31:16 2004 OCC6450 Begin - if (aMF.Extent() == 0) { - hasFace = Standard_False; - } else { - aF = TopoDS::Face(aMF(1)); - } - - if (!hasFace) { - aSt = TopAbs_UNKNOWN; - } else { - Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aF); - Standard_Real aUMin; - Standard_Real aUMax; - Standard_Real aVMin; - Standard_Real aVMax; - - aSurf->Bounds(aUMin, aUMax, aVMin, aVMax); - - Standard_Boolean isMinInf = Precision::IsNegativeInfinite(aUMin); - Standard_Boolean isMaxInf = Precision::IsPositiveInfinite(aUMax); - Standard_Real dT=10.; - Standard_Real aParU; - Standard_Real aParV; - - if (isMinInf && !isMaxInf) { - aParU = aUMax - dT; - } else if (!isMinInf && isMaxInf) { - aParU = aUMin + dT; - } else if (isMinInf && isMaxInf) { - aParU = 0.; - } else { - aParU = IntTools_Tools::IntermediatePoint(aUMin, aUMax); - } - - isMinInf = Precision::IsNegativeInfinite(aVMin); - isMaxInf = Precision::IsPositiveInfinite(aVMax); - - if (isMinInf && !isMaxInf) { - aParV = aVMax - dT; - } else if (!isMinInf && isMaxInf) { - aParV = aVMin + dT; - } else if (isMinInf && isMaxInf) { - aParV = 0.; - } else { - aParV = IntTools_Tools::IntermediatePoint(aVMin, aVMax); - } - - gp_Pnt aP3d = aSurf->Value(aParU, aParV); - - const TopoDS_Solid &aRefSolid = TopoDS::Solid(aRef); - const Handle(IntTools_Context)& aContext = myFiller->Context(); - BRepClass3d_SolidClassifier &aSC = - aContext->SolidClassifier(aRefSolid); - // - aSC.Perform(aP3d, 1e-7); - // - aSt = aSC.State(); - } - } -// Modified by skv - Tue Aug 24 12:31:16 2004 OCC6450 Begin - - BooleanOperations_StateOfShape aState=BOPTools_StateFiller::ConvertState(aSt) ; - - return aState; -} - - -//======================================================================= -// function: ClassifyEdgeToSolidByOnePoint -// purpose: -//======================================================================= - TopAbs_State BOPTools_StateFiller::ClassifyEdgeToSolidByOnePoint(const TopoDS_Edge& E, - const TopoDS_Shape& Ref) -{ - Standard_Real f2 = 0., l2 = 0., par = 0.; - - Handle(Geom_Curve) C3D = BRep_Tool::Curve(E, f2, l2); - gp_Pnt aP3d; - - if(C3D.IsNull()) { - //it means that we are in degenerated edge - const TopoDS_Vertex& fv = TopExp::FirstVertex(E); - if(fv.IsNull()){ - return TopAbs_UNKNOWN; - } - aP3d = BRep_Tool::Pnt(fv); - } - else {//usual case - Standard_Boolean bF2Inf, bL2Inf; - Standard_Real dT=10.; - // - bF2Inf = Precision::IsNegativeInfinite(f2); - bL2Inf = Precision::IsPositiveInfinite(l2); - // - if (bF2Inf && !bL2Inf) { - par=l2-dT; - } - else if (!bF2Inf && bL2Inf) { - par=f2+dT; - } - else if (bF2Inf && bL2Inf) { - par=0.; - } - else { - par=IntTools_Tools::IntermediatePoint(f2, l2); - } - C3D -> D0(par, aP3d); - } - // - const TopoDS_Solid& aRefSolid=TopoDS::Solid(Ref); - const Handle(IntTools_Context)& aContext=myFiller->Context(); - BRepClass3d_SolidClassifier& aSC=aContext->SolidClassifier(aRefSolid); - // - aSC.Perform(aP3d, 1e-7); - // - TopAbs_State aState=aSC.State(); - - return aState; -} -//======================================================================= -// function: SubType -// purpose: -//======================================================================= - TopAbs_ShapeEnum BOPTools_StateFiller::SubType(const TopoDS_Shape& aS) -{ - TopAbs_ShapeEnum aSourceType, aReturnType; - aSourceType=aS.ShapeType(); - - switch (aSourceType) { - case TopAbs_SOLID: - aReturnType=TopAbs_SHELL; - break; - case TopAbs_SHELL: - aReturnType=TopAbs_FACE; - break; - case TopAbs_FACE: - aReturnType=TopAbs_WIRE; - break; - case TopAbs_WIRE: - aReturnType=TopAbs_EDGE; - break; - case TopAbs_EDGE: - aReturnType=TopAbs_VERTEX; - break; - default: - aReturnType=TopAbs_SHAPE; - break; - } - return aReturnType; -} diff --git a/src/BOPTools/BOPTools_Tools.cdl b/src/BOPTools/BOPTools_Tools.cdl deleted file mode 100755 index f939a826e5..0000000000 --- a/src/BOPTools/BOPTools_Tools.cdl +++ /dev/null @@ -1,184 +0,0 @@ --- Created on: 2000-11-16 --- Created by: Peter KURNEV --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class Tools from BOPTools - - ---Purpose: - --- The class contains handy static functions - --- dealing with the topology - -uses - Pnt from gp , - - Shape from TopoDS, - Vertex from TopoDS, - Edge from TopoDS, - Face from TopoDS, - - Range from IntTools, - Context from IntTools, - Curve from IntTools, - - PaveBlock from BOPTools, - - IndexedMapOfShape from TopTools - -is - - - - MakeNewVertex (myclass; - aP1 : Pnt from gp; - aTol: Real from Standard; - aNewVertex:out Vertex from TopoDS); - ---Purpose: - --- Make a vertex using 3D-point and 3D-tolerance value - --- - MakeNewVertex (myclass; - aV1,aV2: Vertex from TopoDS; - aNewVertex:out Vertex from TopoDS); - ---Purpose: - --- Make a vertex using couple of vertices - --- - MakeNewVertex (myclass; - aE1: Edge from TopoDS; - aP1: Real from Standard; - aE2: Edge from TopoDS; - aP2: Real from Standard; - aNewVertex:out Vertex from TopoDS); - ---Purpose: - --- Make a vertex in place of intersection between two edges - --- with parameters - --- - MakeNewVertex (myclass; - aE1: Edge from TopoDS; - aP1: Real from Standard; - aF2: Face from TopoDS; - aNewVertex:out Vertex from TopoDS); - ---Purpose: - --- Make a vertex in place of intersection between the edge - --- with parameter and the face - --- - PointOnEdge (myclass; - aEdge: Edge from TopoDS; - aPrm: Real from Standard; - aP:out Pnt from gp); - ---Purpose: - --- Compute a 3D-point on the edge at parameter - --- - MakeSplitEdge (myclass; - aE1: Edge from TopoDS; - aV1: Vertex from TopoDS; - aP1: Real from Standard; - aV2: Vertex from TopoDS; - aP2: Real from Standard; - aNewEdge:out Edge from TopoDS); - ---Purpose: - --- Make the edge from base edge and two vertices - --- at parameters - --- - MakeSectEdge (myclass; - aIC: Curve from IntTools; - aV1: Vertex from TopoDS; - aP1: Real from Standard; - aV2: Vertex from TopoDS; - aP2: Real from Standard; - aNewEdge:out Edge from TopoDS); - ---Purpose: - --- Make the edge from 3D-Curve and two vertices - --- at parameters - --- - UpdateVertex (myclass; - aIC: Curve from IntTools; - aT : Real from Standard; - aV : Vertex from TopoDS); - ---Purpose: - --- Update the tolerance value for vertex - --- taking into account the fact that lays on - --- the curve - --- - UpdateVertex (myclass; - aE : Edge from TopoDS; - aT : Real from Standard; - aV : Vertex from TopoDS); - ---Purpose: - --- Update the tolerance value for vertex - --- taking into account the fact that lays on - --- the edge - --- - UpdateVertex (myclass; - aVF : Vertex from TopoDS; - aVN : Vertex from TopoDS); - ---Purpose: - --- Update the tolerance value for vertex - --- taking into account the fact that should - --- cover tolerance zone of - --- - IsBlocksCoinside(myclass; - aPB1: PaveBlock from BOPTools; - aPB2: PaveBlock from BOPTools) - returns Boolean from Standard; - ---Purpose: - --- Returns TRUE if PaveBlocks , coinside in 3D - --- taking into account corresp. tolerances' values of vertices, - --- edges - --- - IsBlockInOnFace(myclass; - aPB : PaveBlock from BOPTools; - aF : Face from TopoDS; - aContext: Context from IntTools) - returns Boolean from Standard; - ---Purpose: - --- Returns TRUE if PaveBlock lays on the face , i.e - --- the is IN or ON in 2D of - --- - MapShapes (myclass; - aS : Shape from TopoDS; - aM :out IndexedMapOfShape from TopTools); - ---Purpose: - --- Get a Map containing the shape itself and all its subshapes - --- - CorrectRange (myclass; - aE1: Edge from TopoDS; - aE2: Edge from TopoDS; - aSR: Range from IntTools; - aNewSR:out Range from IntTools); - ---Purpose: - --- Correct shrunk range taking into account 3D-curve - --- resolution and corresp. tolerances' values of , - --- - CorrectRange (myclass; - aE: Edge from TopoDS; - aF: Face from TopoDS; - aSR: Range from IntTools; - aNewSR:out Range from IntTools); - ---Purpose: - --- Correct shrunk range taking into account 3D-curve - --- resolution and corresp. tolerances' values of , - --- - CopySource (myclass; - aSourceShape: Shape from TopoDS; - aDestShape:out Shape from TopoDS); - ---Purpose: - --- Make a copy of - --- - -end Tools; diff --git a/src/BOPTools/BOPTools_Tools.cxx b/src/BOPTools/BOPTools_Tools.cxx deleted file mode 100755 index a627ebd626..0000000000 --- a/src/BOPTools/BOPTools_Tools.cxx +++ /dev/null @@ -1,657 +0,0 @@ -// Created on: 2000-11-16 -// Created by: Peter KURNEV -// Copyright (c) 2000-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include - -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - - -static - void CopySrc(const TopoDS_Shape& E, - TopTools_IndexedDataMapOfShapeShape& aMapSS, - TopoDS_Shape& anEdge); - -//======================================================================= -// function: IsBlockInOnFace -// purpose: -//======================================================================= - Standard_Boolean BOPTools_Tools::IsBlockInOnFace (const BOPTools_PaveBlock& aPB1, - const TopoDS_Face& aF, - const Handle(IntTools_Context)& aContext) -{ - Standard_Boolean bFlag; - Standard_Real f1, l1, ULD, VLD; - gp_Pnt2d aP2D; - gp_Pnt aP11, aP12; - // - // Edge's data - const IntTools_ShrunkRange& aSR1=aPB1.ShrunkRange(); - const TopoDS_Edge& aE1=aSR1.Edge(); - - const IntTools_Range& aShrR= aSR1.ShrunkRange(); - aShrR.Range(f1, l1); - // - Standard_Real dt=0.0075, k;//dt=0.001, k; - k=dt*(l1-f1); - f1=f1+k; - l1=l1-k; - // - // Treatment P11 - BOPTools_Tools::PointOnEdge(aE1, f1, aP11); - // - GeomAPI_ProjectPointOnSurf& aProjector=aContext->ProjPS(aF); - aProjector.Perform(aP11); - // - bFlag=aProjector.IsDone(); - if (!bFlag) { - return bFlag; - } - - aProjector.LowerDistanceParameters(ULD, VLD); - aP2D.SetCoord(ULD, VLD); - // - bFlag=aContext->IsPointInOnFace (aF, aP2D); - // - if (!bFlag) { - return bFlag; - } - // - // Treatment P12 - BOPTools_Tools::PointOnEdge(aE1, l1, aP12); - // - aProjector.Perform(aP12); - // - bFlag=aProjector.IsDone(); - if (!bFlag) { - return bFlag; - } - - aProjector.LowerDistanceParameters(ULD, VLD); - aP2D.SetCoord(ULD, VLD); - // - bFlag=aContext->IsPointInOnFace (aF, aP2D); - // - if (!bFlag) { - return bFlag; - } - // - // Treatment intemediate - Standard_Real m1, aTolF, aTolE, aTol, aDist; - m1=IntTools_Tools::IntermediatePoint(f1, l1); - BOPTools_Tools::PointOnEdge(aE1, m1, aP12); - // - aProjector.Perform(aP12); - // - bFlag=aProjector.IsDone(); - if (!bFlag) { - return bFlag; - } - // - aTolE=BRep_Tool::Tolerance(aE1); - aTolF=BRep_Tool::Tolerance(aF); - aTol=aTolE+aTolF; - aDist=aProjector.LowerDistance(); - if (aDist > aTol){ - return Standard_False; - } - - aProjector.LowerDistanceParameters(ULD, VLD); - aP2D.SetCoord(ULD, VLD); - // - bFlag=aContext->IsPointInOnFace (aF, aP2D); - // - if (!bFlag) { - return bFlag; - } - return bFlag; -} - -//======================================================================= -// function: IsBlocksCoinside -// purpose: -//======================================================================= - Standard_Boolean BOPTools_Tools::IsBlocksCoinside(const BOPTools_PaveBlock& aPB1, - const BOPTools_PaveBlock& aPB2) -{ - // - Standard_Real f1, l1, aTol1; - const IntTools_ShrunkRange aSR1=aPB1.ShrunkRange(); - const TopoDS_Edge& aE1=aSR1.Edge(); - aTol1=BRep_Tool::Tolerance(aE1); - aPB1.Parameters(f1, l1); - gp_Pnt aP11, aP12; - BOPTools_Tools::PointOnEdge(aE1, f1, aP11); - BOPTools_Tools::PointOnEdge(aE1, l1, aP12); - // - Standard_Real f2, l2, aTol2; - const IntTools_ShrunkRange aSR2=aPB2.ShrunkRange(); - const TopoDS_Edge& aE2=aSR2.Edge(); - aTol2=BRep_Tool::Tolerance(aE2); - aPB2.Parameters(f2, l2); - gp_Pnt aP21, aP22; - BOPTools_Tools::PointOnEdge(aE2, f2, aP21); - BOPTools_Tools::PointOnEdge(aE2, l2, aP22); - //// - Standard_Real aTolSum, d1121, d1122, d1222, d1221; - - aTolSum=1.05*(aTol1+aTol2); - - d1121=aP11.Distance(aP21); - if (d1121aTolVF) { - BRep_Builder BB; - BB.UpdateVertex (aVF, aNewTol+aDTol); - } -} -// -//======================================================================= -// function: UpdateVertex -// purpose: -//======================================================================= - void BOPTools_Tools::UpdateVertex (const TopoDS_Edge& aE, - const Standard_Real aT, - const TopoDS_Vertex& aV) -{ - Standard_Real aTolV, aDist, aDTol=1.e-12, aFirst, aLast; - gp_Pnt aPc; - - gp_Pnt aPv=BRep_Tool::Pnt(aV); - aTolV=BRep_Tool::Tolerance(aV); - - Handle(Geom_Curve) aC3D=BRep_Tool::Curve(aE, aFirst, aLast); - aC3D->D0(aT, aPc); - aDist=aPv.Distance(aPc); - if (aDist>aTolV) { - BRep_Builder BB; - BB.UpdateVertex (aV, aDist+aDTol); - } -} -// -//======================================================================= -// function: UpdateVertex -// purpose: -//======================================================================= - void BOPTools_Tools::UpdateVertex (const IntTools_Curve& aC, - const Standard_Real aT, - const TopoDS_Vertex& aV) -{ - Standard_Real aTolV, aDist, aDTol=1.e-12; - gp_Pnt aPc; - - gp_Pnt aPv=BRep_Tool::Pnt(aV); - aTolV=BRep_Tool::Tolerance(aV); - - Handle(Geom_Curve) aC3D=aC.Curve(); - aC3D->D0(aT, aPc); - aDist=aPv.Distance(aPc); - if (aDist>aTolV) { - BRep_Builder BB; - BB.UpdateVertex (aV, aDist+aDTol); - } -} -//======================================================================= -// function: MakeSectEdge -// purpose: -//======================================================================= - void BOPTools_Tools::MakeSectEdge(const IntTools_Curve& aIC, - const TopoDS_Vertex& aV1, - const Standard_Real aP1, - const TopoDS_Vertex& aV2, - const Standard_Real aP2, - TopoDS_Edge& aNewEdge) -{ - Handle(Geom_Curve) aC=aIC.Curve (); - - BRepBuilderAPI_MakeEdge aMakeEdge(aC, aV1, aV2, aP1, aP2); - - const TopoDS_Edge& aE=TopoDS::Edge(aMakeEdge.Shape()); - // - // Range must be as it was ! - BRep_Builder aBB; - aBB.Range (aE, aP1, aP2); - // - aNewEdge=aE; - -} - -//======================================================================= -// function: MakeSplitEdge -// purpose: -//======================================================================= - void BOPTools_Tools::MakeSplitEdge(const TopoDS_Edge& aE, - const TopoDS_Vertex& aV1, - const Standard_Real aP1, - const TopoDS_Vertex& aV2, - const Standard_Real aP2, - TopoDS_Edge& aNewEdge) -{ - Standard_Real f, l, aTol; - Handle(Geom_Curve) aC=BRep_Tool::Curve (aE, f, l); - aTol=BRep_Tool::Tolerance(aE); - // - // MakeEdge is used for chechking all input data only - BRepBuilderAPI_MakeEdge aMakeEdge(aC, aV1, aV2, aP1, aP2); - //ZZ const TopoDS_Edge& E1=TopoDS::Edge(aMakeEdge.Shape()); - TopoDS_Edge E=aE; - E.EmptyCopy(); - - BRep_Builder BB; - BB.Add (E, aV1); - BB.Add (E, aV2); - BB.Range(E, aP1, aP2); - BB.UpdateEdge(E, aTol); - aNewEdge=E; -} - -//======================================================================= -// function: MakeNewVertex -// purpose: -//======================================================================= - void BOPTools_Tools::MakeNewVertex(const TopoDS_Vertex& aV1, - const TopoDS_Vertex& aV2, - TopoDS_Vertex& aNewVertex) -{ - gp_Pnt aPnt1=BRep_Tool::Pnt(aV1); - Standard_Real aTol1=BRep_Tool::Tolerance(aV1); - - gp_Pnt aPnt2=BRep_Tool::Pnt(aV2); - Standard_Real aTol2=BRep_Tool::Tolerance(aV2); - - Standard_Real aMaxTol, aDist; - - aDist=aPnt1.Distance(aPnt2); - aMaxTol=(aTol1>aTol2)? aTol1 : aTol2; - aMaxTol=aMaxTol+0.5*aDist; - - const gp_XYZ& aXYZ1=aPnt1.XYZ(); - const gp_XYZ& aXYZ2=aPnt2.XYZ(); - gp_XYZ aNewXYZ=0.5*(aXYZ1+aXYZ2); - - gp_Pnt aNewPnt(aNewXYZ); - BRep_Builder aBB; - aBB.MakeVertex (aNewVertex, aNewPnt, aMaxTol); -} - //======================================================================= -// function: MakeNewVertex -// purpose: -//======================================================================= - void BOPTools_Tools::MakeNewVertex(const gp_Pnt& aP, - const Standard_Real aTol, - TopoDS_Vertex& aNewVertex) -{ - BRep_Builder aBB; - aBB.MakeVertex (aNewVertex, aP, aTol); -} - -//======================================================================= -// function: MakeNewVertex -// purpose: -//======================================================================= - void BOPTools_Tools::MakeNewVertex(const TopoDS_Edge& aE1, - const Standard_Real aParm1, - const TopoDS_Edge& aE2, - const Standard_Real aParm2, - TopoDS_Vertex& aNewVertex) -{ - Standard_Real aTol1, aTol2, aMaxTol, aDist; - gp_Pnt aPnt1, aPnt2; - - PointOnEdge (aE1, aParm1, aPnt1); - PointOnEdge (aE2, aParm2, aPnt2); - - aTol1=BRep_Tool::Tolerance(aE1); - aTol2=BRep_Tool::Tolerance(aE2); - - aDist=aPnt1.Distance(aPnt2); - aMaxTol=(aTol1>aTol2)? aTol1 : aTol2; - aMaxTol=aMaxTol+0.5*aDist; - - const gp_XYZ& aXYZ1=aPnt1.XYZ(); - const gp_XYZ& aXYZ2=aPnt2.XYZ(); - gp_XYZ aNewXYZ=0.5*(aXYZ1+aXYZ2); - - gp_Pnt aNewPnt(aNewXYZ); - BRep_Builder aBB; - aBB.MakeVertex (aNewVertex, aNewPnt, aMaxTol); -} -//======================================================================= -// function: MakeNewVertex -// purpose: -//======================================================================= - void BOPTools_Tools::MakeNewVertex(const TopoDS_Edge& aE1, - const Standard_Real aParm1, - const TopoDS_Face& aF1, - TopoDS_Vertex& aNewVertex) -{ - Standard_Real aTol1, aTol2, aMaxTol, delta=1.e-12; - gp_Pnt aPnt; - - PointOnEdge (aE1, aParm1, aPnt); - - aTol1=BRep_Tool::Tolerance(aE1); - aTol2=BRep_Tool::Tolerance(aF1); - // - //aMaxTol=(aTol1>aTol2)? aTol1 : aTol2; - aMaxTol=aTol1+aTol2+delta; - // - BRep_Builder aBB; - aBB.MakeVertex (aNewVertex, aPnt, aMaxTol); -} - -//======================================================================= -// function: PointOnEdge -// purpose: -//======================================================================= - void BOPTools_Tools::PointOnEdge(const TopoDS_Edge& aE, - const Standard_Real aParm, - gp_Pnt& aPnt) -{ - Standard_Real f, l; - Handle(Geom_Curve) C1=BRep_Tool::Curve(aE, f, l); - C1->D0(aParm, aPnt); -} - -//======================================================================= -//function : CopySource -//purpose : -//======================================================================= - void BOPTools_Tools::CopySource(const TopoDS_Shape& aSS, - TopoDS_Shape& aSD) -{ - TopTools_IndexedDataMapOfShapeShape aMapSS; - CopySrc (aSS, aMapSS, aSD); -} - -//======================================================================= -//function : MapShapes -//purpose : -//======================================================================= - void BOPTools_Tools::MapShapes(const TopoDS_Shape& aS, - TopTools_IndexedMapOfShape& aM) -{ - aM.Add(aS); - TopoDS_Iterator anIt; - anIt.Initialize(aS); - for (; anIt.More(); anIt.Next()) { - const TopoDS_Shape& aSx=anIt.Value(); - BOPTools_Tools::MapShapes(aSx, aM); - } -} - -//======================================================================= -//function : CorrectRange -//purpose : -//======================================================================= - void BOPTools_Tools::CorrectRange(const TopoDS_Edge& aE1, - const TopoDS_Edge& aE2, - const IntTools_Range& aSR, - IntTools_Range& aNewSR) -{ - Standard_Integer i; - Standard_Real aRes, aTolE1, aTolE2, aTF, aTL, dT; - BRepAdaptor_Curve aBC; - GeomAbs_CurveType aCT; - gp_Pnt aP; - gp_Vec aDer; - // - aNewSR=aSR; - // - //modified by NIZNHY-PKV Tue Feb 10 08:47:03 2009f - aBC.Initialize(aE1); - aCT=aBC.GetType(); - if (aCT==GeomAbs_Line) { - return; - } - //modified by NIZNHY-PKV Tue Feb 10 08:47:06 2009t - // - dT=Precision::PConfusion(); - aTF=aSR.First(); - aTL=aSR.Last(); - // - //modified by NIZNHY-PKV Tue Feb 10 08:47:39 2009f - /* - aBC.Initialize(aE1); - aCT=aBC.GetType(); - */ - //modified by NIZNHY-PKV Tue Feb 10 08:47:43 2009t - // - aTolE1=BRep_Tool::Tolerance(aE1); - aTolE2=BRep_Tool::Tolerance(aE2); - // - for(i=0; i<2; ++i) { - aRes = 2.*(aTolE1 + aTolE2); - // - if (aCT==GeomAbs_BezierCurve || - aCT==GeomAbs_BSplineCurve|| - aCT==GeomAbs_OtherCurve) { - - if(!i){ - aBC.D1 (aTF, aP, aDer); - } - else { - aBC.D1 (aTL, aP, aDer); - } - // - Standard_Real aMgn = aDer.Magnitude(); - - if(aMgn > 1.e-12) { - aRes = aRes/aMgn ; - } - else { - aRes = aBC.Resolution(aRes); - } - } // if (aCT==GeomAbs_BezierCurve||... - else { - aRes = aBC.Resolution(aRes); - } - // - if(!i) { - aNewSR.SetFirst (aTF+aRes); - } - else { - aNewSR.SetLast (aTL-aRes); - } - // - if ((aNewSR.Last()-aNewSR.First()) < dT) { - aNewSR=aSR; - } - //aNewSR=((aNewSR.Last()-aNewSR.First()) < dT) ? aSR : aNewSR; - } -} - -//======================================================================= -//function : CorrectRange -//purpose : -//======================================================================= - void BOPTools_Tools::CorrectRange(const TopoDS_Edge& aE, - const TopoDS_Face& aF, - const IntTools_Range& aSR, - IntTools_Range& aNewSR) -{ - Standard_Integer i; - Standard_Real aRes, aTolF, aTF, aTL, dT; - BRepAdaptor_Curve aBC; - GeomAbs_CurveType aCT; - gp_Pnt aP; - gp_Vec aDer; - // - aNewSR=aSR; - // - dT=Precision::PConfusion(); - aTF=aSR.First(); - aTL=aSR.Last(); - // - aBC.Initialize(aE); - aCT=aBC.GetType(); - // - aTolF=BRep_Tool::Tolerance(aF); - // - for(i=0; i<2; ++i) { - aRes =aTolF; - - if (aCT==GeomAbs_BezierCurve || - aCT==GeomAbs_BSplineCurve|| - aCT==GeomAbs_OtherCurve) { - - if(!i){ - aBC.D1 (aTF, aP, aDer); - } - else { - aBC.D1 (aTL, aP, aDer); - } - // - Standard_Real aMgn = aDer.Magnitude(); - - if(aMgn > 1.e-12) { - aRes = aRes/aMgn ; - } - else { - aRes = aBC.Resolution(aRes); - } - } // if (aCT==GeomAbs_BezierCurve||... - else { - aRes = aBC.Resolution(aRes); - } - // - if(!i) { - aNewSR.SetFirst (aTF+aRes); - } - else { - aNewSR.SetLast (aTL-aRes); - } - // - if ((aNewSR.Last()-aNewSR.First()) < dT) { - aNewSR=aSR; - } - } -} - -//======================================================================= -//function : CopySrc -//purpose : -//======================================================================= -void CopySrc(const TopoDS_Shape& E, - TopTools_IndexedDataMapOfShapeShape& aMapSS, - TopoDS_Shape& anEdge) -{ - BRep_Builder BB; - TopAbs_ShapeEnum aTT; - Standard_Integer aR; - aTT=E.ShapeType(); - - if (aMapSS.Contains(E)) { - anEdge=aMapSS.ChangeFromKey(E); - if (aTT==TopAbs_EDGE) - return; - } - else { - anEdge=E.EmptyCopied(); - aMapSS.Add(E, anEdge); - } - - aR=(Standard_Integer)aTT+1; - - if (aR>TopAbs_VERTEX) { - return; - } - - Standard_Boolean free = anEdge.Free(); - anEdge.Free(Standard_True); - - aTT=(TopAbs_ShapeEnum) aR; - TopExp_Explorer anExpVertices(E, aTT); - for (; anExpVertices.More(); anExpVertices.Next()) { - const TopoDS_Shape& V=anExpVertices.Current(); - TopoDS_Shape aVertex; - - CopySrc (V, aMapSS, aVertex); - - aVertex.Orientation(V.Orientation()); - BB.Add(anEdge, aVertex); - } - - anEdge.Free(free); -} diff --git a/src/BOPTools/BOPTools_Tools2D.cdl b/src/BOPTools/BOPTools_Tools2D.cdl deleted file mode 100755 index a6e45079a4..0000000000 --- a/src/BOPTools/BOPTools_Tools2D.cdl +++ /dev/null @@ -1,248 +0,0 @@ --- Created on: 2001-04-02 --- Created by: Peter KURNEV --- Copyright (c) 2001-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class Tools2D from BOPTools - - ---Purpose: - --- The class contains handy static functions - --- dealing with the topology -uses - Vec from gp, - Dir from gp, - Vertex from TopoDS, - Edge from TopoDS, - Face from TopoDS, - - Curve from Geom2d, - Curve from Geom, - ProjectedCurve from ProjLib - -is - - RemovePCurveForEdgeOnFace (myclass; - aE: Edge from TopoDS; - aF: Face from TopoDS); - ---Purpose: - --- Remove P-Curve of the edge on the face - --- - BuildPCurveForEdgeOnFace (myclass; - aE: Edge from TopoDS; - aF: Face from TopoDS); - ---Purpose: - --- Compute P-Curve for the edge on the face - --- - EdgeTangent (myclass; - anE : Edge from TopoDS; - aT : Real from Standard; - Tau : out Vec from gp) - returns Boolean from Standard; - ---Purpose: - --- Compute tangent for the edge [in 3D] at parameter - --- - FaceNormal (myclass; - aF: Face from TopoDS; - U : Real from Standard; - V : Real from Standard; - aN: out Vec from gp); - ---Purpose: - --- Compute normal for the face at parameters - --- of the corresp. surface. - --- - PointOnSurface (myclass; - aE: Edge from TopoDS; - aF: Face from TopoDS; - aT: Real from Standard; - U : out Real from Standard; - V : out Real from Standard); - ---Purpose: - --- Compute surface parameters of the face - --- for the point from the edge at parameter . - --- - CurveOnSurface (myclass; - aE: Edge from TopoDS; - aF: Face from TopoDS; - aC : out Curve from Geom2d; - aToler: out Real from Standard; - aTrim3d:Boolean from Standard); - ---Purpose: - --- Get P-Curve for the edge on surface . - --- If the P-Curve does not exist, build it using Make2D(). - --- [aToler] - reached tolerance - --- [aTrim3d] - trimming flag. - --- - CurveOnSurface (myclass; - aE: Edge from TopoDS; - aF: Face from TopoDS; - aC : out Curve from Geom2d; - aFirst: out Real from Standard; - aLast : out Real from Standard; - aToler: out Real from Standard; - aTrim3d:Boolean from Standard); - - ---Purpose: - --- Get P-Curve for the edge on surface . - --- If the P-Curve does not exist, build it using Make2D(). - --- [aFirst, aLast] - range of the P-Curve - --- [aToler] - reached tolerance - --- [aTrim3d] - trimming flag. - --- - HasCurveOnSurface (myclass; - aE: Edge from TopoDS; - aF: Face from TopoDS; - aC : out Curve from Geom2d; - aFirst: out Real from Standard; - aLast : out Real from Standard; - aToler: out Real from Standard) - returns Boolean from Standard; - ---Purpose: - --- Returns TRUE if the edge has P-Curve - --- on surface . - --- [aFirst, aLast] - range of the P-Curve - --- [aToler] - reached tolerance - --- If the P-Curve does not exist, aC.IsNull()=TRUE. - --- - HasCurveOnSurface (myclass; - aE: Edge from TopoDS; - aF: Face from TopoDS) - returns Boolean from Standard; - ---Purpose: - --- Returns TRUE if the edge has P-Curve - --- on surface . - --- If the P-Curve does not exist, aC.IsNull()=TRUE. - --- - MakeCurveOnSurface (myclass; - aE: Edge from TopoDS; - aF: Face from TopoDS; - aC : out Curve from Geom2d; - aFirst: out Real from Standard; - aLast : out Real from Standard; - aToler: out Real from Standard; - aTrim3d:Boolean from Standard); - - ---Purpose: - --- Same as Make2D() - --- - Make2D (myclass; - aE: Edge from TopoDS; - aF: Face from TopoDS; - aC : out Curve from Geom2d; - aFirst: out Real from Standard; - aLast : out Real from Standard; - aToler: out Real from Standard; - aTrim3d:Boolean from Standard); - ---Purpose: - --- Make P-Curve for the edge on surface . - --- [aFirst, aLast] - range of the P-Curve - --- [aToler] - reached tolerance - --- [aTrim3d] - trimming flag. - --- - MakePCurveOnFace (myclass; - aF: Face from TopoDS; - C3D : Curve from Geom; - aC : out Curve from Geom2d; - aToler: out Real from Standard) ; - ---Purpose: - --- Make P-Curve for the 3D-curve on surface . - --- [aToler] - reached tolerance - --- - MakePCurveOnFace (myclass; - aF: Face from TopoDS; - C3D : Curve from Geom; - aT1 : Real from Standard; - aT2 : Real from Standard; - aC : out Curve from Geom2d; - aToler: out Real from Standard) ; - ---Purpose: - --- Make P-Curve for the 3D-curve on surface . - --- [aT1, aT2] - range to build - --- [aToler] - reached tolerance - --- - AdjustPCurveOnFace (myclass; - aF : Face from TopoDS; - C3D : Curve from Geom; - aC2D : Curve from Geom2d; - aC2DA : out Curve from Geom2d); - ---Purpose: - --- Adjust P-Curve (3D-curve ) on surface . - --- - AdjustPCurveOnFace (myclass; - aF : Face from TopoDS; - aT1 : Real from Standard; - aT2 : Real from Standard; - aC2D : Curve from Geom2d; - aC2DA : out Curve from Geom2d); - ---Purpose: - --- Adjust P-Curve (3D-curve ) on surface . - --- [aT1, aT2] - range to adjust - --- - MakePCurveOfType (myclass; - PC : ProjectedCurve from ProjLib; - aC : out Curve from Geom2d); - ---Purpose: - --- Make empty P-Curve of relevant to type - --- - TangentOnEdge (myclass; - aParm: Real from Standard; - anE : Edge from TopoDS; - aTang: out Vec from gp) - returns Boolean from Standard; - ---Purpose: - --- Compute tangent for the edge at parameter - --- - TangentOnEdge (myclass; - anE : Edge from TopoDS; - aDTang: out Dir from gp) - returns Boolean from Standard; - ---Purpose: - --- Compute tangent for the edge at arbitrary intermediate parameter. - --- - TangentOnVertex (myclass; - aVF : Vertex from TopoDS; - aVL : Vertex from TopoDS; - anE : Edge from TopoDS; - aTang: out Vec from gp) - returns Boolean from Standard; - ---Purpose: - --- Compute tangent for the vertex point for the edge . - --- is opposite vertex of the edge - --- - EdgeBounds (myclass; - anE : Edge from TopoDS; - aFirst: out Real from Standard; - aLast : out Real from Standard); - ---Purpose: - --- Returns parametric range for the edge . - --- - IntermediatePoint (myclass; - aFirst: Real from Standard; - aLast : Real from Standard) - returns Real from Standard; - ---Purpose: - --- Compute intermediate value in between [aFirst, aLast] . - --- - IntermediatePoint (myclass; - anE : Edge from TopoDS) - returns Real from Standard; - ---Purpose: - --- Compute intermediate value of parameter for the edge . - --- - -end Tools2D; diff --git a/src/BOPTools/BOPTools_Tools2D.cxx b/src/BOPTools/BOPTools_Tools2D.cxx deleted file mode 100755 index 6ea6565995..0000000000 --- a/src/BOPTools/BOPTools_Tools2D.cxx +++ /dev/null @@ -1,751 +0,0 @@ -// Created on: 2001-04-02 -// Created by: Peter KURNEV -// Copyright (c) 2001-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include - -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include - - -static - Standard_Boolean CheckEdgeLength (const TopoDS_Edge& E); - -//======================================================================= -//function : EdgeTangent -//purpose : -//======================================================================= - Standard_Boolean BOPTools_Tools2D::EdgeTangent(const TopoDS_Edge& anEdge, - const Standard_Real aT, - gp_Vec& aTau) -{ - Standard_Boolean isdgE; - Standard_Real first, last; - - isdgE = BRep_Tool::Degenerated(anEdge); - if (isdgE) { - return Standard_False; - } - if (!CheckEdgeLength(anEdge)) { - return Standard_False; - } - - Handle(Geom_Curve) aC=BRep_Tool::Curve(anEdge, first, last); - gp_Pnt aP; - aC->D1(aT, aP, aTau); - Standard_Real mod = aTau.Magnitude(); - if(mod > gp::Resolution()) { - aTau /= mod; - } - else { - return Standard_False; - } - //aTau.Normalize(); - if (anEdge.Orientation() == TopAbs_REVERSED){ - aTau.Reverse(); - } - return Standard_True; -} - - -//======================================================================= -//function : FaceNormal -//purpose : -//======================================================================= - void BOPTools_Tools2D::FaceNormal (const TopoDS_Face& aF, - const Standard_Real U, - const Standard_Real V, - gp_Vec& aN) -{ - gp_Pnt aPnt ; - gp_Vec aD1U, aD1V; - Handle(Geom_Surface) aSurface; - - aSurface=BRep_Tool::Surface(aF); - aSurface->D1 (U, V, aPnt, aD1U, aD1V); - aN=aD1U.Crossed(aD1V); - aN.Normalize(); - if (aF.Orientation() == TopAbs_REVERSED){ - aN.Reverse(); - } - return; -} -//======================================================================= -//function : RemovePCurveForEdgeOnFace -//purpose : -//======================================================================= - void BOPTools_Tools2D::RemovePCurveForEdgeOnFace (const TopoDS_Edge& aE, - const TopoDS_Face& aF) -{ - BRep_Builder aBB; - Handle(Geom2d_Curve) aC2D; - Standard_Real aTol; - - aTol=BRep_Tool::Tolerance(aE); - aBB.UpdateEdge(aE, aC2D, aF, aTol); -} -//======================================================================= -//function : BuildPCurveForEdgeOnFace -//purpose : -//======================================================================= - void BOPTools_Tools2D::BuildPCurveForEdgeOnFace (const TopoDS_Edge& aE, - const TopoDS_Face& aF) -{ - BRep_Builder aBB; - Handle(Geom2d_Curve) aC2D; - Standard_Real aTolPC, aTolFact, aTolEdge, aFirst, aLast; - - Standard_Boolean aHasOld; - aHasOld=BOPTools_Tools2D::HasCurveOnSurface (aE, aF, aC2D, aFirst, aLast, aTolEdge); - if (aHasOld) { - return; - } - - - BOPTools_Tools2D::CurveOnSurface(aE, aF, aC2D, aTolPC, Standard_True); - - aTolEdge=BRep_Tool::Tolerance(aE); - - aTolFact=Max(aTolEdge, aTolPC); - - aBB.UpdateEdge(aE, aC2D, aF, aTolFact); - return; -} -//======================================================================= -//function : PointOnOnSurface -//purpose : -//======================================================================= - void BOPTools_Tools2D::PointOnSurface (const TopoDS_Edge& aE, - const TopoDS_Face& aF, - const Standard_Real aParameter, - Standard_Real& U, - Standard_Real& V) -{ - gp_Pnt2d aP2D; - Handle(Geom2d_Curve) aC2D; - Standard_Real aToler, aFirst, aLast; - - BOPTools_Tools2D::CurveOnSurface (aE, aF, aC2D, aFirst, aLast, aToler, Standard_True); - aC2D->D0(aParameter, aP2D); - U=aP2D.X(); - V=aP2D.Y(); - return; -} - -//======================================================================= -//function : CurveOnSurface -//purpose : -//======================================================================= - void BOPTools_Tools2D::CurveOnSurface (const TopoDS_Edge& aE, - const TopoDS_Face& aF, - Handle(Geom2d_Curve)& aC2D, - Standard_Real& aToler, - const Standard_Boolean trim3d) -{ - Standard_Real aFirst, aLast; - - BOPTools_Tools2D::CurveOnSurface (aE, aF, aC2D, aFirst, aLast, aToler, trim3d); - - return; -} -//======================================================================= -//function : CurveOnSurface -//purpose : -//======================================================================= - void BOPTools_Tools2D::CurveOnSurface (const TopoDS_Edge& aE, - const TopoDS_Face& aF, - Handle(Geom2d_Curve)& aC2D, - Standard_Real& aFirst, - Standard_Real& aLast, - Standard_Real& aToler, - const Standard_Boolean trim3d) -{ - Standard_Boolean aHasOld; - Handle(Geom2d_Curve) C2D; - - aHasOld=BOPTools_Tools2D::HasCurveOnSurface (aE, aF, C2D, aFirst, aLast, aToler); - if (aHasOld) { - aC2D=C2D; - return; - } - - BOPTools_Tools2D::Make2D(aE, aF, C2D, aFirst, aLast, aToler, trim3d); - aC2D=C2D; - return; -} - -//======================================================================= -//function : HasCurveOnSurface -//purpose : -//======================================================================= - Standard_Boolean BOPTools_Tools2D::HasCurveOnSurface (const TopoDS_Edge& aE, - const TopoDS_Face& aF, - Handle(Geom2d_Curve)& aC2D, - Standard_Real& aFirst, - Standard_Real& aLast, - Standard_Real& aToler) -{ - Standard_Boolean aHasOld; - - aToler=BRep_Tool::Tolerance(aE); - BRep_Tool::Range(aE, aFirst, aLast); - - if((aLast - aFirst) < Precision::PConfusion()) { - return Standard_False; - } - - aC2D =BRep_Tool::CurveOnSurface(aE, aF, aFirst, aLast); - aHasOld=!aC2D.IsNull(); - return aHasOld; -} -//======================================================================= -//function : HasCurveOnSurface -//purpose : -//======================================================================= - Standard_Boolean BOPTools_Tools2D::HasCurveOnSurface (const TopoDS_Edge& aE, - const TopoDS_Face& aF) - -{ - Standard_Boolean aHasOld; - Handle(Geom2d_Curve) aC2D; - Standard_Real aFirst, aLast; - BRep_Tool::Range(aE, aFirst, aLast); - - if((aLast - aFirst) < Precision::PConfusion()) { - return Standard_False; - } - - aC2D =BRep_Tool::CurveOnSurface(aE, aF, aFirst, aLast); - aHasOld=!aC2D.IsNull(); - return aHasOld; -} -//======================================================================= -//function : MakeCurveOnSurface -//purpose : -//======================================================================= - void BOPTools_Tools2D::MakeCurveOnSurface (const TopoDS_Edge& aE, - const TopoDS_Face& aF, - Handle(Geom2d_Curve)& aC2D, - Standard_Real& aFirst, - Standard_Real& aLast, - Standard_Real& aToler, - const Standard_Boolean trim3d) -{ - BOPTools_Tools2D::Make2D(aE, aF, aC2D, aFirst, aLast, aToler, trim3d); -} - -//======================================================================= -//function : Make2D -//purpose : -//======================================================================= - void BOPTools_Tools2D::Make2D (const TopoDS_Edge& aE, - const TopoDS_Face& aF, - Handle(Geom2d_Curve)& aC2D, - Standard_Real& aFirst, - Standard_Real& aLast, - Standard_Real& aToler, - const Standard_Boolean trim3d) -{ - Standard_Boolean aLocIdentity; - Standard_Real f3d, l3d; - TopLoc_Location aLoc; - - Handle(Geom2d_Curve) C2D; - - - C2D=BRep_Tool::CurveOnSurface(aE, aF, aFirst, aLast); - - if (!C2D.IsNull()) { - aC2D=C2D; - return; - } - - Handle(Geom_Curve) C3D3, C3D2, C3D; - C3D = BRep_Tool::Curve(aE, aLoc, f3d, l3d); - // - if (C3D.IsNull()) { - // aE has no 3D curve, so nothing is done - } - // - aLocIdentity=aLoc.IsIdentity(); - - if (aLocIdentity) { - C3D2 = C3D; - } - else { - C3D2 = Handle(Geom_Curve):: - DownCast(C3D->Transformed(aLoc.Transformation())); - } - - if (trim3d) { - - C3D3=C3D2; - } - - else { - C3D3=C3D2; - } - // - aToler=.5*BRep_Tool::Tolerance(aE); - BOPTools_Tools2D::MakePCurveOnFace(aF, C3D3, f3d, l3d, aC2D, aToler); - // - aFirst = f3d; - aLast = l3d; -} - -//======================================================================= -//function : MakePCurveOnFace -//purpose : -//======================================================================= - void BOPTools_Tools2D::MakePCurveOnFace (const TopoDS_Face& aF, - const Handle(Geom_Curve)& aC3D, - Handle(Geom2d_Curve)& aC2D, //-> - Standard_Real& TolReached2d) -{ - Standard_Real aFirst, aLast; - - aFirst = aC3D -> FirstParameter(); - aLast = aC3D -> LastParameter(); - // - TolReached2d=0.; - // - BOPTools_Tools2D::MakePCurveOnFace (aF, aC3D, aFirst, aLast, aC2D, TolReached2d); -} - -//======================================================================= -//function : MakePCurveOnFace -//purpose : -//======================================================================= - void BOPTools_Tools2D::MakePCurveOnFace (const TopoDS_Face& aF, - const Handle(Geom_Curve)& aC3D, - const Standard_Real aFirst, - const Standard_Real aLast, - Handle(Geom2d_Curve)& aC2D, - Standard_Real& TolReached2d) -{ - Standard_Real aTolR; - Handle(Geom2d_Curve) aC2DA; - - BRepAdaptor_Surface aBAS(aF, Standard_False); - Handle(BRepAdaptor_HSurface) aBAHS = new BRepAdaptor_HSurface(aBAS); - Handle(GeomAdaptor_HCurve) aBAHC = new GeomAdaptor_HCurve(aC3D, aFirst, aLast); - - ProjLib_ProjectedCurve aProjCurv(aBAHS, aBAHC);// 1 - BOPTools_Tools2D::MakePCurveOfType(aProjCurv, aC2D); - aTolR=aProjCurv.GetTolerance(); - // - if (aC2D.IsNull()) { - ProjLib_ProjectedCurve aProjCurvAgain(aBAHS, aBAHC, TolReached2d);// 2 - BOPTools_Tools2D::MakePCurveOfType(aProjCurvAgain, aC2D); - aTolR = aProjCurvAgain.GetTolerance(); - // - if (aC2D.IsNull()) { - Standard_Real aTR=0.0001; - ProjLib_ProjectedCurve aProj3(aBAHS, aBAHC, aTR);// 3 - BOPTools_Tools2D::MakePCurveOfType(aProj3, aC2D); - aTolR = aProj3.GetTolerance(); - } - } - TolReached2d=aTolR; - - BOPTools_Tools2D::AdjustPCurveOnFace (aF, aFirst, aLast, aC2D, aC2DA); - aC2D=aC2DA; -} - -//======================================================================= -//function : AdjustPCurveOnFace -//purpose : -//======================================================================= - void BOPTools_Tools2D::AdjustPCurveOnFace (const TopoDS_Face& aF, - const Handle(Geom_Curve)& aC3D, - const Handle(Geom2d_Curve)& aC2D, - Handle(Geom2d_Curve)& aC2DA) -{ - Standard_Real first, last; - - first = aC3D -> FirstParameter(); - last = aC3D -> LastParameter(); - - BOPTools_Tools2D::AdjustPCurveOnFace (aF, first, last, aC2D, aC2DA); -} -//======================================================================= -//function : AdjustPCurveOnFace -//purpose : -//======================================================================= - void BOPTools_Tools2D::AdjustPCurveOnFace (const TopoDS_Face& aF, - const Standard_Real aFirst, - const Standard_Real aLast, - const Handle(Geom2d_Curve)& aC2D, - Handle(Geom2d_Curve)& aC2DA) -{ - Standard_Boolean mincond, maxcond, decalu, decalv; - Standard_Integer k, iCnt; - Standard_Real UMin, UMax, VMin, VMax, aT, u2, v2, du, dv, aDelta; - Standard_Real aUPeriod, aUP2, aUP1, aUNew, aDif, aUx; - // - aDelta=Precision::PConfusion(); - - BRepAdaptor_Surface aBAS(aF, Standard_False); - - BRepTools::UVBounds(aF, UMin, UMax, VMin, VMax); - - aT =.5*(aFirst+aLast); - - gp_Pnt2d pC2D; - aC2D->D0(aT, pC2D); - - u2 = pC2D.X(); - v2 = pC2D.Y(); - - du = 0.; - if (aBAS.IsUPeriodic()) { - aUPeriod=aBAS.UPeriod(); - mincond = (u2 < UMin-aDelta); - maxcond = (u2 > UMax+aDelta); - - decalu = mincond || maxcond; - if (decalu) { - iCnt=1; - aUP2=aUPeriod+aUPeriod+aDelta; - aUP1=aUPeriod+aDelta; - // - if (u2 > aUP2) { - for(k=1; 1; ++k) { - aUx=u2-k*aUPeriod; - if (aUx < aUP1) { - iCnt=k; - break; - } - } - } - else if (u2 < -aUP2) { - for(k=1; 1; ++k) { - aUx=u2+k*aUPeriod; - if (aUx > -aUP1) { - //modified by NIZNHY-PKV Thu Apr 12 08:12:09 2012f - iCnt=k+1; - //iCnt=k; - //modified by NIZNHY-PKV Thu Apr 12 08:12:11 2012t - break; - } - } - } - du = ( mincond ) ? aUPeriod : -aUPeriod; - du=iCnt*du; - } - // - aUNew=u2+du; - if (aUNew<(UMin-aDelta) || - aUNew>(UMax+aDelta)) { - // So previous correction was wrong. - // Try to be closer to UMin or UMax. - du=0.; - if (u2>UMax){ - aDif=u2-UMax; - if (aDif < 4.e-7) { - du=-aDif; - } - } - } - } // if (BAHS->IsUPeriodic()) - // - // dv - dv = 0.; - if (aBAS.IsVPeriodic()) { - Standard_Real aVPeriod, aVm, aVr, aVmid, dVm, dVr; - // - aVPeriod=aBAS.VPeriod(); - mincond = (VMin - v2 > aDelta); - maxcond = (v2 - VMax > aDelta); - decalv = mincond || maxcond; - if (decalv) { - dv = ( mincond ) ? aVPeriod : -aVPeriod; - } - // - //xf - if ((VMax-VMinCopy()); - gp_Vec2d aV2D(du,dv); - PCT->Translate(aV2D); - aC2Dx = PCT; - } - - aC2DA=aC2Dx; -} - - -//======================================================================= -//function : MakePCurveOfType -//purpose : -//======================================================================= - void BOPTools_Tools2D::MakePCurveOfType(const ProjLib_ProjectedCurve& PC, - Handle(Geom2d_Curve)& C2D) -{ - - switch (PC.GetType()) { - - case GeomAbs_Line : - C2D = new Geom2d_Line(PC.Line()); - break; - case GeomAbs_Circle : - C2D = new Geom2d_Circle(PC.Circle()); - break; - case GeomAbs_Ellipse : - C2D = new Geom2d_Ellipse(PC.Ellipse()); - break; - case GeomAbs_Parabola : - C2D = new Geom2d_Parabola(PC.Parabola()); - break; - case GeomAbs_Hyperbola : - C2D = new Geom2d_Hyperbola(PC.Hyperbola()); - break; - case GeomAbs_BSplineCurve : - C2D = PC.BSpline(); - break; - case GeomAbs_BezierCurve : - case GeomAbs_OtherCurve : - default : - Standard_NotImplemented::Raise("BOPTools_Tools2D::MakePCurveOfType"); - break; - } -} - -//======================================================================= -//function : TangentOnEdge -//purpose : -//======================================================================= - Standard_Boolean BOPTools_Tools2D::TangentOnEdge(const Standard_Real par, - const TopoDS_Edge& E, - gp_Vec& Tg) -{ - Standard_Boolean isdgE; - - isdgE = BRep_Tool::Degenerated(E); - if (isdgE) { - return Standard_False; - } - if (!CheckEdgeLength(E)) { - return Standard_False; - } - - BRepAdaptor_Curve BC(E); - // - // Body - Standard_Real f, l, tolE, tolp; - Standard_Boolean onf, onl, inbounds; - - f = BC.FirstParameter(); - l = BC.LastParameter(); - tolE = BC.Tolerance(); - tolp = BC.Resolution(tolE); - - onf = Abs(f-par) Precision::Confusion()); -} diff --git a/src/BOPTools/BOPTools_Tools3D.cdl b/src/BOPTools/BOPTools_Tools3D.cdl deleted file mode 100755 index 24fad78a27..0000000000 --- a/src/BOPTools/BOPTools_Tools3D.cdl +++ /dev/null @@ -1,472 +0,0 @@ --- Created on: 2001-04-05 --- Created by: Peter KURNEV --- Copyright (c) 2001-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class Tools3D from BOPTools - - ---Purpose: - -- The class contains handy static functions - -- dealing with the topology - -uses - Pln from gp, - Dir from gp, - Pnt from gp, - Pnt2d from gp, - - Surface from Geom, - - Shape from TopoDS, - Wire from TopoDS, - Face from TopoDS, - Edge from TopoDS, - Solid from TopoDS, - - ShapeEnum from TopAbs, - Orientation from TopAbs, - State from TopAbs, - - ListOfShape from TopTools, - Context from IntTools, - - IndexedDataMapOfShapeListOfShape from TopTools - -is - - SubShapesAmount (myclass; - aS: Shape from TopoDS; - aT: ShapeEnum from TopAbs) - returns Integer from Standard ; - ---Purpose: - -- Returns amount of sub-shapes of type - -- for the shape - -- - IsConvexWire (myclass; - aW: Wire from TopoDS) - returns Boolean from Standard ; - ---Purpose: - -- Returns TRUE if - -- amount of the vertices <= amount of the edges> - -- for the wire - -- - - RemoveSims (myclass; - aF: Face from TopoDS; - aContext: Context from IntTools); - ---Purpose: - -- Remove seam edges from face - -- - RemoveSims (myclass; - aS: Shape from TopoDS; - aContext: Context from IntTools); - ---Purpose: - -- Remove seam edges from all faces of shape - -- - EdgeOrientation (myclass; - aEx: Edge from TopoDS; - aF1: Face from TopoDS; - aF2: Face from TopoDS) - returns Orientation from TopAbs; - ---Purpose: - -- For the draft section edge computes orientation - -- in accordance with vector product between normals to - -- the faces , - -- - IsSplitToReverse1 (myclass; - aE1: Edge from TopoDS; - aE2: Edge from TopoDS; - aContext: Context from IntTools) - returns Boolean from Standard; - ---Purpose: - -- Returns TRUE if direction of the edge is not - -- the same as for the edge - -- (using projection) - -- - DoSplitSEAMOnFace (myclass; - aSp: Edge from TopoDS; - aF : Face from TopoDS); - ---Purpose: - -- Make the edge seam edge for the face - -- - - --modified by NIZHNY-MKK Mon Feb 17 15:02:01 2003.BEGIN - DoSplitSEAMOnFace (myclass; - theSplit : Edge from TopoDS; - theSeam : Edge from TopoDS; - theFace : Face from TopoDS; - IsReversed: out Boolean from Standard) - returns Boolean from Standard; - ---Purpose: - -- Make the edge seam edge for the face - -- It uses pcurves of to make seam edge. - -- IsReversed is true if pcurves of and are - -- reversed according to each other. - -- Returns true if was made seam edge for - -- - --modified by NIZHNY-MKK Mon Feb 17 15:02:04 2003.END - IsTouchCase (myclass; - aEx: Edge from TopoDS; - aF1: Face from TopoDS; - aF2: Face from TopoDS) - returns Boolean from Standard; - ---Purpose: - -- Returns TRUE if the edge is section edge - -- between touching faces , - -- - GetTangentToEdge (myclass; - aE: Edge from TopoDS; - aT: Real from Standard; - aD:out Dir from gp) - returns Boolean from Standard; - ---Purpose: - -- Computes tangent (3D) for the edge - -- at parameter - -- Returns TRUE if the edge is not degenerated. - -- - GetTangentToEdge (myclass; - aE: Edge from TopoDS; - aD:out Dir from gp) - returns Boolean from Standard; - ---Purpose: - --- Computes tangent (3D) for the edge - --- at arbitrary intermediate parameter - --- Returns TRUE if the edge is not degenerated. - --- - GetNormalToFaceOnEdge (myclass; - aE: Edge from TopoDS; - aF: Face from TopoDS; - aT: Real from Standard; - aD:out Dir from gp); - ---Purpose: - --- Computes normal to the face for the point on the edge - --- at parameter - --- - GetNormalToFaceOnEdge (myclass; - aE: Edge from TopoDS; - aF: Face from TopoDS; - aD:out Dir from gp); - ---Purpose: - --- Computes normal to the face for the point on the edge - --- at arbitrary intermediate parameter - --- - GetBiNormal (myclass; - aE: Edge from TopoDS; - aF: Face from TopoDS; - aT: Real from Standard; - aD:out Dir from gp); - ---Purpose: - --- Computes binormal to the face for the point on the edge - --- at parameter - --- - GetBiNormal (myclass; - aE: Edge from TopoDS; - aF: Face from TopoDS; - aD:out Dir from gp); - ---Purpose: - --- Computes binormal to the face for the point on the edge - --- at arbitrary intermediate parameter - --- - IsSplitToReverse(myclass; - aE : Edge from TopoDS; - aSp: Edge from TopoDS) - returns Boolean from Standard; - ---Purpose: - --- Returns TRUE if direction of the edge is not - --- the same as for the edge - --- - GetAdjacentFace (myclass; - aF : Face from TopoDS; - aE : Edge from TopoDS; - aEFMap: IndexedDataMapOfShapeListOfShape from TopTools; - anAdjF:out Face from TopoDS) - returns Boolean from Standard; - ---Purpose: - --- Get face that is adjacent to the face through - --- the edge (using map EF ) - --- Returns FALSE if adjacent face is not found - --- - IsKeepTwice (myclass; - aF1 : Face from TopoDS; - aF2 : Face from TopoDS; - aF2Adj: Face from TopoDS; - aSpEF2: Edge from TopoDS) - returns Boolean from Standard; - ---Purpose: - --- Returns TRUE if pair of faces and - --- that are adjacent faces through the edge - --- crosses the face by - --- - SenseFlag (myclass; - aNF1 : Dir from gp; - aNF2 : Dir from gp) - returns Integer from Standard; - ---Purpose: - --- Returns 1 if scalar product aNF1* aNF2>0. - --- Returns 0 if directions aNF1 aNF2 coinside - --- Returns -1 if scalar product aNF1* aNF2<0. - --- - GetNormalToSurface (myclass; - aS: Surface from Geom; - U : Real from Standard; - V : Real from Standard; - aD:out Dir from gp) - returns Boolean from Standard; - ---Purpose: - --- Compute normal to surface in point (U,V) - --- Returns TRUE if directions aD1U, aD1V coinside - --- - GetPlanes (myclass; - aSp : Edge from TopoDS; - aE2 : Edge from TopoDS; - aEFMap2: IndexedDataMapOfShapeListOfShape from TopTools; - aE1 : Edge from TopoDS; - aF1 : Face from TopoDS; - aST1:out State from TopAbs; - aContext: Context from IntTools); - ---Purpose: - --- Internal usage - --- - Orientation (myclass; - aE : Edge from TopoDS; - aF : Face from TopoDS) - returns Orientation from TopAbs; - ---Purpose: - --- Get the orientation for the edge on the face - --- Returns TopAbs_INTERNAL if the edge is not found - --- on the face - --- - SignDistance (myclass; - aP : Pnt from gp; - aPL: Pln from gp) - returns Real from Standard; - ---Purpose: - --- Computes signed distance between the 3D-point - --- and the plane . - --- - -- Warning: - --- The distance is not divided by sqrt(A*A+B*B+C*C) - --- - GetApproxNormalToFaceOnEdge (myclass; - aE: Edge from TopoDS; - aF: Face from TopoDS; - aT: Real from Standard; - aPx:out Pnt from gp; - aD:out Dir from gp); - ---Purpose: - --- Computes normal to the face for the 3D-point that - --- belonds to the edge at parameter . - -- Output: - --- aPx - the 3D-point where the normal computed - --- aD - the normal; - --- - -- Warning: - --- The normal is computed not exactly in the point on the - --- edge, but in point that is near to the edge towards to - --- the face material (so, we'll have approx. normal) - --- - PointNearEdge (myclass; - aE : Edge from TopoDS; - aF : Face from TopoDS; - aT : Real from Standard; - aDt2D: Real from Standard; - aP2D :out Pnt2d from gp; - aPx :out Pnt from gp); - ---Purpose: - --- Compute the point , () that is near to - --- the edge at parameter towards to the - --- material of the face . The value of shifting in - --- 2D is - --- - PointNearEdge (myclass; - aE: Edge from TopoDS; - aF: Face from TopoDS; - aT: Real from Standard; - aP2D:out Pnt2d from gp; - aPx:out Pnt from gp); - ---Purpose: - --- Computes the point , () that is near to - --- the edge at parameter towards to the - --- material of the face . The value of shifting in - -- 2D is dt2D=BOPTools_Tools3D::MinStepIn2d() - --- - PointNearEdge (myclass; - aE: Edge from TopoDS; - aF: Face from TopoDS; - aP2D:out Pnt2d from gp; - aPx:out Pnt from gp); - ---Purpose: - --- Compute the point , () that is near to - --- the edge at arbitrary parameter towards to the - --- material of the face . The value of shifting in - -- 2D is dt2D=BOPTools_Tools3D::MinStepIn2d() - --- - PointToCompare (myclass; - aP1: Pnt from gp; - aP2: Pnt from gp; - aF: Face from TopoDS; - aPx:out Pnt from gp; - aContext: Context from IntTools); - ---Purpose: - --- For 3D-point find projection point on the face . - --- If the distance (, ) > TolF => - --- For 3D-point find projection point on the face . - --- If the distance (, ) > TolF => returns - --- - GetPlane (myclass; - aSp : Edge from TopoDS; - aE1 : Edge from TopoDS; - aF1 : Face from TopoDS; - aF2 : Face from TopoDS; - aST:out State from TopAbs; - aContext: Context from IntTools); - ---Purpose: - --- Compute 3D-state for the point on the split edge - --- (with base edge and the face ) comparing with - --- the face - --- - GetPointState (myclass; - aSp : Edge from TopoDS; - aEF2 : Edge from TopoDS; - aF2Adj : Face from TopoDS; - aF1 : Face from TopoDS; - aST:out State from TopAbs); - ---Purpose: - --- Compute 3D-state for the point on the split edge - --- (with base edge and the adjacent face ) comparing with - --- the face - --- - - OrientEdgeOnFace (myclass; - aE : Edge from TopoDS; - aF : Face from TopoDS; - aER : out Edge from TopoDS); - ---Purpose: - --- Get the edge from the face that is the same as - --- the edge - --- - - OrientTouchEdgeOnF1 (myclass; - aSp: Edge from TopoDS; - aEx: Edge from TopoDS; - aF1: Face from TopoDS; - aF2: Face from TopoDS) - returns Orientation from TopAbs; - ---Purpose: - --- Computes orientation for the split edge - --- [with base edge and face ] on the - --- face - --- - GetSeams (myclass; - aF : Face from TopoDS; - aSimm1 : out Edge from TopoDS; - aSimm2 : out Edge from TopoDS); - ---Purpose: - --- Get seam edges , for the face - --- - GetSeam (myclass; - aF : Face from TopoDS; - aS1: Edge from TopoDS; - aS2: out Edge from TopoDS); - ---Purpose: - --- Get opposite seam edge for the face with - --- known seam edge - --- - IsValidArea (myclass; - aF : Face from TopoDS; - aNegativeFlag : out Boolean from Standard) - returns Boolean from Standard; - ---Purpose: - --- Check validity of the area of face . - --- Returns TRUE if the Abs. value of the area - --- is greater than 1.e-16 - --- - MinStepIn2d(myclass) - returns Real from Standard; - ---Purpose: - --- Returns simple step value that is used in 2D-computations - --- = 1.e-5 - --- - IsEmptyShape(myclass; - aS: Shape from TopoDS) - returns Boolean from Standard; - ---Purpose: - --- Returns TRUE if the shape does not contain - --- geometry information (e.g. empty compound) - --- - InvertShape(myclass; - aS : Shape from TopoDS; - aSInv:out Shape from TopoDS); - ---Purpose: - --- Change orientations to opposite for the shape - --- and all its sub-shapes. Returns - --- - GetStatePartIN2D(myclass; - aSp :Edge from TopoDS; - aEF1 :Edge from TopoDS; - aF1 :Face from TopoDS; - aF2 :Face from TopoDS; - aContext: Context from IntTools) - returns State from TopAbs; - ---Purpose: - --- Used in touch case - --- Compute the 3D-state for the point on the split - --- edge (with base edge on face ) - --- comparing with . - --- Used in touch case / - --- - CheckSameDomainFaceInside(myclass; theFace1: Face from TopoDS; - theFace2: Face from TopoDS; - theContext: Context from IntTools) - returns Boolean from Standard; - - ComputeFaceState(myclass; theFace: Face from TopoDS; - theRef : Solid from TopoDS; - theContext: Context from IntTools; - theState: out State from TopAbs) - returns Boolean from Standard; - - TreatedAsAnalytic(myclass; aTx :Real from Standard; - aPx :Pnt from gp; - aEx :Edge from TopoDS; - aFx :Face from TopoDS; - aE1 :Edge from TopoDS; - aF1 :Face from TopoDS; - aTolTangent:Real from Standard; - aTolRadius :Real from Standard; - aState :out State from TopAbs; - aContext: Context from IntTools) - returns Boolean from Standard; - - TreatedAsAnalytic (myclass; aFx :Face from TopoDS; - aSpE1 :Edge from TopoDS; - aF1 :Face from TopoDS; - aTolTangent:Real from Standard; - aTolRadius :Real from Standard; - aState :out State from TopAbs; - aContext: Context from IntTools) - returns Boolean from Standard; - - HasAnalyticSurfaceType (myclass; aF: Face from TopoDS) - returns Boolean from Standard; - -end Tools3D; - - - diff --git a/src/BOPTools/BOPTools_Tools3D.cxx b/src/BOPTools/BOPTools_Tools3D.cxx deleted file mode 100755 index c207dd818c..0000000000 --- a/src/BOPTools/BOPTools_Tools3D.cxx +++ /dev/null @@ -1,1425 +0,0 @@ -// Created on: 2001-04-05 -// Created by: Peter KURNEV -// Copyright (c) 2001-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include - -#include - -#include -#include -#include -#include - - - -static - void PointNearE (const TopoDS_Edge& aE, - const TopoDS_Face& aF, - const Standard_Real aT, - gp_Pnt& aPInFace, - const Standard_Boolean aSt); - -static Standard_Boolean CheckKeepArguments(const TopoDS_Face& F1, - const TopoDS_Face& F2, - const TopoDS_Face& F3); - -//======================================================================= -//function : RemoveSims -//purpose : -//======================================================================= - void BOPTools_Tools3D::RemoveSims (const TopoDS_Shape& aS, - const Handle(IntTools_Context)& aContext) -{ - TopExp_Explorer anExp(aS, TopAbs_FACE); - for (; anExp.More(); anExp.Next()) { - const TopoDS_Face& aF=TopoDS::Face(anExp.Current()); - // - BOPTools_Tools3D::RemoveSims (aF, aContext); - } -} - -//======================================================================= -//function : RemoveSims -//purpose : -//======================================================================= - void BOPTools_Tools3D::RemoveSims (const TopoDS_Face& aFF, - const Handle(IntTools_Context)& aContext) -{ - Standard_Boolean anIsClosed, anIsPointInFace1, anIsPointInFace2; - Standard_Real aT1, aT2, aT, aX, aY, dt=1.e-7, aTol; - BRep_Builder BB; - gp_Vec2d aV2D, aV2Dx; - gp_Pnt2d aP2D, aP2Dx; - TopAbs_Orientation anOri; - Handle(Geom2d_Curve) aC2Dx; - // - TopoDS_Face aF=aFF; - aF.Orientation(TopAbs_FORWARD); - // - TopExp_Explorer anExpW (aF, TopAbs_WIRE); - for (; anExpW.More(); anExpW.Next()) { - - TopTools_MapOfShape aMap, aMapToAdd, aMapToRemove; - const TopoDS_Shape& aW=anExpW.Current(); - - TopExp_Explorer anExp(aW, TopAbs_EDGE); - for (; anExp.More(); anExp.Next()) { - const TopoDS_Edge& aE=TopoDS::Edge(anExp.Current()); - // - if (BRep_Tool::Degenerated(aE)){ - continue; - } - // - anIsClosed=BRep_Tool::IsClosed(aE, aF); - if (anIsClosed) { - if (aMap.Contains(aE)) { - continue; - } - aMap.Add(aE); - aTol=BRep_Tool::Tolerance(aE); - - Handle(Geom2d_Curve) aC2D=BRep_Tool::CurveOnSurface(aE, aF, aT1, aT2); - aT=BOPTools_Tools2D::IntermediatePoint(aT1, aT2); - aC2D-> D1(aT, aP2D, aV2D); - - anOri=aE.Orientation(); - if (anOri==TopAbs_REVERSED) { - aV2D.Reverse(); - } - - aV2D.Normalize(); - aX=aV2D.X(); - aY=aV2D.Y(); - aV2Dx.SetCoord(-aY, aX); - - aP2Dx.SetX(aP2D.X()+dt*aV2Dx.X()); - aP2Dx.SetY(aP2D.Y()+dt*aV2Dx.Y()); - // - anIsPointInFace1=aContext->IsPointInFace(aF, aP2Dx); - // - aP2Dx.SetX(aP2D.X()-dt*aV2Dx.X()); - aP2Dx.SetY(aP2D.Y()-dt*aV2Dx.Y()); - // - anIsPointInFace2=aContext->IsPointInFace(aF, aP2Dx); - // - - if (anIsPointInFace1 && anIsPointInFace2) { - continue; - } - // - TopoDS_Edge aEx=aE; - - aEx.EmptyCopy(); - TopExp_Explorer anExpV(aE, TopAbs_VERTEX); - for (; anExpV.More(); anExpV.Next()) { - const TopoDS_Shape& aVx=anExpV.Current(); - BB.Add (aEx, aVx); - } - - BB.UpdateEdge(aEx, aTol); - // - if (anIsPointInFace1) { - if (anOri==TopAbs_REVERSED) { - // Remove Forward - BB.UpdateEdge(aEx, aC2Dx, aF, aTol); - BB.UpdateEdge(aEx, aC2D , aF, aTol); - aEx.Orientation(TopAbs_REVERSED); - } - else { - // Remove Reversed - BB.UpdateEdge(aEx, aC2Dx, aF, aTol); - BB.UpdateEdge(aEx, aC2D , aF, aTol); - aEx.Orientation(TopAbs_FORWARD); - } - aMapToAdd.Add(aEx); - aMapToRemove.Add(aE); - } - } - }// next Edge - // - TopoDS_Shape* pW= (TopoDS_Shape*)&aW; - pW->Free(Standard_True); - - TopTools_MapIteratorOfMapOfShape anIt(aMapToRemove); - for (; anIt.More(); anIt.Next()) { - const TopoDS_Shape& aSR=anIt.Key(); - BB.Remove(*pW, aSR); - } - anIt.Initialize(aMapToAdd); - for (; anIt.More(); anIt.Next()) { - const TopoDS_Shape& aSA=anIt.Key(); - BB.Add(*pW, aSA); - } - - }// next Wire -} - -//======================================================================= -//function : SubShapesAmount -//purpose : -//======================================================================= - Standard_Integer BOPTools_Tools3D::SubShapesAmount (const TopoDS_Shape& aS, - const TopAbs_ShapeEnum aType) -{ - Standard_Integer aNb; - TopTools_IndexedMapOfShape aM; - TopExp::MapShapes(aS, aType, aM); - aNb=aM.Extent(); - return aNb; -} - -//======================================================================= -//function : IsConvexWire -//purpose : -//======================================================================= - Standard_Boolean BOPTools_Tools3D::IsConvexWire (const TopoDS_Wire& aW) -{ - Standard_Boolean aFlag; - Standard_Integer aNbV, aNbE; - - aNbV=BOPTools_Tools3D::SubShapesAmount(aW, TopAbs_VERTEX); - aNbE=BOPTools_Tools3D::SubShapesAmount(aW, TopAbs_EDGE); - aFlag=aNbV <= aNbE; - return aFlag; -} - -//======================================================================= -//function : DoSplitSEAMOnFace -//purpose : -//======================================================================= - void BOPTools_Tools3D::DoSplitSEAMOnFace (const TopoDS_Edge& aSplit, - const TopoDS_Face& aF) -{ - Standard_Boolean bIsUPeriodic, bIsLeft; - Standard_Real aTol, a, b, anUPeriod, aT, anU, dU=1.e-7, anU1; - Standard_Real aScPr; - gp_Pnt2d aP2D; - gp_Vec2d aVec2D; - Handle(Geom2d_Curve) aTmpC1, aTmpC2; - Handle(Geom2d_Curve) C2D1; - Handle(Geom2d_Line) aLD1; - Handle(Geom_Surface) aS; - BRep_Builder BB; - TopoDS_Edge aSp; - // - aSp=aSplit; - aSp.Orientation(TopAbs_FORWARD); - - aTol=BRep_Tool::Tolerance(aSp); - - aS=BRep_Tool::Surface(aF); - bIsUPeriodic=aS->IsUPeriodic(); - - anUPeriod=0.; - if (bIsUPeriodic) { - anUPeriod=aS->UPeriod(); - } - else { - //modified by NIZNHY-PKV Fri Jul 11 09:54:43 2008f - Standard_Boolean bIsUClosed; - Standard_Real aUmin, aUmax, aVmin, aVmax; - Handle(Geom_BSplineSurface) aBS; - Handle(Geom_BezierSurface) aBZ; - // - bIsUClosed=Standard_False; - aBS=Handle(Geom_BSplineSurface)::DownCast(aS); - aBZ=Handle(Geom_BezierSurface) ::DownCast(aS); - // - if (!aBS.IsNull()) { - bIsUClosed=aBS->IsUClosed(); - aBS->Bounds(aUmin, aUmax, aVmin, aVmax); - } - else if (!aBZ.IsNull()) { - bIsUClosed=aBZ->IsUClosed(); - aBZ->Bounds(aUmin, aUmax, aVmin, aVmax); - } - if (!bIsUClosed) { - return; - } - // - anUPeriod=aUmax-aUmin; - //modified by NIZNHY-PKV Fri Jul 11 09:54:49 2008t - } - // - C2D1=BRep_Tool::CurveOnSurface(aSp, aF, a, b); - //modified by NIZNHY-PKV Fri Jul 11 09:55:10 2008f - /* - aLD1=Handle(Geom2d_Line)::DownCast(C2D1); - if (aLD1.IsNull()) { - return; - } - */ - //modified by NIZNHY-PKV Fri Jul 11 09:55:14 2008t - // - aT=BOPTools_Tools2D::IntermediatePoint(a, b); - C2D1->D1(aT, aP2D, aVec2D); - gp_Dir2d aDir2D1(aVec2D); - - // - gp_Dir2d aDOY(0.,1.); - aScPr=aDir2D1*aDOY; - // - // - anU=aP2D.X(); - if (fabs (anU) < dU) { - bIsLeft=Standard_True; - anU1=anU+anUPeriod; - } - else if (fabs (anU-anUPeriod) < dU) { - bIsLeft=Standard_False; - anU1=anU-anUPeriod; - } - else { - return; - } - // - - - aTmpC1=Handle(Geom2d_Curve)::DownCast(C2D1->Copy()); - Handle(Geom2d_TrimmedCurve) aC1 = new Geom2d_TrimmedCurve(aTmpC1, a, b); - - aTmpC2=Handle(Geom2d_Curve)::DownCast(C2D1->Copy()); - Handle(Geom2d_TrimmedCurve) aC2 = new Geom2d_TrimmedCurve(aTmpC2, a, b); - gp_Vec2d aTrV(anU1-anU, 0.); - aC2->Translate(aTrV); - // - if (!bIsLeft) { - if (aScPr<0.) { - BB.UpdateEdge(aSp, aC2, aC1, aF, aTol); - } - else { - BB.UpdateEdge(aSp, aC1, aC2, aF, aTol); - } - } - else { - if (aScPr<0.) { - BB.UpdateEdge(aSp, aC1, aC2, aF, aTol); - } - else { - BB.UpdateEdge(aSp, aC2, aC1, aF, aTol); - } - } - // -} -//======================================================================= -//function : DoSplitSEAMOnFace -//purpose : -//======================================================================= -Standard_Boolean BOPTools_Tools3D::DoSplitSEAMOnFace(const TopoDS_Edge& theSplit, - const TopoDS_Edge& theSeam, - const TopoDS_Face& theFace, - Standard_Boolean& IsReversed) -{ - Standard_Real aTol, f, l, a, b, aPeriod, aT, aParTolerance = 1.e-07; - Standard_Boolean bIsUPeriodic = Standard_False; - Standard_Boolean bIsVPeriodic = Standard_False; - BRep_Builder BB; - gp_Pnt2d aP2D; - gp_Vec2d aVec2D; - - - TopoDS_Edge aSp = theSplit; - aSp.Orientation(TopAbs_FORWARD); - TopoDS_Edge aSeamF = theSeam; - aSeamF.Orientation(TopAbs_FORWARD); - TopoDS_Edge aSeamR = theSeam; - aSeamR.Orientation(TopAbs_REVERSED); - - aTol=BRep_Tool::Tolerance(aSp); - - Handle(Geom2d_Curve) C2D1 = BRep_Tool::CurveOnSurface(aSp, theFace, f, l); - Handle(Geom2d_Curve) C2D2 = BRep_Tool::CurveOnSurface(aSeamF, theFace, a, b); - Handle(Geom2d_Curve) C2D3 = BRep_Tool::CurveOnSurface(aSeamR, theFace, a, b); - // - Handle(Geom2d_TrimmedCurve) atr = Handle(Geom2d_TrimmedCurve)::DownCast(C2D1); - Handle(Geom2d_Line) aLD1; - - if(!atr.IsNull()) { - aLD1 = Handle(Geom2d_Line)::DownCast(atr->BasisCurve()); - } - else { - aLD1 = Handle(Geom2d_Line)::DownCast(C2D1); - } - - if (aLD1.IsNull()) { - return Standard_False; - } - aT = BOPTools_Tools2D::IntermediatePoint(f, l); - C2D1->D1(aT, aP2D, aVec2D); - gp_Dir2d aDir2D(aVec2D); - - gp_Vec2d aVec2D1, aVec2D2; - gp_Pnt2d aP2D1, aP2D2; - C2D2->D1(((a+b) * 0.5), aP2D1, aVec2D1); - C2D3->D1(((a+b) * 0.5), aP2D2, aVec2D2); - - Handle(Geom_Surface) aS=BRep_Tool::Surface(theFace); - bIsUPeriodic = aS->IsUPeriodic(); - bIsVPeriodic = aS->IsVPeriodic(); - - for(Standard_Integer i = 0; i < 2; i++) { - Standard_Boolean bIsPeriodic = (i == 0) ? bIsUPeriodic : bIsVPeriodic; - - if(!bIsPeriodic) - continue; - - aPeriod = (i == 0) ? aS->UPeriod() : aS->VPeriod(); - - Standard_Real aParameter = (i == 0) ? aP2D.X() : aP2D.Y(); - Standard_Real aParameter1 = (i == 0) ? aP2D1.X() : aP2D1.Y(); - Standard_Real aParameter2 = (i == 0) ? aP2D2.X() : aP2D2.Y(); - - Standard_Boolean bIsLower = Standard_False, found = Standard_False; - Standard_Boolean bIsFirst = Standard_False; - Standard_Real aScPr = 0.; - - if (fabs (aParameter - aParameter1) < aParTolerance) { - bIsLower = (aParameter < aParameter2); - bIsFirst = Standard_True; - aScPr = aDir2D * aVec2D1; - } - else if (fabs (aParameter - aParameter2) < aParTolerance) { - bIsLower = (aParameter < aParameter1); - bIsFirst = Standard_False; - aScPr = aDir2D * aVec2D2; - } - found = (fabs(aScPr) > aParTolerance); - - if(found) { - Handle(Geom2d_Curve) aTmpC1, aTmpC2; - - aTmpC1 = Handle(Geom2d_Curve)::DownCast(C2D1->Copy()); - Handle(Geom2d_TrimmedCurve) aC1 = new Geom2d_TrimmedCurve(aTmpC1, f, l); - - aTmpC2 = Handle(Geom2d_Curve)::DownCast(C2D1->Copy()); - Handle(Geom2d_TrimmedCurve) aC2 = new Geom2d_TrimmedCurve(aTmpC2, f, l); - gp_Vec2d aTrV; - - if(i == 0) { - if(bIsLower) - aTrV.SetX(aPeriod); - else - aTrV.SetX(-aPeriod); - aTrV.SetY(0.); - } - else { - if(bIsLower) - aTrV.SetY(aPeriod); - else - aTrV.SetY(-aPeriod); - aTrV.SetX(0.); - } - aC2->Translate(aTrV); - // - IsReversed = (aScPr < 0.); - Standard_Boolean bIsReverseOrder = (!IsReversed) ? !bIsFirst : bIsFirst; - - if(bIsReverseOrder) { - BB.UpdateEdge(aSp, aC2, aC1, theFace, aTol); - } - else { - BB.UpdateEdge(aSp, aC1, aC2, theFace, aTol); - } - return Standard_True; - } - } - return Standard_False; -} -//======================================================================= -//function :IsSplitToReverse1 -//purpose : -//======================================================================= - Standard_Boolean BOPTools_Tools3D::IsSplitToReverse1 (const TopoDS_Edge& aEF1, - const TopoDS_Edge& aEF2, - const Handle(IntTools_Context)& aContext) -{ - Standard_Boolean aFlag; - Standard_Real aT1, aT2, aScPr, a, b; - gp_Vec aV1, aV2; - gp_Pnt aP; - - - Handle(Geom_Curve)aC1=BRep_Tool::Curve(aEF1, a, b); - aT1=BOPTools_Tools2D::IntermediatePoint(a, b); - aC1->D0(aT1, aP); - aFlag=BOPTools_Tools2D::EdgeTangent(aEF1, aT1, aV1); - - if(!aFlag) { - return Standard_False; - } - - gp_Dir aDT1(aV1); - // - aFlag=aContext->ProjectPointOnEdge(aP, aEF2, aT2); - if(!aFlag) { - return Standard_False; - } - // - aFlag=BOPTools_Tools2D::EdgeTangent(aEF2, aT2, aV2); - if(!aFlag) { - return Standard_False; - } - - gp_Dir aDT2(aV2); - - aScPr=aDT1*aDT2; - - return (aScPr<0.); -} - -//======================================================================= -//function : EdgeOrientation -//purpose : -//======================================================================= - TopAbs_Orientation BOPTools_Tools3D::EdgeOrientation (const TopoDS_Edge& aE, - const TopoDS_Face& aF1, - const TopoDS_Face& aF2) -{ - Standard_Real aScPr; - gp_Dir aDTE, aDNF1, aDNF2, aDTN; - - BOPTools_Tools3D::GetNormalToFaceOnEdge(aE, aF1, aDNF1); - BOPTools_Tools3D::GetNormalToFaceOnEdge(aE, aF2, aDNF2); - - aDTN=aDNF1^aDNF2; - - BOPTools_Tools2D::TangentOnEdge(aE, aDTE); - - aScPr=aDTN*aDTE; - - TopAbs_Orientation anOr; - - anOr=TopAbs_FORWARD; - if (aScPr<0.) { - anOr=TopAbs_REVERSED; - } - return anOr; -} -//======================================================================= -//function : IsTouchCase -//purpose : -//======================================================================= - Standard_Boolean BOPTools_Tools3D::IsTouchCase(const TopoDS_Edge& aE, - const TopoDS_Face& aF1, - const TopoDS_Face& aF2) -{ - gp_Dir aDNF1, aDNF2; - - - BOPTools_Tools3D::GetNormalToFaceOnEdge(aE, aF1, aDNF1); - BOPTools_Tools3D::GetNormalToFaceOnEdge(aE, aF2, aDNF2); - - Standard_Boolean bIsDirsCoinside; - bIsDirsCoinside=IntTools_Tools::IsDirsCoinside(aDNF1, aDNF2); - return bIsDirsCoinside; -} -//======================================================================= -//function : GetNormalToFaceOnEdge -//purpose : -//======================================================================= - void BOPTools_Tools3D::GetNormalToFaceOnEdge (const TopoDS_Edge& aE, - const TopoDS_Face& aF, - gp_Dir& aDNF) -{ - Standard_Real aT, aT1, aT2; - - BRep_Tool::CurveOnSurface(aE, aF, aT1, aT2); - aT=BOPTools_Tools2D::IntermediatePoint(aT1, aT2); - - BOPTools_Tools3D::GetNormalToFaceOnEdge (aE, aF, aT, aDNF); - - if (aF.Orientation()==TopAbs_REVERSED){ - aDNF.Reverse(); - } -} - -//======================================================================= -//function : GetNormalToFaceOnEdge -//purpose : -//======================================================================= - void BOPTools_Tools3D::GetNormalToFaceOnEdge (const TopoDS_Edge& aE, - const TopoDS_Face& aF1, - const Standard_Real aT, - gp_Dir& aDNF1) -{ - Standard_Real U, V, aTolPC; - gp_Pnt2d aP2D; - gp_Pnt aP; - gp_Vec aD1U, aD1V; - - Handle(Geom_Surface) aS1=BRep_Tool::Surface(aF1); - - Handle(Geom2d_Curve)aC2D1; - BOPTools_Tools2D::CurveOnSurface(aE, aF1, aC2D1, aTolPC, Standard_True); - - aC2D1->D0(aT, aP2D); - U=aP2D.X(); - V=aP2D.Y(); - - aS1->D1(U, V, aP, aD1U, aD1V); - gp_Dir aDD1U(aD1U); - gp_Dir aDD1V(aD1V); - - aDNF1=aDD1U^aDD1V; -} - -//======================================================================= -//function : GetBiNormal -//purpose : -//======================================================================= - void BOPTools_Tools3D::GetBiNormal(const TopoDS_Edge& aE, - const TopoDS_Face& aF, - const Standard_Real aT, - gp_Dir& aDB) -{ - gp_Dir aDNF, aDT; - // - // Normal to the face aF at parameter aT - BOPTools_Tools3D::GetNormalToFaceOnEdge (aE, aF, aT, aDNF); - if (aF.Orientation()==TopAbs_REVERSED){ - aDNF.Reverse(); - } - // - // Split tangent on aF at parameter aT - BOPTools_Tools3D::GetTangentToEdge(aE, aT, aDT); - - if (aF.Orientation()==TopAbs_REVERSED){ - aDT.Reverse(); - } - // Binormal - aDB=aDNF^aDT; -} - -//======================================================================= -//function : :GetBiNormal -//purpose : -//======================================================================= - void BOPTools_Tools3D::GetBiNormal(const TopoDS_Edge& aSp, - const TopoDS_Face& aF, - gp_Dir& aDB) -{ - gp_Dir aDNF, aDD1Sp; - // - // Normal to the face aF at parameter aT - BOPTools_Tools3D::GetNormalToFaceOnEdge (aSp, aF, aDNF); - // - // Split tangent on aF at parameter aT - BOPTools_Tools3D::GetTangentToEdge(aSp, aDD1Sp); - - if (aF.Orientation()==TopAbs_REVERSED){ - aDD1Sp.Reverse(); - } - // Binormal - aDB=aDNF^aDD1Sp; -} -//======================================================================= -//function : GetTangentToEdge -//purpose : -//======================================================================= - Standard_Boolean BOPTools_Tools3D::GetTangentToEdge(const TopoDS_Edge& anEdge, - gp_Dir& aDT) -{ - Standard_Boolean isdgE; - - Standard_Real aT1, aT2, aT; - - isdgE = BRep_Tool::Degenerated(anEdge); - if (isdgE) { - return Standard_False; - } - - Handle(Geom_Curve) aC=BRep_Tool::Curve(anEdge, aT1, aT2); - aT=BOPTools_Tools2D::IntermediatePoint(aT1, aT2); - - BOPTools_Tools3D::GetTangentToEdge(anEdge, aT, aDT); - - return Standard_True; -} -//======================================================================= -//function : GetTangentToEdge -//purpose : -//======================================================================= - Standard_Boolean BOPTools_Tools3D::GetTangentToEdge(const TopoDS_Edge& anEdge, - const Standard_Real aT, - gp_Dir& aDT) -{ - Standard_Boolean isdgE; - Standard_Real first, last; - - isdgE = BRep_Tool::Degenerated(anEdge); - if (isdgE) { - return Standard_False; - } - - Handle(Geom_Curve) aC=BRep_Tool::Curve(anEdge, first, last); - gp_Pnt aP; - gp_Vec aTau; - aC->D1(aT, aP, aTau); - gp_Dir aD(aTau); - if (anEdge.Orientation() == TopAbs_REVERSED){ - aD.Reverse(); - } - aDT=aD; - - return Standard_True; -} -//======================================================================= -//function : :IsSplitToReverse -//purpose : -//======================================================================= - Standard_Boolean BOPTools_Tools3D:: IsSplitToReverse(const TopoDS_Edge& aE, - const TopoDS_Edge& aSp) -{ - Standard_Real t1, t2, aT; - - Handle(Geom_Curve)aCE=BRep_Tool::Curve(aE, t1, t2); - Handle(Geom_Curve)aCSp=BRep_Tool::Curve(aSp,t1, t2); - - aT=BOPTools_Tools2D::IntermediatePoint(t1, t2); - - gp_Vec aD1E, aD1Sp; - gp_Pnt aP; - - aCE->D1 (aT, aP, aD1E); - aCSp->D1(aT, aP, aD1Sp); - - gp_Dir aDD1E (aD1E); - gp_Dir aDD1Sp(aD1Sp); - - if (aE.Orientation()==TopAbs_REVERSED) { - aDD1E.Reverse(); - } - if (aSp.Orientation()==TopAbs_REVERSED) { - aDD1Sp.Reverse(); - } - - aT=aDD1E*aDD1Sp; - - return (aT<0.); -} - -//======================================================================= -//function : GetAdjacentFace -//purpose : -//======================================================================= - Standard_Boolean BOPTools_Tools3D::GetAdjacentFace(const TopoDS_Face& aFaceObj, - const TopoDS_Edge& anEObj, - const TopTools_IndexedDataMapOfShapeListOfShape& anEdgeFaceMap, - TopoDS_Face& anAdjF) -{ - const TopTools_ListOfShape& aListOfAdjFaces=anEdgeFaceMap.FindFromKey(anEObj); - TopTools_ListIteratorOfListOfShape anIt(aListOfAdjFaces); - TopoDS_Shape anAdjShape; - for (; anIt.More(); anIt.Next()) { - if (anIt.Value()!=aFaceObj) { - anAdjShape=anIt.Value(); - break; - } - } - - if (!anAdjShape.IsNull()) { - anAdjF=TopoDS::Face(anAdjShape); - return Standard_True; - } - else { - return Standard_False; - } -} -//======================================================================= -//function : IsKeepTwice -//purpose : -//======================================================================= - Standard_Boolean BOPTools_Tools3D::IsKeepTwice(const TopoDS_Face& aF1, - const TopoDS_Face& aF2, - const TopoDS_Face& aF2Adj, - const TopoDS_Edge& aSpEF2) -{ - if( !CheckKeepArguments(aF1, aF2, aF2Adj) ) { - return Standard_False; - } - - Standard_Real aT1, aT2, aT, dt=1.e-7, A, B, C, D, d2, d2Adj; - gp_Dir aDNF1, aDNF2, DBF2, aDNF2Adj, DBF2Adj; - gp_Vec aD1Sp; - gp_Pnt aP, aPF2, aPF2Adj; - - Handle(Geom_Curve) aC3D=BRep_Tool::Curve(aSpEF2, aT1, aT2); - aT=BOPTools_Tools2D::IntermediatePoint(aT1, aT2); - BOPTools_Tools3D::GetNormalToFaceOnEdge (aSpEF2, aF1, aT, aDNF1); - - // - // Split tangent on F2 - aC3D->D1(aT, aP, aD1Sp); - gp_Dir aDD1Sp(aD1Sp); - - if (aSpEF2.Orientation()==TopAbs_REVERSED) { - aDD1Sp.Reverse(); - } - // Split Normal on F2 - BOPTools_Tools3D::GetNormalToFaceOnEdge (aSpEF2, aF2, aT, aDNF2); - if (aF2.Orientation()==TopAbs_REVERSED) { - aDNF2.Reverse(); - } - // Binormal on F2 - DBF2=aDNF2^aDD1Sp; - - // Point near aP - aPF2.SetCoord(aP.X()+dt*DBF2.X(), - aP.Y()+dt*DBF2.Y(), - aP.Z()+dt*DBF2.Z()); - - - // - // Split tangent on F2Adj - aDD1Sp.Reverse(); - // Split Normal on F2Adj - BOPTools_Tools3D::GetNormalToFaceOnEdge (aSpEF2, aF2Adj, aT, aDNF2Adj); - if (aF2Adj.Orientation()==TopAbs_REVERSED) { - aDNF2Adj.Reverse(); - } - // Binormal on F2Adj - DBF2Adj=aDNF2Adj^aDD1Sp; - - // Point near aP - aPF2Adj.SetCoord(aP.X()+dt*DBF2Adj.X(), - aP.Y()+dt*DBF2Adj.Y(), - aP.Z()+dt*DBF2Adj.Z()); - // - // Tangent Plane on F1 - gp_Pln aPlnN1(aP, aDNF1); - aPlnN1.Coefficients(A, B, C, D); - // - d2 = A*aPF2.X() + B*aPF2.Y() + C*aPF2.Z() + D; - d2Adj= A*aPF2Adj.X() + B*aPF2Adj.Y()+ C*aPF2Adj.Z() + D; - // - if (fabs(d2)<1.e-10) { - d2=0.; - } - if (fabs(d2Adj)<1.e-10) { - d2Adj=0.; - } - // - aT=d2*d2Adj; - // - return (aT >= 0.); -} - -//======================================================================= -//function : SenseFlag -//purpose : -//======================================================================= - Standard_Integer BOPTools_Tools3D::SenseFlag (const gp_Dir& aDNF1, - const gp_Dir& aDNF2) -{ - Standard_Boolean bIsDirsCoinside; - bIsDirsCoinside=IntTools_Tools::IsDirsCoinside(aDNF1, aDNF2); - if (!bIsDirsCoinside) { - return 0; - } - - Standard_Real aScPr; - - aScPr=aDNF1*aDNF2; - if (aScPr<0.) { - return -1; - } - else if (aScPr>0.) { - return 1; - } - return -1; -} - -//======================================================================= -//function : GetNormalToSurface -//purpose : -//======================================================================= - Standard_Boolean BOPTools_Tools3D::GetNormalToSurface (const Handle(Geom_Surface)& aS, - const Standard_Real U, - const Standard_Real V, - gp_Dir& aDNS) -{ - Standard_Boolean bFlag; - - gp_Pnt aP; - gp_Vec aD1U, aD1V; - - aS->D1(U, V, aP, aD1U, aD1V); - - gp_Dir aDD1U(aD1U); - gp_Dir aDD1V(aD1V); - - bFlag=IntTools_Tools::IsDirsCoinside(aDD1U, aDD1U); - if (!bFlag) { - return bFlag; - } - - aDNS=aDD1U^aDD1V; - return bFlag; -} - -//======================================================================= -//function : GetNormalToSurface -//purpose : local modification -//======================================================================= - -static void GetApproxNormalToFaceOnEdgeEx(const TopoDS_Edge& aE, - const TopoDS_Face& aF, - const Standard_Real aT, - const Standard_Real aDT, - gp_Pnt& aPNear, - gp_Dir& aDNF) -{ - Standard_Real aFirst, aLast; - Handle(Geom2d_Curve) aC2D= BRep_Tool::CurveOnSurface (aE, aF, aFirst, aLast); - - if (aC2D.IsNull()) { - return; - } - - //gp_Pnt aPNear; - gp_Pnt2d aPx2DNear; - BOPTools_Tools3D::PointNearEdge (aE, aF, aT, aDT, aPx2DNear, aPNear); - - Handle(Geom_Surface) aS=BRep_Tool::Surface(aF); - - BOPTools_Tools3D::GetNormalToSurface (aS, aPx2DNear.X(), aPx2DNear.Y(), aDNF); - - if (aF.Orientation()==TopAbs_REVERSED){ - aDNF.Reverse(); - } -} - -//======================================================================= -//function : GetPlanes -//purpose : -//======================================================================= - void BOPTools_Tools3D::GetPlanes (const TopoDS_Edge& aSpx, - const TopoDS_Edge& anEx, - const TopTools_IndexedDataMapOfShapeListOfShape& anEFMapx, - const TopoDS_Edge& anE1, - const TopoDS_Face& aF1, - TopAbs_State& aStPF1, - const Handle(IntTools_Context)& aContext) -{ - Standard_Boolean bIsAdjExists; - - Standard_Real aT, aT1, aT2; - gp_Dir aDNFx1, aDNFx2; - gp_Pnt aPx, aPx1, aPx2, aPF1; - TopoDS_Face aFx1, aFx2; - // - // Point - Handle(Geom_Curve)aC3D =BRep_Tool::Curve(aSpx, aT1, aT2); - aT=BOPTools_Tools2D::IntermediatePoint(aT1, aT2); - - aC3D->D0(aT, aPx); - // - // 1.1. Fx1, Fx2 and theirs normals - TopAbs_Orientation anOrEx, anOr; - anOrEx=anEx.Orientation(); - - TopoDS_Edge aSpxSimm=anEx; - if (anOrEx==TopAbs_FORWARD) { - aSpxSimm.Orientation(TopAbs_REVERSED); - } - else if (anOrEx==TopAbs_REVERSED){ - aSpxSimm.Orientation(TopAbs_FORWARD); - } - // - - const TopTools_ListOfShape& aLF=anEFMapx.FindFromKey(anEx); - TopTools_ListIteratorOfListOfShape anIt(aLF); - - for (; anIt.More(); anIt.Next()) { - const TopoDS_Shape& aFE=anIt.Value(); - aFx1=TopoDS::Face(aFE); - anOr=BOPTools_Tools3D::Orientation(anEx, aFx1); - if (anOr==anOrEx){ - break; - } - } - - //-- EJG - Standard_Boolean aMoreShift = Standard_False; - Standard_Real aF2Tol = BRep_Tool::Tolerance(aFx1); - Standard_Real aF1Tol = BRep_Tool::Tolerance(aF1); - Standard_Real aETol = BRep_Tool::Tolerance(anEx); - if( aETol > 1.e-5 && (aF2Tol > 1.e-5 && aF1Tol > 1.e-5) ) - aMoreShift = Standard_True; - Standard_Real aDT = 9.1e-5; - if( aMoreShift ) { - GetApproxNormalToFaceOnEdgeEx(anEx, aFx1, aT, aDT, aPx1, aDNFx1); - } - else { - //-- EJG - BOPTools_Tools3D::GetApproxNormalToFaceOnEdge (anEx, aFx1, aT, aPx1, aDNFx1); - } - - bIsAdjExists=BOPTools_Tools3D::GetAdjacentFace (aFx1, anEx, anEFMapx, aFx2); - - if (!bIsAdjExists) { - //-- EJG - if( aMoreShift ) { - GetApproxNormalToFaceOnEdgeEx(aSpxSimm, aFx1, aT, aDT, aPx2, aDNFx2); - } - else { - //-- EJG - BOPTools_Tools3D::GetApproxNormalToFaceOnEdge (aSpxSimm, aFx1, aT, aPx2, aDNFx2); - } - - aContext->ProjectPointOnEdge(aPx, anE1, aT1); - PointNearE (anE1, aF1, aT1, aPF1, aMoreShift); - } - - else {// if (bIsAdjExists) - BOPTools_Tools3D::GetApproxNormalToFaceOnEdge (aSpxSimm, aFx2, aT, aPx2, aDNFx2); - // - aContext->ProjectPointOnEdge(aPx, anE1, aT1); - PointNearE (anE1, aF1, aT1, aPF1, aMoreShift); - } - - { - Standard_Real d12, d1, anAlfa12, anAlfa1, aTwoPI; - - aTwoPI = M_PI + M_PI; - - gp_Vec aVx1(aPx, aPx1); - gp_Dir aDBx1 (aVx1); - gp_Pln aPlnToCompare (aPx, aDNFx1); - - gp_Vec aVx2(aPx, aPx2); - gp_Dir aDBx2 (aVx2); - - anAlfa12=aDBx1.Angle(aDBx2); - d12=BOPTools_Tools3D::SignDistance(aPx2, aPlnToCompare); - if (d12 < 0.) { - anAlfa12=aTwoPI-anAlfa12; - } - - gp_Vec aVF1(aPx, aPF1); - gp_Dir aDBF1 (aVF1); - anAlfa1=aDBx1.Angle(aDBF1); - d1=BOPTools_Tools3D::SignDistance(aPF1, aPlnToCompare); - if (d1 < 0.) { - anAlfa1=aTwoPI-anAlfa1; - } - - aStPF1=TopAbs_OUT; - if (anAlfa1 > anAlfa12) { - aStPF1=TopAbs_IN; - } - } -} - -//======================================================================= -//function : Orientation -//purpose : -//======================================================================= - TopAbs_Orientation BOPTools_Tools3D::Orientation(const TopoDS_Edge& anE, - const TopoDS_Face& aF) -{ - TopAbs_Orientation anOr=TopAbs_INTERNAL; - - TopExp_Explorer anExp; - anExp.Init(aF, TopAbs_EDGE); - for (; anExp.More(); anExp.Next()) { - const TopoDS_Edge& anEF1=TopoDS::Edge(anExp.Current()); - if (anEF1.IsEqual(anE)) { - anOr=anEF1.Orientation(); - break; - } - } - return anOr; -} - -//======================================================================= -//function : SignDistance -//purpose : -//======================================================================= - Standard_Real BOPTools_Tools3D::SignDistance(const gp_Pnt& aP, - const gp_Pln& aPln) -{ - Standard_Real A, B, C, D, d; - aPln.Coefficients(A, B, C, D); - // - d = A*aP.X() + B*aP.Y() + C*aP.Z() + D; - - return d; -} - -//======================================================================= -// function: IsValidArea -// purpose: -//======================================================================= - Standard_Boolean BOPTools_Tools3D::IsValidArea (const TopoDS_Face& aF, - Standard_Boolean& bNegativeFlag) - -{ - Standard_Boolean bFlag; - Standard_Real aMass, dM=1.e-16; - GProp_GProps G; - BRepGProp::SurfaceProperties(aF,G); - aMass=G.Mass(); - // - bFlag=(fabs(aMass)-dM > 0.); - bNegativeFlag=(aMass < dM); - - if( bNegativeFlag ) { - Bnd_Box boxF; - BRepBndLib::AddClose(aF, boxF); - Standard_Real aXmin = 0, aYmin = 0., aZmin = 0., aXmax = 0., aYmax = 0., aZmax = 0.; - boxF.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax); - Standard_Boolean bigX = (fabs(aXmax-aXmin) >= 1.e+10); - Standard_Boolean bigY = (fabs(aYmax-aYmin) >= 1.e+10); - Standard_Boolean bigZ = (fabs(aZmax-aZmin) >= 1.e+10); - if( !bigX && (!bigY && !bigZ) ) { - TopExp_Explorer anExp; - Standard_Integer nbW = 0; - for(anExp.Init(aF, TopAbs_WIRE); anExp.More(); anExp.Next()) { - const TopoDS_Wire& aW = TopoDS::Wire(anExp.Current()); - nbW++; - } - if( nbW == 1 ) { - TopTools_IndexedDataMapOfShapeListOfShape mapVE; - mapVE.Clear(); - TopExp::MapShapesAndAncestors(aF,TopAbs_VERTEX,TopAbs_EDGE,mapVE); - Standard_Integer nbKeys = mapVE.Extent(), iKey = 0; - Standard_Boolean changeFlag = Standard_True; - for( iKey = 1; iKey <= nbKeys; iKey++ ) { - const TopoDS_Vertex& iV = TopoDS::Vertex(mapVE.FindKey(iKey)); - if( iV.IsNull() ) continue; - //Standard_Real TolV = BRep_Tool::Tolerance(iV); - const TopTools_ListOfShape& iLE = mapVE.FindFromIndex(iKey); - Standard_Integer nbE = iLE.Extent(); - if( nbE != 2 ) { - changeFlag = Standard_False; - break; - } - const TopoDS_Edge& iE1 = TopoDS::Edge(iLE.First()); - const TopoDS_Edge& iE2 = TopoDS::Edge(iLE.Last()); - if(BRep_Tool::Degenerated(iE1) || - BRep_Tool::Degenerated(iE2) ) continue; - Standard_Real iPE1 = BRep_Tool::Parameter(iV,iE1); - Standard_Real iPE2 = BRep_Tool::Parameter(iV,iE2); - Standard_Real pF1 = 0., pL1 = 0., pF2 = 0., pL2 = 0.; - Handle(Geom_Curve) aC3D1 = BRep_Tool::Curve(iE1,pF1,pL1); - Handle(Geom_Curve) aC3D2 = BRep_Tool::Curve(iE2,pF2,pL2); - if( aC3D1.IsNull() || aC3D2.IsNull() ) { - changeFlag = Standard_False; - break; - } - if( Abs(Abs(pL1-pF1)-Abs(pL2-pF2)) <= 1.e-10 ) { - changeFlag = Standard_False; - break; - } - gp_Pnt aPnt1 = aC3D1->Value(iPE1); - gp_Pnt aPnt2 = aC3D2->Value(iPE2); - Standard_Real dist = aPnt1.Distance(aPnt2); - Standard_Real TolE1 = BRep_Tool::Tolerance(iE1); - Standard_Real TolE2 = BRep_Tool::Tolerance(iE2); - if( dist > (/*TolV+*/TolE1+TolE2) ) { - changeFlag = Standard_False; - break; - } - } - if( changeFlag ) bNegativeFlag = 0; - } - } - } - - // - return bFlag; -} - -//======================================================================= -// function: PointNearE -// purpose: -//======================================================================= -void PointNearE (const TopoDS_Edge& aE, - const TopoDS_Face& aF, - const Standard_Real aT, - gp_Pnt& aPInFace, - const Standard_Boolean aSt) -{ - Standard_Real aT1, aT2; - // - // 1. a Point on Edge aPOnEdge - Handle(Geom_Curve)aC=BRep_Tool::Curve(aE, aT1, aT2); - gp_Pnt aPOnEdge; - gp_Pnt2d aPInFace2D; - // - aC->D0 (aT, aPOnEdge); - // - // 2. a Point inside Face near aPOnEdge aPInFace; - TopoDS_Face aFF=aF; - TopoDS_Edge aERight; - aFF.Orientation(TopAbs_FORWARD); - BOPTools_Tools3D::OrientEdgeOnFace (aE, aFF, aERight); - // - // - Standard_Real aTolE, aDt2D; - GeomAbs_SurfaceType aType; - { - aDt2D=BOPTools_Tools3D::MinStepIn2d(); - // - Handle(Geom_Surface) aS=BRep_Tool::Surface(aFF); - GeomAdaptor_Surface aGASF(aS); - aType=aGASF.GetType(); - if (aType==GeomAbs_Plane) { - aTolE=BRep_Tool::Tolerance(aE); - if (aTolE>aDt2D) { - aDt2D=aTolE; - } - } - - } - - //-- EJG - if( aSt ) - if( aDt2D < 1.e-4) - aDt2D *= 10.; - //-- EJG - - // - BOPTools_Tools3D::PointNearEdge (aERight, aFF, aT, aDt2D, aPInFace2D, aPInFace); - // - if (BRep_Tool::IsClosed(aE, aF)) { - Standard_Real X, Y, UMin, UMax, VMin, VMax; - X=aPInFace2D.X(); - Y=aPInFace2D.Y(); - BRepTools::UVBounds(aF, UMin, UMax, VMin, VMax); - if (!(X >= UMin && X <= UMax && Y >= VMin && Y <= VMax)) { - aERight.Reverse(); - BOPTools_Tools3D::PointNearEdge (aERight, aFF, aT, aPInFace2D, aPInFace); - } - } - -} - -static Standard_Boolean PseudoSDFaces(const BRepAdaptor_Surface& BS1, - const BRepAdaptor_Surface& BS2) -{ - Standard_Real TolF1 = BS1.Tolerance(); - Standard_Real TolF2 = BS2.Tolerance(); - - gp_Pln Pln1 = BS1.Plane(); - gp_Pln Pln2 = BS2.Plane(); - - TopExp_Explorer anExpE; - Standard_Real pF = 0., pL = 0.; - - - const TopoDS_Face& aF1 = BS1.Face(); - Standard_Real maxTolE1 = 1.e-7; - Standard_Integer nbE1 = 0, nbOnE1 = 0; - for(anExpE.Init(aF1, TopAbs_EDGE); anExpE.More(); anExpE.Next()) { - const TopoDS_Edge& aE = TopoDS::Edge(anExpE.Current()); - nbE1++; - Standard_Real aTolE = BRep_Tool::Tolerance(aE); - if( aTolE > maxTolE1 ) maxTolE1 = aTolE; - Handle(Geom_Curve) aC3D = BRep_Tool::Curve(aE, pF, pL); - if( !aC3D.IsNull() ) { - Standard_Real pM = BOPTools_Tools2D::IntermediatePoint(pF, pL); - gp_Pnt mPnt = aC3D->Value(pM); - Standard_Real distMP = Pln2.Distance(mPnt); - - if( distMP <= aTolE ) - nbOnE1++; - else { - TopoDS_Vertex Vf, Vl; - TopExp::Vertices(aE,Vf,Vl); - if( !Vf.IsNull() && !Vl.IsNull() ) { - Standard_Real aTolVf = BRep_Tool::Tolerance(Vf); - Standard_Real aTolVl = BRep_Tool::Tolerance(Vl); - gp_Pnt aPntF = BRep_Tool::Pnt(Vf); - gp_Pnt aPntL = BRep_Tool::Pnt(Vl); - Standard_Real distF = Pln2.Distance(aPntF); - Standard_Real distL = Pln2.Distance(aPntL); - if( distF <= aTolVf && distL <= aTolVl ) - nbOnE1++; - } - else if( !Vf.IsNull() && Vl.IsNull() ) { - Standard_Real aTolVf = BRep_Tool::Tolerance(Vf); - gp_Pnt aPntF = BRep_Tool::Pnt(Vf); - Standard_Real distF = Pln2.Distance(aPntF); - if( distF <= aTolVf ) - nbOnE1++; - } - else if( Vf.IsNull() && !Vl.IsNull() ) { - Standard_Real aTolVl = BRep_Tool::Tolerance(Vl); - gp_Pnt aPntL = BRep_Tool::Pnt(Vl); - Standard_Real distL = Pln2.Distance(aPntL); - if( distL <= aTolVl ) - nbOnE1++; - } - else - continue; - } - } - } - - Standard_Boolean procF1 = ((maxTolE1/TolF1) >= 1000. || - (TolF1/maxTolE1) >= 1000.) ? Standard_True : Standard_False; - procF1 = (procF1 && (nbE1 > 1 && nbOnE1 > 1) ); - - if( !procF1 ) - return Standard_False; - - const TopoDS_Face& aF2 = BS1.Face(); - Standard_Real maxTolE2 = 1.e-7; - Standard_Integer nbE2 = 0, nbOnE2 = 0; - for(anExpE.Init(aF2, TopAbs_EDGE); anExpE.More(); anExpE.Next()) { - const TopoDS_Edge& aE = TopoDS::Edge(anExpE.Current()); - nbE2++; - Standard_Real aTolE = BRep_Tool::Tolerance(aE); - if( aTolE > maxTolE2 ) maxTolE2 = aTolE; - Handle(Geom_Curve) aC3D = BRep_Tool::Curve(aE, pF, pL); - if( !aC3D.IsNull() ) { - Standard_Real pM = BOPTools_Tools2D::IntermediatePoint(pF, pL); - gp_Pnt mPnt = aC3D->Value(pM); - Standard_Real distMP = Pln1.Distance(mPnt); - if( distMP <= aTolE ) - nbOnE2++; - else { - TopoDS_Vertex Vf, Vl; - TopExp::Vertices(aE,Vf,Vl); - if( !Vf.IsNull() && !Vl.IsNull() ) { - Standard_Real aTolVf = BRep_Tool::Tolerance(Vf); - Standard_Real aTolVl = BRep_Tool::Tolerance(Vl); - gp_Pnt aPntF = BRep_Tool::Pnt(Vf); - gp_Pnt aPntL = BRep_Tool::Pnt(Vl); - Standard_Real distF = Pln1.Distance(aPntF); - Standard_Real distL = Pln1.Distance(aPntL); - if( distF <= aTolVf && distL <= aTolVl ) - nbOnE2++; - } - else if( !Vf.IsNull() && Vl.IsNull() ) { - Standard_Real aTolVf = BRep_Tool::Tolerance(Vf); - gp_Pnt aPntF = BRep_Tool::Pnt(Vf); - Standard_Real distF = Pln1.Distance(aPntF); - if( distF <= aTolVf ) - nbOnE2++; - } - else if( Vf.IsNull() && !Vl.IsNull() ) { - Standard_Real aTolVl = BRep_Tool::Tolerance(Vl); - gp_Pnt aPntL = BRep_Tool::Pnt(Vl); - Standard_Real distL = Pln1.Distance(aPntL); - if( distL <= aTolVl ) - nbOnE2++; - } - else - continue; - } - } - } - - Standard_Boolean procF2 = ((maxTolE2/TolF2) >= 1000. || - (TolF2/maxTolE2) >= 1000.) ? Standard_True : Standard_False; - procF2 = (procF2 && (nbE2 > 1 && nbOnE2 > 1) ); - - return (procF1 && procF2); - -} - -Standard_Boolean CheckKeepArguments(const TopoDS_Face& F1, - const TopoDS_Face& F2, - const TopoDS_Face& F3) -{ - BRepAdaptor_Surface aBS1(F1); - BRepAdaptor_Surface aBS2(F2); - BRepAdaptor_Surface aBS3(F3); - - GeomAbs_SurfaceType aT1 = aBS1.GetType(); - GeomAbs_SurfaceType aT2 = aBS2.GetType(); - GeomAbs_SurfaceType aT3 = aBS3.GetType(); - - if(aT1 == GeomAbs_Cylinder || - aT1 == GeomAbs_Cone || - aT1 == GeomAbs_Sphere || - aT1 == GeomAbs_Torus ) return Standard_True; - - if(aT2 == GeomAbs_Cylinder || - aT2 == GeomAbs_Cone || - aT3 == GeomAbs_Sphere || - aT3 == GeomAbs_Torus ) return Standard_True; - - if(aT3 == GeomAbs_Cylinder || - aT3 == GeomAbs_Cone || - aT3 == GeomAbs_Sphere || - aT3 == GeomAbs_Torus ) return Standard_True; - - if( aT1 == GeomAbs_Plane && aT2 == GeomAbs_Plane ) { - if( PseudoSDFaces(aBS1, aBS2) ) - return Standard_False; - } - else if( aT1 == GeomAbs_Plane && aT3 == GeomAbs_Plane ) { - if( PseudoSDFaces(aBS1, aBS3) ) - return Standard_False; - } - else if( aT2 == GeomAbs_Plane && aT3 == GeomAbs_Plane ) { - if( PseudoSDFaces(aBS2, aBS3) ) - return Standard_False; - } - else - return Standard_True; - return Standard_True; -} diff --git a/src/BOPTools/BOPTools_Tools3D_1.cxx b/src/BOPTools/BOPTools_Tools3D_1.cxx deleted file mode 100755 index e235c47145..0000000000 --- a/src/BOPTools/BOPTools_Tools3D_1.cxx +++ /dev/null @@ -1,1091 +0,0 @@ -// Created on: 2001-06-18 -// Created by: Peter KURNEV -// Copyright (c) 2001-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#include -#include - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include - -#include -#include - -#include -#include - -#include -#include - -#include -#include -#include -#include - -#include - -static Standard_Boolean CheckPointInside(BRepClass3d_SolidClassifier& aSolidClassifier, - const gp_Pnt& aP3d, - const Standard_Real aTolerance, - const Handle(IntTools_Context)& theContext, - TopAbs_State& aState, - Standard_Boolean& bFoundInFacePoint); - -//======================================================================= -//function : GetApproxNormalToFaceOnEdge -//purpose : -//======================================================================= -void BOPTools_Tools3D::GetApproxNormalToFaceOnEdge (const TopoDS_Edge& aE, - const TopoDS_Face& aF, - const Standard_Real aT, - gp_Pnt& aPNear, - gp_Dir& aDNF) -{ - Standard_Real aFirst, aLast; - Handle(Geom2d_Curve) aC2D= BRep_Tool::CurveOnSurface (aE, aF, aFirst, aLast); - - if (aC2D.IsNull()) { - return; - } - //gp_Pnt aPNear; - gp_Pnt2d aPx2DNear; - BOPTools_Tools3D::PointNearEdge (aE, aF, aT, aPx2DNear, aPNear); - - Handle(Geom_Surface) aS=BRep_Tool::Surface(aF); - - BOPTools_Tools3D::GetNormalToSurface (aS, aPx2DNear.X(), aPx2DNear.Y(), aDNF); - - if (aF.Orientation()==TopAbs_REVERSED){ - aDNF.Reverse(); - } -} -//======================================================================= -//function : PointNearEdge -//purpose : -//======================================================================= - void BOPTools_Tools3D::PointNearEdge (const TopoDS_Edge& aE, - const TopoDS_Face& aF, - const Standard_Real aT, - const Standard_Real aDt2D, - gp_Pnt2d& aPx2DNear, - gp_Pnt& aPxNear) -{ - Standard_Real aFirst, aLast, aETol, aFTol, transVal; - GeomAbs_SurfaceType aTS; - Handle(Geom2d_Curve) aC2D; - Handle(Geom_Surface) aS; - // - aC2D= BRep_Tool::CurveOnSurface (aE, aF, aFirst, aLast); - if (aC2D.IsNull()) { - aPx2DNear.SetCoord (99., 99); - return; - } - // - aS=BRep_Tool::Surface(aF); - // - gp_Pnt2d aPx2D; - gp_Vec2d aVx2D; - aC2D->D1 (aT, aPx2D, aVx2D); - gp_Dir2d aDx2D(aVx2D); - - gp_Dir2d aDP; - aDP.SetCoord (-aDx2D.Y(), aDx2D.X()); - - if (aE.Orientation()==TopAbs_REVERSED){ - aDP.Reverse(); - } - - if (aF.Orientation()==TopAbs_REVERSED) { - aDP.Reverse(); - } - // - aETol = BRep_Tool::Tolerance(aE); - aFTol = BRep_Tool::Tolerance(aF); - // pkv NPAL19220 - GeomAdaptor_Surface aGAS(aS); - aTS=aGAS.GetType(); - if (aTS==GeomAbs_BSplineSurface) { - if (aETol > 1.e-5) { - aFTol=aETol; - } - } - //modified by NIZNHY-PKV Thu Mar 19 14:15:15 2009f - if( aETol > 1.e-5 || aFTol > 1.e-5 ) { - //if( aETol > 1.e-5 && aFTol > 1.e-5 ) { - //modified by NIZNHY-PKV Thu Mar 19 14:15:24 2009t - //pkv/103/D7 - if(aTS!=GeomAbs_Sphere) { - gp_Vec2d transVec( aDP ); - transVal = aDt2D + aETol + aFTol; - if (aTS==GeomAbs_Cylinder) {// pkv/909/F8 - Standard_Real aR, dT; - // - gp_Cylinder aCyl=aGAS.Cylinder(); - aR=aCyl.Radius(); - dT=1.-transVal/aR; - dT=acos(dT); - transVal=dT; - } - // - transVec.Multiply(transVal); - // - aPx2DNear = aPx2D.Translated( transVec ); - } - else { - aPx2DNear.SetCoord (aPx2D.X()+aDt2D*aDP.X(), aPx2D.Y()+aDt2D*aDP.Y()); - } - } - else { - aPx2DNear.SetCoord (aPx2D.X()+aDt2D*aDP.X(), aPx2D.Y()+aDt2D*aDP.Y()); - } - // - aS->D0(aPx2DNear.X(), aPx2DNear.Y(), aPxNear); -} - -//======================================================================= -//function : PointNearEdge -//purpose : -//======================================================================= - void BOPTools_Tools3D::PointNearEdge (const TopoDS_Edge& aE, - const TopoDS_Face& aF, - const Standard_Real aT, - gp_Pnt2d& aPx2DNear, - gp_Pnt& aPxNear) -{ - Standard_Real dt2D=BOPTools_Tools3D::MinStepIn2d();//~1.e-5; - // - BOPTools_Tools3D::PointNearEdge (aE, aF, aT, dt2D, aPx2DNear, aPxNear); -} - -//======================================================================= -// function: PointNearEdge -// purpose: -//======================================================================= - void BOPTools_Tools3D::PointNearEdge (const TopoDS_Edge& aE, - const TopoDS_Face& aF, - gp_Pnt2d& aPInFace2D, - gp_Pnt& aPInFace) - -{ - Standard_Real aT, aT1, aT2; - // - // 1. - BRep_Tool::Range(aE, aT1, aT2); - aT=BOPTools_Tools2D::IntermediatePoint(aT1, aT2); - // - // 2. a Point inside Face near aPOnEdge aPInFace; - TopoDS_Face aFF=aF; - TopoDS_Edge aERight; - aFF.Orientation(TopAbs_FORWARD); - BOPTools_Tools3D::OrientEdgeOnFace (aE, aFF, aERight); - - BOPTools_Tools3D::PointNearEdge (aERight, aFF, aT, aPInFace2D, aPInFace); -} - - -//======================================================================= -//function : PointToCompare -//purpose : -//======================================================================= - void BOPTools_Tools3D::PointToCompare (const gp_Pnt& aP1, - const gp_Pnt& aP2, - const TopoDS_Face& aF, - gp_Pnt& aPF, - const Handle(IntTools_Context)& aContext) -{ - Standard_Boolean bFlag; - Standard_Real aD, aTolF, U, V; - - Handle(Geom_Surface) aS=BRep_Tool::Surface(aF); - - aTolF=BRep_Tool::Tolerance(aF); - // - GeomAPI_ProjectPointOnSurf& aProjector=aContext->ProjPS(aF); - // - aProjector.Perform(aP1); - // - bFlag=aProjector.IsDone(); - - if (bFlag) { - aD=aProjector.LowerDistance(); - if (aDD0(U, V, aPF); - return; - } - } - // - aProjector.Perform(aP2); - // - bFlag=aProjector.IsDone(); - - if (bFlag) { - aD=aProjector.LowerDistance(); - if (aDD0(U, V, aPF); - return; - } - } - - aPF=aP1; -} - -//======================================================================= -//function : GetPlane -//purpose : -//======================================================================= - void BOPTools_Tools3D::GetPlane (const TopoDS_Edge& aSpEF1, - const TopoDS_Edge& aEF1, - const TopoDS_Face& aF1, - const TopoDS_Face& aF2, - TopAbs_State& aStPF, - const Handle(IntTools_Context)& aContext) -{ - Standard_Real aT1, aT2, aT, aTolF2, aDt2D; - gp_Pnt2d aPx2DNear; - gp_Pnt aPxNear, aPxF2; - gp_Dir aDNF2; - - Handle(Geom_Curve)aC3D =BRep_Tool::Curve(aSpEF1, aT1, aT2); - aT=BOPTools_Tools2D::IntermediatePoint(aT1, aT2); - - Handle(Geom2d_Curve) aC2D= BRep_Tool::CurveOnSurface (aEF1, aF1, aT1, aT2); - - aStPF=TopAbs_OUT; - // - aDt2D=BOPTools_Tools3D::MinStepIn2d();//~1.e-5; - aTolF2=BRep_Tool::Tolerance(aF2); - // - { - GeomAbs_SurfaceType aType1; - - Handle(Geom_Surface) aS1=BRep_Tool::Surface(aF1); - GeomAdaptor_Surface aGASF1(aS1); - aType1=aGASF1.GetType(); - - if (aType1==GeomAbs_Cylinder) { - Standard_Real aCT, aDt2Dx, aPC=0.99; - - aCT=1.-aGASF1.UResolution(aTolF2); - aDt2Dx=aPC*acos(aCT); - if (aDt2Dx>aDt2D) { - aDt2D=aDt2Dx; - } - } - } - // - BOPTools_Tools3D::PointNearEdge (aEF1, aF1, aT, aDt2D, aPx2DNear, aPxNear); - // - - //-- EJG - Standard_Boolean isIn = aContext->IsPointInFace(aF1,aPx2DNear); - if( !isIn ) { - Standard_Real aEF1Tol = BRep_Tool::Tolerance(aEF1); - Standard_Real aF1Tol = BRep_Tool::Tolerance(aF1); - if( aEF1Tol > 1.e-5 || ( aF1Tol > 1.e-5 || aTolF2 > 1.e-5 ) ) { - gp_Pnt2d aP2DOnC; - aC2D->D0(aT, aP2DOnC); - gp_Vec2d aP2Dir( aPx2DNear, aP2DOnC ); - Standard_Real transVal = aP2Dir.Magnitude(); - gp_Vec2d aP2DirN = aP2Dir.Normalized(); - if( aF1Tol > 1.e-5 && aTolF2 > 1.e-5 ) { - transVal = 2.*transVal +aEF1Tol + aF1Tol + aTolF2; - } - else { - transVal *= 2.; - } - aPx2DNear.Translate( (transVal*aP2DirN) ); - Handle(Geom_Surface) aS1 = BRep_Tool::Surface(aF1); - aS1->D0(aPx2DNear.X(), aPx2DNear.Y(), aPxNear); - - } - } - //-- EJG - - Standard_Boolean bFlag; - Standard_Real aD, U, V; - // - GeomAPI_ProjectPointOnSurf& aProjector=aContext->ProjPS(aF2); - // - Handle(Geom_Surface) aS2=BRep_Tool::Surface(aF2); - // - aProjector.Perform(aPxNear); - // - bFlag=aProjector.IsDone(); - - if (!bFlag) { - return; - } - // - aD=aProjector.LowerDistance(); - if (aDD0(U, V, aPxF2); - - BOPTools_Tools3D::GetNormalToSurface (aS2, U, V, aDNF2); - - if (aF2.Orientation()==TopAbs_REVERSED){ - aDNF2.Reverse(); - } - - gp_Pln aPlnF2(aPxF2, aDNF2); - // - aD=BOPTools_Tools3D::SignDistance(aPxNear, aPlnF2); - - if (aD<=0.) { - aStPF=TopAbs_IN; - } - } -} - -//======================================================================= -//function : GetPointState -//purpose : -//======================================================================= - void BOPTools_Tools3D::GetPointState (const TopoDS_Edge& aSpEF2, - const TopoDS_Edge& aEF2, - const TopoDS_Face& aF2adj, - const TopoDS_Face& aF1, - TopAbs_State& aStPF) -{ - Standard_Real aT1, aT2, aT, aTolEF2; - gp_Dir aDNF1; - gp_Pnt2d aPxOnF1, aPxOnF2; - // - TopoDS_Face aF2adjF=aF2adj; - aF2adjF.Orientation(TopAbs_FORWARD); - // - aTolEF2=BRep_Tool::Tolerance(aEF2); - // - aStPF=TopAbs_OUT; - // - Handle(Geom_Curve)aC3D =BRep_Tool::Curve(aSpEF2, aT1, aT2); - aT=BOPTools_Tools2D::IntermediatePoint(aT1, aT2); - // - // 2D-curves of aSpEF2 for aF1, aF2adj - Handle(Geom2d_Curve) aC2DF1= BRep_Tool::CurveOnSurface (aSpEF2, aF1, aT1, aT2); - aC2DF1->D0(aT, aPxOnF1); - - Handle(Geom2d_Curve) aC2DF2= BRep_Tool::CurveOnSurface (aSpEF2, aF2adjF, aT1, aT2); - aC2DF2->D0(aT, aPxOnF2); - // - // Surfaces - Handle(Geom_Surface) aS1=BRep_Tool::Surface(aF1); - Handle(Geom_Surface) aS2=BRep_Tool::Surface(aF2adjF); - - // - // Step aDt2D - Standard_Real aDt2D, aDt2dMin, aURes, aVRes; - // - GeomAdaptor_Surface aGASF2adjF(aS2); - // - aURes=aGASF2adjF.UResolution(aTolEF2); - aVRes=aGASF2adjF.VResolution(aTolEF2); - aDt2D=(aURes>aVRes) ? aURes : aVRes; - // - aDt2dMin=BOPTools_Tools3D::MinStepIn2d(); - // - if (aDt2D < aDt2dMin) { - aDt2D=aDt2dMin; - } - // - // Point aPxNear on aF2adjF that is Near Edge aEF2Right at parameter aT - gp_Pnt2d aPx2DNear; - gp_Pnt aPxNear; - TopoDS_Edge aEF2Right; - // - BOPTools_Tools3D::OrientEdgeOnFace (aEF2, aF2adjF, aEF2Right); - // - BOPTools_Tools3D::PointNearEdge (aEF2Right, aF2adjF, aT, aDt2D, aPx2DNear, aPxNear); - // - // Normal to the face aF1 at the point aPxOnF1 - BOPTools_Tools3D::GetNormalToSurface (aS1, aPxOnF1.X(), aPxOnF1.Y(), aDNF1); - if (aF1.Orientation()==TopAbs_REVERSED){ - aDNF1.Reverse(); - } - // - // Plane to compare aPlnF1 - gp_Pnt aPxF1, aPxF2; - // - aS1->D0(aPxOnF1.X(), aPxOnF1.Y(), aPxF1); - // - gp_Pln aPlnF1(aPxF1, aDNF1); - // - // Correction on shifting vector aVx - { - Standard_Real aX, aY, aZ; - // - aS2->D0(aPxOnF2.X(), aPxOnF2.Y(), aPxF2); - gp_Vec aVx(aPxF2, aPxF1); - // - aX=aPxNear.X()+aVx.X(); - aY=aPxNear.Y()+aVx.Y(); - aZ=aPxNear.Z()+aVx.Z(); - // - aPxNear.SetCoord(aX, aY, aZ); - } - // - // Signed Distance between aPxNear, aPlnF1 - Standard_Real aD; - aD=BOPTools_Tools3D::SignDistance(aPxNear, aPlnF1); - if (aD<=0.) { - aStPF=TopAbs_IN; - } -} - -//======================================================================= -//function : OrientEdgeOnFace -//purpose : -//======================================================================= - void BOPTools_Tools3D::OrientEdgeOnFace (const TopoDS_Edge& aE, - const TopoDS_Face& aF, - TopoDS_Edge& aERight) -{ - if (BRep_Tool::IsClosed(aE, aF)) { - aERight=aE; - aERight.Orientation(aE.Orientation()); - - Standard_Integer iFoundCount = 0; - TopoDS_Edge anEdge = aE; - TopExp_Explorer anExp(aF, TopAbs_EDGE); - - for (; anExp.More(); anExp.Next()) { - const TopoDS_Shape& aSS=anExp.Current(); - - if (aSS.IsSame(aE)) { - anEdge = TopoDS::Edge(aSS); - iFoundCount++; - } - } - - if(iFoundCount == 1) { - aERight = anEdge; - } - return; - } - - TopExp_Explorer anExp(aF, TopAbs_EDGE); - for (; anExp.More(); anExp.Next()) { - const TopoDS_Shape& aSS=anExp.Current(); - if (aSS.IsSame(aE)) { - aERight=aE; - aERight.Orientation(aSS.Orientation()); - return; - } - } - aERight=aE; - aERight.Orientation(aE.Orientation()); -} -//======================================================================= -//function : OrientTouchEdgeOnF1 -//purpose : -//======================================================================= - TopAbs_Orientation BOPTools_Tools3D::OrientTouchEdgeOnF1 (const TopoDS_Edge& aSpEF2, - const TopoDS_Edge& aEF2, - const TopoDS_Face& aF2adj, - const TopoDS_Face& aF1) -{ - Standard_Real aT1, aT2, aT; - // - Handle(Geom_Curve)aC3D =BRep_Tool::Curve(aSpEF2, aT1, aT2); - // - // point on edge aEF2 inside range of aSpEF2: - gp_Pnt aPx; - aT=BOPTools_Tools2D::IntermediatePoint(aT1, aT2); - aC3D->D0(aT, aPx); - // - // Normal to aF1 - gp_Dir aDNF1; - Handle(Geom2d_Curve) aC2DF1= BRep_Tool::CurveOnSurface (aSpEF2, aF1, aT1, aT2); - gp_Pnt2d aPxOnF1; - aC2DF1->D0(aT, aPxOnF1); - - Handle(Geom_Surface) aS1=BRep_Tool::Surface(aF1); - BOPTools_Tools3D::GetNormalToSurface (aS1, aPxOnF1.X(), aPxOnF1.Y(), aDNF1); - - if (aF1.Orientation()==TopAbs_REVERSED){ - aDNF1.Reverse(); - } - // - // Point aPxNear that is ON F2adj and near Px - gp_Pnt2d aPx2DNear; - gp_Pnt aPxNear; - - Handle(Geom2d_Curve) aC2D= BRep_Tool::CurveOnSurface (aEF2, aF2adj, aT1, aT2); - - TopoDS_Face aF2adjF=aF2adj; - aF2adjF.Orientation(TopAbs_FORWARD); - TopoDS_Edge aEF2Right; - BOPTools_Tools3D::OrientEdgeOnFace (aEF2, aF2adjF, aEF2Right); - BOPTools_Tools3D::PointNearEdge (aEF2Right, aF2adjF, aT, aPx2DNear, aPxNear); - // - // Normal to aF2adj - gp_Dir aDNF2; - Handle(Geom_Surface) aS2=BRep_Tool::Surface(aF2adj); - BOPTools_Tools3D::GetNormalToSurface (aS2, aPx2DNear.X(), aPx2DNear.Y(), aDNF2); - - if (aF2adj.Orientation()==TopAbs_REVERSED){ - aDNF2.Reverse(); - } - // - // vector product - gp_Dir aDTN=aDNF1^aDNF2; - // Tangent for split - gp_Vec aTE; - BOPTools_Tools2D::TangentOnEdge(aT, aSpEF2, aTE); - gp_Dir aDTE(aTE); - - Standard_Real aScPr; - aScPr=aDTN*aDTE; - - TopAbs_Orientation anOr; - anOr=TopAbs_FORWARD; - if (aScPr<0.) { - anOr=TopAbs_REVERSED; - } - return anOr; -} - -//======================================================================= -// function: GetSeams -// purpose: -//======================================================================= - void BOPTools_Tools3D::GetSeams (const TopoDS_Face& aF, - TopoDS_Edge& aSim1, - TopoDS_Edge& aSim2) -{ - TopTools_ListOfShape aLS; - TopExp_Explorer anExpEdges (aF, TopAbs_EDGE); - for (; anExpEdges.More(); anExpEdges.Next()) { - const TopoDS_Edge& aE= TopoDS::Edge(anExpEdges.Current()); - if (BRep_Tool::IsClosed(aE, aF)) { - aLS.Append(aE); - } - } - aSim1=TopoDS::Edge(aLS.First()); - aSim2=TopoDS::Edge(aLS.Last ()); -} - -//======================================================================= -// function: GetSeam -// purpose: -//======================================================================= - void BOPTools_Tools3D::GetSeam (const TopoDS_Face& aF, - const TopoDS_Edge& aSim1, - TopoDS_Edge& aSim2) -{ - TopExp_Explorer anExpEdges (aF, TopAbs_EDGE); - for (; anExpEdges.More(); anExpEdges.Next()) { - const TopoDS_Edge& aE= TopoDS::Edge(anExpEdges.Current()); - if (BRep_Tool::IsClosed(aE, aF)) { - if (aE.IsSame(aSim1)) { - if (aE!=aSim1) { - aSim2=aE; - return; - } - } - } - } -} - -//======================================================================= -//function : MinStepIn2d -//purpose : -//======================================================================= - Standard_Real BOPTools_Tools3D::MinStepIn2d() -{ - Standard_Real dt=1.e-5; - return dt; -} - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static - Standard_Boolean HasGeometry(const TopoDS_Shape& aS); - -static - void Add(const TopoDS_Shape& aS, - TopTools_IndexedMapOfShape& myShapes, - Standard_Boolean& bHasGeometry); - -//======================================================================= -//function : IsEmptyShape -//purpose : -//======================================================================= - Standard_Boolean BOPTools_Tools3D::IsEmptyShape(const TopoDS_Shape& aS) -{ - Standard_Boolean bHasGeometry=Standard_False; - // - TopTools_IndexedMapOfShape myShapes; - // - Add(aS, myShapes, bHasGeometry); - - return !bHasGeometry; -} -//======================================================================= -//function : Add -//purpose : -//======================================================================= -void Add(const TopoDS_Shape& aS, - TopTools_IndexedMapOfShape& myShapes, - Standard_Boolean& bHasGeometry) -{ - Standard_Integer anIndex; - // - if (bHasGeometry) { - return; - } - // - if (aS.IsNull()) { - return; - } - // - TopoDS_Shape aSx = aS; - // - anIndex=myShapes.FindIndex(aSx); - if (!anIndex) { - bHasGeometry=HasGeometry (aSx); - if (bHasGeometry) { - return; - } - // - TopoDS_Iterator anIt(aSx, Standard_False, Standard_False); - for(; anIt.More(); anIt.Next()) { - const TopoDS_Shape& aSy=anIt.Value(); - Add(aSy, myShapes, bHasGeometry); - // - if (bHasGeometry) { - return; - } - // - myShapes.Add(aSx); - } - } -} -//======================================================================= -//function : HasGeometry -//purpose : -//======================================================================= - Standard_Boolean HasGeometry(const TopoDS_Shape& aS) -{ - Standard_Boolean bHasGeometry=Standard_True; - TopAbs_ShapeEnum aType= aS.ShapeType(); - - if (aType == TopAbs_VERTEX) { - - Handle(BRep_TVertex) TV = Handle(BRep_TVertex)::DownCast(aS.TShape()); - BRep_ListIteratorOfListOfPointRepresentation itrp(TV->Points()); - - while (itrp.More()) { - const Handle(BRep_PointRepresentation)& PR = itrp.Value(); - - if (PR->IsPointOnCurve()) { - return bHasGeometry; - } - - else if (PR->IsPointOnCurveOnSurface()) { - return bHasGeometry; - } - - else if (PR->IsPointOnSurface()) { - return bHasGeometry; - } - itrp.Next(); - } - } - - // - else if (aType == TopAbs_EDGE) { - Handle(BRep_TEdge) TE = Handle(BRep_TEdge)::DownCast(aS.TShape()); - BRep_ListIteratorOfListOfCurveRepresentation itrc(TE->Curves()); - - while (itrc.More()) { - const Handle(BRep_CurveRepresentation)& CR = itrc.Value(); - if (CR->IsCurve3D()) { - if (!CR->Curve3D().IsNull()) { - return bHasGeometry; - } - } - else if (CR->IsCurveOnSurface()) { - return bHasGeometry; - } - else if (CR->IsRegularity()) { - return bHasGeometry; - } - else if (!CR->Polygon3D().IsNull()) { - return bHasGeometry; - } - else if (CR->IsPolygonOnTriangulation()) { - return bHasGeometry; - } - else if (CR->IsPolygonOnSurface()) { - return bHasGeometry; - } - itrc.Next(); - } - } - // - else if (aType == TopAbs_FACE) { - Handle(BRep_TFace) TF = Handle(BRep_TFace)::DownCast(aS.TShape()); - if (!TF->Surface().IsNull()) { - return bHasGeometry; - } - Handle(Poly_Triangulation) Tr = TF->Triangulation(); - if (!Tr.IsNull()) { - return bHasGeometry; - } - } - - return !bHasGeometry; -} - -//======================================================================= -// function: InvertShape -// purpose: -//======================================================================= - void BOPTools_Tools3D::InvertShape(const TopoDS_Shape& aS, - TopoDS_Shape& aSInvert) -{ - BRep_Builder aBB; - - aSInvert=aS.EmptyCopied(); - - TopoDS_Iterator anIt(aS); - - while (anIt.More()) { - aBB.Add(aSInvert, anIt.Value().Reversed()); - anIt.Next(); - } -} - -//======================================================================= -// function: GetStatePartIN2D -// purpose: -//======================================================================= - TopAbs_State BOPTools_Tools3D::GetStatePartIN2D(const TopoDS_Edge& aSp, - const TopoDS_Edge& aEF1, - const TopoDS_Face& aF1, - const TopoDS_Face& aF2, - const Handle(IntTools_Context)& aContext) -{ - gp_Dir aDBF1, aDNF2; - TopAbs_State aStPF; - - BOPTools_Tools3D::GetBiNormal (aSp, aF1, aDBF1); - BOPTools_Tools3D::GetNormalToFaceOnEdge (aSp, aF2, aDNF2); - - Standard_Real aTolScPr, aScPr; - - aTolScPr=1.e-7; - aScPr=aDBF1*aDNF2; - - //XX 909/G2 - BRepAdaptor_Surface aBAS1, aBAS2; - GeomAbs_SurfaceType aType1, aType2; - - aBAS1.Initialize (aF1, Standard_False); - aBAS2.Initialize (aF2, Standard_False); - aType1=aBAS1.GetType(); - aType2=aBAS2.GetType(); - - if (aType1==GeomAbs_BSplineSurface - || - aType2==GeomAbs_BSplineSurface) { - //aTolScPr=1.e-5; - aTolScPr=5.5e-5; - } - //XX - - if (fabs(aScPr) < aTolScPr) { - - - BOPTools_Tools3D::GetPlane(aSp, aEF1, aF1, aF2, aStPF, aContext); - aScPr=1.; // >0. - if (aStPF==TopAbs_IN) { - aScPr=-1.; // <0. - } - } - - aStPF=TopAbs_OUT; - if (aScPr<0.) { - aStPF=TopAbs_IN; - } - return aStPF; -} -// =========================================================================================== -// function: ComputeFaceState -// purpose: -// =========================================================================================== -Standard_Boolean BOPTools_Tools3D::ComputeFaceState(const TopoDS_Face& theFace, - const TopoDS_Solid& theRef, - const Handle(IntTools_Context)& theContext, - TopAbs_State& theState) -{ - TopAbs_State aState = TopAbs_ON; - - Standard_Real umin = 0., umax = 0., vmin = 0., vmax = 0.; - BRepTools::UVBounds(theFace, umin, umax, vmin, vmax); - Handle(Geom_Surface) aSurface = BRep_Tool::Surface(theFace); - Standard_Real aTolerance = BRep_Tool::Tolerance(theFace); - - Standard_Integer nbpoints = 5; - Standard_Real adeltau = (umax - umin) / (nbpoints + 1); - Standard_Real adeltav = (vmax - vmin) / (nbpoints + 1); - Standard_Real U = umin + adeltau; - Standard_Boolean bFoundValidPoint = Standard_False; - Standard_Boolean bFoundInFacePoint = Standard_False; - BRepClass3d_SolidClassifier& aSolidClassifier = theContext->SolidClassifier(theRef); - Standard_Integer i = 0, j = 0; - - for(i = 1; !bFoundValidPoint && (i <= nbpoints); i++, U+=adeltau) { - Standard_Real V = vmin + adeltav; - - for(j = 1; !bFoundValidPoint && (j <= nbpoints); j++, V+=adeltav) { - gp_Pnt2d aPoint(U,V); - - if(theContext->IsPointInFace(theFace, aPoint)) { - bFoundInFacePoint = Standard_True; - gp_Pnt aP3d = aSurface->Value(U, V); - - aSolidClassifier.Perform(aP3d, aTolerance); - aState = aSolidClassifier.State(); - - if(aState != TopAbs_ON) { - - if(!aSolidClassifier.Rejected()) { - TopoDS_Face aFace2 = aSolidClassifier.Face(); - - if(!aFace2.IsNull()) { - if(BOPTools_Tools3D::CheckSameDomainFaceInside(theFace, aFace2, theContext)) - aState = TopAbs_ON; - else { - break; - } - } - } - } - } - } - } - - if(!bFoundInFacePoint) { - U = (umin + umax) * 0.5; - nbpoints /= 2; - - for(i = 1; !bFoundValidPoint && (i <= nbpoints); i++, U+=adeltau) { - Standard_Real V = (vmin + vmax) * 0.5; - - for(j = 1; !bFoundValidPoint && (j <= nbpoints); j++, V+=adeltav) { - gp_Pnt2d aPoint(U,V); - - if(theContext->IsPointInOnFace(theFace, aPoint)) { - bFoundInFacePoint = Standard_True; - gp_Pnt aP3d = aSurface->Value(U, V); - - bFoundValidPoint = CheckPointInside(aSolidClassifier, aP3d, aTolerance, theContext, - aState, bFoundInFacePoint); - if (bFoundValidPoint) { - break; - } - } - } - } - } - //emv for salome bug 23160 - if(!bFoundInFacePoint) { - TopExp_Explorer aExp; - Standard_Real aT1, aT2, aT, aDt2D; - gp_Pnt aPx, aP3d; - gp_Pnt2d aPoint; - aExp.Init(theFace, TopAbs_EDGE); - for(; aExp.More(); aExp.Next()) { - const TopoDS_Edge& aE=(*(TopoDS_Edge*)(&aExp.Current())); - if (aE.Orientation()==TopAbs_INTERNAL) { - continue; - } - // - if (BRep_Tool::Degenerated(aE)){ - continue; - } - // - //get point inside face - Handle(Geom_Curve)aC3D = BRep_Tool::Curve(aE, aT1, aT2); - aT=BOPTools_Tools2D::IntermediatePoint(aT1, aT2); - aC3D->D0(aT, aPx); - aDt2D = BOPTools_Tools3D::MinStepIn2d(); - aDt2D += 2*BRep_Tool::Tolerance(aE); - BOPTools_Tools3D::PointNearEdge (aE, theFace, aT, aDt2D, aPoint, aP3d); - // - if (theContext->IsPointInOnFace(theFace, aPoint)) { - bFoundInFacePoint = Standard_True; - - bFoundValidPoint = CheckPointInside(aSolidClassifier, aP3d, aTolerance, theContext, - aState, bFoundInFacePoint); - if (bFoundValidPoint) { - break; - } - } - } - } - - if(!bFoundInFacePoint) - return Standard_False; - - theState = aState; - - return Standard_True; -} - -//modified by NIZNHY-PKV Thu Sep 22 10:55:14 2011f -// =========================================================================================== -// function: CheckSameDomainFaceInside -// purpose: Check if distance between several points of theFace1 and -// theFace2 -// =========================================================================================== -Standard_Boolean BOPTools_Tools3D::CheckSameDomainFaceInside(const TopoDS_Face& theFace1, - const TopoDS_Face& theFace2, - const Handle(IntTools_Context)& theContext) -{ - Standard_Boolean bFoundON, bPointInFace; - Standard_Integer nbpoints, i, j; - Standard_Real umin, umax, vmin, vmax, aTol, adeltau, adeltav, U, V, U2, V2, aD, aTolE; - gp_Pnt2d aP2D; - gp_Pnt aP3D; - TopExp_Explorer aExp; - // - BRepTools::UVBounds(theFace1, umin, umax, vmin, vmax); - Handle(Geom_Surface) aS1=BRep_Tool::Surface(theFace1); - // - aTol=BRep_Tool::Tolerance(theFace1); - aExp.Init(theFace1, TopAbs_EDGE); - for(; aExp.More(); aExp.Next()) { - const TopoDS_Edge& aE = TopoDS::Edge(aExp.Current()); - aTolE = BRep_Tool::Tolerance(aE); - aTol=(aTol < aTolE) ? aTolE : aTol; - } - aTol=aTol+BRep_Tool::Tolerance(theFace2); - // - nbpoints=5; - adeltau=(umax - umin) / (nbpoints + 1); - adeltav=(vmax - vmin) / (nbpoints + 1); - bFoundON = Standard_False; - // - GeomAPI_ProjectPointOnSurf& aProjector = theContext->ProjPS(theFace2); - // - for(i=1; i<=nbpoints; ++i){ - U=umin+i*adeltau; - for(j=1; j<=nbpoints; ++j) { - V=vmin+j*adeltav; - aP2D.SetCoord(U,V); - bPointInFace=theContext->IsPointInFace(theFace1, aP2D); - if(bPointInFace) { - aP3D=aS1->Value(U, V); - aProjector.Perform(aP3D); - if(aProjector.IsDone()) { - aProjector.LowerDistanceParameters(U2, V2); - aP2D.SetCoord(U2, V2); - // - aD=aProjector.LowerDistance(); - if(aD > aTol) { - return Standard_False; - } - // - bPointInFace=theContext->IsPointInFace(theFace2, aP2D); - if (bPointInFace) { - bFoundON = Standard_True; - } - } - } - } - } - return bFoundON; -} -//modified by NIZNHY-PKV Thu Sep 22 10:55:19 2011t - -// =========================================================================================== -// function: CheckPointInside -// purpose: -// =========================================================================================== -Standard_Boolean CheckPointInside(BRepClass3d_SolidClassifier& aSolidClassifier, - const gp_Pnt& aP3d, - const Standard_Real aTolerance, - const Handle(IntTools_Context)& theContext, - TopAbs_State& aState, - Standard_Boolean& bFoundInFacePoint) -{ - Standard_Boolean bFoundValidPoint; - - bFoundValidPoint = Standard_False; - - aSolidClassifier.Perform(aP3d, aTolerance); - aState = aSolidClassifier.State(); - - if(aState != TopAbs_ON) { - - if(!aSolidClassifier.Rejected()) { - TopoDS_Face aFace2 = aSolidClassifier.Face(); - - if(!aFace2.IsNull()) { - GeomAPI_ProjectPointOnSurf& aProjector = theContext->ProjPS(aFace2); - aProjector.Perform(aP3d); - - if(aProjector.IsDone()) { - Standard_Real U2 = 0., V2 = 0.; - aProjector.LowerDistanceParameters(U2, V2); - gp_Pnt2d aPoint2(U2, V2); - - if(aProjector.LowerDistance() < aTolerance) { - if(theContext->IsPointInFace(aFace2, aPoint2)) { - aState = TopAbs_ON; - } - } - } - bFoundValidPoint = Standard_True; - } - } - else { - bFoundInFacePoint = Standard_False; - } - } - - return bFoundValidPoint; -} diff --git a/src/BOPTools/BOPTools_Tools3D_2.cxx b/src/BOPTools/BOPTools_Tools3D_2.cxx deleted file mode 100755 index 733bd31f64..0000000000 --- a/src/BOPTools/BOPTools_Tools3D_2.cxx +++ /dev/null @@ -1,363 +0,0 @@ -// Created on: 2004-06-10 -// Created by: Peter KURNEV -// Copyright (c) 2004-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static - Standard_Boolean AnalyticState(const TopoDS_Face& aF1, - const TopoDS_Face& aFx, - const gp_Pnt& aP, - const gp_Dir& aDNSx, - const Standard_Real aTolR, - TopAbs_State& aSt); - -static - gp_Pnt ProjectedPoint (const gp_Pnt&, - const gp_Ax1&); - -//======================================================================= -//function : TreatedAsAnalytic -//purpose : -//======================================================================= - Standard_Boolean BOPTools_Tools3D::TreatedAsAnalytic(const TopoDS_Face& aFx, - const TopoDS_Edge& aSpE1, - const TopoDS_Face& aF1, - const Standard_Real aTolTangent, - const Standard_Real aTolR, - TopAbs_State& aSt, - const Handle(IntTools_Context)& ) -{ - Standard_Boolean bFlag, bIsAnalytic, bIsDirsCoinside; - Standard_Real aT1, aTb, aTe; - gp_Dir aDNSx, aDNS1; - gp_Pnt aP1; - // - bFlag=Standard_False; - // - bIsAnalytic=BOPTools_Tools3D::HasAnalyticSurfaceType(aFx); - if (!bIsAnalytic) { - return bFlag; - } - bIsAnalytic=BOPTools_Tools3D::HasAnalyticSurfaceType(aF1); - if (!bIsAnalytic) { - return bFlag; - } - // - Handle(Geom_Curve)aC3D =BRep_Tool::Curve(aSpE1, aTb, aTe); - aT1=BOPTools_Tools2D::IntermediatePoint (aTb, aTe); - aC3D->D0(aT1, aP1); - // - BOPTools_Tools3D::GetNormalToFaceOnEdge(aSpE1, aF1, aT1, aDNS1); - BOPTools_Tools3D::GetNormalToFaceOnEdge(aSpE1, aFx, aT1, aDNSx); - // - bIsDirsCoinside=IntTools_Tools::IsDirsCoinside(aDNSx, aDNS1, aTolTangent); - if (!bIsDirsCoinside) { - return bFlag; - } - // - bFlag=AnalyticState(aF1, aFx, aP1, aDNSx, aTolR, aSt); - // - return bFlag; -} - -//======================================================================= -//function : TreatedAsAnalytic -//purpose : -//======================================================================= - Standard_Boolean BOPTools_Tools3D::TreatedAsAnalytic(const Standard_Real aTx, - const gp_Pnt& aPx, - const TopoDS_Edge& anEx, - const TopoDS_Face& aFx, - const TopoDS_Edge& anE1, - const TopoDS_Face& aF1, - const Standard_Real aTolTangent, - const Standard_Real aTolR, - TopAbs_State& aSt, - const Handle(IntTools_Context)& aContext) -{ - Standard_Boolean bFlag, bIsAnalytic, bIsDirsCoinside; - Standard_Real aT1; - gp_Dir aDNSx, aDNS1; - // - bFlag=Standard_False; - // - bIsAnalytic=BOPTools_Tools3D::HasAnalyticSurfaceType(aFx); - if (!bIsAnalytic) { - return bFlag; - } - bIsAnalytic=BOPTools_Tools3D::HasAnalyticSurfaceType(aF1); - if (!bIsAnalytic) { - return bFlag; - } - // - BOPTools_Tools3D::GetNormalToFaceOnEdge(anEx, aFx, aTx, aDNSx); - aContext->ProjectPointOnEdge(aPx, anE1, aT1); - BOPTools_Tools3D::GetNormalToFaceOnEdge(anE1, aF1, aT1, aDNS1); - // - bIsDirsCoinside=IntTools_Tools::IsDirsCoinside(aDNSx, aDNS1, aTolTangent); - if (!bIsDirsCoinside) { - return bFlag; - } - // - bFlag=AnalyticState(aF1, aFx, aPx, aDNSx, aTolR, aSt); - // - return bFlag; -} - -//======================================================================= -//function : AnalyticState -//purpose : -//======================================================================= -Standard_Boolean AnalyticState(const TopoDS_Face& aF1, - const TopoDS_Face& aFx, - const gp_Pnt& aP, - const gp_Dir& aDNSx, - const Standard_Real aTolR, - TopAbs_State& aSt) -{ - Standard_Boolean bFlag; - Standard_Real aScPr; - Handle(Geom_Surface) aSF1, aSFx; - GeomAbs_SurfaceType aTypeF1, aTypeFx; - TopAbs_Orientation anOrFx; - gp_Dir aDNFx; - gp_Pnt aPOnAxis; - // - bFlag=Standard_False; - aSt=TopAbs_OUT; - // - aSF1=BRep_Tool::Surface(aF1); - GeomAdaptor_Surface aGASF1(aSF1); - aTypeF1=aGASF1.GetType(); - // - aSFx=BRep_Tool::Surface(aFx); - GeomAdaptor_Surface aGASFx(aSFx); - aTypeFx=aGASFx.GetType(); - // - aDNFx=aDNSx; - anOrFx=aFx.Orientation(); - if (anOrFx==TopAbs_REVERSED){ - aDNFx.Reverse(); - } - // - // Plane/Cylinder - if (aTypeF1==GeomAbs_Plane && aTypeFx==GeomAbs_Cylinder) { - gp_Cylinder aCYx; - // - aCYx=aGASFx.Cylinder(); - aPOnAxis=ProjectedPoint(aP, aCYx.Axis()); - gp_Vec aVTC(aP, aPOnAxis); - gp_Dir aDTC(aVTC); - // - aScPr=aDNFx*aDTC; - if (aScPr>0.) { - aSt=TopAbs_IN; - } - bFlag=!bFlag; - // - } - // - // Cylinder/Plane - else if (aTypeF1==GeomAbs_Cylinder && aTypeFx==GeomAbs_Plane) { - gp_Cylinder aCY1; - // - aCY1=aGASF1.Cylinder(); - aPOnAxis=ProjectedPoint(aP, aCY1.Axis()); - gp_Vec aVTC(aP, aPOnAxis); - gp_Dir aDTC(aVTC); - // - aScPr=aDNFx*aDTC; - if (aScPr<0.) { - aSt=TopAbs_IN; - } - bFlag=!bFlag; - } // - // - // Plane/Cone - else if ( aTypeF1==GeomAbs_Plane && aTypeFx==GeomAbs_Cone) { - gp_Cone aCNx; - // - aCNx=aGASFx.Cone(); - aPOnAxis=ProjectedPoint(aP, aCNx.Axis()); - gp_Vec aVTC(aP, aPOnAxis); - gp_Dir aDTC(aVTC); - // - aScPr=aDNFx*aDTC; - if (aScPr>0.) { - aSt=TopAbs_IN; - } - bFlag=!bFlag; - } - // Cone/Plane - else if (aTypeF1==GeomAbs_Cone && aTypeFx==GeomAbs_Plane) { - gp_Cone aCN1; - // - aCN1=aGASF1.Cone(); - aPOnAxis=ProjectedPoint(aP, aCN1.Axis()); - gp_Vec aVTC(aP, aPOnAxis); - gp_Dir aDTC(aVTC); - // - aScPr=aDNFx*aDTC; - if (aScPr<0.) { - aSt=TopAbs_IN; - } - bFlag=!bFlag; - } // - // - // Cylinder(Cone)/Cylinder(Cone) - else if ((aTypeF1==GeomAbs_Cylinder || aTypeF1==GeomAbs_Cone) && - (aTypeFx==GeomAbs_Cylinder || aTypeFx==GeomAbs_Cone)) { - // - Standard_Real aPr, aR1, aRx, aSemiAngle, aDist; - gp_Pnt aPOnAxis1, aPOnAxisx; - gp_Cylinder aCY1, aCYx; - gp_Cone aCN1, aCNx; - gp_Ax1 anAx1, anAxx; - // - // surface 1 - if (aTypeF1==GeomAbs_Cylinder) { - aCY1=aGASF1.Cylinder(); - anAx1=aCY1.Axis(); - aR1=aCY1.Radius(); - aPOnAxis1=ProjectedPoint(aP, anAx1); - } - else { - aCN1=aGASF1.Cone(); - anAx1=aCN1.Axis(); - aSemiAngle=aCN1.SemiAngle(); - gp_Lin aLin(anAx1); - aDist=aLin.Distance(aP); - aR1=aDist/cos(aSemiAngle); - aPOnAxis1=ProjectedPoint(aP, anAx1); - } - // surface x - if (aTypeFx==GeomAbs_Cylinder) { - aCYx=aGASFx.Cylinder(); - anAxx=aCYx.Axis(); - aRx=aCYx.Radius(); - aPOnAxisx=ProjectedPoint(aP, anAxx); - } - else { - aCNx=aGASFx.Cone(); - anAxx=aCNx.Axis(); - aSemiAngle=aCNx.SemiAngle(); - gp_Lin aLin(anAxx); - aDist=aLin.Distance(aP); - aRx=aDist/cos(aSemiAngle); - aPOnAxisx=ProjectedPoint(aP, anAxx); - } - // - if (fabs(aRx-aR1) < aTolR) { - return bFlag; - } - // - gp_Vec aVTC1(aP, aPOnAxis1); - gp_Vec aVTCx(aP, aPOnAxisx); - gp_Dir aDTC1(aVTC1); - gp_Dir aDTCx(aVTCx); - // - aPr=aDTC1*aDTCx; - if (aPr < 0.) { - // opposite case - aScPr=aDNFx*aDTCx; - if (aScPr>0.) { - aSt=TopAbs_IN; - } - - } - else { - // one inside other - aScPr=aDNFx*aDTC1; - if (aRx0.) { - aSt=TopAbs_IN; - } - } - else { - if (aScPr<0.) { - aSt=TopAbs_IN; - } - } - } - bFlag=!bFlag; - // - } - // - return bFlag; -} - -//======================================================================= -//function : HasAnalyticSurfaceType -//purpose : -//======================================================================= - Standard_Boolean BOPTools_Tools3D::HasAnalyticSurfaceType(const TopoDS_Face& aF) -{ - Standard_Boolean bFlag=Standard_False; - GeomAbs_SurfaceType aType; - // - Handle(Geom_Surface) aS; - // - aS=BRep_Tool::Surface(aF); - GeomAdaptor_Surface aGAS(aS); - aType=aGAS.GetType(); - - // - bFlag= (aType==GeomAbs_Plane || - aType==GeomAbs_Cylinder || - aType==GeomAbs_Cone || - aType==GeomAbs_Sphere); - // - return bFlag; -} - -//======================================================================= -//function :ProjectedPoint -//purpose : -//======================================================================= - gp_Pnt ProjectedPoint (const gp_Pnt& aP, - const gp_Ax1& anAx1) -{ - Standard_Real aDist; - // - gp_Vec aVDirection(anAx1.Direction()); - gp_Pnt anOrigin=anAx1.Location(); - gp_Vec aV(anOrigin, aP); - aDist = aVDirection.Dot(aV); - // - gp_Pnt aPx= anOrigin.Translated(aDist*aVDirection); - return aPx; -} diff --git a/src/BOPTools/BOPTools_VEInterference.cdl b/src/BOPTools/BOPTools_VEInterference.cdl deleted file mode 100755 index 7ab1850269..0000000000 --- a/src/BOPTools/BOPTools_VEInterference.cdl +++ /dev/null @@ -1,57 +0,0 @@ --- Created on: 2000-11-21 --- Created by: Peter KURNEV --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class VEInterference from BOPTools - inherits ShapeShapeInterference from BOPTools - - ---Purpose: - -- class for storing info about an Verex/Edge interference - --- - -is - Create - returns VEInterference from BOPTools; - ---Purpose: - --- Empty constructor - --- - Create (anIndex1, anIndex2: Integer from Standard; - aT: Real from Standard) - returns VEInterference from BOPTools; - ---Purpose: - --- Constructor - --- anIndex1, - --- anIndex2 see BOPTools_ShapeShapeInterference for details - --- aT - values of parameter on the edge - --- - SetParameter (me:out; aT: Real from Standard); - ---Purpose: - --- Modifier - --- - Parameter (me) - returns Real from Standard; - ---Purpose: - --- Selector - --- - -fields - myParameter: Real from Standard; - -end VEInterference; diff --git a/src/BOPTools/BOPTools_VEInterference.cxx b/src/BOPTools/BOPTools_VEInterference.cxx deleted file mode 100755 index 8f647fe500..0000000000 --- a/src/BOPTools/BOPTools_VEInterference.cxx +++ /dev/null @@ -1,61 +0,0 @@ -// Created on: 2000-11-21 -// Created by: Peter KURNEV -// Copyright (c) 2000-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include - -//======================================================================= -//function : BOPTools_VEInterference -//purpose : -//======================================================================= -BOPTools_VEInterference::BOPTools_VEInterference() -: - BOPTools_ShapeShapeInterference(0,0) -{} - -//======================================================================= -//function : BOPTools_ESInterference -//purpose : -//======================================================================= - BOPTools_VEInterference::BOPTools_VEInterference - (const Standard_Integer anIndex1, - const Standard_Integer anIndex2, - const Standard_Real aT) -: - BOPTools_ShapeShapeInterference(anIndex1,anIndex2), - myParameter(aT) -{} - -//======================================================================= -//function : SetParameter -//purpose : -//======================================================================= - void BOPTools_VEInterference::SetParameter (const Standard_Real aT) -{ - myParameter=aT; -} -//======================================================================= -//function : Parameter -//purpose : -//======================================================================= - Standard_Real BOPTools_VEInterference::Parameter ()const -{ - return myParameter; -} diff --git a/src/BOPTools/BOPTools_VSInterference.cdl b/src/BOPTools/BOPTools_VSInterference.cdl deleted file mode 100755 index 0251ce7b82..0000000000 --- a/src/BOPTools/BOPTools_VSInterference.cdl +++ /dev/null @@ -1,58 +0,0 @@ --- Created on: 2000-11-21 --- Created by: Peter KURNEV --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class VSInterference from BOPTools - inherits ShapeShapeInterference from BOPTools - - ---Purpose: - -- Class for storing info about an Verex/Face interference - --- -is - Create - returns VSInterference from BOPTools; - ---Purpose: - --- Empty constructor - --- - Create (anIndex1: Integer from Standard; - anIndex2: Integer from Standard; - U: Real from Standard; - V: Real from Standard) - returns VSInterference from BOPTools; - ---Purpose: - --- Constructor - --- anIndex1, - --- anIndex2 see BOPTools_ShapeShapeInterference for details - --- U, V - values of parameters on the surface - --- - SetUV (me:out; U, V: Real from Standard); - ---Purpose: - --- Modifier - --- - UV (me; U:out Real from Standard; - V:out Real from Standard); - ---Purpose: - --- Selector - --- -fields - myU:Real from Standard; - myV:Real from Standard; - -end VSInterference; diff --git a/src/BOPTools/BOPTools_VSInterference.cxx b/src/BOPTools/BOPTools_VSInterference.cxx deleted file mode 100755 index a8122e68d9..0000000000 --- a/src/BOPTools/BOPTools_VSInterference.cxx +++ /dev/null @@ -1,66 +0,0 @@ -// Created on: 2000-11-21 -// Created by: Peter KURNEV -// Copyright (c) 2000-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include - -//======================================================================= -//function : BOPTools_VSInterference -//purpose : -//======================================================================= -BOPTools_VSInterference::BOPTools_VSInterference() -: - BOPTools_ShapeShapeInterference(0,0) -{} - -//======================================================================= -//function : BOPTools_VSInterference -//purpose : -//======================================================================= - BOPTools_VSInterference::BOPTools_VSInterference - (const Standard_Integer anIndex1, - const Standard_Integer anIndex2, - const Standard_Real U, - const Standard_Real V) -: - BOPTools_ShapeShapeInterference(anIndex1,anIndex2), - myU(U), - myV(V) -{} - -//======================================================================= -//function : SetUV -//purpose : -//======================================================================= - void BOPTools_VSInterference::SetUV (const Standard_Real U, - const Standard_Real V) -{ - myU=U; - myV=V; -} -//======================================================================= -//function : UV -//purpose : -//======================================================================= - void BOPTools_VSInterference::UV (Standard_Real& U, Standard_Real& V) const -{ - U=myU; - V=myV; -} diff --git a/src/BOPTools/BOPTools_VVInterference.cdl b/src/BOPTools/BOPTools_VVInterference.cdl deleted file mode 100755 index 9311db3f2c..0000000000 --- a/src/BOPTools/BOPTools_VVInterference.cdl +++ /dev/null @@ -1,42 +0,0 @@ --- Created on: 2000-11-21 --- Created by: Peter KURNEV --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class VVInterference from BOPTools - inherits ShapeShapeInterference from BOPTools - - ---Purpose: class for storing an Verex/Vertex - --- interference -is - - Create - returns VVInterference from BOPTools; - ---Purpose: - --- Empty constructor - --- - Create (anIndex1, anIndex2: Integer from Standard) - returns VVInterference from BOPTools; - ---Purpose: - --- Constructor - --- anIndex1, - --- anIndex2 see BOPTools_ShapeShapeInterference for details - --- - -end VVInterference; diff --git a/src/BOPTools/BOPTools_VVInterference.cxx b/src/BOPTools/BOPTools_VVInterference.cxx deleted file mode 100755 index 200b5f2d5e..0000000000 --- a/src/BOPTools/BOPTools_VVInterference.cxx +++ /dev/null @@ -1,41 +0,0 @@ -// Created on: 2000-11-21 -// Created by: Peter KURNEV -// Copyright (c) 2000-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include -//======================================================================= -//function : BOPTools_VVInterference -//purpose : -//======================================================================= -BOPTools_VVInterference::BOPTools_VVInterference() -: - BOPTools_ShapeShapeInterference(0,0) -{} - -//======================================================================= -//function : BOPTools_VVInterference -//purpose : -//======================================================================= - BOPTools_VVInterference::BOPTools_VVInterference - (const Standard_Integer anIndex1, - const Standard_Integer anIndex2) -: - BOPTools_ShapeShapeInterference(anIndex1,anIndex2) -{} diff --git a/src/BOPTools/BOPTools_WireStateFiller.cdl b/src/BOPTools/BOPTools_WireStateFiller.cdl deleted file mode 100755 index 24b0a0c779..0000000000 --- a/src/BOPTools/BOPTools_WireStateFiller.cdl +++ /dev/null @@ -1,60 +0,0 @@ --- Created on: 2002-02-04 --- Created by: Peter KURNEV --- Copyright (c) 2002-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class WireStateFiller from BOPTools inherits StateFiller from BOPTools - - ---Purpose: - -- class to compute states (3D) for the edges (and theirs - --- split parts), vertices, wires - --- - -uses - PaveFiller from BOPTools - ---raises - -is - Create (aFiller: PaveFiller from BOPTools) - returns WireStateFiller from BOPTools; - ---Purpose: - --- Constructor - --- - Do(me:out) - is redefined; - ---Purpose: - --- Launch the Filler - --- - DoWires (me:out; - iRank: Integer from Standard) - is private; - ---Purpose: - --- Internal usage - --- - DoWireSolid (me:out; - iRank: Integer from Standard) - is private; - ---Purpose: - --- Internal usage - --- - ---fields - -end WireStateFiller; diff --git a/src/BOPTools/BOPTools_WireStateFiller.cxx b/src/BOPTools/BOPTools_WireStateFiller.cxx deleted file mode 100755 index 8bfbf6d01c..0000000000 --- a/src/BOPTools/BOPTools_WireStateFiller.cxx +++ /dev/null @@ -1,484 +0,0 @@ -// Created on: 2002-02-04 -// Created by: Peter KURNEV -// Copyright (c) 2002-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include - -#include -#include - -#include -#include - -#include - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -//======================================================================= -// function: BOPTools_WireStateFiller::BOPTools_WireStateFiller -// purpose: -//======================================================================= -BOPTools_WireStateFiller::BOPTools_WireStateFiller(const BOPTools_PaveFiller& aFiller) -: - BOPTools_StateFiller(aFiller) -{ -} - -//======================================================================= -// function: Do -// purpose: -//======================================================================= - void BOPTools_WireStateFiller::Do() -{ - TopAbs_ShapeEnum aT1, aT2; - - aT1=(myDS->Object()).ShapeType(); - aT2=(myDS->Tool()).ShapeType(); - - myIsDone=Standard_True; - - if (aT1==TopAbs_WIRE && aT2==TopAbs_WIRE){ - DoWires(1); - DoWires(2); - } - else if (aT1==TopAbs_WIRE && aT2==TopAbs_SHELL){ - DoWires(1); - } - else if (aT2==TopAbs_WIRE && aT1==TopAbs_SHELL){ - DoWires(2); - } - else if (aT1==TopAbs_WIRE && aT2==TopAbs_SOLID){ - DoWireSolid(1); - } - else if (aT2==TopAbs_WIRE && aT1==TopAbs_SOLID){ - DoWireSolid(2); - } - else { - myIsDone=!myIsDone; - } - -} - -//======================================================================= -// function: DoWires -// purpose: -//======================================================================= - void BOPTools_WireStateFiller::DoWires (const Standard_Integer iRankObj) -{ - const TopoDS_Shape& anObj=(iRankObj==1) ? myDS->Object() : myDS->Tool(); - // - const BooleanOperations_IndexedDataMapOfShapeInteger& aDSMap=myDS->ShapeIndexMap(iRankObj); - const BOPTools_SplitShapesPool& aSplitShapesPool=myFiller->SplitShapesPool(); - const BOPTools_CommonBlockPool& aCommonBlockPool=myFiller->CommonBlockPool(); - // - Standard_Integer i, aNbPaveBlocks, nSp, aNbE, nE; - BooleanOperations_StateOfShape aSt; - BOPTools_ListIteratorOfListOfPaveBlock anItPB; - BOPTools_ListIteratorOfListOfCommonBlock anItCB; - TopTools_IndexedMapOfShape aEM; - // - TopExp::MapShapes(anObj, TopAbs_EDGE, aEM); - aNbE=aEM.Extent(); - // - // 1 - for (i=1; i<=aNbE; i++) { - const TopoDS_Edge& aE=TopoDS::Edge(aEM(i)); - nE=aDSMap.FindFromKey(aE); - // - if (BRep_Tool::Degenerated(aE)){ - continue; - } - // - const BOPTools_ListOfCommonBlock& aLCB=aCommonBlockPool(myDS->RefEdge(nE)); - // - anItCB.Initialize(aLCB); - for (; anItCB.More(); anItCB.Next()) { - BOPTools_CommonBlock& aCB=anItCB.Value(); - BOPTools_PaveBlock& aPB=aCB.PaveBlock1(nE); - nSp=aPB.Edge(); - myDS->SetState(nSp, BooleanOperations_ON); - } - } - // - // 2 - for (i=1; i<=aNbE; i++) { - const TopoDS_Edge& aE=TopoDS::Edge(aEM(i)); - nE=aDSMap.FindFromKey(aE); - // - if (BRep_Tool::Degenerated(aE)){ - continue; - } - // - const BOPTools_ListOfPaveBlock& aLPB=aSplitShapesPool(myDS->RefEdge(nE)); - // - aNbPaveBlocks=aLPB.Extent(); - - if (!aNbPaveBlocks) { - myDS->SetState(nE, BooleanOperations_OUT); - continue; - } - // - anItPB.Initialize(aLPB); - for (; anItPB.More(); anItPB.Next()) { - const BOPTools_PaveBlock& aPB=anItPB.Value(); - nSp=aPB.Edge(); - aSt=myDS-> GetState(nSp); - if (aSt!=BooleanOperations_ON) { - myDS->SetState(nSp, BooleanOperations_OUT); - } - } - } -} -//======================================================================= - -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static - void PropagateState(const TopoDS_Shape& aS, - const BooleanOperations_StateOfShape aState, - BooleanOperations_ShapesDataStructure* pDS, - const Standard_Integer iRank, - BOPTools_IndexedDataMapOfShapeWithState& aSWS, - TopTools_IndexedMapOfShape& aProcessedShapes); - -static - Standard_Boolean HasConnexity(const TopoDS_Shape& aS, - const BOPTools_IndexedDataMapOfShapeWithState& aSWS, - const TopTools_IndexedDataMapOfShapeListOfShape& aMVE, - BooleanOperations_StateOfShape& aState); - -//======================================================================= -// function: DoWireSolid -// purpose: -//======================================================================= - void BOPTools_WireStateFiller::DoWireSolid (const Standard_Integer iRankObj) -{ - const TopoDS_Shape& anObj=(iRankObj==1) ? myDS->Object() : myDS->Tool(); - const TopoDS_Shape& aTool=(iRankObj==1) ? myDS->Tool() : myDS->Object(); - // - const BooleanOperations_IndexedDataMapOfShapeInteger& aDSMap=myDS->ShapeIndexMap(iRankObj); - const BOPTools_SplitShapesPool& aSplitShapesPool=myFiller->SplitShapesPool(); - const BOPTools_CommonBlockPool& aCommonBlockPool=myFiller->CommonBlockPool(); - // - Standard_Integer i, aNb, nE, aNbPB; - BooleanOperations_StateOfShape aState; - TopTools_IndexedMapOfShape aEM, anIntersectedShapes, aNonIntersectedShapes; - TopTools_IndexedDataMapOfShapeListOfShape aM, aMVE; - - // - // aM Map - TopExp::MapShapesAndAncestors (anObj, TopAbs_EDGE , TopAbs_WIRE , aM); - // VE Map - TopExp::MapShapesAndAncestors (anObj, TopAbs_VERTEX, TopAbs_EDGE, aMVE); - // - // 1.2. Edges that have Split parts - TopExp::MapShapes(anObj, TopAbs_EDGE, aEM); - aNb=aEM.Extent(); - for (i=1; i<=aNb; i++) { - const TopoDS_Shape& aE=aEM(i); - nE=aDSMap.FindFromKey(aE); - const BOPTools_ListOfPaveBlock& aLPB=aSplitShapesPool(myDS->RefEdge(nE)); - aNbPB=aLPB.Extent(); - // - if (!aNbPB) { - continue; - } - // - if (aNbPB==1) { - const BOPTools_ListOfCommonBlock& aLCB=aCommonBlockPool(myDS->RefEdge(nE)); - if (!aLCB.Extent()) { - const BOPTools_PaveBlock& aPB=aLPB.First(); - Standard_Integer nEB=aPB.Edge(); - if (nEB==aPB.OriginalEdge()) { - Standard_Boolean bHasInterference=Standard_False;// Wng in Gcc 3.0 - Standard_Integer j, aNbSuc, nV; - aNbSuc=myDS->NumberOfSuccessors(nEB); - for (j=1; j<=aNbSuc; j++) { - nV=myDS->GetSuccessor(nE, j); - bHasInterference=myIntrPool->HasInterference(nV); - if (bHasInterference) { - break; - } - } - if (!bHasInterference) { - continue; - } - } - } - } - anIntersectedShapes.Add(aE); - }// for (i=1; i<=aNb; i++) - // - // 1.3. Write Intersected state for anIntersectedShapes to the DS - aNb=anIntersectedShapes.Extent(); - for (i=1; i<=aNb; i++) { - const TopoDS_Shape& aS=anIntersectedShapes(i); - nE=aDSMap.FindFromKey(aS); - myDS->SetState(nE, BooleanOperations_INTERSECTED); - } - // - // 2. aNonIntersectedShapes - // - aNb=aM.Extent(); - for (i=1; i<=aNb; i++) { - const TopoDS_Shape& aS=aM.FindKey(i); - if (!anIntersectedShapes.Contains(aS)) { - aNonIntersectedShapes.Add(aS); - } - } - // - // 2.1. Processing of Non-intersected shapes - BRep_Builder BB; - TopoDS_Compound aCompound; - BB.MakeCompound(aCompound); - aNb=aNonIntersectedShapes.Extent(); - for (i=1; i<=aNb; i++) { - const TopoDS_Shape& aS=aNonIntersectedShapes(i); - BB.Add(aCompound, aS); - } - // - TopTools_IndexedMapOfShape aProcessedShapes; - BOPTools_IndexedDataMapOfShapeWithState aSWS; - Standard_Boolean bHasConnexity; - // - aEM.Clear(); - TopExp::MapShapes(aCompound, TopAbs_EDGE, aEM); - aNb=aEM.Extent(); - for (i=1; i<=aNb; i++) { - const TopoDS_Shape& aS=aEM(i); - if (!aProcessedShapes.Contains(aS)) { - bHasConnexity=HasConnexity(aS, aSWS, aMVE, aState); - if (!bHasConnexity) { - aState=BOPTools_StateFiller::ClassifyShapeByRef (aS, aTool); - } - aSWS.Add(aS, aState); - aProcessedShapes.Add(aS); - PropagateState(aS, aState, myDS, iRankObj, aSWS, aProcessedShapes); - } - } - // - // 2.2. Write Stats for Non-intersected Shapes to the DS - aNb=aSWS.Extent(); - for (i=1; i<=aNb; i++) { - const TopoDS_Shape& aS=aSWS.FindKey(i); - aState=aSWS.FindFromIndex(i); - nE=aDSMap.FindFromKey(aS); - myDS->SetState(nE, aState); - } - //--------------------------------------------------- - // - // 3. Intersected Edges' Processing - // - //--------------------------------------------------- - Standard_Integer nSp, aNBVertices, nV1, nV2; - BooleanOperations_StateOfShape aStV1, aStV2; - - aNb=anIntersectedShapes.Extent(); - for (i=1; i<=aNb; i++) { - const TopoDS_Shape& aS=anIntersectedShapes(i); - if (aS.ShapeType()==TopAbs_EDGE) { - nE=aDSMap.FindFromKey(aS); - // - // 3.1. On Parts Processing - const BOPTools_ListOfCommonBlock& aLCB=aCommonBlockPool(myDS->RefEdge(nE)); - BOPTools_ListIteratorOfListOfCommonBlock anItCB(aLCB); - for (; anItCB.More(); anItCB.Next()) { - const BOPTools_CommonBlock& aCB=anItCB.Value(); - BOPTools_CommonBlock* pCB=(BOPTools_CommonBlock*) &aCB; - BOPTools_PaveBlock& aPB=pCB->PaveBlock1(nE); - nSp=aPB.Edge(); - myDS->SetState(nSp, BooleanOperations_ON); - } - // - // 3.2. IN, OUT Parts Processing - const BOPTools_ListOfPaveBlock& aSplits=aSplitShapesPool(myDS->RefEdge(nE)); - BOPTools_ListIteratorOfListOfPaveBlock anItPB(aSplits); - for (; anItPB.More(); anItPB.Next()) { - const BOPTools_PaveBlock& aPB=anItPB.Value(); - nSp=aPB.Edge(); - const TopoDS_Shape& aSplit=myDS->Shape(nSp); - - aState=myDS->GetState(nSp); - if (aState==BooleanOperations_UNKNOWN|| aState==BooleanOperations_INTERSECTED){ - aNBVertices=myDS->NumberOfSuccessors(nE); - if (aNBVertices==2) { - nV1=myDS->GetSuccessor(nSp, 1); - aStV1=myDS->GetState(nV1); - nV2=myDS->GetSuccessor(nSp, 2); - aStV2=myDS->GetState(nV2); - if ((aStV1==BooleanOperations_IN || aStV1==BooleanOperations_OUT) - && (aStV2==BooleanOperations_ON)) { - myDS->SetState(nSp, aStV1); - } - else if ((aStV2==BooleanOperations_IN || aStV2==BooleanOperations_OUT) - && (aStV1==BooleanOperations_ON)) { - myDS->SetState(nSp, aStV2); - } - else { - aState=BOPTools_StateFiller::ClassifyShapeByRef(aSplit, aTool); - myDS->SetState(nSp, aState); - if (aStV1==BooleanOperations_UNKNOWN) { - myDS->SetState(nV1, aState); - } - if (aStV2==BooleanOperations_UNKNOWN) { - myDS->SetState(nV2, aState); - } - } - }// if (aNBVertices==2) - else { - aState=BOPTools_StateFiller::ClassifyShapeByRef(aSplit, aTool); - myDS->SetState(nSp, aState); - } - }// if (aState==BooleanOperations_UNKNOWN || BooleanOperations_INTERSECTED) - }//for (; anItPB.More(); anItPB.Next()) - }// if (aS.ShapeType()==TopAbs_EDGE) - }// next "Intersected" Edge - -} - -//======================================================================= -// function: HasConnexity -// purpose: -//======================================================================= - Standard_Boolean HasConnexity(const TopoDS_Shape& aS, - const BOPTools_IndexedDataMapOfShapeWithState& aSWS, - const TopTools_IndexedDataMapOfShapeListOfShape& aMVE, - BooleanOperations_StateOfShape& aState) -{ - TopAbs_ShapeEnum aType; - BooleanOperations_StateOfShape aSt; - aType=aS.ShapeType(); - if (aType!=TopAbs_EDGE) { - Standard_Integer i, aNb; - TopTools_IndexedMapOfShape aME; - TopExp::MapShapes(aS, TopAbs_EDGE, aME); - aNb=aME.Extent(); - for (i=1; i<=aNb; i++) { - const TopoDS_Shape& aE=aME(i); - if (aSWS.Contains(aE)){ - aSt=aSWS.FindFromKey(aE); - aState=aSt; - return Standard_True; - } - } - } - else { - TopExp_Explorer anExp (aS, TopAbs_VERTEX); - for (; anExp.More(); anExp.Next()) { - const TopoDS_Shape& aV=anExp.Current(); - if (aMVE.Contains(aV)) { - const TopTools_ListOfShape& anEdgesList=aMVE.FindFromKey(aV); - TopTools_ListIteratorOfListOfShape anIt(anEdgesList); - for (; anIt.More(); anIt.Next()) { - const TopoDS_Shape& aEx=anIt.Value(); - if (aSWS.Contains(aEx)) { - aSt=aSWS.FindFromKey(aEx); - aState=aSt; - return Standard_True; - } - } - } - } - } - - aState=BooleanOperations_UNKNOWN; - return Standard_False; -} - -//======================================================================= -// function: PropagateState -// purpose: -//======================================================================= -void PropagateState(const TopoDS_Shape& aSS, - const BooleanOperations_StateOfShape aState, - BooleanOperations_ShapesDataStructure* pDS, - const Standard_Integer iRank, - BOPTools_IndexedDataMapOfShapeWithState& aSWS, - TopTools_IndexedMapOfShape& aProcessedShapes) -{ - TopAbs_ShapeEnum aSubType; - - aSubType=BOPTools_StateFiller::SubType(aSS); - - if (aSubType==TopAbs_SHAPE) { - return; - } - - const BooleanOperations_IndexedDataMapOfShapeInteger& aDSMap= pDS->ShapeIndexMap(iRank); - - TopTools_IndexedMapOfShape aSubMap; - TopExp::MapShapes(aSS, aSubType, aSubMap); - - Standard_Integer i, aNb, nV; - aNb=aSubMap.Extent(); - for (i=1; i<=aNb; i++) { - const TopoDS_Shape& aS=aSubMap(i); - if (!aProcessedShapes.Contains(aS)) { - if (aSubType==TopAbs_VERTEX) { - nV=aDSMap.FindFromKey(aS); - BooleanOperations_StateOfShape aSt=pDS->GetState(nV); - if (aSt!=BooleanOperations_UNKNOWN){ - aProcessedShapes.Add(aS); - continue; - } - } - aSWS.Add(aS, aState); - aProcessedShapes.Add(aS); - PropagateState (aS, aState, pDS, iRank, aSWS, aProcessedShapes); - } - } -} diff --git a/src/BOPTools/FILES b/src/BOPTools/FILES index 885786e5f4..29abf1699a 100755 --- a/src/BOPTools/FILES +++ b/src/BOPTools/FILES @@ -1,6 +1,12 @@ -BOPTools_Tools3D_1.cxx -BOPTools_Tools3D_2.cxx -BOPTools_PaveFiller_1.cxx -BOPTools_PaveFiller_2.cxx -BOPTools_PaveFiller_3.cxx -BOPTools_PaveFiller_4.cxx +BOPTools_AlgoTools_1.cxx +BOPTools_AlgoTools_2.cxx +BOPTools_AlgoTools2D.cxx +BOPTools_AlgoTools3D.cxx +BOPTools_ConnexityBlock.hxx +BOPTools_ListOfConnexityBlock.hxx +BOPTools_ListOfShapeSet.hxx +BOPTools_CoupleOfShape.hxx +BOPTools_ListOfCoupleOfShape.hxx +BOPTools_ListOfEdgeSet.hxx +BOPTools_MapOfSet.hxx +BOPTools_DataMapOfShapeSet.hxx diff --git a/src/BRepAlgo/BRepAlgo.cdl b/src/BRepAlgo/BRepAlgo.cdl index f0870c526e..fe8fb19b5d 100755 --- a/src/BRepAlgo/BRepAlgo.cdl +++ b/src/BRepAlgo/BRepAlgo.cdl @@ -19,17 +19,17 @@ -- and conditions governing the rights and limitations under the License. -- Modified David CARBONEL --- Add of Sewing class +-- Add of Sewing class package BRepAlgo ---Purpose: - -- The BRepAlgo package provides a full range of - -- services to perform Old Boolean Operations in Open CASCADE. - -- Attention: - -- The New Boolean Operation has replaced the Old - -- Boolean Operations algorithm in the BrepAlgoAPI - -- package in Open CASCADE. + -- The BRepAlgo package provides a full range of + -- services to perform Old Boolean Operations in Open CASCADE. + -- Attention: + -- The New Boolean Operation has replaced the Old + -- Boolean Operations algorithm in the BrepAlgoAPI + -- package in Open CASCADE. uses BRep, @@ -58,10 +58,7 @@ uses TopOpeBRepBuild, TopOpeBRep, Adaptor3d, - StdFail, - BOP, - BOPTools, - BooleanOperations + StdFail is enumeration CheckStatus is @@ -93,12 +90,10 @@ is ---Purpose: class DSAccess; ---Purpose: - class TopOpe; - ---Purpose: class EdgeConnector; ---Purpose: class NormalProjection; - ---Purpose: + ---Purpose: -- class Sewing; now it is in BRepBuilderAPI class DataMapOfShapeBoolean instantiates @@ -126,34 +121,34 @@ is --BRepAlgoAPI f IsValid(S: Shape from TopoDS) - returns Boolean from Standard - raises NullObject from Standard; - ---Purpose: Checks if the shape is "correct". If not, returns - -- , else returns . - + returns Boolean from Standard + raises NullObject from Standard; + ---Purpose: Checks if the shape is "correct". If not, returns + -- , else returns . + IsValid(theArgs : ListOfShape from TopTools; - theResult : Shape from TopoDS; - closedSolid : Boolean from Standard = Standard_False; - GeomCtrl : Boolean from Standard = Standard_True) - returns Boolean from Standard; - ---Purpose: Checks if the Generated and Modified Faces from - -- the shapes in the shape are - -- "correct". The args may be empty, then all faces - -- will be checked. - -- If is True, only closed shape are valid. - -- If is False the geometry of new - -- vertices and edges are not verified and the - -- auto-intersection of new wires are not searched. - - + theResult : Shape from TopoDS; + closedSolid : Boolean from Standard = Standard_False; + GeomCtrl : Boolean from Standard = Standard_True) + returns Boolean from Standard; + ---Purpose: Checks if the Generated and Modified Faces from + -- the shapes in the shape are + -- "correct". The args may be empty, then all faces + -- will be checked. + -- If is True, only closed shape are valid. + -- If is False the geometry of new + -- vertices and edges are not verified and the + -- auto-intersection of new wires are not searched. + + IsTopologicallyValid(S: Shape from TopoDS) - returns Boolean from Standard - raises NullObject from Standard; - ---Purpose: Checks if the shape is "correct". If not, returns - -- , else returns . - -- This method differs from the previous one in the - -- fact that no geometric contols (intersection of - -- wires, pcurve validity) are performed. + returns Boolean from Standard + raises NullObject from Standard; + ---Purpose: Checks if the shape is "correct". If not, returns + -- , else returns . + -- This method differs from the previous one in the + -- fact that no geometric contols (intersection of + -- wires, pcurve validity) are performed. --BRepAlgoAPI t diff --git a/src/BRepAlgo/BRepAlgo_TopOpe.cdl b/src/BRepAlgo/BRepAlgo_TopOpe.cdl deleted file mode 100755 index ab6ec762ec..0000000000 --- a/src/BRepAlgo/BRepAlgo_TopOpe.cdl +++ /dev/null @@ -1,158 +0,0 @@ --- Created on: 1997-08-13 --- Created by: Prestataire Mary FABIEN --- Copyright (c) 1997-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class TopOpe from BRepAlgo - - ---Purpose: - -uses - - Wire from TopoDS, - Shape from TopoDS, - ListOfInteger from TColStd, - SetOfInteger from TColStd, - MapOfInteger from TColStd, - ListOfShape from TopTools, - State from TopAbs, - EdgeConnector from BRepAlgo, - DataMapOfShapeShape from TopTools, - - PDSFiller from BOPTools, - PBuilder from BOP, - HistoryCollector from BOP - -is - - Create returns TopOpe from BRepAlgo; - - Init(me: in out); - ---Purpose: Clean the internal data structure, including the - -- Shapes of Load(). - - --- Remplissage de la SD - - Load(me : in out; S : Shape from TopoDS); - ---Purpose: Load the shape in the DS. - -- - - Load(me : in out; S1, S2 : in out Shape from TopoDS); - ---Purpose: Load the shapes in the DS without intersecting them. - - Intersect(me : in out); - ---Purpose: Intersect two shapes at input and load the DS with - -- their intersection. Clear TopOpeBRepBuild_HBuilder if - -- necessary - - Intersect(me : in out; S1, S2 : Shape from TopoDS); - ---Purpose: Intersect faces contained in two given shapes - -- load the DS with them. Clear TopOpeBRepBuild_HBuilder - -- if necessary - - ToCompleteIntersection(me : in out); - --- Construction of Sections - --- GetSectionEdgeSet(me : in out; S1,S2 : Shape from TopoDS) --- ---Purpose: return the compounds of Edge connected with section - -- that contain the sections between faces contained in - -- S1 and S2. - -- return an empty list of Shape if S1 or S2 do not - -- contain faces. - -- call GetSectionEdgeSet() if it is not done already --- ---C++: return const & --- returns ListOfShape from TopTools; - - GetSectionEdgeSet(me : in out) - ---Purpose: return all compounds of connected edges - -- of section contained in the DS - ---C++: return const & - returns ListOfShape from TopTools; - - - SuppressEdgeSet(me : in out); - ---Purpose: Invalidate a line of complete section. - -- A group of Edges connected by Vertexes. Can be a Wire. - -- Can be a group of connected Edges that do not form a - -- standard Wire. - - --- Reconstruction des Shapes - - Merge(me : in out; state1 : State from TopAbs; - state2 : State from TopAbs) - ---C++: return const & - returns Shape from TopoDS; - - Merge(me : in out; state1 : State from TopAbs) - ---C++: return const & - returns Shape from TopoDS; - - PaveBlocksNotEmpty(me : in out) - returns Boolean from Standard; - --- Access to fields - - Builder(me) - ---C++: return const & - returns PBuilder from BOP; - - DSFiller(me) - ---C++: return const & - returns PDSFiller from BOPTools; - - History(me) - ---C++: return const & - returns HistoryCollector from BOP; - - - Destroy (me: in out); - ---C++: alias "Standard_EXPORT virtual ~BRepAlgo_TopOpe(){Destroy();}" - -fields - - myDSFiller : PDSFiller from BOPTools; - myBuilder : PBuilder from BOP; - myHistory : HistoryCollector from BOP; - - myEC : EdgeConnector from BRepAlgo; - myS1 : Shape from TopoDS; - myS2 : Shape from TopoDS; - myState1,myState2 : State from TopAbs; - - myListOfCompoundOfEdgeConnected : ListOfShape from TopTools; - myCurrentList : ListOfShape from TopTools; - myRecomputeBuilderIsDone : Boolean from Standard; - myGetSectionIsDone : Boolean from Standard; - myResultShape : Shape from TopoDS; - - myWire : Wire from TopoDS; - myListOfVertex : ListOfShape from TopTools; - myModified : ListOfShape from TopTools; - myEmptyShape : Shape from TopoDS; - myEmptyListOfShape : ListOfShape from TopTools; - myEmptyListOfInteger : ListOfInteger from TColStd; - - myCompoundWireMap : DataMapOfShapeShape from TopTools; - mySetOfKeepPoint : SetOfInteger from TColStd; - - -end TopOpe from BRepAlgo; diff --git a/src/BRepAlgo/BRepAlgo_TopOpe.cxx b/src/BRepAlgo/BRepAlgo_TopOpe.cxx deleted file mode 100755 index 08a8c0b4c9..0000000000 --- a/src/BRepAlgo/BRepAlgo_TopOpe.cxx +++ /dev/null @@ -1,492 +0,0 @@ -// Created on: 2004-03-02 -// Created by: Igor FEOKTISTOV -// Copyright (c) 2004-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef DRAW -//#include -#endif - -//======================================================================= -//function : Create -//purpose : -//======================================================================= - -BRepAlgo_TopOpe::BRepAlgo_TopOpe() : - myDSFiller(NULL), myBuilder(NULL) -{ - Init(); -} - -//======================================================================= -//function : Init -//purpose : -//======================================================================= - -void BRepAlgo_TopOpe::Init() -{ - if (myBuilder != NULL) { - delete myBuilder; - } - if (myDSFiller != NULL) { - delete myDSFiller; - } - - myDSFiller = NULL; - myBuilder = NULL; - - myDSFiller = new BOPTools_DSFiller; - - - myRecomputeBuilderIsDone = Standard_False; - myGetSectionIsDone = Standard_False; - myListOfCompoundOfEdgeConnected.Clear(); - myEC = new BRepAlgo_EdgeConnector(); - - - myState1 = TopAbs_UNKNOWN; - myState2 = TopAbs_UNKNOWN; - -} - - -//======================================================================= -//function : Destroy -//purpose : -//======================================================================= - void BRepAlgo_TopOpe::Destroy() -{ - if (myBuilder!=NULL) { - delete myBuilder; - myBuilder=NULL; - } - if (myDSFiller!=NULL) { - delete myDSFiller; - myDSFiller=NULL; - } -} -// Filling the DS - -//======================================================================= -//function : Load -//purpose : -//======================================================================= - -void BRepAlgo_TopOpe::Load(const TopoDS_Shape& ) -{ -} - -//======================================================================= -//function : Load -//purpose : -//======================================================================= - -void BRepAlgo_TopOpe::Load(TopoDS_Shape& S1, - TopoDS_Shape& S2) -{ - -// if ( S1.Orientation() == TopAbs_REVERSED ) { -// S1.Orientation(TopAbs_FORWARD); -// } -// if ( S2.Orientation() == TopAbs_REVERSED ) { -// S2.Orientation(TopAbs_FORWARD); -// } - - - myDSFiller->SetShapes(S1, S2); - myS1 = myDSFiller->Shape1(); - myS2 = myDSFiller->Shape2(); - - myDSFiller->InitFillersAndPools(); - -} - -//======================================================================= -//function : Intersect -//purpose : -//======================================================================= - -void BRepAlgo_TopOpe::Intersect() -{ -// myRecomputeBuilderIsDone = Standard_False; - - if(!myS1.IsNull() && !myS2.IsNull()) { - myDSFiller->Perform(); - } - - myRecomputeBuilderIsDone = Standard_True; - -} - -//======================================================================= -//function : Intersect -//purpose : -//======================================================================= - -void BRepAlgo_TopOpe::Intersect -(const TopoDS_Shape& S1, - const TopoDS_Shape& S2) -{ - myRecomputeBuilderIsDone = Standard_False; - - if(S1.IsNull() || S2.IsNull()) { - return; - } - -// Standard_Boolean orientFORWARD = Standard_False; - TopExp_Explorer exp; - if(S1.ShapeType() != TopAbs_FACE) { - exp.Init(S1, TopAbs_FACE); - if(!exp.More()) - return; - } - if(S2.ShapeType() != TopAbs_FACE) { - exp.Init(S2, TopAbs_FACE); - if(!exp.More()) - return; - } - - const BooleanOperations_ShapesDataStructure& aDS = myDSFiller->DS(); - TColStd_SetOfInteger anObjSubSet, aToolSubSet; - - TopTools_IndexedMapOfShape aMap; - TopExp::MapShapes(S1, aMap); - - Standard_Integer i, index, nbs = aMap.Extent(); - for(i = 1; i <= nbs; ++i) { - const TopoDS_Shape& aS = aMap(i); - index = aDS.ShapeIndex(aS, 1); - if(index > 0) { - anObjSubSet.Add(index); - } - } - - aMap.Clear(); - TopExp::MapShapes(S2, aMap); - nbs = aMap.Extent(); - for(i = 1; i <= nbs; ++i) { - const TopoDS_Shape& aS = aMap(i); - index = aDS.ShapeIndex(aS, 2); - if(index > 0) { - aToolSubSet.Add(index); - } - } - - myDSFiller->PartialPerform(anObjSubSet, aToolSubSet); - -} - -//======================================================================= -//function : ToCompleteIntersection -//purpose : -//======================================================================= - -void BRepAlgo_TopOpe::ToCompleteIntersection() -{ - if(!myRecomputeBuilderIsDone) { - myDSFiller->ToCompletePerform(); - myRecomputeBuilderIsDone = Standard_True; - } -} - -// Construction des Sections - -//======================================================================= -//function : GetSectionEdgeSet -//purpose : -//======================================================================= - -const TopTools_ListOfShape& BRepAlgo_TopOpe::GetSectionEdgeSet() -{ - if(!myRecomputeBuilderIsDone) { - ToCompleteIntersection(); - myRecomputeBuilderIsDone = Standard_True; - myGetSectionIsDone = Standard_False; - } - - if(myGetSectionIsDone) - return myListOfCompoundOfEdgeConnected; - - myGetSectionIsDone = Standard_True; - - myListOfCompoundOfEdgeConnected.Clear(); - - // EdgeConnector - Handle(BRepAlgo_EdgeConnector) EC = myEC; - EC->ClearStartElement(); - TopTools_MapOfShape ME; - ME.Clear(); - - Standard_Integer i, j, aNbFFs, aNbS, aNbCurves, nSect; - - const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); - const BOPTools_InterferencePool& anInterfPool=myDSFiller->InterfPool(); - BOPTools_InterferencePool* pInterfPool= - (BOPTools_InterferencePool*) &anInterfPool; - BOPTools_CArray1OfSSInterference& aFFs= - pInterfPool->SSInterferences(); - // - aNbFFs=aFFs.Extent(); - for (i=1; i<=aNbFFs; ++i) { - BOPTools_SSInterference& aFFi=aFFs(i); - // - // - // Old Section Edges - const BOPTools_ListOfPaveBlock& aSectList=aFFi.PaveBlocks(); - aNbS=aSectList.Extent(); - BOPTools_ListIteratorOfListOfPaveBlock anIt(aSectList); - for (; anIt.More();anIt.Next()) { - const BOPTools_PaveBlock& aPB=anIt.Value(); - nSect=aPB.Edge(); - const TopoDS_Shape& aS=aDS.GetShape(nSect); - - const TopoDS_Edge& aE = TopoDS::Edge(aS); - - if(ME.Contains(aE)) continue; - - ME.Add(aE); - EC->AddStart(aE); - } - // - // New Section Edges - BOPTools_SequenceOfCurves& aBCurves=aFFi.Curves(); - aNbCurves=aBCurves.Length(); - for (j=1; j<=aNbCurves; j++) { - BOPTools_Curve& aBC=aBCurves(j); - const BOPTools_ListOfPaveBlock& aSectEdges=aBC.NewPaveBlocks(); - aNbS=aSectEdges.Extent(); - - BOPTools_ListIteratorOfListOfPaveBlock aPBIt(aSectEdges); - for (; aPBIt.More(); aPBIt.Next()) { - BOPTools_PaveBlock& aPB=aPBIt.Value(); - nSect=aPB.Edge(); - const TopoDS_Shape& aS=aDS.GetShape(nSect); - const TopoDS_Edge& aE = TopoDS::Edge(aS); - - if(ME.Contains(aE)) continue; - - ME.Add(aE); - EC->AddStart(aE); - } - } - } - - - TopTools_ListOfShape& LW = EC->MakeBlock(); - - // the wires are transformed into compounds. - myCompoundWireMap.Clear(); - BRep_Builder BB; - TopTools_ListIteratorOfListOfShape ILW(LW); - TopExp_Explorer Explor; - for(;ILW.More();ILW.Next()) { - TopoDS_Compound Compound; - //POP - BB.MakeCompound(Compound); - // BB.MakeCompound(TopoDS::Compound(Compound)); - Explor.Init(ILW.Value(), TopAbs_EDGE); - for(;Explor.More(); Explor.Next()) { - BB.Add(Compound, Explor.Current()); - } - myListOfCompoundOfEdgeConnected.Append(Compound); - myCompoundWireMap.Bind(Compound,ILW.Value()); - } - - return myListOfCompoundOfEdgeConnected; - -} - - -//======================================================================= -//function : SuppressEdgeSet -//purpose : -//======================================================================= - -void BRepAlgo_TopOpe::SuppressEdgeSet() -{ - myGetSectionIsDone = Standard_False; -} - - -// Reconstruction of Shapes - -//======================================================================= -//function : Merge -//purpose : -//======================================================================= - -const TopoDS_Shape& BRepAlgo_TopOpe::Merge -(const TopAbs_State state1, - const TopAbs_State state2) -{ - - if(!myDSFiller->IsDone()) return myEmptyShape; - - if((state1 != TopAbs_IN) && - (state1 != TopAbs_OUT)) - return myEmptyShape; - if((state2 != TopAbs_IN) && - (state2 != TopAbs_OUT)) - return myEmptyShape; - // if GetSectionEdgeSet has already been called, nothing is done - // in GetSectionEdgeSet. - if(myState1 != TopAbs_UNKNOWN) - if(myState1 != state1 || myState2 != state2) - myGetSectionIsDone = Standard_False; - myState1 = state1; - myState2 = state2; - - BOP_Operation anOp = BOP_UNKNOWN; - if(myState1 == TopAbs_IN && myState2 == TopAbs_IN) anOp = BOP_COMMON; - if(myState1 == TopAbs_OUT && myState2 == TopAbs_IN) anOp = BOP_CUT; - if(myState1 == TopAbs_IN && myState2 == TopAbs_OUT) anOp = BOP_CUT21; - if(myState1 == TopAbs_OUT && myState2 == TopAbs_OUT) anOp = BOP_FUSE; - - if (myBuilder != NULL) { - delete myBuilder; - } - - myBuilder = new BOP_SolidSolid; - myBuilder->SetShapes(myS1, myS2); - myBuilder->SetOperation (anOp); - - myHistory = new BOP_SolidSolidHistoryCollector(myS1, myS2, anOp); - myBuilder->SetHistoryCollector(myHistory); - - myBuilder->DoWithFiller (*myDSFiller); - - myResultShape = myBuilder->Result(); - - return myResultShape; -} - -//======================================================================= -//function : Merge -//purpose : -//======================================================================= - -const TopoDS_Shape& BRepAlgo_TopOpe::Merge -(const TopAbs_State ) -{ - - myResultShape.Nullify(); - return myResultShape; - -} - -//======================================================================= -//function : PaveBlocksNotEmpty -//purpose : -//======================================================================= -Standard_Boolean BRepAlgo_TopOpe::PaveBlocksNotEmpty() -{ - Standard_Integer i, aNbFFs, aNbS; - -// const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); - const BOPTools_InterferencePool& anInterfPool=myDSFiller->InterfPool(); - BOPTools_InterferencePool* pInterfPool= - (BOPTools_InterferencePool*) &anInterfPool; - BOPTools_CArray1OfSSInterference& aFFs= - pInterfPool->SSInterferences(); - // - - // - aNbFFs=aFFs.Extent(); - for (i=1; i<=aNbFFs; ++i) { - BOPTools_SSInterference& aFFi=aFFs(i); - // - // Old Section Edges - const BOPTools_ListOfPaveBlock& aSectList=aFFi.PaveBlocks(); - aNbS=aSectList.Extent(); - - if (aNbS > 0) { - return Standard_True; - } - } - - return Standard_False; - -} - -//======================================================================= -//function : Builder -//purpose : -//======================================================================= - -const BOP_PBuilder& BRepAlgo_TopOpe::Builder() const -{ - return myBuilder; -} - -//======================================================================= -//function : DSFiller -//purpose : -//======================================================================= - -const BOPTools_PDSFiller& BRepAlgo_TopOpe::DSFiller() const -{ - return myDSFiller; -} - -//======================================================================= -//function : History -//purpose : -//======================================================================= - -const Handle(BOP_HistoryCollector)& BRepAlgo_TopOpe::History() const -{ - return myHistory; -} - diff --git a/src/BRepAlgoAPI/BRepAlgoAPI.cdl b/src/BRepAlgoAPI/BRepAlgoAPI.cdl index f95e091e97..ce4a54321a 100755 --- a/src/BRepAlgoAPI/BRepAlgoAPI.cdl +++ b/src/BRepAlgoAPI/BRepAlgoAPI.cdl @@ -95,9 +95,9 @@ uses TopoDS, gp, Geom, - Geom2d, - BOP, - BOPTools, + Geom2d, + BOPAlgo, + BOPDS, BRepBuilderAPI is diff --git a/src/BRepAlgoAPI/BRepAlgoAPI_BooleanOperation.cdl b/src/BRepAlgoAPI/BRepAlgoAPI_BooleanOperation.cdl index 17f51af961..1b9ffecf3f 100755 --- a/src/BRepAlgoAPI/BRepAlgoAPI_BooleanOperation.cdl +++ b/src/BRepAlgoAPI/BRepAlgoAPI_BooleanOperation.cdl @@ -19,6 +19,8 @@ -- and conditions governing the rights and limitations under the License. -- modified by Peter KURNEV Tue Mar 5 14:01:51 2002 +-- modified by Eugeny MALTCHIKOV Wed Jul 04 11:13:01 2012 + deferred class BooleanOperation from BRepAlgoAPI inherits MakeShape from BRepBuilderAPI @@ -37,11 +39,11 @@ uses Shape from TopoDS, ListOfShape from TopTools, - Operation from BOP, - PBuilder from BOP, - HistoryCollector from BOP, - PDSFiller from BOPTools, - DSFiller from BOPTools, + Operation from BOPAlgo, + BOP from BOPAlgo, + PBOP from BOPAlgo, + PaveFiller from BOPAlgo, + PPaveFiller from BOPAlgo, DataMapOfIntegerListOfShape from TopTools, DataMapOfIntegerShape from TopTools, DataMapOfShapeShape from TopTools @@ -50,23 +52,23 @@ is Initialize (S1 :Shape from TopoDS; S2 :Shape from TopoDS; - anOperation:Operation from BOP); + anOperation:Operation from BOPAlgo); ---Purpose: Prepares the operations for S1 and S2. Initialize (S1 :Shape from TopoDS; S2 :Shape from TopoDS; - aDSF :DSFiller from BOPTools; - anOperation:Operation from BOP); + aDSF :PaveFiller from BOPAlgo; + anOperation:Operation from BOPAlgo); ---Purpose: Prepares the operations for S1 and S2. SetOperation (me:out; - anOp: Operation from BOP); + anOp: Operation from BOPAlgo); ---Purpose: Sets the type of Boolean operation to perform - --- It can be BOP_SECTION - --- BOP_COMMON - --- BOP_FUSE - --- BOP_CUT - --- BOP_CUT21 + --- It can be BOPAlgo_SECTION + --- BOPAlgo_COMMON + --- BOPAlgo_FUSE + --- BOPAlgo_CUT + --- BOPAlgo_CUT21 --- @@ -89,7 +91,7 @@ is ---C++: return const & Operation (me) - returns Operation from BOP; + returns Operation from BOPAlgo; ---Purpose: Returns the type of Boolean Operation that has been performed. FuseEdges(me) returns Boolean from Standard; @@ -189,15 +191,13 @@ is ---C++: return const & fields - myS1 : Shape from TopoDS is protected; - myS2 : Shape from TopoDS is protected; - myBuilderCanWork : Boolean from Standard is protected; - myOperation : Operation from BOP is protected; - myErrorStatus : Integer from Standard is protected; - myDSFiller : PDSFiller from BOPTools is protected; - myBuilder : PBuilder from BOP is protected; - - myHistory : HistoryCollector from BOP is protected; + myS1 : Shape from TopoDS is protected; + myS2 : Shape from TopoDS is protected; + myBuilderCanWork : Boolean from Standard is protected; + myOperation : Operation from BOPAlgo is protected; + myErrorStatus : Integer from Standard is protected; + myDSFiller : PPaveFiller from BOPAlgo is protected; + myBuilder : PBOP from BOPAlgo is protected; myEntryType : Integer from Standard; diff --git a/src/BRepAlgoAPI/BRepAlgoAPI_BooleanOperation.cxx b/src/BRepAlgoAPI/BRepAlgoAPI_BooleanOperation.cxx index 80ded2c509..460c333015 100755 --- a/src/BRepAlgoAPI/BRepAlgoAPI_BooleanOperation.cxx +++ b/src/BRepAlgoAPI/BRepAlgoAPI_BooleanOperation.cxx @@ -18,42 +18,24 @@ // purpose or non-infringement. Please see the License for the specific terms // and conditions governing the rights and limitations under the License. - #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include #include #include #include #include -static Handle(BOP_HistoryCollector) MakeCollector(const TopoDS_Shape& theShape1, - const TopoDS_Shape& theShape2, - const BOP_Operation theOperation); - +#include +#include +#include //======================================================================= //function : BRepAlgoAPI_BooleanOperation //purpose : //======================================================================= BRepAlgoAPI_BooleanOperation::BRepAlgoAPI_BooleanOperation(const TopoDS_Shape& aS1, - const TopoDS_Shape& aS2, - const BOP_Operation anOp) + const TopoDS_Shape& aS2, + const BOPAlgo_Operation anOp) : myS1(aS1), myS2(aS2), @@ -71,9 +53,9 @@ static Handle(BOP_HistoryCollector) MakeCollector(const TopoDS_Shape& theS //purpose : //======================================================================= BRepAlgoAPI_BooleanOperation::BRepAlgoAPI_BooleanOperation(const TopoDS_Shape& aS1, - const TopoDS_Shape& aS2, - const BOPTools_DSFiller& aDSFiller, - const BOP_Operation anOp) + const TopoDS_Shape& aS2, + const BOPAlgo_PaveFiller& aDSFiller, + const BOPAlgo_Operation anOp) : myS1(aS1), myS2(aS2), @@ -86,7 +68,7 @@ static Handle(BOP_HistoryCollector) MakeCollector(const TopoDS_Shape& theS myFuseEdges(Standard_False) { if ((Standard_Address) &aDSFiller!=NULL) { - myDSFiller=(BOPTools_PDSFiller)&aDSFiller; + myDSFiller=(BOPAlgo_PaveFiller*)&aDSFiller; } } //======================================================================= @@ -103,12 +85,16 @@ static Handle(BOP_HistoryCollector) MakeCollector(const TopoDS_Shape& theS delete myDSFiller; myDSFiller=NULL; } + + // + myModifFaces.Clear(); + myEdgeMap.Clear(); } //======================================================================= //function : SetOperation //purpose : //======================================================================= - void BRepAlgoAPI_BooleanOperation::SetOperation (const BOP_Operation anOp) + void BRepAlgoAPI_BooleanOperation::SetOperation (const BOPAlgo_Operation anOp) { myOperation=anOp; } @@ -116,7 +102,7 @@ static Handle(BOP_HistoryCollector) MakeCollector(const TopoDS_Shape& theS //function : Operation //purpose : //======================================================================= - BOP_Operation BRepAlgoAPI_BooleanOperation::Operation ()const + BOPAlgo_Operation BRepAlgoAPI_BooleanOperation::Operation ()const { return myOperation; } @@ -175,13 +161,15 @@ const TopTools_ListOfShape& BRepAlgoAPI_BooleanOperation::Modified(const TopoDS_ return myGenerated; } else { - const TopTools_ListOfShape& aLM=myBuilder->Modified(aS); + myGenerated = myBuilder->Modified(aS); if(myFuseEdges) { - return RefinedList(aLM); + TopTools_ListOfShape theLS; + theLS.Assign(myGenerated); + // + RefinedList(theLS); } - - return aLM; + return myGenerated; } } @@ -191,28 +179,13 @@ const TopTools_ListOfShape& BRepAlgoAPI_BooleanOperation::Modified(const TopoDS_ //======================================================================= Standard_Boolean BRepAlgoAPI_BooleanOperation::IsDeleted(const TopoDS_Shape& aS) { - -// Standard_Boolean bDeleted = Standard_True; -// if (myBuilder==NULL) { -// return bDeleted; -// } -// else { -// bDeleted=myBuilder->IsDeleted(aS); -// return bDeleted; -// } - if(myHistory.IsNull()) { - Standard_Boolean bDeleted = Standard_True; - - if (myBuilder==NULL) { - return bDeleted; - } - else { - bDeleted = myBuilder->IsDeleted(aS); - return bDeleted; - } + Standard_Boolean bDeleted = Standard_True; + if (myBuilder != NULL) { + bDeleted=myBuilder->IsDeleted(aS); } - return myHistory->IsDeleted(aS); + return bDeleted; } + //======================================================================= //function : PrepareFiller //purpose : @@ -227,7 +200,7 @@ const TopTools_ListOfShape& BRepAlgoAPI_BooleanOperation::Modified(const TopoDS_ return bIsNewFiller; } // - if (myOperation==BOP_UNKNOWN) { + if (myOperation==BOPAlgo_UNKNOWN) { myErrorStatus=6; return bIsNewFiller; } @@ -235,22 +208,18 @@ const TopTools_ListOfShape& BRepAlgoAPI_BooleanOperation::Modified(const TopoDS_ if (myDSFiller==NULL) { bIsNewFiller=!bIsNewFiller; - myDSFiller=new BOPTools_DSFiller; + myDSFiller=new BOPAlgo_PaveFiller; // if (myDSFiller==NULL) { myErrorStatus=4; return bIsNewFiller; } // - myDSFiller->SetShapes(myS1, myS2); - if (!myDSFiller->IsDone()) { - myErrorStatus=3; - if (myDSFiller!=NULL) { - delete myDSFiller; - myDSFiller = NULL; - return bIsNewFiller; - } - } + BOPCol_ListOfShape aLS; + aLS.Append(myS1); + aLS.Append(myS2); + // + myDSFiller->SetArguments(aLS); } return bIsNewFiller; @@ -261,7 +230,8 @@ const TopTools_ListOfShape& BRepAlgoAPI_BooleanOperation::Modified(const TopoDS_ //======================================================================= void BRepAlgoAPI_BooleanOperation::Build() { - Standard_Boolean bIsDone, bIsNewFiller; + Standard_Boolean bIsNewFiller; + Standard_Integer iErr; // myBuilderCanWork=Standard_False; NotDone(); @@ -283,127 +253,26 @@ const TopTools_ListOfShape& BRepAlgoAPI_BooleanOperation::Modified(const TopoDS_ myBuilder=NULL; } // - const TopoDS_Shape& aS1 = myDSFiller->Shape1(); - const TopoDS_Shape& aS2 = myDSFiller->Shape2(); + const TopoDS_Shape& aS1 = myS1; + const TopoDS_Shape& aS2 = myS2; // myShape.Nullify(); - // - // SECTION - // - if (myOperation==BOP_SECTION) { - myBuilder=new BOP_Section; - } - // - // COMMON, FUSE, CUT12, CUT21 - // - else if (myOperation==BOP_COMMON || myOperation==BOP_FUSE || - myOperation==BOP_CUT || myOperation==BOP_CUT21) { - // - // Check whether one or both of the arguments is(are) empty shape(s) - // If yes, create BOP_EmptyBuilder object and build the result fast. - { - Standard_Boolean bIsEmptyShape1, bIsEmptyShape2; - - bIsEmptyShape1=BOPTools_Tools3D::IsEmptyShape(aS1); - bIsEmptyShape2=BOPTools_Tools3D::IsEmptyShape(aS2); - // - if (bIsEmptyShape1 || bIsEmptyShape2) { - myBuilder=new BOP_EmptyBuilder; - // - if (myBuilder==NULL) { - myErrorStatus=7; - return ; - } - // - myBuilder->SetShapes(aS1, aS2); - myBuilder->SetOperation (myOperation); - myBuilder->DoWithFiller (*myDSFiller); - - bIsDone=myBuilder->IsDone(); - - if (bIsDone) { - myErrorStatus=0; - myBuilderCanWork=Standard_True; - myShape=myBuilder->Result(); - Done(); - } - else { - myErrorStatus=100+myBuilder->ErrorStatus(); - NotDone(); - } - return; - } - } - // - TopAbs_ShapeEnum aT1, aT2; - aT1=aS1.ShapeType(); - aT2=aS2.ShapeType(); - // - // Shell / Shell - if (aT1==TopAbs_SHELL && aT2==TopAbs_SHELL) { - myBuilder=new BOP_ShellShell; - } - // - // Solid / Solid - else if (aT1==TopAbs_SOLID && aT2==TopAbs_SOLID) { - myBuilder=new BOP_SolidSolid; - } - // - // Shell / Solid - else if ((aT1==TopAbs_SOLID && aT2==TopAbs_SHELL) - || - (aT2==TopAbs_SOLID && aT1==TopAbs_SHELL)) { - myBuilder=new BOP_ShellSolid; - } - // - // Wire / Wire - else if (aT1==TopAbs_WIRE && aT2==TopAbs_WIRE){ - myBuilder=new BOP_WireWire; - } - // - // Wire / Shell - else if ((aT1==TopAbs_WIRE && aT2==TopAbs_SHELL) - || - (aT2==TopAbs_WIRE && aT1==TopAbs_SHELL)) { - myBuilder=new BOP_WireShell; - } - // - // Wire / Shell - else if ((aT1==TopAbs_WIRE && aT2==TopAbs_SOLID) - || - (aT2==TopAbs_WIRE && aT1==TopAbs_SOLID)) { - myBuilder=new BOP_WireSolid; - } - else { - myErrorStatus=5; - return ; - } - } + myBuilder=new BOPAlgo_BOP; + myBuilder->AddArgument(aS1); + myBuilder->AddTool(aS2); + myBuilder->SetOperation(myOperation); // - if (myBuilder==NULL) { - myErrorStatus=7; - return ; - } - // - myBuilder->SetShapes(aS1, aS2); - myBuilder->SetOperation (myOperation); - - myHistory = MakeCollector(aS1, aS2, myOperation); - myBuilder->SetHistoryCollector(myHistory); - - myBuilder->DoWithFiller (*myDSFiller); - - bIsDone=myBuilder->IsDone(); - - if (bIsDone) { + myBuilder->PerformWithFiller(*myDSFiller); + iErr = myBuilder->ErrorStatus(); + if (!iErr) { myErrorStatus=0; myBuilderCanWork=Standard_True; - myShape=myBuilder->Result(); + myShape=myBuilder->Shape(); Done(); - } + } else { - myErrorStatus=100+myBuilder->ErrorStatus(); + myErrorStatus=100+iErr; NotDone(); } } @@ -419,17 +288,43 @@ const TopTools_ListOfShape& BRepAlgoAPI_BooleanOperation::SectionEdges() myGenerated.Clear(); return myGenerated; } - else { - const TopTools_ListOfShape& aLM=myBuilder->SectionEdges(); - - if(myFuseEdges) { - return RefinedList(aLM); + // + Standard_Integer aNb, i, j, aNbCurves, nE; + BOPDS_ListIteratorOfListOfPaveBlock anIt; + // + const BOPDS_PDS& pDS = myDSFiller->PDS(); + BOPDS_VectorOfInterfFF& aFFs=pDS->InterfFF(); + myGenerated.Clear(); + // + aNb=aFFs.Extent(); + for (i = 0; i < aNb; i++) { + BOPDS_InterfFF& aFFi=aFFs(i); + const BOPDS_VectorOfCurve& aSeqOfCurve=aFFi.Curves(); + // + aNbCurves=aSeqOfCurve.Extent(); + for (j=0; jEdge(); + const TopoDS_Shape& aE = pDS->Shape(nE); + myGenerated.Append(aE); + } } - - return aLM; } + // + if(myFuseEdges) { + TopTools_ListOfShape theLS; + theLS.Assign(myGenerated); + // + RefinedList(theLS); + } + // + return myGenerated; } -// // ================================================================================================ // function: Modified2 @@ -437,17 +332,34 @@ const TopTools_ListOfShape& BRepAlgoAPI_BooleanOperation::SectionEdges() // ================================================================================================ const TopTools_ListOfShape& BRepAlgoAPI_BooleanOperation::Modified2(const TopoDS_Shape& aS) { - if(myHistory.IsNull()) { + if (myBuilder==NULL) { myGenerated.Clear(); return myGenerated; } - - if(myFuseEdges) { - const TopTools_ListOfShape& aL = myHistory->Modified(aS); - return RefinedList(aL); + // + BOPCol_ListOfShape aLS; + BOPCol_ListIteratorOfListOfShape aIt; + myGenerated.Clear(); + // + const BOPCol_DataMapOfShapeListOfShape& aImages = myBuilder->Images(); + if (aImages.IsBound(aS)) { + aLS = aImages.Find(aS); + } else { + myGenerated.Append(aS); } - - return myHistory->Modified(aS); + // + aIt.Initialize(aLS); + for (;aIt.More(); aIt.Next()) { + myGenerated.Append(aIt.Value()); + } + // + if (myFuseEdges) { + TopTools_ListOfShape theLS; + theLS.Assign(myGenerated); + // + RefinedList(theLS); + } + return myGenerated; } // ================================================================================================ @@ -456,17 +368,17 @@ const TopTools_ListOfShape& BRepAlgoAPI_BooleanOperation::Modified2(const TopoDS // ================================================================================================ const TopTools_ListOfShape& BRepAlgoAPI_BooleanOperation::Generated(const TopoDS_Shape& S) { - if(myHistory.IsNull()) { + if (myBuilder==NULL) { myGenerated.Clear(); return myGenerated; } - + // if(myFuseEdges) { - const TopTools_ListOfShape& aL = myHistory->Generated(S); + const TopTools_ListOfShape& aL = myBuilder->Generated(S); return RefinedList(aL); } - - return myHistory->Generated(S); + + return myBuilder->Generated(S); } // ================================================================================================ @@ -475,10 +387,10 @@ const TopTools_ListOfShape& BRepAlgoAPI_BooleanOperation::Generated(const TopoDS // ================================================================================================ Standard_Boolean BRepAlgoAPI_BooleanOperation::HasModified() const { - if(myHistory.IsNull()) { + if (myBuilder==NULL) { return Standard_False; } - return myHistory->HasModified(); + return myBuilder->HasModified(); } // ================================================================================================ @@ -487,10 +399,10 @@ Standard_Boolean BRepAlgoAPI_BooleanOperation::HasModified() const // ================================================================================================ Standard_Boolean BRepAlgoAPI_BooleanOperation::HasGenerated() const { - if(myHistory.IsNull()) { + if (myBuilder==NULL) { return Standard_False; } - return myHistory->HasGenerated(); + return myBuilder->HasGenerated(); } // ================================================================================================ @@ -499,10 +411,10 @@ Standard_Boolean BRepAlgoAPI_BooleanOperation::HasGenerated() const // ================================================================================================ Standard_Boolean BRepAlgoAPI_BooleanOperation::HasDeleted() const { - if(myHistory.IsNull()) { + if (myBuilder==NULL) { return Standard_False; } - return myHistory->HasDeleted(); + return myBuilder->HasDeleted(); } //======================================================================= //function : RefineEdges @@ -511,7 +423,6 @@ Standard_Boolean BRepAlgoAPI_BooleanOperation::HasDeleted() const void BRepAlgoAPI_BooleanOperation::RefineEdges () { - if(myFuseEdges) return; //Edges have been refined yet BRepLib_FuseEdges FE(myShape); @@ -540,7 +451,6 @@ Standard_Boolean BRepAlgoAPI_BooleanOperation::HasDeleted() const FE.ResultEdges(aResultEdges); FE.Faces(myModifFaces); myFuseEdges = Standard_True; - Standard_Integer i; for(i = 1; i <= nle; ++i) { @@ -548,11 +458,10 @@ Standard_Boolean BRepAlgoAPI_BooleanOperation::HasDeleted() const const TopTools_ListOfShape& aListOfOldEdges = aFusedEdges(i); TopTools_ListIteratorOfListOfShape anIter(aListOfOldEdges); for(; anIter.More(); anIter.Next()) { - myEdgeMap.Bind(anIter.Value(), aNewE); + myEdgeMap.Bind(anIter.Value(), aNewE); } } } - } //======================================================================= @@ -572,21 +481,21 @@ const TopTools_ListOfShape& if(anS.ShapeType() == TopAbs_EDGE) { if(myEdgeMap.IsBound(anS)) { - const TopoDS_Shape& aNewEdge = myEdgeMap.Find(anS); - if(aMap.Add(aNewEdge)) { - myGenerated.Append(aNewEdge); - } + const TopoDS_Shape& aNewEdge = myEdgeMap.Find(anS); + if(aMap.Add(aNewEdge)) { + myGenerated.Append(aNewEdge); + } } else { - myGenerated.Append(anS); + myGenerated.Append(anS); } } else if (anS.ShapeType() == TopAbs_FACE) { if(myModifFaces.IsBound(anS)) { - myGenerated.Append(myModifFaces.Find(anS)); + myGenerated.Append(myModifFaces.Find(anS)); } else { - myGenerated.Append(anS); + myGenerated.Append(anS); } } else { @@ -597,61 +506,3 @@ const TopTools_ListOfShape& return myGenerated; } -// ----------------------------------------------------------------------------------------- -// static function: MakeCollector -// purpose: -// ----------------------------------------------------------------------------------------- -Handle(BOP_HistoryCollector) MakeCollector(const TopoDS_Shape& theShape1, - const TopoDS_Shape& theShape2, - const BOP_Operation theOperation) { - - Handle(BOP_HistoryCollector) aresult; - - if(theOperation == BOP_SECTION) { - aresult = new BOP_SectionHistoryCollector(theShape1, theShape2); - return aresult; - } - - TopAbs_ShapeEnum aT1, aT2; - - aT1 = theShape1.ShapeType(); - aT2 = theShape2.ShapeType(); - // - // Shell / Shell - if (aT1==TopAbs_SHELL && aT2==TopAbs_SHELL) { - // aresult = new BOP_ShellShellHistoryCollector(theShape1, theShape2, theOperation, theDSFiller); - } - // - // Solid / Solid - else if (aT1==TopAbs_SOLID && aT2==TopAbs_SOLID) { - aresult = new BOP_SolidSolidHistoryCollector(theShape1, theShape2, theOperation); - } - // - // Shell / Solid - else if ((aT1==TopAbs_SOLID && aT2==TopAbs_SHELL) - || - (aT2==TopAbs_SOLID && aT1==TopAbs_SHELL)) { - aresult = new BOP_ShellSolidHistoryCollector(theShape1, theShape2, theOperation); - } - // - // Wire / Wire - else if (aT1==TopAbs_WIRE && aT2==TopAbs_WIRE){ - // aresult = new BOP_WireWireHistoryCollector(theShape1, theShape2, theOperation, theDSFiller); - } - // - // Wire / Shell - else if ((aT1==TopAbs_WIRE && aT2==TopAbs_SHELL) - || - (aT2==TopAbs_WIRE && aT1==TopAbs_SHELL)) { - // aresult = new BOP_WireShellHistoryCollector(theShape1, theShape2, theOperation, theDSFiller); - } - // - // Wire / Shell - else if ((aT1==TopAbs_WIRE && aT2==TopAbs_SOLID) - || - (aT2==TopAbs_WIRE && aT1==TopAbs_SOLID)) { - aresult = new BOP_WireSolidHistoryCollector(theShape1, theShape2, theOperation); - } - return aresult; -} - diff --git a/src/BRepAlgoAPI/BRepAlgoAPI_Common.cdl b/src/BRepAlgoAPI/BRepAlgoAPI_Common.cdl index fe3e1dbe78..92d8e74dd4 100755 --- a/src/BRepAlgoAPI/BRepAlgoAPI_Common.cdl +++ b/src/BRepAlgoAPI/BRepAlgoAPI_Common.cdl @@ -32,7 +32,7 @@ class Common from BRepAlgoAPI inherits BooleanOperation from BRepAlgoAPI uses Shape from TopoDS, - DSFiller from BOPTools + PaveFiller from BOPAlgo is Create (S1,S2 : Shape from TopoDS) @@ -40,7 +40,7 @@ is ---Purpose: Constructs a common part for shapes aS1 and aS2 . Create (S1,S2 : Shape from TopoDS; - aDSF:DSFiller from BOPTools) + aDSF:PaveFiller from BOPAlgo) returns Common from BRepAlgoAPI; end Common; --- Purpose: Constructs a common part for shapes aS1 and aS2 using aDSFiller diff --git a/src/BRepAlgoAPI/BRepAlgoAPI_Common.cxx b/src/BRepAlgoAPI/BRepAlgoAPI_Common.cxx index a52318b58a..440f86820c 100755 --- a/src/BRepAlgoAPI/BRepAlgoAPI_Common.cxx +++ b/src/BRepAlgoAPI/BRepAlgoAPI_Common.cxx @@ -18,19 +18,17 @@ // purpose or non-infringement. Please see the License for the specific terms // and conditions governing the rights and limitations under the License. - #include #include -#include //======================================================================= //function : BRepAlgoAPI_Common //purpose : //======================================================================= -BRepAlgoAPI_Common::BRepAlgoAPI_Common(const TopoDS_Shape& S1, - const TopoDS_Shape& S2) -: BRepAlgoAPI_BooleanOperation(S1, S2, BOP_COMMON) + BRepAlgoAPI_Common::BRepAlgoAPI_Common(const TopoDS_Shape& S1, + const TopoDS_Shape& S2) +: BRepAlgoAPI_BooleanOperation(S1, S2, BOPAlgo_COMMON) { BRepAlgoAPI_BooleanOperation* pBO= (BRepAlgoAPI_BooleanOperation*) (void*) this; @@ -41,9 +39,9 @@ BRepAlgoAPI_Common::BRepAlgoAPI_Common(const TopoDS_Shape& S1, //purpose : //======================================================================= BRepAlgoAPI_Common::BRepAlgoAPI_Common(const TopoDS_Shape& S1, - const TopoDS_Shape& S2, - const BOPTools_DSFiller& aDSF) -: BRepAlgoAPI_BooleanOperation(S1, S2, aDSF, BOP_COMMON) + const TopoDS_Shape& S2, + const BOPAlgo_PaveFiller& aDSF) +: BRepAlgoAPI_BooleanOperation(S1, S2, aDSF, BOPAlgo_COMMON) { BRepAlgoAPI_BooleanOperation* pBO= (BRepAlgoAPI_BooleanOperation*) (void*) this; diff --git a/src/BRepAlgoAPI/BRepAlgoAPI_Cut.cdl b/src/BRepAlgoAPI/BRepAlgoAPI_Cut.cdl index 98ec97ed2f..6e1feae9e0 100755 --- a/src/BRepAlgoAPI/BRepAlgoAPI_Cut.cdl +++ b/src/BRepAlgoAPI/BRepAlgoAPI_Cut.cdl @@ -31,8 +31,7 @@ class Cut from BRepAlgoAPI inherits BooleanOperation from BRepAlgoAPI uses Shape from TopoDS, - DSFiller from BOPTools, - Operation from BOP + PaveFiller from BOPAlgo is Create (S1,S2 : Shape from TopoDS) @@ -40,8 +39,9 @@ is ---Purpose: Shape aS2 cuts shape aS1. The -- resulting shape is a new shape produced by the cut operation. + Create (S1,S2 : Shape from TopoDS; - aDSF : DSFiller from BOPTools; + aDSF : PaveFiller from BOPAlgo; bFWD : Boolean from Standard=Standard_True) returns Cut from BRepAlgoAPI; --- Purpose: Constructs a new shape cut from diff --git a/src/BRepAlgoAPI/BRepAlgoAPI_Cut.cxx b/src/BRepAlgoAPI/BRepAlgoAPI_Cut.cxx index 1f57cef5c9..5c07299c56 100755 --- a/src/BRepAlgoAPI/BRepAlgoAPI_Cut.cxx +++ b/src/BRepAlgoAPI/BRepAlgoAPI_Cut.cxx @@ -19,19 +19,17 @@ // and conditions governing the rights and limitations under the License. - #include #include -#include //======================================================================= //function : BRepAlgoAPI_Cut //purpose : //======================================================================= -BRepAlgoAPI_Cut::BRepAlgoAPI_Cut(const TopoDS_Shape& S1, - const TopoDS_Shape& S2) -: BRepAlgoAPI_BooleanOperation(S1, S2, BOP_CUT) + BRepAlgoAPI_Cut::BRepAlgoAPI_Cut(const TopoDS_Shape& S1, + const TopoDS_Shape& S2) +: BRepAlgoAPI_BooleanOperation(S1, S2, BOPAlgo_CUT) { BRepAlgoAPI_BooleanOperation* pBO= (BRepAlgoAPI_BooleanOperation*) (void*) this; @@ -42,10 +40,10 @@ BRepAlgoAPI_Cut::BRepAlgoAPI_Cut(const TopoDS_Shape& S1, //purpose : //======================================================================= BRepAlgoAPI_Cut::BRepAlgoAPI_Cut(const TopoDS_Shape& S1, - const TopoDS_Shape& S2, - const BOPTools_DSFiller& aDSF, - const Standard_Boolean bFWD) -: BRepAlgoAPI_BooleanOperation(S1, S2, aDSF, (bFWD) ? BOP_CUT : BOP_CUT21) + const TopoDS_Shape& S2, + const BOPAlgo_PaveFiller& aDSF, + const Standard_Boolean bFWD) +: BRepAlgoAPI_BooleanOperation(S1, S2, aDSF, (bFWD) ? BOPAlgo_CUT : BOPAlgo_CUT21) { BRepAlgoAPI_BooleanOperation* pBO= (BRepAlgoAPI_BooleanOperation*) (void*) this; diff --git a/src/BRepAlgoAPI/BRepAlgoAPI_Fuse.cdl b/src/BRepAlgoAPI/BRepAlgoAPI_Fuse.cdl index 30baec0d6b..55cee06e26 100755 --- a/src/BRepAlgoAPI/BRepAlgoAPI_Fuse.cdl +++ b/src/BRepAlgoAPI/BRepAlgoAPI_Fuse.cdl @@ -32,7 +32,7 @@ class Fuse from BRepAlgoAPI inherits BooleanOperation from BRepAlgoAPI uses Shape from TopoDS, - DSFiller from BOPTools + PaveFiller from BOPAlgo is Create (S1,S2 : Shape from TopoDS) @@ -40,7 +40,7 @@ is ---Purpose: Constructs a fuse of shapes aS1 and aS2. Create (S1,S2 : Shape from TopoDS; - aDSF:DSFiller from BOPTools) + aDSF:PaveFiller from BOPAlgo) returns Fuse from BRepAlgoAPI; ---Purpose: Constructs a new shape that is a fuse of shapes aS1 and aS2 using aDSFiller. diff --git a/src/BRepAlgoAPI/BRepAlgoAPI_Fuse.cxx b/src/BRepAlgoAPI/BRepAlgoAPI_Fuse.cxx index 990c537ef4..f0c4d9710f 100755 --- a/src/BRepAlgoAPI/BRepAlgoAPI_Fuse.cxx +++ b/src/BRepAlgoAPI/BRepAlgoAPI_Fuse.cxx @@ -22,15 +22,14 @@ #include #include -#include //======================================================================= //function : BRepAlgoAPI_Fuse //purpose : //======================================================================= -BRepAlgoAPI_Fuse::BRepAlgoAPI_Fuse(const TopoDS_Shape& S1, - const TopoDS_Shape& S2) -: BRepAlgoAPI_BooleanOperation(S1, S2, BOP_FUSE) + BRepAlgoAPI_Fuse::BRepAlgoAPI_Fuse(const TopoDS_Shape& S1, + const TopoDS_Shape& S2) +: BRepAlgoAPI_BooleanOperation(S1, S2, BOPAlgo_FUSE) { BRepAlgoAPI_BooleanOperation* pBO= (BRepAlgoAPI_BooleanOperation*) (void*) this; @@ -42,9 +41,9 @@ BRepAlgoAPI_Fuse::BRepAlgoAPI_Fuse(const TopoDS_Shape& S1, //purpose : //======================================================================= BRepAlgoAPI_Fuse::BRepAlgoAPI_Fuse(const TopoDS_Shape& S1, - const TopoDS_Shape& S2, - const BOPTools_DSFiller& aDSF) -: BRepAlgoAPI_BooleanOperation(S1, S2, aDSF, BOP_FUSE) + const TopoDS_Shape& S2, + const BOPAlgo_PaveFiller& aDSF) +: BRepAlgoAPI_BooleanOperation(S1, S2, aDSF, BOPAlgo_FUSE) { BRepAlgoAPI_BooleanOperation* pBO= (BRepAlgoAPI_BooleanOperation*) (void*) this; diff --git a/src/BRepAlgoAPI/BRepAlgoAPI_Section.cdl b/src/BRepAlgoAPI/BRepAlgoAPI_Section.cdl index eb887acaa0..c4b03ef820 100755 --- a/src/BRepAlgoAPI/BRepAlgoAPI_Section.cdl +++ b/src/BRepAlgoAPI/BRepAlgoAPI_Section.cdl @@ -51,14 +51,15 @@ uses Shape from TopoDS, Surface from Geom, Curve from Geom2d, - DSFiller from BOPTools, + PaveFiller from BOPAlgo, ListOfShape from TopTools is Create (S1,S2 : Shape from TopoDS; - aDSF:DSFiller from BOPTools; + aDSF:PaveFiller from BOPAlgo; PerformNow : Boolean = Standard_True) returns Section from BRepAlgoAPI; + ---C++: alias "Standard_EXPORT virtual ~BRepAlgoAPI_Section(){}" Create(Sh1,Sh2 : Shape from TopoDS; PerformNow : Boolean = Standard_True) diff --git a/src/BRepAlgoAPI/BRepAlgoAPI_Section.cxx b/src/BRepAlgoAPI/BRepAlgoAPI_Section.cxx index bebdc3a66d..a088e394d4 100755 --- a/src/BRepAlgoAPI/BRepAlgoAPI_Section.cxx +++ b/src/BRepAlgoAPI/BRepAlgoAPI_Section.cxx @@ -19,6 +19,7 @@ // and conditions governing the rights and limitations under the License. // modified by Michael KLOKOV Wed Mar 6 15:01:25 2002 +// modified by Eugeny MALTCHIKOV Wed Jul 04 11:13:01 2012 #include @@ -27,19 +28,7 @@ #include #include #include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include + #include #include #include @@ -47,7 +36,9 @@ #include #include -#include +#include +#include +#include static TopoDS_Shape MakeShape(const Handle(Geom_Surface)& S) { @@ -56,19 +47,19 @@ static TopoDS_Shape MakeShape(const Handle(Geom_Surface)& S) else return BRepBuilderAPI_MakeShell(S); } -static Standard_Boolean HasAncestorFaces(const BOPTools_DSFiller& theDSFiller, - const TopoDS_Shape& E, - TopoDS_Shape& F1, - TopoDS_Shape& F2); +static Standard_Boolean HasAncestorFaces(const BOPAlgo_PPaveFiller& theDSFiller, + const TopoDS_Shape& E, + TopoDS_Shape& F1, + TopoDS_Shape& F2); //======================================================================= //function : Constructor //purpose : //======================================================================= BRepAlgoAPI_Section::BRepAlgoAPI_Section(const TopoDS_Shape& Sh1, - const TopoDS_Shape& Sh2, - const Standard_Boolean PerformNow) -: BRepAlgoAPI_BooleanOperation(Sh1, Sh2, BOP_SECTION) + const TopoDS_Shape& Sh2, + const Standard_Boolean PerformNow) +: BRepAlgoAPI_BooleanOperation(Sh1, Sh2, BOPAlgo_SECTION) { InitParameters(); myparameterschanged = Standard_True; @@ -77,15 +68,16 @@ BRepAlgoAPI_Section::BRepAlgoAPI_Section(const TopoDS_Shape& Sh1, // StdFail_NotDone::Raise("BRepAlgoAPI_Section : Shape NULL"); myshapeisnull = Standard_True; } - if (PerformNow) + if (PerformNow) { Build(); + } } BRepAlgoAPI_Section::BRepAlgoAPI_Section(const TopoDS_Shape& aS1, - const TopoDS_Shape& aS2, - const BOPTools_DSFiller& aDSF, - const Standard_Boolean PerformNow) -: BRepAlgoAPI_BooleanOperation(aS1, aS2, aDSF, BOP_SECTION) + const TopoDS_Shape& aS2, + const BOPAlgo_PaveFiller& aDSF, + const Standard_Boolean PerformNow) +: BRepAlgoAPI_BooleanOperation(aS1, aS2, aDSF, BOPAlgo_SECTION) { InitParameters(); myparameterschanged = Standard_True; @@ -95,7 +87,7 @@ BRepAlgoAPI_Section::BRepAlgoAPI_Section(const TopoDS_Shape& aS1, myshapeisnull = Standard_True; } - if(PerformNow) { + if (PerformNow) { Build(); } } @@ -106,9 +98,9 @@ BRepAlgoAPI_Section::BRepAlgoAPI_Section(const TopoDS_Shape& aS1, //purpose : //======================================================================= BRepAlgoAPI_Section::BRepAlgoAPI_Section(const TopoDS_Shape& Sh, - const gp_Pln& Pl, - const Standard_Boolean PerformNow) -: BRepAlgoAPI_BooleanOperation(Sh, MakeShape(new Geom_Plane(Pl)), BOP_SECTION) + const gp_Pln& Pl, + const Standard_Boolean PerformNow) +: BRepAlgoAPI_BooleanOperation(Sh, MakeShape(new Geom_Plane(Pl)), BOPAlgo_SECTION) { InitParameters(); myparameterschanged = Standard_True; @@ -117,8 +109,9 @@ BRepAlgoAPI_Section::BRepAlgoAPI_Section(const TopoDS_Shape& Sh, // StdFail_NotDone::Raise("BRepAlgoAPI_Section : Shape NULL"); myshapeisnull = Standard_True; } - if (PerformNow) + if (PerformNow) { Build(); + } } //======================================================================= @@ -126,9 +119,9 @@ BRepAlgoAPI_Section::BRepAlgoAPI_Section(const TopoDS_Shape& Sh, //purpose : //======================================================================= BRepAlgoAPI_Section::BRepAlgoAPI_Section(const TopoDS_Shape& Sh, - const Handle(Geom_Surface)& Sf, - const Standard_Boolean PerformNow) -: BRepAlgoAPI_BooleanOperation(Sh, MakeShape(Sf), BOP_SECTION) + const Handle(Geom_Surface)& Sf, + const Standard_Boolean PerformNow) +: BRepAlgoAPI_BooleanOperation(Sh, MakeShape(Sf), BOPAlgo_SECTION) { InitParameters(); myparameterschanged = Standard_True; @@ -137,8 +130,9 @@ BRepAlgoAPI_Section::BRepAlgoAPI_Section(const TopoDS_Shape& Sh, // StdFail_NotDone::Raise("BRepAlgoAPI_Section : Shape NULL"); myshapeisnull = Standard_True; } - if (PerformNow) + if (PerformNow) { Build(); + } } //======================================================================= @@ -146,9 +140,9 @@ BRepAlgoAPI_Section::BRepAlgoAPI_Section(const TopoDS_Shape& Sh, //purpose : //======================================================================= BRepAlgoAPI_Section::BRepAlgoAPI_Section(const Handle(Geom_Surface)& Sf, - const TopoDS_Shape& Sh, - const Standard_Boolean PerformNow) -: BRepAlgoAPI_BooleanOperation(MakeShape(Sf), Sh, BOP_SECTION) + const TopoDS_Shape& Sh, + const Standard_Boolean PerformNow) +: BRepAlgoAPI_BooleanOperation(MakeShape(Sf), Sh, BOPAlgo_SECTION) { InitParameters(); myparameterschanged = Standard_True; @@ -157,8 +151,9 @@ BRepAlgoAPI_Section::BRepAlgoAPI_Section(const Handle(Geom_Surface)& Sf, // StdFail_NotDone::Raise("BRepAlgoAPI_Section : Shape NULL"); myshapeisnull = Standard_True; } - if (PerformNow) + if (PerformNow) { Build(); + } } //======================================================================= @@ -166,9 +161,9 @@ BRepAlgoAPI_Section::BRepAlgoAPI_Section(const Handle(Geom_Surface)& Sf, //purpose : //======================================================================= BRepAlgoAPI_Section::BRepAlgoAPI_Section(const Handle(Geom_Surface)& Sf1, - const Handle(Geom_Surface)& Sf2, - const Standard_Boolean PerformNow) -: BRepAlgoAPI_BooleanOperation(MakeShape(Sf1), MakeShape(Sf2), BOP_SECTION) + const Handle(Geom_Surface)& Sf2, + const Standard_Boolean PerformNow) +: BRepAlgoAPI_BooleanOperation(MakeShape(Sf1), MakeShape(Sf2), BOPAlgo_SECTION) { InitParameters(); myparameterschanged = Standard_True; @@ -178,8 +173,9 @@ BRepAlgoAPI_Section::BRepAlgoAPI_Section(const Handle(Geom_Surface)& Sf1, myshapeisnull = Standard_True; } - if (PerformNow) + if (PerformNow) { Build(); + } } //======================================================================= @@ -193,7 +189,7 @@ void BRepAlgoAPI_Section::Init1(const TopoDS_Shape& S1) myS1 = S1; if(!myS2.IsNull()) { - myshapeisnull = Standard_False; + myshapeisnull = Standard_False; } myparameterschanged = Standard_True; } @@ -239,7 +235,7 @@ void BRepAlgoAPI_Section::Init2(const TopoDS_Shape& S2) myS2 = S2; if(!myS1.IsNull()) { - myshapeisnull = Standard_False; + myshapeisnull = Standard_False; } myparameterschanged = Standard_True; } @@ -324,9 +320,6 @@ void BRepAlgoAPI_Section::Build() } if(myparameterschanged) { - - myBuilderCanWork = Standard_False; - Standard_Boolean bIsNewFiller = PrepareFiller(); // if (myErrorStatus!=1) { @@ -336,30 +329,13 @@ void BRepAlgoAPI_Section::Build() } // if (bIsNewFiller) { - //Prepare the DS - BOPTools_SSIntersectionAttribute aSectionAttribute(myApprox, myComputePCurve1, myComputePCurve2); - myDSFiller->Perform(aSectionAttribute); - } - BOP_Section* aSectionAlgo = new BOP_Section(); - aSectionAlgo->SetShapes(myS1, myS2); - - myHistory = new BOP_SectionHistoryCollector(myS1, myS2); - aSectionAlgo->SetHistoryCollector(myHistory); - - aSectionAlgo->DoWithFiller(*myDSFiller); - - myBuilder = aSectionAlgo; - - if(aSectionAlgo->IsDone()) { - myErrorStatus=0; - myBuilderCanWork=Standard_True; - myShape = aSectionAlgo->Result(); - Done(); + BOPAlgo_SectionAttribute theSecAttr(myApprox, myComputePCurve1, myComputePCurve2); + myDSFiller->SetSectionAttribute(theSecAttr); + myDSFiller->Perform(); } - else { - myErrorStatus = 100 + aSectionAlgo->ErrorStatus(); - NotDone(); - } + // + BRepAlgoAPI_BooleanOperation::Build(); + // myparameterschanged = Standard_False; } } @@ -379,7 +355,7 @@ Standard_Boolean BRepAlgoAPI_Section::HasAncestorFaceOn1(const TopoDS_Shape& E, return aResult; } TopoDS_Shape F1, F2; - aResult = HasAncestorFaces(*myDSFiller, E, F1, F2); + aResult = HasAncestorFaces(myDSFiller, E, F1, F2); if(F1.IsNull()) { return Standard_False; @@ -403,7 +379,7 @@ Standard_Boolean BRepAlgoAPI_Section::HasAncestorFaceOn2(const TopoDS_Shape& E,T return aResult; } TopoDS_Shape F1, F2; - aResult = HasAncestorFaces(*myDSFiller, E, F1, F2); + aResult = HasAncestorFaces(myDSFiller, E, F1, F2); if(F2.IsNull()) { return Standard_False; @@ -430,7 +406,7 @@ Handle(Geom2d_Curve) BRepAlgoAPI_Section::PCurveOn1(const TopoDS_Shape& E) const aResult = BRep_Tool::CurveOnSurface(anEdge, aFace, f, l); if(!aResult->IsKind(STANDARD_TYPE(Geom2d_TrimmedCurve))) { - aResult = new Geom2d_TrimmedCurve(aResult, f, l); + aResult = new Geom2d_TrimmedCurve(aResult, f, l); } } } @@ -455,7 +431,7 @@ Handle(Geom2d_Curve) BRepAlgoAPI_Section::PCurveOn2(const TopoDS_Shape& E) const aResult = BRep_Tool::CurveOnSurface(anEdge, aFace, f, l); if(!aResult->IsKind(STANDARD_TYPE(Geom2d_TrimmedCurve))) { - aResult = new Geom2d_TrimmedCurve(aResult, f, l); + aResult = new Geom2d_TrimmedCurve(aResult, f, l); } } } @@ -479,69 +455,59 @@ void BRepAlgoAPI_Section::InitParameters() // static function : HasAncestorFaces // purpose : // ------------------------------------------------------------------------ -static Standard_Boolean HasAncestorFaces(const BOPTools_DSFiller& theDSFiller, - const TopoDS_Shape& E, - TopoDS_Shape& F1, - TopoDS_Shape& F2) { - - BOPTools_PaveFiller* aPaveFiller = (BOPTools_PaveFiller*) &theDSFiller.PaveFiller(); - const BOPTools_CArray1OfSSInterference& aFFs = aPaveFiller->InterfPool()->SSInterferences(); - const BooleanOperations_ShapesDataStructure& aDS = theDSFiller.DS(); - Standard_Integer aNb = aFFs.Extent(); - Standard_Integer i = 0; - - for (i = 1; i <= aNb; i++) { - BOPTools_SSInterference* aFFi = (BOPTools_SSInterference*) &aFFs(i); - const BOPTools_SequenceOfCurves& aSeqOfCurve = aFFi->Curves(); - - for(Standard_Integer j = 1; j <= aSeqOfCurve.Length(); j++) { - const BOPTools_Curve& aCurve = aSeqOfCurve.Value(j); - BOPTools_ListIteratorOfListOfPaveBlock anIt(aCurve.NewPaveBlocks()); +static Standard_Boolean HasAncestorFaces(const BOPAlgo_PPaveFiller& theDSFiller, + const TopoDS_Shape& E, + TopoDS_Shape& F1, + TopoDS_Shape& F2) { + + Standard_Integer aNb, i, j, nE, nF1, nF2, aNbCurves;; + // + const BOPDS_PDS& pDS = theDSFiller->PDS(); + BOPDS_VectorOfInterfFF& aFFs=pDS->InterfFF(); + // + aNb=aFFs.Extent(); + + for (i = 0; i < aNb; i++) { + BOPDS_InterfFF& aFFi=aFFs(i); + aFFi.Indices(nF1, nF2); + // + //section edges + const BOPDS_VectorOfCurve& aSeqOfCurve=aFFi.Curves(); + aNbCurves=aSeqOfCurve.Extent(); + for (j=0; jIndex1() : aFFi->Index2(); - - if(anIndex > 0) { - if (fIt == 0) - F1 = aDS.Shape(anIndex); - else - F2 = aDS.Shape(anIndex); - } - } - return Standard_True; - } + const Handle(BOPDS_PaveBlock)& aPB = anIt.Value(); + nE = aPB->Edge(); + if(nE < 0) continue; + // + if(E.IsSame(pDS->Shape(nE))) { + F1 = pDS->Shape(nF1); + F2 = pDS->Shape(nF2); + return Standard_True; + } } } - BOPTools_ListIteratorOfListOfPaveBlock anIt(aFFi->PaveBlocks()); - - for(; anIt.More(); anIt.Next()) { - const BOPTools_PaveBlock& aPB = anIt.Value(); - Standard_Integer anIndex = aPB.Edge(); - - if(anIndex <= 0) - continue; - - if(E.IsSame(aDS.Shape(anIndex))) { - for(Standard_Integer fIt = 0; fIt < 2; fIt++) { - anIndex = (fIt == 0) ? aFFi->Index1() : aFFi->Index2(); - - if(anIndex > 0) { - if (fIt == 0) - F1 = aDS.Shape(anIndex); - else - F2 = aDS.Shape(anIndex); - } - } - return Standard_True; + //existing pave blocks + BOPCol_ListOfInteger aLSE; + BOPCol_ListIteratorOfListOfInteger aItLSE; + // + pDS->SharedEdges(nF1, nF2, aLSE, theDSFiller->Allocator()); + aItLSE.Initialize(aLSE); + for (; aItLSE.More(); aItLSE.Next()) { + nE = aItLSE.Value(); + // + if(E.IsSame(pDS->Shape(nE))) { + F1 = pDS->Shape(nF1); + F2 = pDS->Shape(nF2); + return Standard_True; } } } diff --git a/src/BRepFeat/BRepFeat.cdl b/src/BRepFeat/BRepFeat.cdl index 54a38d8b82..53f28c129c 100755 --- a/src/BRepFeat/BRepFeat.cdl +++ b/src/BRepFeat/BRepFeat.cdl @@ -22,49 +22,49 @@ package BRepFeat - ---Purpose: BRepFeat is necessary for the - -- creation and manipulation of both form and mechanical features in a - -- Boundary Representation framework. Form features can be depressions or - -- protrusions and include the following types: - -- - Cylinder - -- - Draft Prism - -- - Prism - -- - Revolved feature - -- - Pipe - -- Depending on whether you wish to make a depression or a protrusion, - -- you can choose your operation type between the following: - -- - removing matter (a Boolean cut: Fuse setting 0) - -- - adding matter (Boolean fusion: Fuse setting 1) - -- The semantics of form feature creation is based on the - -- construction of shapes: - -- - for a certain length in a certain direction - -- - up to a limiting face - -- - from a limiting face at a height - -- - above and/or below a plane - -- The shape defining the construction of a feature can be either a - -- supporting edge or a concerned area of a face. - -- In case of supporting edge, this contour can be attached to a face - -- of the basis shape by binding. When the contour is bound to this face, - -- the information that the contour will slide on the face becomes - -- available to the relevant class methods. In case of the concerned - -- area of a face, you could, for example, cut it out and move it at - -- a different height, which will define the limiting face of a - -- protrusion or depression. Topological definition with local - -- operations of this sort makes calculations simpler and faster - -- than a global operation. The latter would entail a second phase of - -- removing unwanted matter to get the same result. - -- Mechanical features include ribs - protrusions - and grooves (or - -- slots) - depressions along planar (linear) surfaces or revolution surfaces. - -- The semantics of mechanical features is based on giving - -- thickness to a contour. This thickness can either be unilateral - -- - on one side of the contour - or bilateral - on both sides. As in - -- the semantics of form features, the thickness is defined by - -- construction of shapes in specific contexts. - -- However, in case of mechanical features, development contexts - -- differ. Here they include extrusion: - -- - to a limiting face of the basis shape - -- - to or from a limiting plane - -- - to a height. + ---Purpose: BRepFeat is necessary for the + -- creation and manipulation of both form and mechanical features in a + -- Boundary Representation framework. Form features can be depressions or + -- protrusions and include the following types: + -- - Cylinder + -- - Draft Prism + -- - Prism + -- - Revolved feature + -- - Pipe + -- Depending on whether you wish to make a depression or a protrusion, + -- you can choose your operation type between the following: + -- - removing matter (a Boolean cut: Fuse setting 0) + -- - adding matter (Boolean fusion: Fuse setting 1) + -- The semantics of form feature creation is based on the + -- construction of shapes: + -- - for a certain length in a certain direction + -- - up to a limiting face + -- - from a limiting face at a height + -- - above and/or below a plane + -- The shape defining the construction of a feature can be either a + -- supporting edge or a concerned area of a face. + -- In case of supporting edge, this contour can be attached to a face + -- of the basis shape by binding. When the contour is bound to this face, + -- the information that the contour will slide on the face becomes + -- available to the relevant class methods. In case of the concerned + -- area of a face, you could, for example, cut it out and move it at + -- a different height, which will define the limiting face of a + -- protrusion or depression. Topological definition with local + -- operations of this sort makes calculations simpler and faster + -- than a global operation. The latter would entail a second phase of + -- removing unwanted matter to get the same result. + -- Mechanical features include ribs - protrusions - and grooves (or + -- slots) - depressions along planar (linear) surfaces or revolution surfaces. + -- The semantics of mechanical features is based on giving + -- thickness to a contour. This thickness can either be unilateral + -- - on one side of the contour - or bilateral - on both sides. As in + -- the semantics of form features, the thickness is defined by + -- construction of shapes in specific contexts. + -- However, in case of mechanical features, development contexts + -- differ. Here they include extrusion: + -- - to a limiting face of the basis shape + -- - to or from a limiting plane + -- - to a height. uses BRepBuilderAPI, LocOpe, @@ -80,53 +80,55 @@ uses BRepBuilderAPI, Geom2dAdaptor, TopAbs, --modified by NIZNHY-PKV Thu Mar 21 18:31:59 2002 f - BRepAlgoAPI, + BRepAlgoAPI, + BOPAlgo, + BOPDS, + BOPCol, + BOPTools + --BOP --modified by NIZNHY-PKV Thu Mar 21 18:32:02 2002 t - BOP - + + is enumeration StatusError is - ---Purpose: Discribes the error. - OK, - BadDirect, - BadIntersect, - EmptyBaryCurve, - EmptyCutResult, - FalseSide, - IncDirection, - IncSlidFace, - IncParameter, - IncTypes, - IntervalOverlap, - InvFirstShape, - InvOption, - InvShape, - LocOpeNotDone, - LocOpeInvNotDone, - NoExtFace, - NoFaceProf, - NoGluer, - NoIntersectF, - NoIntersectU, - NoParts, - NoProjPt, - NotInitialized, - NotYetImplemented, - NullRealTool, - NullToolF, - NullToolU + ---Purpose: Discribes the error. + OK, + BadDirect, + BadIntersect, + EmptyBaryCurve, + EmptyCutResult, + FalseSide, + IncDirection, + IncSlidFace, + IncParameter, + IncTypes, + IntervalOverlap, + InvFirstShape, + InvOption, + InvShape, + LocOpeNotDone, + LocOpeInvNotDone, + NoExtFace, + NoFaceProf, + NoGluer, + NoIntersectF, + NoIntersectU, + NoParts, + NoProjPt, + NotInitialized, + NotYetImplemented, + NullRealTool, + NullToolF, + NullToolU end StatusError; - deferred class Builder; -- inherits MakeShape from BRepBuilderAPI + class Builder; -- inherits BOP from BOPAlgo - class LocalOperation; -- inherits Builder from BRepFeat; - class MakeCylindricalHole; -- inherits Builder from BRepFeat; - class SplitShape; -- inherits MakeShape from BRepBuilderAPI; deferred class Form; -- inherits MakeShape from BRepBuilderAPI; @@ -149,86 +151,86 @@ is enumeration Status is -- to be completed - NoError, - InvalidPlacement, - HoleTooLong + NoError, + InvalidPlacement, + HoleTooLong end Status; enumeration PerfSelection is - NoSelection, - SelectionFU, - SelectionU, - SelectionSh, - SelectionShU - ---Purpose: To declare the type of selection semantics for local operation Perform methods - -- - NoSelection - -- - SelectionFU - selection of a face up to which a - -- local operation will be performed - -- - SelectionU - selection of a point up to which a - -- local operation will be performed - -- - SelectionSh - selection of a shape on which a - -- local operation will be performed - -- - SelectionShU - selection of a shape up to which a - -- local operation will be performed. + NoSelection, + SelectionFU, + SelectionU, + SelectionSh, + SelectionShU + ---Purpose: To declare the type of selection semantics for local operation Perform methods + -- - NoSelection + -- - SelectionFU - selection of a face up to which a + -- local operation will be performed + -- - SelectionU - selection of a point up to which a + -- local operation will be performed + -- - SelectionSh - selection of a shape on which a + -- local operation will be performed + -- - SelectionShU - selection of a shape up to which a + -- local operation will be performed. end PerfSelection; SampleEdges(S : Shape from TopoDS; - Pt: in out SequenceOfPnt from TColgp); + Pt: in out SequenceOfPnt from TColgp); Barycenter(S : Shape from TopoDS; - Pt: in out Pnt from gp); - + Pt: in out Pnt from gp); + ParametricBarycenter(S : Shape from TopoDS; - C : Curve from Geom) - - returns Real from Standard; + C : Curve from Geom) + + returns Real from Standard; ParametricMinMax(S : Shape from TopoDS; - C : Curve from Geom; - prmin : out Real from Standard; - prmax : out Real from Standard; - prbmin: out Real from Standard; - prbmax: out Real from Standard; - flag : out Boolean from Standard; - Ori : Boolean from Standard = Standard_False); - ---Purpose: Ori = True taking account the orientation - + C : Curve from Geom; + prmin : out Real from Standard; + prmax : out Real from Standard; + prbmin: out Real from Standard; + prbmax: out Real from Standard; + flag : out Boolean from Standard; + Ori : Boolean from Standard = Standard_False); + ---Purpose: Ori = True taking account the orientation + IsInside(F1 : Face from TopoDS; - F2 : Face from TopoDS) - - returns Boolean from Standard; + F2 : Face from TopoDS) + + returns Boolean from Standard; IsInOut (FC : FClass2d from BRepTopAdaptor; - AC : Curve from Geom2dAdaptor) + AC : Curve from Geom2dAdaptor) - - returns Boolean from Standard; + + returns Boolean from Standard; -- TangSli(E : Edge from TopoDS; - -- F : Shape from TopoDS) - - -- returns Boolean from Standard; + -- F : Shape from TopoDS) + + -- returns Boolean from Standard; FaceUntil (S : Shape from TopoDS; - F : in out Face from TopoDS); - + F : in out Face from TopoDS); + Tool (SRef : Shape from TopoDS; - Fac : Face from TopoDS; - Orf : Orientation from TopAbs) - - returns Solid from TopoDS; + Fac : Face from TopoDS; + Orf : Orientation from TopAbs) + + returns Solid from TopoDS; Print(SE : StatusError from BRepFeat; S : in out OStream) returns OStream; - ---Purpose: Prints the Error description of the State as a String on - -- the Stream and returns . - -- - ---C++: return & + ---Purpose: Prints the Error description of the State as a String on + -- the Stream and returns . + -- + ---C++: return & end BRepFeat; diff --git a/src/BRepFeat/BRepFeat_Builder.cdl b/src/BRepFeat/BRepFeat_Builder.cdl index 59e8c498e9..a79d786f8e 100755 --- a/src/BRepFeat/BRepFeat_Builder.cdl +++ b/src/BRepFeat/BRepFeat_Builder.cdl @@ -1,6 +1,5 @@ --- Created on: 1995-06-13 --- Created by: Jacques GOUSSARD --- Copyright (c) 1995-1999 Matra Datavision +-- Created on: 2012-06-01 +-- Created by: Eugeny MALTCHIKOV -- Copyright (c) 1999-2012 OPEN CASCADE SAS -- -- The content of this file is subject to the Open CASCADE Technology Public @@ -17,77 +16,130 @@ -- limitation, any warranties of merchantability, fitness for a particular -- purpose or non-infringement. Please see the License for the specific terms -- and conditions governing the rights and limitations under the License. - - - -deferred class Builder from BRepFeat inherits MakeShape from BRepBuilderAPI - - ---Purpose: Provides the implementation of all methods - -- required by BRepCtx for class using a Builder from - -- LocOpe. All features have to inherit from this - -- class. - + +class Builder from BRepFeat + inherits BOP from BOPAlgo + + ---Purpose: Provides a basic tool to implement features topological + -- operations. The main goal of the algorithm is to perform + -- the result of the operation according to the + -- kept parts of the tool. + -- Input data: a) DS; + -- b) The kept parts of the tool; + -- c) Operation required. + -- Steps: a) Fill myShapes, myRemoved maps; + -- b) Rebuild edges and faces; + -- c) Build images of the object; + -- d) Build the result of the operation. + -- Result: Result shape of the operation required. + uses - Builder from LocOpe, - Shape from TopoDS, - Face from TopoDS, - Edge from TopoDS, - MapOfShape from TopTools, - ListOfShape from TopTools, - ShapeModification from BRepBuilderAPI - -raises - NotDone from StdFail, - ConstructionError from Standard - -is - - Initialize; - ---Purpose: Empty constructor. - ---C++: inline - - - Initialize(S: Shape from TopoDS) - ---Purpose: Creates a local operation on . - ---C++: inline - -- Raises ConstructionError if is a null shape. - raises ConstructionError from Standard; - - - Initialize(S,T: Shape from TopoDS) - ---Purpose: Creates a local operation between and . - ---C++: inline - -- Raises ConstructionError if is a null shape - raises ConstructionError from Standard; - - - Init(me: in out; S: Shape from TopoDS) - ---Purpose: Initializes a local operation on . - ---C++: inline - raises ConstructionError from Standard - --- The exception is raised if is a null shape. - is static; - - Init(me: in out; S,T: Shape from TopoDS) - ---Purpose: Initializes a local operation between and . - -- Raises ConstructionError if is a null shape. - ---C++: inline - raises ConstructionError from Standard - is static; - - - ---- Methods inherited from MakeShape, that must be redefined. - - Modified(me: in out; F: Shape from TopoDS) - ---Purpose: Returns the list of generated Faces. - ---C++: return const & - returns ListOfShape from TopTools - is redefined static; + Shape from TopoDS, + Face from TopoDS, + ListOfShape from TopTools, + MapOfOrientedShape from BOPCol, + MapOfShape from BOPCol, + IndexedMapOfShape from BOPCol, + DataMapOfShapeListOfShape from BOPCol, + DataMapOfShapeShape from BOPCol, + BaseAllocator from BOPCol, + ListOfShape from BOPCol, + BOP from BOPAlgo + +is + Create + returns Builder from BRepFeat; + ---C++: alias "Standard_EXPORT virtual ~BRepFeat_Builder();" + + Clear(me:out) + is redefined; + ---Purpose: Clears internal fields and arguments. + + Init(me:out; + theShape : Shape from TopoDS); + ---Purpose: Initialyzes the object of local boolean operation. + -- + + Init(me:out; + theShape : Shape from TopoDS; + theTool : Shape from TopoDS); + ---Purpose: Initialyzes the arguments of local boolean operation. + -- + + SetOperation(me:out; + theFuse : Integer from Standard); + ---Purpose: Sets the operation of local boolean operation. + -- If theFuse = 0 than the operation is CUT, otherwise FUSE. + + SetOperation(me:out; + theFuse : Integer from Standard; + theFlag : Boolean from Standard); + ---Purpose: Sets the operation of local boolean operation. + -- If theFlag = TRUE it means that no selection of parts + -- of the tool is needed, t.e. no second part. In that case + -- if theFuse = 0 than operation is COMMON, otherwise CUT21. + -- If theFlag = FALSE SetOperation(theFuse) function is called. -fields - - myBuilder : Builder from LocOpe is protected; - myMap : MapOfShape from TopTools is protected; - myGenFaces: ListOfShape from TopTools is protected; + Prepare(me:out) + is redefined protected; + ---Purpose: Prepares builder of local operation. + -- + + PartsOfTool(me:out; + theLT : out ListOfShape from TopTools); + ---Purpose: Collects parts of the tool. + + KeepParts(me:out; + theIm : ListOfShape from TopTools); + ---Purpose: Initialyzes parts of the tool for second step of algorithm. + -- Collects shapes and all sub-shapes into myShapes map. + + KeepPart(me:out; + theS : Shape from TopoDS); + ---Purpose: Adds shape theS and all its sub-shapes into myShapes map. + -- + + PerformResult(me:out); + ---Purpose: Main function to build the result of the + -- local operation required. + + RebuildFaces(me:out); + ---Purpose: Rebuilds faces in accordance with the kept parts of the tool. + -- + + RebuildEdge(me:out; + theE:Shape from TopoDS; + theF:Face from TopoDS; + theME:MapOfShape from BOPCol; + aLEIm:out ListOfShape from BOPCol); + ---Purpose: Rebuilds edges in accordance with the kept parts of the tool. + -- + + CheckSolidImages(me:out); + ---Purpose: Collects the images of the object, that contains in + -- the images of the tool. + + FillRemoved(me:out); + ---Purpose: Collects the removed parts of the tool into myRemoved map. + -- + + FillRemoved(me:out; + theS : Shape from TopoDS; + theM : in out MapOfShape from BOPCol); + ---Purpose: Adds the shape S and its sub-shapes into myRemoved map. + -- + + FillIn3DParts(me:out; + theInParts:out DataMapOfShapeListOfShape from BOPCol; + theDraftSolids:out DataMapOfShapeShape from BOPCol; + theAllocator:BaseAllocator from BOPCol) + is redefined protected; + ---Purpose: Function is redefined to avoid the usage of removed faces. + -- + +fields + myShapes : MapOfShape from BOPCol is protected; + myRemoved : MapOfShape from BOPCol is protected; + myFuse : Integer from Standard is protected; + end Builder; diff --git a/src/BRepFeat/BRepFeat_Builder.cxx b/src/BRepFeat/BRepFeat_Builder.cxx index 4f7dfc487a..7f98b689c7 100755 --- a/src/BRepFeat/BRepFeat_Builder.cxx +++ b/src/BRepFeat/BRepFeat_Builder.cxx @@ -1,6 +1,5 @@ -// Created on: 1995-06-13 -// Created by: Jacques GOUSSARD -// Copyright (c) 1995-1999 Matra Datavision +// Created on: 2012-06-01 +// Created by: Eugeny MALTCHIKOV // Copyright (c) 1999-2012 OPEN CASCADE SAS // // The content of this file is subject to the Open CASCADE Technology Public @@ -19,31 +18,959 @@ // and conditions governing the rights and limitations under the License. - #include -#include -#include +#include + +#include +#include +#include + +#include #include -#include +#include + +#include +#include + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include + +//======================================================================= +//function : +//purpose : +//======================================================================= + BRepFeat_Builder::BRepFeat_Builder() +: + BOPAlgo_BOP() +{ + Clear(); +} + +//======================================================================= +//function : ~ +//purpose : +//======================================================================= + BRepFeat_Builder::~BRepFeat_Builder() +{ +} + +//======================================================================= +//function : Clear +//purpose : +//======================================================================= + void BRepFeat_Builder::Clear() +{ + myShapes.Clear(); + myRemoved.Clear(); + BOPAlgo_BOP::Clear(); +} + +//======================================================================= +//function : Init +//purpose : +//======================================================================= + void BRepFeat_Builder::Init(const TopoDS_Shape& theShape) +{ + Clear(); + // + AddArgument(theShape); +} + +//======================================================================= +//function : Init +//purpose : +//======================================================================= + void BRepFeat_Builder::Init(const TopoDS_Shape& theShape, + const TopoDS_Shape& theTool) +{ + Clear(); + // + AddArgument(theShape); + AddTool(theTool); +} + +//======================================================================= +//function : SetOperation +//purpose : +//======================================================================= + void BRepFeat_Builder::SetOperation(const Standard_Integer theFuse) +{ + myFuse = theFuse; + myOperation = myFuse ? BOPAlgo_FUSE : BOPAlgo_CUT; +} + +//======================================================================= +//function : SetOperation +//purpose : +//======================================================================= + void BRepFeat_Builder::SetOperation(const Standard_Integer theFuse, + const Standard_Boolean theFlag) +{ + myFuse = theFuse; + if (!theFlag) { + myOperation = myFuse ? BOPAlgo_FUSE : BOPAlgo_CUT; + } else { + myOperation = myFuse ? BOPAlgo_CUT21 : BOPAlgo_COMMON; + } +} + +//======================================================================= +//function : PartsOfTool +//purpose : +//======================================================================= + void BRepFeat_Builder::PartsOfTool(TopTools_ListOfShape& aLT) +{ + TopExp_Explorer aExp; + // + aLT.Clear(); + aExp.Init(myShape, TopAbs_SOLID); + for (;aExp.More(); aExp.Next()) { + const TopoDS_Shape& aS = aExp.Current(); + aLT.Append(aS); + } +} + +//======================================================================= +//function : KeepPartsOfTool +//purpose : +//======================================================================= + void BRepFeat_Builder::KeepParts(const TopTools_ListOfShape& theIm) +{ + TopTools_ListIteratorOfListOfShape aItT; + aItT.Initialize(theIm); + for (; aItT.More(); aItT.Next()) { + const TopoDS_Shape& aTIm=aItT.Value(); + KeepPart(aTIm); + } +} + +//======================================================================= +//function : KeepPart +//purpose : +//======================================================================= + void BRepFeat_Builder::KeepPart(const TopoDS_Shape& thePart) +{ + TopoDS_Shape aF, aFOr; + TopExp_Explorer aExp; + // + BOPTools::MapShapes(thePart, myShapes); +} + +//======================================================================= +//function : Prepare +//purpose : +//======================================================================= + void BRepFeat_Builder::Prepare() +{ + myErrorStatus=0; + // + BRep_Builder aBB; + TopoDS_Compound aC; + aBB.MakeCompound(aC); + myShape=aC; + // + myFlagHistory=Standard_True; + // + FillRemoved(); +} + +//======================================================================= +//function : FillRemoved +//purpose : +//======================================================================= + void BRepFeat_Builder::FillRemoved() +{ + TopExp_Explorer aExp; + aExp.Init(myArgs[0], TopAbs_SOLID); + for (; aExp.More(); aExp.Next()) { + const TopoDS_Shape& aS = aExp.Current(); + myImages.UnBind(aS); + } + // + if (!myImages.IsBound(myArgs[1])) { + return; + } + // + BOPCol_ListIteratorOfListOfShape aItIm; + // + BOPCol_ListOfShape& aLS = myImages.ChangeFind(myArgs[1]); + aItIm.Initialize(aLS); + for (; aItIm.More(); aItIm.Next()) { + const TopoDS_Shape& aS = aItIm.Value(); + FillRemoved(aS, myRemoved); + } +} //======================================================================= -//function : Modified +//function : PerformResult //purpose : //======================================================================= + void BRepFeat_Builder::PerformResult() +{ + myOperation = myFuse ? BOPAlgo_FUSE : BOPAlgo_CUT; + // + Prepare(); + // + RebuildFaces(); + // + FillImagesContainers(TopAbs_SHELL); + if (myErrorStatus) { + return; + } + // + FillImagesSolids(); + if (myErrorStatus) { + return; + } + // + CheckSolidImages(); + // + BuildResult(TopAbs_SOLID); + if (myErrorStatus) { + return; + } + // + FillImagesCompounds(); + if (myErrorStatus) { + return; + } + // + BuildResult(TopAbs_COMPOUND); + if (myErrorStatus) { + return; + } + // + BuildShape(); +} -const TopTools_ListOfShape& BRepFeat_Builder::Modified - (const TopoDS_Shape& F) +//======================================================================= +//function : RebuildFaces +//purpose : +//======================================================================= + void BRepFeat_Builder::RebuildFaces() { - myGenerated.Clear(); - TopTools_ListIteratorOfListOfShape it; - const Handle(BOP_HistoryCollector)& B = myBuilder.History(); - const TopTools_ListOfShape& aLM=B->Modified(F); - it.Initialize(aLM); - for (; it.More(); it.Next()) { - myGenerated.Append(it.Value()); + Standard_Integer aNbS, i, iRank, nSp; + Standard_Boolean bIsClosed, bIsDegenerated, bToReverse, + bRem, bIm, bFlagSD, bVInShapes; + TopAbs_Orientation anOriF, anOriE; + TopoDS_Face aFF, aFSD; + TopoDS_Edge aSp; + TopoDS_Shape aSx; + TopExp_Explorer aExp, aExpE; + BOPCol_MapOfShape aME, aMESplit; + BOPCol_ListIteratorOfListOfShape aItIm; + BOPDS_MapIteratorOfMapOfPaveBlock aItMPB; + BOPCol_MapIteratorOfMapOfShape aItM; + BOPTools_MapOfSet aMST; + BOPCol_ListOfShape aLE; + // + aItM.Initialize(myShapes); + for (; aItM.More(); aItM.Next()) { + const TopoDS_Shape& aS = aItM.Value(); + if (aS.ShapeType() == TopAbs_FACE) { + BOPTools_Set aST; + aST.Add(aS, TopAbs_EDGE); + aMST.Add(aST); + } + } + // + aNbS=myDS->NbSourceShapes(); + for (i=0; iShapeInfo(i); + // + iRank = myDS->Rank(i); + if (iRank == 1) { + const TopoDS_Shape& aS = aSI.Shape(); + // + if (myImages.IsBound(aS)) { + BOPCol_ListOfShape& aLIm = myImages.ChangeFind(aS); + aItIm.Initialize(aLIm); + for (; aItIm.More(); ) { + const TopoDS_Shape& aSIm = aItIm.Value(); + if (!myShapes.Contains(aSIm)) { + aLIm.Remove(aItIm); + continue; + } + aItIm.Next(); + } + } + continue; + } + // + if (aSI.ShapeType()!=TopAbs_FACE) { + continue; + } + // + const BOPDS_FaceInfo& aFI=myDS->FaceInfo(i); + const TopoDS_Face& aF=(*(TopoDS_Face*)(&aSI.Shape())); + // + if (!myImages.IsBound(aF)) { + continue; + } + // + anOriF=aF.Orientation(); + aFF=aF; + aFF.Orientation(TopAbs_FORWARD); + + const BOPDS_MapOfPaveBlock& aMPBIn=aFI.PaveBlocksIn(); + const BOPDS_MapOfPaveBlock& aMPBSc=aFI.PaveBlocksSc(); + + aLE.Clear(); + + //bounding edges + aExp.Init(aFF, TopAbs_EDGE); + for (; aExp.More(); aExp.Next()) { + const TopoDS_Edge& aE=(*(TopoDS_Edge*)(&aExp.Current())); + anOriE=aE.Orientation(); + bIsDegenerated=BRep_Tool::Degenerated(aE); + bIsClosed=BRep_Tool::IsClosed(aE, aF); + if (myImages.IsBound(aE)) { + BOPCol_ListOfShape& aLEIm = myImages.ChangeFind(aE); + // + bRem = Standard_False; + bIm = Standard_False; + aME.Clear(); + BOPCol_ListOfShape aLEImNew; + // + aItIm.Initialize(aLEIm); + for (; aItIm.More(); aItIm.Next()) { + const TopoDS_Shape& aS = aItIm.Value(); + + bVInShapes = Standard_False; + if (myShapes.Contains(aS)) { + bVInShapes = Standard_True; + } else { + aExpE.Init(aS, TopAbs_VERTEX); + for(;aExpE.More(); aExpE.Next()) { + const TopoDS_Shape& aV = aExpE.Current(); + if (myShapes.Contains(aV)) { + bVInShapes = Standard_True; + break; + } + } + } + // + if (bVInShapes) { + bIm = Standard_True; + aLEImNew.Append(aS); + } else { + bRem = Standard_True; + aME.Add(aS); + } + } + // + if (!bRem && !bIm) { + aLE.Append(aE); + continue; + } + // + if (bRem && !bIm) { + aLE.Append(aE); + continue; + } + // + if (bRem && bIm) { + if (aLEIm.Extent() == 2) { + aLE.Append(aE); + continue; + } + if (aMESplit.Add(aE)) { + RebuildEdge(aE, aFF, aME, aLEImNew); + aLEIm.Assign(aLEImNew); + if (aLEIm.Extent() == 1) { + aLE.Append(aE); + continue; + } + } + } + // + aItIm.Initialize(aLEIm); + for (; aItIm.More(); aItIm.Next()) { + aSp = *(TopoDS_Edge*)&aItIm.Value(); + + if (bIsDegenerated) { + aSp.Orientation(anOriE); + aLE.Append(aSp); + continue; + } + // + if (anOriE==TopAbs_INTERNAL) { + aSp.Orientation(TopAbs_FORWARD); + aLE.Append(aSp); + aSp.Orientation(TopAbs_REVERSED); + aLE.Append(aSp); + continue; + } + // + if (bIsClosed) { + if (!BRep_Tool::IsClosed(aSp, aFF)){ + BOPTools_AlgoTools3D::DoSplitSEAMOnFace(aSp, aFF); + } + // + aSp.Orientation(TopAbs_FORWARD); + aLE.Append(aSp); + aSp.Orientation(TopAbs_REVERSED); + aLE.Append(aSp); + continue; + }// if (bIsClosed){ + // + aSp.Orientation(anOriE); + bToReverse=BOPTools_AlgoTools::IsSplitToReverse(aSp, aE, myContext); + if (bToReverse) { + aSp.Reverse(); + } + aLE.Append(aSp); + } + } + else { + aLE.Append(aE); + } + } + + //in edges + aItMPB.Initialize(aMPBIn); + for (; aItMPB.More(); aItMPB.Next()) { + const Handle(BOPDS_PaveBlock)& aPB=aItMPB.Value(); + nSp=aPB->Edge(); + aSp=(*(TopoDS_Edge*)(&myDS->Shape(nSp))); + if (myRemoved.Contains(aSp)) { + continue; + } + // + aSp.Orientation(TopAbs_FORWARD); + aLE.Append(aSp); + aSp.Orientation(TopAbs_REVERSED); + aLE.Append(aSp); + } + //section edges + aItMPB.Initialize(aMPBSc); + for (; aItMPB.More(); aItMPB.Next()) { + const Handle(BOPDS_PaveBlock)& aPB=aItMPB.Value(); + nSp=aPB->Edge(); + aSp=(*(TopoDS_Edge*)(&myDS->Shape(nSp))); + if (myRemoved.Contains(aSp)) { + continue; + } + // + aSp.Orientation(TopAbs_FORWARD); + aLE.Append(aSp); + aSp.Orientation(TopAbs_REVERSED); + aLE.Append(aSp); + } + + //build new faces + BOPAlgo_BuilderFace aBF; + aBF.SetFace(aFF); + aBF.SetShapes(aLE); + + aBF.Perform(); + + BOPCol_ListOfShape& aLFIm = myImages.ChangeFind(aF); + aLFIm.Clear(); + + const BOPCol_ListOfShape& aLFR=aBF.Areas(); + aItIm.Initialize(aLFR); + for (; aItIm.More(); aItIm.Next()) { + TopoDS_Shape& aFR=aItIm.ChangeValue(); + // + BOPTools_Set aST; + aST.Add(aFR, TopAbs_EDGE); + bFlagSD=aMST.Contains(aST); + // + const BOPTools_Set& aSTx=aMST.Added(aST); + aSx=aSTx.Shape(); + aSx.Orientation(anOriF); + aLFIm.Append(aSx); + myOrigins.Bind(aSx, aF); + // + if (bFlagSD) { + myShapesSD.Bind(aFR, aSx); + } + } + // + mySplits.Bind(aF, aLFIm); + if (aLFIm.Extent() == 0) { + mySplits.UnBind(aF); + myImages.UnBind(aF); + } } - return myGenerated; } +//======================================================================= +//function : RebuildEdge +//purpose : +//======================================================================= + void BRepFeat_Builder::RebuildEdge(const TopoDS_Shape& theE, + const TopoDS_Face& theF, + const BOPCol_MapOfShape& aME, + BOPCol_ListOfShape& aLIm) +{ + Standard_Integer nE, nSp, nV1, nV2, nE1, nV, nVx, nVSD; + Standard_Integer nV11, nV21; + Standard_Real aT11, aT21; + Standard_Real aT1, aT2; + TopoDS_Edge aSp, aE; + BOPDS_ShapeInfo aSI; + TopoDS_Vertex aV1, aV2; + Handle(BOPDS_PaveBlock) aPBNew; + BOPCol_MapOfInteger aMI, aMAdd, aMV, aMVOr; + BOPDS_ListIteratorOfListOfPaveBlock aItPB; + BOPCol_ListIteratorOfListOfShape aIt; + BOPCol_ListIteratorOfListOfInteger aItLI; + BOPCol_MapIteratorOfMapOfShape aItM; + BOPDS_MapOfPaveBlock aMPB; + BOPDS_MapIteratorOfMapOfPaveBlock aItMPB; + // + aSI.SetShapeType(TopAbs_EDGE); + + //1. collect origin vertices to aMV map. + nE = myDS->Index(theE); + const BOPDS_ShapeInfo& aSIE = myDS->ShapeInfo(nE); + const BOPCol_ListOfInteger& aLS = aSIE.SubShapes(); + aItLI.Initialize(aLS); + for(; aItLI.More(); aItLI.Next()) { + nV = aItLI.Value(); + nVx=nV; + if (myDS->HasShapeSD(nV, nVSD)) { + nVx=nVSD; + } + aMV.Add(nVx); + aMVOr.Add(nVx); + } + // + //2. collect vertices that should be removed to aMI map. + aPBNew = new BOPDS_PaveBlock; + BOPDS_ListOfPave& aLPExt = aPBNew->ChangeExtPaves(); + BOPDS_ListOfPaveBlock& aLPB = myDS->ChangePaveBlocks(nE); + // + for (aItPB.Initialize(aLPB); aItPB.More(); aItPB.Next()) { + const Handle(BOPDS_PaveBlock)& aPB = aItPB.Value(); + nE1 = aPB->Edge(); + const TopoDS_Shape& aE1 = myDS->Shape(nE1); + // + if (aME.Contains(aE1)) { + aPB->Indices(nV1, nV2); + aMI.Add(nV1); + aMI.Add(nV2); + } + else { + aMPB.Add(aPB); + } + } + //3. collect vertices that split the source shape. + for (aItPB.Initialize(aLPB); aItPB.More(); aItPB.Next()) { + const Handle(BOPDS_PaveBlock)& aPB = aItPB.Value(); + aPB->Indices(nV1, nV2); + // + if (!aMI.Contains(nV1)) { + aMV.Add(nV1); + } + if (!aMI.Contains(nV2)) { + aMV.Add(nV2); + } + } + //4. collect ext paves. + for (aItPB.Initialize(aLPB); aItPB.More(); aItPB.Next()) { + const Handle(BOPDS_PaveBlock)& aPB = aItPB.Value(); + aPB->Indices(nV1, nV2); + // + if (aMV.Contains(nV1)) { + if (aMAdd.Add(nV1) || aMVOr.Contains(nV1)) { + aLPExt.Append(aPB->Pave1()); + } + } + // + if (aMV.Contains(nV2)) { + if (aMAdd.Add(nV2) || aMVOr.Contains(nV2)) { + aLPExt.Append(aPB->Pave2()); + } + } + } + + aE = (*(TopoDS_Edge *)(&theE)); + aE.Orientation(TopAbs_FORWARD); + // + aLIm.Clear(); + // + //5. split edge by new set of vertices. + aLPB.Clear(); + aPBNew->SetOriginalEdge(nE); + aPBNew->Update(aLPB, Standard_False); + // + for (aItPB.Initialize(aLPB); aItPB.More(); aItPB.Next()) { + Handle(BOPDS_PaveBlock)& aPB = aItPB.ChangeValue(); + const BOPDS_Pave& aPave1=aPB->Pave1(); + aPave1.Contents(nV1, aT1); + // + const BOPDS_Pave& aPave2=aPB->Pave2(); + aPave2.Contents(nV2, aT2); + // + aItMPB.Initialize(aMPB); + //check if it is the old pave block. + for (; aItMPB.More(); aItMPB.Next()) { + const Handle(BOPDS_PaveBlock)& aPB1 = aItMPB.Value(); + aPB1->Indices(nV11, nV21); + aPB1->Range(aT11, aT21); + if (nV1 == nV11 && nV2 == nV21 && + aT1 == aT11 && aT2 == aT21) { + const TopoDS_Shape& aEIm = myDS->Shape(aPB1->Edge()); + aLIm.Append(aEIm); + continue; + } + } + // + aV1=(*(TopoDS_Vertex *)(&myDS->Shape(nV1))); + aV1.Orientation(TopAbs_FORWARD); + // + aV2=(*(TopoDS_Vertex *)(&myDS->Shape(nV2))); + aV2.Orientation(TopAbs_REVERSED); + // + BOPTools_AlgoTools::MakeSplitEdge(aE, aV1, aT1, aV2, aT2, aSp); + BOPTools_AlgoTools2D::BuildPCurveForEdgeOnFace(aSp, theF); + // + aSI.SetShape(aSp); + // + Bnd_Box& aBox=aSI.ChangeBox(); + BRepBndLib::Add(aSp, aBox); + // + nSp=myDS->Append(aSI); + // + aPB->SetEdge(nSp); + aLIm.Append(aSp); + } +} + +//======================================================================= +//function : CheckSolidImages +//purpose : +//======================================================================= + void BRepFeat_Builder::CheckSolidImages() +{ + BOPTools_MapOfSet aMST; + BOPCol_ListOfShape aLSImNew; + BOPCol_MapOfShape aMS; + Standard_Boolean bRem; + BOPCol_ListIteratorOfListOfShape aIt; + TopExp_Explorer aExp, aExpF; + Standard_Boolean bFlagSD; + // + const BOPCol_ListOfShape& aLSIm = myImages.Find(myArgs[1]); + aIt.Initialize(aLSIm); + for(;aIt.More();aIt.Next()) { + const TopoDS_Shape& aSolIm = aIt.Value(); + // + BOPTools_Set aST; + aST.Add(aSolIm, TopAbs_FACE); + aMST.Add(aST); + } + // + aExp.Init(myArgs[0], TopAbs_SOLID); + for(; aExp.More(); aExp.Next()) { + const TopoDS_Shape& aSolid = aExp.Current(); + if (myImages.IsBound(aSolid)) { + BOPCol_ListOfShape& aLSImSol = myImages.ChangeFind(aSolid); + aIt.Initialize(aLSImSol); + for(;aIt.More();aIt.Next()) { + const TopoDS_Shape& aSolIm = aIt.Value(); + // + BOPTools_Set aST; + aST.Add(aSolIm, TopAbs_FACE); + bFlagSD=aMST.Contains(aST); + // + const BOPTools_Set& aSTx=aMST.Added(aST); + const TopoDS_Shape& aSx=aSTx.Shape(); + aLSImNew.Append(aSx); + // + if (bFlagSD) { + myShapesSD.Bind(aSolIm, aSx); + } + } + aLSImSol.Assign(aLSImNew); + } + } +} + +//======================================================================= +//function : MapShapes +//purpose : +//======================================================================= + void BRepFeat_Builder::FillRemoved(const TopoDS_Shape& S, + BOPCol_MapOfShape& M) +{ + if (myShapes.Contains(S)) { + return; + } + // + M.Add(S); + TopoDS_Iterator It(S); + while (It.More()) { + FillRemoved(It.Value(),M); + It.Next(); + } +} + +//======================================================================= +//function : FillIn3DParts +//purpose : +//======================================================================= + void BRepFeat_Builder::FillIn3DParts(BOPCol_DataMapOfShapeListOfShape& theInParts, + BOPCol_DataMapOfShapeShape& theDraftSolids, + const Handle(NCollection_BaseAllocator)& theAllocator) +{ + myErrorStatus=0; + // + Standard_Boolean bIsIN, bHasImage; + Standard_Integer aNbS, aNbSolids, i, j, aNbFaces, aNbFP, aNbFPx, aNbFIN, aNbLIF, aNbEFP; + Standard_Integer iRank, aNbRem; + TopAbs_ShapeEnum aType; + TopAbs_State aState; + TopoDS_Iterator aIt, aItF; + BRep_Builder aBB; + TopoDS_Solid aSolidSp; + TopoDS_Face aFP; + BOPCol_ListIteratorOfListOfShape aItS, aItFP, aItEx; + BOPCol_MapIteratorOfMapOfShape aItMS, aItMS1; + // + BOPCol_ListOfShape aLIF(theAllocator); + BOPCol_MapOfShape aMFDone(100, theAllocator); + BOPCol_MapOfShape aMSolids(100, theAllocator); + BOPCol_MapOfShape aMFaces(100, theAllocator); + BOPCol_MapOfShape aMFIN(100, theAllocator); + BOPCol_IndexedMapOfShape aMS(100, theAllocator); + BOPCol_IndexedDataMapOfShapeListOfShape aMEF(100, theAllocator); + // + theDraftSolids.Clear(); + // + aNbRem = myRemoved.Extent(); + // + aNbS=myDS->NbSourceShapes(); + for (i=0; iShapeInfo(i); + const TopoDS_Shape& aS=aSI.Shape(); + // + aType=aSI.ShapeType(); + switch(aType) { + case TopAbs_SOLID: { + aMSolids.Add(aS); + break; + } + // + case TopAbs_FACE: { + // all faces (originals or images) + if (myImages.IsBound(aS)) { + const BOPCol_ListOfShape& aLS=myImages.Find(aS); + aItS.Initialize(aLS); + for (; aItS.More(); aItS.Next()) { + const TopoDS_Shape& aFx=aItS.Value(); + if (!myRemoved.Contains(aFx)) { + aMFaces.Add(aFx); + } + } + } + else { + if (!myRemoved.Contains(aS)) { + aMFaces.Add(aS); + } + } + break; + } + // + default: + break; + } + } + // + aNbFaces=aMFaces.Extent(); + aNbSolids=aMSolids.Extent(); + // + aItMS.Initialize(aMSolids); + for (; aItMS.More(); aItMS.Next()) { + const TopoDS_Solid& aSolid=(*(TopoDS_Solid*)(&aItMS.Value())); + // + aMFDone.Clear(); + aMFIN.Clear(); + aMEF.Clear(); + // + aBB.MakeSolid(aSolidSp); + // + // Draft solid and its pure internal faces => aSolidSp, aLIF + aLIF.Clear(); + BuildDraftSolid(aSolid, aSolidSp, aLIF); + aNbLIF=aLIF.Extent(); + // + // 1 all faces/edges from aSolid [ aMS ] + bHasImage=Standard_False; + aMS.Clear(); + aIt.Initialize(aSolid); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aShell=aIt.Value(); + // + if (myImages.IsBound(aShell)) { + bHasImage=Standard_True; + // + const BOPCol_ListOfShape& aLS=myImages.Find(aShell); + aItS.Initialize(aLS); + for (; aItS.More(); aItS.Next()) { + const TopoDS_Shape& aSx=aItS.Value(); + aMS.Add(aSx); + BOPTools::MapShapes(aSx, TopAbs_FACE, aMS); + BOPTools::MapShapes(aSx, TopAbs_EDGE, aMS); + BOPTools::MapShapesAndAncestors(aSx, TopAbs_EDGE, TopAbs_FACE, aMEF); + } + } + else { + //aMS.Add(aShell); + BOPTools::MapShapes(aShell, TopAbs_FACE, aMS); + BOPTools::MapShapesAndAncestors(aShell, TopAbs_EDGE, TopAbs_FACE, aMEF); + } + } + // + // 2 all faces that are not from aSolid [ aLFP1 ] + BOPCol_IndexedDataMapOfShapeListOfShape aMEFP(100, theAllocator); + BOPCol_ListOfShape aLFP1(theAllocator); + BOPCol_ListOfShape aLFP(theAllocator); + BOPCol_ListOfShape aLCBF(theAllocator); + BOPCol_ListOfShape aLFIN(theAllocator); + BOPCol_ListOfShape aLEx(theAllocator); + // + // for all non-solid faces build EF map [ aMEFP ] + aItMS1.Initialize(aMFaces); + for (; aItMS1.More(); aItMS1.Next()) { + const TopoDS_Shape& aFace=aItMS1.Value(); + if (!aMS.Contains(aFace)) { + BOPTools::MapShapesAndAncestors(aFace, TopAbs_EDGE, TopAbs_FACE, aMEFP); + } + } + // + // among all faces from aMEFP select these that have same edges + // with the solid (i.e aMEF). These faces will be treated first + // to prevent the usage of 3D classifier. + // The full list of faces to process is aLFP1. + aNbEFP=aMEFP.Extent(); + for (j=1; j<=aNbEFP; ++j) { + const TopoDS_Shape& aE=aMEFP.FindKey(j); + // + if (aMEF.Contains(aE)) { // !! + const BOPCol_ListOfShape& aLF=aMEFP(j); + aItFP.Initialize(aLF); + for (; aItFP.More(); aItFP.Next()) { + const TopoDS_Shape& aF=aItFP.Value(); + if (aMFDone.Add(aF)) { + aLFP1.Append(aF); + } + } + } + else { + aLEx.Append(aE); + } + } + // + aItEx.Initialize(aLEx); + for (; aItEx.More(); aItEx.Next()) { + const TopoDS_Shape& aE=aItEx.Value(); + const BOPCol_ListOfShape& aLF=aMEFP.FindFromKey(aE); + aItFP.Initialize(aLF); + for (; aItFP.More(); aItFP.Next()) { + const TopoDS_Shape& aF=aItFP.Value(); + if (aMFDone.Add(aF)) { + //aLFP2.Append(aF); + aLFP1.Append(aF); + } + } + } + // + //========== + // + // 3 Process faces aLFP1 + aMFDone.Clear(); + aNbFP=aLFP1.Extent(); + aItFP.Initialize(aLFP1); + for (; aItFP.More(); aItFP.Next()) { + const TopoDS_Shape& aSP=aItFP.Value(); + if (!aMFDone.Add(aSP)) { + continue; + } + + // + // first face to process + aFP=(*(TopoDS_Face*)(&aSP)); + bIsIN=BOPTools_AlgoTools::IsInternalFace(aFP, aSolidSp, aMEF, 1.e-14, myContext); + aState=(bIsIN) ? TopAbs_IN : TopAbs_OUT; + // + // collect faces to process [ aFP is the first ] + aLFP.Clear(); + aLFP.Append(aFP); + aItS.Initialize(aLFP1); + for (; aItS.More(); aItS.Next()) { + const TopoDS_Shape& aSk=aItS.Value(); + if (!aMFDone.Contains(aSk)) { + aLFP.Append(aSk); + } + } + // + // Connexity Block that spreads from aFP the Bound + // or till the end of the block itself + aLCBF.Clear(); + BOPTools_AlgoTools::MakeConnexityBlock(aLFP, aMS, aLCBF, theAllocator); + // + // fill states for the Connexity Block + aItS.Initialize(aLCBF); + for (; aItS.More(); aItS.Next()) { + const TopoDS_Shape& aSx=aItS.Value(); + aMFDone.Add(aSx); + if (aState==TopAbs_IN) { + aMFIN.Add(aSx); + } + } + // + aNbFPx=aMFDone.Extent(); + if (aNbFPx==aNbFP) { + break; + } + }//for (; aItFP.More(); aItFP.Next()) + // + // faces Inside aSolid + aLFIN.Clear(); + aNbFIN=aMFIN.Extent(); + if (aNbFIN || aNbLIF) { + aItMS1.Initialize(aMFIN); + for (; aItMS1.More(); aItMS1.Next()) { + const TopoDS_Shape& aFIn=aItMS1.Value(); + aLFIN.Append(aFIn); + } + // + aItS.Initialize(aLIF); + for (; aItS.More(); aItS.Next()) { + const TopoDS_Shape& aFIN=aItS.Value(); + aLFIN.Append(aFIN); + } + // + theInParts.Bind(aSolid, aLFIN); + } + if (aNbFIN || bHasImage) { + theDraftSolids.Bind(aSolid, aSolidSp); + } + }// for (; aItMS.More(); aItMS.Next()) { +} diff --git a/src/BRepFeat/BRepFeat_Builder.lxx b/src/BRepFeat/BRepFeat_Builder.lxx deleted file mode 100755 index e95af5c751..0000000000 --- a/src/BRepFeat/BRepFeat_Builder.lxx +++ /dev/null @@ -1,78 +0,0 @@ -// Created on: 1995-06-13 -// Created by: Jacques GOUSSARD -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - - -//======================================================================= -//function : BRepFeat_Builder -//purpose : -//======================================================================= - -inline BRepFeat_Builder::BRepFeat_Builder () -{ -} - - -//======================================================================= -//function : BRepFeat_Builder -//purpose : -//======================================================================= - -inline BRepFeat_Builder::BRepFeat_Builder - (const TopoDS_Shape& S) : myBuilder(S) -{ -} - - -//======================================================================= -//function : BRepFeat_Builder -//purpose : -//======================================================================= - -inline BRepFeat_Builder::BRepFeat_Builder(const TopoDS_Shape& S, - const TopoDS_Shape& T): - myBuilder(S,T) -{ -} - - -//======================================================================= -//function : Init -//purpose : -//======================================================================= - -inline void BRepFeat_Builder::Init(const TopoDS_Shape& S) -{ - myBuilder.Init(S); -} - -//======================================================================= -//function : Init -//purpose : -//======================================================================= - -inline void BRepFeat_Builder::Init(const TopoDS_Shape& S, - const TopoDS_Shape& T) -{ - myBuilder.Init(S,T); -} - - diff --git a/src/BRepFeat/BRepFeat_Form.cdl b/src/BRepFeat/BRepFeat_Form.cdl index 23642a6a5a..77e181cfb6 100755 --- a/src/BRepFeat/BRepFeat_Form.cdl +++ b/src/BRepFeat/BRepFeat_Form.cdl @@ -23,33 +23,33 @@ deferred class Form from BRepFeat inherits MakeShape from BRepBuilderAPI - ---Purpose: Provides general functions to build form features. - -- Form features can be depressions or protrusions and include the following types: - -- - Cylinder - -- - Draft Prism - -- - Prism - -- - Revolved feature - -- - Pipe - -- In each case, you have a choice of operation type between the following: - -- - removing matter (a Boolean cut: Fuse setting 0) - -- - adding matter (Boolean fusion: Fuse setting 1) - -- The semantics of form feature creation is based on the construction of shapes: - -- - along a length - -- - up to a limiting face - -- - from a limiting face to a height - -- - above and/or below a plane - -- The shape defining construction of the feature can be either the - -- supporting edge or the concerned area of a face. - -- In case of the supporting edge, this contour can be attached to a - -- face of the basis shape by binding. When the contour is bound to this - -- face, the information that the contour will slide on the face - -- becomes available to the relevant class methods. In case of the - -- concerned area of a face, you could, for example, cut it out and - -- move it to a different height which will define the limiting face of a - -- protrusion or depression. - -- Topological definition with local operations of this sort makes - -- calculations simpler and faster than a global operation. The latter - -- would entail a second phase of removing unwanted matter to get the same result. + ---Purpose: Provides general functions to build form features. + -- Form features can be depressions or protrusions and include the following types: + -- - Cylinder + -- - Draft Prism + -- - Prism + -- - Revolved feature + -- - Pipe + -- In each case, you have a choice of operation type between the following: + -- - removing matter (a Boolean cut: Fuse setting 0) + -- - adding matter (Boolean fusion: Fuse setting 1) + -- The semantics of form feature creation is based on the construction of shapes: + -- - along a length + -- - up to a limiting face + -- - from a limiting face to a height + -- - above and/or below a plane + -- The shape defining construction of the feature can be either the + -- supporting edge or the concerned area of a face. + -- In case of the supporting edge, this contour can be attached to a + -- face of the basis shape by binding. When the contour is bound to this + -- face, the information that the contour will slide on the face + -- becomes available to the relevant class methods. In case of the + -- concerned area of a face, you could, for example, cut it out and + -- move it to a different height which will define the limiting face of a + -- protrusion or depression. + -- Topological definition with local operations of this sort makes + -- calculations simpler and faster than a global operation. The latter + -- would entail a second phase of removing unwanted matter to get the same result. uses Shape from TopoDS, Face from TopoDS, @@ -64,31 +64,30 @@ uses Shape from TopoDS, StatusError from BRepFeat, HBuilder from TopOpeBRepBuild, --modified by NIZNHY-PKV Thu Mar 21 17:09:08 2002 f - BooleanOperation from BRepAlgoAPI, - --modified by NIZNHY-PKV Thu Mar 21 17:09:11 2002 t - HistoryCollector from BOP + BooleanOperation from BRepAlgoAPI + --modified by NIZNHY-PKV Thu Mar 21 17:09:11 2002 t is Initialize; - ---Purpose: Redefines the empty constructor. - ---C++: inline + ---Purpose: Redefines the empty constructor. + ---C++: inline --- Methods redefined from BRepBuilderAPI_MakeShape Modified(me: in out; F: Shape from TopoDS) - ---Purpose: returns the list of generated Faces. - ---C++: return const & - ---Level: Public + ---Purpose: returns the list of generated Faces. + ---C++: return const & + ---Level: Public returns ListOfShape from TopTools is redefined; Generated(me: in out; S: Shape from TopoDS) - ---Purpose: returns a list of the created faces - -- from the shape . - ---C++: return const & - ---Level: Public + ---Purpose: returns a list of the created faces + -- from the shape . + ---C++: return const & + ---Level: Public returns ListOfShape from TopTools is redefined; @@ -99,36 +98,36 @@ is FirstShape (me) - ---Purpose: Returns the list of shapes created at the bottom of - -- the created form. It may be an empty list. + ---Purpose: Returns the list of shapes created at the bottom of + -- the created form. It may be an empty list. returns ListOfShape from TopTools; - ---C++: return const& + ---C++: return const& LastShape (me) - ---Purpose: Returns the list of shapes created at the top of the - -- created form. It may be an empty list. + ---Purpose: Returns the list of shapes created at the top of the + -- created form. It may be an empty list. returns ListOfShape from TopTools; - ---C++: return const& + ---C++: return const& NewEdges(me) - ---Purpose: Returns a list of the limiting and glueing edges - -- generated by the feature. These edges did not originally - -- exist in the basis shape. - -- The list provides the information necessary for - -- subsequent addition of fillets. It may be an empty list. + ---Purpose: Returns a list of the limiting and glueing edges + -- generated by the feature. These edges did not originally + -- exist in the basis shape. + -- The list provides the information necessary for + -- subsequent addition of fillets. It may be an empty list. ---C++: return const& returns ListOfShape from TopTools; TgtEdges(me) ---Purpose: Returns a list of the tangent edges among the limiting - -- and glueing edges generated by the feature. These - -- edges did not originally exist in the basis shape and are - -- tangent to the face against which the feature is built. - -- The list provides the information necessary for - -- subsequent addition of fillets. It may be an empty list. - -- If an edge is tangent, no fillet is possible, and the edge - -- must subsequently be removed if you want to add a fillet. + -- and glueing edges generated by the feature. These + -- edges did not originally exist in the basis shape and are + -- tangent to the face against which the feature is built. + -- The list provides the information necessary for + -- subsequent addition of fillets. It may be an empty list. + -- If an edge is tangent, no fillet is possible, and the edge + -- must subsequently be removed if you want to add a fillet. ---C++: return const& returns ListOfShape from TopTools; @@ -136,101 +135,95 @@ is BasisShapeValid(me: in out) --- Purpose: Initializes the topological construction if the basis shape is present. ---C++: inline - is static; + is static; GeneratedShapeValid(me: in out) - ---Purpose: Initializes the topological construction if the generated shape S is present. + ---Purpose: Initializes the topological construction if the generated shape S is present. ---C++: inline - is static; + is static; ShapeFromValid(me: in out) - ---Purpose: - -- Initializes the topological construction if the shape is - -- present from the specified integer on. + ---Purpose: + -- Initializes the topological construction if the shape is + -- present from the specified integer on. ---C++: inline - is static; + is static; ShapeUntilValid(me: in out) - --- Purpose: - -- Initializes the topological construction if the shape is - -- present until the specified integer. - ---C++: inline - is static; + --- Purpose: + -- Initializes the topological construction if the shape is + -- present until the specified integer. + ---C++: inline + is static; GluedFacesValid(me: in out) ---Purpose: - -- Initializes the topological construction if the glued face is present. - ---C++: inline - is static; + -- Initializes the topological construction if the glued face is present. + ---C++: inline + is static; SketchFaceValid(me: in out) - --- Purpose: - -- Initializes the topological construction if the sketch face - -- is present. If the sketch face is inside the basis shape, - -- local operations such as glueing can be performed. - ---C++: inline - is static; + --- Purpose: + -- Initializes the topological construction if the sketch face + -- is present. If the sketch face is inside the basis shape, + -- local operations such as glueing can be performed. + ---C++: inline + is static; PerfSelectionValid(me: in out) - --- Purpose: Initializes the topological construction if the selected face is present. + --- Purpose: Initializes the topological construction if the selected face is present. ---C++: inline - is static; + is static; GlobalPerform(me: in out) - ---Purpose: General perform method... + ---Purpose: General perform method... - is static protected; + is static protected; Curves(me: in out; S : in out SequenceOfCurve from TColGeom) - is deferred; + is deferred; BarycCurve(me: in out) - returns Curve from Geom - is deferred; + returns Curve from Geom + is deferred; -- Protected implementation methods UpdateDescendants(me: in out; G: Gluer from LocOpe) - is static protected; + is static protected; --modified by NIZNHY-PKV Thu Mar 21 18:42:53 2002 f UpdateDescendants(me: in out; - aBOP: BooleanOperation from BRepAlgoAPI; - SResult : Shape from TopoDS; + aBOP: BooleanOperation from BRepAlgoAPI; + SResult : Shape from TopoDS; SkipFace : Boolean from Standard = Standard_False) - is static protected; + is static protected; --modified by NIZNHY-PKV Thu Mar 21 18:42:50 2002 t - UpdateDescendants(me: in out; - aHistory : HistoryCollector from BOP; - SResult : Shape from TopoDS; - SkipFace : Boolean from Standard = Standard_False) - is static protected; - UpdateDescendants(me: in out; B : HBuilder from TopOpeBRepBuild; - SResult : Shape from TopoDS; + SResult : Shape from TopoDS; SkipFace : Boolean from Standard = Standard_False) - is static protected; + is static protected; TransformShapeFU(me: in out; flag: Integer from Standard) - returns Boolean from Standard - is protected; + returns Boolean from Standard + is protected; CurrentStatusError(me) - returns StatusError from BRepFeat; + returns StatusError from BRepFeat; fields @@ -256,7 +249,7 @@ fields mySbOK : Boolean from Standard; - mySkOK : Boolean from Standard; + mySkOK : Boolean from Standard; myGSOK : Boolean from Standard; mySFOK : Boolean from Standard; mySUOK : Boolean from Standard; diff --git a/src/BRepFeat/BRepFeat_Form.cxx b/src/BRepFeat/BRepFeat_Form.cxx index 165cf3a7e6..bbffb337da 100755 --- a/src/BRepFeat/BRepFeat_Form.cxx +++ b/src/BRepFeat/BRepFeat_Form.cxx @@ -23,7 +23,6 @@ #include #include -#include #include #include #include @@ -69,6 +68,7 @@ #include #include +#include //modified by NIZNHY-PKV Thu Mar 21 17:30:29 2002 t #ifdef DEB @@ -76,10 +76,8 @@ Standard_IMPORT Standard_Boolean BRepFeat_GettraceFEAT(); #endif static void Descendants(const TopoDS_Shape&, - const LocOpe_Builder&, - TopTools_MapOfShape&); - - + BRepFeat_Builder&, + TopTools_MapOfShape&); //======================================================================= //function : Perform @@ -103,12 +101,10 @@ static void Descendants(const TopoDS_Shape&, return; } - //--- Initialisation - Standard_Integer addflag = 0; - TopExp_Explorer exp,exp2; Standard_Integer theOpe = 2; + TopTools_DataMapIteratorOfDataMapOfShapeShape itm; if(myJustFeat && !myFuse) { #ifdef DEB @@ -127,31 +123,24 @@ static void Descendants(const TopoDS_Shape&, else {} Standard_Boolean ChangeOpe = Standard_False; - -//--- Add Shape From and Until in the map to avoid setting them in LShape Standard_Boolean FromInShape = Standard_False; Standard_Boolean UntilInShape = Standard_False; - TopTools_MapOfShape M; if (!mySFrom.IsNull()) { FromInShape = Standard_True; for (exp2.Init(mySFrom,TopAbs_FACE); exp2.More(); exp2.Next()) { const TopoDS_Shape& ffrom = exp2.Current(); for (exp.Init(mySbase,TopAbs_FACE); exp.More(); exp.Next()) { - if (exp.Current().IsSame(ffrom)) { - break; - } + if (exp.Current().IsSame(ffrom)) { + break; + } } if (!exp.More()) { - FromInShape = Standard_False; + FromInShape = Standard_False; #ifdef DEB - if (trc) cout << " From not in Shape" << endl; + if (trc) cout << " From not in Shape" << endl; #endif - break; - } - else { - addflag++; - M.Add(ffrom); + break; } } } @@ -161,35 +150,20 @@ static void Descendants(const TopoDS_Shape&, for (exp2.Init(mySUntil,TopAbs_FACE); exp2.More(); exp2.Next()) { const TopoDS_Shape& funtil = exp2.Current(); for (exp.Init(mySbase,TopAbs_FACE); exp.More(); exp.Next()) { - if (exp.Current().IsSame(funtil)) { - break; - } + if (exp.Current().IsSame(funtil)) { + break; + } } if (!exp.More()) { - UntilInShape = Standard_False; + UntilInShape = Standard_False; #ifdef DEB - if (trc) cout << " Until not in Shape" << endl; + if (trc) cout << " Until not in Shape" << endl; #endif - break; - } - else { - addflag++; - M.Add(funtil); + break; } } } - -//--- Add Faces of glueing in the map to avoid setting them in LShape - TopTools_DataMapIteratorOfDataMapOfShapeShape itm; - for (itm.Initialize(myGluedF);itm.More();itm.Next()) { - M.Add(itm.Value()); - } - - -//--- Find in the list LShape faces concerned by the feature - - TopTools_ListOfShape LShape; TopTools_ListIteratorOfListOfShape it,it2; Standard_Integer sens = 0; @@ -208,16 +182,9 @@ static void Descendants(const TopoDS_Shape&, LocOpe_CSIntersector ASI1; LocOpe_CSIntersector ASI2; - -#ifndef VREF - LocOpe_CSIntersector ASI3(mySbase); - ASI3.Perform(scur); -#endif - TopTools_ListOfShape IntList; IntList.Clear(); - //--- 1) by intersection // Intersection Tool Shape From @@ -232,14 +199,6 @@ static void Descendants(const TopoDS_Shape&, ASI2.Perform(scur); } -#ifndef VREF -// Intersection Tool base Shape - if (!ASI3.IsDone()) { - theOpe = 2; - LShape.Clear(); - } - else -#endif { // Find sens, locmin, locmax, FFrom, FUntil tempo=0; @@ -247,268 +206,123 @@ static void Descendants(const TopoDS_Shape&, locmax = RealLast(); for (Standard_Integer jj=1; jj<=scur.Length(); jj++) { if (ASI1.IsDone() && ASI2.IsDone()) { - if (ASI1.NbPoints(jj) <= 0) { - continue; - } - mf = ASI1.Point(jj,1).Parameter(); - Mf = ASI1.Point(jj,ASI1.NbPoints(jj)).Parameter(); - if (ASI2.NbPoints(jj) <= 0) { - continue; - } - mu = ASI2.Point(jj,1).Parameter(); - Mu = ASI2.Point(jj,ASI2.NbPoints(jj)).Parameter(); - if (scur(jj)->IsPeriodic()) { - Standard_Real period = scur(jj)->Period(); - locmin = mf; - locmax = ElCLib::InPeriod(Mu,locmin,locmin+period); - } - else { - Standard_Integer ku, kf; - if (! (mu > Mf || mf > Mu)) { //overlapping intervals - sens = 1; - kf = 1; - ku = ASI2.NbPoints(jj); - locmin = mf; - locmax = Max(Mf, Mu); - } - else if (mu > Mf) { - if (sens == -1) { - myStatusError = BRepFeat_IntervalOverlap; - NotDone(); - return; - } - sens = 1; - kf = 1; - ku = ASI2.NbPoints(jj); - locmin = mf; - locmax = Mu; - } - else { - if (sens == 1) { - myStatusError = BRepFeat_IntervalOverlap; - NotDone(); - return; - } - sens = -1; - kf = ASI1.NbPoints(jj); - ku = 1; - locmin = mu; - locmax = Mf; - } - if (Oriffrom == TopAbs_INTERNAL) { - TopAbs_Orientation Oript = ASI1.Point(jj,kf).Orientation(); - if (Oript == TopAbs_FORWARD || Oript == TopAbs_REVERSED) { - if (sens == -1) { - Oript = TopAbs::Reverse(Oript); - } - Oriffrom = TopAbs::Reverse(Oript); - FFrom = ASI1.Point(jj,kf).Face(); - } - } - if (Orifuntil == TopAbs_INTERNAL) { - TopAbs_Orientation Oript = ASI2.Point(jj,ku).Orientation(); - if (Oript == TopAbs_FORWARD || Oript == TopAbs_REVERSED) { - if (sens == -1) { - Oript = TopAbs::Reverse(Oript); - } - Orifuntil = Oript; - FUntil = ASI2.Point(jj,ku).Face(); - } - } - } + if (ASI1.NbPoints(jj) <= 0) { + continue; + } + mf = ASI1.Point(jj,1).Parameter(); + Mf = ASI1.Point(jj,ASI1.NbPoints(jj)).Parameter(); + if (ASI2.NbPoints(jj) <= 0) { + continue; + } + mu = ASI2.Point(jj,1).Parameter(); + Mu = ASI2.Point(jj,ASI2.NbPoints(jj)).Parameter(); + if (scur(jj)->IsPeriodic()) { + Standard_Real period = scur(jj)->Period(); + locmin = mf; + locmax = ElCLib::InPeriod(Mu,locmin,locmin+period); + } + else { + Standard_Integer ku, kf; + if (! (mu > Mf || mf > Mu)) { //overlapping intervals + sens = 1; + kf = 1; + ku = ASI2.NbPoints(jj); + locmin = mf; + locmax = Max(Mf, Mu); + } + else if (mu > Mf) { + if (sens == -1) { + myStatusError = BRepFeat_IntervalOverlap; + NotDone(); + return; + } + sens = 1; + kf = 1; + ku = ASI2.NbPoints(jj); + locmin = mf; + locmax = Mu; + } + else { + if (sens == 1) { + myStatusError = BRepFeat_IntervalOverlap; + NotDone(); + return; + } + sens = -1; + kf = ASI1.NbPoints(jj); + ku = 1; + locmin = mu; + locmax = Mf; + } + if (Oriffrom == TopAbs_INTERNAL) { + TopAbs_Orientation Oript = ASI1.Point(jj,kf).Orientation(); + if (Oript == TopAbs_FORWARD || Oript == TopAbs_REVERSED) { + if (sens == -1) { + Oript = TopAbs::Reverse(Oript); + } + Oriffrom = TopAbs::Reverse(Oript); + FFrom = ASI1.Point(jj,kf).Face(); + } + } + if (Orifuntil == TopAbs_INTERNAL) { + TopAbs_Orientation Oript = ASI2.Point(jj,ku).Orientation(); + if (Oript == TopAbs_FORWARD || Oript == TopAbs_REVERSED) { + if (sens == -1) { + Oript = TopAbs::Reverse(Oript); + } + Orifuntil = Oript; + FUntil = ASI2.Point(jj,ku).Face(); + } + } + } } else if (ASI2.IsDone()) { - if (ASI2.NbPoints(jj) <= 0) - continue; + if (ASI2.NbPoints(jj) <= 0) + continue; // for base case prism on mySUntil -> ambivalent direction // -> preferrable direction = 1 - if(sens != 1) { - if (ASI2.Point(jj,1).Parameter()* - ASI2.Point(jj,ASI2.NbPoints(jj)).Parameter()<=0) - sens=1; - else if (ASI2.Point(jj,1).Parameter()<0.) - sens =-1; - else - sens =1; - } - - Standard_Integer ku; - if (sens == -1) { - ku = 1; - locmax = -ASI2.Point(jj,ku).Parameter(); - locmin = 0.; - } - else { - ku = ASI2.NbPoints(jj); - locmin = 0; - locmax = ASI2.Point(jj,ku).Parameter(); - } - if (Orifuntil == TopAbs_INTERNAL && sens != 0) { - TopAbs_Orientation Oript = ASI2.Point(jj,ku).Orientation(); - if (Oript == TopAbs_FORWARD || Oript == TopAbs_REVERSED) { - if (sens == -1) { - Oript = TopAbs::Reverse(Oript); - } - Orifuntil = Oript; - FUntil = ASI2.Point(jj,ku).Face(); - } - } + if(sens != 1) { + if (ASI2.Point(jj,1).Parameter()* + ASI2.Point(jj,ASI2.NbPoints(jj)).Parameter()<=0) + sens=1; + else if (ASI2.Point(jj,1).Parameter()<0.) + sens =-1; + else + sens =1; + } + + Standard_Integer ku; + if (sens == -1) { + ku = 1; + locmax = -ASI2.Point(jj,ku).Parameter(); + locmin = 0.; + } + else { + ku = ASI2.NbPoints(jj); + locmin = 0; + locmax = ASI2.Point(jj,ku).Parameter(); + } + if (Orifuntil == TopAbs_INTERNAL && sens != 0) { + TopAbs_Orientation Oript = ASI2.Point(jj,ku).Orientation(); + if (Oript == TopAbs_FORWARD || Oript == TopAbs_REVERSED) { + if (sens == -1) { + Oript = TopAbs::Reverse(Oript); + } + Orifuntil = Oript; + FUntil = ASI2.Point(jj,ku).Face(); + } + } } else { - locmin = 0.; - locmax = RealLast(); - sens = 1; - break; - } - - -// Update LShape by adding faces of the base Shape -// that are OK (sens, locmin and locmax) -// that are not yet in the map (Shape From Until and glue faces) -#ifndef VREF - if (theOpe == 2) { - for (Standard_Integer i=1; i<=ASI3.NbPoints(jj); i++) { - Standard_Real theprm = ASI3.Point(jj,i).Parameter() ; - if(locmin > locmax) { - Standard_Real temp = locmin; - locmin = locmax; locmax = temp; - } - if (theprm <= locmax && - theprm >= locmin) { - const TopoDS_Face& fac = ASI3.Point(jj,i).Face(); - if (M.Add(fac)) { - LShape.Append(ASI3.Point(jj,i).Face()); - } - } - } - } - else { - TopAbs_Orientation Or; - Standard_Integer Indfm,IndtM,i; - Standard_Real Tol = -Precision::Confusion(); - if(sens == 1) { - if (ASI3.LocalizeAfter(jj,locmin,Tol,Or,Indfm,i) && - ASI3.LocalizeBefore(jj,locmax,Tol,Or,i,IndtM)) { - for (i= Indfm; i<=IndtM; i++) { - const TopoDS_Face& fac = ASI3.Point(jj,i).Face(); - if (M.Add(fac)) { - LShape.Append(fac); - } - } - } - } - else if(sens == -1) { - if (ASI3.LocalizeBefore(jj,locmin,Tol,Or,Indfm,i) && - ASI3.LocalizeAfter(jj,-locmax,Tol,Or,i,IndtM)) { - for (i= Indfm; i<=IndtM; i++) { - const TopoDS_Face& fac = ASI3.Point(jj,i).Face(); - if (M.Add(fac)) { - LShape.Append(fac); - } - } - } - } - } -#endif - } - } - -#ifndef VREF - -//--- 2) by section with the bounding box - - Bnd_Box prbox; - BRepBndLib::Add(myGShape,prbox); - - Bnd_Box bbb; - if(!mySFrom.IsNull() && !mySUntil.IsNull()) { - BRepBndLib::Add(mySUntil, bbb); - BRepBndLib::Add(mySFrom, bbb); - } - else if(!mySUntil.IsNull() && !mySkface.IsNull()) { - BRepBndLib::Add(mySUntil, bbb); - BRepBndLib::Add(mySkface, bbb); - } - else { - bbb.SetWhole(); - } - - TopExp_Explorer exx1(mySbase, TopAbs_FACE); - Standard_Integer counter = 0; - - -// Are not processed: the face of gluing -// the faces of Shape From -// the faces of Shape Until -// the faces already in LShape -// the faces of myGluedF -// If the face was not eliminated ... it is preserved if bounding box -// collides with the box of myGShape = outil -// or the box of limit faces (mySFrom mySUntil mySkface) - for(; exx1.More(); exx1.Next()) { - const TopoDS_Face& sh = TopoDS::Face(exx1.Current()); - counter++; - - if(sh.IsSame(mySkface) && theOpe==1) continue; - - if(!mySFrom.IsNull()) { - TopExp_Explorer explor(mySFrom, TopAbs_FACE); - for(; explor.More(); explor.Next()) { - const TopoDS_Face& fff = TopoDS::Face(explor.Current()); - if(fff.IsSame(sh)) break; + locmin = 0.; + locmax = RealLast(); + sens = 1; + break; } - if(explor.More()) continue; - } - - if(!mySUntil.IsNull()) { - TopExp_Explorer explor(mySUntil, TopAbs_FACE); - for(; explor.More(); explor.Next()) { - const TopoDS_Face& fff = TopoDS::Face(explor.Current()); - if(fff.IsSame(sh)) break; - } - if(explor.More()) continue; - } - - TopTools_ListIteratorOfListOfShape iter1(LShape); - for(; iter1.More(); iter1.Next()) { - if(iter1.Value().IsSame(sh)) break; - } - if(iter1.More()) continue; - - for (itm.Initialize(myGluedF);itm.More();itm.Next()) { - const TopoDS_Face& glf = TopoDS::Face(itm.Value()); - if(glf.IsSame(sh)) break; - } - if(itm.More()) continue; - - Bnd_Box shbox; - BRepBndLib::Add(sh,shbox); - - if(shbox.IsOut(bbb) || shbox.IsOut(prbox)) continue; - // if(shbox.IsOut(prbox)) continue; - - if(M.Add(sh)) { - LShape.Append(sh); } } -#endif - -#ifdef VREF -// test of performance : add all faces of the base Shape in LShape -// (no phase of parsing, but more faces) -> no concluant - TopExp_Explorer exx1; - for (exx1.Init(mySbase, TopAbs_FACE); - exx1.More(); exx1.Next()) { - const TopoDS_Shape& fac = exx1.Current(); - if (M.Add(fac)) { - LShape.Append(fac); - } - } - -#endif - LocOpe_Gluer theGlue; //--- case of gluing @@ -525,13 +339,13 @@ static void Descendants(const TopoDS_Shape&, if (!mySFrom.IsNull()) { TopoDS_Solid S = BRepFeat::Tool(mySFrom,FFrom,Oriffrom); if (!S.IsNull()) { - B.Add(Comp,S); + B.Add(Comp,S); } } if (!mySUntil.IsNull()) { TopoDS_Solid S = BRepFeat::Tool(mySUntil,FUntil,Orifuntil); if (!S.IsNull()) { - B.Add(Comp,S); + B.Add(Comp,S); } } @@ -545,137 +359,137 @@ static void Descendants(const TopoDS_Shape&, //modified by NIZNHY-PKV Thu Mar 21 17:15:58 2002 t exp.Init(trP.Shape(), TopAbs_SOLID); if (exp.Current().IsNull()) { - theOpe = 2; - ChangeOpe = Standard_True; - Collage = Standard_False; + theOpe = 2; + ChangeOpe = Standard_True; + Collage = Standard_False; } else {// else X0 - // Only solids are preserved - TopoDS_Shape theGShape; - BRep_Builder B; - B.MakeCompound(TopoDS::Compound(theGShape)); - for (; exp.More(); exp.Next()) { - B.Add(theGShape,exp.Current()); - } - if (!BRepAlgo::IsValid(theGShape)) { - theOpe = 2; - ChangeOpe = Standard_True; - Collage = Standard_False; - } - else {// else X1 - if(!mySFrom.IsNull()) { - TopExp_Explorer ex; - ex.Init(mySFrom, TopAbs_FACE); - for(; ex.More(); ex.Next()) { - const TopoDS_Face& fac = TopoDS::Face(ex.Current()); - if (!FromInShape) { + // Only solids are preserved + TopoDS_Shape theGShape; + BRep_Builder B; + B.MakeCompound(TopoDS::Compound(theGShape)); + for (; exp.More(); exp.Next()) { + B.Add(theGShape,exp.Current()); + } + if (!BRepAlgo::IsValid(theGShape)) { + theOpe = 2; + ChangeOpe = Standard_True; + Collage = Standard_False; + } + else {// else X1 + if(!mySFrom.IsNull()) { + TopExp_Explorer ex; + ex.Init(mySFrom, TopAbs_FACE); + for(; ex.More(); ex.Next()) { + const TopoDS_Face& fac = TopoDS::Face(ex.Current()); + if (!FromInShape) { TopTools_ListOfShape thelist; - myMap.Bind(fac, thelist); - } - else { + myMap.Bind(fac, thelist); + } + else { TopTools_ListOfShape thelist1; - locmap.Bind(fac, thelist1); - } - if (trP.IsDeleted(fac)) { - } - else if (!FromInShape) { - myMap(fac) = trP.Modified(fac); - if (myMap(fac).IsEmpty()) myMap(fac).Append(fac); - } - else { - locmap(fac) =trP.Modified(fac) ; - if (locmap(fac).IsEmpty()) locmap(fac).Append(fac); - } - } - }// if(!mySFrom.IsNull()) - // - if(!mySUntil.IsNull()) { - TopExp_Explorer ex; - ex.Init(mySUntil, TopAbs_FACE); - for(; ex.More(); ex.Next()) { - const TopoDS_Face& fac = TopoDS::Face(ex.Current()); - if (!UntilInShape) { - TopTools_ListOfShape thelist2; + locmap.Bind(fac, thelist1); + } + if (trP.IsDeleted(fac)) { + } + else if (!FromInShape) { + myMap(fac) = trP.Modified(fac); + if (myMap(fac).IsEmpty()) myMap(fac).Append(fac); + } + else { + locmap(fac) =trP.Modified(fac) ; + if (locmap(fac).IsEmpty()) locmap(fac).Append(fac); + } + } + }// if(!mySFrom.IsNull()) + // + if(!mySUntil.IsNull()) { + TopExp_Explorer ex; + ex.Init(mySUntil, TopAbs_FACE); + for(; ex.More(); ex.Next()) { + const TopoDS_Face& fac = TopoDS::Face(ex.Current()); + if (!UntilInShape) { + TopTools_ListOfShape thelist2; myMap.Bind(fac,thelist2); - } - else { + } + else { TopTools_ListOfShape thelist3; - locmap.Bind(fac,thelist3); - } - if (trP.IsDeleted(fac)) { - } - else if (!UntilInShape) { - myMap(fac) = trP.Modified(fac); - if (myMap(fac).IsEmpty()) myMap(fac).Append(fac); - } - else { - locmap(fac) = trP.Modified(fac); - if (locmap(fac).IsEmpty()) locmap(fac).Append(fac); - } - } - }// if(!mySUntil.IsNull()) - // - //modified by NIZNHY-PKV Thu Mar 21 17:21:49 2002 f - //UpdateDescendants(trP.Builder(),theGShape,Standard_True); // skip faces - UpdateDescendants(trP,theGShape,Standard_True); // skip faces - //modified by NIZNHY-PKV Thu Mar 21 17:22:32 2002 t - - theGlue.Init(mySbase,theGShape); - for (itm.Initialize(myGluedF);itm.More();itm.Next()) { - const TopoDS_Face& gl = TopoDS::Face(itm.Key()); - TopTools_ListOfShape ldsc; - if (trP.IsDeleted(gl)) { - } - else { - ldsc = trP.Modified(gl); - if (ldsc.IsEmpty()) ldsc.Append(gl); - } - const TopoDS_Face& glface = TopoDS::Face(itm.Value()); - for (it.Initialize(ldsc);it.More();it.Next()) { - const TopoDS_Face& fac = TopoDS::Face(it.Value()); - Collage = BRepFeat::IsInside(fac, glface); - if(!Collage) { - theOpe = 2; - ChangeOpe = Standard_True; - break; - } - else { - theGlue.Bind(fac,glface); - theFE.Set(fac,glface); - for (theFE.InitIterator(); theFE.More();theFE.Next()) { - theGlue.Bind(theFE.EdgeFrom(),theFE.EdgeTo()); - } - } - } - } - }// else X1 + locmap.Bind(fac,thelist3); + } + if (trP.IsDeleted(fac)) { + } + else if (!UntilInShape) { + myMap(fac) = trP.Modified(fac); + if (myMap(fac).IsEmpty()) myMap(fac).Append(fac); + } + else { + locmap(fac) = trP.Modified(fac); + if (locmap(fac).IsEmpty()) locmap(fac).Append(fac); + } + } + }// if(!mySUntil.IsNull()) + // + //modified by NIZNHY-PKV Thu Mar 21 17:21:49 2002 f + //UpdateDescendants(trP.Builder(),theGShape,Standard_True); // skip faces + UpdateDescendants(trP,theGShape,Standard_True); // skip faces + //modified by NIZNHY-PKV Thu Mar 21 17:22:32 2002 t + + theGlue.Init(mySbase,theGShape); + for (itm.Initialize(myGluedF);itm.More();itm.Next()) { + const TopoDS_Face& gl = TopoDS::Face(itm.Key()); + TopTools_ListOfShape ldsc; + if (trP.IsDeleted(gl)) { + } + else { + ldsc = trP.Modified(gl); + if (ldsc.IsEmpty()) ldsc.Append(gl); + } + const TopoDS_Face& glface = TopoDS::Face(itm.Value()); + for (it.Initialize(ldsc);it.More();it.Next()) { + const TopoDS_Face& fac = TopoDS::Face(it.Value()); + Collage = BRepFeat::IsInside(fac, glface); + if(!Collage) { + theOpe = 2; + ChangeOpe = Standard_True; + break; + } + else { + theGlue.Bind(fac,glface); + theFE.Set(fac,glface); + for (theFE.InitIterator(); theFE.More();theFE.Next()) { + theGlue.Bind(theFE.EdgeFrom(),theFE.EdgeTo()); + } + } + } + } + }// else X1 }// else X0 }// if(expp.More() && !Comp.IsNull() && !myGShape.IsNull()) else { theGlue.Init(mySbase,myGShape); for (itm.Initialize(myGluedF); itm.More();itm.Next()) { - const TopoDS_Face& glface = TopoDS::Face(itm.Key()); - const TopoDS_Face& fac = TopoDS::Face(myGluedF(glface)); - for (exp.Init(myGShape,TopAbs_FACE); exp.More(); exp.Next()) { - if (exp.Current().IsSame(glface)) { - break; - } - } - if (exp.More()) { - Collage = BRepFeat::IsInside(glface, fac); - if(!Collage) { - theOpe = 2; - ChangeOpe = Standard_True; - break; - } - else { - theGlue.Bind(glface, fac); - theFE.Set(glface, fac); - for (theFE.InitIterator(); theFE.More();theFE.Next()) { - theGlue.Bind(theFE.EdgeFrom(),theFE.EdgeTo()); - } - } - } + const TopoDS_Face& glface = TopoDS::Face(itm.Key()); + const TopoDS_Face& fac = TopoDS::Face(myGluedF(glface)); + for (exp.Init(myGShape,TopAbs_FACE); exp.More(); exp.Next()) { + if (exp.Current().IsSame(glface)) { + break; + } + } + if (exp.More()) { + Collage = BRepFeat::IsInside(glface, fac); + if(!Collage) { + theOpe = 2; + ChangeOpe = Standard_True; + break; + } + else { + theGlue.Bind(glface, fac); + theFE.Set(glface, fac); + for (theFE.InitIterator(); theFE.More();theFE.Next()) { + theGlue.Bind(theFE.EdgeFrom(),theFE.EdgeTo()); + } + } + } } } @@ -683,43 +497,43 @@ static void Descendants(const TopoDS_Shape&, if (FromInShape && Collage) { TopExp_Explorer ex(mySFrom,TopAbs_FACE); for(; ex.More(); ex.Next()) { - const TopoDS_Face& fac2 = TopoDS::Face(ex.Current()); -// for (it.Initialize(myMap(fac2)); it.More(); it.Next()) { - for (it.Initialize(locmap(fac2)); it.More(); it.Next()) { - const TopoDS_Face& fac1 = TopoDS::Face(it.Value()); - theFE.Set(fac1, fac2); - theGlue.Bind(fac1, fac2); - for (theFE.InitIterator(); theFE.More();theFE.Next()) { - theGlue.Bind(theFE.EdgeFrom(),theFE.EdgeTo()); - } - } -// myMap.UnBind(fac2); + const TopoDS_Face& fac2 = TopoDS::Face(ex.Current()); +// for (it.Initialize(myMap(fac2)); it.More(); it.Next()) { + for (it.Initialize(locmap(fac2)); it.More(); it.Next()) { + const TopoDS_Face& fac1 = TopoDS::Face(it.Value()); + theFE.Set(fac1, fac2); + theGlue.Bind(fac1, fac2); + for (theFE.InitIterator(); theFE.More();theFE.Next()) { + theGlue.Bind(theFE.EdgeFrom(),theFE.EdgeTo()); + } + } +// myMap.UnBind(fac2); } } if (UntilInShape && Collage) { TopExp_Explorer ex(mySUntil, TopAbs_FACE); for(; ex.More(); ex.Next()) { - const TopoDS_Face& fac2 = TopoDS::Face(ex.Current()); -// for (it.Initialize(myMap(fac2)); it.More(); it.Next()) { - for (it.Initialize(locmap(fac2)); it.More(); it.Next()) { - const TopoDS_Face& fac1 = TopoDS::Face(it.Value()); - theGlue.Bind(fac1, fac2); - theFE.Set(fac1, fac2); - for (theFE.InitIterator(); theFE.More();theFE.Next()) { - theGlue.Bind(theFE.EdgeFrom(),theFE.EdgeTo()); - } - } - //myMap.UnBind(fac2); // to avoid fac2 in Map when - // UpdateDescendants(theGlue) is called + const TopoDS_Face& fac2 = TopoDS::Face(ex.Current()); +// for (it.Initialize(myMap(fac2)); it.More(); it.Next()) { + for (it.Initialize(locmap(fac2)); it.More(); it.Next()) { + const TopoDS_Face& fac1 = TopoDS::Face(it.Value()); + theGlue.Bind(fac1, fac2); + theFE.Set(fac1, fac2); + for (theFE.InitIterator(); theFE.More();theFE.Next()) { + theGlue.Bind(theFE.EdgeFrom(),theFE.EdgeTo()); + } + } + //myMap.UnBind(fac2); // to avoid fac2 in Map when + // UpdateDescendants(theGlue) is called } } LocOpe_Operation ope = theGlue.OpeType(); if (ope == LocOpe_INVALID || - (myFuse && ope != LocOpe_FUSE) || - (!myFuse && ope != LocOpe_CUT) || - (!Collage)) { + (myFuse && ope != LocOpe_FUSE) || + (!myFuse && ope != LocOpe_CUT) || + (!Collage)) { theOpe = 2; ChangeOpe = Standard_True; } @@ -736,120 +550,18 @@ static void Descendants(const TopoDS_Shape&, TopoDS_Shape shshs = theGlue.ResultingShape(); // if (BRepOffsetAPI::IsTopologicallyValid(shshs)) { if (BRepAlgo::IsValid(shshs)) { - UpdateDescendants(theGlue); - myNewEdges = theGlue.Edges(); - myTgtEdges = theGlue.TgtEdges(); -// TopTools_ListIteratorOfListOfShape itt1; - if (myModify && !LShape.IsEmpty()) { - TopTools_ListOfShape LTool,LGShape; - LocOpe_Builder theTOpe(theGlue.ResultingShape()); - - for (it2.Initialize(LShape);it2.More();it2.Next()) { - const TopTools_ListOfShape& ldf = myMap(it2.Value()); - if (ldf.Extent() == 1 && ldf.First().IsSame(it2.Value())) { -// const TopoDS_Shape& s = it2.Value(); - LGShape.Append(it2.Value()); - } - else { - for (it.Initialize(ldf);it.More();it.Next()) { - if (M.Add(it.Value())) { -// const TopoDS_Shape& s = it.Value(); - LGShape.Append(it.Value()); - } - } - } - } - for (exp.Init(theGlue.GluedShape(),TopAbs_FACE); - exp.More();exp.Next()) { - for (it.Initialize(theGlue.DescendantFaces - (TopoDS::Face(exp.Current()))); - it.More();it.Next()) { - if (M.Add(it.Value())) { - LTool.Append(it.Value()); - } - } - } - - if (!(LGShape .IsEmpty() || LTool.IsEmpty())) { -// TopTools_ListIteratorOfListOfShape it1(LGShape); -// TopTools_ListIteratorOfListOfShape it2(LTool); - theTOpe.Perform(LGShape,LTool,myFuse); - theTOpe.PerformResult(); - TopTools_ListOfShape TOpeNewEdges, TOpeTgtEdges; - TOpeNewEdges = theTOpe.Edges(); - TOpeTgtEdges = theTOpe.TgtEdges(); - TopTools_ListIteratorOfListOfShape itt1, itt2; - itt1.Initialize(TOpeNewEdges); - itt2.Initialize(myNewEdges); - for(; itt1.More(); itt1.Next()) { - TopoDS_Edge e1 = TopoDS::Edge(itt1.Value()); - Standard_Boolean Adde1 = Standard_True; - for(; itt2.More(); itt2.Next()) { - TopoDS_Edge e2 = TopoDS::Edge(itt2.Value()); - if(e1.IsSame(e2)) { - Adde1 = Standard_False; - break; - } - } - if(Adde1) { - myNewEdges.Append(e1); - } - } - itt1.Initialize(TOpeTgtEdges); - itt2.Initialize(myTgtEdges); - for(; itt1.More(); itt1.Next()) { - TopoDS_Edge e1 = TopoDS::Edge(itt1.Value()); - Standard_Boolean Adde1 = Standard_True; - for(; itt2.More(); itt2.Next()) { - TopoDS_Edge e2 = TopoDS::Edge(itt2.Value()); - if(e1.IsSame(e2)) { - Adde1 = Standard_False; - break; - } - } - if(Adde1) { - myTgtEdges.Append(e1); - } - } - - if (theTOpe.IsDone()) { - Done(); - myShape = theTOpe.ResultingShape(); - TopExp_Explorer exf(myShape, TopAbs_FACE); - if (exf.More() && BRepAlgo::IsTopologicallyValid(myShape)) { - theOpe = 3; // ??? -// UpdateDescendants(theTOpe.Builder(),myShape); - UpdateDescendants(theTOpe.History(),myShape); - } - else { - theOpe = 2; - ChangeOpe = Standard_True; - } - } - else { - theOpe = 2; - ChangeOpe = Standard_True; - } - } - else { -#ifdef DEB - if (trc) cout << " WARNING Gluer failure" << endl; -#endif - Done(); - myShape = theGlue.ResultingShape(); - } - } - else { + UpdateDescendants(theGlue); + myNewEdges = theGlue.Edges(); + myTgtEdges = theGlue.TgtEdges(); #ifdef DEB - if (trc) cout << " Gluer result" << endl; + if (trc) cout << " Gluer result" << endl; #endif - Done(); - myShape = theGlue.ResultingShape(); - } + Done(); + myShape = theGlue.ResultingShape(); } else { - theOpe = 2; - ChangeOpe = Standard_True; + theOpe = 2; + ChangeOpe = Standard_True; } } else { @@ -882,22 +594,6 @@ static void Descendants(const TopoDS_Shape&, #ifdef DEB if (trc) cout << " Passage to topological operations" << endl; #endif - for (itm.Initialize(myGluedF); itm.More();itm.Next()) { - const TopoDS_Face& fac = TopoDS::Face(itm.Value()); - Standard_Boolean found = Standard_False; - TopTools_ListIteratorOfListOfShape it(LShape); - for(; it.More(); it.Next()) { - if(it.Value().IsSame(fac)) { - found = Standard_True; - break; - } - if(found) break; - } - if(!found) { -// failed gluing -> reset faces of gluing in LShape - LShape.Append(fac); - } - } } TopoDS_Shape Comp; @@ -905,26 +601,26 @@ static void Descendants(const TopoDS_Shape&, B.MakeCompound(TopoDS::Compound(Comp)); if (!mySFrom.IsNull() || !mySUntil.IsNull()) { if (!mySFrom.IsNull() && !FromInShape) { - TopoDS_Solid S = BRepFeat::Tool(mySFrom,FFrom,Oriffrom); - if (!S.IsNull()) { - B.Add(Comp,S); - } + TopoDS_Solid S = BRepFeat::Tool(mySFrom,FFrom,Oriffrom); + if (!S.IsNull()) { + B.Add(Comp,S); + } } if (!mySUntil.IsNull() && !UntilInShape) { - if (!mySFrom.IsNull()) { - if (!mySFrom.IsSame(mySUntil)) { - TopoDS_Solid S = BRepFeat::Tool(mySUntil,FUntil,Orifuntil); - if (!S.IsNull()) { - B.Add(Comp,S); - } - } - } - else { - TopoDS_Solid S = BRepFeat::Tool(mySUntil,FUntil,Orifuntil); - if (!S.IsNull()) { - B.Add(Comp,S); - } - } + if (!mySFrom.IsNull()) { + if (!mySFrom.IsSame(mySUntil)) { + TopoDS_Solid S = BRepFeat::Tool(mySUntil,FUntil,Orifuntil); + if (!S.IsNull()) { + B.Add(Comp,S); + } + } + } + else { + TopoDS_Solid S = BRepFeat::Tool(mySUntil,FUntil,Orifuntil); + if (!S.IsNull()) { + B.Add(Comp,S); + } + } } } @@ -933,7 +629,7 @@ static void Descendants(const TopoDS_Shape&, myPerfSelection = BRepFeat_NoSelection; } else if(myPerfSelection == BRepFeat_SelectionFU && - !FromInShape && !UntilInShape) { + !FromInShape && !UntilInShape) { myPerfSelection = BRepFeat_NoSelection; } else if(myPerfSelection == BRepFeat_SelectionShU && !UntilInShape) { @@ -950,89 +646,53 @@ static void Descendants(const TopoDS_Shape&, // the result is necessarily a compound. exp.Init(trP.Shape(),TopAbs_SOLID); if (!exp.More()) { - myStatusError = BRepFeat_EmptyCutResult; - NotDone(); - return; + myStatusError = BRepFeat_EmptyCutResult; + NotDone(); + return; } // Only solids are preserved theGShape.Nullify(); BRep_Builder B; B.MakeCompound(TopoDS::Compound(theGShape)); for (; exp.More(); exp.Next()) { - B.Add(theGShape,exp.Current()); + B.Add(theGShape,exp.Current()); } if (!BRepAlgo::IsValid(theGShape)) { - myStatusError = BRepFeat_InvShape; - NotDone(); - return; + myStatusError = BRepFeat_InvShape; + NotDone(); + return; } if(!mySFrom.IsNull()) { - if(!FromInShape) { - TopExp_Explorer ex(mySFrom, TopAbs_FACE); - for(; ex.More(); ex.Next()) { - const TopoDS_Face& fac = TopoDS::Face(ex.Current()); + if(!FromInShape) { + TopExp_Explorer ex(mySFrom, TopAbs_FACE); + for(; ex.More(); ex.Next()) { + const TopoDS_Face& fac = TopoDS::Face(ex.Current()); TopTools_ListOfShape thelist4; - myMap.Bind(fac,thelist4); - if (trP.IsDeleted(fac)) { - } - else { - myMap(fac) = trP.Modified(fac); - if (myMap(fac).IsEmpty()) myMap(fac).Append(fac); - } - } - } - else { - TopExp_Explorer ex(mySFrom, TopAbs_FACE); - for(; ex.More(); ex.Next()) { - const TopoDS_Face& fac = TopoDS::Face(ex.Current()); - Standard_Boolean found = Standard_False; - TopTools_ListIteratorOfListOfShape it(LShape); - for(; it.More(); it.Next()) { - if(it.Value().IsSame(fac)) { - found = Standard_True; - break; - } - if(found) break; - } - if(!found) { - LShape.Append(fac); - } - } - } + myMap.Bind(fac,thelist4); + if (trP.IsDeleted(fac)) { + } + else { + myMap(fac) = trP.Modified(fac); + if (myMap(fac).IsEmpty()) myMap(fac).Append(fac); + } + } + } } if(!mySUntil.IsNull()) { - if(!UntilInShape) { - TopExp_Explorer ex(mySUntil, TopAbs_FACE); - for(; ex.More(); ex.Next()) { - const TopoDS_Face& fac = TopoDS::Face(ex.Current()); + if(!UntilInShape) { + TopExp_Explorer ex(mySUntil, TopAbs_FACE); + for(; ex.More(); ex.Next()) { + const TopoDS_Face& fac = TopoDS::Face(ex.Current()); TopTools_ListOfShape thelist5; - myMap.Bind(fac,thelist5); - if (trP.IsDeleted(fac)) { - } - else { - myMap(fac) = trP.Modified(fac); - if (myMap.IsEmpty()) myMap(fac).Append(fac); - } - } - } - else { - TopExp_Explorer ex(mySUntil, TopAbs_FACE); - for(; ex.More(); ex.Next()) { - const TopoDS_Face& fac = TopoDS::Face(ex.Current()); - Standard_Boolean found = Standard_False; - TopTools_ListIteratorOfListOfShape it(LShape); - for(; it.More(); it.Next()) { - if(it.Value().IsSame(fac)) { - found = Standard_True; - break; - } - if(found) break; - } - if(!found) { - LShape.Append(fac); - } - } - } + myMap.Bind(fac,thelist5); + if (trP.IsDeleted(fac)) { + } + else { + myMap(fac) = trP.Modified(fac); + if (myMap.IsEmpty()) myMap(fac).Append(fac); + } + } + } } //modified by NIZNHY-PKV Thu Mar 21 17:27:23 2002 f //UpdateDescendants(trP.Builder(),theGShape,Standard_True); @@ -1040,180 +700,117 @@ static void Descendants(const TopoDS_Shape&, //modified by NIZNHY-PKV Thu Mar 21 17:27:31 2002 t }//if(expp.More() && !Comp.IsNull() && !myGShape.IsNull()) { // - else { - if(!mySFrom.IsNull()) { - TopExp_Explorer ex(mySFrom, TopAbs_FACE); - for(; ex.More(); ex.Next()) { - const TopoDS_Face& fac = TopoDS::Face(ex.Current()); - Standard_Boolean found = Standard_False; - TopTools_ListIteratorOfListOfShape it(LShape); - for(; it.More(); it.Next()) { - if(it.Value().IsSame(fac)) { - found = Standard_True; - break; - } - if(found) break; - } - if(!found) { - LShape.Append(fac); - } - } - } - if(!mySUntil.IsNull()) { - TopExp_Explorer ex(mySUntil, TopAbs_FACE); - for(; ex.More(); ex.Next()) { - const TopoDS_Face& fac = TopoDS::Face(ex.Current()); - Standard_Boolean found = Standard_False; - TopTools_ListIteratorOfListOfShape it(LShape); - for(; it.More(); it.Next()) { - if(it.Value().IsSame(fac)) { - found = Standard_True; - break; - } - if(found) break; - } - if(!found) { - LShape.Append(fac); - } - } - } - } - //--- generation of "just feature" for assembly = Parts of tool - TopTools_ListOfShape lshape; - LocOpe_Builder theTOpe; + Standard_Boolean bFlag = (myPerfSelection == BRepFeat_NoSelection) ? 0 : 1; + BRepFeat_Builder theBuilder; + theBuilder.Init(mySbase, theGShape); + theBuilder.SetOperation(myFuse, bFlag); + theBuilder.Perform(); + // + TopTools_ListOfShape lshape; + theBuilder.PartsOfTool(lshape); + // Standard_Real pbmin, pbmax, prmin, prmax; Standard_Boolean flag1; Handle(Geom_Curve) C; - if(!myJustFeat) { - theTOpe.Init(mySbase); - theTOpe.Perform(theGShape,LShape,myFuse); - theTOpe.BuildPartsOfTool(); - lshape = theTOpe.PartsOfTool(); - } - else { - theTOpe.Init(theGShape, mySbase); - TopTools_ListOfShape list; - theTOpe.Perform(list,LShape,Standard_False); - theTOpe.PerformResult(); - if (theTOpe.IsDone()) { - myShape = theTOpe.ResultingShape(); -// UpdateDescendants(theTOpe.Builder(),myShape); // a priori bug of update - UpdateDescendants(theTOpe.History(),myShape); // a priori bug of update - // to be done after selection of parts to be preserved - myNewEdges = theTOpe.Edges(); - myTgtEdges = theTOpe.TgtEdges(); - TopExp_Explorer explo(theTOpe.ResultingShape(), TopAbs_SOLID); - for (; explo.More(); explo.Next()) { - lshape.Append(explo.Current()); - } - } - else { - myStatusError = BRepFeat_LocOpeNotDone; - NotDone(); - return; - } - } //--- Selection of pieces of tool to be preserved - TopoDS_Solid thePartsOfTool; if(!lshape.IsEmpty() && myPerfSelection != BRepFeat_NoSelection) { - // Find ParametricMinMax depending on the constraints of Shape From and Until // -> prmin, prmax, pbmin and pbmax C = BarycCurve(); if (C.IsNull()) { - myStatusError = BRepFeat_EmptyBaryCurve; - NotDone(); - return; + myStatusError = BRepFeat_EmptyBaryCurve; + NotDone(); + return; } if(myPerfSelection == BRepFeat_SelectionSh) { - BRepFeat::ParametricMinMax(mySbase,C, - prmin, prmax, pbmin, pbmax, flag1); + BRepFeat::ParametricMinMax(mySbase,C, + prmin, prmax, pbmin, pbmax, flag1); } else if(myPerfSelection == BRepFeat_SelectionFU) { - Standard_Real prmin1, prmax1, prmin2, prmax2; - Standard_Real prbmin1, prbmax1, prbmin2, prbmax2; + Standard_Real prmin1, prmax1, prmin2, prmax2; + Standard_Real prbmin1, prbmax1, prbmin2, prbmax2; - BRepFeat::ParametricMinMax(mySFrom,C, - prmin1, prmax1, prbmin1, prbmax1, flag1); - BRepFeat::ParametricMinMax(mySUntil,C, - prmin2, prmax2, prbmin2, prbmax2, flag1); + BRepFeat::ParametricMinMax(mySFrom,C, + prmin1, prmax1, prbmin1, prbmax1, flag1); + BRepFeat::ParametricMinMax(mySUntil,C, + prmin2, prmax2, prbmin2, prbmax2, flag1); // case of revolutions - if (C->IsPeriodic()) { - Standard_Real period = C->Period(); - prmax = prmax2; - if (flag1) { - prmin = ElCLib::InPeriod(prmin1,prmax-period,prmax); - } - else { - prmin = Min(prmin1, prmin2); - } - pbmax = prbmax2; - pbmin = ElCLib::InPeriod(prbmin1,pbmax-period,pbmax); - } - else { - prmin = Min(prmin1, prmin2); - prmax = Max(prmax1, prmax2); - pbmin = Min(prbmin1, prbmin2); - pbmax = Max(prbmax1, prbmax2); - } + if (C->IsPeriodic()) { + Standard_Real period = C->Period(); + prmax = prmax2; + if (flag1) { + prmin = ElCLib::InPeriod(prmin1,prmax-period,prmax); + } + else { + prmin = Min(prmin1, prmin2); + } + pbmax = prbmax2; + pbmin = ElCLib::InPeriod(prbmin1,pbmax-period,pbmax); + } + else { + prmin = Min(prmin1, prmin2); + prmax = Max(prmax1, prmax2); + pbmin = Min(prbmin1, prbmin2); + pbmax = Max(prbmax1, prbmax2); + } } else if(myPerfSelection == BRepFeat_SelectionShU) { - Standard_Real prmin1, prmax1, prmin2, prmax2; - Standard_Real prbmin1, prbmax1, prbmin2, prbmax2; - - if(!myJustFeat && sens == 0) sens =1; - if (sens == 0) { - myStatusError = BRepFeat_IncDirection; - NotDone(); - return; - } - - BRepFeat::ParametricMinMax(mySUntil,C, - prmin1, prmax1, prbmin1, prbmax1, flag1); - - BRepFeat::ParametricMinMax(mySbase,C, - prmin2, prmax2, prbmin2, prbmax2, flag1); - if (sens == 1) { - prmin = prmin2; - prmax = prmax1; - pbmin = prbmin2; - pbmax = prbmax1; - } - else if (sens == -1) { - prmin = prmin1; - prmax = prmax2; - pbmin = prbmin1; - pbmax = prbmax2; - } + Standard_Real prmin1, prmax1, prmin2, prmax2; + Standard_Real prbmin1, prbmax1, prbmin2, prbmax2; + + if(!myJustFeat && sens == 0) sens =1; + if (sens == 0) { + myStatusError = BRepFeat_IncDirection; + NotDone(); + return; + } + + BRepFeat::ParametricMinMax(mySUntil,C, + prmin1, prmax1, prbmin1, prbmax1, flag1); + + BRepFeat::ParametricMinMax(mySbase,C, + prmin2, prmax2, prbmin2, prbmax2, flag1); + if (sens == 1) { + prmin = prmin2; + prmax = prmax1; + pbmin = prbmin2; + pbmax = prbmax1; + } + else if (sens == -1) { + prmin = prmin1; + prmax = prmax2; + pbmin = prbmin1; + pbmax = prbmax2; + } } else if (myPerfSelection == BRepFeat_SelectionU) { - Standard_Real prmin1, prmax1, prbmin1, prbmax1; - if (sens == 0) { - myStatusError = BRepFeat_IncDirection; - NotDone(); - return; - } - - // Find parts of the tool containing descendants of Shape Until - BRepFeat::ParametricMinMax(mySUntil,C, - prmin1, prmax1, prbmin1, prbmax1, flag1); - if (sens == 1) { - prmin = RealFirst(); - prmax = prmax1; - pbmin = RealFirst(); - pbmax = prbmax1; - } - else if(sens == -1) { - prmin = prmin1; - prmax = RealLast(); - pbmin = prbmin1; - pbmax = RealLast(); - } + Standard_Real prmin1, prmax1, prbmin1, prbmax1; + if (sens == 0) { + myStatusError = BRepFeat_IncDirection; + NotDone(); + return; + } + + // Find parts of the tool containing descendants of Shape Until + BRepFeat::ParametricMinMax(mySUntil,C, + prmin1, prmax1, prbmin1, prbmax1, flag1); + if (sens == 1) { + prmin = RealFirst(); + prmax = prmax1; + pbmin = RealFirst(); + pbmax = prbmax1; + } + else if(sens == -1) { + prmin = prmin1; + prmax = RealLast(); + pbmin = prbmin1; + pbmax = RealLast(); + } } @@ -1226,287 +823,233 @@ static void Descendants(const TopoDS_Shape&, if (myPerfSelection != BRepFeat_NoSelection) { // modif of the test for cts21181 : (prbmax2 and prnmin2) -> (prbmin1 and prbmax1) // correction take into account flag2 for pro15323 and flag3 for pro16060 - if (!mySUntil.IsNull()) { - TopTools_MapOfShape mapFuntil; - Descendants(mySUntil,theTOpe,mapFuntil); - if (!mapFuntil.IsEmpty()) { - for (it.Initialize(lshape); it.More(); it.Next()) { - TopExp_Explorer expf; - for (expf.Init(it.Value(),TopAbs_FACE); - expf.More(); expf.Next()) { - if (mapFuntil.Contains(expf.Current())) { - Standard_Boolean flag2,flag3; - Standard_Real prmin1, prmax1, prbmin1, prbmax1; - Standard_Real prmin2, prmax2, prbmin2, prbmax2; - BRepFeat::ParametricMinMax(expf.Current(),C, prmin1, prmax1, - prbmin1, prbmax1,flag3); - BRepFeat::ParametricMinMax(it.Value(),C, prmin2, prmax2, - prbmin2, prbmax2,flag2); - if (sens == 1) { - Standard_Boolean testOK = !flag2; - if (flag2) { - testOK = !flag1; - if (flag1 && prmax2 > prmin + delta) { - testOK = !flag3; - if (flag3 && prmax1 == prmax2) { - testOK = Standard_True; - } - } - } - if (prbmin1 < pbmax && testOK) { - if (flag2) { - flag1 = flag2; - prmax = prmax2; - } - pbmax = prbmin1; - } - } - else if (sens == -1){ - Standard_Boolean testOK = !flag2; - if (flag2) { - testOK = !flag1; - if (flag1 && prmin2 < prmax - delta) { - testOK = !flag3; - if (flag3 && prmin1 == prmin2) { - testOK = Standard_True; - } - } - } - if (prbmax1 > pbmin && testOK) { - if (flag2) { - flag1 = flag2; - prmin = prmin2; - } - pbmin = prbmax1; - } - } - break; - } - } - } - it.Initialize(lshape); - } - } - if (!mySFrom.IsNull()) { - TopTools_MapOfShape mapFfrom; - Descendants(mySFrom,theTOpe,mapFfrom); - if (!mapFfrom.IsEmpty()) { - for (it.Initialize(lshape); it.More(); it.Next()) { - TopExp_Explorer expf; - for (expf.Init(it.Value(),TopAbs_FACE); - expf.More(); expf.Next()) { - if (mapFfrom.Contains(expf.Current())) { - Standard_Boolean flag2,flag3; - Standard_Real prmin1, prmax1, prbmin1, prbmax1; - Standard_Real prmin2, prmax2, prbmin2, prbmax2; - BRepFeat::ParametricMinMax(expf.Current(),C, prmin1, prmax1, - prbmin1, prbmax1,flag3); - BRepFeat::ParametricMinMax(it.Value(),C, prmin2, prmax2, - prbmin2, prbmax2,flag2); - if (sens == 1) { - Standard_Boolean testOK = !flag2; - if (flag2) { - testOK = !flag1; - if (flag1 && prmin2 < prmax - delta) { - testOK = !flag3; - if (flag3 && prmin1 == prmin2) { - testOK = Standard_True; - } - } - } - if (prbmax1 > pbmin && testOK) { - if (flag2) { - flag1 = flag2; - prmin = prmin2; - } - pbmin = prbmax1; - } - } - else if (sens == -1){ - Standard_Boolean testOK = !flag2; - if (flag2) { - testOK = !flag1; - if (flag1 && prmax2 > prmin + delta) { - testOK = !flag3; - if (flag3 && prmax1 == prmax2) { - testOK = Standard_True; - } - } - } - if (prbmin1 < pbmax && testOK) { - if (flag2) { - flag1 = flag2; - prmax = prmax2; - } - pbmax = prbmin1; - } - } - break; - } - } - } - it.Initialize(lshape); - } - } + if (!mySUntil.IsNull()) { + TopTools_MapOfShape mapFuntil; + Descendants(mySUntil,theBuilder,mapFuntil); + if (!mapFuntil.IsEmpty()) { + for (it.Initialize(lshape); it.More(); it.Next()) { + TopExp_Explorer expf; + for (expf.Init(it.Value(),TopAbs_FACE); + expf.More(); expf.Next()) { + if (mapFuntil.Contains(expf.Current())) { + Standard_Boolean flag2,flag3; + Standard_Real prmin1, prmax1, prbmin1, prbmax1; + Standard_Real prmin2, prmax2, prbmin2, prbmax2; + BRepFeat::ParametricMinMax(expf.Current(),C, prmin1, prmax1, + prbmin1, prbmax1,flag3); + BRepFeat::ParametricMinMax(it.Value(),C, prmin2, prmax2, + prbmin2, prbmax2,flag2); + if (sens == 1) { + Standard_Boolean testOK = !flag2; + if (flag2) { + testOK = !flag1; + if (flag1 && prmax2 > prmin + delta) { + testOK = !flag3; + if (flag3 && prmax1 == prmax2) { + testOK = Standard_True; + } + } + } + if (prbmin1 < pbmax && testOK) { + if (flag2) { + flag1 = flag2; + prmax = prmax2; + } + pbmax = prbmin1; + } + } + else if (sens == -1){ + Standard_Boolean testOK = !flag2; + if (flag2) { + testOK = !flag1; + if (flag1 && prmin2 < prmax - delta) { + testOK = !flag3; + if (flag3 && prmin1 == prmin2) { + testOK = Standard_True; + } + } + } + if (prbmax1 > pbmin && testOK) { + if (flag2) { + flag1 = flag2; + prmin = prmin2; + } + pbmin = prbmax1; + } + } + break; + } + } + } + it.Initialize(lshape); + } + } + if (!mySFrom.IsNull()) { + TopTools_MapOfShape mapFfrom; + Descendants(mySFrom, theBuilder, mapFfrom); + if (!mapFfrom.IsEmpty()) { + for (it.Initialize(lshape); it.More(); it.Next()) { + TopExp_Explorer expf; + for (expf.Init(it.Value(),TopAbs_FACE); + expf.More(); expf.Next()) { + if (mapFfrom.Contains(expf.Current())) { + Standard_Boolean flag2,flag3; + Standard_Real prmin1, prmax1, prbmin1, prbmax1; + Standard_Real prmin2, prmax2, prbmin2, prbmax2; + BRepFeat::ParametricMinMax(expf.Current(),C, prmin1, prmax1, + prbmin1, prbmax1,flag3); + BRepFeat::ParametricMinMax(it.Value(),C, prmin2, prmax2, + prbmin2, prbmax2,flag2); + if (sens == 1) { + Standard_Boolean testOK = !flag2; + if (flag2) { + testOK = !flag1; + if (flag1 && prmin2 < prmax - delta) { + testOK = !flag3; + if (flag3 && prmin1 == prmin2) { + testOK = Standard_True; + } + } + } + if (prbmax1 > pbmin && testOK) { + if (flag2) { + flag1 = flag2; + prmin = prmin2; + } + pbmin = prbmax1; + } + } + else if (sens == -1){ + Standard_Boolean testOK = !flag2; + if (flag2) { + testOK = !flag1; + if (flag1 && prmax2 > prmin + delta) { + testOK = !flag3; + if (flag3 && prmax1 == prmax2) { + testOK = Standard_True; + } + } + } + if (prbmin1 < pbmax && testOK) { + if (flag2) { + flag1 = flag2; + prmax = prmax2; + } + pbmax = prbmin1; + } + } + break; + } + } + } + it.Initialize(lshape); + } + } } // Parse PartsOfTool to preserve or not depending on ParametricMinMax if (!myJustFeat) { - Standard_Boolean KeepParts = Standard_False; - BRep_Builder BB; - BB.MakeSolid(thePartsOfTool); - Standard_Real prmin1, prmax1, prbmin1, prbmax1; - Standard_Real min, max, pmin, pmax; - Standard_Boolean flag2; - for (it.Initialize(lshape); it.More(); it.Next()) { - if (C->IsPeriodic()) { - Standard_Real period = C->Period(); - Standard_Real pr, prb; - BRepFeat::ParametricMinMax(it.Value(),C, pr, prmax1, - prb, prbmax1,flag2,Standard_True); - if (flag2) { - prmin1 = ElCLib::InPeriod(pr,prmax1-period,prmax1); - } - else { - prmin1 = pr; - } - prbmin1 = ElCLib::InPeriod(prb,prbmax1-period,prbmax1); - } - else { - BRepFeat::ParametricMinMax(it.Value(),C, - prmin1, prmax1, prbmin1, prbmax1,flag2); - } - if(flag2 == Standard_False || flag1 == Standard_False) { - pmin = pbmin; - pmax = pbmax; - min = prbmin1; - max = prbmax1; - } - else { - pmin = prmin; - pmax = prmax; - min = prmin1; - max = prmax1; - } - if ((min > pmax - delta) || - (max < pmin + delta)){ - theTOpe.RemovePart(it.Value()); - } - else { - KeepParts = Standard_True; - const TopoDS_Shape& S = it.Value(); - B.Add(thePartsOfTool,S); - } - } + Standard_Boolean KeepParts = Standard_False; + Standard_Real prmin1, prmax1, prbmin1, prbmax1; + Standard_Real min, max, pmin, pmax; + Standard_Boolean flag2; + for (it.Initialize(lshape); it.More(); it.Next()) { + if (C->IsPeriodic()) { + Standard_Real period = C->Period(); + Standard_Real pr, prb; + BRepFeat::ParametricMinMax(it.Value(),C, pr, prmax1, + prb, prbmax1,flag2,Standard_True); + if (flag2) { + prmin1 = ElCLib::InPeriod(pr,prmax1-period,prmax1); + } + else { + prmin1 = pr; + } + prbmin1 = ElCLib::InPeriod(prb,prbmax1-period,prbmax1); + } + else { + BRepFeat::ParametricMinMax(it.Value(),C, + prmin1, prmax1, prbmin1, prbmax1,flag2); + } + if(flag2 == Standard_False || flag1 == Standard_False) { + pmin = pbmin; + pmax = pbmax; + min = prbmin1; + max = prbmax1; + } + else { + pmin = prmin; + pmax = prmax; + min = prmin1; + max = prmax1; + } + if (!((min > pmax - delta) || + (max < pmin + delta))) { + KeepParts = Standard_True; + const TopoDS_Shape& S = it.Value(); + theBuilder.KeepPart(S); + } + } // Case when no part of the tool is preserved - if (!KeepParts) { + if (!KeepParts) { #ifdef DEB - if (trc) cout << " No parts of tool kept" << endl; + if (trc) cout << " No parts of tool kept" << endl; #endif - myStatusError = BRepFeat_NoParts; - NotDone(); - return; - } + myStatusError = BRepFeat_NoParts; + NotDone(); + return; + } } else { // case JustFeature -> all PartsOfTool are preserved - Standard_Real prmin1, prmax1, prbmin1, prbmax1; - Standard_Real min, max, pmin, pmax; - Standard_Boolean flag2; - TopoDS_Shape Compo; - BRep_Builder B; - B.MakeCompound(TopoDS::Compound(Compo)); - for (it.Initialize(lshape); it.More(); it.Next()) { - BRepFeat::ParametricMinMax(it.Value(),C, - prmin1, prmax1, prbmin1, prbmax1,flag2); - if(flag2 == Standard_False || flag1 == Standard_False) { - pmin = pbmin; - pmax = pbmax; - min = prbmin1; - max = prbmax1; - } - else { - pmin = prmin; - pmax = prmax; - min = prmin1; - max = prmax1; - } - if ((min < pmax - delta) && - (max > pmin + delta)){ - if (!it.Value().IsNull()) { - B.Add(Compo,it.Value()); - } - } - } - myShape = Compo; + Standard_Real prmin1, prmax1, prbmin1, prbmax1; + Standard_Real min, max, pmin, pmax; + Standard_Boolean flag2; + TopoDS_Shape Compo; + BRep_Builder B; + B.MakeCompound(TopoDS::Compound(Compo)); + for (it.Initialize(lshape); it.More(); it.Next()) { + BRepFeat::ParametricMinMax(it.Value(),C, + prmin1, prmax1, prbmin1, prbmax1,flag2); + if(flag2 == Standard_False || flag1 == Standard_False) { + pmin = pbmin; + pmax = pbmax; + min = prbmin1; + max = prbmax1; + } + else { + pmin = prmin; + pmax = prmax; + min = prmin1; + max = prmax1; + } + if ((min < pmax - delta) && + (max > pmin + delta)){ + if (!it.Value().IsNull()) { + B.Add(Compo,it.Value()); + } + } + } + myShape = Compo; } } - //--- Generation of result myShape if (!myJustFeat) { -// removal of edges of section that have no common vertices -// with PartsOfTool preserved - theTOpe.PerformResult(); - if (theTOpe.IsDone()) { - Done(); - myShape = theTOpe.ResultingShape(); -// - BRepLib::SameParameter(myShape, 1.e-7, Standard_True); -// -// update new and tangent edges -// UpdateDescendants(theTOpe.Builder(),myShape); - UpdateDescendants(theTOpe.History(),myShape); - myNewEdges = theTOpe.Edges(); - if(!theTOpe.TgtEdges().IsEmpty()) { - myTgtEdges = theTOpe.TgtEdges(); - } - // else myTgtEdges.Clear(); - } - else {// last recourse (attention new and tangent edges) - if (!thePartsOfTool.IsNull()) { -#ifdef DEB - if (trc) cout << " Parts of Tool : direct Ope. Top." << endl; -#endif - if(myFuse == 1) { - //modified by NIZNHY-PKV Thu Mar 21 17:28:09 2002 f - //BRepAlgo_Fuse f(mySbase, thePartsOfTool); - BRepAlgoAPI_Fuse f(mySbase, thePartsOfTool); - //modified by NIZNHY-PKV Thu Mar 21 17:28:18 2002 t - myShape = f.Shape(); - //modified by NIZNHY-PKV Thu Mar 21 17:28:41 2002 f - //UpdateDescendants(f.Builder(), myShape, Standard_False); - UpdateDescendants(f, myShape, Standard_False); - //modified by NIZNHY-PKV Thu Mar 21 17:28:46 2002 t - Done(); - return; - } - else if(myFuse == 0) { - //modified by NIZNHY-PKV Thu Mar 21 17:29:04 2002 f - //BRepAlgo_Cut c(mySbase, thePartsOfTool); - BRepAlgoAPI_Cut c(mySbase, thePartsOfTool); - //modified by NIZNHY-PKV Thu Mar 21 17:29:07 2002 t - myShape = c.Shape(); - //modified by NIZNHY-PKV Thu Mar 21 17:29:23 2002 f - //UpdateDescendants(c.Builder(), myShape, Standard_False); - UpdateDescendants(c, myShape, Standard_False); - //modified by NIZNHY-PKV Thu Mar 21 17:29:32 2002 t - Done(); - return; - } - } - if (theTOpe.IsInvDone()) { - myStatusError = BRepFeat_LocOpeNotDone; - } - else { - myStatusError = BRepFeat_LocOpeInvNotDone; - } - NotDone(); - return; + // removal of edges of section that have no common vertices + // with PartsOfTool preserved + //modified by NIZHNY-EMV Thu May 10 15:56:24 2012 + if (bFlag) { + theBuilder.PerformResult(); + myShape = theBuilder.Shape(); + } else { + myShape = theBuilder.Shape(); } + //modified by NIZHNY-EMV Thu May 10 15:56:26 2012 + Done(); } else { // all is already done @@ -1517,8 +1060,6 @@ static void Descendants(const TopoDS_Shape&, myStatusError = BRepFeat_OK; } - - //======================================================================= //function : IsDeleted //purpose : @@ -1544,7 +1085,7 @@ const TopTools_ListOfShape& BRepFeat_Form::Modified for(; ite.More(); ite.Next()) { const TopoDS_Shape& sh = ite.Value(); if(!sh.IsSame(F)) - list.Append(sh); + list.Append(sh); } return list; } @@ -1567,7 +1108,7 @@ const TopTools_ListOfShape& BRepFeat_Form::Generated for(; ite.More(); ite.Next()) { const TopoDS_Shape& sh = ite.Value(); if(!sh.IsSame(S)) - list.Append(sh); + list.Append(sh); } return list; } @@ -1593,8 +1134,8 @@ void BRepFeat_Form::UpdateDescendants(const LocOpe_Gluer& G) for (it.Initialize(itdm.Value());it.More();it.Next()) { const TopoDS_Face& fdsc = TopoDS::Face(it.Value()); for (it2.Initialize(G.DescendantFaces(fdsc)); - it2.More();it2.Next()) { - newdsc.Add(it2.Value()); + it2.More();it2.Next()) { + newdsc.Add(it2.Value()); } } myMap.ChangeFind(orig).Clear(); @@ -1699,14 +1240,14 @@ Standard_Boolean BRepFeat_Form::TransformShapeFU(const Standard_Integer flag) } if (styp == STANDARD_TYPE(Geom_Plane) || - styp == STANDARD_TYPE(Geom_CylindricalSurface) || - styp == STANDARD_TYPE(Geom_ConicalSurface)) { + styp == STANDARD_TYPE(Geom_CylindricalSurface) || + styp == STANDARD_TYPE(Geom_ConicalSurface)) { TopExp_Explorer exp1(fac, TopAbs_WIRE); if (!exp1.More()) { - Trf = Standard_True; + Trf = Standard_True; } else { - Trf = BRep_Tool::NaturalRestriction(fac); + Trf = BRep_Tool::NaturalRestriction(fac); } } @@ -1757,79 +1298,22 @@ BRepFeat_StatusError BRepFeat_Form::CurrentStatusError() const return myStatusError; } -/* //======================================================================= //function : Descendants //purpose : //======================================================================= static void Descendants(const TopoDS_Shape& S, - const LocOpe_Builder& theTOpe, - TopTools_MapOfShape& mapF) + BRepFeat_Builder& theFB, + TopTools_MapOfShape& mapF) { mapF.Clear(); - const Handle(TopOpeBRepBuild_HBuilder) B = theTOpe.Builder(); - TopTools_ListIteratorOfListOfShape it; - TopExp_Explorer exp; - for (exp.Init(S,TopAbs_FACE); exp.More(); exp.Next()) { - const TopoDS_Face& fdsc = TopoDS::Face(exp.Current()); - if (B->IsSplit(fdsc, TopAbs_OUT)) { - for (it.Initialize(B->Splits(fdsc,TopAbs_OUT)); - it.More();it.Next()) { - mapF.Add(it.Value()); - } - } - if (B->IsSplit(fdsc, TopAbs_IN)) { - for (it.Initialize(B->Splits(fdsc,TopAbs_IN)); - it.More();it.Next()) { - mapF.Add(it.Value()); - } - } - if (B->IsSplit(fdsc, TopAbs_ON)) { - for (it.Initialize(B->Splits(fdsc,TopAbs_ON)); - it.More();it.Next()) { - mapF.Add(it.Value()); - } - } - if (B->IsMerged(fdsc, TopAbs_OUT)) { - for (it.Initialize(B->Merged(fdsc,TopAbs_OUT)); - it.More();it.Next()) { - mapF.Add(it.Value()); - } - } - if (B->IsMerged(fdsc, TopAbs_IN)) { - for (it.Initialize(B->Merged(fdsc,TopAbs_IN)); - it.More();it.Next()) { - mapF.Add(it.Value()); - } - } - if (B->IsMerged(fdsc, TopAbs_ON)) { - for (it.Initialize(B->Merged(fdsc,TopAbs_ON)); - it.More();it.Next()) { - mapF.Add(it.Value()); - } - } - } -} -*/ - -//======================================================================= -//function : Descendants -//purpose : -//======================================================================= - -static void Descendants(const TopoDS_Shape& S, - const LocOpe_Builder& theTOpe, - TopTools_MapOfShape& mapF) -{ - mapF.Clear(); - const Handle(BOP_HistoryCollector)& B = theTOpe.History(); TopTools_ListIteratorOfListOfShape it; TopExp_Explorer exp; for (exp.Init(S,TopAbs_FACE); exp.More(); exp.Next()) { const TopoDS_Face& fdsc = TopoDS::Face(exp.Current()); - const TopTools_ListOfShape& aLM=B->Modified(fdsc); + const TopTools_ListOfShape& aLM=theFB.Modified(fdsc); it.Initialize(aLM); for (; it.More(); it.Next()) { mapF.Add(it.Value()); @@ -1843,8 +1327,8 @@ static void Descendants(const TopoDS_Shape& S, //purpose : //======================================================================= void BRepFeat_Form::UpdateDescendants(const Handle(TopOpeBRepBuild_HBuilder)& B, - const TopoDS_Shape& S, - const Standard_Boolean SkipFace) + const TopoDS_Shape& S, + const Standard_Boolean SkipFace) { TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itdm; TopTools_ListIteratorOfListOfShape it,it2; @@ -1865,59 +1349,59 @@ static void Descendants(const TopoDS_Shape& S, if(sh.ShapeType() != TopAbs_FACE) continue; const TopoDS_Face& fdsc = TopoDS::Face(it.Value()); for (exp.Init(S,TopAbs_FACE);exp.More();exp.Next()) { - if (exp.Current().IsSame(fdsc)) { // preserved - newdsc.Add(fdsc); - break; - } + if (exp.Current().IsSame(fdsc)) { // preserved + newdsc.Add(fdsc); + break; + } } if (!exp.More()) { - if (B->IsSplit(fdsc, TopAbs_OUT)) { - for (it2.Initialize(B->Splits(fdsc,TopAbs_OUT)); - it2.More();it2.Next()) { - newdsc.Add(it2.Value()); - } - } - if (B->IsSplit(fdsc, TopAbs_IN)) { - for (it2.Initialize(B->Splits(fdsc,TopAbs_IN)); - it2.More();it2.Next()) { - newdsc.Add(it2.Value()); - } - } - if (B->IsSplit(fdsc, TopAbs_ON)) { - for (it2.Initialize(B->Splits(fdsc,TopAbs_ON)); - it2.More();it2.Next()) { - newdsc.Add(it2.Value()); - } - } - if (B->IsMerged(fdsc, TopAbs_OUT)) { - for (it2.Initialize(B->Merged(fdsc,TopAbs_OUT)); - it2.More();it2.Next()) { - newdsc.Add(it2.Value()); - } - } - if (B->IsMerged(fdsc, TopAbs_IN)) { - for (it2.Initialize(B->Merged(fdsc,TopAbs_IN)); - it2.More();it2.Next()) { - newdsc.Add(it2.Value()); - } - } - if (B->IsMerged(fdsc, TopAbs_ON)) { - for (it2.Initialize(B->Merged(fdsc,TopAbs_ON)); - it2.More();it2.Next()) { - newdsc.Add(it2.Value()); - } - } + if (B->IsSplit(fdsc, TopAbs_OUT)) { + for (it2.Initialize(B->Splits(fdsc,TopAbs_OUT)); + it2.More();it2.Next()) { + newdsc.Add(it2.Value()); + } + } + if (B->IsSplit(fdsc, TopAbs_IN)) { + for (it2.Initialize(B->Splits(fdsc,TopAbs_IN)); + it2.More();it2.Next()) { + newdsc.Add(it2.Value()); + } + } + if (B->IsSplit(fdsc, TopAbs_ON)) { + for (it2.Initialize(B->Splits(fdsc,TopAbs_ON)); + it2.More();it2.Next()) { + newdsc.Add(it2.Value()); + } + } + if (B->IsMerged(fdsc, TopAbs_OUT)) { + for (it2.Initialize(B->Merged(fdsc,TopAbs_OUT)); + it2.More();it2.Next()) { + newdsc.Add(it2.Value()); + } + } + if (B->IsMerged(fdsc, TopAbs_IN)) { + for (it2.Initialize(B->Merged(fdsc,TopAbs_IN)); + it2.More();it2.Next()) { + newdsc.Add(it2.Value()); + } + } + if (B->IsMerged(fdsc, TopAbs_ON)) { + for (it2.Initialize(B->Merged(fdsc,TopAbs_ON)); + it2.More();it2.Next()) { + newdsc.Add(it2.Value()); + } + } } } myMap.ChangeFind(orig).Clear(); for (itm.Initialize(newdsc); itm.More(); itm.Next()) { // check the appartenance to the shape... for (exp.Init(S,TopAbs_FACE);exp.More();exp.Next()) { - if (exp.Current().IsSame(itm.Key())) { -// const TopoDS_Shape& sh = itm.Key(); - myMap.ChangeFind(orig).Append(itm.Key()); - break; - } + if (exp.Current().IsSame(itm.Key())) { +// const TopoDS_Shape& sh = itm.Key(); + myMap.ChangeFind(orig).Append(itm.Key()); + break; + } } } } @@ -1928,8 +1412,8 @@ static void Descendants(const TopoDS_Shape& S, //purpose : //======================================================================= void BRepFeat_Form::UpdateDescendants(const BRepAlgoAPI_BooleanOperation& aBOP, - const TopoDS_Shape& S, - const Standard_Boolean SkipFace) + const TopoDS_Shape& S, + const Standard_Boolean SkipFace) { TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itdm; TopTools_ListIteratorOfListOfShape it,it2; @@ -1950,88 +1434,33 @@ static void Descendants(const TopoDS_Shape& S, if(sh.ShapeType() != TopAbs_FACE) continue; const TopoDS_Face& fdsc = TopoDS::Face(it.Value()); for (exp.Init(S,TopAbs_FACE);exp.More();exp.Next()) { - if (exp.Current().IsSame(fdsc)) { // preserved - newdsc.Add(fdsc); - break; - } + if (exp.Current().IsSame(fdsc)) { // preserved + newdsc.Add(fdsc); + break; + } } if (!exp.More()) { - BRepAlgoAPI_BooleanOperation* pBOP=(BRepAlgoAPI_BooleanOperation*)&aBOP; - const TopTools_ListOfShape& aLM=pBOP->Modified(fdsc); - it2.Initialize(aLM); - for (; it2.More(); it2.Next()) { - const TopoDS_Shape& aS=it2.Value(); - newdsc.Add(aS); - } - + BRepAlgoAPI_BooleanOperation* pBOP=(BRepAlgoAPI_BooleanOperation*)&aBOP; + const TopTools_ListOfShape& aLM=pBOP->Modified(fdsc); + it2.Initialize(aLM); + for (; it2.More(); it2.Next()) { + const TopoDS_Shape& aS=it2.Value(); + newdsc.Add(aS); + } + } } myMap.ChangeFind(orig).Clear(); for (itm.Initialize(newdsc); itm.More(); itm.Next()) { // check the appartenance to the shape... for (exp.Init(S,TopAbs_FACE);exp.More();exp.Next()) { - if (exp.Current().IsSame(itm.Key())) { -// const TopoDS_Shape& sh = itm.Key(); - myMap.ChangeFind(orig).Append(itm.Key()); - break; - } + if (exp.Current().IsSame(itm.Key())) { +// const TopoDS_Shape& sh = itm.Key(); + myMap.ChangeFind(orig).Append(itm.Key()); + break; + } } } } } //modified by NIZNHY-PKV Thu Mar 21 18:43:36 2002 t -//======================================================================= -//function : UpdateDescendants -//purpose : -//======================================================================= - void BRepFeat_Form::UpdateDescendants(const Handle(BOP_HistoryCollector)& aBOP, - const TopoDS_Shape& S, - const Standard_Boolean SkipFace) -{ - TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itdm; - TopTools_ListIteratorOfListOfShape it,it2; - TopTools_MapIteratorOfMapOfShape itm; - TopExp_Explorer exp; - - for (itdm.Initialize(myMap);itdm.More();itdm.Next()) { - const TopoDS_Shape& orig = itdm.Key(); - if (SkipFace && orig.ShapeType() == TopAbs_FACE) { - continue; - } - TopTools_MapOfShape newdsc; - - if (itdm.Value().IsEmpty()) {myMap.ChangeFind(orig).Append(orig);} - - for (it.Initialize(itdm.Value());it.More();it.Next()) { - const TopoDS_Shape& sh = it.Value(); - if(sh.ShapeType() != TopAbs_FACE) continue; - const TopoDS_Face& fdsc = TopoDS::Face(it.Value()); - for (exp.Init(S,TopAbs_FACE);exp.More();exp.Next()) { - if (exp.Current().IsSame(fdsc)) { // preserved - newdsc.Add(fdsc); - break; - } - } - if (!exp.More()) { - const TopTools_ListOfShape& aLM=aBOP->Modified(fdsc); - it2.Initialize(aLM); - for (; it2.More(); it2.Next()) { - const TopoDS_Shape& aS=it2.Value(); - newdsc.Add(aS); - } - - } - } - myMap.ChangeFind(orig).Clear(); - for (itm.Initialize(newdsc); itm.More(); itm.Next()) { - // check the appartenance to the shape... - for (exp.Init(S,TopAbs_FACE);exp.More();exp.Next()) { - if (exp.Current().IsSame(itm.Key())) { -// const TopoDS_Shape& sh = itm.Key(); - myMap.ChangeFind(orig).Append(itm.Key()); - break; - } - } - } - } -} diff --git a/src/BRepFeat/BRepFeat_LocalOperation.cdl b/src/BRepFeat/BRepFeat_LocalOperation.cdl deleted file mode 100755 index 055605aeef..0000000000 --- a/src/BRepFeat/BRepFeat_LocalOperation.cdl +++ /dev/null @@ -1,190 +0,0 @@ --- Created on: 1995-06-13 --- Created by: Jacques GOUSSARD --- Copyright (c) 1995-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class LocalOperation from BRepFeat inherits Builder from BRepFeat - - ---Purpose: One of the most significant - -- aspects of BRepFeat functionality is the use of local operations as - -- opposed to global ones. In a global operation, you would first - -- construct a form of the type you wanted in your final feature, and - -- then remove matter so that it could fit into your initial basis - -- object. In a local operation, however, you specify the domain - -- of the feature construction with aspects of the shape on which the - -- feature is being created. These semantics are expressed in terms - -- of a member shape of the basis shape from which - or up to which - -- - matter will be added or removed. As a result, local - -- operations make calculations simpler and faster than global operations. - -- In BRepFeat, the semantics of local operations define features - -- constructed from a contour or a part of the basis shape referred to as the tool. - -uses - Shape from TopoDS, - ListOfShape from TopTools - -raises - NotDone from StdFail, - ConstructionError from Standard - -is - - Create - ---Purpose: Builds the framework to store the topological shape - -- which is to be created by the local operation. - -- Initializes the empty constructor. - returns LocalOperation from BRepFeat; - ---C++: inline - - - Create(S: Shape from TopoDS) - ---C++: inline - ---Purpose: Builds the framework to store the topological shape - -- which is to be created by the local operation. - -- Initializes shape S for a local operation. - -- The exception ConstructionError is raised if is a null shape. - returns LocalOperation from BRepFeat - raises ConstructionError from Standard; - - - Create(S1,S2: Shape from TopoDS) - ---C++: inline - ---Purpose: Builds the framework to store the topological shape - -- which is to be created by the local operation. - -- Initializes S1 and S2 for a local operation. - -- The exception ConstructionError is raised if is a null shape. - returns LocalOperation from BRepFeat - raises ConstructionError from Standard; - --- Init(me: in out; S: Shape from TopoDS) is inherited from BRepFeat_Builder. - --- Init(me: in out; S,T: Shape from TopoDS) is inherited from BRepFeat_Builder. - - - Perform(me: in out; T : Shape from TopoDS; - L : ListOfShape from TopTools; - Fuse : Boolean from Standard) - ---Purpose: Performs the local operation on the formerly given - -- shape, with the tool . defines a set of - -- faces of the shape. The list may not be empty. - -- The boolean gives the type of operation. If - -- set to Standard_True, the operation is a fusion. - -- If set to Standard_False, the operation is a - -- cutting one. - -- - -- The Perform process stops just before constructing - -- any result in order to authorize the selection of - -- parts of the tool. After a call to Perform, it is - -- possible to call BuilPartsOfTool, then - -- RemovePart/ActivatePart to select valid parts, and - -- it is necessary to call PerformResult to get any - -- result. - ---C++: inline - - raises ConstructionError from Standard - --- The exception is raised if is null or same as the shape. - is static; - - - - Perform(me: in out; LShape : ListOfShape from TopTools; - LTool : ListOfShape from TopTools; - Fuse : Boolean from Standard) - - ---Purpose: Performs the local operation on the formerly given - -- shape and tool. defines a set of faces - -- of the shape, a set of faces of the tool. - -- The boolean gives the type of operation. - -- If set to Standard_True, the operation is a - -- fusion. If set to Standard_False, the operation - -- is a cutting one. If (resp. ) is - -- empty, the whole shape (resp. tool) is used. - -- - -- The Perform process stops just before constructing - -- any result in order to authorize the selection of - -- parts of the tool. After a call to Perform, it is - -- possible to call BuilPartsOfTool, then - -- RemovePart/ActivatePart to select valid parts, and - -- it is necessary to call PerformResult to get any - -- result. - ---C++: inline - - raises ConstructionError from Standard - --- The exception is raised if is a null shape. - is static; - - - - BuildPartsOfTool(me: in out) - ---Purpose: Constructs the primitive which serves as the tool for the - -- feature construction. Gives faces concerned by the - -- construction and builds by performing one of the - -- Boolean operations on the two intersecting shapes. - -- Raises NotDone from StdFail if no call to Perform has been done. - ---C++: inline - raises NotDone from StdFail - is static; - - - PartsOfTool(me) - ---Purpose: Returns the list of the parts of tool. Each of - -- these parts is a TopoDS_Shell. - -- Raises NotDone if no call to BuildPartsOfTool has been done. - returns ListOfShape from TopTools - ---C++: return const& - ---C++: inline - raises NotDone from StdFail - - is static; - - - RemovePart(me: in out; S: Shape from TopoDS) - ---Purpose: Removes from the list of valid parts of tool. - -- Raises NotDone if no call to BuildPartsOfTool has - -- been done. - ---C++: inline - raises NotDone from StdFail - is static; - - - ActivatePart(me: in out; S: Shape from TopoDS) - ---Purpose: By default, all tool parts are valid for the local operation. - -- This method removes from the list of invalid parts of - -- tool. By default, all parts of tool are valid for - -- the local operation. - ---C++: inline - raises NotDone from StdFail - -- The exception is raised if no call to BuildPartsOfTool has - -- been done. - is static; - ---- Redefinition of BRepBuilderAPI_MakeShape methods --- --- - - Build(me: in out) - ---Purpose: Builds the resulting shape (redefined from - -- MakeShape). Invalidates the given parts of tools - -- if any, and performs the result of the local - -- operation. - - is redefined; - -end LocalOperation; diff --git a/src/BRepFeat/BRepFeat_LocalOperation.cxx b/src/BRepFeat/BRepFeat_LocalOperation.cxx deleted file mode 100755 index c631e3dced..0000000000 --- a/src/BRepFeat/BRepFeat_LocalOperation.cxx +++ /dev/null @@ -1,54 +0,0 @@ -// Created on: 1995-06-13 -// Created by: Jacques GOUSSARD -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include - -#include - -//======================================================================= -//function : Build -//purpose : -//======================================================================= - -void BRepFeat_LocalOperation::Build () -{ -// try { - myBuilder.PerformResult(); - if (myBuilder.IsDone()) { - Done(); - myShape = myBuilder.ResultingShape(); - - // creation of the Map. - TopExp_Explorer ex; - myMap.Clear(); - for (ex.Init(myShape, TopAbs_FACE); ex.More(); ex.Next()) { - myMap.Add(ex.Current()); - } - } - else { - NotDone(); - } -// } -// catch (StdFail_NotDone) { -// NotDone(); -// } -} diff --git a/src/BRepFeat/BRepFeat_LocalOperation.lxx b/src/BRepFeat/BRepFeat_LocalOperation.lxx deleted file mode 100755 index d1b98e71b8..0000000000 --- a/src/BRepFeat/BRepFeat_LocalOperation.lxx +++ /dev/null @@ -1,127 +0,0 @@ -// Created on: 1995-06-13 -// Created by: Jacques GOUSSARD -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - - -//======================================================================= -//function : BRepFeat_LocalOperation -//purpose : -//======================================================================= - -inline BRepFeat_LocalOperation::BRepFeat_LocalOperation () -{ -} - - -//======================================================================= -//function : BRepFeat_LocalOperation -//purpose : -//======================================================================= - -inline BRepFeat_LocalOperation::BRepFeat_LocalOperation - (const TopoDS_Shape& S) : BRepFeat_Builder(S) -{ -} - - -//======================================================================= -//function : BRepFeat_LocalOperation -//purpose : -//======================================================================= - -inline BRepFeat_LocalOperation::BRepFeat_LocalOperation - (const TopoDS_Shape& S, - const TopoDS_Shape& T) : BRepFeat_Builder(S,T) -{ -} - - -//======================================================================= -//function : Perform -//purpose : -//======================================================================= - -inline void BRepFeat_LocalOperation::Perform(const TopoDS_Shape& T, - const TopTools_ListOfShape& L, - const Standard_Boolean Fuse) -{ - myBuilder.Perform(T,L,Fuse); -} - - -//======================================================================= -//function : Perform -//purpose : -//======================================================================= - -inline void BRepFeat_LocalOperation::Perform(const TopTools_ListOfShape& LS, - const TopTools_ListOfShape& LT, - const Standard_Boolean Fuse) -{ - myBuilder.Perform(LS,LT,Fuse); -} - - -//======================================================================= -//function : BuildPartsOfTool -//purpose : -//======================================================================= - -inline void BRepFeat_LocalOperation::BuildPartsOfTool () -{ - myBuilder.BuildPartsOfTool(); -} - - -//======================================================================= -//function : PartsOfTool -//purpose : -//======================================================================= - -inline const TopTools_ListOfShape& BRepFeat_LocalOperation:: - PartsOfTool () const -{ - return myBuilder.PartsOfTool(); -} - - -//======================================================================= -//function : RemovePart -//purpose : -//======================================================================= - -inline void BRepFeat_LocalOperation::RemovePart(const TopoDS_Shape& S) -{ - myBuilder.RemovePart(S); -} - - -//======================================================================= -//function : ActivatePart -//purpose : -//======================================================================= - -inline void BRepFeat_LocalOperation::ActivatePart(const TopoDS_Shape& S) -{ - myBuilder.ActivatePart(S); -} - - diff --git a/src/BRepFeat/BRepFeat_MakeCylindricalHole.cdl b/src/BRepFeat/BRepFeat_MakeCylindricalHole.cdl index 01195962a1..16165e401e 100755 --- a/src/BRepFeat/BRepFeat_MakeCylindricalHole.cdl +++ b/src/BRepFeat/BRepFeat_MakeCylindricalHole.cdl @@ -22,7 +22,7 @@ class MakeCylindricalHole from BRepFeat inherits Builder from BRepFeat - ---Purpose: Provides a tool to make cylindrical holes on a shape. + ---Purpose: Provides a tool to make cylindrical holes on a shape. uses Shape from TopoDS, Face from TopoDS, @@ -36,127 +36,109 @@ raises NotDone from StdFail, is Create - ---Purpose: Empty constructor. - returns MakeCylindricalHole from BRepFeat; - ---C++: inline - - - Create(S: Shape from TopoDS) - ---Purpose: Creates the tool to perform hole(s) on the shape . - ---C++: inline - returns MakeCylindricalHole from BRepFeat; - - - Create(S: Shape from TopoDS; Axis: Ax1 from gp) - ---Purpose: Creates the tool to perform hole(s) on the shape , - -- with the axis . - ---C++: inline - returns MakeCylindricalHole from BRepFeat; - - --- Init(me: in out; S: Shape from TopoDS) is inherited from BRepFeat_Builder. + ---Purpose: Empty constructor. + returns MakeCylindricalHole from BRepFeat; + ---C++: inline Init(me: in out; Axis: Ax1 from gp) - ---Purpose: Sets the axis of the hole(s). - ---C++: inline - is static; + ---Purpose: Sets the axis of the hole(s). + ---C++: inline + is static; Init(me: in out; S: Shape from TopoDS; Axis: Ax1 from gp) - ---Purpose: Sets the shape and axis on which hole(s) will be - -- performed. + ---Purpose: Sets the shape and axis on which hole(s) will be + -- performed. ---C++: inline - is static; + is static; Perform(me: in out; Radius: Real from Standard) - ---Purpose: Performs every holes of radius . This - -- command has the same effect as a cut operation - -- with an infinite cylinder defined by the given - -- axis and . + ---Purpose: Performs every holes of radius . This + -- command has the same effect as a cut operation + -- with an infinite cylinder defined by the given + -- axis and . - raises ConstructionError from Standard - -- The exception is raised when no shape or no axis is defined. - is static; + raises ConstructionError from Standard + -- The exception is raised when no shape or no axis is defined. + is static; Perform(me: in out; Radius: Real from Standard; PFrom,PTo: Real from Standard; WithControl: Boolean from Standard = Standard_True) - ---Purpose: Performs evry hole of radius located - -- between PFrom and PTo on the given axis. If - -- is set to Standard_False no control - -- are done on the resulting shape after the - -- operation is performed. + ---Purpose: Performs evry hole of radius located + -- between PFrom and PTo on the given axis. If + -- is set to Standard_False no control + -- are done on the resulting shape after the + -- operation is performed. - raises ConstructionError from Standard - -- The exception is raised when no shape or no axis is defined. - is static; + raises ConstructionError from Standard + -- The exception is raised when no shape or no axis is defined. + is static; PerformThruNext(me: in out; Radius: Real from Standard; WithControl: Boolean from Standard = Standard_True) - ---Purpose: Performs the first hole of radius , in the - -- direction of the defined axis. First hole signify - -- first encountered after the origin of the axis. If - -- is set to Standard_False no control - -- are done on the resulting shape after the - -- operation is performed. + ---Purpose: Performs the first hole of radius , in the + -- direction of the defined axis. First hole signify + -- first encountered after the origin of the axis. If + -- is set to Standard_False no control + -- are done on the resulting shape after the + -- operation is performed. - raises ConstructionError from Standard - -- The exception is raised when no shape or no axis is defined. - is static; + raises ConstructionError from Standard + -- The exception is raised when no shape or no axis is defined. + is static; PerformUntilEnd(me: in out; Radius: Real from Standard; WithControl: Boolean from Standard = Standard_True) - ---Purpose: Performs evry holes of radius located - -- after the origin of the given axis. If - -- is set to Standard_False no control - -- are done on the resulting shape after the - -- operation is performed. + ---Purpose: Performs evry holes of radius located + -- after the origin of the given axis. If + -- is set to Standard_False no control + -- are done on the resulting shape after the + -- operation is performed. - raises ConstructionError from Standard - -- The exception is raised when no shape or no axis is defined. - is static; + raises ConstructionError from Standard + -- The exception is raised when no shape or no axis is defined. + is static; PerformBlind(me: in out; Radius: Real from Standard; Length: Real from Standard; - WithControl: Boolean from Standard = Standard_True) - ---Purpose: Performs a blind hole of radius and - -- length . The length is measured from the - -- origin of the given axis. If is set - -- to Standard_False no control are done after the - -- operation is performed. + WithControl: Boolean from Standard = Standard_True) + ---Purpose: Performs a blind hole of radius and + -- length . The length is measured from the + -- origin of the given axis. If is set + -- to Standard_False no control are done after the + -- operation is performed. - raises ConstructionError from Standard - -- The exception is raised when no shape or no axis is defined. - is static; + raises ConstructionError from Standard + -- The exception is raised when no shape or no axis is defined. + is static; Status(me) - ---Purpose: Returns the status after a hole is performed. - ---C++: inline - returns Status from BRepFeat - is static; + ---Purpose: Returns the status after a hole is performed. + ---C++: inline + returns Status from BRepFeat + is static; --- Redefinition of BRepBuilderAPI_MakeShape methods -- -- - Build(me: in out) - ---Purpose: Builds the resulting shape (redefined from - -- MakeShape). Invalidates the given parts of tools - -- if any, and performs the result of the local - -- operation. - - is redefined; + Build(me:out); + ---Purpose: Builds the resulting shape (redefined from + -- MakeShape). Invalidates the given parts of tools + -- if any, and performs the result of the local + -- operation. --- Private implementation method @@ -164,8 +146,8 @@ is Validate(me: in out) - returns Status from BRepFeat - is static private; + returns Status from BRepFeat + is static private; fields diff --git a/src/BRepFeat/BRepFeat_MakeCylindricalHole.cxx b/src/BRepFeat/BRepFeat_MakeCylindricalHole.cxx index 3ebb837f22..10e7d03398 100755 --- a/src/BRepFeat/BRepFeat_MakeCylindricalHole.cxx +++ b/src/BRepFeat/BRepFeat_MakeCylindricalHole.cxx @@ -47,12 +47,12 @@ static void Baryc(const TopoDS_Shape&, - gp_Pnt&); + gp_Pnt&); static void BoxParameters(const TopoDS_Shape&, - const gp_Ax1&, - Standard_Real&, - Standard_Real&); + const gp_Ax1&, + Standard_Real&, + Standard_Real&); //======================================================================= @@ -62,34 +62,34 @@ static void BoxParameters(const TopoDS_Shape&, void BRepFeat_MakeCylindricalHole::Perform(const Standard_Real Radius) { - if (myBuilder.OriginalShape().IsNull() || !myAxDef) { + if (Object().IsNull() || !myAxDef) { Standard_ConstructionError::Raise(); } myIsBlind = Standard_False; myStatus = BRepFeat_NoError; - LocOpe_CurveShapeIntersector theASI(myAxis,myBuilder.OriginalShape()); + LocOpe_CurveShapeIntersector theASI(myAxis,Object()); if (!theASI.IsDone() || theASI.NbPoints() <= 0) { myStatus = BRepFeat_InvalidPlacement; return; } - TopTools_ListOfShape theList; - for (Standard_Integer i=1; i<= theASI.NbPoints(); i++) { - theList.Append(theASI.Point(i).Face()); - } + //TopTools_ListOfShape theList; + //for (Standard_Integer i=1; i<= theASI.NbPoints(); i++) { + // theList.Append(theASI.Point(i).Face()); + //} // It is not possible to use infinite cylinder for topological operations. Standard_Real PMin,PMax; - BoxParameters(myBuilder.OriginalShape(),myAxis,PMin,PMax); + BoxParameters(Object(),myAxis,PMin,PMax); Standard_Real Heigth = 2.*(PMax-PMin); gp_XYZ theOrig = myAxis.Location().XYZ(); theOrig += ((3.*PMin-PMax)/2.) * myAxis.Direction().XYZ(); gp_Pnt p1_ao1(theOrig); gp_Ax2 a1_ao1(p1_ao1,myAxis.Direction()); BRepPrim_Cylinder theCylinder(a1_ao1, - Radius, - Heigth); + Radius, + Heigth); // Probably it is better to make cut directly @@ -105,7 +105,11 @@ void BRepFeat_MakeCylindricalHole::Perform(const Standard_Real Radius) // BRepTools::Dump(theTool,cout); Standard_Boolean Fuse = Standard_False; - myBuilder.Perform(theTool,theList,Fuse); + // + AddTool(theTool); + SetOperation(Fuse); + BOPAlgo_Builder::Perform(); + //myBuilder.Perform(theTool,theList,Fuse); // myBuilder.PerformResult(); } @@ -116,10 +120,10 @@ void BRepFeat_MakeCylindricalHole::Perform(const Standard_Real Radius) //======================================================================= void BRepFeat_MakeCylindricalHole::PerformThruNext(const Standard_Real Radius, - const Standard_Boolean Cont) + const Standard_Boolean Cont) { - if (myBuilder.OriginalShape().IsNull() || !myAxDef) { + if (Object().IsNull() || !myAxDef) { Standard_ConstructionError::Raise(); } @@ -127,7 +131,7 @@ void BRepFeat_MakeCylindricalHole::PerformThruNext(const Standard_Real Radius, myValidate = Cont; myStatus = BRepFeat_NoError; - LocOpe_CurveShapeIntersector theASI(myAxis,myBuilder.OriginalShape()); + LocOpe_CurveShapeIntersector theASI(myAxis,Object()); if (!theASI.IsDone()) { myStatus = BRepFeat_InvalidPlacement; return; @@ -142,12 +146,12 @@ void BRepFeat_MakeCylindricalHole::PerformThruNext(const Standard_Real Radius, First = theASI.Point(IndFrom).Parameter(); ok = theASI.LocalizeAfter(IndTo,theOr,IndFrom,IndTo); if (ok) { - if (theOr != TopAbs_REVERSED) { - ok = Standard_False; - } - else { - Last = theASI.Point(IndTo).Parameter(); - } + if (theOr != TopAbs_REVERSED) { + ok = Standard_False; + } + else { + Last = theASI.Point(IndTo).Parameter(); + } } } @@ -155,12 +159,12 @@ void BRepFeat_MakeCylindricalHole::PerformThruNext(const Standard_Real Radius, Last = theASI.Point(IndTo).Parameter(); ok = theASI.LocalizeBefore(IndFrom,theOr,IndFrom,IndTo); if (ok) { - if (theOr != TopAbs_FORWARD) { - ok = Standard_False; - } - else { - First = theASI.Point(IndFrom).Parameter(); - } + if (theOr != TopAbs_FORWARD) { + ok = Standard_False; + } + else { + First = theASI.Point(IndFrom).Parameter(); + } } } } @@ -169,7 +173,7 @@ void BRepFeat_MakeCylindricalHole::PerformThruNext(const Standard_Real Radius, return; } - TopTools_ListOfShape theList; + /*TopTools_ListOfShape theList; for (Standard_Integer i=1; i<= theASI.NbPoints(); i++) { prm = theASI.Point(i).Parameter(); if (prm >= First && prm <= Last) { @@ -178,18 +182,18 @@ void BRepFeat_MakeCylindricalHole::PerformThruNext(const Standard_Real Radius, else if (prm > Last) { break; } - } + }*/ // It is not possible to use infinite cylinder for topological operations. Standard_Real PMin,PMax; - BoxParameters(myBuilder.OriginalShape(),myAxis,PMin,PMax); + BoxParameters(Object(),myAxis,PMin,PMax); Standard_Real Heigth = 2.*(PMax-PMin); gp_XYZ theOrig = myAxis.Location().XYZ(); theOrig += ((3.*PMin-PMax)/2.) * myAxis.Direction().XYZ(); gp_Pnt p2_ao1(theOrig); gp_Ax2 a2_ao1(p2_ao1,myAxis.Direction()); BRepPrim_Cylinder theCylinder(a2_ao1, - Radius, - Heigth); + Radius, + Heigth); BRep_Builder B; TopoDS_Solid theTool; @@ -202,12 +206,17 @@ void BRepFeat_MakeCylindricalHole::PerformThruNext(const Standard_Real Radius, // BRepTools::Dump(theTool,cout); Standard_Boolean Fuse = Standard_False; - myBuilder.Perform(theTool,theList,Fuse); - myBuilder.BuildPartsOfTool(); + //myBuilder.Perform(theTool,theList,Fuse); + //myBuilder.BuildPartsOfTool(); + AddTool(theTool); + SetOperation(Fuse); + BOPAlgo_Builder::Perform(); + TopTools_ListOfShape parts; + PartsOfTool(parts); Standard_Integer nbparts = 0; - TopTools_ListIteratorOfListOfShape its(myBuilder.PartsOfTool()); + TopTools_ListIteratorOfListOfShape its(parts); for (; its.More(); its.Next()) { nbparts ++; } @@ -221,38 +230,42 @@ void BRepFeat_MakeCylindricalHole::PerformThruNext(const Standard_Real Radius, TopoDS_Shape tokeep; Standard_Real parbar,parmin = Last; gp_Pnt Barycentre; - for (its.Initialize(myBuilder.PartsOfTool()); its.More(); its.Next()) { + for (its.Initialize(parts); its.More(); its.Next()) { Baryc(its.Value(),Barycentre); parbar = ElCLib::LineParameter(myAxis,Barycentre); if (parbar >= First && parbar <= Last && parbar <= parmin) { - parmin = parbar; - tokeep = its.Value(); + parmin = parbar; + tokeep = its.Value(); } } if (tokeep.IsNull()) { // preserve the closest interval Standard_Real dmin = RealLast(); - for (its.Initialize(myBuilder.PartsOfTool()); its.More(); its.Next()) { - Baryc(its.Value(),Barycentre); - parbar = ElCLib::LineParameter(myAxis,Barycentre); - if (parbar < First) { - if (First - parbar < dmin ) { - dmin = First-parbar; - tokeep = its.Value(); - } - else { // parbar > Last - if (parbar - Last < dmin) { - dmin = parbar-Last; - tokeep = its.Value(); - } - } - } + for (its.Initialize(parts); its.More(); its.Next()) { + Baryc(its.Value(),Barycentre); + parbar = ElCLib::LineParameter(myAxis,Barycentre); + if (parbar < First) { + if (First - parbar < dmin ) { + dmin = First-parbar; + tokeep = its.Value(); + } + else { // parbar > Last + if (parbar - Last < dmin) { + dmin = parbar-Last; + tokeep = its.Value(); + } + } + } } } - for (its.Initialize(myBuilder.PartsOfTool()); its.More(); its.Next()) { - if (!tokeep.IsSame(its.Value())) { - myBuilder.RemovePart(its.Value()); + for (its.Initialize(parts); its.More(); its.Next()) { + //if (!tokeep.IsSame(its.Value())) { + // myBuilder.RemovePart(its.Value()); + //} + if (tokeep.IsSame(its.Value())) { + KeepPart(its.Value()); + break; } } } @@ -265,10 +278,10 @@ void BRepFeat_MakeCylindricalHole::PerformThruNext(const Standard_Real Radius, //======================================================================= void BRepFeat_MakeCylindricalHole::PerformUntilEnd(const Standard_Real Radius, - const Standard_Boolean Cont) + const Standard_Boolean Cont) { - if (myBuilder.OriginalShape().IsNull() || !myAxDef) { + if (Object().IsNull() || !myAxDef) { Standard_ConstructionError::Raise(); } @@ -276,7 +289,7 @@ void BRepFeat_MakeCylindricalHole::PerformUntilEnd(const Standard_Real Radius, myValidate = Cont; myStatus = BRepFeat_NoError; - LocOpe_CurveShapeIntersector theASI(myAxis,myBuilder.OriginalShape()); + LocOpe_CurveShapeIntersector theASI(myAxis,Object()); if (!theASI.IsDone()) { myStatus = BRepFeat_InvalidPlacement; return; @@ -296,12 +309,12 @@ void BRepFeat_MakeCylindricalHole::PerformUntilEnd(const Standard_Real Radius, First = theASI.Point(IndFrom).Parameter(); ok = theASI.LocalizeBefore(theASI.NbPoints()+1,theOr,IndFrom,IndTo); if (ok) { - if (theOr != TopAbs_REVERSED) { - ok = Standard_False; - } - else { - Last = theASI.Point(IndTo).Parameter(); - } + if (theOr != TopAbs_REVERSED) { + ok = Standard_False; + } + else { + Last = theASI.Point(IndTo).Parameter(); + } } } } @@ -323,14 +336,14 @@ void BRepFeat_MakeCylindricalHole::PerformUntilEnd(const Standard_Real Radius, // It is not possible to use infinite cylinder for topological operations. Standard_Real PMin,PMax; - BoxParameters(myBuilder.OriginalShape(),myAxis,PMin,PMax); + BoxParameters(Object(),myAxis,PMin,PMax); Standard_Real Heigth = 2.*(PMax-PMin); gp_XYZ theOrig = myAxis.Location().XYZ(); theOrig += ((3.*PMin-PMax)/2.) * myAxis.Direction().XYZ(); gp_Pnt p3_ao1(theOrig); gp_Ax2 a3_ao1(p3_ao1,myAxis.Direction()); BRepPrim_Cylinder theCylinder(a3_ao1, - Radius, - Heigth); + Radius, + Heigth); BRep_Builder B; TopoDS_Solid theTool; @@ -343,12 +356,16 @@ void BRepFeat_MakeCylindricalHole::PerformUntilEnd(const Standard_Real Radius, // BRepTools::Dump(theTool,cout); Standard_Boolean Fuse = Standard_False; - myBuilder.Perform(theTool,theList,Fuse); - myBuilder.BuildPartsOfTool(); - + //myBuilder.Perform(theTool,theList,Fuse); + //myBuilder.BuildPartsOfTool(); + AddTool(theTool); + SetOperation(Fuse); + BOPAlgo_Builder::Perform(); + TopTools_ListOfShape parts; + PartsOfTool(parts); Standard_Integer nbparts = 0; - TopTools_ListIteratorOfListOfShape its(myBuilder.PartsOfTool()); + TopTools_ListIteratorOfListOfShape its(parts); for (; its.More(); its.Next()) { nbparts ++; } @@ -360,15 +377,14 @@ void BRepFeat_MakeCylindricalHole::PerformUntilEnd(const Standard_Real Radius, if (nbparts >= 2) { // preserve everything above the First Standard_Real parbar; gp_Pnt Barycentre; - for (its.Initialize(myBuilder.PartsOfTool()); its.More(); its.Next()) { + for (its.Initialize(parts); its.More(); its.Next()) { Baryc(its.Value(),Barycentre); parbar = ElCLib::LineParameter(myAxis,Barycentre); - if (parbar < First) { - myBuilder.RemovePart(its.Value()); + if (parbar > First) { + KeepPart(its.Value()); } } } -// myBuilder.PerformResult(); } @@ -378,12 +394,12 @@ void BRepFeat_MakeCylindricalHole::PerformUntilEnd(const Standard_Real Radius, //======================================================================= void BRepFeat_MakeCylindricalHole::Perform(const Standard_Real Radius, - const Standard_Real PFrom, - const Standard_Real PTo, - const Standard_Boolean Cont) + const Standard_Real PFrom, + const Standard_Real PTo, + const Standard_Boolean Cont) { - if (myBuilder.OriginalShape().IsNull() || !myAxDef) { + if (Object().IsNull() || !myAxDef) { Standard_ConstructionError::Raise(); } @@ -391,7 +407,7 @@ void BRepFeat_MakeCylindricalHole::Perform(const Standard_Real Radius, myValidate = Cont; myStatus = BRepFeat_NoError; - LocOpe_CurveShapeIntersector theASI(myAxis,myBuilder.OriginalShape()); + LocOpe_CurveShapeIntersector theASI(myAxis,Object()); if (!theASI.IsDone()) { myStatus = BRepFeat_InvalidPlacement; return; @@ -420,12 +436,12 @@ void BRepFeat_MakeCylindricalHole::Perform(const Standard_Real Radius, First = theASI.Point(IndFrom).Parameter(); ok = theASI.LocalizeBefore(thePTo,theOr,IndFrom,IndTo); if (ok) { - if (theOr == TopAbs_FORWARD) { - ok = theASI.LocalizeAfter(IndTo,theOr,IndFrom,IndTo); - } - if (ok && theOr == TopAbs_REVERSED) { - Last = theASI.Point(IndTo).Parameter(); - } + if (theOr == TopAbs_FORWARD) { + ok = theASI.LocalizeAfter(IndTo,theOr,IndFrom,IndTo); + } + if (ok && theOr == TopAbs_REVERSED) { + Last = theASI.Point(IndTo).Parameter(); + } } } } @@ -448,15 +464,15 @@ void BRepFeat_MakeCylindricalHole::Perform(const Standard_Real Radius, // // It is not possible to use infinite cylinder for topological operations. Standard_Real PMin,PMax; - BoxParameters(myBuilder.OriginalShape(),myAxis,PMin,PMax); + BoxParameters(Object(),myAxis,PMin,PMax); Standard_Real Heigth = 2.*(PMax-PMin); gp_XYZ theOrig = myAxis.Location().XYZ(); theOrig += ((3.*PMin-PMax)/2.) * myAxis.Direction().XYZ(); gp_Pnt p4_ao1(theOrig); gp_Ax2 a4_ao1(p4_ao1,myAxis.Direction()); BRepPrim_Cylinder theCylinder(a4_ao1, - Radius, - Heigth); + Radius, + Heigth); BRep_Builder B; TopoDS_Solid theTool; @@ -469,12 +485,16 @@ void BRepFeat_MakeCylindricalHole::Perform(const Standard_Real Radius, // BRepTools::Dump(theTool,cout); Standard_Boolean Fuse = Standard_False; - myBuilder.Perform(theTool,theList,Fuse); - myBuilder.BuildPartsOfTool(); - + //myBuilder.Perform(theTool,theList,Fuse); + //myBuilder.BuildPartsOfTool(); + AddTool(theTool); + SetOperation(Fuse); + BOPAlgo_Builder::Perform(); + TopTools_ListOfShape parts; + PartsOfTool(parts); Standard_Integer nbparts = 0; - TopTools_ListIteratorOfListOfShape its(myBuilder.PartsOfTool()); + TopTools_ListIteratorOfListOfShape its(parts); for (; its.More(); its.Next()) { nbparts ++; } @@ -488,15 +508,14 @@ void BRepFeat_MakeCylindricalHole::Perform(const Standard_Real Radius, TopoDS_Shape tokeep; Standard_Real parbar; gp_Pnt Barycentre; - for (its.Initialize(myBuilder.PartsOfTool()); its.More(); its.Next()) { + for (its.Initialize(parts); its.More(); its.Next()) { Baryc(its.Value(),Barycentre); parbar = ElCLib::LineParameter(myAxis,Barycentre); - if (parbar < First || parbar > Last) { - myBuilder.RemovePart(its.Value()); + if (!(parbar < First || parbar > Last)) { + KeepPart(its.Value()); } } } -// myBuilder.PerformResult(); } @@ -506,11 +525,11 @@ void BRepFeat_MakeCylindricalHole::Perform(const Standard_Real Radius, //======================================================================= void BRepFeat_MakeCylindricalHole::PerformBlind(const Standard_Real Radius, - const Standard_Real Length, - const Standard_Boolean Cont) + const Standard_Real Length, + const Standard_Boolean Cont) { - if (myBuilder.OriginalShape().IsNull() || !myAxDef || Length <= 0.) { + if (Object().IsNull() || !myAxDef || Length <= 0.) { Standard_ConstructionError::Raise(); } @@ -518,7 +537,7 @@ void BRepFeat_MakeCylindricalHole::PerformBlind(const Standard_Real Radius, myValidate = Cont; myStatus = BRepFeat_NoError; - LocOpe_CurveShapeIntersector theASI(myAxis,myBuilder.OriginalShape()); + LocOpe_CurveShapeIntersector theASI(myAxis,Object()); if (!theASI.IsDone()) { myStatus = BRepFeat_InvalidPlacement; return; @@ -569,7 +588,7 @@ void BRepFeat_MakeCylindricalHole::PerformBlind(const Standard_Real Radius, //// It is not possible to use infinite cylinder for topological operations. Standard_Real PMin,PMax; - BoxParameters(myBuilder.OriginalShape(),myAxis,PMin,PMax); + BoxParameters(Object(),myAxis,PMin,PMax); if (PMin > Length) { myStatus = BRepFeat_InvalidPlacement; return; @@ -580,8 +599,8 @@ void BRepFeat_MakeCylindricalHole::PerformBlind(const Standard_Real Radius, theOrig += ((3.*PMin-Length)/2.) * myAxis.Direction().XYZ(); gp_Pnt p5_ao1(theOrig); gp_Ax2 a5_ao1(p5_ao1,myAxis.Direction()); BRepPrim_Cylinder theCylinder(a5_ao1, - Radius, - Heigth); + Radius, + Heigth); BRep_Builder B; TopoDS_Solid theTool; @@ -594,12 +613,16 @@ void BRepFeat_MakeCylindricalHole::PerformBlind(const Standard_Real Radius, // BRepTools::Dump(theTool,cout); Standard_Boolean Fuse = Standard_False; - myBuilder.Perform(theTool,theList,Fuse); - myBuilder.BuildPartsOfTool(); - + //myBuilder.Perform(theTool,theList,Fuse); + //myBuilder.BuildPartsOfTool(); + AddTool(theTool); + SetOperation(Fuse); + BOPAlgo_Builder::Perform(); + TopTools_ListOfShape parts; + PartsOfTool(parts); Standard_Integer nbparts = 0; - TopTools_ListIteratorOfListOfShape its(myBuilder.PartsOfTool()); + TopTools_ListIteratorOfListOfShape its(parts); for (; its.More(); its.Next()) { nbparts ++; } @@ -612,38 +635,36 @@ void BRepFeat_MakeCylindricalHole::PerformBlind(const Standard_Real Radius, TopoDS_Shape tokeep; Standard_Real parbar,parmin = RealLast(); gp_Pnt Barycentre; - for (its.Initialize(myBuilder.PartsOfTool()); its.More(); its.Next()) { + for (its.Initialize(parts); its.More(); its.Next()) { Baryc(its.Value(),Barycentre); parbar = ElCLib::LineParameter(myAxis,Barycentre); if (parbar >= First && parbar <= parmin) { - parmin = parbar; - tokeep = its.Value(); + parmin = parbar; + tokeep = its.Value(); } } if (tokeep.IsNull()) { // preserve the closest interval Standard_Real dmin = RealLast(); - for (its.Initialize(myBuilder.PartsOfTool()); its.More(); its.Next()) { - Baryc(its.Value(),Barycentre); - parbar = ElCLib::LineParameter(myAxis,Barycentre); - if (Abs(First - parbar) < dmin ) { - dmin = Abs(First-parbar); - tokeep = its.Value(); - } + for (its.Initialize(parts); its.More(); its.Next()) { + Baryc(its.Value(),Barycentre); + parbar = ElCLib::LineParameter(myAxis,Barycentre); + if (Abs(First - parbar) < dmin ) { + dmin = Abs(First-parbar); + tokeep = its.Value(); + } } } - for (its.Initialize(myBuilder.PartsOfTool()); its.More(); its.Next()) { - if (!tokeep.IsSame(its.Value())) { - myBuilder.RemovePart(its.Value()); + for (its.Initialize(parts); its.More(); its.Next()) { + if (tokeep.IsSame(its.Value())) { + KeepPart(its.Value()); + break; } } } -// myBuilder.PerformResult(); } - - //======================================================================= //function : Build //purpose : @@ -652,32 +673,17 @@ void BRepFeat_MakeCylindricalHole::PerformBlind(const Standard_Real Radius, void BRepFeat_MakeCylindricalHole::Build () { if (myStatus == BRepFeat_NoError) { - myBuilder.PerformResult(); - if (myBuilder.IsDone()) { + PerformResult(); + if (!ErrorStatus()) { myStatus = (myValidate) ? Validate() : BRepFeat_NoError; if (myStatus == BRepFeat_NoError) { - Done(); - myShape = myBuilder.ResultingShape(); - - // creation of the Map. - myMap.Clear(); - TopExp_Explorer ex; - for (ex.Init(myShape, TopAbs_FACE); ex.More(); ex.Next()) { - myMap.Add(ex.Current()); - } - } - else { - NotDone(); + myShape = Shape(); } } else { - NotDone(); myStatus = BRepFeat_InvalidPlacement; // why not } } - else { - NotDone(); - } } @@ -689,11 +695,11 @@ void BRepFeat_MakeCylindricalHole::Build () BRepFeat_Status BRepFeat_MakeCylindricalHole::Validate () { BRepFeat_Status thestat = BRepFeat_NoError; - TopExp_Explorer ex(myBuilder.ResultingShape(),TopAbs_FACE); + TopExp_Explorer ex(Shape(),TopAbs_FACE); if (myIsBlind) { // limit of the hole for (; ex.More(); ex.Next()) { if (ex.Current().IsSame(myTopFace) ) { - break; + break; } } if (!ex.More()) { @@ -703,12 +709,12 @@ BRepFeat_Status BRepFeat_MakeCylindricalHole::Validate () else { for (; ex.More(); ex.Next()) { if (ex.Current().IsSame(myTopFace) ) { - return BRepFeat_InvalidPlacement; + return BRepFeat_InvalidPlacement; } } for (ex.ReInit(); ex.More(); ex.Next()) { if (ex.Current().IsSame(myBotFace) ) { - return BRepFeat_InvalidPlacement; + return BRepFeat_InvalidPlacement; } } } @@ -733,9 +739,9 @@ void Baryc(const TopoDS_Shape& S, gp_Pnt& B) C = BRep_Tool::Curve(E,L,First,Last); C = Handle(Geom_Curve)::DownCast(C->Transformed(L.Transformation())); for (i=1;i<=11; i++) { - prm = ((11-i)*First + (i-1)*Last)/10.; - Bar += C->Value(prm).XYZ(); - nbp++; + prm = ((11-i)*First + (i-1)*Last)/10.; + Bar += C->Value(prm).XYZ(); + nbp++; } } } @@ -745,9 +751,9 @@ void Baryc(const TopoDS_Shape& S, gp_Pnt& B) void BoxParameters(const TopoDS_Shape& S, - const gp_Ax1& Axis, - Standard_Real& parmin, - Standard_Real& parmax) + const gp_Ax1& Axis, + Standard_Real& parmin, + Standard_Real& parmax) { // calculate the parameters of a bounding box in the direction of the axis of the hole @@ -765,10 +771,10 @@ void BoxParameters(const TopoDS_Shape& S, for (j=2; j<=3; j++) { P.SetY(c[j]); for (k=4; k<=5; k++) { - P.SetZ(c[k]); - param = ElCLib::LineParameter(Axis,P); - parmin = Min(param,parmin); - parmax = Max(param,parmax); + P.SetZ(c[k]); + param = ElCLib::LineParameter(Axis,P); + parmin = Min(param,parmin); + parmax = Max(param,parmax); } } } diff --git a/src/BRepFeat/BRepFeat_MakeCylindricalHole.lxx b/src/BRepFeat/BRepFeat_MakeCylindricalHole.lxx index d4e3289c8a..2bf099a8e9 100755 --- a/src/BRepFeat/BRepFeat_MakeCylindricalHole.lxx +++ b/src/BRepFeat/BRepFeat_MakeCylindricalHole.lxx @@ -30,28 +30,6 @@ inline BRepFeat_MakeCylindricalHole::BRepFeat_MakeCylindricalHole (): myAxDef(Standard_False) {} -//======================================================================= -//function : BRepFeat_MakeCylindricalHole -//purpose : -//======================================================================= - -inline BRepFeat_MakeCylindricalHole::BRepFeat_MakeCylindricalHole - (const TopoDS_Shape& S): - BRepFeat_Builder(S),myAxDef(Standard_False) -{} - -//======================================================================= -//function : BRepFeat_MakeCylindricalHole -//purpose : -//======================================================================= - -inline BRepFeat_MakeCylindricalHole::BRepFeat_MakeCylindricalHole - (const TopoDS_Shape& S, - const gp_Ax1& Axis): - BRepFeat_Builder(S),myAxis(Axis),myAxDef(Standard_True) -{} - - //======================================================================= //function : Init //purpose : @@ -70,14 +48,13 @@ inline void BRepFeat_MakeCylindricalHole::Init(const gp_Ax1& Axis) //======================================================================= inline void BRepFeat_MakeCylindricalHole::Init(const TopoDS_Shape& S, - const gp_Ax1& Axis) + const gp_Ax1& Axis) { BRepFeat_Builder::Init(S); myAxis = Axis; myAxDef = Standard_True; } - //======================================================================= //function : Status //purpose : diff --git a/src/BRepFeat/BRepFeat_MakeLinearForm.cxx b/src/BRepFeat/BRepFeat_MakeLinearForm.cxx index ebbec3acee..11710d8b26 100755 --- a/src/BRepFeat/BRepFeat_MakeLinearForm.cxx +++ b/src/BRepFeat/BRepFeat_MakeLinearForm.cxx @@ -25,7 +25,6 @@ #include #include -#include #include #include #include diff --git a/src/BRepFeat/BRepFeat_MakeRevol.cxx b/src/BRepFeat/BRepFeat_MakeRevol.cxx index 6109b721e8..34531e97fc 100755 --- a/src/BRepFeat/BRepFeat_MakeRevol.cxx +++ b/src/BRepFeat/BRepFeat_MakeRevol.cxx @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include diff --git a/src/BRepFeat/BRepFeat_MakeRevolutionForm.cxx b/src/BRepFeat/BRepFeat_MakeRevolutionForm.cxx index a5e9347135..b8a52e5794 100755 --- a/src/BRepFeat/BRepFeat_MakeRevolutionForm.cxx +++ b/src/BRepFeat/BRepFeat_MakeRevolutionForm.cxx @@ -25,7 +25,6 @@ #include #include -#include #include #include #include @@ -1458,12 +1457,11 @@ Standard_Boolean BRepFeat_MakeRevolutionForm::Propagate(TopTools_ListOfShape& Sl } } else { + e = e1; e1.Nullify(); } } if(e1.IsNull()) { - //Standard_Real f, l; - myListOfEdges.Clear(); TopTools_ListOfShape thelist2; mySlface.Bind(CurrentFace, thelist2); diff --git a/src/BRepFeat/BRepFeat_RibSlot.cdl b/src/BRepFeat/BRepFeat_RibSlot.cdl index 74fde41f2c..7f100f5b78 100755 --- a/src/BRepFeat/BRepFeat_RibSlot.cdl +++ b/src/BRepFeat/BRepFeat_RibSlot.cdl @@ -21,17 +21,17 @@ deferred class RibSlot from BRepFeat inherits MakeShape from BRepBuilderAPI - ---Purpose: Provides functions to build mechanical features. - -- Mechanical features include ribs - protrusions and grooves (or slots) - depressions along - -- planar (linear) surfaces or revolution surfaces. The semantics of mechanical features is built - -- around giving thickness to a contour. This thickness can either be unilateral - on one side - -- of the contour - or bilateral - on both sides. - -- As in the semantics of form features, the thickness is defined by construction of shapes - -- in specific contexts. The development contexts differ, however,in case of mechanical features. - -- Here they include extrusion: - -- - to a limiting face of the basis shape - -- - to or from a limiting plane - -- - to a height. + ---Purpose: Provides functions to build mechanical features. + -- Mechanical features include ribs - protrusions and grooves (or slots) - depressions along + -- planar (linear) surfaces or revolution surfaces. The semantics of mechanical features is built + -- around giving thickness to a contour. This thickness can either be unilateral - on one side + -- of the contour - or bilateral - on both sides. + -- As in the semantics of form features, the thickness is defined by construction of shapes + -- in specific contexts. The development contexts differ, however,in case of mechanical features. + -- Here they include extrusion: + -- - to a limiting face of the basis shape + -- - to or from a limiting plane + -- - to a height. uses Shape from TopoDS, Face from TopoDS, @@ -53,15 +53,14 @@ uses Shape from TopoDS, Dir from gp, StatusError from BRepFeat, --modified by NIZNHY-PKV Thu Mar 21 17:09:08 2002 f - BooleanOperation from BRepAlgoAPI, + BooleanOperation from BRepAlgoAPI --modified by NIZNHY-PKV Thu Mar 21 17:09:11 2002 t - HistoryCollector from BOP is Initialize; - ---Purpose: Redefines the empty constructor. - ---C++: inline + ---Purpose: Redefines the empty constructor. + ---C++: inline --- Methods redefined from BRepBuilderAPI_MakeShape @@ -69,222 +68,210 @@ is IsDeleted(me : in out ; F: Shape from TopoDS) returns Boolean from Standard is redefined; - ---Purpose: Returns true if F a TopoDS_Shape of type edge or face has been deleted. + ---Purpose: Returns true if F a TopoDS_Shape of type edge or face has been deleted. Modified(me: in out; F: Shape from TopoDS) - ---Purpose: Returns the list of generated Faces F. This list may be empty. - ---C++: return const & + ---Purpose: Returns the list of generated Faces F. This list may be empty. + ---C++: return const & returns ListOfShape from TopTools is redefined; Generated(me: in out; S: Shape from TopoDS) - ---Purpose: Returns a list TopTools_ListOfShape of the faces S created in the shape. - ---C++: return const & + ---Purpose: Returns a list TopTools_ListOfShape of the faces S created in the shape. + ---C++: return const & returns ListOfShape from TopTools is redefined; FirstShape (me) - ---Purpose: Returns the list of shapes created at the bottom of - -- the created form. It may be an empty list. + ---Purpose: Returns the list of shapes created at the bottom of + -- the created form. It may be an empty list. returns ListOfShape from TopTools; - ---C++: return const& + ---C++: return const& LastShape (me) - ---Purpose: Returns the list of shapes created at the top of the - -- created form. It may be an empty list. + ---Purpose: Returns the list of shapes created at the top of the + -- created form. It may be an empty list. returns ListOfShape from TopTools; - ---C++: return const& + ---C++: return const& LFPerform(me: in out) - ---Purpose: General perform method... + ---Purpose: General perform method... - is static protected; + is static protected; FacesForDraft(me) - ---Purpose: Returns a list of the limiting and glueing faces - -- generated by the feature. These faces did not originally exist in the basis shape. - -- The list provides the information necessary for - -- subsequent addition of a draft to a face. It may be an empty list. - -- If a face has tangent edges, no draft is possible, and the tangent edges must - -- subsequently be removed if you want to add a draft to the face. + ---Purpose: Returns a list of the limiting and glueing faces + -- generated by the feature. These faces did not originally exist in the basis shape. + -- The list provides the information necessary for + -- subsequent addition of a draft to a face. It may be an empty list. + -- If a face has tangent edges, no draft is possible, and the tangent edges must + -- subsequently be removed if you want to add a draft to the face. returns ListOfShape from TopTools; - ---C++: return const& + ---C++: return const& NewEdges(me) - ---Purpose: Returns a list of the limiting and glueing edges - -- generated by the feature. These edges did not originally exist in the basis shape. - -- The list provides the information necessary for - -- subsequent addition of fillets. It may be an empty list. + ---Purpose: Returns a list of the limiting and glueing edges + -- generated by the feature. These edges did not originally exist in the basis shape. + -- The list provides the information necessary for + -- subsequent addition of fillets. It may be an empty list. returns ListOfShape from TopTools; - ---C++: return const& + ---C++: return const& TgtEdges(me) - ---Purpose: Returns a list of the tangent edges among the - -- limiting and glueing edges generated by the - -- feature. These edges did not originally exist in - -- the basis shape and are tangent to the face - -- against which the feature is built. - -- The list provides the information necessary for - -- subsequent addition of fillets. It may be an empty list. - -- If an edge is tangent, no fillet is possible, and - -- the edge must subsequently be removed if you want to add a fillet. + ---Purpose: Returns a list of the tangent edges among the + -- limiting and glueing edges generated by the + -- feature. These edges did not originally exist in + -- the basis shape and are tangent to the face + -- against which the feature is built. + -- The list provides the information necessary for + -- subsequent addition of fillets. It may be an empty list. + -- If an edge is tangent, no fillet is possible, and + -- the edge must subsequently be removed if you want to add a fillet. returns ListOfShape from TopTools; - ---C++: return const& + ---C++: return const& CheckPoint(me: in out; - e : Edge from TopoDS; - bnd : Real from Standard; - Pln : Plane from Geom) + e : Edge from TopoDS; + bnd : Real from Standard; + Pln : Plane from Geom) returns Pnt from gp is static protected; Normal(me: in out; - F : Face from TopoDS; - P : Pnt from gp) + F : Face from TopoDS; + P : Pnt from gp) returns Dir from gp is static protected; - + IntPar(myclass; - C : Curve from Geom; - P : Pnt from gp) + C : Curve from Geom; + P : Pnt from gp) returns Real from Standard; EdgeExtention(me: in out; - e : in out Edge from TopoDS; - bnd : Real from Standard; - FirstLast : Boolean from Standard) + e : in out Edge from TopoDS; + bnd : Real from Standard; + FirstLast : Boolean from Standard) is static protected; ChoiceOfFaces(myclass; - faces : in out ListOfShape from TopTools; - cc : Curve from Geom; - par : Real from Standard; - bnd : Real from Standard; - Pln : Plane from Geom) + faces : in out ListOfShape from TopTools; + cc : Curve from Geom; + par : Real from Standard; + bnd : Real from Standard; + Pln : Plane from Geom) returns Face from TopoDS; HeightMax(me: in out; - theSbase : Shape from TopoDS; - theSUntil : Shape from TopoDS; - p1 : in out Pnt from gp; - p2 : in out Pnt from gp) + theSbase : Shape from TopoDS; + theSUntil : Shape from TopoDS; + p1 : in out Pnt from gp; + p2 : in out Pnt from gp) returns Real from Standard is static protected; - + ExtremeFaces(me: in out; - RevolRib : Boolean from Standard; - bnd : Real from Standard; - Pln : Plane from Geom; - FirstEdge : in out Edge from TopoDS; - LastEdge : in out Edge from TopoDS; - FirstFace : in out Face from TopoDS; - LastFace : in out Face from TopoDS; - FirstVertex : in out Vertex from TopoDS; - LastVertex : in out Vertex from TopoDS; - OnFirstFace : in out Boolean from Standard; - OnLastFace : in out Boolean from Standard; - PtOnFirstEdge : in out Boolean from Standard; - PtOnLastEdge : in out Boolean from Standard; - OnFirstEdge : in out Edge from TopoDS; - OnLastEdge : in out Edge from TopoDS) + RevolRib : Boolean from Standard; + bnd : Real from Standard; + Pln : Plane from Geom; + FirstEdge : in out Edge from TopoDS; + LastEdge : in out Edge from TopoDS; + FirstFace : in out Face from TopoDS; + LastFace : in out Face from TopoDS; + FirstVertex : in out Vertex from TopoDS; + LastVertex : in out Vertex from TopoDS; + OnFirstFace : in out Boolean from Standard; + OnLastFace : in out Boolean from Standard; + PtOnFirstEdge : in out Boolean from Standard; + PtOnLastEdge : in out Boolean from Standard; + OnFirstEdge : in out Edge from TopoDS; + OnLastEdge : in out Edge from TopoDS) returns Boolean from Standard is static protected; - + PtOnEdgeVertex(me: in out; - RevolRib : Boolean from Standard; - shape : Shape from TopoDS; - point : Pnt from gp; - FirstVertex : Vertex from TopoDS; - LastVertex : Vertex from TopoDS; - PtOnEdge : in out Boolean from Standard; - OnEdge : in out Edge from TopoDS; - PtOnVertex : in out Boolean from Standard; - OnVertex : in out Vertex from TopoDS) + RevolRib : Boolean from Standard; + shape : Shape from TopoDS; + point : Pnt from gp; + FirstVertex : Vertex from TopoDS; + LastVertex : Vertex from TopoDS; + PtOnEdge : in out Boolean from Standard; + OnEdge : in out Edge from TopoDS; + PtOnVertex : in out Boolean from Standard; + OnVertex : in out Vertex from TopoDS) is static protected; SlidingProfile(me: in out; - Prof : in out Face from TopoDS; - RevolRib : Boolean from Standard; - myTol : Real from Standard; - Concavite : in out Integer from Standard; - myPln : Plane from Geom; - BndFace : Face from TopoDS; - CheckPnt : Pnt from gp; - FirstFace : Face from TopoDS; - LastFace : Face from TopoDS; - FirstVertex : Vertex from TopoDS; - LastVertex : Vertex from TopoDS; - FirstEdge : Edge from TopoDS; - LastEdge : Edge from TopoDS) + Prof : in out Face from TopoDS; + RevolRib : Boolean from Standard; + myTol : Real from Standard; + Concavite : in out Integer from Standard; + myPln : Plane from Geom; + BndFace : Face from TopoDS; + CheckPnt : Pnt from gp; + FirstFace : Face from TopoDS; + LastFace : Face from TopoDS; + FirstVertex : Vertex from TopoDS; + LastVertex : Vertex from TopoDS; + FirstEdge : Edge from TopoDS; + LastEdge : Edge from TopoDS) returns Boolean from Standard is static protected; - + NoSlidingProfile(me: in out; - Prof : in out Face from TopoDS; - RevolRib : Boolean from Standard; - myTol : Real from Standard; - Concavite : in out Integer from Standard; - myPln : Plane from Geom; - bnd : Real from Standard; - BndFace : Face from TopoDS; - CheckPnt : Pnt from gp; - FirstFace : Face from TopoDS; - LastFace : Face from TopoDS; - FirstVertex : Vertex from TopoDS; - LastVertex : Vertex from TopoDS; - FirstEdge : Edge from TopoDS; - LastEdge : Edge from TopoDS; - OnFirstFace : Boolean from Standard; - OnLastFace : Boolean from Standard) + Prof : in out Face from TopoDS; + RevolRib : Boolean from Standard; + myTol : Real from Standard; + Concavite : in out Integer from Standard; + myPln : Plane from Geom; + bnd : Real from Standard; + BndFace : Face from TopoDS; + CheckPnt : Pnt from gp; + FirstFace : Face from TopoDS; + LastFace : Face from TopoDS; + FirstVertex : Vertex from TopoDS; + LastVertex : Vertex from TopoDS; + FirstEdge : Edge from TopoDS; + LastEdge : Edge from TopoDS; + OnFirstFace : Boolean from Standard; + OnLastFace : Boolean from Standard) returns Boolean from Standard is static protected; - + UpdateDescendants(me: in out; G: Gluer from LocOpe) is static protected; - ---Purpose: Updates the data structures of descendant - -- shapes during the glueing operation.Returns the modified, generated - -- and deleted faces during the course of the glueing operation. + ---Purpose: Updates the data structures of descendant + -- shapes during the glueing operation.Returns the modified, generated + -- and deleted faces during the course of the glueing operation. UpdateDescendants(me: in out; B : HBuilder from TopOpeBRepBuild; - SResult : Shape from TopoDS; + SResult : Shape from TopoDS; SkipFace : Boolean from Standard = Standard_False) is static protected; --modified by NIZNHY-PKV Thu Mar 21 18:42:53 2002 f UpdateDescendants(me: in out; - aBOP: BooleanOperation from BRepAlgoAPI; - SResult : Shape from TopoDS; + aBOP: BooleanOperation from BRepAlgoAPI; + SResult : Shape from TopoDS; SkipFace : Boolean from Standard = Standard_False) - is static protected; + is static protected; --modified by NIZNHY-PKV Thu Mar 21 18:42:50 2002 t - UpdateDescendants(me: in out; - aBOP: HistoryCollector from BOP; - SResult : Shape from TopoDS; - SkipFace : Boolean from Standard = Standard_False) - is static protected; - ---Purpose: Updates the data structures of descendant - -- shapes during the glueing operation. - -- Returns the modified, generated and deleted faces during the course of the - -- glueing operation; furnishes the arguments of the resulting shape SResult using the - -- builder B to determine the type of modification such as orientation and splitting; - -- checks to see that the SResult belongs to the data structure of the original shape. - CurrentStatusError(me) returns StatusError from BRepFeat; diff --git a/src/BRepFeat/BRepFeat_RibSlot.cxx b/src/BRepFeat/BRepFeat_RibSlot.cxx index 407a0a5651..1f6766722c 100755 --- a/src/BRepFeat/BRepFeat_RibSlot.cxx +++ b/src/BRepFeat/BRepFeat_RibSlot.cxx @@ -24,7 +24,6 @@ #include #include -#include #include #include #include @@ -106,6 +105,7 @@ #include #include +#include #ifdef DEB @@ -146,27 +146,18 @@ void BRepFeat_RibSlot::LFPerform() // Hope that there is just a solid in the result Standard_Boolean UntilInShape = Standard_False; - TopTools_MapOfShape M; - TopTools_ListOfShape LShape; - TopTools_ListOfShape LTool; - if (!mySUntil.IsNull()) { UntilInShape = Standard_True; for (exp2.Init(mySUntil,TopAbs_FACE); exp2.More(); exp2.Next()) { const TopoDS_Shape& funtil = exp2.Current(); for (exp.Init(mySbase,TopAbs_FACE); exp.More(); exp.Next()) { - if (exp.Current().IsSame(funtil)) { - break; - } + if (exp.Current().IsSame(funtil)) { + break; + } } if (!exp.More()) { - UntilInShape = Standard_False; - break; - } - else { - if (M.Add(funtil)) { - LShape.Append(funtil); - } + UntilInShape = Standard_False; + break; } } } @@ -175,26 +166,12 @@ void BRepFeat_RibSlot::LFPerform() TopTools_DataMapIteratorOfDataMapOfShapeShape itm; //Standard_Integer sens = 0; - for (itm.Initialize(myGluedF);itm.More();itm.Next()) { - M.Add(itm.Value()); - } - - - if(!mySUntil.IsNull()) { - exp.Init(mySUntil, TopAbs_FACE); - for(; exp.More(); exp.Next()) { - if(M.Add(exp.Current())) - LShape.Append(exp.Current()); - } - } - LocOpe_Gluer theGlue; //case of gluing if (theOpe == 1) { Standard_Boolean Collage = Standard_True; - //BRep_Builder B; LocOpe_FindEdges theFE; TopTools_DataMapOfShapeListOfShape locmap; @@ -203,32 +180,32 @@ void BRepFeat_RibSlot::LFPerform() const TopoDS_Face& glface = TopoDS::Face(itm.Key()); const TopoDS_Face& fac = TopoDS::Face(myGluedF(glface)); for (exp.Init(myGShape,TopAbs_FACE); exp.More(); exp.Next()) { - if (exp.Current().IsSame(glface)) { - break; - } + if (exp.Current().IsSame(glface)) { + break; + } } if (exp.More()) { - Collage = BRepFeat::IsInside(glface, fac); - if(!Collage) { - theOpe = 2; - ChangeOpe = Standard_True; - break; - } - else { - theGlue.Bind(glface, fac); - theFE.Set(glface, fac); - for (theFE.InitIterator(); theFE.More();theFE.Next()) { - theGlue.Bind(theFE.EdgeFrom(),theFE.EdgeTo()); - } - } + Collage = BRepFeat::IsInside(glface, fac); + if(!Collage) { + theOpe = 2; + ChangeOpe = Standard_True; + break; + } + else { + theGlue.Bind(glface, fac); + theFE.Set(glface, fac); + for (theFE.InitIterator(); theFE.More();theFE.Next()) { + theGlue.Bind(theFE.EdgeFrom(),theFE.EdgeTo()); + } + } } } LocOpe_Operation ope = theGlue.OpeType(); if (ope == LocOpe_INVALID || - (myFuse && ope != LocOpe_FUSE) || - (!myFuse && ope != LocOpe_CUT) || - (!Collage)) { + (myFuse && ope != LocOpe_FUSE) || + (!myFuse && ope != LocOpe_CUT) || + (!Collage)) { theOpe = 2; ChangeOpe = Standard_True; #ifdef DEB @@ -245,112 +222,10 @@ void BRepFeat_RibSlot::LFPerform() UpdateDescendants(theGlue); myNewEdges = theGlue.Edges(); myTgtEdges = theGlue.TgtEdges(); - //TopTools_ListIteratorOfListOfShape itt1; - if (!LShape.IsEmpty()) { - LocOpe_Builder theTOpe(theGlue.ResultingShape()); - // Use of LTool is temporary - for (it2.Initialize(LShape);it2.More();it2.Next()) { - const TopTools_ListOfShape& ldf = myMap(it2.Value()); - if (ldf.Extent() == 1 && ldf.First().IsSame(it2.Value())) { - LTool.Append(it2.Value()); - } - else { - for (it.Initialize(ldf);it.More();it.Next()) { - if (M.Add(it.Value())) { - LTool.Append(it.Value()); - } - } - } - } - LShape.Clear(); - LShape= LTool; - LTool.Clear(); - for (exp.Init(theGlue.GluedShape(),TopAbs_FACE); - exp.More();exp.Next()) { - for (it.Initialize(theGlue.DescendantFaces - (TopoDS::Face(exp.Current()))); - it.More();it.Next()) { - if (M.Add(it.Value())) { - LTool.Append(it.Value()); - } - } - } - - if (!(LShape .IsEmpty() || LTool.IsEmpty())) { - //TopTools_ListIteratorOfListOfShape it1(LShape); - //TopTools_ListIteratorOfListOfShape it2(LTool); - theTOpe.Perform(LShape,LTool,myFuse); - theTOpe.PerformResult(); - TopTools_ListOfShape TOpeNewEdges, TOpeTgtEdges; - TOpeNewEdges = theTOpe.Edges(); - TOpeTgtEdges = theTOpe.TgtEdges(); - TopTools_ListIteratorOfListOfShape itt1, itt2; - itt1.Initialize(TOpeNewEdges); - itt2.Initialize(myNewEdges); - for(; itt1.More(); itt1.Next()) { - TopoDS_Edge e1 = TopoDS::Edge(itt1.Value()); - Standard_Boolean Adde1 = Standard_True; - for(; itt2.More(); itt2.Next()) { - TopoDS_Edge e2 = TopoDS::Edge(itt2.Value()); - if(e1.IsSame(e2)) { - Adde1 = Standard_False; - break; - } - } - if(Adde1) { - myNewEdges.Append(e1); - } - } - itt1.Initialize(TOpeTgtEdges); - itt2.Initialize(myTgtEdges); - for(; itt1.More(); itt1.Next()) { - TopoDS_Edge e1 = TopoDS::Edge(itt1.Value()); - Standard_Boolean Adde1 = Standard_True; - for(; itt2.More(); itt2.Next()) { - TopoDS_Edge e2 = TopoDS::Edge(itt2.Value()); - if(e1.IsSame(e2)) { - Adde1 = Standard_False; - break; - } - } - if(Adde1) { - myTgtEdges.Append(e1); - } - } - - if (theTOpe.IsDone()) { - Done(); - if (BRepAlgo::IsValid(theTOpe.ResultingShape())) { - theOpe = 3; // ??? - myShape = theTOpe.ResultingShape(); -// UpdateDescendants(theTOpe.Builder(),myShape); - UpdateDescendants(theTOpe.History(),myShape); - } - else { - myShape = theGlue.ResultingShape(); - } - } - else { - theOpe = 2; - ChangeOpe = Standard_True; -#ifdef DEB - cout << "Passage to. topologic operation" << endl; -#endif - } - - } - else { - Done(); - myShape = theGlue.ResultingShape(); - } - } - else { - Done(); - myShape = theGlue.ResultingShape(); -// - BRepLib::SameParameter(myShape, 1.e-7, Standard_True); -// - } + // + Done(); + myShape = theGlue.ResultingShape(); + BRepLib::SameParameter(myShape, 1.e-7, Standard_True); } else { theOpe = 2; @@ -361,203 +236,48 @@ void BRepFeat_RibSlot::LFPerform() } } - -// case without gluing - + // case without gluing if (theOpe == 2) { -// Attention, if gluing fails, myGShape with gluing is not correct - if (ChangeOpe) { - myStatusError = BRepFeat_NoGluer; - NotDone(); - return; - } - - TopoDS_Shape theGShape = myGShape; - if (ChangeOpe) { - for (itm.Initialize(myGluedF); itm.More();itm.Next()) { - if(M.Add(itm.Value())) - LShape.Append(itm.Value()); - } - } - TopoDS_Shape Comp; - BRep_Builder B; - - if(!mySUntil.IsNull()) { - TopExp_Explorer ex(mySUntil, TopAbs_FACE); - for(; ex.More(); ex.Next()) { - const TopoDS_Face& fac = TopoDS::Face(ex.Current()); - if(M.Add(fac)) - LShape.Append(fac); - } - } - -// LocOpe_Builder theTOpe(mySbase); - LocOpe_Builder theTOpe(mySbase, theGShape); - - //TopTools_ListIteratorOfListOfShape it3; - //Standard_Real pmin, pmax, pbmin, pbmax; - //Standard_Integer flag1 = Standard_True; - -// theTOpe.Perform(theGShape,LShape,myFuse); - if(!theGShape.IsNull()) { - TopExp_Explorer ex(theGShape, TopAbs_FACE); - for(; ex.More(); ex.Next()) { - const TopoDS_Face& fac = TopoDS::Face(ex.Current()); - LTool.Append(fac); - } - } - theTOpe.Perform(LShape, LTool, myFuse); - - theTOpe.BuildPartsOfTool(); - it.Initialize(theTOpe.PartsOfTool()); - - if (it.More() && myPerfSelection != BRepFeat_NoSelection) { - Standard_Real toler= (BRep_Tool::Tolerance(myPbase))*2; - BRepClass3d_SolidClassifier oussa; - - TopoDS_Solid thePartsOfTool; - BRep_Builder BB; - BB.MakeSolid(thePartsOfTool); - - for(; it.More(); it.Next()) { - oussa.Load(it.Value()); - oussa.Perform(myFirstPnt, toler); - TopAbs_State sp1=oussa.State(); - oussa.Perform(myLastPnt, toler); - TopAbs_State sp2=oussa.State(); -// if (sp1 != TopAbs_ON || sp2 != TopAbs_ON) { - if (sp1 == TopAbs_OUT || sp2 == TopAbs_OUT) { - theTOpe.RemovePart(it.Value()); - } - else { - const TopoDS_Shape& S = it.Value(); - B.Add(thePartsOfTool,S); - } - } - - - -/* TopTools_MapOfShape newdsc; - if(!mySUntil.IsNull()) { - TopTools_MapOfShape toTake; - - const Handle(TopOpeBRepBuild_HBuilder) B = theTOpe.Builder(); - TopoDS_Face fdsc; - TopExp_Explorer ex(mySUntil, TopAbs_FACE); - for(; ex.More(); ex.Next()) { - fdsc = TopoDS::Face(ex.Current()); - - if(B->IsSplit(fdsc, TopAbs_OUT)) { - for (it2.Initialize(B->Splits(fdsc,TopAbs_OUT)); - it2.More();it2.Next()) { - newdsc.Add(it2.Value()); - } - } - if (B->IsSplit(fdsc, TopAbs_IN)) { - for (it2.Initialize(B->Splits(fdsc,TopAbs_IN)); - it2.More();it2.Next()) { - newdsc.Add(it2.Value()); - } - } - if (B->IsSplit(fdsc, TopAbs_ON)) { - for (it2.Initialize(B->Splits(fdsc,TopAbs_ON)); - it2.More();it2.Next()) { - newdsc.Add(it2.Value()); - } - } - if (B->IsMerged(fdsc, TopAbs_OUT)) { - for (it2.Initialize(B->Merged(fdsc,TopAbs_OUT)); - it2.More();it2.Next()) { - newdsc.Add(it2.Value()); - } - } - if (B->IsMerged(fdsc, TopAbs_IN)) { - for (it2.Initialize(B->Merged(fdsc,TopAbs_IN)); - it2.More();it2.Next()) { - newdsc.Add(it2.Value()); - } - } - if (B->IsMerged(fdsc, TopAbs_ON)) { - for (it2.Initialize(B->Merged(fdsc,TopAbs_ON)); - it2.More();it2.Next()) { - newdsc.Add(it2.Value()); - } - } - } - - Standard_Boolean removeflag; - for(; it.More(); it.Next()) { - removeflag = Standard_True; - TopExp_Explorer ex1(it.Value(), TopAbs_FACE); - for(; ex1.More(); ex1.Next()) { - const TopoDS_Face& f = TopoDS::Face(ex1.Current()); - if (newdsc.Contains(f)) { - removeflag = Standard_False; - break; - } - } - if(removeflag) { - theTOpe.RemovePart(it.Value()); - } - } - } */ - - - - theTOpe.PerformResult(); - if (theTOpe.IsDone()) { - Done(); - myShape = theTOpe.ResultingShape(); -// UpdateDescendants(theTOpe.Builder(),myShape); - UpdateDescendants(theTOpe.History(),myShape); - myNewEdges = theTOpe.Edges(); - if(!theTOpe.TgtEdges().IsEmpty()) { - myTgtEdges = theTOpe.TgtEdges(); - } - } - else { -// if (theTOpe.IsInvDone()) { -// myStatusError = BRepFeat_LocOpeNotDone; -// } -// else { - myStatusError = BRepFeat_LocOpeInvNotDone;// last resort (attention to new and tangent edges) -#ifdef DEB - if (trc) cout << " Parts of Tool : direct Ope. Top." << endl; -#endif - if(myFuse == 1) { - //modified by NIZNHY-PKV Fri Mar 22 16:45:07 2002 f - //BRepAlgo_Fuse f(mySbase, thePartsOfTool); - //myShape = f.Shape(); - //UpdateDescendants(f.Builder(), myShape, Standard_False); - BRepAlgoAPI_Fuse f(mySbase, thePartsOfTool); - myShape = f.Shape(); - UpdateDescendants(f, myShape, Standard_False); - //modified by NIZNHY-PKV Fri Mar 22 16:45:16 2002 t - - Done(); - return; - } - else if(myFuse == 0) { - //modified by NIZNHY-PKV Fri Mar 22 16:45:47 2002 f - //BRepAlgo_Cut c(mySbase, thePartsOfTool); - //myShape = c.Shape(); - //UpdateDescendants(c.Builder(), myShape, Standard_False); - BRepAlgoAPI_Cut c(mySbase, thePartsOfTool); - myShape = c.Shape(); - UpdateDescendants(c, myShape, Standard_False); - //modified by NIZNHY-PKV Fri Mar 22 16:45:51 2002 t - Done(); - return; - } -// } - NotDone(); - return; - } - } + BRepFeat_Builder theBuilder; + TopTools_ListOfShape partsoftool; + BRepClass3d_SolidClassifier oussa; + Standard_Boolean bFlag; + TopTools_ListIteratorOfListOfShape aIt; + + bFlag = (myPerfSelection == BRepFeat_NoSelection) ? 0 : 1; + // + theBuilder.Init(mySbase, myGShape); + theBuilder.SetOperation(myFuse, bFlag); + // + theBuilder.Perform(); + if (bFlag) { + theBuilder.PartsOfTool(partsoftool); + aIt.Initialize(partsoftool); + if (aIt.More() && myPerfSelection != BRepFeat_NoSelection) { + Standard_Real toler = (BRep_Tool::Tolerance(myPbase))*2; + // + for(; aIt.More(); aIt.Next()) { + oussa.Load(aIt.Value()); + oussa.Perform(myFirstPnt, toler); + TopAbs_State sp1=oussa.State(); + oussa.Perform(myLastPnt, toler); + TopAbs_State sp2=oussa.State(); + if (!(sp1 == TopAbs_OUT || sp2 == TopAbs_OUT)) { + const TopoDS_Shape& S = aIt.Value(); + theBuilder.KeepPart(S); + } + } + } + // + theBuilder.PerformResult(); + myShape = theBuilder.Shape(); + } else { + myShape = theBuilder.Shape(); + } + Done(); } } - //======================================================================= //function : IsDeleted //purpose : @@ -588,7 +308,7 @@ const TopTools_ListOfShape& BRepFeat_RibSlot::Modified for(; ite.More(); ite.Next()) { const TopoDS_Shape& sh = ite.Value(); if(!sh.IsSame(F)) - list.Append(sh); + list.Append(sh); } return list; } @@ -611,15 +331,15 @@ const TopTools_ListOfShape& BRepFeat_RibSlot::Generated myGenerated.Clear(); if(myLFMap.IsEmpty() || !myLFMap.IsBound(S)) { if (myMap.IsBound(S)) { // check if filter on face or not - static TopTools_ListOfShape list; - list.Clear(); - TopTools_ListIteratorOfListOfShape ite(myMap(S)); - for(; ite.More(); ite.Next()) { - const TopoDS_Shape& sh = ite.Value(); - if(!sh.IsSame(S)) - list.Append(sh); - } - return list; + static TopTools_ListOfShape list; + list.Clear(); + TopTools_ListIteratorOfListOfShape ite(myMap(S)); + for(; ite.More(); ite.Next()) { + const TopoDS_Shape& sh = ite.Value(); + if(!sh.IsSame(S)) + list.Append(sh); + } + return list; } else return myGenerated; } @@ -629,14 +349,14 @@ const TopTools_ListOfShape& BRepFeat_RibSlot::Generated static TopTools_ListOfShape list; list.Clear(); for(; it.More(); it.Next()) { - if(myMap.IsBound(it.Value())) { - TopTools_ListIteratorOfListOfShape it1(myMap(it.Value())); - for(; it1.More(); it1.Next()) { - const TopoDS_Shape& sh = it1.Value(); - if(!sh.IsSame(S)) - list.Append(sh); - } - } + if(myMap.IsBound(it.Value())) { + TopTools_ListIteratorOfListOfShape it1(myMap(it.Value())); + for(; it1.More(); it1.Next()) { + const TopoDS_Shape& sh = it1.Value(); + if(!sh.IsSame(S)) + list.Append(sh); + } + } } return list; } @@ -662,8 +382,8 @@ void BRepFeat_RibSlot::UpdateDescendants(const LocOpe_Gluer& G) for (it.Initialize(itdm.Value());it.More();it.Next()) { const TopoDS_Face& fdsc = TopoDS::Face(it.Value()); for (it2.Initialize(G.DescendantFaces(fdsc)); - it2.More();it2.Next()) { - newdsc.Add(it2.Value()); + it2.More();it2.Next()) { + newdsc.Add(it2.Value()); } } myMap.ChangeFind(orig).Clear(); @@ -678,8 +398,8 @@ void BRepFeat_RibSlot::UpdateDescendants(const LocOpe_Gluer& G) //purpose : //======================================================================= void BRepFeat_RibSlot::UpdateDescendants (const Handle(TopOpeBRepBuild_HBuilder)& B, - const TopoDS_Shape& S, - const Standard_Boolean SkipFace) + const TopoDS_Shape& S, + const Standard_Boolean SkipFace) { TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itdm; TopTools_ListIteratorOfListOfShape it,it2; @@ -697,58 +417,58 @@ void BRepFeat_RibSlot::UpdateDescendants(const LocOpe_Gluer& G) if(sh.ShapeType() != TopAbs_FACE) continue; const TopoDS_Face& fdsc = TopoDS::Face(it.Value()); for (exp.Init(S,TopAbs_FACE);exp.More();exp.Next()) { - if (exp.Current().IsSame(fdsc)) { // preserved - newdsc.Add(fdsc); - break; - } + if (exp.Current().IsSame(fdsc)) { // preserved + newdsc.Add(fdsc); + break; + } } if (!exp.More()) { - if (B->IsSplit(fdsc, TopAbs_OUT)) { - for (it2.Initialize(B->Splits(fdsc,TopAbs_OUT)); - it2.More();it2.Next()) { - newdsc.Add(it2.Value()); - } - } - if (B->IsSplit(fdsc, TopAbs_IN)) { - for (it2.Initialize(B->Splits(fdsc,TopAbs_IN)); - it2.More();it2.Next()) { - newdsc.Add(it2.Value()); - } - } - if (B->IsSplit(fdsc, TopAbs_ON)) { - for (it2.Initialize(B->Splits(fdsc,TopAbs_ON)); - it2.More();it2.Next()) { - newdsc.Add(it2.Value()); - } - } - if (B->IsMerged(fdsc, TopAbs_OUT)) { - for (it2.Initialize(B->Merged(fdsc,TopAbs_OUT)); - it2.More();it2.Next()) { - newdsc.Add(it2.Value()); - } - } - if (B->IsMerged(fdsc, TopAbs_IN)) { - for (it2.Initialize(B->Merged(fdsc,TopAbs_IN)); - it2.More();it2.Next()) { - newdsc.Add(it2.Value()); - } - } - if (B->IsMerged(fdsc, TopAbs_ON)) { - for (it2.Initialize(B->Merged(fdsc,TopAbs_ON)); - it2.More();it2.Next()) { - newdsc.Add(it2.Value()); - } - } + if (B->IsSplit(fdsc, TopAbs_OUT)) { + for (it2.Initialize(B->Splits(fdsc,TopAbs_OUT)); + it2.More();it2.Next()) { + newdsc.Add(it2.Value()); + } + } + if (B->IsSplit(fdsc, TopAbs_IN)) { + for (it2.Initialize(B->Splits(fdsc,TopAbs_IN)); + it2.More();it2.Next()) { + newdsc.Add(it2.Value()); + } + } + if (B->IsSplit(fdsc, TopAbs_ON)) { + for (it2.Initialize(B->Splits(fdsc,TopAbs_ON)); + it2.More();it2.Next()) { + newdsc.Add(it2.Value()); + } + } + if (B->IsMerged(fdsc, TopAbs_OUT)) { + for (it2.Initialize(B->Merged(fdsc,TopAbs_OUT)); + it2.More();it2.Next()) { + newdsc.Add(it2.Value()); + } + } + if (B->IsMerged(fdsc, TopAbs_IN)) { + for (it2.Initialize(B->Merged(fdsc,TopAbs_IN)); + it2.More();it2.Next()) { + newdsc.Add(it2.Value()); + } + } + if (B->IsMerged(fdsc, TopAbs_ON)) { + for (it2.Initialize(B->Merged(fdsc,TopAbs_ON)); + it2.More();it2.Next()) { + newdsc.Add(it2.Value()); + } + } } } myMap.ChangeFind(orig).Clear(); for (itm.Initialize(newdsc); itm.More(); itm.Next()) { // check the belonging to the shape... for (exp.Init(S,TopAbs_FACE);exp.More();exp.Next()) { - if (exp.Current().IsSame(itm.Key())) { - myMap.ChangeFind(orig).Append(itm.Key()); - break; - } + if (exp.Current().IsSame(itm.Key())) { + myMap.ChangeFind(orig).Append(itm.Key()); + break; + } } } } @@ -832,8 +552,8 @@ BRepFeat_StatusError BRepFeat_RibSlot::CurrentStatusError() const //======================================================================= gp_Pnt BRepFeat_RibSlot::CheckPoint(const TopoDS_Edge& e, - const Standard_Real ,//bnd, - const Handle(Geom_Plane)& Pln) + const Standard_Real ,//bnd, + const Handle(Geom_Plane)& Pln) { #ifdef DEB @@ -900,7 +620,7 @@ gp_Dir BRepFeat_RibSlot::Normal(const TopoDS_Face& F,const gp_Pnt& P) gp_Vec D1U, D1V; - AS.D1(U, V, pt, D1U, D1V); + AS.D1(U, V, pt, D1U, D1V); gp_Dir N; CSLib_DerivativeStatus St; CSLib::Normal(D1U, D1V, Precision::Confusion(), St, N); @@ -914,7 +634,7 @@ gp_Dir BRepFeat_RibSlot::Normal(const TopoDS_Face& F,const gp_Pnt& P) //======================================================================= Standard_Real BRepFeat_RibSlot::IntPar(const Handle(Geom_Curve)& C, - const gp_Pnt& P) + const gp_Pnt& P) { if ( C.IsNull()) return 0.; @@ -953,8 +673,8 @@ Standard_Real BRepFeat_RibSlot::IntPar(const Handle(Geom_Curve)& C, //======================================================================= void BRepFeat_RibSlot::EdgeExtention(TopoDS_Edge& e, - const Standard_Real bnd, - const Standard_Boolean FirstLast) + const Standard_Real bnd, + const Standard_Boolean FirstLast) { #ifdef DEB Standard_Boolean trc = BRepFeat_GettraceFEAT(); @@ -1013,10 +733,10 @@ void BRepFeat_RibSlot::EdgeExtention(TopoDS_Edge& e, //======================================================================= TopoDS_Face BRepFeat_RibSlot::ChoiceOfFaces(TopTools_ListOfShape& faces, - const Handle(Geom_Curve)& cc, - const Standard_Real par, - const Standard_Real ,//bnd, - const Handle(Geom_Plane)& Pln) + const Handle(Geom_Curve)& cc, + const Standard_Real par, + const Standard_Real ,//bnd, + const Handle(Geom_Plane)& Pln) { #ifdef DEB @@ -1054,11 +774,11 @@ TopoDS_Face BRepFeat_RibSlot::ChoiceOfFaces(TopTools_ListOfShape& faces, if(!ASI.IsDone()) continue; for(Standard_Integer jj = 1; jj<=Counter; jj++) { if(ASI.NbPoints(jj) >= 1) { - Standard_Real app = ASI.Point(jj,1).Parameter();//modified by NIZNHY-PKV Fri Mar 22 17:05:23 2002 pp - if(app >= 0 && app < Par) { - Par = app; - FFF = f; - } + Standard_Real app = ASI.Point(jj,1).Parameter();//modified by NIZNHY-PKV Fri Mar 22 17:05:23 2002 pp + if(app >= 0 && app < Par) { + Par = app; + FFF = f; + } } } } @@ -1073,8 +793,8 @@ TopoDS_Face BRepFeat_RibSlot::ChoiceOfFaces(TopTools_ListOfShape& faces, //======================================================================= Standard_Real BRepFeat_RibSlot::HeightMax(const TopoDS_Shape& theSbase, - const TopoDS_Shape& theSUntil, - gp_Pnt& p1, + const TopoDS_Shape& theSUntil, + gp_Pnt& p1, gp_Pnt& p2) { #ifdef DEB @@ -1103,20 +823,20 @@ Standard_Real BRepFeat_RibSlot::HeightMax(const TopoDS_Shape& theSbase, //======================================================================= Standard_Boolean BRepFeat_RibSlot::ExtremeFaces(const Standard_Boolean RevolRib, - const Standard_Real bnd, - const Handle(Geom_Plane)& Pln, - TopoDS_Edge& FirstEdge, - TopoDS_Edge& LastEdge, - TopoDS_Face& FirstFace, - TopoDS_Face& LastFace, - TopoDS_Vertex& FirstVertex, - TopoDS_Vertex& LastVertex, - Standard_Boolean& OnFirstFace, - Standard_Boolean& OnLastFace, - Standard_Boolean& PtOnFirstEdge, - Standard_Boolean& PtOnLastEdge, - TopoDS_Edge& OnFirstEdge, - TopoDS_Edge& OnLastEdge) + const Standard_Real bnd, + const Handle(Geom_Plane)& Pln, + TopoDS_Edge& FirstEdge, + TopoDS_Edge& LastEdge, + TopoDS_Face& FirstFace, + TopoDS_Face& LastFace, + TopoDS_Vertex& FirstVertex, + TopoDS_Vertex& LastVertex, + Standard_Boolean& OnFirstFace, + Standard_Boolean& OnLastFace, + Standard_Boolean& PtOnFirstEdge, + Standard_Boolean& PtOnLastEdge, + TopoDS_Edge& OnFirstEdge, + TopoDS_Edge& OnLastEdge) { #ifdef DEB @@ -1170,9 +890,9 @@ Standard_Boolean BRepFeat_RibSlot::ExtremeFaces(const Standard_Boolean RevolRib, Standard_Boolean PtOnLastVertex = Standard_False; TopoDS_Vertex OnFirstVertex, OnLastVertex; PtOnEdgeVertex(RevolRib, mySbase, p1, FirstVertex, LastVertex, - PtOnFirstEdge, OnFirstEdge, PtOnFirstVertex, OnFirstVertex); + PtOnFirstEdge, OnFirstEdge, PtOnFirstVertex, OnFirstVertex); PtOnEdgeVertex(RevolRib, mySbase, p2, FirstVertex, LastVertex, - PtOnLastEdge, OnLastEdge, PtOnLastVertex, OnLastVertex); + PtOnLastEdge, OnLastEdge, PtOnLastVertex, OnLastVertex); TopTools_MapOfShape Map; @@ -1180,51 +900,51 @@ Standard_Boolean BRepFeat_RibSlot::ExtremeFaces(const Standard_Boolean RevolRib, if (!PtOnFirstVertex) { // Find FirstFace : face of the base shape containing OnFirstEdge // meeting ChoiceOfFaces - TopExp_Explorer ex4, ex5; - ex4.Init(mySbase, TopAbs_FACE); - TopTools_ListOfShape faces; - faces.Clear(); - Map.Clear(); - for(; ex4.More(); ex4.Next()) { - const TopoDS_Face& fx = TopoDS::Face(ex4.Current());//modified by NIZNHY-PKV Fri Mar 22 17:06:04 2002 fx instead f - if ( !Map.Add(fx)) continue; - ex5.Init(ex4.Current(), TopAbs_EDGE); - for(; ex5.More(); ex5.Next()) { - const TopoDS_Edge& ee = TopoDS::Edge(ex5.Current()); - if(ee.IsSame(OnFirstEdge)) { - faces.Append(fx); - } - } - } - if(!faces.IsEmpty()) { - TopoDS_Face FFF = ChoiceOfFaces(faces, cc, FirstPar+bnd/50., bnd/50., Pln); - if(!FFF.IsNull()) FirstFace = FFF; - } + TopExp_Explorer ex4, ex5; + ex4.Init(mySbase, TopAbs_FACE); + TopTools_ListOfShape faces; + faces.Clear(); + Map.Clear(); + for(; ex4.More(); ex4.Next()) { + const TopoDS_Face& fx = TopoDS::Face(ex4.Current());//modified by NIZNHY-PKV Fri Mar 22 17:06:04 2002 fx instead f + if ( !Map.Add(fx)) continue; + ex5.Init(ex4.Current(), TopAbs_EDGE); + for(; ex5.More(); ex5.Next()) { + const TopoDS_Edge& ee = TopoDS::Edge(ex5.Current()); + if(ee.IsSame(OnFirstEdge)) { + faces.Append(fx); + } + } + } + if(!faces.IsEmpty()) { + TopoDS_Face FFF = ChoiceOfFaces(faces, cc, FirstPar+bnd/50., bnd/50., Pln); + if(!FFF.IsNull()) FirstFace = FFF; + } } else if(PtOnFirstVertex) { // Find FirstFace : face of the base shape containing OnFirstVertex // meeting ChoiceOfFaces - TopExp_Explorer ex4, ex5; - ex4.Init(mySbase, TopAbs_FACE); - TopTools_ListOfShape faces; - faces.Clear(); - Map.Clear(); - for(; ex4.More(); ex4.Next()) { - const TopoDS_Face& fx = TopoDS::Face(ex4.Current());//modified by NIZNHY-PKV Fri Mar 22 17:06:36 2002 fx instead of f - if ( !Map.Add(fx)) continue; - ex5.Init(ex4.Current(), TopAbs_VERTEX); - for(; ex5.More(); ex5.Next()) { - const TopoDS_Vertex& vv = TopoDS::Vertex(ex5.Current()); - if(vv.IsSame(OnFirstVertex)) { - faces.Append(fx); - break; - } - } - } - if(!faces.IsEmpty()) { - TopoDS_Face FFF = ChoiceOfFaces(faces, cc, FirstPar+bnd/50., bnd/50., Pln); - if(!FFF.IsNull()) FirstFace = FFF; - } + TopExp_Explorer ex4, ex5; + ex4.Init(mySbase, TopAbs_FACE); + TopTools_ListOfShape faces; + faces.Clear(); + Map.Clear(); + for(; ex4.More(); ex4.Next()) { + const TopoDS_Face& fx = TopoDS::Face(ex4.Current());//modified by NIZNHY-PKV Fri Mar 22 17:06:36 2002 fx instead of f + if ( !Map.Add(fx)) continue; + ex5.Init(ex4.Current(), TopAbs_VERTEX); + for(; ex5.More(); ex5.Next()) { + const TopoDS_Vertex& vv = TopoDS::Vertex(ex5.Current()); + if(vv.IsSame(OnFirstVertex)) { + faces.Append(fx); + break; + } + } + } + if(!faces.IsEmpty()) { + TopoDS_Face FFF = ChoiceOfFaces(faces, cc, FirstPar+bnd/50., bnd/50., Pln); + if(!FFF.IsNull()) FirstFace = FFF; + } } FirstEdge = E; BRepLib_MakeVertex v(p1); @@ -1236,52 +956,52 @@ Standard_Boolean BRepFeat_RibSlot::ExtremeFaces(const Standard_Boolean RevolRib, if (!PtOnLastVertex) { // Find LastFace : face of the base shape containing OnLastEdge // meeting ChoiceOfFaces - TopExp_Explorer ex4, ex5; - ex4.Init(mySbase, TopAbs_FACE); - TopTools_ListOfShape faces; - faces.Clear(); - Map.Clear(); - for(; ex4.More(); ex4.Next()) { - const TopoDS_Face& fx = TopoDS::Face(ex4.Current());//modified by NIZNHY-PKV Fri Mar 22 17:06:36 2002 fx instead of f - if ( !Map.Add(fx)) continue; - ex5.Init(ex4.Current(), TopAbs_EDGE); - for(; ex5.More(); ex5.Next()) { - const TopoDS_Edge& ee = TopoDS::Edge(ex5.Current()); - if(ee.IsSame(OnLastEdge)) { - faces.Append(fx); - break; - } - } - } - if(!faces.IsEmpty()) { - TopoDS_Face FFF = ChoiceOfFaces(faces, cc, LastPar-bnd/50., bnd/50., Pln); - if(!FFF.IsNull()) LastFace = FFF; - } + TopExp_Explorer ex4, ex5; + ex4.Init(mySbase, TopAbs_FACE); + TopTools_ListOfShape faces; + faces.Clear(); + Map.Clear(); + for(; ex4.More(); ex4.Next()) { + const TopoDS_Face& fx = TopoDS::Face(ex4.Current());//modified by NIZNHY-PKV Fri Mar 22 17:06:36 2002 fx instead of f + if ( !Map.Add(fx)) continue; + ex5.Init(ex4.Current(), TopAbs_EDGE); + for(; ex5.More(); ex5.Next()) { + const TopoDS_Edge& ee = TopoDS::Edge(ex5.Current()); + if(ee.IsSame(OnLastEdge)) { + faces.Append(fx); + break; + } + } + } + if(!faces.IsEmpty()) { + TopoDS_Face FFF = ChoiceOfFaces(faces, cc, LastPar-bnd/50., bnd/50., Pln); + if(!FFF.IsNull()) LastFace = FFF; + } } else if(PtOnLastEdge && PtOnLastVertex) { // Find LastFace : face of the base shape containing OnLastVertex // meeting ChoiceOfFaces - TopExp_Explorer ex4, ex5; - ex4.Init(mySbase, TopAbs_FACE); - TopTools_ListOfShape faces; - faces.Clear(); - Map.Clear(); - for(; ex4.More(); ex4.Next()) { - const TopoDS_Face& fx = TopoDS::Face(ex4.Current());//modified by NIZNHY-PKV Fri Mar 22 17:06:36 2002 fx instead of f - if ( !Map.Add(fx)) continue; - ex5.Init(ex4.Current(), TopAbs_VERTEX); - for(; ex5.More(); ex5.Next()) { - const TopoDS_Vertex& vv = TopoDS::Vertex(ex5.Current()); - if(vv.IsSame(OnLastVertex)) { - faces.Append(fx); - break; - } - } - } - if(!faces.IsEmpty()) { - TopoDS_Face FFF = ChoiceOfFaces(faces, cc, LastPar-bnd/50., bnd/50., Pln); - if(!FFF.IsNull()) LastFace = FFF; - } + TopExp_Explorer ex4, ex5; + ex4.Init(mySbase, TopAbs_FACE); + TopTools_ListOfShape faces; + faces.Clear(); + Map.Clear(); + for(; ex4.More(); ex4.Next()) { + const TopoDS_Face& fx = TopoDS::Face(ex4.Current());//modified by NIZNHY-PKV Fri Mar 22 17:06:36 2002 fx instead of f + if ( !Map.Add(fx)) continue; + ex5.Init(ex4.Current(), TopAbs_VERTEX); + for(; ex5.More(); ex5.Next()) { + const TopoDS_Vertex& vv = TopoDS::Vertex(ex5.Current()); + if(vv.IsSame(OnLastVertex)) { + faces.Append(fx); + break; + } + } + } + if(!faces.IsEmpty()) { + TopoDS_Face FFF = ChoiceOfFaces(faces, cc, LastPar-bnd/50., bnd/50., Pln); + if(!FFF.IsNull()) LastFace = FFF; + } } LastEdge = E; BRepLib_MakeVertex v(p2); @@ -1307,32 +1027,32 @@ Standard_Boolean BRepFeat_RibSlot::ExtremeFaces(const Standard_Boolean RevolRib, lastpar = ASI.Point(1, ASI.NbPoints(1)).Parameter(); Standard_Integer lastindex = ASI.NbPoints(1); if(lastpar > l) { - for(Standard_Integer jj=ASI.NbPoints(1)-1; jj>=1; jj--) { - Standard_Real par = ASI.Point(1,jj).Parameter(); - if(par <= l) { - lastpar = par; - lastindex = jj; - break; - } - } + for(Standard_Integer jj=ASI.NbPoints(1)-1; jj>=1; jj--) { + Standard_Real par = ASI.Point(1,jj).Parameter(); + if(par <= l) { + lastpar = par; + lastindex = jj; + break; + } + } } Standard_Integer firstindex = lastindex -1; firstpar = ASI.Point(1,firstindex).Parameter(); if(FirstFace.IsNull()) { - FirstFace = ASI.Point(1, firstindex).Face(); - cc->D0(firstpar, firstpoint); - BRepLib_MakeVertex v1(firstpoint); - FirstVertex = TopoDS::Vertex(v1.Shape()); - FirstEdge = E; + FirstFace = ASI.Point(1, firstindex).Face(); + cc->D0(firstpar, firstpoint); + BRepLib_MakeVertex v1(firstpoint); + FirstVertex = TopoDS::Vertex(v1.Shape()); + FirstEdge = E; } if(LastFace.IsNull()) { - LastFace = ASI.Point(1, lastindex).Face(); - cc->D0(lastpar, lastpoint); - BRepLib_MakeVertex v2(lastpoint); - LastVertex = TopoDS::Vertex(v2.Shape()); - LastEdge = E; + LastFace = ASI.Point(1, lastindex).Face(); + cc->D0(lastpar, lastpoint); + BRepLib_MakeVertex v2(lastpoint); + LastVertex = TopoDS::Vertex(v2.Shape()); + LastEdge = E; } } else { @@ -1345,13 +1065,13 @@ Standard_Boolean BRepFeat_RibSlot::ExtremeFaces(const Standard_Boolean RevolRib, if(!OnFirstFace) { if(p1.Distance(firstpoint) <= Precision::Confusion()) - OnFirstFace = Standard_True; + OnFirstFace = Standard_True; else OnFirstFace = Standard_False; } if(!OnLastFace) { if(p2.Distance(lastpoint) <= Precision::Confusion()) - OnLastFace = Standard_True; + OnLastFace = Standard_True; else OnLastFace = Standard_False; } @@ -1386,7 +1106,7 @@ Standard_Boolean BRepFeat_RibSlot::ExtremeFaces(const Standard_Boolean RevolRib, #ifdef DEB gp_Pnt P1 = #endif - BRep_Tool::Pnt(TopExp::FirstVertex(E,Standard_True)); + BRep_Tool::Pnt(TopExp::FirstVertex(E,Standard_True)); gp_Pnt P2 = BRep_Tool::Pnt(TopExp::LastVertex(E,Standard_True)); ex1.Init(mySbase, TopAbs_FACE); TopoDS_Vertex theVertex; @@ -1398,142 +1118,142 @@ Standard_Boolean BRepFeat_RibSlot::ExtremeFaces(const Standard_Boolean RevolRib, TopoDS_Vertex OnVertex; Standard_Real intpar; for(; ex1.More(); ex1.Next()) { - const TopoDS_Face& f = TopoDS::Face(ex1.Current()); - inter.Init(f,curve, BRep_Tool::Tolerance(f)); - if(!inter.More()) continue; - for(; inter.More(); inter.Next()) { - gp_Pnt thePoint = inter.Pnt(); - if(!FirstVertex.IsNull()) { - gp_Pnt point = BRep_Tool::Pnt(FirstVertex); - if(point.Distance(thePoint) <= BRep_Tool::Tolerance(f)) { - continue; - } - } - intpar = IntPar(curve, thePoint); - theEdge = E; - theFace = f; - B.MakeVertex(theVertex, thePoint, Precision::Confusion()); - if(!FirstOK) { - if(thePoint.Distance(P2) <= Precision::Confusion()) { - continue; - } - } + const TopoDS_Face& f = TopoDS::Face(ex1.Current()); + inter.Init(f,curve, BRep_Tool::Tolerance(f)); + if(!inter.More()) continue; + for(; inter.More(); inter.Next()) { + gp_Pnt thePoint = inter.Pnt(); + if(!FirstVertex.IsNull()) { + gp_Pnt point = BRep_Tool::Pnt(FirstVertex); + if(point.Distance(thePoint) <= BRep_Tool::Tolerance(f)) { + continue; + } + } + intpar = IntPar(curve, thePoint); + theEdge = E; + theFace = f; + B.MakeVertex(theVertex, thePoint, Precision::Confusion()); + if(!FirstOK) { + if(thePoint.Distance(P2) <= Precision::Confusion()) { + continue; + } + } // ---Find thepoint on an edge or a vertex of face f - PtOnEdgeVertex(RevolRib, f, thePoint, FirstVertex, LastVertex, - PtOnEdge,OnEdge,PtOnVertex,OnVertex); - - -// if(!theEdge.IsNull()) break; - - if (FirstEdge.IsNull() && !theEdge.IsNull() && - !theFace.IsNull() && !theVertex.IsNull()) { - FirstEdge = theEdge; - FirstFace = theFace; - FirstVertex = theVertex; - PtOnFirstEdge = PtOnEdge; - OnFirstEdge = OnEdge; - theEdge.Nullify(); theFace.Nullify(); theVertex.Nullify(); - if(PtOnEdge && !PtOnVertex) { - TopTools_ListOfShape faces; - faces.Clear(); - faces.Append(FirstFace); - TopExp_Explorer ex2; - ex2.Init(mySbase, TopAbs_FACE); - for(; ex2.More(); ex2.Next()) { - TopoDS_Face fx = TopoDS::Face(ex2.Current());//modified by NIZNHY-PKV Fri Mar 22 17:16:44 2002 fx/f - TopExp_Explorer ex3; - ex3.Init(fx, TopAbs_EDGE); - for(; ex3.More(); ex3.Next()) { - const TopoDS_Edge& e = TopoDS::Edge(ex3.Current()); - if(e.IsSame(OnEdge) && !fx.IsSame(FirstFace)) { - faces.Append(fx); - } - } - } - TopoDS_Face FFF = ChoiceOfFaces(faces, curve, intpar+bnd/10., bnd/10., Pln); - if(!FFF.IsNull()) FirstFace = FFF; - } - else if(PtOnEdge && PtOnVertex) { - TopTools_ListOfShape faces; - faces.Clear(); - faces.Append(FirstFace); - TopExp_Explorer ex2; - ex2.Init(mySbase, TopAbs_FACE); - for(; ex2.More(); ex2.Next()) { - TopoDS_Face fx = TopoDS::Face(ex2.Current());//modified by NIZNHY-PKV Fri Mar 22 17:13:08 2002 fx/f - TopExp_Explorer ex3; - ex3.Init(fx, TopAbs_VERTEX); - for(; ex3.More(); ex3.Next()) { - const TopoDS_Vertex& v = TopoDS::Vertex(ex3.Current()); - if(v.IsSame(OnVertex) && !fx.IsSame(FirstFace)) { - faces.Append(fx); - } - } - } - TopoDS_Face FFF = ChoiceOfFaces(faces, curve, intpar+bnd/10., bnd/10., Pln); - if(!FFF.IsNull()) FirstFace = FFF; - } - if(!FirstEdge.IsNull() && !FirstFace.IsNull() - && !FirstVertex.IsNull()) { - FirstOK = Standard_True; - } - } - if(LastEdge.IsNull() && !theEdge.IsNull() && - !theFace.IsNull() && !theVertex.IsNull() && - !FirstEdge.IsNull()) { - LastEdge = theEdge; - LastFace = theFace; - LastVertex = theVertex; - PtOnLastEdge = PtOnEdge; - OnLastEdge = OnEdge; - if(PtOnEdge && !PtOnVertex) { - TopTools_ListOfShape faces; - faces.Clear(); - faces.Append(LastFace); - TopExp_Explorer ex2; - ex2.Init(mySbase, TopAbs_FACE); - for(; ex2.More(); ex2.Next()) { - TopoDS_Face fx = TopoDS::Face(ex2.Current());//modified by NIZNHY-PKV Fri Mar 22 17:12:06 2002 fx/f - TopExp_Explorer ex3; - ex3.Init(fx, TopAbs_EDGE); - for(; ex3.More(); ex3.Next()) { - const TopoDS_Edge& e = TopoDS::Edge(ex3.Current()); - if(e.IsSame(OnEdge) && !fx.IsSame(LastFace)) { - faces.Append(fx); - } - } - } - TopoDS_Face FFF = ChoiceOfFaces(faces, curve, intpar-bnd/10.,bnd/10., Pln); - if(!FFF.IsNull()) LastFace = FFF; - } - else if(PtOnEdge && PtOnVertex) { - TopTools_ListOfShape faces; - faces.Clear(); - faces.Append(LastFace); - TopExp_Explorer ex2; - ex2.Init(mySbase, TopAbs_FACE); - for(; ex2.More(); ex2.Next()) { - TopoDS_Face fx = TopoDS::Face(ex2.Current());//modified by NIZNHY-PKV Fri Mar 22 17:11:36 2002 fx/f - TopExp_Explorer ex3; - ex3.Init(fx, TopAbs_VERTEX); - for(; ex3.More(); ex3.Next()) { - const TopoDS_Vertex& v = TopoDS::Vertex(ex3.Current()); - if(v.IsSame(OnVertex) && !fx.IsSame(LastFace)) { - faces.Append(fx); - } - } - } - TopoDS_Face FFF = ChoiceOfFaces(faces, curve, intpar-bnd/10.,bnd/10., Pln); - if(!FFF.IsNull()) LastFace = FFF; - } - if(!LastEdge.IsNull() && !LastFace.IsNull() - && !LastVertex.IsNull()) { - LastOK = Standard_True; - } - break; - } - } + PtOnEdgeVertex(RevolRib, f, thePoint, FirstVertex, LastVertex, + PtOnEdge,OnEdge,PtOnVertex,OnVertex); + + +// if(!theEdge.IsNull()) break; + + if (FirstEdge.IsNull() && !theEdge.IsNull() && + !theFace.IsNull() && !theVertex.IsNull()) { + FirstEdge = theEdge; + FirstFace = theFace; + FirstVertex = theVertex; + PtOnFirstEdge = PtOnEdge; + OnFirstEdge = OnEdge; + theEdge.Nullify(); theFace.Nullify(); theVertex.Nullify(); + if(PtOnEdge && !PtOnVertex) { + TopTools_ListOfShape faces; + faces.Clear(); + faces.Append(FirstFace); + TopExp_Explorer ex2; + ex2.Init(mySbase, TopAbs_FACE); + for(; ex2.More(); ex2.Next()) { + TopoDS_Face fx = TopoDS::Face(ex2.Current());//modified by NIZNHY-PKV Fri Mar 22 17:16:44 2002 fx/f + TopExp_Explorer ex3; + ex3.Init(fx, TopAbs_EDGE); + for(; ex3.More(); ex3.Next()) { + const TopoDS_Edge& e = TopoDS::Edge(ex3.Current()); + if(e.IsSame(OnEdge) && !fx.IsSame(FirstFace)) { + faces.Append(fx); + } + } + } + TopoDS_Face FFF = ChoiceOfFaces(faces, curve, intpar+bnd/10., bnd/10., Pln); + if(!FFF.IsNull()) FirstFace = FFF; + } + else if(PtOnEdge && PtOnVertex) { + TopTools_ListOfShape faces; + faces.Clear(); + faces.Append(FirstFace); + TopExp_Explorer ex2; + ex2.Init(mySbase, TopAbs_FACE); + for(; ex2.More(); ex2.Next()) { + TopoDS_Face fx = TopoDS::Face(ex2.Current());//modified by NIZNHY-PKV Fri Mar 22 17:13:08 2002 fx/f + TopExp_Explorer ex3; + ex3.Init(fx, TopAbs_VERTEX); + for(; ex3.More(); ex3.Next()) { + const TopoDS_Vertex& v = TopoDS::Vertex(ex3.Current()); + if(v.IsSame(OnVertex) && !fx.IsSame(FirstFace)) { + faces.Append(fx); + } + } + } + TopoDS_Face FFF = ChoiceOfFaces(faces, curve, intpar+bnd/10., bnd/10., Pln); + if(!FFF.IsNull()) FirstFace = FFF; + } + if(!FirstEdge.IsNull() && !FirstFace.IsNull() + && !FirstVertex.IsNull()) { + FirstOK = Standard_True; + } + } + if(LastEdge.IsNull() && !theEdge.IsNull() && + !theFace.IsNull() && !theVertex.IsNull() && + !FirstEdge.IsNull()) { + LastEdge = theEdge; + LastFace = theFace; + LastVertex = theVertex; + PtOnLastEdge = PtOnEdge; + OnLastEdge = OnEdge; + if(PtOnEdge && !PtOnVertex) { + TopTools_ListOfShape faces; + faces.Clear(); + faces.Append(LastFace); + TopExp_Explorer ex2; + ex2.Init(mySbase, TopAbs_FACE); + for(; ex2.More(); ex2.Next()) { + TopoDS_Face fx = TopoDS::Face(ex2.Current());//modified by NIZNHY-PKV Fri Mar 22 17:12:06 2002 fx/f + TopExp_Explorer ex3; + ex3.Init(fx, TopAbs_EDGE); + for(; ex3.More(); ex3.Next()) { + const TopoDS_Edge& e = TopoDS::Edge(ex3.Current()); + if(e.IsSame(OnEdge) && !fx.IsSame(LastFace)) { + faces.Append(fx); + } + } + } + TopoDS_Face FFF = ChoiceOfFaces(faces, curve, intpar-bnd/10.,bnd/10., Pln); + if(!FFF.IsNull()) LastFace = FFF; + } + else if(PtOnEdge && PtOnVertex) { + TopTools_ListOfShape faces; + faces.Clear(); + faces.Append(LastFace); + TopExp_Explorer ex2; + ex2.Init(mySbase, TopAbs_FACE); + for(; ex2.More(); ex2.Next()) { + TopoDS_Face fx = TopoDS::Face(ex2.Current());//modified by NIZNHY-PKV Fri Mar 22 17:11:36 2002 fx/f + TopExp_Explorer ex3; + ex3.Init(fx, TopAbs_VERTEX); + for(; ex3.More(); ex3.Next()) { + const TopoDS_Vertex& v = TopoDS::Vertex(ex3.Current()); + if(v.IsSame(OnVertex) && !fx.IsSame(LastFace)) { + faces.Append(fx); + } + } + } + TopoDS_Face FFF = ChoiceOfFaces(faces, curve, intpar-bnd/10.,bnd/10., Pln); + if(!FFF.IsNull()) LastFace = FFF; + } + if(!LastEdge.IsNull() && !LastFace.IsNull() + && !LastVertex.IsNull()) { + LastOK = Standard_True; + } + break; + } + } } } @@ -1544,10 +1264,10 @@ Standard_Boolean BRepFeat_RibSlot::ExtremeFaces(const Standard_Boolean RevolRib, gp_Pnt p1 = BRep_Tool::Pnt(FirstVertex); gp_Pnt p2 = BRep_Tool::Pnt(LastVertex); if(p1.Distance(PP1) <= BRep_Tool::Tolerance(FirstFace)) { - OnFirstFace = Standard_True; + OnFirstFace = Standard_True; } if(p2.Distance(PP2) <= BRep_Tool::Tolerance(LastFace)) { - OnLastFace = Standard_True; + OnLastFace = Standard_True; } return Standard_True; } @@ -1568,14 +1288,14 @@ Standard_Boolean BRepFeat_RibSlot::ExtremeFaces(const Standard_Boolean RevolRib, //======================================================================= void BRepFeat_RibSlot::PtOnEdgeVertex(const Standard_Boolean RevolRib, - const TopoDS_Shape& shape, - const gp_Pnt& point, - const TopoDS_Vertex& ,//FirstVertex, - const TopoDS_Vertex& ,//LastVertex, - Standard_Boolean& PtOnEdge, - TopoDS_Edge& OnEdge, - Standard_Boolean& PtOnVertex, - TopoDS_Vertex& OnVertex) + const TopoDS_Shape& shape, + const gp_Pnt& point, + const TopoDS_Vertex& ,//FirstVertex, + const TopoDS_Vertex& ,//LastVertex, + Standard_Boolean& PtOnEdge, + TopoDS_Edge& OnEdge, + Standard_Boolean& PtOnVertex, + TopoDS_Vertex& OnVertex) { #ifdef DEB @@ -1612,21 +1332,21 @@ void BRepFeat_RibSlot::PtOnEdgeVertex(const Standard_Boolean RevolRib, } if(TestOK && proj.Distance(1) <= BRep_Tool::Tolerance(e)) { PtOnEdge = Standard_True; - OnEdge = e; + OnEdge = e; TopoDS_Vertex ev1 = TopExp::FirstVertex(e,Standard_True); TopoDS_Vertex ev2 = TopExp::LastVertex(e,Standard_True); gp_Pnt ep1 = BRep_Tool::Pnt(ev1); gp_Pnt ep2 = BRep_Tool::Pnt(ev2); if(point.Distance(ep1) <= BRep_Tool::Tolerance(ev1)) { - PtOnVertex = Standard_True; - OnVertex = ev1; - break; + PtOnVertex = Standard_True; + OnVertex = ev1; + break; } else if(point.Distance(ep2) <= BRep_Tool::Tolerance(ev1)) { - PtOnVertex = Standard_True; - OnVertex = ev2; - break; - } + PtOnVertex = Standard_True; + OnVertex = ev2; + break; + } break; } } @@ -1639,18 +1359,18 @@ void BRepFeat_RibSlot::PtOnEdgeVertex(const Standard_Boolean RevolRib, //======================================================================= Standard_Boolean BRepFeat_RibSlot::SlidingProfile(TopoDS_Face& Prof, - const Standard_Boolean RevolRib, - const Standard_Real myTol, - Standard_Integer& Concavite, - const Handle(Geom_Plane)& myPln, - const TopoDS_Face& BndFace, - const gp_Pnt& CheckPnt, - const TopoDS_Face& FirstFace, - const TopoDS_Face& LastFace, - const TopoDS_Vertex& ,//FirstVertex, - const TopoDS_Vertex& ,//LastVertex, - const TopoDS_Edge& FirstEdge, - const TopoDS_Edge& LastEdge) + const Standard_Boolean RevolRib, + const Standard_Real myTol, + Standard_Integer& Concavite, + const Handle(Geom_Plane)& myPln, + const TopoDS_Face& BndFace, + const gp_Pnt& CheckPnt, + const TopoDS_Face& FirstFace, + const TopoDS_Face& LastFace, + const TopoDS_Vertex& ,//FirstVertex, + const TopoDS_Vertex& ,//LastVertex, + const TopoDS_Edge& FirstEdge, + const TopoDS_Edge& LastEdge) { #ifdef DEB @@ -1697,9 +1417,9 @@ Standard_Boolean BRepFeat_RibSlot::SlidingProfile(TopoDS_Face& Prof, Standard_Real par1 = ElCLib::Parameter(ln1->Lin(), myFirstPnt); Standard_Real par2 = ElCLib::Parameter(ln2->Lin(), myLastPnt); if(par1 >= myTol || par2 >= myTol) { - Concavite = 2; //paralel and concave - BRepLib_MakeEdge e1(myLastPnt, myFirstPnt); - WW.Add(e1); + Concavite = 2; //paralel and concave + BRepLib_MakeEdge e1(myLastPnt, myFirstPnt); + WW.Add(e1); } } if(d1.IsEqual(d2, myTol)) { @@ -1741,31 +1461,31 @@ Standard_Boolean BRepFeat_RibSlot::SlidingProfile(TopoDS_Face& Prof, Handle(Geom_Curve) c = BRep_Tool::Curve(e, first, last); Handle(Geom2d_Curve) c2d = GeomAPI::To2d(c, myPln->Pln()); Geom2dAPI_InterCurveCurve intcln1(ln2d1, c2d, - Precision::Confusion()); + Precision::Confusion()); if(intcln1.NbPoints() > 0) { - gp_Pnt2d p2d = intcln1.Point(1); - gp_Pnt p; - myPln->D0(p2d.X(), p2d.Y(), p); - Standard_Real parl = IntPar(ln1, p); - Standard_Real parc = IntPar(c, p); - if(parc >= first && parc <= last && parl >= 0) { - BndEdge1 = e; - BndPnt1 = p; - } + gp_Pnt2d p2d = intcln1.Point(1); + gp_Pnt p; + myPln->D0(p2d.X(), p2d.Y(), p); + Standard_Real parl = IntPar(ln1, p); + Standard_Real parc = IntPar(c, p); + if(parc >= first && parc <= last && parl >= 0) { + BndEdge1 = e; + BndPnt1 = p; + } } Geom2dAPI_InterCurveCurve intcln2(ln2d2, c2d, - Precision::Confusion()); + Precision::Confusion()); if(intcln2.NbPoints() > 0) { - gp_Pnt2d p2d = intcln2.Point(1); - gp_Pnt p; - myPln->D0(p2d.X(), p2d.Y(), p); - Standard_Real parl = IntPar(ln2, p); - Standard_Real parc = IntPar(c, p); - if(parc >= first && parc <= last && parl >= 0) { - BndEdge2 = e; - BndPnt2 = p; - } + gp_Pnt2d p2d = intcln2.Point(1); + gp_Pnt p; + myPln->D0(p2d.X(), p2d.Y(), p); + Standard_Real parl = IntPar(ln2, p); + Standard_Real parc = IntPar(c, p); + if(parc >= first && parc <= last && parl >= 0) { + BndEdge2 = e; + BndPnt2 = p; + } } if(!BndEdge1.IsNull() && !BndEdge2.IsNull()) break; } @@ -1787,31 +1507,31 @@ Standard_Boolean BRepFeat_RibSlot::SlidingProfile(TopoDS_Face& Prof, BRepLib_MakeEdge e2(BndPnt1, BndPnt2); WW.Add(e2); BRepLib_MakeEdge e3(BndPnt2, myFirstPnt); - WW.Add(e3); + WW.Add(e3); } else { explo.Init(BndWire); for(; explo.More(); explo.Next()) { - const TopoDS_Edge& e = TopoDS::Edge(explo.Current()); - if(e.IsSame(BndEdge1)) { - gp_Pnt pp; - pp = BRep_Tool::Pnt(TopExp::LastVertex(e,Standard_True)); - if(pp.Distance(BndPnt1) >= BRep_Tool::Tolerance(e)) { - LastPnt = pp; - } -// else { //LinearForm -// gp_Pnt ppp = BRep_Tool::Pnt(TopExp::FirstVertex(e,Standard_True)); -// LastPnt = ppp; -// } - BRepLib_MakeEdge e2(BndPnt1, LastPnt); - WW.Add(e2); - break; - } + const TopoDS_Edge& e = TopoDS::Edge(explo.Current()); + if(e.IsSame(BndEdge1)) { + gp_Pnt pp; + pp = BRep_Tool::Pnt(TopExp::LastVertex(e,Standard_True)); + if(pp.Distance(BndPnt1) >= BRep_Tool::Tolerance(e)) { + LastPnt = pp; + } +// else { //LinearForm +// gp_Pnt ppp = BRep_Tool::Pnt(TopExp::FirstVertex(e,Standard_True)); +// LastPnt = ppp; +// } + BRepLib_MakeEdge e2(BndPnt1, LastPnt); + WW.Add(e2); + break; + } } if(explo.More()) { - explo.Next(); - if(explo.Current().IsNull()) explo.Init(BndWire); + explo.Next(); + if(explo.Current().IsNull()) explo.Init(BndWire); } else explo.Init(BndWire); @@ -1820,29 +1540,29 @@ Standard_Boolean BRepFeat_RibSlot::SlidingProfile(TopoDS_Face& Prof, // -> if no : add edges Standard_Boolean Fin = Standard_False; while(!Fin) { - const TopoDS_Edge& e = TopoDS::Edge(explo.Current()); - if(!e.IsSame(BndEdge2)) { - gp_Pnt pp; - pp = BRep_Tool::Pnt(TopExp::LastVertex(e,Standard_True)); - BRepLib_MakeEdge ee(LastPnt, pp); - WW.Add(ee); - LastPnt = pp; - } - else { + const TopoDS_Edge& e = TopoDS::Edge(explo.Current()); + if(!e.IsSame(BndEdge2)) { + gp_Pnt pp; + pp = BRep_Tool::Pnt(TopExp::LastVertex(e,Standard_True)); + BRepLib_MakeEdge ee(LastPnt, pp); + WW.Add(ee); + LastPnt = pp; + } + else { // the path is closed // -> since met BndEdge2, end of borders on BndFace - Fin = Standard_True; - BRepLib_MakeEdge ee(LastPnt, BndPnt2); - WW.Add(ee); - LastPnt = BndPnt2; - } - if(explo.More()) { - explo.Next(); - if(explo.Current().IsNull()) { - explo.Init(BndWire); - } - } - else explo.Init(BndWire); + Fin = Standard_True; + BRepLib_MakeEdge ee(LastPnt, BndPnt2); + WW.Add(ee); + LastPnt = BndPnt2; + } + if(explo.More()) { + explo.Next(); + if(explo.Current().IsNull()) { + explo.Init(BndWire); + } + } + else explo.Init(BndWire); } BRepLib_MakeEdge e3(BndPnt2, myFirstPnt); @@ -1866,14 +1586,14 @@ Standard_Boolean BRepFeat_RibSlot::SlidingProfile(TopoDS_Face& Prof, WW.Add(ef); for(; EX.More(); EX.Next()) { const TopoDS_Edge& E = EX.Current(); - if(E.IsSame(FirstEdge)) break; + if(E.IsSame(FirstEdge)) break; } EX.Next(); for(; EX.More(); EX.Next()) { const TopoDS_Edge& E = EX.Current(); if(!E.IsSame(LastEdge)) { - WW.Add(E); - } + WW.Add(E); + } else break; } Handle(Geom_Curve) LastCurve = BRep_Tool::Curve(LastEdge, ff, ll); @@ -1951,21 +1671,21 @@ Standard_Boolean BRepFeat_RibSlot::SlidingProfile(TopoDS_Face& Prof, //======================================================================= Standard_Boolean BRepFeat_RibSlot::NoSlidingProfile(TopoDS_Face& Prof, - const Standard_Boolean RevolRib, - const Standard_Real myTol, - Standard_Integer& Concavite, - const Handle(Geom_Plane)& myPln, - const Standard_Real bnd, - const TopoDS_Face& BndFace, - const gp_Pnt& CheckPnt, - const TopoDS_Face& ,//FirstFace, - const TopoDS_Face& ,//LastFace, - const TopoDS_Vertex& ,//FirstVertex, - const TopoDS_Vertex& ,//LastVertex, - const TopoDS_Edge& FirstEdge, - const TopoDS_Edge& LastEdge, - const Standard_Boolean OnFirstFace, - const Standard_Boolean OnLastFace) + const Standard_Boolean RevolRib, + const Standard_Real myTol, + Standard_Integer& Concavite, + const Handle(Geom_Plane)& myPln, + const Standard_Real bnd, + const TopoDS_Face& BndFace, + const gp_Pnt& CheckPnt, + const TopoDS_Face& ,//FirstFace, + const TopoDS_Face& ,//LastFace, + const TopoDS_Vertex& ,//FirstVertex, + const TopoDS_Vertex& ,//LastVertex, + const TopoDS_Edge& FirstEdge, + const TopoDS_Edge& LastEdge, + const Standard_Boolean OnFirstFace, + const Standard_Boolean OnLastFace) { #ifdef DEB @@ -1974,7 +1694,7 @@ Standard_Boolean BRepFeat_RibSlot::NoSlidingProfile(TopoDS_Face& Prof, #endif Standard_Boolean ProfileOK = Standard_True; - Standard_Real l1, f1, f2, l2;//, p; + Standard_Real l1, f1, f2, l2;//, p; TopoDS_Vertex theFV; theFV.Nullify(); gp_Pnt theFirstpoint; TopoDS_Edge theLastEdge; theLastEdge.Nullify(); @@ -2011,7 +1731,7 @@ Standard_Boolean BRepFeat_RibSlot::NoSlidingProfile(TopoDS_Face& Prof, Standard_Real par1 = ElCLib::Parameter(firstln->Lin(), myFirstPnt); Standard_Real par2 = ElCLib::Parameter(lastln->Lin(), myLastPnt); if(par1 >= myTol || par2 >= myTol) - Concavite = 2; //parallel and concave + Concavite = 2; //parallel and concave } if(d1.IsEqual(d2, myTol)) { if(Concavite == 3) TestOK = Standard_False; @@ -2038,21 +1758,21 @@ Standard_Boolean BRepFeat_RibSlot::NoSlidingProfile(TopoDS_Face& Prof, Handle(Geom_Curve) cc = BRep_Tool::Curve(FalseFirstEdge, f, l); cc->D1(f, firstpoint, firstvect); lastln = new Geom_Line(firstpoint, -firstvect); - if(FirstEdge.IsSame(LastEdge)) FalseOnlyOne = FalseFirstEdge; + if(FirstEdge.IsSame(LastEdge)) FalseOnlyOne = FalseFirstEdge; ln2d2 = GeomAPI::To2d(lastln, myPln->Pln()); } if(OnLastFace) { Standard_Real f, l; if(!FirstEdge.IsSame(LastEdge)) { - FalseLastEdge = LastEdge; + FalseLastEdge = LastEdge; } else { - if(FalseOnlyOne.IsNull()) FalseOnlyOne = LastEdge; - FalseLastEdge = FalseOnlyOne; + if(FalseOnlyOne.IsNull()) FalseOnlyOne = LastEdge; + FalseLastEdge = FalseOnlyOne; } EdgeExtention(FalseLastEdge, bnd, Standard_False); if(FirstEdge.IsSame(LastEdge)) { - FalseOnlyOne = FalseLastEdge; + FalseOnlyOne = FalseLastEdge; } const TopoDS_Vertex& vv2 = TopExp::LastVertex(FalseLastEdge,Standard_True); lastpoint = BRep_Tool::Pnt(vv2); @@ -2076,31 +1796,31 @@ Standard_Boolean BRepFeat_RibSlot::NoSlidingProfile(TopoDS_Face& Prof, Handle(Geom_Curve) c = BRep_Tool::Curve(e, first, last); Handle(Geom2d_Curve) c2d = GeomAPI::To2d(c, myPln->Pln()); Geom2dAPI_InterCurveCurve intcln1(ln2d1, c2d, - Precision::Confusion()); + Precision::Confusion()); if(intcln1.NbPoints() > 0) { - gp_Pnt2d p2d = intcln1.Point(1); - gp_Pnt p; - myPln->D0(p2d.X(), p2d.Y(), p); - Standard_Real parl = IntPar(firstln, p); - Standard_Real parc = IntPar(c, p); - if(parc >= first && parc <= last && parl >= 0) { - BndEdge1 = e; - BndPnt1 = p; - } + gp_Pnt2d p2d = intcln1.Point(1); + gp_Pnt p; + myPln->D0(p2d.X(), p2d.Y(), p); + Standard_Real parl = IntPar(firstln, p); + Standard_Real parc = IntPar(c, p); + if(parc >= first && parc <= last && parl >= 0) { + BndEdge1 = e; + BndPnt1 = p; + } } Geom2dAPI_InterCurveCurve intcln2(ln2d2, c2d, - Precision::Confusion()); + Precision::Confusion()); if(intcln2.NbPoints() > 0) { - gp_Pnt2d p2d = intcln2.Point(1); - gp_Pnt p; - myPln->D0(p2d.X(), p2d.Y(), p); - Standard_Real parl = IntPar(lastln, p); - Standard_Real parc = IntPar(c, p); - if(parc >= first && parc <= last && parl >= 0) { - BndEdge2 = e; - BndPnt2 = p; - } + gp_Pnt2d p2d = intcln2.Point(1); + gp_Pnt p; + myPln->D0(p2d.X(), p2d.Y(), p); + Standard_Real parl = IntPar(lastln, p); + Standard_Real parc = IntPar(c, p); + if(parc >= first && parc <= last && parl >= 0) { + BndEdge2 = e; + BndPnt2 = p; + } } if(!BndEdge1.IsNull() && !BndEdge2.IsNull()) break; } @@ -2134,145 +1854,145 @@ Standard_Boolean BRepFeat_RibSlot::NoSlidingProfile(TopoDS_Face& Prof, if(BndEdge1.IsSame(BndEdge2)) { TopoDS_Edge ee2, ee3; if(theLastEdge.IsNull()) { - BRepLib_MakeEdge e2(BndPnt1, BndPnt2); - ee2 = TopoDS::Edge(e2.Shape()); + BRepLib_MakeEdge e2(BndPnt1, BndPnt2); + ee2 = TopoDS::Edge(e2.Shape()); } else { - const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True); - BRepLib_MakeVertex v2(BndPnt2); - BRepLib_MakeEdge e2(v1, v2); - ee2 = TopoDS::Edge(e2.Shape()); + const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True); + BRepLib_MakeVertex v2(BndPnt2); + BRepLib_MakeEdge e2(v1, v2); + ee2 = TopoDS::Edge(e2.Shape()); } BB.Add(w, ee2); theLastEdge = ee2; if(theFV.IsNull()) { - theFV = TopExp::FirstVertex(ee2,Standard_True); - theFirstpoint = BRep_Tool::Pnt(theFV); + theFV = TopExp::FirstVertex(ee2,Standard_True); + theFirstpoint = BRep_Tool::Pnt(theFV); } if(theLastEdge.IsNull()) { - BRepLib_MakeEdge e3(BndPnt2, firstpoint); - ee3 = TopoDS::Edge(e3.Shape()); + BRepLib_MakeEdge e3(BndPnt2, firstpoint); + ee3 = TopoDS::Edge(e3.Shape()); } else { - const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True); - BRepLib_MakeVertex v2(firstpoint); - BRepLib_MakeEdge e3(v1, v2); - ee3 = TopoDS::Edge(e3.Shape()); + const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True); + BRepLib_MakeVertex v2(firstpoint); + BRepLib_MakeEdge e3(v1, v2); + ee3 = TopoDS::Edge(e3.Shape()); } - BB.Add(w, ee3); + BB.Add(w, ee3); theLastEdge = ee3; if(theFV.IsNull()) { - theFV = TopExp::FirstVertex(ee3,Standard_True); - theFirstpoint = BRep_Tool::Pnt(theFV); + theFV = TopExp::FirstVertex(ee3,Standard_True); + theFirstpoint = BRep_Tool::Pnt(theFV); } } else { explo.Init(BndWire); for(; explo.More(); explo.Next()) { - const TopoDS_Edge& e = TopoDS::Edge(explo.Current()); - if(e.IsSame(BndEdge1)) { - gp_Pnt pp; - pp = BRep_Tool::Pnt(TopExp::LastVertex(e,Standard_True)); - if(pp.Distance(BndPnt1) > BRep_Tool::Tolerance(e)) { - LastPnt = pp; - } - TopoDS_Edge eee; - if(theLastEdge.IsNull()) { - BRepLib_MakeEdge e2(BndPnt1, LastPnt); - eee = TopoDS::Edge(e2.Shape()); - } - else { - const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True); - BRepLib_MakeVertex v2(LastPnt); - BRepLib_MakeEdge e2(v1, v2); - eee = TopoDS::Edge(e2.Shape()); - } - BB.Add(w, eee); - theLastEdge = eee; - if(theFV.IsNull()) { - theFV = TopExp::FirstVertex(eee,Standard_True); - theFirstpoint = BRep_Tool::Pnt(theFV); - } - break; - } + const TopoDS_Edge& e = TopoDS::Edge(explo.Current()); + if(e.IsSame(BndEdge1)) { + gp_Pnt pp; + pp = BRep_Tool::Pnt(TopExp::LastVertex(e,Standard_True)); + if(pp.Distance(BndPnt1) > BRep_Tool::Tolerance(e)) { + LastPnt = pp; + } + TopoDS_Edge eee; + if(theLastEdge.IsNull()) { + BRepLib_MakeEdge e2(BndPnt1, LastPnt); + eee = TopoDS::Edge(e2.Shape()); + } + else { + const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True); + BRepLib_MakeVertex v2(LastPnt); + BRepLib_MakeEdge e2(v1, v2); + eee = TopoDS::Edge(e2.Shape()); + } + BB.Add(w, eee); + theLastEdge = eee; + if(theFV.IsNull()) { + theFV = TopExp::FirstVertex(eee,Standard_True); + theFirstpoint = BRep_Tool::Pnt(theFV); + } + break; + } } if(explo.More()) { - explo.Next(); - if(explo.Current().IsNull()) explo.Init(BndWire); + explo.Next(); + if(explo.Current().IsNull()) explo.Init(BndWire); } else explo.Init(BndWire); Standard_Boolean Fin = Standard_False; while(!Fin) { - const TopoDS_Edge& e = TopoDS::Edge(explo.Current()); - if(!e.IsSame(BndEdge2)) { - gp_Pnt pp; - pp = BRep_Tool::Pnt(TopExp::LastVertex(e,Standard_True)); - TopoDS_Edge eee1; - if(theLastEdge.IsNull()) { - BRepLib_MakeEdge ee(LastPnt, pp); - eee1 = TopoDS::Edge(ee.Shape()); - } - else { - const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True); - BRepLib_MakeVertex v2(pp); - BRepLib_MakeEdge ee(v1, v2); - eee1 = TopoDS::Edge(ee.Shape()); - } - BB.Add(w, eee1); - theLastEdge = eee1; - if(theFV.IsNull()) { - theFV = TopExp::FirstVertex(eee1,Standard_True); - theFirstpoint = BRep_Tool::Pnt(theFV); - } - LastPnt = pp; - } - else { - Fin = Standard_True; - TopoDS_Edge eee2; - if(theLastEdge.IsNull()) { - BRepLib_MakeEdge ee(LastPnt, BndPnt2); - eee2 = TopoDS::Edge(ee.Shape()); - } - else { - const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True); - BRepLib_MakeVertex v2(BndPnt2); - BRepLib_MakeEdge ee(v1, v2); - eee2 = TopoDS::Edge(ee.Shape()); - } - BB.Add(w, eee2); - theLastEdge = eee2; - if(theFV.IsNull()) { - theFV = TopExp::FirstVertex(eee2,Standard_True); - theFirstpoint = BRep_Tool::Pnt(theFV); - } - LastPnt = BndPnt2; - } - if(explo.More()) { - explo.Next(); - if(explo.Current().IsNull()) { - explo.Init(BndWire); - } - } - else explo.Init(BndWire); + const TopoDS_Edge& e = TopoDS::Edge(explo.Current()); + if(!e.IsSame(BndEdge2)) { + gp_Pnt pp; + pp = BRep_Tool::Pnt(TopExp::LastVertex(e,Standard_True)); + TopoDS_Edge eee1; + if(theLastEdge.IsNull()) { + BRepLib_MakeEdge ee(LastPnt, pp); + eee1 = TopoDS::Edge(ee.Shape()); + } + else { + const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True); + BRepLib_MakeVertex v2(pp); + BRepLib_MakeEdge ee(v1, v2); + eee1 = TopoDS::Edge(ee.Shape()); + } + BB.Add(w, eee1); + theLastEdge = eee1; + if(theFV.IsNull()) { + theFV = TopExp::FirstVertex(eee1,Standard_True); + theFirstpoint = BRep_Tool::Pnt(theFV); + } + LastPnt = pp; + } + else { + Fin = Standard_True; + TopoDS_Edge eee2; + if(theLastEdge.IsNull()) { + BRepLib_MakeEdge ee(LastPnt, BndPnt2); + eee2 = TopoDS::Edge(ee.Shape()); + } + else { + const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True); + BRepLib_MakeVertex v2(BndPnt2); + BRepLib_MakeEdge ee(v1, v2); + eee2 = TopoDS::Edge(ee.Shape()); + } + BB.Add(w, eee2); + theLastEdge = eee2; + if(theFV.IsNull()) { + theFV = TopExp::FirstVertex(eee2,Standard_True); + theFirstpoint = BRep_Tool::Pnt(theFV); + } + LastPnt = BndPnt2; + } + if(explo.More()) { + explo.Next(); + if(explo.Current().IsNull()) { + explo.Init(BndWire); + } + } + else explo.Init(BndWire); } TopoDS_Edge eee3; if(theLastEdge.IsNull()) { - BRepLib_MakeEdge e3(BndPnt2, firstpoint); - eee3 = TopoDS::Edge(e3.Shape()); + BRepLib_MakeEdge e3(BndPnt2, firstpoint); + eee3 = TopoDS::Edge(e3.Shape()); } else { - const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True); - BRepLib_MakeVertex v2(firstpoint); - BRepLib_MakeEdge e3(v1, v2); - eee3 = TopoDS::Edge(e3.Shape()); + const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True); + BRepLib_MakeVertex v2(firstpoint); + BRepLib_MakeEdge e3(v1, v2); + eee3 = TopoDS::Edge(e3.Shape()); } BB.Add(w, eee3); theLastEdge = eee3; if(theFV.IsNull()) { - theFV = TopExp::FirstVertex(eee3,Standard_True); - theFirstpoint = BRep_Tool::Pnt(theFV); + theFV = TopExp::FirstVertex(eee3,Standard_True); + theFirstpoint = BRep_Tool::Pnt(theFV); } } } @@ -2308,28 +2028,28 @@ Standard_Boolean BRepFeat_RibSlot::NoSlidingProfile(TopoDS_Face& Prof, Standard_Real f, l; Handle(Geom_Curve) cc = BRep_Tool::Curve(FalseOnlyOne, f, l); if(!theLastEdge.IsNull()) { - const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True); - TopoDS_Vertex v2; - const gp_Pnt& pp = BRep_Tool:: - Pnt(TopExp::LastVertex(FalseOnlyOne,Standard_True)); - if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) { - v2 = theFV; - } - else v2 = TopExp::LastVertex(FalseOnlyOne,Standard_True); - BRepLib_MakeEdge e(cc, v1, v2); - theEdge = TopoDS::Edge(e.Shape()); + const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True); + TopoDS_Vertex v2; + const gp_Pnt& pp = BRep_Tool:: + Pnt(TopExp::LastVertex(FalseOnlyOne,Standard_True)); + if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) { + v2 = theFV; + } + else v2 = TopExp::LastVertex(FalseOnlyOne,Standard_True); + BRepLib_MakeEdge e(cc, v1, v2); + theEdge = TopoDS::Edge(e.Shape()); } else { - const TopoDS_Vertex& v1 = TopExp::FirstVertex(FalseOnlyOne,Standard_True); - TopoDS_Vertex v2; - const gp_Pnt& pp = BRep_Tool:: - Pnt(TopExp::LastVertex(FalseOnlyOne,Standard_True)); - if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) { - v2 = theFV; - } - else v2 = TopExp::LastVertex(FalseOnlyOne,Standard_True); - BRepLib_MakeEdge e(cc, v1, v2); - theEdge = TopoDS::Edge(e.Shape()); + const TopoDS_Vertex& v1 = TopExp::FirstVertex(FalseOnlyOne,Standard_True); + TopoDS_Vertex v2; + const gp_Pnt& pp = BRep_Tool:: + Pnt(TopExp::LastVertex(FalseOnlyOne,Standard_True)); + if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) { + v2 = theFV; + } + else v2 = TopExp::LastVertex(FalseOnlyOne,Standard_True); + BRepLib_MakeEdge e(cc, v1, v2); + theEdge = TopoDS::Edge(e.Shape()); } myLFMap(FirstEdge).Append(theEdge); BB.Add(w, theEdge); @@ -2341,28 +2061,28 @@ Standard_Boolean BRepFeat_RibSlot::NoSlidingProfile(TopoDS_Face& Prof, Handle(Geom_Curve) cc = BRep_Tool::Curve(FirstEdge, f, l); TopoDS_Edge theEdge; if(!theLastEdge.IsNull()) { - const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True); - TopoDS_Vertex v2; + const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True); + TopoDS_Vertex v2; // Attention case Wire Reversed -> LastVertex without Standard_True - const gp_Pnt& pp = BRep_Tool::Pnt(TopExp::LastVertex(FirstEdge)); - if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) { - v2 = theFV; - } - else v2 = TopExp::LastVertex(FirstEdge); - BRepLib_MakeEdge e(cc, v1, v2); - theEdge = TopoDS::Edge(e.Shape()); + const gp_Pnt& pp = BRep_Tool::Pnt(TopExp::LastVertex(FirstEdge)); + if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) { + v2 = theFV; + } + else v2 = TopExp::LastVertex(FirstEdge); + BRepLib_MakeEdge e(cc, v1, v2); + theEdge = TopoDS::Edge(e.Shape()); } else { - const TopoDS_Vertex& v1 = TopExp::FirstVertex(FirstEdge,Standard_True); - TopoDS_Vertex v2; - const gp_Pnt& pp = BRep_Tool:: - Pnt(TopExp::LastVertex(FirstEdge,Standard_True)); - if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) { - v2 = theFV; - } - else v2 = TopExp::LastVertex(FirstEdge,Standard_True); - BRepLib_MakeEdge e(cc, v1, v2); - theEdge = TopoDS::Edge(e.Shape()); + const TopoDS_Vertex& v1 = TopExp::FirstVertex(FirstEdge,Standard_True); + TopoDS_Vertex v2; + const gp_Pnt& pp = BRep_Tool:: + Pnt(TopExp::LastVertex(FirstEdge,Standard_True)); + if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) { + v2 = theFV; + } + else v2 = TopExp::LastVertex(FirstEdge,Standard_True); + BRepLib_MakeEdge e(cc, v1, v2); + theEdge = TopoDS::Edge(e.Shape()); } myLFMap(FirstEdge).Append(theEdge); BB.Add(w, theEdge); @@ -2380,13 +2100,13 @@ Standard_Boolean BRepFeat_RibSlot::NoSlidingProfile(TopoDS_Face& Prof, Standard_Real f, l; Handle(Geom_Curve) cc = BRep_Tool::Curve(FirstEdge, f, l); if(!theLastEdge.IsNull()) { - const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True); - const TopoDS_Vertex& v2 = TopExp::LastVertex(FirstEdge,Standard_True); - BRepLib_MakeEdge e(cc, v1, v2); - theEdge = TopoDS::Edge(e.Shape()); + const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True); + const TopoDS_Vertex& v2 = TopExp::LastVertex(FirstEdge,Standard_True); + BRepLib_MakeEdge e(cc, v1, v2); + theEdge = TopoDS::Edge(e.Shape()); } else { - theEdge = FirstEdge; + theEdge = FirstEdge; } myLFMap(FirstEdge).Append(theEdge); BB.Add(w, theEdge); @@ -2398,13 +2118,13 @@ Standard_Boolean BRepFeat_RibSlot::NoSlidingProfile(TopoDS_Face& Prof, Standard_Real f, l; Handle(Geom_Curve) cc = BRep_Tool::Curve(FalseFirstEdge, f, l); if(!theLastEdge.IsNull()) { - const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True); - const TopoDS_Vertex& v2 = TopExp::LastVertex(FalseFirstEdge,Standard_True); - BRepLib_MakeEdge e(cc, v1, v2); - theEdge = TopoDS::Edge(e.Shape()); + const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True); + const TopoDS_Vertex& v2 = TopExp::LastVertex(FalseFirstEdge,Standard_True); + BRepLib_MakeEdge e(cc, v1, v2); + theEdge = TopoDS::Edge(e.Shape()); } else { - theEdge = FalseFirstEdge; + theEdge = FalseFirstEdge; } myLFMap(FirstEdge).Append(theEdge); BB.Add(w, theEdge); @@ -2423,26 +2143,26 @@ Standard_Boolean BRepFeat_RibSlot::NoSlidingProfile(TopoDS_Face& Prof, for(; ex.More(); ex.Next()) { const TopoDS_Edge& E = ex.Current(); if(!E.IsSame(LastEdge)) { - if(!myLFMap.IsBound(E)) { + if(!myLFMap.IsBound(E)) { TopTools_ListOfShape thelist2; - myLFMap.Bind(E, thelist2); - } - TopoDS_Edge eee; - Standard_Real f, l; - Handle(Geom_Curve) cc = BRep_Tool::Curve(E, f, l); - if(!theLastEdge.IsNull()) { - const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True); - const TopoDS_Vertex& v2 = TopExp::LastVertex(E,Standard_True); - BRepLib_MakeEdge e(cc, v1, v2); - eee = TopoDS::Edge(e.Shape()); - } - else { - eee = E; - } - myLFMap(E).Append(eee); - BB.Add(w, eee); - if(theFV.IsNull()) theFV = TopExp::FirstVertex(eee,Standard_True); - theLastEdge = eee; + myLFMap.Bind(E, thelist2); + } + TopoDS_Edge eee; + Standard_Real f, l; + Handle(Geom_Curve) cc = BRep_Tool::Curve(E, f, l); + if(!theLastEdge.IsNull()) { + const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True); + const TopoDS_Vertex& v2 = TopExp::LastVertex(E,Standard_True); + BRepLib_MakeEdge e(cc, v1, v2); + eee = TopoDS::Edge(e.Shape()); + } + else { + eee = E; + } + myLFMap(E).Append(eee); + BB.Add(w, eee); + if(theFV.IsNull()) theFV = TopExp::FirstVertex(eee,Standard_True); + theLastEdge = eee; } else break; } @@ -2450,79 +2170,79 @@ Standard_Boolean BRepFeat_RibSlot::NoSlidingProfile(TopoDS_Face& Prof, if(!OnLastFace) { if(!FirstEdge.IsSame(LastEdge)) { - const TopoDS_Edge& edg = TopoDS::Edge(ex.Current()); - if(!myLFMap.IsBound(edg)) { + const TopoDS_Edge& edg = TopoDS::Edge(ex.Current()); + if(!myLFMap.IsBound(edg)) { TopTools_ListOfShape thelist3; - myLFMap.Bind(edg, thelist3); - } - TopoDS_Edge eee; - Standard_Real f, l; - Handle(Geom_Curve) cc = BRep_Tool::Curve(edg, f, l); - if(!theLastEdge.IsNull()) { - const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True); - TopoDS_Vertex v2; - const gp_Pnt& pp = BRep_Tool:: - Pnt(TopExp::LastVertex(edg,Standard_True)); - if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) { - v2 = theFV; - } - else v2 = TopExp::LastVertex(edg,Standard_True); - BRepLib_MakeEdge e(cc, v1, v2); - eee = TopoDS::Edge(e.Shape()); - } - else { - const TopoDS_Vertex& v1 = TopExp::FirstVertex(edg,Standard_True); - TopoDS_Vertex v2; - const gp_Pnt& pp = BRep_Tool:: - Pnt(TopExp::LastVertex(edg,Standard_True)); - if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) { - v2 = theFV; - } - else v2 = TopExp::LastVertex(edg,Standard_True); - BRepLib_MakeEdge e(cc, v1, v2); - eee = TopoDS::Edge(e.Shape()); - } - myLFMap(edg).Append(eee); - BB.Add(w, eee); - if(theFV.IsNull()) theFV = TopExp::FirstVertex(eee,Standard_True); - theLastEdge = eee; + myLFMap.Bind(edg, thelist3); + } + TopoDS_Edge eee; + Standard_Real f, l; + Handle(Geom_Curve) cc = BRep_Tool::Curve(edg, f, l); + if(!theLastEdge.IsNull()) { + const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True); + TopoDS_Vertex v2; + const gp_Pnt& pp = BRep_Tool:: + Pnt(TopExp::LastVertex(edg,Standard_True)); + if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) { + v2 = theFV; + } + else v2 = TopExp::LastVertex(edg,Standard_True); + BRepLib_MakeEdge e(cc, v1, v2); + eee = TopoDS::Edge(e.Shape()); + } + else { + const TopoDS_Vertex& v1 = TopExp::FirstVertex(edg,Standard_True); + TopoDS_Vertex v2; + const gp_Pnt& pp = BRep_Tool:: + Pnt(TopExp::LastVertex(edg,Standard_True)); + if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) { + v2 = theFV; + } + else v2 = TopExp::LastVertex(edg,Standard_True); + BRepLib_MakeEdge e(cc, v1, v2); + eee = TopoDS::Edge(e.Shape()); + } + myLFMap(edg).Append(eee); + BB.Add(w, eee); + if(theFV.IsNull()) theFV = TopExp::FirstVertex(eee,Standard_True); + theLastEdge = eee; } else { - TopoDS_Edge eee; - Standard_Real f, l; - if(!myLFMap.IsBound(LastEdge)) { + TopoDS_Edge eee; + Standard_Real f, l; + if(!myLFMap.IsBound(LastEdge)) { TopTools_ListOfShape thelist4; - myLFMap.Bind(LastEdge, thelist4); - } - Handle(Geom_Curve) cc = BRep_Tool::Curve(FalseOnlyOne, f, l); - if(!theLastEdge.IsNull()) { - const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True); - TopoDS_Vertex v2; - const gp_Pnt& pp = BRep_Tool:: - Pnt(TopExp::LastVertex(FalseOnlyOne,Standard_True)); - if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) { - v2 = theFV; - } - else v2 = TopExp::LastVertex(FalseOnlyOne,Standard_True); - BRepLib_MakeEdge e(cc, v1, v2); - eee = TopoDS::Edge(e.Shape()); - } - else { - const TopoDS_Vertex& v1 = TopExp::FirstVertex(FalseOnlyOne,Standard_True); - TopoDS_Vertex v2; - const gp_Pnt& pp = BRep_Tool:: - Pnt(TopExp::LastVertex(FalseOnlyOne,Standard_True)); - if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) { - v2 = theFV; - } - else v2 = TopExp::LastVertex(FalseOnlyOne,Standard_True); - BRepLib_MakeEdge e(cc, v1, v2); - eee = TopoDS::Edge(e.Shape()); - } - myLFMap(LastEdge).Append(eee); - BB.Add(w, eee); - if(theFV.IsNull()) theFV = TopExp::FirstVertex(eee,Standard_True); - theLastEdge = eee; + myLFMap.Bind(LastEdge, thelist4); + } + Handle(Geom_Curve) cc = BRep_Tool::Curve(FalseOnlyOne, f, l); + if(!theLastEdge.IsNull()) { + const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True); + TopoDS_Vertex v2; + const gp_Pnt& pp = BRep_Tool:: + Pnt(TopExp::LastVertex(FalseOnlyOne,Standard_True)); + if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) { + v2 = theFV; + } + else v2 = TopExp::LastVertex(FalseOnlyOne,Standard_True); + BRepLib_MakeEdge e(cc, v1, v2); + eee = TopoDS::Edge(e.Shape()); + } + else { + const TopoDS_Vertex& v1 = TopExp::FirstVertex(FalseOnlyOne,Standard_True); + TopoDS_Vertex v2; + const gp_Pnt& pp = BRep_Tool:: + Pnt(TopExp::LastVertex(FalseOnlyOne,Standard_True)); + if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) { + v2 = theFV; + } + else v2 = TopExp::LastVertex(FalseOnlyOne,Standard_True); + BRepLib_MakeEdge e(cc, v1, v2); + eee = TopoDS::Edge(e.Shape()); + } + myLFMap(LastEdge).Append(eee); + BB.Add(w, eee); + if(theFV.IsNull()) theFV = TopExp::FirstVertex(eee,Standard_True); + theLastEdge = eee; } } else { @@ -2530,32 +2250,32 @@ Standard_Boolean BRepFeat_RibSlot::NoSlidingProfile(TopoDS_Face& Prof, Standard_Real f, l; if(!myLFMap.IsBound(LastEdge)) { TopTools_ListOfShape thelist5; - myLFMap.Bind(LastEdge, thelist5); + myLFMap.Bind(LastEdge, thelist5); } Handle(Geom_Curve) cc = BRep_Tool::Curve(FalseLastEdge, f, l); if(!theLastEdge.IsNull()) { - const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True); - TopoDS_Vertex v2; - const gp_Pnt& pp = BRep_Tool:: - Pnt(TopExp::LastVertex(FalseLastEdge,Standard_True)); - if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) { - v2 = theFV; - } - else v2 = TopExp::LastVertex(FalseLastEdge,Standard_True); - BRepLib_MakeEdge e(cc, v1, v2); - eee = TopoDS::Edge(e.Shape()); - } + const TopoDS_Vertex& v1 = TopExp::LastVertex(theLastEdge,Standard_True); + TopoDS_Vertex v2; + const gp_Pnt& pp = BRep_Tool:: + Pnt(TopExp::LastVertex(FalseLastEdge,Standard_True)); + if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) { + v2 = theFV; + } + else v2 = TopExp::LastVertex(FalseLastEdge,Standard_True); + BRepLib_MakeEdge e(cc, v1, v2); + eee = TopoDS::Edge(e.Shape()); + } else { - const TopoDS_Vertex& v1 = TopExp::FirstVertex(FalseLastEdge,Standard_True); - TopoDS_Vertex v2; - const gp_Pnt& pp = BRep_Tool:: - Pnt(TopExp::LastVertex(FalseLastEdge,Standard_True)); - if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) { - v2 = theFV; - } - else v2 = TopExp::LastVertex(FalseLastEdge,Standard_True); - BRepLib_MakeEdge e(cc, v1, v2); - eee = TopoDS::Edge(e.Shape()); + const TopoDS_Vertex& v1 = TopExp::FirstVertex(FalseLastEdge,Standard_True); + TopoDS_Vertex v2; + const gp_Pnt& pp = BRep_Tool:: + Pnt(TopExp::LastVertex(FalseLastEdge,Standard_True)); + if(!theFV.IsNull() && theFirstpoint.Distance(pp) <= myTol) { + v2 = theFV; + } + else v2 = TopExp::LastVertex(FalseLastEdge,Standard_True); + BRepLib_MakeEdge e(cc, v1, v2); + eee = TopoDS::Edge(e.Shape()); } myLFMap(LastEdge).Append(eee); BB.Add(w, eee); @@ -2566,7 +2286,7 @@ Standard_Boolean BRepFeat_RibSlot::NoSlidingProfile(TopoDS_Face& Prof, if(Concavite == 1) { TopoDS_Edge eef; - if(theLastEdge.IsNull()) { + if(theLastEdge.IsNull()) { BRepLib_MakeEdge ef(lastpoint, Pt); eef = TopoDS::Edge(ef.Shape()); } @@ -2575,10 +2295,10 @@ Standard_Boolean BRepFeat_RibSlot::NoSlidingProfile(TopoDS_Face& Prof, BRepLib_MakeVertex vv(Pt); TopoDS_Vertex v2 = TopoDS::Vertex(vv.Shape()); if(!theFV.IsNull() && - Pt.Distance(theFirstpoint) <= myTol) v2 = theFV; + Pt.Distance(theFirstpoint) <= myTol) v2 = theFV; BRepLib_MakeEdge ef(v1, v2); - eef = TopoDS::Edge(ef.Shape()); + eef = TopoDS::Edge(ef.Shape()); } BB.Add(w, eef); if(theFV.IsNull()) theFV = TopExp::FirstVertex(eef,Standard_True); @@ -2646,8 +2366,8 @@ Standard_Boolean BRepFeat_RibSlot::NoSlidingProfile(TopoDS_Face& Prof, //purpose : //======================================================================= void BRepFeat_RibSlot::UpdateDescendants(const BRepAlgoAPI_BooleanOperation& aBOP, - const TopoDS_Shape& S, - const Standard_Boolean SkipFace) + const TopoDS_Shape& S, + const Standard_Boolean SkipFace) { TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itdm; TopTools_ListIteratorOfListOfShape it,it2; @@ -2668,89 +2388,33 @@ Standard_Boolean BRepFeat_RibSlot::NoSlidingProfile(TopoDS_Face& Prof, if(sh.ShapeType() != TopAbs_FACE) continue; const TopoDS_Face& fdsc = TopoDS::Face(it.Value()); for (exp.Init(S,TopAbs_FACE);exp.More();exp.Next()) { - if (exp.Current().IsSame(fdsc)) { // preserved - newdsc.Add(fdsc); - break; - } + if (exp.Current().IsSame(fdsc)) { // preserved + newdsc.Add(fdsc); + break; + } } if (!exp.More()) { - BRepAlgoAPI_BooleanOperation* pBOP=(BRepAlgoAPI_BooleanOperation*)&aBOP; - const TopTools_ListOfShape& aLM=pBOP->Modified(fdsc); - it2.Initialize(aLM); - for (; it2.More(); it2.Next()) { - const TopoDS_Shape& aS=it2.Value(); - newdsc.Add(aS); - } - + BRepAlgoAPI_BooleanOperation* pBOP=(BRepAlgoAPI_BooleanOperation*)&aBOP; + const TopTools_ListOfShape& aLM=pBOP->Modified(fdsc); + it2.Initialize(aLM); + for (; it2.More(); it2.Next()) { + const TopoDS_Shape& aS=it2.Value(); + newdsc.Add(aS); + } + } } myMap.ChangeFind(orig).Clear(); for (itm.Initialize(newdsc); itm.More(); itm.Next()) { // check the belonging to the shape... for (exp.Init(S,TopAbs_FACE);exp.More();exp.Next()) { - if (exp.Current().IsSame(itm.Key())) { -// const TopoDS_Shape& sh = itm.Key(); - myMap.ChangeFind(orig).Append(itm.Key()); - break; - } + if (exp.Current().IsSame(itm.Key())) { +// const TopoDS_Shape& sh = itm.Key(); + myMap.ChangeFind(orig).Append(itm.Key()); + break; + } } } } } //modified by NIZNHY-PKV Thu Mar 21 18:43:36 2002 t - -//======================================================================= -//function : UpdateDescendants -//purpose : -//======================================================================= - void BRepFeat_RibSlot::UpdateDescendants(const Handle(BOP_HistoryCollector)& aBOP, - const TopoDS_Shape& S, - const Standard_Boolean SkipFace) -{ - TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itdm; - TopTools_ListIteratorOfListOfShape it,it2; - TopTools_MapIteratorOfMapOfShape itm; - TopExp_Explorer exp; - - for (itdm.Initialize(myMap);itdm.More();itdm.Next()) { - const TopoDS_Shape& orig = itdm.Key(); - if (SkipFace && orig.ShapeType() == TopAbs_FACE) { - continue; - } - TopTools_MapOfShape newdsc; - - //if (itdm.Value().IsEmpty()) {myMap.ChangeFind(orig).Append(orig);} - - for (it.Initialize(itdm.Value());it.More();it.Next()) { - const TopoDS_Shape& sh = it.Value(); - if(sh.ShapeType() != TopAbs_FACE) continue; - const TopoDS_Face& fdsc = TopoDS::Face(it.Value()); - for (exp.Init(S,TopAbs_FACE);exp.More();exp.Next()) { - if (exp.Current().IsSame(fdsc)) { // preserved - newdsc.Add(fdsc); - break; - } - } - if (!exp.More()) { - const TopTools_ListOfShape& aLM=aBOP->Modified(fdsc); - it2.Initialize(aLM); - for (; it2.More(); it2.Next()) { - const TopoDS_Shape& aS=it2.Value(); - newdsc.Add(aS); - } - - } - } - myMap.ChangeFind(orig).Clear(); - for (itm.Initialize(newdsc); itm.More(); itm.Next()) { - // check the belonging to the shape... - for (exp.Init(S,TopAbs_FACE);exp.More();exp.Next()) { - if (exp.Current().IsSame(itm.Key())) { -// const TopoDS_Shape& sh = itm.Key(); - myMap.ChangeFind(orig).Append(itm.Key()); - break; - } - } - } - } -} diff --git a/src/BRepFill/BRepFill_TrimShellCorner.cxx b/src/BRepFill/BRepFill_TrimShellCorner.cxx index 6ae40d8c58..3f9749c52b 100755 --- a/src/BRepFill/BRepFill_TrimShellCorner.cxx +++ b/src/BRepFill/BRepFill_TrimShellCorner.cxx @@ -33,29 +33,6 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include #include #include @@ -68,6 +45,8 @@ #include #include #include +#include +#include #include #include @@ -84,149 +63,152 @@ #include #include +#include +#include +#include +#include + +#include +#include + static Standard_Boolean IsFromFirstToSecond(const TopoDS_Edge& theEdge, - const Standard_Real theParameterOnUEdge, - const TopoDS_Edge& theUEdge1, - const TopoDS_Edge& theUEdge2, - const TopoDS_Face& theFace); - -static Standard_Boolean FindParameter(const BOPTools_PaveSet& thePaveSet, - const BooleanOperations_KindOfInterference& theType, - const Standard_Integer theInterfIndex, - Standard_Real& theParam); - -static Standard_Boolean FindCommonVertex(const BOPTools_DSFiller& theDSFiller, - const Standard_Integer theEIndex1, - const Standard_Integer theEIndex2, - TopoDS_Vertex& theCommonVertex, - Standard_Real& theParamOnE1, - Standard_Real& theParamOnE2); + const Standard_Real theParameterOnUEdge, + const TopoDS_Edge& theUEdge1, + const TopoDS_Edge& theUEdge2, + const TopoDS_Face& theFace); + +static Standard_Boolean FindCommonVertex(const BOPDS_PDS& theDS, + const Standard_Integer theEIndex1, + const Standard_Integer theEIndex2, + TopoDS_Vertex& theCommonVertex, + Standard_Real& theParamOnE1, + Standard_Real& theParamOnE2); static Standard_Boolean MakeFacesNonSec(const Standard_Integer theIndex, - const Handle(TopTools_HArray2OfShape)& theUEdges, - const Handle(TopTools_HArray2OfShape)& theBounds, - const BOPTools_DSFiller& theDSFiller, - const Standard_Integer theFaceIndex1, - const Standard_Integer theFaceIndex2, - TopTools_DataMapOfShapeListOfShape& theHistMap); + const Handle(TopTools_HArray2OfShape)& theUEdges, + const Handle(TopTools_HArray2OfShape)& theBounds, + const BOPDS_PDS& theDS, + const Standard_Integer theFaceIndex1, + const Standard_Integer theFaceIndex2, + TopTools_DataMapOfShapeListOfShape& theHistMap); static Standard_Boolean MakeFacesSec(const Standard_Integer theIndex, - const Handle(TopTools_HArray2OfShape)& theUEdges, - const Handle(TopTools_HArray2OfShape)& theBounds, - const BOPTools_DSFiller& theDSFiller, - const Standard_Integer theFaceIndex1, - const Standard_Integer theFaceIndex2, - const Standard_Integer theSSInterfIndex, - const gp_Ax2& AxeOfBisPlane, - TopTools_DataMapOfShapeListOfShape& theHistMap); + const Handle(TopTools_HArray2OfShape)& theUEdges, + const Handle(TopTools_HArray2OfShape)& theBounds, + const BOPDS_PDS& theDS, + const Standard_Integer theFaceIndex1, + const Standard_Integer theFaceIndex2, + const Standard_Integer theSSInterfIndex, + const gp_Ax2& AxeOfBisPlane, + TopTools_DataMapOfShapeListOfShape& theHistMap); static Standard_Boolean SplitUEdges(const Handle(TopTools_HArray2OfShape)& theUEdges, - const BOPTools_DSFiller& theDSFiller, - TopTools_DataMapOfShapeListOfShape& theHistMap); + const BOPDS_PDS& theDS, + TopTools_DataMapOfShapeListOfShape& theHistMap); static void FindFreeVertices(const TopoDS_Shape& theShape, - const TopTools_MapOfShape& theVerticesToAvoid, - TopTools_ListOfShape& theListOfVertex); + const TopTools_MapOfShape& theVerticesToAvoid, + TopTools_ListOfShape& theListOfVertex); static Standard_Boolean CheckAndOrientEdges(const TopTools_ListOfShape& theOrderedList, - const gp_Pnt2d& theFirstPoint, - const gp_Pnt2d& theLastPoint, - const TopoDS_Face& theFace, - TopTools_ListOfShape& theOrientedList); + const gp_Pnt2d& theFirstPoint, + const gp_Pnt2d& theLastPoint, + const TopoDS_Face& theFace, + TopTools_ListOfShape& theOrientedList); static Standard_Boolean FillGap(const TopoDS_Vertex& theFirstVertex, - const TopoDS_Vertex& theLastVertex, - const gp_Pnt2d& theFirstPoint, - const gp_Pnt2d& theLastPoint, - const TopoDS_Face& theFace, - const TopoDS_Compound& theSectionEdges, - TopTools_ListOfShape& theOrderedList); + const TopoDS_Vertex& theLastVertex, + const gp_Pnt2d& theFirstPoint, + const gp_Pnt2d& theLastPoint, + const TopoDS_Face& theFace, + const TopoDS_Compound& theSectionEdges, + TopTools_ListOfShape& theOrderedList); static Standard_Boolean FindNextEdge(const TopoDS_Vertex& theFirstVertex, - const TopoDS_Vertex& theLastVertex, - const TopTools_IndexedDataMapOfShapeListOfShape& theMapVE, - const TopTools_MapOfShape& theMapToAvoid, - TopTools_ListOfShape& theOrderedList); + const TopoDS_Vertex& theLastVertex, + const TopTools_IndexedDataMapOfShapeListOfShape& theMapVE, + const TopTools_MapOfShape& theMapToAvoid, + TopTools_ListOfShape& theOrderedList); static Standard_Boolean FindVertex(const TopoDS_Edge& theEdge, - const Standard_Integer theRank, - const BOPTools_DSFiller& theDSFiller, - const TopTools_DataMapOfShapeListOfShape& theHistMap, - TopoDS_Vertex& theVertex, - BOPTools_Pave& thePave); + const Standard_Integer theRank, + const BOPDS_PDS& theDS, + const TopTools_DataMapOfShapeListOfShape& theHistMap, + TopoDS_Vertex& theVertex, + BOPDS_Pave& thePave); static Standard_Boolean FindNextVertex(const Standard_Integer theEdgeIndex, - const BOPTools_Pave& thePrevPave, - const BOPTools_DSFiller& theDSFiller, - TopoDS_Vertex& theNextVertex, - BOPTools_Pave& thePave); + const BOPDS_Pave& thePrevPave, + const BOPDS_PDS& theDS, + TopoDS_Vertex& theNextVertex, + BOPDS_Pave& thePave); -static Standard_Boolean GetPave(const Standard_Integer theEdgeIndex, - const Standard_Boolean isFirst, - const BOPTools_DSFiller& theDSFiller, - BOPTools_Pave& thePave); +static Standard_Boolean GetPave(const Standard_Integer theEdgeIndex, + const Standard_Boolean isFirst, + const BOPDS_PDS& theDS, + BOPDS_Pave& thePave); static Standard_Boolean FindFromUEdge(const TopoDS_Edge& theUE1Old, - const TopoDS_Edge& theUE2Old, - const TopoDS_Edge& theUE1New, - const TopoDS_Edge& theUE2New, - const TopoDS_Face& theFace, - const TopoDS_Compound& theSecEdges, - const Standard_Integer theRank, - const TopoDS_Edge& theBoundEdge, - const Standard_Integer theBoundEdgeIndex, - const BOPTools_DSFiller& theDSFiller, - const TopTools_DataMapOfShapeListOfShape& theHistMap, - TopoDS_Compound& theSecEdgesNew, - TopTools_ListOfShape& theListOfWireEdges, - BOPTools_Pave& theFoundPave, - Standard_Boolean& isOnUEdge); - -static Standard_Boolean FindFromVEdge(const BOPTools_Pave& thePrevPave, - const Standard_Boolean& isOnUEdge, - const TopoDS_Edge& theUE1Old, - const TopoDS_Edge& theUE2Old, - const TopoDS_Face& theFace, - const TopoDS_Compound& theSecEdges, - const Standard_Integer theRank, - const TopoDS_Edge& theBoundEdge, - const Standard_Integer theBoundEdgeIndex, - const BOPTools_DSFiller& theDSFiller, - const TopTools_DataMapOfShapeListOfShape& theHistMap, - TopTools_ListOfShape& theListOfWireEdges, - Standard_Boolean& isSectionFound); + const TopoDS_Edge& theUE2Old, + const TopoDS_Edge& theUE1New, + const TopoDS_Edge& theUE2New, + const TopoDS_Face& theFace, + const TopoDS_Compound& theSecEdges, + const Standard_Integer theRank, + const TopoDS_Edge& theBoundEdge, + const Standard_Integer theBoundEdgeIndex, + const BOPDS_PDS& theDS, + const TopTools_DataMapOfShapeListOfShape& theHistMap, + TopoDS_Compound& theSecEdgesNew, + TopTools_ListOfShape& theListOfWireEdges, + BOPDS_Pave& theFoundPave, + Standard_Boolean& isOnUEdge); + +static Standard_Boolean FindFromVEdge(const BOPDS_Pave& thePrevPave, + const Standard_Boolean& isOnUEdge, + const TopoDS_Edge& theUE1Old, + const TopoDS_Edge& theUE2Old, + const TopoDS_Face& theFace, + const TopoDS_Compound& theSecEdges, + const Standard_Integer theRank, + const TopoDS_Edge& theBoundEdge, + const Standard_Integer theBoundEdgeIndex, + const BOPDS_PDS& theDS, + const TopTools_DataMapOfShapeListOfShape& theHistMap, + TopTools_ListOfShape& theListOfWireEdges, + Standard_Boolean& isSectionFound); static void RemoveEdges(const TopoDS_Compound& theSourceComp, - const TopTools_ListOfShape& theListToRemove, - TopoDS_Compound& theResultComp); + const TopTools_ListOfShape& theListToRemove, + TopoDS_Compound& theResultComp); -static Standard_Boolean FilterSectionEdges(const BOPTools_SequenceOfCurves& theBCurves, - const TopoDS_Face& theSecPlane, - const BOPTools_DSFiller& theDSFiller, - TopoDS_Compound& theResult); +static Standard_Boolean FilterSectionEdges(const BOPDS_VectorOfCurve& theBCurves, + const TopoDS_Face& theSecPlane, + const BOPDS_PDS& theDS, + TopoDS_Compound& theResult); static Standard_Boolean GetUEdges(const Standard_Integer theIndex, - const Standard_Integer theRank, - const Handle(TopTools_HArray2OfShape)& theUEdges, - const TopoDS_Edge& theBoundEdge, - const TopoDS_Face& theFace, - TopoDS_Edge& theFirstUEdge, - TopoDS_Edge& theSecondUEdge); + const Standard_Integer theRank, + const Handle(TopTools_HArray2OfShape)& theUEdges, + const TopoDS_Edge& theBoundEdge, + const TopoDS_Face& theFace, + TopoDS_Edge& theFirstUEdge, + TopoDS_Edge& theSecondUEdge); static Standard_Real ComputeAveragePlaneAndMaxDeviation(const TopoDS_Shape& aWire, - gp_Pln& thePlane, - Standard_Boolean& IsSingular); + gp_Pln& thePlane, + Standard_Boolean& IsSingular); static Standard_Boolean ChooseSection(const TopoDS_Shape& Comp, - const gp_Ax2& bis, - TopoDS_Shape& resWire, - gp_Pln& resPlane, - Standard_Boolean& IsSingular); + const gp_Ax2& bis, + TopoDS_Shape& resWire, + gp_Pln& resPlane, + Standard_Boolean& IsSingular); static Standard_Boolean ChoosePlane(const TopoDS_Shape& Comp, - const gp_Ax2& bis, - gp_Pln& resPlane, - TopoDS_Compound& NewComp); + const gp_Ax2& bis, + gp_Pln& resPlane, + TopoDS_Compound& NewComp); // =========================================================================================== @@ -234,14 +216,14 @@ static Standard_Boolean ChoosePlane(const TopoDS_Shape& Comp, // purpose: // =========================================================================================== BRepFill_TrimShellCorner::BRepFill_TrimShellCorner(const Handle(TopTools_HArray2OfShape)& theFaces, - const gp_Ax2& theAxeOfBisPlane, - const TopoDS_Face& theSecPlane) : + const gp_Ax2& theAxeOfBisPlane, + const TopoDS_Face& theSecPlane) : myAxeOfBisPlane(theAxeOfBisPlane), myDone(Standard_False), myHasSection(Standard_False) { myFaces = new TopTools_HArray2OfShape(theFaces->LowerRow(), theFaces->UpperRow(), - theFaces->LowerCol(), theFaces->UpperCol()); + theFaces->LowerCol(), theFaces->UpperCol()); myFaces->ChangeArray2() = theFaces->Array2(); mySecPln = theSecPlane; } @@ -251,15 +233,15 @@ myHasSection(Standard_False) // purpose: // =========================================================================================== BRepFill_TrimShellCorner::BRepFill_TrimShellCorner(const Handle(TopTools_HArray2OfShape)& theFaces, - const gp_Ax2& theAxeOfBisPlane, - const TopoDS_Wire& theSpine, - const TopoDS_Face& theSecPlane): + const gp_Ax2& theAxeOfBisPlane, + const TopoDS_Wire& theSpine, + const TopoDS_Face& theSecPlane): myAxeOfBisPlane(theAxeOfBisPlane), myDone(Standard_False), myHasSection(Standard_False) { myFaces = new TopTools_HArray2OfShape(theFaces->LowerRow(), theFaces->UpperRow(), - theFaces->LowerCol(), theFaces->UpperCol()); + theFaces->LowerCol(), theFaces->UpperCol()); myFaces->ChangeArray2() = theFaces->Array2(); mySpine = theSpine; mySecPln = theSecPlane; @@ -281,7 +263,7 @@ void BRepFill_TrimShellCorner::SetSpine(const TopoDS_Wire& theSpine) void BRepFill_TrimShellCorner::AddBounds(const Handle(TopTools_HArray2OfShape)& theBounds) { myBounds = new TopTools_HArray2OfShape(theBounds->LowerRow(), theBounds->UpperRow(), - theBounds->LowerCol(), theBounds->UpperCol()); + theBounds->LowerCol(), theBounds->UpperCol()); myBounds->ChangeArray2() = theBounds->Array2(); } @@ -292,7 +274,7 @@ void BRepFill_TrimShellCorner::AddBounds(const Handle(TopTools_HArray2OfShape)& void BRepFill_TrimShellCorner::AddUEdges(const Handle(TopTools_HArray2OfShape)& theUEdges) { myUEdges = new TopTools_HArray2OfShape(theUEdges->LowerRow(), theUEdges->UpperRow(), - theUEdges->LowerCol(), theUEdges->UpperCol()); + theUEdges->LowerCol(), theUEdges->UpperCol()); myUEdges->ChangeArray2() = theUEdges->Array2(); } @@ -302,6 +284,9 @@ void BRepFill_TrimShellCorner::AddUEdges(const Handle(TopTools_HArray2OfShape)& // =========================================================================================== void BRepFill_TrimShellCorner::Perform() { + Standard_Integer anIndex1, anIndex2, nF1, nF2, i, j, aNbP, aNbC; + Standard_Boolean bhassec; + myDone = Standard_False; myHistMap.Clear(); @@ -325,82 +310,83 @@ void BRepFill_TrimShellCorner::Perform() myShape2 = aShell; } } - - BOPTools_DSFiller aDSFiller; - aDSFiller.SetShapes(myShape1, myShape2); - - if (!aDSFiller.IsDone()) { + + BOPAlgo_PaveFiller aPF; + BOPCol_ListOfShape aLS; + aLS.Append(myShape1); + aLS.Append(myShape2); + aPF.SetArguments(aLS); + // + aPF.Perform(); + if (aPF.ErrorStatus()) { return; } - aDSFiller.Perform(); - - BRepAlgoAPI_Section aSectionAlgo(myShape1, myShape2, aDSFiller, Standard_False); - aSectionAlgo.ComputePCurveOn1(Standard_True); - aSectionAlgo.ComputePCurveOn2(Standard_True); - aSectionAlgo.Approximation(Standard_True); - aSectionAlgo.Build(); - - if(!aSectionAlgo.IsDone()) - return; - - const BooleanOperations_ShapesDataStructure& aDS = aDSFiller.DS(); - const BOPTools_InterferencePool& anInterfPool = aDSFiller.InterfPool(); - BOPTools_InterferencePool* pInterfPool = - (BOPTools_InterferencePool*) &anInterfPool; - BOPTools_CArray1OfSSInterference& aFFs = - pInterfPool->SSInterferences(); + // + const BOPDS_PDS& theDS = aPF.PDS(); + // + BOPDS_VectorOfInterfFF& aFFs = theDS->InterfFF(); Standard_Integer aNbFFs = aFFs.Extent(); - if(!SplitUEdges(myUEdges, aDSFiller, myHistMap)) { + if(!SplitUEdges(myUEdges, theDS, myHistMap)) { return; } for(ii = myFaces->LowerRow(); ii <= myFaces->UpperRow(); ii++) { TopoDS_Shape aF1 = myFaces->Value(ii, myFaces->LowerCol()); TopoDS_Shape aF2 = myFaces->Value(ii, myFaces->UpperCol()); - Standard_Integer anIndex1 = aDS.ShapeIndex(aF1, 1); - Standard_Integer anIndex2 = aDS.ShapeIndex(aF2, 2); - - if((anIndex1 == 0) || (anIndex2 == 0)) + // + anIndex1 = theDS->Index(aF1); + anIndex2 = theDS->Index(aF2); + + if((anIndex1 == -1) || (anIndex2 == -1)) continue; - Standard_Integer i = 0; - - for (i=1; i <= aNbFFs; i++) { - BOPTools_SSInterference& aFFi=aFFs(i); + + for (i=0; i < aNbFFs; ++i) { + BOPDS_InterfFF& aFFi = aFFs(i); + aFFi.Indices(nF1, nF2); + // + BOPDS_VectorOfPoint& aVP=aFFi.ChangePoints(); + aNbP=aVP.Extent(); + BOPDS_VectorOfCurve& aVC=aFFi.ChangeCurves(); + aNbC=aVC.Extent(); + if (!aNbP && !aNbC) { + BOPCol_DataMapOfIntegerListOfInteger aMInterfs; + BOPCol_MapOfInteger aMVStick; + Standard_Integer iFlag = 1+2+4+8+16; + aPF.GetInterfs(nF1, nF2, aMVStick, aMInterfs, iFlag); + if (!aMVStick.Extent()) { + continue; + } + } // - Standard_Integer nF1 = aFFi.Index1(); - Standard_Integer nF2 = aFFi.Index2(); - if((nF1 == anIndex1) && (nF2 == anIndex2)) { - BOPTools_SequenceOfCurves& aBCurves = aFFi.Curves(); - Standard_Integer aNbCurves = aBCurves.Length(); - Standard_Integer j = 0; - Standard_Boolean bhassec = Standard_False; - - for (j = 1; j <= aNbCurves; j++) { - const BOPTools_Curve& aBCurve = aBCurves(j); - const BOPTools_ListOfPaveBlock& aSectEdges = aBCurve.NewPaveBlocks(); - - if(!aSectEdges.IsEmpty()) { - bhassec = Standard_True; - break; - } - } - - if(!bhassec) { - if(!MakeFacesNonSec(ii, myUEdges, myBounds, aDSFiller, anIndex1, anIndex2, myHistMap)) { - myHistMap.Clear(); - return; - } - } - else { - if(!MakeFacesSec(ii, myUEdges, myBounds, aDSFiller, anIndex1, anIndex2, - i, myAxeOfBisPlane, myHistMap)) { - myHistMap.Clear(); - return; - } - } - break; + const BOPDS_VectorOfCurve& aVC = aFFi.Curves(); + bhassec = Standard_False; + // + for (j = 0; j < aNbC; ++j) { + const BOPDS_Curve& aBCurve = aVC(j); + const BOPDS_ListOfPaveBlock& aSectEdges = aBCurve.PaveBlocks(); + // + if (aSectEdges.Extent()) { + bhassec = Standard_True; + break; + } + } + + if(!bhassec) { + if(!MakeFacesNonSec(ii, myUEdges, myBounds, theDS, anIndex1, anIndex2, myHistMap)) { + myHistMap.Clear(); + return; + } + } + else { + if(!MakeFacesSec(ii, myUEdges, myBounds, theDS, anIndex1, anIndex2, + i, myAxeOfBisPlane, myHistMap)) { + myHistMap.Clear(); + return; + } + } + break; } } } @@ -430,7 +416,7 @@ Standard_Boolean BRepFill_TrimShellCorner::HasSection() const // purpose: // =========================================================================================== void BRepFill_TrimShellCorner::Modified(const TopoDS_Shape& theShape, - TopTools_ListOfShape& theModified) + TopTools_ListOfShape& theModified) { theModified.Clear(); @@ -444,22 +430,15 @@ void BRepFill_TrimShellCorner::Modified(const TopoDS_Shape& theShape, // purpose: // ---------------------------------------------------------------------------------------------------- Standard_Boolean MakeFacesNonSec(const Standard_Integer theIndex, - const Handle(TopTools_HArray2OfShape)& theUEdges, - const Handle(TopTools_HArray2OfShape)& theBounds, - const BOPTools_DSFiller& theDSFiller, - const Standard_Integer theFaceIndex1, - const Standard_Integer theFaceIndex2, - TopTools_DataMapOfShapeListOfShape& theHistMap) + const Handle(TopTools_HArray2OfShape)& theUEdges, + const Handle(TopTools_HArray2OfShape)& theBounds, + const BOPDS_PDS& theDS, + const Standard_Integer theFaceIndex1, + const Standard_Integer theFaceIndex2, + TopTools_DataMapOfShapeListOfShape& theHistMap) { - Standard_Boolean bHasNewEdge = Standard_False; TopoDS_Edge aNewEdge; - const BooleanOperations_ShapesDataStructure& aDS = theDSFiller.DS(); - const BOPTools_PaveFiller& aPaveFiller = theDSFiller.PaveFiller(); -// BOPTools_DSFiller& aDSFiller = (*((BOPTools_DSFiller*)&theDSFiller)); -// BOPTools_InterferencePool* pIntrPool = (BOPTools_InterferencePool*)&aDSFiller.InterfPool(); -// const BOPTools_CArray1OfEEInterference& aEEs = pIntrPool->EEInterfs(); - const BOPTools_PavePool& aPavePool = aPaveFiller.PavePool(); BRep_Builder aBB; const TopoDS_Shape& aE1 = theBounds->Value(theIndex, 1); @@ -467,12 +446,12 @@ Standard_Boolean MakeFacesNonSec(const Standard_Integer theI // search common vertex between bounds. begin TopoDS_Vertex aCommonVertex; - Standard_Integer anIndex1 = aDS.ShapeIndex(aE1, 1); - Standard_Integer anIndex2 = aDS.ShapeIndex(aE2, 2); + Standard_Integer anIndex1 = theDS->Index(aE1); + Standard_Integer anIndex2 = theDS->Index(aE2); Standard_Real apar1 = 0., apar2 = 0.; Standard_Boolean bvertexfound = - FindCommonVertex(theDSFiller, anIndex1, anIndex2, aCommonVertex, apar1, apar2); + FindCommonVertex(theDS, anIndex1, anIndex2, aCommonVertex, apar1, apar2); // search common vertex between bounds. end Handle(BRepTools_ReShape) aSubstitutor = new BRepTools_ReShape(); @@ -492,14 +471,14 @@ Standard_Boolean MakeFacesNonSec(const Standard_Integer theI const TopTools_ListOfShape& lst = theHistMap.Find(aShape1); if(!lst.IsEmpty()) - aUE1 = TopoDS::Edge(lst.First()); + aUE1 = TopoDS::Edge(lst.First()); } if(theHistMap.IsBound(aShape2)) { const TopTools_ListOfShape& lst = theHistMap.Find(aShape2); if(!lst.IsEmpty()) - aUE2 = TopoDS::Edge(lst.First()); + aUE2 = TopoDS::Edge(lst.First()); } if(!aShape1.IsSame(aUE1)) @@ -532,7 +511,7 @@ Standard_Boolean MakeFacesNonSec(const Standard_Integer theI if(aCommonVertices.Extent() == 2) { aNewEdge = BRepLib_MakeEdge(TopoDS::Vertex(aCommonVertices.First()), - TopoDS::Vertex(aCommonVertices.Last())); + TopoDS::Vertex(aCommonVertices.Last())); bHasNewEdge = Standard_True; } Standard_Integer fit = 0; @@ -547,10 +526,10 @@ Standard_Boolean MakeFacesNonSec(const Standard_Integer theI TopoDS_Shape aUE = aShape; if(theHistMap.IsBound(aShape)) { - const TopTools_ListOfShape& lst = theHistMap.Find(aShape); + const TopTools_ListOfShape& lst = theHistMap.Find(aShape); - if(!lst.IsEmpty()) - aUE = TopoDS::Edge(lst.First()); + if(!lst.IsEmpty()) + aUE = TopoDS::Edge(lst.First()); } const TopoDS_Shape& aV = (fit == 1) ? TopExp::FirstVertex(TopoDS::Edge(aUE)) : TopExp::LastVertex(TopoDS::Edge(aUE)); aMapV.Add(aV); @@ -566,7 +545,7 @@ Standard_Boolean MakeFacesNonSec(const Standard_Integer theI return Standard_False; Standard_Integer aFaceIndex = (fit == 1) ? theFaceIndex1 : theFaceIndex2; - TopoDS_Shape aFace = aDS.Shape(aFaceIndex); + TopoDS_Shape aFace = theDS->Shape(aFaceIndex); TopAbs_Orientation aFaceOri = aFace.Orientation(); TopAbs_Orientation anEdgeOri = TopAbs_FORWARD; aFace.Orientation(TopAbs_FORWARD); @@ -576,7 +555,7 @@ Standard_Boolean MakeFacesNonSec(const Standard_Integer theI for(; anExpE.More(); anExpE.Next()) { if(aCheckEdge.IsSame(anExpE.Current())) - anEdgeOri = anExpE.Current().Orientation(); + anEdgeOri = anExpE.Current().Orientation(); } if(bHasNewEdge) { @@ -587,84 +566,87 @@ Standard_Boolean MakeFacesNonSec(const Standard_Integer theI if(!alonevertices.IsEmpty()) { Standard_Integer anEIndex = (fit == 1) ? anIndex1 : anIndex2; - const BOPTools_PaveSet& aPaveSet = aPavePool(aDS.RefEdge(anEIndex)); - BOPTools_ListIteratorOfListOfPave anPIt(aPaveSet.Set()); Standard_Boolean bfound1 = Standard_False; Standard_Boolean bfound2 = Standard_False; Standard_Real aparam1 = 0., aparam2 = 0.; - for(; anPIt.More(); anPIt.Next()) { - const BOPTools_Pave& aPave = anPIt.Value(); - TopoDS_Shape aV = aDS.Shape(aPave.Index()); - - if(aV.IsSame(alonevertices.First())) { - if(!bfound1) { - aparam1 = aPave.Param(); - bfound1 = Standard_True; - } - } - - if(aV.IsSame(alonevertices.Last())) { - if(!bfound2) { - aparam2 = aPave.Param(); - bfound2 = Standard_True; - } - } + BOPDS_ListOfPave aLP; + theDS->Paves(anEIndex, aLP); + BOPDS_ListIteratorOfListOfPave aIt; + Standard_Integer pit; + aIt.Initialize(aLP); + for ( ; aIt.More(); aIt.Next()) { + const BOPDS_Pave& aPave = aIt.Value(); + TopoDS_Shape aV = theDS->Shape(aPave.Index()); + + if(aV.IsSame(alonevertices.First())) { + if(!bfound1) { + aparam1 = aPave.Parameter(); + bfound1 = Standard_True; + } + } + + if(aV.IsSame(alonevertices.Last())) { + if(!bfound2) { + aparam2 = aPave.Parameter(); + bfound2 = Standard_True; + } + } } if(bfound1 && bfound2) { - TopoDS_Edge aNewBoundE; - - if(fit == 1) { - aNewBoundE = TopoDS::Edge(aE1.EmptyCopied()); - } - else { - aNewBoundE = TopoDS::Edge(aE2.EmptyCopied()); - } - TopoDS_Vertex aV1, aV2; - - if(aparam1 < aparam2) { - aV1 = TopoDS::Vertex(alonevertices.First()); - aV2 = TopoDS::Vertex(alonevertices.Last()); - } - else { - aV1 = TopoDS::Vertex(alonevertices.Last()); - aV2 = TopoDS::Vertex(alonevertices.First()); - Standard_Real tmp = aparam1; - aparam1 = aparam2; - aparam2 = tmp; - } - aV1.Orientation(TopAbs_FORWARD); - aV2.Orientation(TopAbs_REVERSED); - aBB.Add(aNewBoundE, aV1); - aBB.Add(aNewBoundE, aV2); - aBB.Range(aNewBoundE, aparam1, aparam2); - aNewBoundE.Orientation(TopAbs_FORWARD); - - aOrderedList.Append(aNewBoundE); - - if(bHasNewEdge) { - TopExp_Explorer anExpV(aNewEdge, TopAbs_VERTEX); - Standard_Boolean bfoundv = Standard_False; - - for(; !bfoundv && anExpV.More(); anExpV.Next()) { - if(aV2.IsSame(anExpV.Current())) - bfoundv = Standard_True; - } - - if(bfoundv) - aOrderedList.Append(aNewEdge); - else - aOrderedList.Prepend(aNewEdge); - } + TopoDS_Edge aNewBoundE; + + if(fit == 1) { + aNewBoundE = TopoDS::Edge(aE1.EmptyCopied()); + } + else { + aNewBoundE = TopoDS::Edge(aE2.EmptyCopied()); + } + TopoDS_Vertex aV1, aV2; + + if(aparam1 < aparam2) { + aV1 = TopoDS::Vertex(alonevertices.First()); + aV2 = TopoDS::Vertex(alonevertices.Last()); + } + else { + aV1 = TopoDS::Vertex(alonevertices.Last()); + aV2 = TopoDS::Vertex(alonevertices.First()); + Standard_Real tmp = aparam1; + aparam1 = aparam2; + aparam2 = tmp; + } + aV1.Orientation(TopAbs_FORWARD); + aV2.Orientation(TopAbs_REVERSED); + aBB.Add(aNewBoundE, aV1); + aBB.Add(aNewBoundE, aV2); + aBB.Range(aNewBoundE, aparam1, aparam2); + aNewBoundE.Orientation(TopAbs_FORWARD); + + aOrderedList.Append(aNewBoundE); + + if(bHasNewEdge) { + TopExp_Explorer anExpV(aNewEdge, TopAbs_VERTEX); + Standard_Boolean bfoundv = Standard_False; + + for(; !bfoundv && anExpV.More(); anExpV.Next()) { + if(aV2.IsSame(anExpV.Current())) + bfoundv = Standard_True; + } + + if(bfoundv) + aOrderedList.Append(aNewEdge); + else + aOrderedList.Prepend(aNewEdge); + } } else { - return Standard_False; + return Standard_False; } } else { if(bHasNewEdge) { - aOrderedList.Append(aNewEdge); + aOrderedList.Append(aNewEdge); } } @@ -674,12 +656,12 @@ Standard_Boolean MakeFacesNonSec(const Standard_Integer theI TopTools_ListIteratorOfListOfShape anItE(aOrderedList); for(; anItE.More(); anItE.Next()) { - aBB.Add(aW, anItE.Value()); + aBB.Add(aW, anItE.Value()); } if(fit == 1) - aSubstitutor->Replace(aE1.Oriented(TopAbs_FORWARD), aW); + aSubstitutor->Replace(aE1.Oriented(TopAbs_FORWARD), aW); else - aSubstitutor->Replace(aE2.Oriented(TopAbs_FORWARD), aW); + aSubstitutor->Replace(aE2.Oriented(TopAbs_FORWARD), aW); } aSubstitutor->Apply(aFace); @@ -695,15 +677,15 @@ Standard_Boolean MakeFacesNonSec(const Standard_Integer theI TopoDS_Shape aNewValue = aSubstitutor->Value(anExpE.Current()); if(aNewValue.IsNull() || aNewValue.IsSame(anExpE.Current())) - continue; + continue; if(theHistMap.IsBound(anExpE.Current())) - continue; + continue; TopTools_ListOfShape aListOfNewEdge; TopExp_Explorer anExpE2(aNewValue, TopAbs_EDGE); for(; anExpE2.More(); anExpE2.Next()) { - aListOfNewEdge.Append(anExpE2.Current()); + aListOfNewEdge.Append(anExpE2.Current()); } theHistMap.Bind(anExpE.Current(), aListOfNewEdge); } @@ -717,29 +699,23 @@ Standard_Boolean MakeFacesNonSec(const Standard_Integer theI // purpose: // ---------------------------------------------------------------------------------------------------- Standard_Boolean MakeFacesSec(const Standard_Integer theIndex, - const Handle(TopTools_HArray2OfShape)& theUEdges, - const Handle(TopTools_HArray2OfShape)& theBounds, - const BOPTools_DSFiller& theDSFiller, - const Standard_Integer theFaceIndex1, - const Standard_Integer theFaceIndex2, - const Standard_Integer theSSInterfIndex, - const gp_Ax2& AxeOfBisPlane, - TopTools_DataMapOfShapeListOfShape& theHistMap) + const Handle(TopTools_HArray2OfShape)& theUEdges, + const Handle(TopTools_HArray2OfShape)& theBounds, + const BOPDS_PDS& theDS, + const Standard_Integer theFaceIndex1, + const Standard_Integer theFaceIndex2, + const Standard_Integer theSSInterfIndex, + const gp_Ax2& AxeOfBisPlane, + TopTools_DataMapOfShapeListOfShape& theHistMap) { - const BooleanOperations_ShapesDataStructure& aDS = theDSFiller.DS(); -// const BOPTools_PaveFiller& aPaveFiller = theDSFiller.PaveFiller(); - BOPTools_DSFiller& aDSFiller = (*((BOPTools_DSFiller*)&theDSFiller)); - BOPTools_InterferencePool* pIntrPool = (BOPTools_InterferencePool*)&aDSFiller.InterfPool(); - BOPTools_CArray1OfSSInterference& aFFs = pIntrPool->SSInterferences(); -// const BOPTools_PavePool& aPavePool = aPaveFiller.PavePool(); -// const BOPTools_SplitShapesPool& aSplitShapesPool = aPaveFiller.SplitShapesPool(); - + const BOPDS_VectorOfInterfFF& aFFs = theDS->InterfFF(); + const BOPDS_InterfFF& aFFi = aFFs(theSSInterfIndex); + const BOPDS_VectorOfCurve& aBCurves = aFFi.Curves(); + TopoDS_Compound aSecEdges; - BOPTools_SSInterference& aFFi = aFFs(theSSInterfIndex); - BOPTools_SequenceOfCurves& aBCurves = aFFi.Curves(); TopoDS_Face aSecPlane; - if(!FilterSectionEdges(aBCurves, aSecPlane, theDSFiller, aSecEdges)) + if(!FilterSectionEdges(aBCurves, aSecPlane, theDS, aSecEdges)) return Standard_False; TopoDS_Shape SecWire; @@ -764,14 +740,14 @@ Standard_Boolean MakeFacesSec(const Standard_Integer theInde Standard_Integer fit = 0; //, ueit = 0, eindex = 0, i = 0; Handle(BRepTools_ReShape) aSubstitutor = new BRepTools_ReShape(); - for(fit = 1; fit <= 2; fit++) { - Standard_Integer aFaceIndex = (fit == 1) ? theFaceIndex1 : theFaceIndex2; - TopoDS_Face aFace = TopoDS::Face(aDS.Shape(aFaceIndex)); + for(fit = 0; fit < 2; fit++) { + Standard_Integer aFaceIndex = (fit == 0) ? theFaceIndex1 : theFaceIndex2; + TopoDS_Face aFace = TopoDS::Face(theDS->Shape(aFaceIndex)); TopAbs_Orientation aFaceOri = aFace.Orientation(); TopoDS_Face aFaceF = aFace; aFaceF.Orientation(TopAbs_FORWARD); - TopoDS_Edge aBoundEdge = TopoDS::Edge(theBounds->Value(theIndex, theBounds->LowerCol() + fit - 1)); - Standard_Integer aBoundEdgeIndex = aDS.ShapeIndex(aBoundEdge, fit); + TopoDS_Edge aBoundEdge = TopoDS::Edge(theBounds->Value(theIndex, theBounds->LowerCol() +fit)); + Standard_Integer aBoundEdgeIndex = theDS->Index(aBoundEdge); TopoDS_Edge aUE1; TopoDS_Edge aUE2; @@ -785,11 +761,11 @@ Standard_Boolean MakeFacesSec(const Standard_Integer theInde const TopTools_ListOfShape& lst = theHistMap.Find(aUE1); if(!lst.IsEmpty()) { - const TopoDS_Shape& anEdge = lst.First().Oriented(aUE1.Orientation()); + const TopoDS_Shape& anEdge = lst.First().Oriented(aUE1.Orientation()); - if(!aUE1.IsSame(anEdge)) - aSubstitutor->Replace(aUE1.Oriented(TopAbs_FORWARD), anEdge.Oriented(TopAbs_FORWARD)); - aUE1 = TopoDS::Edge(anEdge); + if(!aUE1.IsSame(anEdge)) + aSubstitutor->Replace(aUE1.Oriented(TopAbs_FORWARD), anEdge.Oriented(TopAbs_FORWARD)); + aUE1 = TopoDS::Edge(anEdge); } } @@ -797,32 +773,32 @@ Standard_Boolean MakeFacesSec(const Standard_Integer theInde const TopTools_ListOfShape& lst = theHistMap.Find(aUE2); if(!lst.IsEmpty()) { - const TopoDS_Shape& anEdge = lst.First().Oriented(aUE2.Orientation()); + const TopoDS_Shape& anEdge = lst.First().Oriented(aUE2.Orientation()); - if(!aUE2.IsSame(anEdge)) - aSubstitutor->Replace(aUE2.Oriented(TopAbs_FORWARD), anEdge.Oriented(TopAbs_FORWARD)); - aUE2 = TopoDS::Edge(anEdge); + if(!aUE2.IsSame(anEdge)) + aSubstitutor->Replace(aUE2.Oriented(TopAbs_FORWARD), anEdge.Oriented(TopAbs_FORWARD)); + aUE2 = TopoDS::Edge(anEdge); } } TopoDS_Vertex aPrevVertex, aNextVertex; TopoDS_Compound aCompOfSecEdges = aSecEdges; TopTools_ListOfShape aListOfWireEdges; BRep_Builder aBB; - BOPTools_Pave aPave1; + BOPDS_Pave aPave1; Standard_Boolean isPave1OnUEdge = Standard_True; if(FindFromUEdge(aUE1old, aUE2old, aUE1, aUE2, aFace, aSecEdges, fit, aBoundEdge, aBoundEdgeIndex, - theDSFiller, theHistMap, aCompOfSecEdges, aListOfWireEdges, aPave1, isPave1OnUEdge)) { + theDS, theHistMap, aCompOfSecEdges, aListOfWireEdges, aPave1, isPave1OnUEdge)) { TopTools_ListOfShape aSecondListOfEdges; Standard_Boolean bisSectionFound = Standard_False; if(!FindFromVEdge(aPave1, isPave1OnUEdge, aUE1old, aUE2old, aFace, aCompOfSecEdges, fit, aBoundEdge, - aBoundEdgeIndex, theDSFiller, theHistMap, aSecondListOfEdges, bisSectionFound)) { - return Standard_False; + aBoundEdgeIndex, theDS, theHistMap, aSecondListOfEdges, bisSectionFound)) { + return Standard_False; } if(!bisSectionFound && aListOfWireEdges.IsEmpty()) { - return Standard_False; + return Standard_False; } aListOfWireEdges.Append(aSecondListOfEdges); } @@ -836,8 +812,8 @@ Standard_Boolean MakeFacesSec(const Standard_Integer theInde TopTools_ListIteratorOfListOfShape aEIt(aListOfWireEdges); for(; aEIt.More(); aEIt.Next()) { - if(!aBoundEdge.IsSame(aEIt.Value())) - aBB.Add(aW, aEIt.Value()); + if(!aBoundEdge.IsSame(aEIt.Value())) + aBB.Add(aW, aEIt.Value()); } aSubstitutor->Replace(aBoundEdge.Oriented(TopAbs_FORWARD), aW); } @@ -855,15 +831,15 @@ Standard_Boolean MakeFacesSec(const Standard_Integer theInde TopoDS_Shape aNewValue = aSubstitutor->Value(anExpE.Current()); if(aNewValue.IsNull() || aNewValue.IsSame(anExpE.Current())) - continue; + continue; if(theHistMap.IsBound(anExpE.Current())) - continue; + continue; TopTools_ListOfShape aListOfNewEdge; TopExp_Explorer anExpE2(aNewValue, TopAbs_EDGE); for(; anExpE2.More(); anExpE2.Next()) { - aListOfNewEdge.Append(anExpE2.Current()); + aListOfNewEdge.Append(anExpE2.Current()); } theHistMap.Bind(anExpE.Current(), aListOfNewEdge); } @@ -877,71 +853,58 @@ Standard_Boolean MakeFacesSec(const Standard_Integer theInde // purpose: // ------------------------------------------------------------------------------------------ Standard_Boolean SplitUEdges(const Handle(TopTools_HArray2OfShape)& theUEdges, - const BOPTools_DSFiller& theDSFiller, - TopTools_DataMapOfShapeListOfShape& theHistMap) { - - const BooleanOperations_ShapesDataStructure& aDS = theDSFiller.DS(); -// const BOPTools_PaveFiller& aPaveFiller = theDSFiller.PaveFiller(); -// const BOPTools_SplitShapesPool& aSplitShapesPool = aPaveFiller.SplitShapesPool(); - BOPTools_DSFiller& aDSFiller = (*((BOPTools_DSFiller*)&theDSFiller)); - BOPTools_InterferencePool* pIntrPool = (BOPTools_InterferencePool*)&aDSFiller.InterfPool(); - // const BOPTools_CommonBlockPool& aCBPool = aPaveFiller.CommonBlockPool(); -// const BOPTools_PavePool& aPavePool = aPaveFiller.PavePool(); -// const BOPTools_CArray1OfEEInterference& aEEs = pIntrPool->EEInterfs(); - const BOPTools_CArray1OfVEInterference& aVEs = pIntrPool->VEInterferences(); - const BOPTools_CArray1OfVVInterference& aVVs = pIntrPool->VVInterferences(); + const BOPDS_PDS& theDS, + TopTools_DataMapOfShapeListOfShape& theHistMap) { + + const BOPDS_VectorOfInterfVE& aVEs = theDS->InterfVE(); + const BOPDS_VectorOfInterfVV& aVVs = theDS->InterfVV(); BRep_Builder aBB; - Standard_Integer ueit = 0; + Standard_Integer ueit = 0, upRow, lowCol, upCol; TopTools_Array2OfShape aNewVertices(1,2,1,2); - - for(ueit = theUEdges->LowerRow(); ueit <= theUEdges->UpperRow(); ueit++) { - const TopoDS_Shape& aE1 = theUEdges->Value(ueit, theUEdges->LowerCol()); - const TopoDS_Shape& aE2 = theUEdges->Value(ueit, theUEdges->UpperCol()); + // + upRow = theUEdges->UpperRow(); + lowCol = theUEdges->LowerCol(); + upCol = theUEdges->UpperCol(); + // + for(ueit = theUEdges->LowerRow(); ueit <= upRow; ueit++) { + const TopoDS_Shape& aE1 = theUEdges->Value(ueit, lowCol); + const TopoDS_Shape& aE2 = theUEdges->Value(ueit, upCol); if(theHistMap.IsBound(aE1) || theHistMap.IsBound(aE2)) continue; - Standard_Integer anEIndex1 = aDS.ShapeIndex(aE1, 1); - Standard_Integer anEIndex2 = aDS.ShapeIndex(aE2, 2); + Standard_Integer anEIndex1 = theDS->Index(aE1); + Standard_Integer anEIndex2 = theDS->Index(aE2); TopoDS_Vertex aCommonVertex; Standard_Real apar1 = 0., apar2 = 0.; Standard_Boolean bvertexfound = - FindCommonVertex(theDSFiller, anEIndex1, anEIndex2, aCommonVertex, apar1, apar2); - - if(!bvertexfound) { - Standard_Integer j = 0; - for(j = 0; j < 2; j++) { - Standard_Integer veit = 0; - - for(veit = 1; veit <= aVEs.Extent(); veit++) { - - } - } - } - + FindCommonVertex(theDS, anEIndex1, anEIndex2, aCommonVertex, apar1, apar2); + // if(!bvertexfound) { TopoDS_Vertex V1 = TopExp::LastVertex(TopoDS::Edge(aE1)); TopoDS_Vertex V2 = TopExp::FirstVertex(TopoDS::Edge(aE2)); - Standard_Integer vindex1 = aDS.ShapeIndex(V1, 1); - Standard_Integer vindex2 = aDS.ShapeIndex(V2, 2); + Standard_Integer vindex1 = theDS->Index(V1); + Standard_Integer vindex2 = theDS->Index(V2); Standard_Integer vvit = 0; - - for(vvit = 1; !bvertexfound && (vvit <= aVVs.Extent()); vvit++) { - const BOPTools_VVInterference& aVV = aVVs(vvit); - - if(((vindex1 == aVV.Index1()) && (vindex2 = aVV.Index2())) || - ((vindex1 == aVV.Index2()) && (vindex2 = aVV.Index1()))) { - - if(aVV.NewShape() == 0) { - continue; - } - aCommonVertex = TopoDS::Vertex(aDS.Shape(aVV.NewShape())); - bvertexfound = Standard_True; - apar1 = BRep_Tool::Parameter(V1, TopoDS::Edge(aE1)); - apar2 = BRep_Tool::Parameter(V2, TopoDS::Edge(aE2)); - } + Standard_Integer aNbVVs = aVVs.Extent(); + + for(vvit = 0; !bvertexfound && (vvit < aNbVVs); vvit++) { + //const BOPTools_VVInterference& aVV = aVVs(vvit); + const BOPDS_InterfVV& aVV = aVVs(vvit); + + if(((vindex1 == aVV.Index1()) && (vindex2 = aVV.Index2())) || + ((vindex1 == aVV.Index2()) && (vindex2 = aVV.Index1()))) { + + if(!aVV.HasIndexNew()) { + continue; + } + aCommonVertex = TopoDS::Vertex(theDS->Shape(aVV.IndexNew())); + bvertexfound = Standard_True; + apar1 = BRep_Tool::Parameter(V1, TopoDS::Edge(aE1)); + apar2 = BRep_Tool::Parameter(V2, TopoDS::Edge(aE2)); + } } } @@ -985,8 +948,8 @@ Standard_Boolean SplitUEdges(const Handle(TopTools_HArray2OfShape)& theUEdge // purpose: // ------------------------------------------------------------------------------------------ void FindFreeVertices(const TopoDS_Shape& theShape, - const TopTools_MapOfShape& theVerticesToAvoid, - TopTools_ListOfShape& theListOfVertex) { + const TopTools_MapOfShape& theVerticesToAvoid, + TopTools_ListOfShape& theListOfVertex) { theListOfVertex.Clear(); TopTools_IndexedDataMapOfShapeListOfShape aMap; @@ -1006,85 +969,45 @@ void FindFreeVertices(const TopoDS_Shape& theShape, } } -// ------------------------------------------------------------------------------------------ -// static function: FindParameter -// purpose: -// ------------------------------------------------------------------------------------------ -Standard_Boolean FindParameter(const BOPTools_PaveSet& thePaveSet, - const BooleanOperations_KindOfInterference& theType, - const Standard_Integer theInterfIndex, - Standard_Real& theParam) { - BOPTools_ListIteratorOfListOfPave anPIt(thePaveSet.Set()); - Standard_Boolean bfound = Standard_False; - - for(; anPIt.More(); anPIt.Next()) { - const BOPTools_Pave& aPave = anPIt.Value(); - - if((aPave.Type() == theType) && - (aPave.Interference() == theInterfIndex)) { - theParam = aPave.Param(); - bfound = Standard_True; - break; - } - } - return bfound; -} - // ------------------------------------------------------------------------------------------ // static function: FindCommonVertex // purpose: // ------------------------------------------------------------------------------------------ -Standard_Boolean FindCommonVertex(const BOPTools_DSFiller& theDSFiller, - const Standard_Integer theEIndex1, - const Standard_Integer theEIndex2, - TopoDS_Vertex& theCommonVertex, - Standard_Real& theParamOnE1, - Standard_Real& theParamOnE2) { - - const BooleanOperations_ShapesDataStructure& aDS = theDSFiller.DS(); - const BOPTools_PaveFiller& aPaveFiller = theDSFiller.PaveFiller(); - const BOPTools_PavePool& aPavePool = aPaveFiller.PavePool(); - BOPTools_DSFiller& aDSFiller = (*((BOPTools_DSFiller*)&theDSFiller)); - BOPTools_InterferencePool* pIntrPool = (BOPTools_InterferencePool*)&aDSFiller.InterfPool(); - const BOPTools_CArray1OfEEInterference& aEEs = pIntrPool->EEInterfs(); +Standard_Boolean FindCommonVertex(const BOPDS_PDS& theDS, + const Standard_Integer theEIndex1, + const Standard_Integer theEIndex2, + TopoDS_Vertex& theCommonVertex, + Standard_Real& theParamOnE1, + Standard_Real& theParamOnE2) { + + const BOPDS_VectorOfInterfEE& aEEs = theDS->InterfEE(); Standard_Boolean bvertexfound = Standard_False; TopoDS_Vertex aCommonVertex; Standard_Integer eeit = 0; - for(eeit = 1; eeit <= aEEs.Extent(); eeit++) { - const BOPTools_EEInterference& aEE = aEEs(eeit); + Standard_Integer aNbEEs; + aNbEEs = aEEs.Extent(); + for(eeit = 0; eeit < aNbEEs; ++eeit) { + const BOPDS_InterfEE& aEE = aEEs(eeit); if((theEIndex1 == aEE.Index1() && theEIndex2 == aEE.Index2()) || (theEIndex1 == aEE.Index2() && theEIndex2 == aEE.Index1())) { - if(aEE.NewShape() == 0) - continue; - - if(aDS.GetShapeType(aEE.NewShape()) == TopAbs_VERTEX) { - theCommonVertex = TopoDS::Vertex(aDS.Shape(aEE.NewShape())); - - bvertexfound = Standard_True; - Standard_Integer i = 0; - - for(i = 0; i < 2; i++) { - Standard_Integer anEIndex = (i == 0) ? theEIndex1 : theEIndex2; - const BOPTools_PaveSet& aPaveSet = aPavePool(aDS.RefEdge(anEIndex)); - Standard_Boolean bfound = Standard_False; - - if(i == 0) - bfound = FindParameter(aPaveSet, BooleanOperations_EdgeEdge, eeit, theParamOnE1); - else - bfound = FindParameter(aPaveSet, BooleanOperations_EdgeEdge, eeit, theParamOnE2); - - if(!bfound) { - bvertexfound = Standard_False; - break; - } - } - } - else if(aDS.GetShapeType(aEE.NewShape()) == TopAbs_EDGE) { - + if(!aEE.HasIndexNew()) + continue; + + IntTools_CommonPrt aCP = aEE.CommonPart(); + if(aCP.Type() == TopAbs_VERTEX) { + theCommonVertex = *(TopoDS_Vertex*)&theDS->Shape(aEE.IndexNew()); + if (theEIndex1 == aEE.Index1()) { + BOPInt_Tools::VertexParameters(aCP, theParamOnE1, theParamOnE2); + } else { + BOPInt_Tools::VertexParameters(aCP, theParamOnE2, theParamOnE1); + } + // + bvertexfound = Standard_True; + break; } } } @@ -1096,10 +1019,10 @@ Standard_Boolean FindCommonVertex(const BOPTools_DSFiller& theDSFiller, // purpose: // ------------------------------------------------------------------------------------------ Standard_Boolean IsFromFirstToSecond(const TopoDS_Edge& theEdge, - const Standard_Real theParameterOnUEdge, - const TopoDS_Edge& theUEdge1, - const TopoDS_Edge& theUEdge2, - const TopoDS_Face& theFace) { + const Standard_Real theParameterOnUEdge, + const TopoDS_Edge& theUEdge1, + const TopoDS_Edge& theUEdge2, + const TopoDS_Face& theFace) { TopoDS_Face aFace = theFace; aFace.Orientation(TopAbs_FORWARD); TopoDS_Edge E1, E2; @@ -1143,14 +1066,14 @@ Standard_Boolean IsFromFirstToSecond(const TopoDS_Edge& theEdge, // purpose: // ---------------------------------------------------------------------------------------------------- Standard_Boolean GetUEdges(const Standard_Integer theIndex, - const Standard_Integer theRank, - const Handle(TopTools_HArray2OfShape)& theUEdges, - const TopoDS_Edge& theBoundEdge, - const TopoDS_Face& theFace, - TopoDS_Edge& theFirstUEdge, - TopoDS_Edge& theSecondUEdge) { - const TopoDS_Shape& aUE1 = theUEdges->Value(theIndex, theUEdges->LowerCol() + theRank - 1); - const TopoDS_Shape& aUE2 = theUEdges->Value(theIndex + 1, theUEdges->LowerCol() + theRank - 1); + const Standard_Integer theRank, + const Handle(TopTools_HArray2OfShape)& theUEdges, + const TopoDS_Edge& theBoundEdge, + const TopoDS_Face& theFace, + TopoDS_Edge& theFirstUEdge, + TopoDS_Edge& theSecondUEdge) { + const TopoDS_Shape& aUE1 = theUEdges->Value(theIndex, theUEdges->LowerCol() + theRank); + const TopoDS_Shape& aUE2 = theUEdges->Value(theIndex + 1, theUEdges->LowerCol() + theRank); TopoDS_Face aFace = theFace; aFace.Orientation(TopAbs_FORWARD); @@ -1174,14 +1097,14 @@ Standard_Boolean GetUEdges(const Standard_Integer theIndex, if(C1.IsNull()) return Standard_False; - gp_Pnt2d PU1 = (theRank == 1) ? C1->Value(l) : C1->Value(f); + gp_Pnt2d PU1 = (theRank == 0) ? C1->Value(l) : C1->Value(f); Handle(Geom2d_Curve) C2 = BRep_Tool::CurveOnSurface(theBoundEdge, aFace, f, l); if(C2.IsNull()) return Standard_False; BRep_Tool::Range(theBoundEdge, f, l); gp_Pnt2d pf = C2->Value(f); - TopoDS_Vertex aV = (theRank == 1) ? TopExp::LastVertex(E1) : TopExp::FirstVertex(E1); + TopoDS_Vertex aV = (theRank == 0) ? TopExp::LastVertex(E1) : TopExp::FirstVertex(E1); Standard_Real aTolerance = BRep_Tool::Tolerance(aV); BRepAdaptor_Surface aBAS(aFace, Standard_False); @@ -1200,12 +1123,12 @@ Standard_Boolean GetUEdges(const Standard_Integer theIndex, // purpose: // ---------------------------------------------------------------------------------------------------- Standard_Boolean FillGap(const TopoDS_Vertex& theFirstVertex, - const TopoDS_Vertex& theLastVertex, - const gp_Pnt2d& theFirstPoint, - const gp_Pnt2d& theLastPoint, - const TopoDS_Face& theFace, - const TopoDS_Compound& theSectionEdges, - TopTools_ListOfShape& theOrderedList) { + const TopoDS_Vertex& theLastVertex, + const gp_Pnt2d& theFirstPoint, + const gp_Pnt2d& theLastPoint, + const TopoDS_Face& theFace, + const TopoDS_Compound& theSectionEdges, + TopTools_ListOfShape& theOrderedList) { TopTools_IndexedDataMapOfShapeListOfShape aMap; TopExp::MapShapesAndAncestors(theSectionEdges, TopAbs_VERTEX, TopAbs_EDGE, aMap); @@ -1236,10 +1159,10 @@ Standard_Boolean FillGap(const TopoDS_Vertex& theFirstVertex, // purpose: // ---------------------------------------------------------------------------------------------------- Standard_Boolean FindNextEdge(const TopoDS_Vertex& theFirstVertex, - const TopoDS_Vertex& theLastVertex, - const TopTools_IndexedDataMapOfShapeListOfShape& theMapVE, - const TopTools_MapOfShape& theMapToAvoid, - TopTools_ListOfShape& theOrderedList) { + const TopoDS_Vertex& theLastVertex, + const TopTools_IndexedDataMapOfShapeListOfShape& theMapVE, + const TopTools_MapOfShape& theMapToAvoid, + TopTools_ListOfShape& theOrderedList) { TopoDS_Vertex aCurVertex = theFirstVertex; TopTools_MapOfShape aMapToAvoid; aMapToAvoid = theMapToAvoid; @@ -1259,34 +1182,34 @@ Standard_Boolean FindNextEdge(const TopoDS_Vertex& theFirstVertex, TopoDS_Vertex aSaveCurVertex = aCurVertex; if(!aMapToAvoid.Contains(anEdge)) { - TopoDS_Vertex V1, V2; - TopExp::Vertices(TopoDS::Edge(anEdge), V1, V2); - - if(!aCurVertex.IsSame(V1)) { - aCurVertex = V1; - } - else if(!aCurVertex.IsSame(V2)) { - aCurVertex = V2; - } - aMapToAvoid.Add(anEdge); - befound = Standard_True; - aListOfEdge.Append(anEdge); - - if(!aCurVertex.IsSame(theLastVertex)) { - TopTools_ListOfShape aListtmp; - - if(!FindNextEdge(aCurVertex, theLastVertex, theMapVE, aMapToAvoid, aListtmp)) { - aListOfEdge.Clear(); - aCurVertex = aSaveCurVertex; - continue; - } - else { - aListOfEdge.Append(aListtmp); - theOrderedList.Append(aListOfEdge); - return Standard_True; - } - } - break; + TopoDS_Vertex V1, V2; + TopExp::Vertices(TopoDS::Edge(anEdge), V1, V2); + + if(!aCurVertex.IsSame(V1)) { + aCurVertex = V1; + } + else if(!aCurVertex.IsSame(V2)) { + aCurVertex = V2; + } + aMapToAvoid.Add(anEdge); + befound = Standard_True; + aListOfEdge.Append(anEdge); + + if(!aCurVertex.IsSame(theLastVertex)) { + TopTools_ListOfShape aListtmp; + + if(!FindNextEdge(aCurVertex, theLastVertex, theMapVE, aMapToAvoid, aListtmp)) { + aListOfEdge.Clear(); + aCurVertex = aSaveCurVertex; + continue; + } + else { + aListOfEdge.Append(aListtmp); + theOrderedList.Append(aListOfEdge); + return Standard_True; + } + } + break; } } @@ -1310,10 +1233,10 @@ Standard_Boolean FindNextEdge(const TopoDS_Vertex& theFirstVertex, // purpose: // ---------------------------------------------------------------------------------------------------- Standard_Boolean CheckAndOrientEdges(const TopTools_ListOfShape& theOrderedList, - const gp_Pnt2d& theFirstPoint, - const gp_Pnt2d& theLastPoint, - const TopoDS_Face& theFace, - TopTools_ListOfShape& theOrientedList) { + const gp_Pnt2d& theFirstPoint, + const gp_Pnt2d& theLastPoint, + const TopoDS_Face& theFace, + TopTools_ListOfShape& theOrientedList) { TopTools_ListIteratorOfListOfShape anIt(theOrderedList); if(!anIt.More()) @@ -1424,11 +1347,11 @@ Standard_Boolean CheckAndOrientEdges(const TopTools_ListOfShape& theOrderedList // purpose: // ---------------------------------------------------------------------------------------------------- Standard_Boolean FindVertex(const TopoDS_Edge& theEdge, - const Standard_Integer theRank, - const BOPTools_DSFiller& theDSFiller, - const TopTools_DataMapOfShapeListOfShape& theHistMap, - TopoDS_Vertex& theVertex, - BOPTools_Pave& thePave) { + const Standard_Integer theRank, + const BOPDS_PDS& theDS, + const TopTools_DataMapOfShapeListOfShape& theHistMap, + TopoDS_Vertex& theVertex, + BOPDS_Pave& thePave) { if(!theHistMap.IsBound(theEdge)) return Standard_False; @@ -1437,34 +1360,33 @@ Standard_Boolean FindVertex(const TopoDS_Edge& theEdge, if(lst.IsEmpty()) return Standard_False; - const BooleanOperations_ShapesDataStructure& aDS = theDSFiller.DS(); TopoDS_Edge aNewEdge = TopoDS::Edge(lst.First()); Standard_Real f, l; BRep_Tool::Range(aNewEdge, f, l); - if(theRank == 1) { - thePave.SetParam(l); + if(theRank == 0) { + thePave.SetParameter(l); theVertex = TopExp::LastVertex(aNewEdge); } else { - thePave.SetParam(f); + thePave.SetParameter(f); theVertex = TopExp::FirstVertex(aNewEdge); } - Standard_Integer anIndex = aDS.ShapeIndex(theVertex, theRank); - - if(anIndex == 0) { - Standard_Integer i = 0; - - for(i = aDS.NumberOfSourceShapes() + 1; i <= aDS.NumberOfInsertedShapes(); i++) { - const TopoDS_Shape& aShape = aDS.Shape(i); - - if(theVertex.IsSame(aShape)) { - anIndex = i; - break; + Standard_Integer anIndex = theDS->Index(theVertex); + if (anIndex == -1) { + Standard_Integer i, i1, i2; + i1=theDS->NbSourceShapes(); + i2=theDS->NbShapes(); + for (i=i1; iShape(i); + if(aSx.IsSame(theVertex)) { + anIndex = i; + break; } } } + thePave.SetIndex(anIndex); return Standard_True; @@ -1475,102 +1397,93 @@ Standard_Boolean FindVertex(const TopoDS_Edge& theEdge, // purpose: // ---------------------------------------------------------------------------------------------------- Standard_Boolean FindNextVertex(const Standard_Integer theEdgeIndex, - const BOPTools_Pave& thePrevPave, - const BOPTools_DSFiller& theDSFiller, - TopoDS_Vertex& theNextVertex, - BOPTools_Pave& thePave) { - - const BooleanOperations_ShapesDataStructure& aDS = theDSFiller.DS(); - const BOPTools_PaveFiller& aPaveFiller = theDSFiller.PaveFiller(); - const BOPTools_PavePool& aPavePool = aPaveFiller.PavePool(); - const BOPTools_PaveSet& aPaveSet = aPavePool(aDS.RefEdge(theEdgeIndex)); - BOPTools_PaveSet aSortedPaveSet; - aSortedPaveSet = aPaveSet; - aSortedPaveSet.SortSet(); - - BOPTools_ListIteratorOfListOfPave anIt(aSortedPaveSet.Set()); - BOPTools_Pave anullpave(0, 0.); - Standard_Boolean btakepave = (thePrevPave.IsEqual(anullpave)); - Standard_Boolean bfound = Standard_False; - BOPTools_Pave atmppave; - - for(; anIt.More(); anIt.Next()) { - if(btakepave) { - atmppave = anIt.Value(); - - if(atmppave.Type() != BooleanOperations_UnknownInterference) { - theNextVertex = TopoDS::Vertex(aDS.Shape(atmppave.Index())); - thePave = atmppave; - bfound = Standard_True; - break; + const BOPDS_Pave& thePrevPave, + const BOPDS_PDS& theDS, + TopoDS_Vertex& theNextVertex, + BOPDS_Pave& thePave) { + + Standard_Integer i; + Standard_Boolean bTakePave, bFound; + BOPDS_Pave aTmpPave; + BOPDS_ListIteratorOfListOfPave aItP; + // + BOPDS_Pave anullpave; + bFound = Standard_False; + bTakePave = thePrevPave.IsEqual(anullpave); + + BOPDS_ListOfPave aLP; + theDS->Paves(theEdgeIndex, aLP); + aItP.Initialize(aLP); + for (; aItP.More(); aItP.Next()) { + aTmpPave = aItP.Value(); + // + if (bTakePave) { + if (theDS->IsNewShape(aTmpPave.Index())) { + theNextVertex = *(TopoDS_Vertex*)&theDS->Shape(aTmpPave.Index()); + thePave = aTmpPave; + bFound = Standard_True; + break; } } - - if(thePrevPave.IsEqual(anIt.Value())) { - btakepave = Standard_True; + // + else if (aTmpPave.IsEqual(thePrevPave)) { + bTakePave = Standard_True; } } - - return bfound; + + return bFound; } // ---------------------------------------------------------------------------------------------------- // static function: GetPave // purpose: // ---------------------------------------------------------------------------------------------------- -Standard_Boolean GetPave(const Standard_Integer theEdgeIndex, - const Standard_Boolean isFirst, - const BOPTools_DSFiller& theDSFiller, - BOPTools_Pave& thePave) { - const BooleanOperations_ShapesDataStructure& aDS = theDSFiller.DS(); - const BOPTools_PaveFiller& aPaveFiller = theDSFiller.PaveFiller(); - const BOPTools_PavePool& aPavePool = aPaveFiller.PavePool(); - - const BOPTools_PaveSet& aPaveSet = aPavePool(aDS.RefEdge(theEdgeIndex)); - BOPTools_PaveSet aSortedPaveSet; - aSortedPaveSet = aPaveSet; - aSortedPaveSet.SortSet(); - - if(aSortedPaveSet.Set().IsEmpty()) - return Standard_False; +Standard_Boolean GetPave(const Standard_Integer theEdgeIndex, + const Standard_Boolean isFirst, + const BOPDS_PDS& theDS, + BOPDS_Pave& thePave) { - if(isFirst) { - thePave = aSortedPaveSet.Set().First(); + Handle(BOPDS_PaveBlock) aPB; + BOPDS_ListOfPave aLP; + + theDS->Paves(theEdgeIndex, aLP); + if (!aLP.Extent()) { + return Standard_False; + } + // + if (isFirst) { + thePave = aLP.First(); } else { - thePave = aSortedPaveSet.Set().Last(); + thePave = aLP.Last(); } + return Standard_True; } - // ---------------------------------------------------------------------------------------------------- // static function: FindFromUEdge // purpose: // ---------------------------------------------------------------------------------------------------- Standard_Boolean FindFromUEdge(const TopoDS_Edge& theUE1Old, - const TopoDS_Edge& theUE2Old, - const TopoDS_Edge& theUE1New, - const TopoDS_Edge& theUE2New, - const TopoDS_Face& theFace, - const TopoDS_Compound& theSecEdges, - const Standard_Integer theRank, - const TopoDS_Edge& theBoundEdge, - const Standard_Integer theBoundEdgeIndex, - const BOPTools_DSFiller& theDSFiller, - const TopTools_DataMapOfShapeListOfShape& theHistMap, - TopoDS_Compound& theSecEdgesNew, - TopTools_ListOfShape& theListOfWireEdges, - BOPTools_Pave& theFoundPave, - Standard_Boolean& isOnUEdge) { + const TopoDS_Edge& theUE2Old, + const TopoDS_Edge& theUE1New, + const TopoDS_Edge& theUE2New, + const TopoDS_Face& theFace, + const TopoDS_Compound& theSecEdges, + const Standard_Integer theRank, + const TopoDS_Edge& theBoundEdge, + const Standard_Integer theBoundEdgeIndex, + const BOPDS_PDS& theDS, + const TopTools_DataMapOfShapeListOfShape& theHistMap, + TopoDS_Compound& theSecEdgesNew, + TopTools_ListOfShape& theListOfWireEdges, + BOPDS_Pave& theFoundPave, + Standard_Boolean& isOnUEdge) { theFoundPave.SetIndex(0); - theFoundPave.SetParam(0.); + theFoundPave.SetParameter(0.); isOnUEdge = Standard_True; - const BooleanOperations_ShapesDataStructure& aDS = theDSFiller.DS(); - const BOPTools_PaveFiller& aPaveFiller = theDSFiller.PaveFiller(); - const BOPTools_PavePool& aPavePool = aPaveFiller.PavePool(); - TopoDS_Face aFaceF = theFace; aFaceF.Orientation(TopAbs_FORWARD); TopoDS_Vertex aPrevVertex, aNextVertex; @@ -1578,13 +1491,13 @@ Standard_Boolean FindFromUEdge(const TopoDS_Edge& theUE1O TopTools_ListOfShape aListOfWireEdges; // BRep_Builder aBB; - BOPTools_Pave aPave1(0, 0.), aPave2(0, 0.); + BOPDS_Pave aPave1, aPave2; Standard_Real f = 0., l = 0.; gp_Pnt2d p1, p2; TopoDS_Vertex aFirstV, aLastV; - BOPTools_Pave atmpPave; + BOPDS_Pave atmpPave; - if(!FindVertex(theUE1Old, theRank, theDSFiller, theHistMap, aPrevVertex, atmpPave)) { + if(!FindVertex(theUE1Old, theRank, theDS, theHistMap, aPrevVertex, atmpPave)) { return Standard_True; } @@ -1595,16 +1508,17 @@ Standard_Boolean FindFromUEdge(const TopoDS_Edge& theUE1O aFirstV = aPrevVertex; Standard_Boolean bSecFound = Standard_False; Handle(Geom2d_Curve) aC1 = BRep_Tool::CurveOnSurface(theUE1New, aFaceF, f, l); - p1 = (theRank == 1) ? aC1->Value(l) : aC1->Value(f); - BOPTools_Pave afoundpave(0, 0.); - const BOPTools_PaveSet& aPaveSet = aPavePool(aDS.RefEdge(theBoundEdgeIndex)); - Standard_Integer nbpave = aPaveSet.Set().Extent(); + p1 = (theRank == 0) ? aC1->Value(l) : aC1->Value(f); + BOPDS_Pave afoundpave; + BOPDS_ListOfPave aLP; + theDS->Paves(theBoundEdgeIndex, aLP); + Standard_Integer nbpave = aLP.Extent(); Standard_Integer pit = 0; - - while(FindNextVertex(theBoundEdgeIndex, aPave1, theDSFiller, aNextVertex, aPave2) && (pit < nbpave)) { + + while(FindNextVertex(theBoundEdgeIndex, aPave1, theDS, aNextVertex, aPave2) && (pit < nbpave)) { aLastV = aNextVertex; Handle(Geom2d_Curve) aC2 = BRep_Tool::CurveOnSurface(theBoundEdge, aFaceF, f, l); - p2 = aC2->Value(aPave2.Param()); + p2 = aC2->Value(aPave2.Parameter()); TopTools_ListOfShape aOrderedList; if(FillGap(aFirstV, aLastV, p1, p2, aFaceF, aCompOfSecEdges, aOrderedList)) { @@ -1623,10 +1537,10 @@ Standard_Boolean FindFromUEdge(const TopoDS_Edge& theUE1O pit++; } - if(!bSecFound && FindVertex(theUE2Old, theRank, theDSFiller, theHistMap, aNextVertex, aPave2)) { + if(!bSecFound && FindVertex(theUE2Old, theRank, theDS, theHistMap, aNextVertex, aPave2)) { aLastV = aNextVertex; Handle(Geom2d_Curve) aC2 = BRep_Tool::CurveOnSurface(theUE2New, aFaceF, f, l); - p2 = aC2->Value(aPave2.Param()); + p2 = aC2->Value(aPave2.Parameter()); TopTools_ListOfShape aOrderedList; if(FillGap(aFirstV, aLastV, p1, p2, aFaceF, aCompOfSecEdges, aOrderedList)) { @@ -1655,26 +1569,23 @@ Standard_Boolean FindFromUEdge(const TopoDS_Edge& theUE1O // static function: FindFromVEdge // purpose: // ---------------------------------------------------------------------------------------------------- -Standard_Boolean FindFromVEdge(const BOPTools_Pave& thePrevPave, - const Standard_Boolean& isOnUEdge, - const TopoDS_Edge& theUE1Old, - const TopoDS_Edge& theUE2Old, - const TopoDS_Face& theFace, - const TopoDS_Compound& theSecEdges, - const Standard_Integer theRank, - const TopoDS_Edge& theBoundEdge, - const Standard_Integer theBoundEdgeIndex, - const BOPTools_DSFiller& theDSFiller, - const TopTools_DataMapOfShapeListOfShape& theHistMap, - TopTools_ListOfShape& theListOfWireEdges, - Standard_Boolean& isSectionFound) { +Standard_Boolean FindFromVEdge(const BOPDS_Pave& thePrevPave, + const Standard_Boolean& isOnUEdge, + const TopoDS_Edge& theUE1Old, + const TopoDS_Edge& theUE2Old, + const TopoDS_Face& theFace, + const TopoDS_Compound& theSecEdges, + const Standard_Integer theRank, + const TopoDS_Edge& theBoundEdge, + const Standard_Integer theBoundEdgeIndex, + const BOPDS_PDS& theDS, + const TopTools_DataMapOfShapeListOfShape& theHistMap, + TopTools_ListOfShape& theListOfWireEdges, + Standard_Boolean& isSectionFound) { + theListOfWireEdges.Clear(); isSectionFound = Standard_False; - const BooleanOperations_ShapesDataStructure& aDS = theDSFiller.DS(); - const BOPTools_PaveFiller& aPaveFiller = theDSFiller.PaveFiller(); - const BOPTools_SplitShapesPool& aSplitShapesPool = aPaveFiller.SplitShapesPool(); - const BOPTools_PavePool& aPavePool = aPaveFiller.PavePool(); - + // TopoDS_Face aFaceF = theFace; aFaceF.Orientation(TopAbs_FORWARD); TopoDS_Vertex aPrevVertex, aNextVertex; @@ -1682,15 +1593,15 @@ Standard_Boolean FindFromVEdge(const BOPTools_Pave& thePrev TopTools_ListOfShape aListOfWireEdges; // BRep_Builder aBB; - BOPTools_Pave aPave1(0, 0.), aPave2(0, 0.); + BOPDS_Pave aPave1, aPave2; if(isOnUEdge) { TopoDS_Vertex atmpVertex; - BOPTools_Pave aPaveOfE2; + BOPDS_Pave aPaveOfE2; - if(FindVertex(theUE2Old, theRank, theDSFiller, theHistMap, atmpVertex, aPaveOfE2)) { + if(FindVertex(theUE2Old, theRank, theDS, theHistMap, atmpVertex, aPaveOfE2)) { if(thePrevPave.IsEqual(aPaveOfE2)) - return Standard_True; + return Standard_True; } } @@ -1704,27 +1615,28 @@ Standard_Boolean FindFromVEdge(const BOPTools_Pave& thePrev aPave1 = thePrevPave; if(isOnUEdge) { - BOPTools_Pave atmpPave; + BOPDS_Pave atmpPave; - if(!GetPave(theBoundEdgeIndex, Standard_True, theDSFiller, atmpPave)) { + if(!GetPave(theBoundEdgeIndex, Standard_True, theDS, atmpPave)) { return Standard_False; } aPave1 = atmpPave; } - p1 = aC2->Value(aPave1.Param()); - aPrevVertex = TopoDS::Vertex(aDS.Shape(aPave1.Index())); + p1 = aC2->Value(aPave1.Parameter()); + aPrevVertex = TopoDS::Vertex(theDS->Shape(aPave1.Index())); - const BOPTools_PaveSet& aPaveSet = aPavePool(aDS.RefEdge(theBoundEdgeIndex)); - Standard_Integer nbpave = aPaveSet.Set().Extent(); + BOPDS_ListOfPave aLP; + theDS->Paves(theBoundEdgeIndex, aLP); + Standard_Integer nbpave = aLP.Extent(); Standard_Integer pit = 0; TopTools_Array1OfListOfShape anArrayOfListOfSec(1, nbpave); // by pairs non continuously. begin Standard_Integer k = 0; - BOPTools_Pave aFirstPave = aPave1; + BOPDS_Pave aFirstPave = aPave1; TopoDS_Vertex aFirstVertex = aPrevVertex; gp_Pnt2d apfirst = p1; - BOPTools_ListOfPave aFirstPaves, aLastPaves; + BOPDS_ListOfPave aFirstPaves, aLastPaves; TColStd_ListOfInteger aListOfFlags; Standard_Integer apaircounter = 1; @@ -1735,62 +1647,60 @@ Standard_Boolean FindFromVEdge(const BOPTools_Pave& thePrev Standard_Boolean bfound = Standard_False; pit = 0; - while(FindNextVertex(theBoundEdgeIndex, aPave1, theDSFiller, aNextVertex, aPave2) && (pit < nbpave)) { + while(FindNextVertex(theBoundEdgeIndex, aPave1, theDS, aNextVertex, aPave2) && (pit < nbpave)) { aFirstV = aPrevVertex; aLastV = aNextVertex; - p2 = aC2->Value(aPave2.Param()); + p2 = aC2->Value(aPave2.Parameter()); TopTools_ListOfShape aOrderedList; if(FillGap(aFirstV, aLastV, p1, p2, aFaceF, aCompOfSecEdges, aOrderedList)) { - TopoDS_Compound aComp; - RemoveEdges(aCompOfSecEdges, aOrderedList, aComp); - aCompOfSecEdges = aComp; - - anArrayOfListOfSec(apaircounter++).Append(aOrderedList); - BOPTools_PaveBlock aPB(theBoundEdgeIndex, aFirstPave, aPave2); - aFirstPaves.Append(aFirstPave); - aLastPaves.Append(aPave2); - aListOfFlags.Append(1); - aFirstPave = aPave2; - aFirstVertex = aNextVertex; - apfirst = p2; - aPrevVertex = aNextVertex; - bSecFound = Standard_True; - bfound = Standard_True; + TopoDS_Compound aComp; + RemoveEdges(aCompOfSecEdges, aOrderedList, aComp); + aCompOfSecEdges = aComp; + + anArrayOfListOfSec(apaircounter++).Append(aOrderedList); + aFirstPaves.Append(aFirstPave); + aLastPaves.Append(aPave2); + aListOfFlags.Append(1); + aFirstPave = aPave2; + aFirstVertex = aNextVertex; + apfirst = p2; + aPrevVertex = aNextVertex; + bSecFound = Standard_True; + bfound = Standard_True; } aPave1 = aPave2; pit++; } - if(FindVertex(theUE2Old, theRank, theDSFiller, theHistMap, aNextVertex, aPave2)) { + if(FindVertex(theUE2Old, theRank, theDS, theHistMap, aNextVertex, aPave2)) { aFirstV = aPrevVertex; aLastV = aNextVertex; Handle(Geom2d_Curve) aC3 = BRep_Tool::CurveOnSurface(theUE2Old, aFaceF, f, l); - p2 = aC3->Value(aPave2.Param()); + p2 = aC3->Value(aPave2.Parameter()); TopTools_ListOfShape aOrderedList; if(FillGap(aFirstV, aLastV, p1, p2, aFaceF, aCompOfSecEdges, aOrderedList)) { - TopoDS_Compound aComp; - RemoveEdges(aCompOfSecEdges, aOrderedList, aComp); - aCompOfSecEdges = aComp; - anArrayOfListOfSec(apaircounter++).Append(aOrderedList); - BOPTools_PaveBlock aPB(-1, aFirstPave, aPave2); - aFirstPaves.Append(aFirstPave); - aLastPaves.Append(aPave2); - aListOfFlags.Append(0); - bSecFound = Standard_True; - break; + TopoDS_Compound aComp; + RemoveEdges(aCompOfSecEdges, aOrderedList, aComp); + aCompOfSecEdges = aComp; + anArrayOfListOfSec(apaircounter++).Append(aOrderedList); + aFirstPaves.Append(aFirstPave); + aLastPaves.Append(aPave2); + aListOfFlags.Append(0); + bSecFound = Standard_True; + break; } } if(!bfound) { - if(!FindNextVertex(theBoundEdgeIndex, aFirstPave, theDSFiller, aNextVertex, aPave2)) { - break; + if(!FindNextVertex(theBoundEdgeIndex, aFirstPave, theDS, aNextVertex, aPave2)) { + break; } aFirstPave = aPave2; - apfirst = aC2->Value(aPave2.Param()); + apfirst = aC2->Value(aPave2.Parameter()); aFirstVertex = aNextVertex; } } @@ -1800,72 +1710,72 @@ Standard_Boolean FindFromVEdge(const BOPTools_Pave& thePrev aPave1 = thePrevPave; if(isOnUEdge) { - BOPTools_Pave atmpPave; + BOPDS_Pave atmpPave; - if(!GetPave(theBoundEdgeIndex, Standard_True, theDSFiller, atmpPave)) { + if(!GetPave(theBoundEdgeIndex, Standard_True, theDS, atmpPave)) { return Standard_False; } aPave1 = atmpPave; } - p1 = aC2->Value(aPave1.Param()); - aPrevVertex = TopoDS::Vertex(aDS.Shape(aPave1.Index())); + p1 = aC2->Value(aPave1.Parameter()); + aPrevVertex = TopoDS::Vertex(theDS->Shape(aPave1.Index())); pit = 0; - while(FindNextVertex(theBoundEdgeIndex, aPave1, theDSFiller, aNextVertex, aPave2) && (pit < nbpave)) { + while(FindNextVertex(theBoundEdgeIndex, aPave1, theDS, aNextVertex, aPave2) && (pit < nbpave)) { aFirstV = aPrevVertex; aLastV = aNextVertex; - p2 = aC2->Value(aPave2.Param()); + p2 = aC2->Value(aPave2.Parameter()); Standard_Boolean bisinside = Standard_False; Standard_Integer apbindex = 0; Standard_Integer apbcounter = 1; - BOPTools_ListIteratorOfListOfPaveBlock aPBIt; - BOPTools_ListIteratorOfListOfPave aPIt1, aPIt2; + BOPDS_ListIteratorOfListOfPaveBlock aPBIt; + BOPDS_ListIteratorOfListOfPave aPIt1, aPIt2; TColStd_ListIteratorOfListOfInteger aFlagIt; for(aPIt1.Initialize(aFirstPaves), aPIt2.Initialize(aLastPaves), aFlagIt.Initialize(aListOfFlags); - aPIt1.More() && aPIt2.More() && aFlagIt.More(); - aPIt1.Next(), aPIt2.Next(), aFlagIt.Next(), apbcounter++) { + aPIt1.More() && aPIt2.More() && aFlagIt.More(); + aPIt1.Next(), aPIt2.Next(), aFlagIt.Next(), apbcounter++) { Standard_Boolean bfin = Standard_False; Standard_Boolean blin = Standard_False; if(aPave1.IsEqual(aPIt1.Value())) { - bfin = Standard_True; + bfin = Standard_True; } else { - bfin = (aPave1.Param() > aPIt1.Value().Param()); + bfin = (aPave1.Parameter() > aPIt1.Value().Parameter()); } if(aFlagIt.Value()) { - if(aPave2.IsEqual(aPIt2.Value())) { - blin = Standard_True; - } - else { - blin = (aPave2.Param() < aPIt2.Value().Param()); - } + if(aPave2.IsEqual(aPIt2.Value())) { + blin = Standard_True; + } + else { + blin = (aPave2.Parameter() < aPIt2.Value().Parameter()); + } } else { - if((aPave2.Index() == aPIt2.Value().Index()) && (aPave2.Index() > 0)) { - Handle(Geom2d_Curve) pc = BRep_Tool::CurveOnSurface(theUE2Old, aFaceF, f, l); - gp_Pnt2d p3 = pc->Value(aPIt2.Value().Param()); - TopoDS_Vertex aV = TopoDS::Vertex(aDS.Shape(aPave2.Index())); - BRepAdaptor_Surface aBAS(aFaceF, Standard_False); - Standard_Real aTolerance = BRep_Tool::Tolerance(aV); - Standard_Real utol = aBAS.UResolution(aTolerance); - Standard_Real vtol = aBAS.VResolution(aTolerance); - aTolerance = (utol > vtol) ? utol : vtol; - - if(p2.Distance(p3) < aTolerance) - blin = Standard_True; - } + if((aPave2.Index() == aPIt2.Value().Index()) && (aPave2.Index() > 0)) { + Handle(Geom2d_Curve) pc = BRep_Tool::CurveOnSurface(theUE2Old, aFaceF, f, l); + gp_Pnt2d p3 = pc->Value(aPIt2.Value().Parameter()); + TopoDS_Vertex aV = TopoDS::Vertex(theDS->Shape(aPave2.Index())); + BRepAdaptor_Surface aBAS(aFaceF, Standard_False); + Standard_Real aTolerance = BRep_Tool::Tolerance(aV); + Standard_Real utol = aBAS.UResolution(aTolerance); + Standard_Real vtol = aBAS.VResolution(aTolerance); + aTolerance = (utol > vtol) ? utol : vtol; + + if(p2.Distance(p3) < aTolerance) + blin = Standard_True; + } } if(bfin && blin) { - apbindex = apbcounter; - bisinside = Standard_True; - break; + apbindex = apbcounter; + bisinside = Standard_True; + break; } } @@ -1874,37 +1784,39 @@ Standard_Boolean FindFromVEdge(const BOPTools_Pave& thePrev TopTools_ListOfShape aOrderedList; if(FillGap(aFirstV, aLastV, p1, p2, aFaceF, aCompOfSecEdges, aOrderedList)) { - TopoDS_Compound aComp; - RemoveEdges(aCompOfSecEdges, aOrderedList, aComp); - aCompOfSecEdges = aComp; - aListOfWireEdges.Append(aOrderedList); + TopoDS_Compound aComp; + RemoveEdges(aCompOfSecEdges, aOrderedList, aComp); + aCompOfSecEdges = aComp; + aListOfWireEdges.Append(aOrderedList); - bSecFound = Standard_True; + bSecFound = Standard_True; } else { - TopoDS_Edge aESplit; - BOPTools_PaveBlock aPB(theBoundEdgeIndex, aPave1, aPave2); - // get split - aPBIt.Initialize(aSplitShapesPool(aDS.RefEdge(theBoundEdgeIndex))); - - for(; aPBIt.More(); aPBIt.Next()) { - if(aPB.IsEqual(aPBIt.Value())) { - if(aPBIt.Value().Edge() > 0) { - aESplit = TopoDS::Edge(aDS.Shape(aPBIt.Value().Edge())); - break; - } - } - } - - if(!aESplit.IsNull()) { - aListOfWireEdges.Append(aESplit); - } + TopoDS_Edge aESplit; + // get split + aPBIt.Initialize(theDS->PaveBlocks(theBoundEdgeIndex)); + + for(; aPBIt.More(); aPBIt.Next()) { + const Handle(BOPDS_PaveBlock)& aPB1 = aPBIt.Value(); + if (aPB1->OriginalEdge() == theBoundEdgeIndex && + aPB1->Pave1().IsEqual(aPave1) && + aPB1->Pave2().IsEqual(aPave2) ) { + if(aPB1->Edge() > 0) { + aESplit = *(TopoDS_Edge*)&theDS->Shape(aPB1->Edge()); + break; + } + } + } + + if(!aESplit.IsNull()) { + aListOfWireEdges.Append(aESplit); + } } } else { if(apbindex > 0) { - TopTools_ListOfShape& aListOfSec = anArrayOfListOfSec(apbindex); - aListOfWireEdges.Append(aListOfSec); + TopTools_ListOfShape& aListOfSec = anArrayOfListOfSec(apbindex); + aListOfWireEdges.Append(aListOfSec); } } aPave1 = aPave2; @@ -1913,49 +1825,49 @@ Standard_Boolean FindFromVEdge(const BOPTools_Pave& thePrev pit++; } - if(FindVertex(theUE2Old, theRank, theDSFiller, theHistMap, aNextVertex, aPave2)) { + if(FindVertex(theUE2Old, theRank, theDS, theHistMap, aNextVertex, aPave2)) { aFirstV = aPrevVertex; aLastV = aNextVertex; Handle(Geom2d_Curve) aC3 = BRep_Tool::CurveOnSurface(theUE2Old, aFaceF, f, l); - p2 = aC3->Value(aPave2.Param()); + p2 = aC3->Value(aPave2.Parameter()); Standard_Boolean bisinside = Standard_False; Standard_Integer apbindex = 0; Standard_Integer apbcounter = 1; - BOPTools_ListIteratorOfListOfPaveBlock aPBIt; - BOPTools_ListIteratorOfListOfPave aPIt1, aPIt2; + BOPDS_ListIteratorOfListOfPaveBlock aPBIt; + BOPDS_ListIteratorOfListOfPave aPIt1, aPIt2; TColStd_ListIteratorOfListOfInteger aFlagIt; for(aPIt1.Initialize(aFirstPaves), aPIt2.Initialize(aLastPaves), aFlagIt.Initialize(aListOfFlags); - aPIt1.More() && aPIt2.More() && aFlagIt.More(); - aPIt1.Next(), aPIt2.Next(), aFlagIt.Next(), apbcounter++) { + aPIt1.More() && aPIt2.More() && aFlagIt.More(); + aPIt1.Next(), aPIt2.Next(), aFlagIt.Next(), apbcounter++) { Standard_Boolean bfin = Standard_False; Standard_Boolean blin = Standard_False; if(aPave1.IsEqual(aPIt1.Value())) { - bfin = Standard_True; + bfin = Standard_True; } else { - bfin = (aPave1.Param() > aPIt1.Value().Param()); + bfin = (aPave1.Parameter() > aPIt1.Value().Parameter()); } if(aFlagIt.Value()) { - if(aPave2.IsEqual(aPIt2.Value())) { - blin = Standard_True; - } - else { - blin = (aPave2.Param() < aPIt2.Value().Param()); - } + if(aPave2.IsEqual(aPIt2.Value())) { + blin = Standard_True; + } + else { + blin = (aPave2.Parameter() < aPIt2.Value().Parameter()); + } } else { - blin = Standard_True; + blin = Standard_True; } if(bfin && blin) { - apbindex = apbcounter; - bisinside = Standard_True; - break; + apbindex = apbcounter; + bisinside = Standard_True; + break; } } @@ -1964,40 +1876,42 @@ Standard_Boolean FindFromVEdge(const BOPTools_Pave& thePrev TopTools_ListOfShape aOrderedList; if(FillGap(aFirstV, aLastV, p1, p2, aFaceF, aCompOfSecEdges, aOrderedList)) { - TopoDS_Compound aComp; - RemoveEdges(aCompOfSecEdges, aOrderedList, aComp); - aCompOfSecEdges = aComp; - aListOfWireEdges.Append(aOrderedList); + TopoDS_Compound aComp; + RemoveEdges(aCompOfSecEdges, aOrderedList, aComp); + aCompOfSecEdges = aComp; + aListOfWireEdges.Append(aOrderedList); - bSecFound = Standard_True; + bSecFound = Standard_True; } else { - //add split - TopoDS_Edge aESplit; - // get split - if(!GetPave(theBoundEdgeIndex, Standard_False, theDSFiller, aPave2)) - return Standard_False; - BOPTools_PaveBlock aPB(theBoundEdgeIndex, aPave1, aPave2); - aPBIt.Initialize(aSplitShapesPool(aDS.RefEdge(theBoundEdgeIndex))); - - for(; aPBIt.More(); aPBIt.Next()) { - if(aPB.IsEqual(aPBIt.Value())) { - if(aPBIt.Value().Edge() > 0) { - aESplit = TopoDS::Edge(aDS.Shape(aPBIt.Value().Edge())); - break; - } - } - } - - if(!aESplit.IsNull()) { - aListOfWireEdges.Append(aESplit); - } + //add split + TopoDS_Edge aESplit; + // get split + if(!GetPave(theBoundEdgeIndex, Standard_False, theDS, aPave2)) + return Standard_False; + // + aPBIt.Initialize(theDS->PaveBlocks(theBoundEdgeIndex)); + for(; aPBIt.More(); aPBIt.Next()) { + const Handle(BOPDS_PaveBlock)& aPB1 = aPBIt.Value(); + if (aPB1->OriginalEdge() == theBoundEdgeIndex && + aPB1->Pave1().IsEqual(aPave1) && + aPB1->Pave2().IsEqual(aPave2) ) { + if(aPB1->Edge() > 0) { + aESplit = *(TopoDS_Edge*)&theDS->Shape(aPB1->Edge()); + break; + } + } + } + + if(!aESplit.IsNull()) { + aListOfWireEdges.Append(aESplit); + } } } else { if(apbindex > 0) { - TopTools_ListOfShape& aListOfSec = anArrayOfListOfSec(apbindex); - aListOfWireEdges.Append(aListOfSec); + TopTools_ListOfShape& aListOfSec = anArrayOfListOfSec(apbindex); + aListOfWireEdges.Append(aListOfSec); } } } @@ -2005,18 +1919,20 @@ Standard_Boolean FindFromVEdge(const BOPTools_Pave& thePrev //add split TopoDS_Edge aESplit; // get split - if(!GetPave(theBoundEdgeIndex, Standard_False, theDSFiller, aPave2)) + if(!GetPave(theBoundEdgeIndex, Standard_False, theDS, aPave2)) return Standard_False; - BOPTools_PaveBlock aPB(theBoundEdgeIndex, aPave1, aPave2); - BOPTools_ListIteratorOfListOfPaveBlock aPBIt; - aPBIt.Initialize(aSplitShapesPool(aDS.RefEdge(theBoundEdgeIndex))); + BOPDS_ListIteratorOfListOfPaveBlock aPBIt; + aPBIt.Initialize(theDS->PaveBlocks(theBoundEdgeIndex)); for(; aPBIt.More(); aPBIt.Next()) { - if(aPB.IsEqual(aPBIt.Value())) { - if(aPBIt.Value().Edge() > 0) { - aESplit = TopoDS::Edge(aDS.Shape(aPBIt.Value().Edge())); - break; - } + const Handle(BOPDS_PaveBlock)& aPB1 = aPBIt.Value(); + if (aPB1->OriginalEdge() == theBoundEdgeIndex && + aPB1->Pave1().IsEqual(aPave1) && + aPB1->Pave2().IsEqual(aPave2) ) { + if(aPB1->Edge() > 0) { + aESplit = *(TopoDS_Edge*)&theDS->Shape(aPB1->Edge()); + break; + } } } @@ -2036,8 +1952,8 @@ Standard_Boolean FindFromVEdge(const BOPTools_Pave& thePrev // purpose: // ---------------------------------------------------------------------------------------------------- void RemoveEdges(const TopoDS_Compound& theSourceComp, - const TopTools_ListOfShape& theListToRemove, - TopoDS_Compound& theResultComp) { + const TopTools_ListOfShape& theListToRemove, + TopoDS_Compound& theResultComp) { BRep_Builder aBB; TopoDS_Compound aComp; aBB.MakeCompound(aComp); @@ -2062,66 +1978,64 @@ void RemoveEdges(const TopoDS_Compound& theSourceComp, // static function: FilterSectionEdges // purpose: // ---------------------------------------------------------------------------------------------------- -Standard_Boolean FilterSectionEdges(const BOPTools_SequenceOfCurves& theBCurves, - const TopoDS_Face& theSecPlane, - const BOPTools_DSFiller& theDSFiller, - TopoDS_Compound& theResult) { +Standard_Boolean FilterSectionEdges(const BOPDS_VectorOfCurve& theBCurves, + const TopoDS_Face& theSecPlane, + const BOPDS_PDS& theDS, + TopoDS_Compound& theResult) { theResult.Nullify(); - const BooleanOperations_ShapesDataStructure& aDS = theDSFiller.DS(); BRep_Builder aBB; aBB.MakeCompound(theResult); - Standard_Integer aNbCurves = theBCurves.Length(); + Standard_Integer aNbCurves = theBCurves.Extent(); Standard_Integer cit = 0; + BOPDS_ListIteratorOfListOfPaveBlock aPBIt; + + for(cit = 0; cit < aNbCurves; ++cit) { + const BOPDS_Curve& aBCurve = theBCurves(cit); + const BOPDS_ListOfPaveBlock& aSectEdges = aBCurve.PaveBlocks(); - for(cit = 1; cit <= aNbCurves; cit++) { - const BOPTools_Curve& aBCurve = theBCurves(cit); - const BOPTools_ListOfPaveBlock& aSectEdges = aBCurve.NewPaveBlocks(); - - BOPTools_ListIteratorOfListOfPaveBlock aPBIt(aSectEdges); - + aPBIt.Initialize(aSectEdges); for (; aPBIt.More(); aPBIt.Next()) { - BOPTools_PaveBlock& aPB = aPBIt.Value(); - Standard_Integer nSect = aPB.Edge(); - const TopoDS_Shape& aS = aDS.GetShape(nSect); + const Handle(BOPDS_PaveBlock)& aPB = aPBIt.Value(); + Standard_Integer nSect = aPB->Edge(); + const TopoDS_Shape& aS = theDS->Shape(nSect); TopoDS_Edge anEdge = TopoDS::Edge(aS); Standard_Boolean bAddEdge = Standard_True; if(!theSecPlane.IsNull()) { - IntTools_BeanFaceIntersector anIntersector(anEdge, theSecPlane); - Standard_Real f = 0., l = 0.; - BRep_Tool::Range(anEdge, f, l); - anIntersector.SetBeanParameters(f, l); - // - IntTools_Context aContext; - anIntersector.SetContext(&aContext); - // - anIntersector.Perform(); - - if(anIntersector.IsDone()) { - bAddEdge = Standard_False; - Standard_Integer r = 0; - - for(r = 1; r <= anIntersector.Result().Length(); r++) { - const IntTools_Range& aRange = anIntersector.Result().Value(r); - - if(((aRange.First() - f) < Precision::PConfusion()) && - ((l - aRange.Last()) < Precision::PConfusion())) { - bAddEdge = Standard_True; - } - } - } - else { -// cout << "not done..." << endl; - } - } + IntTools_BeanFaceIntersector anIntersector(anEdge, theSecPlane); + Standard_Real f = 0., l = 0.; + BRep_Tool::Range(anEdge, f, l); + anIntersector.SetBeanParameters(f, l); + // + Handle(IntTools_Context) aContext; + anIntersector.SetContext(aContext); + // + anIntersector.Perform(); + + if(anIntersector.IsDone()) { + bAddEdge = Standard_False; + Standard_Integer r = 0; + + for(r = 1; r <= anIntersector.Result().Length(); r++) { + const IntTools_Range& aRange = anIntersector.Result().Value(r); + + if(((aRange.First() - f) < Precision::PConfusion()) && + ((l - aRange.Last()) < Precision::PConfusion())) { + bAddEdge = Standard_True; + break; + }//if(((aRange.First() - f) < Precision::PConfusion()) && + }//for(r = 1; r <= anIntersector.Result().Length(); r++) { + }//if(anIntersector.IsDone()) { + }//if(!theSecPlane.IsNull()) { if(bAddEdge) { - aBB.Add(theResult, aS); + aBB.Add(theResult, aS); } - } - } + }//for (; aPBIt.More(); aPBIt.Next()) { + }//for(cit = 0; cit < aNbCurves; ++cit) { + return Standard_True; } @@ -2131,8 +2045,8 @@ Standard_Boolean FilterSectionEdges(const BOPTools_SequenceOfCurves& theBCurves, //purpose : //======================================================================= static Standard_Real ComputeAveragePlaneAndMaxDeviation(const TopoDS_Shape& aWire, - gp_Pln& thePlane, - Standard_Boolean& IsSingular) + gp_Pln& thePlane, + Standard_Boolean& IsSingular) { Standard_Integer N = 40, nedges = 0; @@ -2148,10 +2062,10 @@ static Standard_Real ComputeAveragePlaneAndMaxDeviation(const TopoDS_Shape& aWir BRepAdaptor_Curve aCurve(anEdge); GCPnts_UniformAbscissa Distribution( aCurve, N+1 ); for (i = 1; i <= N; i++) - { - Standard_Real par = Distribution.Parameter(i); - Pnts( ind++ ) = aCurve.Value(par); - } + { + Standard_Real par = Distribution.Parameter(i); + Pnts( ind++ ) = aCurve.Value(par); + } } gp_Ax2 Axe; @@ -2165,7 +2079,7 @@ static Standard_Real ComputeAveragePlaneAndMaxDeviation(const TopoDS_Shape& aWir { Standard_Real dist = thePlane.Distance( Pnts(i) ); if (dist > MaxDeviation) - MaxDeviation = dist; + MaxDeviation = dist; } return MaxDeviation; } @@ -2175,10 +2089,10 @@ static Standard_Real ComputeAveragePlaneAndMaxDeviation(const TopoDS_Shape& aWir //purpose : //======================================================================= static Standard_Boolean ChooseSection(const TopoDS_Shape& Comp, - const gp_Ax2& bis, - TopoDS_Shape& resWire, - gp_Pln& resPlane, - Standard_Boolean& IsSingular) + const gp_Ax2& bis, + TopoDS_Shape& resWire, + gp_Pln& resPlane, + Standard_Boolean& IsSingular) { IsSingular = Standard_False; Standard_Real TolDeviation = 0.01; //, TolConf = 1.e-4, TolAng = 1.e-5; @@ -2201,75 +2115,75 @@ static Standard_Boolean ChooseSection(const TopoDS_Shape& Comp, { TopExp_Explorer explo( OldComp, TopAbs_EDGE ); if (!explo.More()) - break; + break; TopoDS_Edge FirstEdge = TopoDS::Edge( explo.Current() ); TopoDS_Wire NewWire = BRepLib_MakeWire( FirstEdge ); B.Remove( OldComp, FirstEdge ); if (NewWire.Closed()) - { - Wseq.Append(NewWire); - continue; - } + { + Wseq.Append(NewWire); + continue; + } for (;;) - { - TopoDS_Vertex Extremity [2]; - TopExp::Vertices( NewWire, Extremity[0], Extremity[1] ); - if (Extremity[0].IsNull() || Extremity[1].IsNull()) - { - anError = Standard_True; - break; - } - TopTools_IndexedDataMapOfShapeListOfShape VEmap; - TopExp::MapShapesAndAncestors( OldComp, TopAbs_VERTEX, TopAbs_EDGE, VEmap ); - TopTools_ListOfShape Vedges [2]; - for (j = 0; j < 2; j++) - if (VEmap.Contains( Extremity[j] )) - Vedges[j] = VEmap.FindFromKey( Extremity[j] ); - if (Vedges[0].IsEmpty() && Vedges[1].IsEmpty()) - //no more edges in OldComp to continue NewWire - break; - Standard_Boolean Modified = Standard_False; - for (j = 0; j < 2; j++) - { - if (Vedges[j].Extent() == 1) - { - const TopoDS_Edge& anEdge = TopoDS::Edge( Vedges[j].First() ); - NewWire = BRepLib_MakeWire( NewWire, anEdge ); - B.Remove( OldComp, anEdge ); - Modified = Standard_True; - } - } - if (!Modified) //only multiple connections - { - ind = (Vedges[0].IsEmpty())? 1 : 0; - TopTools_SequenceOfShape Edges; - TopTools_ListIteratorOfListOfShape itl( Vedges[ind] ); - for (; itl.More(); itl.Next()) - Edges.Append( itl.Value() ); - Standard_Integer theind=0; - Standard_Real MinDeviation = RealLast(); - for (j = 1; j <= Edges.Length(); j++) - { - TopoDS_Wire aWire = BRepLib_MakeWire( NewWire, TopoDS::Edge(Edges(j)) ); - gp_Pln aPlane; - Standard_Boolean issing; - Standard_Real Deviation = ComputeAveragePlaneAndMaxDeviation( aWire, aPlane, issing ); - if (Deviation < MinDeviation) - { - MinDeviation = Deviation; - theind = j; - } - } - NewWire = BRepLib_MakeWire( NewWire, TopoDS::Edge(Edges(theind)) ); - B.Remove( OldComp, Edges(theind) ); - } - if (NewWire.Closed()) - break; - } + { + TopoDS_Vertex Extremity [2]; + TopExp::Vertices( NewWire, Extremity[0], Extremity[1] ); + if (Extremity[0].IsNull() || Extremity[1].IsNull()) + { + anError = Standard_True; + break; + } + TopTools_IndexedDataMapOfShapeListOfShape VEmap; + TopExp::MapShapesAndAncestors( OldComp, TopAbs_VERTEX, TopAbs_EDGE, VEmap ); + TopTools_ListOfShape Vedges [2]; + for (j = 0; j < 2; j++) + if (VEmap.Contains( Extremity[j] )) + Vedges[j] = VEmap.FindFromKey( Extremity[j] ); + if (Vedges[0].IsEmpty() && Vedges[1].IsEmpty()) + //no more edges in OldComp to continue NewWire + break; + Standard_Boolean Modified = Standard_False; + for (j = 0; j < 2; j++) + { + if (Vedges[j].Extent() == 1) + { + const TopoDS_Edge& anEdge = TopoDS::Edge( Vedges[j].First() ); + NewWire = BRepLib_MakeWire( NewWire, anEdge ); + B.Remove( OldComp, anEdge ); + Modified = Standard_True; + } + } + if (!Modified) //only multiple connections + { + ind = (Vedges[0].IsEmpty())? 1 : 0; + TopTools_SequenceOfShape Edges; + TopTools_ListIteratorOfListOfShape itl( Vedges[ind] ); + for (; itl.More(); itl.Next()) + Edges.Append( itl.Value() ); + Standard_Integer theind=0; + Standard_Real MinDeviation = RealLast(); + for (j = 1; j <= Edges.Length(); j++) + { + TopoDS_Wire aWire = BRepLib_MakeWire( NewWire, TopoDS::Edge(Edges(j)) ); + gp_Pln aPlane; + Standard_Boolean issing; + Standard_Real Deviation = ComputeAveragePlaneAndMaxDeviation( aWire, aPlane, issing ); + if (Deviation < MinDeviation) + { + MinDeviation = Deviation; + theind = j; + } + } + NewWire = BRepLib_MakeWire( NewWire, TopoDS::Edge(Edges(theind)) ); + B.Remove( OldComp, Edges(theind) ); + } + if (NewWire.Closed()) + break; + } Wseq.Append(NewWire); if (anError) - break; + break; } Standard_Real Deviation=0.; @@ -2278,38 +2192,38 @@ static Standard_Boolean ChooseSection(const TopoDS_Shape& Comp, if (!anError && !Explo.More()) { if (Wseq.Length() == 1) - { - resWire = Wseq.First(); - Deviation = ComputeAveragePlaneAndMaxDeviation( resWire, resPlane, IsSingular ); - return Standard_True; - } + { + resWire = Wseq.First(); + Deviation = ComputeAveragePlaneAndMaxDeviation( resWire, resPlane, IsSingular ); + return Standard_True; + } else - { - for (i = 1; i <= Wseq.Length(); i++) - { - TopoDS_Wire aWire = TopoDS::Wire( Wseq(i) ); - gp_Pln aPln; - Standard_Boolean issing; - Standard_Real aDeviation = - ComputeAveragePlaneAndMaxDeviation( aWire, aPln, issing ); - if (issing) - continue; - - Standard_Real Angle = aPln.Axis().Angle( bis.Axis() ); - if (Angle > M_PI/2) - Angle = M_PI - Angle; - - if (Angle < MinAngle) - { - MinAngle = Angle; - resWire = aWire; - resPlane = aPln; - Deviation = aDeviation; - } - } - if (Deviation <= TolDeviation) - return Standard_True; - } + { + for (i = 1; i <= Wseq.Length(); i++) + { + TopoDS_Wire aWire = TopoDS::Wire( Wseq(i) ); + gp_Pln aPln; + Standard_Boolean issing; + Standard_Real aDeviation = + ComputeAveragePlaneAndMaxDeviation( aWire, aPln, issing ); + if (issing) + continue; + + Standard_Real Angle = aPln.Axis().Angle( bis.Axis() ); + if (Angle > M_PI/2) + Angle = M_PI - Angle; + + if (Angle < MinAngle) + { + MinAngle = Angle; + resWire = aWire; + resPlane = aPln; + Deviation = aDeviation; + } + } + if (Deviation <= TolDeviation) + return Standard_True; + } } return Standard_False; //end of simplest case @@ -2320,9 +2234,9 @@ static Standard_Boolean ChooseSection(const TopoDS_Shape& Comp, //purpose : //======================================================================= static Standard_Boolean ChoosePlane(const TopoDS_Shape& Comp, - const gp_Ax2& bis, - gp_Pln& resPlane, - TopoDS_Compound& NewComp) + const gp_Ax2& bis, + gp_Pln& resPlane, + TopoDS_Compound& NewComp) { Standard_Real TolConf = 1.e-4, TolAng = 1.e-5; @@ -2342,15 +2256,15 @@ static Standard_Boolean ChoosePlane(const TopoDS_Shape& Comp, BRepAdaptor_Curve aCurve(anEdge); GCPnts_UniformAbscissa Distribution( aCurve, N+1 ); for (i = 1; i <= N/4; i++) - { - Standard_Real par = Distribution.Parameter(i); - Points( Eind*2, i ) = aCurve.Value(par); - } + { + Standard_Real par = Distribution.Parameter(i); + Points( Eind*2, i ) = aCurve.Value(par); + } for (i = 3*N/4+2; i <= N+1; i++) - { - Standard_Real par = Distribution.Parameter(i); - Points( Eind*2+1, i-3*N/4-1 ) = aCurve.Value(par); - } + { + Standard_Real par = Distribution.Parameter(i); + Points( Eind*2+1, i-3*N/4-1 ) = aCurve.Value(par); + } } TColgp_Array1OfPnt Origins( 0, NumberOfEdges*2-1 ); @@ -2362,22 +2276,22 @@ static Standard_Boolean ChoosePlane(const TopoDS_Shape& Comp, { TColgp_Array1OfPnt pnts( 1, N/4 ); for (i = 1; i <= N/4; i++) - pnts(i) = Points( ind, i ); + pnts(i) = Points( ind, i ); gp_Ax2 Axe; GeomLib::AxeOfInertia( pnts, Axe, IsSingular(ind) ); if (!IsSingular(ind)) - { - Origins(ind) = Axe.Location(); - Normals(ind) = Axe.Direction(); - Standard_Real Angle = bis.Angle( Axe ); - if (Angle > M_PI/2) - Angle = M_PI - Angle; - if (Angle < MinAngle) - { - MinAngle = Angle; - MinInd = ind; - } - } + { + Origins(ind) = Axe.Location(); + Normals(ind) = Axe.Direction(); + Standard_Real Angle = bis.Angle( Axe ); + if (Angle > M_PI/2) + Angle = M_PI - Angle; + if (Angle < MinAngle) + { + MinAngle = Angle; + MinInd = ind; + } + } } gp_Ax2 TheAxe( Origins(MinInd), Normals(MinInd) ); @@ -2387,15 +2301,15 @@ static Standard_Boolean ChoosePlane(const TopoDS_Shape& Comp, for (ind = 0; ind < NumberOfEdges*2; ind++) if (!IsSingular(ind)) { - Standard_Real Angle = Normals(ind).Angle( TheAxe.Direction() ); - if (Angle > M_PI/2) - Angle = M_PI - Angle; - if (Angle <= MaxAngleWithPln) - { - iseq.Append(ind); - for (j = 1; j <= N/4; j++) - Pseq.Append( Points(ind,j) ); - } + Standard_Real Angle = Normals(ind).Angle( TheAxe.Direction() ); + if (Angle > M_PI/2) + Angle = M_PI - Angle; + if (Angle <= MaxAngleWithPln) + { + iseq.Append(ind); + for (j = 1; j <= N/4; j++) + Pseq.Append( Points(ind,j) ); + } } TColgp_Array1OfPnt Parray( 1, Pseq.Length() ); @@ -2412,12 +2326,12 @@ static Standard_Boolean ChoosePlane(const TopoDS_Shape& Comp, { Standard_Integer ind0 = iseq(i); if (IsEven(ind0) && i < iseq.Length() && iseq(i+1) == ind0+1) //the whole edge - { - B.Add( NewComp, Eseq(ind0/2+1) ); - i += 2; - } + { + B.Add( NewComp, Eseq(ind0/2+1) ); + i += 2; + } else - i++; + i++; } Standard_Integer slen = Pseq.Length(); @@ -2426,50 +2340,50 @@ static Standard_Boolean ChoosePlane(const TopoDS_Shape& Comp, Standard_Integer IndSing = -1, IndNotSing = -1; gp_Lin aLine; if (IsSingular(ind) && IsSingular(ind+1)) - { - Standard_Boolean OnPlane0 = Standard_False, OnPlane1 = Standard_False; - aLine = gce_MakeLin( Points(ind, 1), Points(ind, N/4) ); - if (resPlane.Contains( aLine, TolConf, TolAng )) - { - for (j = 1; j <= N/4; j++) - Pseq.Append( Points(ind,j) ); - OnPlane0 = Standard_True; - } - aLine = gce_MakeLin( Points(ind+1, 1), Points(ind+1, N/4) ); - if (resPlane.Contains( aLine, TolConf, TolAng )) - { - for (j = 1; j <= N/4; j++) - Pseq.Append( Points(ind+1,j) ); - OnPlane1 = Standard_True; - } - if (OnPlane0 && OnPlane1) - B.Add( NewComp, Eseq(ind/2+1) ); - } + { + Standard_Boolean OnPlane0 = Standard_False, OnPlane1 = Standard_False; + aLine = gce_MakeLin( Points(ind, 1), Points(ind, N/4) ); + if (resPlane.Contains( aLine, TolConf, TolAng )) + { + for (j = 1; j <= N/4; j++) + Pseq.Append( Points(ind,j) ); + OnPlane0 = Standard_True; + } + aLine = gce_MakeLin( Points(ind+1, 1), Points(ind+1, N/4) ); + if (resPlane.Contains( aLine, TolConf, TolAng )) + { + for (j = 1; j <= N/4; j++) + Pseq.Append( Points(ind+1,j) ); + OnPlane1 = Standard_True; + } + if (OnPlane0 && OnPlane1) + B.Add( NewComp, Eseq(ind/2+1) ); + } else if (IsSingular(ind)) - { - IndSing = ind; - IndNotSing = ind+1; - } + { + IndSing = ind; + IndNotSing = ind+1; + } else if (IsSingular(ind+1)) - { - IndNotSing = ind; - IndSing = ind+1; - } + { + IndNotSing = ind; + IndSing = ind+1; + } if (IndSing != -1 && IndNotSing != -1) - { - aLine = gce_MakeLin( Points(IndSing, 1), Points(IndSing, N/4) ); - if (resPlane.Contains( aLine, TolConf, TolAng )) - { - for (j = 1; j <= N/4; j++) - Pseq.Append( Points(IndSing,j) ); - - for (i = 1; i <= iseq.Length(); i++) - if (iseq(i) == IndNotSing) - break; - if (i <= iseq.Length()) - B.Add( NewComp, Eseq(ind/2+1) ); - } - } + { + aLine = gce_MakeLin( Points(IndSing, 1), Points(IndSing, N/4) ); + if (resPlane.Contains( aLine, TolConf, TolAng )) + { + for (j = 1; j <= N/4; j++) + Pseq.Append( Points(IndSing,j) ); + + for (i = 1; i <= iseq.Length(); i++) + if (iseq(i) == IndNotSing) + break; + if (i <= iseq.Length()) + B.Add( NewComp, Eseq(ind/2+1) ); + } + } } //Recompute the axe of plane @@ -2477,7 +2391,7 @@ static Standard_Boolean ChoosePlane(const TopoDS_Shape& Comp, { TColgp_Array1OfPnt Parray2( 1, Pseq.Length() ); for (i = 1; i <= Parray2.Length(); i++) - Parray2(i) = Pseq(i); + Parray2(i) = Pseq(i); GeomLib::AxeOfInertia( Parray2, TheAxe, issing ); resPlane = gp_Pln( TheAxe ); } diff --git a/src/BRepOffset/BRepOffset.cdl b/src/BRepOffset/BRepOffset.cdl index e9f99e8608..96cfc1d780 100755 --- a/src/BRepOffset/BRepOffset.cdl +++ b/src/BRepOffset/BRepOffset.cdl @@ -33,7 +33,10 @@ uses TCollection, TopTools, GeomAbs, - BRepAlgo + BRepAlgo, + BOPAlgo, + BOPDS, + BOPTools is enumeration Type is diff --git a/src/BRepOffset/BRepOffset_Tool.cxx b/src/BRepOffset/BRepOffset_Tool.cxx index c2a1918fa7..3e3bef38fd 100755 --- a/src/BRepOffset/BRepOffset_Tool.cxx +++ b/src/BRepOffset/BRepOffset_Tool.cxx @@ -126,26 +126,11 @@ //tma: for new boolean operation #include -#include #include #include #include #include #include -//#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include #include #include @@ -157,6 +142,9 @@ #include #include +#include +#include +#include #ifdef DRAW #include @@ -181,8 +169,8 @@ static Standard_Integer NbExtE = 1; //======================================================================= void BRepOffset_Tool::EdgeVertices (const TopoDS_Edge& E, - TopoDS_Vertex& V1, - TopoDS_Vertex& V2) + TopoDS_Vertex& V1, + TopoDS_Vertex& V2) { if (E.Orientation() == TopAbs_REVERSED) { TopExp::Vertices(E,V2,V1); @@ -198,8 +186,8 @@ void BRepOffset_Tool::EdgeVertices (const TopoDS_Edge& E, //======================================================================= TopAbs_Orientation BRepOffset_Tool::OriEdgeInFace (const TopoDS_Edge& E, - const TopoDS_Face& F ) - + const TopoDS_Face& F ) + { TopExp_Explorer Exp; Exp.Init(F.Oriented(TopAbs_FORWARD),TopAbs_EDGE); @@ -220,10 +208,10 @@ TopAbs_Orientation BRepOffset_Tool::OriEdgeInFace (const TopoDS_Edge& E, //======================================================================= static void FindPeriod (const TopoDS_Face& F, - Standard_Real& umin, - Standard_Real& umax, - Standard_Real& vmin, - Standard_Real& vmax) + Standard_Real& umin, + Standard_Real& umax, + Standard_Real& vmin, + Standard_Real& vmax) { Bnd_Box2d B; @@ -258,8 +246,8 @@ static void FindPeriod (const TopoDS_Face& F, //======================================================================= static void PutInBounds (const TopoDS_Face& F, - const TopoDS_Edge& E, - Handle(Geom2d_Curve)& C2d) + const TopoDS_Edge& E, + Handle(Geom2d_Curve)& C2d) { Standard_Real umin,umax,vmin,vmax; Standard_Real f,l; @@ -304,8 +292,8 @@ static void PutInBounds (const TopoDS_Face& F, Standard_Real d2 = umin - minC + period; if (d2 < d1) du =-period; if ( du != 0.) { - gp_Vec2d T2(du,0.); - C2d->Translate(T2); + gp_Vec2d T2(du,0.); + C2d->Translate(T2); } } } @@ -338,8 +326,8 @@ static void PutInBounds (const TopoDS_Face& F, Standard_Real d2 = vmin - minC + period; if (d2 < d1) dv =-period; if ( dv != 0.) { - gp_Vec2d T2(0.,dv); - C2d->Translate(T2); + gp_Vec2d T2(0.,dv); + C2d->Translate(T2); } } } @@ -368,7 +356,7 @@ Standard_Real BRepOffset_Tool::Gabarit(const Handle(Geom_Curve)& aCurve) //======================================================================= static void BuildPCurves (const TopoDS_Edge& E, - const TopoDS_Face& F) + const TopoDS_Face& F) { Standard_Real ff,ll; Handle (Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface (E,F,ff,ll); @@ -395,67 +383,67 @@ static void BuildPCurves (const TopoDS_Edge& E, TopExp_Explorer Explo; Explo.Init( theFace, TopAbs_EDGE ); for (; Explo.More(); Explo.Next()) - { - TopoDS_Edge anEdge = TopoDS::Edge( Explo.Current() ); - BRepAdaptor_Curve aCurve( anEdge ); - Extrema_ExtPC fextr( fpoint, aCurve ); - if (!fextr.IsDone() || fextr.NbExt() < 1) - continue; - Standard_Real dist2, dist2min = RealLast(); + { + TopoDS_Edge anEdge = TopoDS::Edge( Explo.Current() ); + BRepAdaptor_Curve aCurve( anEdge ); + Extrema_ExtPC fextr( fpoint, aCurve ); + if (!fextr.IsDone() || fextr.NbExt() < 1) + continue; + Standard_Real dist2, dist2min = RealLast(); Standard_Integer i; - for (i = 1; i <= fextr.NbExt(); i++) - { - dist2 = fextr.SquareDistance(i); - if (dist2 < dist2min) - { - dist2min = dist2; - U1 = fextr.Point(i).Parameter(); - } - } - if (dist2min > TolProj * TolProj) - continue; - Extrema_ExtPC lextr( lpoint, aCurve ); - if (!lextr.IsDone() || lextr.NbExt() <1) - continue; - dist2min = RealLast(); - for (i = 1; i <= lextr.NbExt(); i++) - { - dist2 = lextr.SquareDistance(i); - if (dist2 < dist2min) - { - dist2min = dist2; - U2 = lextr.Point(i).Parameter(); - } - } - if (dist2min <= TolProj * TolProj) - { - theEdge = anEdge; - break; - } - } // for (; Explo.More(); Explo.Current()) + for (i = 1; i <= fextr.NbExt(); i++) + { + dist2 = fextr.SquareDistance(i); + if (dist2 < dist2min) + { + dist2min = dist2; + U1 = fextr.Point(i).Parameter(); + } + } + if (dist2min > TolProj * TolProj) + continue; + Extrema_ExtPC lextr( lpoint, aCurve ); + if (!lextr.IsDone() || lextr.NbExt() <1) + continue; + dist2min = RealLast(); + for (i = 1; i <= lextr.NbExt(); i++) + { + dist2 = lextr.SquareDistance(i); + if (dist2 < dist2min) + { + dist2min = dist2; + U2 = lextr.Point(i).Parameter(); + } + } + if (dist2min <= TolProj * TolProj) + { + theEdge = anEdge; + break; + } + } // for (; Explo.More(); Explo.Current()) if (! theEdge.IsNull()) - { - //Construction of pcurve - if (U2 < U1) - { - Standard_Real temp = U1; - U1 = U2; - U2 = temp; - } - Standard_Real f, l; - C2d = BRep_Tool::CurveOnSurface( theEdge, theFace, f, l ); - C2d = new Geom2d_TrimmedCurve( C2d, U1, U2 ); - - if (theSurf->IsUPeriodic() || theSurf->IsVPeriodic()) - PutInBounds( F, E, C2d ); - - BRep_Builder B; - B.UpdateEdge( E, C2d, F, BRep_Tool::Tolerance(E) ); - BRepLib::SameRange( E ); - - return; - } + { + //Construction of pcurve + if (U2 < U1) + { + Standard_Real temp = U1; + U1 = U2; + U2 = temp; + } + Standard_Real f, l; + C2d = BRep_Tool::CurveOnSurface( theEdge, theFace, f, l ); + C2d = new Geom2d_TrimmedCurve( C2d, U1, U2 ); + + if (theSurf->IsUPeriodic() || theSurf->IsVPeriodic()) + PutInBounds( F, E, C2d ); + + BRep_Builder B; + B.UpdateEdge( E, C2d, F, BRep_Tool::Tolerance(E) ); + BRepLib::SameRange( E ); + + return; + } } // if (typS == ... Handle(BRepAdaptor_HSurface) HS = new BRepAdaptor_HSurface(AS); @@ -517,10 +505,10 @@ static void BuildPCurves (const TopoDS_Edge& E, //======================================================================= void BRepOffset_Tool::OrientSection (const TopoDS_Edge& E, - const TopoDS_Face& F1, - const TopoDS_Face& F2, - TopAbs_Orientation& O1, - TopAbs_Orientation& O2) + const TopoDS_Face& F1, + const TopoDS_Face& F2, + TopAbs_Orientation& O1, + TopAbs_Orientation& O2) { TopLoc_Location L; Standard_Real f,l; @@ -579,9 +567,9 @@ void BRepOffset_Tool::OrientSection (const TopoDS_Edge& E, //======================================================================= Standard_Boolean BRepOffset_Tool::HasCommonShapes (const TopoDS_Face& F1, - const TopoDS_Face& F2, - TopTools_ListOfShape& LE, - TopTools_ListOfShape& LV) + const TopoDS_Face& F2, + TopTools_ListOfShape& LE, + TopTools_ListOfShape& LV) { Standard_Boolean Common = Standard_False; LE.Clear(); LV.Clear(); @@ -594,8 +582,8 @@ Standard_Boolean BRepOffset_Tool::HasCommonShapes (const TopoDS_Face& F1, exp2.Init(F2,TopAbs_EDGE); for (; exp2.More(); exp2.Next()) { if (exp1.Current().IsSame(exp2.Current())) { - Common = Standard_True; - LE.Append(exp1.Current()); + Common = Standard_True; + LE.Append(exp1.Current()); } } } @@ -604,8 +592,8 @@ Standard_Boolean BRepOffset_Tool::HasCommonShapes (const TopoDS_Face& F1, exp2.Init(F2,TopAbs_EDGE); for (exp2.Init(F2,TopAbs_VERTEX); exp2.More(); exp2.Next()) { if (exp1.Current().IsSame(exp2.Current())) { - Common = Standard_True; - LV.Append(exp1.Current()); + Common = Standard_True; + LV.Append(exp1.Current()); } } } @@ -636,9 +624,9 @@ static Standard_Boolean ToSmall (const Handle(Geom_Curve)& C) //======================================================================= static Standard_Boolean IsOnSurface(const Handle(Geom_Curve)& C, - const Handle(Geom_Surface)& S, - Standard_Real TolConf, - Standard_Real& TolReached) + const Handle(Geom_Surface)& S, + Standard_Real TolConf, + Standard_Real& TolReached) { Standard_Real f = C->FirstParameter(); Standard_Real l = C->LastParameter(); @@ -656,11 +644,11 @@ static Standard_Boolean IsOnSurface(const Handle(Geom_Curve)& C, { gp_Ax3 Ax = AS.Plane().Position(); for ( Standard_Integer i = 0; i < n; i++) { - P = C->Value(f+i*du); - ElSLib::PlaneParameters(Ax,P,U,V); - TolReached = P.Distance(ElSLib::PlaneValue(U,V,Ax)); - if ( TolReached > TolConf) - return Standard_False; + P = C->Value(f+i*du); + ElSLib::PlaneParameters(Ax,P,U,V); + TolReached = P.Distance(ElSLib::PlaneValue(U,V,Ax)); + if ( TolReached > TolConf) + return Standard_False; } break; } @@ -669,11 +657,11 @@ static Standard_Boolean IsOnSurface(const Handle(Geom_Curve)& C, gp_Ax3 Ax = AS.Cylinder().Position(); Standard_Real Rad = AS.Cylinder().Radius(); for ( Standard_Integer i = 0; i < n; i++) { - P = C->Value(f+i*du); - ElSLib::CylinderParameters(Ax,Rad,P,U,V); - TolReached = P.Distance(ElSLib::CylinderValue(U,V,Ax,Rad)); - if ( TolReached > TolConf) - return Standard_False; + P = C->Value(f+i*du); + ElSLib::CylinderParameters(Ax,Rad,P,U,V); + TolReached = P.Distance(ElSLib::CylinderValue(U,V,Ax,Rad)); + if ( TolReached > TolConf) + return Standard_False; } break; } @@ -683,11 +671,11 @@ static Standard_Boolean IsOnSurface(const Handle(Geom_Curve)& C, Standard_Real Rad = AS.Cone().RefRadius(); Standard_Real Alp = AS.Cone().SemiAngle(); for ( Standard_Integer i = 0; i < n; i++) { - P = C->Value(f+i*du); - ElSLib::ConeParameters(Ax,Rad,Alp,P,U,V); - TolReached = P.Distance(ElSLib::ConeValue(U,V,Ax,Rad,Alp)); - if ( TolReached > TolConf) - return Standard_False; + P = C->Value(f+i*du); + ElSLib::ConeParameters(Ax,Rad,Alp,P,U,V); + TolReached = P.Distance(ElSLib::ConeValue(U,V,Ax,Rad,Alp)); + if ( TolReached > TolConf) + return Standard_False; } break; } @@ -696,11 +684,11 @@ static Standard_Boolean IsOnSurface(const Handle(Geom_Curve)& C, gp_Ax3 Ax = AS.Sphere().Position(); Standard_Real Rad = AS.Sphere().Radius(); for ( Standard_Integer i = 0; i < n; i++) { - P = C->Value(f+i*du); - ElSLib::SphereParameters(Ax,Rad,P,U,V); - TolReached = P.Distance(ElSLib::SphereValue(U,V,Ax,Rad)); - if ( TolReached > TolConf) - return Standard_False; + P = C->Value(f+i*du); + ElSLib::SphereParameters(Ax,Rad,P,U,V); + TolReached = P.Distance(ElSLib::SphereValue(U,V,Ax,Rad)); + if ( TolReached > TolConf) + return Standard_False; } break; } @@ -710,11 +698,11 @@ static Standard_Boolean IsOnSurface(const Handle(Geom_Curve)& C, Standard_Real R1 = AS.Torus().MajorRadius(); Standard_Real R2 = AS.Torus().MinorRadius(); for ( Standard_Integer i = 0; i < n; i++) { - P = C->Value(f+i*du); - ElSLib::TorusParameters(Ax,R1,R2,P,U,V); - TolReached = P.Distance(ElSLib::TorusValue(U,V,Ax,R1,R2)); - if ( TolReached > TolConf) - return Standard_False; + P = C->Value(f+i*du); + ElSLib::TorusParameters(Ax,R1,R2,P,U,V); + TolReached = P.Distance(ElSLib::TorusValue(U,V,Ax,R1,R2)); + if ( TolReached > TolConf) + return Standard_False; } break; } @@ -735,10 +723,10 @@ static Standard_Boolean IsOnSurface(const Handle(Geom_Curve)& C, //======================================================================= void BRepOffset_Tool::PipeInter(const TopoDS_Face& F1, - const TopoDS_Face& F2, - TopTools_ListOfShape& L1, - TopTools_ListOfShape& L2, - const TopAbs_State Side) + const TopoDS_Face& F2, + TopTools_ListOfShape& L1, + TopTools_ListOfShape& L2, + const TopAbs_State Side) { #ifdef DRAW if (AffichInter) { @@ -767,34 +755,34 @@ void BRepOffset_Tool::PipeInter(const TopoDS_Face& F1, if (ToSmall(CI)) continue; TopoDS_Edge E = BRepLib_MakeEdge(CI); if (Inter.HasLineOnS1(i)) { - Handle(Geom2d_Curve) C2 = Inter.LineOnS1(i); - PutInBounds (F1,E,C2); - B.UpdateEdge (E,C2,F1,BRep_Tool::Tolerance(E)); + Handle(Geom2d_Curve) C2 = Inter.LineOnS1(i); + PutInBounds (F1,E,C2); + B.UpdateEdge (E,C2,F1,BRep_Tool::Tolerance(E)); } else { - BuildPCurves (E,F1); + BuildPCurves (E,F1); } if (Inter.HasLineOnS2(i)) { - Handle(Geom2d_Curve) C2 = Inter.LineOnS2(i); - PutInBounds (F2,E,C2); - B.UpdateEdge (E,C2,F2,BRep_Tool::Tolerance(E)); + Handle(Geom2d_Curve) C2 = Inter.LineOnS2(i); + PutInBounds (F2,E,C2); + B.UpdateEdge (E,C2,F2,BRep_Tool::Tolerance(E)); } else { - BuildPCurves (E,F2); + BuildPCurves (E,F2); } OrientSection (E,F1,F2,O1,O2); if (Side == TopAbs_OUT) { - O1 = TopAbs::Reverse(O1); - O2 = TopAbs::Reverse(O2); + O1 = TopAbs::Reverse(O1); + O2 = TopAbs::Reverse(O2); } L1.Append (E.Oriented(O1)); L2.Append (E.Oriented(O2)); #ifdef DRAW if (AffichInter) { // POP pour NT - char* name = new char[100]; - sprintf(name,"EI_%d",NbNewEdges++); - DBRep::Set(name,E.Oriented(O1)); + char* name = new char[100]; + sprintf(name,"EI_%d",NbNewEdges++); + DBRep::Set(name,E.Oriented(O1)); } #endif } @@ -808,75 +796,61 @@ void BRepOffset_Tool::PipeInter(const TopoDS_Face& F1, //======================================================================= static Standard_Boolean IsAutonomVertex(const TopoDS_Shape& aVertex, - const TopoDS_Shape& F1, - const TopoDS_Shape& F2, - const BooleanOperations_ShapesDataStructure& theDS, - const BOPTools_PaveFiller& thePaveFiller) + const TopoDS_Shape& F1, + const TopoDS_Shape& F2, + const BOPDS_PDS& pDS) { - Standard_Integer i, index = theDS.ShapeIndex( aVertex, 1 ); - if (index == 0) - { - index = theDS.ShapeIndex( aVertex, 2 ); - if (index == 0) - { - for (i = theDS.NumberOfSourceShapes()+1; i <= theDS.NumberOfInsertedShapes(); i++) - { - const TopoDS_Shape& aShape = theDS.GetShape(i); - if (aVertex.IsSame(aShape)) - { - index = i; - break; - } - } - } + Standard_Integer index, indF1, indF2; + Standard_Integer aNbVVs, aNbEEs, aNbEFs, aInt; + // + index = pDS->Index(aVertex); + // + if (!pDS->IsNewShape(index)) { + return Standard_False; + } + // + indF1 = pDS->Index(F1); + indF2 = pDS->Index(F2); + // + + //check if vertex with index "index" is created in FF interference + //VV + BOPDS_VectorOfInterfVV& aVVs=pDS->InterfVV(); + aNbVVs = aVVs.Extent(); + for(aInt = 0; aInt < aNbVVs; aInt++) { + const BOPDS_InterfVV& aVV = aVVs(aInt); + if (aVV.HasIndexNew()) { + if (aVV.IndexNew() == index) { + return Standard_False; + } } + } - Standard_Integer indF1 = theDS.ShapeIndex( F1, 1 ); - Standard_Integer indF2 = theDS.ShapeIndex( F2, 2 ); + //EE + BOPDS_VectorOfInterfEE& aEEs=pDS->InterfEE(); + aNbEEs = aEEs.Extent(); + for(aInt = 0; aInt < aNbEEs; aInt++) { + const BOPDS_InterfEE& aEE = aEEs(aInt); + IntTools_CommonPrt aCP = aEE.CommonPart(); + if(aCP.Type() == TopAbs_VERTEX) { + if (aEE.IndexNew() == index) { + return Standard_False; + } + } + } - BooleanOperations_KindOfInterference theTypeInterf; - const BOPTools_PavePool& thePavePool = thePaveFiller.PavePool(); - BOPTools_ListIteratorOfListOfPave itpave; - for (i = 1; i <= thePavePool.Length(); i++) - { - const BOPTools_ListOfPave& aPaveList = thePavePool(i).Set(); - for (itpave.Initialize( aPaveList ); itpave.More(); itpave.Next()) - { - BOPTools_Pave aPave = itpave.Value(); - if (aPave.Index() == index) - { - theTypeInterf = aPave.Type(); - if (theTypeInterf != BooleanOperations_SurfaceSurface && - theTypeInterf != BooleanOperations_UnknownInterference) - return Standard_False; - } - } - } - - BOPTools_PaveFiller * pPF = (BOPTools_PaveFiller*) &thePaveFiller; - BOPTools_PaveFiller& thePF = *pPF; - BOPTools_CArray1OfSSInterference& aFFs = thePF.InterfPool()->SSInterferences(); - Standard_Integer aNbFFs=aFFs.Extent(); - for (i = 1; i <= aNbFFs; i++) - { - BOPTools_SSInterference& aFFi = aFFs(i); - - if (aFFi.Index1() == indF1 && aFFi.Index2() == indF2) - { - const BOPTools_ListOfPave& aPaveList = aFFi.NewPaveSet().Set(); - for (itpave.Initialize( aPaveList ); itpave.More(); itpave.Next()) - { - BOPTools_Pave aPave = itpave.Value(); - if (aPave.Index() == index) - { - theTypeInterf = aPave.Type(); - if (theTypeInterf != BooleanOperations_SurfaceSurface && - theTypeInterf != BooleanOperations_UnknownInterference) - return Standard_False; - } - } - } + //EF + BOPDS_VectorOfInterfEF& aEFs=pDS->InterfEF(); + aNbEFs = aEFs.Extent(); + for(aInt = 0; aInt < aNbEFs; aInt++) { + const BOPDS_InterfEF& aEF = aEFs(aInt); + IntTools_CommonPrt aCP = aEF.CommonPart(); + if(aCP.Type() == TopAbs_VERTEX) { + if (aEF.IndexNew() == index) { + return Standard_False; + } } + } return Standard_True; } @@ -888,10 +862,10 @@ static Standard_Boolean IsAutonomVertex(const TopoDS_Shape& aVertex, //======================================================================= static Standard_Boolean AreConnex(const TopoDS_Wire& W1, - const TopoDS_Wire& W2, - const TopoDS_Shape& F1, - const TopoDS_Shape& F2, - const BOPTools_DSFiller* pDF) + const TopoDS_Wire& W2, + const TopoDS_Shape& F1, + const TopoDS_Shape& F2, + const BOPDS_PDS& pDS) { TopoDS_Vertex V11, V12, V21, V22; TopExp::Vertices( W1, V11, V12 ); @@ -902,49 +876,49 @@ static Standard_Boolean AreConnex(const TopoDS_Wire& W1, { Standard_Boolean isCV1 = V11.IsSame(V21) || V11.IsSame(V22); Standard_Boolean isCV2 = V12.IsSame(V21) || V12.IsSame(V22); - if (isCV1 && !IsAutonomVertex(V11, F1, F2, pDF->DS(), pDF->PaveFiller())) - { - if (!isCV2) - return Standard_False; - if (!IsAutonomVertex(V12, F1, F2, pDF->DS(), pDF->PaveFiller())) - return Standard_False; - } - if (!isCV1 && !IsAutonomVertex(V12, F1, F2, pDF->DS(), pDF->PaveFiller())) - return Standard_False; + if (isCV1 && !IsAutonomVertex(V11, F1, F2, pDS)) + { + if (!isCV2) + return Standard_False; + if (!IsAutonomVertex(V12, F1, F2, pDS)) + return Standard_False; + } + if (!isCV1 && !IsAutonomVertex(V12, F1, F2, pDS)) + return Standard_False; TopoDS_Vertex CV = (V11.IsSame(V21) || V11.IsSame(V22))? V11 : V12; TopoDS_Edge E1, E2; TopoDS_Iterator itw( W1 ); for (; itw.More(); itw.Next()) - { - E1 = TopoDS::Edge(itw.Value()); - TopoDS_Vertex V1, V2; - TopExp::Vertices( E1, V1, V2 ); - if (V1.IsSame(CV) || V2.IsSame(CV)) - break; - } + { + E1 = TopoDS::Edge(itw.Value()); + TopoDS_Vertex V1, V2; + TopExp::Vertices( E1, V1, V2 ); + if (V1.IsSame(CV) || V2.IsSame(CV)) + break; + } itw.Initialize( W2 ); E2 = TopoDS::Edge(itw.Value()); Standard_Real f, l; Handle(Geom_Curve) C1 = BRep_Tool::Curve( E1, f, l ); if (C1->IsInstance(STANDARD_TYPE(Geom_TrimmedCurve))) - C1 = (*((Handle(Geom_TrimmedCurve)*)&C1))->BasisCurve(); + C1 = (*((Handle(Geom_TrimmedCurve)*)&C1))->BasisCurve(); Handle(Geom_Curve) C2 = BRep_Tool::Curve( E2, f, l ); if (C2->IsInstance(STANDARD_TYPE(Geom_TrimmedCurve))) - C2 = (*((Handle(Geom_TrimmedCurve)*)&C2))->BasisCurve(); + C2 = (*((Handle(Geom_TrimmedCurve)*)&C2))->BasisCurve(); if (C1->IsInstance(STANDARD_TYPE(Geom_Line)) && - C2->IsInstance(STANDARD_TYPE(Geom_Line))) - { - Handle(Geom_Line) L1 = *((Handle(Geom_Line)*) &C1); - gp_Ax1 Axis1 = L1->Position(); - Handle(Geom_Line) L2 = *((Handle(Geom_Line)*) &C2); - gp_Ax1 Axis2 = L2->Position(); - if (! Axis1.IsParallel( Axis2, Precision::Angular() )) - return Standard_False; - } + C2->IsInstance(STANDARD_TYPE(Geom_Line))) + { + Handle(Geom_Line) L1 = *((Handle(Geom_Line)*) &C1); + gp_Ax1 Axis1 = L1->Position(); + Handle(Geom_Line) L2 = *((Handle(Geom_Line)*) &C2); + gp_Ax1 Axis2 = L2->Position(); + if (! Axis1.IsParallel( Axis2, Precision::Angular() )) + return Standard_False; + } return Standard_True; } @@ -958,7 +932,7 @@ static Standard_Boolean AreConnex(const TopoDS_Wire& W1, //======================================================================= static Standard_Boolean AreClosed(const TopoDS_Edge& E1, - const TopoDS_Edge& E2) + const TopoDS_Edge& E2) { TopoDS_Vertex V11, V12, V21, V22; TopExp::Vertices( E1, V11, V12 ); @@ -977,10 +951,10 @@ static Standard_Boolean AreClosed(const TopoDS_Edge& E1, //======================================================================= static Standard_Boolean BSplineEdges(const TopoDS_Edge& E1, - const TopoDS_Edge& E2, - const Standard_Integer par1, - const Standard_Integer par2, - Standard_Real& angle) + const TopoDS_Edge& E2, + const Standard_Integer par1, + const Standard_Integer par2, + Standard_Real& angle) { Standard_Real first1, last1, first2, last2, Param1, Param2; @@ -1019,7 +993,7 @@ static Standard_Boolean BSplineEdges(const TopoDS_Edge& E1, //======================================================================= static Standard_Real AngleWireEdge(const TopoDS_Wire& aWire, - const TopoDS_Edge& anEdge) + const TopoDS_Edge& anEdge) { TopoDS_Vertex V11, V12, V21, V22, CV; TopExp::Vertices( aWire, V11, V12 ); @@ -1033,11 +1007,11 @@ static Standard_Real AngleWireEdge(const TopoDS_Wire& aWire, TopoDS_Vertex v1, v2; TopExp::Vertices( FirstEdge, v1, v2 ); if (v1.IsSame(CV) || v2.IsSame(CV)) - { - V11 = v1; - V12 = v2; - break; - } + { + V11 = v1; + V12 = v2; + break; + } } Standard_Real Angle; if (V11.IsSame(CV) && V21.IsSame(CV)) @@ -1074,16 +1048,16 @@ static void ReconstructPCurves(const TopoDS_Edge& anEdge) { Handle( BRep_CurveRepresentation ) CurveRep = itcr.Value(); if (CurveRep->IsCurveOnSurface()) - { - Handle(Geom_Surface) theSurf = CurveRep->Surface(); - TopLoc_Location theLoc = CurveRep->Location(); - theLoc = anEdge.Location() * theLoc; - theSurf = Handle(Geom_Surface)::DownCast - (theSurf->Transformed(theLoc.Transformation())); - Handle(Geom2d_Curve) ProjPCurve = - GeomProjLib::Curve2d( C3d, f, l, theSurf ); - CurveRep->PCurve( ProjPCurve ); - } + { + Handle(Geom_Surface) theSurf = CurveRep->Surface(); + TopLoc_Location theLoc = CurveRep->Location(); + theLoc = anEdge.Location() * theLoc; + theSurf = Handle(Geom_Surface)::DownCast + (theSurf->Transformed(theLoc.Transformation())); + Handle(Geom2d_Curve) ProjPCurve = + GeomProjLib::Curve2d( C3d, f, l, theSurf ); + CurveRep->PCurve( ProjPCurve ); + } } } @@ -1093,11 +1067,11 @@ static void ReconstructPCurves(const TopoDS_Edge& anEdge) //======================================================================= static Handle(Geom2d_Curve) ConcatPCurves(const TopoDS_Edge& E1, - const TopoDS_Edge& E2, - const TopoDS_Face& F, - const Standard_Boolean After, - Standard_Real& newFirst, - Standard_Real& newLast) + const TopoDS_Edge& E2, + const TopoDS_Face& F, + const Standard_Boolean After, + Standard_Real& newFirst, + Standard_Real& newLast) { Standard_Real Tol = 1.e-7; GeomAbs_Shape Continuity = GeomAbs_C1; @@ -1122,48 +1096,48 @@ static Handle(Geom2d_Curve) ConcatPCurves(const TopoDS_Edge& E1, newLast = Max( last1, last2 ); } else if (PCurve1->DynamicType() == PCurve2->DynamicType() && - (PCurve1->IsInstance(STANDARD_TYPE(Geom2d_Line)) || - PCurve1->IsKind(STANDARD_TYPE(Geom2d_Conic)))) + (PCurve1->IsInstance(STANDARD_TYPE(Geom2d_Line)) || + PCurve1->IsKind(STANDARD_TYPE(Geom2d_Conic)))) { newPCurve = PCurve1; gp_Pnt2d P1, P2; P1 = PCurve2->Value( first2 ); P2 = PCurve2->Value( last2 ); if (PCurve1->IsInstance(STANDARD_TYPE(Geom2d_Line))) - { - Handle(Geom2d_Line) Lin1 = *((Handle(Geom2d_Line)*) &PCurve1); - gp_Lin2d theLin = Lin1->Lin2d(); - first2 = ElCLib::Parameter( theLin, P1 ); - last2 = ElCLib::Parameter( theLin, P2 ); - } + { + Handle(Geom2d_Line) Lin1 = *((Handle(Geom2d_Line)*) &PCurve1); + gp_Lin2d theLin = Lin1->Lin2d(); + first2 = ElCLib::Parameter( theLin, P1 ); + last2 = ElCLib::Parameter( theLin, P2 ); + } else if (PCurve1->IsInstance(STANDARD_TYPE(Geom2d_Circle))) - { - Handle(Geom2d_Circle) Circ1 = *((Handle(Geom2d_Circle)*) &PCurve1); - gp_Circ2d theCirc = Circ1->Circ2d(); - first2 = ElCLib::Parameter( theCirc, P1 ); - last2 = ElCLib::Parameter( theCirc, P2 ); - } + { + Handle(Geom2d_Circle) Circ1 = *((Handle(Geom2d_Circle)*) &PCurve1); + gp_Circ2d theCirc = Circ1->Circ2d(); + first2 = ElCLib::Parameter( theCirc, P1 ); + last2 = ElCLib::Parameter( theCirc, P2 ); + } else if (PCurve1->IsInstance(STANDARD_TYPE(Geom2d_Ellipse))) - { - Handle(Geom2d_Ellipse) Ell1 = *((Handle(Geom2d_Ellipse)*) &PCurve1); - gp_Elips2d theElips = Ell1->Elips2d(); - first2 = ElCLib::Parameter( theElips, P1 ); - last2 = ElCLib::Parameter( theElips, P2 ); - } + { + Handle(Geom2d_Ellipse) Ell1 = *((Handle(Geom2d_Ellipse)*) &PCurve1); + gp_Elips2d theElips = Ell1->Elips2d(); + first2 = ElCLib::Parameter( theElips, P1 ); + last2 = ElCLib::Parameter( theElips, P2 ); + } else if (PCurve1->IsInstance(STANDARD_TYPE(Geom2d_Parabola))) - { - Handle(Geom2d_Parabola) Parab1 = *((Handle(Geom2d_Parabola)*) &PCurve1); - gp_Parab2d theParab = Parab1->Parab2d(); - first2 = ElCLib::Parameter( theParab, P1 ); - last2 = ElCLib::Parameter( theParab, P2 ); - } + { + Handle(Geom2d_Parabola) Parab1 = *((Handle(Geom2d_Parabola)*) &PCurve1); + gp_Parab2d theParab = Parab1->Parab2d(); + first2 = ElCLib::Parameter( theParab, P1 ); + last2 = ElCLib::Parameter( theParab, P2 ); + } else if (PCurve1->IsInstance(STANDARD_TYPE(Geom2d_Hyperbola))) - { - Handle(Geom2d_Hyperbola) Hypr1 = *((Handle(Geom2d_Hyperbola)*) &PCurve1); - gp_Hypr2d theHypr = Hypr1->Hypr2d(); - first2 = ElCLib::Parameter( theHypr, P1 ); - last2 = ElCLib::Parameter( theHypr, P2 ); - } + { + Handle(Geom2d_Hyperbola) Hypr1 = *((Handle(Geom2d_Hyperbola)*) &PCurve1); + gp_Hypr2d theHypr = Hypr1->Hypr2d(); + first2 = ElCLib::Parameter( theHypr, P1 ); + last2 = ElCLib::Parameter( theHypr, P2 ); + } newFirst = Min( first1, first2 ); newLast = Max( last1, last2 ); } @@ -1175,11 +1149,11 @@ static Handle(Geom2d_Curve) ConcatPCurves(const TopoDS_Edge& E1, Concat2d.Add( TC2, Precision::Confusion(), After ); newPCurve = Concat2d.BSplineCurve(); if (newPCurve->Continuity() < GeomAbs_C1) - { - Geom2dConvert_ApproxCurve Approx2d( newPCurve, Tol, Continuity, MaxSeg, MaxDeg ); - if (Approx2d.HasResult()) - newPCurve = Approx2d.Curve(); - } + { + Geom2dConvert_ApproxCurve Approx2d( newPCurve, Tol, Continuity, MaxSeg, MaxDeg ); + if (Approx2d.HasResult()) + newPCurve = Approx2d.Curve(); + } newFirst = newPCurve->FirstParameter(); newLast = newPCurve->LastParameter(); } @@ -1193,14 +1167,14 @@ static Handle(Geom2d_Curve) ConcatPCurves(const TopoDS_Edge& E1, //======================================================================= static TopoDS_Edge Glue(const TopoDS_Edge& E1, - const TopoDS_Edge& E2, - const TopoDS_Vertex& Vfirst, - const TopoDS_Vertex& Vlast, - const Standard_Boolean After, - const TopoDS_Face& F1, - const Standard_Boolean addPCurve1, - const TopoDS_Face& F2, - const Standard_Boolean addPCurve2) + const TopoDS_Edge& E2, + const TopoDS_Vertex& Vfirst, + const TopoDS_Vertex& Vlast, + const Standard_Boolean After, + const TopoDS_Face& F1, + const Standard_Boolean addPCurve1, + const TopoDS_Face& F2, + const Standard_Boolean addPCurve2) { Standard_Real Tol = 1.e-7; GeomAbs_Shape Continuity = GeomAbs_C1; @@ -1227,8 +1201,8 @@ static TopoDS_Edge Glue(const TopoDS_Edge& E1, lparam = Max( last1, last2 ); } else if (C1->DynamicType() == C2->DynamicType() && - (C1->IsInstance(STANDARD_TYPE(Geom_Line)) || - C1->IsKind(STANDARD_TYPE(Geom_Conic)))) + (C1->IsInstance(STANDARD_TYPE(Geom_Line)) || + C1->IsKind(STANDARD_TYPE(Geom_Conic)))) { IsCanonic = Standard_True; newCurve = C1; @@ -1241,11 +1215,11 @@ static TopoDS_Edge Glue(const TopoDS_Edge& E1, Concat.Add( TC2, Precision::Confusion(), After ); newCurve = Concat.BSplineCurve(); if (newCurve->Continuity() < GeomAbs_C1) - { - GeomConvert_ApproxCurve Approx3d( newCurve, Tol, Continuity, MaxSeg, MaxDeg ); - if (Approx3d.HasResult()) - newCurve = Approx3d.Curve(); - } + { + GeomConvert_ApproxCurve Approx3d( newCurve, Tol, Continuity, MaxSeg, MaxDeg ); + if (Approx3d.HasResult()) + newCurve = Approx3d.Curve(); + } fparam = newCurve->FirstParameter(); lparam = newCurve->LastParameter(); } @@ -1281,48 +1255,48 @@ static TopoDS_Edge Glue(const TopoDS_Edge& E1, //purpose : //======================================================================= -static void FindNewVerticesOnBoundsOfFace(const BOPTools_DSFiller& pDF, - const TopoDS_Face& aFace, - const Standard_Integer iFace, - TopTools_DataMapOfShapeShape& VEmap) +static void FindNewVerticesOnBoundsOfFace(const BOPDS_PDS& pDS, + const TopoDS_Face& aFace, + TopTools_DataMapOfShapeShape& VEmap) { TopTools_IndexedMapOfShape OldVertices; TopExp::MapShapes( aFace, TopAbs_VERTEX, OldVertices ); - - const BOPTools_SplitShapesPool& aPool = pDF.SplitShapesPool(); - + BOPDS_ListIteratorOfListOfPaveBlock aItLPB; + TopoDS_Vertex V1, V2; + TopExp_Explorer Explo( aFace, TopAbs_EDGE ); - for (; Explo.More(); Explo.Next()) - { - TopoDS_Shape anEdge = Explo.Current(); - Standard_Integer eind = pDF.DS().ShapeIndex(anEdge,iFace); - const BOPTools_ListOfPaveBlock& aSplitEdges = aPool( pDF.DS().RefEdge(eind) ); - BOPTools_ListIteratorOfListOfPaveBlock itpb( aSplitEdges ); - for (; itpb.More(); itpb.Next()) - { - BOPTools_PaveBlock& aPaveBlock = itpb.Value(); - TopoDS_Shape aSplit = pDF.DS().GetShape( aPaveBlock.Edge() ); - TopoDS_Edge aNewEdge = TopoDS::Edge(aSplit); - TopoDS_Vertex V1, V2; - TopExp::Vertices( aNewEdge, V1, V2 ); - if (!OldVertices.Contains( V1 )) - VEmap.Bind( V1, anEdge ); - if (!OldVertices.Contains( V2 )) - VEmap.Bind( V2, anEdge ); - } + for (; Explo.More(); Explo.Next()) { + const TopoDS_Shape& aE = Explo.Current(); + Standard_Integer nE = pDS->Index(aE); + // + const BOPDS_ListOfPaveBlock& aLPB = pDS->PaveBlocks(nE); + aItLPB.Initialize(aLPB); + for (; aItLPB.More(); aItLPB.Next()) { + const Handle(BOPDS_PaveBlock)& aPB = aItLPB.Value(); + const TopoDS_Edge& aESp = *(TopoDS_Edge*)&pDS->Shape(aPB->Edge()); + // + TopExp::Vertices( aESp, V1, V2 ); + if (!OldVertices.Contains( V1 )) { + VEmap.Bind( V1, aE ); + } + // + if (!OldVertices.Contains( V2 )) { + VEmap.Bind( V2, aE ); + } } + } } - + //======================================================================= //function : CheckIntersFF //purpose : //======================================================================= -static Standard_Boolean CheckIntersFF(const BOPTools_DSFiller& pDF, - const TopoDS_Edge& RefEdge, - const TopoDS_Face& F1, - const TopoDS_Face& F2, - TopTools_IndexedMapOfShape& TrueEdges) +static Standard_Boolean CheckIntersFF(const BOPDS_PDS& pDS, + const TopoDS_Edge& RefEdge, + const TopoDS_Face& F1, + const TopoDS_Face& F2, + TopTools_IndexedMapOfShape& TrueEdges) { Standard_Boolean isEl1 = Standard_False, isEl2 = Standard_False; Standard_Boolean isPlane1 = Standard_False, isPlane2 = Standard_False; @@ -1349,36 +1323,35 @@ static Standard_Boolean CheckIntersFF(const BOPTools_DSFiller& pDF, if (isEl1 && isEl2) return Standard_True; - const BooleanOperations_ShapesDataStructure& aDS = pDF.DS(); - BOPTools_InterferencePool* anIntrPool = (BOPTools_InterferencePool*)&pDF.InterfPool(); - BOPTools_CArray1OfSSInterference& aFFs = anIntrPool->SSInterferences(); + BOPDS_VectorOfInterfFF& aFFs = pDS->InterfFF(); Standard_Integer aNb = aFFs.Extent(); Standard_Integer i, j, nbe = 0; TopTools_SequenceOfShape Edges; - for (i = 1; i <= aNb; i++) + for (i = 0; i < aNb; ++i) { - BOPTools_SSInterference& aFFi = aFFs(i); - BOPTools_SequenceOfCurves& aBCurves = aFFi.Curves(); - Standard_Integer aNbCurves = aBCurves.Length(); + BOPDS_InterfFF& aFFi=aFFs(i); + const BOPDS_VectorOfCurve& aBCurves=aFFi.Curves(); + Standard_Integer aNbCurves = aBCurves.Extent(); - for (j = 1; j <= aNbCurves; j++) - { - BOPTools_Curve& aBC = aBCurves(j); - const BOPTools_ListOfPaveBlock& aSectEdges = aBC.NewPaveBlocks(); - - BOPTools_ListIteratorOfListOfPaveBlock aPBIt(aSectEdges); - - for (; aPBIt.More(); aPBIt.Next()) - { - BOPTools_PaveBlock& aPB=aPBIt.Value(); - Standard_Integer nSect = aPB.Edge(); - TopoDS_Edge anEdge = TopoDS::Edge(aDS.Shape(nSect)); - Edges.Append( anEdge ); - nbe++; - } - } + for (j = 0; j < aNbCurves; ++j) + { + const BOPDS_Curve& aBC=aBCurves(j); + const BOPDS_ListOfPaveBlock& aSectEdges = aBC.PaveBlocks(); + + BOPDS_ListIteratorOfListOfPaveBlock aPBIt; + aPBIt.Initialize(aSectEdges); + + for (; aPBIt.More(); aPBIt.Next()) + { + const Handle(BOPDS_PaveBlock)& aPB = aPBIt.Value(); + Standard_Integer nSect = aPB->Edge(); + const TopoDS_Edge& anEdge = *(TopoDS_Edge*)&pDS->Shape(nSect); + Edges.Append( anEdge ); + nbe++; + } + } } if (nbe <= 1) @@ -1393,8 +1366,8 @@ static Standard_Boolean CheckIntersFF(const BOPTools_DSFiller& pDF, TopoDS_Edge StartEdge; //, StartEonF1, StartEonF2, EndEonF1, EndEonF2; TopTools_DataMapOfShapeShape VEmapF1, VEmapF2; - FindNewVerticesOnBoundsOfFace( pDF, F1, 1, VEmapF1 ); - FindNewVerticesOnBoundsOfFace( pDF, F2, 2, VEmapF2 ); + FindNewVerticesOnBoundsOfFace( pDS, F1, VEmapF1 ); + FindNewVerticesOnBoundsOfFace( pDS, F2, VEmapF2 ); Standard_Real AngTol = 0.1; Standard_Boolean V1onBound = Standard_False; @@ -1408,23 +1381,23 @@ static Standard_Boolean CheckIntersFF(const BOPTools_DSFiller& pDF, V1onBound = VEmapF1.IsBound(V1) || VEmapF2.IsBound(V1); // && ? V2onBound = VEmapF1.IsBound(V2) || VEmapF2.IsBound(V2); // && ? if (V1onBound || V2onBound) - { - BRepAdaptor_Curve CE(StartEdge); - TangFirst = CE.DN( CE.FirstParameter(), 1 ); - TangLast = CE.DN( CE.LastParameter(), 1 ); - if (V1onBound) - { - if (TangFirst.IsParallel( RefTangFirst, AngTol ) || - TangFirst.IsParallel( RefTangLast, AngTol )) - break; //start edged found - } - else if (V2onBound) - { - if (TangLast.IsParallel( RefTangLast, AngTol ) || - TangLast.IsParallel( RefTangFirst, AngTol )) - break; //start edged found - } - } + { + BRepAdaptor_Curve CE(StartEdge); + TangFirst = CE.DN( CE.FirstParameter(), 1 ); + TangLast = CE.DN( CE.LastParameter(), 1 ); + if (V1onBound) + { + if (TangFirst.IsParallel( RefTangFirst, AngTol ) || + TangFirst.IsParallel( RefTangLast, AngTol )) + break; //start edged found + } + else if (V2onBound) + { + if (TangLast.IsParallel( RefTangLast, AngTol ) || + TangLast.IsParallel( RefTangFirst, AngTol )) + break; //start edged found + } + } } if (i > Edges.Length()) //start edged not found @@ -1433,13 +1406,13 @@ static Standard_Boolean CheckIntersFF(const BOPTools_DSFiller& pDF, if (V1onBound && V2onBound) { if (TangFirst.IsParallel(RefTangFirst,AngTol) && TangLast.IsParallel(RefTangLast,AngTol) || - TangFirst.IsParallel(RefTangLast,AngTol) && TangLast.IsParallel(RefTangFirst,AngTol)) - { - TrueEdges.Add( Edges(i) ); - return Standard_True; - } + TangFirst.IsParallel(RefTangLast,AngTol) && TangLast.IsParallel(RefTangFirst,AngTol)) + { + TrueEdges.Add( Edges(i) ); + return Standard_True; + } else - return Standard_False; + return Standard_False; } //StartEonF1 = (V1onBound)? VEmapF1( V1 ) : VEmapF1( V2 ); @@ -1457,40 +1430,40 @@ static Standard_Boolean CheckIntersFF(const BOPTools_DSFiller& pDF, { TColStd_SequenceOfInteger Candidates; for (i = 1; i <= Edges.Length(); i++) - { - TopoDS_Edge anEdge = TopoDS::Edge(Edges(i)); - TopExp::Vertices( anEdge, V1, V2 ); - if (V1.IsSame(Vcur) || V2.IsSame(Vcur)) - Candidates.Append(i); - } + { + TopoDS_Edge anEdge = TopoDS::Edge(Edges(i)); + TopExp::Vertices( anEdge, V1, V2 ); + if (V1.IsSame(Vcur) || V2.IsSame(Vcur)) + Candidates.Append(i); + } if (Candidates.IsEmpty()) - { - TrueEdges.Clear(); - return Standard_False; - } + { + TrueEdges.Clear(); + return Standard_False; + } Standard_Integer minind = 1; if (Candidates.Length() > 1) - { - Standard_Real MinAngle = RealLast(); - for (i = 1; i <= Candidates.Length(); i++) - { - TopoDS_Edge anEdge = TopoDS::Edge(Edges(Candidates(i))); - TopExp::Vertices( anEdge, V1, V2 ); - Standard_Boolean ConnectByFirst = (Vcur.IsSame(V1))? Standard_True : Standard_False; - BRepAdaptor_Curve CE(anEdge); - gp_Vec aTang = (ConnectByFirst)? - CE.DN( CE.FirstParameter(), 1 ) : CE.DN( CE.LastParameter(), 1 ); - if (!ConnectByFirst) - aTang.Reverse(); - Standard_Real anAngle = TangCur.Angle(aTang); - if (anAngle < MinAngle) - { - MinAngle = anAngle; - minind = i; - } - } - } + { + Standard_Real MinAngle = RealLast(); + for (i = 1; i <= Candidates.Length(); i++) + { + TopoDS_Edge anEdge = TopoDS::Edge(Edges(Candidates(i))); + TopExp::Vertices( anEdge, V1, V2 ); + Standard_Boolean ConnectByFirst = (Vcur.IsSame(V1))? Standard_True : Standard_False; + BRepAdaptor_Curve CE(anEdge); + gp_Vec aTang = (ConnectByFirst)? + CE.DN( CE.FirstParameter(), 1 ) : CE.DN( CE.LastParameter(), 1 ); + if (!ConnectByFirst) + aTang.Reverse(); + Standard_Real anAngle = TangCur.Angle(aTang); + if (anAngle < MinAngle) + { + MinAngle = anAngle; + minind = i; + } + } + } TopoDS_Edge CurEdge = TopoDS::Edge(Edges(Candidates(minind))); TrueEdges.Add( CurEdge ); Edges.Remove(Candidates(minind)); @@ -1500,10 +1473,10 @@ static Standard_Boolean CheckIntersFF(const BOPTools_DSFiller& pDF, BRepAdaptor_Curve CE(CurEdge); TangCur = (ConnectByFirst)? CE.DN( CE.LastParameter(), 1 ) : CE.DN( CE.FirstParameter(), 1 ); if (!ConnectByFirst) - TangCur.Reverse(); + TangCur.Reverse(); //check if Vcur is on bounds of faces if (VEmapF1.IsBound(Vcur) || VEmapF2.IsBound(Vcur)) - break; + break; } //end of for (;;) if (TangCur.IsParallel( RefTangFirst, AngTol ) || @@ -1519,12 +1492,12 @@ static Standard_Boolean CheckIntersFF(const BOPTools_DSFiller& pDF, //purpose : //======================================================================= -static TopoDS_Edge AssembleEdge(const BOPTools_DSFiller* pDF, - const TopoDS_Face& F1, - const TopoDS_Face& F2, - const Standard_Boolean addPCurve1, - const Standard_Boolean addPCurve2, - const TopTools_SequenceOfShape& EdgesForConcat) +static TopoDS_Edge AssembleEdge(const BOPDS_PDS& pDS, + const TopoDS_Face& F1, + const TopoDS_Face& F2, + const Standard_Boolean addPCurve1, + const Standard_Boolean addPCurve2, + const TopTools_SequenceOfShape& EdgesForConcat) { TopoDS_Edge CurEdge = TopoDS::Edge( EdgesForConcat(1) ); for (Standard_Integer j = 2; j <= EdgesForConcat.Length(); j++) @@ -1533,51 +1506,51 @@ static TopoDS_Edge AssembleEdge(const BOPTools_DSFiller* pDF, Standard_Boolean After = Standard_False; TopoDS_Vertex Vfirst, Vlast; if (AreClosed( CurEdge, anEdge )) - { - TopoDS_Vertex V1, V2; - TopExp::Vertices( CurEdge, V1, V2 ); - if (IsAutonomVertex( V1, F1, F2, pDF->DS(), pDF->PaveFiller() )) - { - After = Standard_False; - Vfirst = Vlast = V2; - } - else - { - After = Standard_True; - Vfirst = Vlast = V1; - } - } + { + TopoDS_Vertex V1, V2; + TopExp::Vertices( CurEdge, V1, V2 ); + if (IsAutonomVertex( V1, F1, F2, pDS )) + { + After = Standard_False; + Vfirst = Vlast = V2; + } + else + { + After = Standard_True; + Vfirst = Vlast = V1; + } + } else - { - TopoDS_Vertex CV, V11, V12, V21, V22; - TopExp::CommonVertex( CurEdge, anEdge, CV ); - TopExp::Vertices( CurEdge, V11, V12 ); - TopExp::Vertices( anEdge, V21, V22 ); - if (V11.IsSame(CV) && V21.IsSame(CV)) - { - Vfirst = V22; - Vlast = V12; - } - else if (V11.IsSame(CV) && V22.IsSame(CV)) - { - Vfirst = V21; - Vlast = V12; - } - else if (V12.IsSame(CV) && V21.IsSame(CV)) - { - Vfirst = V11; - Vlast = V22; - } - else - { - Vfirst = V11; - Vlast = V21; - } - } //end of else (open wire) + { + TopoDS_Vertex CV, V11, V12, V21, V22; + TopExp::CommonVertex( CurEdge, anEdge, CV ); + TopExp::Vertices( CurEdge, V11, V12 ); + TopExp::Vertices( anEdge, V21, V22 ); + if (V11.IsSame(CV) && V21.IsSame(CV)) + { + Vfirst = V22; + Vlast = V12; + } + else if (V11.IsSame(CV) && V22.IsSame(CV)) + { + Vfirst = V21; + Vlast = V12; + } + else if (V12.IsSame(CV) && V21.IsSame(CV)) + { + Vfirst = V11; + Vlast = V22; + } + else + { + Vfirst = V11; + Vlast = V21; + } + } //end of else (open wire) TopoDS_Edge NewEdge = Glue(CurEdge, anEdge, - Vfirst, Vlast, After, - F1, addPCurve1, F2, addPCurve2); + Vfirst, Vlast, After, + F1, addPCurve1, F2, addPCurve2); CurEdge = NewEdge; } //end of for (Standard_Integer j = 2; j <= EdgesForConcat.Length(); j++) @@ -1590,12 +1563,12 @@ static TopoDS_Edge AssembleEdge(const BOPTools_DSFiller* pDF, //======================================================================= void BRepOffset_Tool::Inter3D(const TopoDS_Face& F1, - const TopoDS_Face& F2, - TopTools_ListOfShape& L1, - TopTools_ListOfShape& L2, - const TopAbs_State Side, - const TopoDS_Edge& RefEdge, - const Standard_Boolean IsRefEdgeDefined) + const TopoDS_Face& F2, + TopTools_ListOfShape& L1, + TopTools_ListOfShape& L2, + const TopAbs_State Side, + const TopoDS_Edge& RefEdge, + const Standard_Boolean IsRefEdgeDefined) { #ifdef DRAW if (AffichInter) { @@ -1614,93 +1587,101 @@ void BRepOffset_Tool::Inter3D(const TopoDS_Face& F1, BRepLib::BuildCurves3d(cpF1); BRepLib::BuildCurves3d(cpF2); - BOPTools_DSFiller pDF1, pDF2; - pDF1.SetShapes(cpF1, cpF2); + BOPAlgo_PaveFiller aPF1, aPF2; + BOPCol_ListOfShape aLS; + aLS.Append(cpF1); + aLS.Append(cpF2); + aPF1.SetArguments(aLS); + // + aPF1.Perform(); + + BOPAlgo_PaveFiller *pPF = &aPF1; - pDF1.Perform(); - - BOPTools_DSFiller * pDF = &pDF1; + aLS.Clear(); TopTools_IndexedMapOfShape TrueEdges; - if (IsRefEdgeDefined && !CheckIntersFF( pDF1, RefEdge, cpF1, cpF2, TrueEdges )) + if (IsRefEdgeDefined && !CheckIntersFF( pPF->PDS(), RefEdge, cpF1, cpF2, TrueEdges )) { cpF1 = F2; cpF2 = F1; - pDF2.SetShapes(cpF1, cpF2); - pDF2.Perform(); - CheckIntersFF( pDF2, RefEdge, cpF1, cpF2, TrueEdges ); - pDF = &pDF2; + aLS.Append(cpF1); + aLS.Append(cpF2); + aPF2.SetArguments(aLS); + aPF2.Perform(); + pPF = &aPF2; + CheckIntersFF( pPF->PDS(), RefEdge, cpF1, cpF2, TrueEdges ); } - Standard_Boolean addPCurve1 = pDF->PaveFiller().SectionAttribute().PCurveOnS1(); - Standard_Boolean addPCurve2 = pDF->PaveFiller().SectionAttribute().PCurveOnS2(); + Standard_Boolean addPCurve1 = 1; + Standard_Boolean addPCurve2 = 1; - const BooleanOperations_ShapesDataStructure& aDS = pDF->DS(); - BOPTools_InterferencePool* anIntrPool = (BOPTools_InterferencePool*)& pDF->InterfPool(); - BOPTools_CArray1OfSSInterference& aFFs = anIntrPool->SSInterferences(); + const BOPDS_PDS& pDS = pPF->PDS(); + BOPDS_VectorOfInterfFF& aFFs=pDS->InterfFF(); Standard_Integer aNb = aFFs.Extent(); Standard_Integer i = 0, j = 0, k; // Store Result L1.Clear(); L2.Clear(); TopAbs_Orientation O1,O2; - for (i = 1; i <= aNb; i++) { - BOPTools_SSInterference& aFFi = aFFs(i); - BOPTools_SequenceOfCurves& aBCurves = aFFi.Curves(); - Standard_Integer aNbCurves = aBCurves.Length(); + for (i = 0; i < aNb; i++) { + BOPDS_InterfFF& aFFi=aFFs(i); + const BOPDS_VectorOfCurve& aBCurves=aFFi.Curves(); + + Standard_Integer aNbCurves = aBCurves.Extent(); - for (j = 1; j <= aNbCurves; j++) { - BOPTools_Curve& aBC = aBCurves(j); - const BOPTools_ListOfPaveBlock& aSectEdges = aBC.NewPaveBlocks(); - - BOPTools_ListIteratorOfListOfPaveBlock aPBIt(aSectEdges); + for (j = 0; j < aNbCurves; j++) { + const BOPDS_Curve& aBC=aBCurves(j); + const BOPDS_ListOfPaveBlock& aSectEdges = aBC.PaveBlocks(); + + BOPDS_ListIteratorOfListOfPaveBlock aPBIt; + aPBIt.Initialize(aSectEdges); for (; aPBIt.More(); aPBIt.Next()) { - BOPTools_PaveBlock& aPB=aPBIt.Value(); - Standard_Integer nSect = aPB.Edge(); - TopoDS_Edge anEdge = TopoDS::Edge(aDS.Shape(nSect)); - if (!TrueEdges.IsEmpty() && !TrueEdges.Contains(anEdge)) - continue; + const Handle(BOPDS_PaveBlock)& aPB = aPBIt.Value(); + Standard_Integer nSect = aPB->Edge(); + const TopoDS_Edge& anEdge = *(TopoDS_Edge*)&pDS->Shape(nSect); + if (!TrueEdges.IsEmpty() && !TrueEdges.Contains(anEdge)) + continue; Standard_Real f, l; - const Handle(Geom_Curve)& aC3DE = BRep_Tool::Curve(anEdge, f, l); - Handle(Geom_TrimmedCurve) aC3DETrim; - - if(!aC3DE.IsNull()) + const Handle(Geom_Curve)& aC3DE = BRep_Tool::Curve(anEdge, f, l); + Handle(Geom_TrimmedCurve) aC3DETrim; + + if(!aC3DE.IsNull()) aC3DETrim = new Geom_TrimmedCurve(aC3DE, f, l); BRep_Builder aBB; - Standard_Real aTolEdge = BRep_Tool::Tolerance(anEdge); - - if (!BOPTools_Tools2D::HasCurveOnSurface(anEdge, cpF1)) { + Standard_Real aTolEdge = BRep_Tool::Tolerance(anEdge); + + if (!BOPTools_AlgoTools2D::HasCurveOnSurface(anEdge, cpF1)) { Handle(Geom2d_Curve) aC2d = aBC.Curve().FirstCurve2d(); if(!aC3DETrim.IsNull()) { - Handle(Geom2d_Curve) aC2dNew; - - if(aC3DE->IsPeriodic()) { - BOPTools_Tools2D::AdjustPCurveOnFace(cpF1, f, l, aC2d, aC2dNew); - } - else { - BOPTools_Tools2D::AdjustPCurveOnFace(cpF1, aC3DETrim, aC2d, aC2dNew); - } - aC2d = aC2dNew; - } - aBB.UpdateEdge(anEdge, aC2d, cpF1, aTolEdge); + Handle(Geom2d_Curve) aC2dNew; + + if(aC3DE->IsPeriodic()) { + BOPTools_AlgoTools2D::AdjustPCurveOnFace(cpF1, f, l, aC2d, aC2dNew); + } + else { + BOPTools_AlgoTools2D::AdjustPCurveOnFace(cpF1, aC3DETrim, aC2d, aC2dNew); + } + aC2d = aC2dNew; + } + aBB.UpdateEdge(anEdge, aC2d, cpF1, aTolEdge); } - if (!BOPTools_Tools2D::HasCurveOnSurface(anEdge, cpF2)) { + if (!BOPTools_AlgoTools2D::HasCurveOnSurface(anEdge, cpF2)) { Handle(Geom2d_Curve) aC2d = aBC.Curve().SecondCurve2d(); if(!aC3DETrim.IsNull()) { - Handle(Geom2d_Curve) aC2dNew; - - if(aC3DE->IsPeriodic()) { - BOPTools_Tools2D::AdjustPCurveOnFace(cpF2, f, l, aC2d, aC2dNew); - } - else { - BOPTools_Tools2D::AdjustPCurveOnFace(cpF2, aC3DETrim, aC2d, aC2dNew); - } - aC2d = aC2dNew; - } - aBB.UpdateEdge(anEdge, aC2d, cpF2, aTolEdge); + Handle(Geom2d_Curve) aC2dNew; + + if(aC3DE->IsPeriodic()) { + BOPTools_AlgoTools2D::AdjustPCurveOnFace(cpF2, f, l, aC2d, aC2dNew); + } + else { + BOPTools_AlgoTools2D::AdjustPCurveOnFace(cpF2, aC3DETrim, aC2d, aC2dNew); + } + aC2d = aC2dNew; + } + aBB.UpdateEdge(anEdge, aC2d, cpF2, aTolEdge); } OrientSection (anEdge, F1, F2, O1, O2); @@ -1715,7 +1696,7 @@ void BRepOffset_Tool::Inter3D(const TopoDS_Face& F1, #ifdef DRAW if (AffichInter) { char* name = new char[100]; - sprintf(name,"EI_%d",NbNewEdges++); + sprintf(name,"EI_%d",NbNewEdges++); DBRep::Set(name,anEdge.Oriented(O1)); } @@ -1749,190 +1730,189 @@ void BRepOffset_Tool::Inter3D(const TopoDS_Face& F1, if (!TrueEdges.IsEmpty()) { - for (i = TrueEdges.Extent(); i >= 1; i--) - EdgesForConcat.Append( TrueEdges(i) ); - TopoDS_Edge theEdge = - AssembleEdge( pDF, cpF1, cpF2, addPCurve1, addPCurve2, EdgesForConcat ); - eseq.Append(theEdge); + for (i = TrueEdges.Extent(); i >= 1; i--) + EdgesForConcat.Append( TrueEdges(i) ); + TopoDS_Edge theEdge = + AssembleEdge( pDS, cpF1, cpF2, addPCurve1, addPCurve2, EdgesForConcat ); + eseq.Append(theEdge); } else { - const BOPTools_PaveFiller& thePaveFiller = pDF->PaveFiller(); - - TopTools_SequenceOfShape wseq; - TopTools_SequenceOfShape edges; - TopTools_ListIteratorOfListOfShape itl(L1); - for (; itl.More(); itl.Next()) - edges.Append( itl.Value() ); - while (!edges.IsEmpty()) - { - TopoDS_Edge anEdge = TopoDS::Edge( edges.First() ); - TopoDS_Wire aWire = BRepLib_MakeWire( anEdge ), resWire; - TColStd_SequenceOfInteger Candidates; - for (k = 1; k <= wseq.Length(); k++) - { - resWire = TopoDS::Wire(wseq(k)); - if (AreConnex( resWire, aWire, cpF1, cpF2, pDF )) - { - Candidates.Append( 1 ); - break; - } - } - if (Candidates.IsEmpty()) - { - wseq.Append( aWire ); - edges.Remove(1); - } - else - { - for (j = 2; j <= edges.Length(); j++) - { - anEdge = TopoDS::Edge( edges(j) ); - //if (anEdge.IsSame(edges(Candidates.First()))) - //continue; - aWire = BRepLib_MakeWire( anEdge ); - if (AreConnex( resWire, aWire, cpF1, cpF2, pDF )) - Candidates.Append( j ); - } - Standard_Integer minind = 1; - if (Candidates.Length() > 1) - { - Standard_Real MinAngle = RealLast(); - for (j = 1; j <= Candidates.Length(); j++) - { - anEdge = TopoDS::Edge( edges(Candidates(j)) ); - Standard_Real anAngle = AngleWireEdge( resWire, anEdge ); - if (anAngle < MinAngle) - { - MinAngle = anAngle; - minind = j; - } - } - } - TopoDS_Wire NewWire = BRepLib_MakeWire( resWire, TopoDS::Edge(edges(Candidates(minind))) ); - wseq(k) = NewWire; - edges.Remove(Candidates(minind)); - } - } //end of while (!edges.IsEmpty()) - - for (i = 1; i <= wseq.Length(); i++) - { - TopoDS_Wire aWire = TopoDS::Wire(wseq(i)); - TopTools_SequenceOfShape EdgesForConcat; - if (aWire.Closed()) - { - TopoDS_Vertex StartVertex; - TopoDS_Edge StartEdge; - Standard_Boolean StartFound = Standard_False; - TopTools_ListOfShape Elist; - - TopoDS_Iterator itw(aWire); - for (; itw.More(); itw.Next()) - { - TopoDS_Edge anEdge = TopoDS::Edge(itw.Value()); - if (StartFound) - Elist.Append(anEdge); - else - { - TopoDS_Vertex V1, V2; - TopExp::Vertices( anEdge, V1, V2 ); - if (!IsAutonomVertex( V1, cpF1, cpF2, aDS, thePaveFiller )) - { - StartVertex = V2; - StartEdge = anEdge; - StartFound = Standard_True; - } - else if (!IsAutonomVertex( V2, cpF1, cpF2, aDS, thePaveFiller )) - { - StartVertex = V1; - StartEdge = anEdge; - StartFound = Standard_True; - } - else - Elist.Append(anEdge); - } - } //end of for (; itw.More(); itw.Next()) - if (!StartFound) - { - itl.Initialize(Elist); - StartEdge = TopoDS::Edge(itl.Value()); - Elist.Remove(itl); - TopoDS_Vertex V1, V2; - TopExp::Vertices( StartEdge, V1, V2 ); - StartVertex = V1; - } - EdgesForConcat.Append( StartEdge ); - while (!Elist.IsEmpty()) - { - for (itl.Initialize(Elist); itl.More(); itl.Next()) - { - TopoDS_Edge anEdge = TopoDS::Edge(itl.Value()); - TopoDS_Vertex V1, V2; - TopExp::Vertices( anEdge, V1, V2 ); - if (V1.IsSame(StartVertex)) - { - StartVertex = V2; - EdgesForConcat.Append( anEdge ); - Elist.Remove(itl); - break; - } - else if (V2.IsSame(StartVertex)) - { - StartVertex = V1; - EdgesForConcat.Append( anEdge ); - Elist.Remove(itl); - break; - } - } - } //end of while (!Elist.IsEmpty()) - } //end of if (aWire.Closed()) - else - { - BRepTools_WireExplorer Wexp( aWire ); - for (; Wexp.More(); Wexp.Next()) - EdgesForConcat.Append( Wexp.Current() ); - } - - TopoDS_Edge theEdge = - AssembleEdge( pDF, cpF1, cpF2, addPCurve1, addPCurve2, EdgesForConcat ); - eseq.Append( theEdge ); - } + + TopTools_SequenceOfShape wseq; + TopTools_SequenceOfShape edges; + TopTools_ListIteratorOfListOfShape itl(L1); + for (; itl.More(); itl.Next()) + edges.Append( itl.Value() ); + while (!edges.IsEmpty()) + { + TopoDS_Edge anEdge = TopoDS::Edge( edges.First() ); + TopoDS_Wire aWire = BRepLib_MakeWire( anEdge ), resWire; + TColStd_SequenceOfInteger Candidates; + for (k = 1; k <= wseq.Length(); k++) + { + resWire = TopoDS::Wire(wseq(k)); + if (AreConnex( resWire, aWire, cpF1, cpF2, pDS )) + { + Candidates.Append( 1 ); + break; + } + } + if (Candidates.IsEmpty()) + { + wseq.Append( aWire ); + edges.Remove(1); + } + else + { + for (j = 2; j <= edges.Length(); j++) + { + anEdge = TopoDS::Edge( edges(j) ); + //if (anEdge.IsSame(edges(Candidates.First()))) + //continue; + aWire = BRepLib_MakeWire( anEdge ); + if (AreConnex( resWire, aWire, cpF1, cpF2, pDS )) + Candidates.Append( j ); + } + Standard_Integer minind = 1; + if (Candidates.Length() > 1) + { + Standard_Real MinAngle = RealLast(); + for (j = 1; j <= Candidates.Length(); j++) + { + anEdge = TopoDS::Edge( edges(Candidates(j)) ); + Standard_Real anAngle = AngleWireEdge( resWire, anEdge ); + if (anAngle < MinAngle) + { + MinAngle = anAngle; + minind = j; + } + } + } + TopoDS_Wire NewWire = BRepLib_MakeWire( resWire, TopoDS::Edge(edges(Candidates(minind))) ); + wseq(k) = NewWire; + edges.Remove(Candidates(minind)); + } + } //end of while (!edges.IsEmpty()) + + for (i = 1; i <= wseq.Length(); i++) + { + TopoDS_Wire aWire = TopoDS::Wire(wseq(i)); + TopTools_SequenceOfShape EdgesForConcat; + if (aWire.Closed()) + { + TopoDS_Vertex StartVertex; + TopoDS_Edge StartEdge; + Standard_Boolean StartFound = Standard_False; + TopTools_ListOfShape Elist; + + TopoDS_Iterator itw(aWire); + for (; itw.More(); itw.Next()) + { + TopoDS_Edge anEdge = TopoDS::Edge(itw.Value()); + if (StartFound) + Elist.Append(anEdge); + else + { + TopoDS_Vertex V1, V2; + TopExp::Vertices( anEdge, V1, V2 ); + if (!IsAutonomVertex( V1, cpF1, cpF2, pDS )) + { + StartVertex = V2; + StartEdge = anEdge; + StartFound = Standard_True; + } + else if (!IsAutonomVertex( V2, cpF1, cpF2, pDS )) + { + StartVertex = V1; + StartEdge = anEdge; + StartFound = Standard_True; + } + else + Elist.Append(anEdge); + } + } //end of for (; itw.More(); itw.Next()) + if (!StartFound) + { + itl.Initialize(Elist); + StartEdge = TopoDS::Edge(itl.Value()); + Elist.Remove(itl); + TopoDS_Vertex V1, V2; + TopExp::Vertices( StartEdge, V1, V2 ); + StartVertex = V1; + } + EdgesForConcat.Append( StartEdge ); + while (!Elist.IsEmpty()) + { + for (itl.Initialize(Elist); itl.More(); itl.Next()) + { + TopoDS_Edge anEdge = TopoDS::Edge(itl.Value()); + TopoDS_Vertex V1, V2; + TopExp::Vertices( anEdge, V1, V2 ); + if (V1.IsSame(StartVertex)) + { + StartVertex = V2; + EdgesForConcat.Append( anEdge ); + Elist.Remove(itl); + break; + } + else if (V2.IsSame(StartVertex)) + { + StartVertex = V1; + EdgesForConcat.Append( anEdge ); + Elist.Remove(itl); + break; + } + } + } //end of while (!Elist.IsEmpty()) + } //end of if (aWire.Closed()) + else + { + BRepTools_WireExplorer Wexp( aWire ); + for (; Wexp.More(); Wexp.Next()) + EdgesForConcat.Append( Wexp.Current() ); + } + + TopoDS_Edge theEdge = + AssembleEdge( pDS, cpF1, cpF2, addPCurve1, addPCurve2, EdgesForConcat ); + eseq.Append( theEdge ); + } } //end of else (when TrueEdges is empty) if (eseq.Length() < L1.Extent()) { - L1.Clear(); - L2.Clear(); - for (i = 1; i <= eseq.Length(); i++) - { - TopoDS_Edge anEdge = TopoDS::Edge(eseq(i)); - BRepLib::SameParameter(anEdge, aSameParTol, Standard_True); - Standard_Real EdgeTol = BRep_Tool::Tolerance(anEdge); + L1.Clear(); + L2.Clear(); + for (i = 1; i <= eseq.Length(); i++) + { + TopoDS_Edge anEdge = TopoDS::Edge(eseq(i)); + BRepLib::SameParameter(anEdge, aSameParTol, Standard_True); + Standard_Real EdgeTol = BRep_Tool::Tolerance(anEdge); #ifdef DEB - cout<<"Tolerance of glued E = "< l + Precision::Confusion()) { + U > l + Precision::Confusion()) { cout << " ProjectVertexOnEdge : hors borne :"<FirstParameter(); fl1[1] = C1->LastParameter(); - fl2[0] = C2->FirstParameter(); fl2[1] = C2->LastParameter(); - } - Geom2dAdaptor_Curve AC1(C1,fl1[0],fl1[1]); - Geom2dAdaptor_Curve AC2(C2,fl2[0],fl2[1]); - - if (itry == 0) { - gp_Pnt2d P1[2],P2[2]; - P1[0] = C1->Value(fl1[0]); P1[1] = C1->Value(fl1[1]); - P2[0] = C2->Value(fl2[0]); P2[1] = C2->Value(fl2[1]); - - Standard_Integer i1 ; - for ( i1 = 0; i1 < 2; i1++) { - for (Standard_Integer i2 = 0; i2 < 2; i2++) { - if (Abs(fl1[i1]) < Precision::Infinite() && - Abs(fl2[i2]) < Precision::Infinite() ) { - if (P1[i1].IsEqual(P2[i2],TolConf)) { - YaSol = Standard_True; - U1 = fl1[i1]; U2 = fl2[i2]; - P2d = C1->Value(U1); - } - } - } - } - if (!YaSol) - for (i1 = 0; i1 < 2; i1++) - { - Extrema_ExtPC2d extr( P1[i1], AC2 ); - if (extr.IsDone() && extr.NbExt() > 0) - { - Standard_Real Dist2, Dist2Min = extr.SquareDistance(1); - Standard_Integer IndexMin = 1; - for (Standard_Integer ind = 2; ind <= extr.NbExt(); ind++) - { - Dist2 = extr.SquareDistance(ind); - if (Dist2 < Dist2Min) - { - Dist2Min = Dist2; - IndexMin = ind; - } - } + gp_Pnt2d P2d; + if (itry == 1) { + fl1[0] = C1->FirstParameter(); fl1[1] = C1->LastParameter(); + fl2[0] = C2->FirstParameter(); fl2[1] = C2->LastParameter(); + } + Geom2dAdaptor_Curve AC1(C1,fl1[0],fl1[1]); + Geom2dAdaptor_Curve AC2(C2,fl2[0],fl2[1]); + + if (itry == 0) { + gp_Pnt2d P1[2],P2[2]; + P1[0] = C1->Value(fl1[0]); P1[1] = C1->Value(fl1[1]); + P2[0] = C2->Value(fl2[0]); P2[1] = C2->Value(fl2[1]); + + Standard_Integer i1 ; + for ( i1 = 0; i1 < 2; i1++) { + for (Standard_Integer i2 = 0; i2 < 2; i2++) { + if (Abs(fl1[i1]) < Precision::Infinite() && + Abs(fl2[i2]) < Precision::Infinite() ) { + if (P1[i1].IsEqual(P2[i2],TolConf)) { + YaSol = Standard_True; + U1 = fl1[i1]; U2 = fl2[i2]; + P2d = C1->Value(U1); + } + } + } + } + if (!YaSol) + for (i1 = 0; i1 < 2; i1++) + { + Extrema_ExtPC2d extr( P1[i1], AC2 ); + if (extr.IsDone() && extr.NbExt() > 0) + { + Standard_Real Dist2, Dist2Min = extr.SquareDistance(1); + Standard_Integer IndexMin = 1; + for (Standard_Integer ind = 2; ind <= extr.NbExt(); ind++) + { + Dist2 = extr.SquareDistance(ind); + if (Dist2 < Dist2Min) + { + Dist2Min = Dist2; + IndexMin = ind; + } + } if (Dist2Min <= Precision::SquareConfusion()) - { - YaSol = Standard_True; - P2d = P1[i1]; - U1 = fl1[i1]; - U2 = (extr.Point(IndexMin)).Parameter(); - break; - } - } - } - if (!YaSol) - for (Standard_Integer i2 = 0; i2 < 2; i2++) - { - Extrema_ExtPC2d extr( P2[i2], AC1 ); - if (extr.IsDone() && extr.NbExt() > 0) - { - Standard_Real Dist2, Dist2Min = extr.SquareDistance(1); - Standard_Integer IndexMin = 1; - for (Standard_Integer ind = 2; ind <= extr.NbExt(); ind++) - { - Dist2 = extr.SquareDistance(ind); - if (Dist2 < Dist2Min) - { - Dist2Min = Dist2; - IndexMin = ind; - } - } + { + YaSol = Standard_True; + P2d = P1[i1]; + U1 = fl1[i1]; + U2 = (extr.Point(IndexMin)).Parameter(); + break; + } + } + } + if (!YaSol) + for (Standard_Integer i2 = 0; i2 < 2; i2++) + { + Extrema_ExtPC2d extr( P2[i2], AC1 ); + if (extr.IsDone() && extr.NbExt() > 0) + { + Standard_Real Dist2, Dist2Min = extr.SquareDistance(1); + Standard_Integer IndexMin = 1; + for (Standard_Integer ind = 2; ind <= extr.NbExt(); ind++) + { + Dist2 = extr.SquareDistance(ind); + if (Dist2 < Dist2Min) + { + Dist2Min = Dist2; + IndexMin = ind; + } + } if (Dist2Min <= Precision::SquareConfusion()) - { - YaSol = Standard_True; - P2d = P2[i2]; - U2 = fl2[i2]; - U1 = (extr.Point(IndexMin)).Parameter(); - break; - } - } - } - } - - if (!YaSol) { - Geom2dInt_GInter Inter (AC1,AC2,TolConf,TolConf); - - if (!Inter.IsEmpty() && Inter.NbPoints() > 0) { - YaSol = Standard_True; - U1 = Inter.Point(1).ParamOnFirst(); - U2 = Inter.Point(1).ParamOnSecond(); - P2d = Inter.Point(1).Value(); - } - else if (!Inter.IsEmpty() && Inter.NbSegments() > 0) { - YaSol = Standard_True; - IntRes2d_IntersectionSegment Seg = Inter.Segment(1); - IntRes2d_IntersectionPoint IntP1 = Seg.FirstPoint(); - IntRes2d_IntersectionPoint IntP2 = Seg.LastPoint(); - Standard_Real U1on1 = IntP1.ParamOnFirst(); - Standard_Real U1on2 = IntP2.ParamOnFirst(); - Standard_Real U2on1 = IntP1.ParamOnSecond(); - Standard_Real U2on2 = IntP2.ParamOnSecond(); + { + YaSol = Standard_True; + P2d = P2[i2]; + U2 = fl2[i2]; + U1 = (extr.Point(IndexMin)).Parameter(); + break; + } + } + } + } + + if (!YaSol) { + Geom2dInt_GInter Inter (AC1,AC2,TolConf,TolConf); + + if (!Inter.IsEmpty() && Inter.NbPoints() > 0) { + YaSol = Standard_True; + U1 = Inter.Point(1).ParamOnFirst(); + U2 = Inter.Point(1).ParamOnSecond(); + P2d = Inter.Point(1).Value(); + } + else if (!Inter.IsEmpty() && Inter.NbSegments() > 0) { + YaSol = Standard_True; + IntRes2d_IntersectionSegment Seg = Inter.Segment(1); + IntRes2d_IntersectionPoint IntP1 = Seg.FirstPoint(); + IntRes2d_IntersectionPoint IntP2 = Seg.LastPoint(); + Standard_Real U1on1 = IntP1.ParamOnFirst(); + Standard_Real U1on2 = IntP2.ParamOnFirst(); + Standard_Real U2on1 = IntP1.ParamOnSecond(); + Standard_Real U2on2 = IntP2.ParamOnSecond(); #ifdef DEB - cout << " BRepOffset_Tool::Inter2d SEGMENT d intersection" << endl; - cout << " ===> Parametres sur Curve1 : "; - cout << U1on1 << " " << U1on2 << endl; - cout << " ===> Parametres sur Curve2 : "; - cout << U2on1 << " " << U2on2 << endl; + cout << " BRepOffset_Tool::Inter2d SEGMENT d intersection" << endl; + cout << " ===> Parametres sur Curve1 : "; + cout << U1on1 << " " << U1on2 << endl; + cout << " ===> Parametres sur Curve2 : "; + cout << U2on1 << " " << U2on2 << endl; #endif - U1 = (U1on1 + U1on2)/2.; - U2 = (U2on1 + U2on2)/2.; - gp_Pnt2d P2d1 = C1->Value(U1); - gp_Pnt2d P2d2 = C2->Value(U2); - P2d.SetX( (P2d1.X() + P2d2.X()) / 2.); - P2d.SetY( (P2d1.Y() + P2d2.Y()) / 2.); - } - } - if (YaSol) { - gp_Pnt P = S->Value(P2d.X(),P2d.Y()); - TopoDS_Vertex V = BRepLib_MakeVertex(P); - V.Orientation(TopAbs_INTERNAL); - TopoDS_Shape aLocalEdge = E1.Oriented(TopAbs_FORWARD); - B.UpdateVertex(V,U1,TopoDS::Edge(aLocalEdge),TolConf); - aLocalEdge = E2.Oriented(TopAbs_FORWARD); - B.UpdateVertex(V,U2,TopoDS::Edge(aLocalEdge),TolConf); -// B.UpdateVertex(V,U1,TopoDS::Edge(E1.Oriented(TopAbs_FORWARD)),TolConf); -// B.UpdateVertex(V,U2,TopoDS::Edge(E2.Oriented(TopAbs_FORWARD)),TolConf); - LV.Append(V); - } + U1 = (U1on1 + U1on2)/2.; + U2 = (U2on1 + U2on2)/2.; + gp_Pnt2d P2d1 = C1->Value(U1); + gp_Pnt2d P2d2 = C2->Value(U2); + P2d.SetX( (P2d1.X() + P2d2.X()) / 2.); + P2d.SetY( (P2d1.Y() + P2d2.Y()) / 2.); + } + } + if (YaSol) { + gp_Pnt P = S->Value(P2d.X(),P2d.Y()); + TopoDS_Vertex V = BRepLib_MakeVertex(P); + V.Orientation(TopAbs_INTERNAL); + TopoDS_Shape aLocalEdge = E1.Oriented(TopAbs_FORWARD); + B.UpdateVertex(V,U1,TopoDS::Edge(aLocalEdge),TolConf); + aLocalEdge = E2.Oriented(TopAbs_FORWARD); + B.UpdateVertex(V,U2,TopoDS::Edge(aLocalEdge),TolConf); +// B.UpdateVertex(V,U1,TopoDS::Edge(E1.Oriented(TopAbs_FORWARD)),TolConf); +// B.UpdateVertex(V,U2,TopoDS::Edge(E2.Oriented(TopAbs_FORWARD)),TolConf); + LV.Append(V); + } } } itry++; @@ -2514,10 +2494,10 @@ void BRepOffset_Tool::Inter2d (const TopoDS_Face& F, U = BRep_Tool::Parameter(CV,TopoDS::Edge(aLocalEdge)); // U = BRep_Tool::Parameter(CV,TopoDS::Edge(E1.Oriented(TopAbs_FORWARD))); if ( U < UMin) { - VF = CV; UMin = U; + VF = CV; UMin = U; } if ( U > UMax) { - VL = CV; UMax = U; + VL = CV; UMax = U; } } LV.Clear();LV.Append(VF); LV.Append(VL); @@ -2541,9 +2521,9 @@ void BRepOffset_Tool::Inter2d (const TopoDS_Face& F, //======================================================================= static void SelectEdge (const TopoDS_Face& F, - const TopoDS_Face& EF, - const TopoDS_Edge& E, - TopTools_ListOfShape& LInt) + const TopoDS_Face& EF, + const TopoDS_Edge& E, + TopTools_ListOfShape& LInt) { //------------------------------------------------------------ // detrompeur sur les intersections sur les faces periodiques @@ -2588,13 +2568,13 @@ static void SelectEdge (const TopoDS_Face& F, //======================================================================= static void MakeFace(const Handle(Geom_Surface)& S, - const Standard_Real Um, - const Standard_Real UM, - const Standard_Real Vm, - const Standard_Real VM, - const Standard_Boolean isVminDegen, - const Standard_Boolean isVmaxDegen, - TopoDS_Face& F) + const Standard_Real Um, + const Standard_Real UM, + const Standard_Real Vm, + const Standard_Real VM, + const Standard_Boolean isVminDegen, + const Standard_Boolean isVmaxDegen, + TopoDS_Face& F) { Standard_Real UMin = Um; Standard_Real UMax = UM; @@ -2624,12 +2604,12 @@ static void MakeFace(const Handle(Geom_Surface)& S, Standard_Boolean uclosed = IsSuclosed && Abs(UMin - umin) < epsilon && - Abs(UMax - umax) < epsilon; + Abs(UMax - umax) < epsilon; Standard_Boolean vclosed = IsSvclosed && Abs(VMin - vmin) < epsilon && - Abs(VMax - vmax) < epsilon; + Abs(VMax - vmax) < epsilon; // degenerated flags (for cones) Standard_Boolean vmindegen = isVminDegen, vmaxdegen = isVmaxDegen; @@ -2644,9 +2624,9 @@ static void MakeFace(const Handle(Geom_Surface)& S, Standard_Real Uapex, Vapex; ElSLib::Parameters( theCone, theApex, Uapex, Vapex ); if (Abs(VMin - Vapex) <= Precision::Confusion()) - vmindegen = Standard_True; + vmindegen = Standard_True; if (Abs(VMax - Vapex) <= Precision::Confusion()) - vmaxdegen = Standard_True; + vmaxdegen = Standard_True; } // compute vertices @@ -2701,15 +2681,15 @@ static void MakeFace(const Handle(Geom_Surface)& S, Cumax = S->UIso(UMax); if (!vmininf) { - Cvmin = S->VIso(VMin); - if (BRepOffset_Tool::Gabarit( Cvmin ) <= TolApex) - vmindegen = Standard_True; + Cvmin = S->VIso(VMin); + if (BRepOffset_Tool::Gabarit( Cvmin ) <= TolApex) + vmindegen = Standard_True; } if (!vmaxinf) { - Cvmax = S->VIso(VMax); - if (BRepOffset_Tool::Gabarit( Cvmax ) <= TolApex) - vmaxdegen = Standard_True; + Cvmax = S->VIso(VMax); + if (BRepOffset_Tool::Gabarit( Cvmax ) <= TolApex) + vmaxdegen = Standard_True; } } @@ -2744,17 +2724,17 @@ static void MakeFace(const Handle(Geom_Surface)& S, eumax = eumin; else { if (hasiso) - B.MakeEdge(eumax,Cumax,tol); + B.MakeEdge(eumax,Cumax,tol); else - B.MakeEdge(eumax); + B.MakeEdge(eumax); B.UpdateEdge(eumax,Lumax,F,tol); if (!vmininf) { - V10.Orientation(TopAbs_FORWARD); - B.Add(eumax,V10); + V10.Orientation(TopAbs_FORWARD); + B.Add(eumax,V10); } if (!vmaxinf) { - V11.Orientation(TopAbs_REVERSED); - B.Add(eumax,V11); + V11.Orientation(TopAbs_REVERSED); + B.Add(eumax,V11); } B.Range(eumax,VMin,VMax); } @@ -2787,21 +2767,21 @@ static void MakeFace(const Handle(Geom_Surface)& S, evmax = evmin; else { if (hasiso && !vmaxdegen) - B.MakeEdge(evmax,Cvmax,tol); + B.MakeEdge(evmax,Cvmax,tol); else - B.MakeEdge(evmax); + B.MakeEdge(evmax); B.UpdateEdge(evmax,Lvmax,F,tol); if (!umininf) { - V01.Orientation(TopAbs_FORWARD); - B.Add(evmax,V01); + V01.Orientation(TopAbs_FORWARD); + B.Add(evmax,V01); } if (!umaxinf) { - V11.Orientation(TopAbs_REVERSED); - B.Add(evmax,V11); + V11.Orientation(TopAbs_REVERSED); + B.Add(evmax,V11); } B.Range(evmax,UMin,UMax); if (vmaxdegen) - B.Degenerated(evmax, Standard_True); + B.Degenerated(evmax, Standard_True); } } @@ -2852,19 +2832,19 @@ static void MakeFace(const Handle(Geom_Surface)& S, //======================================================================= static Standard_Boolean EnlargeGeometry(Handle(Geom_Surface)& S, - Standard_Real& U1, - Standard_Real& U2, - Standard_Real& V1, - Standard_Real& V2, - Standard_Boolean& IsV1degen, - Standard_Boolean& IsV2degen, - const Standard_Real uf1, - const Standard_Real uf2, - const Standard_Real vf1, - const Standard_Real vf2, - const Standard_Boolean GlobalEnlargeU, - const Standard_Boolean GlobalEnlargeVfirst, - const Standard_Boolean GlobalEnlargeVlast) + Standard_Real& U1, + Standard_Real& U2, + Standard_Real& V1, + Standard_Real& V2, + Standard_Boolean& IsV1degen, + Standard_Boolean& IsV2degen, + const Standard_Real uf1, + const Standard_Real uf2, + const Standard_Real vf1, + const Standard_Real vf2, + const Standard_Boolean GlobalEnlargeU, + const Standard_Boolean GlobalEnlargeVfirst, + const Standard_Boolean GlobalEnlargeVlast) { const Standard_Real coeff = 4.; const Standard_Real TolApex = 1.e-5; @@ -2873,7 +2853,7 @@ static Standard_Boolean EnlargeGeometry(Handle(Geom_Surface)& S, if ( S->DynamicType() == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) { Handle(Geom_Surface) BS = (*((Handle(Geom_RectangularTrimmedSurface)*)&S))->BasisSurface(); EnlargeGeometry(BS,U1,U2,V1,V2,IsV1degen,IsV2degen, - uf1,uf2,vf1,vf2,GlobalEnlargeU,GlobalEnlargeVfirst,GlobalEnlargeVlast); + uf1,uf2,vf1,vf2,GlobalEnlargeU,GlobalEnlargeVfirst,GlobalEnlargeVlast); if (!GlobalEnlargeVfirst) V1 = vf1; if (!GlobalEnlargeVlast) @@ -2888,11 +2868,11 @@ static Standard_Boolean EnlargeGeometry(Handle(Geom_Surface)& S, else if (S->DynamicType() == STANDARD_TYPE(Geom_OffsetSurface)) { Handle(Geom_Surface) Surf = (*((Handle(Geom_OffsetSurface)*)&S))->BasisSurface(); SurfaceChange = EnlargeGeometry(Surf,U1,U2,V1,V2,IsV1degen,IsV2degen, - uf1,uf2,vf1,vf2,GlobalEnlargeU,GlobalEnlargeVfirst,GlobalEnlargeVlast); + uf1,uf2,vf1,vf2,GlobalEnlargeU,GlobalEnlargeVfirst,GlobalEnlargeVlast); Handle(Geom_OffsetSurface)::DownCast(S)->SetBasisSurface(Surf); } else if (S->DynamicType() == STANDARD_TYPE(Geom_SurfaceOfLinearExtrusion) || - S->DynamicType() == STANDARD_TYPE(Geom_SurfaceOfRevolution)) + S->DynamicType() == STANDARD_TYPE(Geom_SurfaceOfRevolution)) { Standard_Real du=0., dv=0.; Handle( Geom_Curve ) uiso, viso, uiso1, uiso2, viso1, viso2; @@ -2902,81 +2882,81 @@ static Standard_Boolean EnlargeGeometry(Handle(Geom_Surface)& S, Standard_Boolean enlargeVfirst = GlobalEnlargeVfirst, enlargeVlast = GlobalEnlargeVlast; S->Bounds( u1, u2, v1, v2 ); if (Precision::IsInfinite(u1) || Precision::IsInfinite(u2)) - { - du = uf2-uf1; - u1 = uf1-du; - u2 = uf2+du; - enlargeU = Standard_False; - } + { + du = uf2-uf1; + u1 = uf1-du; + u2 = uf2+du; + enlargeU = Standard_False; + } else if (S->IsUClosed()) - enlargeU = Standard_False; + enlargeU = Standard_False; else - { - viso = S->VIso( vf1 ); - GeomAdaptor_Curve gac( viso ); - du = GCPnts_AbscissaPoint::Length( gac ) / coeff; - uiso1 = S->UIso( uf1 ); - uiso2 = S->UIso( uf2 ); - if (BRepOffset_Tool::Gabarit( uiso1 ) <= TolApex) - enlargeUfirst = Standard_False; - if (BRepOffset_Tool::Gabarit( uiso2 ) <= TolApex) - enlargeUlast = Standard_False; - } + { + viso = S->VIso( vf1 ); + GeomAdaptor_Curve gac( viso ); + du = GCPnts_AbscissaPoint::Length( gac ) / coeff; + uiso1 = S->UIso( uf1 ); + uiso2 = S->UIso( uf2 ); + if (BRepOffset_Tool::Gabarit( uiso1 ) <= TolApex) + enlargeUfirst = Standard_False; + if (BRepOffset_Tool::Gabarit( uiso2 ) <= TolApex) + enlargeUlast = Standard_False; + } if (Precision::IsInfinite(v1) || Precision::IsInfinite(v2)) - { - dv = vf2-vf1; - v1 = vf1-dv; - v2 = vf2+dv; - enlargeV = Standard_False; - } + { + dv = vf2-vf1; + v1 = vf1-dv; + v2 = vf2+dv; + enlargeV = Standard_False; + } else if (S->IsVClosed()) - enlargeV = Standard_False; + enlargeV = Standard_False; else - { - uiso = S->UIso( uf1 ); - GeomAdaptor_Curve gac( uiso ); - dv = GCPnts_AbscissaPoint::Length( gac ) / coeff; - viso1 = S->VIso( vf1 ); - viso2 = S->VIso( vf2 ); - if (BRepOffset_Tool::Gabarit( viso1 ) <= TolApex) - { - enlargeVfirst = Standard_False; - IsV1degen = Standard_True; - } - if (BRepOffset_Tool::Gabarit( viso2 ) <= TolApex) - { - enlargeVlast = Standard_False; - IsV2degen = Standard_True; - } - } + { + uiso = S->UIso( uf1 ); + GeomAdaptor_Curve gac( uiso ); + dv = GCPnts_AbscissaPoint::Length( gac ) / coeff; + viso1 = S->VIso( vf1 ); + viso2 = S->VIso( vf2 ); + if (BRepOffset_Tool::Gabarit( viso1 ) <= TolApex) + { + enlargeVfirst = Standard_False; + IsV1degen = Standard_True; + } + if (BRepOffset_Tool::Gabarit( viso2 ) <= TolApex) + { + enlargeVlast = Standard_False; + IsV2degen = Standard_True; + } + } S = new Geom_RectangularTrimmedSurface( S, u1, u2, v1, v2 ); if (enlargeU) - { - if (enlargeUfirst) - GeomLib::ExtendSurfByLength( *((Handle(Geom_BoundedSurface)*)&S), du, 1, Standard_True, Standard_False ); - if (enlargeUlast) - GeomLib::ExtendSurfByLength( *((Handle(Geom_BoundedSurface)*)&S), du, 1, Standard_True, Standard_True ); - } + { + if (enlargeUfirst) + GeomLib::ExtendSurfByLength( *((Handle(Geom_BoundedSurface)*)&S), du, 1, Standard_True, Standard_False ); + if (enlargeUlast) + GeomLib::ExtendSurfByLength( *((Handle(Geom_BoundedSurface)*)&S), du, 1, Standard_True, Standard_True ); + } if (enlargeV) - { - if (enlargeVfirst) - GeomLib::ExtendSurfByLength( *((Handle(Geom_BoundedSurface)*)&S), dv, 1, Standard_False, Standard_False ); - if (enlargeVlast) - GeomLib::ExtendSurfByLength( *((Handle(Geom_BoundedSurface)*)&S), dv, 1, Standard_False, Standard_True ); - } + { + if (enlargeVfirst) + GeomLib::ExtendSurfByLength( *((Handle(Geom_BoundedSurface)*)&S), dv, 1, Standard_False, Standard_False ); + if (enlargeVlast) + GeomLib::ExtendSurfByLength( *((Handle(Geom_BoundedSurface)*)&S), dv, 1, Standard_False, Standard_True ); + } S->Bounds( U1, U2, V1, V2 ); SurfaceChange = Standard_True; } else if (S->DynamicType() == STANDARD_TYPE(Geom_BezierSurface) || - S->DynamicType() == STANDARD_TYPE(Geom_BSplineSurface)) + S->DynamicType() == STANDARD_TYPE(Geom_BSplineSurface)) { Standard_Boolean enlargeU = GlobalEnlargeU, enlargeV = Standard_True; Standard_Boolean enlargeUfirst = enlargeU, enlargeUlast = enlargeU; Standard_Boolean enlargeVfirst = GlobalEnlargeVfirst, enlargeVlast = GlobalEnlargeVlast; if (S->IsUClosed()) - enlargeU = Standard_False; + enlargeU = Standard_False; if (S->IsVClosed()) - enlargeV = Standard_False; + enlargeV = Standard_False; Standard_Real duf = uf2-uf1, dvf = vf2-vf1; Standard_Real u1, u2, v1, v2; @@ -2986,56 +2966,56 @@ static Standard_Boolean EnlargeGeometry(Handle(Geom_Surface)& S, Handle( Geom_Curve ) uiso, viso, uiso1, uiso2, viso1, viso2; GeomAdaptor_Curve gac; if (enlargeU) - { - viso = S->VIso( v1 ); - gac.Load( viso ); - du = GCPnts_AbscissaPoint::Length( gac ) / coeff; - uiso1 = S->UIso( u1 ); - uiso2 = S->UIso( u2 ); - if (BRepOffset_Tool::Gabarit( uiso1 ) <= TolApex) - enlargeUfirst = Standard_False; - if (BRepOffset_Tool::Gabarit( uiso2 ) <= TolApex) - enlargeUlast = Standard_False; - } + { + viso = S->VIso( v1 ); + gac.Load( viso ); + du = GCPnts_AbscissaPoint::Length( gac ) / coeff; + uiso1 = S->UIso( u1 ); + uiso2 = S->UIso( u2 ); + if (BRepOffset_Tool::Gabarit( uiso1 ) <= TolApex) + enlargeUfirst = Standard_False; + if (BRepOffset_Tool::Gabarit( uiso2 ) <= TolApex) + enlargeUlast = Standard_False; + } if (enlargeV) - { - uiso = S->UIso( u1 ); - gac.Load( uiso ); - dv = GCPnts_AbscissaPoint::Length( gac ) / coeff; - viso1 = S->VIso( v1 ); - viso2 = S->VIso( v2 ); - if (BRepOffset_Tool::Gabarit( viso1 ) <= TolApex) - { - enlargeVfirst = Standard_False; - IsV1degen = Standard_True; - } - if (BRepOffset_Tool::Gabarit( viso2 ) <= TolApex) - { - enlargeVlast = Standard_False; - IsV2degen = Standard_True; - } - } + { + uiso = S->UIso( u1 ); + gac.Load( uiso ); + dv = GCPnts_AbscissaPoint::Length( gac ) / coeff; + viso1 = S->VIso( v1 ); + viso2 = S->VIso( v2 ); + if (BRepOffset_Tool::Gabarit( viso1 ) <= TolApex) + { + enlargeVfirst = Standard_False; + IsV1degen = Standard_True; + } + if (BRepOffset_Tool::Gabarit( viso2 ) <= TolApex) + { + enlargeVlast = Standard_False; + IsV2degen = Standard_True; + } + } if (enlargeU) - { - if (enlargeUfirst && uf1-u1 < duf) - GeomLib::ExtendSurfByLength( *((Handle(Geom_BoundedSurface)*)&S), du, 1, Standard_True, Standard_False ); - if (enlargeUlast && u2-uf2 < duf) - GeomLib::ExtendSurfByLength( *((Handle(Geom_BoundedSurface)*)&S), du, 1, Standard_True, Standard_True ); - } + { + if (enlargeUfirst && uf1-u1 < duf) + GeomLib::ExtendSurfByLength( *((Handle(Geom_BoundedSurface)*)&S), du, 1, Standard_True, Standard_False ); + if (enlargeUlast && u2-uf2 < duf) + GeomLib::ExtendSurfByLength( *((Handle(Geom_BoundedSurface)*)&S), du, 1, Standard_True, Standard_True ); + } if (enlargeV) - { - if (enlargeVfirst && vf1-v1 < dvf) - GeomLib::ExtendSurfByLength( *((Handle(Geom_BoundedSurface)*)&S), dv, 1, Standard_False, Standard_False ); - if (enlargeVlast && v2-vf2 < dvf) - GeomLib::ExtendSurfByLength( *((Handle(Geom_BoundedSurface)*)&S), dv, 1, Standard_False, Standard_True ); - } + { + if (enlargeVfirst && vf1-v1 < dvf) + GeomLib::ExtendSurfByLength( *((Handle(Geom_BoundedSurface)*)&S), dv, 1, Standard_False, Standard_False ); + if (enlargeVlast && v2-vf2 < dvf) + GeomLib::ExtendSurfByLength( *((Handle(Geom_BoundedSurface)*)&S), dv, 1, Standard_False, Standard_True ); + } S->Bounds( U1, U2, V1, V2 ); SurfaceChange = Standard_True; } // else if (S->DynamicType() == STANDARD_TYPE(Geom_BezierSurface) || -// S->DynamicType() == STANDARD_TYPE(Geom_BSplineSurface)) { +// S->DynamicType() == STANDARD_TYPE(Geom_BSplineSurface)) { // S->Bounds(U1,U2,V1,V2); // } else { @@ -3057,7 +3037,7 @@ static Standard_Boolean EnlargeGeometry(Handle(Geom_Surface)& S, //======================================================================= static void UpdatePCurves (const TopoDS_Face& F, - TopoDS_Face& BF) + TopoDS_Face& BF) { Standard_Real f,l; Standard_Integer i; @@ -3073,22 +3053,22 @@ static void UpdatePCurves (const TopoDS_Face& F, CE.Orientation( TopAbs_FORWARD ); Handle(Geom2d_Curve) C2 = BRep_Tool::CurveOnSurface( CE, F, f, l ); if (!C2.IsNull()) - { - if (BRep_Tool::IsClosed( CE, F )) - { - CE.Reverse(); - Handle(Geom2d_Curve) C2R = BRep_Tool::CurveOnSurface( CE, F, f, l ); - B.UpdateEdge( CE, NullPCurve, NullPCurve, F, BRep_Tool::Tolerance(CE) ); - B.UpdateEdge( CE, C2, C2R, BF, BRep_Tool::Tolerance(CE) ); - } - else - { - B.UpdateEdge( CE, NullPCurve, F, BRep_Tool::Tolerance(CE) ); - B.UpdateEdge( CE, C2, BF, BRep_Tool::Tolerance(CE) ); - } - - B.Range(CE,f,l); - } + { + if (BRep_Tool::IsClosed( CE, F )) + { + CE.Reverse(); + Handle(Geom2d_Curve) C2R = BRep_Tool::CurveOnSurface( CE, F, f, l ); + B.UpdateEdge( CE, NullPCurve, NullPCurve, F, BRep_Tool::Tolerance(CE) ); + B.UpdateEdge( CE, C2, C2R, BF, BRep_Tool::Tolerance(CE) ); + } + else + { + B.UpdateEdge( CE, NullPCurve, F, BRep_Tool::Tolerance(CE) ); + B.UpdateEdge( CE, C2, BF, BRep_Tool::Tolerance(CE) ); + } + + B.Range(CE,f,l); + } } } @@ -3098,17 +3078,17 @@ static void UpdatePCurves (const TopoDS_Face& F, //======================================================================= static void CompactUVBounds (const TopoDS_Face& F, - Standard_Real& UMin, - Standard_Real& UMax, - Standard_Real& VMin, - Standard_Real& VMax) + Standard_Real& UMin, + Standard_Real& UMax, + Standard_Real& VMin, + Standard_Real& VMax) { // Calcul serre pour que les bornes ne couvrent pas plus d une periode Standard_Real U1,U2; Standard_Real N = 33; Bnd_Box2d B; - TopExp_Explorer exp; + TopExp_Explorer exp; for (exp.Init(F, TopAbs_EDGE); exp.More(); exp.Next()) { const TopoDS_Edge& E = TopoDS::Edge(exp.Current()); BRepAdaptor_Curve2d C(E,F); @@ -3133,10 +3113,10 @@ static void CompactUVBounds (const TopoDS_Face& F, //======================================================================= void BRepOffset_Tool::CheckBounds(const TopoDS_Face& F, - const BRepOffset_Analyse& Analyse, - Standard_Boolean& enlargeU, - Standard_Boolean& enlargeVfirst, - Standard_Boolean& enlargeVlast) + const BRepOffset_Analyse& Analyse, + Standard_Boolean& enlargeU, + Standard_Boolean& enlargeVfirst, + Standard_Boolean& enlargeVlast) { enlargeU = Standard_True; enlargeVfirst = Standard_True; enlargeVlast = Standard_True; @@ -3159,78 +3139,78 @@ void BRepOffset_Tool::CheckBounds(const TopoDS_Face& F, { TopExp_Explorer Explo(F, TopAbs_EDGE); for (; Explo.More(); Explo.Next()) - { - const TopoDS_Edge& anEdge = TopoDS::Edge(Explo.Current()); - const BRepOffset_ListOfInterval& L = Analyse.Type(anEdge); - if (!L.IsEmpty() || BRep_Tool::Degenerated(anEdge)) - { - BRepOffset_Type OT = L.First().Type(); - if (OT == BRepOffset_Tangent || BRep_Tool::Degenerated(anEdge)) - { - Standard_Real fpar, lpar; - Handle(Geom2d_Curve) aCurve = BRep_Tool::CurveOnSurface(anEdge, F, fpar, lpar); - if (aCurve->DynamicType() == STANDARD_TYPE(Geom2d_TrimmedCurve)) - aCurve = (*((Handle(Geom2d_TrimmedCurve)*)&aCurve))->BasisCurve(); - - Handle(Geom2d_Line) theLine; - if (aCurve->DynamicType() == STANDARD_TYPE(Geom2d_Line)) - theLine = *((Handle(Geom2d_Line)*)&aCurve); - else if (aCurve->DynamicType() == STANDARD_TYPE(Geom2d_BezierCurve) || - aCurve->DynamicType() == STANDARD_TYPE(Geom2d_BSplineCurve)) - { - Standard_Real newFpar, newLpar, deviation; - theLine = ShapeCustom_Curve2d::ConvertToLine2d(aCurve, fpar, lpar, Precision::Confusion(), - newFpar, newLpar, deviation); - } - - if (!theLine.IsNull()) - { - gp_Dir2d theDir = theLine->Direction(); - if (theDir.IsParallel( gp::DX2d(), Precision::Angular() )) - { - Vbound++; - if (BRep_Tool::Degenerated(anEdge)) - { - if (Abs(theLine->Location().Y() - VF1) <= Precision::Confusion()) - enlargeVfirst = Standard_False; - else //theLine->Location().Y() is near VF2 - enlargeVlast = Standard_False; - } - else - { - if (theLine->Location().Y() < Vfirst) - Vfirst = theLine->Location().Y(); - if (theLine->Location().Y() > Vlast) - Vlast = theLine->Location().Y(); - } - } - else if (theDir.IsParallel( gp::DY2d(), Precision::Angular() )) - { - Ubound++; - if (theLine->Location().X() < Ufirst) - Ufirst = theLine->Location().X(); - if (theLine->Location().X() > Ulast) - Ulast = theLine->Location().X(); - } - } - } - } - } + { + const TopoDS_Edge& anEdge = TopoDS::Edge(Explo.Current()); + const BRepOffset_ListOfInterval& L = Analyse.Type(anEdge); + if (!L.IsEmpty() || BRep_Tool::Degenerated(anEdge)) + { + BRepOffset_Type OT = L.First().Type(); + if (OT == BRepOffset_Tangent || BRep_Tool::Degenerated(anEdge)) + { + Standard_Real fpar, lpar; + Handle(Geom2d_Curve) aCurve = BRep_Tool::CurveOnSurface(anEdge, F, fpar, lpar); + if (aCurve->DynamicType() == STANDARD_TYPE(Geom2d_TrimmedCurve)) + aCurve = (*((Handle(Geom2d_TrimmedCurve)*)&aCurve))->BasisCurve(); + + Handle(Geom2d_Line) theLine; + if (aCurve->DynamicType() == STANDARD_TYPE(Geom2d_Line)) + theLine = *((Handle(Geom2d_Line)*)&aCurve); + else if (aCurve->DynamicType() == STANDARD_TYPE(Geom2d_BezierCurve) || + aCurve->DynamicType() == STANDARD_TYPE(Geom2d_BSplineCurve)) + { + Standard_Real newFpar, newLpar, deviation; + theLine = ShapeCustom_Curve2d::ConvertToLine2d(aCurve, fpar, lpar, Precision::Confusion(), + newFpar, newLpar, deviation); + } + + if (!theLine.IsNull()) + { + gp_Dir2d theDir = theLine->Direction(); + if (theDir.IsParallel( gp::DX2d(), Precision::Angular() )) + { + Vbound++; + if (BRep_Tool::Degenerated(anEdge)) + { + if (Abs(theLine->Location().Y() - VF1) <= Precision::Confusion()) + enlargeVfirst = Standard_False; + else //theLine->Location().Y() is near VF2 + enlargeVlast = Standard_False; + } + else + { + if (theLine->Location().Y() < Vfirst) + Vfirst = theLine->Location().Y(); + if (theLine->Location().Y() > Vlast) + Vlast = theLine->Location().Y(); + } + } + else if (theDir.IsParallel( gp::DY2d(), Precision::Angular() )) + { + Ubound++; + if (theLine->Location().X() < Ufirst) + Ufirst = theLine->Location().X(); + if (theLine->Location().X() > Ulast) + Ulast = theLine->Location().X(); + } + } + } + } + } } if (Ubound >= 2 || Vbound >= 2) { if (Ubound >= 2 && - Abs(UF1-Ufirst) <= Precision::Confusion() && - Abs(UF2-Ulast) <= Precision::Confusion()) - enlargeU = Standard_False; + Abs(UF1-Ufirst) <= Precision::Confusion() && + Abs(UF2-Ulast) <= Precision::Confusion()) + enlargeU = Standard_False; if (Vbound >= 2 && - Abs(VF1-Vfirst) <= Precision::Confusion() && - Abs(VF2-Vlast) <= Precision::Confusion()) - { - enlargeVfirst = Standard_False; - enlargeVlast = Standard_False; - } + Abs(VF1-Vfirst) <= Precision::Confusion() && + Abs(VF2-Vlast) <= Precision::Confusion()) + { + enlargeVfirst = Standard_False; + enlargeVlast = Standard_False; + } } } @@ -3262,7 +3242,7 @@ Standard_Boolean BRepOffset_Tool::EnLargeFace if (S->IsUPeriodic() || S->IsVPeriodic()) { // Calcul serre pour que les bornes ne couvre pas plus d une periode - CompactUVBounds(F,UF1,UF2,VF1,VF2); + CompactUVBounds(F,UF1,UF2,VF1,VF2); } else { BRepTools::UVBounds(F,UF1,UF2,VF1,VF2); @@ -3274,7 +3254,7 @@ Standard_Boolean BRepOffset_Tool::EnLargeFace if (CanExtentSurface) { SurfaceChange = EnlargeGeometry( S, UU1, UU2, VV1, VV2, isVV1degen, isVV2degen, UF1, UF2, VF1, VF2, - enlargeU, enlargeVfirst, enlargeVlast ); + enlargeU, enlargeVfirst, enlargeVlast ); } else { UU1 = Max(US1,UU1); UU2 = Min(UU2,US2); @@ -3312,15 +3292,15 @@ Standard_Boolean BRepOffset_Tool::EnLargeFace Standard_Real Uapex, Vapex; ElSLib::Parameters( theCone, theApex, Uapex, Vapex ); if (VV1 < Vapex && Vapex < VV2) - { - //consider that VF1 and VF2 are on the same side from apex - Standard_Real TolApex = 1.e-5; - if (Vapex - VF1 >= TolApex || - Vapex - VF2 >= TolApex) //if (VF1 < Vapex || VF2 < Vapex) - VV2 = Vapex; - else - VV1 = Vapex; - } + { + //consider that VF1 and VF2 are on the same side from apex + Standard_Real TolApex = 1.e-5; + if (Vapex - VF1 >= TolApex || + Vapex - VF2 >= TolApex) //if (VF1 < Vapex || VF2 < Vapex) + VV2 = Vapex; + else + VV1 = Vapex; + } } if (!enlargeU) @@ -3371,9 +3351,9 @@ Standard_Boolean BRepOffset_Tool::EnLargeFace //======================================================================= static Standard_Boolean TryParameter (const TopoDS_Edge& OE, - TopoDS_Vertex& V, - const TopoDS_Edge& NE, - Standard_Real TolConf) + TopoDS_Vertex& V, + const TopoDS_Edge& NE, + Standard_Real TolConf) { BRepAdaptor_Curve OC(OE); BRepAdaptor_Curve NC(NE); @@ -3406,9 +3386,9 @@ static Standard_Boolean TryParameter (const TopoDS_Edge& OE, // TopoDS_Edge EE = TopoDS::Edge(NE.Oriented(TopAbs_FORWARD)); aLocalShape = V.Oriented(TopAbs_INTERNAL); B.UpdateVertex(TopoDS::Vertex(aLocalShape), - U,NE,BRep_Tool::Tolerance(NE)); + U,NE,BRep_Tool::Tolerance(NE)); // B.UpdateVertex(TopoDS::Vertex(V.Oriented(TopAbs_INTERNAL)), -// U,NE,BRep_Tool::Tolerance(NE)); +// U,NE,BRep_Tool::Tolerance(NE)); } return OK; } @@ -3419,7 +3399,7 @@ static Standard_Boolean TryParameter (const TopoDS_Edge& OE, //======================================================================= void BRepOffset_Tool::MapVertexEdges (const TopoDS_Shape& S, - TopTools_DataMapOfShapeListOfShape& MEV) + TopTools_DataMapOfShapeListOfShape& MEV) { TopExp_Explorer exp; exp.Init(S.Oriented(TopAbs_FORWARD),TopAbs_EDGE); @@ -3430,16 +3410,16 @@ void BRepOffset_Tool::MapVertexEdges (const TopoDS_Shape& S, TopoDS_Vertex V1,V2; TopExp::Vertices (E,V1,V2); if (!MEV.IsBound(V1)) { - TopTools_ListOfShape empty; - MEV.Bind(V1,empty); + TopTools_ListOfShape empty; + MEV.Bind(V1,empty); } MEV(V1).Append(E); if (!V1.IsSame(V2)) { - if (!MEV.IsBound(V2)) { - TopTools_ListOfShape empty; - MEV.Bind(V2,empty); - } - MEV(V2).Append(E); + if (!MEV.IsBound(V2)) { + TopTools_ListOfShape empty; + MEV.Bind(V2,empty); + } + MEV(V2).Append(E); } } } @@ -3451,9 +3431,9 @@ void BRepOffset_Tool::MapVertexEdges (const TopoDS_Shape& S, //======================================================================= void BRepOffset_Tool::BuildNeighbour (const TopoDS_Wire& W, - const TopoDS_Face& F, - TopTools_DataMapOfShapeShape& NOnV1, - TopTools_DataMapOfShapeShape& NOnV2) + const TopoDS_Face& F, + TopTools_DataMapOfShapeShape& NOnV1, + TopTools_DataMapOfShapeShape& NOnV2) { TopoDS_Vertex V1,V2,VP1,VP2,FV1,FV2; TopoDS_Edge CurE,FirstE,PrecE; @@ -3463,7 +3443,7 @@ void BRepOffset_Tool::BuildNeighbour (const TopoDS_Wire& W, TopoDS_Shape aLocalWire = W.Oriented(TopAbs_FORWARD); wexp.Init(TopoDS::Wire(aLocalWire),TopoDS::Face(aLocalFace)); // wexp.Init(TopoDS::Wire(W.Oriented(TopAbs_FORWARD)), -// TopoDS::Face(F.Oriented(TopAbs_FORWARD))); +// TopoDS::Face(F.Oriented(TopAbs_FORWARD))); CurE = FirstE = PrecE = wexp.Current(); TopExp::Vertices(CurE,V1,V2); FV1 = VP1 = V1; FV2 = VP2 = V2; @@ -3491,11 +3471,11 @@ void BRepOffset_Tool::BuildNeighbour (const TopoDS_Wire& W, //======================================================================= void BRepOffset_Tool::ExtentFace (const TopoDS_Face& F, - TopTools_DataMapOfShapeShape& ConstShapes, - TopTools_DataMapOfShapeShape& ToBuild, - const TopAbs_State Side, - const Standard_Real TolConf, - TopoDS_Face& NF) + TopTools_DataMapOfShapeShape& ConstShapes, + TopTools_DataMapOfShapeShape& ToBuild, + const TopAbs_State Side, + const Standard_Real TolConf, + TopoDS_Face& NF) { #ifdef DRAW if (AffichInter) { @@ -3546,28 +3526,28 @@ void BRepOffset_Tool::ExtentFace (const TopoDS_Face& F, TopoDS_Edge Ecs; //patch Handle(Geom2d_Curve) C2 = BRep_Tool::CurveOnSurface(CE,Fforward,f,l); if (!C2.IsNull()) { - if (ConstShapes.IsBound(CE)) { - Ecs = TopoDS::Edge(ConstShapes(CE)); - BRep_Tool::Range(Ecs,f,l); - } - if (BRep_Tool::IsClosed(CE,Fforward)) { - TopoDS_Shape aLocalShape = CE.Reversed(); - Handle(Geom2d_Curve) C2R = - BRep_Tool::CurveOnSurface(TopoDS::Edge(aLocalShape),Fforward,f,l); -// Handle(Geom2d_Curve) C2R = -// BRep_Tool::CurveOnSurface(TopoDS::Edge(CE.Reversed()),F,f,l); - B.UpdateEdge (CE,C2,C2R,EF,BRep_Tool::Tolerance(CE)); - if (! Ecs.IsNull()) - B.UpdateEdge (Ecs,C2,C2R,EF,BRep_Tool::Tolerance(CE)); - } - else { - B.UpdateEdge (CE,C2,EF,BRep_Tool::Tolerance(CE)); - if (! Ecs.IsNull()) - B.UpdateEdge (Ecs,C2,EF,BRep_Tool::Tolerance(CE)); - } - B.Range(CE,f,l); - if (! Ecs.IsNull()) - B.Range(Ecs,f,l); + if (ConstShapes.IsBound(CE)) { + Ecs = TopoDS::Edge(ConstShapes(CE)); + BRep_Tool::Range(Ecs,f,l); + } + if (BRep_Tool::IsClosed(CE,Fforward)) { + TopoDS_Shape aLocalShape = CE.Reversed(); + Handle(Geom2d_Curve) C2R = + BRep_Tool::CurveOnSurface(TopoDS::Edge(aLocalShape),Fforward,f,l); +// Handle(Geom2d_Curve) C2R = +// BRep_Tool::CurveOnSurface(TopoDS::Edge(CE.Reversed()),F,f,l); + B.UpdateEdge (CE,C2,C2R,EF,BRep_Tool::Tolerance(CE)); + if (! Ecs.IsNull()) + B.UpdateEdge (Ecs,C2,C2R,EF,BRep_Tool::Tolerance(CE)); + } + else { + B.UpdateEdge (CE,C2,EF,BRep_Tool::Tolerance(CE)); + if (! Ecs.IsNull()) + B.UpdateEdge (Ecs,C2,EF,BRep_Tool::Tolerance(CE)); + } + B.Range(CE,f,l); + if (! Ecs.IsNull()) + B.Range(Ecs,f,l); } } } @@ -3589,21 +3569,21 @@ void BRepOffset_Tool::ExtentFace (const TopoDS_Face& F, // Construction edges //------------------------------------------------ for (exp2.Init(W.Oriented(TopAbs_FORWARD),TopAbs_EDGE); - exp2.More(); exp2.Next()) { + exp2.More(); exp2.Next()) { const TopoDS_Edge& E = TopoDS::Edge(exp2.Current()); if (ConstShapes.IsBound(E)) ToBuild.UnBind(E); if (ToBuild.IsBound(E)) { - TopTools_ListOfShape LOE; - LOE.Append(E); - BRepOffset_Tool::TryProject (TopoDS::Face(ToBuild(E)), - EF,LOE,LInt2,LInt1,Side,TolConf); - if (!LInt1.IsEmpty()) - ToBuild.UnBind(E); + TopTools_ListOfShape LOE; + LOE.Append(E); + BRepOffset_Tool::TryProject (TopoDS::Face(ToBuild(E)), + EF,LOE,LInt2,LInt1,Side,TolConf); + if (!LInt1.IsEmpty()) + ToBuild.UnBind(E); } } for (exp2.Init(W.Oriented(TopAbs_FORWARD),TopAbs_EDGE); - exp2.More(); exp2.Next()) { + exp2.More(); exp2.Next()) { const TopoDS_Edge& E = TopoDS::Edge(exp2.Current()); if (ConstShapes.IsBound(E)) ToBuild.UnBind(E); if (ToBuild.IsBound(E)) { @@ -3614,33 +3594,33 @@ void BRepOffset_Tool::ExtentFace (const TopoDS_Face& F, // the radius of the cylinder becomes smaller. if (LInt1.IsEmpty()) continue; - if (LInt1.Extent() > 1) { - // l intersection est en plusieurs edges (franchissement de couture) - SelectEdge (F,EF,E,LInt1); - } - NE = TopoDS::Edge(LInt1.First()); - Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &NE.TShape()); - TE->Tolerance( TE->Tolerance()*10. ); //???? - if (NE.Orientation() == E.Orientation()) { - Build.Bind(E,NE.Oriented(TopAbs_FORWARD)); - } - else { - Build.Bind(E,NE.Oriented(TopAbs_REVERSED)); - } - const TopoDS_Edge& EOnV1 = TopoDS::Edge(NOnV1(E)); - if (!ToBuild .IsBound(EOnV1) && - !ConstShapes.IsBound(EOnV1) && - !Build .IsBound(EOnV1)) { - ExtentEdge (F,EF,EOnV1,NE); - Build.Bind (EOnV1,NE.Oriented(TopAbs_FORWARD)); - } - const TopoDS_Edge& EOnV2 = TopoDS::Edge(NOnV2(E)); - if (!ToBuild .IsBound(EOnV2) && - !ConstShapes.IsBound(EOnV2) && - !Build .IsBound(EOnV2)) { - ExtentEdge (F,EF,EOnV2,NE); - Build.Bind (EOnV2,NE.Oriented (TopAbs_FORWARD)); - } + if (LInt1.Extent() > 1) { + // l intersection est en plusieurs edges (franchissement de couture) + SelectEdge (F,EF,E,LInt1); + } + NE = TopoDS::Edge(LInt1.First()); + Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &NE.TShape()); + TE->Tolerance( TE->Tolerance()*10. ); //???? + if (NE.Orientation() == E.Orientation()) { + Build.Bind(E,NE.Oriented(TopAbs_FORWARD)); + } + else { + Build.Bind(E,NE.Oriented(TopAbs_REVERSED)); + } + const TopoDS_Edge& EOnV1 = TopoDS::Edge(NOnV1(E)); + if (!ToBuild .IsBound(EOnV1) && + !ConstShapes.IsBound(EOnV1) && + !Build .IsBound(EOnV1)) { + ExtentEdge (F,EF,EOnV1,NE); + Build.Bind (EOnV1,NE.Oriented(TopAbs_FORWARD)); + } + const TopoDS_Edge& EOnV2 = TopoDS::Edge(NOnV2(E)); + if (!ToBuild .IsBound(EOnV2) && + !ConstShapes.IsBound(EOnV2) && + !Build .IsBound(EOnV2)) { + ExtentEdge (F,EF,EOnV2,NE); + Build.Bind (EOnV2,NE.Oriented (TopAbs_FORWARD)); + } } } @@ -3653,100 +3633,100 @@ void BRepOffset_Tool::ExtentFace (const TopoDS_Face& F, TopoDS_Vertex V1,V2; for (exp2.Init(W.Oriented(TopAbs_FORWARD),TopAbs_EDGE); - exp2.More(); exp2.Next()) { + exp2.More(); exp2.Next()) { const TopoDS_Edge& E = TopoDS::Edge(exp2.Current()); TopExp::Vertices (E,V1,V2); BRep_Tool::Range (E,f,l); TopoDS_Vertex V; if (Build.IsBound(E)) { - const TopoDS_Edge& NEOnV1 = TopoDS::Edge(NOnV1(E)); - if (Build.IsBound(NEOnV1) && - (ToBuild.IsBound(E) || ToBuild.IsBound(NEOnV1))) { - if (E.IsSame(NEOnV1)) - V = TopExp::FirstVertex(TopoDS::Edge(Build(E))); - else { - //--------------- - // intersection. - //--------------- - if (!Build.IsBound(V1)) { - Inter2d (EF,TopoDS::Edge(Build(E)), - TopoDS::Edge(Build(NEOnV1)),LV,/*TolConf*/Precision::Confusion()); - if (Build(E).Orientation() == TopAbs_FORWARD) { - V = TopoDS::Vertex(LV.First()); - } - else { - V = TopoDS::Vertex(LV.Last()); - } - } - else { - V = TopoDS::Vertex(Build(V1)); - if (MVE (V1).Extent() > 2) { - V.Orientation(TopAbs_FORWARD); - if (Build(E).Orientation() == TopAbs_REVERSED) - V.Orientation(TopAbs_REVERSED); - ProjectVertexOnEdge(V,TopoDS::Edge(Build(E)),TolConf); - } - } - } - } - else { - //------------ - //projection - //------------ - V = V1; - if (ConstShapes.IsBound(V1)) V = TopoDS::Vertex(ConstShapes(V1)); - V.Orientation(TopAbs_FORWARD); - if (Build(E).Orientation() == TopAbs_REVERSED) - V.Orientation(TopAbs_REVERSED); - if (!TryParameter (E,V,TopoDS::Edge(Build(E)),TolConf)) - ProjectVertexOnEdge(V,TopoDS::Edge(Build(E)),TolConf); - } - ConstShapes.Bind(V1,V); - Build.Bind (V1,V); - const TopoDS_Edge& NEOnV2 = TopoDS::Edge(NOnV2(E)); - if (Build.IsBound(NEOnV2) && - (ToBuild.IsBound(E) || ToBuild.IsBound(NEOnV2))) { - if (E.IsSame(NEOnV2)) - V = TopExp::LastVertex(TopoDS::Edge(Build(E))); - else { - //-------------- - // intersection. - //--------------- - if (!Build.IsBound(V2)) { - Inter2d (EF,TopoDS::Edge(Build(E)), - TopoDS::Edge(Build(NEOnV2)),LV,/*TolConf*/Precision::Confusion()); - if (Build(E).Orientation() == TopAbs_FORWARD) { - V = TopoDS::Vertex(LV.Last()); - } - else { - V = TopoDS::Vertex(LV.First()); - } - } - else { - V = TopoDS::Vertex(Build(V2)); - if (MVE (V2).Extent() > 2) { - V.Orientation(TopAbs_REVERSED); - if (Build(E).Orientation() == TopAbs_REVERSED) - V.Orientation(TopAbs_FORWARD); - ProjectVertexOnEdge(V,TopoDS::Edge(Build(E)),TolConf); - } - } - } - } - else { - //------------ - //projection - //------------ - V = V2; - if (ConstShapes.IsBound(V2)) V = TopoDS::Vertex(ConstShapes(V2)); - V.Orientation(TopAbs_REVERSED); - if (Build(E).Orientation() == TopAbs_REVERSED) - V.Orientation(TopAbs_FORWARD); - if (!TryParameter (E,V,TopoDS::Edge(Build(E)),TolConf)) - ProjectVertexOnEdge(V,TopoDS::Edge(Build(E)),TolConf); - } - ConstShapes.Bind(V2,V); - Build.Bind(V2,V); + const TopoDS_Edge& NEOnV1 = TopoDS::Edge(NOnV1(E)); + if (Build.IsBound(NEOnV1) && + (ToBuild.IsBound(E) || ToBuild.IsBound(NEOnV1))) { + if (E.IsSame(NEOnV1)) + V = TopExp::FirstVertex(TopoDS::Edge(Build(E))); + else { + //--------------- + // intersection. + //--------------- + if (!Build.IsBound(V1)) { + Inter2d (EF,TopoDS::Edge(Build(E)), + TopoDS::Edge(Build(NEOnV1)),LV,/*TolConf*/Precision::Confusion()); + if (Build(E).Orientation() == TopAbs_FORWARD) { + V = TopoDS::Vertex(LV.First()); + } + else { + V = TopoDS::Vertex(LV.Last()); + } + } + else { + V = TopoDS::Vertex(Build(V1)); + if (MVE (V1).Extent() > 2) { + V.Orientation(TopAbs_FORWARD); + if (Build(E).Orientation() == TopAbs_REVERSED) + V.Orientation(TopAbs_REVERSED); + ProjectVertexOnEdge(V,TopoDS::Edge(Build(E)),TolConf); + } + } + } + } + else { + //------------ + //projection + //------------ + V = V1; + if (ConstShapes.IsBound(V1)) V = TopoDS::Vertex(ConstShapes(V1)); + V.Orientation(TopAbs_FORWARD); + if (Build(E).Orientation() == TopAbs_REVERSED) + V.Orientation(TopAbs_REVERSED); + if (!TryParameter (E,V,TopoDS::Edge(Build(E)),TolConf)) + ProjectVertexOnEdge(V,TopoDS::Edge(Build(E)),TolConf); + } + ConstShapes.Bind(V1,V); + Build.Bind (V1,V); + const TopoDS_Edge& NEOnV2 = TopoDS::Edge(NOnV2(E)); + if (Build.IsBound(NEOnV2) && + (ToBuild.IsBound(E) || ToBuild.IsBound(NEOnV2))) { + if (E.IsSame(NEOnV2)) + V = TopExp::LastVertex(TopoDS::Edge(Build(E))); + else { + //-------------- + // intersection. + //--------------- + if (!Build.IsBound(V2)) { + Inter2d (EF,TopoDS::Edge(Build(E)), + TopoDS::Edge(Build(NEOnV2)),LV,/*TolConf*/Precision::Confusion()); + if (Build(E).Orientation() == TopAbs_FORWARD) { + V = TopoDS::Vertex(LV.Last()); + } + else { + V = TopoDS::Vertex(LV.First()); + } + } + else { + V = TopoDS::Vertex(Build(V2)); + if (MVE (V2).Extent() > 2) { + V.Orientation(TopAbs_REVERSED); + if (Build(E).Orientation() == TopAbs_REVERSED) + V.Orientation(TopAbs_FORWARD); + ProjectVertexOnEdge(V,TopoDS::Edge(Build(E)),TolConf); + } + } + } + } + else { + //------------ + //projection + //------------ + V = V2; + if (ConstShapes.IsBound(V2)) V = TopoDS::Vertex(ConstShapes(V2)); + V.Orientation(TopAbs_REVERSED); + if (Build(E).Orientation() == TopAbs_REVERSED) + V.Orientation(TopAbs_FORWARD); + if (!TryParameter (E,V,TopoDS::Edge(Build(E)),TolConf)) + ProjectVertexOnEdge(V,TopoDS::Edge(Build(E)),TolConf); + } + ConstShapes.Bind(V2,V); + Build.Bind(V2,V); } } @@ -3765,149 +3745,149 @@ void BRepOffset_Tool::ExtentFace (const TopoDS_Face& F, // Reconstruction. //----------------- for (exp2.Init(W.Oriented(TopAbs_FORWARD),TopAbs_EDGE); - exp2.More(); exp2.Next()) { + exp2.More(); exp2.Next()) { const TopoDS_Edge& E = TopoDS::Edge(exp2.Current()); TopExp::Vertices (E,V1,V2); if (Build.IsBound(E)) { - NE = TopoDS::Edge(Build(E)); - BRep_Tool::Range(NE,f,l); - Or = NE.Orientation(); - //----------------------------------------------------- - // Copy pour virer les vertex deja sur la nouvelle edge. - //----------------------------------------------------- - NV1 = TopoDS::Vertex(ConstShapes(V1)); - NV2 = TopoDS::Vertex(ConstShapes(V2)); - - TopoDS_Shape aLocalVertex = NV1.Oriented(TopAbs_INTERNAL); - TopoDS_Shape aLocalEdge = NE.Oriented(TopAbs_INTERNAL); - - U1 = BRep_Tool::Parameter(TopoDS::Vertex(aLocalVertex), - TopoDS::Edge (aLocalEdge)); - aLocalVertex = NV2.Oriented(TopAbs_INTERNAL); - aLocalEdge = NE.Oriented(TopAbs_FORWARD); - U2 = BRep_Tool::Parameter - (TopoDS::Vertex(aLocalVertex),TopoDS::Edge (aLocalEdge)); -// U1 = BRep_Tool::Parameter -// (TopoDS::Vertex(NV1.Oriented(TopAbs_INTERNAL)), -// TopoDS::Edge (NE .Oriented(TopAbs_FORWARD))); -// U2 = BRep_Tool::Parameter -// (TopoDS::Vertex(NV2.Oriented(TopAbs_INTERNAL)), -// TopoDS::Edge (NE.Oriented(TopAbs_FORWARD))); - aLocalEdge = NE.EmptyCopied(); - NE = TopoDS::Edge(aLocalEdge); - NE.Orientation(TopAbs_FORWARD); - if (NV1.IsSame(NV2)) - { - //-------------- - // edge ferme. - //-------------- - if (Or == TopAbs_FORWARD) {U1 = f; U2 = l;} - else {U1 = l; U2 = f;} - if (Or == TopAbs_FORWARD) - { - if (U1 > U2) - { - if (Abs(U1-l) < eps) U1 = f; - if (Abs(U2-f) < eps) U2 = l; - } - TopoDS_Shape aLocalVertex = NV1.Oriented(TopAbs_FORWARD ); - B.Add (NE,TopoDS::Vertex(aLocalVertex)); - aLocalVertex = NV2.Oriented(TopAbs_REVERSED); - B.Add (NE,TopoDS::Vertex(aLocalVertex)); -// B.Add (NE,TopoDS::Vertex(NV1.Oriented(TopAbs_FORWARD ))); -// B.Add (NE,TopoDS::Vertex(NV2.Oriented(TopAbs_REVERSED))); - B.Range(NE,U1,U2); - ConstShapes.Bind(E,NE); - NE.Orientation(E.Orientation()); - } - else - { - if (U2 > U1) - { - if (Abs(U2-l) < eps) U2 = f; - if (Abs(U1-f) < eps) U1 = l; - } - TopoDS_Shape aLocalVertex = NV2.Oriented(TopAbs_FORWARD ); - B.Add (NE,TopoDS::Vertex(aLocalVertex)); - aLocalVertex = NV1.Oriented(TopAbs_REVERSED); - B.Add (NE,TopoDS::Vertex(aLocalVertex)); -// B.Add (NE,TopoDS::Vertex(NV2.Oriented(TopAbs_FORWARD ))); -// B.Add (NE,TopoDS::Vertex(NV1.Oriented(TopAbs_REVERSED))); - B.Range(NE,U2,U1); - ConstShapes.Bind(E,NE.Oriented(TopAbs_REVERSED)); - NE.Orientation(TopAbs::Reverse(E.Orientation())); - } - } - else - { - //------------------- - // edge is not ferme. - //------------------- - if (Or == TopAbs_FORWARD) { - if (U1 > U2) { - TopoDS_Shape aLocalVertex = NV2.Oriented(TopAbs_FORWARD ); - B.Add (NE,TopoDS::Vertex(aLocalVertex)); - aLocalVertex = NV1.Oriented(TopAbs_REVERSED); - B.Add (NE,TopoDS::Vertex(aLocalVertex)); -// B.Add (NE,TopoDS::Vertex(NV2.Oriented(TopAbs_FORWARD ))); -// B.Add (NE,TopoDS::Vertex(NV1.Oriented(TopAbs_REVERSED))); - B.Range(NE,U2,U1); - } - else - { - TopoDS_Shape aLocalVertex = NV1.Oriented(TopAbs_FORWARD ); - B.Add (NE,TopoDS::Vertex(aLocalVertex)); - aLocalVertex = NV2.Oriented(TopAbs_REVERSED); - B.Add (NE,TopoDS::Vertex(aLocalVertex)); -// B.Add (NE,TopoDS::Vertex(NV1.Oriented(TopAbs_FORWARD ))); -// B.Add (NE,TopoDS::Vertex(NV2.Oriented(TopAbs_REVERSED))); - B.Range(NE,U1,U2); - } - ConstShapes.Bind(E,NE); - NE.Orientation(E.Orientation()); - } - else { - if (U2 > U1) { - TopoDS_Shape aLocalVertex = NV1.Oriented(TopAbs_FORWARD ); - B.Add (NE,TopoDS::Vertex(aLocalVertex)); - aLocalVertex = NV2.Oriented(TopAbs_REVERSED); - B.Add (NE,TopoDS::Vertex(aLocalVertex)); -// B.Add (NE,TopoDS::Vertex(NV1.Oriented(TopAbs_FORWARD ))); -// B.Add (NE,TopoDS::Vertex(NV2.Oriented(TopAbs_REVERSED))); - B.Range(NE,U1,U2); - ConstShapes.Bind(E,NE); - NE.Orientation(E.Orientation()); - } - else - { - TopoDS_Shape aLocalVertex = NV2.Oriented(TopAbs_FORWARD ); - B.Add (NE,TopoDS::Vertex(aLocalVertex)); - aLocalVertex = NV1.Oriented(TopAbs_REVERSED); - B.Add (NE,TopoDS::Vertex(aLocalVertex)); -// B.Add (NE,TopoDS::Vertex(NV2.Oriented(TopAbs_FORWARD ))); -// B.Add (NE,TopoDS::Vertex(NV1.Oriented(TopAbs_REVERSED))); - B.Range(NE,U2,U1); - ConstShapes.Bind(E,NE.Oriented(TopAbs_REVERSED)); - NE.Orientation(TopAbs::Reverse(E.Orientation())); - } - } - } - Build.UnBind(E); + NE = TopoDS::Edge(Build(E)); + BRep_Tool::Range(NE,f,l); + Or = NE.Orientation(); + //----------------------------------------------------- + // Copy pour virer les vertex deja sur la nouvelle edge. + //----------------------------------------------------- + NV1 = TopoDS::Vertex(ConstShapes(V1)); + NV2 = TopoDS::Vertex(ConstShapes(V2)); + + TopoDS_Shape aLocalVertex = NV1.Oriented(TopAbs_INTERNAL); + TopoDS_Shape aLocalEdge = NE.Oriented(TopAbs_INTERNAL); + + U1 = BRep_Tool::Parameter(TopoDS::Vertex(aLocalVertex), + TopoDS::Edge (aLocalEdge)); + aLocalVertex = NV2.Oriented(TopAbs_INTERNAL); + aLocalEdge = NE.Oriented(TopAbs_FORWARD); + U2 = BRep_Tool::Parameter + (TopoDS::Vertex(aLocalVertex),TopoDS::Edge (aLocalEdge)); +// U1 = BRep_Tool::Parameter +// (TopoDS::Vertex(NV1.Oriented(TopAbs_INTERNAL)), +// TopoDS::Edge (NE .Oriented(TopAbs_FORWARD))); +// U2 = BRep_Tool::Parameter +// (TopoDS::Vertex(NV2.Oriented(TopAbs_INTERNAL)), +// TopoDS::Edge (NE.Oriented(TopAbs_FORWARD))); + aLocalEdge = NE.EmptyCopied(); + NE = TopoDS::Edge(aLocalEdge); + NE.Orientation(TopAbs_FORWARD); + if (NV1.IsSame(NV2)) + { + //-------------- + // edge ferme. + //-------------- + if (Or == TopAbs_FORWARD) {U1 = f; U2 = l;} + else {U1 = l; U2 = f;} + if (Or == TopAbs_FORWARD) + { + if (U1 > U2) + { + if (Abs(U1-l) < eps) U1 = f; + if (Abs(U2-f) < eps) U2 = l; + } + TopoDS_Shape aLocalVertex = NV1.Oriented(TopAbs_FORWARD ); + B.Add (NE,TopoDS::Vertex(aLocalVertex)); + aLocalVertex = NV2.Oriented(TopAbs_REVERSED); + B.Add (NE,TopoDS::Vertex(aLocalVertex)); +// B.Add (NE,TopoDS::Vertex(NV1.Oriented(TopAbs_FORWARD ))); +// B.Add (NE,TopoDS::Vertex(NV2.Oriented(TopAbs_REVERSED))); + B.Range(NE,U1,U2); + ConstShapes.Bind(E,NE); + NE.Orientation(E.Orientation()); + } + else + { + if (U2 > U1) + { + if (Abs(U2-l) < eps) U2 = f; + if (Abs(U1-f) < eps) U1 = l; + } + TopoDS_Shape aLocalVertex = NV2.Oriented(TopAbs_FORWARD ); + B.Add (NE,TopoDS::Vertex(aLocalVertex)); + aLocalVertex = NV1.Oriented(TopAbs_REVERSED); + B.Add (NE,TopoDS::Vertex(aLocalVertex)); +// B.Add (NE,TopoDS::Vertex(NV2.Oriented(TopAbs_FORWARD ))); +// B.Add (NE,TopoDS::Vertex(NV1.Oriented(TopAbs_REVERSED))); + B.Range(NE,U2,U1); + ConstShapes.Bind(E,NE.Oriented(TopAbs_REVERSED)); + NE.Orientation(TopAbs::Reverse(E.Orientation())); + } + } + else + { + //------------------- + // edge is not ferme. + //------------------- + if (Or == TopAbs_FORWARD) { + if (U1 > U2) { + TopoDS_Shape aLocalVertex = NV2.Oriented(TopAbs_FORWARD ); + B.Add (NE,TopoDS::Vertex(aLocalVertex)); + aLocalVertex = NV1.Oriented(TopAbs_REVERSED); + B.Add (NE,TopoDS::Vertex(aLocalVertex)); +// B.Add (NE,TopoDS::Vertex(NV2.Oriented(TopAbs_FORWARD ))); +// B.Add (NE,TopoDS::Vertex(NV1.Oriented(TopAbs_REVERSED))); + B.Range(NE,U2,U1); + } + else + { + TopoDS_Shape aLocalVertex = NV1.Oriented(TopAbs_FORWARD ); + B.Add (NE,TopoDS::Vertex(aLocalVertex)); + aLocalVertex = NV2.Oriented(TopAbs_REVERSED); + B.Add (NE,TopoDS::Vertex(aLocalVertex)); +// B.Add (NE,TopoDS::Vertex(NV1.Oriented(TopAbs_FORWARD ))); +// B.Add (NE,TopoDS::Vertex(NV2.Oriented(TopAbs_REVERSED))); + B.Range(NE,U1,U2); + } + ConstShapes.Bind(E,NE); + NE.Orientation(E.Orientation()); + } + else { + if (U2 > U1) { + TopoDS_Shape aLocalVertex = NV1.Oriented(TopAbs_FORWARD ); + B.Add (NE,TopoDS::Vertex(aLocalVertex)); + aLocalVertex = NV2.Oriented(TopAbs_REVERSED); + B.Add (NE,TopoDS::Vertex(aLocalVertex)); +// B.Add (NE,TopoDS::Vertex(NV1.Oriented(TopAbs_FORWARD ))); +// B.Add (NE,TopoDS::Vertex(NV2.Oriented(TopAbs_REVERSED))); + B.Range(NE,U1,U2); + ConstShapes.Bind(E,NE); + NE.Orientation(E.Orientation()); + } + else + { + TopoDS_Shape aLocalVertex = NV2.Oriented(TopAbs_FORWARD ); + B.Add (NE,TopoDS::Vertex(aLocalVertex)); + aLocalVertex = NV1.Oriented(TopAbs_REVERSED); + B.Add (NE,TopoDS::Vertex(aLocalVertex)); +// B.Add (NE,TopoDS::Vertex(NV2.Oriented(TopAbs_FORWARD ))); +// B.Add (NE,TopoDS::Vertex(NV1.Oriented(TopAbs_REVERSED))); + B.Range(NE,U2,U1); + ConstShapes.Bind(E,NE.Oriented(TopAbs_REVERSED)); + NE.Orientation(TopAbs::Reverse(E.Orientation())); + } + } + } + Build.UnBind(E); } // Build.IsBound(E) else if (ConstShapes.IsBound(E)) { // !Build.IsBound(E) - NE = TopoDS::Edge(ConstShapes(E)); - BuildPCurves(NE,NF); - Or = NE.Orientation(); - if (Or == TopAbs_REVERSED) { - NE.Orientation(TopAbs::Reverse(E.Orientation())); - } - else { - NE.Orientation(E.Orientation()); - } + NE = TopoDS::Edge(ConstShapes(E)); + BuildPCurves(NE,NF); + Or = NE.Orientation(); + if (Or == TopAbs_REVERSED) { + NE.Orientation(TopAbs::Reverse(E.Orientation())); + } + else { + NE.Orientation(E.Orientation()); + } } else { - NE = E; - ConstShapes.Bind(E,NE.Oriented(TopAbs_FORWARD)); + NE = E; + ConstShapes.Bind(E,NE.Oriented(TopAbs_FORWARD)); } B.Add(NW,NE); } @@ -3933,7 +3913,7 @@ void BRepOffset_Tool::ExtentFace (const TopoDS_Face& F, //======================================================================= TopoDS_Shape BRepOffset_Tool::Deboucle3D(const TopoDS_Shape& S, - const TopTools_MapOfShape& Boundary) + const TopTools_MapOfShape& Boundary) { return BRepAlgo_Tool::Deboucle3D(S,Boundary); } @@ -3944,8 +3924,8 @@ TopoDS_Shape BRepOffset_Tool::Deboucle3D(const TopoDS_Shape& S, //======================================================================= static Standard_Boolean IsInOut (BRepTopAdaptor_FClass2d& FC, - Geom2dAdaptor_Curve AC, - const TopAbs_State& S ) + Geom2dAdaptor_Curve AC, + const TopAbs_State& S ) { Standard_Real Def = 100*Precision::Confusion(); GCPnts_QuasiUniformDeflection QU(AC,Def); @@ -3959,17 +3939,17 @@ static Standard_Boolean IsInOut (BRepTopAdaptor_FClass2d& FC, } return Standard_True; } - + //======================================================================= //function : CorrectOrientation //purpose : //======================================================================= void BRepOffset_Tool::CorrectOrientation(const TopoDS_Shape& SI, - const TopTools_IndexedMapOfShape& NewEdges, - Handle(BRepAlgo_AsDes)& AsDes, - BRepAlgo_Image& InitOffset, - const Standard_Real Offset) + const TopTools_IndexedMapOfShape& NewEdges, + Handle(BRepAlgo_AsDes)& AsDes, + BRepAlgo_Image& InitOffset, + const Standard_Real Offset) { TopExp_Explorer exp; @@ -3988,30 +3968,30 @@ void BRepOffset_Tool::CorrectOrientation(const TopoDS_Shape& SI, Standard_Boolean YaInt = Standard_False; for (; itE.More(); itE.Next()) { - const TopoDS_Edge& OE = TopoDS::Edge(itE.Value()); - if (NewEdges.Contains(OE)) {YaInt = Standard_True; break;} + const TopoDS_Edge& OE = TopoDS::Edge(itE.Value()); + if (NewEdges.Contains(OE)) {YaInt = Standard_True; break;} } if (YaInt) { - TopoDS_Shape aLocalFace = FI.Oriented(TopAbs_FORWARD); - BRepTopAdaptor_FClass2d FC (TopoDS::Face(aLocalFace), - Precision::Confusion()); -// BRepTopAdaptor_FClass2d FC (TopoDS::Face(FI.Oriented(TopAbs_FORWARD)), -// Precision::Confusion()); - for (itE.Initialize(LOE); itE.More(); itE.Next()) { - TopoDS_Shape& OE = itE.Value(); - if (NewEdges.Contains(OE)) { - Handle(Geom2d_Curve) CO2d = - BRep_Tool::CurveOnSurface(TopoDS::Edge(OE),OF,f,l); - Geom2dAdaptor_Curve AC(CO2d,f,l); - - if (Offset > 0) { - if (IsInOut(FC,AC,TopAbs_OUT)) OE.Reverse(); - } -// else { -// if (IsInOut(FC,AC,TopAbs_IN)) OE.Reverse(); -// } - } - } + TopoDS_Shape aLocalFace = FI.Oriented(TopAbs_FORWARD); + BRepTopAdaptor_FClass2d FC (TopoDS::Face(aLocalFace), + Precision::Confusion()); +// BRepTopAdaptor_FClass2d FC (TopoDS::Face(FI.Oriented(TopAbs_FORWARD)), +// Precision::Confusion()); + for (itE.Initialize(LOE); itE.More(); itE.Next()) { + TopoDS_Shape& OE = itE.Value(); + if (NewEdges.Contains(OE)) { + Handle(Geom2d_Curve) CO2d = + BRep_Tool::CurveOnSurface(TopoDS::Edge(OE),OF,f,l); + Geom2dAdaptor_Curve AC(CO2d,f,l); + + if (Offset > 0) { + if (IsInOut(FC,AC,TopAbs_OUT)) OE.Reverse(); + } +// else { +// if (IsInOut(FC,AC,TopAbs_IN)) OE.Reverse(); +// } + } + } } } } diff --git a/src/BRepTest/BRepTest_FeatureCommands.cxx b/src/BRepTest/BRepTest_FeatureCommands.cxx index 2e57e5342d..20a4a1adc0 100755 --- a/src/BRepTest/BRepTest_FeatureCommands.cxx +++ b/src/BRepTest/BRepTest_FeatureCommands.cxx @@ -46,7 +46,8 @@ #include #include -#include +//#include +#include #include #include #include @@ -156,9 +157,17 @@ static Standard_Integer Loc(Draw_Interpretor& theCommands, // LF.Append(TopoDS::Face(DBRep::Get(a[i+5],TopAbs_FACE))); } - BRepFeat_LocalOperation BLoc(S); - BLoc.Perform(T,LF,Fuse); - BLoc.BuildPartsOfTool(); + //BRepFeat_LocalOperation BLoc(S); + //BLoc.Perform(T,LF,Fuse); + //BLoc.BuildPartsOfTool(); + TopTools_ListOfShape parts; + BRepFeat_Builder BLoc; + BLoc.Init(S,T); + BLoc.SetOperation(Fuse); + //BRepFeat_LocalOperation BLoc; + //BLoc.Init(S,T,Fuse); + BLoc.Perform(); + BLoc.PartsOfTool(parts); #if 0 char newname[1024]; @@ -167,7 +176,7 @@ static Standard_Integer Loc(Draw_Interpretor& theCommands, while (*p != '\0') p++; *p = '_'; p++; - TopTools_ListIteratorOfListOfShape its(BLoc.PartsOfTool()); + TopTools_ListIteratorOfListOfShape its(parts); dout.Clear(); i = 0; for (; its.More(); its.Next()) { @@ -185,29 +194,29 @@ static Standard_Integer Loc(Draw_Interpretor& theCommands, // S = TopoDS::Shell(DBRep::Get(".",TopAbs_SHELL)); Draw::LastPick(qq,ww,ee,button); if (!S.IsNull()) { - - switch (button) { - case 1: - BLoc.RemovePart(S); - break; - case 2: - BLoc.ActivatePart(S); - break; - default: - {} - } + + switch (button) { + case 1: + //BLoc.RemovePart(S); + break; + case 2: + BLoc.KeepPart(S); + break; + default: + {} + } } else { - button = 3; + button = 3; } } while (button != 3); } #endif - BLoc.Build(); - if (BLoc.IsDone()) { + BLoc.PerformResult(); + if (!BLoc.ErrorStatus()) { // dout.Clear(); - DBRep::Set(a[1],BLoc); + DBRep::Set(a[1],BLoc.Shape()); dout.Flush(); return 0; } @@ -240,9 +249,9 @@ static Standard_Integer HOLE1(Draw_Interpretor& theCommands, } theHole.Build(); - if (theHole.IsDone()) { + if (!theHole.ErrorStatus()) { // dout.Clear(); - DBRep::Set(a[1],theHole); + DBRep::Set(a[1],theHole.Shape()); dout.Flush(); return 0; } @@ -266,9 +275,9 @@ static Standard_Integer HOLE2(Draw_Interpretor& theCommands, theHole.PerformThruNext(Radius,WithControl); theHole.Build(); - if (theHole.IsDone()) { + if (!theHole.ErrorStatus()) { // dout.Clear(); - DBRep::Set(a[1],theHole); + DBRep::Set(a[1],theHole.Shape()); dout.Flush(); return 0; } @@ -291,9 +300,9 @@ static Standard_Integer HOLE3(Draw_Interpretor& theCommands, theHole.Init(S,gp_Ax1(Or,Di)); theHole.PerformUntilEnd(Radius,WithControl); theHole.Build(); - if (theHole.IsDone()) { + if (!theHole.ErrorStatus()) { // dout.Clear(); - DBRep::Set(a[1],theHole); + DBRep::Set(a[1],theHole.Shape()); dout.Flush(); return 0; } @@ -318,9 +327,9 @@ static Standard_Integer HOLE4(Draw_Interpretor& theCommands, theHole.Init(S,gp_Ax1(Or,Di)); theHole.PerformBlind(Radius,Length,WithControl); theHole.Build(); - if (theHole.IsDone()) { + if (!theHole.ErrorStatus()) { // dout.Clear(); - DBRep::Set(a[1],theHole); + DBRep::Set(a[1],theHole.Shape()); dout.Flush(); return 0; } @@ -1081,12 +1090,16 @@ static Standard_Integer Debou(Draw_Interpretor& theCommands, // LF2.Append(TopoDS::Face(DBRep::Get(a[i],TopAbs_FACE))); } - BRepFeat_LocalOperation BLoc(S); - BLoc.Perform(LF,LF2,Fuse); - BLoc.Build(); - if (BLoc.IsDone()) { + //BRepFeat_LocalOperation BLoc(S); + //BLoc.Perform(LF,LF2,Fuse); + //BLoc.Build(); + BRepFeat_Builder BLoc; + BLoc.Init(S, S); + BLoc.Perform(); + BLoc.PerformResult(); + if (!BLoc.ErrorStatus()) { // dout.Clear(); - DBRep::Set(a[1],BLoc); + DBRep::Set(a[1],BLoc.Shape()); dout.Flush(); return 0; } diff --git a/src/BRepTest/BRepTest_FilletCommands.cxx b/src/BRepTest/BRepTest_FilletCommands.cxx index 65da9b3a5c..5c79548fe3 100755 --- a/src/BRepTest/BRepTest_FilletCommands.cxx +++ b/src/BRepTest/BRepTest_FilletCommands.cxx @@ -45,7 +45,9 @@ #include #include -#include +//#include +#include + #include #include #include @@ -406,15 +408,17 @@ Standard_Integer boptopoblend(Draw_Interpretor& di, Standard_Integer narg, const } Standard_Real Rad = atof(a[4]); - BOPTools_DSFiller theDSFiller; - - theDSFiller.SetShapes( S1, S2 ); - if (!theDSFiller.IsDone()) { + BOPAlgo_PaveFiller theDSFiller; + BOPCol_ListOfShape aLS; + aLS.Append(S1); + aLS.Append(S2); + theDSFiller.SetArguments(aLS); + // + theDSFiller.Perform(); + if (theDSFiller.ErrorStatus()) { printf("Check types of the arguments, please\n"); return 1; } - - theDSFiller.Perform(); BRepAlgoAPI_BooleanOperation* pBuilder=NULL; diff --git a/src/BooleanOperations/BooleanOperations.cdl b/src/BooleanOperations/BooleanOperations.cdl deleted file mode 100755 index 5ad76d034e..0000000000 --- a/src/BooleanOperations/BooleanOperations.cdl +++ /dev/null @@ -1,153 +0,0 @@ --- Created on: 2000-07-10 --- Created by: Vincent DELOS --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -package BooleanOperations - - ---Purpose: package to perform Boolean Operations between two - -- solids called Object and Tool. - -uses - gp, - Bnd, - math, - BRep, - Geom, - TopAbs, - TopExp, - TopoDS, - TColStd, - TopTools, - Standard, - TCollection, - BRepAdaptor, - GeomAdaptor, - IntTools, - BOPTColStd -is - - class AncestorsAndSuccessors; - ---Purpose: to have a fast access in the class ShapesDataStructure - -- to the upper and lower shapes of a given shape. - -- e.g. : ancestors of an edge are the wires that contain - -- it and its successors are the vertices that it holds. - - ---modified by NIZNHY-PKV Wed Feb 2 14:47:51 2005f --- class InterferenceResult; - --Purpose: to describe a single interference between two shapes - -- in the class ShapesDataStructure. - --- pointer PInterferenceResult to InterferenceResult from BooleanOperations; - --- class InterferencesList; - --Purpose: if the considered shape S belongs to the Object this - -- class will list all the shapes of the Tool whose - -- bounding boxes intersects with the bounding box of S; - -- if S belongs to the Tool we store all the shapes of - -- the Object whose intersection with S is not empty. ---modified by NIZNHY-PKV Wed Feb 2 14:48:00 2005t - - class ShapeAndInterferences; - ---Purpose: contains a shape S, its bounding box, its state - -- according to the other solid, its ancestors and - -- successors, all of its interferences with the other - -- solid. - - pointer PShapeAndInterferences to ShapeAndInterferences from BooleanOperations; - - class ShapesDataStructure; - ---Purpose: contains all the shapes of the Object and Tool, all - -- the shapes created by intersection, their bounding - -- boxes, their states, their ancestors and successors, - -- and all of their interferences. - - pointer PShapesDataStructure to ShapesDataStructure from BooleanOperations; - - class Explorer; - ---Purpose: to find subshapes of a given shape of the Data Structure. - - class OnceExplorer; - ---Purpose: the derived class of Explorer to find subshapes only once. - - --class BooleanOperations; - ---Purpose: is to be deferred with inherited classes Cut, Common, - -- Fuse to perform boolean operations . - - - enumeration StateOfShape is - ---Purpose: State of a Shape of the 1st solid according to the - -- 2nd one. State INOROUT is used when we know that - -- a shape is totally IN or totally OUT. State - -- INTERSECTED refers to a shape of the 1st solid cut - -- by the 2nd solid. When a shape has a state - -- different of INTERSECTED or UNKNOWN all of its - -- subshapes have the same state. - IN, - OUT, - ON, - UNKNOWN, - INOROUT, - INTERSECTED - end StateOfShape; - - enumeration KindOfInterference is - ---Purpose: Interferences describe an intersection between two - -- shapes. They are classified following a hierarchy - -- from the lower until the upper. - SurfaceSurface, - EdgeSurface, - VertexSurface, - EdgeEdge, - VertexEdge, - VertexVertex, - UnknownInterference - end StateOfShape; - - enumeration KindOfIntersection is - ---Purpose: Describes the fact that we can have no - -- intersection between two shapes, or a true or a - -- tangent one. - NoIntersection, - TrueIntersection, - SameDomain - end KindOfIntersection; - - - ------------------------ - -- For internal needs -- - ------------------------ - - class AncestorsSeqAndSuccessorsSeq; - - class IndexedDataMapOfShapeAncestorsSuccessors instantiates IndexedDataMap from TCollection - (Shape from TopoDS,AncestorsSeqAndSuccessorsSeq from BooleanOperations,ShapeMapHasher from TopTools); - - - - class IndexedDataMapOfShapeInteger instantiates - IndexedDataMap from TCollection(Shape from TopoDS, - Integer from Standard, - ShapeMapHasher from TopTools); - -end BooleanOperations; - - - diff --git a/src/BooleanOperations/BooleanOperations_AncestorsAndSuccessors.cdl b/src/BooleanOperations/BooleanOperations_AncestorsAndSuccessors.cdl deleted file mode 100755 index 27205b7ebf..0000000000 --- a/src/BooleanOperations/BooleanOperations_AncestorsAndSuccessors.cdl +++ /dev/null @@ -1,97 +0,0 @@ --- Created on: 2000-07-10 --- Created by: Vincent DELOS --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class AncestorsAndSuccessors from BooleanOperations - - ---Purpose: provides all the ancestors and successors of a - -- given shape. Exemple : for an edge the ancestors - -- are the wires that hold it and the successors are - -- its vertices. - -uses - Orientation from TopAbs, - SequenceOfInteger from TColStd, - AncestorsSeqAndSuccessorsSeq from BooleanOperations - -is - - Create returns AncestorsAndSuccessors from BooleanOperations; - - Create (AncSuccessors: AncestorsSeqAndSuccessorsSeq; shift: Integer) returns AncestorsAndSuccessors from BooleanOperations; - ---Purpose: allocates space and fills it with the data of AncSuccessors. - - Destroy(me:in out); - ---C++: alias ~ - - - Dump (me); - ---Purpose: to display the fields. - - - -------------------- - -- INLINE METHODS -- - -------------------- - - GetAncestor (me; AncestorIndex: Integer) returns Integer; - ---C++: inline - SetAncestor (me:in out; AncestorIndex,AncestorNumber: Integer); - ---C++: inline - GetAncestors(me; theArrayOfAncestors:out Address;AncestorsNumber:out Integer); - ---C++: inline - - GetSuccessor (me; SuccessorIndex: Integer) returns Integer; - ---C++: inline - SetSuccessor (me:in out; SuccessorIndex,SuccessorNumber: Integer); - ---C++: inline - GetSuccessors(me; theArrayOfSuccessors:out Address; SuccessorsNumber:out Integer); - ---C++: inline - - GetOrientation (me; OrientationIndex: Integer) returns Orientation; - ---C++: inline - SetOrientation (me:in out; OrientationIndex: Integer; anOrientation: Orientation from TopAbs); - ---C++: inline - GetOrientations(me; theArrayOfOrientations:out Address;OrientationsNumber:out Integer); - ---C++: inline - - NumberOfAncestors (me) returns Integer; - ---C++: inline - NumberOfSuccessors (me) returns Integer; - ---C++: inline - - -fields - -myAncestors: Address; ----Purpose: the array containing all the ancestors of our given shape. - -mySuccessors: Address; ----Purpose: the array containing all the successors. - -myOrientations: Address; ----Purpose: the array containing all the orientation of the successors. - -myAncestorsSize : Integer; ----Purpose: the number of ancestors. - -mySuccessorsSize: Integer; ----Purpose: the number of successors. - -end AncestorsAndSuccessors; diff --git a/src/BooleanOperations/BooleanOperations_AncestorsAndSuccessors.cxx b/src/BooleanOperations/BooleanOperations_AncestorsAndSuccessors.cxx deleted file mode 100755 index c1ba7d1ec2..0000000000 --- a/src/BooleanOperations/BooleanOperations_AncestorsAndSuccessors.cxx +++ /dev/null @@ -1,119 +0,0 @@ -// Created on: 2000-07-10 -// Created by: Vincent DELOS -// Copyright (c) 2000-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include -#include - -//=========================================================================== -//function : BooleanOperations_AncestorsAndSuccessors -//purpose : default creator -//=========================================================================== -BooleanOperations_AncestorsAndSuccessors::BooleanOperations_AncestorsAndSuccessors(): - myAncestors(0L), - mySuccessors(0L), - myOrientations(0L), - myAncestorsSize(0), - mySuccessorsSize(0) -{ -} - - -//=========================================================================== -//function : BooleanOperations_AncestorsAndSuccessors -//purpose : -//=========================================================================== - BooleanOperations_AncestorsAndSuccessors::BooleanOperations_AncestorsAndSuccessors - (const BooleanOperations_AncestorsSeqAndSuccessorsSeq& AncSuc, - const Standard_Integer shift) : - - myAncestors(0L), - mySuccessors(0L), - myOrientations(0L), - myAncestorsSize(0), - mySuccessorsSize(0) -{ - Standard_Integer i, j; - // - // Ancestors - // - myAncestorsSize = AncSuc.NumberOfAncestors(); - if (myAncestorsSize) { - myAncestors = (Standard_Integer*)Standard::Allocate(myAncestorsSize*sizeof(Standard_Integer)); - - for (i=1; i<=myAncestorsSize; i++) { - ((Standard_Integer*)myAncestors)[i-1] = AncSuc.GetAncestor(i) + shift; - } - } - // - // Successors - // - mySuccessorsSize = AncSuc.NumberOfSuccessors(); - if (mySuccessorsSize) { - mySuccessors = (Standard_Integer*) Standard::Allocate(mySuccessorsSize*sizeof(Standard_Integer)); - myOrientations = (TopAbs_Orientation*)Standard::Allocate(mySuccessorsSize*sizeof(TopAbs_Orientation)); - - for (i=1; i<=mySuccessorsSize; i++) { - j=i-1; - ((Standard_Integer*)mySuccessors )[j] = AncSuc.GetSuccessor(i) + shift; - ((TopAbs_Orientation*)myOrientations)[j] = AncSuc.GetOrientation(i); - } - } -} - - -//=========================================================================== -//function : Destroy -//purpose : destructor -//=========================================================================== - void BooleanOperations_AncestorsAndSuccessors::Destroy() -{ - if (myAncestors) { - Standard::Free((Standard_Address&)myAncestors); - } - if (mySuccessors) { - Standard::Free((Standard_Address&)mySuccessors); - } - if (myOrientations) { - Standard::Free((Standard_Address&)myOrientations); - } -} - - -//=========================================================================== -//function : Dump -//purpose : -//=========================================================================== - void BooleanOperations_AncestorsAndSuccessors::Dump() const -{ - Standard_Integer i; - - cout<. - SetNewOrientation(me:in out; theOrientation: Orientation); - ---C++: inline - ---Purpose: appends SuccessorNumber in the array refering to . - - -fields - -myAncestors: SequenceOfInteger; ----Purpose: the sequence containing all the ancestors of our given shape. - -mySuccessors: SequenceOfInteger; ----Purpose: the array containing all the successors. - -myOrientations:SequenceOfInteger; ----Purpose: the array containing all orientations corresponding to the successors. - -end AncestorsSeqAndSuccessorsSeq; diff --git a/src/BooleanOperations/BooleanOperations_AncestorsSeqAndSuccessorsSeq.cxx b/src/BooleanOperations/BooleanOperations_AncestorsSeqAndSuccessorsSeq.cxx deleted file mode 100755 index c5cc57135f..0000000000 --- a/src/BooleanOperations/BooleanOperations_AncestorsSeqAndSuccessorsSeq.cxx +++ /dev/null @@ -1,51 +0,0 @@ -// Created on: 2000-08-17 -// Created by: Vincent DELOS -// Copyright (c) 2000-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include - -//=========================================================================== -//function : BooleanOperations_AncestorsSeqAndSuccessorsSeq -//purpose : creator -//=========================================================================== -BooleanOperations_AncestorsSeqAndSuccessorsSeq::BooleanOperations_AncestorsSeqAndSuccessorsSeq() : - myAncestors(), - mySuccessors() -{ -} - - -//=========================================================================== -//function : Dump -//purpose : -//=========================================================================== - void BooleanOperations_AncestorsSeqAndSuccessorsSeq::Dump() const -{ - Standard_Integer i; - - cout< - -const static Standard_Integer theStackSize=20; -// -//=========================================================================== -//function : BooleanOperations_Explorer -//purpose : -//=========================================================================== - BooleanOperations_Explorer::BooleanOperations_Explorer - (const BooleanOperations_ShapesDataStructure& SDS): - myStack(0L), - myTopOfStack(-1), - mySizeOfStack(-1), - myTargetToFind(TopAbs_SHAPE), - myTargetToAvoid(TopAbs_SHAPE) -{ - myShapesDataStructure = (BooleanOperations_PShapesDataStructure)&SDS; -} -//=========================================================================== -//function : Delete -//purpose : ~BooleanOperations_Explorer -//=========================================================================== - void BooleanOperations_Explorer::Delete() -{ - if(myStack != 0L) { - - Standard::Free((Standard_Address&)myStack); - } - myStack = 0; -} -//=========================================================================== -//function : Init -//purpose : -//=========================================================================== - void BooleanOperations_Explorer::Init(const Standard_Integer aShapeNumber, - const TopAbs_ShapeEnum TargetToFind, - const TopAbs_ShapeEnum TargetToAvoid) -{ - Standard_Integer i,j,k,theNumberOfTheShapeOnTop; - TopAbs_ShapeEnum theTypeOfShapeOnTop,successorType; - - myTargetToFind = TargetToFind; - myTargetToAvoid = TargetToAvoid; - - if (myStack != 0L) { - Standard::Free((Standard_Address&)myStack); - } - - mySizeOfStack = theStackSize; - myStack = (Standard_Integer*)Standard::Allocate(theStackSize*sizeof(Standard_Integer)); - - ((Standard_Integer*)myStack)[0] = aShapeNumber; - myTopOfStack = 0; - - theNumberOfTheShapeOnTop = ((Standard_Integer*)myStack)[myTopOfStack]; - theTypeOfShapeOnTop = (*myShapesDataStructure).GetShapeType(theNumberOfTheShapeOnTop); - if (theTypeOfShapeOnTop == myTargetToFind) - { - hasMore = Standard_True; - return; - } - while (theTypeOfShapeOnTop != myTargetToFind) - { - Standard_Address theSuccessors; - Standard_Integer theNumberOfSuccessors; - // We get the successors of the shape on top of the stack. - (*myShapesDataStructure).GetSuccessors(theNumberOfTheShapeOnTop,theSuccessors,theNumberOfSuccessors); - // Do we have enough place to store our new successors ? - if ((myTopOfStack+theNumberOfSuccessors > mySizeOfStack) && (theSuccessors != 0L)) - { - // We don't have enough place so we reallocate. - Standard_Address theNewStack = (Standard_Integer*)Standard::Allocate - ((mySizeOfStack+theStackSize+theNumberOfSuccessors)*sizeof(Standard_Integer)); - // We copy the old array in the one. - for (j=0;j mySizeOfStack) && (theSuccessors != 0L)) - { - Standard_Address theNewStack; - theNewStack = (Standard_Integer*)Standard::Allocate - ((mySizeOfStack+theNumberOfSuccessors+theStackSize)*sizeof(Standard_Integer)); - for (j=0;j. - -end OnceExplorer; diff --git a/src/BooleanOperations/BooleanOperations_OnceExplorer.cxx b/src/BooleanOperations/BooleanOperations_OnceExplorer.cxx deleted file mode 100755 index b298d6ab52..0000000000 --- a/src/BooleanOperations/BooleanOperations_OnceExplorer.cxx +++ /dev/null @@ -1,310 +0,0 @@ -// Created on: 2000-09-07 -// Created by: Vincent DELOS -// Copyright (c) 2000-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include - -//#define theStackSize (20) -const static Standard_Integer theStackSize=20; - -#define BITFLAG(n) (1 << (n)) // creation of 2 power n. -#define BITSET(word,mask) (word) |= (mask) // to set a bit to 1 in word using mask. -#define BITCLEAR(word,mask) (word) &= ~(mask) // to set a bit to 0 in word using mask. -#define BITISSET(word,mask) ((word) & (mask)) // returns the value of the bit corresponding to mask. -#define LEMOT(id) ((id) >> 5) // the number of the integer we will work on. -#define LEBIT(id) (BITFLAG((id) & 31)) // the number of the bit we will work on (2 power (id%32)). -#define CC0BIT(id,anArray) BITCLEAR(anArray[LEMOT(id)],LEBIT(id)) // sets to 0 the bit number id in anArray. -#define CC1BIT(id,anArray) BITSET(anArray[LEMOT(id)],LEBIT(id)) // sets to 1 the bit number id in anArray. -#define NNNBIT(id,anArray) (BITISSET(anArray[LEMOT(id)],LEBIT(id)) ? 1 : 0) // returns the bit number id in anArray. - -//=========================================================================== -//function : BooleanOperations_OnceExplorer -//purpose : -//=========================================================================== - BooleanOperations_OnceExplorer::BooleanOperations_OnceExplorer - (const BooleanOperations_ShapesDataStructure& SDS): - BooleanOperations_Explorer(SDS) -{ - hasMore = Standard_False; - // The size of the array of bits is the lower multiple of - //32 greater than the number of shapes in myShapesDataStructure. - Standard_Integer MultipleOf32= (((*myShapesDataStructure).myLength+31) & (~31)); - - mySizeOfArrayOfBits = MultipleOf32/32; - myArrayOfBits = 0L; -} -//modified by NIZNHY-PKV Sun Dec 15 16:28:15 2002 f -//=========================================================================== -//function : Delete -//purpose : alias ~BooleanOperations_Explorer -//=========================================================================== - void BooleanOperations_OnceExplorer::Delete() -{ - if (myArrayOfBits) { - free (myArrayOfBits); - } - BooleanOperations_Explorer::Delete(); -} -//modified by NIZNHY-PKV Sun Dec 15 16:29:10 2002 t -//=========================================================================== -//function : Init -//purpose : -//=========================================================================== - void BooleanOperations_OnceExplorer::Init(const Standard_Integer aShapeNumber, - const TopAbs_ShapeEnum TargetToFind, - const TopAbs_ShapeEnum TargetToAvoid) -{ - Standard_Integer i,j,k,theNumberOfTheShapeOnTop,aSuccessorNumber; - Standard_Integer* anArrayOfBits; - Standard_Boolean shapeAlreadyProcessed; - TopAbs_ShapeEnum theTypeOfShapeOnTop,successorType; - - myTargetToFind = TargetToFind; - myTargetToAvoid = TargetToAvoid; - -// Modified by skv - Thu Apr 7 11:19:39 2005 Begin - hasMore = Standard_False; -// Modified by skv - Thu Apr 7 11:19:41 2005 End - - // We first test if myShapesDataStructure has changed. - Standard_Integer MultipleOf32= (((*myShapesDataStructure).myLength+31) & (~31)); - Standard_Integer NewSize = MultipleOf32/32; - if (myArrayOfBits!=0L) - free(myArrayOfBits); - myArrayOfBits = (Standard_Integer*)calloc(mySizeOfArrayOfBits,sizeof(Standard_Integer)); - mySizeOfArrayOfBits = NewSize; - - if (myStack != 0L) { - Standard::Free((Standard_Address&)myStack); - } - mySizeOfStack = theStackSize; - myStack = (Standard_Integer*)Standard::Allocate(theStackSize*sizeof(Standard_Integer)); - - ((Standard_Integer*)myStack)[0] = aShapeNumber; - myTopOfStack = 0; - - theNumberOfTheShapeOnTop = ((Standard_Integer*)myStack)[myTopOfStack]; - theTypeOfShapeOnTop = (*myShapesDataStructure).GetShapeType(theNumberOfTheShapeOnTop); - if (theTypeOfShapeOnTop == myTargetToFind) - { - hasMore = Standard_True; - return; - } -// Modified by skv - Thu Apr 7 11:19:39 2005 Begin - if (theTypeOfShapeOnTop == TopAbs_VERTEX) { - hasMore = Standard_False; - - return; - } -// Modified by skv - Thu Apr 7 11:19:41 2005 End - - while (theTypeOfShapeOnTop != myTargetToFind) - { - Standard_Address theSuccessors; - Standard_Integer theNumberOfSuccessors; - // We get the successors of the shape on top of the stack. - (*myShapesDataStructure).GetSuccessors(theNumberOfTheShapeOnTop,theSuccessors,theNumberOfSuccessors); - // Do we have enough place to store our new successors ? - if ((myTopOfStack+theNumberOfSuccessors > mySizeOfStack) && (theSuccessors != 0L)) - { - // We don't have enough place so we reallocate. - Standard_Address theNewStack = (Standard_Integer*)Standard::Allocate - ((mySizeOfStack+theStackSize+theNumberOfSuccessors)*sizeof(Standard_Integer)); - // We copy the old array in the new one. - for (j=0;j mySizeOfStack) && (theSuccessors != 0L)) - { - Standard_Address theNewStack; - theNewStack = (Standard_Integer*)Standard::Allocate - ((mySizeOfStack+theNumberOfSuccessors+theStackSize)*sizeof(Standard_Integer)); - for (j=0;j. - --- Dump (me); - ---Purpose: to display the fields. ---modified by NIZNHY-PKV Wed Feb 2 12:55:39 2005t - -fields - myBoundingBox : Box from Bnd; - ---Purpose: the bounding box of . - - myAncestorsAndSuccessors : AncestorsAndSuccessors from BooleanOperations; - ---Purpose: the shapes that contain and/or containded by . - - myShape : Shape; - ---Purpose: can be a shape of the Object, of the Tool or created by - -- intersecting both of them. - - myState : StateOfShape; - ---Purpose: the state of . - ---modified by NIZNHY-PKV Wed Feb 2 12:53:22 2005f - --myInterferencesList : InterferencesList; ---modified by NIZNHY-PKV Wed Feb 2 12:53:40 2005t - ---Purpose: all the shapes whose intersection with is not empty. - -friends - class ShapesDataStructure from BooleanOperations - -end ShapeAndInterferences; diff --git a/src/BooleanOperations/BooleanOperations_ShapeAndInterferences.cxx b/src/BooleanOperations/BooleanOperations_ShapeAndInterferences.cxx deleted file mode 100755 index 9e105ebe60..0000000000 --- a/src/BooleanOperations/BooleanOperations_ShapeAndInterferences.cxx +++ /dev/null @@ -1,58 +0,0 @@ -// Created on: 2000-07-25 -// Created by: Vincent DELOS -// Copyright (c) 2000-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include - -//=========================================================================== -//function : ShapeAndInterferences -//purpose : -//=========================================================================== -BooleanOperations_ShapeAndInterferences::BooleanOperations_ShapeAndInterferences(): - myState(BooleanOperations_UNKNOWN) -{ -} -//modified by NIZNHY-PKV Wed Feb 2 12:55:46 2005f -/* -//=========================================================================== -//function : SetInterference -//purpose : -//=========================================================================== - void BooleanOperations_ShapeAndInterferences::SetInterference - (const BooleanOperations_InterferenceResult& Interf) -{ - myInterferencesList.SetInterference(Interf); -} - -//=========================================================================== -//function : Dump -//purpose : -//=========================================================================== - void BooleanOperations_ShapeAndInterferences::Dump() const -{ - cout< - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include -#include - - -#ifdef WNT -#pragma warning ( disable : 4291 ) -#endif - -static - void Message(const Standard_Integer i); - -const static Standard_Integer AddedValue=20; - -//=========================================================================== -//function : BooleanOperations_ShapesDataStructure -//purpose : creator -//=========================================================================== - BooleanOperations_ShapesDataStructure::BooleanOperations_ShapesDataStructure(): - myListOfShapeAndInterferences(NULL), - myNumberOfShapesOfTheObject(0), - myNumberOfShapesOfTheTool(0), - myNumberOfInsertedShapes(0), - myLength(0), - myNbEdges(0) -{ - //printf("-BOPDS_ShapesDataStructure CREATE:%x\n", (int)this); -} -//=========================================================================== -//function : BooleanOperations_ShapesDataStructure -//purpose : creator -//=========================================================================== - BooleanOperations_ShapesDataStructure::BooleanOperations_ShapesDataStructure(const TopoDS_Shape& Object, - const TopoDS_Shape& Tool) -: - myListOfShapeAndInterferences(NULL), - myNumberOfShapesOfTheObject(0), - myNumberOfShapesOfTheTool(0), - myNumberOfInsertedShapes(0), - myLength(0), - myObject(Object), - myTool(Tool), - myNbEdges(0) -{ - //printf(" BOPDS_ShapesDataStructure CREATE:%x\n", (int)this); - Standard_Integer i, Average;//, aNbShapes; - BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors IndDatMapTool; - BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors IndDatMapObject; - - FillIndexedMapOfShapesAncestorsAndSuccessors(Object,IndDatMapObject); - FillIndexedMapOfShapesAncestorsAndSuccessors(Tool,IndDatMapTool); - myNumberOfShapesOfTheObject = IndDatMapObject.Extent(); - myNumberOfShapesOfTheTool = IndDatMapTool.Extent(); - Average = (myNumberOfShapesOfTheTool+myNumberOfShapesOfTheObject)/2; - myLength = myNumberOfShapesOfTheTool+myNumberOfShapesOfTheObject+Average; - ///// - myListOfShapeAndInterferences = (BooleanOperations_PShapeAndInterferences) - Standard::Allocate(myLength*sizeof(BooleanOperations_ShapeAndInterferences)); - // - // Inserting the shapes into the DS - // Object - for (i=1; i<=myNumberOfShapesOfTheObject; i++){ - const BooleanOperations_AncestorsSeqAndSuccessorsSeq& theAncestorsSeqAndSuccessorsSeq = - IndDatMapObject.FindFromIndex(i); - const TopoDS_Shape& theShape = IndDatMapObject.FindKey(i); - InsertShapeAndAncestorsSuccessors(theShape, theAncestorsSeqAndSuccessorsSeq, 0); - } - // Tool - for (i=1;i<=myNumberOfShapesOfTheTool;i++){ - const BooleanOperations_AncestorsSeqAndSuccessorsSeq& theAncestorsSeqAndSuccessorsSeq = - IndDatMapTool.FindFromIndex(i); - const TopoDS_Shape& theShape = IndDatMapTool.FindKey(i); - InsertShapeAndAncestorsSuccessors(theShape,theAncestorsSeqAndSuccessorsSeq,myNumberOfShapesOfTheObject); - } - // - // Fill the myShapeIndexMapObj - for (i=1; i<=myNumberOfShapesOfTheObject; ++i){ - const TopoDS_Shape& aS=GetShape(i); - myShapeIndexMapObj.Add(aS, i); - } - // - // - // Fill the myShapeIndexMapObj - Standard_Integer iFirst, iLast; - // - ToolRange (iFirst, iLast); - for (i=iFirst; i<=iLast; ++i){ - const TopoDS_Shape& aS=GetShape(i); - myShapeIndexMapTool.Add(aS, i); - } - // - iLast=myNumberOfShapesOfTheObject+myNumberOfShapesOfTheTool; - // - // Fill myRefEdges - myRefEdges.Resize(iLast); - - for (i=1; i<=iLast; ++i) { - const TopoDS_Shape& aS=Shape(i); - myRefEdges(i)=0; - if (aS.ShapeType()==TopAbs_EDGE) { - myNbEdges++; - myRefEdges(i)=myNbEdges; - } - } -} -//modified by NIZNHY-PKV Wed Feb 2 11:34:07 2005f -//=========================================================================== -//function : ~ -//purpose : -//=========================================================================== - BooleanOperations_ShapesDataStructure::~BooleanOperations_ShapesDataStructure() -{ - //printf(" BOPDS_ShapesDataStructure DELETE:%x\n", (int)this); - Destroy(); -} -//modified by NIZNHY-PKV Wed Feb 2 11:34:12 2005t -//=========================================================================== -//function : BooleanOperations_ShapesDataStructure -//purpose : destructor -//=========================================================================== - void BooleanOperations_ShapesDataStructure::Destroy() -{ - Standard_Integer i; - - for (i=0;iFindSubshapes(Sha,TotalNumberOfShapes,IndDatMap); - // - Standard_Integer aNumberOfShapes = IndDatMap.Extent(); - for(Standard_Integer i=1; i <= aNumberOfShapes; i++) { - const BooleanOperations_AncestorsSeqAndSuccessorsSeq& anAncestorAndSuccessorSeq1=IndDatMap(i); - TColStd_MapOfInteger aMapOfIndices; - for(Standard_Integer j = 1; j <= anAncestorAndSuccessorSeq1.NumberOfSuccessors(); j++) { - Standard_Integer aShapeIndex = anAncestorAndSuccessorSeq1.GetSuccessor(j); - if(aMapOfIndices.Add(aShapeIndex)) { - BooleanOperations_AncestorsSeqAndSuccessorsSeq& anAncestorAndSuccessorSeq2 = - IndDatMap.ChangeFromIndex(aShapeIndex); - anAncestorAndSuccessorSeq2.SetNewAncestor(i); - } - } - } -} -//=========================================================================== -//function : FindSubshapes -//purpose : -//=========================================================================== - void BooleanOperations_ShapesDataStructure::FindSubshapes - (const TopoDS_Shape& Sha, - Standard_Integer& TotalNumberOfShapes, - BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors& IndDatMap) const -{ -// - TopoDS_Iterator anIt(Sha, Standard_True);//Standard_False); - Standard_Integer anIndexOfShape = IndDatMap.FindIndex(Sha); - BooleanOperations_AncestorsSeqAndSuccessorsSeq& AncSucOfShape=IndDatMap.ChangeFromIndex(anIndexOfShape); - for(; anIt.More(); anIt.Next()) { - const TopoDS_Shape& aSubShape = anIt.Value(); - Standard_Integer aSubShapeIndex = 0; - Standard_Boolean isNewSubShape = Standard_False; - if(!IndDatMap.Contains(aSubShape)) { - isNewSubShape = Standard_True; - BooleanOperations_AncestorsSeqAndSuccessorsSeq anAncestorAndSuccessorSeq; - aSubShapeIndex = IndDatMap.Add(aSubShape, anAncestorAndSuccessorSeq); - } - else { - aSubShapeIndex = IndDatMap.FindIndex(aSubShape); - } - AncSucOfShape.SetNewSuccessor(aSubShapeIndex); - AncSucOfShape.SetNewOrientation(aSubShape.Orientation()); - // - if(isNewSubShape && (aSubShape.ShapeType() != TopAbs_VERTEX)) { - FindSubshapes(aSubShape, TotalNumberOfShapes, IndDatMap); - } - } - TotalNumberOfShapes = IndDatMap.Extent(); -} -//=========================================================================== -//function : ReInit -//purpose : -//=========================================================================== - void BooleanOperations_ShapesDataStructure::ReInit() -{ - Standard_Integer i,NewLength; - BooleanOperations_PShapeAndInterferences NewListOfShapeAndInterferences; - - NewLength = AddedValue + myLength; - NewListOfShapeAndInterferences = (BooleanOperations_PShapeAndInterferences) - Standard::Allocate(NewLength*sizeof(BooleanOperations_ShapeAndInterferences)); - - //modified by NIZNHY-PKV Wed Feb 2 12:16:51 2005f - //printf(" ReInit:%x, was:%x, now:%x\n", - // (int)this, - // (int)myListOfShapeAndInterferences, - // (int)NewListOfShapeAndInterferences); - //modified by NIZNHY-PKV Wed Feb 2 12:16:55 2005t - - for (i=0;i0) { - Standard::Free((Standard_Address&) myListOfShapeAndInterferences); - } - - myLength = NewLength; - myListOfShapeAndInterferences = NewListOfShapeAndInterferences; -} -//=========================================================================== -//function : InsertShapeAndAncestorsSuccessors -//purpose : -//=========================================================================== -void BooleanOperations_ShapesDataStructure::InsertShapeAndAncestorsSuccessors - (const TopoDS_Shape& S, - const BooleanOperations_AncestorsSeqAndSuccessorsSeq& AncSuc, - const Standard_Integer shift) -{ - if ((myNumberOfInsertedShapes<0)||(myNumberOfInsertedShapes>myLength)) { - Message(1); - } - // - Bnd_Box B; - // - if (myNumberOfInsertedShapes==myLength) { - ReInit(); - } - - new (&(myListOfShapeAndInterferences[myNumberOfInsertedShapes].myShape)) TopoDS_Shape(S); - // Compute and insert the bounding box of . - if (!S.IsNull()) { - BRepBndLib::Add(S,B); - } - new (&(myListOfShapeAndInterferences[myNumberOfInsertedShapes].myBoundingBox)) - Bnd_Box(B); - new (&(myListOfShapeAndInterferences[myNumberOfInsertedShapes].myAncestorsAndSuccessors)) - BooleanOperations_AncestorsAndSuccessors(AncSuc,shift); - - myListOfShapeAndInterferences[myNumberOfInsertedShapes].myState = BooleanOperations_UNKNOWN; - myNumberOfInsertedShapes++; -} - -//=========================================================================== -//function : GetShape -//purpose : -//=========================================================================== - const TopoDS_Shape& BooleanOperations_ShapesDataStructure::GetShape(const Standard_Integer index) const -{ - if ((index<1)||(index>myNumberOfInsertedShapes)) { - Message(1); - } - return myListOfShapeAndInterferences[index-1].GetShape(); -} -//=========================================================================== -//function : Shape -//purpose : -//=========================================================================== - const TopoDS_Shape& BooleanOperations_ShapesDataStructure::Shape(const Standard_Integer index) const -{ - return GetShape(index); -} -//=========================================================================== -//function : GetShapeType -//purpose : -//=========================================================================== - TopAbs_ShapeEnum BooleanOperations_ShapesDataStructure::GetShapeType(const Standard_Integer index) const -{ - if ((index<1)||(index>myNumberOfInsertedShapes)) { - Message(1); - } - return myListOfShapeAndInterferences[index-1].GetShapeType(); -} -//=========================================================================== -//function : GetBoundingBox -//purpose : -//=========================================================================== - const Bnd_Box& BooleanOperations_ShapesDataStructure::GetBoundingBox(const Standard_Integer index) const -{ - if ((index<1)||(index>myNumberOfInsertedShapes)) { - Message(1); - } - return myListOfShapeAndInterferences[index-1].GetBoundingBox(); -} -//=========================================================================== -//function : GetState -//purpose : -//=========================================================================== - BooleanOperations_StateOfShape BooleanOperations_ShapesDataStructure::GetState(const Standard_Integer index) const -{ - if ((index<1)||(index>myNumberOfInsertedShapes)) { - Message(1); - } - return myListOfShapeAndInterferences[index-1].GetState(); -} -//=========================================================================== -//function : SetState -//purpose : -//=========================================================================== - void BooleanOperations_ShapesDataStructure::SetState(const Standard_Integer index, - const BooleanOperations_StateOfShape theState) -{ - if ((index<1)||(index>myNumberOfInsertedShapes)) { - Message(1); - } - myListOfShapeAndInterferences[index-1].SetState(theState); -} - -//=========================================================================== -//function : NumberOfAncestors -//purpose : -//=========================================================================== - Standard_Integer - BooleanOperations_ShapesDataStructure::NumberOfAncestors(const Standard_Integer index) const -{ - if ((index<1)||(index>myNumberOfInsertedShapes)) { - Message(1); - } - return myListOfShapeAndInterferences[index-1].NumberOfAncestors(); -} -//=========================================================================== -//function : NumberOfSuccessors -//purpose : -//=========================================================================== - Standard_Integer - BooleanOperations_ShapesDataStructure::NumberOfSuccessors(const Standard_Integer index) const -{ - if ((index<1)||(index>myNumberOfInsertedShapes)) { - Message(1); - } - return myListOfShapeAndInterferences[index-1].NumberOfSuccessors(); -} -//=========================================================================== -//function : GetAncestor -//purpose : -//=========================================================================== - Standard_Integer - BooleanOperations_ShapesDataStructure::GetAncestor(const Standard_Integer index, - const Standard_Integer ancestorNumber) const -{ - if ((index<1)|| - (index>myNumberOfInsertedShapes)|| - (ancestorNumber<1)|| - (ancestorNumber>NumberOfAncestors(index))) { - Message(1); - } - return myListOfShapeAndInterferences[index-1].GetAncestor(ancestorNumber); -} -//=========================================================================== -//function : GetSuccessor -//purpose : -//=========================================================================== - Standard_Integer - BooleanOperations_ShapesDataStructure::GetSuccessor(const Standard_Integer index, - const Standard_Integer successorNumber) const -{ - if ((index<1)||(index>myNumberOfInsertedShapes)||(successorNumber<1)||(successorNumber>NumberOfSuccessors(index))) { - Message(1); - } - if (GetShapeType(index) == TopAbs_VERTEX) { - Message(2); - } - return myListOfShapeAndInterferences[index-1].GetSuccessor(successorNumber); -} -//=========================================================================== -//function : GetAncestors -//purpose : returns the array of ancestors -//=========================================================================== - void - BooleanOperations_ShapesDataStructure::GetAncestors(const Standard_Integer index, - Standard_Address& theArrayOfAncestors, - Standard_Integer& ancestorsNumber) const -{ - if ((index<1)||(index>myNumberOfInsertedShapes)) { - Message(1); - } - myListOfShapeAndInterferences[index-1].GetAncestors(theArrayOfAncestors,ancestorsNumber); -} - - -//=========================================================================== -//function : GetSuccessors -//purpose : returns the array of successors -//=========================================================================== - void - BooleanOperations_ShapesDataStructure::GetSuccessors(const Standard_Integer index, - Standard_Address& theArrayOfSuccessors, - Standard_Integer& successorsNumber) const -{ - if ((index<1)||(index>myNumberOfInsertedShapes)) { - Message(1); - } - if (GetShapeType(index) == TopAbs_VERTEX) { - Message(2); - } - myListOfShapeAndInterferences[index-1].GetSuccessors(theArrayOfSuccessors,successorsNumber); -} - -// -//=========================================================================== -//function : NumberOfShapesOfTheObject -//purpose : -//=========================================================================== - Standard_Integer BooleanOperations_ShapesDataStructure::NumberOfShapesOfTheObject()const -{ - return myNumberOfShapesOfTheObject; -} -//=========================================================================== -//function : NumberOfShapesOfTheTool -//purpose : -//=========================================================================== - Standard_Integer BooleanOperations_ShapesDataStructure::NumberOfShapesOfTheTool()const -{ - return myNumberOfShapesOfTheTool; -} - -// - -//=========================================================================== -//function : NumberOfInsertedShapes -//purpose : -//=========================================================================== - Standard_Integer BooleanOperations_ShapesDataStructure::NumberOfInsertedShapes()const -{ - return myNumberOfInsertedShapes; -} -//=========================================================================== -//function : NumberOfNewShapes -//purpose : -//=========================================================================== - Standard_Integer BooleanOperations_ShapesDataStructure::NumberOfNewShapes()const -{ - Standard_Integer aNb; - - aNb=NumberOfSourceShapes(); - aNb=myNumberOfInsertedShapes-aNb; - return aNb; -} - -//=========================================================================== -//function : NumberOfSourceShapes -//purpose : -//=========================================================================== - Standard_Integer BooleanOperations_ShapesDataStructure::NumberOfSourceShapes()const -{ - Standard_Integer aNb; - aNb=myNumberOfShapesOfTheTool+myNumberOfShapesOfTheObject; - return aNb; -} - -//=========================================================================== -//function : IsNewShape -//purpose : -//=========================================================================== - Standard_Boolean - BooleanOperations_ShapesDataStructure::IsNewShape(const Standard_Integer anIndex)const -{ - Standard_Boolean aFlag; - aFlag=anIndex>NumberOfSourceShapes(); - return aFlag; -} - - -//=========================================================================== -//function : Line -//purpose : -//=========================================================================== - const BooleanOperations_ShapeAndInterferences& - BooleanOperations_ShapesDataStructure::Line(const Standard_Integer index) const -{ - if ((index<1)||(index>myNumberOfInsertedShapes)) { - Message(1); - } - return myListOfShapeAndInterferences[index-1]; -} -//=========================================================================== -//function : Object -//purpose : -//=========================================================================== - const TopoDS_Shape& BooleanOperations_ShapesDataStructure::Object()const -{ - return myObject; -} -//=========================================================================== -//function : Tool -//purpose : -//=========================================================================== - const TopoDS_Shape& BooleanOperations_ShapesDataStructure::Tool()const -{ - return myTool; -} -//=========================================================================== -//function : ObjectRange -//purpose : -//=========================================================================== - void BooleanOperations_ShapesDataStructure::ObjectRange(Standard_Integer& iFirst, - Standard_Integer& iLast)const -{ - iFirst=1; - iLast=NumberOfShapesOfTheObject(); -} - -//=========================================================================== -//function : ToolRange -//purpose : -//=========================================================================== - void BooleanOperations_ShapesDataStructure::ToolRange(Standard_Integer& iFirst, - Standard_Integer& iLast)const -{ - iFirst=NumberOfShapesOfTheObject()+1; - iLast=NumberOfShapesOfTheObject()+NumberOfShapesOfTheTool(); -} -//=========================================================================== -//function : Rank -//purpose : -//=========================================================================== - Standard_Integer BooleanOperations_ShapesDataStructure::Rank(const Standard_Integer nS)const - -{ - if (IsNewShape(nS)) { - return 3; - } - - Standard_Integer iFirst, iLast; - - ObjectRange(iFirst, iLast); - if (nS >= iFirst && nS <= iLast){ - return 1; - } - - ToolRange(iFirst, iLast); - if (nS >= iFirst && nS <= iLast){ - return 2; - } - return 0; // ? -} - -//=========================================================================== -//function : RefEdge -//purpose : -//=========================================================================== - Standard_Integer - BooleanOperations_ShapesDataStructure::RefEdge(const Standard_Integer anIndex)const -{ - Standard_Integer iRefEdge; - iRefEdge=myRefEdges(anIndex); - return iRefEdge; -} - -//=========================================================================== -//function : NbEdges -//purpose : -//=========================================================================== - Standard_Integer BooleanOperations_ShapesDataStructure::NbEdges()const -{ - return myNbEdges; -} - - -//=========================================================================== -//function : Message -//purpose : -//=========================================================================== -void Message(const Standard_Integer i) -{ - char buf[256]; - sprintf(buf, " BooleanOperations_ShapesDataStructure:: "); - BOPTColStd_Dump::PrintMessage(buf); - - switch (i) { - case 1: - sprintf (buf, "index is out of range\n"); - break; - case 2: - sprintf (buf, "incorrect Type\n"); - break; - default: - sprintf(buf, "undefined message\n"); - break; - } - BOPTColStd_Dump::PrintMessage(buf); - Standard_DomainError::Raise("Message"); -} - -//=========================================================================== -//function : Dump -//purpose : -//=========================================================================== - void BooleanOperations_ShapesDataStructure::Dump(Standard_OStream& S) const -{ - - Standard_Integer i,j; - TopAbs_ShapeEnum T; - //ZZ gp_Pnt thePoint; - BooleanOperations_StateOfShape St; - - S<myNumberOfInsertedShapes)||(successorNumber<1)||(successorNumber>NumberOfSuccessors(index))) { - Message(1); - } - if (GetShapeType(index) == TopAbs_VERTEX) { - Message(2); - } - return myListOfShapeAndInterferences[index-1].GetOrientation(successorNumber); -} -//=========================================================================== -//function : GetOrientations -//purpose : returns the array of orientations -//=========================================================================== - void - BooleanOperations_ShapesDataStructure::GetOrientations(const Standard_Integer index, - Standard_Address& theArrayOfOrientations, - Standard_Integer& orientationsNumber) const -{ - if ((index<1)||(index>myNumberOfInsertedShapes)) { - Message(1); - } - if (GetShapeType(index) == TopAbs_VERTEX) { - Message(2); - } - myListOfShapeAndInterferences[index-1].GetOrientations(theArrayOfOrientations,orientationsNumber); -} -//modified by NIZNHY-PKV Wed Feb 2 14:44:08 2005f -/* -#ifdef WNT -#pragma warning ( default : 4291 ) -#endif -*/ -/* -//=========================================================================== -//function : InsertInterference -//purpose : -//=========================================================================== - void BooleanOperations_ShapesDataStructure::InsertInterference(const Standard_Integer index, - const BooleanOperations_InterferenceResult&)// IR) -{ - if ((index<1)||(index>myNumberOfInsertedShapes)) { - Message(1); - } -//modified by NIZNHY-PKV Wed Feb 2 13:02:32 2005ft -// myListOfShapeAndInterferences[index-1].SetInterference(IR); -} -//=========================================================================== -//function : GetInterference -//purpose : -//=========================================================================== - const BooleanOperations_InterferenceResult& - BooleanOperations_ShapesDataStructure::GetInterference(const Standard_Integer index, - const Standard_Integer interfNumber) const -{ - - if ((index<1)||(index>myNumberOfInsertedShapes)) { - Message(1); - } - //modified by NIZNHY-PKV Wed Feb 2 13:04:12 2005f - //return myListOfShapeAndInterferences[index-1].GetInterference(interfNumber); - - static BooleanOperations_InterferenceResult aIR; - return aIR; - //modified by NIZNHY-PKV Wed Feb 2 13:04:22 2005t -} - -//=========================================================================== -//function : GetIntersectedShape -//purpose : -//=========================================================================== - Standard_Integer - BooleanOperations_ShapesDataStructure::GetIntersectedShape(const Standard_Integer index, - const Standard_Integer interfNumber) const -{ - if ((index<1)||(index>myNumberOfInsertedShapes)) { - Message(1); - } - //modified by NIZNHY-PKV Wed Feb 2 13:04:39 2005f - //return myListOfShapeAndInterferences[index-1].GetIntersectedShape(interfNumber); - return 0; - //modified by NIZNHY-PKV Wed Feb 2 13:04:45 2005t -} -//=========================================================================== -//function : GetIntersectionResult -//purpose : -//=========================================================================== - Standard_Integer - BooleanOperations_ShapesDataStructure::GetIntersectionResult (const Standard_Integer index, - const Standard_Integer interfNumber) const -{ - if ((index<1)||(index>myNumberOfInsertedShapes)) { - Message(1); - } - //modified by NIZNHY-PKV Wed Feb 2 13:05:36 2005f - //return myListOfShapeAndInterferences[index-1].GetIntersectionResult(interfNumber); - return 0; - //modified by NIZNHY-PKV Wed Feb 2 13:04:45 2005t -} -//=========================================================================== -//function : NumberOfInterferences -//purpose : -//=========================================================================== - Standard_Integer - BooleanOperations_ShapesDataStructure::NumberOfInterferences(const Standard_Integer index) const -{ - if ((index<1)||(index>myNumberOfInsertedShapes)) { - Message(1); - } - //modified by NIZNHY-PKV Wed Feb 2 13:06:43 2005f - //return myListOfShapeAndInterferences[index-1].NumberOfInterferences(); - return 0; - //modified by NIZNHY-PKV Wed Feb 2 13:04:45 2005t -} - -*/ -//modified by NIZNHY-PKV Wed Feb 2 14:44:11 2005t diff --git a/src/IntTools/IntTools_BeanFaceIntersector.cdl b/src/IntTools/IntTools_BeanFaceIntersector.cdl index 102ba9e523..f1b0996f58 100755 --- a/src/IntTools/IntTools_BeanFaceIntersector.cdl +++ b/src/IntTools/IntTools_BeanFaceIntersector.cdl @@ -173,9 +173,9 @@ is ComputeLinePlane(me: in out) is private; - + FastComputeExactIntersection(me: in out) - returns Boolean from Standard is private; + returns Integer from Standard is private; ComputeUsingExtremum(me: in out) is private; diff --git a/src/IntTools/IntTools_BeanFaceIntersector.cxx b/src/IntTools/IntTools_BeanFaceIntersector.cxx index e5f3c628c8..772c0618da 100755 --- a/src/IntTools/IntTools_BeanFaceIntersector.cxx +++ b/src/IntTools/IntTools_BeanFaceIntersector.cxx @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -327,7 +328,7 @@ void IntTools_BeanFaceIntersector::Perform() { myIsDone = Standard_False; myResults.Clear(); - Standard_Boolean bRet; + Standard_Integer bRet; Standard_Integer aDiscretization = 30; Standard_Real aRelativeDeflection = 0.01; myDeflection = aRelativeDeflection; @@ -409,12 +410,18 @@ void IntTools_BeanFaceIntersector::Perform() } // bRet=FastComputeExactIntersection(); - if(bRet) { + if(bRet == 1) { IntTools_Range aRange(myFirstParameter, myLastParameter); myResults.Append(aRange); myIsDone = Standard_True; return; + } + //modified by NIZHNY-EMV Fri Apr 20 09:38:08 2012 + else if (bRet == 2) { + myIsDone = Standard_True; + return; } + //modified by NIZHNY-EMV Fri Apr 20 09:38:10 2012 // Standard_Boolean coinside = TestCoinside(myCurve,mySurface); @@ -714,13 +721,13 @@ void IntTools_BeanFaceIntersector::ComputeAroundExactIntersection() // function: FastComputeExactIntersection // purpose: // ================================================================================== -Standard_Boolean IntTools_BeanFaceIntersector::FastComputeExactIntersection() +Standard_Integer IntTools_BeanFaceIntersector::FastComputeExactIntersection() { - Standard_Boolean aresult; + Standard_Integer aresult; GeomAbs_CurveType aCT; GeomAbs_SurfaceType aST; // - aresult = Standard_False; + aresult = 0; aCT=myCurve.GetType(); aST=mySurface.GetType(); // @@ -737,7 +744,7 @@ Standard_Boolean IntTools_BeanFaceIntersector::FastComputeExactIntersection() if((surfPlane.Distance(myCurve.Value(myFirstParameter)) < myCriteria) && (surfPlane.Distance(myCurve.Value(myLastParameter)) < myCriteria)) { myRangeManager.InsertRange(myFirstParameter, myLastParameter, 2); - aresult = Standard_True; + aresult = 1; } } else { // else 1 @@ -815,7 +822,7 @@ Standard_Boolean IntTools_BeanFaceIntersector::FastComputeExactIntersection() // if(insertRange) { myRangeManager.InsertRange(myFirstParameter, myLastParameter, 2); - aresult = Standard_True; + aresult = 1; } }//if(anAngle < Precision::Angular()) { }//else { // else 1 @@ -850,7 +857,7 @@ Standard_Boolean IntTools_BeanFaceIntersector::FastComputeExactIntersection() if(adist < myCriteria) { // Abs is important function here myRangeManager.InsertRange(myFirstParameter, myLastParameter, 2); - aresult = Standard_True; + aresult = 1; } } } @@ -870,7 +877,7 @@ Standard_Boolean IntTools_BeanFaceIntersector::FastComputeExactIntersection() if(adist < myCriteria) { myRangeManager.InsertRange(myFirstParameter, myLastParameter, 2); - aresult = Standard_True; + aresult = 1; } } } @@ -922,12 +929,31 @@ Standard_Boolean IntTools_BeanFaceIntersector::FastComputeExactIntersection() break; } } + //modified by NIZHNY-EMV Fri Apr 20 08:45:29 2012 + // + if (!bFlag) { + Standard_Real U, V, aTm; + gp_Pnt aPm; + gp_Pnt2d aP2d; + // + aTm = IntTools_Tools::IntermediatePoint(myFirstParameter, myLastParameter); + aPm = myCurve.Value(aTm); + ElSLib::Parameters(aCyl, aPm, U, V); + aP2d.SetCoord(U,V); + // + bFlag = !(myContext->IsPointInOnFace(mySurface.Face(), aP2d)); + } // if (!bFlag){ myRangeManager.InsertRange(myFirstParameter, myLastParameter, 2); - aresult = Standard_True; + aresult = 1; return aresult; } + else { + aresult = 2; + return aresult; + } + //modified by NIZHNY-EMV Fri Apr 20 08:45:32 2012 } }//if(aCT==GeomAbs_Line) { diff --git a/src/IntTools/IntTools_EdgeEdge.cxx b/src/IntTools/IntTools_EdgeEdge.cxx index 57c65e8d73..8386df4fce 100755 --- a/src/IntTools/IntTools_EdgeEdge.cxx +++ b/src/IntTools/IntTools_EdgeEdge.cxx @@ -1503,7 +1503,7 @@ IntTools_EdgeEdge::IntTools_EdgeEdge() // IsParallel = Standard_False; IsCoincide = Standard_False; - Tolang2 = 1.e-16; + Tolang2 = Precision::Angular(); Tol2 = myCriteria*myCriteria; // gp_Lin C1 = myCFrom.Line(); @@ -1512,6 +1512,7 @@ IntTools_EdgeEdge::IntTools_EdgeEdge() const gp_Dir& D2 = C2.Position().Direction(); Standard_Real aCos = D1.Dot(D2); Standard_Real Ang2; + if(aCos >= 0. ) { Ang2 = 2.*(1. - aCos); } diff --git a/src/IntTools/IntTools_FaceFace.cxx b/src/IntTools/IntTools_FaceFace.cxx index 462df3faff..a02ace8137 100755 --- a/src/IntTools/IntTools_FaceFace.cxx +++ b/src/IntTools/IntTools_FaceFace.cxx @@ -1041,6 +1041,46 @@ void IntTools_FaceFace::SetList(IntSurf_ListOfPntOn2S& aListOfPnts) myTolReached3d=sqrt(aD2max); } }//else if ((aType1==GeomAbs_Plane && aType2==GeomAbs_Sphere) ... + else if (!myApprox) { + Standard_Integer i, aNbP, j ; + Standard_Real aT1, aT2, dT, aD2, aD2Max, aEps, aT11, aT12; + // + aD2Max=0.; + aNbLin=mySeqOfCurve.Length(); + // + for (i=1; i<=aNbLin; ++i) { + const IntTools_Curve& aIC=mySeqOfCurve(i); + const Handle(Geom_Curve)& aC3D=aIC.Curve(); + const Handle(Geom2d_Curve)& aC2D1=aIC.FirstCurve2d(); + const Handle(Geom2d_Curve)& aC2D2=aIC.SecondCurve2d(); + // + if (aC3D.IsNull()) { + continue; + } + const Handle(Geom_BSplineCurve)& aBC= + Handle(Geom_BSplineCurve)::DownCast(aC3D); + if (aBC.IsNull()) { + continue; + } + // + aT1=aBC->FirstParameter(); + aT2=aBC->LastParameter(); + // + aEps=0.0001*(aT2-aT1); + aNbP=11; + dT=(aT2-aT1)/aNbP; + for (j=1; jaD2Max) { + aD2Max=aD2; + } + } + }//for (i=1; i<=aNbLin; ++i) { + myTolReached3d=sqrt(aD2Max); + } //modified by NIZNHY-PKV Thu Aug 30 13:31:12 2012t } //======================================================================= diff --git a/src/IntWalk/IntWalk_PWalking_1.gxx b/src/IntWalk/IntWalk_PWalking_1.gxx index a2614394ea..3a0200397e 100755 --- a/src/IntWalk/IntWalk_PWalking_1.gxx +++ b/src/IntWalk/IntWalk_PWalking_1.gxx @@ -531,7 +531,11 @@ void IntWalk_PWalking::Perform(const TColStd_Array1OfReal& ParDep, Standard_Integer LevelOfIterWithoutAppend = -1; // Arrive = Standard_False; - while(!Arrive) {//010 + //emv for chl 927 K1 + //check one more point with half-step + Standard_Integer bTryOneMorePoint = 0; + // + while(!Arrive || bTryOneMorePoint==1) {//010 LevelOfIterWithoutAppend++; if(LevelOfIterWithoutAppend>20) { Arrive = Standard_True; @@ -561,6 +565,11 @@ void IntWalk_PWalking::Perform(const TColStd_Array1OfReal& ParDep, //--ofv.begin Standard_Real aIncKey, aEps, dP1, dP2, dP3, dP4; // + if (bTryOneMorePoint) { + f *= 2; + ++bTryOneMorePoint; + } + // dP1 = sensCheminement * pasuv[0] * previousd1.X() /f; dP2 = sensCheminement * pasuv[1] * previousd1.Y() /f; dP3 = sensCheminement * pasuv[2] * previousd2.X() /f; @@ -1049,6 +1058,11 @@ void IntWalk_PWalking::Perform(const TColStd_Array1OfReal& ParDep, } //007 switch(Status) } //008 fin traitement point en court (TEST DEFLECTION) } //009 fin traitement ligne (else if myIntersectionOn2S.IsDone()) + if (Arrive && !close) { + ++bTryOneMorePoint; + } else if (bTryOneMorePoint) { + Arrive = Standard_True; + } } //010 fin si premier point de depart a permis un cheminement while(!Arrive) done = Standard_True; } diff --git a/src/LocOpe/LocOpe.cdl b/src/LocOpe/LocOpe.cdl index 57a75f5928..760ec551d1 100755 --- a/src/LocOpe/LocOpe.cdl +++ b/src/LocOpe/LocOpe.cdl @@ -22,8 +22,8 @@ package LocOpe - ---Purpose: Provides tools to implement local topological - -- operations on a shape. + ---Purpose: Provides tools to implement local topological + -- operations on a shape. uses MMgt, StdFail, @@ -39,15 +39,11 @@ uses MMgt, TopExp, TopTools, BRepFill, - BRepAlgo, BRepSweep, - BOP, TopOpeBRepDS -- TopOpeBRepBuild -is - - class Builder; +is class SplitShape; @@ -81,9 +77,9 @@ is class FindEdgesInFace; class DataMapOfShapePnt instantiates DataMap from TCollection - (Shape from TopoDS, - Pnt from gp, - ShapeMapHasher from TopTools); + (Shape from TopoDS, + Pnt from gp, + ShapeMapHasher from TopTools); class PntFace; @@ -98,52 +94,52 @@ is class SequenceOfPntFace instantiates Sequence from TCollection - (PntFace from LocOpe); + (PntFace from LocOpe); class SequenceOfLin instantiates Sequence from TCollection - (Lin from gp); + (Lin from gp); class SequenceOfCirc instantiates Sequence from TCollection - (Circ from gp); + (Circ from gp); private class HBuilder; -- inherits HBuilder from TopOpeBRepBuild private class BuildWires; -- used in LocOpe_Spliter enumeration Operation is - FUSE, - CUT, - INVALID + FUSE, + CUT, + INVALID end Operation; Closed(W: Wire from TopoDS; OnF: Face from TopoDS) - ---Purpose: Returns Standard_True when the wire is closed - -- on the face . - returns Boolean from Standard; + ---Purpose: Returns Standard_True when the wire is closed + -- on the face . + returns Boolean from Standard; Closed(E: Edge from TopoDS; OnF: Face from TopoDS) - ---Purpose: Returns Standard_True when the edge is closed - -- on the face . - returns Boolean from Standard; + ---Purpose: Returns Standard_True when the edge is closed + -- on the face . + returns Boolean from Standard; TgtFaces(E : Edge from TopoDS; - F1: Face from TopoDS; - F2: Face from TopoDS) - ---Purpose: Returns Standard_True when the faces are tangent - returns Boolean from Standard; + F1: Face from TopoDS; + F2: Face from TopoDS) + ---Purpose: Returns Standard_True when the faces are tangent + returns Boolean from Standard; -- IsInside(F1: Face from TopoDS; F2: Face from TopoDS) --- ---Purpose: Returns Standard_True when the face F1 is in the --- -- F2 . --- returns Boolean from Standard; +-- ---Purpose: Returns Standard_True when the face F1 is in the +-- -- F2 . +-- returns Boolean from Standard; SampleEdges(S : Shape from TopoDS; - Pt: in out SequenceOfPnt from TColgp); + Pt: in out SequenceOfPnt from TColgp); end LocOpe; diff --git a/src/LocOpe/LocOpe_Builder.cdl b/src/LocOpe/LocOpe_Builder.cdl deleted file mode 100755 index fae408ac46..0000000000 --- a/src/LocOpe/LocOpe_Builder.cdl +++ /dev/null @@ -1,270 +0,0 @@ --- Created on: 1995-04-25 --- Created by: Jacques GOUSSARD --- Copyright (c) 1995-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class Builder from LocOpe - - ---Purpose: Provides a basic tool to implement local - -- topological operations. - -uses - Shape from TopoDS, - ListOfShape from TopTools, --- HBuilder from TopOpeBRepBuild, --- DSAccess from BRepAlgo, - HistoryCollector from BOP, - TopOpe from BRepAlgo, - MapOfShape from TopTools - - -raises - NotDone from StdFail, - ConstructionError from Standard - - -is - - Create - ---Purpose: Empty constructor. - returns Builder from LocOpe; - - - Create(S: Shape from TopoDS) - ---Purpose: Creates a builder for local operations on . - returns Builder from LocOpe - raises ConstructionError from Standard; - --- The exception is raised if is a null shape. - - - Create(S: Shape from TopoDS; Tool: Shape from TopoDS) - ---Purpose: Creates a builder for local operations between - -- and . - returns Builder from LocOpe - raises ConstructionError from Standard; - --- The exception is raised if or is a null shape . - - - Init(me: in out; S: Shape from TopoDS) - ---Purpose: Initializes a builder for local operations on . - raises ConstructionError from Standard - --- The exception is raised if is a null shape. - is static; - - - Init(me: in out; S: Shape from TopoDS; Tool: Shape from TopoDS) - ---Purpose: Initializes a builder for local operations between - -- and . - raises ConstructionError from Standard - --- The exception is raised if or is a null shape. - is static; - - - Perform(me: in out; Tool : Shape from TopoDS; - L : ListOfShape from TopTools; - Fuse : Boolean from Standard) - - ---Purpose: Performs the local operation on the formerly given - -- shape. defines a set of faces of the - -- shape. The whole tool is used. The list may not be - -- empty. The boolean gives the type of - -- operation. If set to Standard_True, the operation - -- is a fusion. If set to Standard_False, the - -- operation is a cutting one. - -- - -- The Perform process stops just before constructing - -- any result in order to authorize the selection of - -- parts of the tool. After a call to Perform, it is - -- possible to call BuilPartsOfTool, then - -- RemovePart/ActivatePart to select valid parts, and - -- it is necessary to call PerformResult to get any - -- result. - - raises ConstructionError from Standard - -- The exception is raised if is null or same as the shape. - - is static; - - - Perform(me: in out; LShape : ListOfShape from TopTools; - LTool : ListOfShape from TopTools; - Fuse : Boolean from Standard) - - ---Purpose: Performs the local operation on the formerly given - -- shape and tool. defines a set of faces - -- of the shape. defines a set of faces of - -- the tool. The boolean gives the type of - -- operation. If set to Standard_True, the operation - -- is a fusion. If set to Standard_False, the - -- operation is a cutting one. If (resp. - -- ) is empty, the whole shape (resp. tool) is - -- used. - -- - -- The Perform process stops just before constructing - -- any result in order to authorize the selection of - -- parts of the tool. After a call to Perform, it is - -- possible to call BuilPartsOfTool, then - -- RemovePart/ActivatePart to select valid parts, and - -- it is necessary to call PerformResult to get any - -- result. - - is static; - - - - BuildPartsOfTool(me: in out) - ---Purpose: Builds every valid parts of the tool. - raises NotDone from StdFail - -- The exception is raised if no call to Perform has been done. - is static; - - - PartsOfTool(me) - ---Purpose: Returns the list of the parts of tool. Each of - -- this part is a TopoDS_Shell. - returns ListOfShape from TopTools - ---C++: return const& - raises NotDone from StdFail - -- The exception is raised if no call to BuildPartsOfTool has - -- been done. - is static; - - - RemovePart(me: in out; S: Shape from TopoDS) - ---Purpose: Removes from the list of valid parts of tool. - raises NotDone from StdFail - -- The exception is raised if no call to BuildPartsOfTool has - -- been done. - is static; - - - ActivatePart(me: in out; S: Shape from TopoDS) - ---Purpose: Removes from the list of invalid parts of - -- tool. By default, all parts of tool are valid for - -- the local operation. - raises NotDone from StdFail - -- The exception is raised if no call to BuildPartsOfTool has - -- been done. - is static; - - - - PerformResult(me: in out) - ---Purpose: Invalidates the given parts of tools if any, and - -- performs the result of the local operation. - raises NotDone from StdFail - -- The exception is raised if no call to Perform has been done. - is static; - - - IsDone(me) - ---Purpose: Returns Standard_True if the operation has been - -- successfuly done. - returns Boolean from Standard - ---C++: inline - is static; - - IsInvDone(me) - ---Purpose: Returns Standard_True if the Invalidate Parts - -- operation has been successfuly done. - returns Boolean from Standard - ---C++: inline - is static; - - ResultingShape(me) - ---Purpose: Returns the result of the operation. - - returns Shape from TopoDS - ---C++: return const& - ---C++: inline - raises NotDone from StdFail - -- The exception is raised if IsDone returns Standard_False. - is static; - - - OriginalShape(me) - ---Purpose: Returns the shape on which the operation is defined. - returns Shape from TopoDS - ---C++: return const& - ---C++: inline - is static; - - - Tool(me) - ---Purpose: Returns the "tool" used to perform the local operation. - returns Shape from TopoDS - ---C++: return const& - ---C++: inline - is static; - - --- Builder(me) --- returns HBuilder from TopOpeBRepBuild - - History(me) - returns HistoryCollector from BOP - ---C++: inline - ---C++: return const& - is static; - - ---- Private implementation methods --- - - InvalidateParts(me: in out) - - is static; - - Edges(me) - - returns ListOfShape from TopTools - ---C++: return const& - is static; - - TgtEdges(me) - - returns ListOfShape from TopTools - ---C++: return const& - is static; - - -fields - - myDone : Boolean from Standard; - myShape : Shape from TopoDS; - myTool : Shape from TopoDS; - myResult : Shape from TopoDS; - myParts : ListOfShape from TopTools; - myRemoved : ListOfShape from TopTools; - myPdone : Boolean from Standard; - myPerfdone: Boolean from Standard; - myInvDone : Boolean from Standard; - myFuse : Boolean from Standard; - myEdges : ListOfShape from TopTools; - myTgtEdges: ListOfShape from TopTools; --- myAlgo : DSAccess from BRepAlgo; - myAlgo : TopOpe from BRepAlgo; - myShapeMap: MapOfShape from TopTools; - myToolMap : MapOfShape from TopTools; - -end Builder; - - - diff --git a/src/LocOpe/LocOpe_Builder.cxx b/src/LocOpe/LocOpe_Builder.cxx deleted file mode 100755 index c5df3683af..0000000000 --- a/src/LocOpe/LocOpe_Builder.cxx +++ /dev/null @@ -1,1053 +0,0 @@ -// Created on: 1995-04-25 -// Created by: Jacques GOUSSARD -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include - -#include -#include -#include - - -//#include -//#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//#define DRAW -#ifdef DRAW -#include -#include -#endif - -void RemoveFaces(const TopoDS_Shape& theComp, const BOPTools_PDSFiller& theDSFiller, - TopTools_MapOfShape& theMap) -{ - const BooleanOperations_ShapesDataStructure& aDS = theDSFiller->DS(); - const BOPTools_InterferencePool& anInterfPool = theDSFiller->InterfPool(); - BOPTools_InterferencePool* pInterfPool = (BOPTools_InterferencePool*) &anInterfPool; - BOPTools_CArray1OfSSInterference& aFFs = pInterfPool->SSInterferences(); - - TopTools_MapOfShape aCompMap; - TopExp_Explorer anExp(theComp, TopAbs_EDGE); - for(; anExp.More(); anExp.Next()) { - aCompMap.Add(anExp.Current()); - } - - Standard_Integer aNbFFs=aFFs.Extent(), i, j, aNbS, aNbCurves, nSect; - - for (i=1; i<=aNbFFs; ++i) { - BOPTools_SSInterference& aFFi=aFFs(i); - // - // - // Old Section Edges - const BOPTools_ListOfPaveBlock& aSectList=aFFi.PaveBlocks(); - aNbS=aSectList.Extent(); - BOPTools_ListIteratorOfListOfPaveBlock anIt(aSectList); - for (; anIt.More();anIt.Next()) { - const BOPTools_PaveBlock& aPB=anIt.Value(); - nSect=aPB.Edge(); - const TopoDS_Shape& aS=aDS.GetShape(nSect); - - const TopoDS_Edge& aE = TopoDS::Edge(aS); - - if(!aCompMap.Contains(aE)) continue; - - Standard_Integer nF1 = aFFi.Index1(); - Standard_Integer nF2 = aFFi.Index2(); - - const TopoDS_Shape& aF1 = aDS.Shape(nF1); - const TopoDS_Shape& aF2 = aDS.Shape(nF2); - - if(theMap.Contains(aF1)) theMap.Remove(aF1); - if(theMap.Contains(aF2)) theMap.Remove(aF2); - - - } - // - // New Section Edges - BOPTools_SequenceOfCurves& aBCurves=aFFi.Curves(); - aNbCurves=aBCurves.Length(); - for (j=1; j<=aNbCurves; j++) { - BOPTools_Curve& aBC=aBCurves(j); - const BOPTools_ListOfPaveBlock& aSectEdges=aBC.NewPaveBlocks(); - aNbS=aSectEdges.Extent(); - - BOPTools_ListIteratorOfListOfPaveBlock aPBIt(aSectEdges); - for (; aPBIt.More(); aPBIt.Next()) { - BOPTools_PaveBlock& aPB=aPBIt.Value(); - nSect=aPB.Edge(); - const TopoDS_Shape& aS=aDS.GetShape(nSect); - const TopoDS_Edge& aE = TopoDS::Edge(aS); - - if(!aCompMap.Contains(aE)) continue; - - Standard_Integer nF1 = aFFi.Index1(); - Standard_Integer nF2 = aFFi.Index2(); - - const TopoDS_Shape& aF1 = aDS.Shape(nF1); - const TopoDS_Shape& aF2 = aDS.Shape(nF2); - - if(theMap.Contains(aF1)) theMap.Remove(aF1); - if(theMap.Contains(aF2)) theMap.Remove(aF2); - - } - } - } - - } - -inline Standard_Boolean Egal(const gp_Pnt& P1, const gp_Pnt& P2) -{ - - return ((P1.X() == P2.X()) && - (P1.Y() == P2.Y()) && - (P1.Z() == P2.Z())); - -} - - -//======================================================================= -//function : LocOpe_Builder -//purpose : -//======================================================================= - -LocOpe_Builder::LocOpe_Builder() : - myDone(Standard_False), myPdone(Standard_False),myPerfdone(Standard_False), - myInvDone(Standard_False) -{ - -} - - -//======================================================================= -//function : LocOpe_Builder -//purpose : -//======================================================================= - -LocOpe_Builder::LocOpe_Builder(const TopoDS_Shape& S) : - myDone(Standard_False), myShape(S), myTool(S), - myPdone(Standard_False), myPerfdone(Standard_False), - myInvDone(Standard_False) -{ - - if (S.IsNull()) { - Standard_ConstructionError::Raise(); - } -} - - -//======================================================================= -//function : LocOpe_Builder -//purpose : -//======================================================================= - -LocOpe_Builder::LocOpe_Builder(const TopoDS_Shape& S, - const TopoDS_Shape& T) : - myDone(Standard_False), myShape(S), myTool(T), - myPdone(Standard_False), myPerfdone(Standard_False), - myInvDone(Standard_False) -{ - - if (S.IsNull()|| T.IsNull()) { - Standard_ConstructionError::Raise(); - } -} - - -//======================================================================= -//function : Init -//purpose : -//======================================================================= - -void LocOpe_Builder::Init(const TopoDS_Shape& S) -{ - if (S.IsNull()) { - Standard_ConstructionError::Raise(); - } - - myDone = Standard_False; - myPdone = Standard_False; - myPerfdone = Standard_False; - myInvDone = Standard_False; - myShape = S; - myTool = S; - myParts.Clear(); - myRemoved.Clear(); - myResult.Nullify(); -} - -//======================================================================= -//function : Init -//purpose : -//======================================================================= - -void LocOpe_Builder::Init(const TopoDS_Shape& S, - const TopoDS_Shape& T) -{ - if (S.IsNull() || T.IsNull()) { - Standard_ConstructionError::Raise(); - } - - myDone = Standard_False; - myPdone = Standard_False; - myPerfdone = Standard_False; - myInvDone = Standard_False; - myShape = S; - myTool = T; - myParts.Clear(); - myRemoved.Clear(); - myResult.Nullify(); -} - - -//======================================================================= -//function : Perform -//purpose : -//======================================================================= - -void LocOpe_Builder::Perform (const TopoDS_Shape& Tool, - const TopTools_ListOfShape& L, - const Standard_Boolean Fuse) -{ - - if (Tool.IsNull() || myShape.IsSame(Tool)) { - Standard_ConstructionError::Raise(); - } - myTool = Tool; - TopTools_ListOfShape LTool; - TopExp_Explorer exp; - for (exp.Init(myTool,TopAbs_FACE); exp.More(); exp.Next()) { -// for (TopExp_Explorer exp(myTool,TopAbs_FACE); exp.More(); exp.Next()) { - LTool.Append(exp.Current()); - } - Perform(L,LTool,Fuse); -} - - -//======================================================================= -//function : Perform -//purpose : -//======================================================================= - -void LocOpe_Builder::Perform (const TopTools_ListOfShape& LShape, - const TopTools_ListOfShape& LTool, - const Standard_Boolean Fuse) -{ - - - myPerfdone = Standard_False; - myInvDone = Standard_False; - - myDone = Standard_False; - myPdone = Standard_False; - - myFuse = Fuse; - TopAbs_State St2 = (myFuse) ? TopAbs_OUT : TopAbs_IN; - - - TopTools_MapOfShape mapUsedShape,mapUsedTool,mapShape, - mapTool,mapAdded, NewEdges; - TopTools_IndexedDataMapOfShapeListOfShape EFMap; - TopTools_ListIteratorOfListOfShape its(LShape),itt(LTool); - TopTools_MapIteratorOfMapOfShape itm,itm2; - TopTools_ListOfShape newFS,newFT; - BRep_Builder B; - - Standard_Boolean found; - - TopExp::MapShapesAndAncestors(myShape,TopAbs_EDGE,TopAbs_FACE,EFMap); - if (!myTool.IsSame(myShape)) { - TopExp::MapShapesAndAncestors(myTool,TopAbs_EDGE,TopAbs_FACE,EFMap); - } - - // on veut l`orientation relative correcte des faces dans le shape -// for (TopExp_Explorer it(myShape.Oriented(TopAbs_FORWARD),TopAbs_FACE); - TopExp_Explorer it(myShape.Oriented(TopAbs_FORWARD),TopAbs_FACE); - for ( ; it.More(); it.Next()) { - mapShape.Add(it.Current()); - } - - for (it.Init(myTool.Oriented(TopAbs_FORWARD),TopAbs_FACE); - it.More(); - it.Next()) { - mapTool.Add(it.Current()); - } - - if (!LShape.IsEmpty()) { - - // on verifie que les faces de LShape appartiennent a myShape - while (its.More()) { - Standard_Boolean found = Standard_False; - for (itm.Initialize(mapShape);itm.More(); itm.Next()) { - if (itm.Key().IsSame(its.Value())) { - found = Standard_True; - break; - } - } - if (!found) { - return; - } - - TopAbs_Orientation orient = itm.Key().Orientation(); - TopoDS_Face theF = TopoDS::Face(its.Value()); - theF.Orientation(orient); - if (mapAdded.Add(theF)) { - newFS.Append(theF); - } - its.Next(); - } - } - else { - for (it.Init(myShape.Oriented(TopAbs_FORWARD),TopAbs_FACE); - it.More(); - it.Next()) { - if (mapAdded.Add(it.Current())) { - newFS.Append(it.Current()); - } - } - } - - - if (!LTool.IsEmpty()) { - // on verifie que les faces de LTool appartiennent a myTool - while (itt.More()) { - found = Standard_False; - for (itm.Initialize(mapTool);itm.More(); itm.Next()) { - if (itm.Key().IsSame(itt.Value())) { - found = Standard_True; - break; - } - } - if (!found) { - return; - } - - TopAbs_Orientation orient = itm.Key().Orientation(); - TopoDS_Face theF = TopoDS::Face(itt.Value()); - theF.Orientation(orient); - if (mapAdded.Add(theF)) { - newFT.Append(theF); - } - itt.Next(); - } - } - else { - for (it.Init(myTool.Oriented(TopAbs_FORWARD),TopAbs_FACE); - it.More(); - it.Next()) { - if (mapAdded.Add(it.Current())) { - newFT.Append(it.Current()); - } - } - } - -#ifdef DRAW - Standard_Integer ii = 0; - char namep[10]; - for (its.Initialize(newFS); its.More(); its.Next()) { - ii++; - sprintf(namep,"F_%d",ii); - DBRep::Set(namep,its.Value()); - } - ii = 0; - for (itt.Initialize(newFT); itt.More(); itt.Next()) { - ii++; - sprintf(namep,"T_%d",ii); - DBRep::Set(namep,itt.Value()); - } -#endif -#ifdef DRAW - DBRep::Set("myShape", myShape); - DBRep::Set("myTool", myTool); -#endif - - myShapeMap.Clear(); - myToolMap.Clear(); //-------------- - -#ifdef DRAW - ii = 0; -#endif - do { -#ifdef DRAW - ii++; -#endif - TopoDS_Compound CoFS, CoFT, CoTool, CoShape; - B.MakeCompound(CoFS); - B.MakeCompound(CoFT); - B.MakeCompound(CoTool); - B.MakeCompound(CoShape); - for (its.Initialize(newFS); its.More(); its.Next()) { - myShapeMap.Add(its.Value()); - B.Add(CoFS, its.Value()); - } -#ifdef DRAW - sprintf(namep,"CoFS_%d",ii); - DBRep::Set(namep, CoFS); -#endif - - for (itt.Initialize(newFT); itt.More(); itt.Next()) { - myToolMap.Add(itt.Value()); - B.Add(CoFT, itt.Value()); - } -#ifdef DRAW - sprintf(namep,"CoFT_%d",ii); - DBRep::Set(namep, CoFT); -#endif - - for (itm2.Initialize(mapUsedTool); itm2.More(); itm2.Next()) { - myToolMap.Add(itm2.Key()); - B.Add(CoTool, itm2.Key()); - } -#ifdef DRAW - sprintf(namep,"CoTool_%d",ii); - DBRep::Set(namep, CoTool); -#endif - - for (itm.Initialize(mapUsedShape); itm.More(); itm.Next()) { - myShapeMap.Add(itm.Key()); - B.Add(CoShape, itm.Key()); - } -#ifdef DRAW - sprintf(namep,"CoShape_%d",ii); - DBRep::Set(namep, CoShape); -#endif - -//--------------------------------------------------------------- - myAlgo.Init(); - if (St2 != TopAbs_OUT) { - myAlgo.Load(myShape, myTool); - } - else { - myAlgo.Load(myTool, myShape); - } - - TopoDS_Compound aCoShape, aCoTool; - B.MakeCompound(aCoShape); - B.MakeCompound(aCoTool); - - TopTools_MapIteratorOfMapOfShape anIt1(myShapeMap), anIt2(myToolMap); - - for(; anIt1.More(); anIt1.Next()) { - B.Add(aCoShape, anIt1.Key()); - } - - for(; anIt2.More(); anIt2.Next()) { - B.Add(aCoTool, anIt2.Key()); - } - - if (St2 != TopAbs_OUT) myAlgo.Intersect(aCoShape, aCoTool); - else myAlgo.Intersect(aCoTool, aCoShape); - -//------------------------------------------------------------------- - - for (its.Initialize(newFS); its.More(); its.Next()) { - mapUsedShape.Add(its.Value()); - } - for (itt.Initialize(newFT); itt.More(); itt.Next()) { - mapUsedTool.Add(itt.Value()); - } - - newFS.Clear(); - newFT.Clear(); - - const BOPTools_PDSFiller& aFiller = myAlgo.DSFiller(); - const BooleanOperations_ShapesDataStructure& aDS = aFiller->DS(); - const BOPTools_InterferencePool& anIntrf = aFiller->InterfPool(); - //Checks if the set of faces is complete - for (Standard_Integer i=1; i<=EFMap.Extent(); i++) { - const TopoDS_Edge& Ed = TopoDS::Edge(EFMap.FindKey(i)); - - Standard_Integer index = aDS.ShapeIndex(Ed, 1); - if(index <= 0) index = aDS.ShapeIndex(Ed, 2); - if(index > 0 ) { - - if(!anIntrf.HasInterference(index)) continue; - - const TopTools_ListOfShape& Lf = EFMap.FindFromIndex(i); - Standard_Boolean InShape = Standard_False; - for (its.Initialize(Lf); its.More(); its.Next()) { - if (mapUsedShape.Contains(its.Value())) { - InShape = Standard_True; - break; - } - else if (mapUsedTool.Contains(its.Value())) { - InShape = Standard_False; - break; - } - } - if (!its.More()) { - Standard_ConstructionError::Raise(); - } - - for (its.Initialize(Lf); its.More(); its.Next()) { - if (InShape) { - if (!mapUsedShape.Contains(its.Value())) { - for (itm.Initialize(mapShape);itm.More(); itm.Next()) { - if (itm.Key().IsSame(its.Value())) { - break; - } - } - TopAbs_Orientation orient = itm.Key().Orientation(); - TopoDS_Face newF = TopoDS::Face(its.Value()); - newF.Orientation(orient); - if (mapAdded.Add(newF)) { - newFS.Append(newF); - } - } - } - else { - if (!mapUsedTool.Contains(its.Value())) { - for (itm.Initialize(mapTool);itm.More(); itm.Next()) { - if (itm.Key().IsSame(its.Value())) { - break; - } - } - TopAbs_Orientation orient = itm.Key().Orientation(); - TopoDS_Face newF = TopoDS::Face(its.Value()); - newF.Orientation(orient); - if (mapAdded.Add(newF)) { - newFT.Append(newF); - } - } - } - } - } - } - } while (!(newFS.IsEmpty() && newFT.IsEmpty())); - - - //----------------------------------------- - myAlgo.ToCompleteIntersection(); - //----------------------------------------- - - - myPerfdone = Standard_True; - -} - - -//======================================================================= -//function : BuildPartsOfTool -//purpose : -//======================================================================= - -void LocOpe_Builder::BuildPartsOfTool () -{ - if (!myPerfdone) { - StdFail_NotDone::Raise(); - } - - myPdone = Standard_False; - myParts.Clear(); - myRemoved.Clear(); - - TopAbs_State St2 = (myFuse) ? TopAbs_OUT : TopAbs_IN; - - TopoDS_Shape SS; - static Standard_Boolean OK; - OK = Standard_True; - - try { - OCC_CATCH_SIGNALS - if (St2 != TopAbs_OUT) { - SS = myAlgo.Merge(TopAbs_IN, St2); - } - else { - SS = myAlgo.Merge(St2, TopAbs_IN); - } - } - catch (Standard_Failure){ - OK = Standard_False; - } - - -//-------------------------------------------- -#ifdef DRAW - DBRep::Set("SS", SS); -#endif -//------------------------------------------------------------ - TopTools_MapOfShape DummyMap; - if (!SS.IsNull()) SS = BRepAlgo_Tool::Deboucle3D(SS, DummyMap); - if (SS.IsNull()) OK = Standard_False; - - // Est-ce que le shape est valide ? - TopExp_Explorer ex; - if (OK) { - ex.Init(SS, TopAbs_FACE); - OK = ex.More(); - if (OK) { - if (!BRepAlgo::IsTopologicallyValid(SS)) { - OK = Standard_False; -#ifdef DRAW - cout <<"LocOpe_Builder::BuildPartsOfTool: Shape non valide, on intersecte tout."<< endl; -#endif - } - } - else { -#ifdef DRAW - cout <<"LocOpe_Builder: Pas de faces dans le resultat, on intersecte tout."<< endl; -#endif - } - } - - - if (!OK) { - myAlgo.Init(); - if (St2 != TopAbs_OUT) { - myAlgo.Load(myShape, myTool); - myAlgo.Intersect(); - SS = myAlgo.Merge(TopAbs_IN, St2); - } - else { - myAlgo.Load(myTool, myShape); - myAlgo.Intersect(); - SS = myAlgo.Merge(St2, TopAbs_IN); - } - } - - TopExp_Explorer exp; - for (exp.Init(SS,TopAbs_SHELL); - exp.More(); exp.Next()) { - TopoDS_Shape S1 = exp.Current(); - if (!S1.IsNull()) S1 = BRepAlgo_Tool::Deboucle3D(S1, DummyMap); - if (!S1.IsNull()) myParts.Append(S1); - } - - myPdone = Standard_True; -} - - -//======================================================================= -//function : PartsOfTool -//purpose : -//======================================================================= - -const TopTools_ListOfShape& LocOpe_Builder::PartsOfTool () const -{ - if (!myPdone) { - StdFail_NotDone::Raise(); - } - return myParts; -} - - -//======================================================================= -//function : RemovePart -//purpose : -//======================================================================= - -void LocOpe_Builder::RemovePart (const TopoDS_Shape& S) -{ - if (!myPdone) { - StdFail_NotDone::Raise(); - } - - TopTools_ListIteratorOfListOfShape its(myParts); - for (;its.More(); its.Next()) { - if (S.IsSame(its.Value())) { - break; - } - } - if (!its.More()) { // S ne peut etre enlever -#ifdef DRAW - cout << "Invalid Shape" << endl; -#endif - } - else { - for (its.Initialize(myRemoved); its.More(); its.Next()) { - if (S.IsSame(its.Value())) { - break; - } - } - if (its.More()) { // S deja enleve -#ifdef DRAW - cout << "S has already been removed" << endl; -#endif - } - else { - myRemoved.Append(S); - } - } -} - - - -//======================================================================= -//function : ActivatePart -//purpose : -//======================================================================= - -void LocOpe_Builder::ActivatePart (const TopoDS_Shape& S) -{ - if (!myPdone) { - StdFail_NotDone::Raise(); - } - TopTools_ListIteratorOfListOfShape its(myRemoved); - for (;its.More(); its.Next()) { - if (S.IsSame(its.Value())) { - break; - } - } - if (!its.More()) { // S ne peut etre re-active -#ifdef DRAW - cout << "Invalid Shape" << endl; -#endif - } - else { - myRemoved.Remove(its); - } -} - - -//======================================================================= -//function : PerformResult -//purpose : -//======================================================================= - -void LocOpe_Builder::PerformResult() -{ - if (!myPerfdone) { - StdFail_NotDone::Raise(); - } - - - InvalidateParts(); - - TopTools_MapOfShape DummyMap; - Standard_Boolean OK = Standard_True; - TopAbs_State St1; - - if (!myShape.IsSame(myTool)) { - St1 = TopAbs_OUT; - TopAbs_State St2 = (myFuse) ? TopAbs_OUT : TopAbs_IN; - - if (St2 != TopAbs_OUT) myResult = myAlgo.Merge(St1, St2); - else myResult = myAlgo.Merge(St2, St1); - -#ifdef DRAW - DBRep::Set("res1", myResult); -#endif - if (!myResult.IsNull()) - myResult = BRepAlgo_Tool::Deboucle3D(myResult, DummyMap); -#ifdef DRAW - DBRep::Set("res2", myResult); -#endif - - if (myResult.IsNull()) OK = Standard_False; - - if (OK) { - if (!BRepAlgo::IsTopologicallyValid(myResult)) { - OK = Standard_False; -#ifdef DRAW - cout <<"LocOpe_Builder::PerformResult: Shape non valide, on intersecte tout."<< endl; -#endif - } - } -/* - if (!OK) { - myShapeMap.Clear(); - myAlgo.Init(); - TopExp_Explorer anExp(myShape, TopAbs_FACE); - for(; anExp.More(); anExp.Next()) { - myShapeMap.Add(anExp.Current()); - } - if (St2 != TopAbs_OUT) { - myAlgo.Load(myShape, myTool); - myAlgo.Intersect(); - InvalidateParts(); - myResult = myAlgo.Merge(St1, St2); - } - else { - myAlgo.Load(myTool, myShape); - myAlgo.Intersect(); - InvalidateParts(); - myResult = myAlgo.Merge(St2, St1); - } -#ifdef DRAW - DBRep::Set("res3", myResult); -#endif - if (!myResult.IsNull()) myResult = BRepAlgo_Tool::Deboucle3D(myResult, DummyMap); -#ifdef DRAW - DBRep::Set("res4", myResult); -#endif - } -*/ - } - else { - St1 = (myFuse) ? TopAbs_OUT : TopAbs_IN; - myResult = myAlgo.Merge(St1); // debouclage -#ifdef DRAW - DBRep::Set("res5", myResult); -#endif - if (!myResult.IsNull()) myResult = BRepAlgo_Tool::Deboucle3D(myResult, DummyMap); -#ifdef DRAW - DBRep::Set("res6", myResult); -#endif - } - - -#ifdef DRAW - DBRep::Set("myRes", myResult); -#endif - - - myEdges.Clear(); - myTgtEdges.Clear(); - TopExp_Explorer ex, ex1; - - if (myResult.IsNull() || !OK) { - myDone = Standard_False; - } - else { - - TopTools_ListIteratorOfListOfShape is(myAlgo.GetSectionEdgeSet()); - while (is.More()) { - for (ex.Init(is.Value(), TopAbs_EDGE); ex.More(); ex.Next()) { - const TopoDS_Edge& E = TopoDS::Edge(ex.Current()); - ex1.Init(myResult, TopAbs_EDGE); - for(; ex1.More(); ex1.Next()) { - if(E.IsSame(ex1.Current())) break; - } - if(ex1.More()) { - myEdges.Append(E); - } - } - is.Next(); - } - - TopTools_IndexedDataMapOfShapeListOfShape ma; - TopTools_ListIteratorOfListOfShape its3; - - TopExp::MapShapesAndAncestors(myResult, TopAbs_EDGE, TopAbs_FACE, ma); - its3.Initialize(myEdges); - for(; its3.More(); its3.Next()) { - const TopoDS_Edge& edg = TopoDS::Edge(its3.Value()); - const TopTools_ListOfShape& L0 = ma.FindFromKey(its3.Value()); - const TopoDS_Face& F1 = TopoDS::Face(L0.First()); - const TopoDS_Face& F2 = TopoDS::Face(L0.Last()); - if(!F1.IsSame(F2)) { - if(LocOpe::TgtFaces(edg, F1, F2)) { - myTgtEdges.Append(its3.Value()); - } - } - } - myDone = Standard_True; - } - - if (!myInvDone) { - myDone = Standard_False; - } - -} - - - -//======================================================================= -//function : InvalidateParts -//purpose : -//======================================================================= - -void LocOpe_Builder::InvalidateParts () -{ - - myInvDone = Standard_True; - const TopTools_ListOfShape& L = myAlgo.GetSectionEdgeSet(); - TopTools_ListOfShape *pL = (TopTools_ListOfShape*)&L; - - TopTools_ListIteratorOfListOfShape its; - -#ifdef DRAW - char namep[12]; - Standard_Integer ii = 0; - for (its.Initialize(L); its.More(); its.Next()) { - ii++; - sprintf(namep,"CO_%d",ii); - DBRep::Set(namep, its.Value()); - } - - ii = 0; - for (its.Initialize(myParts);its.More(); its.Next()) { - ii++; - sprintf(namep,"thePart_%d",ii); - DBRep::Set(namep,its.Value()); - } -#endif - - - if (myRemoved.IsEmpty() && myParts.IsEmpty()) { - return; - } - - Standard_Integer NbFaces = myShapeMap.Extent(); - - TopExp_Explorer exp, exp1; - - its.Initialize(*pL); - while (its.More()) { - TopoDS_Compound C = TopoDS::Compound(its.Value()); - Standard_Boolean Finish = Standard_False; - - for (exp.Init(C,TopAbs_VERTEX); !Finish && exp.More(); exp.Next()) { - gp_Pnt P1 = BRep_Tool::Pnt(TopoDS::Vertex(exp.Current())); - TopTools_ListIteratorOfListOfShape its2(myRemoved); - - for (; !Finish && its2.More(); its2.Next()) { - for (exp1.Init(its2.Value(),TopAbs_VERTEX); exp1.More(); exp1.Next()) { - gp_Pnt P2 = BRep_Tool::Pnt(TopoDS::Vertex(exp1.Current())); - if (Egal(P1, P2)) { - // le compound est a enlever. - Finish = Standard_True; - break; - } - } - } - } - - Standard_Boolean ToSuppress = Standard_True; - - for (exp.Init(C,TopAbs_VERTEX); ToSuppress && exp.More(); exp.Next()) { - gp_Pnt P1 = BRep_Tool::Pnt(TopoDS::Vertex(exp.Current())); -// its2 iterateur sur myRemoved = morceaux outils enleves -// its3 iteratuer sur myParts = tous les morceaux outil - TopTools_ListIteratorOfListOfShape its3(myParts); - - for (;ToSuppress && its3.More(); its3.Next()) { - - Standard_Integer myKeep = Standard_True; - TopTools_ListIteratorOfListOfShape its2(myRemoved); - for (; its2.More(); its2.Next()) { - if (its3.Value() == its2.Value()) myKeep = Standard_False; - } - if (!myKeep) continue; - - for (exp1.Init(its3.Value(),TopAbs_VERTEX); exp1.More(); exp1.Next()) { - gp_Pnt P2 = BRep_Tool::Pnt(TopoDS::Vertex(exp1.Current())); - if (Egal(P1, P2)) { - // le compound est a garder. - ToSuppress = Standard_False; - break; - } - } - } - } - - if (Finish || ToSuppress) { - myAlgo.SuppressEdgeSet(); - pL->Remove(its); - RemoveFaces(C, myAlgo.DSFiller(), myShapeMap); - } - -#ifdef DRAW - if (!Finish && ToSuppress) { - cout << "LocOpe_Builder::InvalidateParts : suppress intersection line" << endl; - } -#endif - - if (Finish && !ToSuppress) { -#ifdef DRAW - cout << "LocOpe_Builder::InvalidateParts : intersection line conflict" << endl; -#endif - myInvDone = Standard_False; - } - - if (Finish || ToSuppress) continue; - its.Next(); - } - - if(NbFaces > myShapeMap.Extent()) { - - TopAbs_State St2 = (myFuse) ? TopAbs_OUT : TopAbs_IN; - BRep_Builder B; - - TopoDS_Compound aCoShape, aCoTool; - B.MakeCompound(aCoShape); - B.MakeCompound(aCoTool); - - TopTools_MapIteratorOfMapOfShape anIt1(myShapeMap), anIt2(myToolMap); - - for(; anIt1.More(); anIt1.Next()) { - B.Add(aCoShape, anIt1.Key()); - } - - for(; anIt2.More(); anIt2.Next()) { - B.Add(aCoTool, anIt2.Key()); - } - -#ifdef DRAW - DBRep::Set("aCoShape", aCoShape); -#endif - myAlgo.Init(); - if (St2 != TopAbs_OUT) { - myAlgo.Load(myShape, myTool); - } - else { - myAlgo.Load(myTool, myShape); - } - - if (St2 != TopAbs_OUT) myAlgo.Intersect(aCoShape, aCoTool); - else myAlgo.Intersect(aCoTool, aCoShape); - - myAlgo.ToCompleteIntersection(); - - } -} - - diff --git a/src/LocOpe/LocOpe_Builder.lxx b/src/LocOpe/LocOpe_Builder.lxx deleted file mode 100755 index d6f9b4b664..0000000000 --- a/src/LocOpe/LocOpe_Builder.lxx +++ /dev/null @@ -1,115 +0,0 @@ -// Created on: 1995-05-10 -// Created by: Jacques GOUSSARD -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#include - - -//======================================================================= -//function : IsDone -//purpose : -//======================================================================= - -inline Standard_Boolean LocOpe_Builder::IsDone () const -{ - return myDone; -} - - -//======================================================================= -//function : IsInvDone -//purpose : -//======================================================================= - -inline Standard_Boolean LocOpe_Builder::IsInvDone () const -{ - return myInvDone; -} - - -//======================================================================= -//function : OriginalShape -//purpose : -//======================================================================= - -inline const TopoDS_Shape& LocOpe_Builder::OriginalShape () const -{ - return myShape; -} - - -//======================================================================= -//function : Tool -//purpose : -//======================================================================= - -inline const TopoDS_Shape& LocOpe_Builder::Tool () const -{ - return myTool; -} - - - -//======================================================================= -//function : ResultingShape -//purpose : -//======================================================================= - -inline const TopoDS_Shape& LocOpe_Builder::ResultingShape () const -{ - if (!myDone) {StdFail_NotDone::Raise();} - return myResult; -} - - -//======================================================================= -//function : Builder -//purpose : -//======================================================================= - -inline const Handle(BOP_HistoryCollector)& LocOpe_Builder::History() const -{ - return myAlgo.History(); -} - - -//======================================================================= -//function : Edges -//purpose : -//======================================================================= - -inline const TopTools_ListOfShape& LocOpe_Builder::Edges() const -{ - return myEdges; -} - - -//======================================================================= -//function : TgtEdges -//purpose : -//======================================================================= - -inline const TopTools_ListOfShape& LocOpe_Builder::TgtEdges() const -{ - return myTgtEdges; -} - - - diff --git a/src/QANewBRepNaming/QANewBRepNaming_ImportShape.cxx b/src/QANewBRepNaming/QANewBRepNaming_ImportShape.cxx index 9be4ee70ef..46933f95b1 100755 --- a/src/QANewBRepNaming/QANewBRepNaming_ImportShape.cxx +++ b/src/QANewBRepNaming/QANewBRepNaming_ImportShape.cxx @@ -250,27 +250,27 @@ void QANewBRepNaming_ImportShape::LoadC0Edges(const TopoDS_Shape& S, const TopTools_ListOfShape& aList1 = edgeNaborFaces.Find(anEdge1); TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itr(edgeNaborFaces); for (; itr.More(); itr.Next()) { - TopoDS_Shape anEdge2 = itr.Key(); - if (anEdge1.IsSame(anEdge2)) continue; - const TopTools_ListOfShape& aList2 = itr.Value(); - // compare lists of the neighbour faces of edge1 and edge2 - if (aList1.Extent() == aList2.Extent()) { - Standard_Integer aMatches = 0; - for(TopTools_ListIteratorOfListOfShape aLIter1(aList1);aLIter1.More();aLIter1.Next()) - for(TopTools_ListIteratorOfListOfShape aLIter2(aList2);aLIter2.More();aLIter2.Next()) - if (aLIter1.Value().IsSame(aLIter2.Value())) aMatches++; - if (aMatches == aList1.Extent()) { - aC0=Standard_True; - TNaming_Builder bC0Edge(Tagger->NewChild()); - bC0Edge.Generated(anEdge2); + TopoDS_Shape anEdge2 = itr.Key(); + if (anEdge1.IsSame(anEdge2)) continue; + const TopTools_ListOfShape& aList2 = itr.Value(); + // compare lists of the neighbour faces of edge1 and edge2 + if (aList1.Extent() == aList2.Extent()) { + Standard_Integer aMatches = 0; + for(TopTools_ListIteratorOfListOfShape aLIter1(aList1);aLIter1.More();aLIter1.Next()) + for(TopTools_ListIteratorOfListOfShape aLIter2(aList2);aLIter2.More();aLIter2.Next()) + if (aLIter1.Value().IsSame(aLIter2.Value())) aMatches++; + if (aMatches == aList1.Extent()) { + aC0=Standard_True; + TNaming_Builder bC0Edge(Tagger->NewChild()); + bC0Edge.Generated(anEdge2); aEdgesToRemove.Append (anEdge2); - } - } + } + } } // remove items from the data map for(TopTools_ListIteratorOfListOfShape anIt(aEdgesToRemove); anIt.More(); anIt.Next()) edgeNaborFaces.UnBind(anIt.Value()); - } + } if (aC0) { TNaming_Builder bC0Edge(Tagger->NewChild()); bC0Edge.Generated(anEdge1); diff --git a/src/QANewModTopOpe/QANewModTopOpe.cdl b/src/QANewModTopOpe/QANewModTopOpe.cdl index d07289d9e9..11fb927b82 100755 --- a/src/QANewModTopOpe/QANewModTopOpe.cdl +++ b/src/QANewModTopOpe/QANewModTopOpe.cdl @@ -29,7 +29,8 @@ uses TopAbs, BRepTools, gp, - BOPTools + BOPAlgo, + BOPDS is diff --git a/src/QANewModTopOpe/QANewModTopOpe_Glue.cxx b/src/QANewModTopOpe/QANewModTopOpe_Glue.cxx index bf0ea2dd88..5d30478850 100755 --- a/src/QANewModTopOpe/QANewModTopOpe_Glue.cxx +++ b/src/QANewModTopOpe/QANewModTopOpe_Glue.cxx @@ -97,7 +97,7 @@ QANewModTopOpe_Glue::QANewModTopOpe_Glue(const TopoDS_Shape& theS1, const TopoDS_Shape& theS2, const Standard_Boolean theAllowCutting, const Standard_Boolean thePerformNow) -: BRepAlgoAPI_BooleanOperation (theS1,theS2, BOP_FUSE), +: BRepAlgoAPI_BooleanOperation (theS1,theS2, BOPAlgo_FUSE), myAllowCutting (theAllowCutting), myCompleted (Standard_False) { diff --git a/src/QANewModTopOpe/QANewModTopOpe_Glue_SDFaces.cxx b/src/QANewModTopOpe/QANewModTopOpe_Glue_SDFaces.cxx index 9c477416be..913eb665d7 100755 --- a/src/QANewModTopOpe/QANewModTopOpe_Glue_SDFaces.cxx +++ b/src/QANewModTopOpe/QANewModTopOpe_Glue_SDFaces.cxx @@ -429,14 +429,14 @@ QANewModTopOpe_Glue::PerformSDFaces() if (!isAnalitic(aFirstFace)) continue; - if (QANewModTopOpe_Tools::HasSameDomain(myDSFiller, aFirstFace)) { + if (QANewModTopOpe_Tools::HasSameDomain(myBuilder, aFirstFace)) { if(!aHasSDF) aHasSDF = Standard_True; TopTools_ListOfShape aLOfSDFace; TopTools_ListIteratorOfListOfShape anIter; - QANewModTopOpe_Tools::SameDomain(myDSFiller, aFirstFace, aLOfSDFace); + QANewModTopOpe_Tools::SameDomain(myBuilder, aFirstFace, aLOfSDFace); anIter.Initialize(aLOfSDFace); for(; anIter.More(); anIter.Next()) { @@ -583,7 +583,7 @@ QANewModTopOpe_Glue::PerformSDFaces() } } } - + // remove items from the data map for(TopTools_ListIteratorOfListOfShape anIt(aShapesToRemove); anIt.More(); anIt.Next()) myMapModif.UnBind(anIt.Value()); diff --git a/src/QANewModTopOpe/QANewModTopOpe_Glue_shell.cxx b/src/QANewModTopOpe/QANewModTopOpe_Glue_shell.cxx index 534deae85a..54bcb61610 100755 --- a/src/QANewModTopOpe/QANewModTopOpe_Glue_shell.cxx +++ b/src/QANewModTopOpe/QANewModTopOpe_Glue_shell.cxx @@ -208,7 +208,7 @@ SplitEdgeComplete (const TopoDS_Edge& theEdge, static void SplitEdge (const TopoDS_Edge &theEdge, - const BOPTools_PDSFiller &thePDSFiller, + const BOPAlgo_PPaveFiller &thePDSFiller, const TopTools_MapOfShape &theEdgesValid, const Standard_Boolean useMap, TopTools_ListOfShape &theListSplits) @@ -446,13 +446,13 @@ QANewModTopOpe_Glue::PerformShell() hasSolid2 = Standard_True; if (hasSolid1 && hasSolid2) - myOperation = BOP_FUSE; + myOperation = BOPAlgo_FUSE; else if (hasSolid1) - myOperation = BOP_CUT21; + myOperation = BOPAlgo_CUT21; else if (hasSolid2) - myOperation = BOP_CUT; + myOperation = BOPAlgo_CUT; else - myOperation = BOP_SECTION; + myOperation = BOPAlgo_SECTION; BRepAlgoAPI_BooleanOperation::Build(); if (!BuilderCanWork()) @@ -885,7 +885,7 @@ QANewModTopOpe_Glue::PerformShell() static TopoDS_Face SplitFaceBoundary (const TopoDS_Face& theFace, BRepTools_Substitution& theSubst, - const BOPTools_PDSFiller &thePDSFiller, + const BOPAlgo_PPaveFiller &thePDSFiller, const TopTools_MapOfShape& theEdgesValid, const Standard_Boolean useMap, TopTools_DataMapOfShapeListOfShape& theMapModif) diff --git a/src/QANewModTopOpe/QANewModTopOpe_Intersection.cxx b/src/QANewModTopOpe/QANewModTopOpe_Intersection.cxx index 5637ca9980..d62f67c26c 100755 --- a/src/QANewModTopOpe/QANewModTopOpe_Intersection.cxx +++ b/src/QANewModTopOpe/QANewModTopOpe_Intersection.cxx @@ -32,12 +32,12 @@ #include #include #include -#include -#include #include #include #include +#include + static Standard_Boolean NoFaces(const TopoDS_Shape& S1, const TopoDS_Shape& S2) { @@ -52,7 +52,7 @@ static Standard_Boolean NoFaces(const TopoDS_Shape& S1, const TopoDS_Shape& S2) QANewModTopOpe_Intersection::QANewModTopOpe_Intersection( const TopoDS_Shape& theObject1, const TopoDS_Shape& theObject2 ) -: BRepAlgoAPI_BooleanOperation( theObject1, theObject2, BOP_SECTION) +: BRepAlgoAPI_BooleanOperation( theObject1, theObject2, BOPAlgo_SECTION) { myMapGener.Clear(); @@ -137,9 +137,8 @@ QANewModTopOpe_Intersection::QANewModTopOpe_Intersection( const TopoDS_Shape& th // if (bIsNewFiller) { //Prepare the DS - BOPTools_SSIntersectionAttribute aSectionAttribute(Standard_True, - Standard_False, Standard_False); - myDSFiller->Perform(aSectionAttribute); + myDSFiller->Perform(); + } Build(); diff --git a/src/QANewModTopOpe/QANewModTopOpe_Tools.cdl b/src/QANewModTopOpe/QANewModTopOpe_Tools.cdl index 019d17bca1..277e41087b 100755 --- a/src/QANewModTopOpe/QANewModTopOpe_Tools.cdl +++ b/src/QANewModTopOpe/QANewModTopOpe_Tools.cdl @@ -24,28 +24,29 @@ uses Edge from TopoDS, Shape from TopoDS, State from TopAbs, - PDSFiller from BOPTools, + PPaveFiller from BOPAlgo, + PBOP from BOPAlgo, ListOfShape from TopTools, IndexedDataMapOfShapeListOfShape from TopTools is - NbPoints(myclass; theDSFiller: PDSFiller from BOPTools) + NbPoints(myclass; theDSFiller: PPaveFiller from BOPAlgo) returns Integer from Standard; - NewVertex(myclass; theDSFiller: PDSFiller from BOPTools; + NewVertex(myclass; theDSFiller: PPaveFiller from BOPAlgo; theIndex : Integer from Standard) returns Shape from TopoDS; - HasSameDomain(myclass; theDSFiller: PDSFiller from BOPTools; + HasSameDomain(myclass; theBuilder: PBOP from BOPAlgo; theFace : Shape from TopoDS) returns Boolean from Standard; - SameDomain(myclass; theDSFiller: PDSFiller from BOPTools; + SameDomain(myclass; theBuilder: PBOP from BOPAlgo; theFace : Shape from TopoDS; theResultList: out ListOfShape from TopTools); - IsSplit(myclass; theDSFiller: PDSFiller from BOPTools; + IsSplit(myclass; theDSFiller: PPaveFiller from BOPAlgo; theEdge : Shape from TopoDS; theState : State from TopAbs) returns Boolean from Standard; @@ -53,7 +54,7 @@ is --- arguments of which was solids or compounds of solids. --- - Splits(myclass; theDSFiller: PDSFiller from BOPTools; + Splits(myclass; theDSFiller: PPaveFiller from BOPAlgo; theEdge : Shape from TopoDS; theState : State from TopAbs; theResultList: out ListOfShape from TopTools); @@ -65,13 +66,13 @@ is theSplits: out ListOfShape from TopTools) returns Boolean from Standard; - EdgeCurveAncestors(myclass; theDSFiller: PDSFiller from BOPTools; + EdgeCurveAncestors(myclass; theDSFiller: PPaveFiller from BOPAlgo; theEdge : Shape from TopoDS; theFace1 : out Shape from TopoDS; theFace2 : out Shape from TopoDS) returns Boolean from Standard; - EdgeSectionAncestors(myclass; theDSFiller: PDSFiller from BOPTools; + EdgeSectionAncestors(myclass; theDSFiller: PPaveFiller from BOPAlgo; theEdge : Shape from TopoDS; LF1,LF2 : out ListOfShape from TopTools; LE1,LE2 : out ListOfShape from TopTools) diff --git a/src/QANewModTopOpe/QANewModTopOpe_Tools.cxx b/src/QANewModTopOpe/QANewModTopOpe_Tools.cxx index 417ca804cb..34b36e7786 100755 --- a/src/QANewModTopOpe/QANewModTopOpe_Tools.cxx +++ b/src/QANewModTopOpe/QANewModTopOpe_Tools.cxx @@ -17,44 +17,12 @@ #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include #include #include #include #include -#include -#include -#include #include #include @@ -75,64 +43,74 @@ #include #include +#include +#include +#include +#include +#include +#include +#include +#include + static Standard_Boolean CheckSameDomainFaceInside(const TopoDS_Face& theFace1, - const TopoDS_Face& theFace2); + const TopoDS_Face& theFace2); static Standard_Boolean AddShapeToHistoryMap(const TopoDS_Shape& theOldShape, - const TopoDS_Shape& theNewShape, - TopTools_IndexedDataMapOfShapeListOfShape& theHistoryMap); + const TopoDS_Shape& theNewShape, + TopTools_IndexedDataMapOfShapeListOfShape& theHistoryMap); static void FillEdgeHistoryMap(BRepAlgoAPI_BooleanOperation& theBOP, - TopTools_IndexedDataMapOfShapeListOfShape& theHistoryMap); + TopTools_IndexedDataMapOfShapeListOfShape& theHistoryMap); static void SortVertexOnEdge(const TopoDS_Edge& theEdge, - const TopTools_ListOfShape& theListOfVertex, - TopTools_ListOfShape& theListOfVertexSorted); + const TopTools_ListOfShape& theListOfVertex, + TopTools_ListOfShape& theListOfVertexSorted); + +static TopAbs_State GetEdgeState(const BOPDS_PDS& pDS, + const Handle(BOPDS_PaveBlock)& aPB); // ======================================================================================== // function: NbPoints // purpose: // ======================================================================================== -Standard_Integer QANewModTopOpe_Tools::NbPoints(const BOPTools_PDSFiller& theDSFiller) +Standard_Integer QANewModTopOpe_Tools::NbPoints(const BOPAlgo_PPaveFiller& theDSFiller) { - Standard_Integer i = 0, anbpoints = 0; - const BooleanOperations_ShapesDataStructure& aDS = theDSFiller->DS(); - BOPTools_InterferencePool* anIntrPool = (BOPTools_InterferencePool*)&theDSFiller->InterfPool(); - BOPTools_CArray1OfSSInterference& aFFs = anIntrPool->SSInterferences(); - Standard_Integer aNb=aFFs.Extent(); - - for (i = 1; i <= aNb; i++) { - BOPTools_SSInterference& aFFi = aFFs(i); - TColStd_ListOfInteger& anAloneVertices = aFFi.AloneVertices(); - anbpoints += anAloneVertices.Extent(); - } - BOPTools_CArray1OfESInterference& aEFs = anIntrPool->ESInterferences(); - aNb = aEFs.Extent(); - - for (i = 1; i <= aNb; i++) { - BOPTools_ESInterference& aESInterf = aEFs(i); - Standard_Integer anIndex = aESInterf.NewShape(); + Standard_Integer i, anbpoints, aNb; + // + const BOPDS_PDS& pDS = theDSFiller->PDS(); + anbpoints = 0; - if(anIndex == 0) - continue; + //FF + BOPDS_VectorOfInterfFF& aFFs=pDS->InterfFF(); + aNb=aFFs.Extent(); + for (i = 0; i < aNb; ++i) { + BOPDS_InterfFF& aFF=aFFs(i); + const BOPDS_VectorOfPoint& aVP=aFF.Points(); + anbpoints += aVP.Extent(); + } - if(aDS.GetShapeType(anIndex) == TopAbs_VERTEX) + //EF + BOPDS_VectorOfInterfEF& aEFs=pDS->InterfEF(); + aNb = aEFs.Extent(); + for (i = 0; i < aNb; ++i) { + BOPDS_InterfEF& aEF=aEFs(i); + IntTools_CommonPrt aCP = aEF.CommonPart(); + if(aCP.Type() == TopAbs_VERTEX) { anbpoints++; + } } - - BOPTools_CArray1OfEEInterference& aEEs = anIntrPool->EEInterferences(); + + //EE + BOPDS_VectorOfInterfEE& aEEs=pDS->InterfEE(); aNb = aEEs.Extent(); - - for (i = 1; i <= aNb; i++) { - BOPTools_EEInterference& aEEInterf = aEEs(i); - Standard_Integer anIndex = aEEInterf.NewShape(); - - if(anIndex == 0) - continue; - - if(aDS.GetShapeType(anIndex) == TopAbs_VERTEX) + for (i = 0; i < aNb; ++i) { + BOPDS_InterfEE& aEE=aEEs(i); + IntTools_CommonPrt aCP = aEE.CommonPart(); + if(aCP.Type() == TopAbs_VERTEX) { anbpoints++; + } } + return anbpoints; } @@ -140,273 +118,146 @@ Standard_Integer QANewModTopOpe_Tools::NbPoints(const BOPTools_PDSFiller& theDSF // function: NewVertex // purpose: // ======================================================================================== -TopoDS_Shape QANewModTopOpe_Tools::NewVertex(const BOPTools_PDSFiller& theDSFiller, - const Standard_Integer theIndex) +TopoDS_Shape QANewModTopOpe_Tools::NewVertex(const BOPAlgo_PPaveFiller& theDSFiller, + const Standard_Integer theIndex) { TopoDS_Shape aVertex; + Standard_Integer i, j, anbpoints, aNb, aNbP; + // + const BOPDS_PDS& pDS = theDSFiller->PDS(); + anbpoints = 0; - Standard_Integer i = 0, anbpoints = 0; - const BooleanOperations_ShapesDataStructure& aDS = theDSFiller->DS(); - BOPTools_InterferencePool* anIntrPool = (BOPTools_InterferencePool*)&theDSFiller->InterfPool(); - BOPTools_CArray1OfSSInterference& aFFs = anIntrPool->SSInterferences(); - Standard_Integer aNb=aFFs.Extent(); - - for (i = 1; i <= aNb; i++) { - BOPTools_SSInterference& aFFi = aFFs(i); - TColStd_ListOfInteger& anAloneVertices = aFFi.AloneVertices(); - TColStd_ListIteratorOfListOfInteger anIt(anAloneVertices); - - for(; anIt.More(); anIt.Next()) { + //FF + BOPDS_VectorOfInterfFF& aFFs=pDS->InterfFF(); + aNb=aFFs.Extent(); + for (i = 0; i < aNb; ++i) { + BOPDS_InterfFF& aFF=aFFs(i); + const BOPDS_VectorOfPoint& aVP=aFF.Points(); + aNbP = aVP.Extent(); + for(j = 0; j < aNbP; ++j) { anbpoints++; - - if(theIndex == anbpoints) { - return aDS.Shape(anIt.Value()); + // + if (theIndex == anbpoints) { + const BOPDS_Point& aNP = aVP(j); + return pDS->Shape(aNP.Index()); } } } - BOPTools_CArray1OfESInterference& aEFs = anIntrPool->ESInterferences(); - aNb = aEFs.Extent(); - - for (i = 1; i <= aNb; i++) { - BOPTools_ESInterference& aESInterf = aEFs(i); - Standard_Integer anIndex = aESInterf.NewShape(); - - if(anIndex == 0) - continue; - if(aDS.GetShapeType(anIndex) == TopAbs_VERTEX) { + //EF + BOPDS_VectorOfInterfEF& aEFs=pDS->InterfEF(); + aNb = aEFs.Extent(); + for (i = 0; i < aNb; ++i) { + BOPDS_InterfEF& aEF=aEFs(i); + IntTools_CommonPrt aCP = aEF.CommonPart(); + if(aCP.Type() == TopAbs_VERTEX) { anbpoints++; - - if(theIndex == anbpoints) { - return aDS.Shape(anIndex); + // + if (theIndex == anbpoints) { + return pDS->Shape(aEF.IndexNew()); } } } - - BOPTools_CArray1OfEEInterference& aEEs = anIntrPool->EEInterferences(); + + //EE + BOPDS_VectorOfInterfEE& aEEs=pDS->InterfEE(); aNb = aEEs.Extent(); - - for (i = 1; i <= aNb; i++) { - BOPTools_EEInterference& aEEInterf = aEEs(i); - Standard_Integer anIndex = aEEInterf.NewShape(); - - if(anIndex == 0) - continue; - - if(aDS.GetShapeType(anIndex) == TopAbs_VERTEX) { + for (i = 0; i < aNb; ++i) { + BOPDS_InterfEE& aEE=aEEs(i); + IntTools_CommonPrt aCP = aEE.CommonPart(); + if(aCP.Type() == TopAbs_VERTEX) { anbpoints++; - - if(theIndex == anbpoints) { - return aDS.Shape(anIndex); + // + if (theIndex == anbpoints) { + return pDS->Shape(aEE.IndexNew()); } } } + return aVertex; } + // ======================================================================================== -// function: HasSameDomain +// function: HasDomain // purpose: // ======================================================================================== -Standard_Boolean QANewModTopOpe_Tools::HasSameDomain(const BOPTools_PDSFiller& theDSFiller, - const TopoDS_Shape& theFace) +Standard_Boolean QANewModTopOpe_Tools::HasSameDomain(const BOPAlgo_PBOP& theBuilder, + const TopoDS_Shape& theFace) { - if(theFace.IsNull() || (theFace.ShapeType() != TopAbs_FACE)) - return Standard_False; - const BOPTools_PaveFiller& aPaveFiller = theDSFiller->PaveFiller(); - BOPTools_PCurveMaker aPCurveMaker(aPaveFiller); - aPCurveMaker.Do(); - - BOPTools_DEProcessor aDEProcessor(aPaveFiller); - aDEProcessor.Do(); - - const BooleanOperations_ShapesDataStructure& aDS = theDSFiller->DS(); - BOPTools_InterferencePool* pIntrPool = (BOPTools_InterferencePool*)&theDSFiller->InterfPool(); - BOPTools_CArray1OfSSInterference& aFFs = pIntrPool->SSInterferences(); + Standard_Integer bRet; + bRet = Standard_False; // - Standard_Boolean bFlag; - Standard_Integer i, aNb, nF1, nF2, iZone, aNbSps, iSenseFlag; - gp_Dir aDNF1, aDNF2; - - aNb=aFFs.Extent(); - - for (i = 1; i <= aNb; i++) { - bFlag=Standard_False; - - BOPTools_SSInterference& aFF=aFFs(i); - - nF1=aFF.Index1(); - nF2=aFF.Index2(); - const TopoDS_Face& aF1 = TopoDS::Face(aDS.Shape(nF1)); - const TopoDS_Face& aF2 = TopoDS::Face(aDS.Shape(nF2)); - - if(!theFace.IsSame(aF1) && !theFace.IsSame(aF2)) - continue; - - const BOPTools_ListOfPaveBlock& aLPB = aFF.PaveBlocks(); - aNbSps = aLPB.Extent(); - - if (!aNbSps) { - continue; - } - const BOPTools_PaveBlock& aPB = aLPB.First(); - const TopoDS_Edge& aSpE = TopoDS::Edge(aDS.Shape(aPB.Edge())); - - BOPTools_Tools3D::GetNormalToFaceOnEdge (aSpE, aF1, aDNF1); - BOPTools_Tools3D::GetNormalToFaceOnEdge (aSpE, aF2, aDNF2); - iSenseFlag=BOPTools_Tools3D::SenseFlag (aDNF1, aDNF2); - - if (iSenseFlag==1 || iSenseFlag==-1) { - // - // - TopoDS_Face aF1FWD=aF1; - aF1FWD.Orientation (TopAbs_FORWARD); - - BOP_WireEdgeSet aWES (aF1FWD); - BOP_SDFWESFiller aWESFiller(nF1, nF2, *theDSFiller); - aWESFiller.SetSenseFlag(iSenseFlag); - aWESFiller.SetOperation(BOP_COMMON); - aWESFiller.Do(aWES); - - BOP_FaceBuilder aFB; - aFB.Do(aWES); - const TopTools_ListOfShape& aLF=aFB.NewFaces(); - - iZone = 0; - TopTools_ListIteratorOfListOfShape anIt(aLF); - - for (; anIt.More(); anIt.Next()) { - const TopoDS_Shape& aFR=anIt.Value(); - - if (aFR.ShapeType()==TopAbs_FACE) { - const TopoDS_Face& aFaceResult=TopoDS::Face(aFR); - // - Standard_Boolean bIsValidIn2D, bNegativeFlag; - bIsValidIn2D=BOPTools_Tools3D::IsValidArea (aFaceResult, bNegativeFlag); - - if (bIsValidIn2D) { - - if(CheckSameDomainFaceInside(aFaceResult, aF2)) { - iZone = 1; - break; - } - } - } - } + if(theFace.IsNull() || (theFace.ShapeType() != TopAbs_FACE)) + return bRet; - if (iZone) { - bFlag = Standard_True; - aFF.SetStatesMap(aWESFiller.StatesMap()); - } - } - aFF.SetTangentFacesFlag(bFlag); - aFF.SetSenseFlag (iSenseFlag); + BOPCol_ListIteratorOfListOfShape aIt; + const BOPCol_DataMapOfShapeListOfShape& aImages = theBuilder->Images(); + if (!aImages.IsBound(theFace)) { + return bRet; + } + const BOPCol_ListOfShape& aLF=aImages.Find(theFace); + + if (aLF.Extent() == 0) { + return bRet; + } + const BOPCol_DataMapOfShapeShape& aShapesSD = theBuilder->ShapesSD(); - if(bFlag) { - return Standard_True; + aIt.Initialize(aLF); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aFsp = aIt.Value(); + if (aShapesSD.IsBound(aFsp)) { + bRet = Standard_True; + break; } } - return Standard_False; + + return bRet; } // ======================================================================================== // function: SameDomain // purpose: // ======================================================================================== -void QANewModTopOpe_Tools::SameDomain(const BOPTools_PDSFiller& theDSFiller, - const TopoDS_Shape& theFace, - TopTools_ListOfShape& theResultList) +void QANewModTopOpe_Tools::SameDomain(const BOPAlgo_PBOP& theBuilder, + const TopoDS_Shape& theFace, + TopTools_ListOfShape& theResultList) { theResultList.Clear(); if(theFace.IsNull() || (theFace.ShapeType() != TopAbs_FACE)) return; - const BOPTools_PaveFiller& aPaveFiller = theDSFiller->PaveFiller(); - BOPTools_PCurveMaker aPCurveMaker(aPaveFiller); - aPCurveMaker.Do(); - - BOPTools_DEProcessor aDEProcessor(aPaveFiller); - aDEProcessor.Do(); - - const BooleanOperations_ShapesDataStructure& aDS = theDSFiller->DS(); - BOPTools_InterferencePool* pIntrPool = (BOPTools_InterferencePool*)&theDSFiller->InterfPool(); - BOPTools_CArray1OfSSInterference& aFFs = pIntrPool->SSInterferences(); - // - Standard_Integer i, aNb, nF1, nF2, aNbSps, iSenseFlag; - gp_Dir aDNF1, aDNF2; - - aNb=aFFs.Extent(); - - for (i = 1; i <= aNb; i++) { - BOPTools_SSInterference& aFF=aFFs(i); - - nF1=aFF.Index1(); - nF2=aFF.Index2(); - const TopoDS_Face& aF1 = TopoDS::Face(aDS.Shape(nF1)); - const TopoDS_Face& aF2 = TopoDS::Face(aDS.Shape(nF2)); - - if(!theFace.IsSame(aF1) && !theFace.IsSame(aF2)) - continue; - if(aFF.IsTangentFaces()) { - if(theFace.IsSame(aF1)) - theResultList.Append(aF2); - else - theResultList.Append(aF1); - continue; - } - - const BOPTools_ListOfPaveBlock& aLPB = aFF.PaveBlocks(); - aNbSps = aLPB.Extent(); - - if (!aNbSps) { - continue; - } - const BOPTools_PaveBlock& aPB = aLPB.First(); - const TopoDS_Edge& aSpE = TopoDS::Edge(aDS.Shape(aPB.Edge())); - - BOPTools_Tools3D::GetNormalToFaceOnEdge (aSpE, aF1, aDNF1); - BOPTools_Tools3D::GetNormalToFaceOnEdge (aSpE, aF2, aDNF2); - iSenseFlag=BOPTools_Tools3D::SenseFlag (aDNF1, aDNF2); - - if (iSenseFlag==1 || iSenseFlag==-1) { - // - // - TopoDS_Face aF1FWD=aF1; - aF1FWD.Orientation (TopAbs_FORWARD); - - BOP_WireEdgeSet aWES (aF1FWD); - BOP_SDFWESFiller aWESFiller(nF1, nF2, *theDSFiller); - aWESFiller.SetSenseFlag(iSenseFlag); - aWESFiller.SetOperation(BOP_COMMON); - aWESFiller.Do(aWES); - - BOP_FaceBuilder aFB; - aFB.Do(aWES); - const TopTools_ListOfShape& aLF=aFB.NewFaces(); - - TopTools_ListIteratorOfListOfShape anIt(aLF); - - for (; anIt.More(); anIt.Next()) { - const TopoDS_Shape& aFR=anIt.Value(); - - if (aFR.ShapeType()==TopAbs_FACE) { - const TopoDS_Face& aFaceResult=TopoDS::Face(aFR); - // - Standard_Boolean bIsValidIn2D, bNegativeFlag; - bIsValidIn2D=BOPTools_Tools3D::IsValidArea (aFaceResult, bNegativeFlag); - - if (bIsValidIn2D) { - - if(CheckSameDomainFaceInside(aFaceResult, aF2)) { - if(theFace.IsSame(aF1)) - theResultList.Append(aF2); - else - theResultList.Append(aF1); - break; - } - } - } + BOPCol_ListIteratorOfListOfShape aIt; + const BOPCol_ListOfShape& aLF=theBuilder->Splits().Find(theFace); + + if (aLF.Extent() == 0) { + return; + } + const BOPCol_DataMapOfShapeShape& aShapesSD = theBuilder->ShapesSD(); + const BOPCol_DataMapOfShapeShape& aOrigins = theBuilder->Origins(); + + aIt.Initialize(aLF); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aFSp = aIt.Value(); + if (aShapesSD.IsBound(aFSp)) { + const TopoDS_Shape& aFSD = aShapesSD.Find(aFSp); + const TopoDS_Shape& aFOr = aOrigins.Find(aFSD); + if (theFace.IsEqual(aFOr)) { + BOPCol_DataMapIteratorOfDataMapOfShapeShape aItSD; + aItSD.Initialize(aShapesSD); + for (; aItSD.More(); aItSD.Next()) { + const TopoDS_Shape& aS = aItSD.Value(); + if (aFSD.IsEqual(aS)) { + const TopoDS_Shape& aSK = aItSD.Key(); + const TopoDS_Shape& aSKOr = aOrigins.Find(aSK); + if (!aSKOr.IsEqual(theFace)) { + theResultList.Append(aSKOr); + } + } + } + } else { + theResultList.Append(aFOr); } } } @@ -416,45 +267,35 @@ void QANewModTopOpe_Tools::SameDomain(const BOPTools_PDSFiller& theDSFiller, // function: IsSplit // purpose: // ======================================================================================== -Standard_Boolean QANewModTopOpe_Tools::IsSplit(const BOPTools_PDSFiller& theDSFiller, - const TopoDS_Shape& theEdge, - const TopAbs_State theState) +Standard_Boolean QANewModTopOpe_Tools::IsSplit(const BOPAlgo_PPaveFiller& theDSFiller, + const TopoDS_Shape& theEdge, + const TopAbs_State theState) { if(theEdge.IsNull() || (theEdge.ShapeType() != TopAbs_EDGE)) return Standard_False; - const BOPTools_SplitShapesPool& aSplitShapesPool = theDSFiller->SplitShapesPool(); - const BooleanOperations_ShapesDataStructure& aDS = theDSFiller->DS(); - - const BooleanOperations_IndexedDataMapOfShapeInteger& aMap1 = aDS.ShapeIndexMap(1); - const BooleanOperations_IndexedDataMapOfShapeInteger& aMap2 = aDS.ShapeIndexMap(2); - Standard_Integer anIndex = 0; - - if(aMap1.Contains(theEdge)) - anIndex = aDS.ShapeIndex(theEdge, 1); - else if(aMap2.Contains(theEdge)) - anIndex = aDS.ShapeIndex(theEdge, 2); - else - return Standard_False; - const BOPTools_ListOfPaveBlock& aSplits = aSplitShapesPool(aDS.RefEdge(anIndex)); - BOPTools_ListIteratorOfListOfPaveBlock aPBIt(aSplits); + Standard_Integer index, nSp; + // + const BOPDS_PDS& pDS = theDSFiller->PDS(); + index = pDS->Index(theEdge); + if (index == -1) { + return Standard_False; + } + const BOPDS_ListOfPaveBlock& aLPB = pDS->PaveBlocks(index); + BOPDS_ListIteratorOfListOfPaveBlock aPBIt; + aPBIt.Initialize(aLPB); for (; aPBIt.More(); aPBIt.Next()) { - BOPTools_PaveBlock& aPB = aPBIt.Value(); - Standard_Integer nSp = aPB.Edge(); - TopAbs_State aSplitState = BOPTools_StateFiller::ConvertState(aDS.GetState(nSp)); + const Handle(BOPDS_PaveBlock)& aPB = aPBIt.Value(); + nSp = aPB->Edge(); + + TopAbs_State aSplitState = GetEdgeState(pDS, aPB); - if(aSplitState == theState) + if(aSplitState == theState) { return Standard_True; + } } -// if(theState == TopAbs_ON) { -// const BOPTools_CommonBlockPool& aCommonBlockPool= theDSFiller->CommonBlockPool(); -// const BOPTools_ListOfCommonBlock& aCBlocks = aCommonBlockPool(aDS.RefEdge(anIndex)); - -// if(!aCBlocks.IsEmpty()) -// return Standard_True; -// } return Standard_False; } @@ -462,63 +303,38 @@ Standard_Boolean QANewModTopOpe_Tools::IsSplit(const BOPTools_PDSFiller& theDSFi // function: Splits // purpose: // ======================================================================================== -void QANewModTopOpe_Tools::Splits(const BOPTools_PDSFiller& theDSFiller, - const TopoDS_Shape& theEdge, - const TopAbs_State theState, - TopTools_ListOfShape& theResultList) +void QANewModTopOpe_Tools::Splits(const BOPAlgo_PPaveFiller& theDSFiller, + const TopoDS_Shape& theEdge, + const TopAbs_State theState, + TopTools_ListOfShape& theResultList) { theResultList.Clear(); if(theEdge.IsNull() || (theEdge.ShapeType() != TopAbs_EDGE)) return; - const BOPTools_SplitShapesPool& aSplitShapesPool = theDSFiller->SplitShapesPool(); - const BooleanOperations_ShapesDataStructure& aDS = theDSFiller->DS(); - - const BooleanOperations_IndexedDataMapOfShapeInteger& aMap1 = aDS.ShapeIndexMap(1); - const BooleanOperations_IndexedDataMapOfShapeInteger& aMap2 = aDS.ShapeIndexMap(2); - Standard_Integer anIndex = 0; - - if(aMap1.Contains(theEdge)) - anIndex = aDS.ShapeIndex(theEdge, 1); - else if(aMap2.Contains(theEdge)) - anIndex = aDS.ShapeIndex(theEdge, 2); - else - return; - const BOPTools_ListOfPaveBlock& aSplits = aSplitShapesPool(aDS.RefEdge(anIndex)); - BOPTools_ListIteratorOfListOfPaveBlock aPBIt(aSplits); -// TopTools_MapOfShape aMapE; + Standard_Integer index, nSp; + // + const BOPDS_PDS& pDS = theDSFiller->PDS(); + index = pDS->Index(theEdge); + if (index == -1) { + return; + } + const BOPDS_ListOfPaveBlock& aLPB = pDS->PaveBlocks(index); + BOPDS_ListIteratorOfListOfPaveBlock aPBIt; + aPBIt.Initialize(aLPB); for (; aPBIt.More(); aPBIt.Next()) { - BOPTools_PaveBlock& aPB = aPBIt.Value(); - Standard_Integer nSp = aPB.Edge(); - TopAbs_State aSplitState = BOPTools_StateFiller::ConvertState(aDS.GetState(nSp)); + const Handle(BOPDS_PaveBlock)& aPB = aPBIt.Value(); + nSp = aPB->Edge(); + + TopAbs_State aSplitState = GetEdgeState(pDS, aPB); if(aSplitState == theState) { - TopoDS_Shape aSplit = aDS.Shape(nSp); + TopoDS_Shape aSplit = pDS->Shape(nSp); theResultList.Append(aSplit); -// aMapE.Add(aSplit); } } - -// if(theState == TopAbs_ON) { -// const BOPTools_CommonBlockPool& aCommonBlockPool= theDSFiller->CommonBlockPool(); -// const BOPTools_ListOfCommonBlock& aCBlocks = aCommonBlockPool(aDS.RefEdge(anIndex)); -// BOPTools_ListIteratorOfListOfCommonBlock anIt(aCBlocks); - -// for(; anIt.More(); anIt.Next()) { -// const BOPTools_CommonBlock& aCB = anIt.Value(); -// BOPTools_CommonBlock* pCB=(BOPTools_CommonBlock*) &aCB; -// BOPTools_PaveBlock& aPB = pCB->PaveBlock1(anIndex); -// Standard_Integer nSp = aPB.Edge(); -// TopoDS_Shape aSplit = aDS.Shape(nSp); - -// if(aMapE.Contains(aSplit)) -// continue; -// theResultList.Append(aSplit); -// aMapE.Add(aSplit); -// } -// } } // ======================================================================================== @@ -526,7 +342,7 @@ void QANewModTopOpe_Tools::Splits(const BOPTools_PDSFiller& theDSFiller, // purpose: // ======================================================================================== Standard_Boolean QANewModTopOpe_Tools::SplitE(const TopoDS_Edge& theEdge, - TopTools_ListOfShape& theSplits) + TopTools_ListOfShape& theSplits) { // prequesitory : is a valid edge. TopAbs_Orientation oEanc = theEdge.Orientation(); @@ -582,45 +398,44 @@ Standard_Boolean QANewModTopOpe_Tools::SplitE(const TopoDS_Edge& theEdge, // function: EdgeCurveAncestors // purpose: // ======================================================================================== - Standard_Boolean QANewModTopOpe_Tools::EdgeCurveAncestors(const BOPTools_PDSFiller& theDSFiller, - const TopoDS_Shape& theEdge, - TopoDS_Shape& theFace1, - TopoDS_Shape& theFace2) + Standard_Boolean QANewModTopOpe_Tools::EdgeCurveAncestors(const BOPAlgo_PPaveFiller& theDSFiller, + const TopoDS_Shape& theEdge, + TopoDS_Shape& theFace1, + TopoDS_Shape& theFace2) { theFace1.Nullify(); theFace2.Nullify(); + // + Standard_Integer i, j, aNb, aNbC, nE, nF1, nF2; + BOPDS_ListIteratorOfListOfPaveBlock aIt; - const BooleanOperations_ShapesDataStructure& aDS = theDSFiller->DS(); - BOPTools_InterferencePool* anIntrPool = (BOPTools_InterferencePool*)&theDSFiller->InterfPool(); - BOPTools_CArray1OfSSInterference& aFFs = anIntrPool->SSInterferences(); - Standard_Integer aNb = aFFs.Extent(); - Standard_Integer i = 0, j = 0; - - for (i = 1; i <= aNb; i++) { - BOPTools_SSInterference& aFFi = aFFs(i); - BOPTools_SequenceOfCurves& aBCurves = aFFi.Curves(); - Standard_Integer aNbCurves = aBCurves.Length(); + const BOPDS_PDS& pDS = theDSFiller->PDS(); + BOPDS_VectorOfInterfFF& aFFs=pDS->InterfFF(); - for (j = 1; j <= aNbCurves; j++) { - BOPTools_Curve& aBC = aBCurves(j); - const BOPTools_ListOfPaveBlock& aSectEdges = aBC.NewPaveBlocks(); - - BOPTools_ListIteratorOfListOfPaveBlock aPBIt(aSectEdges); - - for (; aPBIt.More(); aPBIt.Next()) { - BOPTools_PaveBlock& aPB=aPBIt.Value(); - Standard_Integer nSect = aPB.Edge(); - - if(theEdge.IsSame(aDS.Shape(nSect))) { - Standard_Integer nF1 = aFFi.Index1(); - Standard_Integer nF2 = aFFi.Index2(); - theFace1 = aDS.Shape(nF1); - theFace2 = aDS.Shape(nF2); - return Standard_True; - } + aNb=aFFs.Extent(); + for (i = 0; i < aNb; ++i) { + BOPDS_InterfFF& aFF=aFFs(i); + + const BOPDS_VectorOfCurve& aVC = aFF.Curves(); + aNbC = aVC.Extent(); + for (j = 0; j < aNbC; ++j) { + const BOPDS_Curve& aNC = aVC(j); + const BOPDS_ListOfPaveBlock& aLPB = aNC.PaveBlocks(); + aIt.Initialize(aLPB); + for (; aIt.More(); aIt.Next()) { + const Handle(BOPDS_PaveBlock)& aPB = aIt.Value(); + nE = aPB->Edge(); + const TopoDS_Shape& aE = pDS->Shape(nE); + if (theEdge.IsSame(aE)) { + aFF.Indices(nF1, nF2); + theFace1 = pDS->Shape(nF1); + theFace2 = pDS->Shape(nF2); + return Standard_True; + } } } } + return Standard_False; } @@ -628,76 +443,77 @@ Standard_Boolean QANewModTopOpe_Tools::SplitE(const TopoDS_Edge& theEdge, // function: EdgeSectionAncestors // purpose: // ======================================================================================== -Standard_Boolean QANewModTopOpe_Tools::EdgeSectionAncestors(const BOPTools_PDSFiller& theDSFiller, - const TopoDS_Shape& theEdge, - TopTools_ListOfShape& LF1, - TopTools_ListOfShape& LF2, - TopTools_ListOfShape& LE1, - TopTools_ListOfShape& LE2) +Standard_Boolean QANewModTopOpe_Tools::EdgeSectionAncestors(const BOPAlgo_PPaveFiller& theDSFiller, + const TopoDS_Shape& theEdge, + TopTools_ListOfShape& LF1, + TopTools_ListOfShape& LF2, + TopTools_ListOfShape& LE1, + TopTools_ListOfShape& LE2) { if(theEdge.ShapeType() != TopAbs_EDGE) return Standard_False; - const BooleanOperations_ShapesDataStructure& aDS = theDSFiller->DS(); - Standard_Integer i = 0, nb = 0; - nb = aDS.NumberOfSourceShapes(); - - for(i = 1; i <= nb; i++) { - if(aDS.GetShapeType(i) != TopAbs_EDGE) - continue; + + const BOPDS_PDS& pDS = theDSFiller->PDS(); + Standard_Integer i = 0, nb = 0, nF, nE, nEOr; + BOPCol_MapOfInteger aMIF; + nb = pDS->NbSourceShapes(); + + nE = pDS->Index(theEdge); + const BOPDS_ListOfPaveBlock& aLPB1 = pDS->PaveBlocks(nE); + if (!aLPB1.Extent()) { + return Standard_False; + } - const BOPTools_CommonBlockPool& aCommonBlockPool = theDSFiller->CommonBlockPool(); - const BOPTools_ListOfCommonBlock& aCBlocks = aCommonBlockPool(aDS.RefEdge(i)); - BOPTools_ListIteratorOfListOfCommonBlock anIt(aCBlocks); + const Handle(BOPDS_PaveBlock)& aPB1 = aLPB1.First(); + const Handle(BOPDS_CommonBlock)& aCB=aPB1->CommonBlock(); + if (aCB.IsNull()) { + return Standard_False; + } + + const BOPCol_ListOfInteger& aLIF = aCB->Faces(); + BOPCol_ListIteratorOfListOfInteger aItLI; + aItLI.Initialize(aLIF); + for ( ; aItLI.More(); aItLI.Next()) { + nF = aItLI.Value(); + if(pDS->Rank(nF) == 0) + LF1.Append(pDS->Shape(nF)); + else + LF2.Append(pDS->Shape(nF)); - for(; anIt.More(); anIt.Next()) { - const BOPTools_CommonBlock& aCB = anIt.Value(); - BOPTools_CommonBlock* pCB = (BOPTools_CommonBlock*) &aCB; - BOPTools_PaveBlock& aPB = pCB->PaveBlock1(i); - Standard_Integer nSp = aPB.Edge(); - TopoDS_Shape aSplit = aDS.Shape(nSp); - - if(!theEdge.IsSame(aSplit)) - continue; - - if(aDS.Rank(i) == 1) - LE1.Append(aDS.Shape(i)); - else - LE2.Append(aDS.Shape(i)); - Standard_Integer nFace = aCB.Face(); - - if(aCB.Face()) { - if(aDS.Rank(nFace) == 1) - LF1.Append(aDS.Shape(nFace)); - else - LF2.Append(aDS.Shape(nFace)); - } - // find edge ancestors.begin - TopTools_IndexedMapOfShape aMapF; - Standard_Integer j = 0, k = 0; - - for(j = 1; j <= aDS.NumberOfAncestors(i); j++) { - Standard_Integer aAncestor1 = aDS.GetAncestor(i, j); - - for(k = 1; k <= aDS.NumberOfAncestors(aAncestor1); k++) { - Standard_Integer aAncestor2 = aDS.GetAncestor(aAncestor1, k); + aMIF.Add(nF); + } - if(aDS.GetShapeType(aAncestor2) == TopAbs_FACE) { - const TopoDS_Shape& aFace = aDS.Shape(aAncestor2); + const BOPDS_ListOfPaveBlock& aLPB = aCB->PaveBlocks(); + BOPDS_ListIteratorOfListOfPaveBlock aItPB; + aItPB.Initialize(aLPB); + for (; aItPB.More(); aItPB.Next()) { + const Handle(BOPDS_PaveBlock)& aPB = aItPB.Value(); + nEOr = aPB->OriginalEdge(); - if(aMapF.Contains(aFace)) - continue; + if(pDS->Rank(nEOr) == 0) + LE1.Append(pDS->Shape(nEOr)); + else + LE2.Append(pDS->Shape(nEOr)); - if(aDS.Rank(i) == 1) - LF1.Append(aFace); - else - LF2.Append(aFace); - aMapF.Add(aFace); - } - } + //find edge ancestors + for(i = 0; i < nb; ++i) { + const BOPDS_ShapeInfo& aSI = pDS->ShapeInfo(i); + if(aSI.ShapeType() != TopAbs_FACE) { + continue; } - // find edge ancestors.end - } + const BOPCol_ListOfInteger& aSubShapes = aSI.SubShapes(); + aItLI.Initialize(aSubShapes); + for (; aItLI.More(); aItLI.Next()) { + if (nEOr == aItLI.Value()) { + if (aMIF.Add(i)) { + if(pDS->Rank(i) == 0) LF1.Append(pDS->Shape(i)); + else LF2.Append(pDS->Shape(i)); + }//if (aMIF.Add(i)) { + }//if (nEOr == aItLI.Value()) { + }//for (; aItLI.More(); aItLI.Next()) { + }//for(i = 0; i < nb; ++i) { } + Standard_Boolean r = (!LF1.IsEmpty() && !LF2.IsEmpty()); r = r && (!LE1.IsEmpty() || !LE2.IsEmpty()); return r; @@ -708,37 +524,45 @@ Standard_Boolean QANewModTopOpe_Tools::EdgeSectionAncestors(const BOPTools_PDSFi // purpose: // ======================================================================================== Standard_Boolean QANewModTopOpe_Tools::BoolOpe(const TopoDS_Shape& theFace1, - const TopoDS_Shape& theFace2, - Standard_Boolean& IsCommonFound, - TopTools_IndexedDataMapOfShapeListOfShape& theHistoryMap) + const TopoDS_Shape& theFace2, + Standard_Boolean& IsCommonFound, + TopTools_IndexedDataMapOfShapeListOfShape& theHistoryMap) { IsCommonFound = Standard_False; theHistoryMap.Clear(); + gp_Dir aDNF1, aDNF2; + Standard_Integer iSenseFlag; - BOPTools_DSFiller aDSFiller; - aDSFiller.SetShapes(theFace1, theFace2); - - if (!aDSFiller.IsDone()) { + BOPAlgo_PaveFiller aDSFiller; + BOPCol_ListOfShape aLS; + aLS.Append(theFace1); + aLS.Append(theFace2); + aDSFiller.SetArguments(aLS); + + aDSFiller.Perform(); + if (aDSFiller.ErrorStatus()) { return Standard_False; } - aDSFiller.Perform(); - const BooleanOperations_ShapesDataStructure& aDS = aDSFiller.DS(); - BOPTools_InterferencePool* anIntrPool = (BOPTools_InterferencePool*)&aDSFiller.InterfPool(); - Standard_Integer aNb = 0; + + const BOPDS_PDS& pDS = aDSFiller.PDS(); + + Standard_Integer aNb = 0, aNbSps; Standard_Integer i = 0, j = 0; TopTools_IndexedMapOfShape aMapV; + { BRepAlgoAPI_Common aCommon(theFace1, theFace2, aDSFiller); if(!aCommon.IsDone()) { return Standard_False; } + TopExp_Explorer anExp(aCommon.Shape(), TopAbs_FACE); - if(!anExp.More()) { IsCommonFound = Standard_False; return Standard_True; } + IsCommonFound = Standard_True; TopExp::MapShapes(aCommon.Shape(), TopAbs_VERTEX, aMapV); // fill edge history.begin @@ -746,54 +570,75 @@ Standard_Boolean QANewModTopOpe_Tools::BoolOpe(const TopoDS_Shape& theFace1, // fill edge history.end // fill face history.begin - BOPTools_CArray1OfSSInterference& aFFs = anIntrPool->SSInterferences(); + BOPDS_VectorOfInterfFF& aFFs = pDS->InterfFF(); aNb = aFFs.Extent(); Standard_Boolean bReverseFlag = Standard_True; Standard_Boolean fillhistory = Standard_True; - for (i=1; i<=aNb; i++) { - BOPTools_SSInterference& aFF = aFFs(i); + for (i=0; iShape(nF1)); + const TopoDS_Face& aF2 = *(TopoDS_Face*)(&pDS->Shape(nF2)); + + BOPCol_ListOfInteger aLSE; + pDS->SharedEdges(nF1, nF2, aLSE, aDSFiller.Allocator()); + aNbSps = aLSE.Extent(); + + if (!aNbSps) { + fillhistory = Standard_False; + continue; + } + + Standard_Integer nE = aLSE.First(); + const TopoDS_Edge& aSpE = *(TopoDS_Edge*)(&pDS->Shape(nE)); + + BOPTools_AlgoTools3D::GetNormalToFaceOnEdge (aSpE, aF1, aDNF1); + BOPTools_AlgoTools3D::GetNormalToFaceOnEdge (aSpE, aF2, aDNF2); + iSenseFlag=BOPTools_AlgoTools3D::SenseFlag (aDNF1, aDNF2); - if(aFF.SenseFlag() == 1) { - fillhistory = Standard_True; - bReverseFlag = Standard_False; + if(iSenseFlag == 1) { + fillhistory = Standard_True; + bReverseFlag = Standard_False; } - else if(aFF.SenseFlag() == -1) { - fillhistory = Standard_True; - bReverseFlag = Standard_True; + else if(iSenseFlag == -1) { + fillhistory = Standard_True; + bReverseFlag = Standard_True; } else - fillhistory = Standard_False; + fillhistory = Standard_False; } if(fillhistory) { for(; anExp.More(); anExp.Next()) { - TopoDS_Shape aResShape = anExp.Current(); - - if(theFace1.Orientation() == aResShape.Orientation()) { - AddShapeToHistoryMap(theFace1, aResShape, theHistoryMap); - - if(bReverseFlag) - aResShape.Reverse(); - AddShapeToHistoryMap(theFace2, aResShape, theHistoryMap); - } - else if(theFace2.Orientation() == aResShape.Orientation()) { - AddShapeToHistoryMap(theFace2, aResShape, theHistoryMap); - - if(bReverseFlag) - aResShape.Reverse(); - AddShapeToHistoryMap(theFace1, aResShape, theHistoryMap); - } - else { - aResShape.Orientation(theFace1.Orientation()); - AddShapeToHistoryMap(theFace1, aResShape, theHistoryMap); - aResShape.Orientation(theFace2.Orientation()); - - if(bReverseFlag) - aResShape.Reverse(); - AddShapeToHistoryMap(theFace2, aResShape, theHistoryMap); - } + TopoDS_Shape aResShape = anExp.Current(); + + if(theFace1.Orientation() == aResShape.Orientation()) { + AddShapeToHistoryMap(theFace1, aResShape, theHistoryMap); + + if(bReverseFlag) + aResShape.Reverse(); + AddShapeToHistoryMap(theFace2, aResShape, theHistoryMap); + } + else if(theFace2.Orientation() == aResShape.Orientation()) { + AddShapeToHistoryMap(theFace2, aResShape, theHistoryMap); + + if(bReverseFlag) + aResShape.Reverse(); + AddShapeToHistoryMap(theFace1, aResShape, theHistoryMap); + } + else { + aResShape.Orientation(theFace1.Orientation()); + AddShapeToHistoryMap(theFace1, aResShape, theHistoryMap); + aResShape.Orientation(theFace2.Orientation()); + + if(bReverseFlag) + aResShape.Reverse(); + AddShapeToHistoryMap(theFace2, aResShape, theHistoryMap); + } } } // fill face history.end @@ -841,71 +686,56 @@ Standard_Boolean QANewModTopOpe_Tools::BoolOpe(const TopoDS_Shape& theFace1, } // fill vertex history.begin - BOPTools_CArray1OfVVInterference& aVVs = anIntrPool->VVInterferences(); + BOPDS_VectorOfInterfVV& aVVs = pDS->InterfVV(); aNb = aVVs.Extent(); - for (i = 1; i <= aNb; i++) { - BOPTools_VVInterference& aVVi = aVVs(i); - Standard_Integer aNewShapeIndex = aVVi.NewShape(); - - if(aNewShapeIndex == 0) + for (i = 0; i < aNb; ++i) { + BOPDS_InterfVV& aVVi = aVVs(i); + if (!aVVi.HasIndexNew()) { continue; - const TopoDS_Shape& aNewVertex = aDS.Shape(aNewShapeIndex); + } + Standard_Integer aNewShapeIndex = aVVi.IndexNew(); - if(!aMapV.Contains(aNewVertex)) + const TopoDS_Shape& aNewVertex = pDS->Shape(aNewShapeIndex); + + if(!aMapV.Contains(aNewVertex)) { continue; - const TopoDS_Shape& aV1 = aDS.Shape(aVVi.Index1()); - const TopoDS_Shape& aV2 = aDS.Shape(aVVi.Index2()); + } + + const TopoDS_Shape& aV1 = pDS->Shape(aVVi.Index1()); + const TopoDS_Shape& aV2 = pDS->Shape(aVVi.Index2()); AddShapeToHistoryMap(aV1, aNewVertex, theHistoryMap); AddShapeToHistoryMap(aV2, aNewVertex, theHistoryMap); } - BOPTools_CArray1OfVEInterference& aVEs = anIntrPool->VEInterferences(); - aNb = aVEs.Extent(); - for (i = 1; i <= aNb; i++) { - BOPTools_VEInterference& aVEi = aVEs(i); - Standard_Integer aNewShapeIndex = aVEi.NewShape(); + BOPDS_VectorOfInterfVE& aVEs = pDS->InterfVE(); + aNb = aVEs.Extent(); - if(aNewShapeIndex == 0) - continue; - const TopoDS_Shape& aNewVertex = aDS.Shape(aNewShapeIndex); + for (i = 0; i < aNb; ++i) { + BOPDS_InterfVE& aVEi = aVEs(i); + + Standard_Integer anIndex = aVEi.Index1(); + const TopoDS_Shape& aNewVertex = pDS->Shape(anIndex); if(!aMapV.Contains(aNewVertex)) continue; - Standard_Integer anIndex = 0; - if(aDS.GetShapeType(aVEi.Index1()) == TopAbs_VERTEX) - anIndex = aVEi.Index1(); - else if(aDS.GetShapeType(aVEi.Index2()) == TopAbs_VERTEX) - anIndex = aVEi.Index2(); - else - continue; - const TopoDS_Shape& aV = aDS.Shape(anIndex); - AddShapeToHistoryMap(aV, aNewVertex, theHistoryMap); + AddShapeToHistoryMap(aNewVertex, aNewVertex, theHistoryMap); } - BOPTools_CArray1OfVSInterference& aVSs = anIntrPool->VSInterferences(); + + BOPDS_VectorOfInterfVF& aVSs = pDS->InterfVF(); aNb = aVSs.Extent(); - for (i = 1; i <= aNb; i++) { - BOPTools_VSInterference& aVSi = aVSs(i); - Standard_Integer aNewShapeIndex = aVSi.NewShape(); + for (i = 0; i < aNb; ++i) { + BOPDS_InterfVF& aVSi = aVSs(i); - if(aNewShapeIndex == 0) - continue; - const TopoDS_Shape& aNewVertex = aDS.Shape(aNewShapeIndex); + Standard_Integer anIndex = aVSi.Index1(); + const TopoDS_Shape& aNewVertex = pDS->Shape(anIndex); if(!aMapV.Contains(aNewVertex)) continue; - Standard_Integer anIndex = 0; - if(aDS.GetShapeType(aVSi.Index1()) == TopAbs_VERTEX) - anIndex = aVSi.Index1(); - else if(aDS.GetShapeType(aVSi.Index2()) == TopAbs_VERTEX) - anIndex = aVSi.Index2(); - else - continue; - const TopoDS_Shape& aV = aDS.Shape(anIndex); - AddShapeToHistoryMap(aV, aNewVertex, theHistoryMap); + AddShapeToHistoryMap(aNewVertex, aNewVertex, theHistoryMap); } // fill vertex history.end return Standard_True; @@ -918,11 +748,11 @@ Standard_Boolean QANewModTopOpe_Tools::BoolOpe(const TopoDS_Shape& theFace1, // theFace1's edges and tolerance of theFace2 // ----------------------------------------------------------------- Standard_Boolean CheckSameDomainFaceInside(const TopoDS_Face& theFace1, - const TopoDS_Face& theFace2) { + const TopoDS_Face& theFace2) { Standard_Real umin = 0., umax = 0., vmin = 0., vmax = 0.; BRepTools::UVBounds(theFace1, umin, umax, vmin, vmax); - IntTools_Context aContext; + Handle(IntTools_Context) aContext; Handle(Geom_Surface) aSurface = BRep_Tool::Surface(theFace1); Standard_Real aTolerance = BRep_Tool::Tolerance(theFace1); @@ -939,7 +769,7 @@ Standard_Boolean CheckSameDomainFaceInside(const TopoDS_Face& theFace1, Standard_Real adeltau = (umax - umin) / (nbpoints + 1); Standard_Real adeltav = (vmax - vmin) / (nbpoints + 1); Standard_Real U = umin + adeltau; - GeomAPI_ProjectPointOnSurf& aProjector = aContext.ProjPS(theFace2); + GeomAPI_ProjectPointOnSurf& aProjector = aContext->ProjPS(theFace2); for(Standard_Integer i = 1; i <= nbpoints; i++, U+=adeltau) { Standard_Real V = vmin + adeltav; @@ -947,15 +777,15 @@ Standard_Boolean CheckSameDomainFaceInside(const TopoDS_Face& theFace1, for(Standard_Integer j = 1; j <= nbpoints; j++, V+=adeltav) { gp_Pnt2d aPoint(U,V); - if(aContext.IsPointInFace(theFace1, aPoint)) { - gp_Pnt aP3d = aSurface->Value(U, V); - aProjector.Perform(aP3d); + if(aContext->IsPointInFace(theFace1, aPoint)) { + gp_Pnt aP3d = aSurface->Value(U, V); + aProjector.Perform(aP3d); - if(aProjector.IsDone()) { + if(aProjector.IsDone()) { - if(aProjector.LowerDistance() > aTolerance) - return Standard_False; - } + if(aProjector.LowerDistance() > aTolerance) + return Standard_False; + } } } } @@ -968,8 +798,8 @@ Standard_Boolean CheckSameDomainFaceInside(const TopoDS_Face& theFace1, // purpose: // -------------------------------------------------------------------------------------------- Standard_Boolean AddShapeToHistoryMap(const TopoDS_Shape& theOldShape, - const TopoDS_Shape& theNewShape, - TopTools_IndexedDataMapOfShapeListOfShape& theHistoryMap) { + const TopoDS_Shape& theNewShape, + TopTools_IndexedDataMapOfShapeListOfShape& theHistoryMap) { if(!theHistoryMap.Contains(theOldShape)) { TopTools_ListOfShape aList; @@ -1000,7 +830,7 @@ Standard_Boolean AddShapeToHistoryMap(const TopoDS_Shape& theOldShape, // purpose: // -------------------------------------------------------------------------------------------- void FillEdgeHistoryMap(BRepAlgoAPI_BooleanOperation& theBOP, - TopTools_IndexedDataMapOfShapeListOfShape& theHistoryMap) { + TopTools_IndexedDataMapOfShapeListOfShape& theHistoryMap) { TopExp_Explorer anExp; anExp.Init(theBOP.Shape1(), TopAbs_EDGE); @@ -1031,8 +861,8 @@ void FillEdgeHistoryMap(BRepAlgoAPI_BooleanOperation& theBOP, // purpose: // -------------------------------------------------------------------------------------------- void SortVertexOnEdge(const TopoDS_Edge& theEdge, - const TopTools_ListOfShape& theListOfVertex, - TopTools_ListOfShape& theListOfVertexSorted) { + const TopTools_ListOfShape& theListOfVertex, + TopTools_ListOfShape& theListOfVertexSorted) { TopTools_DataMapOfIntegerShape mapiv;// mapiv.Find(iV) = V TColStd_IndexedMapOfReal mappar; // mappar.FindIndex(parV) = iV @@ -1063,3 +893,28 @@ void SortVertexOnEdge(const TopoDS_Edge& theEdge, theListOfVertexSorted.Append(v); } } + +// -------------------------------------------------------------------------------------------- +// static function: GetEdgeState +// purpose: +// -------------------------------------------------------------------------------------------- + static TopAbs_State GetEdgeState(const BOPDS_PDS& pDS, + const Handle(BOPDS_PaveBlock)& aPB) +{ + Standard_Integer j, aNbFI; + Standard_Boolean bIn; + TopAbs_State aState = TopAbs_ON; + // + const BOPDS_VectorOfFaceInfo& aVFI = pDS->FaceInfoPool(); + aNbFI = aVFI.Extent(); + // + for (j = 0; j < aNbFI; ++j) { + const BOPDS_FaceInfo& aFI = aVFI(j); + bIn = aFI.PaveBlocksIn().Contains(aPB); + if (bIn) { + aState = TopAbs_IN; + break; + } + } + return aState; +} diff --git a/src/TKBO/PACKAGES b/src/TKBO/PACKAGES index 31a8c9206b..85ff5bc129 100755 --- a/src/TKBO/PACKAGES +++ b/src/TKBO/PACKAGES @@ -1,6 +1,9 @@ BOPTColStd -BOPTools -BOP -BooleanOperations IntTools BRepAlgoAPI + +BOPCol +BOPInt +BOPDS +BOPAlgo +BOPTools diff --git a/tests/boolean/bcommon_2d/A7 b/tests/boolean/bcommon_2d/A7 index 0e42bde504..c1b65e0917 100644 --- a/tests/boolean/bcommon_2d/A7 +++ b/tests/boolean/bcommon_2d/A7 @@ -2,5 +2,5 @@ restore [locate_data_file case_1_solid.brep] a restore [locate_data_file case_1_wire3.brep] b bcommon result b a set length 942.478 -set nbsh_v 4 +set nbsh_v 2 set nbsh_e 4 diff --git a/tests/boolean/bcommon_2d/B1 b/tests/boolean/bcommon_2d/B1 index 79df60b89b..0416f3accb 100644 --- a/tests/boolean/bcommon_2d/B1 +++ b/tests/boolean/bcommon_2d/B1 @@ -3,4 +3,4 @@ restore [locate_data_file case_1_wire3.brep] b bcommon result b a set length 942.478 set nbsh_v 2 -set nbsh_e 2 +set nbsh_e 4 diff --git a/tests/boolean/bfuse_complex/Q7 b/tests/boolean/bfuse_complex/Q7 index 17e661b2d2..7858aaf37c 100644 --- a/tests/boolean/bfuse_complex/Q7 +++ b/tests/boolean/bfuse_complex/Q7 @@ -10,6 +10,6 @@ bcut res1 tool base explode res1 So -bfuse result base res1_2 +bfuse result base res1_1 set square 181990 diff --git a/tests/boolean/bfuse_complex/Q8 b/tests/boolean/bfuse_complex/Q8 index 5913423c36..934a54d329 100644 --- a/tests/boolean/bfuse_complex/Q8 +++ b/tests/boolean/bfuse_complex/Q8 @@ -11,6 +11,6 @@ bcut rcut1 tool1 base explode rcut1 -bfuse result base rcut1_1 +bfuse result base rcut1_2 set square 13428.1 diff --git a/tests/boolean/bfuse_complex/Q9 b/tests/boolean/bfuse_complex/Q9 index c94bbc5ad5..bd10db75ae 100644 --- a/tests/boolean/bfuse_complex/Q9 +++ b/tests/boolean/bfuse_complex/Q9 @@ -11,6 +11,6 @@ bcut rcut2 tool2 base explode rcut2 -bfuse result base rcut2_1 +bfuse result base rcut2_2 set square 13822.2 diff --git a/tests/boolean/bfuse_complex/S2 b/tests/boolean/bfuse_complex/S2 index 74c9511d2e..17581b1d23 100644 --- a/tests/boolean/bfuse_complex/S2 +++ b/tests/boolean/bfuse_complex/S2 @@ -11,9 +11,9 @@ bcut res pr sh explode res -bfuse res2 sh res_2 +bfuse res2 sh res_3 -bfuse result sh res_3 +bfuse result sh res_2 set square 3734.83 diff --git a/tests/boolean/bopcommon_2d/A7 b/tests/boolean/bopcommon_2d/A7 index e8b836577b..38d15b62c3 100644 --- a/tests/boolean/bopcommon_2d/A7 +++ b/tests/boolean/bopcommon_2d/A7 @@ -3,5 +3,5 @@ restore [locate_data_file case_1_wire3.brep] b bop a b bopcommon result set length 942.478 -set nbsh_v 4 +set nbsh_v 2 set nbsh_e 4 diff --git a/tests/boolean/bopcommon_2d/B1 b/tests/boolean/bopcommon_2d/B1 index b58c041997..1184d199c3 100644 --- a/tests/boolean/bopcommon_2d/B1 +++ b/tests/boolean/bopcommon_2d/B1 @@ -4,4 +4,4 @@ bop a b bopcommon result set length 942.478 set nbsh_v 2 -set nbsh_e 2 +set nbsh_e 4 diff --git a/tests/boolean/bopcommon_simple/ZP8 b/tests/boolean/bopcommon_simple/ZP8 index 0366271c53..4ca00499bf 100644 --- a/tests/boolean/bopcommon_simple/ZP8 +++ b/tests/boolean/bopcommon_simple/ZP8 @@ -13,4 +13,4 @@ explode r so bop r_1 b1 bopcommon result -set square 96 +set square empty diff --git a/tests/boolean/bopcut_simple/ZP9 b/tests/boolean/bopcut_simple/ZP9 index 8e7dc20b38..0f62898c13 100644 --- a/tests/boolean/bopcut_simple/ZP9 +++ b/tests/boolean/bopcut_simple/ZP9 @@ -13,4 +13,4 @@ explode r so bop r_1 b1 bopcut result -set square 600 +set square 696 diff --git a/tests/boolean/bopfuse_simple/ZP5 b/tests/boolean/bopfuse_simple/ZP5 index 2d55fda44a..9a554d2775 100644 --- a/tests/boolean/bopfuse_simple/ZP5 +++ b/tests/boolean/bopfuse_simple/ZP5 @@ -13,4 +13,4 @@ explode r so bop r_1 b1 bopfuse result -set square 696 +set square 600 diff --git a/tests/boolean/boptuc_simple/ZP4 b/tests/boolean/boptuc_simple/ZP4 index 1c5760e13a..9fb33a6aec 100644 --- a/tests/boolean/boptuc_simple/ZP4 +++ b/tests/boolean/boptuc_simple/ZP4 @@ -13,4 +13,4 @@ explode r so bop r_1 b1 boptuc result -set square empty +set square 96 diff --git a/tests/boolean/bsection/C9 b/tests/boolean/bsection/C9 index 5d1187f0f7..decb7a7f23 100644 --- a/tests/boolean/bsection/C9 +++ b/tests/boolean/bsection/C9 @@ -2,4 +2,4 @@ restore [locate_data_file a40] a restore [locate_data_file b40] b bsection result a b -set length 39.8158 +set length 50.8667 diff --git a/tests/boolean/bsection/D8 b/tests/boolean/bsection/D8 index 956b82710e..867674a34f 100644 --- a/tests/boolean/bsection/D8 +++ b/tests/boolean/bsection/D8 @@ -3,4 +3,4 @@ restore [locate_data_file a49] a restore [locate_data_file b50] b bsection result a b -set length 0 +set length 254.014 diff --git a/tests/boolean/bsection/E8 b/tests/boolean/bsection/E8 index bbfe1a15f0..7b4402c3d3 100644 --- a/tests/boolean/bsection/E8 +++ b/tests/boolean/bsection/E8 @@ -1,6 +1,5 @@ -puts "TODO OCC22911 ALL: Error : The bsection is not valid." restore [locate_data_file a49] a restore [locate_data_file b49] b bsection result a b -set length 0 +set length 122.155 diff --git a/tests/boolean/bsection/H3 b/tests/boolean/bsection/H3 index 891fbd30be..8f26113e33 100644 --- a/tests/boolean/bsection/H3 +++ b/tests/boolean/bsection/H3 @@ -1,5 +1,5 @@ restore [locate_data_file BUGDATA_2293.rle] a explode a -bsection result a_1 a_2 -2d -a +bsection result a_1 a_2 set length 285.489 diff --git a/tests/boolean/bsection/H4 b/tests/boolean/bsection/H4 index a8228fcf01..7810223fc1 100644 --- a/tests/boolean/bsection/H4 +++ b/tests/boolean/bsection/H4 @@ -1,5 +1,5 @@ restore [locate_data_file BUGDATA_2293_nofog.rle] a explode a -bsection result a_1 a_2 -2d -a +bsection result a_1 a_2 set length 285.489 diff --git a/tests/boolean/bsection/H5 b/tests/boolean/bsection/H5 index 69bb1afec6..0ed35de2e3 100644 --- a/tests/boolean/bsection/H5 +++ b/tests/boolean/bsection/H5 @@ -1,5 +1,5 @@ restore [locate_data_file BUGDATA_2381.rle] a explode a -bsection result a_1 a_2 -2d -a +bsection result a_1 a_2 set length 691.399 diff --git a/tests/boolean/bsection/H6 b/tests/boolean/bsection/H6 index 8354f4b121..def7873fa9 100644 --- a/tests/boolean/bsection/H6 +++ b/tests/boolean/bsection/H6 @@ -1,5 +1,5 @@ restore [locate_data_file BUGDATA_2381_nofog.rle] a explode a -bsection result a_1 a_2 -2d -a +bsection result a_1 a_2 set length 691.399 diff --git a/tests/boolean/bsection/H7 b/tests/boolean/bsection/H7 index 30ba45b2f5..9327d8b4cc 100644 --- a/tests/boolean/bsection/H7 +++ b/tests/boolean/bsection/H7 @@ -1,5 +1,5 @@ restore [locate_data_file GEN453.rle] a explode a -bsection result a_1 a_2 -2d -a +bsection result a_1 a_2 set length 267.619 diff --git a/tests/boolean/bsection/H8 b/tests/boolean/bsection/H8 index 8e9a851b65..0428e9e819 100644 --- a/tests/boolean/bsection/H8 +++ b/tests/boolean/bsection/H8 @@ -1,5 +1,5 @@ restore [locate_data_file GEN453_nofog.rle] a explode a -bsection result a_1 a_2 -2d -a +bsection result a_1 a_2 set length 267.619 diff --git a/tests/boolean/bsection/H9 b/tests/boolean/bsection/H9 index 3fc4336768..b2c2235977 100644 --- a/tests/boolean/bsection/H9 +++ b/tests/boolean/bsection/H9 @@ -1,5 +1,5 @@ restore [locate_data_file GEN465.rle] a explode a -bsection result a_1 a_2 -2d -a +bsection result a_1 a_2 set length 49.9609 diff --git a/tests/boolean/bsection/I1 b/tests/boolean/bsection/I1 index 7a695c08b5..d3e4c31ac8 100644 --- a/tests/boolean/bsection/I1 +++ b/tests/boolean/bsection/I1 @@ -1,5 +1,5 @@ restore [locate_data_file GEN465_nofog.rle] a explode a -bsection result a_1 a_2 -2d -a +bsection result a_1 a_2 set length 49.9609 diff --git a/tests/boolean/bsection/I2 b/tests/boolean/bsection/I2 index db89a87e64..8b63b12382 100644 --- a/tests/boolean/bsection/I2 +++ b/tests/boolean/bsection/I2 @@ -1,5 +1,5 @@ restore [locate_data_file GEN510-3454.rle] a explode a -bsection result a_1 a_2 -2d -a +bsection result a_1 a_2 set length 8.10428 diff --git a/tests/boolean/bsection/I3 b/tests/boolean/bsection/I3 index f7958a308a..d2b272c4a6 100644 --- a/tests/boolean/bsection/I3 +++ b/tests/boolean/bsection/I3 @@ -1,5 +1,5 @@ restore [locate_data_file GEN510-3454_nofog.rle] a explode a -bsection result a_1 a_2 -2d -a +bsection result a_1 a_2 set length 8.14819 diff --git a/tests/boolean/bsection/I4 b/tests/boolean/bsection/I4 index 11e4f92d19..5737af9b9c 100644 --- a/tests/boolean/bsection/I4 +++ b/tests/boolean/bsection/I4 @@ -1,5 +1,5 @@ restore [locate_data_file GEN510-3666.rle] a explode a -bsection result a_1 a_2 -2d -a +bsection result a_1 a_2 set length 114.142 diff --git a/tests/boolean/bsection/I5 b/tests/boolean/bsection/I5 index ebd84b23d0..b14922ddf7 100644 --- a/tests/boolean/bsection/I5 +++ b/tests/boolean/bsection/I5 @@ -1,5 +1,5 @@ restore [locate_data_file GEN510-3666_nofog.rle] a explode a -bsection result a_1 a_2 -2d -a +bsection result a_1 a_2 set length 114.142 diff --git a/tests/boolean/bsection/I6 b/tests/boolean/bsection/I6 index c5dc688c67..8c2eab70a7 100644 --- a/tests/boolean/bsection/I6 +++ b/tests/boolean/bsection/I6 @@ -1,5 +1,5 @@ restore [locate_data_file GEN510-3681.rle] a explode a -bsection result a_1 a_2 -2d -a +bsection result a_1 a_2 set length 38.4985 diff --git a/tests/boolean/bsection/I7 b/tests/boolean/bsection/I7 index 640c1b95fa..adf25708ef 100644 --- a/tests/boolean/bsection/I7 +++ b/tests/boolean/bsection/I7 @@ -1,5 +1,5 @@ restore [locate_data_file GEN510-3681_nofog.rle] a explode a -bsection result a_1 a_2 -2d -a +bsection result a_1 a_2 set length 38.4985 diff --git a/tests/boolean/bsection/I8 b/tests/boolean/bsection/I8 index 21ba82b2d3..b8c64abcb7 100644 --- a/tests/boolean/bsection/I8 +++ b/tests/boolean/bsection/I8 @@ -1,5 +1,5 @@ restore [locate_data_file GEN525_3291.rle] a explode a -bsection result a_1 a_2 -2d -a +bsection result a_1 a_2 set length 335.21 diff --git a/tests/boolean/bsection/I9 b/tests/boolean/bsection/I9 index 75f36d0e78..f5cfbecc9d 100644 --- a/tests/boolean/bsection/I9 +++ b/tests/boolean/bsection/I9 @@ -1,5 +1,5 @@ restore [locate_data_file GEN525_3367_1.rle] a explode a -bsection result a_1 a_2 -2d -a +bsection result a_1 a_2 set length 356.984 diff --git a/tests/boolean/bsection/J1 b/tests/boolean/bsection/J1 index 15226389c1..3bf93de030 100644 --- a/tests/boolean/bsection/J1 +++ b/tests/boolean/bsection/J1 @@ -1,5 +1,5 @@ restore [locate_data_file GEN525_3367_1_nofog.rle] a explode a -bsection result a_1 a_2 -2d -a +bsection result a_1 a_2 set length 356.984 diff --git a/tests/boolean/bsection/J2 b/tests/boolean/bsection/J2 index a5143d90de..8cbeecbdad 100644 --- a/tests/boolean/bsection/J2 +++ b/tests/boolean/bsection/J2 @@ -1,5 +1,5 @@ restore [locate_data_file GEN525_3367_2.rle] a explode a -bsection result a_1 a_2 -2d -a +bsection result a_1 a_2 set length 356.984 diff --git a/tests/boolean/bsection/J3 b/tests/boolean/bsection/J3 index 952cef0f7d..6fbc098009 100644 --- a/tests/boolean/bsection/J3 +++ b/tests/boolean/bsection/J3 @@ -1,5 +1,5 @@ restore [locate_data_file GEN525_3367_2_nofog.rle] a explode a -bsection result a_1 a_2 -2d -a +bsection result a_1 a_2 set length 356.984 diff --git a/tests/boolean/bsection/J4 b/tests/boolean/bsection/J4 index 373da701ca..14cf2a4a83 100644 --- a/tests/boolean/bsection/J4 +++ b/tests/boolean/bsection/J4 @@ -1,5 +1,5 @@ restore [locate_data_file GEN525_3403.rle] a explode a -bsection result a_1 a_2 -2d -a +bsection result a_1 a_2 set length 1093.37 diff --git a/tests/boolean/bsection/J5 b/tests/boolean/bsection/J5 index 2acd8d9fae..d081d79a30 100644 --- a/tests/boolean/bsection/J5 +++ b/tests/boolean/bsection/J5 @@ -1,5 +1,5 @@ restore [locate_data_file GEN525_3403_nofog.rle] a explode a -bsection result a_1 a_2 -2d -a +bsection result a_1 a_2 set length 1093.37 diff --git a/tests/boolean/bsection/J6 b/tests/boolean/bsection/J6 index 0368f5c561..0f50e8379b 100644 --- a/tests/boolean/bsection/J6 +++ b/tests/boolean/bsection/J6 @@ -1,5 +1,5 @@ restore [locate_data_file GEN539.rle] a explode a -bsection result a_1 a_2 -2d -a +bsection result a_1 a_2 set length 2225.71 diff --git a/tests/boolean/bsection/J7 b/tests/boolean/bsection/J7 index 4047734d1a..2e97564508 100644 --- a/tests/boolean/bsection/J7 +++ b/tests/boolean/bsection/J7 @@ -1,5 +1,5 @@ restore [locate_data_file GEN539_nofog.rle] a explode a -bsection result a_1 a_2 -2d -a +bsection result a_1 a_2 set length 2224.79 diff --git a/tests/boolean/bsection/J8 b/tests/boolean/bsection/J8 index 17f185d094..b93f3b7480 100644 --- a/tests/boolean/bsection/J8 +++ b/tests/boolean/bsection/J8 @@ -1,5 +1,5 @@ restore [locate_data_file GEN585.rle] a explode a -bsection result a_1 a_2 -2d -a +bsection result a_1 a_2 set length 2225.7 diff --git a/tests/boolean/bsection/J9 b/tests/boolean/bsection/J9 index 9f1c011c02..7268b73d7e 100644 --- a/tests/boolean/bsection/J9 +++ b/tests/boolean/bsection/J9 @@ -1,5 +1,5 @@ restore [locate_data_file GEN585_nofog.rle] a explode a -bsection result a_1 a_2 -2d -a +bsection result a_1 a_2 set length 2224.79 diff --git a/tests/boolean/bsection/K1 b/tests/boolean/bsection/K1 index 8954e6b058..80c8cf338d 100644 --- a/tests/boolean/bsection/K1 +++ b/tests/boolean/bsection/K1 @@ -1,5 +1,5 @@ restore [locate_data_file GEN594.rle] a explode a -bsection result a_1 a_2 -2d -a +bsection result a_1 a_2 set length 30.8671 diff --git a/tests/boolean/bsection/K2 b/tests/boolean/bsection/K2 index a2f83f45c7..672b4815e9 100644 --- a/tests/boolean/bsection/K2 +++ b/tests/boolean/bsection/K2 @@ -1,5 +1,5 @@ restore [locate_data_file GEN594_nofog.rle] a explode a -bsection result a_1 a_2 -2d -a +bsection result a_1 a_2 set length 30.8671 diff --git a/tests/boolean/bsection/K3 b/tests/boolean/bsection/K3 index 076c88a569..48548dd7b4 100644 --- a/tests/boolean/bsection/K3 +++ b/tests/boolean/bsection/K3 @@ -1,5 +1,5 @@ restore [locate_data_file GEN605.rle] a explode a -bsection result a_1 a_2 -2d -a +bsection result a_1 a_2 set length 8.41959 diff --git a/tests/boolean/bsection/K4 b/tests/boolean/bsection/K4 index 1ebc2957ff..cbeb52a128 100644 --- a/tests/boolean/bsection/K4 +++ b/tests/boolean/bsection/K4 @@ -1,5 +1,5 @@ restore [locate_data_file GEN605_nofog.rle] a explode a -bsection result a_1 a_2 -2d -a +bsection result a_1 a_2 set length 8.41959 diff --git a/tests/boolean/bsection/K5 b/tests/boolean/bsection/K5 index 5adbefb4d7..fceffb07aa 100644 --- a/tests/boolean/bsection/K5 +++ b/tests/boolean/bsection/K5 @@ -1,5 +1,5 @@ restore [locate_data_file GEN664.rle] a explode a -bsection result a_1 a_2 -2d -a +bsection result a_1 a_2 set length 718.013 diff --git a/tests/boolean/bsection/K6 b/tests/boolean/bsection/K6 index c7f61e4b4a..0f2f436659 100644 --- a/tests/boolean/bsection/K6 +++ b/tests/boolean/bsection/K6 @@ -1,5 +1,5 @@ restore [locate_data_file GEN664_nofog.rle] a explode a -bsection result a_1 a_2 -2d -a +bsection result a_1 a_2 set length 718.013 diff --git a/tests/boolean/bsection/K7 b/tests/boolean/bsection/K7 index 2ecb0874ae..ebb8d23776 100644 --- a/tests/boolean/bsection/K7 +++ b/tests/boolean/bsection/K7 @@ -1,5 +1,5 @@ restore [locate_data_file GEN676.rle] a explode a -bsection result a_1 a_2 -2d -a +bsection result a_1 a_2 set length 88.9434 diff --git a/tests/boolean/bsection/K8 b/tests/boolean/bsection/K8 index eadc406fc1..6da3acfba9 100644 --- a/tests/boolean/bsection/K8 +++ b/tests/boolean/bsection/K8 @@ -1,5 +1,5 @@ restore [locate_data_file GEN676_nofog.rle] a explode a -bsection result a_1 a_2 -2d -a +bsection result a_1 a_2 set length 88.9434 diff --git a/tests/boolean/bsection/K9 b/tests/boolean/bsection/K9 index 21ba82b2d3..b8c64abcb7 100644 --- a/tests/boolean/bsection/K9 +++ b/tests/boolean/bsection/K9 @@ -1,5 +1,5 @@ restore [locate_data_file GEN525_3291.rle] a explode a -bsection result a_1 a_2 -2d -a +bsection result a_1 a_2 set length 335.21 diff --git a/tests/boolean/bsection/L1 b/tests/boolean/bsection/L1 index c97a4606e3..914c048a78 100644 --- a/tests/boolean/bsection/L1 +++ b/tests/boolean/bsection/L1 @@ -1,5 +1,5 @@ restore [locate_data_file GEN731.rle] a explode a -bsection result a_1 a_2 -2d -a +bsection result a_1 a_2 set length 445.675 diff --git a/tests/boolean/bsection/L2 b/tests/boolean/bsection/L2 index fdb697683e..82082ca52f 100644 --- a/tests/boolean/bsection/L2 +++ b/tests/boolean/bsection/L2 @@ -1,5 +1,5 @@ restore [locate_data_file GEN731_nofog.rle] a explode a -bsection result a_1 a_2 -2d -a +bsection result a_1 a_2 set length 445.675 diff --git a/tests/boolean/bsection/L3 b/tests/boolean/bsection/L3 index c915ff1b57..c972b4434f 100644 --- a/tests/boolean/bsection/L3 +++ b/tests/boolean/bsection/L3 @@ -1,5 +1,5 @@ restore [locate_data_file GEN745.rle] a explode a -bsection result a_1 a_2 -2d -a +bsection result a_1 a_2 set length 96.7669 diff --git a/tests/boolean/bsection/L4 b/tests/boolean/bsection/L4 index 5954d0f809..011ff17a9c 100644 --- a/tests/boolean/bsection/L4 +++ b/tests/boolean/bsection/L4 @@ -1,5 +1,5 @@ restore [locate_data_file GEN745_nofog.rle] a explode a -bsection result a_1 a_2 -2d -a +bsection result a_1 a_2 set length 96.7669 diff --git a/tests/boolean/bsection/L5 b/tests/boolean/bsection/L5 index a0736d0b47..b88b78c951 100644 --- a/tests/boolean/bsection/L5 +++ b/tests/boolean/bsection/L5 @@ -1,5 +1,5 @@ restore [locate_data_file GEN746.rle] a explode a -bsection result a_1 a_2 -2d -a +bsection result a_1 a_2 set length 556.6 diff --git a/tests/boolean/bsection/L6 b/tests/boolean/bsection/L6 index 1b85ff1353..a228e4c70f 100644 --- a/tests/boolean/bsection/L6 +++ b/tests/boolean/bsection/L6 @@ -1,5 +1,5 @@ restore [locate_data_file GEN746_nofog.rle] a explode a -bsection result a_1 a_2 -2d -a +bsection result a_1 a_2 set length 556.6 diff --git a/tests/boolean/bsection/L7 b/tests/boolean/bsection/L7 index 805348a55b..dd9ab0d1b8 100644 --- a/tests/boolean/bsection/L7 +++ b/tests/boolean/bsection/L7 @@ -1,5 +1,5 @@ restore [locate_data_file GEN747.rle] a explode a -bsection result a_1 a_2 -2d -a +bsection result a_1 a_2 set length 72.4212 diff --git a/tests/boolean/bsection/L8 b/tests/boolean/bsection/L8 index f7a0a4abf5..46e9432e23 100644 --- a/tests/boolean/bsection/L8 +++ b/tests/boolean/bsection/L8 @@ -1,5 +1,5 @@ restore [locate_data_file GEN747_nofog.rle] a explode a -bsection result a_1 a_2 -2d -a +bsection result a_1 a_2 set length 79.8847 diff --git a/tests/boolean/bsection/L9 b/tests/boolean/bsection/L9 index f42b356e68..9bf7a63c63 100644 --- a/tests/boolean/bsection/L9 +++ b/tests/boolean/bsection/L9 @@ -1,5 +1,5 @@ restore [locate_data_file GEN757.rle] a explode a -bsection result a_1 a_2 -2d -a +bsection result a_1 a_2 set length 683.183 diff --git a/tests/boolean/bsection/M1 b/tests/boolean/bsection/M1 index abef12371a..5d3de0dde6 100644 --- a/tests/boolean/bsection/M1 +++ b/tests/boolean/bsection/M1 @@ -1,5 +1,5 @@ restore [locate_data_file GEN757_nofog.rle] a explode a -bsection result a_1 a_2 -2d -a +bsection result a_1 a_2 set length 683.183 diff --git a/tests/boolean/bsection/M2 b/tests/boolean/bsection/M2 index c78efc9bc7..cdabc81cae 100644 --- a/tests/boolean/bsection/M2 +++ b/tests/boolean/bsection/M2 @@ -1,5 +1,5 @@ restore [locate_data_file GEN758.rle] a explode a -bsection result a_1 a_2 -2d -a +bsection result a_1 a_2 set length 22.2575 diff --git a/tests/boolean/bsection/M3 b/tests/boolean/bsection/M3 index 02e8bacc4f..08a3f95292 100644 --- a/tests/boolean/bsection/M3 +++ b/tests/boolean/bsection/M3 @@ -1,5 +1,5 @@ restore [locate_data_file GEN758_nofog.rle] a explode a -bsection result a_1 a_2 -2d -a +bsection result a_1 a_2 set length 22.2575 diff --git a/tests/boolean/bsection/M4 b/tests/boolean/bsection/M4 index ef8e05d368..ca72936c09 100644 --- a/tests/boolean/bsection/M4 +++ b/tests/boolean/bsection/M4 @@ -1,5 +1,5 @@ restore [locate_data_file GEN776.rle] a explode a -bsection result a_1 a_2 -2d -a +bsection result a_1 a_2 set length 226.488 diff --git a/tests/boolean/bsection/M5 b/tests/boolean/bsection/M5 index 01ed221158..c5e2d6c3b3 100644 --- a/tests/boolean/bsection/M5 +++ b/tests/boolean/bsection/M5 @@ -1,5 +1,5 @@ restore [locate_data_file GEN776_nofog.rle] a explode a -bsection result a_1 a_2 -2d -a +bsection result a_1 a_2 set length 226.487 diff --git a/tests/boolean/bsection/M6 b/tests/boolean/bsection/M6 index 766572f38e..7babd8ba0f 100644 --- a/tests/boolean/bsection/M6 +++ b/tests/boolean/bsection/M6 @@ -1,5 +1,5 @@ restore [locate_data_file GEN778.rle] a explode a -bsection result a_1 a_2 -2d -a +bsection result a_1 a_2 set length 456.707 diff --git a/tests/boolean/bsection/M7 b/tests/boolean/bsection/M7 index b6f933c333..936f6a6ee9 100644 --- a/tests/boolean/bsection/M7 +++ b/tests/boolean/bsection/M7 @@ -1,5 +1,5 @@ restore [locate_data_file GEN778_nofog.rle] a explode a -bsection result a_1 a_2 -2d -a +bsection result a_1 a_2 set length 456.707 diff --git a/tests/boolean/bsection/M8 b/tests/boolean/bsection/M8 index 2d3530b1de..614264a2c9 100644 --- a/tests/boolean/bsection/M8 +++ b/tests/boolean/bsection/M8 @@ -16,7 +16,7 @@ set i -5 while {$i < 0} { plane p_$i $i*1000 0 0 1 0 0 mkface f_$i p_$i - bsection s_$i b f_$i -2d -a + bsection s_$i b f_$i compound result s_$i result set dist [expr $i * 1000] puts "OK Section$i:$dist" @@ -27,7 +27,7 @@ incr i 5 while {$i <= 30} { plane p_$i $i*1000 0 0 1 0 0 mkface f_$i p_$i - bsection s_$i b f_$i -2d -a + bsection s_$i b f_$i compound result s_$i result set dist [expr $i * 1000] puts "OK Section$i:$dist" @@ -37,7 +37,7 @@ incr i 20 while {$i <= 105} { plane p_$i $i*1000 0 0 1 0 0 mkface f_$i p_$i - bsection s_$i b f_$i -2d -a + bsection s_$i b f_$i compound result s_$i result set dist [expr $i * 1000] puts "OK Section$i:$dist" diff --git a/tests/boolean/bsection/M9 b/tests/boolean/bsection/M9 index f00c4d4189..ba5db053a2 100644 --- a/tests/boolean/bsection/M9 +++ b/tests/boolean/bsection/M9 @@ -16,7 +16,7 @@ compound result repeat 21 { plane p_$i 0 $i*100 0 0 1 0 mkface f_$i p_$i - bsection s_$i b f_$i -2d -a + bsection s_$i b f_$i compound result s_$i result set dist [expr $i * 100] puts "OK Section:$dist" diff --git a/tests/boolean/bsection/N2 b/tests/boolean/bsection/N2 index ad00ee1898..95096b00a5 100644 --- a/tests/boolean/bsection/N2 +++ b/tests/boolean/bsection/N2 @@ -1,6 +1,6 @@ restore [locate_data_file lh3d_px1.brep] a plane p 0 0 0 1 0 0 mkface f p -bsection result a f -2d -a +bsection result a f set length 18981.4 diff --git a/tests/boolean/bsection/N4 b/tests/boolean/bsection/N4 index 2f77a9a32d..20f8ed3f1b 100644 --- a/tests/boolean/bsection/N4 +++ b/tests/boolean/bsection/N4 @@ -6,7 +6,7 @@ set i 1 repeat 199 { plane p_$i 0 $i*100 0 0 1 0 mkface f_$i p_$i - bsection s_$i a f_$i -2d -a + bsection s_$i a f_$i compound result s_$i result set dist [expr $i * 100] puts "OK Section:$dist" diff --git a/tests/boolean/bsection/N5 b/tests/boolean/bsection/N5 index b8c8969842..58104e059b 100644 --- a/tests/boolean/bsection/N5 +++ b/tests/boolean/bsection/N5 @@ -6,7 +6,7 @@ compound result repeat 155 { plane p_$i 0 0 $i*100 0 0 1 mkface f_$i p_$i -bsection s_$i a f_$i -2d -a +bsection s_$i a f_$i compound result s_$i result display s_$i clear f_$i diff --git a/tests/boolean/bsection/N6 b/tests/boolean/bsection/N6 index d93c144419..dede481fe7 100644 --- a/tests/boolean/bsection/N6 +++ b/tests/boolean/bsection/N6 @@ -5,7 +5,7 @@ set i -60 repeat 108 { plane p_$i $i*1000 0 0 1 0 0 mkface f_$i p_$i -bsection s_$i a f_$i -2d -a +bsection s_$i a f_$i display s_$i compound result s_$i result clear f_$i diff --git a/tests/boolean/bsection/N7 b/tests/boolean/bsection/N7 index ec389e6d4f..ba943f64bb 100644 --- a/tests/boolean/bsection/N7 +++ b/tests/boolean/bsection/N7 @@ -7,7 +7,7 @@ set i 1 repeat 199 { plane p_$i 0 $i*100 0 0 1 0 mkface f_$i p_$i -bsection s_$i a f_$i -2d -a +bsection s_$i a f_$i compound result s_$i result display s_$i clear f_$i diff --git a/tests/boolean/bsection/O2 b/tests/boolean/bsection/O2 index 8e40ae83b5..0bfb9b3364 100644 --- a/tests/boolean/bsection/O2 +++ b/tests/boolean/bsection/O2 @@ -1,5 +1,5 @@ restore [locate_data_file pro14150a.rle] a restore [locate_data_file pro14150b.rle] b -bsection result a b -2d +bsection result a b set length 267.619 diff --git a/tests/boolean/bsection/O5 b/tests/boolean/bsection/O5 index bf7b0afd14..52ef58f32f 100644 --- a/tests/boolean/bsection/O5 +++ b/tests/boolean/bsection/O5 @@ -1,5 +1,5 @@ restore [locate_data_file pro14151a.rle] a restore [locate_data_file CFI_pro14fjq.rle] b -bsection result a b -2d +bsection result a b set length 49.9609 diff --git a/tests/boolean/bsection/O6 b/tests/boolean/bsection/O6 index 55586dede2..3e0fea3b3b 100644 --- a/tests/boolean/bsection/O6 +++ b/tests/boolean/bsection/O6 @@ -1,5 +1,10 @@ restore [locate_data_file pro14151a.rle] a +<<<<<<< HEAD restore [locate_data_file CFI_pro14fjq.rle] b bsection result b a -2d +======= +restore [locate_data_file pro14151b.rle] b +bsection result b a +>>>>>>> a5b92d9... 0021762: Integration of new Boolean Operation algorithm to OCCT. Fixing regressions. set length 49.9609 diff --git a/tests/boolean/bsection/P1 b/tests/boolean/bsection/P1 index 419174cbc0..b9da7321e4 100644 --- a/tests/boolean/bsection/P1 +++ b/tests/boolean/bsection/P1 @@ -2,6 +2,6 @@ restore [locate_data_file CIN901_intcqhmi.rle] m explode m compound m_1 m_3 c1 compound m_2 m_4 c2 -bsection result c1 c2 -2d -a +bsection result c1 c2 set length 40.5172 diff --git a/tests/boolean/bsection/P2 b/tests/boolean/bsection/P2 index e926290c62..f05af09815 100644 --- a/tests/boolean/bsection/P2 +++ b/tests/boolean/bsection/P2 @@ -2,6 +2,6 @@ restore [locate_data_file CIN901_intcqhmj.rle] m explode m # m_1 : Sr Revolution # m_2 : Sr Reglee -bsection result m_1 m_2 -2d -a +bsection result m_1 m_2 set length 126.535 diff --git a/tests/boolean/bsection/P3 b/tests/boolean/bsection/P3 index d12bcfc999..87e1bb9bb3 100644 --- a/tests/boolean/bsection/P3 +++ b/tests/boolean/bsection/P3 @@ -3,6 +3,6 @@ explode m # m_1 : Cq # m_2 -> m_5 : Cones compound m_2 m_3 m_4 m_5 c1 -bsection result m_1 c1 -2d -a +bsection result m_1 c1 set length 214.703 diff --git a/tests/boolean/bsection/P4 b/tests/boolean/bsection/P4 index 669ca81e4a..74cc1f58aa 100644 --- a/tests/boolean/bsection/P4 +++ b/tests/boolean/bsection/P4 @@ -3,9 +3,9 @@ explode m # primitives : m_1 m_3 m_4 m_5 # m_2 : Bloc compound m_1 m_3 m_5 c1 -bsection s c1 m_2 -2d -a +bsection s c1 m_2 # PB -bsection s2 m_4 m_2 -2d -a +bsection s2 m_4 m_2 compound s s2 result set length 682.142 diff --git a/tests/boolean/bsection/P5 b/tests/boolean/bsection/P5 index 8e73f2e371..3ceac2601d 100644 --- a/tests/boolean/bsection/P5 +++ b/tests/boolean/bsection/P5 @@ -1,6 +1,6 @@ restore [locate_data_file CIN902_intcqhmn.rle] m explode m f # m_1 -bsection result m_1 m_2 -2d -a +bsection result m_1 m_2 set length 27.9451 diff --git a/tests/boolean/bsection/P6 b/tests/boolean/bsection/P6 index ad8b2cc969..797f1fe83b 100644 --- a/tests/boolean/bsection/P6 +++ b/tests/boolean/bsection/P6 @@ -2,6 +2,6 @@ restore [locate_data_file CIN902_intcqhmp.rle] m explode m # m_1 : Prisme # m_2 : Contre-depouille -bsection result m_1 m_2 -2d -a +bsection result m_1 m_2 set length 574.782 diff --git a/tests/boolean/bsection/P7 b/tests/boolean/bsection/P7 index 1a0af0ec16..0eeb853a6a 100644 --- a/tests/boolean/bsection/P7 +++ b/tests/boolean/bsection/P7 @@ -2,6 +2,6 @@ restore [locate_data_file CIN902_intcqhmr.rle] m explode m # m_1 : Bossage # m_2 : Carreau (Enveloppe) -bsection result m_1 m_2 -2d -a +bsection result m_1 m_2 set length 202.944 diff --git a/tests/boolean/bsection/P8 b/tests/boolean/bsection/P8 index 6b85732eb6..72d4eeaeef 100644 --- a/tests/boolean/bsection/P8 +++ b/tests/boolean/bsection/P8 @@ -6,6 +6,6 @@ explode m # m_4 : Bis a 45 degre # m_5 : Bis a n degre compound m_2 m_3 m_4 m_5 c1 -bsection result m_1 c1 -2d -a +bsection result m_1 c1 set length 264.653 diff --git a/tests/boolean/bsection/R5 b/tests/boolean/bsection/R5 index fcbb11e5ad..3a74c5e2e4 100644 --- a/tests/boolean/bsection/R5 +++ b/tests/boolean/bsection/R5 @@ -10,6 +10,4 @@ renamevar c2_1 c2 bsection result c1 c2 -# CR23404 -#set length 550.64 -set length 575.486 +set length 575.501 diff --git a/tests/boolean/bsection/S4 b/tests/boolean/bsection/S4 index 072ee0be94..14f9d3ac58 100644 --- a/tests/boolean/bsection/S4 +++ b/tests/boolean/bsection/S4 @@ -13,6 +13,4 @@ renamevar c2_1 c2 bsection result c1 c2 -# CR23404 -#set length 550.64 -set length 575.486 +set length 575.501 diff --git a/tests/feat/featlf/C8 b/tests/feat/featlf/C8 index 50c8fef0b1..32241b0f01 100644 --- a/tests/feat/featlf/C8 +++ b/tests/feat/featlf/C8 @@ -9,4 +9,4 @@ featlf pr pp pl 0 0 0.3 0 0 -0.2 1 1 featperform lf result -set square 232.03 +set square 42.03 diff --git a/tests/feat/featlf/C9 b/tests/feat/featlf/C9 index aa83c5b13a..fb00313ecf 100644 --- a/tests/feat/featlf/C9 +++ b/tests/feat/featlf/C9 @@ -10,4 +10,4 @@ featlf pr pp pl 0 0 0.3 0 0 -0.2 1 1 featperform lf result -set square 269.502 +set square 49.5019 diff --git a/tests/feat/featlf/D6 b/tests/feat/featlf/D6 index 2bb17c6b0b..dd2bc3366d 100644 --- a/tests/feat/featlf/D6 +++ b/tests/feat/featlf/D6 @@ -10,4 +10,4 @@ featlf pr pp pl 0 0 0.3 0 0 -0.2 1 1 featperform lf result -set square 270.387 +set square 50.3873 diff --git a/tests/feat/featprism/G3 b/tests/feat/featprism/G3 index 7ea7cc05b3..2ec7df97df 100644 --- a/tests/feat/featprism/G3 +++ b/tests/feat/featprism/G3 @@ -10,4 +10,4 @@ compound pr1_3 pr1_4 fu featprism pr1 p2 p2 -2 -4 0 1 1 featperform prism result fu -set square 47.6164 +set square 26.9296 diff --git a/tests/feat/featprism/O5 b/tests/feat/featprism/O5 index 06e7d2d7a9..c1a9bebdf3 100644 --- a/tests/feat/featprism/O5 +++ b/tests/feat/featprism/O5 @@ -10,4 +10,4 @@ copy base_8 funtil featprism base cont cont -1 0 0 1 1 featperform prism result funtil -set square 3.28622e+06 +set square 1.7422e+006 diff --git a/tests/feat/featprism/R5 b/tests/feat/featprism/R5 index a0e7e1534c..b6219f6cc9 100644 --- a/tests/feat/featprism/R5 +++ b/tests/feat/featprism/R5 @@ -6,4 +6,4 @@ mkplane w w featprism s w w 0 1 0 1 1 featperform prism result s_3 s_3 -set square 3.20701e+06 +set square 1.40005e+006 diff --git a/tests/feat/featrevol/J7 b/tests/feat/featrevol/J7 index fb5cfa03c1..d8e74994f9 100644 --- a/tests/feat/featrevol/J7 +++ b/tests/feat/featrevol/J7 @@ -9,4 +9,4 @@ copy base_4 funtil featrevol base cont cont 54.06494140625 70.2841796875 0 0 0 1 1 1 featperform revol result funtil ffrom -set square 609342 +set square 474697 diff --git a/tests/feat/featrf/A3 b/tests/feat/featrf/A3 index 84a6c603d2..253de2a0e5 100644 --- a/tests/feat/featrf/A3 +++ b/tests/feat/featrf/A3 @@ -14,4 +14,4 @@ plane pl -2 0 5 0 1 0 featrf s w pl 0 0 0 0 0 1 0.2 0.2 1 0 featperform rf result -set square 357.255 +set square 107.82 diff --git a/tests/feat/featrf/B1 b/tests/feat/featrf/B1 index 3c1dca2c68..0ccc920f29 100644 --- a/tests/feat/featrf/B1 +++ b/tests/feat/featrf/B1 @@ -14,4 +14,4 @@ plane pl -1.4 0 4.8 0 1 0 featrf s w pl 0 0 0 0 0 1 0.2 0.2 1 0 featperform rf result -set square 337.832 +set square 101.665