ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkNormalQuadEdgeMeshFilter.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 #ifndef __itkNormalQuadEdgeMeshFilter_h
00019 #define __itkNormalQuadEdgeMeshFilter_h
00020 
00021 #include "itkQuadEdgeMeshToQuadEdgeMeshFilter.h"
00022 #include "itkQuadEdgeMeshPolygonCell.h"
00023 #include "itkTriangleHelper.h"
00024 
00025 namespace itk
00026 {
00067 template< class TInputMesh, class TOutputMesh >
00068 class ITK_EXPORT NormalQuadEdgeMeshFilter:
00069   public QuadEdgeMeshToQuadEdgeMeshFilter< TInputMesh, TOutputMesh >
00070 {
00071 public:
00072   typedef NormalQuadEdgeMeshFilter                                    Self;
00073   typedef QuadEdgeMeshToQuadEdgeMeshFilter< TInputMesh, TOutputMesh > Superclass;
00074   typedef SmartPointer< Self >                                        Pointer;
00075   typedef SmartPointer< const Self >                                  ConstPointer;
00076 
00077   itkNewMacro (Self);
00078 
00079   itkTypeMacro (NormalQuadEdgeMeshFilter,
00080                 QuadEdgeMeshToQuadEdgeMeshFilter);
00081 
00082   typedef TInputMesh                              InputMeshType;
00083   typedef typename InputMeshType::Pointer         InputMeshPointer;
00084   typedef typename InputMeshType::PointIdentifier InputPointIdentifier;
00085   typedef typename InputMeshType::PointType       InputPointType;
00086   typedef typename InputMeshType::VectorType      InputVectorType;
00087   typedef typename InputMeshType::QEType          InputQEType;
00088 
00089   typedef TOutputMesh                                          OutputMeshType;
00090   typedef typename OutputMeshType::Pointer                     OutputMeshPointer;
00091   typedef typename OutputMeshType::PointType                   OutputPointType;
00092   typedef typename OutputPointType::VectorType                 OutputVectorType;
00093   typedef typename OutputMeshType::QEType                      OutputQEType;
00094   typedef typename OutputMeshType::PointIdentifier             OutputPointIdentifier;
00095   typedef typename OutputMeshType::PointIdIterator             OutputPointIdIterator;
00096   typedef typename OutputMeshType::PointsContainerPointer      OutputPointsContainerPointer;
00097   typedef typename OutputMeshType::PointsContainerIterator     OutputPointsContainerIterator;
00098   typedef typename OutputMeshType::CellType                    OutputCellType;
00099   typedef typename OutputMeshType::CellIdentifier              OutputCellIdentifier;
00100   typedef typename OutputMeshType::CellAutoPointer             OutputCellAutoPointer;
00101   typedef typename OutputMeshType::CellsContainerConstIterator OutputCellsContainerPointer;
00102   typedef typename OutputMeshType::CellsContainerConstIterator OutputCellsContainerConstIterator;
00103 
00104   typedef TriangleHelper< OutputPointType > TriangleType;
00105 
00106   typedef QuadEdgeMeshPolygonCell< OutputCellType >   OutputPolygonType;
00107   typedef typename OutputPolygonType::SelfAutoPointer OutputPolygonAutoPointer;
00108 
00109   typedef typename OutputMeshType::CellDataContainer  OutputCellDataContainer;
00110   typedef typename OutputMeshType::PointDataContainer OutputPointDataContainer;
00111 
00112   typedef typename OutputMeshType::MeshTraits        OutputMeshTraits;
00113   typedef typename OutputMeshTraits::PixelType       OutputVertexNormalType;
00114   typedef typename OutputVertexNormalType::ValueType OutputVertexNormalComponentType;
00115 
00116   typedef typename OutputMeshTraits::CellPixelType OutputFaceNormalType;
00117   typedef typename OutputFaceNormalType::ValueType OutputFaceNormalComponentType;
00118 
00119   enum WeightType {
00120     GOURAUD = 0, // Uniform weights
00121     THURMER,     // Angle on a triangle at the given vertex
00122     AREA
00123     };
00124 
00125   itkSetMacro (Weight, WeightType);
00126   itkGetConstMacro (Weight, WeightType);
00127 protected:
00128   NormalQuadEdgeMeshFilter();
00129   ~NormalQuadEdgeMeshFilter();
00130   void PrintSelf(std::ostream & os, Indent indent) const;
00131 
00132   WeightType m_Weight;
00133 
00140   OutputFaceNormalType ComputeFaceNormal(OutputPolygonType *iPoly);
00141 
00146   void ComputeAllFaceNormals();
00147 
00152   void ComputeAllVertexNormals();
00153 
00158   OutputVertexNormalType ComputeVertexNormal(
00159     const OutputPointIdentifier & iId);
00160 
00164   OutputVertexNormalComponentType Weight(const OutputPointIdentifier & iPId,
00165                                          const OutputCellIdentifier & iCId);
00166 
00171   void GenerateData();
00172 
00173 private:
00174   NormalQuadEdgeMeshFilter (const Self &);
00175   void operator=(const Self &);
00176 };
00177 }
00178 
00179 #include "itkNormalQuadEdgeMeshFilter.hxx"
00180 #endif
00181