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 myMapPBCB(100, myAllocator),
85 myFaceInfoPool(myAllocator),
86 myShapesSD(100, myAllocator),
87 myInterfTB(100, myAllocator),
88 myInterfVV(myAllocator),
89 myInterfVE(myAllocator),
90 myInterfVF(myAllocator),
91 myInterfEE(myAllocator),
92 myInterfEF(myAllocator),
93 myInterfFF(myAllocator)
98 //=======================================================================
101 //=======================================================================
102 BOPDS_DS::BOPDS_DS(const Handle(NCollection_BaseAllocator)& theAllocator)
104 myAllocator(theAllocator),
105 myArguments(myAllocator),
106 myRanges(myAllocator),
107 myLines(myAllocator),
108 myMapShapeIndex(100, myAllocator),
109 myPaveBlocksPool(myAllocator),
110 myMapPBCB(100, myAllocator),
111 myFaceInfoPool(myAllocator),
112 myShapesSD(100, myAllocator),
113 myInterfTB(100, myAllocator),
114 myInterfVV(myAllocator),
115 myInterfVE(myAllocator),
116 myInterfVF(myAllocator),
117 myInterfEE(myAllocator),
118 myInterfEF(myAllocator),
119 myInterfFF(myAllocator)
124 //=======================================================================
127 //=======================================================================
128 BOPDS_DS::~BOPDS_DS()
132 //=======================================================================
135 //=======================================================================
136 void BOPDS_DS::Clear()
144 myMapShapeIndex.Clear();
145 myPaveBlocksPool.Clear();
146 myFaceInfoPool.Clear();
157 //=======================================================================
158 //function : SetArguments
160 //=======================================================================
161 void BOPDS_DS::SetArguments(const BOPCol_ListOfShape& theLS)
165 //=======================================================================
166 //function : Arguments
168 //=======================================================================
169 const BOPCol_ListOfShape& BOPDS_DS::Arguments()const
173 //=======================================================================
174 //function : Allocator
176 //=======================================================================
177 const Handle(NCollection_BaseAllocator)& BOPDS_DS::Allocator()const
182 //=======================================================================
183 //function : NbShapes
185 //=======================================================================
186 Standard_Integer BOPDS_DS::NbShapes()const
188 return myLines.Size();
190 //=======================================================================
191 //function : NbSourceShapes
193 //=======================================================================
194 Standard_Integer BOPDS_DS::NbSourceShapes()const
196 return myNbSourceShapes;
198 //=======================================================================
199 //function : NbRanges
201 //=======================================================================
202 Standard_Integer BOPDS_DS::NbRanges()const
204 return myRanges.Size();
206 //=======================================================================
209 //=======================================================================
210 const BOPDS_IndexRange& BOPDS_DS::Range(const Standard_Integer theI)const
212 return myRanges(theI);
214 //=======================================================================
217 //=======================================================================
218 Standard_Integer BOPDS_DS::Rank(const Standard_Integer theI)const
220 Standard_Integer i, aNb, iErr;
224 for(i=0; i<aNb; ++i) {
225 const BOPDS_IndexRange& aR=Range(i);
226 if (aR.Contains(theI)) {
232 //=======================================================================
233 //function : IsNewShape
235 //=======================================================================
236 Standard_Boolean BOPDS_DS::IsNewShape(const Standard_Integer theI)const
238 return theI>=NbSourceShapes();
240 //=======================================================================
243 //=======================================================================
244 Standard_Integer BOPDS_DS::Append(const BOPDS_ShapeInfo& theSI)
248 iX=myLines.Append()-1;
252 //=======================================================================
255 //=======================================================================
256 Standard_Integer BOPDS_DS::Append(const TopoDS_Shape& theS)
260 iX=myLines.Append()-1;
261 myLines(iX).SetShape(theS);
264 //=======================================================================
265 //function : ShapeInfo
267 //=======================================================================
268 const BOPDS_ShapeInfo& BOPDS_DS::ShapeInfo(const Standard_Integer theI)const
270 return myLines(theI);
272 //=======================================================================
273 //function : ChangeShapeInfo
275 //=======================================================================
276 BOPDS_ShapeInfo& BOPDS_DS::ChangeShapeInfo(const Standard_Integer theI)
278 BOPDS_ShapeInfo *pSI;
280 const BOPDS_ShapeInfo& aSI=ShapeInfo(theI);
281 pSI=(BOPDS_ShapeInfo *)&aSI;
284 //=======================================================================
287 //=======================================================================
288 const TopoDS_Shape& BOPDS_DS::Shape(const Standard_Integer theI)const
290 const TopoDS_Shape& aS=ShapeInfo(theI).Shape();
293 //=======================================================================
296 //=======================================================================
297 Standard_Integer BOPDS_DS::Index(const TopoDS_Shape& theS)const
299 Standard_Integer iRet;
302 if (myMapShapeIndex.IsBound(theS)) {
303 iRet=myMapShapeIndex.Find(theS);
308 //=======================================================================
311 //=======================================================================
312 void BOPDS_DS::Init()
314 Standard_Integer i1, i2, j, aI, aNb, aNbS, aNbE, aNbSx, nV, nW, nE, aNbF;
316 TopAbs_ShapeEnum aTS;
317 BOPCol_ListIteratorOfListOfInteger aIt1, aIt2, aIt3;
318 BOPCol_ListIteratorOfListOfShape aIt;
320 Handle(NCollection_IncAllocator) aAllocator;
322 // 1 Append Source Shapes
323 aNb=myArguments.Extent();
328 myRanges.SetStartSize(aNb);
331 aIt.Initialize(myArguments);
332 for (; aIt.More(); aIt.Next()) {
333 const TopoDS_Shape& aSx=aIt.Value();
338 aIt.Initialize(myArguments);
339 for (; aIt.More(); aIt.Next()) {
340 const TopoDS_Shape& aSx=aIt.Value();
343 TotalShapes(aSx, aNbSx);
347 myLines.SetStartSize(2*aNbS);
348 myLines.SetIncrement(aNbS);
351 //-----------------------------------------------------scope_1 f
352 aAllocator=new NCollection_IncAllocator();
354 BOPCol_DataMapOfShapeInteger& aMSI=myMapShapeIndex;
358 aIt.Initialize(myArguments);
359 for (; aIt.More(); aIt.Next()) {
360 const TopoDS_Shape& aS=aIt.Value();
361 if (aMSI.IsBound(aS)) {
367 InitShape(aI, aS, aAllocator, aMSI);
370 aR.SetIndices(i1, i2);
375 myNbSourceShapes=NbShapes();
380 for (j=0; j<myNbSourceShapes; ++j) {
381 BOPDS_ShapeInfo& aSI=ChangeShapeInfo(j);
383 const TopoDS_Shape& aS=aSI.Shape();
388 if (aTS==TopAbs_VERTEX) {
389 Bnd_Box& aBox=aSI.ChangeBox();
390 const TopoDS_Vertex& aV=*((TopoDS_Vertex*)&aS);
391 const gp_Pnt& aP=BRep_Tool::Pnt(aV);
392 aTol=BRep_Tool::Tolerance(aV);
399 for (j=0; j<myNbSourceShapes; ++j) {
400 BOPDS_ShapeInfo& aSI=ChangeShapeInfo(j);
403 if (aTS==TopAbs_EDGE) {
404 const TopoDS_Shape& aS=aSI.Shape();
405 const TopoDS_Edge& aE=*((TopoDS_Edge*)&aS);
406 aTol=BRep_Tool::Tolerance(aE);
408 if (!BRep_Tool::Degenerated(aE)) {
409 Standard_Boolean bInf1, bInf2;
410 Standard_Integer aIx;
411 Standard_Real aT1, aT2;
413 Handle(Geom_Curve) aC3D;
417 BOPDS_ShapeInfo aSIx;
419 BOPCol_ListOfInteger& aLI=aSI.ChangeSubShapes();
422 aEx.Orientation(TopAbs_FORWARD);
424 aC3D=BRep_Tool::Curve (aEx, aT1, aT2);
425 bInf1=Precision::IsNegativeInfinite(aT1);
426 bInf2=Precision::IsPositiveInfinite(aT2);
430 aBB.MakeVertex(aVx, aPx, aTol);
431 aVx.Orientation(TopAbs_FORWARD);
434 aSIx.SetShapeType(TopAbs_VERTEX);
435 aSIx.SetFlag(1); //infinite flag
442 aBB.MakeVertex(aVx, aPx, aTol);
443 aVx.Orientation(TopAbs_REVERSED);
446 aSIx.SetShapeType(TopAbs_VERTEX);
447 aSIx.SetFlag(1);//infinite flag
457 Bnd_Box& aBox=aSI.ChangeBox();
458 BRepBndLib::Add(aE, aBox);
460 const BOPCol_ListOfInteger& aLV=aSI.SubShapes();
461 aIt1.Initialize(aLV);
462 for (; aIt1.More(); aIt1.Next()) {
464 BOPDS_ShapeInfo& aSIV=ChangeShapeInfo(nV);
465 Bnd_Box& aBx=aSIV.ChangeBox();
472 BOPCol_MapOfInteger aMI(100, aAllocator);
473 BOPCol_MapIteratorOfMapOfInteger aItMI;
476 for (j=0; j<myNbSourceShapes; ++j) {
477 BOPDS_ShapeInfo& aSI=ChangeShapeInfo(j);
480 if (aTS==TopAbs_FACE) {
481 const TopoDS_Shape& aS=aSI.Shape();
482 const TopoDS_Face& aF=*((TopoDS_Face*)&aS);
483 aTol=BRep_Tool::Tolerance(aF);
485 Bnd_Box& aBox=aSI.ChangeBox();
486 BRepBndLib::Add(aS, aBox);
488 BOPCol_ListOfInteger& aLW=aSI.ChangeSubShapes();
489 aIt1.Initialize(aLW);
490 for (; aIt1.More(); aIt1.Next()) {
492 BOPDS_ShapeInfo& aSIW=ChangeShapeInfo(nW);
494 const BOPCol_ListOfInteger& aLE=aSIW.SubShapes();
495 aIt2.Initialize(aLE);
496 for (; aIt2.More(); aIt2.Next()) {
498 BOPDS_ShapeInfo& aSIE=ChangeShapeInfo(nE);
499 Bnd_Box& aBx=aSIE.ChangeBox();
503 const TopoDS_Edge& aE=*(TopoDS_Edge*)(&aSIE.Shape());
504 if (BRep_Tool::Degenerated(aE)) {
508 const BOPCol_ListOfInteger& aLV=aSIE.SubShapes();
509 aIt3.Initialize(aLV);
510 for (; aIt3.More(); aIt3.Next()) {
515 }//for (; aIt1.More(); aIt1.Next()) {
518 // For a Face: change wires for BRep sub-shapes
520 aItMI.Initialize(aMI);
521 for (; aItMI.More(); aItMI.Next()) {
527 }//if (aTS==TopAbs_FACE) {
528 }//for (j=0; j<myNbSourceShapes; ++j) {
531 aAllocator.Nullify();
532 //-----------------------------------------------------scope_1 t
534 // 3 myPaveBlocksPool
535 myPaveBlocksPool.SetStartSize(aNbE);
536 myPaveBlocksPool.SetIncrement(aNbE);
537 myPaveBlocksPool.Init();
540 myFaceInfoPool.SetStartSize(aNbF);
541 myFaceInfoPool.SetIncrement(aNbF);
542 myFaceInfoPool.Init();
545 //=======================================================================
546 //function : InitShape
548 //=======================================================================
549 void BOPDS_DS::InitShape(const Standard_Integer aI,
550 const TopoDS_Shape& aS,
551 Handle(NCollection_BaseAllocator)& theAllocator,
552 BOPCol_DataMapOfShapeInteger& aMSI)
554 Standard_Integer aIx;
556 BOPCol_ListIteratorOfListOfInteger aIt1;
558 BOPDS_ShapeInfo& aSI=ChangeShapeInfo(aI);
559 aSI.SetShapeType(aS.ShapeType());
560 BOPCol_ListOfInteger& aLI=aSI.ChangeSubShapes();
562 BOPCol_MapOfInteger aM(100, theAllocator);
564 aIt1.Initialize(aLI);
565 for (; aIt1.More(); aIt1.Next()) {
566 aM.Add(aIt1.Value());
570 for (; aIt.More(); aIt.Next()) {
571 const TopoDS_Shape& aSx=aIt.Value();
572 if (aMSI.IsBound(aSx)) {
580 InitShape(aIx, aSx, theAllocator, aMSI);
588 //=======================================================================
589 //function : HasInterf
591 //=======================================================================
592 Standard_Boolean BOPDS_DS::HasInterf(const Standard_Integer theI) const
594 Standard_Integer n1, n2;
595 Standard_Boolean bRet;
596 BOPDS_MapIteratorMapOfPassKey aIt;
598 bRet = Standard_False;
600 aIt.Initialize(myInterfTB);
601 for (; aIt.More(); aIt.Next()) {
602 const BOPDS_PassKey& aPK = aIt.Value();
604 if (n1 == theI || n2 == theI) {
605 bRet = Standard_True;
613 //=======================================================================
614 //function : HasInterfShapeSubShapes
616 //=======================================================================
617 Standard_Boolean BOPDS_DS::HasInterfShapeSubShapes(const Standard_Integer theI1,
618 const Standard_Integer theI2)const
620 Standard_Boolean bRet;
622 BOPCol_ListIteratorOfListOfInteger aIt;
623 bRet = Standard_False;
625 const BOPDS_ShapeInfo& aSI=ShapeInfo(theI2);
626 const BOPCol_ListOfInteger& aLI=aSI.SubShapes();
628 for (; aIt.More(); aIt.Next()) {
630 bRet=HasInterf(theI1, n2);
638 //=======================================================================
639 //function : HasInterfSubShapes
641 //=======================================================================
642 Standard_Boolean BOPDS_DS::HasInterfSubShapes(const Standard_Integer theI1,
643 const Standard_Integer theI2)const
645 Standard_Boolean bRet;
647 BOPCol_ListIteratorOfListOfInteger aIt;
648 bRet = Standard_False;
650 const BOPDS_ShapeInfo& aSI=ShapeInfo(theI1);
651 const BOPCol_ListOfInteger& aLI=aSI.SubShapes();
653 for (; aIt.More(); aIt.Next()) {
655 bRet=HasInterfShapeSubShapes(n1, theI2);
664 //=======================================================================
665 //function : PaveBlocksPool
667 //=======================================================================
668 const BOPDS_VectorOfListOfPaveBlock& BOPDS_DS::PaveBlocksPool()const
670 return myPaveBlocksPool;
672 //=======================================================================
673 //function : ChangePaveBlocksPool
675 //=======================================================================
676 BOPDS_VectorOfListOfPaveBlock& BOPDS_DS::ChangePaveBlocksPool()
678 return myPaveBlocksPool;
680 //=======================================================================
681 //function : HasPaveBlocks
683 //=======================================================================
684 Standard_Boolean BOPDS_DS::HasPaveBlocks(const Standard_Integer theI)const
686 return ShapeInfo(theI).HasReference();
688 //=======================================================================
689 //function : PaveBlocks
691 //=======================================================================
692 const BOPDS_ListOfPaveBlock& BOPDS_DS::PaveBlocks(const Standard_Integer theI)const
694 static BOPDS_ListOfPaveBlock sLPB;
695 Standard_Integer aRef;
697 if (HasPaveBlocks(theI)) {
698 aRef=ShapeInfo(theI).Reference();
699 const BOPDS_ListOfPaveBlock& aLPB=myPaveBlocksPool(aRef);
704 //=======================================================================
705 //function : ChangePaveBlocks
707 //=======================================================================
708 BOPDS_ListOfPaveBlock& BOPDS_DS::ChangePaveBlocks(const Standard_Integer theI)
710 Standard_Boolean bHasReference;
711 Standard_Integer aRef;
713 BOPDS_ShapeInfo& aSI=ChangeShapeInfo(theI);
714 bHasReference=aSI.HasReference();
715 if (!bHasReference) {
716 InitPaveBlocks(theI);
719 aRef=aSI.Reference();
720 return myPaveBlocksPool(aRef);
722 //=======================================================================
723 //function : InitPaveBlocks
725 //=======================================================================
726 void BOPDS_DS::InitPaveBlocks(const Standard_Integer theI)
728 Standard_Integer nV = 0, iRef, aNbV, nVSD, i;
731 BOPCol_ListIteratorOfListOfInteger aIt;
733 Handle(BOPDS_PaveBlock) aPB;
735 BOPDS_ShapeInfo& aSI=ChangeShapeInfo(theI);
736 const TopoDS_Edge& aE=*(TopoDS_Edge*)(&aSI.Shape());
738 const BOPCol_ListOfInteger& aLV=aSI.SubShapes();
744 aPB=new BOPDS_PaveBlock;
745 aPB->SetOriginalEdge(theI);
748 for (i=0; aIt.More(); aIt.Next(), ++i) {
751 const BOPDS_ShapeInfo& aSIV=ShapeInfo(nV);
752 aV=*(TopoDS_Vertex*)(&aSIV.Shape());
753 if (aSIV.HasFlag()) {
754 aT=ComputeParameter(aV, aE);
757 aT=BRep_Tool::Parameter(aV, aE);
760 if (HasShapeSD(nV, nVSD)) {
764 aPave.SetParameter(aT);
765 aPB->AppendExtPave(aPave);
770 aT=BRep_Tool::Parameter(aV, aE);
772 aPave.SetParameter(aT);
773 aPB->AppendExtPave1(aPave);
776 iRef = myPaveBlocksPool.Append() - 1;
777 BOPDS_ListOfPaveBlock &aLPB=myPaveBlocksPool(iRef);
779 aPB->Update(aLPB, Standard_False);
780 aSI.SetReference(iRef);
782 //=======================================================================
783 //function : UpdatePaveBlocks
785 //=======================================================================
786 void BOPDS_DS::UpdatePaveBlocks()
788 Standard_Boolean bIsToUpdate;
789 Standard_Integer i, aNbPBP;
790 BOPDS_ListOfPaveBlock aLPBN(myAllocator);
791 BOPDS_ListIteratorOfListOfPaveBlock aItPB, aItPBN;
793 BOPDS_VectorOfListOfPaveBlock& aPBP=myPaveBlocksPool;
796 for (i=0; i<aNbPBP; ++i) {
797 BOPDS_ListOfPaveBlock& aLPB=aPBP(i);
799 aItPB.Initialize(aLPB);
800 for (; aItPB.More(); aItPB.Next()) {
801 Handle(BOPDS_PaveBlock)& aPB=aItPB.ChangeValue();
803 bIsToUpdate=aPB->IsToUpdate();
808 aItPBN.Initialize(aLPBN);
809 for (; aItPBN.More(); aItPBN.Next()) {
810 Handle(BOPDS_PaveBlock)& aPBN=aItPBN.ChangeValue();
815 }// for (; aItPB.More(); aItPB.Next()) {
816 }// for (i=0; i<aNbPBP; ++i) {
818 //=======================================================================
819 //function : UpdatePaveBlock
821 //=======================================================================
822 void BOPDS_DS::UpdatePaveBlock(const Handle(BOPDS_PaveBlock)& thePB)
824 if (!thePB->IsToUpdate()){
828 Standard_Integer nE, iRef;
829 BOPDS_ListIteratorOfListOfPaveBlock aItPB, aItPBN;
830 BOPDS_ListOfPaveBlock aLPBN(myAllocator);
831 Handle(BOPDS_PaveBlock) aPB;
833 BOPDS_VectorOfListOfPaveBlock& aPBP=myPaveBlocksPool;
835 nE=thePB->OriginalEdge();
836 BOPDS_ShapeInfo& aSI=ChangeShapeInfo(nE);
837 iRef=aSI.Reference();
838 BOPDS_ListOfPaveBlock& aLPB=aPBP(iRef);
840 aItPB.Initialize(aLPB);
841 for (; aItPB.More(); aItPB.Next()) {
842 aPB=aItPB.ChangeValue();
846 aItPBN.Initialize(aLPBN);
847 for (; aItPBN.More(); aItPBN.Next()) {
848 Handle(BOPDS_PaveBlock)& aPBN=aItPBN.ChangeValue();
856 //=======================================================================
857 //function : UpdateCommonBlock
859 //=======================================================================
860 void BOPDS_DS::UpdateCommonBlock(const Handle(BOPDS_CommonBlock)& theCB)
862 Standard_Integer nE, iRef, n1, n2;
863 BOPDS_ListIteratorOfListOfPaveBlock aItPB, aItPBCB, aItPBN;
864 BOPDS_DataMapIteratorOfDataMapOfPassKeyListOfPaveBlock aItMPKLPB;
865 BOPDS_ListOfPaveBlock aLPBN;
866 BOPDS_DataMapOfPassKeyListOfPaveBlock aMPKLPB;
867 Handle(BOPDS_PaveBlock) aPB;
868 Handle(BOPDS_CommonBlock) aCBx;
871 const BOPDS_ListOfPaveBlock& aLPBCB=theCB->PaveBlocks();
872 if (!aLPBCB.First()->IsToUpdate()){
876 const BOPCol_ListOfInteger& aLF=theCB->Faces();
878 BOPDS_VectorOfListOfPaveBlock& aPBP=myPaveBlocksPool;
880 aItPBCB.Initialize(aLPBCB);
881 for (; aItPBCB.More(); aItPBCB.Next()) {
882 const Handle(BOPDS_PaveBlock)& aPBCB=aItPBCB.ChangeValue();
884 nE=aPBCB->OriginalEdge();
885 iRef=ChangeShapeInfo(nE).Reference();
886 BOPDS_ListOfPaveBlock& aLPB=aPBP(iRef);
888 aItPB.Initialize(aLPB);
889 for (; aItPB.More(); aItPB.Next()) {
890 aPB=aItPB.ChangeValue();
896 aItPBN.Initialize(aLPBN);
897 for (; aItPBN.More(); aItPBN.Next()) {
898 Handle(BOPDS_PaveBlock)& aPBN=aItPBN.ChangeValue();
901 aPBN->Indices(n1, n2);
903 if (aMPKLPB.IsBound(aPK)) {
904 BOPDS_ListOfPaveBlock& aLPBx=aMPKLPB.ChangeFind(aPK);
908 BOPDS_ListOfPaveBlock aLPBx;
910 aMPKLPB.Bind(aPK, aLPBx);
919 aItMPKLPB.Initialize(aMPKLPB);
920 for (; aItMPKLPB.More(); aItMPKLPB.Next()) {
921 BOPDS_ListOfPaveBlock& aLPBx=aItMPKLPB.ChangeValue();
923 while (aLPBx.Extent()) {
924 Standard_Boolean bCoinside;
925 Standard_Real aTol, aTolMax(0.);
926 BOPDS_ListOfPaveBlock aLPBxN;
928 aItPB.Initialize(aLPBx);
929 for(; aItPB.More(); ) {
930 const Handle(BOPDS_PaveBlock)& aPBx=aItPB.Value();
931 if (aLPBxN.Extent()) {
932 const Handle(BOPDS_PaveBlock)& aPBCx = aLPBxN.First();
933 bCoinside = CheckCoincidence(aPBx, aPBCx);
935 nE = aPBx->OriginalEdge();
936 const TopoDS_Edge& aE = *(TopoDS_Edge*)&Shape(nE);
937 aTol = BRep_Tool::Tolerance(aE);
939 //pave block with the max tolerance of the original edge
940 //must be the first in the common block
941 if (aTolMax < aTol) {
943 aLPBxN.Prepend(aPBx);
950 }//if (aLPBxN.Extent()) {
952 nE = aPBx->OriginalEdge();
953 const TopoDS_Edge& aE = *(TopoDS_Edge*)&Shape(nE);
954 aTolMax = BRep_Tool::Tolerance(aE);
961 }//for(; aItPB.More(); ) {
963 aCBx=new BOPDS_CommonBlock;
964 aCBx->AddPaveBlocks(aLPBxN);
967 aItPB.Initialize(aLPBxN);
968 for (; aItPB.More(); aItPB.Next()) {
969 aPB=aItPB.ChangeValue();
970 SetCommonBlock(aPB, aCBx);
976 //=======================================================================
977 // function: RealPaveBlock
979 //=======================================================================
980 Handle(BOPDS_PaveBlock) BOPDS_DS::RealPaveBlock
981 (const Handle(BOPDS_PaveBlock)& thePB) const
983 if (IsCommonBlock(thePB)) {
984 const Handle(BOPDS_CommonBlock)& aCB = CommonBlock(thePB);
985 const Handle(BOPDS_PaveBlock)& aPB = aCB->PaveBlock1();
991 //=======================================================================
992 // function: IsCommonBlockOnEdge
994 //=======================================================================
995 Standard_Boolean BOPDS_DS::IsCommonBlockOnEdge
996 (const Handle(BOPDS_PaveBlock)& thePB) const
998 if (IsCommonBlock(thePB)) {
999 const Handle(BOPDS_CommonBlock)& aCB = CommonBlock(thePB);
1000 return aCB->PaveBlocks().Extent()>1;
1002 return Standard_False;
1005 //=======================================================================
1006 //function : IsCommonBlock
1008 //=======================================================================
1009 Standard_Boolean BOPDS_DS::IsCommonBlock
1010 (const Handle(BOPDS_PaveBlock)& thePB) const
1012 return myMapPBCB.IsBound(thePB);
1015 //=======================================================================
1016 //function : CommonBlock
1018 //=======================================================================
1019 const Handle(BOPDS_CommonBlock)& BOPDS_DS::CommonBlock
1020 (const Handle(BOPDS_PaveBlock)& thePB) const
1022 Handle(BOPDS_CommonBlock) aNullCB;
1024 const Handle(BOPDS_CommonBlock)& aCB =
1025 IsCommonBlock(thePB) ? myMapPBCB.Find(thePB) : aNullCB;
1030 //=======================================================================
1031 //function : SetCommonBlock
1033 //=======================================================================
1034 void BOPDS_DS::SetCommonBlock(const Handle(BOPDS_PaveBlock)& thePB,
1035 const Handle(BOPDS_CommonBlock)& theCB)
1037 if (IsCommonBlock(thePB)) {
1038 Handle(BOPDS_CommonBlock)& aCB = myMapPBCB.ChangeFind(thePB);
1042 myMapPBCB.Bind(thePB, theCB);
1050 //=======================================================================
1051 //function : FaceInfoPool
1053 //=======================================================================
1054 const BOPDS_VectorOfFaceInfo& BOPDS_DS::FaceInfoPool()const
1056 return myFaceInfoPool;
1058 //=======================================================================
1059 //function : HasFaceInfo
1061 //=======================================================================
1062 Standard_Boolean BOPDS_DS::HasFaceInfo(const Standard_Integer theI)const
1064 return ShapeInfo(theI).HasReference();
1066 //=======================================================================
1067 //function : FaceInfo
1069 //=======================================================================
1070 const BOPDS_FaceInfo& BOPDS_DS::FaceInfo(const Standard_Integer theI)const
1072 static BOPDS_FaceInfo sFI;
1073 Standard_Integer aRef;
1075 if (HasFaceInfo(theI)) {
1076 aRef=ShapeInfo(theI).Reference();
1077 const BOPDS_FaceInfo& aFI=myFaceInfoPool(aRef);
1082 //=======================================================================
1083 //function : ChangeFaceInfo
1085 //=======================================================================
1086 BOPDS_FaceInfo& BOPDS_DS::ChangeFaceInfo(const Standard_Integer theI)
1088 Standard_Boolean bHasReference;
1089 Standard_Integer aRef;
1090 BOPDS_FaceInfo* pFI;
1092 BOPDS_ShapeInfo& aSI=ChangeShapeInfo(theI);
1093 bHasReference=aSI.HasReference();
1094 if (!bHasReference) {
1098 aRef=aSI.Reference();
1099 const BOPDS_FaceInfo& aFI=myFaceInfoPool(aRef);
1100 pFI=(BOPDS_FaceInfo*)&aFI;
1103 //=======================================================================
1104 //function : InitFaceInfo
1106 //=======================================================================
1107 void BOPDS_DS::InitFaceInfo(const Standard_Integer theI)
1109 Standard_Integer iRef;
1111 BOPDS_ShapeInfo& aSI=ChangeShapeInfo(theI);
1112 iRef=myFaceInfoPool.Append()-1;
1113 BOPDS_FaceInfo &aFI=myFaceInfoPool(iRef);
1114 aSI.SetReference(iRef);
1117 UpdateFaceInfoIn(theI);
1118 UpdateFaceInfoOn(theI);
1120 //=======================================================================
1121 //function : UpdateFaceInfoIn
1123 //=======================================================================
1124 void BOPDS_DS::UpdateFaceInfoIn(const Standard_Integer theI)
1126 Standard_Integer iRef;
1128 BOPDS_ShapeInfo& aSI=ChangeShapeInfo(theI);
1129 if (aSI.HasReference()) {
1130 iRef=aSI.Reference();
1131 BOPDS_FaceInfo &aFI=myFaceInfoPool(iRef);
1133 BOPDS_IndexedMapOfPaveBlock& aMPBIn=aFI.ChangePaveBlocksIn();
1134 BOPCol_MapOfInteger& aMVIn=aFI.ChangeVerticesIn();
1137 FaceInfoIn(theI, aMPBIn, aMVIn);
1140 //=======================================================================
1141 //function : UpdateFaceInfoOn
1143 //=======================================================================
1144 void BOPDS_DS::UpdateFaceInfoOn(const Standard_Integer theI)
1146 Standard_Integer iRef;
1148 BOPDS_ShapeInfo& aSI=ChangeShapeInfo(theI);
1149 if (aSI.HasReference()) {
1150 iRef=aSI.Reference();
1151 BOPDS_FaceInfo &aFI=myFaceInfoPool(iRef);
1153 BOPDS_IndexedMapOfPaveBlock& aMPBOn=aFI.ChangePaveBlocksOn();
1154 BOPCol_MapOfInteger& aMVOn=aFI.ChangeVerticesOn();
1157 FaceInfoOn(theI, aMPBOn, aMVOn);
1160 //=======================================================================
1161 //function : FaceInfoOn
1163 //=======================================================================
1164 void BOPDS_DS::FaceInfoOn(const Standard_Integer theF,
1165 BOPDS_IndexedMapOfPaveBlock& theMPB,
1166 BOPCol_MapOfInteger& theMI)
1168 Standard_Integer nS, nSD, nV1, nV2;
1169 BOPCol_ListIteratorOfListOfInteger aIt;
1170 BOPDS_ListIteratorOfListOfPaveBlock aItPB;
1172 const BOPDS_ShapeInfo& aSI=ShapeInfo(theF);
1173 const BOPCol_ListOfInteger& aLI=aSI.SubShapes();
1174 aIt.Initialize(aLI);
1175 for (; aIt.More(); aIt.Next()) {
1177 const BOPDS_ShapeInfo& aSIE=ShapeInfo(nS);
1178 if (aSIE.ShapeType()==TopAbs_EDGE) {
1179 const BOPDS_ListOfPaveBlock& aLPB=PaveBlocks(nS);
1180 aItPB.Initialize(aLPB);
1181 for (; aItPB.More(); aItPB.Next()) {
1182 const Handle(BOPDS_PaveBlock)& aPB=aItPB.Value();
1183 aPB->Indices(nV1, nV2);
1186 Handle(BOPDS_PaveBlock) aPBR=RealPaveBlock(aPB);
1189 }//if (aSIE.ShapeType()==TopAbs_EDGE)
1191 // nE is TopAbs_VERTEX
1192 if (HasShapeSD(nS, nSD)) {
1199 //=======================================================================
1200 //function : FaceInfoIn
1202 //=======================================================================
1203 void BOPDS_DS::FaceInfoIn(const Standard_Integer theF,
1204 BOPDS_IndexedMapOfPaveBlock& theMPB,
1205 BOPCol_MapOfInteger& theMI)
1207 Standard_Integer i, aNbVF, aNbEF, nV, nE;
1208 BOPDS_ListIteratorOfListOfPaveBlock aItPB;
1210 BOPDS_VectorOfInterfVF& aVFs=InterfVF();
1211 aNbVF=aVFs.Extent();
1212 for (i=0; i<aNbVF; ++i) {
1213 BOPDS_InterfVF& aVF=aVFs(i);
1214 if(aVF.Contains(theF)) {
1215 nV=aVF.OppositeIndex(theF);
1220 BOPDS_VectorOfInterfEF& aEFs=InterfEF();
1221 aNbEF=aEFs.Extent();
1222 for (i=0; i<aNbEF; ++i) {
1223 BOPDS_InterfEF& aEF=aEFs(i);
1224 if(aEF.Contains(theF)) {
1225 if(aEF.HasIndexNew(nV)) {
1229 nE=aEF.OppositeIndex(theF);
1230 const BOPDS_ListOfPaveBlock& aLPB=PaveBlocks(nE);
1231 aItPB.Initialize(aLPB);
1232 for (; aItPB.More(); aItPB.Next()) {
1233 const Handle(BOPDS_PaveBlock)& aPB=aItPB.Value();
1234 if (IsCommonBlock(aPB)) {
1235 const Handle(BOPDS_CommonBlock)& aCB=CommonBlock(aPB);
1236 if (aCB->Contains(theF)) {
1237 const Handle(BOPDS_PaveBlock)& aPB1=aCB->PaveBlock1();
1241 }// for (; aItPB.More(); aItPB.Next()) {
1243 }// if(aEF.Contains(theF)) {
1244 }// for (i=0; i<aNbEF; ++i) {
1247 //=======================================================================
1248 //function : RefineFaceInfoOn
1250 //=======================================================================
1251 void BOPDS_DS::RefineFaceInfoOn()
1253 Standard_Integer i, aNb, nF, aNbPB, j;
1254 BOPDS_IndexedMapOfPaveBlock aMPB;
1256 aNb=myFaceInfoPool.Extent();
1257 for (i=0; i<aNb; ++i) {
1258 BOPDS_FaceInfo &aFI=myFaceInfoPool(i);
1260 UpdateFaceInfoOn(nF);
1261 BOPDS_IndexedMapOfPaveBlock& aMPBOn=aFI.ChangePaveBlocksOn();
1264 aMPB.Assign(aMPBOn);
1267 aNbPB=aMPB.Extent();
1268 for (j=1; j<=aNbPB; ++j) {
1269 const Handle(BOPDS_PaveBlock)& aPB=aMPB(j);
1270 if (aPB->HasEdge()) {
1276 //=======================================================================
1277 //function : AloneVertices
1279 //=======================================================================
1280 void BOPDS_DS::AloneVertices(const Standard_Integer theI,
1281 BOPCol_ListOfInteger& theLI)const
1283 if (HasFaceInfo(theI)) {
1285 Standard_Integer i, nV1, nV2, nV;
1286 BOPDS_MapIteratorOfMapOfPaveBlock aItMPB;
1287 BOPCol_MapIteratorOfMapOfInteger aItMI;
1289 BOPCol_MapOfInteger aMI(100, myAllocator);
1291 const BOPDS_FaceInfo& aFI=FaceInfo(theI);
1293 for (i=0; i<2; ++i) {
1294 const BOPDS_IndexedMapOfPaveBlock& aMPB=(!i) ? aFI.PaveBlocksIn() : aFI.PaveBlocksSc();
1295 aItMPB.Initialize(aMPB);
1296 for (; aItMPB.More(); aItMPB.Next()) {
1297 const Handle(BOPDS_PaveBlock)& aPB=aItMPB.Value();
1298 aPB->Indices(nV1, nV2);
1304 for (i=0; i<2; ++i) {
1305 const BOPCol_MapOfInteger& aMIV=(!i) ? aFI.VerticesIn() : aFI.VerticesSc();
1306 aItMI.Initialize(aMIV);
1307 for (; aItMI.More(); aItMI.Next()) {
1318 //=======================================================================
1319 //function : VerticesOnIn
1321 //=======================================================================
1322 void BOPDS_DS::VerticesOnIn(const Standard_Integer nF1,
1323 const Standard_Integer nF2,
1324 BOPCol_MapOfInteger& aMI,
1325 BOPDS_MapOfPaveBlock& aMPB)const
1327 Standard_Integer i, nV, nV1, nV2;
1328 BOPCol_MapIteratorOfMapOfInteger aIt;
1329 BOPDS_IndexedMapOfPaveBlock* pMPB[4];
1330 BOPDS_MapIteratorOfMapOfPaveBlock aItMPB;
1332 const BOPDS_FaceInfo& aFI1=FaceInfo(nF1);
1333 const BOPDS_FaceInfo& aFI2=FaceInfo(nF2);
1335 pMPB[0]=(BOPDS_IndexedMapOfPaveBlock*)&aFI1.PaveBlocksOn();
1336 pMPB[1]=(BOPDS_IndexedMapOfPaveBlock*)&aFI1.PaveBlocksIn();
1337 pMPB[2]=(BOPDS_IndexedMapOfPaveBlock*)&aFI2.PaveBlocksOn();
1338 pMPB[3]=(BOPDS_IndexedMapOfPaveBlock*)&aFI2.PaveBlocksIn();
1340 for (i=0; i<4; ++i) {
1341 aItMPB.Initialize(*pMPB[i]);
1342 for (; aItMPB.More(); aItMPB.Next()) {
1343 const Handle(BOPDS_PaveBlock)& aPB=aItMPB.Value();
1345 aPB->Indices(nV1, nV2);
1351 const BOPCol_MapOfInteger& aMVOn1=aFI1.VerticesOn();
1352 const BOPCol_MapOfInteger& aMVIn1=aFI1.VerticesIn();
1353 const BOPCol_MapOfInteger& aMVOn2=aFI2.VerticesOn();
1354 const BOPCol_MapOfInteger& aMVIn2=aFI2.VerticesIn();
1356 for (i=0; i<2; ++i) {
1357 const BOPCol_MapOfInteger& aMV1=(!i) ? aMVOn1 : aMVIn1;
1358 aIt.Initialize(aMV1);
1359 for (; aIt.More(); aIt.Next()) {
1361 if (aMVOn2.Contains(nV) || aMVIn2.Contains(nV)) {
1367 //=======================================================================
1368 //function : SharedEdges
1370 //=======================================================================
1371 void BOPDS_DS::SharedEdges(const Standard_Integer nF1,
1372 const Standard_Integer nF2,
1373 BOPCol_ListOfInteger& theLI,
1374 const Handle(NCollection_BaseAllocator)& aAllocator)
1376 Standard_Integer nE, nSp;
1377 BOPCol_ListIteratorOfListOfInteger aItLI;
1378 BOPDS_ListIteratorOfListOfPaveBlock aItLPB;
1379 BOPCol_MapOfInteger aMI(100, aAllocator);
1381 const BOPDS_ShapeInfo& aSI1=ShapeInfo(nF1);
1382 const BOPCol_ListOfInteger& aLI1=aSI1.SubShapes();
1383 aItLI.Initialize(aLI1);
1384 for (; aItLI.More(); aItLI.Next()) {
1386 const BOPDS_ShapeInfo& aSIE=ChangeShapeInfo(nE);
1387 if(aSIE.ShapeType()==TopAbs_EDGE) {
1388 const BOPDS_ListOfPaveBlock& aLPB=PaveBlocks(nE);
1389 if (aLPB.IsEmpty()) {
1393 aItLPB.Initialize(aLPB);
1394 for (; aItLPB.More(); aItLPB.Next()) {
1395 const Handle(BOPDS_PaveBlock) aPB=RealPaveBlock(aItLPB.Value());
1403 const BOPDS_ShapeInfo& aSI2=ShapeInfo(nF2);
1404 const BOPCol_ListOfInteger& aLI2=aSI2.SubShapes();
1405 aItLI.Initialize(aLI2);
1406 for (; aItLI.More(); aItLI.Next()) {
1408 const BOPDS_ShapeInfo& aSIE=ChangeShapeInfo(nE);
1409 if(aSIE.ShapeType()==TopAbs_EDGE) {
1410 const BOPDS_ListOfPaveBlock& aLPB=PaveBlocks(nE);
1411 if (aLPB.IsEmpty()) {
1412 if (aMI.Contains(nE)) {
1417 aItLPB.Initialize(aLPB);
1418 for (; aItLPB.More(); aItLPB.Next()) {
1419 const Handle(BOPDS_PaveBlock) aPB=RealPaveBlock(aItLPB.Value());
1421 if (aMI.Contains(nSp)) {
1430 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1432 // same domain shapes
1434 //=======================================================================
1435 //function : ShapesSD
1437 //=======================================================================
1438 BOPCol_DataMapOfIntegerInteger& BOPDS_DS::ShapesSD()
1442 //=======================================================================
1443 //function : AddShapeSD
1445 //=======================================================================
1446 void BOPDS_DS::AddShapeSD(const Standard_Integer theIndex,
1447 const Standard_Integer theIndexSD)
1449 myShapesSD.Bind(theIndex, theIndexSD);
1451 //=======================================================================
1452 //function : HasShapeSD
1454 //=======================================================================
1455 Standard_Boolean BOPDS_DS::HasShapeSD(const Standard_Integer theIndex,
1456 Standard_Integer& theIndexSD)const
1458 Standard_Boolean bRet;
1460 bRet=myShapesSD.IsBound(theIndex);
1462 theIndexSD=myShapesSD.Find(theIndex);
1466 //=======================================================================
1469 //=======================================================================
1470 void BOPDS_DS::Dump()const
1472 Standard_Integer i, aNb, aNbSS;
1474 printf(" *** DS ***\n");
1476 printf(" Ranges:%d\n", aNb);
1477 for (i=0; i<aNb; ++i) {
1478 const BOPDS_IndexRange& aR=Range(i);
1483 aNbSS=NbSourceShapes();
1484 printf(" Shapes:%d\n", aNbSS);
1486 for (i=0; i<aNb; ++i) {
1487 const BOPDS_ShapeInfo& aSI=ShapeInfo(i);
1492 printf(" ****** adds\n");
1495 printf(" ******\n");
1498 //=======================================================================
1499 // function: CheckCoincidence
1501 //=======================================================================
1502 Standard_Boolean BOPDS_DS::CheckCoincidence(const Handle(BOPDS_PaveBlock)& aPB1,
1503 const Handle(BOPDS_PaveBlock)& aPB2)
1505 Standard_Boolean bRet;
1506 Standard_Integer nE1, nE2, aNbPoints;
1507 Standard_Real aT11, aT12, aT21, aT22, aT1m, aD, aTol, aT2x;
1510 bRet=Standard_False;
1512 aPB1->Range(aT11, aT12);
1513 aT1m=IntTools_Tools::IntermediatePoint (aT11, aT12);
1514 nE1=aPB1->OriginalEdge();
1515 const TopoDS_Edge& aE1=(*(TopoDS_Edge*)(&Shape(nE1)));
1516 BOPTools_AlgoTools::PointOnEdge(aE1, aT1m, aP1m);
1518 aPB2->Range(aT21, aT22);
1519 nE2=aPB2->OriginalEdge();
1520 const TopoDS_Edge& aE2=(*(TopoDS_Edge*)(&Shape(nE2)));
1523 Handle(Geom_Curve)aC2 = BRep_Tool::Curve (aE2, f, l);
1524 GeomAPI_ProjectPointOnCurve aPPC;
1525 aPPC.Init(aC2, f, l);
1527 aNbPoints=aPPC.NbPoints();
1529 aD=aPPC.LowerDistance();
1531 aTol=BRep_Tool::Tolerance(aE1);
1532 aTol=aTol+BRep_Tool::Tolerance(aE2);
1534 aT2x=aPPC.LowerDistanceParameter();
1535 if (aT2x>aT21 && aT2x<aT22) {
1543 //=======================================================================
1544 // function: SortPaveBlocks
1546 //=======================================================================
1547 void BOPDS_DS::SortPaveBlocks(const Handle(BOPDS_CommonBlock)& aCB)
1549 Standard_Integer theI;
1550 Standard_Boolean bToSort;
1551 bToSort = IsToSort(aCB, theI);
1556 Standard_Integer i(0);
1557 const BOPDS_ListOfPaveBlock& aLPB = aCB->PaveBlocks();
1558 BOPDS_ListOfPaveBlock aLPBN = aLPB;
1560 Handle(BOPDS_PaveBlock) aPB;
1561 BOPDS_ListIteratorOfListOfPaveBlock aIt;
1563 aIt.Initialize(aLPBN);
1564 for (aIt.Next(); aIt.More(); ) {
1575 aCB->AddPaveBlocks(aLPBN);
1578 //=======================================================================
1579 // function: IsToSort
1581 //=======================================================================
1582 Standard_Boolean BOPDS_DS::IsToSort(const Handle(BOPDS_CommonBlock)& aCB,
1583 Standard_Integer& theI)
1585 Standard_Boolean bRet;
1586 bRet = Standard_False;
1587 const BOPDS_ListOfPaveBlock& aLPB = aCB->PaveBlocks();
1588 if (aLPB.Extent()==1) {
1592 Standard_Integer nE;
1593 Standard_Real aTolMax, aTol;
1594 Handle(BOPDS_PaveBlock) aPB;
1596 BOPDS_ListIteratorOfListOfPaveBlock aIt;
1599 nE = aPB->OriginalEdge();
1600 aE = (*(TopoDS_Edge *)(&Shape(nE)));
1601 aTolMax = BRep_Tool::Tolerance(aE);
1604 aIt.Initialize(aLPB);
1605 for (aIt.Next(); aIt.More(); aIt.Next()) {
1608 nE = aPB->OriginalEdge();
1609 aE = (*(TopoDS_Edge *)(&Shape(nE)));
1610 aTol = BRep_Tool::Tolerance(aE);
1611 if (aTolMax < aTol) {
1613 bRet = Standard_True;
1620 //=======================================================================
1621 // function: IsSubShape
1623 //=======================================================================
1624 Standard_Boolean BOPDS_DS::IsSubShape(const Standard_Integer theI1,
1625 const Standard_Integer theI2)
1627 Standard_Boolean bRet;
1628 Standard_Integer nS;
1629 bRet = Standard_False;
1631 BOPCol_ListIteratorOfListOfInteger aItLI;
1633 const BOPDS_ShapeInfo& aSI = ShapeInfo(theI2);
1634 const BOPCol_ListOfInteger& aLI = aSI.SubShapes();
1635 aItLI.Initialize(aLI);
1636 for(;aItLI.More(); aItLI.Next()) {
1639 bRet = Standard_True;
1647 //=======================================================================
1650 //=======================================================================
1651 void BOPDS_DS::Paves(const Standard_Integer theEdge,
1652 BOPDS_ListOfPave& theLP)
1654 Standard_Integer aNb, i;
1656 BOPDS_ListIteratorOfListOfPaveBlock aIt;
1657 BOPDS_MapOfPave aMP;
1659 const BOPDS_ListOfPaveBlock& aLPB = PaveBlocks(theEdge);
1660 aNb = aLPB.Extent();
1661 aNb = (aNb==0) ? 0 : (aNb+1);
1663 pPaves=(BOPDS_Pave *)myAllocator->Allocate(aNb*sizeof(BOPDS_Pave));
1664 for (i=0; i<aNb; ++i) {
1665 new (pPaves+i) BOPDS_Pave();
1669 for (aIt.Initialize(aLPB); aIt.More(); aIt.Next()) {
1670 const Handle(BOPDS_PaveBlock)& aPB = aIt.Value();
1671 if (aMP.Add(aPB->Pave1())){
1672 pPaves[i] = aPB->Pave1();
1675 if (aMP.Add(aPB->Pave2())){
1676 pPaves[i] = aPB->Pave2();
1681 SortShell(aNb, pPaves);
1683 for (i = 0; i < aNb; ++i) {
1684 theLP.Append(pPaves[i]);
1688 //=======================================================================
1689 // function: UpdateTolerance
1691 //=======================================================================
1692 void BOPDS_DS::UpdateEdgeTolerance(const Standard_Integer nE,
1693 const Standard_Real aTol)
1695 Standard_Integer nV;
1696 Standard_Real aTolV;
1698 BOPCol_ListIteratorOfListOfInteger aIt;
1700 const TopoDS_Edge& aE = *(TopoDS_Edge*)&Shape(nE);
1701 aBB.UpdateEdge(aE, aTol);
1702 BOPDS_ShapeInfo& aSIE=ChangeShapeInfo(nE);
1703 Bnd_Box& aBoxE=aSIE.ChangeBox();
1704 BRepBndLib::Add(aE, aBoxE);
1706 const BOPCol_ListOfInteger& aLI = aSIE.SubShapes();
1707 aIt.Initialize(aLI);
1708 for (; aIt.More(); aIt.Next()) {
1710 const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&Shape(nV);
1711 aTolV = BRep_Tool::Tolerance(aV);
1713 aBB.UpdateVertex(aV, aTol);
1714 BOPDS_ShapeInfo& aSIV = ChangeShapeInfo(nV);
1715 Bnd_Box& aBoxV = aSIV.ChangeBox();
1716 BRepBndLib::Add(aV, aBoxV);
1721 //=======================================================================
1722 //function : TotalShapes
1724 //=======================================================================
1725 void TotalShapes(const TopoDS_Shape& aS,
1726 Standard_Integer& aNbS)
1730 pS=(TopoDS_Shape *)&aS;
1731 if (!pS->Checked()) {
1732 TopoDS_Iterator aIt;
1737 for (; aIt.More(); aIt.Next()) {
1738 const TopoDS_Shape& aSx=aIt.Value();
1739 TotalShapes(aSx, aNbS);
1743 //=======================================================================
1744 //function : ResetShape
1746 //=======================================================================
1747 void ResetShape(const TopoDS_Shape& aS)
1751 pS=(TopoDS_Shape *)&aS;
1754 //=======================================================================
1755 //function : ResetShape
1757 //=======================================================================
1758 void ResetShapes(const TopoDS_Shape& aS)
1760 TopoDS_Iterator aIt;
1764 for (; aIt.More(); aIt.Next()) {
1765 const TopoDS_Shape& aSx=aIt.Value();
1769 #include <Geom_Curve.hxx>
1771 //=======================================================================
1772 //function : ComputeParameter
1774 //=======================================================================
1775 Standard_Real ComputeParameter(const TopoDS_Vertex& aV,
1776 const TopoDS_Edge& aE)
1778 Standard_Real aT1, aT2, aTRet, aTolE2, aD2;
1780 Handle(Geom_Curve) aC3D;
1784 aEE.Orientation(TopAbs_FORWARD);
1788 aTolE2=BRep_Tool::Tolerance(aE);
1789 aTolE2=aTolE2*aTolE2;
1791 aPV=BRep_Tool::Pnt(aV);
1793 aC3D=BRep_Tool::Curve (aEE, aT1, aT2);
1796 aD2=aPC.SquareDistance(aPV);
1802 aD2=aPC.SquareDistance(aPV);
1809 //=======================================================================
1810 // function: SortShell
1812 //=======================================================================
1813 void SortShell(const int n, BOPDS_Pave *a)
1815 int nd, i, j, l, d=1;
1826 for (i=0; i<nd; ++i) {
1835 if (j > -1) goto m30;
1836 }//if (a[l] < a[j]){
1837 }//for (i=0; i<nd; ++i)