0026619: Tolerances of operands are modified using bop
[occt.git] / src / BOPAlgo / BOPAlgo_PaveFiller_9.cxx
CommitLineData
505abfb8 1// Created by: Peter KURNEV
2// Copyright (c) 1999-2014 OPEN CASCADE SAS
3//
4// This file is part of Open CASCADE Technology software library.
5//
6// This library is free software; you can redistribute it and/or modify it under
7// the terms of the GNU Lesser General Public License version 2.1 as published
8// by the Free Software Foundation, with special exception defined in the file
9// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10// distribution for complete text of the license and disclaimer of any warranty.
11//
12// Alternatively, this file may be used under the terms of Open CASCADE
13// commercial license or contractual agreement.
14
505abfb8 15
42cf5bc1 16#include <Bnd_Box.hxx>
17#include <BOPAlgo_PaveFiller.hxx>
18#include <BOPAlgo_SectionAttribute.hxx>
505abfb8 19#include <BOPCol_MapOfInteger.hxx>
42cf5bc1 20#include <BOPCol_NCVector.hxx>
c7b59798 21#include <BOPCol_Parallel.hxx>
42cf5bc1 22#include <BOPDS_Curve.hxx>
23#include <BOPDS_DS.hxx>
505abfb8 24#include <BOPDS_Iterator.hxx>
25#include <BOPDS_ListOfPaveBlock.hxx>
42cf5bc1 26#include <BOPDS_PaveBlock.hxx>
27#include <BOPDS_ShapeInfo.hxx>
28#include <gp_Pnt.hxx>
29#include <IntTools_Context.hxx>
1e143abb 30#include <IntTools_ShrunkRange.hxx>
42cf5bc1 31#include <TopoDS_Edge.hxx>
32#include <TopoDS_Face.hxx>
33#include <TopoDS_Vertex.hxx>
505abfb8 34
42cf5bc1 35//
505abfb8 36//=======================================================================
37//class : BOPAlgo_ShrunkRange
38//purpose :
39//=======================================================================
1e143abb 40class BOPAlgo_ShrunkRange : public IntTools_ShrunkRange {
505abfb8 41 public:
42 BOPAlgo_ShrunkRange()
1e143abb 43 : IntTools_ShrunkRange(),
505abfb8 44 myWarningStatus(0) {
45 }
46 //
47 virtual ~BOPAlgo_ShrunkRange() {
48 }
49 //
50 void SetPaveBlock(const Handle(BOPDS_PaveBlock)& aPB) {
51 myPB=aPB;
52 }
53 //
54 Handle(BOPDS_PaveBlock)& PaveBlock() {
55 return myPB;
56 }
57 //
58 virtual void Perform() {
59 //
60 myWarningStatus=0;
61 //
1e143abb 62 IntTools_ShrunkRange::Perform();
505abfb8 63 if (myErrorStatus) {
64 myWarningStatus=1;
65 }
66 }
67 //
68 Standard_Integer WarningStatus() const {
69 return myWarningStatus;
70 }
71 //
72 protected:
73 Standard_Integer myWarningStatus;
74 Handle(BOPDS_PaveBlock) myPB;
75};
76//
77//=======================================================================
78typedef BOPCol_NCVector
79 <BOPAlgo_ShrunkRange> BOPAlgo_VectorOfShrunkRange;
80//
c7b59798 81typedef BOPCol_ContextFunctor
505abfb8 82 <BOPAlgo_ShrunkRange,
83 BOPAlgo_VectorOfShrunkRange,
1e143abb 84 Handle(IntTools_Context),
85 IntTools_Context> BOPAlgo_ShrunkRangeFunctor;
505abfb8 86//
c7b59798 87typedef BOPCol_ContextCnt
505abfb8 88 <BOPAlgo_ShrunkRangeFunctor,
89 BOPAlgo_VectorOfShrunkRange,
1e143abb 90 Handle(IntTools_Context)> BOPAlgo_ShrunkRangeCnt;
505abfb8 91//
92//=======================================================================
93// function: FillShrunkData
94// purpose:
95//=======================================================================
96void BOPAlgo_PaveFiller::FillShrunkData(const TopAbs_ShapeEnum aType1,
97 const TopAbs_ShapeEnum aType2)
98{
99 Standard_Integer iSize;
100
101 //
102 myErrorStatus=0;
103 //
104 myIterator->Initialize(aType1, aType2);
105 iSize=myIterator->ExpectedLength();
106 if (!iSize) {
107 return;
108 }
109 //
110 Standard_Boolean bJustAdd;
3510db62 111 Standard_Integer i, nS[2], nE, nV1, nV2, aNbVSD, k, iWrn;
505abfb8 112 Standard_Real aT1, aT2, aTS1, aTS2;
113 BOPDS_ListIteratorOfListOfPaveBlock aItLPB;
114 BOPCol_MapOfInteger aMI;
115 BOPAlgo_VectorOfShrunkRange aVSD;
3510db62 116 TopAbs_ShapeEnum aType[2] = { aType1, aType2 };
505abfb8 117 //
118 for (; myIterator->More(); myIterator->Next()) {
119 myIterator->Value(nS[0], nS[1], bJustAdd);
120 if(bJustAdd) {
121 continue;
122 }
123 //
3510db62 124 for (i=0; i < 2; ++i) {
505abfb8 125 nE=nS[i];
3510db62 126 if (aType[i] != TopAbs_EDGE || !aMI.Add(nE)) {
505abfb8 127 continue;
128 }
129 //
130 const BOPDS_ShapeInfo& aSIE=myDS->ShapeInfo(nE);
131 if (aSIE.HasFlag()){
132 continue;
133 }
134 //
135 BOPDS_ListOfPaveBlock& aLPB=myDS->ChangePaveBlocks(nE);
136 aItLPB.Initialize(aLPB);
137 for (; aItLPB.More(); aItLPB.Next()) {
138 const Handle(BOPDS_PaveBlock)& aPB=aItLPB.ChangeValue();
139 if (aPB->HasShrunkData()) {
140 continue;
141 }
142 //
143 // FillShrunkData(aPB);
144 aPB->Indices(nV1, nV2);
145 aPB->Range(aT1, aT2);
146 //
147 const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&aSIE.Shape()));
148 //
149 const TopoDS_Vertex& aV1=
150 (*(TopoDS_Vertex *)(&myDS->Shape(nV1)));
151 //
152 const TopoDS_Vertex& aV2=
153 (*(TopoDS_Vertex *)(&myDS->Shape(nV2)));
154 //
155 BOPAlgo_ShrunkRange& aSD=aVSD.Append1();
156 //
157 aSD.SetPaveBlock(aPB);
158 aSD.SetData(aE, aT1, aT2, aV1, aV2);
159 }
160 }
161 }
162 //
163 aNbVSD=aVSD.Extent();
164 //=============================================================
165 BOPAlgo_ShrunkRangeCnt::Perform(myRunParallel, aVSD, myContext);
166 //=============================================================
167 //
168 for (k=0; k < aNbVSD; ++k) {
169 BOPAlgo_ShrunkRange& aSD=aVSD(k);
170 iWrn=aSD.WarningStatus();
171 if (iWrn==1) {
172 continue;
173 }
174 //
175 Handle(BOPDS_PaveBlock)& aPB=aSD.PaveBlock();
176 aSD.ShrunkRange(aTS1, aTS2);
177 const Bnd_Box& aBox=aSD.BndBox();
178 //
179 aPB->SetShrunkData(aTS1, aTS2, aBox);
180 }
181}