GteIntpVectorField2.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 
12 #include <memory>
13 
14 // Given points (x0[i],y0[i]) which are mapped to (x1[i],y1[i]) for
15 // 0 <= i < N, interpolate positions (xIn,yIn) to (xOut,yOut).
16 
17 namespace gte
18 {
19 
20 template <typename InputType, typename ComputeType, typename RationalType>
22 {
23 public:
24  // Construction and destruction.
26  IntpVectorField2(int numPoints, Vector2<InputType> const* domain,
27  Vector2<InputType> const* range);
28 
29  // The return value is 'true' if and only if (xIn,yIn) is in the convex
30  // hull of the input domain points, in which case the interpolation is
31  // valid.
33  Vector2<InputType>& output) const;
34 
35 protected:
38  TriangleMesh mMesh;
39 
40  std::vector<InputType> mXRange;
41  std::vector<InputType> mYRange;
42  std::unique_ptr<IntpQuadraticNonuniform2<InputType, TriangleMesh>> mXInterp;
43  std::unique_ptr<IntpQuadraticNonuniform2<InputType, TriangleMesh>> mYInterp;
44 };
45 
46 
47 template <typename InputType, typename ComputeType, typename RationalType>
49 {
50 }
51 
52 template <typename InputType, typename ComputeType, typename RationalType>
54  int numPoints, Vector2<InputType> const* domain,
56  :
58 {
59  // Repackage the output vectors into individual components. This is
60  // required because of the format that the quadratic interpolator expects
61  // for its input data.
62  mXRange.resize(numPoints);
63  mYRange.resize(numPoints);
64  for (int i = 0; i < numPoints; ++i)
65  {
66  mXRange[i] = range[i][0];
67  mYRange[i] = range[i][1];
68  }
69 
70  // Common triangulator for the interpolators.
71  mDelaunay(numPoints, &domain[0], (ComputeType)0);
72 
73  // Create interpolator for x-coordinate of vector field.
74  mXInterp = std::make_unique<IntpQuadraticNonuniform2<InputType, TriangleMesh>>(
75  mMesh, &mXRange[0], (InputType)1);
76 
77  // Create interpolator for y-coordinate of vector field, but share the
78  // already created triangulation for the x-interpolator.
79  mYInterp = std::make_unique<IntpQuadraticNonuniform2<InputType, TriangleMesh>>(
80  mMesh, &mYRange[0], (InputType)1);
81 }
82 
83 template <typename InputType, typename ComputeType, typename RationalType>
85  Vector2<InputType> const& input, Vector2<InputType>& output) const
86 {
87  InputType xDeriv, yDeriv;
88  return (*mXInterp)(input, output[0], xDeriv, yDeriv)
89  && (*mYInterp)(input, output[1], xDeriv, yDeriv);
90 }
91 
92 
93 }
std::unique_ptr< IntpQuadraticNonuniform2< InputType, TriangleMesh > > mYInterp
std::unique_ptr< IntpQuadraticNonuniform2< InputType, TriangleMesh > > mXInterp
std::vector< InputType > mYRange
bool operator()(Vector2< InputType > const &input, Vector2< InputType > &output) const
IntpVectorField2(int numPoints, Vector2< InputType > const *domain, Vector2< InputType > const *range)
GLenum GLenum GLenum input
Definition: glext.h:9913
Delaunay2Mesh< InputType, ComputeType, RationalType > TriangleMesh
GLenum GLint * range
Definition: glcorearb.h:1920
Delaunay2< InputType, ComputeType > mDelaunay
std::vector< InputType > mXRange


geometric_tools_engine
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 04:00:00