資源簡(jiǎn)介
本示例演示了從文件中讀取數(shù)據(jù)點(diǎn)并把讀取的點(diǎn)在UG中畫(huà)出來(lái),然后根據(jù)每個(gè)截面上的點(diǎn)擬合成樣條曲線并對(duì)曲線進(jìn)行光順等操作,最后通過(guò)曲線創(chuàng)建曲面的過(guò)程。

代碼片段和文件信息
//The?following?program?was?created?by?Northwestern?Polytechnical?University?in?2007.
#include?“StdAfx.h“
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#define?UF_CALL(X)?(report(?__FILE__?__LINE__?#X?(X)))
static?int?report(?char?*file?int?line?char?*call?int?irc)
{
????if?(irc)
????{
????????char????messg[133];
????????printf(“%s?line?%d:??%s\n“?file?line?call);
????????(UF_get_fail_message(irc?messg))??
????????????printf(“????returned?a?%d\n“?irc)?:
????????????printf(“????returned?error?%d:??%s\n“?irc?messg);
????}
????return(irc);
}
tag_t?SmoothSpline(tag_t?spline_tag)
{
UF_CURVE_spline_t?spline_data;
int?cont_order;
? double?dist_toler?ang_toler;
double?smooth_param?=?1.2;
int?num_states;
? UF_CURVE_state_p_t?states;
tag_t?output_tag;
UF_CALL(UF_CURVE_ask_spline_data(spline_tag&spline_data));//get?spline_data
cont_order=2;
? dist_toler=smooth_param;
ang_toler=360;
UF_CALL(?UF_CURVE_smooth_spline_data
(&spline_datacont_orderdist_tolerang_toler&num_states&states));//光順曲線
UF_CALL(UF_CURVE_create_spline(&spline_data&output_tag&num_states&states));
//光順以后重新生成曲線
UF_OBJ_set_color(spline_tag?1);
UF_free(spline_data.knots);
UF_free(spline_data.poles);
UF_free(states);
return?output_tag;
}
void?CreateSheetbody(tag_t?*spline)
{
int?i;
UF_STRING_t?s_section?s_spine;
int?patch?=?2?alignment?=?1;
double?value[6];
int?vdegree?=?3?vstatus?=?0?body_type?=?1;
UF_FEATURE_SIGN?boolean?=?UF_NULLSIGN;
double?tol[3]?=?{0.0010.5*PI/180.00.001};
tag_t?c_face_id[2]?=?{NULLNULL};
int?c_flag[2]?=?{00};
tag_t?body_obj_id;
UF_MODL_init_string_list(&s_section);
UF_MODL_create_string_list(6?6?&s_section);
s_section.num?=?6;
for(i=0;?i<6;?i++)
{
s_section.string[i]?=?1;
s_section.dir[i]?=?UF_MODL_CURVE_START_FROM_BEGIN;
s_section.id[i]?=?spline[i];
}
UF_MODL_create_thru_curves(&s_section?&s_spine?&patch?&alignment?value?&vdegree
&vstatus?&body_type?boolean?tol?c_face_id?c_flag?&body_obj_id);
UF_MODL_free_string_list(&s_section);
}
static?void?do_ugopen_api(void)
{
FILE?*fp;
int?i?j;
char?filename[100];
double?point[3];
tag_t?t_pnt;
tag_t?spline[6];
double?pnt[6][300];
int?num_points?=?100;
int?opt=1;
for?(i=0;?i<6;?i++)
{
sprintf(filename?“E:\\slice%d.txt“?i);
fp?=?fopen(filename?“r“);
j?=?0;
if?(fp!=NULL)
{
while?(!feof(fp))
{
fscanf(fp?“%lf?%lf?%lf“?&point[0]?&point[1]?&point[2]);
UF_CURVE_create_point(point?&t_pnt);
pnt[i][3*j]?=?point[0];
pnt[i][3*j+1]?=?point[1];
pnt[i][3*j+2]?=?point[2];
j++;
}
FTN(uf5080)(&opt?&num_points?pnt[i]?&spline[i]);
spline[i]?=?SmoothSpline(spline[i]);
}?
else
uc1601(“Cannot?
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件???????3325??2007-12-26?21:07??Create_Surface\chapter5_blade.cpp
?????文件?????102472??2007-11-07?16:30??Create_Surface\chapter5_blade.dll
?????文件???????4250??2007-11-07?09:37??Create_Surface\chapter5_blade.dsp
?????文件????????553??2007-11-06?22:12??Create_Surface\chapter5_blade.dsw
?????文件??????50176??2007-12-26?20:52??Create_Surface\chapter5_blade.ncb
?????文件??????49664??2007-12-26?20:52??Create_Surface\chapter5_blade.opt
?????文件???????1243??2007-11-07?16:30??Create_Surface\chapter5_blade.plg
?????文件????????211??2006-07-09?11:07??Create_Surface\StdAfx.cpp
?????文件???????1447??2006-07-09?11:07??Create_Surface\StdAfx.h
?????目錄??????????0??2010-04-17?13:07??Create_Surface
-----------?---------??----------?-----??----
???????????????213341????????????????????10
- 上一篇:電機(jī)控制FOC算法方框圖
- 下一篇:DHCP snooping代碼
評(píng)論
共有 條評(píng)論