15 #include "ipSegmentation.h" 30 m_PaintingPixelValue(paintingPixelValue),
57 Superclass::Activated();
75 Superclass::Deactivated();
105 int radius = (
m_Size) / 2;
106 float fradius =
static_cast<float>(
m_Size) / 2.0f;
114 centerCorrection.Fill(0);
117 bool evenSize = ((
m_Size % 2) == 0);
120 centerCorrection[0] += 0.5;
121 centerCorrection[1] += 0.5;
125 std::vector<mitk::Point2D> quarterCycleUpperRight;
126 std::vector<mitk::Point2D> quarterCycleLowerRight;
127 std::vector<mitk::Point2D> quarterCycleLowerLeft;
128 std::vector<mitk::Point2D> quarterCycleUpperLeft;
131 bool curPointIsInside =
true;
133 curPoint[1] = radius;
134 quarterCycleUpperRight.push_back(
upperLeft(curPoint));
140 while (curPoint[1] > 0)
143 float curPointX_squared = 0.0f;
144 float curPointY_squared = (curPoint[1] - centerCorrection[1]) * (curPoint[1] - centerCorrection[1]);
145 while (curPointIsInside)
149 curPointX_squared = (curPoint[0] - centerCorrection[0]) * (curPoint[0] - centerCorrection[0]);
150 const float len = sqrt(curPointX_squared + curPointY_squared);
154 curPointIsInside =
false;
157 quarterCycleUpperRight.push_back(
upperLeft(curPoint));
160 while (!curPointIsInside)
164 curPointY_squared = (curPoint[1] - centerCorrection[1]) * (curPoint[1] - centerCorrection[1]);
165 const float len = sqrt(curPointX_squared + curPointY_squared);
169 curPointIsInside =
true;
170 quarterCycleUpperRight.push_back(
upperLeft(curPoint));
174 if (curPoint[1] <= 0)
183 std::vector<mitk::Point2D>::const_iterator it = quarterCycleUpperRight.begin();
184 while (it != quarterCycleUpperRight.end())
191 quarterCycleLowerRight.push_back(p);
196 quarterCycleLowerLeft.push_back(p);
201 quarterCycleUpperLeft.push_back(p);
208 std::vector<mitk::Point2D>::const_iterator it = quarterCycleUpperRight.begin();
209 while (it != quarterCycleUpperRight.end())
220 quarterCycleLowerRight.push_back(q);
225 q[1] = -1.0f * q[1] + 1;
226 q[0] = -1.0f * q[0] + 1;
227 quarterCycleLowerLeft.push_back(q);
234 quarterCycleUpperLeft.push_back(q);
242 for (
unsigned int i = 0; i < quarterCycleUpperRight.size(); i++)
244 tempPoint[0] = quarterCycleUpperRight[i][0];
245 tempPoint[1] = quarterCycleUpperRight[i][1];
247 contourInImageIndexCoordinates->AddVertex(tempPoint);
250 for (
int i = quarterCycleLowerRight.size() - 1; i >= 0; i--)
252 tempPoint[0] = quarterCycleLowerRight[i][0];
253 tempPoint[1] = quarterCycleLowerRight[i][1];
255 contourInImageIndexCoordinates->AddVertex(tempPoint);
257 for (
unsigned int i = 0; i < quarterCycleLowerLeft.size(); i++)
259 tempPoint[0] = quarterCycleLowerLeft[i][0];
260 tempPoint[1] = quarterCycleLowerLeft[i][1];
262 contourInImageIndexCoordinates->AddVertex(tempPoint);
265 for (
int i = quarterCycleUpperLeft.size() - 1; i >= 0; i--)
267 tempPoint[0] = quarterCycleUpperLeft[i][0];
268 tempPoint[1] = quarterCycleUpperLeft[i][1];
270 contourInImageIndexCoordinates->AddVertex(tempPoint);
336 Point3D worldCoordinates = positionEvent->GetPositionInWorld();
339 m_WorkingSlice->GetGeometry()->WorldToIndex(worldCoordinates, indexCoordinates);
344 indexCoordinates[0] = std::round(indexCoordinates[0]);
345 indexCoordinates[1] = std::round(indexCoordinates[1]);
349 indexCoordinates[0] = std::round(indexCoordinates[0]);
350 indexCoordinates[1] = std::round(indexCoordinates[1]);
354 if (fabs(indexCoordinates[0] - lastPos[0]) >
mitk::eps || fabs(indexCoordinates[1] - lastPos[1]) >
mitk::eps ||
355 fabs(indexCoordinates[2] - lastPos[2]) >
mitk::eps || leftMouseButtonPressed)
357 lastPos = indexCoordinates;
364 int t = positionEvent->GetSender()->GetTimeStep();
367 contour->SetClosed(
true);
374 auto point = (*it)->Coordinates;
375 point[0] += indexCoordinates[0];
376 point[1] += indexCoordinates[1];
378 contour->AddVertex(point);
382 if (leftMouseButtonPressed)
384 const double dist = indexCoordinates.EuclideanDistanceTo(
m_LastPosition);
385 const double radius =
static_cast<double>(
m_Size) / 2.0;
389 auto *labelImage =
dynamic_cast<LabelSetImage *
>(image.GetPointer());
394 activeColor = labelImage->
GetActiveLabel(labelImage->GetActiveLayer())->GetValue();
414 direction[1] = indexCoordinates[1] - m_LastPosition[1];
415 direction[2] = indexCoordinates[2] - m_LastPosition[2];
417 direction[0] = direction.GetVnlVector().normalize()[0];
418 direction[1] = direction.GetVnlVector().normalize()[1];
419 direction[2] = direction.GetVnlVector().normalize()[2];
422 normal[0] = -1.0 * direction[1];
423 normal[1] = direction[0];
428 vertex[0] = m_LastPosition[0] + (normal[0] * radius);
429 vertex[1] = m_LastPosition[1] + (normal[1] * radius);
431 contour->AddVertex(vertex);
434 vertex[0] = currentPos[0] + (normal[0] * radius);
435 vertex[1] = currentPos[1] + (normal[1] * radius);
437 contour->AddVertex(vertex);
440 vertex[0] = currentPos[0] - (normal[0] * radius);
441 vertex[1] = currentPos[1] - (normal[1] * radius);
443 contour->AddVertex(vertex);
446 vertex[0] = m_LastPosition[0] - (normal[0] * radius);
447 vertex[1] = m_LastPosition[1] - (normal[1] * radius);
449 contour->AddVertex(vertex);
467 displayContour->Clear();
478 Point3D point = (*it)->Coordinates;
480 displayContour->AddVertex(point, t);
486 assert(positionEvent->GetSender()->GetRenderWindow());
528 const auto *abstractTransformGeometry(
537 if (!image || !planeGeometry || abstractTransformGeometry)
544 m_WorkingNode->ReplaceProperty(
"color", workingNode->GetProperty(
"color"));
549 bool isSameSlice(
false);
577 m_WorkingNode->SetProperty(
"color", workingNode->GetProperty(
"color"));
Super class for all position events.
bool MatrixEqualElementWise(const vnl_matrix_fixed< TCoordRep, NRows, NCols > &matrix1, const vnl_matrix_fixed< TCoordRep, NRows, NCols > &matrix2, mitk::ScalarType epsilon=mitk::eps)
Check for element-wise matrix equality with a user defined accuracy.
static BaseRenderer * GetInstance(vtkRenderWindow *renWin)
static vtkRenderWindow * GetRenderWindowByName(const std::string &name)
virtual unsigned int GetSlice() const
static void FillContourInSlice(ContourModel *projectedContour, Image *sliceImage, mitk::Image::Pointer workingImage, int paintingPixelValue=1)
Fill a contour in a 2D slice with a specified pixel value at time step 0.
virtual const PlaneGeometry * GetCurrentWorldPlaneGeometry()
Get the current 2D-worldgeometry (m_CurrentWorldPlaneGeometry) used for 2D-rendering.
virtual void Add(DataNode *node, const DataStorage::SetOfObjects *parents=nullptr)=0
Adds a DataNode containing a data object to its internal storage.
BaseRenderer * GetSender() const
The LevelWindow class Class to store level/window values.
static RenderingManager * GetInstance()
Represents an action, that is executed after a certain event (in statemachine-mechanism) TODO: implem...
Image class for storing images.
mitk::Label * GetActiveLabel(unsigned int layer=0)
Returns the active label of a specific layer.
mitk::Image::Pointer image
virtual void Remove(const DataNode *node)=0
Removes node from the DataStorage.
void RequestUpdate(vtkRenderWindow *renderWindow)
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.
LabelSetImage class for handling labels and layers in a segmentation session.
MITKCORE_EXPORT const ScalarType eps
virtual bool Exists(const DataNode *node) const =0
Checks if a node exists in the DataStorage.
Describes a two-dimensional, rectangular plane.
#define CONNECT_FUNCTION(a, f)
void RequestUpdateAll(RequestType type=REQUEST_UPDATE_ALL)
Class for nodes of the DataTree.
mitk::AffineTransform3D * GetIndexToWorldTransform()
Get the transformation used to convert from index to world coordinates.