sphereMeshGenerator.h
1 //
2 // Copyright 2022 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef PXR_IMAGING_GEOM_UTIL_SPHERE_MESH_GENERATOR_H
25 #define PXR_IMAGING_GEOM_UTIL_SPHERE_MESH_GENERATOR_H
26 
27 #include "pxr/imaging/geomUtil/api.h"
28 #include "pxr/imaging/geomUtil/meshGeneratorBase.h"
29 
30 #include "pxr/pxr.h"
31 
32 PXR_NAMESPACE_OPEN_SCOPE
33 
34 class GfMatrix4d;
35 class PxOsdMeshTopology;
36 
68 {
69 public:
70  static constexpr size_t minNumRadial = 3;
71  static constexpr size_t minNumAxial = 2;
72 
73  GEOMUTIL_API
74  static size_t ComputeNumPoints(
75  const size_t numRadial,
76  const size_t numAxial,
77  const bool closedSweep = true);
78 
79  GEOMUTIL_API
80  static PxOsdMeshTopology GenerateTopology(
81  const size_t numRadial,
82  const size_t numAxial,
83  const bool closedSweep = true);
84 
85  template<typename PointIterType,
86  typename ScalarType,
87  typename Enabled =
88  typename _EnableIfGfVec3Iterator<PointIterType>::type>
89  static void GeneratePoints(
90  PointIterType iter,
91  const size_t numRadial,
92  const size_t numAxial,
93  const ScalarType radius,
94  const GfMatrix4d* framePtr = nullptr)
95  {
96  constexpr ScalarType sweep = 360;
97  GeneratePoints(iter, numRadial, numAxial, radius, sweep, framePtr);
98  }
99 
100  template<typename PointIterType,
101  typename ScalarType,
102  typename Enabled =
103  typename _EnableIfGfVec3Iterator<PointIterType>::type>
104  static void GeneratePoints(
105  PointIterType iter,
106  const size_t numRadial,
107  const size_t numAxial,
108  const ScalarType radius,
109  const ScalarType sweepDegrees,
110  const GfMatrix4d* framePtr = nullptr)
111  {
112  using PointType =
113  typename std::iterator_traits<PointIterType>::value_type;
114 
115  _GeneratePointsImpl(numRadial, numAxial, radius, sweepDegrees,
116  framePtr ? _PointWriter<PointType>(iter, framePtr)
117  : _PointWriter<PointType>(iter));
118  }
119 
120  using GeomUtilMeshGeneratorBase::GeneratePoints;
121 
122 private:
123 
124  template<typename PointType>
125  static void _GeneratePointsImpl(
126  const size_t numRadial,
127  const size_t numAxial,
128  const typename PointType::ScalarType radius,
129  const typename PointType::ScalarType sweepDegrees,
130  const _PointWriter<PointType>& ptWriter);
131 };
132 
133 PXR_NAMESPACE_CLOSE_SCOPE
134 
135 #endif // PXR_IMAGING_GEOM_UTIL_SPHERE_MESH_GENERATOR_H
This class provides common implementation for the different mesh generator classes in GeomUtil.
Topology data for meshes.
Definition: meshTopology.h:69
Stores a 4x4 matrix of double elements.
Definition: matrix4d.h:87
This class provides an implementation for generating topology and point positions on a sphere with a ...