|
| 1 | +/* |
| 2 | + * Copyright (c) 2019 - 2022 Geode-solutions. All rights reserved. |
| 3 | + */ |
| 4 | + |
| 5 | +#include <absl/flags/flag.h> |
| 6 | +#include <absl/flags/parse.h> |
| 7 | +#include <absl/flags/usage.h> |
| 8 | + |
| 9 | +#include <async++.h> |
| 10 | + |
| 11 | +#include <geode/basic/assert.h> |
| 12 | +#include <geode/basic/filename.h> |
| 13 | +#include <geode/basic/logger.h> |
| 14 | + |
| 15 | +#include <geode/geosciences/representation/core/cross_section.h> |
| 16 | +#include <geode/geosciences/representation/io/cross_section_input.h> |
| 17 | + |
| 18 | +#include <geode/geosciences/detail/common.h> |
| 19 | + |
| 20 | +#include <geode/inspector/section_inspector.h> |
| 21 | + |
| 22 | +ABSL_FLAG( std::string, input, "/path/my/model.og_xsctn", "Input model" ); |
| 23 | +ABSL_FLAG( bool, |
| 24 | + component_linking, |
| 25 | + true, |
| 26 | + "Toggle components linking to unique vertices criterion" ); |
| 27 | +ABSL_FLAG( bool, |
| 28 | + corners, |
| 29 | + true, |
| 30 | + "Toggle inspection of corner topology through unique vertices" ); |
| 31 | +ABSL_FLAG( bool, |
| 32 | + lines, |
| 33 | + true, |
| 34 | + "Toggle inspection of lines topology through unique vertices" ); |
| 35 | +ABSL_FLAG( bool, |
| 36 | + surfaces, |
| 37 | + true, |
| 38 | + "Toggle inspection of surfaces topology through unique vertices" ); |
| 39 | +ABSL_FLAG( bool, |
| 40 | + verbose, |
| 41 | + false, |
| 42 | + "Toggle verbose mode for the inspection of topology through unique " |
| 43 | + "vertices" ); |
| 44 | + |
| 45 | +void inspect_cross_section( const geode::CrossSection& cross_section ) |
| 46 | +{ |
| 47 | + const auto verbose = absl::GetFlag( FLAGS_verbose ); |
| 48 | + const geode::SectionInspector cross_section_inspector{ cross_section, |
| 49 | + verbose }; |
| 50 | + absl::InlinedVector< async::task< void >, 13 > tasks; |
| 51 | + if( absl::GetFlag( FLAGS_component_linking ) ) |
| 52 | + { |
| 53 | + tasks.emplace_back( async::spawn( [&cross_section_inspector] { |
| 54 | + const auto nb_corners = |
| 55 | + cross_section_inspector |
| 56 | + .nb_corners_not_linked_to_a_unique_vertex(); |
| 57 | + geode::Logger::info( |
| 58 | + nb_corners, " corners not linked to a unique vertex" ); |
| 59 | + } ) ); |
| 60 | + tasks.emplace_back( async::spawn( [&cross_section_inspector] { |
| 61 | + const auto nb_lines = |
| 62 | + cross_section_inspector |
| 63 | + .nb_lines_meshed_but_not_linked_to_a_unique_vertex(); |
| 64 | + geode::Logger::info( |
| 65 | + nb_lines, " lines meshed but not linked to a unique vertex" ); |
| 66 | + } ) ); |
| 67 | + tasks.emplace_back( async::spawn( [&cross_section_inspector] { |
| 68 | + const auto nb_surfaces = |
| 69 | + cross_section_inspector |
| 70 | + .nb_surfaces_meshed_but_not_linked_to_a_unique_vertex(); |
| 71 | + geode::Logger::info( nb_surfaces, |
| 72 | + " surfaces meshed but not linked to a unique vertex" ); |
| 73 | + } ) ); |
| 74 | + } |
| 75 | + if( absl::GetFlag( FLAGS_corners ) ) |
| 76 | + { |
| 77 | + tasks.emplace_back( async::spawn( [&cross_section_inspector] { |
| 78 | + const auto nb = |
| 79 | + cross_section_inspector.multiple_corners_unique_vertices() |
| 80 | + .size(); |
| 81 | + geode::Logger::info( |
| 82 | + nb, " unique vertices associated to multiple corners." ); |
| 83 | + } ) ); |
| 84 | + tasks.emplace_back( async::spawn( [&cross_section_inspector] { |
| 85 | + const auto nb = |
| 86 | + cross_section_inspector.multiple_internals_corner_vertices() |
| 87 | + .size(); |
| 88 | + geode::Logger::info( nb, " unique vertices associated to a corner " |
| 89 | + "with multiple internals." ); |
| 90 | + } ) ); |
| 91 | + tasks.emplace_back( async::spawn( [&cross_section_inspector] { |
| 92 | + const auto nb = cross_section_inspector |
| 93 | + .not_internal_nor_boundary_corner_vertices() |
| 94 | + .size(); |
| 95 | + geode::Logger::info( nb, |
| 96 | + " unique vertices associated to a corner which is neither " |
| 97 | + "internal nor boundary." ); |
| 98 | + } ) ); |
| 99 | + tasks.emplace_back( async::spawn( [&cross_section_inspector] { |
| 100 | + const auto nb = |
| 101 | + cross_section_inspector |
| 102 | + .internal_with_multiple_incidences_corner_vertices() |
| 103 | + .size(); |
| 104 | + geode::Logger::info( nb, |
| 105 | + " unique vertices associated to a corner which is internal " |
| 106 | + "but has multiple incidences." ); |
| 107 | + } ) ); |
| 108 | + tasks.emplace_back( async::spawn( [&cross_section_inspector] { |
| 109 | + const auto nb = |
| 110 | + cross_section_inspector.line_corners_without_boundary_status() |
| 111 | + .size(); |
| 112 | + geode::Logger::info( nb, " unique vertices associated to a corner " |
| 113 | + "part of a line but not boundary of it." ); |
| 114 | + } ) ); |
| 115 | + } |
| 116 | + if( absl::GetFlag( FLAGS_lines ) ) |
| 117 | + { |
| 118 | + tasks.emplace_back( async::spawn( [&cross_section_inspector] { |
| 119 | + const auto nb = |
| 120 | + cross_section_inspector |
| 121 | + .part_of_not_boundary_nor_internal_line_unique_vertices() |
| 122 | + .size(); |
| 123 | + geode::Logger::info( nb, " unique vertices part of a line which is " |
| 124 | + "neither internal nor boundary." ); |
| 125 | + } ) ); |
| 126 | + tasks.emplace_back( async::spawn( [&cross_section_inspector] { |
| 127 | + const auto nb = |
| 128 | + cross_section_inspector |
| 129 | + .part_of_line_with_invalid_internal_topology_unique_vertices() |
| 130 | + .size(); |
| 131 | + geode::Logger::info( nb, " unique vertices part of a line with " |
| 132 | + "invalid internal topology." ); |
| 133 | + } ) ); |
| 134 | + tasks.emplace_back( async::spawn( [&cross_section_inspector] { |
| 135 | + const auto nb = cross_section_inspector |
| 136 | + .part_of_invalid_unique_line_unique_vertices() |
| 137 | + .size(); |
| 138 | + geode::Logger::info( nb, " unique vertices part of a unique line " |
| 139 | + "with invalid topology." ); |
| 140 | + } ) ); |
| 141 | + tasks.emplace_back( async::spawn( [&cross_section_inspector] { |
| 142 | + const auto nb = cross_section_inspector |
| 143 | + .part_of_lines_but_not_corner_unique_vertices() |
| 144 | + .size(); |
| 145 | + geode::Logger::info( nb, |
| 146 | + " unique vertices part of multiple lines but not a corner." ); |
| 147 | + } ) ); |
| 148 | + } |
| 149 | + if( absl::GetFlag( FLAGS_surfaces ) ) |
| 150 | + { |
| 151 | + tasks.emplace_back( async::spawn( [&cross_section_inspector] { |
| 152 | + const auto nb = cross_section_inspector |
| 153 | + .part_of_invalid_surfaces_unique_vertices() |
| 154 | + .size(); |
| 155 | + geode::Logger::info( nb, |
| 156 | + " unique vertices part of surfaces with invalid topology." ); |
| 157 | + } ) ); |
| 158 | + } |
| 159 | + async::when_all( tasks.begin(), tasks.end() ).wait(); |
| 160 | +} |
| 161 | + |
| 162 | +int main( int argc, char* argv[] ) |
| 163 | +{ |
| 164 | + try |
| 165 | + { |
| 166 | + absl::SetProgramUsageMessage( absl::StrCat( |
| 167 | + "CrossSection inspector from Geode-solutions.\n", "Sample usage:\n", |
| 168 | + argv[0], " --input my_cross_section.og_xsctn\n", |
| 169 | + "Default behavior tests all available criteria, to disable one " |
| 170 | + "use --noXXX, e.g. --nocomponent_linking" ) ); |
| 171 | + absl::ParseCommandLine( argc, argv ); |
| 172 | + |
| 173 | + geode::detail::initialize_geosciences_io(); |
| 174 | + const auto filename = absl::GetFlag( FLAGS_input ); |
| 175 | + |
| 176 | + inspect_cross_section( geode::load_cross_section( filename ) ); |
| 177 | + |
| 178 | + return 0; |
| 179 | + } |
| 180 | + catch( ... ) |
| 181 | + { |
| 182 | + return geode::geode_lippincott(); |
| 183 | + } |
| 184 | +} |
0 commit comments