planeMeshGenerator.h
1 //
2 // Copyright 2024 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_IMAGING_GEOM_UTIL_PLANE_MESH_GENERATOR_H
8 #define PXR_IMAGING_GEOM_UTIL_PLANE_MESH_GENERATOR_H
9 
10 #include "pxr/imaging/geomUtil/api.h"
11 #include "pxr/imaging/geomUtil/meshGeneratorBase.h"
13 
14 #include "pxr/pxr.h"
15 
16 PXR_NAMESPACE_OPEN_SCOPE
17 
18 class GfMatrix4d;
19 class PxOsdMeshTopology;
20 
52 {
53 public:
54  GEOMUTIL_API
55  static size_t ComputeNumPoints();
56 
57  static size_t ComputeNumNormals()
58  {
59  // A single normal for all points.
60  return 1;
61  }
62 
63  static TfToken GetNormalsInterpolation()
64  {
65  // A single normal for all points.
66  return GeomUtilInterpolationTokens->constant;
67  }
68 
69  GEOMUTIL_API
70  static PxOsdMeshTopology GenerateTopology();
71 
72  template<typename PointIterType,
73  typename ScalarType,
74  typename Enabled =
75  typename _EnableIfGfVec3Iterator<PointIterType>::type>
76  static void GeneratePoints(
77  PointIterType iter,
78  const ScalarType xLength,
79  const ScalarType yLength,
80  const GfMatrix4d* framePtr = nullptr)
81  {
82  using PointType =
83  typename std::iterator_traits<PointIterType>::value_type;
84 
85  _GeneratePointsImpl(xLength, yLength,
86  framePtr ? _PointWriter<PointType>(iter, framePtr)
87  : _PointWriter<PointType>(iter));
88  }
89 
90  using GeomUtilMeshGeneratorBase::GeneratePoints;
91 
92  template<typename PointIterType,
93  typename Enabled =
94  typename _EnableIfGfVec3Iterator<PointIterType>::type>
95  static void GenerateNormals(
96  PointIterType iter,
97  const GfMatrix4d* framePtr = nullptr)
98  {
99  using PointType =
100  typename std::iterator_traits<PointIterType>::value_type;
101 
102  _GenerateNormalsImpl(
103  framePtr ? _PointWriter<PointType>(iter, framePtr)
104  : _PointWriter<PointType>(iter));
105  }
106 
107  using GeomUtilMeshGeneratorBase::GenerateNormals;
108 
109 private:
110 
111  template<typename PointType>
112  static void _GeneratePointsImpl(
113  const typename PointType::ScalarType xLength,
114  const typename PointType::ScalarType yLength,
115  const _PointWriter<PointType>& ptWriter);
116 
117  template<typename PointType>
118  static void _GenerateNormalsImpl(
119  const _PointWriter<PointType>& ptWriter);
120 };
121 
122 PXR_NAMESPACE_CLOSE_SCOPE
123 
124 #endif // PXR_IMAGING_GEOM_UTIL_PLANE_MESH_GENERATOR_H
This class provides common implementation for the different mesh generator classes in GeomUtil.
Topology data for meshes.
Definition: meshTopology.h:52
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:80
Stores a 4x4 matrix of double elements.
Definition: matrix4d.h:70
This class provides an implementation for generating topology, point positions and surface normals on...