|
程序如下,编译了一下没有提示错误和警告,但是在ug里无法生成圆柱体。不知道是什么问题,恳请大虾们指教。。。
' `7 X5 p: M$ r5 K9 y; R7 @- ?! z* L' T: V
int WHEEL_ok_cb ( int dialog_id,' a" d# C B0 ?) X
void * client_data,; s3 E7 E* s9 n
UF_STYLER_item_value_type_p_t callback_data)8 @) @5 ]# r1 f8 |( O0 Q
{
[5 V/ P5 q7 |7 _& E# b6 T /* Make sure User Function is available. */
, d# U/ A3 G2 ~: \5 x5 Q if ( UF_initialize() != 0)
* x) z: Y' i5 K6 u0 g( O4 l! ^ return ( UF_UI_CB_CONTINUE_DIALOG );$ n" ?$ y7 a2 W7 l4 p1 d
/* ---- Enter your callback code here ----- */
; S: ]) S4 @: B create_wheel( dialog_id );
# _8 j3 P" s& s% r5 L: x UF_terminate ();
8 V$ D6 e. @/ j7 R, O0 B7 O /* Callback acknowledged, terminate dialog */
+ d5 k# h& q+ C) ?1 a /* It is STRONGLY recommended that you exit your */9 Y; C8 b) }" ?1 B- s1 ?
/* callback with UF_UI_CB_EXIT_DIALOG in a ok callback.*/( M' P1 x9 V& `0 y) o' M, k1 w
/* return ( UF_UI_CB_EXIT_DIALOG ); */
* x- Z: E6 L# g K! l return (UF_UI_CB_EXIT_DIALOG); - a: K2 O5 Q' T4 d0 a
}; ~3 v( n- l) q3 t) z
static void get_real_data: w l; J5 P6 J
( int dialog_id, /*I*/
& U0 w \9 a5 q0 r* i char *item_id, /*I*/
' ]& Y2 k- {9 f5 k double *value /*O*/
$ j% T7 E2 M( m0 v7 U$ w6 { )6 K% n) @2 D8 c8 b# M
{
% X/ ~# U* b* U* Q UF_STYLER_item_value_type_t WHEEL;
- H1 D; H5 j8 X4 C" ^% Z- B WHEEL.item_attr = UF_STYLER_VALUE;6 Q* x: ^& a3 O1 x: a3 G9 V* s
WHEEL.item_id = item_id;
% C$ u8 g/ O$ v' ?$ N UF_STYLER_ask_value ( dialog_id, &WHEEL );) e4 W7 m8 T7 I5 Z* y- O# N
*value = WHEEL.value.real;
! D: R: k' v1 t' V}
+ k2 ^0 H# }( Z, M4 k8 U6 Cstatic void create_wheel(int dialog_id)9 w9 t8 T& [) |9 A/ b/ a: O' r* t. l
{
+ ^& C5 G2 o. H# e) \& j( D double diameter = 0.0;* M1 T$ ^2 A' j4 l+ m
double width = 0.0;0 d5 E+ S, P, C/ \, s5 L- i
double origin[3] = {0.0, 30.0, 0.0 };
, Z X# @' {- Y$ o5 q double direction[3] = {0, 0, 1 };& d! m! o J+ y f% D
char *size[2] = { NULL };
2 _# a+ Q) \) R' m tag_t cyl_obj_id = NULL_TAG;
" w e$ G' b% ?, b" U int error = 0;# D+ `6 [* n2 e; `/ U2 z; ]
//取得用户输入。
# Q" ^; R. ?. n' _# H+ c1 ^3 k get_real_data( dialog_id, WHEEL_DIAM, &diameter );9 u0 l2 K1 }5 {
get_real_data( dialog_id, WHEEL_HEIGHT, &width );
; p9 `. e. d3 z0 d; ^. L/ o& U //参数类型转换7 B8 x3 ^! O' T$ _/ o
size[0] = (char *)UF_allocate_memory( 256 * sizeof(char), &error );
1 z2 `9 a/ O" x2 s x size[1] = (char *)UF_allocate_memory( 256 * sizeof(char), &error );- Y9 n1 T% N; n: i
sprintf( size[0], "%f", diameter );8 M5 x. n5 H; g: K- | \3 r( d
sprintf( size[1], "%f", width );
8 r9 D. j, H0 `4 G: Z //调用UF函数,生成Cylinder ]* y2 m A1 f; X+ B
error = UF_MODL_create_cyl1(UF_NULLSIGN, origin, size[1], size[0], direction, &cyl_obj_id);( U- m8 H2 U# `. p
UF_free( size[0] );
, Y! h8 G7 Z/ Z4 O: k4 Q UF_free( size[1] );
' ]8 f7 Q1 t V9 y' e6 P& u} |
|