Loading...
Searching...
No Matches
sphereMeshGenerator.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_SPHERE_MESH_GENERATOR_H
8#define PXR_IMAGING_GEOM_UTIL_SPHERE_MESH_GENERATOR_H
9
10#include "pxr/imaging/geomUtil/api.h"
11#include "pxr/imaging/geomUtil/meshGeneratorBase.h"
12
13#include "pxr/pxr.h"
14
15PXR_NAMESPACE_OPEN_SCOPE
16
17class GfMatrix4d;
19
51{
52public:
53 static constexpr size_t minNumRadial = 3;
54 static constexpr size_t minNumAxial = 2;
55
56 GEOMUTIL_API
57 static size_t ComputeNumPoints(
58 const size_t numRadial,
59 const size_t numAxial,
60 const bool closedSweep = true);
61
62 GEOMUTIL_API
63 static PxOsdMeshTopology GenerateTopology(
64 const size_t numRadial,
65 const size_t numAxial,
66 const bool closedSweep = true);
67
68 template<typename PointIterType,
69 typename ScalarType,
70 typename Enabled =
71 typename _EnableIfGfVec3Iterator<PointIterType>::type>
72 static void GeneratePoints(
73 PointIterType iter,
74 const size_t numRadial,
75 const size_t numAxial,
76 const ScalarType radius,
77 const GfMatrix4d* framePtr = nullptr)
78 {
79 constexpr ScalarType sweep = 360;
80 GeneratePoints(iter, numRadial, numAxial, radius, sweep, framePtr);
81 }
82
83 template<typename PointIterType,
84 typename ScalarType,
85 typename Enabled =
86 typename _EnableIfGfVec3Iterator<PointIterType>::type>
87 static void GeneratePoints(
88 PointIterType iter,
89 const size_t numRadial,
90 const size_t numAxial,
91 const ScalarType radius,
92 const ScalarType sweepDegrees,
93 const GfMatrix4d* framePtr = nullptr)
94 {
95 using PointType =
96 typename std::iterator_traits<PointIterType>::value_type;
97
98 _GeneratePointsImpl(numRadial, numAxial, radius, sweepDegrees,
99 framePtr ? _PointWriter<PointType>(iter, framePtr)
100 : _PointWriter<PointType>(iter));
101 }
102
103 using GeomUtilMeshGeneratorBase::GeneratePoints;
104
105private:
106
107 template<typename PointType>
108 static void _GeneratePointsImpl(
109 const size_t numRadial,
110 const size_t numAxial,
111 const typename PointType::ScalarType radius,
112 const typename PointType::ScalarType sweepDegrees,
113 const _PointWriter<PointType>& ptWriter);
114};
115
116PXR_NAMESPACE_CLOSE_SCOPE
117
118#endif // PXR_IMAGING_GEOM_UTIL_SPHERE_MESH_GENERATOR_H
This class provides common implementation for the different mesh generator classes in GeomUtil.
This class provides an implementation for generating topology and point positions on a sphere with a ...
Stores a 4x4 matrix of double elements.
Definition: matrix4d.h:71
Topology data for meshes.
Definition: meshTopology.h:52