cgma
|
00001 #include "PartPTCurve.hpp" 00002 #include "PartitionSurface.hpp" 00003 #include "PartitionPoint.hpp" 00004 #include "GMem.hpp" 00005 #include "PartitionEngine.hpp" 00006 #include "CubitMessage.hpp" 00007 00008 PartPTCurve::PartPTCurve( PartitionSurface* owner ) 00009 { 00010 owner->sub_entity_set().add_lower_order( this ); 00011 } 00012 00013 PartPTCurve* PartPTCurve::construct( const CubitSimpleAttrib& attrib, 00014 PartitionSurface* owner ) 00015 { 00016 DLIList<int> vertex_conn; 00017 PartPTCurve* result = new PartPTCurve( owner, attrib, vertex_conn ); 00018 00019 if ( vertex_conn.size() != 4 ) 00020 { 00021 delete result; 00022 return 0; 00023 } 00024 00025 PartitionPoint *start = 0, *end = 0; 00026 PartitionEntity* ent; 00027 vertex_conn.reset(); 00028 int set_id = vertex_conn.get_and_step(); 00029 int ent_id = vertex_conn.get_and_step(); 00030 ent = PartitionEngine::instance().entity_from_id(set_id,ent_id,owner->sub_entity_set()); 00031 start = dynamic_cast<PartitionPoint*>(ent); 00032 set_id = vertex_conn.get_and_step(); 00033 ent_id = vertex_conn.get_and_step(); 00034 ent = PartitionEngine::instance().entity_from_id(set_id,ent_id,owner->sub_entity_set()); 00035 end = dynamic_cast<PartitionPoint*>(ent); 00036 00037 if ( !start || !end || start != end ) 00038 { 00039 delete result; 00040 return 0; 00041 } 00042 00043 result->start_point( end ); 00044 result->end_point( end ); 00045 return result; 00046 } 00047 00048 PartPTCurve::PartPTCurve( PartitionSurface* surface, 00049 const CubitSimpleAttrib& attrib, 00050 DLIList<int>& vertex_conn ) 00051 { 00052 DLIList<CubitVector*> points; 00053 DLIList<int> junk; 00054 surface->sub_entity_set().add_lower_order( this, attrib, 1, points, junk, vertex_conn, junk ); 00055 assert( points.size() == 0 ); 00056 } 00057 00058 PartPTCurve::~PartPTCurve() 00059 {} 00060 00061 PartitionCurve* PartPTCurve::split( double ) 00062 { assert(0); return 0; } 00063 00064 CubitStatus PartPTCurve::combine( PartitionCurve* curve ) 00065 { 00066 assert( dynamic_cast<PartPTCurve*>(curve) != NULL ); 00067 assert( 0 ); 00068 return CUBIT_FAILURE; 00069 } 00070 00071 CubitStatus PartPTCurve::get_graphics( GMem& result, 00072 double /*angle_tolerance*/, 00073 double /*distance_tolerance*/, 00074 double /*max_edge_length*/) 00075 { 00076 result.pointListCount = 0; 00077 return CUBIT_SUCCESS; 00078 } 00079 00080 00081 void PartPTCurve::append_simple_attribute_virt(const CubitSimpleAttrib& csa) 00082 { sub_entity_set().add_attribute( this, csa ); } 00083 void PartPTCurve::remove_simple_attribute_virt(const CubitSimpleAttrib& csa) 00084 { sub_entity_set().rem_attribute( this, csa ); } 00085 void PartPTCurve::remove_all_simple_attribute_virt() 00086 { sub_entity_set().rem_all_attrib( this ); } 00087 CubitStatus PartPTCurve::get_simple_attribute(DLIList<CubitSimpleAttrib>& list) 00088 { 00089 sub_entity_set().get_attributes( this, list ); 00090 return CUBIT_SUCCESS; 00091 } 00092 CubitStatus PartPTCurve::get_simple_attribute(const CubitString& name, 00093 DLIList<CubitSimpleAttrib>& list) 00094 { 00095 sub_entity_set().get_attributes( this, name.c_str(), list ); 00096 return CUBIT_SUCCESS; 00097 } 00098 00099 CubitBox PartPTCurve::bounding_box() const 00100 { return CubitBox( coordinates() ); } 00101 double PartPTCurve::measure() 00102 { return 0.0; } 00103 GeometryType PartPTCurve::geometry_type() 00104 { return POINT_CURVE_TYPE; } 00105 00106 CubitStatus PartPTCurve::closest_point( CubitVector const& , 00107 CubitVector& closest, 00108 CubitVector* tangent, 00109 CubitVector* curvature, 00110 double* param ) 00111 { 00112 closest = coordinates(); 00113 if( tangent ) tangent->set(0.,0.,0.); 00114 if( curvature) curvature->set(0.,0.,0.); 00115 if( param ) *param = 0.0; 00116 return CUBIT_SUCCESS; 00117 } 00118 00119 CubitPointContainment PartPTCurve::point_containment( const CubitVector& position ) 00120 { return is_position_on(position) ? CUBIT_PNT_BOUNDARY : CUBIT_PNT_OFF; } 00121 00122 CubitBoolean PartPTCurve::is_position_on( const CubitVector& position ) 00123 { 00124 const double tolsqr = GEOMETRY_RESABS * GEOMETRY_RESABS; 00125 return (position - coordinates()).length_squared() < tolsqr; 00126 } 00127 00128 CubitBoolean PartPTCurve::G1_discontinuous( double, CubitVector* min, CubitVector* plu ) 00129 { 00130 if( min ) min->set( 0., 0., 0. ); 00131 if( plu ) plu->set( 0., 0., 0. ); 00132 return CUBIT_TRUE; 00133 } 00134 00135 CubitStatus PartPTCurve::get_interior_extrema( DLIList<CubitVector*>&, CubitSense& ) 00136 { return CUBIT_SUCCESS; } 00137 00138 CubitStatus PartPTCurve::get_center_radius( CubitVector&, double& ) 00139 { return CUBIT_FAILURE; } 00140 00141 CubitBoolean PartPTCurve::get_param_range( double& lower, double& upper ) 00142 { lower = upper = 0.0; return CUBIT_TRUE; } 00143 00144 double PartPTCurve::start_param() 00145 { return 0.0; } 00146 double PartPTCurve::end_param() 00147 { return 0.0; } 00148 00149 CubitBoolean PartPTCurve::is_periodic( double& period ) 00150 { period = 0.0; return CUBIT_TRUE; } 00151 00152 double PartPTCurve::length_from_u( double, double ) 00153 { return 0.0; } 00154 00155 double PartPTCurve::u_from_position( const CubitVector& ) 00156 { return 0.0; } 00157 00158 CubitStatus PartPTCurve::position_from_u( double, CubitVector& result ) 00159 { result = coordinates(); return CUBIT_SUCCESS; } 00160 00161 double PartPTCurve::u_from_arc_length( double, double ) 00162 { return 0.0; } 00163 00164 CubitVector PartPTCurve::coordinates() const 00165 { 00166 if( start_point() ) 00167 return start_point()->coordinates(); 00168 00169 if( end_point() ) 00170 return end_point()->coordinates(); 00171 00172 return CubitVector(0.,0.,0.); 00173 } 00174 00175 void PartPTCurve::reverse_sense() 00176 { } 00177 00178 CubitStatus PartPTCurve::save( CubitSimpleAttrib& attrib ) 00179 { 00180 int id = sub_entity_set().get_id(this); 00181 if( id <= 0 ) return CUBIT_FAILURE; 00182 00183 DLIList<int> end_points(4); 00184 get_save_topology(end_points); 00185 00186 return sub_entity_set().save_geometry( id, 1, 0, 0, &end_points, 0, attrib ); 00187 } 00188 00189 CubitStatus PartPTCurve::get_spline_params 00190 ( 00191 bool &rational, // return true/false 00192 int °ree, // the degree of this spline 00193 DLIList<CubitVector> &cntrl_pts, // xyz position of controlpoints 00194 DLIList<double> &cntrl_pt_weights, // if rational, a weight for each cntrl point. 00195 DLIList<double> &knots, // There should be order+cntrl_pts.size()-2 knots 00196 bool &spline_is_reversed 00197 ) const 00198 { 00199 PRINT_ERROR("Currently, Cubit is unable to determine spline parameters for PartPTCurves.\n"); 00200 return CUBIT_FAILURE; 00201 } 00202 00203 CubitStatus PartPTCurve::get_ellipse_params 00204 ( 00205 CubitVector ¢er_vec, 00206 CubitVector &normal, 00207 CubitVector &major_axis, 00208 double &radius_ratio 00209 ) const 00210 { 00211 PRINT_ERROR("Currently, Cubit is unable to determine ellipse parameters for PartPTCurves.\n"); 00212 return CUBIT_FAILURE; 00213 }