Lagrange
Loading...
Searching...
No Matches
generate_disc.h
1/*
2 * Copyright 2025 Adobe. All rights reserved.
3 * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License. You may obtain a copy
5 * of the License at http://www.apache.org/licenses/LICENSE-2.0
6 *
7 * Unless required by applicable law or agreed to in writing, software distributed under
8 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9 * OF ANY KIND, either express or implied. See the License for the specific language
10 * governing permissions and limitations under the License.
11 */
12#pragma once
13
14#include <lagrange/SurfaceMesh.h>
15#include <lagrange/internal/constants.h>
16#include <lagrange/primitive/PrimitiveOptions.h>
17
18#include <array>
19
20namespace lagrange::primitive {
21
24
26{
27 using Scalar = PrimitiveOptions::Scalar;
28
30 Scalar radius = 1.0;
31
33 Scalar start_angle = 0.0;
34
36 Scalar end_angle = static_cast<Scalar>(2 * lagrange::internal::pi);
37
39 size_t radial_sections = 32;
40
42 size_t num_rings = 1;
43
45 std::array<Scalar, 3> normal = {0, 0, 1};
46
47 void project_to_valid_range()
48 {
49 radius = std::max(radius, Scalar(0));
50 radial_sections = std::max(radial_sections, size_t(3));
51 num_rings = std::max(num_rings, size_t(1));
52 }
53};
54
64template <typename Scalar, typename Index>
65SurfaceMesh<Scalar, Index> generate_disc(DiscOptions setting);
66
68
69} // namespace lagrange::primitive
@ Scalar
Mesh attribute must have exactly 1 channel.
Definition AttributeFwd.h:56
SurfaceMesh< Scalar, Index > generate_disc(DiscOptions setting)
Generates a disc mesh with the specified settings.
Definition generate_disc.cpp:31
Definition generate_disc.h:26
size_t radial_sections
Number of radial sections (spokes) in the disc.
Definition generate_disc.h:39
Scalar end_angle
End angle of the disc in radians.
Definition generate_disc.h:36
std::array< Scalar, 3 > normal
Unit normal vector for the disc.
Definition generate_disc.h:45
Scalar start_angle
Start angle of the disc in radians.
Definition generate_disc.h:33
Scalar radius
Radius of the disc.
Definition generate_disc.h:30
size_t num_rings
Number of concentric rings in the disc.
Definition generate_disc.h:42
Common settings shared by all primitives.
Definition PrimitiveOptions.h:28