GCC Code Coverage Report


ernie/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
28 / 28
100.0%
Branches:
-
-%
Functions:
26 / 26, 1 excl
100.0%

scene/schema/mesh.h
Line Branch Exec Source
1 // SPDX-License-Identifier: BSD-3-Clause
2 /// @file mesh.h
3 /// @brief UsdGeom's point-based geometry: meshes, point clouds and curves.
4 ///
5 /// References:
6 /// - Pixar, UsdGeomMesh, UsdGeomPoints and UsdGeomCurves,
7 /// https://openusd.org/release/api/usd_geom_page_front.html
8 #pragma once
9
10 #include "ernie/scene/schema/geom.h"
11
12 // clang-format off
13 #define ERNIE_POINT_BASED_ATTRIBUTES(X) \
14 X(Tensor, Points, "points", Tensor(), "float32 or float64 (n, 3) positions in its own space.", \
15 .group = "Geometry", .components = 3, .dirty = Dirty::Points) \
16 X(Tensor, Velocities, "velocities", Tensor(), "(n, 3) metres per second of each point.", \
17 .group = "Motion", .components = 3, .dirty = Dirty::Points) \
18 X(Tensor, Accelerations, "accelerations", Tensor(), "(n, 3) metres per second squared.", \
19 .group = "Motion", .components = 3, .dirty = Dirty::Points) \
20 X(Tensor, Normals, "normals", Tensor(), "(n, 3) normals; computed from the faces when unset.", \
21 .group = "Geometry", .components = 3, .dirty = Dirty::Points)
22
23 #define ERNIE_MESH_INDICES(X, Name, usdName, text) \
24 X(Tensor, Name, usdName, Tensor(), text, .group = "Topology", .integer = true, \
25 .dirty = Dirty::Topology)
26
27 #define ERNIE_MESH_ATTRIBUTES(X) \
28 ERNIE_MESH_INDICES(X, FaceVertexCounts, "faceVertexCounts", \
29 "The number of vertices of each face.") \
30 ERNIE_MESH_INDICES(X, FaceVertexIndices, "faceVertexIndices", \
31 "The point indices of the faces' vertices, in order.") \
32 X(std::string, SubdivisionScheme, "subdivisionScheme", "catmullClark", \
33 "The surface the faces are the control mesh of; none draws the faces themselves.", \
34 .label = "Subdivision", .group = "Subdivision", \
35 .options = {"catmullClark", "loop", "bilinear", "none"}, .dirty = Dirty::Topology) \
36 X(std::string, InterpolateBoundary, "interpolateBoundary", "edgeAndCorner", \
37 "How boundary edges and corners are interpolated.", .group = "Subdivision", \
38 .options = {"none", "edgeOnly", "edgeAndCorner"}, .dirty = Dirty::Topology) \
39 X(std::string, FaceVaryingLinearInterpolation, "faceVaryingLinearInterpolation", \
40 "cornersPlus1", "Where face-varying primvars stay linear rather than smoothed.", \
41 .group = "Subdivision", \
42 .options = {"none", "cornersOnly", "cornersPlus1", "cornersPlus2", "boundaries", "all"}, \
43 .dirty = Dirty::Topology) \
44 X(std::string, TriangleSubdivisionRule, "triangleSubdivisionRule", "catmullClark", \
45 "Catmull-Clark's weights for triangles, or smoother ones.", .group = "Subdivision", \
46 .options = {"catmullClark", "smooth"}, .dirty = Dirty::Topology) \
47 ERNIE_MESH_INDICES(X, HoleIndices, "holeIndices", "Faces left out of the surface.") \
48 ERNIE_MESH_INDICES(X, CornerIndices, "cornerIndices", "Points that are sharp corners.") \
49 X(Tensor, CornerSharpnesses, "cornerSharpnesses", Tensor(), "The sharpness of each corner.", \
50 .group = "Subdivision", .dirty = Dirty::Topology) \
51 ERNIE_MESH_INDICES(X, CreaseIndices, "creaseIndices", \
52 "Point indices of creases, one after another.") \
53 ERNIE_MESH_INDICES(X, CreaseLengths, "creaseLengths", "The number of points of each crease.") \
54 X(Tensor, CreaseSharpnesses, "creaseSharpnesses", Tensor(), \
55 "The sharpness of each crease, or of each crease edge.", .group = "Subdivision", \
56 .dirty = Dirty::Topology) \
57 X(int, SubdivisionRefineLevel, "ernie:subdivision:refineLevel", 1, \
58 "Uniform refinement of the surface: 2^level segments along each control edge.", \
59 .label = "Refine level", .group = "Subdivision", .lower = AtLeast(0.0), \
60 .upper = AtMost(8.0), .dirty = Dirty::Topology)
61
62 #define ERNIE_WIDTHS_ATTRIBUTE(X, text) \
63 X(Tensor, Widths, "widths", Tensor(), text, .group = "Geometry", .dirty = Dirty::Points)
64
65 #define ERNIE_POINTS_ATTRIBUTES(X) \
66 ERNIE_WIDTHS_ATTRIBUTE(X, "Diameters in metres: one per point, or one for all.") \
67 X(Tensor, Ids, "ids", Tensor(), "int64 ids that follow points across time samples.", \
68 .group = "Geometry", .integer = true, .dirty = Dirty::Topology)
69
70 #define ERNIE_CURVES_ATTRIBUTES(X) \
71 ERNIE_MESH_INDICES(X, CurveVertexCounts, "curveVertexCounts", \
72 "The number of points of each curve.") \
73 ERNIE_WIDTHS_ATTRIBUTE(X, "Diameters in metres: per point, per segment end, or one for all.")
74
75 #define ERNIE_BASIS_CURVES_ATTRIBUTES(X) \
76 X(std::string, Type, "type", "cubic", "Linear segments, or cubic ones by the basis.", \
77 .group = "Topology", .options = {"linear", "cubic"}, .dirty = Dirty::Topology) \
78 X(std::string, Basis, "basis", "bezier", "The cubic basis.", .group = "Topology", \
79 .options = {"bezier", "bspline", "catmullRom"}, .dirty = Dirty::Topology) \
80 X(std::string, Wrap, "wrap", "nonperiodic", \
81 "Open curves, closed ones, or open ones through their end points.", .group = "Topology", \
82 .options = {"nonperiodic", "periodic", "pinned"}, .dirty = Dirty::Topology)
83
84 #define ERNIE_NURBS_CURVES_ATTRIBUTES(X) \
85 ERNIE_MESH_INDICES(X, Order, "order", "The order (degree + 1) of each curve.") \
86 X(Tensor, Knots, "knots", Tensor(), "Each curve's knots, curveVertexCount + order of them.", \
87 .group = "Topology", .dirty = Dirty::Topology) \
88 X(Tensor, Ranges, "ranges", Tensor(), "(n, 2) parametric range drawn of each curve.", \
89 .group = "Topology", .components = 2, .dirty = Dirty::Topology) \
90 X(Tensor, PointWeights, "pointWeights", Tensor(), "Rational weights, one per point.", \
91 .group = "Geometry", .dirty = Dirty::Points)
92
93 #define ERNIE_HERMITE_CURVES_ATTRIBUTES(X) \
94 X(Tensor, Tangents, "tangents", Tensor(), "(n, 3) tangent of each point.", \
95 .group = "Geometry", .components = 3, .dirty = Dirty::Points)
96 // clang-format on
97
98 namespace ernie {
99
100 15 ERNIE_SCHEMA(PointBased, Gprim, ERNIE_POINT_BASED_ATTRIBUTES, "Geometry from an array of points.");
101 15 ERNIE_CONCRETE_SCHEMA(Mesh, PointBased, ERNIE_MESH_ATTRIBUTES,
102 "A polygon mesh, or the control mesh of a subdivision surface.");
103 9 ERNIE_CONCRETE_SCHEMA(Points, PointBased, ERNIE_POINTS_ATTRIBUTES,
104 "A point cloud of spheres, each its own width.");
105 8 ERNIE_SCHEMA(Curves, PointBased, ERNIE_CURVES_ATTRIBUTES,
106 "Batched curves, each a run of points, swept by its widths.");
107 5 ERNIE_CONCRETE_SCHEMA(BasisCurves, Curves, ERNIE_BASIS_CURVES_ATTRIBUTES,
108 "Linear or cubic curves: hair, fur, cables and wires.");
109 2 ERNIE_CONCRETE_SCHEMA(NurbsCurves, Curves, ERNIE_NURBS_CURVES_ATTRIBUTES,
110 "Rational B-spline curves of any order.");
111 3 ERNIE_CONCRETE_SCHEMA(HermiteCurves, Curves, ERNIE_HERMITE_CURVES_ATTRIBUTES,
112 "Cubic curves through their points with a tangent at each.");
113
114 } // namespace ernie
115