diff --git a/Modules/Core/Common/include/itkPolyLineCell.h b/Modules/Core/Common/include/itkPolyLineCell.h index b5c3f1bafe3..55e5067848c 100644 --- a/Modules/Core/Common/include/itkPolyLineCell.h +++ b/Modules/Core/Common/include/itkPolyLineCell.h @@ -78,6 +78,9 @@ class ITK_TEMPLATE_EXPORT PolyLineCell : public TCellInterface bool GetBoundaryFeature(int dimension, CellFeatureIdentifier, CellAutoPointer &) override; + void + InitializePoints(); + void ClearPoints(); @@ -114,16 +117,21 @@ class ITK_TEMPLATE_EXPORT PolyLineCell : public TCellInterface /** Visitor interface */ itkCellVisitMacro(CellGeometryEnum::LINE_CELL); - /** Constructor and destructor */ - PolyLineCell() = default; - PolyLineCell(PointIdentifier NumberOfPoints) + void + InitializePoints(PointIdentifier numberOfPoints) { - for (PointIdentifier i = 0; i < NumberOfPoints; ++i) + m_PointIds.clear(); + for (PointIdentifier i = 0; i < numberOfPoints; ++i) { m_PointIds.push_back(NumericTraits::max()); } } + /** Constructor and destructor */ + PolyLineCell() { InitializePoints(2); } + + PolyLineCell(PointIdentifier numberOfPoints) { InitializePoints(numberOfPoints); } + ~PolyLineCell() override = default; protected: diff --git a/Modules/Core/Common/include/itkPolyLineCell.hxx b/Modules/Core/Common/include/itkPolyLineCell.hxx index 32c05075220..fadafd6a497 100644 --- a/Modules/Core/Common/include/itkPolyLineCell.hxx +++ b/Modules/Core/Common/include/itkPolyLineCell.hxx @@ -242,7 +242,7 @@ template void PolyLineCell::ClearPoints() { - m_PointIds.clear(); + InitializePoints(2); }