Пример #1
0
  void TestOpMovePointUpOnFirstPoint()
  {
    //check OpMOVEPOINTUP  on first point ExecuteOperation

    mitk::PointSet::PointType p1 = pointSet->GetPoint(1);
    mitk::PointSet::PointType p2 = pointSet->GetPoint(2);

    doOp = new mitk::PointOperation(mitk::OpMOVEPOINTUP, p1, 1);

    pointSet->ExecuteOperation(doOp);


    mitk::PointSet::PointType newP1 = pointSet->GetPoint(1);
    mitk::PointSet::PointType newP2 = pointSet->GetPoint(2);

    CPPUNIT_ASSERT_EQUAL_MESSAGE("check PointOperation OpMOVEPOINTUP for point id 1: ",
        true, ((newP1 == p1) && (newP2 == p2)));

    /*
      if (((newP1 == p1) && (newP2 == p2)) == false)
      {
      std::cout<<"[FAILED]"<<std::endl;
      return EXIT_FAILURE;
      }
      std::cout<<"[PASSED]"<<std::endl;
     */
  }
Пример #2
0
    void PointSetCompare(mitk::PointSet::Pointer pointSet2,
                         mitk::PointSet::Pointer pointSet1, bool& /*identical*/)
    {
        MITK_TEST_CONDITION(pointSet1->GetSize() == pointSet2->GetSize(), "Testing if PointSet size is correct" );

        for (unsigned int t = 0; t < numberOfTimeSeries; t++)
        {
            for (unsigned int i = 0; i < (unsigned int) pointSet1->GetSize(t); ++i)
            {
                mitk::Point3D p1 = pointSet1->GetPoint(i);
                mitk::Point3D p2 = pointSet2->GetPoint(i);

                //test
                std::cout << "r point: " << p2 << std::endl;
                std::cout << "w point: " << p1 << std::endl;

                //test end

                MITK_TEST_CONDITION((p1[0] - p2[0]) <= 0.0001, "Testing if X coordinates of the Point are at the same Position" );
                MITK_TEST_CONDITION((p1[1] - p2[1]) <= 0.0001, "Testing if Y coordinates of the Point are at the same Position" );
                MITK_TEST_CONDITION((p1[2] - p2[2]) <= 0.0001, "Testing if Z coordinates of the Point are at the same Position" );

            }
        }

        // testing geometry
        MITK_TEST_CONDITION( mitk::Equal( *(pointSet1->GetGeometry()), *(pointSet2->GetGeometry()), 0.000001, true),
                             "Restored geometry must equal original one.");
    }
Пример #3
0
  void TestOpMovePointUp()
  {
    //check OpMOVEPOINTUP  ExecuteOperation
    const int id = 4;

    mitk::Point3D point = pointSet->GetPoint(id);

    mitk::Point3D point4(0.);
    doOp = new mitk::PointOperation(mitk::OpMOVEPOINTUP, point4, id);

    pointSet->ExecuteOperation(doOp);
    mitk::Point3D tempPoint = pointSet->GetPoint(id-1);

    CPPUNIT_ASSERT_EQUAL_MESSAGE("check PointOperation OpMOVEPOINTUP ",
        true, tempPoint == point);

    /*
    if (tempPoint != point)
    {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
    }
    delete doOp;
    std::cout<<"[PASSED]"<<std::endl;
     */
  }
Пример #4
0
  void TestPointOperationOpRemove()
  {
    //check OpREMOVE  ExecuteOperation
    int id=0;
    mitk::Point3D point;
    mitk::Point3D tempPoint;

    point = pointSet->GetPoint(id);

    doOp = new mitk::PointOperation(mitk::OpREMOVE, point, id);

    pointSet->ExecuteOperation(doOp);
    tempPoint = pointSet->GetPoint(id);

    CPPUNIT_ASSERT_EQUAL_MESSAGE("check PointOperation OpREMOVE ",
        false, pointSet->IndexExists(id) );

    /*
    if(pointSet->IndexExists(id))
    {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
    }
    delete doOp;
    std::cout<<"[PASSED]"<<std::endl;
     */
  }
  void TestCreateHoleInThePointIDs()
  {
    // create a hole in the point IDs
    mitk::Point3D point(0.);
    mitk::PointSet::PointType p10, p11, p12;
    p10.Fill(10.0);
    p11.Fill(11.0);
    p12.Fill(12.0);
    pointSet->InsertPoint(10, p10);
    pointSet->InsertPoint(11, p11);
    pointSet->InsertPoint(12, p12);

    CPPUNIT_ASSERT_EQUAL_MESSAGE("add points with id 10, 11, 12: ",
        true, (pointSet->IndexExists(10) == true) || (pointSet->IndexExists(11) == true) || (pointSet->IndexExists(12) == true));

    //check OpREMOVE  ExecuteOperation
    int id = 11;
    auto  doOp = new mitk::PointOperation(mitk::OpREMOVE, point, id);
    pointSet->ExecuteOperation(doOp);

    CPPUNIT_ASSERT_EQUAL_MESSAGE( "remove point id 11: ",
        false, pointSet->IndexExists(id));

    /*
      if(pointSet->IndexExists(id))
      {
      std::cout<<"[FAILED]"<<std::endl;
      return EXIT_FAILURE;
      }
      delete doOp;
      std::cout<<"[PASSED]"<<std::endl;
     */

    //mitk::PointOperation* doOp = new mitk::PointOperation(mitk::OpMOVEPOINTUP, p12, 12);
    //pointSet->ExecuteOperation(doOp);
    delete doOp;

    //check OpMOVEPOINTUP  ExecuteOperation
    doOp = new mitk::PointOperation(mitk::OpMOVEPOINTUP, p12, 12);
    pointSet->ExecuteOperation(doOp);
    delete doOp;

    mitk::PointSet::PointType newP10 = pointSet->GetPoint(10);
    mitk::PointSet::PointType newP12 = pointSet->GetPoint(12);

    CPPUNIT_ASSERT_EQUAL_MESSAGE("check PointOperation OpMOVEPOINTUP for point id 12:",
        true, ((newP10 == p12) && (newP12 == p10)));

    //check OpMOVEPOINTDOWN  ExecuteOperation
    doOp = new mitk::PointOperation(mitk::OpMOVEPOINTDOWN, p10, 10);
    pointSet->ExecuteOperation(doOp);
    delete doOp;
    newP10 = pointSet->GetPoint(10);
    newP12 = pointSet->GetPoint(12);

    CPPUNIT_ASSERT_EQUAL_MESSAGE("check PointOperation OpMOVEPOINTDOWN for point id 10: ",
        true, ((newP10 == p10) && (newP12 == p12)));
  }
Пример #6
0
std::vector<mitk::Point3D> PointSetToVector(const mitk::PointSet::Pointer & mps)
{
  std::vector<mitk::Point3D> result;
  for(int i = 0 ; i < mps->GetSize(); i++)
    result.push_back(mps->GetPoint(i));
  return result;
}
Пример #7
0
  void TestPointOperationOpMove()
  {
    //check opMOVE  ExecuteOperation
    int id=1;
    mitk::Point3D point1;
    mitk::Point3D tempPoint;
    point1.Fill(2);

    doOp = new mitk::PointOperation(mitk::OpMOVE, point1, id);

    pointSet->ExecuteOperation(doOp);
    tempPoint = pointSet->GetPoint(id);

    CPPUNIT_ASSERT_EQUAL_MESSAGE("check PointOperation OpMove ",
        true, tempPoint == point1);

    /*
    if (tempPoint != point1)
    {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
    }
    delete doOp;
    std::cout<<"[PASSED]"<<std::endl;
     */
  }
double mitk::StaticIGTHelperFunctions::ComputeFRE(mitk::PointSet::Pointer imageFiducials, mitk::PointSet::Pointer realWorldFiducials, vtkSmartPointer<vtkLandmarkTransform> transform)
{
  if (imageFiducials->GetSize() != realWorldFiducials->GetSize()) return -1;
  double FRE = 0;
  for (int i = 0; i < imageFiducials->GetSize(); i++)
  {
    itk::Point<double> current_image_fiducial_point = imageFiducials->GetPoint(i);
    if (transform != NULL)
    {
      current_image_fiducial_point = transform->TransformPoint(imageFiducials->GetPoint(i)[0], imageFiducials->GetPoint(i)[1], imageFiducials->GetPoint(i)[2]);
    }
    double cur_error_squared = current_image_fiducial_point.SquaredEuclideanDistanceTo(realWorldFiducials->GetPoint(i));
    FRE += cur_error_squared;
  }

  FRE = sqrt(FRE / (double)imageFiducials->GetSize());

  return FRE;
}
inline static mitk::Image::Pointer CreateTestImageWithPointSet(mitk::ScalarType pixelValue, unsigned int dimX, unsigned int dimY, mitk::PointSet::Pointer subSet)
{
  typedef itk::Image<mitk::ScalarType,2> ItkImageType2D;
  typedef itk::ImageRegionIterator<ItkImageType2D> ItkImageRegionIteratorType2D;

  ItkImageType2D::Pointer image = ItkImageType2D::New();
  ItkImageType2D::IndexType start;
  start[0] = 0;
  start[1] = 0;
  ItkImageType2D::SizeType size;
  size[0] = dimX;
  size[1] = dimY;
  ItkImageType2D::RegionType region;
  region.SetSize(size);
  region.SetIndex( start);
  ItkImageType2D::SpacingType spacing;
  spacing[0] = 1.0;
  spacing[1] = 1.0;

  image->SetRegions( region );
  image->SetSpacing ( spacing );
  image->Allocate();

  //Obtaining image data from ToF camera//

  //Correlate inten values to PixelIndex//
  ItkImageRegionIteratorType2D imageIterator(image,image->GetLargestPossibleRegion());
  imageIterator.GoToBegin();

  while (!imageIterator.IsAtEnd())
  {
    imageIterator.Set(pixelValue);
    ++imageIterator;
  }
  // distances varying from pixelValue
  std::vector<mitk::ScalarType> distances;
  distances.push_back(50);
  distances.push_back(500);
  distances.push_back(2050);
  distances.push_back(300);
  // set the pixel values for the subset
  for (unsigned int i=0; i<subSet->GetSize(); i++)
  {
    mitk::Point3D point = subSet->GetPoint(i);
    ItkImageType2D::IndexType index;
    index[0] = point[0];
    index[1] = point[1];
    mitk::ScalarType distance = distances.at(i);
    image->SetPixel(index,distance);
  }
  mitk::Image::Pointer mitkImage = mitk::Image::New();
  mitk::CastToMitkImage(image,mitkImage);
  return mitkImage;
}
Пример #10
0
std::string mitk::NavigationToolWriter::ConvertPointSetToString(mitk::PointSet::Pointer pointSet)
  {
  std::stringstream returnValue;
  mitk::PointSet::PointDataIterator it;
  for ( it = pointSet->GetPointSet()->GetPointData()->Begin();it != pointSet->GetPointSet()->GetPointData()->End();it++ )
    {
    mitk::Point3D thisPoint = pointSet->GetPoint(it->Index());
    returnValue << it->Index() << ";" << ConvertPointToString(thisPoint) << "|";
    }
  return returnValue.str();
  }
  void TestSwapPointPositionDownwards()
  {
    //Check SwapPointPosition downwards
    mitk::Point3D point;
    mitk::Point3D tempPoint;
    point = pointSet->GetPoint(0);
    pointSet->SwapPointPosition(0, false);
    tempPoint = pointSet->GetPoint(1);

    CPPUNIT_ASSERT_EQUAL_MESSAGE("check SwapPointPosition down",
        true, point == tempPoint);

    /*
if(point != tempPoint)
{
std::cout<<"[FAILED]"<<std::endl;
return EXIT_FAILURE;
}
std::cout<<"[PASSED]"<<std::endl;
     */
  }
bool PointSetsEqual(mitk::PointSet::Pointer pointSet1, mitk::PointSet::Pointer pointSet2)
{
  bool pointSetsEqual = true;
  if (pointSet1->GetSize()==pointSet2->GetSize())
  {
    for (unsigned int i=0; i<pointSet1->GetSize(); i++)
    {
      mitk::Point3D expectedPoint = pointSet1->GetPoint(i);
      mitk::Point3D resultPoint = pointSet2->GetPoint(i);
      if (!mitk::Equal(expectedPoint,resultPoint))
      {
        pointSetsEqual = false;
      }
    }
  }
  else
  {
    pointSetsEqual = false;
  }
  return pointSetsEqual;
}
Пример #13
0
  void TestOpMovePointDown()
  {
    //check OpMOVEPOINTDown  ExecuteOperation

    const int id = 2;

    mitk::Point3D point = pointSet->GetPoint(id);
    mitk::Point3D point2(0.);
    doOp = new mitk::PointOperation(mitk::OpMOVEPOINTDOWN, point2, id);
    pointSet->ExecuteOperation(doOp);
    mitk::Point3D tempPoint = pointSet->GetPoint(id+1);

    CPPUNIT_ASSERT_EQUAL_MESSAGE("check PointOperation OpMOVEPOINTDOWN ",
        true, tempPoint == point);

    /*
    if (tempPoint != point)
    {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
    }
    std::cout<<"[PASSED]"<<std::endl;
     */
  }
  void TestInsertPointWithPointSpecification()
  {
    //check InsertPoint with PointSpecification
    mitk::Point3D point5;
    mitk::Point3D tempPoint;
    point5.Fill(7);

    pointSet->SetPoint(5, point5, mitk::PTEDGE );
    tempPoint = pointSet->GetPoint(5);

    CPPUNIT_ASSERT_EQUAL_MESSAGE("check InsertPoint with PointSpecification" ,
        true, tempPoint == point5);
    /*
      if (tempPoint != point5)
      {
      std::cout<<"[FAILED]"<<std::endl;
      return EXIT_FAILURE;
      }
      std::cout<<"[PASSED]"<<std::endl;
     */
  }
Пример #15
0
  void TestCreateOperationAndAddPoint()
  {
    int id = 0;
    mitk::Point3D point;
    point.Fill(1);

    doOp = new mitk::PointOperation(mitk::OpINSERT, point, id);

    pointSet->ExecuteOperation(doOp);
    CPPUNIT_ASSERT_EQUAL_MESSAGE("check if added points exists",
        true, pointSet->GetSize()==4 && pointSet->IndexExists(id));


    mitk::Point3D tempPoint;
    tempPoint.Fill(0);

    tempPoint = pointSet->GetPoint(id);

    CPPUNIT_ASSERT_EQUAL_MESSAGE("check if added point contains real value",
        true, point == tempPoint);
  }
void QmitkUSNavigationStepPunctuationIntervention::UpdateCriticalStructures(mitk::NavigationData::Pointer needle, mitk::PointSet::Pointer path)
{
  // update the distances for the risk structures widget
  ui->riskStructuresRangeWidget->UpdateDistancesToNeedlePosition(needle);

  //iterate through all zones
  for (mitk::DataStorage::SetOfObjects::ConstIterator it = m_ZoneNodes->Begin();
       it != m_ZoneNodes->End(); ++it)
  {
    mitk::DataNode::Pointer currentNode = it->Value();
    //get center point and radius
    float radius = -1;
    mitk::Point3D center;
    currentNode->GetFloatProperty("zone.size", radius);
    center = currentNode->GetData()->GetGeometry()->GetIndexToWorldTransform()->GetTranslation();
    mitk::Point3D point0 = path->GetPoint(0);
    mitk::Point3D point1 = path->GetPoint(1);
    if (CheckSphereLineIntersection(center,radius,point0,point1))
      {currentNode->SetColor(mitk::IGTColor_WARNING);}
    else
      {currentNode->SetColor(m_OldColors[currentNode]);}
  }
}