Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-19 09:28:07

0001 // Created on: 2012-06-20
0002 // Created by: Sergey ZERCHANINOV
0003 // Copyright (c) 2011-2014 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef _Graphic3d_Vertex_HeaderFile
0017 #define _Graphic3d_Vertex_HeaderFile
0018 
0019 #include <Standard.hxx>
0020 #include <Standard_DefineAlloc.hxx>
0021 #include <Standard_Macro.hxx>
0022 #include <Standard_ShortReal.hxx>
0023 #include <Standard_OStream.hxx>
0024 
0025 //! This class represents a graphical 3D point.
0026 class Graphic3d_Vertex
0027 {
0028 public:
0029   DEFINE_STANDARD_ALLOC
0030 
0031   //! Creates a point with 0.0, 0.0, 0.0 coordinates.
0032   Graphic3d_Vertex() { SetCoord(0.0f, 0.0f, 0.0f); }
0033 
0034   //! Creates a point with theX, theY and theZ coordinates.
0035   Graphic3d_Vertex(const float theX, const float theY, const float theZ)
0036   {
0037     SetCoord(theX, theY, theZ);
0038   }
0039 
0040   //! Creates a point with theX, theY and theZ coordinates.
0041   Graphic3d_Vertex(const double theX, const double theY, const double theZ)
0042   {
0043     SetCoord(theX, theY, theZ);
0044   }
0045 
0046   //! Modifies the coordinates.
0047   void SetCoord(const float theX, const float theY, const float theZ)
0048   {
0049     xyz[0] = theX;
0050     xyz[1] = theY;
0051     xyz[2] = theZ;
0052   }
0053 
0054   //! Modifies the coordinates.
0055   void SetCoord(const double theX, const double theY, const double theZ)
0056   {
0057     xyz[0] = float(theX);
0058     xyz[1] = float(theY);
0059     xyz[2] = float(theZ);
0060   }
0061 
0062   //! Returns the coordinates.
0063   void Coord(float& theX, float& theY, float& theZ) const
0064   {
0065     theX = xyz[0];
0066     theY = xyz[1];
0067     theZ = xyz[2];
0068   }
0069 
0070   //! Returns the coordinates.
0071   void Coord(double& theX, double& theY, double& theZ) const
0072   {
0073     theX = xyz[0];
0074     theY = xyz[1];
0075     theZ = xyz[2];
0076   }
0077 
0078   //! Returns the X coordinates.
0079   float X() const { return xyz[0]; }
0080 
0081   //! Returns the Y coordinate.
0082   float Y() const { return xyz[1]; }
0083 
0084   //! Returns the Z coordinate.
0085   float Z() const { return xyz[2]; }
0086 
0087   //! Returns the distance between two points.
0088   Standard_EXPORT float Distance(const Graphic3d_Vertex& theOther) const;
0089 
0090   //! Dumps the content of me into the stream
0091   Standard_EXPORT void DumpJson(Standard_OStream& theOStream, int theDepth = -1) const;
0092 
0093   float xyz[3];
0094 };
0095 
0096 #endif