Commit | Line | Data |
---|---|---|
b311480e | 1 | // Copyright (c) 1995-1999 Matra Datavision |
973c2be1 | 2 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e | 3 | // |
973c2be1 | 4 | // This file is part of Open CASCADE Technology software library. |
b311480e | 5 | // |
d5f74e42 | 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 | |
973c2be1 | 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. | |
b311480e | 11 | // |
973c2be1 | 12 | // Alternatively, this file may be used under the terms of Open CASCADE |
13 | // commercial license or contractual agreement. | |
b311480e | 14 | |
7fd59977 | 15 | #ifdef CHRONO |
16 | #include <OSD_Chronometer.hxx> | |
17 | OSD_Chronometer Chronrsnld; | |
18 | ||
19 | #endif | |
20 | ||
96a85238 | 21 | #include <NCollection_IncAllocator.hxx> |
7fd59977 | 22 | #include <Precision.hxx> |
23 | ||
24 | IntWalk_IWalking::IntWalk_IWalking (const Standard_Real Epsilon, | |
25 | const Standard_Real Deflection, | |
26 | const Standard_Real Increment ) : | |
27 | done(Standard_False), | |
28 | fleche(Deflection), | |
29 | pas(Increment), | |
30 | tolerance(1,2), | |
1ef32e96 | 31 | epsilon(Epsilon*Epsilon), |
96a85238 RL |
32 | wd1 (IntWalk_VectorOfWalkingData::allocator_type (new NCollection_IncAllocator)), |
33 | wd2 (wd1.get_allocator()), | |
b92f3572 | 34 | nbMultiplicities (wd1.get_allocator()) |
7fd59977 | 35 | { |
36 | } | |
37 | ||
96a85238 RL |
38 | |
39 | //======================================================================= | |
40 | //function : Reset | |
41 | //purpose : Clears NCollection_Vector-based containers and adds | |
42 | // dummy data to maintain start index of 1 and consistent with | |
43 | // previous TCollection_Sequence-based implementation and other | |
44 | // used TCollection-based containers | |
45 | //======================================================================= | |
46 | ||
47 | void IntWalk_IWalking::Clear() | |
48 | { | |
49 | wd1.clear(); | |
50 | wd2.clear(); | |
51 | IntWalk_WalkingData aDummy; | |
52 | aDummy.etat = -10; | |
53 | aDummy.ustart = aDummy.vstart = 0.; | |
54 | wd1.push_back (aDummy); | |
55 | wd2.push_back (aDummy); | |
56 | nbMultiplicities.clear(); | |
57 | nbMultiplicities.push_back (-1); | |
58 | ||
59 | done = Standard_False; | |
60 | seqAjout.Clear(); | |
61 | lines.Clear(); | |
62 | } | |
7fd59977 | 63 | |
64 | // *************************************************************************** | |
b1c5c4e6 | 65 | // etat1=12 not tangent, not passes |
66 | // etat1=11 tangent, not passes | |
67 | // etat1=2 not tangent, passes | |
68 | // etat1=1 tangent, passes | |
69 | // after a point is processed its state becomes negative. | |
7fd59977 | 70 | // *************************************************************************** |
b1c5c4e6 | 71 | // etat2=13 interior start point on closed line |
72 | // etat2=12 interior start point on open line | |
73 | // (line initially closed -> la line s is open) | |
74 | // after a point is processed (or if it is passed over during | |
75 | // routing) its state becomes negative. | |
7fd59977 | 76 | // **************************************************************************** |
77 | ||
78 | // | |
b1c5c4e6 | 79 | // Perform with interior points |
7fd59977 | 80 | // |
81 | void IntWalk_IWalking::Perform(const ThePOPIterator& Pnts1, | |
82 | const ThePOLIterator& Pnts2, | |
83 | TheIWFunction& Func, | |
84 | const ThePSurface& Caro, | |
85 | const Standard_Boolean Reversed) | |
86 | ||
87 | { | |
88 | ||
89 | Standard_Integer I; | |
7fd59977 | 90 | Standard_Boolean Rajout = Standard_False; |
91 | Standard_Integer nbPnts1 = Pnts1.Length(); | |
92 | Standard_Integer nbPnts2 = Pnts2.Length(); | |
93 | Standard_Real U,V; | |
94 | ||
96a85238 | 95 | Clear(); |
7fd59977 | 96 | reversed = Reversed; |
97 | ||
98 | ||
b1c5c4e6 | 99 | // Loading of etat1 and etat2 as well as ustart and vstart. |
7fd59977 | 100 | |
101 | TColStd_SequenceOfReal Umult; | |
102 | TColStd_SequenceOfReal Vmult; | |
103 | ||
104 | Standard_Integer decal=0; | |
96a85238 RL |
105 | wd1.reserve (nbPnts1+decal); |
106 | nbMultiplicities.reserve (nbPnts1+decal); | |
7fd59977 | 107 | for (I=1;I <= nbPnts1+decal; I++) { |
96a85238 RL |
108 | const ThePointOfPath& PathPnt = Pnts1.Value(I-decal); |
109 | IntWalk_WalkingData aWD1; | |
110 | aWD1.etat = 1; | |
7fd59977 | 111 | if (!ThePointOfPathTool::IsPassingPnt(PathPnt)) |
96a85238 | 112 | aWD1.etat = 11; |
7fd59977 | 113 | if (!ThePointOfPathTool::IsTangent(PathPnt)) |
96a85238 RL |
114 | ++aWD1.etat; |
115 | ||
b1c5c4e6 | 116 | if(aWD1.etat==2) { |
96a85238 RL |
117 | aWD1.etat=11; |
118 | } | |
119 | ||
120 | ThePointOfPathTool::Value2d(PathPnt, aWD1.ustart, aWD1.vstart); | |
121 | wd1.push_back (aWD1); | |
122 | Standard_Integer aNbMult = ThePointOfPathTool::Multiplicity(PathPnt); | |
123 | nbMultiplicities.push_back(aNbMult); | |
124 | ||
125 | for (Standard_Integer J = 1; J <= aNbMult; J++) { | |
126 | ThePointOfPathTool::Parameters(PathPnt, J, U, V); | |
127 | Umult.Append(U); | |
128 | Vmult.Append(V); | |
7fd59977 | 129 | } |
130 | } | |
131 | ||
96a85238 | 132 | wd2.reserve (nbPnts2); |
7fd59977 | 133 | for (I = 1; I <= nbPnts2; I++) { |
96a85238 RL |
134 | IntWalk_WalkingData aWD2; |
135 | aWD2.etat = 13; | |
136 | ThePointOfLoopTool::Value2d(Pnts2.Value(I), aWD2.ustart, aWD2.vstart); | |
137 | wd2.push_back (aWD2); | |
7fd59977 | 138 | } |
139 | ||
140 | tolerance(1) = ThePSurfaceTool::UResolution(Caro,Precision::Confusion()); | |
141 | tolerance(2) = ThePSurfaceTool::VResolution(Caro,Precision::Confusion()); | |
142 | ||
143 | Um = ThePSurfaceTool::FirstUParameter(Caro); | |
144 | Vm = ThePSurfaceTool::FirstVParameter(Caro); | |
145 | UM = ThePSurfaceTool::LastUParameter(Caro); | |
146 | VM = ThePSurfaceTool::LastVParameter(Caro); | |
147 | ||
148 | if (UM < Um) { | |
149 | Standard_Real utemp = UM; | |
150 | UM = Um; | |
151 | Um = utemp; | |
152 | } | |
153 | if (VM < Vm) { | |
154 | Standard_Real vtemp = VM; | |
155 | VM = Vm; | |
156 | Vm = vtemp; | |
157 | } | |
158 | ||
159 | Func.Set(Caro); | |
160 | ||
b1c5c4e6 | 161 | // calculation of all open lines |
b92f3572 | 162 | if (nbPnts1 != 0) |
163 | ComputeOpenLine(Umult,Vmult,Pnts1,Func,Rajout); | |
164 | ||
b1c5c4e6 | 165 | // calculation of all closed lines |
b92f3572 | 166 | if (nbPnts2 != 0) |
167 | ComputeCloseLine(Umult,Vmult,Pnts1,Pnts2,Func,Rajout); | |
168 | ||
7fd59977 | 169 | for (I = 1; I <= nbPnts1; I++) { |
96a85238 | 170 | if (wd1[I].etat >0) seqSingle.Append(Pnts1(I)); |
7fd59977 | 171 | } |
172 | done = Standard_True; | |
173 | } | |
174 | ||
175 | ||
176 | ||
177 | // | |
b1c5c4e6 | 178 | // Perform without interior point |
7fd59977 | 179 | // |
180 | ||
181 | void IntWalk_IWalking::Perform(const ThePOPIterator& Pnts1, | |
182 | TheIWFunction& Func, | |
183 | const ThePSurface& Caro, | |
184 | const Standard_Boolean Reversed) | |
185 | ||
186 | { | |
187 | Standard_Integer I; | |
7fd59977 | 188 | Standard_Boolean Rajout = Standard_False; |
189 | Standard_Integer nbPnts1 = Pnts1.Length(); | |
190 | Standard_Real U,V; | |
191 | ||
7fd59977 | 192 | reversed = Reversed; |
193 | ||
194 | ||
b1c5c4e6 | 195 | // Loading of etat1 as well as ustart1 and vstart1. |
7fd59977 | 196 | |
197 | TColStd_SequenceOfReal Umult; | |
198 | TColStd_SequenceOfReal Vmult; | |
199 | ||
96a85238 | 200 | wd1.reserve (nbPnts1); |
7fd59977 | 201 | for (I=1;I <= nbPnts1; I++) { |
96a85238 RL |
202 | const ThePointOfPath& PathPnt = Pnts1.Value(I); |
203 | IntWalk_WalkingData aWD1; | |
204 | aWD1.etat = 1; | |
205 | if (!ThePointOfPathTool::IsPassingPnt(PathPnt)) aWD1.etat = 11; | |
206 | if (!ThePointOfPathTool::IsTangent(PathPnt)) ++aWD1.etat; | |
207 | ThePointOfPathTool::Value2d(PathPnt, aWD1.ustart, aWD1.vstart); | |
208 | wd1.push_back (aWD1); | |
209 | Standard_Integer aNbMult = ThePointOfPathTool::Multiplicity(PathPnt); | |
210 | nbMultiplicities.push_back(aNbMult); | |
211 | ||
212 | for (Standard_Integer J = 1; J <= aNbMult; J++) { | |
213 | ThePointOfPathTool::Parameters(PathPnt, J, U, V); | |
7fd59977 | 214 | Umult.Append(U); |
215 | Vmult.Append(V); | |
216 | } | |
217 | } | |
218 | ||
219 | tolerance(1) = ThePSurfaceTool::UResolution(Caro,Precision::Confusion()); | |
220 | tolerance(2) = ThePSurfaceTool::VResolution(Caro,Precision::Confusion()); | |
221 | ||
222 | Um = ThePSurfaceTool::FirstUParameter(Caro); | |
223 | Vm = ThePSurfaceTool::FirstVParameter(Caro); | |
224 | UM = ThePSurfaceTool::LastUParameter(Caro); | |
225 | VM = ThePSurfaceTool::LastVParameter(Caro); | |
226 | ||
227 | if (UM < Um) { | |
228 | Standard_Real utemp = UM; | |
229 | UM = Um; | |
230 | Um = utemp; | |
231 | } | |
232 | if (VM < Vm) { | |
233 | Standard_Real vtemp = VM; | |
234 | VM = Vm; | |
235 | Vm = vtemp; | |
236 | } | |
237 | ||
238 | Func.Set(Caro); | |
239 | ||
240 | // calcul de toutes les lignes ouvertes | |
241 | if (nbPnts1 != 0) ComputeOpenLine(Umult,Vmult,Pnts1,Func,Rajout); | |
242 | ||
243 | for (I = 1; I <= nbPnts1; I++) { | |
96a85238 | 244 | if (wd1[I].etat >0) seqSingle.Append(Pnts1(I)); |
7fd59977 | 245 | } |
246 | done = Standard_True; | |
247 | } | |
248 | ||
249 | ||
250 |