Beispiel #1
0
void mitk::SlicedData::SetOrigin(const mitk::Point3D& origin)
{
  mitk::TimeSlicedGeometry* timeSlicedGeometry = GetTimeSlicedGeometry();
  
  assert(timeSlicedGeometry!=NULL);

  mitk::SlicedGeometry3D* slicedGeometry;

  unsigned int steps = timeSlicedGeometry->GetTimeSteps();

  for(unsigned int timestep = 0; timestep < steps; ++timestep)
  {
    slicedGeometry = GetSlicedGeometry(timestep);
    if(slicedGeometry != NULL)
    {
      slicedGeometry->SetOrigin(origin);
      if(slicedGeometry->GetEvenlySpaced())
      {
        mitk::Geometry2D* geometry2D = slicedGeometry->GetGeometry2D(0);
        geometry2D->SetOrigin(origin);
        slicedGeometry->InitializeEvenlySpaced(geometry2D, slicedGeometry->GetSlices());
      }
    }
    if(GetTimeSlicedGeometry()->GetEvenlyTimed())
    {
      GetTimeSlicedGeometry()->InitializeEvenlyTimed(slicedGeometry, steps);
      break;
    }
  }
}
Beispiel #2
0
void mitk::BaseData::PrintSelf(std::ostream& os, itk::Indent indent) const
{
  os << std::endl;
  os << indent << " TimeSlicedGeometry: ";
  if(GetTimeSlicedGeometry() == NULL)
    os << "NULL" << std::endl;
  else
    GetTimeSlicedGeometry()->Print(os, indent);
}
Beispiel #3
0
bool mitk::SlicedData::VerifyRequestedRegion()
{
  if(GetTimeSlicedGeometry() == NULL) return false;

  unsigned int i;

  // Is the requested region within the LargestPossibleRegion?
  // Note that the test is indeed against the largest possible region
  // rather than the buffered region; see DataObject::VerifyRequestedRegion.
  const IndexType &requestedRegionIndex = m_RequestedRegion.GetIndex();
  const IndexType &largestPossibleRegionIndex
    = GetLargestPossibleRegion().GetIndex();

  const SizeType& requestedRegionSize = m_RequestedRegion.GetSize();
  const SizeType& largestPossibleRegionSize
    = GetLargestPossibleRegion().GetSize();

  for (i=0; i< RegionDimension; ++i)
  {
    if ( (requestedRegionIndex[i] < largestPossibleRegionIndex[i]) ||
      ((requestedRegionIndex[i] + static_cast<long>(requestedRegionSize[i]))
    > (largestPossibleRegionIndex[i]+static_cast<long>(largestPossibleRegionSize[i]))))
    {
      return false;
    }
  }

  return true;
}
Beispiel #4
0
mitk::ScalarType mitk::Cone::GetVolume()
{
  Geometry3D* geometry = GetTimeSlicedGeometry();
  return   geometry->GetExtentInMM(0) * 0.5
    * geometry->GetExtentInMM(2) * 0.5
    * vnl_math::pi / 3.0
    * geometry->GetExtentInMM(1);
}
Beispiel #5
0
const mitk::TimeSlicedGeometry* mitk::BaseData::GetUpdatedTimeSlicedGeometry()
{
  SetRequestedRegionToLargestPossibleRegion();

  UpdateOutputInformation();

  return GetTimeSlicedGeometry();
}
Beispiel #6
0
void mitk::ContourSet::UpdateOutputInformation()
{
  mitk::ContourSet::ContourVectorType contourVec = GetContours();
  mitk::ContourSet::ContourIterator contoursIterator = contourVec.begin();
  mitk::ContourSet::ContourIterator contoursIteratorEnd = contourVec.end();

  // initialize container
  mitk::BoundingBox::PointsContainer::Pointer pointscontainer=mitk::BoundingBox::PointsContainer::New();

  mitk::BoundingBox::PointIdentifier pointid=0;
  mitk::Point3D point;

  mitk::AffineTransform3D* transform = GetTimeSlicedGeometry()->GetIndexToWorldTransform();
  mitk::AffineTransform3D::Pointer inverse = mitk::AffineTransform3D::New();
  transform->GetInverse(inverse);

  // calculate a bounding box that includes all contours
  // \todo probably we should do this additionally for each time-step
  while (contoursIterator != contoursIteratorEnd)
  {
    const Geometry3D* geometry = (*contoursIterator).second->GetUpdatedTimeSlicedGeometry();
    unsigned char i;
    for(i=0; i<8; ++i)
    {
      point = inverse->TransformPoint(geometry->GetCornerPoint(i));
      if(point[0]*point[0]+point[1]*point[1]+point[2]*point[2] < mitk::large)
        pointscontainer->InsertElement( pointid++, point);
      else
      {
        itkGenericOutputMacro( << "Unrealistically distant corner point encountered. Ignored. BoundingObject: " << (*contoursIterator).second );
      }
    }
    ++contoursIterator;
  }

  mitk::BoundingBox::Pointer boundingBox = mitk::BoundingBox::New();
  boundingBox->SetPoints(pointscontainer);
  boundingBox->ComputeBoundingBox();

  Geometry3D* geometry3d = GetGeometry(0);
  geometry3d->SetIndexToWorldTransform(transform);
  geometry3d->SetBounds(boundingBox->GetBounds());

  GetTimeSlicedGeometry()->InitializeEvenlyTimed(geometry3d, GetTimeSlicedGeometry()->GetTimeSteps());
}
Beispiel #7
0
void mitk::UnstructuredGrid::CalculateBoundingBox()
{
  //
  // first make sure, that the associated time sliced geometry has
  // the same number of geometry 3d's as vtkUnstructuredGrids are present
  //
  mitk::TimeSlicedGeometry* timeGeometry = GetTimeSlicedGeometry();
  if ( timeGeometry->GetTimeSteps() != m_GridSeries.size() )
  {
    itkExceptionMacro(<<"timeGeometry->GetTimeSteps() != m_GridSeries.size() -- use Initialize(timeSteps) with correct number of timeSteps!");
  }
Beispiel #8
0
void mitk::UnstructuredGrid::UpdateOutputInformation()
{
 if ( this->GetSource() )
  {
    this->GetSource()->UpdateOutputInformation();
  }
  if ( ( m_CalculateBoundingBox ) && ( m_GridSeries.size() > 0 ) )
    CalculateBoundingBox();
  else
    GetTimeSlicedGeometry()->UpdateInformation();
}
Beispiel #9
0
void mitk::Surface::UpdateOutputInformation()
{
  if ( this->GetSource() )
  {
    this->GetSource()->UpdateOutputInformation();
  }
  if ( ( m_CalculateBoundingBox ) && ( m_PolyDataSeries.size() > 0 ) )
    CalculateBoundingBox();
  else
    GetTimeSlicedGeometry()->UpdateInformation();
}
Beispiel #10
0
void mitk::SlicedData::SetSpacing(mitk::Vector3D aSpacing)
{
  mitk::TimeSlicedGeometry* timeSlicedGeometry = GetTimeSlicedGeometry();
  
  assert(timeSlicedGeometry!=NULL);

  mitk::SlicedGeometry3D* slicedGeometry;

  unsigned int steps = timeSlicedGeometry->GetTimeSteps();

  for(unsigned int timestep = 0; timestep < steps; ++timestep)
  {
    slicedGeometry = GetSlicedGeometry(timestep);
    if(slicedGeometry != NULL)
    {
      slicedGeometry->SetSpacing(aSpacing);
    }
    if(GetTimeSlicedGeometry()->GetEvenlyTimed())
    {
      GetTimeSlicedGeometry()->InitializeEvenlyTimed(slicedGeometry, steps);
      break;
    }
  }
}
Beispiel #11
0
void mitk::PointSet::UpdateOutputInformation()
{
  if ( this->GetSource( ) )
  {
      this->GetSource( )->UpdateOutputInformation( );
  }

  //
  // first make sure, that the associated time sliced geometry has
  // the same number of geometry 3d's as PointSets are present
  //
  mitk::TimeSlicedGeometry* timeGeometry = GetTimeSlicedGeometry();
  if ( timeGeometry->GetTimeSteps() != m_PointSetSeries.size() )
  {
    itkExceptionMacro(<<"timeGeometry->GetTimeSteps() != m_PointSetSeries.size() -- use Initialize(timeSteps) with correct number of timeSteps!");
  }
Beispiel #12
0
void mitk::ContourModel::UpdateOutputInformation()
{
  if ( this->GetSource() )
  {
    this->GetSource()->UpdateOutputInformation();
  }

  if(this->m_UpdateBoundingBox)
  {

    //update the bounds of the geometry according to the stored vertices
    float mitkBounds[6];

    //calculate the boundingbox at each timestep
    typedef itk::BoundingBox<unsigned long, 3, ScalarType>        BoundingBoxType;
    typedef BoundingBoxType::PointsContainer                      PointsContainer;

    int timesteps = this->GetTimeSteps();

    //iterate over the timesteps
    for(int currenTimeStep = 0; currenTimeStep < timesteps; currenTimeStep++)
    {
      if( dynamic_cast< mitk::PlaneGeometry* >(this->GetGeometry(currenTimeStep)) )
      {
        //do not update bounds for 2D geometries, as they are unfortunately defined with min bounds 0!
        return;
      }
      else
      {//we have a 3D geometry -> let's update bounds
        //only update bounds if the contour was modified
        if (this->GetMTime() > this->GetGeometry(currenTimeStep)->GetBoundingBox()->GetMTime())
        {
          mitkBounds[0] = 0.0;
          mitkBounds[1] = 0.0;
          mitkBounds[2] = 0.0;
          mitkBounds[3] = 0.0;
          mitkBounds[4] = 0.0;
          mitkBounds[5] = 0.0;

          BoundingBoxType::Pointer boundingBox = BoundingBoxType::New();

          PointsContainer::Pointer points = PointsContainer::New();

          VertexIterator it = this->IteratorBegin(currenTimeStep);
          VertexIterator end = this->IteratorEnd(currenTimeStep);

          //fill the boundingbox with the points
          while(it != end)
          {
            Point3D currentP = (*it)->Coordinates;
            BoundingBoxType::PointType p;
            p.CastFrom(currentP);
            points->InsertElement(points->Size(), p);

            it++;
          }

          //construct the new boundingBox
          boundingBox->SetPoints(points);
          boundingBox->ComputeBoundingBox();
          BoundingBoxType::BoundsArrayType tmp = boundingBox->GetBounds();
          mitkBounds[0] = tmp[0];
          mitkBounds[1] = tmp[1];
          mitkBounds[2] = tmp[2];
          mitkBounds[3] = tmp[3];
          mitkBounds[4] = tmp[4];
          mitkBounds[5] = tmp[5];

          //set boundingBox at current timestep
          Geometry3D* geometry3d = this->GetGeometry(currenTimeStep);
          geometry3d->SetBounds(mitkBounds);
        }
      }
    }
    this->m_UpdateBoundingBox = false;
  }
  GetTimeSlicedGeometry()->UpdateInformation();
}
Beispiel #13
0
//const mitk::Geometry2D* mitk::SlicedData::GetGeometry2D(int s, int t) const
//{
//  const_cast<SlicedData*>(this)->SetRequestedRegionToLargestPossibleRegion();
//
//  const_cast<SlicedData*>(this)->UpdateOutputInformation();
//
//  return GetSlicedGeometry(t)->GetGeometry2D(s);
//}
//
mitk::SlicedGeometry3D* mitk::SlicedData::GetSlicedGeometry(unsigned int t) const
{
  if(GetTimeSlicedGeometry() == NULL)
    return NULL;
  return dynamic_cast<SlicedGeometry3D*>(GetTimeSlicedGeometry()->GetGeometry3D(t));
}
Beispiel #14
0
mitk::ContourSet::ContourSet() :
  m_ContourVector( ContourVectorType() ),
  m_NumberOfContours (0)
{
  GetTimeSlicedGeometry()->InitializeEvenlyTimed(1);
}
Beispiel #15
0
void mitk::ContourSet::Initialize()
{
  m_ContourVector = ContourVectorType();
  GetTimeSlicedGeometry()->InitializeEvenlyTimed(1);
}