26 :
mitk::
BaseData(other), m_ContourSeries(other.m_ContourSeries), m_lineInterpolation(other.m_lineInterpolation)
33 m_SelectedVertex =
nullptr;
34 this->m_ContourSeries.clear();
39 if (!this->IsEmptyTimeStep(timestep))
41 this->AddVertex(vertex,
false, timestep);
47 if (!this->IsEmptyTimeStep(timestep))
49 this->m_ContourSeries[timestep]->AddVertex(vertex, isControlPoint);
50 this->InvokeEvent(ContourModelSizeChangeEvent());
52 this->m_UpdateBoundingBox =
true;
58 if (!this->IsEmptyTimeStep(timestep))
60 this->m_ContourSeries[timestep]->AddVertex(vertex);
61 this->InvokeEvent(ContourModelSizeChangeEvent());
63 this->m_UpdateBoundingBox =
true;
69 if (vertex !=
nullptr)
71 this->m_ContourSeries[timestep]->AddVertex(*const_cast<VertexType *>(vertex));
77 if (!this->IsEmptyTimeStep(timestep))
79 this->AddVertexAtFront(vertex,
false, timestep);
85 if (!this->IsEmptyTimeStep(timestep))
87 this->m_ContourSeries[timestep]->AddVertexAtFront(vertex, isControlPoint);
88 this->InvokeEvent(ContourModelSizeChangeEvent());
90 this->m_UpdateBoundingBox =
true;
96 if (!this->IsEmptyTimeStep(timestep))
98 this->m_ContourSeries[timestep]->AddVertexAtFront(vertex);
99 this->InvokeEvent(ContourModelSizeChangeEvent());
101 this->m_UpdateBoundingBox =
true;
107 if (!this->IsEmptyTimeStep(timestep))
109 if (pointId >= 0 && this->m_ContourSeries[timestep]->GetSize() > pointId)
111 this->m_ContourSeries[timestep]->SetVertexAt(pointId, point);
113 this->m_UpdateBoundingBox =
true;
123 if (vertex ==
nullptr)
126 if (!this->IsEmptyTimeStep(timestep))
128 if (pointId >= 0 && this->m_ContourSeries[timestep]->GetSize() > pointId)
130 this->m_ContourSeries[timestep]->SetVertexAt(pointId, vertex);
132 this->m_UpdateBoundingBox =
true;
142 if (!this->IsEmptyTimeStep(timestep))
144 if (index >= 0 && this->m_ContourSeries[timestep]->GetSize() > index)
146 this->m_ContourSeries[timestep]->InsertVertexAtIndex(vertex, isControlPoint, index);
147 this->InvokeEvent(ContourModelSizeChangeEvent());
149 this->m_UpdateBoundingBox =
true;
156 if (!this->IsEmptyTimeStep(timestep))
158 return this->m_ContourSeries[timestep]->IsEmpty();
165 return this->IsEmpty(0);
170 if (!this->IsEmptyTimeStep(timestep))
172 return this->m_ContourSeries[timestep]->GetSize();
179 if (!this->IsEmptyTimeStep(timestep))
181 return this->m_ContourSeries[timestep]->GetVertexAt(index);
188 if (!this->IsEmptyTimeStep(timestep))
190 return this->m_ContourSeries[timestep]->GetIndex(vertex);
197 if (!this->IsEmptyTimeStep(timestep))
199 this->m_ContourSeries[timestep]->Close();
200 this->InvokeEvent(ContourModelClosedEvent());
202 this->m_UpdateBoundingBox =
true;
208 if (!this->IsEmptyTimeStep(timestep))
210 this->m_ContourSeries[timestep]->Open();
211 this->InvokeEvent(ContourModelClosedEvent());
213 this->m_UpdateBoundingBox =
true;
219 if (!this->IsEmptyTimeStep(timestep))
221 this->m_ContourSeries[timestep]->SetClosed(isClosed);
222 this->InvokeEvent(ContourModelClosedEvent());
224 this->m_UpdateBoundingBox =
true;
230 return (this->m_ContourSeries.size() <= t);
235 if (!this->IsEmptyTimeStep(timestep))
237 return this->m_ContourSeries[timestep]->IsNearContour(point, eps);
244 if (!this->IsEmptyTimeStep(timestep))
246 if (!this->m_ContourSeries[timestep]->IsClosed())
248 this->m_ContourSeries[timestep]->Concatenate(other->
m_ContourSeries[timestep], check);
249 this->InvokeEvent(ContourModelSizeChangeEvent());
251 this->m_UpdateBoundingBox =
true;
258 return this->IteratorBegin(timestep);
263 if (!this->IsEmptyTimeStep(timestep))
265 return this->m_ContourSeries[timestep]->IteratorBegin();
269 mitkThrow() <<
"No iterator at invalid timestep " << timestep <<
". There are only " << this->GetTimeSteps()
270 <<
" timesteps available.";
276 return this->IteratorEnd(timestep);
281 if (!this->IsEmptyTimeStep(timestep))
283 return this->m_ContourSeries[timestep]->IteratorEnd();
287 mitkThrow() <<
"No iterator at invalid timestep " << timestep <<
". There are only " << this->GetTimeSteps()
288 <<
" timesteps available.";
294 if (!this->IsEmptyTimeStep(timestep))
296 return this->m_ContourSeries[timestep]->IsClosed();
303 if (!this->IsEmptyTimeStep(timestep))
305 this->m_SelectedVertex = this->m_ContourSeries[timestep]->GetVertexAt(point, eps);
307 return this->m_SelectedVertex !=
nullptr;
312 if (!this->IsEmptyTimeStep(timestep) && index >= 0)
314 return (this->m_SelectedVertex = this->m_ContourSeries[timestep]->GetVertexAt(index));
321 if (!this->IsEmptyTimeStep(timestep))
323 VertexType *vertex = this->m_ContourSeries[timestep]->GetVertexAt(point, eps);
324 if (vertex !=
nullptr)
335 if (!this->IsEmptyTimeStep(timestep) && index >= 0)
337 VertexType *vertex = this->m_ContourSeries[timestep]->GetVertexAt(index);
338 if (vertex !=
nullptr)
349 if (!this->IsEmptyTimeStep(timestep))
351 if (this->m_ContourSeries[timestep]->RemoveVertex(vertex))
354 this->m_UpdateBoundingBox =
true;
355 this->InvokeEvent(ContourModelSizeChangeEvent());
364 if (!this->IsEmptyTimeStep(timestep))
366 if (this->m_ContourSeries[timestep]->RemoveVertexAt(index))
369 this->m_UpdateBoundingBox =
true;
370 this->InvokeEvent(ContourModelSizeChangeEvent());
379 if (!this->IsEmptyTimeStep(timestep))
381 if (this->m_ContourSeries[timestep]->RemoveVertexAt(point, eps))
384 this->m_UpdateBoundingBox =
true;
385 this->InvokeEvent(ContourModelSizeChangeEvent());
394 if (this->m_SelectedVertex)
396 this->ShiftVertex(this->m_SelectedVertex, translate);
398 this->m_UpdateBoundingBox =
true;
404 if (!this->IsEmptyTimeStep(timestep))
406 VertexListType *vList = this->m_ContourSeries[timestep]->GetVertexList();
407 auto it = vList->begin();
408 auto end = vList->end();
413 this->ShiftVertex((*it), translate);
418 this->m_UpdateBoundingBox =
true;
419 this->InvokeEvent(ContourModelShiftEvent());
432 if (!this->IsEmptyTimeStep(timestep))
435 this->m_ContourSeries[timestep]->Clear();
436 this->InitializeEmpty();
438 this->m_UpdateBoundingBox =
true;
444 std::size_t oldSize = this->m_ContourSeries.size();
446 if (static_cast<std::size_t>(timeSteps) > oldSize)
448 Superclass::Expand(timeSteps);
451 for (std::size_t i = oldSize; i < static_cast<std::size_t>(timeSteps); i++)
456 this->InvokeEvent(ContourModelExpandTimeBoundsEvent());
479 return Superclass::GetUpdatedGeometry(t);
484 return Superclass::GetGeometry(t);
496 this->InitializeEmpty();
498 this->m_UpdateBoundingBox =
true;
503 if (!this->IsEmptyTimeStep(timestep))
505 this->m_ContourSeries[timestep]->RedistributeControlVertices(this->GetSelectedVertex(), period);
506 this->InvokeEvent(ContourModelClosedEvent());
508 this->m_UpdateBoundingBox =
true;
515 Superclass::ClearData();
518 this->m_ContourSeries.clear();
523 this->InitializeEmpty();
525 this->m_UpdateBoundingBox =
true;
531 this->InitializeTimeGeometry(numberOfTimesteps);
533 for (
mitk::TimeStepType currentTimestep = 0; currentTimestep < numberOfTimesteps; currentTimestep++)
536 this->SetClosed(other.
IsClosed(currentTimestep), currentTimestep);
539 m_SelectedVertex =
nullptr;
542 this->m_UpdateBoundingBox =
true;
548 this->m_ContourSeries.resize(0);
552 this->InitializeTimeGeometry(1);
554 m_SelectedVertex =
nullptr;
560 if (this->GetSource())
562 this->GetSource()->UpdateOutputInformation();
565 if (this->m_UpdateBoundingBox)
571 typedef itk::BoundingBox<unsigned long, 3, ScalarType>
BoundingBoxType;
572 typedef BoundingBoxType::PointsContainer PointsContainer;
574 int timesteps = this->GetTimeSteps();
577 for (
int currenTimeStep = 0; currenTimeStep < timesteps; currenTimeStep++)
579 if (dynamic_cast<mitk::PlaneGeometry *>(this->GetGeometry(currenTimeStep)))
587 if (this->GetMTime() > this->GetGeometry(currenTimeStep)->GetBoundingBox()->GetMTime())
600 auto it = this->IteratorBegin(currenTimeStep);
601 auto end = this->IteratorEnd(currenTimeStep);
606 Point3D currentP = (*it)->Coordinates;
608 p.CastFrom(currentP);
609 points->InsertElement(points->Size(), p);
615 boundingBox->SetPoints(points);
616 boundingBox->ComputeBoundingBox();
618 mitkBounds[0] = tmp[0];
619 mitkBounds[1] = tmp[1];
620 mitkBounds[2] = tmp[2];
621 mitkBounds[3] = tmp[3];
622 mitkBounds[4] = tmp[4];
623 mitkBounds[5] = tmp[5];
626 BaseGeometry *geometry3d = this->GetGeometry(currenTimeStep);
631 this->m_UpdateBoundingBox =
false;
633 GetTimeGeometry()->Update();
bool RemoveVertexAt(int index, int timestep=0)
Remove a vertex at given index within the container.
ContourModel is a structure of linked vertices defining a contour in 3D space. The vertices are store...
itk::SmartPointer< Self > Pointer
virtual void UpdateOutputInformation() override
Update the OutputInformation of a ContourModel object.
void Concatenate(mitk::ContourModel *other, int timestep=0, bool check=false)
Concatenate two contours. The starting control point of the other will be added at the end of the con...
virtual void SetClosed(bool isClosed, int timestep=0)
Set closed property to given boolean.
mitk::Point3D Coordinates
Coordinates in 3D space.
void ShiftVertex(VertexType *vertex, mitk::Vector3D &vector)
virtual void Initialize() override
Initialize all data objects.
VertexIterator End(int timestep=0) const
Returns a const VertexIterator at the end element of the contour.
Base of all data objects.
virtual bool VerifyRequestedRegion() override
Inherit from base data - no region support available for contourModel objects.
Base class of all Operation-classes.
mitk::ContourElement::VertexIterator VertexIterator
DataCollection - Class to facilitate loading/accessing structured data.
const mitk::TimeGeometry * GetTimeGeometry() const
Return the TimeGeometry of the data as const pointer.
bool IsControlPoint
Treat point special.
VertexIterator IteratorBegin(int timestep=0) const
Returns a const VertexIterator at the start element of the contour.
bool SelectVertexAt(int index, int timestep=0)
Mark a vertex at an index in the container as selected.
virtual void SetRequestedRegionToLargestPossibleRegion() override
Inherit from base data - no region support available for contourModel objects.
void AddVertex(mitk::Point3D &vertex, int timestep=0)
Add a vertex to the contour at given timestep. The vertex is added at the end of contour.
virtual bool IsNearContour(mitk::Point3D &point, float eps, int timestep)
Check if mouse cursor is near the contour.
virtual void Close(int timestep=0)
Close the contour. The last control point will be linked with the first point.
virtual const mitk::BaseGeometry * GetUpdatedGeometry(int t=0)
Get the updated geometry with recomputed bounds.
int GetIndex(const VertexType *vertex, int timestep=0)
Remove a vertex at given timestep within the container.
ContourModelSeries m_ContourSeries
virtual bool IsEmptyTimeStep(unsigned int t) const override
Check if there isn't something at this timestep.
virtual void Expand(unsigned int timeSteps) override
Expand the timebounds of the TimeGeometry to given number of timesteps.
virtual bool IsEmpty() const override
Returns whether the contour model is empty.
virtual void ClearData() override
reset to non-initialized state, release memory
itk::BoundingBox< unsigned long, 3, mitk::ScalarType > BoundingBoxType
virtual void SetRequestedRegion(const itk::DataObject *data) override
Inherit from base data - no region support available for contourModel objects.
void ShiftSelectedVertex(mitk::Vector3D &translate)
Shift the currently selected vertex by a translation vector.
virtual mitk::BaseGeometry * GetGeometry(int t=0) const
Get the BaseGeometry for timestep t.
std::vcl_size_t TimeStepType
void ShiftContour(mitk::Vector3D &translate, int timestep=0)
Shift the whole contour by a translation vector at given timestep.
virtual void Clear() override
Clear the storage container.
virtual void RedistributeControlVertices(int period, int timestep)
Redistributes ontrol vertices with a given period (as number of vertices)
void ExecuteOperation(Operation *operation) override
overwrite if the Data can be called by an Interactor (StateMachine).
void SetBounds(const BoundsArrayType &bounds)
Set the bounding box (in index/unit coordinates)
VertexType * m_SelectedVertex
LineSegmentInterpolation m_lineInterpolation
bool IsClosed(int timestep=0) const
Return if the contour is closed or not.
virtual void InitializeEmpty() override
Pure virtual; Must be used in subclasses to get a data object to a valid state. Should at least creat...
VertexIterator Begin(int timestep=0) const
Returns a const VertexIterator at the start element of the contour.
virtual bool RequestedRegionIsOutsideOfTheBufferedRegion() override
Inherit from base data - no region support available for contourModel objects.
MITKCORE_EXPORT const ScalarType eps
mitk::ContourElement::VertexListType VertexListType
void AddVertexAtFront(mitk::Point3D &vertex, int timestep=0)
Add a vertex to the contour at given timestep AT THE FRONT of the contour. The vertex is added at the...
void InsertVertexAtIndex(mitk::Point3D &vertex, int index, bool isControlPoint=false, int timestep=0)
Insert a vertex at given index.
bool RemoveVertex(const VertexType *vertex, int timestep=0)
Remove a vertex at given timestep within the container.
VertexIterator IteratorEnd(int timestep=0) const
Returns a const VertexIterator at the end element of the contour.
bool SetControlVertexAt(int index, int timestep=0)
Mark a vertex at an index in the container as control point.
Represents a single vertex of contour.
bool SetVertexAt(int pointId, const mitk::Point3D &point, unsigned int timestep=0)
Set a coordinates for point at given index.
BaseGeometry Describes the geometry of a data object.
virtual void Open(int timestep=0)
Set isClosed to false contour. The link between the last control point the first point will be remove...
BoundingBoxType::BoundsArrayType BoundsArrayType
virtual const VertexType * GetVertexAt(int index, int timestep=0) const
Returns the vertex at the index position within the container.
int GetNumberOfVertices(int timestep=0) const
Returns the number of vertices at a given timestep.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.