From 626cc2a65446c422beccb2c8f3b4513fd1647cfc Mon Sep 17 00:00:00 2001 From: AsnelChristian Date: Fri, 9 Jun 2017 17:12:23 +0100 Subject: [PATCH] LineModel: Rename connections() to edges() Closes https://github.com/Makman2/CE3D2/issues/108 --- CE3D2/doc/GettingStarted-LineModels.md | 2 +- CE3D2/models/LineModel.cpp | 18 +++++----- CE3D2/models/LineModel.h | 6 ++-- CE3D2/render/TextRenderer.cpp | 2 +- CE3D2/tests/models/LineModelTest.cpp | 48 ++++++++++++------------- CE3D2/tests/render/TextRendererTest.cpp | 2 +- 6 files changed, 39 insertions(+), 39 deletions(-) diff --git a/CE3D2/doc/GettingStarted-LineModels.md b/CE3D2/doc/GettingStarted-LineModels.md index 9680a26..3d1467a 100644 --- a/CE3D2/doc/GettingStarted-LineModels.md +++ b/CE3D2/doc/GettingStarted-LineModels.md @@ -27,7 +27,7 @@ int main() The line model contains additional information what vectors are connected together with a line. This information is stored inside -`LineModel::connections()` using index pairs of the vectors in +`LineModel::edges()` using index pairs of the vectors in `LineModel::vectors()`. The indices in the pairs refer to the (zero-based) position inside `LineModel::vectors()`. diff --git a/CE3D2/models/LineModel.cpp b/CE3D2/models/LineModel.cpp index 6abd78c..810c8dc 100644 --- a/CE3D2/models/LineModel.cpp +++ b/CE3D2/models/LineModel.cpp @@ -9,17 +9,17 @@ namespace Models { LineModel::LineModel() : Model() - , m_Connections() + , m_Edges() {} LineModel::LineModel(std::string name) : Model(name) - , m_Connections() + , m_Edges() {} LineModel::LineModel(Model const& copy) : Model(copy) - , m_Connections() + , m_Edges() {} LineModel::~LineModel() @@ -47,7 +47,7 @@ namespace Models LineModel::hypercube(Vector::size_type dimension) { using container_size_type = std::remove_reference().connections())>::type::size_type; + std::declval().edges())>::type::size_type; // Precompute the size needed to store the index-pairs. container_size_type index_count = @@ -68,7 +68,7 @@ namespace Models // The `dimension == 0` case is automatically covered from // `Model::hypercube()`. auto model = LineModel(Model::hypercube(dimension)); - auto& connections = model.connections(); + auto& connections = model.edges(); // The pre-size calculation formula below doesn't work for // `dimension == 1` (because of the bitshift optimizations for 2^x @@ -113,15 +113,15 @@ namespace Models } StorageType const& - LineModel::connections() const + LineModel::edges() const { - return m_Connections; + return m_Edges; } StorageType& - LineModel::connections() + LineModel::edges() { - return m_Connections; + return m_Edges; } } } diff --git a/CE3D2/models/LineModel.h b/CE3D2/models/LineModel.h index 7f117ce..5765c90 100644 --- a/CE3D2/models/LineModel.h +++ b/CE3D2/models/LineModel.h @@ -64,7 +64,7 @@ namespace Models /// @returns A reference to the `StorageType` containing the /// connection-index-pairs. StorageType& - connections(); + edges(); /// Returns a read-only `StorageType` that contains the pairs that /// define the line-connections of the model between the vectors. @@ -72,10 +72,10 @@ namespace Models /// @returns A `const` reference to the `StorageType` containing the /// connection-index-pairs. StorageType const& - connections() const; + edges() const; private: - StorageType m_Connections; + StorageType m_Edges; }; } } diff --git a/CE3D2/render/TextRenderer.cpp b/CE3D2/render/TextRenderer.cpp index fd52ea8..f956e25 100644 --- a/CE3D2/render/TextRenderer.cpp +++ b/CE3D2/render/TextRenderer.cpp @@ -99,7 +99,7 @@ namespace Render { if (model->is_visible()) { - for (auto const& indexpair: model->connections()) + for (auto const& indexpair: model->edges()) { auto const& v1 = model->vectors()[indexpair.first]; auto const& v2 = model->vectors()[indexpair.second]; diff --git a/CE3D2/tests/models/LineModelTest.cpp b/CE3D2/tests/models/LineModelTest.cpp index 1a8920f..1ba2bca 100644 --- a/CE3D2/tests/models/LineModelTest.cpp +++ b/CE3D2/tests/models/LineModelTest.cpp @@ -106,7 +106,7 @@ struct HypercubeConnectionsFixture } std::remove_reference().connections())>::type + CE3D2::Models::LineModel>().edges())>::type F_connections; }; @@ -142,33 +142,33 @@ BOOST_AUTO_TEST_CASE(test_from_model_constructor) CE3D2_CHECK_VECTORS_EQUAL(uut.vectors()[1], vecs[1]); CE3D2_CHECK_VECTORS_EQUAL(uut.vectors()[2], vecs[2]); - BOOST_CHECK_EQUAL(uut.connections().size(), 0); + BOOST_CHECK_EQUAL(uut.edges().size(), 0); } -BOOST_AUTO_TEST_CASE(test_connections) +BOOST_AUTO_TEST_CASE(test_edges) { CE3D2::Models::LineModel uut; - BOOST_CHECK_EQUAL(uut.connections().size(), 0); + BOOST_CHECK_EQUAL(uut.edges().size(), 0); auto ip = CE3D2::Models::IndexPair(0, 1); - uut.connections().push_back(ip); - BOOST_CHECK_EQUAL(uut.connections().size(), 1); - CE3D2_CHECK_INDEX_PAIRS_EQUAL(uut.connections()[0], ip); + uut.edges().push_back(ip); + BOOST_CHECK_EQUAL(uut.edges().size(), 1); + CE3D2_CHECK_INDEX_PAIRS_EQUAL(uut.edges()[0], ip); auto ip2 = CE3D2::Models::IndexPair(55, 142); - uut.connections().push_back(ip2); - BOOST_CHECK_EQUAL(uut.connections().size(), 2); - CE3D2_CHECK_INDEX_PAIRS_EQUAL(uut.connections()[0], ip); - CE3D2_CHECK_INDEX_PAIRS_EQUAL(uut.connections()[1], ip2); + uut.edges().push_back(ip2); + BOOST_CHECK_EQUAL(uut.edges().size(), 2); + CE3D2_CHECK_INDEX_PAIRS_EQUAL(uut.edges()[0], ip); + CE3D2_CHECK_INDEX_PAIRS_EQUAL(uut.edges()[1], ip2); - uut.connections().clear(); - BOOST_CHECK_EQUAL(uut.connections().size(), 0); + uut.edges().clear(); + BOOST_CHECK_EQUAL(uut.edges().size(), 0); } #define CHECK_HYPERCUBE_CONNECTIONS(result) \ for (std::remove_reference().connections())> \ + std::declval().edges())> \ ::type::size_type i = 0; \ i < (result).size(); \ i++) \ @@ -190,8 +190,8 @@ BOOST_FIXTURE_TEST_CASE(test_square, HypercubeConnectionsFixture) CE3D2_CHECK_VECTORS_EQUAL(uut.vectors()[3], CE3D2::create_vector(-0.5f, -0.5f)); - BOOST_CHECK_EQUAL(uut.connections().size(), 4); - CHECK_HYPERCUBE_CONNECTIONS(uut.connections()); + BOOST_CHECK_EQUAL(uut.edges().size(), 4); + CHECK_HYPERCUBE_CONNECTIONS(uut.edges()); } BOOST_FIXTURE_TEST_CASE(test_cube, HypercubeConnectionsFixture) @@ -216,8 +216,8 @@ BOOST_FIXTURE_TEST_CASE(test_cube, HypercubeConnectionsFixture) CE3D2_CHECK_VECTORS_EQUAL(uut.vectors()[7], CE3D2::create_vector(-0.5f, -0.5f, -0.5f)); - BOOST_CHECK_EQUAL(uut.connections().size(), 12); - CHECK_HYPERCUBE_CONNECTIONS(uut.connections()); + BOOST_CHECK_EQUAL(uut.edges().size(), 12); + CHECK_HYPERCUBE_CONNECTIONS(uut.edges()); } BOOST_FIXTURE_TEST_CASE(test_tesseract, HypercubeConnectionsFixture) @@ -258,8 +258,8 @@ BOOST_FIXTURE_TEST_CASE(test_tesseract, HypercubeConnectionsFixture) CE3D2_CHECK_VECTORS_EQUAL(uut.vectors()[15], CE3D2::create_vector(-0.5f, -0.5f, -0.5f, -0.5f)); - BOOST_CHECK_EQUAL(uut.connections().size(), 32); - CHECK_HYPERCUBE_CONNECTIONS(uut.connections()); + BOOST_CHECK_EQUAL(uut.edges().size(), 32); + CHECK_HYPERCUBE_CONNECTIONS(uut.edges()); } BOOST_FIXTURE_TEST_CASE(test_hypercube, HypercubeConnectionsFixture) @@ -274,8 +274,8 @@ BOOST_FIXTURE_TEST_CASE(test_hypercube, HypercubeConnectionsFixture) CE3D2_CHECK_VECTORS_EQUAL(uut.vectors()[0], CE3D2::create_vector(0.5f)); CE3D2_CHECK_VECTORS_EQUAL(uut.vectors()[1], CE3D2::create_vector(-0.5f)); - BOOST_CHECK_EQUAL(uut.connections().size(), 1); - CHECK_HYPERCUBE_CONNECTIONS(uut.connections()); + BOOST_CHECK_EQUAL(uut.edges().size(), 1); + CHECK_HYPERCUBE_CONNECTIONS(uut.edges()); // Test the 5D case. uut = CE3D2::Models::LineModel::hypercube(5); @@ -378,8 +378,8 @@ BOOST_FIXTURE_TEST_CASE(test_hypercube, HypercubeConnectionsFixture) uut.vectors()[31], CE3D2::create_vector(-0.5f, -0.5f, -0.5f, -0.5f, -0.5f)); - BOOST_CHECK_EQUAL(uut.connections().size(), 80); - CHECK_HYPERCUBE_CONNECTIONS(uut.connections()); + BOOST_CHECK_EQUAL(uut.edges().size(), 80); + CHECK_HYPERCUBE_CONNECTIONS(uut.edges()); } BOOST_AUTO_TEST_SUITE_END() diff --git a/CE3D2/tests/render/TextRendererTest.cpp b/CE3D2/tests/render/TextRendererTest.cpp index 9f0c3d3..781adb3 100644 --- a/CE3D2/tests/render/TextRendererTest.cpp +++ b/CE3D2/tests/render/TextRendererTest.cpp @@ -270,7 +270,7 @@ BOOST_AUTO_TEST_CASE(test_line_render3) auto& vectors = line->vectors(); vectors.push_back(CE3D2::create_vector(1.0f, 1.0f)); vectors.push_back(CE3D2::create_vector(36.0f, 12.0f)); - auto& edges = line->connections(); + auto& edges = line->edges(); edges.push_back(CE3D2::Models::IndexPair(0, 1)); CE3D2::Render::TextRenderer renderer;