20 for(
int j=0; j<channel.
width(); j++)
22 channel[i][j] = value;
32 std::cout <<
"1) Basic Channel Test" << std::endl;
33 size_t num_points = 10000;
47 fillChannel(colors, static_cast<unsigned char>(255));
50 std::cout <<
" points: " << points << std::endl;
51 std::cout <<
" number of normals: " << normals.
numElements() << std::endl;
52 std::cout <<
" number of color channels: " << colors.
width() << std::endl;
55 std::cout <<
" deep copy" << std::endl;
57 std::cout <<
" shallow copy" << std::endl;
66 std::cout <<
" generate a variant channel..." << std::endl;
68 std::cout <<
" a variant channel: " << vchannel << std::endl;
71 auto data = vchannel.
dataPtr<
float>();
72 std::cout <<
" first element of points: " << data[0] << std::endl;
75 std::cout <<
" float is the index " 77 <<
" in [float, unsigned char]" 84 std::cout <<
"2) Multi Channel Map Usage" << std::endl;
85 size_t num_points = 10000;
93 fillChannel(colors, static_cast<unsigned char>(255));
106 cm.insert({
"normals", normals});
109 std::cout <<
" number of channels in channelmap: " << cm.size() << std::endl;
110 std::cout <<
" number of points: " << cm[
"points"].numElements() << std::endl;
120 if(not_existing_channel) {
123 std::cout <<
" the channel 'hello world' doesnt exist" << std::endl;
127 auto it = cm.find(
"points");
130 std::cout <<
" " << it->first <<
" found!" << std::endl;
131 if(it->second.is_type<
float>())
139 std::cout <<
" lets iterate" << std::endl;
142 std::cout <<
" --"<< it.first <<
": " << it.second.
numElements() <<
" x " << it.second.width() << std::endl;
148 std::cout <<
" lets iterate over the type float" << std::endl;
149 for(
auto it = cm.typedBegin<
float>(); it != cm.end(); ++it)
152 std::cout <<
" --" << it->first <<
": " << ch << std::endl;
160 std::cout <<
" removing floats..." << std::endl,
161 std::cout <<
" size before remove: " << cm.size() << std::endl;
163 while(it2 != cm.end())
167 std::cout <<
" size after remove: " << cm.size() << std::endl;
173 std::vector<std::string> keys = fcm.
keys<
float>();
174 size_t num_float_channels = fcm.
numChannels<
float>();
177 std::cout <<
" The channel map: " << std::endl;
178 std::cout << cm << std::endl;
181 std::cout <<
" Channel Map Copy:" << std::endl;
183 std::cout <<
" deep copy" << std::endl;
185 std::cout <<
" deep copy" << std::endl;
188 std::cout <<
" shallow copy" << std::endl;
196 size_t num_points = 10000;
205 fillChannel(colors, static_cast<unsigned char>(255));
206 fillChannel(hyper, static_cast<unsigned char>(100));
208 std::cout <<
"3) Channel Manager Usage" << std::endl;
213 {
"points2" , points},
217 cm[
"points"] = points;
219 cm[
"normals"] = normals;
238 std::cout <<
" total number of elements: " << cm.size() << std::endl;
239 std::cout <<
" num float channels: " << cm.
numChannels<
float>() << std::endl;
240 std::cout <<
" float channels are:" << std::endl;
242 for(
auto key : cm.
keys<
float>())
244 std::cout <<
" -- " << key << std::endl;
249 std::cout <<
" float channels again:" << std::endl;
250 for(
auto it = cm.
typedBegin<
float>(); it != cm.end(); ++it)
252 std::cout <<
" -- " << it->first <<
" " << it->second.numElements() << std::endl;
253 cm2.insert({it->first, it->second});
254 cm2[it->first] = it->second;
257 std::cout <<
" inserted elements: " << cm2.size() << std::endl;
259 std::cout <<
" float iteration with remove:" << std::endl;
261 while(it != cm.end())
263 std::cout <<
" remove " << it->first << std::endl;
268 std::cout <<
" unsigned char iteration:" << std::endl;
269 for(
auto it = cm.
typedBegin<
unsigned char>(); it != cm.end(); ++it)
271 std::cout <<
" -- " << it->first << std::endl;
278 std::cout <<
" colors found: " << colors3->numElements() << std::endl;
285 size_t num_points = 10000;
293 fillChannel(colors, static_cast<unsigned char>(255));
295 std::cout <<
"3) Channel Manager Usage" << std::endl;
303 cm[
"points"] = points;
305 cm[
"normals"] = normals;
309 std::cout <<
"Sliced:" << std::endl;
310 std::cout << cm_sliced << std::endl;
313 std::cout <<
"Random Sampled:" << std::endl;
314 std::cout << cm_sampled << std::endl;
322 std::cout <<
" should be 42: " << pts4[10][0] << std::endl;
334 for(
int j=0; j<pts.
width(); j++)
336 if(pts[i][j] != pts2[i][j])
338 std::cout <<
"ERROR" << std::endl;
346 size_t num_points = 10000;
354 {
"normals", normals},
360 auto it = bb.find(
"points");
364 vchannel = it->second;
365 switch(vchannel.type())
368 std::cout <<
" a char!" << std::endl;
371 std::cout <<
" a float! " << vchannel.numElements() << std::endl;
BaseBuffer manipulate(V visitor)
void compileTimeFunctionsUsage()
void fillChannel(Channel< T > &channel, T value)
Access type index with type.
int main(int argc, const char **argv)
floatOptional getFloatAtomic(const std::string &name)
Gets an atomic float value.
iterator< U > typedBegin()
Channel< U >::Optional getOptional(const std::string &name)
UCharChannel::Optional UCharChannelOptional
VariantChannel< T... > val_type
void basicChannelUsage()
Basic Channel Usage.
iterator< U > erase(iterator< U > it)
FloatChannel::Optional FloatChannelOptional
void channelManagerUsage()
void multiChannelMapUsage()
Channel< U > & get(const std::string &name)
Gets AttributeChannel with type U from map as reference.
std::vector< std::string > keys()
Gets the available keys by a specific type.
boost::shared_array< U > dataPtr() const
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.
Channel< float >::Optional getFloatChannel(const std::string &name)
Gets a float channel and returns it as optional.
size_t numElements() const
ChannelManager class Store and access AttributeChannels. It expands the MultiChannelMap with downwoar...
size_t numChannels()
Counts the number of channels by a specific type. For total number of channels use "size()"...
static constexpr std::size_t value
Channel< T >::Optional getChannel(const std::string &name)
Gets a channel and returns it as optional.