cgma
CompositeCurve.hpp
Go to the documentation of this file.
00001 //-------------------------------------------------------------------------
00002 // Filename      : CompositeCurve.hpp
00003 //
00004 // Purpose       : Geometry defined as the joining of a chain of curves.
00005 //
00006 // Special Notes : 
00007 //
00008 // Creator       : Jason Kraftcheck
00009 //
00010 // Creation Date : 12/19/01
00011 //-------------------------------------------------------------------------
00012 
00013 #ifndef COMPOSITE_CURVE_HPP
00014 #define COMPOSITE_CURVE_HPP
00015 
00016 #include "VGDefines.h"
00017 #include "Curve.hpp"
00018 #include "CompositeGeom.hpp"
00019 #include "HiddenEntitySet.hpp"
00020 #include "CompositeCoEdge.hpp"
00021 
00022 class CompositeSurface;
00023 class CompositePoint;
00024 class TBPoint;
00025 
00026 class CompositeCurve : public Curve, public TBOwner
00027 {
00028 
00029   public:
00030   
00031     int HadBridgeRemoved;
00032     //CompositeCurve( DLIList<Curve*>& curve_list, bool periodic );
00033     //CompositeCurve( );
00034     CompositeCurve( Curve* curve );
00035     CompositeCurve( CompositeGeom* geometry );
00036     CompositeCurve( CompositePoint* point ); // create point-curve
00037     
00038     virtual ~CompositeCurve();
00039    
00040     inline Curve* get_curve( int index ) const;
00041     inline CubitSense get_sense( int index ) const;
00042     inline int num_curves( ) const;
00043     inline int index_of( Curve* curve_ptr ) const;
00044     inline void update();
00045     Curve* remove_curve( int index );
00046     
00047 /*
00048     inline CubitStatus append_curve( Curve* curve_ptr );
00049     inline CubitStatus prepend_curve( Curve* curve_ptr );
00050     CubitStatus insert_curve( Curve* curve_ptr, int index );
00051     Curve* remove_curve( Curve* curve_ptr );
00052     Curve* remove_curve( int index );
00053 */
00054     CompositeCurve* split( Curve* curve_ptr );
00055     CubitStatus combine( CompositeCurve* curve_ptr, bool prepend );
00056     void reverse();
00057     
00058     CompositeCoEdge* first_coedge() const;
00059     CompositeCoEdge* next_coedge( CompositeCoEdge* after_this ) const;
00060     CubitStatus add( CompositeCoEdge* coedge );
00061     CubitStatus remove( CompositeCoEdge* coedge );
00062     
00063     CompositePoint* start_point() const;
00064     CompositePoint* end_point() const;
00065     CubitStatus start_point( CompositePoint* pt );
00066     CubitStatus end_point( CompositePoint* pt );
00067     CompositePoint* other_point( CompositePoint* pt );
00068     CompositePoint* common_point( CompositeCurve* curve );
00069     CompositeCurve* next( const CompositePoint* around_this );
00070 
00071     HiddenEntitySet& hidden_entities();
00072     void get_hidden_points( DLIList<TBPoint*>& points );
00073     
00074     bool has_parent_composite_surface() const;
00075     
00076     /**************** Methods from TopologyBridge *******************/
00077     
00078     void append_simple_attribute_virt( const CubitSimpleAttrib& csa );
00079     void remove_simple_attribute_virt(const CubitSimpleAttrib& csa );
00080     void remove_all_simple_attribute_virt();
00081     CubitStatus get_simple_attribute(DLIList<CubitSimpleAttrib>& csa_list );
00082     CubitStatus get_simple_attribute( const CubitString& name,
00083                                   DLIList<CubitSimpleAttrib>& attrib_list );
00084     GeometryQueryEngine* get_geometry_query_engine() const;
00085     
00086     void get_parents_virt( DLIList<TopologyBridge*>& parents );
00087     void get_children_virt( DLIList<TopologyBridge*>& children );
00088     int layer() const { return COMPOSITE_LAYER; }
00089 
00090     /******************** Methods from TBOwner **********************/
00091    
00092     CubitStatus remove_bridge( TopologyBridge* bridge );
00093     CubitStatus swap_bridge( TopologyBridge* old, 
00094                              TopologyBridge* neww, 
00095                              bool reversed );
00096     CubitBoolean contains_bridge( TopologyBridge* bridge ) const;
00097     void notify_reversed( TopologyBridge* bridge );
00098     void notify_split( TopologyBridge* new_bridge, TopologyBridge* split_from );
00099 //    void notify_joined( TopologyBridge* dead, TopologyBridge* keep );
00100 
00101     /**************** Methods from GeometryEntity *******************/
00102 
00103       CubitBox bounding_box() const;
00104     double measure( ) ;
00105     GeometryType geometry_type();
00106     
00107 
00108     /******************** Methods from Curve ***********************/
00109 
00110     CubitBoolean get_param_range( double& lower, double& upper );
00111     CubitBoolean is_periodic( double& period);
00112     double start_param();
00113     double end_param();
00114 
00115     CubitStatus position_from_u( double u_value, CubitVector& pos );
00116     double u_from_position (const CubitVector& input_position);
00117 
00118     double length_from_u( double parameter1, double parameter2 );
00119     double u_from_arc_length ( double root_param, double arc_length );
00120 
00121     CubitStatus closest_point( CubitVector const& location, 
00122                                CubitVector& closest_location,
00123                                CubitVector* tangent_ptr = NULL,
00124                                CubitVector* curvature_ptr = NULL,
00125                                double *param = NULL);
00126 
00127     CubitStatus closest_point_trimmed( CubitVector const& from_pt,
00128                                        CubitVector& result_pt );
00129 
00130     CubitBoolean is_position_on( const CubitVector &test_position );
00131     CubitPointContainment point_containment( const CubitVector &point );
00132 
00133     CubitStatus get_point_direction( CubitVector& origin,
00134                                        CubitVector& direction );
00135 
00136     CubitStatus get_interior_extrema( 
00137                             DLIList<CubitVector*>& interior_points,
00138                             CubitSense& return_sense);
00139 
00140     CubitStatus get_center_radius( CubitVector& c, double& r );
00141 
00142     CubitBoolean G1_discontinuous( double param,
00143                 CubitVector* minus_tangent = NULL,
00144                 CubitVector* plus_tangent = NULL );
00145 
00146 
00147     void print_debug_info( const char* prefix = 0, bool brief = false ) const;
00148 
00149     CubitStatus stitch( CompositeCurve* merge_with );
00150     void unstitch_all();
00151     CompositeCurve* primary_stitched_curve();
00152     bool is_stitched();
00153     void get_stitched( DLIList<CompositeCurve*>& list );
00154 
00155     CubitStatus curve_param( double u_composite, double& u_curve, int& index ) const;
00156       double composite_param( int index, double param ) const;
00157     
00158     //void draw( int color );
00159   
00160     void read_attributes() ; //{ compGeom->read_attributes(); }
00161     void write_attributes() ; //{ compGeom->write_attributes(); }
00162 
00163   //R CubitStatus
00164   //O- true or false if spline is rational or not.
00165   //O- the degree of this spline
00166   //O- the control points
00167   //O- If rational, weight for each control point
00168   //O- whether underlying spline is reversed
00169   virtual CubitStatus get_spline_params( bool &rational,
00170                                          int &degree,
00171                                          DLIList<CubitVector> &cntrl_pts,
00172                                          DLIList<double> &cntrl_pt_weights,
00173                                          DLIList<double> &knots,
00174                                          bool &spline_is_reversed
00175                                        ) const;
00176     //R CubitStatus
00177     //O- center - ellipse center point
00178     //O- normal - normal of the plane of the ellipse
00179     //O- major_axis - major axis of the ellipse
00180     //O- radius_ratio - ratio of the length of the major to minor axis.
00181   virtual CubitStatus get_ellipse_params( CubitVector &center,
00182                                           CubitVector &normal,
00183                                           CubitVector &major_axis,
00184                                           double &radius_ratio ) const;
00185 
00186   protected: 
00187   
00188     CompositeCurve();
00189 
00190     int closest_curve( CubitVector const& location,
00191                        CubitVector *point = NULL );
00192     //R int
00193     //R- The index of the closest curve
00194     //I location
00195     //I- A position for which the closest curve is desired.
00196     //O point
00197     //O- The closest point on the curve
00198     //- This function finds the closest underlying Curve of this 
00199     //- CompositeCurve to a given point
00200   
00201       double lengthUntilI( int index ) const;
00202   
00203     void fixup_periodic_param( double& u ) const;
00204     
00205     CubitStatus set_point( bool set_start_point, CompositePoint* point );
00206 
00207 private:
00208 
00209       // these have no implementation, just private delcarations
00210       // to prevent the compiler from generating default implementations
00211     CompositeCurve& operator=(const CompositeCurve&);
00212     CompositeCurve(const CompositeCurve&);
00213 
00214     CompositeGeom* compGeom;
00215     
00216     HiddenEntitySet* hiddenSet;
00217     
00218     CompositeCoEdge* firstCoEdge;
00219     
00220     CompositePoint* startPoint;
00221     CompositePoint* endPoint;
00222     
00223     CompositeCurve* startNext;
00224     CompositeCurve* endNext;
00225     
00226     CompositeCurve* stitchNext;
00227 };
00228 
00229 inline Curve* CompositeCurve::get_curve( int index ) const
00230   { return dynamic_cast<Curve*>(compGeom->entity(index)); }
00231 
00232 inline CubitSense CompositeCurve::get_sense( int index ) const
00233   { return compGeom->sense( index ); }
00234 
00235 inline int CompositeCurve::num_curves( ) const
00236   { return compGeom->num_entities(); }
00237 
00238 inline int CompositeCurve::index_of( Curve* curve ) const
00239   { return compGeom->index_of( curve ); }
00240 
00241 inline void CompositeCurve::update()
00242   { compGeom->update_cached_data();}
00243 
00244 /*
00245 inline CubitStatus CompositeCurve::prepend_curve( Curve* curve )
00246   { return insert_curve( curve, 0 ); }
00247 
00248 inline CubitStatus CompositeCurve::append_curve( Curve* curve )
00249   { return insert_curve( curve, num_curves() ); }
00250 */
00251 inline CompositeCoEdge* CompositeCurve::first_coedge( ) const
00252   { return firstCoEdge; }
00253 
00254 inline CompositeCoEdge* CompositeCurve::next_coedge( CompositeCoEdge* coedge ) const
00255   { return !coedge ? firstCoEdge : coedge->myCurve == this ? coedge->nextOnCurve : 0; }
00256 
00257 inline CompositePoint* CompositeCurve::start_point() const
00258   { return startPoint; }
00259 
00260 inline CompositePoint* CompositeCurve::end_point() const
00261   { return endPoint; }
00262 
00263 
00264 
00265 inline HiddenEntitySet& CompositeCurve::hidden_entities()
00266   { if( !hiddenSet ) 
00267       hiddenSet = new HiddenEntitySet(this);
00268     return *hiddenSet; 
00269   }
00270 
00271 
00272 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines