cgma
|
00001 //------------------------------------------------------------------------- 00002 // Filename : OCCSurface.hpp 00003 // 00004 // Purpose : 00005 // 00006 // Special Notes : 00007 // 00008 // Creator : Jane Hu 00009 // 00010 // Creation Date : 00011 // 00012 // Owner : 00013 //------------------------------------------------------------------------- 00014 00015 #ifndef SURFACE_OCC_HPP 00016 #define SURFACE_OCC_HPP 00017 00018 00019 // ********** BEGIN STANDARD INCLUDES ********** 00020 // ********** END STANDARD INCLUDES ********** 00021 00022 // ********** BEGIN OCC INCLUDES ********** 00023 00024 #include "TopoDS_Face.hxx" 00025 00026 // ********** END OCC INCLUDES ********** 00027 00028 00029 // ********** BEGIN CUBIT INCLUDES ********** 00030 00031 #include "CubitDefines.h" 00032 #include "Surface.hpp" 00033 00034 // ********** END CUBIT INCLUDES ********** 00035 00036 class TopologyEntity; 00037 class RefVolume; 00038 class RefFace; 00039 class RefVolume; 00040 class OCCShell; 00041 class OCCAttrib; 00042 00043 class OCCBody; 00044 class OCCLump; 00045 class OCCLoop; 00046 class OCCCoEdge; 00047 class OCCCurve; 00048 class OCCPoint; 00049 class BRepBuilderAPI_MakeShape; 00050 class BRepAlgoAPI_BooleanOperation; 00051 class BRepBuilderAPI_ModifyShape; 00052 class LocOpe_SplitShape; 00053 class TopoDS_Vertex; 00055 00056 class OCCSurface : public Surface 00057 { 00058 00059 public : 00060 00061 OCCSurface(TopoDS_Face *theFace); 00062 00063 virtual ~OCCSurface() ; 00064 //- The destructor 00065 00066 //if op is of BRepFilletAPI_MakeFillet2d type, need to input the 00067 //removed_vertex for update. 00068 static CubitStatus update_OCC_entity(TopoDS_Face& old_surface, 00069 TopoDS_Shape& new_surface, 00070 BRepBuilderAPI_MakeShape *op, 00071 TopoDS_Vertex* removed_vertex = NULL, 00072 LocOpe_SplitShape* sp = NULL); 00073 00074 virtual CubitStatus closest_point_along_vector(CubitVector& from_point, 00075 CubitVector& along_vector, 00076 CubitVector& point_on_surface); //This function has not been implemented. 00077 00078 00079 void add_hardpoint(OCCPoint* HardPoint){myHardPoints.append(HardPoint);} 00080 void remove_hardpoint(OCCPoint* HardPoint){myHardPoints.remove(HardPoint);} 00081 DLIList<OCCPoint*> get_hardpoints() {return myHardPoints;} 00082 00083 virtual void append_simple_attribute_virt(const CubitSimpleAttrib&); 00084 //R void 00085 //I 00086 //I- 00087 //I- that is to be appended to this OSME object. 00088 //- The purpose of this function is to append a 00089 //- attribute to the OSME. The is attached to each of the 00090 //- underlying solid model entities this one points to. 00091 00092 virtual void remove_simple_attribute_virt(const CubitSimpleAttrib&); 00093 //R void 00094 //I CubitSimpleAttrib* 00095 //I- A reference to a CubitSimpleAttrib object which is the object 00096 //I- that is to be removed to this OSME object. 00097 //- The purpose of this function is to remove a simple 00098 //- attribute from the OSME. The attribute is attached to each of the 00099 //- underlying solid model entities this one points to. 00100 00101 virtual void remove_all_simple_attribute_virt(); 00102 //R void 00103 //I- 00104 //- The purpose of this function is to remove all simple 00105 //- attributes from the OSME. 00106 00107 virtual CubitStatus get_simple_attribute(DLIList<CubitSimpleAttrib>&); 00108 virtual CubitStatus get_simple_attribute(const CubitString& name, 00109 DLIList<CubitSimpleAttrib>&); 00110 //R CubitSimpleAttrib* 00111 //R- the returned cubit simple attribute. 00112 //- The purpose of this function is to get the attributes 00113 //- of the geometry entity. The name is attached to the underlying solid 00114 //- model entity(ies) this one points to. 00115 //- MJP Note: 00116 //- This is the code that implements the requirement that names 00117 //- of VGI Entities propagate across solid model boolean 00118 //- operations. The success of this relies, of course, on the underlying 00119 //- solid modeler being able to propagate attributes across 00120 //- such operations on its entities. If it cannot, then "names" 00121 //- of VGI entities will not propagate. 00122 00123 virtual CubitBox bounding_box() const ; 00124 // see comments in GeometryEntity.hpp 00125 00126 virtual GeometryQueryEngine* 00127 get_geometry_query_engine() const; 00128 //R GeometryQueryEngine* 00129 //R- A pointer to the geometric modeling engine associated with 00130 //R- the object. 00131 //- This function returns a pointer to the geometric modeling engine 00132 //- associated with the object. 00133 00134 // Added by CAT 00135 virtual CubitStatus get_point_normal( CubitVector& , 00136 CubitVector& ); 00137 //- Only valid for planar surfaces 00138 //- Finds the underlying plane's origin and normal vector 00139 //- Returns CubitFailure if not a plane. The origin and normal 00140 //- are returned directly from the underlying format for a plane. 00141 00142 virtual void closest_point_trimmed(CubitVector from_point, 00143 CubitVector& point_on_surface); 00144 //R void 00145 //I CubitVector 00146 //I- point from which to find closest point on trimmed surface 00147 //O CubitVector 00148 //O- point on trimmed surface closest to passed-in point 00149 //- This function finds the closest point on a TRIMMED surface to the 00150 //- passed-in point. 00151 00152 virtual CubitStatus closest_point_uv_guess( 00153 CubitVector const& location, 00154 double &u, double &v, 00155 CubitVector* closest_location = NULL, 00156 CubitVector* unit_normal = NULL ); 00157 00158 virtual CubitSense get_shell_sense(ShellSM*) const; 00159 00160 virtual CubitStatus closest_point( 00161 CubitVector const& location, 00162 CubitVector* closest_location = NULL, 00163 CubitVector* unit_normal_ptr = NULL, 00164 CubitVector* curvature1_ptr = NULL, 00165 CubitVector* curvature2_ptr = NULL); 00166 //R CubitStatus 00167 //R- CUBIT_SUCCESS/FAILURE 00168 //I location 00169 //I- The point to which the closest point on the surface is desired. 00170 //O closest_location 00171 //O- The point on the Surface, closest to the 00172 //O- input location (which might not be on the Surface). This is 00173 //O- input as a reference so that the function can modify its 00174 //O- contents. 00175 //O unit_normal_ptr 00176 //O- The normal (represented as a unit vector) at the closest_location. 00177 //O- If this pointer is NULL, the normal is not returned. 00178 //O curvature1_ptr 00179 //O- The first principal curvature of the surface at closest_location. 00180 //O- If this pointer is NULL, this curvature is not returned. 00181 //O curvature2_ptr 00182 //O- The second principal curvature of the surface at closest_location. 00183 //O- If this pointer is NULL, this curvature is not returned. 00184 //- This function computes the point on the surface closest to the input 00185 //- location -- i.e., closest_location. 00186 //- The first Facet FACE in the list 00187 //- is queried. 00188 //- 00189 //- If the input pointer values of unit_normal, curvature1 and 00190 //- curvature2 00191 //- are non-NULL, the normal and principal curvatures, too, are 00192 //- returned. These are computed at closest_location, not at the 00193 //- input location. 00194 //- 00195 //- NOTE: 00196 //- It is assumed that if the calling code needs the normal or the 00197 //- principal curvatures, it will *allocate* space for the CubitVectors 00198 //- before sending in the pointers. 00199 00200 virtual CubitStatus principal_curvatures( 00201 CubitVector const& location, 00202 double& curvature_1, 00203 double& curvature_2, 00204 CubitVector* closest_location = NULL ); 00205 //R CubitStatus 00206 //R- CUBIT_SUCCESS/FAILURE 00207 //I location 00208 //I- The point at which the curvatures are being requested -- it is also 00209 //I- the point to which the closest point on the surface is returned. 00210 //I- curvatures. 00211 //O closest_location 00212 //O- The point on the surface, closest to the input location (this 00213 //O- might not be on the surface). This is input as a reference 00214 //O- so that the function can modify its contents. 00215 //O curvature_1/2 00216 //O- Returned principal curvature magnitudes. 00217 //- This functions computes the point on the surface that is closest 00218 //- to the input location and then calculates the magnitudes of the 00219 //- principal curvatures at this (possibly, new) point on the surface. 00220 00221 virtual CubitStatus evaluate( double u, double v, 00222 CubitVector *position, 00223 CubitVector *normal, 00224 CubitVector *curvature1, 00225 CubitVector *curvature2 ); 00226 00227 00228 00229 virtual CubitVector position_from_u_v (double u, double v); 00230 //R CubitVector 00231 //R- Returned position vector. 00232 //I u, v 00233 //I- Input point in {u.v} space 00234 //- This function returns the coordinates in world space of a point 00235 //- in the parameter space of this Surface object. 00236 00237 virtual CubitStatus u_v_from_position (CubitVector const& location, 00238 double& u, 00239 double& v, 00240 CubitVector* 00241 closest_location = NULL ); 00242 //R CubitStatus 00243 //R- CUBIT_SUCCESS/FAILURE 00244 //I location 00245 //I- The input point in global space 00246 //O closest_point 00247 //O- The point on the Surface closest to the input location 00248 //O u, v 00249 //O- The returned u, v coordinate values (in local parametric space) 00250 //O- of the closest_point 00251 //I refvolume_ptr 00252 //- This function returns the {u, v} coordinates of the point 00253 //- on the Surface closest to the input point (specified in global 00254 //- space). The closest_location is also returned. 00255 00256 virtual CubitBoolean is_periodic(); 00257 //R CubitBoolean 00258 //R- CUBIT_TRUE/CUBIT_FALSE 00259 //- This function determines whether the underlying geometry of the 00260 //- OCCSurface is periodic or not. Returns CUBIT_TRUE if it is and 00261 //- CUBIT_FALSE if it is not. 00262 //- MJP NOTE: 00263 //- The first Facet FACE in the list is queried. It is assumed 00264 //- that all the FACEs have the same underlying surface. 00265 00266 virtual CubitBoolean is_periodic_in_U( double& period ); 00267 //R CubitBoolean 00268 //R- CUBIT_TRUE/CUBIT_FALSE 00269 //O period 00270 //O- The value of the period in the U direction. 00271 //- Determines whether the Facet surface object associated 00272 //- with one of the FACEs of this OCCSurface object is 00273 //- periodic in the U direction or not. If it is, it 00274 //- returns CUBIT_TRUE and the value of the period. Otherwise, 00275 //- it returns CUBIT_FALSE and a value of 0.0 or the period. 00276 //- MJP NOTE: 00277 //- The first Facet FACE in the list is queried. It is assumed 00278 //- that all the FACEs have the same underlying surface. 00279 00280 virtual CubitBoolean is_periodic_in_V( double& period ); 00281 //R CubitBoolean 00282 //R- CUBIT_TRUE/CUBIT_FALSE 00283 //O period 00284 //O- The value of the period in the V direction. 00285 //- Determines whether the Facet surface object associated 00286 //- with one of the FACEs of this OCCSurface object is 00287 //- periodic in the V direction or not. If it is, it 00288 //- returns CUBIT_TRUE and the value of the period. Otherwise, 00289 //- it returns CUBIT_FALSE and a value of 0.0 or the period. 00290 //- MJP NOTE: 00291 //- The first Facet FACE in the list is queried. It is assumed 00292 //- that all the FACEs have the same underlying surface. 00293 00294 virtual CubitBoolean is_singular_in_U( double u_param ); 00295 virtual CubitBoolean is_singular_in_V( double v_param ); 00296 //R CubitBoolean 00297 //R- CUBIT_TRUE/CUBIT_FALSE 00298 //I double u/v parameter value. 00299 //- Determines if the surface is singular in a given direction 00300 //- at a given parameter value. 00301 00302 virtual CubitBoolean is_closed_in_U(); 00303 virtual CubitBoolean is_closed_in_V(); 00304 //R CubitBoolean 00305 //R- CUBIT_TRUE/CUBIT_FALSE 00306 //- Determines if the surface is closed, smoothly or not in the 00307 //- given parameter direction. 00308 //- A periodic surface is always closed but a closed surface is 00309 //- is not always periodic. 00310 00311 virtual CubitStatus uv_derivitives( double u_param, 00312 double v_param, 00313 CubitVector &du, 00314 CubitVector &dv ); 00315 //R CubitStatus 00316 //R- CUBIT_SUCCESS/CUBIT_FAILURE 00317 //O- du, dv 00318 //- Determines the u and v derivitives from the given parameter 00319 //- values. 00320 00321 TopoDS_Face *get_TopoDS_Face() 00322 {if (myTopoDSFace && !myTopoDSFace->IsNull()) assert (myTopoDSFace->ShapeType() == TopAbs_FACE); return myTopoDSFace;} 00323 void set_TopoDS_Face(TopoDS_Face& face); 00324 00325 int get_loops(DLIList<OCCLoop*>&); 00326 00327 int get_coedges(DLIList<OCCCoEdge*>&); 00328 00329 int get_curves(DLIList<OCCCurve*>&); 00330 00331 int get_points(DLIList<OCCPoint*>& points); 00332 00333 void set_shell(OCCShell* shell) 00334 { myShell = shell;} 00335 00336 void set_lump(OCCLump* lump) 00337 { myLump = lump;} 00338 00339 void set_body(OCCBody* body) 00340 { myBody = body;} 00341 00342 OCCShell* my_shell() {return myShell;} 00343 00344 OCCLump* my_lump() {return myLump;} 00345 00346 OCCBody* my_body() {return myBody;} 00347 00348 CubitStatus get_bodies(DLIList<OCCBody*> &bodies); 00349 00350 virtual CubitBoolean is_parametric(); 00351 //R CubitBoolean 00352 //R- CUBIT_TRUE/CUBIT_FALSE 00353 //- This method returns CUBIT_TRUE if a parametric representation 00354 //- is available for the surface 00355 00356 virtual CubitBoolean get_param_range_U( double& lower_bound, 00357 double& upper_bound ); 00358 //R CubitBoolean 00359 //R- CUBIT_TRUE/CUBIT_FALSE 00360 //O lower_bound 00361 //O- The lower bound of the parametric range in the U direction. 00362 //O- This is set to 0.0 if the surface is not parametric. 00363 //O upper_bound 00364 //O- The upper bound of the parametric range in the U direction. 00365 //O- This is set to 0.0 if the surface is not parametric. 00366 //- Returns the lower and upper parametric bounds of the 00367 //- surface in U, if it is parametric. Otherwise, it returns 00368 //- CUBIT_FALSE and zeroes for the upper and lower parametric 00369 //- bounds. 00370 //- MJP NOTE: 00371 //- The first Facet FACE in the list is queried. It is assumed 00372 //- that all the FACEs have the same underlying surface. 00373 00374 virtual CubitBoolean get_param_range_V( double& lower_bound, 00375 double& upper_bound ); 00376 //R CubitBoolean 00377 //R- CUBIT_TRUE/CUBIT_FALSE 00378 //O lower_bound 00379 //O- The lower bound of the parametric range in the V direction. 00380 //O- This is set to 0.0 if the surface is not parametric. 00381 //O upper_bound 00382 //O- The upper bound of the parametric range in the V direction. 00383 //O- This is set to 0.0 if the surface is not parametric. 00384 //- Returns the lower and upper parametric bounds of the 00385 //- surface in V, if it is parametric. Otherwise, it returns 00386 //- CUBIT_FALSE and zeroes for the upper and lower parametric 00387 //- bounds. 00388 //- MJP NOTE: 00389 //- The first Facet FACE in the list is queried. It is assumed 00390 //- that all the FACEs have the same underlying surface. 00391 00392 virtual CubitBoolean is_position_on( CubitVector &test_position ); 00393 //R CubitBoolean 00394 //R- CUBIT_TRUE/CUBIT_FALSE 00395 //I CubitVector 00396 //I- position, point where we want to test, whether or not it 00397 //- is on the surface. 00398 00399 virtual CubitPointContainment point_containment( const CubitVector &point ); 00400 virtual CubitPointContainment point_containment( double u, double v ); 00401 00402 virtual CubitStatus get_projected_distance_on_surface( CubitVector *pos1, 00403 CubitVector *pos2, 00404 double &distance ); 00405 00406 virtual CubitStatus get_nurb_params( bool &rational, 00407 int °ree_u, 00408 int °ree_v, 00409 int &num_cntrl_pts_u, 00410 int &num_cntrl_pts_v, 00411 DLIList<CubitVector> &cntrl_pts, 00412 DLIList<double> &weights, 00413 DLIList<double> &u_knots, 00414 DLIList<double> &v_knots ) const ; 00415 //- Only valid for nurbs surfaces 00416 //O rational 00417 //O- True if the nurb is rational 00418 //O degree_u 00419 //O- The degree of the nurb in the u direction 00420 //O degree_v 00421 //O- The degree of the nurb in the v direction 00422 //O num_cntrl_pts_u 00423 //O- Number of control points in the u direction 00424 //O num_cntrl_pts_v 00425 //O- Number of control points in the v direction 00426 //O cntrl_pts 00427 //O- The control points stored as 00428 //O- cntrl_pts[0 ] = pt[u=0][v=0] 00429 //O- cntrl_pts[1 ] = pt[u=1][v=0] 00430 //O- ... 00431 //O- cntrl_pts[num_cntrl_pts_u-1] = pt[u=?][v=0] 00432 //O- cntrl_pts[num_cntrl_pts_u ] = pt[u=0][v=1] 00433 //O- ... 00434 //O weights 00435 //O- If rational, weights for each control point, stored in the same 00436 //O- order as the control points. No weights are returned if 00437 //O- rational == false 00438 //O u_knots 00439 //O- knot vector in the u direction 00440 //O v_knots 00441 //O- knot vector in the v direction 00442 00443 virtual CubitStatus get_sphere_params( CubitVector ¢er, 00444 double &radius ) const ; 00445 //- Only valid for spherical surfaces 00446 //O center 00447 //O- The center of the sphere 00448 //O radius 00449 //O- The radius of the sphere 00450 00451 virtual CubitStatus get_cone_params( CubitVector ¢er, 00452 CubitVector &normal, 00453 CubitVector &major_axis, 00454 double &radius_ratio, 00455 double &sine_angle, 00456 double &cos_angle ) const ; 00457 //- Only valid for conical surfaces. Cylinders are a special case of conicals. 00458 //O center 00459 //O- 00460 //O normal 00461 //O- 00462 //O major_axis 00463 //O- 00464 //O radius_ratio 00465 //O- 00466 //O sine_angle 00467 //O- 00468 //O cos_angle 00469 //O- 00470 00471 virtual CubitStatus get_torus_params( CubitVector ¢er, 00472 CubitVector &normal, 00473 double &major_radius, 00474 double &minor_radius ) const ; 00475 //- Only valid for torus surfaces. 00476 //O center 00477 //O- 00478 //O normal 00479 //O- 00480 //O major_radius 00481 //O- 00482 //O minor_radius 00483 //O- 00484 00485 GeometryType geometry_type(); 00486 //R GeometryType (enum) 00487 //R- The enumerated type of the geometric representation 00488 00489 virtual double measure(); 00490 //R double 00491 //R- The numeric value of the measure (its units depend on the dimension 00492 //R- of the RefEntity being "measured") 00493 //- A generic geometric extent function. 00494 //- Returns volume for Lump, area for Surface, length for Curve and 00495 //- 1.0 for Point 00496 00497 CubitVector center_point(); 00498 virtual CubitSense get_geometry_sense(); 00499 //- Return the relative surface sense. (see below) 00500 00501 virtual void get_parents_virt( DLIList<TopologyBridge*>& parents ); 00502 virtual void get_children_virt( DLIList<TopologyBridge*>& children ); 00503 00504 CubitBoolean is_flat(); 00505 CubitBoolean is_spherical(); 00506 CubitBoolean is_conical(); 00507 00508 CubitStatus update_OCC_entity( BRepBuilderAPI_ModifyShape *aBRepTrsf, 00509 BRepAlgoAPI_BooleanOperation *op = NULL); 00510 protected: 00511 00512 private: 00513 //CubitSense sense_; 00514 //- The sense of the RefFace that owns this Surface with respect 00515 //- to the positive sense of the first FACE in FACEPtrList_. 00516 //- When a Surface is first constructed, this value is arbitrarily 00517 //- set to CUBIT_FORWARD. 00518 //- In the case of Surfaces, the normal is used in determining 00519 //- the relative sense value. 00520 //- MJP NOTE: 00521 //- Not only does the RefFace have a sense wrt its Surface, but each 00522 //- Facet FACE has a sense wrt its underlying "surface" object. 00523 00524 TopoDS_Face *myTopoDSFace; 00525 00526 //Following 3 members are only for sheeted body. 00527 OCCShell* myShell; 00528 OCCLump* myLump; 00529 OCCBody* myBody; 00530 DLIList<OCCPoint*> myHardPoints; 00531 00532 }; 00533 00534 00535 // ********** BEGIN INLINE FUNCTIONS ********** 00536 // ********** END INLINE FUNCTIONS ********** 00537 00538 // ********** BEGIN FRIEND FUNCTIONS ********** 00539 // ********** END FRIEND FUNCTIONS ********** 00540 00541 // ********** BEGIN EXTERN FUNCTIONS ********** 00542 // ********** END EXTERN FUNCTIONS ********** 00543 00544 #endif 00545