Salome HOME
Join modifications from branch BR_DEBUG_3_2_0b1
[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
38 //=======================================================================
39 // function: PerformVF
40 // purpose: 
41 //=======================================================================
42   void NMTTools_PaveFiller::PerformVF() 
43 {
44   myIsDone=Standard_False;
45   //
46   Standard_Boolean aJustAddInterference;
47   Standard_Integer n1, n2, anIndexIn, aFlag, aWhat, aWith, aNbVSs, aBlockLength, iSDV;
48   Standard_Real aU, aV;
49   TopoDS_Vertex aV1;
50   TopoDS_Face aF2;
51   //
52   BOPTools_CArray1OfVSInterference& aVSs=myIntrPool->VSInterferences();
53   //
54   // V/E Interferences 
55   myDSIt.Initialize(TopAbs_VERTEX, TopAbs_FACE);
56   //
57   // BlockLength correction
58   aNbVSs=ExpectedPoolLength();
59   aBlockLength=aVSs.BlockLength();
60   if (aNbVSs > aBlockLength) {
61     aVSs.SetBlockLength(aNbVSs);
62   }
63   //
64   for (; myDSIt.More(); myDSIt.Next()) {
65     myDSIt.Current(n1, n2, aJustAddInterference);
66     //
67     if (! myIntrPool->IsComputed(n1, n2)) {
68       if (! IsSuccesstorsComputed(n1, n2)) {
69         anIndexIn=0;
70         aWhat=n1; // Vertex
71         aWith=n2; // Face
72         SortTypes(aWhat, aWith);
73         //
74         iSDV=FindSDVertex(aWhat);
75         //
76         if(aJustAddInterference) {
77           myIntrPool->AddInterference(aWhat, aWith, BooleanOperations_VertexSurface, anIndexIn);
78           continue;
79         }
80         //
81         aV1=TopoDS::Vertex(myDS->Shape(aWhat));
82         if (iSDV) {
83           aV1=TopoDS::Vertex(myDS->Shape(iSDV));
84         }
85         //
86         aF2=TopoDS::Face(myDS->Shape(aWith));
87         //
88         aFlag=myContext.ComputeVS (aV1, aF2, aU, aV);
89         //
90         if (!aFlag) {
91           //
92           // Add Interference to the Pool
93           BOPTools_VSInterference anInterf (aWhat, aWith, aU, aV);
94           anIndexIn=aVSs.Append(anInterf);
95           //
96           // SetState for Vertex in DS;
97           myDS->SetState (aWhat, BooleanOperations_ON);
98           // Insert Vertex in Interference Object
99           BOPTools_VSInterference& aVS=aVSs(anIndexIn);
100           aVS.SetNewShape(aWhat);
101         }
102         myIntrPool->AddInterference(aWhat, aWith, BooleanOperations_VertexSurface, anIndexIn);
103       }
104     }
105   }
106   myIsDone=Standard_True;
107 }