17 #ifndef __itkAutomaticTopologyMeshSource_txx
18 #define __itkAutomaticTopologyMeshSource_txx
25 #include "itkNumericTraits.h"
31 template<
class TOutputMesh>
35 m_OutputMesh = TOutputMesh::New();
40 this->ReleaseDataBeforeUpdateFlagOff();
43 template<
class TOutputMesh>
49 template<
class TOutputMesh>
57 if( pointIDPlusOne != 0 )
59 pointID = pointIDPlusOne - 1;
63 pointID = nextNewPointID;
64 pointIDPlusOne = pointID + 1;
65 m_OutputMesh->SetPoint( pointID, p0 );
70 template<
class TOutputMesh>
77 for( i = 0; i < PointDimension; i++ )
79 newPoint[ i ] = p0[ i ];
81 return AddPoint( newPoint );
84 template<
class TOutputMesh>
93 unsigned int end = ( PointDimension < 6 ? PointDimension : 6 );
94 for( i = 0; i < end; i++ )
96 newPoint[ i ] = p0[ i ];
98 for(; i < PointDimension; i++ )
102 return AddPoint( newPoint );
105 template<
class TOutputMesh>
117 if( *cellIDPlusOne != 0 )
119 cellID = *cellIDPlusOne - 1;
125 cellID = m_OutputMesh->GetNumberOfCells();
126 *cellIDPlusOne = cellID + 1;
130 newCell->SetPointId( 0, pointIDs[0] );
133 m_OutputMesh->SetCell( cellID, newCell );
135 m_OutputMesh->SetBoundaryAssignment( 0, cellID, 0, cellID );
141 template<
class TOutputMesh>
151 if( *cellIDPlusOne != 0 )
153 cellID = *cellIDPlusOne - 1;
165 for( i = 0; i < pointIdsEnd; i++ )
168 vertexArray[i] = AddVertex( pointID );
169 newCell->SetPointId( i, pointID );
173 cellID = m_OutputMesh->GetNumberOfCells();
174 *cellIDPlusOne = cellID + 1;
177 m_OutputMesh->SetCell( cellID, newCell );
181 for( i = 0; i < pointIdsEnd; i++ )
184 m_OutputMesh->SetBoundaryAssignment( 0, cellID, i, boundaryID );
192 template<
class TOutputMesh>
202 if( *cellIDPlusOne != 0 )
204 cellID = *cellIDPlusOne - 1;
220 for( i = 0; i < pointIdsEnd; i++ )
223 vertexArray[i] = AddVertex( pointID );
224 newCell->SetPointId( i, pointID );
229 for( i = 0; i < lineIdsEnd; i++ )
231 lineArray[i] = AddLine( pointIDs[i], pointIDs[ (i+1) % pointIdsEnd ] );
235 cellID = m_OutputMesh->GetNumberOfCells();
236 *cellIDPlusOne = cellID + 1;
239 m_OutputMesh->SetCell( cellID, newCell );
243 for( i = 0; i < pointIdsEnd; i++ )
245 m_OutputMesh->SetBoundaryAssignment( 0, cellID, i, vertexArray[i] );
248 for( i = 0; i < lineIdsEnd; i++ )
250 m_OutputMesh->SetBoundaryAssignment( 1, cellID, i, lineArray[i] );
258 template<
class TOutputMesh>
268 if( *cellIDPlusOne != 0 )
270 cellID = *cellIDPlusOne - 1;
286 for( i = 0; i < pointIdsEnd; i++ )
289 vertexArray[i] = AddVertex( pointID );
290 newCell->SetPointId( i, pointID );
295 lineArray[0] = AddLine( pointIDs[0], pointIDs[1] );
296 lineArray[1] = AddLine( pointIDs[2], pointIDs[3] );
297 lineArray[2] = AddLine( pointIDs[0], pointIDs[2] );
298 lineArray[3] = AddLine( pointIDs[1], pointIDs[3] );
301 cellID = m_OutputMesh->GetNumberOfCells();
302 *cellIDPlusOne = cellID + 1;
305 m_OutputMesh->SetCell( cellID, newCell );
309 for( i = 0; i < pointIdsEnd; i++ )
311 m_OutputMesh->SetBoundaryAssignment( 0, cellID, i, vertexArray[i] );
314 for( i = 0; i < lineIdsEnd; i++ )
316 m_OutputMesh->SetBoundaryAssignment( 1, cellID, i, lineArray[i] );
323 template<
class TOutputMesh>
333 if( *cellIDPlusOne != 0 )
335 cellID = *cellIDPlusOne - 1;
352 for( i = 0; i < pointIdsEnd; i++ )
355 vertexArray[i] = AddVertex( pointID );
356 newCell->SetPointId( i, pointID );
361 lineArray[0] = AddLine( pointIDs[0], pointIDs[1] );
362 lineArray[1] = AddLine( pointIDs[0], pointIDs[2] );
363 lineArray[2] = AddLine( pointIDs[0], pointIDs[3] );
364 lineArray[3] = AddLine( pointIDs[1], pointIDs[2] );
365 lineArray[4] = AddLine( pointIDs[1], pointIDs[3] );
366 lineArray[5] = AddLine( pointIDs[2], pointIDs[3] );
370 faceArray[0] = AddTriangle( pointIDs[0], pointIDs[1], pointIDs[2] );
371 faceArray[1] = AddTriangle( pointIDs[0], pointIDs[1], pointIDs[3] );
372 faceArray[2] = AddTriangle( pointIDs[0], pointIDs[2], pointIDs[3] );
373 faceArray[3] = AddTriangle( pointIDs[1], pointIDs[2], pointIDs[3] );
376 cellID = m_OutputMesh->GetNumberOfCells();
377 *cellIDPlusOne = cellID + 1;
380 m_OutputMesh->SetCell( cellID, newCell );
384 for( i = 0; i < pointIdsEnd; i++ )
386 m_OutputMesh->SetBoundaryAssignment( 0, cellID, i, vertexArray[i] );
389 for( i = 0; i < lineIdsEnd; i++ )
391 m_OutputMesh->SetBoundaryAssignment( 1, cellID, i, lineArray[i] );
394 for( i = 0; i < faceIdsEnd; i++ )
396 m_OutputMesh->SetBoundaryAssignment( 2, cellID, i, faceArray[i] );
404 template<
class TOutputMesh>
414 if( *cellIDPlusOne != 0 )
416 cellID = *cellIDPlusOne - 1;
433 for( i = 0; i < pointIdsEnd; i++ )
436 vertexArray[i] = AddVertex( pointID );
437 newCell->SetPointId( i, pointID );
442 lineArray[0] = AddLine( pointIDs[0], pointIDs[1] );
443 lineArray[1] = AddLine( pointIDs[2], pointIDs[3] );
444 lineArray[2] = AddLine( pointIDs[4], pointIDs[5] );
445 lineArray[3] = AddLine( pointIDs[6], pointIDs[7] );
446 lineArray[4] = AddLine( pointIDs[0], pointIDs[2] );
447 lineArray[5] = AddLine( pointIDs[1], pointIDs[3] );
448 lineArray[6] = AddLine( pointIDs[4], pointIDs[6] );
449 lineArray[7] = AddLine( pointIDs[5], pointIDs[7] );
450 lineArray[8] = AddLine( pointIDs[0], pointIDs[4] );
451 lineArray[9] = AddLine( pointIDs[1], pointIDs[5] );
452 lineArray[10] = AddLine( pointIDs[2], pointIDs[6] );
453 lineArray[11] = AddLine( pointIDs[3], pointIDs[7] );
457 faceArray[0] = AddQuadrilateral( pointIDs[0], pointIDs[1], pointIDs[2], pointIDs[3] );
458 faceArray[1] = AddQuadrilateral( pointIDs[4], pointIDs[5], pointIDs[6], pointIDs[7] );
459 faceArray[2] = AddQuadrilateral( pointIDs[0], pointIDs[1], pointIDs[4], pointIDs[5] );
460 faceArray[3] = AddQuadrilateral( pointIDs[2], pointIDs[3], pointIDs[6], pointIDs[7] );
461 faceArray[4] = AddQuadrilateral( pointIDs[0], pointIDs[2], pointIDs[4], pointIDs[6] );
462 faceArray[5] = AddQuadrilateral( pointIDs[1], pointIDs[3], pointIDs[5], pointIDs[7] );
465 cellID = m_OutputMesh->GetNumberOfCells();
466 *cellIDPlusOne = cellID + 1;
469 m_OutputMesh->SetCell( cellID, newCell );
473 for( i = 0; i < pointIdsEnd; i++ )
475 m_OutputMesh->SetBoundaryAssignment( 0, cellID, i, vertexArray[i] );
478 for( i = 0; i < lineIdsEnd; i++ )
480 m_OutputMesh->SetBoundaryAssignment( 1, cellID, i, lineArray[i] );
483 for( i = 0; i < faceIdsEnd; i++ )
485 m_OutputMesh->SetBoundaryAssignment( 2, cellID, i, faceArray[i] );
493 template<
class TOutputMesh>
499 pointIDs[ 0 ] = pointId0;
500 return AddVertex( pointIDs );
503 template<
class TOutputMesh>
509 pointIDs[ 0 ] = pointId0;
510 pointIDs[ 1 ] = pointId1;
511 return AddLine( pointIDs );
514 template<
class TOutputMesh>
521 pointIDs[ 0 ] = pointId0;
522 pointIDs[ 1 ] = pointId1;
523 pointIDs[ 2 ] = pointId2;
524 return AddTriangle( pointIDs );
527 template<
class TOutputMesh>
534 pointIDs[ 0 ] = pointId0;
535 pointIDs[ 1 ] = pointId1;
536 pointIDs[ 2 ] = pointId2;
537 pointIDs[ 3 ] = pointId3;
538 return AddQuadrilateral( pointIDs );
541 template<
class TOutputMesh>
548 pointIDs[ 0 ] = pointId0;
549 pointIDs[ 1 ] = pointId1;
550 pointIDs[ 2 ] = pointId2;
551 pointIDs[ 3 ] = pointId3;
552 return AddTetrahedron( pointIDs );
555 template<
class TOutputMesh>
564 pointIDs[ 0 ] = pointId0;
565 pointIDs[ 1 ] = pointId1;
566 pointIDs[ 2 ] = pointId2;
567 pointIDs[ 3 ] = pointId3;
568 pointIDs[ 4 ] = pointId4;
569 pointIDs[ 5 ] = pointId5;
570 pointIDs[ 6 ] = pointId6;
571 pointIDs[ 7 ] = pointId7;
572 return AddHexahedron( pointIDs );
575 template<
class TOutputMesh>
581 return AddVertex( pointId );
584 template<
class TOutputMesh>
590 pointIDs[ 0 ] = AddPoint( p0 );
591 pointIDs[ 1 ] = AddPoint( p1 );
592 return AddLine( pointIDs );
595 template<
class TOutputMesh>
602 pointIDs[ 0 ] = AddPoint( p0 );
603 pointIDs[ 1 ] = AddPoint( p1 );
604 pointIDs[ 2 ] = AddPoint( p2 );
605 return AddTriangle( pointIDs );
608 template<
class TOutputMesh>
615 pointIDs[ 0 ] = AddPoint( p0 );
616 pointIDs[ 1 ] = AddPoint( p1 );
617 pointIDs[ 2 ] = AddPoint( p2 );
618 pointIDs[ 3 ] = AddPoint( p3 );
619 return AddQuadrilateral( pointIDs );
622 template<
class TOutputMesh>
629 pointIDs[ 0 ] = AddPoint( p0 );
630 pointIDs[ 1 ] = AddPoint( p1 );
631 pointIDs[ 2 ] = AddPoint( p2 );
632 pointIDs[ 3 ] = AddPoint( p3 );
633 return AddTetrahedron( pointIDs );
636 template<
class TOutputMesh>
645 pointIDs[ 0 ] = AddPoint( p0 );
646 pointIDs[ 1 ] = AddPoint( p1 );
647 pointIDs[ 2 ] = AddPoint( p2 );
648 pointIDs[ 3 ] = AddPoint( p3 );
649 pointIDs[ 4 ] = AddPoint( p4 );
650 pointIDs[ 5 ] = AddPoint( p5 );
651 pointIDs[ 6 ] = AddPoint( p6 );
652 pointIDs[ 7 ] = AddPoint( p7 );
653 return AddHexahedron( pointIDs );
656 template<
class TOutputMesh>
662 pointIDs[ 0 ] = AddPoint( p0 );
663 return AddVertex( pointIDs );
666 template<
class TOutputMesh>
673 pointIDs[ 0 ] = AddPoint( p0 );
674 pointIDs[ 1 ] = AddPoint( p1 );
675 return AddLine( pointIDs );
678 template<
class TOutputMesh>
686 pointIDs[ 0 ] = AddPoint( p0 );
687 pointIDs[ 1 ] = AddPoint( p1 );
688 pointIDs[ 2 ] = AddPoint( p2 );
689 return AddTriangle( pointIDs );
692 template<
class TOutputMesh>
701 pointIDs[ 0 ] = AddPoint( p0 );
702 pointIDs[ 1 ] = AddPoint( p1 );
703 pointIDs[ 2 ] = AddPoint( p2 );
704 pointIDs[ 3 ] = AddPoint( p3 );
705 return AddQuadrilateral( pointIDs );
708 template<
class TOutputMesh>
717 pointIDs[ 0 ] = AddPoint( p0 );
718 pointIDs[ 1 ] = AddPoint( p1 );
719 pointIDs[ 2 ] = AddPoint( p2 );
720 pointIDs[ 3 ] = AddPoint( p3 );
721 return AddTetrahedron( pointIDs );
724 template<
class TOutputMesh>
737 pointIDs[ 0 ] = AddPoint( p0 );
738 pointIDs[ 1 ] = AddPoint( p1 );
739 pointIDs[ 2 ] = AddPoint( p2 );
740 pointIDs[ 3 ] = AddPoint( p3 );
741 pointIDs[ 4 ] = AddPoint( p4 );
742 pointIDs[ 5 ] = AddPoint( p5 );
743 pointIDs[ 6 ] = AddPoint( p6 );
744 pointIDs[ 7 ] = AddPoint( p7 );
745 return AddHexahedron( pointIDs );