[Insight-developers] DataObject::SetRequestedRegion(DataObject *)

Joshua Cates cates@cs.utah.edu
Wed, 12 Sep 2001 15:43:41 -0600 (MDT)


Hi all,

I don't know whether to classify this as a documentation issue or as a
bug, but I think it needs to be addressed in either case.

Implicit in the two code snippets below is the assumption that all outputs
of a ProcessObject are of the same type (note that itk::Mesh also makes
this assumption in Mesh::SetRequestedRegion).

For example, if I create a ProcessObject with two outputs: a Mesh and an
Image, then ProcessObject::GenerateOutputRequestedRegion will be called
with either a Mesh or Image argument and, consequently, either
Image::SetRequestedRegion or Mesh::SetRequestedRegion will fail.

--------------------------

>From itkImageBase.txx:

 template<unsigned int VImageDimension>
 void 
 ImageBase<VImageDimension>
 ::SetRequestedRegion(DataObject *data)
 {
   ImageBase *imgData;
   std::cout << "ImageBase::SetRequestedRegion DataObject = " << data <<
    std::endl;
   imgData = dynamic_cast<ImageBase*>(data);  

   if (imgData)
     {
     m_RequestedRegion = imgData->GetRequestedRegion();
     }
   else
     {
     // pointer could not be cast back down
     std::cerr << "itk::ImageBase::SetRequestedRegion(DataObject*) cannot
                cast "
               << typeid(data).name() << " to "
               << typeid(ImageBase*).name() << std::endl;
     }
 }


>From itkProcessObject.cxx

 /**
  * By default we set all the output requested regions to be the same.
  */
 void 
 ProcessObject
 ::GenerateOutputRequestedRegion(DataObject *output)
 {
   std::vector<DataObjectPointer>::size_type idx;
   for (idx = 0; idx < m_Outputs.size(); ++idx)
     {
     if (m_Outputs[idx] && m_Outputs[idx] != output)
       {
       m_Outputs[idx]->SetRequestedRegion(output);
       }
     }  
 }
--------------

Josh.


______________________________
 Josh Cates			
 School of Computer Science	
 University of Utah
 Email: cates@cs.utah.edu
 Phone: (801) 587-7697
 URL:   www.cs.utk.edu/~cates