GteExtremalQuery3.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 Real>
17 {
18 public:
19  // Abstract base class.
20  virtual ~ExtremalQuery3();
21 
22  // Disallow copying and assignment.
23  ExtremalQuery3(ExtremalQuery3 const&) = delete;
24  ExtremalQuery3& operator=(ExtremalQuery3 const&) = delete;
25 
26  // Member access.
27  Polyhedron3<Real> const& GetPolytope() const;
28  std::vector<Vector3<Real>> const& GetFaceNormals() const;
29 
30  // Compute the extreme vertices in the specified direction and return the
31  // indices of the vertices in the polyhedron vertex array.
32  virtual void GetExtremeVertices(Vector3<Real> const& direction,
33  int& positiveDirection, int& negativeDirection) = 0;
34 
35 protected:
36  // The caller must ensure that the input polyhedron is convex.
37  ExtremalQuery3(Polyhedron3<Real> const& polytope);
38 
40  std::vector<Vector3<Real>> mFaceNormals;
41 };
42 
43 
44 template <typename Real>
46 {
47 }
48 
49 template <typename Real>
51 {
52  return mPolytope;
53 }
54 
55 template <typename Real>
56 std::vector<Vector3<Real>> const& ExtremalQuery3<Real>::GetFaceNormals() const
57 {
58  return mFaceNormals;
59 }
60 
61 template <typename Real>
63  :
64  mPolytope(polytope)
65 {
66  // Create the face normals.
67  auto vertexPool = mPolytope.GetVertices();
68  auto const& indices = mPolytope.GetIndices();
69  int const numTriangles = static_cast<int>(indices.size()) / 3;
70  mFaceNormals.resize(numTriangles);
71  for (int t = 0; t < numTriangles; ++t)
72  {
73  Vector3<Real> v0 = vertexPool[indices[3 * t + 0]];
74  Vector3<Real> v1 = vertexPool[indices[3 * t + 1]];
75  Vector3<Real> v2 = vertexPool[indices[3 * t + 2]];
76  Vector3<Real> edge1 = v1 - v0;
77  Vector3<Real> edge2 = v2 - v0;
78  mFaceNormals[t] = UnitCross(edge1, edge2);
79  }
80 }
81 
82 }
ExtremalQuery3(ExtremalQuery3 const &)=delete
virtual void GetExtremeVertices(Vector3< Real > const &direction, int &positiveDirection, int &negativeDirection)=0
std::vector< Vector3< Real > > const & GetFaceNormals() const
Polyhedron3< Real > const & GetPolytope() const
GLfloat GLfloat v1
Definition: glcorearb.h:812
Vector< N, Real > UnitCross(Vector< N, Real > const &v0, Vector< N, Real > const &v1, bool robust=false)
Definition: GteVector3.h:130
ExtremalQuery3 & operator=(ExtremalQuery3 const &)=delete
GLsizei GLenum const void * indices
Definition: glcorearb.h:401
GLfloat v0
Definition: glcorearb.h:811
GLdouble GLdouble t
Definition: glext.h:239
std::vector< Vector3< Real > > mFaceNormals
GLfloat GLfloat GLfloat v2
Definition: glcorearb.h:813
Polyhedron3< Real > const & mPolytope


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