GCC Code Coverage Report


Directory: ./
File: basic/debug_stream.cpp
Date: 2026-09-27 03:12:47
Exec Total Coverage
Lines: 0 52 0.0%
Functions: 0 10 0.0%
Branches: 0 18 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/debug_stream.h>
41 #include <geogram/basic/string.h>
42 #include <geogram/basic/logger.h>
43
44 namespace GEO {
45
46 ✗ DebugStream::DebugStream(
47 const std::string& name, index_t id
48 ✗ ) :
49 ✗ out_(filename(name,id).c_str()),
50 ✗ filename_(filename(name,id).c_str()),
51 ✗ nv_(0) {
52 ✗ Logger::out("Debug") << "Opening debug stream:"
53 << filename_ << std::endl;
54 ✗ }
55
56 ✗ DebugStream::~DebugStream() {
57 ✗ Logger::out("Debug") << "Closing debug stream:"
58 << filename_ << std::endl;
59 ✗ }
60
61 ✗ std::string DebugStream::filename(const std::string& name, index_t id) {
62 ✗ if(id == index_t(-1)) {
63 ✗ return name + ".obj";
64 }
65 ✗ return name + String::format("_%05d.obj",int(id));
66 }
67
68 ✗ void DebugStream::add_point(const vec3& p) {
69 ✗ out_ << "v " << p << std::endl;
70 ✗ ++nv_;
71 ✗ }
72
73 ✗ void DebugStream::add_point(const vec2& p) {
74 ✗ out_ << "v " << p << " " << 0.0 << std::endl;
75 ✗ ++nv_;
76 ✗ }
77
78 ✗ void DebugStream::add_segment(const vec3& p1, const vec3& p2) {
79 ✗ add_point(p1);
80 ✗ add_point(p2);
81 ✗ out_ << "l " << nv_- 1 << " " << nv_ << std::endl;
82 ✗ }
83
84 ✗ void DebugStream::add_segment(const vec2& p1, const vec2& p2) {
85 ✗ add_point(p1);
86 ✗ add_point(p2);
87 ✗ out_ << "l " << nv_- 1 << " " << nv_ << std::endl;
88 ✗ }
89
90 ✗ void DebugStream::add_triangle(
91 const vec3& p1, const vec3& p2, const vec3& p3
92 ) {
93 ✗ add_point(p1);
94 ✗ add_point(p2);
95 ✗ add_point(p3);
96 ✗ out_ << "f " << nv_ - 2 << " " << nv_ - 1 << " " << nv_ << std::endl;
97 ✗ }
98
99 ✗ void DebugStream::add_triangle(
100 const vec2& p1, const vec2& p2, const vec2& p3
101 ) {
102 ✗ add_point(p1);
103 ✗ add_point(p2);
104 ✗ add_point(p3);
105 ✗ out_ << "f " << nv_ - 2 << " " << nv_ - 1 << " " << nv_ << std::endl;
106 ✗ }
107
108 ✗ void DebugStream::add_tet(
109 const vec3 p1, const vec3& p2, const vec3& p3, const vec3& p4
110 ) {
111 ✗ add_point(p1);
112 ✗ add_point(p2);
113 ✗ add_point(p3);
114 ✗ add_point(p4);
115 ✗ index_t v = nv_ - 3;
116 ✗ out_ << "f " << v << " " << v+1 << " " << v+2 << " " << std::endl;
117 out_ << "f " << v+1 << " " << v << " " << v+3 << " " << std::endl;
118 out_ << "f " << v+2 << " " << v+1 << " " << v+3 << " " << std::endl;
119 out_ << "f " << v << " " << v+2 << " " << v+3 << " " << std::endl;
120 ✗ }
121
122 }
123