Salome HOME
149eed7fc348da8e7e8edf209b313f025701f636
[modules/geom.git] / src / NMTTools / NMTTools_PaveFiller_3.cxx
1 // File:        NMTTools_PaveFiller_3.cxx
2 // Created:     Mon Dec  8 16:06:56 2003
3 // Author:      Peter KURNEV
4 //              <pkv@irinox>
5
6
7 #include <NMTTools_PaveFiller.ixx>
8
9 #include <TopoDS.hxx>
10 #include <TopoDS_Shape.hxx>
11 #include <TopoDS_Vertex.hxx>
12 #include <TopoDS_Face.hxx>
13
14 #include <BOPTools_VSInterference.hxx>
15 #include <BOPTools_CArray1OfVSInterference.hxx>
16
17 #include <NMTDS_ShapesDataStructure.hxx>
18
19 //=======================================================================
20 // function: PerformVF
21 // purpose: 
22 //=======================================================================
23   void NMTTools_PaveFiller::PerformVF() 
24 {
25   myIsDone=Standard_False;
26   //
27   Standard_Boolean aJustAddInterference;
28   Standard_Integer n1, n2, anIndexIn, aFlag, aWhat, aWith, aNbVSs, aBlockLength, iSDV;
29   Standard_Real aU, aV;
30   TopoDS_Vertex aV1;
31   TopoDS_Face aF2;
32   //
33   BOPTools_CArray1OfVSInterference& aVSs=myIntrPool->VSInterferences();
34   //
35   // V/E Interferences 
36   myDSIt.Initialize(TopAbs_VERTEX, TopAbs_FACE);
37   //
38   // BlockLength correction
39   aNbVSs=ExpectedPoolLength();
40   aBlockLength=aVSs.BlockLength();
41   if (aNbVSs > aBlockLength) {
42     aVSs.SetBlockLength(aNbVSs);
43   }
44   //
45   for (; myDSIt.More(); myDSIt.Next()) {
46     myDSIt.Current(n1, n2, aJustAddInterference);
47     //
48     if (! myIntrPool->IsComputed(n1, n2)) {
49       if (! IsSuccesstorsComputed(n1, n2)) {
50         anIndexIn=0;
51         aWhat=n1; // Vertex
52         aWith=n2; // Face
53         SortTypes(aWhat, aWith);
54         //
55         iSDV=FindSDVertex(aWhat);
56         //
57         if(aJustAddInterference) {
58           myIntrPool->AddInterference(aWhat, aWith, BooleanOperations_VertexSurface, anIndexIn);
59           continue;
60         }
61         //
62         aV1=TopoDS::Vertex(myDS->Shape(aWhat));
63         if (iSDV) {
64           aV1=TopoDS::Vertex(myDS->Shape(iSDV));
65         }
66         //
67         aF2=TopoDS::Face(myDS->Shape(aWith));
68         //
69         aFlag=myContext.ComputeVS (aV1, aF2, aU, aV);
70         //
71         if (!aFlag) {
72           //
73           // Add Interference to the Pool
74           BOPTools_VSInterference anInterf (aWhat, aWith, aU, aV);
75           anIndexIn=aVSs.Append(anInterf);
76           //
77           // SetState for Vertex in DS;
78           myDS->SetState (aWhat, BooleanOperations_ON);
79           // Insert Vertex in Interference Object
80           BOPTools_VSInterference& aVS=aVSs(anIndexIn);
81           aVS.SetNewShape(aWhat);
82         }
83         myIntrPool->AddInterference(aWhat, aWith, BooleanOperations_VertexSurface, anIndexIn);
84       }
85     }
86   }
87   myIsDone=Standard_True;
88 }