Lagrange
Loading...
Searching...
No Matches
serialize_mesh.h
1/*
2 * Copyright 2026 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/fs/filesystem.h>
16#include <lagrange/serialization/api.h>
17#include <lagrange/serialization/types.h>
18#include <lagrange/utils/span.h>
19
20#include <cstdint>
21#include <vector>
22
23namespace lagrange::serialization {
24
33
39constexpr uint32_t mesh_format_version()
40{
41 return 1;
42}
43
55template <typename Scalar, typename Index>
56LA_SERIALIZATION2_API std::vector<uint8_t> serialize_mesh(
58 const SerializeOptions& options = {});
59
76template <typename MeshType>
77LA_SERIALIZATION2_API MeshType
78deserialize_mesh(span<const uint8_t> buffer, const DeserializeOptions& options = {});
79
92template <typename Scalar, typename Index>
93LA_SERIALIZATION2_API void save_mesh(
94 const fs::path& filename,
95 const SurfaceMesh<Scalar, Index>& mesh,
96 const SerializeOptions& options = {});
97
113template <typename MeshType>
114LA_SERIALIZATION2_API MeshType
115load_mesh(const fs::path& filename, const DeserializeOptions& options = {});
116
118
119} // namespace lagrange::serialization
A general purpose polygonal mesh class.
Definition SurfaceMesh.h:73
LA_SERIALIZATION2_API void save_mesh(const fs::path &filename, const SurfaceMesh< Scalar, Index > &mesh, const SerializeOptions &options={})
Save a SurfaceMesh to a file.
Definition serialize_mesh.cpp:267
LA_SERIALIZATION2_API std::vector< uint8_t > serialize_mesh(const SurfaceMesh< Scalar, Index > &mesh, const SerializeOptions &options={})
Serialize a SurfaceMesh to a byte buffer.
Definition serialize_mesh.cpp:179
LA_SERIALIZATION2_API MeshType deserialize_mesh(span< const uint8_t > buffer, const DeserializeOptions &options={})
Deserialize a SurfaceMesh from a byte buffer.
Definition serialize_mesh.cpp:196
constexpr uint32_t mesh_format_version()
Current mesh serialization format version.
Definition serialize_mesh.h:39
LA_SERIALIZATION2_API MeshType load_mesh(const fs::path &filename, const DeserializeOptions &options={})
Load a SurfaceMesh from a file.
Definition serialize_mesh.cpp:281
::nonstd::span< T, Extent > span
A bounds-safe view for sequences of objects.
Definition span.h:27
Options for deserialization (load/deserialize functions).
Definition types.h:39
Options for serialization (save/serialize functions).
Definition types.h:22