1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-16 10:08:36 +03:00

0025747: Bad IGES file after import and export with different units

- Fixed ellipse curve radius scale
- Fixed hyperbola curve radius scale
- Fixed plane surface scale
- Fixed cylindrical, conical, spherical, toroidal radius and axis scale

Test case for issue CR25747
This commit is contained in:
dbv 2015-02-26 12:47:41 +03:00 committed by bugmaster
parent 31b1749c42
commit a1096551c9
4 changed files with 95 additions and 64 deletions

View File

@ -625,8 +625,8 @@ Handle(IGESData_IGESEntity) GeomToIGES_GeomCurve::TransferCurve
Build.EvalXYZ((start->Value(U1)).XYZ(), Xs, Ys, Zs); Build.EvalXYZ((start->Value(U1)).XYZ(), Xs, Ys, Zs);
Build.EvalXYZ((start->Value(U2)).XYZ(), Xe, Ye, Ze); Build.EvalXYZ((start->Value(U2)).XYZ(), Xe, Ye, Ze);
gp_Elips2d E2d = gp_Elips2d(gp_Ax22d(gp::Origin2d(), gp::DX2d(), gp::DY2d()), gp_Elips2d E2d = gp_Elips2d(gp_Ax22d(gp::Origin2d(), gp::DX2d(), gp::DY2d()),
(start->MajorRadius()), (start->MajorRadius() / GetUnit()),
(start->MinorRadius())); (start->MinorRadius() / GetUnit()));
Standard_Real A, B, C, D, E, F; Standard_Real A, B, C, D, E, F;
E2d.Coefficients(A, C, B, D, E, F);//#59 rln 29.12.98 PRO17015 face 67 E2d.Coefficients(A, C, B, D, E, F);//#59 rln 29.12.98 PRO17015 face 67
//gp_Elips2d returns 0.5*K not K //gp_Elips2d returns 0.5*K not K
@ -687,8 +687,8 @@ Handle(IGESData_IGESEntity) GeomToIGES_GeomCurve::TransferCurve
Build.EvalXYZ((start->Value(U1)).XYZ(), Xs, Ys, Zs); Build.EvalXYZ((start->Value(U1)).XYZ(), Xs, Ys, Zs);
Build.EvalXYZ((start->Value(U2)).XYZ(), Xe, Ye, Ze); Build.EvalXYZ((start->Value(U2)).XYZ(), Xe, Ye, Ze);
gp_Hypr2d H2d = gp_Hypr2d (gp_Ax22d(gp::Origin2d(), gp::DX2d(), gp::DY2d()), gp_Hypr2d H2d = gp_Hypr2d (gp_Ax22d(gp::Origin2d(), gp::DX2d(), gp::DY2d()),
(start->MajorRadius()), (start->MajorRadius() / GetUnit()),
(start->MinorRadius())); (start->MinorRadius() / GetUnit()));
Standard_Real A, B, C, D, E, F; Standard_Real A, B, C, D, E, F;
H2d.Coefficients(A, C, B, D, E, F); H2d.Coefficients(A, C, B, D, E, F);

View File

@ -506,8 +506,8 @@ Handle(IGESData_IGESEntity) GeomToIGES_GeomSurface::TransferSurface(const Handle
Standard_Real A,B,C,D; Standard_Real A,B,C,D;
start->Coefficients(A,B,C,D); start->Coefficients(A,B,C,D);
D = -D;// because of difference in Geom_Plane class and Type 108 D = -D;// because of difference in Geom_Plane class and Type 108
gp_XYZ anAttach = start->Location().XYZ(); gp_XYZ anAttach = start->Location().XYZ().Divided( GetUnit() );
aPlane->Init(A,B,C,D,0,anAttach,0); aPlane->Init (A, B, C, D / GetUnit(), 0, anAttach, 0);
res = aPlane; res = aPlane;
return res; return res;
} }
@ -604,7 +604,7 @@ Handle(IGESData_IGESEntity) GeomToIGES_GeomSurface::TransferSurface
//#30 rln 19.10.98 IGES axis = reversed CAS.CADE axis //#30 rln 19.10.98 IGES axis = reversed CAS.CADE axis
//Axis->Init(gp_XYZ(0.0, 0.0, 0.0), gp_XYZ(0.0, 0.0, 1.0/GetUnit())); //Axis->Init(gp_XYZ(0.0, 0.0, 0.0), gp_XYZ(0.0, 0.0, 1.0/GetUnit()));
//Surf->Init (Axis, Generatrix, U1, U2); //Surf->Init (Axis, Generatrix, U1, U2);
Axis->Init(gp_XYZ (0, 0, 1. / GetUnit()), gp_XYZ (0, 0, 0)); Axis->Init(gp_XYZ (0, 0, 1.), gp_XYZ (0, 0, 0));
Surf->Init (Axis, Generatrix, 2 * M_PI - U2, 2 * M_PI - U1); Surf->Init (Axis, Generatrix, 2 * M_PI - U2, 2 * M_PI - U1);
@ -682,7 +682,7 @@ Handle(IGESData_IGESEntity) GeomToIGES_GeomSurface::TransferSurface
//#30 rln 19.10.98 IGES axis = reversed CAS.CADE axis //#30 rln 19.10.98 IGES axis = reversed CAS.CADE axis
//Axis->Init(gp_XYZ(0.0, 0.0, 0.0), gp_XYZ(0.0, 0.0, 1.0/GetUnit())); //Axis->Init(gp_XYZ(0.0, 0.0, 0.0), gp_XYZ(0.0, 0.0, 1.0/GetUnit()));
//Surf->Init (Axis, Generatrix, U1, U2); //Surf->Init (Axis, Generatrix, U1, U2);
Axis->Init(gp_XYZ (0, 0, 1. / GetUnit()), gp_XYZ (0, 0, 0)); Axis->Init(gp_XYZ (0, 0, 1.), gp_XYZ (0, 0, 0));
Surf->Init (Axis, Generatrix, 2 * M_PI - U2, 2 * M_PI - U1); Surf->Init (Axis, Generatrix, 2 * M_PI - U2, 2 * M_PI - U1);
@ -754,7 +754,7 @@ Handle(IGESData_IGESEntity) GeomToIGES_GeomSurface::TransferSurface
Handle(IGESGeom_Line) Axis = new IGESGeom_Line; Handle(IGESGeom_Line) Axis = new IGESGeom_Line;
//#30 rln 19.10.98 IGES axis = reversed CAS.CADE axis //#30 rln 19.10.98 IGES axis = reversed CAS.CADE axis
//Axis->Init(gp_XYZ(0.0, 0.0, 0.0), gp_XYZ(0.0, 0.0, 1.0/GetUnit())); //Axis->Init(gp_XYZ(0.0, 0.0, 0.0), gp_XYZ(0.0, 0.0, 1.0/GetUnit()));
Axis->Init(gp_XYZ (0, 0, 1. / GetUnit()), gp_XYZ (0, 0, 0)); Axis->Init(gp_XYZ (0, 0, 1.), gp_XYZ (0, 0, 0));
if ( Gen->IsKind(STANDARD_TYPE(IGESGeom_CircularArc))) { if ( Gen->IsKind(STANDARD_TYPE(IGESGeom_CircularArc))) {
//#30 rln 19.10.98 Surf->Init (Axis, Gen, U1, U2); //#30 rln 19.10.98 Surf->Init (Axis, Gen, U1, U2);
@ -820,7 +820,7 @@ Handle(IGESData_IGESEntity) GeomToIGES_GeomSurface::TransferSurface
Handle(IGESGeom_Line) Axis = new IGESGeom_Line; Handle(IGESGeom_Line) Axis = new IGESGeom_Line;
//#30 rln 19.10.98 IGES axis = reversed CAS.CADE axis //#30 rln 19.10.98 IGES axis = reversed CAS.CADE axis
//Axis->Init(gp_XYZ(0.0, 0.0, 0.0), gp_XYZ(0.0, 0.0, 1.0/GetUnit())); //Axis->Init(gp_XYZ(0.0, 0.0, 0.0), gp_XYZ(0.0, 0.0, 1.0/GetUnit()));
Axis->Init(gp_XYZ (0, 0, 1. / GetUnit()), gp_XYZ (0, 0, 0)); Axis->Init(gp_XYZ (0, 0, 1.), gp_XYZ (0, 0, 0));
//:l6 abv: CTS22022: writing full tori: if ( Gen->IsKind(STANDARD_TYPE(IGESGeom_CircularArc))) { //:l6 abv: CTS22022: writing full tori: if ( Gen->IsKind(STANDARD_TYPE(IGESGeom_CircularArc))) {
//#30 rln 19.10.98 Surf->Init (Axis, Gen, U1, U2); //#30 rln 19.10.98 Surf->Init (Axis, Gen, U1, U2);
@ -1087,22 +1087,19 @@ Handle(IGESData_IGESEntity) GeomToIGES_GeomSurface::TransferPlaneSurface(const H
Handle(IGESSolid_PlaneSurface) Plsurf = new IGESSolid_PlaneSurface; Handle(IGESSolid_PlaneSurface) Plsurf = new IGESSolid_PlaneSurface;
GeomToIGES_GeomPoint GP(*this); GeomToIGES_GeomPoint GP(*this);
GeomToIGES_GeomVector GV(*this);
gp_Pln Pln = start->Pln(); gp_Pln aPln = start->Pln();
Handle(Geom_CartesianPoint) mypoint = new Geom_CartesianPoint(Pln.Location()); Handle(Geom_CartesianPoint) mypoint = new Geom_CartesianPoint (aPln.Location());
Handle(IGESGeom_Point) aLocation = GP.TransferPoint(mypoint); Handle(IGESGeom_Point) aLocation = GP.TransferPoint(mypoint);
gp_Ax1 Axe = Pln.Axis(); Handle(IGESGeom_Direction) aNormal = new IGESGeom_Direction;
Handle(Geom_Direction) mydir = new Geom_Direction(Axe.Direction()); aNormal->Init (aPln.Axis().Direction().XYZ());
Handle(IGESGeom_Direction) aNormal = GV.TransferVector(mydir);
gp_Ax1 XAxe = Pln.XAxis(); Handle(IGESGeom_Direction) aRefDir = new IGESGeom_Direction;
Handle(Geom_Direction) rdir = new Geom_Direction(XAxe.Direction()); aRefDir->Init (aPln.XAxis().Direction().XYZ());
Handle(IGESGeom_Direction) refdir = GV.TransferVector(rdir);
Plsurf->Init (aLocation, aNormal, refdir); Plsurf->Init (aLocation, aNormal, aRefDir);
res = Plsurf; res = Plsurf;
return res; return res;
@ -1128,24 +1125,21 @@ Handle(IGESData_IGESEntity) GeomToIGES_GeomSurface::TransferCylindricalSurface(c
Handle(IGESSolid_CylindricalSurface) CylSurf = new IGESSolid_CylindricalSurface; Handle(IGESSolid_CylindricalSurface) CylSurf = new IGESSolid_CylindricalSurface;
GeomToIGES_GeomPoint GP(*this); GeomToIGES_GeomPoint GP(*this);
GeomToIGES_GeomVector GV(*this);
gp_Cylinder Cyl = start->Cylinder(); gp_Cylinder aCyl = start->Cylinder();
Handle(Geom_CartesianPoint) mypoint = new Geom_CartesianPoint(Cyl.Location()); Handle(Geom_CartesianPoint) mypoint = new Geom_CartesianPoint (aCyl.Location());
Handle(IGESGeom_Point) aLocation = GP.TransferPoint(mypoint); Handle(IGESGeom_Point) aLocation = GP.TransferPoint(mypoint);
gp_Ax1 Axe = Cyl.Axis(); Handle(IGESGeom_Direction) anAxis = new IGESGeom_Direction;
Handle(Geom_Direction) mydir = new Geom_Direction(Axe.Direction()); anAxis->Init (aCyl.Axis().Direction().XYZ());
Handle(IGESGeom_Direction) Axis = GV.TransferVector(mydir);
gp_Ax1 XAxe = Cyl.XAxis(); Handle(IGESGeom_Direction) aRefDir = new IGESGeom_Direction;
Handle(Geom_Direction) rdir = new Geom_Direction(XAxe.Direction()); aRefDir->Init (aCyl.XAxis().Direction().XYZ());
Handle(IGESGeom_Direction) refdir = GV.TransferVector(rdir);
Standard_Real radius = Cyl.Radius(); Standard_Real aRadius = aCyl.Radius() / GetUnit();
CylSurf->Init (aLocation, Axis, radius, refdir); CylSurf->Init (aLocation, anAxis, aRadius, aRefDir);
res = CylSurf; res = CylSurf;
return res; return res;
} }
@ -1171,10 +1165,9 @@ Handle(IGESData_IGESEntity) GeomToIGES_GeomSurface::TransferConicalSurface(const
Handle(IGESSolid_ConicalSurface) ConSurf = new IGESSolid_ConicalSurface; Handle(IGESSolid_ConicalSurface) ConSurf = new IGESSolid_ConicalSurface;
GeomToIGES_GeomPoint GP(*this); GeomToIGES_GeomPoint GP(*this);
GeomToIGES_GeomVector GV(*this);
gp_Cone Con = start->Cone(); gp_Cone Con = start->Cone();
Standard_Real radius = Con.RefRadius(); Standard_Real aRadius = Con.RefRadius() / GetUnit();
Standard_Real angle = Con.SemiAngle(); Standard_Real angle = Con.SemiAngle();
gp_Ax1 Axe = Con.Axis(); gp_Ax1 Axe = Con.Axis();
gp_Ax1 XAxe = Con.XAxis(); gp_Ax1 XAxe = Con.XAxis();
@ -1189,13 +1182,13 @@ Handle(IGESData_IGESEntity) GeomToIGES_GeomSurface::TransferConicalSurface(const
} }
Handle(IGESGeom_Point) aLocation = GP.TransferPoint(mypoint); Handle(IGESGeom_Point) aLocation = GP.TransferPoint(mypoint);
Handle(Geom_Direction) mydir = new Geom_Direction(Axe.Direction()); Handle(IGESGeom_Direction) anAxis = new IGESGeom_Direction;
Handle(IGESGeom_Direction) Axis = GV.TransferVector(mydir); anAxis->Init (Axe.Direction().XYZ());
Handle(Geom_Direction) rdir = new Geom_Direction(XDir);//XAxe.Direction()); Handle(IGESGeom_Direction) aRefDir = new IGESGeom_Direction;
Handle(IGESGeom_Direction) refdir = GV.TransferVector(rdir); aRefDir->Init (XDir.XYZ());
ConSurf->Init (aLocation, Axis, radius, angle*180./M_PI, refdir); ConSurf->Init (aLocation, anAxis, aRadius, angle*180./M_PI, aRefDir);
res = ConSurf; res = ConSurf;
return res; return res;
} }
@ -1221,24 +1214,21 @@ Handle(IGESData_IGESEntity) GeomToIGES_GeomSurface::TransferSphericalSurface(con
Handle(IGESSolid_SphericalSurface) SphSurf = new IGESSolid_SphericalSurface; Handle(IGESSolid_SphericalSurface) SphSurf = new IGESSolid_SphericalSurface;
GeomToIGES_GeomPoint GP(*this); GeomToIGES_GeomPoint GP(*this);
GeomToIGES_GeomVector GV(*this);
gp_Sphere Sph = start->Sphere(); gp_Sphere aSph = start->Sphere();
Handle(Geom_CartesianPoint) mypoint = new Geom_CartesianPoint(Sph.Location()); Handle(Geom_CartesianPoint) mypoint = new Geom_CartesianPoint(aSph.Location());
Handle(IGESGeom_Point) aLocation = GP.TransferPoint(mypoint); Handle(IGESGeom_Point) aLocation = GP.TransferPoint(mypoint);
gp_Ax1 Axe = Sph.Position().Axis(); Handle(IGESGeom_Direction) anAxis = new IGESGeom_Direction;
Handle(Geom_Direction) mydir = new Geom_Direction(Axe.Direction()); anAxis->Init (aSph.Position().Axis().Direction().XYZ());
Handle(IGESGeom_Direction) Axis = GV.TransferVector(mydir);
gp_Ax1 XAxe = Sph.XAxis(); Handle(IGESGeom_Direction) aRefDir = new IGESGeom_Direction;
Handle(Geom_Direction) rdir = new Geom_Direction(XAxe.Direction()); aRefDir->Init (aSph.XAxis().Direction().XYZ());
Handle(IGESGeom_Direction) refdir = GV.TransferVector(rdir);
Standard_Real radius = Sph.Radius(); Standard_Real aRadius = aSph.Radius() / GetUnit();
SphSurf->Init (aLocation, radius, Axis, refdir); SphSurf->Init (aLocation, aRadius, anAxis, aRefDir);
res = SphSurf; res = SphSurf;
return res; return res;
} }
@ -1258,25 +1248,22 @@ Handle(IGESData_IGESEntity) GeomToIGES_GeomSurface::TransferToroidalSurface(cons
Handle(IGESSolid_ToroidalSurface) TorSurf = new IGESSolid_ToroidalSurface; Handle(IGESSolid_ToroidalSurface) TorSurf = new IGESSolid_ToroidalSurface;
GeomToIGES_GeomPoint GP(*this); GeomToIGES_GeomPoint GP(*this);
GeomToIGES_GeomVector GV(*this);
gp_Torus Tor = start->Torus(); gp_Torus aTor = start->Torus();
Handle(Geom_CartesianPoint) mypoint = new Geom_CartesianPoint(Tor.Location()); Handle(Geom_CartesianPoint) mypoint = new Geom_CartesianPoint (aTor.Location());
Handle(IGESGeom_Point) aLocation = GP.TransferPoint(mypoint); Handle(IGESGeom_Point) aLocation = GP.TransferPoint(mypoint);
gp_Ax1 Axe = Tor.Axis(); Handle(IGESGeom_Direction) anAxis = new IGESGeom_Direction;
Handle(Geom_Direction) mydir = new Geom_Direction(Axe.Direction()); anAxis->Init (aTor.Axis().Direction().XYZ());
Handle(IGESGeom_Direction) Axis = GV.TransferVector(mydir);
gp_Ax1 XAxe = Tor.XAxis(); Handle(IGESGeom_Direction) aRefDir = new IGESGeom_Direction;
Handle(Geom_Direction) rdir = new Geom_Direction(XAxe.Direction()); aRefDir->Init (aTor.XAxis().Direction().XYZ());
Handle(IGESGeom_Direction) refdir = GV.TransferVector(rdir);
Standard_Real major = Tor.MajorRadius(); Standard_Real aMajor = aTor.MajorRadius() / GetUnit();
Standard_Real minor = Tor.MinorRadius(); Standard_Real aMinor = aTor.MinorRadius() / GetUnit();
TorSurf->Init (aLocation, Axis, major, minor, refdir); TorSurf->Init (aLocation, anAxis, aMajor, aMinor, aRefDir);
res = TorSurf; res = TorSurf;
return res; return res;
} }

View File

@ -256,9 +256,9 @@ IGESGeom_ConicArc::IGESGeom_ConicArc () { }
Standard_Real cos2t; Standard_Real cos2t;
Standard_Real auxil; Standard_Real auxil;
if (Abs(term2)<= eps && Abs(term1)<= eps) { if (Abs(term1)< gp::Resolution()) {
cos2t = 1.; cos2t = 1.;
auxil = 0.; auxil = term2;
} }
else { else {
Standard_Real t2d = term2/term1; //skl 28.12.2001 Standard_Real t2d = term2/term1; //skl 28.12.2001

44
tests/bugs/iges/bug25747 Normal file
View File

@ -0,0 +1,44 @@
puts "========"
puts "OCC25747"
puts "========"
puts ""
######################################
# Bad IGES file after import and export with different units
######################################
catch {exec rm ${imagedir}/OCC25747.igs}
# default OCCT unit for reading
param xstep.cascade.unit MM
param write.iges.unit M
param write.iges.brep.mode 1
# good IGES file
ReadIges D [locate_data_file bug25747_pencil.igs]
XShow D
vtop
vfit
vsetdispmode 1
vdump ${imagedir}/${casename}_1.png
WriteIges D ${imagedir}/OCC25747.igs
# bad IGES file after export
ReadIges T ${imagedir}/OCC25747.igs
XShow T
vtop
vfit
vsetdispmode 1
vdump ${imagedir}/${casename}_2.png
# Check image
set y 205.
checkcolor 20 $y 0.0588 0.0588 0.8
checkcolor 210 $y 0.5058 0.5764 0.0588
checkcolor 330 $y 0.0588 0.0588 0.8
checkcolor 360 $y 0.6862 0.4039 0.3333
checkcolor 400 $y 0.1215 0.1215 0.7529