GteDelaunay3Mesh.h
Go to the documentation of this file.
1 // David Eberly, Geometric Tools, Redmond WA 98052
2 // Copyright (c) 1998-2017
3 // Distributed under the Boost Software License, Version 1.0.
4 // http://www.boost.org/LICENSE_1_0.txt
5 // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
6 // File Version: 3.0.0 (2016/06/19)
7 
8 #pragma once
9 
11 
12 namespace gte
13 {
14 
15 template <typename InputType, typename ComputeType, typename RationalType>
17 {
18 public:
19  // Construction.
21 
22  // Mesh information.
23  inline int GetNumVertices() const;
24  inline int GetNumTetrahedra() const;
25  inline Vector3<InputType> const* GetVertices() const;
26  inline int const* GetIndices() const;
27  inline int const* GetAdjacencies() const;
28 
29  // Containment queries.
30  int GetContainingTetrahedron(Vector3<InputType> const& P) const;
31  bool GetVertices(int t, std::array<Vector3<InputType>, 4>& vertices)
32  const;
33  bool GetIndices(int t, std::array<int, 4>& indices) const;
34  bool GetAdjacencies(int t, std::array<int, 4>& adjacencies) const;
35  bool GetBarycentrics(int t, Vector3<InputType> const& P,
36  std::array<InputType, 4>& bary) const;
37 
38 private:
40 };
41 
42 
43 template <typename InputType, typename ComputeType, typename RationalType>
45  Delaunay3<InputType, ComputeType> const& delaunay)
46  :
47  mDelaunay(&delaunay)
48 {
49 }
50 
51 template <typename InputType, typename ComputeType, typename RationalType>
54 {
55  return mDelaunay->GetNumVertices();
56 }
57 
58 template <typename InputType, typename ComputeType, typename RationalType>
61 {
62  return mDelaunay->GetNumTetrahedra();
63 }
64 
65 template <typename InputType, typename ComputeType, typename RationalType>
66 inline Vector3<InputType> const*
68 GetVertices() const
69 {
70  return mDelaunay->GetVertices();
71 }
72 
73 template <typename InputType, typename ComputeType, typename RationalType>
75 GetIndices() const
76 {
77  return &mDelaunay->GetIndices()[0];
78 }
79 
80 template <typename InputType, typename ComputeType, typename RationalType>
83 {
84  return &mDelaunay->GetAdjacencies()[0];
85 }
86 
87 template <typename InputType, typename ComputeType, typename RationalType>
90 {
92  return mDelaunay->GetContainingTetrahedron(P, info);
93 }
94 
95 template <typename InputType, typename ComputeType, typename RationalType>
97 GetVertices(int t, std::array<Vector3<InputType>, 4>& vertices) const
98 {
99  if (mDelaunay->GetDimension() == 3)
100  {
101  std::array<int, 4> indices;
102  if (mDelaunay->GetIndices(t, indices))
103  {
104  PrimalQuery3<ComputeType> const& query = mDelaunay->GetQuery();
105  Vector3<ComputeType> const* ctVertices = query.GetVertices();
106  for (int i = 0; i < 4; ++i)
107  {
108  Vector3<ComputeType> const& V = ctVertices[indices[i]];
109  for (int j = 0; j < 3; ++j)
110  {
111  vertices[i][j] = (InputType)V[j];
112  }
113  }
114  return true;
115  }
116  }
117  return false;
118 }
119 
120 template <typename InputType, typename ComputeType, typename RationalType>
122 GetIndices(int t, std::array<int, 4>& indices) const
123 {
124  return mDelaunay->GetIndices(t, indices);
125 }
126 
127 template <typename InputType, typename ComputeType, typename RationalType>
129 GetAdjacencies(int t, std::array<int, 4>& indices) const
130 {
131  return mDelaunay->GetAdjacencies(t, indices);
132 }
133 
134 template <typename InputType, typename ComputeType, typename RationalType>
137 std::array<InputType, 4>& bary) const
138 {
139  std::array<int, 4> indices;
140  if (mDelaunay->GetIndices(t, indices))
141  {
142  PrimalQuery3<ComputeType> const& query = mDelaunay->GetQuery();
143  Vector3<ComputeType> const* vertices = query.GetVertices();
144  Vector3<RationalType> rtP{ P[0], P[1], P[2] };
145  std::array<Vector3<RationalType>, 4> rtV;
146  for (int i = 0; i < 4; ++i)
147  {
148  Vector3<ComputeType> const& V = vertices[indices[i]];
149  for (int j = 0; j < 3; ++j)
150  {
151  rtV[i][j] = (RationalType)V[j];
152  }
153  };
154 
155  RationalType rtBary[4];
156  if (ComputeBarycentrics(rtP, rtV[0], rtV[1], rtV[2], rtV[3], rtBary))
157  {
158  for (int i = 0; i < 4; ++i)
159  {
160  bary[i] = (InputType)rtBary[i];
161  }
162  return true;
163  }
164  }
165  return false;
166 }
167 
168 
169 }
Delaunay3< InputType, ComputeType > const * mDelaunay
bool GetBarycentrics(int t, Vector3< InputType > const &P, std::array< InputType, 4 > &bary) const
Delaunay3Mesh(Delaunay3< InputType, ComputeType > const &delaunay)
int GetContainingTetrahedron(Vector3< InputType > const &P) const
Vector3< InputType > const * GetVertices() const
Vector3< Real > const * GetVertices() const
GLsizei GLenum const void * indices
Definition: glcorearb.h:401
int const * GetIndices() const
GLdouble GLdouble t
Definition: glext.h:239
bool ComputeBarycentrics(Vector2< Real > const &p, Vector2< Real > const &v0, Vector2< Real > const &v1, Vector2< Real > const &v2, Real bary[3], Real epsilon=(Real) 0)
Definition: GteVector2.h:135
GLenum array
Definition: glext.h:6669
int GetNumTetrahedra() const
int GetNumVertices() const
GLenum query
Definition: glext.h:2716
int const * GetAdjacencies() const


geometric_tools_engine
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 03:59:59