// Copyright (c) 1995-1999 Matra Datavision // Copyright (c) 1999-2014 OPEN CASCADE SAS // // 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 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 #include inline gp_GTrsf2d::gp_GTrsf2d () { shape = gp_Identity; matrix.SetScale (1.0); loc.SetCoord (0.0, 0.0); scale = 1.0; } inline gp_GTrsf2d::gp_GTrsf2d (const gp_Trsf2d& T) { shape = T.shape; matrix = T.matrix; loc = T.loc; scale = T.scale; } inline gp_GTrsf2d::gp_GTrsf2d (const gp_Mat2d& M, const gp_XY& V) : matrix(M), loc(V) { shape = gp_Other; scale = 0.0; } inline void gp_GTrsf2d::SetValue (const Standard_Integer Row, const Standard_Integer Col, const Standard_Real Value) { Standard_OutOfRange_Raise_if (Row < 1 || Row > 2 || Col < 1 || Col > 3, " "); if (Col == 3) loc.SetCoord (Row, Value); else matrix.SetValue (Row, Col, Value); shape = gp_Other; } inline void gp_GTrsf2d::SetTrsf2d (const gp_Trsf2d& T) { shape = T.shape; matrix = T.matrix; loc = T.loc; scale = T.scale; } inline void gp_GTrsf2d::SetVectorialPart (const gp_Mat2d& Matrix) { matrix = Matrix; shape = gp_Other; scale = 0.0; } inline Standard_Boolean gp_GTrsf2d::IsNegative () const { return matrix.Determinant() < 0.0; } inline Standard_Boolean gp_GTrsf2d::IsSingular () const { return matrix.IsSingular(); } inline const gp_Mat2d& gp_GTrsf2d::VectorialPart () const { return matrix; } inline Standard_Real gp_GTrsf2d::Value (const Standard_Integer Row, const Standard_Integer Col) const { Standard_OutOfRange_Raise_if (Row < 1 || Row > 2 || Col < 1 || Col > 3, " "); if (Col == 3) return loc.Coord (Row); if (shape == gp_Other) return matrix.Value (Row, Col); return scale * matrix.Value (Row, Col); } inline gp_TrsfForm gp_GTrsf2d::Form () const { return shape; } inline const gp_XY& gp_GTrsf2d::TranslationPart () const { return loc; } inline gp_GTrsf2d gp_GTrsf2d::Inverted () const { gp_GTrsf2d T = *this; T.Invert (); return T; } inline gp_GTrsf2d gp_GTrsf2d::Multiplied (const gp_GTrsf2d& T) const { gp_GTrsf2d Tres = *this; Tres.Multiply (T); return Tres; } inline gp_GTrsf2d gp_GTrsf2d::Powered (const Standard_Integer N) const { gp_GTrsf2d T = *this; T.Power (N); return T; } inline void gp_GTrsf2d::Transforms (gp_XY& Coord) const { Coord.Multiply (matrix); if (!(shape == gp_Other) && !(scale == 1.0)) Coord.Multiply (scale); Coord.Add(loc); } inline gp_XY gp_GTrsf2d::Transformed(const gp_XY& Coord) const { gp_XY newCoord = Coord; Transforms(newCoord); return newCoord; } inline void gp_GTrsf2d::Transforms (Standard_Real& X, Standard_Real& Y) const { gp_XY Doublet (X, Y); Doublet.Multiply (matrix); if (!(shape == gp_Other) && !(scale == 1.0)) Doublet.Multiply (scale); Doublet.Add(loc); Doublet.Coord (X, Y); }