HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cuboidMeshGenerator.h
Go to the documentation of this file.
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_CUBOID_MESH_GENERATOR_H
25 #define PXR_IMAGING_GEOM_UTIL_CUBOID_MESH_GENERATOR_H
26 
29 
30 #include "pxr/pxr.h"
31 
33 
34 class GfMatrix4d;
35 class PxOsdMeshTopology;
36 
37 /// This class provides an implementation for generating topology and point
38 /// positions on a rectangular cuboid given the dimensions along the X, Y and Z
39 /// axes. The generated cuboid is centered at the origin.
40 ///
41 /// An optional transform may be provided to GeneratePoints to orient the
42 /// cuboid as necessary.
43 ///
44 /// Usage:
45 /// \code{.cpp}
46 ///
47 /// const size_t numPoints =
48 /// GeomUtilCuboidMeshGenerator::ComputeNumPoints();
49 /// const float l = 5, b = 4, h = 3;
50 ///
51 /// MyPointContainer<GfVec3f> points(numPoints);
52 ///
53 /// GeomUtilCuboidMeshGenerator::GeneratePoints(
54 /// points.begin(), l, b, h);
55 ///
56 /// \endcode
57 ///
60 {
61 public:
63  static size_t ComputeNumPoints();
64 
67 
68  template<typename PointIterType,
69  typename ScalarType,
70  typename Enabled =
72  static void GeneratePoints(
73  PointIterType iter,
74  const ScalarType xLength,
75  const ScalarType yLength,
76  const ScalarType zLength,
77  const GfMatrix4d* framePtr = nullptr)
78  {
79  using PointType =
81 
82  _GeneratePointsImpl(xLength, yLength, zLength,
83  framePtr ? _PointWriter<PointType>(iter, framePtr)
84  : _PointWriter<PointType>(iter));
85  }
86 
88 
89 private:
90 
91  template<typename PointType>
92  static void _GeneratePointsImpl(
93  const typename PointType::ScalarType xLength,
94  const typename PointType::ScalarType yLength,
95  const typename PointType::ScalarType zLength,
96  const _PointWriter<PointType>& ptWriter);
97 };
98 
100 
101 #endif // PXR_IMAGING_GEOM_UTIL_CUBOID_MESH_GENERATOR_H
static GEOMUTIL_API size_t ComputeNumPoints()
uint64 value_type
Definition: GA_PrimCompat.h:29
#define GEOMUTIL_API
Definition: api.h:40
static void GeneratePoints(PointIterType iter,...)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1432
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
static void GeneratePoints(PointIterType iter, const ScalarType xLength, const ScalarType yLength, const ScalarType zLength, const GfMatrix4d *framePtr=nullptr)
static GEOMUTIL_API PxOsdMeshTopology GenerateTopology()