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_FUNCTIONS
15 #include <lagrange/primitive/legacy/generate_torus.h>
16#endif
17
18#include <lagrange/SurfaceMesh.h>
19#include <lagrange/internal/constants.h>
20#include <lagrange/primitive/PrimitiveOptions.h>
21
22namespace lagrange::primitive {
23
26
31{
32 using Scalar = PrimitiveOptions::Scalar;
33 using Index = size_t;
34
37 Scalar major_radius = 5;
38
41 Scalar minor_radius = 1;
42
45 Index ring_segments = 50;
46
49 Index pipe_segments = 50;
50
54
57 Scalar end_sweep_angle = static_cast<Scalar>(2 * lagrange::internal::pi);
58
71 {
72 minor_radius = std::max(minor_radius, static_cast<Scalar>(0.0));
73 major_radius = std::max(major_radius, static_cast<Scalar>(minor_radius));
74 ring_segments = std::max(ring_segments, static_cast<Index>(3));
75 pipe_segments = std::max(pipe_segments, static_cast<Index>(3));
76 }
77};
78
98template <typename Scalar, typename Index>
99SurfaceMesh<Scalar, Index> generate_torus(TorusOptions setting);
100
102
103} // namespace lagrange::primitive
A general purpose polygonal mesh class.
Definition SurfaceMesh.h:66
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:31
void project_to_valid_range()
Clamps all parameters to valid ranges.
Definition generate_torus.h:70
Scalar start_sweep_angle
Starting angle for partial torus generation (in radians).
Definition generate_torus.h:53
Index ring_segments
Number of subdivisions around the major circumference (around the donut hole).
Definition generate_torus.h:45
Scalar minor_radius
Radius of the tube that forms the torus (thickness of the donut).
Definition generate_torus.h:41
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:37
Scalar end_sweep_angle
Ending angle for partial torus generation (in radians).
Definition generate_torus.h:57
Index pipe_segments
Number of subdivisions around the minor circumference (around the tube).
Definition generate_torus.h:49