1 // File: NMTTools_PaveFiller_1.cxx
2 // Created: Mon Dec 8 11:47:55 2003
3 // Author: Peter KURNEV
7 #include <NMTTools_PaveFiller.ixx>
9 #include <TColStd_IndexedMapOfInteger.hxx>
12 #include <TopoDS_Shape.hxx>
13 #include <TopoDS_Vertex.hxx>
15 #include <TopTools_ListOfShape.hxx>
17 #include <IntTools_Tools.hxx>
18 #include <BOPTools_VVInterference.hxx>
19 #include <BOPTools_CArray1OfVVInterference.hxx>
20 #include <BOPTools_VVInterference.hxx>
21 #include <BooleanOperations_AncestorsSeqAndSuccessorsSeq.hxx>
22 #include <BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger.hxx>
24 #include <NMTDS_ShapesDataStructure.hxx>
25 #include <NMTTools_Tools.hxx>
26 #include <TopTools_IndexedMapOfShape.hxx>
30 //=======================================================================
31 // function: PerformVV
33 //=======================================================================
34 void NMTTools_PaveFiller::PerformVV()
36 myIsDone=Standard_False;
38 Standard_Integer n1, n2,anIndexIn, aFlag, aWhat, aWith, aNbVVs, aBlockLength;
39 Standard_Boolean bJustAddInterference;
41 BOPTools_CArray1OfVVInterference& aVVs=myIntrPool->VVInterferences();
43 // BlockLength correction
44 aNbVVs=ExpectedPoolLength();
45 aBlockLength=aVVs.BlockLength();
46 if (aNbVVs > aBlockLength) {
47 aVVs.SetBlockLength(aNbVVs);
50 // V/V BooleanOperations_VertexVertex
51 myDSIt.Initialize(TopAbs_VERTEX, TopAbs_VERTEX);
53 for (; myDSIt.More(); myDSIt.Next()) {
54 myDSIt.Current(n1, n2, bJustAddInterference);
56 if (!myIntrPool->IsComputed(n1, n2)) {
60 SortTypes(aWhat, aWith);
61 if (!bJustAddInterference) {
62 const TopoDS_Shape& aS1=myDS->GetShape(aWhat);
63 const TopoDS_Shape& aS2=myDS->GetShape(aWith);
65 const TopoDS_Vertex& aV1=TopoDS::Vertex(aS1);
66 const TopoDS_Vertex& aV2=TopoDS::Vertex(aS2);
67 aFlag=IntTools_Tools::ComputeVV (aV1, aV2);
70 BOPTools_VVInterference anInterf (aWhat, aWith);
71 anIndexIn=aVVs.Append(anInterf);
74 myIntrPool->AddInterference(aWhat, aWith, BooleanOperations_VertexVertex, anIndexIn);
77 myIsDone=Standard_True;
79 //=======================================================================
80 // function: PerformNewVertices
82 //=======================================================================
83 void NMTTools_PaveFiller::PerformNewVertices()
85 myIsDone=Standard_False;
87 Standard_Integer i, aNb, anIndex1, anIndex2, aNewShape;
88 TopoDS_Vertex aNewVertex;
89 BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
91 Standard_Integer aNbChains, j, aNbV, aIdV, aNbL;
92 TColStd_IndexedMapOfInteger aMapWhole;
93 BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger aMapChains;//aMCV
94 TopTools_ListOfShape aLV;
95 TopTools_IndexedMapOfShape aM;
97 // 1. VV Interferences
98 BOPTools_CArray1OfVVInterference& VVs=myIntrPool->VVInterferences();
100 NMTTools_Tools::FindChains(VVs, aMapChains);
102 aNbChains=aMapChains.Extent();
103 for (i=1; i<=aNbChains; ++i) {
104 const TColStd_IndexedMapOfInteger& aChain=aMapChains(i);
108 aNbV=aChain.Extent();
109 for (j=1; j<=aNbV; ++j) {
111 const TopoDS_Shape& aV=myDS->Shape(aIdV);
112 if (!aM.Contains(aV)) {
125 NMTTools_Tools::MakeNewVertex(aLV, aNewVertex);
126 // Insert New Vertex in DS;
127 // aNewShape is # of DS-line, where aNewVertex is kept
128 myDS->InsertShapeAndAncestorsSuccessors(aNewVertex, anASSeq);
129 aNewShape=myDS->NumberOfInsertedShapes();
131 // State of New Vertex is ON
132 myDS->SetState (aNewShape, BooleanOperations_ON);
135 // Insert New Vertex in Interference
137 for (j=1; j<=aNb; ++j) {
138 BOPTools_VVInterference& VV=VVs(j);
139 anIndex1=VV.Index1();
140 anIndex2=VV.Index2();
141 if (aChain.Contains(anIndex1) || aChain.Contains(anIndex2)) {
142 VV.SetNewShape(aNewShape);
146 myIsDone=Standard_True;
149 //=======================================================================
150 // function: FindSDVertex
152 //=======================================================================
153 Standard_Integer NMTTools_PaveFiller::FindSDVertex(const Standard_Integer nV)const
155 Standard_Integer i, aNb, anIndex1, anIndex2, aNewShape=0;
157 BOPTools_CArray1OfVVInterference& VVs=myIntrPool->VVInterferences();
160 for (i=1; i<=aNb; i++) {
161 const BOPTools_VVInterference& VV=VVs(i);
162 anIndex1=VV.Index1();
163 anIndex2=VV.Index2();
164 if (nV==anIndex1 || nV==anIndex2) {
165 aNewShape=VV.NewShape();