|
马上注册登录,享用更多网站功能!
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
// DelCurves.cpp : Defines the initialization routines for the DLL.
//但是还是实现我了我想实现的功能,判断有重合的线,然后自动去除一条,请大家帮帮忙~
#include "stdafx.h"
#include "DelCurves.h"
#include "ug.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
BEGIN_MESSAGE_MAP(CDelCurvesApp, CWinApp)
END_MESSAGE_MAP()
// CDelCurvesApp construction
CDelCurvesApp::CDelCurvesApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
// The one and only CDelCurvesApp object
CDelCurvesApp theApp;
// CDelCurvesApp initialization
BOOL CDelCurvesApp::InitInstance()
{
CWinApp::InitInstance();
return TRUE;
}
extern int mask_for_curves(UF_UI_selection_p_t select, void *type)
{
UF_UI_mask_t
mask[4] = { { UF_line_type, 0, 0 },
{ UF_circle_type, 0, 0 },
{ UF_conic_type, UF_all_subtype, 0 },
{ UF_spline_type, 0, 0 }};
if (!UF_CALL(UF_UI_set_sel_mask(
select, //输入选择的点
UF_UI_SEL_MASK_CLEAR_AND_ENABLE_SPECIFIC, //面动作
4, //Number of mask triples
mask) //Array of mask triples
))
return (UF_UI_SEL_SUCCESS);
else
return (UF_UI_SEL_FAILURE);
}
static int deletecurve(char *prompt, tag_t **curves)
{
int
resp,n,ii;
UF_CALL(
UF_UI_select_with_class_dialog( //Select multiple objects with the class selection dialog.
"Select curves", //Cue line message to display
prompt, //Dialog Title or Null提示
UF_UI_SEL_SCOPE_ANY_IN_ASSEMBLY, /*int scope,选择范围
Selection scope
UF_UI_SEL_SCOPE_NO_CHANGE
UF_UI_SEL_SCOPE_ANY_IN_ASSEMBLY
UF_UI_SEL_SCOPE_WORK_PART
UF_UI_SEL_SCOPE_WORK_PART_AND_OCC*/
mask_for_curves, //按分类选择
NULL, //User data for initialization procedure or NULL
&resp, /*UF_UI_BACK
UF_UI_CANCEL
UF_UI_OK*/
&n, //被选择对象的个数
curves) //被选中对象标示的数组
);
for (ii = 0; ii < n; ii++)
UF_CALL(UF_DISP_set_highlight((*curves)[ii], 0));
return n;
}
void do_api()
{
int n_curves,n,i,j,k,m;
tag_t *curves_id;
double point_coords[ 3 ];
double point[10][3];
char buffer[UF_UI_MAX_STRING_LEN];
n_curves = deletecurve("Select Curves", &curves_id);
CString str;
str.Format("%d",n_curves);
AfxMessageBox(str);
for ( n=0;n<n_curves;n++ )
{
tag_t
last,
offset,
start;
UF_CALL(UF_SO_create_scalar_double( //Creates a double scalar.
curves_id[n], //Tag of object in part
UF_SO_update_after_modeling, //Update option
0.0, //Real constant常数
&start) //Pointer to double scalar
);
UF_CALL(UF_SO_create_point_on_curve( //Creates a smart point via a curve and scalar value t
curves_id[n], //Tag of object in part
UF_SO_update_after_modeling, //Update option
curves_id[n], //Tag of curve
start, //Tag of scale
&last) //Pointer to tag of point
);
UF_CALL(UF_SO_set_visibility_option( //Sets the visibility option for the specified smart object
last, //Tag of smart object
UF_SO_invisible) //visibility option
);
UF_CALL(UF_SO_create_scalar_double(
curves_id[n],
UF_SO_update_after_modeling,
0.5,
&offset)
);
UF_CALL(UF_SO_create_point_along_curve(
curves_id[n],
UF_SO_update_after_modeling,
curves_id[n],
last,
offset,
UF_SO_point_along_curve_percent,
FALSE,
&last));
UF_CALL(UF_SO_set_visibility_option(
last,
UF_SO_visible)
);
UF_CURVE_ask_point_data (
last,
point_coords );
i = n;
if ( i<n_curves )
{
point[i][0] = point_coords[0];
point[i][1] = point_coords[1];
point[i][2] = point_coords[2];
}
UF_OBJ_delete_object( last );
}
for( j=0;j<n_curves;j++ )
{
UF_CALL(UF_UI_open_listing_window());
sprintf(buffer,"Point NO: = %d\n", j+1);
UF_CALL(UF_UI_write_listing_window(buffer));
UF_CALL(UF_UI_open_listing_window());
sprintf(buffer,"Center Point Data is: = \n%f\n", point[j][0]);
UF_CALL(UF_UI_write_listing_window(buffer));
UF_CALL(UF_UI_open_listing_window());
sprintf(buffer,"%f\n", point[j][1]);
UF_CALL(UF_UI_write_listing_window(buffer));
UF_CALL(UF_UI_open_listing_window());
sprintf(buffer,"%f\n", point[j][2]);
UF_CALL(UF_UI_write_listing_window(buffer));
UF_CALL(UF_UI_write_listing_window("\n"));
}
for( k=0;k<n_curves;k++ )
{
for( m=1;m<n_curves;m++ )
{
if( (point[k][0] == point[m][0]) && (point[k][1] == point[m][1]) && (point[k][2] == point[m][2]) (k!=m) )
{
UF_OBJ_delete_object( curves_id[m] );
AfxMessageBox("有重合");
}
}
}
}
extern "C" DllExport void ufusr (char *param,int *returnCode, int rlen)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
if(!UF_CALL(UF_initialize()))
{
do_api();
UF_CALL(UF_terminate());
}
}
int ufusr_ask_unload(void)
{
return (UF_UNLOAD_SEL_DIALOG);
} |
|