|
程序如下,编译了一下没有提示错误和警告,但是在ug里无法生成圆柱体。不知道是什么问题,恳请大虾们指教。。。
: @( M `! L: o7 g; K8 H: z+ M( j1 Q2 t* X0 J6 _2 t
int WHEEL_ok_cb ( int dialog_id,
, l4 W$ n/ \. z/ Q void * client_data,6 g% [* s& M2 z
UF_STYLER_item_value_type_p_t callback_data)$ |. _$ B3 H C5 l2 W
{
% X/ |5 C- ~4 @2 z/ ? /* Make sure User Function is available. */ / V6 U3 F- k0 R
if ( UF_initialize() != 0)
* C: n1 {6 _# E9 L return ( UF_UI_CB_CONTINUE_DIALOG );* H0 g% o8 W& Y
/* ---- Enter your callback code here ----- */
8 s; ]+ V' V4 r% A5 g( y( N create_wheel( dialog_id );
$ N, C* c' s6 Y: r8 S: v UF_terminate ();
: m) q! r% C* m8 H$ T' W3 T& A /* Callback acknowledged, terminate dialog */
5 @ B B! \$ W /* It is STRONGLY recommended that you exit your */$ w; J* {$ w$ `+ w8 h
/* callback with UF_UI_CB_EXIT_DIALOG in a ok callback.*/
K, K& D0 x0 x /* return ( UF_UI_CB_EXIT_DIALOG ); */1 O- }- p& M- j# s
return (UF_UI_CB_EXIT_DIALOG); : `9 m& g" I% I! x6 _
}/ t0 \3 l0 l* I' `9 Z$ p4 F
static void get_real_data
6 l+ [* A3 P" T0 |( int dialog_id, /*I*/
" j4 R, c# K7 _" n# o! E& Y% W+ h char *item_id, /*I*/4 A- J9 ^+ M3 P9 m( e! a$ v$ I
double *value /*O*/
- a* d- K5 z: u: [ ). H) T* `4 h- r' q
{' ^ r4 J/ v# [
UF_STYLER_item_value_type_t WHEEL;( L- r$ L& h. P8 Y4 N4 G" w% ?5 r" |
WHEEL.item_attr = UF_STYLER_VALUE;
+ R6 O$ y- T7 o( J5 k WHEEL.item_id = item_id;
8 a1 V. O$ n' O' m& q7 T UF_STYLER_ask_value ( dialog_id, &WHEEL );
. _7 E: L5 N3 T) ^! [4 H *value = WHEEL.value.real;- d0 t% H1 f: t8 E& F! M
}
/ O6 k5 v- n+ g4 W2 _5 X. Ystatic void create_wheel(int dialog_id)
$ ^, s$ R1 x1 {& ]+ Z) ]6 v: v$ S) v- l9 X{ G0 ?' l1 i7 Z2 t0 y
double diameter = 0.0;
. c+ P4 D. _# \# t8 ]+ ?: c double width = 0.0;
5 h) M0 ~" Y. M3 Q; z3 D0 a0 h+ q! l double origin[3] = {0.0, 30.0, 0.0 };
) F8 U8 n* c; U2 x$ a }. N/ U double direction[3] = {0, 0, 1 };
" d1 k; D3 E4 B4 | char *size[2] = { NULL };6 i: _8 q; P. N
tag_t cyl_obj_id = NULL_TAG;
9 w, O1 W+ J6 Q4 B- [7 }% Z int error = 0;8 Y1 c5 L7 M7 U+ `4 \
//取得用户输入。! x9 c1 f E) y6 F% ^2 I
get_real_data( dialog_id, WHEEL_DIAM, &diameter );# ]5 F6 t0 A) X( {, w, Y
get_real_data( dialog_id, WHEEL_HEIGHT, &width );- V6 [, i E4 r( C* @
//参数类型转换
3 C( W! w/ l4 ` size[0] = (char *)UF_allocate_memory( 256 * sizeof(char), &error );
4 k6 v! Y& t7 R size[1] = (char *)UF_allocate_memory( 256 * sizeof(char), &error );5 T3 W0 f. {1 E) y8 ~; H$ z1 F
sprintf( size[0], "%f", diameter );
8 A0 G) u( g7 d2 c. }5 {5 D sprintf( size[1], "%f", width );, f& X4 A0 x& K& j/ C7 I" U) j
//调用UF函数,生成Cylinder6 a' F3 G+ i' z0 _5 E4 d
error = UF_MODL_create_cyl1(UF_NULLSIGN, origin, size[1], size[0], direction, &cyl_obj_id);
- W; H5 [5 v8 m* ]( c. V V% V UF_free( size[0] );
' h- `* Z) _7 n: O* l+ q* k b( u UF_free( size[1] );' `1 d2 |5 \$ L' M! Q* B$ Q6 S
} |
|