#ifndef _itkOrganism_txx #define _itkOrganism_txx #include "itkOrganism.h" namespace itk { template ItkOrganism ::ItkOrganism() { //typedef unsigned char PixelType; //const unsigned int Dimension =nDims; //typedef itk::Image< PixelType, Dimension > ImageType; } template char *ItkOrganism< TInputImage, TOutputImage, TExternalForceImage, DataType, nDims>::checkMessages() { char* a=0; return a; } template bool ItkOrganism< TInputImage,TOutputImage, TExternalForceImage, DataType, nDims>::postMessage() { return 0; } template void ItkOrganism< TInputImage,TOutputImage, TExternalForceImage, DataType, nDims>::GenerateData() { //************************* //Create the output image //************************* typename InputImageType::ConstPointer input = this->GetInput(); typename OutputImageType::Pointer output = this->GetOutput(); typename InputImageType::SizeType imageSize; imageSize = (output->GetLargestPossibleRegion()).GetSize(); typedef itk::Image doubleIm; output->SetSpacing( input->GetSpacing() ); // Set the image spacing output->SetOrigin( input->GetOrigin() ); // Set the image origin output->SetRegions(input->GetLargestPossibleRegion()); output->Allocate(); // physLayer->calculateImageForces();*/ //************************* //Run the organism //************************* for(int i=0; irunTime;i++) this->run(); //TODO get output to use binaryImageFromTopology //output = this->geomLayer->generateBinaryImageFromTopology(); typename GeometricType::BinaryImageType::SizeType sz = input->GetLargestPossibleRegion().GetSize(); typename GeometricType::BinaryImageType::Pointer binImg = this->geomLayer->generateBinaryImageFromTopology( sz); itk::ImageRegionIterator out(output,output->GetLargestPossibleRegion()); itk::ImageRegionConstIterator in(binImg,binImg->GetLargestPossibleRegion()); for ( in.GoToBegin(), out.GoToBegin(); !in.IsAtEnd(); ++in, ++out ) { out.Set(in.Get()); } } template int ItkOrganism::run() { //Get pointers to output/input data typename OutputImageType::Pointer output = this->GetOutput(); typename InputImageType::ConstPointer input = this->GetInput(); this->cgLayer->update(); this->physLayer->simulate(); return 0; } template bool ItkOrganism< TInputImage, TOutputImage, TExternalForceImage, DataType, nDims>::setDefaultBehaviour() { return 0; } template bool ItkOrganism< TInputImage, TOutputImage, TExternalForceImage, DataType, nDims>::setSchedule() { return 0; } template void ItkOrganism ::GenerateInputRequestedRegion() throw (InvalidRequestedRegionError) { // call the superclass' implementation of this method Superclass::GenerateInputRequestedRegion(); // get pointers to the input and output typename Superclass::InputImagePointer inputPtr = const_cast< TInputImage * >( this->GetInput() ); typename Superclass::OutputImagePointer outputPtr = this->GetOutput(); if ( !inputPtr || !outputPtr ) { return; } // get a copy of the input requested region (should equal the output requested region) typename TInputImage::RegionType inputRequestedRegion; inputRequestedRegion = inputPtr->GetRequestedRegion(); // crop the input requested region at the input's largest possible region if ( inputRequestedRegion.Crop(inputPtr->GetLargestPossibleRegion()) ) { inputPtr->SetRequestedRegion( inputRequestedRegion ); return; } else { // Couldn't crop the region (requested region is outside the largest // possible region). Throw an exception. // store what we tried to request (prior to trying to crop) inputPtr->SetRequestedRegion( inputRequestedRegion ); // build an exception InvalidRequestedRegionError e(__FILE__, __LINE__); OStringStream msg; msg << static_cast(this->GetNameOfClass()) << "::GenerateInputRequestedRegion()"; e.SetLocation(msg.str().c_str()); e.SetDescription("Requested region is (at least partially) outside the largest possible region."); e.SetDataObject(inputPtr); throw e; } }//end } #endif