Mesh Oriented datABase  (version 5.4.1)
Array-based unstructured mesh datastructure
smoab::detail::MixedCellConnectivity Class Reference

#include <MixedCellConnectivity.h>

+ Collaboration diagram for smoab::detail::MixedCellConnectivity:

Public Member Functions

 MixedCellConnectivity (smoab::Range const &cells, moab::Interface *moab)
void compactIds (vtkIdType &numCells, vtkIdType &connectivityLength)
void moabPoints (smoab::Range &range) const
void copyConnectivity (std::vector< EntityHandle > &output) const
void copyToVtkCellInfo (vtkIdType *cellArray, vtkIdType *cellLocations, unsigned char *cellTypes) const

Private Types

typedef std::vector
< EntityHandle >
::const_iterator 
EntityConstIterator
typedef std::vector
< EntityHandle * >
::const_iterator 
ConnConstIterator
typedef std::vector
< detail::ContinousCellInfo >
::const_iterator 
InfoConstIterator

Private Attributes

std::vector< EntityHandle * > Connectivity
std::vector< EntityHandleUniquePoints
std::vector
< detail::ContinousCellInfo
Info

Detailed Description

Definition at line 15 of file MixedCellConnectivity.h.


Member Typedef Documentation

typedef std::vector< EntityHandle* >::const_iterator smoab::detail::MixedCellConnectivity::ConnConstIterator [private]

Definition at line 197 of file MixedCellConnectivity.h.

typedef std::vector< EntityHandle >::const_iterator smoab::detail::MixedCellConnectivity::EntityConstIterator [private]

Definition at line 196 of file MixedCellConnectivity.h.

Definition at line 198 of file MixedCellConnectivity.h.


Constructor & Destructor Documentation

Definition at line 18 of file MixedCellConnectivity.h.

References moab::Range::begin(), moab::Interface::connect_iterate(), Connectivity, moab::Range::end(), Info, moab::Range::size(), moab::Interface::type_from_handle(), and smoab::detail::vtkCellType().

            : Connectivity(), UniquePoints(), Info()
        {
            int count                  = 0;
            const std::size_t cellSize = cells.size();
            while( count != cellSize )
            {
                EntityHandle* connectivity;
                int numVerts = 0, iterationCount = 0;
                //use the highly efficent calls, since we know that are of the same dimension
                moab->connect_iterate( cells.begin() + count, cells.end(), connectivity, numVerts, iterationCount );
                //if we didn't read anything, break!
                if( iterationCount == 0 )
                {
                    break;
                }

                //identify the cell type that we currently have,
                //store that along with the connectivity in a temp storage vector
                const moab::EntityType type = moab->type_from_handle( *cells.begin() + count );

                //while all these cells are contiously of the same type,
                //quadric hexs in vtk have 20 points, but moab has 21 so we
                //need to store this difference
                int numVTKVerts = numVerts;
                int vtkCellType = smoab::detail::vtkCellType( type, numVTKVerts );

                ContinousCellInfo info = { vtkCellType, numVerts, ( numVerts - numVTKVerts ), iterationCount };
                this->Info.push_back( info );
                this->Connectivity.push_back( connectivity );

                count += iterationCount;
            }
        }

Member Function Documentation

void smoab::detail::MixedCellConnectivity::compactIds ( vtkIdType &  numCells,
vtkIdType &  connectivityLength 
) [inline]

Definition at line 54 of file MixedCellConnectivity.h.

References copyConnectivity(), Info, and UniquePoints.

Referenced by smoab::detail::LoadGeometry::fill().

        {
            //converts all the ids to be ordered starting at zero, and also
            //keeping the orginal logical ordering. Stores the result of this
            //operation in the unstrucutred grid that is passed in

            //lets determine the total length of the connectivity
            connectivityLength = 0;
            numCells           = 0;
            for( InfoConstIterator i = this->Info.begin(); i != this->Info.end(); ++i )
            {
                connectivityLength += ( *i ).numCells * ( *i ).numVerts;
                numCells += ( *i ).numCells;
            }

            this->UniquePoints.reserve( connectivityLength );

            this->copyConnectivity( this->UniquePoints );
            std::sort( this->UniquePoints.begin(), this->UniquePoints.end() );

            typedef std::vector< EntityHandle >::iterator EntityIterator;
            EntityIterator newEnd = std::unique( this->UniquePoints.begin(), this->UniquePoints.end() );

            const std::size_t newSize = std::distance( this->UniquePoints.begin(), newEnd );
            this->UniquePoints.resize( newSize );
        }
void smoab::detail::MixedCellConnectivity::copyConnectivity ( std::vector< EntityHandle > &  output) const [inline]

Definition at line 91 of file MixedCellConnectivity.h.

References Connectivity, Info, and size.

Referenced by compactIds().

        {
            //walk the info to find the length of each sub connectivity array,
            //and insert them into the vector, ordering is implied by the order
            //the connecitivy sub array are added to this class
            ConnConstIterator c = this->Connectivity.begin();
            for( InfoConstIterator i = this->Info.begin(); i != this->Info.end(); ++i, ++c )
            {
                //remember our Connectivity is a vector of pointers whose
                //length is held in the info vector.
                const int numUnusedPoints = ( *i ).numUnusedVerts;
                if( numUnusedPoints == 0 )
                {
                    const int connLength = ( *i ).numCells * ( *i ).numVerts;
                    std::copy( *c, *c + connLength, std::back_inserter( output ) );
                }
                else
                {
                    //we have cell connectivity that we need to skip,
                    //so we have to manual copy each cells connectivity
                    const int size      = ( *i ).numCells;
                    const int numPoints = ( *i ).numVerts;
                    for( int j = 0; j < size; ++j )
                    {
                        std::copy( *c, *c + numPoints, std::back_inserter( output ) );
                    }
                    c += numPoints + ( *i ).numUnusedVerts;
                }
            }
        }
void smoab::detail::MixedCellConnectivity::copyToVtkCellInfo ( vtkIdType *  cellArray,
vtkIdType *  cellLocations,
unsigned char *  cellTypes 
) const [inline]

Definition at line 124 of file MixedCellConnectivity.h.

References Connectivity, smoab::detail::FixQuadraticIdOrdering(), Info, UniquePoints, and smoab::detail::vtkCellType().

Referenced by smoab::detail::LoadGeometry::addGridsTopology().

        {
            vtkIdType currentVtkConnectivityIndex = 0;
            ConnConstIterator c                   = this->Connectivity.begin();
            for( InfoConstIterator i = this->Info.begin(); i != this->Info.end(); ++i, ++c )
            {
                //for this group of the same cell type we need to fill the cellTypes
                const int numCells = ( *i ).numCells;
                const int numVerts = ( *i ).numVerts;

                std::fill_n( cellTypes, numCells, static_cast< unsigned char >( ( *i ).type ) );

                //for each cell in this collection that have the same type
                //grab the raw array now, so we can properly increment for each vert in each cell
                EntityHandle* moabConnectivity = *c;
                for( int j = 0; j < numCells; ++j )
                {
                    cellLocations[j] = currentVtkConnectivityIndex;

                    //cell arrays start and end are different, since we
                    //have to account for element that states the length of each cell
                    cellArray[0] = numVerts;

                    for( int k = 0; k < numVerts; ++k, ++moabConnectivity )
                    {
                        //this is going to be a root of some failures when we start
                        //reading really large datasets under 32bit.

                        //fyi, don't use a range ds for unique points, distance
                        //function is horribly slow they need to override it
                        EntityConstIterator result =
                            std::lower_bound( this->UniquePoints.begin(), this->UniquePoints.end(), *moabConnectivity );
                        std::size_t newId = std::distance( this->UniquePoints.begin(), result );
                        cellArray[k + 1]  = static_cast< vtkIdType >( newId );
                    }

                    //skip any extra unused points, which is currnetly only
                    //the extra center point in moab quadratic hex
                    moabConnectivity += ( *i ).numUnusedVerts;

                    currentVtkConnectivityIndex += numVerts + 1;
                    cellArray += numVerts + 1;
                }

                //For Tri-Quadratic-Hex and Quadratric-Wedge Moab and VTK
                //Differ on the order of the edge ids. For wedge we need to swap
                //indices 9,10,11 with 12,13,14 for each cell. For Hex we sawp
                //12,13,14,15 with 16,17,18,19
                int vtkCellType         = ( *i ).type;
                vtkIdType* connectivity = cellArray - ( numCells * ( numVerts + 1 ) );
                if( vtkCellType == VTK_TRIQUADRATIC_HEXAHEDRON )
                {
                    smoab::detail::QuadratricOrdering< VTK_TRIQUADRATIC_HEXAHEDRON > newOrdering;
                    smoab::detail::FixQuadraticIdOrdering( connectivity, numCells, newOrdering );
                }
                else if( vtkCellType == VTK_QUADRATIC_WEDGE )
                {
                    smoab::detail::QuadratricOrdering< VTK_QUADRATIC_WEDGE > newOrdering;
                    smoab::detail::FixQuadraticIdOrdering( connectivity, numCells, newOrdering );
                }

                cellLocations += numCells;
                cellTypes += numCells;
            }
        }

Definition at line 82 of file MixedCellConnectivity.h.

References UniquePoints.

Referenced by smoab::detail::LoadGeometry::addCoordinates().

        {
            //from the documentation a reverse iterator is the fastest way
            //to insert into a range.
            std::copy( this->UniquePoints.rbegin(), this->UniquePoints.rend(), moab::range_inserter( range ) );
        }

Member Data Documentation

List of all members.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines