Branch data Line data Source code
1 : : //-------------------------------------------------------------------------
2 : : // Copyright Notice
3 : : //
4 : : // Copyright (c) 1996
5 : : // by Malcolm J. Panthaki, DBA, and the University of New Mexico.
6 : : //-------------------------------------------------------------------------
7 : : //
8 : : //-------------------------------------------------------------------------
9 : : // Filename : Surface.hpp
10 : : //
11 : : // Purpose :
12 : : //
13 : : // Special Notes :
14 : : //
15 : : // Creator : Xuechen Liu
16 : : //
17 : : // Creation Date : 08/02/96
18 : : //
19 : : // Owner : Malcolm J. Panthaki
20 : : //-------------------------------------------------------------------------
21 : :
22 : : #ifndef SURFACE_HPP
23 : : #define SURFACE_HPP
24 : :
25 : :
26 : : #include <assert.h>
27 : :
28 : :
29 : : #include "CubitDefines.h"
30 : : #include "GeometryEntity.hpp"
31 : :
32 : :
33 : : class CubitVector;
34 : : template <class X> class DLIList;
35 : : class ShellSM;
36 : :
37 : : class CUBIT_GEOM_EXPORT Surface : public GeometryEntity
38 : : {
39 : : public :
40 : :
41 : : Surface() ;
42 : : //- The default constructor
43 : :
44 : : virtual ~Surface() ;
45 : : //- The destructor
46 : :
47 : : typedef Curve ChildType;
48 : :
49 : : virtual CubitSense get_shell_sense( ShellSM* shell_ptr ) const = 0;
50 : :
51 : : virtual void closest_point_trimmed(CubitVector from_point,
52 : : CubitVector& point_on_surface) = 0;
53 : : //R void
54 : : //I CubitVector
55 : : //I- point from which to find closest point on trimmed surface
56 : : //O CubitVector
57 : : //O- point on trimmed surface closest to passed-in point
58 : : //- This function finds the closest point on a TRIMMED surface to the
59 : : //- passed-in point.
60 : :
61 : : virtual void closest_points_trimmed(std::vector<CubitVector> &from_points_list,
62 : : std::vector<CubitVector> &points_on_surface_list);
63 : :
64 : : virtual CubitStatus closest_point_along_vector(CubitVector& from_point,
65 : : CubitVector& along_vector,
66 : : CubitVector& point_on_surface) = 0;
67 : :
68 : : virtual CubitStatus get_point_normal( CubitVector& point,
69 : : CubitVector& normal ) = 0;
70 : : //- Only valid for planar surfaces
71 : : //- Finds the underlying plane's origin and normal (unit) vector
72 : : //- Returns CubitFailure if not a plane.
73 : :
74 : 0 : virtual void param_dir(CubitVector &/*unit_dir_in_world_space*/,
75 : 0 : CubitVector &/*pos_on_surf*/, double &/*du*/, double &/*dv*/){}
76 : :
77 : : virtual CubitStatus closest_point_uv_guess(
78 : : CubitVector const& location,
79 : : double& u_guess, double& v_guess,
80 : : CubitVector* closest_location = NULL,
81 : : CubitVector* unit_normal = NULL ) = 0;
82 : : //R CubitStatus
83 : : //I location
84 : : //I- Position to evaluate from.
85 : : //I u, v
86 : : //I- As input, hint as to location of result.
87 : : //I- As output, u and v of the result.
88 : : //I closest_location
89 : : //I- If not null, the closest point to 'location' on the surface.
90 : : //I unit_normal
91 : : //I- If not null, set to normal at result position.
92 : : //- Find closest point on surface, passing a parameter pair
93 : : //- near the result point as a hint to the surface evaluator
94 : : //- and passing back the paramter pair of the resuling
95 : : //- position on the surface.
96 : :
97 : :
98 : : virtual CubitStatus closest_point(
99 : : CubitVector const& location,
100 : : CubitVector* closest_location = NULL,
101 : : CubitVector* unit_normal = NULL,
102 : : CubitVector* curvature1 = NULL,
103 : : CubitVector* curvature2 = NULL) = 0;
104 : : //R CubitStatus
105 : : //R- CUBIT_SUCCESS/FAILURE
106 : : //I location
107 : : //I- The point to which the closest point on the surface is desired.
108 : : //O closest_location
109 : : //O- The point on the Surface, closest to the
110 : : //O- input location (which might not be on the Surface). This is
111 : : //O- input as a reference so that the function can modify its
112 : : //O- contents.
113 : : /*BWC
114 : : It says that this is passed in as a reference but it isn't. My guess is
115 : : that it should be a reference and not a pointer. I will leave it for
116 : : now in case I am missing something, but, maybe it should be changed.
117 : : BWC*/
118 : : //I refvolume_ptr
119 : : //I- The first underlying geometric entity is used to compute the
120 : : //I- normal.
121 : : //O unit_normal
122 : : //O- The normal (represented as a unit vector) at the closest_location.
123 : : //O- If this pointer is NULL, the normal is not returned.
124 : : //O curvature1
125 : : //O- The first principal curvature of the Surface at closest_location.
126 : : //O- If this pointer is NULL, this curvature is not returned.
127 : : //O curvature2
128 : : //O- The second principal curvature of the Surface at closest_location.
129 : : //O- If this pointer is NULL, this curvature is not returned.
130 : : //- This function computes the point on the Surface closest to the input
131 : : //- location -- i.e., closest_location.
132 : : //-
133 : : //- The first FACE in the list
134 : : //- is queried.
135 : : //-
136 : : //- If the input pointer values of unit_normal, curvature1 and curvature2
137 : : //- are non-NULL, the normal and principal curvatures, too, are
138 : : //- returned. These are computed at closest_location, not at the
139 : : //- input location.
140 : : //-
141 : : //- NOTE:
142 : : //- It is assumed that if the calling code needs the normal or the
143 : : //- principal curvatures, it will *allocate* space for the CubitVectors
144 : : //- before sending in the pointers.
145 : :
146 : : virtual CubitStatus closest_points(DLIList<CubitVector *> &location_list,
147 : : DLIList<CubitVector *> *closest_location_list = NULL,
148 : : DLIList<CubitVector *> *unit_normal_list = NULL,
149 : : DLIList<CubitVector *> *curvature1_list = NULL,
150 : : DLIList<CubitVector *> *curvature2_list = NULL);
151 : :
152 : : virtual CubitStatus principal_curvatures(
153 : : CubitVector const& location,
154 : : double& curvature_1,
155 : : double& curvature_2,
156 : : CubitVector* closest_location = NULL ) = 0;
157 : : //R CubitStatus
158 : : //R- CUBIT_SUCCESS/FAILURE
159 : : //I location
160 : : //I- The point at which the curvatures are being requested -- it is also
161 : : //I- the point to which the closest point on the surface is returned.
162 : : //I refvolume_ptr
163 : : //O closest_location
164 : : //O- The point on the surface, closest to the input location (this
165 : : //O- might not be on the surface). This is input as a reference
166 : : //O- so that the function can modify its contents.
167 : : //O curvature_1/2
168 : : //O- Returned principal curvature magnitudes.
169 : : //- This functions computes the point on the surface that is closest
170 : : //- to the input location and then calculates the magnitudes of the
171 : : //- principal curvatures at this (possibly, new) point on the surface.
172 : :
173 : :
174 : : virtual CubitStatus evaluate( double u, double v,
175 : : CubitVector *position,
176 : : CubitVector *normal,
177 : : CubitVector *curvature1,
178 : : CubitVector *curvature2 )=0;
179 : :
180 : : // evaluate parameters on a surface
181 : : // returns the position on the surface
182 : : // returns the first order derivatives: du, dv
183 : : // returns the second order derivatives: duu, duv, dvv
184 : : virtual CubitStatus evaluate( double u, double v, CubitVector& pos, CubitVector deriv1[2], CubitVector deriv2[3]);
185 : :
186 : : //R CubitStatus
187 : : //R- CUBIT_SUCCESS/FAILURE
188 : : //I u
189 : : //I- The u coordinate value (local parametric space).
190 : : //I v
191 : : //I- The v coordinate value (local parametric space).
192 : : //O- The coordinates of a point in global
193 : : //- (world) space that correspond to the input {u,v} point in
194 : : //- local parametric space. This is an optional output that is
195 : : //- only calculated if the supplied CubitVector is not NULL;
196 : : //O-The normal to the surface at the point with the given parametric position.
197 : : //- This is an optional output that is only calculated if the
198 : : //- supplied CubitVector is not NULL;
199 : : //O- The principle curvature directions at the point with the given parametric position.
200 : : //- These are optional outputs that are only calculated if the
201 : : //- supplied CubitVectors curvature1 and curvature2 are both not NULL;
202 : :
203 : :
204 : : virtual CubitVector position_from_u_v (double u, double v) = 0;
205 : : //R CubitVector
206 : : //R- The returned position in global space
207 : : //I u
208 : : //I- The u coordinate value (local parametric space).
209 : : //I v
210 : : //I- The v coordinate value (local parametric space).
211 : : //- This function returns the coordinates of a point in global
212 : : //- (world) space that correspond to the input {u,v} point in
213 : : //- local parametric space.
214 : :
215 : : virtual CubitStatus u_v_from_position (
216 : : CubitVector const& location,
217 : : double& u,
218 : : double& v,
219 : : CubitVector* closest_location = NULL ) = 0;
220 : : //R CubitStatus
221 : : //R- CUBIT_SUCCESS/FAILURE
222 : : //I location
223 : : //I- The input point in global space
224 : : //O closest_point
225 : : //O- The point on the Surface closest to the input location
226 : : //O u, v
227 : : //O- The returned u, v coordinate values (in local parametric space)
228 : : //O- of the closest_point
229 : : //- This function returns the {u, v} coordinates of the point
230 : : //- on the Surface closest to the input point (specified in global
231 : : //- space). The closest_location is also returned.
232 : :
233 : : virtual CubitBoolean is_periodic() = 0;
234 : : //R CubitBoolean
235 : : //R- CUBIT_TRUE/CUBIT_FALSE
236 : : //- This function determines whether the underlying geometry of the
237 : : //- Surface is periodic or not. Returns CUBIT_TRUE if it is and
238 : : //- CUBIT_FALSE if it is not.
239 : :
240 : : virtual CubitBoolean is_periodic_in_U( double& period ) = 0;
241 : : //R CubitBoolean
242 : : //R- CUBIT_TRUE/CUBIT_FALSE
243 : : //O period
244 : : //O- The value of the period in the U direction.
245 : : //- Determines whether the surface object is
246 : : //- periodic in the U direction or not. If it is, it
247 : : //- returns CUBIT_TRUE and the value of the period. Otherwise,
248 : : //- it returns CUBIT_FALSE and a value of 0.0 or the period.
249 : :
250 : : virtual CubitBoolean is_periodic_in_V( double& period ) = 0;
251 : : //R CubitBoolean
252 : : //R- CUBIT_TRUE/CUBIT_FALSE
253 : : //O period
254 : : //O- The value of the period in the V direction.
255 : : //- Determines whether the surface object is
256 : : //- periodic in the V direction or not. If it is, it
257 : : //- returns CUBIT_TRUE and the value of the period. Otherwise,
258 : : //- it returns CUBIT_FALSE and a value of 0.0 or the period.
259 : :
260 : : virtual CubitBoolean is_singular_in_U( double u_param ) = 0;
261 : : virtual CubitBoolean is_singular_in_V( double v_param ) = 0;
262 : : //R CubitBoolean
263 : : //R- CUBIT_TRUE/CUBIT_FALSE
264 : : //I double u parameter value.
265 : : //- Determines if the surface is singular in a given direction
266 : : //- at a given parameter value.
267 : :
268 : 0 : virtual CubitBoolean is_closed_in_U(){return CUBIT_FALSE;}
269 : 0 : virtual CubitBoolean is_closed_in_V(){return CUBIT_FALSE;}
270 : : //R CubitBoolean
271 : : //R- CUBIT_TRUE/CUBIT_FALSE
272 : : //- Determines if the surface is closed, smoothly or not in the
273 : : //- given parameter direction.
274 : : //- A periodic surface is always closed but a closed surface is
275 : : //- is not always periodic.
276 : : //- For modelars that do allow closed surfaces they will need
277 : : //- to implement this functionality. For instance, Pro does
278 : : //- not allow such surfaces so it will always return false.
279 : : //- will so Surface implements its own function.
280 : :
281 : : virtual CubitStatus uv_derivitives( double u_param,
282 : : double v_param,
283 : : CubitVector &du,
284 : : CubitVector &dv ) = 0;
285 : : //R CubitStatus
286 : : //R- CUBIT_SUCCESS/CUBIT_FAILURE
287 : : //O- du, dv
288 : : //- Determines the u and v derivitives from the given parameter
289 : : //- values.
290 : :
291 : : virtual CubitBoolean is_parametric() = 0;
292 : : //R CubitBoolean
293 : : //R- CUBIT_TRUE/CUBIT_FALSE
294 : : //- This function determines whether the underlying geometry of the
295 : : //- Surface is parametrically defined or not. Returns CUBIT_TRUE if
296 : : //- it is and CUBIT_FALSE if it is not.
297 : :
298 : :
299 : :
300 : : virtual CubitBoolean get_param_range_U( double& lower_bound,
301 : : double& upper_bound ) = 0;
302 : : //R CubitBoolean
303 : : //R- CUBIT_TRUE/CUBIT_FALSE
304 : : //O lower_bound
305 : : //O- The lower bound of the parametric range in the U direction.
306 : : //O- This is set to 0.0 if the surface is not parametric.
307 : : //O upper_bound
308 : : //O- The upper bound of the parametric range in the U direction.
309 : : //O- This is set to 0.0 if the surface is not parametric.
310 : : //- Returns the lower and upper parametric bounds of the
311 : : //- surface in U, if it is parametric. Otherwise, it returns
312 : : //- CUBIT_FALSE and zeroes for the upper and lower parametric
313 : : //- bounds.
314 : :
315 : : virtual CubitBoolean get_param_range_V( double& lower_bound,
316 : : double& upper_bound ) = 0;
317 : : //R CubitBoolean
318 : : //R- CUBIT_TRUE/CUBIT_FALSE
319 : : //O lower_bound
320 : : //O- The lower bound of the parametric range in the V direction.
321 : : //O- This is set to 0.0 if the surface is not parametric.
322 : : //O upper_bound
323 : : //O- The upper bound of the parametric range in the V direction.
324 : : //O- This is set to 0.0 if the surface is not parametric.
325 : : //- Returns the lower and upper parametric bounds of the
326 : : //- surface in V, if it is parametric. Otherwise, it returns
327 : : //- CUBIT_FALSE and zeroes for the upper and lower parametric
328 : : //- bounds.
329 : :
330 : : virtual CubitBoolean is_position_on( CubitVector &test_position ) = 0;
331 : : //R CubitBoolean
332 : : //R- CUBIT_TRUE/CUBIT_FALSE
333 : : //I CubitVector
334 : : //I- position, point where we want to test, whether or not it
335 : : //- is on the surface.
336 : : virtual void are_positions_on( DLIList<CubitVector *> &test_position_list,
337 : : DLIList<CubitBoolean *> &is_on_list );
338 : :
339 : : virtual CubitPointContainment point_containment( const CubitVector &point ) = 0;
340 : : virtual CubitPointContainment point_containment( double u, double v ) = 0;
341 : : //R CubitPointContainment - is the point outside, inside or on the boundary?
342 : : //R- CUBIT_PNT_OUTSIDE, CUBIT_PNT_INSIDE, CUBIT_PNT_BOUNDARY,
343 : : // CUBIT_PNT_UNKNOWN
344 : : //I CubitVector
345 : : //I- position to check, known to be on the Surface
346 : : //I double
347 : : //I- u coordinate, if known (significantly faster, if this is known - however
348 : : // if not known let the function figure it out)
349 : : //I double
350 : : //I- v coordinate, if known (significantly faster, if this is known - however
351 : : // if not known let the function figure it out)
352 : :
353 : : virtual CubitSense get_geometry_sense() = 0;
354 : : //- Returns the relative sense of the Surface with respect
355 : : //- to the geometry underneath. This is geometry engine dependent.
356 : : //- Currently this is used for the tet mesher...
357 : :
358 : 0 : virtual CubitSense get_uv_sense()
359 : : {
360 : 0 : return CUBIT_UNKNOWN;
361 : : }
362 : :
363 : : virtual CubitStatus get_projected_distance_on_surface( CubitVector *pos1,
364 : : CubitVector *pos2,
365 : : double &distance ) = 0;
366 : :
367 : :
368 : 0 : virtual GeometryType geometry_type()
369 : 0 : {return UNDEFINED_SURFACE_TYPE;};
370 : : //R GeometryType (enum)
371 : : //R- The enumerated type of the geometric representation
372 : :
373 : 0 : virtual GeometryType is_cylindrical()
374 : 0 : {return UNDEFINED_SURFACE_TYPE;};
375 : : //R GeometryType (enum)
376 : : //R- CYLINDRICAL_SURFACE_TYPE if true UNDEFINED_SURFACE_TYPE if false
377 : :
378 : : // Now handled at RefFace level. -- j.k. Oct, 2003
379 : : //virtual void reverse_sense() = 0;
380 : : //- Switch the sense of this Surface wrt the RefFace that owns it.
381 : :
382 : : virtual CubitStatus get_nurb_params( bool &rational,
383 : : int °ree_u,
384 : : int °ree_v,
385 : : int &num_cntrl_pts_u,
386 : : int &num_cntrl_pts_v,
387 : : DLIList<CubitVector> &cntrl_pts,
388 : : DLIList<double> &weights,
389 : : DLIList<double> &u_knots,
390 : : DLIList<double> &v_knots ) const = 0;
391 : : //- Only valid for nurbs surfaces
392 : : //O rational
393 : : //O- True if the nurb is rational
394 : : //O degree_u
395 : : //O- The degree of the nurb in the u direction
396 : : //O degree_v
397 : : //O- The degree of the nurb in the v direction
398 : : //O num_cntrl_pts_u
399 : : //O- Number of control points in the u direction
400 : : //O num_cntrl_pts_v
401 : : //O- Number of control points in the v direction
402 : : //O cntrl_pts
403 : : //O- The control points stored as
404 : : //O- cntrl_pts[0 ] = pt[u=0][v=0]
405 : : //O- cntrl_pts[1 ] = pt[u=1][v=0]
406 : : //O- ...
407 : : //O- cntrl_pts[num_cntrl_pts_u-1] = pt[u=?][v=0]
408 : : //O- cntrl_pts[num_cntrl_pts_u ] = pt[u=0][v=1]
409 : : //O- ...
410 : : //O weights
411 : : //O- If rational, weights for each control point, stored in the same
412 : : //O- order as the control points. No weights are returned if
413 : : //O- rational == false
414 : : //O u_knots
415 : : //O- knot vector in the u direction
416 : : //O v_knots
417 : : //O- knot vector in the v direction
418 : :
419 : : virtual CubitStatus get_sphere_params( CubitVector ¢er,
420 : : double &radius ) const = 0;
421 : : //- Only valid for spherical surfaces
422 : : //O center
423 : : //O- The center of the sphere
424 : : //O radius
425 : : //O- The radius of the sphere
426 : :
427 : : virtual CubitStatus get_cone_params( CubitVector ¢er,
428 : : CubitVector &normal,
429 : : CubitVector &major_axis,
430 : : double &radius_ratio,
431 : : double &sine_angle,
432 : : double &cos_angle ) const = 0;
433 : : //- Only valid for conical surfaces. Cylinders are a special case of conicals.
434 : : //O center
435 : : //O-
436 : : //O normal
437 : : //O-
438 : : //O major_axis
439 : : //O-
440 : : //O radius_ratio
441 : : //O-
442 : : //O sine_angle
443 : : //O-
444 : : //O cos_angle
445 : : //O-
446 : :
447 : : virtual CubitStatus get_torus_params( CubitVector ¢er,
448 : : CubitVector &normal,
449 : : double &major_radius,
450 : : double &minor_radius ) const = 0;
451 : : //- Only valid for torus surfaces.
452 : : //O center
453 : : //O-
454 : : //O normal
455 : : //O-
456 : : //O major_radius
457 : : //O-
458 : : //O minor_radius
459 : : //O-
460 : :
461 : : protected:
462 : :
463 : : private:
464 : :
465 : : } ;
466 : :
467 : :
468 : : #endif
469 : :
|