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
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;
+ }
+ }
}
//
// 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.
// 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>
#include <TColgp_Array1OfVec2d.hxx>
#include <TColStd_SequenceOfInteger.hxx>
#include <Precision.hxx>
+#include <BRepBuilderAPI_Transform.hxx>
//=======================================================================
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();
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);
// 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) {
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;
}
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);
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;
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;
// 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;
//
// 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.
#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>
{
myTolerance = tol3d; //OCC217
//myTolerance = Max(tolerance,Precision::PApproximation());
- const Handle_Adaptor2d_HCurve2d InitCurve2d ;
+ const Handle(Adaptor2d_HCurve2d) InitCurve2d ;
myBSpline = Perform(InitCurve2d,Curve,S);
}
(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();
}
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());
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;
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);
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);
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;
}
//=======================================================================
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;
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
--
-- 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
---C++: inline
--- Purpose : Transformation of a triplet XYZ with a Trsf
-
+ Orthogonalize(me: in out)
+ is protected;
+ --- Purpose : Makes orthogonalization of "matrix"
fields
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);
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;
}
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;
+}
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;
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();
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();
}
}
+//=======================================================================
+//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;
+}