Skip to content

Commit

Permalink
Various compile error fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Jackson <[email protected]>
  • Loading branch information
imikejackson committed Jul 9, 2024
1 parent 2e1a26c commit cd3b889
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,8 @@ DataStore<UnderlyingType_t<PixelT>> ConvertImageToDataStore(itk::Image<PixelT, D
using ImageType = itk::Image<PixelT, Dimension>;
using T = UnderlyingType_t<PixelT>;
typename ImageType::SizeType imageSize = image.GetLargestPossibleRegion().GetSize();
std::vector<usize> tDims(imageSize.rbegin(), imageSize.rend());
std::vector<usize> cDims = GetComponentDimensions<PixelT>();
typename DataStore<T>::ShapeType tDims(imageSize.rbegin(), imageSize.rend());
typename DataStore<T>::ShapeType cDims = GetComponentDimensions<PixelT>();
if constexpr(Dimension == 2)
{
tDims.insert(tDims.begin(), 1);
Expand Down
3 changes: 2 additions & 1 deletion src/simplnx/DataStructure/AbstractDataStore.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ class AbstractDataStore : public IDataStore
using XArrayType = typename xt::xarray<T>;
using Iterator = typename XArrayType::iterator;
using ConstIterator = typename XArrayType::const_iterator;
using XArrayShapeType = typename xt::xarray<T>::shape_type;

virtual ~AbstractDataStore() = default;
~AbstractDataStore() override = default;

/**
* @brief Returns the value found at the specified index of the DataStore.
Expand Down
15 changes: 2 additions & 13 deletions src/simplnx/DataStructure/AbstractListStore.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class AbstractListStore
using iterator = typename xarray_type::iterator;
using const_iterator = typename xarray_type::const_iterator;

~AbstractListStore() = default;
virtual ~AbstractListStore() = default;

virtual xarray_type& xarray() = 0;
virtual const xarray_type& xarray() const = 0;
Expand Down Expand Up @@ -153,7 +153,7 @@ class AbstractListStore
return copyOfList(grainId);
}

usize getListSize(uint64 grainId) const
usize getListSize(usize grainId) const
{
auto offset = grainId * xtensorListSize();
return xarray().flat(offset);
Expand Down Expand Up @@ -221,17 +221,6 @@ class AbstractListStore
return getNumberOfLists();
}

/**
* @brief getListSize
* @param grainId
* @return int32
*/
virtual int32 getListSize(int32 grainId) const
{
uint64 offset = (grainId * xtensorListSize()); // First element is list size
return xarray().flat(offset);
}

/**
* @brief operator []
* @param grainId
Expand Down
10 changes: 5 additions & 5 deletions src/simplnx/DataStructure/DataStore.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class DataStore : public AbstractDataStore<T>
, m_NumComponents(std::accumulate(m_ComponentShape.cbegin(), m_ComponentShape.cend(), static_cast<size_t>(1), std::multiplies<>()))
, m_NumTuples(std::accumulate(m_TupleShape.cbegin(), m_TupleShape.cend(), static_cast<size_t>(1), std::multiplies<>()))
{
std::vector<uint64> shape(m_TupleShape.begin(), m_TupleShape.end());
typename AbstractDataStore<T>::XArrayShapeType shape(m_TupleShape.begin(), m_TupleShape.end());
shape.insert(shape.end(), m_ComponentShape.begin(), m_ComponentShape.end());
m_Array = std::shared_ptr<XArrayType>(new XArrayType(shape));

Expand All @@ -89,7 +89,7 @@ class DataStore : public AbstractDataStore<T>
, m_NumComponents(std::accumulate(m_ComponentShape.cbegin(), m_ComponentShape.cend(), static_cast<size_t>(1), std::multiplies<>()))
, m_NumTuples(std::accumulate(m_TupleShape.cbegin(), m_TupleShape.cend(), static_cast<size_t>(1), std::multiplies<>()))
{
std::vector<uint64> shape(m_TupleShape.begin(), m_TupleShape.end());
typename AbstractDataStore<T>::XArrayShapeType shape(m_TupleShape.begin(), m_TupleShape.end());
shape.insert(shape.end(), m_ComponentShape.begin(), m_ComponentShape.end());
m_Array = std::shared_ptr<XArrayType>(new XArrayType(shape));
if(buffer != nullptr)
Expand Down Expand Up @@ -183,12 +183,12 @@ class DataStore : public AbstractDataStore<T>
return m_Array->data();
}

XArrayType& xarray()
XArrayType& xarray() override
{
return *m_Array.get();
}

const XArrayType& xarray() const
const XArrayType& xarray() const override
{
return *m_Array.get();
}
Expand Down Expand Up @@ -257,7 +257,7 @@ class DataStore : public AbstractDataStore<T>

usize newSize = getNumberOfComponents() * m_NumTuples;

std::vector<uint64> shape(m_TupleShape.begin(), m_TupleShape.end());
typename AbstractDataStore<T>::XArrayShapeType shape(m_TupleShape.begin(), m_TupleShape.end());
shape.insert(shape.end(), m_ComponentShape.begin(), m_ComponentShape.end());

if(m_Array.get() == nullptr) // Data was never allocated
Expand Down
4 changes: 2 additions & 2 deletions src/simplnx/DataStructure/ListStore.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ListStore : public AbstractListStore<T>
using xarray_type = typename parent_type::xarray_type;
using iterator = typename parent_type::iterator;
using const_iterator = typename parent_type::const_iterator;
using shape_type = typename std::vector<uint64>;
using shape_type = typename std::vector<usize>;

/**
* @brief Constructs a ListStore using the specified tuple shape and list size.
Expand Down Expand Up @@ -65,7 +65,7 @@ class ListStore : public AbstractListStore<T>
, m_XtensorListSize(std::move(copy.m_XtensorListSize))
{
}
~ListStore() = default;
~ListStore() override = default;

/**
* @brief Returns a reference to the underlying xtensor array.
Expand Down
11 changes: 8 additions & 3 deletions src/simplnx/DataStructure/NeighborList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace nx::core
template <typename T>
NeighborList<T>::NeighborList(DataStructure& dataStructure, const std::string& name, usize numTuples)
: INeighborList(dataStructure, name, numTuples)
, m_Store(std::make_shared<ListStore<T>>(std::vector<uint64>{numTuples}))
, m_Store(std::make_shared<ListStore<T>>(std::vector<usize>{numTuples}))
, m_IsAllocated(false)
, m_InitValue(static_cast<T>(0.0))
{
Expand Down Expand Up @@ -48,7 +48,7 @@ NeighborList<T>* NeighborList<T>::Import(DataStructure& dataStructure, const std
}

template <typename T>
NeighborList<T>::NeighborList<T>(const NeighborList<T>& other)
NeighborList<T>::NeighborList(const NeighborList<T>& other)
: INeighborList(other)
, m_Store(other.m_Store)
, m_IsAllocated(other.m_IsAllocated)
Expand All @@ -59,6 +59,11 @@ NeighborList<T>::NeighborList<T>(const NeighborList<T>& other)
template <typename T>
NeighborList<T>& NeighborList<T>::operator=(const NeighborList<T>& rhs)
{
if(this == &rhs)
{
return *this;
}

m_Store->copy(*rhs.m_Store.get());
m_IsAllocated = rhs.m_IsAllocated;
m_InitValue = rhs.m_InitValue;
Expand Down Expand Up @@ -283,7 +288,7 @@ template <typename T>
void NeighborList<T>::setLists(const std::vector<std::vector<T>>& neighborLists)
{
usize totalFeatures = neighborLists.size();
uint64 reserveSize = 0;
usize reserveSize = 0;
for(size_t i = 1; i < totalFeatures; i++)
{
reserveSize = std::max(reserveSize, neighborLists[i].size());
Expand Down
2 changes: 1 addition & 1 deletion src/simplnx/Utilities/DataArrayUtilities.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1108,7 +1108,7 @@ class AppendArray
using NeighborListType = NeighborList<T>;
auto* destArrayPtr = dynamic_cast<NeighborListType*>(m_DestCellArray);
// Make sure the destination array is allocated AND each tuple list is initialized so we can use the [] operator to copy over the data
if(destArray->getVectors().empty() || destArray->getList(0).size() == 0)
if(destArrayPtr->getVectors().empty() || destArrayPtr->getList(0).size() == 0)
{
destArrayPtr->addEntry(destArrayPtr->getNumberOfTuples() - 1, 0);
}
Expand Down

0 comments on commit cd3b889

Please sign in to comment.