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 |
40 | class BOPAlgo_ShrunkRange : public IntTools_ShrunkRange { |
505abfb8 |
41 | public: |
42 | BOPAlgo_ShrunkRange() |
01b5b3df |
43 | : IntTools_ShrunkRange() { |
505abfb8 |
44 | } |
45 | // |
46 | virtual ~BOPAlgo_ShrunkRange() { |
47 | } |
48 | // |
49 | void SetPaveBlock(const Handle(BOPDS_PaveBlock)& aPB) { |
50 | myPB=aPB; |
51 | } |
52 | // |
53 | Handle(BOPDS_PaveBlock)& PaveBlock() { |
54 | return myPB; |
55 | } |
56 | // |
57 | virtual void Perform() { |
1e143abb |
58 | IntTools_ShrunkRange::Perform(); |
0d0481c7 |
59 | } |
505abfb8 |
60 | // |
61 | protected: |
505abfb8 |
62 | Handle(BOPDS_PaveBlock) myPB; |
63 | }; |
64 | // |
65 | //======================================================================= |
66 | typedef BOPCol_NCVector |
67 | <BOPAlgo_ShrunkRange> BOPAlgo_VectorOfShrunkRange; |
68 | // |
c7b59798 |
69 | typedef BOPCol_ContextFunctor |
505abfb8 |
70 | <BOPAlgo_ShrunkRange, |
71 | BOPAlgo_VectorOfShrunkRange, |
1e143abb |
72 | Handle(IntTools_Context), |
73 | IntTools_Context> BOPAlgo_ShrunkRangeFunctor; |
505abfb8 |
74 | // |
c7b59798 |
75 | typedef BOPCol_ContextCnt |
505abfb8 |
76 | <BOPAlgo_ShrunkRangeFunctor, |
77 | BOPAlgo_VectorOfShrunkRange, |
1e143abb |
78 | Handle(IntTools_Context)> BOPAlgo_ShrunkRangeCnt; |
505abfb8 |
79 | // |
80 | //======================================================================= |
81 | // function: FillShrunkData |
82 | // purpose: |
83 | //======================================================================= |
84 | void BOPAlgo_PaveFiller::FillShrunkData(const TopAbs_ShapeEnum aType1, |
85 | const TopAbs_ShapeEnum aType2) |
86 | { |
87 | Standard_Integer iSize; |
88 | |
89 | // |
90 | myErrorStatus=0; |
91 | // |
92 | myIterator->Initialize(aType1, aType2); |
93 | iSize=myIterator->ExpectedLength(); |
94 | if (!iSize) { |
95 | return; |
96 | } |
97 | // |
01b5b3df |
98 | Standard_Integer i, nS[2], nE, nV1, nV2, aNbVSD, k; |
505abfb8 |
99 | Standard_Real aT1, aT2, aTS1, aTS2; |
100 | BOPDS_ListIteratorOfListOfPaveBlock aItLPB; |
101 | BOPCol_MapOfInteger aMI; |
102 | BOPAlgo_VectorOfShrunkRange aVSD; |
3510db62 |
103 | TopAbs_ShapeEnum aType[2] = { aType1, aType2 }; |
505abfb8 |
104 | // |
105 | for (; myIterator->More(); myIterator->Next()) { |
25dfc507 |
106 | myIterator->Value(nS[0], nS[1]); |
505abfb8 |
107 | // |
3510db62 |
108 | for (i=0; i < 2; ++i) { |
505abfb8 |
109 | nE=nS[i]; |
3510db62 |
110 | if (aType[i] != TopAbs_EDGE || !aMI.Add(nE)) { |
505abfb8 |
111 | continue; |
112 | } |
113 | // |
114 | const BOPDS_ShapeInfo& aSIE=myDS->ShapeInfo(nE); |
115 | if (aSIE.HasFlag()){ |
116 | continue; |
117 | } |
118 | // |
119 | BOPDS_ListOfPaveBlock& aLPB=myDS->ChangePaveBlocks(nE); |
120 | aItLPB.Initialize(aLPB); |
121 | for (; aItLPB.More(); aItLPB.Next()) { |
122 | const Handle(BOPDS_PaveBlock)& aPB=aItLPB.ChangeValue(); |
8ae442a8 |
123 | if (aPB->HasShrunkData() && myDS->IsValidShrunkData(aPB)) { |
505abfb8 |
124 | continue; |
125 | } |
126 | // |
127 | // FillShrunkData(aPB); |
128 | aPB->Indices(nV1, nV2); |
129 | aPB->Range(aT1, aT2); |
130 | // |
131 | const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&aSIE.Shape())); |
132 | // |
133 | const TopoDS_Vertex& aV1= |
134 | (*(TopoDS_Vertex *)(&myDS->Shape(nV1))); |
135 | // |
136 | const TopoDS_Vertex& aV2= |
137 | (*(TopoDS_Vertex *)(&myDS->Shape(nV2))); |
138 | // |
139 | BOPAlgo_ShrunkRange& aSD=aVSD.Append1(); |
140 | // |
141 | aSD.SetPaveBlock(aPB); |
142 | aSD.SetData(aE, aT1, aT2, aV1, aV2); |
143 | } |
144 | } |
145 | } |
146 | // |
147 | aNbVSD=aVSD.Extent(); |
148 | //============================================================= |
149 | BOPAlgo_ShrunkRangeCnt::Perform(myRunParallel, aVSD, myContext); |
150 | //============================================================= |
151 | // |
0d0481c7 |
152 | Standard_Real aFuzz = myFuzzyValue / 2.; |
505abfb8 |
153 | for (k=0; k < aNbVSD; ++k) { |
154 | BOPAlgo_ShrunkRange& aSD=aVSD(k); |
01b5b3df |
155 | if (!aSD.IsDone()) { |
505abfb8 |
156 | continue; |
157 | } |
158 | // |
159 | Handle(BOPDS_PaveBlock)& aPB=aSD.PaveBlock(); |
160 | aSD.ShrunkRange(aTS1, aTS2); |
0d0481c7 |
161 | Bnd_Box aBox=aSD.BndBox(); |
162 | aBox.SetGap(aBox.GetGap() + aFuzz); |
01b5b3df |
163 | Standard_Boolean bIsSplittable = aSD.IsSplittable(); |
505abfb8 |
164 | // |
01b5b3df |
165 | aPB->SetShrunkData(aTS1, aTS2, aBox, bIsSplittable); |
505abfb8 |
166 | } |
167 | } |