-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathGenericContainerArray.h
More file actions
76 lines (62 loc) · 2.57 KB
/
Copy pathGenericContainerArray.h
File metadata and controls
76 lines (62 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#pragma once
#include <vector>
#include "GenericContainer.h"
#include "Observer.h"
#include "itkDataObject.h"
#include "ParticleEvents.h"
#include "itkWeakPointer.h"
namespace shapeworks {
/*!
* @class GenericContainerArray
* @brief This class appears to be an array of GenericContainers (e.g. std::vector) that implements the Observer
* interface. The array size tracks the number of domains in the system. E.g. one per domain
*/
template <class T>
class GenericContainerArray : public std::vector<typename GenericContainer<T>::Pointer>, public Observer {
public:
/** Standard class typedefs */
typedef T DataType;
typedef GenericContainerArray Self;
typedef Observer Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
typedef itk::WeakPointer<const Self> ConstWeakPointer;
/** Method for creation through the object factory. */
itkNewMacro(Self);
/** Run-time type information (and related methods). */
itkTypeMacro(GenericContainerArray, Observer);
/** Callbacks that may be defined by a subclass. If a subclass defines one
of these callback methods, the corresponding flag in m_DefinedCallbacks
should be set to true so that the ParticleSystem will know to register
the appropriate event with this method. */
virtual void DomainAddEventCallback(Object*, const itk::EventObject&) {
this->resize(this->size() + 1);
this->operator[](this->size() - 1) = GenericContainer<T>::New();
}
virtual void PositionAddEventCallback(Object* o, const itk::EventObject& e) {
const ParticlePositionAddEvent& event = dynamic_cast<const ParticlePositionAddEvent&>(e);
this->operator[](event.GetDomainIndex())->operator[](event.GetPositionIndex()) = 0.0;
}
virtual void PositionRemoveEventCallback(Object*, const itk::EventObject&) {
// NEED TO IMPLEMENT THIS
}
void ZeroAllValues() {
for (unsigned d = 0; d < this->size(); d++) {
for (unsigned int i = 0; i < this->operator[](d)->GetSize(); i++) {
this->operator[](d)->operator[](i) = 0.0;
}
}
}
protected:
GenericContainerArray() {
this->m_DefinedCallbacks.DomainAddEvent = true;
this->m_DefinedCallbacks.PositionAddEvent = true;
this->m_DefinedCallbacks.PositionRemoveEvent = true;
}
virtual ~GenericContainerArray(){};
void PrintSelf(std::ostream& os, itk::Indent indent) const { Superclass::PrintSelf(os, indent); }
private:
GenericContainerArray(const Self&); // purposely not implemented
void operator=(const Self&); // purposely not implemented
};
} // namespace shapeworks