]> SALOME platform Git repositories - modules/geom.git/blob - src/NMTTools/NMTTools_PaveFiller_3.cxx
Salome HOME
0021434: Boolean operations generate a shape with big vertex tolerance.
[modules/geom.git] / src / NMTTools / NMTTools_PaveFiller_3.cxx
1 // Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21
22 // File:        NMTTools_PaveFiller_3.cxx
23 // Created:     Mon Dec  8 16:06:56 2003
24 // Author:      Peter KURNEV
25
26 #include <NMTTools_PaveFiller.ixx>
27
28 #include <Basics_OCCTVersion.hxx>
29
30 #include <TopoDS.hxx>
31 #include <TopoDS_Shape.hxx>
32 #include <TopoDS_Vertex.hxx>
33 #include <TopoDS_Face.hxx>
34
35 #include <TopExp_Explorer.hxx>
36
37 #include <BOPTools_VSInterference.hxx>
38 #include <BOPTools_CArray1OfVSInterference.hxx>
39
40 #include <NMTDS_Iterator.hxx>
41 #include <NMTDS_ShapesDataStructure.hxx>
42 #include <NMTDS_InterfPool.hxx>
43
44
45 // Modified  Thu Sep 14 14:35:18 2006 
46 // Contribution of Samtech www.samcef.com BEGIN
47 static
48   Standard_Boolean Contains(const TopoDS_Face& aF,
49                             const TopoDS_Vertex& aV);
50 // Contribution of Samtech www.samcef.com END
51
52 //=======================================================================
53 // function: PerformVF
54 // purpose: 
55 //=======================================================================
56   void NMTTools_PaveFiller::PerformVF() 
57 {
58   myIsDone=Standard_False;
59   //
60   Standard_Boolean aJustAdd;
61   Standard_Integer n1, n2, anIndexIn, aFlag, aWhat, aWith, aNbVSs, aBlockLength, iSDV;
62   Standard_Real aU, aV;
63   TopoDS_Vertex aV1;
64   TopoDS_Face aF2;
65   //
66   BOPTools_CArray1OfVSInterference& aVSs=myIP->VSInterferences();
67   //
68   // V/E Interferences 
69   myDSIt->Initialize(TopAbs_VERTEX, TopAbs_FACE);
70   //
71   // BlockLength correction
72   aNbVSs=myDSIt->BlockLength();
73   aBlockLength=aVSs.BlockLength();
74   if (aNbVSs > aBlockLength) {
75     aVSs.SetBlockLength(aNbVSs);
76   }
77   //
78   for (; myDSIt->More(); myDSIt->Next()) {
79     myDSIt->Current(n1, n2, aJustAdd);
80     if (! IsSuccessorsComputed(n1, n2)) {
81       anIndexIn=0;
82       aWhat=n1; // Vertex
83       aWith=n2; // Face
84       if (myDS->GetShapeType(n1)==TopAbs_FACE) {
85         aWhat=n2;
86         aWith=n1;
87       }
88       //
89       iSDV=FindSDVertex(aWhat);
90         //
91       if(aJustAdd) {
92         //myIntrPool->AddInterference(aWhat, aWith, BooleanOperations_VertexSurface, anIndexIn);
93         continue;
94       }
95       //
96       aV1=TopoDS::Vertex(myDS->Shape(aWhat));
97       if (iSDV) {
98         aV1=TopoDS::Vertex(myDS->Shape(iSDV));
99       }
100         //
101       aF2=TopoDS::Face(myDS->Shape(aWith));
102       //
103       // Modified  Thu Sep 14 14:35:18 2006 
104       // Contribution of Samtech www.samcef.com BEGIN
105       if (Contains(aF2, aV1)) {
106         continue;
107       }
108       // Contribution of Samtech www.samcef.com END
109       //
110 #if OCC_VERSION_LARGE > 0x06050200
111       aFlag=myContext->ComputeVS (aV1, aF2, aU, aV);
112 #else
113       aFlag=myContext.ComputeVS (aV1, aF2, aU, aV);
114 #endif
115       //
116       if (!aFlag) {
117         //
118         // Add Interference to the Pool
119         BOPTools_VSInterference anInterf (aWhat, aWith, aU, aV);
120         anIndexIn=aVSs.Append(anInterf);
121         //
122         // SetState for Vertex in DS;
123         myDS->SetState (aWhat, BooleanOperations_ON);
124         // Insert Vertex in Interference Object
125         BOPTools_VSInterference& aVS=aVSs(anIndexIn);
126         aVS.SetNewShape(aWhat);
127         // qqf
128         {
129           myIP->Add(aWhat, aWith, Standard_True, NMTDS_TI_VF);
130         }
131         // qqt
132       }
133       //myIntrPool->AddInterference(aWhat, aWith, BooleanOperations_VertexSurface, anIndexIn);
134     }
135   }
136   myIsDone=Standard_True;
137 }
138 // Modified  Thu Sep 14 14:35:18 2006 
139 // Contribution of Samtech www.samcef.com BEGIN
140 //=======================================================================
141 //function : Contains
142 //purpose  : 
143 //=======================================================================
144 Standard_Boolean Contains(const TopoDS_Face& aF,
145                           const TopoDS_Vertex& aV)
146 {
147   Standard_Boolean bRet;
148   TopExp_Explorer aExp;
149   //
150   bRet=Standard_False;
151   aExp.Init(aF, TopAbs_VERTEX);
152   for (; aExp.More(); aExp.Next()) {
153     const TopoDS_Shape& aVF=aExp.Current();
154     if (aVF.IsSame(aV)) {
155       bRet=!bRet;
156       break;
157     }
158   }
159   return bRet;
160 }
161 // Contribution of Samtech www.samcef.com END