|
|
leaf
发表于 2014-11-26 07:50:53
tag_t newPartTag = NULL_TAG;
+ y, c( u- ~$ ~ tag_t cylTag = NULL_TAG;5 c f2 C: d: b0 M, A; k
tag_t bodyTag = NULL_TAG;
( ~0 b% g. c+ H2 w- i- q, I double cylOrigin[3] = {20, 30, 40};
; I' G& P. |. j7 h; p char cylDiam[256] = "50";0 n: {0 Q& R' y% H& D6 q! E s
double cylDirection[3] = {0, 0 ,1};: R! u1 r' B8 p0 }. g, E, ]; ?
double height = 60;& U; l( P, P6 e4 A; D- s1 o
) `- i# v/ c/ O" n% J6 }: u* l
( V o, d3 C! y3 B" i9 x' o char cylHeight[256];" F7 Q4 i- h2 ]4 t. o
sprintf_s(cylHeight, sizeof(cylHeight), "%f", height);! x6 a5 l7 E' Q2 z# o0 c( M+ W- I
//创建part
' f0 t" M0 b7 P UF_CALL(UF_PART_new("D:\\leaf.part", 1, &newPartTag)); q! I& T3 I' t1 e% O% J
//创建圆柱" e$ C! E6 b2 f( h! Z; g6 u
UF_CALL(UF_MODL_create_cyl1(UF_NULLSIGN, cylOrigin, cylHeight, cylDiam, cylDirection, &cylTag));6 J3 e; [& L; A5 I; d, ~/ o
//获取圆柱特征所在的体; {: s0 V+ r4 \+ w2 `/ S8 f8 d+ ?$ f3 ^
UF_CALL(UF_MODL_ask_feat_body(cylTag,&bodyTag));
8 V6 Z5 R3 K. ] //获取体上的边* a4 U1 [6 Z! P
uf_list_p_t edge_list ;
' v, N! n- j" w) E UF_CALL(UF_MODL_ask_body_edges(bodyTag, &edge_list));9 R. u+ J# g6 _. l1 W2 |9 F
//得到边的数量
( _- B! @" P5 [2 L4 m1 Z int edgeCount = 0;
1 W: r: G/ b! |& M5 B! K UF_CALL(UF_MODL_ask_list_count(edge_list, &edgeCount));2 O1 q Q( n! C" x% C7 t4 N
//打印边的数量6 z# {) D: v6 L$ m% e1 N
char cCount[256];
! k" ?0 L+ {8 b8 E; c" ` sprintf_s(cCount, sizeof(cCount), "cylinder实体上的边的数量:%d", edgeCount);
' N0 w" G4 B) f5 O; c7 W8 a& ? uc1601(cCount, 1);
8 G" C/ O4 w6 S) ?2 B) W - _* c# r7 L( U0 l# T
int error;
; I) {# S' a) [$ z* c, z/ w. `: c6 z double (*point_coords)[3];! F- W$ y; b- @, j h8 [9 d
point_coords= (double (*)[3]) UF_allocate_memory(edgeCount * sizeof(double [3]), &error );
. V3 g! N$ G7 U5 w! @0 e //获取圆柱的上两条边的圆心' }4 s7 m, H( e4 N* B
int i = 0;
6 g+ t7 x) j0 { tag_t curveOriginTag = NULL_TAG;3 u5 t! G' S: Z2 j
for (i; i < edgeCount; i++)
# V6 \0 R5 r+ E" p {
( h. ?5 j& U7 V5 P' p3 v UF_CALL(UF_MODL_ask_list_item(edge_list, i, &curveOriginTag));
" f% j. m; w5 M+ y1 D UF_CALL(UF_CURVE_ask_centroid(curveOriginTag, point_coords[i]));$ o, b/ C, X0 l/ ^
}6 q7 h5 w) s! J4 a) `, q" @6 @/ d
//将圆心存放到直线起始点的链表中, ~! Q( e8 e6 ^2 m3 E0 \
UF_CURVE_line_p_t line_coords;; e* Y L ^8 E! f. N! w
line_coords= (UF_CURVE_line_p_t ) UF_allocate_memory(edgeCount * sizeof(double [3]), &error );
: B# h* c2 F3 n7 F+ j# f line_coords->start_point[0] = point_coords[0][0];4 K" [5 N: d( F) U% i: H
line_coords->start_point[1] = point_coords[0][1];
w2 }& @3 l- [1 Y# Y* L line_coords->start_point[2] = point_coords[0][2];- z5 j& Z2 u* ^7 r
line_coords->end_point[0] = point_coords[1][0];
/ U3 i% Z8 Q' W. l0 B: U% i* p' j line_coords->end_point[1] = point_coords[1][1];& l) A! ~; Q" C% h4 Y
line_coords->end_point[2] = point_coords[1][2];2 H7 n( M* x' _$ f5 z
. w9 x `1 c t! ]( F tag_t lineTag = NULL_TAG;
+ Z, u8 T i! ^. t# a, B0 p5 M 5 d4 Z5 Y; n8 e: J
//创建直线6 r$ n; U! O3 q
UF_CALL(UF_CURVE_create_line(line_coords, &lineTag));
, c. A+ O) ~% w L. Z& H1 a$ ^- P
//打印直线的端点9 B% W! B" f. d8 w
char msg[256];
, a1 n. j0 { I8 Z; ^0 S! ` sprintf_s(msg, sizeof(msg), "创建的直线的起点是:%f、%f、%f,\n终点是:%f、%f、%f.",
* d0 Q: @+ h9 F8 ^5 B: s1 \: { line_coords->start_point[0],
, B4 R7 A6 f" j) s( w& | line_coords->start_point[1],/ W* d8 q1 |3 T' [( v* r9 B
line_coords->start_point[2],9 [& {5 y0 B, p( X
line_coords->end_point[0],; e5 n* k0 |% L% ~
line_coords->end_point[1], O& y+ f: |1 K6 ?" ^; l+ D7 y
line_coords->end_point[2]);3 X1 @. w6 Z+ `8 ~% H7 t
UF_CALL(UF_UI_open_listing_window());
% _: l7 k0 K" H' G# Q) d: c& [: h UF_CALL(UF_UI_write_listing_window(msg));2 L& I0 [6 \4 i
//UF_CALL(UF_UI_close_listing_window());
7 O- B- L! F7 w
- T+ o7 f' F1 i) u, x3 [$ a //释放动态内存
6 p, ~8 w1 P) F5 y UF_MODL_delete_list(&edge_list);4 [4 r; ]% C9 ^8 S& O& Z
UF_free(point_coords);
3 p; z; n# @4 n i) j( u q! r4 k UF_free(line_coords);/ |' }# j5 o1 N$ w/ g8 _
' x0 b; B! m- f4 t
UF_PART_save();
+ d+ [' T# B. e8 `; y/ v UF_PART_close_all(); |
评分
-
查看全部评分
|