Ejemplo n.º 1
0
  static PlanarFigureToMemoryWriterList SerializePlanarFiguresToMemoryBuffers( PlanarFigureList &planarFigures )
  {
    PlanarFigureToMemoryWriterList pfMemoryWriters;
    unsigned int i;
    PlanarFigureList::iterator it;

    bool success = true;
    for ( it = planarFigures.begin(), i = 0;
    it != planarFigures.end();
    ++it, ++i )
    {
      mitk::PlanarFigureWriter::Pointer writer = mitk::PlanarFigureWriter::New();
      writer->SetWriteToMemory( true );
      writer->SetInput( *it );
      writer->Update();

      pfMemoryWriters.push_back(writer);

      if(!writer->GetSuccess())
        success = false;
    }

    MITK_TEST_CONDITION_REQUIRED(success, "Testing if writing to memory buffers was successful");

    return pfMemoryWriters;
  }
Ejemplo n.º 2
0
  static void VerifyPlanarFigures( PlanarFigureList &planarFigures1, PlanarFigureList &planarFigures2 )
  {
    PlanarFigureList::iterator it1, it2;

    int i = 0;
    for ( it1 = planarFigures1.begin(); it1 != planarFigures1.end(); ++it1 )
    {
      bool planarFigureFound = false;
      int j = 0;
      for ( it2 = planarFigures2.begin(); it2 != planarFigures2.end(); ++it2 )
      {
        // Compare PlanarFigures (returns false if different types)
        if ( ComparePlanarFigures( *it1, *it2 ) )
        {
          planarFigureFound = true;
        }
        ++j;
      }

      // Test if (at least) on PlanarFigure of the first type was found in the second list
      MITK_TEST_CONDITION_REQUIRED(
          planarFigureFound,
          "Testing if " << (*it1)->GetNameOfClass() << " has a counterpart " << i );
      ++i;
    }
  }
Ejemplo n.º 3
0
  static PlanarFigureList CreateDeepCopiedPlanarFigures(PlanarFigureList original)
  {
    PlanarFigureList copiedPlanarFigures;

    PlanarFigureList::iterator it1;

    for ( it1 = original.begin(); it1 != original.end(); ++it1 )
    {
      mitk::PlanarFigure::Pointer copiedFigure = (*it1)->Clone();

      copiedPlanarFigures.push_back(copiedFigure);
    }
    return copiedPlanarFigures;
  }
Ejemplo n.º 4
0
  static PlanarFigureList CreateDeepCopiedPlanarFigures(PlanarFigureList original)
  {
    PlanarFigureList copiedPlanarFigures;

    PlanarFigureList::iterator it1;

    for ( it1 = original.begin(); it1 != original.end(); ++it1 )
    {
      mitk::PlanarFigure::Pointer copiedFigure;
      if(strcmp((*it1)->GetNameOfClass(), "PlanarAngle") == 0)
      {
        copiedFigure    = mitk::PlanarAngle::New();
      }
      if(strcmp((*it1)->GetNameOfClass(), "PlanarCircle") == 0)
      {
        copiedFigure    = mitk::PlanarCircle::New();
      }
      if(strcmp((*it1)->GetNameOfClass(), "PlanarLine") == 0)
      {
        copiedFigure    = mitk::PlanarLine::New();
      }
      if(strcmp((*it1)->GetNameOfClass(), "PlanarPolygon") == 0)
      {
        copiedFigure    = mitk::PlanarPolygon::New();
      }
      if(strcmp((*it1)->GetNameOfClass(), "PlanarSubdivisionPolygon") == 0)
      {
        copiedFigure    = mitk::PlanarSubdivisionPolygon::New();
      }
      if(strcmp((*it1)->GetNameOfClass(), "PlanarCross") == 0)
      {
        copiedFigure    = mitk::PlanarCross::New();
      }
      if(strcmp((*it1)->GetNameOfClass(), "PlanarRectangle") == 0)
      {
        copiedFigure    = mitk::PlanarRectangle::New();
      }
      if(strcmp((*it1)->GetNameOfClass(), "PlanarFourPointAngle") == 0)
      {
        copiedFigure    = mitk::PlanarFourPointAngle::New();
      }

      copiedFigure->DeepCopy((*it1));
      copiedPlanarFigures.push_back(copiedFigure.GetPointer());
    }
    return copiedPlanarFigures;
  }
Ejemplo n.º 5
0
 static PlanarFigureList CreateClonedPlanarFigures(PlanarFigureList original)
 {
   PlanarFigureList clonedPlanarFigures;
   clonedPlanarFigures.resize(original.size());
   std::transform(original.begin(), original.end(), clonedPlanarFigures.begin(), Clone);
   return clonedPlanarFigures;
 }
Ejemplo n.º 6
0
  static PlanarFigureList DeserializePlanarFigures( std::string& fileName)
  {
    // Read in the planar figures
    mitk::PlanarFigureReader::Pointer reader = mitk::PlanarFigureReader::New();
    reader->SetFileName( fileName.c_str() );
    reader->Update();

    MITK_TEST_CONDITION_REQUIRED(
        reader->GetSuccess(),
        "Testing if reading was successful");


    // Store them in the list and return it
    PlanarFigureList planarFigures;
    for ( unsigned int i = 0; i < reader->GetNumberOfOutputs(); ++i )
    {
      mitk::PlanarFigure* figure = reader->GetOutput( i );
      planarFigures.push_back( figure );
    }

    return planarFigures;
  }
Ejemplo n.º 7
0
  static PlanarFigureList DeserializePlanarFiguresFromMemoryBuffers( PlanarFigureToMemoryWriterList pfMemoryWriters)
  {
    // Store them in the list and return it
    PlanarFigureList planarFigures;
    bool success = true;
    for ( unsigned int i = 0; i < pfMemoryWriters.size(); ++i )
    {
      // Read in the planar figures
      mitk::PlanarFigureReader::Pointer reader = mitk::PlanarFigureReader::New();
      reader->SetReadFromMemory( true );
      reader->SetMemoryBuffer(pfMemoryWriters[i]->GetMemoryPointer(), pfMemoryWriters[i]->GetMemorySize());
      reader->Update();
      mitk::PlanarFigure* figure = reader->GetOutput( 0 );
      planarFigures.push_back( figure );

      if(!reader->GetSuccess())
        success = false;
    }

    MITK_TEST_CONDITION_REQUIRED(success, "Testing if reading was successful");

    return planarFigures;
  }
Ejemplo n.º 8
0
  static void SerializePlanarFigures( PlanarFigureList &planarFigures, std::string& fileName )
  {
    //std::string  sceneFileName = Poco::Path::temp() + /*Poco::Path::separator() +*/ "scene.zip";
    std::cout << "File name: " << fileName << std::endl;

    mitk::PlanarFigureWriter::Pointer writer = mitk::PlanarFigureWriter::New();
    writer->SetFileName( fileName.c_str() );

    unsigned int i;
    PlanarFigureList::iterator it;
    for ( it = planarFigures.begin(), i = 0;
    it != planarFigures.end();
    ++it, ++i )
    {
      writer->SetInput( i, *it );
    }

    writer->Update();

    MITK_TEST_CONDITION_REQUIRED(
        writer->GetSuccess(),
        "Testing if writing was successful");
  }
Ejemplo n.º 9
0
  static PlanarFigureList CreatePlanarFigures()
  {
    PlanarFigureList planarFigures;

    // Create PlaneGeometry on which to place the PlanarFigures
    mitk::PlaneGeometry::Pointer planeGeometry = mitk::PlaneGeometry::New();
    planeGeometry->InitializeStandardPlane( 100.0, 100.0 );

    // Create a few sample points for PlanarFigure placement
    mitk::Point2D p0; p0[0] = 20.0; p0[1] = 20.0;
    mitk::Point2D p1; p1[0] = 80.0; p1[1] = 80.0;
    mitk::Point2D p2; p2[0] = 90.0; p2[1] = 10.0;
    mitk::Point2D p3; p3[0] = 10.0; p3[1] = 90.0;

    // Create PlanarAngle
    mitk::PlanarAngle::Pointer planarAngle = mitk::PlanarAngle::New();
    planarAngle->SetGeometry2D( planeGeometry );
    planarAngle->PlaceFigure( p0 );
    planarAngle->SetCurrentControlPoint( p1 );
    planarAngle->AddControlPoint( p2 );
    planarFigures.push_back( planarAngle.GetPointer() );

    // Create PlanarCircle
    mitk::PlanarCircle::Pointer planarCircle = mitk::PlanarCircle::New();
    planarCircle->SetGeometry2D( planeGeometry );
    planarCircle->PlaceFigure( p0 );
    planarCircle->SetCurrentControlPoint( p1 );
    planarFigures.push_back( planarCircle.GetPointer() );

    // Create PlanarCross
    mitk::PlanarCross::Pointer planarCross = mitk::PlanarCross::New();
    planarCross->SetSingleLineMode( false );
    planarCross->SetGeometry2D( planeGeometry );
    planarCross->PlaceFigure( p0 );
    planarCross->SetCurrentControlPoint( p1 );
    planarCross->AddControlPoint( p2 );
    planarCross->AddControlPoint( p3 );
    planarFigures.push_back( planarCross.GetPointer() );

    // Create PlanarFourPointAngle
    mitk::PlanarFourPointAngle::Pointer planarFourPointAngle = mitk::PlanarFourPointAngle::New();
    planarFourPointAngle->SetGeometry2D( planeGeometry );
    planarFourPointAngle->PlaceFigure( p0 );
    planarFourPointAngle->SetCurrentControlPoint( p1 );
    planarFourPointAngle->AddControlPoint( p2 );
    planarFourPointAngle->AddControlPoint( p3 );
    planarFigures.push_back( planarFourPointAngle.GetPointer() );

    // Create PlanarLine
    mitk::PlanarLine::Pointer planarLine = mitk::PlanarLine::New();
    planarLine->SetGeometry2D( planeGeometry );
    planarLine->PlaceFigure( p0 );
    planarLine->SetCurrentControlPoint( p1 );
    planarFigures.push_back( planarLine.GetPointer() );

    // Create PlanarPolygon
    mitk::PlanarPolygon::Pointer planarPolygon = mitk::PlanarPolygon::New();
    planarPolygon->SetClosed( false );
    planarPolygon->SetGeometry2D( planeGeometry );
    planarPolygon->PlaceFigure( p0 );
    planarPolygon->SetCurrentControlPoint( p1 );
    planarPolygon->AddControlPoint( p2 );
    planarPolygon->AddControlPoint( p3 );
    planarFigures.push_back( planarPolygon.GetPointer() );

    // Create PlanarSubdivisionPolygon
    mitk::PlanarSubdivisionPolygon::Pointer planarSubdivisionPolygon = mitk::PlanarSubdivisionPolygon::New();
    planarSubdivisionPolygon->SetClosed( false );
    planarSubdivisionPolygon->SetGeometry2D( planeGeometry );
    planarSubdivisionPolygon->PlaceFigure( p0 );
    planarSubdivisionPolygon->SetCurrentControlPoint( p1 );
    planarSubdivisionPolygon->AddControlPoint( p2 );
    planarSubdivisionPolygon->AddControlPoint( p3 );
    planarFigures.push_back( planarSubdivisionPolygon.GetPointer() );

    // Create PlanarRectangle
    mitk::PlanarRectangle::Pointer planarRectangle = mitk::PlanarRectangle::New();
    planarRectangle->SetGeometry2D( planeGeometry );
    planarRectangle->PlaceFigure( p0 );
    planarRectangle->SetCurrentControlPoint( p1 );
    planarFigures.push_back( planarRectangle.GetPointer() );

    //create preciseGeometry which is using float coordinates
    mitk::PlaneGeometry::Pointer preciseGeometry = mitk::PlaneGeometry::New();
    mitk::Vector3D right;
    right[0] = 0.0;
    right[1] = 1.23456;
    right[2] = 0.0;

    mitk::Vector3D down;
    down[0] = 1.23456;
    down[1] = 0.0;
    down[2] = 0.0;

    mitk::Vector3D spacing;
    spacing[0] = 0.0123456;
    spacing[1] = 0.0123456;
    spacing[2] = 1.123456;
    preciseGeometry->InitializeStandardPlane( right, down, &spacing );

    //convert points into the precise coordinates
    mitk::Point2D p0precise; p0precise[0] = p0[0] * spacing[0]; p0precise[1] = p0[1] * spacing[1];
    mitk::Point2D p1precise; p1precise[0] = p1[0] * spacing[0]; p1precise[1] = p1[1] * spacing[1];
    mitk::Point2D p2precise; p2precise[0] = p2[0] * spacing[0]; p2precise[1] = p2[1] * spacing[1];
    mitk::Point2D p3precise; p3precise[0] = p3[0] * spacing[0]; p3precise[1] = p3[1] * spacing[1];

    //Now all PlanarFigures are create using the precise Geometry
    // Create PlanarCross
    mitk::PlanarCross::Pointer nochncross = mitk::PlanarCross::New();
    nochncross->SetSingleLineMode( false );
    nochncross->SetGeometry2D( preciseGeometry );
    nochncross->PlaceFigure( p0precise );
    nochncross->SetCurrentControlPoint( p1precise );
    nochncross->AddControlPoint( p2precise );
    nochncross->AddControlPoint( p3precise );
    planarFigures.push_back( nochncross.GetPointer() );

    // Create PlanarAngle
    mitk::PlanarAngle::Pointer planarAnglePrecise = mitk::PlanarAngle::New();
    planarAnglePrecise->SetGeometry2D( preciseGeometry );
    planarAnglePrecise->PlaceFigure( p0precise );
    planarAnglePrecise->SetCurrentControlPoint( p1precise );
    planarAnglePrecise->AddControlPoint( p2precise );
    planarFigures.push_back( planarAnglePrecise.GetPointer() );

    // Create PlanarCircle
    mitk::PlanarCircle::Pointer planarCirclePrecise = mitk::PlanarCircle::New();
    planarCirclePrecise->SetGeometry2D( preciseGeometry );
    planarCirclePrecise->PlaceFigure( p0precise );
    planarCirclePrecise->SetCurrentControlPoint( p1precise );
    planarFigures.push_back( planarCirclePrecise.GetPointer() );

    // Create PlanarFourPointAngle
    mitk::PlanarFourPointAngle::Pointer planarFourPointAnglePrecise = mitk::PlanarFourPointAngle::New();
    planarFourPointAnglePrecise->SetGeometry2D( preciseGeometry );
    planarFourPointAnglePrecise->PlaceFigure( p0precise );
    planarFourPointAnglePrecise->SetCurrentControlPoint( p1precise );
    planarFourPointAnglePrecise->AddControlPoint( p2precise );
    planarFourPointAnglePrecise->AddControlPoint( p3precise );
    planarFigures.push_back( planarFourPointAnglePrecise.GetPointer() );

    // Create PlanarLine
    mitk::PlanarLine::Pointer planarLinePrecise = mitk::PlanarLine::New();
    planarLinePrecise->SetGeometry2D( preciseGeometry );
    planarLinePrecise->PlaceFigure( p0precise );
    planarLinePrecise->SetCurrentControlPoint( p1precise );
    planarFigures.push_back( planarLinePrecise.GetPointer() );

    // Create PlanarPolygon
    mitk::PlanarPolygon::Pointer planarPolygonPrecise = mitk::PlanarPolygon::New();
    planarPolygonPrecise->SetClosed( false );
    planarPolygonPrecise->SetGeometry2D( preciseGeometry );
    planarPolygonPrecise->PlaceFigure( p0precise );
    planarPolygonPrecise->SetCurrentControlPoint( p1precise );
    planarPolygonPrecise->AddControlPoint( p2precise );
    planarPolygonPrecise->AddControlPoint( p3precise );
    planarFigures.push_back( planarPolygonPrecise.GetPointer() );

    // Create PlanarSubdivisionPolygon
    mitk::PlanarSubdivisionPolygon::Pointer planarSubdivisionPolygonPrecise = mitk::PlanarSubdivisionPolygon::New();
    planarSubdivisionPolygonPrecise->SetClosed( false );
    planarSubdivisionPolygonPrecise->SetGeometry2D( preciseGeometry );
    planarSubdivisionPolygonPrecise->PlaceFigure( p0precise );
    planarSubdivisionPolygonPrecise->SetCurrentControlPoint( p1precise );
    planarSubdivisionPolygonPrecise->AddControlPoint( p2precise );
    planarSubdivisionPolygonPrecise->AddControlPoint( p3precise );
    planarFigures.push_back( planarSubdivisionPolygonPrecise.GetPointer() );

    // Create PlanarRectangle
    mitk::PlanarRectangle::Pointer planarRectanglePrecise = mitk::PlanarRectangle::New();
    planarRectanglePrecise->SetGeometry2D( preciseGeometry );
    planarRectanglePrecise->PlaceFigure( p0precise );
    planarRectanglePrecise->SetCurrentControlPoint( p1precise );
    planarFigures.push_back( planarRectanglePrecise.GetPointer() );

    return planarFigures;
  }