1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-09-03 14:10:33 +03:00

0025194: It is necessary to orthogonalize transformation matrix in gp_Trsf and gp_Trsf2d classes

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
This commit is contained in:
nbv
2014-09-10 11:28:19 +04:00
committed by ifv
parent 657b3ae503
commit 71c8570833
14 changed files with 292 additions and 137 deletions

View File

@@ -173,21 +173,30 @@ const gp_Pnt2d& AppParCurves_MultiPoint::Point2d (const Standard_Integer Index)
void AppParCurves_MultiPoint::Dump(Standard_OStream& o) const void AppParCurves_MultiPoint::Dump(Standard_OStream& o) const
{ {
o << "AppParCurves_MultiPoint dump:" << endl; o << "AppParCurves_MultiPoint dump:" << endl;
o << "It contains " << NbPoints() << " 3d points and " << NbPoints2d() <<" 2d points." << endl; const Standard_Integer aNbPnts3D = NbPoints(),
/* aNbPnts2D = NbPoints2d();
if (Dimension(i) == 3) { o << "It contains " << aNbPnts3D << " 3d points and " << aNbPnts2D <<" 2d points." << endl;
for (Standard_Integer j = 1; j <= tabPoint->Length(); j++) {
o << " Pole No. " << j << ": " << endl; if(aNbPnts3D > 0)
o << " Pole x = " << (tabPoint->Value(i)->Point(j)).X() << endl; {
o << " Pole y = " << (tabPoint->Value(i)->Point(j)).Y() << endl; for(Standard_Integer i = tabPoint->Lower(); i <= tabPoint->Upper(); i++)
o << " Pole z = " << (tabPoint->Value(i)->Point(j)).Z() << endl; {
} 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; if(aNbPnts2D > 0)
o << " Pole x = " << (tabPoint->Value(i)->Point2d(j)).X() << endl; {
o << " Pole y = " << (tabPoint->Value(i)->Point2d(j)).Y() << endl; 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;
}
}
} }

View File

@@ -5,8 +5,8 @@
// //
// This file is part of Open CASCADE Technology software library. // This file is part of Open CASCADE Technology software library.
// //
// This library is free software; you can redistribute it and / or modify it // This library is free software; you can redistribute it and/or modify it under
// under the terms of the GNU Lesser General Public version 2.1 as published // 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 // 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 // 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. // 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 // Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement. // commercial license or contractual agreement.
#include <BRepFill_LocationLaw.ixx> #include <BRepFill_LocationLaw.ixx>
#include <BRepTools_WireExplorer.hxx> #include <BRepTools_WireExplorer.hxx>
@@ -36,6 +37,7 @@
#include <TColgp_Array1OfVec2d.hxx> #include <TColgp_Array1OfVec2d.hxx>
#include <TColStd_SequenceOfInteger.hxx> #include <TColStd_SequenceOfInteger.hxx>
#include <Precision.hxx> #include <Precision.hxx>
#include <BRepBuilderAPI_Transform.hxx>
//======================================================================= //=======================================================================
@@ -606,10 +608,11 @@ void BRepFill_LocationLaw::CurvilinearBounds(const Standard_Integer Index,
gp_Trsf fila; gp_Trsf fila;
fila.SetValues(M(1,1), M(1,2), M(1,3), V.X(), 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(2,1), M(2,2), M(2,3), V.Y(),
M(3,1), M(3,2), M(3,3), V.Z(), M(3,1), M(3,2), M(3,3), V.Z());
1.e-12, 1.e-14); //TopLoc_Location Loc(fila);
TopLoc_Location Loc(fila); //W.Location(Loc.Multiplied(W.Location()));
W.Location(Loc.Multiplied(W.Location())); W = BRepBuilderAPI_Transform(W, fila, Standard_True); //copy
///////////////////////////////////////////
} }
else { else {
W.Nullify(); W.Nullify();

View File

@@ -168,8 +168,7 @@ void BRepFill_Pipe::Perform(const TopoDS_Wire& Spine,
myLoc->Law(1)->D0(first, M, V); myLoc->Law(1)->D0(first, M, V);
fila.SetValues(M(1,1), M(1,2), M(1,3), V.X(), 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(2,1), M(2,2), M(2,3), V.Y(),
M(3,1), M(3,2), M(3,3), V.Z(), M(3,1), M(3,2), M(3,3), V.Z());
1.e-12, 1.e-14);
fila.Multiply(myTrsf); fila.Multiply(myTrsf);
TopLoc_Location LocFirst(fila); 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 // 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(), 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(2,1), M(2,2), M(2,3), V.Y(),
M(3,1), M(3,2), M(3,3), V.Z(), M(3,1), M(3,2), M(3,3), V.Z());
1.e-12, 1.e-14);
fila.Multiply(myTrsf); fila.Multiply(myTrsf);
TopLoc_Location LocLast(fila); TopLoc_Location LocLast(fila);
if (! myLoc->IsClosed() || LocFirst != LocLast) { if (! myLoc->IsClosed() || LocFirst != LocLast) {

View 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], T.SetValues(V1[0],V1[1],V1[2],V[0],
V2[0],V2[1],V2[2],V[1], V2[0],V2[1],V2[2],V[1],
V3[0],V3[1],V3[2],V[2], V3[0],V3[1],V3[2],V[2]);
Precision::Angular(),
Precision::Confusion());
return IS; return IS;
} }

View 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), 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(2,1), GTfBegin(2,2), GTfBegin(2,3), GTfBegin(2,4),
GTfBegin(3,1), GTfBegin(3,2), GTfBegin(3,3), GTfBegin(3,4), GTfBegin(3,1), GTfBegin(3,2), GTfBegin(3,3), GTfBegin(3,4));
1.e-12, 1.e-14);
// Get the last transformation // Get the last transformation
theLoc->D0(aLast, M, VEnd); 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), 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(2,1), GTfEnd(2,2), GTfEnd(2,3), GTfEnd(2,4),
GTfEnd(3,1), GTfEnd(3,2), GTfEnd(3,3), GTfEnd(3,4), GTfEnd(3,1), GTfEnd(3,2), GTfEnd(3,3), GTfEnd(3,4));
1.e-12, 1.e-14);
Handle(Geom_Surface) aSurf = theSec->BSplineSurface(); Handle(Geom_Surface) aSurf = theSec->BSplineSurface();
Standard_Real Umin; Standard_Real Umin;
@@ -610,8 +608,7 @@ static Standard_Boolean IsSweepParallelSpine (const Handle(GeomFill_LocationLaw)
OCC_CATCH_SIGNALS OCC_CATCH_SIGNALS
Tf2.SetValues(Tf(1,1), Tf(1,2), Tf(1,3), Tf(1,4), 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(2,1), Tf(2,2), Tf(2,3), Tf(2,4),
Tf(3,1), Tf(3,2), Tf(3,3), Tf(3,4), Tf(3,1), Tf(3,2), Tf(3,3), Tf(3,4));
1.e-12, 1.e-14);
} }
catch (Standard_ConstructionError) { catch (Standard_ConstructionError) {
IsTrsf = Standard_False; IsTrsf = Standard_False;
@@ -798,8 +795,7 @@ static Standard_Boolean IsSweepParallelSpine (const Handle(GeomFill_LocationLaw)
// OCC_CATCH_SIGNALS // OCC_CATCH_SIGNALS
Tf2.SetValues(Tf(1,1), Tf(1,2), Tf(1,3), Tf(1,4), 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(2,1), Tf(2,2), Tf(2,3), Tf(2,4),
Tf(3,1), Tf(3,2), Tf(3,3), Tf(3,4), Tf(3,1), Tf(3,2), Tf(3,3), Tf(3,4));
1.e-14, 1.e-15);
// } // }
// catch (Standard_ConstructionError) { // catch (Standard_ConstructionError) {
// IsTrsf = Standard_False; // IsTrsf = Standard_False;

View File

@@ -4,8 +4,8 @@
// //
// This file is part of Open CASCADE Technology software library. // This file is part of Open CASCADE Technology software library.
// //
// This library is free software; you can redistribute it and / or modify it // This library is free software; you can redistribute it and/or modify it under
// under the terms of the GNU Lesser General Public version 2.1 as published // 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 // 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 // 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. // distribution for complete text of the license and disclaimer of any warranty.
@@ -52,8 +52,6 @@
#include <GeomAbs_SurfaceType.hxx> #include <GeomAbs_SurfaceType.hxx>
#include <GeomAbs_CurveType.hxx> #include <GeomAbs_CurveType.hxx>
#include <Handle_Adaptor3d_HCurve.hxx>
#include <Handle_Adaptor3d_HSurface.hxx>
#include <Adaptor3d_Surface.hxx> #include <Adaptor3d_Surface.hxx>
#include <Adaptor3d_Curve.hxx> #include <Adaptor3d_Curve.hxx>
#include <Adaptor3d_HSurface.hxx> #include <Adaptor3d_HSurface.hxx>
@@ -412,7 +410,7 @@ ProjLib_ComputeApproxOnPolarSurface::ProjLib_ComputeApproxOnPolarSurface
{ {
myTolerance = tol3d; //OCC217 myTolerance = tol3d; //OCC217
//myTolerance = Max(tolerance,Precision::PApproximation()); //myTolerance = Max(tolerance,Precision::PApproximation());
const Handle_Adaptor2d_HCurve2d InitCurve2d ; const Handle(Adaptor2d_HCurve2d) InitCurve2d ;
myBSpline = Perform(InitCurve2d,Curve,S); myBSpline = Perform(InitCurve2d,Curve,S);
} }
@@ -1059,14 +1057,91 @@ Handle(Adaptor2d_HCurve2d)
(pntproj, Surf->Surface(), U0, V0, TolU, TolV) ; (pntproj, Surf->Surface(), U0, V0, TolU, TolV) ;
if (aLocateExtPS.IsDone()) 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); (aLocateExtPS.Point()).Parameter(U0,V0);
U1 = U0 + usens*uperiod; U1 = U0 + usens*uperiod;
V1 = V0 + vsens*vperiod; V1 = V0 + vsens*vperiod;
Pts2d(i).SetCoord(U1,V1); Pts2d(i).SetCoord(U1,V1);
myProjIsDone = Standard_True; 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) { if(!myProjIsDone && uperiod) {
Standard_Real Uinf, Usup, Uaux; Standard_Real Uinf, Usup, Uaux;
Uinf = Surf->Surface().FirstUParameter(); Uinf = Surf->Surface().FirstUParameter();
@@ -1544,16 +1619,16 @@ Handle(Geom2d_BSplineCurve)
} }
Handle(Geom2d_BSplineCurve) DummyC2d = Handle(Geom2d_BSplineCurve) DummyC2d =
new Geom2d_BSplineCurve(DummyPoles, DummyKnots, DummyMults, 1); new Geom2d_BSplineCurve(DummyPoles, DummyKnots, DummyMults, 1);
Standard_CString Temp = "bs2d";
#ifdef DRAW #ifdef DRAW
Standard_CString Temp = "bs2d";
DrawTrSurf::Set(Temp,DummyC2d); DrawTrSurf::Set(Temp,DummyC2d);
#endif #endif
// DrawTrSurf::Set((Standard_CString ) "bs2d",DummyC2d); // DrawTrSurf::Set((Standard_CString ) "bs2d",DummyC2d);
Handle(Geom2dAdaptor_HCurve) DDD = Handle(Geom2dAdaptor_HCurve) DDD =
Handle(Geom2dAdaptor_HCurve)::DownCast(InitCurve2d); Handle(Geom2dAdaptor_HCurve)::DownCast(InitCurve2d);
Temp = "initc2d";
#ifdef DRAW #ifdef DRAW
Temp = "initc2d";
DrawTrSurf::Set(Temp,DDD->ChangeCurve2d().Curve()); DrawTrSurf::Set(Temp,DDD->ChangeCurve2d().Curve());
#endif #endif
// DrawTrSurf::Set((Standard_CString ) "initc2d",DDD->ChangeCurve2d().Curve()); // DrawTrSurf::Set((Standard_CString ) "initc2d",DDD->ChangeCurve2d().Curve());

View File

@@ -181,8 +181,7 @@ TColStd_Array2OfReal matrix(1,4,1,4);
trsf.SetValues( trsf.SetValues(
matrix.Value(1,1),matrix.Value(1,2),matrix.Value(1,3),matrix.Value(1,4), 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(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), matrix.Value(3,1),matrix.Value(3,2),matrix.Value(3,3),matrix.Value(3,4));
0.001,0.0001);
Handle(Geom_Transformation) gtrsf = new Geom_Transformation(trsf); Handle(Geom_Transformation) gtrsf = new Geom_Transformation(trsf);
return gtrsf; return gtrsf;

View File

@@ -58,8 +58,7 @@ Handle(Graphic3d_Structure) PrsMgr_Prs::Compute(const Handle(Graphic3d_DataStruc
Standard_Integer LC(AMatrix.LowerCol()),LR(AMatrix.LowerRow()); 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), 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+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), AMatrix(LR+2,LC),AMatrix(LR+2,LC+1),AMatrix(LR+2,LC+2),AMatrix(LR+2,LC+3));
Precision::Angular(),Precision::Confusion());
Handle(Geom_Transformation) G = new Geom_Transformation(TheTrsf); Handle(Geom_Transformation) G = new Geom_Transformation(TheTrsf);
return myPresentation3d->Compute(aProjector,G); 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()); 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), 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+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), AMatrix(LR+2,LC),AMatrix(LR+2,LC+1),AMatrix(LR+2,LC+2),AMatrix(LR+2,LC+3));
Precision::Angular(),Precision::Confusion());
Handle(Geom_Transformation) G = new Geom_Transformation(TheTrsf); Handle(Geom_Transformation) G = new Geom_Transformation(TheTrsf);

View File

@@ -229,9 +229,7 @@ static void ReadTrsf(gp_Trsf& T,
T.SetValues(V1[0],V1[1],V1[2],V[0], T.SetValues(V1[0],V1[1],V1[2],V[0],
V2[0],V2[1],V2[2],V[1], V2[0],V2[1],V2[2],V[1],
V3[0],V3[1],V3[2],V[2], V3[0],V3[1],V3[2],V[2]);
Precision::Angular(),
Precision::Confusion());
return; return;
} }
//======================================================================= //=======================================================================

View File

@@ -28,8 +28,7 @@ Vrml_MatrixTransform::Vrml_MatrixTransform()
gp_Trsf T; gp_Trsf T;
T.SetValues ( 1, 0, 0, 0, T.SetValues ( 1, 0, 0, 0,
0, 1, 0, 0, 0, 1, 0, 0,
0, 0, 1, 0, 0, 0, 1, 0);
Precision::Angular(), Precision::Confusion());
T.SetScaleFactor(1); T.SetScaleFactor(1);
myMatrix = T; myMatrix = T;

View File

@@ -204,8 +204,7 @@ is
SetValues(me : in out; SetValues(me : in out;
a11, a12, a13, a14, a11, a12, a13, a14,
a21, a22, a23, a24, a21, a22, a23, a24,
a31, a32, a33, a34 : Real; a31, a32, a33, a34 : Real)
Tolang, TolDist : Real)
---Purpose: Sets the coefficients of the transformation. The ---Purpose: Sets the coefficients of the transformation. The
-- transformation of the point x,y,z is the point -- transformation of the point x,y,z is the point
@@ -213,16 +212,11 @@ is
-- --
-- x' = a11 x + a12 y + a13 z + a14 -- x' = a11 x + a12 y + a13 z + a14
-- y' = a21 x + a22 y + a23 z + a24 -- y' = a21 x + a22 y + a23 z + a24
-- z' = a31 x + a32 y + a43 z + a34 -- z' = a31 x + a32 y + a33 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..).
-- --
-- The method Value(i,j) will return aij. -- The method Value(i,j) will return aij.
-- Raises ConstructionError if the determinant of the aij is null. Or if -- Raises ConstructionError if the determinant of the aij is null.
-- the matrix as not a uniform scale. -- The matrix is orthogonalyzed before future using.
raises raises
ConstructionError from Standard ConstructionError from Standard
@@ -371,7 +365,9 @@ is
---C++: inline ---C++: inline
--- Purpose : Transformation of a triplet XYZ with a Trsf --- Purpose : Transformation of a triplet XYZ with a Trsf
Orthogonalize(me: in out)
is protected;
--- Purpose : Makes orthogonalization of "matrix"
fields fields

View File

@@ -328,14 +328,7 @@ void gp_Trsf::SetValues(const Standard_Real a11,
const Standard_Real a31, const Standard_Real a31,
const Standard_Real a32, const Standard_Real a32,
const Standard_Real a33, const Standard_Real a33,
const Standard_Real a34, const Standard_Real a34)
// const Standard_Real Tolang,
const Standard_Real ,
const Standard_Real
#ifndef No_Exception
TolDist
#endif
)
{ {
gp_XYZ col1(a11,a21,a31); gp_XYZ col1(a11,a21,a31);
gp_XYZ col2(a12,a22,a32); gp_XYZ col2(a12,a22,a32);
@@ -347,63 +340,19 @@ void gp_Trsf::SetValues(const Standard_Real a11,
Standard_Real As = s; Standard_Real As = s;
if (As < 0) As = - As; if (As < 0) As = - As;
Standard_ConstructionError_Raise_if Standard_ConstructionError_Raise_if
(As < gp::Resolution(),"gp_Trsf::SeValues, null determinant"); (As < gp::Resolution(),"gp_Trsf::SetValues, null determinant");
if (s > 0) if (s > 0)
s = Pow(s,1./3.); s = Pow(s,1./3.);
else else
s = -Pow(-s,1./3.); s = -Pow(-s,1./3.);
M.Divide(s); 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; scale = s;
shape = gp_CompoundTrsf; shape = gp_CompoundTrsf;
matrix = M; matrix = M;
Orthogonalize();
loc = col4; loc = col4;
} }
@@ -817,3 +766,42 @@ Standard_Boolean gp_Trsf::GetRotation (gp_XYZ& theAxis,
theAxis = aVec.XYZ(); theAxis = aVec.XYZ();
return Standard_True; 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;
}

View File

@@ -242,6 +242,31 @@ is
Transforms (me; Coord : out XY) is static; Transforms (me; Coord : out XY) is static;
---C++: inline ---C++: inline
--- Purpose : Transforms a doublet XY with a Trsf2d --- 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 fields
scale : Real; scale : Real;

View File

@@ -23,31 +23,32 @@
void gp_Trsf2d::SetMirror (const gp_Ax2d& A) void gp_Trsf2d::SetMirror (const gp_Ax2d& A)
{ {
shape = gp_Ax1Mirror; shape = gp_Ax1Mirror;
scale = - 1.0;
const gp_Dir2d& V = A.Direction (); const gp_Dir2d& V = A.Direction ();
const gp_Pnt2d& P = A.Location (); const gp_Pnt2d& P = A.Location ();
Standard_Real VX = V.X(); Standard_Real VX = V.X();
Standard_Real VY = V.Y(); Standard_Real VY = V.Y();
Standard_Real X0 = P.X(); Standard_Real X0 = P.X();
Standard_Real Y0 = P.Y(); 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)), 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 * X0) + (VY * VY - 1.0) * 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, void gp_Trsf2d::SetTransformation (const gp_Ax2d& FromA1,
const gp_Ax2d& ToA2) const gp_Ax2d& ToA2)
{ {
shape = gp_CompoundTrsf; shape = gp_CompoundTrsf;
scale = 1.0;
//matrix from XOY to A2 : //matrix from XOY to A2 :
const gp_XY& V1 = ToA2.Direction().XY(); const gp_XY& V1 = ToA2.Direction().XY();
gp_XY V2 (-V1.Y(), V1.X()); gp_XY V2 (-V1.Y(), V1.X());
matrix.SetCol (1, V1);
matrix.SetCol (2, V2); SetValues(V1.X(), V2.X(), ToA2.Location().X(),
loc = ToA2.Location().XY(); V1.Y(), V2.Y(), ToA2.Location().Y());
scale = 1.0;
matrix.Transpose(); matrix.Transpose();
loc.Multiply (matrix); loc.Multiply (matrix);
loc.Reverse(); loc.Reverse();
@@ -65,12 +66,14 @@ void gp_Trsf2d::SetTransformation (const gp_Ax2d& FromA1,
void gp_Trsf2d::SetTransformation (const gp_Ax2d& A) void gp_Trsf2d::SetTransformation (const gp_Ax2d& A)
{ {
shape = gp_CompoundTrsf; shape = gp_CompoundTrsf;
scale = 1.0;
const gp_XY& V1 = A.Direction().XY(); const gp_XY& V1 = A.Direction().XY();
gp_XY V2 (-V1.Y(), V1.X()); gp_XY V2 (-V1.Y(), V1.X());
matrix.SetCol (1, V1);
matrix.SetCol (2, V2); SetValues(V1.X(), V2.X(), A.Location().X(),
loc = A.Location().XY(); V1.Y(), V2.Y(), A.Location().Y());
scale = 1.0;
matrix.Transpose(); matrix.Transpose();
loc.Multiply (matrix); loc.Multiply (matrix);
loc.Reverse(); 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;
}