MFEM  v4.1.0
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-2020, Lawrence Livermore National Security, LLC. Produced
2 // at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3 // LICENSE and NOTICE for details. LLNL-CODE-806117.
4 //
5 // This file is part of the MFEM library. For more information and source code
6 // availability visit https://mfem.org.
7 //
8 // MFEM is free software; you can redistribute it and/or modify it under the
9 // terms of the BSD-3 license. We welcome feedback and contributions, see file
10 // CONTRIBUTING.md for details.
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  // Trivial copy constructor and trivial copy assignment operator
30 
31  Vertex (double *xx, int dim);
32  Vertex( double x, double y) { coord[0] = x; coord[1] = y; coord[2] = 0.; }
33  Vertex( double x, double y, double z)
34  { coord[0] = x; coord[1] = y; coord[2] = z; }
35 
36  /// Returns pointer to the coordinates of the vertex.
37  inline double * operator() () const { return (double*)coord; }
38 
39  /// Returns the i'th coordinate of the vertex.
40  inline double & operator() (int i) { return coord[i]; }
41 
42  /// Returns the i'th coordinate of the vertex.
43  inline const double & operator() (int i) const { return coord[i]; }
44 
45  /// (DEPRECATED) Set the coordinates of the Vertex.
46  /** @deprecated This old version of SetCoords is not always memory safe. */
47  void SetCoords(const double *p)
48  { coord[0] = p[0]; coord[1] = p[1]; coord[2] = p[2]; }
49 
50  /// Sets vertex location based on given point p
51  void SetCoords(int dim, const double *p)
52  { for (int i = 0; i < dim; i++) { coord[i] = p[i]; } }
53 
54  // Trivial destructor
55 };
56 
57 }
58 
59 #endif
void SetCoords(int dim, const double *p)
Sets vertex location based on given point p.
Definition: vertex.hpp:51
Data type for vertex.
Definition: vertex.hpp:21
Vertex(double x, double y, double z)
Definition: vertex.hpp:33
void SetCoords(const double *p)
(DEPRECATED) Set the coordinates of the Vertex.
Definition: vertex.hpp:47
double coord[3]
Definition: vertex.hpp:24
int dim
Definition: ex24.cpp:43
double * operator()() const
Returns pointer to the coordinates of the vertex.
Definition: vertex.hpp:37
Vertex(double x, double y)
Definition: vertex.hpp:32