GCC Code Coverage Report


Directory: ./
File: examples/geogram/manifold_harmonics/main.cpp
Date: 2026-09-07 02:36:43
Exec Total Coverage
Lines: 0 51 0.0%
Functions: 0 1 0.0%
Branches: 0 124 0.0%

Line Branch Exec Source
1 /*
2 * Copyright (c) 2000-2022 Inria
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * * Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * * Neither the name of the ALICE Project-Team nor the names of its
14 * contributors may be used to endorse or promote products derived from this
15 * software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
28 *
29 * Contact: Bruno Levy
30 *
31 * https://www.inria.fr/fr/bruno-levy
32 *
33 * Inria,
34 * Domaine de Voluceau,
35 * 78150 Le Chesnay - Rocquencourt
36 * FRANCE
37 *
38 */
39
40 #include <geogram/basic/common.h>
41 #include <geogram/basic/logger.h>
42 #include <geogram/basic/command_line.h>
43 #include <geogram/basic/command_line_args.h>
44 #include <geogram/basic/stopwatch.h>
45 #include <geogram/mesh/mesh.h>
46 #include <geogram/mesh/mesh_io.h>
47 #include <geogram/mesh/mesh_manifold_harmonics.h>
48
49 // if GEO_DYNAMIC_LIBS is not defined, then there is unreachable code.
50 #ifdef GEO_COMPILER_MSVC
51 #pragma warning( disable : 4702)
52 #endif
53
54 int main(int argc, char** argv) {
55 using namespace GEO;
56
57 GEO::initialize(GEO::GEOGRAM_INSTALL_ALL);
58
59 try {
60
61 #ifndef GEO_DYNAMIC_LIBS
62 // Manifold Harmonics depend on ARPACK, loaded dynamically by
63 // OpenNL, so geogram needs to be compiled with dynamic libs.
64 GEO::Logger::err("MH")
65 << "Needs geogram compiled with dynamic libs"
66 << std::endl;
67 GEO::Logger::err("MH")
68 << "(see https://github.com/BrunoLevy/geogram/wiki/FAQ)"
69 << std::endl;
70
71 return(-1);
72 #endif
73
74 Stopwatch Wtot("Total time");
75
76 std::vector<std::string> filenames;
77
78 CmdLine::import_arg_group("standard");
79 CmdLine::import_arg_group("algo");
80 CmdLine::declare_arg(
81 "nb_eigens", 30, "number of eigenpairs"
82 );
83
84 CmdLine::declare_arg(
85 "discretization", "FEM_P1_LUMPED",
86 "one of COMBINATORIAL, UNIFORM, FEM_P1, FEM_P1_LUMPED"
87 );
88
89 if(
90 !CmdLine::parse(
91 argc, argv, filenames, "inmesh <outmesh>"
92 )
93 ) {
94 return 1;
95 }
96
97 LaplaceBeltramiDiscretization discretization = FEM_P1_LUMPED;
98
99 const std::string& discretization_str =
100 CmdLine::get_arg("discretization");
101
102 if(discretization_str == "COMBINATORIAL") {
103 discretization = COMBINATORIAL;
104 } else if(discretization_str == "UNIFORM") {
105 discretization = UNIFORM;
106 } else if(discretization_str == "FEM_P1") {
107 discretization = FEM_P1;
108 } else if(discretization_str == "FEM_P1_LUMPED") {
109 discretization = FEM_P1_LUMPED;
110 } else {
111 Logger::err("MH")
112 << discretization_str << ": invalid discretization"
113 << std::endl;
114 exit(-1);
115 }
116
117 if(filenames.size() != 2) {
118 Logger::out("Smooth") << "Generating output to out.geogram"
119 << std::endl;
120 filenames.push_back("out.geogram");
121 }
122
123 Logger::div("Data I/O");
124
125 Mesh M;
126
127 MeshIOFlags flags;
128 flags.reset_element(MESH_CELLS);
129 flags.set_attributes(MESH_ALL_ATTRIBUTES);
130 if(!mesh_load(filenames[0], M, flags)) {
131 return 1;
132 }
133
134 mesh_compute_manifold_harmonics(
135 M, CmdLine::get_arg_uint("nb_eigens"), discretization
136 );
137
138 if(!mesh_save(M, filenames[1], flags)) {
139 return 1;
140 }
141
142 }
143 catch(const std::exception& e) {
144 std::cerr << "Received an exception: " << e.what() << std::endl;
145 return 1;
146 }
147
148 Logger::out("") << "Everything OK, Returning status 0" << std::endl;
149 return 0;
150 }
151