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)::DownCast (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 Handle(BRep_Curve3D) GC (Handle(BRep_Curve3D)::DownCast (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)::DownCast (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 Handle(BRep_Polygon3D) GC (Handle(BRep_Polygon3D)::DownCast (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 Handle(BRep_GCurve) GC (Handle(BRep_GCurve)::DownCast (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 = aCurveLocation.Predivided(L);
341 First = f; Last = l; //Range of edge must not be modified
343 if (!aCurveLocation.IsIdentity())
345 const gp_Trsf& T = aCurveLocation.Transformation();
346 Handle(Geom_Geometry) GC3d = C3d->Transformed(T);
347 C3d = Handle(Geom_Curve)::DownCast (GC3d);
348 f = C3d->TransformedParameter(f, T);
349 l = C3d->TransformedParameter(l, T);
351 GeomAdaptor_Surface& GAS = HS->ChangeSurface();
354 Handle(Geom_Curve) ProjOnPlane =
355 GeomProjLib::ProjectOnPlane(new Geom_TrimmedCurve(C3d,f,l,Standard_True,Standard_False),
357 GP->Position().Direction(),
360 GeomAdaptor_Curve& GAC = HC->ChangeCurve();
361 GAC.Load(ProjOnPlane);
363 ProjLib_ProjectedCurve Proj(HS,HC);
364 Handle(Geom2d_Curve) pc = Geom2dAdaptor::MakeCurve(Proj);
366 if (pc->DynamicType() == STANDARD_TYPE(Geom2d_TrimmedCurve)) {
367 Handle(Geom2d_TrimmedCurve) TC =
368 Handle(Geom2d_TrimmedCurve)::DownCast (pc);
369 pc = TC->BasisCurve();
378 //=======================================================================
379 //function : CurveOnSurface
381 //=======================================================================
383 void BRep_Tool::CurveOnSurface(const TopoDS_Edge& E,
384 Handle(Geom2d_Curve)& C,
385 Handle(Geom_Surface)& S,
387 Standard_Real& First,
390 // find the representation
391 BRep_ListIteratorOfListOfCurveRepresentation itcr
392 ((*((Handle(BRep_TEdge)*)&E.TShape()))->ChangeCurves());
394 while (itcr.More()) {
395 const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
396 if (cr->IsCurveOnSurface()) {
397 Handle(BRep_GCurve) GC (Handle(BRep_GCurve)::DownCast (cr));
400 L = E.Location() * GC->Location();
401 GC->Range(First,Last);
407 C = Handle(Geom2d_Curve)();
408 S = Handle(Geom_Surface)();
409 L = TopLoc_Location();
412 //=======================================================================
413 //function : CurveOnSurface
415 //=======================================================================
417 void BRep_Tool::CurveOnSurface(const TopoDS_Edge& E,
418 Handle(Geom2d_Curve)& C,
419 Handle(Geom_Surface)& S,
421 Standard_Real& First,
423 const Standard_Integer Index)
425 Standard_Integer i = 0;
426 Standard_Boolean Eisreversed = (E.Orientation() == TopAbs_REVERSED);
428 // find the representation
429 BRep_ListIteratorOfListOfCurveRepresentation itcr
430 ((*((Handle(BRep_TEdge)*)&E.TShape()))->ChangeCurves());
432 while (itcr.More()) {
433 const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
434 if (cr->IsCurveOnSurface()) {
435 Handle(BRep_GCurve) GC (Handle(BRep_GCurve)::DownCast (cr));
437 if (i > Index) break;
439 // JMB le 21 Mai 1999
440 // it is done as in the other CurveOnSurface methods, ie. take into account
441 // the orientation in case of cut edges (return PCurve2)
442 // otherwise there is a risk to loop curves or to not get the prover one.
443 if (GC->IsCurveOnClosedSurface() && Eisreversed)
448 L = E.Location() * GC->Location();
449 GC->Range(First,Last);
456 C = Handle(Geom2d_Curve)();
457 S = Handle(Geom_Surface)();
458 L = TopLoc_Location();
461 //=======================================================================
462 //function : PolygonOnSurface
463 //purpose : Returns the polygon associated to the edge in the
464 // parametric space of the face. Returns a NULL
465 // handle if this polygon does not exist.
466 //=======================================================================
468 Handle(Poly_Polygon2D) BRep_Tool::PolygonOnSurface(const TopoDS_Edge& E,
469 const TopoDS_Face& F)
472 const Handle(Geom_Surface)& S = BRep_Tool::Surface(F,l);
473 TopoDS_Edge aLocalEdge = E;
474 if (F.Orientation() == TopAbs_REVERSED) {
475 aLocalEdge.Reverse();
476 // return PolygonOnSurface(E,S,l);
478 // return PolygonOnSurface(TopoDS::Edge(E.Reversed()),S,l);
480 // return PolygonOnSurface(E,S,l);
481 return PolygonOnSurface(aLocalEdge,S,l);
484 //=======================================================================
485 //function : PolygonOnSurface
486 //purpose : Returns the polygon associated to the edge in the
487 // parametric space of the surface. Returns a NULL
488 // handle if this polygon does not exist.
489 //=======================================================================
491 static const Handle(Poly_Polygon2D) nullPolygon2D;
493 Handle(Poly_Polygon2D)
494 BRep_Tool::PolygonOnSurface(const TopoDS_Edge& E,
495 const Handle(Geom_Surface)& S,
496 const TopLoc_Location& L)
498 TopLoc_Location l = L.Predivided(E.Location());
499 Standard_Boolean Eisreversed = (E.Orientation() == TopAbs_REVERSED);
501 // find the representation
502 BRep_ListIteratorOfListOfCurveRepresentation itcr
503 ((*((Handle(BRep_TEdge)*)&E.TShape()))->ChangeCurves());
505 while (itcr.More()) {
506 const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
507 if (cr->IsPolygonOnSurface(S,l)) {
508 if (cr->IsPolygonOnClosedSurface() && Eisreversed )
509 return cr->Polygon2();
511 return cr->Polygon();
516 return nullPolygon2D;
519 //=======================================================================
520 //function : PolygonOnSurface
522 //=======================================================================
524 void BRep_Tool::PolygonOnSurface(const TopoDS_Edge& E,
525 Handle(Poly_Polygon2D)& P,
526 Handle(Geom_Surface)& S,
529 // find the representation
530 BRep_ListIteratorOfListOfCurveRepresentation itcr
531 ((*((Handle(BRep_TEdge)*)&E.TShape()))->ChangeCurves());
533 while (itcr.More()) {
534 const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
535 if (cr->IsPolygonOnSurface()) {
536 Handle(BRep_PolygonOnSurface) PS (Handle(BRep_PolygonOnSurface)::DownCast (cr));
539 L = E.Location() * PS->Location();
545 L = TopLoc_Location();
546 P = Handle(Poly_Polygon2D)();
547 S = Handle(Geom_Surface)();
550 //=======================================================================
551 //function : PolygonOnSurface
553 //=======================================================================
555 void BRep_Tool::PolygonOnSurface(const TopoDS_Edge& E,
556 Handle(Poly_Polygon2D)& P,
557 Handle(Geom_Surface)& S,
559 const Standard_Integer Index)
561 Standard_Integer i = 0;
563 // find the representation
564 BRep_ListIteratorOfListOfCurveRepresentation itcr
565 ((*((Handle(BRep_TEdge)*)&E.TShape()))->ChangeCurves());
567 while (itcr.More()) {
568 const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
569 if (cr->IsPolygonOnSurface()) {
570 Handle(BRep_PolygonOnSurface) PS (Handle(BRep_PolygonOnSurface)::DownCast (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 Handle(BRep_PolygonOnTriangulation) PT (Handle(BRep_PolygonOnTriangulation)::DownCast (cr));
642 P = PT->PolygonOnTriangulation();
643 T = PT->Triangulation();
644 L = E.Location() * PT->Location();
650 L = TopLoc_Location();
651 P = Handle(Poly_PolygonOnTriangulation)();
652 T = Handle(Poly_Triangulation)();
655 //=======================================================================
656 //function : PolygonOnTriangulation
658 //=======================================================================
661 BRep_Tool::PolygonOnTriangulation(const TopoDS_Edge& E,
662 Handle(Poly_PolygonOnTriangulation)& P,
663 Handle(Poly_Triangulation)& T,
665 const Standard_Integer Index)
667 Standard_Integer i = 0;
669 // find the representation
670 BRep_ListIteratorOfListOfCurveRepresentation itcr
671 ((*((Handle(BRep_TEdge)*)&E.TShape()))->ChangeCurves());
673 while (itcr.More()) {
674 const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
675 if (cr->IsPolygonOnTriangulation()) {
676 Handle(BRep_PolygonOnTriangulation) PT (Handle(BRep_PolygonOnTriangulation)::DownCast (cr));
678 if (i > Index) break;
680 T = PT->Triangulation();
681 P = PT->PolygonOnTriangulation();
682 L = E.Location() * PT->Location();
689 L = TopLoc_Location();
690 P = Handle(Poly_PolygonOnTriangulation)();
691 T = Handle(Poly_Triangulation)();
694 //=======================================================================
695 //function : IsClosed
696 //purpose : Returns True if <E> has two PCurves in the
697 // parametric space of <F>. i.e. <F> is on a closed
698 // surface and <E> is on the closing curve.
699 //=======================================================================
701 Standard_Boolean BRep_Tool::IsClosed(const TopoDS_Edge& E,
702 const TopoDS_Face& F)
705 const Handle(Geom_Surface)& S = BRep_Tool::Surface(F,l);
706 if (IsClosed(E,S,l)) return Standard_True;
707 const Handle(Poly_Triangulation)& T = BRep_Tool::Triangulation(F,l);
708 return IsClosed(E, T, l);
711 //=======================================================================
712 //function : IsClosed
713 //purpose : Returns True if <E> has two PCurves in the
714 // parametric space of <S>. i.e. <S> is a closed
715 // surface and <E> is on the closing curve.
716 //=======================================================================
718 Standard_Boolean BRep_Tool::IsClosed(const TopoDS_Edge& E,
719 const Handle(Geom_Surface)& S,
720 const TopLoc_Location& L)
722 //modified by NIZNHY-PKV Fri Oct 17 12:16:58 2008f
724 return Standard_False;
726 //modified by NIZNHY-PKV Fri Oct 17 12:16:54 2008t
728 TopLoc_Location l = L.Predivided(E.Location());
730 // find the representation
731 BRep_ListIteratorOfListOfCurveRepresentation itcr
732 ((*((Handle(BRep_TEdge)*)&E.TShape()))->ChangeCurves());
734 while (itcr.More()) {
735 const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
736 if (cr->IsCurveOnSurface(S,l) &&
737 cr->IsCurveOnClosedSurface())
738 return Standard_True;
741 return Standard_False;
744 //=======================================================================
745 //function : IsClosed
746 //purpose : Returns True if <E> has two arrays of indices in
747 // the triangulation <T>.
748 //=======================================================================
750 Standard_Boolean BRep_Tool::IsClosed(const TopoDS_Edge& E,
751 const Handle(Poly_Triangulation)& T,
752 const TopLoc_Location& L)
754 TopLoc_Location l = L.Predivided(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 Handle(BRep_Curve3D) CR (Handle(BRep_Curve3D)::DownCast (cr));
830 if (!CR->Curve3D().IsNull()) {
836 else if (cr->IsCurveOnSurface()) {
837 Handle(BRep_GCurve) CR (Handle(BRep_GCurve)::DownCast (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)::DownCast (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)::DownCast (cr)->UVPoints2(PFirst,PLast);
916 Handle(BRep_CurveOnSurface)::DownCast (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)::DownCast (cr)->
1005 SetUVPoints2(PFirst,PLast);
1007 Handle(BRep_CurveOnSurface)::DownCast (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)
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 else if (theShape.ShapeType() == TopAbs_EDGE)
1492 TopoDS_Vertex aVFirst, aVLast;
1493 TopExp::Vertices(TopoDS::Edge(theShape), aVFirst, aVLast);
1494 return !aVFirst.IsNull() && aVFirst.IsSame(aVLast);
1496 return theShape.Closed();
1499 //modified by NIZNHY-PKV Fri Oct 17 14:09:58 2008 f
1500 //=======================================================================
1501 //function : IsPlane
1503 //=======================================================================
1504 Standard_Boolean IsPlane(const Handle(Geom_Surface)& aS)
1506 Standard_Boolean bRet;
1507 Handle(Geom_Plane) aGP;
1508 Handle(Geom_RectangularTrimmedSurface) aGRTS;
1509 Handle(Geom_OffsetSurface) aGOFS;
1511 aGRTS=Handle(Geom_RectangularTrimmedSurface)::DownCast(aS);
1512 aGOFS=Handle(Geom_OffsetSurface)::DownCast(aS);
1514 if(!aGOFS.IsNull()) {
1515 aGP=Handle(Geom_Plane)::DownCast(aGOFS->BasisSurface());
1517 else if(!aGRTS.IsNull()) {
1518 aGP=Handle(Geom_Plane)::DownCast(aGRTS->BasisSurface());
1521 aGP=Handle(Geom_Plane)::DownCast(aS);