|
leaf
发表于 2014-11-26 07:50:53
tag_t newPartTag = NULL_TAG;: n9 x1 r" {- [/ b' Z# V
tag_t cylTag = NULL_TAG;" p3 `* O9 d$ {3 n5 {. J$ x5 G
tag_t bodyTag = NULL_TAG;
0 B. |1 B0 _' h double cylOrigin[3] = {20, 30, 40};' U6 H7 h& Q- E7 _% X
char cylDiam[256] = "50";
* q' v* A" P' c: p6 q( N double cylDirection[3] = {0, 0 ,1};" K' N- p5 f/ k( l7 Q2 M2 N; ^6 K; _
double height = 60;
. ^! n5 @# P. m ?3 g: @* M" o0 j0 h l/ j1 w o8 b
6 j N9 x2 b0 y/ G# z
char cylHeight[256];1 L7 n' V+ s6 R5 V0 R
sprintf_s(cylHeight, sizeof(cylHeight), "%f", height);
4 X5 q8 A- N* ~6 I# k9 q //创建part% W2 r' i& \0 q
UF_CALL(UF_PART_new("D:\\leaf.part", 1, &newPartTag));
, G. Z7 Y1 v% k, E& _0 M9 ] //创建圆柱
/ M) H5 P! P U% t" @# F UF_CALL(UF_MODL_create_cyl1(UF_NULLSIGN, cylOrigin, cylHeight, cylDiam, cylDirection, &cylTag));
' i2 ]3 f; }( c% U$ J# G //获取圆柱特征所在的体0 |9 H+ A* Z9 I7 y' P
UF_CALL(UF_MODL_ask_feat_body(cylTag,&bodyTag));
3 o5 `1 m# k3 `+ M7 l0 e* N //获取体上的边
9 [( h; ~7 n2 }+ l uf_list_p_t edge_list ;
6 ^2 d7 K- _1 R. _# T2 B: J/ V: X UF_CALL(UF_MODL_ask_body_edges(bodyTag, &edge_list));' y5 Q% _- L; @
//得到边的数量
5 k$ V2 I0 l A$ o/ G5 y" k int edgeCount = 0;
# y. G$ {8 q' t2 s UF_CALL(UF_MODL_ask_list_count(edge_list, &edgeCount));
! f' r' ?" B- @ {4 v9 Z; V5 h //打印边的数量* `" D3 K! A( {( P3 g
char cCount[256];
" E6 s/ d! b5 C/ q+ U* I! e$ Q$ T t sprintf_s(cCount, sizeof(cCount), "cylinder实体上的边的数量:%d", edgeCount);
/ ~* h* l# b+ k( M uc1601(cCount, 1);( ~; \; D4 T: F
% {, D- p8 z, D& @# D int error;# i5 S% k$ L$ {5 t2 l1 P. r
double (*point_coords)[3];
# B/ { o8 L4 j6 s( R* p point_coords= (double (*)[3]) UF_allocate_memory(edgeCount * sizeof(double [3]), &error );# D; L+ K' p- O% Q: F' f. W% _- {
//获取圆柱的上两条边的圆心
8 e1 y+ A0 y8 N+ Q3 s. G int i = 0;& f! M r. J/ J$ L5 ?& T3 X/ T
tag_t curveOriginTag = NULL_TAG;( N8 _; ]. e4 U
for (i; i < edgeCount; i++)
/ d2 ?1 p6 Q m O2 X& v: a {
5 M V5 O* N- P& F$ W: x9 Y, x UF_CALL(UF_MODL_ask_list_item(edge_list, i, &curveOriginTag));
+ Q- Q2 a: v5 d( [3 R UF_CALL(UF_CURVE_ask_centroid(curveOriginTag, point_coords[i]));/ P$ A4 [3 g3 E( B6 U
}
, R+ L" l, I$ m6 A1 x6 ?' r8 a# S" F4 k //将圆心存放到直线起始点的链表中5 P" O4 \5 ~# ]+ [ w, a$ F5 _3 \
UF_CURVE_line_p_t line_coords;
9 M; O0 X; y) g line_coords= (UF_CURVE_line_p_t ) UF_allocate_memory(edgeCount * sizeof(double [3]), &error );
; Q9 g4 E8 y, ^9 a line_coords->start_point[0] = point_coords[0][0];
' c) p9 c1 J t# [4 i* [ line_coords->start_point[1] = point_coords[0][1];
1 ?) m: Q/ N1 ]# b line_coords->start_point[2] = point_coords[0][2];
* \0 B$ \8 ?8 _8 P line_coords->end_point[0] = point_coords[1][0];
g6 O1 r& `6 [4 T line_coords->end_point[1] = point_coords[1][1];( U/ `/ Y8 j2 q
line_coords->end_point[2] = point_coords[1][2];
5 ~2 W; U8 [! l( t; p, G! b
0 z) f. ~2 z7 T& ~8 i. A- a tag_t lineTag = NULL_TAG;
, X( ^+ O- i6 W- v+ @: n ' @8 U) X8 J. O: Y+ b g! f
//创建直线" \0 {% n9 r# G* B
UF_CALL(UF_CURVE_create_line(line_coords, &lineTag));% P! W% V: ^" Q. l3 D9 N/ L
! k( ?6 z2 [6 h
//打印直线的端点
. _0 ~- e/ R. z. C% n7 J char msg[256];8 i; E/ E: S0 N' \/ F
sprintf_s(msg, sizeof(msg), "创建的直线的起点是:%f、%f、%f,\n终点是:%f、%f、%f.",
! T- J: x5 [) Y5 \+ W line_coords->start_point[0],/ f% Z, c' f3 s4 B* O$ O2 g
line_coords->start_point[1],
; I3 g( a3 U0 {1 V# u line_coords->start_point[2],
! {0 S& Y6 W/ P/ e line_coords->end_point[0],
( a, b7 U5 Z y7 ~' M, `' n" H0 n4 D line_coords->end_point[1],& q+ y7 M' [5 b
line_coords->end_point[2]);* L: |4 M8 v6 i4 e A0 A# A7 s
UF_CALL(UF_UI_open_listing_window());4 D6 R& `! y- |
UF_CALL(UF_UI_write_listing_window(msg));
- ]& h) W t, j //UF_CALL(UF_UI_close_listing_window());
7 o& g% _. _) E$ U8 R1 D
P- w5 ^4 F+ S+ Z7 a) I2 k7 }0 L //释放动态内存
4 z) N: h( m- j/ J) n UF_MODL_delete_list(&edge_list);/ B* H2 g* S$ i& y$ E$ u
UF_free(point_coords);0 z$ s. H/ x$ h
UF_free(line_coords);) [# j. k7 K& L6 ]. @
7 p) O) L/ f, X4 v& N Z& f
UF_PART_save();
" p; Y! D. C7 g$ u. I; E. Y UF_PART_close_all(); |
评分
-
查看全部评分
|