Salome HOME
Mantis issue 0020894: EDF 1421 GEOM: Partition Bug with big geometrical objects....
[modules/geom.git] / src / NMTTools / NMTTools_PCurveMaker.cxx
1 //  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 // File:        NMTTools_PCurveMaker.cxx
24 // Created:     
25 // Author:      Peter KURNEV
26 //              <pkv@irinox>
27 //
28 #include <NMTTools_PCurveMaker.ixx>
29
30 #include <gp_Pnt2d.hxx>
31
32 #include <Precision.hxx>
33
34 #include <Geom_Curve.hxx>
35 #include <Geom_TrimmedCurve.hxx>
36 #include <Geom2d_Curve.hxx>
37 #include <GeomAdaptor_Curve.hxx>
38 #include <GeomAdaptor_HCurve.hxx>
39
40 #include <TopoDS.hxx>
41 #include <TopoDS_Face.hxx>
42 #include <TopoDS_Edge.hxx>
43 #include <TopoDS_Vertex.hxx>
44
45 #include <TopExp.hxx>
46 #include <TopTools_IndexedMapOfShape.hxx>
47
48 #include <BRep_Tool.hxx>
49 #include <BRep_Builder.hxx>
50 #include <BRepAdaptor_HSurface.hxx>
51
52 #include <NMTDS_ShapesDataStructure.hxx>
53 #include <NMTTools_DSFiller.hxx>
54
55 #include <IntTools_Curve.hxx>
56
57 #include <BOPTools_InterferencePool.hxx>
58 #include <BOPTools_CArray1OfSSInterference.hxx>
59 #include <BOPTools_SSInterference.hxx>
60 #include <BOPTools_ListOfPaveBlock.hxx>
61 #include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
62 #include <BOPTools_PaveBlock.hxx>
63 #include <BOPTools_Tools2D.hxx>
64 #include <NMTTools_PaveFiller.hxx>
65
66
67 //=======================================================================
68 // function: NMTTools_PCurveMaker
69 // purpose: 
70 //=======================================================================
71   NMTTools_PCurveMaker::NMTTools_PCurveMaker(NMTTools_PDSFiller& pDSFiller)
72 :
73   myIsDone(Standard_False)
74 {
75   myDSFiller=pDSFiller;
76 }
77 //=======================================================================
78 // function: IsDone
79 // purpose: 
80 //=======================================================================
81   Standard_Boolean NMTTools_PCurveMaker::IsDone() const
82 {
83   return myIsDone;
84 }
85 //=======================================================================
86 // function: Do
87 // purpose: 
88 //=======================================================================
89   void NMTTools_PCurveMaker::Do()
90 {
91   Standard_Integer i, aNb,  nF1, nF2, nE;
92   BOPTools_ListIteratorOfListOfPaveBlock anIt;
93   TopoDS_Face aF1FWD, aF2FWD;
94   //
95   NMTTools_PaveFiller *pFiller=(NMTTools_PaveFiller*) &(myDSFiller->PaveFiller());
96   NMTDS_ShapesDataStructure *pDS=pFiller->DS();
97   //
98   BOPTools_CArray1OfSSInterference& aFFs=(pFiller->InterfPool())->SSInterferences();
99   //
100   aNb=aFFs.Extent();
101   for (i=1; i<=aNb; ++i) {
102     BOPTools_SSInterference& aFF=aFFs(i);
103     // Faces
104     aFF.Indices(nF1, nF2);
105     const TopoDS_Face& aF1=TopoDS::Face(pDS->Shape(nF1));
106     const TopoDS_Face& aF2=TopoDS::Face(pDS->Shape(nF2));
107     //
108     // 1.Forwarding the Faces
109     aF1FWD=aF1;
110     aF1FWD.Orientation(TopAbs_FORWARD);
111     aF2FWD=aF2;
112     aF2FWD.Orientation(TopAbs_FORWARD);
113     //
114     // 2. In, On parts processing
115     const BOPTools_ListOfPaveBlock& aLPBInOn=aFF.PaveBlocks();
116     anIt.Initialize(aLPBInOn);
117     for (; anIt.More(); anIt.Next()) {
118       const BOPTools_PaveBlock& aPB=anIt.Value();
119       const BOPTools_PaveBlock& aPBInOn=pFiller->RealPaveBlock(aPB);
120       //
121       nE=aPBInOn.Edge();
122       const TopoDS_Edge& aE=TopoDS::Edge(pDS->Shape(nE));
123       
124       BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aE, aF1FWD);
125       BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aE, aF2FWD);
126     }
127   } //  for (i=1; i<=aNb; i++)
128   myIsDone=Standard_True;
129 }
130