30 :
BaseData(other), m_PointSetSeries(other.GetPointSetSeriesSize()), m_CalculateBoundingBox(true)
42 if (otherPts->GetPointData(i.Index(), &pointData))
57 m_PointSetSeries.clear();
58 Superclass::ClearData();
63 m_PointSetSeries.resize(1);
67 m_PointSetSeries[0]->SetPointData(pointData);
68 m_CalculateBoundingBox =
false;
70 Superclass::InitializeTimeGeometry(1);
78 return IsInitialized() && (GetSize(t) == 0);
91 unsigned int oldSize = m_PointSetSeries.size();
93 if (timeSteps > oldSize)
95 Superclass::Expand(timeSteps);
97 m_PointSetSeries.resize(timeSteps);
98 for (
unsigned int i = oldSize; i < timeSteps; ++i)
102 m_PointSetSeries[i]->SetPointData(pointData);
106 m_CalculateBoundingBox =
true;
108 this->InvokeEvent(PointSetExtendTimeRangeEvent());
114 return m_PointSetSeries.size();
119 if (t < m_PointSetSeries.size())
121 return m_PointSetSeries[t]->GetNumberOfPoints();
131 if (t < (
int)m_PointSetSeries.size())
133 return m_PointSetSeries[t];
143 if (t >= 0 && t < static_cast<int>(m_PointSetSeries.size()))
145 return m_PointSetSeries[t]->GetPoints()->Begin();
147 return m_EmptyPointsContainer->End();
152 if (t >= 0 && t < static_cast<int>(m_PointSetSeries.size()))
154 return m_PointSetSeries[t]->GetPoints()->Begin();
156 return m_EmptyPointsContainer->End();
161 if (t >= 0 && t < static_cast<int>(m_PointSetSeries.size()))
163 return m_PointSetSeries[t]->GetPoints()->End();
165 return m_EmptyPointsContainer->End();
170 if (t >= 0 && t < static_cast<int>(m_PointSetSeries.size()))
172 return m_PointSetSeries[t]->GetPoints()->End();
174 return m_EmptyPointsContainer->End();
179 if ((
unsigned int)t >= m_PointSetSeries.size())
181 return m_EmptyPointsContainer->End();
184 return this->Begin(t) == this->End(t) ? this->End(t) : --End(t);
189 if (t >= (
int)m_PointSetSeries.size())
199 this->GetGeometry(t)->WorldToIndex(point, indexPoint);
204 PointsContainer::Iterator it, end;
205 end = m_PointSetSeries[t]->GetPoints()->End();
207 distance = distance * distance;
218 for (it = m_PointSetSeries[t]->GetPoints()->Begin(), i = 0; it != end; ++it, ++i)
220 bool ok = m_PointSetSeries[t]->GetPoints()->GetElementIfIndexExists(it->Index(), &out);
226 else if (indexPoint == out)
232 tmp = out[0] - indexPoint[0];
234 tmp = out[1] - indexPoint[1];
236 tmp = out[2] - indexPoint[2];
241 bestIndex = it->Index();
253 if ((
unsigned int)t >= m_PointSetSeries.size())
258 if (m_PointSetSeries[t]->GetPoints()->IndexExists(
id))
260 m_PointSetSeries[t]->GetPoint(
id, &out);
261 this->GetGeometry(t)->IndexToWorld(out, out);
272 if ((
unsigned int)t >= m_PointSetSeries.size())
277 if (m_PointSetSeries[t]->GetPoints()->GetElementIfIndexExists(
id, point))
279 this->GetGeometry(t)->IndexToWorld(*point, *point);
294 this->GetGeometry(t)->WorldToIndex(point, indexPoint);
295 m_PointSetSeries[t]->SetPoint(
id, indexPoint);
297 defaultPointData.
id = id;
301 m_PointSetSeries[t]->SetPointData(
id, defaultPointData);
303 m_CalculateBoundingBox =
true;
313 this->GetGeometry(t)->WorldToIndex(point, indexPoint);
314 m_PointSetSeries[t]->SetPoint(
id, indexPoint);
316 defaultPointData.
id = id;
319 m_PointSetSeries[t]->SetPointData(
id, defaultPointData);
321 m_CalculateBoundingBox =
true;
332 if ((
unsigned int)t < m_PointSetSeries.size())
336 if (tempGeometry ==
nullptr)
338 MITK_INFO << __FILE__ <<
", l." << __LINE__ <<
": GetGeometry of " << t <<
" returned NULL!" << std::endl;
342 m_PointSetSeries[t]->GetPoints()->InsertElement(
id, indexPoint);
344 defaultPointData.
id = id;
347 m_PointSetSeries[t]->GetPointData()->InsertElement(
id, defaultPointData);
350 m_CalculateBoundingBox =
true;
361 if (m_PointSetSeries[t]->GetNumberOfPoints() > 0)
369 this->GetGeometry(t)->WorldToIndex(point, indexPoint);
370 m_PointSetSeries[t]->SetPoint(
id, indexPoint);
372 defaultPointData.
id = id;
376 m_PointSetSeries[t]->SetPointData(
id, defaultPointData);
378 m_CalculateBoundingBox =
true;
386 if ((
unsigned int)t < m_PointSetSeries.size())
388 DataType *pointSet = m_PointSetSeries[t];
393 bool exists = points->IndexExists(
id);
396 points->DeleteIndex(
id);
397 pdata->DeleteIndex(
id);
406 if ((
unsigned int)t < m_PointSetSeries.size())
408 DataType *pointSet = m_PointSetSeries[t];
418 PointsContainer::ElementIdentifier
id = (--eit).Index();
419 points->DeleteIndex(
id);
420 pdata->DeleteIndex(
id);
429 return m_EmptyPointsContainer->End();
434 if (IndexExists(
id, t))
440 if (IndexExists(
id - 1, t))
442 InsertPoint(
id, GetPoint(
id - 1, t), t);
443 InsertPoint(
id - 1, point, t);
450 if (IndexExists(
id + 1, t))
452 InsertPoint(
id, GetPoint(
id + 1, t), t);
453 InsertPoint(
id + 1, point, t);
464 if ((
unsigned int)t < m_PointSetSeries.size())
466 return m_PointSetSeries[t]->GetPoints()->IndexExists(position);
476 if (this->IndexExists(position, t))
479 m_PointSetSeries[t]->GetPointData(position, &pointData);
490 if (this->IndexExists(position, t))
493 TimePointType timeInMS = this->GetTimeGeometry()->TimeStepToTimePoint(t);
496 Point3D point = this->GetPoint(position, t);
498 std::unique_ptr<PointOperation> op;
508 this->ExecuteOperation(op.get());
514 if (this->IndexExists(position, t))
517 m_PointSetSeries[t]->GetPointData(position, &pointData);
528 if ((
unsigned int)t >= m_PointSetSeries.size())
533 int numberOfSelected = 0;
535 for (it = m_PointSetSeries[t]->GetPointData()->Begin(); it != m_PointSetSeries[t]->GetPointData()->End(); it++)
537 if (it->Value().selected ==
true)
543 return numberOfSelected;
548 if ((
unsigned int)t >= m_PointSetSeries.size())
554 for (it = m_PointSetSeries[t]->GetPointData()->Begin(); it != m_PointSetSeries[t]->GetPointData()->End(); it++)
556 if (it->Value().selected ==
true)
572 timeStep = this->GetTimeGeometry()->TimePointToTimeStep(pointOp->GetTimeInMS());
577 MITK_ERROR <<
"Time step (" << timeStep <<
") outside of PointSet time bounds" << std::endl;
588 int position = pointOp->GetIndex();
591 pt.CastFrom(pointOp->GetPoint());
593 if (timeStep >= (
int)this->GetTimeSteps())
594 this->Expand(timeStep + 1);
598 if (geometry ==
nullptr)
600 MITK_INFO <<
"GetGeometry returned NULL!\n";
605 m_PointSetSeries[timeStep]->GetPoints()->InsertElement(position, pt);
608 static_cast<unsigned int>(pointOp->GetIndex()), pointOp->GetSelected(), pointOp->GetPointType()};
610 m_PointSetSeries[timeStep]->GetPointData()->InsertElement(position, pointData);
615 m_CalculateBoundingBox =
true;
617 this->InvokeEvent(PointSetAddEvent());
618 this->OnPointSetChange();
625 pt.CastFrom(pointOp->GetPoint());
628 this->GetGeometry(timeStep)->WorldToIndex(pt, pt);
631 m_PointSetSeries[timeStep]->SetPoint(pointOp->GetIndex(), pt);
636 if (!m_PointSetSeries[timeStep]->GetPointData(pointOp->GetIndex(), &pointData))
638 m_PointSetSeries[timeStep]->SetPointData(pointOp->GetIndex(), pointData);
641 this->OnPointSetChange();
646 m_CalculateBoundingBox =
true;
648 this->InvokeEvent(PointSetMoveEvent());
654 m_PointSetSeries[timeStep]->GetPoints()->DeleteIndex((
unsigned)pointOp->GetIndex());
655 m_PointSetSeries[timeStep]->GetPointData()->DeleteIndex((
unsigned)pointOp->GetIndex());
657 this->OnPointSetChange();
661 m_CalculateBoundingBox =
true;
663 this->InvokeEvent(PointSetRemoveEvent());
670 m_PointSetSeries[timeStep]->GetPointData(pointOp->GetIndex(), &pointData);
672 m_PointSetSeries[timeStep]->SetPointData(pointOp->GetIndex(), pointData);
680 m_PointSetSeries[timeStep]->GetPointData(pointOp->GetIndex(), &pointData);
682 m_PointSetSeries[timeStep]->SetPointData(pointOp->GetIndex(), pointData);
690 m_PointSetSeries[timeStep]->GetPointData(pointOp->GetIndex(), &pointData);
691 pointData.
pointSpec = pointOp->GetPointType();
692 m_PointSetSeries[timeStep]->SetPointData(pointOp->GetIndex(), pointData);
702 PointsContainer::STLContainerType points = m_PointSetSeries[timeStep]->GetPoints()->CastToSTLContainer();
703 auto it = points.find(currentID);
704 if (it == points.end())
706 if (it == points.begin())
712 if (this->SwapPointContents(prevID, currentID, timeStep) ==
true)
720 PointsContainer::STLContainerType points = m_PointSetSeries[timeStep]->GetPoints()->CastToSTLContainer();
721 auto it = points.find(currentID);
722 if (it == points.end())
725 if (it == points.end())
730 if (this->SwapPointContents(nextID, currentID, timeStep) ==
true)
736 itkWarningMacro(
"mitkPointSet could not understrand the operation. Please check!");
745 ((
const itk::Object *)
this)->InvokeEvent(endevent);
754 if (this->GetSource())
756 this->GetSource()->UpdateOutputInformation();
764 if (timeGeometry->CountTimeSteps() != m_PointSetSeries.size())
766 itkExceptionMacro(<<
"timeGeometry->CountTimeSteps() != m_PointSetSeries.size() -- use Initialize(timeSteps) with "
767 "correct number of timeSteps!");
778 if (m_CalculateBoundingBox)
780 for (
unsigned int i = 0; i < m_PointSetSeries.size(); ++i)
785 if (m_PointSetSeries[i].IsNull() || (m_PointSetSeries[i]->GetNumberOfPoints() == 0) ||
786 (itkBounds == itkBoundsNull))
788 itkBounds = itkBoundsNull;
793 for (
unsigned int j = 0; j < 3; ++j)
795 if (itkBounds[j * 2 + 1] - itkBounds[j * 2] < 1.0)
797 BoundingBox::CoordRepType center = (itkBounds[j * 2] + itkBounds[j * 2 + 1]) / 2.0;
798 itkBounds[j * 2] = center - 0.5;
799 itkBounds[j * 2 + 1] = center + 0.5;
802 this->GetGeometry(i)->SetBounds(itkBounds);
804 m_CalculateBoundingBox =
false;
806 this->GetTimeGeometry()->Update();
829 Superclass::PrintSelf(os, indent);
831 os << indent <<
"Number timesteps: " << m_PointSetSeries.size() <<
"\n";
833 for (
auto it = m_PointSetSeries.begin(); it != m_PointSetSeries.end(); ++it)
835 os << indent <<
"Timestep " << i++ <<
": \n";
837 itk::Indent nextIndent = indent.GetNextIndent();
838 ps->Print(os, nextIndent);
839 MeshType::PointsContainer *points = ps->GetPoints();
840 MeshType::PointDataContainer *datas = ps->GetPointData();
841 MeshType::PointDataContainer::Iterator dataIterator = datas->Begin();
842 for (MeshType::PointsContainer::Iterator pointIterator = points->Begin(); pointIterator != points->End();
843 ++pointIterator, ++dataIterator)
845 os << nextIndent <<
"Point " << pointIterator->Index() <<
": [";
846 os << pointIterator->Value().GetElement(0);
847 for (
unsigned int i = 1; i < PointType::GetPointDimension(); ++i)
849 os <<
", " << pointIterator->Value().GetElement(i);
852 os <<
", selected: " << dataIterator->Value().selected <<
", point spec: " << dataIterator->Value().pointSpec
862 if (m_PointSetSeries[timeStep]->GetPoint(id1, &p1) ==
false)
865 if (m_PointSetSeries[timeStep]->GetPointData(id1, &data1) ==
false)
868 if (m_PointSetSeries[timeStep]->GetPoint(id2, &p2) ==
false)
871 if (m_PointSetSeries[timeStep]->GetPointData(id2, &data2) ==
false)
874 m_PointSetSeries[timeStep]->SetPoint(id1, p2);
875 m_PointSetSeries[timeStep]->SetPointData(id1, data2);
876 m_PointSetSeries[timeStep]->SetPoint(id2, p1);
877 m_PointSetSeries[timeStep]->SetPointData(id2, data1);
892 if ((leftHandSide ==
nullptr) || (rightHandSide ==
nullptr))
894 MITK_ERROR <<
"mitk::Equal( const mitk::PointSet* leftHandSide, const mitk::PointSet* rightHandSide, "
895 "mitk::ScalarType eps, bool verbose ) does not work with NULL pointer input.";
898 return Equal(*leftHandSide, *rightHandSide, eps, verbose, checkGeometry);
916 MITK_INFO <<
"[( PointSet )] Geometries differ.";
924 MITK_INFO <<
"[( PointSet )] Number of points differ.";
933 int numberOfIncorrectPoints = 0;
938 pointSetIteratorRight = rightHandSide.
Begin();
939 pointSetIteratorLeft != end;
940 ++pointSetIteratorLeft, ++pointSetIteratorRight)
942 pointLeftHandSide = pointSetIteratorLeft.Value();
943 pointRightHandSide = pointSetIteratorRight.Value();
944 if (!
mitk::Equal(pointLeftHandSide, pointRightHandSide, eps, verbose))
947 MITK_INFO <<
"[( PointSet )] Point values are different.";
949 numberOfIncorrectPoints++;
953 if ((numberOfIncorrectPoints > 0) && verbose)
955 MITK_INFO << numberOfIncorrectPoints <<
" of a total of " << leftHandSide.
GetSize() <<
" points are different.";
DataType::PointsContainerIterator PointsIterator
PointsIterator GetMaxId(int t=0)
Get an iterator to the max ID element if existent. Return End() otherwise.
virtual unsigned int GetPointSetSeriesSize() const
itk::SmartPointer< Self > Pointer
virtual void PrintSelf(std::ostream &os, itk::Indent indent) const override
print content of the object to os
virtual void Expand(unsigned int timeSteps) override
Expands the TimeGeometry to a number of TimeSteps.
DataType::PointDataContainer PointDataContainer
virtual int GetSize(unsigned int t=0) const
returns the current size of the point-list
Base of all data objects.
Base class of all Operation-classes.
virtual void SetRequestedRegionToLargestPossibleRegion() override
Set the RequestedRegion to the LargestPossibleRegion.
virtual void ExecuteOperation(Operation *operation) override
executes the given Operation
bool SwapPointContents(PointIdentifier id1, PointIdentifier id2, int t=0)
swaps point coordinates and point data of the points with identifiers id1 and id2 ...
#define mitkCheckOperationTypeMacro(OperationType, operation, newOperationName)
struct for data of a point
PointType GetPoint(PointIdentifier id, int t=0) const
Get the point with ID id in world coordinates.
virtual PointSpecificationType GetSpecificationTypeInfo(int position, int t) const
to get the type of the point at the position and the moment
int SearchPoint(Point3D point, ScalarType distance, int t=0) const
searches a point in the list == point +/- distance
mitk::PointSpecificationType pointSpec
Constants for most interaction classes, due to the generic StateMachines.
virtual void ClearData() override
reset to non-initialized state, release memory
DataType::PointsContainer::ConstIterator PointsConstIterator
virtual void InitializeEmpty() override
Pure virtual; Must be used in subclasses to get a data object to a valid state. Should at least creat...
bool SwapPointPosition(PointIdentifier id, bool moveUpwards, int t=0)
Swap a point at the given position (id) with the upper point (moveUpwards=true) or with the lower poi...
PointSetSeries m_PointSetSeries
virtual void SetSelectInfo(int position, bool selected, int t=0)
virtual bool RequestedRegionIsOutsideOfTheBufferedRegion() override
Determine whether the RequestedRegion is outside of the BufferedRegion.
DataType::PointIdentifier PointIdentifier
bool RemovePointIfExists(PointIdentifier id, int t=0)
Remove point with given id at timestep t, if existent.
Data structure which stores a set of points. Superclass of mitk::Mesh.
virtual DataType::Pointer GetPointSet(int t=0) const
returns the pointset
itk::BoundingBox< unsigned long, 3, mitk::ScalarType > BoundingBoxType
virtual int SearchSelectedPoint(int t=0) const
searches a selected point and returns the id of that point. If no point is found, then -1 is returned...
Operation that handles all actions on one Point.
void InsertPoint(PointIdentifier id, PointType point, int t=0)
Set the given point in world coordinate system into the itkPointSet.
mitk::ScalarType TimePointType
bool operator==(const PointDataType &other) const
PointsIterator RemovePointAtEnd(int t=0)
Remove max id point at timestep t and return iterator to precedent point.
DataType::PointsContainer PointsContainer
void SetPoint(PointIdentifier id, PointType point, int t=0)
Set the given point in world coordinate system into the itkPointSet.
MITKNEWMODULE_EXPORT bool Equal(mitk::ExampleDataStructure *leftHandSide, mitk::ExampleDataStructure *rightHandSide, mitk::ScalarType eps, bool verbose)
Returns true if the example data structures are considered equal.
virtual int GetNumberOfSelected(int t=0) const
returns the number of selected points
virtual bool IndexExists(int position, int t=0) const
returns true if a point exists at this position
virtual bool VerifyRequestedRegion() override
Verify that the RequestedRegion is within the LargestPossibleRegion.
MITKCORE_EXPORT const ScalarType eps
bool GetPointIfExists(PointIdentifier id, PointType *point, int t=0) const
Get the point with ID id in world coordinates.
PointsIterator Begin(int t=0)
virtual bool IsEmptyTimeStep(unsigned int t) const override
Check whether object contains data (at a specified time), e.g., a set of points may be empty...
DataType::PointDataContainerIterator PointDataIterator
OperationType GetOperationType()
virtual void UpdateOutputInformation() override
mitk::BaseGeometry * GetGeometry(int t=0) const
Return the geometry, which is a TimeGeometry, of the data as non-const pointer.
PointSpecificationType
enumeration of the type a point can be
PointsIterator End(int t=0)
BaseGeometry Describes the geometry of a data object.
BoundingBoxType::BoundsArrayType BoundsArrayType
virtual void SetRequestedRegion(const itk::DataObject *data) override
Set the requested region from this data object to match the requested region of the data object passe...
void WorldToIndex(const mitk::Point3D &pt_mm, mitk::Point3D &pt_units) const
Convert world coordinates (in mm) of a point to (continuous!) index coordinates.
virtual bool GetSelectInfo(int position, int t=0) const
to get the state selected/unselected of the point on the position
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.