Skip to content

Commit

Permalink
remove duplicate Array2D, update galois dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
wkjarosz committed Oct 30, 2023
1 parent ce6170e commit 290acc4
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 141 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ if(pcg32_ADDED)
target_include_directories(pcg32 INTERFACE "${pcg32_SOURCE_DIR}")
endif()

cpmaddpackage("gh:wkjarosz/galois#4cd153fd7b9fcec55de85e13fbae4af1d51aedfd")
cpmaddpackage("gh:wkjarosz/galois#1a81ee0c514fa38e230d8295b25511f0b85dc5d3")
if(galois_ADDED)
target_include_directories(galois++ INTERFACE "${galois_SOURCE_DIR}/include")
endif()
Expand Down
10 changes: 5 additions & 5 deletions gui/SampleViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ string gridFragmentShader =
void computeCameraMatrices(Matrix4f &model, Matrix4f &lookat, Matrix4f &view, Matrix4f &proj, const CameraParameters &c,
float window_aspect);
void drawEPSGrid(const Matrix4f &mvp, int grid_res, ofstream &file);
void writeEPSPoints(const Array2D<float> &points, int start, int count, const Matrix4f &mvp, ofstream &file, int dim_x,
void writeEPSPoints(const Array2d<float> &points, int start, int count, const Matrix4f &mvp, ofstream &file, int dim_x,
int dim_y, int dim_z);

float mapCount2Slider(int count)
Expand Down Expand Up @@ -1533,7 +1533,7 @@ void SampleViewer::generate_points()
{
vector<float> r(m_num_dimensions, 0.5f);
generator->sample(r.data(), i);
for (int j = 0; j < m_points.size_y(); ++j)
for (int j = 0; j < m_points.sizeY(); ++j)
m_points(i, j) = r[j] - 0.5f;
}
float time2 = (float)glfwGetTime();
Expand All @@ -1558,7 +1558,7 @@ void SampleViewer::populate_point_subset()
// << ((m_subset_level->value() + 0.0f)/m_num_subset_levels->value()) << ", "
// << ((m_subset_level->value()+1.0f)/m_num_subset_levels->value()) << ")." << endl;
m_subset_count = 0;
for (int i = 0; i < m_points.size_x(); ++i)
for (int i = 0; i < m_points.sizeX(); ++i)
{
float v = m_points(i, m_subset_axis->value());
// cout << v << endl;
Expand All @@ -1567,7 +1567,7 @@ void SampleViewer::populate_point_subset()
v < (m_subset_level->value() + 1.0f) / m_num_subset_levels->value())
{
// copy all dimensions (rows) of point i
for (int j = 0; j < m_subset_points.size_y(); ++j)
for (int j = 0; j < m_subset_points.sizeY(); ++j)
m_subset_points(m_subset_count, j) = m_points(i, j);
++m_subset_count;
}
Expand Down Expand Up @@ -1703,7 +1703,7 @@ void drawEPSGrid(const Matrix4f &mvp, int grid_res, ofstream &file)
}
}

void writeEPSPoints(const Array2D<float> &points, int start, int count, const Matrix4f &mvp, ofstream &file, int dim_x,
void writeEPSPoints(const Array2d<float> &points, int start, int count, const Matrix4f &mvp, ofstream &file, int dim_x,
int dim_y, int dim_z)
{
for (int i = start; i < start + count; i++)
Expand Down
3 changes: 2 additions & 1 deletion gui/SampleViewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <nanogui/textbox.h>
#include <thread>

#include <galois++/array2d.h>
#include <sampler/fwd.h>

#include "utils.h"
Expand Down Expand Up @@ -131,7 +132,7 @@ class SampleViewer : public Screen
nanogui::ref<Shader> m_point_shader;
nanogui::ref<Shader> m_grid_shader;
nanogui::ref<Shader> m_point_2d_shader;
Array2D<float> m_points, m_subset_points;
Array2d<float> m_points, m_subset_points;
vector<Vector3f> m_3d_points;
int m_target_point_count, m_point_count, m_subset_count = 0, m_coarse_line_count, m_fine_line_count;

Expand Down
134 changes: 0 additions & 134 deletions gui/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,137 +267,3 @@ struct Arcball
};

NAMESPACE_END(nanogui)

//! Generic, resizable, 2D array class.
template <typename T>
class Array2D
{
public:
//@{ \name Constructors and destructors
Array2D(); // empty array, 0 by 0 elements
Array2D(int size_x, int size_y, const T &value = T(0.)); // size_x by size_y elements

Array2D(const Array2D &o)
{
m_data = o.m_data;
m_sizes[0] = o.m_sizes[0];
m_sizes[1] = o.m_sizes[1];
}
Array2D &operator=(const Array2D &o)
{
m_data = o.m_data;
m_sizes[0] = o.m_sizes[0];
m_sizes[1] = o.m_sizes[1];
return *this;
};
//@}

//@{ \name Element access
T &operator()(int x, int y)
{
return m_data[y * m_sizes[0] + x];
}
const T &operator()(int x, int y) const
{
return m_data[y * m_sizes[0] + x];
}
T &operator()(int i)
{
return m_data[i];
}
const T &operator()(int i) const
{
return m_data[i];
}
const T *data() const
{
return &(m_data[0]);
}
T *data()
{
return &(m_data[0]);
}
//@}

//@{ \name Dimension sizes
int width() const
{
return m_sizes[0];
}
int height() const
{
return m_sizes[1];
}
int size() const
{
return m_sizes[0] * m_sizes[1];
}
int size(int d) const
{
return m_sizes[d];
}
int size_x() const
{
return m_sizes[0];
}
int size_y() const
{
return m_sizes[1];
}

Array2D &swapped_dims()
{
std::swap(m_sizes[0], m_sizes[1]);
return *this;
}
//@}

void resize(int size_x, int size_y, const T &value = T(0.));
void reset(const T &value = T(0.));
void operator=(const T &);

protected:
std::vector<T> m_data;
int m_sizes[2];
};

template <typename T>
inline Array2D<T>::Array2D() : m_data()
{
m_sizes[0] = m_sizes[1] = 0;
}

template <typename T>
inline Array2D<T>::Array2D(int size_x, int size_y, const T &value) : m_data(size_x * size_y, value)
{
m_sizes[0] = size_x;
m_sizes[1] = size_y;
}

template <typename T>
inline void Array2D<T>::resize(int size_x, int size_y, const T &value)
{
if (size_x == m_sizes[0] && size_y == m_sizes[1])
return;

m_data.resize(size_x * size_y, value);
m_sizes[0] = size_x;
m_sizes[1] = size_y;
}

template <typename T>
inline void Array2D<T>::reset(const T &value)
{
for (int i = 0; i < size(); ++i)
m_data[i] = value;
}

template <typename T>
inline void Array2D<T>::operator=(const T &value)
{
reset(value);
}

using Array2Di = Array2D<int>;
using Array2Dd = Array2D<double>;
using Array2Df = Array2D<float>;

0 comments on commit 290acc4

Please sign in to comment.