📄 face.~cpp
字号:
};
temp = "ToolType";
if (str->Names[i]==temp){
ToolType = str->Values[str->Names[i]].ToInt();
};
temp = "WorkShape";
if (str->Names[i]==temp){
WorkShape = str->Values[str->Names[i]].ToInt();
};
//981027 int FeedDirection;//0:y,1:x
temp = "FeedDirection";
if (str->Names[i]==temp){
FeedDirection = str->Values[str->Names[i]].ToInt();
};
//981028 int ErrorComp;//0:false,1:true
temp = "ErrorComp";
if (str->Names[i]==temp){
ErrorComp = str->Values[str->Names[i]].ToInt();
};
temp = "ErrorCompFileName";
if (str->Names[i]==temp){
ErrorCompFileName = str->Values[str->Names[i]];
};
/*temp = "WheelRadiusFlycut";
if (str->Names[i]==temp){
WheelRadiusFlycut = str->Values[str->Names[i]].ToDouble();
};
*/
//case "LargeRadius";
// break;
//case "SmallRadius";
// break;
temp = "XRadiusEllipse";
if (str->Names[i]==temp){
XRadiusEllipse = str->Values[str->Names[i]].ToDouble();
};
temp = "YRadiusEllipse";
if (str->Names[i]==temp){
YRadiusEllipse = str->Values[str->Names[i]].ToDouble();
};
};
if (hasDiameter==false){
for (int i=0; i<str->Count; i++){
AnsiString temp;
temp = "WheelRadiusFlycut";
if (str->Names[i]==temp){
WheelRadiusFlycut = str->Values[str->Names[i]].ToDouble();
};
};
};
if (ToolType==1) WheelRadiusFlycut=ToolRadiusFlycut;//in case of ball-endmill
LargeRadius = WheelRadiusFlycut - ToolRadiusFlycut;
SmallRadius = ToolRadiusFlycut;
if (NumWorkAreaPoints>100)
{
NumWorkAreaPoints=99;
};
if (NumWorkAreaPoints>0)
{
WorkAreaPoints = new vector[NumWorkAreaPoints];
};
for (int j=0;j<NumWorkAreaPoints ;j++)
{
for (int i=0; i<str->Count; i++){
AnsiString temp;
temp = AnsiString("WorkAreaPoints[")+j+AnsiString("].x");
if (str->Names[i]==temp){
WorkAreaPoints[j].setX( str->Values[str->Names[i]].ToDouble());
};
temp = AnsiString("WorkAreaPoints[")+j+AnsiString("].y");
if (str->Names[i]==temp){
WorkAreaPoints[j].setY( str->Values[str->Names[i]].ToDouble());
};
};
};
};
void face::GetFaceParameter(TStringList *str)
{
str->Add(AnsiString("---face parameter(s)---"));
str->Add(AnsiString("WorkShape=")+ WorkShape);
str->Add(AnsiString("//0:square,1:circle,2:ellipse,4:convex_polygon"));
str->Add(AnsiString("NumWorkAreaPoints=")+ NumWorkAreaPoints);
for (int i=0;i<NumWorkAreaPoints;i++)
{
str->Add(AnsiString("WorkAreaPoints[")+i+"].x="+ WorkAreaPoints[i].getX());
str->Add(AnsiString("WorkAreaPoints[")+i+"].y="+ WorkAreaPoints[i].getY());
};
str->Add(AnsiString("XRadiusEllipse=")+ XRadiusEllipse);
str->Add(AnsiString("YRadiusEllipse=")+ YRadiusEllipse);
str->Add(AnsiString("WorkDiameter=")+ WorkDiameter);
str->Add(AnsiString("//=WorkSizeX"));
str->Add(AnsiString("WorkSizeY=")+ WorkSizeY);
str->Add(AnsiString("WorkPosition=")+ WorkPosition);
str->Add(AnsiString(" "));
str->Add(AnsiString("Speed=")+ Speed);
str->Add(AnsiString("JogSpeed=")+ JogSpeed);
str->Add(AnsiString("RevSpeed=")+ RevSpeed);
str->Add(AnsiString("Escape=")+ Escape);
str->Add(AnsiString(" "));
str->Add(AnsiString("FeedDirection=")+ FeedDirection);
str->Add(AnsiString("//0:Y, 1:X"));
str->Add(AnsiString("X_Pitch=")+ X_Pitch);
str->Add(AnsiString("Y_Pitch=")+ Y_Pitch);
str->Add(AnsiString("ProgramNumber=")+ ProgramNumber);
str->Add(AnsiString(" "));
str->Add(AnsiString("MinAngle=")+ MinAngle);
str->Add(AnsiString("MaxAngle=")+ MaxAngle);
str->Add(AnsiString(" "));
str->Add(AnsiString("ToolType=")+ ToolType);
str->Add(AnsiString("//0:torus,1:ball"));
//wolter_thiskness
str->Add(AnsiString("//wolter_thickness=")+ wolter_thickness);
str->Add(AnsiString("ToolRadiusFlycut=")+ ToolRadiusFlycut);
str->Add(AnsiString("//=Real tool radius - wolter_thickness"));
str->Add(AnsiString("WheelDiameterFlycut=")+ WheelRadiusFlycut*2.);
str->Add(AnsiString("--------------"));
str->Add(AnsiString("WheelRadiusFlycut=")+ WheelRadiusFlycut);
str->Add(AnsiString("LargeRadius=")+ LargeRadius);
str->Add(AnsiString("SmallRadius=")+ SmallRadius);
str->Add(AnsiString("--Roughness--"));
str->Add(AnsiString("Error(Roughness)BetweenLines=\n")+ RoughnessBetweenLines);
str->Add(AnsiString("Error(Roughness)AlongLine=\n")+ RoughnessAlongLine);
str->Add(AnsiString("-------------"));
str->Add(AnsiString("--ErrorComp--"));
str->Add(AnsiString("//0:false, 1:true"));
str->Add(AnsiString("ErrorComp=")+ (int)ErrorComp);
str->Add(AnsiString("ErrorCompFileName=")+ ErrorCompFileName);
};
double face::x_roughness(double xx,double yy)
{
if (FeedDirection==0){
double dzdx=gradX(xx,yy);
double dx = XPitch(xx,yy)*sqrt(1*1+dzdx*dzdx);
double r = LargeRadius + SmallRadius; //=WheelRadius
double roughness = dx*dx/r/4.;
return roughness;
}else{
double dzdx = gradX(xx,yy);
double ddzdxx = gradXX(xx,yy);
double tan_theta = sqrt(1./(1.+dzdx*dzdx));
double answer = ddzdxx*(XPitch(xx,yy)/8.)*tan_theta;
return (answer);
}
};
double face::y_roughness(double xx,double yy)
{
if (FeedDirection==0){
double dzdy = gradY(xx,yy);
double ddzdyy = gradYY(xx,yy);
double tan_theta = sqrt(1./(1.+dzdy*dzdy));
double answer = ddzdyy*(YPitch(xx,yy)/8.)*tan_theta;
return (answer);
}else{
double dzdy=gradY(xx,yy);
double dy = YPitch(xx,yy)*sqrt(1*1+dzdy*dzdy);
double r = SmallRadius; //=ToolRadius
double roughness = dy*dy/r/4.;
return roughness;
};
};
//981008
int face::LatticeDataOut (AnsiString filename){
char cmd[256];
ofstream fout;
fout.open(filename.c_str());
if (fout==NULL)
{
return(0);
}else{
if (FeedDirection==0){
// Lattice judgement
// j1:jmax
int jmax_temp = jmax[0];
for (int i=0;i<imax;i++) {
if (jmax_temp!=jmax[i]) {
fout.close();
ShowMessage("Lattice Error!(jmax[i])");
return(0);
};
};
// end of j1
//j2:x[i]
double x_temp;
for (int i=0;i<imax;i++) {
x_temp=x[i][0];
for (int j=0;j<jmax[0];j++){
if (fabs(x_temp-x[i][j])>1.0e-6) {
fout.close();
ShowMessage("Lattice Error!(x[i][j])");
return(0);
};
};
};
//end of j2
//j3:y[j]
double y_temp;
for (int j=0;j<jmax[0];j++) {
y_temp=y[0][j];
for (int i=0;i<imax;i++){
if (fabs(y_temp-y[i][j])>1.0e-6) {
fout.close();
ShowMessage("Lattice Error!(y[i][j])");
return(0);
};
};
};
//end of j3
//end of Lattice judgement
fout << imax <<' '<<jmax[0]<<endl;
for (int i=0;i<imax;i++){
sprintf(cmd,"%10.6lf",x[i][0]);
fout << cmd<<endl;
};
for (int j=0;j<jmax[0];j++){
sprintf(cmd,"%10.6lf",y[0][j]);
fout << cmd<<endl;
};
/////////////////////////////////
}else{
// Lattice judgement
// j1:jmax
int jmax_temp = jmax[0];
for (int i=0;i<imax;i++) {
if (jmax_temp!=jmax[i]) {
fout.close();
ShowMessage("Lattice Error!(jmax[i])");
return(0);
};
};
// end of j1
//j2:y[i]
double y_temp;
for (int i=0;i<imax;i++) {
y_temp=y[i][0];
for (int j=0;j<jmax[0];j++){
if (fabs(y_temp-y[i][j])>1.0e-6) {
fout.close();
ShowMessage("Lattice Error!(y[i][j])");
return(0);
};
};
};
//end of j2
//j3:x[j]
double x_temp;
for (int j=0;j<jmax[0];j++) {
x_temp=x[0][j];
for (int i=0;i<imax;i++){
if (fabs(x_temp-x[i][j])>1.0e-6) {
fout.close();
ShowMessage("Lattice Error!(x[i][j])");
return(0);
};
};
};
//end of j3
//end of Lattice judgement
fout << jmax[0] <<' '<<imax<<endl;
for (int j=0;j<jmax[0];j++){
sprintf(cmd,"%10.6lf",x[0][j]);
fout << cmd<<endl;
};
for (int i=0;i<imax;i++){
sprintf(cmd,"%10.6lf",y[i][0]);
fout << cmd<<endl;
};
/////////////////////////////////
};
fout.close();
return(1);
};
};//end of LatticeDataOut
void face::FlagErrorComp(bool flag){
ErrorComp =flag;
};
void face::CenterLine(AnsiString filename)
{
char text[256];
//open file
ofstream fout;
fout.open(filename.c_str());
if (fout==NULL) return;
vector machine;
fout.precision(9);
fout << " x y z x_machine y_machine z_machine"<<endl;
//Calculate Start-Point(xs,ys).End-Point(xe,ye)
double xstart,xend,xpitch;
double ystart,yend,ypitch;
if (FeedDirection==0){ //in case of FeedDirection==0(0:y,1:x)
ystart = -WorkPosition + WorkDiameter/1.9 ;
yend = -WorkPosition - WorkDiameter/1.9 ;
ypitch = YPitch(0,-WorkPosition);
xstart = 0. ;
xend = 0. ;
xpitch = 0. ;
}else{
xstart = WorkDiameter/1.9 ;
xend = -WorkDiameter/1.9 ;
xpitch = XPitch(0,-WorkPosition);
ystart = 0. ;
yend = 0. ;
ypitch = 0. ;
}
double xtemp = xstart;
double ytemp = ystart;
while ((xtemp>=xend)&&(ytemp>=yend)){
if ( InWorkArea( xtemp,ytemp) )
{
machine = MachinePosition(GetPosition(xtemp,ytemp));
sprintf(text," %9.6lf %9.6lf %9.6lf %9.6lf %9.6lf %9.6lf",
xtemp,ytemp, GetZ(xtemp,ytemp),
machine.getX(),machine.getY(),machine.getZ());
fout << text << endl;
}
xtemp -= xpitch;
ytemp -= ypitch;
};
//close file
fout.close();
}
bool face::isConflict(double x, double y)
{
bool result = false;
//wolter1yin2004/03/11
if(x>-2.71&&x<2.71) result = true;
if (x>128.68&&x<131.32) result = true;
//wolter2
//if (x<-128.8133&&x>-131.18685) result = true;
return result;
};
#endif;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -