| 145 | } |
| 146 | |
| 147 | void test_section() |
| 148 | { |
| 149 | std::vector< geode::Point2D > points{ |
| 150 | geode::Point2D{ { 0, 0 } }, |
| 151 | geode::Point2D{ { 1, 0 } }, |
| 152 | geode::Point2D{ { 1, 1 } }, |
| 153 | geode::Point2D{ { 0, 1 } }, |
| 154 | geode::Point2D{ { 0.5, 0.2 } }, |
| 155 | geode::Point2D{ { 0.5, 0.8 } }, |
| 156 | geode::Point2D{ { 0, 0.5 } }, |
| 157 | geode::Point2D{ { 0.5, 0 } }, |
| 158 | geode::Point2D{ { 1, 0.5 } }, |
| 159 | geode::Point2D{ { 0.5, 1 } }, |
| 160 | geode::Point2D{ { 0.5, 0.5 } }, |
| 161 | }; |
| 162 | const auto nb_vertices = points.size(); |
| 163 | geode::Section section; |
| 164 | geode::SimplicialSectionCreator creator{ section, std::move( points ) }; |
| 165 | geode::OpenGeodeModelException::test( |
| 166 | section.nb_unique_vertices() == nb_vertices, |
| 167 | "Wrong number of unique vertices" ); |
| 168 | |
| 169 | std::vector< geode::CornerDefinition > corner_definitions{ |
| 170 | { 0 }, |
| 171 | { 1 }, |
| 172 | { 2 }, |
| 173 | { 3 }, |
| 174 | { 4 }, |
| 175 | { 5 }, |
| 176 | }; |
| 177 | const auto corners = creator.create_corners( corner_definitions ); |
| 178 | geode::OpenGeodeModelException::test( |
| 179 | corners.size() == corner_definitions.size(), |
| 180 | "Wrong number of corners" ); |
| 181 | |
| 182 | std::vector< geode::LineDefinition > line_definitions{ |
| 183 | { { 0, 7, 1 } }, |
| 184 | { { 1, 8, 2 } }, |
| 185 | { { 2, 9, 3 } }, |
| 186 | { { 3, 6, 0 } }, |
| 187 | { { 4, 10, 5 } }, |
| 188 | }; |
| 189 | const auto lines = creator.create_lines( corners, line_definitions ); |
| 190 | geode::OpenGeodeModelException::test( |
| 191 | lines.size() == line_definitions.size(), "Wrong number of lines" ); |
| 192 | for( const auto l : geode::Indices{ lines } ) |
| 193 | { |
| 194 | const auto& line = section.line( lines[l] ); |
| 195 | const auto& mesh = line.mesh(); |
| 196 | geode::OpenGeodeModelException::test( |
| 197 | mesh.nb_vertices() == line_definitions[l].vertices.size(), |
| 198 | "Wrong number of Line vertices" ); |
| 199 | geode::OpenGeodeModelException::test( |
| 200 | mesh.nb_edges() == line_definitions[l].vertices.size() - 1, |
| 201 | "Wrong number of Line edges" ); |
| 202 | for( const auto& corner : section.boundaries( line ) ) |
| 203 | { |
| 204 | if( corner.id() != corners[line_definitions[l].vertices.front()] |
no test coverage detected