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