Lagrange
Loading...
Searching...
No Matches
separate_by_facet_groups.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/function_ref.h>
16#include <lagrange/utils/invalid.h>
17#include <lagrange/utils/span.h>
18
19#include <string_view>
20
21namespace lagrange {
22
30
34struct SeparateByFacetGroupsOptions
35{
39 std::string_view source_vertex_attr_name;
40
44 std::string_view source_facet_attr_name;
45
47 bool map_attributes = false;
48
49 SeparateByFacetGroupsOptions() = default;
50 SeparateByFacetGroupsOptions(const SeparateByFacetGroupsOptions&) = default;
51 SeparateByFacetGroupsOptions(SeparateByFacetGroupsOptions&&) = default;
52 SeparateByFacetGroupsOptions& operator=(const SeparateByFacetGroupsOptions&) = default;
53 SeparateByFacetGroupsOptions& operator=(SeparateByFacetGroupsOptions&&) = default;
54
56 template <typename T>
57 explicit SeparateByFacetGroupsOptions(const T& options)
58 {
59 source_vertex_attr_name = options.source_vertex_attr_name;
60 source_facet_attr_name = options.source_facet_attr_name;
61 map_attributes = options.map_attributes;
62 }
63};
64
81template <typename Scalar, typename Index>
82std::vector<SurfaceMesh<Scalar, Index>> separate_by_facet_groups(
83 const SurfaceMesh<Scalar, Index>& mesh,
84 size_t num_groups,
85 span<const Index> facet_group_indices,
86 const SeparateByFacetGroupsOptions& options = {});
87
103template <typename Scalar, typename Index>
104std::vector<SurfaceMesh<Scalar, Index>> separate_by_facet_groups(
105 const SurfaceMesh<Scalar, Index>& mesh,
106 span<const Index> facet_group_indices,
107 const SeparateByFacetGroupsOptions& options = {});
108
125template <typename Scalar, typename Index>
126std::vector<SurfaceMesh<Scalar, Index>> separate_by_facet_groups(
127 const SurfaceMesh<Scalar, Index>& mesh,
128 size_t num_groups,
129 function_ref<Index(Index)> get_facet_group,
130 const SeparateByFacetGroupsOptions& options = {});
131
133
134} // namespace lagrange
A general purpose polygonal mesh class.
Definition SurfaceMesh.h:66
A lightweight non-owning reference to a callable.
Definition function_ref.h:47
std::vector< SurfaceMesh< Scalar, Index > > separate_by_facet_groups(const SurfaceMesh< Scalar, Index > &mesh, size_t num_groups, span< const Index > facet_group_indices, const SeparateByFacetGroupsOptions &options={})
Extract a set of submeshes based on facet groups.
Definition separate_by_facet_groups.cpp:29
::nonstd::span< T, Extent > span
A bounds-safe view for sequences of objects.
Definition span.h:27
Main namespace for Lagrange.
Option settings for separate_by_facet_groups.
Definition separate_by_facet_groups.h:35
std::string_view source_facet_attr_name
The name of the output attribute holding source facet indices.
Definition separate_by_facet_groups.h:44
bool map_attributes
Map all attributes over to submesh.
Definition separate_by_facet_groups.h:47
SeparateByFacetGroupsOptions(const T &options)
Explicit conversion from other compatible option types.
Definition separate_by_facet_groups.h:57
std::string_view source_vertex_attr_name
The name of the output attribute holding source vertex indices.
Definition separate_by_facet_groups.h:39