Lagrange
Loading...
Searching...
No Matches
generate_torus.h
1/*
2 * Copyright 2019 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#ifdef LAGRANGE_ENABLE_LEGACY_HEADERS
15 #include <lagrange/primitive/legacy/generate_torus.h>
16#endif
17
18#include <lagrange/primitive/api.h>
19
20#include <lagrange/SurfaceMesh.h>
21#include <lagrange/internal/constants.h>
22#include <lagrange/primitive/PrimitiveOptions.h>
23
24namespace lagrange::primitive {
25
28
33{
34 using Scalar = PrimitiveOptions::Scalar;
35 using Index = size_t;
36
39 Scalar major_radius = 5;
40
43 Scalar minor_radius = 1;
44
47 Index ring_segments = 50;
48
51 Index pipe_segments = 50;
52
56
59 Scalar end_sweep_angle = static_cast<Scalar>(2 * lagrange::internal::pi);
60
73 {
74 minor_radius = std::max(minor_radius, static_cast<Scalar>(0.0));
75 major_radius = std::max(major_radius, static_cast<Scalar>(minor_radius));
76 ring_segments = std::max(ring_segments, static_cast<Index>(3));
77 pipe_segments = std::max(pipe_segments, static_cast<Index>(3));
78 }
79};
80
100template <typename Scalar, typename Index>
101LA_PRIMITIVE_API SurfaceMesh<Scalar, Index> generate_torus(TorusOptions setting);
102
104
105} // namespace lagrange::primitive
A general purpose polygonal mesh class.
Definition SurfaceMesh.h:73
SurfaceMesh< Scalar, Index > generate_torus(TorusOptions setting)
Generate a torus mesh.
Definition generate_torus.cpp:42
Common settings shared by all primitives.
Definition PrimitiveOptions.h:28
Options for generating a torus mesh.
Definition generate_torus.h:33
void project_to_valid_range()
Clamps all parameters to valid ranges.
Definition generate_torus.h:72
Scalar start_sweep_angle
Starting angle for partial torus generation (in radians).
Definition generate_torus.h:55
Index ring_segments
Number of subdivisions around the major circumference (around the donut hole).
Definition generate_torus.h:47
Scalar minor_radius
Radius of the tube that forms the torus (thickness of the donut).
Definition generate_torus.h:43
Scalar major_radius
Distance from the center of the torus to the center of the tube (donut hole to tube center).
Definition generate_torus.h:39
Scalar end_sweep_angle
Ending angle for partial torus generation (in radians).
Definition generate_torus.h:59
Index pipe_segments
Number of subdivisions around the minor circumference (around the tube).
Definition generate_torus.h:51