Example #1
0
void mitk::BaseRenderer::SetWorldGeometry(mitk::Geometry3D* geometry)
{
    itkDebugMacro("setting WorldGeometry to " << geometry);

    if (m_WorldGeometry != geometry)
    {
        if (geometry->GetBoundingBox()->GetDiagonalLength2() == 0)
            return;

        m_WorldGeometry = geometry;
        m_TimeSlicedWorldGeometry = dynamic_cast<TimeSlicedGeometry*>(geometry);
        SlicedGeometry3D* slicedWorldGeometry;
        if (m_TimeSlicedWorldGeometry.IsNotNull())
        {
            itkDebugMacro("setting TimeSlicedWorldGeometry to " << m_TimeSlicedWorldGeometry);
            if (m_TimeStep >= m_TimeSlicedWorldGeometry->GetTimeSteps())
                m_TimeStep = m_TimeSlicedWorldGeometry->GetTimeSteps() - 1;
            slicedWorldGeometry = dynamic_cast<SlicedGeometry3D*>(m_TimeSlicedWorldGeometry->GetGeometry3D(m_TimeStep));
        }
        else
        {
            slicedWorldGeometry = dynamic_cast<SlicedGeometry3D*>(geometry);
        }
        Geometry2D::Pointer geometry2d;
        if (slicedWorldGeometry != NULL)
        {
            if (m_Slice >= slicedWorldGeometry->GetSlices() && (m_Slice != 0))
                m_Slice = slicedWorldGeometry->GetSlices() - 1;
            geometry2d = slicedWorldGeometry->GetGeometry2D(m_Slice);
            if (geometry2d.IsNull())
            {
                PlaneGeometry::Pointer plane = mitk::PlaneGeometry::New();
                plane->InitializeStandardPlane(slicedWorldGeometry);
                geometry2d = plane;
            }
            SetCurrentWorldGeometry(slicedWorldGeometry);
        }
        else
        {
            geometry2d = dynamic_cast<Geometry2D*>(geometry);
            if (geometry2d.IsNull())
            {
                PlaneGeometry::Pointer plane = PlaneGeometry::New();
                plane->InitializeStandardPlane(geometry);
                geometry2d = plane;
            }
            SetCurrentWorldGeometry(geometry);
        }
        SetCurrentWorldGeometry2D(geometry2d); // calls Modified()
    }
    if (m_CurrentWorldGeometry2D.IsNull())
        itkWarningMacro("m_CurrentWorldGeometry2D is NULL");
}
void mitk::InternalTrackingTool::SetPosition(mitk::Point3D position)
{
  itkDebugMacro("setting  m_Position to " << position);

  MutexLockHolder lock(*m_MyMutex); // lock and unlock the mutex
  m_Position = position;
  this->Modified();
}
bool mitk::NavigationDataObjectVisualizationFilter::GetTransformOrientation( unsigned int index ) const
{
  itkDebugMacro("returning TransformOrientation for index " << index);
  BooleanInputMap::const_iterator it = this->m_TransformOrientation.find(index);
  if (it != this->m_TransformOrientation.end())
    return it->second;
  else
    return true; // default to true
}
Example #4
0
itk::DataObject::Pointer mitk::LookupTableSource::MakeOutput( const DataObjectIdentifierType & name )
{
  itkDebugMacro("MakeOutput(" << name << ")");
  if( this->IsIndexedOutputName(name) )
  {
    return this->MakeOutput( this->MakeIndexFromOutputName(name) );
  }
  return OutputType::New().GetPointer();
}
Example #5
0
itk::DataObject::Pointer mitk::SurfaceSource::MakeOutput(const DataObjectIdentifierType &name)
{
  itkDebugMacro("MakeOutput(" << name << ")");
  if (this->IsIndexedOutputName(name))
  {
    return this->MakeOutput(this->MakeIndexFromOutputName(name));
  }
  return static_cast<itk::DataObject *>(mitk::Surface::New().GetPointer());
}
void mitk::InternalTrackingTool::SetOrientation(mitk::Quaternion orientation)
{
  itkDebugMacro("setting  m_Orientation to " << orientation);

  MutexLockHolder lock(*m_MyMutex); // lock and unlock the mutex
  m_Orientation = orientation;
  this->Modified();

}
itk::DataObject::Pointer mitk::ContourModelSetToImageFilter::MakeOutput(const DataObjectIdentifierType &name)
{
  itkDebugMacro("MakeOutput(" << name << ")");
  if (this->IsIndexedOutputName(name))
  {
    return this->MakeOutput(this->MakeIndexFromOutputName(name));
  }
  return OutputType::New().GetPointer();
}
void mitk::InternalTrackingTool::SetDataValid(bool _arg)
{
  itkDebugMacro("setting m_DataValid to " << _arg);
  if (this->m_DataValid != _arg)
  {
    MutexLockHolder lock(*m_MyMutex); // lock and unlock the mutex
    this->m_DataValid = _arg;
    this->Modified();
  }
}
void mitk::NavigationDataObjectVisualizationFilter::SetTransformOrientation( unsigned int index, bool applyTransform )
{
  itkDebugMacro("setting TransformOrientation for index " << index << " to " << applyTransform);
  BooleanInputMap::const_iterator it = this->m_TransformOrientation.find(index);
  if ((it != this->m_TransformOrientation.end()) && (it->second == applyTransform))
    return;

  this->m_TransformOrientation[index] = applyTransform;
  this->Modified(); \
}
void mitk::InternalTrackingTool::SetTrackingError(float error)
{
  itkDebugMacro("setting  m_TrackingError  to " << error);
  MutexLockHolder lock(*m_MyMutex); // lock and unlock the mutex
  if (error == m_TrackingError)
  {
    return;
  }
  m_TrackingError = error;
  this->Modified();
}
Example #11
0
void mitk::BaseRenderer::SetDisplayGeometry(mitk::DisplayGeometry* geometry2d)
{
    itkDebugMacro("setting DisplayGeometry to " << geometry2d);
    if (m_DisplayGeometry != geometry2d)
    {
        m_DisplayGeometry = geometry2d;
        m_DisplayGeometryData->SetGeometry2D(m_DisplayGeometry);
        m_DisplayGeometryUpdateTime.Modified();
        Modified();
    }
}
Example #12
0
void mitk::TrackingDevice::SetState( TrackingDeviceState state )
{
  itkDebugMacro("setting  m_State to " << state);

  MutexLockHolder lock(*m_StateMutex); // lock and unlock the mutex
  if (m_State == state)
  {
    return;
  }
  m_State = state;
  this->Modified();
}
void mitk::InternalTrackingTool::SetErrorMessage(const char* _arg)
{
  itkDebugMacro("setting  m_ErrorMessage  to " << _arg);
  MutexLockHolder lock(*m_MyMutex); // lock and unlock the mutex
  if ((_arg == NULL) || (_arg == this->m_ErrorMessage))
    return;

  if (_arg != NULL)
    this->m_ErrorMessage = _arg;
  else
    this->m_ErrorMessage = "";
  this->Modified();
}
Example #14
0
void mitk::BaseData::ConnectSource(itk::ProcessObject *arg, unsigned int idx) const
{
#ifdef MITK_WEAKPOINTER_PROBLEM_WORKAROUND_ENABLED
  itkDebugMacro( "connecting source  " << arg
    << ", source output index " << idx);

  if ( GetSource().GetPointer() != arg || m_SourceOutputIndexDuplicate != idx)
  {
    m_SmartSourcePointer = dynamic_cast<mitk::BaseProcess*>(arg);
    m_SourceOutputIndexDuplicate = idx;
    Modified();
  }
#endif
}
Example #15
0
void mitk::IGTLDevice::SetState( IGTLDeviceState state )
{
  itkDebugMacro("setting  m_State to " << state);

  m_StateMutex->Lock();
//  MutexLockHolder lock(*m_StateMutex); // lock and unlock the mutex

  if (m_State == state)
  {
    m_StateMutex->Unlock();
    return;
  }
  m_State = state;
  m_StateMutex->Unlock();
  this->Modified();
}
void mitk::InternalTrackingTool::SetToolName(const char* _arg)
{
  itkDebugMacro("setting  m_ToolName to " << _arg);
  MutexLockHolder lock(*m_MyMutex); // lock and unlock the mutex
  if ( _arg && (_arg == this->m_ToolName) )
  {
    return;
  }
  if (_arg)
  {
    this->m_ToolName= _arg;
  }
  else
  {
    this->m_ToolName= "";
  }
  this->Modified();
}
Example #17
0
void mitk::ExtrudedContour::BuildGeometry()
{
  if(m_Contour.IsNull())
    return;

//  Initialize(1);

  Vector3D nullvector; nullvector.Fill(0.0);
  float xProj[3];
  unsigned int i;
  unsigned int numPts = 20; //m_Contour->GetNumberOfPoints();
  mitk::Contour::PathPointer path = m_Contour->GetContourPath();
  mitk::Contour::PathType::InputType cstart = path->StartOfInput();
  mitk::Contour::PathType::InputType cend   = path->EndOfInput();
  mitk::Contour::PathType::InputType cstep  = (cend-cstart)/numPts;
  mitk::Contour::PathType::InputType ccur;

  // Part I: guarantee/calculate legal vectors

  m_Vector.Normalize();
  itk2vtk(m_Vector, m_Normal);
  // check m_Vector
  if(mitk::Equal(m_Vector, nullvector) || m_AutomaticVectorGeneration)
  {
    if ( m_AutomaticVectorGeneration == false)
      itkWarningMacro("Extrusion vector is 0 ("<< m_Vector << "); trying to use normal of polygon");

    vtkPoints *loopPoints = vtkPoints::New();
    //mitk::Contour::PointsContainerIterator pointsIt = m_Contour->GetPoints()->Begin();
    double vtkpoint[3];

    unsigned int i=0;
    for(i=0, ccur=cstart; i<numPts; ++i, ccur+=cstep)
    {
      itk2vtk(path->Evaluate(ccur), vtkpoint);
      loopPoints->InsertNextPoint(vtkpoint);
    }

    // Make sure points define a loop with a m_Normal
    vtkPolygon::ComputeNormal(loopPoints, m_Normal);
    loopPoints->Delete();

    vtk2itk(m_Normal, m_Vector);
    if(mitk::Equal(m_Vector, nullvector))
    {
      itkExceptionMacro("Cannot calculate normal of polygon");
    }
  }
  // check m_RightVector
  if((mitk::Equal(m_RightVector, nullvector)) || (mitk::Equal(m_RightVector*m_Vector, 0.0)==false))
  {
    if(mitk::Equal(m_RightVector, nullvector))
    {
      itkDebugMacro("Right vector is 0. Calculating.");
    }
    else
    {
      itkWarningMacro("Right vector ("<<m_RightVector<<") not perpendicular to extrusion vector "<<m_Vector<<": "<<m_RightVector*m_Vector);
    }
    // calculate a legal m_RightVector
    if( mitk::Equal( m_Vector[1], 0.0f ) == false )
    {
      FillVector3D( m_RightVector, 1.0f, -m_Vector[0]/m_Vector[1], 0.0f );
      m_RightVector.Normalize();
    }
    else
    {
      FillVector3D( m_RightVector, 0.0f, 1.0f, 0.0f );
    }
  }

  // calculate down-vector
  VnlVector rightDV = m_RightVector.GetVnlVector(); rightDV.normalize(); vnl2vtk(rightDV, m_Right);
  VnlVector downDV  = vnl_cross_3d( m_Vector.GetVnlVector(), rightDV ); downDV.normalize();  vnl2vtk(downDV,  m_Down);

  // Part II: calculate plane as base for extrusion, project the contour
  // on this plane and store as polygon for IsInside test and BoundingBox calculation

  // initialize m_ProjectionPlane, yet with origin at 0
  m_ProjectionPlane->InitializeStandardPlane(rightDV, downDV);

  // create vtkPolygon from contour and simultaneously determine 2D bounds of
  // contour projected on m_ProjectionPlane
  //mitk::Contour::PointsContainerIterator pointsIt = m_Contour->GetPoints()->Begin();
  m_Polygon->Points->Reset();
  m_Polygon->Points->SetNumberOfPoints(numPts);
  m_Polygon->PointIds->Reset();
  m_Polygon->PointIds->SetNumberOfIds(numPts);
  mitk::Point2D pt2d;
  mitk::Point3D pt3d;
  mitk::Point2D min, max;
  min.Fill(ScalarTypeNumericTraits::max());
  max.Fill(ScalarTypeNumericTraits::min());
  xProj[2]=0.0;
  for(i=0, ccur=cstart; i<numPts; ++i, ccur+=cstep)
  {
    pt3d.CastFrom(path->Evaluate(ccur));
    m_ProjectionPlane->Map(pt3d, pt2d);
    xProj[0]=pt2d[0];
    if(pt2d[0]<min[0]) min[0]=pt2d[0];
    if(pt2d[0]>max[0]) max[0]=pt2d[0];
    xProj[1]=pt2d[1];
    if(pt2d[1]<min[1]) min[1]=pt2d[1];
    if(pt2d[1]>max[1]) max[1]=pt2d[1];
    m_Polygon->Points->SetPoint(i, xProj);
    m_Polygon->PointIds->SetId(i, i);
  }
  // shift parametric origin to (0,0)
  for(i=0; i<numPts; ++i)
  {
    double * pt = this->m_Polygon->Points->GetPoint(i);

    pt[0]-=min[0]; pt[1]-=min[1];
    itkDebugMacro( << i << ": (" << pt[0] << "," << pt[1] << "," << pt[2] << ")" );
  }
  this->m_Polygon->GetBounds(m_ProjectedContourBounds);
  //m_ProjectedContourBounds[4]=-1.0; m_ProjectedContourBounds[5]=1.0;

  // calculate origin (except translation along the normal) and bounds
  // of m_ProjectionPlane:
  //  origin is composed of the minimum x-/y-coordinates of the polygon,
  //  bounds from the extent of the polygon, both after projecting on the plane
  mitk::Point3D origin;
  m_ProjectionPlane->Map(min, origin);
  ScalarType bounds[6]={0, max[0]-min[0], 0, max[1]-min[1], 0, 1};
  m_ProjectionPlane->SetBounds(bounds);
  m_ProjectionPlane->SetOrigin(origin);

  // Part III: initialize geometry
  if(m_ClippingGeometry.IsNotNull())
  {
    ScalarType min_dist=ScalarTypeNumericTraits::max(), max_dist=ScalarTypeNumericTraits::min(), dist;
    unsigned char i;
    for(i=0; i<8; ++i)
    {
      dist = m_ProjectionPlane->SignedDistance( m_ClippingGeometry->GetCornerPoint(i) );
      if(dist<min_dist) min_dist=dist;
      if(dist>max_dist) max_dist=dist;
    }
    //incorporate translation along the normal into origin
    origin = origin+m_Vector*min_dist;
    m_ProjectionPlane->SetOrigin(origin);
    bounds[5]=max_dist-min_dist;
  }
  else
    bounds[5]=20;

  itk2vtk(origin, m_Origin);

  mitk::Geometry3D::Pointer g3d = GetGeometry( 0 );
  assert( g3d.IsNotNull() );
  g3d->SetBounds(bounds);
  g3d->SetIndexToWorldTransform(m_ProjectionPlane->GetIndexToWorldTransform());
  g3d->TransferItkToVtkTransform();

  ProportionalTimeGeometry::Pointer timeGeometry = ProportionalTimeGeometry::New();
  timeGeometry->Initialize(g3d,1);
  SetTimeGeometry(timeGeometry);

}
Example #18
0
void mitk::PicFileReader::GenerateData()
{
    Image::Pointer output = this->GetOutput();

    // Check to see if we can read the file given the name or prefix
    //
    if ( m_FileName == "" && m_FilePrefix == "" )
    {
        throw itk::ImageFileReaderException(__FILE__, __LINE__, "One of FileName or FilePrefix must be non-empty");
    }

    if( m_FileName != "")
    {
        mitkIpPicDescriptor* outputPic = mitkIpPicNew();
        outputPic = CastToIpPicDescriptor(output, outputPic);
        mitkIpPicDescriptor* pic=MITKipPicGet(const_cast<char *>(m_FileName.c_str()),
                                              outputPic);
        // comes upside-down (in MITK coordinates) from PIC file
        ConvertHandedness(pic);

        mitkIpPicTSV_t *tsv;
        if ( (tsv = mitkIpPicQueryTag( pic, "SOURCE HEADER" )) != NULL)
        {
          if(tsv->n[0]>1e+06)
          {
            mitkIpPicTSV_t *tsvSH;
            tsvSH = mitkIpPicDelTag( pic, "SOURCE HEADER" );
            mitkIpPicFreeTag(tsvSH);
          }
        }
        if ( (tsv = mitkIpPicQueryTag( pic, "ICON80x80" )) != NULL)
        {
          mitkIpPicTSV_t *tsvSH;
          tsvSH = mitkIpPicDelTag( pic, "ICON80x80" );
          mitkIpPicFreeTag(tsvSH);
        }
        if ( (tsv = mitkIpPicQueryTag( pic, "VELOCITY" )) != NULL)
        {
          mitkIpPicDescriptor* header = mitkIpPicCopyHeader(pic, NULL);
          header->data = tsv->value;
          ConvertHandedness(header);
          output->SetChannel(header->data, 1);
          header->data = NULL;
          mitkIpPicFree(header);
          mitkIpPicDelTag( pic, "VELOCITY" );
        }

        //slice-wise reading
        //currently much too slow.
        //else
        //{
        //  int sstart, smax;
        //  int tstart, tmax;

        //  sstart=output->GetRequestedRegion().GetIndex(2);
        //  smax=sstart+output->GetRequestedRegion().GetSize(2);

        //  tstart=output->GetRequestedRegion().GetIndex(3);
        //  tmax=tstart+output->GetRequestedRegion().GetSize(3);

        //  int s,t;
        //  for(s=sstart; s<smax; ++s)
        //  {
        //    for(t=tstart; t<tmax; ++t)
        //    {
        //      mitkIpPicDescriptor* pic=mitkIpPicGetSlice(const_cast<char *>(m_FileName.c_str()), NULL, t*smax+s+1);
        //      output->SetPicSlice(pic,s,t);
        //    }
        //  }
        //}
    }
    else
    {
        int position;
        mitkIpPicDescriptor*  pic=NULL;

        int zDim=(output->GetDimension()>2?output->GetDimensions()[2]:1);
        printf("\n zdim is %u \n",zDim);

        for (position = 0; position < zDim; ++position) 
        {
            char fullName[1024];

            sprintf(fullName, m_FilePattern.c_str(), m_FilePrefix.c_str(), m_StartFileIndex+position);

            pic=MITKipPicGet(fullName, pic);
            if(pic==NULL)
            {
                itkDebugMacro("Pic file '" << fullName << "' does not exist."); 
            }
            /* FIXME else
            if(output->SetPicSlice(pic, position)==false)
            {
                itkDebugMacro("Image '" << fullName << "' could not be added to Image."); 
            }*/
       }
       if(pic!=NULL)
         mitkIpPicFree(pic);
    }
}
Example #19
0
mitk::DataNode* mitk::Mapper::GetDataNode() const
{
  itkDebugMacro("returning DataNode address " << this->m_DataNode );
  return this->m_DataNode.GetPointer();
}