cgma
PartitionSurface.hpp
Go to the documentation of this file.
00001 //-------------------------------------------------------------------------
00002 // Filename      : PartitionSurface.hpp
00003 //
00004 // Purpose       : 
00005 //
00006 // Special Notes : 
00007 //
00008 // Creator       : Jason Kraftcheck
00009 //
00010 // Creation Date : 04/21/02
00011 //-------------------------------------------------------------------------
00012 
00013 #ifndef PARTITION_SURFACE_HPP
00014 #define PARTITION_SURFACE_HPP
00015 
00016 #include <set>
00017 #include "Surface.hpp"
00018 #include "PartitionEntity.hpp"
00019 #include "PartitionCoSurf.hpp"
00020 #include "PartitionLoop.hpp"
00021 
00022 class FacetEvalTool;
00023 class CubitFacetData;
00024 class PartitionShell;
00025 class PartitionLump;
00026 class CubitFacetEdge;
00027 class CubitFacet;
00028 class CubitFacetEdgeData;
00029 class CubitPointData;
00030 
00031 class PartitionSurface : public Surface, 
00032                          public PartitionEntity
00033 {
00034 
00035 public:
00036 
00037   virtual CubitStatus combine( PartitionSurface* dead_surface );
00038   
00039   static PartitionSurface* construct( const CubitSimpleAttrib& attrib, PartitionLump* vol );
00040 
00041   PartitionSurface( PartitionLump* owner );
00042   
00043   PartitionSurface* split( DLIList<CubitFacetData*>& facets_to_move );
00044 
00045   virtual ~PartitionSurface();
00046   
00047   int num_loops() const;
00048   PartitionLoop* next_loop( const PartitionLoop* prev = 0 ) const;
00049   
00050   CubitStatus add( PartitionLoop* loop );
00051   CubitStatus remove( PartitionLoop* loop );
00052   
00053   CubitStatus add( PartitionCoSurf* cosurf );
00054   CubitStatus remove( PartitionCoSurf* cosurf );
00055   
00056   PartitionCoSurf* next_co_surface( const PartitionCoSurf* prev = 0 ) const;
00057   PartitionCoSurf* find_first( const PartitionShell* shell ) const;
00058     // Get the first CoSurface connecting this surface w/ the passed shell
00059   PartitionCoSurf* find_first( const PartitionLump* lump ) const;
00060     // Get the first CoSurface connecting this surface w/ a
00061     // shell owned by the passed volume
00062   PartitionCoSurf* find_next( const PartitionCoSurf* cosurf ) const;
00063     // Get the next CoSurface after the passed CoSurface and
00064     // with the same Shell as the passed CoSurface.
00065   PartitionCoSurf* find_first( const PartitionShell* shell, CubitSense sense ) const;
00066     // Get the first CoSurface w/ the passed shell and sense
00067   
00068   void get_points( DLIList<PartitionPoint*>& list ) const;
00069   
00070   virtual CubitStatus save( CubitSimpleAttrib& attrib );
00071   
00072   CubitBox bounding_box() const;
00073 
00074   double measure();
00075   GeometryType geometry_type();
00076 
00077 
00078   virtual CubitStatus move_to_geometry( CubitVector& position );
00079   virtual void closest_point_trimmed( CubitVector from, CubitVector& closest);
00080   virtual CubitStatus get_point_normal( CubitVector& point, CubitVector& normal );
00081 
00082   virtual CubitStatus closest_point_uv_guess(  
00083       CubitVector const& location,
00084       double &u, double &v,
00085       CubitVector* closest_location = NULL,
00086       CubitVector* unit_normal = NULL );
00087 
00088   virtual CubitStatus evaluate( double u, double v,
00089                                 CubitVector *position,                                   
00090                                 CubitVector *normal,
00091                                 CubitVector *curvature1,
00092                                 CubitVector *curvature2 );
00093 
00094   virtual CubitStatus get_projected_distance_on_surface( CubitVector *pos1,
00095                                                          CubitVector *pos2, 
00096                                                          double &distance );
00097 
00098   virtual CubitStatus closest_point( CubitVector const& pos, 
00099                              CubitVector* close = 0, CubitVector* norm = 0,
00100                              CubitVector* curv1 = 0, CubitVector* curv2 = 0);
00101   virtual CubitStatus principal_curvatures( CubitVector const& loc, 
00102                                     double& curv1, double& curv2,
00103                                     CubitVector* closest_location=0 );
00104 
00105   virtual CubitVector position_from_u_v( double u, double v );
00106   virtual CubitStatus u_v_from_position( CubitVector const& location,
00107                                  double& u, double& v,
00108                                  CubitVector* closest_location = NULL );
00109   
00110   virtual CubitStatus closest_point_along_vector( CubitVector& from_point, 
00111                                                   CubitVector& along_vector,
00112                                                   CubitVector& point_on_surface);
00113   virtual CubitBoolean is_periodic();
00114   virtual CubitBoolean is_periodic_in_U( double& period );
00115   virtual CubitBoolean is_periodic_in_V( double& period );
00116   virtual CubitBoolean is_singular_in_U( double u_param );
00117   virtual CubitBoolean is_singular_in_V( double v_param );
00118   virtual CubitBoolean is_closed_in_U();
00119   virtual CubitBoolean is_closed_in_V();
00120 
00121   virtual CubitStatus get_sphere_params( CubitVector &center,
00122                                          double &radius ) const;
00123     //- Only valid for spherical surfaces
00124     //O center
00125     //O- The center of the sphere
00126     //O radius
00127     //O- The radius of the sphere
00128 
00129   virtual CubitStatus get_cone_params( CubitVector &center,
00130                                        CubitVector &normal,
00131                                        CubitVector &major_axis,
00132                                        double &radius_ratio,
00133                                        double &sine_angle,
00134                                        double &cos_angle ) const;
00135     //- Only valid for conical surfaces.  Cylinders are a special case of conicals.
00136     //O center
00137     //O- 
00138     //O normal
00139     //O- 
00140     //O major_axis
00141     //O- 
00142     //O radius_ratio
00143     //O- 
00144     //O sine_angle
00145     //O- 
00146     //O cos_angle
00147     //O- 
00148 
00149     virtual CubitStatus get_torus_params( CubitVector &center,
00150                                         CubitVector &normal,
00151                                         double &major_radius,
00152                                         double &minor_radius ) const;
00153     //- Only valid for torus surfaces.
00154     //O center
00155     //O- 
00156     //O normal
00157     //O- 
00158     //O major_radius
00159     //O- 
00160     //O minor_radius
00161     //O- 
00162 
00163   virtual CubitStatus get_nurb_params( bool &rational,
00164                                        int &degree_u,
00165                                        int &degree_v,
00166                                        int &num_cntrl_pts_u,
00167                                        int &num_cntrl_pts_v,
00168                                        DLIList<CubitVector> &cntrl_pts,
00169                                        DLIList<double> &weights,
00170                                        DLIList<double> &u_knots,
00171                                        DLIList<double> &v_knots ) const;
00172   //- Only valid for nurbs surfaces
00173   //O rational
00174   //O-   True if the nurb is rational
00175   //O degree_u
00176   //O-   The degree of the nurb in the u direction
00177   //O degree_v
00178   //O-   The degree of the nurb in the v direction
00179   //O num_cntrl_pts_u
00180   //O-   Number of control points in the u direction
00181   //O num_cntrl_pts_v
00182   //O-   Number of control points in the v direction
00183   //O cntrl_pts
00184   //O-   The control points stored as
00185   //O-           cntrl_pts[0                ] = pt[u=0][v=0]
00186   //O-           cntrl_pts[1                ] = pt[u=1][v=0]
00187   //O-               ...
00188   //O-           cntrl_pts[num_cntrl_pts_u-1] = pt[u=?][v=0]
00189   //O-           cntrl_pts[num_cntrl_pts_u  ] = pt[u=0][v=1]
00190   //O-               ...
00191   //O weights
00192   //O-   If rational, weights for each control point, stored in the same
00193   //O-   order as the control points.  No weights are returned if
00194   //O-   rational == false
00195   //O u_knots
00196   //O-   knot vector in the u direction
00197   //O v_knots
00198   //O-   knot vector in the v direction
00199 
00200   virtual CubitStatus uv_derivitives( double u, double v,
00201                               CubitVector &du, CubitVector &dv );
00202   virtual CubitBoolean is_parametric();
00203   virtual CubitBoolean get_param_range_U( double& lo, double& hi );
00204   virtual CubitBoolean get_param_range_V( double& lo, double& hi );
00205  
00206   virtual CubitBoolean is_position_on( CubitVector &test_position );
00207 
00208   virtual CubitPointContainment point_containment( const CubitVector &point );
00209   virtual CubitPointContainment point_containment( double u, double v );
00210 //  virtual CubitPointContainment point_containment( CubitVector &point, 
00211 //                                           double u, double v );
00212   CubitPointContainment point_containment( const CubitVector &point, 
00213                                            PartitionCurve*& boundary_curve );
00214 
00215   CubitSense get_geometry_sense();
00216   void reverse_sense();
00217 
00218   
00219   void get_parents_virt( DLIList<TopologyBridge*>& );
00220   void get_children_virt( DLIList<TopologyBridge*>& );
00221   int layer() const { return sub_entity_set().get_owner_layer(); }
00222   GeometryQueryEngine* get_geometry_query_engine() const;
00223   
00224   virtual CubitSense get_shell_sense( ShellSM* shell_ptr ) const;
00225 
00226   void append_simple_attribute_virt(const CubitSimpleAttrib&);
00227   void remove_simple_attribute_virt(const CubitSimpleAttrib&);
00228   void remove_all_simple_attribute_virt();
00229   CubitStatus get_simple_attribute(DLIList<CubitSimpleAttrib>&);
00230   CubitStatus get_simple_attribute( const CubitString& name,
00231                                     DLIList<CubitSimpleAttrib>& );
00232   
00233   void notify_split( FacetEntity* old_tri, FacetEntity* new_tri );
00234   void notify_destroyed( CubitFacetData* facet );
00235   void get_facet_data( DLIList<CubitFacetData*>& result_list ) const;
00236   void set_facet_data( const DLIList<CubitFacetData*>& new_list );
00237   void replace_facets(DLIList<CubitFacetData*> &dead_facets,
00238                       DLIList<CubitFacetData*> &new_facets);
00239   bool has_facets() const { return facetList.size() > 0; }
00240   void draw_facets( int color ) const;
00241 
00242 
00243   CubitStatus init_facet_data();
00244   
00245 
00246   virtual void transform( const CubitTransformMatrix& xform );
00247 
00248   virtual void print_debug_info( const char* prefix = 0, 
00249                                  bool print_sub_entity_set = true ) const;
00250   CubitFacet* closest_facet( const CubitVector& input_position,
00251                              CubitVector& result_position);
00252   //- Call the following function for the facets owned by this surface.
00253                              
00254   CubitStatus notify_moving_point( CubitPoint* point, 
00255                                    const CubitVector& new_pos );
00256   //- Call fix_move_point for facetts of this PartitionSurface, 
00257   //- and update the facet list for this surface accordingly.
00258 
00259 protected:
00260  
00261   void interior_facet_points( DLIList<CubitPoint*>& result_list ) const;
00262   
00263   void update_facet_tool();
00264 
00265   void reverse_loops();
00266   
00267   PartitionSurface( );
00268   
00269   virtual PartitionSurface* copy();
00270 
00271   CubitStatus get_save_topology( DLIList<int>& curves );
00272   
00273   
00274   CubitStatus insert_facets( DLIList <PartitionEntity*> points,
00275                              DLIList <CubitFacetEdgeData *> &boundary_edges,
00276                              DLIList <CubitFacetData*> &surf_facets);
00277   
00278   DLIList<CubitFacetData*> facetList;
00279   CubitSense geometry_sense;
00280 
00281 private:
00282   
00283   PartitionSurface( PartitionSurface* split_from );
00284 
00285   PartitionSurface( const PartitionSurface& );
00286 
00287   PartitionLoop* firstLoop;
00288   PartitionCoSurf* firstCoSurf;
00289 
00290   
00291 };
00292 
00293 inline PartitionLoop* 
00294 PartitionSurface::next_loop( const PartitionLoop* prev ) const
00295 { 
00296   return !prev                   ? firstLoop           : 
00297          prev->mySurface == this ? prev->nextInSurface : 
00298                                    0; 
00299 }
00300   
00301 inline PartitionCoSurf* 
00302 PartitionSurface::next_co_surface( const PartitionCoSurf* prev ) const
00303 { 
00304   return !prev                   ? firstCoSurf       :
00305          prev->mySurface == this ? prev->surfaceNext :
00306                                    0;
00307 }
00308 
00309 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines