Loading...
Searching...
No Matches
diskMeshGenerator.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_DISK_MESH_GENERATOR_H
8#define PXR_IMAGING_GEOM_UTIL_DISK_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
16PXR_NAMESPACE_OPEN_SCOPE
17
18class GfMatrix4d;
20
53{
54public:
55 static constexpr size_t minNumRadial = 3;
56
57 GEOMUTIL_API
58 static size_t ComputeNumPoints(
59 const size_t numRadial,
60 const bool closedSweep = true);
61
62 static size_t ComputeNumNormals()
63 {
64 // A single normal for all points.
65 return 1;
66 }
67
68 static TfToken GetNormalsInterpolation()
69 {
70 // A single normal for all points.
71 return GeomUtilInterpolationTokens->constant;
72 }
73
74 GEOMUTIL_API
75 static PxOsdMeshTopology GenerateTopology(
76 const size_t numRadial,
77 const bool closedSweep = true);
78
79 template<typename PointIterType,
80 typename ScalarType,
81 typename Enabled =
82 typename _EnableIfGfVec3Iterator<PointIterType>::type>
83 static void GeneratePoints(
84 PointIterType iter,
85 const size_t numRadial,
86 const ScalarType radius,
87 const GfMatrix4d* framePtr = nullptr)
88 {
89 constexpr ScalarType sweep = 360;
90
91 GeneratePoints(iter, numRadial,
92 radius, sweep, framePtr);
93 }
94
95 template<typename PointIterType,
96 typename ScalarType,
97 typename Enabled =
98 typename _EnableIfGfVec3Iterator<PointIterType>::type>
99 static void GeneratePoints(
100 PointIterType iter,
101 const size_t numRadial,
102 const ScalarType radius,
103 const ScalarType sweepDegrees,
104 const GfMatrix4d* framePtr = nullptr)
105 {
106 using PointType =
107 typename std::iterator_traits<PointIterType>::value_type;
108
109 _GeneratePointsImpl(numRadial, radius, sweepDegrees,
110 framePtr ? _PointWriter<PointType>(iter, framePtr)
111 : _PointWriter<PointType>(iter));
112 }
113
114 using GeomUtilMeshGeneratorBase::GeneratePoints;
115
116 template<typename PointIterType,
117 typename Enabled =
118 typename _EnableIfGfVec3Iterator<PointIterType>::type>
119 static void GenerateNormals(
120 PointIterType iter,
121 const GfMatrix4d* framePtr = nullptr)
122 {
123 using PointType =
124 typename std::iterator_traits<PointIterType>::value_type;
125
126 _GenerateNormalsImpl(
127 framePtr ? _PointWriter<PointType>(iter, framePtr)
128 : _PointWriter<PointType>(iter));
129 }
130
131 using GeomUtilMeshGeneratorBase::GenerateNormals;
132
133private:
134
135 template<typename PointType>
136 static void _GeneratePointsImpl(
137 const size_t numRadial,
138 const typename PointType::ScalarType radius,
139 const typename PointType::ScalarType sweepDegrees,
140 const _PointWriter<PointType>& ptWriter);
141
142 template<typename PointType>
143 static void _GenerateNormalsImpl(
144 const _PointWriter<PointType>& ptWriter);
145};
146
147PXR_NAMESPACE_CLOSE_SCOPE
148
149#endif // PXR_IMAGING_GEOM_UTIL_DISK_MESH_GENERATOR_H
This class provides an implementation for generating topology, point positions and surface normals on...
This class provides common implementation for the different mesh generator classes in GeomUtil.
Stores a 4x4 matrix of double elements.
Definition: matrix4d.h:71
Topology data for meshes.
Definition: meshTopology.h:52
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71