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
22 // File: NMTTools_PaveFiller_2.cxx
23 // Created: Mon Dec 8 12:02:56 2003
24 // Author: Peter KURNEV
26 #include <Standard_Version.hxx>
28 #include <NMTTools_PaveFiller.hxx>
30 #include <Basics_OCCTVersion.hxx>
32 #include <Precision.hxx>
36 #include <Geom_Curve.hxx>
38 #include <TopAbs_Orientation.hxx>
41 #include <TopoDS_Edge.hxx>
42 #include <TopoDS_Vertex.hxx>
43 #include <TopoDS_Iterator.hxx>
45 #include <BRep_Builder.hxx>
46 #include <BRep_Tool.hxx>
48 #include <BOPTools_Pave.hxx>
49 #include <BOPTools_PaveSet.hxx>
50 #include <BOPTools_CArray1OfVEInterference.hxx>
51 #include <BOPTools_VEInterference.hxx>
53 #include <BooleanOperations_AncestorsSeqAndSuccessorsSeq.hxx>
55 #include <NMTDS_Iterator.hxx>
56 #include <NMTDS_ShapesDataStructure.hxx>
57 #include <NMTDS_InterfPool.hxx>
60 #include <BOPTools_IndexedMapOfCoupleOfInteger.hxx>
61 #include <BOPTools_CoupleOfInteger.hxx>
62 #include <BooleanOperations_OnceExplorer.hxx>
64 #include <IntTools_Context.hxx>
67 Standard_Boolean Contains(const TopoDS_Edge& aE,
68 const TopoDS_Vertex& aV);
70 //=======================================================================
71 // function: PerformVE
73 //=======================================================================
74 void NMTTools_PaveFiller::PerformVE()
76 myIsDone=Standard_False;
78 Standard_Boolean bJustAdd;
79 Standard_Integer n1, n2, anIndexIn, aFlag, aWhat;
80 Standard_Integer aWith, aNbVEs, aBlockLength, iSDV, nV1;
82 #if OCC_VERSION_LARGE > 0x06030008
83 // In OCCT6.3.0sp9 is changed a signature of IntTools_Context::ComputeVE() method
84 Standard_Boolean bToUpdateVertex;
89 BOPTools_IndexedMapOfCoupleOfInteger aSnareMap;
90 BOPTools_CoupleOfInteger aCouple;
92 BOPTools_CArray1OfVEInterference& aVEs=myIP->VEInterferences();
94 myDSIt->Initialize (TopAbs_VERTEX, TopAbs_EDGE);
96 // BlockLength correction
97 aNbVEs=myDSIt->BlockLength();
98 aBlockLength=aVEs.BlockLength();
99 if (aNbVEs > aBlockLength) {
100 aVEs.SetBlockLength(aNbVEs);
103 for (; myDSIt->More(); myDSIt->Next()) {
104 myDSIt->Current(n1, n2, bJustAdd);
105 if (!IsSuccessorsComputed(n1, n2)) {
109 if (myDS->GetShapeType(n1)==TopAbs_EDGE) {
118 aE2=TopoDS::Edge(myDS->Shape(aWith));
119 if (BRep_Tool::Degenerated(aE2)){
124 aV1=TopoDS::Vertex(myDS->Shape(aWhat));
126 iSDV=FindSDVertex(aWhat);
129 aV1=TopoDS::Vertex(myDS->Shape(nV1));
130 // Modified to find same domain vertex Thu Sep 14 14:35:18 2006
131 // Contribution of Samtech www.samcef.com BEGIN
132 Standard_Integer nVE, iSDVE, iRet;
134 BooleanOperations_OnceExplorer aExp(*myDS);
136 aExp.Init(aWith, TopAbs_VERTEX);
137 for (; aExp.More(); aExp.Next()) {
139 iSDVE=FindSDVertex(nVE);
150 if (Contains(aE2, aV1)) {
153 // Contribution of Samtech www.samcef.com END
156 //modified by NIZNHY-PKV Mon Dec 28 08:58:05 2009f
157 #if OCC_VERSION_LARGE > 0x06030008
158 // In OCCT6.3.0sp9 is changed a signature of IntTools_Context::ComputeVE() method
159 aFlag = myContext->ComputeVE (aV1, aE2, aT, bToUpdateVertex, aDist);
161 aFlag = myContext->ComputeVE (aV1, aE2, aT);
163 //modified by NIZNHY-PKV Mon Dec 28 08:58:13 2009t
166 // Add Interference to the Pool
167 BOPTools_VEInterference anInterf (aWhat, aWith, aT);
168 anIndexIn=aVEs.Append(anInterf);
170 // Add Pave to the Edge's myPavePool
171 aCouple.SetCouple(nV1, aWith);
172 if (!aSnareMap.Contains(aCouple)){
173 aSnareMap.Add(aCouple);
175 BOPTools_Pave aPave(nV1, aT, BooleanOperations_VertexEdge);
176 aPave.SetInterference(anIndexIn);
177 BOPTools_PaveSet& aPaveSet= myPavePool(myDS->RefEdge(aWith));
178 aPaveSet.Append(aPave);
181 // State for the Vertex in DS;
182 myDS->SetState (aWhat, BooleanOperations_ON);
183 // Insert Vertex in Interference Object
184 BOPTools_VEInterference& aVE=aVEs(anIndexIn);
185 aVE.SetNewShape(aWhat);
187 myIP->Add(aWhat, aWith, Standard_True, NMTDS_TI_VE);
189 //modified by NIZNHY-PKV Mon Dec 28 09:00:54 2009f
190 #if OCC_VERSION_LARGE > 0x06030008
191 // In OCCT6.3.0sp9 is changed a signature of IntTools_Context::ComputeVE() method
192 if (bToUpdateVertex) {
195 aBB.UpdateVertex(aV1, aDist);
198 //modified by NIZNHY-PKV Mon Dec 28 09:00:57 2009t
203 myIsDone=Standard_True;
206 //=======================================================================
207 // function: PrepareEdges
209 //=======================================================================
210 void NMTTools_PaveFiller::PrepareEdges()
212 Standard_Integer i, nV, ii, aNBSuc, ip, aNbShapesObject;
214 TopAbs_Orientation anOr;
218 aNbShapesObject=myDS->NumberOfShapesOfTheObject();
219 for (i=1; i<=myNbSources; ++i) {
220 if (myDS->GetShapeType(i)==TopAbs_EDGE) {
221 aE=TopoDS::Edge(myDS->Shape(i));
223 if (BRep_Tool::Degenerated(aE)){
227 BOPTools_PaveSet& aPaveSet=myPavePool(myDS->RefEdge(i));
230 aNBSuc=myDS->NumberOfSuccessors(i);
231 for (ii=1; ii <=aNBSuc; ii++) {
232 nV=myDS->GetSuccessor(i, ii);
233 anOr=myDS->GetOrientation(i, ii);
234 aV=TopoDS::Vertex(myDS->Shape(nV));
235 aV.Orientation(anOr);
236 aT=BRep_Tool::Parameter(aV, aE);
240 aV=TopoDS::Vertex(myDS->Shape(ip));
241 aV.Orientation(anOr);// XX ? if the edge is closed it'll be amazing result
245 BOPTools_Pave aPave(nV, aT);
246 aPaveSet.Append (aPave);
252 // Modified Thu Sep 14 14:35:18 2006
253 // Contribution of Samtech www.samcef.com BEGIN
254 //=======================================================================
255 //function : Contains
257 //=======================================================================
258 Standard_Boolean Contains(const TopoDS_Edge& aE,
259 const TopoDS_Vertex& aV)
261 Standard_Boolean bRet;
266 for (; aIt.More(); aIt.Next()) {
267 const TopoDS_Shape& aVE=aIt.Value();
268 if (aVE.IsSame(aV)) {
275 // Contribution of Samtech www.samcef.com END