Lagrange
compute_normal.h
1/*
2 * Copyright 2020 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/legacy/compute_normal.h>
16#endif
17
18#include <lagrange/NormalWeightingType.h>
19#include <lagrange/SurfaceMesh.h>
20#include <lagrange/utils/function_ref.h>
21#include <lagrange/utils/span.h>
22
23#include <string_view>
24
25namespace lagrange {
26
34
39{
41 std::string_view output_attribute_name = "@normal";
42
45
48 std::string_view facet_normal_attribute_name = "@facet_normal";
49
52
55 bool keep_facet_normals = false;
56};
57
73template <typename Scalar, typename Index>
76 function_ref<bool(Index)> is_edge_smooth,
77 span<const Index> cone_vertices = {},
78 NormalOptions options = {});
79
96template <typename Scalar, typename Index>
98 SurfaceMesh<Scalar, Index>& mesh,
99 function_ref<bool(Index, Index)> is_edge_smooth,
100 span<const Index> cone_vertices = {},
101 NormalOptions options = {});
102
120template <typename Scalar, typename Index>
122 SurfaceMesh<Scalar, Index>& mesh,
123 Scalar feature_angle_threshold,
124 span<const Index> cone_vertices = {},
125 NormalOptions options = {});
126
128
129} // namespace lagrange
A lightweight non-owning reference to a callable.
Definition: function_ref.h:47
uint32_t AttributeId
Identified to be used to access an attribute.
Definition: AttributeFwd.h:73
AttributeId compute_normal(SurfaceMesh< Scalar, Index > &mesh, function_ref< bool(Index)> is_edge_smooth, span< const Index > cone_vertices={}, NormalOptions options={})
Compute smooth normals based on specified sharp edges and cone vertices.
Definition: compute_normal.cpp:192
NormalWeightingType
Weighting types for averaging corner normals around a vertex.
Definition: NormalWeightingType.h:27
@ Angle
Incident face normals are averaged weighted by incident angle of vertex.
function_ref(R(*)(Args...)) -> function_ref< R(Args...)>
Deduce function_ref type from a function pointer.
::nonstd::span< T, Extent > span
A bounds-safe view for sequences of objects.
Definition: span.h:27
Main namespace for Lagrange.
Definition: AABBIGL.h:30
Option struct for computing indexed mesh normals.
Definition: compute_normal.h:39
bool keep_facet_normals
Whether to keep any newly added facet normal attribute.
Definition: compute_normal.h:55
std::string_view facet_normal_attribute_name
Precomputed facet normal attribute name.
Definition: compute_normal.h:48
bool recompute_facet_normals
Whether to recompute the facet normal attribute, or reuse existing cached values if present.
Definition: compute_normal.h:51
std::string_view output_attribute_name
Output normal attribute name.
Definition: compute_normal.h:41
NormalWeightingType weight_type
Per-vertex normal averaging weighting type.
Definition: compute_normal.h:44