7 #ifndef PXR_IMAGING_GEOM_UTIL_MESH_GENERATOR_BASE_H
8 #define PXR_IMAGING_GEOM_UTIL_MESH_GENERATOR_BASE_H
21 #include <type_traits>
74 template<
typename IterType>
83 template<
typename IterType>
85 :
public std::enable_if<_IsGfVec3Iterator<IterType>::value, void>
88 template<
typename IterType>
90 :
public std::enable_if<!_IsGfVec3Iterator<IterType>::value, void>
107 template<
typename Po
intType>
110 template<
class IterType>
113 : _writeFnPtr(&
_PointWriter<PointType>::_WritePoint<IterType>)
114 , _writeDirFnPtr(&
_PointWriter<PointType>::_WriteDir<IterType>)
115 , _untypedIterPtr(static_cast<
void*>(&iter))
118 template<
class IterType>
123 &
_PointWriter<PointType>::_TransformAndWritePoint<IterType>)
125 &
_PointWriter<PointType>::_TransformAndWriteDir<IterType>)
126 , _untypedIterPtr(static_cast<
void*>(&iter))
127 , _framePtr(framePtr)
131 const PointType& pt)
const
133 (this->*_writeFnPtr)(pt);
137 const typename PointType::ScalarType scaleXY,
138 const std::vector<std::array<
139 typename PointType::ScalarType, 2>>& arcXY,
140 const typename PointType::ScalarType arcZ)
const
142 for (
const auto& xy : arcXY) {
143 Write(PointType(scaleXY * xy[0], scaleXY * xy[1], arcZ));
148 const PointType& dir)
const
150 (this->*_writeDirFnPtr)(dir);
154 const typename PointType::ScalarType scaleXY,
155 const std::vector<std::array<
156 typename PointType::ScalarType, 2>>& arcXY,
157 const typename PointType::ScalarType arcZ)
const
159 for (
const auto& xy : arcXY) {
160 WriteDir(PointType(scaleXY * xy[0], scaleXY * xy[1], arcZ));
165 template<
class IterType>
167 const PointType& pt)
const
169 IterType& iter = *
static_cast<IterType*
>(_untypedIterPtr);
174 template<
class IterType>
175 void _TransformAndWritePoint(
176 const PointType& pt)
const
178 IterType& iter = *
static_cast<IterType*
>(_untypedIterPtr);
179 using OutType =
typename std::remove_reference_t<decltype(*iter)>;
180 *iter =
static_cast<OutType
>(_framePtr->
Transform(pt));
184 template<
class IterType>
186 const PointType& pt)
const
188 IterType& iter = *
static_cast<IterType*
>(_untypedIterPtr);
193 template<
class IterType>
194 void _TransformAndWriteDir(
195 const PointType& dir)
const
197 IterType& iter = *
static_cast<IterType*
>(_untypedIterPtr);
198 using OutType =
typename std::remove_reference_t<decltype(*iter)>;
199 *iter =
static_cast<OutType
>(_framePtr->
TransformDir(dir));
204 void (_PointWriter<PointType>::*)(
const PointType &)
const;
205 _WriteFnPtr _writeFnPtr;
206 _WriteFnPtr _writeDirFnPtr;
207 void* _untypedIterPtr;
245 const size_t numRadial,
246 const size_t numQuadStrips,
249 const bool closedSweep);
257 const size_t numRadial,
258 const bool closedSweep);
264 const size_t numRadial,
265 const size_t numQuadStrips,
268 const bool closedSweep);
273 template<
typename ScalarType>
275 const size_t numRadial,
276 const ScalarType sweepDegrees)
278 constexpr ScalarType twoPi = 2.0 *
M_PI;
280 const ScalarType sweep =
GfClamp(sweepRadians, -twoPi, twoPi);
285 std::vector<std::array<ScalarType, 2>>
result(numPts);
286 for (
size_t radIdx = 0; radIdx < numPts; ++radIdx) {
288 const ScalarType longAngle =
289 (ScalarType(radIdx) / ScalarType(numRadial)) * sweep;
290 result[radIdx][0] =
cos(longAngle);
291 result[radIdx][1] =
sin(longAngle);
305 template<
typename PointIterType,
309 PointIterType iter, ...)
312 "This function only supports iterators to GfVec3f or GfVec3d "
323 template<
typename PointIterType,
327 PointIterType iter, ...)
330 "This function only supports iterators to GfVec3f or GfVec3d "
339 #endif // PXR_IMAGING_GEOM_UTIL_MESH_GENERATOR_BASE_H
SYS_API double cos(double x)
void WriteDir(const PointType &dir) const
double GfClamp(double value, double min, double max)
GLsizei const GLfloat * value
**But if you need a result
GfVec3d Transform(const GfVec3d &vec) const
GfVec3d TransformDir(const GfVec3d &vec) const
_PointWriter(IterType &iter, const GfMatrix4d *const framePtr)
void Write(const PointType &pt) const
typename std::iterator_traits< IterType >::value_type PointType
void WriteArcDir(const typename PointType::ScalarType scaleXY, const std::vector< std::array< typename PointType::ScalarType, 2 >> &arcXY, const typename PointType::ScalarType arcZ) const
static PxOsdMeshTopology _GenerateCappedQuadTopology(const size_t numRadial, const size_t numQuadStrips, const _CapStyle bottomCapStyle, const _CapStyle topCapStyle, const bool closedSweep)
static size_t _ComputeNumCappedQuadTopologyPoints(const size_t numRadial, const size_t numQuadStrips, const _CapStyle bottomCapStyle, const _CapStyle topCapStyle, const bool closedSweep)
double GfDegreesToRadians(double degrees)
void WriteArc(const typename PointType::ScalarType scaleXY, const std::vector< std::array< typename PointType::ScalarType, 2 >> &arcXY, const typename PointType::ScalarType arcZ) const
static void GeneratePoints(PointIterType iter,...)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
bool GfIsClose(GfColor const &c1, GfColor const &c2, double tolerance)
#define PXR_NAMESPACE_CLOSE_SCOPE
_PointWriter(IterType &iter)
static size_t _ComputeNumRadialPoints(const size_t numRadial, const bool closedSweep)
static std::vector< std::array< ScalarType, 2 > > _GenerateUnitArcXY(const size_t numRadial, const ScalarType sweepDegrees)
SYS_API double sin(double x)
static void GenerateNormals(PointIterType iter,...)