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();
364 InitShape(aI, aS, aAllocator, aMSI);
367 aR.SetIndices(i1, i2);
374 myNbSourceShapes=NbShapes();
379 for (j=0; j<myNbSourceShapes; ++j) {
380 BOPDS_ShapeInfo& aSI=ChangeShapeInfo(j);
382 const TopoDS_Shape& aS=aSI.Shape();
387 if (aTS==TopAbs_VERTEX) {
388 Bnd_Box& aBox=aSI.ChangeBox();
389 const TopoDS_Vertex& aV=*((TopoDS_Vertex*)&aS);
390 const gp_Pnt& aP=BRep_Tool::Pnt(aV);
391 aTol=BRep_Tool::Tolerance(aV);
398 for (j=0; j<myNbSourceShapes; ++j) {
399 BOPDS_ShapeInfo& aSI=ChangeShapeInfo(j);
402 if (aTS==TopAbs_EDGE) {
403 const TopoDS_Shape& aS=aSI.Shape();
404 const TopoDS_Edge& aE=*((TopoDS_Edge*)&aS);
405 aTol=BRep_Tool::Tolerance(aE);
407 if (!BRep_Tool::Degenerated(aE)) {
408 Standard_Boolean bInf1, bInf2;
409 Standard_Integer aIx;
410 Standard_Real aT1, aT2;
412 Handle(Geom_Curve) aC3D;
416 BOPDS_ShapeInfo aSIx;
418 BOPCol_ListOfInteger& aLI=aSI.ChangeSubShapes();
421 aEx.Orientation(TopAbs_FORWARD);
423 aC3D=BRep_Tool::Curve (aEx, aT1, aT2);
424 bInf1=Precision::IsNegativeInfinite(aT1);
425 bInf2=Precision::IsPositiveInfinite(aT2);
429 aBB.MakeVertex(aVx, aPx, aTol);
430 aVx.Orientation(TopAbs_FORWARD);
433 aSIx.SetShapeType(TopAbs_VERTEX);
434 aSIx.SetFlag(1); //infinite flag
441 aBB.MakeVertex(aVx, aPx, aTol);
442 aVx.Orientation(TopAbs_REVERSED);
445 aSIx.SetShapeType(TopAbs_VERTEX);
446 aSIx.SetFlag(1);//infinite flag
456 Bnd_Box& aBox=aSI.ChangeBox();
457 BRepBndLib::Add(aE, aBox);
459 const BOPCol_ListOfInteger& aLV=aSI.SubShapes();
460 aIt1.Initialize(aLV);
461 for (; aIt1.More(); aIt1.Next()) {
463 BOPDS_ShapeInfo& aSIV=ChangeShapeInfo(nV);
464 Bnd_Box& aBx=aSIV.ChangeBox();
471 BOPCol_MapOfInteger aMI(100, aAllocator);
472 BOPCol_MapIteratorOfMapOfInteger aItMI;
475 for (j=0; j<myNbSourceShapes; ++j) {
476 BOPDS_ShapeInfo& aSI=ChangeShapeInfo(j);
479 if (aTS==TopAbs_FACE) {
480 const TopoDS_Shape& aS=aSI.Shape();
481 const TopoDS_Face& aF=*((TopoDS_Face*)&aS);
482 aTol=BRep_Tool::Tolerance(aF);
484 Bnd_Box& aBox=aSI.ChangeBox();
485 BRepBndLib::Add(aS, aBox);
487 BOPCol_ListOfInteger& aLW=aSI.ChangeSubShapes();
488 aIt1.Initialize(aLW);
489 for (; aIt1.More(); aIt1.Next()) {
491 BOPDS_ShapeInfo& aSIW=ChangeShapeInfo(nW);
493 const BOPCol_ListOfInteger& aLE=aSIW.SubShapes();
494 aIt2.Initialize(aLE);
495 for (; aIt2.More(); aIt2.Next()) {
497 BOPDS_ShapeInfo& aSIE=ChangeShapeInfo(nE);
498 Bnd_Box& aBx=aSIE.ChangeBox();
502 const TopoDS_Edge& aE=*(TopoDS_Edge*)(&aSIE.Shape());
503 if (BRep_Tool::Degenerated(aE)) {
507 const BOPCol_ListOfInteger& aLV=aSIE.SubShapes();
508 aIt3.Initialize(aLV);
509 for (; aIt3.More(); aIt3.Next()) {
514 }//for (; aIt1.More(); aIt1.Next()) {
517 // For a Face: change wires for BRep sub-shapes
519 aItMI.Initialize(aMI);
520 for (; aItMI.More(); aItMI.Next()) {
526 }//if (aTS==TopAbs_FACE) {
527 }//for (j=0; j<myNbSourceShapes; ++j) {
530 aAllocator.Nullify();
531 //-----------------------------------------------------scope_1 t
533 // 3 myPaveBlocksPool
534 myPaveBlocksPool.SetStartSize(aNbE);
535 myPaveBlocksPool.SetIncrement(aNbE);
536 myPaveBlocksPool.Init();
539 myFaceInfoPool.SetStartSize(aNbF);
540 myFaceInfoPool.SetIncrement(aNbF);
541 myFaceInfoPool.Init();
544 //=======================================================================
545 //function : InitShape
547 //=======================================================================
548 void BOPDS_DS::InitShape(const Standard_Integer aI,
549 const TopoDS_Shape& aS,
550 Handle(NCollection_BaseAllocator)& theAllocator,
551 BOPCol_DataMapOfShapeInteger& aMSI)
553 Standard_Integer aIx;
555 BOPCol_ListIteratorOfListOfInteger aIt1;
557 BOPDS_ShapeInfo& aSI=ChangeShapeInfo(aI);
558 aSI.SetShapeType(aS.ShapeType());
559 BOPCol_ListOfInteger& aLI=aSI.ChangeSubShapes();
561 BOPCol_MapOfInteger aM(100, theAllocator);
563 aIt1.Initialize(aLI);
564 for (; aIt1.More(); aIt1.Next()) {
565 aM.Add(aIt1.Value());
569 for (; aIt.More(); aIt.Next()) {
570 const TopoDS_Shape& aSx=aIt.Value();
571 if (aMSI.IsBound(aSx)) {
579 InitShape(aIx, aSx, theAllocator, aMSI);
587 //=======================================================================
588 //function : HasInterf
590 //=======================================================================
591 Standard_Boolean BOPDS_DS::HasInterf(const Standard_Integer theI) const
593 Standard_Integer n1, n2;
594 Standard_Boolean bRet;
595 BOPDS_MapIteratorMapOfPassKey aIt;
597 bRet = Standard_False;
599 aIt.Initialize(myInterfTB);
600 for (; aIt.More(); aIt.Next()) {
601 const BOPDS_PassKey& aPK = aIt.Value();
603 if (n1 == theI || n2 == theI) {
604 bRet = Standard_True;
612 //=======================================================================
613 //function : HasInterfShapeSubShapes
615 //=======================================================================
616 Standard_Boolean BOPDS_DS::HasInterfShapeSubShapes(const Standard_Integer theI1,
617 const Standard_Integer theI2)const
619 Standard_Boolean bRet;
621 BOPCol_ListIteratorOfListOfInteger aIt;
622 bRet = Standard_False;
624 const BOPDS_ShapeInfo& aSI=ShapeInfo(theI2);
625 const BOPCol_ListOfInteger& aLI=aSI.SubShapes();
627 for (; aIt.More(); aIt.Next()) {
629 bRet=HasInterf(theI1, n2);
637 //=======================================================================
638 //function : HasInterfSubShapes
640 //=======================================================================
641 Standard_Boolean BOPDS_DS::HasInterfSubShapes(const Standard_Integer theI1,
642 const Standard_Integer theI2)const
644 Standard_Boolean bRet;
646 BOPCol_ListIteratorOfListOfInteger aIt;
647 bRet = Standard_False;
649 const BOPDS_ShapeInfo& aSI=ShapeInfo(theI1);
650 const BOPCol_ListOfInteger& aLI=aSI.SubShapes();
652 for (; aIt.More(); aIt.Next()) {
654 bRet=HasInterfShapeSubShapes(n1, theI2);
663 //=======================================================================
664 //function : PaveBlocksPool
666 //=======================================================================
667 const BOPDS_VectorOfListOfPaveBlock& BOPDS_DS::PaveBlocksPool()const
669 return myPaveBlocksPool;
671 //=======================================================================
672 //function : ChangePaveBlocksPool
674 //=======================================================================
675 BOPDS_VectorOfListOfPaveBlock& BOPDS_DS::ChangePaveBlocksPool()
677 return myPaveBlocksPool;
679 //=======================================================================
680 //function : HasPaveBlocks
682 //=======================================================================
683 Standard_Boolean BOPDS_DS::HasPaveBlocks(const Standard_Integer theI)const
685 return ShapeInfo(theI).HasReference();
687 //=======================================================================
688 //function : PaveBlocks
690 //=======================================================================
691 const BOPDS_ListOfPaveBlock& BOPDS_DS::PaveBlocks(const Standard_Integer theI)const
693 static BOPDS_ListOfPaveBlock sLPB;
694 Standard_Integer aRef;
696 if (HasPaveBlocks(theI)) {
697 aRef=ShapeInfo(theI).Reference();
698 const BOPDS_ListOfPaveBlock& aLPB=myPaveBlocksPool(aRef);
703 //=======================================================================
704 //function : ChangePaveBlocks
706 //=======================================================================
707 BOPDS_ListOfPaveBlock& BOPDS_DS::ChangePaveBlocks(const Standard_Integer theI)
709 Standard_Boolean bHasReference;
710 Standard_Integer aRef;
712 BOPDS_ShapeInfo& aSI=ChangeShapeInfo(theI);
713 bHasReference=aSI.HasReference();
714 if (!bHasReference) {
715 InitPaveBlocks(theI);
718 aRef=aSI.Reference();
719 return myPaveBlocksPool(aRef);
721 //=======================================================================
722 //function : InitPaveBlocks
724 //=======================================================================
725 void BOPDS_DS::InitPaveBlocks(const Standard_Integer theI)
727 Standard_Integer nV, iRef, aNbV, nVSD, i;
730 BOPCol_ListIteratorOfListOfInteger aIt;
732 Handle(BOPDS_PaveBlock) aPB;
734 BOPDS_ShapeInfo& aSI=ChangeShapeInfo(theI);
735 const TopoDS_Edge& aE=*(TopoDS_Edge*)(&aSI.Shape());
737 const BOPCol_ListOfInteger& aLV=aSI.SubShapes();
743 aPB=new BOPDS_PaveBlock;
744 aPB->SetOriginalEdge(theI);
747 for (i=0; aIt.More(); aIt.Next(), ++i) {
750 const BOPDS_ShapeInfo& aSIV=ShapeInfo(nV);
751 aV=*(TopoDS_Vertex*)(&aSIV.Shape());
752 if (aSIV.HasFlag()) {
753 aT=ComputeParameter(aV, aE);
756 aT=BRep_Tool::Parameter(aV, aE);
759 if (HasShapeSD(nV, nVSD)) {
763 aPave.SetParameter(aT);
764 aPB->AppendExtPave(aPave);
769 aT=BRep_Tool::Parameter(aV, aE);
771 aPave.SetParameter(aT);
772 aPB->AppendExtPave1(aPave);
775 iRef = myPaveBlocksPool.Append() - 1;
776 BOPDS_ListOfPaveBlock &aLPB=myPaveBlocksPool(iRef);
778 aPB->Update(aLPB, Standard_False);
779 aSI.SetReference(iRef);
781 //=======================================================================
782 //function : UpdatePaveBlocks
784 //=======================================================================
785 void BOPDS_DS::UpdatePaveBlocks()
787 Standard_Boolean bIsToUpdate;
788 Standard_Integer i, aNbPBP;
789 BOPDS_ListOfPaveBlock aLPBN(myAllocator);
790 BOPDS_ListIteratorOfListOfPaveBlock aItPB, aItPBN;
792 BOPDS_VectorOfListOfPaveBlock& aPBP=myPaveBlocksPool;
795 for (i=0; i<aNbPBP; ++i) {
796 BOPDS_ListOfPaveBlock& aLPB=aPBP(i);
798 aItPB.Initialize(aLPB);
799 for (; aItPB.More(); aItPB.Next()) {
800 Handle(BOPDS_PaveBlock)& aPB=aItPB.ChangeValue();
802 bIsToUpdate=aPB->IsToUpdate();
807 aItPBN.Initialize(aLPBN);
808 for (; aItPBN.More(); aItPBN.Next()) {
809 Handle(BOPDS_PaveBlock)& aPBN=aItPBN.ChangeValue();
814 }// for (; aItPB.More(); aItPB.Next()) {
815 }// for (i=0; i<aNbPBP; ++i) {
817 //=======================================================================
818 //function : UpdatePaveBlock
820 //=======================================================================
821 void BOPDS_DS::UpdatePaveBlock(const Handle(BOPDS_PaveBlock)& thePB)
823 if (!thePB->IsToUpdate()){
827 Standard_Integer nE, iRef;
828 BOPDS_ListIteratorOfListOfPaveBlock aItPB, aItPBN;
829 BOPDS_ListOfPaveBlock aLPBN(myAllocator);
830 Handle(BOPDS_PaveBlock) aPB;
832 BOPDS_VectorOfListOfPaveBlock& aPBP=myPaveBlocksPool;
834 nE=thePB->OriginalEdge();
835 BOPDS_ShapeInfo& aSI=ChangeShapeInfo(nE);
836 iRef=aSI.Reference();
837 BOPDS_ListOfPaveBlock& aLPB=aPBP(iRef);
839 aItPB.Initialize(aLPB);
840 for (; aItPB.More(); aItPB.Next()) {
841 aPB=aItPB.ChangeValue();
845 aItPBN.Initialize(aLPBN);
846 for (; aItPBN.More(); aItPBN.Next()) {
847 Handle(BOPDS_PaveBlock)& aPBN=aItPBN.ChangeValue();
855 //=======================================================================
856 //function : UpdateCommonBlock
858 //=======================================================================
859 void BOPDS_DS::UpdateCommonBlock(const Handle(BOPDS_CommonBlock)& theCB)
861 Standard_Integer nE, iRef, n1, n2;
862 BOPDS_ListIteratorOfListOfPaveBlock aItPB, aItPBCB, aItPBN;
863 BOPDS_DataMapIteratorOfDataMapOfPassKeyListOfPaveBlock aItMPKLPB;
864 BOPDS_ListOfPaveBlock aLPBN;
865 BOPDS_DataMapOfPassKeyListOfPaveBlock aMPKLPB;
866 Handle(BOPDS_PaveBlock) aPB;
867 Handle(BOPDS_CommonBlock) aCBx;
870 const BOPDS_ListOfPaveBlock& aLPBCB=theCB->PaveBlocks();
871 if (!aLPBCB.First()->IsToUpdate()){
875 const BOPCol_ListOfInteger& aLF=theCB->Faces();
877 BOPDS_VectorOfListOfPaveBlock& aPBP=myPaveBlocksPool;
879 aItPBCB.Initialize(aLPBCB);
880 for (; aItPBCB.More(); aItPBCB.Next()) {
881 const Handle(BOPDS_PaveBlock)& aPBCB=aItPBCB.ChangeValue();
883 nE=aPBCB->OriginalEdge();
884 iRef=ChangeShapeInfo(nE).Reference();
885 BOPDS_ListOfPaveBlock& aLPB=aPBP(iRef);
887 aItPB.Initialize(aLPB);
888 for (; aItPB.More(); aItPB.Next()) {
889 aPB=aItPB.ChangeValue();
895 aItPBN.Initialize(aLPBN);
896 for (; aItPBN.More(); aItPBN.Next()) {
897 Handle(BOPDS_PaveBlock)& aPBN=aItPBN.ChangeValue();
900 aPBN->Indices(n1, n2);
902 if (aMPKLPB.IsBound(aPK)) {
903 BOPDS_ListOfPaveBlock& aLPBx=aMPKLPB.ChangeFind(aPK);
907 BOPDS_ListOfPaveBlock aLPBx;
909 aMPKLPB.Bind(aPK, aLPBx);
918 aItMPKLPB.Initialize(aMPKLPB);
919 for (; aItMPKLPB.More(); aItMPKLPB.Next()) {
920 BOPDS_ListOfPaveBlock& aLPBx=aItMPKLPB.ChangeValue();
922 while (aLPBx.Extent()) {
923 Standard_Boolean bCoinside;
924 Standard_Real aTol, aTolMax(0.);
925 BOPDS_ListOfPaveBlock aLPBxN;
927 aItPB.Initialize(aLPBx);
928 for(; aItPB.More(); ) {
929 const Handle(BOPDS_PaveBlock)& aPBx=aItPB.Value();
930 if (aLPBxN.Extent()) {
931 const Handle(BOPDS_PaveBlock)& aPBCx = aLPBxN.First();
932 bCoinside = CheckCoincidence(aPBx, aPBCx);
934 nE = aPBx->OriginalEdge();
935 const TopoDS_Edge& aE = *(TopoDS_Edge*)&Shape(nE);
936 aTol = BRep_Tool::Tolerance(aE);
938 //pave block with the max tolerance of the original edge
939 //must be the first in the common block
940 if (aTolMax < aTol) {
942 aLPBxN.Prepend(aPBx);
949 }//if (aLPBxN.Extent()) {
951 nE = aPBx->OriginalEdge();
952 const TopoDS_Edge& aE = *(TopoDS_Edge*)&Shape(nE);
953 aTolMax = BRep_Tool::Tolerance(aE);
960 }//for(; aItPB.More(); ) {
962 aCBx=new BOPDS_CommonBlock;
963 aCBx->AddPaveBlocks(aLPBxN);
966 aItPB.Initialize(aLPBxN);
967 for (; aItPB.More(); aItPB.Next()) {
968 aPB=aItPB.ChangeValue();
969 SetCommonBlock(aPB, aCBx);
975 //=======================================================================
976 // function: RealPaveBlock
978 //=======================================================================
979 Handle(BOPDS_PaveBlock) BOPDS_DS::RealPaveBlock
980 (const Handle(BOPDS_PaveBlock)& thePB) const
982 if (IsCommonBlock(thePB)) {
983 const Handle(BOPDS_CommonBlock)& aCB = CommonBlock(thePB);
984 const Handle(BOPDS_PaveBlock)& aPB = aCB->PaveBlock1();
990 //=======================================================================
991 // function: IsCommonBlockOnEdge
993 //=======================================================================
994 Standard_Boolean BOPDS_DS::IsCommonBlockOnEdge
995 (const Handle(BOPDS_PaveBlock)& thePB) const
997 if (IsCommonBlock(thePB)) {
998 const Handle(BOPDS_CommonBlock)& aCB = CommonBlock(thePB);
999 return aCB->PaveBlocks().Extent()>1;
1001 return Standard_False;
1004 //=======================================================================
1005 //function : IsCommonBlock
1007 //=======================================================================
1008 Standard_Boolean BOPDS_DS::IsCommonBlock
1009 (const Handle(BOPDS_PaveBlock)& thePB) const
1011 return myMapPBCB.IsBound(thePB);
1014 //=======================================================================
1015 //function : CommonBlock
1017 //=======================================================================
1018 const Handle(BOPDS_CommonBlock)& BOPDS_DS::CommonBlock
1019 (const Handle(BOPDS_PaveBlock)& thePB) const
1021 Handle(BOPDS_CommonBlock) aNullCB;
1023 const Handle(BOPDS_CommonBlock)& aCB =
1024 IsCommonBlock(thePB) ? myMapPBCB.Find(thePB) : aNullCB;
1029 //=======================================================================
1030 //function : SetCommonBlock
1032 //=======================================================================
1033 void BOPDS_DS::SetCommonBlock(const Handle(BOPDS_PaveBlock)& thePB,
1034 const Handle(BOPDS_CommonBlock)& theCB)
1036 if (IsCommonBlock(thePB)) {
1037 Handle(BOPDS_CommonBlock)& aCB = myMapPBCB.ChangeFind(thePB);
1041 myMapPBCB.Bind(thePB, theCB);
1049 //=======================================================================
1050 //function : FaceInfoPool
1052 //=======================================================================
1053 const BOPDS_VectorOfFaceInfo& BOPDS_DS::FaceInfoPool()const
1055 return myFaceInfoPool;
1057 //=======================================================================
1058 //function : HasFaceInfo
1060 //=======================================================================
1061 Standard_Boolean BOPDS_DS::HasFaceInfo(const Standard_Integer theI)const
1063 return ShapeInfo(theI).HasReference();
1065 //=======================================================================
1066 //function : FaceInfo
1068 //=======================================================================
1069 const BOPDS_FaceInfo& BOPDS_DS::FaceInfo(const Standard_Integer theI)const
1071 static BOPDS_FaceInfo sFI;
1072 Standard_Integer aRef;
1074 if (HasFaceInfo(theI)) {
1075 aRef=ShapeInfo(theI).Reference();
1076 const BOPDS_FaceInfo& aFI=myFaceInfoPool(aRef);
1081 //=======================================================================
1082 //function : ChangeFaceInfo
1084 //=======================================================================
1085 BOPDS_FaceInfo& BOPDS_DS::ChangeFaceInfo(const Standard_Integer theI)
1087 Standard_Boolean bHasReference;
1088 Standard_Integer aRef;
1089 BOPDS_FaceInfo* pFI;
1091 BOPDS_ShapeInfo& aSI=ChangeShapeInfo(theI);
1092 bHasReference=aSI.HasReference();
1093 if (!bHasReference) {
1097 aRef=aSI.Reference();
1098 const BOPDS_FaceInfo& aFI=myFaceInfoPool(aRef);
1099 pFI=(BOPDS_FaceInfo*)&aFI;
1102 //=======================================================================
1103 //function : InitFaceInfo
1105 //=======================================================================
1106 void BOPDS_DS::InitFaceInfo(const Standard_Integer theI)
1108 Standard_Integer iRef;
1110 BOPDS_ShapeInfo& aSI=ChangeShapeInfo(theI);
1111 iRef=myFaceInfoPool.Append()-1;
1112 BOPDS_FaceInfo &aFI=myFaceInfoPool(iRef);
1113 aSI.SetReference(iRef);
1116 UpdateFaceInfoIn(theI);
1117 UpdateFaceInfoOn(theI);
1119 //=======================================================================
1120 //function : UpdateFaceInfoIn
1122 //=======================================================================
1123 void BOPDS_DS::UpdateFaceInfoIn(const Standard_Integer theI)
1125 Standard_Integer iRef;
1127 BOPDS_ShapeInfo& aSI=ChangeShapeInfo(theI);
1128 if (aSI.HasReference()) {
1129 iRef=aSI.Reference();
1130 BOPDS_FaceInfo &aFI=myFaceInfoPool(iRef);
1132 BOPDS_IndexedMapOfPaveBlock& aMPBIn=aFI.ChangePaveBlocksIn();
1133 BOPCol_MapOfInteger& aMVIn=aFI.ChangeVerticesIn();
1136 FaceInfoIn(theI, aMPBIn, aMVIn);
1139 //=======================================================================
1140 //function : UpdateFaceInfoOn
1142 //=======================================================================
1143 void BOPDS_DS::UpdateFaceInfoOn(const Standard_Integer theI)
1145 Standard_Integer iRef;
1147 BOPDS_ShapeInfo& aSI=ChangeShapeInfo(theI);
1148 if (aSI.HasReference()) {
1149 iRef=aSI.Reference();
1150 BOPDS_FaceInfo &aFI=myFaceInfoPool(iRef);
1152 BOPDS_IndexedMapOfPaveBlock& aMPBOn=aFI.ChangePaveBlocksOn();
1153 BOPCol_MapOfInteger& aMVOn=aFI.ChangeVerticesOn();
1156 FaceInfoOn(theI, aMPBOn, aMVOn);
1159 //=======================================================================
1160 //function : FaceInfoOn
1162 //=======================================================================
1163 void BOPDS_DS::FaceInfoOn(const Standard_Integer theF,
1164 BOPDS_IndexedMapOfPaveBlock& theMPB,
1165 BOPCol_MapOfInteger& theMI)
1167 Standard_Integer nS, nSD, nV1, nV2;
1168 BOPCol_ListIteratorOfListOfInteger aIt;
1169 BOPDS_ListIteratorOfListOfPaveBlock aItPB;
1171 const BOPDS_ShapeInfo& aSI=ShapeInfo(theF);
1172 const BOPCol_ListOfInteger& aLI=aSI.SubShapes();
1173 aIt.Initialize(aLI);
1174 for (; aIt.More(); aIt.Next()) {
1176 const BOPDS_ShapeInfo& aSIE=ShapeInfo(nS);
1177 if (aSIE.ShapeType()==TopAbs_EDGE) {
1178 const BOPDS_ListOfPaveBlock& aLPB=PaveBlocks(nS);
1179 aItPB.Initialize(aLPB);
1180 for (; aItPB.More(); aItPB.Next()) {
1181 const Handle(BOPDS_PaveBlock)& aPB=aItPB.Value();
1182 aPB->Indices(nV1, nV2);
1185 Handle(BOPDS_PaveBlock) aPBR=RealPaveBlock(aPB);
1188 }//if (aSIE.ShapeType()==TopAbs_EDGE)
1190 // nE is TopAbs_VERTEX
1191 if (HasShapeSD(nS, nSD)) {
1198 //=======================================================================
1199 //function : FaceInfoIn
1201 //=======================================================================
1202 void BOPDS_DS::FaceInfoIn(const Standard_Integer theF,
1203 BOPDS_IndexedMapOfPaveBlock& theMPB,
1204 BOPCol_MapOfInteger& theMI)
1206 Standard_Integer i, aNbVF, aNbEF, nV, nE;
1207 BOPDS_ListIteratorOfListOfPaveBlock aItPB;
1209 BOPDS_VectorOfInterfVF& aVFs=InterfVF();
1210 aNbVF=aVFs.Extent();
1211 for (i=0; i<aNbVF; ++i) {
1212 BOPDS_InterfVF& aVF=aVFs(i);
1213 if(aVF.Contains(theF)) {
1214 nV=aVF.OppositeIndex(theF);
1219 BOPDS_VectorOfInterfEF& aEFs=InterfEF();
1220 aNbEF=aEFs.Extent();
1221 for (i=0; i<aNbEF; ++i) {
1222 BOPDS_InterfEF& aEF=aEFs(i);
1223 if(aEF.Contains(theF)) {
1224 if(aEF.HasIndexNew(nV)) {
1228 nE=aEF.OppositeIndex(theF);
1229 const BOPDS_ListOfPaveBlock& aLPB=PaveBlocks(nE);
1230 aItPB.Initialize(aLPB);
1231 for (; aItPB.More(); aItPB.Next()) {
1232 const Handle(BOPDS_PaveBlock)& aPB=aItPB.Value();
1233 if (IsCommonBlock(aPB)) {
1234 const Handle(BOPDS_CommonBlock)& aCB=CommonBlock(aPB);
1235 if (aCB->Contains(theF)) {
1236 const Handle(BOPDS_PaveBlock)& aPB1=aCB->PaveBlock1();
1240 }// for (; aItPB.More(); aItPB.Next()) {
1242 }// if(aEF.Contains(theF)) {
1243 }// for (i=0; i<aNbEF; ++i) {
1246 //=======================================================================
1247 //function : RefineFaceInfoOn
1249 //=======================================================================
1250 void BOPDS_DS::RefineFaceInfoOn()
1252 Standard_Integer i, aNb, nF, aNbPB, j;
1253 BOPDS_IndexedMapOfPaveBlock aMPB;
1255 aNb=myFaceInfoPool.Extent();
1256 for (i=0; i<aNb; ++i) {
1257 BOPDS_FaceInfo &aFI=myFaceInfoPool(i);
1259 UpdateFaceInfoOn(nF);
1260 BOPDS_IndexedMapOfPaveBlock& aMPBOn=aFI.ChangePaveBlocksOn();
1263 aMPB.Assign(aMPBOn);
1266 aNbPB=aMPB.Extent();
1267 for (j=1; j<=aNbPB; ++j) {
1268 const Handle(BOPDS_PaveBlock)& aPB=aMPB(j);
1269 if (aPB->HasEdge()) {
1275 //=======================================================================
1276 //function : AloneVertices
1278 //=======================================================================
1279 void BOPDS_DS::AloneVertices(const Standard_Integer theI,
1280 BOPCol_ListOfInteger& theLI)const
1282 if (HasFaceInfo(theI)) {
1284 Standard_Integer i, nV1, nV2, nV;
1285 BOPDS_MapIteratorOfMapOfPaveBlock aItMPB;
1286 BOPCol_MapIteratorOfMapOfInteger aItMI;
1288 BOPCol_MapOfInteger aMI(100, myAllocator);
1290 const BOPDS_FaceInfo& aFI=FaceInfo(theI);
1292 for (i=0; i<2; ++i) {
1293 const BOPDS_IndexedMapOfPaveBlock& aMPB=(!i) ? aFI.PaveBlocksIn() : aFI.PaveBlocksSc();
1294 aItMPB.Initialize(aMPB);
1295 for (; aItMPB.More(); aItMPB.Next()) {
1296 const Handle(BOPDS_PaveBlock)& aPB=aItMPB.Value();
1297 aPB->Indices(nV1, nV2);
1303 for (i=0; i<2; ++i) {
1304 const BOPCol_MapOfInteger& aMIV=(!i) ? aFI.VerticesIn() : aFI.VerticesSc();
1305 aItMI.Initialize(aMIV);
1306 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 nV, nV1, nV2;
1328 BOPCol_MapIteratorOfMapOfInteger aIt;
1329 BOPDS_MapIteratorOfMapOfPaveBlock aItMPB;
1331 const BOPDS_FaceInfo& aFI1=FaceInfo(nF1);
1332 const BOPDS_FaceInfo& aFI2=FaceInfo(nF2);
1334 const BOPDS_IndexedMapOfPaveBlock& aMPBOn1=aFI1.PaveBlocksOn();
1335 aItMPB.Initialize(aMPBOn1);
1336 for (; aItMPB.More(); aItMPB.Next()) {
1337 const Handle(BOPDS_PaveBlock)& aPB=aItMPB.Value();
1339 aPB->Indices(nV1, nV2);
1344 const BOPDS_IndexedMapOfPaveBlock& aMPBIn1=aFI1.PaveBlocksIn();
1345 aItMPB.Initialize(aMPBIn1);
1346 for (; aItMPB.More(); aItMPB.Next()) {
1347 const Handle(BOPDS_PaveBlock)& aPB=aItMPB.Value();
1349 aPB->Indices(nV1, nV2);
1354 const BOPDS_IndexedMapOfPaveBlock& aMPBOn2=aFI2.PaveBlocksOn();
1355 aItMPB.Initialize(aMPBOn2);
1356 for (; aItMPB.More(); aItMPB.Next()) {
1357 const Handle(BOPDS_PaveBlock)& aPB=aItMPB.Value();
1359 aPB->Indices(nV1, nV2);
1364 const BOPDS_IndexedMapOfPaveBlock& aMPBIn2=aFI2.PaveBlocksIn();
1365 aItMPB.Initialize(aMPBIn2);
1366 for (; aItMPB.More(); aItMPB.Next()) {
1367 const Handle(BOPDS_PaveBlock)& aPB=aItMPB.Value();
1369 aPB->Indices(nV1, nV2);
1374 const BOPCol_MapOfInteger& aMVOn1=aFI1.VerticesOn();
1375 aIt.Initialize(aMVOn1);
1376 for (; aIt.More(); aIt.Next()) {
1381 const BOPCol_MapOfInteger& aMVIn1=aFI1.VerticesIn();
1382 aIt.Initialize(aMVIn1);
1383 for (; aIt.More(); aIt.Next()) {
1388 const BOPCol_MapOfInteger& aMVOn2=aFI2.VerticesOn();
1389 aIt.Initialize(aMVOn2);
1390 for (; aIt.More(); aIt.Next()) {
1395 const BOPCol_MapOfInteger& aMVIn2=aFI2.VerticesIn();
1396 aIt.Initialize(aMVIn2);
1397 for (; aIt.More(); aIt.Next()) {
1402 //=======================================================================
1403 //function : SharedEdges
1405 //=======================================================================
1406 void BOPDS_DS::SharedEdges(const Standard_Integer nF1,
1407 const Standard_Integer nF2,
1408 BOPCol_ListOfInteger& theLI,
1409 const Handle(NCollection_BaseAllocator)& aAllocator)
1411 Standard_Integer nE, nSp;
1412 BOPCol_ListIteratorOfListOfInteger aItLI;
1413 BOPDS_ListIteratorOfListOfPaveBlock aItLPB;
1414 BOPCol_MapOfInteger aMI(100, aAllocator);
1416 const BOPDS_ShapeInfo& aSI1=ShapeInfo(nF1);
1417 const BOPCol_ListOfInteger& aLI1=aSI1.SubShapes();
1418 aItLI.Initialize(aLI1);
1419 for (; aItLI.More(); aItLI.Next()) {
1421 const BOPDS_ShapeInfo& aSIE=ChangeShapeInfo(nE);
1422 if(aSIE.ShapeType()==TopAbs_EDGE) {
1423 const BOPDS_ListOfPaveBlock& aLPB=PaveBlocks(nE);
1424 if (aLPB.IsEmpty()) {
1428 aItLPB.Initialize(aLPB);
1429 for (; aItLPB.More(); aItLPB.Next()) {
1430 const Handle(BOPDS_PaveBlock) aPB=RealPaveBlock(aItLPB.Value());
1438 const BOPDS_ShapeInfo& aSI2=ShapeInfo(nF2);
1439 const BOPCol_ListOfInteger& aLI2=aSI2.SubShapes();
1440 aItLI.Initialize(aLI2);
1441 for (; aItLI.More(); aItLI.Next()) {
1443 const BOPDS_ShapeInfo& aSIE=ChangeShapeInfo(nE);
1444 if(aSIE.ShapeType()==TopAbs_EDGE) {
1445 const BOPDS_ListOfPaveBlock& aLPB=PaveBlocks(nE);
1446 if (aLPB.IsEmpty()) {
1447 if (aMI.Contains(nE)) {
1452 aItLPB.Initialize(aLPB);
1453 for (; aItLPB.More(); aItLPB.Next()) {
1454 const Handle(BOPDS_PaveBlock) aPB=RealPaveBlock(aItLPB.Value());
1456 if (aMI.Contains(nSp)) {
1465 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1467 // same domain shapes
1469 //=======================================================================
1470 //function : ShapesSD
1472 //=======================================================================
1473 BOPCol_DataMapOfIntegerInteger& BOPDS_DS::ShapesSD()
1477 //=======================================================================
1478 //function : AddShapeSD
1480 //=======================================================================
1481 void BOPDS_DS::AddShapeSD(const Standard_Integer theIndex,
1482 const Standard_Integer theIndexSD)
1484 myShapesSD.Bind(theIndex, theIndexSD);
1486 //=======================================================================
1487 //function : HasShapeSD
1489 //=======================================================================
1490 Standard_Boolean BOPDS_DS::HasShapeSD(const Standard_Integer theIndex,
1491 Standard_Integer& theIndexSD)const
1493 Standard_Boolean bRet;
1495 bRet=myShapesSD.IsBound(theIndex);
1497 theIndexSD=myShapesSD.Find(theIndex);
1501 //=======================================================================
1504 //=======================================================================
1505 void BOPDS_DS::Dump()const
1507 Standard_Integer i, aNb, aNbSS;
1509 printf(" *** DS ***\n");
1511 printf(" Ranges:%d\n", aNb);
1512 for (i=0; i<aNb; ++i) {
1513 const BOPDS_IndexRange& aR=Range(i);
1518 aNbSS=NbSourceShapes();
1519 printf(" Shapes:%d\n", aNbSS);
1521 for (i=0; i<aNb; ++i) {
1522 const BOPDS_ShapeInfo& aSI=ShapeInfo(i);
1527 printf(" ****** adds\n");
1530 printf(" ******\n");
1533 //=======================================================================
1534 // function: CheckCoincidence
1536 //=======================================================================
1537 Standard_Boolean BOPDS_DS::CheckCoincidence(const Handle(BOPDS_PaveBlock)& aPB1,
1538 const Handle(BOPDS_PaveBlock)& aPB2)
1540 Standard_Boolean bRet;
1541 Standard_Integer nE1, nE2, aNbPoints;
1542 Standard_Real aT11, aT12, aT21, aT22, aT1m, aD, aTol, aT2x;
1545 bRet=Standard_False;
1547 aPB1->Range(aT11, aT12);
1548 aT1m=IntTools_Tools::IntermediatePoint (aT11, aT12);
1549 nE1=aPB1->OriginalEdge();
1550 const TopoDS_Edge& aE1=(*(TopoDS_Edge*)(&Shape(nE1)));
1551 BOPTools_AlgoTools::PointOnEdge(aE1, aT1m, aP1m);
1553 aPB2->Range(aT21, aT22);
1554 nE2=aPB2->OriginalEdge();
1555 const TopoDS_Edge& aE2=(*(TopoDS_Edge*)(&Shape(nE2)));
1558 Handle(Geom_Curve)aC2 = BRep_Tool::Curve (aE2, f, l);
1559 GeomAPI_ProjectPointOnCurve aPPC;
1560 aPPC.Init(aC2, f, l);
1562 aNbPoints=aPPC.NbPoints();
1564 aD=aPPC.LowerDistance();
1566 aTol=BRep_Tool::Tolerance(aE1);
1567 aTol=aTol+BRep_Tool::Tolerance(aE2);
1569 aT2x=aPPC.LowerDistanceParameter();
1570 if (aT2x>aT21 && aT2x<aT22) {
1578 //=======================================================================
1579 // function: SortPaveBlocks
1581 //=======================================================================
1582 void BOPDS_DS::SortPaveBlocks(const Handle(BOPDS_CommonBlock)& aCB)
1584 Standard_Integer theI;
1585 Standard_Boolean bToSort;
1586 bToSort = IsToSort(aCB, theI);
1591 Standard_Integer i(0);
1592 const BOPDS_ListOfPaveBlock& aLPB = aCB->PaveBlocks();
1593 BOPDS_ListOfPaveBlock aLPBN = aLPB;
1595 Handle(BOPDS_PaveBlock) aPB;
1596 BOPDS_ListIteratorOfListOfPaveBlock aIt;
1598 aIt.Initialize(aLPBN);
1599 for (aIt.Next(); aIt.More(); ) {
1610 aCB->AddPaveBlocks(aLPBN);
1613 //=======================================================================
1614 // function: IsToSort
1616 //=======================================================================
1617 Standard_Boolean BOPDS_DS::IsToSort(const Handle(BOPDS_CommonBlock)& aCB,
1618 Standard_Integer& theI)
1620 Standard_Boolean bRet;
1621 bRet = Standard_False;
1622 const BOPDS_ListOfPaveBlock& aLPB = aCB->PaveBlocks();
1623 if (aLPB.Extent()==1) {
1627 Standard_Integer nE;
1628 Standard_Real aTolMax, aTol;
1629 Handle(BOPDS_PaveBlock) aPB;
1631 BOPDS_ListIteratorOfListOfPaveBlock aIt;
1634 nE = aPB->OriginalEdge();
1635 aE = (*(TopoDS_Edge *)(&Shape(nE)));
1636 aTolMax = BRep_Tool::Tolerance(aE);
1639 aIt.Initialize(aLPB);
1640 for (aIt.Next(); aIt.More(); aIt.Next()) {
1643 nE = aPB->OriginalEdge();
1644 aE = (*(TopoDS_Edge *)(&Shape(nE)));
1645 aTol = BRep_Tool::Tolerance(aE);
1646 if (aTolMax < aTol) {
1648 bRet = Standard_True;
1655 //=======================================================================
1656 // function: IsSubShape
1658 //=======================================================================
1659 Standard_Boolean BOPDS_DS::IsSubShape(const Standard_Integer theI1,
1660 const Standard_Integer theI2)
1662 Standard_Boolean bRet;
1663 Standard_Integer nS;
1664 bRet = Standard_False;
1666 BOPCol_ListIteratorOfListOfInteger aItLI;
1668 const BOPDS_ShapeInfo& aSI = ShapeInfo(theI2);
1669 const BOPCol_ListOfInteger& aLI = aSI.SubShapes();
1670 aItLI.Initialize(aLI);
1671 for(;aItLI.More(); aItLI.Next()) {
1674 bRet = Standard_True;
1682 //=======================================================================
1685 //=======================================================================
1686 void BOPDS_DS::Paves(const Standard_Integer theEdge,
1687 BOPDS_ListOfPave& theLP)
1689 Standard_Integer aNb, i;
1691 BOPDS_ListIteratorOfListOfPaveBlock aIt;
1692 BOPDS_MapOfPave aMP;
1694 const BOPDS_ListOfPaveBlock& aLPB = PaveBlocks(theEdge);
1695 aNb = aLPB.Extent();
1696 aNb = (aNb==0) ? 0 : (aNb+1);
1698 pPaves=(BOPDS_Pave *)myAllocator->Allocate(aNb*sizeof(BOPDS_Pave));
1699 for (i=0; i<aNb; ++i) {
1700 new (pPaves+i) BOPDS_Pave();
1704 for (aIt.Initialize(aLPB); aIt.More(); aIt.Next()) {
1705 const Handle(BOPDS_PaveBlock)& aPB = aIt.Value();
1706 if (aMP.Add(aPB->Pave1())){
1707 pPaves[i] = aPB->Pave1();
1710 if (aMP.Add(aPB->Pave2())){
1711 pPaves[i] = aPB->Pave2();
1716 SortShell(aNb, pPaves);
1718 for (i = 0; i < aNb; ++i) {
1719 theLP.Append(pPaves[i]);
1723 //=======================================================================
1724 // function: UpdateTolerance
1726 //=======================================================================
1727 void BOPDS_DS::UpdateEdgeTolerance(const Standard_Integer nE,
1728 const Standard_Real aTol)
1730 Standard_Integer nV;
1731 Standard_Real aTolV;
1733 BOPCol_ListIteratorOfListOfInteger aIt;
1735 const TopoDS_Edge& aE = *(TopoDS_Edge*)&Shape(nE);
1736 aBB.UpdateEdge(aE, aTol);
1737 BOPDS_ShapeInfo& aSIE=ChangeShapeInfo(nE);
1738 Bnd_Box& aBoxE=aSIE.ChangeBox();
1739 BRepBndLib::Add(aE, aBoxE);
1741 const BOPCol_ListOfInteger& aLI = aSIE.SubShapes();
1742 aIt.Initialize(aLI);
1743 for (; aIt.More(); aIt.Next()) {
1745 const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&Shape(nV);
1746 aTolV = BRep_Tool::Tolerance(aV);
1748 aBB.UpdateVertex(aV, aTol);
1749 BOPDS_ShapeInfo& aSIV = ChangeShapeInfo(nV);
1750 Bnd_Box& aBoxV = aSIV.ChangeBox();
1751 BRepBndLib::Add(aV, aBoxV);
1756 //=======================================================================
1757 //function : TotalShapes
1759 //=======================================================================
1760 void TotalShapes(const TopoDS_Shape& aS,
1761 Standard_Integer& aNbS)
1765 pS=(TopoDS_Shape *)&aS;
1766 if (!pS->Checked()) {
1767 TopoDS_Iterator aIt;
1772 for (; aIt.More(); aIt.Next()) {
1773 const TopoDS_Shape& aSx=aIt.Value();
1774 TotalShapes(aSx, aNbS);
1778 //=======================================================================
1779 //function : ResetShape
1781 //=======================================================================
1782 void ResetShape(const TopoDS_Shape& aS)
1786 pS=(TopoDS_Shape *)&aS;
1789 //=======================================================================
1790 //function : ResetShape
1792 //=======================================================================
1793 void ResetShapes(const TopoDS_Shape& aS)
1795 TopoDS_Iterator aIt;
1799 for (; aIt.More(); aIt.Next()) {
1800 const TopoDS_Shape& aSx=aIt.Value();
1804 #include <Geom_Curve.hxx>
1806 //=======================================================================
1807 //function : ComputeParameter
1809 //=======================================================================
1810 Standard_Real ComputeParameter(const TopoDS_Vertex& aV,
1811 const TopoDS_Edge& aE)
1813 Standard_Real aT1, aT2, aTRet, aTolE2, aD2;
1815 Handle(Geom_Curve) aC3D;
1819 aEE.Orientation(TopAbs_FORWARD);
1823 aTolE2=BRep_Tool::Tolerance(aE);
1824 aTolE2=aTolE2*aTolE2;
1826 aPV=BRep_Tool::Pnt(aV);
1828 aC3D=BRep_Tool::Curve (aEE, aT1, aT2);
1831 aD2=aPC.SquareDistance(aPV);
1837 aD2=aPC.SquareDistance(aPV);
1844 //=======================================================================
1845 // function: SortShell
1847 //=======================================================================
1848 void SortShell(const int n, BOPDS_Pave *a)
1850 int nd, i, j, l, d=1;
1861 for (i=0; i<nd; ++i) {
1870 if (j > -1) goto m30;
1871 }//if (a[l] < a[j]){
1872 }//for (i=0; i<nd; ++i)