2#ifndef _TINYPBRT_SHAPE_HPP_
3#define _TINYPBRT_SHAPE_HPP_
55 case CURVE:
return "curve";
57 case DISK:
return "disk";
58 case SPHERE:
return "sphere";
63 default:
return "UNKNOWN";
89 case BEZIER:
return "bezier";
92 default:
return "UNKNOWN";
118 default:
return "UNKNOWN";
146 case FLAT:
return "flat";
148 case RIBBON:
return "ribbon";
150 default:
return "UNKNOWN";
160 using wrapper::wrapper;
166 [[nodiscard]]
constexpr point3_array p() const noexcept {
return _native->p; }
169 [[nodiscard]]
constexpr normal_array n() const noexcept {
return _native->n; }
175 [[nodiscard]]
constexpr auto reflect() const noexcept {
return std::make_tuple(
indices(),
p(),
n(),
uv()); }
191 using wrapper::wrapper;
194 [[nodiscard]]
constexpr p_array_type p() const noexcept {
return _native->p; }
197 [[nodiscard]]
constexpr n_array_type n() const noexcept {
return _native->n; }
200 [[nodiscard]]
constexpr float_t width() const noexcept {
return _native->width; }
225 [[nodiscard]]
constexpr auto reflect() const noexcept {
236 using wrapper::wrapper;
239 [[nodiscard]]
constexpr float_t radius() const noexcept {
return _native->radius; }
242 [[nodiscard]]
constexpr float_t z_min() const noexcept {
return _native->z_min; }
245 [[nodiscard]]
constexpr float_t z_max() const noexcept {
return _native->z_max; }
248 [[nodiscard]]
constexpr float_t phi_max() const noexcept {
return _native->phi_max; }
260 using wrapper::wrapper;
263 [[nodiscard]]
constexpr float_t height() const noexcept {
return _native->height; }
266 [[nodiscard]]
constexpr float_t radius() const noexcept {
return _native->radius; }
272 [[nodiscard]]
constexpr float_t phi_max() const noexcept {
return _native->phi_max; }
275 [[nodiscard]]
constexpr auto reflect() const noexcept {
286 using wrapper::wrapper;
289 [[nodiscard]]
constexpr float_t radius() const noexcept {
return _native->radius; }
292 [[nodiscard]]
constexpr float_t z_min() const noexcept {
return _native->z_min; }
295 [[nodiscard]]
constexpr float_t z_max() const noexcept {
return _native->z_max; }
298 [[nodiscard]]
constexpr float_t phi_max() const noexcept {
return _native->phi_max; }
310 using wrapper::wrapper;
316 [[nodiscard]]
constexpr point3_array p() const noexcept {
return _native->p; }
319 [[nodiscard]]
constexpr normal_array n() const noexcept {
return _native->n; }
322 [[nodiscard]]
constexpr vec3_array s() const noexcept {
return _native->s; }
328 [[nodiscard]]
constexpr auto reflect() const noexcept {
return std::make_tuple(
indices(),
p(),
n(),
s(),
uv()); }
337 using wrapper::wrapper;
340 [[nodiscard]]
constexpr string file_name() const noexcept {
return _native->file_name; }
349 [[nodiscard]]
constexpr auto reflect() const noexcept {
360 using wrapper::wrapper;
366 [[nodiscard]]
constexpr point_array p() const noexcept {
return _native->p; }
369 [[nodiscard]]
constexpr uint_t levels() const noexcept {
return _native->levels; }
380 : detail::wrapper<shape, tpbrt_shape_t>,
381 detail::with_variant<shape, shape_bilinear_mesh_params, shape_curve_params, shape_cylinder_params, shape_disk_params,
382 shape_sphere_params, shape_triangle_mesh_params, shape_ply_mesh_params, shape_loop_subdiv_params> {
384 using wrapper::wrapper;
435 [[nodiscard]]
constexpr std::optional<shape_bilinear_mesh_params>
as_bilinear_mesh() const noexcept {
437 return _native->as.bilinear_mesh;
441 [[nodiscard]]
constexpr std::optional<shape_curve_params>
as_curve() const noexcept {
442 if (!
is_curve()) {
return std::nullopt; }
443 return _native->as.curve;
447 [[nodiscard]]
constexpr std::optional<shape_cylinder_params>
as_cylinder() const noexcept {
449 return _native->as.cylinder;
453 [[nodiscard]]
constexpr std::optional<shape_disk_params>
as_disk() const noexcept {
454 if (!
is_disk()) {
return std::nullopt; }
455 return _native->as.disk;
459 [[nodiscard]]
constexpr std::optional<shape_sphere_params>
as_sphere() const noexcept {
460 if (!
is_sphere()) {
return std::nullopt; }
461 return _native->as.sphere;
465 [[nodiscard]]
constexpr std::optional<shape_triangle_mesh_params>
as_triangle_mesh() const noexcept {
467 return _native->as.triangle_mesh;
471 [[nodiscard]]
constexpr std::optional<shape_ply_mesh_params>
as_ply_mesh() const noexcept {
473 return _native->as.ply_mesh;
477 [[nodiscard]]
constexpr std::optional<shape_loop_subdiv_params>
as_loop_subdiv() const noexcept {
479 return _native->as.loop_subdiv;
483 [[nodiscard]]
constexpr variant_type
to_variant() const noexcept {
487 case CURVE:
return _native->as.curve;
488 case CYLINDER:
return _native->as.cylinder;
489 case DISK:
return _native->as.disk;
490 case SPHERE:
return _native->as.sphere;
492 case PLY_MESH:
return _native->as.ply_mesh;
501 [[nodiscard]]
constexpr auto reflect() const noexcept {
constexpr std::string_view to_string(const accelerator_type type) noexcept
Converts accelerator_type enum value to string.
Definition accelerator.hpp:39
@ MAX_NUM
Count of available accelerator types.
tpbrt_uchar_t uchar_t
Unsigned char type.
Definition fwd.hpp:34
tpbrt_uint_t uint_t
Unsigned int type.
Definition fwd.hpp:92
bool bool_t
Bool type.
Definition fwd.hpp:82
tpbrt_float_t float_t
Float type.
Definition fwd.hpp:97
shape_curve_type
Curve shape type.
Definition shape.hpp:126
shape_type
Shape types.
Definition shape.hpp:24
shape_curve_basis
Curve shape basis.
Definition shape.hpp:71
shape_curve_degree
Curve shape degree.
Definition shape.hpp:100
@ RIBBON
Curve has a fixed orientation.
@ FLAT
Curve is always oriented to face the incident ray.
@ BILINEAR_MESH
Bilinear mesh.
@ LOOP_SUBDIV
Loop subdivision.
@ TRIANGLE_MESH
Triangle mesh.
@ TPBRT_SHAPE_CURVE_DEGREE_3
3 Degree.
Definition shape.h:68
@ TPBRT_SHAPE_CURVE_DEGREE_2
2 Degree.
Definition shape.h:66
@ TPBRT_SHAPE_CURVE_TYPE_FLAT
Curve is always oriented to face the incident ray.
Definition shape.h:77
@ TPBRT_SHAPE_CURVE_TYPE_RIBBON
Curve has a fixed orientation.
Definition shape.h:81
@ TPBRT_SHAPE_CURVE_TYPE_CYLINDER
Alternative includes a shading normal that causes the curve to appear to have a cylindrical cross sec...
Definition shape.h:79
@ TPBRT_SHAPE_CURVE_TYPE_MAX_NUM
Count of available curve types.
Definition shape.h:83
@ TPBRT_SHAPE_TYPE_BILINEAR_MESH
Bilinear mesh.
Definition shape.h:28
@ TPBRT_SHAPE_TYPE_SPHERE
Sphere.
Definition shape.h:36
@ TPBRT_SHAPE_TYPE_PLY_MESH
Ply file mesh.
Definition shape.h:40
@ TPBRT_SHAPE_TYPE_LOOP_SUBDIV
Loop subdivision.
Definition shape.h:42
@ TPBRT_SHAPE_TYPE_CYLINDER
Cylinder.
Definition shape.h:32
@ TPBRT_SHAPE_TYPE_TRIANGLE_MESH
Triangle mesh.
Definition shape.h:38
@ TPBRT_SHAPE_TYPE_MAX_NUM
Count of available shape types.
Definition shape.h:44
@ TPBRT_SHAPE_TYPE_DISK
Disk.
Definition shape.h:34
@ TPBRT_SHAPE_TYPE_CURVE
Curve.
Definition shape.h:30
@ TPBRT_SHAPE_CURVE_BASIS_BEZIER
Bezier curve.
Definition shape.h:53
@ TPBRT_SHAPE_CURVE_BASIS_BSPLINE
BSpline curve.
Definition shape.h:55
@ TPBRT_SHAPE_CURVE_BASIS_MAX_NUM
Count of available curve shape basis.
Definition shape.h:57
Definition accelerator.hpp:14
C++ wrapper for tpbrt_area_light_handle_t.
Definition light.hpp:403
Generic C++ array view with type conversion (a non owning view on memory owned by the C library).
Definition common.hpp:448
C++ wrapper for tpbrt_material_handle_t.
Definition material.hpp:81
C++ wrapper for tpbrt_opt_float_t.
Definition math.hpp:24
C++ wrapper for tpbrt_shape_bilinear_mesh_params_t.
Definition shape.hpp:158
constexpr uint_array indices() const noexcept
Returns indices value.
Definition shape.hpp:163
constexpr auto reflect() const noexcept
Conversion to tuple.
Definition shape.hpp:175
constexpr point3_array p() const noexcept
Returns p value.
Definition shape.hpp:166
constexpr point2_array uv() const noexcept
Returns uv value.
Definition shape.hpp:172
constexpr normal_array n() const noexcept
Returns n value.
Definition shape.hpp:169
C++ wrapper for tpbrt_shape_curve_params_t.
Definition shape.hpp:182
constexpr auto reflect() const noexcept
Conversion to tuple.
Definition shape.hpp:225
constexpr shape_curve_basis basis() const noexcept
Returns basis value.
Definition shape.hpp:212
constexpr uint_t split_depth() const noexcept
Returns split_depth value.
Definition shape.hpp:209
constexpr n_array_type n() const noexcept
Returns n value.
Definition shape.hpp:197
constexpr p_array_type p() const noexcept
Returns p value.
Definition shape.hpp:194
constexpr float_t width() const noexcept
Returns width value.
Definition shape.hpp:200
constexpr shape_curve_degree degree() const noexcept
Returns degree value.
Definition shape.hpp:217
constexpr opt_float width1() const noexcept
Returns width1 value.
Definition shape.hpp:206
constexpr opt_float width0() const noexcept
Returns width0 value.
Definition shape.hpp:203
constexpr shape_curve_type type() const noexcept
Returns type value.
Definition shape.hpp:222
C++ wrapper for tpbrt_shape_cylinder_params_t.
Definition shape.hpp:234
constexpr float_t z_max() const noexcept
Returns z_max value.
Definition shape.hpp:245
constexpr float_t radius() const noexcept
Returns radius value.
Definition shape.hpp:239
constexpr float_t phi_max() const noexcept
Returns phi_max value.
Definition shape.hpp:248
constexpr auto reflect() const noexcept
Conversion to tuple.
Definition shape.hpp:251
constexpr float_t z_min() const noexcept
Returns z_min value.
Definition shape.hpp:242
C++ wrapper for tpbrt_shape_disk_params_t.
Definition shape.hpp:258
constexpr float_t phi_max() const noexcept
Returns phi_max value.
Definition shape.hpp:272
constexpr float_t height() const noexcept
Returns height value.
Definition shape.hpp:263
constexpr auto reflect() const noexcept
Conversion to tuple.
Definition shape.hpp:275
constexpr float_t inner_radius() const noexcept
Returns inner_radius value.
Definition shape.hpp:269
constexpr float_t radius() const noexcept
Returns radius value.
Definition shape.hpp:266
C++ wrapper for tpbrt_shape_loop_subdiv_params_t.
Definition shape.hpp:358
constexpr point_array p() const noexcept
Returns p value.
Definition shape.hpp:366
constexpr auto reflect() const noexcept
Conversion to tuple.
Definition shape.hpp:372
constexpr uint_array indices() const noexcept
Returns indices value.
Definition shape.hpp:363
constexpr uint_t levels() const noexcept
Returns levels value.
Definition shape.hpp:369
C++ wrapper for tpbrt_shape_ply_mesh_params_t.
Definition shape.hpp:335
constexpr string file_name() const noexcept
Returns file_name value.
Definition shape.hpp:340
constexpr texture_handle displacement() const noexcept
Returns displacement value.
Definition shape.hpp:343
constexpr float_t edge_length() const noexcept
Returns edge_length value.
Definition shape.hpp:346
constexpr auto reflect() const noexcept
Conversion to tuple.
Definition shape.hpp:349
C++ wrapper for tpbrt_shape_sphere_params_t.
Definition shape.hpp:284
constexpr auto reflect() const noexcept
Conversion to tuple.
Definition shape.hpp:301
constexpr float_t phi_max() const noexcept
Returns phi_max value.
Definition shape.hpp:298
constexpr float_t z_min() const noexcept
Returns z_min value.
Definition shape.hpp:292
constexpr float_t z_max() const noexcept
Returns z_max value.
Definition shape.hpp:295
constexpr float_t radius() const noexcept
Returns radius value.
Definition shape.hpp:289
C++ wrapper for tpbrt_shape_triangle_mesh_params_t.
Definition shape.hpp:308
constexpr normal_array n() const noexcept
Returns n value.
Definition shape.hpp:319
constexpr point3_array p() const noexcept
Returns p value.
Definition shape.hpp:316
constexpr point2_array uv() const noexcept
Returns uv value.
Definition shape.hpp:325
constexpr uint_array indices() const noexcept
Returns indices value.
Definition shape.hpp:313
constexpr vec3_array s() const noexcept
Returns s value.
Definition shape.hpp:322
constexpr auto reflect() const noexcept
Conversion to tuple.
Definition shape.hpp:328
C++ wrapper for tpbrt_shape_t.
Definition shape.hpp:382
constexpr texture_handle alpha() const noexcept
Returns alpha value.
Definition shape.hpp:387
constexpr std::optional< shape_ply_mesh_params > as_ply_mesh() const noexcept
Returns shape parameters as ply_mesh.
Definition shape.hpp:471
constexpr bool_t is_curve() const noexcept
Returns true if type is curve.
Definition shape.hpp:414
constexpr std::optional< shape_disk_params > as_disk() const noexcept
Returns shape parameters as disk.
Definition shape.hpp:453
constexpr material_handle material() const noexcept
Returns material value.
Definition shape.hpp:393
constexpr bool_t is_bilinear_mesh() const noexcept
Returns true if type is bilinear_mesh.
Definition shape.hpp:411
constexpr std::optional< shape_curve_params > as_curve() const noexcept
Returns shape parameters as curve.
Definition shape.hpp:441
constexpr shape_type type() const noexcept
Returns type value.
Definition shape.hpp:408
constexpr std::optional< shape_bilinear_mesh_params > as_bilinear_mesh() const noexcept
Returns shape parameters as bilinear_mesh.
Definition shape.hpp:435
constexpr bool_t is_cylinder() const noexcept
Returns true if type is cylinder.
Definition shape.hpp:417
constexpr bool_t reverse_orientation() const noexcept
Returns reverse_orientation value.
Definition shape.hpp:405
constexpr bool_t is_loop_subdiv() const noexcept
Returns true if type is loop_subdiv.
Definition shape.hpp:432
constexpr std::optional< shape_loop_subdiv_params > as_loop_subdiv() const noexcept
Returns shape parameters as loop_subdiv.
Definition shape.hpp:477
constexpr bool_t is_sphere() const noexcept
Returns true if type is sphere.
Definition shape.hpp:423
constexpr bool_t is_disk() const noexcept
Returns true if type is disk.
Definition shape.hpp:420
constexpr media_handle exterior_media_handle() const noexcept
Returns exterior_media_handle value.
Definition shape.hpp:402
constexpr std::optional< shape_sphere_params > as_sphere() const noexcept
Returns shape parameters as sphere.
Definition shape.hpp:459
constexpr auto reflect() const noexcept
Conversion to tuple.
Definition shape.hpp:501
constexpr area_light_handle area_light() const noexcept
Returns area_light value.
Definition shape.hpp:396
constexpr bool_t is_triangle_mesh() const noexcept
Returns true if type is triangle_mesh.
Definition shape.hpp:426
constexpr media_handle interior_media_handle() const noexcept
Returns interior_media_handle value.
Definition shape.hpp:399
constexpr transform_animated transform() const noexcept
Returns transform value.
Definition shape.hpp:390
constexpr variant_type to_variant() const noexcept
Conversion to variant.
Definition shape.hpp:483
constexpr bool_t is_ply_mesh() const noexcept
Returns true if type is ply_mesh.
Definition shape.hpp:429
constexpr std::optional< shape_cylinder_params > as_cylinder() const noexcept
Returns shape parameters as cylinder.
Definition shape.hpp:447
constexpr std::optional< shape_triangle_mesh_params > as_triangle_mesh() const noexcept
Returns shape parameters as triangle_mesh.
Definition shape.hpp:465
C++ wrapper for tpbrt_shapes_list_t.
Definition shape.hpp:511
C++ wrapper for tpbrt_texture_handle_t.
Definition texture.hpp:53
C++ wrapper for tpbrt_uint_array_t.
Definition math.hpp:69
C++ wrapper for tpbrt_vec2_array_t.
Definition math.hpp:198
C++ wrapper for tpbrt_vec3_array_t.
Definition math.hpp:207