Lagrange
Loading...
Searching...
No Matches
Options.h
1/*
2 * Copyright 2026 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/AttributeFwd.h>
15#include <lagrange/utils/warning.h>
16
17#include <Eigen/Core>
18
19#include <cstdint>
20#include <functional>
21#include <map>
22#include <string>
23#include <variant>
24#include <vector>
25
26namespace lagrange {
27namespace raycasting {
28
30enum class ProjectMode {
31 CLOSEST_VERTEX [[deprecated]] = 0,
32 CLOSEST_POINT [[deprecated]] = 1,
33 RAY_CASTING [[deprecated]] = 2,
37 2,
38};
39
41enum class CastMode {
42 ONE_WAY [[deprecated]] = 0,
43 BOTH_WAYS [[deprecated]] = 1,
44 OneWay = 0,
46};
47
49enum class FallbackMode {
50 CONSTANT [[deprecated]] = 0,
51 CLOSEST_VERTEX [[deprecated]] = 1,
52 CLOSEST_POINT [[deprecated]] = 2,
56};
57
58using WrapMode [[deprecated]] = FallbackMode;
59
60inline const std::map<std::string, ProjectMode>& project_modes()
61{
63 static std::map<std::string, ProjectMode> _modes = {
64 {"CLOSEST_VERTEX", ProjectMode::CLOSEST_VERTEX},
65 {"CLOSEST_POINT", ProjectMode::CLOSEST_POINT},
66 {"RAY_CASTING", ProjectMode::RAY_CASTING},
67 {"ClosestVertex", ProjectMode::ClosestVertex},
68 {"ClosestPoint", ProjectMode::ClosestPoint},
69 {"RayCasting", ProjectMode::RayCasting},
70 };
71 LA_IGNORE_DEPRECATION_WARNING_END
72 return _modes;
73}
74
75inline const std::map<std::string, CastMode>& cast_modes()
76{
78 static std::map<std::string, CastMode> _modes = {
79 {"ONE_WAY", CastMode::ONE_WAY},
80 {"BOTH_WAYS", CastMode::BOTH_WAYS},
81 {"OneWay", CastMode::OneWay},
82 {"BothWays", CastMode::BothWays},
83 };
84 LA_IGNORE_DEPRECATION_WARNING_END
85 return _modes;
86}
87
88inline const std::map<std::string, FallbackMode>& fallback_modes()
89{
91 static std::map<std::string, FallbackMode> _modes = {
92 {"CONSTANT", FallbackMode::CONSTANT},
93 {"CLOSEST_VERTEX", FallbackMode::CLOSEST_VERTEX},
94 {"CLOSEST_POINT", FallbackMode::CLOSEST_POINT},
95 {"Constant", FallbackMode::Constant},
96 {"ClosestVertex", FallbackMode::ClosestVertex},
97 {"ClosestPoint", FallbackMode::ClosestPoint},
98 };
99 LA_IGNORE_DEPRECATION_WARNING_END
100 return _modes;
101}
102
103[[deprecated]] inline const std::map<std::string, FallbackMode>& wrap_modes()
104{
105 return fallback_modes();
106}
107
112
117{
119 std::vector<AttributeId> attribute_ids;
120
124 bool project_vertices = true;
125
128 std::function<bool(uint64_t)> skip_vertex = nullptr;
129};
130
135{
145 std::variant<std::monostate, Eigen::Vector3f, AttributeId> direction = {};
146
149
152
154 double default_value = 0.0;
155
159 std::function<void(uint64_t, bool)> user_callback = nullptr;
160};
161
170
172
173} // namespace raycasting
174} // namespace lagrange
#define LA_IGNORE_DEPRECATION_WARNING_BEGIN
Ignore deprecation warnings.
Definition warning.h:76
Raycasting operations.
Definition ClosestPointResult.h:22
ProjectMode
Main projection mode.
Definition Options.h:30
@ RayCasting
Copy attribute by projecting along a prescribed direction on the source mesh.
Definition Options.h:36
@ ClosestPoint
Interpolate attribute from the closest point on the source mesh.
Definition Options.h:35
@ CLOSEST_POINT
Definition Options.h:32
@ ClosestVertex
Copy attribute from the closest vertex on the source mesh.
Definition Options.h:34
@ RAY_CASTING
Definition Options.h:33
@ CLOSEST_VERTEX
Definition Options.h:31
FallbackMode
Fallback mode for vertices without a hit.
Definition Options.h:49
@ ClosestPoint
Interpolate attribute from the closest point on the source mesh.
Definition Options.h:55
@ CLOSEST_POINT
Definition Options.h:52
@ ClosestVertex
Copy attribute from the closest vertex on the source mesh.
Definition Options.h:54
@ CONSTANT
Definition Options.h:50
@ Constant
Fill with a constant value (defaults to 0).
Definition Options.h:53
@ CLOSEST_VERTEX
Definition Options.h:51
CastMode
Ray-casting mode.
Definition Options.h:41
@ BothWays
Cast a ray both forward and backward in the prescribed direction.
Definition Options.h:45
@ OneWay
Cast a ray forward in the prescribed direction.
Definition Options.h:44
@ BOTH_WAYS
Definition Options.h:43
@ ONE_WAY
Definition Options.h:42
const std::map< std::string, ProjectMode > & project_modes()
<
Definition Options.h:60
Main namespace for Lagrange.
Common options for projection functions.
Definition Options.h:117
bool project_vertices
Whether to project vertex positions.
Definition Options.h:124
std::vector< AttributeId > attribute_ids
Additional vertex attribute ids to project (beyond vertex positions).
Definition Options.h:119
std::function< bool(uint64_t)> skip_vertex
If provided, whether to skip assignment for a target vertex or not.
Definition Options.h:128
Options for project_directional().
Definition Options.h:135
double default_value
Scalar used to fill attributes in Constant fallback mode.
Definition Options.h:154
CastMode cast_mode
Whether to project forward along the ray, or both forward and backward.
Definition Options.h:148
std::variant< std::monostate, Eigen::Vector3f, AttributeId > direction
Raycasting direction to project attributes.
Definition Options.h:145
std::function< void(uint64_t, bool)> user_callback
Optional callback invoked for each target vertex with (vertex index, was_hit).
Definition Options.h:159
FallbackMode fallback_mode
Fallback mode for vertices where there is no hit.
Definition Options.h:151
Options for project().
Definition Options.h:166
ProjectMode project_mode
Projection mode to choose from.
Definition Options.h:168