itkQuadEdgeMeshToQuadEdgeMeshFilter.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __itkQuadEdgeMeshToQuadEdgeMeshFilter_h
00019 #define __itkQuadEdgeMeshToQuadEdgeMeshFilter_h
00020
00021 #include "itkMeshToMeshFilter.h"
00022
00023 namespace itk
00024 {
00034 template< typename TInputMesh, typename TOutputMesh >
00035 class QuadEdgeMeshToQuadEdgeMeshFilter
00036 : public MeshToMeshFilter< TInputMesh, TOutputMesh >
00037 {
00038 public:
00040 typedef QuadEdgeMeshToQuadEdgeMeshFilter Self;
00041 typedef MeshToMeshFilter< TInputMesh, TOutputMesh > Superclass;
00042 typedef SmartPointer< Self > Pointer;
00043 typedef SmartPointer< const Self > ConstPointer;
00044
00046 typedef TInputMesh InputMeshType;
00047 typedef typename InputMeshType::Pointer InputMeshPointer;
00048 typedef typename InputMeshType::ConstPointer InputMeshConstPointer;
00049 typedef typename InputMeshType::CoordRepType InputCoordRepType;
00050 typedef typename InputMeshType::PointType InputPointType;
00051 typedef typename InputMeshType::PointIdentifier InputPointIdentifier;
00052 typedef typename InputMeshType::QEPrimal InputQEPrimal;
00053 typedef typename InputMeshType::VectorType InputVectorType;
00054
00055 typedef typename InputMeshType::PointDataContainer InputPointDataContainer;
00056 typedef typename InputMeshType::CellDataContainer InputCellDataContainer;
00057
00058 typedef typename InputPointDataContainer::ConstPointer
00059 InputPointDataContainerConstPointer;
00060 typedef typename InputMeshType::PointsContainerConstIterator
00061 InputPointsContainerConstIterator;
00062 typedef typename InputMeshType::PointsContainerConstPointer
00063 InputPointsContainerConstPointer;
00064 typedef typename InputMeshType::CellsContainerConstIterator
00065 InputCellsContainerConstIterator;
00066 typedef typename InputMeshType::CellsContainerConstPointer
00067 InputCellsContainerConstPointer;
00068
00069 typedef typename InputMeshType::EdgeCellType InputEdgeCellType;
00070 typedef typename InputMeshType::PolygonCellType InputPolygonCellType;
00071 typedef typename InputMeshType::PointIdList InputPointIdList;
00072 typedef typename InputMeshType::CellTraits InputCellTraits;
00073 typedef typename InputCellTraits::PointIdInternalIterator
00074 InputPointsIdInternalIterator;
00075
00076 typedef typename InputQEPrimal::IteratorGeom InputQEIterator;
00077
00079 typedef TOutputMesh OutputMeshType;
00080 typedef typename OutputMeshType::Pointer OutputMeshPointer;
00081 typedef typename OutputMeshType::ConstPointer OutputMeshConstPointer;
00082 typedef typename OutputMeshType::CoordRepType OutputCoordRepType;
00083 typedef typename OutputMeshType::PointType OutputPointType;
00084 typedef typename OutputMeshType::PointIdentifier OutputPointIdentifier;
00085 typedef typename OutputMeshType::QEPrimal OutputQEPrimal;
00086 typedef typename OutputMeshType::VectorType OutputVectorType;
00087 typedef typename OutputQEPrimal::IteratorGeom OutputQEIterator;
00088 typedef typename OutputMeshType::PointsContainerIterator
00089 OutputPointsContainerIterator;
00090 typedef typename OutputMeshType::PointsContainerPointer
00091 OutputPointsContainerPointer;
00092 typedef typename OutputMeshType::PointsContainerConstPointer
00093 OutputPointsContainerConstPointer;
00094
00095 typedef typename OutputMeshType::PointDataContainer OutputPointDataContainer;
00096 typedef typename OutputMeshType::CellDataContainer OutputCellDataContainer;
00097
00098 public:
00099 itkNewMacro( Self );
00100 itkTypeMacro( QuadEdgeMeshToQuadEdgeMeshFilter, MeshToMeshFilter );
00101
00102 protected:
00103 QuadEdgeMeshToQuadEdgeMeshFilter();
00104 virtual ~QuadEdgeMeshToQuadEdgeMeshFilter() { }
00105
00106 virtual void CopyMeshToMesh(const TInputMesh * in, TOutputMesh * out);
00107 virtual void CopyInputMeshToOutputMesh();
00108 virtual void CopyInputMeshToOutputMeshGeometry();
00109 virtual void CopyInputMeshToOutputMeshPoints();
00110 virtual void CopyInputMeshToOutputMeshCells();
00111 virtual void CopyInputMeshToOutputMeshEdgeCells();
00112 virtual void CopyInputMeshToOutputMeshFieldData();
00113 virtual void CopyInputMeshToOutputMeshPointData();
00114 virtual void CopyInputMeshToOutputMeshCellData();
00115
00116 private:
00117 QuadEdgeMeshToQuadEdgeMeshFilter( const Self& );
00118 void operator=( const Self& );
00119 };
00120
00121
00122
00123
00124
00125
00126
00127
00128 template< class TInputMesh, class TOutputMesh >
00129 void CopyMeshToMeshCellData( const TInputMesh * in, TOutputMesh * out )
00130 {
00131
00132 typedef typename TInputMesh::CellDataContainer InputCellDataContainer;
00133 typedef typename TOutputMesh::CellDataContainer OutputCellDataContainer;
00134 typedef typename InputCellDataContainer::ConstPointer InputCellDataContainerConstPointer;
00135 typedef typename OutputCellDataContainer::Pointer OutputCellDataContainerPointer;
00136
00137 InputCellDataContainerConstPointer inputCellData = in->GetCellData();
00138
00139 if( inputCellData.IsNull() )
00140 {
00141
00142 return;
00143 }
00144
00145 OutputCellDataContainerPointer outputCellData = OutputCellDataContainer::New();
00146 outputCellData->Reserve( inputCellData->Size() );
00147
00148
00149 typedef typename InputCellDataContainer::ConstIterator InputCellDataContainerConstIterator;
00150 InputCellDataContainerConstIterator inIt = inputCellData->Begin();
00151 while( inIt != inputCellData->End() )
00152 {
00153 outputCellData->SetElement( inIt.Index(), inIt.Value() );
00154 inIt++;
00155 }
00156
00157 out->SetCellData( outputCellData );
00158 }
00159
00160
00161
00162 template< class TInputMesh, class TOutputMesh >
00163 void CopyMeshToMeshPointData( const TInputMesh * in, TOutputMesh * out )
00164 {
00165
00166 typedef typename TOutputMesh::PointDataContainer OutputPointDataContainer;
00167 typedef typename OutputPointDataContainer::Pointer OutputPointDataContainerPointer;
00168 typedef typename TInputMesh::PointDataContainer InputPointDataContainer;
00169
00170 const InputPointDataContainer * inputPointData = in->GetPointData();
00171
00172 if( inputPointData == NULL )
00173 {
00174
00175 return;
00176 }
00177
00178 OutputPointDataContainerPointer outputPointData = OutputPointDataContainer::New();
00179 outputPointData->Reserve( inputPointData->Size() );
00180
00181
00182 typedef typename InputPointDataContainer::ConstIterator InputPointDataContainerConstIterator;
00183 InputPointDataContainerConstIterator inIt = inputPointData->Begin();
00184 while( inIt != inputPointData->End() )
00185 {
00186 outputPointData->SetElement( inIt.Index(), inIt.Value() );
00187 inIt++;
00188 }
00189
00190 out->SetPointData( outputPointData );
00191 }
00192
00193
00194
00195 template< class TInputMesh, class TOutputMesh >
00196 void CopyMeshToMeshCells( const TInputMesh * in, TOutputMesh * out )
00197 {
00198
00199 typedef typename TInputMesh::CellsContainer InputCellsContainer;
00200 typedef typename InputCellsContainer::ConstPointer InputCellsContainerConstPointer;
00201 typedef typename InputCellsContainer::ConstIterator InputCellsContainerConstIterator;
00202 typedef typename TInputMesh::PolygonCellType InputPolygonCellType;
00203 typedef typename TInputMesh::PointIdList InputPointIdList;
00204 typedef typename TInputMesh::CellTraits InputCellTraits;
00205 typedef typename InputCellTraits::PointIdInternalIterator
00206 InputPointsIdInternalIterator;
00207
00208 out->SetCellsAllocationMethod( TOutputMesh::CellsAllocatedDynamicallyCellByCell );
00209
00210 InputCellsContainerConstPointer inCells = in->GetCells();
00211
00212 if( inCells )
00213 {
00214 InputCellsContainerConstIterator cIt = inCells->Begin();
00215 while( cIt != inCells->End() )
00216 {
00217 InputPolygonCellType * pe = dynamic_cast< InputPolygonCellType* >( cIt.Value());
00218 if( pe )
00219 {
00220 InputPointIdList points;
00221 InputPointsIdInternalIterator pit = pe->InternalPointIdsBegin();
00222 while( pit != pe->InternalPointIdsEnd( ) )
00223 {
00224 points.push_back( ( *pit ) );
00225 ++pit;
00226 }
00227 out->AddFaceWithSecurePointList( points, false );
00228 }
00229 cIt++;
00230 }
00231 }
00232 }
00233
00234
00235
00236 template< class TInputMesh, class TOutputMesh >
00237 void CopyMeshToMeshEdgeCells( const TInputMesh * in, TOutputMesh * out )
00238 {
00239
00240 typedef typename TInputMesh::CellsContainer InputCellsContainer;
00241 typedef typename InputCellsContainer::ConstPointer InputCellsContainerConstPointer;
00242 typedef typename InputCellsContainer::ConstIterator InputCellsContainerConstIterator;
00243 typedef typename TInputMesh::EdgeCellType InputEdgeCellType;
00244
00245 InputCellsContainerConstPointer inEdgeCells = in->GetEdgeCells();
00246
00247 if( inEdgeCells )
00248 {
00249 InputCellsContainerConstIterator ecIt = inEdgeCells->Begin();
00250 while( ecIt != inEdgeCells->End() )
00251 {
00252 InputEdgeCellType* pe = dynamic_cast< InputEdgeCellType* >( ecIt.Value());
00253 if( pe )
00254 {
00255 out->AddEdgeWithSecurePointList( pe->GetQEGeom()->GetOrigin(),
00256 pe->GetQEGeom()->GetDestination() );
00257 }
00258 ecIt++;
00259 }
00260 }
00261 }
00262
00263
00264
00265 template< class TInputMesh, class TOutputMesh >
00266 void CopyMeshToMeshPoints( const TInputMesh * in, TOutputMesh * out )
00267 {
00268
00269 typedef typename TInputMesh::PointsContainer InputPointsContainer;
00270 typedef typename InputPointsContainer::ConstPointer InputPointsContainerConstPointer;
00271 typedef typename InputPointsContainer::ConstIterator InputPointsContainerConstIterator;
00272 typedef typename TOutputMesh::PointType OutputPointType;
00273
00274 InputPointsContainerConstPointer inPoints = in->GetPoints();
00275
00276 if( inPoints )
00277 {
00278 InputPointsContainerConstIterator inIt = inPoints->Begin();
00279 OutputPointType pOut;
00280
00281 while( inIt != inPoints->End() )
00282 {
00283 pOut.CastFrom( inIt.Value() );
00284 out->SetPoint( inIt.Index(), pOut );
00285 inIt++;
00286 }
00287 }
00288 }
00289
00290
00291 }
00292
00293 #ifndef ITK_MANUAL_INSTANTIATION
00294 #include "itkQuadEdgeMeshToQuadEdgeMeshFilter.txx"
00295 #endif
00296
00297 #endif
00298