1 // Created by: Peter KURNEV
2 // Copyright (c) 2010-2014 OPEN CASCADE SAS
3 // Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
4 // Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT,
5 // EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
7 // This file is part of Open CASCADE Technology software library.
9 // This library is free software; you can redistribute it and/or modify it under
10 // the terms of the GNU Lesser General Public License version 2.1 as published
11 // by the Free Software Foundation, with special exception defined in the file
12 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
13 // distribution for complete text of the license and disclaimer of any warranty.
15 // Alternatively, this file may be used under the terms of Open CASCADE
16 // commercial license or contractual agreement.
19 #include <Bnd_Box.hxx>
20 #include <BOPAlgo_PaveFiller.hxx>
21 #include <BOPAlgo_SectionAttribute.hxx>
22 #include <BOPAlgo_Tools.hxx>
23 #include <BOPCol_DataMapOfIntegerInteger.hxx>
24 #include <BOPCol_DataMapOfIntegerListOfInteger.hxx>
25 #include <BOPCol_ListOfShape.hxx>
26 #include <BOPCol_MapOfInteger.hxx>
27 #include <BOPDS_Curve.hxx>
28 #include <BOPDS_DS.hxx>
29 #include <BOPDS_Iterator.hxx>
30 #include <BOPDS_PaveBlock.hxx>
31 #include <BOPDS_ShapeInfo.hxx>
32 #include <BOPDS_VectorOfInterfVV.hxx>
33 #include <BOPTools_AlgoTools.hxx>
34 #include <BRepBndLib.hxx>
35 #include <BRep_TVertex.hxx>
36 #include <BRep_Tool.hxx>
38 #include <IntTools_Context.hxx>
39 #include <NCollection_BaseAllocator.hxx>
40 #include <Precision.hxx>
42 #include <TopoDS_Face.hxx>
43 #include <TopoDS_Vertex.hxx>
45 //=======================================================================
46 // function: PerformVV
48 //=======================================================================
49 void BOPAlgo_PaveFiller::PerformVV()
51 Standard_Boolean bWithSubShape;
52 Standard_Integer n1, n2, iFlag, aSize, k, aNbBlocks;
53 Handle(NCollection_BaseAllocator) aAllocator;
57 myIterator->Initialize(TopAbs_VERTEX, TopAbs_VERTEX);
58 aSize=myIterator->ExpectedLength();
63 BOPDS_VectorOfInterfVV& aVVs=myDS->InterfVV();
64 aVVs.SetIncrement(aSize);
66 //-----------------------------------------------------scope f
68 NCollection_BaseAllocator::CommonBaseAllocator();
69 BOPCol_IndexedDataMapOfIntegerListOfInteger aMILI(100, aAllocator);
70 BOPCol_DataMapOfIntegerListOfInteger aMBlocks(100, aAllocator);
73 for (; myIterator->More(); myIterator->Next()) {
74 myIterator->Value(n1, n2, bWithSubShape);
76 const TopoDS_Vertex& aV1=(*(TopoDS_Vertex *)(&myDS->Shape(n1)));
77 const TopoDS_Vertex& aV2=(*(TopoDS_Vertex *)(&myDS->Shape(n2)));
79 iFlag=BOPTools_AlgoTools::ComputeVV(aV1, aV2);
81 BOPAlgo_Tools::FillMap(n1, n2, aMILI, aAllocator);
86 BOPAlgo_Tools::MakeBlocksCnx(aMILI, aMBlocks, aAllocator);
89 aNbBlocks=aMBlocks.Extent();
90 for (k=0; k<aNbBlocks; ++k) {
91 const BOPCol_ListOfInteger& aLI=aMBlocks.Find(k);
96 BOPCol_DataMapIteratorOfDataMapOfIntegerInteger aItDMII;
98 BOPCol_DataMapOfIntegerInteger& aDMII=myDS->ShapesSD();
99 aItDMII.Initialize(aDMII);
100 for (; aItDMII.More(); aItDMII.Next()) {
102 myDS->InitPaveBlocksForVertex(n1);
105 //-----------------------------------------------------scope t
110 //=======================================================================
111 // function: PerformVV
113 //=======================================================================
114 void BOPAlgo_PaveFiller::MakeSDVertices(const BOPCol_ListOfInteger& theVertIndices)
116 TopoDS_Vertex aVSD, aVn;
117 BOPCol_ListIteratorOfListOfInteger aItLI(theVertIndices);
118 BOPCol_ListOfShape aLV;
119 for (; aItLI.More(); aItLI.Next()) {
120 Standard_Integer nX = aItLI.Value();
121 Standard_Integer nSD;
122 if (myDS->HasShapeSD(nX, nSD)) {
123 aVSD = TopoDS::Vertex(myDS->Shape(nSD));
125 const TopoDS_Shape& aV = myDS->Shape(nX);
128 BOPTools_AlgoTools::MakeVertex(aLV, aVn);
129 if (!aVSD.IsNull()) {
130 // update old SD vertex with new value
131 Handle(BRep_TVertex)& aTVertex =
132 reinterpret_cast<Handle(BRep_TVertex)&>(const_cast<Handle(TopoDS_TShape)&>(aVSD.TShape()));
133 aTVertex->Pnt(BRep_Tool::Pnt(aVn));
134 aTVertex->Tolerance(BRep_Tool::Tolerance(aVn));
137 // Append new vertex to the DS
138 BOPDS_ShapeInfo aSIn;
139 aSIn.SetShapeType(TopAbs_VERTEX);
141 Standard_Integer n = myDS->Append(aSIn);
143 BOPDS_ShapeInfo& aSIDS = myDS->ChangeShapeInfo(n);
144 Bnd_Box& aBox = aSIDS.ChangeBox();
145 BRepBndLib::Add(aVn, aBox);
146 aBox.SetGap(aBox.GetGap() + Precision::Confusion());
149 BOPDS_VectorOfInterfVV& aVVs = myDS->InterfVV();
150 aVVs.SetIncrement(theVertIndices.Extent());
152 aItLI.Initialize(theVertIndices);
153 for (; aItLI.More(); aItLI.Next()) {
154 Standard_Integer n1 = aItLI.Value();
155 myDS->AddShapeSD(n1, n);
157 BOPCol_ListIteratorOfListOfInteger aItLI2 = aItLI;
159 for (; aItLI2.More(); aItLI2.Next()) {
160 Standard_Integer n2 = aItLI2.Value();
162 myDS->AddInterf(n1, n2);
163 BOPDS_InterfVV& aVV = aVVs.Append1();
165 aVV.SetIndices(n1, n2);