1 // Copyright (C) 2007-2012 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
23 // File: NMTTools_PaveFiller_2.cxx
24 // Created: Mon Dec 8 12:02:56 2003
25 // Author: Peter KURNEV
27 #include <Standard_Version.hxx>
29 #include <NMTTools_PaveFiller.hxx>
31 #include <Basics_OCCTVersion.hxx>
33 #include <Precision.hxx>
37 #include <Geom_Curve.hxx>
39 #include <TopAbs_Orientation.hxx>
42 #include <TopoDS_Edge.hxx>
43 #include <TopoDS_Vertex.hxx>
44 #include <TopoDS_Iterator.hxx>
46 #include <BRep_Builder.hxx>
47 #include <BRep_Tool.hxx>
49 #include <BOPTools_Pave.hxx>
50 #include <BOPTools_PaveSet.hxx>
51 #include <BOPTools_CArray1OfVEInterference.hxx>
52 #include <BOPTools_VEInterference.hxx>
54 #include <BooleanOperations_AncestorsSeqAndSuccessorsSeq.hxx>
56 #include <NMTDS_Iterator.hxx>
57 #include <NMTDS_ShapesDataStructure.hxx>
58 #include <NMTDS_InterfPool.hxx>
61 #include <BOPTools_IndexedMapOfCoupleOfInteger.hxx>
62 #include <BOPTools_CoupleOfInteger.hxx>
63 #include <BooleanOperations_OnceExplorer.hxx>
65 #include <IntTools_Context.hxx>
68 Standard_Boolean Contains(const TopoDS_Edge& aE,
69 const TopoDS_Vertex& aV);
71 //=======================================================================
72 // function: PerformVE
74 //=======================================================================
75 void NMTTools_PaveFiller::PerformVE()
77 myIsDone=Standard_False;
79 Standard_Boolean bJustAdd;
80 Standard_Integer n1, n2, anIndexIn, aFlag, aWhat;
81 Standard_Integer aWith, aNbVEs, aBlockLength, iSDV, nV1;
83 #if OCC_VERSION_LARGE > 0x06030008
84 // In OCCT6.3.0sp9 is changed a signature of IntTools_Context::ComputeVE() method
85 Standard_Boolean bToUpdateVertex;
90 BOPTools_IndexedMapOfCoupleOfInteger aSnareMap;
91 BOPTools_CoupleOfInteger aCouple;
93 BOPTools_CArray1OfVEInterference& aVEs=myIP->VEInterferences();
95 myDSIt->Initialize (TopAbs_VERTEX, TopAbs_EDGE);
97 // BlockLength correction
98 aNbVEs=myDSIt->BlockLength();
99 aBlockLength=aVEs.BlockLength();
100 if (aNbVEs > aBlockLength) {
101 aVEs.SetBlockLength(aNbVEs);
104 for (; myDSIt->More(); myDSIt->Next()) {
105 myDSIt->Current(n1, n2, bJustAdd);
106 if (!IsSuccessorsComputed(n1, n2)) {
110 if (myDS->GetShapeType(n1)==TopAbs_EDGE) {
119 aE2=TopoDS::Edge(myDS->Shape(aWith));
120 if (BRep_Tool::Degenerated(aE2)){
125 aV1=TopoDS::Vertex(myDS->Shape(aWhat));
127 iSDV=FindSDVertex(aWhat);
130 aV1=TopoDS::Vertex(myDS->Shape(nV1));
131 // Modified to find same domain vertex Thu Sep 14 14:35:18 2006
132 // Contribution of Samtech www.samcef.com BEGIN
133 Standard_Integer nVE, iSDVE, iRet;
135 BooleanOperations_OnceExplorer aExp(*myDS);
137 aExp.Init(aWith, TopAbs_VERTEX);
138 for (; aExp.More(); aExp.Next()) {
140 iSDVE=FindSDVertex(nVE);
151 if (Contains(aE2, aV1)) {
154 // Contribution of Samtech www.samcef.com END
157 //modified by NIZNHY-PKV Mon Dec 28 08:58:05 2009f
158 #if OCC_VERSION_LARGE > 0x06030008
159 // In OCCT6.3.0sp9 is changed a signature of IntTools_Context::ComputeVE() method
160 aFlag = myContext->ComputeVE (aV1, aE2, aT, bToUpdateVertex, aDist);
162 aFlag = myContext->ComputeVE (aV1, aE2, aT);
164 //modified by NIZNHY-PKV Mon Dec 28 08:58:13 2009t
167 // Add Interference to the Pool
168 BOPTools_VEInterference anInterf (aWhat, aWith, aT);
169 anIndexIn=aVEs.Append(anInterf);
171 // Add Pave to the Edge's myPavePool
172 aCouple.SetCouple(nV1, aWith);
173 if (!aSnareMap.Contains(aCouple)){
174 aSnareMap.Add(aCouple);
176 BOPTools_Pave aPave(nV1, aT, BooleanOperations_VertexEdge);
177 aPave.SetInterference(anIndexIn);
178 BOPTools_PaveSet& aPaveSet= myPavePool(myDS->RefEdge(aWith));
179 aPaveSet.Append(aPave);
182 // State for the Vertex in DS;
183 myDS->SetState (aWhat, BooleanOperations_ON);
184 // Insert Vertex in Interference Object
185 BOPTools_VEInterference& aVE=aVEs(anIndexIn);
186 aVE.SetNewShape(aWhat);
188 myIP->Add(aWhat, aWith, Standard_True, NMTDS_TI_VE);
190 //modified by NIZNHY-PKV Mon Dec 28 09:00:54 2009f
191 #if OCC_VERSION_LARGE > 0x06030008
192 // In OCCT6.3.0sp9 is changed a signature of IntTools_Context::ComputeVE() method
193 if (bToUpdateVertex) {
196 aBB.UpdateVertex(aV1, aDist);
199 //modified by NIZNHY-PKV Mon Dec 28 09:00:57 2009t
204 myIsDone=Standard_True;
207 //=======================================================================
208 // function: PrepareEdges
210 //=======================================================================
211 void NMTTools_PaveFiller::PrepareEdges()
213 Standard_Integer i, nV, ii, aNBSuc, ip, aNbShapesObject;
215 TopAbs_Orientation anOr;
219 aNbShapesObject=myDS->NumberOfShapesOfTheObject();
220 for (i=1; i<=myNbSources; ++i) {
221 if (myDS->GetShapeType(i)==TopAbs_EDGE) {
222 aE=TopoDS::Edge(myDS->Shape(i));
224 if (BRep_Tool::Degenerated(aE)){
228 BOPTools_PaveSet& aPaveSet=myPavePool(myDS->RefEdge(i));
231 aNBSuc=myDS->NumberOfSuccessors(i);
232 for (ii=1; ii <=aNBSuc; ii++) {
233 nV=myDS->GetSuccessor(i, ii);
234 anOr=myDS->GetOrientation(i, ii);
235 aV=TopoDS::Vertex(myDS->Shape(nV));
236 aV.Orientation(anOr);
237 aT=BRep_Tool::Parameter(aV, aE);
241 aV=TopoDS::Vertex(myDS->Shape(ip));
242 aV.Orientation(anOr);// XX ? if the edge is closed it'll be amazing result
246 BOPTools_Pave aPave(nV, aT);
247 aPaveSet.Append (aPave);
253 // Modified Thu Sep 14 14:35:18 2006
254 // Contribution of Samtech www.samcef.com BEGIN
255 //=======================================================================
256 //function : Contains
258 //=======================================================================
259 Standard_Boolean Contains(const TopoDS_Edge& aE,
260 const TopoDS_Vertex& aV)
262 Standard_Boolean bRet;
267 for (; aIt.More(); aIt.Next()) {
268 const TopoDS_Shape& aVE=aIt.Value();
269 if (aVE.IsSame(aV)) {
276 // Contribution of Samtech www.samcef.com END