Shapeworks Studio  2.1
Shape analysis software suite
itkPSMContainerArrayAttribute.h
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkPSMContainerArrayAttribute_h
19 #define __itkPSMContainerArrayAttribute_h
20 
21 #include "itkDataObject.h"
22 #include "itkWeakPointer.h"
23 #include "itkPSMAttribute.h"
24 #include "itkPSMContainer.h"
25 #include <vector>
26 
27 namespace itk
28 {
34 template <class T, unsigned int VDimension>
36  : public std::vector<typename PSMContainer<T>::Pointer >,
37  public PSMAttribute<VDimension>
38 {
39 public:
41  typedef T DataType;
43  typedef PSMAttribute<VDimension> Superclass;
44  typedef SmartPointer<Self> Pointer;
45  typedef SmartPointer<const Self> ConstPointer;
46  typedef WeakPointer<const Self> ConstWeakPointer;
47 
49  itkNewMacro(Self);
50 
53 
58  virtual void DomainAddEventCallback(Object *, const EventObject &)
59  {
60  this->resize( this->size() +1);
61  this->operator[](this->size() -1) = PSMContainer<T>::New();
62  }
63 
64  virtual void PositionAddEventCallback(Object *, const EventObject &e)
65  {
66  const itk::ParticlePositionAddEvent &event
67  = dynamic_cast<const itk::ParticlePositionAddEvent &>(e);
68  this->operator[](event.GetDomainIndex())->operator[](event.GetPositionIndex()) = 0.0;
69  }
70 
71  virtual void PositionRemoveEventCallback(Object *, const EventObject &)
72  {
73  itkExceptionMacro("This class does note support removal of particles positions.");
74  }
75 
76  void ZeroAllValues()
77  {
78  for (unsigned d = 0; d < this->size(); d++)
79  {
80  for (unsigned int i = 0; i < this->operator[](d)->GetSize(); i++)
81  {
82  this->operator[](d)->operator[](i) = 0.0;
83  }
84 
85  }
86  }
87 
88  protected:
90  {
91  this->m_DefinedCallbacks.DomainAddEvent = true;
92  this->m_DefinedCallbacks.PositionAddEvent = true;
93  this->m_DefinedCallbacks.PositionRemoveEvent = true;
94  }
95  virtual ~PSMContainerArrayAttribute() {};
96 
97  void PrintSelf(std::ostream& os, Indent indent) const
98  { Superclass::PrintSelf(os,indent); }
99 
100  private:
101  PSMContainerArrayAttribute(const Self&); //purposely not implemented
102  void operator=(const Self&); //purposely not implemented
103 
104 };
105 
106 } // end namespace
107 
108 #endif
Base class for PSMParticleSystem attribute classes.
virtual void DomainAddEventCallback(Object *, const EventObject &)
A container class that holds particle position information for the PSMParticleSystem class...