|
leaf
发表于 2014-11-26 07:50:53
tag_t newPartTag = NULL_TAG;
, Q4 {, ~8 D# }2 D% d/ F tag_t cylTag = NULL_TAG;
1 ?; M! V! W" x; w, m tag_t bodyTag = NULL_TAG;% |# O; P {# z
double cylOrigin[3] = {20, 30, 40};
: H" v+ g# q$ m" p- z$ W9 m char cylDiam[256] = "50";
6 R. D: I" r0 M) \$ ~# u2 v double cylDirection[3] = {0, 0 ,1};
% c& }$ O* r3 m double height = 60;
# b/ ~6 J$ e8 M. f* F- Q5 M- @ 3 ~( R5 V* I" h4 r' I5 b. x
. m# J, J, h; b7 R8 n2 x char cylHeight[256];
9 Y6 g% }2 y( T8 {/ }: d( V sprintf_s(cylHeight, sizeof(cylHeight), "%f", height);2 m6 i, N% y! p$ S4 Z) \: a4 M
//创建part- S! c9 p4 e! e9 S8 J. R y
UF_CALL(UF_PART_new("D:\\leaf.part", 1, &newPartTag));$ z8 p& C9 e- j! @: x
//创建圆柱' V* B% |. i0 u) W6 ~
UF_CALL(UF_MODL_create_cyl1(UF_NULLSIGN, cylOrigin, cylHeight, cylDiam, cylDirection, &cylTag));( |4 X$ Y: L: |, u' r
//获取圆柱特征所在的体
5 }9 P$ r0 w+ i1 D S UF_CALL(UF_MODL_ask_feat_body(cylTag,&bodyTag));. a" j& O1 f, Y$ | A
//获取体上的边
( Y" I; S) z# o6 \2 p uf_list_p_t edge_list ;) ^! K. L) {1 g, B) J
UF_CALL(UF_MODL_ask_body_edges(bodyTag, &edge_list));* ]4 d: S5 T( Z+ { J- i
//得到边的数量4 S. `8 B$ e- Y
int edgeCount = 0;
) u9 Z8 C3 i+ a. ? UF_CALL(UF_MODL_ask_list_count(edge_list, &edgeCount));
# v) l6 y7 w* U1 [# V, F //打印边的数量" D" R0 @1 U* f, ?
char cCount[256];# `$ J1 V G& Y1 W
sprintf_s(cCount, sizeof(cCount), "cylinder实体上的边的数量:%d", edgeCount);
( | S. m) a! _, U" x uc1601(cCount, 1);; A4 c2 _( J8 x* g; a& K
* b6 |! b4 d3 o& J) Y
int error;
9 Y8 a2 U) N2 q double (*point_coords)[3];
- ^+ |5 B! m1 _& ` point_coords= (double (*)[3]) UF_allocate_memory(edgeCount * sizeof(double [3]), &error );
5 B; f. a- v. [" Y) W //获取圆柱的上两条边的圆心
" i" u( p1 B* O7 T2 H int i = 0; b' {4 e/ Z7 F( c1 D
tag_t curveOriginTag = NULL_TAG;
$ X4 j- Z+ D2 w w1 C for (i; i < edgeCount; i++)
3 I" z. m# v4 @5 ^3 B1 r {
7 z3 f! ~8 c! }' I UF_CALL(UF_MODL_ask_list_item(edge_list, i, &curveOriginTag));
f! I2 s$ [: F6 r" l: d' D UF_CALL(UF_CURVE_ask_centroid(curveOriginTag, point_coords[i]));
4 u @. r. B! c5 a( P/ g }
$ z# j7 y" Q& V* @- j W1 U+ H$ u x6 @ //将圆心存放到直线起始点的链表中
7 N0 Z( P+ c( Z+ g UF_CURVE_line_p_t line_coords;$ o2 C0 N) S& @: ]
line_coords= (UF_CURVE_line_p_t ) UF_allocate_memory(edgeCount * sizeof(double [3]), &error );8 z9 ^! N# H* o9 a" p/ Z. ^* ~
line_coords->start_point[0] = point_coords[0][0];
9 }. f$ D0 _% M line_coords->start_point[1] = point_coords[0][1];6 P/ z) L: q: t. p }% x4 m
line_coords->start_point[2] = point_coords[0][2];! t! I g, R: `" p' H) n& q
line_coords->end_point[0] = point_coords[1][0];$ f6 {* n, M* B9 T6 a3 M; `2 X. T
line_coords->end_point[1] = point_coords[1][1];
6 {, [$ o6 f% m2 @9 I3 B line_coords->end_point[2] = point_coords[1][2];
4 J5 I3 y- x+ S! X9 d |6 h$ }$ j5 ^; T, F# l
tag_t lineTag = NULL_TAG;
, z% F( f" `# N+ }
+ B' _" P; T- f! T) A2 K //创建直线$ ^* |7 Z5 G {! X% n
UF_CALL(UF_CURVE_create_line(line_coords, &lineTag));+ o+ p2 w, N& g9 r9 ?. v. `
" V2 E' _% J$ { //打印直线的端点
& `: n& J' Y6 e2 p. L) h char msg[256];; ~1 R- L+ G7 ?$ ^1 t, g! d
sprintf_s(msg, sizeof(msg), "创建的直线的起点是:%f、%f、%f,\n终点是:%f、%f、%f.",7 W, e6 \% i: `4 d# ^. }
line_coords->start_point[0],) U5 [0 k1 F7 i: L3 `
line_coords->start_point[1],
( F+ R" e2 j" i line_coords->start_point[2],4 r# T5 m: i. N4 }4 |
line_coords->end_point[0],0 f3 R- g+ h3 q F, K! Y1 @
line_coords->end_point[1],) u) k2 f1 J1 ^; l$ [% C4 q
line_coords->end_point[2]);& e7 P" E! l* s: ]6 D* t
UF_CALL(UF_UI_open_listing_window());
: S$ X& y2 a" l- o! d UF_CALL(UF_UI_write_listing_window(msg)); b+ F+ Y: @& m! |/ c
//UF_CALL(UF_UI_close_listing_window());' q4 h, \5 ~+ u: J6 g
! K/ s* M# `0 d# w //释放动态内存
3 I, W) u* ~4 H4 f1 Y; _ }& | UF_MODL_delete_list(&edge_list);
. F& `: ?5 X- [0 H/ b# T UF_free(point_coords);+ X4 k6 O: k! U) Y
UF_free(line_coords);. \1 M7 G m8 j2 Z6 I
3 g3 Q8 @$ }' W" ]& f* i UF_PART_save();
. [" G1 b; N9 S6 w- b UF_PART_close_all(); |
评分
-
查看全部评分
|