Shapeworks Studio  2.1
Shape analysis software suite
itkPSMRegionDomain.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 __itkPSMRegionDomain_h
19 #define __itkPSMRegionDomain_h
20 
21 #include "itkDataObject.h"
22 #include "itkPSMDomain.h"
23 #include "itkPoint.h"
24 #include "itkWeakPointer.h"
25 #include "itkExceptionObject.h"
26 
27 namespace itk
28 {
32 template <unsigned int VDimension>
33 class ITK_EXPORT PSMRegionDomain : public PSMDomain<VDimension>
34 {
35 public:
38  typedef PSMDomain<VDimension> Superclass;
39  typedef SmartPointer<Self> Pointer;
40  typedef SmartPointer<const Self> ConstPointer;
41  typedef WeakPointer<const Self> ConstWeakPointer;
42 
44  itkNewMacro(Self);
45 
47  itkTypeMacro(PSMRegionDomain, PSMDomain);
48 
50  itkStaticConstMacro(Dimension, unsigned int, VDimension);
51 
54 
60  virtual bool ApplyConstraints(PointType &p) const
61  {
62  for (unsigned int i = 0; i < VDimension; i++)
63  {
64  if ( p[i] < m_LowerBound[i] || p[i] > m_UpperBound[i])
65  {
66  itkExceptionMacro(<< "Point " << p << " is outside of the specified Domain, with bounding box "
67  << m_LowerBound << " - " << m_UpperBound
68  << std::endl;);
69 
70  }
71  }
72  return false;
73  }
74 
76  itkSetMacro(LowerBound, PointType);
77  itkSetMacro(UpperBound, PointType);
78  virtual const PointType &GetUpperBound() const
79  { return m_UpperBound; }
80  virtual const PointType &GetLowerBound() const
81  { return m_LowerBound; }
82 
85  void SetRegion(const PointType &l, const PointType &u)
86  {
87  this->SetLowerBound(l);
88  this->SetUpperBound(u);
89  }
90 
91 protected:
92  PSMRegionDomain() {}
93  void PrintSelf(std::ostream& os, Indent indent) const
94  {
95  Superclass::PrintSelf(os, indent);
96  os << "LowerBound = " << m_LowerBound << std::endl;
97  os << "UpperBound = " << m_UpperBound << std::endl;
98  }
99  virtual ~PSMRegionDomain() {};
100 
101 private:
102  PSMRegionDomain(const Self&); //purposely not implemented
103  void operator=(const Self&); //purposely not implemented
104 
105  PointType m_LowerBound;
106  PointType m_UpperBound;
107 
108 };
109 
110 } // end namespace itk
111 
112 #endif
Point< double, VDimension > PointType
virtual const PointType & GetLowerBound() const
Base class for defining the domain in which a particle system exists.
Definition: itkPSMDomain.h:48
void SetRegion(const PointType &l, const PointType &u)
virtual bool ApplyConstraints(PointType &p) const