// 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. // Modif JCV 04/10/90 ajout des methodes Form Scale IsNegative // Modif JCV 10/12/90 ajout de la methode Translationpart #include #include #include #include inline gp_Trsf::gp_Trsf () : scale(1.0), shape(gp_Identity), matrix(1,0,0, 0,1,0, 0,0,1), loc(0.0, 0.0, 0.0) {} inline void gp_Trsf::SetMirror (const gp_Pnt& P) { shape = gp_PntMirror; scale = -1.0; loc = P.XYZ(); matrix.SetIdentity (); loc.Multiply(2.0); } inline void gp_Trsf::SetTranslation (const gp_Vec& V) { shape = gp_Translation; scale = 1.; matrix.SetIdentity (); loc = V.XYZ(); } inline void gp_Trsf::SetTranslation(const gp_Pnt& P1, const gp_Pnt& P2) { shape = gp_Translation; scale = 1.0; matrix.SetIdentity (); loc = (P2.XYZ()).Subtracted (P1.XYZ()); } inline void gp_Trsf::SetForm(const gp_TrsfForm P) { shape = P; } inline Standard_Boolean gp_Trsf::IsNegative() const { return (scale < 0.0); } inline const gp_XYZ& gp_Trsf::TranslationPart () const { return loc; } inline const gp_Mat& gp_Trsf::HVectorialPart () const { return matrix; } inline Standard_Real gp_Trsf::Value (const Standard_Integer Row, const Standard_Integer Col) const { Standard_OutOfRange_Raise_if (Row < 1 || Row > 3 || Col < 1 || Col > 4, " "); if (Col < 4) return scale * matrix.Value (Row, Col); else return loc.Coord (Row); } inline gp_TrsfForm gp_Trsf::Form () const { return shape; } inline Standard_Real gp_Trsf::ScaleFactor () const { return scale; } inline gp_Trsf gp_Trsf::Inverted() const { gp_Trsf T = *this; T.Invert(); return T; } inline gp_Trsf gp_Trsf::Multiplied (const gp_Trsf& T) const { gp_Trsf Tresult(*this); Tresult.Multiply(T); return Tresult; } inline gp_Trsf gp_Trsf::Powered (const Standard_Integer N) const { gp_Trsf T = *this; T.Power (N); return T; } inline void gp_Trsf::Transforms (Standard_Real& X, Standard_Real& Y, Standard_Real& Z) const { gp_XYZ Triplet (X, Y, Z); Triplet.Multiply (matrix); if (scale != 1.0) Triplet.Multiply (scale); Triplet.Add(loc); X = Triplet.X(); Y = Triplet.Y(); Z = Triplet.Z(); } inline void gp_Trsf::Transforms (gp_XYZ& Coord) const { Coord.Multiply (matrix); if (scale != 1.0) Coord.Multiply (scale); Coord.Add(loc); }