|
leaf
发表于 2014-11-26 07:50:53
tag_t newPartTag = NULL_TAG;
: G( j) C* w4 a; Q$ ]4 d tag_t cylTag = NULL_TAG;
% m! Q# U9 ~4 d2 i: P t tag_t bodyTag = NULL_TAG;, ~) p# ~( @$ ~' t7 j( Q$ u
double cylOrigin[3] = {20, 30, 40};& V" ]+ J& G' F$ _0 A
char cylDiam[256] = "50";
* ~, s, N# h. l/ |$ W* F2 x! _ double cylDirection[3] = {0, 0 ,1};& s$ p6 I3 k, m* Z9 J* f/ \4 n, o6 M
double height = 60;
0 j# @5 x+ Y7 @/ r* H: o+ [# q / k0 }9 {5 @" p- D+ }8 U k
% I$ O4 F a/ Q3 M! a char cylHeight[256];% ], P* o) k$ Y
sprintf_s(cylHeight, sizeof(cylHeight), "%f", height);
7 R: e; G0 k3 Z* A' d //创建part
7 h% b; _% }9 \! t( r6 F UF_CALL(UF_PART_new("D:\\leaf.part", 1, &newPartTag));
/ L) Z0 J. }8 F1 Y //创建圆柱$ @# z6 b* [# s& H5 Q+ G2 q
UF_CALL(UF_MODL_create_cyl1(UF_NULLSIGN, cylOrigin, cylHeight, cylDiam, cylDirection, &cylTag));, W0 B+ w0 u# O% k$ v3 n
//获取圆柱特征所在的体1 @7 z% ?" C q% V# {
UF_CALL(UF_MODL_ask_feat_body(cylTag,&bodyTag));
/ V7 s2 Y6 @3 k3 l+ Q0 Q% a //获取体上的边9 L: E" B- U* E" U/ {4 l
uf_list_p_t edge_list ;
+ D! W7 Y. Y+ q UF_CALL(UF_MODL_ask_body_edges(bodyTag, &edge_list));
3 @6 e9 g+ e4 Z! s/ H* } X) {5 z //得到边的数量3 H" _- `$ @; c0 N3 W) I
int edgeCount = 0;
& W7 D H1 l l+ D+ D( V* c9 T UF_CALL(UF_MODL_ask_list_count(edge_list, &edgeCount));
6 d3 D4 v5 q1 Y' [* B' F //打印边的数量
+ j1 V7 `" m; R1 S+ q char cCount[256];0 I. |* P8 Q( t5 [4 [# c6 ?0 `! d4 e
sprintf_s(cCount, sizeof(cCount), "cylinder实体上的边的数量:%d", edgeCount);7 N0 X: M# p& l% B. o
uc1601(cCount, 1);" V- ~$ e: l" _. J' f
+ W7 m2 G! k- l( J
int error;5 k4 u+ U% G _: s& ?
double (*point_coords)[3];
0 c0 [7 Z, j- |6 l' U) V point_coords= (double (*)[3]) UF_allocate_memory(edgeCount * sizeof(double [3]), &error );- w7 P L% |9 b, S
//获取圆柱的上两条边的圆心8 Q' H( B e+ ]+ H- J, f
int i = 0;
, ?/ p8 `' x( b4 g" o- l/ n tag_t curveOriginTag = NULL_TAG;
$ M# r4 T) M* i9 v+ S* s for (i; i < edgeCount; i++)0 s) A' p2 _. ]& s+ s" T& P
{
0 f) y% _8 j1 W UF_CALL(UF_MODL_ask_list_item(edge_list, i, &curveOriginTag));6 T, L0 ^5 F0 r/ N% d# a
UF_CALL(UF_CURVE_ask_centroid(curveOriginTag, point_coords[i]));
. q2 Q: h- M2 z0 y' n }* d3 z+ I3 Q3 j) [. D
//将圆心存放到直线起始点的链表中# H2 f4 y6 ?4 ^: y
UF_CURVE_line_p_t line_coords;1 u! K" S1 C1 G
line_coords= (UF_CURVE_line_p_t ) UF_allocate_memory(edgeCount * sizeof(double [3]), &error );
. p2 [5 y* e+ }) \5 Z line_coords->start_point[0] = point_coords[0][0];
2 W2 e. G5 u, Q" j" m line_coords->start_point[1] = point_coords[0][1];; V/ y, ^7 t* Y1 S2 Y1 n+ g
line_coords->start_point[2] = point_coords[0][2];
( r4 a9 K* p* l. h4 u line_coords->end_point[0] = point_coords[1][0];9 \! L" {' T& }' E3 D
line_coords->end_point[1] = point_coords[1][1];3 ]" b1 |! l. X* C, E+ R$ u4 x& }* m
line_coords->end_point[2] = point_coords[1][2];
- |- d9 [1 z) J3 K! ]+ F x1 @" |, n5 @
tag_t lineTag = NULL_TAG;
3 F1 Q& q; A* J8 f& q
& ^& u. s8 l* j //创建直线
5 z$ a, A* K, @9 D UF_CALL(UF_CURVE_create_line(line_coords, &lineTag));
# t0 Y* p) T5 ?: V- @* Z4 G& j& _7 A6 r+ q" N
//打印直线的端点# i% w8 z0 b3 {; r
char msg[256];
5 }* t x4 x; ?4 E7 K sprintf_s(msg, sizeof(msg), "创建的直线的起点是:%f、%f、%f,\n终点是:%f、%f、%f.",
3 ]) c- p. Z& v; \7 s line_coords->start_point[0],& y1 v2 w4 J4 V' `( h6 B5 ?
line_coords->start_point[1],
8 l7 ?4 p1 p' r9 ^ line_coords->start_point[2],
. H% Y6 l+ V! t- |" Y# S line_coords->end_point[0],
! a" s6 S' W. j" V9 W4 Y3 H, F line_coords->end_point[1],
2 ]3 U( i: }) l: \ line_coords->end_point[2]);
% F8 f+ W; U% l+ a) ?5 U L4 c5 r UF_CALL(UF_UI_open_listing_window());' y$ o5 o- i' |& `( Q# W. Y! F. ]
UF_CALL(UF_UI_write_listing_window(msg));! U! G0 l4 i* q; z, D. G" y7 I
//UF_CALL(UF_UI_close_listing_window());
5 z# x: `" Y0 E1 X9 F
- d3 @ J/ i1 b6 m/ K8 s; g" e: y //释放动态内存
! `+ I9 O; B- c5 E3 y( l1 {4 f UF_MODL_delete_list(&edge_list);
% J2 h# Z# l1 S/ m; ] UF_free(point_coords);, O% y$ \: j/ d6 p/ u
UF_free(line_coords);
1 X, g9 \: O0 s( }5 J) m) _- a0 n2 h5 E& T! n2 L4 K
UF_PART_save();3 D/ }0 i- T0 l6 i
UF_PART_close_all(); |
评分
-
查看全部评分
|