Avara3D 0.2.0
C++ API reference
TorusKnot.h
1//
2// TorusKnot.h
3// avara3d
4//
5// Created by Morgan Davis on 3/6/24.
6// Copyright © 2026 Morgan K Davis. All rights reserved.
7//
8
9#ifndef AVARA3D_MESH_PRIMITIVE_TORUSKNOT_H
10#define AVARA3D_MESH_PRIMITIVE_TORUSKNOT_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 TorusKnot : public MeshElement {
27
28 public:
29 // [Public Static Member Functions]
30
32 static std::shared_ptr<Mesh> Mesh(unsigned p,
33 unsigned q,
34 unsigned slices = DEFAULT_SLICES,
35 unsigned segments = DEFAULT_SEGMENTS,
36 std::shared_ptr<Material> material = nullptr);
37
38 // [Public Lifecycle Functions]
39
41 TorusKnot(unsigned p,
42 unsigned q,
43 unsigned slices = DEFAULT_SLICES,
44 unsigned segments = DEFAULT_SEGMENTS);
45
46 // [Public Member Functions]
47
49 unsigned p() const;
50
52 unsigned q() const;
53
55 unsigned slices() const;
56
58 unsigned segments() const;
59
60 private:
61 // [Private Constants]
62
63 static constexpr unsigned DEFAULT_SLICES = 8;
64 static constexpr unsigned DEFAULT_SEGMENTS = 96;
65
66 // [Private Member Variables]
67
68 unsigned _p;
69 unsigned _q;
70 unsigned _slices;
71 unsigned _segments;
72 };
73
74}
75
76#endif // AVARA3D_MESH_PRIMITIVE_TORUSKNOT_H
Owns the vertex and optional index data for one mesh primitive.
Definition: MeshElement.h:43
Tubular torus-knot mesh element controlled by the knot parameters p and q.
Definition: TorusKnot.h:26
unsigned slices() const
Returns the tube cross-section subdivision count.
unsigned q() const
Returns the configured q knot parameter.
TorusKnot(unsigned p, unsigned q, unsigned slices=DEFAULT_SLICES, unsigned segments=DEFAULT_SEGMENTS)
Generates torus-knot geometry with the supplied knot parameters and subdivisions.
unsigned segments() const
Returns the knot-path subdivision count.
static std::shared_ptr< Mesh > Mesh(unsigned p, unsigned q, unsigned slices=DEFAULT_SLICES, unsigned segments=DEFAULT_SEGMENTS, std::shared_ptr< Material > material=nullptr)
Creates a Mesh containing a TorusKnot and optional material.
unsigned p() const
Returns the configured p knot parameter.