Skip to content

Commit

Permalink
Override listCount for variable-length lists
Browse files Browse the repository at this point in the history
  • Loading branch information
bchretien committed Feb 20, 2017
1 parent 721ef72 commit 63a39e6
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion source/tinyply.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,18 @@ namespace tinyply
return property_type_for_type<typename T::value_type>();
}

template <typename T>
inline bool is_vector_type(typename std::enable_if<!std::is_arithmetic<T>::value>::type* = 0)
{
return true;
}

template <typename T>
inline bool is_vector_type(typename std::enable_if<std::is_arithmetic<T>::value>::type* = 0)
{
return false;
}

class PlyElement
{
void parse_internal(std::istream & is);
Expand Down Expand Up @@ -291,7 +303,7 @@ namespace tinyply
std::vector<std::string> objInfo;

template<typename T>
size_t request_properties_from_element(const std::string & elementKey, std::vector<std::string> propertyKeys, std::vector<T> & source, const int listCount = 1)
size_t request_properties_from_element(const std::string & elementKey, std::vector<std::string> propertyKeys, std::vector<T> & source, int listCount = 1)
{
if (get_elements().size() == 0)
return 0;
Expand All @@ -303,6 +315,10 @@ namespace tinyply
}
else return 0;

// If a vector<vector<...>> is provided, override listCount
if (is_vector_type<T>())
listCount = 0;

// count and verify large enough
auto instance_counter = [&](const std::string & elementKey, const std::string & propertyKey)
{
Expand Down

0 comments on commit 63a39e6

Please sign in to comment.