1 // Copyright (C) 2007-2011 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
29 #include <Standard_Version.hxx>
31 #include <NMTTools_PaveFiller.ixx>
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>
60 // Modified Thu Sep 14 14:35:18 2006
61 // Contribution of Samtech www.samcef.com BEGIN
62 #include <BOPTools_IndexedMapOfCoupleOfInteger.hxx>
63 #include <BOPTools_CoupleOfInteger.hxx>
64 #include <BooleanOperations_OnceExplorer.hxx>
67 Standard_Boolean Contains(const TopoDS_Edge& aE,
68 const TopoDS_Vertex& aV);
69 // Contribution of Samtech www.samcef.com END
71 // In OCCT6.3.0sp9 is changed a signature of IntTools_Context::ComputeVE() method
72 #ifdef OCC_VERSION_SERVICEPACK
73 #define OCC_VERSION_LARGE (OCC_VERSION_MAJOR << 24 | OCC_VERSION_MINOR << 16 | OCC_VERSION_MAINTENANCE << 8 | OCC_VERSION_SERVICEPACK)
75 #define OCC_VERSION_LARGE (OCC_VERSION_MAJOR << 24 | OCC_VERSION_MINOR << 16 | OCC_VERSION_MAINTENANCE << 8)
78 //=======================================================================
79 // function: PerformVE
81 //=======================================================================
82 void NMTTools_PaveFiller::PerformVE()
84 myIsDone=Standard_False;
86 Standard_Boolean bJustAdd;
87 Standard_Integer n1, n2, anIndexIn, aFlag, aWhat;
88 Standard_Integer aWith, aNbVEs, aBlockLength, iSDV, nV1;
90 #if OCC_VERSION_LARGE > 0x06030008
91 Standard_Boolean bToUpdateVertex;
96 BOPTools_IndexedMapOfCoupleOfInteger aSnareMap;
97 BOPTools_CoupleOfInteger aCouple;
99 BOPTools_CArray1OfVEInterference& aVEs=myIP->VEInterferences();
101 myDSIt->Initialize (TopAbs_VERTEX, TopAbs_EDGE);
103 // BlockLength correction
104 aNbVEs=myDSIt->BlockLength();
105 aBlockLength=aVEs.BlockLength();
106 if (aNbVEs > aBlockLength) {
107 aVEs.SetBlockLength(aNbVEs);
110 for (; myDSIt->More(); myDSIt->Next()) {
111 myDSIt->Current(n1, n2, bJustAdd);
112 if (!IsSuccessorsComputed(n1, n2)) {
116 if (myDS->GetShapeType(n1)==TopAbs_EDGE) {
125 aE2=TopoDS::Edge(myDS->Shape(aWith));
126 if (BRep_Tool::Degenerated(aE2)){
131 aV1=TopoDS::Vertex(myDS->Shape(aWhat));
133 iSDV=FindSDVertex(aWhat);
136 aV1=TopoDS::Vertex(myDS->Shape(nV1));
137 // Modified to find same domain vertex Thu Sep 14 14:35:18 2006
138 // Contribution of Samtech www.samcef.com BEGIN
139 Standard_Integer nVE, iSDVE, iRet;
141 BooleanOperations_OnceExplorer aExp(*myDS);
143 aExp.Init(aWith, TopAbs_VERTEX);
144 for (; aExp.More(); aExp.Next()) {
146 iSDVE=FindSDVertex(nVE);
157 if (Contains(aE2, aV1)) {
160 // Contribution of Samtech www.samcef.com END
163 //modified by NIZNHY-PKV Mon Dec 28 08:58:05 2009f
164 #if OCC_VERSION_LARGE > 0x06030008
165 aFlag=myContext.ComputeVE (aV1, aE2, aT, bToUpdateVertex, aDist);
167 aFlag=myContext.ComputeVE (aV1, aE2, aT);
169 //modified by NIZNHY-PKV Mon Dec 28 08:58:13 2009t
172 // Add Interference to the Pool
173 BOPTools_VEInterference anInterf (aWhat, aWith, aT);
174 anIndexIn=aVEs.Append(anInterf);
176 // Add Pave to the Edge's myPavePool
177 aCouple.SetCouple(nV1, aWith);
178 if (!aSnareMap.Contains(aCouple)){
179 aSnareMap.Add(aCouple);
181 BOPTools_Pave aPave(nV1, aT, BooleanOperations_VertexEdge);
182 aPave.SetInterference(anIndexIn);
183 BOPTools_PaveSet& aPaveSet= myPavePool(myDS->RefEdge(aWith));
184 aPaveSet.Append(aPave);
187 // State for the Vertex in DS;
188 myDS->SetState (aWhat, BooleanOperations_ON);
189 // Insert Vertex in Interference Object
190 BOPTools_VEInterference& aVE=aVEs(anIndexIn);
191 aVE.SetNewShape(aWhat);
193 myIP->Add(aWhat, aWith, Standard_True, NMTDS_TI_VE);
195 //modified by NIZNHY-PKV Mon Dec 28 09:00:54 2009f
196 #if OCC_VERSION_LARGE > 0x06030008
197 if (bToUpdateVertex) {
200 aBB.UpdateVertex(aV1, aDist);
203 //modified by NIZNHY-PKV Mon Dec 28 09:00:57 2009t
208 myIsDone=Standard_True;
211 //=======================================================================
212 // function: PrepareEdges
214 //=======================================================================
215 void NMTTools_PaveFiller::PrepareEdges()
217 Standard_Integer i, nV, ii, aNBSuc, ip, aNbShapesObject;
219 TopAbs_Orientation anOr;
223 aNbShapesObject=myDS->NumberOfShapesOfTheObject();
224 for (i=1; i<=myNbSources; ++i) {
225 if (myDS->GetShapeType(i)==TopAbs_EDGE) {
226 aE=TopoDS::Edge(myDS->Shape(i));
228 if (BRep_Tool::Degenerated(aE)){
232 BOPTools_PaveSet& aPaveSet=myPavePool(myDS->RefEdge(i));
235 aNBSuc=myDS->NumberOfSuccessors(i);
236 for (ii=1; ii <=aNBSuc; ii++) {
237 nV=myDS->GetSuccessor(i, ii);
238 anOr=myDS->GetOrientation(i, ii);
239 aV=TopoDS::Vertex(myDS->Shape(nV));
240 aV.Orientation(anOr);
241 aT=BRep_Tool::Parameter(aV, aE);
245 aV=TopoDS::Vertex(myDS->Shape(ip));
246 aV.Orientation(anOr);// XX ? if the edge is closed it'll be amazing result
250 BOPTools_Pave aPave(nV, aT);
251 aPaveSet.Append (aPave);
257 // Modified Thu Sep 14 14:35:18 2006
258 // Contribution of Samtech www.samcef.com BEGIN
259 //=======================================================================
260 //function : Contains
262 //=======================================================================
263 Standard_Boolean Contains(const TopoDS_Edge& aE,
264 const TopoDS_Vertex& aV)
266 Standard_Boolean bRet;
271 for (; aIt.More(); aIt.Next()) {
272 const TopoDS_Shape& aVE=aIt.Value();
273 if (aVE.IsSame(aV)) {
280 // Contribution of Samtech www.samcef.com END