|
leaf
发表于 2014-11-26 07:50:53
tag_t newPartTag = NULL_TAG;
4 H% _/ d I" ?/ C, ` w& b H5 T tag_t cylTag = NULL_TAG;
" e( K. [$ E. L" L tag_t bodyTag = NULL_TAG;
; J8 ]5 b' @8 w5 \0 W double cylOrigin[3] = {20, 30, 40};
9 U% T5 J c8 w T9 ^ char cylDiam[256] = "50";8 T9 q& k% x4 ?/ S* m, e$ P
double cylDirection[3] = {0, 0 ,1};
1 _/ F0 X6 h4 H double height = 60;/ H: f/ V) s# W l: @
: I7 J5 t- Z! H2 {/ a& K) V" O
5 u+ h9 W" r2 @9 x char cylHeight[256];
5 _( B5 }6 S4 q( _- _' h# E# ?+ k3 | sprintf_s(cylHeight, sizeof(cylHeight), "%f", height);
/ \: W8 B6 k( t7 |: F% L( p& q) i$ O //创建part
! N0 K1 D! @! T( G! \+ z) A UF_CALL(UF_PART_new("D:\\leaf.part", 1, &newPartTag));
% w% x( z& j( ^- L3 B% n! N0 l //创建圆柱% x- P6 L& r& ~* [1 P. Y7 c# @) R
UF_CALL(UF_MODL_create_cyl1(UF_NULLSIGN, cylOrigin, cylHeight, cylDiam, cylDirection, &cylTag));
! {6 r' T' U# K$ {9 J+ t$ a1 Z8 S //获取圆柱特征所在的体
7 D( {+ W% C) i, g @1 Y UF_CALL(UF_MODL_ask_feat_body(cylTag,&bodyTag));* e7 t+ C! c( Z. m8 ^
//获取体上的边
1 ]1 m5 g- z7 v' z uf_list_p_t edge_list ;* r+ T) h( u# j
UF_CALL(UF_MODL_ask_body_edges(bodyTag, &edge_list));) y0 I, \( N( s$ E. _
//得到边的数量5 f& O, u- t& S! [
int edgeCount = 0;
% T/ a& C. ^' k6 t' ` k# \, L6 k UF_CALL(UF_MODL_ask_list_count(edge_list, &edgeCount));0 \- A) z! _) _9 T
//打印边的数量
3 d6 |+ J; }/ i: t char cCount[256];3 R+ j0 q h% U0 ^+ p
sprintf_s(cCount, sizeof(cCount), "cylinder实体上的边的数量:%d", edgeCount);0 Z! O' s2 h) u# J9 w/ \1 g
uc1601(cCount, 1);
: I! n# l$ n: A - [3 S6 P" r) Z/ w0 _
int error;
# ^* a J) d7 W/ K$ Y" i double (*point_coords)[3];
5 [' }/ s8 K* d" G8 h point_coords= (double (*)[3]) UF_allocate_memory(edgeCount * sizeof(double [3]), &error );
# t' ]/ X& O5 {; I r8 ~& H/ M //获取圆柱的上两条边的圆心% P" ^ v) ` _! t0 G
int i = 0;, h( B" R1 j Y- a7 ?6 ]+ I
tag_t curveOriginTag = NULL_TAG;; p I5 f! W% F. I2 O
for (i; i < edgeCount; i++)6 l. U; z1 o$ W5 ]
{
' Z% c) E9 X8 |! d& F UF_CALL(UF_MODL_ask_list_item(edge_list, i, &curveOriginTag));
" A) N' T- e/ Z2 n5 q$ Y UF_CALL(UF_CURVE_ask_centroid(curveOriginTag, point_coords[i]));8 @6 C3 }1 E2 V! D P4 l! u% |% I
}( b' m. i* A4 Y9 z. q
//将圆心存放到直线起始点的链表中
3 K- d/ B: O& L: d) B U G, P UF_CURVE_line_p_t line_coords;0 B& [* _/ n# G7 ]+ P# t
line_coords= (UF_CURVE_line_p_t ) UF_allocate_memory(edgeCount * sizeof(double [3]), &error );& j0 d+ s5 W2 C
line_coords->start_point[0] = point_coords[0][0];
! I7 q3 e/ ?) J: O4 p. O5 J line_coords->start_point[1] = point_coords[0][1];
. I5 @2 R' h7 ^ line_coords->start_point[2] = point_coords[0][2];* M- x4 K+ y9 [8 X6 t2 f7 G
line_coords->end_point[0] = point_coords[1][0]; \6 N, z# L, g( i5 j% @3 N% ]
line_coords->end_point[1] = point_coords[1][1];
# p( |( E4 t5 f( Z8 M" L3 P line_coords->end_point[2] = point_coords[1][2];
" B: n6 @# W' i" v$ n/ P
) O- p+ J9 w* r! n tag_t lineTag = NULL_TAG;# i& k# e$ e' T5 ~& A- l
+ U! S# R0 }( m% S$ W" W s //创建直线
' T1 b) v" C/ H. X$ L @) H UF_CALL(UF_CURVE_create_line(line_coords, &lineTag));) j' ^- F; h5 u- I" q8 e
. Q \3 X; \3 v: O% Y$ }
//打印直线的端点3 B/ {1 p; w5 k9 H4 W
char msg[256];
, ?0 L; b( g7 \7 Q$ u' X5 m sprintf_s(msg, sizeof(msg), "创建的直线的起点是:%f、%f、%f,\n终点是:%f、%f、%f.",$ W y/ G: j6 I8 L* r, A8 B2 A8 k8 }
line_coords->start_point[0],3 R1 j1 p& K2 @
line_coords->start_point[1],
; J. I$ b/ p6 r/ m' h* d4 O line_coords->start_point[2],
- g6 N @9 z4 {: r* V$ P4 O line_coords->end_point[0],1 U; s# |+ P0 J7 q0 I! [! k
line_coords->end_point[1],6 z/ K$ t s; a
line_coords->end_point[2]);/ R, [0 k# w9 P; p8 L
UF_CALL(UF_UI_open_listing_window());) i& F7 v7 A0 w4 s2 S! E3 @
UF_CALL(UF_UI_write_listing_window(msg));8 ?1 K. ?8 i( V7 y
//UF_CALL(UF_UI_close_listing_window());
, W( S; v4 i9 n* Y% G
9 g* S6 ]/ f6 J1 _ //释放动态内存, h. z9 j# o. l5 p9 z1 F7 i8 S& y
UF_MODL_delete_list(&edge_list);, g* |" [4 Z# e) A
UF_free(point_coords);' o* R: x: `7 a0 d9 Y, y
UF_free(line_coords);1 B3 ]* c2 \7 Q3 D5 d
1 `. U0 s! o6 e4 W; t% B! N% m* g UF_PART_save();
1 f$ _+ ?# b- ] UF_PART_close_all(); |
评分
-
查看全部评分
|