Lagrange
Loading...
Searching...
No Matches
geometry_central_utils.h
1/*
2 * Copyright 2025 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
16// clang-format off
17#include <lagrange/utils/warnoff.h>
18#include <geometrycentral/surface/vertex_position_geometry.h>
19#include <geometrycentral/surface/surface_point.h>
20#include <lagrange/utils/warnon.h>
21// clang-format on
22
23#include <memory>
24
25namespace lagrange::geodesic::gc {
26
27using gcSurfaceMesh = geometrycentral::surface::SurfaceMesh;
28using gcGeometry = geometrycentral::surface::VertexPositionGeometry;
29using gcSurfacePoint = geometrycentral::surface::SurfacePoint;
30
31template <typename Scalar, typename Index>
32std::tuple<std::unique_ptr<gcSurfaceMesh>, std::unique_ptr<gcGeometry>> extract_gc_mesh(
33 SurfaceMesh<Scalar, Index>& mesh)
34{
35 auto vertices = vertex_view(mesh);
36 auto facets = facet_view(mesh);
37 auto gc_mesh = std::make_unique<gcSurfaceMesh>(facets);
38 auto gc_geom = std::make_unique<gcGeometry>(*gc_mesh, vertices);
39 return std::make_tuple(std::move(gc_mesh), std::move(gc_geom));
40}
41
42} // namespace lagrange::geodesic::gc
ConstRowMatrixView< Scalar > vertex_view(const SurfaceMesh< Scalar, Index > &mesh)
Returns a read-only view of the mesh vertices in the form of an Eigen matrix.
Definition views.cpp:156
ConstRowMatrixView< Index > facet_view(const SurfaceMesh< Scalar, Index > &mesh)
Returns a read-only view of a mesh facets in the form of an Eigen matrix.
Definition views.cpp:170