Loading...
Searching...
No Matches
capsuleMeshGenerator.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_CAPSULE_MESH_GENERATOR_H
25#define PXR_IMAGING_GEOM_UTIL_CAPSULE_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
32PXR_NAMESPACE_OPEN_SCOPE
33
34class GfMatrix4d;
36
71{
72public:
73 static constexpr size_t minNumRadial = 3;
74 static constexpr size_t minNumCapAxial = 1;
75
76 GEOMUTIL_API
77 static size_t ComputeNumPoints(
78 const size_t numRadial,
79 const size_t numCapAxial,
80 const bool closedSweep = true);
81
82 GEOMUTIL_API
83 static PxOsdMeshTopology GenerateTopology(
84 const size_t numRadial,
85 const size_t numCapAxial,
86 const bool closedSweep = true);
87
88 template<typename PointIterType,
89 typename ScalarType,
90 typename Enabled =
91 typename _EnableIfGfVec3Iterator<PointIterType>::type>
92 static void GeneratePoints(
93 PointIterType iter,
94 const size_t numRadial,
95 const size_t numCapAxial,
96 const ScalarType radius,
97 const ScalarType height,
98 const GfMatrix4d* framePtr = nullptr)
99 {
100 constexpr ScalarType sweep = 360;
101
102 GeneratePoints(iter, numRadial, numCapAxial,
103 /* bottomRadius = */ radius,
104 /* topRadius = */ radius,
105 height, sweep, framePtr);
106 }
107
108 template<typename PointIterType,
109 typename ScalarType,
110 typename Enabled =
111 typename _EnableIfGfVec3Iterator<PointIterType>::type>
112 static void GeneratePoints(
113 PointIterType iter,
114 const size_t numRadial,
115 const size_t numCapAxial,
116 const ScalarType bottomRadius,
117 const ScalarType topRadius,
118 const ScalarType height,
119 const ScalarType sweepDegrees,
120 const GfMatrix4d* framePtr = nullptr)
121 {
122 using PointType =
123 typename std::iterator_traits<PointIterType>::value_type;
124
125 _GeneratePointsImpl(numRadial, numCapAxial, bottomRadius, topRadius,
126 height, sweepDegrees,
127 framePtr ? _PointWriter<PointType>(iter, framePtr)
128 : _PointWriter<PointType>(iter));
129 }
130
131 using GeomUtilMeshGeneratorBase::GeneratePoints;
132
133private:
134 template<typename PointType>
135 static void _GeneratePointsImpl(
136 const size_t numRadial,
137 const size_t numCapAxial,
138 const typename PointType::ScalarType bottomRadius,
139 const typename PointType::ScalarType topRadius,
140 const typename PointType::ScalarType height,
141 const typename PointType::ScalarType sweep,
142 const _PointWriter<PointType>& ptWriter);
143};
144
145PXR_NAMESPACE_CLOSE_SCOPE
146
147#endif // PXR_IMAGING_GEOM_UTIL_CAPSULE_MESH_GENERATOR_H
This class provides an implementation for generating topology and point positions on a capsule.
This class provides common implementation for the different mesh generator classes in GeomUtil.
Stores a 4x4 matrix of double elements.
Definition: matrix4d.h:88
Topology data for meshes.
Definition: meshTopology.h:69