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/primitive/api.h>
15
16#include <lagrange/SurfaceMesh.h>
17#include <lagrange/internal/constants.h>
18#include <lagrange/primitive/PrimitiveOptions.h>
19
20#include <array>
21
22namespace lagrange::primitive {
23
26
28{
29 using Scalar = PrimitiveOptions::Scalar;
30
32 Scalar radius = 1.0;
33
35 Scalar start_angle = 0.0;
36
38 Scalar end_angle = static_cast<Scalar>(2 * lagrange::internal::pi);
39
41 size_t radial_sections = 32;
42
44 size_t num_rings = 1;
45
47 std::array<Scalar, 3> normal = {0, 0, 1};
48
49 void project_to_valid_range()
50 {
51 radius = std::max(radius, Scalar(0));
52 radial_sections = std::max(radial_sections, size_t(3));
53 num_rings = std::max(num_rings, size_t(1));
54 }
55};
56
66template <typename Scalar, typename Index>
67LA_PRIMITIVE_API SurfaceMesh<Scalar, Index> generate_disc(DiscOptions setting);
68
70
71} // 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:28
size_t radial_sections
Number of radial sections (spokes) in the disc.
Definition generate_disc.h:41
Scalar end_angle
End angle of the disc in radians.
Definition generate_disc.h:38
std::array< Scalar, 3 > normal
Unit normal vector for the disc.
Definition generate_disc.h:47
Scalar start_angle
Start angle of the disc in radians.
Definition generate_disc.h:35
Scalar radius
Radius of the disc.
Definition generate_disc.h:32
size_t num_rings
Number of concentric rings in the disc.
Definition generate_disc.h:44
Common settings shared by all primitives.
Definition PrimitiveOptions.h:28