cgma
SegmentedCurve.hpp
Go to the documentation of this file.
00001 //-------------------------------------------------------------------------
00002 // Filename      : SegmentedCurve.hpp
00003 //
00004 // Purpose       : 
00005 //
00006 // Special Notes : 
00007 //
00008 // Creator       : Jason Kraftcheck
00009 //
00010 // Creation Date : 04/18/02
00011 //-------------------------------------------------------------------------
00012 
00013 #ifndef SEGMENTED_CURVE_HPP
00014 #define SEGMENTED_CURVE_HPP
00015 
00016 #include "PartitionCurve.hpp"
00017 #include "PartitionLoop.hpp"
00018 #include "VGArray.hpp"
00019 
00020 class PartitionSurface;
00021 class PartitionLump;
00022 class CubitSimpleAttrib;
00023 class CubitTransformMatrix;
00024 
00025 class SegmentedCurve : public PartitionCurve
00026 {
00027 public:
00028 
00029   PartitionCurve* split( double param );
00030   CubitStatus combine( PartitionCurve* dead_curve );
00031   
00032   static SegmentedCurve* construct( const CubitSimpleAttrib& attrib,
00033                                     PartitionEntity* parent );
00034   
00035   SegmentedCurve( PartitionSurface* owning_surf, DLIList<CubitVector*>& segments );
00036   SegmentedCurve( PartitionLump* owning_vol, DLIList<CubitVector*>& segments );
00037   
00038   virtual ~SegmentedCurve( );
00039             
00040   CubitBoolean is_linear( );
00041   
00042   virtual CubitStatus save( CubitSimpleAttrib& attrib );
00043             
00044   virtual CubitStatus get_point_direction( CubitVector& origin,
00045                                            CubitVector& direction );
00046   
00047   virtual CubitStatus get_center_radius( CubitVector& center, double& radius );
00048         
00049   virtual double length_from_u( double param1, double param2 );
00050   
00051   virtual CubitBoolean is_periodic( double& period);
00052   CubitBoolean is_periodic() const;
00053   
00054   virtual CubitBoolean get_param_range( double& lower_bound,
00055                                         double& upper_bound );
00056   
00057   virtual CubitStatus closest_point( 
00058     CubitVector const& location, 
00059     CubitVector& closest_location,
00060     CubitVector* tangent_ptr = NULL,
00061     CubitVector* curvature_ptr = NULL,
00062     double* param = NULL);
00063   
00064   virtual CubitStatus closest_point_trimmed( 
00065     CubitVector const& from_pt, CubitVector& result_pt );
00066   
00067   
00068   virtual double u_from_position (const CubitVector& position);
00069   
00070   virtual CubitStatus position_from_u (double u_value,
00071                                        CubitVector& position);
00072   
00073   virtual double u_from_arc_length ( double param, double length );
00074   
00075   virtual CubitBoolean is_position_on( const CubitVector &position );
00076   
00077   virtual double start_param(){ return 0.0; }
00078   virtual double end_param(){ return point_count() - 1; }
00079   
00080   virtual CubitBox bounding_box() const;
00081   
00082   virtual double measure();
00083   
00084   virtual CubitStatus get_segments( DLIList<CubitVector*>& points );
00085   
00086   virtual CubitStatus get_interior_extrema( DLIList<CubitVector*>& points,
00087                                             CubitSense& return_sense );
00088   
00089   virtual int point_count() const;
00090     
00091   virtual CubitBoolean G1_discontinuous( double param,
00092                         CubitVector* minus_tangent = NULL,
00093                         CubitVector* plus_tangent = NULL );
00094                         
00095   CubitPointContainment point_containment( const CubitVector& vect );
00096   
00097   CubitStatus get_graphics( GMem& result,
00098                             double angle_tolerance=0,
00099                             double distance_tolerance=0,
00100                             double max_edge_length=0); 
00101   
00102   void reverse_sense();
00103   
00104   virtual void print_debug_info( const char* prefix, bool pss = true ) const;
00105   
00106 
00107   virtual void transform( const CubitTransformMatrix& );
00108   
00109   //R CubitStatus
00110   //O- true or false if spline is rational or not.
00111   //O- the degree of this spline
00112   //O- the control points
00113   //O- If rational, weight for each control point
00114   //O- whether underlying spline is reversed
00115   virtual CubitStatus get_spline_params( bool &rational,
00116                                          int &degree,
00117                                          DLIList<CubitVector> &cntrl_pts,
00118                                          DLIList<double> &cntrl_pt_weights,
00119                                          DLIList<double> &knots,
00120                                          bool &spline_is_reversed
00121                                        ) const;
00122   //R CubitStatus
00123   //O- center - ellipse center point
00124   //O- normal - normal of the plane of the ellipse
00125   //O- major_axis - major axis of the ellipse
00126   //O- radius_ratio - ratio of the length of the major to minor axis.
00127   virtual CubitStatus get_ellipse_params( CubitVector &center,
00128                                           CubitVector &normal,
00129                                           CubitVector &major_axis,
00130                                           double &radius_ratio ) const;
00131 protected:
00132   
00133   int segment_from_u( double& u );
00134     // Return the index of the segment corresponding to the
00135     // passed parameter value, and change the passed double
00136     // to be a parameter on the segment.  Returns -1 to
00137     // indicate an invalid parameter value.
00138   
00139   int closest_segment( CubitVector const& location,
00140                        double* fraction_on_segment = NULL,
00141                        CubitVector* closest_pt = NULL );
00142     //Find the segment of the curve closest to the passed location.
00143     //The return value is the index of the start point of the 
00144     //segment.  Optional values passed back are the fraction along
00145     //the segment at which the passed location was closest, and the
00146     //corresponding position.
00147   
00148   static double closest_point_on_segment( 
00149                                   const CubitVector& segment_base,
00150                                   const CubitVector& segment_direction,
00151                                   const CubitVector& from_position );
00152     //Find the closest location on a bounded segment defined by
00153     //segment_base and segment_direction to from_position.  The
00154     //return value is the fraction along segment_direction from 
00155     //segment_base.  Or a parameter value in the range [0,1], where
00156     //zero is segment_base, and 1 is segment_base+segment_direction.
00157   
00158   double segment_length( int segment_no ) const;
00159   
00160   CubitVector position( int index ) const;
00161   
00162   void normalize_periodic_parameter( double& u );
00163   
00164 private:
00165   SegmentedCurve( PartitionEntity* owning_vol, 
00166                   const CubitSimpleAttrib& attrib,
00167                   DLIList<int>& pass_back_vertex_conn );
00168 
00169   SegmentedCurve( SegmentedCurve* split_from, int num_points );
00170   
00171   VGArray<CubitVector> point_list;
00172 };
00173 
00174 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines