diff -uprN GeomTools/GeomTools.cxx "GeomTools - patch/GeomTools.cxx"
--- GeomTools/GeomTools.cxx	2022-02-01 21:05:58.000000000 +0900
+++ "GeomTools - patch/GeomTools.cxx"	2022-04-13 12:05:34.529594900 +0900
@@ -15,6 +15,12 @@
 // commercial license or contractual agreement.
 
 
+#include <gp_Pnt2d.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Dir2d.hxx>
+#include <gp_Dir.hxx>
+#include <gp_Ax1.hxx>
+#include <gp_Ax3.hxx>
 #include <Geom2d_Curve.hxx>
 #include <Geom_Curve.hxx>
 #include <Geom_Surface.hxx>
@@ -110,3 +116,127 @@ void GeomTools::GetReal(Standard_IStream
   IS.width(anOldWide);
   theValue = Strtod(buffer, NULL);
 }
+
+//=======================================================================
+//function : GetPnt2d
+//purpose  : 
+//=======================================================================
+
+void GeomTools::GetPnt2d(Standard_IStream& IS, gp_Pnt2d& theValue)
+{
+  Standard_Real X = 0., Y = 0.;
+  GeomTools::GetReal(IS, X);
+  GeomTools::GetReal(IS, Y);
+  theValue.SetCoord(X, Y);
+}
+
+//=======================================================================
+//function : GetPnt
+//purpose  : 
+//=======================================================================
+
+void GeomTools::GetPnt(Standard_IStream& IS, gp_Pnt& theValue)
+{
+  Standard_Real X = 0., Y = 0., Z = 0.;
+  GeomTools::GetReal(IS, X);
+  GeomTools::GetReal(IS, Y);
+  GeomTools::GetReal(IS, Z);
+  theValue.SetCoord(X, Y, Z);
+}
+
+//=======================================================================
+//function : GetDir2d
+//purpose  : 
+//=======================================================================
+
+static Standard_Boolean Check(const gp_Dir2d& D, Standard_Real X, Standard_Real Y)
+{
+  return gp_Vec2d(D.XY()).Angle(gp_Vec2d(X, Y)) <= gp::Resolution();
+}
+
+void GeomTools::GetDir2d(Standard_IStream& IS, gp_Dir2d& theValue)
+{
+  Standard_Real X = 0., Y = 0.;
+  GeomTools::GetReal(IS, X);
+  GeomTools::GetReal(IS, Y);
+  theValue.SetCoord(X, Y);
+  if (Check(theValue, X, Y))
+  {
+    const_cast<gp_XY&>(theValue.XY()).SetCoord(X, Y);
+  }
+}
+
+//=======================================================================
+//function : GetDir
+//purpose  : 
+//=======================================================================
+
+static Standard_Boolean Check(const gp_Dir& D, Standard_Real X, Standard_Real Y, Standard_Real Z)
+{
+  return gp_Vec(D.XYZ()).Angle(gp_Vec(X, Y, Z)) <= gp::Resolution();
+}
+
+static Standard_Boolean Check(const gp_Dir& D, const gp_Dir& D2)
+{
+  return gp_Vec(D.XYZ()).Angle(gp_Vec(D2.XYZ())) <= gp::Resolution();
+}
+
+void GeomTools::GetDir(Standard_IStream& IS, gp_Dir& theValue)
+{
+  Standard_Real X = 0., Y = 0., Z = 0.;
+  GeomTools::GetReal(IS, X);
+  GeomTools::GetReal(IS, Y);
+  GeomTools::GetReal(IS, Z);
+  theValue.SetCoord(X, Y, Z);
+  if (Check(theValue, X, Y, Z))
+  {
+    const_cast<gp_XYZ&>(theValue.XYZ()).SetCoord(X, Y, Z);
+  }
+}
+
+//=======================================================================
+//function : GetAx1
+//purpose  : 
+//=======================================================================
+
+void GeomTools::GetAx1(Standard_IStream& IS, gp_Ax1& theValue)
+{
+  gp_Pnt P(0., 0., 0.);
+  gp_Dir D(1., 0., 0.);
+  GeomTools::GetPnt(IS, P);
+  GeomTools::GetDir(IS, D);
+  gp_Ax1 ax1(P, D);
+  if (Check(ax1.Direction(), D))
+  {
+    const_cast<gp_XYZ&>(ax1.Direction().XYZ()) = D.XYZ();
+  }
+  theValue = ax1;
+}
+
+//=======================================================================
+//function : GetAx3
+//purpose  : 
+//=======================================================================
+
+void GeomTools::GetAx3(Standard_IStream& IS, gp_Ax3& theValue)
+{
+  gp_Pnt P(0., 0., 0.);
+  gp_Dir A(1., 0., 0.), AX(1., 0., 0.), AY(1., 0., 0.);
+  GeomTools::GetPnt(IS, P);
+  GeomTools::GetDir(IS, A);
+  GeomTools::GetDir(IS, AX);
+  GeomTools::GetDir(IS, AY);
+  gp_Ax3 ax3(P, A, AX);
+  if (Check(ax3.Direction(), A) &&
+      Check(ax3.XDirection(), AX) &&
+      Check(ax3.YDirection(), AY))
+  {
+    const_cast<gp_XYZ&>(ax3.Direction().XYZ()) = A.XYZ();
+    const_cast<gp_XYZ&>(ax3.XDirection().XYZ()) = AX.XYZ();
+    const_cast<gp_XYZ&>(ax3.YDirection().XYZ()) = AY.XYZ();
+  }
+  if (AY.DotCross(A, AX) < 0)
+    ax3.YReverse();
+  theValue = ax3;
+}
+
diff -uprN GeomTools/GeomTools.hxx "GeomTools - patch/GeomTools.hxx"
--- GeomTools/GeomTools.hxx	2022-02-01 21:05:58.000000000 +0900
+++ "GeomTools - patch/GeomTools.hxx"	2022-04-13 12:01:47.192496700 +0900
@@ -24,6 +24,12 @@
 #include <Standard_OStream.hxx>
 #include <Standard_IStream.hxx>
 #include <Standard_Real.hxx>
+class gp_Pnt2d;
+class gp_Pnt;
+class gp_Dir2d;
+class gp_Dir;
+class gp_Ax1;
+class gp_Ax3;
 class Geom_Surface;
 class Geom_Curve;
 class Geom2d_Curve;
@@ -78,6 +84,24 @@ public:
   //! Reads the Standard_Real value from the stream. Zero is read
   //! in case of error
   Standard_EXPORT static void GetReal (Standard_IStream& IS, Standard_Real& theValue);
+  
+  //! Reads the gp_Pnt2d value from the stream.
+  Standard_EXPORT static void GetPnt2d (Standard_IStream& IS, gp_Pnt2d& theValue);
+  
+  //! Reads the gp_Pnt value from the stream.
+  Standard_EXPORT static void GetPnt (Standard_IStream& IS, gp_Pnt& theValue);
+  
+  //! Reads the gp_Dir2d value from the stream.
+  Standard_EXPORT static void GetDir2d (Standard_IStream& IS, gp_Dir2d& theValue);
+  
+  //! Reads the gp_Dir value from the stream.
+  Standard_EXPORT static void GetDir (Standard_IStream& IS, gp_Dir& theValue);
+  
+  //! Reads the gp_Ax1 value from the stream.
+  Standard_EXPORT static void GetAx1(Standard_IStream& IS, gp_Ax1& theValue);
+  
+  //! Reads the gp_Ax3 value from the stream.
+  Standard_EXPORT static void GetAx3(Standard_IStream& IS, gp_Ax3& theValue);
 
 
 
diff -uprN GeomTools/GeomTools_Curve2dSet.cxx "GeomTools - patch/GeomTools_Curve2dSet.cxx"
--- GeomTools/GeomTools_Curve2dSet.cxx	2022-02-01 21:05:58.000000000 +0900
+++ "GeomTools - patch/GeomTools_Curve2dSet.cxx"	2022-04-13 11:18:04.029931800 +0900
@@ -510,35 +510,6 @@ void  GeomTools_Curve2dSet::Write(Standa
 
 
 //=======================================================================
-//function : ReadPnt2d
-//purpose  : 
-//=======================================================================
-
-static Standard_IStream& operator>>(Standard_IStream& IS, gp_Pnt2d& P)
-{
-  Standard_Real X=0.,Y=0.;
-  GeomTools::GetReal(IS, X);
-  GeomTools::GetReal(IS, Y);
-  P.SetCoord(X,Y);
-  return IS;
-}
-
-//=======================================================================
-//function : ReadDir2d
-//purpose  : 
-//=======================================================================
-
-static Standard_IStream& operator>>(Standard_IStream& IS, gp_Dir2d& D)
-{
-  Standard_Real X=0.,Y=0.;
-  GeomTools::GetReal(IS, X);
-  GeomTools::GetReal(IS, Y);
-  D.SetCoord(X,Y);
-  return IS;
-}
-
-
-//=======================================================================
 //function : ReadCurve2d
 //purpose  : 
 //=======================================================================
@@ -548,7 +519,8 @@ static Standard_IStream& operator>>(Stan
 {
   gp_Pnt2d P(0.,0.);
   gp_Dir2d AX(1.,0.);
-  IS >> P >> AX;
+  GeomTools::GetPnt2d(IS, P);
+  GeomTools::GetDir2d(IS, AX);
   L = new Geom2d_Line(P,AX);
   return IS;
 }
@@ -564,7 +536,9 @@ static Standard_IStream& operator>>(Stan
   gp_Pnt2d P(0.,0.);
   gp_Dir2d AX(1.,0.),AY(1.,0.);
   Standard_Real R=0.;
-  IS >> P >> AX >> AY;
+  GeomTools::GetPnt2d(IS, P);
+  GeomTools::GetDir2d(IS, AX);
+  GeomTools::GetDir2d(IS, AY);
   GeomTools::GetReal(IS, R);
   C = new Geom2d_Circle(gp_Ax22d(P,AX,AY),R);
   return IS;
@@ -581,7 +555,9 @@ static Standard_IStream& operator>>(Stan
   gp_Pnt2d P(0.,0.);
   gp_Dir2d AX(1.,0.),AY(1.,0.);
   Standard_Real R1=0.,R2=0.;
-  IS >> P >> AX >> AY;
+  GeomTools::GetPnt2d(IS, P);
+  GeomTools::GetDir2d(IS, AX);
+  GeomTools::GetDir2d(IS, AY);
   GeomTools::GetReal(IS, R1);
   GeomTools::GetReal(IS, R2);
   E = new Geom2d_Ellipse(gp_Ax22d(P,AX,AY),R1,R2);
@@ -599,7 +575,9 @@ static Standard_IStream& operator>>(Stan
   gp_Pnt2d P(0.,0.);
   gp_Dir2d AX(1.,0.),AY(1.,0.);
   Standard_Real R1=0.;
-  IS >> P >> AX >> AY;
+  GeomTools::GetPnt2d(IS, P);
+  GeomTools::GetDir2d(IS, AX);
+  GeomTools::GetDir2d(IS, AY);
   GeomTools::GetReal(IS, R1);
   C = new Geom2d_Parabola(gp_Ax22d(P,AX,AY),R1);
   return IS;
@@ -616,7 +594,9 @@ static Standard_IStream& operator>>(Stan
   gp_Pnt2d P(0.,0.);
   gp_Dir2d AX(1.,0.),AY(1.,0.);
   Standard_Real R1=0.,R2=0.;
-  IS >> P >> AX >> AY;
+  GeomTools::GetPnt2d(IS, P);
+  GeomTools::GetDir2d(IS, AX);
+  GeomTools::GetDir2d(IS, AY);
   GeomTools::GetReal(IS, R1);
   GeomTools::GetReal(IS, R2);
   H = new Geom2d_Hyperbola(gp_Ax22d(P,AX,AY),R1,R2);
@@ -642,7 +622,7 @@ static Standard_IStream& operator>>(Stan
   TColStd_Array1OfReal weights(1,degree+1);
   
   for (i = 1; i <= degree+1; i++) {
-    IS >> poles(i);
+    GeomTools::GetPnt2d(IS, poles(i));
     if (rational)
       GeomTools::GetReal(IS, weights(i));
   }
@@ -674,7 +654,7 @@ static Standard_IStream& operator>>(Stan
   TColStd_Array1OfReal weights(1,nbpoles);
 
   for (i = 1; i <= nbpoles; i++) {
-    IS >> poles(i);
+    GeomTools::GetPnt2d(IS, poles(i));
     if (rational)
       GeomTools::GetReal(IS, weights(i));
   }
diff -uprN GeomTools/GeomTools_CurveSet.cxx "GeomTools - patch/GeomTools_CurveSet.cxx"
--- GeomTools/GeomTools_CurveSet.cxx	2022-02-01 21:05:58.000000000 +0900
+++ "GeomTools - patch/GeomTools_CurveSet.cxx"	2022-04-13 11:01:19.047716700 +0900
@@ -527,37 +527,6 @@ void  GeomTools_CurveSet::Write(Standard
 
 
 //=======================================================================
-//function : ReadPnt
-//purpose  : 
-//=======================================================================
-
-static Standard_IStream& operator>>(Standard_IStream& IS, gp_Pnt& P)
-{
-  Standard_Real X=0.,Y=0.,Z=0.;
-  GeomTools::GetReal(IS, X);
-  GeomTools::GetReal(IS, Y);
-  GeomTools::GetReal(IS, Z);
-  P.SetCoord(X,Y,Z);
-  return IS;
-}
-
-//=======================================================================
-//function : ReadDir
-//purpose  : 
-//=======================================================================
-
-static Standard_IStream& operator>>(Standard_IStream& IS, gp_Dir& D)
-{
-  Standard_Real X=0.,Y=0.,Z=0.;
-  GeomTools::GetReal(IS, X);
-  GeomTools::GetReal(IS, Y);
-  GeomTools::GetReal(IS, Z);
-  D.SetCoord(X,Y,Z);
-  return IS;
-}
-
-
-//=======================================================================
 //function : ReadCurve
 //purpose  : 
 //=======================================================================
@@ -567,7 +536,8 @@ static Standard_IStream& operator>>(Stan
 {
   gp_Pnt P(0.,0.,0.);
   gp_Dir AX(1.,0.,0.);
-  IS >> P >> AX;
+  GeomTools::GetPnt(IS, P);
+  GeomTools::GetDir(IS, AX);
   L = new Geom_Line(P,AX);
   return IS;
 }
@@ -583,7 +553,10 @@ static Standard_IStream& operator>>(Stan
   gp_Pnt P(0.,0.,0.);
   gp_Dir A(1.,0.,0.),AX(1.,0.,0.),AY(1.,0.,0.);
   Standard_Real R=0.;
-  IS >> P >> A >> AX >> AY;
+  GeomTools::GetPnt(IS, P);
+  GeomTools::GetDir(IS, A);
+  GeomTools::GetDir(IS, AX);
+  GeomTools::GetDir(IS, AY);
   GeomTools::GetReal(IS, R);
   C = new Geom_Circle(gp_Ax2(P,A,AX),R);
   return IS;
@@ -600,7 +573,10 @@ static Standard_IStream& operator>>(Stan
   gp_Pnt P(0.,0.,0.);
   gp_Dir A(1.,0.,0.),AX(1.,0.,0.),AY(1.,0.,0.);
   Standard_Real R1=0.,R2=0.;
-  IS >> P >> A >> AX >> AY;
+  GeomTools::GetPnt(IS, P);
+  GeomTools::GetDir(IS, A);
+  GeomTools::GetDir(IS, AX);
+  GeomTools::GetDir(IS, AY);
   GeomTools::GetReal(IS, R1);
   GeomTools::GetReal(IS, R2);
   E = new Geom_Ellipse(gp_Ax2(P,A,AX),R1,R2);
@@ -618,7 +594,10 @@ static Standard_IStream& operator>>(Stan
   gp_Pnt P(0.,0.,0.);
   gp_Dir A(1.,0.,0.),AX(1.,0.,0.),AY(1.,0.,0.);
   Standard_Real R1=0.;
-  IS >> P >> A >> AX >> AY;
+  GeomTools::GetPnt(IS, P);
+  GeomTools::GetDir(IS, A);
+  GeomTools::GetDir(IS, AX);
+  GeomTools::GetDir(IS, AY);
   GeomTools::GetReal(IS, R1);
   C = new Geom_Parabola(gp_Ax2(P,A,AX),R1);
   return IS;
@@ -635,7 +614,10 @@ static Standard_IStream& operator>>(Stan
   gp_Pnt P(0.,0.,0.);
   gp_Dir A(1.,0.,0.),AX(1.,0.,0.),AY(1.,0.,0.);
   Standard_Real R1=0.,R2=0.;
-  IS >> P >> A >> AX >> AY;
+  GeomTools::GetPnt(IS, P);
+  GeomTools::GetDir(IS, A);
+  GeomTools::GetDir(IS, AX);
+  GeomTools::GetDir(IS, AY);
   GeomTools::GetReal(IS, R1);
   GeomTools::GetReal(IS, R2);
   H = new Geom_Hyperbola(gp_Ax2(P,A,AX),R1,R2);
@@ -661,7 +643,7 @@ static Standard_IStream& operator>>(Stan
   TColStd_Array1OfReal weights(1,degree+1);
   
   for (i = 1; i <= degree+1; i++) {
-    IS >> poles(i);
+    GeomTools::GetPnt(IS, poles(i));
     if (rational)
       GeomTools::GetReal(IS, weights(i));
   }
@@ -694,7 +676,7 @@ static Standard_IStream& operator>>(Stan
   TColStd_Array1OfReal weights(1,nbpoles);
   
   for (i = 1; i <= nbpoles; i++) {
-    IS >> poles(i);
+    GeomTools::GetPnt(IS, poles(i));
     if (rational)
       GeomTools::GetReal(IS, weights(i));
   }
@@ -742,7 +724,7 @@ static Standard_IStream& operator>>(Stan
   Standard_Real p=0.;
   GeomTools::GetReal(IS, p);
   gp_Dir D(1.,0.,0.);
-  IS >> D;
+  GeomTools::GetDir(IS, D);
   Handle(Geom_Curve) BC = GeomTools_CurveSet::ReadCurve(IS);
   C = new Geom_OffsetCurve(BC,p,D);
   return IS;
diff -uprN GeomTools/GeomTools_SurfaceSet.cxx "GeomTools - patch/GeomTools_SurfaceSet.cxx"
--- GeomTools/GeomTools_SurfaceSet.cxx	2022-02-01 21:05:58.000000000 +0900
+++ "GeomTools - patch/GeomTools_SurfaceSet.cxx"	2022-04-13 11:00:37.677366900 +0900
@@ -647,54 +647,6 @@ void  GeomTools_SurfaceSet::Write(Standa
 
 
 //=======================================================================
-//function : ReadPnt
-//purpose  : 
-//=======================================================================
-
-static Standard_IStream& operator>>(Standard_IStream& IS, gp_Pnt& P)
-{
-  Standard_Real X=0.,Y=0.,Z=0.;
-  GeomTools::GetReal(IS, X);
-  GeomTools::GetReal(IS, Y);
-  GeomTools::GetReal(IS, Z);
-  P.SetCoord(X,Y,Z);
-  return IS;
-}
-
-//=======================================================================
-//function : ReadDir
-//purpose  : 
-//=======================================================================
-
-static Standard_IStream& operator>>(Standard_IStream& IS, gp_Dir& D)
-{
-  Standard_Real X=0.,Y=0.,Z=0.;
-  GeomTools::GetReal(IS, X);
-  GeomTools::GetReal(IS, Y);
-  GeomTools::GetReal(IS, Z);
-  D.SetCoord(X,Y,Z);
-  return IS;
-}
-
-//=======================================================================
-//function : ReadAx3
-//purpose  : 
-//=======================================================================
-
-static Standard_IStream& operator>>(Standard_IStream& IS, gp_Ax3& A3)
-{
-  gp_Pnt P(0.,0.,0.);
-  gp_Dir A(1.,0.,0.),AX(1.,0.,0.),AY(1.,0.,0.);
-  IS >> P >> A >> AX >> AY;
-  gp_Ax3 ax3(P,A,AX);
-  if (AY.DotCross(A,AX) < 0)
-    ax3.YReverse();
-  A3 = ax3;
-  return IS;
-}
-
-
-//=======================================================================
 //function : operator>>
 //purpose  : 
 //=======================================================================
@@ -703,7 +655,7 @@ static Standard_IStream& operator>>(Stan
 				    Handle(Geom_Plane)& S)
 {
   gp_Ax3 A;
-  IS >> A;
+  GeomTools::GetAx3(IS, A);
   S = new Geom_Plane(A);
   return IS;
 }
@@ -718,7 +670,7 @@ static Standard_IStream& operator>>(Stan
 {
   gp_Ax3 A;
   Standard_Real R=0.;
-  IS >> A;
+  GeomTools::GetAx3(IS, A);
   GeomTools::GetReal(IS, R);
   S = new Geom_CylindricalSurface(A,R);
   return IS;
@@ -734,7 +686,7 @@ static Standard_IStream& operator>>(Stan
 {
   gp_Ax3 A;
   Standard_Real R=0.,Ang=0.;
-  IS >> A;
+  GeomTools::GetAx3(IS, A);
   GeomTools::GetReal(IS, R);
   GeomTools::GetReal(IS, Ang);
   S = new Geom_ConicalSurface(A,Ang,R);
@@ -751,7 +703,7 @@ static Standard_IStream& operator>>(Stan
 {
   gp_Ax3 A;
   Standard_Real R=0.;
-  IS >> A;
+  GeomTools::GetAx3(IS, A);
   GeomTools::GetReal(IS, R);
   S = new Geom_SphericalSurface(A,R);
   return IS;
@@ -767,7 +719,7 @@ static Standard_IStream& operator>>(Stan
 {
   gp_Ax3 A;
   Standard_Real R1=0.,R2=0.;
-  IS >> A;
+  GeomTools::GetAx3(IS, A);
   GeomTools::GetReal(IS, R1);
   GeomTools::GetReal(IS, R2);
   S = new Geom_ToroidalSurface(A,R1,R2);
@@ -783,7 +735,7 @@ static Standard_IStream& operator>>(Stan
 				    Handle(Geom_SurfaceOfLinearExtrusion)& S)
 {
   gp_Dir D(1.,0.,0.);
-  IS >> D;
+  GeomTools::GetDir(IS, D);
   Handle(Geom_Curve) C = GeomTools_CurveSet::ReadCurve(IS);
   S = new Geom_SurfaceOfLinearExtrusion(C,D);
   return IS;
@@ -797,11 +749,10 @@ static Standard_IStream& operator>>(Stan
 static Standard_IStream& operator>>(Standard_IStream& IS,
 				    Handle(Geom_SurfaceOfRevolution)& S)
 {
-  gp_Pnt P(0.,0.,0.);
-  gp_Dir D(1.,0.,0.);
-  IS >> P >> D;
+  gp_Ax1 A;
+  GeomTools::GetAx1(IS, A);
   Handle(Geom_Curve) C = GeomTools_CurveSet::ReadCurve(IS);
-  S = new Geom_SurfaceOfRevolution(C,gp_Ax1(P,D));
+  S = new Geom_SurfaceOfRevolution(C,A);
   return IS;
 }
 
@@ -823,7 +774,7 @@ static Standard_IStream& operator>>(Stan
   Standard_Integer i,j;
   for (i = 1; i <= udegree+1; i++) {
     for (j = 1; j <= vdegree+1; j++) {
-      IS >> poles(i,j);
+      GeomTools::GetPnt(IS, poles(i,j));
       if (urational || vrational)
 	GeomTools::GetReal(IS, weights(i,j));
     }
@@ -859,7 +810,7 @@ static Standard_IStream& operator>>(Stan
   Standard_Integer i,j;
   for (i = 1; i <= nbupoles; i++) {
     for (j = 1; j <= nbvpoles; j++) {
-      IS >> poles(i,j);
+      GeomTools::GetPnt(IS, poles(i,j));
       if (urational || vrational)
 	GeomTools::GetReal(IS, weights(i,j));
     }
