]> OCCT Git - occt-copy.git/commitdiff
0025194: It is necessary to orthogonalize transformation matrix in gp_Trsf and gp_Trs...
authornbv <nbv@opencascade.com>
Wed, 10 Sep 2014 07:28:19 +0000 (11:28 +0400)
committerifv <ifv@opencascade.com>
Mon, 24 Nov 2014 13:53:05 +0000 (16:53 +0300)
1. Method "SetValues()" for gp_Trsf2d class is added.
2. Method Orthogonalize for gp_Trsf2d and gp_Trsf classes was added.
3. Unused arguments from "SetValues()" method for gp_Trsf was deleted.
4. Output of AppParCurves_MultiPoint Dump  was corrected.
5. Method of right projected point choosing was corrected in ProjLib package.
6. Some test cases were changed according to their new behavior.

Conflicts:
src/BRepFill/BRepFill_LocationLaw.cxx
src/ProjLib/ProjLib_ComputeApproxOnPolarSurface.cxx
tests/de/iges_2/E6

14 files changed:
src/AppParCurves/AppParCurves_MultiPoint.cxx
src/BRepFill/BRepFill_LocationLaw.cxx
src/BRepFill/BRepFill_Pipe.cxx
src/BinTools/BinTools_LocationSet.cxx
src/GeomFill/GeomFill_Sweep.cxx
src/ProjLib/ProjLib_ComputeApproxOnPolarSurface.cxx
src/Prs3d/Prs3d_Presentation.cxx
src/PrsMgr/PrsMgr_Prs.cxx
src/TopTools/TopTools_LocationSet.cxx
src/Vrml/Vrml_MatrixTransform.cxx
src/gp/gp_Trsf.cdl
src/gp/gp_Trsf.cxx
src/gp/gp_Trsf2d.cdl
src/gp/gp_Trsf2d.cxx

index a9a00ef8814318c51bed0e4bb40b6ebb7f3814e9..7f11638e7e100cde29c43038d5a035268e3d47e4 100644 (file)
@@ -173,21 +173,30 @@ const gp_Pnt2d& AppParCurves_MultiPoint::Point2d (const Standard_Integer Index)
 void AppParCurves_MultiPoint::Dump(Standard_OStream& o) const
 {
   o << "AppParCurves_MultiPoint dump:" << endl;
-  o << "It contains " << NbPoints() << " 3d points and " << NbPoints2d() <<" 2d points." << endl;
-  /*
-    if (Dimension(i) == 3) {
-      for (Standard_Integer j = 1; j <= tabPoint->Length(); j++) {
-       o << " Pole No. " << j << ": " << endl;
-       o << " Pole x = " << (tabPoint->Value(i)->Point(j)).X() << endl;
-       o << " Pole y = " << (tabPoint->Value(i)->Point(j)).Y() << endl;
-       o << " Pole z = " << (tabPoint->Value(i)->Point(j)).Z() << endl;
-      }
+  const Standard_Integer  aNbPnts3D = NbPoints(),
+                          aNbPnts2D = NbPoints2d();
+  o << "It contains " << aNbPnts3D << " 3d points and " << aNbPnts2D <<" 2d points." << endl;
+  
+  if(aNbPnts3D > 0)
+  {
+    for(Standard_Integer i = tabPoint->Lower(); i <= tabPoint->Upper(); i++)
+    {
+      o << "3D-Point #" << i << endl;
+
+      o << " Pole x = " << (tabPoint->Value(i)/*->Point(j)*/).X() << endl;
+      o << " Pole y = " << (tabPoint->Value(i)/*->Point(j)*/).Y() << endl;
+      o << " Pole z = " << (tabPoint->Value(i)/*->Point(j)*/).Z() << endl;
     }
-    else {
-      for (Standard_Integer j = 1; j <= tabPoint->Length(); j++) {
-       o << " Pole No. " << j << ": " << endl;
-       o << " Pole x = " << (tabPoint->Value(i)->Point2d(j)).X() << endl;
-       o << " Pole y = " << (tabPoint->Value(i)->Point2d(j)).Y() << endl;
-      }
-*/
+  }
+  
+  if(aNbPnts2D > 0)
+  {
+    for(Standard_Integer i = tabPoint2d->Lower(); i <= tabPoint2d->Upper(); i++)
+    {
+      o << "2D-Point #" << i << endl;
+
+      o << " Pole x = " << (tabPoint2d->Value(i)/*->Point2d(j)*/).X() << endl;
+      o << " Pole y = " << (tabPoint2d->Value(i)/*->Point2d(j)*/).Y() << endl;
+    }
+  }
 }
index c86fec3c79b97674880b846b6eb9176753f7370a..5a02d83b98a7e4f78d711a8d20116cc9162b55b1 100644 (file)
@@ -5,8 +5,8 @@
 //
 // This file is part of Open CASCADE Technology software library.
 //
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
 // by the Free Software Foundation, with special exception defined in the file
 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
 // distribution for complete text of the license and disclaimer of any warranty.
@@ -14,6 +14,7 @@
 // Alternatively, this file may be used under the terms of Open CASCADE
 // commercial license or contractual agreement.
 
+
 #include <BRepFill_LocationLaw.ixx>
 
 #include <BRepTools_WireExplorer.hxx>
@@ -36,6 +37,7 @@
 #include <TColgp_Array1OfVec2d.hxx>
 #include <TColStd_SequenceOfInteger.hxx>
 #include <Precision.hxx>
+#include <BRepBuilderAPI_Transform.hxx>
 
 
 //=======================================================================
@@ -606,10 +608,11 @@ void BRepFill_LocationLaw::CurvilinearBounds(const Standard_Integer Index,
     gp_Trsf fila;
     fila.SetValues(M(1,1), M(1,2), M(1,3), V.X(),
                   M(2,1), M(2,2), M(2,3), V.Y(),
-                  M(3,1), M(3,2), M(3,3), V.Z(),
-                  1.e-12, 1.e-14);
-    TopLoc_Location Loc(fila);
-    W.Location(Loc.Multiplied(W.Location()));
+                  M(3,1), M(3,2), M(3,3), V.Z());
+    //TopLoc_Location Loc(fila);
+    //W.Location(Loc.Multiplied(W.Location()));
+    W = BRepBuilderAPI_Transform(W, fila, Standard_True); //copy
+    ///////////////////////////////////////////
   }
   else {
     W.Nullify();
index 5c4f57944df618fe88dc435b625e52078b14eb2c..aee0c01ce4f13054b42645c0ba99bbbd7c84b60e 100644 (file)
@@ -168,8 +168,7 @@ void BRepFill_Pipe::Perform(const TopoDS_Wire&  Spine,
   myLoc->Law(1)->D0(first, M, V);
     fila.SetValues(M(1,1), M(1,2), M(1,3), V.X(),
                   M(2,1), M(2,2), M(2,3), V.Y(),
-                  M(3,1), M(3,2), M(3,3), V.Z(),
-                  1.e-12, 1.e-14);
+                  M(3,1), M(3,2), M(3,3), V.Z());
 
   fila.Multiply(myTrsf);
   TopLoc_Location LocFirst(fila);
@@ -183,8 +182,7 @@ void BRepFill_Pipe::Perform(const TopoDS_Wire&  Spine,
 //    try { // Not good, but there are no other means to test SetValues
   fila.SetValues(M(1,1), M(1,2), M(1,3), V.X(),
                 M(2,1), M(2,2), M(2,3), V.Y(),
-                M(3,1), M(3,2), M(3,3), V.Z(),
-                1.e-12, 1.e-14);
+                M(3,1), M(3,2), M(3,3), V.Z());
   fila.Multiply(myTrsf);
   TopLoc_Location LocLast(fila);
   if (! myLoc->IsClosed() || LocFirst != LocLast) {
index b08d75a5711772385083fe91c524e52182e32cd3..343fdf83b57bc21931985c07aeef00f0e529ca47 100644 (file)
@@ -46,9 +46,7 @@ static Standard_IStream& operator >>(Standard_IStream& IS, gp_Trsf& T)
 
   T.SetValues(V1[0],V1[1],V1[2],V[0],
              V2[0],V2[1],V2[2],V[1],
-             V3[0],V3[1],V3[2],V[2],
-             Precision::Angular(),
-             Precision::Confusion());
+             V3[0],V3[1],V3[2],V[2]);
   return IS;
 }
 
index d0f7ebc9741dad9823e08bb927049a7ed6019377..a0800f13b6ce4332d09d091f9c2ceef1cba52b75 100644 (file)
@@ -526,8 +526,7 @@ static Standard_Boolean IsSweepParallelSpine (const Handle(GeomFill_LocationLaw)
 
   TfBegin.SetValues(GTfBegin(1,1), GTfBegin(1,2), GTfBegin(1,3), GTfBegin(1,4),
                    GTfBegin(2,1), GTfBegin(2,2), GTfBegin(2,3), GTfBegin(2,4),
-                   GTfBegin(3,1), GTfBegin(3,2), GTfBegin(3,3), GTfBegin(3,4),
-                   1.e-12, 1.e-14);
+                   GTfBegin(3,1), GTfBegin(3,2), GTfBegin(3,3), GTfBegin(3,4));
 
 // Get the last transformation
   theLoc->D0(aLast, M, VEnd);
@@ -537,8 +536,7 @@ static Standard_Boolean IsSweepParallelSpine (const Handle(GeomFill_LocationLaw)
 
   TfEnd.SetValues(GTfEnd(1,1), GTfEnd(1,2), GTfEnd(1,3), GTfEnd(1,4),
                  GTfEnd(2,1), GTfEnd(2,2), GTfEnd(2,3), GTfEnd(2,4),
-                 GTfEnd(3,1), GTfEnd(3,2), GTfEnd(3,3), GTfEnd(3,4),
-                 1.e-12, 1.e-14);
+                 GTfEnd(3,1), GTfEnd(3,2), GTfEnd(3,3), GTfEnd(3,4));
 
   Handle(Geom_Surface) aSurf = theSec->BSplineSurface();
   Standard_Real Umin;
@@ -610,8 +608,7 @@ static Standard_Boolean IsSweepParallelSpine (const Handle(GeomFill_LocationLaw)
       OCC_CATCH_SIGNALS
       Tf2.SetValues(Tf(1,1), Tf(1,2), Tf(1,3), Tf(1,4),
                    Tf(2,1), Tf(2,2), Tf(2,3), Tf(2,4),
-                   Tf(3,1), Tf(3,2), Tf(3,3), Tf(3,4),
-                   1.e-12, 1.e-14);
+                   Tf(3,1), Tf(3,2), Tf(3,3), Tf(3,4));
     }
     catch (Standard_ConstructionError) {
       IsTrsf = Standard_False;
@@ -798,8 +795,7 @@ static Standard_Boolean IsSweepParallelSpine (const Handle(GeomFill_LocationLaw)
 //        OCC_CATCH_SIGNALS
        Tf2.SetValues(Tf(1,1), Tf(1,2), Tf(1,3), Tf(1,4),
                      Tf(2,1), Tf(2,2), Tf(2,3), Tf(2,4),
-                     Tf(3,1), Tf(3,2), Tf(3,3), Tf(3,4),
-                     1.e-14, 1.e-15);
+                     Tf(3,1), Tf(3,2), Tf(3,3), Tf(3,4));
 //      }
 //      catch (Standard_ConstructionError) {
 //     IsTrsf = Standard_False;
index bae53c4bc04aa385d383c2a01b65b4a281c9a107..8e0ab0cc99c42eab3d5fe88143af46b23758f86b 100644 (file)
@@ -4,8 +4,8 @@
 //
 // This file is part of Open CASCADE Technology software library.
 //
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
 // by the Free Software Foundation, with special exception defined in the file
 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
 // distribution for complete text of the license and disclaimer of any warranty.
@@ -52,8 +52,6 @@
 
 #include <GeomAbs_SurfaceType.hxx>
 #include <GeomAbs_CurveType.hxx>
-#include <Handle_Adaptor3d_HCurve.hxx>
-#include <Handle_Adaptor3d_HSurface.hxx>
 #include <Adaptor3d_Surface.hxx>
 #include <Adaptor3d_Curve.hxx>
 #include <Adaptor3d_HSurface.hxx>
@@ -412,7 +410,7 @@ ProjLib_ComputeApproxOnPolarSurface::ProjLib_ComputeApproxOnPolarSurface
 {
   myTolerance = tol3d; //OCC217
   //myTolerance = Max(tolerance,Precision::PApproximation());
-  const Handle_Adaptor2d_HCurve2d InitCurve2d ;
+  const Handle(Adaptor2d_HCurve2d) InitCurve2d ;
   myBSpline = Perform(InitCurve2d,Curve,S);  
 } 
 
@@ -1059,14 +1057,91 @@ Handle(Adaptor2d_HCurve2d)
            (pntproj, Surf->Surface(), U0, V0, TolU, TolV) ;
          
          if (aLocateExtPS.IsDone())
-           if (aLocateExtPS.SquareDistance() < DistTol3d * DistTol3d) {  //OCC217
-           //if (aLocateExtPS.SquareDistance() < Tol3d * Tol3d) {
+          {
+           if (aLocateExtPS.SquareDistance() < DistTol3d * DistTol3d)
+            {  //OCC217
+              //if (aLocateExtPS.SquareDistance() < Tol3d * Tol3d) {
              (aLocateExtPS.Point()).Parameter(U0,V0);
              U1 = U0 + usens*uperiod;
              V1 = V0 + vsens*vperiod;
              Pts2d(i).SetCoord(U1,V1);
              myProjIsDone = Standard_True;
            }
+            else
+            {
+              Extrema_ExtPS aGlobalExtr(pntproj, Surf->Surface(), TolU, TolV);
+              if (aGlobalExtr.IsDone())
+              {
+                Standard_Real LocalMinSqDist = RealLast();
+                Standard_Integer imin = 0;
+                for (Standard_Integer isol = 1; isol <= aGlobalExtr.NbExt(); isol++)
+                {
+                  Standard_Real aSqDist = aGlobalExtr.SquareDistance(isol);
+                  if (aSqDist < LocalMinSqDist)
+                  {
+                    LocalMinSqDist = aSqDist;
+                    imin = isol;
+                  }
+                }
+                if (LocalMinSqDist < DistTol3d * DistTol3d)
+                {
+                  Standard_Real LocalU, LocalV;
+                  aGlobalExtr.Point(imin).Parameter(LocalU, LocalV);
+                  if (uperiod > 0. && Abs(U0 - LocalU) >= uperiod/2.)
+                  {
+                    if (LocalU > U0)
+                      usens = -1;
+                    else
+                      usens = 1;
+                  }
+                  if (vperiod > 0. && Abs(V0 - LocalV) >= vperiod/2.)
+                  {
+                    if (LocalV > V0)
+                      vsens = -1;
+                    else
+                      vsens = 1;
+                  }
+                  U0 = LocalU; V0 = LocalV;
+                  U1 = U0 + usens*uperiod;
+                  V1 = V0 + vsens*vperiod;
+                  Pts2d(i).SetCoord(U1,V1);
+                  myProjIsDone = Standard_True;
+
+                  if((i == 2) && (!IsEqual(uperiod, 0.0) || !IsEqual(vperiod, 0.0)))
+                  {//Make 1st point more precise for periodic surfaces
+                    const Standard_Integer aSize = 3;
+                    const gp_Pnt2d aP(Pts2d(2)); 
+                    Standard_Real aUpar[aSize], aVpar[aSize];
+                    Pts2d(1).Coord(aUpar[1], aVpar[1]);
+                    aUpar[0] = aUpar[1] - uperiod;
+                    aUpar[2] = aUpar[1] + uperiod;
+                    aVpar[0] = aVpar[1] - vperiod;
+                    aVpar[2] = aVpar[1] + vperiod;
+
+                    Standard_Real aSQdistMin = RealLast();
+                    Standard_Integer aBestUInd = 1, aBestVInd = 1;
+                    const Standard_Integer  aSizeU = IsEqual(uperiod, 0.0) ? 1 : aSize,
+                                            aSizeV = IsEqual(vperiod, 0.0) ? 1 : aSize;
+                    for(Standard_Integer uInd = 0; uInd < aSizeU; uInd++)
+                    {
+                      for(Standard_Integer vInd = 0; vInd < aSizeV; vInd++)
+                      {
+                        Standard_Real aSQdist = aP.SquareDistance(gp_Pnt2d(aUpar[uInd], aVpar[vInd]));
+                        if(aSQdist < aSQdistMin)
+                        {
+                          aSQdistMin = aSQdist;
+                          aBestUInd = uInd;
+                          aBestVInd = vInd;
+                        }
+                      }
+                    }
+
+                    Pts2d(1).SetCoord(aUpar[aBestUInd], aVpar[aBestVInd]);
+                  }//if(i == 2) condition
+                }
+              }
+            }
+          }
          if(!myProjIsDone && uperiod) {
            Standard_Real Uinf, Usup, Uaux;
            Uinf = Surf->Surface().FirstUParameter();
@@ -1544,16 +1619,16 @@ Handle(Geom2d_BSplineCurve)
   }
   Handle(Geom2d_BSplineCurve) DummyC2d =
     new Geom2d_BSplineCurve(DummyPoles, DummyKnots, DummyMults, 1);
-  Standard_CString Temp = "bs2d";
 #ifdef DRAW
+  Standard_CString Temp = "bs2d";
   DrawTrSurf::Set(Temp,DummyC2d);
 #endif
 //  DrawTrSurf::Set((Standard_CString ) "bs2d",DummyC2d);
   Handle(Geom2dAdaptor_HCurve) DDD = 
     Handle(Geom2dAdaptor_HCurve)::DownCast(InitCurve2d);
   
-  Temp = "initc2d";
 #ifdef DRAW
+  Temp = "initc2d";
   DrawTrSurf::Set(Temp,DDD->ChangeCurve2d().Curve());
 #endif
 //  DrawTrSurf::Set((Standard_CString ) "initc2d",DDD->ChangeCurve2d().Curve());
index 38d5a7cb97f43f28815b1a18890a6db2084c5c90..72c90481c0341b347f0026b4390e9c61e90453bd 100644 (file)
@@ -181,8 +181,7 @@ TColStd_Array2OfReal matrix(1,4,1,4);
   trsf.SetValues(
         matrix.Value(1,1),matrix.Value(1,2),matrix.Value(1,3),matrix.Value(1,4),
         matrix.Value(2,1),matrix.Value(2,2),matrix.Value(2,3),matrix.Value(2,4),
-        matrix.Value(3,1),matrix.Value(3,2),matrix.Value(3,3),matrix.Value(3,4),
-        0.001,0.0001);  
+        matrix.Value(3,1),matrix.Value(3,2),matrix.Value(3,3),matrix.Value(3,4));  
   Handle(Geom_Transformation) gtrsf = new Geom_Transformation(trsf); 
 
   return gtrsf;
index 0aa1d8db9120a032f65416d468358114f5fbf47e..4de32430d9f277ac95bcc1245b08445e7c2af1d4 100644 (file)
@@ -58,8 +58,7 @@ Handle(Graphic3d_Structure) PrsMgr_Prs::Compute(const Handle(Graphic3d_DataStruc
   Standard_Integer LC(AMatrix.LowerCol()),LR(AMatrix.LowerRow());
   TheTrsf.SetValues(AMatrix(LR,LC),AMatrix(LR,LC+1),AMatrix(LR,LC+2),AMatrix(LR,LC+3),
                    AMatrix(LR+1,LC),AMatrix(LR+1,LC+1),AMatrix(LR+1,LC+2),AMatrix(LR+1,LC+3),
-                   AMatrix(LR+2,LC),AMatrix(LR+2,LC+1),AMatrix(LR+2,LC+2),AMatrix(LR+2,LC+3),
-                   Precision::Angular(),Precision::Confusion());
+                   AMatrix(LR+2,LC),AMatrix(LR+2,LC+1),AMatrix(LR+2,LC+2),AMatrix(LR+2,LC+3));
    Handle(Geom_Transformation) G = new Geom_Transformation(TheTrsf);
   
   return myPresentation3d->Compute(aProjector,G);
@@ -90,8 +89,7 @@ void PrsMgr_Prs::Compute(const Handle(Graphic3d_DataStructureManager)& aProjecto
   Standard_Integer LC(AMatrix.LowerCol()),LR(AMatrix.LowerRow());
   TheTrsf.SetValues(AMatrix(LR,LC),AMatrix(LR,LC+1),AMatrix(LR,LC+2),AMatrix(LR,LC+3),
                    AMatrix(LR+1,LC),AMatrix(LR+1,LC+1),AMatrix(LR+1,LC+2),AMatrix(LR+1,LC+3),
-                   AMatrix(LR+2,LC),AMatrix(LR+2,LC+1),AMatrix(LR+2,LC+2),AMatrix(LR+2,LC+3),
-                   Precision::Angular(),Precision::Confusion());
+                   AMatrix(LR+2,LC),AMatrix(LR+2,LC+1),AMatrix(LR+2,LC+2),AMatrix(LR+2,LC+3));
   Handle(Geom_Transformation) G = new Geom_Transformation(TheTrsf);
 
 
index 5d43a4e783154eed713cda82e4a8b02810cdcf15..0fe53d55470676dc88561b9ab35b4a28da26704a 100644 (file)
@@ -229,9 +229,7 @@ static void ReadTrsf(gp_Trsf& T,
   
   T.SetValues(V1[0],V1[1],V1[2],V[0],
              V2[0],V2[1],V2[2],V[1],
-             V3[0],V3[1],V3[2],V[2],
-             Precision::Angular(),
-             Precision::Confusion());
+             V3[0],V3[1],V3[2],V[2]);
   return;
 }
 //=======================================================================
index 340f11e51dada191cc9a6512a795bbf8d6b9e6ee..92ceb791d9ec702d67d1d658eb9b7788f6e15959 100644 (file)
@@ -28,8 +28,7 @@ Vrml_MatrixTransform::Vrml_MatrixTransform()
   gp_Trsf T;
   T.SetValues ( 1, 0, 0, 0,
                0, 1, 0, 0,
-               0, 0, 1, 0,
-               Precision::Angular(), Precision::Confusion());
+               0, 0, 1, 0);
   T.SetScaleFactor(1); 
 
   myMatrix = T;
index d03e6a6f9dfe5c196f4b726795c2fd4505aa2bbf..55c2f5a816ffae0db57e1f96559ebf8503403145 100644 (file)
@@ -204,8 +204,7 @@ is
   SetValues(me : in out;
             a11, a12, a13, a14,
             a21, a22, a23, a24,
-            a31, a32, a33, a34 : Real;
-            Tolang, TolDist : Real)
+            a31, a32, a33, a34 : Real)
 
         ---Purpose: Sets the coefficients  of the transformation.  The
         --          transformation  of the  point  x,y,z is  the point
@@ -213,16 +212,11 @@ is
         --          
         --          x' = a11 x + a12 y + a13 z + a14
         --          y' = a21 x + a22 y + a23 z + a24
-        --          z' = a31 x + a32 y + a43 z + a34
-        --          
-        --          Tolang and  TolDist are  used  to  test  for  null
-        --          angles and null distances to determine the form of
-        --          the transformation (identity, translation, etc..).
+        --          z' = a31 x + a32 y + a33 z + a34
         --          
         --          The method Value(i,j) will return aij.
-        --          Raises ConstructionError if the determinant of  the aij is null. Or  if
-        --          the matrix as not a uniform scale.
-
+        --          Raises ConstructionError if the determinant of  the aij is null.
+        --          The matrix is orthogonalyzed before future using.
     raises
         ConstructionError from Standard
 
@@ -371,7 +365,9 @@ is
         ---C++: inline
         --- Purpose : Transformation of a triplet XYZ with a Trsf
 
-
+  Orthogonalize(me: in out)
+    is protected;
+        --- Purpose : Makes orthogonalization of "matrix"
 
 fields
 
index 22dfe1785e9f65ba2584f839cf1dba64aca3abdb..e1db13c63d33ff8a3289fb7677781ea139563c0a 100644 (file)
@@ -328,14 +328,7 @@ void gp_Trsf::SetValues(const Standard_Real a11,
                         const Standard_Real a31, 
                         const Standard_Real a32,
                         const Standard_Real a33, 
-                        const Standard_Real a34, 
-//                      const Standard_Real Tolang, 
-                        const Standard_Real , 
-                        const Standard_Real
-#ifndef No_Exception
-                                            TolDist
-#endif
-                       )
+                        const Standard_Real a34)
 {
   gp_XYZ col1(a11,a21,a31);
   gp_XYZ col2(a12,a22,a32);
@@ -347,63 +340,19 @@ void gp_Trsf::SetValues(const Standard_Real a11,
   Standard_Real As = s;
   if (As < 0) As = - As;
   Standard_ConstructionError_Raise_if
-    (As < gp::Resolution(),"gp_Trsf::SeValues, null determinant");
+    (As < gp::Resolution(),"gp_Trsf::SetValues, null determinant");
   if (s > 0)
     s = Pow(s,1./3.);
   else
     s = -Pow(-s,1./3.);
   M.Divide(s);
   
-  // check if the matrix is a rotation matrix
-  // the transposition should be the invert.
-  gp_Mat TM(M);
-  TM.Transpose();
-  TM.Multiply(M);
-  //
-  // don t trust the initial values !
-  //
-  gp_Mat anIdentity ;
-  anIdentity.SetIdentity() ;
-  TM.Subtract(anIdentity);
-  As = TM.Value(1,1);
-  if (As < 0) As = - As;
-  Standard_ConstructionError_Raise_if
-    (As > TolDist,"gp_Trsf::SeValues, non uniform");
-  As = TM.Value(1,2);
-  if (As < 0) As = - As;
-  Standard_ConstructionError_Raise_if
-    (As > TolDist,"gp_Trsf::SeValues, non uniform");
-  As = TM.Value(1,3);
-  if (As < 0) As = - As;
-  Standard_ConstructionError_Raise_if
-    (As > TolDist,"gp_Trsf::SeValues, non uniform");
-  As = TM.Value(2,1);
-  if (As < 0) As = - As;
-  Standard_ConstructionError_Raise_if
-    (As > TolDist,"gp_Trsf::SeValues, non uniform");
-  As = TM.Value(2,2);
-  if (As < 0) As = - As;
-  Standard_ConstructionError_Raise_if
-    (As > TolDist,"gp_Trsf::SeValues, non uniform");
-  As = TM.Value(2,3);
-  if (As < 0) As = - As;
-  Standard_ConstructionError_Raise_if
-    (As > TolDist,"gp_Trsf::SeValues, non uniform");
-  As = TM.Value(3,1);
-  if (As < 0) As = - As;
-  Standard_ConstructionError_Raise_if
-    (As > TolDist,"gp_Trsf::SeValues, non uniform");
-  As = TM.Value(3,2);
-  if (As < 0) As = - As;
-  Standard_ConstructionError_Raise_if
-    (As > TolDist,"gp_Trsf::SeValues, non uniform");
-  As = TM.Value(3,3);
-  if (As < 0) As = - As;
-  Standard_ConstructionError_Raise_if
-    (As > TolDist,"gp_Trsf::SeValues, non uniform");
   scale = s;
   shape = gp_CompoundTrsf;
+
   matrix = M;
+  Orthogonalize();
+  
   loc = col4;
 }
 
@@ -817,3 +766,42 @@ Standard_Boolean gp_Trsf::GetRotation (gp_XYZ&        theAxis,
   theAxis = aVec.XYZ();
   return Standard_True;
 }
+
+//=======================================================================
+//function : Orthogonalize
+//purpose  : 
+//=======================================================================
+void gp_Trsf::Orthogonalize()
+{
+  gp_Mat aTM(matrix);
+
+  gp_XYZ aV1 = aTM.Column(1);
+  gp_XYZ aV2 = aTM.Column(2);
+  gp_XYZ aV3 = aTM.Column(3);
+
+  aV1.Normalize();
+
+  aV2 -= aV1*(aV2.Dot(aV1));
+  aV2.Normalize();
+
+  aV3 -= aV1*(aV3.Dot(aV1)) + aV2*(aV3.Dot(aV2));
+  aV3.Normalize();
+
+  aTM.SetCols(aV1, aV2, aV3);
+
+  aV1 = aTM.Row(1);
+  aV2 = aTM.Row(2);
+  aV3 = aTM.Row(3);
+
+  aV1.Normalize();
+
+  aV2 -= aV1*(aV2.Dot(aV1));
+  aV2.Normalize();
+
+  aV3 -= aV1*(aV3.Dot(aV1)) + aV2*(aV3.Dot(aV2));
+  aV3.Normalize();
+
+  aTM.SetRows(aV1, aV2, aV3);
+
+  matrix = aTM;
+}
index b570808669b98be6536fd59c5df5c2ea8e8b1367..7e52ca2e5983c027b4b354519198d1af9f0461ae 100644 (file)
@@ -242,6 +242,31 @@ is
   Transforms (me; Coord : out XY)   is static;
         ---C++: inline    
         --- Purpose : Transforms  a doublet XY with a Trsf2d
+
+  SetValues(me : in out;
+            a11, a12, a13, a21, a22, a23 : Real)
+
+        ---Purpose: Sets the coefficients  of the transformation. The 
+         --         transformation  of the  point  x,y is  the point
+         --         x',y' with :
+         --
+         --         x' = a11 x + a12 y + a13
+         --         y' = a21 x + a22 y + a23
+         --
+         --         The method Value(i,j) will return aij.
+         --         Raises ConstructionError if the determinant of the aij is null.
+         --         If the matrix as not a uniform scale it will be orthogonalyzed before future using.
+
+    raises
+        ConstructionError from Standard
+
+    is static;
+        
+  Orthogonalize(me: in out)
+    is protected;
+        --- Purpose : Makes orthogonalization of "matrix"
+  
+
 fields
 
   scale  : Real;
index baed96957b603bec66a385eb3791c94583a4f1f6..e3f0a36654623a5d4f20a3fa45e26bd1ba87045b 100644 (file)
 void gp_Trsf2d::SetMirror (const gp_Ax2d& A)
 {
   shape = gp_Ax1Mirror;
-  scale = - 1.0;
   const gp_Dir2d& V = A.Direction ();
   const gp_Pnt2d& P = A.Location ();
   Standard_Real VX = V.X();
   Standard_Real VY = V.Y();
   Standard_Real X0 = P.X();
   Standard_Real Y0 = P.Y();
-  matrix.SetCol (1, gp_XY (1.0 - 2.0 * VX * VX, -2.0 * VX * VY));
-  matrix.SetCol (2, gp_XY (-2.0 * VX * VY, 1.0 - 2.0 * VY * VY));
 
-  loc.SetCoord  (-2.0 * ((VX * VX - 1.0) * X0 + (VX * VY * Y0)),
-                 -2.0 * ((VX * VY * X0) + (VY * VY - 1.0) * Y0));
+  SetValues(1.0-2.0*VX*VX, -2.0*VX*VY, -2.0*((VX * VX - 1.0)*X0 + (VX*VY*Y0)), 
+            -2.0*VX*VY, 1.0-2.0*VY*VY, -2.0*((VX*VY*X0)+(VY*VY-1.0)*Y0));
+
+  scale = - 1.0;
 }
 
 void gp_Trsf2d::SetTransformation (const gp_Ax2d& FromA1,
                                   const gp_Ax2d& ToA2)
 {
   shape = gp_CompoundTrsf;
-  scale = 1.0;
   //matrix from XOY to A2 :
   const gp_XY& V1 = ToA2.Direction().XY();
   gp_XY V2 (-V1.Y(), V1.X());
-  matrix.SetCol (1, V1);
-  matrix.SetCol (2, V2);
-  loc = ToA2.Location().XY();
+
+  SetValues(V1.X(), V2.X(), ToA2.Location().X(),
+            V1.Y(), V2.Y(), ToA2.Location().Y());
+
+  scale = 1.0;
+
   matrix.Transpose();
   loc.Multiply (matrix);
   loc.Reverse();
@@ -65,12 +66,14 @@ void gp_Trsf2d::SetTransformation (const gp_Ax2d& FromA1,
 void gp_Trsf2d::SetTransformation (const gp_Ax2d& A)
 {
   shape = gp_CompoundTrsf;
-  scale = 1.0;
   const gp_XY& V1 = A.Direction().XY();
   gp_XY V2 (-V1.Y(), V1.X());
-  matrix.SetCol (1, V1);
-  matrix.SetCol (2, V2);
-  loc = A.Location().XY();
+
+  SetValues(V1.X(), V2.X(), A.Location().X(),
+            V1.Y(), V2.Y(), A.Location().Y());
+
+  scale = 1.0;
+
   matrix.Transpose();
   loc.Multiply (matrix);
   loc.Reverse();
@@ -497,3 +500,73 @@ void gp_Trsf2d::PreMultiply (const gp_Trsf2d& T)
   }
 }
 
+//=======================================================================
+//function : SetValues
+//purpose  : 
+//=======================================================================
+void gp_Trsf2d::SetValues(const Standard_Real a11,
+                          const Standard_Real a12,
+                          const Standard_Real a13,
+                          const Standard_Real a21,
+                          const Standard_Real a22,
+                          const Standard_Real a23)
+{
+  gp_XY col1(a11,a21);
+  gp_XY col2(a12,a22);
+  gp_XY col3(a13,a23);
+  // compute the determinant
+  gp_Mat2d M(col1,col2);
+  Standard_Real s = M.Determinant();
+  Standard_Real As = s;
+  if (As < 0)
+    As = - As;
+  Standard_ConstructionError_Raise_if
+    (As < gp::Resolution(),"gp_Trsf2d::SetValues, null determinant");
+
+  if (s > 0)
+    s = sqrt(s);
+  else
+    s = sqrt(-s);
+  
+  M.Divide(s);
+
+  scale = s;
+  shape = gp_CompoundTrsf;
+
+  matrix = M;
+  Orthogonalize();
+  
+  loc = col3;
+}
+
+
+//=======================================================================
+//function : Orthogonalize
+//purpose  : 
+//=======================================================================
+void gp_Trsf2d::Orthogonalize()
+{
+  gp_Mat2d aTM(matrix);
+
+  gp_XY aV1 = aTM.Column(1);
+  gp_XY aV2 = aTM.Column(2);
+
+  aV1.Normalize();
+
+  aV2 -= aV1*(aV2.Dot(aV1));
+  aV2.Normalize();
+
+  aTM.SetCols(aV1, aV2);
+
+  aV1 = aTM.Row(1);
+  aV2 = aTM.Row(2);
+
+  aV1.Normalize();
+
+  aV2 -= aV1*(aV2.Dot(aV1));
+  aV2.Normalize();
+
+  aTM.SetRows(aV1, aV2);
+
+  matrix = aTM;
+}