Shapeworks Studio  2.1
Shape analysis software suite
itkPSMDomain.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 __itkPSMDomain_h
19 #define __itkPSMDomain_h
20 
21 #include "itkDataObject.h"
22 #include "itkObjectFactory.h"
23 #include "itkPoint.h"
24 #include "itkWeakPointer.h"
25 
26 namespace itk
27 {
47 template <unsigned int VDimension>
48 class ITK_EXPORT PSMDomain : public DataObject
49 {
50 public:
52  typedef PSMDomain Self;
53  typedef DataObject Superclass;
54  typedef SmartPointer<Self> Pointer;
55  typedef SmartPointer<const Self> ConstPointer;
56  typedef WeakPointer<const Self> ConstWeakPointer;
57 
59  itkNewMacro(Self);
60 
62  itkTypeMacro(PSMDomain, DataObject);
63 
65  itkStaticConstMacro(Dimension, unsigned int, VDimension);
66 
69 
74  virtual bool ApplyConstraints(PointType &) const
75  { return false; }
76 
81  virtual double Distance(const PointType &a, const PointType &b) const
82  {
83  double sum = 0.0;
84  for (unsigned int i = 0; i < VDimension; i++)
85  {
86  sum += (b[i]-a[i]) * (b[i]-a[i]);
87  }
88  return sqrt(sum);
89  }
90 
95  virtual const PointType &GetLowerBound() const
96  {
97  itkExceptionMacro("This Domain does not define a lower bound.");
98  }
99  virtual const PointType &GetUpperBound() const
100  {
101  itkExceptionMacro("This Domain does not define an upper bound.");
102  }
103 
105  void DisableConstraints() { m_ConstraintsEnabled = false; }
106  void EnableConstraints() { m_ConstraintsEnabled = true; }
107  bool GetConstraintsEnabled() const { return m_ConstraintsEnabled; }
108  void SetConstraintsEnabled( bool g ) { m_ConstraintsEnabled = g; }
109 
110 
111 protected:
112  PSMDomain();
113  void PrintSelf(std::ostream& os, Indent indent) const;
114  virtual ~PSMDomain() {}
115 
116  bool m_ConstraintsEnabled;
117 
118 private:
119  PSMDomain(const Self&); //purposely not implemented
120  void operator=(const Self&); //purposely not implemented
121 
122 };
123 
124 } // end namespace itk
125 
126 #ifndef ITK_MANUAL_INSTANTIATION
127 #include "itkPSMDomain.hxx"
128 #endif
129 
130 #endif
Point< double, VDimension > PointType
Definition: itkPSMDomain.h:68
virtual double Distance(const PointType &a, const PointType &b) const
Definition: itkPSMDomain.h:81
PSMDomain Self
Definition: itkPSMDomain.h:52
Base class for defining the domain in which a particle system exists.
Definition: itkPSMDomain.h:48
virtual bool ApplyConstraints(PointType &) const
Definition: itkPSMDomain.h:74
virtual const PointType & GetLowerBound() const
Definition: itkPSMDomain.h:95
void DisableConstraints()
Definition: itkPSMDomain.h:105