|
|
leaf
发表于 2014-11-26 07:50:53
tag_t newPartTag = NULL_TAG;9 y, F2 ?% p# O& Y9 Z7 ]- v: q
tag_t cylTag = NULL_TAG;
1 i+ E" I/ n, H3 k, I1 Q tag_t bodyTag = NULL_TAG;5 ~6 i1 q5 K* u
double cylOrigin[3] = {20, 30, 40};6 R5 f$ y( y& t% K: Q5 m# L' e$ B
char cylDiam[256] = "50"; c: y2 v; L) f" ~
double cylDirection[3] = {0, 0 ,1};0 E8 e) `) E, ?- j: _
double height = 60;
* }0 x) M- w$ K3 p # e2 s3 i- m# U% o! A
0 g5 Q9 Y& |- E! H
char cylHeight[256];' Z, Z Z0 ]2 [; @' f
sprintf_s(cylHeight, sizeof(cylHeight), "%f", height);$ C/ K( O9 W: t
//创建part
- z7 S- f) v1 x( |% R UF_CALL(UF_PART_new("D:\\leaf.part", 1, &newPartTag));& ?: |$ \) G# }% r8 d
//创建圆柱
% e M/ u/ b+ c; W UF_CALL(UF_MODL_create_cyl1(UF_NULLSIGN, cylOrigin, cylHeight, cylDiam, cylDirection, &cylTag));9 d$ F2 t) g0 K
//获取圆柱特征所在的体
4 t6 U8 \$ u2 g3 v, V% E1 p UF_CALL(UF_MODL_ask_feat_body(cylTag,&bodyTag));) Y4 P, H4 N0 Y; \9 t4 Q$ ?4 o9 d2 f
//获取体上的边" q+ m2 Z. K) W/ T0 ~9 c% S
uf_list_p_t edge_list ;) @$ W6 z" `; V2 _) Y. m, @
UF_CALL(UF_MODL_ask_body_edges(bodyTag, &edge_list));
+ R6 k4 e7 j+ u* A" p) | //得到边的数量
" R$ ~+ r7 M, P int edgeCount = 0;
5 o" ]/ g0 g( b e) R. v UF_CALL(UF_MODL_ask_list_count(edge_list, &edgeCount));
) ^& ^$ C8 l0 A# `% n* D; q //打印边的数量
3 i+ V: Y( |8 J# F char cCount[256];9 | M: t3 ~. ? t4 d* G* Q
sprintf_s(cCount, sizeof(cCount), "cylinder实体上的边的数量:%d", edgeCount);
1 U! n2 c, _: Y, |* ~$ E' A! V uc1601(cCount, 1);3 S1 C$ h2 U; H, X( G9 L& I
( U4 D- J: [( V int error;
2 s( Y$ ^5 L" l1 Y double (*point_coords)[3];
7 v* ?5 f% V8 T' A0 S point_coords= (double (*)[3]) UF_allocate_memory(edgeCount * sizeof(double [3]), &error );
2 A- T$ P5 p* C5 U //获取圆柱的上两条边的圆心9 g$ k) q3 y$ P7 a% d
int i = 0;
4 u& s3 s- _. e$ |/ {2 A' ~ tag_t curveOriginTag = NULL_TAG;5 C: i, ~5 J0 k2 `
for (i; i < edgeCount; i++)$ _7 `! I5 c( {1 W4 H* t
{
4 J1 l$ C: s/ t/ u% F8 j8 X UF_CALL(UF_MODL_ask_list_item(edge_list, i, &curveOriginTag));# K& }% A+ u) \% ^& C* j! `5 V5 m
UF_CALL(UF_CURVE_ask_centroid(curveOriginTag, point_coords[i]));1 R& B1 k* F7 l. [7 i/ F5 @
}
: k6 o, ]. O7 f" n4 @ //将圆心存放到直线起始点的链表中8 r) s- |. J3 M
UF_CURVE_line_p_t line_coords;
/ N2 a- Y9 P" I* J9 a line_coords= (UF_CURVE_line_p_t ) UF_allocate_memory(edgeCount * sizeof(double [3]), &error );; e$ |7 s8 q8 q" V
line_coords->start_point[0] = point_coords[0][0];
' o/ N3 W$ g& s# T7 [8 } ]9 @ line_coords->start_point[1] = point_coords[0][1];
1 s1 S6 Y( ]. \" L' X line_coords->start_point[2] = point_coords[0][2];
7 ~* o" _/ Q% S; P& L line_coords->end_point[0] = point_coords[1][0];
5 X6 H" _% e2 @2 B+ U( \5 z5 ~/ U line_coords->end_point[1] = point_coords[1][1];
, x& K- K' D: s0 j/ m. G line_coords->end_point[2] = point_coords[1][2];9 W3 v8 I9 ?( i5 P
2 R, o/ L6 K+ A# D0 T tag_t lineTag = NULL_TAG;
1 c& T% \8 p: T- T3 o& K" U
) c+ u5 f3 @1 d) {4 q% ]$ D5 o& L //创建直线
/ n }3 g# w" `9 R UF_CALL(UF_CURVE_create_line(line_coords, &lineTag));4 ?2 x" J/ @9 a: G
/ m+ n. h, G2 \+ F
//打印直线的端点
* _% G% | X- ^) S/ F/ F5 |& g char msg[256];# e# Z' x I1 O' n/ ]
sprintf_s(msg, sizeof(msg), "创建的直线的起点是:%f、%f、%f,\n终点是:%f、%f、%f.",
5 b5 }/ S0 n9 c# N/ f/ M line_coords->start_point[0],( F0 F" U2 u0 n3 g: h4 L# l" [
line_coords->start_point[1],
( ^/ Z$ [8 v N7 D& } line_coords->start_point[2],
, \2 M/ O7 p' @. H \/ \ line_coords->end_point[0],
, \/ Y9 W: o* L) b line_coords->end_point[1],
$ B0 l( ~4 d5 T1 F line_coords->end_point[2]);
7 F8 j6 W, o+ q- } UF_CALL(UF_UI_open_listing_window());6 k" s3 w0 U! V- T4 s
UF_CALL(UF_UI_write_listing_window(msg));
, b/ |8 q9 w& w Z8 U' f //UF_CALL(UF_UI_close_listing_window());, O/ ]( M1 e' y/ O0 t( G+ R5 A
* o0 n! u5 h+ {- u. A4 J- e1 i0 K' ?
//释放动态内存
! f$ P' U4 s, z6 v* w# [- ^8 ^ UF_MODL_delete_list(&edge_list);) ^, }* P* D0 t7 s8 x: w: `9 }
UF_free(point_coords);4 u- j, Y. Z5 i w' v
UF_free(line_coords);
# Z; {. ~$ B/ H b( R0 }* V; e" i u# H+ o' e* {+ c# H7 I8 _! Q9 Y& [
UF_PART_save();
% d5 l! V: b+ {" J' H UF_PART_close_all(); |
评分
-
查看全部评分
|