|
|
leaf
发表于 2014-11-26 07:50:53
tag_t newPartTag = NULL_TAG;
1 a' _) z+ r# [7 G# y tag_t cylTag = NULL_TAG;
# K& E2 j; C8 u( @% B9 V* O tag_t bodyTag = NULL_TAG;0 z1 `6 W7 S" X: E$ l* k- G
double cylOrigin[3] = {20, 30, 40};
, o8 w& f% ~3 X0 B; E% ?$ X5 T char cylDiam[256] = "50";! g# h5 ^ T6 C- D
double cylDirection[3] = {0, 0 ,1};
! I7 v9 b, C- e; p# g6 e0 }& X double height = 60;
+ h& l$ j* h! ~4 N- N
; x7 {3 u4 r" T
" s1 e: e5 h; Y; ^' q$ ~ char cylHeight[256];
: z5 _7 x4 u5 ^; m( p0 k sprintf_s(cylHeight, sizeof(cylHeight), "%f", height);) s! w- j: G- e* x! L# Y3 ]1 y
//创建part! e/ V" M" E/ b* n) H
UF_CALL(UF_PART_new("D:\\leaf.part", 1, &newPartTag));- X) s' I$ X6 i* Z' Y
//创建圆柱
4 b2 ~! t' m( p9 X; {8 D UF_CALL(UF_MODL_create_cyl1(UF_NULLSIGN, cylOrigin, cylHeight, cylDiam, cylDirection, &cylTag));
6 i1 }. W2 ^1 [9 Z, G+ E K //获取圆柱特征所在的体
1 X$ G1 x$ K; @4 o4 a" L UF_CALL(UF_MODL_ask_feat_body(cylTag,&bodyTag));
/ h* b) j* S! ]# e2 |5 r+ j6 L //获取体上的边
' C7 m1 [* K( p1 R uf_list_p_t edge_list ;' I$ f7 R: c( E' {+ }6 C$ O: Q
UF_CALL(UF_MODL_ask_body_edges(bodyTag, &edge_list));
! ?0 J5 W# t5 o7 e4 T x( T' a //得到边的数量: m# ~7 q* E* E
int edgeCount = 0;/ V2 G; w! u2 Q$ c2 g: d+ T/ Q$ L7 k8 o
UF_CALL(UF_MODL_ask_list_count(edge_list, &edgeCount));
}- `* d% m, w //打印边的数量
. v- c$ o, d! w9 R. C2 C/ ^! X char cCount[256];
4 v. `9 Q% L8 s! J' Q- o sprintf_s(cCount, sizeof(cCount), "cylinder实体上的边的数量:%d", edgeCount);0 A6 Y- q& E, K! s, m
uc1601(cCount, 1);7 b- a9 O: [3 B s
`" ?3 k: C2 k" F int error;
8 n5 h/ q4 @# U double (*point_coords)[3];
# c$ ?+ [: k* b point_coords= (double (*)[3]) UF_allocate_memory(edgeCount * sizeof(double [3]), &error );
+ r$ z/ q7 p6 @8 H/ x* }3 ?! ] //获取圆柱的上两条边的圆心- Z$ _- S0 ^; b$ q+ a7 L2 Q
int i = 0;
! o& A) |7 y" k tag_t curveOriginTag = NULL_TAG;
; I4 ^8 p% [' k( f% r) G3 L8 r for (i; i < edgeCount; i++)- U7 ~- m/ H. w* e7 \/ @0 `
{ [0 C! N) _1 \& H6 C/ S
UF_CALL(UF_MODL_ask_list_item(edge_list, i, &curveOriginTag));' W" a3 D3 ^2 ]' l$ {; h7 p6 J! ~ n
UF_CALL(UF_CURVE_ask_centroid(curveOriginTag, point_coords[i]));
& Q! u" f; R8 b4 w' G; q( G }
8 r% ^1 f/ i. m% |( } //将圆心存放到直线起始点的链表中, E7 [9 |7 Y; n) i7 \$ g
UF_CURVE_line_p_t line_coords;& J: [6 B7 d6 G
line_coords= (UF_CURVE_line_p_t ) UF_allocate_memory(edgeCount * sizeof(double [3]), &error );
* c3 W$ e) v8 E) t4 h line_coords->start_point[0] = point_coords[0][0];
5 L; ~2 E# E, [1 ` line_coords->start_point[1] = point_coords[0][1];
, g3 b) L2 v' r& q: q0 | line_coords->start_point[2] = point_coords[0][2];. q* ^1 c* {/ u( i) M4 Z8 `
line_coords->end_point[0] = point_coords[1][0];3 p4 H( f! |9 A& N% Z
line_coords->end_point[1] = point_coords[1][1];
) u) l- {9 D7 \. O# Z line_coords->end_point[2] = point_coords[1][2];5 M. o0 L, c+ w* `
0 _. U ^, P2 M& R4 V" C1 Y& W tag_t lineTag = NULL_TAG;
6 W( P! N0 i; A9 h2 c8 l' q
# X0 x4 c5 }) Z) M- G T; q //创建直线' Z F5 J; |6 w% i
UF_CALL(UF_CURVE_create_line(line_coords, &lineTag));
% A# u! v" |+ x! \) e X8 n5 s9 V( g+ y
//打印直线的端点
* ]" F. a9 Q, Y8 o" i& ^ char msg[256];
- n. c0 |5 \2 R0 z! r# L } c" n% e' \ sprintf_s(msg, sizeof(msg), "创建的直线的起点是:%f、%f、%f,\n终点是:%f、%f、%f.",
: ^, c2 l% z# }4 e& A5 p line_coords->start_point[0]," |; ~* c$ b5 f: s% r% W3 a! `7 }8 n
line_coords->start_point[1],
, p7 K8 e+ V! d! J) x line_coords->start_point[2],
5 O1 G S; J9 _9 s; w line_coords->end_point[0],$ R+ e1 ?1 x2 v3 E( J
line_coords->end_point[1],
/ v1 t3 y% Z+ D- K2 [. \ line_coords->end_point[2]);
5 {# e( i- j* ^7 r* n" y UF_CALL(UF_UI_open_listing_window());' q$ Y2 J4 w, A( n9 X. e5 |5 [
UF_CALL(UF_UI_write_listing_window(msg));
3 k6 l y8 ?) e2 h" S //UF_CALL(UF_UI_close_listing_window());9 S+ {& n- _7 b7 m, E1 z, {
6 O$ e3 R. A8 f: Y( z# ? //释放动态内存& W2 g2 Y0 a8 A3 |
UF_MODL_delete_list(&edge_list);
6 S7 t% p8 _3 M m4 ^. f* Y; p8 { UF_free(point_coords);* b* L$ k- B) r8 v
UF_free(line_coords);
2 s- O+ O7 a& T* V8 t9 [# W9 Y& C, y
UF_PART_save();
f2 l5 C# D5 l( m' ?. n: ~ UF_PART_close_all(); |
评分
-
查看全部评分
|