/*判断曲线是否是样条*/ bool isSpline(tag_t cruve_tag) { logical is_spline = 0; UF_EVAL_p_t evaluator; UF_CALL(UF_EVAL_initialize(cruve_tag, &evaluator)); UF_CALL(UF_EVAL_is_spline(evaluator, &is_spline)); UF_CALL(UF_EVAL_free(evaluator)); return is_spline; } /*判断样条是否是2D维度*/ bool isSpline2D(tag_t cruve_tag) { if (isSpline(cruve_tag)) { /*获取几何对象的维度*/ int dimensionality;//物体的维度 double data[6]; //如果dimensionality(维度) = UF_MODL_POINT,data[0 - 2] = 点的坐标 //如果dimensionality(维度) = UF_MODL_LINEAR,data[0 - 2] = 直线上一点的坐标,data[3 - 5] = 直线的单位方向向量 //如果dimensionality(维度) = UF_MODL_PLANAR,data[0 - 2] = 平面上一点的坐标,data[3 - 5] = 平面的单位法向量 //如果dimensionality(维度) = UF_MODL_THREE_DIMENSIONAL,data[0 - 5] = 未使用 UF_CALL(UF_MODL_ask_obj_dimensionality(cruve_tag, &dimensionality, data)); if (UF_MODL_LINEAR == dimensionality || UF_MODL_PLANAR == dimensionality) return 1; } return 0; } /*判断样条是否近似线性(是否可转换成直线)*/ bool isSpline2DLinearSimilar(tag_t cruve_tag) { if (isSpline2D(cruve_tag)) { /*计算曲线的最大曲率数据 */ double check_curva = 1 / 300.0; double range[4] = { 0,100,0,0 };//For curves: range[0]=umin, range[1]=umax.For surfaces: range[0-1]= umin & umax range[2-3]=vmin & vmax int curva_type = 0;//Not used for curve objects double max_curva[5];//O //For curve objects max_curva[0] = u ,max_curva[1-3]: 曲率最大的点坐标 ,max_curva[4]: 最大曲率 int status;//0= max_curva[] is returned.1=constant curvature object encountered. only return the constant value in max_curva[4] UF_CALL(UF_MODL_ask_max_curvature(cruve_tag, range, curva_type, max_curva, &status)); if (fabs(max_curva[4]) < check_curva) return 1; } return 0; }