|
|
leaf
发表于 2014-11-26 07:50:53
tag_t newPartTag = NULL_TAG;, N. u; L9 T: y
tag_t cylTag = NULL_TAG;
/ X9 m" d/ A* g( n tag_t bodyTag = NULL_TAG;
. q- K# o6 I8 h4 S& v8 m1 A- ^/ M double cylOrigin[3] = {20, 30, 40};* Y& E! C* \! S$ i0 \- l& b
char cylDiam[256] = "50";9 a# ]5 ^5 |6 T- h# q3 t9 O$ E
double cylDirection[3] = {0, 0 ,1};
- ^9 @0 e% h9 Q( i" _ double height = 60;4 b! H, E" g. }2 H; b6 o$ P
9 @' q" H+ @9 n/ R5 m. S. e% Y
- v, A& h' Q2 G* `& X
char cylHeight[256];
# d/ b' t n+ ~4 [ sprintf_s(cylHeight, sizeof(cylHeight), "%f", height);
2 I1 {& t$ f. ~% D' [ //创建part
& m# C8 e+ Q* Y9 t3 J) p0 d UF_CALL(UF_PART_new("D:\\leaf.part", 1, &newPartTag));% Y7 }9 q( i5 Q* w) P' B3 m
//创建圆柱2 [4 _. s3 ~. v$ G4 S; [" _: H
UF_CALL(UF_MODL_create_cyl1(UF_NULLSIGN, cylOrigin, cylHeight, cylDiam, cylDirection, &cylTag));0 k0 F$ q5 x% t# o) S2 s: @9 S4 o
//获取圆柱特征所在的体( B1 B- |- }; Y( `* w4 r
UF_CALL(UF_MODL_ask_feat_body(cylTag,&bodyTag));' I+ C/ T; ?9 U4 c* R( J) A9 ~
//获取体上的边
! J; q2 c% H( ?5 ` uf_list_p_t edge_list ;
8 S$ U- I% O: D) V! x UF_CALL(UF_MODL_ask_body_edges(bodyTag, &edge_list));
6 x, g3 w' F& Q- t; N* n9 n //得到边的数量
( p: s- a1 K* b+ d' I int edgeCount = 0;6 G I R& @0 X9 ^: U
UF_CALL(UF_MODL_ask_list_count(edge_list, &edgeCount));
) U6 A' }1 [: r //打印边的数量& i* c/ K& E/ {7 [# ?4 R6 l
char cCount[256];% |% ~7 m% ^8 u& ]: q
sprintf_s(cCount, sizeof(cCount), "cylinder实体上的边的数量:%d", edgeCount);4 \2 ^9 b2 {. O. z& h/ b$ @
uc1601(cCount, 1);6 M3 N, q) R3 J* y/ \
* n1 F8 n% ]! u( E2 j3 ~ int error;
v7 ?1 W) l9 z) e! c! ] double (*point_coords)[3];
- Z% M* H, Q; r8 u _8 v9 X* q" x point_coords= (double (*)[3]) UF_allocate_memory(edgeCount * sizeof(double [3]), &error );
* |* q3 F5 Q6 W0 j //获取圆柱的上两条边的圆心3 ^3 R# Z2 z" d A# e2 z
int i = 0;
3 q! Q: Z5 M5 [) T" M tag_t curveOriginTag = NULL_TAG;
: ^) F, O- m, B3 N for (i; i < edgeCount; i++)2 t4 Q; }/ F! u( ]2 y
{& F4 }4 s; z9 C v4 l2 N7 t
UF_CALL(UF_MODL_ask_list_item(edge_list, i, &curveOriginTag));- N# t* `6 S9 w0 i& \7 T+ h
UF_CALL(UF_CURVE_ask_centroid(curveOriginTag, point_coords[i]));2 v; S* W# p: D6 m& x
}8 Q0 I* D% q) C
//将圆心存放到直线起始点的链表中, R6 @8 A- m( q" Z! X: Y
UF_CURVE_line_p_t line_coords;
* ?" B$ ], Q) P) C4 N line_coords= (UF_CURVE_line_p_t ) UF_allocate_memory(edgeCount * sizeof(double [3]), &error );: L( R6 g9 y; d9 V+ E3 J
line_coords->start_point[0] = point_coords[0][0];
; U, D# {. V/ f0 k5 b line_coords->start_point[1] = point_coords[0][1];; J# o, ^4 |9 E
line_coords->start_point[2] = point_coords[0][2];9 R) E& G! c9 z7 E; ?) ]
line_coords->end_point[0] = point_coords[1][0];0 |* r* E% M0 p/ o
line_coords->end_point[1] = point_coords[1][1];: G# o5 K! S+ f! t
line_coords->end_point[2] = point_coords[1][2]; S+ I$ [; n: o7 j+ @8 F
( O! L" ]8 A* x9 ]; B5 o/ ^ tag_t lineTag = NULL_TAG;9 H- T$ C. G5 S
( p2 D3 }. `8 ?2 v9 C# d c
//创建直线% ]7 p$ _8 c; F7 X V; \, j
UF_CALL(UF_CURVE_create_line(line_coords, &lineTag));
9 X2 j5 ?8 @8 ~6 m# q
0 T+ Y- ^3 A1 k9 o+ A //打印直线的端点
, G4 }' Z, R9 p7 d1 c" Z8 V: I char msg[256];
3 v" c9 g% }; l6 |# z6 d$ U sprintf_s(msg, sizeof(msg), "创建的直线的起点是:%f、%f、%f,\n终点是:%f、%f、%f.",
6 H Y$ n( u* Z line_coords->start_point[0],
( x9 e. A! ^7 l% Q# {! d line_coords->start_point[1],) Z2 r3 Z; A% Z" H1 n
line_coords->start_point[2],$ X1 P3 m" H$ w
line_coords->end_point[0],; }4 B' j% A" U9 J) S
line_coords->end_point[1],
1 S. P) j. p! h line_coords->end_point[2]);$ \( a) _1 A: A' Q" j4 j- l
UF_CALL(UF_UI_open_listing_window());
8 j3 \8 ]+ U1 t% R4 r/ c UF_CALL(UF_UI_write_listing_window(msg));
9 a+ l% f8 g9 R. }% t6 @$ C //UF_CALL(UF_UI_close_listing_window());
2 o+ U: Y% @/ N7 k4 G$ a5 ?
2 A( D' U2 ~$ ? //释放动态内存( g+ F! s" `' {1 L6 y
UF_MODL_delete_list(&edge_list);
# w" H4 C3 Y1 l& L UF_free(point_coords);6 [7 U/ s4 p8 p3 [$ _
UF_free(line_coords);
" x4 j9 |- C" Z7 D; {+ \# c& x
3 F0 q5 K0 W+ Z4 h6 m+ v( G UF_PART_save();
9 O ~& Z5 [$ |" h2 x/ t UF_PART_close_all(); |
评分
-
查看全部评分
|