Salome HOME
This commit was generated by cvs2git to create tag 'TRIPOLI_323'.
[modules/geom.git] / src / NMTTools / NMTTools_PaveFiller_3.cxx
1 // Copyright (C) 2007-2012  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
23 // File:        NMTTools_PaveFiller_3.cxx
24 // Created:     Mon Dec  8 16:06:56 2003
25 // Author:      Peter KURNEV
26 //              <pkv@irinox>
27 //
28 #include <NMTTools_PaveFiller.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 #include <IntTools_Context.hxx>
44
45
46 static
47   Standard_Boolean Contains(const TopoDS_Face& aF,
48                             const TopoDS_Vertex& aV);
49
50 //=======================================================================
51 // function: PerformVF
52 // purpose:
53 //=======================================================================
54   void NMTTools_PaveFiller::PerformVF()
55 {
56   myIsDone=Standard_False;
57   //
58   Standard_Boolean aJustAdd;
59   Standard_Integer n1, n2, anIndexIn, aFlag, aWhat, aWith, aNbVSs, aBlockLength, iSDV;
60   Standard_Real aU, aV;
61   TopoDS_Vertex aV1;
62   TopoDS_Face aF2;
63   //
64   BOPTools_CArray1OfVSInterference& aVSs=myIP->VSInterferences();
65   //
66   // V/E Interferences
67   myDSIt->Initialize(TopAbs_VERTEX, TopAbs_FACE);
68   //
69   // BlockLength correction
70   aNbVSs=myDSIt->BlockLength();
71   aBlockLength=aVSs.BlockLength();
72   if (aNbVSs > aBlockLength) {
73     aVSs.SetBlockLength(aNbVSs);
74   }
75   //
76   for (; myDSIt->More(); myDSIt->Next()) {
77     myDSIt->Current(n1, n2, aJustAdd);
78     if (! IsSuccessorsComputed(n1, n2)) {
79       anIndexIn=0;
80       aWhat=n1; // Vertex
81       aWith=n2; // Face
82       if (myDS->GetShapeType(n1)==TopAbs_FACE) {
83         aWhat=n2;
84         aWith=n1;
85       }
86       //
87       iSDV=FindSDVertex(aWhat);
88         //
89       if(aJustAdd) {
90         //myIntrPool->AddInterference(aWhat, aWith, BooleanOperations_VertexSurface, anIndexIn);
91         continue;
92       }
93       //
94       aV1=TopoDS::Vertex(myDS->Shape(aWhat));
95       if (iSDV) {
96         aV1=TopoDS::Vertex(myDS->Shape(iSDV));
97       }
98         //
99       aF2=TopoDS::Face(myDS->Shape(aWith));
100       //
101       // Modified  Thu Sep 14 14:35:18 2006
102       // Contribution of Samtech www.samcef.com BEGIN
103       if (Contains(aF2, aV1)) {
104         continue;
105       }
106       // Contribution of Samtech www.samcef.com END
107       //
108       aFlag=myContext->ComputeVS (aV1, aF2, aU, aV);
109       //
110       if (!aFlag) {
111         //
112         // Add Interference to the Pool
113         BOPTools_VSInterference anInterf (aWhat, aWith, aU, aV);
114         anIndexIn=aVSs.Append(anInterf);
115         //
116         // SetState for Vertex in DS;
117         myDS->SetState (aWhat, BooleanOperations_ON);
118         // Insert Vertex in Interference Object
119         BOPTools_VSInterference& aVS=aVSs(anIndexIn);
120         aVS.SetNewShape(aWhat);
121         // qqf
122         {
123           myIP->Add(aWhat, aWith, Standard_True, NMTDS_TI_VF);
124         }
125         // qqt
126       }
127       //myIntrPool->AddInterference(aWhat, aWith, BooleanOperations_VertexSurface, anIndexIn);
128     }
129   }
130   myIsDone=Standard_True;
131 }
132 // Modified  Thu Sep 14 14:35:18 2006
133 // Contribution of Samtech www.samcef.com BEGIN
134 //=======================================================================
135 //function : Contains
136 //purpose  :
137 //=======================================================================
138 Standard_Boolean Contains(const TopoDS_Face& aF,
139                           const TopoDS_Vertex& aV)
140 {
141   Standard_Boolean bRet;
142   TopExp_Explorer aExp;
143   //
144   bRet=Standard_False;
145   aExp.Init(aF, TopAbs_VERTEX);
146   for (; aExp.More(); aExp.Next()) {
147     const TopoDS_Shape& aVF=aExp.Current();
148     if (aVF.IsSame(aV)) {
149       bRet=!bRet;
150       break;
151     }
152   }
153   return bRet;
154 }
155 // Contribution of Samtech www.samcef.com END