// 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_Parab::gp_Parab () : focalLength (RealLast()) { } inline gp_Parab::gp_Parab (const gp_Ax2& A2, const Standard_Real Focal) : pos(A2), focalLength (Focal) { Standard_ConstructionError_Raise_if (Focal < 0.0, "gp_Parab() - focal length should be >= 0"); } inline gp_Parab::gp_Parab (const gp_Ax1& D, const gp_Pnt& F) { gp_Lin Droite(D); focalLength = Droite.Distance(F) / 2.; gp_Ax1 Ax = Droite.Normal(F).Position(); gp_Ax1 Ay = Droite.Position(); const gp_Dir& DD = Ax.Direction(); pos = gp_Ax2 (gp_Pnt(F.X() - focalLength * DD.X(), F.Y() - focalLength * DD.Y(), F.Z() - focalLength * DD.Z()), Ax.Direction().Crossed(Ay.Direction()), Ax.Direction()); } inline void gp_Parab::SetAxis (const gp_Ax1& A1) { pos.SetAxis (A1); } inline void gp_Parab::SetFocal (const Standard_Real Focal) { Standard_ConstructionError_Raise_if (Focal < 0.0, "gp_Parab::SetFocal() - focal length should be >= 0"); focalLength = Focal; } inline void gp_Parab::SetLocation (const gp_Pnt& P) { pos.SetLocation(P); } inline void gp_Parab::SetPosition (const gp_Ax2& A2) { pos = A2; } inline const gp_Ax1& gp_Parab::Axis () const { return pos.Axis(); } inline gp_Ax1 gp_Parab::Directrix() const { const gp_Pnt& PP = pos.Location (); const gp_Dir& DD = pos.XDirection(); gp_Pnt P (PP.X() - focalLength * DD.X(), PP.Y() - focalLength * DD.Y(), PP.Z() - focalLength * DD.Z()); return gp_Ax1 (P, pos.YDirection()); } inline Standard_Real gp_Parab::Focal() const { return focalLength; } inline gp_Pnt gp_Parab::Focus() const { const gp_Pnt& PP = pos.Location (); const gp_Dir& DD = pos.XDirection(); return gp_Pnt (PP.X() + focalLength * DD.X(), PP.Y() + focalLength * DD.Y(), PP.Z() + focalLength * DD.Z()); } inline const gp_Pnt& gp_Parab::Location () const { return pos.Location(); } inline Standard_Real gp_Parab::Parameter() const { return 2.0 * focalLength; } inline const gp_Ax2& gp_Parab::Position() const { return pos; } inline gp_Ax1 gp_Parab::XAxis () const { return gp_Ax1 (pos.Location(), pos.XDirection()); } inline gp_Ax1 gp_Parab::YAxis () const { return gp_Ax1 (pos.Location(), pos.YDirection()); } inline void gp_Parab::Rotate (const gp_Ax1& A1, const Standard_Real Ang) { pos.Rotate (A1, Ang); } inline gp_Parab gp_Parab::Rotated (const gp_Ax1& A1, const Standard_Real Ang) const { gp_Parab Prb = *this; Prb.pos.Rotate (A1, Ang); return Prb; } inline void gp_Parab::Scale (const gp_Pnt& P, const Standard_Real S) { focalLength *= S; if (focalLength < 0) focalLength = - focalLength; pos.Scale (P, S); } inline gp_Parab gp_Parab::Scaled (const gp_Pnt& P, const Standard_Real S) const { gp_Parab Prb = *this; Prb.focalLength *= S; if (Prb.focalLength < 0) Prb.focalLength = - Prb.focalLength; Prb.pos.Scale (P, S); return Prb; } inline void gp_Parab::Transform (const gp_Trsf& T) { focalLength *= T.ScaleFactor(); if (focalLength < 0) focalLength = - focalLength; pos.Transform (T); } inline gp_Parab gp_Parab::Transformed (const gp_Trsf& T) const { gp_Parab Prb = *this; Prb.focalLength *= T.ScaleFactor(); if (Prb.focalLength < 0) Prb.focalLength = - Prb.focalLength; Prb.pos.Transform (T); return Prb; } inline void gp_Parab::Translate (const gp_Vec& V) { pos.Translate (V); } inline gp_Parab gp_Parab::Translated (const gp_Vec& V) const { gp_Parab Prb = *this; Prb.pos.Translate (V); return Prb; } inline void gp_Parab::Translate (const gp_Pnt& P1, const gp_Pnt& P2) { pos.Translate (P1, P2); } inline gp_Parab gp_Parab::Translated (const gp_Pnt& P1, const gp_Pnt& P2) const { gp_Parab Prb = *this; Prb.pos.Translate (P1, P2); return Prb; }