| 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.h> | ||
| 41 | #include <geogram/mesh/mesh_io.h> | ||
| 42 | #include <geogram/delaunay/CDT_2d.h> | ||
| 43 | #include <geogram/basic/logger.h> | ||
| 44 | #include <geogram/basic/command_line.h> | ||
| 45 | #include <geogram/basic/command_line_args.h> | ||
| 46 | |||
| 47 | 32 | int main(int argc, char** argv) { | |
| 48 | |||
| 49 |
1/2✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
|
32 | GEO::initialize(GEO::GEOGRAM_INSTALL_ALL); |
| 50 |
2/4✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 32 times.
✗ Branch 5 not taken.
|
32 | GEO::Logger::instance()->set_quiet(false); |
| 51 |
2/4✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 32 times.
✗ Branch 5 not taken.
|
64 | GEO::CmdLine::import_arg_group("standard"); |
| 52 |
2/4✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 32 times.
✗ Branch 5 not taken.
|
64 | GEO::CmdLine::import_arg_group("algo"); |
| 53 |
1/2✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
|
32 | GEO::CmdLine::declare_arg( |
| 54 |
2/4✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 32 times.
✗ Branch 5 not taken.
|
160 | "constrained", true, "compute a constrained triangulation" |
| 55 | ); | ||
| 56 |
1/2✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
|
32 | GEO::CmdLine::declare_arg( |
| 57 |
2/4✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 32 times.
✗ Branch 5 not taken.
|
160 | "delaunay", true, "compute a Delaunay triangulation" |
| 58 | ); | ||
| 59 |
1/2✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
|
32 | GEO::CmdLine::declare_arg( |
| 60 |
1/2✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
|
64 | "remove_external_triangles", false, |
| 61 |
1/2✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
|
96 | "remove triangles adjacent to border" |
| 62 | ); | ||
| 63 |
3/6✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 32 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 32 times.
✗ Branch 8 not taken.
|
96 | GEO::CmdLine::declare_arg("quad", false, "enclosing polygon is a quad"); |
| 64 | |||
| 65 | 32 | std::vector<std::string> filenames; | |
| 66 |
3/6✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 32 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 32 times.
|
64 | if(!GEO::CmdLine::parse(argc, argv, filenames, "constraints_filename")) { |
| 67 | ✗ | return 1; | |
| 68 | } | ||
| 69 | |||
| 70 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
|
32 | if(filenames.size() != 1) { |
| 71 | ✗ | return 1; | |
| 72 | } | ||
| 73 | |||
| 74 |
1/2✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
|
32 | GEO::Mesh constraints; |
| 75 |
2/4✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 32 times.
✗ Branch 6 not taken.
|
32 | GEO::mesh_load(filenames[0], constraints); |
| 76 |
1/2✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
|
32 | constraints.vertices.set_dimension(2); |
| 77 | |||
| 78 |
1/2✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
|
32 | GEO::CDT2d cdt; |
| 79 |
2/4✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 32 times.
✗ Branch 5 not taken.
|
32 | cdt.set_delaunay(GEO::CmdLine::get_arg_bool("delaunay")); |
| 80 | |||
| 81 | 32 | GEO::index_t n=0; | |
| 82 |
3/6✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 32 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 32 times.
|
64 | if(GEO::CmdLine::get_arg_bool("quad")) { |
| 83 | ✗ | n=4; | |
| 84 | ✗ | GEO::vec2 p0(constraints.vertices.point_ptr(0)); | |
| 85 | ✗ | GEO::vec2 p1(constraints.vertices.point_ptr(1)); | |
| 86 | ✗ | GEO::vec2 p2(constraints.vertices.point_ptr(2)); | |
| 87 | ✗ | GEO::vec2 p3(constraints.vertices.point_ptr(3)); | |
| 88 | ✗ | cdt.create_enclosing_quad(p0,p1,p2,p3); | |
| 89 | } else { | ||
| 90 | 32 | n=3; | |
| 91 |
1/2✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
|
32 | GEO::vec2 p0(constraints.vertices.point_ptr(0)); |
| 92 |
1/2✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
|
32 | GEO::vec2 p1(constraints.vertices.point_ptr(1)); |
| 93 |
1/2✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
|
32 | GEO::vec2 p2(constraints.vertices.point_ptr(2)); |
| 94 |
1/2✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
|
32 | cdt.create_enclosing_triangle(p0,p1,p2); |
| 95 | } | ||
| 96 | |||
| 97 |
1/2✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
|
32 | GEO::vector<GEO::index_t> indices(constraints.vertices.nb()-n); |
| 98 |
1/2✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
|
64 | cdt.insert( |
| 99 |
1/2✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
|
32 | constraints.vertices.nb()-n, constraints.vertices.point_ptr(n), |
| 100 | indices.data() | ||
| 101 | ); | ||
| 102 | |||
| 103 |
3/6✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 32 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 32 times.
✗ Branch 8 not taken.
|
64 | if(GEO::CmdLine::get_arg_bool("constrained")) { |
| 104 |
2/2✓ Branch 5 taken 854 times.
✓ Branch 6 taken 32 times.
|
886 | for(GEO::index_t e: constraints.edges) { |
| 105 |
1/2✓ Branch 1 taken 854 times.
✗ Branch 2 not taken.
|
854 | GEO::index_t v1=constraints.edges.vertex(e,0); |
| 106 |
1/2✓ Branch 1 taken 854 times.
✗ Branch 2 not taken.
|
854 | GEO::index_t v2=constraints.edges.vertex(e,1); |
| 107 |
2/2✓ Branch 0 taken 768 times.
✓ Branch 1 taken 86 times.
|
854 | if(v1 >= n) { |
| 108 |
1/2✓ Branch 1 taken 768 times.
✗ Branch 2 not taken.
|
768 | v1 = indices[v1-n]; |
| 109 | } | ||
| 110 |
2/2✓ Branch 0 taken 770 times.
✓ Branch 1 taken 84 times.
|
854 | if(v2 >= n) { |
| 111 |
1/2✓ Branch 1 taken 770 times.
✗ Branch 2 not taken.
|
770 | v2 = indices[v2-n]; |
| 112 | } | ||
| 113 |
1/2✓ Branch 1 taken 854 times.
✗ Branch 2 not taken.
|
854 | cdt.insert_constraint(v1,v2); |
| 114 | } | ||
| 115 | // Create the vertices coming from constraint intersections | ||
| 116 |
2/2✓ Branch 2 taken 168 times.
✓ Branch 3 taken 32 times.
|
200 | for(GEO::index_t v=constraints.vertices.nb(); v<cdt.nv(); ++v) { |
| 117 |
2/4✓ Branch 1 taken 168 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 168 times.
✗ Branch 6 not taken.
|
168 | constraints.vertices.create_vertex(cdt.point(v).data()); |
| 118 | } | ||
| 119 | } | ||
| 120 |
1/2✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
|
32 | cdt.check_consistency(); |
| 121 |
4/6✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 32 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 4 times.
✓ Branch 8 taken 28 times.
|
64 | if(GEO::CmdLine::get_arg_bool("remove_external_triangles")) { |
| 122 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
4 | cdt.remove_external_triangles(); |
| 123 | } | ||
| 124 |
1/2✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
|
32 | cdt.check_consistency(); |
| 125 |
4/8✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 32 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 32 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 32 times.
✗ Branch 11 not taken.
|
32 | GEO::Logger::out("CDT") << "CDT OK" << std::endl; |
| 126 | |||
| 127 |
3/4✓ Branch 1 taken 445442 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 445410 times.
✓ Branch 4 taken 32 times.
|
445442 | for(GEO::index_t t=0; t<cdt.nT(); ++t) { |
| 128 |
4/8✓ Branch 1 taken 445410 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 445410 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 445410 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 445410 times.
✗ Branch 11 not taken.
|
445410 | constraints.facets.create_triangle( |
| 129 | cdt.Tv(t,0), cdt.Tv(t,1), cdt.Tv(t,2) | ||
| 130 | ); | ||
| 131 | } | ||
| 132 | |||
| 133 |
1/2✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
|
32 | constraints.facets.connect(); |
| 134 | |||
| 135 |
3/6✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 32 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 32 times.
✗ Branch 8 not taken.
|
96 | GEO::mesh_save(constraints,"result.geogram"); |
| 136 | |||
| 137 | 32 | return 0; | |
| 138 | 32 | } | |
| 139 |