// Copyright (c) 1995-1999 Matra Datavision // Copyright (c) 1999-2012 OPEN CASCADE SAS // // The content of this file is subject to the Open CASCADE Technology Public // License Version 6.5 (the "License"). You may not use the content of this file // except in compliance with the License. Please obtain a copy of the License // at http://www.opencascade.org and read it completely before using this file. // // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. // // The Original Code and all software distributed under the License is // distributed on an "AS IS" basis, without warranty of any kind, and the // Initial Developer hereby disclaims all such warranties, including without // limitation, any warranties of merchantability, fitness for a particular // purpose or non-infringement. Please see the License for the specific terms // and conditions governing the rights and limitations under the License. #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); }