MFEM  v3.4
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
vertex.hpp
Go to the documentation of this file.
1 // Copyright (c) 2010, Lawrence Livermore National Security, LLC. Produced at
2 // the Lawrence Livermore National Laboratory. LLNL-CODE-443211. All Rights
3 // reserved. See file COPYRIGHT for details.
4 //
5 // This file is part of the MFEM library. For more information and source code
6 // availability see http://mfem.org.
7 //
8 // MFEM is free software; you can redistribute it and/or modify it under the
9 // terms of the GNU Lesser General Public License (as published by the Free
10 // Software Foundation) version 2.1 dated February 1999.
11 
12 #ifndef MFEM_VERTEX
13 #define MFEM_VERTEX
14 
15 #include "../config/config.hpp"
16 
17 namespace mfem
18 {
19 
20 /// Data type for vertex
21 class Vertex
22 {
23 protected:
24  double coord[3];
25 
26 public:
27  Vertex() { }
28 
29  Vertex (double *xx, int dim);
30  Vertex( double x, double y) { coord[0] = x; coord[1] = y; coord[2] = 0.; }
31  Vertex( double x, double y, double z)
32  { coord[0] = x; coord[1] = y; coord[2] = z; }
33 
34  /// Returns pointer to the coordinates of the vertex.
35  inline double * operator() () const { return (double*)coord; }
36 
37  /// Returns the i'th coordinate of the vertex.
38  inline double & operator() (int i) { return coord[i]; }
39 
40  /// Returns the i'th coordinate of the vertex.
41  inline const double & operator() (int i) const { return coord[i]; }
42 
43  /// (DEPRECATED) Set the coordinates of the Vertex.
44  /** @deprecated This old version of SetCoords is not always memory safe. */
45  void SetCoords(const double *p)
46  { coord[0] = p[0]; coord[1] = p[1]; coord[2] = p[2]; }
47 
48  /// Sets vertex location based on given point p
49  void SetCoords(int dim, const double *p)
50  { for (int i = 0; i < dim; i++) { coord[i] = p[i]; } }
51 
52  ~Vertex() { }
53 };
54 
55 }
56 
57 #endif
void SetCoords(int dim, const double *p)
Sets vertex location based on given point p.
Definition: vertex.hpp:49
Data type for vertex.
Definition: vertex.hpp:21
int dim
Definition: ex3.cpp:47
Vertex(double x, double y, double z)
Definition: vertex.hpp:31
void SetCoords(const double *p)
(DEPRECATED) Set the coordinates of the Vertex.
Definition: vertex.hpp:45
double coord[3]
Definition: vertex.hpp:24
double * operator()() const
Returns pointer to the coordinates of the vertex.
Definition: vertex.hpp:35
Vertex(double x, double y)
Definition: vertex.hpp:30