cgma
|
00001 //------------------------------------------------------------------------- 00002 // Filename : CompositeSurface.hpp 00003 // 00004 // Purpose : A class for composited surface geometry 00005 // 00006 // Special Notes : 00007 // 00008 // Creator : Jason Kraftcheck 00009 // 00010 // Creation Date : 03/10/98 00011 // 00012 // Owner : Jason Kraftcheck 00013 //------------------------------------------------------------------------- 00014 00015 #ifndef COMPOSITE_SURFACE_HPP 00016 #define COMPOSITE_SURFACE_HPP 00017 00018 #include "VGDefines.h" 00019 #include "CompositeGeom.hpp" 00020 #include "Surface.hpp" 00021 #include "TBOwner.hpp" 00022 #include "HiddenEntitySet.hpp" 00023 #include "CompositeLoop.hpp" 00024 #include "CompositeCoSurf.hpp" 00025 00026 class CompositeCoSurf; 00027 class CompositeEngine; 00028 class CompositePoint; 00029 class CompositeCurve; 00030 class CompositeShell; 00031 class CompositeLump; 00032 class CompSurfFacets; 00033 class GMem; 00034 00035 class CompositeSurface: public Surface, public TBOwner 00036 { 00037 friend class CompositeEngine; 00038 00039 public: 00040 CompositeSurface( Surface* surf_ptr ); 00041 CompositeSurface( CompositeGeom* geom_ptr ); 00042 //- Constructor 00043 00044 virtual ~CompositeSurface(); 00045 //- Destructor 00046 00047 //CubitStatus add( Surface* surface, CubitSense relative_sense ); 00048 //CubitStatus remove( Surface* surface ); 00049 void get_ignored_surfs(DLIList<Surface*> &surfs); 00050 int num_surfs() const; 00051 int index_of( Surface* surface ) const; 00052 void update(); 00053 Surface* get_surface( int index ) const; 00054 CubitSense get_sense( int index ) const; 00055 Surface* remove_surface( int index ); 00056 void ignore_surface(int surface_id); 00057 void ignore_surface(Surface *surf); 00058 void unignore_surface(int surface_id); 00059 CompositeLoop* first_loop() const; 00060 CompositeLoop* next_loop( CompositeLoop* after_this = 0 ) const; 00061 CubitStatus add( CompositeLoop* loop ); 00062 CubitStatus remove( CompositeLoop* loop ); 00063 00064 CubitStatus add( CompositeCoSurf* cosurf ); 00065 CubitStatus remove( CompositeCoSurf* cosurf ); 00066 00067 CompositeCoSurf* next_co_surface( CompositeCoSurf* prev = 0 ) const; 00068 00069 CompositeCoSurf* find_first( CompositeShell* shell ) const; 00070 // Get the first CoSurface connecting this surface w/ the passed shell 00071 CompositeCoSurf* find_first( CompositeLump* lump ) const; 00072 // Get the first CoSurface connecting this surface w/ a 00073 // shell owned by the passed volume 00074 CompositeCoSurf* find_next( CompositeCoSurf* cosurf ) const; 00075 // Get the next CoSurface after the passed CoSurface and 00076 // with the same Shell as the passed CoSurface. 00077 00078 void get_curves( DLIList<CompositeCurve*>& curves ); 00079 00080 HiddenEntitySet& hidden_entities(); 00081 bool has_hidden_entities() const; 00082 00083 CompositeSurface* split( VGArray<int>& indices_to_move ); 00084 CubitStatus combine( CompositeSurface* dead_surface ); 00085 00086 CubitStatus stitch( CompositeSurface* stitch_partner ); 00087 CompositeSurface* unstitch( ); 00088 CompositeSurface* get_stitch_partner() const 00089 { return stitchPartner; } 00090 00091 00092 /************************************************ 00093 **** Methods Inhereted from GeometryEntity ***** 00094 ************************************************/ 00095 CubitBox bounding_box() const; 00096 double measure(); 00097 GeometryQueryEngine* get_geometry_query_engine() const; 00098 GeometryType geometry_type(); 00099 00100 00101 /************************************************ 00102 ******** Methods Inhereted from TBOwner ******** 00103 ************************************************/ 00104 CubitStatus remove_bridge( TopologyBridge* bridge ); 00105 CubitStatus swap_bridge( TopologyBridge* old_tb, TopologyBridge* new_tb, 00106 bool reversed ); 00107 CubitBoolean contains_bridge( TopologyBridge* bridge ) const; 00108 void notify_reversed( TopologyBridge* bridge ); 00109 void notify_split( TopologyBridge* new_bridge, TopologyBridge* old_bridge ); 00110 void notify_topology_modified( TopologyBridge* bridge ); 00111 00112 /************************************************ 00113 **** Methods Inhereted from TopologyBridge ***** 00114 ************************************************/ 00115 void append_simple_attribute_virt( const CubitSimpleAttrib& simple_attrib_ptr ); 00116 void remove_simple_attribute_virt( const CubitSimpleAttrib& simple_attrib_ptr ); 00117 void remove_all_simple_attribute_virt(); 00118 CubitStatus get_simple_attribute( DLIList<CubitSimpleAttrib>& attrib_list ); 00119 CubitStatus get_simple_attribute( const CubitString& name, 00120 DLIList<CubitSimpleAttrib>& attrib_list ); 00121 00122 00123 void get_parents_virt( DLIList<TopologyBridge*>& parents ); 00124 void get_children_virt( DLIList<TopologyBridge*>& children ); 00125 int layer() const { return COMPOSITE_LAYER; } 00126 00127 /********************************************************** 00128 **** Methods Inhereted from Surface, and implemented ***** 00129 **********************************************************/ 00130 virtual CubitSense get_shell_sense( ShellSM* shell_ptr ) const; 00131 00132 virtual void closest_point_trimmed( CubitVector from_point, 00133 CubitVector& result ); 00134 virtual CubitStatus get_point_normal( CubitVector& origin, 00135 CubitVector& normal ); 00136 00137 virtual CubitStatus closest_point_uv_guess( 00138 CubitVector const& location, 00139 double &u, double &v, 00140 CubitVector* closest_location = NULL, 00141 CubitVector* unit_normal = NULL ); 00142 00143 virtual CubitStatus evaluate( double u, double v, 00144 CubitVector *position, 00145 CubitVector *normal, 00146 CubitVector *curvature1, 00147 CubitVector *curvature2 ); 00148 00149 virtual CubitStatus get_projected_distance_on_surface( CubitVector *pos1, 00150 CubitVector *pos2, 00151 double &distance ); 00152 00153 virtual CubitStatus closest_point( CubitVector const& location, 00154 CubitVector* closest_location = NULL, 00155 CubitVector* unit_normal = NULL, 00156 CubitVector* curvature1 = NULL, 00157 CubitVector* curvature2 = NULL ); 00158 00159 virtual CubitStatus closest_point_along_vector(CubitVector& from_point, 00160 CubitVector& along_vector, 00161 CubitVector& point_on_surface); 00162 00163 virtual CubitStatus principal_curvatures( CubitVector const& location, 00164 double& curvature_1, 00165 double& curvature_2, 00166 CubitVector* closest_location ); 00167 virtual CubitBoolean is_parametric(); 00168 virtual CubitBoolean is_position_on(CubitVector& position); 00169 virtual CubitPointContainment point_containment( const CubitVector &point ); 00170 virtual CubitPointContainment point_containment( double u, double v ); 00171 // virtual CubitPointContainment point_containment( CubitVector &point, 00172 // double u, double v ); 00173 virtual CubitSense get_geometry_sense(); 00174 virtual void reverse_sense(); 00175 00176 00177 /************************************************************** 00178 **** Methods Inhereted from Surface, and not implemented ***** 00179 **************************************************************/ 00180 virtual CubitVector position_from_u_v( double u, double v ); 00181 virtual CubitStatus u_v_from_position( CubitVector const& position, 00182 double& u, double& v, 00183 CubitVector* closest_point ); 00184 virtual CubitBoolean is_periodic(); 00185 virtual CubitBoolean is_periodic_in_U( double& period ); 00186 virtual CubitBoolean is_periodic_in_V( double& period ); 00187 virtual CubitBoolean is_singular_in_U( double u_value ); 00188 virtual CubitBoolean is_singular_in_V( double v_value ); 00189 virtual CubitBoolean is_closed_in_U(); 00190 virtual CubitBoolean is_closed_in_V(); 00191 virtual CubitStatus uv_derivitives( double u, double v, 00192 CubitVector& du, 00193 CubitVector& dv ); 00194 virtual CubitBoolean get_param_range_U( double& lower, double& upper ); 00195 virtual CubitBoolean get_param_range_V( double& lower, double& upper ); 00196 00197 virtual CubitStatus get_sphere_params( CubitVector ¢er, 00198 double &radius ) const; 00199 //- Only valid for spherical surfaces 00200 //O center 00201 //O- The center of the sphere 00202 //O radius 00203 //O- The radius of the sphere 00204 00205 virtual CubitStatus get_cone_params( CubitVector ¢er, 00206 CubitVector &normal, 00207 CubitVector &major_axis, 00208 double &radius_ratio, 00209 double &sine_angle, 00210 double &cos_angle ) const; 00211 //- Only valid for conical surfaces. Cylinders are a special case of conicals. 00212 //O center 00213 //O- 00214 //O normal 00215 //O- 00216 //O major_axis 00217 //O- 00218 //O radius_ratio 00219 //O- 00220 //O sine_angle 00221 //O- 00222 //O cos_angle 00223 //O- 00224 00225 virtual CubitStatus get_torus_params( CubitVector ¢er, 00226 CubitVector &normal, 00227 double &major_radius, 00228 double &minor_radius ) const; 00229 //- Only valid for torus surfaces. 00230 //O center 00231 //O- 00232 //O normal 00233 //O- 00234 //O major_radius 00235 //O- 00236 //O minor_radius 00237 //O- 00238 00239 virtual CubitStatus get_nurb_params( bool &rational, 00240 int °ree_u, 00241 int °ree_v, 00242 int &num_cntrl_pts_u, 00243 int &num_cntrl_pts_v, 00244 DLIList<CubitVector> &cntrl_pts, 00245 DLIList<double> &weights, 00246 DLIList<double> &u_knots, 00247 DLIList<double> &v_knots ) const; 00248 //- Only valid for nurbs surfaces 00249 //O rational 00250 //O- True if the nurb is rational 00251 //O degree_u 00252 //O- The degree of the nurb in the u direction 00253 //O degree_v 00254 //O- The degree of the nurb in the v direction 00255 //O num_cntrl_pts_u 00256 //O- Number of control points in the u direction 00257 //O num_cntrl_pts_v 00258 //O- Number of control points in the v direction 00259 //O cntrl_pts 00260 //O- The control points stored as 00261 //O- cntrl_pts[0 ] = pt[u=0][v=0] 00262 //O- cntrl_pts[1 ] = pt[u=1][v=0] 00263 //O- ... 00264 //O- cntrl_pts[num_cntrl_pts_u-1] = pt[u=?][v=0] 00265 //O- cntrl_pts[num_cntrl_pts_u ] = pt[u=0][v=1] 00266 //O- ... 00267 //O weights 00268 //O- If rational, weights for each control point, stored in the same 00269 //O- order as the control points. No weights are returned if 00270 //O- rational == false 00271 //O u_knots 00272 //O- knot vector in the u direction 00273 //O v_knots 00274 //O- knot vector in the v direction 00275 00276 void get_hidden_curves( DLIList<Curve*>& curves ); 00277 00278 void print_debug_info( const char* line_prefix = 0, bool brief = false ); 00279 00280 int closest_underlying_surface( const CubitVector& position ); 00281 00282 static void print_cpt_stats(); 00283 static void reset_cpt_stats(); 00284 00285 void read_attributes() { compGeom->read_attributes(); } 00286 void write_attributes() { compGeom->write_attributes(); } 00287 00288 00289 CubitStatus get_graphics( GMem& gmem ); 00290 00291 // handles transformation of composite surface 00292 // child loops, coedges, etc. must be handled separately 00293 void notify_transformed(); 00294 00295 protected: 00296 00297 void update_facet_tool(); 00298 void update_facets_to_ignore(); 00299 CubitStatus closest_trimmed( int underlying_surface, 00300 const CubitVector& position, 00301 CubitVector& result ); 00302 00303 void update_modified( Surface* modified_surface, 00304 DLIList<CompositeCurve*>& new_curves ); 00305 void update_modified(); 00306 bool is_dead_coedge( CompositeCoEdge* coedge ); 00307 void remove_dead_coedge( CompositeCoEdge* coedge ); 00308 00309 private: 00310 int HadBridgeRemoved; 00311 00312 DLIList<Surface*> surfacesToIgnore; 00313 00314 // these have no implementation, just private delcarations 00315 // to prevent the compiler from generating default implementations 00316 CompositeSurface& operator=(const CompositeSurface&); 00317 CompositeSurface(const CompositeSurface&); 00318 00319 CompositeGeom *compGeom; 00320 CompositeSurface *stitchPartner; 00321 00322 CompositeCoSurf* firstCoSurf; 00323 00324 CompositeLoop* firstLoop; 00325 00326 HiddenEntitySet* hiddenSet; 00327 00328 CompSurfFacets* facetTool; 00329 }; 00330 00331 00332 inline Surface* CompositeSurface::get_surface( int index ) const 00333 { return dynamic_cast<Surface*>(compGeom->entity(index)); } 00334 00335 inline CubitSense CompositeSurface::get_sense( int index ) const 00336 { return compGeom->sense(index); } 00337 00338 inline int CompositeSurface::num_surfs() const 00339 { return compGeom->num_entities(); } 00340 00341 inline int CompositeSurface::index_of( Surface* surf ) const 00342 { return compGeom->index_of( surf ); } 00343 00344 inline void CompositeSurface::update() 00345 { compGeom->update_cached_data(); } 00346 inline CompositeLoop* CompositeSurface::first_loop( ) const 00347 { return firstLoop; } 00348 00349 inline CompositeLoop* CompositeSurface::next_loop( CompositeLoop* loop ) const 00350 { return !loop ? firstLoop : loop->mySurface == this ? loop->loopNext : 0; } 00351 00352 inline CompositeCoSurf* CompositeSurface::next_co_surface( CompositeCoSurf* prev ) const 00353 { return prev ? prev->surfaceNext : firstCoSurf; } 00354 00355 inline HiddenEntitySet& CompositeSurface::hidden_entities() 00356 { 00357 if( !hiddenSet ) 00358 hiddenSet = new HiddenEntitySet(this); 00359 return *hiddenSet; 00360 } 00361 00362 00363 #endif 00364