1 // Created on: 1995-02-08
2 // Created by: Jacques GOUSSARD
3 // Copyright (c) 1995-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 <GeomInt_LineTool.ixx>
19 #include <IntPatch_WLine.hxx>
20 #include <IntPatch_RLine.hxx>
21 #include <IntPatch_ALine.hxx>
22 #include <IntPatch_GLine.hxx>
23 #include <Precision.hxx>
26 //=======================================================================
29 //=======================================================================
30 Standard_Integer GeomInt_LineTool::NbVertex(const Handle(IntPatch_Line)& L)
34 case IntPatch_Analytic: return Handle(IntPatch_ALine)::DownCast(L)->NbVertex();
35 case IntPatch_Restriction: return Handle(IntPatch_RLine)::DownCast(L)->NbVertex();
36 case IntPatch_Walking: return Handle(IntPatch_WLine)::DownCast(L)->NbVertex();
39 return Handle(IntPatch_GLine)::DownCast(L)->NbVertex();
43 //=======================================================================
46 //=======================================================================
47 const IntPatch_Point & GeomInt_LineTool::Vertex(const Handle(IntPatch_Line)& L,
48 const Standard_Integer I)
52 case IntPatch_Analytic: return Handle(IntPatch_ALine)::DownCast(L)->Vertex(I);
53 case IntPatch_Restriction: return Handle(IntPatch_RLine)::DownCast(L)->Vertex(I);
54 case IntPatch_Walking: return Handle(IntPatch_WLine)::DownCast(L)->Vertex(I);
57 return Handle(IntPatch_GLine)::DownCast(L)->Vertex(I);
61 //=======================================================================
62 //function : FirstParameter
64 //=======================================================================
65 Standard_Real GeomInt_LineTool::FirstParameter (const Handle(IntPatch_Line)& L)
67 const IntPatch_IType typl = L->ArcType();
70 case IntPatch_Analytic:
72 Handle(IntPatch_ALine) alin = Handle(IntPatch_ALine)::DownCast(L);
73 if (alin->HasFirstPoint())
74 return alin->FirstPoint().ParameterOnLine();
75 Standard_Boolean included;
76 Standard_Real firstp = alin->FirstParameter(included);
78 firstp += Epsilon(firstp);
82 case IntPatch_Restriction:
84 Handle(IntPatch_RLine) rlin = Handle(IntPatch_RLine)::DownCast(L);
85 return (rlin->HasFirstPoint()? rlin->FirstPoint().ParameterOnLine() : -Precision::Infinite()); // a voir selon le type de la ligne 2d
88 case IntPatch_Walking:
90 Handle(IntPatch_WLine) wlin = Handle(IntPatch_WLine)::DownCast(L);
91 return (wlin->HasFirstPoint()? wlin->FirstPoint().ParameterOnLine() : 1.);
96 Handle(IntPatch_GLine) glin = Handle(IntPatch_GLine)::DownCast(L);
97 if (glin->HasFirstPoint())
98 return glin->FirstPoint().ParameterOnLine();
102 case IntPatch_Parabola:
103 case IntPatch_Hyperbola:
104 return -Precision::Infinite();
113 //=======================================================================
114 //function : LastParameter
116 //=======================================================================
117 Standard_Real GeomInt_LineTool::LastParameter (const Handle(IntPatch_Line)& L)
119 const IntPatch_IType typl = L->ArcType();
122 case IntPatch_Analytic:
124 Handle(IntPatch_ALine) alin = Handle(IntPatch_ALine)::DownCast(L);
125 if (alin->HasLastPoint())
126 return alin->LastPoint().ParameterOnLine();
127 Standard_Boolean included;
128 Standard_Real lastp = alin->LastParameter(included);
130 lastp -=Epsilon(lastp);
134 case IntPatch_Restriction:
136 Handle(IntPatch_RLine) rlin = Handle(IntPatch_RLine)::DownCast(L);
137 return (rlin->HasLastPoint()? rlin->LastPoint().ParameterOnLine() : Precision::Infinite()); // a voir selon le type de la ligne 2d
140 case IntPatch_Walking:
142 Handle(IntPatch_WLine) wlin = Handle(IntPatch_WLine)::DownCast(L);
143 return (wlin->HasLastPoint()? wlin->LastPoint().ParameterOnLine() : wlin->NbPnts());
148 Handle(IntPatch_GLine) glin = Handle(IntPatch_GLine)::DownCast(L);
149 if (glin->HasLastPoint())
150 return glin->LastPoint().ParameterOnLine();
154 case IntPatch_Parabola:
155 case IntPatch_Hyperbola:
156 return Precision::Infinite();
157 case IntPatch_Circle:
158 case IntPatch_Ellipse: