0022048: Visualization, AIS_InteractiveContext - single object selection should alway...
[occt.git] / src / ShapeAlgo / ShapeAlgo_AlgoContainer.cxx
CommitLineData
b311480e 1// Created on: 2000-02-07
2// Created by: data exchange team
973c2be1 3// Copyright (c) 2000-2014 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
b311480e 6//
d5f74e42 7// This library is free software; you can redistribute it and/or modify it under
8// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 9// by the Free Software Foundation, with special exception defined in the file
10// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11// distribution for complete text of the license and disclaimer of any warranty.
b311480e 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
7fd59977 15
7fd59977 16
17#include <BRep_Builder.hxx>
18#include <BRep_Tool.hxx>
19#include <BRepBuilderAPI_MakeEdge.hxx>
20#include <BRepBuilderAPI_MakeWire.hxx>
42cf5bc1 21#include <BRepTools.hxx>
22#include <Geom2d_BSplineCurve.hxx>
23#include <Geom_BSplineCurve.hxx>
24#include <Geom_BSplineSurface.hxx>
25#include <Geom_Curve.hxx>
26#include <Geom_Surface.hxx>
27#include <GeomInt_WLApprox.hxx>
28#include <gp_Pnt.hxx>
29#include <IntPatch_WLine.hxx>
30#include <IntSurf_LineOn2S.hxx>
31#include <IntSurf_PntOn2S.hxx>
7fd59977 32#include <Precision.hxx>
42cf5bc1 33#include <ShapeAlgo_AlgoContainer.hxx>
34#include <ShapeAlgo_ToolContainer.hxx>
35#include <ShapeAnalysis.hxx>
36#include <ShapeAnalysis_Edge.hxx>
37#include <ShapeAnalysis_Wire.hxx>
7fd59977 38#include <ShapeBuild_Edge.hxx>
39#include <ShapeConstruct.hxx>
40#include <ShapeCustom.hxx>
41#include <ShapeCustom_Surface.hxx>
42cf5bc1 42#include <ShapeExtend_WireData.hxx>
7fd59977 43#include <ShapeFix.hxx>
44#include <ShapeFix_Edge.hxx>
42cf5bc1 45#include <ShapeFix_Wire.hxx>
7fd59977 46#include <ShapeUpgrade.hxx>
47#include <ShapeUpgrade_ShapeDivideContinuity.hxx>
42cf5bc1 48#include <Standard_Type.hxx>
49#include <TColgp_Array1OfPnt.hxx>
50#include <TColgp_Array1OfPnt2d.hxx>
51#include <TColStd_Array1OfInteger.hxx>
52#include <TColStd_Array1OfReal.hxx>
7fd59977 53#include <TopExp.hxx>
42cf5bc1 54#include <TopoDS.hxx>
55#include <TopoDS_Edge.hxx>
56#include <TopoDS_Face.hxx>
57#include <TopoDS_Iterator.hxx>
58#include <TopoDS_Shape.hxx>
59#include <TopoDS_Wire.hxx>
7fd59977 60
25e59720 61IMPLEMENT_STANDARD_RTTIEXT(ShapeAlgo_AlgoContainer,Standard_Transient)
92efcf78 62
7fd59977 63//=======================================================================
64//function : ShapeAlgo_AlgoContainer
65//purpose :
66//=======================================================================
7fd59977 67ShapeAlgo_AlgoContainer::ShapeAlgo_AlgoContainer()
68{
69 myTC = new ShapeAlgo_ToolContainer;
70}
71
72//=======================================================================
73//function : ConnectNextWire
74//purpose :
75//=======================================================================
76
77Standard_Boolean ShapeAlgo_AlgoContainer::ConnectNextWire (const Handle(ShapeAnalysis_Wire)& saw,
78 const Handle(ShapeExtend_WireData)& nextsewd,
79 const Standard_Real maxtol,
80 Standard_Real& distmin,
81 Standard_Boolean& revsewd,
82 Standard_Boolean& revnextsewd) const
83{
84 distmin = 0;
85 revsewd = revnextsewd = Standard_False;
86 if (nextsewd->NbEdges() == 0) return Standard_True;
87
88 Handle(ShapeExtend_WireData) sewd = saw->WireData();
89 //add edges into empty WireData
90 if(sewd->NbEdges() == 0) {
91 sewd->Add (nextsewd);
92 return Standard_True;
93 }
94
95 Standard_Real tailhead, tailtail, headtail, headhead;
96 saw->CheckShapeConnect (tailhead, tailtail, headtail, headhead, nextsewd->Wire(), maxtol);
97 distmin = tailhead;
98 Standard_Real precision = saw->Precision();
99
100 if ( tailhead > precision && tailtail > precision &&
101 ( saw->LastCheckStatus (ShapeExtend_DONE4) ||
102 saw->LastCheckStatus (ShapeExtend_DONE3) ) ) {
103 sewd->Reverse();
104 distmin = headhead;
105 revsewd = Standard_True;
106 if (saw->LastCheckStatus (ShapeExtend_DONE3)) {
107 nextsewd->Reverse();
108 revnextsewd = Standard_True;
109 distmin = headtail;
110 }
111 }
112 else if (!saw->LastCheckStatus (ShapeExtend_FAIL) && !saw->LastCheckStatus (ShapeExtend_DONE5)) {
113 nextsewd->Reverse();
114 revnextsewd = Standard_True;
115 distmin = tailtail;
116 }
117 Standard_Boolean OK = !saw->LastCheckStatus (ShapeExtend_FAIL);
118 if (OK) sewd->Add (nextsewd);
119 return OK;
120}
121
122//=======================================================================
123//function : ApproxBSplineCurve
124//purpose :
125//=======================================================================
126
127void ShapeAlgo_AlgoContainer::ApproxBSplineCurve (const Handle(Geom_BSplineCurve)& bspline,
128 TColGeom_SequenceOfCurve& seq) const
129{
130 seq.Clear();
131 Handle(Geom_BSplineCurve) res, modifCurve;
132 TColGeom_SequenceOfCurve SCurve;
133
134 // si la BSpline est de degre 1 , on approxime .
135 // on passe par le programme des intersections ou tout le travail
136 // est deja fait !!! ( il faut faire des paquets de 30 points
137 // maximum , travailler dans un espace 0,1 pour tenir la precision)
138
139 if (bspline->Degree() != 1) {
140 seq.Append(bspline);
141 return;
142 }
143
144 // on detecte d`eventuelles cassures par la multiplicite des poles.
145 // Puis on approxime chaque "partie" de BSpline
146
147 Standard_Integer NbKnots = bspline->NbKnots();
148 Standard_Integer NbPoles = bspline->NbPoles();
149 TColgp_Array1OfPnt Poles(1,NbPoles);
150 TColStd_Array1OfReal Weigs(1,NbPoles); Weigs.Init(1.);
151 TColStd_Array1OfReal Knots(1,NbKnots);
152 TColStd_Array1OfInteger Mults(1,NbKnots);
153
154 bspline->Poles(Poles);
155 if ( bspline->IsRational()) bspline->Weights(Weigs);
156 bspline->Knots(Knots);
157 bspline->Multiplicities(Mults);
158 Standard_Integer deg = bspline->Degree();
159
160 Standard_Integer jpole = 1;
161 Standard_Integer j, PoleIndex, I1;
162 PoleIndex = 1;
163 I1 = 1;
164 for ( Standard_Integer ipole = 1; ipole < NbPoles; ipole++) {
165 if (Poles(ipole).IsEqual(Poles(ipole+1),Precision::Confusion())) {
166 if (jpole == 1) {
167 PoleIndex++;
168 }
169 else {
170 TColgp_Array1OfPnt newPoles(1,jpole);
171 TColStd_Array1OfReal newWeigs(1,jpole); Weigs.Init(1.);
172 Standard_Integer NbNew = jpole - deg + 1;
173 TColStd_Array1OfReal newKnots(1,NbNew);
174 TColStd_Array1OfInteger newMults(1,NbNew);
175 for ( j = 1; j <= NbNew; j++) {
176 newKnots(j) = Knots(I1+j-1);
177 newMults(j) = Mults(I1+j-1);
178 }
179 newMults(1) = newMults(NbNew) = deg+1;
180 for ( j = 1; j <= jpole; j++) {
181 newWeigs(j) = Weigs(PoleIndex );
182 newPoles(j) = Poles(PoleIndex++);
183 }
184
185 Handle(Geom_BSplineCurve) newC = new Geom_BSplineCurve
186 (newPoles, newWeigs, newKnots, newMults, deg);
187 SCurve.Append(newC);
188 I1 = ipole+1;
189 jpole = 1;
190 }
191 }
192 else {
193 jpole++;
194 }
195 }
196
197
198 Handle(Geom_BSplineCurve) mycurve;
199 Standard_Integer nbcurves = SCurve.Length();
200 if (nbcurves == 0) {
201 nbcurves = 1;
202 SCurve.Append(bspline);
203 }
204
205 for (Standard_Integer itab = 1; itab <= nbcurves; itab++) {
206 mycurve = Handle(Geom_BSplineCurve)::DownCast(SCurve.Value(itab));
207 jpole = mycurve->NbPoles();
208 if ( jpole > 2) {
209 TColgp_Array1OfPnt newP(1,jpole);
210 mycurve->Poles(newP);
211 Handle(IntSurf_LineOn2S) R = new IntSurf_LineOn2S();
212 Standard_Real u1,v1,u2,v2;
213 u1 = v1 = 0.;
214 u2 = v2 = 1.;
215 for( j=1; j<=jpole; j++) {
216 IntSurf_PntOn2S POn2S;
217 POn2S.SetValue(newP(j),u1,v1,u2,v2);
218 R->Add(POn2S);
219 }
220 GeomInt_WLApprox theapp3d;
221 Standard_Real Tol = Precision::Approximation();
4e14c88f 222 theapp3d.SetParameters(Tol, Tol, 4, 8, 0, 30, Standard_True);
7fd59977 223 Handle(IntPatch_WLine) WL = new IntPatch_WLine(R, Standard_False);
224 Standard_Integer indicemin = 1;
225 Standard_Integer indicemax = jpole;
226 theapp3d.Perform(WL, Standard_True, Standard_False,
227 Standard_False, indicemin, indicemax);
228 if (!theapp3d.IsDone()) {
229 modifCurve = mycurve;
230 }
231 else if (theapp3d.NbMultiCurves() != 1) {
232 modifCurve = mycurve;
233 }
234 else {
235 const AppParCurves_MultiBSpCurve& mbspc = theapp3d.Value(1);
236 Standard_Integer nbpoles = mbspc.NbPoles();
237 TColgp_Array1OfPnt tpoles(1,nbpoles);
238 mbspc.Curve(1,tpoles);
239 modifCurve = new Geom_BSplineCurve(tpoles,
240 mbspc.Knots(),
241 mbspc.Multiplicities(),
242 mbspc.Degree());
243 }
244 }
245 else {
246 modifCurve = mycurve;
247 }
248 seq.Append(modifCurve);
249 }
250}
251
252//=======================================================================
253//function : ApproxBSplineCurve
254//purpose :
255//=======================================================================
256
257void ShapeAlgo_AlgoContainer::ApproxBSplineCurve (const Handle(Geom2d_BSplineCurve)& bspline,
258 TColGeom2d_SequenceOfCurve& seq) const
259{
260 seq.Clear();
261 Handle(Geom2d_BSplineCurve) res, modifCurve;
262 TColGeom2d_SequenceOfCurve SCurve;
263
264 // si la BSpline est de degre 1 , on approxime .
265 // on passe par le programme des intersections ou tout le travail
266 // est deja fait !!! ( il faut faire des paquets de 30 points
267 // maximum , travailler dans un espace 0,1 pour tenir la precision
268 // puis reconstruire une BSpline somme des toutes les Bspline).
269
270 if (bspline->Degree() != 1) {
271 seq.Append(bspline);
272 return;
273 }
274
275 // on detecte d`eventuelles cassures par la multiplicite des poles.
276 // Puis on approxime chaque "partie" de BSpline et on reconstruit
277 // une BSpline = somme des BSplines traitees
278
279 Standard_Integer NbKnots = bspline->NbKnots();
280 Standard_Integer NbPoles = bspline->NbPoles();
281 TColgp_Array1OfPnt2d Poles(1,NbPoles);
282 TColStd_Array1OfReal Weigs(1,NbPoles); Weigs.Init(1.);
283 TColStd_Array1OfReal Knots(1,NbKnots);
284 TColStd_Array1OfInteger Mults(1,NbKnots);
285
286 bspline->Poles(Poles);
287 if ( bspline->IsRational()) bspline->Weights(Weigs);
288 bspline->Knots(Knots);
289 bspline->Multiplicities(Mults);
290 Standard_Integer deg = bspline->Degree();
291
292 Standard_Integer jpole = 1;
293 Standard_Integer j, PoleIndex, I1;
294 PoleIndex = 1;
295 I1 = 1;
296 for ( Standard_Integer ipole = 1; ipole < NbPoles; ipole++) {
297 if (Poles(ipole).IsEqual(Poles(ipole+1),Precision::PConfusion())) {
298 if (jpole == 1) {
299 PoleIndex++;
300 }
301 else {
302 TColgp_Array1OfPnt2d newPoles(1,jpole);
303 TColStd_Array1OfReal newWeigs(1,jpole); Weigs.Init(1.);
304 Standard_Integer NbNew = jpole - deg + 1;
305 TColStd_Array1OfReal newKnots(1,NbNew);
306 TColStd_Array1OfInteger newMults(1,NbNew);
307 for ( j = 1; j <= NbNew; j++) {
308 newKnots(j) = Knots(I1+j-1);
309 newMults(j) = Mults(I1+j-1);
310 }
311 newMults(1) = newMults(NbNew) = deg+1;
312 for ( j = 1; j <= jpole; j++) {
313 newWeigs(j) = Weigs(PoleIndex );
314 newPoles(j) = Poles(PoleIndex++);
315 }
316
317 Handle(Geom2d_BSplineCurve) newC = new Geom2d_BSplineCurve
318 (newPoles, newWeigs, newKnots, newMults, deg);
319 SCurve.Append(newC);
320 I1 = ipole+1;
321 jpole = 1;
322 }
323 }
324 else {
325 jpole++;
326 }
327 }
328
329
330 Handle(Geom2d_BSplineCurve) mycurve;
331 Standard_Integer nbcurves = SCurve.Length();
332 if (nbcurves == 0) {
333 nbcurves = 1;
334 SCurve.Append(bspline);
335 }
336
337 for (Standard_Integer itab = 1; itab <= nbcurves; itab++) {
338 mycurve = Handle(Geom2d_BSplineCurve)::DownCast(SCurve.Value(itab));
339 jpole = mycurve->NbPoles();
340 if ( jpole > 10) {
341 TColgp_Array1OfPnt P(1,jpole);
342 TColgp_Array1OfPnt2d newP(1,jpole);
343 mycurve->Poles(newP);
344 Handle(IntSurf_LineOn2S) R = new IntSurf_LineOn2S();
345 Standard_Real u2,v2;
346 u2 = v2 = 1.;
347 for( j=1; j<=jpole; j++) {
348 IntSurf_PntOn2S POn2S;
349 POn2S.SetValue(P(j),newP(j).X(),newP(j).Y(),u2,v2);
350 R->Add(POn2S);
351 }
352 GeomInt_WLApprox theapp3d;
353 Standard_Real Tol = Precision::PApproximation();
4e14c88f 354 theapp3d.SetParameters(Tol, Tol, 4, 8, 0, 30, Standard_True);
7fd59977 355 Handle(IntPatch_WLine) WL = new IntPatch_WLine(R, Standard_False);
356 Standard_Integer indicemin = 1;
357 Standard_Integer indicemax = jpole;
358 theapp3d.Perform(WL, Standard_False, Standard_True,
359 Standard_False, indicemin, indicemax);
360 if (!theapp3d.IsDone()) {
361 modifCurve = mycurve;
362 }
363 else if (theapp3d.NbMultiCurves() != 1) {
364 modifCurve = mycurve;
365 }
366 else {
367 const AppParCurves_MultiBSpCurve& mbspc = theapp3d.Value(1);
368 Standard_Integer nbpoles = mbspc.NbPoles();
369 TColgp_Array1OfPnt2d tpoles(1,nbpoles);
370 mbspc.Curve(1,tpoles);
371 for( j=1; j<=jpole; j++) {
372 }
373 modifCurve = new Geom2d_BSplineCurve(tpoles,
374 mbspc.Knots(),
375 mbspc.Multiplicities(),
376 mbspc.Degree());
377 }
378 }
379 else {
380 modifCurve = mycurve;
381 }
382 seq.Append(modifCurve);
383 }
384}
385
386//=======================================================================
387//function : C0ShapeToC1Shape
388//purpose :
389//=======================================================================
390
391 TopoDS_Shape ShapeAlgo_AlgoContainer::C0ShapeToC1Shape (const TopoDS_Shape& shape,
392 const Standard_Real tol) const
393{
394 ShapeUpgrade_ShapeDivideContinuity sdc(shape);
395 sdc.SetTolerance(tol);
396 sdc.SetBoundaryCriterion(GeomAbs_C1);
397 sdc.SetSurfaceCriterion(GeomAbs_C1);
398 sdc.Perform();
399 return sdc.Result();
400}
401
402//=======================================================================
403//function : ConvertSurfaceToBSpline
404//purpose :
405//=======================================================================
406
407 Handle(Geom_BSplineSurface) ShapeAlgo_AlgoContainer::ConvertSurfaceToBSpline(const Handle(Geom_Surface)& surf,
408 const Standard_Real UF,
409 const Standard_Real UL,
410 const Standard_Real VF,
411 const Standard_Real VL) const
412{
413 return ShapeConstruct::ConvertSurfaceToBSpline(surf, UF, UL, VF, VL,
414 Precision::Confusion(), GeomAbs_C1, 100,
415 Geom_BSplineSurface::MaxDegree());
416}
417
418//=======================================================================
419//function : HomoWires
420//purpose :
421//=======================================================================
422
423 Standard_Boolean ShapeAlgo_AlgoContainer::HomoWires(const TopoDS_Wire& wireIn1,
424 const TopoDS_Wire& wireIn2,
425 TopoDS_Wire& wireOut1,
426 TopoDS_Wire& wireOut2,
427 const Standard_Boolean) const
428{
429 //Standard_Boolean res = Standard_False; //szv#4:S4163:12Mar99 not needed
430 TopoDS_Iterator Cook, Perry;
431 TopoDS_Edge edge1, edge2;
432 TopLoc_Location loc1, loc2;
433// BRepBuilderAPI_MakeWire makeWire1, makeWire2;
434 ShapeExtend_WireData makeWire1, makeWire2;
435 Standard_Boolean iterCook, iterPerry;
436 Standard_Integer nEdges1, nEdges2;
437 Standard_Real length1, length2;
438 Standard_Real first1, first2;
439 Standard_Real last1, last2;
440 Standard_Real delta1, delta2;
441
442 Handle (Geom_Curve) crv1;
443 Handle (Geom_Curve) crv2;
444
445 //Standard_Boolean notEnd = Standard_True; //szv#4:S4163:12Mar99 unused
446 Standard_Integer nbCreatedEdges = 0;
447 // gka
448 //TopoDS_Vertex v11,v12,v21,v22
449 Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire();
450 sfw->Load(wireIn1);
451 sfw->FixReorder();
452 TopoDS_Wire wireIn11 = sfw->Wire() ;
453 sfw->Load(wireIn2);
454 sfw->FixReorder();
455 TopoDS_Wire wireIn22 = sfw->Wire() ;
456
457 iterCook = iterPerry = Standard_True;
458 length1 = length2 = 0.;
459 nEdges1 = nEdges2 = 0;
460 for (Cook.Initialize(wireIn11); Cook.More(); Cook.Next()) {
461 nEdges1++;
462 edge1 = TopoDS::Edge(Cook.Value());
463 crv1 = BRep_Tool::Curve(edge1, loc1, first1, last1);
464 length1 += last1 - first1;
465 }
466 for (Perry.Initialize(wireIn22); Perry.More(); Perry.Next()) {
467 nEdges2++;
468 edge2 = TopoDS::Edge(Perry.Value());
469 crv2 = BRep_Tool::Curve(edge2, loc2, first2, last2);
470 length2 += last2 - first2;
471 }
472 Standard_Real epsilon = Precision::PConfusion() * (length1 + length2);
473 if (nEdges1 == 1 && nEdges2 == 1){
474 wireOut1 = wireIn11;
475 wireOut2 = wireIn22;
476 return Standard_True; //szv#4:S4163:12Mar99 `res=` not needed
477 }
478
479 if (length1 < epsilon) {
480 Cook.Initialize(wireIn11);
481 for (Perry.Initialize(wireIn22); Perry.More(); Perry.Next()) {
482 edge1 = TopoDS::Edge(Cook.Value());
483 makeWire1.Add(edge1);
484 }
485 wireOut1 = makeWire1.Wire();
486 wireOut2 = wireIn22;
487 return Standard_True; //szv#4:S4163:12Mar99 `res=` not needed
488 }
489 if (length2 < epsilon) {
490 Perry.Initialize(wireIn22);
491 for (Cook.Initialize(wireIn11); Cook.More(); Cook.Next()) {
492 edge2 = TopoDS::Edge(Perry.Value());
493 makeWire2.Add(edge2);
494 }
495 wireOut1 = wireIn11;
496 wireOut2 = makeWire2.Wire();
497 return Standard_True; //szv#4:S4163:12Mar99 `res=` not needed
498 }
499
500
501 Standard_Real ratio = length2 / length1;
502
503 Cook.Initialize(wireIn11);
504 Perry.Initialize(wireIn22);
505 edge1 = TopoDS::Edge(Cook.Value());
506 edge2 = TopoDS::Edge(Perry.Value());
507 // essai mjm du 22/05/97
508 Standard_Boolean IsToReverse1 = Standard_False;
509 Standard_Boolean IsToReverse2 = Standard_False;
510 if (edge1.Orientation() == TopAbs_REVERSED)
511 IsToReverse1 = Standard_True;
512 if (edge2.Orientation() == TopAbs_REVERSED)
513 IsToReverse2 = Standard_True;
514 crv1 = BRep_Tool::Curve(edge1, loc1, first1, last1);
515 crv2 = BRep_Tool::Curve(edge2, loc2, first2, last2);
516 delta1 = last1 - first1;
517 delta2 = last2 - first2;
518 while (nbCreatedEdges < (nEdges1 + nEdges2-1)) { /*just a security. */
519
520 if ((delta1*ratio - delta2) > epsilon) {
521 BRepBuilderAPI_MakeEdge makeEdge1;
522 if(!IsToReverse1) {
523 makeEdge1.Init(crv1, first1, first1 + delta2/ratio);
524 first1+= delta2/ratio;
525 }
526 else { // gka BUC60685
527 makeEdge1.Init(crv1, last1 - delta2/ratio , last1);
528 last1 -= delta2/ratio;
529 }
530 BRepBuilderAPI_MakeEdge makeEdge2(crv2, first2, last2);
531 edge1 = makeEdge1.Edge();
532 edge2 = makeEdge2.Edge();
533// essai mjm du 22/05/97
534 iterCook = Standard_False;
535 //first1 += delta2/ratio;
536 delta1 = last1 - first1;
537 iterPerry = Standard_True;
538 nbCreatedEdges++;
539 }
540 else if (Abs(delta1*ratio - delta2) <= epsilon) {
541 BRepBuilderAPI_MakeEdge makeEdge1(crv1, first1, last1);
542 BRepBuilderAPI_MakeEdge makeEdge2(crv2, first2, last2);
543 edge1 = makeEdge1.Edge();
544 edge2 = makeEdge2.Edge();
545 iterCook = Standard_True;
546 iterPerry = Standard_True;
547 nbCreatedEdges += 2;
548 }
549 else /*((delta1*ratio - delta2) < -epsilon)*/ {
550 BRepBuilderAPI_MakeEdge makeEdge1(crv1, first1, last1);
551 edge1 = makeEdge1.Edge();
552 BRepBuilderAPI_MakeEdge makeEdge2;
553 if(!IsToReverse2) {
554 makeEdge2.Init(crv2, first2, first2 + delta1*ratio);
555 first2 += delta1*ratio;
556 }
557 else { // gka BUC60685
558 makeEdge2.Init(crv2, last2 - delta1*ratio, last2);
559 last2 -= delta1*ratio;
560 }
561 edge1 = makeEdge1.Edge();
562 edge2 = makeEdge2.Edge();
563 iterCook = Standard_True;
564 iterPerry = Standard_False;
565 //first2 += delta1*ratio;
566 delta2 = last2 - first2;
567 nbCreatedEdges++;
568 }
569 edge1.Move(loc1);
570 edge2.Move(loc2);
571 if ( IsToReverse1) edge1.Reverse();
572 if ( IsToReverse2) edge2.Reverse();
573 makeWire1.Add(edge1);
574 makeWire2.Add(edge2);
575
576 if (iterCook && iterPerry) {
577 TopoDS_Iterator Copernic = Cook;
578 if (Copernic.More())
579 Copernic.Next();
580 if (!Copernic.More()) {
581 wireOut1 = makeWire1.Wire();
582 wireOut2 = makeWire2.Wire();
583 return Standard_True; //szv#4:S4163:12Mar99 `res=` not needed
584 }
585 }
586 if (iterCook) {
587 Cook.Next();
588 edge1 = TopoDS::Edge(Cook.Value());
589 if (edge1.Orientation() == TopAbs_REVERSED)
590 IsToReverse1 = Standard_True;
591 else IsToReverse1 = Standard_False;
592 crv1 = BRep_Tool::Curve(edge1, loc1, first1, last1);
593 delta1 = last1 - first1;
594 }
595 if (iterPerry) {
596 Perry.Next();
597 edge2 = TopoDS::Edge(Perry.Value());
598 if (edge2.Orientation() == TopAbs_REVERSED)
599 IsToReverse2 = Standard_True;
600 else IsToReverse2 = Standard_False;
601 crv2 = BRep_Tool::Curve(edge2, loc2, first2, last2);
602 delta2 = last2 - first2;
603 }
604
605 }
606 return Standard_False; //szv#4:S4163:12Mar99 `res=` not needed
607}
608
609//=======================================================================
610//function : C0BSplineToSequenceOfC1BSplineCurve
611//purpose :
612//=======================================================================
613
614 Standard_Boolean ShapeAlgo_AlgoContainer::C0BSplineToSequenceOfC1BSplineCurve(const Handle(Geom_BSplineCurve)& BS,
615 Handle(TColGeom_HSequenceOfBoundedCurve)& seqBS) const
616{
617 return ShapeUpgrade::C0BSplineToSequenceOfC1BSplineCurve (BS, seqBS);
618}
619
620//=======================================================================
621//function : C0BSplineToSequenceOfC1BSplineCurve
622//purpose :
623//=======================================================================
624
625 Standard_Boolean ShapeAlgo_AlgoContainer::C0BSplineToSequenceOfC1BSplineCurve(const Handle(Geom2d_BSplineCurve)& BS,
626 Handle(TColGeom2d_HSequenceOfBoundedCurve)& seqBS) const
627{
628 return ShapeUpgrade::C0BSplineToSequenceOfC1BSplineCurve (BS, seqBS);
629}
630
631//=======================================================================
632//function : OuterWire
633//purpose :
634//=======================================================================
635
636TopoDS_Wire ShapeAlgo_AlgoContainer::OuterWire(const TopoDS_Face& face) const
637{
638 return ShapeAnalysis::OuterWire(face);
639}
640
641//=======================================================================
642//function : ConvertToPeriodic
643//purpose :
644//=======================================================================
645
646 Handle(Geom_Surface) ShapeAlgo_AlgoContainer::ConvertToPeriodic (const Handle(Geom_Surface)& surf) const
647{
648 ShapeCustom_Surface scs (surf);
649 return scs.ConvertToPeriodic (Standard_False);
650}
651
652//=======================================================================
653//function : GetFaceUVBounds
654//purpose :
655//=======================================================================
656
657 void ShapeAlgo_AlgoContainer::GetFaceUVBounds (const TopoDS_Face& F,
658 Standard_Real& Umin,
659 Standard_Real& Umax,
660 Standard_Real& Vmin,
661 Standard_Real& Vmax) const
662{
663 ShapeAnalysis::GetFaceUVBounds (F, Umin, Umax, Vmin, Vmax);
664}
665
666//=======================================================================
667//function : ConvertCurveToBSpline
668//purpose :
669//=======================================================================
670
671Handle(Geom_BSplineCurve) ShapeAlgo_AlgoContainer::ConvertCurveToBSpline(const Handle(Geom_Curve)& C3D,
672 const Standard_Real First,
673 const Standard_Real Last,
674 const Standard_Real Tol3d,
675 const GeomAbs_Shape Continuity,
676 const Standard_Integer MaxSegments,
677 const Standard_Integer MaxDegree) const
678{
679 return ShapeConstruct::ConvertCurveToBSpline(C3D, First, Last, Tol3d, Continuity, MaxSegments, MaxDegree);
680}