1 // Created by: Peter KURNEV
2 // Copyright (c) 1999-2012 OPEN CASCADE SAS
4 // The content of this file is subject to the Open CASCADE Technology Public
5 // License Version 6.5 (the "License"). You may not use the content of this file
6 // except in compliance with the License. Please obtain a copy of the License
7 // at http://www.opencascade.org and read it completely before using this file.
9 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
10 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12 // The Original Code and all software distributed under the License is
13 // distributed on an "AS IS" basis, without warranty of any kind, and the
14 // Initial Developer hereby disclaims all such warranties, including without
15 // limitation, any warranties of merchantability, fitness for a particular
16 // purpose or non-infringement. Please see the License for the specific terms
17 // and conditions governing the rights and limitations under the License.
20 #include <BOPDS_DS.ixx>
22 #include <NCollection_IncAllocator.hxx>
23 #include <NCollection_BaseAllocator.hxx>
26 #include <Bnd_Box.hxx>
28 #include <TopoDS_Shape.hxx>
29 #include <TopoDS_Iterator.hxx>
30 #include <TopoDS_Vertex.hxx>
31 #include <TopoDS_Edge.hxx>
32 #include <TopoDS_Face.hxx>
33 #include <BRep_Tool.hxx>
35 #include <BRepBndLib.hxx>
37 #include <BOPCol_MapOfInteger.hxx>
38 #include <BOPCol_ListOfInteger.hxx>
39 #include <BOPCol_DataMapOfShapeInteger.hxx>
41 #include <BOPDS_IndexRange.hxx>
42 #include <BOPDS_ShapeInfo.hxx>
43 #include <BOPDS_PassKey.hxx>
44 #include <BOPDS_DataMapOfPassKeyListOfPaveBlock.hxx>
45 #include <BOPDS_PassKey.hxx>
47 #include <Geom_Curve.hxx>
48 #include <BRep_Builder.hxx>
49 #include <Precision.hxx>
50 #include <IntTools_Tools.hxx>
51 #include <BOPTools_AlgoTools.hxx>
52 #include <GeomAPI_ProjectPointOnCurve.hxx>
53 #include <BOPDS_MapOfPave.hxx>
57 inline void ResetShape(const TopoDS_Shape& aS);
60 inline void ResetShapes(const TopoDS_Shape& aS);
63 void TotalShapes(const TopoDS_Shape& aS,
64 Standard_Integer& aNbS);
67 Standard_Real ComputeParameter(const TopoDS_Vertex& aV,
68 const TopoDS_Edge& aE);
70 void SortShell(const int n, BOPDS_Pave *a);
72 //=======================================================================
75 //=======================================================================
78 myAllocator(NCollection_BaseAllocator::CommonBaseAllocator()),
79 myArguments(myAllocator),
80 myRanges(myAllocator),
82 myMapShapeIndex(100, myAllocator),
83 myPaveBlocksPool(myAllocator),
84 myFaceInfoPool(myAllocator),
85 myShapesSD(100, myAllocator),
86 myInterfTB(100, myAllocator),
87 myInterfVV(myAllocator),
88 myInterfVE(myAllocator),
89 myInterfVF(myAllocator),
90 myInterfEE(myAllocator),
91 myInterfEF(myAllocator),
92 myInterfFF(myAllocator)
97 //=======================================================================
100 //=======================================================================
101 BOPDS_DS::BOPDS_DS(const Handle(NCollection_BaseAllocator)& theAllocator)
103 myAllocator(theAllocator),
104 myArguments(myAllocator),
105 myRanges(myAllocator),
106 myLines(myAllocator),
107 myMapShapeIndex(100, myAllocator),
108 myPaveBlocksPool(myAllocator),
109 myFaceInfoPool(myAllocator),
110 myShapesSD(100, myAllocator),
111 myInterfTB(100, myAllocator),
112 myInterfVV(myAllocator),
113 myInterfVE(myAllocator),
114 myInterfVF(myAllocator),
115 myInterfEE(myAllocator),
116 myInterfEF(myAllocator),
117 myInterfFF(myAllocator)
122 //=======================================================================
125 //=======================================================================
126 BOPDS_DS::~BOPDS_DS()
130 //=======================================================================
133 //=======================================================================
134 void BOPDS_DS::Clear()
142 myMapShapeIndex.Clear();
143 myPaveBlocksPool.Clear();
144 myFaceInfoPool.Clear();
154 //=======================================================================
155 //function : SetArguments
157 //=======================================================================
158 void BOPDS_DS::SetArguments(const BOPCol_ListOfShape& theLS)
162 //=======================================================================
163 //function : Arguments
165 //=======================================================================
166 const BOPCol_ListOfShape& BOPDS_DS::Arguments()const
170 //=======================================================================
171 //function : Allocator
173 //=======================================================================
174 const Handle(NCollection_BaseAllocator)& BOPDS_DS::Allocator()const
179 //=======================================================================
180 //function : NbShapes
182 //=======================================================================
183 Standard_Integer BOPDS_DS::NbShapes()const
185 return myLines.Size();
187 //=======================================================================
188 //function : NbSourceShapes
190 //=======================================================================
191 Standard_Integer BOPDS_DS::NbSourceShapes()const
193 return myNbSourceShapes;
195 //=======================================================================
196 //function : NbRanges
198 //=======================================================================
199 Standard_Integer BOPDS_DS::NbRanges()const
201 return myRanges.Size();
203 //=======================================================================
206 //=======================================================================
207 const BOPDS_IndexRange& BOPDS_DS::Range(const Standard_Integer theI)const
209 return myRanges(theI);
211 //=======================================================================
214 //=======================================================================
215 Standard_Integer BOPDS_DS::Rank(const Standard_Integer theI)const
217 Standard_Integer i, aNb, iErr;
221 for(i=0; i<aNb; ++i) {
222 const BOPDS_IndexRange& aR=Range(i);
223 if (aR.Contains(theI)) {
229 //=======================================================================
230 //function : IsNewShape
232 //=======================================================================
233 Standard_Boolean BOPDS_DS::IsNewShape(const Standard_Integer theI)const
235 return theI>=NbSourceShapes();
237 //=======================================================================
240 //=======================================================================
241 Standard_Integer BOPDS_DS::Append(const BOPDS_ShapeInfo& theSI)
245 iX=myLines.Append()-1;
249 //=======================================================================
252 //=======================================================================
253 Standard_Integer BOPDS_DS::Append(const TopoDS_Shape& theS)
257 iX=myLines.Append()-1;
258 myLines(iX).SetShape(theS);
261 //=======================================================================
262 //function : ShapeInfo
264 //=======================================================================
265 const BOPDS_ShapeInfo& BOPDS_DS::ShapeInfo(const Standard_Integer theI)const
267 return myLines(theI);
269 //=======================================================================
270 //function : ChangeShapeInfo
272 //=======================================================================
273 BOPDS_ShapeInfo& BOPDS_DS::ChangeShapeInfo(const Standard_Integer theI)
275 BOPDS_ShapeInfo *pSI;
277 const BOPDS_ShapeInfo& aSI=ShapeInfo(theI);
278 pSI=(BOPDS_ShapeInfo *)&aSI;
281 //=======================================================================
284 //=======================================================================
285 const TopoDS_Shape& BOPDS_DS::Shape(const Standard_Integer theI)const
287 const TopoDS_Shape& aS=ShapeInfo(theI).Shape();
290 //=======================================================================
293 //=======================================================================
294 Standard_Integer BOPDS_DS::Index(const TopoDS_Shape& theS)const
296 Standard_Integer iRet;
299 if (myMapShapeIndex.IsBound(theS)) {
300 iRet=myMapShapeIndex.Find(theS);
305 //=======================================================================
308 //=======================================================================
309 void BOPDS_DS::Init()
311 Standard_Integer i1, i2, j, aI, aNb, aNbS, aNbE, aNbSx, nV, nW, nE, aNbF;
313 TopAbs_ShapeEnum aTS;
314 BOPCol_ListIteratorOfListOfInteger aIt1, aIt2, aIt3;
315 BOPCol_ListIteratorOfListOfShape aIt;
317 Handle(NCollection_IncAllocator) aAllocator;
319 // 1 Append Source Shapes
320 aNb=myArguments.Extent();
325 myRanges.SetStartSize(aNb);
328 aIt.Initialize(myArguments);
329 for (; aIt.More(); aIt.Next()) {
330 const TopoDS_Shape& aSx=aIt.Value();
335 aIt.Initialize(myArguments);
336 for (; aIt.More(); aIt.Next()) {
337 const TopoDS_Shape& aSx=aIt.Value();
340 TotalShapes(aSx, aNbSx);
344 myLines.SetStartSize(2*aNbS);
345 myLines.SetIncrement(aNbS);
348 //-----------------------------------------------------scope_1 f
349 aAllocator=new NCollection_IncAllocator();
351 BOPCol_DataMapOfShapeInteger& aMSI=myMapShapeIndex;
355 aIt.Initialize(myArguments);
356 for (; aIt.More(); aIt.Next()) {
357 const TopoDS_Shape& aS=aIt.Value();
361 InitShape(aI, aS, aAllocator, aMSI);
364 aR.SetIndices(i1, i2);
371 myNbSourceShapes=NbShapes();
376 for (j=0; j<myNbSourceShapes; ++j) {
377 BOPDS_ShapeInfo& aSI=ChangeShapeInfo(j);
379 const TopoDS_Shape& aS=aSI.Shape();
384 if (aTS==TopAbs_VERTEX) {
385 Bnd_Box& aBox=aSI.ChangeBox();
386 const TopoDS_Vertex& aV=*((TopoDS_Vertex*)&aS);
387 const gp_Pnt& aP=BRep_Tool::Pnt(aV);
388 aTol=BRep_Tool::Tolerance(aV);
395 for (j=0; j<myNbSourceShapes; ++j) {
396 BOPDS_ShapeInfo& aSI=ChangeShapeInfo(j);
399 if (aTS==TopAbs_EDGE) {
400 const TopoDS_Shape& aS=aSI.Shape();
401 const TopoDS_Edge& aE=*((TopoDS_Edge*)&aS);
402 aTol=BRep_Tool::Tolerance(aE);
404 if (!BRep_Tool::Degenerated(aE)) {
405 Standard_Boolean bInf1, bInf2;
406 Standard_Integer aIx;
407 Standard_Real aT1, aT2;
409 Handle(Geom_Curve) aC3D;
413 BOPDS_ShapeInfo aSIx;
415 BOPCol_ListOfInteger& aLI=aSI.ChangeSubShapes();
418 aEx.Orientation(TopAbs_FORWARD);
420 aC3D=BRep_Tool::Curve (aEx, aT1, aT2);
421 bInf1=Precision::IsNegativeInfinite(aT1);
422 bInf2=Precision::IsPositiveInfinite(aT2);
426 aBB.MakeVertex(aVx, aPx, aTol);
427 aVx.Orientation(TopAbs_FORWARD);
430 aSIx.SetShapeType(TopAbs_VERTEX);
431 aSIx.SetFlag(1); //infinite flag
438 aBB.MakeVertex(aVx, aPx, aTol);
439 aVx.Orientation(TopAbs_REVERSED);
442 aSIx.SetShapeType(TopAbs_VERTEX);
443 aSIx.SetFlag(1);//infinite flag
453 Bnd_Box& aBox=aSI.ChangeBox();
454 BRepBndLib::Add(aE, aBox);
456 const BOPCol_ListOfInteger& aLV=aSI.SubShapes();
457 aIt1.Initialize(aLV);
458 for (; aIt1.More(); aIt1.Next()) {
460 BOPDS_ShapeInfo& aSIV=ChangeShapeInfo(nV);
461 Bnd_Box& aBx=aSIV.ChangeBox();
468 BOPCol_MapOfInteger aMI(100, aAllocator);
469 BOPCol_MapIteratorOfMapOfInteger aItMI;
472 for (j=0; j<myNbSourceShapes; ++j) {
473 BOPDS_ShapeInfo& aSI=ChangeShapeInfo(j);
476 if (aTS==TopAbs_FACE) {
477 const TopoDS_Shape& aS=aSI.Shape();
478 const TopoDS_Face& aF=*((TopoDS_Face*)&aS);
479 aTol=BRep_Tool::Tolerance(aF);
481 Bnd_Box& aBox=aSI.ChangeBox();
482 BRepBndLib::Add(aS, aBox);
484 BOPCol_ListOfInteger& aLW=aSI.ChangeSubShapes();
485 aIt1.Initialize(aLW);
486 for (; aIt1.More(); aIt1.Next()) {
488 BOPDS_ShapeInfo& aSIW=ChangeShapeInfo(nW);
490 const BOPCol_ListOfInteger& aLE=aSIW.SubShapes();
491 aIt2.Initialize(aLE);
492 for (; aIt2.More(); aIt2.Next()) {
494 BOPDS_ShapeInfo& aSIE=ChangeShapeInfo(nE);
495 Bnd_Box& aBx=aSIE.ChangeBox();
499 const TopoDS_Edge& aE=*(TopoDS_Edge*)(&aSIE.Shape());
500 if (BRep_Tool::Degenerated(aE)) {
504 const BOPCol_ListOfInteger& aLV=aSIE.SubShapes();
505 aIt3.Initialize(aLV);
506 for (; aIt3.More(); aIt3.Next()) {
511 }//for (; aIt1.More(); aIt1.Next()) {
514 // For a Face: change wires for BRep sub-shapes
516 aItMI.Initialize(aMI);
517 for (; aItMI.More(); aItMI.Next()) {
523 }//if (aTS==TopAbs_FACE) {
524 }//for (j=0; j<myNbSourceShapes; ++j) {
527 aAllocator.Nullify();
528 //-----------------------------------------------------scope_1 t
530 // 3 myPaveBlocksPool
531 myPaveBlocksPool.SetStartSize(aNbE);
532 myPaveBlocksPool.SetIncrement(aNbE);
533 myPaveBlocksPool.Init();
536 myFaceInfoPool.SetStartSize(aNbF);
537 myFaceInfoPool.SetIncrement(aNbF);
538 myFaceInfoPool.Init();
541 //=======================================================================
542 //function : InitShape
544 //=======================================================================
545 void BOPDS_DS::InitShape(const Standard_Integer aI,
546 const TopoDS_Shape& aS,
547 Handle(NCollection_BaseAllocator)& theAllocator,
548 BOPCol_DataMapOfShapeInteger& aMSI)
550 Standard_Integer aIx;
552 BOPCol_ListIteratorOfListOfInteger aIt1;
554 BOPDS_ShapeInfo& aSI=ChangeShapeInfo(aI);
555 aSI.SetShapeType(aS.ShapeType());
556 BOPCol_ListOfInteger& aLI=aSI.ChangeSubShapes();
558 BOPCol_MapOfInteger aM(100, theAllocator);
560 aIt1.Initialize(aLI);
561 for (; aIt1.More(); aIt1.Next()) {
562 aM.Add(aIt1.Value());
566 for (; aIt.More(); aIt.Next()) {
567 const TopoDS_Shape& aSx=aIt.Value();
568 if (aMSI.IsBound(aSx)) {
576 InitShape(aIx, aSx, theAllocator, aMSI);
584 //=======================================================================
585 //function : HasInterf
587 //=======================================================================
588 Standard_Boolean BOPDS_DS::HasInterf(const Standard_Integer theI) const
590 Standard_Integer n1, n2;
591 Standard_Boolean bRet;
592 BOPDS_MapIteratorMapOfPassKey aIt;
594 bRet = Standard_False;
596 aIt.Initialize(myInterfTB);
597 for (; aIt.More(); aIt.Next()) {
598 const BOPDS_PassKey& aPK = aIt.Value();
600 if (n1 == theI || n2 == theI) {
601 bRet = Standard_True;
609 //=======================================================================
610 //function : HasInterfShapeSubShapes
612 //=======================================================================
613 Standard_Boolean BOPDS_DS::HasInterfShapeSubShapes(const Standard_Integer theI1,
614 const Standard_Integer theI2)const
616 Standard_Boolean bRet;
618 BOPCol_ListIteratorOfListOfInteger aIt;
619 bRet = Standard_False;
621 const BOPDS_ShapeInfo& aSI=ShapeInfo(theI2);
622 const BOPCol_ListOfInteger& aLI=aSI.SubShapes();
624 for (; aIt.More(); aIt.Next()) {
626 bRet=HasInterf(theI1, n2);
634 //=======================================================================
635 //function : HasInterfSubShapes
637 //=======================================================================
638 Standard_Boolean BOPDS_DS::HasInterfSubShapes(const Standard_Integer theI1,
639 const Standard_Integer theI2)const
641 Standard_Boolean bRet;
643 BOPCol_ListIteratorOfListOfInteger aIt;
644 bRet = Standard_False;
646 const BOPDS_ShapeInfo& aSI=ShapeInfo(theI1);
647 const BOPCol_ListOfInteger& aLI=aSI.SubShapes();
649 for (; aIt.More(); aIt.Next()) {
651 bRet=HasInterfShapeSubShapes(n1, theI2);
660 //=======================================================================
661 //function : PaveBlocksPool
663 //=======================================================================
664 const BOPDS_VectorOfListOfPaveBlock& BOPDS_DS::PaveBlocksPool()const
666 return myPaveBlocksPool;
668 //=======================================================================
669 //function : ChangePaveBlocksPool
671 //=======================================================================
672 BOPDS_VectorOfListOfPaveBlock& BOPDS_DS::ChangePaveBlocksPool()
674 return myPaveBlocksPool;
676 //=======================================================================
677 //function : HasPaveBlocks
679 //=======================================================================
680 Standard_Boolean BOPDS_DS::HasPaveBlocks(const Standard_Integer theI)const
682 return ShapeInfo(theI).HasReference();
684 //=======================================================================
685 //function : PaveBlocks
687 //=======================================================================
688 const BOPDS_ListOfPaveBlock& BOPDS_DS::PaveBlocks(const Standard_Integer theI)const
690 static BOPDS_ListOfPaveBlock sLPB;
691 Standard_Integer aRef;
693 if (HasPaveBlocks(theI)) {
694 aRef=ShapeInfo(theI).Reference();
695 const BOPDS_ListOfPaveBlock& aLPB=myPaveBlocksPool(aRef);
700 //=======================================================================
701 //function : ChangePaveBlocks
703 //=======================================================================
704 BOPDS_ListOfPaveBlock& BOPDS_DS::ChangePaveBlocks(const Standard_Integer theI)
706 Standard_Boolean bHasReference;
707 Standard_Integer aRef;
709 BOPDS_ShapeInfo& aSI=ChangeShapeInfo(theI);
710 bHasReference=aSI.HasReference();
711 if (!bHasReference) {
712 InitPaveBlocks(theI);
715 aRef=aSI.Reference();
716 return myPaveBlocksPool(aRef);
718 //=======================================================================
719 //function : InitPaveBlocks
721 //=======================================================================
722 void BOPDS_DS::InitPaveBlocks(const Standard_Integer theI)
724 Standard_Integer nV, iRef, aNbV, nVSD, i;
727 BOPCol_ListIteratorOfListOfInteger aIt;
729 Handle(BOPDS_PaveBlock) aPB;
731 BOPDS_ShapeInfo& aSI=ChangeShapeInfo(theI);
732 const TopoDS_Edge& aE=*(TopoDS_Edge*)(&aSI.Shape());
734 const BOPCol_ListOfInteger& aLV=aSI.SubShapes();
740 aPB=new BOPDS_PaveBlock;
741 aPB->SetOriginalEdge(theI);
744 for (i=0; aIt.More(); aIt.Next(), ++i) {
747 const BOPDS_ShapeInfo& aSIV=ShapeInfo(nV);
748 aV=*(TopoDS_Vertex*)(&aSIV.Shape());
749 if (aSIV.HasFlag()) {
750 aT=ComputeParameter(aV, aE);
753 aT=BRep_Tool::Parameter(aV, aE);
756 if (HasShapeSD(nV, nVSD)) {
760 aPave.SetParameter(aT);
761 aPB->AppendExtPave(aPave);
766 aT=BRep_Tool::Parameter(aV, aE);
768 aPave.SetParameter(aT);
769 aPB->AppendExtPave1(aPave);
772 iRef = myPaveBlocksPool.Append() - 1;
773 BOPDS_ListOfPaveBlock &aLPB=myPaveBlocksPool(iRef);
775 aPB->Update(aLPB, Standard_False);
776 aSI.SetReference(iRef);
778 //=======================================================================
779 //function : UpdatePaveBlocks
781 //=======================================================================
782 void BOPDS_DS::UpdatePaveBlocks()
784 Standard_Boolean bIsToUpdate;
785 Standard_Integer i, aNbPBP;
786 BOPDS_ListOfPaveBlock aLPBN(myAllocator);
787 BOPDS_ListIteratorOfListOfPaveBlock aItPB, aItPBN;
789 BOPDS_VectorOfListOfPaveBlock& aPBP=myPaveBlocksPool;
792 for (i=0; i<aNbPBP; ++i) {
793 BOPDS_ListOfPaveBlock& aLPB=aPBP(i);
795 aItPB.Initialize(aLPB);
796 for (; aItPB.More(); aItPB.Next()) {
797 Handle(BOPDS_PaveBlock)& aPB=aItPB.ChangeValue();
799 bIsToUpdate=aPB->IsToUpdate();
804 aItPBN.Initialize(aLPBN);
805 for (; aItPBN.More(); aItPBN.Next()) {
806 Handle(BOPDS_PaveBlock)& aPBN=aItPBN.ChangeValue();
811 }// for (; aItPB.More(); aItPB.Next()) {
812 }// for (i=0; i<aNbPBP; ++i) {
814 //=======================================================================
815 //function : UpdatePaveBlock
817 //=======================================================================
818 void BOPDS_DS::UpdatePaveBlock(const Handle(BOPDS_PaveBlock)& thePB)
820 if (!thePB->IsToUpdate()){
824 Standard_Integer nE, iRef;
825 BOPDS_ListIteratorOfListOfPaveBlock aItPB, aItPBN;
826 BOPDS_ListOfPaveBlock aLPBN(myAllocator);
827 Handle(BOPDS_PaveBlock) aPB;
829 BOPDS_VectorOfListOfPaveBlock& aPBP=myPaveBlocksPool;
831 nE=thePB->OriginalEdge();
832 BOPDS_ShapeInfo& aSI=ChangeShapeInfo(nE);
833 iRef=aSI.Reference();
834 BOPDS_ListOfPaveBlock& aLPB=aPBP(iRef);
836 aItPB.Initialize(aLPB);
837 for (; aItPB.More(); aItPB.Next()) {
838 aPB=aItPB.ChangeValue();
842 aItPBN.Initialize(aLPBN);
843 for (; aItPBN.More(); aItPBN.Next()) {
844 Handle(BOPDS_PaveBlock)& aPBN=aItPBN.ChangeValue();
852 //=======================================================================
853 //function : UpdateCommonBlock
855 //=======================================================================
856 void BOPDS_DS::UpdateCommonBlock(const Handle(BOPDS_CommonBlock)& theCB)
858 Standard_Integer nE, iRef, n1, n2;
859 BOPDS_ListIteratorOfListOfPaveBlock aItPB, aItPBCB, aItPBN;
860 BOPDS_DataMapIteratorOfDataMapOfPassKeyListOfPaveBlock aItMPKLPB;
861 BOPDS_ListOfPaveBlock aLPBN;
862 BOPDS_DataMapOfPassKeyListOfPaveBlock aMPKLPB;
863 Handle(BOPDS_PaveBlock) aPB;
864 Handle(BOPDS_CommonBlock) aCBx;
867 const BOPDS_ListOfPaveBlock& aLPBCB=theCB->PaveBlocks();
868 if (!aLPBCB.First()->IsToUpdate()){
872 const BOPCol_ListOfInteger& aLF=theCB->Faces();
874 BOPDS_VectorOfListOfPaveBlock& aPBP=myPaveBlocksPool;
876 aItPBCB.Initialize(aLPBCB);
877 for (; aItPBCB.More(); aItPBCB.Next()) {
878 const Handle(BOPDS_PaveBlock)& aPBCB=aItPBCB.ChangeValue();
880 nE=aPBCB->OriginalEdge();
881 iRef=ChangeShapeInfo(nE).Reference();
882 BOPDS_ListOfPaveBlock& aLPB=aPBP(iRef);
884 aItPB.Initialize(aLPB);
885 for (; aItPB.More(); aItPB.Next()) {
886 aPB=aItPB.ChangeValue();
892 aItPBN.Initialize(aLPBN);
893 for (; aItPBN.More(); aItPBN.Next()) {
894 Handle(BOPDS_PaveBlock)& aPBN=aItPBN.ChangeValue();
897 aPBN->Indices(n1, n2);
899 if (aMPKLPB.IsBound(aPK)) {
900 BOPDS_ListOfPaveBlock& aLPBx=aMPKLPB.ChangeFind(aPK);
904 BOPDS_ListOfPaveBlock aLPBx;
906 aMPKLPB.Bind(aPK, aLPBx);
915 aItMPKLPB.Initialize(aMPKLPB);
916 for (; aItMPKLPB.More(); aItMPKLPB.Next()) {
917 BOPDS_ListOfPaveBlock& aLPBx=aItMPKLPB.ChangeValue();
919 while (aLPBx.Extent()) {
920 Standard_Boolean bCoinside;
921 Standard_Real aTol, aTolMax(0.);
922 BOPDS_ListOfPaveBlock aLPBxN;
924 aItPB.Initialize(aLPBx);
925 for(; aItPB.More(); ) {
926 const Handle(BOPDS_PaveBlock)& aPBx=aItPB.Value();
927 if (aLPBxN.Extent()) {
928 const Handle(BOPDS_PaveBlock)& aPBCx = aLPBxN.First();
929 bCoinside = CheckCoincidence(aPBx, aPBCx);
931 nE = aPBx->OriginalEdge();
932 const TopoDS_Edge& aE = *(TopoDS_Edge*)&Shape(nE);
933 aTol = BRep_Tool::Tolerance(aE);
935 //pave block with the max tolerance of the original edge
936 //must be the first in the common block
937 if (aTolMax < aTol) {
939 aLPBxN.Prepend(aPBx);
946 }//if (aLPBxN.Extent()) {
948 nE = aPBx->OriginalEdge();
949 const TopoDS_Edge& aE = *(TopoDS_Edge*)&Shape(nE);
950 aTolMax = BRep_Tool::Tolerance(aE);
957 }//for(; aItPB.More(); ) {
959 aCBx=new BOPDS_CommonBlock;
960 aCBx->AddPaveBlocks(aLPBxN);
963 aItPB.Initialize(aLPBxN);
964 for (; aItPB.More(); aItPB.Next()) {
965 aPB=aItPB.ChangeValue();
966 aPB->SetCommonBlock(aCBx);
975 //=======================================================================
976 //function : FaceInfoPool
978 //=======================================================================
979 const BOPDS_VectorOfFaceInfo& BOPDS_DS::FaceInfoPool()const
981 return myFaceInfoPool;
983 //=======================================================================
984 //function : HasFaceInfo
986 //=======================================================================
987 Standard_Boolean BOPDS_DS::HasFaceInfo(const Standard_Integer theI)const
989 return ShapeInfo(theI).HasReference();
991 //=======================================================================
992 //function : FaceInfo
994 //=======================================================================
995 const BOPDS_FaceInfo& BOPDS_DS::FaceInfo(const Standard_Integer theI)const
997 static BOPDS_FaceInfo sFI;
998 Standard_Integer aRef;
1000 if (HasFaceInfo(theI)) {
1001 aRef=ShapeInfo(theI).Reference();
1002 const BOPDS_FaceInfo& aFI=myFaceInfoPool(aRef);
1007 //=======================================================================
1008 //function : ChangeFaceInfo
1010 //=======================================================================
1011 BOPDS_FaceInfo& BOPDS_DS::ChangeFaceInfo(const Standard_Integer theI)
1013 Standard_Boolean bHasReference;
1014 Standard_Integer aRef;
1015 BOPDS_FaceInfo* pFI;
1017 BOPDS_ShapeInfo& aSI=ChangeShapeInfo(theI);
1018 bHasReference=aSI.HasReference();
1019 if (!bHasReference) {
1023 aRef=aSI.Reference();
1024 const BOPDS_FaceInfo& aFI=myFaceInfoPool(aRef);
1025 pFI=(BOPDS_FaceInfo*)&aFI;
1028 //=======================================================================
1029 //function : InitFaceInfo
1031 //=======================================================================
1032 void BOPDS_DS::InitFaceInfo(const Standard_Integer theI)
1034 Standard_Integer iRef;
1036 BOPDS_ShapeInfo& aSI=ChangeShapeInfo(theI);
1037 iRef=myFaceInfoPool.Append()-1;
1038 BOPDS_FaceInfo &aFI=myFaceInfoPool(iRef);
1039 aSI.SetReference(iRef);
1042 UpdateFaceInfoIn(theI);
1043 UpdateFaceInfoOn(theI);
1045 //=======================================================================
1046 //function : UpdateFaceInfoIn
1048 //=======================================================================
1049 void BOPDS_DS::UpdateFaceInfoIn(const Standard_Integer theI)
1051 Standard_Integer iRef;
1053 BOPDS_ShapeInfo& aSI=ChangeShapeInfo(theI);
1054 if (aSI.HasReference()) {
1055 iRef=aSI.Reference();
1056 BOPDS_FaceInfo &aFI=myFaceInfoPool(iRef);
1058 BOPDS_IndexedMapOfPaveBlock& aMPBIn=aFI.ChangePaveBlocksIn();
1059 BOPCol_MapOfInteger& aMVIn=aFI.ChangeVerticesIn();
1062 FaceInfoIn(theI, aMPBIn, aMVIn);
1065 //=======================================================================
1066 //function : UpdateFaceInfoOn
1068 //=======================================================================
1069 void BOPDS_DS::UpdateFaceInfoOn(const Standard_Integer theI)
1071 Standard_Integer iRef;
1073 BOPDS_ShapeInfo& aSI=ChangeShapeInfo(theI);
1074 if (aSI.HasReference()) {
1075 iRef=aSI.Reference();
1076 BOPDS_FaceInfo &aFI=myFaceInfoPool(iRef);
1078 BOPDS_IndexedMapOfPaveBlock& aMPBOn=aFI.ChangePaveBlocksOn();
1079 BOPCol_MapOfInteger& aMVOn=aFI.ChangeVerticesOn();
1082 FaceInfoOn(theI, aMPBOn, aMVOn);
1085 //=======================================================================
1086 //function : FaceInfoOn
1088 //=======================================================================
1089 void BOPDS_DS::FaceInfoOn(const Standard_Integer theF,
1090 BOPDS_IndexedMapOfPaveBlock& theMPB,
1091 BOPCol_MapOfInteger& theMI)
1093 Standard_Integer nS, nSD, nV1, nV2;
1094 BOPCol_ListIteratorOfListOfInteger aIt;
1095 BOPDS_ListIteratorOfListOfPaveBlock aItPB;
1097 const BOPDS_ShapeInfo& aSI=ShapeInfo(theF);
1098 const BOPCol_ListOfInteger& aLI=aSI.SubShapes();
1099 aIt.Initialize(aLI);
1100 for (; aIt.More(); aIt.Next()) {
1102 const BOPDS_ShapeInfo& aSIE=ShapeInfo(nS);
1103 if (aSIE.ShapeType()==TopAbs_EDGE) {
1104 const BOPDS_ListOfPaveBlock& aLPB=PaveBlocks(nS);
1105 aItPB.Initialize(aLPB);
1106 for (; aItPB.More(); aItPB.Next()) {
1107 const Handle(BOPDS_PaveBlock)& aPB=aItPB.Value();
1108 aPB->Indices(nV1, nV2);
1111 if (aPB->IsCommonBlock()) {
1112 const Handle(BOPDS_CommonBlock)& aCB=aPB->CommonBlock();
1113 const Handle(BOPDS_PaveBlock)& aPB1=aCB->PaveBlock1();
1120 }//if (aSIE.ShapeType()==TopAbs_EDGE)
1122 // nE is TopAbs_VERTEX
1123 if (HasShapeSD(nS, nSD)) {
1130 //=======================================================================
1131 //function : FaceInfoIn
1133 //=======================================================================
1134 void BOPDS_DS::FaceInfoIn(const Standard_Integer theF,
1135 BOPDS_IndexedMapOfPaveBlock& theMPB,
1136 BOPCol_MapOfInteger& theMI)
1138 Standard_Integer i, aNbVF, aNbEF, nV, nE;
1139 BOPDS_ListIteratorOfListOfPaveBlock aItPB;
1141 BOPDS_VectorOfInterfVF& aVFs=InterfVF();
1142 aNbVF=aVFs.Extent();
1143 for (i=0; i<aNbVF; ++i) {
1144 BOPDS_InterfVF& aVF=aVFs(i);
1145 if(aVF.Contains(theF)) {
1146 nV=aVF.OppositeIndex(theF);
1151 BOPDS_VectorOfInterfEF& aEFs=InterfEF();
1152 aNbEF=aEFs.Extent();
1153 for (i=0; i<aNbEF; ++i) {
1154 BOPDS_InterfEF& aEF=aEFs(i);
1155 if(aEF.Contains(theF)) {
1156 if(aEF.HasIndexNew(nV)) {
1160 nE=aEF.OppositeIndex(theF);
1161 const BOPDS_ListOfPaveBlock& aLPB=PaveBlocks(nE);
1162 aItPB.Initialize(aLPB);
1163 for (; aItPB.More(); aItPB.Next()) {
1164 const Handle(BOPDS_PaveBlock)& aPB=aItPB.Value();
1165 if (aPB->IsCommonBlock()) {
1166 const Handle(BOPDS_CommonBlock)& aCB=aPB->CommonBlock();
1167 if (aCB->Contains(theF)) {
1168 const Handle(BOPDS_PaveBlock)& aPB1=aCB->PaveBlock1();
1172 }// for (; aItPB.More(); aItPB.Next()) {
1174 }// if(aEF.Contains(theF)) {
1175 }// for (i=0; i<aNbEF; ++i) {
1178 //=======================================================================
1179 //function : RefineFaceInfoOn
1181 //=======================================================================
1182 void BOPDS_DS::RefineFaceInfoOn()
1184 Standard_Integer i, aNb, nF, aNbPB, j;
1185 BOPDS_IndexedMapOfPaveBlock aMPB;
1187 aNb=myFaceInfoPool.Extent();
1188 for (i=0; i<aNb; ++i) {
1189 BOPDS_FaceInfo &aFI=myFaceInfoPool(i);
1191 UpdateFaceInfoOn(nF);
1192 BOPDS_IndexedMapOfPaveBlock& aMPBOn=aFI.ChangePaveBlocksOn();
1195 aMPB.Assign(aMPBOn);
1198 aNbPB=aMPB.Extent();
1199 for (j=1; j<=aNbPB; ++j) {
1200 const Handle(BOPDS_PaveBlock)& aPB=aMPB(j);
1201 if (aPB->HasEdge()) {
1207 //=======================================================================
1208 //function : AloneVertices
1210 //=======================================================================
1211 void BOPDS_DS::AloneVertices(const Standard_Integer theI,
1212 BOPCol_ListOfInteger& theLI)const
1214 if (HasFaceInfo(theI)) {
1216 Standard_Integer i, nV1, nV2, nV;
1217 BOPDS_MapIteratorOfMapOfPaveBlock aItMPB;
1218 BOPCol_MapIteratorOfMapOfInteger aItMI;
1220 BOPCol_MapOfInteger aMI(100, myAllocator);
1222 const BOPDS_FaceInfo& aFI=FaceInfo(theI);
1224 for (i=0; i<2; ++i) {
1225 const BOPDS_IndexedMapOfPaveBlock& aMPB=(!i) ? aFI.PaveBlocksIn() : aFI.PaveBlocksSc();
1226 aItMPB.Initialize(aMPB);
1227 for (; aItMPB.More(); aItMPB.Next()) {
1228 const Handle(BOPDS_PaveBlock)& aPB=aItMPB.Value();
1229 aPB->Indices(nV1, nV2);
1235 for (i=0; i<2; ++i) {
1236 const BOPCol_MapOfInteger& aMIV=(!i) ? aFI.VerticesIn() : aFI.VerticesSc();
1237 aItMI.Initialize(aMIV);
1238 for (; aItMI.More(); aItMI.Next()) {
1250 //=======================================================================
1251 //function : VerticesOnIn
1253 //=======================================================================
1254 void BOPDS_DS::VerticesOnIn(const Standard_Integer nF1,
1255 const Standard_Integer nF2,
1256 BOPCol_MapOfInteger& aMI,
1257 BOPDS_MapOfPaveBlock& aMPB)const
1259 Standard_Integer nV, nV1, nV2;
1260 BOPCol_MapIteratorOfMapOfInteger aIt;
1261 BOPDS_MapIteratorOfMapOfPaveBlock aItMPB;
1263 const BOPDS_FaceInfo& aFI1=FaceInfo(nF1);
1264 const BOPDS_FaceInfo& aFI2=FaceInfo(nF2);
1266 const BOPDS_IndexedMapOfPaveBlock& aMPBOn1=aFI1.PaveBlocksOn();
1267 aItMPB.Initialize(aMPBOn1);
1268 for (; aItMPB.More(); aItMPB.Next()) {
1269 const Handle(BOPDS_PaveBlock)& aPB=aItMPB.Value();
1271 aPB->Indices(nV1, nV2);
1276 const BOPDS_IndexedMapOfPaveBlock& aMPBIn1=aFI1.PaveBlocksIn();
1277 aItMPB.Initialize(aMPBIn1);
1278 for (; aItMPB.More(); aItMPB.Next()) {
1279 const Handle(BOPDS_PaveBlock)& aPB=aItMPB.Value();
1281 aPB->Indices(nV1, nV2);
1286 const BOPDS_IndexedMapOfPaveBlock& aMPBOn2=aFI2.PaveBlocksOn();
1287 aItMPB.Initialize(aMPBOn2);
1288 for (; aItMPB.More(); aItMPB.Next()) {
1289 const Handle(BOPDS_PaveBlock)& aPB=aItMPB.Value();
1291 aPB->Indices(nV1, nV2);
1296 const BOPDS_IndexedMapOfPaveBlock& aMPBIn2=aFI2.PaveBlocksIn();
1297 aItMPB.Initialize(aMPBIn2);
1298 for (; aItMPB.More(); aItMPB.Next()) {
1299 const Handle(BOPDS_PaveBlock)& aPB=aItMPB.Value();
1301 aPB->Indices(nV1, nV2);
1306 const BOPCol_MapOfInteger& aMVOn1=aFI1.VerticesOn();
1307 aIt.Initialize(aMVOn1);
1308 for (; aIt.More(); aIt.Next()) {
1313 const BOPCol_MapOfInteger& aMVIn1=aFI1.VerticesIn();
1314 aIt.Initialize(aMVOn1);
1315 for (; aIt.More(); aIt.Next()) {
1320 const BOPCol_MapOfInteger& aMVOn2=aFI2.VerticesOn();
1321 aIt.Initialize(aMVOn2);
1322 for (; aIt.More(); aIt.Next()) {
1327 const BOPCol_MapOfInteger& aMVIn2=aFI2.VerticesIn();
1328 aIt.Initialize(aMVOn1);
1329 for (; aIt.More(); aIt.Next()) {
1334 //=======================================================================
1335 //function : SharedEdges
1337 //=======================================================================
1338 void BOPDS_DS::SharedEdges(const Standard_Integer nF1,
1339 const Standard_Integer nF2,
1340 BOPCol_ListOfInteger& theLI,
1341 const Handle(NCollection_BaseAllocator)& aAllocator)
1343 Standard_Integer nE, nSp;
1344 BOPCol_ListIteratorOfListOfInteger aItLI;
1345 BOPDS_ListIteratorOfListOfPaveBlock aItLPB;
1346 BOPCol_MapOfInteger aMI(100, aAllocator);
1348 const BOPDS_ShapeInfo& aSI1=ShapeInfo(nF1);
1349 const BOPCol_ListOfInteger& aLI1=aSI1.SubShapes();
1350 aItLI.Initialize(aLI1);
1351 for (; aItLI.More(); aItLI.Next()) {
1353 const BOPDS_ShapeInfo& aSIE=ChangeShapeInfo(nE);
1354 if(aSIE.ShapeType()==TopAbs_EDGE) {
1355 const BOPDS_ListOfPaveBlock& aLPB=PaveBlocks(nE);
1356 if (aLPB.IsEmpty()) {
1360 aItLPB.Initialize(aLPB);
1361 for (; aItLPB.More(); aItLPB.Next()) {
1362 const Handle(BOPDS_PaveBlock) aPB=aItLPB.Value()->RealPaveBlock();
1370 const BOPDS_ShapeInfo& aSI2=ShapeInfo(nF2);
1371 const BOPCol_ListOfInteger& aLI2=aSI2.SubShapes();
1372 aItLI.Initialize(aLI2);
1373 for (; aItLI.More(); aItLI.Next()) {
1375 const BOPDS_ShapeInfo& aSIE=ChangeShapeInfo(nE);
1376 if(aSIE.ShapeType()==TopAbs_EDGE) {
1377 const BOPDS_ListOfPaveBlock& aLPB=PaveBlocks(nE);
1378 if (aLPB.IsEmpty()) {
1379 if (aMI.Contains(nE)) {
1384 aItLPB.Initialize(aLPB);
1385 for (; aItLPB.More(); aItLPB.Next()) {
1386 const Handle(BOPDS_PaveBlock) aPB=aItLPB.Value()->RealPaveBlock();
1388 if (aMI.Contains(nSp)) {
1397 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1399 // same domain shapes
1401 //=======================================================================
1402 //function : ShapesSD
1404 //=======================================================================
1405 BOPCol_DataMapOfIntegerInteger& BOPDS_DS::ShapesSD()
1409 //=======================================================================
1410 //function : AddShapeSD
1412 //=======================================================================
1413 void BOPDS_DS::AddShapeSD(const Standard_Integer theIndex,
1414 const Standard_Integer theIndexSD)
1416 myShapesSD.Bind(theIndex, theIndexSD);
1418 //=======================================================================
1419 //function : HasShapeSD
1421 //=======================================================================
1422 Standard_Boolean BOPDS_DS::HasShapeSD(const Standard_Integer theIndex,
1423 Standard_Integer& theIndexSD)const
1425 Standard_Boolean bRet;
1427 bRet=myShapesSD.IsBound(theIndex);
1429 theIndexSD=myShapesSD.Find(theIndex);
1433 //=======================================================================
1436 //=======================================================================
1437 void BOPDS_DS::Dump()const
1439 Standard_Integer i, aNb, aNbSS;
1441 printf(" *** DS ***\n");
1443 printf(" Ranges:%d\n", aNb);
1444 for (i=0; i<aNb; ++i) {
1445 const BOPDS_IndexRange& aR=Range(i);
1450 aNbSS=NbSourceShapes();
1451 printf(" Shapes:%d\n", aNbSS);
1453 for (i=0; i<aNb; ++i) {
1454 const BOPDS_ShapeInfo& aSI=ShapeInfo(i);
1459 printf(" ****** adds\n");
1462 printf(" ******\n");
1465 //=======================================================================
1466 // function: CheckCoincidence
1468 //=======================================================================
1469 Standard_Boolean BOPDS_DS::CheckCoincidence(const Handle(BOPDS_PaveBlock)& aPB1,
1470 const Handle(BOPDS_PaveBlock)& aPB2)
1472 Standard_Boolean bRet;
1473 Standard_Integer nE1, nE2, aNbPoints;
1474 Standard_Real aT11, aT12, aT21, aT22, aT1m, aD, aTol, aT2x;
1477 bRet=Standard_False;
1479 aPB1->Range(aT11, aT12);
1480 aT1m=IntTools_Tools::IntermediatePoint (aT11, aT12);
1481 nE1=aPB1->OriginalEdge();
1482 const TopoDS_Edge& aE1=(*(TopoDS_Edge*)(&Shape(nE1)));
1483 BOPTools_AlgoTools::PointOnEdge(aE1, aT1m, aP1m);
1485 aPB2->Range(aT21, aT22);
1486 nE2=aPB2->OriginalEdge();
1487 const TopoDS_Edge& aE2=(*(TopoDS_Edge*)(&Shape(nE2)));
1490 Handle(Geom_Curve)aC2 = BRep_Tool::Curve (aE2, f, l);
1491 GeomAPI_ProjectPointOnCurve aPPC;
1492 aPPC.Init(aC2, f, l);
1494 aNbPoints=aPPC.NbPoints();
1496 aD=aPPC.LowerDistance();
1498 aTol=BRep_Tool::Tolerance(aE1);
1499 aTol=aTol+BRep_Tool::Tolerance(aE2);
1501 aT2x=aPPC.LowerDistanceParameter();
1502 if (aT2x>aT21 && aT2x<aT22) {
1510 //=======================================================================
1511 // function: SortPaveBlocks
1513 //=======================================================================
1514 void BOPDS_DS::SortPaveBlocks(const Handle(BOPDS_CommonBlock)& aCB)
1516 Standard_Integer theI;
1517 Standard_Boolean bToSort;
1518 bToSort = IsToSort(aCB, theI);
1523 Standard_Integer i(0);
1524 const BOPDS_ListOfPaveBlock& aLPB = aCB->PaveBlocks();
1525 BOPDS_ListOfPaveBlock aLPBN = aLPB;
1527 Handle(BOPDS_PaveBlock) aPB;
1528 BOPDS_ListIteratorOfListOfPaveBlock aIt;
1530 aIt.Initialize(aLPBN);
1531 for (aIt.Next(); aIt.More(); ) {
1542 aCB->AddPaveBlocks(aLPBN);
1545 //=======================================================================
1546 // function: IsToSort
1548 //=======================================================================
1549 Standard_Boolean BOPDS_DS::IsToSort(const Handle(BOPDS_CommonBlock)& aCB,
1550 Standard_Integer& theI)
1552 Standard_Boolean bRet;
1553 bRet = Standard_False;
1554 const BOPDS_ListOfPaveBlock& aLPB = aCB->PaveBlocks();
1555 if (aLPB.Extent()==1) {
1559 Standard_Integer nE;
1560 Standard_Real aTolMax, aTol;
1561 Handle(BOPDS_PaveBlock) aPB;
1563 BOPDS_ListIteratorOfListOfPaveBlock aIt;
1566 nE = aPB->OriginalEdge();
1567 aE = (*(TopoDS_Edge *)(&Shape(nE)));
1568 aTolMax = BRep_Tool::Tolerance(aE);
1571 aIt.Initialize(aLPB);
1572 for (aIt.Next(); aIt.More(); aIt.Next()) {
1575 nE = aPB->OriginalEdge();
1576 aE = (*(TopoDS_Edge *)(&Shape(nE)));
1577 aTol = BRep_Tool::Tolerance(aE);
1578 if (aTolMax < aTol) {
1580 bRet = Standard_True;
1587 //=======================================================================
1588 // function: IsSubShape
1590 //=======================================================================
1591 Standard_Boolean BOPDS_DS::IsSubShape(const Standard_Integer theI1,
1592 const Standard_Integer theI2)
1594 Standard_Boolean bRet;
1595 Standard_Integer nS;
1596 bRet = Standard_False;
1598 BOPCol_ListIteratorOfListOfInteger aItLI;
1600 const BOPDS_ShapeInfo& aSI = ShapeInfo(theI2);
1601 const BOPCol_ListOfInteger& aLI = aSI.SubShapes();
1602 aItLI.Initialize(aLI);
1603 for(;aItLI.More(); aItLI.Next()) {
1606 bRet = Standard_True;
1614 //=======================================================================
1617 //=======================================================================
1618 void BOPDS_DS::Paves(const Standard_Integer theEdge,
1619 BOPDS_ListOfPave& theLP)
1621 Standard_Integer aNb, i;
1623 BOPDS_ListIteratorOfListOfPaveBlock aIt;
1624 BOPDS_MapOfPave aMP;
1626 const BOPDS_ListOfPaveBlock& aLPB = PaveBlocks(theEdge);
1627 aNb = aLPB.Extent();
1628 aNb = (aNb==0) ? 0 : (aNb+1);
1630 pPaves=(BOPDS_Pave *)myAllocator->Allocate(aNb*sizeof(BOPDS_Pave));
1631 for (i=0; i<aNb; ++i) {
1632 new (pPaves+i) BOPDS_Pave();
1636 for (aIt.Initialize(aLPB); aIt.More(); aIt.Next()) {
1637 const Handle(BOPDS_PaveBlock)& aPB = aIt.Value();
1638 if (aMP.Add(aPB->Pave1())){
1639 pPaves[i] = aPB->Pave1();
1642 if (aMP.Add(aPB->Pave2())){
1643 pPaves[i] = aPB->Pave2();
1648 SortShell(aNb, pPaves);
1650 for (i = 0; i < aNb; ++i) {
1651 theLP.Append(pPaves[i]);
1655 //=======================================================================
1656 // function: UpdateTolerance
1658 //=======================================================================
1659 void BOPDS_DS::UpdateEdgeTolerance(const Standard_Integer nE,
1660 const Standard_Real aTol)
1662 Standard_Integer nV;
1663 Standard_Real aTolV;
1665 BOPCol_ListIteratorOfListOfInteger aIt;
1667 const TopoDS_Edge& aE = *(TopoDS_Edge*)&Shape(nE);
1668 aBB.UpdateEdge(aE, aTol);
1669 BOPDS_ShapeInfo& aSIE=ChangeShapeInfo(nE);
1670 Bnd_Box& aBoxE=aSIE.ChangeBox();
1671 BRepBndLib::Add(aE, aBoxE);
1673 const BOPCol_ListOfInteger& aLI = aSIE.SubShapes();
1674 aIt.Initialize(aLI);
1675 for (; aIt.More(); aIt.Next()) {
1677 const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&Shape(nV);
1678 aTolV = BRep_Tool::Tolerance(aV);
1680 aBB.UpdateVertex(aV, aTol);
1681 BOPDS_ShapeInfo& aSIV = ChangeShapeInfo(nV);
1682 Bnd_Box& aBoxV = aSIV.ChangeBox();
1683 BRepBndLib::Add(aV, aBoxV);
1688 //=======================================================================
1689 //function : TotalShapes
1691 //=======================================================================
1692 void TotalShapes(const TopoDS_Shape& aS,
1693 Standard_Integer& aNbS)
1697 pS=(TopoDS_Shape *)&aS;
1698 if (!pS->Checked()) {
1699 TopoDS_Iterator aIt;
1704 for (; aIt.More(); aIt.Next()) {
1705 const TopoDS_Shape& aSx=aIt.Value();
1706 TotalShapes(aSx, aNbS);
1710 //=======================================================================
1711 //function : ResetShape
1713 //=======================================================================
1714 void ResetShape(const TopoDS_Shape& aS)
1718 pS=(TopoDS_Shape *)&aS;
1721 //=======================================================================
1722 //function : ResetShape
1724 //=======================================================================
1725 void ResetShapes(const TopoDS_Shape& aS)
1727 TopoDS_Iterator aIt;
1731 for (; aIt.More(); aIt.Next()) {
1732 const TopoDS_Shape& aSx=aIt.Value();
1736 #include <Geom_Curve.hxx>
1738 //=======================================================================
1739 //function : ComputeParameter
1741 //=======================================================================
1742 Standard_Real ComputeParameter(const TopoDS_Vertex& aV,
1743 const TopoDS_Edge& aE)
1745 Standard_Real aT1, aT2, aTRet, aTolE2, aD2;
1747 Handle(Geom_Curve) aC3D;
1751 aEE.Orientation(TopAbs_FORWARD);
1755 aTolE2=BRep_Tool::Tolerance(aE);
1756 aTolE2=aTolE2*aTolE2;
1758 aPV=BRep_Tool::Pnt(aV);
1760 aC3D=BRep_Tool::Curve (aEE, aT1, aT2);
1763 aD2=aPC.SquareDistance(aPV);
1769 aD2=aPC.SquareDistance(aPV);
1776 //=======================================================================
1777 // function: SortShell
1779 //=======================================================================
1780 void SortShell(const int n, BOPDS_Pave *a)
1782 int nd, i, j, l, d=1;
1793 for (i=0; i<nd; ++i) {
1802 if (j > -1) goto m30;
1803 }//if (a[l] < a[j]){
1804 }//for (i=0; i<nd; ++i)