GCC Code Coverage Report


Directory: ./
File: lib/geogram/mesh/mesh_halfedges.cpp
Date: 2026-09-07 02:36:43
Exec Total Coverage
Lines: 41 68 60.3%
Functions: 3 5 60.0%
Branches: 34 124 27.4%

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/mesh/mesh_halfedges.h>
41
42 namespace GEO {
43
44 6004 bool MeshHalfedges::move_to_next_around_vertex(Halfedge& H) const {
45
1/6
✗ Branch 1 not taken.
✓ Branch 2 taken 6004 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
6004 geo_debug_assert(halfedge_is_valid(H));
46 6004 index_t v = mesh_.facet_corners.vertex(H.corner);
47 6004 index_t f = mesh_.facet_corners.adjacent_facet(H.corner);
48
2/2
✓ Branch 0 taken 2256 times.
✓ Branch 1 taken 3748 times.
6004 if(f == NO_FACET) {
49 2256 return false;
50 }
51 3748 if(
52
2/4
✗ Branch 1 not taken.
✓ Branch 2 taken 3748 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3748 times.
3748 facet_region_.is_bound() &&
53 facet_region_[H.facet] != facet_region_[f]
54 ) {
55 return false;
56 }
57
2/4
✓ Branch 1 taken 3748 times.
✗ Branch 2 not taken.
✓ Branch 8 taken 7719 times.
✗ Branch 9 not taken.
7719 for(index_t c: mesh_.facets.corners(f)) {
58
1/2
✓ Branch 1 taken 7719 times.
✗ Branch 2 not taken.
7719 index_t pc = mesh_.facets.prev_corner_around_facet(f, c);
59 7719 if(
60
5/6
✓ Branch 1 taken 7719 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3748 times.
✓ Branch 4 taken 3971 times.
✓ Branch 5 taken 3748 times.
✓ Branch 6 taken 3971 times.
11467 mesh_.facet_corners.vertex(c) == v &&
61
2/4
✓ Branch 1 taken 3748 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3748 times.
✗ Branch 4 not taken.
3748 mesh_.facet_corners.adjacent_facet(pc) == H.facet
62 ) {
63 3748 H.corner = c;
64 3748 H.facet = f;
65 3748 return true;
66 }
67 }
68 geo_assert_not_reached;
69 }
70
71 121266 bool MeshHalfedges::move_to_prev_around_vertex(Halfedge& H) const {
72
1/6
✗ Branch 1 not taken.
✓ Branch 2 taken 121266 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
121266 geo_debug_assert(halfedge_is_valid(H));
73 121266 index_t v = mesh_.facet_corners.vertex(H.corner);
74 121266 index_t pc = mesh_.facets.prev_corner_around_facet(H.facet, H.corner);
75 121266 index_t f = mesh_.facet_corners.adjacent_facet(pc);
76
2/2
✓ Branch 0 taken 47743 times.
✓ Branch 1 taken 73523 times.
121266 if(f == NO_FACET) {
77 47743 return false;
78 }
79 73523 if(
80
2/4
✗ Branch 1 not taken.
✓ Branch 2 taken 73523 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 73523 times.
73523 facet_region_.is_bound() &&
81 facet_region_[H.facet] != facet_region_[f]
82 ) {
83 return false;
84 }
85
2/4
✓ Branch 1 taken 73523 times.
✗ Branch 2 not taken.
✓ Branch 8 taken 137547 times.
✗ Branch 9 not taken.
137547 for(index_t c: mesh_.facets.corners(f)) {
86 137547 if(
87
5/6
✓ Branch 1 taken 137547 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 73523 times.
✓ Branch 4 taken 64024 times.
✓ Branch 5 taken 73523 times.
✓ Branch 6 taken 64024 times.
211070 mesh_.facet_corners.vertex(c) == v &&
88
2/4
✓ Branch 1 taken 73523 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 73523 times.
✗ Branch 4 not taken.
73523 mesh_.facet_corners.adjacent_facet(c) == H.facet
89 ) {
90 73523 H.corner = c;
91 73523 H.facet = f;
92 73523 return true;
93 }
94 }
95 geo_assert_not_reached;
96 }
97
98 2256 void MeshHalfedges::move_to_next_around_border(Halfedge& H) const {
99
1/6
✗ Branch 1 not taken.
✓ Branch 2 taken 2256 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
2256 geo_debug_assert(halfedge_is_valid(H));
100
1/6
✗ Branch 1 not taken.
✓ Branch 2 taken 2256 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
2256 geo_debug_assert(halfedge_is_border(H));
101 2256 move_to_next_around_facet(H);
102 2256 index_t count = 0;
103
2/2
✓ Branch 1 taken 3748 times.
✓ Branch 2 taken 2256 times.
6004 while(move_to_next_around_vertex(H)) {
104 3748 ++count;
105
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3748 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
3748 geo_assert(count < 10000);
106 }
107 2256 }
108
109 void MeshHalfedges::move_to_prev_around_border(Halfedge& H) const {
110 geo_debug_assert(halfedge_is_valid(H));
111 geo_debug_assert(halfedge_is_border(H));
112 index_t count = 0;
113 while(move_to_prev_around_vertex(H)) {
114 ++count;
115 geo_assert(count < 10000);
116 }
117 move_to_prev_around_facet(H);
118 }
119
120 void MeshHalfedges::move_to_opposite(Halfedge& H) const {
121 geo_debug_assert(halfedge_is_valid(H));
122 index_t v = mesh_.facet_corners.vertex(
123 mesh_.facets.next_corner_around_facet(H.facet, H.corner)
124 );
125 index_t f = mesh_.facet_corners.adjacent_facet(H.corner);
126 geo_assert(f != NO_FACET);
127 for(index_t c: mesh_.facets.corners(f)) {
128 if(mesh_.facet_corners.vertex(c) == v) {
129 H.facet = f;
130 H.corner = c;
131 return;
132 }
133 }
134 geo_assert_not_reached;
135 }
136 }
137