VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkStructuredGridConnectivity.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00031 #ifndef vtkStructuredGridConnectivity_H_ 00032 #define vtkStructuredGridConnectivity_H_ 00033 00034 #define VTK_NO_OVERLAP 0 00035 #define VTK_NODE_OVERLAP 1 00036 #define VTK_EDGE_OVERLAP 2 00037 #define VTK_PARTIAL_OVERLAP 3 00038 00039 // VTK include directives 00040 #include "vtkFiltersGeometryModule.h" // For export macro 00041 #include "vtkAbstractGridConnectivity.h" 00042 #include "vtkStructuredNeighbor.h" // For Structured Neighbor object definition 00043 #include "vtkStructuredData.h" // For data description definitions 00044 00045 // C++ include directives 00046 #include <iostream> // For cout 00047 #include <vector> // For STL vector 00048 #include <map> // For STL map 00049 #include <utility> // For STL pair and overloaded relational operators 00050 #include <cassert> // For assert() 00051 00052 // Forward Declarations 00053 class vtkIdList; 00054 class vtkUnsignedCharArray; 00055 class vtkPointData; 00056 class vtkCellData; 00057 class vtkPoints; 00058 00059 class VTKFILTERSGEOMETRY_EXPORT vtkStructuredGridConnectivity : 00060 public vtkAbstractGridConnectivity 00061 { 00062 public: 00063 static vtkStructuredGridConnectivity* New(); 00064 vtkTypeMacro( vtkStructuredGridConnectivity, vtkAbstractGridConnectivity ); 00065 void PrintSelf(ostream& os, vtkIndent indent ); 00066 00068 00069 vtkSetVector6Macro(WholeExtent,int); 00070 vtkGetVector6Macro(WholeExtent,int); 00072 00074 00075 vtkGetMacro(DataDimension,int); 00077 00079 virtual void SetNumberOfGrids( const unsigned int N ); 00080 00082 00084 virtual void RegisterGrid( const int gridID, int extents[6], 00085 vtkUnsignedCharArray* nodesGhostArray, 00086 vtkUnsignedCharArray* cellGhostArray, 00087 vtkPointData* pointData, 00088 vtkCellData* cellData, 00089 vtkPoints* gridNodes ); 00091 00094 void GetGridExtent( const int gridID, int extent[6] ); 00095 00098 void SetGhostedGridExtent( const int gridID, int ext[6] ); 00099 00101 void GetGhostedGridExtent( const int gridID, int ext[6] ); 00102 00104 virtual void ComputeNeighbors(); 00105 00107 00109 int GetNumberOfNeighbors( const int gridID ) 00110 { return( static_cast<int>(this->Neighbors[ gridID ].size() )); }; 00112 00115 vtkStructuredNeighbor GetGridNeighbor(const int gridID, const int nei); 00116 00120 vtkIdList* GetNeighbors( const int gridID, int *extents ); 00121 00123 00126 void FillGhostArrays( 00127 const int gridID, 00128 vtkUnsignedCharArray *nodesArray, 00129 vtkUnsignedCharArray *cellsArray ); 00131 00133 virtual void CreateGhostLayers( const int N=1 ); 00134 00135 protected: 00136 vtkStructuredGridConnectivity(); 00137 virtual ~vtkStructuredGridConnectivity(); 00138 00140 00141 bool InBounds( const int idx, const int Lo, const int Hi ) 00142 { return( (idx>=Lo) && (idx<=Hi) ); }; 00144 00146 00147 bool StrictlyInsideBounds( const int idx, const int Lo, const int Hi ) 00148 { return( (idx > Lo) && (idx < Hi) ); }; 00150 00152 00153 bool IsSubset( int A[2], int B[2] ) 00154 { return( this->InBounds(A[0], B[0], B[1]) && 00155 this->InBounds(A[1], B[0], B[1]) ); }; 00157 00159 int Cardinality( int S[2] ) { return( S[1]-S[0]+1 ); }; 00160 00162 00164 int GetNumberOfNodesPerCell( const int dim ) 00165 { 00166 int numNodes = 0; 00167 switch( dim ) 00168 { 00169 case 1: 00170 numNodes = 2; // line cell 00171 break; 00172 case 2: 00173 numNodes = 4; // quad cell 00174 break; 00175 case 3: 00176 numNodes = 8; // hex cell 00177 break; 00178 default: 00179 assert( "ERROR: code should not reach here!" && false ); 00180 } // END switch 00181 return( numNodes ); 00182 } 00184 00186 00187 void FillNodesGhostArray( 00188 const int gridID, const int dataDescription, 00189 int GridExtent[6], int RealExtent[6], vtkUnsignedCharArray *nodeArray ); 00191 00193 00194 void FillCellsGhostArray( 00195 const int dataDescription, const int numNodesPerCell, 00196 int dims[3], int CellExtent[6], vtkUnsignedCharArray *nodesArray, 00197 vtkUnsignedCharArray *cellsArray ); 00199 00201 00204 void SearchNeighbors( 00205 const int gridID, 00206 const int i, const int j, const int k, 00207 vtkIdList *neiList ); 00209 00211 00213 void MarkNodeProperty( 00214 const int gridID, 00215 const int i, const int j, const int k, 00216 int ext[6], int RealExtent[6], unsigned char &pfield ); 00218 00220 00222 void MarkCellProperty( 00223 unsigned char &pfield, 00224 unsigned char *nodeGhostFields, const int numNodes ); 00226 00228 void GetRealExtent( const int gridID, int GridExtent[6],int RealExtent[6] ); 00229 00231 00233 bool IsGhostNode( 00234 int GridExtent[6], int RealExtent[6], 00235 const int i, const int j, const int k ); 00237 00239 00241 bool IsNodeOnBoundaryOfExtent( 00242 const int i, const int j, const int k, int ext[6] ); 00244 00246 00249 bool IsNodeOnSharedBoundary( 00250 const int gridID, int RealExtent[6], 00251 const int i, const int j, const int k ); 00253 00257 bool IsNodeOnBoundary( const int i, const int j, const int k ); 00258 00260 00262 bool IsNodeInterior( 00263 const int i, const int j, const int k, 00264 int GridExtent[6] ); 00266 00268 00271 bool IsNodeWithinExtent( 00272 const int i, const int j, const int k, 00273 int GridExtent[6] ) 00274 { 00275 bool status = false; 00277 00278 switch( this->DataDescription ) 00279 { 00280 case VTK_X_LINE: 00281 if( (GridExtent[0] <= i) && (i <= GridExtent[1]) ) 00282 { 00283 status = true; 00284 } 00285 break; 00286 case VTK_Y_LINE: 00287 if( (GridExtent[2] <= j) && (j <= GridExtent[3] ) ) 00288 { 00289 status = true; 00290 } 00291 break; 00292 case VTK_Z_LINE: 00293 if( (GridExtent[4] <= k) && (k <= GridExtent[5] ) ) 00294 { 00295 status = true; 00296 } 00297 break; 00298 case VTK_XY_PLANE: 00299 if( (GridExtent[0] <= i) && (i <= GridExtent[1]) && 00300 (GridExtent[2] <= j) && (j <= GridExtent[3]) ) 00301 { 00302 status = true; 00303 } 00304 break; 00305 case VTK_YZ_PLANE: 00306 if( (GridExtent[2] <= j) && (j <= GridExtent[3] ) && 00307 (GridExtent[4] <= k) && (k <= GridExtent[5] ) ) 00308 { 00309 status = true; 00310 } 00311 break; 00312 case VTK_XZ_PLANE: 00313 if( (GridExtent[0] <= i) && (i <= GridExtent[1] ) && 00314 (GridExtent[4] <= k) && (k <= GridExtent[5] ) ) 00315 { 00316 status = true; 00317 } 00318 break; 00319 case VTK_XYZ_GRID: 00320 if( (GridExtent[0] <= i) && (i <= GridExtent[1]) && 00321 (GridExtent[2] <= j) && (j <= GridExtent[3]) && 00322 (GridExtent[4] <= k) && (k <= GridExtent[5]) ) 00323 { 00324 status = true; 00325 } 00326 break; 00327 default: 00328 std::cout << "Data description is: " << this->DataDescription << "\n"; 00329 std::cout.flush(); 00330 assert( "pre: Undefined data-description!" && false ); 00331 } // END switch 00332 00333 return( status ); 00334 } 00335 00337 00338 void SetNeighbors( 00339 const int i, const int j, 00340 int i2jOrientation[3], int j2iOrientation[3], 00341 int overlapExtent[6] ); 00343 00345 00351 void DetermineNeighborOrientation( 00352 const int idx, int A[2], int B[2], int overlap[2], int orient[3] ); 00354 00356 00359 void DetectNeighbors( 00360 const int i, const int j, int ex1[6], int ex2[6], 00361 int orientation[3], int ndim); 00363 00369 int IntervalOverlap( int A[2], int B[2], int overlap[2] ); 00370 00376 int DoPartialOverlap( int s[2], int S[2], int overlap[2] ); 00377 00379 00384 int PartialOverlap( 00385 int A[2], const int CofA, 00386 int B[2], const int CofB, 00387 int overlap[2] ); 00389 00392 void EstablishNeighbors( const int i, const int j ); 00393 00397 void AcquireDataDescription(); 00398 00406 bool HasBlockConnection( const int gridID, const int blockDirection ); 00407 00415 void RemoveBlockConnection( const int gridID, const int blockDirection ); 00416 00424 void AddBlockConnection( const int gridID, const int blockDirection ); 00425 00428 void ClearBlockConnections( const int gridID ); 00429 00435 int GetNumberOfConnectingBlockFaces( const int gridID ); 00436 00439 void SetBlockTopology( const int gridID ); 00440 00442 00447 void GetIJKBlockOrientation( 00448 const int i, const int j, const int k, int ext[6], int orientation[3] ); 00450 00452 00454 int Get1DOrientation( 00455 const int idx, const int ExtentLo, const int ExtentHi, 00456 const int OnLo, const int OnHi, const int NotOnBoundary ); 00458 00461 void CreateGhostedExtent( const int gridID, const int N ); 00462 00464 00467 void GetGhostedExtent( 00468 int *ghostedExtent, int GridExtent[6], 00469 const int minIdx, const int maxIdx, const int N); 00471 00475 void CreateGhostedMaskArrays(const int gridID); 00476 00481 void InitializeGhostData( const int gridID ); 00482 00486 void AllocatePointData( vtkPointData *RPD, const int N, vtkPointData *PD ); 00487 00491 void AllocateCellData( vtkCellData *RCD, const int N, vtkCellData *CD ); 00492 00495 void TransferRegisteredDataToGhostedData( const int gridID ); 00496 00499 void ComputeNeighborSendAndRcvExtent( const int gridID, const int N ); 00500 00504 virtual void TransferGhostDataFromNeighbors( const int gridID ); 00505 00507 00508 void TransferLocalNeighborData( 00509 const int gridID, const vtkStructuredNeighbor& Neighor); 00511 00513 00514 void CopyCoordinates( 00515 vtkPoints *source, vtkIdType sourceIdx, 00516 vtkPoints *target, vtkIdType targetIdx ); 00518 00520 00525 void CopyFieldData( 00526 vtkFieldData *source, vtkIdType sourceIdx, 00527 vtkFieldData *target, vtkIdType targetIdx ); 00529 00533 int GetNeighborIndex( const int gridIdx, const int NeighborGridIdx ); 00534 00536 void PrintExtent( int extent[6] ); 00537 00538 int DataDimension; 00539 int DataDescription; 00540 int WholeExtent[6]; 00541 00542 // BTX 00543 std::vector< int > GridExtents; 00544 std::vector< int > GhostedExtents; 00545 std::vector< unsigned char > BlockTopology; 00546 std::vector< std::vector<vtkStructuredNeighbor> > Neighbors; 00547 std::map< std::pair< int,int >, int > NeighborPair2NeighborListIndex; 00548 // ETX 00549 00550 private: 00551 vtkStructuredGridConnectivity( const vtkStructuredGridConnectivity& ); // Not implemented 00552 void operator=(const vtkStructuredGridConnectivity& ); // Not implemented 00553 }; 00554 00555 //============================================================================= 00556 // INLINE METHODS 00557 //============================================================================= 00558 00559 //------------------------------------------------------------------------------ 00560 inline int vtkStructuredGridConnectivity::GetNeighborIndex( 00561 const int gridIdx, const int NeighborGridIdx ) 00562 { 00563 assert("pre: Grid index is out-of-bounds!" && 00564 (gridIdx >= 0) && 00565 (gridIdx < static_cast<int>(this->NumberOfGrids))); 00566 assert("pre: Neighbor grid index is out-of-bounds!" && 00567 (NeighborGridIdx >= 0) && 00568 (NeighborGridIdx < static_cast<int>(this->NumberOfGrids) ) ); 00569 00570 std::pair<int,int> gridPair = std::make_pair(gridIdx,NeighborGridIdx); 00571 assert("pre: Neighboring grid pair does not exist in hash!" && 00572 (this->NeighborPair2NeighborListIndex.find(gridPair) != 00573 this->NeighborPair2NeighborListIndex.end() ) ); 00574 00575 return(this->NeighborPair2NeighborListIndex[gridPair]); 00576 } 00577 00578 //------------------------------------------------------------------------------ 00579 inline void vtkStructuredGridConnectivity::GetGhostedExtent( 00580 int *ghostedExtent, int GridExtent[6], 00581 const int minIdx, const int maxIdx, const int N ) 00582 { 00583 assert( "pre: Number of ghost layers must be N >= 1" && (N >= 1) ); 00584 assert( "pre: ghosted extent pointer is NULL" && ghostedExtent != NULL); 00585 00586 ghostedExtent[minIdx] = GridExtent[minIdx]-N; 00587 ghostedExtent[maxIdx] = GridExtent[maxIdx]+N; 00588 00589 // Clamp the ghosted extent to be within the WholeExtent 00590 ghostedExtent[minIdx] = 00591 (ghostedExtent[minIdx] < this->WholeExtent[minIdx] )? 00592 this->WholeExtent[minIdx] : ghostedExtent[minIdx]; 00593 ghostedExtent[maxIdx] = 00594 (ghostedExtent[maxIdx] > this->WholeExtent[maxIdx])? 00595 this->WholeExtent[maxIdx] : ghostedExtent[maxIdx]; 00596 } 00597 00598 //------------------------------------------------------------------------------ 00599 inline void vtkStructuredGridConnectivity::SetGhostedGridExtent( 00600 const int gridID, int ext[6] ) 00601 { 00602 assert( "pre: gridID is out-of-bounds" && 00603 (gridID >= 0) && (gridID < static_cast<int>(this->NumberOfGrids))); 00604 assert( "pre: ghosted-extents vector has not been allocated" && 00605 (this->NumberOfGrids == this->GhostedExtents.size()/6 ) ); 00606 00607 for( int i=0; i < 6; ++i ) 00608 { 00609 this->GhostedExtents[ gridID*6+i ] = ext[i]; 00610 } 00611 } 00612 00613 //------------------------------------------------------------------------------ 00614 inline void vtkStructuredGridConnectivity::GetGridExtent( 00615 const int gridID, int ext[6]) 00616 { 00617 assert( "pre: gridID out-of-bounds!" && 00618 (gridID >= 0 && gridID < static_cast<int>(this->NumberOfGrids))); 00619 for( int i=0; i < 6; ++i ) 00620 { 00621 ext[i] = this->GridExtents[ gridID*6+i ]; 00622 } 00623 } 00624 00625 //------------------------------------------------------------------------------ 00626 inline void vtkStructuredGridConnectivity::GetGhostedGridExtent( 00627 const int gridID, int ext[6]) 00628 { 00629 assert( "pre: gridID out-of-bounds!" && 00630 (gridID >= 0 && gridID < static_cast<int>(this->NumberOfGrids))); 00631 00632 if( this->GhostedExtents.size() == 0 ) 00633 { 00634 ext[0] = ext[2] = ext[4] = -1; 00635 ext[1] = ext[3] = ext[5] = 0; 00636 vtkErrorMacro( "No ghosted extents found for registered grid extends!!!" ); 00637 return; 00638 } 00639 00640 assert( "GhostedExtents are not aligned with registered grid extents" && 00641 ( this->GhostedExtents.size() == this->GridExtents.size() ) ); 00642 for( int i=0; i < 6; ++i ) 00643 { 00644 ext[i] = this->GhostedExtents[ gridID*6+i ]; 00645 } 00646 } 00647 00648 //------------------------------------------------------------------------------ 00649 inline bool vtkStructuredGridConnectivity::IsNodeOnBoundaryOfExtent( 00650 const int i, const int j, const int k, int ext[6] ) 00651 { 00652 if( !this->IsNodeWithinExtent( i,j,k, ext) ) 00653 { 00654 return false; 00655 } 00656 00657 bool status = false; 00658 switch( this->DataDescription ) 00659 { 00660 case VTK_X_LINE: 00661 if( i==ext[0] || i==ext[1] ) 00662 { 00663 status = true; 00664 } 00665 break; 00666 case VTK_Y_LINE: 00667 if( j==ext[2] || j==ext[3] ) 00668 { 00669 status = true; 00670 } 00671 break; 00672 case VTK_Z_LINE: 00673 if( k==ext[4] || k==ext[5] ) 00674 { 00675 status = true; 00676 } 00677 break; 00678 case VTK_XY_PLANE: 00679 if( (i==ext[0] || i==ext[1]) || 00680 (j==ext[2] || j==ext[3]) ) 00681 { 00682 status = true; 00683 } 00684 break; 00685 case VTK_YZ_PLANE: 00686 if( (j==ext[2] || j==ext[3]) || 00687 (k==ext[4] || k==ext[5]) ) 00688 { 00689 status = true; 00690 } 00691 break; 00692 case VTK_XZ_PLANE: 00693 if( (i==ext[0] || i==ext[1]) || 00694 (k==ext[4] || k==ext[5]) ) 00695 { 00696 status = true; 00697 } 00698 break; 00699 case VTK_XYZ_GRID: 00700 if( (i==ext[0] || i==ext[1]) || 00701 (j==ext[2] || j==ext[3]) || 00702 (k==ext[4] || k==ext[5]) ) 00703 { 00704 status = true; 00705 } 00706 break; 00707 default: 00708 std::cout << "Data description is: " << this->DataDescription << "\n"; 00709 std::cout.flush(); 00710 assert( "pre: Undefined data-description!" && false ); 00711 } // END switch 00712 00713 return( status ); 00714 } 00715 00716 //------------------------------------------------------------------------------ 00717 inline bool vtkStructuredGridConnectivity::IsNodeInterior( 00718 const int i, const int j, const int k, 00719 int GridExtent[6] ) 00720 { 00721 bool status = false; 00722 00723 switch( this->DataDescription ) 00724 { 00725 case VTK_X_LINE: 00726 if( (GridExtent[0] < i) && (i < GridExtent[1]) ) 00727 { 00728 status = true; 00729 } 00730 break; 00731 case VTK_Y_LINE: 00732 if( (GridExtent[2] < j) && (j < GridExtent[3] ) ) 00733 { 00734 status = true; 00735 } 00736 break; 00737 case VTK_Z_LINE: 00738 if( (GridExtent[4] < k) && (k < GridExtent[5] ) ) 00739 { 00740 status = true; 00741 } 00742 break; 00743 case VTK_XY_PLANE: 00744 if( (GridExtent[0] < i) && (i < GridExtent[1]) && 00745 (GridExtent[2] < j) && (j < GridExtent[3]) ) 00746 { 00747 status = true; 00748 } 00749 break; 00750 case VTK_YZ_PLANE: 00751 if( (GridExtent[2] < j) && (j < GridExtent[3] ) && 00752 (GridExtent[4] < k) && (k < GridExtent[5] ) ) 00753 { 00754 status = true; 00755 } 00756 break; 00757 case VTK_XZ_PLANE: 00758 if( (GridExtent[0] < i) && (i < GridExtent[1] ) && 00759 (GridExtent[4] < k) && (k < GridExtent[5] ) ) 00760 { 00761 status = true; 00762 } 00763 break; 00764 case VTK_XYZ_GRID: 00765 if( (GridExtent[0] < i) && (i < GridExtent[1]) && 00766 (GridExtent[2] < j) && (j < GridExtent[3]) && 00767 (GridExtent[4] < k) && (k < GridExtent[5]) ) 00768 { 00769 status = true; 00770 } 00771 break; 00772 default: 00773 std::cout << "Data description is: " << this->DataDescription << "\n"; 00774 std::cout.flush(); 00775 assert( "pre: Undefined data-description!" && false ); 00776 } // END switch 00777 00778 return( status ); 00779 } 00780 00781 //------------------------------------------------------------------------------ 00782 inline void vtkStructuredGridConnectivity::DetermineNeighborOrientation( 00783 const int idx, int A[2], int B[2], int overlap[2], int orient[3] ) 00784 { 00785 assert( "pre: idx is out-of-bounds" && (idx >= 0) && (idx < 3) ); 00786 00787 // A. Non-overlapping cases 00788 if( overlap[0] == overlap[1] ) 00789 { 00790 if( A[1] == B[0] ) 00791 { 00792 orient[ idx ] = vtkStructuredNeighbor::HI; 00793 } 00794 else if( A[0] == B[1] ) 00795 { 00796 orient[ idx ] = vtkStructuredNeighbor::LO; 00797 } 00798 else 00799 { 00800 orient[ idx ] = vtkStructuredNeighbor::UNDEFINED; 00801 assert( "ERROR: Code should not reach here!" && false ); 00802 } 00803 } // END non-overlapping cases 00804 // B. Sub-set cases 00805 else if( this->IsSubset( A, B) ) 00806 { 00807 if( (A[0] == B[0]) && (A[1] == B[1]) ) 00808 { 00809 orient[ idx ] = vtkStructuredNeighbor::ONE_TO_ONE; 00810 } 00811 else if( this->StrictlyInsideBounds( A[0], B[0], B[1] ) && 00812 this->StrictlyInsideBounds( A[1], B[0], B[1] ) ) 00813 { 00814 orient[ idx ] = vtkStructuredNeighbor::SUBSET_BOTH; 00815 } 00816 else if( A[0] == B[0] ) 00817 { 00818 orient[ idx ] = vtkStructuredNeighbor::SUBSET_HI; 00819 } 00820 else if( A[1] == B[1] ) 00821 { 00822 orient[ idx ] = vtkStructuredNeighbor::SUBSET_LO; 00823 } 00824 else 00825 { 00826 orient[ idx ] = vtkStructuredNeighbor::UNDEFINED; 00827 assert( "ERROR: Code should not reach here!" && false ); 00828 } 00829 } 00830 // C. Super-set cases 00831 else if( this->IsSubset( B, A ) ) 00832 { 00833 orient[ idx ] = vtkStructuredNeighbor::SUPERSET; 00834 } 00835 // D. Partially-overlapping (non-subset) cases 00836 else if( !(this->IsSubset(A,B) || this->IsSubset(A,B)) ) 00837 { 00838 if( this->InBounds( A[0], B[0], B[1] ) ) 00839 { 00840 orient[ idx ] = vtkStructuredNeighbor::LO; 00841 } 00842 else if( this->InBounds( A[1], B[0], B[1] ) ) 00843 { 00844 orient[ idx ] = vtkStructuredNeighbor::HI; 00845 } 00846 else 00847 { 00848 orient[ idx ] = vtkStructuredNeighbor::UNDEFINED; 00849 assert( "ERROR: Code should not reach here!" && false ); 00850 } 00851 } 00852 else 00853 { 00854 orient[ idx ] = vtkStructuredNeighbor::UNDEFINED; 00855 assert( "ERROR: Code should not reach here!" && false ); 00856 } 00857 } 00858 00859 //------------------------------------------------------------------------------ 00860 inline int vtkStructuredGridConnectivity::Get1DOrientation( 00861 const int idx, const int ExtentLo, const int ExtentHi, 00862 const int OnLo, const int OnHi, const int NotOnBoundary ) 00863 { 00864 if( idx == ExtentLo ) 00865 { 00866 return OnLo; 00867 } 00868 else if( idx == ExtentHi ) 00869 { 00870 return OnHi; 00871 } 00872 return NotOnBoundary; 00873 } 00874 00875 //------------------------------------------------------------------------------ 00876 inline bool vtkStructuredGridConnectivity::HasBlockConnection( 00877 const int gridID, const int blockDirection ) 00878 { 00879 // Sanity check 00880 assert("pre: gridID is out-of-bounds" && 00881 (gridID >=0) && (gridID < static_cast<int>(this->NumberOfGrids))); 00882 assert("pre: BlockTopology has not been properly allocated" && 00883 (this->NumberOfGrids == this->BlockTopology.size())); 00884 assert("pre: blockDirection is out-of-bounds" && 00885 (blockDirection >= 0) && (blockDirection < 6) ); 00886 bool status = false; 00887 if( this->BlockTopology[ gridID ] & (1 << blockDirection) ) 00888 { 00889 status = true; 00890 } 00891 return( status ); 00892 } 00893 00894 //------------------------------------------------------------------------------ 00895 inline void vtkStructuredGridConnectivity::RemoveBlockConnection( 00896 const int gridID, const int blockDirection ) 00897 { 00898 // Sanity check 00899 assert("pre: gridID is out-of-bounds" && 00900 (gridID >=0) && (gridID < static_cast<int>(this->NumberOfGrids))); 00901 assert("pre: BlockTopology has not been properly allocated" && 00902 (this->NumberOfGrids == this->BlockTopology.size())); 00903 assert("pre: blockDirection is out-of-bounds" && 00904 (blockDirection >= 0) && (blockDirection < 6) ); 00905 00906 this->BlockTopology[ gridID ] &= ~(1 << blockDirection); 00907 } 00908 00909 //------------------------------------------------------------------------------ 00910 inline void vtkStructuredGridConnectivity::AddBlockConnection( 00911 const int gridID, const int blockDirection ) 00912 { 00913 // Sanity check 00914 assert("pre: gridID is out-of-bounds" && 00915 (gridID >=0) && (gridID < static_cast<int>(this->NumberOfGrids))); 00916 assert("pre: BlockTopology has not been properly allocated" && 00917 (this->NumberOfGrids == this->BlockTopology.size())); 00918 assert("pre: blockDirection is out-of-bounds" && 00919 (blockDirection >= 0) && (blockDirection < 6) ); 00920 this->BlockTopology[ gridID ] |= (1 << blockDirection); 00921 } 00922 00923 //------------------------------------------------------------------------------ 00924 inline void vtkStructuredGridConnectivity::ClearBlockConnections( 00925 const int gridID ) 00926 { 00927 // Sanity check 00928 assert("pre: gridID is out-of-bounds" && 00929 (gridID >=0) && (gridID < static_cast<int>(this->NumberOfGrids))); 00930 assert("pre: BlockTopology has not been properly allocated" && 00931 (this->NumberOfGrids == this->BlockTopology.size())); 00932 for( int i=0; i < 6; ++i ) 00933 { 00934 this->RemoveBlockConnection( gridID, i ); 00935 } // END for all block directions 00936 } 00937 00938 //------------------------------------------------------------------------------ 00939 inline int vtkStructuredGridConnectivity::GetNumberOfConnectingBlockFaces( 00940 const int gridID ) 00941 { 00942 // Sanity check 00943 assert("pre: gridID is out-of-bounds" && 00944 (gridID >=0) && (gridID < static_cast<int>(this->NumberOfGrids))); 00945 assert("pre: BlockTopology has not been properly allocated" && 00946 (this->NumberOfGrids == this->BlockTopology.size())); 00947 00948 int count = 0; 00949 for( int i=0; i < 6; ++i ) 00950 { 00951 if( this->HasBlockConnection( gridID, i ) ) 00952 { 00953 ++count; 00954 } 00955 } 00956 assert( "post: count must be in [0,5]" && (count >=0 && count <= 6) ); 00957 return( count ); 00958 } 00959 00960 //------------------------------------------------------------------------------ 00961 inline void vtkStructuredGridConnectivity::SetNumberOfGrids( 00962 const unsigned int N ) 00963 { 00964 this->NumberOfGrids = N; 00965 this->AllocateUserRegisterDataStructures(); 00966 00967 this->GridExtents.resize( 6*N,-1); 00968 this->Neighbors.resize( N ); 00969 this->BlockTopology.resize( N ); 00970 } 00971 #endif /* vtkStructuredGridConnectivity_H_ */