Lagrange
extract_submesh.h
1/*
2 * Copyright 2019 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/extract_submesh.h>
16#endif
17
18#include <lagrange/SurfaceMesh.h>
19#include <lagrange/utils/span.h>
20
21#include <string_view>
22
23namespace lagrange {
31
36{
40 std::string_view source_vertex_attr_name;
41
45 std::string_view source_facet_attr_name;
46
48 bool map_attributes = false;
49
50 SubmeshOptions() = default;
51 SubmeshOptions(const SubmeshOptions&) = default;
52 SubmeshOptions(SubmeshOptions&&) = default;
53 SubmeshOptions& operator=(const SubmeshOptions&) = default;
54 SubmeshOptions& operator=(SubmeshOptions&&) = default;
55
59 template <typename T>
60 explicit SubmeshOptions(const T& options)
61 {
62 source_vertex_attr_name = options.source_vertex_attr_name;
63 source_facet_attr_name = options.source_facet_attr_name;
64 map_attributes = options.map_attributes;
65 }
66};
67
82template <typename Scalar, typename Index>
83SurfaceMesh<Scalar, Index> extract_submesh(
84 const SurfaceMesh<Scalar, Index>& mesh,
85 span<const Index> selected_facets,
86 const SubmeshOptions& options = {});
87
88
90
91} // namespace lagrange
SurfaceMesh< Scalar, Index > extract_submesh(const SurfaceMesh< Scalar, Index > &mesh, span< const Index > selected_facets, const SubmeshOptions &options={})
Extract a submesh that consists of a subset of the facets of the source mesh.
Definition: extract_submesh.cpp:26
Main namespace for Lagrange.
Definition: AABBIGL.h:30
Options for extract submesh.
Definition: extract_submesh.h:36
std::string_view source_facet_attr_name
The name of the output attribute holding source facet indices.
Definition: extract_submesh.h:45
bool map_attributes
Map all attributes over to submesh.
Definition: extract_submesh.h:48
std::string_view source_vertex_attr_name
The name of the output attribute holding source vertex indices.
Definition: extract_submesh.h:40
SubmeshOptions(const T &options)
Explicit conversion from other compatible option structs.
Definition: extract_submesh.h:60