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> |
42cf5bc1 |
19 | #include <BOPDS_Curve.hxx> |
20 | #include <BOPDS_DS.hxx> |
505abfb8 |
21 | #include <BOPDS_Iterator.hxx> |
22 | #include <BOPDS_ListOfPaveBlock.hxx> |
42cf5bc1 |
23 | #include <BOPDS_PaveBlock.hxx> |
24 | #include <BOPDS_ShapeInfo.hxx> |
1155d05a |
25 | #include <BOPTools_Parallel.hxx> |
42cf5bc1 |
26 | #include <gp_Pnt.hxx> |
27 | #include <IntTools_Context.hxx> |
1e143abb |
28 | #include <IntTools_ShrunkRange.hxx> |
1155d05a |
29 | #include <NCollection_Vector.hxx> |
30 | #include <TColStd_MapOfInteger.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 | //======================================================================= |
1155d05a |
66 | typedef NCollection_Vector |
505abfb8 |
67 | <BOPAlgo_ShrunkRange> BOPAlgo_VectorOfShrunkRange; |
68 | // |
1155d05a |
69 | typedef BOPTools_ContextFunctor |
505abfb8 |
70 | <BOPAlgo_ShrunkRange, |
71 | BOPAlgo_VectorOfShrunkRange, |
1e143abb |
72 | Handle(IntTools_Context), |
73 | IntTools_Context> BOPAlgo_ShrunkRangeFunctor; |
505abfb8 |
74 | // |
1155d05a |
75 | typedef BOPTools_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 | { |
505abfb8 |
87 | myIterator->Initialize(aType1, aType2); |
33ba8565 |
88 | Standard_Integer iSize = myIterator->ExpectedLength(); |
505abfb8 |
89 | if (!iSize) { |
90 | return; |
91 | } |
92 | // |
01b5b3df |
93 | Standard_Integer i, nS[2], nE, nV1, nV2, aNbVSD, k; |
33ba8565 |
94 | Standard_Real aT1, aT2; |
505abfb8 |
95 | BOPDS_ListIteratorOfListOfPaveBlock aItLPB; |
1155d05a |
96 | TColStd_MapOfInteger aMI; |
505abfb8 |
97 | BOPAlgo_VectorOfShrunkRange aVSD; |
3510db62 |
98 | TopAbs_ShapeEnum aType[2] = { aType1, aType2 }; |
505abfb8 |
99 | // |
100 | for (; myIterator->More(); myIterator->Next()) { |
25dfc507 |
101 | myIterator->Value(nS[0], nS[1]); |
505abfb8 |
102 | // |
3510db62 |
103 | for (i=0; i < 2; ++i) { |
505abfb8 |
104 | nE=nS[i]; |
3510db62 |
105 | if (aType[i] != TopAbs_EDGE || !aMI.Add(nE)) { |
505abfb8 |
106 | continue; |
107 | } |
108 | // |
109 | const BOPDS_ShapeInfo& aSIE=myDS->ShapeInfo(nE); |
110 | if (aSIE.HasFlag()){ |
111 | continue; |
112 | } |
113 | // |
114 | BOPDS_ListOfPaveBlock& aLPB=myDS->ChangePaveBlocks(nE); |
115 | aItLPB.Initialize(aLPB); |
116 | for (; aItLPB.More(); aItLPB.Next()) { |
117 | const Handle(BOPDS_PaveBlock)& aPB=aItLPB.ChangeValue(); |
8ae442a8 |
118 | if (aPB->HasShrunkData() && myDS->IsValidShrunkData(aPB)) { |
505abfb8 |
119 | continue; |
120 | } |
121 | // |
122 | // FillShrunkData(aPB); |
123 | aPB->Indices(nV1, nV2); |
124 | aPB->Range(aT1, aT2); |
125 | // |
126 | const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&aSIE.Shape())); |
127 | // |
128 | const TopoDS_Vertex& aV1= |
129 | (*(TopoDS_Vertex *)(&myDS->Shape(nV1))); |
130 | // |
131 | const TopoDS_Vertex& aV2= |
132 | (*(TopoDS_Vertex *)(&myDS->Shape(nV2))); |
133 | // |
1155d05a |
134 | BOPAlgo_ShrunkRange& aSD=aVSD.Appended(); |
505abfb8 |
135 | // |
136 | aSD.SetPaveBlock(aPB); |
137 | aSD.SetData(aE, aT1, aT2, aV1, aV2); |
138 | } |
139 | } |
140 | } |
141 | // |
1155d05a |
142 | aNbVSD=aVSD.Length(); |
505abfb8 |
143 | //============================================================= |
144 | BOPAlgo_ShrunkRangeCnt::Perform(myRunParallel, aVSD, myContext); |
145 | //============================================================= |
146 | // |
147 | for (k=0; k < aNbVSD; ++k) { |
33ba8565 |
148 | BOPAlgo_ShrunkRange& aSD = aVSD(k); |
149 | AnalyzeShrunkData(aSD.PaveBlock(), aSD); |
505abfb8 |
150 | } |
151 | } |