b311480e |
1 | // Created on: 1994-09-06 |
2 | // Created by: Yves FRICAUD |
3 | // Copyright (c) 1994-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
42cf5bc1 |
17 | |
18 | #include <Geom2d_Curve.hxx> |
7fd59977 |
19 | #include <Geom2dAdaptor_Curve.hxx> |
42cf5bc1 |
20 | #include <Geom2dLProp_CurAndInf2d.hxx> |
21 | #include <Geom2dLProp_NumericCurInf2d.hxx> |
7fd59977 |
22 | #include <gp_Circ2d.hxx> |
23 | #include <gp_Elips2d.hxx> |
24 | #include <gp_Hypr2d.hxx> |
42cf5bc1 |
25 | #include <gp_Lin2d.hxx> |
7fd59977 |
26 | #include <gp_Parab2d.hxx> |
42cf5bc1 |
27 | #include <LProp_AnalyticCurInf.hxx> |
7fd59977 |
28 | #include <TColStd_Array1OfReal.hxx> |
29 | |
7fd59977 |
30 | //======================================================================= |
31 | //function : Geom2dLProp_CurAndInf2d |
32 | //purpose : |
33 | //======================================================================= |
34 | Geom2dLProp_CurAndInf2d::Geom2dLProp_CurAndInf2d() |
35 | { |
36 | } |
37 | |
38 | |
39 | //======================================================================= |
40 | //function : Perform |
41 | //purpose : |
42 | //======================================================================= |
43 | |
44 | void Geom2dLProp_CurAndInf2d::Perform(const Handle(Geom2d_Curve)& C) |
45 | { |
46 | PerformCurExt(C); |
47 | PerformInf (C); |
48 | } |
49 | |
50 | |
51 | //======================================================================= |
52 | //function : PerformCurExt |
53 | //purpose : |
54 | //======================================================================= |
55 | |
56 | void Geom2dLProp_CurAndInf2d::PerformCurExt(const Handle(Geom2d_Curve)& C) |
57 | { |
58 | isDone = Standard_True; |
59 | |
60 | Geom2dAdaptor_Curve CC(C); |
61 | LProp_AnalyticCurInf AC; |
62 | Geom2dLProp_NumericCurInf2d NC; |
63 | GeomAbs_CurveType CType = CC.GetType(); |
64 | |
65 | switch (CType) { |
66 | case GeomAbs_Line: |
67 | break; |
68 | case GeomAbs_Circle: |
69 | break; |
70 | case GeomAbs_Ellipse: |
71 | AC.Perform(CType,CC.FirstParameter(),CC.LastParameter(),*this); |
72 | break; |
73 | case GeomAbs_Hyperbola: |
74 | AC.Perform(CType,CC.FirstParameter(),CC.LastParameter(),*this); |
75 | break; |
76 | case GeomAbs_Parabola: |
77 | AC.Perform(CType,CC.FirstParameter(),CC.LastParameter(),*this); |
78 | break; |
79 | case GeomAbs_BSplineCurve: |
80 | if (CC.Continuity() >= GeomAbs_C3 ) { |
81 | NC.PerformCurExt(C,*this); |
82 | isDone = NC.IsDone(); |
83 | } |
84 | else { |
85 | // Decoupage en intervalles C3. |
86 | isDone = Standard_True; |
87 | Standard_Integer NbInt = CC.NbIntervals(GeomAbs_C3); |
88 | TColStd_Array1OfReal Param(1,NbInt+1); |
89 | CC.Intervals(Param,GeomAbs_C3); |
90 | for (Standard_Integer i = 1; i <= NbInt; i++) { |
91 | NC.PerformCurExt(C,Param(i),Param(i+1),*this); |
92 | if (!NC.IsDone()) {isDone = Standard_False;} |
93 | } |
94 | } |
95 | break; |
96 | |
97 | default : { |
98 | NC.PerformCurExt(C,*this); |
99 | isDone = NC.IsDone(); |
100 | } |
101 | break; |
102 | } |
103 | |
104 | } |
105 | |
106 | |
107 | //======================================================================= |
108 | //function : PerformInf |
109 | //purpose : |
110 | //======================================================================= |
111 | |
112 | void Geom2dLProp_CurAndInf2d::PerformInf(const Handle(Geom2d_Curve)& C) |
113 | { |
114 | isDone = Standard_True; |
115 | |
116 | Geom2dAdaptor_Curve CC(C); |
117 | GeomAbs_CurveType CType = CC.GetType(); |
118 | Geom2dLProp_NumericCurInf2d NC; |
119 | |
120 | switch (CType) { |
121 | case GeomAbs_Line: |
122 | break; |
123 | case GeomAbs_Circle: |
124 | break; |
125 | case GeomAbs_Ellipse: |
126 | break; |
127 | case GeomAbs_Hyperbola: |
128 | break; |
129 | case GeomAbs_Parabola: |
130 | break; |
131 | case GeomAbs_BSplineCurve: |
132 | if (CC.Continuity() >= GeomAbs_C3 ) { |
133 | NC.PerformInf(C,*this); |
134 | isDone = NC.IsDone(); |
135 | } |
136 | else { |
137 | // Decoupage en intervalles C3. |
138 | isDone = Standard_True; |
139 | Standard_Integer NbInt = CC.NbIntervals(GeomAbs_C3); |
140 | TColStd_Array1OfReal Param(1,NbInt+1); |
141 | CC.Intervals(Param,GeomAbs_C3); |
142 | |
143 | for (Standard_Integer i = 1; i <= NbInt; i++) { |
144 | NC.PerformInf(C,Param(i),Param(i+1),*this); |
145 | if (!NC.IsDone()) {isDone = Standard_False;} |
146 | } |
147 | } |
148 | break; |
149 | |
150 | default : { |
151 | NC.PerformInf(C,*this); |
152 | isDone = NC.IsDone(); |
153 | } |
154 | break; |
155 | } |
156 | } |
157 | |
158 | |
159 | //======================================================================= |
160 | //function : IsDone |
161 | //purpose : |
162 | //======================================================================= |
163 | |
164 | Standard_Boolean Geom2dLProp_CurAndInf2d::IsDone() const |
165 | { |
166 | return isDone; |
167 | } |
168 | |
169 | |