1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File: NMTTools_PaveFiller_2.cxx
23 // Created: Mon Dec 8 12:02:56 2003
24 // Author: Peter KURNEV
27 #include <NMTTools_PaveFiller.ixx>
29 #include <Precision.hxx>
33 #include <Geom_Curve.hxx>
35 #include <TopAbs_Orientation.hxx>
38 #include <TopoDS_Edge.hxx>
39 #include <TopoDS_Vertex.hxx>
40 #include <TopoDS_Iterator.hxx>
42 #include <BRep_Builder.hxx>
43 #include <BRep_Tool.hxx>
45 #include <BOPTools_Pave.hxx>
46 #include <BOPTools_PaveSet.hxx>
47 #include <BOPTools_CArray1OfVEInterference.hxx>
48 #include <BOPTools_VEInterference.hxx>
50 #include <BooleanOperations_AncestorsSeqAndSuccessorsSeq.hxx>
51 #include <NMTDS_Iterator.hxx>
52 #include <NMTDS_ShapesDataStructure.hxx>
53 #include <NMTDS_InterfPool.hxx>
55 // Modified Thu Sep 14 14:35:18 2006
56 // Contribution of Samtech www.samcef.com BEGIN
57 #include <BOPTools_IndexedMapOfCoupleOfInteger.hxx>
58 #include <BOPTools_CoupleOfInteger.hxx>
59 #include <BooleanOperations_OnceExplorer.hxx>
63 Standard_Boolean Contains(const TopoDS_Edge& aE,
64 const TopoDS_Vertex& aV);
65 // Contribution of Samtech www.samcef.com END
67 //=======================================================================
68 // function: PerformVE
70 //=======================================================================
71 void NMTTools_PaveFiller::PerformVE()
73 myIsDone=Standard_False;
75 Standard_Boolean bJustAdd;
76 Standard_Integer n1, n2, anIndexIn, aFlag, aWhat, aWith, aNbVEs, aBlockLength, iSDV, nV1;
80 BOPTools_IndexedMapOfCoupleOfInteger aSnareMap;
81 BOPTools_CoupleOfInteger aCouple;
83 BOPTools_CArray1OfVEInterference& aVEs=myIP->VEInterferences();
85 myDSIt->Initialize (TopAbs_VERTEX, TopAbs_EDGE);
87 // BlockLength correction
88 aNbVEs=myDSIt->BlockLength();
89 aBlockLength=aVEs.BlockLength();
90 if (aNbVEs > aBlockLength) {
91 aVEs.SetBlockLength(aNbVEs);
94 for (; myDSIt->More(); myDSIt->Next()) {
95 myDSIt->Current(n1, n2, bJustAdd);
96 if (!IsSuccessorsComputed(n1, n2)) {
100 if (myDS->GetShapeType(n1)==TopAbs_EDGE) {
106 //myIntrPool->AddInterference(aWhat, aWith, BooleanOperations_VertexEdge, anIndexIn);
110 aE2=TopoDS::Edge(myDS->Shape(aWith));
111 if (BRep_Tool::Degenerated(aE2)){
116 aV1=TopoDS::Vertex(myDS->Shape(aWhat));
118 iSDV=FindSDVertex(aWhat);
121 aV1=TopoDS::Vertex(myDS->Shape(nV1));
122 // Modified to find same domain vertex Thu Sep 14 14:35:18 2006
123 // Contribution of Samtech www.samcef.com BEGIN
124 Standard_Integer nVE, iSDVE, iRet;
126 BooleanOperations_OnceExplorer aExp(*myDS);
128 aExp.Init(aWith, TopAbs_VERTEX);
129 for (; aExp.More(); aExp.Next()) {
131 iSDVE=FindSDVertex(nVE);
142 if (Contains(aE2, aV1)) {
145 // Contribution of Samtech www.samcef.com END
148 aFlag=myContext.ComputeVE (aV1, aE2, aT);
151 // Add Interference to the Pool
152 BOPTools_VEInterference anInterf (aWhat, aWith, aT);
153 anIndexIn=aVEs.Append(anInterf);
155 // Add Pave to the Edge's myPavePool
156 aCouple.SetCouple(nV1, aWith);
157 if (!aSnareMap.Contains(aCouple)){
158 aSnareMap.Add(aCouple);
160 BOPTools_Pave aPave(nV1, aT, BooleanOperations_VertexEdge);
161 aPave.SetInterference(anIndexIn);
162 BOPTools_PaveSet& aPaveSet= myPavePool(myDS->RefEdge(aWith));
163 aPaveSet.Append(aPave);
166 // State for the Vertex in DS;
167 myDS->SetState (aWhat, BooleanOperations_ON);
168 // Insert Vertex in Interference Object
169 BOPTools_VEInterference& aVE=aVEs(anIndexIn);
170 aVE.SetNewShape(aWhat);
173 myIP->Add(aWhat, aWith, Standard_True, NMTDS_TI_VE);
177 //myIntrPool->AddInterference(aWhat, aWith, BooleanOperations_VertexEdge, anIndexIn);
180 myIsDone=Standard_True;
182 //=======================================================================
183 // function: PrepareEdges
185 //=======================================================================
186 void NMTTools_PaveFiller::PrepareEdges()
188 Standard_Integer i, nV, ii, aNBSuc, ip, aNbShapesObject;
190 TopAbs_Orientation anOr;
194 aNbShapesObject=myDS->NumberOfShapesOfTheObject();
195 for (i=1; i<=myNbSources; ++i) {
196 if (myDS->GetShapeType(i)==TopAbs_EDGE) {
197 aE=TopoDS::Edge(myDS->Shape(i));
199 if (BRep_Tool::Degenerated(aE)){
203 BOPTools_PaveSet& aPaveSet=myPavePool(myDS->RefEdge(i));
206 aNBSuc=myDS->NumberOfSuccessors(i);
207 for (ii=1; ii <=aNBSuc; ii++) {
208 nV=myDS->GetSuccessor(i, ii);
209 anOr=myDS->GetOrientation(i, ii);
210 aV=TopoDS::Vertex(myDS->Shape(nV));
211 aV.Orientation(anOr);
212 aT=BRep_Tool::Parameter(aV, aE);
216 aV=TopoDS::Vertex(myDS->Shape(ip));
217 aV.Orientation(anOr);// XX ? if the edge is closed it'll be amazing result
221 BOPTools_Pave aPave(nV, aT);
222 aPaveSet.Append (aPave);
228 // Modified Thu Sep 14 14:35:18 2006
229 // Contribution of Samtech www.samcef.com BEGIN
230 //=======================================================================
231 //function : Contains
233 //=======================================================================
234 Standard_Boolean Contains(const TopoDS_Edge& aE,
235 const TopoDS_Vertex& aV)
237 Standard_Boolean bRet;
242 for (; aIt.More(); aIt.Next()) {
243 const TopoDS_Shape& aVE=aIt.Value();
244 if (aVE.IsSame(aV)) {
251 // Contribution of Samtech www.samcef.com END