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_HEADERS
15 #include <lagrange/primitive/legacy/generate_sphere.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
38 Scalar radius = 1;
39
42
44 Scalar end_sweep_angle = static_cast<Scalar>(2 * lagrange::internal::pi);
45
48
51
56 {
57 radius = std::max(radius, Scalar(0.0));
58 num_longitude_sections = std::max(num_longitude_sections, static_cast<Index>(3));
59 num_latitude_sections = std::max(num_latitude_sections, static_cast<Index>(3));
60 }
61};
62
76template <typename Scalar, typename Index>
77LA_PRIMITIVE_API SurfaceMesh<Scalar, Index> generate_sphere(SphereOptions setting);
78
80
81} // namespace lagrange::primitive
A general purpose polygonal mesh class.
Definition SurfaceMesh.h:73
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:33
void project_to_valid_range()
Project setting into valid range.
Definition generate_sphere.h:55
Scalar start_sweep_angle
Sphere starting angle in radians.
Definition generate_sphere.h:41
Index num_latitude_sections
Number of sections along the latitude (horizontal) direction.
Definition generate_sphere.h:50
Index num_longitude_sections
Number of sections along the longitude (vertical) direction.
Definition generate_sphere.h:47
Scalar radius
Sphere radius.
Definition generate_sphere.h:38
Scalar end_sweep_angle
Sphere ending angle in radians.
Definition generate_sphere.h:44