Lagrange
Loading...
Searching...
No Matches
generate_sphere.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_sphere.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
36 Scalar radius = 1;
37
40
42 Scalar end_sweep_angle = static_cast<Scalar>(2 * lagrange::internal::pi);
43
46
49
54 {
55 radius = std::max(radius, Scalar(0.0));
56 num_longitude_sections = std::max(num_longitude_sections, static_cast<Index>(3));
57 num_latitude_sections = std::max(num_latitude_sections, static_cast<Index>(3));
58 }
59};
60
74template <typename Scalar, typename Index>
75SurfaceMesh<Scalar, Index> generate_sphere(SphereOptions setting);
76
78
79} // namespace lagrange::primitive
A general purpose polygonal mesh class.
Definition SurfaceMesh.h:66
SurfaceMesh< Scalar, Index > generate_sphere(SphereOptions setting)
Generate a sphere mesh based on the specified settings.
Definition generate_sphere.cpp:59
Common settings shared by all primitives.
Definition PrimitiveOptions.h:28
Options for generating a sphere mesh.
Definition generate_sphere.h:31
void project_to_valid_range()
Project setting into valid range.
Definition generate_sphere.h:53
Scalar start_sweep_angle
Sphere starting angle in radians.
Definition generate_sphere.h:39
Index num_latitude_sections
Number of sections along the latitude (horizontal) direction.
Definition generate_sphere.h:48
Index num_longitude_sections
Number of sections along the longitude (vertical) direction.
Definition generate_sphere.h:45
Scalar radius
Sphere radius.
Definition generate_sphere.h:36
Scalar end_sweep_angle
Sphere ending angle in radians.
Definition generate_sphere.h:42