大家帮看看
有什么毛病?新手,勿笑。
#include "stdafx.h"
#include "Create_Box.h"
#include "ug.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
BEGIN_MESSAGE_MAP(CCreate_BoxApp, CWinApp)
END_MESSAGE_MAP()
CCreate_BoxAppCreate_BoxApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
// The one and only CCreate_BoxApp object
CCreate_BoxApp theApp;
// CCreate_BoxApp initialization
BOOL CCreate_BoxApp:nitInstance()
{
CWinApp:nitInstance();
return TRUE;
}
static double cc[6];
static tag_t select_anything(char *prompt)
{
double
cp[3];
int
resp;
tag_t
view;
tag_t
object;
UF_CALL(UF_UI_select_with_single_dialog(
prompt,
"Asset Create Box",
UF_UI_SEL_SCOPE_WORK_PART,
NULL,
NULL,
&resp,
&object,
cp,
[$view))]
if (resp == UF_UI_OBJECT_SELECTED || resp == UF_UI_OBJECT_SELECTED_BY_NAME)
{
UF_CALL(UF_DISP_set_highlight(object, 0));
return object;
}
else return NULL_TAG;
}
static void display_bounding_box(tag_t object)
{
double
box[6],
end[3],
start[3];
UF_OBJ_disp_props_t
props = { 1, UF_OBJ_WHITE, UF_OBJ_NOT_BLANKED, UF_OBJ_WIDTH_NORMAL,
UF_OBJ_FONT_SOLID, FALSE};
UF_MODL_ask_bounding_box(object, box);
start[0] = box[0];
start[1] = box[1];
start[2] = box[2];
end[0] = box[3];
end[1] = box[1];
end[2] = box[2];
UF_CALL(UF_DISP_display_temporary_line(NULL_TAG, UF_DISP_USE_WORK_VIEW,
start, end, [$props))]
start[0] = box[3];
start[1] = box[1];
start[2] = box[2];
end[0] = box[3];
end[1] = box[1];
end[2] = box[5];
UF_CALL(UF_DISP_display_temporary_line(NULL_TAG, UF_DISP_USE_WORK_VIEW,
start, end, [$props))]
start[0] = box[3];
start[1] = box[1];
start[2] = box[5];
end[0] = box[0];
end[1] = box[1];
end[2] = box[5];
UF_CALL(UF_DISP_display_temporary_line(NULL_TAG, UF_DISP_USE_WORK_VIEW,
start, end, [$props))]
start[0] = box[0];
start[1] = box[1];
start[2] = box[5];
end[0] = box[0];
end[1] = box[1];
end[2] = box[2];
UF_CALL(UF_DISP_display_temporary_line(NULL_TAG, UF_DISP_USE_WORK_VIEW,
start, end, [$props))]
start[0] = box[0];
start[1] = box[1];
start[2] = box[2];
end[0] = box[0];
end[1] = box[4];
end[2] = box[2];
UF_CALL(UF_DISP_display_temporary_line(NULL_TAG, UF_DISP_USE_WORK_VIEW,
start, end, [$props))]
start[0] = box[3];
start[1] = box[1];
start[2] = box[2];
end[0] = box[3];
end[1] = box[4];
end[2] = box[2];
UF_CALL(UF_DISP_display_temporary_line(NULL_TAG, UF_DISP_USE_WORK_VIEW,
start, end, [$props))]
start[0] = box[3];
start[1] = box[1];
start[2] = box[5];
end[0] = box[3];
end[1] = box[4];
end[2] = box[5];
UF_CALL(UF_DISP_display_temporary_line(NULL_TAG, UF_DISP_USE_WORK_VIEW,
start, end, [$props))]
start[0] = box[0];
start[1] = box[1];
start[2] = box[5];
end[0] = box[0];
end[1] = box[4];
end[2] = box[5];
UF_CALL(UF_DISP_display_temporary_line(NULL_TAG, UF_DISP_USE_WORK_VIEW,
start, end, [$props))]
start[0] = box[0];
start[1] = box[4];
start[2] = box[2];
end[0] = box[3];
end[1] = box[4];
end[2] = box[2];
UF_CALL(UF_DISP_display_temporary_line(NULL_TAG, UF_DISP_USE_WORK_VIEW,
start, end, [$props))]
start[0] = box[3];
start[1] = box[4];
start[2] = box[2];
end[0] = box[3];
end[1] = box[4];
end[2] = box[5];
UF_CALL(UF_DISP_display_temporary_line(NULL_TAG, UF_DISP_USE_WORK_VIEW,
start, end, [$props))]
start[0] = box[3];
start[1] = box[4];
start[2] = box[5];
end[0] = box[0];
end[1] = box[4];
end[2] = box[5];
UF_CALL(UF_DISP_display_temporary_line(NULL_TAG, UF_DISP_USE_WORK_VIEW,
start, end, [$props))]
start[0] = box[0];
start[1] = box[4];
start[2] = box[5];
end[0] = box[0];
end[1] = box[4];
end[2] = box[2];
UF_CALL(UF_DISP_display_temporary_line(NULL_TAG, UF_DISP_USE_WORK_VIEW,
start, end, [$props))]
cc[0] = box[0];
cc[1] = box[1];
cc[2] = box[2];
cc[3] = box[3];
cc[4] = box[4];
cc[5] = box[5];
}
static double aa[6];
static double bb[6];
void do_it1(void)
{
tag_t
object1,object2;
object1 = select_anything("Select an object");
display_bounding_box(object1);
aa[0] = cc[0];
aa[1] = cc[1];
aa[2] = cc[2];
aa[3] = cc[3];
aa[4] = cc[4];
aa[5] = cc[5];
object2 = select_anything("Select an object");
display_bounding_box(object2);
bb[0] = cc[0];
bb[1] = cc[1];
bb[2] = cc[2];
bb[3] = cc[3];
bb[4] = cc[4];
bb[5] = cc[5];
}
void show_it()
{
//下面是求最大轮廓
double dd[3] = {0,0,0};
for( int i= 0;i<3;i++)
{
if( aa < bb)
dd = aa;
else dd = bb;
}
double ee[3] = {0,0,0};
for( int i= 3;i<6;i++)
{
if( aa > bb)
ee = aa;
else ee = bb;
}
double ff[6]= {0,0,0,0,0,0};
ff[0] = dd[0];
ff[1] = dd[1];
ff[2] = dd[2];
ff[3] = ee[0];
ff[4] = ee[1];
ff[5] = ee[2];
//画最大轮廓线
UF_CURVE_line_t sline1;
tag_t line1;
sline1.start_point[0] =ff[0];
sline1.start_point[1] =ff[1];
sline1.start_point[2] =ff[2];
sline1.end_point[0] = ff[3];
sline1.end_point[1] = ff[1];
sline1.end_point[2] = ff[2];
UF_CURVE_create_line([$sline1,&line1)]
UF_CURVE_line_t sline2;
tag_t line2;
sline1.start_point[0] =ff[3];
sline1.start_point[1] =ff[1];
sline1.start_point[2] =ff[2];
sline1.end_point[0] = ff[3];
sline1.end_point[1] = ff[1];
sline1.end_point[2] = ff[5];
UF_CURVE_create_line([$sline2,&line2)]
UF_CURVE_line_t sline3;
tag_t line3;
sline1.start_point[0] =ff[3];
sline1.start_point[1] =ff[1];
sline1.start_point[2] =ff[5];
sline1.end_point[0] = ff[0];
sline1.end_point[1] = ff[1];
sline1.end_point[2] = ff[5];
UF_CURVE_create_line([$sline3,&line3)]
UF_CURVE_line_t sline4;
tag_t line4;
sline1.start_point[0] =ff[0];
sline1.start_point[1] =ff[1];
sline1.start_point[2] =ff[5];
sline1.end_point[0] = ff[0];
sline1.end_point[1] = ff[1];
sline1.end_point[2] = ff[2];
UF_CURVE_create_line([$sline4,&line4)]
UF_CURVE_line_t sline5;
tag_t line5;
sline1.start_point[0] =ff[0];
sline1.start_point[1] =ff[1];
sline1.start_point[2] =ff[2];
sline1.end_point[0] = ff[0];
sline1.end_point[1] = ff[4];
sline1.end_point[2] = ff[2];
UF_CURVE_create_line([$sline5,&line5)]
UF_CURVE_line_t sline6;
tag_t line6;
sline1.start_point[0] =ff[3];
sline1.start_point[1] =ff[1];
sline1.start_point[2] =ff[2];
sline1.end_point[0] = ff[3];
sline1.end_point[1] = ff[4];
sline1.end_point[2] = ff[2];
UF_CURVE_create_line([$sline6,&line6)]
UF_CURVE_line_t sline7;
tag_t line7;
sline1.start_point[0] =ff[3];
sline1.start_point[1] =ff[1];
sline1.start_point[2] =ff[5];
sline1.end_point[0] = ff[3];
sline1.end_point[1] = ff[4];
sline1.end_point[2] = ff[5];
UF_CURVE_create_line([$sline7,&line7)]
UF_CURVE_line_t sline8;
tag_t line8;
sline1.start_point[0] =ff[0];
sline1.start_point[1] =ff[1];
sline1.start_point[2] =ff[5];
sline1.end_point[0] = ff[0];
sline1.end_point[1] = ff[4];
sline1.end_point[2] = ff[5];
UF_CURVE_create_line([$sline8,&line8)]
UF_CURVE_line_t sline9;
tag_t line9;
sline1.start_point[0] =ff[0];
sline1.start_point[1] =ff[4];
sline1.start_point[2] =ff[2];
sline1.end_point[0] = ff[3];
sline1.end_point[1] = ff[4];
sline1.end_point[2] = ff[2];
UF_CURVE_create_line([$sline9,&line9)]
UF_CURVE_line_t sline10;
tag_t line10;
sline1.start_point[0] =ff[3];
sline1.start_point[1] =ff[4];
sline1.start_point[2] =ff[2];
sline1.end_point[0] = ff[3];
sline1.end_point[1] = ff[4];
sline1.end_point[2] = ff[5];
UF_CURVE_create_line([$sline10,&line10)]
UF_CURVE_line_t sline11;
tag_t line11;
sline1.start_point[0] =ff[3];
sline1.start_point[1] =ff[4];
sline1.start_point[2] =ff[5];
sline1.end_point[0] = ff[0];
sline1.end_point[1] = ff[4];
sline1.end_point[2] = ff[5];
UF_CURVE_create_line([$sline11,&line11)]
UF_CURVE_line_t sline12;
tag_t line12;
sline1.start_point[0] =ff[0];
sline1.start_point[1] =ff[4];
sline1.start_point[2] =ff[5];
sline1.end_point[0] = ff[0];
sline1.end_point[1] = ff[4];
sline1.end_point[2] = ff[2];
UF_CURVE_create_line([$sline12,&line12)]
}
extern "C" DllExport void ufusr (char *param,int *returnCode, int rlen)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
if(!UF_CALL(UF_initialize()))
{
do_it1();
show_it();
UF_CALL(UF_terminate());
}
}
int ufusr_ask_unload(void)
{
return (UF_UNLOAD_SEL_DIALOG);
} |