|
|
leaf
发表于 2014-11-26 07:50:53
tag_t newPartTag = NULL_TAG;
/ I! Y% M6 @( D2 W, Z# d tag_t cylTag = NULL_TAG;' l4 ? n: A$ @
tag_t bodyTag = NULL_TAG;
& h# A; P" T: N% v1 M$ x! x double cylOrigin[3] = {20, 30, 40};
/ R |1 G- c# P" c6 R char cylDiam[256] = "50";
7 B1 p, s1 w1 K double cylDirection[3] = {0, 0 ,1};
9 A% n$ \8 i0 X5 X7 ` double height = 60;# Z3 B& `0 Z4 R& ?3 m: `+ [
+ u! W) w3 K4 y' _
8 R. u6 N2 |% ], f) h% {6 Z
char cylHeight[256];
- p4 P/ x1 [1 L! }, n9 h$ R5 n sprintf_s(cylHeight, sizeof(cylHeight), "%f", height);
: ~/ s1 I' Y; |" |* d //创建part
$ z, r; a7 h0 C$ s2 Q) K( s$ p8 M UF_CALL(UF_PART_new("D:\\leaf.part", 1, &newPartTag));
$ [. b* P7 F }, C5 Q A //创建圆柱* L4 q) m; P$ m, H: q5 T- h
UF_CALL(UF_MODL_create_cyl1(UF_NULLSIGN, cylOrigin, cylHeight, cylDiam, cylDirection, &cylTag));
, B1 d. W2 u# ? //获取圆柱特征所在的体% a/ J: m8 X* }% @0 z3 `" l$ M
UF_CALL(UF_MODL_ask_feat_body(cylTag,&bodyTag));* Y2 A$ t/ }. f( R. s
//获取体上的边
+ r7 Z. S0 p0 ^4 L uf_list_p_t edge_list ;
# n6 o" a4 G% c# p7 B* H* b UF_CALL(UF_MODL_ask_body_edges(bodyTag, &edge_list));
' X3 u5 f! u% C+ v4 |9 N% X //得到边的数量' q4 T( Q' {; f; l1 c2 B
int edgeCount = 0;
* {1 Y' G; W1 O c S/ U0 u: Z: ?9 Y* O UF_CALL(UF_MODL_ask_list_count(edge_list, &edgeCount));
, p# c, _) K; K, X" h. u //打印边的数量
0 i' I+ E# C, {, ^* X char cCount[256];
. [, K A/ B& {9 q Y sprintf_s(cCount, sizeof(cCount), "cylinder实体上的边的数量:%d", edgeCount);0 ]* N* Q& m* X- h G
uc1601(cCount, 1);$ z. s9 R0 l8 Q" [( g2 h7 L( |
# ^. H* I* }8 }( f, s. q int error;, ?' P* Y% w5 W9 F2 W' q/ h( {
double (*point_coords)[3];- K; H: `* Q" u# e
point_coords= (double (*)[3]) UF_allocate_memory(edgeCount * sizeof(double [3]), &error );4 o! r- B* y. X6 q6 M
//获取圆柱的上两条边的圆心
N* Q$ Q8 _/ Q" i. A: G \6 J int i = 0;
! q9 V9 q+ g; b& O) y% l tag_t curveOriginTag = NULL_TAG;
1 e2 ~+ Z: k! w y/ w for (i; i < edgeCount; i++)
2 Q% J4 N) X: W, r, { {
: P& I+ k3 Y! Q" s+ |0 b UF_CALL(UF_MODL_ask_list_item(edge_list, i, &curveOriginTag));2 D* h% R' |8 f
UF_CALL(UF_CURVE_ask_centroid(curveOriginTag, point_coords[i]));, [$ i( i, J( ?4 q" |& c ]& f. ]
}/ m4 f, d4 U- p% C3 e$ M t
//将圆心存放到直线起始点的链表中
8 J6 T" _, F R2 e UF_CURVE_line_p_t line_coords;7 C( j. l* [! w5 x; j3 a8 P0 |
line_coords= (UF_CURVE_line_p_t ) UF_allocate_memory(edgeCount * sizeof(double [3]), &error );% c2 Q, h, ^( m) M/ ^0 ?
line_coords->start_point[0] = point_coords[0][0];
1 J9 R$ V' a+ p" t% q+ v line_coords->start_point[1] = point_coords[0][1];" }" d- |. d$ y% W P( b
line_coords->start_point[2] = point_coords[0][2];
2 l8 T* G# y9 W line_coords->end_point[0] = point_coords[1][0];! L! n; e3 j; H
line_coords->end_point[1] = point_coords[1][1];! \! t4 L H+ B, h
line_coords->end_point[2] = point_coords[1][2];8 I O! }) M+ P% a8 D1 _7 r& s: R( S
9 \9 ~' ?9 [, y* L9 z3 u
tag_t lineTag = NULL_TAG;
1 u: v5 I3 n. W ?, u( [" x * J3 f! V& ^% Z& O! v8 V& E1 Y
//创建直线
- A) e1 a# R+ C5 x- R; u1 o UF_CALL(UF_CURVE_create_line(line_coords, &lineTag));, N: U) m# Q3 \0 Z) J
6 M2 w" [# t7 T) Y
//打印直线的端点
4 G5 G) N5 f: E5 G+ s char msg[256];
: [6 ^9 M: ]; n# V' n' `7 Q sprintf_s(msg, sizeof(msg), "创建的直线的起点是:%f、%f、%f,\n终点是:%f、%f、%f.",$ m7 Q) _$ x' Q7 w) v
line_coords->start_point[0],
7 @# J% ?7 Z, T line_coords->start_point[1],+ ?/ F+ X; H7 L" j+ I% f
line_coords->start_point[2],+ b: F O8 l, f1 z* K; T
line_coords->end_point[0],
( x/ K# g7 D9 {( j( m line_coords->end_point[1],
% R; c3 D4 y9 h3 O2 T line_coords->end_point[2]);
6 d. d$ h% T. _7 t6 z$ J. D5 m: V UF_CALL(UF_UI_open_listing_window());
3 H6 f# s# Q: R% p UF_CALL(UF_UI_write_listing_window(msg));
0 d% d4 ]' T$ o$ j //UF_CALL(UF_UI_close_listing_window());
- i4 P7 U: z0 I+ a9 g9 h5 c" O+ Y2 Q* l& Q; T( |. E
//释放动态内存) I/ M8 M, K) x6 i( w
UF_MODL_delete_list(&edge_list);; K0 |+ p$ P& N# p- x! ^8 C* F( H
UF_free(point_coords);
" f) @" X5 c1 H- G6 A, Y: w7 U UF_free(line_coords);
* W6 m$ w# V+ n6 `, o6 p% }
: L/ ^' C l4 Z. N% ~0 a$ K UF_PART_save(); y5 T: i B9 [* X) z
UF_PART_close_all(); |
评分
-
查看全部评分
|