int
main(int, char *[])
{
using PixelType = float;
using CellType = MeshType::CellType;
constexpr unsigned int numberOfPoints = 10;
for (unsigned int id = 0; id < numberOfPoints; ++id)
{
point[0] =
static_cast<PointType::ValueType
>(id);
mesh->SetPoint(
id,
point);
}
CellType::CellAutoPointer line;
constexpr unsigned int numberOfCells = numberOfPoints - 1;
for (unsigned int cellId = 0; cellId < numberOfCells; ++cellId)
{
line.TakeOwnership(new LineType);
line->SetPointId(0, cellId);
line->SetPointId(1, cellId + 1);
mesh->SetCell(cellId, line);
}
std::cout << "Points = " << mesh->GetNumberOfPoints() << std::endl;
std::cout << "Cells = " << mesh->GetNumberOfCells() << std::endl;
for (unsigned int cellId = 0; cellId < numberOfCells; ++cellId)
{
mesh->SetCellData(cellId, static_cast<PixelType>(cellId * cellId));
}
for (unsigned int cellId = 0; cellId < numberOfCells; ++cellId)
{
auto value = static_cast<PixelType>(0.0);
mesh->GetCellData(cellId, &value);
std::cout << "Cell " << cellId << " = " << value << std::endl;
}
using CellDataIterator = MeshType::CellDataContainer::ConstIterator;
CellDataIterator cellDataIterator = mesh->GetCellData()->Begin();
const CellDataIterator end = mesh->GetCellData()->End();
while (cellDataIterator != end)
{
const PixelType cellValue = cellDataIterator.Value();
std::cout << cellValue << std::endl;
++cellDataIterator;
}
return EXIT_SUCCESS;
}
Represents a line segment for a Mesh.
Implements the N-dimensional mesh structure.
ImageBaseType::PointType PointType
static constexpr double eps
*par Constraints *The filter image with at least two dimensions and a vector *length of at least The theory supports extension to scalar but *the implementation of the itk vector classes do not **The template parameter TRealType must be floating point(float or double) or *a user-defined "real" numerical type with arithmetic operations defined *sufficient to compute derivatives. **\par Performance *This filter will automatically multithread if run with *SetUsePrincipleComponents