0024166: Unable to create file with "Save" menu of voxeldemo Qt sample
[occt.git] / src / BOPAlgo / BOPAlgo_PaveFiller_1.cxx
CommitLineData
4e57c75e 1// Created by: Peter KURNEV
2// Copyright (c) 2010-2012 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
6//
7// The content of this file is subject to the Open CASCADE Technology Public
8// License Version 6.5 (the "License"). You may not use the content of this file
9// except in compliance with the License. Please obtain a copy of the License
10// at http://www.opencascade.org and read it completely before using this file.
11//
12// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
13// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14//
15// The Original Code and all software distributed under the License is
16// distributed on an "AS IS" basis, without warranty of any kind, and the
17// Initial Developer hereby disclaims all such warranties, including without
18// limitation, any warranties of merchantability, fitness for a particular
19// purpose or non-infringement. Please see the License for the specific terms
20// and conditions governing the rights and limitations under the License.
21
22
23#include <BOPAlgo_PaveFiller.ixx>
24
25#include <NCollection_IncAllocator.hxx>
26#include <NCollection_BaseAllocator.hxx>
27
28#include <Bnd_Box.hxx>
29
30#include <TopoDS_Vertex.hxx>
31#include <BRepBndLib.hxx>
32
33#include <BOPCol_DataMapOfIntegerListOfInteger.hxx>
34#include <BOPCol_MapOfInteger.hxx>
35#include <BOPCol_ListOfShape.hxx>
36
37#include <BOPDS_DS.hxx>
38#include <BOPDS_Iterator.hxx>
39#include <BOPTools_AlgoTools.hxx>
40#include <BOPDS_VectorOfInterfVV.hxx>
41#include <BOPDS_ShapeInfo.hxx>
42#include <BOPAlgo_Tools.hxx>
43
44
45//=======================================================================
46// function: PerformVV
47// purpose:
48//=======================================================================
49 void BOPAlgo_PaveFiller::PerformVV()
50{
51 Standard_Boolean bWithSubShape;
52 Standard_Integer n1, n2, iFlag, nX, n, aSize, i, aNbVV, j, iX, k, aNbBlocks;
53 Handle(NCollection_IncAllocator) aAllocator;
54 BOPCol_DataMapIteratorOfDataMapOfIntegerListOfInteger aItMILI;
55 BOPCol_ListIteratorOfListOfInteger aItLI, aItLI2;
56 TopoDS_Vertex aVn;
57 BOPDS_ShapeInfo aSIn;
58 //
59 myErrorStatus=0;
60 //
61 myIterator->Initialize(TopAbs_VERTEX, TopAbs_VERTEX);
62 aSize=myIterator->ExpectedLength();
63 if (!aSize) {
64 return;
65 }
66 //
67 aSIn.SetShapeType(TopAbs_VERTEX);
68
69 BOPDS_VectorOfInterfVV& aVVs=myDS->InterfVV();
70 aVVs.SetStartSize(aSize);
71 aVVs.SetIncrement(aSize);
72 aVVs.Init();
73 //
74 //-----------------------------------------------------scope f
75 aAllocator=new NCollection_IncAllocator();
76 BOPCol_IndexedDataMapOfIntegerListOfInteger aMILI(100, aAllocator);
77 BOPCol_DataMapOfIntegerListOfInteger aMBlocks(100, aAllocator);
78 BOPCol_ListOfShape aLV(aAllocator);
79 //
80 // 1. Map V/LV
81 for (; myIterator->More(); myIterator->Next()) {
82 myIterator->Value(n1, n2, bWithSubShape);
83 //
84 const TopoDS_Vertex& aV1=(*(TopoDS_Vertex *)(&myDS->Shape(n1)));
85 const TopoDS_Vertex& aV2=(*(TopoDS_Vertex *)(&myDS->Shape(n2)));
86 //
87 iFlag=BOPTools_AlgoTools::ComputeVV(aV1, aV2);
88 if (!iFlag) {
89 BOPAlgo_Tools::FillMap(n1, n2, aMILI, aAllocator);
90 }
91 }
92 //
93 // 2. Make blocks
94 BOPAlgo_Tools::MakeBlocksCnx(aMILI, aMBlocks, aAllocator);
95 //
96 // 3. Make vertices
97 aNbBlocks=aMBlocks.Extent();
98 for (k=0; k<aNbBlocks; ++k) {
99 const BOPCol_ListOfInteger& aLI=aMBlocks.Find(k);
100 //
101 aLV.Clear();
102 aItLI.Initialize(aLI);
103 for (; aItLI.More(); aItLI.Next()) {
104 nX=aItLI.Value();
105 const TopoDS_Shape& aV=myDS->Shape(nX);
106 aLV.Append(aV);
107 }
108 //
109 BOPTools_AlgoTools::MakeVertex(aLV, aVn);
110 //
111 // Appennd new vertex to the DS
112 aSIn.SetShape(aVn);
113 n=myDS->Append(aSIn);
114 //
115 BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(n);
116 Bnd_Box& aBox=aSIDS.ChangeBox();
117 BRepBndLib::Add(aVn, aBox);
118 //
119 // Fill ShapesSD
120 aItLI.Initialize(aLI);
121 for (i=0; aItLI.More(); aItLI.Next(), ++i) {
122 n1=aItLI.Value();
123 myDS->AddShapeSD(n1, n);
124 //
125 aItLI2.Initialize(aLI);
126 for (j=0; aItLI2.More(); aItLI2.Next(), ++j) {
127 if (j>i) {
128 n2=aItLI2.Value();
129 //
130 myDS->AddInterf(n1, n2);
131 iX=aVVs.Append()-1;
132 BOPDS_InterfVV& aVV=aVVs(iX);
133 aVV.SetIndices(n1, n2);
134 aVV.SetIndexNew(n);
135 }
136 }
137 }
138 }
139 aNbVV=aVVs.Extent();
140 //
141 //-----------------------------------------------------scope t
142 aLV.Clear();
143 aMBlocks.Clear();
144 aMILI.Clear();
145 aAllocator.Nullify();
146}