Lagrange
compute_centroid.h
1/*
2 * Copyright 2023 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/utils/StackVector.h>
16
17namespace lagrange {
18
26
31{
33 std::string_view output_attribute_name = "@facet_centroid";
34};
35
48template <typename Scalar, typename Index>
51 FacetCentroidOptions options = {});
52
57{
61 Area
62 } weighting_type = Area;
63
66 std::string_view facet_centroid_attribute_name = "@facet_centroid";
67
70 std::string_view facet_area_attribute_name = "@facet_area";
71};
72
85template <typename Scalar, typename Index>
88 span<Scalar> centroid,
89 MeshCentroidOptions options = {});
90
92} // namespace lagrange
uint32_t AttributeId
Identified to be used to access an attribute.
Definition: AttributeFwd.h:73
AttributeId compute_facet_centroid(SurfaceMesh< Scalar, Index > &mesh, FacetCentroidOptions options={})
Compute per-facet centroid.
Definition: compute_centroid.cpp:31
void compute_mesh_centroid(const SurfaceMesh< Scalar, Index > &mesh, span< Scalar > centroid, MeshCentroidOptions options={})
Compute mesh centroid, where mesh centroid is defined as the weighted sum of facet centroids.
Definition: compute_centroid.cpp:74
::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 per-facet centroid.
Definition: compute_centroid.h:31
std::string_view output_attribute_name
Ouptut facet centroid attribute name.
Definition: compute_centroid.h:33
Option struct for computing mesh centroid.
Definition: compute_centroid.h:57
std::string_view facet_centroid_attribute_name
Precomputed facet centroid attribute name.
Definition: compute_centroid.h:66
WeightingType
Weighting type for mesh centroid computation.
Definition: compute_centroid.h:59
@ Area
Per-facet centroid are weighted by facet area.
Definition: compute_centroid.h:61
@ Uniform
Per-facet centroid are weighted uniformly.
Definition: compute_centroid.h:60
std::string_view facet_area_attribute_name
Precomputed facet area attribute name.
Definition: compute_centroid.h:70