Salome HOME
Update mail address
[modules/geom.git] / src / NMTTools / NMTTools_PCurveMaker.cxx
1 // Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 // 
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.
8 // 
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.
13 //
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
17 //
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 //
20 // File:        NMTTools_PCurveMaker.cxx
21 // Created:     
22 // Author:      Peter KURNEV
23 //              <pkv@irinox>
24
25
26 #include <NMTTools_PCurveMaker.ixx>
27
28 #include <gp_Pnt2d.hxx>
29
30 #include <Precision.hxx>
31
32 #include <Geom_Curve.hxx>
33 #include <Geom_TrimmedCurve.hxx>
34 #include <Geom2d_Curve.hxx>
35 #include <GeomAdaptor_Curve.hxx>
36 #include <GeomAdaptor_HCurve.hxx>
37
38 #include <TopoDS.hxx>
39 #include <TopoDS_Face.hxx>
40 #include <TopoDS_Edge.hxx>
41 #include <TopoDS_Vertex.hxx>
42
43 #include <TopExp.hxx>
44 #include <TopTools_IndexedMapOfShape.hxx>
45
46 #include <BRep_Tool.hxx>
47 #include <BRep_Builder.hxx>
48 #include <BRepAdaptor_HSurface.hxx>
49
50 #include <NMTDS_ShapesDataStructure.hxx>
51 #include <NMTTools_DSFiller.hxx>
52
53 #include <IntTools_Curve.hxx>
54
55 #include <BOPTools_InterferencePool.hxx>
56 #include <BOPTools_CArray1OfSSInterference.hxx>
57 #include <BOPTools_SSInterference.hxx>
58 #include <BOPTools_ListOfPaveBlock.hxx>
59 #include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
60 #include <BOPTools_PaveBlock.hxx>
61 #include <BOPTools_Tools2D.hxx>
62 #include <NMTTools_PaveFiller.hxx>
63
64
65 //=======================================================================
66 // function: NMTTools_PCurveMaker
67 // purpose: 
68 //=======================================================================
69   NMTTools_PCurveMaker::NMTTools_PCurveMaker(NMTTools_PDSFiller& pDSFiller)
70 :
71   myIsDone(Standard_False)
72 {
73   myDSFiller=pDSFiller;
74 }
75 //=======================================================================
76 // function: IsDone
77 // purpose: 
78 //=======================================================================
79   Standard_Boolean NMTTools_PCurveMaker::IsDone() const
80 {
81   return myIsDone;
82 }
83 //=======================================================================
84 // function: Do
85 // purpose: 
86 //=======================================================================
87   void NMTTools_PCurveMaker::Do()
88 {
89   Standard_Integer i, aNb,  nF1, nF2, nE;
90   BOPTools_ListIteratorOfListOfPaveBlock anIt;
91   TopoDS_Face aF1FWD, aF2FWD;
92   //
93   NMTTools_PaveFiller *pFiller=(NMTTools_PaveFiller*) &(myDSFiller->PaveFiller());
94   NMTDS_ShapesDataStructure *pDS=pFiller->DS();
95   //
96   BOPTools_CArray1OfSSInterference& aFFs=(pFiller->InterfPool())->SSInterferences();
97   //
98   aNb=aFFs.Extent();
99   for (i=1; i<=aNb; ++i) {
100     BOPTools_SSInterference& aFF=aFFs(i);
101     // Faces
102     aFF.Indices(nF1, nF2);
103     const TopoDS_Face& aF1=TopoDS::Face(pDS->Shape(nF1));
104     const TopoDS_Face& aF2=TopoDS::Face(pDS->Shape(nF2));
105     //
106     // 1.Forwarding the Faces
107     aF1FWD=aF1;
108     aF1FWD.Orientation(TopAbs_FORWARD);
109     aF2FWD=aF2;
110     aF2FWD.Orientation(TopAbs_FORWARD);
111     //
112     // 2. In, On parts processing
113     const BOPTools_ListOfPaveBlock& aLPBInOn=aFF.PaveBlocks();
114     anIt.Initialize(aLPBInOn);
115     for (; anIt.More(); anIt.Next()) {
116       const BOPTools_PaveBlock& aPB=anIt.Value();
117       const BOPTools_PaveBlock& aPBInOn=pFiller->RealPaveBlock(aPB);
118       //
119       nE=aPBInOn.Edge();
120       const TopoDS_Edge& aE=TopoDS::Edge(pDS->Shape(nE));
121       
122       BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aE, aF1FWD);
123       BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aE, aF2FWD);
124     }
125   } //  for (i=1; i<=aNb; i++)
126   myIsDone=Standard_True;
127 }
128