diff --git a/src/GeomToIGES/GeomToIGES_GeomCurve.cxx b/src/GeomToIGES/GeomToIGES_GeomCurve.cxx index d53ba4c41e..e551302916 100644 --- a/src/GeomToIGES/GeomToIGES_GeomCurve.cxx +++ b/src/GeomToIGES/GeomToIGES_GeomCurve.cxx @@ -625,8 +625,8 @@ Handle(IGESData_IGESEntity) GeomToIGES_GeomCurve::TransferCurve Build.EvalXYZ((start->Value(U1)).XYZ(), Xs, Ys, Zs); Build.EvalXYZ((start->Value(U2)).XYZ(), Xe, Ye, Ze); gp_Elips2d E2d = gp_Elips2d(gp_Ax22d(gp::Origin2d(), gp::DX2d(), gp::DY2d()), - (start->MajorRadius()), - (start->MinorRadius())); + (start->MajorRadius() / GetUnit()), + (start->MinorRadius() / GetUnit())); Standard_Real A, B, C, D, E, F; E2d.Coefficients(A, C, B, D, E, F);//#59 rln 29.12.98 PRO17015 face 67 //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(U2)).XYZ(), Xe, Ye, Ze); gp_Hypr2d H2d = gp_Hypr2d (gp_Ax22d(gp::Origin2d(), gp::DX2d(), gp::DY2d()), - (start->MajorRadius()), - (start->MinorRadius())); + (start->MajorRadius() / GetUnit()), + (start->MinorRadius() / GetUnit())); Standard_Real A, B, C, D, E, F; H2d.Coefficients(A, C, B, D, E, F); diff --git a/src/GeomToIGES/GeomToIGES_GeomSurface.cxx b/src/GeomToIGES/GeomToIGES_GeomSurface.cxx index 4ee97570f1..cd70db17f8 100644 --- a/src/GeomToIGES/GeomToIGES_GeomSurface.cxx +++ b/src/GeomToIGES/GeomToIGES_GeomSurface.cxx @@ -506,8 +506,8 @@ Handle(IGESData_IGESEntity) GeomToIGES_GeomSurface::TransferSurface(const Handle Standard_Real A,B,C,D; start->Coefficients(A,B,C,D); D = -D;// because of difference in Geom_Plane class and Type 108 - gp_XYZ anAttach = start->Location().XYZ(); - aPlane->Init(A,B,C,D,0,anAttach,0); + gp_XYZ anAttach = start->Location().XYZ().Divided( GetUnit() ); + aPlane->Init (A, B, C, D / GetUnit(), 0, anAttach, 0); res = aPlane; return res; } @@ -604,7 +604,7 @@ Handle(IGESData_IGESEntity) GeomToIGES_GeomSurface::TransferSurface //#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())); //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); @@ -682,7 +682,7 @@ Handle(IGESData_IGESEntity) GeomToIGES_GeomSurface::TransferSurface //#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())); //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); @@ -754,7 +754,7 @@ Handle(IGESData_IGESEntity) GeomToIGES_GeomSurface::TransferSurface Handle(IGESGeom_Line) Axis = new IGESGeom_Line; //#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, 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))) { //#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; //#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, 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))) { //#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; 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); - gp_Ax1 Axe = Pln.Axis(); - Handle(Geom_Direction) mydir = new Geom_Direction(Axe.Direction()); - Handle(IGESGeom_Direction) aNormal = GV.TransferVector(mydir); + Handle(IGESGeom_Direction) aNormal = new IGESGeom_Direction; + aNormal->Init (aPln.Axis().Direction().XYZ()); - gp_Ax1 XAxe = Pln.XAxis(); - Handle(Geom_Direction) rdir = new Geom_Direction(XAxe.Direction()); - Handle(IGESGeom_Direction) refdir = GV.TransferVector(rdir); + Handle(IGESGeom_Direction) aRefDir = new IGESGeom_Direction; + aRefDir->Init (aPln.XAxis().Direction().XYZ()); - Plsurf->Init (aLocation, aNormal, refdir); + Plsurf->Init (aLocation, aNormal, aRefDir); res = Plsurf; return res; @@ -1128,24 +1125,21 @@ Handle(IGESData_IGESEntity) GeomToIGES_GeomSurface::TransferCylindricalSurface(c Handle(IGESSolid_CylindricalSurface) CylSurf = new IGESSolid_CylindricalSurface; 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); - gp_Ax1 Axe = Cyl.Axis(); - Handle(Geom_Direction) mydir = new Geom_Direction(Axe.Direction()); - Handle(IGESGeom_Direction) Axis = GV.TransferVector(mydir); + Handle(IGESGeom_Direction) anAxis = new IGESGeom_Direction; + anAxis->Init (aCyl.Axis().Direction().XYZ()); - gp_Ax1 XAxe = Cyl.XAxis(); - Handle(Geom_Direction) rdir = new Geom_Direction(XAxe.Direction()); - Handle(IGESGeom_Direction) refdir = GV.TransferVector(rdir); + Handle(IGESGeom_Direction) aRefDir = new IGESGeom_Direction; + aRefDir->Init (aCyl.XAxis().Direction().XYZ()); - Standard_Real radius = Cyl.Radius(); - - CylSurf->Init (aLocation, Axis, radius, refdir); + Standard_Real aRadius = aCyl.Radius() / GetUnit(); + + CylSurf->Init (aLocation, anAxis, aRadius, aRefDir); res = CylSurf; return res; } @@ -1171,10 +1165,9 @@ Handle(IGESData_IGESEntity) GeomToIGES_GeomSurface::TransferConicalSurface(const Handle(IGESSolid_ConicalSurface) ConSurf = new IGESSolid_ConicalSurface; GeomToIGES_GeomPoint GP(*this); - GeomToIGES_GeomVector GV(*this); gp_Cone Con = start->Cone(); - Standard_Real radius = Con.RefRadius(); + Standard_Real aRadius = Con.RefRadius() / GetUnit(); Standard_Real angle = Con.SemiAngle(); gp_Ax1 Axe = Con.Axis(); gp_Ax1 XAxe = Con.XAxis(); @@ -1189,13 +1182,13 @@ Handle(IGESData_IGESEntity) GeomToIGES_GeomSurface::TransferConicalSurface(const } Handle(IGESGeom_Point) aLocation = GP.TransferPoint(mypoint); - Handle(Geom_Direction) mydir = new Geom_Direction(Axe.Direction()); - Handle(IGESGeom_Direction) Axis = GV.TransferVector(mydir); + Handle(IGESGeom_Direction) anAxis = new IGESGeom_Direction; + anAxis->Init (Axe.Direction().XYZ()); - Handle(Geom_Direction) rdir = new Geom_Direction(XDir);//XAxe.Direction()); - Handle(IGESGeom_Direction) refdir = GV.TransferVector(rdir); + Handle(IGESGeom_Direction) aRefDir = new IGESGeom_Direction; + 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; return res; } @@ -1221,24 +1214,21 @@ Handle(IGESData_IGESEntity) GeomToIGES_GeomSurface::TransferSphericalSurface(con Handle(IGESSolid_SphericalSurface) SphSurf = new IGESSolid_SphericalSurface; 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); - gp_Ax1 Axe = Sph.Position().Axis(); - Handle(Geom_Direction) mydir = new Geom_Direction(Axe.Direction()); - Handle(IGESGeom_Direction) Axis = GV.TransferVector(mydir); + Handle(IGESGeom_Direction) anAxis = new IGESGeom_Direction; + anAxis->Init (aSph.Position().Axis().Direction().XYZ()); - gp_Ax1 XAxe = Sph.XAxis(); - Handle(Geom_Direction) rdir = new Geom_Direction(XAxe.Direction()); - Handle(IGESGeom_Direction) refdir = GV.TransferVector(rdir); + Handle(IGESGeom_Direction) aRefDir = new IGESGeom_Direction; + aRefDir->Init (aSph.XAxis().Direction().XYZ()); - 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; return res; } @@ -1258,25 +1248,22 @@ Handle(IGESData_IGESEntity) GeomToIGES_GeomSurface::TransferToroidalSurface(cons Handle(IGESSolid_ToroidalSurface) TorSurf = new IGESSolid_ToroidalSurface; 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); - gp_Ax1 Axe = Tor.Axis(); - Handle(Geom_Direction) mydir = new Geom_Direction(Axe.Direction()); - Handle(IGESGeom_Direction) Axis = GV.TransferVector(mydir); + Handle(IGESGeom_Direction) anAxis = new IGESGeom_Direction; + anAxis->Init (aTor.Axis().Direction().XYZ()); - gp_Ax1 XAxe = Tor.XAxis(); - Handle(Geom_Direction) rdir = new Geom_Direction(XAxe.Direction()); - Handle(IGESGeom_Direction) refdir = GV.TransferVector(rdir); + Handle(IGESGeom_Direction) aRefDir = new IGESGeom_Direction; + aRefDir->Init (aTor.XAxis().Direction().XYZ()); - Standard_Real major = Tor.MajorRadius(); - Standard_Real minor = Tor.MinorRadius(); + Standard_Real aMajor = aTor.MajorRadius() / GetUnit(); + Standard_Real aMinor = aTor.MinorRadius() / GetUnit(); - TorSurf->Init (aLocation, Axis, major, minor, refdir); + TorSurf->Init (aLocation, anAxis, aMajor, aMinor, aRefDir); res = TorSurf; return res; } diff --git a/src/IGESGeom/IGESGeom_ConicArc.cxx b/src/IGESGeom/IGESGeom_ConicArc.cxx index e6b628ee41..91f7ad5d30 100644 --- a/src/IGESGeom/IGESGeom_ConicArc.cxx +++ b/src/IGESGeom/IGESGeom_ConicArc.cxx @@ -256,9 +256,9 @@ IGESGeom_ConicArc::IGESGeom_ConicArc () { } Standard_Real cos2t; Standard_Real auxil; - if (Abs(term2)<= eps && Abs(term1)<= eps) { + if (Abs(term1)< gp::Resolution()) { cos2t = 1.; - auxil = 0.; + auxil = term2; } else { Standard_Real t2d = term2/term1; //skl 28.12.2001 diff --git a/tests/bugs/iges/bug25747 b/tests/bugs/iges/bug25747 new file mode 100644 index 0000000000..e04258846f --- /dev/null +++ b/tests/bugs/iges/bug25747 @@ -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