예제 #1
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;
    }
  }
예제 #2
0
 static PlanarFigureList CreateClonedPlanarFigures(PlanarFigureList original)
 {
   PlanarFigureList clonedPlanarFigures;
   clonedPlanarFigures.resize(original.size());
   std::transform(original.begin(), original.end(), clonedPlanarFigures.begin(), Clone);
   return clonedPlanarFigures;
 }
  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;
  }
예제 #4
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;
  }
  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;
  }
  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");
  }