ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkBoundingBox.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 /*=========================================================================
00019  *
00020  *  Portions of this file are subject to the VTK Toolkit Version 3 copyright.
00021  *
00022  *  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00023  *
00024  *  For complete copyright, license and disclaimer of warranty information
00025  *  please refer to the NOTICE file at the top of the ITK source tree.
00026  *
00027  *=========================================================================*/
00028 #ifndef __itkBoundingBox_h
00029 #define __itkBoundingBox_h
00030 
00031 #include "itkPoint.h"
00032 #include "itkVectorContainer.h"
00033 #include "itkIntTypes.h"
00034 
00035 namespace itk
00036 {
00070 template<
00071   typename TPointIdentifier = IdentifierType,
00072   int VPointDimension = 3,
00073   typename TCoordRep = float,
00074   typename TPointsContainer =
00075     VectorContainer< TPointIdentifier, Point< TCoordRep, VPointDimension > >
00076   >
00077 class ITK_EXPORT BoundingBox:public Object
00078 {
00079 public:
00081   typedef BoundingBox                Self;
00082   typedef Object                     Superclass;
00083   typedef SmartPointer< Self >       Pointer;
00084   typedef SmartPointer< const Self > ConstPointer;
00085 
00087   itkTypeMacro(BoundingBox, Object);
00088 
00090   itkNewMacro(Self);
00091 
00093   typedef TPointIdentifier                       PointIdentifier;
00094   typedef TCoordRep                              CoordRepType;
00095   typedef TPointsContainer                       PointsContainer;
00096   typedef typename PointsContainer::Pointer      PointsContainerPointer;
00097   typedef typename PointsContainer::ConstPointer PointsContainerConstPointer;
00098 
00099   typedef Point< CoordRepType, VPointDimension >         PointType;
00100   typedef FixedArray< CoordRepType, VPointDimension *2 > BoundsArrayType;
00101 
00103   itkStaticConstMacro(PointDimension, unsigned int,  VPointDimension);
00104 
00106   typedef typename PointsContainer::ConstIterator PointsContainerConstIterator;
00107   typedef typename PointsContainer::Iterator      PointsContainerIterator;
00108 
00112   void SetPoints(const PointsContainer *);
00113 
00114   const PointsContainer * GetPoints(void) const;
00115 
00117   const PointsContainer * GetCorners(void);
00118 
00120   bool ComputeBoundingBox(void) const;
00121 
00127   itkGetConstReferenceMacro(Bounds, BoundsArrayType);
00128 
00131   PointType GetCenter(void) const;
00132 
00135   PointType GetMinimum(void) const;
00136 
00140   void      SetMinimum(const PointType &);
00141 
00144   PointType GetMaximum(void) const;
00145 
00149   void      SetMaximum(const PointType &);
00150 
00155   void ConsiderPoint(const PointType &);
00156 
00160   typedef typename NumericTraits< CoordRepType >::AccumulateType AccumulateType;
00161   AccumulateType GetDiagonalLength2(void) const;
00162 
00164   bool IsInside(const PointType &) const;
00165 
00167   unsigned long GetMTime(void) const;
00168 
00170   Pointer DeepCopy() const;
00171 
00172 #if 0
00173 
00187   bool IntersectWithLine(CoordRepType origin[PointDimension],
00188                          CoordRepType direction[PointDimension],
00189                          CoordRepType coords[PointDimension],
00190                          CoordRepType *t);
00191 
00192 #endif
00193 protected:
00194   BoundingBox();
00195   virtual ~BoundingBox();
00196   void PrintSelf(std::ostream & os, Indent indent) const;
00197 
00198   typedef typename PointsContainer::ConstIterator ConstIterator;
00199 private:
00200   BoundingBox(const Self &);    //purposely not implemented
00201   void operator=(const Self &); //purposely not implemented
00202 
00203   PointsContainerConstPointer m_PointsContainer;
00204   PointsContainerPointer      m_CornersContainer;
00205   mutable BoundsArrayType     m_Bounds;
00206   mutable TimeStamp           m_BoundsMTime; // The last time the bounds
00207                                              // were computed.
00208 };
00209 } // end namespace itk
00210 
00211 #ifndef ITK_MANUAL_INSTANTIATION
00212 #include "itkBoundingBox.hxx"
00213 #endif
00214 
00215 #endif
00216