0024428: Implementation of LGPL license
[occt.git] / src / BOPAlgo / BOPAlgo_PaveFiller_1.cxx
CommitLineData
4e57c75e 1// Created by: Peter KURNEV
973c2be1 2// Copyright (c) 2010-2014 OPEN CASCADE SAS
4e57c75e 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//
973c2be1 7// This file is part of Open CASCADE Technology software library.
4e57c75e 8//
973c2be1 9// This library is free software; you can redistribute it and / or modify it
10// under the terms of the GNU Lesser General Public 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.
4e57c75e 14//
973c2be1 15// Alternatively, this file may be used under the terms of Open CASCADE
16// commercial license or contractual agreement.
4e57c75e 17
18#include <BOPAlgo_PaveFiller.ixx>
19
20#include <NCollection_IncAllocator.hxx>
21#include <NCollection_BaseAllocator.hxx>
22
23#include <Bnd_Box.hxx>
24
25#include <TopoDS_Vertex.hxx>
26#include <BRepBndLib.hxx>
27
28#include <BOPCol_DataMapOfIntegerListOfInteger.hxx>
29#include <BOPCol_MapOfInteger.hxx>
30#include <BOPCol_ListOfShape.hxx>
31
32#include <BOPDS_DS.hxx>
33#include <BOPDS_Iterator.hxx>
34#include <BOPTools_AlgoTools.hxx>
35#include <BOPDS_VectorOfInterfVV.hxx>
36#include <BOPDS_ShapeInfo.hxx>
37#include <BOPAlgo_Tools.hxx>
38
39
40//=======================================================================
41// function: PerformVV
42// purpose:
43//=======================================================================
44 void BOPAlgo_PaveFiller::PerformVV()
45{
46 Standard_Boolean bWithSubShape;
47 Standard_Integer n1, n2, iFlag, nX, n, aSize, i, aNbVV, j, iX, k, aNbBlocks;
48 Handle(NCollection_IncAllocator) aAllocator;
49 BOPCol_DataMapIteratorOfDataMapOfIntegerListOfInteger aItMILI;
50 BOPCol_ListIteratorOfListOfInteger aItLI, aItLI2;
51 TopoDS_Vertex aVn;
52 BOPDS_ShapeInfo aSIn;
53 //
54 myErrorStatus=0;
55 //
56 myIterator->Initialize(TopAbs_VERTEX, TopAbs_VERTEX);
57 aSize=myIterator->ExpectedLength();
58 if (!aSize) {
59 return;
60 }
61 //
62 aSIn.SetShapeType(TopAbs_VERTEX);
63
64 BOPDS_VectorOfInterfVV& aVVs=myDS->InterfVV();
65 aVVs.SetStartSize(aSize);
66 aVVs.SetIncrement(aSize);
67 aVVs.Init();
68 //
69 //-----------------------------------------------------scope f
70 aAllocator=new NCollection_IncAllocator();
71 BOPCol_IndexedDataMapOfIntegerListOfInteger aMILI(100, aAllocator);
72 BOPCol_DataMapOfIntegerListOfInteger aMBlocks(100, aAllocator);
73 BOPCol_ListOfShape aLV(aAllocator);
74 //
75 // 1. Map V/LV
76 for (; myIterator->More(); myIterator->Next()) {
77 myIterator->Value(n1, n2, bWithSubShape);
78 //
79 const TopoDS_Vertex& aV1=(*(TopoDS_Vertex *)(&myDS->Shape(n1)));
80 const TopoDS_Vertex& aV2=(*(TopoDS_Vertex *)(&myDS->Shape(n2)));
81 //
82 iFlag=BOPTools_AlgoTools::ComputeVV(aV1, aV2);
83 if (!iFlag) {
84 BOPAlgo_Tools::FillMap(n1, n2, aMILI, aAllocator);
85 }
86 }
87 //
88 // 2. Make blocks
89 BOPAlgo_Tools::MakeBlocksCnx(aMILI, aMBlocks, aAllocator);
90 //
91 // 3. Make vertices
92 aNbBlocks=aMBlocks.Extent();
93 for (k=0; k<aNbBlocks; ++k) {
94 const BOPCol_ListOfInteger& aLI=aMBlocks.Find(k);
95 //
96 aLV.Clear();
97 aItLI.Initialize(aLI);
98 for (; aItLI.More(); aItLI.Next()) {
99 nX=aItLI.Value();
100 const TopoDS_Shape& aV=myDS->Shape(nX);
101 aLV.Append(aV);
102 }
103 //
104 BOPTools_AlgoTools::MakeVertex(aLV, aVn);
105 //
106 // Appennd new vertex to the DS
107 aSIn.SetShape(aVn);
108 n=myDS->Append(aSIn);
109 //
110 BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(n);
111 Bnd_Box& aBox=aSIDS.ChangeBox();
112 BRepBndLib::Add(aVn, aBox);
113 //
114 // Fill ShapesSD
115 aItLI.Initialize(aLI);
116 for (i=0; aItLI.More(); aItLI.Next(), ++i) {
117 n1=aItLI.Value();
118 myDS->AddShapeSD(n1, n);
119 //
120 aItLI2.Initialize(aLI);
121 for (j=0; aItLI2.More(); aItLI2.Next(), ++j) {
122 if (j>i) {
123 n2=aItLI2.Value();
124 //
125 myDS->AddInterf(n1, n2);
126 iX=aVVs.Append()-1;
127 BOPDS_InterfVV& aVV=aVVs(iX);
128 aVV.SetIndices(n1, n2);
129 aVV.SetIndexNew(n);
130 }
131 }
132 }
133 }
134 aNbVV=aVVs.Extent();
135 //
136 //-----------------------------------------------------scope t
137 aLV.Clear();
138 aMBlocks.Clear();
139 aMILI.Clear();
140 aAllocator.Nullify();
141}