Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 1995-04-20 |
2 | // Created by: Bruno DUMORTIER | |
3 | // Copyright (c) 1995-1999 Matra Datavision | |
973c2be1 | 4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e | 5 | // |
973c2be1 | 6 | // This file is part of Open CASCADE Technology software library. |
b311480e | 7 | // |
d5f74e42 | 8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published | |
973c2be1 | 10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT | |
12 | // distribution for complete text of the license and disclaimer of any warranty. | |
b311480e | 13 | // |
973c2be1 | 14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. | |
7fd59977 | 16 | |
17 | // Modified by skv - Fri Jul 8 11:21:38 2005 OCC9145 | |
18 | ||
42cf5bc1 | 19 | #include <Adaptor3d_Curve.hxx> |
5201d3e6 | 20 | #include <Adaptor2d_OffsetCurve.hxx> |
42cf5bc1 | 21 | #include <Bisector_Bisec.hxx> |
22 | #include <BRep_Builder.hxx> | |
23 | #include <BRep_CurveRepresentation.hxx> | |
24 | #include <BRep_GCurve.hxx> | |
25 | #include <BRep_TEdge.hxx> | |
26 | #include <BRep_Tool.hxx> | |
27 | #include <BRep_TVertex.hxx> | |
7fd59977 | 28 | #include <BRepAdaptor_Curve.hxx> |
29 | #include <BRepAdaptor_Surface.hxx> | |
7fd59977 | 30 | #include <BRepFill_DataMapOfNodeShape.hxx> |
42cf5bc1 | 31 | #include <BRepFill_DataMapOfOrientedShapeListOfShape.hxx> |
7fd59977 | 32 | #include <BRepFill_DataMapOfShapeSequenceOfPnt.hxx> |
42cf5bc1 | 33 | #include <BRepFill_DataMapOfShapeSequenceOfReal.hxx> |
34 | #include <BRepFill_OffsetWire.hxx> | |
7fd59977 | 35 | #include <BRepFill_TrimEdgeTool.hxx> |
36 | #include <BRepLib.hxx> | |
42cf5bc1 | 37 | #include <BRepLib_MakeEdge.hxx> |
7fd59977 | 38 | #include <BRepLib_MakeFace.hxx> |
42cf5bc1 | 39 | #include <BRepLib_MakeVertex.hxx> |
7fd59977 | 40 | #include <BRepLib_MakeWire.hxx> |
42cf5bc1 | 41 | #include <BRepMAT2d_BisectingLocus.hxx> |
42 | #include <BRepMAT2d_Explorer.hxx> | |
43 | #include <BRepMAT2d_LinkTopoBilo.hxx> | |
7fd59977 | 44 | #include <BRepTools.hxx> |
42cf5bc1 | 45 | #include <BRepTools_Substitution.hxx> |
7fd59977 | 46 | #include <BRepTools_WireExplorer.hxx> |
42cf5bc1 | 47 | #include <Geom2d_BSplineCurve.hxx> |
7fd59977 | 48 | #include <Geom2d_Circle.hxx> |
42cf5bc1 | 49 | #include <Geom2d_Curve.hxx> |
7fd59977 | 50 | #include <Geom2d_Line.hxx> |
7fd59977 | 51 | #include <Geom2d_OffsetCurve.hxx> |
42cf5bc1 | 52 | #include <Geom2d_TrimmedCurve.hxx> |
53 | #include <Geom2dAdaptor_Curve.hxx> | |
54 | #include <Geom2dAdaptor_HCurve.hxx> | |
55 | #include <Geom2dConvert_CompCurveToBSplineCurve.hxx> | |
56 | #include <Geom2dLProp_CLProps2d.hxx> | |
7fd59977 | 57 | #include <Geom_Circle.hxx> |
6a442250 | 58 | #include <Geom_Line.hxx> |
7fd59977 | 59 | #include <Geom_OffsetCurve.hxx> |
42cf5bc1 | 60 | #include <Geom_Plane.hxx> |
61 | #include <Geom_Surface.hxx> | |
62 | #include <Geom_TrimmedCurve.hxx> | |
63 | #include <GeomAPI.hxx> | |
64 | #include <gp.hxx> | |
65 | #include <gp_Ax2.hxx> | |
66 | #include <gp_Dir2d.hxx> | |
67 | #include <gp_Pln.hxx> | |
68 | #include <gp_Vec.hxx> | |
69 | #include <MAT2d_CutCurve.hxx> | |
7fd59977 | 70 | #include <MAT_Arc.hxx> |
7fd59977 | 71 | #include <MAT_Graph.hxx> |
42cf5bc1 | 72 | #include <MAT_Node.hxx> |
7fd59977 | 73 | #include <Precision.hxx> |
42cf5bc1 | 74 | #include <Standard_ConstructionError.hxx> |
75 | #include <Standard_ErrorHandler.hxx> | |
76 | #include <Standard_NoSuchObject.hxx> | |
7fd59977 | 77 | #include <Standard_NotImplemented.hxx> |
42cf5bc1 | 78 | #include <TColgp_Array1OfPnt2d.hxx> |
7fd59977 | 79 | #include <TColgp_SequenceOfPnt.hxx> |
42cf5bc1 | 80 | #include <TColStd_Array1OfInteger.hxx> |
81 | #include <TColStd_Array1OfReal.hxx> | |
82 | #include <TColStd_SequenceOfReal.hxx> | |
83 | #include <TopAbs.hxx> | |
7fd59977 | 84 | #include <TopExp.hxx> |
85 | #include <TopExp_Explorer.hxx> | |
86 | #include <TopoDS.hxx> | |
7fd59977 | 87 | #include <TopoDS_Compound.hxx> |
42cf5bc1 | 88 | #include <TopoDS_Face.hxx> |
7fd59977 | 89 | #include <TopoDS_Iterator.hxx> |
42cf5bc1 | 90 | #include <TopoDS_Shape.hxx> |
91 | #include <TopoDS_Wire.hxx> | |
7fd59977 | 92 | #include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx> |
93 | #include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx> | |
42cf5bc1 | 94 | #include <TopTools_DataMapOfShapeListOfShape.hxx> |
7fd59977 | 95 | #include <TopTools_DataMapOfShapeSequenceOfShape.hxx> |
42cf5bc1 | 96 | #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx> |
7fd59977 | 97 | #include <TopTools_IndexedMapOfShape.hxx> |
42cf5bc1 | 98 | #include <TopTools_ListIteratorOfListOfShape.hxx> |
99 | #include <TopTools_ListOfShape.hxx> | |
100 | #include <TopTools_MapIteratorOfMapOfShape.hxx> | |
101 | #include <TopTools_MapOfShape.hxx> | |
102 | #include <TopTools_SequenceOfShape.hxx> | |
103 | ||
104 | #include <stdio.h> | |
873c119f | 105 | #ifdef OCCT_DEBUG |
106 | //#define DRAW | |
7fd59977 | 107 | #ifdef DRAW |
108 | #include <Draw.hxx> | |
109 | #include <DrawTrSurf.hxx> | |
110 | #include <DrawTrSurf_Curve2d.hxx> | |
111 | #include <DBRep.hxx> | |
ec357c5c | 112 | #include <Geom_Curve.hxx> |
7fd59977 | 113 | static Standard_Boolean AffichGeom = Standard_False; |
114 | static Standard_Boolean Affich2d = Standard_False; | |
115 | static Standard_Boolean AffichEdge = Standard_False; | |
116 | static Standard_Integer NbTRIMEDGES = 0; | |
117 | static Standard_Integer NbOFFSET = 0; | |
118 | static Standard_Integer NbEDGES = 0; | |
119 | static Standard_Integer NbBISSEC = 0; | |
7fd59977 | 120 | #endif |
873c119f | 121 | #endif |
7fd59977 | 122 | |
123 | // Modified by Sergey KHROMOV - Thu Nov 16 17:24:39 2000 Begin | |
124 | ||
125 | static void QuasiFleche(const Adaptor3d_Curve& C, | |
873c119f | 126 | const Standard_Real Deflection2, |
127 | const Standard_Real Udeb, | |
128 | const gp_Pnt& Pdeb, | |
129 | const gp_Vec& Vdeb, | |
130 | const Standard_Real Ufin, | |
131 | const gp_Pnt& Pfin, | |
132 | const gp_Vec& Vfin, | |
133 | const Standard_Integer Nbmin, | |
134 | const Standard_Real Eps, | |
135 | TColStd_SequenceOfReal& Parameters, | |
136 | TColgp_SequenceOfPnt& Points); | |
7fd59977 | 137 | |
138 | static Standard_Boolean PerformCurve (TColStd_SequenceOfReal& Parameters, | |
873c119f | 139 | TColgp_SequenceOfPnt& Points, |
140 | const Adaptor3d_Curve& C, | |
141 | const Standard_Real Deflection, | |
142 | const Standard_Real U1, | |
143 | const Standard_Real U2, | |
144 | const Standard_Real EPSILON, | |
145 | const Standard_Integer Nbmin); | |
7fd59977 | 146 | |
147 | static void CheckBadEdges(const TopoDS_Face& Spine, const Standard_Real Offset, | |
873c119f | 148 | const BRepMAT2d_BisectingLocus& Locus, |
149 | const BRepMAT2d_LinkTopoBilo& Link, | |
150 | TopTools_ListOfShape& BadEdges); | |
7fd59977 | 151 | |
152 | static Standard_Integer CutEdge (const TopoDS_Edge& E, | |
873c119f | 153 | const TopoDS_Face& F, |
154 | Standard_Integer ForceCut, | |
155 | TopTools_ListOfShape& Cuts); | |
7fd59977 | 156 | |
157 | ||
158 | static void CutCurve (const Handle(Geom2d_TrimmedCurve)& C, | |
873c119f | 159 | const Standard_Integer nbParts, |
160 | TColGeom2d_SequenceOfCurve& theCurves); | |
7fd59977 | 161 | // Modified by Sergey KHROMOV - Thu Nov 16 17:24:47 2000 End |
162 | ||
163 | ||
164 | static void EdgeVertices (const TopoDS_Edge& E, | |
873c119f | 165 | TopoDS_Vertex& V1, |
166 | TopoDS_Vertex& V2) | |
7fd59977 | 167 | { |
168 | if (E.Orientation() == TopAbs_REVERSED) { | |
169 | TopExp::Vertices(E,V2,V1); | |
170 | } | |
171 | else { | |
172 | TopExp::Vertices(E,V1,V2); | |
173 | } | |
174 | } | |
7fd59977 | 175 | static Standard_Boolean VertexFromNode |
873c119f | 176 | (const Handle(MAT_Node)& aNode, |
177 | const Standard_Real Offset, | |
178 | gp_Pnt2d& PN, | |
179 | BRepFill_DataMapOfNodeShape& MapNodeVertex, | |
180 | TopoDS_Vertex& VN); | |
7fd59977 | 181 | |
182 | static void StoreInMap (const TopoDS_Shape& V1, | |
873c119f | 183 | const TopoDS_Shape& V2, |
184 | TopTools_IndexedDataMapOfShapeShape& MapVV); | |
7fd59977 | 185 | |
186 | static void TrimEdge (const TopoDS_Edge& CurrentEdge, | |
e11c1bc4 | 187 | const TopoDS_Shape& CurrentSpine, |
188 | const TopoDS_Face& AllSpine, | |
873c119f | 189 | const TopTools_ListOfShape& D, |
6a442250 | 190 | TopTools_SequenceOfShape& Sv, |
191 | TColStd_SequenceOfReal& MapverPar, | |
192 | TopTools_SequenceOfShape& S, | |
193 | TopTools_IndexedDataMapOfShapeShape& MapVV, | |
194 | const Standard_Integer IndOfE); | |
7fd59977 | 195 | |
e11c1bc4 | 196 | static Standard_Boolean IsInnerEdge(const TopoDS_Shape& ProE, |
197 | const TopoDS_Face& AllSpine, | |
198 | Standard_Real& TrPar1, | |
199 | Standard_Real& TrPar2); | |
200 | ||
7fd59977 | 201 | static Standard_Boolean DoubleOrNotInside (const TopTools_ListOfShape& EC, |
873c119f | 202 | const TopoDS_Vertex& V); |
7fd59977 | 203 | |
204 | static Standard_Boolean IsSmallClosedEdge(const TopoDS_Edge& anEdge, | |
873c119f | 205 | const TopoDS_Vertex& aVertex); |
7fd59977 | 206 | |
207 | static void MakeCircle | |
873c119f | 208 | (const TopoDS_Edge& E, |
209 | const TopoDS_Vertex& V, | |
210 | const TopoDS_Face& F, | |
211 | const Standard_Real Offset, | |
212 | BRepFill_IndexedDataMapOfOrientedShapeListOfShape& Map, | |
213 | const Handle(Geom_Plane)& RefPlane); | |
7fd59977 | 214 | |
215 | static void MakeOffset | |
873c119f | 216 | (const TopoDS_Edge& E, |
217 | const TopoDS_Face& F, | |
218 | const Standard_Real Offset, | |
219 | BRepFill_IndexedDataMapOfOrientedShapeListOfShape& Map, | |
220 | const Handle(Geom_Plane)& RefPlane, | |
221 | const Standard_Boolean IsOpenResult, | |
c7806cb6 | 222 | const GeomAbs_JoinType theJoinType, |
873c119f | 223 | const TopoDS_Vertex * Ends); |
7fd59977 | 224 | |
7642e2d0 | 225 | Standard_Boolean CheckSmallParamOnEdge(const TopoDS_Edge& anEdge); |
226 | ||
7fd59977 | 227 | //======================================================================= |
228 | //function : KPartCircle | |
229 | //purpose : | |
230 | //======================================================================= | |
231 | ||
232 | static Standard_Boolean KPartCircle | |
873c119f | 233 | (const TopoDS_Face& mySpine, |
234 | const Standard_Real myOffset, | |
235 | const Standard_Boolean IsOpenResult, | |
236 | const Standard_Real Alt, | |
237 | TopoDS_Shape& myShape, | |
238 | BRepFill_IndexedDataMapOfOrientedShapeListOfShape& myMap, | |
239 | Standard_Boolean& myIsDone) | |
7fd59977 | 240 | { |
7fd59977 | 241 | TopExp_Explorer exp(mySpine,TopAbs_EDGE); |
242 | Standard_Integer NbEdges = 0; | |
243 | TopoDS_Edge E; | |
244 | ||
245 | for (; exp.More(); exp.Next()) { | |
246 | NbEdges++; | |
247 | E = TopoDS::Edge(exp.Current()); | |
248 | if (NbEdges > 1) return Standard_False; | |
249 | } | |
7fd59977 | 250 | |
251 | Standard_Real f,l; | |
252 | TopLoc_Location L; | |
253 | Handle(Geom_Curve) C = BRep_Tool::Curve(E,L,f,l); | |
254 | ||
255 | if (C->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) { | |
256 | Handle(Geom_TrimmedCurve) Ct = Handle(Geom_TrimmedCurve)::DownCast(C); | |
257 | C = Ct->BasisCurve(); | |
258 | } | |
259 | ||
da72a17c | 260 | if ((C->IsKind(STANDARD_TYPE(Geom_Circle)) && BRep_Tool::IsClosed(E)) || //closed circle |
e11c1bc4 | 261 | IsOpenResult) |
6a442250 | 262 | { |
6a442250 | 263 | Standard_Real anOffset = myOffset; |
6a442250 | 264 | |
0e0f7a7c | 265 | Handle(Geom2d_Curve) aPCurve = BRep_Tool::CurveOnSurface(E, mySpine, f, l); |
6a442250 | 266 | Handle(Geom2dAdaptor_HCurve) AHC = new Geom2dAdaptor_HCurve(aPCurve, f, l); |
0e0f7a7c | 267 | Handle(Geom2d_Curve) OC; |
268 | if (AHC->GetType() == GeomAbs_Line) | |
269 | { | |
ef237d73 | 270 | if (E.Orientation() == TopAbs_REVERSED) |
271 | anOffset *= -1; | |
5201d3e6 | 272 | Adaptor2d_OffsetCurve Off(AHC,anOffset); |
0e0f7a7c | 273 | OC = new Geom2d_Line(Off.Line()); |
274 | } | |
275 | else if (AHC->GetType() == GeomAbs_Circle) | |
276 | { | |
ef237d73 | 277 | if (E.Orientation() == TopAbs_FORWARD) |
278 | anOffset *= -1; | |
0e0f7a7c | 279 | gp_Circ2d theCirc = AHC->Circle(); |
c7806cb6 | 280 | if (anOffset > 0. || Abs(anOffset) < theCirc.Radius()) |
281 | OC = new Geom2d_Circle (theCirc.Position(), theCirc.Radius() + anOffset); | |
282 | else | |
283 | { | |
284 | myIsDone = Standard_False; | |
285 | return Standard_False; | |
873c119f | 286 | } |
0e0f7a7c | 287 | } |
288 | else | |
289 | { | |
ef237d73 | 290 | if (E.Orientation() == TopAbs_FORWARD) |
291 | anOffset *= -1; | |
0e0f7a7c | 292 | Handle(Geom2d_TrimmedCurve) G2dT = new Geom2d_TrimmedCurve(aPCurve, f, l); |
293 | OC = new Geom2d_OffsetCurve( G2dT, anOffset); | |
294 | } | |
295 | Handle(Geom_Surface) aSurf = BRep_Tool::Surface(mySpine); | |
6a442250 | 296 | Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast(aSurf); |
0e0f7a7c | 297 | myShape = BRepLib_MakeEdge(OC, aPlane, f, l); |
6a442250 | 298 | BRepLib::BuildCurve3d(TopoDS::Edge(myShape)); |
299 | ||
300 | myShape.Orientation(E.Orientation()); | |
301 | myShape.Location(L); | |
a2ff7810 | 302 | if (fabs(Alt) > gp::Resolution()) { |
6a442250 | 303 | BRepAdaptor_Surface S(mySpine,0); |
304 | gp_Ax1 Nor = S.Plane().Axis(); | |
305 | gp_Trsf T; | |
306 | gp_Vec Trans(Nor.Direction()); | |
307 | Trans = Alt*Trans; | |
308 | T.SetTranslation(Trans); | |
309 | myShape.Move(TopLoc_Location(T)); | |
310 | } | |
311 | ||
312 | TopTools_ListOfShape LL; | |
313 | LL.Append(myShape); | |
314 | myMap.Add(E,LL); | |
315 | ||
316 | TopoDS_Edge myEdge = TopoDS::Edge(myShape); | |
317 | myShape = BRepLib_MakeWire(myEdge); | |
318 | ||
319 | myIsDone = Standard_True; | |
320 | return Standard_True; | |
321 | } | |
7fd59977 | 322 | |
0e0f7a7c | 323 | return Standard_False; |
7fd59977 | 324 | } |
325 | ||
326 | //======================================================================= | |
327 | //function : BRepFill_OffsetWire | |
328 | //purpose : | |
329 | //======================================================================= | |
330 | ||
331 | BRepFill_OffsetWire::BRepFill_OffsetWire() | |
6a442250 | 332 | : myIsOpenResult(Standard_False), |
333 | myIsDone(Standard_False) | |
7fd59977 | 334 | { |
335 | } | |
336 | ||
337 | ||
338 | //======================================================================= | |
339 | //function : BRepFill_OffsetWire | |
340 | //purpose : | |
341 | //======================================================================= | |
342 | ||
343 | BRepFill_OffsetWire::BRepFill_OffsetWire(const TopoDS_Face& Spine, | |
873c119f | 344 | const GeomAbs_JoinType Join, |
345 | const Standard_Boolean IsOpenResult) | |
7fd59977 | 346 | { |
6a442250 | 347 | Init(Spine,Join,IsOpenResult); |
7fd59977 | 348 | } |
349 | ||
7fd59977 | 350 | //======================================================================= |
351 | //function : Init | |
352 | //purpose : | |
353 | //======================================================================= | |
354 | ||
355 | void BRepFill_OffsetWire::Init(const TopoDS_Face& Spine, | |
873c119f | 356 | const GeomAbs_JoinType Join, |
357 | const Standard_Boolean IsOpenResult) | |
7fd59977 | 358 | { |
7fd59977 | 359 | myIsDone = Standard_False; |
360 | TopoDS_Shape aLocalShape = Spine.Oriented(TopAbs_FORWARD); | |
361 | mySpine = TopoDS::Face(aLocalShape); | |
873c119f | 362 | // mySpine = TopoDS::Face(Spine.Oriented(TopAbs_FORWARD)); |
7fd59977 | 363 | myJoinType = Join; |
6a442250 | 364 | myIsOpenResult = IsOpenResult; |
873c119f | 365 | |
7fd59977 | 366 | myMap.Clear(); |
367 | myMapSpine.Clear(); | |
368 | //------------------------------------------------------------------ | |
0d969553 | 369 | // cut the spine for bissectors. |
7fd59977 | 370 | //------------------------------------------------------------------ |
873c119f | 371 | // Modified by Sergey KHROMOV - Tue Nov 26 17:39:03 2002 Begin |
7fd59977 | 372 | static BRepMAT2d_Explorer Exp; |
373 | ||
374 | Exp.Perform(mySpine); | |
375 | ||
873c119f | 376 | // TopoDS_Face anOldSpine = mySpine; |
7fd59977 | 377 | |
378 | mySpine = TopoDS::Face(Exp.ModifiedShape(mySpine)); | |
379 | PrepareSpine (); | |
380 | ||
873c119f | 381 | // Modified by Sergey KHROMOV - Tue Nov 26 17:39:03 2002 End |
7fd59977 | 382 | TopoDS_Shape aShape; |
86b3805f | 383 | BRepFill_IndexedDataMapOfOrientedShapeListOfShape aMap; |
7fd59977 | 384 | Standard_Boolean Done; |
e11c1bc4 | 385 | if (KPartCircle(myWorkSpine,1.,myIsOpenResult,0.,aShape,aMap,Done)) return; |
873c119f | 386 | |
7fd59977 | 387 | |
388 | //----------------------------------------------------- | |
0d969553 Y |
389 | // Calculate the map of bissectors to the left. |
390 | // and Links Topology -> base elements of the map. | |
7fd59977 | 391 | //----------------------------------------------------- |
392 | ||
873c119f | 393 | // Modified by Sergey KHROMOV - Tue Nov 26 17:39:03 2002 Begin |
394 | // static BRepMAT2d_Explorer Exp; | |
395 | // Modified by Sergey KHROMOV - Tue Nov 26 17:39:03 2002 End | |
7fd59977 | 396 | Exp.Perform(myWorkSpine); |
c19dd45e | 397 | myBilo.Compute(Exp, 1 ,MAT_Left, myJoinType, myIsOpenResult); |
873c119f | 398 | myLink.Perform(Exp,myBilo); |
7fd59977 | 399 | } |
400 | ||
401 | ||
402 | //======================================================================= | |
403 | //function : IsDone | |
404 | //purpose : | |
405 | //======================================================================= | |
406 | ||
407 | Standard_Boolean BRepFill_OffsetWire::IsDone() const | |
408 | { | |
409 | return myIsDone; | |
410 | } | |
411 | ||
412 | ||
413 | //======================================================================= | |
414 | //function : Spine | |
415 | //purpose : | |
416 | //======================================================================= | |
417 | ||
418 | const TopoDS_Face& BRepFill_OffsetWire::Spine() const | |
419 | { | |
420 | return mySpine; | |
421 | } | |
422 | ||
423 | ||
424 | //======================================================================= | |
425 | //function : Shape | |
426 | //purpose : | |
427 | //======================================================================= | |
428 | ||
429 | const TopoDS_Shape& BRepFill_OffsetWire::Shape() const | |
430 | { | |
431 | return myShape; | |
432 | } | |
433 | ||
434 | ||
435 | //======================================================================= | |
436 | //function : GeneratedShapes | |
437 | //purpose : | |
438 | //======================================================================= | |
439 | ||
440 | const TopTools_ListOfShape& BRepFill_OffsetWire::GeneratedShapes | |
873c119f | 441 | (const TopoDS_Shape& SpineShape) |
7fd59977 | 442 | { |
443 | if (!myCallGen) { | |
444 | if (!myMapSpine.IsEmpty()) { | |
0d969553 | 445 | // myMapSpine can be empty if passed by PerformWithBilo. |
7fd59977 | 446 | TopTools_DataMapIteratorOfDataMapOfShapeShape it(myMapSpine); |
447 | for (; it.More(); it.Next()) { | |
86b3805f J |
448 | if (myMap.Contains(it.Key())) { |
449 | if (!myMap.Contains(it.Value())) { | |
7fd59977 | 450 | TopTools_ListOfShape L; |
86b3805f | 451 | myMap.Add(it.Value(),L); |
7fd59977 | 452 | } |
453 | if ( !it.Value().IsSame(it.Key())) { | |
86b3805f J |
454 | myMap.ChangeFromKey(it.Value()).Append(myMap.ChangeFromKey(it.Key())); |
455 | //myMap.UnBind(it.Key()); | |
456 | TopoDS_Shape LastShape = myMap.FindKey(myMap.Extent()); | |
457 | TopTools_ListOfShape LastList; | |
458 | LastList.Append(myMap(myMap.Extent())); | |
459 | myMap.RemoveLast(); | |
460 | if (myMap.FindIndex(it.Key()) != 0) | |
461 | myMap.Substitute(myMap.FindIndex(it.Key()), LastShape, LastList); | |
7fd59977 | 462 | } |
463 | } | |
86b3805f J |
464 | if (myMap.Contains(it.Key().Reversed())) { |
465 | if (!myMap.Contains(it.Value().Reversed())) { | |
7fd59977 | 466 | TopTools_ListOfShape L; |
86b3805f | 467 | myMap.Add(it.Value().Reversed(),L); |
7fd59977 | 468 | } |
469 | if ( !it.Value().IsSame(it.Key())) { | |
86b3805f J |
470 | myMap.ChangeFromKey(it.Value().Reversed()).Append(myMap.ChangeFromKey(it.Key().Reversed())); |
471 | //myMap.UnBind(it.Key().Reversed()); | |
472 | TopoDS_Shape LastShape = myMap.FindKey(myMap.Extent()); | |
473 | TopTools_ListOfShape LastList; | |
474 | LastList.Append(myMap(myMap.Extent())); | |
475 | myMap.RemoveLast(); | |
476 | if (myMap.FindIndex(it.Key().Reversed()) != 0) | |
477 | myMap.Substitute(myMap.FindIndex(it.Key().Reversed()), LastShape, LastList); | |
7fd59977 | 478 | } |
479 | } | |
480 | } | |
481 | } | |
482 | myCallGen = Standard_True; | |
483 | } | |
873c119f | 484 | |
86b3805f J |
485 | if (myMap.Contains(SpineShape)) { |
486 | return myMap.FindFromKey(SpineShape); | |
7fd59977 | 487 | } |
488 | else { | |
489 | static TopTools_ListOfShape Empty; | |
490 | return Empty; | |
491 | } | |
492 | } | |
493 | ||
494 | ||
495 | //======================================================================= | |
496 | //function : JoinType | |
497 | //purpose : | |
498 | //======================================================================= | |
499 | ||
500 | GeomAbs_JoinType BRepFill_OffsetWire::JoinType() const | |
501 | { | |
502 | return myJoinType; | |
503 | } | |
504 | ||
505 | //======================================================================= | |
506 | //function : Perform | |
507 | //purpose : | |
508 | //======================================================================= | |
509 | ||
510 | void BRepFill_OffsetWire::Perform (const Standard_Real Offset, | |
873c119f | 511 | const Standard_Real Alt) |
7fd59977 | 512 | { |
91bb31f3 | 513 | // Modified by skv - Fri Jul 8 11:21:38 2005 OCC9145 Begin |
514 | try | |
515 | { | |
7fd59977 | 516 | OCC_CATCH_SIGNALS |
91bb31f3 | 517 | myCallGen = Standard_False; |
e11c1bc4 | 518 | if (KPartCircle(myWorkSpine,Offset,myIsOpenResult,Alt,myShape,myMap,myIsDone)) return; |
7fd59977 | 519 | |
520 | TopoDS_Face oldWorkSpain = myWorkSpine; | |
521 | ||
522 | TopTools_ListOfShape BadEdges; | |
523 | CheckBadEdges(myWorkSpine,Offset,myBilo,myLink,BadEdges); | |
524 | ||
91bb31f3 | 525 | if(!BadEdges.IsEmpty()) |
526 | { | |
7fd59977 | 527 | // Modification of myWorkSpine; |
528 | //cout << "Modification of myWorkSpine : " << BadEdges.Extent() << endl; | |
529 | BRepTools_Substitution aSubst; | |
530 | TopTools_ListIteratorOfListOfShape it(BadEdges); | |
531 | TopTools_ListOfShape aL; | |
532 | Standard_Real aDefl = .01 * Abs(Offset); | |
533 | TColStd_SequenceOfReal Parameters; | |
534 | TColgp_SequenceOfPnt Points; | |
535 | ||
536 | for(; it.More(); it.Next()) { | |
91bb31f3 | 537 | aL.Clear(); |
538 | Parameters.Clear(); | |
539 | Points.Clear(); | |
540 | const TopoDS_Shape& anE = it.Value(); | |
541 | ||
542 | TopoDS_Vertex Vf, Vl; | |
543 | TopExp::Vertices(TopoDS::Edge(anE), Vf, Vl); | |
544 | ||
545 | Standard_Real f, l; | |
546 | Handle(Geom_Curve) G3d = BRep_Tool::Curve(TopoDS::Edge(anE),f,l); | |
547 | GeomAdaptor_Curve AC(G3d,f,l); | |
548 | ||
549 | PerformCurve(Parameters, Points, AC, aDefl, f, | |
873c119f | 550 | l, Precision::Confusion(), 2); |
91bb31f3 | 551 | |
552 | Standard_Integer NPnts = Points.Length(); | |
553 | if(NPnts > 2) | |
554 | { | |
555 | //cout << NPnts << " points " << endl; | |
556 | TopoDS_Vertex FV = Vf; | |
557 | TopoDS_Vertex LV; | |
558 | TopoDS_Edge newE; | |
559 | Standard_Integer np; | |
560 | for(np = 2; np < NPnts; np++) { | |
561 | gp_Pnt LP = Points(np); | |
562 | LV = BRepLib_MakeVertex(LP); | |
563 | newE = BRepLib_MakeEdge(FV, LV); | |
564 | aL.Append(newE); | |
565 | FV = LV; | |
566 | } | |
567 | LV = Vl; | |
568 | newE = BRepLib_MakeEdge(FV, LV); | |
569 | aL.Append(newE); | |
570 | } | |
571 | else | |
572 | { | |
573 | //cout << " 2 points " << endl; | |
574 | TopoDS_Edge newE = BRepLib_MakeEdge(Vf, Vl); | |
575 | aL.Append(newE); | |
576 | } | |
577 | //Update myMapSpine | |
578 | if (myMapSpine.IsBound( anE )) | |
579 | { | |
580 | TopTools_ListIteratorOfListOfShape newit( aL ); | |
581 | for (; newit.More(); newit.Next()) | |
582 | { | |
583 | TopoDS_Edge NewEdge = TopoDS::Edge( newit.Value() ); | |
584 | myMapSpine.Bind( NewEdge, myMapSpine(anE) ); | |
585 | TopoDS_Vertex NewV1, NewV2; | |
586 | EdgeVertices( NewEdge, NewV1, NewV2 ); | |
587 | if (!myMapSpine.IsBound(NewV1)) myMapSpine.Bind( NewV1, myMapSpine(anE) ); | |
588 | if (!myMapSpine.IsBound(NewV2)) myMapSpine.Bind( NewV2, myMapSpine(anE) ); | |
589 | } | |
590 | myMapSpine.UnBind( anE ); | |
591 | } | |
592 | /////////////////// | |
593 | aSubst.Substitute(anE, aL); | |
7fd59977 | 594 | } |
595 | ||
596 | TopTools_DataMapOfShapeListOfShape wwmap; | |
597 | TopoDS_Iterator itws( myWorkSpine ); | |
598 | for (; itws.More(); itws.Next()) | |
91bb31f3 | 599 | { |
600 | TopoDS_Shape aWire = itws.Value(); | |
601 | aSubst.Build( aWire ); | |
602 | if (aSubst.IsCopied(aWire)) | |
603 | { | |
604 | TopoDS_Wire NewWire = TopoDS::Wire( aSubst.Copy(aWire).First() ); | |
605 | NewWire.Closed( aWire.Closed() ); | |
606 | TopTools_ListOfShape Lw; | |
607 | Lw.Append( NewWire ); | |
608 | wwmap.Bind( aWire, Lw ); | |
609 | } | |
610 | } | |
7fd59977 | 611 | aSubst.Clear(); |
612 | TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itmap( wwmap ); | |
613 | for (; itmap.More(); itmap.Next()) | |
91bb31f3 | 614 | aSubst.Substitute( itmap.Key(), itmap.Value() ); |
873c119f | 615 | |
7fd59977 | 616 | aSubst.Build(myWorkSpine); |
873c119f | 617 | |
7fd59977 | 618 | if(aSubst.IsCopied(myWorkSpine)) { |
91bb31f3 | 619 | myWorkSpine = TopoDS::Face(aSubst.Copy(myWorkSpine).First()); |
ab87e6fc | 620 | |
91bb31f3 | 621 | BRepMAT2d_Explorer newExp; |
622 | newExp.Perform(myWorkSpine); | |
623 | BRepMAT2d_BisectingLocus newBilo; | |
624 | BRepMAT2d_LinkTopoBilo newLink; | |
c19dd45e | 625 | newBilo.Compute(newExp, 1, MAT_Left, myJoinType, myIsOpenResult); |
ab87e6fc | 626 | |
91bb31f3 | 627 | if(!newBilo.IsDone()) |
628 | { | |
629 | myShape.Nullify(); | |
630 | myIsDone = Standard_False; | |
631 | return; | |
632 | } | |
7fd59977 | 633 | |
91bb31f3 | 634 | newLink.Perform(newExp,newBilo); |
635 | PerformWithBiLo(myWorkSpine,Offset,newBilo,newLink,myJoinType,Alt); | |
636 | myWorkSpine = oldWorkSpain; | |
7fd59977 | 637 | } |
638 | else { | |
91bb31f3 | 639 | PerformWithBiLo(myWorkSpine,Offset,myBilo,myLink,myJoinType,Alt); |
7fd59977 | 640 | } |
7fd59977 | 641 | } |
91bb31f3 | 642 | else |
643 | { | |
7fd59977 | 644 | PerformWithBiLo(myWorkSpine,Offset,myBilo,myLink,myJoinType,Alt); |
645 | } | |
ab87e6fc | 646 | } |
9775fa61 | 647 | catch (Standard_Failure const& anException) { |
0797d9d3 | 648 | #ifdef OCCT_DEBUG |
ab87e6fc | 649 | cout<<"An exception was caught in BRepFill_OffsetWire::Perform : "; |
9775fa61 | 650 | anException.Print(cout); |
ab87e6fc | 651 | cout<<endl; |
63c629aa | 652 | #endif |
9775fa61 | 653 | (void)anException; |
654 | myShape.Nullify(); | |
655 | myIsDone = Standard_False; | |
91bb31f3 | 656 | |
7fd59977 | 657 | return; |
658 | } | |
ab87e6fc | 659 | |
91bb31f3 | 660 | // Modified by skv - Fri Jul 8 11:21:38 2005 OCC9145 End |
661 | // Modified by Sergey KHROMOV - Thu Mar 14 10:48:15 2002 Begin | |
6a442250 | 662 | if (!myIsOpenResult) |
663 | { | |
664 | TopExp_Explorer anExp(myShape, TopAbs_WIRE); | |
873c119f | 665 | |
6a442250 | 666 | for (; anExp.More(); anExp.Next()) { |
667 | const TopoDS_Shape &aWire = anExp.Current(); | |
873c119f | 668 | |
6a442250 | 669 | if (!aWire.Closed()) { |
670 | myShape.Nullify(); | |
671 | myIsDone = Standard_False; | |
9775fa61 | 672 | throw Standard_ConstructionError("Offset wire is not closed."); |
6a442250 | 673 | } |
7fd59977 | 674 | } |
675 | } | |
91bb31f3 | 676 | // Modified by Sergey KHROMOV - Thu Mar 14 10:48:16 2002 End |
7fd59977 | 677 | } |
678 | ||
679 | //======================================================================= | |
680 | //function : Compute | |
681 | //purpose : | |
682 | //======================================================================= | |
683 | ||
684 | void Compute (const TopoDS_Face& Spine, | |
873c119f | 685 | TopoDS_Shape& aShape, |
686 | BRepFill_IndexedDataMapOfOrientedShapeListOfShape& Map, | |
687 | const Standard_Real Alt) | |
7fd59977 | 688 | { |
689 | BRep_Builder B; | |
690 | B.MakeCompound(TopoDS::Compound(aShape)); | |
691 | Standard_Real ALT = Alt; | |
692 | if ( Spine.Orientation() == TopAbs_REVERSED) ALT = -Alt; | |
693 | gp_Trsf T; | |
694 | T.SetTranslation(gp_Vec(0.,0.,ALT)); | |
695 | TopLoc_Location L(T); | |
696 | ||
697 | for ( TopExp_Explorer exp(Spine,TopAbs_WIRE); exp.More(); exp.Next()) { | |
698 | const TopoDS_Wire& CurW = TopoDS::Wire(exp.Current()); | |
699 | TopoDS_Shape aLocalShape = CurW.Moved(L); | |
700 | TopoDS_Wire NewW = TopoDS::Wire(aLocalShape); | |
873c119f | 701 | // TopoDS_Wire NewW = TopoDS::Wire(CurW.Moved(L)); |
7fd59977 | 702 | B.Add(aShape,NewW); |
0d969553 | 703 | // update Map. |
7fd59977 | 704 | TopoDS_Iterator it1( CurW); |
705 | TopoDS_Iterator it2( NewW); | |
706 | for ( ; it1.More(); it1.Next(), it2.Next()) { | |
707 | TopTools_ListOfShape List; | |
708 | List.Append(it2.Value()); | |
86b3805f | 709 | Map.Add(it1.Value(), List); |
7fd59977 | 710 | } |
711 | } | |
712 | } | |
713 | ||
714 | //======================================================================= | |
715 | //function : PerformWithBiLo | |
716 | //purpose : | |
717 | //======================================================================= | |
718 | ||
719 | void BRepFill_OffsetWire::PerformWithBiLo | |
873c119f | 720 | (const TopoDS_Face& Spine, |
721 | const Standard_Real Offset, | |
722 | const BRepMAT2d_BisectingLocus& Locus, | |
723 | BRepMAT2d_LinkTopoBilo& Link, | |
724 | const GeomAbs_JoinType Join, | |
725 | const Standard_Real Alt) | |
7fd59977 | 726 | { |
7fd59977 | 727 | myIsDone = Standard_False; |
51740958 | 728 | TopoDS_Shape aLocalShapeWork = Spine.Oriented(TopAbs_FORWARD); |
729 | myWorkSpine = TopoDS::Face(aLocalShapeWork); | |
873c119f | 730 | // myWorkSpine = TopoDS::Face(Spine.Oriented(TopAbs_FORWARD)); |
7fd59977 | 731 | myJoinType = Join; |
732 | myOffset = Offset ; | |
733 | myShape.Nullify(); | |
734 | ||
735 | ||
736 | if (mySpine.IsNull()) { | |
737 | TopoDS_Shape aLocalShape = Spine.Oriented(TopAbs_FORWARD); | |
738 | mySpine = TopoDS::Face(aLocalShape); | |
873c119f | 739 | // mySpine = TopoDS::Face(Spine.Oriented(TopAbs_FORWARD)); |
740 | } | |
7fd59977 | 741 | myMap.Clear(); |
742 | ||
7fd59977 | 743 | if ( Abs(myOffset) < Precision::Confusion()) { |
744 | Compute(mySpine,myShape,myMap,Alt); | |
745 | myIsDone = Standard_True; | |
746 | return; | |
747 | } | |
748 | ||
0d969553 Y |
749 | //******************************** |
750 | // Calculate for a non null offset | |
751 | //******************************** | |
e11c1bc4 | 752 | if (KPartCircle(myWorkSpine,Offset,myIsOpenResult,Alt,myShape,myMap,myIsDone)) |
91bb31f3 | 753 | return; |
7fd59977 | 754 | |
755 | BRep_Builder myBuilder; | |
756 | myBuilder.MakeCompound(TopoDS::Compound(myShape)); | |
873c119f | 757 | |
7fd59977 | 758 | //--------------------------------------------------------------------- |
0d969553 Y |
759 | // MapNodeVertex : associate to each node of the map (key1) and to |
760 | // each element of the profile (key2) a vertex (item). | |
761 | // MapBis : all edges or vertices (item) generated by | |
762 | // a bisectrice on a face or an edge (key) of revolution tubes. | |
763 | // MapVerPar : Map of parameters of vertices on parallel edges | |
764 | // the list contained in MapVerPar (E) corresponds to | |
765 | // parameters on E of vertices contained in MapBis(E); | |
7fd59977 | 766 | //--------------------------------------------------------------------- |
767 | ||
768 | ||
769 | BRepFill_DataMapOfNodeShape MapNodeVertex; | |
770 | TopTools_DataMapOfShapeSequenceOfShape MapBis; | |
771 | BRepFill_DataMapOfShapeSequenceOfReal MapVerPar; | |
772 | ||
773 | TopTools_DataMapOfShapeShape EmptyMap; | |
774 | TopTools_SequenceOfShape EmptySeq; | |
775 | TopTools_ListOfShape EmptyList; | |
776 | TColStd_SequenceOfReal EmptySeqOfReal; | |
777 | ||
7fd59977 | 778 | Handle(Geom_Plane) RefPlane = |
779 | Handle(Geom_Plane)::DownCast(BRep_Tool::Surface(myWorkSpine)); | |
a2ff7810 | 780 | if (fabs(Alt) > gp::Resolution()) { |
781 | Standard_Real anAlt = Alt; | |
782 | if ( myWorkSpine.Orientation() == TopAbs_REVERSED) anAlt = -Alt; | |
783 | RefPlane = Handle(Geom_Plane)::DownCast | |
784 | (RefPlane->Translated( anAlt * gp_Vec(RefPlane->Axis().Direction() ))); | |
785 | } | |
7fd59977 | 786 | |
787 | //--------------------------------------------------------------- | |
0d969553 | 788 | // Construction of Circles and OffsetCurves |
7fd59977 | 789 | //--------------------------------------------------------------- |
6a442250 | 790 | |
791 | TopoDS_Vertex Ends [2]; | |
792 | if (myIsOpenResult) | |
793 | { | |
794 | TopoDS_Wire theWire; | |
795 | TopoDS_Iterator iter(mySpine); | |
796 | theWire = TopoDS::Wire(iter.Value()); | |
797 | TopExp::Vertices(theWire, Ends[0], Ends[1]); | |
798 | } | |
873c119f | 799 | |
7fd59977 | 800 | for (Standard_Integer ic = 1; ic <= Locus.NumberOfContours(); ic++) { |
801 | TopoDS_Shape PEE = Link.GeneratingShape(Locus.BasicElt(ic,Locus.NumberOfElts(ic))); | |
802 | TopoDS_Shape& PE = PEE ; | |
803 | for (Standard_Integer ie = 1; ie <= Locus.NumberOfElts(ic); ie++) { | |
804 | const TopoDS_Shape& SE = Link.GeneratingShape(Locus.BasicElt(ic,ie)); | |
805 | if (SE.ShapeType() == TopAbs_VERTEX) { | |
0e0f7a7c | 806 | if (!SE.IsSame(Ends[0]) && !SE.IsSame(Ends[1])) |
807 | MakeCircle (TopoDS::Edge(PE),TopoDS::Vertex(SE), | |
808 | myWorkSpine,myOffset,myMap,RefPlane); | |
7fd59977 | 809 | } |
810 | else { | |
873c119f | 811 | MakeOffset (TopoDS::Edge(SE),myWorkSpine,myOffset,myMap,RefPlane, |
c7806cb6 | 812 | myIsOpenResult, myJoinType, Ends); |
873c119f | 813 | PE = SE; |
7fd59977 | 814 | } |
815 | } | |
816 | } | |
817 | ||
016dfb16 | 818 | //Remove possible hanging arcs on vertices |
819 | if (myIsOpenResult && myJoinType == GeomAbs_Arc) | |
820 | { | |
821 | if (!myMap.IsEmpty() && | |
822 | myMap.FindKey(1).ShapeType() == TopAbs_VERTEX) | |
823 | { | |
824 | //myMap.RemoveFirst(); | |
825 | TopoDS_Shape LastShape = myMap.FindKey(myMap.Extent()); | |
826 | TopTools_ListOfShape LastList; | |
827 | LastList.Append(myMap(myMap.Extent())); | |
828 | myMap.RemoveLast(); | |
829 | if (!myMap.IsEmpty()) | |
830 | myMap.Substitute(1, LastShape, LastList); | |
831 | } | |
832 | if (!myMap.IsEmpty() && | |
833 | myMap.FindKey(myMap.Extent()).ShapeType() == TopAbs_VERTEX) | |
834 | myMap.RemoveLast(); | |
835 | } | |
7fd59977 | 836 | |
873c119f | 837 | #ifdef OCCT_DEBUG |
1896126e | 838 | #ifdef DRAW |
7fd59977 | 839 | if (AffichEdge) { |
0d969553 | 840 | cout << " End Construction of geometric primitives "<<endl; |
7fd59977 | 841 | } |
842 | #endif | |
873c119f | 843 | #endif |
7fd59977 | 844 | |
845 | ||
846 | //--------------------------------------------------- | |
0d969553 | 847 | // Construction of offset vertices. |
7fd59977 | 848 | //--------------------------------------------------- |
849 | BRepFill_DataMapOfOrientedShapeListOfShape Detromp; | |
850 | Handle(MAT_Arc) CurrentArc; | |
851 | Handle(Geom2d_Curve) Bis, PCurve1, PCurve2 ; | |
852 | Handle(Geom_Curve) CBis; | |
853 | Standard_Boolean Reverse; | |
854 | TopoDS_Edge CurrentEdge; | |
855 | TopoDS_Shape S [2]; | |
856 | TopoDS_Edge E [2]; | |
857 | TopLoc_Location L; | |
86b3805f | 858 | Standard_Integer j, k; |
7fd59977 | 859 | |
860 | for (Standard_Integer i = 1; i <= Locus.Graph()->NumberOfArcs(); i++) { | |
861 | ||
862 | CurrentArc = Locus.Graph()->Arc(i); | |
863 | Bisector_Bisec Bisec = Locus.GeomBis(CurrentArc,Reverse); | |
873c119f | 864 | #ifdef OCCT_DEBUG |
7fd59977 | 865 | #ifdef DRAW |
873c119f | 866 | |
867 | if ( AffichGeom) { | |
868 | char name[256]; | |
869 | sprintf(name,"BISSEC_%d",NbBISSEC++); | |
870 | DrawTrSurf::Set(name,Bisec.Value()); | |
871 | } | |
872 | #endif | |
7fd59977 | 873 | #endif |
874 | ||
0d969553 Y |
875 | //------------------------------------------------------------------- |
876 | // Return elements of the spine corresponding to separate basicElts. | |
877 | //------------------------------------------------------------------- | |
7fd59977 | 878 | S [0] = Link.GeneratingShape(CurrentArc->FirstElement()); |
879 | S [1] = Link.GeneratingShape(CurrentArc->SecondElement()); | |
880 | ||
881 | TopTools_SequenceOfShape Vertices; | |
882 | TColgp_SequenceOfPnt Params; | |
873c119f | 883 | |
7fd59977 | 884 | TopTools_DataMapOfShapeSequenceOfShape MapSeqVer; |
885 | BRepFill_DataMapOfShapeSequenceOfPnt MapSeqPar; | |
886 | ||
887 | //----------------------------------------------------------- | |
0d969553 Y |
888 | // Return parallel edges on each face. |
889 | // If no offset generated => move to the next bissectrice. | |
7fd59977 | 890 | //-------------------------------------------------------------- |
86b3805f J |
891 | if (myMap.Contains(S[0]) && myMap.Contains(S[1])) { |
892 | E [0] = TopoDS::Edge(myMap.FindFromKey(S[0]).First()); | |
893 | E [1] = TopoDS::Edge(myMap.FindFromKey(S[1]).First()); | |
7fd59977 | 894 | } |
895 | else continue; | |
896 | ||
897 | //----------------------------------------------------------- | |
0d969553 Y |
898 | // Construction of vertices corresponding to the node of the map. |
899 | // if they are on the offset. | |
7fd59977 | 900 | //----------------------------------------------------------- |
901 | TopoDS_Vertex VS,VE; | |
902 | Handle(MAT_Node) Node1, Node2; | |
903 | ||
904 | if (Reverse) { | |
905 | Node1 = CurrentArc->SecondNode(); | |
906 | Node2 = CurrentArc->FirstNode(); | |
907 | } | |
908 | else { | |
909 | Node1 = CurrentArc->FirstNode(); | |
910 | Node2 = CurrentArc->SecondNode(); | |
911 | } | |
873c119f | 912 | |
7fd59977 | 913 | Standard_Boolean StartOnEdge = 0, EndOnEdge = 0; |
873c119f | 914 | |
7fd59977 | 915 | if (!Node1->Infinite()) { |
916 | gp_Pnt2d aLocalPnt2d = Locus.GeomElt(Node1); | |
917 | StartOnEdge = VertexFromNode(Node1, myOffset, aLocalPnt2d ,MapNodeVertex,VS); | |
873c119f | 918 | // StartOnEdge = VertexFromNode(Node1, myOffset, Locus.GeomElt(Node1), |
919 | // MapNodeVertex,VS); | |
7fd59977 | 920 | } |
921 | if (!Node2->Infinite()) { | |
922 | gp_Pnt2d aLocalPnt2d = Locus.GeomElt(Node2) ; | |
923 | EndOnEdge = VertexFromNode(Node2, myOffset, aLocalPnt2d ,MapNodeVertex,VE); | |
873c119f | 924 | // EndOnEdge = VertexFromNode(Node2, myOffset, Locus.GeomElt(Node2), |
925 | // MapNodeVertex,VE); | |
7fd59977 | 926 | } |
927 | ||
9eb68d38 | 928 | if (myJoinType == GeomAbs_Intersection) |
929 | StartOnEdge = EndOnEdge = 0; | |
930 | ||
7fd59977 | 931 | //--------------------------------------------- |
0d969553 | 932 | // Construction of geometries. |
7fd59977 | 933 | //--------------------------------------------- |
934 | BRepFill_TrimEdgeTool Trim (Bisec, | |
873c119f | 935 | Locus.GeomElt(CurrentArc->FirstElement()), |
936 | Locus.GeomElt(CurrentArc->SecondElement()), | |
937 | myOffset); | |
7fd59977 | 938 | |
939 | //----------------------------------------------------------- | |
0d969553 | 940 | // Construction of vertices on edges parallel to the spine. |
7fd59977 | 941 | //----------------------------------------------------------- |
942 | ||
46767247 | 943 | Trim.IntersectWith(E[0], E[1], S[0], S[1], Ends[0], Ends[1], |
944 | myJoinType, myIsOpenResult, Params); | |
7fd59977 | 945 | |
946 | for (Standard_Integer s = 1; s <= Params.Length(); s++) { | |
947 | TopoDS_Vertex VC; | |
948 | myBuilder.MakeVertex (VC); | |
949 | gp_Pnt2d P2 = Bisec.Value()->Value(Params.Value(s).X()); | |
950 | gp_Pnt PVC(P2.X(),P2.Y(),0.); | |
951 | ||
952 | myBuilder.UpdateVertex(VC,PVC,Precision::Confusion()); | |
953 | Vertices.Append(VC); | |
954 | } | |
955 | if (StartOnEdge) { | |
956 | Standard_Boolean Start = 1; | |
957 | Trim.AddOrConfuse(Start, E[0], E[1], Params); | |
958 | if (Params.Length() == Vertices.Length()) | |
873c119f | 959 | Vertices.SetValue(1,VS); |
7fd59977 | 960 | |
961 | else | |
873c119f | 962 | // the point was not found by IntersectWith |
963 | Vertices.Prepend(VS); | |
7fd59977 | 964 | } |
965 | if (EndOnEdge) { | |
966 | Standard_Boolean Start = 0; | |
967 | Trim.AddOrConfuse(Start, E[0], E[1], Params); | |
968 | if (Params.Length() == Vertices.Length()) | |
873c119f | 969 | Vertices.SetValue(Params.Length(),VE); |
7fd59977 | 970 | |
971 | else | |
873c119f | 972 | // the point was not found by IntersectWith |
973 | Vertices.Append(VE); | |
7fd59977 | 974 | } |
975 | ||
976 | //------------------------------------------------------------ | |
0d969553 Y |
977 | // Update Detromp. |
978 | // Detromp allows to remove vertices on the offset | |
979 | // corresponding to tangency zones | |
980 | // Detromp ranks the vertices that limit | |
981 | // the parts of the bissectrices located between the spine and the | |
982 | // offset. | |
7fd59977 | 983 | //------------------------------------------------------------ |
984 | if (!Detromp.IsBound(S[0])) Detromp.Bind(S[0],EmptyList); | |
985 | if (!Detromp.IsBound(S[1])) Detromp.Bind(S[1],EmptyList); | |
986 | ||
987 | ||
c19dd45e | 988 | UpdateDetromp (Detromp, S[0], S[1], Vertices, Params, |
873c119f | 989 | Bisec, StartOnEdge, EndOnEdge, Trim); |
7fd59977 | 990 | //---------------------------------------------- |
0d969553 Y |
991 | // Storage of vertices on parallel edges. |
992 | // fill MapBis and MapVerPar. | |
7fd59977 | 993 | //---------------------------------------------- |
994 | if (!Vertices.IsEmpty()) { | |
995 | for (k = 0; k <= 1; k++) { | |
873c119f | 996 | if (!MapBis.IsBound(E[k])) { |
997 | MapBis .Bind(E[k],EmptySeq); | |
998 | MapVerPar.Bind(E[k],EmptySeqOfReal); | |
999 | } | |
1000 | for (Standard_Integer ii = 1; ii <= Vertices.Length(); ii++) { | |
1001 | MapBis (E[k]).Append(Vertices.Value(ii)); | |
1002 | if (k == 0) MapVerPar (E[k]).Append(Params.Value(ii).Y()); | |
1003 | else MapVerPar (E[k]).Append(Params.Value(ii).Z()); | |
1004 | } | |
7fd59977 | 1005 | } |
1006 | } | |
1007 | else { | |
1008 | //------------------------------------------------------------ | |
0d969553 Y |
1009 | // FOR COMPLETE CIRCLES. the parallel line can be contained |
1010 | // in the zone without intersection with the border | |
1011 | // no intersection | |
1012 | // if myoffset is < distance of nodes the parallel can be valid. | |
7fd59977 | 1013 | //------------------------------------------------------------- |
1014 | for (k = 0; k <= 1; k++) { | |
873c119f | 1015 | if (!MapBis.IsBound(E[k])) { |
1016 | if (Node1->Distance() > myOffset && Node2->Distance() > myOffset) { | |
1017 | MapBis .Bind(E[k],EmptySeq); | |
1018 | MapVerPar.Bind(E[k],EmptySeqOfReal); | |
1019 | } | |
1020 | } | |
7fd59977 | 1021 | } |
1022 | } | |
1023 | } | |
873c119f | 1024 | |
1025 | #ifdef OCCT_DEBUG | |
1896126e | 1026 | #ifdef DRAW |
7fd59977 | 1027 | if (AffichEdge) { |
0d969553 | 1028 | cout << " End Construction of vertices on offsets"<<endl; |
7fd59977 | 1029 | } |
873c119f | 1030 | #endif |
7fd59977 | 1031 | #endif |
1032 | ||
1033 | //---------------------------------- | |
0d969553 | 1034 | // Construction of parallel edges. |
7fd59977 | 1035 | //---------------------------------- |
1036 | TopTools_IndexedDataMapOfShapeShape MapVV; | |
1037 | ||
1038 | TopoDS_Shape CurrentSpine; | |
1039 | ||
86b3805f | 1040 | //BRepFill_DataMapIteratorOfDataMapOfOrientedShapeListOfShape ite1; |
7fd59977 | 1041 | |
86b3805f J |
1042 | for (j = 1; j <= myMap.Extent(); j++) { |
1043 | CurrentSpine = myMap.FindKey(j); | |
1044 | CurrentEdge = TopoDS::Edge(myMap(j).First()); | |
7fd59977 | 1045 | |
86b3805f | 1046 | myMap(j).Clear(); |
7fd59977 | 1047 | if (MapBis.IsBound(CurrentEdge)) { |
51740958 | 1048 | TopTools_SequenceOfShape aSeqOfShape; |
7fd59977 | 1049 | if (!MapBis(CurrentEdge).IsEmpty()) { |
6a442250 | 1050 | Standard_Integer IndOfE = 0; |
1051 | if (myIsOpenResult) | |
1052 | { | |
1053 | if (j == 1) | |
1054 | IndOfE = 1; | |
1055 | else if (j == myMap.Extent()) | |
1056 | IndOfE = -1; | |
1057 | } | |
873c119f | 1058 | TrimEdge (CurrentEdge, |
1059 | CurrentSpine, | |
1060 | mySpine, | |
1061 | Detromp (CurrentSpine), | |
1062 | MapBis (CurrentEdge) , | |
1063 | MapVerPar(CurrentEdge) , | |
51740958 | 1064 | aSeqOfShape, MapVV, IndOfE); |
1065 | for ( k = 1; k <= aSeqOfShape.Length(); k++) { | |
1066 | myMap(j).Append(aSeqOfShape.Value(k)); | |
873c119f | 1067 | } |
7fd59977 | 1068 | } |
1069 | else { | |
873c119f | 1070 | //----------------- |
1071 | // Complete circles | |
1072 | //----------------- | |
1073 | myMap(j).Append(CurrentEdge); | |
7fd59977 | 1074 | } |
1075 | } | |
1076 | } | |
873c119f | 1077 | |
7fd59977 | 1078 | Standard_Integer ind; |
1079 | for (ind = 1; ind <= MapVV.Extent(); ind++) | |
873c119f | 1080 | { |
1081 | TopoDS_Vertex OldV = TopoDS::Vertex(MapVV.FindKey(ind)); | |
1082 | TopoDS_Vertex NewV = TopoDS::Vertex(MapVV(ind)); | |
1083 | gp_Pnt P1 = BRep_Tool::Pnt(OldV); | |
1084 | gp_Pnt P2 = BRep_Tool::Pnt(NewV); | |
1085 | myBuilder.UpdateVertex(NewV, P1.Distance(P2)); | |
1086 | TopTools_ListOfShape LV; | |
1087 | LV.Append( NewV.Oriented(TopAbs_FORWARD) ); | |
1088 | BRepTools_Substitution aSubst; | |
1089 | aSubst.Substitute( OldV, LV ); | |
1090 | for (j = 1; j <= myMap.Extent(); j++) | |
7fd59977 | 1091 | { |
873c119f | 1092 | TopTools_ListIteratorOfListOfShape itl(myMap(j)); |
1093 | for (; itl.More(); itl.Next()) | |
1094 | { | |
1095 | aSubst.Build(itl.Value()); | |
1096 | if (aSubst.IsCopied(itl.Value())) | |
1097 | { | |
1098 | const TopTools_ListOfShape& listSh = aSubst.Copy(itl.Value()); | |
1099 | TopAbs_Orientation SaveOr = itl.Value().Orientation(); | |
1100 | itl.Value() = listSh.First(); | |
1101 | itl.Value().Orientation(SaveOr); | |
1102 | } | |
1103 | } | |
7fd59977 | 1104 | } |
873c119f | 1105 | } |
7fd59977 | 1106 | |
1107 | //---------------------------------- | |
0d969553 | 1108 | // Construction of offset wires. |
7fd59977 | 1109 | //---------------------------------- |
1110 | MakeWires (); | |
1111 | ||
0d969553 | 1112 | // Update vertices ( Constructed in the plane Z = 0) !!! |
7fd59977 | 1113 | TopTools_MapOfShape MapVertex; |
1114 | for ( TopExp_Explorer exp(myShape,TopAbs_VERTEX); exp.More(); exp.Next()) { | |
1115 | TopoDS_Vertex V = TopoDS::Vertex(exp.Current()); | |
1116 | if ( MapVertex.Add(V)) { | |
1117 | gp_Pnt P = BRep_Tool::Pnt(V); | |
1118 | P = RefPlane->Value(P.X(),P.Y()); | |
1119 | myBuilder.UpdateVertex(V,P, Precision::Confusion()); | |
1120 | } | |
1121 | } | |
1122 | ||
0d969553 | 1123 | // Construction of curves 3d. |
7fd59977 | 1124 | BRepLib::BuildCurves3d(myShape); |
1125 | MapVertex.Clear(); | |
1126 | TopExp_Explorer Explo( myShape, TopAbs_EDGE ); | |
1127 | for (; Explo.More(); Explo.Next()) | |
873c119f | 1128 | { |
51740958 | 1129 | TopoDS_Edge anEdge = TopoDS::Edge( Explo.Current() ); |
873c119f | 1130 | TopoDS_Vertex V1, V2; |
51740958 | 1131 | TopExp::Vertices(anEdge, V1, V2 ); |
873c119f | 1132 | Handle(BRep_TVertex)& TV1 = *((Handle(BRep_TVertex)*) &(V1).TShape()); |
1133 | Handle(BRep_TVertex)& TV2 = *((Handle(BRep_TVertex)*) &(V2).TShape()); | |
1134 | ||
1135 | TopLoc_Location loc; | |
1136 | Standard_Real f, l; | |
51740958 | 1137 | Handle( Geom_Curve ) theCurve = BRep_Tool::Curve(anEdge, loc, f, l ); |
873c119f | 1138 | theCurve = Handle( Geom_Curve )::DownCast( theCurve->Copy() ); |
1139 | theCurve->Transform( loc.Transformation() ); | |
1140 | gp_Pnt f3d = theCurve->Value( f ); | |
1141 | gp_Pnt l3d = theCurve->Value( l ); | |
1142 | ||
1143 | Standard_Real dist1, dist2; | |
1144 | dist1 = f3d.Distance( TV1->Pnt() ); | |
1145 | dist2 = l3d.Distance( TV2->Pnt() ); | |
1146 | if (! MapVertex.Contains( V1 )) | |
7fd59977 | 1147 | { |
7fd59977 | 1148 | |
873c119f | 1149 | TV1->Pnt( f3d ); |
1150 | MapVertex.Add( V1 ); | |
7fd59977 | 1151 | } |
873c119f | 1152 | else |
1153 | TV1->UpdateTolerance( 1.5*dist1 ); | |
1154 | if (! MapVertex.Contains( V2 )) | |
1155 | { | |
1156 | TV2->Pnt( l3d ); | |
1157 | MapVertex.Add( V2 ); | |
1158 | } | |
1159 | else | |
1160 | TV2->UpdateTolerance( 1.5*dist2 ); | |
1161 | } | |
7fd59977 | 1162 | |
1867dc32 | 1163 | if (!myIsOpenResult) |
1164 | FixHoles(); | |
7fd59977 | 1165 | |
1166 | myIsDone = Standard_True; | |
1167 | } | |
1168 | ||
1169 | ||
1170 | //======================================================================= | |
1171 | //function : Generated | |
1172 | //purpose : | |
1173 | //======================================================================= | |
1174 | ||
86b3805f | 1175 | BRepFill_IndexedDataMapOfOrientedShapeListOfShape& |
873c119f | 1176 | BRepFill_OffsetWire::Generated() |
7fd59977 | 1177 | { |
1178 | return myMap; | |
1179 | } | |
1180 | ||
1181 | ||
1182 | //======================================================================= | |
1183 | //function : PrepareSpine | |
1184 | //purpose : | |
1185 | //======================================================================= | |
1186 | ||
1187 | void BRepFill_OffsetWire::PrepareSpine() | |
1188 | { | |
1189 | BRep_Builder B; | |
1190 | TopTools_ListOfShape Cuts; | |
1191 | TopTools_ListIteratorOfListOfShape IteCuts; | |
1192 | TopoDS_Vertex V1,V2; | |
1193 | ||
1194 | myWorkSpine.Nullify(); | |
1195 | myMapSpine.Clear(); | |
1196 | ||
1197 | TopLoc_Location L; | |
1198 | const Handle(Geom_Surface)& S = BRep_Tool::Surface (mySpine,L); | |
1199 | Standard_Real TolF = BRep_Tool::Tolerance(mySpine); | |
1200 | B.MakeFace(myWorkSpine,S,L,TolF); | |
1201 | ||
1202 | for (TopoDS_Iterator IteF(mySpine) ; IteF.More(); IteF.Next()) { | |
1203 | ||
1204 | TopoDS_Wire NW; | |
1205 | B.MakeWire (NW); | |
1206 | ||
873c119f | 1207 | // Modified by Sergey KHROMOV - Thu Nov 16 17:29:55 2000 Begin |
7fd59977 | 1208 | Standard_Integer ForcedCut = 0; |
1209 | Standard_Integer nbResEdges = -1; | |
1210 | TopTools_IndexedMapOfShape EdgeMap; | |
1211 | ||
1212 | TopExp::MapShapes(IteF.Value(), TopAbs_EDGE, EdgeMap); | |
1213 | Standard_Integer nbEdges = EdgeMap.Extent(); | |
1214 | ||
6a442250 | 1215 | if (nbEdges == 1 && !myIsOpenResult) //in case of open wire there's no need to do it |
7fd59977 | 1216 | ForcedCut = 2; |
873c119f | 1217 | // Modified by Sergey KHROMOV - Thu Nov 16 17:29:48 2000 End |
7fd59977 | 1218 | |
1219 | for (TopoDS_Iterator IteW(IteF.Value()); IteW.More(); IteW.Next()) { | |
1220 | ||
1221 | const TopoDS_Edge& E = TopoDS::Edge(IteW.Value()); | |
1222 | EdgeVertices(E,V1,V2); | |
1223 | myMapSpine.Bind(V1,V1); | |
1224 | myMapSpine.Bind(V2,V2); | |
1225 | Cuts.Clear(); | |
1226 | ||
0d969553 | 1227 | // Cut |
7fd59977 | 1228 | TopoDS_Shape aLocalShape = E.Oriented(TopAbs_FORWARD); |
873c119f | 1229 | // Modified by Sergey KHROMOV - Thu Nov 16 17:29:29 2000 Begin |
7fd59977 | 1230 | if (nbEdges == 2 && nbResEdges == 0) |
873c119f | 1231 | ForcedCut = 1; |
1232 | // Modified by Sergey KHROMOV - Thu Nov 16 17:29:33 2000 End | |
7fd59977 | 1233 | nbResEdges = CutEdge (TopoDS::Edge(aLocalShape), mySpine, ForcedCut, Cuts); |
1234 | ||
1235 | if (Cuts.IsEmpty()) { | |
873c119f | 1236 | B.Add(NW,E); |
1237 | myMapSpine.Bind(E,E); | |
7fd59977 | 1238 | } |
1239 | else { | |
873c119f | 1240 | for (IteCuts.Initialize(Cuts); IteCuts.More(); IteCuts.Next()) { |
1241 | TopoDS_Edge NE = TopoDS::Edge(IteCuts.Value()); | |
1242 | NE.Orientation(E.Orientation()); | |
1243 | B.Add(NW,NE); | |
1244 | myMapSpine.Bind(NE,E); | |
1245 | EdgeVertices(NE,V1,V2); | |
1246 | if (!myMapSpine.IsBound(V1)) myMapSpine.Bind(V1,E); | |
1247 | if (!myMapSpine.IsBound(V2)) myMapSpine.Bind(V2,E); | |
1248 | } | |
7fd59977 | 1249 | } |
1250 | } | |
873c119f | 1251 | // Modified by Sergey KHROMOV - Thu Mar 7 09:17:41 2002 Begin |
7fd59977 | 1252 | TopoDS_Vertex aV1; |
1253 | TopoDS_Vertex aV2; | |
1254 | ||
1255 | TopExp::Vertices(NW, aV1, aV2); | |
1256 | ||
1257 | NW.Closed(aV1.IsSame(aV2)); | |
873c119f | 1258 | |
1259 | // Modified by Sergey KHROMOV - Thu Mar 7 09:17:43 2002 End | |
7fd59977 | 1260 | B.Add(myWorkSpine, NW); |
1261 | } | |
1262 | ||
873c119f | 1263 | #ifdef OCCT_DEBUG |
7fd59977 | 1264 | #ifdef DRAW |
1265 | if ( AffichEdge) { | |
1896126e | 1266 | DBRep::Set("WS",myWorkSpine); |
873c119f | 1267 | DBRep::Set("MS",mySpine); |
1268 | BRepTools::Write(myWorkSpine, "WS"); | |
1269 | BRepTools::Write(mySpine, "MS"); | |
7fd59977 | 1270 | } |
1271 | #endif | |
873c119f | 1272 | #endif |
7fd59977 | 1273 | |
1274 | } | |
1275 | ||
c19dd45e | 1276 | //======================================================================= |
1277 | //function : UpdateDetromp | |
1278 | //purpose : For each interval on bissectrice defined by parameters | |
1279 | // test if the medium point is at a distance > offset | |
1280 | // in this case vertices corresponding to the extremities of the interval | |
1281 | // are ranked in the proofing. | |
1282 | // => If the same vertex appears in the proofing, the | |
1283 | // border of the zone of proximity is tangent to the offset . | |
1284 | //======================================================================= | |
1285 | ||
1286 | void BRepFill_OffsetWire::UpdateDetromp (BRepFill_DataMapOfOrientedShapeListOfShape& Detromp, | |
1287 | const TopoDS_Shape& Shape1, | |
1288 | const TopoDS_Shape& Shape2, | |
1289 | const TopTools_SequenceOfShape& Vertices, | |
1290 | const TColgp_SequenceOfPnt& Params, | |
1291 | const Bisector_Bisec& Bisec, | |
1292 | const Standard_Boolean SOnE, | |
1293 | const Standard_Boolean EOnE, | |
1294 | const BRepFill_TrimEdgeTool& Trim) const | |
1295 | { | |
c19dd45e | 1296 | Standard_Integer ii = 1; |
c19dd45e | 1297 | |
46767247 | 1298 | if (myJoinType == GeomAbs_Intersection) |
1299 | { | |
1300 | for (; ii <= Vertices.Length(); ii++) | |
1301 | { | |
1302 | const TopoDS_Vertex& aVertex = TopoDS::Vertex(Vertices.Value(ii)); | |
1303 | Detromp(Shape1).Append(aVertex); | |
1304 | Detromp(Shape2).Append(aVertex); | |
c19dd45e | 1305 | } |
c19dd45e | 1306 | } |
46767247 | 1307 | else //myJoinType == GeomAbs_Arc |
1308 | { | |
1309 | Standard_Real U1,U2; | |
1310 | TopoDS_Vertex V1,V2; | |
1311 | ||
1312 | const Handle(Geom2d_Curve)& Bis = Bisec.Value(); | |
c65f8201 | 1313 | Standard_Boolean ForceAdd = Standard_False; |
1314 | Handle(Geom2d_TrimmedCurve) aTC = Handle(Geom2d_TrimmedCurve)::DownCast(Bis); | |
1315 | if(!aTC.IsNull() && aTC->BasisCurve()->IsPeriodic()) | |
1316 | { | |
1317 | gp_Pnt2d Pf = Bis->Value(Bis->FirstParameter()); | |
1318 | gp_Pnt2d Pl = Bis->Value(Bis->LastParameter()); | |
1319 | ForceAdd = Pf.Distance(Pl) <= Precision::Confusion(); | |
1320 | } | |
1321 | ||
46767247 | 1322 | U1 = Bis->FirstParameter(); |
1323 | ||
1324 | if (SOnE) { | |
1325 | // the first point of the bissectrice is on the offset | |
1326 | V1 = TopoDS::Vertex(Vertices.Value(ii)); | |
1327 | ii++; | |
1328 | } | |
1329 | ||
1330 | while (ii <= Vertices.Length()) { | |
1331 | U2 = Params.Value(ii).X(); | |
1332 | V2 = TopoDS::Vertex(Vertices.Value(ii)); | |
1333 | ||
1334 | gp_Pnt2d P = Bis->Value((U2 + U1)*0.5); | |
c65f8201 | 1335 | if (!Trim.IsInside(P) || ForceAdd) { |
873c119f | 1336 | if (!V1.IsNull()) { |
1337 | Detromp(Shape1).Append(V1); | |
1338 | Detromp(Shape2).Append(V1); | |
1339 | } | |
46767247 | 1340 | Detromp(Shape1).Append(V2); |
1341 | Detromp(Shape2).Append(V2); | |
c19dd45e | 1342 | } |
46767247 | 1343 | U1 = U2; |
1344 | V1 = V2; | |
1345 | ii ++; | |
c19dd45e | 1346 | } |
46767247 | 1347 | |
1348 | // test medium point between the last parameter and the end of the bissectrice. | |
1349 | U2 = Bis->LastParameter(); | |
1350 | if (!EOnE) { | |
1351 | if (!Precision::IsInfinite(U2)) { | |
1352 | gp_Pnt2d P = Bis->Value((U2 + U1)*0.5); | |
c65f8201 | 1353 | if (!Trim.IsInside(P) || ForceAdd) { |
46767247 | 1354 | if (!V1.IsNull()) { |
1355 | Detromp(Shape1).Append(V1); | |
1356 | Detromp(Shape2).Append(V1); | |
1357 | } | |
1358 | } | |
c19dd45e | 1359 | } |
46767247 | 1360 | else { |
1361 | if (!V1.IsNull()) { | |
1362 | Detromp(Shape1).Append(V1); | |
1363 | Detromp(Shape2).Append(V1); | |
1364 | } | |
1365 | } | |
1366 | } | |
1367 | //else if(myJoinType != GeomAbs_Arc) | |
1368 | //{ | |
1369 | // if (!V1.IsNull()) { | |
1370 | // Detromp(Shape1).Append(V1); | |
1371 | // Detromp(Shape2).Append(V1); | |
1372 | // } | |
1373 | //} | |
1374 | } //end of else (myJoinType==GeomAbs_Arc) | |
c19dd45e | 1375 | } |
1376 | ||
7fd59977 | 1377 | //======================================================================= |
1378 | //function : MakeWires | |
1379 | //purpose : | |
1380 | //======================================================================= | |
1381 | ||
1382 | void BRepFill_OffsetWire::MakeWires() | |
1383 | { | |
1384 | //-------------------------------------------------------- | |
0d969553 | 1385 | // creation of a single list of created parallel edges. |
7fd59977 | 1386 | //-------------------------------------------------------- |
1387 | TopTools_SequenceOfShape TheEdges; | |
1388 | TopTools_ListOfShape TheWires; | |
1389 | TopTools_ListIteratorOfListOfShape itl; | |
86b3805f J |
1390 | //BRepFill_DataMapIteratorOfDataMapOfOrientedShapeListOfShape ite; |
1391 | TopTools_IndexedDataMapOfShapeListOfShape MVE; | |
1392 | //TopTools_DataMapIteratorOfDataMapOfShapeListOfShape MVEit; | |
7fd59977 | 1393 | TopoDS_Vertex V1,V2,VF,CV; |
86b3805f | 1394 | Standard_Integer i; |
7fd59977 | 1395 | |
86b3805f J |
1396 | for (i = 1; i <= myMap.Extent(); i++) { |
1397 | for (itl.Initialize(myMap(i)); itl.More(); itl.Next()) { | |
7fd59977 | 1398 | const TopoDS_Edge& E = TopoDS::Edge(itl.Value()); |
1399 | TopExp::Vertices (E,V1,V2); | |
1400 | if (V1.IsSame(V2) && IsSmallClosedEdge(E, V1)) | |
873c119f | 1401 | continue; //remove small closed edges |
7642e2d0 | 1402 | if (!CheckSmallParamOnEdge(E)) |
1403 | continue; | |
86b3805f | 1404 | if (!MVE.Contains(V1)) { |
873c119f | 1405 | TopTools_ListOfShape empty; |
1406 | MVE.Add(V1,empty); | |
7fd59977 | 1407 | } |
86b3805f J |
1408 | MVE.ChangeFromKey(V1).Append(E); |
1409 | if (!MVE.Contains(V2)) { | |
873c119f | 1410 | TopTools_ListOfShape empty; |
1411 | MVE.Add(V2,empty); | |
7fd59977 | 1412 | } |
86b3805f | 1413 | MVE.ChangeFromKey(V2).Append(E); |
7fd59977 | 1414 | } |
1415 | } | |
1416 | ||
1417 | //-------------------------------------- | |
0d969553 | 1418 | // Creation of parallel wires. |
7fd59977 | 1419 | //-------------------------------------- |
1420 | BRep_Builder B; | |
1421 | ||
873c119f | 1422 | |
1423 | // Standard_Integer NbEdges; | |
1424 | // Standard_Boolean NewWire = Standard_True; | |
1425 | // Standard_Boolean AddEdge = Standard_False; | |
7fd59977 | 1426 | |
1427 | TopoDS_Wire NW; | |
1428 | Standard_Boolean End; | |
1429 | TopoDS_Edge CE; | |
1430 | ||
1431 | while (!MVE.IsEmpty()) { | |
1432 | B.MakeWire(NW); | |
1433 | ||
86b3805f J |
1434 | //MVEit.Initialize(MVE); |
1435 | for (i = 1; i <= MVE.Extent(); i++) | |
1436 | if(MVE(i).Extent() == 1) | |
1437 | break; | |
7fd59977 | 1438 | |
86b3805f J |
1439 | //if(!MVEit.More()) MVEit.Initialize(MVE); |
1440 | if (i > MVE.Extent()) | |
1441 | i = 1; | |
7fd59977 | 1442 | |
86b3805f J |
1443 | CV = VF = TopoDS::Vertex(MVE.FindKey(i)); |
1444 | CE = TopoDS::Edge(MVE(i).First()); | |
7fd59977 | 1445 | End = Standard_False; |
1867dc32 | 1446 | MVE.ChangeFromKey(CV).RemoveFirst(); |
1447 | ||
1448 | if (myIsOpenResult && MVE.FindFromKey(CV).IsEmpty()) | |
1449 | { | |
1450 | //MVE.UnBind(CV); | |
1451 | TopoDS_Shape LastShape = MVE.FindKey(MVE.Extent()); | |
1452 | TopTools_ListOfShape LastList; | |
1453 | LastList.Append(MVE(MVE.Extent())); | |
1454 | MVE.RemoveLast(); | |
1455 | if (MVE.FindIndex(CV) != 0) | |
1456 | MVE.Substitute(MVE.FindIndex(CV), LastShape, LastList); | |
1457 | } | |
1458 | ||
7fd59977 | 1459 | |
873c119f | 1460 | // Modified by Sergey KHROMOV - Thu Mar 14 11:29:59 2002 Begin |
7fd59977 | 1461 | Standard_Boolean isClosed = Standard_False; |
873c119f | 1462 | |
1463 | // Modified by Sergey KHROMOV - Thu Mar 14 11:30:00 2002 End | |
7fd59977 | 1464 | |
1465 | while(!End) { | |
1466 | //------------------------------- | |
0d969553 | 1467 | // Construction of a wire. |
7fd59977 | 1468 | //------------------------------- |
1469 | TopExp::Vertices(CE,V1,V2); | |
1470 | if (!CV.IsSame(V1)) CV = V1; else CV = V2; | |
1471 | ||
1472 | B.Add (NW,CE); | |
1473 | ||
86b3805f | 1474 | if (VF.IsSame(CV) || !MVE.Contains(CV)) { |
873c119f | 1475 | // Modified by Sergey KHROMOV - Thu Mar 14 11:30:14 2002 Begin |
1476 | isClosed = VF.IsSame(CV); | |
1477 | // Modified by Sergey KHROMOV - Thu Mar 14 11:30:15 2002 End | |
1478 | End = Standard_True; | |
1479 | //MVE.UnBind(VF); | |
86b3805f J |
1480 | TopoDS_Shape LastShape = MVE.FindKey(MVE.Extent()); |
1481 | TopTools_ListOfShape LastList; | |
1482 | LastList.Append(MVE(MVE.Extent())); | |
1483 | MVE.RemoveLast(); | |
1484 | if (MVE.FindIndex(VF) != 0) | |
1485 | MVE.Substitute(MVE.FindIndex(VF), LastShape, LastList); | |
7fd59977 | 1486 | } |
1487 | ||
1488 | if (!End) { | |
873c119f | 1489 | if (MVE.FindFromKey(CV).Extent() > 2) { |
1490 | //cout <<"vertex on more that 2 edges in a face."<<endl; | |
1491 | } | |
1492 | for ( itl.Initialize(MVE.FindFromKey(CV)); itl.More(); itl.Next()) { | |
1493 | if (itl.Value().IsSame(CE)) { | |
1494 | MVE.ChangeFromKey(CV).Remove(itl); | |
1495 | break; | |
1496 | } | |
1497 | } | |
1498 | if (!MVE.FindFromKey(CV).IsEmpty()) { | |
1499 | CE = TopoDS::Edge(MVE.FindFromKey(CV).First()); | |
1500 | MVE.ChangeFromKey(CV).RemoveFirst(); | |
1501 | } | |
1867dc32 | 1502 | else if (myIsOpenResult)//CV was a vertex with one edge |
1503 | End = Standard_True; | |
1504 | ||
873c119f | 1505 | if (MVE.FindFromKey(CV).IsEmpty()) |
86b3805f J |
1506 | { |
1507 | //MVE.UnBind(CV); | |
1508 | TopoDS_Shape LastShape = MVE.FindKey(MVE.Extent()); | |
1509 | TopTools_ListOfShape LastList; | |
1510 | LastList.Append(MVE(MVE.Extent())); | |
1511 | MVE.RemoveLast(); | |
1512 | if (MVE.FindIndex(CV) != 0) | |
1513 | MVE.Substitute(MVE.FindIndex(CV), LastShape, LastList); | |
1514 | } | |
7fd59977 | 1515 | } |
1516 | } | |
873c119f | 1517 | // Modified by Sergey KHROMOV - Thu Mar 14 11:29:31 2002 Begin |
1518 | // NW.Closed(Standard_True); | |
7fd59977 | 1519 | NW.Closed(isClosed); |
873c119f | 1520 | // Modified by Sergey KHROMOV - Thu Mar 14 11:29:37 2002 End |
7fd59977 | 1521 | TheWires.Append(NW); |
1522 | } | |
1523 | ||
0d969553 Y |
1524 | // update myShape : |
1525 | // -- if only one wire : myShape is a Wire | |
1526 | // -- if several wires : myShape is a Compound. | |
7fd59977 | 1527 | if ( TheWires.Extent() == 1) { |
1528 | myShape = TheWires.First(); | |
1529 | } | |
1530 | else { | |
1531 | TopoDS_Compound R; | |
1532 | B.MakeCompound(R); | |
1533 | TopTools_ListIteratorOfListOfShape it(TheWires); | |
1534 | for ( ; it.More(); it.Next()) { | |
1535 | B.Add(R, it.Value()); | |
1536 | } | |
1537 | myShape = R; | |
1538 | } | |
1539 | ||
1540 | } | |
1541 | ||
1542 | //======================================================================= | |
1543 | //function : FixHoles | |
1544 | //purpose : | |
1545 | //======================================================================= | |
1546 | ||
1547 | void BRepFill_OffsetWire::FixHoles() | |
1548 | { | |
1549 | TopTools_SequenceOfShape ClosedWires, UnclosedWires, IsolatedWires; | |
1550 | ||
1551 | Standard_Real MaxTol = 0.; | |
7fd59977 | 1552 | BRep_Builder BB; |
1553 | ||
1554 | TopExp_Explorer Explo( mySpine, TopAbs_VERTEX ); | |
1555 | for (; Explo.More(); Explo.Next()) | |
91bb31f3 | 1556 | { |
1557 | const TopoDS_Vertex& aVertex = TopoDS::Vertex( Explo.Current() ); | |
1558 | Standard_Real Tol = BRep_Tool::Tolerance(aVertex); | |
1559 | if (Tol > MaxTol) | |
1560 | MaxTol = Tol; | |
1561 | } | |
7fd59977 | 1562 | MaxTol *= 100.; |
1563 | ||
1564 | Explo.Init( myShape, TopAbs_WIRE ); | |
1565 | for (; Explo.More(); Explo.Next()) | |
91bb31f3 | 1566 | { |
1567 | TopoDS_Shape aWire = Explo.Current(); | |
1568 | // Remove duplicated edges | |
1569 | TopTools_DataMapOfShapeListOfShape EEmap; | |
1570 | TopoDS_Iterator it( aWire ); | |
1571 | for (; it.More(); it.Next()) | |
7fd59977 | 1572 | { |
91bb31f3 | 1573 | const TopoDS_Shape& anEdge = it.Value(); |
1574 | if (! EEmap.IsBound( anEdge )) | |
1575 | { | |
1576 | TopTools_ListOfShape LE; | |
1577 | EEmap.Bind( anEdge, LE ); | |
1578 | } | |
7fd59977 | 1579 | else |
91bb31f3 | 1580 | EEmap(anEdge).Append( anEdge ); |
7fd59977 | 1581 | } |
91bb31f3 | 1582 | aWire.Free( Standard_True ); |
1583 | TopTools_DataMapIteratorOfDataMapOfShapeListOfShape mapit( EEmap ); | |
1584 | for (; mapit.More(); mapit.Next()) | |
1585 | { | |
1586 | const TopTools_ListOfShape& LE = mapit.Value(); | |
1587 | TopTools_ListIteratorOfListOfShape itl( LE ); | |
1588 | for (; itl.More(); itl.Next()) | |
1589 | BB.Remove( aWire, itl.Value() ); | |
1590 | } | |
1591 | // Sorting | |
1592 | if (aWire.Closed()) | |
1593 | ClosedWires.Append( aWire ); | |
1594 | else | |
1595 | UnclosedWires.Append( aWire ); | |
1596 | } | |
1597 | ||
7fd59977 | 1598 | while (!UnclosedWires.IsEmpty()) |
91bb31f3 | 1599 | { |
1600 | TopoDS_Wire& Base = TopoDS::Wire( UnclosedWires(1) ); | |
1601 | TopoDS_Vertex Vf, Vl; | |
1602 | TopExp::Vertices( Base, Vf, Vl ); | |
1603 | if(Vf.IsNull() || Vl.IsNull()) | |
873c119f | 1604 | { |
9775fa61 | 1605 | throw Standard_Failure("BRepFill_OffsetWire::FixHoles(): Wrong wire."); |
873c119f | 1606 | } |
91bb31f3 | 1607 | gp_Pnt Pf, Pl; |
1608 | Pf = BRep_Tool::Pnt(Vf); | |
1609 | Pl = BRep_Tool::Pnt(Vl); | |
1610 | Standard_Real DistF = RealLast(), DistL = RealLast(); | |
1232a766 | 1611 | Standard_Integer IndexF = 0, IndexL = 0; |
91bb31f3 | 1612 | Standard_Boolean IsFirstF = Standard_False, IsFirstL = Standard_False; |
1613 | for (Standard_Integer i = 2; i <= UnclosedWires.Length(); i++) | |
7fd59977 | 1614 | { |
91bb31f3 | 1615 | TopoDS_Wire aWire = TopoDS::Wire( UnclosedWires(i) ); |
1616 | TopoDS_Vertex V1, V2; | |
1617 | TopExp::Vertices( aWire, V1, V2 ); | |
1618 | ||
1619 | if(V1.IsNull() || V2.IsNull()) | |
873c119f | 1620 | { |
9775fa61 | 1621 | throw Standard_Failure("BRepFill_OffsetWire::FixHoles(): Wrong wire."); |
873c119f | 1622 | } |
91bb31f3 | 1623 | |
1624 | gp_Pnt P1, P2; | |
1625 | P1 = BRep_Tool::Pnt(V1); | |
1626 | P2 = BRep_Tool::Pnt(V2); | |
1627 | Standard_Real dist = Pf.Distance( P1 ); | |
1628 | if (dist < DistF) | |
1629 | { | |
1630 | DistF = dist; | |
1631 | IndexF = i; | |
1632 | IsFirstF = Standard_True; | |
1633 | } | |
1634 | dist = Pf.Distance( P2 ); | |
1635 | if (dist < DistF) | |
1636 | { | |
1637 | DistF = dist; | |
1638 | IndexF = i; | |
1639 | IsFirstF = Standard_False; | |
1640 | } | |
1641 | dist = Pl.Distance( P1 ); | |
1642 | if (dist < DistL) | |
1643 | { | |
1644 | DistL = dist; | |
1645 | IndexL = i; | |
1646 | IsFirstL = Standard_True; | |
1647 | } | |
1648 | dist = Pl.Distance( P2 ); | |
1649 | if (dist < DistL) | |
1650 | { | |
1651 | DistL = dist; | |
1652 | IndexL = i; | |
1653 | IsFirstL = Standard_False; | |
1654 | } | |
1655 | } | |
1232a766 | 1656 | if (DistF > MaxTol) |
1657 | IndexF = 0; | |
1658 | if (DistL > MaxTol) | |
1659 | IndexL = 0; | |
91bb31f3 | 1660 | TopoDS_Wire theWire; |
1661 | TopoDS_Edge theEdge; | |
1662 | TopoDS_Vertex theVertex; | |
1663 | Standard_Real CommonTol; | |
1664 | Standard_Boolean TryToClose = Standard_True; | |
1665 | if (DistF <= MaxTol && DistL <= MaxTol && IndexF == IndexL && IsFirstF == IsFirstL) | |
1666 | { | |
1667 | if (DistF < DistL) | |
1668 | { | |
1669 | DistL = RealLast(); | |
1670 | IndexL++; | |
1671 | } | |
1672 | else | |
1673 | { | |
1674 | DistF = RealLast(); | |
1675 | IndexF++; | |
1676 | } | |
1677 | TryToClose = Standard_False; | |
1678 | } | |
1679 | if (DistF <= MaxTol) | |
1680 | { | |
1681 | theWire = TopoDS::Wire( UnclosedWires(IndexF) ); | |
1682 | TopoDS_Vertex V1, V2; | |
1683 | TopExp::Vertices( theWire, V1, V2 ); | |
1684 | TopTools_IndexedDataMapOfShapeListOfShape VEmap; | |
1685 | TopExp::MapShapesAndAncestors( theWire, TopAbs_VERTEX, TopAbs_EDGE, VEmap ); | |
1686 | theEdge = (IsFirstF)? TopoDS::Edge(VEmap.FindFromKey( V1 ).First()) : | |
1687 | TopoDS::Edge(VEmap.FindFromKey( V2 ).First()); | |
1688 | TopoDS_Iterator it( theWire ); | |
1689 | for (; it.More(); it.Next()) | |
1690 | { | |
1691 | TopoDS_Edge anEdge = TopoDS::Edge( it.Value() ); | |
1692 | if (IsFirstF) anEdge.Reverse(); | |
1693 | if (!anEdge.IsSame( theEdge )) | |
1694 | BB.Add( Base, anEdge ); | |
1695 | } | |
1696 | theVertex = (IsFirstF)? V1 : V2; | |
1697 | CommonTol = Max( BRep_Tool::Tolerance(Vf), BRep_Tool::Tolerance(theVertex) ); | |
1698 | if (DistF <= CommonTol) | |
1699 | { | |
1700 | theEdge.Free( Standard_True ); | |
1701 | Vf.Orientation( theVertex.Orientation() ); | |
1702 | BB.Remove( theEdge, theVertex ); | |
1703 | BB.Add( theEdge, Vf ); | |
1704 | BB.UpdateVertex( Vf, CommonTol ); | |
1705 | if (IsFirstF) theEdge.Reverse(); | |
1706 | BB.Add( Base, theEdge ); | |
1707 | } | |
1708 | else | |
1709 | { | |
1710 | if (IsFirstF) theEdge.Reverse(); | |
1711 | BB.Add( Base, theEdge ); | |
1712 | // Creating new edge from theVertex to Vf | |
1713 | TopoDS_Edge NewEdge = BRepLib_MakeEdge( theVertex, Vf ); | |
1714 | BB.Add( Base, NewEdge ); | |
1715 | } | |
1716 | } | |
1717 | if (DistL <= MaxTol && IndexL != IndexF) | |
1718 | { | |
1719 | theWire = TopoDS::Wire( UnclosedWires(IndexL) ); | |
1720 | TopoDS_Vertex V1, V2; | |
1721 | TopExp::Vertices( theWire, V1, V2 ); | |
1722 | TopTools_IndexedDataMapOfShapeListOfShape VEmap; | |
1723 | TopExp::MapShapesAndAncestors( theWire, TopAbs_VERTEX, TopAbs_EDGE, VEmap ); | |
1724 | theEdge = (IsFirstL)? TopoDS::Edge(VEmap.FindFromKey( V1 ).First()) : | |
1725 | TopoDS::Edge(VEmap.FindFromKey( V2 ).First()); | |
1726 | TopoDS_Iterator it( theWire ); | |
1727 | for (; it.More(); it.Next()) | |
1728 | { | |
1729 | TopoDS_Edge anEdge = TopoDS::Edge( it.Value() ); | |
1730 | if (!IsFirstL) anEdge.Reverse(); | |
1731 | if (!anEdge.IsSame( theEdge )) | |
1732 | BB.Add( Base, anEdge ); | |
1733 | } | |
1734 | theVertex = (IsFirstL)? V1 : V2; | |
1735 | CommonTol = Max( BRep_Tool::Tolerance(Vl), BRep_Tool::Tolerance(theVertex) ); | |
1736 | if (DistL <= CommonTol) | |
1737 | { | |
1738 | theEdge.Free( Standard_True ); | |
1739 | Vl.Orientation( theVertex.Orientation() ); | |
1740 | BB.Remove( theEdge, theVertex ); | |
1741 | BB.Add( theEdge, Vl ); | |
1742 | BB.UpdateVertex( Vl, CommonTol ); | |
1743 | if (!IsFirstL) theEdge.Reverse(); | |
1744 | BB.Add( Base, theEdge ); | |
1745 | } | |
1746 | else | |
1747 | { | |
1748 | if (!IsFirstL) theEdge.Reverse(); | |
1749 | BB.Add( Base, theEdge ); | |
1750 | // Creating new edge from Vl to theVertex | |
1751 | TopoDS_Edge NewEdge = BRepLib_MakeEdge( Vl, theVertex ); | |
1752 | BB.Add( Base, NewEdge ); | |
1753 | } | |
1754 | } | |
1755 | // Check if it is possible to close resulting wire | |
1756 | if (TryToClose) | |
1757 | { | |
1758 | TopExp::Vertices( Base, Vf, Vl ); | |
1759 | CommonTol = Max( BRep_Tool::Tolerance(Vf), BRep_Tool::Tolerance(Vl) ); | |
1760 | TopTools_IndexedDataMapOfShapeListOfShape VEmap; | |
1761 | TopExp::MapShapesAndAncestors( Base, TopAbs_VERTEX, TopAbs_EDGE, VEmap ); | |
1762 | TopoDS_Edge Efirst, Elast; | |
1763 | Efirst = TopoDS::Edge(VEmap.FindFromKey( Vf ).First()); | |
1764 | Elast = TopoDS::Edge(VEmap.FindFromKey( Vl ).First()); | |
7fd59977 | 1765 | Pf = BRep_Tool::Pnt(Vf); |
1766 | Pl = BRep_Tool::Pnt(Vl); | |
91bb31f3 | 1767 | Standard_Real Dist = Pf.Distance(Pl); |
1768 | if (Dist <= CommonTol) | |
1769 | { | |
1770 | Elast.Free( Standard_True ); | |
1771 | Vf.Orientation( Vl.Orientation() ); | |
1772 | BB.Remove( Elast, Vl ); | |
1773 | BB.Add( Elast, Vf ); | |
1774 | BB.UpdateVertex( Vf, CommonTol ); | |
1775 | Base.Closed( Standard_True ); | |
1776 | } | |
1777 | else if (Dist <= MaxTol) | |
1778 | { | |
1779 | // Creating new edge from Vl to Vf | |
1780 | TopoDS_Edge NewEdge = BRepLib_MakeEdge( Vf, Vl ); | |
1781 | BB.Add( Base, NewEdge ); | |
1782 | Base.Closed( Standard_True ); | |
1783 | } | |
7fd59977 | 1784 | } |
91bb31f3 | 1785 | // Updating sequences ClosedWires and UnclosedWires |
1786 | if (DistF <= MaxTol) | |
1787 | UnclosedWires.Remove( IndexF ); | |
1788 | if (DistL <= MaxTol && IndexL != IndexF) | |
7fd59977 | 1789 | { |
91bb31f3 | 1790 | if (DistF <= MaxTol && IndexL > IndexF) |
1791 | IndexL--; | |
1792 | UnclosedWires.Remove( IndexL ); | |
7fd59977 | 1793 | } |
91bb31f3 | 1794 | if (Base.Closed()) |
7fd59977 | 1795 | { |
91bb31f3 | 1796 | ClosedWires.Append( Base ); |
1797 | UnclosedWires.Remove( 1 ); | |
7fd59977 | 1798 | } |
91bb31f3 | 1799 | else if (DistF > MaxTol && DistL > MaxTol) |
1800 | { | |
1801 | IsolatedWires.Append( Base ); | |
1802 | UnclosedWires.Remove( 1 ); | |
1803 | } | |
1804 | } | |
1805 | ||
1806 | // Updating myShape | |
1807 | if (ClosedWires.Length() + IsolatedWires.Length() == 1) | |
1808 | { | |
1809 | if (!ClosedWires.IsEmpty()) | |
1810 | myShape = ClosedWires.First(); | |
1811 | else | |
1812 | myShape = IsolatedWires.First(); | |
1813 | } | |
1814 | else | |
1815 | { | |
1816 | TopoDS_Compound R; | |
1817 | BB.MakeCompound( R ); | |
51740958 | 1818 | Standard_Integer i; |
91bb31f3 | 1819 | for (i = 1; i <= ClosedWires.Length(); i++) |
1820 | BB.Add( R, ClosedWires(i) ); | |
1821 | for (i = 1; i <= IsolatedWires.Length(); i++) | |
1822 | BB.Add( R, IsolatedWires(i) ); | |
1823 | myShape = R; | |
1824 | } | |
7fd59977 | 1825 | } |
1826 | ||
1827 | //======================================================================= | |
1828 | //function : CutEdge | |
0d969553 Y |
1829 | //purpose : Cut edge at the extrema of curvatures and points of inflexion. |
1830 | // So, closed circles are cut in two. | |
1831 | // If <Cuts> is empty, the edge is not modified. | |
1832 | // The first and the last vertex of the initial edge | |
1833 | // belong to the first and the last parts respectively. | |
7fd59977 | 1834 | //======================================================================= |
1835 | Standard_Integer CutEdge (const TopoDS_Edge& E, | |
873c119f | 1836 | const TopoDS_Face& F, |
1837 | Standard_Integer ForceCut, | |
1838 | TopTools_ListOfShape& Cuts) | |
7fd59977 | 1839 | { |
1840 | Cuts.Clear(); | |
1841 | MAT2d_CutCurve Cuter; | |
1842 | TColGeom2d_SequenceOfCurve theCurves; | |
1843 | Standard_Real f,l; | |
1844 | Handle(Geom2d_Curve) C2d; | |
1845 | Handle(Geom2d_TrimmedCurve) CT2d; | |
873c119f | 1846 | // Modified by Sergey KHROMOV - Wed Mar 6 17:36:25 2002 Begin |
7fd59977 | 1847 | Standard_Real aTol = BRep_Tool::Tolerance(E); |
1848 | Handle(Geom_Curve) aC; | |
873c119f | 1849 | // Modified by Sergey KHROMOV - Wed Mar 6 17:36:25 2002 End |
7fd59977 | 1850 | |
1851 | TopoDS_Vertex V1,V2,VF,VL; | |
1852 | TopExp::Vertices (E,V1,V2); | |
1853 | BRep_Builder B; | |
1854 | ||
1855 | C2d = BRep_Tool::CurveOnSurface (E,F,f,l); | |
873c119f | 1856 | // Modified by Sergey KHROMOV - Wed Mar 6 17:36:54 2002 Begin |
7fd59977 | 1857 | aC = BRep_Tool::Curve(E,f,l); |
873c119f | 1858 | // Modified by Sergey KHROMOV - Wed Mar 6 17:36:54 2002 End |
7fd59977 | 1859 | CT2d = new Geom2d_TrimmedCurve(C2d,f,l); |
1860 | //if (E.Orientation() == TopAbs_REVERSED) CT2d->Reverse(); | |
1861 | ||
1862 | if (CT2d->BasisCurve()->IsKind(STANDARD_TYPE(Geom2d_Circle)) && | |
873c119f | 1863 | ( Abs(f-l) >= M_PI) ) { |
1864 | return 0; | |
7fd59977 | 1865 | } |
1866 | ||
1867 | //------------------------- | |
0d969553 | 1868 | // Cut curve. |
7fd59977 | 1869 | //------------------------- |
1870 | Cuter.Perform(CT2d); | |
1871 | ||
873c119f | 1872 | // Modified by Sergey KHROMOV - Thu Nov 16 17:28:29 2000 Begin |
7fd59977 | 1873 | if (ForceCut == 0) { |
1874 | if (Cuter.UnModified()) { | |
873c119f | 1875 | //----------------------------- |
1876 | // edge not modified => return. | |
1877 | //----------------------------- | |
7fd59977 | 1878 | return 0; |
1879 | } else { | |
1880 | for (Standard_Integer k = 1; k <= Cuter.NbCurves(); k++) | |
873c119f | 1881 | theCurves.Append(Cuter.Value(k)); |
7fd59977 | 1882 | } |
1883 | } else if (ForceCut == 1) { | |
1884 | if (Cuter.UnModified()) { | |
1885 | CutCurve (CT2d, 2, theCurves); | |
1886 | } else { | |
1887 | for (Standard_Integer k = 1; k <= Cuter.NbCurves(); k++) | |
873c119f | 1888 | |
1889 | theCurves.Append(Cuter.Value(k)); | |
7fd59977 | 1890 | } |
1891 | } else if (ForceCut == 2) { | |
1892 | if (Cuter.UnModified()) { | |
1893 | CutCurve (CT2d, 3, theCurves); | |
1894 | } else { | |
1895 | if (Cuter.NbCurves() == 2) { | |
873c119f | 1896 | |
1897 | Handle(Geom2d_TrimmedCurve)CC = Cuter.Value(1); | |
1898 | ||
1899 | if (CC->LastParameter() > (l+f)/2.) { | |
1900 | CutCurve (CC, 2, theCurves); | |
1901 | theCurves.Append(Cuter.Value(2)); | |
1902 | } else { | |
1903 | theCurves.Append(CC); | |
1904 | CutCurve (Cuter.Value(2), 2, theCurves); | |
1905 | } | |
7fd59977 | 1906 | } else { |
873c119f | 1907 | for (Standard_Integer k = 1; k <= Cuter.NbCurves(); k++) |
1908 | theCurves.Append(Cuter.Value(k)); | |
7fd59977 | 1909 | } |
1910 | } | |
1911 | } | |
873c119f | 1912 | |
1913 | // Modified by Sergey KHROMOV - Thu Nov 16 17:28:37 2000 End | |
7fd59977 | 1914 | |
1915 | //-------------------------------------- | |
0d969553 | 1916 | // Creation of cut edges. |
7fd59977 | 1917 | //-------------------------------------- |
1918 | VF = V1; | |
1919 | ||
1920 | for (Standard_Integer k = 1; k <= theCurves.Length(); k++) { | |
1921 | ||
1922 | Handle(Geom2d_TrimmedCurve)CC = Handle(Geom2d_TrimmedCurve)::DownCast(theCurves.Value(k)); | |
1923 | ||
1924 | if (k == theCurves.Length()) {VL = V2;} | |
1925 | else { | |
873c119f | 1926 | // Modified by Sergey KHROMOV - Wed Mar 6 17:38:02 2002 Begin |
7fd59977 | 1927 | gp_Pnt P = aC->Value(CC->LastParameter()); |
1928 | ||
1929 | VL = BRepLib_MakeVertex(P); | |
1930 | B.UpdateVertex(VL, aTol); | |
873c119f | 1931 | // Modified by Sergey KHROMOV - Wed Mar 6 17:38:05 2002 End |
7fd59977 | 1932 | } |
1933 | TopoDS_Shape aLocalShape = E.EmptyCopied(); | |
1934 | TopoDS_Edge NE = TopoDS::Edge(aLocalShape); | |
873c119f | 1935 | // TopoDS_Edge NE = TopoDS::Edge(E.EmptyCopied()); |
7fd59977 | 1936 | NE.Orientation(TopAbs_FORWARD); |
1937 | B.Add (NE,VF.Oriented(TopAbs_FORWARD)); | |
1938 | B.Add (NE,VL.Oriented(TopAbs_REVERSED)); | |
1939 | B.Range(NE,CC->FirstParameter(),CC->LastParameter()); | |
1940 | Cuts.Append(NE.Oriented(E.Orientation())); | |
1941 | VF = VL; | |
1942 | } | |
1943 | ||
1944 | return theCurves.Length(); | |
1945 | } | |
1946 | ||
1947 | // Modified by Sergey KHROMOV - Thu Nov 16 17:27:56 2000 Begin | |
1948 | //======================================================================= | |
1949 | //function : CutCurve | |
1950 | //purpose : | |
1951 | //======================================================================= | |
1952 | ||
1953 | void CutCurve (const Handle(Geom2d_TrimmedCurve)& C, | |
873c119f | 1954 | const Standard_Integer nbParts, |
1955 | TColGeom2d_SequenceOfCurve& theCurves) | |
7fd59977 | 1956 | { |
1957 | Handle(Geom2d_TrimmedCurve) TrimC; | |
1958 | Standard_Real UF,UL,UC; | |
1959 | Standard_Real Step; | |
1960 | gp_Pnt2d PF,PL,PC; | |
1961 | Standard_Real PTol = Precision::PConfusion()*10; | |
1962 | Standard_Real Tol = Precision::Confusion()*10; | |
1963 | Standard_Boolean YaCut = Standard_False; | |
1964 | ||
1965 | UF = C->FirstParameter(); | |
1966 | UL = C->LastParameter (); | |
1967 | PF = C->Value(UF); | |
1968 | PL = C->Value(UL); | |
1969 | ||
1970 | Step = (UL - UF)/nbParts; | |
1971 | ||
1972 | for (Standard_Integer i = 1; i < nbParts; i++) { | |
1973 | ||
1974 | UC = UF + i*Step; | |
1975 | PC = C->Value(UC); | |
1976 | ||
1977 | if (UC - UF > PTol && PC.Distance(PF) > Tol) { | |
1978 | if ( UL - UC < PTol || PL.Distance(PC) < Tol) | |
873c119f | 1979 | continue; |
7fd59977 | 1980 | |
1981 | TrimC = new Geom2d_TrimmedCurve(C,UF,UC); | |
1982 | theCurves.Append(TrimC); | |
1983 | UF = UC; | |
1984 | PF = PC; | |
1985 | YaCut = Standard_True; | |
1986 | } | |
1987 | } | |
1988 | if (YaCut) { | |
1989 | TrimC = new Geom2d_TrimmedCurve(C,UF,UL); | |
1990 | theCurves.Append(TrimC); | |
1991 | } else | |
1992 | theCurves.Append(C); | |
1993 | } | |
1994 | // Modified by Sergey KHROMOV - Thu Nov 16 17:28:13 2000 End | |
1995 | ||
1996 | //======================================================================= | |
1997 | //function : MakeCircle | |
1998 | //purpose : | |
1999 | //======================================================================= | |
2000 | ||
2001 | void MakeCircle (const TopoDS_Edge& E, | |
873c119f | 2002 | const TopoDS_Vertex& V, |
2003 | const TopoDS_Face& F, | |
2004 | const Standard_Real Offset, | |
2005 | BRepFill_IndexedDataMapOfOrientedShapeListOfShape& Map, | |
2006 | const Handle(Geom_Plane)& RefPlane) | |
7fd59977 | 2007 | { |
0d969553 | 2008 | // evaluate the Axis of the Circle. |
7fd59977 | 2009 | Standard_Real f,l; |
2010 | Handle(Geom2d_Curve) GC = BRep_Tool::CurveOnSurface(E,F,f,l); | |
2011 | gp_Vec2d DX; | |
2012 | gp_Pnt2d P; | |
2013 | ||
2014 | if (E.Orientation() == TopAbs_FORWARD) { | |
2015 | GC->D1(l,P,DX); | |
2016 | DX.Reverse(); | |
2017 | } | |
2018 | else GC->D1(f,P,DX); | |
2019 | ||
2020 | gp_Ax2d Axis(P,gp_Dir2d(DX)); | |
2021 | Handle(Geom2d_Circle) Circ | |
2022 | = new Geom2d_Circle(Axis, Abs(Offset), Offset < 0.); | |
2023 | ||
2024 | // Bind the edges in my Map. | |
2025 | TopoDS_Edge OE = BRepLib_MakeEdge(Circ, RefPlane); | |
2026 | TopTools_ListOfShape LL; | |
2027 | ||
2028 | LL.Append(OE); | |
86b3805f | 2029 | Map.Add(V,LL); |
7fd59977 | 2030 | |
873c119f | 2031 | #ifdef OCCT_DEBUG |
7fd59977 | 2032 | #ifdef DRAW |
2033 | if ( AffichGeom && !OE.IsNull()) { | |
1896126e | 2034 | char name[256]; |
7fd59977 | 2035 | sprintf(name,"OFFSET_%d",++NbOFFSET); |
2036 | DBRep::Set(name,OE); | |
2037 | } | |
2038 | #endif | |
873c119f | 2039 | #endif |
7fd59977 | 2040 | } |
2041 | ||
2042 | //======================================================================= | |
2043 | //function : MakeOffset | |
2044 | //purpose : | |
2045 | //======================================================================= | |
2046 | ||
2047 | void MakeOffset (const TopoDS_Edge& E, | |
873c119f | 2048 | const TopoDS_Face& F, |
2049 | const Standard_Real Offset, | |
2050 | BRepFill_IndexedDataMapOfOrientedShapeListOfShape& Map, | |
2051 | const Handle(Geom_Plane)& RefPlane, | |
2052 | const Standard_Boolean IsOpenResult, | |
c7806cb6 | 2053 | const GeomAbs_JoinType theJoinType, |
873c119f | 2054 | const TopoDS_Vertex * Ends) |
7fd59977 | 2055 | { |
2056 | Standard_Real f,l; | |
2057 | Standard_Real anOffset = Offset; | |
2058 | ||
2059 | if (E.Orientation() == TopAbs_REVERSED) anOffset *= -1; | |
2060 | ||
2061 | Handle(Geom2d_Curve) G2d = BRep_Tool::CurveOnSurface(E,F,f,l); | |
2062 | Handle(Geom2d_Curve) G2dOC; | |
2063 | ||
6a442250 | 2064 | Standard_Boolean ToExtendFirstPar = Standard_True; |
2065 | Standard_Boolean ToExtendLastPar = Standard_True; | |
2066 | if (IsOpenResult) | |
2067 | { | |
2068 | TopoDS_Vertex V1, V2; | |
2069 | TopExp::Vertices(E, V1, V2); | |
2070 | if (V1.IsSame(Ends[0]) || | |
873c119f | 2071 | V1.IsSame(Ends[1])) |
6a442250 | 2072 | ToExtendFirstPar = Standard_False; |
2073 | if (V2.IsSame(Ends[0]) || | |
873c119f | 2074 | V2.IsSame(Ends[1])) |
6a442250 | 2075 | ToExtendLastPar = Standard_False; |
2076 | } | |
2077 | ||
7fd59977 | 2078 | Geom2dAdaptor_Curve AC(G2d,f,l); |
2079 | if ( AC.GetType() == GeomAbs_Circle) { | |
0d969553 Y |
2080 | // if the offset is greater otr equal to the radius and the side of the |
2081 | // concavity of the circle => edge null. | |
7fd59977 | 2082 | gp_Circ2d C1(AC.Circle()); |
7fd59977 | 2083 | gp_Ax22d axes( C1.Axis()); |
2084 | gp_Dir2d Xd = axes.XDirection(); | |
2085 | gp_Dir2d Yd = axes.YDirection(); | |
2086 | Standard_Real Crossed = Xd.X()*Yd.Y()-Xd.Y()*Yd.X(); | |
2087 | Standard_Real Signe = ( Crossed > 0.) ? 1. : -1.; | |
2088 | ||
9ffd84ad | 2089 | if (anOffset*Signe < AC.Circle().Radius() - Precision::Confusion()) { |
0d969553 | 2090 | |
7fd59977 | 2091 | Handle(Geom2dAdaptor_HCurve) AHC = |
873c119f | 2092 | new Geom2dAdaptor_HCurve(G2d); |
5201d3e6 | 2093 | Adaptor2d_OffsetCurve Off(AHC,-anOffset); |
7fd59977 | 2094 | Handle(Geom2d_Circle) CC = new Geom2d_Circle(Off.Circle()); |
2095 | ||
c6541a0c | 2096 | Standard_Real Delta = 2*M_PI - l + f; |
c7806cb6 | 2097 | if (theJoinType == GeomAbs_Arc) |
2098 | { | |
873c119f | 2099 | if (ToExtendFirstPar) |
2100 | f -= 0.2*Delta; | |
2101 | if (ToExtendLastPar) | |
2102 | l += 0.2*Delta; | |
c7806cb6 | 2103 | } |
2104 | else //GeomAbs_Intersection | |
2105 | { | |
2106 | if (ToExtendFirstPar && ToExtendLastPar) | |
2107 | { | |
2108 | Standard_Real old_l = l; | |
2109 | f = old_l + Delta/2.; | |
2110 | l = f + 2*M_PI; | |
2111 | } | |
2112 | else if (ToExtendFirstPar) | |
2113 | { | |
2114 | f = l; | |
2115 | l = f + 2*M_PI; | |
2116 | } | |
2117 | else if (ToExtendLastPar) | |
2118 | { | |
2119 | l = f + 2*M_PI; | |
2120 | } | |
2121 | } | |
7fd59977 | 2122 | G2dOC = new Geom2d_TrimmedCurve(CC,f,l); |
2123 | } | |
2124 | } | |
2125 | else if (AC.GetType() == GeomAbs_Line) { | |
2126 | Handle(Geom2dAdaptor_HCurve) AHC = | |
2127 | new Geom2dAdaptor_HCurve(G2d); | |
5201d3e6 | 2128 | Adaptor2d_OffsetCurve Off(AHC,anOffset); |
7fd59977 | 2129 | Handle(Geom2d_Line) CC = new Geom2d_Line(Off.Line()); |
2130 | Standard_Real Delta = (l - f); | |
6a442250 | 2131 | if (ToExtendFirstPar) |
c7806cb6 | 2132 | { |
2133 | if (theJoinType == GeomAbs_Arc) | |
873c119f | 2134 | f -= Delta; |
c7806cb6 | 2135 | else //GeomAbs_Intersection |
2136 | f = -Precision::Infinite(); | |
2137 | } | |
6a442250 | 2138 | if (ToExtendLastPar) |
c7806cb6 | 2139 | { |
2140 | if (theJoinType == GeomAbs_Arc) | |
873c119f | 2141 | l += Delta; |
c7806cb6 | 2142 | else //GeomAbs_Intersection |
2143 | l = Precision::Infinite(); | |
2144 | } | |
7fd59977 | 2145 | G2dOC = new Geom2d_TrimmedCurve(CC,f,l); |
2146 | } | |
2147 | else { | |
2148 | ||
2149 | anOffset = -anOffset; | |
2150 | Handle(Geom2d_TrimmedCurve) G2dT = new Geom2d_TrimmedCurve(G2d,f,l); | |
2151 | G2dOC = new Geom2d_OffsetCurve( G2dT, anOffset); | |
2152 | ||
2153 | } | |
2154 | ||
2155 | // Bind the edges in my Map. | |
2156 | if (!G2dOC.IsNull()) { | |
2157 | TopoDS_Edge OE = BRepLib_MakeEdge(G2dOC, RefPlane); | |
2158 | OE.Orientation(E.Orientation()); | |
2159 | TopTools_ListOfShape LL; | |
2160 | LL.Append(OE); | |
86b3805f | 2161 | Map.Add(E,LL); |
7fd59977 | 2162 | |
873c119f | 2163 | #ifdef OCCT_DEBUG |
7fd59977 | 2164 | #ifdef DRAW |
2165 | if (AffichGeom && !OE.IsNull()) { | |
1896126e | 2166 | char name[256]; |
7fd59977 | 2167 | sprintf(name,"OFFSET_%d",++NbOFFSET); |
2168 | DBRep::Set(name,OE); | |
873c119f | 2169 | //Standard_Real ii = 0; |
7fd59977 | 2170 | } |
2171 | #endif | |
873c119f | 2172 | #endif |
2173 | ||
7fd59977 | 2174 | } |
2175 | } | |
2176 | ||
7fd59977 | 2177 | |
2178 | //======================================================================= | |
2179 | //function : VertexFromNode | |
2180 | //purpose : | |
2181 | //======================================================================= | |
2182 | ||
2183 | Standard_Boolean VertexFromNode (const Handle(MAT_Node)& aNode, | |
873c119f | 2184 | const Standard_Real Offset, |
2185 | gp_Pnt2d& PN, | |
2186 | BRepFill_DataMapOfNodeShape& MapNodeVertex, | |
2187 | TopoDS_Vertex& VN) | |
7fd59977 | 2188 | { |
2189 | Standard_Boolean Status; | |
2190 | Standard_Real Tol = Precision::Confusion(); | |
2191 | BRep_Builder B; | |
2192 | ||
2193 | if (!aNode->Infinite() && Abs(aNode->Distance()-Offset) < Tol) { | |
2194 | //------------------------------------------------ | |
0d969553 | 2195 | // the Node gives a vertex on the offset |
7fd59977 | 2196 | //------------------------------------------------ |
2197 | if (MapNodeVertex.IsBound(aNode)) { | |
2198 | VN = TopoDS::Vertex(MapNodeVertex(aNode)); | |
2199 | } | |
2200 | else { | |
2201 | gp_Pnt P(PN.X(),PN.Y(),0.); | |
2202 | B.MakeVertex (VN); | |
2203 | B.UpdateVertex(VN,P, Precision::Confusion()); | |
2204 | MapNodeVertex.Bind(aNode,VN); | |
2205 | } | |
2206 | Status = Standard_True; | |
2207 | } | |
2208 | else Status = Standard_False; | |
2209 | ||
2210 | return Status; | |
2211 | } | |
2212 | ||
2213 | ||
2214 | //======================================================================= | |
2215 | //function : StoreInMap | |
2216 | //purpose : | |
2217 | //======================================================================= | |
2218 | ||
2219 | void StoreInMap (const TopoDS_Shape& V1, | |
873c119f | 2220 | const TopoDS_Shape& V2, |
2221 | TopTools_IndexedDataMapOfShapeShape& MapVV) | |
7fd59977 | 2222 | { |
2223 | TopoDS_Shape OldV = V1, NewV = V2; | |
2224 | Standard_Integer i; | |
2225 | ||
2226 | if (MapVV.Contains(V2)) | |
2227 | NewV = MapVV.FindFromKey(V2); | |
2228 | ||
2229 | if (MapVV.Contains(V1)) | |
2230 | MapVV.ChangeFromKey(V1) = NewV; | |
2231 | ||
2232 | for (i = 1; i <= MapVV.Extent(); i++) | |
2233 | if (MapVV(i).IsSame(V1)) | |
2234 | MapVV(i) = NewV; | |
2235 | ||
2236 | MapVV.Add(V1, NewV); | |
2237 | } | |
2238 | ||
2239 | //======================================================================= | |
2240 | //function : TrimEdge | |
2241 | //purpose : | |
2242 | //======================================================================= | |
2243 | ||
2244 | void TrimEdge (const TopoDS_Edge& E, | |
e11c1bc4 | 2245 | const TopoDS_Shape& ProE, |
2246 | const TopoDS_Face& AllSpine, | |
7fd59977 | 2247 | const TopTools_ListOfShape& Detromp, |
6a442250 | 2248 | TopTools_SequenceOfShape& TheVer, |
2249 | TColStd_SequenceOfReal& ThePar, | |
2250 | TopTools_SequenceOfShape& S, | |
2251 | TopTools_IndexedDataMapOfShapeShape& MapVV, | |
2252 | const Standard_Integer IndOfE) | |
7fd59977 | 2253 | { |
2254 | Standard_Boolean Change = Standard_True; | |
2255 | BRep_Builder TheBuilder; | |
2256 | S.Clear(); | |
2257 | ||
2258 | //----------------------------------------------------------- | |
0d969553 | 2259 | // Parse two sequences depending on the parameter on the edge. |
7fd59977 | 2260 | //----------------------------------------------------------- |
2261 | while (Change) { | |
2262 | Change = Standard_False; | |
2263 | for (Standard_Integer i = 1; i < ThePar.Length(); i++) { | |
2264 | if (ThePar.Value(i) > ThePar.Value(i+1)) { | |
873c119f | 2265 | ThePar.Exchange(i,i+1); |
2266 | TheVer.Exchange(i,i+1); | |
2267 | Change = Standard_True; | |
7fd59977 | 2268 | } |
2269 | } | |
2270 | } | |
2271 | ||
2272 | //---------------------------------------------------------- | |
0d969553 | 2273 | // If a vertex is not in the proofing, it is eliminated. |
7fd59977 | 2274 | //---------------------------------------------------------- |
2275 | if (!BRep_Tool::Degenerated(E)) { | |
2276 | for (Standard_Integer k = 1; k <= TheVer.Length(); k ++) { | |
2277 | if ( DoubleOrNotInside (Detromp, | |
873c119f | 2278 | TopoDS::Vertex(TheVer.Value(k)))) { |
2279 | TheVer.Remove(k); | |
2280 | ThePar.Remove(k); | |
2281 | k--; | |
7fd59977 | 2282 | } |
2283 | } | |
2284 | } | |
2285 | ||
2286 | //---------------------------------------------------------- | |
0d969553 Y |
2287 | // If a vertex_double appears twice in the proofing |
2288 | // the vertex is removed. | |
2289 | // otherwise preserve only one of its representations. | |
7fd59977 | 2290 | //---------------------------------------------------------- |
2291 | if (!BRep_Tool::Degenerated(E)) { | |
94f71cad | 2292 | Standard_Real aParTol = 2.0 * Precision::PConfusion(); |
7fd59977 | 2293 | for (Standard_Integer k = 1; k < TheVer.Length(); k ++) { |
2294 | if (TheVer.Value(k).IsSame(TheVer.Value(k+1)) || | |
94f71cad | 2295 | Abs(ThePar.Value(k)-ThePar.Value(k+1)) <= aParTol) { |
873c119f | 2296 | |
2297 | if(k+1 == TheVer.Length()) { | |
2298 | StoreInMap(TheVer(k), TheVer(k+1), MapVV); | |
2299 | TheVer.Remove(k); | |
2300 | ThePar.Remove(k); | |
2301 | } | |
2302 | else { | |
2303 | StoreInMap(TheVer(k+1), TheVer(k), MapVV); | |
2304 | TheVer.Remove(k+1); | |
2305 | ThePar.Remove(k+1); | |
2306 | } | |
2307 | /* | |
2308 | if ( DoubleOrNotInside (Detromp, | |
2309 | TopoDS::Vertex(TheVer.Value(k)))) { | |
2310 | TheVer.Remove(k); | |
2311 | ThePar.Remove(k); | |
2312 | k--; | |
2313 | } | |
2314 | */ | |
2315 | k--; | |
7fd59977 | 2316 | } |
2317 | } | |
2318 | } | |
2319 | //----------------------------------------------------------- | |
0d969553 Y |
2320 | // Creation of edges. |
2321 | // the number of vertices should be even. The created edges | |
2322 | // go from a vertex with uneven index i to vertex i+1; | |
7fd59977 | 2323 | //----------------------------------------------------------- |
6a442250 | 2324 | if (IndOfE == 1 || IndOfE == -1) //open result and extreme edges of result |
2325 | { | |
7fd59977 | 2326 | TopoDS_Shape aLocalShape = E.EmptyCopied(); |
2327 | TopoDS_Edge NewEdge = TopoDS::Edge(aLocalShape); | |
6a442250 | 2328 | TopoDS_Vertex V1, V2; |
2329 | TopExp::Vertices(E, V1, V2); | |
2330 | Standard_Real fpar, lpar; | |
e11c1bc4 | 2331 | Handle(Geom_Surface) aPlane; |
2332 | TopLoc_Location aLoc; | |
2333 | Handle(Geom2d_Curve) PCurve; | |
2334 | BRep_Tool::CurveOnSurface(E, PCurve, aPlane, aLoc, fpar, lpar); | |
2335 | //BRep_Tool::Range(E, fpar, lpar); | |
2336 | ||
2337 | Standard_Real TrPar1, TrPar2; | |
2338 | Standard_Boolean ToTrimAsOrigin = IsInnerEdge(ProE, AllSpine, TrPar1, TrPar2); | |
2339 | ||
6a442250 | 2340 | if (IndOfE == 1) //first edge of open wire |
2341 | { | |
2342 | if (NewEdge.Orientation() == TopAbs_FORWARD) | |
2343 | { | |
e11c1bc4 | 2344 | if (ToTrimAsOrigin) |
2345 | { | |
2346 | fpar = TrPar1; | |
2347 | gp_Pnt2d TrPnt2d = PCurve->Value(fpar); | |
2348 | gp_Pnt TrPnt(TrPnt2d.X(), TrPnt2d.Y(), 0.); | |
2349 | V1 = BRepLib_MakeVertex(TrPnt); | |
2350 | } | |
6a442250 | 2351 | TheBuilder.Add(NewEdge, V1.Oriented(TopAbs_FORWARD)); |
2352 | TheBuilder.Add(NewEdge, TheVer.First().Oriented(TopAbs_REVERSED)); | |
2353 | TheBuilder.Range(NewEdge, fpar, ThePar.First()); | |
2354 | } | |
2355 | else | |
2356 | { | |
e11c1bc4 | 2357 | if (ToTrimAsOrigin) |
2358 | { | |
2359 | lpar = TrPar2; | |
2360 | gp_Pnt2d TrPnt2d = PCurve->Value(lpar); | |
2361 | gp_Pnt TrPnt(TrPnt2d.X(), TrPnt2d.Y(), 0.); | |
2362 | V2 = BRepLib_MakeVertex(TrPnt); | |
2363 | } | |
6a442250 | 2364 | TheBuilder.Add(NewEdge, TheVer.First().Oriented(TopAbs_REVERSED)); |
2365 | TheBuilder.Add(NewEdge, V2.Oriented(TopAbs_FORWARD)); | |
2366 | TheBuilder.Range(NewEdge, ThePar.First(), lpar); | |
2367 | } | |
7fd59977 | 2368 | } |
6a442250 | 2369 | else //last edge of open wire |
2370 | { | |
2371 | if (NewEdge.Orientation() == TopAbs_FORWARD) | |
2372 | { | |
e11c1bc4 | 2373 | if (ToTrimAsOrigin) |
2374 | { | |
2375 | lpar = TrPar2; | |
2376 | gp_Pnt2d TrPnt2d = PCurve->Value(lpar); | |
2377 | gp_Pnt TrPnt(TrPnt2d.X(), TrPnt2d.Y(), 0.); | |
2378 | V2 = BRepLib_MakeVertex(TrPnt); | |
2379 | } | |
6a442250 | 2380 | TheBuilder.Add(NewEdge, TheVer.First().Oriented(TopAbs_FORWARD)); |
2381 | TheBuilder.Add(NewEdge, V2.Oriented(TopAbs_REVERSED)); | |
2382 | TheBuilder.Range(NewEdge, ThePar.First(), lpar); | |
2383 | } | |
2384 | else | |
2385 | { | |
e11c1bc4 | 2386 | if (ToTrimAsOrigin) |
2387 | { | |
2388 | fpar = TrPar1; | |
2389 | gp_Pnt2d TrPnt2d = PCurve->Value(fpar); | |
2390 | gp_Pnt TrPnt(TrPnt2d.X(), TrPnt2d.Y(), 0.); | |
2391 | V1 = BRepLib_MakeVertex(TrPnt); | |
2392 | } | |
6a442250 | 2393 | TheBuilder.Add(NewEdge, V1.Oriented(TopAbs_REVERSED)); |
2394 | TheBuilder.Add(NewEdge, TheVer.First().Oriented(TopAbs_FORWARD)); | |
2395 | TheBuilder.Range(NewEdge, fpar, ThePar.First()); | |
2396 | } | |
7fd59977 | 2397 | } |
6a442250 | 2398 | S.Append(NewEdge); |
2399 | } | |
2400 | else | |
2401 | { | |
2402 | for (Standard_Integer k = 1; k < TheVer.Length(); k = k+2) { | |
2403 | TopoDS_Shape aLocalShape = E.EmptyCopied(); | |
2404 | TopoDS_Edge NewEdge = TopoDS::Edge(aLocalShape); | |
2405 | // TopoDS_Edge NewEdge = TopoDS::Edge(E.EmptyCopied()); | |
2406 | ||
2407 | if (NewEdge.Orientation() == TopAbs_REVERSED) { | |
2408 | TheBuilder.Add (NewEdge,TheVer.Value(k) .Oriented(TopAbs_REVERSED)); | |
2409 | TheBuilder.Add (NewEdge,TheVer.Value(k+1).Oriented(TopAbs_FORWARD)); | |
2410 | } | |
2411 | else { | |
2412 | TheBuilder.Add (NewEdge,TheVer.Value(k) .Oriented(TopAbs_FORWARD)); | |
2413 | TheBuilder.Add (NewEdge,TheVer.Value(k+1).Oriented(TopAbs_REVERSED)); | |
2414 | } | |
2415 | ||
2416 | ||
2417 | TheBuilder.Range(NewEdge,ThePar.Value(k),ThePar.Value(k+1)); | |
2418 | ||
873c119f | 2419 | #ifdef OCCT_DEBUG |
7fd59977 | 2420 | #ifdef DRAW |
6a442250 | 2421 | if ( AffichEdge) { |
2422 | char name[256]; | |
2423 | sprintf(name,"TRIMEDGE_%d",NbTRIMEDGES); | |
2424 | DBRep::Set(name,NewEdge); | |
2425 | } | |
2426 | if (Affich2d) { | |
2427 | TopLoc_Location L; | |
2428 | Standard_Real f,l; | |
2429 | Handle(Geom_Surface) Surf; | |
2430 | Handle(Geom2d_Curve) C; | |
2431 | BRep_Tool::CurveOnSurface(NewEdge,C,Surf,L,f,l); | |
2432 | char name[256]; | |
2433 | sprintf(name,"OFFSET2d_%d",NbTRIMEDGES++); | |
2434 | Handle(Geom2d_TrimmedCurve) C2d = new Geom2d_TrimmedCurve(C,f,l); | |
2435 | Handle(DrawTrSurf_Curve2d) dr = | |
2436 | new DrawTrSurf_Curve2d(C2d,Standard_False); | |
2437 | dr->SetColor(Draw_bleu); | |
2438 | Draw::Set(name,dr); | |
2439 | } | |
7fd59977 | 2440 | #endif |
873c119f | 2441 | #endif |
6a442250 | 2442 | S.Append(NewEdge); |
2443 | } | |
7fd59977 | 2444 | } |
2445 | } | |
2446 | ||
e11c1bc4 | 2447 | //======================================================================= |
2448 | //function : IsInnerEdge | |
2449 | //purpose : | |
2450 | //======================================================================= | |
2451 | ||
2452 | static Standard_Boolean IsInnerEdge(const TopoDS_Shape& ProE, | |
2453 | const TopoDS_Face& AllSpine, | |
2454 | Standard_Real& TrPar1, | |
2455 | Standard_Real& TrPar2) | |
2456 | { | |
2457 | if (ProE.ShapeType() != TopAbs_EDGE) | |
2458 | return Standard_False; | |
2459 | ||
2460 | TopoDS_Edge anEdge = TopoDS::Edge(ProE); | |
2461 | ||
2462 | TopTools_IndexedDataMapOfShapeListOfShape VEmap; | |
2463 | TopExp::MapShapesAndAncestors(AllSpine, TopAbs_VERTEX, TopAbs_EDGE, VEmap); | |
2464 | for (Standard_Integer i = 1; i <= VEmap.Extent(); i++) | |
2465 | { | |
2466 | const TopTools_ListOfShape& LE = VEmap(i); | |
2467 | if (LE.Extent() == 1 && anEdge.IsSame(LE.First())) | |
2468 | return Standard_False; | |
2469 | } | |
2470 | ||
2471 | BRep_Tool::Range(anEdge, TrPar1, TrPar2); | |
2472 | return Standard_True; | |
2473 | } | |
2474 | ||
2475 | ||
2476 | ||
7fd59977 | 2477 | //======================================================================= |
2478 | //function : DoubleOrNotInside | |
0d969553 | 2479 | //purpose : return True if V appears twice in LV or is not inside. |
7fd59977 | 2480 | //======================================================================= |
2481 | ||
2482 | Standard_Boolean DoubleOrNotInside (const TopTools_ListOfShape& LV, | |
873c119f | 2483 | const TopoDS_Vertex& V) |
7fd59977 | 2484 | { |
2485 | Standard_Boolean Vu = Standard_False; | |
2486 | TopTools_ListIteratorOfListOfShape it(LV); | |
2487 | ||
2488 | for ( ; it.More(); it.Next()) { | |
2489 | if (V.IsSame(it.Value())) { | |
2490 | if (Vu) return Standard_True; | |
2491 | else Vu = Standard_True; | |
2492 | } | |
2493 | } | |
2494 | if (Vu) return Standard_False; | |
2495 | else return Standard_True; | |
2496 | } | |
2497 | ||
2498 | Standard_Boolean IsSmallClosedEdge(const TopoDS_Edge& anEdge, | |
873c119f | 2499 | const TopoDS_Vertex& aVertex) |
7fd59977 | 2500 | { |
2501 | gp_Pnt PV = BRep_Tool::Pnt(aVertex); | |
2502 | gp_Pnt2d PV2d, Pfirst, Plast, Pmid; | |
2503 | PV2d.SetCoord( PV.X(), PV.Y() ); | |
2504 | ||
2505 | Handle(Geom2d_Curve) PCurve; | |
2506 | Handle( BRep_CurveRepresentation ) CurveRep = | |
2507 | ((Handle(BRep_TEdge)::DownCast(anEdge.TShape()))->Curves()).First(); | |
2508 | PCurve = CurveRep->PCurve(); | |
2509 | ||
2510 | Standard_Real fpar = (Handle(BRep_GCurve)::DownCast(CurveRep))->First(); | |
2511 | Standard_Real lpar = (Handle(BRep_GCurve)::DownCast(CurveRep))->Last(); | |
2512 | Pfirst = PCurve->Value(fpar); | |
2513 | Plast = PCurve->Value(lpar); | |
2514 | Pmid = PCurve->Value((fpar + lpar)*0.5); | |
2515 | ||
2516 | Standard_Real theTol = BRep_Tool::Tolerance(aVertex); | |
2517 | theTol *= 1.5; | |
2518 | ||
2519 | Standard_Real dist1 = Pfirst.Distance(PV2d); | |
2520 | Standard_Real dist2 = Plast.Distance(PV2d); | |
2521 | Standard_Real dist3 = Pmid.Distance(PV2d); | |
2522 | ||
2523 | if (dist1 <= theTol && dist2 <= theTol && dist3 <= theTol) | |
2524 | return Standard_True; | |
2525 | ||
2526 | return Standard_False; | |
2527 | } | |
2528 | ||
2529 | static void CheckBadEdges(const TopoDS_Face& Spine, const Standard_Real Offset, | |
873c119f | 2530 | const BRepMAT2d_BisectingLocus& Locus, |
2531 | const BRepMAT2d_LinkTopoBilo& Link, | |
2532 | TopTools_ListOfShape& BadEdges) | |
7fd59977 | 2533 | { |
2534 | ||
2535 | TopoDS_Face F = TopoDS::Face(Spine.Oriented(TopAbs_FORWARD)); | |
2536 | Standard_Real eps = Precision::Confusion(); | |
2537 | Standard_Real LimCurv = 1./Offset; | |
2538 | ||
2539 | TopTools_MapOfShape aMap; | |
2540 | ||
2541 | for (Standard_Integer ic = 1; ic <= Locus.NumberOfContours(); ic++) { | |
2542 | for (Standard_Integer ie = 1; ie <= Locus.NumberOfElts(ic); ie++) { | |
2543 | const TopoDS_Shape& SE = Link.GeneratingShape(Locus.BasicElt(ic,ie)); | |
2544 | if (SE.ShapeType() == TopAbs_EDGE) { | |
2545 | ||
873c119f | 2546 | |
2547 | if (aMap.Contains(SE)) { | |
2548 | //cout << "Edge is treated second time" << endl; | |
2549 | continue; | |
2550 | } | |
2551 | ||
2552 | ||
2553 | TopoDS_Edge E = TopoDS::Edge(SE); | |
2554 | ||
2555 | ||
2556 | Standard_Real f,l; | |
2557 | ||
2558 | ||
2559 | Handle(Geom2d_Curve) G2d = BRep_Tool::CurveOnSurface(E,F,f,l); | |
2560 | ||
2561 | ||
2562 | Geom2dAdaptor_Curve AC(G2d,f,l); | |
2563 | GeomAbs_CurveType aCType = AC.GetType(); | |
2564 | ||
2565 | ||
2566 | if(aCType != GeomAbs_Line && aCType != GeomAbs_Circle) { | |
2567 | ||
2568 | ||
2569 | Standard_Boolean reverse = Standard_False; | |
2570 | if (E.Orientation() == TopAbs_FORWARD) reverse = Standard_True; | |
2571 | ||
2572 | ||
2573 | gp_Pnt2d P, Pc; | |
2574 | gp_Dir2d N; | |
2575 | ||
2576 | ||
2577 | Geom2dLProp_CLProps2d aCLProps(G2d, 2, eps); | |
2578 | ||
2579 | ||
2580 | aCLProps.SetParameter(f); | |
2581 | if(!aCLProps.IsTangentDefined()) { | |
2582 | BadEdges.Append(SE); | |
2583 | aMap.Add(SE); | |
2584 | continue; | |
2585 | } | |
2586 | ||
2587 | ||
2588 | P = aCLProps.Value(); | |
2589 | Standard_Real Crv = aCLProps.Curvature(); | |
2590 | ||
2591 | ||
2592 | if(Crv >= eps) { | |
2593 | aCLProps.Tangent(N); | |
2594 | Standard_Real x = N.Y(), y = -N.X(); | |
2595 | N.SetCoord(x, y); | |
2596 | if (reverse) N.Reverse(); | |
2597 | aCLProps.CentreOfCurvature(Pc); | |
2598 | gp_Vec2d Dir( P, Pc ); | |
2599 | if (N.Dot(Dir) > 0.) { | |
2600 | if (LimCurv <= Crv + eps) { | |
2601 | BadEdges.Append(SE); | |
2602 | aMap.Add(SE); | |
2603 | continue; | |
2604 | } | |
2605 | } | |
2606 | } | |
2607 | ||
2608 | ||
2609 | aCLProps.SetParameter(l); | |
2610 | if(!aCLProps.IsTangentDefined()) { | |
2611 | BadEdges.Append(SE); | |
2612 | aMap.Add(SE); | |
2613 | continue; | |
2614 | } | |
2615 | ||
2616 | ||
2617 | P = aCLProps.Value(); | |
2618 | Crv = aCLProps.Curvature(); | |
2619 | ||
2620 | ||
2621 | if(Crv >= eps) { | |
2622 | aCLProps.Tangent(N); | |
2623 | Standard_Real x = N.Y(), y = -N.X(); | |
2624 | N.SetCoord(x, y); | |
2625 | if (reverse) N.Reverse(); | |
2626 | aCLProps.CentreOfCurvature(Pc); | |
2627 | gp_Vec2d Dir( P, Pc ); | |
2628 | if (N.Dot(Dir) > 0.) { | |
2629 | if (LimCurv <= Crv + eps) { | |
2630 | BadEdges.Append(SE); | |
2631 | aMap.Add(SE); | |
2632 | continue; | |
2633 | } | |
2634 | } | |
2635 | } | |
2636 | } | |
7fd59977 | 2637 | } |
2638 | } | |
2639 | } | |
2640 | } | |
2641 | ||
2642 | ||
2643 | //======================================================================= | |
2644 | //function : PerformCurve | |
2645 | //purpose : | |
2646 | //======================================================================= | |
2647 | ||
2648 | static Standard_Boolean PerformCurve (TColStd_SequenceOfReal& Parameters, | |
873c119f | 2649 | |
2650 | TColgp_SequenceOfPnt& Points, | |
2651 | const Adaptor3d_Curve& C, | |
2652 | const Standard_Real Deflection, | |
2653 | const Standard_Real U1, | |
2654 | const Standard_Real U2, | |
2655 | const Standard_Real EPSILON, | |
2656 | const Standard_Integer Nbmin) | |
7fd59977 | 2657 | { |
2658 | Standard_Real UU1 = Min(U1, U2); | |
2659 | Standard_Real UU2 = Max(U1, U2); | |
2660 | ||
2661 | gp_Pnt Pdeb, Pfin; | |
2662 | gp_Vec Ddeb,Dfin; | |
2663 | C.D1(UU1,Pdeb,Ddeb); | |
2664 | Parameters.Append(UU1); | |
2665 | Points.Append(Pdeb); | |
2666 | ||
2667 | C.D1(UU2,Pfin,Dfin); | |
91bb31f3 | 2668 | |
2669 | const Standard_Real aDelta = UU2 - UU1; | |
2670 | const Standard_Real aDist = Pdeb.Distance(Pfin); | |
2671 | ||
2672 | if((aDelta/aDist) > 5.0e-14) | |
2673 | { | |
2674 | QuasiFleche(C,Deflection*Deflection, | |
873c119f | 2675 | |
2676 | UU1,Pdeb, | |
2677 | Ddeb, | |
2678 | UU2,Pfin, | |
2679 | Dfin, | |
2680 | Nbmin, | |
2681 | EPSILON*EPSILON, | |
2682 | Parameters,Points); | |
91bb31f3 | 2683 | } |
2684 | ||
7fd59977 | 2685 | return Standard_True; |
2686 | } | |
2687 | //======================================================================= | |
2688 | //function : QuasiFleche | |
2689 | //purpose : | |
2690 | //======================================================================= | |
2691 | ||
2692 | static void QuasiFleche(const Adaptor3d_Curve& C, | |
873c119f | 2693 | |
2694 | const Standard_Real Deflection2, | |
2695 | const Standard_Real Udeb, | |
2696 | const gp_Pnt& Pdeb, | |
2697 | const gp_Vec& Vdeb, | |
2698 | const Standard_Real Ufin, | |
2699 | const gp_Pnt& Pfin, | |
2700 | const gp_Vec& Vfin, | |
2701 | const Standard_Integer Nbmin, | |
2702 | const Standard_Real Eps, | |
2703 | TColStd_SequenceOfReal& Parameters, | |
2704 | TColgp_SequenceOfPnt& Points) | |
7fd59977 | 2705 | { |
2706 | Standard_Integer Ptslength = Points.Length(); | |
2707 | Standard_Real Udelta = Ufin-Udeb; | |
2708 | gp_Pnt Pdelta; | |
2709 | gp_Vec Vdelta; | |
2710 | if (Nbmin > 2) { | |
2711 | Udelta /=(Nbmin-1); | |
2712 | C.D1(Udeb+Udelta,Pdelta,Vdelta); | |
2713 | } | |
2714 | else { | |
2715 | Pdelta = Pfin; | |
2716 | Vdelta = Vfin; | |
2717 | } | |
2718 | ||
2719 | ||
2720 | Standard_Real Norme = gp_Vec(Pdeb,Pdelta).SquareMagnitude(); | |
2721 | Standard_Real theFleche=0; | |
2722 | Standard_Boolean flecheok = Standard_False; | |
2723 | if (Norme > Eps) { | |
0d969553 | 2724 | // Evaluation of the arrow by interpolation. See IntWalk_IWalking_5.gxx |
7fd59977 | 2725 | Standard_Real N1 = Vdeb.SquareMagnitude(); |
2726 | Standard_Real N2 = Vdelta.SquareMagnitude(); | |
2727 | if (N1 > Eps && N2 > Eps) { | |
2728 | Standard_Real Normediff = | |
873c119f | 2729 | |
2730 | (Vdeb.Normalized().XYZ()-Vdelta.Normalized().XYZ()).SquareModulus(); | |
7fd59977 | 2731 | if (Normediff > Eps) { |
873c119f | 2732 | |
2733 | theFleche = Normediff*Norme/64.; | |
2734 | flecheok = Standard_True; | |
7fd59977 | 2735 | } |
2736 | } | |
2737 | } | |
2738 | if (!flecheok) { | |
2739 | gp_Pnt Pmid((Pdeb.XYZ()+Pdelta.XYZ())/2.); | |
2740 | gp_Pnt Pverif(C.Value(Udeb+Udelta/2.)); | |
2741 | theFleche = Pmid.SquareDistance(Pverif); | |
2742 | } | |
2743 | ||
2744 | if (theFleche < Deflection2) { | |
2745 | Parameters.Append(Udeb+Udelta); | |
2746 | Points.Append(Pdelta); | |
2747 | } | |
2748 | else { | |
2749 | QuasiFleche(C,Deflection2,Udeb,Pdeb, | |
873c119f | 2750 | |
2751 | Vdeb, | |
2752 | Udeb+Udelta,Pdelta, | |
2753 | Vdelta, | |
2754 | 3, | |
2755 | Eps, | |
2756 | Parameters,Points); | |
7fd59977 | 2757 | |
2758 | } | |
2759 | ||
2760 | if (Nbmin > 2) { | |
2761 | QuasiFleche(C,Deflection2,Udeb+Udelta,Pdelta, | |
873c119f | 2762 | |
2763 | Vdelta, | |
2764 | Ufin,Pfin, | |
2765 | Vfin, | |
2766 | Nbmin-(Points.Length()-Ptslength), | |
2767 | Eps, | |
2768 | Parameters,Points); | |
7fd59977 | 2769 | } |
2770 | } | |
ab87e6fc | 2771 | |
7642e2d0 | 2772 | Standard_Boolean CheckSmallParamOnEdge(const TopoDS_Edge& anEdge) |
2773 | { | |
2774 | const BRep_ListOfCurveRepresentation& aList = ((Handle(BRep_TEdge)::DownCast(anEdge.TShape()))->Curves()); | |
2775 | if (!aList.IsEmpty()) | |
2776 | { | |
2777 | Handle( BRep_CurveRepresentation ) CRep = ((Handle(BRep_TEdge)::DownCast(anEdge.TShape()))->Curves()).First(); | |
2778 | Standard_Real f = (Handle(BRep_GCurve)::DownCast(CRep))->First(); | |
2779 | Standard_Real l = (Handle(BRep_GCurve)::DownCast(CRep))->Last(); | |
2780 | if (Abs (l - f) < Precision::PConfusion()) | |
2781 | return Standard_False; | |
2782 | } | |
2783 | return Standard_True; | |
2784 | } | |
2785 | ||
2786 |