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