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_Tools.hxx>
22 #include <BOPAlgo_Alerts.hxx>
23 #include <BOPDS_DS.hxx>
24 #include <BOPDS_Iterator.hxx>
25 #include <BOPDS_PaveBlock.hxx>
26 #include <BOPDS_ShapeInfo.hxx>
27 #include <BOPDS_VectorOfInterfVV.hxx>
28 #include <BOPTools_AlgoTools.hxx>
29 #include <BRep_Builder.hxx>
30 #include <BRep_TVertex.hxx>
31 #include <BRep_Tool.hxx>
33 #include <IntTools_Context.hxx>
34 #include <NCollection_BaseAllocator.hxx>
35 #include <Precision.hxx>
36 #include <TColStd_DataMapOfIntegerInteger.hxx>
38 #include <TopoDS_Face.hxx>
39 #include <TopoDS_Vertex.hxx>
40 #include <TopoDS_Compound.hxx>
41 #include <TopTools_ListOfShape.hxx>
43 //=======================================================================
44 // function: PerformVV
46 //=======================================================================
47 void BOPAlgo_PaveFiller::PerformVV()
49 Standard_Integer n1, n2, iFlag, aSize;
50 Handle(NCollection_BaseAllocator) aAllocator;
52 myIterator->Initialize(TopAbs_VERTEX, TopAbs_VERTEX);
53 aSize=myIterator->ExpectedLength();
58 BOPDS_VectorOfInterfVV& aVVs=myDS->InterfVV();
59 aVVs.SetIncrement(aSize);
61 //-----------------------------------------------------scope f
63 NCollection_BaseAllocator::CommonBaseAllocator();
64 NCollection_IndexedDataMap<Standard_Integer, TColStd_ListOfInteger>aMILI(100, aAllocator);
65 NCollection_List<TColStd_ListOfInteger> aMBlocks(aAllocator);
68 for (; myIterator->More(); myIterator->Next()) {
69 myIterator->Value(n1, n2);
71 const TopoDS_Vertex& aV1=(*(TopoDS_Vertex *)(&myDS->Shape(n1)));
72 const TopoDS_Vertex& aV2=(*(TopoDS_Vertex *)(&myDS->Shape(n2)));
74 iFlag=BOPTools_AlgoTools::ComputeVV(aV1, aV2, myFuzzyValue);
76 BOPAlgo_Tools::FillMap<Standard_Integer, TColStd_MapIntegerHasher>(n1, n2, aMILI, aAllocator);
81 BOPAlgo_Tools::MakeBlocks<Standard_Integer, TColStd_MapIntegerHasher>(aMILI, aMBlocks, aAllocator);
84 NCollection_List<TColStd_ListOfInteger>::Iterator aItB(aMBlocks);
85 for (; aItB.More(); aItB.Next()) {
86 const TColStd_ListOfInteger& aLI = aItB.Value();
90 TColStd_DataMapIteratorOfDataMapOfIntegerInteger aItDMII;
92 TColStd_DataMapOfIntegerInteger& aDMII=myDS->ShapesSD();
93 aItDMII.Initialize(aDMII);
94 for (; aItDMII.More(); aItDMII.Next()) {
96 myDS->InitPaveBlocksForVertex(n1);
99 //-----------------------------------------------------scope t
104 //=======================================================================
105 // function: PerformVV
107 //=======================================================================
108 Standard_Integer BOPAlgo_PaveFiller::MakeSDVertices
109 (const TColStd_ListOfInteger& theVertIndices,
110 const Standard_Boolean theAddInterfs)
112 TopoDS_Vertex aVSD, aVn;
113 Standard_Integer nSD = -1;
114 TColStd_ListIteratorOfListOfInteger aItLI(theVertIndices);
115 TopTools_ListOfShape aLV;
116 for (; aItLI.More(); aItLI.Next()) {
117 Standard_Integer nX = aItLI.Value(), nSD1;
118 if (myDS->HasShapeSD(nX, nSD1)) {
119 const TopoDS_Shape& aVSD1 = myDS->Shape(nSD1);
121 aVSD = TopoDS::Vertex(aVSD1);
128 const TopoDS_Shape& aV = myDS->Shape(nX);
131 BOPTools_AlgoTools::MakeVertex(aLV, aVn);
134 // update old SD vertex with new value
135 Handle(BRep_TVertex)& aTVertex =
136 reinterpret_cast<Handle(BRep_TVertex)&>(const_cast<Handle(TopoDS_TShape)&>(aVSD.TShape()));
137 aTVertex->Pnt(BRep_Tool::Pnt(aVn));
138 aTVertex->Tolerance(BRep_Tool::Tolerance(aVn));
143 // Append new vertex to the DS
144 BOPDS_ShapeInfo aSIn;
145 aSIn.SetShapeType(TopAbs_VERTEX);
147 nV = myDS->Append(aSIn);
149 BOPDS_ShapeInfo& aSIDS = myDS->ChangeShapeInfo(nV);
150 Bnd_Box& aBox = aSIDS.ChangeBox();
151 aBox.Add(BRep_Tool::Pnt(aVn));
152 aBox.SetGap(BRep_Tool::Tolerance(aVn) + Precision::Confusion());
155 BOPDS_VectorOfInterfVV& aVVs = myDS->InterfVV();
157 aVVs.SetIncrement(theVertIndices.Extent());
159 aItLI.Initialize(theVertIndices);
160 for (; aItLI.More(); aItLI.Next()) {
161 Standard_Integer n1 = aItLI.Value();
162 myDS->AddShapeSD(n1, nV);
164 Standard_Integer iR1 = myDS->Rank(n1);
165 const TopoDS_Shape& aV1 = myDS->Shape(n1);
167 TColStd_ListIteratorOfListOfInteger aItLI2 = aItLI;
169 for (; aItLI2.More(); aItLI2.Next()) {
170 Standard_Integer n2 = aItLI2.Value();
172 if (iR1 >= 0 && iR1 == myDS->Rank(n2)) {
173 // add warning status
174 const TopoDS_Shape& aV2 = myDS->Shape(n2);
177 BRep_Builder().MakeCompound(aWC);
178 BRep_Builder().Add(aWC, aV1);
179 BRep_Builder().Add(aWC, aV2);
181 AddWarning (new BOPAlgo_AlertSelfInterferingShape (aWC));
185 myDS->AddInterf(n1, n2);
186 BOPDS_InterfVV& aVV = aVVs.Appended();
188 aVV.SetIndices(n1, n2);