cgma
|
00001 //------------------------------------------------------------------------- 00002 // Copyright Notice 00003 // 00004 // Copyright (c) 1996 00005 // by Malcolm J. Panthaki, DBA, and the University of New Mexico. 00006 //------------------------------------------------------------------------- 00007 // 00008 //------------------------------------------------------------------------- 00009 // Filename : Surface.hpp 00010 // 00011 // Purpose : 00012 // 00013 // Special Notes : 00014 // 00015 // Creator : Xuechen Liu 00016 // 00017 // Creation Date : 08/02/96 00018 // 00019 // Owner : Malcolm J. Panthaki 00020 //------------------------------------------------------------------------- 00021 00022 #ifndef SURFACE_HPP 00023 #define SURFACE_HPP 00024 00025 00026 #include <assert.h> 00027 00028 00029 #include "CubitDefines.h" 00030 #include "GeometryEntity.hpp" 00031 00032 00033 class CubitVector; 00034 template <class X> class DLIList; 00035 class ShellSM; 00036 00037 class CUBIT_GEOM_EXPORT Surface : public GeometryEntity 00038 { 00039 public : 00040 00041 Surface() ; 00042 //- The default constructor 00043 00044 virtual ~Surface() ; 00045 //- The destructor 00046 00047 typedef Curve ChildType; 00048 00049 virtual CubitSense get_shell_sense( ShellSM* shell_ptr ) const = 0; 00050 00051 virtual void closest_point_trimmed(CubitVector from_point, 00052 CubitVector& point_on_surface) = 0; 00053 //R void 00054 //I CubitVector 00055 //I- point from which to find closest point on trimmed surface 00056 //O CubitVector 00057 //O- point on trimmed surface closest to passed-in point 00058 //- This function finds the closest point on a TRIMMED surface to the 00059 //- passed-in point. 00060 00061 virtual void closest_points_trimmed(std::vector<CubitVector> &from_points_list, 00062 std::vector<CubitVector> &points_on_surface_list); 00063 00064 virtual CubitStatus closest_point_along_vector(CubitVector& from_point, 00065 CubitVector& along_vector, 00066 CubitVector& point_on_surface) = 0; 00067 00068 virtual CubitStatus get_point_normal( CubitVector& point, 00069 CubitVector& normal ) = 0; 00070 //- Only valid for planar surfaces 00071 //- Finds the underlying plane's origin and normal (unit) vector 00072 //- Returns CubitFailure if not a plane. 00073 00074 virtual void param_dir(CubitVector &/*unit_dir_in_world_space*/, 00075 CubitVector &/*pos_on_surf*/, double &/*du*/, double &/*dv*/){} 00076 00077 virtual CubitStatus closest_point_uv_guess( 00078 CubitVector const& location, 00079 double& u_guess, double& v_guess, 00080 CubitVector* closest_location = NULL, 00081 CubitVector* unit_normal = NULL ) = 0; 00082 //R CubitStatus 00083 //I location 00084 //I- Position to evaluate from. 00085 //I u, v 00086 //I- As input, hint as to location of result. 00087 //I- As output, u and v of the result. 00088 //I closest_location 00089 //I- If not null, the closest point to 'location' on the surface. 00090 //I unit_normal 00091 //I- If not null, set to normal at result position. 00092 //- Find closest point on surface, passing a parameter pair 00093 //- near the result point as a hint to the surface evaluator 00094 //- and passing back the paramter pair of the resuling 00095 //- position on the surface. 00096 00097 00098 virtual CubitStatus closest_point( 00099 CubitVector const& location, 00100 CubitVector* closest_location = NULL, 00101 CubitVector* unit_normal = NULL, 00102 CubitVector* curvature1 = NULL, 00103 CubitVector* curvature2 = NULL) = 0; 00104 //R CubitStatus 00105 //R- CUBIT_SUCCESS/FAILURE 00106 //I location 00107 //I- The point to which the closest point on the surface is desired. 00108 //O closest_location 00109 //O- The point on the Surface, closest to the 00110 //O- input location (which might not be on the Surface). This is 00111 //O- input as a reference so that the function can modify its 00112 //O- contents. 00113 /*BWC 00114 It says that this is passed in as a reference but it isn't. My guess is 00115 that it should be a reference and not a pointer. I will leave it for 00116 now in case I am missing something, but, maybe it should be changed. 00117 BWC*/ 00118 //I refvolume_ptr 00119 //I- The first underlying geometric entity is used to compute the 00120 //I- normal. 00121 //O unit_normal 00122 //O- The normal (represented as a unit vector) at the closest_location. 00123 //O- If this pointer is NULL, the normal is not returned. 00124 //O curvature1 00125 //O- The first principal curvature of the Surface at closest_location. 00126 //O- If this pointer is NULL, this curvature is not returned. 00127 //O curvature2 00128 //O- The second principal curvature of the Surface at closest_location. 00129 //O- If this pointer is NULL, this curvature is not returned. 00130 //- This function computes the point on the Surface closest to the input 00131 //- location -- i.e., closest_location. 00132 //- 00133 //- The first FACE in the list 00134 //- is queried. 00135 //- 00136 //- If the input pointer values of unit_normal, curvature1 and curvature2 00137 //- are non-NULL, the normal and principal curvatures, too, are 00138 //- returned. These are computed at closest_location, not at the 00139 //- input location. 00140 //- 00141 //- NOTE: 00142 //- It is assumed that if the calling code needs the normal or the 00143 //- principal curvatures, it will *allocate* space for the CubitVectors 00144 //- before sending in the pointers. 00145 00146 virtual CubitStatus closest_points(DLIList<CubitVector *> &location_list, 00147 DLIList<CubitVector *> *closest_location_list = NULL, 00148 DLIList<CubitVector *> *unit_normal_list = NULL, 00149 DLIList<CubitVector *> *curvature1_list = NULL, 00150 DLIList<CubitVector *> *curvature2_list = NULL); 00151 00152 virtual CubitStatus principal_curvatures( 00153 CubitVector const& location, 00154 double& curvature_1, 00155 double& curvature_2, 00156 CubitVector* closest_location = NULL ) = 0; 00157 //R CubitStatus 00158 //R- CUBIT_SUCCESS/FAILURE 00159 //I location 00160 //I- The point at which the curvatures are being requested -- it is also 00161 //I- the point to which the closest point on the surface is returned. 00162 //I refvolume_ptr 00163 //O closest_location 00164 //O- The point on the surface, closest to the input location (this 00165 //O- might not be on the surface). This is input as a reference 00166 //O- so that the function can modify its contents. 00167 //O curvature_1/2 00168 //O- Returned principal curvature magnitudes. 00169 //- This functions computes the point on the surface that is closest 00170 //- to the input location and then calculates the magnitudes of the 00171 //- principal curvatures at this (possibly, new) point on the surface. 00172 00173 00174 virtual CubitStatus evaluate( double u, double v, 00175 CubitVector *position, 00176 CubitVector *normal, 00177 CubitVector *curvature1, 00178 CubitVector *curvature2 )=0; 00179 00180 // evaluate parameters on a surface 00181 // returns the position on the surface 00182 // returns the first order derivatives: du, dv 00183 // returns the second order derivatives: duu, duv, dvv 00184 virtual CubitStatus evaluate( double u, double v, CubitVector& pos, CubitVector deriv1[2], CubitVector deriv2[3]); 00185 00186 //R CubitStatus 00187 //R- CUBIT_SUCCESS/FAILURE 00188 //I u 00189 //I- The u coordinate value (local parametric space). 00190 //I v 00191 //I- The v coordinate value (local parametric space). 00192 //O- The coordinates of a point in global 00193 //- (world) space that correspond to the input {u,v} point in 00194 //- local parametric space. This is an optional output that is 00195 //- only calculated if the supplied CubitVector is not NULL; 00196 //O-The normal to the surface at the point with the given parametric position. 00197 //- This is an optional output that is only calculated if the 00198 //- supplied CubitVector is not NULL; 00199 //O- The principle curvature directions at the point with the given parametric position. 00200 //- These are optional outputs that are only calculated if the 00201 //- supplied CubitVectors curvature1 and curvature2 are both not NULL; 00202 00203 00204 virtual CubitVector position_from_u_v (double u, double v) = 0; 00205 //R CubitVector 00206 //R- The returned position in global space 00207 //I u 00208 //I- The u coordinate value (local parametric space). 00209 //I v 00210 //I- The v coordinate value (local parametric space). 00211 //- This function returns the coordinates of a point in global 00212 //- (world) space that correspond to the input {u,v} point in 00213 //- local parametric space. 00214 00215 virtual CubitStatus u_v_from_position ( 00216 CubitVector const& location, 00217 double& u, 00218 double& v, 00219 CubitVector* closest_location = NULL ) = 0; 00220 //R CubitStatus 00221 //R- CUBIT_SUCCESS/FAILURE 00222 //I location 00223 //I- The input point in global space 00224 //O closest_point 00225 //O- The point on the Surface closest to the input location 00226 //O u, v 00227 //O- The returned u, v coordinate values (in local parametric space) 00228 //O- of the closest_point 00229 //- This function returns the {u, v} coordinates of the point 00230 //- on the Surface closest to the input point (specified in global 00231 //- space). The closest_location is also returned. 00232 00233 virtual CubitBoolean is_periodic() = 0; 00234 //R CubitBoolean 00235 //R- CUBIT_TRUE/CUBIT_FALSE 00236 //- This function determines whether the underlying geometry of the 00237 //- Surface is periodic or not. Returns CUBIT_TRUE if it is and 00238 //- CUBIT_FALSE if it is not. 00239 00240 virtual CubitBoolean is_periodic_in_U( double& period ) = 0; 00241 //R CubitBoolean 00242 //R- CUBIT_TRUE/CUBIT_FALSE 00243 //O period 00244 //O- The value of the period in the U direction. 00245 //- Determines whether the surface object is 00246 //- periodic in the U direction or not. If it is, it 00247 //- returns CUBIT_TRUE and the value of the period. Otherwise, 00248 //- it returns CUBIT_FALSE and a value of 0.0 or the period. 00249 00250 virtual CubitBoolean is_periodic_in_V( double& period ) = 0; 00251 //R CubitBoolean 00252 //R- CUBIT_TRUE/CUBIT_FALSE 00253 //O period 00254 //O- The value of the period in the V direction. 00255 //- Determines whether the surface object is 00256 //- periodic in the V direction or not. If it is, it 00257 //- returns CUBIT_TRUE and the value of the period. Otherwise, 00258 //- it returns CUBIT_FALSE and a value of 0.0 or the period. 00259 00260 virtual CubitBoolean is_singular_in_U( double u_param ) = 0; 00261 virtual CubitBoolean is_singular_in_V( double v_param ) = 0; 00262 //R CubitBoolean 00263 //R- CUBIT_TRUE/CUBIT_FALSE 00264 //I double u parameter value. 00265 //- Determines if the surface is singular in a given direction 00266 //- at a given parameter value. 00267 00268 virtual CubitBoolean is_closed_in_U(){return CUBIT_FALSE;} 00269 virtual CubitBoolean is_closed_in_V(){return CUBIT_FALSE;} 00270 //R CubitBoolean 00271 //R- CUBIT_TRUE/CUBIT_FALSE 00272 //- Determines if the surface is closed, smoothly or not in the 00273 //- given parameter direction. 00274 //- A periodic surface is always closed but a closed surface is 00275 //- is not always periodic. 00276 //- For modelars that do allow closed surfaces they will need 00277 //- to implement this functionality. For instance, Pro does 00278 //- not allow such surfaces so it will always return false. 00279 //- will so Surface implements its own function. 00280 00281 virtual CubitStatus uv_derivitives( double u_param, 00282 double v_param, 00283 CubitVector &du, 00284 CubitVector &dv ) = 0; 00285 //R CubitStatus 00286 //R- CUBIT_SUCCESS/CUBIT_FAILURE 00287 //O- du, dv 00288 //- Determines the u and v derivitives from the given parameter 00289 //- values. 00290 00291 virtual CubitBoolean is_parametric() = 0; 00292 //R CubitBoolean 00293 //R- CUBIT_TRUE/CUBIT_FALSE 00294 //- This function determines whether the underlying geometry of the 00295 //- Surface is parametrically defined or not. Returns CUBIT_TRUE if 00296 //- it is and CUBIT_FALSE if it is not. 00297 00298 00299 00300 virtual CubitBoolean get_param_range_U( double& lower_bound, 00301 double& upper_bound ) = 0; 00302 //R CubitBoolean 00303 //R- CUBIT_TRUE/CUBIT_FALSE 00304 //O lower_bound 00305 //O- The lower bound of the parametric range in the U direction. 00306 //O- This is set to 0.0 if the surface is not parametric. 00307 //O upper_bound 00308 //O- The upper bound of the parametric range in the U direction. 00309 //O- This is set to 0.0 if the surface is not parametric. 00310 //- Returns the lower and upper parametric bounds of the 00311 //- surface in U, if it is parametric. Otherwise, it returns 00312 //- CUBIT_FALSE and zeroes for the upper and lower parametric 00313 //- bounds. 00314 00315 virtual CubitBoolean get_param_range_V( double& lower_bound, 00316 double& upper_bound ) = 0; 00317 //R CubitBoolean 00318 //R- CUBIT_TRUE/CUBIT_FALSE 00319 //O lower_bound 00320 //O- The lower bound of the parametric range in the V direction. 00321 //O- This is set to 0.0 if the surface is not parametric. 00322 //O upper_bound 00323 //O- The upper bound of the parametric range in the V direction. 00324 //O- This is set to 0.0 if the surface is not parametric. 00325 //- Returns the lower and upper parametric bounds of the 00326 //- surface in V, if it is parametric. Otherwise, it returns 00327 //- CUBIT_FALSE and zeroes for the upper and lower parametric 00328 //- bounds. 00329 00330 virtual CubitBoolean is_position_on( CubitVector &test_position ) = 0; 00331 //R CubitBoolean 00332 //R- CUBIT_TRUE/CUBIT_FALSE 00333 //I CubitVector 00334 //I- position, point where we want to test, whether or not it 00335 //- is on the surface. 00336 virtual void are_positions_on( DLIList<CubitVector *> &test_position_list, 00337 DLIList<CubitBoolean *> &is_on_list ); 00338 00339 virtual CubitPointContainment point_containment( const CubitVector &point ) = 0; 00340 virtual CubitPointContainment point_containment( double u, double v ) = 0; 00341 //R CubitPointContainment - is the point outside, inside or on the boundary? 00342 //R- CUBIT_PNT_OUTSIDE, CUBIT_PNT_INSIDE, CUBIT_PNT_BOUNDARY, 00343 // CUBIT_PNT_UNKNOWN 00344 //I CubitVector 00345 //I- position to check, known to be on the Surface 00346 //I double 00347 //I- u coordinate, if known (significantly faster, if this is known - however 00348 // if not known let the function figure it out) 00349 //I double 00350 //I- v coordinate, if known (significantly faster, if this is known - however 00351 // if not known let the function figure it out) 00352 00353 virtual CubitSense get_geometry_sense() = 0; 00354 //- Returns the relative sense of the Surface with respect 00355 //- to the geometry underneath. This is geometry engine dependent. 00356 //- Currently this is used for the tet mesher... 00357 00358 virtual CubitSense get_uv_sense() 00359 { 00360 return CUBIT_UNKNOWN; 00361 } 00362 00363 virtual CubitStatus get_projected_distance_on_surface( CubitVector *pos1, 00364 CubitVector *pos2, 00365 double &distance ) = 0; 00366 00367 00368 virtual GeometryType geometry_type() 00369 {return UNDEFINED_SURFACE_TYPE;}; 00370 //R GeometryType (enum) 00371 //R- The enumerated type of the geometric representation 00372 00373 virtual GeometryType is_cylindrical() 00374 {return UNDEFINED_SURFACE_TYPE;}; 00375 //R GeometryType (enum) 00376 //R- CYLINDRICAL_SURFACE_TYPE if true UNDEFINED_SURFACE_TYPE if false 00377 00378 // Now handled at RefFace level. -- j.k. Oct, 2003 00379 //virtual void reverse_sense() = 0; 00380 //- Switch the sense of this Surface wrt the RefFace that owns it. 00381 00382 virtual CubitStatus get_nurb_params( bool &rational, 00383 int °ree_u, 00384 int °ree_v, 00385 int &num_cntrl_pts_u, 00386 int &num_cntrl_pts_v, 00387 DLIList<CubitVector> &cntrl_pts, 00388 DLIList<double> &weights, 00389 DLIList<double> &u_knots, 00390 DLIList<double> &v_knots ) const = 0; 00391 //- Only valid for nurbs surfaces 00392 //O rational 00393 //O- True if the nurb is rational 00394 //O degree_u 00395 //O- The degree of the nurb in the u direction 00396 //O degree_v 00397 //O- The degree of the nurb in the v direction 00398 //O num_cntrl_pts_u 00399 //O- Number of control points in the u direction 00400 //O num_cntrl_pts_v 00401 //O- Number of control points in the v direction 00402 //O cntrl_pts 00403 //O- The control points stored as 00404 //O- cntrl_pts[0 ] = pt[u=0][v=0] 00405 //O- cntrl_pts[1 ] = pt[u=1][v=0] 00406 //O- ... 00407 //O- cntrl_pts[num_cntrl_pts_u-1] = pt[u=?][v=0] 00408 //O- cntrl_pts[num_cntrl_pts_u ] = pt[u=0][v=1] 00409 //O- ... 00410 //O weights 00411 //O- If rational, weights for each control point, stored in the same 00412 //O- order as the control points. No weights are returned if 00413 //O- rational == false 00414 //O u_knots 00415 //O- knot vector in the u direction 00416 //O v_knots 00417 //O- knot vector in the v direction 00418 00419 virtual CubitStatus get_sphere_params( CubitVector ¢er, 00420 double &radius ) const = 0; 00421 //- Only valid for spherical surfaces 00422 //O center 00423 //O- The center of the sphere 00424 //O radius 00425 //O- The radius of the sphere 00426 00427 virtual CubitStatus get_cone_params( CubitVector ¢er, 00428 CubitVector &normal, 00429 CubitVector &major_axis, 00430 double &radius_ratio, 00431 double &sine_angle, 00432 double &cos_angle ) const = 0; 00433 //- Only valid for conical surfaces. Cylinders are a special case of conicals. 00434 //O center 00435 //O- 00436 //O normal 00437 //O- 00438 //O major_axis 00439 //O- 00440 //O radius_ratio 00441 //O- 00442 //O sine_angle 00443 //O- 00444 //O cos_angle 00445 //O- 00446 00447 virtual CubitStatus get_torus_params( CubitVector ¢er, 00448 CubitVector &normal, 00449 double &major_radius, 00450 double &minor_radius ) const = 0; 00451 //- Only valid for torus surfaces. 00452 //O center 00453 //O- 00454 //O normal 00455 //O- 00456 //O major_radius 00457 //O- 00458 //O minor_radius 00459 //O- 00460 00461 protected: 00462 00463 private: 00464 00465 } ; 00466 00467 00468 #endif 00469