1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File: GEOMAlgo_Gluer.cxx
21 // Created: Sat Dec 04 12:45:53 2004
22 // Author: Peter KURNEV
26 #include <GEOMAlgo_Gluer.ixx>
28 #include <NMTDS_BoxBndTree.hxx>
29 #include <NCollection_UBTreeFiller.hxx>
31 #include <TColStd_MapIteratorOfMapOfInteger.hxx>
32 #include <TColStd_MapOfInteger.hxx>
33 #include <TColStd_ListOfInteger.hxx>
34 #include <TColStd_ListIteratorOfListOfInteger.hxx>
40 #include <Geom_Curve.hxx>
41 #include <Geom_Surface.hxx>
43 #include <Bnd_Box.hxx>
44 #include <Bnd_HArray1OfBox.hxx>
45 #include <Bnd_BoundSortBox.hxx>
47 #include <TopLoc_Location.hxx>
48 #include <TopAbs_ShapeEnum.hxx>
49 #include <TopAbs_Orientation.hxx>
52 #include <TopoDS_Edge.hxx>
53 #include <TopoDS_Vertex.hxx>
54 #include <TopoDS_Shape.hxx>
55 #include <TopoDS_Compound.hxx>
56 #include <TopoDS_Wire.hxx>
57 #include <TopoDS_Shell.hxx>
58 #include <TopoDS_Solid.hxx>
59 #include <TopoDS_Iterator.hxx>
61 #include <TopTools_IndexedMapOfShape.hxx>
62 #include <TopTools_ListOfShape.hxx>
63 #include <TopTools_ListIteratorOfListOfShape.hxx>
64 #include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
65 #include <TopTools_MapOfShape.hxx>
66 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
69 #include <TopExp_Explorer.hxx>
71 #include <BRep_Tool.hxx>
72 #include <BRep_Builder.hxx>
73 #include <BRepLib.hxx>
74 #include <BRepTools.hxx>
75 #include <BRepBndLib.hxx>
77 #include <IntTools_Context.hxx>
78 #include <BOPTools_Tools.hxx>
79 #include <BOPTools_Tools3D.hxx>
80 #include <BOPTools_Tools2D.hxx>
81 #include <BOP_CorrectTolerances.hxx>
83 #include <GEOMAlgo_IndexedDataMapOfIntegerShape.hxx>
84 #include <GEOMAlgo_IndexedDataMapOfShapeBox.hxx>
85 #include <GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape.hxx>
86 #include <GEOMAlgo_PassKeyShape.hxx>
87 #include <GEOMAlgo_Tools.hxx>
91 void GetSubShapes(const TopoDS_Shape& aS,
92 TopTools_IndexedMapOfShape& aMSS);
94 //=======================================================================
95 //function : GEOMAlgo_Gluer
97 //=======================================================================
98 GEOMAlgo_Gluer::GEOMAlgo_Gluer()
104 myCheckGeometry=Standard_True;
107 //=======================================================================
108 //function : ~GEOMAlgo_Gluer
110 //=======================================================================
111 GEOMAlgo_Gluer::~GEOMAlgo_Gluer()
114 //=======================================================================
115 //function : SetCheckGeometry
117 //=======================================================================
118 void GEOMAlgo_Gluer::SetCheckGeometry(const Standard_Boolean aFlag)
120 myCheckGeometry=aFlag;
122 //=======================================================================
123 //function : CheckGeometry
125 //=======================================================================
126 Standard_Boolean GEOMAlgo_Gluer::CheckGeometry() const
128 return myCheckGeometry;
130 //=======================================================================
131 //function : AloneShapes
133 //=======================================================================
134 Standard_Integer GEOMAlgo_Gluer::AloneShapes()const
138 //=======================================================================
141 //=======================================================================
142 const TopTools_DataMapOfShapeListOfShape& GEOMAlgo_Gluer::Images()const
146 //=======================================================================
149 //=======================================================================
150 const TopTools_DataMapOfShapeShape& GEOMAlgo_Gluer::Origins()const
154 //=======================================================================
157 //=======================================================================
158 void GEOMAlgo_Gluer::Perform()
164 const Standard_Integer aNb=8;
165 void (GEOMAlgo_Gluer::* pF[aNb])()={
166 &GEOMAlgo_Gluer::CheckData, &GEOMAlgo_Gluer::InnerTolerance,
167 &GEOMAlgo_Gluer::MakeVertices, &GEOMAlgo_Gluer::MakeEdges,
168 &GEOMAlgo_Gluer::MakeFaces, &GEOMAlgo_Gluer::MakeShells,
169 &GEOMAlgo_Gluer::MakeSolids, &GEOMAlgo_Gluer::CheckResult
172 for (i=0; i<aNb; ++i) {
179 //=======================================================================
180 //function : MakeVertices
182 //=======================================================================
183 void GEOMAlgo_Gluer::MakeVertices()
187 Standard_Integer j, i, aNbV, aNbVSD;
188 TColStd_ListIteratorOfListOfInteger aIt;
191 TopTools_IndexedMapOfShape aMV, aMVProcessed;
192 TopTools_ListIteratorOfListOfShape aItS;
193 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItIm;
194 TopTools_DataMapOfShapeListOfShape aMVV;
195 GEOMAlgo_IndexedDataMapOfIntegerShape aMIS;
196 GEOMAlgo_IndexedDataMapOfShapeBox aMSB;
198 NMTDS_BoxBndTreeSelector aSelector;
199 NMTDS_BoxBndTree aBBTree;
200 NCollection_UBTreeFiller <Standard_Integer, Bnd_Box> aTreeFiller(aBBTree);
203 TopExp::MapShapes(myShape, TopAbs_VERTEX, aMV);
206 myErrorStatus=2; // no vertices in source shape
210 for (i=1; i<=aNbV; ++i) {
211 const TopoDS_Shape& aV=aMV(i);
215 BRepBndLib::Add(aV, aBox);
217 aTreeFiller.Add(i, aBox);
225 //------------------------------
227 for (i=1; i<=aNbV; ++i) {
228 const TopoDS_Shape& aV=aMV(i);
230 if (aMVProcessed.Contains(aV)) {
234 Standard_Integer aNbIP, aIP, aNbIP1, aIP1;
235 TopTools_ListOfShape aLVSD;
236 TColStd_MapOfInteger aMIP, aMIP1, aMIPC;
237 TColStd_MapIteratorOfMapOfInteger aIt1;
242 aIt1.Initialize(aMIP);
243 for(; aIt1.More(); aIt1.Next()) {
245 if (aMIPC.Contains(aIP)) {
249 const TopoDS_Shape& aVP=aMIS.FindFromKey(aIP);
250 const Bnd_Box& aBoxVP=aMSB.FindFromKey(aVP);
253 aSelector.SetBox(aBoxVP);
255 aNbVSD=aBBTree.Select(aSelector);
257 continue; // it must not be
260 const TColStd_ListOfInteger& aLI=aSelector.Indices();
262 for (; aIt.More(); aIt.Next()) {
264 if (aMIP.Contains(aIP1)) {
268 } //for (; aIt.More(); aIt.Next()) {
269 }//for(; aIt1.More(); aIt1.Next()) {
271 aNbIP1=aMIP1.Extent();
276 aIt1.Initialize(aMIP);
277 for(; aIt1.More(); aIt1.Next()) {
283 aIt1.Initialize(aMIP1);
284 for(; aIt1.More(); aIt1.Next()) {
292 aNbIP=aMIPC.Extent();
294 if (!aNbIP) {// no SD vertices founded
297 aMVProcessed.Add(aV);
299 else { // SD vertices founded [ aMIPC ]
300 aIt1.Initialize(aMIPC);
301 for(j=0; aIt1.More(); aIt1.Next(), ++j) {
303 const TopoDS_Shape& aVP=aMIS.FindFromKey(aIP);
308 aMVProcessed.Add(aVP);
311 myImages.Bind(aVF, aLVSD);
312 }// for (i=1; i<=aNbV; ++i) {
313 //------------------------------
317 aItIm.Initialize(myImages);
318 for (; aItIm.More(); aItIm.Next()) {
319 const TopoDS_Shape& aV=aItIm.Key();
320 const TopTools_ListOfShape& aLVSD=aItIm.Value();
321 aNbVSD=aLVSD.Extent();
324 MakeVertex(aLVSD, aVnew);
325 aMVV.Bind(aVnew, aLVSD);
329 // UnBind old vertices
331 for (i=1; i<=aNbV; ++i) {
332 const TopoDS_Shape& aV=aMV(i);
337 aItIm.Initialize(aMVV);
338 for (; aItIm.More(); aItIm.Next()) {
339 const TopoDS_Shape& aV=aItIm.Key();
340 const TopTools_ListOfShape& aLVSD=aItIm.Value();
341 myImages.Bind(aV, aLVSD);
345 aItIm.Initialize(myImages);
346 for (; aItIm.More(); aItIm.Next()) {
347 const TopoDS_Shape& aV=aItIm.Key();
348 const TopTools_ListOfShape& aLVSD=aItIm.Value();
349 aItS.Initialize(aLVSD);
350 for (; aItS.More(); aItS.Next()) {
351 const TopoDS_Shape& aVSD=aItS.Value();
352 if (!myOrigins.IsBound(aVSD)) {
353 myOrigins.Bind(aVSD, aV);
358 //=======================================================================
359 //function : MakeSolids
361 //=======================================================================
362 void GEOMAlgo_Gluer::MakeSolids()
366 Standard_Integer aNbS;
367 TopAbs_Orientation anOr;
368 TopoDS_Compound aCmp;
369 TopoDS_Solid aNewSolid;
370 TopTools_IndexedMapOfShape aMS;
371 TopExp_Explorer aExpS, aExp;
374 aBB.MakeCompound(aCmp);
377 aExpS.Init(myShape, TopAbs_SOLID);
378 for (; aExpS.More(); aExpS.Next()) {
379 const TopoDS_Solid& aSolid=TopoDS::Solid(aExpS.Current());
380 if (aMS.Contains(aSolid)) {
385 anOr=aSolid.Orientation();
387 aBB.MakeSolid(aNewSolid);
388 aNewSolid.Orientation(anOr);
390 aExp.Init(aSolid, TopAbs_SHELL);
391 for (; aExp.More(); aExp.Next()) {
392 const TopoDS_Shape& aShell=aExp.Current();
393 const TopoDS_Shape& aShellR=myOrigins.Find(aShell);
394 aBB.Add(aNewSolid, aShellR);
397 TopTools_ListOfShape aLS;
400 myImages.Bind(aNewSolid, aLS);
401 myOrigins.Bind(aSolid, aNewSolid);
403 aBB.Add(aCmp, aNewSolid);
410 Standard_Real aTol=1.e-7;
411 BOP_CorrectTolerances::CorrectCurveOnSurface(myResult);
414 //=======================================================================
415 //function : MakeShells
417 //=======================================================================
418 void GEOMAlgo_Gluer::MakeShells()
422 Standard_Boolean bIsToReverse;
423 Standard_Integer i, aNbS;
424 TopAbs_Orientation anOr;
425 TopoDS_Shell aNewShell;
427 TopTools_IndexedMapOfShape aMS;
428 TopExp_Explorer aExp;
431 TopExp::MapShapes(myShape, TopAbs_SHELL, aMS);
434 for (i=1; i<=aNbS; ++i) {
435 const TopoDS_Shell& aShell=TopoDS::Shell(aMS(i));
436 anOr=aShell.Orientation();
438 aBB.MakeShell(aNewShell);
439 aNewShell.Orientation(anOr);
440 aExp.Init(aShell, TopAbs_FACE);
441 for (; aExp.More(); aExp.Next()) {
442 const TopoDS_Face& aF=TopoDS::Face(aExp.Current());
443 aFR=TopoDS::Face(myOrigins.Find(aF));
444 if (aFR.IsSame(aF)) {
445 aBB.Add(aNewShell, aF);
448 bIsToReverse=IsToReverse(aFR, aF);
452 aBB.Add(aNewShell, aFR);
455 TopTools_ListOfShape aLS;
458 myImages.Bind(aNewShell, aLS);
459 myOrigins.Bind(aShell, aNewShell);
462 //=======================================================================
463 //function : MakeFaces
465 //=======================================================================
466 void GEOMAlgo_Gluer::MakeFaces()
468 MakeShapes(TopAbs_FACE);
470 //=======================================================================
471 //function : MakeEdges
473 //=======================================================================
474 void GEOMAlgo_Gluer::MakeEdges()
476 MakeShapes(TopAbs_EDGE);
478 //=======================================================================
479 //function : MakeShapes
481 //=======================================================================
482 void GEOMAlgo_Gluer::MakeShapes(const TopAbs_ShapeEnum aType)
486 Standard_Boolean bHasNewSubShape;
487 Standard_Integer i, aNbF, aNbSDF, iErr;
488 TopoDS_Shape aNewShape;
489 TopTools_IndexedMapOfShape aMF;
490 TopTools_ListIteratorOfListOfShape aItS;
491 GEOMAlgo_PassKeyShape aPKF;
492 GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape aMPKLF;
494 TopExp::MapShapes(myShape, aType, aMF);
497 for (i=1; i<=aNbF; ++i) {
498 const TopoDS_Shape& aS=aMF(i);
500 if (aType==TopAbs_FACE) {
501 const TopoDS_Face& aF=TopoDS::Face(aS);
502 FacePassKey(aF, aPKF);
504 else if (aType==TopAbs_EDGE) {
505 const TopoDS_Edge& aE=TopoDS::Edge(aS);
506 EdgePassKey(aE, aPKF);
513 if (aMPKLF.Contains(aPKF)) {
514 TopTools_ListOfShape& aLSDF=aMPKLF.ChangeFromKey(aPKF);
518 TopTools_ListOfShape aLSDF;
521 aMPKLF.Add(aPKF, aLSDF);
524 // check geometric coincidence
525 if (myCheckGeometry) {
526 iErr=GEOMAlgo_Tools::RefineSDShapes(aMPKLF, myTol, myContext);
535 aNbF=aMPKLF.Extent();
536 for (i=1; i<=aNbF; ++i) {
537 const TopTools_ListOfShape& aLSDF=aMPKLF(i);
538 aNbSDF=aLSDF.Extent();
540 myErrorStatus=4; // it must not be
543 const TopoDS_Shape& aS1=aLSDF.First();
545 bHasNewSubShape=Standard_True;
546 // prevent creation of a new shape if there are not
547 // new subshapes of aSS among the originals
549 bHasNewSubShape=HasNewSubShape(aS1);
550 if (!bHasNewSubShape) {
552 aNewShape.Orientation(TopAbs_FORWARD);
556 if (bHasNewSubShape) {
557 if (aType==TopAbs_FACE) {
558 TopoDS_Face aNewFace;
560 const TopoDS_Face& aF1=TopoDS::Face(aS1);
561 MakeFace(aF1, aNewFace);
564 else if (aType==TopAbs_EDGE) {
565 TopoDS_Edge aNewEdge;
567 const TopoDS_Edge& aE1=TopoDS::Edge(aS1);
568 MakeEdge(aE1, aNewEdge);
573 myImages.Bind(aNewShape, aLSDF);
575 aItS.Initialize(aLSDF);
576 for (; aItS.More(); aItS.Next()) {
577 const TopoDS_Shape& aFSD=aItS.Value();
578 if (!myOrigins.IsBound(aFSD)) {
579 myOrigins.Bind(aFSD, aNewShape);
584 //=======================================================================
585 //function : CheckResult
587 //=======================================================================
588 void GEOMAlgo_Gluer::CheckResult()
592 if (myResult.IsNull()) {
597 Standard_Boolean bFound;
598 Standard_Integer i, j, aNbS, aNbFS, aNbSx;
599 TopTools_IndexedMapOfShape aMS, aMFS;
600 TopTools_IndexedDataMapOfShapeListOfShape aMFR;
602 TopExp::MapShapesAndAncestors(myResult, TopAbs_FACE, TopAbs_SOLID, aMFR);
603 TopExp::MapShapes(myResult, TopAbs_SOLID, aMS);
608 for (i=1; i<=aNbS; ++i) {
609 const TopoDS_Shape& aSolid=aMS(i);
612 TopExp::MapShapes(aSolid, TopAbs_FACE, aMFS);
614 bFound=Standard_False;
616 for (j=1; j<=aNbFS; ++j) {
617 const TopoDS_Shape& aFS=aMFS(j);
618 if (aMFR.Contains(aFS)) {
619 const TopTools_ListOfShape& aLSx=aMFR.FindFromKey(aFS);
635 //=======================================================================
636 //function : CheckData
638 //=======================================================================
639 void GEOMAlgo_Gluer::CheckData()
643 if (myShape.IsNull()) {
648 //=======================================================================
649 //function : InnerTolerance
651 //=======================================================================
652 void GEOMAlgo_Gluer::InnerTolerance()
658 Standard_Real aX[3][2], dH, dHmin, aCoef, aTolTresh;
661 BRepBndLib::Add(myShape, aBox);
662 aBox.Get(aX[0][0], aX[1][0], aX[2][0], aX[0][1], aX[1][1], aX[2][1]);
664 dHmin=aX[0][1]-aX[0][0];
665 for (i=1; i<3; ++i) {
666 dH=aX[i][1]-aX[i][0];
674 aTolTresh=aCoef*dHmin;
675 if (myTol>aTolTresh) {
681 //=======================================================================
682 //function : FacePassKey
684 //=======================================================================
685 void GEOMAlgo_Gluer::FacePassKey(const TopoDS_Face& aF,
686 GEOMAlgo_PassKeyShape& aPK)
688 Standard_Integer i, aNbE;
689 TopTools_ListOfShape aLE;
690 TopTools_IndexedMapOfShape aME;
692 TopExp::MapShapes(aF, TopAbs_EDGE, aME);
695 for (i=1; i<=aNbE; ++i) {
696 const TopoDS_Shape& aE=aME(i);
697 if (!myOrigins.IsBound(aE)) {
701 const TopoDS_Shape& aER=myOrigins.Find(aE);
706 //=======================================================================
707 //function : EdgePassKey
709 //=======================================================================
710 void GEOMAlgo_Gluer::EdgePassKey(const TopoDS_Edge& aE,
711 GEOMAlgo_PassKeyShape& aPK)
713 TopoDS_Vertex aV1, aV2;
715 TopExp::Vertices(aE, aV1, aV2);
717 if (!myOrigins.IsBound(aV1) || !myOrigins.IsBound(aV2) ) {
721 const TopoDS_Shape& aVR1=myOrigins.Find(aV1);
722 const TopoDS_Shape& aVR2=myOrigins.Find(aV2);
723 aPK.SetShapes(aVR1, aVR2);
725 //=======================================================================
726 //function : MakeVertex
728 //=======================================================================
729 void GEOMAlgo_Gluer::MakeVertex(const TopTools_ListOfShape& aLV,
730 TopoDS_Vertex& aNewVertex)
732 Standard_Integer aNbV;
733 Standard_Real aTolV, aD, aDmax;
738 TopTools_ListIteratorOfListOfShape aIt;
746 aGC.SetCoord(0.,0.,0.);
748 for (; aIt.More(); aIt.Next()) {
749 aVx=TopoDS::Vertex(aIt.Value());
750 aP3D=BRep_Tool::Pnt(aVx);
753 aGC/=(Standard_Real)aNbV;
759 for (; aIt.More(); aIt.Next()) {
760 aVx=TopoDS::Vertex(aIt.Value());
761 aP3D=BRep_Tool::Pnt(aVx);
762 aTolV=BRep_Tool::Tolerance(aVx);
763 aD=aPGC.Distance(aP3D)+aTolV;
769 aBB.MakeVertex (aNewVertex, aPGC, aDmax);
771 //=======================================================================
772 //function : MakeEdge
774 //=======================================================================
775 void GEOMAlgo_Gluer::MakeEdge(const TopoDS_Edge& aE,
776 TopoDS_Edge& aNewEdge)
780 Standard_Boolean bIsDE;
781 Standard_Real aT1, aT2;
782 TopoDS_Vertex aV1, aV2, aVR1, aVR2;
785 bIsDE=BRep_Tool::Degenerated(aE);
788 aEx.Orientation(TopAbs_FORWARD);
790 TopExp::Vertices(aEx, aV1, aV2);
792 aT1=BRep_Tool::Parameter(aV1, aEx);
793 aT2=BRep_Tool::Parameter(aV2, aEx);
795 aVR1=TopoDS::Vertex(myOrigins.Find(aV1));
796 aVR1.Orientation(TopAbs_FORWARD);
797 aVR2=TopoDS::Vertex(myOrigins.Find(aV2));
798 aVR2.Orientation(TopAbs_REVERSED);
804 TopAbs_Orientation anOrE;
806 anOrE=aE.Orientation();
807 aTol=BRep_Tool::Tolerance(aE);
814 aBB.Range(E, aT1, aT2);
815 aBB.Degenerated(E, Standard_True);
816 aBB.UpdateEdge(E, aTol);
822 BOPTools_Tools::MakeSplitEdge(aEx, aVR1, aT1, aVR2, aT2, aNewEdge);
825 //=======================================================================
826 //function : MakeFace
828 //=======================================================================
829 void GEOMAlgo_Gluer::MakeFace(const TopoDS_Face& aF,
830 TopoDS_Face& aNewFace)
834 Standard_Boolean bIsToReverse, bIsUPeriodic;
835 Standard_Real aTol, aUMin, aUMax, aVMin, aVMax;
838 TopoDS_Face aFFWD, newFace;
839 TopLoc_Location aLoc;
840 Handle(Geom_Surface) aS;
841 Handle(Geom2d_Curve) aC2D;
842 TopExp_Explorer aExpW, aExpE;
846 aFFWD.Orientation(TopAbs_FORWARD);
848 aS=BRep_Tool::Surface(aFFWD, aLoc);
849 bIsUPeriodic=GEOMAlgo_Tools::IsUPeriodic(aS);
850 aTol=BRep_Tool::Tolerance(aFFWD);
851 BRepTools::UVBounds(aF, aUMin, aUMax, aVMin, aVMax);
853 aBB.MakeFace (newFace, aS, aLoc, aTol);
855 aExpW.Init(aFFWD, TopAbs_WIRE);
856 for (; aExpW.More(); aExpW.Next()) {
857 aBB.MakeWire(newWire);
858 const TopoDS_Wire& aW=TopoDS::Wire(aExpW.Current());
859 aExpE.Init(aW, TopAbs_EDGE);
860 for (; aExpE.More(); aExpE.Next()) {
861 const TopoDS_Edge& aE=TopoDS::Edge(aExpE.Current());
862 aER=TopoDS::Edge(myOrigins.Find(aE));
864 aER.Orientation(TopAbs_FORWARD);
865 if (!BRep_Tool::Degenerated(aER)) {
868 GEOMAlgo_Tools::RefinePCurveForEdgeOnFace(aER, aFFWD, aUMin, aUMax);
870 BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aER, aFFWD);
873 bIsToReverse=BOPTools_Tools3D::IsSplitToReverse1(aER, aE, myContext);
879 aER.Orientation(aE.Orientation());
882 aBB.Add(newWire, aER);
885 TopTools_ListOfShape aLW;
888 myImages.Bind(newWire, aLW);
889 myOrigins.Bind(aW, newWire);
891 aBB.Add(newFace, newWire);
895 //=======================================================================
896 //function : IsToReverse
898 //=======================================================================
899 Standard_Boolean GEOMAlgo_Gluer::IsToReverse(const TopoDS_Face& aFR,
900 const TopoDS_Face& aF)
902 Standard_Boolean bRet;
903 Standard_Real aT, aT1, aT2, aTR, aScPr;
904 TopExp_Explorer aExp;
905 Handle(Geom_Curve)aC3D;
911 aExp.Init(aF, TopAbs_EDGE);
912 for (; aExp.More(); aExp.Next()) {
913 const TopoDS_Edge& aE=TopoDS::Edge(aExp.Current());
915 if (BRep_Tool::Degenerated(aE)) {
919 const TopoDS_Edge& aER=TopoDS::Edge(myOrigins.Find(aE));
921 aC3D=BRep_Tool::Curve(aE, aT1, aT2);
922 aT=BOPTools_Tools2D::IntermediatePoint(aT1, aT2);
924 myContext.ProjectPointOnEdge(aP, aER, aTR);
926 BOPTools_Tools3D::GetNormalToFaceOnEdge (aE, aF, aT, aDNF);
927 if (aF.Orientation()==TopAbs_REVERSED) {
931 BOPTools_Tools3D::GetNormalToFaceOnEdge (aER, aFR, aTR, aDNFR);
932 if (aFR.Orientation()==TopAbs_REVERSED) {
941 //=======================================================================
942 //function : HasNewSubShape
944 //=======================================================================
945 Standard_Boolean GEOMAlgo_Gluer::HasNewSubShape(const TopoDS_Shape& aS)const
947 Standard_Boolean bRet;
948 Standard_Integer i, aNbSS;
949 TopTools_IndexedMapOfShape aMSS;
951 GetSubShapes(aS, aMSS);
955 for (i=1; i<=aNbSS; ++i) {
956 const TopoDS_Shape& aSS=aMSS(i);
957 if (aSS.ShapeType()==TopAbs_WIRE) {
961 bRet=!myOrigins.IsBound(aSS);
966 const TopoDS_Shape& aSSIm=myOrigins.Find(aSS);
967 bRet=!aSSIm.IsSame(aSS);
974 //=======================================================================
975 //function : GetSubShapes
977 //=======================================================================
978 void GetSubShapes(const TopoDS_Shape& aS,
979 TopTools_IndexedMapOfShape& aMSS)
982 TopAbs_ShapeEnum aType;
985 aType=aS.ShapeType();
986 aR=(Standard_Integer)aType+1;
987 if (aR>TopAbs_VERTEX) {
992 for (; aIt.More(); aIt.Next()) {
993 const TopoDS_Shape& aSS=aIt.Value();
995 GetSubShapes(aSS, aMSS);
998 //=======================================================================
999 //function : Modified
1001 //=======================================================================
1002 const TopTools_ListOfShape& GEOMAlgo_Gluer::Modified (const TopoDS_Shape& aS)
1004 TopAbs_ShapeEnum aType;
1006 myGenerated.Clear();
1008 aType=aS.ShapeType();
1009 if (aType==TopAbs_VERTEX ||
1010 aType==TopAbs_EDGE ||
1011 aType==TopAbs_WIRE ||
1012 aType==TopAbs_FACE ||
1013 aType==TopAbs_SHELL ||
1014 aType==TopAbs_SOLID) {
1015 if(myOrigins.IsBound(aS)) {
1016 const TopoDS_Shape& aSnew=myOrigins.Find(aS);
1017 if (!aSnew.IsSame(aS)) {
1018 myGenerated.Append(aSnew);
1025 //=======================================================================
1026 //function : Generated
1028 //=======================================================================
1029 const TopTools_ListOfShape& GEOMAlgo_Gluer::Generated(const TopoDS_Shape& )
1031 myGenerated.Clear();
1034 //=======================================================================
1035 //function : IsDeleted
1037 //=======================================================================
1038 Standard_Boolean GEOMAlgo_Gluer::IsDeleted (const TopoDS_Shape& aS)
1040 Standard_Boolean bRet=Standard_False;
1042 const TopTools_ListOfShape& aL=Modified(aS);
1050 // 1 - the object is just initialized
1051 // 2 - no vertices found in source shape
1052 // 3 - nb same domain vertices for the vertex Vi =0
1053 // 4 - nb same domain edges(faces) for the edge Ei(face Fi) =0
1054 // 5 - source shape is Null
1055 // 6 - result shape is Null
1056 // 101 - nb edges > PassKey.NbMax() in FacesPassKey()
1057 // 102 - the edge Ei can not be found in myOrigins Map
1058 // 100 - the vertex Vi can not be found in myOrigins Map
1062 // 1 - some shapes can not be glued by faces