8 #ifndef META_OCEAN_TRACKING_CORRESPONDENCE_SET_H
9 #define META_OCEAN_TRACKING_CORRESPONDENCE_SET_H
77 inline size_t size()
const;
193 explicit inline operator bool()
const;
216 template <
typename T>
222 template <
typename T>
224 correspondenceElementsSet(1, elements)
229 template <
typename T>
231 correspondenceElementsSet(1, elements)
236 template <
typename T>
238 correspondenceElementsSet(std::move(correspondenceSet.correspondenceElementsSet))
243 template <
typename T>
246 ocean_assert(isValid());
247 return correspondenceElementsSet.size();
250 template <
typename T>
253 ocean_assert(isValid());
254 return correspondenceElementsSet.empty() ? 0 : correspondenceElementsSet.front().size();
257 template <
typename T>
260 ocean_assert(isValid());
261 return correspondenceElementsSet;
264 template <
typename T>
267 ocean_assert(isValid());
268 ocean_assert(correspondenceElementsSet.empty() || correspondenceElementsSet.front().size() == elements.size());
270 if (!correspondenceElementsSet.empty() && correspondenceElementsSet.front().size() != elements.size())
273 if (correspondenceElementsSet.empty())
274 correspondenceElementsSet.push_back(elements);
276 correspondenceElementsSet.front() = elements;
281 template <
typename T>
284 ocean_assert(isValid());
285 ocean_assert(correspondenceElementsSet.empty() || correspondenceElementsSet.front().size() == elements.size());
287 if (!correspondenceElementsSet.empty() && correspondenceElementsSet.front().size() != elements.size())
290 if (correspondenceElementsSet.empty())
291 correspondenceElementsSet.push_back(elements);
293 correspondenceElementsSet.front() = elements;
298 template <
typename T>
301 ocean_assert(isValid() && !elements.empty());
303 ocean_assert(elements.size() >= validIndices.size());
311 const IndexSet32 indexSet(validIndices.begin(), validIndices.end());
314 ocean_assert(indexSet.size() == validIndices.size());
316 if (elements.size() == validIndices.size())
317 ocean_assert(*indexSet.rbegin() == validIndices.size() - 1);
320 for (Indices32::const_iterator i = validIndices.begin(); i != validIndices.end(); ++i)
321 ocean_assert(*i < elements.size());
326 if (elements.size() == validIndices.size())
328 if (correspondenceElementsSet.empty())
329 correspondenceElementsSet.push_back(elements);
331 correspondenceElementsSet.front() = elements;
335 for (
typename ElementsVector::iterator i = correspondenceElementsSet.begin(); i != correspondenceElementsSet.end(); ++i)
338 if (correspondenceElementsSet.empty())
339 correspondenceElementsSet.push_back(std::move(
Subset::subset(elements, validIndices)));
341 correspondenceElementsSet.front() = std::move(
Subset::subset(elements, validIndices));
347 template <
typename T>
350 ocean_assert(isValid());
351 ocean_assert(correspondenceElementsSet.empty() || correspondenceElementsSet.front().size() == elements.size());
353 if (!correspondenceElementsSet.empty() && correspondenceElementsSet.front().size() != elements.size())
356 if (correspondenceElementsSet.empty())
357 correspondenceElementsSet.push_back(elements);
359 correspondenceElementsSet.back() = elements;
364 template <
typename T>
367 ocean_assert(isValid());
368 ocean_assert(correspondenceElementsSet.empty() || correspondenceElementsSet.front().size() == elements.size());
370 if (!correspondenceElementsSet.empty() && correspondenceElementsSet.front().size() != elements.size())
373 if (correspondenceElementsSet.empty())
374 correspondenceElementsSet.push_back(elements);
376 correspondenceElementsSet.back() = elements;
381 template <
typename T>
384 ocean_assert(isValid() && !elements.empty());
386 ocean_assert(elements.size() >= validIndices.size());
394 const IndexSet32 indexSet(validIndices.begin(), validIndices.end());
397 ocean_assert(indexSet.size() == validIndices.size());
399 if (elements.size() == validIndices.size())
400 ocean_assert(*indexSet.rbegin() == validIndices.size() - 1);
403 for (Indices32::const_iterator i = validIndices.begin(); i != validIndices.end(); ++i)
404 ocean_assert(*i < elements.size());
409 if (elements.size() == validIndices.size())
411 if (correspondenceElementsSet.empty())
412 correspondenceElementsSet.push_back(elements);
414 correspondenceElementsSet.back() = elements;
418 for (
typename ElementsVector::iterator i = correspondenceElementsSet.begin(); i != correspondenceElementsSet.end(); ++i)
421 if (correspondenceElementsSet.empty())
422 correspondenceElementsSet.push_back(std::move(
Subset::subset(elements, validIndices)));
424 correspondenceElementsSet.back() = std::move(
Subset::subset(elements, validIndices));
430 template <
typename T>
433 ocean_assert(isValid());
434 ocean_assert(correspondenceElementsSet.empty() || correspondenceElementsSet.front().size() == elements.size());
436 if (!correspondenceElementsSet.empty() && correspondenceElementsSet.front().size() != elements.size())
439 correspondenceElementsSet.push_back(elements);
444 template <
typename T>
447 ocean_assert(isValid());
448 ocean_assert(correspondenceElementsSet.empty() || correspondenceElementsSet.front().size() == elements.size());
450 if (!correspondenceElementsSet.empty() && correspondenceElementsSet.front().size() != elements.size())
453 correspondenceElementsSet.push_back(elements);
458 template <
typename T>
461 ocean_assert(isValid() && !elements.empty());
463 ocean_assert(elements.size() >= validIndices.size());
471 const IndexSet32 indexSet(validIndices.begin(), validIndices.end());
474 ocean_assert(indexSet.size() == validIndices.size());
476 if (elements.size() == validIndices.size())
477 ocean_assert(*indexSet.rbegin() == validIndices.size() - 1);
480 for (Indices32::const_iterator i = validIndices.begin(); i != validIndices.end(); ++i)
481 ocean_assert(*i < elements.size());
486 if (elements.size() == validIndices.size())
487 correspondenceElementsSet.push_back(elements);
490 for (
typename ElementsVector::iterator i = correspondenceElementsSet.begin(); i != correspondenceElementsSet.end(); ++i)
493 correspondenceElementsSet.push_back(std::move(
Subset::subset(elements, validIndices)));
499 template <
typename T>
502 ocean_assert(isValid());
504 ocean_assert(elements() >= validIndices.size());
506 if (elements() < validIndices.size())
511 const IndexSet32 indexSet(validIndices.begin(), validIndices.end());
514 ocean_assert(indexSet.size() == validIndices.size());
516 if (elements() == validIndices.size())
517 ocean_assert(*indexSet.rbegin() == validIndices.size() - 1);
520 for (Indices32::const_iterator i = validIndices.begin(); i != validIndices.end(); ++i)
521 ocean_assert(*i < elements());
526 if (elements() != validIndices.size())
528 for (
typename ElementsVector::iterator i = correspondenceElementsSet.begin(); i != correspondenceElementsSet.end(); ++i)
535 template <
typename T>
538 ocean_assert(isValid());
539 return correspondenceElementsSet.empty();
542 template <
typename T>
545 ocean_assert(isValid());
546 return !correspondenceElementsSet.empty();
549 template <
typename T>
552 for (
size_t n = 1; n < correspondenceElementsSet.size(); ++n)
553 if (correspondenceElementsSet[0].size() != correspondenceElementsSet[n].size())
559 template <
typename T>
562 ocean_assert(isValid() && right.isValid());
565 correspondenceElementsSet = std::move(right.correspondenceElementsSet);
static std::vector< T > subset(const std::vector< T > &objects, const std::vector< TIndex > &indices)
Extracts a subset of a given set of objects by usage of an index vector holding the indices of all ob...
Definition: Subset.h:751
This class manages a set of element correspondences.
Definition: CorrespondenceSet.h:30
bool addElements(const Elements &elements, const Indices32 &validIndices)
Adds a new subset of elements that corresponds to a subset of the stored sets of elements.
Definition: CorrespondenceSet.h:459
CorrespondenceSet(Elements &&elements)
Creates new object by adding the first elements.
Definition: CorrespondenceSet.h:230
bool isEmpty() const
Returns whether this object does not hold any set of elements.
Definition: CorrespondenceSet.h:536
T Type
Defines the data type of the individual elements.
Definition: CorrespondenceSet.h:36
bool setFirstElements(Elements &&elements)
Changes (or sets) the first set of elements.
Definition: CorrespondenceSet.h:282
size_t elements() const
Returns the number of corresponding elements.
Definition: CorrespondenceSet.h:251
CorrespondenceSet(CorrespondenceSet< T > &&correspondenceSet) noexcept
Move constructor.
Definition: CorrespondenceSet.h:237
bool isValid() const
Returns whether this object stores sets of elements with same number of elements.
Definition: CorrespondenceSet.h:550
CorrespondenceSet< T > & operator=(CorrespondenceSet< T > &&right) noexcept
Move operator.
Definition: CorrespondenceSet.h:560
bool setLastElements(Elements &&elements)
Changes (or sets) the last set of elements.
Definition: CorrespondenceSet.h:365
bool reduce(const Indices32 &validIndices)
Reduces the elements within each set of corresponding elements.
Definition: CorrespondenceSet.h:500
CorrespondenceSet(const Elements &elements)
Creates new object by adding the first elements.
Definition: CorrespondenceSet.h:223
bool setFirstElements(const Elements &elements)
Changes (or sets) the first set of elements.
Definition: CorrespondenceSet.h:265
std::vector< T > Elements
This class defines a vector storing individual elements.
Definition: CorrespondenceSet.h:41
std::vector< Elements > ElementsVector
This class defines a vector storing vectors of elements.
Definition: CorrespondenceSet.h:46
bool setLastElements(const Elements &elements)
Changes (or sets) the last set of elements.
Definition: CorrespondenceSet.h:348
CorrespondenceSet()
Creates an empty object.
Definition: CorrespondenceSet.h:217
bool setFirstElements(const Elements &elements, const Indices32 &validIndices)
Changes (or sets) the first set of elements.
Definition: CorrespondenceSet.h:299
bool addElements(Elements &&elements)
Adds a new set of elements that corresponds to the stored sets of elements.
Definition: CorrespondenceSet.h:445
ElementsVector correspondenceElementsSet
The set of corresponding elements.
Definition: CorrespondenceSet.h:213
size_t size() const
Returns the number of correspondences.
Definition: CorrespondenceSet.h:244
bool setLastElements(const Elements &elements, const Indices32 &validIndices)
Changes (or sets) the last set of elements.
Definition: CorrespondenceSet.h:382
bool addElements(const Elements &elements)
Adds a new set of elements that corresponds to the stored sets of elements.
Definition: CorrespondenceSet.h:431
const ElementsVector & correspondences() const
Returns the set of stored correspondences.
Definition: CorrespondenceSet.h:258
std::set< Index32 > IndexSet32
Definition of a set holding 32 bit indices.
Definition: Base.h:114
std::vector< Index32 > Indices32
Definition of a vector holding 32 bit index values.
Definition: Base.h:96
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15