0024002: Overall code and build procedure refactoring -- automatic
[occt.git] / src / BRepMAT2d / BRepMAT2d_Explorer.cxx
CommitLineData
b311480e 1// Created on: 1994-10-04
2// Created by: Yves FRICAUD
3// Copyright (c) 1994-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
42cf5bc1 17
18#include <BRep_Builder.hxx>
19#include <BRep_Tool.hxx>
20#include <BRepBuilderAPI_MakeFace.hxx>
21#include <BRepLib.hxx>
22#include <BRepMAT2d_Explorer.hxx>
7fd59977 23#include <BRepTools_WireExplorer.hxx>
42cf5bc1 24#include <GCE2d_MakeArcOfCircle.hxx>
25#include <GCE2d_MakeSegment.hxx>
26#include <Geom2d_BezierCurve.hxx>
27#include <Geom2d_BoundedCurve.hxx>
28#include <Geom2d_BSplineCurve.hxx>
29#include <Geom2d_Circle.hxx>
30#include <Geom2d_Curve.hxx>
31#include <Geom2d_Ellipse.hxx>
32#include <Geom2d_Hyperbola.hxx>
33#include <Geom2d_Line.hxx>
34#include <Geom2d_Parabola.hxx>
7fd59977 35#include <Geom2d_TrimmedCurve.hxx>
42cf5bc1 36#include <Geom2dConvert.hxx>
37#include <Geom_Curve.hxx>
38#include <Geom_TrimmedCurve.hxx>
39#include <GeomAbs_CurveType.hxx>
7fd59977 40#include <GeomAPI.hxx>
7fd59977 41#include <gp.hxx>
42#include <gp_Pln.hxx>
42cf5bc1 43#include <MAT2d_SequenceOfSequenceOfCurve.hxx>
7fd59977 44#include <Precision.hxx>
42cf5bc1 45#include <TColGeom2d_SequenceOfCurve.hxx>
46#include <TopAbs.hxx>
7fd59977 47#include <TopExp.hxx>
42cf5bc1 48#include <TopExp_Explorer.hxx>
49#include <TopLoc_Location.hxx>
50#include <TopoDS.hxx>
51#include <TopoDS_Face.hxx>
52#include <TopoDS_Shape.hxx>
53#include <TopoDS_Wire.hxx>
7fd59977 54#include <TopTools_IndexedDataMapOfShapeShape.hxx>
42cf5bc1 55
873c119f 56//
7fd59977 57// Modified by Sergey KHROMOV - Thu Dec 5 10:38:14 2002 Begin
58static TopoDS_Edge MakeEdge(const Handle(Geom2d_Curve) &theCurve,
873c119f 59 const TopoDS_Face &theFace,
60 const TopoDS_Vertex &theVFirst,
61 const TopoDS_Vertex &theVLast);
7fd59977 62// Modified by Sergey KHROMOV - Thu Dec 5 10:38:16 2002 End
873c119f 63//
64static GeomAbs_CurveType GetCurveType(const Handle(Geom2d_Curve)& theC2d);
65static void AdjustCurveEnd(Handle(Geom2d_BoundedCurve)& theC2d, const gp_Pnt2d theP,
66 const Standard_Boolean isFirst);
67//
7fd59977 68//=======================================================================
69//function : BRepMAT2d_Explorer
70//purpose :
71//=======================================================================
72
73BRepMAT2d_Explorer::BRepMAT2d_Explorer()
74{
75 Clear();
76}
77
78//=======================================================================
79//function : BRepMAT2d_Explorer
80//purpose :
81//=======================================================================
82
83BRepMAT2d_Explorer::BRepMAT2d_Explorer(const TopoDS_Face& aFace)
84{
85 Perform (aFace);
86}
87
88//=======================================================================
89//function : Perform
90//purpose :
91//=======================================================================
92
93void BRepMAT2d_Explorer::Perform(const TopoDS_Face& aFace)
94{
95 Clear();
96 myShape = aFace;
97 TopoDS_Face F = TopoDS::Face(aFace);
98 F.Orientation(TopAbs_FORWARD);
99 TopExp_Explorer Exp (F,TopAbs_WIRE);
873c119f 100 // Modified by Sergey KHROMOV - Tue Nov 26 16:10:37 2002 Begin
7fd59977 101 Handle(Geom_Surface) aSurf = BRep_Tool::Surface(F);
1c72dff6 102 TopoDS_Face aNewF = BRepBuilderAPI_MakeFace(aSurf, Precision::Confusion());
7fd59977 103
104 while (Exp.More()) {
105 Add (TopoDS::Wire (Exp.Current()),F, aNewF);
106 Exp.Next();
107 }
108
109 BRepLib::BuildCurves3d(aNewF);
110
111 myModifShapes.Add(aFace, aNewF);
873c119f 112 // CheckConnection();
113 // Modified by Sergey KHROMOV - Tue Nov 26 16:10:38 2002 End
7fd59977 114}
115
116//=======================================================================
117//function : Add
118//purpose :
119//=======================================================================
120
121void BRepMAT2d_Explorer::Add(const TopoDS_Wire& Spine,
873c119f 122 const TopoDS_Face& aFace,
123 TopoDS_Face& aNewFace)
7fd59977 124{
873c119f 125 // Modified by Sergey KHROMOV - Tue Nov 26 14:25:46 2002 Begin
126 // This method is totally rewroted to include check
127 // of connection and creation of a new spine.
7fd59977 128 NewContour();
129 myIsClosed(currentContour) = (Spine.Closed()) ? Standard_True : Standard_False;
130
873c119f 131 // Modified by skv - Wed Jun 23 12:23:01 2004 Integration Begin
132 // Taking into account side of bisecting loci construction.
133 // TopoDS_Wire aWFwd = TopoDS::Wire(Spine.Oriented(TopAbs_FORWARD));
134 // BRepTools_WireExplorer anExp(aWFwd, aFace);
7fd59977 135 BRepTools_WireExplorer anExp(Spine, aFace);
873c119f 136 // Modified by skv - Wed Jun 23 12:23:02 2004 Integration End
7fd59977 137 TopTools_IndexedDataMapOfShapeShape anOldNewE;
138
139 if (!anExp.More())
140 return;
141
142 TopoDS_Edge aFirstEdge = anExp.Current();
873c119f 143 TopoDS_Edge aPrevEdge = aFirstEdge;
7fd59977 144 Standard_Real UFirst,ULast, aD;
7fd59977 145 Handle(Geom2d_Curve) C2d;
146 Handle(Geom2d_TrimmedCurve) CT2d;
147 Handle(Geom2d_TrimmedCurve) aFirstCurve;
148 gp_Pnt2d aPFirst;
149 gp_Pnt2d aPLast;
150 gp_Pnt2d aPCurFirst;
873c119f 151 // Modified by skv - Mon Jul 11 19:00:25 2005 Integration Begin
152 // Set the confusion tolerance in accordance with the further algo
153 // Standard_Real aTolConf = Precision::Confusion();
7fd59977 154 Standard_Real aTolConf = 1.e-8;
873c119f 155 // Modified by skv - Mon Jul 11 19:00:25 2005 Integration End
7fd59977 156 Standard_Boolean isModif = Standard_False;
157
873c119f 158 // Treatment of the first edge of a wire.
7fd59977 159 anOldNewE.Add(aFirstEdge, aFirstEdge);
160 C2d = BRep_Tool::CurveOnSurface (aFirstEdge, aFace, UFirst, ULast);
161 CT2d = new Geom2d_TrimmedCurve(C2d,UFirst,ULast);
162
163 if (aFirstEdge.Orientation() == TopAbs_REVERSED)
164 CT2d->Reverse();
165
166 aPFirst = CT2d->Value(CT2d->FirstParameter());
167 aPLast = CT2d->Value(CT2d->LastParameter());
168
169 Add(CT2d);
170 aFirstCurve = CT2d;
171 anExp.Next();
172
873c119f 173 // Treatment of the next edges:
7fd59977 174 for (; anExp.More(); anExp.Next()) {
175 TopoDS_Edge anEdge = anExp.Current();
176
177 anOldNewE.Add(anEdge, anEdge);
178 C2d = BRep_Tool::CurveOnSurface (anEdge, aFace, UFirst, ULast);
179 CT2d = new Geom2d_TrimmedCurve(C2d,UFirst,ULast);
180
181 if (anEdge.Orientation() == TopAbs_REVERSED)
182 CT2d->Reverse();
183
184 aPCurFirst = CT2d->Value(CT2d->FirstParameter());
185 //
186 aD=aPLast.Distance(aPCurFirst);
187 if (aD > aTolConf) {
188 // There are two ways how to fill holes:
189 // First, to create a line between these two points.
190 // Second, create a BSpline curve and to add the last point of the previous
191 // curve as the first pole of the current one. Second method which
192 // is worse was performed before and leaved here. Otherwise too much
193 // code should be rewritten.
194 isModif = Standard_True;
195 //
873c119f 196 Standard_Integer aNbC = theCurves.Value(currentContour).Length();
197 Handle(Geom2d_BoundedCurve) CPrev =
198 Handle(Geom2d_BoundedCurve)::DownCast(theCurves.ChangeValue(currentContour).ChangeValue(aNbC));
199 //
200 GeomAbs_CurveType TCPrev = GetCurveType(CPrev);
201 GeomAbs_CurveType TCCurr = GetCurveType(CT2d);
202 //
203 if(TCCurr <= TCPrev)
204 {
205 AdjustCurveEnd(CT2d, aPLast, Standard_True);
206 // Creation of new edge.
207 TopoDS_Edge aNewEdge;
208 TopoDS_Vertex aVf = TopExp::FirstVertex(anEdge);
209 TopoDS_Vertex aVl = TopExp::LastVertex(anEdge);
210
211 if (anEdge.Orientation() == TopAbs_FORWARD)
212 aNewEdge = MakeEdge(CT2d, aNewFace, aVf, aVl);
213 else
214 aNewEdge = MakeEdge(CT2d->Reversed(), aNewFace, aVf, aVl);
215
216 aNewEdge.Orientation(anEdge.Orientation());
217
218 anOldNewE.ChangeFromKey(anEdge) = aNewEdge;
219 }
220 else
221 {
222 gp_Pnt2d aP = CT2d->Value(CT2d->FirstParameter());
223 AdjustCurveEnd(CPrev, aP, Standard_False);
224 theCurves.ChangeValue(currentContour).ChangeValue(aNbC) = CPrev;
225 //Change previous edge
226 TopoDS_Edge aNewEdge;
227 TopoDS_Vertex aVf = TopExp::FirstVertex(aPrevEdge);
228 TopoDS_Vertex aVl = TopExp::LastVertex(aPrevEdge);
229
230 if (aPrevEdge.Orientation() == TopAbs_FORWARD)
231 aNewEdge = MakeEdge(CPrev, aNewFace, aVf, aVl);
232 else
233 aNewEdge = MakeEdge(CPrev->Reversed(), aNewFace, aVf, aVl);
234
235 aNewEdge.Orientation(aPrevEdge.Orientation());
236
237 anOldNewE.ChangeFromKey(aPrevEdge) = aNewEdge;
238
239 }
7fd59977 240
7fd59977 241 }
242
243 aPLast = CT2d->Value(CT2d->LastParameter());
244 Add(CT2d);
873c119f 245 aPrevEdge = anEdge;
7fd59977 246 }
247
248 // Check of the distance between the first and the last point of wire
249 // if the wire is closed.
873c119f 250 if (myIsClosed(currentContour) && aPLast.Distance(aPFirst) > aTolConf) {
251 isModif = Standard_True;
7fd59977 252
873c119f 253 //
254 Standard_Integer aNbC = theCurves.Value(currentContour).Length();
255 Handle(Geom2d_BoundedCurve) CPrev =
256 Handle(Geom2d_BoundedCurve)::DownCast(theCurves.ChangeValue(currentContour).ChangeValue(aNbC));
257 //
258 GeomAbs_CurveType TCPrev = GetCurveType(CPrev);
259 GeomAbs_CurveType TCCurr = GetCurveType(aFirstCurve);
260 //
261 if(TCCurr <= TCPrev)
262 {
263 AdjustCurveEnd(aFirstCurve, aPLast, Standard_True);
7fd59977 264 theCurves.ChangeValue(currentContour).ChangeValue(1) = aFirstCurve;
873c119f 265 // Creation of new edge.
7fd59977 266 TopoDS_Edge aNewEdge;
267 TopoDS_Vertex aVf = TopExp::FirstVertex(aFirstEdge);
268 TopoDS_Vertex aVl = TopExp::LastVertex(aFirstEdge);
269
270 if (aFirstEdge.Orientation() == TopAbs_FORWARD)
873c119f 271 aNewEdge = MakeEdge(aFirstCurve, aNewFace, aVf, aVl);
7fd59977 272 else
873c119f 273 aNewEdge = MakeEdge(aFirstCurve->Reversed(), aNewFace, aVf, aVl);
7fd59977 274
275 aNewEdge.Orientation(aFirstEdge.Orientation());
873c119f 276
7fd59977 277 anOldNewE.ChangeFromKey(aFirstEdge) = aNewEdge;
278 }
873c119f 279 else
280 {
281 gp_Pnt2d aP = aFirstCurve->Value(aFirstCurve->FirstParameter());
282 AdjustCurveEnd(CPrev, aP, Standard_False);
283 theCurves.ChangeValue(currentContour).ChangeValue(aNbC) = CPrev;
284 //Change previous edge
285 TopoDS_Edge aNewEdge;
286 TopoDS_Vertex aVf = TopExp::FirstVertex(aPrevEdge);
287 TopoDS_Vertex aVl = TopExp::LastVertex(aPrevEdge);
288
289 if (aPrevEdge.Orientation() == TopAbs_FORWARD)
290 aNewEdge = MakeEdge(CPrev, aNewFace, aVf, aVl);
291 else
292 aNewEdge = MakeEdge(CPrev->Reversed(), aNewFace, aVf, aVl);
293
294 aNewEdge.Orientation(aPrevEdge.Orientation());
295
296 anOldNewE.ChangeFromKey(aPrevEdge) = aNewEdge;
297
298 }
299
300 }
7fd59977 301
302 TopoDS_Wire aNewWire;
303 BRep_Builder aBuilder;
304
305 if (isModif) {
306 Standard_Integer i;
307 Standard_Integer aNbEdges = anOldNewE.Extent();
308
309 aBuilder.MakeWire(aNewWire);
310
311 for (i = 1; i <= aNbEdges; i++) {
312 const TopoDS_Shape &aKey = anOldNewE.FindKey(i);
313 const TopoDS_Shape &aNewEdge = anOldNewE.FindFromIndex(i);
314
315 aBuilder.Add(aNewWire, aNewEdge);
316 myModifShapes.Add(aKey, aNewEdge);
317 }
318
319 if (myIsClosed(currentContour))
320 aNewWire.Closed(Standard_True);
321
322 // Modified by skv - Fri Nov 12 17:22:12 2004 Integration Begin
323 // The orientation of wire is already taken into account.
324 // aNewWire.Orientation(Spine.Orientation());
325 // Modified by skv - Fri Nov 12 17:22:12 2004 Integration End
326 myModifShapes.Add(Spine, aNewWire);
327 } else
328 aNewWire = Spine;
329
330 aBuilder.Add(aNewFace, aNewWire);
873c119f 331 // Modified by Sergey KHROMOV - Tue Nov 26 14:25:53 2002 End
7fd59977 332}
333
334//=======================================================================
335//function : CheckConnection
336//purpose :
337//=======================================================================
338
339// Modified by Sergey KHROMOV - Tue Nov 26 17:21:44 2002 Begin
340// void BRepMAT2d_Explorer::CheckConnection()
341// {
342// for (Standard_Integer i = 1; i <= theCurves.Length(); i++)
343// for (Standard_Integer j = 2; j <= theCurves(i).Length(); j++)
344// {
345// gp_Pnt2d P1 = theCurves(i)(j-1)->Value( theCurves(i)(j-1)->LastParameter() );
346// gp_Pnt2d P2 = theCurves(i)(j)->Value( theCurves(i)(j)->FirstParameter() );
347// if (P1.Distance( P2 ) > Precision::Confusion())
348// {
349// Handle( Geom2d_BSplineCurve ) BCurve;
350// if (theCurves(i)(j)->DynamicType() != STANDARD_TYPE(Geom2d_BSplineCurve))
351// BCurve = Geom2dConvert::CurveToBSplineCurve( theCurves(i)(j) );
352// else
353// BCurve = Handle( Geom2d_BSplineCurve )::DownCast( theCurves(i)(j) );
354// BCurve->SetPole( 1, P1 );
355// theCurves(i)(j) = new Geom2d_TrimmedCurve( BCurve, BCurve->FirstParameter(), BCurve->LastParameter() );
356// }
357// }
358// }
359// Modified by Sergey KHROMOV - Tue Nov 26 17:21:29 2002 End
360
361//=======================================================================
362//function : Clear
363//purpose :
364//=======================================================================
365
366void BRepMAT2d_Explorer::Clear()
367{
368 theCurves.Clear() ;
369 currentContour = 0;
873c119f 370 // Modified by Sergey KHROMOV - Wed Mar 6 16:07:55 2002 Begin
7fd59977 371 myIsClosed.Clear();
372 myModifShapes.Clear();
873c119f 373 // Modified by Sergey KHROMOV - Wed Mar 6 16:07:55 2002 End
7fd59977 374}
375
376
377//=======================================================================
378//function : NewContour
379//purpose :
380//=======================================================================
381
382void BRepMAT2d_Explorer::NewContour()
383{
384 TColGeom2d_SequenceOfCurve Contour;
385 theCurves.Append(Contour);
873c119f 386 // Modified by Sergey KHROMOV - Wed Mar 6 16:12:05 2002 Begin
7fd59977 387 myIsClosed.Append(Standard_False);
873c119f 388 // Modified by Sergey KHROMOV - Wed Mar 6 16:12:05 2002 End
7fd59977 389 currentContour ++ ;
390}
391
392
393//=======================================================================
394//function : Add
395//purpose :
396//=======================================================================
397
398void BRepMAT2d_Explorer::Add(const Handle(Geom2d_Curve)& aCurve)
399{
400 theCurves.ChangeValue(currentContour).Append(aCurve);
401}
402
403//=======================================================================
404//function : NumberOfContours
405//purpose :
406//=======================================================================
407
408Standard_Integer BRepMAT2d_Explorer::NumberOfContours() const
409{
410 return theCurves.Length() ;
411}
412
413
414//=======================================================================
415//function : NumberOfCurves
416//purpose :
417//=======================================================================
418
419Standard_Integer BRepMAT2d_Explorer::NumberOfCurves
420 (const Standard_Integer IndexContour)
873c119f 421 const
7fd59977 422{
423 return theCurves.Value(IndexContour).Length();
424}
425
426
427//=======================================================================
428//function : Init
429//purpose :
430//=======================================================================
431
432void BRepMAT2d_Explorer::Init(const Standard_Integer IndexContour)
433{
434 currentContour = IndexContour;
435 current = 1;
436}
437
438
439//=======================================================================
440//function : More
441//purpose :
442//=======================================================================
443
444Standard_Boolean BRepMAT2d_Explorer::More() const
445{
446 return (current <= NumberOfCurves(currentContour));
447}
448
449
450//=======================================================================
451//function : Next
452//purpose :
453//=======================================================================
454
455void BRepMAT2d_Explorer::Next()
456{
457 current++;
458}
459
460
461//=======================================================================
462//function : Value
463//purpose :
464//=======================================================================
465
466Handle(Geom2d_Curve) BRepMAT2d_Explorer::Value() const
467{
468 return theCurves.Value(currentContour).Value(current);
469}
470
471//=======================================================================
472//function : Shape
473//purpose :
474//=======================================================================
475
476TopoDS_Shape BRepMAT2d_Explorer::Shape() const
477{
478 return myShape;
479}
480
481
482//=======================================================================
483//function : Contour
484//purpose :
485//=======================================================================
486
487const TColGeom2d_SequenceOfCurve& BRepMAT2d_Explorer::Contour
488 (const Standard_Integer IC)
873c119f 489 const
7fd59977 490{
491 return theCurves.Value(IC);
492}
493
494
495// Modified by Sergey KHROMOV - Wed Mar 6 17:40:07 2002 Begin
496//=======================================================================
497//function : IsModified
498//purpose :
499//=======================================================================
500
501Standard_Boolean BRepMAT2d_Explorer::IsModified
873c119f 502 (const TopoDS_Shape &aShape) const
7fd59977 503{
504 if (myModifShapes.Contains(aShape)) {
505 const TopoDS_Shape &aNewShape = myModifShapes.FindFromKey(aShape);
506 const Standard_Boolean isSame = aNewShape.IsSame(aShape);
507
508 return !isSame;
509 }
510
511 return Standard_False;
512}
513
514//=======================================================================
515//function : ModifiedShape
516//purpose :
517//=======================================================================
518
519TopoDS_Shape BRepMAT2d_Explorer::ModifiedShape
873c119f 520 (const TopoDS_Shape &aShape) const
7fd59977 521{
522 if (myModifShapes.Contains(aShape)) {
523 const TopoDS_Shape &aNewShape = myModifShapes.FindFromKey(aShape);
524
525 return aNewShape;
526 }
527
528 return aShape;
529}
530
531//=======================================================================
532//function : GetIsClosed
533//purpose :
534//=======================================================================
535
536const TColStd_SequenceOfBoolean &BRepMAT2d_Explorer::GetIsClosed() const
537{
538 return myIsClosed;
539}
540
541//=======================================================================
542//function : MakeEdge
543//purpose : Creation of an edge by 2d curve, face and two vertices.
544//=======================================================================
545
546TopoDS_Edge MakeEdge(const Handle(Geom2d_Curve) &theCurve,
873c119f 547 const TopoDS_Face &theFace,
548 const TopoDS_Vertex &theVFirst,
549 const TopoDS_Vertex &theVLast)
7fd59977 550{
551 TopoDS_Edge aNewEdge;
552 BRep_Builder aBuilder;
553 Standard_Real aTol = Precision::Confusion();
554 Standard_Real aFPar = theCurve->FirstParameter();
555 Standard_Real aLPar = theCurve->LastParameter();
556
557 aBuilder.MakeEdge(aNewEdge);
558 aBuilder.UpdateEdge(aNewEdge, theCurve, theFace, aTol);
559 aBuilder.Add(aNewEdge, theVFirst.Oriented(TopAbs_FORWARD));
560 aBuilder.Add(aNewEdge, theVLast.Oriented(TopAbs_REVERSED));
561 aBuilder.Range(aNewEdge, aFPar, aLPar);
562
563 return aNewEdge;
564}
565// Modified by Sergey KHROMOV - Wed Mar 6 17:40:14 2002 End
873c119f 566//
567//=======================================================================
568//function : GetCurveType
569//purpose : Get curve type.
570//=======================================================================
571
572GeomAbs_CurveType GetCurveType(const Handle(Geom2d_Curve)& theC2d)
573{
574 GeomAbs_CurveType aTypeCurve = GeomAbs_OtherCurve;
575 Handle(Standard_Type) TheType = theC2d->DynamicType();
576 if ( TheType == STANDARD_TYPE(Geom2d_TrimmedCurve)) {
c5f3a425 577 TheType = Handle(Geom2d_TrimmedCurve)::DownCast (theC2d)->BasisCurve()->DynamicType();
873c119f 578 }
579
580 if ( TheType == STANDARD_TYPE(Geom2d_Circle)) {
581 aTypeCurve = GeomAbs_Circle;
582 }
583 else if ( TheType ==STANDARD_TYPE(Geom2d_Line)) {
584 aTypeCurve = GeomAbs_Line;
585 }
586 else if ( TheType == STANDARD_TYPE(Geom2d_Ellipse)) {
587 aTypeCurve = GeomAbs_Ellipse;
588 }
589 else if ( TheType == STANDARD_TYPE(Geom2d_Parabola)) {
590 aTypeCurve = GeomAbs_Parabola;
591 }
592 else if ( TheType == STANDARD_TYPE(Geom2d_Hyperbola)) {
593 aTypeCurve = GeomAbs_Hyperbola;
594 }
595 else if ( TheType == STANDARD_TYPE(Geom2d_BezierCurve)) {
596 aTypeCurve = GeomAbs_BezierCurve;
597 }
598 else if ( TheType == STANDARD_TYPE(Geom2d_BSplineCurve)) {
599 aTypeCurve = GeomAbs_BSplineCurve;
600 }
601 else {
602 aTypeCurve = GeomAbs_OtherCurve;
603 }
604 return aTypeCurve;
605}
606//=======================================================================
607//function : AdjustCurveEnd
608//purpose :
609//=======================================================================
610void AdjustCurveEnd(Handle(Geom2d_BoundedCurve)& theC2d, const gp_Pnt2d theP,
611 const Standard_Boolean isFirst)
612{
613 GeomAbs_CurveType aType = GetCurveType(theC2d);
614 if(aType == GeomAbs_Line)
615 {
616 //create new line
617 if(isFirst)
618 {
619 gp_Pnt2d aP = theC2d->Value(theC2d->LastParameter());
c04c30b3 620 theC2d = GCE2d_MakeSegment(theP, aP).Value();
873c119f 621 }
622 else
623 {
624 gp_Pnt2d aP = theC2d->Value(theC2d->FirstParameter());
c04c30b3 625 theC2d = GCE2d_MakeSegment(aP, theP).Value();
873c119f 626 }
627 }
628 else
629 {
630 //Convert to BSpline and adjust first pole
631 Handle(Geom2d_BSplineCurve) BCurve =
632 Geom2dConvert::CurveToBSplineCurve(theC2d, Convert_QuasiAngular);
633 if(isFirst)
634 {
635 BCurve->SetPole(1, theP);
636 theC2d = new Geom2d_TrimmedCurve(BCurve, BCurve->FirstParameter(),
637 BCurve->LastParameter());
638 }
639 else
640 {
641 BCurve->SetPole(BCurve->NbPoles(), theP);
642 theC2d = new Geom2d_TrimmedCurve(BCurve, BCurve->FirstParameter(),
643 BCurve->LastParameter());
644 }
645 }
646
647}