Skip to content

Commit

Permalink
LineModel: Rename connections() to edges()
Browse files Browse the repository at this point in the history
  • Loading branch information
AsnelChristian committed Jun 9, 2017
1 parent 080bfd0 commit 626cc2a
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 39 deletions.
2 changes: 1 addition & 1 deletion CE3D2/doc/GettingStarted-LineModels.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()`.

Expand Down
18 changes: 9 additions & 9 deletions CE3D2/models/LineModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -47,7 +47,7 @@ namespace Models
LineModel::hypercube(Vector::size_type dimension)
{
using container_size_type = std::remove_reference<decltype(
std::declval<LineModel>().connections())>::type::size_type;
std::declval<LineModel>().edges())>::type::size_type;

// Precompute the size needed to store the index-pairs.
container_size_type index_count =
Expand All @@ -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
Expand Down Expand Up @@ -113,15 +113,15 @@ namespace Models
}

StorageType<IndexPair> const&
LineModel::connections() const
LineModel::edges() const
{
return m_Connections;
return m_Edges;
}

StorageType<IndexPair>&
LineModel::connections()
LineModel::edges()
{
return m_Connections;
return m_Edges;
}
}
}
6 changes: 3 additions & 3 deletions CE3D2/models/LineModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,18 @@ namespace Models
/// @returns A reference to the `StorageType` containing the
/// connection-index-pairs.
StorageType<IndexPair>&
connections();
edges();

/// Returns a read-only `StorageType` that contains the pairs that
/// define the line-connections of the model between the vectors.
///
/// @returns A `const` reference to the `StorageType` containing the
/// connection-index-pairs.
StorageType<IndexPair> const&
connections() const;
edges() const;

private:
StorageType<IndexPair> m_Connections;
StorageType<IndexPair> m_Edges;
};
}
}
Expand Down
2 changes: 1 addition & 1 deletion CE3D2/render/TextRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
48 changes: 24 additions & 24 deletions CE3D2/tests/models/LineModelTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ struct HypercubeConnectionsFixture
}

std::remove_reference<decltype(std::declval<
CE3D2::Models::LineModel>().connections())>::type
CE3D2::Models::LineModel>().edges())>::type
F_connections;
};

Expand Down Expand Up @@ -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<decltype( \
std::declval<CE3D2::Models::LineModel>().connections())> \
std::declval<CE3D2::Models::LineModel>().edges())> \
::type::size_type i = 0; \
i < (result).size(); \
i++) \
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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);
Expand Down Expand Up @@ -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()
2 changes: 1 addition & 1 deletion CE3D2/tests/render/TextRendererTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 626cc2a

Please sign in to comment.