📄 face.~cpp
字号:
if (FeedDirection==0){
Approach = MachinePosition(GetPosition(xApproach[i],yApproach[i])+vector(0.,0.,-ee_lat[i][0]) ) ;
}else{
Approach = MachinePosition(GetPosition(xApproach[i],yApproach[i])+vector(0.,0.,-ee_lat[0][i]) ) ;
};
}else {
Approach = MachinePosition(GetPosition(xApproach[i],yApproach[i])) ;
};//----------------------end of ErrorComp
// WriteAPoint(fout, Approach, JogSpeed );
WriteAPoint(fout, Approach, JogSpeed ); //990115 moriyasu
MachiningTime = MachiningTime + 0;
//end of initial point
//// approach
//------------------------ErrorComp 981028
if (ErrorComp){
if (FeedDirection==0){
Approach = MachinePosition(GetPosition(xApproach[i],yApproach[i])+vector(0.,0.,ee_lat[i][0]) ) ;
now = MachinePosition(GetPosition(x[i][0],y[i][0])+vector(0.,0.,ee_lat[i][0])) ;
}else{
Approach = MachinePosition(GetPosition(xApproach[i],yApproach[i])+vector(0.,0.,ee_lat[0][i]) ) ;
now = MachinePosition(GetPosition(x[i][0],y[i][0])+vector(0.,0.,ee_lat[0][i])) ;
};
}else {
Approach = MachinePosition(GetPosition(xApproach[i],yApproach[i])) ;
now = MachinePosition(GetPosition(x[i][0],y[i][0])) ;
};//----------------------end of ErrorComp
WriteAPoint(fout, now, MachineSpeed(Approach, now) );
MachiningTime = MachiningTime
+ distance2(Approach,now)/MachineSpeed(Approach, now) ;
//end of approach
//// y_loop
for(int j=1;j<jmax[i];j++)
{
prev = now;
//------------------------ErrorComp 981028
if (ErrorComp){
if (FeedDirection==0){
now = MachinePosition(GetPosition(x[i][j],y[i][j])+vector(0.,0.,-ee_lat[i][j])) ;
}else{
now = MachinePosition(GetPosition(x[i][j],y[i][j])+vector(0.,0.,-ee_lat[j][i])) ;
};
}else {
now = MachinePosition(GetPosition(x[i][j],y[i][j])) ;
};//----------------------end of ErrorComp
//now = MachinePosition(GetPosition(x[i][j],y[i][j]));
WriteAPoint(fout, now, MachineSpeed(prev,now));
MachiningTime = MachiningTime
+ distance2(prev,now)/MachineSpeed(prev,now) ;
};//end of y_loop
////escape
prev = now;
//------------------------ErrorComp 981028
if (ErrorComp){
if (FeedDirection==0){
Escape = MachinePosition(GetPosition(xEscape[i],yEscape[i])+vector(0.,0.,-ee_lat[i][jmax[i]-1]) ) ;
}else{
Escape = MachinePosition(GetPosition(xEscape[i],yEscape[i])+vector(0.,0.,-ee_lat[jmax[i]-1][i]) ) ;
};
}else {
Escape = MachinePosition(GetPosition(xEscape[i],yEscape[i])) ;
};//----------------------end of ErrorComp
Escape = MachinePosition(GetPosition(xEscape[i],yEscape[i])) ;
WriteAPoint(fout, Escape, MachineSpeed(prev, Escape) );
MachiningTime = MachiningTime
+ distance2(prev,Escape)/MachineSpeed(prev,Escape) ;
/* WriteAPoint(fout, Escape, 500. );
MachiningTime = MachiningTime
+ distance2(prev,Escape)/500. ;
*/
//end of escape
////feed points
///////Attention!!///////////////////////
///////First, z-direction return.
///////Second, y-direction return.
///////////////////////////97.Nov.25
///////First, y.Second,z
////////ELID OFF 990117 moriyasu
//fout << "M25;" << endl;
//fout << "G94G04P100;" << endl;
//MachiningTime += 0.1/60.;
/*now = vector(Escape.getX(),Approach.getY(),Escape.getZ());
WriteAPoint(fout, now, JogSpeed);
MachiningTime = MachiningTime
+ distance2(Escape,now)/JogSpeed ;
*/
//fout << "G94G04P100;" << endl;
//MachiningTime += 0.1/60.;
// WriteAPoint(fout, Approach, JogSpeed);
//WriteAPoint(fout, Approach, JogSpeed); // 990115 moriyasu
//MachiningTime = MachiningTime+ distance2(now,Approach)/500.;
};//end of x_loop
fout << "G01G90Z50.0F5000;" << endl;
Approach = MachinePosition(GetPosition(xApproach[0],yApproach[0])) ;
Approach.setZ(10.);
WriteAPoint(fout, Approach, JogSpeed );
//MachiningTime += 3.0/500.;
////////ELID off
fout << "M64;" << endl;
////////endmill stop
fout << "(M05);" << endl;
////////coolant stop
fout << "(M19);" << endl;
////stop machine
fout << "M02;" << endl ;
fout << "(Machining time will be :" << MachiningTime << " min);"<<endl ;
fout << "%" << endl;
/////////////////////////////////
//close file
fout.close();
//sprintf(text,"Success to output NC program!\n"/*,i*/);
//cout << text;
//cout << "(Machining time will be :" << MachiningTime << " min);"<<endl ;
//cout << "OK?"<<endl;
//cin >> text;
return(1);
}
};//end of NcDataOut
int face::FaceDataOut(const char* filename){
//ErrorComp偺僠僃僢僋
if (ErrorComp){
bool judge=true;
for (int i=0;i<imax;i++){
for (int j=0;j<jmax[i];j++){
if (FeedDirection==0){
judge = judge && (fabs(x[i][j]-xx_lat[i])<1.e-6);
judge = judge && (fabs(y[i][j]-yy_lat[j])<1.e-6);
judge = judge && (imax==get_np_lat());
judge = judge && (jmax[i]==get_nq_lat());
}else{
judge = judge && (fabs(x[i][j]-xx_lat[j])<1.e-6);
judge = judge && (fabs(y[i][j]-yy_lat[i])<1.e-6);
judge = judge && (jmax[i]==get_np_lat());
judge = judge && (imax==get_nq_lat());
};
}
};
if (judge==false) {
ShowMessage("Error about ErrorComp in face::NCDataOut !");
return 0;
};
};
char text[1000];
ofstream fout;
fout.open(filename);
if (fout==NULL)
{
sprintf(text, "Can't open file: %s ", filename);
//write
//cout << text;
return(0);
}
else
{
sprintf(text, "Writing file: %s \n", filename);
//write
//cout << text;
/////////////////////////////////
vector machine;
fout.precision(9);
fout << " x y z x_machine y_machine z_machine angle tool_ok LineNo PointNo"<<endl;
for(int i=0;i<imax;i++)
{
//------------------------ErrorComp 981028
if (ErrorComp){
if (FeedDirection==0){
machine = MachinePosition(GetPosition(xApproach[i],yApproach[i])+vector(0.,0.,-ee_lat[i][0])) ;
}else{
machine = MachinePosition(GetPosition(xApproach[i],yApproach[i])+vector(0.,0.,-ee_lat[0][i])) ;
};
}else {
machine = MachinePosition(GetPosition(xApproach[i],yApproach[i])) ;
};//----------------------end of ErrorComp
//machine = MachinePosition(GetPosition(xApproach[i],yApproach[i]));
/*fout << xApproach[i] << ' ' << yApproach[i]
<< ' ' << GetZ(xApproach[i],yApproach[i])<<' ';
fout << machine.getX() << ' '<< machine.getY() << ' '<< machine.getZ();
fout << endl;
*/
sprintf(text,"%9.6lf %9.6lf %9.6lf %9.6lf %9.6lf %9.6lf %9.6lf %9d %9d %9d",xApproach[i],yApproach[i], GetZ(xApproach[i],yApproach[i]),
machine.getX(),machine.getY(),machine.getZ(),0.,1,i,-1);
fout << text << endl;
for(int j=0;j<jmax[i];j++)
{
double angle = ToolAngle(x[i][j],y[i][j]);
//------------------------ErrorComp 981028
if (ErrorComp){
if (FeedDirection==0){
machine = MachinePosition(GetPosition(x[i][j],y[i][j])+vector(0.,0.,-ee_lat[i][j])) ;
}else{
machine = MachinePosition(GetPosition(x[i][j],y[i][j])+vector(0.,0.,-ee_lat[j][i])) ;
};
}else {
machine = MachinePosition(GetPosition(x[i][j],y[i][j])) ;
};//----------------------end of ErrorComp
//machine = MachinePosition(GetPosition(x[i][j],y[i][j]));
/*
fout << x[i][j] << ' ' << y[i][j]
<< ' ' << GetZ(x[i][j],y[i][j]) <<' ';
fout << machine.getX() << ' '<< machine.getY() << ' '<< machine.getZ();
fout << ' ' << angle << ' ' << ToolOk[i][j]<<'\n';
*/
sprintf(text,"%9.6lf %9.6lf %9.6lf %9.6lf %9.6lf %9.6lf %9.6lf %9d %9d %9d",x[i][j],y[i][j], GetZ(x[i][j],y[i][j]),
machine.getX(),machine.getY(),machine.getZ(),angle,ToolOk[i][j],i,j);
fout << text << endl;
}
//------------------------ErrorComp 981028
if (ErrorComp){
if (FeedDirection==0){
machine = MachinePosition(GetPosition(xEscape[i],yEscape[i])+vector(0.,0.,-ee_lat[i][jmax[i]-1]) ) ;
}else{
machine = MachinePosition(GetPosition(xEscape[i],yEscape[i])+vector(0.,0.,-ee_lat[jmax[i]-1][i]) ) ;
};
}else {
machine = MachinePosition(GetPosition(xEscape[i],yEscape[i])) ;
};//----------------------end of ErrorComp
//machine = MachinePosition(GetPosition(xEscape[i],yEscape[i]));
/*
fout << xEscape[i] << ' ' << yEscape[i]
<< ' ' << GetZ(xEscape[i],yEscape[i])<<' ';
fout << machine.getX() << ' '<< machine.getY() << ' '<< machine.getZ() ;
fout << endl;
*/
sprintf(text,"%9.6lf %9.6lf %9.6lf %9.6lf %9.6lf %9.6lf %9.6lf %9d %9d %9d",xEscape[i],yEscape[i], GetZ(xEscape[i],yEscape[i]),
machine.getX(),machine.getY(),machine.getZ(),0.,1,i,-2);
fout << text << endl;
}
/////////////////////////////////
fout.close();
sprintf(text,"Write Success!\n"/*,i*/);
//write;
//cout << text;
return(1);
}
}; //end of FaceDataOut
// machining-time prediction
//980519
void face::SetFaceParameter(TStringList *str)
{
bool hasDiameter = false; //WheelDiameter偲WheelRadius偺屳姺惈偺偨傔
NumWorkAreaPoints=0;
for (int i=0; i<str->Count; i++){
AnsiString temp;
temp = "WorkDiameter";
if (str->Names[i]==temp){
WorkDiameter = str->Values[str->Names[i]].ToDouble();
};
temp = "WorkSizeY";
if (str->Names[i]==temp){
WorkSizeY = str->Values[str->Names[i]].ToDouble();
};
temp = "NumWorkAreaPoints";
if (str->Names[i]==temp){
NumWorkAreaPoints = str->Values[str->Names[i]].ToDouble();
};
temp = "WorkPosition";
if (str->Names[i]==temp){
WorkPosition = str->Values[str->Names[i]].ToDouble();
};
temp = "MinAngle";
if (str->Names[i]==temp){
MinAngle = str->Values[str->Names[i]].ToDouble();
};
temp = "MaxAngle";
if (str->Names[i]==temp){
MaxAngle = str->Values[str->Names[i]].ToDouble();
};
temp = "Speed";
if (str->Names[i]==temp){
Speed = str->Values[str->Names[i]].ToDouble();
};
temp = "JogSpeed";
if (str->Names[i]==temp){
JogSpeed = str->Values[str->Names[i]].ToDouble();
};
temp = "RevSpeed";
if (str->Names[i]==temp){
RevSpeed = str->Values[str->Names[i]].ToDouble();
};
temp = "Escape";
if (str->Names[i]==temp){
Escape = str->Values[str->Names[i]].ToDouble();
};
/*
temp = "RoughnessBetweenLines";
if (str->Names[i]==temp){
RoughnessBetweenLines = str->Values[str->Names[i]].ToDouble();
};
temp = "RoughnessAlongLine";
if (str->Names[i]==temp){
RoughnessAlongLine = str->Values[str->Names[i]].ToDouble();
};
*/
temp = "X_Pitch";
if (str->Names[i]==temp){
X_Pitch = str->Values[str->Names[i]].ToDouble();
};
temp = "Y_Pitch";
if (str->Names[i]==temp){
Y_Pitch = str->Values[str->Names[i]].ToDouble();
};
temp = "ProgramNumber";
if (str->Names[i]==temp){
ProgramNumber = str->Values[str->Names[i]].ToInt();
};
temp = "ToolRadiusFlycut";
if (str->Names[i]==temp){
ToolRadiusFlycut = str->Values[str->Names[i]].ToDouble();
};
temp = "WheelDiameterFlycut";
if (str->Names[i]==temp){
WheelRadiusFlycut = str->Values[str->Names[i]].ToDouble()/2.;
hasDiameter = true;
};
temp = "wolter_thickness";
if (str->Names[i]==temp){
wolter_thickness = str->Values[str->Names[i]].ToDouble();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -