Avara3D 0.2.0
C++ API reference
Torus.h
1//
2// Torus.h
3// avara3d
4//
5// Created by Morgan Davis on 11/8/17.
6// Copyright © 2026 Morgan K Davis. All rights reserved.
7//
8
9#ifndef AVARA3D_MESH_PRIMITIVE_TORUS_H
10#define AVARA3D_MESH_PRIMITIVE_TORUS_H
11
12#include <memory>
13
14#include "a3d/mesh/MeshElement.h"
15
16namespace a3d {
17
18 class Mesh;
19 class Material;
20
26 class Torus : public MeshElement {
27
28 public:
29 // [Public Static Member Functions]
30
32 static std::shared_ptr<Mesh> Mesh(float minorRadius,
33 float majorRadius,
34 unsigned slices = DEFAULT_SLICES,
35 unsigned segments = DEFAULT_SEGMENTS,
36 std::shared_ptr<Material> material = nullptr);
37
38 // [Public Lifecycle Functions]
39
42 float majorRadius,
43 unsigned slices = DEFAULT_SLICES,
44 unsigned segments = DEFAULT_SEGMENTS);
45
46 // [Public Member Functions]
47
49 float minorRadius() const;
50
52 float majorRadius() const;
53
55 unsigned slices() const;
56
58 unsigned segments() const;
59
60 private:
61 // [Private Constants]
62
63 static constexpr unsigned DEFAULT_SLICES = 16;
64 static constexpr unsigned DEFAULT_SEGMENTS = 32;
65
66 // [Private Member Variables]
67
68 float _minorRadius;
69 float _majorRadius;
70 unsigned _slices;
71 unsigned _segments;
72 };
73
74}
75
76#endif // AVARA3D_MESH_PRIMITIVE_TORUS_H
Owns the vertex and optional index data for one mesh primitive.
Definition: MeshElement.h:43
Torus mesh element centered at the origin in the XY plane.
Definition: Torus.h:26
unsigned segments() const
Returns the major-ring subdivision count.
unsigned slices() const
Returns the minor-ring subdivision count.
float majorRadius() const
Returns the configured major-radius parameter.
static std::shared_ptr< Mesh > Mesh(float minorRadius, float majorRadius, unsigned slices=DEFAULT_SLICES, unsigned segments=DEFAULT_SEGMENTS, std::shared_ptr< Material > material=nullptr)
Creates a Mesh containing a Torus and optional material.
Torus(float minorRadius, float majorRadius, unsigned slices=DEFAULT_SLICES, unsigned segments=DEFAULT_SEGMENTS)
Generates torus geometry with the supplied radii and subdivision counts.
float minorRadius() const
Returns the configured minor-radius parameter.