Lagrange
Loading...
Searching...
No Matches
stitch_mesh.h
1/*
2 * Copyright 2024 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
13#pragma once
14
15#include <lagrange/find_matching_attributes.h>
16#include <lagrange/map_attribute.h>
17#include <lagrange/mesh_cleanup/remove_duplicate_vertices.h>
18#include <lagrange/weld_indexed_attribute.h>
19
20namespace lagrange::io {
21
22template <typename Scalar, typename Index>
23void stitch_mesh(SurfaceMesh<Scalar, Index>& mesh)
24{
25 // Point clouds have no corners to stitch. Keep their vertex attributes vertex-based.
26 if (mesh.get_num_corners() == 0) return;
27
28 // Convert vertex attributes to indexed before stitching anything
31 }
32
33 // Now we can stitch vertices
34 RemoveDuplicateVerticesOptions rm_opts;
35 rm_opts.boundary_only = true;
36 remove_duplicate_vertices(mesh, rm_opts);
37
38 // Weld indexed attributes
39 WeldOptions weld_opts;
40 weld_opts.epsilon_abs = 0;
41 weld_opts.epsilon_rel = 0;
43 weld_indexed_attribute(mesh, id, weld_opts);
44 }
45}
46
47} // namespace lagrange::io
void weld_indexed_attribute(SurfaceMesh< Scalar, Index > &mesh, AttributeId attr_id, const WeldOptions &options={})
Weld an indexed attribute by combining all corners around a vertex with the same attribute value.
Definition weld_indexed_attribute.cpp:500
AttributeId map_attribute_in_place(SurfaceMesh< Scalar, Index > &mesh, AttributeId id, AttributeElement new_element)
Map attribute values to a different element type.
Definition map_attribute.cpp:292
@ Indexed
Indexed mesh attributes.
Definition AttributeFwd.h:45
@ Vertex
Per-vertex mesh attributes.
Definition AttributeFwd.h:28
void remove_duplicate_vertices(SurfaceMesh< Scalar, Index > &mesh, const RemoveDuplicateVerticesOptions &options={})
Removes duplicate vertices from a mesh.
Definition remove_duplicate_vertices.cpp:35
std::vector< AttributeId > find_matching_attributes(const SurfaceMesh< Scalar, Index > &mesh, const AttributeMatcher &options)
Finds all attributes with the specified usage/element type/number of channels.
Definition find_matching_attributes.cpp:80
Mesh input/output.
Definition detect_file_format.h:19