1 // Created on: 1993-03-10
2 // Created by: JCV
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16 
17 
18 #include <BSplCLib.hxx>
19 #include <BSplSLib.hxx>
20 #include <Geom_BezierCurve.hxx>
21 #include <Geom_BSplineCurve.hxx>
22 #include <Geom_Circle.hxx>
23 #include <Geom_Curve.hxx>
24 #include <Geom_Ellipse.hxx>
25 #include <Geom_Geometry.hxx>
26 #include <Geom_Hyperbola.hxx>
27 #include <Geom_Line.hxx>
28 #include <Geom_OffsetCurve.hxx>
29 #include <Geom_Parabola.hxx>
30 #include <Geom_SurfaceOfLinearExtrusion.hxx>
31 #include <Geom_TrimmedCurve.hxx>
32 #include <Geom_UndefinedDerivative.hxx>
33 #include <GeomAbs_CurveType.hxx>
34 #include <GeomEvaluator_SurfaceOfExtrusion.hxx>
35 #include <gp.hxx>
36 #include <gp_Ax2d.hxx>
37 #include <gp_Dir.hxx>
38 #include <gp_GTrsf2d.hxx>
39 #include <gp_Lin.hxx>
40 #include <gp_Pnt.hxx>
41 #include <gp_Trsf.hxx>
42 #include <gp_Vec.hxx>
43 #include <gp_XYZ.hxx>
44 #include <Precision.hxx>
45 #include <Standard_RangeError.hxx>
46 #include <Standard_Type.hxx>
47 
48 IMPLEMENT_STANDARD_RTTIEXT(Geom_SurfaceOfLinearExtrusion,Geom_SweptSurface)
49 
50 #define  POLES    (poles->Array2())
51 #define  WEIGHTS  (weights->Array2())
52 #define  UKNOTS   (uknots->Array1())
53 #define  VKNOTS   (vknots->Array1())
54 #define  UFKNOTS  (ufknots->Array1())
55 #define  VFKNOTS  (vfknots->Array1())
56 #define  FMULTS   (BSplCLib::NoMults())
57 
58 typedef Geom_SurfaceOfLinearExtrusion         SurfaceOfLinearExtrusion;
59 typedef Geom_Curve                            Curve;
60 typedef gp_Dir  Dir;
61 typedef gp_Pnt  Pnt;
62 typedef gp_Trsf Trsf;
63 typedef gp_Vec  Vec;
64 typedef gp_XYZ  XYZ;
65 
66 
67 
68 //=======================================================================
69 //function : Copy
70 //purpose  :
71 //=======================================================================
72 
Handle(Geom_Geometry)73 Handle(Geom_Geometry) Geom_SurfaceOfLinearExtrusion::Copy () const
74 {
75 
76   Handle(Geom_SurfaceOfLinearExtrusion) Sr;
77   Sr = new SurfaceOfLinearExtrusion (basisCurve, direction);
78   return Sr;
79 }
80 
81 
82 //=======================================================================
83 //function : Geom_SurfaceOfLinearExtrusion
84 //purpose  :
85 //=======================================================================
86 
Geom_SurfaceOfLinearExtrusion(const Handle (Geom_Curve)& C,const Dir & V)87 Geom_SurfaceOfLinearExtrusion::Geom_SurfaceOfLinearExtrusion
88   ( const Handle(Geom_Curve)& C,
89     const Dir& V) {
90 
91    basisCurve = Handle(Geom_Curve)::DownCast(C->Copy());  // Copy 10-03-93
92    direction  = V;
93    smooth     = C->Continuity();
94    myEvaluator = new GeomEvaluator_SurfaceOfExtrusion(basisCurve, direction);
95  }
96 
97 
98 //=======================================================================
99 //function : UReverse
100 //purpose  :
101 //=======================================================================
102 
UReverse()103 void Geom_SurfaceOfLinearExtrusion::UReverse () {
104 
105   basisCurve->Reverse();
106 }
107 
108 
109 //=======================================================================
110 //function : UReversedParameter
111 //purpose  :
112 //=======================================================================
113 
UReversedParameter(const Standard_Real U) const114 Standard_Real Geom_SurfaceOfLinearExtrusion::UReversedParameter(const Standard_Real U) const {
115 
116   return basisCurve->ReversedParameter(U);
117 }
118 
119 
120 //=======================================================================
121 //function : VReverse
122 //purpose  :
123 //=======================================================================
124 
VReverse()125 void Geom_SurfaceOfLinearExtrusion::VReverse () {
126 
127   direction.Reverse();
128   myEvaluator->SetDirection(direction);
129 }
130 
131 
132 //=======================================================================
133 //function : VReversedParameter
134 //purpose  :
135 //=======================================================================
136 
VReversedParameter(const Standard_Real V) const137 Standard_Real Geom_SurfaceOfLinearExtrusion::VReversedParameter( const Standard_Real V) const {
138 
139   return (-V);
140 }
141 
142 
143 //=======================================================================
144 //function : SetDirection
145 //purpose  :
146 //=======================================================================
147 
SetDirection(const Dir & V)148 void Geom_SurfaceOfLinearExtrusion::SetDirection (const Dir& V)
149 {
150   direction = V;
151   myEvaluator->SetDirection(direction);
152 }
153 
154 
155 //=======================================================================
156 //function : SetBasisCurve
157 //purpose  :
158 //=======================================================================
159 
SetBasisCurve(const Handle (Geom_Curve)& C)160 void Geom_SurfaceOfLinearExtrusion::SetBasisCurve (const Handle(Geom_Curve)& C) {
161 
162    smooth = C->Continuity();
163    basisCurve = Handle(Geom_Curve)::DownCast(C->Copy());  // Copy 10-03-93
164    myEvaluator = new GeomEvaluator_SurfaceOfExtrusion(basisCurve, direction);
165 }
166 
167 
168 //=======================================================================
169 //function : Bounds
170 //purpose  :
171 //=======================================================================
172 
Bounds(Standard_Real & U1,Standard_Real & U2,Standard_Real & V1,Standard_Real & V2) const173 void Geom_SurfaceOfLinearExtrusion::Bounds ( Standard_Real& U1,
174 					     Standard_Real& U2,
175 					     Standard_Real& V1,
176 					     Standard_Real& V2 ) const {
177 
178   V1 = -Precision::Infinite();  V2 = Precision::Infinite();
179   U1 = basisCurve->FirstParameter();  U2 = basisCurve->LastParameter();
180 }
181 
182 
183 //=======================================================================
184 //function : D0
185 //purpose  :
186 //=======================================================================
187 
D0(const Standard_Real U,const Standard_Real V,Pnt & P) const188 void Geom_SurfaceOfLinearExtrusion::D0 (const Standard_Real U,
189                                         const Standard_Real V,
190                                               Pnt& P)  const
191 {
192   myEvaluator->D0(U, V, P);
193 }
194 
195 
196 //=======================================================================
197 //function : D1
198 //purpose  :
199 //=======================================================================
200 
D1(const Standard_Real U,const Standard_Real V,Pnt & P,Vec & D1U,Vec & D1V) const201 void Geom_SurfaceOfLinearExtrusion::D1 (const Standard_Real U,
202                                         const Standard_Real V,
203                                               Pnt& P,
204                                               Vec& D1U, Vec& D1V) const
205 {
206   myEvaluator->D1(U, V, P, D1U, D1V);
207 }
208 
209 
210 //=======================================================================
211 //function : D2
212 //purpose  :
213 //=======================================================================
214 
D2(const Standard_Real U,const Standard_Real V,Pnt & P,Vec & D1U,Vec & D1V,Vec & D2U,Vec & D2V,Vec & D2UV) const215 void Geom_SurfaceOfLinearExtrusion::D2 (const Standard_Real U,
216                                         const Standard_Real V,
217                                               Pnt& P,
218                                               Vec& D1U, Vec& D1V,
219                                               Vec& D2U, Vec& D2V, Vec& D2UV) const
220 {
221   myEvaluator->D2(U, V, P, D1U, D1V, D2U, D2V, D2UV);
222 }
223 
224 
225 //=======================================================================
226 //function : D3
227 //purpose  :
228 //=======================================================================
229 
D3(const Standard_Real U,const Standard_Real V,Pnt & P,Vec & D1U,Vec & D1V,Vec & D2U,Vec & D2V,Vec & D2UV,Vec & D3U,Vec & D3V,Vec & D3UUV,Vec & D3UVV) const230 void Geom_SurfaceOfLinearExtrusion::D3 (const Standard_Real U,
231                                         const Standard_Real V,
232                                               Pnt& P,
233                                               Vec& D1U, Vec& D1V,
234                                               Vec& D2U, Vec& D2V, Vec& D2UV,
235                                               Vec& D3U, Vec& D3V, Vec& D3UUV, Vec& D3UVV) const
236 {
237   myEvaluator->D3(U, V, P, D1U, D1V, D2U, D2V, D2UV, D3U, D3V, D3UUV, D3UVV);
238 }
239 
240 
241 //=======================================================================
242 //function : DN
243 //purpose  :
244 //=======================================================================
245 
DN(const Standard_Real U,const Standard_Real V,const Standard_Integer Nu,const Standard_Integer Nv) const246 Vec Geom_SurfaceOfLinearExtrusion::DN (const Standard_Real    U,
247                                        const Standard_Real    V,
248                                        const Standard_Integer Nu,
249                                        const Standard_Integer Nv) const
250 {
251   return myEvaluator->DN(U, V, Nu, Nv);
252 }
253 
254 
255 //=======================================================================
256 //function : UIso
257 //purpose  :
258 //=======================================================================
259 
Handle(Geom_Curve)260 Handle(Geom_Curve) Geom_SurfaceOfLinearExtrusion::UIso (const Standard_Real U) const {
261 
262   Handle(Geom_Line) L;
263   L = new Geom_Line (basisCurve->Value (U), direction);
264   return L;
265 }
266 
267 
268 //=======================================================================
269 //function : VIso
270 //purpose  :
271 //=======================================================================
272 
Handle(Geom_Curve)273 Handle(Geom_Curve) Geom_SurfaceOfLinearExtrusion::VIso (const Standard_Real V) const {
274 
275   Vec Vdir (direction);
276   Vdir.Multiply (V);
277   Handle(Geom_Curve) C;
278   C = Handle(Geom_Curve)::DownCast(basisCurve->Translated(Vdir));
279   return C;
280 }
281 
282 
283 //=======================================================================
284 //function : IsCNu
285 //purpose  :
286 //=======================================================================
287 
IsCNu(const Standard_Integer N) const288 Standard_Boolean Geom_SurfaceOfLinearExtrusion::IsCNu (const Standard_Integer N) const {
289 
290   Standard_RangeError_Raise_if (N < 0, " ");
291   return basisCurve->IsCN (N);
292 }
293 
294 
295 //=======================================================================
296 //function : IsCNv
297 //purpose  :
298 //=======================================================================
299 
IsCNv(const Standard_Integer) const300 Standard_Boolean Geom_SurfaceOfLinearExtrusion::IsCNv (const Standard_Integer ) const {
301 
302   return Standard_True;
303 }
304 
305 
306 //=======================================================================
307 //function : Transform
308 //purpose  :
309 //=======================================================================
310 
Transform(const Trsf & T)311 void Geom_SurfaceOfLinearExtrusion::Transform (const Trsf& T) {
312 
313    direction.Transform   (T);
314    basisCurve->Transform (T);
315    myEvaluator->SetDirection(direction);
316 }
317 
318 
319 
320 //=======================================================================
321 //function : IsUClosed
322 //purpose  :
323 //=======================================================================
324 
IsUClosed() const325 Standard_Boolean Geom_SurfaceOfLinearExtrusion::IsUClosed () const {
326 
327   return basisCurve->IsClosed ();
328 }
329 
330 
331 //=======================================================================
332 //function : IsUPeriodic
333 //purpose  :
334 //=======================================================================
335 
IsUPeriodic() const336 Standard_Boolean Geom_SurfaceOfLinearExtrusion::IsUPeriodic () const {
337 
338   return basisCurve->IsPeriodic ();
339 }
340 
341 //=======================================================================
342 //function : IsVClosed
343 //purpose  :
344 //=======================================================================
345 
IsVClosed() const346 Standard_Boolean Geom_SurfaceOfLinearExtrusion::IsVClosed () const  {
347 
348   return Standard_False;
349 }
350 
351 //=======================================================================
352 //function : IsVPeriodic
353 //purpose  :
354 //=======================================================================
355 
IsVPeriodic() const356 Standard_Boolean Geom_SurfaceOfLinearExtrusion::IsVPeriodic () const {
357 
358   return Standard_False;
359 }
360 
361 //=======================================================================
362 //function : TransformParameters
363 //purpose  :
364 //=======================================================================
365 
TransformParameters(Standard_Real & U,Standard_Real & V,const gp_Trsf & T) const366 void Geom_SurfaceOfLinearExtrusion::TransformParameters(Standard_Real& U,
367 							Standard_Real& V,
368 							const gp_Trsf& T)
369 const
370 {
371   U = basisCurve->TransformedParameter(U,T);
372   if (!Precision::IsInfinite(V)) V *= Abs(T.ScaleFactor());
373 }
374 
375 //=======================================================================
376 //function : ParametricTransformation
377 //purpose  :
378 //=======================================================================
379 
ParametricTransformation(const gp_Trsf & T) const380 gp_GTrsf2d Geom_SurfaceOfLinearExtrusion::ParametricTransformation
381 (const gp_Trsf& T) const
382 {
383   // transformation in the V Direction
384   gp_GTrsf2d TV;
385   gp_Ax2d Axis(gp::Origin2d(),gp::DX2d());
386   TV.SetAffinity(Axis, Abs(T.ScaleFactor()));
387   // transformation in the U Direction
388   gp_GTrsf2d TU;
389   Axis = gp_Ax2d(gp::Origin2d(),gp::DY2d());
390   TU.SetAffinity(Axis, basisCurve->ParametricTransformation(T));
391 
392   return TU * TV;
393 }
394 
395 //=======================================================================
396 //function : DumpJson
397 //purpose  :
398 //=======================================================================
DumpJson(Standard_OStream & theOStream,Standard_Integer theDepth) const399 void Geom_SurfaceOfLinearExtrusion::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
400 {
401   OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
402 
403   OCCT_DUMP_BASE_CLASS (theOStream, theDepth, Geom_SweptSurface)
404 }
405