18 #ifndef __itkQuadEdgeMeshEulerOperatorsTestHelper_h
19 #define __itkQuadEdgeMeshEulerOperatorsTestHelper_h
26 template<
class TMesh >
35 typename CheckerType::Pointer check = CheckerType::New();
36 check->SetMesh( mesh );
37 check->SetExpectedNumberOfPoints( NumVertices );
38 check->SetExpectedNumberOfEdges( NumFaces );
39 check->SetExpectedNumberOfFaces( NumEdges );
40 check->SetExpectedNumberOfBoundaries( NumBorders );
41 check->SetExpectedGenus( Genus );
42 return( check->ValidateEulerCharacteristic( ) );
46 template<
class TMesh >
47 std::vector< typename TMesh::PointType >
50 typedef typename TMesh::PointType PointType;
51 typedef typename PointType::CoordRepType CoordRepType;
52 std::vector< PointType > oPt( iN * iN );
54 for(
unsigned int i = 0; i < iN; i++ )
56 for(
unsigned int j = 0; j < iN; j++ )
58 oPt[ i * iN + j ][0] =
static_cast< CoordRepType
>( j );
59 oPt[ i * iN + j ][1] =
static_cast< CoordRepType
>( i );
60 oPt[ i * iN + j ][2] =
static_cast< CoordRepType
>( 0. );
68 template<
class TMesh >
71 typedef TMesh MeshType;
72 typedef typename MeshType::CellType CellType;
76 if( mesh->GetNumberOfPoints( ) )
79 mesh->ClearFreePointAndCellIndexesLists();
83 int expectedNumPts = 25;
84 int expectedNumCells = 16;
85 int simpleSquareCells[64] =
103 typedef typename MeshType::PointType PointType;
105 std::vector< PointType > pts = GeneratePointCoordinates< MeshType >( 5 );
107 for(
int i=0; i<expectedNumPts; i++)
109 mesh->SetPoint( i, pts[i] );
112 typename CellType::CellAutoPointer cellpointer;
113 QEPolygonCellType *poly;
115 for(
int i=0; i<expectedNumCells; i++)
117 poly =
new QEPolygonCellType( 4 );
118 cellpointer.TakeOwnership( poly );
119 cellpointer->SetPointId( 0, simpleSquareCells[4*i] );
120 cellpointer->SetPointId( 1, simpleSquareCells[4*i+1] );
121 cellpointer->SetPointId( 2, simpleSquareCells[4*i+2] );
122 cellpointer->SetPointId( 3, simpleSquareCells[4*i+3] );
123 mesh->SetCell( i, cellpointer );
128 template<
class TMesh >
131 typedef TMesh MeshType;
132 typedef typename MeshType::CellType CellType;
136 if( mesh->GetNumberOfPoints( ) )
139 mesh->ClearFreePointAndCellIndexesLists();
143 int expectedNumPts = 25;
144 int expectedNumCells = 32;
145 int simpleSquareCells[96] =
179 typedef typename TMesh::PointType PointType;
180 std::vector< PointType > pts = GeneratePointCoordinates< TMesh >( 5 );
182 for(
int i=0; i<expectedNumPts; i++)
184 mesh->SetPoint( i, pts[i] );
187 typename CellType::CellAutoPointer cellpointer;
188 QEPolygonCellType *poly;
190 for(
int i=0; i<expectedNumCells; i++)
192 poly =
new QEPolygonCellType( 3 );
193 cellpointer.TakeOwnership( poly );
194 cellpointer->SetPointId( 0, simpleSquareCells[3*i] );
195 cellpointer->SetPointId( 1, simpleSquareCells[3*i+1] );
196 cellpointer->SetPointId( 2, simpleSquareCells[3*i+2] );
197 mesh->SetCell( i, cellpointer );
202 template<
class TMesh >
205 typedef TMesh MeshType;
206 typedef typename MeshType::CellType CellType;
210 if( mesh->GetNumberOfPoints( ) )
213 mesh->ClearFreePointAndCellIndexesLists();
217 int expectedNumPts = 4;
218 int expectedNumCells = 4;
219 int simpleSquareCells[12] =
225 typedef typename TMesh::PointType PointType;
226 std::vector< PointType > pts( 4 );
228 pts[i][0] = 0.; pts[i][1] = 1.; pts[i++][2] = 0.;
229 pts[i][0] = 0.; pts[i][1] = -1.; pts[i++][2] = 0.;
230 pts[i][0] = -1.; pts[i][1] = 0.; pts[i++][2] = 0.;
231 pts[i][0] = 0.; pts[i][1] = 0.; pts[i++][2] = 1.;
233 for( i=0; i<expectedNumPts; i++)
235 mesh->SetPoint( i, pts[i] );
238 typename CellType::CellAutoPointer cellpointer;
239 QEPolygonCellType *poly;
241 for( i=0; i<expectedNumCells; i++)
243 poly =
new QEPolygonCellType( 3 );
244 cellpointer.TakeOwnership( poly );
245 cellpointer->SetPointId( 0, simpleSquareCells[3*i] );
246 cellpointer->SetPointId( 1, simpleSquareCells[3*i+1] );
247 cellpointer->SetPointId( 2, simpleSquareCells[3*i+2] );
248 mesh->SetCell( i, cellpointer );
254 template<
class TMesh >
257 typedef TMesh MeshType;
258 typedef typename MeshType::CellType CellType;
262 if( mesh->GetNumberOfPoints( ) )
265 mesh->ClearFreePointAndCellIndexesLists();
269 int expectedNumPts = 3;
270 int expectedNumCells = 2;
271 int simpleSquareCells[6] =
275 typedef typename TMesh::PointType PointType;
276 std::vector< PointType > pts( 3 );
278 pts[i][0] = 0.; pts[i][1] = 1.; pts[i++][2] = 0.;
279 pts[i][0] = 0.; pts[i][1] = -1.; pts[i++][2] = 0.;
280 pts[i][0] = -1.; pts[i][1] = 0.; pts[i++][2] = 0.;
282 for( i=0; i<expectedNumPts; i++)
284 mesh->SetPoint( i, pts[i] );
287 typename CellType::CellAutoPointer cellpointer;
288 QEPolygonCellType *poly;
290 for( i=0; i<expectedNumCells; i++)
292 poly =
new QEPolygonCellType( 3 );
293 cellpointer.TakeOwnership( poly );
294 cellpointer->SetPointId( 0, simpleSquareCells[3*i] );
295 cellpointer->SetPointId( 1, simpleSquareCells[3*i+1] );
296 cellpointer->SetPointId( 2, simpleSquareCells[3*i+2] );
297 mesh->SetCell( i, cellpointer );