Loading...
Searching...
No Matches
capsuleMeshGenerator.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_CAPSULE_MESH_GENERATOR_H
8#define PXR_IMAGING_GEOM_UTIL_CAPSULE_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
54{
55public:
56 static constexpr size_t minNumRadial = 3;
57 static constexpr size_t minNumCapAxial = 1;
58
59 GEOMUTIL_API
60 static size_t ComputeNumPoints(
61 const size_t numRadial,
62 const size_t numCapAxial,
63 const bool closedSweep = true);
64
65 GEOMUTIL_API
66 static PxOsdMeshTopology GenerateTopology(
67 const size_t numRadial,
68 const size_t numCapAxial,
69 const bool closedSweep = true);
70
71 template<typename PointIterType,
72 typename ScalarType,
73 typename Enabled =
74 typename _EnableIfGfVec3Iterator<PointIterType>::type>
75 static void GeneratePoints(
76 PointIterType iter,
77 const size_t numRadial,
78 const size_t numCapAxial,
79 const ScalarType radius,
80 const ScalarType height,
81 const GfMatrix4d* framePtr = nullptr)
82 {
83 constexpr ScalarType sweep = 360;
84
85 GeneratePoints(iter, numRadial, numCapAxial,
86 /* bottomRadius = */ radius,
87 /* topRadius = */ radius,
88 height, sweep, framePtr);
89 }
90
91 template<typename PointIterType,
92 typename ScalarType,
93 typename Enabled =
94 typename _EnableIfGfVec3Iterator<PointIterType>::type>
95 static void GeneratePoints(
96 PointIterType iter,
97 const size_t numRadial,
98 const size_t numCapAxial,
99 const ScalarType bottomRadius,
100 const ScalarType topRadius,
101 const ScalarType height,
102 const ScalarType sweepDegrees,
103 const GfMatrix4d* framePtr = nullptr)
104 {
105 using PointType =
106 typename std::iterator_traits<PointIterType>::value_type;
107
108 _GeneratePointsImpl(numRadial, numCapAxial, bottomRadius, topRadius,
109 height, sweepDegrees,
110 framePtr ? _PointWriter<PointType>(iter, framePtr)
111 : _PointWriter<PointType>(iter));
112 }
113
114 using GeomUtilMeshGeneratorBase::GeneratePoints;
115
116private:
117 template<typename PointType>
118 static void _GeneratePointsImpl(
119 const size_t numRadial,
120 const size_t numCapAxial,
121 const typename PointType::ScalarType bottomRadius,
122 const typename PointType::ScalarType topRadius,
123 const typename PointType::ScalarType height,
124 const typename PointType::ScalarType sweep,
125 const _PointWriter<PointType>& ptWriter);
126};
127
128PXR_NAMESPACE_CLOSE_SCOPE
129
130#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:71
Topology data for meshes.
Definition: meshTopology.h:52