弄了一天。ok了。下面是代码。共享一下。或许以后有人用得着。
static void set_wcs_for_setup(Setup &setup)
{
double csys[9],x_axis[3],y_axis[3],origin[3];
tag_t mx,wcs,geomTag,setupTag,geomRootTag;
char reason[UF_NCGROUP_MAX_REASON_LEN+1];
logical answer;
origin[0] = setup.origin.getX();
origin[1] = setup.origin.getY();
origin[2] = setup.origin.getZ();
x_axis[0] = setup.x.getX()-origin[0];
x_axis[1] = setup.x.getY()-origin[1];
x_axis[2] = setup.x.getZ()-origin[2];
y_axis[0] = setup.y.getX()-origin[0];
y_axis[1] = setup.y.getY()-origin[1];
y_axis[2] = setup.y.getZ()-origin[2];
UF_MTX3_initialize(x_axis, y_axis, csys);
UF_CSYS_create_matrix(csys, &mx);
UF_CSYS_create_csys(origin, mx, &wcs);
UF_CSYS_set_wcs(wcs);
char* type = const_cast<char*>(setup.type.c_str());
char* subType = const_cast<char*>(setup.subType.c_str());
UF_NCGEOM_create(type, subType, &geomTag);
UF_OBJ_set_name(geomTag, setup.name.c_str());
UF_SETUP_ask_setup(&setupTag);
UF_SETUP_ask_geom_root(setupTag, &geomRootTag);
UF_NCGROUP_can_accept_member(geomRootTag, geomTag, &answer, reason);
if(answer == TRUE)
UF_NCGROUP_accept_member(geomRootTag, geomTag);
UF_PARAM_set_tag_value(geomTag, UF_PARAM_MCS, wcs);
} |