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: NMTTools_PaveFiller_2.cxx
21 // Created: Mon Dec 8 12:02:56 2003
22 // Author: Peter KURNEV
26 #include <NMTTools_PaveFiller.ixx>
28 #include <Precision.hxx>
32 #include <Geom_Curve.hxx>
34 #include <TopAbs_Orientation.hxx>
37 #include <TopoDS_Edge.hxx>
38 #include <TopoDS_Vertex.hxx>
39 #include <TopoDS_Iterator.hxx>
41 #include <BRep_Builder.hxx>
42 #include <BRep_Tool.hxx>
44 #include <BOPTools_Pave.hxx>
45 #include <BOPTools_PaveSet.hxx>
46 #include <BOPTools_CArray1OfVEInterference.hxx>
47 #include <BOPTools_VEInterference.hxx>
49 #include <BooleanOperations_AncestorsSeqAndSuccessorsSeq.hxx>
51 #include <NMTDS_ShapesDataStructure.hxx>
53 // Modified Thu Sep 14 14:35:18 2006
54 // Contribution of Samtech www.samcef.com BEGIN
55 #include <BOPTools_IndexedMapOfCoupleOfInteger.hxx>
56 #include <BOPTools_CoupleOfInteger.hxx>
57 #include <BooleanOperations_OnceExplorer.hxx>
61 Standard_Boolean Contains(const TopoDS_Edge& aE,
62 const TopoDS_Vertex& aV);
63 // Contribution of Samtech www.samcef.com END
64 //=======================================================================
65 // function: PrepareEdges
67 //=======================================================================
68 void NMTTools_PaveFiller::PrepareEdges()
70 Standard_Integer i, nV, ii, aNBSuc, ip, aNbShapesObject;
72 TopAbs_Orientation anOr;
76 aNbShapesObject=myDS->NumberOfShapesOfTheObject();
77 for (i=1; i<=myNbSources; ++i) {
78 if (myDS->GetShapeType(i)==TopAbs_EDGE) {
79 aE=TopoDS::Edge(myDS->Shape(i));
81 if (BRep_Tool::Degenerated(aE)){
85 BOPTools_PaveSet& aPaveSet=myPavePool(myDS->RefEdge(i));
88 aNBSuc=myDS->NumberOfSuccessors(i);
89 for (ii=1; ii <=aNBSuc; ii++) {
90 nV=myDS->GetSuccessor(i, ii);
91 anOr=myDS->GetOrientation(i, ii);
92 aV=TopoDS::Vertex(myDS->Shape(nV));
94 aT=BRep_Tool::Parameter(aV, aE);
98 aV=TopoDS::Vertex(myDS->Shape(ip));
99 aV.Orientation(anOr);// XX ? if the edge is closed it'll be amazing result
103 BOPTools_Pave aPave(nV, aT);
104 aPaveSet.Append (aPave);
109 //=======================================================================
110 // function: PerformVE
112 //=======================================================================
113 void NMTTools_PaveFiller::PerformVE()
115 myIsDone=Standard_False;
117 Standard_Boolean bJustAddInterference;
118 Standard_Integer n1, n2, anIndexIn, aFlag, aWhat, aWith, aNbVEs, aBlockLength, iSDV, nV1;
122 BOPTools_IndexedMapOfCoupleOfInteger aSnareMap;
123 BOPTools_CoupleOfInteger aCouple;
125 BOPTools_CArray1OfVEInterference& aVEs=myIntrPool->VEInterferences();
127 myDSIt.Initialize (TopAbs_VERTEX, TopAbs_EDGE);
129 // BlockLength correction
130 aNbVEs=ExpectedPoolLength();
131 aBlockLength=aVEs.BlockLength();
132 if (aNbVEs > aBlockLength) {
133 aVEs.SetBlockLength(aNbVEs);
136 for (; myDSIt.More(); myDSIt.Next()) {
137 myDSIt.Current(n1, n2, bJustAddInterference);
139 if (! myIntrPool->IsComputed(n1, n2)) {
140 if (! IsSuccesstorsComputed(n1, n2)) {
144 SortTypes(aWhat, aWith);
146 if(bJustAddInterference) {
147 myIntrPool->AddInterference(aWhat, aWith, BooleanOperations_VertexEdge, anIndexIn);
151 aE2=TopoDS::Edge(myDS->Shape(aWith));
152 if (BRep_Tool::Degenerated(aE2)){
157 aV1=TopoDS::Vertex(myDS->Shape(aWhat));
159 iSDV=FindSDVertex(aWhat);
162 aV1=TopoDS::Vertex(myDS->Shape(nV1));
163 // Modified to find same domain vertex Thu Sep 14 14:35:18 2006
164 // Contribution of Samtech www.samcef.com BEGIN
165 Standard_Integer nVE, iSDVE, iRet;
167 BooleanOperations_OnceExplorer aExp(*myDS);
169 aExp.Init(aWith, TopAbs_VERTEX);
170 for (; aExp.More(); aExp.Next()) {
172 iSDVE=FindSDVertex(nVE);
183 if (Contains(aE2, aV1)) {
186 // Contribution of Samtech www.samcef.com END
189 aFlag=myContext.ComputeVE (aV1, aE2, aT);
192 // Add Interference to the Pool
193 BOPTools_VEInterference anInterf (aWhat, aWith, aT);
194 anIndexIn=aVEs.Append(anInterf);
196 // Add Pave to the Edge's myPavePool
197 aCouple.SetCouple(nV1, aWith);
198 if (!aSnareMap.Contains(aCouple)){
199 aSnareMap.Add(aCouple);
201 BOPTools_Pave aPave(nV1, aT, BooleanOperations_VertexEdge);
202 aPave.SetInterference(anIndexIn);
203 BOPTools_PaveSet& aPaveSet= myPavePool(myDS->RefEdge(aWith));
204 aPaveSet.Append(aPave);
207 // State for the Vertex in DS;
208 myDS->SetState (aWhat, BooleanOperations_ON);
209 // Insert Vertex in Interference Object
210 BOPTools_VEInterference& aVE=aVEs(anIndexIn);
211 aVE.SetNewShape(aWhat);
213 myIntrPool->AddInterference(aWhat, aWith, BooleanOperations_VertexEdge, anIndexIn);
217 myIsDone=Standard_True;
219 // Modified Thu Sep 14 14:35:18 2006
220 // Contribution of Samtech www.samcef.com BEGIN
221 //=======================================================================
222 //function : Contains
224 //=======================================================================
225 Standard_Boolean Contains(const TopoDS_Edge& aE,
226 const TopoDS_Vertex& aV)
228 Standard_Boolean bRet;
233 for (; aIt.More(); aIt.Next()) {
234 const TopoDS_Shape& aVE=aIt.Value();
235 if (aVE.IsSame(aV)) {
242 // Contribution of Samtech www.samcef.com END