Updates will be applied - 3:30pm EDT (UTC -400). No downtime expected.

Commit 48e3c0f6 authored by Robert Maynard's avatar Robert Maynard

Update PointConnectivity to return the cell type of the iterating cell.

parent 56317a9d
......@@ -124,10 +124,23 @@ void PointConnectivity::initCellTraversal()
//----------------------------------------------------------------------------
bool PointConnectivity::fetchNextCell(int& numPts, const smtk::mesh::Handle* &points)
{
smtk::mesh::CellType cellType;
return this->m_connectivity->fetchNextCell(this->m_iteratorLocation,
cellType,
numPts,
points);
}
//----------------------------------------------------------------------------
bool PointConnectivity::fetchNextCell( smtk::mesh::CellType& cellType,
int& numPts,
const smtk::mesh::Handle* &points)
{
return this->m_connectivity->fetchNextCell(this->m_iteratorLocation,
cellType,
numPts,
points);
}
}
}
......@@ -14,6 +14,7 @@
#include "smtk/CoreExports.h"
#include "smtk/PublicPointerDefs.h"
#include "smtk/mesh/CellTypes.h"
#include "smtk/mesh/Handle.h"
namespace smtk {
......@@ -35,10 +36,10 @@ public:
typedef const value_type& const_reference;
PointConnectivity(const smtk::mesh::CollectionPtr& parent,
const smtk::mesh::HandleRange& range);
const smtk::mesh::HandleRange& range);
PointConnectivity(const smtk::mesh::CollectionPtr& parent,
const smtk::mesh::Handle& cell);
const smtk::mesh::Handle& cell);
//Copy Constructor required for rule of 3
PointConnectivity(const PointConnectivity& other);
......@@ -62,10 +63,20 @@ public:
//start cell traversal of the vertices
void initCellTraversal();
//fetch the handles to the points of the cell.
//fetch the number of points and the handle to the points
//of the cell.
//The pointer that is returned must not be deleted.
//The pointer returned should be treated as a read only pointer
bool fetchNextCell(int& numPts, const smtk::mesh::Handle* &points);
bool fetchNextCell( int& numPts,
const smtk::mesh::Handle* &points);
//fetch the cell type, the number of points and the handle to the points
//of the cell.
//The pointer that is returned must not be deleted.
//The pointer returned should be treated as a read only pointer
bool fetchNextCell( smtk::mesh::CellType& cellType,
int& numPts,
const smtk::mesh::Handle* &points);
//struct that holds the required information to compute what is the
//current cell when we are iterating.
......
......@@ -9,12 +9,9 @@
//=========================================================================
#include "smtk/mesh/moab/PointConnectivityStorage.h"
#include "smtk/mesh/moab/CellTypeToType.h"
#include "smtk/mesh/moab/Interface.h"
#ifndef NDEBUG
# include <iostream>
#endif
#include "moab/Interface.hpp"
namespace smtk {
......@@ -29,6 +26,7 @@ PointConnectivityStorage::PointConnectivityStorage(
ConnectivityStartPositions(),
ConnectivityArraysLengths(),
ConnectivityVertsPerCell(),
ConnectivityTypePerCell(),
NumberOfCells(0),
NumberOfVerts(0),
VertConnectivityStorage()
......@@ -55,6 +53,7 @@ PointConnectivityStorage::PointConnectivityStorage(
while(cells_current != cells_end &&
m_iface->type_from_handle(*cells_current) == ::moab::MBVERTEX)
{
smtk::mesh::HandleRange::iterator verts_start = cells_current.start_of_block();
smtk::mesh::HandleRange::iterator verts_end = cells_current.end_of_block();
......@@ -92,13 +91,17 @@ PointConnectivityStorage::PointConnectivityStorage(
numVertsPerCell,
numCellsInSubRange);
if(result == ::moab::MB_SUCCESS)
{
this->ConnectivityStartPositions.push_back(connectivity);
this->ConnectivityArraysLengths.push_back(numCellsInSubRange);
this->ConnectivityVertsPerCell.push_back(numVertsPerCell);
//fetch the current cell type for this block
::moab::EntityType moabCellType = m_iface->type_from_handle(*cells_current);
this->ConnectivityTypePerCell.push_back(
smtk::mesh::moab::moabToSMTKCell( static_cast< int >(moabCellType) ) );
//increment our iterator
cells_current += static_cast<std::size_t>(numCellsInSubRange);
......@@ -136,6 +139,7 @@ PointConnectivityStorage::PointConnectivityStorage(
ConnectivityStartPositions(),
ConnectivityArraysLengths(),
ConnectivityVertsPerCell(),
ConnectivityTypePerCell(),
NumberOfCells(0),
NumberOfVerts(0),
VertConnectivityStorage()
......@@ -147,7 +151,8 @@ PointConnectivityStorage::PointConnectivityStorage(
const int numCellsInSubRange=1; //we are only passed a single cell
//we have none
if(m_iface->type_from_handle(cell) == ::moab::MBVERTEX)
::moab::EntityType moabCellType = m_iface->type_from_handle(cell);
if(moabCellType == ::moab::MBVERTEX)
{
//add to the VertConnectivityStorage the ids of the vertices in this
//range
......@@ -165,6 +170,9 @@ PointConnectivityStorage::PointConnectivityStorage(
this->ConnectivityArraysLengths.push_back(numCellsInSubRange);
this->ConnectivityVertsPerCell.push_back(numVertsPerCell);
this->ConnectivityTypePerCell.push_back(
smtk::mesh::moab::moabToSMTKCell( static_cast< int >(moabCellType) ) );
this->NumberOfCells = numCellsInSubRange;
this->NumberOfVerts = numVertsPerCell;
}
......@@ -180,6 +188,7 @@ void PointConnectivityStorage::initTraversal(
//----------------------------------------------------------------------------
bool PointConnectivityStorage::fetchNextCell(
smtk::mesh::PointConnectivity::IterationState& state,
smtk::mesh::CellType& cellType,
int& numPts,
const smtk::mesh::Handle* &points)
{
......@@ -191,6 +200,7 @@ bool PointConnectivityStorage::fetchNextCell(
const std::size_t index = state.whichConnectivityVector;
const std::size_t ptr = state.ptrOffsetInVector;
cellType = this->ConnectivityTypePerCell[ index ];
numPts = this->ConnectivityVertsPerCell[ index ];
points = &this->ConnectivityStartPositions[ index ][ptr];
......
......@@ -33,6 +33,7 @@ public:
void initTraversal( smtk::mesh::PointConnectivity::IterationState& state );
bool fetchNextCell( smtk::mesh::PointConnectivity::IterationState& state,
smtk::mesh::CellType& cellType,
int& numPts,
const smtk::mesh::Handle* &points);
......@@ -46,6 +47,7 @@ private:
std::vector< const smtk::mesh::Handle* > ConnectivityStartPositions;
std::vector<int> ConnectivityArraysLengths;
std::vector<int> ConnectivityVertsPerCell;
std::vector< smtk::mesh::CellType > ConnectivityTypePerCell;
std::size_t NumberOfCells;
std::size_t NumberOfVerts;
......
......@@ -10,6 +10,7 @@
#include "smtk/mesh/Collection.h"
#include "smtk/mesh/Manager.h"
#include "smtk/mesh/TypeSet.h"
#include "smtk/io/ImportMesh.h"
#include "smtk/mesh/testing/cxx/helpers.h"
......@@ -177,15 +178,25 @@ void verify_iteration(const smtk::mesh::CollectionPtr& c)
std::size_t actualNumCells = 0;
std::size_t actualNumVerts = 0;
smtk::mesh::CellType cellType;
smtk::mesh::CellTypes allCellTypesSeen;
int size=0;
const smtk::mesh::Handle* points;
for(twoDim.initCellTraversal(); twoDim.fetchNextCell(size, points);)
for(twoDim.initCellTraversal(); twoDim.fetchNextCell(cellType, size, points);)
{
++actualNumCells;
actualNumVerts += static_cast<std::size_t>(size);
allCellTypesSeen[cellType] = true;
// c->debugDump( points );
}
smtk::mesh::TypeSet typeSet( allCellTypesSeen, false, true );
//verify that the cell types that are reported are only 2D cells.
test( typeSet.hasDimension( smtk::mesh::Dims1 ) == false );
test( typeSet.hasDimension( smtk::mesh::Dims2 ) == true );
test( typeSet.hasDimension( smtk::mesh::Dims3 ) == false );
test( reportedNumCells == actualNumCells);
test( reportedNumVerts == actualNumVerts);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment