GteDelaunay2Mesh.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 GetNumTriangles() const;
25  inline Vector2<InputType> const* GetVertices() const;
26  inline int const* GetIndices() const;
27  inline int const* GetAdjacencies() const;
28 
29  // Containment queries.
30  int GetContainingTriangle(Vector2<InputType> const& P) const;
31  bool GetVertices(int t, std::array<Vector2<InputType>, 3>& vertices)
32  const;
33  bool GetIndices(int t, std::array<int, 3>& indices) const;
34  bool GetAdjacencies(int t, std::array<int, 3>& adjacencies) const;
35  bool GetBarycentrics(int t, Vector2<InputType> const& P,
36  std::array<InputType, 3>& bary) const;
37 
38 private:
40 };
41 
42 
43 template <typename InputType, typename ComputeType, typename RationalType>
45  Delaunay2<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->GetNumTriangles();
63 }
64 
65 template <typename InputType, typename ComputeType, typename RationalType>
66 inline Vector2<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->GetContainingTriangle(P, info);
93 }
94 
95 template <typename InputType, typename ComputeType, typename RationalType>
97 GetVertices(int t, std::array<Vector2<InputType>, 3>& vertices) const
98 {
99  if (mDelaunay->GetDimension() == 2)
100  {
101  std::array<int, 3> indices;
102  if (mDelaunay->GetIndices(t, indices))
103  {
104  PrimalQuery2<ComputeType> const& query = mDelaunay->GetQuery();
105  Vector2<ComputeType> const* ctVertices = query.GetVertices();
106  for (int i = 0; i < 3; ++i)
107  {
108  Vector2<ComputeType> const& V = ctVertices[indices[i]];
109  for (int j = 0; j < 2; ++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, 3>& 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, 3>& indices) const
130 {
131  return mDelaunay->GetAdjacencies(t, indices);
132 }
133 
134 template <typename InputType, typename ComputeType, typename RationalType>
137 std::array<InputType, 3>& bary) const
138 {
139  std::array<int, 3> indices;
140  if (mDelaunay->GetIndices(t, indices))
141  {
142  PrimalQuery2<ComputeType> const& query = mDelaunay->GetQuery();
143  Vector2<ComputeType> const* vertices = query.GetVertices();
144  Vector2<RationalType> rtP{ P[0], P[1] };
145  std::array<Vector2<RationalType>, 3> rtV;
146  for (int i = 0; i < 3; ++i)
147  {
148  Vector2<ComputeType> const& V = vertices[indices[i]];
149  for (int j = 0; j < 2; ++j)
150  {
151  rtV[i][j] = (RationalType)V[j];
152  }
153  };
154 
155  RationalType rtBary[3];
156  if (ComputeBarycentrics(rtP, rtV[0], rtV[1], rtV[2], rtBary))
157  {
158  for (int i = 0; i < 3; ++i)
159  {
160  bary[i] = (InputType)rtBary[i];
161  }
162  return true;
163  }
164  }
165  return false;
166 }
167 
168 
169 }
Vector2< InputType > const * GetVertices() const
bool GetBarycentrics(int t, Vector2< InputType > const &P, std::array< InputType, 3 > &bary) const
int const * GetAdjacencies() const
int GetContainingTriangle(Vector2< InputType > const &P) const
int GetNumTriangles() const
Vector2< Real > const * GetVertices() const
GLsizei GLenum const void * indices
Definition: glcorearb.h:401
Delaunay2Mesh(Delaunay2< InputType, ComputeType > const &delaunay)
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
Delaunay2< InputType, ComputeType > const * mDelaunay
int GetNumVertices() const
GLenum query
Definition: glext.h:2716
int const * GetIndices() const


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