ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkQuadEdgeMeshMacro.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 __itkQuadEdgeMeshMacro_h
00019 #define __itkQuadEdgeMeshMacro_h
00020 
00021 namespace itk
00022 {
00024 
00047 #define itkQEMeshForAllPointsMacro(MeshType,                               \
00048                                    MeshInstance,                           \
00049                                    PointVariable,                          \
00050                                    PointIndex)                             \
00051     {                                                                      \
00052     typedef typename MeshType::PointType       PointType;                  \
00053     typedef typename MeshType::PointIdentifier PointIdentifier;            \
00054     typedef typename MeshType::PointsContainer PointsContainer;            \
00055     typedef typename MeshType::PointsContainerIterator                     \
00056     PointsContainerIterator;                                               \
00057                                                                            \
00058     PointsContainer *points = ( MeshInstance )->GetPoints();               \
00059     /* If no points container are present, do nothing */                   \
00060     if ( !points )                                                         \
00061       {                                                                    \
00062       itkWarningMacro("No point container in itkQEMeshForAllPointsMacro"); \
00063       }                                                                    \
00064     else                                                                   \
00065       {                                                                    \
00066       PointsContainerIterator pointIterator = points->Begin();             \
00067       while ( pointIterator != points->End() )                             \
00068         {                                                                  \
00069         PointType       PointVariable = pointIterator.Value();             \
00070         PointIdentifier PointIndex = pointIterator.Index();
00071 
00072 
00079 #define itkQEMeshForAllPointsEndMacro \
00080   pointIterator++;                    \
00081   }    /* while */                    \
00082   }    /* if */                       \
00083   }
00084 
00086 
00105 #define itkQEMeshForAllCellsMacro(MeshType,                                    \
00106                                   MeshInstance,                                \
00107                                   cellIterator)                                \
00108     {                                                                          \
00109     typedef typename MeshType::CellsContainer CellsContainer;                  \
00110     typedef typename MeshType::CellsContainerIterator                          \
00111     CellsContainerIterator;                                                    \
00112     /* If no cells are present, do nothing */                                  \
00113     if ( !MeshInstance->GetCells() )                                           \
00114       {                                                                        \
00115       itkWarningMacro("No Cells container in itkQEMeshForAllCellsMacro");      \
00116       }                                                                        \
00117     else                                                                       \
00118       {                                                                        \
00119       CellsContainerIterator cellIterator = MeshInstance->GetCells()->Begin(); \
00120       while ( cellIterator != MeshInstance->GetCells()->End() )                \
00121         {                                                                      \
00122         /* Users code comes here: */
00123 
00130 #define itkQEMeshForAllCellsEndMacro(cellIterator) \
00131   cellIterator++;                                  \
00132   }    /* while */                                 \
00133   }    /* if */                                    \
00134   }
00135 
00137 
00153 #define itkQEMeshForAllPrimalEdgesMacro(MeshType,                   \
00154                                         MeshInstance,               \
00155                                         EdgeVariable)               \
00156     {                                                               \
00157     typedef typename MeshType::QEPrimal QEPrimal;                   \
00158                                                                     \
00159     itkQEMeshForAllCellsMacro(MeshType, MeshInstance, cellIterator) \
00160       {                                                             \
00161       if ( QEPrimal * EdgeVariable =                                \
00162              dynamic_cast< QEPrimal * >( cellIterator.Value() ) )   \
00163         {                                                           \
00164         /* Users code comes here: */
00165 
00172 #define itkQEMeshForAllPrimalEdgesEndMacro \
00173   }     /* fi */                           \
00174   }                                        \
00175   itkQEMeshForAllCellsEndMacro             \
00176   }
00177 } // end namespace
00178 
00179 #endif
00180