30 #ifndef LVR2_TYPES_BASEBUFFER 31 #define LVR2_TYPES_BASEBUFFER 79 return channelWidth<unsigned char>(name);
89 return channelWidth<float>(name);
99 return channelWidth<unsigned int>(name);
112 bool hasChannel(
const std::string& name)
const;
120 return hasChannel<unsigned char>(name);
129 return hasChannel<float>(name);
138 return hasChannel<unsigned int>(name);
161 addChannel<float>(data, name);
171 addChannel<unsigned char>(data, name);
181 addChannel<unsigned int>(data, name);
191 void addChannel(boost::shared_array<T> array, std::string name,
size_t n,
size_t width);
200 addChannel<unsigned int>(array, name, n, width);
210 addChannel<float>(array, name, n, width);
222 addChannel<unsigned char>(array, name, n, width);
234 void addEmptyChannel(
const std::string& name,
size_t n,
size_t width);
244 addEmptyChannel<float>(name, n, width);
255 addEmptyChannel<unsigned char>(name, n, width);
266 addEmptyChannel<unsigned int>(name, n, width);
295 return removeChannel<unsigned int>(name);
308 return removeChannel<float>(name);
321 return removeChannel<unsigned char>(name);
337 template <
typename T>
340 for(
auto it = this->typedBegin<T>(); it != this->end(); ++it)
342 channels.insert(*it);
355 template <
typename T>
358 for(
auto it = this->typedBegin<T>(); it != this->end(); ++it)
360 channels.push_back({it->first, it->second});
395 return getChannel<float>(name);
406 return getChannel<unsigned char>(name);
417 return getChannel<unsigned int>(name);
477 return getHandle<float>(idx, name);
489 return getHandle<unsigned char>(idx, name);
501 return getHandle<unsigned int>(idx, name);
518 boost::shared_array<T>
getArray(
const std::string& name,
size_t& n,
size_t& w);
530 return getArray<float>(name, n, w);
543 return getArray<unsigned char>(name, n, w);
556 return getArray<unsigned int>(name, n, w);
573 void addAtomic(T data,
const std::string& name);
626 boost::optional<T>
getAtomic(
const std::string& name);
638 return getAtomic<float>(name);
651 return getAtomic<unsigned char>(name);
664 return getAtomic<int>(name);
671 for(
auto vchannel: *
this)
673 cm.insert({vchannel.first, boost::apply_visitor(visitor, vchannel.second)});
681 for(
auto elem : *
this)
683 ret.insert({elem.first, elem.second.clone()});
692 #include "BaseBuffer.tcc" 694 #endif // LVR2_TYPES_BASEBUFFER int getAllChannelsOfType(std::vector< std::pair< std::string, Channel< T > >> &channels)
Returns all channels of type T.
UCharProxy getUCharHandle(unsigned int idx, const std::string &name)
Get a Handle object (ElementProxy) of an uchar channel.
BaseBuffer manipulate(V visitor)
void addAtomic(T data, const std::string &name)
Adds an atomic value. Exists only for compatibility reasons. Dont use atomics, they are implemented a...
Datastructures for holding loaded data.
void getChannel(const std::string &name, FloatChannelOptional &channelOptional)
Gets a float channel and returns it as optional.
ElementProxy< T > getHandle(unsigned int idx, const std::string &name)
Get a Handle object (ElementProxy) of a specific typed channel.
bool hasUCharChannel(const std::string &name) const
Checks if an uchar channel is available.
Access type index by type.
void addFloatChannel(floatArr array, std::string name, size_t n, size_t width)
Constructs a float channel from an boost::shared_array and saves it to the map.
FloatProxy getFloatHandle(unsigned int idx, const std::string &name)
Get a Handle object (ElementProxy) of a float channel.
IndexProxy getIndexHandle(unsigned int idx, const std::string &name)
Get a Handle object (ElementProxy) of an index channel.
bool hasIndexChannel(const std::string &name) const
Checks if an index channel is available.
void addEmptyChannel(const std::string &name, size_t n, size_t width)
Adds an empty channel to the map.
boost::optional< T > getAtomic(const std::string &name)
Gets an atomic value.
void addEmptyFloatChannel(const std::string &name, size_t n, size_t width)
Adds an empty float channel to the map.
ucharOptional getUCharAtomic(const std::string &name)
Gets an atomic uchar value.
size_t indexChannelWidth(const std::string &name) const
Gets an index channels width.
std::unordered_map< std::string, VariantChannel< T... > > base
bool removeIndexChannel(const std::string &name)
Removes an index channel. If the type is not required use: erase.
size_t channelWidth(const std::string &name) const
Gets a channels width.
void addIntAtomic(int data, const std::string &name)
Adds an atomic int value. Exists only for compatibility reasons. Dont use atomics, they are implemented as Channels. -> memory overhead. Kept because of api stability.
boost::optional< int > intOptional
floatOptional getFloatAtomic(const std::string &name)
Gets an atomic float value.
boost::shared_array< unsigned char > ucharArr
UCharChannel::Optional UCharChannelOptional
void addUCharChannel(ucharArr array, std::string name, size_t n, size_t width)
Constructs an uchar channel from an boost::shared_array and saves it to the map.
void addIndexChannel(indexArray array, std::string name, size_t n, size_t width)
Constructs an index channel from an boost::shared_array and saves it to the map.
void addFloatChannel(FloatChannelPtr data, const std::string &name)
Adds a float channel pointer to the map.
bool hasChannel(const std::string &name) const
Checks if a channel is available.
OutMapT< typename InMapT::HandleType, std::result_of_t< MapF(typename InMapT::ValueType)> > map(const InMapT &mapIn, MapF func)
Calls func for each value of the given map and save the result in the output map. ...
void addChannel(typename Channel< T >::Ptr data, const std::string &name)
Adds a channel pointer to the map.
boost::optional< unsigned char > ucharOptional
void getChannel(const std::string &name, IndexChannelOptional &channelOptional)
Gets an index channel and returns it as optional.
floatArr getFloatArray(const std::string &name, size_t &n, size_t &w)
Gets a float channel as array.
boost::shared_array< unsigned int > indexArray
void addEmptyUCharChannel(const std::string &name, size_t n, size_t width)
Adds an empty uchar channel to the map.
ucharArr getUCharArray(const std::string &name, size_t &n, size_t &w)
Gets an uchar channel as array.
void addIndexChannel(IndexChannelPtr data, const std::string &name)
Adds an index channel pointer to the map. cointer to add. cannel.
boost::shared_array< float > floatArr
void addUCharChannel(UCharChannelPtr data, const std::string &name)
Adds an uchar channel pointer to the map.
void addUCharAtomic(unsigned char data, const std::string &name)
Adds an atomic uchar value. Exists only for compatibility reasons. Dont use atomics, they are implemented as Channels. -> memory overhead. Kept because of api stability.
void addEmptyIndexChannel(const std::string &name, size_t n, size_t width)
Adds an empty index channel to the map.
VariantChannelMap< char, unsigned char, short, unsigned short, int, unsigned int, float, double > MultiChannelMap
IndexChannel::Ptr IndexChannelPtr
FloatChannel::Optional FloatChannelOptional
boost::optional< Channel< T > > Optional
size_t floatChannelWidth(const std::string &name) const
Gets a float channels width.
intOptional getIntAtomic(const std::string &name)
Gets an atomic int value.
UCharChannel::Ptr UCharChannelPtr
boost::optional< float > floatOptional
bool removeFloatChannel(const std::string &name)
Removes a float channel. If the type is not required use: erase.
boost::shared_array< T > getArray(const std::string &name, size_t &n, size_t &w)
Gets a channel as array.
IndexChannel::Optional IndexChannelOptional
bool hasFloatChannel(const std::string &name) const
Checks if a float channel is available.
void getChannel(const std::string &name, UCharChannelOptional &channelOptional)
Gets an uchar channel and returns it as optional.
Channel< unsigned int >::Optional getIndexChannel(const std::string &name)
Gets an index channel and returns it as optional.
FloatChannel::Ptr FloatChannelPtr
void addFloatAtomic(float data, const std::string &name)
Adds an atomic float value. Exists only for compatibility reasons. Dont use atomics, they are implemented as Channels. -> memory overhead.
int getAllChannelsOfType(std::map< std::string, Channel< T > > &channels)
Returns all channels of type T.
Channel< float >::Optional getFloatChannel(const std::string &name)
Gets a float channel and returns it as optional.
size_t ucharChannelWidth(const std::string &name) const
Gets an uchar channels width.
std::shared_ptr< Channel< T > > Ptr
ChannelManager class Store and access AttributeChannels. It expands the MultiChannelMap with downwoar...
bool removeChannel(const std::string &name)
Removes a channel with a specific type. If the type is not required use: erase.
Channel< unsigned char >::Optional getUCharChannel(const std::string &name)
Gets an uchar channel and returns it as optional.
bool removeUCharChannel(const std::string &name)
Removes an uchar channel. If the type is not required use: erase.
indexArray getIndexArray(const std::string &name, size_t &n, size_t &w)
Gets an index channel as array.
Channel< T >::Optional getChannel(const std::string &name)
Gets a channel and returns it as optional.