Lagrange
Loading...
Searching...
No Matches
GeodesicEngine.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/SurfaceMesh.h>
15#include <lagrange/geodesic/api.h>
16
17#include <functional>
18
19namespace lagrange::geodesic {
20
24struct LA_GEODESIC_API SingleSourceGeodesicOptions
25{
27 size_t source_facet_id = 0;
28
32 std::array<double, 2> source_facet_bc = {0.0f, 0.0f};
33
38 std::array<double, 3> ref_dir = {0.0f, 1.0f, 0.0f};
39
44 std::array<double, 3> second_ref_dir = {1.0f, 0.0f, 0.0f};
45
52 double radius = -1.0f;
53
55 std::string_view output_geodesic_attribute_name = "@geodesic_distance";
56
58 std::string_view output_polar_angle_attribute_name = "@polar_angle";
59};
60
72
76struct LA_GEODESIC_API PointToPointGeodesicOptions
77{
79 size_t source_facet_id = 0;
80
82 size_t target_facet_id = 0;
83
87 std::array<double, 2> source_facet_bc = {0.0f, 0.0f};
88
92 std::array<double, 2> target_facet_bc = {0.0f, 0.0f};
93};
94
101template <typename Scalar, typename Index>
103{
104public:
107
108public:
109public:
115 explicit GeodesicEngine(Mesh& mesh);
116
120 virtual ~GeodesicEngine() = default;
121
130 const SingleSourceGeodesicOptions& options) = 0;
131
140
141protected:
142 const Mesh& mesh() const { return m_mesh.get(); }
143 Mesh& mesh() { return m_mesh.get(); }
144
145private:
146 std::reference_wrapper<Mesh> m_mesh;
147};
148
149} // namespace lagrange::geodesic
Definition Mesh.h:48
A general purpose polygonal mesh class.
Definition SurfaceMesh.h:66
virtual ~GeodesicEngine()=default
Base class destructor.
virtual SingleSourceGeodesicResult single_source_geodesic(const SingleSourceGeodesicOptions &options)=0
Computes geodesic distance from one source to each vertex on the mesh.
GeodesicEngine(Mesh &mesh)
Base class constructor.
Definition GeodesicEngine.cpp:20
SurfaceMesh< Scalar, Index > Mesh
The mesh type.
Definition GeodesicEngine.h:106
virtual Scalar point_to_point_geodesic(const PointToPointGeodesicOptions &options)
Computes the geodesic distance between two points on the mesh.
Definition GeodesicEngine.cpp:33
uint32_t AttributeId
Identified to be used to access an attribute.
Definition AttributeFwd.h:73
constexpr AttributeId invalid_attribute_id()
Invalid attribute id.
Definition AttributeFwd.h:76
@ Scalar
Mesh attribute must have exactly 1 channel.
Definition AttributeFwd.h:56
General options for point-to-point geodesic computations.
Definition GeodesicEngine.h:77
std::array< double, 2 > target_facet_bc
Barycentric coordinates of the target point within the target facet.
Definition GeodesicEngine.h:92
size_t target_facet_id
Facets containing the target point.
Definition GeodesicEngine.h:82
std::array< double, 2 > source_facet_bc
Barycentric coordinates of the source point within the source facet.
Definition GeodesicEngine.h:87
size_t source_facet_id
Facet containing the source point.
Definition GeodesicEngine.h:79
General options for one-to-many geodesic computations.
Definition GeodesicEngine.h:25
std::array< double, 3 > second_ref_dir
The secondary reference up direction for the geodesic polar coordinates.
Definition GeodesicEngine.h:44
std::string_view output_geodesic_attribute_name
The name of the output attribute to store the geodesic distance.
Definition GeodesicEngine.h:55
double radius
The maximum geodesic distance from the seed point to consider.
Definition GeodesicEngine.h:52
std::array< double, 2 > source_facet_bc
The barycentric coordinates of the seed facet.
Definition GeodesicEngine.h:32
size_t source_facet_id
The facet id of the seed facet.
Definition GeodesicEngine.h:27
std::array< double, 3 > ref_dir
The reference up direction for the geodesic polar coordinates.
Definition GeodesicEngine.h:38
std::string_view output_polar_angle_attribute_name
The name of the output attribute to store the geodesic polar coordinates.
Definition GeodesicEngine.h:58
Result of a single source geodesic computation.
Definition GeodesicEngine.h:65
AttributeId polar_angle_id
The attribute id of the polar angle attribute, if available.
Definition GeodesicEngine.h:70
AttributeId geodesic_distance_id
The attribute id of the geodesic distance attribute.
Definition GeodesicEngine.h:67