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 <array>
18#include <functional>
19#include <vector>
20
21namespace lagrange::geodesic {
22
26struct LA_GEODESIC_API SingleSourceGeodesicOptions
27{
29 size_t source_facet_id = 0;
30
34 std::array<double, 2> source_facet_bc = {0.0f, 0.0f};
35
40 std::array<double, 3> ref_dir = {0.0f, 1.0f, 0.0f};
41
46 std::array<double, 3> second_ref_dir = {1.0f, 0.0f, 0.0f};
47
54 double radius = -1.0f;
55
57 std::string_view output_geodesic_attribute_name = "@geodesic_distance";
58
60 std::string_view output_polar_angle_attribute_name = "@polar_angle";
61};
62
74
78struct LA_GEODESIC_API PointToPointGeodesicOptions
79{
81 size_t source_facet_id = 0;
82
84 size_t target_facet_id = 0;
85
89 std::array<double, 2> source_facet_bc = {0.0f, 0.0f};
90
94 std::array<double, 2> target_facet_bc = {0.0f, 0.0f};
95};
96
101{
103 size_t source_facet_id = 0;
104
106 size_t target_facet_id = 0;
107
111 std::array<double, 2> source_facet_bc = {0.0f, 0.0f};
112
116 std::array<double, 2> target_facet_bc = {0.0f, 0.0f};
117};
118
119
126template <typename Scalar, typename Index>
128{
131 std::vector<std::array<Scalar, 3>> points;
132
136 std::vector<Index> facet_ids;
137};
138
145template <typename Scalar, typename Index>
147{
148public:
151
152public:
153public:
159 explicit GeodesicEngine(Mesh& mesh);
160
164 virtual ~GeodesicEngine() = default;
165
174 const SingleSourceGeodesicOptions& options) = 0;
175
184
199 const PointToPointGeodesicPathOptions& options);
200
201protected:
202 const Mesh& mesh() const { return m_mesh.get(); }
203 Mesh& mesh() { return m_mesh.get(); }
204
205private:
206 std::reference_wrapper<Mesh> m_mesh;
207};
208
209} // namespace lagrange::geodesic
Definition Mesh.h:48
A general purpose polygonal mesh class.
Definition SurfaceMesh.h:73
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:21
SurfaceMesh< Scalar, Index > Mesh
The mesh type.
Definition GeodesicEngine.h:150
virtual Scalar point_to_point_geodesic(const PointToPointGeodesicOptions &options)
Computes the geodesic distance between two points on the mesh.
Definition GeodesicEngine.cpp:34
virtual GeodesicPathResult< Scalar, Index > point_to_point_geodesic_path(const PointToPointGeodesicPathOptions &options)
Computes the geodesic path between two points on the mesh.
Definition GeodesicEngine.cpp:54
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
Result of a point-to-point geodesic path computation.
Definition GeodesicEngine.h:128
std::vector< Index > facet_ids
Facet index for each path segment.
Definition GeodesicEngine.h:136
std::vector< std::array< Scalar, 3 > > points
Ordered list of 3D points along the geodesic path from source to target.
Definition GeodesicEngine.h:131
General options for point-to-point geodesic computations.
Definition GeodesicEngine.h:79
std::array< double, 2 > target_facet_bc
Barycentric coordinates of the target point within the target facet.
Definition GeodesicEngine.h:94
size_t target_facet_id
Facets containing the target point.
Definition GeodesicEngine.h:84
std::array< double, 2 > source_facet_bc
Barycentric coordinates of the source point within the source facet.
Definition GeodesicEngine.h:89
size_t source_facet_id
Facet containing the source point.
Definition GeodesicEngine.h:81
Options for point-to-point geodesic path computation.
Definition GeodesicEngine.h:101
std::array< double, 2 > target_facet_bc
Barycentric coordinates of the target point within the target facet.
Definition GeodesicEngine.h:116
size_t target_facet_id
Facet containing the target point.
Definition GeodesicEngine.h:106
std::array< double, 2 > source_facet_bc
Barycentric coordinates of the source point within the source facet.
Definition GeodesicEngine.h:111
size_t source_facet_id
Facet containing the source point.
Definition GeodesicEngine.h:103
General options for one-to-many geodesic computations.
Definition GeodesicEngine.h:27
std::array< double, 3 > second_ref_dir
The secondary reference up direction for the geodesic polar coordinates.
Definition GeodesicEngine.h:46
std::string_view output_geodesic_attribute_name
The name of the output attribute to store the geodesic distance.
Definition GeodesicEngine.h:57
double radius
The maximum geodesic distance from the seed point to consider.
Definition GeodesicEngine.h:54
std::array< double, 2 > source_facet_bc
The barycentric coordinates of the seed facet.
Definition GeodesicEngine.h:34
size_t source_facet_id
The facet id of the seed facet.
Definition GeodesicEngine.h:29
std::array< double, 3 > ref_dir
The reference up direction for the geodesic polar coordinates.
Definition GeodesicEngine.h:40
std::string_view output_polar_angle_attribute_name
The name of the output attribute to store the geodesic polar coordinates.
Definition GeodesicEngine.h:60
Result of a single source geodesic computation.
Definition GeodesicEngine.h:67
AttributeId polar_angle_id
The attribute id of the polar angle attribute, if available.
Definition GeodesicEngine.h:72
AttributeId geodesic_distance_id
The attribute id of the geodesic distance attribute.
Definition GeodesicEngine.h:69