| 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/voronoi/RVD_mesh_builder.h> | ||
| 41 | |||
| 42 | namespace GEO { | ||
| 43 | |||
| 44 | 1297 | RVDVertexMap::RVDVertexMap() : | |
| 45 | 1297 | nb_vertices_(0) { | |
| 46 | 1297 | } | |
| 47 | |||
| 48 | 1144225 | index_t RVDVertexMap::find_or_create_vertex( | |
| 49 | index_t center_vertex_id, const SymbolicVertex& sym | ||
| 50 | ) { | ||
| 51 |
4/5✓ Branch 1 taken 53016 times.
✓ Branch 2 taken 347191 times.
✓ Branch 3 taken 560524 times.
✓ Branch 4 taken 183494 times.
✗ Branch 5 not taken.
|
1144225 | switch(sym.nb_bisectors()) { |
| 52 | 53016 | case 3: | |
| 53 | { | ||
| 54 |
1/2✓ Branch 1 taken 53016 times.
✗ Branch 2 not taken.
|
53016 | index_t ib1 = sym.bisector(0); |
| 55 |
1/2✓ Branch 1 taken 53016 times.
✗ Branch 2 not taken.
|
53016 | index_t ib2 = sym.bisector(1); |
| 56 |
1/2✓ Branch 1 taken 53016 times.
✗ Branch 2 not taken.
|
53016 | index_t ib3 = sym.bisector(2); |
| 57 |
1/2✓ Branch 1 taken 53016 times.
✗ Branch 2 not taken.
|
53016 | quadindex K(center_vertex_id + 1, ib1 + 1, ib2 + 1, ib3 + 1); |
| 58 |
1/2✓ Branch 1 taken 53016 times.
✗ Branch 2 not taken.
|
53016 | auto it = ppp_to_id_.find(K); |
| 59 |
2/2✓ Branch 2 taken 35755 times.
✓ Branch 3 taken 17261 times.
|
53016 | if(it != ppp_to_id_.end()) { |
| 60 | 35755 | return it->second; | |
| 61 | } else { | ||
| 62 | 17261 | index_t result = new_vertex(); | |
| 63 |
1/2✓ Branch 1 taken 17261 times.
✗ Branch 2 not taken.
|
17261 | ppp_to_id_[K] = result; |
| 64 | 17261 | return result; | |
| 65 | } | ||
| 66 | } | ||
| 67 | 347191 | case 2: | |
| 68 | { | ||
| 69 |
1/2✓ Branch 1 taken 347191 times.
✗ Branch 2 not taken.
|
347191 | index_t f = sym.boundary_facet(0); |
| 70 |
1/2✓ Branch 1 taken 347191 times.
✗ Branch 2 not taken.
|
347191 | index_t ib1 = sym.bisector(0); |
| 71 |
1/2✓ Branch 1 taken 347191 times.
✗ Branch 2 not taken.
|
347191 | index_t ib2 = sym.bisector(1); |
| 72 | signed_quadindex K( | ||
| 73 | 347191 | signed_index_t(center_vertex_id) + 1, | |
| 74 | 347191 | -signed_index_t(f) - 1, | |
| 75 | 347191 | signed_index_t(ib1) + 1, | |
| 76 | 347191 | signed_index_t(ib2) + 1 | |
| 77 |
1/2✓ Branch 1 taken 347191 times.
✗ Branch 2 not taken.
|
347191 | ); |
| 78 |
1/2✓ Branch 1 taken 347191 times.
✗ Branch 2 not taken.
|
347191 | auto it = ppm_to_id_.find(K); |
| 79 |
2/2✓ Branch 2 taken 243045 times.
✓ Branch 3 taken 104146 times.
|
347191 | if(it != ppm_to_id_.end()) { |
| 80 | 243045 | return it->second; | |
| 81 | } else { | ||
| 82 | 104146 | index_t result = new_vertex(); | |
| 83 |
1/2✓ Branch 1 taken 104146 times.
✗ Branch 2 not taken.
|
104146 | ppm_to_id_[K] = result; |
| 84 | 104146 | return result; | |
| 85 | } | ||
| 86 | } | ||
| 87 | 560524 | case 1: | |
| 88 | { | ||
| 89 | index_t bv1, bv2; | ||
| 90 |
1/2✓ Branch 1 taken 560524 times.
✗ Branch 2 not taken.
|
560524 | sym.get_boundary_edge(bv1, bv2); |
| 91 |
1/2✓ Branch 1 taken 560524 times.
✗ Branch 2 not taken.
|
560524 | index_t ib = sym.bisector(0); |
| 92 | signed_quadindex K( | ||
| 93 | 560524 | signed_index_t(center_vertex_id) + 1, | |
| 94 | 560524 | -signed_index_t(bv1) - 1, | |
| 95 | 560524 | -signed_index_t(bv2) - 1, | |
| 96 | 560524 | signed_index_t(ib) + 1 | |
| 97 |
1/2✓ Branch 1 taken 560524 times.
✗ Branch 2 not taken.
|
560524 | ); |
| 98 |
1/2✓ Branch 1 taken 560524 times.
✗ Branch 2 not taken.
|
560524 | auto it = pmm_to_id_.find(K); |
| 99 |
2/2✓ Branch 2 taken 422576 times.
✓ Branch 3 taken 137948 times.
|
560524 | if(it != pmm_to_id_.end()) { |
| 100 | 422576 | return it->second; | |
| 101 | } else { | ||
| 102 | 137948 | index_t result = new_vertex(); | |
| 103 |
1/2✓ Branch 1 taken 137948 times.
✗ Branch 2 not taken.
|
137948 | pmm_to_id_[K] = result; |
| 104 | 137948 | return result; | |
| 105 | } | ||
| 106 | } | ||
| 107 | 183494 | case 0: | |
| 108 | { | ||
| 109 | 183494 | index_t bv = sym.get_boundary_vertex(); | |
| 110 |
2/2✓ Branch 1 taken 705 times.
✓ Branch 2 taken 182789 times.
|
183494 | if(bv >= bv_to_id_.size()) { |
| 111 |
1/2✓ Branch 1 taken 705 times.
✗ Branch 2 not taken.
|
705 | bv_to_id_.resize(bv + 1, -1); |
| 112 | } | ||
| 113 |
2/2✓ Branch 1 taken 31415 times.
✓ Branch 2 taken 152079 times.
|
183494 | if(bv_to_id_[bv] == -1) { |
| 114 | 31415 | bv_to_id_[bv] = signed_index_t(new_vertex()); | |
| 115 | } | ||
| 116 | 183494 | return index_t(bv_to_id_[bv]); | |
| 117 | } | ||
| 118 | ✗ | default: | |
| 119 | ✗ | geo_assert_not_reached; | |
| 120 | } | ||
| 121 | } | ||
| 122 | } | ||
| 123 |