列出程式 Data registration and integration for 3D shape measurement 之主程式碼。由於整體程式碼過於龐大,因此只列出主程式碼表示其結構,副程
式與眾多函式庫不於此列出。
B.6.1 三點對位運算主程式碼
void Cdialog::OnOK() {
// TODO: Add extra validation here char fn0[200],fn1[200],fnout[80];
UpdateData(TRUE);
int nnei,npara,nint,i;
double pi,cr1,cr2;
cr1 = 1.3; cr2 = 1.3;
ads_point
gpoint1,center1,gpoint2,center2,tmp,gpoint3,gpoint4,gpoint5,gpoi nt6,center3,center4,center5,center6;
nnei=m_nnei; npara = m_npara; nint=254; pi=4.0*atan(1.0);
CDialog::OnOK();
//nnei<1500 npara<300
acedCommand(RTSTR,"osnap",RTSTR,"none",0);
acedCommand(RTSTR,"cmdecho",RTSTR,"0",0);
// ********** draw left ***********
acedCommand(RTSTR,"erase",RTSTR,"all",RTSTR,"",0);
acedCommand(RTSTR,"layer",RTSTR,"Make",RTSTR,"left",RTSTR,"
color",RTSTR,"blue",RTSTR,"",RTSTR,"",0);
strcpy(fn0,"d:/a2002/test0.tst");draw_fn(fn0);
acedCommand(RTSTR,"layer",RTSTR,"set",RTSTR,"0",RTSTR,"",0)
;
get_point(gpoint1);
get_point(gpoint3);
get_point(gpoint5);
if(m_bStep == TRUE)acedGetPoint(NULL,"\n Get 3 Points!! Get Point to Continue",tmp);
acedCommand(RTSTR,"erase",RTSTR,"all",RTSTR,"",0);
if(m_bFAPoint1 == FALSE) for(i=0;i<3;i++) center1[i] = gpoint1[i];
if(m_bFAPoint2 == FALSE) for(i=0;i<3;i++) center3[i] = gpoint3[i];
if(m_bFAPoint3 == FALSE) for(i=0;i<3;i++) center5[i] = gpoint5[i];
// ********** find apex *********
if(m_bStep == TRUE) {
draw_apex(center1,cr1);
draw_apex(center3,cr1);
draw_apex(center5,cr1);
acedCommand(RTSTR,"layer",RTSTR,"set",RTSTR,"left",RTSTR,""
,0);
draw_fn(fn0);
acedCommand(RTSTR,"layer",RTSTR,"set",RTSTR,"0",RTSTR,"",0)
;
acedGetPoint(NULL,"\n Get 3 Points!! Get Point to
}//end if
// ********** draw right ***********
acedCommand(RTSTR,"erase",RTSTR,"all",RTSTR,"",0);
acedCommand(RTSTR,"layer",RTSTR,"Make",RTSTR,"right",RTSTR,
"color",RTSTR,"magenta",RTSTR,"",RTSTR,"",0);
strcpy(fn1,"d:/a2002/test1.tst");draw_fn(fn1);
acedCommand(RTSTR,"layer",RTSTR,"set",RTSTR,"0",RTSTR,"",0)
;
get_point(gpoint2);
get_point(gpoint4);
get_point(gpoint6);
if(m_bStep == TRUE)acedGetPoint(NULL,"\n Get 3 Points!! Get Point to Continue",tmp);
acedCommand(RTSTR,"erase",RTSTR,"all",RTSTR,"",0);
if(m_bFAPoint1 == FALSE) for(i=0;i<3;i++) center2[i] = gpoint2[i];
if(m_bFAPoint2 == FALSE) for(i=0;i<3;i++) center4[i] = gpoint4[i];
if(m_bFAPoint3 == FALSE) for(i=0;i<3;i++) center6[i] = gpoint6[i];
// ********** find apex *********
if(m_bStep == TRUE) {
draw_apex(center2,cr2);
draw_apex(center4,cr2);
draw_apex(center6,cr2);
acedCommand(RTSTR,"layer",RTSTR,"set",RTSTR,"right",RTSTR,"
",0);
draw_fn(fn1);
acedCommand(RTSTR,"layer",RTSTR,"set",RTSTR,"0",RTSTR,"",0)
;
acedGetPoint(NULL,"\n Get 3 Points!! Get Point to Continue",tmp);
}//end if
acedCommand(RTSTR,"erase",RTSTR,"all",RTSTR,"",0);
strcpy(fnout,"d:/a2002/tmp.tst");
registration(fn0,fn1,fnout,center1,center2,center3,center4, center5,center6);
if(m_bStep == FALSE) acedCommand(RTSTR,"zoom",RTSTR,"e",0);
acedCommand(RTSTR,"regen",0);
}
B.6.2 單點對位運算主程式碼
void Cdialog::OnRegis1() {
UpdateData(TRUE);
int nnei,npara,nint,i;
double pi,cr1,cr2;
cr1 = 1.3; cr2 = 1.3;
ads_point gpoint1,center1,gpoint2,center2,tmp;
nnei=m_nnei; npara = m_npara; nint=254;
CDialog::OnOK();
//nnei<1500 npara<300
acedCommand(RTSTR,"osnap",RTSTR,"none",0);
acedCommand(RTSTR,"cmdecho",RTSTR,"0",0);
// ********** draw left ***********
acedCommand(RTSTR,"erase",RTSTR,"all",RTSTR,"",0);
acedCommand(RTSTR,"layer",RTSTR,"Make",RTSTR,"left",RTSTR,"
color",RTSTR,"blue",RTSTR,"",RTSTR,"",0);
strcpy(fn0,"d:/a2002/test0.tst");draw_fn(fn0);
acedCommand(RTSTR,"layer",RTSTR,"set",RTSTR,"0",RTSTR,"",0)
;
get_point(gpoint1);
if(m_bStep == TRUE)acedGetPoint(NULL,"\n Get 1 Point!! Get Point to Continue Registration",tmp);
acedCommand(RTSTR,"erase",RTSTR,"all",RTSTR,"",0);
if(m_bFAPoint1 == FALSE) for(i=0;i<3;i++) center1[i] = gpoint1[i];
// ********** find apex *********
if(m_bFAPoint1 == TRUE)
find_apex(fn0,nnei,npara,gpoint1,center1,&cr1,m_bPlanar,m_bPara)
;
// ********** re draw left ***********
if(m_bStep == TRUE) {
draw_apex(center1,cr1);
acedCommand(RTSTR,"layer",RTSTR,"set",RTSTR,"left",RTSTR,""
,0);
draw_fn(fn0);
acedCommand(RTSTR,"layer",RTSTR,"set",RTSTR,"0",RTSTR,"",0)
;
acedGetPoint(NULL,"\n Get 1 Apex Point!! Get Point to Continue Registration",tmp);
}//end if
// ********** draw right ***********
acedCommand(RTSTR,"erase",RTSTR,"all",RTSTR,"",0);
acedCommand(RTSTR,"layer",RTSTR,"Make",RTSTR,"right",RTSTR,
"color",RTSTR,"magenta",RTSTR,"",RTSTR,"",0);
strcpy(fn1,"d:/a2002/test1.tst");draw_fn(fn1);
acedCommand(RTSTR,"layer",RTSTR,"set",RTSTR,"0",RTSTR,"",0)
;
get_point(gpoint2);
if(m_bStep == TRUE)acedGetPoint(NULL,"\n Get 1 Point!! Get Point to Continue Registration",tmp);
acedCommand(RTSTR,"erase",RTSTR,"all",RTSTR,"",0);
if(m_bFAPoint1 == FALSE) for(i=0;i<3;i++) center2[i] = gpoint2[i];
// ********** find apex *********
if(m_bFAPoint1 == TRUE)
find_apex(fn1,nnei,npara,gpoint2,center2,&cr2,m_bPlanar,m_bPara)
;
// ********** re draw right ***********
if(m_bStep == TRUE) {
draw_apex(center2,cr2);
acedCommand(RTSTR,"layer",RTSTR,"set",RTSTR,"right",RTSTR,"
",0);
draw_fn(fn1);
acedCommand(RTSTR,"layer",RTSTR,"set",RTSTR,"0",RTSTR,"",0)
;
acedGetPoint(NULL,"\n Get 1 Apex Point!! Get Point to Continue Registration",tmp);
}//end if
acedCommand(RTSTR,"erase",RTSTR,"all",RTSTR,"",0);
strcpy(fnout,"d:/a2002/tmp.tst");
Regis1(fn0,fn1,fnout,center1,center2);
if(m_bStep == FALSE) acedCommand(RTSTR,"zoom",RTSTR,"e",0);
acedCommand(RTSTR,"regen",0);
}
B.6.3 整合運算主程式碼
void Cdialog::OnIntegration() {
char fn0[200],fnout[200];
int nint,blending;
UpdateData(TRUE);
CDialog::OnOK();
nint=m_nint;
blending=m_iBlending;
strcpy(fn0,"d:/a2002/test0.tst");
strcpy(fnout,"d:/a2002/tmp.tst");
if(m_bReDraw == TRUE) draw_int();
integration(fn0,fnout,nint,blending,m_bStep);
}
B.6.4 左側視角三維點資料 網格化鋪面主程式碼
void Cdialog::OnButton4() {
char fnin[80];
strcpy(fnin,"d:/a2002/int_L.tst");
FILE *fpin;
int n,m,i,j;
ads_point pt;
CDialog::OnOK();
acedCommand(RTSTR,"erase",RTSTR,"all",RTSTR,"",0);
fpin=fopen(fnin,"r");
fscanf(fpin,"%d %d",&m,&n);
acedCommand(RTSTR,"3dmesh",RTSHORT,m,RTSHORT,n,0);
for(i=0;i<m;i++) for(j=0;j<n;j++) {
fscanf(fpin,"%lf %lf %lf", &pt[0], &pt[1],
&pt[2]);
acedCommand(RT3DPOINT,pt,0);
}
acedCommand(RTSTR,"zoom",RTSTR,"e",0);
acedCommand(RTSTR,"regen",0);
return;
}
B.6.5 右側視角三維點資料 網格化鋪面主程式碼
void Cdialog::OnButton3() {
char fnin[80];
strcpy(fnin,"d:/a2002/int_R.tst");
FILE *fpin;
int n,m,i,j;
ads_point pt;
CDialog::OnOK();
acedCommand(RTSTR,"erase",RTSTR,"all",RTSTR,"",0);
fpin=fopen(fnin,"r");
fscanf(fpin,"%d %d",&m,&n);
acedCommand(RTSTR,"3dmesh",RTSHORT,m,RTSHORT,n,0);
for(i=0;i<m;i++) for(j=0;j<n;j++) {
fscanf(fpin,"%lf %lf %lf", &pt[0], &pt[1],
&pt[2]);
acedCommand(RT3DPOINT,pt,0);
}
acedCommand(RTSTR,"zoom",RTSTR,"e",0);
acedCommand(RTSTR,"regen",0);
return;
}
B.6.6 完成對位三維點資料 網格化鋪面主程式碼
void Cdialog::OnButton2() {
char fnin[80];
strcpy(fnin,"d:/a2002/final.tst");
CDialog::OnOK();
FILE *fpin;
int n,m,i,j;
ads_point pt;
CDialog::OnOK();
acedCommand(RTSTR,"erase",RTSTR,"all",RTSTR,"",0);
fpin=fopen(fnin,"r");
fscanf(fpin,"%d %d",&m,&n);
acedCommand(RTSTR,"3dmesh",RTSHORT,m,RTSHORT,n,0);
for(i=0;i<m;i++) for(j=0;j<n;j++) {
fscanf(fpin,"%lf %lf %lf", &pt[0], &pt[1],
&pt[2]);
acedCommand(RT3DPOINT,pt,0);
}
acedCommand(RTSTR,"zoom",RTSTR,"e",0);
acedCommand(RTSTR,"regen",0);
return;
}
B.6.7 擷取剖面主程式碼
void Cdialog::OnButton6()
// TODO: Add your control notification handler code here char fnin[80];
strcpy(fnin,"d:/a2002/final.tst");
CDialog::OnOK();
FILE *fpin;
int n,m,i,j;
ads_point pt[2][255],ptl[255],gp,tmp;
double YYY,c,r;
r=5.0;
CDialog::OnOK();
acedCommand(RTSTR,"layer",RTSTR,"Make",RTSTR,"Section0",RTS TR,"color",RTSTR,"green",RTSTR,"",RTSTR,"",0);
acedCommand(RTSTR,"osnap",RTSTR,"near",0);
acedGetPoint(NULL,"\n Get a nearest Point ",gp);
YYY = gp[1];
acedCommand(RTSTR,"sphere",RT3DPOINT,gp,RTREAL,r,0);
acedGetPoint(NULL,"\n Get Point to Continue!! ",tmp);
acedCommand(RTSTR,"osnap",RTSTR,"none",0);
///acedGetReal("Input Y :",&YYY);
//acedCommand(RTSTR,"erase",RTSTR,"all",RTSTR,"",0);
fpin=fopen(fnin,"r");
fscanf(fpin,"%d %d",&m,&n);
for(j=0;j<n;j++) {
pt[0][n][0]=0;
pt[0][n][1]=0;
pt[0][n][2]=0;
}
for(j=0;j<n;j++) //read frist line {
fscanf(fpin,"%lf %lf %lf", &pt[1][j][0], &pt[1][j][1],
&pt[1][j][2]);
}
for(i=1;i<m;i++) {
for(j=0;j<n;j++) {
fscanf(fpin,"%lf %lf %lf", &pt[0][j][0],
&pt[0][j][1], &pt[0][j][2]);
}
if(YYY<pt[1][0][1] && YYY>pt[0][0][1]) break;
if(YYY>pt[1][0][1] && YYY<pt[0][0][1]) break;
if(YYY==pt[0][0][1]) break;
for(j=0;j<n;j++) {
pt[1][j][0]=pt[0][j][0];
pt[1][j][1]=pt[0][j][1];
pt[1][j][2]=pt[0][j][2];
}
if(i== m-1)acutPrintf("Not Found!!");
}
c = (YYY-pt[0][0][1])/(pt[1][0][1]-pt[0][0][1]);
acutPrintf("i = %d",i);
acedCommand(RTSTR,"layer",RTSTR,"Make",RTSTR,"Section1",RTS TR,"color",RTSTR,"red",RTSTR,"",RTSTR,"",0);
acedCommand(RTSTR,"3Dpoly",0);
for(j=0;j<n;j++) {
acedCommand(RT3DPOINT,pt[0][j],0);
}
acedCommand(RTSTR,"",0);
acedCommand(RTSTR,"3Dpoly",0);
for(j=0;j<n;j++) {
acedCommand(RT3DPOINT,pt[1][j],0);
}
acedCommand(RTSTR,"layer",RTSTR,"Make",RTSTR,"Section2",RTS TR,"color",RTSTR,"blue",RTSTR,"",RTSTR,"",0);
acedCommand(RTSTR,"3Dpoly",0);
for(j=0;j<n;j++) {
ptl[j][0]=(pt[1][j][0]-pt[0][j][0])*c+pt[0][j][0];
ptl[j][2]=(pt[1][j][2]-pt[0][j][2])*c+pt[0][j][2];
ptl[j][1]=YYY;
acedCommand(RT3DPOINT,ptl[j],0);
}
acedCommand(RTSTR,"",0);
acedCommand(RTSTR,"zoom",RTSTR,"e",0);
acedCommand(RTSTR,"regen",0);
acedCommand(RTSTR,"layer",RTSTR,"set",RTSTR,"0",RTSTR,"",0)
;
return;
}
作者簡歷
姓 名 : 鍾宜達
出生日期 : 中華民國 72 年 8 月 31 日
出 生 地 : 台北市
學 經 歷 : 民國 78~84 年 台北市立公館國民小學
民國 84~87 年 台北市立民族國民中學
民國 87~90 年 台北市立大同高級中學
民國 90~94 年 國立交通大學機械工程學系
民國 94~96 年 國立交通大學機械工程學系碩士班
通訊地址 : 台北市文山區萬美街二段八十一號
電 話 : 0958-080-052
E m a i l : [email protected]