cgma
|
00001 //- Class: SurfParamTool 00002 //------------------------------------------------------------------------- 00003 // Filename : SurfParamTool.cpp 00004 // 00005 // Purpose : This is the generic version of ParamTool when the 00006 // geometry engine has a sufficient parameterization. 00007 // It uses the tool's existing functions to get transform 00008 // between uv and xyz spaces. 00009 // 00010 // Creator : Christopher Hynes 00011 // 00012 // Creation Date : 7/10/2002 00013 // 00014 // Owner : Christopher Hynes 00015 //------------------------------------------------------------------------- 00016 00017 #include "SurfParamTool.hpp" 00018 #include "CastTo.hpp" 00019 #include "Surface.hpp" 00020 #include "DLIList.hpp" 00021 00022 //------------------------------------------------------------------------- 00023 // Function: SurfParamTool 00024 // Description: constructor 00025 // Author: chynes 00026 // Date: 7/10/2002 00027 //------------------------------------------------------------------------- 00028 SurfParamTool::SurfParamTool(Surface *surf) 00029 { 00030 00031 //- update private variables 00032 refSurf = surf; 00033 00034 } 00035 00036 //------------------------------------------------------------------------- 00037 // Function: SurfParamTool 00038 // Description: deconstructor 00039 // Author: chynes 00040 // Date: 7/10/2002 00041 //------------------------------------------------------------------------- 00042 SurfParamTool::~SurfParamTool() {} 00043 00044 //=================================================================================== 00045 // Function: set_up_space (Public) 00046 // Description: sets up space of flattening 00047 // Author: chynes 00048 // Date: 7/10/02 00049 //=================================================================================== 00050 CubitStatus SurfParamTool::set_up_space(void) { 00051 00052 CubitStatus rv = CUBIT_SUCCESS; 00053 00054 00055 return rv; 00056 } 00057 00058 //=================================================================================== 00059 // Function: transform_to_uv (Public) 00060 // Description: same as title, the local sizing will be returned in the z coord 00061 // Author: chynes 00062 // Date: 7/10/02 00063 //=================================================================================== 00064 CubitStatus SurfParamTool::transform_to_uv(const CubitVector &xyz_location, CubitVector &uv_location) 00065 { 00066 double u,v; 00067 00068 CubitStatus rv = refSurf->u_v_from_position(xyz_location, u, v); 00069 uv_location.set(u,v,1.0); 00070 00071 CubitVector du, dv; 00072 uv_derivitives(u,v,du,dv); 00073 00074 return rv; 00075 } 00076 00077 //=================================================================================== 00078 // Function: transform_to_xyz (Public) 00079 // Description: same as title 00080 // Author: chynes 00081 // Date: 7/10/02 00082 //=================================================================================== 00083 CubitStatus SurfParamTool::transform_to_xyz(CubitVector &xyz_location, const CubitVector &uv_location) 00084 { 00085 xyz_location = refSurf->position_from_u_v(uv_location.x(), uv_location.y()); 00086 00087 return CUBIT_SUCCESS; 00088 } 00089 00090 CubitStatus SurfParamTool::uv_derivitives( double u_param, double v_param, CubitVector &du, CubitVector &dv ) 00091 { 00092 return refSurf->uv_derivitives (u_param, v_param, du, dv); 00093 } 00094 00095 //void intersect2DLines(double x0, double y0, double x1, double y1, 00096 // double x2, double y2, double x3, double y3, 00097 // double &xc, double &yc) 00101 //{ 00102 // double u = ( (x3-x2)*(y0-y2) - (y3-y2)*(x0-x2) ) / ( (y3-y2)*(x1-x0) - (x3-x2)*(y1-y0) ); 00103 // 00104 // xc = x0 + u * (x1-x0); 00105 // yc = y0 + u * (y1-y0); 00106 //} 00107 // 00108 // 00109 // 00110 //CubitStatus SurfParamTool::circumcenter(double u0, double v0, 00111 // double u1, double v1, 00112 // double u2, double v2, 00113 // CubitVector ¢er) 00118 //{ 00119 // 00120 // // first, lets calculate the circumcenter without the gradients to make sure the system works 00121 // 00122 // // our method for finding a circumcenter utilizes the fact that the perpendicalar bisectors of each side 00123 // // of the triangle intersect at the circumcenter 00124 // 00125 // // find the three bisectors of the sides 00126 // 00127 // double u3 = u0 + (u1 - u0) * 0.5; // midpoint of side 0-1 00128 // double v3 = v0 + (v1 - v0) * 0.5; 00129 // 00130 // double u4 = u3 + v0 - v1; // point on the perp bisector of side 0-1 00131 // double v4 = v3 + u1 - u0; 00132 // 00133 // double u5 = u1 + (u2 - u1) * 0.5; // midpoint of side 1-2 00134 // double v5 = v1 + (v2 - v1) * 0.5; 00135 // 00136 // double u6 = u5 + v1 - v2; // point on the perp bisector of side 1-2 00137 // double v6 = v5 + u2 - u1; 00138 // 00139 // double u7 = u0 + (u2 - u0) * 0.5; // midpoint of side 0-2 00140 // double v7 = v0 + (v2 - v0) * 0.5; 00141 // 00142 // double u8 = u7 + v0 - v2; 00143 // double v8 = v7 + u2 - u0; 00144 // 00145 // // intersect two bisectors to give a cirumcenter 00146 // 00147 // double xc, yc; 00148 // intersect2DLines(u3,v3,u4,v4,u5,v5,u6,v6,xc,yc); 00149 // double xc2, yc2; 00150 // intersect2DLines(u3,v3,u4,v4,u7,v7,u8,v8,xc2,yc2); 00151 // double xc3, yc3; 00152 // intersect2DLines(u5,v5,u6,v6,u7,v7,u8,v8,xc3,yc3); 00153 // 00154 // 00155 // 00156 // 00157 // //// get derivitives of each point 00158 // 00159 // //CubitVector du0, du1, du2, dv0, dv1, dv2, du, dv; 00160 // //uv_derivitives (u0, v0, du0, dv0); 00161 // //uv_derivitives (u1, v1, du1, dv1); 00162 // //uv_derivitives (u2, v2, du2, dv2); 00163 // 00164 // //// for now, average derivities first 00165 // 00166 // //du = (du0 + du1 + du2) / 3.0; n 00167 // //dv = (dv0 + dv1 + dv2) / 3.0; 00168 // 00169 // //// Calculate the rotation angle to the principal axis 00170 // 00171 // //double alpha = atan2( 2.0 * ( du.x()*dv.x() + du.y()*dv.y() ), (du.length_squared() - dv.length_squared())) * 0.5; 00172 // 00173 // //// Calculate principal derivitives 00174 // 00175 // //double cosa = acos(alpha); 00176 // //double sina = asin(alpha); 00177 // //CubitVector dup = cosa * du + sina * dv; 00178 // //CubitVector dvp = -sina * du + cosa * dv; 00179 // 00180 // //// 00181 // 00182 // 00183 // return CUBIT_SUCCESS; 00184 //} 00185 00186 00187 00188 00189 //EOF 00190 00191 //- Class: TestParamTool 00192 //------------------------------------------------------------------------- 00193 // Filename : TestParamTool.cpp 00194 // 00195 // Purpose : This is the generic version of ParamTool when the 00196 // geometry engine has a sufficient parameterization. 00197 // It uses the tool's existing functions to get transform 00198 // between uv and xyz spaces. 00199 // 00200 // Creator : Christopher Hynes 00201 // 00202 // Creation Date : 7/10/2002 00203 // 00204 // Owner : Christopher Hynes 00205 //------------------------------------------------------------------------- 00206 00207 #include "CastTo.hpp" 00208 #include "Surface.hpp" 00209 #include "DLIList.hpp" 00210 00211 //------------------------------------------------------------------------- 00212 // Function: TestParamTool 00213 // Description: constructor 00214 // Author: chynes 00215 // Date: 7/10/2002 00216 //------------------------------------------------------------------------- 00217 TestParamTool::TestParamTool() 00218 { 00219 00220 //- update private variables 00221 // refSurf = surf; 00222 00223 uRange = 1.0; 00224 vRange = 4.0; 00225 00226 xMin = -0.5; 00227 yMin = -0.5; 00228 00229 xMax = 0.5; 00230 yMax = 0.5; 00231 00232 00233 zDepth = 0.5; // constant z coordinate of test surface 00234 00235 } 00236 00237 //------------------------------------------------------------------------- 00238 // Function: TestParamTool 00239 // Description: deconstructor 00240 // Author: chynes 00241 // Date: 7/10/2002 00242 //------------------------------------------------------------------------- 00243 TestParamTool::~TestParamTool() {} 00244 00245 //=================================================================================== 00246 // Function: set_up_space (Public) 00247 // Description: sets up space of flattening 00248 // Author: chynes 00249 // Date: 7/10/02 00250 //=================================================================================== 00251 CubitStatus TestParamTool::set_up_space(void) 00252 { 00253 00254 CubitStatus rv = CUBIT_SUCCESS; 00255 00256 00257 return rv; 00258 } 00259 00260 //=================================================================================== 00261 // Function: transform_to_uv (Public) 00262 // Description: same as title, the local sizing will be returned in the z coord 00263 // Author: chynes 00264 // Date: 7/10/02 00265 //=================================================================================== 00266 CubitStatus TestParamTool::transform_to_uv(const CubitVector &xyz_location, CubitVector &uv_location) 00267 { 00268 // calculate the u,v from the x,y 00269 00270 double u = (xyz_location.x()-xMin)/(xMax-xMin) * uRange; 00271 double v = (xyz_location.y()-yMin)/(yMax-yMin) * vRange; 00272 uv_location.set(u,v,1.0); 00273 00274 return CUBIT_SUCCESS; 00275 } 00276 00277 //=================================================================================== 00278 // Function: transform_to_xyz (Public) 00279 // Description: same as title 00280 // Author: chynes 00281 // Date: 7/10/02 00282 //=================================================================================== 00283 CubitStatus TestParamTool::transform_to_xyz(CubitVector &xyz_location, const CubitVector &uv_location) 00284 { 00285 // get x,y from u,v 00286 00287 double x = uv_location.x()/uRange + xMin; 00288 double y = uv_location.y()/vRange + yMin; 00289 00290 xyz_location.set(x,y,zDepth); 00291 00292 return CUBIT_SUCCESS; 00293 } 00294 00295 CubitStatus TestParamTool::uv_derivitives( double u_param, double v_param, CubitVector &du, CubitVector &dv ) 00296 { 00297 du.set(1.0/uRange,0,0); 00298 dv.set(0,1.0/vRange,0); 00299 return CUBIT_SUCCESS; 00300 }