Commit e2883890 authored by Robert Maynard's avatar Robert Maynard

Update for_each for CellSet to return cell types for each cell.

parent 48e3c0f6
......@@ -56,10 +56,12 @@ public:
}
//--------------------------------------------------------------------------
void operator()(int numPts,
void operator()(smtk::mesh::CellType& cellType,
int numPts,
const smtk::mesh::Handle* const pointIds,
const double* const coords)
{
(void) cellType;
for( int i=0; i < numPts; ++i)
{
const double currValue = coords[(i*3)+1];
......
......@@ -229,7 +229,7 @@ SMTKCORE_EXPORT void for_each(const CellSet& a, CellForEach &filter)
const smtk::mesh::InterfacePtr& iface = a.m_parent->interface();
filter.m_collection=a.m_parent;
iface->cellForEach(a.m_range, pc, filter);
iface->cellForEach(pc, filter);
}
}
......
......@@ -201,8 +201,7 @@ public:
const smtk::mesh::ContainsFunctor& containsFunctor) const = 0;
//----------------------------------------------------------------------------
virtual void cellForEach( const HandleRange &cells,
smtk::mesh::PointConnectivity& a,
virtual void cellForEach( smtk::mesh::PointConnectivity& a,
smtk::mesh::CellForEach& filter) const = 0;
//----------------------------------------------------------------------------
......
......@@ -154,7 +154,8 @@ public:
class SMTKCORE_EXPORT CellForEach
{
public:
virtual void operator()(int numPts,
virtual void operator()(smtk::mesh::CellType& cellType,
int numPts,
const smtk::mesh::Handle* const pointIds,
const double* const coords)=0;
......
......@@ -908,26 +908,22 @@ smtk::mesh::HandleRange Interface::pointDifference(const smtk::mesh::HandleRange
}
//----------------------------------------------------------------------------
void Interface::cellForEach(const smtk::mesh::HandleRange &cells,
smtk::mesh::PointConnectivity& pc,
void Interface::cellForEach(smtk::mesh::PointConnectivity& pc,
smtk::mesh::CellForEach& filter) const
{
if(!pc.is_empty())
{
smtk::mesh::CellType cellType;
int size=0;
const smtk::mesh::Handle* points;
std::vector<double> coords;
typedef smtk::mesh::HandleRange::const_iterator cit;
pc.initCellTraversal();
for(cit i = cells.begin(); i!= cells.end(); ++i)
{
bool validCell = pc.fetchNextCell(size, points);
if(!validCell)
{
continue;
}
for(pc.initCellTraversal();
pc.fetchNextCell(cellType, size, points) == true;
)
{
coords.reserve(size*3);
//query to grab the coordinates for these points
......@@ -936,7 +932,7 @@ void Interface::cellForEach(const smtk::mesh::HandleRange &cells,
&coords[0]);
//call the custom filter
filter(size,points,&coords[0]);
filter(cellType,size,points,&coords[0]);
}
}
return;
......
......@@ -198,8 +198,7 @@ public:
const smtk::mesh::ContainsFunctor& containsFunctor) const;
//----------------------------------------------------------------------------
void cellForEach( const HandleRange &cells,
smtk::mesh::PointConnectivity& a,
void cellForEach( smtk::mesh::PointConnectivity& a,
smtk::mesh::CellForEach& filter) const;
//----------------------------------------------------------------------------
......
......@@ -544,6 +544,9 @@ class CountCells : public smtk::mesh::CellForEach
//seen all the cells that we expect to be given
smtk::mesh::HandleRange pointsSeen;
//keep track of all the cell types we have been passed
smtk::mesh::CellTypes cellTypesSeen;
//keep a physical count of number of cells so that we can verify we
//don't iterate over a cell more than once
int numCellsVisited;
......@@ -562,19 +565,23 @@ public:
}
//--------------------------------------------------------------------------
void operator()(int numPts,
void operator()(smtk::mesh::CellType& cellType,
int numPts,
const smtk::mesh::Handle* const pointIds,
const double* const coords)
{
this->numCellsVisited++;
this->numPointsSeen += numPts;
this->pointsSeen.insert( pointIds, pointIds+numPts);
this->cellTypesSeen[static_cast<int>(cellType)] = true;
}
int numberOCellsVisited() const { return numCellsVisited; }
int numberOPointsSeen() const { return numPointsSeen; }
smtk::mesh::HandleRange points() const { return pointsSeen; }
smtk::mesh::CellTypes cellTypes() const { return cellTypesSeen; }
};
//----------------------------------------------------------------------------
......@@ -605,6 +612,13 @@ void verify_cellset_for_each(const smtk::mesh::CollectionPtr& c)
//the exact same number of cells
test( pointsFromConnectivity == functor.points() );
test( numPointsSeen == functor.numberOPointsSeen() );
//verify that the cell types that are reported are only 3D cells.
smtk::mesh::TypeSet typeSet( functor.cellTypes(), false, true );
test( typeSet.hasDimension( smtk::mesh::Dims1 ) == false );
test( typeSet.hasDimension( smtk::mesh::Dims2 ) == false );
test( typeSet.hasDimension( smtk::mesh::Dims3 ) == true );
}
......
......@@ -52,10 +52,12 @@ public:
}
//--------------------------------------------------------------------------
void operator()(int numPts,
void operator()(smtk::mesh::CellType& cellType,
int numPts,
const smtk::mesh::Handle* const pointIds,
const double* const coords)
{
(void)cellType;
(void)coords;
this->numCellsVisited++;
this->numPointsSeen += numPts;
......
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