MeshKit
1.0
|
00001 #include "CAMALCurveEval.hpp" 00002 #include "meshkit/ModelEnt.hpp" 00003 #include "meshkit/MKCore.hpp" 00004 #include "meshkit/iGeom.hpp" 00005 #include "meshkit/Error.hpp" 00006 00007 namespace MeshKit 00008 { 00009 00010 double CAMALCurveEval::arc_length() 00011 { 00012 return modelEnt->measure(); 00013 } 00014 00015 bool CAMALCurveEval::is_parametric() 00016 { 00017 return true; 00018 } 00019 00020 bool CAMALCurveEval::is_periodic(double& period) 00021 { 00022 bool is_peru, is_perv; 00023 iGeom::Error err = modelEnt->igeom_instance()->isEntPeriodic(modelEnt->geom_handle(), is_peru, is_perv); 00024 IBERRCHK(err, "Trouble calling isEntPeriodic."); 00025 double umin, umax; 00026 err = modelEnt->igeom_instance()->getEntURange(modelEnt->geom_handle(), umin, umax); 00027 IBERRCHK(err, "Trouble calling getEntURange."); 00028 period = umax - umin; 00029 return is_peru; 00030 } 00031 00032 void CAMALCurveEval::get_param_range(double& u_start, double& u_end) 00033 { 00034 iGeom::Error err = modelEnt->igeom_instance()->getEntURange(modelEnt->geom_handle(), u_start, u_end); 00035 IBERRCHK(err, "Trouble calling getEntURange."); 00036 } 00037 00038 double CAMALCurveEval::u_from_arc_length(double u_root, double arc_length) 00039 { 00040 double u_start, u_end; 00041 iGeom::Error err = modelEnt->igeom_instance()->getEntURange(modelEnt->geom_handle(), u_start, u_end); 00042 IBERRCHK(err, "Trouble calling getEntURange."); 00043 if (u_end-u_start <= 0) return arc_length/modelEnt->measure(); 00044 else return u_root + (arc_length/modelEnt->measure())*(u_end-u_start); 00045 } 00046 00047 bool CAMALCurveEval::position_from_u(double u, 00048 double& x, double& y, double& z ) 00049 { 00050 iGeom::Error err = modelEnt->igeom_instance()->getEntUtoXYZ(modelEnt->geom_handle(), u, x, y, z); 00051 IBERRCHK(err, "Trouble calling getEntUtoXYZ."); 00052 return true; 00053 } 00054 00055 void CAMALCurveEval::move_to_curve(double& x, double& y, double& z) 00056 { 00057 double dum[3]; 00058 modelEnt->evaluate(x, y, z, dum); 00059 x = dum[0]; 00060 y = dum[1]; 00061 z = dum[2]; 00062 } 00063 00064 double CAMALCurveEval::u_from_position(double x, double y, double z) 00065 { 00066 double u; 00067 iGeom::Error err = modelEnt->igeom_instance()->getEntXYZtoU(modelEnt->geom_handle(), x, y, z, u); 00068 IBERRCHK(err, "Trouble calling getEntXYZtoU."); 00069 return u; 00070 } 00071 00072 void CAMALCurveEval::start_coordinates(double& x, double& y, double& z) 00073 { 00074 double u_start, u_end; 00075 iGeom::Error err = modelEnt->igeom_instance()->getEntURange(modelEnt->geom_handle(), u_start, u_end); 00076 IBERRCHK(err, "Trouble calling getEntURange."); 00077 position_from_u(u_start, x, y, z); 00078 } 00079 00080 void CAMALCurveEval::end_coordinates(double& x, double& y, double& z) 00081 { 00082 double u_start, u_end; 00083 iGeom::Error err = modelEnt->igeom_instance()->getEntURange(modelEnt->geom_handle(), u_start, u_end); 00084 IBERRCHK(err, "Trouble calling getEntURange."); 00085 position_from_u(u_end, x, y, z); 00086 } 00087 00088 } // namespace MeshKit 00089