Salome HOME
2e525fd26432624f3de4349d39368e304ffa5fbf
[modules/geom.git] / NMTTools_PaveFiller_9.cxx
1 // File:        NMTTools_PaveFiller_9.cxx
2 // Created:     Fri Dec 19 11:15:53 2003
3 // Author:      Peter KURNEV
4 //              <pkv@irinox>
5
6 #include <NMTTools_PaveFiller.ixx>
7
8 #include <Geom_Surface.hxx>
9
10 #include <TopLoc_Location.hxx>
11 #include <TopAbs_Orientation.hxx>
12
13 #include <TopoDS.hxx>
14 #include <TopoDS_Face.hxx>
15 #include <TopoDS_Wire.hxx>
16 #include <TopoDS_Edge.hxx>
17 #include <TopoDS_Shape.hxx>
18
19 #include <BRep_Builder.hxx>
20 #include <BRep_Tool.hxx>
21
22 #include <TopExp_Explorer.hxx>
23
24 #include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
25 #include <BOPTools_ListOfPaveBlock.hxx>
26 #include <BOPTools_PaveBlock.hxx>
27 #include <BOPTools_Tools3D.hxx>
28
29 #include <NMTDS_ShapesDataStructure.hxx>
30
31 #include <NMTTools_CommonBlockAPI.hxx>
32 #include <NMTTools_CommonBlock.hxx>
33
34
35 //=======================================================================
36 // function: PrepareFace
37 // purpose: 
38 //=======================================================================
39   void NMTTools_PaveFiller::PrepareFace(const Standard_Integer nF, 
40                                         TopoDS_Face& newFace)
41 {
42   Standard_Boolean bToReverse, bIsDegenerated;
43   Standard_Integer iRankF, nE, nSp, aNbPB;
44   Standard_Real aTol;
45   TopLoc_Location aLoc;
46   TopoDS_Face aF;
47   TopoDS_Wire newWire;
48   TopoDS_Edge aSp;
49   TopAbs_Orientation anOrF, anOrE;
50   BRep_Builder aBB;
51   TopExp_Explorer aExpW, aExpE;
52   BOPTools_ListIteratorOfListOfPaveBlock aItPB;
53   //
54   iRankF=myDS->Rank(nF);
55   aF=TopoDS::Face(myDS->Shape(nF));
56   anOrF=aF.Orientation();
57   aF.Orientation(TopAbs_FORWARD);
58   //
59   Handle(Geom_Surface) aS=BRep_Tool::Surface(aF, aLoc);
60   aTol=BRep_Tool::Tolerance(aF);
61   //
62   aBB.MakeFace (newFace, aS, aLoc, aTol);
63   //
64   aExpW.Init(aF, TopAbs_WIRE);
65   for (; aExpW.More(); aExpW.Next()) {
66     const TopoDS_Shape& aW=aExpW.Current();
67     aBB.MakeWire(newWire);
68     //
69     aExpE.Init(aW, TopAbs_EDGE);
70     for (; aExpE.More(); aExpE.Next()) {
71       const TopoDS_Edge& aE=TopoDS::Edge(aExpE.Current());
72       bIsDegenerated=BRep_Tool::Degenerated(aE);
73       anOrE=aE.Orientation();
74       //
75       nE=myDS->ShapeIndex(aE, iRankF);
76       const BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(nE));
77       aNbPB=aLPB.Extent();
78       if (!aNbPB) {
79         aBB.Add(newWire, aE);
80         continue;
81       }
82       //
83       aItPB.Initialize(aLPB);
84       for (; aItPB.More(); aItPB.Next()) {
85         const BOPTools_PaveBlock& aPB=aItPB.Value();
86         const BOPTools_PaveBlock& aPBR=RealPaveBlock(aPB);
87         nSp=aPBR.Edge();
88         //
89         aSp=TopoDS::Edge(myDS->Shape(nSp));
90         if (!bIsDegenerated) {
91           bToReverse=BOPTools_Tools3D::IsSplitToReverse1(aSp, aE, myContext);
92           if (bToReverse) {
93             aSp.Reverse();
94           }
95         }
96         else {
97          aSp.Orientation(anOrE);
98         }
99         aBB.Add(newWire, aSp);
100       }
101     }
102     aBB.Add(newFace, newWire);
103   }
104   newFace.Orientation(anOrF);
105 }