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 myMapPBCB(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 myFaceInfoPool(myAllocator),
111 myShapesSD(100, myAllocator),
112 myMapPBCB(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, 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()) {
1319 //=======================================================================
1320 //function : VerticesOnIn
1322 //=======================================================================
1323 void BOPDS_DS::VerticesOnIn(const Standard_Integer nF1,
1324 const Standard_Integer nF2,
1325 BOPCol_MapOfInteger& aMI,
1326 BOPDS_MapOfPaveBlock& aMPB)const
1328 Standard_Integer nV, nV1, nV2;
1329 BOPCol_MapIteratorOfMapOfInteger aIt;
1330 BOPDS_MapIteratorOfMapOfPaveBlock aItMPB;
1332 const BOPDS_FaceInfo& aFI1=FaceInfo(nF1);
1333 const BOPDS_FaceInfo& aFI2=FaceInfo(nF2);
1335 const BOPDS_IndexedMapOfPaveBlock& aMPBOn1=aFI1.PaveBlocksOn();
1336 aItMPB.Initialize(aMPBOn1);
1337 for (; aItMPB.More(); aItMPB.Next()) {
1338 const Handle(BOPDS_PaveBlock)& aPB=aItMPB.Value();
1340 aPB->Indices(nV1, nV2);
1345 const BOPDS_IndexedMapOfPaveBlock& aMPBIn1=aFI1.PaveBlocksIn();
1346 aItMPB.Initialize(aMPBIn1);
1347 for (; aItMPB.More(); aItMPB.Next()) {
1348 const Handle(BOPDS_PaveBlock)& aPB=aItMPB.Value();
1350 aPB->Indices(nV1, nV2);
1355 const BOPDS_IndexedMapOfPaveBlock& aMPBOn2=aFI2.PaveBlocksOn();
1356 aItMPB.Initialize(aMPBOn2);
1357 for (; aItMPB.More(); aItMPB.Next()) {
1358 const Handle(BOPDS_PaveBlock)& aPB=aItMPB.Value();
1360 aPB->Indices(nV1, nV2);
1365 const BOPDS_IndexedMapOfPaveBlock& aMPBIn2=aFI2.PaveBlocksIn();
1366 aItMPB.Initialize(aMPBIn2);
1367 for (; aItMPB.More(); aItMPB.Next()) {
1368 const Handle(BOPDS_PaveBlock)& aPB=aItMPB.Value();
1370 aPB->Indices(nV1, nV2);
1375 const BOPCol_MapOfInteger& aMVOn1=aFI1.VerticesOn();
1376 aIt.Initialize(aMVOn1);
1377 for (; aIt.More(); aIt.Next()) {
1382 const BOPCol_MapOfInteger& aMVIn1=aFI1.VerticesIn();
1383 aIt.Initialize(aMVIn1);
1384 for (; aIt.More(); aIt.Next()) {
1389 const BOPCol_MapOfInteger& aMVOn2=aFI2.VerticesOn();
1390 aIt.Initialize(aMVOn2);
1391 for (; aIt.More(); aIt.Next()) {
1396 const BOPCol_MapOfInteger& aMVIn2=aFI2.VerticesIn();
1397 aIt.Initialize(aMVIn2);
1398 for (; aIt.More(); aIt.Next()) {
1403 //=======================================================================
1404 //function : SharedEdges
1406 //=======================================================================
1407 void BOPDS_DS::SharedEdges(const Standard_Integer nF1,
1408 const Standard_Integer nF2,
1409 BOPCol_ListOfInteger& theLI,
1410 const Handle(NCollection_BaseAllocator)& aAllocator)
1412 Standard_Integer nE, nSp;
1413 BOPCol_ListIteratorOfListOfInteger aItLI;
1414 BOPDS_ListIteratorOfListOfPaveBlock aItLPB;
1415 BOPCol_MapOfInteger aMI(100, aAllocator);
1417 const BOPDS_ShapeInfo& aSI1=ShapeInfo(nF1);
1418 const BOPCol_ListOfInteger& aLI1=aSI1.SubShapes();
1419 aItLI.Initialize(aLI1);
1420 for (; aItLI.More(); aItLI.Next()) {
1422 const BOPDS_ShapeInfo& aSIE=ChangeShapeInfo(nE);
1423 if(aSIE.ShapeType()==TopAbs_EDGE) {
1424 const BOPDS_ListOfPaveBlock& aLPB=PaveBlocks(nE);
1425 if (aLPB.IsEmpty()) {
1429 aItLPB.Initialize(aLPB);
1430 for (; aItLPB.More(); aItLPB.Next()) {
1431 const Handle(BOPDS_PaveBlock) aPB=RealPaveBlock(aItLPB.Value());
1439 const BOPDS_ShapeInfo& aSI2=ShapeInfo(nF2);
1440 const BOPCol_ListOfInteger& aLI2=aSI2.SubShapes();
1441 aItLI.Initialize(aLI2);
1442 for (; aItLI.More(); aItLI.Next()) {
1444 const BOPDS_ShapeInfo& aSIE=ChangeShapeInfo(nE);
1445 if(aSIE.ShapeType()==TopAbs_EDGE) {
1446 const BOPDS_ListOfPaveBlock& aLPB=PaveBlocks(nE);
1447 if (aLPB.IsEmpty()) {
1448 if (aMI.Contains(nE)) {
1453 aItLPB.Initialize(aLPB);
1454 for (; aItLPB.More(); aItLPB.Next()) {
1455 const Handle(BOPDS_PaveBlock) aPB=RealPaveBlock(aItLPB.Value());
1457 if (aMI.Contains(nSp)) {
1466 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1468 // same domain shapes
1470 //=======================================================================
1471 //function : ShapesSD
1473 //=======================================================================
1474 BOPCol_DataMapOfIntegerInteger& BOPDS_DS::ShapesSD()
1478 //=======================================================================
1479 //function : AddShapeSD
1481 //=======================================================================
1482 void BOPDS_DS::AddShapeSD(const Standard_Integer theIndex,
1483 const Standard_Integer theIndexSD)
1485 myShapesSD.Bind(theIndex, theIndexSD);
1487 //=======================================================================
1488 //function : HasShapeSD
1490 //=======================================================================
1491 Standard_Boolean BOPDS_DS::HasShapeSD(const Standard_Integer theIndex,
1492 Standard_Integer& theIndexSD)const
1494 Standard_Boolean bRet;
1496 bRet=myShapesSD.IsBound(theIndex);
1498 theIndexSD=myShapesSD.Find(theIndex);
1502 //=======================================================================
1505 //=======================================================================
1506 void BOPDS_DS::Dump()const
1508 Standard_Integer i, aNb, aNbSS;
1510 printf(" *** DS ***\n");
1512 printf(" Ranges:%d\n", aNb);
1513 for (i=0; i<aNb; ++i) {
1514 const BOPDS_IndexRange& aR=Range(i);
1519 aNbSS=NbSourceShapes();
1520 printf(" Shapes:%d\n", aNbSS);
1522 for (i=0; i<aNb; ++i) {
1523 const BOPDS_ShapeInfo& aSI=ShapeInfo(i);
1528 printf(" ****** adds\n");
1531 printf(" ******\n");
1534 //=======================================================================
1535 // function: CheckCoincidence
1537 //=======================================================================
1538 Standard_Boolean BOPDS_DS::CheckCoincidence(const Handle(BOPDS_PaveBlock)& aPB1,
1539 const Handle(BOPDS_PaveBlock)& aPB2)
1541 Standard_Boolean bRet;
1542 Standard_Integer nE1, nE2, aNbPoints;
1543 Standard_Real aT11, aT12, aT21, aT22, aT1m, aD, aTol, aT2x;
1546 bRet=Standard_False;
1548 aPB1->Range(aT11, aT12);
1549 aT1m=IntTools_Tools::IntermediatePoint (aT11, aT12);
1550 nE1=aPB1->OriginalEdge();
1551 const TopoDS_Edge& aE1=(*(TopoDS_Edge*)(&Shape(nE1)));
1552 BOPTools_AlgoTools::PointOnEdge(aE1, aT1m, aP1m);
1554 aPB2->Range(aT21, aT22);
1555 nE2=aPB2->OriginalEdge();
1556 const TopoDS_Edge& aE2=(*(TopoDS_Edge*)(&Shape(nE2)));
1559 Handle(Geom_Curve)aC2 = BRep_Tool::Curve (aE2, f, l);
1560 GeomAPI_ProjectPointOnCurve aPPC;
1561 aPPC.Init(aC2, f, l);
1563 aNbPoints=aPPC.NbPoints();
1565 aD=aPPC.LowerDistance();
1567 aTol=BRep_Tool::Tolerance(aE1);
1568 aTol=aTol+BRep_Tool::Tolerance(aE2);
1570 aT2x=aPPC.LowerDistanceParameter();
1571 if (aT2x>aT21 && aT2x<aT22) {
1579 //=======================================================================
1580 // function: SortPaveBlocks
1582 //=======================================================================
1583 void BOPDS_DS::SortPaveBlocks(const Handle(BOPDS_CommonBlock)& aCB)
1585 Standard_Integer theI;
1586 Standard_Boolean bToSort;
1587 bToSort = IsToSort(aCB, theI);
1592 Standard_Integer i(0);
1593 const BOPDS_ListOfPaveBlock& aLPB = aCB->PaveBlocks();
1594 BOPDS_ListOfPaveBlock aLPBN = aLPB;
1596 Handle(BOPDS_PaveBlock) aPB;
1597 BOPDS_ListIteratorOfListOfPaveBlock aIt;
1599 aIt.Initialize(aLPBN);
1600 for (aIt.Next(); aIt.More(); ) {
1611 aCB->AddPaveBlocks(aLPBN);
1614 //=======================================================================
1615 // function: IsToSort
1617 //=======================================================================
1618 Standard_Boolean BOPDS_DS::IsToSort(const Handle(BOPDS_CommonBlock)& aCB,
1619 Standard_Integer& theI)
1621 Standard_Boolean bRet;
1622 bRet = Standard_False;
1623 const BOPDS_ListOfPaveBlock& aLPB = aCB->PaveBlocks();
1624 if (aLPB.Extent()==1) {
1628 Standard_Integer nE;
1629 Standard_Real aTolMax, aTol;
1630 Handle(BOPDS_PaveBlock) aPB;
1632 BOPDS_ListIteratorOfListOfPaveBlock aIt;
1635 nE = aPB->OriginalEdge();
1636 aE = (*(TopoDS_Edge *)(&Shape(nE)));
1637 aTolMax = BRep_Tool::Tolerance(aE);
1640 aIt.Initialize(aLPB);
1641 for (aIt.Next(); aIt.More(); aIt.Next()) {
1644 nE = aPB->OriginalEdge();
1645 aE = (*(TopoDS_Edge *)(&Shape(nE)));
1646 aTol = BRep_Tool::Tolerance(aE);
1647 if (aTolMax < aTol) {
1649 bRet = Standard_True;
1656 //=======================================================================
1657 // function: IsSubShape
1659 //=======================================================================
1660 Standard_Boolean BOPDS_DS::IsSubShape(const Standard_Integer theI1,
1661 const Standard_Integer theI2)
1663 Standard_Boolean bRet;
1664 Standard_Integer nS;
1665 bRet = Standard_False;
1667 BOPCol_ListIteratorOfListOfInteger aItLI;
1669 const BOPDS_ShapeInfo& aSI = ShapeInfo(theI2);
1670 const BOPCol_ListOfInteger& aLI = aSI.SubShapes();
1671 aItLI.Initialize(aLI);
1672 for(;aItLI.More(); aItLI.Next()) {
1675 bRet = Standard_True;
1683 //=======================================================================
1686 //=======================================================================
1687 void BOPDS_DS::Paves(const Standard_Integer theEdge,
1688 BOPDS_ListOfPave& theLP)
1690 Standard_Integer aNb, i;
1692 BOPDS_ListIteratorOfListOfPaveBlock aIt;
1693 BOPDS_MapOfPave aMP;
1695 const BOPDS_ListOfPaveBlock& aLPB = PaveBlocks(theEdge);
1696 aNb = aLPB.Extent();
1697 aNb = (aNb==0) ? 0 : (aNb+1);
1699 pPaves=(BOPDS_Pave *)myAllocator->Allocate(aNb*sizeof(BOPDS_Pave));
1700 for (i=0; i<aNb; ++i) {
1701 new (pPaves+i) BOPDS_Pave();
1705 for (aIt.Initialize(aLPB); aIt.More(); aIt.Next()) {
1706 const Handle(BOPDS_PaveBlock)& aPB = aIt.Value();
1707 if (aMP.Add(aPB->Pave1())){
1708 pPaves[i] = aPB->Pave1();
1711 if (aMP.Add(aPB->Pave2())){
1712 pPaves[i] = aPB->Pave2();
1717 SortShell(aNb, pPaves);
1719 for (i = 0; i < aNb; ++i) {
1720 theLP.Append(pPaves[i]);
1724 //=======================================================================
1725 // function: UpdateTolerance
1727 //=======================================================================
1728 void BOPDS_DS::UpdateEdgeTolerance(const Standard_Integer nE,
1729 const Standard_Real aTol)
1731 Standard_Integer nV;
1732 Standard_Real aTolV;
1734 BOPCol_ListIteratorOfListOfInteger aIt;
1736 const TopoDS_Edge& aE = *(TopoDS_Edge*)&Shape(nE);
1737 aBB.UpdateEdge(aE, aTol);
1738 BOPDS_ShapeInfo& aSIE=ChangeShapeInfo(nE);
1739 Bnd_Box& aBoxE=aSIE.ChangeBox();
1740 BRepBndLib::Add(aE, aBoxE);
1742 const BOPCol_ListOfInteger& aLI = aSIE.SubShapes();
1743 aIt.Initialize(aLI);
1744 for (; aIt.More(); aIt.Next()) {
1746 const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&Shape(nV);
1747 aTolV = BRep_Tool::Tolerance(aV);
1749 aBB.UpdateVertex(aV, aTol);
1750 BOPDS_ShapeInfo& aSIV = ChangeShapeInfo(nV);
1751 Bnd_Box& aBoxV = aSIV.ChangeBox();
1752 BRepBndLib::Add(aV, aBoxV);
1757 //=======================================================================
1758 //function : TotalShapes
1760 //=======================================================================
1761 void TotalShapes(const TopoDS_Shape& aS,
1762 Standard_Integer& aNbS)
1766 pS=(TopoDS_Shape *)&aS;
1767 if (!pS->Checked()) {
1768 TopoDS_Iterator aIt;
1773 for (; aIt.More(); aIt.Next()) {
1774 const TopoDS_Shape& aSx=aIt.Value();
1775 TotalShapes(aSx, aNbS);
1779 //=======================================================================
1780 //function : ResetShape
1782 //=======================================================================
1783 void ResetShape(const TopoDS_Shape& aS)
1787 pS=(TopoDS_Shape *)&aS;
1790 //=======================================================================
1791 //function : ResetShape
1793 //=======================================================================
1794 void ResetShapes(const TopoDS_Shape& aS)
1796 TopoDS_Iterator aIt;
1800 for (; aIt.More(); aIt.Next()) {
1801 const TopoDS_Shape& aSx=aIt.Value();
1805 #include <Geom_Curve.hxx>
1807 //=======================================================================
1808 //function : ComputeParameter
1810 //=======================================================================
1811 Standard_Real ComputeParameter(const TopoDS_Vertex& aV,
1812 const TopoDS_Edge& aE)
1814 Standard_Real aT1, aT2, aTRet, aTolE2, aD2;
1816 Handle(Geom_Curve) aC3D;
1820 aEE.Orientation(TopAbs_FORWARD);
1824 aTolE2=BRep_Tool::Tolerance(aE);
1825 aTolE2=aTolE2*aTolE2;
1827 aPV=BRep_Tool::Pnt(aV);
1829 aC3D=BRep_Tool::Curve (aEE, aT1, aT2);
1832 aD2=aPC.SquareDistance(aPV);
1838 aD2=aPC.SquareDistance(aPV);
1845 //=======================================================================
1846 // function: SortShell
1848 //=======================================================================
1849 void SortShell(const int n, BOPDS_Pave *a)
1851 int nd, i, j, l, d=1;
1862 for (i=0; i<nd; ++i) {
1871 if (j > -1) goto m30;
1872 }//if (a[l] < a[j]){
1873 }//for (i=0; i<nd; ++i)