cuboidMeshGenerator.h
1 //
2 // Copyright 2022 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_CUBOID_MESH_GENERATOR_H
8 #define PXR_IMAGING_GEOM_UTIL_CUBOID_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  // Normals are per face.
60  return 6;
61  }
62 
63  static TfToken GetNormalsInterpolation()
64  {
65  // Normals are per face.
66  return GeomUtilInterpolationTokens->uniform;
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 ScalarType zLength,
81  const GfMatrix4d* framePtr = nullptr)
82  {
83  using PointType =
84  typename std::iterator_traits<PointIterType>::value_type;
85 
86  _GeneratePointsImpl(xLength, yLength, zLength,
87  framePtr ? _PointWriter<PointType>(iter, framePtr)
88  : _PointWriter<PointType>(iter));
89  }
90 
91  using GeomUtilMeshGeneratorBase::GeneratePoints;
92 
93  template<typename PointIterType,
94  typename Enabled =
95  typename _EnableIfGfVec3Iterator<PointIterType>::type>
96  static void GenerateNormals(
97  PointIterType iter,
98  const GfMatrix4d* framePtr = nullptr)
99  {
100  using PointType =
101  typename std::iterator_traits<PointIterType>::value_type;
102 
103  _GenerateNormalsImpl(
104  framePtr ? _PointWriter<PointType>(iter, framePtr)
105  : _PointWriter<PointType>(iter));
106  }
107 
108  using GeomUtilMeshGeneratorBase::GenerateNormals;
109 
110 private:
111 
112  template<typename PointType>
113  static void _GeneratePointsImpl(
114  const typename PointType::ScalarType xLength,
115  const typename PointType::ScalarType yLength,
116  const typename PointType::ScalarType zLength,
117  const _PointWriter<PointType>& ptWriter);
118 
119  template<typename PointType>
120  static void _GenerateNormalsImpl(
121  const _PointWriter<PointType>& ptWriter);
122 };
123 
124 PXR_NAMESPACE_CLOSE_SCOPE
125 
126 #endif // PXR_IMAGING_GEOM_UTIL_CUBOID_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...