0021762: Integration of new Boolean Operation algorithm to OCCT.
[occt.git] / src / BOPAlgo / BOPAlgo_PaveFiller_2.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 <TopoDS_Vertex.hxx>
26#include <TopoDS_Edge.hxx>
27#include <BRep_Tool.hxx>
28
29#include <BOPInt_Context.hxx>
30
31#include <BOPDS_Iterator.hxx>
32#include <BOPDS_VectorOfInterfVE.hxx>
33#include <BOPDS_Interf.hxx>
34#include <BOPDS_PassKey.hxx>
35#include <BOPDS_MapOfPassKey.hxx>
36#include <BRepBndLib.hxx>
37#include <BRep_Builder.hxx>
38
39
40//=======================================================================
41// function: PerformVE
42// purpose:
43//=======================================================================
44 void BOPAlgo_PaveFiller::PerformVE()
45{
46 Standard_Boolean bJustAdd;
47 Standard_Integer iSize, nV, nE, nVSD, iFlag, nVx, i;
48 Standard_Real aT, aTolE, aTolV;
49 BOPDS_Pave aPave;
50 BOPDS_PassKey aPK;
51 BOPDS_MapOfPassKey aMPK;
52 BRep_Builder aBB;
53 //
54 myErrorStatus=0;
55 //
56 myIterator->Initialize(TopAbs_VERTEX, TopAbs_EDGE);
57 iSize=myIterator->ExpectedLength();
58 if (!iSize) {
59 return;
60 }
61 //
62 BOPDS_VectorOfInterfVE& aVEs=myDS->InterfVE();
63 aVEs.SetStartSize(iSize);
64 aVEs.SetIncrement(iSize);
65 aVEs.Init();
66 //
67 for (; myIterator->More(); myIterator->Next()) {
68 myIterator->Value(nV, nE, bJustAdd);
69 if(bJustAdd) {
70 continue;
71 }
72 //
73 const BOPDS_ShapeInfo& aSIE=myDS->ShapeInfo(nE);
74 if (aSIE.HasSubShape(nV)) {
75 continue;
76 }
77 //
78 if (aSIE.HasFlag()){
79 continue;
80 }
81 //
82 if (myDS->HasInterfShapeSubShapes(nV, nE)) {
83 continue;
84 }
85 //
86 nVx=nV;
87 if (myDS->HasShapeSD(nV, nVSD)) {
88 nVx=nVSD;
89 }
90 //
91 aPK.SetIds(nVx, nE);
92 if (!aMPK.Add(aPK)) {
93 continue;
94 }
95 //
96 const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&aSIE.Shape()));
97 const TopoDS_Vertex& aV=(*(TopoDS_Vertex *)(&myDS->Shape(nVx)));
98 //
99 iFlag=myContext->ComputeVE (aV, aE, aT);
100 if (!iFlag) {
101 // 1
102 i=aVEs.Append()-1;
103 BOPDS_InterfVE& aVE=aVEs(i);
104 aVE.SetIndices(nV, nE);
105 aVE.SetParameter(aT);
106 // 2
107 myDS->AddInterf(nV, nE);
108 // 3
109 BOPDS_ListOfPaveBlock& aLPB=myDS->ChangePaveBlocks(nE);
110 Handle(BOPDS_PaveBlock)& aPB=*((Handle_BOPDS_PaveBlock*)&aLPB.First());
111 //
112 aPave.SetIndex(nVx);
113 aPave.SetParameter(aT);
114 aPB->AppendExtPave(aPave);
115 aTolV = BRep_Tool::Tolerance(aV);
116 aTolE = BRep_Tool::Tolerance(aE);
117 if ( aTolV < aTolE) {
118 aBB.UpdateVertex(aV, aTolE);
119 BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(nVx);
120 Bnd_Box& aBoxDS=aSIDS.ChangeBox();
121 BRepBndLib::Add(aV, aBoxDS);
122 }
123 }
124 }//for (; myIterator->More(); myIterator->Next()) {
125}