| 1 | //------------------------------------------------------------------------- |
|---|
| 2 | // Filename : CompositeCurve.hpp |
|---|
| 3 | // |
|---|
| 4 | // Purpose : Geometry defined as the joining of a chain of curves. |
|---|
| 5 | // |
|---|
| 6 | // Special Notes : |
|---|
| 7 | // |
|---|
| 8 | // Creator : Jason Kraftcheck |
|---|
| 9 | // |
|---|
| 10 | // Creation Date : 12/19/01 |
|---|
| 11 | //------------------------------------------------------------------------- |
|---|
| 12 | |
|---|
| 13 | #ifndef COMPOSITE_CURVE_HPP |
|---|
| 14 | #define COMPOSITE_CURVE_HPP |
|---|
| 15 | |
|---|
| 16 | #include "VGDefines.h" |
|---|
| 17 | #include "Curve.hpp" |
|---|
| 18 | #include "CompositeGeom.hpp" |
|---|
| 19 | #include "HiddenEntitySet.hpp" |
|---|
| 20 | #include "CompositeCoEdge.hpp" |
|---|
| 21 | |
|---|
| 22 | class CompositeSurface; |
|---|
| 23 | class CompositePoint; |
|---|
| 24 | class Point; |
|---|
| 25 | |
|---|
| 26 | class CompositeCurve : public Curve, public TBOwner |
|---|
| 27 | { |
|---|
| 28 | |
|---|
| 29 | public: |
|---|
| 30 | |
|---|
| 31 | int HadBridgeRemoved; |
|---|
| 32 | //CompositeCurve( DLIList<Curve*>& curve_list, bool periodic ); |
|---|
| 33 | //CompositeCurve( ); |
|---|
| 34 | CompositeCurve( Curve* curve ); |
|---|
| 35 | CompositeCurve( CompositeGeom* geometry ); |
|---|
| 36 | CompositeCurve( CompositePoint* point ); // create point-curve |
|---|
| 37 | |
|---|
| 38 | virtual ~CompositeCurve(); |
|---|
| 39 | |
|---|
| 40 | inline Curve* get_curve( int index ) const; |
|---|
| 41 | inline CubitSense get_sense( int index ) const; |
|---|
| 42 | inline int num_curves( ) const; |
|---|
| 43 | inline int index_of( Curve* curve_ptr ) const; |
|---|
| 44 | inline void update(); |
|---|
| 45 | Curve* remove_curve( int index ); |
|---|
| 46 | |
|---|
| 47 | /* |
|---|
| 48 | inline CubitStatus append_curve( Curve* curve_ptr ); |
|---|
| 49 | inline CubitStatus prepend_curve( Curve* curve_ptr ); |
|---|
| 50 | CubitStatus insert_curve( Curve* curve_ptr, int index ); |
|---|
| 51 | Curve* remove_curve( Curve* curve_ptr ); |
|---|
| 52 | Curve* remove_curve( int index ); |
|---|
| 53 | */ |
|---|
| 54 | CompositeCurve* split( Curve* curve_ptr ); |
|---|
| 55 | CubitStatus combine( CompositeCurve* curve_ptr, bool prepend ); |
|---|
| 56 | void reverse(); |
|---|
| 57 | |
|---|
| 58 | CompositeCoEdge* first_coedge() const; |
|---|
| 59 | CompositeCoEdge* next_coedge( CompositeCoEdge* after_this ) const; |
|---|
| 60 | #ifdef BOYD15 |
|---|
| 61 | CompositeCoEdge* find_coedge( CompositeSurface* surface ) const; |
|---|
| 62 | #endif |
|---|
| 63 | CubitStatus add( CompositeCoEdge* coedge ); |
|---|
| 64 | CubitStatus remove( CompositeCoEdge* coedge ); |
|---|
| 65 | |
|---|
| 66 | CompositePoint* start_point() const; |
|---|
| 67 | CompositePoint* end_point() const; |
|---|
| 68 | CubitStatus start_point( CompositePoint* pt ); |
|---|
| 69 | CubitStatus end_point( CompositePoint* pt ); |
|---|
| 70 | CompositePoint* other_point( CompositePoint* pt ); |
|---|
| 71 | #ifdef BOYD15 |
|---|
| 72 | CompositePoint* closest_end_point( const CubitVector& pos ); |
|---|
| 73 | #endif |
|---|
| 74 | CompositePoint* common_point( CompositeCurve* curve ); |
|---|
| 75 | CompositeCurve* next( const CompositePoint* around_this ); |
|---|
| 76 | |
|---|
| 77 | HiddenEntitySet& hidden_entities(); |
|---|
| 78 | void get_hidden_points( DLIList<Point*>& points ); |
|---|
| 79 | |
|---|
| 80 | bool has_parent_composite_surface() const; |
|---|
| 81 | |
|---|
| 82 | /**************** Methods from TopologyBridge *******************/ |
|---|
| 83 | |
|---|
| 84 | void append_simple_attribute_virt( CubitSimpleAttrib* csa ); |
|---|
| 85 | void remove_simple_attribute_virt(CubitSimpleAttrib* csa ); |
|---|
| 86 | void remove_all_simple_attribute_virt(); |
|---|
| 87 | CubitStatus get_simple_attribute(DLIList<CubitSimpleAttrib*>& csa_list ); |
|---|
| 88 | CubitStatus get_simple_attribute( const CubitString& name, |
|---|
| 89 | DLIList<CubitSimpleAttrib*>& attrib_list ); |
|---|
| 90 | GeometryQueryEngine* get_geometry_query_engine() const; |
|---|
| 91 | |
|---|
| 92 | void get_parents_virt( DLIList<TopologyBridge*>& parents ); |
|---|
| 93 | void get_children_virt( DLIList<TopologyBridge*>& children ); |
|---|
| 94 | int layer() const { return COMPOSITE_LAYER; } |
|---|
| 95 | |
|---|
| 96 | /******************** Methods from TBOwner **********************/ |
|---|
| 97 | |
|---|
| 98 | CubitStatus remove_bridge( TopologyBridge* bridge ); |
|---|
| 99 | CubitStatus swap_bridge( TopologyBridge* old, |
|---|
| 100 | TopologyBridge* neww, |
|---|
| 101 | bool reversed ); |
|---|
| 102 | CubitBoolean contains_bridge( TopologyBridge* bridge ) const; |
|---|
| 103 | void notify_reversed( TopologyBridge* bridge ); |
|---|
| 104 | void notify_split( TopologyBridge* new_bridge, TopologyBridge* split_from ); |
|---|
| 105 | // void notify_joined( TopologyBridge* dead, TopologyBridge* keep ); |
|---|
| 106 | |
|---|
| 107 | /**************** Methods from GeometryEntity *******************/ |
|---|
| 108 | |
|---|
| 109 | CubitBox bounding_box() const; |
|---|
| 110 | double measure( ) ; |
|---|
| 111 | GeometryType geometry_type(); |
|---|
| 112 | |
|---|
| 113 | |
|---|
| 114 | /******************** Methods from Curve ***********************/ |
|---|
| 115 | |
|---|
| 116 | CubitBoolean get_param_range( double& lower, double& upper ); |
|---|
| 117 | CubitBoolean is_periodic( double& period); |
|---|
| 118 | double start_param(); |
|---|
| 119 | double end_param(); |
|---|
| 120 | |
|---|
| 121 | CubitStatus position_from_u( double u_value, CubitVector& pos ); |
|---|
| 122 | double u_from_position (const CubitVector& input_position); |
|---|
| 123 | |
|---|
| 124 | double length_from_u( double parameter1, double parameter2 ); |
|---|
| 125 | double u_from_arc_length ( double root_param, double arc_length ); |
|---|
| 126 | |
|---|
| 127 | CubitStatus closest_point( CubitVector const& location, |
|---|
| 128 | CubitVector& closest_location, |
|---|
| 129 | CubitVector* tangent_ptr = NULL, |
|---|
| 130 | CubitVector* curvature_ptr = NULL, |
|---|
| 131 | double *param = NULL); |
|---|
| 132 | #ifdef BOYD15 |
|---|
| 133 | void get_tangent( CubitVector const& location, CubitVector& tangent ); |
|---|
| 134 | void get_curvature( CubitVector const& location, CubitVector& curvature ); |
|---|
| 135 | #endif |
|---|
| 136 | |
|---|
| 137 | CubitStatus closest_point_trimmed( CubitVector const& from_pt, |
|---|
| 138 | CubitVector& result_pt ); |
|---|
| 139 | |
|---|
| 140 | CubitBoolean is_position_on( const CubitVector &test_position ); |
|---|
| 141 | CubitPointContainment point_containment( const CubitVector &point ); |
|---|
| 142 | |
|---|
| 143 | CubitStatus get_point_direction( CubitVector& origin, |
|---|
| 144 | CubitVector& direction ); |
|---|
| 145 | |
|---|
| 146 | CubitStatus get_interior_extrema( |
|---|
| 147 | DLIList<CubitVector*>& interior_points, |
|---|
| 148 | CubitSense& return_sense); |
|---|
| 149 | |
|---|
| 150 | CubitStatus get_center_radius( CubitVector& c, double& r ); |
|---|
| 151 | |
|---|
| 152 | CubitBoolean G1_discontinuous( double param, |
|---|
| 153 | CubitVector* minus_tangent = NULL, |
|---|
| 154 | CubitVector* plus_tangent = NULL ); |
|---|
| 155 | |
|---|
| 156 | |
|---|
| 157 | void print_debug_info( const char* prefix = 0, bool brief = false ) const; |
|---|
| 158 | |
|---|
| 159 | CubitStatus stitch( CompositeCurve* merge_with ); |
|---|
| 160 | void unstitch_all(); |
|---|
| 161 | CompositeCurve* primary_stitched_curve(); |
|---|
| 162 | bool is_stitched(); |
|---|
| 163 | void get_stitched( DLIList<CompositeCurve*>& list ); |
|---|
| 164 | |
|---|
| 165 | CubitStatus curve_param( double u_composite, double& u_curve, int& index ) const; |
|---|
| 166 | double composite_param( int index, double param ) const; |
|---|
| 167 | |
|---|
| 168 | //void draw( int color ); |
|---|
| 169 | |
|---|
| 170 | void read_attributes() ; //{ compGeom->read_attributes(); } |
|---|
| 171 | void write_attributes() ; //{ compGeom->write_attributes(); } |
|---|
| 172 | |
|---|
| 173 | protected: |
|---|
| 174 | |
|---|
| 175 | CompositeCurve(); |
|---|
| 176 | |
|---|
| 177 | int closest_curve( CubitVector const& location, |
|---|
| 178 | CubitVector *point = NULL ); |
|---|
| 179 | //R int |
|---|
| 180 | //R- The index of the closest curve |
|---|
| 181 | //I location |
|---|
| 182 | //I- A position for which the closest curve is desired. |
|---|
| 183 | //O point |
|---|
| 184 | //O- The closest point on the curve |
|---|
| 185 | //- This function finds the closest underlying Curve of this |
|---|
| 186 | //- CompositeCurve to a given point |
|---|
| 187 | |
|---|
| 188 | double lengthUntilI( int index ) const; |
|---|
| 189 | |
|---|
| 190 | void fixup_periodic_param( double& u ) const; |
|---|
| 191 | |
|---|
| 192 | CubitStatus set_point( bool set_start_point, CompositePoint* point ); |
|---|
| 193 | |
|---|
| 194 | private: |
|---|
| 195 | |
|---|
| 196 | // these have no implementation, just private delcarations |
|---|
| 197 | // to prevent the compiler from generating default implementations |
|---|
| 198 | CompositeCurve& operator=(const CompositeCurve&); |
|---|
| 199 | CompositeCurve(const CompositeCurve&); |
|---|
| 200 | |
|---|
| 201 | CompositeGeom* compGeom; |
|---|
| 202 | |
|---|
| 203 | HiddenEntitySet* hiddenSet; |
|---|
| 204 | |
|---|
| 205 | CompositeCoEdge* firstCoEdge; |
|---|
| 206 | |
|---|
| 207 | CompositePoint* startPoint; |
|---|
| 208 | CompositePoint* endPoint; |
|---|
| 209 | |
|---|
| 210 | CompositeCurve* startNext; |
|---|
| 211 | CompositeCurve* endNext; |
|---|
| 212 | |
|---|
| 213 | CompositeCurve* stitchNext; |
|---|
| 214 | }; |
|---|
| 215 | |
|---|
| 216 | inline Curve* CompositeCurve::get_curve( int index ) const |
|---|
| 217 | { return dynamic_cast<Curve*>(compGeom->entity(index)); } |
|---|
| 218 | |
|---|
| 219 | inline CubitSense CompositeCurve::get_sense( int index ) const |
|---|
| 220 | { return compGeom->sense( index ); } |
|---|
| 221 | |
|---|
| 222 | inline int CompositeCurve::num_curves( ) const |
|---|
| 223 | { return compGeom->num_entities(); } |
|---|
| 224 | |
|---|
| 225 | inline int CompositeCurve::index_of( Curve* curve ) const |
|---|
| 226 | { return compGeom->index_of( curve ); } |
|---|
| 227 | |
|---|
| 228 | inline void CompositeCurve::update() |
|---|
| 229 | { compGeom->update_cached_data();} |
|---|
| 230 | |
|---|
| 231 | /* |
|---|
| 232 | inline CubitStatus CompositeCurve::prepend_curve( Curve* curve ) |
|---|
| 233 | { return insert_curve( curve, 0 ); } |
|---|
| 234 | |
|---|
| 235 | inline CubitStatus CompositeCurve::append_curve( Curve* curve ) |
|---|
| 236 | { return insert_curve( curve, num_curves() ); } |
|---|
| 237 | */ |
|---|
| 238 | inline CompositeCoEdge* CompositeCurve::first_coedge( ) const |
|---|
| 239 | { return firstCoEdge; } |
|---|
| 240 | |
|---|
| 241 | inline CompositeCoEdge* CompositeCurve::next_coedge( CompositeCoEdge* coedge ) const |
|---|
| 242 | { return !coedge ? firstCoEdge : coedge->myCurve == this ? coedge->nextOnCurve : 0; } |
|---|
| 243 | |
|---|
| 244 | inline CompositePoint* CompositeCurve::start_point() const |
|---|
| 245 | { return startPoint; } |
|---|
| 246 | |
|---|
| 247 | inline CompositePoint* CompositeCurve::end_point() const |
|---|
| 248 | { return endPoint; } |
|---|
| 249 | |
|---|
| 250 | |
|---|
| 251 | |
|---|
| 252 | inline HiddenEntitySet& CompositeCurve::hidden_entities() |
|---|
| 253 | { if( !hiddenSet ) |
|---|
| 254 | hiddenSet = new HiddenEntitySet(this); |
|---|
| 255 | return *hiddenSet; |
|---|
| 256 | } |
|---|
| 257 | |
|---|
| 258 | |
|---|
| 259 | #endif |
|---|