1 // Created on: 1993-07-07
2 // Created by: Remi LEQUETTE
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <BRep_Tool.ixx>
18 #include <BRep_TFace.hxx>
19 #include <BRep_TEdge.hxx>
20 #include <BRep_TVertex.hxx>
21 #include <BRep_CurveRepresentation.hxx>
22 #include <BRep_CurveOnSurface.hxx>
23 #include <BRep_CurveOnClosedSurface.hxx>
24 #include <BRep_ListIteratorOfListOfCurveRepresentation.hxx>
25 #include <BRep_PointRepresentation.hxx>
26 #include <BRep_ListIteratorOfListOfPointRepresentation.hxx>
27 #include <BRep_Curve3D.hxx>
28 #include <BRep_Polygon3D.hxx>
29 #include <BRep_PolygonOnSurface.hxx>
30 #include <BRep_PolygonOnClosedSurface.hxx>
31 #include <BRep_PolygonOnTriangulation.hxx>
32 #include <BRep_PolygonOnClosedTriangulation.hxx>
34 #include <TopoDS_Iterator.hxx>
35 #include <TopoDS_Wire.hxx>
36 #include <TopExp_Explorer.hxx>
38 #include <TopTools_MapOfShape.hxx>
40 #include <Geom_Plane.hxx>
41 #include <Geom_RectangularTrimmedSurface.hxx>
42 #include <Geom_OffsetSurface.hxx>
43 #include <Geom_TrimmedCurve.hxx>
44 #include <Geom2d_TrimmedCurve.hxx>
45 #include <ProjLib_ProjectedCurve.hxx>
46 #include <GeomProjLib.hxx>
47 #include <Geom2dAdaptor.hxx>
48 #include <GeomAdaptor_HCurve.hxx>
49 #include <GeomAdaptor_HSurface.hxx>
50 #include <Precision.hxx>
51 #include <Poly_Triangulation.hxx>
52 #include <Poly_Polygon3D.hxx>
53 #include <Poly_Polygon2D.hxx>
54 #include <Poly_PolygonOnTriangulation.hxx>
56 #include <NCollection_Map.hxx>
57 #include <NCollection_IncAllocator.hxx>
58 #include <TopTools_ShapeMapHasher.hxx>
60 //modified by NIZNHY-PKV Fri Oct 17 14:13:29 2008f
62 Standard_Boolean IsPlane(const Handle(Geom_Surface)& aS);
63 //modified by NIZNHY-PKV Fri Oct 17 14:13:33 2008t
65 //=======================================================================
67 //purpose : Returns the geometric surface of the face. Returns
68 // in <L> the location for the surface.
69 //=======================================================================
71 const Handle(Geom_Surface)& BRep_Tool::Surface(const TopoDS_Face& F,
74 Handle(BRep_TFace)& TF = *((Handle(BRep_TFace)*) &F.TShape());
75 L = F.Location() * TF->Location();
79 //=======================================================================
81 //purpose : Returns the geometric surface of the face. It can
82 // be a copy if there is a Location.
83 //=======================================================================
85 Handle(Geom_Surface) BRep_Tool::Surface(const TopoDS_Face& F)
87 Handle(BRep_TFace)& TF = *((Handle(BRep_TFace)*) &F.TShape());
88 TopLoc_Location L = F.Location() * TF->Location();
89 Handle(Geom_Surface) S = TF->Surface();
91 if(S.IsNull()) return S;
93 Handle(Geom_Geometry) S1;
94 if (!L.IsIdentity()) {
96 S = *((Handle(Geom_Surface)*)&S1);
97 S->Transform(L.Transformation());
102 //=======================================================================
103 //function : Triangulation
104 //purpose : Returns the Triangulation of the face. It is a
105 // null handle if there is no triangulation.
106 //=======================================================================
108 const Handle(Poly_Triangulation)&
109 BRep_Tool::Triangulation(const TopoDS_Face& F,
113 return (*((Handle(BRep_TFace)*)&F.TShape()))->Triangulation();
116 //=======================================================================
117 //function : Tolerance
118 //purpose : Returns the tolerance of the face.
119 //=======================================================================
121 Standard_Real BRep_Tool::Tolerance(const TopoDS_Face& F)
123 Standard_Real p = (*((Handle(BRep_TFace)*)&F.TShape()))->Tolerance();
124 Standard_Real pMin = Precision::Confusion();
125 if (p > pMin) return p;
129 //=======================================================================
130 //function : NaturalRestriction
131 //purpose : Returns the NaturalRestriction flag of the face.
132 //=======================================================================
134 Standard_Boolean BRep_Tool::NaturalRestriction(const TopoDS_Face& F)
136 return (*((Handle(BRep_TFace)*) &F.TShape()))->NaturalRestriction();
139 //=======================================================================
141 //purpose : Returns the 3D curve of the edge. May be a Null
142 // handle. Returns in <L> the location for the curve.
143 // In <First> and <Last> the parameter range.
144 //=======================================================================
146 static const Handle(Geom_Curve) nullCurve;
148 const Handle(Geom_Curve)& BRep_Tool::Curve(const TopoDS_Edge& E,
150 Standard_Real& First,
153 // find the representation
154 BRep_ListIteratorOfListOfCurveRepresentation itcr
155 ((*((Handle(BRep_TEdge)*)&E.TShape()))->ChangeCurves());
157 while (itcr.More()) {
158 const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
159 if (cr->IsCurve3D()) {
160 const Handle(BRep_Curve3D)& GC = *((Handle(BRep_Curve3D)*)&cr);
161 L = E.Location() * GC->Location();
162 GC->Range(First,Last);
163 return GC->Curve3D();
171 //=======================================================================
173 //purpose : Returns the 3D curve of the edge. May be a Null handle.
174 // In <First> and <Last> the parameter range.
175 // It can be a copy if there is a Location.
176 //=======================================================================
178 Handle(Geom_Curve) BRep_Tool::Curve(const TopoDS_Edge& E,
179 Standard_Real& First,
183 Handle(Geom_Curve) C = Curve(E,L,First,Last);
185 Handle(Geom_Geometry) C1;
186 if ( !L.IsIdentity() ) {
188 C = *((Handle(Geom_Curve)*)&C1);
189 C->Transform(L.Transformation());
195 //=======================================================================
196 //function : IsGeometric
197 //purpose : Returns True if <E> is a 3d curve or a curve on
199 //=======================================================================
201 Standard_Boolean BRep_Tool::IsGeometric(const TopoDS_Edge& E)
203 // find the representation
204 BRep_ListIteratorOfListOfCurveRepresentation itcr
205 ((*((Handle(BRep_TEdge)*)&E.TShape()))->ChangeCurves());
207 while (itcr.More()) {
208 const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
209 if (cr->IsCurve3D()) {
210 Standard_Real first, last;
212 const Handle(Geom_Curve)& C = BRep_Tool::Curve(E, L, first, last);
213 if (!C.IsNull()) return Standard_True;
215 else if (cr->IsCurveOnSurface()) return Standard_True;
218 return Standard_False;
221 //=======================================================================
222 //function : Polygon3D
223 //purpose : Returns the 3D polygon of the edge. May be a Null
224 // handle. Returns in <L> the location for the polygon.
225 //=======================================================================
227 static const Handle(Poly_Polygon3D) nullPolygon3D;
229 const Handle(Poly_Polygon3D)& BRep_Tool::Polygon3D(const TopoDS_Edge& E,
232 // find the representation
233 BRep_ListIteratorOfListOfCurveRepresentation itcr
234 ((*((Handle(BRep_TEdge)*)&E.TShape()))->ChangeCurves());
236 while (itcr.More()) {
237 const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
238 if (cr->IsPolygon3D()) {
239 const Handle(BRep_Polygon3D)& GC = *((Handle(BRep_Polygon3D)*)&cr);
240 L = E.Location() * GC->Location();
241 return GC->Polygon3D();
246 return nullPolygon3D;
249 //=======================================================================
250 //function : CurveOnSurface
251 //purpose : Returns the curve associated to the edge in the
252 // parametric space of the face. Returns a NULL
253 // handle if this curve does not exist. Returns in
254 // <First> and <Last> the parameter range.
255 //=======================================================================
257 Handle(Geom2d_Curve) BRep_Tool::CurveOnSurface(const TopoDS_Edge& E,
258 const TopoDS_Face& F,
259 Standard_Real& First,
263 const Handle(Geom_Surface)& S = BRep_Tool::Surface(F,l);
264 TopoDS_Edge aLocalEdge = E;
265 if (F.Orientation() == TopAbs_REVERSED) {
266 aLocalEdge.Reverse();
267 // return CurveOnSurface(E,S,l,First,Last);
269 // return CurveOnSurface(TopoDS::Edge(E.Reversed()),S,l,First,Last);
271 // return CurveOnSurface(E,S,l,First,Last);
272 return CurveOnSurface(aLocalEdge,S,l,First,Last);
275 //=======================================================================
276 //function : CurveOnSurface
277 //purpose : Returns the curve associated to the edge in the
278 // parametric space of the surface. Returns a NULL
279 // handle if this curve does not exist. Returns in
280 // <First> and <Last> the parameter range.
281 //=======================================================================
283 static const Handle(Geom2d_Curve) nullPCurve;
285 Handle(Geom2d_Curve) BRep_Tool::CurveOnSurface(const TopoDS_Edge& E,
286 const Handle(Geom_Surface)& S,
287 const TopLoc_Location& L,
288 Standard_Real& First,
291 TopLoc_Location loc = L.Predivided(E.Location());
292 Standard_Boolean Eisreversed = (E.Orientation() == TopAbs_REVERSED);
294 // find the representation
295 BRep_ListIteratorOfListOfCurveRepresentation itcr
296 ((*((Handle(BRep_TEdge)*)&E.TShape()))->ChangeCurves());
298 while (itcr.More()) {
299 const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
300 if (cr->IsCurveOnSurface(S,loc)) {
301 const Handle(BRep_GCurve)& GC = *((Handle(BRep_GCurve)*)&cr);
302 GC->Range(First,Last);
303 if (GC->IsCurveOnClosedSurface() && Eisreversed)
304 return GC->PCurve2();
311 // for planar surface and 3d curve try a projection
312 // modif 21-05-97 : for RectangularTrimmedSurface, try a projection
313 Handle(Geom_Plane) GP;
314 Handle(Geom_RectangularTrimmedSurface) GRTS;
315 GRTS = Handle(Geom_RectangularTrimmedSurface)::DownCast(S);
317 GP = Handle(Geom_Plane)::DownCast(GRTS->BasisSurface());
319 GP = Handle(Geom_Plane)::DownCast(S);
320 //fin modif du 21-05-97
324 Handle(GeomAdaptor_HCurve) HC;
325 Handle(GeomAdaptor_HSurface) HS;
327 HC = new GeomAdaptor_HCurve();
328 HS = new GeomAdaptor_HSurface();
330 TopLoc_Location aCurveLocation;
332 Standard_Real f, l;// for those who call with (u,u).
333 Handle(Geom_Curve) C3d = BRep_Tool::Curve(E, aCurveLocation, f, l);
340 aCurveLocation = L.Predivided(aCurveLocation);
342 Handle(Geom_Plane) Plane = GP;
343 if (!aCurveLocation.IsIdentity())
345 const gp_Trsf& T = aCurveLocation.Transformation();
346 Handle(Geom_Geometry) GPT = GP->Transformed(T);
347 Plane = *((Handle(Geom_Plane)*)&GPT);
349 GeomAdaptor_Surface& GAS = HS->ChangeSurface();
352 Handle(Geom_Curve) ProjOnPlane =
353 GeomProjLib::ProjectOnPlane(new Geom_TrimmedCurve(C3d,f,l,Standard_True,Standard_False),
355 Plane->Position().Direction(),
358 GeomAdaptor_Curve& GAC = HC->ChangeCurve();
359 GAC.Load(ProjOnPlane);
361 ProjLib_ProjectedCurve Proj(HS,HC);
362 Handle(Geom2d_Curve) pc = Geom2dAdaptor::MakeCurve(Proj);
364 if (pc->DynamicType() == STANDARD_TYPE(Geom2d_TrimmedCurve)) {
365 Handle(Geom2d_TrimmedCurve) TC =
366 (*((Handle(Geom2d_TrimmedCurve)*)&pc));
367 pc = TC->BasisCurve();
376 //=======================================================================
377 //function : CurveOnSurface
379 //=======================================================================
381 void BRep_Tool::CurveOnSurface(const TopoDS_Edge& E,
382 Handle(Geom2d_Curve)& C,
383 Handle(Geom_Surface)& S,
385 Standard_Real& First,
388 // find the representation
389 BRep_ListIteratorOfListOfCurveRepresentation itcr
390 ((*((Handle(BRep_TEdge)*)&E.TShape()))->ChangeCurves());
392 while (itcr.More()) {
393 const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
394 if (cr->IsCurveOnSurface()) {
395 const Handle(BRep_GCurve)& GC = *((Handle(BRep_GCurve)*)&cr);
398 L = E.Location() * GC->Location();
399 GC->Range(First,Last);
405 C = Handle(Geom2d_Curve)();
406 S = Handle(Geom_Surface)();
407 L = TopLoc_Location();
410 //=======================================================================
411 //function : CurveOnSurface
413 //=======================================================================
415 void BRep_Tool::CurveOnSurface(const TopoDS_Edge& E,
416 Handle(Geom2d_Curve)& C,
417 Handle(Geom_Surface)& S,
419 Standard_Real& First,
421 const Standard_Integer Index)
423 Standard_Integer i = 0;
424 Standard_Boolean Eisreversed = (E.Orientation() == TopAbs_REVERSED);
426 // find the representation
427 BRep_ListIteratorOfListOfCurveRepresentation itcr
428 ((*((Handle(BRep_TEdge)*)&E.TShape()))->ChangeCurves());
430 while (itcr.More()) {
431 const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
432 if (cr->IsCurveOnSurface()) {
433 const Handle(BRep_GCurve)& GC = *((Handle(BRep_GCurve)*)&cr);
435 if (i > Index) break;
437 // JMB le 21 Mai 1999
438 // it is done as in the other CurveOnSurface methods, ie. take into account
439 // the orientation in case of cut edges (return PCurve2)
440 // otherwise there is a risk to loop curves or to not get the prover one.
441 if (GC->IsCurveOnClosedSurface() && Eisreversed)
446 L = E.Location() * GC->Location();
447 GC->Range(First,Last);
454 C = Handle(Geom2d_Curve)();
455 S = Handle(Geom_Surface)();
456 L = TopLoc_Location();
459 //=======================================================================
460 //function : PolygonOnSurface
461 //purpose : Returns the polygon associated to the edge in the
462 // parametric space of the face. Returns a NULL
463 // handle if this polygon does not exist.
464 //=======================================================================
466 Handle(Poly_Polygon2D) BRep_Tool::PolygonOnSurface(const TopoDS_Edge& E,
467 const TopoDS_Face& F)
470 const Handle(Geom_Surface)& S = BRep_Tool::Surface(F,l);
471 TopoDS_Edge aLocalEdge = E;
472 if (F.Orientation() == TopAbs_REVERSED) {
473 aLocalEdge.Reverse();
474 // return PolygonOnSurface(E,S,l);
476 // return PolygonOnSurface(TopoDS::Edge(E.Reversed()),S,l);
478 // return PolygonOnSurface(E,S,l);
479 return PolygonOnSurface(aLocalEdge,S,l);
482 //=======================================================================
483 //function : PolygonOnSurface
484 //purpose : Returns the polygon associated to the edge in the
485 // parametric space of the surface. Returns a NULL
486 // handle if this polygon does not exist.
487 //=======================================================================
489 static const Handle(Poly_Polygon2D) nullPolygon2D;
491 Handle(Poly_Polygon2D)
492 BRep_Tool::PolygonOnSurface(const TopoDS_Edge& E,
493 const Handle(Geom_Surface)& S,
494 const TopLoc_Location& L)
496 TopLoc_Location l = L.Predivided(E.Location());
497 Standard_Boolean Eisreversed = (E.Orientation() == TopAbs_REVERSED);
499 // find the representation
500 BRep_ListIteratorOfListOfCurveRepresentation itcr
501 ((*((Handle(BRep_TEdge)*)&E.TShape()))->ChangeCurves());
503 while (itcr.More()) {
504 const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
505 if (cr->IsPolygonOnSurface(S,l)) {
506 if (cr->IsPolygonOnClosedSurface() && Eisreversed )
507 return cr->Polygon2();
509 return cr->Polygon();
514 return nullPolygon2D;
517 //=======================================================================
518 //function : PolygonOnSurface
520 //=======================================================================
522 void BRep_Tool::PolygonOnSurface(const TopoDS_Edge& E,
523 Handle(Poly_Polygon2D)& P,
524 Handle(Geom_Surface)& S,
527 // find the representation
528 BRep_ListIteratorOfListOfCurveRepresentation itcr
529 ((*((Handle(BRep_TEdge)*)&E.TShape()))->ChangeCurves());
531 while (itcr.More()) {
532 const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
533 if (cr->IsPolygonOnSurface()) {
534 const Handle(BRep_PolygonOnSurface)& PS =
535 *((Handle(BRep_PolygonOnSurface)*)&cr);
538 L = E.Location() * PS->Location();
544 L = TopLoc_Location();
545 P = Handle(Poly_Polygon2D)();
546 S = Handle(Geom_Surface)();
549 //=======================================================================
550 //function : PolygonOnSurface
552 //=======================================================================
554 void BRep_Tool::PolygonOnSurface(const TopoDS_Edge& E,
555 Handle(Poly_Polygon2D)& P,
556 Handle(Geom_Surface)& S,
558 const Standard_Integer Index)
560 Standard_Integer i = 0;
562 // find the representation
563 BRep_ListIteratorOfListOfCurveRepresentation itcr
564 ((*((Handle(BRep_TEdge)*)&E.TShape()))->ChangeCurves());
566 while (itcr.More()) {
567 const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
568 if (cr->IsPolygonOnSurface()) {
569 const Handle(BRep_PolygonOnSurface)& PS =
570 *((Handle(BRep_PolygonOnSurface)*)&cr);
572 if (i > Index) break;
576 L = E.Location() * PS->Location();
583 L = TopLoc_Location();
584 P = Handle(Poly_Polygon2D)();
585 S = Handle(Geom_Surface)();
588 //=======================================================================
589 //function : PolygonOnTriangulation
590 //purpose : Returns the polygon associated to the edge in the
591 // parametric space of the face. Returns a NULL
592 // handle if this polygon does not exist.
593 //=======================================================================
595 static const Handle(Poly_PolygonOnTriangulation) nullArray;
597 const Handle(Poly_PolygonOnTriangulation)&
598 BRep_Tool::PolygonOnTriangulation(const TopoDS_Edge& E,
599 const Handle(Poly_Triangulation)& T,
600 const TopLoc_Location& L)
602 TopLoc_Location l = L.Predivided(E.Location());
603 Standard_Boolean Eisreversed = (E.Orientation() == TopAbs_REVERSED);
605 // find the representation
606 BRep_ListIteratorOfListOfCurveRepresentation itcr
607 ((*((Handle(BRep_TEdge)*)&E.TShape()))->ChangeCurves());
609 while (itcr.More()) {
610 const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
611 if ( cr->IsPolygonOnTriangulation(T,l)) {
612 if ( cr->IsPolygonOnClosedTriangulation() && Eisreversed )
613 return cr->PolygonOnTriangulation2();
615 return cr->PolygonOnTriangulation();
623 //=======================================================================
624 //function : PolygonOnTriangulation
626 //=======================================================================
629 BRep_Tool::PolygonOnTriangulation(const TopoDS_Edge& E,
630 Handle(Poly_PolygonOnTriangulation)& P,
631 Handle(Poly_Triangulation)& T,
634 // find the representation
635 BRep_ListIteratorOfListOfCurveRepresentation itcr
636 ((*((Handle(BRep_TEdge)*)&E.TShape()))->ChangeCurves());
638 while (itcr.More()) {
639 const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
640 if (cr->IsPolygonOnTriangulation()) {
641 const Handle(BRep_PolygonOnTriangulation)& PT =
642 *((Handle(BRep_PolygonOnTriangulation)*)&cr);
643 P = PT->PolygonOnTriangulation();
644 T = PT->Triangulation();
645 L = E.Location() * PT->Location();
651 L = TopLoc_Location();
652 P = Handle(Poly_PolygonOnTriangulation)();
653 T = Handle(Poly_Triangulation)();
656 //=======================================================================
657 //function : PolygonOnTriangulation
659 //=======================================================================
662 BRep_Tool::PolygonOnTriangulation(const TopoDS_Edge& E,
663 Handle(Poly_PolygonOnTriangulation)& P,
664 Handle(Poly_Triangulation)& T,
666 const Standard_Integer Index)
668 Standard_Integer i = 0;
670 // find the representation
671 BRep_ListIteratorOfListOfCurveRepresentation itcr
672 ((*((Handle(BRep_TEdge)*)&E.TShape()))->ChangeCurves());
674 while (itcr.More()) {
675 const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
676 if (cr->IsPolygonOnTriangulation()) {
677 const Handle(BRep_PolygonOnTriangulation)& PT =
678 *((Handle(BRep_PolygonOnTriangulation)*)&cr);
680 if (i > Index) break;
682 T = PT->Triangulation();
683 P = PT->PolygonOnTriangulation();
684 L = E.Location() * PT->Location();
691 L = TopLoc_Location();
692 P = Handle(Poly_PolygonOnTriangulation)();
693 T = Handle(Poly_Triangulation)();
696 //=======================================================================
697 //function : IsClosed
698 //purpose : Returns True if <E> has two PCurves in the
699 // parametric space of <F>. i.e. <F> is on a closed
700 // surface and <E> is on the closing curve.
701 //=======================================================================
703 Standard_Boolean BRep_Tool::IsClosed(const TopoDS_Edge& E,
704 const TopoDS_Face& F)
707 const Handle(Geom_Surface)& S = BRep_Tool::Surface(F,l);
708 if (IsClosed(E,S,l)) return Standard_True;
709 return IsClosed(E, BRep_Tool::Triangulation(F,l));
712 //=======================================================================
713 //function : IsClosed
714 //purpose : Returns True if <E> has two PCurves in the
715 // parametric space of <S>. i.e. <S> is a closed
716 // surface and <E> is on the closing curve.
717 //=======================================================================
719 Standard_Boolean BRep_Tool::IsClosed(const TopoDS_Edge& E,
720 const Handle(Geom_Surface)& S,
721 const TopLoc_Location& L)
723 //modified by NIZNHY-PKV Fri Oct 17 12:16:58 2008f
725 return Standard_False;
727 //modified by NIZNHY-PKV Fri Oct 17 12:16:54 2008t
729 TopLoc_Location l = L.Predivided(E.Location());
731 // find the representation
732 BRep_ListIteratorOfListOfCurveRepresentation itcr
733 ((*((Handle(BRep_TEdge)*)&E.TShape()))->ChangeCurves());
735 while (itcr.More()) {
736 const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
737 if (cr->IsCurveOnSurface(S,l) &&
738 cr->IsCurveOnClosedSurface())
739 return Standard_True;
742 return Standard_False;
745 //=======================================================================
746 //function : IsClosed
747 //purpose : Returns True if <E> has two arrays of indices in
748 // the triangulation <T>.
749 //=======================================================================
751 Standard_Boolean BRep_Tool::IsClosed(const TopoDS_Edge& E,
752 const Handle(Poly_Triangulation)& T)
754 TopLoc_Location l = E.Location();
756 // find the representation
757 BRep_ListIteratorOfListOfCurveRepresentation itcr
758 ((*((Handle(BRep_TEdge)*)&E.TShape()))->ChangeCurves());
760 while (itcr.More()) {
761 const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
762 if (cr->IsPolygonOnTriangulation(T,l) &&
763 cr->IsPolygonOnClosedTriangulation())
764 return Standard_True;
767 return Standard_False;
770 //=======================================================================
771 //function : Tolerance
772 //purpose : Returns the tolerance for <E>.
773 //=======================================================================
775 Standard_Real BRep_Tool::Tolerance(const TopoDS_Edge& E)
777 Standard_Real p = (*((Handle(BRep_TEdge)*)&E.TShape()))->Tolerance();
778 Standard_Real pMin = Precision::Confusion();
779 if (p > pMin) return p;
783 //=======================================================================
784 //function : SameParameter
785 //purpose : Returns the SameParameter flag for the edge.
786 //=======================================================================
788 Standard_Boolean BRep_Tool::SameParameter(const TopoDS_Edge& E)
790 return (*((Handle(BRep_TEdge)*)&E.TShape()))->SameParameter();
793 //=======================================================================
794 //function : SameRange
795 //purpose : Returns the SameRange flag for the edge.
796 //=======================================================================
798 Standard_Boolean BRep_Tool::SameRange(const TopoDS_Edge& E)
800 return (*((Handle(BRep_TEdge)*)&E.TShape()))->SameRange();
803 //=======================================================================
804 //function : Degenerated
805 //purpose : Returns True if the edge is degenerated.
806 //=======================================================================
808 Standard_Boolean BRep_Tool::Degenerated(const TopoDS_Edge& E)
810 return (*((Handle(BRep_TEdge)*)&E.TShape()))->Degenerated();
813 //=======================================================================
816 //=======================================================================
818 void BRep_Tool::Range(const TopoDS_Edge& E,
819 Standard_Real& First,
822 // set the range to all the representations
823 BRep_ListIteratorOfListOfCurveRepresentation itcr
824 ((*((Handle(BRep_TEdge)*)&E.TShape()))->ChangeCurves());
826 while (itcr.More()) {
827 const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
828 if (cr->IsCurve3D()) {
829 const Handle(BRep_Curve3D)& CR = *((Handle(BRep_Curve3D)*)&cr);
830 if (!CR->Curve3D().IsNull()) {
836 else if (cr->IsCurveOnSurface()) {
837 const Handle(BRep_GCurve)& CR = *((Handle(BRep_GCurve)*)&cr);
846 //=======================================================================
849 //=======================================================================
851 void BRep_Tool::Range(const TopoDS_Edge& E,
852 const Handle(Geom_Surface)& S,
853 const TopLoc_Location& L,
854 Standard_Real& First,
857 TopLoc_Location l = L.Predivided(E.Location());
859 // find the representation
860 BRep_ListIteratorOfListOfCurveRepresentation itcr
861 ((*((Handle(BRep_TEdge)*)&E.TShape()))->ChangeCurves());
863 while (itcr.More()) {
864 const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
865 if (cr->IsCurveOnSurface(S,l)) {
866 (*((Handle(BRep_GCurve)*)&cr))->Range(First,Last);
874 (*((Handle(BRep_TEdge)*)&E.TShape()))->Modified(Standard_True);
877 //=======================================================================
880 //=======================================================================
882 void BRep_Tool::Range(const TopoDS_Edge& E,
883 const TopoDS_Face& F,
884 Standard_Real& First,
888 const Handle(Geom_Surface)& S = BRep_Tool::Surface(F,L);
889 Range(E,S,L,First,Last);
892 //=======================================================================
893 //function : UVPoints
895 //=======================================================================
897 void BRep_Tool::UVPoints(const TopoDS_Edge& E,
898 const Handle(Geom_Surface)& S,
899 const TopLoc_Location& L,
903 TopLoc_Location l = L.Predivided(E.Location());
904 Standard_Boolean Eisreversed = (E.Orientation() == TopAbs_REVERSED);
906 // find the representation
907 BRep_ListIteratorOfListOfCurveRepresentation itcr
908 ((*((Handle(BRep_TEdge)*)&E.TShape()))->ChangeCurves());
910 while (itcr.More()) {
911 const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
912 if (cr->IsCurveOnSurface(S,l)) {
913 if (cr->IsCurveOnClosedSurface() && Eisreversed)
914 (*((Handle(BRep_CurveOnClosedSurface)*)&cr))->UVPoints2(PFirst,PLast);
916 (*((Handle(BRep_CurveOnSurface)*)&cr))->UVPoints(PFirst,PLast);
922 // for planar surface project the vertices
923 // modif 21-05-97 : for RectangularTrimmedSurface, project the vertices
924 Handle(Geom_Plane) GP;
925 Handle(Geom_RectangularTrimmedSurface) GRTS;
926 GRTS = Handle(Geom_RectangularTrimmedSurface)::DownCast(S);
928 GP = Handle(Geom_Plane)::DownCast(GRTS->BasisSurface());
930 GP = Handle(Geom_Plane)::DownCast(S);
931 //fin modif du 21-05-97
933 // get the two vertices
935 TopExp::Vertices(E,Vf,Vl);
937 TopLoc_Location Linverted = L.Inverted();
941 gp_Pln pln = GP->Pln();
945 gp_Pnt PF = BRep_Tool::Pnt(Vf);
946 ElSLib::Parameters(pln,PF,u,v);
948 PFirst.SetCoord(u,v);
952 gp_Pnt PL = BRep_Tool::Pnt(Vl);
953 ElSLib::Parameters(pln,PL,u,v);
959 //=======================================================================
960 //function : UVPoints
962 //=======================================================================
964 void BRep_Tool::UVPoints(const TopoDS_Edge& E,
965 const TopoDS_Face& F,
970 const Handle(Geom_Surface)& S = BRep_Tool::Surface(F,L);
971 TopoDS_Edge aLocalEdge = E;
972 if (F.Orientation() == TopAbs_REVERSED) {
973 aLocalEdge.Reverse();
974 // UVPoints(E,S,L,PFirst,PLast);
976 // UVPoints(TopoDS::Edge(E.Reversed()),S,L,PFirst,PLast);
978 // UVPoints(E,S,L,PFirst,PLast);
979 UVPoints(aLocalEdge,S,L,PFirst,PLast);
982 //=======================================================================
983 //function : SetUVPoints
985 //=======================================================================
987 void BRep_Tool::SetUVPoints(const TopoDS_Edge& E,
988 const Handle(Geom_Surface)& S,
989 const TopLoc_Location& L,
990 const gp_Pnt2d& PFirst,
991 const gp_Pnt2d& PLast)
993 TopLoc_Location l = L.Predivided(E.Location());
994 Standard_Boolean Eisreversed = (E.Orientation() == TopAbs_REVERSED);
996 // find the representation
997 BRep_ListIteratorOfListOfCurveRepresentation itcr
998 ((*((Handle(BRep_TEdge)*)&E.TShape()))->ChangeCurves());
1000 while (itcr.More()) {
1001 const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
1002 if (cr->IsCurveOnSurface(S,l)) {
1003 if (cr->IsCurveOnClosedSurface() && Eisreversed)
1004 (*((Handle(BRep_CurveOnClosedSurface)*) &cr))->
1005 SetUVPoints2(PFirst,PLast);
1007 (*((Handle(BRep_CurveOnSurface)*) &cr))->
1008 SetUVPoints(PFirst,PLast);
1014 //=======================================================================
1015 //function : SetUVPoints
1017 //=======================================================================
1019 void BRep_Tool::SetUVPoints(const TopoDS_Edge& E,
1020 const TopoDS_Face& F,
1021 const gp_Pnt2d& PFirst,
1022 const gp_Pnt2d& PLast)
1025 const Handle(Geom_Surface)& S = BRep_Tool::Surface(F,L);
1026 TopoDS_Edge aLocalEdge = E;
1027 if (F.Orientation() == TopAbs_REVERSED) {
1028 aLocalEdge.Reverse();
1029 // SetUVPoints(TopoDS::Edge(E.Reversed()),S,L,PFirst,PLast);
1032 // SetUVPoints(E,S,L,PFirst,PLast);
1033 SetUVPoints(aLocalEdge,S,L,PFirst,PLast);
1036 //=======================================================================
1037 //function : HasContinuity
1038 //purpose : Returns True if the edge is on the surfaces of the
1040 //=======================================================================
1042 Standard_Boolean BRep_Tool::HasContinuity(const TopoDS_Edge& E,
1043 const TopoDS_Face& F1,
1044 const TopoDS_Face& F2)
1046 TopLoc_Location l1,l2;
1047 const Handle(Geom_Surface)& S1 = BRep_Tool::Surface(F1,l1);
1048 const Handle(Geom_Surface)& S2 = BRep_Tool::Surface(F2,l2);
1049 return HasContinuity(E,S1,S2,l1,l2);
1052 //=======================================================================
1053 //function : Continuity
1054 //purpose : Returns the continuity.
1055 //=======================================================================
1057 GeomAbs_Shape BRep_Tool::Continuity(const TopoDS_Edge& E,
1058 const TopoDS_Face& F1,
1059 const TopoDS_Face& F2)
1061 TopLoc_Location l1,l2;
1062 const Handle(Geom_Surface)& S1 = BRep_Tool::Surface(F1,l1);
1063 const Handle(Geom_Surface)& S2 = BRep_Tool::Surface(F2,l2);
1064 return Continuity(E,S1,S2,l1,l2);
1067 //=======================================================================
1068 //function : HasContinuity
1069 //purpose : Returns True if the edge is on the surfaces.
1070 //=======================================================================
1072 Standard_Boolean BRep_Tool::HasContinuity(const TopoDS_Edge& E,
1073 const Handle(Geom_Surface)& S1,
1074 const Handle(Geom_Surface)& S2,
1075 const TopLoc_Location& L1,
1076 const TopLoc_Location& L2)
1078 const TopLoc_Location& Eloc = E.Location();
1079 TopLoc_Location l1 = L1.Predivided(Eloc);
1080 TopLoc_Location l2 = L2.Predivided(Eloc);
1082 // find the representation
1083 BRep_ListIteratorOfListOfCurveRepresentation itcr
1084 ((*((Handle(BRep_TEdge)*)&E.TShape()))->ChangeCurves());
1086 while (itcr.More()) {
1087 const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
1088 if (cr->IsRegularity(S1,S2,l1,l2))
1089 return Standard_True;
1092 return Standard_False;
1095 //=======================================================================
1096 //function : Continuity
1097 //purpose : Returns the continuity.
1098 //=======================================================================
1100 GeomAbs_Shape BRep_Tool::Continuity(const TopoDS_Edge& E,
1101 const Handle(Geom_Surface)& S1,
1102 const Handle(Geom_Surface)& S2,
1103 const TopLoc_Location& L1,
1104 const TopLoc_Location& L2)
1106 TopLoc_Location l1 = L1.Predivided(E.Location());
1107 TopLoc_Location l2 = L2.Predivided(E.Location());
1109 // find the representation
1110 BRep_ListIteratorOfListOfCurveRepresentation itcr
1111 ((*((Handle(BRep_TEdge)*)&E.TShape()))->ChangeCurves());
1113 while (itcr.More()) {
1114 const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
1115 if (cr->IsRegularity(S1,S2,l1,l2))
1116 return cr->Continuity();
1122 //=======================================================================
1123 //function : HasContinuity
1124 //purpose : Returns True if the edge is on some two surfaces.
1125 //=======================================================================
1127 Standard_Boolean BRep_Tool::HasContinuity(const TopoDS_Edge& E)
1129 BRep_ListIteratorOfListOfCurveRepresentation itcr
1130 ((*((Handle(BRep_TEdge)*)&E.TShape()))->Curves());
1132 for (; itcr.More(); itcr.Next())
1134 const Handle(BRep_CurveRepresentation)& CR = itcr.Value();
1135 if (CR->IsRegularity())
1136 return Standard_True;
1138 return Standard_False;
1141 //=======================================================================
1143 //purpose : Returns the 3d point.
1144 //=======================================================================
1146 gp_Pnt BRep_Tool::Pnt(const TopoDS_Vertex& V)
1148 Handle(BRep_TVertex)& TV = *((Handle(BRep_TVertex)*) &V.TShape());
1152 Standard_NullObject::Raise("BRep_Tool:: TopoDS_Vertex hasn't gp_Pnt");
1155 gp_Pnt P = TV->Pnt();
1156 P.Transform(V.Location().Transformation());
1160 //=======================================================================
1161 //function : Tolerance
1162 //purpose : Returns the tolerance.
1163 //=======================================================================
1165 Standard_Real BRep_Tool::Tolerance(const TopoDS_Vertex& V)
1167 Handle(BRep_TVertex)& aTVert = *((Handle(BRep_TVertex)*)&V.TShape());
1169 if (aTVert.IsNull())
1171 Standard_NullObject::Raise("BRep_Tool:: TopoDS_Vertex hasn't gp_Pnt");
1174 Standard_Real p = aTVert->Tolerance();
1175 Standard_Real pMin = Precision::Confusion();
1176 if (p > pMin) return p;
1180 //=======================================================================
1181 //function : Parameter
1182 //purpose : Returns the parameter of <V> on <E>.
1183 //=======================================================================
1185 Standard_Real BRep_Tool::Parameter(const TopoDS_Vertex& V,
1186 const TopoDS_Edge& E)
1189 // Search the vertex in the edge
1191 Standard_Boolean rev = Standard_False;
1193 TopAbs_Orientation orient = TopAbs_INTERNAL;
1195 TopoDS_Iterator itv(E.Oriented(TopAbs_FORWARD));
1197 // if the edge has no vertices
1198 // and is degenerated use the vertex orientation
1201 if (!itv.More() && Degenerated(E)) {
1202 orient = V.Orientation();
1205 while (itv.More()) {
1206 const TopoDS_Shape& Vcur = itv.Value();
1207 if (V.IsSame(Vcur)) {
1212 rev = E.Orientation() == TopAbs_REVERSED;
1213 if (Vcur.Orientation() == V.Orientation()) {
1221 if (!VF.IsNull()) orient = VF.Orientation();
1225 if (orient == TopAbs_FORWARD) {
1226 BRep_Tool::Range(E,f,l);
1227 return (rev) ? l : f;
1230 else if (orient == TopAbs_REVERSED) {
1231 BRep_Tool::Range(E,f,l);
1232 return (rev) ? f : l;
1237 const Handle(Geom_Curve)& C = BRep_Tool::Curve(E,L,f,l);
1238 L = L.Predivided(V.Location());
1239 if (!C.IsNull() || Degenerated(E)) {
1240 BRep_ListIteratorOfListOfPointRepresentation itpr
1241 ((*((Handle(BRep_TVertex)*) &V.TShape()))->Points());
1243 while (itpr.More()) {
1244 const Handle(BRep_PointRepresentation)& pr = itpr.Value();
1245 if (pr->IsPointOnCurve(C,L)) {
1246 Standard_Real p = pr->Parameter();
1247 Standard_Real res = p;// SVV 4 nov 99 - to avoid warnings on Linux
1249 // Closed curves RLE 16 june 94
1250 if (Precision::IsNegativeInfinite(f)) return pr->Parameter();//p;
1251 if (Precision::IsPositiveInfinite(l)) return pr->Parameter();//p;
1252 gp_Pnt Pf = C->Value(f).Transformed(L.Transformation());
1253 gp_Pnt Pl = C->Value(l).Transformed(L.Transformation());
1254 Standard_Real tol = BRep_Tool::Tolerance(V);
1255 if (Pf.Distance(Pl) < tol) {
1256 if (Pf.Distance(BRep_Tool::Pnt(V)) < tol) {
1257 if (V.Orientation() == TopAbs_FORWARD) res = f;//p = f;
1258 else res = l;//p = l;
1269 // let us try with the first pcurve
1270 Handle(Geom2d_Curve) PC;
1271 Handle(Geom_Surface) S;
1272 BRep_Tool::CurveOnSurface(E,PC,S,L,f,l);
1273 L = L.Predivided(V.Location());
1274 BRep_ListIteratorOfListOfPointRepresentation itpr
1275 ((*((Handle(BRep_TVertex)*) &V.TShape()))->Points());
1277 while (itpr.More()) {
1278 const Handle(BRep_PointRepresentation)& pr = itpr.Value();
1279 if (pr->IsPointOnCurveOnSurface(PC,S,L)) {
1280 Standard_Real p = pr->Parameter();
1281 // Closed curves RLE 16 june 94
1282 if (PC->IsClosed()) {
1283 if ((p == PC->FirstParameter()) ||
1284 (p == PC->LastParameter())) {
1285 if (V.Orientation() == TopAbs_FORWARD) p = PC->FirstParameter();
1286 else p = PC->LastParameter();
1296 Standard_NoSuchObject::Raise("BRep_Tool:: no parameter on edge");
1300 //=======================================================================
1301 //function : Parameter
1302 //purpose : Returns the parameters of the vertex on the
1303 // pcurve of the edge on the face.
1304 //=======================================================================
1306 Standard_Real BRep_Tool::Parameter(const TopoDS_Vertex& V,
1307 const TopoDS_Edge& E,
1308 const TopoDS_Face& F)
1311 const Handle(Geom_Surface)& S = BRep_Tool::Surface(F,L);
1312 return BRep_Tool::Parameter(V,E,S,L);
1315 //=======================================================================
1316 //function : Parameter
1317 //purpose : Returns the parameters of the vertex on the
1318 // pcurve of the edge on the surface.
1319 //=======================================================================
1321 Standard_Real BRep_Tool::Parameter(const TopoDS_Vertex& V,
1322 const TopoDS_Edge& E,
1323 const Handle(Geom_Surface)& S,
1324 const TopLoc_Location& L)
1326 // Search the vertex in the edge
1328 Standard_Boolean rev = Standard_False;
1330 TopoDS_Iterator itv(E.Oriented(TopAbs_FORWARD));
1332 while (itv.More()) {
1333 if (V.IsSame(itv.Value())) {
1334 if (VF.IsNull()) VF = itv.Value();
1336 rev = E.Orientation() == TopAbs_REVERSED;
1337 if (itv.Value().Orientation() == V.Orientation())
1344 TopAbs_Orientation orient = TopAbs_INTERNAL;
1345 if (!VF.IsNull()) orient = VF.Orientation();
1349 if (orient == TopAbs_FORWARD) {
1350 BRep_Tool::Range(E,S,L,f,l);
1351 return (rev) ? l : f;
1354 else if (orient == TopAbs_REVERSED) {
1355 BRep_Tool::Range(E,S,L,f,l);
1356 return (rev) ? f : l;
1360 Handle(Geom2d_Curve) PC = BRep_Tool::CurveOnSurface(E,S,L,f,l);
1361 BRep_ListIteratorOfListOfPointRepresentation itpr
1362 ((*((Handle(BRep_TVertex)*) &V.TShape()))->Points());
1364 while (itpr.More()) {
1365 if (itpr.Value()->IsPointOnCurveOnSurface(PC,S,L))
1366 return itpr.Value()->Parameter();
1371 //----------------------------------------------------------
1374 const Handle(Geom_Curve)& C = BRep_Tool::Curve(E,L1,f,l);
1375 L1 = L1.Predivided(V.Location());
1376 if (!C.IsNull() || Degenerated(E)) {
1377 BRep_ListIteratorOfListOfPointRepresentation itpr
1378 ((*((Handle(BRep_TVertex)*) &V.TShape()))->Points());
1380 while (itpr.More()) {
1381 const Handle(BRep_PointRepresentation)& pr = itpr.Value();
1382 if (pr->IsPointOnCurve(C,L1)) {
1383 Standard_Real p = pr->Parameter();
1384 Standard_Real res = p;
1386 // Closed curves RLE 16 june 94
1387 if (Precision::IsNegativeInfinite(f)) return res;
1388 if (Precision::IsPositiveInfinite(l)) return res;
1389 gp_Pnt Pf = C->Value(f).Transformed(L1.Transformation());
1390 gp_Pnt Pl = C->Value(l).Transformed(L1.Transformation());
1391 Standard_Real tol = BRep_Tool::Tolerance(V);
1392 if (Pf.Distance(Pl) < tol) {
1393 if (Pf.Distance(BRep_Tool::Pnt(V)) < tol) {
1394 if (V.Orientation() == TopAbs_FORWARD) res = f;
1405 //----------------------------------------------------------
1407 Standard_NoSuchObject::Raise("BRep_Tool:: no parameter on edge");
1411 //=======================================================================
1412 //function : Parameters
1413 //purpose : Returns the parameters of the vertex on the face.
1414 //=======================================================================
1416 gp_Pnt2d BRep_Tool::Parameters(const TopoDS_Vertex& V,
1417 const TopoDS_Face& F)
1420 const Handle(Geom_Surface)& S = BRep_Tool::Surface(F,L);
1421 L = L.Predivided(V.Location());
1422 BRep_ListIteratorOfListOfPointRepresentation itpr
1423 ((*((Handle(BRep_TVertex)*) &V.TShape()))->Points());
1424 // It is checked if there is PointRepresentation (case non Manifold)
1426 while (itpr.More()) {
1427 if (itpr.Value()->IsPointOnSurface(S,L)) {
1428 return gp_Pnt2d(itpr.Value()->Parameter(),
1429 itpr.Value()->Parameter2());
1434 TopoDS_Vertex Vf,Vl;
1436 // Otherwise the edges are searched (PMN 4/06/97) It is not possible to succeed 999/1000!
1437 // even if often there is a way to make more economically than above...
1438 TopExp_Explorer exp;
1439 for (exp.Init(F, TopAbs_EDGE); exp.More(); exp.Next()) {
1440 E = TopoDS::Edge(exp.Current());
1441 TopExp::Vertices(E, Vf, Vl);
1442 if ((V.IsSame(Vf)) || (V.IsSame(Vl))) {
1444 UVPoints(E, F, Pf, Pl);
1445 if (V.IsSame(Vf)) return Pf;
1446 else return Pl;//Ambiguity (natural) for degenerated edges.
1449 Standard_NoSuchObject::Raise("BRep_Tool:: no parameters on surface");
1450 return gp_Pnt2d(0,0);
1452 //=======================================================================
1453 //function : IsClosed
1455 //=======================================================================
1456 Standard_Boolean BRep_Tool::IsClosed (const TopoDS_Shape& theShape)
1458 if (theShape.ShapeType() == TopAbs_SHELL || theShape.ShapeType() == TopAbs_SOLID)
1460 NCollection_Map<TopoDS_Shape, TopTools_ShapeMapHasher> aMap (101, new NCollection_IncAllocator);
1461 TopExp_Explorer exp (theShape.Oriented(TopAbs_FORWARD), TopAbs_EDGE);
1462 Standard_Boolean hasBound = Standard_False;
1463 for (; exp.More(); exp.Next())
1465 const TopoDS_Edge& E = TopoDS::Edge(exp.Current());
1466 if (BRep_Tool::Degenerated(E) || E.Orientation() == TopAbs_INTERNAL || E.Orientation() == TopAbs_EXTERNAL)
1468 hasBound = Standard_True;
1472 return hasBound && aMap.IsEmpty();
1474 else if (theShape.ShapeType() == TopAbs_WIRE)
1476 NCollection_Map<TopoDS_Shape, TopTools_ShapeMapHasher> aMap (101, new NCollection_IncAllocator);
1477 TopExp_Explorer exp (theShape.Oriented(TopAbs_FORWARD), TopAbs_VERTEX);
1478 Standard_Boolean hasBound = Standard_False;
1479 for (; exp.More(); exp.Next())
1481 const TopoDS_Shape& V = exp.Current();
1482 if (V.Orientation() == TopAbs_INTERNAL || V.Orientation() == TopAbs_EXTERNAL)
1484 hasBound = Standard_True;
1488 return hasBound && aMap.IsEmpty();
1490 return theShape.Closed();
1493 //modified by NIZNHY-PKV Fri Oct 17 14:09:58 2008 f
1494 //=======================================================================
1495 //function : IsPlane
1497 //=======================================================================
1498 Standard_Boolean IsPlane(const Handle(Geom_Surface)& aS)
1500 Standard_Boolean bRet;
1501 Handle(Geom_Plane) aGP;
1502 Handle(Geom_RectangularTrimmedSurface) aGRTS;
1503 Handle(Geom_OffsetSurface) aGOFS;
1505 aGRTS=Handle(Geom_RectangularTrimmedSurface)::DownCast(aS);
1506 aGOFS=Handle(Geom_OffsetSurface)::DownCast(aS);
1508 if(!aGOFS.IsNull()) {
1509 aGP=Handle(Geom_Plane)::DownCast(aGOFS->BasisSurface());
1511 else if(!aGRTS.IsNull()) {
1512 aGP=Handle(Geom_Plane)::DownCast(aGRTS->BasisSurface());
1515 aGP=Handle(Geom_Plane)::DownCast(aS);