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>
50 #include <NMTDS_Iterator.hxx>
51 #include <NMTDS_ShapesDataStructure.hxx>
52 #include <NMTDS_InterfPool.hxx>
54 // Modified Thu Sep 14 14:35:18 2006
55 // Contribution of Samtech www.samcef.com BEGIN
56 #include <BOPTools_IndexedMapOfCoupleOfInteger.hxx>
57 #include <BOPTools_CoupleOfInteger.hxx>
58 #include <BooleanOperations_OnceExplorer.hxx>
62 Standard_Boolean Contains(const TopoDS_Edge& aE,
63 const TopoDS_Vertex& aV);
64 // Contribution of Samtech www.samcef.com END
66 //=======================================================================
67 // function: PerformVE
69 //=======================================================================
70 void NMTTools_PaveFiller::PerformVE()
72 myIsDone=Standard_False;
74 Standard_Boolean bJustAdd;
75 Standard_Integer n1, n2, anIndexIn, aFlag, aWhat, aWith, aNbVEs, aBlockLength, iSDV, nV1;
79 BOPTools_IndexedMapOfCoupleOfInteger aSnareMap;
80 BOPTools_CoupleOfInteger aCouple;
82 BOPTools_CArray1OfVEInterference& aVEs=myIP->VEInterferences();
84 myDSIt->Initialize (TopAbs_VERTEX, TopAbs_EDGE);
86 // BlockLength correction
87 aNbVEs=myDSIt->BlockLength();
88 aBlockLength=aVEs.BlockLength();
89 if (aNbVEs > aBlockLength) {
90 aVEs.SetBlockLength(aNbVEs);
93 for (; myDSIt->More(); myDSIt->Next()) {
94 myDSIt->Current(n1, n2, bJustAdd);
95 if (!IsSuccessorsComputed(n1, n2)) {
99 if (myDS->GetShapeType(n1)==TopAbs_EDGE) {
105 //myIntrPool->AddInterference(aWhat, aWith, BooleanOperations_VertexEdge, anIndexIn);
109 aE2=TopoDS::Edge(myDS->Shape(aWith));
110 if (BRep_Tool::Degenerated(aE2)){
115 aV1=TopoDS::Vertex(myDS->Shape(aWhat));
117 iSDV=FindSDVertex(aWhat);
120 aV1=TopoDS::Vertex(myDS->Shape(nV1));
121 // Modified to find same domain vertex Thu Sep 14 14:35:18 2006
122 // Contribution of Samtech www.samcef.com BEGIN
123 Standard_Integer nVE, iSDVE, iRet;
125 BooleanOperations_OnceExplorer aExp(*myDS);
127 aExp.Init(aWith, TopAbs_VERTEX);
128 for (; aExp.More(); aExp.Next()) {
130 iSDVE=FindSDVertex(nVE);
141 if (Contains(aE2, aV1)) {
144 // Contribution of Samtech www.samcef.com END
147 aFlag=myContext.ComputeVE (aV1, aE2, aT);
150 // Add Interference to the Pool
151 BOPTools_VEInterference anInterf (aWhat, aWith, aT);
152 anIndexIn=aVEs.Append(anInterf);
154 // Add Pave to the Edge's myPavePool
155 aCouple.SetCouple(nV1, aWith);
156 if (!aSnareMap.Contains(aCouple)){
157 aSnareMap.Add(aCouple);
159 BOPTools_Pave aPave(nV1, aT, BooleanOperations_VertexEdge);
160 aPave.SetInterference(anIndexIn);
161 BOPTools_PaveSet& aPaveSet= myPavePool(myDS->RefEdge(aWith));
162 aPaveSet.Append(aPave);
165 // State for the Vertex in DS;
166 myDS->SetState (aWhat, BooleanOperations_ON);
167 // Insert Vertex in Interference Object
168 BOPTools_VEInterference& aVE=aVEs(anIndexIn);
169 aVE.SetNewShape(aWhat);
172 myIP->Add(aWhat, aWith, Standard_True, NMTDS_TI_VE);
176 //myIntrPool->AddInterference(aWhat, aWith, BooleanOperations_VertexEdge, anIndexIn);
179 myIsDone=Standard_True;
181 //=======================================================================
182 // function: PrepareEdges
184 //=======================================================================
185 void NMTTools_PaveFiller::PrepareEdges()
187 Standard_Integer i, nV, ii, aNBSuc, ip, aNbShapesObject;
189 TopAbs_Orientation anOr;
193 aNbShapesObject=myDS->NumberOfShapesOfTheObject();
194 for (i=1; i<=myNbSources; ++i) {
195 if (myDS->GetShapeType(i)==TopAbs_EDGE) {
196 aE=TopoDS::Edge(myDS->Shape(i));
198 if (BRep_Tool::Degenerated(aE)){
202 BOPTools_PaveSet& aPaveSet=myPavePool(myDS->RefEdge(i));
205 aNBSuc=myDS->NumberOfSuccessors(i);
206 for (ii=1; ii <=aNBSuc; ii++) {
207 nV=myDS->GetSuccessor(i, ii);
208 anOr=myDS->GetOrientation(i, ii);
209 aV=TopoDS::Vertex(myDS->Shape(nV));
210 aV.Orientation(anOr);
211 aT=BRep_Tool::Parameter(aV, aE);
215 aV=TopoDS::Vertex(myDS->Shape(ip));
216 aV.Orientation(anOr);// XX ? if the edge is closed it'll be amazing result
220 BOPTools_Pave aPave(nV, aT);
221 aPaveSet.Append (aPave);
227 // Modified Thu Sep 14 14:35:18 2006
228 // Contribution of Samtech www.samcef.com BEGIN
229 //=======================================================================
230 //function : Contains
232 //=======================================================================
233 Standard_Boolean Contains(const TopoDS_Edge& aE,
234 const TopoDS_Vertex& aV)
236 Standard_Boolean bRet;
241 for (; aIt.More(); aIt.Next()) {
242 const TopoDS_Shape& aVE=aIt.Value();
243 if (aVE.IsSame(aV)) {
250 // Contribution of Samtech www.samcef.com END