diff --git a/CMake/TestCurlMulti.cxx b/CMake/TestCurlMulti.cxx new file mode 100644 index 0000000000000000000000000000000000000000..9b010c115d12798b2a1758bf6117895dcbb79801 --- /dev/null +++ b/CMake/TestCurlMulti.cxx @@ -0,0 +1,12 @@ +#include "curl/curl.h" +#include <iostream> + +int main(int argc,char * argv[]) +{ + CURLM * multiHandle; + multiHandle = curl_multi_init(); + curl_multi_setopt(multiHandle, CURLMOPT_MAXCONNECTS, 10); + curl_multi_cleanup(multiHandle); + + return 0; +} diff --git a/CMakeLists.txt b/CMakeLists.txt index 5b8b35a05faf7433b7ce7a90edf195216d60a317..6804f52783dad0674df9f18c22b9380b7c0ac908 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -366,6 +366,15 @@ IF(OTB_USE_CURL) INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIR}) + # TODO add test to check if curl multi is available + TRY_COMPILE(OTB_CURL_MULTI_AVAILABLE + ${CMAKE_CURRENT_BINARY_DIR}/CMake + ${CMAKE_CURRENT_SOURCE_DIR}/CMake/TestCurlMulti.cxx + CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:PATH=${CURL_INCLUDE_DIR}" "-DLINK_LIBRARIES:STRING=${CURL_LIBRARY}" + OUTPUT_VARIABLE OUTPUT) + IF (OTB_CURL_MULTI_AVAILABLE) + ADD_DEFINITIONS(-DOTB_CURL_MULTI_AVAILABLE) + ENDIF (OTB_CURL_MULTI_AVAILABLE) ENDIF(OTB_USE_CURL) #------------------------------- diff --git a/Code/IO/CMakeLists.txt b/Code/IO/CMakeLists.txt index fc4624bcafdb0871d32ae6e0daac32f55f9b1e43..6ee7fbf2294edcd0c5ba5f85006c72809876d7e3 100644 --- a/Code/IO/CMakeLists.txt +++ b/Code/IO/CMakeLists.txt @@ -12,8 +12,6 @@ IF(NOT OTB_COMPILE_JPEG2000) ENDIF(NOT OTB_COMPILE_JPEG2000) IF( NOT OTB_USE_CURL ) - LIST(REMOVE_ITEM OTBIO_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/otbTileMapImageIOFactory.cxx" ) - LIST(REMOVE_ITEM OTBIO_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/otbTileMapImageIO.cxx" ) LIST(REMOVE_ITEM OTBIO_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/otbTileMapFetcher.cxx" ) ENDIF( NOT OTB_USE_CURL ) @@ -37,7 +35,7 @@ ADD_LIBRARY(OTBIO ${OTBIO_SRCS}) # LINK_INTERFACE_LIBRARIES "" # ) TARGET_LINK_LIBRARIES (OTBIO ${GDAL_LIBRARY} ${OGR_LIBRARY} ${JPEG_LIBRARY} ${TIFF_LIBRARY} ${GEOTIFF_LIBRARY} OTBCommon) -TARGET_LINK_LIBRARIES (OTBIO otbossim otbossimplugins ITKIO ITKCommon dxf otbkml) +TARGET_LINK_LIBRARIES (OTBIO otbossim otbossimplugins ITKIO ITKCommon dxf otbkml tinyXML) IF (OTB_USE_LIBLAS) TARGET_LINK_LIBRARIES(OTBIO otbliblas) @@ -47,7 +45,7 @@ IF( OTB_COMPILE_JPEG2000 ) ENDIF( OTB_COMPILE_JPEG2000 ) IF( OTB_USE_CURL ) - TARGET_LINK_LIBRARIES (OTBIO ${CURL_LIBRARY} tinyXML) + TARGET_LINK_LIBRARIES (OTBIO ${CURL_LIBRARY}) ENDIF( OTB_USE_CURL ) IF(OTB_LIBRARY_PROPERTIES) SET_TARGET_PROPERTIES(OTBIO PROPERTIES ${OTB_LIBRARY_PROPERTIES}) @@ -67,8 +65,6 @@ IF(NOT OTB_INSTALL_NO_DEVELOPMENT) FILE(GLOB __files2 "${CMAKE_CURRENT_SOURCE_DIR}/*.txx") IF( NOT OTB_USE_CURL ) - LIST(REMOVE_ITEM __files1 "${CMAKE_CURRENT_SOURCE_DIR}/otbTileMapImageIOFactory.h" ) - LIST(REMOVE_ITEM __files1 "${CMAKE_CURRENT_SOURCE_DIR}/otbTileMapImageIO.h" ) LIST(REMOVE_ITEM __files1 "${CMAKE_CURRENT_SOURCE_DIR}/otbTileMapFetcher.h" ) ENDIF( NOT OTB_USE_CURL ) diff --git a/Code/IO/otbCoordinateToName.cxx b/Code/IO/otbCoordinateToName.cxx index 2f4203ec6d76fed599d41e125ac7603fcca1a771..c6f740c601112b16ef671f4f3eafa48f5c4af796 100644 --- a/Code/IO/otbCoordinateToName.cxx +++ b/Code/IO/otbCoordinateToName.cxx @@ -20,10 +20,8 @@ #include "otbMacro.h" #include <sstream> -#ifdef OTB_USE_CURL #include "tinyxml.h" -#include <curl/curl.h> -#endif +#include "otbCurlHelper.h" #include "itkMersenneTwisterRandomVariateGenerator.h" @@ -110,59 +108,34 @@ void CoordinateToName::DoEvaluate() m_IsValid = true; } -void CoordinateToName::RetrieveXML(std::ostringstream& urlStream) const +void CoordinateToName::RetrieveXML(const std::ostringstream& urlStream) const { -#ifdef OTB_USE_CURL - CURL * curl; - CURLcode res; - - FILE* output_file = fopen(m_TempFileName.c_str(), "w"); - curl = curl_easy_init(); - - char url[256]; - strcpy(url, urlStream.str().data()); - -// std::cout << url << std::endl; - if (curl) - { - std::vector<char> chunk; - curl_easy_setopt(curl, CURLOPT_URL, url); - - // Set 5s timeout - curl_easy_setopt(curl, CURLOPT_TIMEOUT, 5); - - curl_easy_setopt(curl, CURLOPT_WRITEDATA, output_file); - res = curl_easy_perform(curl); - - fclose(output_file); - /* always cleanup */ - curl_easy_cleanup(curl); - } -#endif + CurlHelper::Pointer curlHelper = CurlHelper::New(); + curlHelper->RetrieveFile(urlStream, m_TempFileName); } void CoordinateToName::ParseXMLGeonames(std::string& placeName, std::string& countryName) const { -#ifdef OTB_USE_CURL TiXmlDocument doc(m_TempFileName.c_str()); - doc.LoadFile(); - TiXmlHandle docHandle(&doc); - - TiXmlElement* childName = docHandle.FirstChild("geonames").FirstChild("geoname"). - FirstChild("name").Element(); - if (childName) + if (doc.LoadFile()) { - placeName = childName->GetText(); - } - TiXmlElement* childCountryName = docHandle.FirstChild("geonames").FirstChild("geoname"). + TiXmlHandle docHandle(&doc); + + TiXmlElement* childName = docHandle.FirstChild("geonames").FirstChild("geoname"). + FirstChild("name").Element(); + if (childName) + { + placeName = childName->GetText(); + } + TiXmlElement* childCountryName = docHandle.FirstChild("geonames").FirstChild("geoname"). FirstChild("countryName").Element(); - if (childCountryName) - { - countryName = childCountryName->GetText(); + if (childCountryName) + { + countryName = childCountryName->GetText(); + } + otbMsgDevMacro(<< "Near " << placeName << " in " << countryName); + remove(m_TempFileName.c_str()); } - otbMsgDevMacro(<< "Near " << placeName << " in " << countryName); - remove(m_TempFileName.c_str()); -#endif } } // namespace otb diff --git a/Code/IO/otbCoordinateToName.h b/Code/IO/otbCoordinateToName.h index e371f1b7186fce2908f69a23f1005d49c52a9aa0..91410e44042c7353897262500eb2fa0f99b0bc21 100644 --- a/Code/IO/otbCoordinateToName.h +++ b/Code/IO/otbCoordinateToName.h @@ -113,7 +113,7 @@ protected: CoordinateToName(); virtual ~CoordinateToName() {} void PrintSelf(std::ostream& os, itk::Indent indent) const; - void RetrieveXML(std::ostringstream& urlStream) const; + void RetrieveXML(const std::ostringstream& urlStream) const; void ParseXMLGeonames(std::string& placeName, std::string& countryName) const; virtual void DoEvaluate(); diff --git a/Code/IO/otbCurlHelper.cxx b/Code/IO/otbCurlHelper.cxx new file mode 100644 index 0000000000000000000000000000000000000000..660a3bb35dab2781607fe062a17d77bbc3bc8c59 --- /dev/null +++ b/Code/IO/otbCurlHelper.cxx @@ -0,0 +1,279 @@ +/*========================================================================= + + Program: ORFEO Toolbox + Language: C++ + Date: $Date$ + Version: $Revision$ + + + Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. + See OTBCopyright.txt for details. + + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "otbCurlHelper.h" +#include "otbMacro.h" + +#ifdef OTB_USE_CURL +#include <curl/curl.h> +#include <cstring> +#endif + +namespace otb +{ + +int CurlHelper::TestUrlAvailability(const std::string& url) const +{ +#ifdef OTB_USE_CURL + // Set up a curl request + CURL * curl; + CURLcode res = CURL_LAST; + curl = curl_easy_init(); + + // Set up the browser + std::string browser = + "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-GB; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11"; + + if (curl) + { + curl_easy_setopt(curl, CURLOPT_USERAGENT, browser.data()); + curl_easy_setopt(curl, CURLOPT_URL, url.data()); + // Set the dummy write function + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &Self::curlDummyWriteFunction); + curl_easy_setopt(curl, CURLOPT_MAXFILESIZE, 1); + + // Perform requet + res = curl_easy_perform(curl); + } + return res; +#else + otbMsgDevMacro(<< "Curl is not available, compile with OTB_USE_CURL to ON"); + return -1; +#endif +} + +int CurlHelper::RetrieveFile(const std::ostringstream& urlStream, std::string filename) const +{ + return RetrieveFile(urlStream.str(), filename); +} + +int CurlHelper::RetrieveFile(const std::string& urlString, std::string filename) const +{ +#ifdef OTB_USE_CURL + CURL * curl; + CURLcode res = CURL_LAST; + + FILE* output_file = fopen(filename.c_str(), "w"); + curl = curl_easy_init(); + + char url[256]; + strcpy(url, urlString.data()); + +// std::cout << url << std::endl; + if (curl) + { + std::vector<char> chunk; + curl_easy_setopt(curl, CURLOPT_URL, url); + + // Set 5s timeout + curl_easy_setopt(curl, CURLOPT_TIMEOUT, 5); + + curl_easy_setopt(curl, CURLOPT_WRITEDATA, output_file); + res = curl_easy_perform(curl); + + fclose(output_file); + /* always cleanup */ + curl_easy_cleanup(curl); + } + return res; +#else + otbMsgDevMacro(<< "Curl is not available, compile with OTB_USE_CURL to ON"); + return -1; +#endif +} + + +int CurlHelper::RetrieveFileMulti(const std::vector<std::string>& listURLs, + const std::vector<std::string>& listFilename, + int maxConnect) const +{ +#ifdef OTB_USE_CURL +#ifdef OTB_CURL_MULTI_AVAILABLE + otbMsgDevMacro(<< "Using curl multi"); + std::string m_Browser = "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-GB; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11"; + + CURLM * multiHandle; + std::vector<CURL *> listCurlHandles; + std::vector<FILE *> listFiles; + + std::vector<std::string>::const_iterator filename; + filename = listFilename.begin(); + while (filename != listFilename.end() ) + { + FILE* lOutputFile = fopen((*filename).c_str(), "w"); + if (lOutputFile == NULL) + { + itkExceptionMacro(<< "otbCurlHelper: bad file name: " << (*filename).c_str()); + } + + // Add file to vector + listFiles.push_back(lOutputFile); + ++filename; + } + + // Initialize curl multi handle + multiHandle = curl_multi_init(); + + if (!multiHandle) + { + itkExceptionMacro(<< "otbCurlHelper: Curl multi handle init error."); + } + + listCurlHandles.clear(); + + // Initialize curl handle + + std::vector<std::string>::const_iterator url; + std::vector<FILE *>::const_iterator file; + url = listURLs.begin(); + file = listFiles.begin(); + while ( (url != listURLs.end()) && (file != listFiles.end() )) + { + CURL * lEasyHandle; + lEasyHandle = curl_easy_init(); + + if (!lEasyHandle) + { + itkExceptionMacro(<< "otbCurlHelper: Curl easy handle init error."); + } + + // Param easy handle + curl_easy_setopt(lEasyHandle, CURLOPT_USERAGENT, m_Browser.data()); + curl_easy_setopt(lEasyHandle, CURLOPT_URL, (*url).data()); + curl_easy_setopt(lEasyHandle, CURLOPT_WRITEDATA, *file); + + // Add easy handle to multi handle + curl_multi_add_handle(multiHandle, lEasyHandle); + + // Add hanle to vector + listCurlHandles.push_back(lEasyHandle); + ++url; + ++file; + } + +//fetch tiles + // Configure multi handle - set the maximum connections + curl_multi_setopt(multiHandle, CURLMOPT_MAXCONNECTS, maxConnect); + curl_multi_setopt(multiHandle, CURLMOPT_PIPELINING, 0); + + // Perform + int lStillRunning; + + while (CURLM_CALL_MULTI_PERFORM == curl_multi_perform(multiHandle, &lStillRunning)); + + // Now get that URL + while (lStillRunning) + { + struct timeval timeout; + int rc; // Return code + + fd_set fdread; + fd_set fdwrite; + fd_set fdexcep; + int maxfd; + + FD_ZERO(&fdread); + FD_ZERO(&fdwrite); + FD_ZERO(&fdexcep); + + /* set a suitable timeout to play around with */ + timeout.tv_sec = 0; + timeout.tv_usec = 1; + + /* get file descriptors from the transfers */ + curl_multi_fdset(multiHandle, &fdread, &fdwrite, &fdexcep, &maxfd); + + rc = select(maxfd + 1, &fdread, &fdwrite, &fdexcep, &timeout); + + switch (rc) + { + case -1: + /* select error */ + break; + case 0: + /* timeout */ + default: + /* timeout or readable/writable sockets */ + while ( + CURLM_CALL_MULTI_PERFORM == curl_multi_perform(multiHandle, &lStillRunning) + ) + ; + break; + } + } + + int remaining_msgs = 1; + int error = 0; + CURLMsg *msg; + while (remaining_msgs) + { + msg = curl_multi_info_read(multiHandle, &remaining_msgs); + if (msg != NULL) + { + if (CURLE_OK != msg->data.result) error = 1; + } + } + + if (error != 0) + { + itkExceptionMacro(<< "otbCurlHelper: Error occurs while perform Multi handle"); + } + + +// Cleanup + + // Close files + for (unsigned int currentFile = 0; currentFile < listFiles.size(); currentFile++) + { + fclose(listFiles[currentFile]); + } + listFiles.clear(); + + // Cleanup easy handles + for (unsigned int currentHandle = 0; currentHandle < listCurlHandles.size(); currentHandle++) + { + curl_easy_cleanup(listCurlHandles[currentHandle]); + } + listCurlHandles.clear(); + + // Cleanup multi handle + curl_multi_cleanup(multiHandle); + + + +#else + //fallback on non curl multi + otbMsgDevMacro(<< "Curl multi is not available, fallback on standard"); + std::vector<std::string>::const_iterator url; + std::vector<FILE *>::const_iterator file; + url = listURLs.begin(); + file = listFiles.begin(); + while ( (url != listURLs.end()) && (file != listFiles.end() )) + { + RetrieveFile(*url, *file); + } +#endif +#else + otbMsgDevMacro(<< "Curl is not available, compile with OTB_USE_CURL to ON"); + return -1; +#endif +} + + +} + diff --git a/Code/IO/otbCurlHelper.h b/Code/IO/otbCurlHelper.h new file mode 100644 index 0000000000000000000000000000000000000000..e0ffa8d10ef7b5b2cdd8d53e349c08bec220e1df --- /dev/null +++ b/Code/IO/otbCurlHelper.h @@ -0,0 +1,67 @@ +/*========================================================================= + + Program: ORFEO Toolbox + Language: C++ + Date: $Date$ + Version: $Revision$ + + + Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. + See OTBCopyright.txt for details. + + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef __otbCurlHelper_h +#define __otbCurlHelper_h + +#include <sstream> +#include "itkObject.h" +#include "itkObjectFactory.h" + +namespace otb +{ +/** + * \class CurlHelper + * \brief Class to use the curl capabilities from OTB + * + */ +class ITK_EXPORT CurlHelper : public itk::Object +{ +public: + /** Standard class typedefs. */ + typedef CurlHelper Self; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + typedef itk::Object Superclass; + + itkTypeMacro(CurlHelper, itk::Object); + itkNewMacro(Self); + + int TestUrlAvailability(const std::string& url) const; + int RetrieveFile(const std::ostringstream& urlStream, std::string filename) const; + int RetrieveFile(const std::string& urlString, std::string filename) const; + + int RetrieveFileMulti(const std::vector<std::string>& listURLs, + const std::vector<std::string>& listFiles, + int maxConnect) const; +protected: + CurlHelper() {} + ~CurlHelper() {} + + +private: + CurlHelper(const Self &); //purposely not implemented + void operator =(const Self&); //purposely not implemented + + size_t curlDummyWriteFunction(void*, size_t, size_t nmemb, void*) + { + return nmemb; + } + +}; +} +#endif diff --git a/Code/IO/otbImageFileReader.h b/Code/IO/otbImageFileReader.h index 322aef38fba4e1c597d98c9dfad96bfc045c668c..f5c69db52eff264e50b6073f7af975a689550f3b 100644 --- a/Code/IO/otbImageFileReader.h +++ b/Code/IO/otbImageFileReader.h @@ -90,10 +90,6 @@ private: */ bool GetGdalReadImageFileName(const std::string& filename, std::string& GdalFileName); - // This is a dummy function to prevent curl from writing data to disk - // when testing http adresses - static size_t curlDummyWriteFunction(void*, size_t, size_t nmemb, void*); - ImageFileReader(const Self &); //purposely not implemented void operator =(const Self&); //purposely not implemented diff --git a/Code/IO/otbImageFileReader.txx b/Code/IO/otbImageFileReader.txx index b8328f95aa71334cd79d7525bddfd4a232769a36..c4318c084b8d336d58ac1eec45b32f68824804d9 100644 --- a/Code/IO/otbImageFileReader.txx +++ b/Code/IO/otbImageFileReader.txx @@ -28,27 +28,20 @@ #include "otbMetaDataKey.h" #include "imaging/ossimImageHandlerRegistry.h" -// #include "ossim/imaging/ossimImageHandlerSarFactory.h" #include "imaging/ossimImageHandler.h" #include "init/ossimInit.h" #include "base/ossimKeywordlist.h" -// #include "ossim/projection/ossimProjectionFactoryRegistry.h" -// #include "ossim/ossimPluginProjectionFactory.h" #include "projection/ossimProjection.h" #include "projection/ossimProjectionFactoryRegistry.h" #include "ossim/ossimPluginProjectionFactory.h" -#ifdef OTB_USE_CURL #include "otbTileMapImageIO.h" //FIXME find a better way #include "projection/ossimTileMapModel.h" -#endif #include <itksys/SystemTools.hxx> #include <fstream> -#ifdef OTB_USE_CURL -#include "curl/curl.h" -#endif +#include "otbCurlHelper.h" namespace otb { @@ -382,7 +375,6 @@ ImageFileReader<TOutputImage> if (projection) { -#ifdef OTB_USE_CURL if (projection->getClassName() == "ossimTileMapModel") { //FIXME find a better way to do that @@ -391,7 +383,6 @@ ImageFileReader<TOutputImage> typename TileMapImageIO::Pointer imageIO = dynamic_cast<TileMapImageIO*>(this->GetImageIO()); dynamic_cast<ossimTileMapModel*>(projection)->setDepth(imageIO->GetDepth()); } -#endif hasMetaData = projection->saveState(geom_kwl); // delete projection; //FIXME find out where this should occur } @@ -453,49 +444,27 @@ void ImageFileReader<TOutputImage> ::TestFileExistanceAndReadability() { -// Handle the curl case -#ifdef OTB_USE_CURL // Test if the file a server name if (this->m_FileName[0] == 'h' && this->m_FileName[1] == 't' && this->m_FileName[2] == 't' && this->m_FileName[3] == 'p') { - // Set up a curl request - CURL * curl; - CURLcode res; - curl = curl_easy_init(); - - // Set up the browser - std::string browser = - "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-GB; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11"; - - if (curl) + CurlHelper::Pointer curlHelper = CurlHelper::New(); + int res = curlHelper->TestUrlAvailability(this->m_FileName); + if (res != 0 && res != 63) // 63 stands for filesize exceed { - curl_easy_setopt(curl, CURLOPT_USERAGENT, browser.data()); - curl_easy_setopt(curl, CURLOPT_URL, this->m_FileName.data()); - // Set the dummy write function - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &Self::curlDummyWriteFunction); - curl_easy_setopt(curl, CURLOPT_MAXFILESIZE, 1); - - // Perform requet - res = curl_easy_perform(curl); - - if (res != 0 && res != 63) // 63 stands for filesize exceed - { - itk::ImageFileReaderException e(__FILE__, __LINE__); - itk::OStringStream msg; - msg << "File name is an http address, but curl fails to connect to it " - << std::endl << "Filename = " << this->m_FileName - << std::endl << "Curl error code = " << res - << std::endl; - e.SetDescription(msg.str().c_str()); - throw e; - } - return; + itk::ImageFileReaderException e(__FILE__, __LINE__); + itk::OStringStream msg; + msg << "File name is an http address, but curl fails to connect to it " + << std::endl << "Filename = " << this->m_FileName + << std::endl << "Curl error code = " << res + << std::endl; + e.SetDescription(msg.str().c_str()); + throw e; } + return; } -#endif // Test if the file exists. if (!itksys::SystemTools::FileExists(this->m_FileName.c_str())) @@ -592,13 +561,6 @@ ImageFileReader<TOutputImage> otbMsgDevMacro(<< "fic_trouve : " << fic_trouve); return (fic_trouve); } -template <class TOutputImage> -size_t -ImageFileReader<TOutputImage> -::curlDummyWriteFunction(void*, size_t, size_t nmemb, void*) -{ - return nmemb; -} } //namespace otb diff --git a/Code/IO/otbTileMapImageIO.cxx b/Code/IO/otbTileMapImageIO.cxx index 9e19210875a0dd6c5ce0747da9ef484e6538eb7f..718d15ee9aec916d3659cd67e5486ece92f3fa9e 100644 --- a/Code/IO/otbTileMapImageIO.cxx +++ b/Code/IO/otbTileMapImageIO.cxx @@ -38,6 +38,8 @@ #include "base/ossimFilename.h" #include "itkTimeProbe.h" +#include "otbCurlHelper.h" + namespace otb { @@ -78,8 +80,6 @@ TileMapImageIO::TileMapImageIO() m_FileNameIsServerName = false; - // Initialize browser - m_Browser = "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-GB; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11"; // Set maximum of connections to 10 m_MaxConnect = 10; @@ -152,17 +152,9 @@ void TileMapImageIO::Read(void* buffer) int nTilesX = (int) ceil(totSamples / 256.) + 1; int nTilesY = (int) ceil(totLines / 256.) + 1; - // Initialize curl multi handle - m_MultiHandle = curl_multi_init(); - - if (!m_MultiHandle) - { - itkExceptionMacro(<< "Tile Map IO : Curl mutli handle init error."); - } // Clear vectors - m_ListCurlHandles.clear(); - m_ListFiles.clear(); + m_ListFilename.clear(); m_ListURLs.clear(); m_ListTiles.clear(); @@ -182,17 +174,16 @@ void TileMapImageIO::Read(void* buffer) // Try to read tile from cache if (!this->CanReadFromCache(m_ListTiles.back().filename)) { - // Generate curl handle for this tile - this->GenerateCURLHandle(m_ListTiles.back()); + this->GenerateURL(m_ListTiles.back().x, m_ListTiles.back().y); + m_ListFilename.push_back(m_ListTiles.back().filename); } } } - // Fetch tiles from net - this->FetchTiles(); + CurlHelper::Pointer curlHelper = CurlHelper::New(); + curlHelper->RetrieveFileMulti(m_ListURLs, m_ListFilename, m_MaxConnect); - // Cleanup datas use to download tiles - this->Cleanup(); + m_ListURLs.clear(); // Generate buffer this->GenerateBuffer(p); @@ -248,46 +239,6 @@ bool TileMapImageIO::CanReadFromCache(std::string filename) return lCanRead; } -/* - * This method generate curl handles and add to multi handle - */ -void TileMapImageIO::GenerateCURLHandle(TileNameAndCoordType tileInfo) -{ - // Generate URL - this->GenerateURL(tileInfo.x, tileInfo.y); - - // Initialize curl handle - CURL * lEasyHandle; - lEasyHandle = curl_easy_init(); - - if (!lEasyHandle) - { - itkExceptionMacro(<< "Tile Map IO : Curl easy handle init error."); - } - - // Create file - FILE* lOutputFile = fopen(tileInfo.filename.c_str(), "w"); - - if (lOutputFile == NULL) - { - itkExceptionMacro(<< "TileMap read : bad file name."); - } - - // Add file to vector - m_ListFiles.push_back(lOutputFile); - - // Param easy handle - curl_easy_setopt(lEasyHandle, CURLOPT_USERAGENT, m_Browser.data()); - curl_easy_setopt(lEasyHandle, CURLOPT_URL, m_ListURLs.back().data()); - curl_easy_setopt(lEasyHandle, CURLOPT_WRITEDATA, m_ListFiles.back()); - - // Add easy handle to multi handle - curl_multi_add_handle(m_MultiHandle, lEasyHandle); - - // Add hanle to vector - m_ListCurlHandles.push_back(lEasyHandle); -} - /* * This method generate URLs */ @@ -345,108 +296,6 @@ void TileMapImageIO::GenerateURL(double x, double y) m_ListURLs.push_back(urlStream.str()); } -/* - * This method perform curl multi handle - */ -void TileMapImageIO::FetchTiles() -{ - // Configure multi handle - set the maximum connections - curl_multi_setopt(m_MultiHandle, CURLMOPT_MAXCONNECTS, m_MaxConnect); - curl_multi_setopt(m_MultiHandle, CURLMOPT_PIPELINING, 0); - - // Perform - int lStillRunning; - - while ( - CURLM_CALL_MULTI_PERFORM == curl_multi_perform(m_MultiHandle, &lStillRunning) - ) - ; - - // Now get that URL - while (lStillRunning) - { - struct timeval timeout; - int rc; // Return code - - fd_set fdread; - fd_set fdwrite; - fd_set fdexcep; - int maxfd; - - FD_ZERO(&fdread); - FD_ZERO(&fdwrite); - FD_ZERO(&fdexcep); - - /* set a suitable timeout to play around with */ - timeout.tv_sec = 0; - timeout.tv_usec = 1; - - /* get file descriptors from the transfers */ - curl_multi_fdset(m_MultiHandle, &fdread, &fdwrite, &fdexcep, &maxfd); - - rc = select(maxfd + 1, &fdread, &fdwrite, &fdexcep, &timeout); - - switch (rc) - { - case -1: - /* select error */ - break; - case 0: - /* timeout */ - default: - /* timeout or readable/writable sockets */ - while ( - CURLM_CALL_MULTI_PERFORM == curl_multi_perform(m_MultiHandle, &lStillRunning) - ) - ; - break; - } - } - - int remaining_msgs = 1; - int error = 0; - CURLMsg *msg; - while (remaining_msgs) - { - msg = curl_multi_info_read(m_MultiHandle, &remaining_msgs); - if (msg != NULL) - { - if (CURLE_OK != msg->data.result) error = 1; - } - } - - if (error != 0) - { - itkExceptionMacro(<< "TileMapImageIO : Error occurs while perform Multi handle"); - } -} - -/* - * This method cleanup datas - */ -void TileMapImageIO::Cleanup() -{ - // Close files - for (unsigned int currentFile = 0; currentFile < m_ListFiles.size(); currentFile++) - { - fclose(m_ListFiles[currentFile]); - } - m_ListFiles.clear(); - - // Cleanup easy handles - for (unsigned int currentHandle = 0; currentHandle < m_ListCurlHandles.size(); currentHandle++) - { - curl_easy_cleanup(m_ListCurlHandles[currentHandle]); - } - m_ListCurlHandles.clear(); - - // Cleanup multi handle - curl_multi_cleanup(m_MultiHandle); - - // Cleanup url vector - m_ListURLs.clear(); -} - /* * This method generate the output buffer */ @@ -458,9 +307,10 @@ void TileMapImageIO::GenerateBuffer(unsigned char *p) int firstSample = this->GetIORegion().GetIndex()[0]; int nComponents = this->GetNumberOfComponents(); + unsigned char * bufferTile = new unsigned char[256 * 256 * nComponents]; for (unsigned int currentTile = 0; currentTile < m_ListTiles.size(); currentTile++) { - unsigned char * bufferTile = new unsigned char[256 * 256 * nComponents]; + // Read tile from cache this->ReadTile(m_ListTiles[currentTile].filename, bufferTile); @@ -495,8 +345,8 @@ void TileMapImageIO::GenerateBuffer(unsigned char *p) } } } //end of tile copy - delete[] bufferTile; } //end of full image copy + delete[] bufferTile; } /* diff --git a/Code/IO/otbTileMapImageIO.h b/Code/IO/otbTileMapImageIO.h index d8734e23053833959e3ad711aabe45baee4687bf..5dca3ed87228deb7c64a93263397d0cc77dddaa1 100644 --- a/Code/IO/otbTileMapImageIO.h +++ b/Code/IO/otbTileMapImageIO.h @@ -30,9 +30,6 @@ #include "itkImageIOBase.h" #include "otbImageRegionTileMapSplitter.h" -/* Curl Library*/ -#include <curl/curl.h> - namespace otb { @@ -190,19 +187,13 @@ private: /** CURL Multi */ void GenerateTileInfo(double x, double y, int numTileX, int numTileY); bool CanReadFromCache(std::string filename); - void GenerateCURLHandle(TileNameAndCoordType tileInfo); void GenerateURL(double x, double y); - void FetchTiles(); - void Cleanup(); void GenerateBuffer(unsigned char * p); void ReadTile(std::string filename, void * buffer); - CURLM * m_MultiHandle; - std::vector<CURL *> m_ListCurlHandles; - std::vector<FILE *> m_ListFiles; + std::vector<std::string> m_ListFilename; std::vector<std::string> m_ListURLs; std::vector<TileNameAndCoordType> m_ListTiles; - std::string m_Browser; int m_MaxConnect; /** Byte per pixel pixel */ diff --git a/Code/Projections/otbPlaceNameToLonLat.cxx b/Code/Projections/otbPlaceNameToLonLat.cxx index da87940b3075e8eaaeef83a2a7d3541f5767a410..6e8115a284c3b3166b7fcb65cd935779e31e3210 100644 --- a/Code/Projections/otbPlaceNameToLonLat.cxx +++ b/Code/Projections/otbPlaceNameToLonLat.cxx @@ -18,7 +18,7 @@ #include "otbPlaceNameToLonLat.h" #include "tinyxml.h" -#include <curl/curl.h> +#include "otbCurlHelper.h" namespace otb { @@ -105,42 +105,10 @@ curlHandlerWriteMemoryCallback(void *ptr, size_t size, size_t nmemb, } */ -void PlaceNameToLonLat::RetrieveXML(std::ostringstream& urlStream) +void PlaceNameToLonLat::RetrieveXML(const std::ostringstream& urlStream) { - - CURL * curl; - CURLcode res; - - FILE* output_file = fopen("out.xml", "w"); - curl = curl_easy_init(); - -// std::cout << "URL data " << urlStream.str().data() << std::endl; - - char url[256]; - strcpy(url, urlStream.str().data()); - -// std::cout << url << std::endl; - if (curl) - { - std::vector<char> chunk; - curl_easy_setopt(curl, CURLOPT_URL, url); - /* - //Step needed to handle curl without temporary file - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION,this->curlHandlerWriteMemoryCallback); - curl_easy_setopt(curl, CURLOPT_FILE, (void *)&chunk); - */ - - // Set 5s timeout - curl_easy_setopt(curl, CURLOPT_TIMEOUT, 5); - - curl_easy_setopt(curl, CURLOPT_WRITEDATA, output_file); - res = curl_easy_perform(curl); - - fclose(output_file); - /* always cleanup */ - curl_easy_cleanup(curl); - } - + CurlHelper::Pointer curlHelper = CurlHelper::New(); + curlHelper->RetrieveFile(urlStream, "out.xml"); } void PlaceNameToLonLat::ParseXMLYahoo() diff --git a/Code/Projections/otbPlaceNameToLonLat.h b/Code/Projections/otbPlaceNameToLonLat.h index f68a3671a4293f6df6629921ad33a5c64ae59919..d09a28f10880c21bd096d9e0b54ade05d14af03f 100644 --- a/Code/Projections/otbPlaceNameToLonLat.h +++ b/Code/Projections/otbPlaceNameToLonLat.h @@ -59,7 +59,7 @@ protected: PlaceNameToLonLat(); virtual ~PlaceNameToLonLat() {} void PrintSelf(std::ostream& os, itk::Indent indent) const; - void RetrieveXML(std::ostringstream& urlStream); + void RetrieveXML(const std::ostringstream& urlStream); void ParseXMLYahoo(); void ParseXMLGoogle(); void ParseXMLGeonames(); //Not implemented yet TODO diff --git a/Examples/Markov/CMakeLists.txt b/Examples/Markov/CMakeLists.txt index de989de77155df986ef14057bc0b85ab89b69d13..da3b0cb6e620cd3932521cf29e603dec729f87f1 100644 --- a/Examples/Markov/CMakeLists.txt +++ b/Examples/Markov/CMakeLists.txt @@ -77,7 +77,7 @@ ADD_TEST(maTeMarkovRegularizationExampleTest ${EXE_TESTS} ${TEMP}/MarkovRegularization-scaled.png 0.2 20 - 1.0 + 0.0 1 # true to use always the same rand() sample, false otherwis ) diff --git a/Examples/Markov/MarkovRegularizationExample.cxx b/Examples/Markov/MarkovRegularizationExample.cxx index 37f9e582ae4f0e6434948063b8c7f1a7a4fc84f0..655c2ef29a0016cdea251fea71e3cf6c5e21b1f8 100644 --- a/Examples/Markov/MarkovRegularizationExample.cxx +++ b/Examples/Markov/MarkovRegularizationExample.cxx @@ -27,7 +27,7 @@ // Software Guide : BeginCommandLineArgs // INPUTS: {ROI_QB_MUL_1_SVN_CLASS_MULTI.png} // OUTPUTS: {MarkovRegularization.png}, {MarkovRegularization-scaled.png} -// 0.2 20 1.0 1 +// 0.2 20 0.0 1 // Software Guide : EndCommandLineArgs // Software Guide : BeginLatex @@ -139,7 +139,7 @@ int main(int argc, char* argv[]) unsigned int nClass = labelledStat->GetNumberOfLabels(); // Software Guide : EndCodeSnippet - optimizer->SetParameters(atoi(argv[6])); + optimizer->SetSingleParameter(0.0); markovFilter->SetNumberOfClasses(nClass); markovFilter->SetMaximumNumberOfIterations(atoi(argv[5])); markovFilter->SetErrorTolerance(0.0); diff --git a/OTBConfig.cmake.in b/OTBConfig.cmake.in index c37c000939598bf616f91d65070af61e58cebe39..4e3457b23d7db62afd28984584fd4cc6efe47089 100644 --- a/OTBConfig.cmake.in +++ b/OTBConfig.cmake.in @@ -109,6 +109,7 @@ SET(OTB_GL_USE_ACCEL "@OTB_GL_USE_ACCEL@") # Curl library SET(OTB_USE_CURL "@OTB_USE_CURL@") +SET(OTB_CURL_MULTI_AVAILABLE "@OTB_CURL_MULTI_AVAILABLE@") #Developpers message SET(OTB_SHOW_ALL_MSG_DEBUG "@OTB_SHOW_ALL_MSG_DEBUG@") diff --git a/UseOTB.cmake.in b/UseOTB.cmake.in index e4e15b41c3e9d8990f5722862255e1b78ef6790b..7dac912f8aff53aec5060b35ceb86960d1ac25b9 100644 --- a/UseOTB.cmake.in +++ b/UseOTB.cmake.in @@ -132,3 +132,7 @@ ENDIF(OTB_USE_EXTERNAL_GDAL) IF(OTB_USE_CURL) ADD_DEFINITIONS(-DOTB_USE_CURL) ENDIF(OTB_USE_CURL) + +IF(OTB_CURL_MULTI_AVAILABLE) +ADD_DEFINITIONS(-DOTB_CURL_MULTI_AVAILABLE) +ENDIF(OTB_CURL_MULTI_AVAILABLE) diff --git a/Utilities/ITK/CMake/FindNUMARRAY.cmake b/Utilities/ITK/CMake/FindNUMARRAY.cmake index d268e865fa74ead730cf509659e1f0f2a6fc7fc4..33c4130871f8ffee6f8a580e6e659393ba621cc4 100644 --- a/Utilities/ITK/CMake/FindNUMARRAY.cmake +++ b/Utilities/ITK/CMake/FindNUMARRAY.cmake @@ -8,6 +8,7 @@ FIND_PATH(PYTHON_NUMARRAY_INCLUDE_DIR arrayobject.h /usr/include/python2.3/numarray/ + /usr/share/pyshared/numpy/core/include/numpy/ DOC "Directory where the arrayobject.h header file can be found. This file is part of the numarray package" ) diff --git a/Utilities/ITK/CMake/InsightValgrind.supp b/Utilities/ITK/CMake/InsightValgrind.supp index 28a4cc2981702bd22ab2495f71f35e28148a6aee..59d4fcff987bf13fe29d50452f28bd046d1e6688 100644 --- a/Utilities/ITK/CMake/InsightValgrind.supp +++ b/Utilities/ITK/CMake/InsightValgrind.supp @@ -214,9 +214,606 @@ fun:malloc fun:Tcl_Alloc fun:TclAllocateFreeObjects - fun:Tcl_NewObj } +{ + CrazyTclError11 + Memcheck:Leak + fun:malloc + fun:realloc + fun:Tcl_Realloc + fun:Tcl_Export +} + +{ + CrazyTclError12 + Memcheck:Leak + fun:malloc + ... + fun:getpwuid_r + fun:getpwuid + ... + fun:Tcl_CreateInterp +} + +{ + CrazyTclError13 + Memcheck:Leak + fun:calloc + ... + fun:getpwuid_r + fun:getpwuid + ... + fun:Tcl_CreateInterp +} + +{ + CrazyTclError14 + Memcheck:Leak + fun:realloc + fun:Tcl_Realloc + fun:Tcl_Export +} + +{ + CrazyTclError15 + Memcheck:Leak + fun:malloc + ... + fun:Tcl_ListObjIndex + fun:Tcl_SetEnsembleMappingDict +} + +{ + CrazyTclEroor16 + Memcheck:Leak + fun:malloc + fun:TclpAlloc + fun:Tcl_Alloc + fun:Tcl_GetThreadData + fun:Tcl_InitNotifier + fun:TclInitNotifier + fun:Tcl_FindExecutable + fun:Tcl_Main + fun:main +} + +{ + CrazyTclError17 + Memcheck:Leak + fun:malloc + fun:TclpAlloc + fun:Tcl_Alloc + fun:TclCreateExecEnv + fun:Tcl_CreateInterp + fun:Tcl_Main + fun:main +} + +{ + CrazyTclError18 + Memcheck:Leak + fun:malloc + fun:TclpAlloc + fun:TclpRealloc + fun:Tcl_Realloc + fun:Tcl_DStringSetLength + fun:Tcl_ExternalToUtfDString + fun:TclpFindVariable + fun:TclGetEnv + obj:/usr/lib/libtcl8.4.so.0 + obj:/usr/lib/libtcl8.4.so.0 + fun:TclVarTraceExists + obj:/usr/lib/libtcl8.4.so.0 +} + +{ + CrazyTclError19 + Memcheck:Leak + fun:malloc + fun:TclpAlloc + fun:Tcl_Alloc + obj:/usr/lib/libtcl8.4.so.0 + obj:/usr/lib/libtcl8.4.so.0 + obj:/usr/lib/libtcl8.4.so.0 + fun:Tcl_FSEvalFile + fun:TclEvalObjvInternal + fun:Tcl_EvalObjv + fun:Tcl_EvalObjEx + fun:Tcl_UplevelObjCmd + fun:TclEvalObjvInternal +} + +{ + CrazyTclError20 + Memcheck:Leak + fun:malloc + fun:TclpAlloc + fun:TclpRealloc + fun:Tcl_Realloc + fun:Tcl_SetObjLength + obj:/usr/lib/libtcl8.4.so.0 + obj:/usr/lib/libtcl8.4.so.0 + fun:Tcl_FSEvalFile + fun:TclEvalObjvInternal + fun:Tcl_EvalObjv + fun:Tcl_EvalObjEx + fun:Tcl_UplevelObjCmd +} + +{ + CrazyTclError21 + Memcheck:Leak + fun:malloc + fun:TclpAlloc + fun:Tcl_Alloc + fun:TclCompileScript + obj:/usr/lib/libtcl8.4.so.0 + obj:/usr/lib/libtcl8.4.so.0 + fun:TclCompileExpr + fun:TclCompileIfCmd + fun:TclCompileScript + fun:TclCompileIfCmd + fun:TclCompileScript + fun:TclCompileIfCmd +} + +{ + CrazyTclError22 + Memcheck:Leak + fun:malloc + fun:TclpAlloc + fun:Tcl_Alloc + fun:Tcl_ListObjAppendElement + fun:TclGlob + fun:Tcl_GlobObjCmd + fun:TclEvalObjvInternal + obj:/usr/lib/libtcl8.4.so.0 + fun:TclCompEvalObj + fun:TclObjInterpProc + fun:TclEvalObjvInternal + obj:/usr/lib/libtcl8.4.so.0 +} + +{ + CrazyTclError23 + Memcheck:Leak + fun:malloc + fun:TclpAlloc + fun:Tcl_Alloc + fun:TclCompileScript + fun:TclCompileTokens + fun:TclCompileExprWords + fun:TclCompileScript + fun:TclCompileTokens + fun:TclCompileSetCmd + fun:TclCompileScript + fun:TclCompileIfCmd + fun:TclCompileScript +} + +{ + CrazyTclError24 + Memcheck:Leak + fun:malloc + fun:TclThreadAllocObj + fun:Tcl_NewObj + fun:TclNewFSPathObj + fun:TclpMatchInDirectory + fun:Tcl_FSMatchInDirectory + fun:TclDoGlob + fun:TclDoGlob + fun:TclDoGlob + fun:TclDoGlob + fun:TclDoGlob + fun:TclDoGlob +} + +{ + CrayTclError25 + Memcheck:Leak + fun:malloc + fun:TclpAlloc + fun:TclpRealloc + fun:Tcl_AttemptSetObjLength + obj:/usr/lib/libtcl8.4.so.0 + fun:Tcl_AppendObjToObj + obj:/usr/lib/libtcl8.4.so.0 + fun:Tcl_GetStringFromObj + obj:/usr/lib/libtcl8.4.so.0 + fun:Tcl_GetStringFromObj + obj:/usr/lib/libtcl8.4.so.0 + fun:TclCompEvalObj +} + +{ + CrazyTclError26 + Memcheck:Leak + fun:malloc + fun:TclpAlloc + fun:Tcl_Alloc + fun:Tcl_ListObjAppendElement + fun:TclpMatchInDirectory + fun:Tcl_FSMatchInDirectory + fun:TclDoGlob + fun:TclDoGlob + fun:TclDoGlob + fun:TclDoGlob + fun:TclDoGlob + fun:TclDoGlob +} + +{ + CrazyTclError27 + Memcheck:Leak + fun:malloc + fun:TclpAlloc + fun:Tcl_Alloc + obj:/usr/lib/libtcl8.4.so.0 + obj:/usr/lib/libtcl8.4.so.0 + fun:Tcl_WriteObj + fun:Tcl_PutsObjCmd + fun:TclEvalObjvInternal + obj:/usr/lib/libtcl8.4.so.0 + fun:TclCompEvalObj + fun:TclObjInterpProc + fun:TclEvalObjvInternal +} + +{ + CrazyTclError28 + Memcheck:Leak + fun:malloc + fun:TclThreadAllocObj + fun:Tcl_NewStringObj + fun:TclNewFSPathObj + fun:TclpMatchInDirectory + fun:Tcl_FSMatchInDirectory + fun:TclDoGlob + fun:TclDoGlob + fun:TclDoGlob + fun:TclDoGlob + fun:TclDoGlob + fun:TclDoGlob +} + +{ + CrazyTclError29 + Memcheck:Leak + fun:malloc + fun:TclpAlloc + fun:Tcl_Alloc + fun:TclInitByteCodeObj + fun:TclSetByteCodeFromAny + obj:/usr/lib/libtcl8.4.so.0 + fun:TclObjInterpProc + fun:TclEvalObjvInternal + obj:/usr/lib/libtcl8.4.so.0 + fun:TclCompEvalObj + fun:TclObjInterpProc + fun:TclEvalObjvInternal +} + +{ + CrazyTclError30 + Memcheck:Leak + fun:malloc + fun:TclpAlloc + fun:Tcl_Alloc + obj:/usr/lib/libtcl8.4.so.0 + obj:/usr/lib/libtcl8.4.so.0 + obj:/usr/lib/libtcl8.4.so.0 + fun:Tcl_GetsObj + fun:Tcl_Gets + obj:/usr/lib/libtcl8.4.so.0 + fun:Tcl_SetSystemEncoding + fun:TclpSetInitialEncodings + obj:/usr/lib/libtcl8.4.so.0 +} + +{ + CrazyTclError31 + Memcheck:Leak + fun:malloc + fun:TclpAlloc + fun:Tcl_Alloc + fun:TclCompileScript + fun:TclCompileIfCmd + fun:TclCompileScript + fun:TclCompileIfCmd + fun:TclCompileScript + fun:TclCompileWhileCmd + fun:TclCompileScript + fun:TclCompileIfCmd + fun:TclCompileScript +} + +{ + CrazyTclError32 + Memcheck:Leak + fun:malloc + fun:TclpAlloc + fun:Tcl_Alloc + fun:TclExpandCodeArray + fun:TclCompileIncrCmd + fun:TclCompileScript + fun:TclCompileIfCmd + fun:TclCompileScript + fun:TclCompileWhileCmd + fun:TclCompileScript + fun:TclCompileIfCmd + fun:TclCompileScript +} + +{ + CrazyTclError33 + Memcheck:Leak + fun:malloc + fun:TclpAlloc + fun:Tcl_Alloc + fun:Tcl_CreateHashEntry + fun:TclLookupArrayElement + obj:/usr/lib/libtcl8.4.so.0 + fun:TclCompEvalObj + fun:TclObjInterpProc + fun:TclEvalObjvInternal + obj:/usr/lib/libtcl8.4.so.0 + fun:TclCompEvalObj + fun:TclObjInterpProc +} + +{ + CrazyTclError34 + Memcheck:Leak + fun:malloc + fun:TclThreadAllocObj + fun:Tcl_NewStringObj + fun:TclpNativeSplitPath + fun:Tcl_FSSplitPath + obj:/usr/lib/libtcl8.4.so.0 + fun:TclFSEnsureEpochOk + fun:Tcl_FSGetFileSystemForPath + fun:Tcl_FSAccess + obj:/usr/lib/libtcl8.4.so.0 + fun:Tcl_FileObjCmd +} + +{ + CrazyTclError35 + Memcheck:Leak + fun:malloc + fun:TclThreadAllocObj + fun:Tcl_NewStringObj + fun:TclpNativeSplitPath + fun:Tcl_FSSplitPath + obj:/usr/lib/libtcl8.4.so.0 + fun:Tcl_FSGetNormalizedPath + fun:TclFSEnsureEpochOk + fun:Tcl_FSGetFileSystemForPath + fun:Tcl_FSAccess + obj:/usr/lib/libtcl8.4.so.0 + fun:Tcl_FileObjCmd +} + +{ + CrazyTclError36 + Memcheck:Leak + fun:malloc + fun:TclThreadAllocObj + fun:Tcl_NewLongObj + obj:/usr/lib/libtcl8.4.so.0 + fun:Tcl_ExprObj + obj:/usr/lib/libtcl8.4.so.0 + fun:TclCompEvalObj + fun:TclObjInterpProc + fun:TclEvalObjvInternal + obj:/usr/lib/libtcl8.4.so.0 + fun:TclCompEvalObj + fun:TclObjInterpProc +} +{ + CrazyTclError37 + Memcheck:Leak + fun:malloc + fun:TclpAlloc + fun:Tcl_Alloc + obj:/usr/lib/libtcl8.4.so.0 + obj:/usr/lib/libtcl8.4.so.0 + fun:Tcl_SetSystemEncoding + fun:TclpSetInitialEncodings + obj:/usr/lib/libtcl8.4.so.0 + fun:Tcl_FindExecutable + fun:Tcl_Main + fun:main +} +{ + CrazyTclError38 + Memcheck:Leak + fun:malloc + fun:TclpAlloc + fun:Tcl_Alloc + fun:TclCompileScript + fun:TclCompileTokens + fun:TclCompileExprWords + fun:TclCompileExprCmd + fun:TclCompileScript + fun:TclCompileTokens + fun:TclCompileSetCmd + fun:TclCompileScript + fun:TclCompileCmdWord +} +{ + CrazyTclError39 + Memcheck:Leak + fun:malloc + fun:TclpAlloc + fun:Tcl_Alloc + fun:TclCompileScript + obj:/usr/lib/libtcl8.4.so.0 + obj:/usr/lib/libtcl8.4.so.0 + fun:TclCompileExpr + fun:TclCompileExprWords + fun:TclCompileIfCmd + fun:TclCompileScript + fun:TclCompileCmdWord + fun:TclCompileIfCmd +} +{ + CrazyTclError40 + Memcheck:Leak + fun:malloc + fun:TclpAlloc + fun:Tcl_Alloc + obj:/usr/lib/libtcl8.4.so.0 + obj:/usr/lib/libtcl8.4.so.0 + fun:Tcl_SetSystemEncoding + fun:TclpSetInitialEncodings + obj:/usr/lib/libtcl8.4.so.0 + fun:Tcl_FindExecutable + fun:Tcl_Main + fun:main +} +{ + CrazyTclError41 + Memcheck:Leak + fun:malloc + fun:TclpAlloc + fun:Tcl_Alloc + obj:/usr/lib/libtcl8.4.so.0 + obj:/usr/lib/libtcl8.4.so.0 + fun:Tcl_SetSystemEncoding + fun:TclpSetInitialEncodings + obj:/usr/lib/libtcl8.4.so.0 + fun:Tcl_FindExecutable + fun:Tcl_Main + fun:main +} +{ + CrazyTclError42 + Memcheck:Leak + fun:malloc + fun:TclpAlloc + fun:TclpRealloc + fun:Tcl_AttemptRealloc + fun:Tcl_AttemptSetObjLength + obj:/usr/lib/libtcl8.4.so.0 + fun:Tcl_AppendObjToObj + obj:/usr/lib/libtcl8.4.so.0 + fun:Tcl_GetStringFromObj + obj:/usr/lib/libtcl8.4.so.0 + fun:Tcl_GetStringFromObj + obj:/usr/lib/libtcl8.4.so.0 +} +{ + CrayTclError43 + Memcheck:Leak + fun:malloc + fun:TclpAlloc + fun:Tcl_Alloc + fun:TclCompileScript + fun:TclCompileTokens + fun:TclCompileExprWords + fun:TclCompileExprCmd + fun:TclCompileScript + fun:TclCompileTokens + fun:TclCompileSetCmd + fun:TclCompileScript + fun:TclCompileCmdWord +} +{ + CrazyTclError44 + Memcheck:Leak + fun:malloc + fun:TclpAlloc + fun:Tcl_Alloc + fun:TclCompileScript + obj:/usr/lib/libtcl8.4.so.0 + obj:/usr/lib/libtcl8.4.so.0 + fun:TclCompileExpr + fun:TclCompileExprWords + fun:TclCompileIfCmd + fun:TclCompileScript + fun:TclCompileCmdWord + fun:TclCompileIfCmd +} +{ + CrazyTclError45 + Memcheck:Leak + fun:malloc + fun:TclpAlloc + fun:Tcl_Alloc + obj:/usr/lib/libtcl8.4.so.0 + obj:/usr/lib/libtcl8.4.so.0 + fun:Tcl_SetSystemEncoding + fun:TclpSetInitialEncodings + obj:/usr/lib/libtcl8.4.so.0 + fun:Tcl_FindExecutable + fun:Tcl_Main + fun:main +} +{ + CrazyTclError46 + Memcheck:Leak + fun:malloc + fun:TclpAlloc + fun:Tcl_Alloc + fun:TclCompileScript + fun:TclCompileTokens + fun:TclCompileExprWords + fun:TclCompileExprCmd + fun:TclCompileScript + fun:TclCompileTokens + fun:TclCompileSetCmd + fun:TclCompileScript + fun:TclCompileCmdWord +} +{ + CrazyTclError47 + Memcheck:Leak + fun:malloc + fun:TclpAlloc + fun:Tcl_Alloc + fun:TclCompileScript + obj:/usr/lib/libtcl8.4.so.0 + obj:/usr/lib/libtcl8.4.so.0 + fun:TclCompileExpr + fun:TclCompileExprWords + fun:TclCompileIfCmd + fun:TclCompileScript + fun:TclCompileCmdWord + fun:TclCompileIfCmd +} +{ + CrazyTclError48 + Memcheck:Leak + fun:malloc + fun:TclpAlloc + fun:Tcl_Alloc + fun:TclCompileScript + obj:/usr/lib/libtcl8.4.so.0 + obj:/usr/lib/libtcl8.4.so.0 + fun:TclCompileExpr + fun:TclCompileExprWords + fun:TclCompileIfCmd + fun:TclCompileScript + fun:TclCompileCmdWord + fun:TclCompileIfCmd +} +{ + CrazyTclError49 + Memcheck:Leak + fun:malloc + fun:TclpAlloc + fun:Tcl_Alloc + obj:/usr/lib/libtcl8.4.so.0 + obj:/usr/lib/libtcl8.4.so.0 + fun:Tcl_SetSystemEncoding + fun:TclpSetInitialEncodings + obj:/usr/lib/libtcl8.4.so.0 + fun:Tcl_FindExecutable + fun:Tcl_Main + fun:main +} { <insert a suppression name here> Memcheck:Leak @@ -419,6 +1016,283 @@ dlopen leak2 Memcheck:Leak fun:calloc - obj:/lib/libdl-2.3.?.so + obj:/lib/libdl-2.?.?.so fun:dlopen* } +{ + <insert_a_suppression_name_here> + Memcheck:Leak + fun:malloc + fun:TclpAlloc + fun:Tcl_Alloc + fun:Tcl_GetThreadData + fun:Tcl_InitNotifier + fun:TclInitNotifier + fun:TclInitSubsystems + fun:Tcl_FindExecutable + fun:Tcl_Main + fun:main +} +{ + <insert_a_suppression_name_here> + Memcheck:Leak + fun:malloc + fun:TclpAlloc + fun:Tcl_Alloc + fun:Tcl_CreateChannel + fun:Tcl_MakeFileChannel + fun:TclpGetDefaultStdChannel + fun:Tcl_GetStdChannel + fun:Tcl_GetChannel + fun:Tcl_PutsObjCmd + fun:TclEvalObjvInternal + obj:/usr/lib/libtcl8.4.so.0 + fun:TclCompEvalObj +} +{ + <insert_a_suppression_name_here> + Memcheck:Leak + fun:malloc + fun:TclpAlloc + fun:Tcl_Alloc + obj:/usr/lib/libtcl8.4.so.0 + fun:Tcl_GetStringFromObj + obj:/usr/lib/libtcl8.4.so.0 + fun:TclCompEvalObj + fun:TclObjInterpProc + fun:TclEvalObjvInternal + obj:/usr/lib/libtcl8.4.so.0 + fun:TclCompEvalObj + fun:TclObjInterpProc +} +{ + <insert_a_suppression_name_here> + Memcheck:Leak + fun:malloc + fun:TclpAlloc + fun:Tcl_Alloc + obj:/usr/lib/libtcl8.4.so.0 + obj:/usr/lib/libtcl8.4.so.0 + obj:/usr/lib/libtcl8.4.so.0 + fun:Tcl_GetsObj + fun:Tcl_GetsObjCmd + fun:TclEvalObjvInternal + obj:/usr/lib/libtcl8.4.so.0 + fun:TclCompEvalObj + fun:TclObjInterpProc +} +{ + <insert_a_suppression_name_here> + Memcheck:Leak + fun:malloc + fun:TclpAlloc + fun:Tcl_Alloc + obj:/usr/lib/libtcl8.4.so.0 + obj:/usr/lib/libtcl8.4.so.0 + obj:/usr/lib/libtcl8.4.so.0 + fun:Tcl_GetsObj + fun:Tcl_GetsObjCmd + fun:TclEvalObjvInternal + obj:/usr/lib/libtcl8.4.so.0 + fun:TclCompEvalObj + fun:TclObjInterpProc +} +{ + <insert_a_suppression_name_here> + Memcheck:Leak + fun:malloc + fun:TclpAlloc + fun:Tcl_Alloc + obj:/usr/lib/libtcl8.4.so.0 + obj:/usr/lib/libtcl8.4.so.0 + obj:/usr/lib/libtcl8.4.so.0 + fun:Tcl_GetsObj + fun:Tcl_GetsObjCmd + fun:TclEvalObjvInternal + obj:/usr/lib/libtcl8.4.so.0 + fun:TclCompEvalObj + fun:TclObjInterpProc +} +{ + <insert_a_suppression_name_here> + Memcheck:Leak + fun:malloc + fun:TclpAlloc + fun:Tcl_Alloc + fun:Tcl_MutexLock + fun:TclInitObjSubsystem + fun:TclInitSubsystems + fun:Tcl_FindExecutable + fun:Tcl_Main + fun:main +} +{ + <insert_a_suppression_name_here> + Memcheck:Leak + fun:malloc + fun:TclpAlloc + fun:Tcl_Alloc + fun:Tcl_CreateHashEntry + fun:Tcl_RegisterObjType + fun:TclInitObjSubsystem + fun:TclInitSubsystems + fun:Tcl_FindExecutable + fun:Tcl_Main + fun:main +} +{ + <insert_a_suppression_name_here> + Memcheck:Leak + fun:malloc + fun:TclpAlloc + fun:Tcl_Alloc + obj:/usr/lib/libtcl8.4.so.0 + obj:/usr/lib/libtcl8.4.so.0 + obj:/usr/lib/libtcl8.4.so.0 + fun:Tcl_GetsObj + fun:Tcl_Gets + obj:/usr/lib/libtcl8.4.so.0 + fun:TclpSetInitialEncodings + obj:/usr/lib/libtcl8.4.so.0 + fun:Tcl_FindExecutable +} +{ + <insert_a_suppression_name_here> + Memcheck:Leak + fun:malloc + fun:TclpAlloc + fun:Tcl_Alloc + obj:/usr/lib/libtcl8.4.so.0 + obj:/usr/lib/libtcl8.4.so.0 + fun:TclpSetInitialEncodings + obj:/usr/lib/libtcl8.4.so.0 + fun:Tcl_FindExecutable + fun:Tcl_Main + fun:main +} +{ + <insert_a_suppression_name_here> + Memcheck:Leak + fun:malloc + fun:TclpAlloc + fun:Tcl_Alloc + obj:/usr/lib/libtcl8.4.so.0 + obj:/usr/lib/libtcl8.4.so.0 + obj:/usr/lib/libtcl8.4.so.0 + fun:Tcl_FSEvalFile + fun:Tcl_SourceObjCmd + fun:TclEvalObjvInternal + fun:Tcl_EvalObjv + fun:Tcl_EvalObjEx + fun:Tcl_UplevelObjCmd +} +{ + <insert_a_suppression_name_here> + Memcheck:Leak + fun:malloc + fun:TclpAlloc + fun:Tcl_Alloc + obj:/usr/lib/libtcl8.4.so.0 + obj:/usr/lib/libtcl8.4.so.0 + obj:/usr/lib/libtcl8.4.so.0 + fun:Tcl_FSEvalFile + fun:Tcl_SourceObjCmd + fun:TclEvalObjvInternal + fun:Tcl_EvalObjv + fun:Tcl_EvalObjEx + fun:Tcl_UplevelObjCmd +} +{ + <insert_a_suppression_name_here> + Memcheck:Leak + fun:malloc + fun:TclpAlloc + fun:TclpRealloc + fun:Tcl_Realloc + fun:Tcl_SetObjLength + obj:/usr/lib/libtcl8.4.so.0 + obj:/usr/lib/libtcl8.4.so.0 + fun:Tcl_FSEvalFile + fun:Tcl_SourceObjCmd + fun:TclEvalObjvInternal + fun:Tcl_EvalObjv + fun:Tcl_EvalObjEx +} +{ + <insert_a_suppression_name_here> + Memcheck:Leak + fun:malloc + fun:TclpAlloc + fun:Tcl_Alloc + fun:Tcl_NewStringObj + fun:Tcl_EvalTokensStandard + fun:Tcl_EvalEx + fun:Tcl_FSEvalFile + fun:Tcl_SourceObjCmd + fun:TclEvalObjvInternal + fun:Tcl_EvalObjv + fun:Tcl_EvalObjEx + fun:Tcl_UplevelObjCmd +} +{ + <insert_a_suppression_name_here> + Memcheck:Leak + fun:malloc + fun:TclpAlloc + fun:TclpRealloc + fun:Tcl_Realloc + fun:Tcl_SetObjLength + obj:/usr/lib/libtcl8.4.so.0 + obj:/usr/lib/libtcl8.4.so.0 + fun:Tcl_FSEvalFile + fun:Tcl_Main + fun:main +} +{ + <insert_a_suppression_name_here> + Memcheck:Leak + fun:malloc + fun:TclpAlloc + fun:Tcl_Alloc + fun:Tcl_CreateChannel + fun:Tcl_MakeFileChannel + fun:TclpGetDefaultStdChannel + fun:Tcl_GetStdChannel + obj:/usr/lib/libtcl8.4.so.0 + fun:Tcl_GetChannel + fun:Tcl_PutsObjCmd + fun:TclEvalObjvInternal + obj:/usr/lib/libtcl8.4.so.0 +} +{ + <insert_a_suppression_name_here> + Memcheck:Leak + fun:malloc + fun:TclpAlloc + fun:Tcl_Alloc + obj:/usr/lib/libtcl8.4.so.0 + obj:/usr/lib/libtcl8.4.so.0 + obj:/usr/lib/libtcl8.4.so.0 + fun:Tcl_GetsObj + fun:Tcl_GetsObjCmd + fun:TclEvalObjvInternal + obj:/usr/lib/libtcl8.4.so.0 + fun:TclCompEvalObj + fun:TclObjInterpProc +} +{ + <insert_a_suppression_name_here> + Memcheck:Leak + fun:malloc + fun:TclpAlloc + fun:TclpRealloc + fun:Tcl_AttemptRealloc + fun:Tcl_AttemptSetObjLength + obj:/usr/lib/libtcl8.4.so.0 + fun:Tcl_EvalTokensStandard + fun:Tcl_EvalEx + fun:Tcl_FSEvalFile + fun:Tcl_SourceObjCmd + fun:TclEvalObjvInternal + fun:Tcl_EvalObjv +} diff --git a/Utilities/ITK/CMake/itkTestCStyleIOWCharFilename.cxx b/Utilities/ITK/CMake/itkTestCStyleIOWCharFilename.cxx new file mode 100644 index 0000000000000000000000000000000000000000..4853880e6d321744bc5eb187171ecb5c1b49aa6e --- /dev/null +++ b/Utilities/ITK/CMake/itkTestCStyleIOWCharFilename.cxx @@ -0,0 +1,33 @@ +/*========================================================================= + + Program: Insight Segmentation & Registration Toolkit + Module: $RCSfile: itkTestCStyleIOWCharFilename.cxx,v $ + Language: C++ + Date: $Date: 2009-11-24 15:15:59 $ + Version: $Revision: 1.1 $ + + Copyright (c) Insight Software Consortium. All rights reserved. + See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +/* + This file tests whether we have _wopen and the like +*/ + +#include <io.h> // for _wopen +#include <fcntl.h> // for _O_RDONLY +#include <stdio.h> // for _wfopen + +int main() +{ + _wopen( L"tmptest.txt", _O_RDONLY ); + _wfopen( L"tmptest.txt", L"r" ); + _wunlink( L"tmptest.txt" ); + return 0; +} + diff --git a/Utilities/ITK/CMake/itkTestCompareTypes.cxx b/Utilities/ITK/CMake/itkTestCompareTypes.cxx index c6aa9c99d0228bd11524348f51a53c1d41986430..f1eb1140336b13aac89f48cb83e6041fa8b1df18 100644 --- a/Utilities/ITK/CMake/itkTestCompareTypes.cxx +++ b/Utilities/ITK/CMake/itkTestCompareTypes.cxx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkTestCompareTypes.cxx,v $ Language: C++ - Date: $Date: 2005-01-22 21:02:11 $ - Version: $Revision: 1.1 $ + Date: $Date: 2009-11-17 12:32:42 $ + Version: $Revision: 1.2 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -14,6 +14,21 @@ PURPOSE. See the above copyright notices for more information. =========================================================================*/ + +#ifdef HAVE_SYS_TYPES_H +# include <sys/types.h> +#endif /* HAVE_SYS_TYPES_H */ + +#ifdef HAVE_STDINT_H +# include <stdint.h> +#endif /* HAVE_STDINT_H */ + +#ifdef HAVE_STDDEF_H +# include <stddef.h> +#endif /* HAVE_STDDEF_H */ + +#define TYPE_LONG_LONG long long + typedef ITK_TEST_COMPARE_TYPE_1 Type1; typedef ITK_TEST_COMPARE_TYPE_2 Type2; diff --git a/Utilities/ITK/CMake/itkTestConvertTypes.cxx b/Utilities/ITK/CMake/itkTestConvertTypes.cxx new file mode 100644 index 0000000000000000000000000000000000000000..fea3d8d2c56209af65cdab0cc82f575381fbdd6c --- /dev/null +++ b/Utilities/ITK/CMake/itkTestConvertTypes.cxx @@ -0,0 +1,49 @@ +/*========================================================================= + + Program: Insight Segmentation & Registration Toolkit + Module: $RCSfile: itkTestConvertTypes.cxx,v $ + Language: C++ + Date: $Date: 2009-11-17 12:32:42 $ + Version: $Revision: 1.1 $ + + Copyright (c) Insight Software Consortium. All rights reserved. + See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +/*========================================================================= + + Program: Visualization Toolkit + Module: $RCSfile: itkTestConvertTypes.cxx,v $ + + Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen + All rights reserved. + See Copyright.txt or http://www.kitware.com/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notice for more information. + +=========================================================================*/ + +#define TYPE_UNSIGNED___INT64 unsigned __int64 + +typedef ITK_TEST_CONVERT_TYPE_TO TypeTo; +typedef ITK_TEST_CONVERT_TYPE_FROM TypeFrom; + +void function(TypeTo& l, TypeFrom const& r) +{ + l = static_cast<TypeTo>(r); +} + +int main() +{ + TypeTo tTo = TypeTo(); + TypeFrom tFrom = TypeFrom(); + function(tTo, tFrom); + return 0; +} diff --git a/Utilities/ITK/CMake/itkTestFDStream.cxx b/Utilities/ITK/CMake/itkTestFDStream.cxx new file mode 100644 index 0000000000000000000000000000000000000000..df1470027372f34e0c755b5a21b116e3b5e189b8 --- /dev/null +++ b/Utilities/ITK/CMake/itkTestFDStream.cxx @@ -0,0 +1,34 @@ +/*========================================================================= + + Program: Insight Segmentation & Registration Toolkit + Module: $RCSfile: itkTestFDStream.cxx,v $ + Language: C++ + Date: $Date: 2009-11-24 15:16:01 $ + Version: $Revision: 1.1 $ + + Copyright (c) Insight Software Consortium. All rights reserved. + See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +/* + This file tests whether fdstream compiles +*/ + +#include "fdstream.hpp" + +int main() +{ + // stream with buffer reading from file descriptor 0 (standard input) + boost::fdistream in(0); + + // stream with buffer writing to file descriptor 1 (standard output) + boost::fdostream out(1); + + return 0; +} + diff --git a/Utilities/ITK/CMake/itkTestFriendTemplatedFunction.cxx b/Utilities/ITK/CMake/itkTestFriendTemplatedFunction.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/CMake/itkTestIOStreamsWCharFilenameConstructors.cxx b/Utilities/ITK/CMake/itkTestIOStreamsWCharFilenameConstructors.cxx new file mode 100644 index 0000000000000000000000000000000000000000..2503af7528e59edf73affbd6269c8bb8b52cee08 --- /dev/null +++ b/Utilities/ITK/CMake/itkTestIOStreamsWCharFilenameConstructors.cxx @@ -0,0 +1,30 @@ +/*========================================================================= + + Program: Insight Segmentation & Registration Toolkit + Module: $RCSfile: itkTestIOStreamsWCharFilenameConstructors.cxx,v $ + Language: C++ + Date: $Date: 2009-11-24 15:16:01 $ + Version: $Revision: 1.1 $ + + Copyright (c) Insight Software Consortium. All rights reserved. + See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +/* + This file tests whether fstream's have a wchar_t * constructor +*/ + +#include <fstream> + +int main() +{ + std::ofstream ostr( L"tmptest.txt" ); + std::ifstream istr( L"tmptest.txt" ); + return 0; +} + diff --git a/Utilities/ITK/CMake/itkTestTemplatePartialSpecialization.cxx b/Utilities/ITK/CMake/itkTestTemplatePartialSpecialization.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/CMake/itkTestTypes.cmake b/Utilities/ITK/CMake/itkTestTypes.cmake new file mode 100644 index 0000000000000000000000000000000000000000..a4616a193fcedd8bc9a0094215cf926c93249a6b --- /dev/null +++ b/Utilities/ITK/CMake/itkTestTypes.cmake @@ -0,0 +1,137 @@ +# based on VTK/CMake/vtkTestTypes.cmake 11/13/09 -BCL + +CHECK_TYPE_SIZE("long long" ITK_SIZEOF_LONG_LONG) +CHECK_TYPE_SIZE("__int64" ITK_SIZEOF___INT64) + +# The only compiler that satisfies the criteria for __int64 specified +# in this file is Borland, however from some reason the NumericTraits +# are not funcitoning therefore we had no systems which correctly +# support __int64 as a fundemental type. +# +# Disable trying to even use __int64 +SET( ITK_TRY_TO_USE__INT64 0 ) + +IF( ITK_TRY_TO_USE__INT64 ) + IF(HAVE_ITK_SIZEOF___INT64) + # In CMake 2.6 and above the type __int64 may have been found only + # due to inclusion of a system header. Further try-compiles using + # the type should include the header too. + SET(_HAVE_DEFS) + FOREACH(def HAVE_SYS_TYPES_H HAVE_STDINT_H HAVE_STDDEF_H) + IF(${def}) + LIST(APPEND _HAVE_DEFS -D${def}) + ENDIF(${def}) + ENDFOREACH(def) + + IF("ITK_TYPE_SAME_LONG_AND___INT64" MATCHES "^ITK_TYPE_SAME_LONG_AND___INT64$") + MESSAGE(STATUS "Checking whether long and __int64 are the same type") + TRY_COMPILE(ITK_TYPE_SAME_LONG_AND___INT64 + ${ITK_BINARY_DIR}/CMakeTmp + ${ITK_SOURCE_DIR}/CMake/itkTestCompareTypes.cxx + COMPILE_DEFINITIONS + -DITK_TEST_COMPARE_TYPE_1=long + -DITK_TEST_COMPARE_TYPE_2=__int64 + ${_HAVE_DEFS} + OUTPUT_VARIABLE OUTPUT) + IF(ITK_TYPE_SAME_LONG_AND___INT64) + MESSAGE(STATUS "Checking whether long and __int64 are the same type -- yes") + SET(ITK_TYPE_SAME_LONG_AND___INT64 1 CACHE INTERNAL "Whether long and __int64 are the same type") + WRITE_FILE(${CMAKE_BINARY_DIR}/CMakeFiles/CMakeOutput.log + "Determining whether long and __int64 are the same type " + "passed with the following output:\n" + "${OUTPUT}\n" APPEND) + ELSE(ITK_TYPE_SAME_LONG_AND___INT64) + MESSAGE(STATUS "Checking whether long and __int64 are the same type -- no") + SET(ITK_TYPE_SAME_LONG_AND___INT64 0 CACHE INTERNAL "Whether long and __int64 are the same type") + WRITE_FILE(${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log + "Determining whether long and __int64 are the same type " + "failed with the following output:\n" + "${OUTPUT}\n" APPEND) + ENDIF(ITK_TYPE_SAME_LONG_AND___INT64) + ENDIF("ITK_TYPE_SAME_LONG_AND___INT64" MATCHES "^ITK_TYPE_SAME_LONG_AND___INT64$") + + IF(HAVE_ITK_SIZEOF_LONG_LONG) + IF("ITK_TYPE_SAME_LONG_LONG_AND___INT64" MATCHES "^ITK_TYPE_SAME_LONG_LONG_AND___INT64$") + MESSAGE(STATUS "Checking whether long long and __int64 are the same type") + TRY_COMPILE(ITK_TYPE_SAME_LONG_LONG_AND___INT64 + ${ITK_BINARY_DIR}/CMakeTmp + ${ITK_SOURCE_DIR}/CMake/itkTestCompareTypes.cxx + COMPILE_DEFINITIONS + -DITK_TEST_COMPARE_TYPE_1=TYPE_LONG_LONG + -DITK_TEST_COMPARE_TYPE_2=__int64 + ${_HAVE_DEFS} + OUTPUT_VARIABLE OUTPUT) + IF(ITK_TYPE_SAME_LONG_LONG_AND___INT64) + MESSAGE(STATUS "Checking whether long long and __int64 are the same type -- yes") + SET(ITK_TYPE_SAME_LONG_LONG_AND___INT64 1 CACHE INTERNAL "Whether long long and __int64 are the same type") + WRITE_FILE(${CMAKE_BINARY_DIR}/CMakeFiles/CMakeOutput.log + "Determining whether long long and __int64 are the same type " + "passed with the following output:\n" + "${OUTPUT}\n" APPEND) + ELSE(ITK_TYPE_SAME_LONG_LONG_AND___INT64) + MESSAGE(STATUS "Checking whether long long and __int64 are the same type -- no") + SET(ITK_TYPE_SAME_LONG_LONG_AND___INT64 0 CACHE INTERNAL "Whether long long and __int64 are the same type") + WRITE_FILE(${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log + "Determining whether long long and __int64 are the same type " + "failed with the following output:\n" + "${OUTPUT}\n" APPEND) + ENDIF(ITK_TYPE_SAME_LONG_LONG_AND___INT64) + ENDIF("ITK_TYPE_SAME_LONG_LONG_AND___INT64" MATCHES "^ITK_TYPE_SAME_LONG_LONG_AND___INT64$") + ENDIF(HAVE_ITK_SIZEOF_LONG_LONG) + IF(NOT ITK_TYPE_SAME_LONG_AND___INT64) + IF(NOT ITK_TYPE_SAME_LONG_LONG_AND___INT64) + # VS 6 cannot convert unsigned __int64 to double unless the + # "Visual C++ Processor Pack" is installed. + IF("ITK_TYPE_CONVERT_UI64_TO_DOUBLE" MATCHES "^ITK_TYPE_CONVERT_UI64_TO_DOUBLE$") + MESSAGE(STATUS "Checking whether unsigned __int64 can convert to double") + TRY_COMPILE(ITK_TYPE_CONVERT_UI64_TO_DOUBLE + ${ITK_BINARY_DIR}/CMakeTmp + ${ITK_SOURCE_DIR}/CMake/itkTestConvertTypes.cxx + COMPILE_DEFINITIONS + -DITK_TEST_CONVERT_TYPE_FROM=TYPE_UNSIGNED___INT64 + -DITK_TEST_CONVERT_TYPE_TO=double + ${_HAVE_DEFS} + OUTPUT_VARIABLE OUTPUT) + IF(ITK_TYPE_CONVERT_UI64_TO_DOUBLE) + MESSAGE(STATUS "Checking whether unsigned __int64 can convert to double -- yes") + SET(ITK_TYPE_CONVERT_UI64_TO_DOUBLE 1 CACHE INTERNAL "Whether unsigned __int64 can convert to double") + WRITE_FILE(${CMAKE_BINARY_DIR}/CMakeFiles/CMakeOutput.log + "Determining whether unsigned __int64 can convert to double " + "passed with the following output:\n" + "${OUTPUT}\n" APPEND) + ELSE(ITK_TYPE_CONVERT_UI64_TO_DOUBLE) + MESSAGE(STATUS "Checking whether unsigned __int64 can convert to double -- no") + SET(ITK_TYPE_CONVERT_UI64_TO_DOUBLE 0 CACHE INTERNAL "Whether unsigned __int64 can convert to double") + WRITE_FILE(${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log + "Determining whether unsigned __int64 can convert to double " + "failed with the following output:\n" + "${OUTPUT}\n" APPEND) + ENDIF(ITK_TYPE_CONVERT_UI64_TO_DOUBLE) + ENDIF("ITK_TYPE_CONVERT_UI64_TO_DOUBLE" MATCHES "^ITK_TYPE_CONVERT_UI64_TO_DOUBLE$") + ENDIF(NOT ITK_TYPE_SAME_LONG_LONG_AND___INT64) + ENDIF(NOT ITK_TYPE_SAME_LONG_AND___INT64) + ENDIF(HAVE_ITK_SIZEOF___INT64) +ENDIF ( ITK_TRY_TO_USE__INT64 ) + +# Enable the "long long" type if it is available. It is standard in +# C99 and C++03 but not in earlier standards. +SET(ITK_TYPE_USE_LONG_LONG) +IF(HAVE_ITK_SIZEOF_LONG_LONG) + SET(ITK_TYPE_USE_LONG_LONG 1) +ENDIF(HAVE_ITK_SIZEOF_LONG_LONG) + +# Enable the "__int64" type if it is available and is a fundemental type. It is not +# standard. It also must be convertable to double. +SET(ITK_TYPE_USE___INT64) + +IF ( ITK_TRY_TO_USE__INT64 ) +IF(HAVE_ITK_SIZEOF___INT64) + IF(NOT ITK_TYPE_SAME_LONG_AND___INT64) + IF(NOT ITK_TYPE_SAME_LONG_LONG_AND___INT64) + IF(ITK_TYPE_CONVERT_UI64_TO_DOUBLE) + SET(ITK_TYPE_USE___INT64 1) + ENDIF(ITK_TYPE_CONVERT_UI64_TO_DOUBLE) + ENDIF(NOT ITK_TYPE_SAME_LONG_LONG_AND___INT64) + ENDIF(NOT ITK_TYPE_SAME_LONG_AND___INT64) +ENDIF(HAVE_ITK_SIZEOF___INT64) +ENDIF( ITK_TRY_TO_USE__INT64 ) diff --git a/Utilities/ITK/CMakeLists.txt b/Utilities/ITK/CMakeLists.txt index c4144e2c78ec552dc07cff58eab0f793a21833d7..109a10334a883d84e990c960e652c12a8543c62a 100644 --- a/Utilities/ITK/CMakeLists.txt +++ b/Utilities/ITK/CMakeLists.txt @@ -47,7 +47,7 @@ ENDIF("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" MATCHES "^2\\.4$") #----------------------------------------------------------------------------- # ITK version number. An even minor number corresponds to releases. SET(ITK_VERSION_MAJOR "3") -SET(ITK_VERSION_MINOR "16") +SET(ITK_VERSION_MINOR "18") SET(ITK_VERSION_PATCH "0") # Version string should not include patch level. The major.minor is @@ -110,7 +110,13 @@ OPTION(USE_FFTWD "Use double precision FFTW if found" OFF) MARK_AS_ADVANCED(USE_FFTWF) OPTION(USE_FFTWF "Use single precision FFTW if found" OFF) IF( USE_FFTWD OR USE_FFTWF ) - FIND_PACKAGE( FFTW ) + SET(msg "ATTENTION: You have enabled the use of FFTW,") + SET(msg "${msg} this library is distributed under a GPL license.") + SET(msg "${msg} By enabling this option, the binary of the ITK libraries") + SET(msg "${msg} that you are going to build will be covered by a GPL license,") + SET(msg "${msg} and so it will be any executable that you link against these libraries.") + MESSAGE("${msg}") + FIND_PACKAGE( FFTW ) ENDIF( USE_FFTWD OR USE_FFTWF ) # Deal with SGI SCSL Options @@ -130,6 +136,7 @@ IF( ITK_USE_MINC2 ) ENDIF( NOT MINC2_FOUND ) ENDIF( ITK_USE_MINC2 ) + #----------------------------------------------------------------------------- # ITK build configuration options. OPTION(BUILD_SHARED_LIBS "Build ITK with shared libraries." OFF) @@ -138,7 +145,7 @@ SET(ITK_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS}) IF(NOT ITK_NO_LIBRARY_VERSION) # This setting of SOVERSION assumes that any API change # will increment either the minor or major version number of ITK. - SET(ITK_LIBRARY_PROPERTIES + SET(ITK_LIBRARY_PROPERTIES VERSION "${ITK_VERSION_MAJOR}.${ITK_VERSION_MINOR}.${ITK_VERSION_PATCH}" SOVERSION "${ITK_VERSION_MAJOR}.${ITK_VERSION_MINOR}" ) @@ -274,6 +281,10 @@ MARK_AS_ADVANCED(ITK_USE_TEMPLATE_META_PROGRAMMING_LOOP_UNROLLING) OPTION(ITK_USE_DEPRECATED_LEVELSET_INTERPOLATION "Turn on the use of a sparse field level set surface interpolation method that has been deprecated since ITK 3.6. Turn this flag ON to exactly replicate the behavior of ITK<=3.4." OFF) MARK_AS_ADVANCED(ITK_USE_DEPRECATED_LEVELSET_INTERPOLATION) +OPTION(ITK_USE_DEPRECATED_FAST_MARCHING "Turn on incorrect handling of TrialPoints in itk::FastMarchingImageFilter result of a bug fixed in ITK 3.18. Turn this flag ON to exactly replicate the behavior of ITK<=3.16." OFF) +MARK_AS_ADVANCED(ITK_USE_DEPRECATED_FAST_MARCHING) + + #----------------------------------------------------------------------------- # Installation vars. # ITK_INSTALL_BIN_DIR - binary dir (executables) @@ -285,6 +296,9 @@ MARK_AS_ADVANCED(ITK_USE_DEPRECATED_LEVELSET_INTERPOLATION) # ITK_INSTALL_NO_RUNTIME - do not install runtime files # ITK_INSTALL_NO_DOCUMENTATION - do not install documentation files +OPTION(ITK_USE_FLAT_DIRECTORY_INSTALL "When ON, ITK will install all the header files in a single directory. This reduces the number of directories that must be searched for headers in projects based on ITK" OFF) +MARK_AS_ADVANCED(ITK_USE_FLAT_DIRECTORY_INSTALL) + IF(NOT ITK_INSTALL_BIN_DIR) # Solaris: unlike libraries, 64 bit executables should be installed in "bin${sun64}" only # if the 32 version is installed in "bin/sparcv7" or "bin/i86", and a isaexec @@ -317,10 +331,9 @@ IF(NOT ITK_INSTALL_LIB_DIR) MESSAGE("Warning: Unknown processor '${sunproc}'. The libraries may not be installed in the right place.") ENDIF("${sun64}" STREQUAL "") ENDIF(CMAKE_SYSTEM MATCHES "SunOS.*" AND CMAKE_SIZEOF_VOID_P EQUAL 8) - # OTB Modifications -# SET(ITK_INSTALL_LIB_DIR "/lib/InsightToolkit${sun64}") - SET(ITK_INSTALL_LIB_DIR "/lib/otb${sun64}") +# SET(ITK_INSTALL_LIB_DIR "/lib/InsightToolkit${sun64}") + SET(ITK_INSTALL_LIB_DIR "/lib/otb${sun64}") ENDIF(NOT ITK_INSTALL_LIB_DIR) IF(NOT ITK_INSTALL_DATA_DIR) @@ -398,16 +411,16 @@ SET(ITK_DIR "${CMAKE_BINARY_DIR}" CACHE INTERNAL "ITK dir to be used by subproje # be particulary useful to distributed prebuilt ITK witk extended languages # support enable # -# INCLUDE(InstallRequiredSystemLibraries) -# SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Insight Toolkit") -# SET(CPACK_PACKAGE_VENDOR "ISC") -# SET(CPACK_PACKAGE_VERSION_MAJOR "${ITK_VERSION_MAJOR}") -# SET(CPACK_PACKAGE_VERSION_MINOR "${ITK_VERSION_MINOR}") -# SET(CPACK_PACKAGE_VERSION_PATCH "${ITK_VERSION_PATCH}") -# SET(CPACK_PACKAGE_INSTALL_DIRECTORY "InsightToolkit-${ITK_VERSION_MAJOR}.${ITK_VERSION_MINOR}") -# # SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README") -# SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/Copyright/ITKCopyright.txt") -# INCLUDE(CPack) +#INCLUDE(InstallRequiredSystemLibraries) +#SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Insight Toolkit") +#SET(CPACK_PACKAGE_VENDOR "ISC") +#SET(CPACK_PACKAGE_VERSION_MAJOR "${ITK_VERSION_MAJOR}") +#SET(CPACK_PACKAGE_VERSION_MINOR "${ITK_VERSION_MINOR}") +#SET(CPACK_PACKAGE_VERSION_PATCH "${ITK_VERSION_PATCH}") +#SET(CPACK_PACKAGE_INSTALL_DIRECTORY "InsightToolkit-${ITK_VERSION_MAJOR}.${ITK_VERSION_MINOR}") +# SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README") +#SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/Copyright/ITKCopyright.txt") +#INCLUDE(CPack) #----------------------------------------------------------------------------- @@ -477,7 +490,7 @@ ITK_THIRD_PARTY_OPTION(LIBXML2 libxml2) #----------------------------------------------------------------------------- # If choose to build documentation, then search for Doxygen executables. -# OTB Modifications +# OTB Modifications #OPTION(BUILD_DOXYGEN "Build Doxygen Documentation" OFF) #IF(BUILD_DOXYGEN) # FIND_PACKAGE(Doxygen) @@ -489,12 +502,10 @@ SUBDIRS(Utilities Code) SUBDIRS(Wrapping) -# OTB Modifications #IF (BUILD_TESTING) # SUBDIRS(Testing) #ENDIF (BUILD_TESTING) -# OTB Modifications #IF(BUILD_EXAMPLES) # SUBDIRS(Examples) #ENDIF(BUILD_EXAMPLES) @@ -506,30 +517,30 @@ IF(CMAKE_COMPILER_IS_GNUCXX) SET(ITK_REQUIRED_CXX_FLAGS "${ITK_REQUIRED_CXX_FLAGS} -ftemplate-depth-50 -Wall") INCLUDE(${ITK_SOURCE_DIR}/CMake/itkCheckCXXAcceptsFlags.cmake) itkCHECK_CXX_ACCEPTS_FLAGS("-Wno-deprecated" CXX_HAS_DEPRECATED_FLAG) - IF(CXX_HAS_DEPRECATED_FLAG) + IF(CXX_HAS_DEPRECATED_FLAG) SET(ITK_REQUIRED_CXX_FLAGS "${ITK_REQUIRED_CXX_FLAGS} -Wno-deprecated") - ENDIF(CXX_HAS_DEPRECATED_FLAG) + ENDIF(CXX_HAS_DEPRECATED_FLAG) IF(APPLE) # -no-cpp-precomp and -Wno-long-double were compiler flags present # only in Apple's gcc and not in the FSF gcc. The flags are obsolete # and totally removed in gcc 4.2 and later. I believe they are only # needed with gcc 3.3 and earlier. itkCHECK_CXX_ACCEPTS_FLAGS("-no-cpp-precomp" CXX_HAS_CPP_PRECOMP_FLAG) - IF(CXX_HAS_CPP_PRECOMP_FLAG) + IF(CXX_HAS_CPP_PRECOMP_FLAG) SET(ITK_REQUIRED_C_FLAGS "${ITK_REQUIRED_C_FLAGS} -no-cpp-precomp") SET(ITK_REQUIRED_CXX_FLAGS "${ITK_REQUIRED_CXX_FLAGS} -no-cpp-precomp") - ENDIF(CXX_HAS_CPP_PRECOMP_FLAG) + ENDIF(CXX_HAS_CPP_PRECOMP_FLAG) itkCHECK_CXX_ACCEPTS_FLAGS("-Wno-long-double" CXX_HAS_LONGDOUBLE_FLAG) - IF(CXX_HAS_LONGDOUBLE_FLAG) + IF(CXX_HAS_LONGDOUBLE_FLAG) SET(ITK_REQUIRED_C_FLAGS "${ITK_REQUIRED_C_FLAGS} -Wno-long-double") SET(ITK_REQUIRED_CXX_FLAGS "${ITK_REQUIRED_CXX_FLAGS} -Wno-long-double") - ENDIF(CXX_HAS_LONGDOUBLE_FLAG) + ENDIF(CXX_HAS_LONGDOUBLE_FLAG) OPTION(ITK_USE_64BITS_APPLE_TRUNCATION_WARNING "Turn on warnings on 64bits to 32bits truncations." OFF) MARK_AS_ADVANCED(ITK_USE_64BITS_APPLE_TRUNCATION_WARNING) ENDIF(APPLE) - + # gcc must have -msse2 option to enable sse2 support IF(VNL_CONFIG_ENABLE_SSE2 OR VNL_CONFIG_ENABLE_SSE2_ROUNDING) SET(ITK_REQUIRED_CXX_FLAGS "${ITK_REQUIRED_CXX_FLAGS} -msse2") @@ -635,7 +646,7 @@ IF(MINGW) ENDIF(MINGW) #----------------------------------------------------------------------------- -# Find platform-specific differences in the handling of IEEE floating point +# Find platform-specific differences in the handling of IEEE floating point # special values. INCLUDE(${ITK_SOURCE_DIR}/CMake/CheckBigBitfield.cmake) CHECK_BIG_BITFIELD(BIGBITFIELD_VALUE ${ITK_SOURCE_DIR}/CMake) @@ -655,75 +666,21 @@ ENDIF(QNANHIBIT_VALUE) INCLUDE(CheckTypeSize) -CHECK_TYPE_SIZE("long long" ITK_SIZEOF_LONG_LONG) -CHECK_TYPE_SIZE("__int64" ITK_SIZEOF___INT64) -IF(ITK_SIZEOF___INT64) - IF("ITK_TYPE_SAME_LONG_AND___INT64" MATCHES "^ITK_TYPE_SAME_LONG_AND___INT64$") - MESSAGE(STATUS "Checking whether long and __int64 are the same type") - TRY_COMPILE(ITK_TYPE_SAME_LONG_AND___INT64 - ${ITK_BINARY_DIR}/CMakeTmp - ${ITK_SOURCE_DIR}/CMake/itkTestCompareTypes.cxx - COMPILE_DEFINITIONS - -DITK_TEST_COMPARE_TYPE_1=long - -DITK_TEST_COMPARE_TYPE_2=__int64 - OUTPUT_VARIABLE OUTPUT) - IF(ITK_TYPE_SAME_LONG_AND___INT64) - MESSAGE(STATUS "Checking whether long and __int64 are the same type -- yes") - SET(ITK_TYPE_SAME_LONG_AND___INT64 1 CACHE INTERNAL "Whether long and __int64 are the same type") - ELSE(ITK_TYPE_SAME_LONG_AND___INT64) - MESSAGE(STATUS "Checking whether long and __int64 are the same type -- no") - SET(ITK_TYPE_SAME_LONG_AND___INT64 0 CACHE INTERNAL "Whether long and __int64 are the same type") - WRITE_FILE(${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Determining whether long and __int64 are the same type " - "failed with the following output:\n" - "${OUTPUT}\n" APPEND) - ENDIF(ITK_TYPE_SAME_LONG_AND___INT64) - ENDIF("ITK_TYPE_SAME_LONG_AND___INT64" MATCHES "^ITK_TYPE_SAME_LONG_AND___INT64$") -ENDIF(ITK_SIZEOF___INT64) - -IF(ITK_SIZEOF_LONG_LONG) - CONFIGURE_FILE(${ITK_SOURCE_DIR}/CMake/itkTestStreamLongLong.cxx.in - ${ITK_BINARY_DIR}/CMake/itkTestStreamLongLong.cxx @ONLY IMMEDIATE) - IF("ITK_OSTREAM_SUPPORTS_LONG_LONG" MATCHES "^ITK_OSTREAM_SUPPORTS_LONG_LONG$") - MESSAGE(STATUS "Checking if ostream supports long long") - TRY_COMPILE(ITK_OSTREAM_SUPPORTS_LONG_LONG - ${ITK_BINARY_DIR} - ${ITK_BINARY_DIR}/CMake/itkTestStreamLongLong.cxx - COMPILE_DEFINITIONS -DITK_TEST_OSTREAM_LONG_LONG - OUTPUT_VARIABLE OUTPUT) - IF(ITK_OSTREAM_SUPPORTS_LONG_LONG) - MESSAGE(STATUS "Checking if ostream supports long long -- yes") - SET(ITK_OSTREAM_SUPPORTS_LONG_LONG 1 CACHE INTERNAL "Whether ostream supports long long") - ELSE(ITK_OSTREAM_SUPPORTS_LONG_LONG) - MESSAGE(STATUS "Checking if ostream supports long long -- no") - SET(ITK_OSTREAM_SUPPORTS_LONG_LONG 0 CACHE INTERNAL "Whether ostream supports long long") - WRITE_FILE(${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Determining if ostream supports long long " - "failed with the following output:\n" - "${OUTPUT}\n" APPEND) - ENDIF(ITK_OSTREAM_SUPPORTS_LONG_LONG) - ENDIF("ITK_OSTREAM_SUPPORTS_LONG_LONG" MATCHES "^ITK_OSTREAM_SUPPORTS_LONG_LONG$") - IF("ITK_ISTREAM_SUPPORTS_LONG_LONG" MATCHES "^ITK_ISTREAM_SUPPORTS_LONG_LONG$") - MESSAGE(STATUS "Checking if istream supports long long") - TRY_COMPILE(ITK_ISTREAM_SUPPORTS_LONG_LONG - ${ITK_BINARY_DIR} - ${ITK_BINARY_DIR}/CMake/itkTestStreamLongLong.cxx - COMPILE_DEFINITIONS -DITK_TEST_ISTREAM_LONG_LONG - OUTPUT_VARIABLE OUTPUT) - IF(ITK_ISTREAM_SUPPORTS_LONG_LONG) - MESSAGE(STATUS "Checking if istream supports long long -- yes") - SET(ITK_ISTREAM_SUPPORTS_LONG_LONG 1 CACHE INTERNAL "Whether istream supports long long") - ELSE(ITK_ISTREAM_SUPPORTS_LONG_LONG) - MESSAGE(STATUS "Checking if istream supports long long -- no") - SET(ITK_ISTREAM_SUPPORTS_LONG_LONG 0 CACHE INTERNAL "Whether istream supports long long") - WRITE_FILE(${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Determining if istream supports long long " - "failed with the following output:\n" - "${OUTPUT}\n" APPEND) - ENDIF(ITK_ISTREAM_SUPPORTS_LONG_LONG) - ENDIF("ITK_ISTREAM_SUPPORTS_LONG_LONG" MATCHES "^ITK_ISTREAM_SUPPORTS_LONG_LONG$") -ENDIF(ITK_SIZEOF_LONG_LONG) +#----------------------------------------------------------------------------- +# +# Check types such as long long and __int64 +INCLUDE(${ITK_SOURCE_DIR}/CMake/itkTestTypes.cmake) + + +#----------------------------------------------------------------------------- +# check if the platform has the header file "fenv.h" which has been added as part of the C99 standard +INCLUDE(CheckIncludeFiles) +CHECK_INCLUDE_FILES(fenv.h HAVE_FENV_H) + +#----------------------------------------------------------------------------- +# check if the platform has some widely used header files +CHECK_INCLUDE_FILES("unistd.h" HAVE_UNISTD_H) # # See if compiler preprocessor has the __FUNCTION__ directive used by itkExceptionMacro @@ -745,6 +702,39 @@ TRY_COMPILE(ITK_SUPPORTS_TEMPLATE_PARTIAL_SPECIALIZATION # INCLUDE(${ITK_SOURCE_DIR}/CMake/itkTestFriendTemplatedFunction.cmake) + +#----------------------------------------------------------------------------- +# check if the platform has c style IO functions that uses wchar_t * filenames +# For some reason I can't manage to get a usable result from CHECK_FUNCTION_EXISTS +TRY_COMPILE(ITK_SUPPORTS_WCHAR_T_FILENAME_CSTYLEIO + ${ITK_BINARY_DIR}/CMakeTmp + ${ITK_SOURCE_DIR}/CMake/itkTestCStyleIOWCharFilename.cxx + OUTPUT_VARIABLE ITK_SUPPORTS_WCHAR_T_FILENAME_CSTYLEIO_OUTPUT) + +#----------------------------------------------------------------------------- +# check if the platform has IO streams constructors that uses wchar_t * filenames +TRY_COMPILE(ITK_SUPPORTS_WCHAR_T_FILENAME_IOSTREAMS_CONSTRUCTORS + ${ITK_BINARY_DIR}/CMakeTmp + ${ITK_SOURCE_DIR}/CMake/itkTestIOStreamsWCharFilenameConstructors.cxx + OUTPUT_VARIABLE ITK_SUPPORTS_WCHAR_T_FILENAME_IOSTREAMS_CONSTRUCTORS_OUTPUT) + +#----------------------------------------------------------------------------- +# check if the platform can compile fdstream.hpp +IF(HAVE_UNISTD_H) + TRY_COMPILE(ITK_SUPPORTS_FDSTREAM_HPP + ${ITK_BINARY_DIR}/CMakeTmp + ${ITK_SOURCE_DIR}/CMake/itkTestFDStream.cxx + CMAKE_FLAGS -DINCLUDE_DIRECTORIES:STRING=${ITK_SOURCE_DIR}/Utilities/itkExtHdrs + COMPILE_DEFINITIONS -DITK_HAVE_UNISTD_H=${HAVE_UNISTD_H} + OUTPUT_VARIABLE ITK_SUPPORTS_FDSTREAM_HPP_OUTPUT) +ELSE(HAVE_UNISTD_H) + TRY_COMPILE(ITK_SUPPORTS_FDSTREAM_HPP + ${ITK_BINARY_DIR}/CMakeTmp + ${ITK_SOURCE_DIR}/CMake/itkTestFDStream.cxx + CMAKE_FLAGS -DINCLUDE_DIRECTORIES:STRING=${ITK_SOURCE_DIR}/Utilities/itkExtHdrs + OUTPUT_VARIABLE ITK_SUPPORTS_FDSTREAM_HPP_OUTPUT) +ENDIF(HAVE_UNISTD_H) + #----------------------------------------------------------------------------- # Configure the default ITK_DATA_ROOT for the location of ITK Data. FIND_PATH(ITK_DATA_ROOT ITKData.readme ${ITK_SOURCE_DIR}/Testing/Data $ENV{ITK_DATA_ROOT}) @@ -753,7 +743,7 @@ MARK_AS_ADVANCED(ITK_DATA_ROOT) #----------------------------------------------------------------------------- # Configure the default ITK_BRAINWEB_DATA_ROOT for the location of ITK Data. # When this data is available, additional 3D tests are enabled. -FIND_PATH(ITK_BRAINWEB_DATA_ROOT brainweb165a10f17.mha +FIND_PATH(ITK_BRAINWEB_DATA_ROOT brainweb165a10f17.mha DOC "Directory with data taken from http://public.kitware.com/pub/itk/Data/BrainWeb/") MARK_AS_ADVANCED(ITK_BRAINWEB_DATA_ROOT) @@ -784,12 +774,12 @@ MARK_AS_ADVANCED(ITK_VISIBLEHUMAN_DATA_ROOT) #----------------------------------------------------------------------------- # This flag is used in particular, to enable some tests that require large memory to run. # This probably can be discovered at configuration time by CMake. (Check with CMake developers). -SET(ITK_COMPUTER_MEMORY_SIZE 1 CACHE STRING "Provide here the size of your RAM Memory in GigaBytes") +SET(ITK_COMPUTER_MEMORY_SIZE 1 CACHE STRING "Provide here the size of your RAM Memory in GigaBytes") MARK_AS_ADVANCED(ITK_COMPUTER_MEMORY_SIZE) #----------------------------------------------------------------------------- # Configure files with settings for use by the build. -CONFIGURE_FILE(${ITK_SOURCE_DIR}/itkConfigure.h.in +CONFIGURE_FILE(${ITK_SOURCE_DIR}/itkConfigure.h.in ${ITK_BINARY_DIR}/itkConfigure.h) IF(NOT ITK_INSTALL_NO_DEVELOPMENT) INSTALL(FILES ${ITK_BINARY_DIR}/itkConfigure.h @@ -815,7 +805,7 @@ INCLUDE_DIRECTORIES( #----------------------------------------------------------------------------- # ITK_USE_SYSTEM_GDCM is provided so that you can use an installed or external -# version of gdcm. If its on, you must specify the variables +# version of gdcm. If its on, you must specify the variables # Important: INCLUDE(${GDCM_USE_FILE}) *has* to be set after the # INCLUDE_DIRECTORIES that sets all the include paths for ITK, otherwise # if GDCM was build with VTK support, including it will bring the VTK diff --git a/Utilities/ITK/CTestConfig.cmake b/Utilities/ITK/CTestConfig.cmake index 643e14e327a7e18861b4a49e50f75614481a77df..16f120e7b87531c04d0a424b0d103a5a8f88d2ae 100644 --- a/Utilities/ITK/CTestConfig.cmake +++ b/Utilities/ITK/CTestConfig.cmake @@ -1,5 +1,5 @@ set(CTEST_PROJECT_NAME "ITK") -set(CTEST_NIGHTLY_START_TIME "21:00:00 EDT") +set(CTEST_NIGHTLY_START_TIME "1:00:00 UTC") set(CTEST_DROP_METHOD "http") set(CTEST_DROP_SITE "www.cdash.org") diff --git a/Utilities/ITK/Code/Algorithms/CMakeLists.txt b/Utilities/ITK/Code/Algorithms/CMakeLists.txt index 67bc835607b5d1a54bc81edaa3d4ef5c9099de4c..bb9fadf186a8ba7578d3c183b39516c89b8c39a6 100644 --- a/Utilities/ITK/Code/Algorithms/CMakeLists.txt +++ b/Utilities/ITK/Code/Algorithms/CMakeLists.txt @@ -35,10 +35,16 @@ IF(NOT ITK_INSTALL_NO_LIBRARIES) ARCHIVE DESTINATION ${ITK_INSTALL_LIB_DIR_CM24} COMPONENT Development) ENDIF(NOT ITK_INSTALL_NO_LIBRARIES) +IF(ITK_USE_FLAT_DIRECTORY_INSTALL) + SET( ITK_INSTALL_INCLUDE_DIR_CM24_ALGORITHMS ${ITK_INSTALL_INCLUDE_DIR_CM24}) +ELSE(ITK_USE_FLAT_DIRECTORY_INSTALL) + SET( ITK_INSTALL_INCLUDE_DIR_CM24_ALGORITHMS ${ITK_INSTALL_INCLUDE_DIR_CM24}/Algorithms) +ENDIF(ITK_USE_FLAT_DIRECTORY_INSTALL) + IF(NOT ITK_INSTALL_NO_DEVELOPMENT) FILE(GLOB __files1 "${CMAKE_CURRENT_SOURCE_DIR}/*.h") FILE(GLOB __files2 "${CMAKE_CURRENT_SOURCE_DIR}/*.txx") INSTALL(FILES ${__files1} ${__files2} - DESTINATION ${ITK_INSTALL_INCLUDE_DIR_CM24}/Algorithms + DESTINATION ${ITK_INSTALL_INCLUDE_DIR_CM24_ALGORITHMS} COMPONENT Development) ENDIF(NOT ITK_INSTALL_NO_DEVELOPMENT) diff --git a/Utilities/ITK/Code/Algorithms/itkBalloonForceFilter.h b/Utilities/ITK/Code/Algorithms/itkBalloonForceFilter.h index a3fe6311ffa49b021a6539000171422f073d1509..3adb80b98a93d8f5b029d8d2602224b652dbe5b6 100644 --- a/Utilities/ITK/Code/Algorithms/itkBalloonForceFilter.h +++ b/Utilities/ITK/Code/Algorithms/itkBalloonForceFilter.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkBalloonForceFilter.h,v $ Language: C++ - Date: $Date: 2009-04-23 03:53:34 $ - Version: $Revision: 1.40 $ + Date: $Date: 2009-11-22 18:19:44 $ + Version: $Revision: 1.42 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -34,9 +34,9 @@ namespace itk * \brief * * BalloonForceFilter is used to apply balloon force and the potential - * force onto the 2D deformable model. For 3D (multi-slices) segmentation - * please use BalloonForce3DFilter - * The balloon force is vertical to the surface of the model. The potential + * force onto the 2D surface model embedded in a 3D space. + * + * The balloon force is normal to the surface of the model. The potential * force is given out by the estimated boundary points. These two will meet * a balance at the boundary, thus the deformable model will fit to the * boundary. @@ -77,6 +77,10 @@ public: InputPointsContainerPointer; typedef typename InputMeshType::PointsContainer::Iterator InputPointsContainerIterator; + typedef typename InputMeshType::PointsContainerConstPointer + InputPointsContainerConstPointer; + typedef typename InputMeshType::PointsContainer::ConstIterator + InputPointsContainerConstIterator; typedef typename InputMeshType::PointDataContainerPointer InputPointDataContainerPointer; typedef typename InputMeshType::PointDataContainer::Iterator @@ -89,6 +93,15 @@ public: InputCellDataContainerPointer; typedef typename InputMeshType::CellDataContainer::Iterator InputCellDataContainerIterator; + typedef typename InputMeshType::CellsContainerConstPointer + InputCellsContainerConstPointer; + typedef typename InputMeshType::CellsContainer::ConstIterator + InputCellsContainerConstIterator; + typedef typename InputMeshType::CellDataContainerConstPointer + InputCellDataContainerConstPointer; + typedef typename InputMeshType::CellDataContainer::ConstIterator + InputCellDataContainerConstIterator; + typedef typename OutputMeshType::PointsContainerPointer OutputPointsContainerPointer; typedef typename OutputMeshType::PointsContainer::Iterator @@ -102,6 +115,7 @@ public: typedef CovariantVector<PixelType, 2> GradientType; typedef Image<GradientType, 2> GradientImageType; typedef typename InputMeshType::Pointer InputMeshPointer; + typedef typename InputMeshType::ConstPointer InputMeshConstPointer; typedef typename OutputMeshType::Pointer OutputMeshPointer; typedef typename ImageType::Pointer ImagePointer; typedef typename ImageType::IndexType IndexType; diff --git a/Utilities/ITK/Code/Algorithms/itkBalloonForceFilter.txx b/Utilities/ITK/Code/Algorithms/itkBalloonForceFilter.txx index eba1607c8d056537ba593e0e76e2775e5b57b15e..12284951cd6506648c62512a56c19b6f2ee395e8 100644 --- a/Utilities/ITK/Code/Algorithms/itkBalloonForceFilter.txx +++ b/Utilities/ITK/Code/Algorithms/itkBalloonForceFilter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkBalloonForceFilter.txx,v $ Language: C++ - Date: $Date: 2009-04-06 13:46:30 $ - Version: $Revision: 1.73 $ + Date: $Date: 2009-09-17 11:04:00 $ + Version: $Revision: 1.74 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -167,8 +167,9 @@ BalloonForceFilter<TInputMesh, TOutputMesh> m_Normals = InputMeshType::New(); m_Locations = InputMeshType::New(); - InputPointsContainerPointer myPoints = this->GetInput(0)->GetPoints(); - InputPointsContainerIterator points = myPoints->Begin(); + InputMeshConstPointer inputMesh = this->GetInput(0); + InputPointsContainerConstPointer myPoints = inputMesh->GetPoints(); + InputPointsContainerConstIterator points = myPoints->Begin(); InputPointsContainerPointer myForces = m_Forces->GetPoints(); myForces->Reserve(m_NumberOfNodes); @@ -190,11 +191,11 @@ BalloonForceFilter<TInputMesh, TOutputMesh> myLocations->Reserve(m_NumberOfNodes); InputPointsContainerIterator locations = myLocations->Begin(); - InputCellsContainerPointer myCells = this->GetInput(0)->GetCells(); - InputCellsContainerIterator cells = myCells->Begin(); + InputCellsContainerConstPointer myCells = inputMesh->GetCells(); + InputCellsContainerConstIterator cells = myCells->Begin(); - InputCellDataContainerPointer myCellData = this->GetInput(0)->GetCellData(); - InputCellDataContainerIterator celldata = myCellData->Begin(); + InputCellDataContainerConstPointer myCellData = inputMesh->GetCellData(); + InputCellDataContainerConstIterator celldata = myCellData->Begin(); ImageSizeType ImageSize = m_Gradient->GetBufferedRegion().GetSize(); @@ -944,11 +945,13 @@ BalloonForceFilter<TInputMesh, TOutputMesh> InputPointsContainerPointer myLocations = m_Locations->GetPoints(); InputPointsContainerIterator locations = myLocations->Begin(); - InputCellsContainerPointer myCells = this->GetInput(0)->GetCells(); - InputCellsContainerIterator cells = myCells->Begin(); + InputMeshConstPointer inputMesh = this->GetInput(0); - InputCellDataContainerPointer myCellData = this->GetInput(0)->GetCellData(); - InputCellDataContainerIterator celldata = myCellData->Begin(); + InputCellsContainerConstPointer myCells = inputMesh->GetCells(); + InputCellsContainerConstIterator cells = myCells->Begin(); + + InputCellDataContainerConstPointer myCellData = inputMesh->GetCellData(); + InputCellDataContainerConstIterator celldata = myCellData->Begin(); { for (unsigned int i=0; i<m_NumberOfNodes; i++) diff --git a/Utilities/ITK/Code/Algorithms/itkBayesianClassifierImageFilter.h b/Utilities/ITK/Code/Algorithms/itkBayesianClassifierImageFilter.h old mode 100644 new mode 100755 index a35a1e7ee53cd1e442a9ffff1144624a467cef5d..8ef4fb2795a5e496d8bb74497e7f3694a4f3a9cd --- a/Utilities/ITK/Code/Algorithms/itkBayesianClassifierImageFilter.h +++ b/Utilities/ITK/Code/Algorithms/itkBayesianClassifierImageFilter.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkBayesianClassifierImageFilter.h,v $ Language: C++ - Date: $Date: 2009-04-23 03:53:34 $ - Version: $Revision: 1.15 $ + Date: $Date: 2010-01-30 21:05:25 $ + Version: $Revision: 1.17 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -170,6 +170,9 @@ public: void SetSmoothingFilter( SmoothingFilterType * ); itkGetConstMacro( SmoothingFilter, SmoothingFilterPointer ); + /** Set the priors **/ + virtual void SetPriors( const PriorsImageType * ); + /** Number of iterations to apply the smoothing filter */ itkSetMacro( NumberOfSmoothingIterations, unsigned int ); itkGetConstMacro( NumberOfSmoothingIterations, unsigned int ); diff --git a/Utilities/ITK/Code/Algorithms/itkBayesianClassifierImageFilter.txx b/Utilities/ITK/Code/Algorithms/itkBayesianClassifierImageFilter.txx old mode 100644 new mode 100755 index b94b725c6589f14657999b3fb15bae7595a5966c..d280f832b96073e0c04923693dc8c8d0c0569559 --- a/Utilities/ITK/Code/Algorithms/itkBayesianClassifierImageFilter.txx +++ b/Utilities/ITK/Code/Algorithms/itkBayesianClassifierImageFilter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkBayesianClassifierImageFilter.txx,v $ Language: C++ - Date: $Date: 2009-03-13 14:26:51 $ - Version: $Revision: 1.9 $ + Date: $Date: 2010-01-30 21:05:25 $ + Version: $Revision: 1.12 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -197,7 +197,7 @@ BayesianClassifierImageFilter<TInputVectorImage, TLabelsType, while( !itrMembershipImage.IsAtEnd() ) { - PosteriorsPixelType posteriors; + PosteriorsPixelType posteriors(numberOfClasses); const PriorsPixelType priors = itrPriorsImage.Get(); const MembershipPixelType memberships = itrMembershipImage.Get(); for( unsigned int i=0; i<numberOfClasses; i++) @@ -251,6 +251,22 @@ BayesianClassifierImageFilter<TInputVectorImage, TLabelsType, } +/** + * Set the prior image + */ +template < class TInputVectorImage, class TLabelsType, + class TPosteriorsPrecisionType, class TPriorsPrecisionType > +void +BayesianClassifierImageFilter<TInputVectorImage, TLabelsType, + TPosteriorsPrecisionType, TPriorsPrecisionType > +::SetPriors( const PriorsImageType * priors ) +{ + this->ProcessObject::SetNthInput(1, const_cast< PriorsImageType * >( priors ) ); + this->m_UserProvidedPriors = true; + this->Modified(); +} + + /** * Normalize the posteriors and smooth them using an user-provided. */ diff --git a/Utilities/ITK/Code/Algorithms/itkBinaryMask3DMeshSource.txx b/Utilities/ITK/Code/Algorithms/itkBinaryMask3DMeshSource.txx index f4cf71c5e7956ff110ee51cf891837f1b65290f7..71e0092c9c5284d662a39cda37770c0fcc7122c2 100644 --- a/Utilities/ITK/Code/Algorithms/itkBinaryMask3DMeshSource.txx +++ b/Utilities/ITK/Code/Algorithms/itkBinaryMask3DMeshSource.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkBinaryMask3DMeshSource.txx,v $ Language: C++ -Date: $Date: 2009-04-12 03:55:23 $ -Version: $Revision: 1.29 $ +Date: $Date: 2009-10-06 19:11:58 $ +Version: $Revision: 1.30 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -56,7 +56,7 @@ BinaryMask3DMeshSource<TInputImage,TOutputMesh> this->GetOutput()->GetPoints()->Reserve(m_NodeLimit); this->GetOutput()->GetCells()->Reserve(m_CellLimit); - m_ObjectValue = NumericTraits< InputPixelType >::Zero; + m_ObjectValue = NumericTraits< InputPixelType >::One; } template<class TInputImage, class TOutputMesh> diff --git a/Utilities/ITK/Code/Algorithms/itkBioCellBase.cxx b/Utilities/ITK/Code/Algorithms/itkBioCellBase.cxx index 94d20650e9056dc132ee7d7bcbba2bc3d67f1e81..8359bda59a7c740682797654d7da6b6dfd6d319f 100644 --- a/Utilities/ITK/Code/Algorithms/itkBioCellBase.cxx +++ b/Utilities/ITK/Code/Algorithms/itkBioCellBase.cxx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkBioCellBase.cxx,v $ Language: C++ - Date: $Date: 2008-10-20 21:50:21 $ - Version: $Revision: 1.6 $ + Date: $Date: 2010-03-30 15:20:03 $ + Version: $Revision: 1.8 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -19,6 +19,7 @@ #include "vnl/vnl_math.h" #include "vnl/vnl_sample.h" +#include "itkMath.h" namespace itk { @@ -276,9 +277,9 @@ CellBase SetMaximumGenerationLimit( 40 ); // it should use Teleomeres for implementing this - WellNourishedColor.Set( 0.0, 0.0, 1.0 ); - HopefullColor.Set( 0.0, 1.0, 0.0 ); - StarvingColor.Set( 1.0, 0.0, 0.0 ); + WellNourishedColor.Set( 0.0f, 0.0f, 1.0f ); + HopefullColor.Set( 0.0f, 1.0f, 0.0f ); + StarvingColor.Set( 1.0f, 0.0f, 0.0f ); SetDefaultColor( HopefullColor ); @@ -574,9 +575,11 @@ void CellBase ::SecreteProducts(void) { - m_Color.SetRed( m_Genome->GetExpressionLevel( RedGene ) ); - m_Color.SetGreen( m_Genome->GetExpressionLevel( GreenGene ) ); - m_Color.SetBlue( m_Genome->GetExpressionLevel( BlueGene ) ); + typedef ColorType::ValueType ColorValueType; + + m_Color.SetRed( ColorValueType( m_Genome->GetExpressionLevel( RedGene ) ) ); + m_Color.SetGreen( ColorValueType( m_Genome->GetExpressionLevel( GreenGene ) ) ); + m_Color.SetBlue( ColorValueType( m_Genome->GetExpressionLevel( BlueGene ) ) ); } /** diff --git a/Utilities/ITK/Code/Algorithms/itkBioGene.cxx b/Utilities/ITK/Code/Algorithms/itkBioGene.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Algorithms/itkBioGene.h b/Utilities/ITK/Code/Algorithms/itkBioGene.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Algorithms/itkBioGeneNetwork.cxx b/Utilities/ITK/Code/Algorithms/itkBioGeneNetwork.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Algorithms/itkBioGeneNetwork.h b/Utilities/ITK/Code/Algorithms/itkBioGeneNetwork.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Algorithms/itkClassifierBase.h b/Utilities/ITK/Code/Algorithms/itkClassifierBase.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Algorithms/itkClassifierBase.txx b/Utilities/ITK/Code/Algorithms/itkClassifierBase.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Algorithms/itkConnectedRegionsMeshFilter.h b/Utilities/ITK/Code/Algorithms/itkConnectedRegionsMeshFilter.h index 430a51e6a74a0395bceaa0b473eb62090f29b13a..d49c1a98013e28b879cad9e3b8bb15ffd5849246 100644 --- a/Utilities/ITK/Code/Algorithms/itkConnectedRegionsMeshFilter.h +++ b/Utilities/ITK/Code/Algorithms/itkConnectedRegionsMeshFilter.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkConnectedRegionsMeshFilter.h,v $ Language: C++ - Date: $Date: 2009-04-23 03:53:34 $ - Version: $Revision: 1.27 $ + Date: $Date: 2009-09-17 11:04:00 $ + Version: $Revision: 1.28 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -68,7 +68,7 @@ public: */ typedef TInputMesh InputMeshType; typedef TOutputMesh OutputMeshType; - typedef typename TInputMesh::Pointer InputMeshPointer; + typedef typename TInputMesh::ConstPointer InputMeshConstPointer; typedef typename TOutputMesh::Pointer OutputMeshPointer; itkStaticConstMacro( PointDimension, unsigned int, @@ -76,14 +76,18 @@ public: typedef typename TInputMesh::PointType InputMeshPointType; typedef typename TInputMesh::PointIdentifier InputMeshPointIdentifier; - typedef typename TInputMesh::PointsContainerPointer - InputMeshPointsContainerPointer; + typedef typename TInputMesh::PointsContainerConstPointer + InputMeshPointsContainerConstPointer; typedef typename TInputMesh::CellsContainer InputMeshCellsContainer; typedef typename TInputMesh::CellsContainerPointer InputMeshCellsContainerPointer; + typedef typename TInputMesh::CellsContainerConstPointer + InputMeshCellsContainerConstPointer; typedef typename TInputMesh::CellDataContainer InputMeshCellDataContainer; typedef typename TInputMesh::CellDataContainerPointer InputMeshCellDataContainerPointer; + typedef typename TInputMesh::CellDataContainerConstPointer + InputMeshCellDataContainerConstPointer; typedef typename InputMeshType::PointsContainer::ConstIterator PointsContainerConstIterator; typedef typename InputMeshType::CellsContainer::ConstIterator @@ -93,8 +97,8 @@ public: typedef typename TInputMesh::CellAutoPointer InputMeshCellPointer; typedef typename TInputMesh::CellTraits::PointIdConstIterator InputMeshPointIdConstIterator; - typedef typename TInputMesh::CellLinksContainerPointer - InputMeshCellLinksContainerPointer; + typedef typename TInputMesh::CellLinksContainerConstPointer + InputMeshCellLinksContainerConstPointer; typedef typename TInputMesh::PointCellLinksContainer InputMeshCellLinksContainer; typedef typename TInputMesh::CellIdentifier InputMeshCellIdentifier; diff --git a/Utilities/ITK/Code/Algorithms/itkConnectedRegionsMeshFilter.txx b/Utilities/ITK/Code/Algorithms/itkConnectedRegionsMeshFilter.txx index 3d94aac3df3fe8cc007ba2f3887c925eaaca61b6..2a05b217ed2fb6e4728d6c3da53625a253644b13 100644 --- a/Utilities/ITK/Code/Algorithms/itkConnectedRegionsMeshFilter.txx +++ b/Utilities/ITK/Code/Algorithms/itkConnectedRegionsMeshFilter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkConnectedRegionsMeshFilter.txx,v $ Language: C++ - Date: $Date: 2008-10-23 16:15:23 $ - Version: $Revision: 1.36 $ + Date: $Date: 2009-09-17 11:04:00 $ + Version: $Revision: 1.37 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -137,11 +137,11 @@ void ConnectedRegionsMeshFilter<TInputMesh, TOutputMesh> ::GenerateData() { - InputMeshPointer input = this->GetInput(); + InputMeshConstPointer input = this->GetInput(); OutputMeshPointer output = this->GetOutput(); - InputMeshPointsContainerPointer inPts = input->GetPoints(); - InputMeshCellsContainerPointer inCells = input->GetCells(); - InputMeshCellDataContainerPointer inCellData = input->GetCellData(); + InputMeshPointsContainerConstPointer inPts = input->GetPoints(); + InputMeshCellsContainerConstPointer inCells = input->GetCells(); + InputMeshCellDataContainerConstPointer inCellData = input->GetCellData(); itkDebugMacro(<<"Executing connectivity"); @@ -217,7 +217,7 @@ ConnectedRegionsMeshFilter<TInputMesh, TOutputMesh> m_NumberOfCellsInRegion = 0; if ( m_ExtractionMode == PointSeededRegions ) { - InputMeshCellLinksContainerPointer cellLinks; + InputMeshCellLinksContainerConstPointer cellLinks; cellLinks = input->GetCellLinks(); InputMeshCellLinksContainer links; typename std::set<InputMeshCellIdentifier>::iterator citer; @@ -249,7 +249,7 @@ ConnectedRegionsMeshFilter<TInputMesh, TOutputMesh> double minDist2=NumericTraits<double>::max(), dist2; InputMeshPointIdentifier minId = 0; InputMeshPointType x; - for (PointsContainerConstIterator piter=inPts->Begin(); + for (PointsContainerConstIterator piter = inPts->Begin(); piter != inPts->End(); ++piter) { x = piter->Value(); @@ -262,7 +262,7 @@ ConnectedRegionsMeshFilter<TInputMesh, TOutputMesh> } // get the cells using the closest point and use them as seeds - InputMeshCellLinksContainerPointer cellLinks; + InputMeshCellLinksContainerConstPointer cellLinks; cellLinks = input->GetCellLinks(); InputMeshCellLinksContainer links; typename std::set<InputMeshCellIdentifier>::iterator citer; @@ -287,8 +287,8 @@ ConnectedRegionsMeshFilter<TInputMesh, TOutputMesh> itkDebugMacro (<<"Extracted " << m_RegionNumber << " region(s)"); // Pass the point and point data through - output->SetPoints(inPts); - output->SetPointData(input->GetPointData()); + this->CopyInputMeshToOutputMeshPoints(); + this->CopyInputMeshToOutputMeshPointData(); // Create output cells // @@ -413,12 +413,11 @@ void ConnectedRegionsMeshFilter<TInputMesh, TOutputMesh> ::PropagateConnectedWave() { - InputMeshPointer input = this->GetInput(); + InputMeshConstPointer input = this->GetInput(); unsigned long cellId; InputMeshCellPointer cellPtr; InputMeshPointIdConstIterator piter; - InputMeshCellLinksContainerPointer cellLinks; - cellLinks = input->GetCellLinks(); + InputMeshCellLinksContainerConstPointer cellLinks = input->GetCellLinks(); InputMeshCellLinksContainer links; std::vector<unsigned long>::iterator i; diff --git a/Utilities/ITK/Code/Algorithms/itkDeformableMesh3DFilter.h b/Utilities/ITK/Code/Algorithms/itkDeformableMesh3DFilter.h index b499565849b943f9a2a7167efed942f27ff36902..5a53d9a5a92cdbb83a3202964e161c87f8d03080 100644 --- a/Utilities/ITK/Code/Algorithms/itkDeformableMesh3DFilter.h +++ b/Utilities/ITK/Code/Algorithms/itkDeformableMesh3DFilter.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkDeformableMesh3DFilter.h,v $ Language: C++ - Date: $Date: 2009-04-28 17:42:50 $ - Version: $Revision: 1.29 $ + Date: $Date: 2009-09-17 11:04:00 $ + Version: $Revision: 1.30 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -76,8 +76,12 @@ public: typedef TInputMesh InputMeshType; typedef typename InputMeshType::PointsContainerPointer InputPointsContainerPointer; + typedef typename InputMeshType::PointsContainerConstPointer + InputPointsContainerConstPointer; typedef typename InputMeshType::PointsContainer::Iterator InputPointsContainerIterator; + typedef typename InputMeshType::PointsContainer::ConstIterator + InputPointsContainerConstIterator; typedef typename InputMeshType::PointDataContainerPointer InputPointDataContainerPointer; typedef typename InputMeshType::PointDataContainer::Iterator @@ -86,10 +90,18 @@ public: InputCellsContainerPointer; typedef typename InputMeshType::CellsContainer::Iterator InputCellsContainerIterator; + typedef typename InputMeshType::CellsContainerConstPointer + InputCellsContainerConstPointer; + typedef typename InputMeshType::CellsContainer::ConstIterator + InputCellsContainerConstIterator; typedef typename InputMeshType::CellDataContainerPointer InputCellDataContainerPointer; typedef typename InputMeshType::CellDataContainer::Iterator InputCellDataContainerIterator; + typedef typename InputMeshType::CellDataContainerConstPointer + InputCellDataContainerConstPointer; + typedef typename InputMeshType::CellDataContainer::ConstIterator + InputCellDataContainerConstIterator; typedef TOutputMesh OutputMeshType; typedef typename OutputMeshType::PointsContainerPointer @@ -124,9 +136,10 @@ public: typedef CovariantVector<double, 3> double3DVector; /* Mesh pointer definition. */ - typedef typename InputMeshType::Pointer InputMeshPointer; - typedef typename OutputMeshType::Pointer OutputMeshPointer; - typedef typename GradientImageType::Pointer GradientImagePointer; + typedef typename InputMeshType::Pointer InputMeshPointer; + typedef typename InputMeshType::ConstPointer InputMeshConstPointer; + typedef typename OutputMeshType::Pointer OutputMeshPointer; + typedef typename GradientImageType::Pointer GradientImagePointer; /* Stiffness Matrix Type definition */ typedef vnl_matrix_fixed<double, 4, 4> StiffnessMatrixType; diff --git a/Utilities/ITK/Code/Algorithms/itkDeformableMesh3DFilter.txx b/Utilities/ITK/Code/Algorithms/itkDeformableMesh3DFilter.txx index 761cd4667b8deb49fa59985dd715744d66510ffe..1257958460a2db3ca0b15a17bdddd6995e4eb7b3 100644 --- a/Utilities/ITK/Code/Algorithms/itkDeformableMesh3DFilter.txx +++ b/Utilities/ITK/Code/Algorithms/itkDeformableMesh3DFilter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkDeformableMesh3DFilter.txx,v $ Language: C++ - Date: $Date: 2009-05-22 17:54:15 $ - Version: $Revision: 1.64 $ + Date: $Date: 2009-09-17 11:04:01 $ + Version: $Revision: 1.65 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -122,8 +122,9 @@ DeformableMesh3DFilter<TInputMesh, TOutputMesh> m_Normals = InputMeshType::New(); m_Locations = InputMeshType::New(); - InputPointsContainerPointer myPoints = this->GetInput(0)->GetPoints(); - InputPointsContainerIterator points = myPoints->Begin(); + InputMeshConstPointer inputMesh = this->GetInput(0); + InputPointsContainerConstPointer myPoints = inputMesh->GetPoints(); + InputPointsContainerConstIterator points = myPoints->Begin(); InputPointsContainerPointer myForces = m_Forces->GetPoints(); myForces->Reserve(m_NumberOfNodes); @@ -145,10 +146,8 @@ DeformableMesh3DFilter<TInputMesh, TOutputMesh> myLocations->Reserve(m_NumberOfNodes); InputPointsContainerIterator locations = myLocations->Begin(); - InputCellsContainerPointer myCells = this->GetInput(0)->GetCells(); - InputCellsContainerIterator cells = myCells->Begin(); - - InputCellDataContainerPointer myCellData = this->GetInput(0)->GetCellData(); + InputCellsContainerConstPointer myCells = inputMesh->GetCells(); + InputCellsContainerConstIterator cells = myCells->Begin(); ImageSizeType ImageSize = m_Gradient->GetBufferedRegion().GetSize(); @@ -279,8 +278,9 @@ void DeformableMesh3DFilter<TInputMesh, TOutputMesh> ::SetMeshStiffness () { - InputCellDataContainerPointer myCellData = this->GetInput(0)->GetCellData(); - InputCellDataContainerIterator celldata = myCellData->Begin(); + InputMeshConstPointer inputMesh = this->GetInput(0); + InputCellDataContainerConstPointer myCellData = inputMesh->GetCellData(); + InputCellDataContainerConstIterator celldata = myCellData->Begin(); m_K = new StiffnessMatrixRawPointer[m_NumberOfCells]; @@ -304,8 +304,9 @@ DeformableMesh3DFilter<TInputMesh, TOutputMesh> int i; const unsigned long *tp; - InputCellsContainerPointer myCells = this->GetInput(0)->GetCells(); - InputCellsContainerIterator cells = myCells->Begin(); + InputMeshConstPointer inputMesh = this->GetInput(0); + InputCellsContainerConstPointer myCells = inputMesh->GetCells(); + InputCellsContainerConstIterator cells = myCells->Begin(); InputPointsContainerPointer myForces = m_Forces->GetPoints(); InputPointsContainerIterator forces = myForces->Begin(); @@ -475,11 +476,12 @@ DeformableMesh3DFilter<TInputMesh, TOutputMesh> InputPointsContainerPointer myLocations = m_Locations->GetPoints(); InputPointsContainerIterator locations = myLocations->Begin(); - InputCellsContainerPointer myCells = this->GetInput(0)->GetCells(); - InputCellsContainerIterator cells = myCells->Begin(); + InputMeshConstPointer inputMesh = this->GetInput(0); + InputCellsContainerConstPointer myCells = inputMesh->GetCells(); + InputCellsContainerConstIterator cells = myCells->Begin(); - InputCellDataContainerPointer myCellData = this->GetInput(0)->GetCellData(); - InputCellDataContainerIterator celldata = myCellData->Begin(); + InputCellDataContainerConstPointer myCellData = inputMesh->GetCellData(); + InputCellDataContainerConstIterator celldata = myCellData->Begin(); i = 0; for (; i<m_NumberOfNodes; i++) @@ -776,8 +778,9 @@ DeformableMesh3DFilter<TInputMesh, TOutputMesh> double coa, cob, coc; double absvec; - InputCellsContainerPointer myCells = this->GetInput(0)->GetCells(); - InputCellsContainerIterator cells = myCells->Begin(); + InputMeshConstPointer inputMesh = this->GetInput(0); + InputCellsContainerConstPointer myCells = inputMesh->GetCells(); + InputCellsContainerConstIterator cells = myCells->Begin(); InputPointsContainerPointer myNormals = m_Normals->GetPoints(); InputPointsContainerIterator normals = myNormals->Begin(); diff --git a/Utilities/ITK/Code/Algorithms/itkDeformableSimplexMesh3DFilter.h b/Utilities/ITK/Code/Algorithms/itkDeformableSimplexMesh3DFilter.h index abc4e7f672158ec573f1777fe6851d488cae6a8a..49bdab2c8006b80941862447f5fa7808e2829415 100644 --- a/Utilities/ITK/Code/Algorithms/itkDeformableSimplexMesh3DFilter.h +++ b/Utilities/ITK/Code/Algorithms/itkDeformableSimplexMesh3DFilter.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkDeformableSimplexMesh3DFilter.h,v $ Language: C++ - Date: $Date: 2009-05-12 17:26:20 $ - Version: $Revision: 1.17 $ + Date: $Date: 2009-10-29 18:40:34 $ + Version: $Revision: 1.19 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -92,9 +92,9 @@ public: typedef TInputMesh InputMeshType; typedef TOutputMesh OutputMeshType; - typedef typename InputMeshType::PointsContainerPointer InputPointsContainerPointer; - typedef typename InputMeshType::PointsContainer InputPointsContainer; - typedef typename InputMeshType::PointsContainer::Iterator InputPointsContainerIterator; + typedef typename InputMeshType::PointsContainerPointer InputPointsContainerPointer; + typedef typename InputMeshType::PointsContainer InputPointsContainer; + typedef typename InputMeshType::PointsContainer::ConstIterator InputPointsContainerConstIterator; /** Other definitions. */ typedef typename SimplexMeshGeometry::PointType PointType; @@ -189,7 +189,7 @@ public: itkGetConstMacro(Rigidity, unsigned int); itkSetObjectMacro(Data, GeometryMapType ); - itkGetObjectMacro(Data, GeometryMapType ); + itkGetConstObjectMacro(Data, GeometryMapType ); /** Width, height and depth of image */ itkGetConstMacro(ImageWidth,int); diff --git a/Utilities/ITK/Code/Algorithms/itkDeformableSimplexMesh3DFilter.txx b/Utilities/ITK/Code/Algorithms/itkDeformableSimplexMesh3DFilter.txx index d9717cb54365c240acde7b55856961544bf4b08e..a4794f6f8fe0475faa416ddacd27b57bf0d9e4aa 100644 --- a/Utilities/ITK/Code/Algorithms/itkDeformableSimplexMesh3DFilter.txx +++ b/Utilities/ITK/Code/Algorithms/itkDeformableSimplexMesh3DFilter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkDeformableSimplexMesh3DFilter.txx,v $ Language: C++ - Date: $Date: 2009-05-22 18:02:19 $ - Version: $Revision: 1.24 $ + Date: $Date: 2009-10-29 18:40:35 $ + Version: $Revision: 1.26 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -76,27 +76,27 @@ DeformableSimplexMesh3DFilter<TInputMesh, TOutputMesh> ::PrintSelf(std::ostream& os, Indent indent) const { Superclass::PrintSelf(os,indent); - os << indent << "Alpha = " << m_Alpha << std::endl; - os << indent << "Beta = " << m_Beta << std::endl; - os << indent << "Gamma = " << m_Gamma << std::endl; - os << indent << "Rigidity = " << m_Rigidity << std::endl; - os << indent << "Iterations = " << m_Iterations << std::endl; - os << indent << "Step = " << m_Step << std::endl; - os << indent << "ImageDepth = " << m_ImageDepth << std::endl; - if( this->m_Gradient.IsNotNull() ) + os << indent << "Alpha = " << this->GetAlpha() << std::endl; + os << indent << "Beta = " << this->GetBeta() << std::endl; + os << indent << "Gamma = " << this->GetGamma() << std::endl; + os << indent << "Rigidity = " << this->GetRigidity() << std::endl; + os << indent << "Iterations = " << this->GetIterations() << std::endl; + os << indent << "Step = " << this->GetStep() << std::endl; + os << indent << "ImageDepth = " << this->GetImageDepth() << std::endl; + if( this->GetGradient().IsNotNull() ) { - os << indent << "Gradient = " << this->m_Gradient << std::endl; + os << indent << "Gradient = " << this->GetGradient() << std::endl; } else { os << indent << "Gradient = " << "(None)" << std::endl; } - os << indent << "ImageHeight = " << m_ImageHeight << std::endl; - os << indent << "ImageWidth = " << m_ImageWidth << std::endl; - os << indent << "Damping = " << m_Damping << std::endl; + os << indent << "ImageHeight = " << this->GetImageHeight() << std::endl; + os << indent << "ImageWidth = " << this->GetImageWidth() << std::endl; + os << indent << "Damping = " << this->GetDamping() << std::endl; if( this->m_Data.IsNotNull() ) { - os << indent << "Data = " << this->m_Data << std::endl; + os << indent << "Data = " << this->GetData() << std::endl; } else { @@ -134,15 +134,18 @@ DeformableSimplexMesh3DFilter<TInputMesh, TOutputMesh> this->ComputeDisplacement(); m_Step++; } - InputPointsContainerPointer myPoints = this->GetInput(0)->GetPoints(); - InputPointsContainerIterator points = myPoints->Begin(); - while( points != myPoints->End() ) + + const InputMeshType * inputMesh = this->GetInput(0); + const InputPointsContainer * points = inputMesh->GetPoints(); + InputPointsContainerConstIterator pointItr = points->Begin(); + + while( pointItr != points->End() ) { SimplexMeshGeometry * data; - unsigned long idx = points.Index(); + unsigned long idx = pointItr.Index(); data = this->m_Data->GetElement(idx); delete data->neighborSet; - points++; + pointItr++; } this->ComputeOutput(); } @@ -155,8 +158,9 @@ void DeformableSimplexMesh3DFilter<TInputMesh, TOutputMesh> ::Initialize() { - InputPointsContainerPointer myPoints = this->GetInput(0)->GetPoints(); - InputPointsContainerIterator points = myPoints->Begin(); + const InputMeshType * inputMesh = this->GetInput(0); + const InputPointsContainer * points = inputMesh->GetPoints(); + InputPointsContainerConstIterator pointItr = points->Begin(); if ( this->m_Gradient.IsNotNull() ) { @@ -178,22 +182,22 @@ DeformableSimplexMesh3DFilter<TInputMesh, TOutputMesh> this->m_Data = this->GetInput(0)->GetGeometryData(); } - while( points != myPoints->End() ) + while( pointItr != points->End() ) { SimplexMeshGeometry * data; - unsigned long idx = points.Index(); + unsigned long idx = pointItr.Index(); data = this->m_Data->GetElement(idx); - data->pos = points.Value(); + data->pos = pointItr.Value(); - // InputMeshType::ArrayType neighbors = this->GetInput(0)->GetNeighbors( points.Index() ); + // InputMeshType::ArrayType neighbors = this->GetInput(0)->GetNeighbors( pointItr.Index() ); - data->neighbors[0] = myPoints->GetElement(data->neighborIndices[0]); - data->neighbors[1] = myPoints->GetElement(data->neighborIndices[1]); - data->neighbors[2] = myPoints->GetElement(data->neighborIndices[2]); + data->neighbors[0] = points->GetElement(data->neighborIndices[0]); + data->neighbors[1] = points->GetElement(data->neighborIndices[1]); + data->neighbors[2] = points->GetElement(data->neighborIndices[2]); // store neighborset with a specific radius - InputNeighbors* neighborsList = this->GetInput(0)->GetNeighbors( points.Index() , m_Rigidity); + InputNeighbors* neighborsList = this->GetInput(0)->GetNeighbors( pointItr.Index() , m_Rigidity); InputNeighborsIterator neighborIt = neighborsList->begin(); NeighborSetType * neighborSet = new NeighborSetType(); @@ -205,7 +209,7 @@ DeformableSimplexMesh3DFilter<TInputMesh, TOutputMesh> delete neighborsList; data->neighborSet = neighborSet; - points++; + pointItr++; } OutputMeshPointer outputMesh = this->GetOutput(); @@ -223,7 +227,8 @@ DeformableSimplexMesh3DFilter<TInputMesh, TOutputMesh> VectorType tmp; // unsigned long idx = 0; - InputMeshPointer inputMesh = this->GetInput(0); + const InputMeshType * inputMesh = this->GetInput(0); + const InputPointsContainer * points = inputMesh->GetPoints(); typename GeometryMapType::Iterator dataIt = this->m_Data->Begin(); @@ -234,9 +239,9 @@ DeformableSimplexMesh3DFilter<TInputMesh, TOutputMesh> // idx = dataIt.Index(); data = dataIt.Value(); - data->neighbors[0] = inputMesh->GetPoints()->GetElement(data->neighborIndices[0]); - data->neighbors[1] = inputMesh->GetPoints()->GetElement(data->neighborIndices[1]); - data->neighbors[2] = inputMesh->GetPoints()->GetElement(data->neighborIndices[2]); + data->neighbors[0] = points->GetElement(data->neighborIndices[0]); + data->neighbors[1] = points->GetElement(data->neighborIndices[1]); + data->neighbors[2] = points->GetElement(data->neighborIndices[2]); // compute normal normal.Fill(0.0); @@ -284,7 +289,13 @@ void DeformableSimplexMesh3DFilter<TInputMesh, TOutputMesh> ::ComputeDisplacement() { - InputMeshPointer inputMesh = this->GetInput(0); + const InputMeshType * inputMesh = this->GetInput(0); + + // Filters should not modify their input... + // There is a design flaw here. + InputPointsContainer * nonConstPoints = + const_cast< InputPointsContainer * >( inputMesh->GetPoints() ); + typename GeometryMapType::Iterator dataIt = this->m_Data->Begin(); SimplexMeshGeometry * data; VectorType displacement; @@ -301,7 +312,7 @@ DeformableSimplexMesh3DFilter<TInputMesh, TOutputMesh> (data->externalForce).Get_vnl_vector() ); data->pos += displacement; - inputMesh->GetPoints()->InsertElement( dataIt.Index(), data->pos ); + nonConstPoints->InsertElement( dataIt.Index(), data->pos ); dataIt++; } @@ -313,7 +324,6 @@ void DeformableSimplexMesh3DFilter<TInputMesh, TOutputMesh> ::ComputeInternalForce(SimplexMeshGeometry *data) { - InputMeshPointer inputMesh = this->GetInput(0); VectorType tangentForce, normalForce; double eps1Diff, eps2Diff, eps3Diff; // double diffAbsSum; @@ -365,10 +375,9 @@ DeformableSimplexMesh3DFilter<TInputMesh, TOutputMesh> { data->internalForce += tangentForce + normalForce; } - - } + /** Compute model Displacement according to image gradient forces */ template <typename TInputMesh, typename TOutputMesh> void @@ -455,9 +464,12 @@ DeformableSimplexMesh3DFilter<TInputMesh, TOutputMesh> ::ComputeOutput() { OutputMeshType * output = this->GetOutput(); - output->SetPoints(this->GetInput(0)->GetPoints()); - output->SetPointData(this->GetInput(0)->GetPointData()); - output->SetCells(this->GetInput(0)->GetCells()); + + this->CopyInputMeshToOutputMeshPoints(); + this->CopyInputMeshToOutputMeshPointData(); + this->CopyInputMeshToOutputMeshCells(); + this->CopyInputMeshToOutputMeshCellData(); + output->SetGeometryData(this->m_Data); output->SetLastCellId( this->GetInput(0)->GetLastCellId() ); } @@ -469,8 +481,11 @@ void DeformableSimplexMesh3DFilter<TInputMesh, TOutputMesh> ::UpdateReferenceMetrics() { - InputMeshPointer inputMesh = this->GetInput(0); - InputPointsContainerPointer points = inputMesh->GetPoints(); + const InputMeshType * inputMesh = this->GetInput(0); + + // Filters should not change their input. + // There is a design flaw here. + InputMeshType * nonConstInputMesh = const_cast< InputMeshType * >( inputMesh ); double H; double H_N1; @@ -516,7 +531,7 @@ DeformableSimplexMesh3DFilter<TInputMesh, TOutputMesh> // set current reference metrics data->referenceMetrics = eps; - inputMesh->SetPointData( dataIt->Index() , H ); + nonConstInputMesh->SetPointData( dataIt->Index() , H ); dataIt.Value() = data; // m_Data->InsertElement(dataIt->Index(),data); dataIt++; diff --git a/Utilities/ITK/Code/Algorithms/itkFEMRegistrationFilter.h b/Utilities/ITK/Code/Algorithms/itkFEMRegistrationFilter.h index fc4c350e1dc15843d979703599392f1617524fe6..f8a400fabff331e530faecac291d9f98834fcb11 100644 --- a/Utilities/ITK/Code/Algorithms/itkFEMRegistrationFilter.h +++ b/Utilities/ITK/Code/Algorithms/itkFEMRegistrationFilter.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkFEMRegistrationFilter.h,v $ Language: C++ - Date: $Date: 2009-04-23 03:53:35 $ - Version: $Revision: 1.26 $ + Date: $Date: 2010-03-02 03:40:35 $ + Version: $Revision: 1.29 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -211,7 +211,8 @@ public: /** Writes the displacement field to a file as a single volume with multiple components. */ int WriteDisplacementFieldMultiComponent(); - /** One can set the reference file names to read images from files */ + /** One can set the reference file names to read images from files. + \deprecated This method currently doesn't have any effect. */ void SetMovingFile(const char* r) { m_MovingFileName=r; @@ -222,6 +223,7 @@ public: return m_MovingFileName; } + /** \deprecated This method doesn't have any effect */ void SetFixedFile(const char* t) {m_FixedFileName=t;} std::string GetFixedFile() {return m_FixedFileName;} @@ -479,10 +481,12 @@ public: ~FEMRegistrationFilter(); // HELPER FUNCTIONS -protected : +protected: - /** \class A non-templated class to access FEMObjectFactory + /** + * \class FEMOF + * A non-templated class to access FEMObjectFactory * Easy access to the FEMObjectFactory. We create a new class * whose name is shorter and it's not templated... */ @@ -547,7 +551,7 @@ protected : void PrintSelf(std::ostream& os, Indent indent) const; -private : +private: void InitializeField(); @@ -556,8 +560,8 @@ private : std::string m_ConfigFileName; std::string m_ResultsFileName; - std::string m_MovingFileName; - std::string m_FixedFileName; + std::string m_MovingFileName; // This variable is currently not being used. + std::string m_FixedFileName; // This variable is currently not being used. std::string m_LandmarkFileName; std::string m_DisplacementsFileName; std::string m_MeshFileName; diff --git a/Utilities/ITK/Code/Algorithms/itkFEMRegistrationFilter.txx b/Utilities/ITK/Code/Algorithms/itkFEMRegistrationFilter.txx index 22673a29511cad1ba710f7570111abe3836ab58f..27f76d64253dc9e57df153c4c58afa6a71caddb0 100644 --- a/Utilities/ITK/Code/Algorithms/itkFEMRegistrationFilter.txx +++ b/Utilities/ITK/Code/Algorithms/itkFEMRegistrationFilter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkFEMRegistrationFilter.txx,v $ Language: C++ - Date: $Date: 2009-06-15 22:11:29 $ - Version: $Revision: 1.59 $ + Date: $Date: 2010-04-01 22:17:59 $ + Version: $Revision: 1.60 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -579,7 +579,7 @@ int FEMRegistrationFilter<TMovingImage,TFixedImage>::WriteDisplacementField(unsi fieldImage = fieldCaster->GetOutput(); // Set up the output filename - std::string outfile=m_DisplacementsFileName+static_cast<char>('x'+index)+std::string("vec.hdr"); + std::string outfile=m_DisplacementsFileName+static_cast<char>('x'+index)+std::string("vec.mhd"); std::cout << "Writing displacements to " << outfile; typedef typename FloatImageType::PixelType FType; @@ -1611,7 +1611,7 @@ void FEMRegistrationFilter<TMovingImage,TFixedImage>::WriteWarpedImage(const cha // for image output std::ofstream fbin; - std::string exte=".hdr"; + std::string exte=".mhd"; std::string fnum; OStringStream buf; diff --git a/Utilities/ITK/Code/Algorithms/itkFFTComplexConjugateToRealImageFilter.h b/Utilities/ITK/Code/Algorithms/itkFFTComplexConjugateToRealImageFilter.h index d55fec15a2e8a40ad977ab8993b7f97e8d5b7aab..584a9e5bbddc50c8117d15cdd7a81f2e6af05ae4 100644 --- a/Utilities/ITK/Code/Algorithms/itkFFTComplexConjugateToRealImageFilter.h +++ b/Utilities/ITK/Code/Algorithms/itkFFTComplexConjugateToRealImageFilter.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkFFTComplexConjugateToRealImageFilter.h,v $ Language: C++ - Date: $Date: 2009-05-12 17:26:20 $ - Version: $Revision: 1.8 $ + Date: $Date: 2010-02-27 00:09:41 $ + Version: $Revision: 1.10 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -25,7 +25,7 @@ namespace itk { /** \class FFTComplexConjugateToRealImageFilter - * /brief + * \brief * * \ingroup */ @@ -84,6 +84,7 @@ public: protected: FFTComplexConjugateToRealImageFilter() : m_ActualXDimensionIsOdd(false) {} virtual ~FFTComplexConjugateToRealImageFilter(){} + void EnlargeOutputRequestedRegion(DataObject *itkNotUsed(output)); private: bool m_ActualXDimensionIsOdd; diff --git a/Utilities/ITK/Code/Algorithms/itkFFTComplexConjugateToRealImageFilter.txx b/Utilities/ITK/Code/Algorithms/itkFFTComplexConjugateToRealImageFilter.txx index f3e529d5168a3fadf29f1052ff50711485768929..199dd2c24d4b802f79f5af4f38f0f304befddc47 100644 --- a/Utilities/ITK/Code/Algorithms/itkFFTComplexConjugateToRealImageFilter.txx +++ b/Utilities/ITK/Code/Algorithms/itkFFTComplexConjugateToRealImageFilter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkFFTComplexConjugateToRealImageFilter.txx,v $ Language: C++ - Date: $Date: 2008-12-21 19:13:11 $ - Version: $Revision: 1.11 $ + Date: $Date: 2010-02-27 00:09:41 $ + Version: $Revision: 1.12 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -163,5 +163,14 @@ GenerateInputRequestedRegion() } } +template <class TPixel, unsigned int VDimension> +void +FFTComplexConjugateToRealImageFilter<TPixel,VDimension>:: +EnlargeOutputRequestedRegion(DataObject *) +{ + this->GetOutput() + ->SetRequestedRegion( this->GetOutput()->GetLargestPossibleRegion() ); +} + } #endif diff --git a/Utilities/ITK/Code/Algorithms/itkFFTWComplexConjugateToRealImageFilter.txx b/Utilities/ITK/Code/Algorithms/itkFFTWComplexConjugateToRealImageFilter.txx index 976012404e8634c335972c1c01fee4c26d8c45a2..53f443b8bd965015565805facac1c8f9b07a6ea6 100644 --- a/Utilities/ITK/Code/Algorithms/itkFFTWComplexConjugateToRealImageFilter.txx +++ b/Utilities/ITK/Code/Algorithms/itkFFTWComplexConjugateToRealImageFilter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkFFTWComplexConjugateToRealImageFilter.txx,v $ Language: C++ - Date: $Date: 2008-12-21 19:13:11 $ - Version: $Revision: 1.14 $ + Date: $Date: 2010-02-26 23:50:55 $ + Version: $Revision: 1.15 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -23,6 +23,7 @@ #include "itkIndent.h" #include "itkMetaDataObject.h" #include "itkImageRegionIterator.h" +#include "itkProgressReporter.h" namespace itk { @@ -41,6 +42,10 @@ GenerateData() return; } + // we don't have a nice progress to report, but at least this simple line + // reports the begining and the end of the process + ProgressReporter progress(this, 0, 1); + // allocate output buffer memory outputPtr->SetBufferedRegion( outputPtr->GetRequestedRegion() ); outputPtr->Allocate(); diff --git a/Utilities/ITK/Code/Algorithms/itkFFTWRealToComplexConjugateImageFilter.h b/Utilities/ITK/Code/Algorithms/itkFFTWRealToComplexConjugateImageFilter.h index 0ef60c3c145cc52b1f7cff39d994d110dae2045e..a84fb282d0be688d3c3d04b19f4fcc85728bbd59 100644 --- a/Utilities/ITK/Code/Algorithms/itkFFTWRealToComplexConjugateImageFilter.h +++ b/Utilities/ITK/Code/Algorithms/itkFFTWRealToComplexConjugateImageFilter.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkFFTWRealToComplexConjugateImageFilter.h,v $ Language: C++ - Date: $Date: 2008-12-21 19:13:11 $ - Version: $Revision: 1.11 $ + Date: $Date: 2010-02-26 05:28:24 $ + Version: $Revision: 1.12 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -24,7 +24,7 @@ namespace itk { /** \class FFTWRealToComplexConjugateImageFilter - * /brief + * \brief * * \ingroup */ diff --git a/Utilities/ITK/Code/Algorithms/itkFFTWRealToComplexConjugateImageFilter.txx b/Utilities/ITK/Code/Algorithms/itkFFTWRealToComplexConjugateImageFilter.txx index 59ce13a60b165a5223f3d2c23a79132e8c9bcd7c..c912ec020724b053b08b7a8fcae795525d0449e2 100644 --- a/Utilities/ITK/Code/Algorithms/itkFFTWRealToComplexConjugateImageFilter.txx +++ b/Utilities/ITK/Code/Algorithms/itkFFTWRealToComplexConjugateImageFilter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkFFTWRealToComplexConjugateImageFilter.txx,v $ Language: C++ - Date: $Date: 2008-12-21 19:13:11 $ - Version: $Revision: 1.12 $ + Date: $Date: 2010-02-26 23:50:55 $ + Version: $Revision: 1.13 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -22,6 +22,7 @@ #include <iostream> #include "itkIndent.h" #include "itkMetaDataObject.h" +#include "itkProgressReporter.h" namespace itk { @@ -44,6 +45,10 @@ GenerateData() return; } + // we don't have a nice progress to report, but at least this simple line + // reports the begining and the end of the process + ProgressReporter progress(this, 0, 1); + // allocate output buffer memory outputPtr->SetBufferedRegion( outputPtr->GetRequestedRegion() ); outputPtr->Allocate(); diff --git a/Utilities/ITK/Code/Algorithms/itkFastMarchingImageFilter.h b/Utilities/ITK/Code/Algorithms/itkFastMarchingImageFilter.h index 2f4f854878e753964df5447a83da3e12ab1b2263..13e53dcf7f268c6247de071132221e5bf9713d62 100644 --- a/Utilities/ITK/Code/Algorithms/itkFastMarchingImageFilter.h +++ b/Utilities/ITK/Code/Algorithms/itkFastMarchingImageFilter.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkFastMarchingImageFilter.h,v $ Language: C++ - Date: $Date: 2009-04-23 03:53:35 $ - Version: $Revision: 1.40 $ + Date: $Date: 2010-01-13 14:19:09 $ + Version: $Revision: 1.41 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -162,7 +162,7 @@ public: * away points; TrialPoints represent points within a narrowband of the * propagating front; and AlivePoints represent points which have already * been processed. */ - enum LabelType { FarPoint, AlivePoint, TrialPoint }; + enum LabelType { FarPoint, AlivePoint, TrialPoint, InitialTrialPoint }; /** LabelImage typedef support. */ typedef Image<unsigned char, itkGetStaticConstMacro(SetDimension)> LabelImageType; diff --git a/Utilities/ITK/Code/Algorithms/itkFastMarchingImageFilter.txx b/Utilities/ITK/Code/Algorithms/itkFastMarchingImageFilter.txx index 64900c7b11c51acdbf0cbb91914f523a98718c13..5d7a1ab816a15abce7afb807c5033f3260b81e05 100644 --- a/Utilities/ITK/Code/Algorithms/itkFastMarchingImageFilter.txx +++ b/Utilities/ITK/Code/Algorithms/itkFastMarchingImageFilter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkFastMarchingImageFilter.txx,v $ Language: C++ - Date: $Date: 2008-12-21 19:13:11 $ - Version: $Revision: 1.52 $ + Date: $Date: 2010-01-13 14:19:09 $ + Version: $Revision: 1.53 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -23,7 +23,6 @@ #include "vnl/vnl_math.h" #include <algorithm> - namespace itk { @@ -238,8 +237,13 @@ FastMarchingImageFilter<TLevelSet,TSpeedImage> continue; } +#ifdef ITK_USE_DEPRECATED_FAST_MARCHING // make this a trial point m_LabelImage->SetPixel( node.GetIndex(), TrialPoint ); +#else + // make this an initial trial point + m_LabelImage->SetPixel( node.GetIndex(), InitialTrialPoint ); +#endif outputPixel = node.GetValue(); output->SetPixel( node.GetIndex(), outputPixel ); @@ -289,7 +293,11 @@ FastMarchingImageFilter<TLevelSet,TSpeedImage> } // is this node already alive ? +#ifdef ITK_USE_DEPRECATED_FAST_MARCHING if ( m_LabelImage->GetPixel( node.GetIndex() ) != TrialPoint ) +#else + if ( m_LabelImage->GetPixel( node.GetIndex() ) == AlivePoint ) +#endif { continue; } @@ -349,7 +357,12 @@ FastMarchingImageFilter<TLevelSet,TSpeedImage> { neighIndex[j] = index[j] - 1; } +#ifdef ITK_USE_DEPRECATED_FAST_MARCHING if ( m_LabelImage->GetPixel( neighIndex ) != AlivePoint ) +#else + unsigned char label = m_LabelImage->GetPixel( neighIndex ); + if ( label != AlivePoint && label != InitialTrialPoint ) +#endif { this->UpdateValue( neighIndex, speedImage, output ); } @@ -359,7 +372,12 @@ FastMarchingImageFilter<TLevelSet,TSpeedImage> { neighIndex[j] = index[j] + 1; } +#ifdef ITK_USE_DEPRECATED_FAST_MARCHING if ( m_LabelImage->GetPixel( neighIndex ) != AlivePoint ) +#else + label = m_LabelImage->GetPixel( neighIndex ); + if ( label != AlivePoint && label != InitialTrialPoint ) +#endif { this->UpdateValue( neighIndex, speedImage, output ); } diff --git a/Utilities/ITK/Code/Algorithms/itkImagePCADecompositionCalculator.h b/Utilities/ITK/Code/Algorithms/itkImagePCADecompositionCalculator.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Algorithms/itkImagePCADecompositionCalculator.txx b/Utilities/ITK/Code/Algorithms/itkImagePCADecompositionCalculator.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Algorithms/itkIsolatedWatershedImageFilter.h b/Utilities/ITK/Code/Algorithms/itkIsolatedWatershedImageFilter.h index c8105689dd2850b0ab0450672247451e23ecc695..a451a8ace7446c5684c4c54f3bb42c033b109cfa 100644 --- a/Utilities/ITK/Code/Algorithms/itkIsolatedWatershedImageFilter.h +++ b/Utilities/ITK/Code/Algorithms/itkIsolatedWatershedImageFilter.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkIsolatedWatershedImageFilter.h,v $ Language: C++ - Date: $Date: 2009-04-23 03:53:35 $ - Version: $Revision: 1.5 $ + Date: $Date: 2010-02-26 05:28:24 $ + Version: $Revision: 1.6 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. diff --git a/Utilities/ITK/Code/Algorithms/itkKappaStatisticImageToImageMetric.h b/Utilities/ITK/Code/Algorithms/itkKappaStatisticImageToImageMetric.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Algorithms/itkKappaStatisticImageToImageMetric.txx b/Utilities/ITK/Code/Algorithms/itkKappaStatisticImageToImageMetric.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Algorithms/itkKullbackLeiblerCompareHistogramImageToImageMetric.h b/Utilities/ITK/Code/Algorithms/itkKullbackLeiblerCompareHistogramImageToImageMetric.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Algorithms/itkKullbackLeiblerCompareHistogramImageToImageMetric.txx b/Utilities/ITK/Code/Algorithms/itkKullbackLeiblerCompareHistogramImageToImageMetric.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Algorithms/itkLevelSetMotionRegistrationFilter.txx b/Utilities/ITK/Code/Algorithms/itkLevelSetMotionRegistrationFilter.txx index 83e1a49088c1825fc165cfe177426edb849410ef..387f16dc48f2a115363cfba5b7ef8b9a5eeb14ca 100644 --- a/Utilities/ITK/Code/Algorithms/itkLevelSetMotionRegistrationFilter.txx +++ b/Utilities/ITK/Code/Algorithms/itkLevelSetMotionRegistrationFilter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkLevelSetMotionRegistrationFilter.txx,v $ Language: C++ - Date: $Date: 2009-01-24 20:02:58 $ - Version: $Revision: 1.6 $ + Date: $Date: 2009-10-20 20:39:08 $ + Version: $Revision: 1.7 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -79,9 +79,11 @@ LevelSetMotionRegistrationFilter<TFixedImage,TMovingImage,TDeformationField> << "Could not cast difference function to LevelSetMotionRegistrationFunction" ); } - /* - * Smooth the deformation field - */ + drfp->SetUseImageSpacing( this->GetUseImageSpacing() ); + + // + // Smooth the deformation field + // if ( this->GetSmoothDeformationField() ) { this->SmoothDeformationField(); diff --git a/Utilities/ITK/Code/Algorithms/itkLevelSetMotionRegistrationFunction.h b/Utilities/ITK/Code/Algorithms/itkLevelSetMotionRegistrationFunction.h index 35ba59f4ca25cf13af1000bed2f7709707922550..5f58559e29669646a95b18d653218d04e44446a6 100644 --- a/Utilities/ITK/Code/Algorithms/itkLevelSetMotionRegistrationFunction.h +++ b/Utilities/ITK/Code/Algorithms/itkLevelSetMotionRegistrationFunction.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkLevelSetMotionRegistrationFunction.h,v $ Language: C++ - Date: $Date: 2009-01-24 20:02:58 $ - Version: $Revision: 1.4 $ + Date: $Date: 2009-10-20 20:39:08 $ + Version: $Revision: 1.5 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -193,7 +193,14 @@ FloatOffsetType(0.0)); * image prior to calculating gradients. */ virtual void SetGradientSmoothingStandardDeviations(double); virtual double GetGradientSmoothingStandardDeviations() const; - + + /** Use the image spacing information in calculations. Use this option if you + * want derivatives in physical space. Default is UseImageSpacing ON, due to a + * backward compatibility state. */ + void SetUseImageSpacing( bool); + bool GetUseImageSpacing() const; + + protected: LevelSetMotionRegistrationFunction(); ~LevelSetMotionRegistrationFunction() {} @@ -253,6 +260,7 @@ private: /** Mutex lock to protect modification to metric. */ mutable SimpleFastMutexLock m_MetricCalculationLock; + bool m_UseImageSpacing; }; diff --git a/Utilities/ITK/Code/Algorithms/itkLevelSetMotionRegistrationFunction.txx b/Utilities/ITK/Code/Algorithms/itkLevelSetMotionRegistrationFunction.txx index 360e84ac8b166917025d706838681f91046a1186..3c2919a1af1b94566884405a0a69a4932530d5d7 100644 --- a/Utilities/ITK/Code/Algorithms/itkLevelSetMotionRegistrationFunction.txx +++ b/Utilities/ITK/Code/Algorithms/itkLevelSetMotionRegistrationFunction.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkLevelSetMotionRegistrationFunction.txx,v $ Language: C++ - Date: $Date: 2009-01-24 20:02:58 $ - Version: $Revision: 1.6 $ + Date: $Date: 2009-10-20 20:39:08 $ + Version: $Revision: 1.7 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -57,6 +57,7 @@ LevelSetMotionRegistrationFunction<TFixedImage,TMovingImage,TDeformationField> m_NumberOfPixelsProcessed = 0L; m_RMSChange = NumericTraits<double>::max(); m_SumOfSquaredChange = 0.0; + m_UseImageSpacing = true; m_MovingImageSmoothingFilter = MovingImageSmoothingFilterType::New(); m_MovingImageSmoothingFilter @@ -192,6 +193,30 @@ LevelSetMotionRegistrationFunction<TFixedImage,TMovingImage,TDeformationField> return m_GradientSmoothingStandardDeviations; } +/** + * Return the flag that defines whether the image spacing should be taken into + * account in computations. + */ +template <class TFixedImage, class TMovingImage, class TDeformationField> +bool +LevelSetMotionRegistrationFunction<TFixedImage,TMovingImage,TDeformationField> +::GetUseImageSpacing() const +{ + return this->m_UseImageSpacing; +} + +/** + * Set the flag that defines whether the image spacing should be taken into + * account in computations. + */ +template <class TFixedImage, class TMovingImage, class TDeformationField> +void +LevelSetMotionRegistrationFunction<TFixedImage,TMovingImage,TDeformationField> +::SetUseImageSpacing( bool useImageSpacing ) +{ + this->m_UseImageSpacing = useImageSpacing; +} + /** * Set the function state values before each iteration */ @@ -272,7 +297,14 @@ LevelSetMotionRegistrationFunction<TFixedImage,TMovingImage,TDeformationField> // smooth image. Do we need to structure the gradient calculation to // take into account the Jacobian of the deformation field? i.e. in // which coordinate frame do we ultimately want the gradient vector? - const MovingSpacingType mSpacing = this->GetMovingImage()->GetSpacing(); + + MovingSpacingType mSpacing = this->GetMovingImage()->GetSpacing(); + + if( !this->m_UseImageSpacing ) + { + mSpacing.Fill( 1.0 ); + } + PointType mPoint( mappedPoint ); const double centralValue = m_SmoothMovingImageInterpolator->Evaluate( mPoint ); double forwardDifferences[ImageDimension]; @@ -367,7 +399,7 @@ LevelSetMotionRegistrationFunction<TFixedImage,TMovingImage,TDeformationField> // spacing. we will use this to calculate a timestep which // converts the update (measured in intensity) to a vector // measured in physical units (mm). - L1norm += (vnl_math_abs(update[j]) / this->GetMovingImage()->GetSpacing()[j]); + L1norm += (vnl_math_abs(update[j]) / mSpacing[j]); } } diff --git a/Utilities/ITK/Code/Algorithms/itkMRFImageFilter.txx b/Utilities/ITK/Code/Algorithms/itkMRFImageFilter.txx index 6455035abbb66fd6d999a4bb1fe3c121ab8773e3..d7a37e41029d0c2b4e98bce32dc79f3637ff1539 100644 --- a/Utilities/ITK/Code/Algorithms/itkMRFImageFilter.txx +++ b/Utilities/ITK/Code/Algorithms/itkMRFImageFilter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkMRFImageFilter.txx,v $ Language: C++ - Date: $Date: 2009-06-16 07:58:47 $ - Version: $Revision: 1.68 $ + Date: $Date: 2009-10-27 16:06:46 $ + Version: $Revision: 1.69 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -456,9 +456,8 @@ MRFImageFilter<TInputImage, TClassifiedImage> totalNumberOfPixelsInInputImage *= static_cast<int>(inputImageSize[ i ]); } - int maxNumPixelError = - static_cast<int>( Math::Round( m_ErrorTolerance * - m_TotalNumberOfValidPixelsInOutputImage) ); + int maxNumPixelError = Math::Round<int>( m_ErrorTolerance * + m_TotalNumberOfValidPixelsInOutputImage); m_NumberOfIterations = 0; do diff --git a/Utilities/ITK/Code/Algorithms/itkMattesMutualInformationImageToImageMetric.h b/Utilities/ITK/Code/Algorithms/itkMattesMutualInformationImageToImageMetric.h index cc89b32cc3ad926a5edab574aebea61e95423e1c..4544764b7f9c519ac181efbd35bf41816879b4f4 100644 --- a/Utilities/ITK/Code/Algorithms/itkMattesMutualInformationImageToImageMetric.h +++ b/Utilities/ITK/Code/Algorithms/itkMattesMutualInformationImageToImageMetric.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkMattesMutualInformationImageToImageMetric.h,v $ Language: C++ - Date: $Date: 2009-01-26 21:45:51 $ - Version: $Revision: 1.27 $ + Date: $Date: 2009-11-02 18:46:33 $ + Version: $Revision: 1.29 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -159,6 +159,7 @@ public: /** Index and Point typedef support. */ typedef typename FixedImageType::IndexType FixedImageIndexType; + typedef typename FixedImageType::OffsetValueType OffsetValueType; typedef typename FixedImageIndexType::IndexValueType FixedImageIndexValueType; typedef typename MovingImageType::IndexType MovingImageIndexType; typedef typename TransformType::InputPointType FixedImagePointType; @@ -194,9 +195,12 @@ public: 1, NumericTraits<unsigned long>::max() ); itkGetConstReferenceMacro( NumberOfSpatialSamples, unsigned long); - /** Number of bins to used in the histogram. Typical value is 50. */ + /** Number of bins to used in the histogram. Typical value is 50. The minimum + * value is 5 due to the padding required by the Parzen windowing with a + * cubic-BSpline kernel. Note that even if the metric is used on binary images, + * the number of bins should at least be equal to five. */ itkSetClampMacro( NumberOfHistogramBins, unsigned long, - 1, NumericTraits<unsigned long>::max() ); + 5, NumericTraits<unsigned long>::max() ); itkGetConstReferenceMacro( NumberOfHistogramBins, unsigned long); /** Reinitialize the seed of the random number generator that selects the diff --git a/Utilities/ITK/Code/Algorithms/itkMattesMutualInformationImageToImageMetric.txx b/Utilities/ITK/Code/Algorithms/itkMattesMutualInformationImageToImageMetric.txx index 86b9ecac48fd348e72adf938db3a2027a4545a3e..c968665cb29713e63ab9fc124c43159cd102c7d9 100644 --- a/Utilities/ITK/Code/Algorithms/itkMattesMutualInformationImageToImageMetric.txx +++ b/Utilities/ITK/Code/Algorithms/itkMattesMutualInformationImageToImageMetric.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkMattesMutualInformationImageToImageMetric.txx,v $ Language: C++ - Date: $Date: 2009-08-25 11:48:26 $ - Version: $Revision: 1.63 $ + Date: $Date: 2009-10-21 16:01:30 $ + Version: $Revision: 1.64 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -237,13 +237,14 @@ MattesMutualInformationImageToImageMetric<TFixedImage,TMovingImage> */ const int padding = 2; // this will pad by 2 bins - m_FixedImageBinSize = ( fixedImageMax - fixedImageMin ) / - static_cast<double>( m_NumberOfHistogramBins - 2 * padding ); + const double histogramWidth = + static_cast<double>( static_cast< OffsetValueType >( this->m_NumberOfHistogramBins ) - 2 * padding ); + + m_FixedImageBinSize = ( fixedImageMax - fixedImageMin ) / histogramWidth; m_FixedImageNormalizedMin = fixedImageMin / m_FixedImageBinSize - static_cast<double>( padding ); - m_MovingImageBinSize = ( movingImageMax - movingImageMin ) / - static_cast<double>( m_NumberOfHistogramBins - 2 * padding ); + m_MovingImageBinSize = ( movingImageMax - movingImageMin ) / histogramWidth; m_MovingImageNormalizedMin = movingImageMin / m_MovingImageBinSize - static_cast<double>( padding ); @@ -269,8 +270,8 @@ MattesMutualInformationImageToImageMetric<TFixedImage,TMovingImage> * Allocate memory for the marginal PDF and initialize values * to zero. The marginal PDFs are stored as std::vector. */ - m_FixedImageMarginalPDF.resize( m_NumberOfHistogramBins, 0.0 ); - m_MovingImageMarginalPDF.resize( m_NumberOfHistogramBins, 0.0 ); + m_FixedImageMarginalPDF.resize( this->m_NumberOfHistogramBins, 0.0 ); + m_MovingImageMarginalPDF.resize( this->m_NumberOfHistogramBins, 0.0 ); /** * Allocate memory for the joint PDF and joint PDF derivatives. @@ -667,16 +668,22 @@ MattesMutualInformationImageToImageMetric<TFixedImage,TMovingImage> double windowTerm = static_cast<double>( (*iter).FixedImageValue ) / m_FixedImageBinSize - m_FixedImageNormalizedMin; - unsigned int pindex = static_cast<unsigned int>( vcl_floor(windowTerm ) ); + + OffsetValueType pindex = static_cast< OffsetValueType >( vcl_floor(windowTerm ) ); // Make sure the extreme values are in valid bins if ( pindex < 2 ) { pindex = 2; } - else if ( pindex > (m_NumberOfHistogramBins - 3) ) + else { - pindex = m_NumberOfHistogramBins - 3; + const OffsetValueType nindex = + static_cast< OffsetValueType >( this->m_NumberOfHistogramBins ) - 3; + if ( pindex > nindex ) + { + pindex = nindex; + } } (*iter).FixedImageParzenWindowIndex = pindex; @@ -747,20 +754,25 @@ MattesMutualInformationImageToImageMetric<TFixedImage,TMovingImage> // Determine parzen window arguments (see eqn 6 of Mattes paper [2]) double movingImageParzenWindowTerm = movingImageValue / m_MovingImageBinSize - m_MovingImageNormalizedMin; - unsigned int movingImageParzenWindowIndex = - static_cast<unsigned int>( vcl_floor(movingImageParzenWindowTerm ) ); + + OffsetValueType movingImageParzenWindowIndex = + static_cast<OffsetValueType>( vcl_floor(movingImageParzenWindowTerm ) ); // Make sure the extreme values are in valid bins if ( movingImageParzenWindowIndex < 2 ) { movingImageParzenWindowIndex = 2; } - else if ( movingImageParzenWindowIndex > (m_NumberOfHistogramBins - 3) ) + else { - movingImageParzenWindowIndex = m_NumberOfHistogramBins - 3; + const OffsetValueType nindex = + static_cast< OffsetValueType >( this->m_NumberOfHistogramBins ) - 3; + if ( movingImageParzenWindowIndex > nindex ) + { + movingImageParzenWindowIndex = nindex; + } } - // Since a zero-order BSpline (box car) kernel is used for // the fixed image marginal pdf, we need only increment the // fixedImageParzenWindowIndex by value of 1.0. @@ -1027,7 +1039,8 @@ MattesMutualInformationImageToImageMetric<TFixedImage,TMovingImage> // Determine parzen window arguments (see eqn 6 of Mattes paper [2]) double movingImageParzenWindowTerm = movingImageValue / m_MovingImageBinSize - m_MovingImageNormalizedMin; - unsigned int movingImageParzenWindowIndex = + + OffsetValueType movingImageParzenWindowIndex = static_cast<unsigned int>( vcl_floor(movingImageParzenWindowTerm ) ); // Make sure the extreme values are in valid bins @@ -1035,9 +1048,14 @@ MattesMutualInformationImageToImageMetric<TFixedImage,TMovingImage> { movingImageParzenWindowIndex = 2; } - else if ( movingImageParzenWindowIndex > (m_NumberOfHistogramBins - 3) ) + else { - movingImageParzenWindowIndex = m_NumberOfHistogramBins - 3; + const OffsetValueType nindex = + static_cast< OffsetValueType >( this->m_NumberOfHistogramBins ) - 3; + if ( movingImageParzenWindowIndex > nindex ) + { + movingImageParzenWindowIndex = nindex; + } } @@ -1306,20 +1324,24 @@ MattesMutualInformationImageToImageMetric<TFixedImage,TMovingImage> // Determine parzen window arguments (see eqn 6 of Mattes paper [2]). double movingImageParzenWindowTerm = movingImageValue / m_MovingImageBinSize - m_MovingImageNormalizedMin; - unsigned int movingImageParzenWindowIndex = - static_cast<unsigned int>( vcl_floor(movingImageParzenWindowTerm ) ); + OffsetValueType movingImageParzenWindowIndex = + static_cast<OffsetValueType>( vcl_floor(movingImageParzenWindowTerm ) ); // Make sure the extreme values are in valid bins if ( movingImageParzenWindowIndex < 2 ) { movingImageParzenWindowIndex = 2; } - else if ( movingImageParzenWindowIndex > (m_NumberOfHistogramBins - 3) ) + else { - movingImageParzenWindowIndex = m_NumberOfHistogramBins - 3; + const OffsetValueType nindex = + static_cast< OffsetValueType >( this->m_NumberOfHistogramBins ) - 3; + if ( movingImageParzenWindowIndex > nindex ) + { + movingImageParzenWindowIndex = nindex; + } } - // Move the pointer to the fist affected bin int pdfMovingIndex = static_cast<int>( movingImageParzenWindowIndex ) - 1; diff --git a/Utilities/ITK/Code/Algorithms/itkMeanReciprocalSquareDifferenceImageToImageMetric.h b/Utilities/ITK/Code/Algorithms/itkMeanReciprocalSquareDifferenceImageToImageMetric.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Algorithms/itkMeanReciprocalSquareDifferenceImageToImageMetric.txx b/Utilities/ITK/Code/Algorithms/itkMeanReciprocalSquareDifferenceImageToImageMetric.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Algorithms/itkMeanReciprocalSquareDifferencePointSetToImageMetric.h b/Utilities/ITK/Code/Algorithms/itkMeanReciprocalSquareDifferencePointSetToImageMetric.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Algorithms/itkMeanReciprocalSquareDifferencePointSetToImageMetric.txx b/Utilities/ITK/Code/Algorithms/itkMeanReciprocalSquareDifferencePointSetToImageMetric.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Algorithms/itkMinMaxCurvatureFlowFunction.txx b/Utilities/ITK/Code/Algorithms/itkMinMaxCurvatureFlowFunction.txx index 24c567842295c18a0737eb2631318a00a5f6e62a..7afa966ceaa39110ca4b0518c97725ca78fefb38 100644 --- a/Utilities/ITK/Code/Algorithms/itkMinMaxCurvatureFlowFunction.txx +++ b/Utilities/ITK/Code/Algorithms/itkMinMaxCurvatureFlowFunction.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkMinMaxCurvatureFlowFunction.txx,v $ Language: C++ - Date: $Date: 2009-06-16 07:58:47 $ - Version: $Revision: 1.29 $ + Date: $Date: 2009-10-27 16:06:41 $ + Version: $Revision: 1.30 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -285,15 +285,15 @@ MinMaxCurvatureFlowFunction<TImage> // Compute first perpendicular point - position[0] = Math::Round( (double)(m_StencilRadius - gradient[1]) ); - position[1] = Math::Round( (double)(m_StencilRadius + gradient[0]) ); + position[0] = Math::Round<unsigned long>( (double)(m_StencilRadius - gradient[1]) ); + position[1] = Math::Round<unsigned long>( (double)(m_StencilRadius + gradient[0]) ); threshold = it.GetPixel( position[0] + stride * position[1] ); // Compute second perpendicular point - position[0] = Math::Round( (double)(m_StencilRadius + gradient[1]) ); - position[1] = Math::Round( (double)(m_StencilRadius - gradient[0]) ); + position[0] = Math::Round<unsigned long>( (double)(m_StencilRadius + gradient[1]) ); + position[1] = Math::Round<unsigned long>( (double)(m_StencilRadius - gradient[0]) ); threshold += it.GetPixel( position[0] + stride * position[1] ); @@ -393,32 +393,32 @@ MinMaxCurvatureFlowFunction<TImage> double rCosPhi = m_StencilRadius * cosPhi; // Point 1: angle = 0; - position[0] = Math::Round( m_StencilRadius + rCosThetaCosPhi ); - position[1] = Math::Round( m_StencilRadius + rCosThetaSinPhi ); - position[2] = Math::Round( m_StencilRadius - rSinTheta ); + position[0] = Math::Round<unsigned long>( m_StencilRadius + rCosThetaCosPhi ); + position[1] = Math::Round<unsigned long>( m_StencilRadius + rCosThetaSinPhi ); + position[2] = Math::Round<unsigned long>( m_StencilRadius - rSinTheta ); threshold += it.GetPixel( position[0] + strideY * position[1] + strideZ * position[2] ); // Point 2: angle = 90; - position[0] = Math::Round( m_StencilRadius - rSinPhi ); - position[1] = Math::Round( m_StencilRadius + rCosPhi ); + position[0] = Math::Round<unsigned long>( m_StencilRadius - rSinPhi ); + position[1] = Math::Round<unsigned long>( m_StencilRadius + rCosPhi ); position[2] = m_StencilRadius; threshold += it.GetPixel( position[0] + strideY * position[1] + strideZ * position[2] ); // Point 3: angle = 180; - position[0] = Math::Round( m_StencilRadius - rCosThetaCosPhi ); - position[1] = Math::Round( m_StencilRadius - rCosThetaSinPhi ); - position[2] = Math::Round( m_StencilRadius + rSinTheta ); + position[0] = Math::Round<unsigned long>( m_StencilRadius - rCosThetaCosPhi ); + position[1] = Math::Round<unsigned long>( m_StencilRadius - rCosThetaSinPhi ); + position[2] = Math::Round<unsigned long>( m_StencilRadius + rSinTheta ); threshold += it.GetPixel( position[0] + strideY * position[1] + strideZ * position[2] ); // Point 4: angle = 270; - position[0] = Math::Round( m_StencilRadius + rSinPhi ); - position[1] = Math::Round( m_StencilRadius - rCosPhi ); + position[0] = Math::Round<unsigned long>( m_StencilRadius + rSinPhi ); + position[1] = Math::Round<unsigned long>( m_StencilRadius - rCosPhi ); position[2] = m_StencilRadius; threshold += it.GetPixel( position[0] + diff --git a/Utilities/ITK/Code/Algorithms/itkOtsuMultipleThresholdsCalculator.h b/Utilities/ITK/Code/Algorithms/itkOtsuMultipleThresholdsCalculator.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Algorithms/itkOtsuMultipleThresholdsCalculator.txx b/Utilities/ITK/Code/Algorithms/itkOtsuMultipleThresholdsCalculator.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Algorithms/itkOtsuMultipleThresholdsImageFilter.h b/Utilities/ITK/Code/Algorithms/itkOtsuMultipleThresholdsImageFilter.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Algorithms/itkOtsuMultipleThresholdsImageFilter.txx b/Utilities/ITK/Code/Algorithms/itkOtsuMultipleThresholdsImageFilter.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Algorithms/itkPDEDeformableRegistrationFilter.h b/Utilities/ITK/Code/Algorithms/itkPDEDeformableRegistrationFilter.h index 50999fef177339a83e28ad3fed84bc863b8f2df0..d7762e8cc2c0e533fdeb135ac3ecd78a3799d5d9 100644 --- a/Utilities/ITK/Code/Algorithms/itkPDEDeformableRegistrationFilter.h +++ b/Utilities/ITK/Code/Algorithms/itkPDEDeformableRegistrationFilter.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkPDEDeformableRegistrationFilter.h,v $ Language: C++ - Date: $Date: 2009-04-23 03:53:36 $ - Version: $Revision: 1.25 $ + Date: $Date: 2009-10-19 15:18:52 $ + Version: $Revision: 1.26 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -128,7 +128,7 @@ public: const MovingImageType * GetMovingImage(void) const; /** Set initial deformation field. */ - void SetInitialDeformationField( DeformationFieldType * ptr ) + void SetInitialDeformationField( const DeformationFieldType * ptr ) { this->SetInput( ptr ); } /** Get output deformation field. */ diff --git a/Utilities/ITK/Code/Algorithms/itkPointSetToImageMetric.h b/Utilities/ITK/Code/Algorithms/itkPointSetToImageMetric.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Algorithms/itkPointSetToImageMetric.txx b/Utilities/ITK/Code/Algorithms/itkPointSetToImageMetric.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Algorithms/itkRegularSphereMeshSource.txx b/Utilities/ITK/Code/Algorithms/itkRegularSphereMeshSource.txx index 2e7d2d51b9e228b0ee304b1a05103a31e00b9171..407f3b3df410914ce8a30c94482cf4fbf1c28d11 100644 --- a/Utilities/ITK/Code/Algorithms/itkRegularSphereMeshSource.txx +++ b/Utilities/ITK/Code/Algorithms/itkRegularSphereMeshSource.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkRegularSphereMeshSource.txx,v $ Language: C++ - Date: $Date: 2009-04-08 23:03:40 $ - Version: $Revision: 1.16 $ + Date: $Date: 2009-09-17 11:04:02 $ + Version: $Revision: 1.17 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -297,6 +297,8 @@ RegularSphereMeshSource<TOutputMesh> // set output outputMesh->Graft(result); + + result->SetCells( NULL ); } } diff --git a/Utilities/ITK/Code/Algorithms/itkScalarImageKmeansImageFilter.h b/Utilities/ITK/Code/Algorithms/itkScalarImageKmeansImageFilter.h index abdd20926a3303dc818e5cbdd9e93f5f7929f8ed..d185c8fb4bb10e9e736082faf86f066ad22f91a4 100644 --- a/Utilities/ITK/Code/Algorithms/itkScalarImageKmeansImageFilter.h +++ b/Utilities/ITK/Code/Algorithms/itkScalarImageKmeansImageFilter.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkScalarImageKmeansImageFilter.h,v $ Language: C++ - Date: $Date: 2009-05-02 05:43:55 $ - Version: $Revision: 1.6 $ + Date: $Date: 2010-01-31 19:29:05 $ + Version: $Revision: 1.7 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -65,10 +65,10 @@ namespace itk * * \ingroup ClassificationFilters */ -template <class TInputImage > +template <class TInputImage, + class TOutputImage=Image<unsigned char, ::itk::GetImageDimension<TInputImage>::ImageDimension> > class ITK_EXPORT ScalarImageKmeansImageFilter : - public ImageToImageFilter< TInputImage, Image<unsigned char, - ::itk::GetImageDimension<TInputImage>::ImageDimension> > + public ImageToImageFilter< TInputImage, TOutputImage > { public: /** Extract dimension from input and output image. */ @@ -76,9 +76,8 @@ public: TInputImage::ImageDimension); /** Convenient typedefs for simplifying declarations. */ - typedef TInputImage InputImageType; - typedef Image<unsigned char, - ::itk::GetImageDimension<TInputImage>::ImageDimension> OutputImageType; + typedef TInputImage InputImageType; + typedef TOutputImage OutputImageType; /** Standard class typedefs. */ typedef ScalarImageKmeansImageFilter Self; diff --git a/Utilities/ITK/Code/Algorithms/itkScalarImageKmeansImageFilter.txx b/Utilities/ITK/Code/Algorithms/itkScalarImageKmeansImageFilter.txx index 56fb2bbaf3040bb7260ab1282db4813e7fa2485d..16ffcc40e35b51ee7acdccf040deb46f27282013 100644 --- a/Utilities/ITK/Code/Algorithms/itkScalarImageKmeansImageFilter.txx +++ b/Utilities/ITK/Code/Algorithms/itkScalarImageKmeansImageFilter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkScalarImageKmeansImageFilter.txx,v $ Language: C++ - Date: $Date: 2009-05-02 05:43:55 $ - Version: $Revision: 1.12 $ + Date: $Date: 2010-01-31 19:29:05 $ + Version: $Revision: 1.13 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -29,16 +29,16 @@ namespace itk { -template <class TInputImage> -ScalarImageKmeansImageFilter<TInputImage> +template <class TInputImage, class TOutputImage> +ScalarImageKmeansImageFilter<TInputImage, TOutputImage> ::ScalarImageKmeansImageFilter() { m_UseNonContiguousLabels = false; m_ImageRegionDefined = false; } -template <class TInputImage> -void ScalarImageKmeansImageFilter<TInputImage> +template <class TInputImage, class TOutputImage> +void ScalarImageKmeansImageFilter<TInputImage, TOutputImage> ::SetImageRegion( const ImageRegionType & region ) { m_ImageRegion = region; @@ -47,9 +47,9 @@ void ScalarImageKmeansImageFilter<TInputImage> -template< class TInputImage > +template< class TInputImage, class TOutputImage > void -ScalarImageKmeansImageFilter< TInputImage > +ScalarImageKmeansImageFilter< TInputImage, TOutputImage > ::GenerateData() { typename AdaptorType::Pointer adaptor = AdaptorType::New(); @@ -242,9 +242,9 @@ ScalarImageKmeansImageFilter< TInputImage > * Add a new class for the classifier. This requires to explicitly set the * initial mean value for that class. */ -template <class TInputImage > +template <class TInputImage, class TOutputImage > void -ScalarImageKmeansImageFilter<TInputImage > +ScalarImageKmeansImageFilter<TInputImage, TOutputImage > ::AddClassWithInitialMean( RealPixelType mean ) { this->m_InitialMeans.push_back( mean ); @@ -254,9 +254,9 @@ ScalarImageKmeansImageFilter<TInputImage > /** * Standard "PrintSelf" method */ -template <class TInputImage > +template <class TInputImage, class TOutputImage > void -ScalarImageKmeansImageFilter<TInputImage > +ScalarImageKmeansImageFilter<TInputImage, TOutputImage > ::PrintSelf( std::ostream& os, Indent indent) const diff --git a/Utilities/ITK/Code/Algorithms/itkSimplexMeshVolumeCalculator.h b/Utilities/ITK/Code/Algorithms/itkSimplexMeshVolumeCalculator.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Algorithms/itkSimplexMeshVolumeCalculator.txx b/Utilities/ITK/Code/Algorithms/itkSimplexMeshVolumeCalculator.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Algorithms/itkSymmetricForcesDemonsRegistrationFilter.h b/Utilities/ITK/Code/Algorithms/itkSymmetricForcesDemonsRegistrationFilter.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Algorithms/itkSymmetricForcesDemonsRegistrationFilter.txx b/Utilities/ITK/Code/Algorithms/itkSymmetricForcesDemonsRegistrationFilter.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Algorithms/itkSymmetricForcesDemonsRegistrationFunction.h b/Utilities/ITK/Code/Algorithms/itkSymmetricForcesDemonsRegistrationFunction.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Algorithms/itkSymmetricForcesDemonsRegistrationFunction.txx b/Utilities/ITK/Code/Algorithms/itkSymmetricForcesDemonsRegistrationFunction.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Algorithms/itkThresholdSegmentationLevelSetFunction.h b/Utilities/ITK/Code/Algorithms/itkThresholdSegmentationLevelSetFunction.h index fd3cd9968581d7166d96d15f9afca641e355e1e8..c02085fd55c0655f774d4bb7527846abfd643e6b 100644 --- a/Utilities/ITK/Code/Algorithms/itkThresholdSegmentationLevelSetFunction.h +++ b/Utilities/ITK/Code/Algorithms/itkThresholdSegmentationLevelSetFunction.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkThresholdSegmentationLevelSetFunction.h,v $ Language: C++ - Date: $Date: 2009-01-27 19:30:16 $ - Version: $Revision: 1.14 $ + Date: $Date: 2009-11-22 13:36:06 $ + Version: $Revision: 1.15 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -80,24 +80,24 @@ public: /** Set/Get threshold values */ void SetUpperThreshold(FeatureScalarType f) - { m_UpperThreshold = f; } + { m_UpperThreshold = f; } FeatureScalarType GetUpperThreshold() const - { return m_UpperThreshold; } + { return m_UpperThreshold; } void SetLowerThreshold(FeatureScalarType f) - { m_LowerThreshold = f; } + { m_LowerThreshold = f; } FeatureScalarType GetLowerThreshold() const - { return m_LowerThreshold; } + { return m_LowerThreshold; } virtual void CalculateSpeedImage(); virtual void Initialize(const RadiusType &r) - { + { Superclass::Initialize(r); this->SetAdvectionWeight( NumericTraits<ScalarValueType>::Zero); this->SetPropagationWeight(-1.0 * NumericTraits<ScalarValueType>::One); this->SetCurvatureWeight(NumericTraits<ScalarValueType>::One); - } + } /** Set/Get the weight applied to the edge (Laplacian) attractor in the speed * term function. Zero will turn this term off. */ diff --git a/Utilities/ITK/Code/Algorithms/itkVectorThresholdSegmentationLevelSetFunction.h b/Utilities/ITK/Code/Algorithms/itkVectorThresholdSegmentationLevelSetFunction.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Algorithms/itkVectorThresholdSegmentationLevelSetFunction.txx b/Utilities/ITK/Code/Algorithms/itkVectorThresholdSegmentationLevelSetFunction.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Algorithms/itkVectorThresholdSegmentationLevelSetImageFilter.h b/Utilities/ITK/Code/Algorithms/itkVectorThresholdSegmentationLevelSetImageFilter.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Algorithms/itkVectorThresholdSegmentationLevelSetImageFilter.txx b/Utilities/ITK/Code/Algorithms/itkVectorThresholdSegmentationLevelSetImageFilter.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Algorithms/itkVnlFFTComplexConjugateToRealImageFilter.txx b/Utilities/ITK/Code/Algorithms/itkVnlFFTComplexConjugateToRealImageFilter.txx index 5d548593eb743f18781003a2d02c24cd03e0fadb..d306d910b3ea181f6027db85b67f7717b8dd4846 100644 --- a/Utilities/ITK/Code/Algorithms/itkVnlFFTComplexConjugateToRealImageFilter.txx +++ b/Utilities/ITK/Code/Algorithms/itkVnlFFTComplexConjugateToRealImageFilter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkVnlFFTComplexConjugateToRealImageFilter.txx,v $ Language: C++ -Date: $Date: 2009-01-27 19:30:16 $ -Version: $Revision: 1.12 $ +Date: $Date: 2010-02-26 23:50:55 $ +Version: $Revision: 1.13 $ Copyright (c) 2002 Insight Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -23,6 +23,7 @@ PURPOSE. See the above copyright notices for more information. #include "vnl/algo/vnl_fft_1d.h" #include "vnl/algo/vnl_fft_2d.h" #include "vnl_fft_3d.h" +#include "itkProgressReporter.h" namespace itk { @@ -42,6 +43,10 @@ GenerateData() return; } + // we don't have a nice progress to report, but at least this simple line + // reports the begining and the end of the process + ProgressReporter progress(this, 0, 1); + const typename TInputImageType::SizeType& outputSize = outputPtr->GetLargestPossibleRegion().GetSize(); unsigned int num_dims = outputPtr->GetImageDimension(); diff --git a/Utilities/ITK/Code/Algorithms/itkVnlFFTRealToComplexConjugateImageFilter.txx b/Utilities/ITK/Code/Algorithms/itkVnlFFTRealToComplexConjugateImageFilter.txx index 9e16f36e8c83ce9c9ffd2d37418ccdf781970faf..cb538b7f6e72db553b43c502c5e9acd11a978efe 100644 --- a/Utilities/ITK/Code/Algorithms/itkVnlFFTRealToComplexConjugateImageFilter.txx +++ b/Utilities/ITK/Code/Algorithms/itkVnlFFTRealToComplexConjugateImageFilter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkVnlFFTRealToComplexConjugateImageFilter.txx,v $ Language: C++ -Date: $Date: 2009-01-27 19:30:16 $ -Version: $Revision: 1.12 $ +Date: $Date: 2010-02-26 23:50:55 $ +Version: $Revision: 1.13 $ Copyright (c) 2002 Insight Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -26,6 +26,7 @@ PURPOSE. See the above copyright notices for more information. #include "vnl/algo/vnl_fft_1d.h" #include "vnl/algo/vnl_fft_2d.h" #include "vnl_fft_3d.h" +#include "itkProgressReporter.h" namespace itk { @@ -72,6 +73,10 @@ GenerateData() return; } + // we don't have a nice progress to report, but at least this simple line + // reports the begining and the end of the process + ProgressReporter progress(this, 0, 1); + const typename Superclass::TInputImageType::SizeType& inputSize = inputPtr->GetLargestPossibleRegion().GetSize(); unsigned int num_dims = inputPtr->GetImageDimension(); diff --git a/Utilities/ITK/Code/Algorithms/itkVoronoiSegmentationImageFilterBase.h b/Utilities/ITK/Code/Algorithms/itkVoronoiSegmentationImageFilterBase.h index b91248636d8f39fd462f12bc3f9504246b95acc9..683dc4f38be04aa306e1f1b777bb921ae9f73aec 100644 --- a/Utilities/ITK/Code/Algorithms/itkVoronoiSegmentationImageFilterBase.h +++ b/Utilities/ITK/Code/Algorithms/itkVoronoiSegmentationImageFilterBase.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkVoronoiSegmentationImageFilterBase.h,v $ Language: C++ - Date: $Date: 2009-06-16 14:57:53 $ - Version: $Revision: 1.31 $ + Date: $Date: 2010-02-26 05:28:24 $ + Version: $Revision: 1.32 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -26,7 +26,7 @@ namespace itk { /** \class VoronoiSegmentationImageFilterBase - * /brief Base class for VoronoiSegmentationImageFilter + * \brief Base class for VoronoiSegmentationImageFilter * * Voronoi SegmentationImageFilter is a class of segmenation algorithms that * works on 2D image. diff --git a/Utilities/ITK/Code/Algorithms/itkWatershedMiniPipelineProgressCommand.cxx b/Utilities/ITK/Code/Algorithms/itkWatershedMiniPipelineProgressCommand.cxx index adddb850826943cac8ea00e8a9e92dbbebcaa20b..60da48915b8e87f14cf412160e8aa9d7e4b08c32 100644 --- a/Utilities/ITK/Code/Algorithms/itkWatershedMiniPipelineProgressCommand.cxx +++ b/Utilities/ITK/Code/Algorithms/itkWatershedMiniPipelineProgressCommand.cxx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkWatershedMiniPipelineProgressCommand.cxx,v $ Language: C++ - Date: $Date: 2009-05-12 20:21:46 $ - Version: $Revision: 1.5 $ + Date: $Date: 2009-11-28 16:23:24 $ + Version: $Revision: 1.6 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -27,9 +27,12 @@ void WatershedMiniPipelineProgressCommand if( typeid(event) == typeid ( ProgressEvent) ) { - m_Filter->UpdateProgress( (m_Count + po->GetProgress()) / - m_NumberOfFilters); - if (po->GetProgress() == 1.0) m_Count += 1.0; + m_Filter->UpdateProgress( + static_cast<float>( (m_Count + po->GetProgress()) / m_NumberOfFilters )); + if( po->GetProgress() == 1.0 ) + { + m_Count += 1.0; + } } } @@ -41,9 +44,12 @@ void WatershedMiniPipelineProgressCommand if( typeid(event) == typeid ( ProgressEvent) ) { - m_Filter->UpdateProgress( (m_Count + po->GetProgress()) / - m_NumberOfFilters); - if (po->GetProgress() == 1.0) m_Count += 1.0; + m_Filter->UpdateProgress( + static_cast<float>( (m_Count + po->GetProgress()) / m_NumberOfFilters) ); + if (po->GetProgress() == 1.0) + { + m_Count += 1.0; + } } } diff --git a/Utilities/ITK/Code/Algorithms/itkWatershedMiniPipelineProgressCommand.h b/Utilities/ITK/Code/Algorithms/itkWatershedMiniPipelineProgressCommand.h index 1b9fda251a41ead77f701ea8ecd821178c6c8638..52f94caac205108afc3414bf853fcbc6f233f135 100644 --- a/Utilities/ITK/Code/Algorithms/itkWatershedMiniPipelineProgressCommand.h +++ b/Utilities/ITK/Code/Algorithms/itkWatershedMiniPipelineProgressCommand.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkWatershedMiniPipelineProgressCommand.h,v $ Language: C++ - Date: $Date: 2009-05-12 20:21:46 $ - Version: $Revision: 1.7 $ + Date: $Date: 2009-11-28 16:23:24 $ + Version: $Revision: 1.8 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -59,8 +59,8 @@ public: itkGetConstMacro(NumberOfFilters, double); protected: - WatershedMiniPipelineProgressCommand() : m_Count(0.0), m_Filter(0), - m_NumberOfFilters(1) {} + WatershedMiniPipelineProgressCommand() : m_Count(0.0), m_Filter(NULL), + m_NumberOfFilters(1.0) {} virtual ~WatershedMiniPipelineProgressCommand() {} void PrintSelf(std::ostream& os, Indent indent) const; diff --git a/Utilities/ITK/Code/Algorithms/itkWatershedSegmentTreeGenerator.h b/Utilities/ITK/Code/Algorithms/itkWatershedSegmentTreeGenerator.h index ade8cb0c019465fa8cffbd19a7d7ad7af2d4c0a5..6a5b69eec2cea26d12439e2584286587c3c4c449 100644 --- a/Utilities/ITK/Code/Algorithms/itkWatershedSegmentTreeGenerator.h +++ b/Utilities/ITK/Code/Algorithms/itkWatershedSegmentTreeGenerator.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkWatershedSegmentTreeGenerator.h,v $ Language: C++ - Date: $Date: 2009-04-23 03:53:38 $ - Version: $Revision: 1.15 $ + Date: $Date: 2010-03-02 03:40:36 $ + Version: $Revision: 1.16 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -31,7 +31,7 @@ namespace watershed { /** - * \class WatershedSegmentTreeGenerator + * \class SegmentTreeGenerator * This filter is a process object class that implements a step in the N-d * watershed segmentation algorithm. It produces an ordered list (SegmentTree) * of binary merges between segments at increasing saliency levels. This diff --git a/Utilities/ITK/Code/Algorithms/itkWatershedSegmenter.h b/Utilities/ITK/Code/Algorithms/itkWatershedSegmenter.h index bca987fce01f0be109373eef4a7901c699fcb818..69a61d85f82c6fe466f488784e3f667fe2612196 100644 --- a/Utilities/ITK/Code/Algorithms/itkWatershedSegmenter.h +++ b/Utilities/ITK/Code/Algorithms/itkWatershedSegmenter.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkWatershedSegmenter.h,v $ Language: C++ - Date: $Date: 2009-04-23 03:53:38 $ - Version: $Revision: 1.19 $ + Date: $Date: 2010-03-02 03:40:36 $ + Version: $Revision: 1.20 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -31,7 +31,7 @@ namespace itk { namespace watershed { -/** \class WatershedSegmenter +/** \class Segmenter * * This filter implements the first step in the N-d watershed segmentation * algorithm. It produces a segmented, labeled image from a scalar-valued diff --git a/Utilities/ITK/Code/BasicFilters/CMakeLists.txt b/Utilities/ITK/Code/BasicFilters/CMakeLists.txt index 3ae43c396c2577eacc55e3796817c7606a18f1fe..6456c841d439b499e1540427397a09db966a8126 100644 --- a/Utilities/ITK/Code/BasicFilters/CMakeLists.txt +++ b/Utilities/ITK/Code/BasicFilters/CMakeLists.txt @@ -11,10 +11,17 @@ IF(NOT ITK_INSTALL_NO_LIBRARIES) ARCHIVE DESTINATION ${ITK_INSTALL_LIB_DIR_CM24} COMPONENT Development) ENDIF(NOT ITK_INSTALL_NO_LIBRARIES) +IF(ITK_USE_FLAT_DIRECTORY_INSTALL) + SET( ITK_INSTALL_INCLUDE_DIR_CM24_BASICFILTERS ${ITK_INSTALL_INCLUDE_DIR_CM24}) +ELSE(ITK_USE_FLAT_DIRECTORY_INSTALL) + SET( ITK_INSTALL_INCLUDE_DIR_CM24_BASICFILTERS ${ITK_INSTALL_INCLUDE_DIR_CM24}/BasicFilters) +ENDIF(ITK_USE_FLAT_DIRECTORY_INSTALL) + + IF(NOT ITK_INSTALL_NO_DEVELOPMENT) FILE(GLOB __files1 "${CMAKE_CURRENT_SOURCE_DIR}/*.h") FILE(GLOB __files2 "${CMAKE_CURRENT_SOURCE_DIR}/*.txx") INSTALL(FILES ${__files1} ${__files2} - DESTINATION ${ITK_INSTALL_INCLUDE_DIR_CM24}/BasicFilters + DESTINATION ${ITK_INSTALL_INCLUDE_DIR_CM24_BASICFILTERS} COMPONENT Development) ENDIF(NOT ITK_INSTALL_NO_DEVELOPMENT) diff --git a/Utilities/ITK/Code/BasicFilters/itkAbsImageFilter.h b/Utilities/ITK/Code/BasicFilters/itkAbsImageFilter.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/BasicFilters/itkAndImageFilter.h b/Utilities/ITK/Code/BasicFilters/itkAndImageFilter.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/BasicFilters/itkApproximateSignedDistanceMapImageFilter.h b/Utilities/ITK/Code/BasicFilters/itkApproximateSignedDistanceMapImageFilter.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/BasicFilters/itkApproximateSignedDistanceMapImageFilter.txx b/Utilities/ITK/Code/BasicFilters/itkApproximateSignedDistanceMapImageFilter.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/BasicFilters/itkBSplineDecompositionImageFilter.h b/Utilities/ITK/Code/BasicFilters/itkBSplineDecompositionImageFilter.h index 8a330387b5bf29bcc4f32714e865cbb8f99859bc..b07de2b79975cdbb4aac1c1ed3f5ff13d7bf7706 100644 --- a/Utilities/ITK/Code/BasicFilters/itkBSplineDecompositionImageFilter.h +++ b/Utilities/ITK/Code/BasicFilters/itkBSplineDecompositionImageFilter.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkBSplineDecompositionImageFilter.h,v $ Language: C++ - Date: $Date: 2009-04-25 12:27:05 $ - Version: $Revision: 1.11 $ + Date: $Date: 2010-03-19 07:06:01 $ + Version: $Revision: 1.12 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -104,16 +104,11 @@ public: /** Begin concept checking */ itkConceptMacro(DimensionCheck, (Concept::SameDimension<ImageDimension, OutputImageDimension>)); -// itkConceptMacro(InputConvertibleToDoubleCheck, -// (Concept::Convertible<typename TInputImage::PixelType, double>)); -// itkConceptMacro(OutputConvertibleToDoubleCheck, -// (Concept::Convertible<typename TOutputImage::PixelType, double>)); -// itkConceptMacro(InputConvertibleToOutputCheck, -// (Concept::Convertible<typename TInputImage::PixelType, -// typename TOutputImage::PixelType>)); -//FIXME probably need a fix in the OptBSplineInterpolateImageFilter - itkConceptMacro(DoubleConvertibleToOutputCheck, - (Concept::Convertible<double, typename TOutputImage::PixelType>)); +// itkConceptMacro(InputConvertibleToOutputCheck, +// (Concept::Convertible<typename TInputImage::PixelType, +// typename TOutputImage::PixelType>)); +// itkConceptMacro(DoubleConvertibleToOutputCheck, +// (Concept::Convertible<double, typename TOutputImage::PixelType>)); /** End concept checking */ #endif @@ -131,7 +126,7 @@ protected: void EnlargeOutputRequestedRegion( DataObject *output ); /** These are needed by the smoothing spline routine. */ - std::vector<CoeffType> m_Scratch; // temp storage for processing of Coefficients + std::vector<CoeffType> m_Scratch; // temp storage for processing of Coefficients typename TInputImage::SizeType m_DataLength; // Image size unsigned int m_SplineOrder; // User specified spline order (3rd or cubic is the default) diff --git a/Utilities/ITK/Code/BasicFilters/itkBSplineDecompositionImageFilter.txx b/Utilities/ITK/Code/BasicFilters/itkBSplineDecompositionImageFilter.txx index 6ba262ff0da4c88e172f2f6d1e367d2bacdceea1..136a7c1eddd5cf980a95da540ee1191eff82be26 100644 --- a/Utilities/ITK/Code/BasicFilters/itkBSplineDecompositionImageFilter.txx +++ b/Utilities/ITK/Code/BasicFilters/itkBSplineDecompositionImageFilter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkBSplineDecompositionImageFilter.txx,v $ Language: C++ - Date: $Date: 2009-04-05 23:09:19 $ - Version: $Revision: 1.13 $ + Date: $Date: 2010-03-19 07:06:01 $ + Version: $Revision: 1.14 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. diff --git a/Utilities/ITK/Code/BasicFilters/itkBSplineInterpolateImageFunction.txx b/Utilities/ITK/Code/BasicFilters/itkBSplineInterpolateImageFunction.txx index 0fb05dfd0f13718b19a27d9cb4b8d69c96753165..f8a6947d1af7a7bc89edb5f54ef312757eeff56c 100644 --- a/Utilities/ITK/Code/BasicFilters/itkBSplineInterpolateImageFunction.txx +++ b/Utilities/ITK/Code/BasicFilters/itkBSplineInterpolateImageFunction.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkBSplineInterpolateImageFunction.txx,v $ Language: C++ - Date: $Date: 2008-11-10 16:55:00 $ - Version: $Revision: 1.21 $ + Date: $Date: 2009-10-13 07:39:24 $ + Version: $Revision: 1.22 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -105,6 +105,7 @@ BSplineInterpolateImageFunction<TImageType,TCoordRep,TCoefficientType> } else { + m_CoefficientFilter->GetOutput()->DisconnectPipeline(); m_Coefficients = NULL; } } diff --git a/Utilities/ITK/Code/BasicFilters/itkBilateralImageFilter.txx b/Utilities/ITK/Code/BasicFilters/itkBilateralImageFilter.txx index 7c2b7009b8831b0d421a1a707ecfecff30fb00e9..a8c54b63820b3139b24d74e97beb9d86b0ec5f58 100644 --- a/Utilities/ITK/Code/BasicFilters/itkBilateralImageFilter.txx +++ b/Utilities/ITK/Code/BasicFilters/itkBilateralImageFilter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkBilateralImageFilter.txx,v $ Language: C++ - Date: $Date: 2009-08-07 15:27:48 $ - Version: $Revision: 1.32 $ + Date: $Date: 2009-10-27 16:06:37 $ + Version: $Revision: 1.33 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -305,7 +305,7 @@ BilateralImageFilter<TInputImage, TOutputImage> { // look up the range gaussian in a table tableArg = rangeDistance * distanceToTableIndex; - rangeGaussian = m_RangeGaussianTable[Math::Floor(tableArg)]; + rangeGaussian = m_RangeGaussianTable[Math::Floor<size_t>(tableArg)]; // normalization factor so filter integrates to one // (product of the domain and the range gaussian) diff --git a/Utilities/ITK/Code/BasicFilters/itkChangeLabelImageFilter.h b/Utilities/ITK/Code/BasicFilters/itkChangeLabelImageFilter.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/BasicFilters/itkChangeLabelImageFilter.txx b/Utilities/ITK/Code/BasicFilters/itkChangeLabelImageFilter.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/BasicFilters/itkContourDirectedMeanDistanceImageFilter.h b/Utilities/ITK/Code/BasicFilters/itkContourDirectedMeanDistanceImageFilter.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/BasicFilters/itkContourDirectedMeanDistanceImageFilter.txx b/Utilities/ITK/Code/BasicFilters/itkContourDirectedMeanDistanceImageFilter.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/BasicFilters/itkContourMeanDistanceImageFilter.h b/Utilities/ITK/Code/BasicFilters/itkContourMeanDistanceImageFilter.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/BasicFilters/itkContourMeanDistanceImageFilter.txx b/Utilities/ITK/Code/BasicFilters/itkContourMeanDistanceImageFilter.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/BasicFilters/itkDeformationFieldSource.h b/Utilities/ITK/Code/BasicFilters/itkDeformationFieldSource.h old mode 100644 new mode 100755 index 165f147a423ac36dc8a79bce67d24cd1febe3581..18b502d4efe03b0c384e964495022205c56047bb --- a/Utilities/ITK/Code/BasicFilters/itkDeformationFieldSource.h +++ b/Utilities/ITK/Code/BasicFilters/itkDeformationFieldSource.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkDeformationFieldSource.h,v $ Language: C++ - Date: $Date: 2008-10-14 19:20:33 $ - Version: $Revision: 1.5 $ + Date: $Date: 2009-11-21 21:21:56 $ + Version: $Revision: 1.6 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -94,6 +94,7 @@ public: /** Image spacing typedef */ typedef typename TOutputImage::SpacingType SpacingType; typedef typename TOutputImage::PointType OriginPointType; + typedef typename TOutputImage::DirectionType DirectionType; /** Set the coordinate transformation. * Set the KernelBase spline used for resampling the deformation grid. @@ -120,6 +121,10 @@ public: itkSetMacro(OutputOrigin, OriginPointType); virtual void SetOutputOrigin( const double* values); + /** Set the output direciton cosine matrix. */ + itkSetMacro( OutputDirection, DirectionType ); + itkGetConstReferenceMacro( OutputDirection, DirectionType ); + /** Get the output image origin. */ itkGetConstReferenceMacro( OutputOrigin, OriginPointType ); @@ -163,6 +168,7 @@ private: OutputImageRegionType m_OutputRegion; // Region of the output image SpacingType m_OutputSpacing; // output image spacing OriginPointType m_OutputOrigin; // output image origin + DirectionType m_OutputDirection; // output image direction cosines LandmarkContainerPointer m_SourceLandmarks; // List of source landmarks LandmarkContainerPointer m_TargetLandmarks; // List of target landmarks diff --git a/Utilities/ITK/Code/BasicFilters/itkDeformationFieldSource.txx b/Utilities/ITK/Code/BasicFilters/itkDeformationFieldSource.txx old mode 100644 new mode 100755 index af31e5b74ee0eb4260f4346f593429727a3cc64f..869f9db72a05a758e2adafe4c4511f9dc78ac456 --- a/Utilities/ITK/Code/BasicFilters/itkDeformationFieldSource.txx +++ b/Utilities/ITK/Code/BasicFilters/itkDeformationFieldSource.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkDeformationFieldSource.txx,v $ Language: C++ - Date: $Date: 2008-10-14 19:20:33 $ - Version: $Revision: 1.7 $ + Date: $Date: 2009-11-21 21:21:56 $ + Version: $Revision: 1.8 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -36,6 +36,7 @@ DeformationFieldSource<TOutputImage> { m_OutputSpacing.Fill(1.0); m_OutputOrigin.Fill(0.0); + m_OutputDirection.SetIdentity(); typedef ThinPlateSplineKernelTransform< double, @@ -61,6 +62,7 @@ DeformationFieldSource<TOutputImage> os << indent << "OutputRegion: " << m_OutputRegion << std::endl; os << indent << "OutputSpacing: " << m_OutputSpacing << std::endl; os << indent << "OutputOrigin: " << m_OutputOrigin << std::endl; + os << indent << "OutputDirection: " << m_OutputDirection << std::endl; os << indent << "KernelTransform: " << m_KernelTransform.GetPointer() << std::endl; os << indent << "Source Landmarks: " << m_SourceLandmarks.GetPointer() << std::endl; os << indent << "Target Landmarks: " << m_TargetLandmarks.GetPointer() << std::endl; @@ -221,6 +223,7 @@ DeformationFieldSource<TOutputImage> // Set spacing and origin outputPtr->SetSpacing( m_OutputSpacing ); outputPtr->SetOrigin( m_OutputOrigin ); + outputPtr->SetDirection( m_OutputDirection ); return; } diff --git a/Utilities/ITK/Code/BasicFilters/itkHoughTransform2DCirclesImageFilter.h b/Utilities/ITK/Code/BasicFilters/itkHoughTransform2DCirclesImageFilter.h index 66622fd47e8916a2a433b2ed86188f5fe1b68445..804dfe6ea3e9eb1792e7a89da4f4cbb99cef5e0b 100644 --- a/Utilities/ITK/Code/BasicFilters/itkHoughTransform2DCirclesImageFilter.h +++ b/Utilities/ITK/Code/BasicFilters/itkHoughTransform2DCirclesImageFilter.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkHoughTransform2DCirclesImageFilter.h,v $ Language: C++ - Date: $Date: 2009-04-25 12:27:26 $ - Version: $Revision: 1.13 $ + Date: $Date: 2010-02-03 18:53:41 $ + Version: $Revision: 1.14 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -163,9 +163,6 @@ protected: HoughTransform2DCirclesImageFilter(); virtual ~HoughTransform2DCirclesImageFilter() {}; - HoughTransform2DCirclesImageFilter(const Self&) {} - void operator=(const Self&) {} - void PrintSelf(std::ostream& os, Indent indent) const; /** HoughTransform2DCirclesImageFilter needs the entire input. Therefore @@ -181,6 +178,9 @@ protected: private: + HoughTransform2DCirclesImageFilter(const Self&); + void operator=(const Self&); + float m_SweepAngle; double m_MinimumRadius; double m_MaximumRadius; diff --git a/Utilities/ITK/Code/BasicFilters/itkHoughTransform2DLinesImageFilter.h b/Utilities/ITK/Code/BasicFilters/itkHoughTransform2DLinesImageFilter.h index 062a2fa9b2b405b338c30a9b95e07bbe4e981737..e406cf449aaaea0caff5738e2845b89eb81e2278 100644 --- a/Utilities/ITK/Code/BasicFilters/itkHoughTransform2DLinesImageFilter.h +++ b/Utilities/ITK/Code/BasicFilters/itkHoughTransform2DLinesImageFilter.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkHoughTransform2DLinesImageFilter.h,v $ Language: C++ - Date: $Date: 2009-04-25 12:27:26 $ - Version: $Revision: 1.11 $ + Date: $Date: 2010-02-03 18:53:41 $ + Version: $Revision: 1.12 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -159,9 +159,6 @@ protected: HoughTransform2DLinesImageFilter(); virtual ~HoughTransform2DLinesImageFilter() {}; - HoughTransform2DLinesImageFilter(const Self&) {} - void operator=(const Self&) {} - void PrintSelf(std::ostream& os, Indent indent) const; /** HoughTransform2DLinesImageFilter needs the entire input. Therefore @@ -182,6 +179,9 @@ protected: private: + HoughTransform2DLinesImageFilter(const Self&); + void operator=(const Self&); + float m_AngleResolution; float m_Threshold; OutputImagePointer m_SimplifyAccumulator; diff --git a/Utilities/ITK/Code/BasicFilters/itkIntensityWindowingImageFilter.h b/Utilities/ITK/Code/BasicFilters/itkIntensityWindowingImageFilter.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/BasicFilters/itkIntensityWindowingImageFilter.txx b/Utilities/ITK/Code/BasicFilters/itkIntensityWindowingImageFilter.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/BasicFilters/itkInteriorExteriorMeshFilter.txx b/Utilities/ITK/Code/BasicFilters/itkInteriorExteriorMeshFilter.txx index 0c17b83503c673cde6535ee608fe81444869c89c..5ec59b6628585cc93c9b808f8e885705af6c6f69 100644 --- a/Utilities/ITK/Code/BasicFilters/itkInteriorExteriorMeshFilter.txx +++ b/Utilities/ITK/Code/BasicFilters/itkInteriorExteriorMeshFilter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkInteriorExteriorMeshFilter.txx,v $ Language: C++ - Date: $Date: 2008-10-16 16:45:10 $ - Version: $Revision: 1.12 $ + Date: $Date: 2009-09-17 11:14:56 $ + Version: $Revision: 1.13 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -65,17 +65,17 @@ InteriorExteriorMeshFilter<TInputMesh,TOutputMesh,TSpatialFunction> typedef typename TInputMesh::PointsContainer InputPointsContainer; typedef typename TOutputMesh::PointsContainer OutputPointsContainer; - typedef typename TInputMesh::PointsContainerPointer InputPointsContainerPointer; + typedef typename TInputMesh::PointsContainerConstPointer InputPointsContainerConstPointer; typedef typename TOutputMesh::PointsContainerPointer OutputPointsContainerPointer; typedef typename TInputMesh::PointDataContainer InputPointDataContainer; typedef typename TOutputMesh::PointDataContainer OutputPointDataContainer; - typedef typename TInputMesh::PointDataContainerPointer InputPointDataContainerPointer; + typedef typename TInputMesh::PointDataContainerConstPointer InputPointDataContainerConstPointer; typedef typename TOutputMesh::PointDataContainerPointer OutputPointDataContainerPointer; - InputMeshPointer inputMesh = this->GetInput(); - OutputMeshPointer outputMesh = this->GetOutput(); + const InputMeshType * inputMesh = this->GetInput(); + OutputMeshPointer outputMesh = this->GetOutput(); if( !inputMesh ) { @@ -95,8 +95,8 @@ InteriorExteriorMeshFilter<TInputMesh,TOutputMesh,TSpatialFunction> outputMesh->SetBufferedRegion( outputMesh->GetRequestedRegion() ); - InputPointsContainerPointer inPoints = inputMesh->GetPoints(); - InputPointDataContainerPointer inData = inputMesh->GetPointData(); + InputPointsContainerConstPointer inPoints = inputMesh->GetPoints(); + InputPointDataContainerConstPointer inData = inputMesh->GetPointData(); typename InputPointsContainer::ConstIterator inputPoint = inPoints->Begin(); typename InputPointDataContainer::ConstIterator inputData; @@ -143,11 +143,10 @@ InteriorExteriorMeshFilter<TInputMesh,TOutputMesh,TSpatialFunction> } // Create duplicate references to the rest of data in the mesh - outputMesh->SetCellLinks( inputMesh->GetCellLinks() ); - - outputMesh->SetCells( inputMesh->GetCells() ); - outputMesh->SetCellData( inputMesh->GetCellData() ); - + this->CopyInputMeshToOutputMeshCellLinks(); + this->CopyInputMeshToOutputMeshCells(); + this->CopyInputMeshToOutputMeshCellData(); + unsigned int maxDimension = TInputMesh::MaxTopologicalDimension; for( unsigned int dim = 0; dim < maxDimension; dim++ ) diff --git a/Utilities/ITK/Code/BasicFilters/itkInverseDeformationFieldImageFilter.h b/Utilities/ITK/Code/BasicFilters/itkInverseDeformationFieldImageFilter.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/BasicFilters/itkInverseDeformationFieldImageFilter.txx b/Utilities/ITK/Code/BasicFilters/itkInverseDeformationFieldImageFilter.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/BasicFilters/itkIterativeInverseDeformationFieldImageFilter.h b/Utilities/ITK/Code/BasicFilters/itkIterativeInverseDeformationFieldImageFilter.h old mode 100644 new mode 100755 index 1c21911ccfe4244a8cdf3237ce1d92f127730fb9..8ffe5a0481478dc2204c5bc53c2c2830128e2ee8 --- a/Utilities/ITK/Code/BasicFilters/itkIterativeInverseDeformationFieldImageFilter.h +++ b/Utilities/ITK/Code/BasicFilters/itkIterativeInverseDeformationFieldImageFilter.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkIterativeInverseDeformationFieldImageFilter.h,v $ Language: C++ - Date: $Date: 2009-04-25 12:27:27 $ - Version: $Revision: 1.8 $ + Date: $Date: 2010-01-20 21:08:48 $ + Version: $Revision: 1.9 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -103,8 +103,6 @@ public: itkSetMacro(StopValue, double); itkGetConstMacro(StopValue, double); - char* GetReport() {return this->m_Report;} - #ifdef ITK_USE_CONCEPT_CHECKING /** Begin concept checking */ itkConceptMacro(OutputHasNumericTraitsCheck, @@ -117,7 +115,6 @@ protected: ~IterativeInverseDeformationFieldImageFilter() {} void PrintSelf(std::ostream& os, Indent indent) const; - void MakeReport(); void GenerateData( ); diff --git a/Utilities/ITK/Code/BasicFilters/itkIterativeInverseDeformationFieldImageFilter.txx b/Utilities/ITK/Code/BasicFilters/itkIterativeInverseDeformationFieldImageFilter.txx old mode 100644 new mode 100755 index 0f7e103243d31b7f576697ab79db07cb991fef03..56945b071c4488328b2194c0fa8a5802970f9589 --- a/Utilities/ITK/Code/BasicFilters/itkIterativeInverseDeformationFieldImageFilter.txx +++ b/Utilities/ITK/Code/BasicFilters/itkIterativeInverseDeformationFieldImageFilter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkIterativeInverseDeformationFieldImageFilter.txx,v $ Language: C++ - Date: $Date: 2008-11-07 19:39:44 $ - Version: $Revision: 1.10 $ + Date: $Date: 2010-02-15 15:18:46 $ + Version: $Revision: 1.11 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -118,7 +118,6 @@ void IterativeInverseDeformationFieldImageFilter<TInputImage, TOutputImage> } ProgressReporter progress(this, 0, - m_NumberOfIterations * inputPtr->GetLargestPossibleRegion().GetNumberOfPixels()); OutputIterator OutputIt = OutputIterator(outputPtr, outputPtr->GetRequestedRegion()); FieldInterpolatorPointer inputFieldInterpolator = FieldInterpolatorType::New(); diff --git a/Utilities/ITK/Code/BasicFilters/itkLabelStatisticsImageFilter.h b/Utilities/ITK/Code/BasicFilters/itkLabelStatisticsImageFilter.h index 35d037b08f87dc4d431bbe5459a5924f62719081..2e273acf1836b2cdaeb15b0214f66751c42b9332 100644 --- a/Utilities/ITK/Code/BasicFilters/itkLabelStatisticsImageFilter.h +++ b/Utilities/ITK/Code/BasicFilters/itkLabelStatisticsImageFilter.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkLabelStatisticsImageFilter.h,v $ Language: C++ - Date: $Date: 2009-05-05 18:16:17 $ - Version: $Revision: 1.13 $ + Date: $Date: 2010-02-05 18:18:37 $ + Version: $Revision: 1.14 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -238,14 +238,14 @@ public: itkBooleanMacro(UseHistograms); /** Set the label image */ - void SetLabelInput(TLabelImage *input) + void SetLabelInput(const TLabelImage *input) { // Process object is not const-correct so the const casting is required. this->SetNthInput(1, const_cast<TLabelImage *>(input) ); } /** Get the label image */ - LabelImageType * GetLabelInput() + const LabelImageType * GetLabelInput() const { return static_cast<LabelImageType*>(const_cast<DataObject *>(this->ProcessObject::GetInput(1))); } diff --git a/Utilities/ITK/Code/BasicFilters/itkMatrixIndexSelectionImageFilter.h b/Utilities/ITK/Code/BasicFilters/itkMatrixIndexSelectionImageFilter.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/BasicFilters/itkNaryMaximumImageFilter.h b/Utilities/ITK/Code/BasicFilters/itkNaryMaximumImageFilter.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/BasicFilters/itkOrImageFilter.h b/Utilities/ITK/Code/BasicFilters/itkOrImageFilter.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/BasicFilters/itkParallelSparseFieldLevelSetImageFilter.txx b/Utilities/ITK/Code/BasicFilters/itkParallelSparseFieldLevelSetImageFilter.txx index efcc6f0445dd3f5ea3e2e689acad437042b74d9a..0011ea6728fbc54a3b0a211513cfc74033e588b1 100644 --- a/Utilities/ITK/Code/BasicFilters/itkParallelSparseFieldLevelSetImageFilter.txx +++ b/Utilities/ITK/Code/BasicFilters/itkParallelSparseFieldLevelSetImageFilter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkParallelSparseFieldLevelSetImageFilter.txx,v $ Language: C++ - Date: $Date: 2008-10-17 16:30:48 $ - Version: $Revision: 1.43 $ + Date: $Date: 2009-09-30 16:07:13 $ + Version: $Revision: 1.44 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -1198,6 +1198,7 @@ ParallelSparseFieldLevelSetImageFilter<TInputImage, TOutputImage> // Create the temporary output image str->Filter->m_OutputImageTemp = OutputImageType::New(); + str->Filter->m_OutputImageTemp->CopyInformation(str->Filter->m_OutputImage); str->Filter->m_OutputImageTemp->SetRegions(str->Filter->m_OutputImage->GetRequestedRegion()); str->Filter->m_OutputImageTemp->Allocate(); } @@ -2636,7 +2637,8 @@ ParallelSparseFieldLevelSetImageFilter<TInputImage, TOutputImage> Superclass::PrintSelf(os, indent); unsigned int i; - os << indent << "m_IsoSurfaceValue: " << m_IsoSurfaceValue << std::endl; + os << indent << "m_NumberOfLayers: " << NumericTraits<StatusType>::PrintType(this->GetNumberOfLayers()) << std::endl; + os << indent << "m_IsoSurfaceValue: " << this->GetIsoSurfaceValue() << std::endl; os << indent << "m_LayerNodeStore: " << m_LayerNodeStore; unsigned int ThreadId; for (ThreadId=0; ThreadId < m_NumOfThreads; ThreadId++) diff --git a/Utilities/ITK/Code/BasicFilters/itkParametricSpaceToImageSpaceMeshFilter.txx b/Utilities/ITK/Code/BasicFilters/itkParametricSpaceToImageSpaceMeshFilter.txx index a5a35e641a77ea5f62d3f607384f40d9f698afd2..710402228dada2c9bbcae144bf906e33440b49b8 100644 --- a/Utilities/ITK/Code/BasicFilters/itkParametricSpaceToImageSpaceMeshFilter.txx +++ b/Utilities/ITK/Code/BasicFilters/itkParametricSpaceToImageSpaceMeshFilter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkParametricSpaceToImageSpaceMeshFilter.txx,v $ Language: C++ - Date: $Date: 2008-10-17 16:30:48 $ - Version: $Revision: 1.11 $ + Date: $Date: 2009-09-17 11:14:56 $ + Version: $Revision: 1.12 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -68,7 +68,7 @@ ParametricSpaceToImageSpaceMeshFilter<TInputMesh,TOutputMesh> typedef typename TInputMesh::PointDataContainerPointer InputPointDataContainerPointer; typedef typename TOutputMesh::PointDataContainerPointer OutputPointDataContainerPointer; - InputMeshPointer inputMesh = this->GetInput(); + const InputMeshType * inputMesh = this->GetInput(); OutputMeshPointer outputMesh = this->GetOutput(); if( !inputMesh ) @@ -83,12 +83,12 @@ ParametricSpaceToImageSpaceMeshFilter<TInputMesh,TOutputMesh> outputMesh->SetBufferedRegion( outputMesh->GetRequestedRegion() ); - InputPointsContainerPointer inPoints = inputMesh->GetPoints(); + const InputPointsContainer * inPoints = inputMesh->GetPoints(); OutputPointsContainerPointer outPoints = OutputPointsContainer::New(); outPoints->Reserve( inputMesh->GetNumberOfPoints() ); - InputPointDataContainerPointer inData = inputMesh->GetPointData(); + const InputPointDataContainer * inData = inputMesh->GetPointData(); OutputPointDataContainerPointer outData = OutputPointDataContainer::New(); outData->Reserve( inputMesh->GetNumberOfPoints() ); diff --git a/Utilities/ITK/Code/BasicFilters/itkPolylineMask2DImageFilter.h b/Utilities/ITK/Code/BasicFilters/itkPolylineMask2DImageFilter.h index 54688942a92786ae3f0f11c0b3a54c0cf6b4125b..d45632dad7c82e1dccd1200f83c30cacb880c3e1 100644 --- a/Utilities/ITK/Code/BasicFilters/itkPolylineMask2DImageFilter.h +++ b/Utilities/ITK/Code/BasicFilters/itkPolylineMask2DImageFilter.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkPolylineMask2DImageFilter.h,v $ Language: C++ - Date: $Date: 2008-01-20 18:00:40 $ - Version: $Revision: 1.7 $ + Date: $Date: 2010-01-20 23:54:11 $ + Version: $Revision: 1.8 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -34,6 +34,11 @@ namespace itk * value of pixels outside the masked region will be set to zero. * * \warning The Polygon represented by the input Polyline must be a convex polygon. + * \warning The Polygon's inside is defined by the standard clock-wise + * convention. That is, when walking along the polygon, the inside of the + * polygon is at the right-hand side. Note also that this must be interpreted + * in the natural coordinate system used by ITK, not the one used in computer + * graphics. * * \ingroup ImageToImageFilter * \sa PolylineMaskImageFilter diff --git a/Utilities/ITK/Code/BasicFilters/itkRGBToLuminanceImageFilter.h b/Utilities/ITK/Code/BasicFilters/itkRGBToLuminanceImageFilter.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/BasicFilters/itkRescaleIntensityImageFilter.h b/Utilities/ITK/Code/BasicFilters/itkRescaleIntensityImageFilter.h index 24be9164c9cac79922cf31dc9bc1ae5c6d962cea..b6b6501b52d4250597c79c44062266477b41b576 100644 --- a/Utilities/ITK/Code/BasicFilters/itkRescaleIntensityImageFilter.h +++ b/Utilities/ITK/Code/BasicFilters/itkRescaleIntensityImageFilter.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkRescaleIntensityImageFilter.h,v $ Language: C++ - Date: $Date: 2009-04-01 14:36:31 $ - Version: $Revision: 1.17 $ + Date: $Date: 2010-01-25 23:37:03 $ + Version: $Revision: 1.18 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -85,6 +85,14 @@ private: * is defined by the user in terms of the minimum and maximum values that * the output image should have. * + * The following equation gives the mapping of the intensity values + * + * \par + * \f[ + * \[ outputPixel = ( inputPixel - inputMin) \times + * \frac{(outputMax - outputMin )}{(inputMax - inputMin)} + outputMin \] + * \f] + * * All computations are performed in the precison of the input pixel's * RealType. Before assigning the computed value to the output pixel. * @@ -93,7 +101,7 @@ private: * supposed to set those values in this filter. If you need a filter where you * can set the minimum and maximum values of the input, please use the * IntensityWindowingImageFilter. If you want a filter that can use a - * user-defined linear transformation for the intensity, then please use teh + * user-defined linear transformation for the intensity, then please use the * ShiftScaleImageFilter. * * \sa IntensityWindowingImageFilter diff --git a/Utilities/ITK/Code/BasicFilters/itkScalarToArrayCastImageFilter.h b/Utilities/ITK/Code/BasicFilters/itkScalarToArrayCastImageFilter.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/BasicFilters/itkSimpleContourExtractorImageFilter.h b/Utilities/ITK/Code/BasicFilters/itkSimpleContourExtractorImageFilter.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/BasicFilters/itkSimpleContourExtractorImageFilter.txx b/Utilities/ITK/Code/BasicFilters/itkSimpleContourExtractorImageFilter.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/BasicFilters/itkSimplexMeshAdaptTopologyFilter.txx b/Utilities/ITK/Code/BasicFilters/itkSimplexMeshAdaptTopologyFilter.txx index f49068332569d58edbf522317a232c7ec389495d..eaf77d342bacccd818d5a13c6d22fdd49c00e10c 100644 --- a/Utilities/ITK/Code/BasicFilters/itkSimplexMeshAdaptTopologyFilter.txx +++ b/Utilities/ITK/Code/BasicFilters/itkSimplexMeshAdaptTopologyFilter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkSimplexMeshAdaptTopologyFilter.txx,v $ Language: C++ - Date: $Date: 2009-06-14 19:55:37 $ - Version: $Revision: 1.18 $ + Date: $Date: 2009-09-17 11:14:56 $ + Version: $Revision: 1.19 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -49,7 +49,7 @@ void SimplexMeshAdaptTopologyFilter<TInputMesh, TOutputMesh> { this->Initialize(); this->ComputeCellParameters(); - InsertNewCells(); + this->InsertNewCells(); } // @@ -64,13 +64,17 @@ template <typename TInputMesh, typename TOutputMesh> void SimplexMeshAdaptTopologyFilter<TInputMesh, TOutputMesh> ::ComputeCellParameters() { - InputMeshPointer inputMesh = this->GetInput(0); + const InputMeshType * inputMesh = this->GetInput(0); + + // A filter shouldn't modify its input. + // There is a design flaw here... + InputMeshType * nonConstInput = const_cast< InputMeshType * >( inputMesh ); // Ensure that cells will be deallocated by the Mesh. - inputMesh->SetCellsAllocationMethod( TInputMesh::CellsAllocatedDynamicallyCellByCell ); + nonConstInput->SetCellsAllocationMethod( TInputMesh::CellsAllocatedDynamicallyCellByCell ); SimplexVisitorInterfacePointer simplexVisitor = SimplexVisitorInterfaceType::New(); - simplexVisitor->mesh = inputMesh; + simplexVisitor->mesh = nonConstInput; CellMultiVisitorPointer mv = CellMultiVisitorType::New(); mv->AddVisitor(simplexVisitor); this->GetInput(0)->Accept(mv); @@ -158,11 +162,11 @@ void SimplexMeshAdaptTopologyFilter<TInputMesh, TOutputMesh> newMidPoint.SetToMidPoint( helperPoint, cellCenter ); - inputMesh->SetPoint( firstNewIndex , newMidPoint); - inputMesh->SetGeometryData( firstNewIndex , new itk::SimplexMeshGeometry() ); + nonConstInput->SetPoint( firstNewIndex , newMidPoint); + nonConstInput->SetGeometryData( firstNewIndex , new itk::SimplexMeshGeometry() ); - inputMesh->ReplaceNeighbor( lineOneFirstIdx, lineOneSecondIdx, firstNewIndex); - inputMesh->ReplaceNeighbor( lineOneSecondIdx, lineOneFirstIdx, firstNewIndex); + nonConstInput->ReplaceNeighbor( lineOneFirstIdx, lineOneSecondIdx, firstNewIndex); + nonConstInput->ReplaceNeighbor( lineOneSecondIdx, lineOneFirstIdx, firstNewIndex); //create second new point @@ -172,19 +176,19 @@ void SimplexMeshAdaptTopologyFilter<TInputMesh, TOutputMesh> helperPoint.SetToMidPoint(p1,p2); newMidPoint.SetToMidPoint( helperPoint, cellCenter ); - inputMesh->SetPoint( secondNewIndex , newMidPoint ); - inputMesh->SetGeometryData( secondNewIndex , new itk::SimplexMeshGeometry() ); + nonConstInput->SetPoint( secondNewIndex , newMidPoint ); + nonConstInput->SetGeometryData( secondNewIndex , new itk::SimplexMeshGeometry() ); - inputMesh->ReplaceNeighbor( lineTwoFirstIdx, lineTwoSecondIdx, secondNewIndex); - inputMesh->ReplaceNeighbor( lineTwoSecondIdx, lineTwoFirstIdx, secondNewIndex); + nonConstInput->ReplaceNeighbor( lineTwoFirstIdx, lineTwoSecondIdx, secondNewIndex); + nonConstInput->ReplaceNeighbor( lineTwoSecondIdx, lineTwoFirstIdx, secondNewIndex); - inputMesh->AddNeighbor(firstNewIndex, secondNewIndex); - inputMesh->AddNeighbor(firstNewIndex, lineOneFirstIdx); - inputMesh->AddNeighbor(firstNewIndex, lineOneSecondIdx); + nonConstInput->AddNeighbor(firstNewIndex, secondNewIndex); + nonConstInput->AddNeighbor(firstNewIndex, lineOneFirstIdx); + nonConstInput->AddNeighbor(firstNewIndex, lineOneSecondIdx); - inputMesh->AddNeighbor(secondNewIndex, lineTwoSecondIdx); - inputMesh->AddNeighbor(secondNewIndex, firstNewIndex); - inputMesh->AddNeighbor(secondNewIndex, lineTwoFirstIdx); + nonConstInput->AddNeighbor(secondNewIndex, lineTwoSecondIdx); + nonConstInput->AddNeighbor(secondNewIndex, firstNewIndex); + nonConstInput->AddNeighbor(secondNewIndex, lineTwoFirstIdx); CovariantVectorType lineOneFirstNormal = inputMesh->ComputeNormal(lineOneFirstIdx); CovariantVectorType firstNewNormal = inputMesh->ComputeNormal(firstNewIndex); @@ -200,18 +204,18 @@ void SimplexMeshAdaptTopologyFilter<TInputMesh, TOutputMesh> if (prod < 0) { - inputMesh->SwapNeighbors( firstNewIndex, lineOneFirstIdx, lineOneSecondIdx); + nonConstInput->SwapNeighbors( firstNewIndex, lineOneFirstIdx, lineOneSecondIdx); firstNewNormal = inputMesh->ComputeNormal(firstNewIndex); } prod = dot_product(secondNewNormal.GetVnlVector(), lineTwoFirstNormal.GetVnlVector()); if (prod < 0) { - inputMesh->SwapNeighbors( secondNewIndex, lineTwoFirstIdx, lineTwoSecondIdx); + nonConstInput->SwapNeighbors( secondNewIndex, lineTwoFirstIdx, lineTwoSecondIdx); secondNewNormal = inputMesh->ComputeNormal(secondNewIndex); } - this->GetInput(0)->AddEdge( firstNewIndex, secondNewIndex ); + nonConstInput->AddEdge( firstNewIndex, secondNewIndex ); // splitting cell unsigned long newPointIndex = 0; @@ -228,7 +232,7 @@ void SimplexMeshAdaptTopologyFilter<TInputMesh, TOutputMesh> m_NewSimplexCellPointer->SetPointId( newPointIndex++, secondNewIndex ); m_NewSimplexCellPointer->SetPointId( newPointIndex++, firstNewIndex ); - this->GetInput(0)->ReplaceFace( curvatureIt.Index(), m_NewSimplexCellPointer ); + nonConstInput->ReplaceFace( curvatureIt.Index(), m_NewSimplexCellPointer ); OutputPolygonType * polygon2 = new OutputPolygonType; m_NewSimplexCellPointer.TakeOwnership( polygon2 ); @@ -241,14 +245,14 @@ void SimplexMeshAdaptTopologyFilter<TInputMesh, TOutputMesh> m_NewSimplexCellPointer->SetPointId( newPointIndex++, firstPointId ); m_NewSimplexCellPointer->SetPointId( newPointIndex++, firstNewIndex ); m_NewSimplexCellPointer->SetPointId( newPointIndex++, secondNewIndex ); - this->GetInput(0)->AddFace( m_NewSimplexCellPointer ); + nonConstInput->AddFace( m_NewSimplexCellPointer ); - this->GetInput(0)->BuildCellLinks(); + nonConstInput->BuildCellLinks(); - ModifyNeighborCells(lineOneFirstIdx, lineOneSecondIdx, firstNewIndex); - ModifyNeighborCells(lineTwoFirstIdx, lineTwoSecondIdx, secondNewIndex); + this->ModifyNeighborCells(lineOneFirstIdx, lineOneSecondIdx, firstNewIndex); + this->ModifyNeighborCells(lineTwoFirstIdx, lineTwoSecondIdx, secondNewIndex); - if( this->GetInput(0)->GetCellsAllocationMethod() == TInputMesh::CellsAllocatedDynamicallyCellByCell ) + if( inputMesh->GetCellsAllocationMethod() == TInputMesh::CellsAllocatedDynamicallyCellByCell ) { delete poly.GetPointer(); } @@ -265,9 +269,10 @@ void SimplexMeshAdaptTopologyFilter<TInputMesh, TOutputMesh> ::InsertNewCells() { typename TOutputMesh::Pointer output = TOutputMesh::New(); - output->SetPoints(this->GetInput(0)->GetPoints()); - output->SetPointData(this->GetInput(0)->GetPointData()); - output->SetCells(this->GetInput(0)->GetCells()); + this->CopyInputMeshToOutputMeshPoints(); + this->CopyInputMeshToOutputMeshPointData(); + this->CopyInputMeshToOutputMeshCellData(); + this->CopyInputMeshToOutputMeshCells(); output->SetGeometryData(this->GetInput(0)->GetGeometryData()); output->SetLastCellId( this->GetInput(0)->GetLastCellId() ); this->ProcessObject::SetNthOutput(0, output.GetPointer()); @@ -284,6 +289,12 @@ SimplexMeshAdaptTopologyFilter<TInputMesh, TOutputMesh> std::set<unsigned long> result; + const InputMeshType * inputMesh = this->GetInput(0); + + // A filter shouldn't modify its input. + // There is a design flaw here... + InputMeshType * nonConstInput = const_cast< InputMeshType * >( inputMesh ); + while (cellIt != cells1.end() ) { std::set<unsigned long>::iterator found = std::find(cells2.begin(), cells2.end(), *cellIt); @@ -307,9 +318,9 @@ SimplexMeshAdaptTopologyFilter<TInputMesh, TOutputMesh> unsigned long first= *lineIt++; unsigned long second= *lineIt; - this->GetInput(0)->AddEdge( first, insertPointId ); - this->GetInput(0)->AddEdge( insertPointId, second ); - this->GetInput(0)->GetCells()->DeleteIndex( *cellIt ); + nonConstInput->AddEdge( first, insertPointId ); + nonConstInput->AddEdge( insertPointId, second ); + nonConstInput->GetCells()->DeleteIndex( *cellIt ); } else if ( nextCell->GetNumberOfPoints() > 3 ) { @@ -340,7 +351,7 @@ SimplexMeshAdaptTopologyFilter<TInputMesh, TOutputMesh> m_NewSimplexCellPointer->SetPointId( cnt++, insertPointId ); } - this->GetInput(0)->ReplaceFace( *cellIt, m_NewSimplexCellPointer ); + nonConstInput->ReplaceFace( *cellIt, m_NewSimplexCellPointer ); } cellIt++; diff --git a/Utilities/ITK/Code/BasicFilters/itkSimplexMeshToTriangleMeshFilter.h b/Utilities/ITK/Code/BasicFilters/itkSimplexMeshToTriangleMeshFilter.h index 8c8d18118a10cb7893e826f64f4ed060dcf9bccc..5966274f1c3d11885b79d0d41b1745c2071fabbc 100644 --- a/Utilities/ITK/Code/BasicFilters/itkSimplexMeshToTriangleMeshFilter.h +++ b/Utilities/ITK/Code/BasicFilters/itkSimplexMeshToTriangleMeshFilter.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkSimplexMeshToTriangleMeshFilter.h,v $ Language: C++ -Date: $Date: 2009-06-13 17:42:56 $ -Version: $Revision: 1.9 $ +Date: $Date: 2009-09-17 11:14:56 $ +Version: $Revision: 1.10 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -17,11 +17,11 @@ PURPOSE. See the above copyright notices for more information. #ifndef __itkSimplexMeshToTriangleMeshFilter_h #define __itkSimplexMeshToTriangleMeshFilter_h -#include <itkMesh.h> -#include <itkLineCell.h> -#include <itkPolygonCell.h> -#include <itkVertexCell.h> -#include <itkMapContainer.h> +#include "itkMesh.h" +#include "itkLineCell.h" +#include "itkPolygonCell.h" +#include "itkVertexCell.h" +#include "itkMapContainer.h" #include "itkSimplexMesh.h" #include "itkMeshToMeshFilter.h" @@ -67,7 +67,7 @@ public: typedef TInputMesh InputMeshType; - typedef typename InputMeshType::Pointer InputMeshPointer; + typedef typename InputMeshType::ConstPointer InputMeshConstPointer; typedef typename InputMeshType::PointType InputPointType; typedef typename InputMeshType::PixelType InputPixelType; typedef typename InputMeshType::MeshTraits::CellTraits InputCellTraitsType; @@ -139,14 +139,14 @@ public: return m_CenterMap; } - void SetMesh(InputMeshPointer mesh) + void SetMesh( const InputMeshType * mesh) { this->m_Mesh = mesh; } protected: - InputMeshPointer m_Mesh; - PointMapPointer m_CenterMap; + InputMeshConstPointer m_Mesh; + PointMapPointer m_CenterMap; }; typedef itk::CellInterfaceVisitorImplementation<InputPixelType, diff --git a/Utilities/ITK/Code/BasicFilters/itkSimplexMeshToTriangleMeshFilter.txx b/Utilities/ITK/Code/BasicFilters/itkSimplexMeshToTriangleMeshFilter.txx index 0854b2c17e67f7e19b118047f8c8cbee9e9e9028..22811b86b1f34acefb9c3cd346dc0d2b3bbeddb6 100644 --- a/Utilities/ITK/Code/BasicFilters/itkSimplexMeshToTriangleMeshFilter.txx +++ b/Utilities/ITK/Code/BasicFilters/itkSimplexMeshToTriangleMeshFilter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkSimplexMeshToTriangleMeshFilter.txx,v $ Language: C++ -Date: $Date: 2008-10-17 20:49:56 $ -Version: $Revision: 1.6 $ +Date: $Date: 2009-09-17 11:14:56 $ +Version: $Revision: 1.7 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -62,9 +62,9 @@ void SimplexMeshToTriangleMeshFilter<TInputMesh, TOutputMesh> typename AutoMeshSourceType::Pointer meshSource = AutoMeshSourceType::New(); typename AutoMeshSourceType::PointType p1,p2,p3; - typename TInputMesh::Pointer inputMesh = this->GetInput(0); - typename InputPointsContainer::Pointer points = inputMesh->GetPoints(); - typename TInputMesh::PointsContainerIterator pointsIt = points->Begin(); + typename TInputMesh::ConstPointer inputMesh = this->GetInput(0); + typename InputPointsContainer::ConstPointer points = inputMesh->GetPoints(); + typename TInputMesh::PointsContainerConstIterator pointsIt = points->Begin(); meshSource->Update(); diff --git a/Utilities/ITK/Code/BasicFilters/itkSmoothingRecursiveGaussianImageFilter.h b/Utilities/ITK/Code/BasicFilters/itkSmoothingRecursiveGaussianImageFilter.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/BasicFilters/itkSmoothingRecursiveGaussianImageFilter.txx b/Utilities/ITK/Code/BasicFilters/itkSmoothingRecursiveGaussianImageFilter.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/BasicFilters/itkSquareImageFilter.h b/Utilities/ITK/Code/BasicFilters/itkSquareImageFilter.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/BasicFilters/itkStreamingImageFilter.txx b/Utilities/ITK/Code/BasicFilters/itkStreamingImageFilter.txx index 43eeabe6f18f7ff9f2782f7f4f1cdfde85efc99a..6de4b99b91eccc1c8bbd18b542c4d5ddc871b388 100644 --- a/Utilities/ITK/Code/BasicFilters/itkStreamingImageFilter.txx +++ b/Utilities/ITK/Code/BasicFilters/itkStreamingImageFilter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkStreamingImageFilter.txx,v $ Language: C++ - Date: $Date: 2009-02-04 16:34:09 $ - Version: $Revision: 1.18 $ + Date: $Date: 2009-12-07 22:10:01 $ + Version: $Revision: 1.19 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -107,7 +107,7 @@ StreamingImageFilter<TInputImage,TOutputImage> // we don't call GenerateInputRequestedRegion since the requested // regions are manage when the pipeline is execute - // we don't call inputs PopafateRequestedRegion either + // we don't call inputs PropagateRequestedRegion either // because the pipeline managed later } diff --git a/Utilities/ITK/Code/BasicFilters/itkTransformMeshFilter.txx b/Utilities/ITK/Code/BasicFilters/itkTransformMeshFilter.txx index 17b3b0f809915591aa4e114117f582ac2ae71e12..22a42170167a63202b153e02bf1698aa81c2e832 100644 --- a/Utilities/ITK/Code/BasicFilters/itkTransformMeshFilter.txx +++ b/Utilities/ITK/Code/BasicFilters/itkTransformMeshFilter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkTransformMeshFilter.txx,v $ Language: C++ - Date: $Date: 2008-10-18 16:11:15 $ - Version: $Revision: 1.23 $ + Date: $Date: 2009-09-17 11:14:56 $ + Version: $Revision: 1.24 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -62,11 +62,11 @@ TransformMeshFilter<TInputMesh,TOutputMesh,TTransform> typedef typename TInputMesh::PointsContainer InputPointsContainer; typedef typename TOutputMesh::PointsContainer OutputPointsContainer; - typedef typename TInputMesh::PointsContainerPointer InputPointsContainerPointer; + typedef typename TInputMesh::PointsContainerConstPointer InputPointsContainerConstPointer; typedef typename TOutputMesh::PointsContainerPointer OutputPointsContainerPointer; - InputMeshPointer inputMesh = this->GetInput(); - OutputMeshPointer outputMesh = this->GetOutput(); + const InputMeshType * inputMesh = this->GetInput(); + OutputMeshPointer outputMesh = this->GetOutput(); if( !inputMesh ) { @@ -80,7 +80,7 @@ TransformMeshFilter<TInputMesh,TOutputMesh,TTransform> outputMesh->SetBufferedRegion( outputMesh->GetRequestedRegion() ); - InputPointsContainerPointer inPoints = inputMesh->GetPoints(); + InputPointsContainerConstPointer inPoints = inputMesh->GetPoints(); OutputPointsContainerPointer outPoints = outputMesh->GetPoints(); outPoints->Reserve( inputMesh->GetNumberOfPoints() ); @@ -101,13 +101,14 @@ TransformMeshFilter<TInputMesh,TOutputMesh,TTransform> // Create duplicate references to the rest of data on the mesh - - outputMesh->SetPointData( inputMesh->GetPointData() ); - - outputMesh->SetCellLinks( inputMesh->GetCellLinks() ); - - outputMesh->SetCells( inputMesh->GetCells() ); - outputMesh->SetCellData( inputMesh->GetCellData() ); + this->CopyInputMeshToOutputMeshPointData(); + this->CopyInputMeshToOutputMeshCellLinks(); + this->CopyInputMeshToOutputMeshCells(); + this->CopyInputMeshToOutputMeshCellData(); + + // FIXME: DELETEME outputMesh->SetCellLinks( inputMesh->GetCellLinks() ); + // FIXME: DELETEME outputMesh->SetCells( inputMesh->GetCells() ); + // FIXME: DELETEME outputMesh->SetCellData( inputMesh->GetCellData() ); unsigned int maxDimension = TInputMesh::MaxTopologicalDimension; @@ -119,6 +120,7 @@ TransformMeshFilter<TInputMesh,TOutputMesh,TTransform> } } + } // end namespace itk #endif diff --git a/Utilities/ITK/Code/BasicFilters/itkTriangleMeshToSimplexMeshFilter.h b/Utilities/ITK/Code/BasicFilters/itkTriangleMeshToSimplexMeshFilter.h index ee910b9fbb73d799b151bc9bdc253fbebc78c6cb..69ee89202e62287e849cbc05f834bdc62bef0f39 100644 --- a/Utilities/ITK/Code/BasicFilters/itkTriangleMeshToSimplexMeshFilter.h +++ b/Utilities/ITK/Code/BasicFilters/itkTriangleMeshToSimplexMeshFilter.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkTriangleMeshToSimplexMeshFilter.h,v $ Language: C++ -Date: $Date: 2009-05-12 17:23:01 $ -Version: $Revision: 1.6 $ +Date: $Date: 2009-09-17 11:14:56 $ +Version: $Revision: 1.7 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -70,9 +70,10 @@ public: typedef typename TInputMesh::BoundaryAssignmentsContainerPointer InputBoundaryAssignmentsContainerPointer; - typedef typename TInputMesh::PointsContainer InputPointsContainer; - typedef typename InputPointsContainer::Pointer InputPointsContainerPointer; - typedef typename InputPointsContainer::Iterator InputPointsContainerIterator; + typedef typename TInputMesh::PointsContainer InputPointsContainer; + typedef typename InputPointsContainer::Pointer InputPointsContainerPointer; + typedef typename InputPointsContainer::Iterator InputPointsContainerIterator; + typedef typename InputPointsContainer::ConstIterator InputPointsContainerConstIterator; typedef typename TOutputMesh::Pointer OutputMeshPointer; typedef typename TOutputMesh::PointType OutputPointType; diff --git a/Utilities/ITK/Code/BasicFilters/itkTriangleMeshToSimplexMeshFilter.txx b/Utilities/ITK/Code/BasicFilters/itkTriangleMeshToSimplexMeshFilter.txx index 9dcae3523078c991b41d8bb0cf7f7fe5c6ecd55a..f9eeb96bcdae1a78c454ede1af5f339a92ef8212 100644 --- a/Utilities/ITK/Code/BasicFilters/itkTriangleMeshToSimplexMeshFilter.txx +++ b/Utilities/ITK/Code/BasicFilters/itkTriangleMeshToSimplexMeshFilter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkTriangleMeshToSimplexMeshFilter.txx,v $ Language: C++ -Date: $Date: 2007-12-30 13:12:55 $ -Version: $Revision: 1.5 $ +Date: $Date: 2009-09-17 11:14:56 $ +Version: $Revision: 1.6 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -44,10 +44,10 @@ template <typename TInputMesh, typename TOutputMesh> void TriangleMeshToSimplexMeshFilter<TInputMesh, TOutputMesh> ::GenerateData() { - Initialize(); - CreateSimplexPoints(); - CreateSimplexNeighbors(); - CreateCells(); + this->Initialize(); + this->CreateSimplexPoints(); + this->CreateSimplexNeighbors(); + this->CreateCells(); this->GetOutput()->BuildCellLinks(); } @@ -58,7 +58,7 @@ void TriangleMeshToSimplexMeshFilter<TInputMesh, TOutputMesh> const unsigned long *tp; - InputMeshPointer input = this->GetInput(0); + const InputMeshType * input = this->GetInput(0); m_IdOffset = input->GetNumberOfCells(); m_EdgeCellId = 0; @@ -98,9 +98,9 @@ void TriangleMeshToSimplexMeshFilter<TInputMesh, TOutputMesh> " does not exist in the input mesh"); } - CreateNewEdge( idx1, 0, tp[0], tp[1] ); - CreateNewEdge( idx1, 1, tp[1], tp[2] ); - CreateNewEdge( idx1, 2, tp[2], tp[0] ); + this->CreateNewEdge( idx1, 0, tp[0], tp[1] ); + this->CreateNewEdge( idx1, 1, tp[1], tp[2] ); + this->CreateNewEdge( idx1, 2, tp[2], tp[0] ); } } @@ -130,14 +130,16 @@ TriangleMeshToSimplexMeshFilter<TInputMesh,TOutputMesh> ::CreateEdgeForTrianglePair( unsigned long pointIndex, unsigned long boundaryId) { EdgeIdentifierType facePair = m_EdgeNeighborList->GetElement(boundaryId); + if (facePair.first == pointIndex) { - this->GetOutput()->AddNeighbor( pointIndex , facePair.second); + this->GetOutput()->AddNeighbor( pointIndex , facePair.second); } else { - this->GetOutput()->AddNeighbor( pointIndex , facePair.first); + this->GetOutput()->AddNeighbor( pointIndex , facePair.first); } + if (!m_HandledEdgeIds->IndexExists( boundaryId )) { unsigned long edgeId = this->GetOutput()->AddEdge( facePair.first, facePair.second ); @@ -187,8 +189,11 @@ void TriangleMeshToSimplexMeshFilter<TInputMesh, TOutputMesh> { unsigned long boundaryId; - InputMeshPointer input = this->GetInput(0); + const InputMeshType * input = this->GetInput(0); + // The filter shouldn't modify the input... + InputMeshType * nonConstInput = const_cast< InputMeshType * >( input ); + EdgeIdentifierType edge = std::make_pair(startPointId,endPointId); EdgeIdentifierType edgeInv = std::make_pair(endPointId,startPointId); @@ -199,7 +204,7 @@ void TriangleMeshToSimplexMeshFilter<TInputMesh, TOutputMesh> m_NewInputMeshCellPointer.TakeOwnership( new LineType ); m_NewInputMeshCellPointer->SetPointId(0, startPointId); m_NewInputMeshCellPointer->SetPointId(1, endPointId); - input->SetCell( boundaryId, m_NewInputMeshCellPointer ); + nonConstInput->SetCell( boundaryId, m_NewInputMeshCellPointer ); m_EdgeCellId++; } @@ -214,7 +219,7 @@ void TriangleMeshToSimplexMeshFilter<TInputMesh, TOutputMesh> boundaryId = m_Edges->GetElement(edgeInv); } } - input->SetBoundaryAssignment( 1,currentCellId, featureId , boundaryId); + nonConstInput->SetBoundaryAssignment( 1,currentCellId, featureId , boundaryId); if (!m_EdgeNeighborList->IndexExists(boundaryId)) @@ -277,8 +282,8 @@ TriangleMeshToSimplexMeshFilter<TInputMesh, TOutputMesh> ::CreateCells() { - InputPointsContainerPointer pointsContainer = this->GetInput(0)->GetPoints(); - InputPointsContainerIterator points = pointsContainer->Begin(); + const InputPointsContainer * pointsContainer = this->GetInput(0)->GetPoints(); + InputPointsContainerConstIterator points = pointsContainer->Begin(); unsigned long idx; typedef itk::MapContainer<unsigned long, unsigned long> MapType; @@ -386,7 +391,7 @@ typename TriangleMeshToSimplexMeshFilter<TInputMesh, TOutputMesh>::InputPointTyp TriangleMeshToSimplexMeshFilter<TInputMesh, TOutputMesh> ::ComputeFaceCenter(unsigned long faceId) { - InputMeshPointer input = this->GetInput(0); + const InputMeshType * input = this->GetInput(0); const unsigned long *tp; InputPointType v1, v2, v3; diff --git a/Utilities/ITK/Code/BasicFilters/itkUnaryFunctorImageFilter.txx b/Utilities/ITK/Code/BasicFilters/itkUnaryFunctorImageFilter.txx index 5a0054b99031c2dd5cae3d97c7b6b9f3389a6bb7..685b1857a0d20beb9278d517300a1ce236abaa2f 100644 --- a/Utilities/ITK/Code/BasicFilters/itkUnaryFunctorImageFilter.txx +++ b/Utilities/ITK/Code/BasicFilters/itkUnaryFunctorImageFilter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkUnaryFunctorImageFilter.txx,v $ Language: C++ - Date: $Date: 2008-10-07 17:31:02 $ - Version: $Revision: 1.32 $ + Date: $Date: 2009-10-28 03:37:14 $ + Version: $Revision: 1.34 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. diff --git a/Utilities/ITK/Code/BasicFilters/itkVectorConnectedComponentImageFilter.h b/Utilities/ITK/Code/BasicFilters/itkVectorConnectedComponentImageFilter.h index 84f9c407952c6e1c9f874e47451fe57d760637b9..e501b93ce4dc192773ccba0caaa529276709e8e9 100644 --- a/Utilities/ITK/Code/BasicFilters/itkVectorConnectedComponentImageFilter.h +++ b/Utilities/ITK/Code/BasicFilters/itkVectorConnectedComponentImageFilter.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkVectorConnectedComponentImageFilter.h,v $ Language: C++ - Date: $Date: 2009-04-01 14:36:37 $ - Version: $Revision: 1.9 $ + Date: $Date: 2010-03-02 03:40:37 $ + Version: $Revision: 1.11 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -26,7 +26,10 @@ namespace itk { - + +namespace Functor +{ + /** \class SimilarVectorsFunctor * * \brief A connected components filter that labels the @@ -35,8 +38,6 @@ namespace itk * threshold. Vectors that are 180 degrees out of phase * are similar. Assumes that vectors are normalized. */ - -namespace Functor { template<class TInput> class SimilarVectorsFunctor @@ -72,6 +73,14 @@ protected: } // end namespace Functor +/** \class VectorConnectedComponentImageFilter + * + * \brief A connected components filter that labels the + * objects in a vector image. Two vectors are pointing + * similar directions if one minus their dot product is less than a + * threshold. Vectors that are 180 degrees out of phase + * are similar. Assumes that vectors are normalized. + */ template <class TInputImage, class TOutputImage, class TMaskImage=TInputImage> class ITK_EXPORT VectorConnectedComponentImageFilter : public ConnectedComponentFunctorImageFilter<TInputImage,TOutputImage, diff --git a/Utilities/ITK/Code/BasicFilters/itkVectorIndexSelectionCastImageFilter.h b/Utilities/ITK/Code/BasicFilters/itkVectorIndexSelectionCastImageFilter.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/BasicFilters/itkVectorResampleImageFilter.h b/Utilities/ITK/Code/BasicFilters/itkVectorResampleImageFilter.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/BasicFilters/itkVectorResampleImageFilter.txx b/Utilities/ITK/Code/BasicFilters/itkVectorResampleImageFilter.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/BasicFilters/itkVotingBinaryHoleFillingImageFilter.h b/Utilities/ITK/Code/BasicFilters/itkVotingBinaryHoleFillingImageFilter.h index a2a1894a4211df380c883e3e82e1302303977d97..ed2aa2e9ab00b535315f8fe529e3e7ffb66d58be 100644 --- a/Utilities/ITK/Code/BasicFilters/itkVotingBinaryHoleFillingImageFilter.h +++ b/Utilities/ITK/Code/BasicFilters/itkVotingBinaryHoleFillingImageFilter.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkVotingBinaryHoleFillingImageFilter.h,v $ Language: C++ - Date: $Date: 2008-10-17 20:50:03 $ - Version: $Revision: 1.10 $ + Date: $Date: 2010-04-01 20:51:27 $ + Version: $Revision: 1.11 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -69,7 +69,8 @@ public: typedef typename InputImageType::RegionType InputImageRegionType; typedef typename OutputImageType::RegionType OutputImageRegionType; - typedef typename InputImageType::SizeType InputSizeType; + typedef typename InputImageType::SizeType InputSizeType; + typedef typename InputImageType::SizeValueType SizeValueType; /** Majority threshold. It is the number of pixels over 50% that will decide @@ -83,7 +84,7 @@ public: /** Returns the number of pixels that changed when the filter was executed. */ - itkGetConstReferenceMacro( NumberOfPixelsChanged, unsigned int ); + itkGetConstReferenceMacro( NumberOfPixelsChanged, SizeValueType ); #ifdef ITK_USE_CONCEPT_CHECKING /** Begin concept checking */ @@ -130,12 +131,12 @@ private: VotingBinaryHoleFillingImageFilter(const Self&); //purposely not implemented void operator=(const Self&); //purposely not implemented - unsigned int m_MajorityThreshold; + unsigned int m_MajorityThreshold; - unsigned int m_NumberOfPixelsChanged; + SizeValueType m_NumberOfPixelsChanged; // Auxiliary array for multi-threading - Array<unsigned int> m_Count; + Array<SizeValueType> m_Count; }; } // end namespace itk diff --git a/Utilities/ITK/Code/BasicFilters/itkVotingBinaryHoleFillingImageFilter.txx b/Utilities/ITK/Code/BasicFilters/itkVotingBinaryHoleFillingImageFilter.txx index f503f17ad5956748acf0ef45ad8575c8e98f0ce1..047274fa947df0d7da40df1a55fb6a690a293f20 100644 --- a/Utilities/ITK/Code/BasicFilters/itkVotingBinaryHoleFillingImageFilter.txx +++ b/Utilities/ITK/Code/BasicFilters/itkVotingBinaryHoleFillingImageFilter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkVotingBinaryHoleFillingImageFilter.txx,v $ Language: C++ - Date: $Date: 2008-10-17 20:50:03 $ - Version: $Revision: 1.6 $ + Date: $Date: 2010-04-01 20:51:27 $ + Version: $Revision: 1.7 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -162,7 +162,8 @@ void VotingBinaryHoleFillingImageFilter< TInputImage, TOutputImage> ::AfterThreadedGenerateData() { - this->m_NumberOfPixelsChanged = 0; + this->m_NumberOfPixelsChanged = NumericTraits< SizeValueType >::Zero; + unsigned int numberOfThreads = this->GetNumberOfThreads(); this->m_Count.SetSize(numberOfThreads); for(unsigned int t=0; t<numberOfThreads; t++) diff --git a/Utilities/ITK/Code/BasicFilters/itkWarpImageFilter.h b/Utilities/ITK/Code/BasicFilters/itkWarpImageFilter.h index 473a95287e991d3dcf1b8ed2db3872bb00b0dea7..c02b7813227e9ac319763719e5bb9f9d1fa0d66d 100644 --- a/Utilities/ITK/Code/BasicFilters/itkWarpImageFilter.h +++ b/Utilities/ITK/Code/BasicFilters/itkWarpImageFilter.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkWarpImageFilter.h,v $ Language: C++ - Date: $Date: 2009-04-25 12:28:12 $ - Version: $Revision: 1.30 $ + Date: $Date: 2009-10-29 11:19:00 $ + Version: $Revision: 1.31 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -109,6 +109,7 @@ public: typedef typename Superclass::OutputImagePointer OutputImagePointer; typedef typename Superclass::InputImageConstPointer InputImageConstPointer; typedef typename OutputImageType::IndexType IndexType; + typedef typename OutputImageType::IndexValueType IndexValueType; typedef typename OutputImageType::SizeType SizeType; typedef typename OutputImageType::PixelType PixelType; typedef typename OutputImageType::SpacingType SpacingType; diff --git a/Utilities/ITK/Code/BasicFilters/itkWarpImageFilter.txx b/Utilities/ITK/Code/BasicFilters/itkWarpImageFilter.txx index 44b3d93619dfc1bf0308a65bb69c29364b370cfa..c64cc48bdf26282bb9dbc7fe0c893e9404d5288d 100644 --- a/Utilities/ITK/Code/BasicFilters/itkWarpImageFilter.txx +++ b/Utilities/ITK/Code/BasicFilters/itkWarpImageFilter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkWarpImageFilter.txx,v $ Language: C++ - Date: $Date: 2009-03-24 21:48:17 $ - Version: $Revision: 1.33 $ + Date: $Date: 2009-10-29 11:19:10 $ + Version: $Revision: 1.34 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -215,19 +215,19 @@ WarpImageFilter<TInputImage,TOutputImage,TDeformationField> * Compute base index = closest index below point * Compute distance from point to base index */ - signed long baseIndex[ImageDimension]; + IndexType baseIndex; IndexType neighIndex; double distance[ImageDimension]; for( dim = 0; dim < ImageDimension; dim++ ) { - baseIndex[dim] = (long) vcl_floor(index[dim] ); + baseIndex[dim] = Math::Floor< IndexValueType >( index[dim] ); if( baseIndex[dim] >= m_StartIndex[dim] ) { if( baseIndex[dim] < m_EndIndex[dim] ) { - distance[dim] = index[dim] - double( baseIndex[dim] ); + distance[dim] = index[dim] - static_cast<double>( baseIndex[dim] ); } else { diff --git a/Utilities/ITK/Code/BasicFilters/itkWarpMeshFilter.txx b/Utilities/ITK/Code/BasicFilters/itkWarpMeshFilter.txx index 8549f1131d7a2f5c59a69cd267d1be7c463bf97f..4950954256f163ff1449d3a2cb3447ee6d213400 100644 --- a/Utilities/ITK/Code/BasicFilters/itkWarpMeshFilter.txx +++ b/Utilities/ITK/Code/BasicFilters/itkWarpMeshFilter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkWarpMeshFilter.txx,v $ Language: C++ - Date: $Date: 2008-10-07 17:31:02 $ - Version: $Revision: 1.2 $ + Date: $Date: 2009-09-17 11:14:56 $ + Version: $Revision: 1.3 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -83,7 +83,7 @@ WarpMeshFilter<TInputMesh,TOutputMesh,TDeformationField> typedef typename TInputMesh::PointsContainerPointer InputPointsContainerPointer; typedef typename TOutputMesh::PointsContainerPointer OutputPointsContainerPointer; - InputMeshPointer inputMesh = this->GetInput(); + const InputMeshType * inputMesh = this->GetInput(); OutputMeshPointer outputMesh = this->GetOutput(); DeformationFieldPointer fieldPtr = this->GetDeformationField(); @@ -99,7 +99,7 @@ WarpMeshFilter<TInputMesh,TOutputMesh,TDeformationField> outputMesh->SetBufferedRegion( outputMesh->GetRequestedRegion() ); - InputPointsContainerPointer inPoints = inputMesh->GetPoints(); + const InputPointsContainer * inPoints = inputMesh->GetPoints(); OutputPointsContainerPointer outPoints = outputMesh->GetPoints(); outPoints->Reserve( inputMesh->GetNumberOfPoints() ); @@ -140,13 +140,10 @@ WarpMeshFilter<TInputMesh,TOutputMesh,TDeformationField> // Create duplicate references to the rest of data on the mesh - outputMesh->SetPointData( inputMesh->GetPointData() ); - - outputMesh->SetCellLinks( inputMesh->GetCellLinks() ); - - outputMesh->SetCells( inputMesh->GetCells() ); - outputMesh->SetCellData( inputMesh->GetCellData() ); - + this->CopyInputMeshToOutputMeshPointData(); + this->CopyInputMeshToOutputMeshCells(); + this->CopyInputMeshToOutputMeshCellLinks(); + this->CopyInputMeshToOutputMeshCellData(); unsigned int maxDimension = TInputMesh::MaxTopologicalDimension; diff --git a/Utilities/ITK/Code/BasicFilters/itkWarpVectorImageFilter.h b/Utilities/ITK/Code/BasicFilters/itkWarpVectorImageFilter.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/BasicFilters/itkWarpVectorImageFilter.txx b/Utilities/ITK/Code/BasicFilters/itkWarpVectorImageFilter.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/BasicFilters/itkWeightedAddImageFilter.h b/Utilities/ITK/Code/BasicFilters/itkWeightedAddImageFilter.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/BasicFilters/itkXorImageFilter.h b/Utilities/ITK/Code/BasicFilters/itkXorImageFilter.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Common/CMakeLists.txt b/Utilities/ITK/Code/Common/CMakeLists.txt index b2c35a076e6f0336028705de22c0d61066bd4190..55749ea90e6d8d253d882b5a9cf7524cd92bcf7c 100644 --- a/Utilities/ITK/Code/Common/CMakeLists.txt +++ b/Utilities/ITK/Code/Common/CMakeLists.txt @@ -42,7 +42,11 @@ SET(ITKCommon_SRCS itkNumericTraitsRGBPixel.cxx itkNumericTraitsRGBAPixel.cxx itkNumericTraitsVectorPixel.cxx + itkNumericTraitsTensorPixel.cxx + itkNumericTraitsTensorPixel2.cxx + itkNumericTraitsDiffusionTensor3DPixel.cxx itkNumericTraitsFixedArrayPixel.cxx + itkNumericTraitsFixedArrayPixel2.cxx itkObject.cxx itkObjectFactoryBase.cxx itkOneWayEquivalencyTable.cxx @@ -166,17 +170,26 @@ IF(NOT ITK_INSTALL_NO_LIBRARIES) ARCHIVE DESTINATION ${ITK_INSTALL_LIB_DIR_CM24} COMPONENT Development) ENDIF(NOT ITK_INSTALL_NO_LIBRARIES) +IF(ITK_USE_FLAT_DIRECTORY_INSTALL) + SET( ITK_INSTALL_INCLUDE_DIR_CM24_COMMON ${ITK_INSTALL_INCLUDE_DIR_CM24}) + SET( ITK_INSTALL_INCLUDE_DIR_CM24_COMMON_TEMPLATES ${ITK_INSTALL_INCLUDE_DIR_CM24}) +ELSE(ITK_USE_FLAT_DIRECTORY_INSTALL) + SET( ITK_INSTALL_INCLUDE_DIR_CM24_COMMON ${ITK_INSTALL_INCLUDE_DIR_CM24}/Common) + SET( ITK_INSTALL_INCLUDE_DIR_CM24_COMMON_TEMPLATES ${ITK_INSTALL_INCLUDE_DIR_CM24}/Common/Templates) +ENDIF(ITK_USE_FLAT_DIRECTORY_INSTALL) + + IF(NOT ITK_INSTALL_NO_DEVELOPMENT) FILE(GLOB __files1 "${CMAKE_CURRENT_SOURCE_DIR}/*.h") FILE(GLOB __files2 "${CMAKE_CURRENT_SOURCE_DIR}/*.txx") INSTALL(FILES ${__files1} ${__files2} - DESTINATION ${ITK_INSTALL_INCLUDE_DIR_CM24}/Common + DESTINATION ${ITK_INSTALL_INCLUDE_DIR_CM24_COMMON} COMPONENT Development) IF(ITK_EXPLICIT_INSTANTIATION) FILE(GLOB __files3 "${CMAKE_CURRENT_BINARY_DIR}/Templates/*.h") INSTALL(FILES ${__files3} - DESTINATION ${ITK_INSTALL_INCLUDE_DIR_CM24}/Common/Templates + DESTINATION ${ITK_INSTALL_INCLUDE_DIR_CM24_COMMON_TEMPLATES} COMPONENT Development) ENDIF(ITK_EXPLICIT_INSTANTIATION) ENDIF(NOT ITK_INSTALL_NO_DEVELOPMENT) diff --git a/Utilities/ITK/Code/Common/itkAbsImageAdaptor.h b/Utilities/ITK/Code/Common/itkAbsImageAdaptor.h old mode 100644 new mode 100755 index 81c55095e1e71544ee4c17392959454beb17cc1d..06a29b0e722e15c7002dd942e374b9a662315a6d --- a/Utilities/ITK/Code/Common/itkAbsImageAdaptor.h +++ b/Utilities/ITK/Code/Common/itkAbsImageAdaptor.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkAbsImageAdaptor.h,v $ Language: C++ - Date: $Date: 2006-03-19 04:36:58 $ - Version: $Revision: 1.4 $ + Date: $Date: 2009-09-19 19:56:20 $ + Version: $Revision: 1.5 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -28,7 +28,7 @@ namespace Accessor { * * AbsPixelAccessor is templated over an internal type and an * external type representation. This class cast the input - * applies the funtion to it and cast the result according + * applies the function to it and cast the result according * to the types defined as template parameters * * \ingroup ImageAdaptors diff --git a/Utilities/ITK/Code/Common/itkAcosImageAdaptor.h b/Utilities/ITK/Code/Common/itkAcosImageAdaptor.h index b90f9e28b8b3e7eaeb3a00620b9c7c1b9333c987..54927985b71f2a18b03520a0fcee37e30a4ebd1f 100644 --- a/Utilities/ITK/Code/Common/itkAcosImageAdaptor.h +++ b/Utilities/ITK/Code/Common/itkAcosImageAdaptor.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkAcosImageAdaptor.h,v $ Language: C++ - Date: $Date: 2006-03-19 04:36:58 $ - Version: $Revision: 1.14 $ + Date: $Date: 2009-09-19 19:56:20 $ + Version: $Revision: 1.15 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -29,7 +29,7 @@ namespace Accessor { * * AcosPixelAccessor is templated over an internal type and an * external type representation. This class cast the input - * applies the funtion to it and cast the result according + * applies the function to it and cast the result according * to the types defined as template parameters * * \ingroup ImageAdaptors */ diff --git a/Utilities/ITK/Code/Common/itkAnnulusOperator.txx b/Utilities/ITK/Code/Common/itkAnnulusOperator.txx index d13cdaf58bb77693bc6d93ef54dfe2fd9db5a960..4458613285979591cc120c809809e8d6adf90945 100644 --- a/Utilities/ITK/Code/Common/itkAnnulusOperator.txx +++ b/Utilities/ITK/Code/Common/itkAnnulusOperator.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkAnnulusOperator.txx,v $ Language: C++ - Date: $Date: 2009-04-05 10:56:39 $ - Version: $Revision: 1.7 $ + Date: $Date: 2009-11-03 12:24:18 $ + Version: $Revision: 1.8 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -19,6 +19,7 @@ #define __itkAnnulusOperator_txx #include "itkAnnulusOperator.h" +#include "itkMath.h" #include "itkSphereSpatialFunction.h" namespace itk @@ -92,7 +93,7 @@ AnnulusOperator<TPixel, TDimension, TAllocator> double outerRadius = m_InnerRadius + m_Thickness; for (i=0; i < TDimension; ++i) { - r[i] = static_cast<SizeValueType>(vcl_ceil(outerRadius / m_Spacing[i])); + r[i] = Math::Ceil<SizeValueType>(outerRadius / m_Spacing[i]); } this->SetRadius(r); diff --git a/Utilities/ITK/Code/Common/itkArray.h b/Utilities/ITK/Code/Common/itkArray.h index b3ea19b0b7e199d78be9ee36fa5dd2087ea2d12b..52e00465389369bcbcc8d966eb20665e250123c4 100644 --- a/Utilities/ITK/Code/Common/itkArray.h +++ b/Utilities/ITK/Code/Common/itkArray.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkArray.h,v $ Language: C++ - Date: $Date: 2006-07-09 01:35:05 $ - Version: $Revision: 1.47 $ + Date: $Date: 2010-03-15 19:02:09 $ + Version: $Revision: 1.48 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -57,7 +57,7 @@ public: Array(); /** Constructor with size. Size can only be changed by assignment */ - Array(unsigned int dimension); + explicit Array(unsigned int dimension); /** Constructor that initializes array with contents from a user supplied * buffer. The pointer to the buffer and the length is specified. By default, diff --git a/Utilities/ITK/Code/Common/itkAsinImageAdaptor.h b/Utilities/ITK/Code/Common/itkAsinImageAdaptor.h index 6c6e3d919854a58d769af8164b568ba620dd3361..4fe821f2a18032a287a92c5b0ce0be93814731d9 100644 --- a/Utilities/ITK/Code/Common/itkAsinImageAdaptor.h +++ b/Utilities/ITK/Code/Common/itkAsinImageAdaptor.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkAsinImageAdaptor.h,v $ Language: C++ - Date: $Date: 2006-03-19 04:36:58 $ - Version: $Revision: 1.13 $ + Date: $Date: 2009-09-19 19:56:20 $ + Version: $Revision: 1.14 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -30,7 +30,7 @@ namespace Accessor { * * AsinPixelAccessor is templated over an internal type and an * external type representation. This class cast the input - * applies the funtion to it and cast the result according + * applies the function to it and cast the result according * to the types defined as template parameters * * \ingroup ImageAdaptors */ diff --git a/Utilities/ITK/Code/Common/itkAtanImageAdaptor.h b/Utilities/ITK/Code/Common/itkAtanImageAdaptor.h index d51195eeba884fe9f3c793901b5eb1e9fc25cc99..f36145ccce5613847632aec995781dec2cf57eb4 100644 --- a/Utilities/ITK/Code/Common/itkAtanImageAdaptor.h +++ b/Utilities/ITK/Code/Common/itkAtanImageAdaptor.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkAtanImageAdaptor.h,v $ Language: C++ - Date: $Date: 2006-03-19 04:36:58 $ - Version: $Revision: 1.13 $ + Date: $Date: 2009-09-19 19:56:20 $ + Version: $Revision: 1.14 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -30,7 +30,7 @@ namespace Accessor { * * AtanPixelAccessor is templated over an internal type and an * external type representation. This class cast the input - * applies the funtion to it and cast the result according + * applies the function to it and cast the result according * to the types defined as template parameters * \ingroup ImageAdaptors * diff --git a/Utilities/ITK/Code/Common/itkBSplineDeformableTransform.h b/Utilities/ITK/Code/Common/itkBSplineDeformableTransform.h index 9d1429c5767020361787b37741c3f3bedf3a388f..f8b2ee99de6fb28a068a83e793b3b2d8373cf4e4 100644 --- a/Utilities/ITK/Code/Common/itkBSplineDeformableTransform.h +++ b/Utilities/ITK/Code/Common/itkBSplineDeformableTransform.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkBSplineDeformableTransform.h,v $ Language: C++ - Date: $Date: 2009-05-13 15:26:06 $ - Version: $Revision: 1.41 $ + Date: $Date: 2010-03-05 15:26:30 $ + Version: $Revision: 1.42 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -119,7 +119,11 @@ public: typedef SmartPointer<const Self> ConstPointer; /** New macro for creation of through the object factory. */ - itkNewMacro( Self ); + static Pointer New(void); + + /** CreateAnother method will clone the existing instance of this type, + * including its internal member variables. */ + virtual ::itk::LightObject::Pointer CreateAnother(void) const; /** Run-time type information (and related methods). */ itkTypeMacro( BSplineDeformableTransform, Transform ); diff --git a/Utilities/ITK/Code/Common/itkBSplineDeformableTransform.txx b/Utilities/ITK/Code/Common/itkBSplineDeformableTransform.txx index cc29be0589fd679eda03b9e4161fbc2a80ba5093..41e458385e727339578edb1ae55f06628e5974f9 100644 --- a/Utilities/ITK/Code/Common/itkBSplineDeformableTransform.txx +++ b/Utilities/ITK/Code/Common/itkBSplineDeformableTransform.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkBSplineDeformableTransform.txx,v $ Language: C++ - Date: $Date: 2009-05-13 22:04:48 $ - Version: $Revision: 1.45 $ + Date: $Date: 2010-03-05 18:38:59 $ + Version: $Revision: 1.49 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -136,6 +136,40 @@ BSplineDeformableTransform<TScalarType, NDimensions, VSplineOrder> } +// Explicit New() method, used here because we need to split the itkNewMacro() +// in order to overload the CreateAnother() method. +template<class TScalarType, unsigned int NDimensions, unsigned int VSplineOrder> +typename BSplineDeformableTransform<TScalarType, NDimensions, VSplineOrder>::Pointer +BSplineDeformableTransform<TScalarType, NDimensions, VSplineOrder> +::New(void) +{ + Pointer smartPtr = ::itk::ObjectFactory< Self >::Create(); + if(smartPtr.IsNull()) + { + smartPtr = static_cast<Pointer>(new Self); + } + smartPtr->UnRegister(); + return smartPtr; +} + + +// Explicit New() method, used here because we need to split the itkNewMacro() +// in order to overload the CreateAnother() method. +template<class TScalarType, unsigned int NDimensions, unsigned int VSplineOrder> +::itk::LightObject::Pointer +BSplineDeformableTransform<TScalarType, NDimensions, VSplineOrder> +::CreateAnother(void) const +{ + ::itk::LightObject::Pointer smartPtr; + Pointer copyPtr = Self::New().GetPointer(); + + copyPtr->m_BulkTransform = this->GetBulkTransform(); + + smartPtr = static_cast<Pointer>(copyPtr); + + return smartPtr; +} + // Get the number of parameters template<class TScalarType, unsigned int NDimensions, unsigned int VSplineOrder> unsigned int @@ -188,7 +222,7 @@ BSplineDeformableTransform<TScalarType, NDimensions, VSplineOrder> // when spline order is even. // The valid interval for evaluation is [start+offset, last-offset) // when spline order is odd. - // Where offset = vcl_floor(spline / 2 ). + // Where offset = floor(spline / 2 ). // Note that the last pixel is not included in the valid region // with odd spline orders. typename RegionType::SizeType size = m_GridRegion.GetSize(); @@ -341,10 +375,12 @@ BSplineDeformableTransform<TScalarType, NDimensions, VSplineOrder> // expected number of parameters if ( parameters.Size() != this->GetNumberOfParameters() ) { - itkExceptionMacro(<<"Mismatched between parameters size " - << parameters.size() - << " and region size " - << m_GridRegion.GetNumberOfPixels() ); + itkExceptionMacro(<<"Mismatch between parameters size " + << parameters.Size() + << " and expected number of parameters " + << this->GetNumberOfParameters() + << (m_GridRegion.GetNumberOfPixels() == 0 ? + ". \nSince the size of the grid region is 0, perhaps you forgot to SetGridRegion or SetFixedParameters before setting the Parameters." : "")); } // Clean up buffered parameters diff --git a/Utilities/ITK/Code/Common/itkBSplineInterpolationWeightFunction.txx b/Utilities/ITK/Code/Common/itkBSplineInterpolationWeightFunction.txx index fd670d7eb237e1b70029034e4db14695901d1258..f16ad4891b10183b9f30584c747ad58ee983786c 100644 --- a/Utilities/ITK/Code/Common/itkBSplineInterpolationWeightFunction.txx +++ b/Utilities/ITK/Code/Common/itkBSplineInterpolationWeightFunction.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkBSplineInterpolationWeightFunction.txx,v $ Language: C++ - Date: $Date: 2009-06-16 08:01:55 $ - Version: $Revision: 1.16 $ + Date: $Date: 2009-10-27 18:12:49 $ + Version: $Revision: 1.19 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -20,6 +20,7 @@ #include "itkBSplineInterpolationWeightFunction.h" #include "itkImage.h" #include "itkMatrix.h" +#include "itkMath.h" #include "itkImageRegionConstIteratorWithIndex.h" namespace itk @@ -119,14 +120,14 @@ void BSplineInterpolationWeightFunction<TCoordRep, VSpaceDimension, WeightsType & weights, IndexType & startIndex ) const { + typedef typename IndexType::IndexValueType IndexValueType; unsigned int j, k; // Find the starting index of the support region for ( j = 0; j < SpaceDimension; j++ ) { - startIndex[j] = static_cast<typename IndexType::IndexValueType>( - Math::Floor( index[j] - static_cast<double>( SplineOrder - 1 ) / 2.0 ) ); + startIndex[j] = Math::Floor<IndexValueType> ( index[j] - static_cast<double>( SplineOrder - 1 ) / 2.0 ); } // Compute the weights diff --git a/Utilities/ITK/Code/Common/itkBarrier.h b/Utilities/ITK/Code/Common/itkBarrier.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Common/itkByteSwapper.h b/Utilities/ITK/Code/Common/itkByteSwapper.h index d2b0db6de851584d0f34511ac264cda7a7912aea..64b214dbfb80b583aa71828f3f6588893c6b30bb 100644 --- a/Utilities/ITK/Code/Common/itkByteSwapper.h +++ b/Utilities/ITK/Code/Common/itkByteSwapper.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkByteSwapper.h,v $ Language: C++ - Date: $Date: 2008-10-10 14:28:21 $ - Version: $Revision: 1.16 $ + Date: $Date: 2009-12-08 19:53:43 $ + Version: $Revision: 1.17 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -60,7 +60,7 @@ public: static bool SystemIsLE () { return SystemIsLittleEndian(); } /** Generic swap method handles type T. The swapping is - * done in-place. Either 2-byte or 4-byte swapping + * done in-place. 2, 4 and 8 byte swapping * can be handled. Single byte types are not swapped; * others raise an exception. The method is used to * swap to and from Big Endian. */ @@ -71,7 +71,7 @@ public: typedef ::size_t BufferSizeType; /** Generic swap method handles type T. The swapping is - * done in-place. Either 2-byte or 4-byte swapping + * done in-place. 2, 4 and 8 byte swapping * can be handled. Single byte types are not swapped; * others raise an exception. The method is used to * swap to and from Big Endian. */ @@ -80,7 +80,7 @@ public: /** Generic swap method handles type T. The data is * swapped and written (in binary) to the ostream * given. A total of num values of type T are written - * and swapped. Either 2-byte or 4-byte swapping + * and swapped. 2, 4 and 8 byte swapping * can be handled. Single byte types are not swapped; * others raise an exception. The method is used to * swap to and from Big Endian. */ @@ -88,14 +88,14 @@ public: OStreamType *fp); /** Generic swap method handles type T. The swapping is - * done in-place. Either 2-byte or 4-byte swapping + * done in-place. 2, 4 and 8 byte swapping * can be handled. Single byte types are not swapped; * others raise an exception. The method is used to * swap to and from Little Endian. */ static void SwapFromSystemToLittleEndian(T *p); /** Generic swap method handles type T. The swapping is - * done in-place. Either 2-byte or 4-byte swapping + * done in-place. 2, 4 and 8 byte swapping * can be handled. Single byte types are not swapped; * others raise an exception. The method is used to * swap to and from Little Endian. */ @@ -104,7 +104,7 @@ public: /** Generic swap method handles type T. The data is * swapped and written (in binary) to the ostream * given. A total of num values of type T are written - * and swapped. Either 2-byte or 4-byte swapping + * and swapped. 2, 4 and 8 byte swapping * can be handled. Single byte types are not swapped; * others raise an exception. The method is used to * swap to and from Little Endian. */ @@ -140,7 +140,7 @@ protected: /** Swap 8 bytes. */ static void Swap8(void *p); - /** Swap a range of four-byte words. Num is the number of four-byte words + /** Swap a range of 8-byte words. Num is the number of four-byte words * to swap. */ static void Swap8Range(void *p, BufferSizeType num); diff --git a/Utilities/ITK/Code/Common/itkCenteredAffineTransform.h b/Utilities/ITK/Code/Common/itkCenteredAffineTransform.h index b8b82072c5aaa65ea980be494e296451ca5e2726..bf97c74df1773c0da173723dfe95256252d295ce 100644 --- a/Utilities/ITK/Code/Common/itkCenteredAffineTransform.h +++ b/Utilities/ITK/Code/Common/itkCenteredAffineTransform.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkCenteredAffineTransform.h,v $ Language: C++ - Date: $Date: 2009-04-09 09:23:20 $ - Version: $Revision: 1.16 $ + Date: $Date: 2009-11-29 01:38:00 $ + Version: $Revision: 1.18 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -59,6 +59,7 @@ public: /** Types taken from the Superclass */ typedef typename Superclass::ParametersType ParametersType; + typedef typename Superclass::ParametersValueType ParametersValueType; typedef typename Superclass::JacobianType JacobianType; typedef typename Superclass::ScalarType ScalarType; typedef typename Superclass::InputVectorType InputVectorType; @@ -71,12 +72,15 @@ public: typedef typename Superclass::InputVnlVectorType InputVnlVectorType; typedef typename Superclass::OutputVnlVectorType OutputVnlVectorType; typedef typename Superclass::InputPointType InputPointType; + typedef typename Superclass::InputPointValueType InputPointValueType; + typedef typename Superclass::OutputVectorValueType OutputVectorValueType; typedef typename Superclass::OutputPointType OutputPointType; typedef typename Superclass::MatrixType MatrixType; + typedef typename Superclass::MatrixValueType MatrixValueType; typedef typename Superclass::OffsetType OffsetType; /** Base inverse transform type. This type should not be changed to the - * concrete inverse transform type or inheritance would be lost.*/ + * concrete inverse transform type or inheritance would be lost. */ typedef typename Superclass::InverseTransformBaseType InverseTransformBaseType; typedef typename InverseTransformBaseType::Pointer InverseTransformBasePointer; diff --git a/Utilities/ITK/Code/Common/itkCenteredAffineTransform.txx b/Utilities/ITK/Code/Common/itkCenteredAffineTransform.txx index a9461908a4b9b52e1be101d2f20c754816a22a39..43ec32b70b9ce3e06e4eb7e139ee47ac18fcea2b 100644 --- a/Utilities/ITK/Code/Common/itkCenteredAffineTransform.txx +++ b/Utilities/ITK/Code/Common/itkCenteredAffineTransform.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkCenteredAffineTransform.txx,v $ Language: C++ - Date: $Date: 2009-04-09 09:23:20 $ - Version: $Revision: 1.13 $ + Date: $Date: 2010-03-30 15:20:03 $ + Version: $Revision: 1.16 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. diff --git a/Utilities/ITK/Code/Common/itkCenteredEuler3DTransform.h b/Utilities/ITK/Code/Common/itkCenteredEuler3DTransform.h index 39df8a672bf62da0061cf152d4cedf5039cabc5d..3b91461730fb56a6652909cfee2793a8b025c4d5 100644 --- a/Utilities/ITK/Code/Common/itkCenteredEuler3DTransform.h +++ b/Utilities/ITK/Code/Common/itkCenteredEuler3DTransform.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkCenteredEuler3DTransform.h,v $ Language: C++ - Date: $Date: 2009-04-09 09:23:20 $ - Version: $Revision: 1.11 $ + Date: $Date: 2010-03-16 08:49:50 $ + Version: $Revision: 1.15 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -58,6 +58,7 @@ public: itkStaticConstMacro(ParametersDimension, unsigned int, 9); typedef typename Superclass::ParametersType ParametersType; + typedef typename Superclass::ParametersValueType ParametersValueType; typedef typename Superclass::JacobianType JacobianType; typedef typename Superclass::ScalarType ScalarType; typedef typename Superclass::InputVectorType InputVectorType; @@ -75,23 +76,28 @@ public: typedef typename Superclass::InverseMatrixType InverseMatrixType; typedef typename Superclass::CenterType CenterType; typedef typename Superclass::TranslationType TranslationType; + typedef typename Superclass::TranslationValueType TranslationValueType; typedef typename Superclass::OffsetType OffsetType; /** Base inverse transform type. This type should not be changed to the - * concrete inverse transform type or inheritance would be lost.*/ + * concrete inverse transform type or inheritance would be lost. */ typedef typename Superclass::InverseTransformBaseType InverseTransformBaseType; typedef typename InverseTransformBaseType::Pointer InverseTransformBasePointer; /** Set the transformation from a container of parameters - * This is typically used by optimizers. - * There are six parameters. The first three represent the - * rotation and the last three represent the translation. */ + * This is typically used by optimizers. There are nine parameters. The first + * three represent the angles of rotation (in radians) around each one of the + * axes (X,Y,Z), the next three parameters represent the coordinates of the + * center of rotation and the last three parameters represent the + * translation. */ void SetParameters( const ParametersType & parameters ); /** Get the parameters that uniquely define the transform - * This is typically used by optimizers. - * There are six parameters. The first three represent the - * rotation and the last three represent the translation. */ + * This is typically used by optimizers. There are nine parameters. The first + * three represent the angles of rotation (in radians) around each one of the + * axes (X,Y,Z), the next three parameters represent the coordinates of the + * center of rotation and the last three parameters represent the + * translation. */ const ParametersType & GetParameters( void ) const; /** This method computes the Jacobian matrix of the transformation. diff --git a/Utilities/ITK/Code/Common/itkCenteredEuler3DTransform.txx b/Utilities/ITK/Code/Common/itkCenteredEuler3DTransform.txx index 7b31b8d10515f725be3885a7859f8b4102ad429e..f070b15e3a3cba25e44fa95ea88ed04c20d4e0b6 100644 --- a/Utilities/ITK/Code/Common/itkCenteredEuler3DTransform.txx +++ b/Utilities/ITK/Code/Common/itkCenteredEuler3DTransform.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkCenteredEuler3DTransform.txx,v $ Language: C++ - Date: $Date: 2009-04-09 09:23:20 $ - Version: $Revision: 1.13 $ + Date: $Date: 2010-03-30 15:20:02 $ + Version: $Revision: 1.16 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -75,9 +75,13 @@ CenteredEuler3DTransform<TScalarType> { itkDebugMacro( << "Setting parameters " << parameters ); - this->SetVarRotation(parameters[0], parameters[1], parameters[2]); + const ScalarType angleX = parameters[0]; + const ScalarType angleY = parameters[1]; + const ScalarType angleZ = parameters[2]; + this->SetVarRotation( angleX, angleY, angleZ ); CenterType newCenter; + typedef typename CenterType::ValueType CenterValueType; newCenter[0] = parameters[3]; newCenter[1] = parameters[4]; newCenter[2] = parameters[5]; diff --git a/Utilities/ITK/Code/Common/itkCenteredRigid2DTransform.h b/Utilities/ITK/Code/Common/itkCenteredRigid2DTransform.h index 9c22d5e30fe19e2ca791e758d02d5c3e5cc58b0d..8bd5f92237f32fb1961b1d0e8cad10951425eb08 100644 --- a/Utilities/ITK/Code/Common/itkCenteredRigid2DTransform.h +++ b/Utilities/ITK/Code/Common/itkCenteredRigid2DTransform.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkCenteredRigid2DTransform.h,v $ Language: C++ - Date: $Date: 2009-04-09 09:23:20 $ - Version: $Revision: 1.16 $ + Date: $Date: 2009-11-29 01:38:00 $ + Version: $Revision: 1.18 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -75,7 +75,8 @@ public: typedef typename Superclass::ScalarType ScalarType; /** Parameters type. */ - typedef typename Superclass::ParametersType ParametersType; + typedef typename Superclass::ParametersType ParametersType; + typedef typename Superclass::ParametersValueType ParametersValueType; /** Jacobian type. */ typedef typename Superclass::JacobianType JacobianType; @@ -84,12 +85,14 @@ public: typedef typename Superclass::OffsetType OffsetType; /** Point type. */ - typedef typename Superclass::InputPointType InputPointType; - typedef typename Superclass::OutputPointType OutputPointType; + typedef typename Superclass::InputPointType InputPointType; + typedef typename Superclass::OutputPointType OutputPointType; + typedef typename Superclass::InputPointValueType InputPointValueType; /** Vector type. */ - typedef typename Superclass::InputVectorType InputVectorType; - typedef typename Superclass::OutputVectorType OutputVectorType; + typedef typename Superclass::InputVectorType InputVectorType; + typedef typename Superclass::OutputVectorType OutputVectorType; + typedef typename Superclass::OutputVectorValueType OutputVectorValueType; /** CovariantVector type. */ typedef typename Superclass::InputCovariantVectorType @@ -102,7 +105,7 @@ public: typedef typename Superclass::OutputVnlVectorType OutputVnlVectorType; /** Base inverse transform type. This type should not be changed to the - * concrete inverse transform type or inheritance would be lost.*/ + * concrete inverse transform type or inheritance would be lost. */ typedef typename Superclass::InverseTransformBaseType InverseTransformBaseType; typedef typename InverseTransformBaseType::Pointer InverseTransformBasePointer; diff --git a/Utilities/ITK/Code/Common/itkCenteredRigid2DTransform.txx b/Utilities/ITK/Code/Common/itkCenteredRigid2DTransform.txx index a0913c31031ff458062ab42c4547bdd12f36b142..b2d6700114958d70f6ddab87ade21086129619e7 100644 --- a/Utilities/ITK/Code/Common/itkCenteredRigid2DTransform.txx +++ b/Utilities/ITK/Code/Common/itkCenteredRigid2DTransform.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkCenteredRigid2DTransform.txx,v $ Language: C++ - Date: $Date: 2009-04-09 09:23:20 $ - Version: $Revision: 1.28 $ + Date: $Date: 2010-03-30 15:20:02 $ + Version: $Revision: 1.31 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -60,9 +60,11 @@ CenteredRigid2DTransform<TScalarType> this->m_Parameters = parameters; // Set the angle - this->SetVarAngle( parameters[0] ); + const TScalarType angle = parameters[0]; + this->SetVarAngle( angle ); // Set the center InputPointType center; + for(unsigned int i=0; i < SpaceDimension; i++) { center[i] = parameters[i+1]; @@ -71,6 +73,7 @@ CenteredRigid2DTransform<TScalarType> // Set the translation OutputVectorType translation; + for(unsigned int j=0; j < SpaceDimension; j++) { translation[j] = parameters[j+1+SpaceDimension]; diff --git a/Utilities/ITK/Code/Common/itkCenteredSimilarity2DTransform.h b/Utilities/ITK/Code/Common/itkCenteredSimilarity2DTransform.h index 32c3cb94b9ca94355229cbcdf07749e5858bb622..7638c2d762e4e94302c8deff0ca660c41bab6f6d 100644 --- a/Utilities/ITK/Code/Common/itkCenteredSimilarity2DTransform.h +++ b/Utilities/ITK/Code/Common/itkCenteredSimilarity2DTransform.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkCenteredSimilarity2DTransform.h,v $ Language: C++ - Date: $Date: 2009-04-09 09:23:20 $ - Version: $Revision: 1.7 $ + Date: $Date: 2009-11-29 01:38:00 $ + Version: $Revision: 1.9 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -80,17 +80,20 @@ public: typedef typename Superclass::ScalarType ScalarType; /** Parameters type. */ - typedef typename Superclass::ParametersType ParametersType; + typedef typename Superclass::ParametersType ParametersType; + typedef typename Superclass::ParametersValueType ParametersValueType; /** Jacobian type. */ typedef typename Superclass::JacobianType JacobianType; /** Offset type. */ - typedef typename Superclass::OffsetType OffsetType; + typedef typename Superclass::OffsetType OffsetType; + typedef typename Superclass::OffsetValueType OffsetValueType; /** Point type. */ typedef typename Superclass::InputPointType InputPointType; typedef typename Superclass::OutputPointType OutputPointType; + typedef typename InputPointType::ValueType InputPointValueType; /** Vector type. */ typedef typename Superclass::InputVectorType InputVectorType; @@ -107,7 +110,7 @@ public: typedef typename Superclass::OutputVnlVectorType OutputVnlVectorType; /** Base inverse transform type. This type should not be changed to the - * concrete inverse transform type or inheritance would be lost.*/ + * concrete inverse transform type or inheritance would be lost. */ typedef typename Superclass::InverseTransformBaseType InverseTransformBaseType; typedef typename InverseTransformBaseType::Pointer InverseTransformBasePointer; diff --git a/Utilities/ITK/Code/Common/itkCenteredSimilarity2DTransform.txx b/Utilities/ITK/Code/Common/itkCenteredSimilarity2DTransform.txx index 6579275471e4c03295c2b0536dd1f7cda726be8a..a82dff4489f7d12950aa7860f6c094425ac317e8 100644 --- a/Utilities/ITK/Code/Common/itkCenteredSimilarity2DTransform.txx +++ b/Utilities/ITK/Code/Common/itkCenteredSimilarity2DTransform.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkCenteredSimilarity2DTransform.txx,v $ Language: C++ - Date: $Date: 2009-04-09 09:23:20 $ - Version: $Revision: 1.9 $ + Date: $Date: 2010-03-30 15:20:02 $ + Version: $Revision: 1.12 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -52,10 +52,12 @@ CenteredSimilarity2DTransform<TScalarType> itkDebugMacro( << "Setting parameters " << parameters ); // Set scale - this->SetVarScale(parameters[0]); + const TScalarType scale = parameters[0]; + this->SetVarScale( scale ); // Set angle - this->SetVarAngle( parameters[1] ); + const TScalarType angle = parameters[1]; + this->SetVarAngle( angle ); InputPointType center; for(unsigned int j=0; j < SpaceDimension; j++) @@ -66,6 +68,7 @@ CenteredSimilarity2DTransform<TScalarType> // Set translation OffsetType translation; + for(unsigned int i=0; i < SpaceDimension; i++) { translation[i] = parameters[i+4]; @@ -209,10 +212,9 @@ GetInverse( Self* inverse) const } inverse->SetCenter( this->GetCenter() ); // inverse have the same center - inverse->SetScale( 1.0 / this->GetScale() ); + inverse->SetScale( NumericTraits<double>::One / this->GetScale() ); inverse->SetAngle( -this->GetAngle() ); - inverse->SetTranslation( -( this->GetInverseMatrix() - * this->GetTranslation() ) ); + inverse->SetTranslation( -( this->GetInverseMatrix() * this->GetTranslation() ) ); return true; } @@ -223,7 +225,11 @@ CenteredSimilarity2DTransform<TScalarType> ::GetInverseTransform() const { Pointer inv = New(); - return GetInverse(inv) ? inv.GetPointer() : NULL; + if( this->GetInverse(inv) ) + { + return inv.GetPointer(); + } + return NULL; } // Create and return a clone of the transformation diff --git a/Utilities/ITK/Code/Common/itkCommand.cxx b/Utilities/ITK/Code/Common/itkCommand.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Common/itkComplexToImaginaryImageAdaptor.h b/Utilities/ITK/Code/Common/itkComplexToImaginaryImageAdaptor.h index f27911ea98f68e8e8ac15b04d978ab48037dcd21..1bbbf8eb19edf35ae5104e409e12c37e77e0e210 100644 --- a/Utilities/ITK/Code/Common/itkComplexToImaginaryImageAdaptor.h +++ b/Utilities/ITK/Code/Common/itkComplexToImaginaryImageAdaptor.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkComplexToImaginaryImageAdaptor.h,v $ Language: C++ - Date: $Date: 2006-03-19 23:24:29 $ - Version: $Revision: 1.4 $ + Date: $Date: 2009-09-19 19:56:20 $ + Version: $Revision: 1.5 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -29,7 +29,7 @@ namespace Accessor { * * ComplexToImaginaryPixelAccessor is templated over an internal type and an * external type representation. The internal type is an std::complex<T> and - * the external part is a type T. This class cast the input applies the funtion + * the external part is a type T. This class cast the input applies the function * to it and cast the result according to the types defined as template * parameters * diff --git a/Utilities/ITK/Code/Common/itkComplexToModulusImageAdaptor.h b/Utilities/ITK/Code/Common/itkComplexToModulusImageAdaptor.h index 2d8b2bff8576c6bff3965eae1d67f2700c91021a..2b1968905d22cdbd52891a07d16f1b4abfaece0e 100644 --- a/Utilities/ITK/Code/Common/itkComplexToModulusImageAdaptor.h +++ b/Utilities/ITK/Code/Common/itkComplexToModulusImageAdaptor.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkComplexToModulusImageAdaptor.h,v $ Language: C++ - Date: $Date: 2006-04-01 13:44:21 $ - Version: $Revision: 1.5 $ + Date: $Date: 2009-09-19 19:56:20 $ + Version: $Revision: 1.6 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -29,7 +29,7 @@ namespace Accessor { * * ComplexToModulusPixelAccessor is templated over an internal type and an * external type representation. The internal type is an std::complex<T> and - * the external part is a type T. This class cast the input applies the funtion + * the external part is a type T. This class cast the input applies the function * to it and cast the result according to the types defined as template * parameters * diff --git a/Utilities/ITK/Code/Common/itkComplexToPhaseImageAdaptor.h b/Utilities/ITK/Code/Common/itkComplexToPhaseImageAdaptor.h index c02a985e21d36b63bb9d54b48f12a898935ad8ea..381164dc8bb1667182d387244861441c93bea96a 100644 --- a/Utilities/ITK/Code/Common/itkComplexToPhaseImageAdaptor.h +++ b/Utilities/ITK/Code/Common/itkComplexToPhaseImageAdaptor.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkComplexToPhaseImageAdaptor.h,v $ Language: C++ - Date: $Date: 2006-03-19 23:24:29 $ - Version: $Revision: 1.4 $ + Date: $Date: 2009-09-19 19:56:20 $ + Version: $Revision: 1.5 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -29,7 +29,7 @@ namespace Accessor { * * ComplexToPhasePixelAccessor is templated over an internal type and an * external type representation. The internal type is an std::complex<T> and - * the external part is a type T. This class cast the input applies the funtion + * the external part is a type T. This class cast the input applies the function * to it and cast the result according to the types defined as template * parameters * diff --git a/Utilities/ITK/Code/Common/itkComplexToRealImageAdaptor.h b/Utilities/ITK/Code/Common/itkComplexToRealImageAdaptor.h index 8d1dc0214a7e0853258b9ff7419f88a1764a356e..e02ed631194aa9da7343ab5c76d0fec583c26c6b 100644 --- a/Utilities/ITK/Code/Common/itkComplexToRealImageAdaptor.h +++ b/Utilities/ITK/Code/Common/itkComplexToRealImageAdaptor.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkComplexToRealImageAdaptor.h,v $ Language: C++ - Date: $Date: 2006-03-19 23:24:29 $ - Version: $Revision: 1.3 $ + Date: $Date: 2009-09-19 19:56:20 $ + Version: $Revision: 1.4 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -29,7 +29,7 @@ namespace Accessor { * * ComplexToRealPixelAccessor is templated over an internal type and an * external type representation. The internal type is an std::complex<T> and - * the external part is a type T. This class cast the input applies the funtion + * the external part is a type T. This class cast the input applies the function * to it and cast the result according to the types defined as template * parameters * diff --git a/Utilities/ITK/Code/Common/itkConditionVariable.cxx b/Utilities/ITK/Code/Common/itkConditionVariable.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Common/itkConditionVariable.h b/Utilities/ITK/Code/Common/itkConditionVariable.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Common/itkCosImageAdaptor.h b/Utilities/ITK/Code/Common/itkCosImageAdaptor.h index 32b949d853ce454cd8d0ff1af5686bab599ad4e3..36f3acaba2d9e47469d3d8bee523099345816116 100644 --- a/Utilities/ITK/Code/Common/itkCosImageAdaptor.h +++ b/Utilities/ITK/Code/Common/itkCosImageAdaptor.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkCosImageAdaptor.h,v $ Language: C++ - Date: $Date: 2006-03-19 23:23:38 $ - Version: $Revision: 1.13 $ + Date: $Date: 2009-09-19 19:56:20 $ + Version: $Revision: 1.14 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -29,7 +29,7 @@ namespace Accessor { * * CosPixelAccessor is templated over an internal type and an * external type representation. This class cast the input - * applies the funtion to it and cast the result according + * applies the function to it and cast the result according * to the types defined as template parameters * * \ingroup ImageAdaptors diff --git a/Utilities/ITK/Code/Common/itkDecisionRuleBase.cxx b/Utilities/ITK/Code/Common/itkDecisionRuleBase.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Common/itkDecisionRuleBase.h b/Utilities/ITK/Code/Common/itkDecisionRuleBase.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Common/itkDiffusionTensor3D.h b/Utilities/ITK/Code/Common/itkDiffusionTensor3D.h index ee2eb65f5575e716d43ce6bf295003f5c82450d0..ddade3777ce53a080bdfa5d049930e82bdfb7136 100644 --- a/Utilities/ITK/Code/Common/itkDiffusionTensor3D.h +++ b/Utilities/ITK/Code/Common/itkDiffusionTensor3D.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkDiffusionTensor3D.h,v $ Language: C++ - Date: $Date: 2009-03-23 21:43:57 $ - Version: $Revision: 1.11 $ + Date: $Date: 2010-04-09 21:20:50 $ + Version: $Revision: 1.14 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -22,7 +22,7 @@ #undef DiffusionTensor3D #endif -#include <itkSymmetricSecondRankTensor.h> +#include "itkSymmetricSecondRankTensor.h" namespace itk @@ -101,17 +101,28 @@ public: DiffusionTensor3D(); /** Constructor with initialization. */ - DiffusionTensor3D(const Self& r); DiffusionTensor3D(const Superclass& r); DiffusionTensor3D(const ComponentType& r); DiffusionTensor3D(const ComponentArrayType r); + + /** Constructor to enable casting... */ + template < typename TCoordRepB > + DiffusionTensor3D( const DiffusionTensor3D<TCoordRepB> & pa ) + :SymmetricSecondRankTensor<TComponent,3>(pa) { } /** Pass-through assignment operator for the Array base class. */ - Self& operator= (const Self& r); Self& operator= (const Superclass & r); Self& operator= (const ComponentType& r); Self& operator= (const ComponentArrayType r); + /** Templated Pass-through assignment for the Array base class. */ + template < typename TCoordRepB > + Self& operator= ( const DiffusionTensor3D<TCoordRepB> & pa ) + { + SymmetricSecondRankTensor<TComponent,3>::operator=(pa); + return *this; + } + /** Get Trace value */ AccumulateValueType GetTrace() const; @@ -127,6 +138,7 @@ public: }; } // end namespace itk +#include "itkNumericTraitsDiffusionTensor3DPixel.h" // Define instantiation macro for this template. #define ITK_TEMPLATE_DiffusionTensor3D(_, EXPORT, x, y) namespace itk { \ diff --git a/Utilities/ITK/Code/Common/itkDiffusionTensor3D.txx b/Utilities/ITK/Code/Common/itkDiffusionTensor3D.txx index 949b934e84c9395ead4ddeb37e458065e65dc2f9..1d6202e2d8849acf86f652e582744b61942312e3 100644 --- a/Utilities/ITK/Code/Common/itkDiffusionTensor3D.txx +++ b/Utilities/ITK/Code/Common/itkDiffusionTensor3D.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkDiffusionTensor3D.txx,v $ Language: C++ - Date: $Date: 2008-10-07 09:09:39 $ - Version: $Revision: 1.8 $ + Date: $Date: 2010-03-17 16:34:47 $ + Version: $Revision: 1.9 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -34,16 +34,6 @@ DiffusionTensor3D<T> } -/** - * Constructor with initialization - */ -template<class T> -DiffusionTensor3D<T> -::DiffusionTensor3D( const Self & r ):SymmetricSecondRankTensor<T,3>(r) -{ -} - - /** * Constructor with initialization */ @@ -74,19 +64,6 @@ DiffusionTensor3D<T> } -/** - * Assignment Operator - */ -template<class T> -DiffusionTensor3D<T>& -DiffusionTensor3D<T> -::operator= (const Self& r) -{ - Superclass::operator=(r); - return *this; -} - - /** * Assignment Operator */ diff --git a/Utilities/ITK/Code/Common/itkElasticBodySplineKernelTransform.h b/Utilities/ITK/Code/Common/itkElasticBodySplineKernelTransform.h index 1985d023e98003ff835afb63c87bd3a34553872e..48104218c8e10953191cf4cbe9caa2c8f3608666 100644 --- a/Utilities/ITK/Code/Common/itkElasticBodySplineKernelTransform.h +++ b/Utilities/ITK/Code/Common/itkElasticBodySplineKernelTransform.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkElasticBodySplineKernelTransform.h,v $ Language: C++ - Date: $Date: 2009-06-14 12:30:08 $ - Version: $Revision: 1.37 $ + Date: $Date: 2010-02-26 05:28:25 $ + Version: $Revision: 1.38 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -24,6 +24,8 @@ namespace itk { /** \class ElasticBodySplineKernelTransform + * \brief This class defines the elastic body spline (EBS) transformation. + * * This class defines the elastic body spline (EBS) transformation. * It is implemented in as straightforward a manner as possible from * the IEEE TMI paper by Davis, Khotanzad, Flamig, and Harms, @@ -112,7 +114,7 @@ protected: itkLegacyMacro( virtual const GMatrixType & ComputeG(const InputVectorType& landmarkVector) const ); /** alpha, Alpha is related to Poisson's Ratio (\f$\nu\f$) as - * \$\alpha = 12 ( 1 - \nu ) - 1\f$ + * \f$ \alpha = 12 ( 1 - \nu ) - 1\f$ */ TScalarType m_Alpha; diff --git a/Utilities/ITK/Code/Common/itkEllipsoidInteriorExteriorSpatialFunction.txx b/Utilities/ITK/Code/Common/itkEllipsoidInteriorExteriorSpatialFunction.txx index 15ea0f257547e229d1377ce95e9d494a568c86df..ee21003b1877ac995e188563c5939f1101dcf75d 100644 --- a/Utilities/ITK/Code/Common/itkEllipsoidInteriorExteriorSpatialFunction.txx +++ b/Utilities/ITK/Code/Common/itkEllipsoidInteriorExteriorSpatialFunction.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkEllipsoidInteriorExteriorSpatialFunction.txx,v $ Language: C++ - Date: $Date: 2008-10-07 12:03:53 $ - Version: $Revision: 1.27 $ + Date: $Date: 2009-11-24 02:27:27 $ + Version: $Revision: 1.28 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -28,8 +28,8 @@ EllipsoidInteriorExteriorSpatialFunction<VDimension, TInput> ::EllipsoidInteriorExteriorSpatialFunction() { m_Orientations = NULL; - m_Axes.Fill(1.0); // Lengths of ellipsoid axes. - m_Center.Fill(0.0); // Origin of ellipsoid + m_Axes.Fill(1.0f); // Lengths of ellipsoid axes. + m_Center.Fill(0.0f); // Origin of ellipsoid } template <unsigned int VDimension, typename TInput > diff --git a/Utilities/ITK/Code/Common/itkEuler3DTransform.h b/Utilities/ITK/Code/Common/itkEuler3DTransform.h index 3b8873635e9643da138c119075b81d41dd696ac0..b43f6da06b53328a954c07a17ea4873301aac8e5 100644 --- a/Utilities/ITK/Code/Common/itkEuler3DTransform.h +++ b/Utilities/ITK/Code/Common/itkEuler3DTransform.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkEuler3DTransform.h,v $ Language: C++ - Date: $Date: 2008-10-13 15:36:31 $ - Version: $Revision: 1.14 $ + Date: $Date: 2009-11-28 15:53:14 $ + Version: $Revision: 1.15 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -67,6 +67,7 @@ public: itkStaticConstMacro(ParametersDimension, unsigned int, 6); typedef typename Superclass::ParametersType ParametersType; + typedef typename Superclass::ParametersValueType ParametersValueType; typedef typename Superclass::JacobianType JacobianType; typedef typename Superclass::ScalarType ScalarType; typedef typename Superclass::InputVectorType InputVectorType; diff --git a/Utilities/ITK/Code/Common/itkEuler3DTransform.txx b/Utilities/ITK/Code/Common/itkEuler3DTransform.txx index 4e457c2d9f1739fd8ab0b22e8f1b1f20aca573d4..c661e6b3a49b0216b28166f8ed74418c459b255a 100644 --- a/Utilities/ITK/Code/Common/itkEuler3DTransform.txx +++ b/Utilities/ITK/Code/Common/itkEuler3DTransform.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkEuler3DTransform.txx,v $ Language: C++ - Date: $Date: 2009-04-05 10:56:39 $ - Version: $Revision: 1.25 $ + Date: $Date: 2010-03-30 15:20:02 $ + Version: $Revision: 1.27 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -165,7 +165,7 @@ Euler3DTransform<TScalarType> } else { - m_AngleX = 0; + m_AngleX = NumericTraits< ScalarType >::Zero; double x = this->GetMatrix()[1][1]; double y = -this->GetMatrix()[0][1]; m_AngleZ = vcl_atan2(y,x); @@ -187,7 +187,7 @@ Euler3DTransform<TScalarType> } else { - m_AngleZ = 0; + m_AngleZ = NumericTraits< ScalarType >::Zero; double x = this->GetMatrix()[0][0]; double y = this->GetMatrix()[1][0]; m_AngleY = vcl_atan2(y,x); @@ -204,29 +204,31 @@ Euler3DTransform<TScalarType> ::ComputeMatrix( void ) { // need to check if angles are in the right order - const double cx = vcl_cos(m_AngleX); - const double sx = vcl_sin(m_AngleX); - const double cy = vcl_cos(m_AngleY); - const double sy = vcl_sin(m_AngleY); - const double cz = vcl_cos(m_AngleZ); - const double sz = vcl_sin(m_AngleZ); + const ScalarType cx = vcl_cos(m_AngleX); + const ScalarType sx = vcl_sin(m_AngleX); + const ScalarType cy = vcl_cos(m_AngleY); + const ScalarType sy = vcl_sin(m_AngleY); + const ScalarType cz = vcl_cos(m_AngleZ); + const ScalarType sz = vcl_sin(m_AngleZ); + const ScalarType one = NumericTraits< ScalarType >::One; + const ScalarType zero = NumericTraits< ScalarType >::Zero; Matrix<TScalarType,3,3> RotationX; - RotationX[0][0]=1;RotationX[0][1]=0;RotationX[0][2]=0; - RotationX[1][0]=0;RotationX[1][1]=cx;RotationX[1][2]=-sx; - RotationX[2][0]=0;RotationX[2][1]=sx;RotationX[2][2]=cx; + RotationX[0][0]=one; RotationX[0][1]=zero; RotationX[0][2]=zero; + RotationX[1][0]=zero; RotationX[1][1]=cx; RotationX[1][2]=-sx; + RotationX[2][0]=zero; RotationX[2][1]=sx; RotationX[2][2]=cx; Matrix<TScalarType,3,3> RotationY; - RotationY[0][0]=cy;RotationY[0][1]=0;RotationY[0][2]=sy; - RotationY[1][0]=0;RotationY[1][1]=1;RotationY[1][2]=0; - RotationY[2][0]=-sy;RotationY[2][1]=0;RotationY[2][2]=cy; + RotationY[0][0]=cy; RotationY[0][1]=zero; RotationY[0][2]=sy; + RotationY[1][0]=zero; RotationY[1][1]=one; RotationY[1][2]=zero; + RotationY[2][0]=-sy; RotationY[2][1]=zero; RotationY[2][2]=cy; Matrix<TScalarType,3,3> RotationZ; - RotationZ[0][0]=cz;RotationZ[0][1]=-sz;RotationZ[0][2]=0; - RotationZ[1][0]=sz;RotationZ[1][1]=cz;RotationZ[1][2]=0; - RotationZ[2][0]=0;RotationZ[2][1]=0;RotationZ[2][2]=1; + RotationZ[0][0]=cz; RotationZ[0][1]=-sz; RotationZ[0][2]=zero; + RotationZ[1][0]=sz; RotationZ[1][1]=cz; RotationZ[1][2]=zero; + RotationZ[2][0]=zero; RotationZ[2][1]=zero; RotationZ[2][2]=one; /** Aply the rotation first around Y then X then Z */ if(m_ComputeZYX) diff --git a/Utilities/ITK/Code/Common/itkExceptionObject.cxx b/Utilities/ITK/Code/Common/itkExceptionObject.cxx index 14fea45859725113ecaa67dc0a266ea25b1d79b6..ed87d5008828ebb7682d0c84aba1f7bd750532e2 100644 --- a/Utilities/ITK/Code/Common/itkExceptionObject.cxx +++ b/Utilities/ITK/Code/Common/itkExceptionObject.cxx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkExceptionObject.cxx,v $ Language: C++ - Date: $Date: 2008-10-13 15:36:31 $ - Version: $Revision: 1.17 $ + Date: $Date: 2009-09-21 13:33:11 $ + Version: $Revision: 1.18 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -186,8 +186,10 @@ ExceptionObject & ExceptionObject::operator= ( const ExceptionObject &orig ) { // Note: there is no superclass assignment here, because std::exception::operator= - // appears have a bug on some platforms, including MSVC 2003. As reported by Jouni Kiviniemi: - // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=328570 + // appears have a bug on some platforms, including MSVC 2003. The MSVC 2003 bug is + // described at the Usenet newsgroup microsoft.public.vc.language, June 2, 2008, + // subject "VC7.1 std::exception assignment operator bug (crash) a known issue?" + // http://groups.google.com/group/microsoft.public.vc.language/msg/15b927c8c1130e88 // Assigns its smart pointer: m_ExceptionData = orig.m_ExceptionData; diff --git a/Utilities/ITK/Code/Common/itkExpImageAdaptor.h b/Utilities/ITK/Code/Common/itkExpImageAdaptor.h index d14e9ba454ced789e03c65535afda02f74bfbcc3..9d7885723334a45d9be2d77a6015d7b233bf8d19 100644 --- a/Utilities/ITK/Code/Common/itkExpImageAdaptor.h +++ b/Utilities/ITK/Code/Common/itkExpImageAdaptor.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkExpImageAdaptor.h,v $ Language: C++ - Date: $Date: 2008-10-13 15:36:31 $ - Version: $Revision: 1.13 $ + Date: $Date: 2009-09-19 19:56:20 $ + Version: $Revision: 1.14 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -29,7 +29,7 @@ namespace Accessor { * * ExpPixelAccessor is templated over an internal type and an * external type representation. This class cast the input - * applies the funtion to it and cast the result according + * applies the function to it and cast the result according * to the types defined as template parameters * * \ingroup ImageAdaptors diff --git a/Utilities/ITK/Code/Common/itkExpNegativeImageAdaptor.h b/Utilities/ITK/Code/Common/itkExpNegativeImageAdaptor.h index 6d1950208db8560b16944c193fcab230384f173e..7d9b159cb50fb02f8839173deebec7b43e22a8ad 100644 --- a/Utilities/ITK/Code/Common/itkExpNegativeImageAdaptor.h +++ b/Utilities/ITK/Code/Common/itkExpNegativeImageAdaptor.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkExpNegativeImageAdaptor.h,v $ Language: C++ - Date: $Date: 2008-10-13 15:36:31 $ - Version: $Revision: 1.4 $ + Date: $Date: 2009-09-19 19:56:20 $ + Version: $Revision: 1.5 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -29,7 +29,7 @@ namespace Accessor { * * ExpNegativePixelAccessor is templated over an internal type and an * external type representation. This class cast the input - * applies the funtion to it and cast the result according + * applies the function to it and cast the result according * to the types defined as template parameters * * \ingroup ImageAdaptors diff --git a/Utilities/ITK/Code/Common/itkFiniteCylinderSpatialFunction.txx b/Utilities/ITK/Code/Common/itkFiniteCylinderSpatialFunction.txx index a08bf3b4ba8d960f8b843dceb93e6c45fac107ae..4f5e34611c7beef703296799a79f91531b7c4ac8 100644 --- a/Utilities/ITK/Code/Common/itkFiniteCylinderSpatialFunction.txx +++ b/Utilities/ITK/Code/Common/itkFiniteCylinderSpatialFunction.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkFiniteCylinderSpatialFunction.txx,v $ Language: C++ -Date: $Date: 2009-04-06 16:49:29 $ -Version: $Revision: 1.10 $ +Date: $Date: 2009-11-24 02:27:27 $ +Version: $Revision: 1.11 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -27,10 +27,10 @@ template <unsigned int VDimension, typename TInput> FiniteCylinderSpatialFunction<VDimension, TInput> ::FiniteCylinderSpatialFunction() { - m_Orientation.Fill(1.0); - m_AxisLength = 1.0; // Length of cylinder axis. - m_Radius = 1.0; // Radius of cylinder. - m_Center.Fill(0.0); // Origin of cylinder + m_Orientation.Fill(1.0f); + m_AxisLength = 1.0f; // Length of cylinder axis. + m_Radius = 1.0f; // Radius of cylinder. + m_Center.Fill(0.0f); // Origin of cylinder } template <unsigned int VDimension, typename TInput > diff --git a/Utilities/ITK/Code/Common/itkFiniteDifferenceImageFilter.h b/Utilities/ITK/Code/Common/itkFiniteDifferenceImageFilter.h index 828406ff75bde5d40120bfbb72be9dc86615f1dd..f63a4e4c9ac1b6e8606a179f18243df9c00f2369 100644 --- a/Utilities/ITK/Code/Common/itkFiniteDifferenceImageFilter.h +++ b/Utilities/ITK/Code/Common/itkFiniteDifferenceImageFilter.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkFiniteDifferenceImageFilter.h,v $ Language: C++ - Date: $Date: 2009-02-05 19:04:56 $ - Version: $Revision: 1.40 $ + Date: $Date: 2009-10-19 14:26:45 $ + Version: $Revision: 1.42 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -226,19 +226,8 @@ public: #endif protected: - FiniteDifferenceImageFilter() - { - m_UseImageSpacing = false; - m_ElapsedIterations = 0; - m_DifferenceFunction = 0; - m_NumberOfIterations = NumericTraits<unsigned int>::max(); - m_MaximumRMSError = 0.0; - m_RMSChange = 0.0; - m_State = UNINITIALIZED; - m_ManualReinitialization = false; - this->InPlaceOff(); - } - ~FiniteDifferenceImageFilter() {} + FiniteDifferenceImageFilter(); + ~FiniteDifferenceImageFilter(); void PrintSelf(std::ostream& os, Indent indent) const; /** This method allocates a temporary update container in the subclass. */ @@ -351,6 +340,10 @@ private: FiniteDifferenceImageFilter(const Self&); //purposely not implemented void operator=(const Self&); //purposely not implemented + /** Initialize the values of the Function coefficients. This function will + * also take care of checking whether the image spacing should be taken into + * account or not. */ + void InitializeFunctionCoefficients(); /** Control whether derivatives use spacing of the input image in its calculation. */ diff --git a/Utilities/ITK/Code/Common/itkFiniteDifferenceImageFilter.txx b/Utilities/ITK/Code/Common/itkFiniteDifferenceImageFilter.txx index 8275166a25441ca282cc46b9cc7070d706e005c5..22ad2ac0895d77e1aff514b504bfdfd98bce0aff 100644 --- a/Utilities/ITK/Code/Common/itkFiniteDifferenceImageFilter.txx +++ b/Utilities/ITK/Code/Common/itkFiniteDifferenceImageFilter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkFiniteDifferenceImageFilter.txx,v $ Language: C++ - Date: $Date: 2008-10-16 23:25:41 $ - Version: $Revision: 1.47 $ + Date: $Date: 2009-10-19 15:32:55 $ + Version: $Revision: 1.51 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -24,7 +24,28 @@ #include "itkFiniteDifferenceImageFilter.h" namespace itk { - + +template <class TInputImage, class TOutputImage> +FiniteDifferenceImageFilter<TInputImage, TOutputImage> +::FiniteDifferenceImageFilter() +{ + m_UseImageSpacing = false; + m_ElapsedIterations = 0; + m_DifferenceFunction = 0; + m_NumberOfIterations = NumericTraits<unsigned int>::max(); + m_MaximumRMSError = 0.0; + m_RMSChange = 0.0; + m_State = UNINITIALIZED; + m_ManualReinitialization = false; + this->InPlaceOff(); +} + +template <class TInputImage, class TOutputImage> +FiniteDifferenceImageFilter<TInputImage, TOutputImage> +::~FiniteDifferenceImageFilter() +{ +} + template <class TInputImage, class TOutputImage> void FiniteDifferenceImageFilter<TInputImage, TOutputImage> @@ -39,24 +60,6 @@ FiniteDifferenceImageFilter<TInputImage, TOutputImage> if (this->GetState() == UNINITIALIZED) { - // Set the coefficients for the deriviatives - double coeffs[TInputImage::ImageDimension]; - if (m_UseImageSpacing) - { - for (unsigned int i = 0; i < TInputImage::ImageDimension; i++) - { - coeffs[i] = 1.0 / this->GetInput()->GetSpacing()[i]; - } - } - else - { - for (unsigned int i = 0; i < TInputImage::ImageDimension; i++) - { - coeffs[i] = 1.0; - } - } - m_DifferenceFunction->SetScaleCoefficients(coeffs); - // Allocate the output image this->AllocateOutputs(); @@ -64,6 +67,9 @@ FiniteDifferenceImageFilter<TInputImage, TOutputImage> // directly on the output image and the update buffer. this->CopyInputToOutput(); + // Set the coefficients of the Function and consider the use of images spacing. + this->InitializeFunctionCoefficients(); + // Perform any other necessary pre-iteration initialization. this->Initialize(); @@ -235,6 +241,40 @@ FiniteDifferenceImageFilter<TInputImage, TOutputImage> } +template <class TInputImage, class TOutputImage> +void +FiniteDifferenceImageFilter<TInputImage, TOutputImage> +::InitializeFunctionCoefficients() +{ + // Set the coefficients for the derivatives + double coeffs[TOutputImage::ImageDimension]; + + if ( this->m_UseImageSpacing ) + { + const TOutputImage * outputImage = this->GetOutput(); + if( outputImage == NULL ) + { + itkExceptionMacro("Output image is NULL"); + } + + typedef typename TOutputImage::SpacingType SpacingType; + const SpacingType spacing = outputImage->GetSpacing(); + + for (unsigned int i = 0; i < TOutputImage::ImageDimension; i++) + { + coeffs[i] = 1.0 / spacing[i]; + } + } + else + { + for (unsigned int i = 0; i < TOutputImage::ImageDimension; i++) + { + coeffs[i] = 1.0; + } + } + m_DifferenceFunction->SetScaleCoefficients(coeffs); +} + template <class TInputImage, class TOutputImage> void FiniteDifferenceImageFilter<TInputImage, TOutputImage> diff --git a/Utilities/ITK/Code/Common/itkFixedArray.h b/Utilities/ITK/Code/Common/itkFixedArray.h index 7d0a66dccbe355e2749970725af4abdaee37401b..0d50b132a7f31367ff8f8377a82671fd6aaaed4d 100644 --- a/Utilities/ITK/Code/Common/itkFixedArray.h +++ b/Utilities/ITK/Code/Common/itkFixedArray.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkFixedArray.h,v $ Language: C++ - Date: $Date: 2009-07-09 18:06:39 $ - Version: $Revision: 1.45 $ + Date: $Date: 2009-11-28 09:15:37 $ + Version: $Revision: 1.46 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -140,6 +140,7 @@ public: /** Constructors */ FixedArray(); FixedArray(const ValueType r[VLength]); + FixedArray(const ValueType& r); /** Constructor to initialize a fixed array from another of any data type */ template< class TFixedArrayValueType > diff --git a/Utilities/ITK/Code/Common/itkFixedArray.txx b/Utilities/ITK/Code/Common/itkFixedArray.txx index 3547f881e2187cd23a67303b21e1949bba343b5d..0926b2f77230a82a85d060f41e0ffff4073fe26d 100644 --- a/Utilities/ITK/Code/Common/itkFixedArray.txx +++ b/Utilities/ITK/Code/Common/itkFixedArray.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkFixedArray.txx,v $ Language: C++ - Date: $Date: 2008-10-16 13:28:49 $ - Version: $Revision: 1.24 $ + Date: $Date: 2009-11-28 09:15:37 $ + Version: $Revision: 1.25 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -33,6 +33,19 @@ FixedArray<TValueType, VLength> { } +/** + * Constructor to initialize entire array to one value. + */ +template <typename TValueType, unsigned int VLength> +FixedArray<TValueType, VLength> +::FixedArray(const ValueType& r) +{ + for(Iterator i = Begin(); i != End(); ++i) + { + *i = r; + } +} + /** * Constructor assumes input points to array of correct size. * Values are copied individually instead of with a binary copy. This diff --git a/Utilities/ITK/Code/Common/itkFrustumSpatialFunction.txx b/Utilities/ITK/Code/Common/itkFrustumSpatialFunction.txx index 257f39ed04e26bc4d24db232dc2168e5689b83e8..c2d20212143f1de237d14a6f0c62eb32a2b6cf30 100644 --- a/Utilities/ITK/Code/Common/itkFrustumSpatialFunction.txx +++ b/Utilities/ITK/Code/Common/itkFrustumSpatialFunction.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkFrustumSpatialFunction.txx,v $ Language: C++ - Date: $Date: 2008-10-16 23:25:41 $ - Version: $Revision: 1.11 $ + Date: $Date: 2009-11-24 02:27:27 $ + Version: $Revision: 1.12 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -27,13 +27,13 @@ FrustumSpatialFunction<VImageDimension,TInput>::FrustumSpatialFunction() { for (unsigned int i = 0; i < m_Apex.GetPointDimension(); i++) { - m_Apex[i] = 0.0; + m_Apex[i] = 0.0f; } - m_AngleZ = 0.0; - m_ApertureAngleX = 0.0; - m_ApertureAngleY = 0.0; - m_TopPlane = 0.0; - m_BottomPlane = 0.0; + m_AngleZ = 0.0f; + m_ApertureAngleX = 0.0f; + m_ApertureAngleY = 0.0f; + m_TopPlane = 0.0f; + m_BottomPlane = 0.0f; m_RotationPlane = RotateInXZPlane; } diff --git a/Utilities/ITK/Code/Common/itkImage.h b/Utilities/ITK/Code/Common/itkImage.h index 6bbbafa8a9bd53df522bcb873df0daff3af74879..25f58ddc329fe31d09b55f8c1f5ccdc7762f5513 100644 --- a/Utilities/ITK/Code/Common/itkImage.h +++ b/Utilities/ITK/Code/Common/itkImage.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkImage.h,v $ Language: C++ - Date: $Date: 2009-08-14 13:28:21 $ - Version: $Revision: 1.151 $ + Date: $Date: 2010-04-09 23:22:45 $ + Version: $Revision: 1.152 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -284,7 +284,7 @@ public: protected: Image(); void PrintSelf(std::ostream& os, Indent indent) const; - virtual ~Image() {}; + virtual ~Image() {} /** Compute helper matrices used to transform Index coordinates to * PhysicalPoint coordinates and back. This method is virtual and will be diff --git a/Utilities/ITK/Code/Common/itkImageBase.h b/Utilities/ITK/Code/Common/itkImageBase.h index 9568955914832f85a2b8926f48b5da0a47b9b2b5..9da3139d73f326dadf105a434244b96f9868f492 100644 --- a/Utilities/ITK/Code/Common/itkImageBase.h +++ b/Utilities/ITK/Code/Common/itkImageBase.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkImageBase.h,v $ Language: C++ - Date: $Date: 2009-07-12 10:52:52 $ - Version: $Revision: 1.81 $ + Date: $Date: 2009-12-14 16:28:26 $ + Version: $Revision: 1.83 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -387,7 +387,7 @@ public: sum += this->m_PhysicalPointToIndex[i][j] * (point[j] - this->m_Origin[j]); } #ifdef ITK_USE_CENTERED_PIXEL_COORDINATES_CONSISTENTLY - index[i] = static_cast< IndexValueType>( itk::Math::RoundHalfIntegerUp( sum ) ); + index[i] = Math::RoundHalfIntegerUp< IndexValueType>( sum ); #else index[i] = static_cast< IndexValueType>( sum ); #endif @@ -557,6 +557,15 @@ public: * origin, etc. */ virtual void UpdateOutputInformation(); + /** Overriden from base class to check if the requested image region + * has zero pixels. + * + * This is needed so that filters can set an input's requested + * region to zero, to indicate that it does not need to be updated + * or executed. + */ + virtual void UpdateOutputData(); + /** Set the RequestedRegion to the LargestPossibleRegion. This * forces a filter to produce all of the output in one execution * (i.e. not streaming) on the next call to Update(). */ diff --git a/Utilities/ITK/Code/Common/itkImageBase.txx b/Utilities/ITK/Code/Common/itkImageBase.txx index ba3465f7c7b94159184e399831a796a63cb6fe7c..7b08abe92d495bb6490c3898a015752eb3ceeeb1 100644 --- a/Utilities/ITK/Code/Common/itkImageBase.txx +++ b/Utilities/ITK/Code/Common/itkImageBase.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkImageBase.txx,v $ Language: C++ - Date: $Date: 2009-08-15 08:03:36 $ - Version: $Revision: 1.60 $ + Date: $Date: 2010-01-21 15:51:32 $ + Version: $Revision: 1.63 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -258,6 +258,38 @@ ImageBase<VImageDimension> } } +template<unsigned int VImageDimension> +void +ImageBase<VImageDimension> +::UpdateOutputData() +{ + // If the requested region does not contain any pixels then there is + // no reason to Update the output data. This is needed so that + // filters don't need to update all inputs. This occours in + // ImageBase as oppose to DataObject, but cause this statement + // requires the specific GetNumberOfPixels methods ( as oppose to a + // generic Region::IsEmpty method ). + // + // Also note, the check of the largest possible region is needed so + // that an exception will be thrown in the process object when no + // input has been set. ( This part of the statement could be removed + // if this check happened earlier in the pipeline ) + if( this->GetRequestedRegion().GetNumberOfPixels() > 0 + || this->GetLargestPossibleRegion().GetNumberOfPixels() == 0 ) + { + this->Superclass::UpdateOutputData(); + } +// if ITK_LEGACY_SILENT or ITK_LEGACY_REMOVE is enabled then we don't +// print the waring message +#if !defined(ITK_LEGACY_SILENT) && !defined(ITK_LEGACY_REMOVE) + else + { + // Let us try to give a warning of this change in behavior. + itkWarningMacro(<<"Not executing UpdateOutputData due to zero pixel condition RequestedRegion:" + << this->GetRequestedRegion() << " BufferedRegion: " << this->GetBufferedRegion()); + } +#endif // !ITK_LEGACY_SILENT && !ITK_LEGACY_REMOVE +} //---------------------------------------------------------------------------- template<unsigned int VImageDimension> diff --git a/Utilities/ITK/Code/Common/itkImageFunction.h b/Utilities/ITK/Code/Common/itkImageFunction.h index 3df0b84d891d0e4cd7b2649801f5c35f1742b7bc..41c34b26a285587f71629179a9fdd4902a2ffa51 100644 --- a/Utilities/ITK/Code/Common/itkImageFunction.h +++ b/Utilities/ITK/Code/Common/itkImageFunction.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkImageFunction.h,v $ Language: C++ - Date: $Date: 2009-06-01 13:39:10 $ - Version: $Revision: 1.49 $ + Date: $Date: 2009-10-29 11:18:33 $ + Version: $Revision: 1.50 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -94,7 +94,8 @@ public: typedef TCoordRep CoordRepType; /** Index Type. */ - typedef typename InputImageType::IndexType IndexType; + typedef typename InputImageType::IndexType IndexType; + typedef typename InputImageType::IndexValueType IndexValueType; /** ContinuousIndex Type. */ typedef ContinuousIndex<TCoordRep,itkGetStaticConstMacro(ImageDimension)> diff --git a/Utilities/ITK/Code/Common/itkImageFunction.txx b/Utilities/ITK/Code/Common/itkImageFunction.txx index a04a9ffcb5a37cbe8cc9a783a630b9427edd6943..10b33d233104200ab89822bba342dd54fa44f32e 100644 --- a/Utilities/ITK/Code/Common/itkImageFunction.txx +++ b/Utilities/ITK/Code/Common/itkImageFunction.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkImageFunction.txx,v $ Language: C++ - Date: $Date: 2009-05-07 14:03:44 $ - Version: $Revision: 1.18 $ + Date: $Date: 2009-11-24 02:27:27 $ + Version: $Revision: 1.20 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -32,8 +32,8 @@ ImageFunction<TInputImage, TOutput, TCoordRep> m_Image = NULL; m_StartIndex.Fill(0); m_EndIndex.Fill(0); - m_StartContinuousIndex.Fill(0.0); - m_EndContinuousIndex.Fill(0.0); + m_StartContinuousIndex.Fill(0.0f); + m_EndContinuousIndex.Fill(0.0f); } @@ -70,7 +70,6 @@ ImageFunction<TInputImage, TOutput, TCoordRep> if ( ptr ) { - typedef typename IndexType::IndexValueType IndexValueType; typename InputImageType::SizeType size = ptr->GetBufferedRegion().GetSize(); m_StartIndex = ptr->GetBufferedRegion().GetIndex(); diff --git a/Utilities/ITK/Code/Common/itkImageRegion.h b/Utilities/ITK/Code/Common/itkImageRegion.h index 937a989a5b4abd532c538191bb12f94457a7ba8e..ccd2354d600eec2fd931e9ecd23595f0b811f849 100644 --- a/Utilities/ITK/Code/Common/itkImageRegion.h +++ b/Utilities/ITK/Code/Common/itkImageRegion.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkImageRegion.h,v $ Language: C++ - Date: $Date: 2009-07-12 23:19:57 $ - Version: $Revision: 1.35 $ + Date: $Date: 2009-12-18 19:56:48 $ + Version: $Revision: 1.37 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -180,7 +180,7 @@ public: { return false; } - if( index[i] >= (m_Index[i] + static_cast<long>(m_Size[i])) ) + if( index[i] >= (m_Index[i] + static_cast<IndexValueType>(m_Size[i])) ) { return false; } @@ -200,7 +200,7 @@ public: for(unsigned int i=0; i<ImageDimension; i++) { #ifdef ITK_USE_CENTERED_PIXEL_COORDINATES_CONSISTENTLY - if( itk::Math::RoundHalfIntegerUp(index[i]) < static_cast<int>( m_Index[i] ) ) + if( Math::RoundHalfIntegerUp<IndexValueType>(index[i]) < static_cast<IndexValueType>( m_Index[i] ) ) #else if( index[i] < static_cast<TCoordRepType>( m_Index[i] ) ) #endif @@ -213,7 +213,7 @@ public: m_Index[i] + m_Size[i] - 0.5); #else const TCoordRepType bound = static_cast<TCoordRepType>( - m_Index[i] + static_cast<long>(m_Size[i]) - 1); + m_Index[i] + static_cast<IndexValueType>(m_Size[i]) - 1); #endif if( index[i] > bound ) @@ -224,7 +224,10 @@ public: return true; } - /** Test if a region (the argument) is completely inside of this region */ + /** Test if a region (the argument) is completely inside of this region. If + * the region that is passed as argument to this method, has a size of value + * zero, then it will not be considered to be inside of the current region, + * even its starting index is inside. */ bool IsInside(const Self ®ion) const { diff --git a/Utilities/ITK/Code/Common/itkImageRegionMultidimensionalSplitter.txx b/Utilities/ITK/Code/Common/itkImageRegionMultidimensionalSplitter.txx index 87effec8aa03f328e3877952431240afb02cf05f..49cefb00cd2510cc8c7279b3204e0cb41bfe33b7 100644 --- a/Utilities/ITK/Code/Common/itkImageRegionMultidimensionalSplitter.txx +++ b/Utilities/ITK/Code/Common/itkImageRegionMultidimensionalSplitter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkImageRegionMultidimensionalSplitter.txx,v $ Language: C++ - Date: $Date: 2009-04-06 13:46:38 $ - Version: $Revision: 1.10 $ + Date: $Date: 2009-11-03 12:24:19 $ + Version: $Revision: 1.11 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -99,8 +99,7 @@ ImageRegionMultidimensionalSplitter<VImageDimension> else { splits[j] = (unsigned int) splitsPerDimension; - pixelsPerSplit[j] = (unsigned int) vcl_ceil(regionSize[j] - / (double) splits[j]); + pixelsPerSplit[j] = Math::Ceil<unsigned int>( regionSize[j] / (double) splits[j] ); numPieces *= (unsigned int) splitsPerDimension; } } diff --git a/Utilities/ITK/Code/Common/itkImageRegionSplitter.txx b/Utilities/ITK/Code/Common/itkImageRegionSplitter.txx index 3014d623b8a7ce52be5c8c727ccb98c1578fa9e6..b303bb8dee14f8a190beff24904fecee07d59263 100644 --- a/Utilities/ITK/Code/Common/itkImageRegionSplitter.txx +++ b/Utilities/ITK/Code/Common/itkImageRegionSplitter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkImageRegionSplitter.txx,v $ Language: C++ - Date: $Date: 2009-04-06 13:46:38 $ - Version: $Revision: 1.9 $ + Date: $Date: 2009-11-03 12:24:21 $ + Version: $Revision: 1.10 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -48,8 +48,8 @@ ImageRegionSplitter<VImageDimension> // determine the actual number of pieces that will be generated SizeValueType range = regionSize[splitAxis]; - int valuesPerPiece = (int)vcl_ceil(range/(double)requestedNumber); - int maxPieceUsed = (int)vcl_ceil(range/(double)valuesPerPiece) - 1; + int valuesPerPiece = Math::Ceil<int>(range/(double)requestedNumber); + int maxPieceUsed = Math::Ceil<int>(range/(double)valuesPerPiece) - 1; return maxPieceUsed + 1; } @@ -90,8 +90,8 @@ ImageRegionSplitter<VImageDimension> // determine the actual number of pieces that will be generated SizeValueType range = regionSize[splitAxis]; - int valuesPerPiece = (int)vcl_ceil(range/(double)numberOfPieces); - int maxPieceUsed = (int)vcl_ceil(range/(double)valuesPerPiece) - 1; + int valuesPerPiece = Math::Ceil<int>(range/(double)numberOfPieces); + int maxPieceUsed = Math::Ceil<int>(range/(double)valuesPerPiece) - 1; // Split the region if ((int) i < maxPieceUsed) diff --git a/Utilities/ITK/Code/Common/itkImageSource.txx b/Utilities/ITK/Code/Common/itkImageSource.txx index d97f6435547435d3acb4c623800eebff81eacfb0..9566756369d60f4b9cce87360098848761b30a41 100644 --- a/Utilities/ITK/Code/Common/itkImageSource.txx +++ b/Utilities/ITK/Code/Common/itkImageSource.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkImageSource.txx,v $ Language: C++ - Date: $Date: 2009-08-26 19:09:35 $ - Version: $Revision: 1.68 $ + Date: $Date: 2009-11-03 12:24:24 $ + Version: $Revision: 1.69 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -165,8 +165,8 @@ ImageSource<TOutputImage> // determine the actual number of pieces that will be generated typename TOutputImage::SizeType::SizeValueType range = requestedRegionSize[splitAxis]; - int valuesPerThread = (int)::vcl_ceil(range/(double)num); - int maxThreadIdUsed = (int)::vcl_ceil(range/(double)valuesPerThread) - 1; + int valuesPerThread = Math::Ceil<int>(range/(double)num); + int maxThreadIdUsed = Math::Ceil<int>(range/(double)valuesPerThread) - 1; // Split the region if (i < maxThreadIdUsed) diff --git a/Utilities/ITK/Code/Common/itkImageTransformHelper.h b/Utilities/ITK/Code/Common/itkImageTransformHelper.h index 83900db2ea0406964654827c73f00ab023c68e0e..d61214feda51cdc65141b6d2a42863cbf0453a3f 100644 --- a/Utilities/ITK/Code/Common/itkImageTransformHelper.h +++ b/Utilities/ITK/Code/Common/itkImageTransformHelper.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkImageTransformHelper.h,v $ Language: C++ - Date: $Date: 2009-05-07 14:03:45 $ - Version: $Revision: 1.12 $ + Date: $Date: 2009-10-27 20:25:10 $ + Version: $Revision: 1.15 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -32,15 +32,16 @@ template <unsigned int NImageDimension, unsigned int R, unsigned int C> class ImageTransformHelper { public: - typedef ImageBase<NImageDimension> ImageType; - typedef typename ImageType::IndexType IndexType; - typedef typename ImageType::SpacingType SpacingType; - typedef Matrix<double, NImageDimension, NImageDimension> MatrixType; - typedef typename ImageType::PointType OriginType; - typedef Point<double, NImageDimension> DoublePoint; - typedef Point<float, NImageDimension> FloatPoint; - typedef Concept::Detail::UniqueType_bool<false> UniqueTypeBoolFalse; - typedef Concept::Detail::UniqueType_bool<true> UniqueTypeBoolTrue; + typedef ImageBase<NImageDimension> ImageType; + typedef typename ImageType::IndexType IndexType; + typedef typename ImageBase<NImageDimension>::IndexValueType IndexValueType; + typedef typename ImageType::SpacingType SpacingType; + typedef Matrix<double, NImageDimension, NImageDimension> MatrixType; + typedef typename ImageType::PointType OriginType; + typedef Point<double, NImageDimension> DoublePoint; + typedef Point<float, NImageDimension> FloatPoint; + typedef Concept::Detail::UniqueType_bool<false> UniqueTypeBoolFalse; + typedef Concept::Detail::UniqueType_bool<true> UniqueTypeBoolTrue; // // Methods with DoublePoint @@ -175,9 +176,9 @@ public: const UniqueTypeBoolTrue& ) { #ifdef ITK_USE_CENTERED_PIXEL_COORDINATES_CONSISTENTLY - index[R] = static_cast<typename IndexType::IndexValueType>( itk::Math::RoundHalfIntegerUp( rindex[R] ) ); + index[R] = Math::RoundHalfIntegerUp<IndexValueType>( rindex[R] ); #else - index[R] = static_cast<typename IndexType::IndexValueType>(rindex[R]); + index[R] = static_cast<IndexValueType>(rindex[R]); #endif } @@ -314,10 +315,9 @@ public: const UniqueTypeBoolTrue& ) { #ifdef ITK_USE_CENTERED_PIXEL_COORDINATES_CONSISTENTLY - index[R] = static_cast<typename IndexType::IndexValueType>( - itk::Math::RoundHalfIntegerUp(rindex[R]) ); + index[R] = Math::RoundHalfIntegerUp<IndexValueType>(rindex[R]); #else - index[R] = static_cast<typename IndexType::IndexValueType>(rindex[R]); + index[R] = static_cast<IndexValueType>(rindex[R]); #endif } diff --git a/Utilities/ITK/Code/Common/itkIndex.h b/Utilities/ITK/Code/Common/itkIndex.h index 83e4fe5b11c8973829293cac6c5d5fdaa735b325..b2e5e072ce29049ae62a6dff5e2b46b9fbb9dbd5 100644 --- a/Utilities/ITK/Code/Common/itkIndex.h +++ b/Utilities/ITK/Code/Common/itkIndex.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkIndex.h,v $ Language: C++ - Date: $Date: 2009-07-12 10:52:52 $ - Version: $Revision: 1.64 $ + Date: $Date: 2009-10-27 16:06:22 $ + Version: $Revision: 1.66 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -21,6 +21,7 @@ #include "itkOffset.h" #include "itkSize.h" #include "itkFixedArray.h" +#include "itkMath.h" #include <memory> @@ -269,7 +270,7 @@ public: #else for(unsigned int i=0;i < VIndexDimension; ++i) { - m_Index[i] = static_cast< IndexValueType>( itk::Math::Round( point[i] ) ); + m_Index[i] = Math::Round<IndexValueType>( point[i] ); } #endif } diff --git a/Utilities/ITK/Code/Common/itkIntTypes.h b/Utilities/ITK/Code/Common/itkIntTypes.h index 8789822f5d75b7d34547261861b4ebcc6410f00f..bae7e9b6afce81873c1defc1ec35405e31bf2b78 100644 --- a/Utilities/ITK/Code/Common/itkIntTypes.h +++ b/Utilities/ITK/Code/Common/itkIntTypes.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkIntTypes.h,v $ Language: C++ - Date: $Date: 2009-02-05 19:04:58 $ - Version: $Revision: 1.7 $ + Date: $Date: 2010-03-30 17:57:39 $ + Version: $Revision: 1.11 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -17,39 +17,187 @@ #ifndef __itkIntTypes_h #define __itkIntTypes_h +#include "itkConfigure.h" + +#if defined(ITK_HAVE_STDINT_H) +#include <stdint.h> +#define ITK_HAS_INT_64 +#else +// the system doesn't have the C or C++ version of stdint so lets use +// itksys's types for fixed widths +#include "itksys/FundamentalType.h" + +#ifdef ITK_HAVE_STDDEF_H +#include <stddef.h> +#endif //ITK_HAVE_STDDEF_H + +#if defined(itksys_CAN_CONVERT_UI64_TO_DOUBLE) && ( itksys_SIZEOF_LONG == 8 || itksys_USE_LONG_LONG == 8 ) +#define ITK_HAS_INT_64 +#endif + +#endif // ITK_HAVE_CSTDINT + + +#if !defined(ITK_LEGACY_REMOVE) #ifdef __cplusplus extern "C" { #endif - /** Convenient and more descriptive integer types. */ + /** \deprecated This type have been deprecated due to erroneous + * value, please use itk::int8_t instead. */ typedef char ITK_INT8; + + /** \deprecated This type have been deprecated due to erroneous + * value, please use itk::int32_8 instead. */ typedef int ITK_INT32; #ifndef _WIN32 + /** \deprecated This type have been deprecated due to erroneous + * value, please use itk::int64_t instead. */ typedef long long ITK_INT64; #endif #ifdef _WIN32 + typedef long ITK_INT64; #endif + /** \deprecated This type have been deprecated due to erroneous + * value, please use itk::uint8_t instead. */ typedef unsigned char ITK_UINT8; + + /** \deprecated This type have been deprecated due to erroneous + * value, please use itk::uint16_t instead. */ typedef unsigned short ITK_UINT16; + + /** \deprecated This type have been deprecated due to erroneous + * value, please use itk::uint32_t instead. */ typedef unsigned ITK_UINT32; #ifndef _WIN32 + /** \deprecated This type have been deprecated due to erroneous + * value, please use itk::uint64_t instead. */ typedef unsigned long long ITK_UINT64; #endif #ifdef _WIN32 + typedef unsigned long ITK_UINT64; #endif + /** \deprecated This type have been deprecated due to erroneous + * value, please use itk::intptr_t instead. */ typedef int ITK_INTPTR; + + /** \deprecated This type have been deprecated due to erroneous + * value, please use itk::uintptr_t instead. */ typedef unsigned ITK_UINTPTR; #ifdef __cplusplus } #endif +#endif // ITK_LEGACY_REMOVE + +namespace itk +{ +#if defined(ITK_HAVE_STDINT_H) + +// Note: these types are technically optional in C99 stdint.h file. As +// such a try complile for their existance may be needed. +typedef ::int8_t int8_t; +typedef ::uint8_t uint8_t; +typedef ::int16_t int16_t; +typedef ::uint16_t uint16_t; +typedef ::int32_t int32_t; +typedef ::uint32_t uint32_t; +typedef ::int64_t int64_t; +typedef ::uint64_t uint64_t; + + +// Note: these types are required for the C99 stdint.h file. However, +// not all C++ systems have a fully functional 64-bit integer. +typedef ::int_least8_t int_least8_t; +typedef ::uint_least8_t uint_least8_t; +typedef ::int_least16_t int_least16_t; +typedef ::uint_least16_t uint_least16_t; +typedef ::int_least32_t int_least32_t; +typedef ::uint_least32_t uint_least32_t; +typedef ::int_least64_t int_least64_t; +typedef ::uint_least64_t uint_least64_t; + + +// Note: these types are required for the C99 stdint.h file. However, +// not all C++ systems have a fully functional 64-bit integer. +typedef ::int_fast8_t int_fast8_t; +typedef ::uint_fast8_t uint_fast8_t; +typedef ::int_fast16_t int_fast16_t; +typedef ::uint_fast16_t uint_fast16_t; +typedef ::int_fast32_t int_fast32_t; +typedef ::uint_fast32_t uint_fast32_t; +typedef ::int_fast64_t int_fast64_t; +typedef ::uint_fast64_t uint_fast64_t; + +typedef ::intmax_t intmax_t; +typedef ::uintmax_t uintmax_t; + +typedef ::intptr_t intptr_t; +typedef ::uintptr_t uintptr_t; + +#else // ITK_HAVE_STDINT_H || ITK_HAVE_CSTDINT + +/** Fixed width interger types. */ +typedef ::itksysFundamentalType_Int8 int8_t; +typedef ::itksysFundamentalType_UInt8 uint8_t; +typedef ::itksysFundamentalType_Int16 int16_t; +typedef ::itksysFundamentalType_UInt16 uint16_t; +typedef ::itksysFundamentalType_Int32 int32_t; +typedef ::itksysFundamentalType_UInt32 uint32_t; + +/** Types which are at least a certain size, these are prefered over + * fixed width. */ +typedef int8_t int_least8_t; +typedef uint8_t uint_least8_t; +typedef int16_t int_least16_t; +typedef uint16_t uint_least16_t; +typedef int32_t int_least32_t; +typedef uint32_t uint_least32_t; + +/** Types which are at least a certain size but may be greater if + * performace benifits, these are prefered over fixed width. */ +typedef int8_t int_fast8_t; +typedef uint8_t uint_fast8_t; +typedef int16_t int_fast16_t; +typedef uint16_t uint_fast16_t; +typedef int32_t int_fast32_t; +typedef uint32_t uint_fast32_t; + +#ifndef ITK_HAS_INT_64 + +typedef int32_t intmax_t; +typedef uint32_t uintmax_t; + +#else // ITK_HAS_INT_64 + +/** Optional 64-bit sized types. As not all systems have 64-bit + * integers, usage of these types must conditional on the + * preprocessor definition of ITK_HAS_INT_64. */ +typedef ::itksysFundamentalType_Int64 int64_t; +typedef ::itksysFundamentalType_UInt64 uint64_t; +typedef int64_t int_least64_t; +typedef uint64_t uint_least64_t; +typedef int64_t int_fast64_t; +typedef uint64_t uint_fast64_t; + +/** Types which contain the largest represetable integer. */ +typedef int64_t intmax_t; +typedef uint64_t uintmax_t; + +#endif // ITK_HAS_INT_64 + +typedef ::ptrdiff_t intptr_t; +typedef ::size_t uintptr_t; + +#endif // ITK_HAVE_STDINT_H +} #endif /* __itkIntTypes_h */ diff --git a/Utilities/ITK/Code/Common/itkInternationalizationIOHelpers.h b/Utilities/ITK/Code/Common/itkInternationalizationIOHelpers.h new file mode 100644 index 0000000000000000000000000000000000000000..590a297f9ca492b5d05f2191d0f7a66535b10bfa --- /dev/null +++ b/Utilities/ITK/Code/Common/itkInternationalizationIOHelpers.h @@ -0,0 +1,271 @@ +/*========================================================================= + + Program: Insight Segmentation & Registration Toolkit + Module: $RCSfile: itkInternationalizationIOHelpers.h,v $ + Language: C++ + Date: $Date: 2010-01-13 20:16:01 $ + Version: $Revision: 1.3 $ + + Copyright (c) Insight Software Consortium. All rights reserved. + See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef __itkInternationalizationIOHelpers_h +#define __itkInternationalizationIOHelpers_h + +// This header provides some helper functions to deal with unicode filenames +// It is mainly directed towards being able to use utf-8 encoded filenames +// on windows. +// This should help better dealing with internationalization (a.k.a i18n) + +#include "itkConfigure.h" +#include "itkMacro.h" + +#ifdef ITK_HAVE_UNISTD_H +# include <unistd.h> // for unlink +#else +# include <io.h> +#endif + +#include <stdio.h> // Borland needs this (cstdio does not work easy) +#include <fcntl.h> +#include <iostream> +#include <string> +#include <sys/stat.h> + +// Find out how to handle unicode filenames on windows: +// * VS>=8.0 has _wopen and _wfopen and can open a (i/o)fstream using a wide string +// * cygwin has NO _wopen an NO _wfopen. If you really need unicode +// filenames on cygwin, just use cygwin >= 1.7 for now, it works with utf8 +// natively. Alternatively, we could try and use pure win32 functions such as +// CreateFileW and convert the win32 file handle using _open_osfhandle and _fdopen +// * VS6.0 has _wopen and _wfopen but cannot open a (i/o)fstream using a wide string +// nor can it compile fdstream => disable unicode filename support +// * Borland c++, VS7.x and MinGW have _wopen and _wfopen but cannot open a +// (i/o)fstream using a wide string. They can however compile fdstream + +#if defined(ITK_SUPPORTS_WCHAR_T_FILENAME_CSTYLEIO) \ + && ( defined(ITK_SUPPORTS_WCHAR_T_FILENAME_IOSTREAMS_CONSTRUCTORS) || defined(ITK_SUPPORTS_FDSTREAM_HPP) ) +# define LOCAL_USE_WIN32_WOPEN 1 +# include <windows.h> // required by winnls.h +# include <winnls.h> // for MultiByteToWideChar +#else +# define LOCAL_USE_WIN32_WOPEN 0 +#endif + +#if (LOCAL_USE_WIN32_WOPEN && defined(ITK_SUPPORTS_WCHAR_T_FILENAME_IOSTREAMS_CONSTRUCTORS)) \ + || (!LOCAL_USE_WIN32_WOPEN) +# define LOCAL_USE_FDSTREAM 0 +# include <fstream> +#else +# define LOCAL_USE_FDSTREAM 1 +# include "fdstream.hpp" +#endif + + +namespace itk +{ +namespace i18n +{ + +// Check if the string is correctly encoded +#if LOCAL_USE_WIN32_WOPEN +inline bool IsStringEncodingValid(const std::string & str) +{ + // Check if the string is really encoded in utf-8 using windows API + // MultiByteToWideChar returns 0 if there was a problem during conversion + // when given the MB_ERR_INVALID_CHARS flag + const int utf16_size = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, str.c_str(), + static_cast<int>(str.length()), 0, 0); + return (utf16_size != 0); +} +#else +inline bool IsStringEncodingValid(const std::string & itkNotUsed( str ) ) +{ + return true; +} +#endif + +#if LOCAL_USE_WIN32_WOPEN +// Convert a utf8 encoded std::string to a utf16 encoded wstring on windows +inline std::wstring Utf8StringToWString( const std::string & str ) +{ + // We do not set the MB_ERR_INVALID_CHARS to do an approximate conversion when non + // utf8 characters are found. An alternative would be to throw an exception + + // First get the size + const int utf16_size = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), + static_cast<int>(str.length()), 0, 0); + + // Now do the conversion + std::wstring wstr; + wstr.resize(utf16_size); + MultiByteToWideChar(CP_UTF8, 0, str.c_str(), + static_cast<int>(str.length()), &wstr[0], utf16_size); + + return wstr; +} + +#endif + +// Get a file descriptor from a filename (using utf8 to wstring +// on windows if requested) without specifying any specific permissions +inline int I18nOpen( const std::string & str, const int & flags ) +{ +#if LOCAL_USE_WIN32_WOPEN + // cygwin has NO _wopen but mingw has + // If you really need unicode filenames on cygwin, just use cygwin >= 1.7 + // Convert to utf16 + const std::wstring str_utf16 = Utf8StringToWString( str ); + return _wopen(str_utf16.c_str(), flags); +#else + return open(str.c_str(), flags); +#endif +} + +// Get a file descriptor from a filename (using utf8 to wstring +// on windows if requested) +inline int I18nOpen( const std::string & str, const int & flags, const int & mode ) +{ +#if LOCAL_USE_WIN32_WOPEN + // cygwin has NO _wopen but mingw has + // If you really need unicode filenames on cygwin, just use cygwin >= 1.7 + // Convert to utf16 + const std::wstring str_utf16 = Utf8StringToWString( str ); + return _wopen(str_utf16.c_str(), flags, mode); +#else + return open(str.c_str(), flags, mode); +#endif +} + +// Reading wrapper around I18nOpen to avoid explicitely specifying the flags +inline int I18nOpenForReading( const std::string & str ) +{ +#if LOCAL_USE_WIN32_WOPEN + return I18nOpen(str, _O_RDONLY | _O_BINARY ); +#else + ///\todo check if cygwin has and needs the O_BINARY flag + return I18nOpen(str, O_RDONLY ); +#endif +} + +// Writting wrapper around I18nOpen to avoid explicitely specifying the flags +inline int I18nOpenForWritting( const std::string & str, const bool append = false ) +{ +#if LOCAL_USE_WIN32_WOPEN + if (!append) return I18nOpen(str, _O_WRONLY | _O_CREAT | _O_BINARY, _S_IREAD | _S_IWRITE ); + else return I18nOpen(str, _O_WRONLY | _O_CREAT | _O_APPEND | _O_BINARY, _S_IREAD | _S_IWRITE ); +#else + ///\todo check if cygwin has and needs the O_BINARY flag + if (!append) return I18nOpen(str, O_WRONLY | O_CREAT, S_IREAD | S_IWRITE ); + else return I18nOpen(str, O_WRONLY | O_CREAT | O_APPEND, S_IREAD | S_IWRITE ); +#endif +} + +// Get a FILE * pointer from a filename (using utf8 to wstring +// on windows if requested) +inline FILE * I18nFopen( const std::string & str, const std::string & mode ) +{ +#if LOCAL_USE_WIN32_WOPEN + // cygwin has NO _wfopen but mingw has + // If you really need unicode filenames on cygwin, just use cygwin >= 1.7 + // Convert to utf16 + const std::wstring str_utf16 = Utf8StringToWString( str ); + const std::wstring mode_utf16 = Utf8StringToWString( mode ); + return _wfopen(str_utf16.c_str(), mode_utf16.c_str()); +#else + return fopen(str.c_str(), mode.c_str()); +#endif +} + +#if LOCAL_USE_FDSTREAM +class I18nOfstream : public std::ostream +{ +public: + I18nOfstream( const char * str, + std::ios_base::openmode mode = std::ios_base::out ) + : std::ostream(0) + , m_fd( I18nOpenForWritting( str, (mode & std::ios::app)?true:false ) ) + , m_buf( m_fd ) + { + ///\todo better handle mode flag + this->rdbuf(&m_buf); + } + + ~I18nOfstream() { this->close(); } + + bool is_open() { return (m_fd!=-1); } + + void close() + { + if ( m_fd!=-1 ) ::close( m_fd ); + m_fd = -1; + } + +private: + int m_fd; + itk::fdoutbuf m_buf; +}; + +class I18nIfstream : public std::istream +{ +public: + I18nIfstream( const char * str, + std::ios_base::openmode mode = std::ios_base::in ) + : std::istream(0) + , m_fd( I18nOpenforreading( str ) ) + , m_buf( m_fd ) + { + ///\todo better handle mode flag + this->rdbuf(&m_buf); + } + + ~I18nIfstream() { this->close(); } + + bool is_open() { return (m_fd!=-1); } + + void close() + { + if ( m_fd!=-1 ) ::close( m_fd ); + m_fd = -1; + } + +private: + int m_fd; + itk::fdinbuf m_buf; +}; +#elif LOCAL_USE_WIN32_WOPEN +class I18nOfstream : public std::ofstream +{ +public: + I18nOfstream( const char * str, std::ios_base::openmode mode = std::ios_base::out ) + : std::ofstream( Utf8StringToWString(str).c_str(), mode ) + { + } +}; + +class I18nIfstream : public std::ifstream +{ +public: + I18nIfstream( const char * str, std::ios_base::openmode mode = std::ios_base::in ) + : std::ifstream( Utf8StringToWString(str).c_str(), mode ) + { + } +}; +#else +typedef std::ofstream I18nOfstream; +typedef std::ifstream I18nIfstream; +#endif + +} // end namespace +} // end namespace + + +#undef LOCAL_USE_WIN32_WOPEN +#undef LOCAL_USE_FDSTREAM + +#endif /* __itkInternationalizationIOHelpers_h */ diff --git a/Utilities/ITK/Code/Common/itkInterpolateImageFunction.h b/Utilities/ITK/Code/Common/itkInterpolateImageFunction.h index 4e9146aab5ba72514320b214d3b91c641b74a6c5..19688dcf3c1f9d06d11e902dbc042407fb2b86a9 100644 --- a/Utilities/ITK/Code/Common/itkInterpolateImageFunction.h +++ b/Utilities/ITK/Code/Common/itkInterpolateImageFunction.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkInterpolateImageFunction.h,v $ Language: C++ - Date: $Date: 2008-05-14 09:26:05 $ - Version: $Revision: 1.21 $ + Date: $Date: 2009-10-29 11:18:40 $ + Version: $Revision: 1.22 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -69,7 +69,8 @@ public: typedef typename Superclass::PointType PointType; /** Index typedef support. */ - typedef typename Superclass::IndexType IndexType; + typedef typename Superclass::IndexType IndexType; + typedef typename Superclass::IndexValueType IndexValueType; /** ContinuousIndex typedef support. */ typedef typename Superclass::ContinuousIndexType ContinuousIndexType; diff --git a/Utilities/ITK/Code/Common/itkKernelFunction.cxx b/Utilities/ITK/Code/Common/itkKernelFunction.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Common/itkLevelSetFunction.h b/Utilities/ITK/Code/Common/itkLevelSetFunction.h index c43bae38326b084f10bd6e49eb483ed611927665..590763ba6630179420d376bbf31bcc5b9045579c 100644 --- a/Utilities/ITK/Code/Common/itkLevelSetFunction.h +++ b/Utilities/ITK/Code/Common/itkLevelSetFunction.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkLevelSetFunction.h,v $ Language: C++ - Date: $Date: 2009-02-05 19:05:00 $ - Version: $Revision: 1.25 $ + Date: $Date: 2009-11-24 02:27:27 $ + Version: $Revision: 1.26 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -284,7 +284,7 @@ public: protected: LevelSetFunction() { - m_EpsilonMagnitude = 1.0e-5; + m_EpsilonMagnitude = static_cast<ScalarValueType>( 1.0e-5 ); m_AdvectionWeight = m_PropagationWeight = m_CurvatureWeight = m_LaplacianSmoothingWeight = NumericTraits<ScalarValueType>::Zero; diff --git a/Utilities/ITK/Code/Common/itkLevelSetFunction.txx b/Utilities/ITK/Code/Common/itkLevelSetFunction.txx index be7a1cbb372eeebd38802e27a1d555577ce85f65..75363d5f778b44303b0c6cfd967dd0d634bb80d8 100644 --- a/Utilities/ITK/Code/Common/itkLevelSetFunction.txx +++ b/Utilities/ITK/Code/Common/itkLevelSetFunction.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkLevelSetFunction.txx,v $ Language: C++ -Date: $Date: 2009-02-05 19:05:00 $ -Version: $Revision: 1.33 $ +Date: $Date: 2010-03-30 15:20:02 $ +Version: $Revision: 1.35 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -322,11 +322,13 @@ LevelSetFunction< TImageType > gd->m_dx[i] = 0.5 * (it.GetPixel( positionA ) - it.GetPixel( positionB ) ) * neighborhoodScales[i]; gd->m_dxy[i][i] = ( it.GetPixel( positionA ) - + it.GetPixel( positionB ) - 2.0 * center_value ) * - vnl_math_sqr(neighborhoodScales[i]); + + it.GetPixel( positionB ) - 2.0 * center_value ) * + vnl_math_sqr(neighborhoodScales[i]); gd->m_dx_forward[i] = ( it.GetPixel( positionA ) - center_value ) * neighborhoodScales[i]; + gd->m_dx_backward[i] = ( center_value - it.GetPixel( positionB ) ) * neighborhoodScales[i]; + gd->m_GradMagSqr += gd->m_dx[i] * gd->m_dx[i]; for( j = i+1; j < ImageDimension; j++ ) diff --git a/Utilities/ITK/Code/Common/itkLightProcessObject.cxx b/Utilities/ITK/Code/Common/itkLightProcessObject.cxx index 8e99c9658857574ba60c6e28c02ef91ff5c8d71c..5b3f2f4648b3e1ebf2c87ebfed246d4b347f59be 100644 --- a/Utilities/ITK/Code/Common/itkLightProcessObject.cxx +++ b/Utilities/ITK/Code/Common/itkLightProcessObject.cxx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkLightProcessObject.cxx,v $ Language: C++ - Date: $Date: 2009-02-05 19:05:00 $ - Version: $Revision: 1.8 $ + Date: $Date: 2009-11-24 02:27:27 $ + Version: $Revision: 1.9 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -28,7 +28,7 @@ LightProcessObject ::LightProcessObject() { m_AbortGenerateData = false; - m_Progress = 0.0; + m_Progress = 0.0f; } @@ -84,7 +84,7 @@ LightProcessObject * before we start to execute is 0.0. */ m_AbortGenerateData = 0; - m_Progress = 0.0; + m_Progress = 0.0f; this->GenerateData(); @@ -94,7 +94,7 @@ LightProcessObject */ if ( !m_AbortGenerateData ) { - this->UpdateProgress(1.0); + this->UpdateProgress(1.0f); } // Notify end event observers diff --git a/Utilities/ITK/Code/Common/itkLinearInterpolateImageFunction.h b/Utilities/ITK/Code/Common/itkLinearInterpolateImageFunction.h index 1890a95503904363123dd220291007a9823f0123..fb23a95f4cd22dfbc82713cdc592e369c9a4a54c 100644 --- a/Utilities/ITK/Code/Common/itkLinearInterpolateImageFunction.h +++ b/Utilities/ITK/Code/Common/itkLinearInterpolateImageFunction.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkLinearInterpolateImageFunction.h,v $ Language: C++ - Date: $Date: 2009-07-29 07:38:01 $ - Version: $Revision: 1.37 $ + Date: $Date: 2009-10-29 11:18:41 $ + Version: $Revision: 1.38 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -81,7 +81,8 @@ public: itkStaticConstMacro(ImageDimension, unsigned int,Superclass::ImageDimension); /** Index typedef support. */ - typedef typename Superclass::IndexType IndexType; + typedef typename Superclass::IndexType IndexType; + typedef typename Superclass::IndexValueType IndexValueType; /** ContinuousIndex typedef support. */ typedef typename Superclass::ContinuousIndexType ContinuousIndexType; diff --git a/Utilities/ITK/Code/Common/itkLinearInterpolateImageFunction.txx b/Utilities/ITK/Code/Common/itkLinearInterpolateImageFunction.txx index 9ef4e89daa50b715f04646e51feccf7b563ac3ed..b67e3e7b989c336425971560bae250fb9df64d2e 100644 --- a/Utilities/ITK/Code/Common/itkLinearInterpolateImageFunction.txx +++ b/Utilities/ITK/Code/Common/itkLinearInterpolateImageFunction.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkLinearInterpolateImageFunction.txx,v $ Language: C++ - Date: $Date: 2009-07-29 07:38:01 $ - Version: $Revision: 1.43 $ + Date: $Date: 2009-10-29 11:18:43 $ + Version: $Revision: 1.45 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -83,12 +83,12 @@ LinearInterpolateImageFunction< TInputImage, TCoordRep > * Compute base index = closet index below point * Compute distance from point to base index */ - signed long baseIndex[ImageDimension]; + IndexType baseIndex; double distance[ImageDimension]; for( dim = 0; dim < ImageDimension; dim++ ) { - baseIndex[dim] = Math::Floor( index[dim] ); + baseIndex[dim] = Math::Floor< IndexValueType >( index[dim] ); distance[dim] = index[dim] - static_cast< double >( baseIndex[dim] ); } diff --git a/Utilities/ITK/Code/Common/itkLog10ImageAdaptor.h b/Utilities/ITK/Code/Common/itkLog10ImageAdaptor.h index bc8da9e17152f98e1677b315bb6c2c328bef0ff5..bb24583a246e328a17d91a91baa1ab8a2a129e44 100644 --- a/Utilities/ITK/Code/Common/itkLog10ImageAdaptor.h +++ b/Utilities/ITK/Code/Common/itkLog10ImageAdaptor.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkLog10ImageAdaptor.h,v $ Language: C++ - Date: $Date: 2009-02-05 19:05:01 $ - Version: $Revision: 1.13 $ + Date: $Date: 2009-09-19 19:56:20 $ + Version: $Revision: 1.14 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -29,7 +29,7 @@ namespace Accessor { * * Log10PixelAccessor is templated over an internal type and an * external type representation. This class cast the input - * applies the funtion to it and cast the result according + * applies the function to it and cast the result according * to the types defined as template parameters * * \ingroup ImageAdaptors diff --git a/Utilities/ITK/Code/Common/itkLogImageAdaptor.h b/Utilities/ITK/Code/Common/itkLogImageAdaptor.h index f67a5b07ed1c10ad1619dc64ae9606c8c76bfc42..62ce62e55cb899b8f9bf32b0814abe3dd6ed8a3a 100644 --- a/Utilities/ITK/Code/Common/itkLogImageAdaptor.h +++ b/Utilities/ITK/Code/Common/itkLogImageAdaptor.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkLogImageAdaptor.h,v $ Language: C++ - Date: $Date: 2009-02-05 19:05:01 $ - Version: $Revision: 1.13 $ + Date: $Date: 2009-09-19 19:56:20 $ + Version: $Revision: 1.14 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -29,7 +29,7 @@ namespace Accessor { * * LogPixelAccessor is templated over an internal type and an * external type representation. This class cast the input - * applies the funtion to it and cast the result according + * applies the function to it and cast the result according * to the types defined as template parameters * * \ingroup ImageAdaptors diff --git a/Utilities/ITK/Code/Common/itkMacro.h b/Utilities/ITK/Code/Common/itkMacro.h index 48049b76f277d36f0da57997947738dbcce8a347..fedd6aaa461d5699dcb8d69f448ad0a41f4d5896 100644 --- a/Utilities/ITK/Code/Common/itkMacro.h +++ b/Utilities/ITK/Code/Common/itkMacro.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkMacro.h,v $ Language: C++ - Date: $Date: 2009-06-16 07:58:46 $ - Version: $Revision: 1.97 $ + Date: $Date: 2009-10-28 16:05:57 $ + Version: $Revision: 1.100 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -39,7 +39,6 @@ #include <cassert> #endif -#include "vnl/vnl_math.h" // Determine type of string stream to use. #if !defined(CMAKE_NO_ANSI_STRING_STREAM) @@ -970,24 +969,6 @@ private: #endif -namespace itk -{ -namespace Math -{ -inline int RoundHalfIntegerUp(float x) { return vnl_math_rnd_halfintup(x); } -inline int RoundHalfIntegerUp(double x) { return vnl_math_rnd_halfintup(x); } -inline int RoundHalfIntegerToEven(float x) { return vnl_math_rnd_halfinttoeven(x); } -inline int RoundHalfIntegerToEven(double x) { return vnl_math_rnd_halfinttoeven(x); } -inline int Round(float x) { return RoundHalfIntegerUp(x); } -inline int Round(double x) { return RoundHalfIntegerUp(x); } -inline int Floor(float x) { return vnl_math_floor(x); } -inline int Floor(double x) { return vnl_math_floor(x); } -inline int Ceil(float x) { return vnl_math_ceil(x); } -inline int Ceil(double x) { return vnl_math_ceil(x); } -} // end namespace Math -} // end namespace itk - - #ifdef ITK_USE_TEMPLATE_META_PROGRAMMING_LOOP_UNROLLING //-------------------------------------------------------------------------------- // Helper macros for Template Meta-Programming techniques of for-loops unrolling @@ -1017,7 +998,7 @@ inline int Ceil(double x) { return vnl_math_ceil(x); } #define itkForLoopRoundingAndAssignmentMacro(DestinationType,Sourcrnd_halfintup,DestinationElementType,DestinationArray,SourceArray,NumberOfIterations) \ for(unsigned int i=0;i < NumberOfIterations; ++i) \ { \ - DestinationArray[i] = static_cast< DestinationElementType >( itk::Math::Round( SourceArray[i] ) ); \ + DestinationArray[i] = itk::Math::Round< DestinationElementType >( SourceArray[i] ); \ } #endif diff --git a/Utilities/ITK/Code/Common/itkMapContainer.h b/Utilities/ITK/Code/Common/itkMapContainer.h index 8b896d95e8290fcea1cee2da1000a9f06704fd15..2e7a3de184a379e2032b44da437b6f1bdbada992 100644 --- a/Utilities/ITK/Code/Common/itkMapContainer.h +++ b/Utilities/ITK/Code/Common/itkMapContainer.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkMapContainer.h,v $ Language: C++ - Date: $Date: 2009-02-05 19:05:01 $ - Version: $Revision: 1.49 $ + Date: $Date: 2009-11-22 15:36:04 $ + Version: $Revision: 1.50 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -108,8 +108,7 @@ public: /** \class Iterator * \brief The non-const iterator type for the map. */ - class Iterator - { + class Iterator { public: Iterator() {} Iterator( const MapIterator& i ): m_Iter(i) {} diff --git a/Utilities/ITK/Code/Common/itkMath.h b/Utilities/ITK/Code/Common/itkMath.h new file mode 100644 index 0000000000000000000000000000000000000000..985fdd7c631932ffd8e5169aa5215fa31cfd4673 --- /dev/null +++ b/Utilities/ITK/Code/Common/itkMath.h @@ -0,0 +1,260 @@ +/*========================================================================= + + Program: Insight Segmentation & Registration Toolkit + Module: $RCSfile: itkMath.h,v $ + Language: C++ + Date: $Date: 2010-04-07 17:25:21 $ + Version: $Revision: 1.16 $ + + Copyright (c) Insight Software Consortium. All rights reserved. + See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. + + Portions of this code are covered under the VTK copyright. + See VTKCopyright.txt or http://www.kitware.com/VTKCopyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#ifndef __itkMath_h +#define __itkMath_h + + +#include "itkConfigure.h" +#include "itkIntTypes.h" +#include "itkMathDetail.h" +#include "itkConceptChecking.h" + + +namespace itk +{ +namespace Math +{ + +// These constants originate from VXL's vnl_math.h. They have been +// moved here to improve visibility, and to ensure that the constants +// are available during compile time ( as opposed to static const +// member vaiables ). + +/** \brief \f[e] The base of the natural logarithm or Euler's number */ +static const double e = 2.7182818284590452354; +/** \brief \f[ \log_2 e \f] */ +static const double log2e = 1.4426950408889634074; +/** \brief \f[ \log_10 e \f] */ +static const double log10e = 0.43429448190325182765; +/** \brief \f[ \log_e 2 \f] */ +static const double ln2 = 0.69314718055994530942; +/** \brief \f[ \log_e 10 \f] */ +static const double ln10 = 2.30258509299404568402; +/** \brief \f[ \pi ] */ +static const double pi = 3.14159265358979323846; +/** \brief \f[ \frac{\pi}{2} \f] */ +static const double pi_over_2 = 1.57079632679489661923; +/** \brief \f[ \frac{\pi}{4} \f] */ +static const double pi_over_4 = 0.78539816339744830962; +/** \brief \f[ \frac{1}{\pi} \f] */ +static const double one_over_pi = 0.31830988618379067154; +/** \brief \f[ \frac{2}{\pi} \f] */ +static const double two_over_pi = 0.63661977236758134308; +/** \brief \f[ \frac{2}{\sqrt{\pi}} \f] */ +static const double two_over_sqrtpi = 1.12837916709551257390; +/** \brief \f[ \frac{2}{\sqrt{2\pi}} \f] */ +static const double one_over_sqrt2pi = 0.39894228040143267794; +/** \brief \f[ \sqrt{2} \f] */ +static const double sqrt2 = 1.41421356237309504880; +/** \brief \f[ \sqrt{ \frac{1}{2}} \f] */ +static const double sqrt1_2 = 0.70710678118654752440; + + +#ifdef ITK_HAS_INT_64 +/** A useful macro to generate a template floating point to integer + * conversion templated on the return type and using either the 32 + * bit, the 64 bit or the vanilla version */ +#define itkTemplateFloatingToIntegerMacro(name) \ + template <typename TReturn,typename TInput> \ + inline TReturn name(TInput x) \ + { \ + \ + if (sizeof(TReturn) <= 4) \ + { \ + return static_cast<TReturn>(Detail::name##_32(x)); \ + } \ + else if (sizeof(TReturn) <= 8) \ + { \ + return static_cast<TReturn>(Detail::name##_64(x)); \ + } \ + else \ + { \ + return static_cast<TReturn>(Detail::name##_base<TReturn,TInput>(x)); \ + } \ + } +#else +#define itkTemplateFloatingToIntegerMacro(name) \ + template <typename TReturn,typename TInput> \ + inline TReturn name(TInput x) \ + { \ + if (sizeof(TReturn) <= 4) \ + { \ + return static_cast<TReturn>(Detail::name##_32(x)); \ + } \ + else \ + { \ + return static_cast<TReturn>(Detail::name##_base<TReturn,TInput>(x)); \ + } \ + } +#endif // end ITK_HAS_INT_64 + +/** \brief Round towards nearest integer + * + * \tparam TReturn must be an interger type + * \tparam TInput must be float or double + * + * halfway cases are rounded towards the nearest even + * integer, e.g. + * \code + * RoundHalfIntegerToEven( 1.5) == 2 + * RoundHalfIntegerToEven(-1.5) == -2 + * RoundHalfIntegerToEven( 2.5) == 2 + * RoundHalfIntegerToEven( 3.5) == 4 + * \endcode + * + * The behavior of overflow is undefined due to numerous implementations. + * + * \warning We assume that the rounding mode is not changed from the default + * one (or at least that it is always restored to the default one). + */ +itkTemplateFloatingToIntegerMacro(RoundHalfIntegerToEven); + +/** \brief Round towards nearest integer + * + * \tparam TReturn must be an interger type + * \tparam TInput must be float or double + * + * halfway cases are rounded upward, e.g. + * \code + * RoundHalfIntegerUp( 1.5) == 2 + * RoundHalfIntegerUp(-1.5) == -1 + * RoundHalfIntegerUp( 2.5) == 3 + * \endcode + * + * The behavior of overflow is undefined due to numerous implementations. + * + * \warning The argument absolute value must be less than + * NumbericTraits<TReturn>::max()/2 for RoundHalfIntegerUp to be + * guaranteed to work. + * + * \warning We also assume that the rounding mode is not changed from + * the default one (or at least that it is always restored to the + * default one). + */ +itkTemplateFloatingToIntegerMacro(RoundHalfIntegerUp); + +/** \brief Round towards nearest integer (This is a synonym for RoundHalfIntegerUp) + * + * \tparam TReturn must be an interger type + * \tparam TInput must be float or double + * + * \sa RoundHalfIntegerUp<TReturn, TInput>() + */ +template <typename TReturn, typename TInput> +inline TReturn Round(TInput x) { return RoundHalfIntegerUp<TReturn,TInput>(x); } + +/** \brief Round towards minus infinity + * + * The behavior of overflow is undefined due to numerous implementations. + * + * \warning argument absolute value must be less than + * NumbericTraits<TReturn>::max()/2 for vnl_math_floor to be + * guaranteed to work. + * + * \warning We also assume that the rounding mode is not changed from + * the default one (or at least that it is always restored to the + * default one). + */ +itkTemplateFloatingToIntegerMacro(Floor); + +/** \brief Round towards plus infinity + * + * The behavior of overflow is undefined due to numerous implementations. + * + * \warning argument absolute value must be less than INT_MAX/2 + * for vnl_math_ceil to be guaranteed to work. + * \warning We also assume that the rounding mode is not changed from + * the default one (or at least that it is always restored to the + * default one). + */ +itkTemplateFloatingToIntegerMacro(Ceil); + + +#undef itkTemplateFloatingToIntegerMacro + + +#if !defined(ITK_LEGACY_REMOVE) && !VCL_TEMPLATE_MATCHES_TOO_OFTEN +// VCL_TEMPLATE_MATCHES_TOO_OFTEN is used here because some compilers +// can not handle function overloading with templated and +// non-templated methods, ie the templated functions matches too often + + +/** @{ */ +/** \deprecated These methods have been deprecated as of ITK 3.16. Please + * use the templated methods of the form + * itk::Math::XXX<TReturn,TINput(TInput x) instead. + * + * \sa RoundHalfIntegerUp<TReturn, TInput>() */ +inline int RoundHalfIntegerToEven(double x) { return Detail::RoundHalfIntegerToEven_32(x); } +inline int RoundHalfIntegerToEven(float x) { return Detail::RoundHalfIntegerToEven_32(x); } + +inline int RoundHalfIntegerUp(double x) { return Detail::RoundHalfIntegerUp_32(x); } +inline int RoundHalfIntegerUp(float x) { return Detail::RoundHalfIntegerUp_32(x); } + +inline int Round(double x) { return Detail::RoundHalfIntegerUp_32(x); } +inline int Round(float x) { return Detail::RoundHalfIntegerUp_32(x); } + +inline int Floor(double x) { return Detail::Floor_32(x); } +inline int Floor(float x) { return Detail::Floor_32(x); } + +inline int Ceil(double x) { return Detail::Ceil_32(x); } +inline int Ceil(float x) { return Detail::Ceil_32(x); } +/** @} */ + +#endif // end of ITK_LEGACY_REMOVE + +template <typename TReturn,typename TInput> +inline TReturn CastWithRangeCheck(TInput x) +{ + +#ifdef ITK_USE_CONCEPT_CHECKING + itkConceptMacro( OnlyDefinedForIntegerTypes1, (itk::Concept::IsInteger<TReturn>) ); + itkConceptMacro( OnlyDefinedForIntegerTypes2, (itk::Concept::IsInteger<TInput>) ); +#endif // ITK_USE_CONCEPT_CHECKING + + TReturn ret = static_cast<TReturn>(x); + if ( sizeof (TReturn) > sizeof(TInput) && + !( !itk::NumericTraits<TReturn>::is_signed && itk::NumericTraits<TInput>::is_signed ) ) + { + // if the output type is bigger and we are not converting a signed + // interger to an unsigned interger then we have no problems + return ret; + } + else if ( sizeof (TReturn) >= sizeof(TInput) ) + { + if ( itk::NumericTraits<TInput>::IsPositive(x) != itk::NumericTraits<TReturn>::IsPositive(ret) ) + { + itk::RangeError _e(__FILE__, __LINE__); + throw _e; + } + } + else if ( static_cast<TInput>(ret) != x || + ( itk::NumericTraits<TInput>::IsPositive(x) != itk::NumericTraits<TReturn>::IsPositive(ret) ) ) + { + itk::RangeError _e(__FILE__, __LINE__); + throw _e; + } + return ret; +} + +} // end namespace Math +} // end namespace itk +#endif // end of itkMath.h diff --git a/Utilities/ITK/Code/Common/itkMathDetail.h b/Utilities/ITK/Code/Common/itkMathDetail.h new file mode 100644 index 0000000000000000000000000000000000000000..8e8f4ffabb43ecbd5fb4aab46d8750d3c6390394 --- /dev/null +++ b/Utilities/ITK/Code/Common/itkMathDetail.h @@ -0,0 +1,371 @@ +/*========================================================================= + + Program: Insight Segmentation & Registration Toolkit + Module: $RCSfile: itkMathDetail.h,v $ + Language: C++ + Date: $Date: 2009-12-16 15:00:29 $ + Version: $Revision: 1.13 $ + + Copyright (c) Insight Software Consortium. All rights reserved. + See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. + + Portions of this code are covered under the VTK copyright. + See VTKCopyright.txt or http://www.kitware.com/VTKCopyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#ifndef __itkMathDetail_h +#define __itkMathDetail_h + +#include "vnl/vnl_math.h" +#include "itkNumericTraits.h" + +#ifdef ITK_HAVE_FENV_H +// The Sun Studio CC compiler seems to have a bug where if cstdio is +// included stdio.h must also be included before fenv.h +#include <stdio.h> +#include <fenv.h> // should this be cfenv? +#endif /* ITK_HAVE_FENV_H */ + +// Figure out when the fast implementations can be used +// +// Turn on 32-bit sse2 impl if asked for +#if VNL_CONFIG_ENABLE_SSE2_ROUNDING && defined(__SSE2__) && (!defined(__GCCXML__)) +# define USE_SSE2_32IMPL 1 +#else +# define USE_SSE2_32IMPL 0 +#endif +// Turn on 64-bit sse2 impl only on 64-bit architectures and if asked for +# define USE_SSE2_64IMPL 0 +#if VNL_CONFIG_ENABLE_SSE2_ROUNDING && defined(__SSE2__) && \ + ( defined(__x86_64) || defined(__x86_64__) || defined(_M_X64)) && (!defined(__GCCXML__) ) +// _mm_cvtsd_si64 and _mm_cvtss_si64 are not defined in gcc prior to 4.0 +// of gcc, we have opted not to use a compile test for this due to +// complication with universal binaries on apple +#if (!defined(__GNUC__) || ( defined(__GNUC__) && (__GNUC__>=4 ) )) +# undef USE_SSE2_64IMPL +# define USE_SSE2_64IMPL 1 +#endif +#endif + +// Turn on 32-bit and 64-bit asm impl when using GCC on x86 platform with the following exception: +// GCCXML +#if defined(__GNUC__) && (!defined(__GCCXML__)) && (defined(__i386__) || defined(__i386) || defined(__x86_64__) || defined(__x86_64)) +# define GCC_USE_ASM_32IMPL 1 +# define GCC_USE_ASM_64IMPL 1 +#else +# define GCC_USE_ASM_32IMPL 0 +# define GCC_USE_ASM_64IMPL 0 +#endif +// Turn on 32-bit and 64-bit asm impl when using msvc on 32 bits windows +#if defined(VCL_VC) && (!defined(__GCCXML__)) && !defined(_WIN64) +# define VC_USE_ASM_32IMPL 1 +# define VC_USE_ASM_64IMPL 1 +#else +# define VC_USE_ASM_32IMPL 0 +# define VC_USE_ASM_64IMPL 0 +#endif + + +namespace itk +{ +namespace Math +{ +namespace Detail +{ +// The functions defined in this namespace are not meant to be used directly +// and thus do not adhere to the standard backward-compatibility +// policy of ITK, as any Detail namespace should be considered private. +// Please use the functions from the itk::Math namespace instead + +//////////////////////////////////////// +// Base versions + +template <typename TReturn, typename TInput> +inline TReturn RoundHalfIntegerToEven_base(TInput x) +{ + if ( NumericTraits<TInput>::IsNonnegative( x ) ) + { + x += static_cast<TInput>( 0.5 ); + } + else + { + x -= static_cast<TInput>( 0.5 ); + } + + const TReturn r = static_cast<TReturn>( x ); + return ( x != static_cast<TInput>( r ) ) ? r : static_cast<TReturn>( 2*(r/2) ); +} + +template <typename TReturn, typename TInput> +inline TReturn RoundHalfIntegerUp_base(TInput x) +{ + x += static_cast<TInput>( 0.5 ); + const TReturn r = static_cast<TReturn>( x ); + return ( NumericTraits<TInput>::IsNonnegative( x ) ) ? + r : + ( x == static_cast<TInput>( r ) ? r : r - static_cast<TReturn>(1) ); +} + +template <typename TReturn, typename TInput> +inline TReturn Floor_base(TInput x) +{ + const TReturn r = static_cast<TReturn>( x ); + + return ( NumericTraits<TInput>::IsNonnegative( x ) ) ? + r : + ( x == static_cast<TInput>( r ) ? r : r - static_cast<TReturn>(1) ); +} + +template <typename TReturn, typename TInput> +inline TReturn Ceil_base(TInput x) +{ + const TReturn r = static_cast<TReturn>( x ); + return ( NumericTraits<TInput>::IsNegative( x ) ) ? + r : + ( x == static_cast<TInput>( r ) ? r : r + static_cast<TReturn>(1) ); +} + +//////////////////////////////////////// +// 32 bits versions + + +#if USE_SSE2_32IMPL // sse2 implementation + +inline int32_t RoundHalfIntegerToEven_32(double x) +{ + #if defined(ITK_CHECK_FPU_ROUNDING_MODE) && defined(HAVE_FENV_H) + assert( fegetround() == FE_TONEAREST ); + #endif + return _mm_cvtsd_si32(_mm_set_sd(x)); +} +inline int32_t RoundHalfIntegerToEven_32(float x) +{ + #if defined(ITK_CHECK_FPU_ROUNDING_MODE) && defined(HAVE_FENV_H) + assert( fegetround() == FE_TONEAREST ); + #endif + return _mm_cvtss_si32(_mm_set_ss(x)); +} + +#elif GCC_USE_ASM_32IMPL // gcc asm implementation + +inline int32_t RoundHalfIntegerToEven_32(double x) +{ + #if defined(ITK_CHECK_FPU_ROUNDING_MODE) && defined(HAVE_FENV_H) + assert( fegetround() == FE_TONEAREST ); + #endif + int32_t r; + __asm__ __volatile__( "fistpl %0" : "=m"(r) : "t"(x) : "st" ); + return r; +} + +inline int32_t RoundHalfIntegerToEven_32(float x) +{ + #if defined(ITK_CHECK_FPU_ROUNDING_MODE) && defined(HAVE_FENV_H) + assert( fegetround() == FE_TONEAREST ); + #endif + int32_t r; + __asm__ __volatile__( "fistpl %0" : "=m"(r) : "t"(x) : "st" ); + return r; +} + +#elif VC_USE_ASM_32IMPL // msvc asm implementation + +inline int32_t RoundHalfIntegerToEven_32(double x) +{ + #if defined(ITK_CHECK_FPU_ROUNDING_MODE) && defined(HAVE_FENV_H) + assert( fegetround() == FE_TONEAREST ); + #endif + int32_t r; + __asm + { + fld x + fistp r + } + return r; +} + +inline int32_t RoundHalfIntegerToEven_32(float x) +{ + #if defined(ITK_CHECK_FPU_ROUNDING_MODE) && defined(HAVE_FENV_H) + assert( fegetround() == FE_TONEAREST ); + #endif + int32_t r; + __asm + { + fld x + fistp r + } + return r; +} + +#else // Base implementation + +inline int32_t RoundHalfIntegerToEven_32(double x) { return RoundHalfIntegerToEven_base<int32_t,double>(x); } +inline int32_t RoundHalfIntegerToEven_32(float x) { return RoundHalfIntegerToEven_base<int32_t,float>(x); } + +#endif + + +#if USE_SSE2_32IMPL || GCC_USE_ASM_32IMPL || VC_USE_ASM_32IMPL + +inline int32_t RoundHalfIntegerUp_32(double x) { return RoundHalfIntegerToEven_32(2*x+0.5)>>1; } +inline int32_t RoundHalfIntegerUp_32(float x) { return RoundHalfIntegerToEven_32(2*x+0.5f)>>1; } + + +inline int32_t Floor_32(double x) { return RoundHalfIntegerToEven_32(2*x-0.5)>>1; } +inline int32_t Floor_32(float x) { return RoundHalfIntegerToEven_32(2*x-0.5f)>>1; } + +inline int32_t Ceil_32(double x) { return -(RoundHalfIntegerToEven_32(-0.5-2*x)>>1); } +inline int32_t Ceil_32(float x) { return -(RoundHalfIntegerToEven_32(-0.5f-2*x)>>1); } + +#else // Base implementation + +inline int32_t RoundHalfIntegerUp_32(double x) { return RoundHalfIntegerUp_base<int32_t,double>(x); } +inline int32_t RoundHalfIntegerUp_32(float x) { return RoundHalfIntegerUp_base<int32_t,float>(x); } + +inline int32_t Floor_32(double x) { return Floor_base<int32_t,double>(x); } +inline int32_t Floor_32(float x) { return Floor_base<int32_t,float>(x); } + +inline int32_t Ceil_32(double x) { return Ceil_base<int32_t,double>(x); } +inline int32_t Ceil_32(float x) { return Ceil_base<int32_t,float>(x); } + +#endif // USE_SSE2_32IMPL || GCC_USE_ASM_32IMPL || VC_USE_ASM_32IMPL + + +//////////////////////////////////////// +// 64 bits versions +#ifdef ITK_HAS_INT_64 + +#if USE_SSE2_64IMPL // sse2 implementation + +inline int64_t RoundHalfIntegerToEven_64(double x) +{ + #if defined(ITK_CHECK_FPU_ROUNDING_MODE) && defined(HAVE_FENV_H) + assert( fegetround() == FE_TONEAREST ); + #endif + return _mm_cvtsd_si64(_mm_set_sd(x)); +} +inline int64_t RoundHalfIntegerToEven_64(float x) +{ + #if defined(ITK_CHECK_FPU_ROUNDING_MODE) && defined(HAVE_FENV_H) + assert( fegetround() == FE_TONEAREST ); + #endif + return _mm_cvtss_si64(_mm_set_ss(x)); +} + +#elif GCC_USE_ASM_64IMPL // gcc asm implementation + +inline int64_t RoundHalfIntegerToEven_64(double x) +{ + #if defined(ITK_CHECK_FPU_ROUNDING_MODE) && defined(HAVE_FENV_H) + assert( fegetround() == FE_TONEAREST ); + #endif + int64_t r; + __asm__ __volatile__( "fistpll %0" : "=m"(r) : "t"(x) : "st" ); + return r; +} + +inline int64_t RoundHalfIntegerToEven_64(float x) +{ + #if defined(ITK_CHECK_FPU_ROUNDING_MODE) && defined(HAVE_FENV_H) + assert( fegetround() == FE_TONEAREST ); + #endif + int64_t r; + __asm__ __volatile__( "fistpll %0" : "=m"(r) : "t"(x) : "st" ); + return r; +} + +#elif VC_USE_ASM_64IMPL // msvc asm implementation + +inline int64_t RoundHalfIntegerToEven_64(double x) +{ + #if defined(ITK_CHECK_FPU_ROUNDING_MODE) && defined(HAVE_FENV_H) + assert( fegetround() == FE_TONEAREST ); + #endif + int64_t r; + __asm + { + fld x + fistp r + } + return r; +} + +inline int64_t RoundHalfIntegerToEven_64(float x) +{ + #if defined(ITK_CHECK_FPU_ROUNDING_MODE) && defined(HAVE_FENV_H) + assert( fegetround() == FE_TONEAREST ); + #endif + int64_t r; + __asm + { + fld x + fistp r + } + return r; +} + +#else // Base implementation + +inline int64_t RoundHalfIntegerToEven_64(double x) { return RoundHalfIntegerToEven_base<int64_t,double>(x); } +inline int64_t RoundHalfIntegerToEven_64(float x) { return RoundHalfIntegerToEven_base<int64_t,float>(x); } + +#endif + + +#if USE_SSE2_64IMPL || GCC_USE_ASM_64IMPL || VC_USE_ASM_64IMPL + +inline int64_t RoundHalfIntegerUp_64(double x) { return RoundHalfIntegerToEven_64(2*x+0.5)>>1; } +inline int64_t RoundHalfIntegerUp_64(float x) { return RoundHalfIntegerToEven_64(2*x+0.5f)>>1; } + +inline int64_t Floor_64(double x) { return RoundHalfIntegerToEven_64(2*x-0.5)>>1; } +inline int64_t Floor_64(float x) { return RoundHalfIntegerToEven_64(2*x-0.5f)>>1; } + + +inline int64_t Ceil_64(double x) { return -(RoundHalfIntegerToEven_64(-0.5-2*x)>>1); } +inline int64_t Ceil_64(float x) { return -(RoundHalfIntegerToEven_64(-0.5f-2*x)>>1); } + + +#else // Base implementation + +inline int64_t RoundHalfIntegerUp_64(double x) { return RoundHalfIntegerUp_base<int64_t,double>(x); } +inline int64_t RoundHalfIntegerUp_64(float x) { return RoundHalfIntegerUp_base<int64_t,float>(x); } + +inline int64_t Floor_64(double x) { return Floor_base<int64_t,double>(x); } +inline int64_t Floor_64(float x) { return Floor_base<int64_t,float>(x); } + +inline int64_t Ceil_64(double x) { return Ceil_base<int64_t,double>(x); } +inline int64_t Ceil_64(float x) { return Ceil_base<int64_t,float>(x); } + +#endif // USE_SSE2_64IMPL || GCC_USE_ASM_64IMPL || VC_USE_ASM_64IMPL + +#endif // VXL_HAS_INT_64 + +} // end namespace Detail +} // end namespace Math + +// move to itkConceptChecking? +namespace Concept +{ +template< typename T> struct FloatOrDouble; +template<> struct FloatOrDouble<float>{}; +template<> struct FloatOrDouble<double>{}; +} // end namespace Concept + +} // end namespace itk + + +#undef USE_SSE2_32IMPL +#undef GCC_USE_ASM_32IMPL +#undef VC_USE_ASM_32IMPL + +#undef USE_SSE2_64IMPL +#undef GCC_USE_ASM_64IMPL +#undef VC_USE_ASM_64IMPL + +#endif // end of itkMathDetail.h diff --git a/Utilities/ITK/Code/Common/itkMatrixOffsetTransformBase.h b/Utilities/ITK/Code/Common/itkMatrixOffsetTransformBase.h old mode 100644 new mode 100755 index f018d4e92c91d5879c6043c63f9ea455bf6c5a25..43f47f8e33923bce90f1d5a3898fcf7529e4cc0a --- a/Utilities/ITK/Code/Common/itkMatrixOffsetTransformBase.h +++ b/Utilities/ITK/Code/Common/itkMatrixOffsetTransformBase.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkMatrixOffsetTransformBase.h,v $ Language: C++ - Date: $Date: 2009-04-09 09:23:21 $ - Version: $Revision: 1.22 $ + Date: $Date: 2009-11-28 15:58:04 $ + Version: $Revision: 1.25 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -103,6 +103,7 @@ public: /** Parameters Type */ typedef typename Superclass::ParametersType ParametersType; + typedef typename Superclass::ParametersValueType ParametersValueType; /** Jacobian Type */ typedef typename Superclass::JacobianType JacobianType; @@ -115,6 +116,7 @@ public: itkGetStaticConstMacro(InputSpaceDimension)> InputVectorType; typedef Vector<TScalarType, itkGetStaticConstMacro(OutputSpaceDimension)> OutputVectorType; + typedef typename OutputVectorType::ValueType OutputVectorValueType; /** Standard covariant vector type for this class */ typedef CovariantVector<TScalarType, @@ -136,14 +138,17 @@ public: typedef Point<TScalarType, itkGetStaticConstMacro(InputSpaceDimension)> InputPointType; + typedef typename InputPointType::ValueType InputPointValueType; typedef Point<TScalarType, itkGetStaticConstMacro(OutputSpaceDimension)> OutputPointType; + typedef typename OutputPointType::ValueType OutputPointValueType; /** Standard matrix type for this class */ typedef Matrix<TScalarType, itkGetStaticConstMacro(OutputSpaceDimension), itkGetStaticConstMacro(InputSpaceDimension)> MatrixType; + typedef typename MatrixType::ValueType MatrixValueType; /** Standard inverse matrix type for this class */ typedef Matrix<TScalarType, itkGetStaticConstMacro(InputSpaceDimension), @@ -153,11 +158,14 @@ public: typedef InputPointType CenterType; typedef OutputVectorType OffsetType; + typedef typename OffsetType::ValueType OffsetValueType; typedef OutputVectorType TranslationType; + typedef typename TranslationType::ValueType TranslationValueType; + /** Base inverse transform type. This type should not be changed to the - * concrete inverse transform type or inheritance would be lost.*/ + * concrete inverse transform type or inheritance would be lost. */ typedef typename Superclass::InverseTransformBaseType InverseTransformBaseType; typedef typename InverseTransformBaseType::Pointer InverseTransformBasePointer; diff --git a/Utilities/ITK/Code/Common/itkMatrixOffsetTransformBase.txx b/Utilities/ITK/Code/Common/itkMatrixOffsetTransformBase.txx old mode 100644 new mode 100755 index 950b1b20b1e96e3507a760d0cbacc8d3039564cb..b9a6c46292e26a6ee44b7938b05f0fde195f8671 --- a/Utilities/ITK/Code/Common/itkMatrixOffsetTransformBase.txx +++ b/Utilities/ITK/Code/Common/itkMatrixOffsetTransformBase.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkMatrixOffsetTransformBase.txx,v $ Language: C++ - Date: $Date: 2009-04-09 09:23:21 $ - Version: $Revision: 1.19 $ + Date: $Date: 2010-03-30 15:20:02 $ + Version: $Revision: 1.23 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -20,6 +20,7 @@ #include "itkNumericTraits.h" #include "itkMatrixOffsetTransformBase.h" #include "vnl/algo/vnl_matrix_inverse.h" +#include "itkMath.h" namespace itk @@ -139,9 +140,9 @@ MatrixOffsetTransformBase<TScalarType, NInputDimensions, NOutputDimensions> { m_Matrix.SetIdentity(); m_MatrixMTime.Modified(); - m_Offset.Fill( 0.0 ); - m_Translation.Fill( 0.0 ); - m_Center.Fill( 0.0 ); + m_Offset.Fill( NumericTraits< OutputVectorValueType >::Zero ); + m_Translation.Fill( NumericTraits< OutputVectorValueType >::Zero ); + m_Center.Fill( NumericTraits< InputPointValueType >::Zero ); m_Singular = false; m_InverseMatrix.SetIdentity(); m_InverseMatrixMTime = m_MatrixMTime; @@ -313,6 +314,7 @@ MatrixOffsetTransformBase<TScalarType, NInputDimensions, NOutputDimensions> { this->m_FixedParameters = fp; InputPointType c; + typedef typename ParametersType::ValueType ParameterValueType; for ( unsigned int i = 0; i < NInputDimensions; i++ ) { c[i] = this->m_FixedParameters[i]; diff --git a/Utilities/ITK/Code/Common/itkMaximumDecisionRule.cxx b/Utilities/ITK/Code/Common/itkMaximumDecisionRule.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Common/itkMaximumDecisionRule.h b/Utilities/ITK/Code/Common/itkMaximumDecisionRule.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Common/itkMaximumRatioDecisionRule.cxx b/Utilities/ITK/Code/Common/itkMaximumRatioDecisionRule.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Common/itkMaximumRatioDecisionRule.h b/Utilities/ITK/Code/Common/itkMaximumRatioDecisionRule.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Common/itkMersenneTwisterRandomVariateGenerator.cxx b/Utilities/ITK/Code/Common/itkMersenneTwisterRandomVariateGenerator.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Common/itkMersenneTwisterRandomVariateGenerator.h b/Utilities/ITK/Code/Common/itkMersenneTwisterRandomVariateGenerator.h old mode 100644 new mode 100755 index 4885b7bdade4ad760929961831ebb3b6e58950fb..77d0593449b17e94bb406b2c982473a08c1b42f1 --- a/Utilities/ITK/Code/Common/itkMersenneTwisterRandomVariateGenerator.h +++ b/Utilities/ITK/Code/Common/itkMersenneTwisterRandomVariateGenerator.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkMersenneTwisterRandomVariateGenerator.h,v $ Language: C++ - Date: $Date: 2009-08-08 15:25:34 $ - Version: $Revision: 1.9 $ + Date: $Date: 2009-12-14 18:34:54 $ + Version: $Revision: 1.10 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -111,7 +111,7 @@ public: typedef SmartPointer<Self> Pointer; typedef SmartPointer<const Self> ConstPointer; - typedef ITK_UINT32 IntegerType; + typedef uint32_t IntegerType; /** Run-time type information (and related methods). */ itkTypeMacro(MersenneTwisterRandomVariateGenerator, diff --git a/Utilities/ITK/Code/Common/itkMesh.h b/Utilities/ITK/Code/Common/itkMesh.h index e3d437d19dcb5dba02f9dd07c7283e1955306f30..f4b6e703650844a9574991c4bb41c99410c026b2 100644 --- a/Utilities/ITK/Code/Common/itkMesh.h +++ b/Utilities/ITK/Code/Common/itkMesh.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkMesh.h,v $ Language: C++ - Date: $Date: 2009-06-21 16:25:08 $ - Version: $Revision: 1.98 $ + Date: $Date: 2009-09-17 11:14:56 $ + Version: $Revision: 1.99 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -171,14 +171,16 @@ public: CoordRepType,PointsContainer> BoundingBoxType; /** Create types that are pointers to each of the container types. */ - typedef typename PointsContainer::Pointer PointsContainerPointer; - typedef typename CellsContainer::Pointer CellsContainerPointer; - typedef typename CellsContainer::ConstPointer CellsContainerConstPointer; - typedef typename CellLinksContainer::Pointer CellLinksContainerPointer; - typedef typename PointDataContainer::Pointer PointDataContainerPointer; - typedef typename CellDataContainer::Pointer CellDataContainerPointer; - typedef typename PointLocatorType::Pointer PointLocatorPointer; - typedef typename BoundingBoxType::Pointer BoundingBoxPointer; + typedef typename PointsContainer::Pointer PointsContainerPointer; + typedef typename CellsContainer::Pointer CellsContainerPointer; + typedef typename CellsContainer::ConstPointer CellsContainerConstPointer; + typedef typename CellLinksContainer::Pointer CellLinksContainerPointer; + typedef typename PointDataContainer::Pointer PointDataContainerPointer; + typedef typename CellDataContainer::Pointer CellDataContainerPointer; + typedef typename CellDataContainer::ConstPointer CellDataContainerConstPointer; + typedef typename PointLocatorType::Pointer PointLocatorPointer; + typedef typename BoundingBoxType::Pointer BoundingBoxPointer; + typedef typename CellLinksContainer::ConstPointer CellLinksContainerConstPointer; /** Create types that are iterators for each of the container types. */ typedef typename @@ -282,7 +284,7 @@ protected: /** An object containing parent cell links for each point. Since a point * can be used by multiple cells, each point identifier accesses another * container which holds the cell identifiers */ - CellLinksContainerPointer m_CellLinksContainer; + mutable CellLinksContainerPointer m_CellLinksContainer; /** A vector of objects containing explicit cell boundary assignments. * The vector is indexed by the topological dimension of the cell @@ -428,7 +430,7 @@ public: #endif /** Dynamically build the links from points back to their using cells. This * information is stored in the cell links container, not in the points. */ - void BuildCellLinks(); + void BuildCellLinks() const; #ifndef CABLE_CONFIGURATION /** Get the bounding box of a cell in the mesh. The user @@ -440,7 +442,7 @@ public: /** This method iterates over all the cells in the mesh and has * each cell Accept the MultiVisitor. See MultiVisitor for more * information. (Note, this follows the Visitor Design Pattern.) */ - virtual void Accept(CellMultiVisitorType* mv); + virtual void Accept(CellMultiVisitorType* mv) const; #endif /** Set/Get the identification of the method used to allocate cells \warning Failure to call this method correctly will lead to memory leaks diff --git a/Utilities/ITK/Code/Common/itkMesh.txx b/Utilities/ITK/Code/Common/itkMesh.txx index f0e868de89b35da4c82fe95b41b414b61016397e..a2488c97a612a9b7aa6b2d9540c88ee57ddab38d 100644 --- a/Utilities/ITK/Code/Common/itkMesh.txx +++ b/Utilities/ITK/Code/Common/itkMesh.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkMesh.txx,v $ Language: C++ - Date: $Date: 2009-06-21 23:14:45 $ - Version: $Revision: 1.103 $ + Date: $Date: 2009-09-17 11:14:56 $ + Version: $Revision: 1.104 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -79,6 +79,7 @@ Mesh<TPixelType, VDimension, TMeshTraits> << m_CellLinksContainer ); return m_CellLinksContainer; } + template <typename TPixelType, unsigned int VDimension, typename TMeshTraits> const typename Mesh<TPixelType, VDimension, TMeshTraits>::CellLinksContainer * Mesh<TPixelType, VDimension, TMeshTraits> @@ -955,23 +956,26 @@ Mesh<TPixelType, VDimension, TMeshTraits> template <typename TPixelType, unsigned int VDimension, typename TMeshTraits> void Mesh<TPixelType, VDimension, TMeshTraits> -::Accept(CellMultiVisitorType* mv) +::Accept(CellMultiVisitorType* mv) const { - if(!m_CellsContainer) + if(! this->m_CellsContainer) { return; } - for(CellsContainerIterator i = m_CellsContainer->Begin(); - i != m_CellsContainer->End(); ++i) + + CellsContainerConstIterator itr = this->m_CellsContainer->Begin(); + + while( itr != this->m_CellsContainer->End() ) { - if( i->Value() ) + if( itr->Value() ) { - i->Value()->Accept(i->Index(), mv); + itr->Value()->Accept(itr->Index(), mv); } else { - itkDebugMacro("Null cell at " << i->Index()); + itkDebugMacro("Null cell at " << itr->Index()); } + ++itr; } } @@ -983,7 +987,7 @@ Mesh<TPixelType, VDimension, TMeshTraits> template <typename TPixelType, unsigned int VDimension, typename TMeshTraits> void Mesh<TPixelType, VDimension, TMeshTraits> -::BuildCellLinks() +::BuildCellLinks() const { /** * Make sure we have a cells and a points container. @@ -1001,7 +1005,7 @@ Mesh<TPixelType, VDimension, TMeshTraits> */ if( !m_CellLinksContainer ) { - this->SetCellLinks(CellLinksContainer::New()); + this->m_CellLinksContainer = CellLinksContainer::New(); } /** @@ -1214,7 +1218,6 @@ Mesh<TPixelType, VDimension, TMeshTraits> << typeid(Self*).name() ); } - this->m_CellsContainer = mesh->m_CellsContainer; this->m_CellDataContainer = mesh->m_CellDataContainer; this->m_CellLinksContainer = mesh->m_CellLinksContainer; diff --git a/Utilities/ITK/Code/Common/itkMeshToMeshFilter.h b/Utilities/ITK/Code/Common/itkMeshToMeshFilter.h index 31842c25f2f0e2312e7d6e66019fc0cdce4fcf33..c19f90a3e78b5a2fa90150f3580825fcf1c9592d 100644 --- a/Utilities/ITK/Code/Common/itkMeshToMeshFilter.h +++ b/Utilities/ITK/Code/Common/itkMeshToMeshFilter.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkMeshToMeshFilter.h,v $ Language: C++ - Date: $Date: 2009-02-05 22:04:14 $ - Version: $Revision: 1.19 $ + Date: $Date: 2009-09-17 11:14:57 $ + Version: $Revision: 1.20 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -52,20 +52,28 @@ public: itkTypeMacro(MeshToMeshFilter,MeshSource); /** Some convenient typedefs. */ - typedef TInputMesh InputMeshType; - typedef typename InputMeshType::Pointer InputMeshPointer; + typedef TInputMesh InputMeshType; + typedef typename InputMeshType::Pointer InputMeshPointer; + typedef TOutputMesh OutputMeshType; + typedef typename OutputMeshType::Pointer OutputMeshPointer; /** Set the mesh input of this process object. */ - void SetInput(InputMeshType *input); + void SetInput( const InputMeshType *input); /** Get the mesh input of this process object. */ - InputMeshType * GetInput(void); - InputMeshType * GetInput(unsigned int idx); + const InputMeshType * GetInput(void) const; + const InputMeshType * GetInput(unsigned int idx) const; protected: MeshToMeshFilter(); ~MeshToMeshFilter() {}; + void CopyInputMeshToOutputMeshPoints(); + void CopyInputMeshToOutputMeshPointData(); + void CopyInputMeshToOutputMeshCellLinks(); + void CopyInputMeshToOutputMeshCells(); + void CopyInputMeshToOutputMeshCellData(); + private: MeshToMeshFilter(const Self&); //purposely not implemented void operator=(const Self&); //purposely not implemented diff --git a/Utilities/ITK/Code/Common/itkMeshToMeshFilter.txx b/Utilities/ITK/Code/Common/itkMeshToMeshFilter.txx index a1a3351b33f437fe9ab1f456c56d8b8627ce71fd..7b177a20803b12e0bddfc2f64680863ccf21ccb7 100644 --- a/Utilities/ITK/Code/Common/itkMeshToMeshFilter.txx +++ b/Utilities/ITK/Code/Common/itkMeshToMeshFilter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkMeshToMeshFilter.txx,v $ Language: C++ - Date: $Date: 2009-02-05 22:04:14 $ - Version: $Revision: 1.20 $ + Date: $Date: 2009-09-17 11:14:57 $ + Version: $Revision: 1.21 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -45,9 +45,11 @@ MeshToMeshFilter<TInputMesh,TOutputMesh> template <class TInputMesh, class TOutputMesh> void MeshToMeshFilter<TInputMesh,TOutputMesh> -::SetInput(TInputMesh *input) +::SetInput(const TInputMesh *input) { - this->ProcessObject::SetNthInput(0, input); + // Process object is not const-correct so the const_cast is required here + this->ProcessObject::SetNthInput(0, + const_cast< TInputMesh * >( input ) ); } @@ -55,16 +57,16 @@ MeshToMeshFilter<TInputMesh,TOutputMesh> * */ template <class TInputMesh, class TOutputMesh> -typename MeshToMeshFilter<TInputMesh,TOutputMesh>::InputMeshType * +const typename MeshToMeshFilter<TInputMesh,TOutputMesh>::InputMeshType * MeshToMeshFilter<TInputMesh,TOutputMesh> -::GetInput() +::GetInput() const { if (this->GetNumberOfInputs() < 1) { return 0; } - return static_cast<TInputMesh*> + return static_cast< const TInputMesh * > (this->ProcessObject::GetInput(0)); } @@ -73,14 +75,198 @@ MeshToMeshFilter<TInputMesh,TOutputMesh> * */ template <class TInputMesh, class TOutputMesh> -typename MeshToMeshFilter<TInputMesh,TOutputMesh>::InputMeshType * +const typename MeshToMeshFilter<TInputMesh,TOutputMesh>::InputMeshType * MeshToMeshFilter<TInputMesh,TOutputMesh> -::GetInput(unsigned int idx) +::GetInput(unsigned int idx) const { - return static_cast<TInputMesh*> + return dynamic_cast<const TInputMesh*> (this->ProcessObject::GetInput(idx)); } + +template <class TInputMesh, class TOutputMesh> +void +MeshToMeshFilter<TInputMesh,TOutputMesh> +::CopyInputMeshToOutputMeshPoints(void) +{ + const InputMeshType * inputMesh = this->GetInput(); + OutputMeshPointer outputMesh = this->GetOutput(); + + typedef typename TOutputMesh::PointsContainer OutputPointsContainer; + typedef typename TInputMesh::PointsContainer InputPointsContainer; + + typename OutputPointsContainer::Pointer outputPoints = OutputPointsContainer::New(); + const InputPointsContainer * inputPoints = inputMesh->GetPoints(); + + if( inputPoints ) + { + outputPoints->Reserve( inputPoints->Size() ); + + typename InputPointsContainer::ConstIterator inputItr = inputPoints->Begin(); + typename InputPointsContainer::ConstIterator inputEnd = inputPoints->End(); + + typename OutputPointsContainer::Iterator outputItr = outputPoints->Begin(); + + while( inputItr != inputEnd ) + { + outputItr.Value() = inputItr.Value(); + ++inputItr; + ++outputItr; + } + + outputMesh->SetPoints( outputPoints ); + } +} + + +template <class TInputMesh, class TOutputMesh> +void +MeshToMeshFilter<TInputMesh,TOutputMesh> +::CopyInputMeshToOutputMeshPointData(void) +{ + const InputMeshType * inputMesh = this->GetInput(); + OutputMeshPointer outputMesh = this->GetOutput(); + + typedef typename TOutputMesh::PointDataContainer OutputPointDataContainer; + typedef typename TInputMesh::PointDataContainer InputPointDataContainer; + + typename OutputPointDataContainer::Pointer outputPointData = OutputPointDataContainer::New(); + const InputPointDataContainer * inputPointData = inputMesh->GetPointData(); + + if( inputPointData ) + { + outputPointData->Reserve( inputPointData->Size() ); + + typename InputPointDataContainer::ConstIterator inputItr = inputPointData->Begin(); + typename InputPointDataContainer::ConstIterator inputEnd = inputPointData->End(); + + typename OutputPointDataContainer::Iterator outputItr = outputPointData->Begin(); + + while( inputItr != inputEnd ) + { + outputItr.Value() = inputItr.Value(); + ++inputItr; + ++outputItr; + } + + outputMesh->SetPointData( outputPointData ); + } +} + + +template <class TInputMesh, class TOutputMesh> +void +MeshToMeshFilter<TInputMesh,TOutputMesh> +::CopyInputMeshToOutputMeshCellLinks(void) +{ + const InputMeshType * inputMesh = this->GetInput(); + OutputMeshPointer outputMesh = this->GetOutput(); + + typedef typename TOutputMesh::CellLinksContainer OutputCellLinksContainer; + typedef typename TInputMesh::CellLinksContainer InputCellLinksContainer; + + typename OutputCellLinksContainer::Pointer outputCellLinks = OutputCellLinksContainer::New(); + const InputCellLinksContainer * inputCellLinks = inputMesh->GetCellLinks(); + + if( inputCellLinks ) + { + outputCellLinks->Reserve( inputCellLinks->Size() ); + + typename InputCellLinksContainer::ConstIterator inputItr = inputCellLinks->Begin(); + typename InputCellLinksContainer::ConstIterator inputEnd = inputCellLinks->End(); + + typename OutputCellLinksContainer::Iterator outputItr = outputCellLinks->Begin(); + + while( inputItr != inputEnd ) + { + outputItr.Value() = inputItr.Value(); + ++inputItr; + ++outputItr; + } + + outputMesh->SetCellLinks( outputCellLinks ); + } +} + + +template <class TInputMesh, class TOutputMesh> +void +MeshToMeshFilter<TInputMesh,TOutputMesh> +::CopyInputMeshToOutputMeshCells(void) +{ + const InputMeshType * inputMesh = this->GetInput(); + OutputMeshPointer outputMesh = this->GetOutput(); + + typedef typename TOutputMesh::CellsContainer OutputCellsContainer; + typedef typename TInputMesh::CellsContainer InputCellsContainer; + typedef typename TOutputMesh::CellAutoPointer CellAutoPointer; + + outputMesh->SetCellsAllocationMethod( OutputMeshType::CellsAllocatedDynamicallyCellByCell ); + + typename OutputCellsContainer::Pointer outputCells = OutputCellsContainer::New(); + const InputCellsContainer * inputCells = inputMesh->GetCells(); + + if( inputCells ) + { + outputCells->Reserve( inputCells->Size() ); + + typename InputCellsContainer::ConstIterator inputItr = inputCells->Begin(); + typename InputCellsContainer::ConstIterator inputEnd = inputCells->End(); + + typename OutputCellsContainer::Iterator outputItr = outputCells->Begin(); + + CellAutoPointer clone; + + while( inputItr != inputEnd ) + { +// outputItr.Value() = inputItr.Value(); + // BUG: FIXME: Here we are copying a pointer, which is a mistake. What we should do is to clone the cell. + inputItr.Value()->MakeCopy( clone ); + outputItr.Value() = clone.ReleaseOwnership(); + + ++inputItr; + ++outputItr; + } + + outputMesh->SetCells( outputCells ); + } +} + + +template <class TInputMesh, class TOutputMesh> +void +MeshToMeshFilter<TInputMesh,TOutputMesh> +::CopyInputMeshToOutputMeshCellData(void) +{ + const InputMeshType * inputMesh = this->GetInput(); + OutputMeshPointer outputMesh = this->GetOutput(); + + typedef typename TOutputMesh::CellDataContainer OutputCellDataContainer; + typedef typename TInputMesh::CellDataContainer InputCellDataContainer; + + typename OutputCellDataContainer::Pointer outputCellData = OutputCellDataContainer::New(); + const InputCellDataContainer * inputCellData = inputMesh->GetCellData(); + + if( inputCellData ) + { + outputCellData->Reserve( inputCellData->Size() ); + + typename InputCellDataContainer::ConstIterator inputItr = inputCellData->Begin(); + typename InputCellDataContainer::ConstIterator inputEnd = inputCellData->End(); + + typename OutputCellDataContainer::Iterator outputItr = outputCellData->Begin(); + + while( inputItr != inputEnd ) + { + outputItr.Value() = inputItr.Value(); + ++inputItr; + ++outputItr; + } + + outputMesh->SetCellData( outputCellData ); + } +} + } // end namespace itk diff --git a/Utilities/ITK/Code/Common/itkMultiThreader.h b/Utilities/ITK/Code/Common/itkMultiThreader.h index 4482695932d564bc4d0ad88c7ea3cac099d2f0eb..24d72bdf0a3fc7640b32402f0b19b6f9e4b6f06a 100644 --- a/Utilities/ITK/Code/Common/itkMultiThreader.h +++ b/Utilities/ITK/Code/Common/itkMultiThreader.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkMultiThreader.h,v $ Language: C++ - Date: $Date: 2009-06-14 08:50:53 $ - Version: $Revision: 1.32 $ + Date: $Date: 2009-11-22 13:34:19 $ + Version: $Revision: 1.34 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -88,10 +88,11 @@ namespace itk #define ITK_MAX_THREADS 128 #endif -// mingw threads cause crashes so limit to 1 +// at one point, mingw threads caused crashes so limit was set to 1 +// as of July 2009, all tests are passing with threads enabled #if defined(__MINGW32__) #undef ITK_MAX_THREADS -#define ITK_MAX_THREADS 1 +#define ITK_MAX_THREADS 128 #endif // On some sgi machines, threads and stl don't mix so limit to 1 @@ -204,9 +205,9 @@ public: #ifdef ITK_USE_SPROC static bool GetInitialized() - { return m_Initialized; } + { return m_Initialized; } static usptr_t * GetThreadArena() - { return m_ThreadArena; } + { return m_ThreadArena; } static void Initialize(); #endif diff --git a/Utilities/ITK/Code/Common/itkNearestNeighborExtrapolateImageFunction.h b/Utilities/ITK/Code/Common/itkNearestNeighborExtrapolateImageFunction.h index ed6a97d8ebdf8407336cb0506f2b4dadd644c467..ab3165e9acde5b5bc3f7daf4e407b265a51bd336 100644 --- a/Utilities/ITK/Code/Common/itkNearestNeighborExtrapolateImageFunction.h +++ b/Utilities/ITK/Code/Common/itkNearestNeighborExtrapolateImageFunction.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkNearestNeighborExtrapolateImageFunction.h,v $ Language: C++ - Date: $Date: 2009-08-08 14:29:02 $ - Version: $Revision: 1.10 $ + Date: $Date: 2009-10-29 17:37:04 $ + Version: $Revision: 1.12 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -63,7 +63,8 @@ public: itkStaticConstMacro(ImageDimension, unsigned int,Superclass::ImageDimension); /** Index typedef support. */ - typedef typename Superclass::IndexType IndexType; + typedef typename Superclass::IndexType IndexType; + typedef typename Superclass::IndexValueType IndexValueType; /** ContinuousIndex typedef support. */ typedef typename Superclass::ContinuousIndexType ContinuousIndexType; @@ -78,11 +79,10 @@ public: virtual OutputType EvaluateAtContinuousIndex( const ContinuousIndexType & index ) const { - typedef typename IndexType::IndexValueType ValueType; IndexType nindex; for ( unsigned int j = 0; j < ImageDimension; j++ ) { - nindex[j] = static_cast<ValueType>( itk::Math::RoundHalfIntegerUp( index[j] ) ); + nindex[j] = Math::RoundHalfIntegerUp<IndexValueType>( index[j] ); if ( nindex[j] < this->GetStartIndex()[j] ) { nindex[j] = this->GetStartIndex()[j]; diff --git a/Utilities/ITK/Code/Common/itkNonUniformBSpline.h b/Utilities/ITK/Code/Common/itkNonUniformBSpline.h old mode 100644 new mode 100755 index 1b456f9ee77461c9a0785c1eb20b13fbf266befb..0c18ceec4c606dd45cdc3d020e3c3086e4b4a158 --- a/Utilities/ITK/Code/Common/itkNonUniformBSpline.h +++ b/Utilities/ITK/Code/Common/itkNonUniformBSpline.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkNonUniformBSpline.h,v $ Language: C++ - Date: $Date: 2009-02-06 20:53:13 $ - Version: $Revision: 1.5 $ + Date: $Date: 2010-03-25 14:57:49 $ + Version: $Revision: 1.6 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -73,17 +73,14 @@ public: itkTypeMacro( NonUniformBSpline, Object ); /** - Set points which the spline will attempt to interpolate. - */ + * Set points which the spline will attempt to interpolate. + */ void SetPoints( PointListType & newPoints ); /** - Get the points the spline is trying to interpolate. - */ - PointListType& GetPoints() - { - return m_Points; - } + * Get the points the spline is trying to interpolate. + */ + itkGetConstReferenceMacro( Points, PointListType ); /** * Set the knot vector. Knots may be nonuniformly spaced. @@ -121,10 +118,7 @@ public: /** * Get the control points for the spline */ - ControlPointListType& GetControlPoints() - { - return m_ControlPoints; - } + itkGetConstReferenceMacro( ControlPoints, ControlPointListType ); /** * Evaluate the basis functions directly. @@ -137,19 +131,9 @@ public: /** * Set the order of the spline. */ - void SetSplineOrder(unsigned int order) - { - m_SplineOrder = order; - this->Modified(); - } + itkSetMacro( SplineOrder, unsigned int ); + itkGetConstReferenceMacro( SplineOrder, unsigned int ); - /** - * Get the order of the spline. - */ - unsigned int GetSplineOrder() - { - return m_SplineOrder; - } protected: diff --git a/Utilities/ITK/Code/Common/itkNonUniformBSpline.txx b/Utilities/ITK/Code/Common/itkNonUniformBSpline.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Common/itkNumericTraits.cxx b/Utilities/ITK/Code/Common/itkNumericTraits.cxx index dbd1e3947d9905eb8a10a48ef722af6c8da297fb..8e78a906b148786681a495af99ff7ca6886a4214 100644 --- a/Utilities/ITK/Code/Common/itkNumericTraits.cxx +++ b/Utilities/ITK/Code/Common/itkNumericTraits.cxx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkNumericTraits.cxx,v $ Language: C++ - Date: $Date: 2007-12-23 17:59:29 $ - Version: $Revision: 1.11 $ + Date: $Date: 2009-11-30 15:29:34 $ + Version: $Revision: 1.13 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -57,12 +57,6 @@ const double NumericTraits<double>::One = 1.0; const long double NumericTraits<long double>::Zero = 0.0; const long double NumericTraits<long double>::One = 1.0; - -#ifdef _WIN64 -typedef std::string::size_type size_type; -const size_type NumericTraits<size_type>::Zero = 0.0; -const size_type NumericTraits<size_type>::One = 1.0; -#endif const std::complex<float> NumericTraits< std::complex<float> >::Zero = std::complex<float>(0.0f,0.0f); const std::complex<float> NumericTraits< std::complex<float> >::One = std::complex<float>(1.0f,0.0f); @@ -70,4 +64,13 @@ const std::complex<float> NumericTraits< std::complex<float> >::One = std::com const std::complex<double> NumericTraits< std::complex<double> >::Zero = std::complex<double>(0.0,0.0); const std::complex<double> NumericTraits< std::complex<double> >::One = std::complex<double>(1.0,0.0); + +#ifdef ITK_TYPE_USE_LONG_LONG +const long long NumericTraits<long long>::Zero = 0LL; +const long long NumericTraits<long long>::One = 1LL; +const unsigned long long NumericTraits<unsigned long long>::Zero = 0ULL; +const unsigned long long NumericTraits<unsigned long long>::One = 1ULL; +#endif + + } // end namespace itk diff --git a/Utilities/ITK/Code/Common/itkNumericTraits.h b/Utilities/ITK/Code/Common/itkNumericTraits.h index 9cc93715e339433974ae29642b9ad1ff07990932..530607baddca3a01feeaa8cb9586927746aff2ed 100644 --- a/Utilities/ITK/Code/Common/itkNumericTraits.h +++ b/Utilities/ITK/Code/Common/itkNumericTraits.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkNumericTraits.h,v $ Language: C++ - Date: $Date: 2009-07-12 10:48:39 $ - Version: $Revision: 1.58 $ + Date: $Date: 2010-04-05 18:05:48 $ + Version: $Revision: 1.65 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -140,8 +140,8 @@ public: static bool NonpositiveMin() { return false; } static bool IsPositive(bool val) { return val; } static bool IsNonpositive(bool val) { return !val; } - static bool IsNegative(bool /* val */) { return false; } - static bool IsNonnegative(bool /*val*/) {return true; } + static bool IsNegative(bool val) { return val ? false : false; } + static bool IsNonnegative(bool val) {return val ? true : true; } static bool ZeroValue() { return Zero; } static bool OneValue() { return One; } }; @@ -245,8 +245,8 @@ public: static unsigned char NonpositiveMin() { return vcl_numeric_limits<ValueType>::min(); } static bool IsPositive(unsigned char val) { return val != Zero; } static bool IsNonpositive(unsigned char val) { return val == Zero; } - static bool IsNegative(unsigned char /* val */) { return false; } - static bool IsNonnegative(unsigned char /*val */) {return true; } + static bool IsNegative(unsigned char val ) { return val ? false : false; } + static bool IsNonnegative(unsigned char val) {return val ? true : true; } static unsigned char ZeroValue() { return Zero; } static unsigned char OneValue() { return One; } static ValueType Clamp(ValueType val,ValueType minVal, ValueType maxVal) @@ -304,10 +304,10 @@ public: itkNUMERIC_TRAITS_MIN_MAX_MACRO(); static unsigned short NonpositiveMin() { return vcl_numeric_limits<ValueType>::min(); } - static unsigned short IsPositive(unsigned short val) { return val != Zero; } + static bool IsPositive(unsigned short val) { return val != Zero; } static bool IsNonpositive(unsigned short val) { return val == Zero; } - static bool IsNegative(unsigned short/* val*/) { return false; } - static bool IsNonnegative(unsigned short /*val*/) {return true; } + static bool IsNegative(unsigned short val) { return val ? false : false; } + static bool IsNonnegative(unsigned short val) {return val ? true : true; } static unsigned short ZeroValue() { return Zero; } static unsigned short OneValue() { return One; } static ValueType Clamp(ValueType val,ValueType minVal, ValueType maxVal) @@ -370,8 +370,8 @@ public: static unsigned int NonpositiveMin() { return 0; } static bool IsPositive(unsigned int val) { return val != Zero; } static bool IsNonpositive(unsigned int val) { return val == Zero; } - static bool IsNegative(unsigned int /*val*/) { return false; } - static bool IsNonnegative(unsigned int /*val*/) {return true; } + static bool IsNegative(unsigned int val) { return val ? false : false; } + static bool IsNonnegative(unsigned int val) {return val ? true : true; } static unsigned int ZeroValue() { return Zero; } static unsigned int OneValue() { return One; } static ValueType Clamp(ValueType val,ValueType minVal, ValueType maxVal) @@ -620,42 +620,65 @@ public: } }; - -#if 0 -#ifndef ITK_TYPE_SAME_LONG_AND___INT64 -/** \class NumericTraits< __int64 > - * \brief Define traits for type std::complex<double>. +#ifdef ITK_TYPE_USE_LONG_LONG +/** \class NumericTraits<long long> + * \brief Define traits for type long long. * \ingroup DataRepresentation */ template <> -class NumericTraits< __int64 > { +class NumericTraits<long long> +: public vcl_numeric_limits<long long> { public: - typedef __int64 TheType; - typedef __int64 ValueType; - typedef TheType PrintType; - typedef __int64 AbsType; - typedef TheType AccumulateType; - typedef double RealType; - typedef double ScalarRealType; - typedef double FloatType; + typedef long long ValueType; + typedef long long PrintType; + typedef long long AbsType; + typedef long long AccumulateType; + typedef double RealType; + typedef RealType ScalarRealType; + typedef float FloatType; - static const TheType ITKCommon_EXPORT Zero; - static const TheType ITKCommon_EXPORT One; + static const ValueType ITKCommon_EXPORT Zero; + static const ValueType ITKCommon_EXPORT One; - static TheType min( TheType ) { return vcl_numeric_limits<ValueType>::min(); } - static TheType max( TheType ) { return vcl_numeric_limits<ValueType>::max(); } - static TheType NonpositiveMin() { - return TheType(-NumericTraits<double>::NonpositiveMin(),0.0); } - static bool IsPositive(TheType val) { return val.real() > 0.0; } - static bool IsNonpositive(TheType val) { return val.real() <= 0.0; } - static bool IsNegative(TheType val) { return val.real() < 0.0; } - static bool IsNonnegative(TheType val) {return val.real() >= 0.0; } - static TheType ZeroValue() { return Zero; } - static TheType OneValue() { return One; } + itkNUMERIC_TRAITS_MIN_MAX_MACRO(); + static ValueType NonpositiveMin() { return vcl_numeric_limits<ValueType>::min(); } + static bool IsPositive(ValueType val) { return val > Zero; } + static bool IsNonpositive(ValueType val) { return val <= Zero; } + static bool IsNegative(ValueType val) { return val < Zero; } + static bool IsNonnegative(ValueType val) {return val >= Zero; } + static ValueType ZeroValue() { return Zero; } + static ValueType OneValue() { return One; } }; -#endif -#endif +/** \class NumericTraits<unsigned long long> + * \brief Define traits for type unsigned long long. + * \ingroup DataRepresentation + */ +template <> +class NumericTraits<unsigned long long> + : public vcl_numeric_limits<unsigned long long> { +public: + typedef unsigned long long ValueType; + typedef unsigned long long PrintType; + typedef unsigned long long AbsType; + typedef unsigned long long AccumulateType; + typedef double RealType; + typedef RealType ScalarRealType; + typedef float FloatType; + + static const ValueType ITKCommon_EXPORT Zero; + static const ValueType ITKCommon_EXPORT One; + + itkNUMERIC_TRAITS_MIN_MAX_MACRO(); + static ValueType NonpositiveMin() { return vcl_numeric_limits<ValueType>::min(); } + static bool IsPositive(ValueType val) { return val != Zero; } + static bool IsNonpositive(ValueType val) { return val == Zero; } + static bool IsNegative(ValueType) { return false; } + static bool IsNonnegative(ValueType) {return true; } + static ValueType ZeroValue() { return Zero; } + static ValueType OneValue() { return One; } +}; +#endif /* #ifdef ITK_TYPE_USE_LONG_LONG */ } // end namespace itk diff --git a/Utilities/ITK/Code/Common/itkNumericTraitsCovariantVectorPixel.cxx b/Utilities/ITK/Code/Common/itkNumericTraitsCovariantVectorPixel.cxx index 68aad7b7d07a19a1c85696a0c3e3ffa6c5b97a70..1d36986148fca638ceb8aaed1c299f8a6a53696d 100644 --- a/Utilities/ITK/Code/Common/itkNumericTraitsCovariantVectorPixel.cxx +++ b/Utilities/ITK/Code/Common/itkNumericTraitsCovariantVectorPixel.cxx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkNumericTraitsCovariantVectorPixel.cxx,v $ Language: C++ - Date: $Date: 2005-10-05 20:35:08 $ - Version: $Revision: 1.1 $ + Date: $Date: 2009-12-01 16:53:23 $ + Version: $Revision: 1.3 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -19,204 +19,21 @@ namespace itk { -const CovariantVector<unsigned char, 2> NumericTraits<CovariantVector<unsigned char, 2> >::Zero = CovariantVector<unsigned char, 2>( NumericTraits<unsigned char>::Zero ); -const CovariantVector<unsigned char, 2> NumericTraits<CovariantVector<unsigned char, 2> >::One = CovariantVector<unsigned char, 2>( NumericTraits<unsigned char>::One ); -const CovariantVector<signed char, 2> NumericTraits<CovariantVector<signed char, 2> >::Zero = CovariantVector<signed char, 2>( NumericTraits<signed char>::Zero ); -const CovariantVector<signed char, 2> NumericTraits<CovariantVector<signed char, 2> >::One = CovariantVector<signed char, 2>( NumericTraits<signed char>::One ); -const CovariantVector<char, 2> NumericTraits<CovariantVector<char, 2> >::Zero = CovariantVector<char, 2>( NumericTraits<char>::Zero ); -const CovariantVector<char, 2> NumericTraits<CovariantVector<char, 2> >::One = CovariantVector<char, 2>( NumericTraits<char>::One ); -const CovariantVector<short, 2> NumericTraits<CovariantVector<short, 2> >::Zero = CovariantVector<short, 2>( NumericTraits<short>::Zero ); -const CovariantVector<short, 2> NumericTraits<CovariantVector<short, 2> >::One = CovariantVector<short, 2>( NumericTraits<short>::One ); -const CovariantVector<unsigned short, 2> NumericTraits<CovariantVector<unsigned short, 2> >::Zero = CovariantVector<unsigned short, 2>( NumericTraits<unsigned short>::Zero ); -const CovariantVector<unsigned short, 2> NumericTraits<CovariantVector<unsigned short, 2> >::One = CovariantVector<unsigned short, 2>( NumericTraits<unsigned short>::One ); -const CovariantVector<int, 2> NumericTraits<CovariantVector<int, 2> >::Zero = CovariantVector<int, 2>( NumericTraits<int>::Zero ); -const CovariantVector<int, 2> NumericTraits<CovariantVector<int, 2> >::One = CovariantVector<int, 2>( NumericTraits<int>::One ); -const CovariantVector<unsigned int, 2> NumericTraits<CovariantVector<unsigned int, 2> >::Zero = CovariantVector<unsigned int, 2>( NumericTraits<unsigned int>::Zero ); -const CovariantVector<unsigned int, 2> NumericTraits<CovariantVector<unsigned int, 2> >::One = CovariantVector<unsigned int, 2>( NumericTraits<unsigned int>::One ); -const CovariantVector<long, 2> NumericTraits<CovariantVector<long, 2> >::Zero = CovariantVector<long, 2>( NumericTraits<long>::Zero ); -const CovariantVector<long, 2> NumericTraits<CovariantVector<long, 2> >::One = CovariantVector<long, 2>( NumericTraits<long>::One ); -const CovariantVector<unsigned long, 2> NumericTraits<CovariantVector<unsigned long, 2> >::Zero = CovariantVector<unsigned long, 2>( NumericTraits<unsigned long>::Zero ); -const CovariantVector<unsigned long, 2> NumericTraits<CovariantVector<unsigned long, 2> >::One = CovariantVector<unsigned long, 2>( NumericTraits<unsigned long>::One ); -const CovariantVector<float, 2> NumericTraits<CovariantVector<float, 2> >::Zero = CovariantVector<float, 2>( NumericTraits<float >::Zero ); -const CovariantVector<float, 2> NumericTraits<CovariantVector<float, 2> >::One = CovariantVector<float, 2>( NumericTraits<float>::One ); -const CovariantVector<double, 2> NumericTraits<CovariantVector<double, 2> >::Zero = CovariantVector<double , 2>( NumericTraits<double>::Zero ); -const CovariantVector<double, 2> NumericTraits<CovariantVector<double, 2> >::One = CovariantVector<double, 2>( NumericTraits<double>::One ); -const CovariantVector<long double, 2> NumericTraits<CovariantVector<long double, 2> >::Zero = CovariantVector<long double, 2>( NumericTraits<long double>::Zero ); -const CovariantVector<long double, 2> NumericTraits<CovariantVector<long double, 2> >::One = CovariantVector<long double, 2>( NumericTraits<long double>::One ); - -const CovariantVector<unsigned char, 3> NumericTraits<CovariantVector<unsigned char, 3> >::Zero = CovariantVector<unsigned char, 3>( NumericTraits<unsigned char>::Zero ); -const CovariantVector<unsigned char, 3> NumericTraits<CovariantVector<unsigned char, 3> >::One = CovariantVector<unsigned char, 3>( NumericTraits<unsigned char>::One ); -const CovariantVector<signed char, 3> NumericTraits<CovariantVector<signed char, 3> >::Zero = CovariantVector<signed char, 3>( NumericTraits<signed char>::Zero ); -const CovariantVector<signed char, 3> NumericTraits<CovariantVector<signed char, 3> >::One = CovariantVector<signed char, 3>( NumericTraits<signed char>::One ); -const CovariantVector<char, 3> NumericTraits<CovariantVector<char, 3> >::Zero = CovariantVector<char, 3>( NumericTraits<char>::Zero ); -const CovariantVector<char, 3> NumericTraits<CovariantVector<char, 3> >::One = CovariantVector<char, 3>( NumericTraits<char>::One ); -const CovariantVector<short, 3> NumericTraits<CovariantVector<short, 3> >::Zero = CovariantVector<short, 3>( NumericTraits<short>::Zero ); -const CovariantVector<short, 3> NumericTraits<CovariantVector<short, 3> >::One = CovariantVector<short, 3>( NumericTraits<short>::One ); -const CovariantVector<unsigned short, 3> NumericTraits<CovariantVector<unsigned short, 3> >::Zero = CovariantVector<unsigned short, 3>( NumericTraits<unsigned short>::Zero ); -const CovariantVector<unsigned short, 3> NumericTraits<CovariantVector<unsigned short, 3> >::One = CovariantVector<unsigned short, 3>( NumericTraits<unsigned short>::One ); -const CovariantVector<int, 3> NumericTraits<CovariantVector<int, 3> >::Zero = CovariantVector<int, 3>( NumericTraits<int>::Zero ); -const CovariantVector<int, 3> NumericTraits<CovariantVector<int, 3> >::One = CovariantVector<int, 3>( NumericTraits<int>::One ); -const CovariantVector<unsigned int, 3> NumericTraits<CovariantVector<unsigned int, 3> >::Zero = CovariantVector<unsigned int, 3>( NumericTraits<unsigned int>::Zero ); -const CovariantVector<unsigned int, 3> NumericTraits<CovariantVector<unsigned int, 3> >::One = CovariantVector<unsigned int, 3>( NumericTraits<unsigned int>::One ); -const CovariantVector<long, 3> NumericTraits<CovariantVector<long, 3> >::Zero = CovariantVector<long, 3>( NumericTraits<long>::Zero ); -const CovariantVector<long, 3> NumericTraits<CovariantVector<long, 3> >::One = CovariantVector<long, 3>( NumericTraits<long>::One ); -const CovariantVector<unsigned long, 3> NumericTraits<CovariantVector<unsigned long, 3> >::Zero = CovariantVector<unsigned long, 3>( NumericTraits<unsigned long>::Zero ); -const CovariantVector<unsigned long, 3> NumericTraits<CovariantVector<unsigned long, 3> >::One = CovariantVector<unsigned long, 3>( NumericTraits<unsigned long>::One ); -const CovariantVector<float, 3> NumericTraits<CovariantVector<float, 3> >::Zero = CovariantVector<float, 3>( NumericTraits<float >::Zero ); -const CovariantVector<float, 3> NumericTraits<CovariantVector<float, 3> >::One = CovariantVector<float, 3>( NumericTraits<float>::One ); -const CovariantVector<double, 3> NumericTraits<CovariantVector<double, 3> >::Zero = CovariantVector<double , 3>( NumericTraits<double>::Zero ); -const CovariantVector<double, 3> NumericTraits<CovariantVector<double, 3> >::One = CovariantVector<double, 3>( NumericTraits<double>::One ); -const CovariantVector<long double, 3> NumericTraits<CovariantVector<long double, 3> >::Zero = CovariantVector<long double, 3>( NumericTraits<long double>::Zero ); -const CovariantVector<long double, 3> NumericTraits<CovariantVector<long double, 3> >::One = CovariantVector<long double, 3>( NumericTraits<long double>::One ); - -const CovariantVector<unsigned char, 4> NumericTraits<CovariantVector<unsigned char, 4> >::Zero = CovariantVector<unsigned char, 4>( NumericTraits<unsigned char>::Zero ); -const CovariantVector<unsigned char, 4> NumericTraits<CovariantVector<unsigned char, 4> >::One = CovariantVector<unsigned char, 4>( NumericTraits<unsigned char>::One ); -const CovariantVector<signed char, 4> NumericTraits<CovariantVector<signed char, 4> >::Zero = CovariantVector<signed char, 4>( NumericTraits<signed char>::Zero ); -const CovariantVector<signed char, 4> NumericTraits<CovariantVector<signed char, 4> >::One = CovariantVector<signed char, 4>( NumericTraits<signed char>::One ); -const CovariantVector<char, 4> NumericTraits<CovariantVector<char, 4> >::Zero = CovariantVector<char, 4>( NumericTraits<char>::Zero ); -const CovariantVector<char, 4> NumericTraits<CovariantVector<char, 4> >::One = CovariantVector<char, 4>( NumericTraits<char>::One ); -const CovariantVector<short, 4> NumericTraits<CovariantVector<short, 4> >::Zero = CovariantVector<short, 4>( NumericTraits<short>::Zero ); -const CovariantVector<short, 4> NumericTraits<CovariantVector<short, 4> >::One = CovariantVector<short, 4>( NumericTraits<short>::One ); -const CovariantVector<unsigned short, 4> NumericTraits<CovariantVector<unsigned short, 4> >::Zero = CovariantVector<unsigned short, 4>( NumericTraits<unsigned short>::Zero ); -const CovariantVector<unsigned short, 4> NumericTraits<CovariantVector<unsigned short, 4> >::One = CovariantVector<unsigned short, 4>( NumericTraits<unsigned short>::One ); -const CovariantVector<int, 4> NumericTraits<CovariantVector<int, 4> >::Zero = CovariantVector<int, 4>( NumericTraits<int>::Zero ); -const CovariantVector<int, 4> NumericTraits<CovariantVector<int, 4> >::One = CovariantVector<int, 4>( NumericTraits<int>::One ); -const CovariantVector<unsigned int, 4> NumericTraits<CovariantVector<unsigned int, 4> >::Zero = CovariantVector<unsigned int, 4>( NumericTraits<unsigned int>::Zero ); -const CovariantVector<unsigned int, 4> NumericTraits<CovariantVector<unsigned int, 4> >::One = CovariantVector<unsigned int, 4>( NumericTraits<unsigned int>::One ); -const CovariantVector<long, 4> NumericTraits<CovariantVector<long, 4> >::Zero = CovariantVector<long, 4>( NumericTraits<long>::Zero ); -const CovariantVector<long, 4> NumericTraits<CovariantVector<long, 4> >::One = CovariantVector<long, 4>( NumericTraits<long>::One ); -const CovariantVector<unsigned long, 4> NumericTraits<CovariantVector<unsigned long, 4> >::Zero = CovariantVector<unsigned long, 4>( NumericTraits<unsigned long>::Zero ); -const CovariantVector<unsigned long, 4> NumericTraits<CovariantVector<unsigned long, 4> >::One = CovariantVector<unsigned long, 4>( NumericTraits<unsigned long>::One ); -const CovariantVector<float, 4> NumericTraits<CovariantVector<float, 4> >::Zero = CovariantVector<float, 4>( NumericTraits<float >::Zero ); -const CovariantVector<float, 4> NumericTraits<CovariantVector<float, 4> >::One = CovariantVector<float, 4>( NumericTraits<float>::One ); -const CovariantVector<double, 4> NumericTraits<CovariantVector<double, 4> >::Zero = CovariantVector<double , 4>( NumericTraits<double>::Zero ); -const CovariantVector<double, 4> NumericTraits<CovariantVector<double, 4> >::One = CovariantVector<double, 4>( NumericTraits<double>::One ); -const CovariantVector<long double, 4> NumericTraits<CovariantVector<long double, 4> >::Zero = CovariantVector<long double, 4>( NumericTraits<long double>::Zero ); -const CovariantVector<long double, 4> NumericTraits<CovariantVector<long double, 4> >::One = CovariantVector<long double, 4>( NumericTraits<long double>::One ); - -const CovariantVector<unsigned char, 5> NumericTraits<CovariantVector<unsigned char, 5> >::Zero = CovariantVector<unsigned char, 5>( NumericTraits<unsigned char>::Zero ); -const CovariantVector<unsigned char, 5> NumericTraits<CovariantVector<unsigned char, 5> >::One = CovariantVector<unsigned char, 5>( NumericTraits<unsigned char>::One ); -const CovariantVector<signed char, 5> NumericTraits<CovariantVector<signed char, 5> >::Zero = CovariantVector<signed char, 5>( NumericTraits<signed char>::Zero ); -const CovariantVector<signed char, 5> NumericTraits<CovariantVector<signed char, 5> >::One = CovariantVector<signed char, 5>( NumericTraits<signed char>::One ); -const CovariantVector<char, 5> NumericTraits<CovariantVector<char, 5> >::Zero = CovariantVector<char, 5>( NumericTraits<char>::Zero ); -const CovariantVector<char, 5> NumericTraits<CovariantVector<char, 5> >::One = CovariantVector<char, 5>( NumericTraits<char>::One ); -const CovariantVector<short, 5> NumericTraits<CovariantVector<short, 5> >::Zero = CovariantVector<short, 5>( NumericTraits<short>::Zero ); -const CovariantVector<short, 5> NumericTraits<CovariantVector<short, 5> >::One = CovariantVector<short, 5>( NumericTraits<short>::One ); -const CovariantVector<unsigned short, 5> NumericTraits<CovariantVector<unsigned short, 5> >::Zero = CovariantVector<unsigned short, 5>( NumericTraits<unsigned short>::Zero ); -const CovariantVector<unsigned short, 5> NumericTraits<CovariantVector<unsigned short, 5> >::One = CovariantVector<unsigned short, 5>( NumericTraits<unsigned short>::One ); -const CovariantVector<int, 5> NumericTraits<CovariantVector<int, 5> >::Zero = CovariantVector<int, 5>( NumericTraits<int>::Zero ); -const CovariantVector<int, 5> NumericTraits<CovariantVector<int, 5> >::One = CovariantVector<int, 5>( NumericTraits<int>::One ); -const CovariantVector<unsigned int, 5> NumericTraits<CovariantVector<unsigned int, 5> >::Zero = CovariantVector<unsigned int, 5>( NumericTraits<unsigned int>::Zero ); -const CovariantVector<unsigned int, 5> NumericTraits<CovariantVector<unsigned int, 5> >::One = CovariantVector<unsigned int, 5>( NumericTraits<unsigned int>::One ); -const CovariantVector<long, 5> NumericTraits<CovariantVector<long, 5> >::Zero = CovariantVector<long, 5>( NumericTraits<long>::Zero ); -const CovariantVector<long, 5> NumericTraits<CovariantVector<long, 5> >::One = CovariantVector<long, 5>( NumericTraits<long>::One ); -const CovariantVector<unsigned long, 5> NumericTraits<CovariantVector<unsigned long, 5> >::Zero = CovariantVector<unsigned long, 5>( NumericTraits<unsigned long>::Zero ); -const CovariantVector<unsigned long, 5> NumericTraits<CovariantVector<unsigned long, 5> >::One = CovariantVector<unsigned long, 5>( NumericTraits<unsigned long>::One ); -const CovariantVector<float, 5> NumericTraits<CovariantVector<float, 5> >::Zero = CovariantVector<float, 5>( NumericTraits<float >::Zero ); -const CovariantVector<float, 5> NumericTraits<CovariantVector<float, 5> >::One = CovariantVector<float, 5>( NumericTraits<float>::One ); -const CovariantVector<double, 5> NumericTraits<CovariantVector<double, 5> >::Zero = CovariantVector<double , 5>( NumericTraits<double>::Zero ); -const CovariantVector<double, 5> NumericTraits<CovariantVector<double, 5> >::One = CovariantVector<double, 5>( NumericTraits<double>::One ); -const CovariantVector<long double, 5> NumericTraits<CovariantVector<long double, 5> >::Zero = CovariantVector<long double, 5>( NumericTraits<long double>::Zero ); -const CovariantVector<long double, 5> NumericTraits<CovariantVector<long double, 5> >::One = CovariantVector<long double, 5>( NumericTraits<long double>::One ); - -const CovariantVector<unsigned char, 6> NumericTraits<CovariantVector<unsigned char, 6> >::Zero = CovariantVector<unsigned char, 6>( NumericTraits<unsigned char>::Zero ); -const CovariantVector<unsigned char, 6> NumericTraits<CovariantVector<unsigned char, 6> >::One = CovariantVector<unsigned char, 6>( NumericTraits<unsigned char>::One ); -const CovariantVector<signed char, 6> NumericTraits<CovariantVector<signed char, 6> >::Zero = CovariantVector<signed char, 6>( NumericTraits<signed char>::Zero ); -const CovariantVector<signed char, 6> NumericTraits<CovariantVector<signed char, 6> >::One = CovariantVector<signed char, 6>( NumericTraits<signed char>::One ); -const CovariantVector<char, 6> NumericTraits<CovariantVector<char, 6> >::Zero = CovariantVector<char, 6>( NumericTraits<char>::Zero ); -const CovariantVector<char, 6> NumericTraits<CovariantVector<char, 6> >::One = CovariantVector<char, 6>( NumericTraits<char>::One ); -const CovariantVector<short, 6> NumericTraits<CovariantVector<short, 6> >::Zero = CovariantVector<short, 6>( NumericTraits<short>::Zero ); -const CovariantVector<short, 6> NumericTraits<CovariantVector<short, 6> >::One = CovariantVector<short, 6>( NumericTraits<short>::One ); -const CovariantVector<unsigned short, 6> NumericTraits<CovariantVector<unsigned short, 6> >::Zero = CovariantVector<unsigned short, 6>( NumericTraits<unsigned short>::Zero ); -const CovariantVector<unsigned short, 6> NumericTraits<CovariantVector<unsigned short, 6> >::One = CovariantVector<unsigned short, 6>( NumericTraits<unsigned short>::One ); -const CovariantVector<int, 6> NumericTraits<CovariantVector<int, 6> >::Zero = CovariantVector<int, 6>( NumericTraits<int>::Zero ); -const CovariantVector<int, 6> NumericTraits<CovariantVector<int, 6> >::One = CovariantVector<int, 6>( NumericTraits<int>::One ); -const CovariantVector<unsigned int, 6> NumericTraits<CovariantVector<unsigned int, 6> >::Zero = CovariantVector<unsigned int, 6>( NumericTraits<unsigned int>::Zero ); -const CovariantVector<unsigned int, 6> NumericTraits<CovariantVector<unsigned int, 6> >::One = CovariantVector<unsigned int, 6>( NumericTraits<unsigned int>::One ); -const CovariantVector<long, 6> NumericTraits<CovariantVector<long, 6> >::Zero = CovariantVector<long, 6>( NumericTraits<long>::Zero ); -const CovariantVector<long, 6> NumericTraits<CovariantVector<long, 6> >::One = CovariantVector<long, 6>( NumericTraits<long>::One ); -const CovariantVector<unsigned long, 6> NumericTraits<CovariantVector<unsigned long, 6> >::Zero = CovariantVector<unsigned long, 6>( NumericTraits<unsigned long>::Zero ); -const CovariantVector<unsigned long, 6> NumericTraits<CovariantVector<unsigned long, 6> >::One = CovariantVector<unsigned long, 6>( NumericTraits<unsigned long>::One ); -const CovariantVector<float, 6> NumericTraits<CovariantVector<float, 6> >::Zero = CovariantVector<float, 6>( NumericTraits<float >::Zero ); -const CovariantVector<float, 6> NumericTraits<CovariantVector<float, 6> >::One = CovariantVector<float, 6>( NumericTraits<float>::One ); -const CovariantVector<double, 6> NumericTraits<CovariantVector<double, 6> >::Zero = CovariantVector<double , 6>( NumericTraits<double>::Zero ); -const CovariantVector<double, 6> NumericTraits<CovariantVector<double, 6> >::One = CovariantVector<double, 6>( NumericTraits<double>::One ); -const CovariantVector<long double, 6> NumericTraits<CovariantVector<long double, 6> >::Zero = CovariantVector<long double, 6>( NumericTraits<long double>::Zero ); -const CovariantVector<long double, 6> NumericTraits<CovariantVector<long double, 6> >::One = CovariantVector<long double, 6>( NumericTraits<long double>::One ); - -const CovariantVector<unsigned char, 7> NumericTraits<CovariantVector<unsigned char, 7> >::Zero = CovariantVector<unsigned char, 7>( NumericTraits<unsigned char>::Zero ); -const CovariantVector<unsigned char, 7> NumericTraits<CovariantVector<unsigned char, 7> >::One = CovariantVector<unsigned char, 7>( NumericTraits<unsigned char>::One ); -const CovariantVector<signed char, 7> NumericTraits<CovariantVector<signed char, 7> >::Zero = CovariantVector<signed char, 7>( NumericTraits<signed char>::Zero ); -const CovariantVector<signed char, 7> NumericTraits<CovariantVector<signed char, 7> >::One = CovariantVector<signed char, 7>( NumericTraits<signed char>::One ); -const CovariantVector<char, 7> NumericTraits<CovariantVector<char, 7> >::Zero = CovariantVector<char, 7>( NumericTraits<char>::Zero ); -const CovariantVector<char, 7> NumericTraits<CovariantVector<char, 7> >::One = CovariantVector<char, 7>( NumericTraits<char>::One ); -const CovariantVector<short, 7> NumericTraits<CovariantVector<short, 7> >::Zero = CovariantVector<short, 7>( NumericTraits<short>::Zero ); -const CovariantVector<short, 7> NumericTraits<CovariantVector<short, 7> >::One = CovariantVector<short, 7>( NumericTraits<short>::One ); -const CovariantVector<unsigned short, 7> NumericTraits<CovariantVector<unsigned short, 7> >::Zero = CovariantVector<unsigned short, 7>( NumericTraits<unsigned short>::Zero ); -const CovariantVector<unsigned short, 7> NumericTraits<CovariantVector<unsigned short, 7> >::One = CovariantVector<unsigned short, 7>( NumericTraits<unsigned short>::One ); -const CovariantVector<int, 7> NumericTraits<CovariantVector<int, 7> >::Zero = CovariantVector<int, 7>( NumericTraits<int>::Zero ); -const CovariantVector<int, 7> NumericTraits<CovariantVector<int, 7> >::One = CovariantVector<int, 7>( NumericTraits<int>::One ); -const CovariantVector<unsigned int, 7> NumericTraits<CovariantVector<unsigned int, 7> >::Zero = CovariantVector<unsigned int, 7>( NumericTraits<unsigned int>::Zero ); -const CovariantVector<unsigned int, 7> NumericTraits<CovariantVector<unsigned int, 7> >::One = CovariantVector<unsigned int, 7>( NumericTraits<unsigned int>::One ); -const CovariantVector<long, 7> NumericTraits<CovariantVector<long, 7> >::Zero = CovariantVector<long, 7>( NumericTraits<long>::Zero ); -const CovariantVector<long, 7> NumericTraits<CovariantVector<long, 7> >::One = CovariantVector<long, 7>( NumericTraits<long>::One ); -const CovariantVector<unsigned long, 7> NumericTraits<CovariantVector<unsigned long, 7> >::Zero = CovariantVector<unsigned long, 7>( NumericTraits<unsigned long>::Zero ); -const CovariantVector<unsigned long, 7> NumericTraits<CovariantVector<unsigned long, 7> >::One = CovariantVector<unsigned long, 7>( NumericTraits<unsigned long>::One ); -const CovariantVector<float, 7> NumericTraits<CovariantVector<float, 7> >::Zero = CovariantVector<float, 7>( NumericTraits<float >::Zero ); -const CovariantVector<float, 7> NumericTraits<CovariantVector<float, 7> >::One = CovariantVector<float, 7>( NumericTraits<float>::One ); -const CovariantVector<double, 7> NumericTraits<CovariantVector<double, 7> >::Zero = CovariantVector<double , 7>( NumericTraits<double>::Zero ); -const CovariantVector<double, 7> NumericTraits<CovariantVector<double, 7> >::One = CovariantVector<double, 7>( NumericTraits<double>::One ); -const CovariantVector<long double, 7> NumericTraits<CovariantVector<long double, 7> >::Zero = CovariantVector<long double, 7>( NumericTraits<long double>::Zero ); -const CovariantVector<long double, 7> NumericTraits<CovariantVector<long double, 7> >::One = CovariantVector<long double, 7>( NumericTraits<long double>::One ); - -const CovariantVector<unsigned char, 8> NumericTraits<CovariantVector<unsigned char, 8> >::Zero = CovariantVector<unsigned char, 8>( NumericTraits<unsigned char>::Zero ); -const CovariantVector<unsigned char, 8> NumericTraits<CovariantVector<unsigned char, 8> >::One = CovariantVector<unsigned char, 8>( NumericTraits<unsigned char>::One ); -const CovariantVector<signed char, 8> NumericTraits<CovariantVector<signed char, 8> >::Zero = CovariantVector<signed char, 8>( NumericTraits<signed char>::Zero ); -const CovariantVector<signed char, 8> NumericTraits<CovariantVector<signed char, 8> >::One = CovariantVector<signed char, 8>( NumericTraits<signed char>::One ); -const CovariantVector<char, 8> NumericTraits<CovariantVector<char, 8> >::Zero = CovariantVector<char, 8>( NumericTraits<char>::Zero ); -const CovariantVector<char, 8> NumericTraits<CovariantVector<char, 8> >::One = CovariantVector<char, 8>( NumericTraits<char>::One ); -const CovariantVector<short, 8> NumericTraits<CovariantVector<short, 8> >::Zero = CovariantVector<short, 8>( NumericTraits<short>::Zero ); -const CovariantVector<short, 8> NumericTraits<CovariantVector<short, 8> >::One = CovariantVector<short, 8>( NumericTraits<short>::One ); -const CovariantVector<unsigned short, 8> NumericTraits<CovariantVector<unsigned short, 8> >::Zero = CovariantVector<unsigned short, 8>( NumericTraits<unsigned short>::Zero ); -const CovariantVector<unsigned short, 8> NumericTraits<CovariantVector<unsigned short, 8> >::One = CovariantVector<unsigned short, 8>( NumericTraits<unsigned short>::One ); -const CovariantVector<int, 8> NumericTraits<CovariantVector<int, 8> >::Zero = CovariantVector<int, 8>( NumericTraits<int>::Zero ); -const CovariantVector<int, 8> NumericTraits<CovariantVector<int, 8> >::One = CovariantVector<int, 8>( NumericTraits<int>::One ); -const CovariantVector<unsigned int, 8> NumericTraits<CovariantVector<unsigned int, 8> >::Zero = CovariantVector<unsigned int, 8>( NumericTraits<unsigned int>::Zero ); -const CovariantVector<unsigned int, 8> NumericTraits<CovariantVector<unsigned int, 8> >::One = CovariantVector<unsigned int, 8>( NumericTraits<unsigned int>::One ); -const CovariantVector<long, 8> NumericTraits<CovariantVector<long, 8> >::Zero = CovariantVector<long, 8>( NumericTraits<long>::Zero ); -const CovariantVector<long, 8> NumericTraits<CovariantVector<long, 8> >::One = CovariantVector<long, 8>( NumericTraits<long>::One ); -const CovariantVector<unsigned long, 8> NumericTraits<CovariantVector<unsigned long, 8> >::Zero = CovariantVector<unsigned long, 8>( NumericTraits<unsigned long>::Zero ); -const CovariantVector<unsigned long, 8> NumericTraits<CovariantVector<unsigned long, 8> >::One = CovariantVector<unsigned long, 8>( NumericTraits<unsigned long>::One ); -const CovariantVector<float, 8> NumericTraits<CovariantVector<float, 8> >::Zero = CovariantVector<float, 8>( NumericTraits<float >::Zero ); -const CovariantVector<float, 8> NumericTraits<CovariantVector<float, 8> >::One = CovariantVector<float, 8>( NumericTraits<float>::One ); -const CovariantVector<double, 8> NumericTraits<CovariantVector<double, 8> >::Zero = CovariantVector<double , 8>( NumericTraits<double>::Zero ); -const CovariantVector<double, 8> NumericTraits<CovariantVector<double, 8> >::One = CovariantVector<double, 8>( NumericTraits<double>::One ); -const CovariantVector<long double, 8> NumericTraits<CovariantVector<long double, 8> >::Zero = CovariantVector<long double, 8>( NumericTraits<long double>::Zero ); -const CovariantVector<long double, 8> NumericTraits<CovariantVector<long double, 8> >::One = CovariantVector<long double, 8>( NumericTraits<long double>::One ); - -const CovariantVector<unsigned char, 9> NumericTraits<CovariantVector<unsigned char, 9> >::Zero = CovariantVector<unsigned char, 9>( NumericTraits<unsigned char>::Zero ); -const CovariantVector<unsigned char, 9> NumericTraits<CovariantVector<unsigned char, 9> >::One = CovariantVector<unsigned char, 9>( NumericTraits<unsigned char>::One ); -const CovariantVector<signed char, 9> NumericTraits<CovariantVector<signed char, 9> >::Zero = CovariantVector<signed char, 9>( NumericTraits<signed char>::Zero ); -const CovariantVector<signed char, 9> NumericTraits<CovariantVector<signed char, 9> >::One = CovariantVector<signed char, 9>( NumericTraits<signed char>::One ); -const CovariantVector<char, 9> NumericTraits<CovariantVector<char, 9> >::Zero = CovariantVector<char, 9>( NumericTraits<char>::Zero ); -const CovariantVector<char, 9> NumericTraits<CovariantVector<char, 9> >::One = CovariantVector<char, 9>( NumericTraits<char>::One ); -const CovariantVector<short, 9> NumericTraits<CovariantVector<short, 9> >::Zero = CovariantVector<short, 9>( NumericTraits<short>::Zero ); -const CovariantVector<short, 9> NumericTraits<CovariantVector<short, 9> >::One = CovariantVector<short, 9>( NumericTraits<short>::One ); -const CovariantVector<unsigned short, 9> NumericTraits<CovariantVector<unsigned short, 9> >::Zero = CovariantVector<unsigned short, 9>( NumericTraits<unsigned short>::Zero ); -const CovariantVector<unsigned short, 9> NumericTraits<CovariantVector<unsigned short, 9> >::One = CovariantVector<unsigned short, 9>( NumericTraits<unsigned short>::One ); -const CovariantVector<int, 9> NumericTraits<CovariantVector<int, 9> >::Zero = CovariantVector<int, 9>( NumericTraits<int>::Zero ); -const CovariantVector<int, 9> NumericTraits<CovariantVector<int, 9> >::One = CovariantVector<int, 9>( NumericTraits<int>::One ); -const CovariantVector<unsigned int, 9> NumericTraits<CovariantVector<unsigned int, 9> >::Zero = CovariantVector<unsigned int, 9>( NumericTraits<unsigned int>::Zero ); -const CovariantVector<unsigned int, 9> NumericTraits<CovariantVector<unsigned int, 9> >::One = CovariantVector<unsigned int, 9>( NumericTraits<unsigned int>::One ); -const CovariantVector<long, 9> NumericTraits<CovariantVector<long, 9> >::Zero = CovariantVector<long, 9>( NumericTraits<long>::Zero ); -const CovariantVector<long, 9> NumericTraits<CovariantVector<long, 9> >::One = CovariantVector<long, 9>( NumericTraits<long>::One ); -const CovariantVector<unsigned long, 9> NumericTraits<CovariantVector<unsigned long, 9> >::Zero = CovariantVector<unsigned long, 9>( NumericTraits<unsigned long>::Zero ); -const CovariantVector<unsigned long, 9> NumericTraits<CovariantVector<unsigned long, 9> >::One = CovariantVector<unsigned long, 9>( NumericTraits<unsigned long>::One ); -const CovariantVector<float, 9> NumericTraits<CovariantVector<float, 9> >::Zero = CovariantVector<float, 9>( NumericTraits<float >::Zero ); -const CovariantVector<float, 9> NumericTraits<CovariantVector<float, 9> >::One = CovariantVector<float, 9>( NumericTraits<float>::One ); -const CovariantVector<double, 9> NumericTraits<CovariantVector<double, 9> >::Zero = CovariantVector<double , 9>( NumericTraits<double>::Zero ); -const CovariantVector<double, 9> NumericTraits<CovariantVector<double, 9> >::One = CovariantVector<double, 9>( NumericTraits<double>::One ); -const CovariantVector<long double, 9> NumericTraits<CovariantVector<long double, 9> >::Zero = CovariantVector<long double, 9>( NumericTraits<long double>::Zero ); -const CovariantVector<long double, 9> NumericTraits<CovariantVector<long double, 9> >::One = CovariantVector<long double, 9>( NumericTraits<long double>::One ); +itkStaticNumericTraitsGenericArrayDimensionsMacro( CovariantVector, char ); +itkStaticNumericTraitsGenericArrayDimensionsMacro( CovariantVector, unsigned char ); +itkStaticNumericTraitsGenericArrayDimensionsMacro( CovariantVector, signed char ); +itkStaticNumericTraitsGenericArrayDimensionsMacro( CovariantVector, short ); +itkStaticNumericTraitsGenericArrayDimensionsMacro( CovariantVector, unsigned short ); +itkStaticNumericTraitsGenericArrayDimensionsMacro( CovariantVector, int ); +itkStaticNumericTraitsGenericArrayDimensionsMacro( CovariantVector, unsigned int ); +itkStaticNumericTraitsGenericArrayDimensionsMacro( CovariantVector, long ); +itkStaticNumericTraitsGenericArrayDimensionsMacro( CovariantVector, unsigned long ); +itkStaticNumericTraitsGenericArrayDimensionsMacro( CovariantVector, float ); +itkStaticNumericTraitsGenericArrayDimensionsMacro( CovariantVector, double ); +itkStaticNumericTraitsGenericArrayDimensionsMacro( CovariantVector, long double ); +#ifdef ITK_TYPE_USE_LONG_LONG +itkStaticNumericTraitsGenericArrayDimensionsMacro( CovariantVector, long long ); +itkStaticNumericTraitsGenericArrayDimensionsMacro( CovariantVector, unsigned long long ); +#endif // ITK_TYPE_USE_LONG_LONG } // end namespace itk diff --git a/Utilities/ITK/Code/Common/itkNumericTraitsCovariantVectorPixel.h b/Utilities/ITK/Code/Common/itkNumericTraitsCovariantVectorPixel.h index 11520674f54724094cc8fd3f6ec3415e7d304e90..6e7403940b708404a4be6c2a0e5b8846ac7d2262 100644 --- a/Utilities/ITK/Code/Common/itkNumericTraitsCovariantVectorPixel.h +++ b/Utilities/ITK/Code/Common/itkNumericTraitsCovariantVectorPixel.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkNumericTraitsCovariantVectorPixel.h,v $ Language: C++ - Date: $Date: 2009-02-06 20:53:13 $ - Version: $Revision: 1.6 $ + Date: $Date: 2009-12-01 16:53:23 $ + Version: $Revision: 1.8 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -17,1173 +17,41 @@ #ifndef __itkNumericTraitsCovariantVectorPixel_h #define __itkNumericTraitsCovariantVectorPixel_h -#include "itkNumericTraits.h" +#include "itkNumericTraitsFixedArrayPixel.h" #include "itkCovariantVector.h" -// This file defines numeric traits for vector pixels types in itk -// TODO: Add doxygen tags.. - namespace itk { -template <> class NumericTraits<CovariantVector<unsigned char, 2 > > { -public: - typedef unsigned char ValueType; - typedef CovariantVector<unsigned char, 2> PrintType; - typedef CovariantVector<unsigned char, 2> AbsType; - typedef CovariantVector<unsigned short, 2> AccumulateType; - typedef CovariantVector<double, 2> RealType; - typedef double ScalarRealType; - static const CovariantVector<unsigned char, 2> ITKCommon_EXPORT Zero; - static const CovariantVector<unsigned char, 2> ITKCommon_EXPORT One; - static CovariantVector<unsigned char,2> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<signed char, 2> > { -public: - typedef signed char ValueType; - typedef CovariantVector<signed char, 2> PrintType; - typedef CovariantVector<unsigned char, 2> AbsType; - typedef CovariantVector<short, 2> AccumulateType; - typedef CovariantVector<double, 2> RealType; - typedef double ScalarRealType; - static const CovariantVector<signed char, 2> ITKCommon_EXPORT Zero; - static const CovariantVector<signed char, 2> ITKCommon_EXPORT One; - static CovariantVector<signed char,2> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<char, 2> > { -public: - typedef char ValueType; - typedef CovariantVector<char, 2> PrintType; - typedef CovariantVector<unsigned char, 2> AbsType; - typedef CovariantVector<short, 2> AccumulateType; - typedef CovariantVector<double, 2> RealType; - typedef double ScalarRealType; - static const CovariantVector<char, 2> ITKCommon_EXPORT Zero; - static const CovariantVector<char, 2> ITKCommon_EXPORT One; - static CovariantVector<char,2> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<short, 2> > { -public: - typedef short ValueType; - typedef CovariantVector<short, 2> PrintType; - typedef CovariantVector<unsigned short, 2> AbsType; - typedef CovariantVector<int, 2> AccumulateType; - typedef CovariantVector<double, 2> RealType; - typedef double ScalarRealType; - static const CovariantVector<short, 2> ITKCommon_EXPORT Zero; - static const CovariantVector<short, 2> ITKCommon_EXPORT One; - static CovariantVector<short,2> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<unsigned short, 2> > { -public: - typedef unsigned short ValueType; - typedef CovariantVector<unsigned short, 2> PrintType; - typedef CovariantVector<unsigned short, 2> AbsType; - typedef CovariantVector<unsigned int, 2> AccumulateType; - typedef CovariantVector<double, 2> RealType; - typedef double ScalarRealType; - static const CovariantVector<unsigned short, 2> ITKCommon_EXPORT Zero; - static const CovariantVector<unsigned short, 2> ITKCommon_EXPORT One; - static CovariantVector<unsigned short,2> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<int, 2> > { -public: - typedef int ValueType; - typedef CovariantVector<int, 2> PrintType; - typedef CovariantVector<unsigned int, 2> AbsType; - typedef CovariantVector<long, 2> AccumulateType; - typedef CovariantVector<double, 2> RealType; - typedef double ScalarRealType; - static const CovariantVector<int, 2> ITKCommon_EXPORT Zero; - static const CovariantVector<int, 2> ITKCommon_EXPORT One; - static CovariantVector<int,2> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<unsigned int, 2> > { -public: - typedef unsigned int ValueType; - typedef CovariantVector<unsigned int, 2> PrintType; - typedef CovariantVector<unsigned int, 2> AbsType; - typedef CovariantVector<unsigned long, 2> AccumulateType; - typedef CovariantVector<double, 2> RealType; - typedef double ScalarRealType; - static const CovariantVector<unsigned int, 2> ITKCommon_EXPORT Zero; - static const CovariantVector<unsigned int, 2> ITKCommon_EXPORT One; - static CovariantVector<unsigned int,2> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<long, 2> > { -public: - typedef long ValueType; - typedef CovariantVector<long, 2> PrintType; - typedef CovariantVector<unsigned long, 2> AbsType; - typedef CovariantVector<long, 2> AccumulateType; - typedef CovariantVector<double, 2> RealType; - typedef double ScalarRealType; - static const CovariantVector<long, 2> ITKCommon_EXPORT Zero; - static const CovariantVector<long, 2> ITKCommon_EXPORT One; - static CovariantVector<long,2> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<unsigned long, 2> > { -public: - typedef unsigned long ValueType; - typedef CovariantVector<unsigned long, 2> PrintType; - typedef CovariantVector<unsigned long, 2> AbsType; - typedef CovariantVector<unsigned long, 2> AccumulateType; - typedef CovariantVector<double, 2> RealType; - typedef double ScalarRealType; - static const CovariantVector<unsigned long, 2> ITKCommon_EXPORT Zero; - static const CovariantVector<unsigned long, 2> ITKCommon_EXPORT One; - static CovariantVector<unsigned long,2> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<float, 2> > { -public: - typedef float ValueType; - typedef CovariantVector<float, 2> PrintType; - typedef CovariantVector<float, 2> AbsType; - typedef CovariantVector<double, 2> AccumulateType; - typedef CovariantVector<double, 2> RealType; - typedef double ScalarRealType; - static const CovariantVector<float, 2> ITKCommon_EXPORT Zero; - static const CovariantVector<float, 2> ITKCommon_EXPORT One; - static CovariantVector<float, 2> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<double, 2> > { -public: - typedef double ValueType; - typedef CovariantVector<double, 2> PrintType; - typedef CovariantVector<double, 2> AbsType; - typedef CovariantVector<long double, 2> AccumulateType; - typedef CovariantVector<double, 2> RealType; - typedef double ScalarRealType; - static const CovariantVector<double, 2> ITKCommon_EXPORT Zero; - static const CovariantVector<double, 2> ITKCommon_EXPORT One; - static CovariantVector<double, 2> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<long double, 2> > { -public: - typedef long double ValueType; - typedef CovariantVector<long double, 2> PrintType; - typedef CovariantVector<long double, 2> AbsType; - typedef CovariantVector<long double, 2> AccumulateType; - typedef CovariantVector<long double, 2> RealType; - typedef long double ScalarRealType; - static const CovariantVector<long double, 2> ITKCommon_EXPORT Zero; - static const CovariantVector<long double, 2> ITKCommon_EXPORT One; - static CovariantVector<long double, 2> ZeroValue() { return Zero; } -}; - -template <> class NumericTraits<CovariantVector<unsigned char, 3 > > { -public: - typedef unsigned char ValueType; - typedef CovariantVector<unsigned char, 3> PrintType; - typedef CovariantVector<unsigned char, 3> AbsType; - typedef CovariantVector<unsigned short, 3> AccumulateType; - typedef CovariantVector<double, 3> RealType; - typedef double ScalarRealType; - static const CovariantVector<unsigned char, 3> ITKCommon_EXPORT Zero; - static const CovariantVector<unsigned char, 3> ITKCommon_EXPORT One; - static CovariantVector<unsigned char, 3> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<signed char, 3> > { -public: - typedef signed char ValueType; - typedef CovariantVector<signed char, 3> PrintType; - typedef CovariantVector<unsigned char, 3> AbsType; - typedef CovariantVector<short, 3> AccumulateType; - typedef CovariantVector<double, 3> RealType; - typedef double ScalarRealType; - static const CovariantVector<signed char, 3> ITKCommon_EXPORT Zero; - static const CovariantVector<signed char, 3> ITKCommon_EXPORT One; - static CovariantVector<signed char, 3> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<char, 3> > { -public: - typedef char ValueType; - typedef CovariantVector<char, 3> PrintType; - typedef CovariantVector<unsigned char, 3> AbsType; - typedef CovariantVector<short, 3> AccumulateType; - typedef CovariantVector<double, 3> RealType; - typedef double ScalarRealType; - static const CovariantVector<char, 3> ITKCommon_EXPORT Zero; - static const CovariantVector<char, 3> ITKCommon_EXPORT One; - static CovariantVector<char, 3> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<short, 3> > { -public: - typedef short ValueType; - typedef CovariantVector<short, 3> PrintType; - typedef CovariantVector<unsigned short, 3> AbsType; - typedef CovariantVector<int, 3> AccumulateType; - typedef CovariantVector<double, 3> RealType; - typedef double ScalarRealType; - static const CovariantVector<short, 3> ITKCommon_EXPORT Zero; - static const CovariantVector<short, 3> ITKCommon_EXPORT One; - static CovariantVector<short, 3> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<unsigned short, 3> > { -public: - typedef unsigned short ValueType; - typedef CovariantVector<unsigned short, 3> PrintType; - typedef CovariantVector<unsigned short, 3> AbsType; - typedef CovariantVector<unsigned int, 3> AccumulateType; - typedef CovariantVector<double, 3> RealType; - typedef double ScalarRealType; - static const CovariantVector<unsigned short, 3> ITKCommon_EXPORT Zero; - static const CovariantVector<unsigned short, 3> ITKCommon_EXPORT One; - static CovariantVector<unsigned short, 3> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<int, 3> > { -public: - typedef int ValueType; - typedef CovariantVector<int, 3> PrintType; - typedef CovariantVector<unsigned int, 3> AbsType; - typedef CovariantVector<long, 3> AccumulateType; - typedef CovariantVector<double, 3> RealType; - typedef double ScalarRealType; - static const CovariantVector<int, 3> ITKCommon_EXPORT Zero; - static const CovariantVector<int, 3> ITKCommon_EXPORT One; - static CovariantVector<int, 3> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<unsigned int, 3> > { -public: - typedef unsigned int ValueType; - typedef CovariantVector<unsigned int, 3> PrintType; - typedef CovariantVector<unsigned int, 3> AbsType; - typedef CovariantVector<unsigned long, 3> AccumulateType; - typedef CovariantVector<double, 3> RealType; - typedef double ScalarRealType; - static const CovariantVector<unsigned int, 3> ITKCommon_EXPORT Zero; - static const CovariantVector<unsigned int, 3> ITKCommon_EXPORT One; - static CovariantVector<unsigned int, 3> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<long, 3> > { -public: - typedef long ValueType; - typedef CovariantVector<long, 3> PrintType; - typedef CovariantVector<unsigned long, 3> AbsType; - typedef CovariantVector<long, 3> AccumulateType; - typedef CovariantVector<double, 3> RealType; - typedef double ScalarRealType; - static const CovariantVector<long, 3> ITKCommon_EXPORT Zero; - static const CovariantVector<long, 3> ITKCommon_EXPORT One; - static CovariantVector<long, 3> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<unsigned long, 3> > { -public: - typedef unsigned long ValueType; - typedef CovariantVector<unsigned long, 3> PrintType; - typedef CovariantVector<unsigned long, 3> AbsType; - typedef CovariantVector<unsigned long, 3> AccumulateType; - typedef CovariantVector<double, 3> RealType; - typedef double ScalarRealType; - static const CovariantVector<unsigned long, 3> ITKCommon_EXPORT Zero; - static const CovariantVector<unsigned long, 3> ITKCommon_EXPORT One; - static CovariantVector<unsigned long, 3> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<float, 3> > { -public: - typedef float ValueType; - typedef CovariantVector<float, 3> PrintType; - typedef CovariantVector<float, 3> AbsType; - typedef CovariantVector<double, 3> AccumulateType; - typedef CovariantVector<double, 3> RealType; - typedef double ScalarRealType; - static const CovariantVector<float, 3> ITKCommon_EXPORT Zero; - static const CovariantVector<float, 3> ITKCommon_EXPORT One; - static CovariantVector<float, 3> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<double, 3> > { -public: - typedef double ValueType; - typedef CovariantVector<double, 3> PrintType; - typedef CovariantVector<double, 3> AbsType; - typedef CovariantVector<long double, 3> AccumulateType; - typedef CovariantVector<double, 3> RealType; - typedef double ScalarRealType; - static const CovariantVector<double, 3> ITKCommon_EXPORT Zero; - static const CovariantVector<double, 3> ITKCommon_EXPORT One; - static CovariantVector<double, 3> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<long double, 3> > { -public: - typedef long double ValueType; - typedef CovariantVector<long double, 3> PrintType; - typedef CovariantVector<long double, 3> AbsType; - typedef CovariantVector<long double, 3> AccumulateType; - typedef CovariantVector<long double, 3> RealType; - typedef long double ScalarRealType; - static const CovariantVector<long double, 3> ITKCommon_EXPORT Zero; - static const CovariantVector<long double, 3> ITKCommon_EXPORT One; - static CovariantVector<long double, 3> ZeroValue() { return Zero; } -}; - -template <> class NumericTraits<CovariantVector<unsigned char, 4 > > { -public: - typedef unsigned char ValueType; - typedef CovariantVector<unsigned char, 4> PrintType; - typedef CovariantVector<unsigned char, 4> AbsType; - typedef CovariantVector<unsigned short, 4> AccumulateType; - typedef CovariantVector<double, 4> RealType; - typedef double ScalarRealType; - static const CovariantVector<unsigned char, 4> ITKCommon_EXPORT Zero; - static const CovariantVector<unsigned char, 4> ITKCommon_EXPORT One; - static CovariantVector<unsigned char, 4> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<signed char, 4> > { -public: - typedef signed char ValueType; - typedef CovariantVector<signed char, 4> PrintType; - typedef CovariantVector<unsigned char, 4> AbsType; - typedef CovariantVector<short, 4> AccumulateType; - typedef CovariantVector<double, 4> RealType; - typedef double ScalarRealType; - static const CovariantVector<signed char, 4> ITKCommon_EXPORT Zero; - static const CovariantVector<signed char, 4> ITKCommon_EXPORT One; - static CovariantVector<signed char, 4> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<char, 4> > { -public: - typedef char ValueType; - typedef CovariantVector<char, 4> PrintType; - typedef CovariantVector<unsigned char, 4> AbsType; - typedef CovariantVector<short, 4> AccumulateType; - typedef CovariantVector<double, 4> RealType; - typedef double ScalarRealType; - static const CovariantVector<char, 4> ITKCommon_EXPORT Zero; - static const CovariantVector<char, 4> ITKCommon_EXPORT One; - static CovariantVector<char, 4> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<short, 4> > { -public: - typedef short ValueType; - typedef CovariantVector<short, 4> PrintType; - typedef CovariantVector<unsigned short, 4> AbsType; - typedef CovariantVector<int, 4> AccumulateType; - typedef CovariantVector<double, 4> RealType; - typedef double ScalarRealType; - static const CovariantVector<short, 4> ITKCommon_EXPORT Zero; - static const CovariantVector<short, 4> ITKCommon_EXPORT One; - static CovariantVector<short, 4> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<unsigned short, 4> > { -public: - typedef unsigned short ValueType; - typedef CovariantVector<unsigned short, 4> PrintType; - typedef CovariantVector<unsigned short, 4> AbsType; - typedef CovariantVector<unsigned int, 4> AccumulateType; - typedef CovariantVector<double, 4> RealType; - typedef double ScalarRealType; - static const CovariantVector<unsigned short, 4> ITKCommon_EXPORT Zero; - static const CovariantVector<unsigned short, 4> ITKCommon_EXPORT One; - static CovariantVector<unsigned short, 4> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<int, 4> > { -public: - typedef int ValueType; - typedef CovariantVector<int, 4> PrintType; - typedef CovariantVector<unsigned int, 4> AbsType; - typedef CovariantVector<long, 4> AccumulateType; - typedef CovariantVector<double, 4> RealType; - typedef double ScalarRealType; - static const CovariantVector<int, 4> ITKCommon_EXPORT Zero; - static const CovariantVector<int, 4> ITKCommon_EXPORT One; - static CovariantVector<int, 4> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<unsigned int, 4> > { -public: - typedef unsigned int ValueType; - typedef CovariantVector<unsigned int, 4> PrintType; - typedef CovariantVector<unsigned int, 4> AbsType; - typedef CovariantVector<unsigned long, 4> AccumulateType; - typedef CovariantVector<double, 4> RealType; - typedef double ScalarRealType; - static const CovariantVector<unsigned int, 4> ITKCommon_EXPORT Zero; - static const CovariantVector<unsigned int, 4> ITKCommon_EXPORT One; - static CovariantVector<unsigned int, 4> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<long, 4> > { -public: - typedef long ValueType; - typedef CovariantVector<long, 4> PrintType; - typedef CovariantVector<unsigned long, 4> AbsType; - typedef CovariantVector<long, 4> AccumulateType; - typedef CovariantVector<double, 4> RealType; - typedef double ScalarRealType; - static const CovariantVector<long, 4> ITKCommon_EXPORT Zero; - static const CovariantVector<long, 4> ITKCommon_EXPORT One; - static CovariantVector<long, 4> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<unsigned long, 4> > { -public: - typedef unsigned long ValueType; - typedef CovariantVector<unsigned long, 4> PrintType; - typedef CovariantVector<unsigned long, 4> AbsType; - typedef CovariantVector<unsigned long, 4> AccumulateType; - typedef CovariantVector<double, 4> RealType; - typedef double ScalarRealType; - static const CovariantVector<unsigned long, 4> ITKCommon_EXPORT Zero; - static const CovariantVector<unsigned long, 4> ITKCommon_EXPORT One; - static CovariantVector<unsigned long, 4> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<float, 4> > { -public: - typedef float ValueType; - typedef CovariantVector<float, 4> PrintType; - typedef CovariantVector<float, 4> AbsType; - typedef CovariantVector<double, 4> AccumulateType; - typedef CovariantVector<double, 4> RealType; - typedef double ScalarRealType; - static const CovariantVector<float, 4> ITKCommon_EXPORT Zero; - static const CovariantVector<float, 4> ITKCommon_EXPORT One; - static CovariantVector<float, 4> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<double, 4> > { -public: - typedef double ValueType; - typedef CovariantVector<double, 4> PrintType; - typedef CovariantVector<double, 4> AbsType; - typedef CovariantVector<long double, 4> AccumulateType; - typedef CovariantVector<double, 4> RealType; - typedef double ScalarRealType; - static const CovariantVector<double, 4> ITKCommon_EXPORT Zero; - static const CovariantVector<double, 4> ITKCommon_EXPORT One; - static CovariantVector<double, 4> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<long double, 4> > { -public: - typedef long double ValueType; - typedef CovariantVector<long double, 4> PrintType; - typedef CovariantVector<long double, 4> AbsType; - typedef CovariantVector<long double, 4> AccumulateType; - typedef CovariantVector<long double, 4> RealType; - typedef long double ScalarRealType; - static const CovariantVector<long double, 4> ITKCommon_EXPORT Zero; - static const CovariantVector<long double, 4> ITKCommon_EXPORT One; - static CovariantVector<long double, 4> ZeroValue() { return Zero; } -}; - -template <> class NumericTraits<CovariantVector<unsigned char, 5 > > { -public: - typedef unsigned char ValueType; - typedef CovariantVector<unsigned char, 5> PrintType; - typedef CovariantVector<unsigned char, 5> AbsType; - typedef CovariantVector<unsigned short, 5> AccumulateType; - typedef CovariantVector<double, 5> RealType; - typedef double ScalarRealType; - static const CovariantVector<unsigned char, 5> ITKCommon_EXPORT Zero; - static const CovariantVector<unsigned char, 5> ITKCommon_EXPORT One; - static CovariantVector<unsigned char, 5> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<signed char, 5> > { -public: - typedef signed char ValueType; - typedef CovariantVector<signed char, 5> PrintType; - typedef CovariantVector<unsigned char, 5> AbsType; - typedef CovariantVector<short, 5> AccumulateType; - typedef CovariantVector<double, 5> RealType; - typedef double ScalarRealType; - static const CovariantVector<signed char, 5> ITKCommon_EXPORT Zero; - static const CovariantVector<signed char, 5> ITKCommon_EXPORT One; - static CovariantVector<signed char, 5> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<char, 5> > { -public: - typedef char ValueType; - typedef CovariantVector<char, 5> PrintType; - typedef CovariantVector<unsigned char, 5> AbsType; - typedef CovariantVector<short, 5> AccumulateType; - typedef CovariantVector<double, 5> RealType; - typedef double ScalarRealType; - static const CovariantVector<char, 5> ITKCommon_EXPORT Zero; - static const CovariantVector<char, 5> ITKCommon_EXPORT One; - static CovariantVector<char, 5> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<short, 5> > { -public: - typedef short ValueType; - typedef CovariantVector<short, 5> PrintType; - typedef CovariantVector<unsigned short, 5> AbsType; - typedef CovariantVector<int, 5> AccumulateType; - typedef CovariantVector<double, 5> RealType; - typedef double ScalarRealType; - static const CovariantVector<short, 5> ITKCommon_EXPORT Zero; - static const CovariantVector<short, 5> ITKCommon_EXPORT One; - static CovariantVector<short, 5> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<unsigned short, 5> > { -public: - typedef unsigned short ValueType; - typedef CovariantVector<unsigned short, 5> PrintType; - typedef CovariantVector<unsigned short, 5> AbsType; - typedef CovariantVector<unsigned int, 5> AccumulateType; - typedef CovariantVector<double, 5> RealType; - typedef double ScalarRealType; - static const CovariantVector<unsigned short, 5> ITKCommon_EXPORT Zero; - static const CovariantVector<unsigned short, 5> ITKCommon_EXPORT One; - static CovariantVector<unsigned short, 5> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<int, 5> > { -public: - typedef int ValueType; - typedef CovariantVector<int, 5> PrintType; - typedef CovariantVector<unsigned int, 5> AbsType; - typedef CovariantVector<long, 5> AccumulateType; - typedef CovariantVector<double, 5> RealType; - typedef double ScalarRealType; - static const CovariantVector<int, 5> ITKCommon_EXPORT Zero; - static const CovariantVector<int, 5> ITKCommon_EXPORT One; - static CovariantVector<int, 5> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<unsigned int, 5> > { -public: - typedef unsigned int ValueType; - typedef CovariantVector<unsigned int, 5> PrintType; - typedef CovariantVector<unsigned int, 5> AbsType; - typedef CovariantVector<unsigned long, 5> AccumulateType; - typedef CovariantVector<double, 5> RealType; - typedef double ScalarRealType; - static const CovariantVector<unsigned int, 5> ITKCommon_EXPORT Zero; - static const CovariantVector<unsigned int, 5> ITKCommon_EXPORT One; - static CovariantVector<unsigned int, 5> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<long, 5> > { -public: - typedef long ValueType; - typedef CovariantVector<long, 5> PrintType; - typedef CovariantVector<unsigned long, 5> AbsType; - typedef CovariantVector<long, 5> AccumulateType; - typedef CovariantVector<double, 5> RealType; - typedef double ScalarRealType; - static const CovariantVector<long, 5> ITKCommon_EXPORT Zero; - static const CovariantVector<long, 5> ITKCommon_EXPORT One; - static CovariantVector<long, 5> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<unsigned long, 5> > { -public: - typedef unsigned long ValueType; - typedef CovariantVector<unsigned long, 5> PrintType; - typedef CovariantVector<unsigned long, 5> AbsType; - typedef CovariantVector<unsigned long, 5> AccumulateType; - typedef CovariantVector<double, 5> RealType; - typedef double ScalarRealType; - static const CovariantVector<unsigned long, 5> ITKCommon_EXPORT Zero; - static const CovariantVector<unsigned long, 5> ITKCommon_EXPORT One; - static CovariantVector<unsigned long, 5> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<float, 5> > { -public: - typedef float ValueType; - typedef CovariantVector<float, 5> PrintType; - typedef CovariantVector<float, 5> AbsType; - typedef CovariantVector<double, 5> AccumulateType; - typedef CovariantVector<double, 5> RealType; - typedef double ScalarRealType; - static const CovariantVector<float, 5> ITKCommon_EXPORT Zero; - static const CovariantVector<float, 5> ITKCommon_EXPORT One; - static CovariantVector<float, 5> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<double, 5> > { -public: - typedef double ValueType; - typedef CovariantVector<double, 5> PrintType; - typedef CovariantVector<double, 5> AbsType; - typedef CovariantVector<long double, 5> AccumulateType; - typedef CovariantVector<double, 5> RealType; - typedef double ScalarRealType; - static const CovariantVector<double, 5> ITKCommon_EXPORT Zero; - static const CovariantVector<double, 5> ITKCommon_EXPORT One; - static CovariantVector<double, 5> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<long double, 5> > { -public: - typedef long double ValueType; - typedef CovariantVector<long double, 5> PrintType; - typedef CovariantVector<long double, 5> AbsType; - typedef CovariantVector<long double, 5> AccumulateType; - typedef CovariantVector<long double, 5> RealType; - typedef long double ScalarRealType; - static const CovariantVector<long double, 5> ITKCommon_EXPORT Zero; - static const CovariantVector<long double, 5> ITKCommon_EXPORT One; - static CovariantVector<long double, 5> ZeroValue() { return Zero; } -}; - -template <> class NumericTraits<CovariantVector<unsigned char, 6 > > { -public: - typedef unsigned char ValueType; - typedef CovariantVector<unsigned char, 6> PrintType; - typedef CovariantVector<unsigned char, 6> AbsType; - typedef CovariantVector<unsigned short, 6> AccumulateType; - typedef CovariantVector<double, 6> RealType; - typedef double ScalarRealType; - static const CovariantVector<unsigned char, 6> ITKCommon_EXPORT Zero; - static const CovariantVector<unsigned char, 6> ITKCommon_EXPORT One; - static CovariantVector<unsigned char, 6> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<signed char, 6> > { -public: - typedef signed char ValueType; - typedef CovariantVector<signed char, 6> PrintType; - typedef CovariantVector<unsigned char, 6> AbsType; - typedef CovariantVector<short, 6> AccumulateType; - typedef CovariantVector<double, 6> RealType; - typedef double ScalarRealType; - static const CovariantVector<signed char, 6> ITKCommon_EXPORT Zero; - static const CovariantVector<signed char, 6> ITKCommon_EXPORT One; - static CovariantVector<signed char, 6> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<char, 6> > { -public: - typedef char ValueType; - typedef CovariantVector<char, 6> PrintType; - typedef CovariantVector<unsigned char, 6> AbsType; - typedef CovariantVector<short, 6> AccumulateType; - typedef CovariantVector<double, 6> RealType; - typedef double ScalarRealType; - static const CovariantVector<char, 6> ITKCommon_EXPORT Zero; - static const CovariantVector<char, 6> ITKCommon_EXPORT One; - static CovariantVector<char, 6> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<short, 6> > { -public: - typedef short ValueType; - typedef CovariantVector<short, 6> PrintType; - typedef CovariantVector<unsigned short, 6> AbsType; - typedef CovariantVector<int, 6> AccumulateType; - typedef CovariantVector<double, 6> RealType; - typedef double ScalarRealType; - static const CovariantVector<short, 6> ITKCommon_EXPORT Zero; - static const CovariantVector<short, 6> ITKCommon_EXPORT One; - static CovariantVector<short, 6> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<unsigned short, 6> > { -public: - typedef unsigned short ValueType; - typedef CovariantVector<unsigned short, 6> PrintType; - typedef CovariantVector<unsigned short, 6> AbsType; - typedef CovariantVector<unsigned int, 6> AccumulateType; - typedef CovariantVector<double, 6> RealType; - typedef double ScalarRealType; - static const CovariantVector<unsigned short, 6> ITKCommon_EXPORT Zero; - static const CovariantVector<unsigned short, 6> ITKCommon_EXPORT One; - static CovariantVector<unsigned short, 6> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<int, 6> > { -public: - typedef int ValueType; - typedef CovariantVector<int, 6> PrintType; - typedef CovariantVector<unsigned int, 6> AbsType; - typedef CovariantVector<long, 6> AccumulateType; - typedef CovariantVector<double, 6> RealType; - typedef double ScalarRealType; - static const CovariantVector<int, 6> ITKCommon_EXPORT Zero; - static const CovariantVector<int, 6> ITKCommon_EXPORT One; - static CovariantVector<int, 6> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<unsigned int, 6> > { -public: - typedef unsigned int ValueType; - typedef CovariantVector<unsigned int, 6> PrintType; - typedef CovariantVector<unsigned int, 6> AbsType; - typedef CovariantVector<unsigned long, 6> AccumulateType; - typedef CovariantVector<double, 6> RealType; - typedef double ScalarRealType; - static const CovariantVector<unsigned int, 6> ITKCommon_EXPORT Zero; - static const CovariantVector<unsigned int, 6> ITKCommon_EXPORT One; - static CovariantVector<unsigned int, 6> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<long, 6> > { -public: - typedef long ValueType; - typedef CovariantVector<long, 6> PrintType; - typedef CovariantVector<unsigned long, 6> AbsType; - typedef CovariantVector<long, 6> AccumulateType; - typedef CovariantVector<double, 6> RealType; - typedef double ScalarRealType; - static const CovariantVector<long, 6> ITKCommon_EXPORT Zero; - static const CovariantVector<long, 6> ITKCommon_EXPORT One; - static CovariantVector<long, 6> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<unsigned long, 6> > { -public: - typedef unsigned long ValueType; - typedef CovariantVector<unsigned long, 6> PrintType; - typedef CovariantVector<unsigned long, 6> AbsType; - typedef CovariantVector<unsigned long, 6> AccumulateType; - typedef CovariantVector<double, 6> RealType; - typedef double ScalarRealType; - static const CovariantVector<unsigned long, 6> ITKCommon_EXPORT Zero; - static const CovariantVector<unsigned long, 6> ITKCommon_EXPORT One; - static CovariantVector<unsigned long, 6> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<float, 6> > { -public: - typedef float ValueType; - typedef CovariantVector<float, 6> PrintType; - typedef CovariantVector<float, 6> AbsType; - typedef CovariantVector<double, 6> AccumulateType; - typedef CovariantVector<double, 6> RealType; - typedef double ScalarRealType; - static const CovariantVector<float, 6> ITKCommon_EXPORT Zero; - static const CovariantVector<float, 6> ITKCommon_EXPORT One; - static CovariantVector<float, 6> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<double, 6> > { -public: - typedef double ValueType; - typedef CovariantVector<double, 6> PrintType; - typedef CovariantVector<double, 6> AbsType; - typedef CovariantVector<long double, 6> AccumulateType; - typedef CovariantVector<double, 6> RealType; - typedef double ScalarRealType; - static const CovariantVector<double, 6> ITKCommon_EXPORT Zero; - static const CovariantVector<double, 6> ITKCommon_EXPORT One; - static CovariantVector<double, 6> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<long double, 6> > { -public: - typedef long double ValueType; - typedef CovariantVector<long double, 6> PrintType; - typedef CovariantVector<long double, 6> AbsType; - typedef CovariantVector<long double, 6> AccumulateType; - typedef CovariantVector<long double, 6> RealType; - typedef long double ScalarRealType; - static const CovariantVector<long double, 6> ITKCommon_EXPORT Zero; - static const CovariantVector<long double, 6> ITKCommon_EXPORT One; - static CovariantVector<long double, 6> ZeroValue() { return Zero; } -}; - -template <> class NumericTraits<CovariantVector<unsigned char, 7 > > { -public: - typedef unsigned char ValueType; - typedef CovariantVector<unsigned char, 7> PrintType; - typedef CovariantVector<unsigned char, 7> AbsType; - typedef CovariantVector<unsigned short, 7> AccumulateType; - typedef CovariantVector<double, 7> RealType; - typedef double ScalarRealType; - static const CovariantVector<unsigned char, 7> ITKCommon_EXPORT Zero; - static const CovariantVector<unsigned char, 7> ITKCommon_EXPORT One; - static CovariantVector<unsigned char, 7> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<signed char, 7> > { -public: - typedef signed char ValueType; - typedef CovariantVector<signed char, 7> PrintType; - typedef CovariantVector<unsigned char, 7> AbsType; - typedef CovariantVector<short, 7> AccumulateType; - typedef CovariantVector<double, 7> RealType; - typedef double ScalarRealType; - static const CovariantVector<signed char, 7> ITKCommon_EXPORT Zero; - static const CovariantVector<signed char, 7> ITKCommon_EXPORT One; - static CovariantVector<signed char, 7> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<char, 7> > { -public: - typedef char ValueType; - typedef CovariantVector<char, 7> PrintType; - typedef CovariantVector<unsigned char, 7> AbsType; - typedef CovariantVector<short, 7> AccumulateType; - typedef CovariantVector<double, 7> RealType; - typedef double ScalarRealType; - static const CovariantVector<char, 7> ITKCommon_EXPORT Zero; - static const CovariantVector<char, 7> ITKCommon_EXPORT One; - static CovariantVector<char, 7> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<short, 7> > { -public: - typedef short ValueType; - typedef CovariantVector<short, 7> PrintType; - typedef CovariantVector<unsigned short, 7> AbsType; - typedef CovariantVector<int, 7> AccumulateType; - typedef CovariantVector<double, 7> RealType; - typedef double ScalarRealType; - static const CovariantVector<short, 7> ITKCommon_EXPORT Zero; - static const CovariantVector<short, 7> ITKCommon_EXPORT One; - static CovariantVector<short, 7> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<unsigned short, 7> > { -public: - typedef unsigned short ValueType; - typedef CovariantVector<unsigned short, 7> PrintType; - typedef CovariantVector<unsigned short, 7> AbsType; - typedef CovariantVector<unsigned int, 7> AccumulateType; - typedef CovariantVector<double, 7> RealType; - typedef double ScalarRealType; - static const CovariantVector<unsigned short, 7> ITKCommon_EXPORT Zero; - static const CovariantVector<unsigned short, 7> ITKCommon_EXPORT One; - static CovariantVector<unsigned short, 7> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<int, 7> > { -public: - typedef int ValueType; - typedef CovariantVector<int, 7> PrintType; - typedef CovariantVector<unsigned int, 7> AbsType; - typedef CovariantVector<long, 7> AccumulateType; - typedef CovariantVector<double, 7> RealType; - typedef double ScalarRealType; - static const CovariantVector<int, 7> ITKCommon_EXPORT Zero; - static const CovariantVector<int, 7> ITKCommon_EXPORT One; - static CovariantVector<int, 7> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<unsigned int, 7> > { -public: - typedef unsigned int ValueType; - typedef CovariantVector<unsigned int, 7> PrintType; - typedef CovariantVector<unsigned int, 7> AbsType; - typedef CovariantVector<unsigned long, 7> AccumulateType; - typedef CovariantVector<double, 7> RealType; - typedef double ScalarRealType; - static const CovariantVector<unsigned int, 7> ITKCommon_EXPORT Zero; - static const CovariantVector<unsigned int, 7> ITKCommon_EXPORT One; - static CovariantVector<unsigned int, 7> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<long, 7> > { -public: - typedef long ValueType; - typedef CovariantVector<long, 7> PrintType; - typedef CovariantVector<unsigned long, 7> AbsType; - typedef CovariantVector<long, 7> AccumulateType; - typedef CovariantVector<double, 7> RealType; - typedef double ScalarRealType; - static const CovariantVector<long, 7> ITKCommon_EXPORT Zero; - static const CovariantVector<long, 7> ITKCommon_EXPORT One; - static CovariantVector<long, 7> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<unsigned long, 7> > { -public: - typedef unsigned long ValueType; - typedef CovariantVector<unsigned long, 7> PrintType; - typedef CovariantVector<unsigned long, 7> AbsType; - typedef CovariantVector<unsigned long, 7> AccumulateType; - typedef CovariantVector<double, 7> RealType; - typedef double ScalarRealType; - static const CovariantVector<unsigned long, 7> ITKCommon_EXPORT Zero; - static const CovariantVector<unsigned long, 7> ITKCommon_EXPORT One; - static CovariantVector<unsigned long, 7> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<float, 7> > { -public: - typedef float ValueType; - typedef CovariantVector<float, 7> PrintType; - typedef CovariantVector<float, 7> AbsType; - typedef CovariantVector<double, 7> AccumulateType; - typedef CovariantVector<double, 7> RealType; - typedef double ScalarRealType; - static const CovariantVector<float, 7> ITKCommon_EXPORT Zero; - static const CovariantVector<float, 7> ITKCommon_EXPORT One; - static CovariantVector<float, 7> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<double, 7> > { -public: - typedef double ValueType; - typedef CovariantVector<double, 7> PrintType; - typedef CovariantVector<double, 7> AbsType; - typedef CovariantVector<long double, 7> AccumulateType; - typedef CovariantVector<double, 7> RealType; - typedef double ScalarRealType; - static const CovariantVector<double, 7> ITKCommon_EXPORT Zero; - static const CovariantVector<double, 7> ITKCommon_EXPORT One; - static CovariantVector<double, 7> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<long double, 7> > { -public: - typedef long double ValueType; - typedef CovariantVector<long double, 7> PrintType; - typedef CovariantVector<long double, 7> AbsType; - typedef CovariantVector<long double, 7> AccumulateType; - typedef CovariantVector<long double, 7> RealType; - typedef long double ScalarRealType; - static const CovariantVector<long double, 7> ITKCommon_EXPORT Zero; - static const CovariantVector<long double, 7> ITKCommon_EXPORT One; - static CovariantVector<long double, 7> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<unsigned char, 8 > > { -public: - typedef unsigned char ValueType; - typedef CovariantVector<unsigned char, 8> PrintType; - typedef CovariantVector<unsigned char, 8> AbsType; - typedef CovariantVector<unsigned short, 8> AccumulateType; - typedef CovariantVector<double, 8> RealType; - typedef double ScalarRealType; - static const CovariantVector<unsigned char, 8> ITKCommon_EXPORT Zero; - static const CovariantVector<unsigned char, 8> ITKCommon_EXPORT One; - static CovariantVector<unsigned char, 8> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<signed char, 8> > { -public: - typedef signed char ValueType; - typedef CovariantVector<signed char, 8> PrintType; - typedef CovariantVector<unsigned char, 8> AbsType; - typedef CovariantVector<short, 8> AccumulateType; - typedef CovariantVector<double, 8> RealType; - typedef double ScalarRealType; - static const CovariantVector<signed char, 8> ITKCommon_EXPORT Zero; - static const CovariantVector<signed char, 8> ITKCommon_EXPORT One; - static CovariantVector<signed char, 8> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<char, 8> > { -public: - typedef char ValueType; - typedef CovariantVector<char, 8> PrintType; - typedef CovariantVector<unsigned char, 8> AbsType; - typedef CovariantVector<short, 8> AccumulateType; - typedef CovariantVector<double, 8> RealType; - typedef double ScalarRealType; - static const CovariantVector<char, 8> ITKCommon_EXPORT Zero; - static const CovariantVector<char, 8> ITKCommon_EXPORT One; - static CovariantVector<char, 8> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<short, 8> > { -public: - typedef short ValueType; - typedef CovariantVector<short, 8> PrintType; - typedef CovariantVector<unsigned short, 8> AbsType; - typedef CovariantVector<int, 8> AccumulateType; - typedef CovariantVector<double, 8> RealType; - typedef double ScalarRealType; - static const CovariantVector<short, 8> ITKCommon_EXPORT Zero; - static const CovariantVector<short, 8> ITKCommon_EXPORT One; - static CovariantVector<short, 8> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<unsigned short, 8> > { -public: - typedef unsigned short ValueType; - typedef CovariantVector<unsigned short, 8> PrintType; - typedef CovariantVector<unsigned short, 8> AbsType; - typedef CovariantVector<unsigned int, 8> AccumulateType; - typedef CovariantVector<double, 8> RealType; - typedef double ScalarRealType; - static const CovariantVector<unsigned short, 8> ITKCommon_EXPORT Zero; - static const CovariantVector<unsigned short, 8> ITKCommon_EXPORT One; - static CovariantVector<unsigned short, 8> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<int, 8> > { -public: - typedef int ValueType; - typedef CovariantVector<int, 8> PrintType; - typedef CovariantVector<unsigned int, 8> AbsType; - typedef CovariantVector<long, 8> AccumulateType; - typedef CovariantVector<double, 8> RealType; - typedef double ScalarRealType; - static const CovariantVector<int, 8> ITKCommon_EXPORT Zero; - static const CovariantVector<int, 8> ITKCommon_EXPORT One; - static CovariantVector<int, 8> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<unsigned int, 8> > { -public: - typedef unsigned int ValueType; - typedef CovariantVector<unsigned int, 8> PrintType; - typedef CovariantVector<unsigned int, 8> AbsType; - typedef CovariantVector<unsigned long, 8> AccumulateType; - typedef CovariantVector<double, 8> RealType; - typedef double ScalarRealType; - static const CovariantVector<unsigned int, 8> ITKCommon_EXPORT Zero; - static const CovariantVector<unsigned int, 8> ITKCommon_EXPORT One; - static CovariantVector<unsigned int, 8> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<long, 8> > { -public: - typedef long ValueType; - typedef CovariantVector<long, 8> PrintType; - typedef CovariantVector<unsigned long, 8> AbsType; - typedef CovariantVector<long, 8> AccumulateType; - typedef CovariantVector<double, 8> RealType; - typedef double ScalarRealType; - static const CovariantVector<long, 8> ITKCommon_EXPORT Zero; - static const CovariantVector<long, 8> ITKCommon_EXPORT One; - static CovariantVector<long, 8> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<unsigned long, 8> > { -public: - typedef unsigned long ValueType; - typedef CovariantVector<unsigned long, 8> PrintType; - typedef CovariantVector<unsigned long, 8> AbsType; - typedef CovariantVector<unsigned long, 8> AccumulateType; - typedef CovariantVector<double, 8> RealType; - typedef double ScalarRealType; - static const CovariantVector<unsigned long, 8> ITKCommon_EXPORT Zero; - static const CovariantVector<unsigned long, 8> ITKCommon_EXPORT One; - static CovariantVector<unsigned long, 8> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<float, 8> > { -public: - typedef float ValueType; - typedef CovariantVector<float, 8> PrintType; - typedef CovariantVector<float, 8> AbsType; - typedef CovariantVector<double, 8> AccumulateType; - typedef CovariantVector<double, 8> RealType; - typedef double ScalarRealType; - static const CovariantVector<float, 8> ITKCommon_EXPORT Zero; - static const CovariantVector<float, 8> ITKCommon_EXPORT One; - static CovariantVector<float, 8> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<double, 8> > { -public: - typedef double ValueType; - typedef CovariantVector<double, 8> PrintType; - typedef CovariantVector<double, 8> AbsType; - typedef CovariantVector<long double, 8> AccumulateType; - typedef CovariantVector<double, 8> RealType; - typedef double ScalarRealType; - static const CovariantVector<double, 8> ITKCommon_EXPORT Zero; - static const CovariantVector<double, 8> ITKCommon_EXPORT One; - static CovariantVector<double, 8> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<long double, 8> > { -public: - typedef long double ValueType; - typedef CovariantVector<long double, 8> PrintType; - typedef CovariantVector<long double, 8> AbsType; - typedef CovariantVector<long double, 8> AccumulateType; - typedef CovariantVector<long double, 8> RealType; - typedef long double ScalarRealType; - static const CovariantVector<long double, 8> ITKCommon_EXPORT Zero; - static const CovariantVector<long double, 8> ITKCommon_EXPORT One; - static CovariantVector<long double, 8> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<unsigned char, 9 > > { -public: - typedef unsigned char ValueType; - typedef CovariantVector<unsigned char, 9> PrintType; - typedef CovariantVector<unsigned char, 9> AbsType; - typedef CovariantVector<unsigned short, 9> AccumulateType; - typedef CovariantVector<double, 9> RealType; - typedef double ScalarRealType; - static const CovariantVector<unsigned char, 9> ITKCommon_EXPORT Zero; - static const CovariantVector<unsigned char, 9> ITKCommon_EXPORT One; - static CovariantVector<unsigned char, 9> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<signed char, 9> > { -public: - typedef signed char ValueType; - typedef CovariantVector<signed char, 9> PrintType; - typedef CovariantVector<unsigned char, 9> AbsType; - typedef CovariantVector<short, 9> AccumulateType; - typedef CovariantVector<double, 9> RealType; - typedef double ScalarRealType; - static const CovariantVector<signed char, 9> ITKCommon_EXPORT Zero; - static const CovariantVector<signed char, 9> ITKCommon_EXPORT One; - static CovariantVector<signed char, 9> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<char, 9> > { -public: - typedef char ValueType; - typedef CovariantVector<char, 9> PrintType; - typedef CovariantVector<unsigned char, 9> AbsType; - typedef CovariantVector<short, 9> AccumulateType; - typedef CovariantVector<double, 9> RealType; - typedef double ScalarRealType; - static const CovariantVector<char, 9> ITKCommon_EXPORT Zero; - static const CovariantVector<char, 9> ITKCommon_EXPORT One; - static CovariantVector<char, 9> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<short, 9> > { -public: - typedef short ValueType; - typedef CovariantVector<short, 9> PrintType; - typedef CovariantVector<unsigned short, 9> AbsType; - typedef CovariantVector<int, 9> AccumulateType; - typedef CovariantVector<double, 9> RealType; - typedef double ScalarRealType; - static const CovariantVector<short, 9> ITKCommon_EXPORT Zero; - static const CovariantVector<short, 9> ITKCommon_EXPORT One; - static CovariantVector<short, 9> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<unsigned short, 9> > { -public: - typedef unsigned short ValueType; - typedef CovariantVector<unsigned short, 9> PrintType; - typedef CovariantVector<unsigned short, 9> AbsType; - typedef CovariantVector<unsigned int, 9> AccumulateType; - typedef CovariantVector<double, 9> RealType; - typedef double ScalarRealType; - static const CovariantVector<unsigned short, 9> ITKCommon_EXPORT Zero; - static const CovariantVector<unsigned short, 9> ITKCommon_EXPORT One; - static CovariantVector<unsigned short, 9> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<int, 9> > { -public: - typedef int ValueType; - typedef CovariantVector<int, 9> PrintType; - typedef CovariantVector<unsigned int, 9> AbsType; - typedef CovariantVector<long, 9> AccumulateType; - typedef CovariantVector<double, 9> RealType; - typedef double ScalarRealType; - static const CovariantVector<int, 9> ITKCommon_EXPORT Zero; - static const CovariantVector<int, 9> ITKCommon_EXPORT One; - static CovariantVector<int, 9> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<unsigned int, 9> > { -public: - typedef unsigned int ValueType; - typedef CovariantVector<unsigned int, 9> PrintType; - typedef CovariantVector<unsigned int, 9> AbsType; - typedef CovariantVector<unsigned long, 9> AccumulateType; - typedef CovariantVector<double, 9> RealType; - typedef double ScalarRealType; - static const CovariantVector<unsigned int, 9> ITKCommon_EXPORT Zero; - static const CovariantVector<unsigned int, 9> ITKCommon_EXPORT One; - static CovariantVector<unsigned int, 9> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<long, 9> > { -public: - typedef long ValueType; - typedef CovariantVector<long, 9> PrintType; - typedef CovariantVector<unsigned long, 9> AbsType; - typedef CovariantVector<long, 9> AccumulateType; - typedef CovariantVector<double, 9> RealType; - typedef double ScalarRealType; - static const CovariantVector<long, 9> ITKCommon_EXPORT Zero; - static const CovariantVector<long, 9> ITKCommon_EXPORT One; - static CovariantVector<long, 9> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<unsigned long, 9> > { -public: - typedef unsigned long ValueType; - typedef CovariantVector<unsigned long, 9> PrintType; - typedef CovariantVector<unsigned long, 9> AbsType; - typedef CovariantVector<unsigned long, 9> AccumulateType; - typedef CovariantVector<double, 9> RealType; - typedef double ScalarRealType; - static const CovariantVector<unsigned long, 9> ITKCommon_EXPORT Zero; - static const CovariantVector<unsigned long, 9> ITKCommon_EXPORT One; - static CovariantVector<unsigned long, 9> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<float, 9> > { -public: - typedef float ValueType; - typedef CovariantVector<float, 9> PrintType; - typedef CovariantVector<float, 9> AbsType; - typedef CovariantVector<double, 9> AccumulateType; - typedef CovariantVector<double, 9> RealType; - typedef double ScalarRealType; - static const CovariantVector<float, 9> ITKCommon_EXPORT Zero; - static const CovariantVector<float, 9> ITKCommon_EXPORT One; - static CovariantVector<float, 9> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<double, 9> > { -public: - typedef double ValueType; - typedef CovariantVector<double, 9> PrintType; - typedef CovariantVector<double, 9> AbsType; - typedef CovariantVector<long double, 9> AccumulateType; - typedef CovariantVector<double, 9> RealType; - typedef double ScalarRealType; - static const CovariantVector<double, 9> ITKCommon_EXPORT Zero; - static const CovariantVector<double, 9> ITKCommon_EXPORT One; - static CovariantVector<double, 9> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<CovariantVector<long double, 9> > { -public: - typedef long double ValueType; - typedef CovariantVector<long double, 9> PrintType; - typedef CovariantVector<long double, 9> AbsType; - typedef CovariantVector<long double, 9> AccumulateType; - typedef CovariantVector<long double, 9> RealType; - typedef long double ScalarRealType; - static const CovariantVector<long double, 9> ITKCommon_EXPORT Zero; - static const CovariantVector<long double, 9> ITKCommon_EXPORT One; - static CovariantVector<long double, 9> ZeroValue() { return Zero; } -}; +// +// Instantiate the macros to declare the NumericTraits for the +// CovariantVector types. +// +#ifdef ITK_USE_NUMERIC_TRAITS_PARTIAL_SPECIALIZATION + +itkNumericTraitsGenericArrayScalarsDimensionsMacro( CovariantVector ); + +#else // ITK_USE_NUMERIC_TRAITS_PARTIAL_SPECIALIZATION + +itkNumericTraitsGenericArrayDimensionsMacro( CovariantVector, char ); +itkNumericTraitsGenericArrayDimensionsMacro( CovariantVector, unsigned char ); +itkNumericTraitsGenericArrayDimensionsMacro( CovariantVector, signed char ); +itkNumericTraitsGenericArrayDimensionsMacro( CovariantVector, short ); +itkNumericTraitsGenericArrayDimensionsMacro( CovariantVector, unsigned short ); +itkNumericTraitsGenericArrayDimensionsMacro( CovariantVector, int ); +itkNumericTraitsGenericArrayDimensionsMacro( CovariantVector, unsigned int ); +itkNumericTraitsGenericArrayDimensionsMacro( CovariantVector, long ); +itkNumericTraitsGenericArrayDimensionsMacro( CovariantVector, unsigned long ); +itkNumericTraitsGenericArrayDimensionsMacro( CovariantVector, float ); +itkNumericTraitsGenericArrayDimensionsMacro( CovariantVector, double ); +itkNumericTraitsGenericArrayDimensionsMacro( CovariantVector, long double ); +#ifdef ITK_TYPE_USE_LONG_LONG +itkNumericTraitsGenericArrayDimensionsMacro( CovariantVector, long long ); +itkNumericTraitsGenericArrayDimensionsMacro( CovariantVector, unsigned long long ); +#endif // ITK_TYPE_USE_LONG_LONG + +#endif // ITK_USE_NUMERIC_TRAITS_PARTIAL_SPECIALIZATION } // end namespace itk diff --git a/Utilities/ITK/Code/Common/itkNumericTraitsDiffusionTensor3DPixel.cxx b/Utilities/ITK/Code/Common/itkNumericTraitsDiffusionTensor3DPixel.cxx new file mode 100755 index 0000000000000000000000000000000000000000..2f24fac33f6ab34f564c1c8673578da02455c0b8 --- /dev/null +++ b/Utilities/ITK/Code/Common/itkNumericTraitsDiffusionTensor3DPixel.cxx @@ -0,0 +1,65 @@ +/*========================================================================= + + Program: Insight Segmentation & Registration Toolkit + Module: $RCSfile: itkNumericTraitsDiffusionTensor3DPixel.cxx,v $ + Language: C++ + Date: $Date: 2010-03-17 23:03:44 $ + Version: $Revision: 1.2 $ + + Copyright (c) Insight Software Consortium. All rights reserved. + See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#include "itkNumericTraitsDiffusionTensor3DPixel.h" + +namespace itk +{ + +// All the specializations that were here previously have now been +// replaced with a single template in the header file. +// + +// +// Helper macro for initializing the Zero and One static member of the NumericTraits<>. +// + +#ifdef ITK_USE_NUMERIC_TRAITS_PARTIAL_SPECIALIZATION + +#define DIFFUSIONTENSOR3DPIXELSTATICTRAITSMACRO( T ) \ +template<> \ +const DiffusionTensor3D<T> NumericTraits< DiffusionTensor3D<T> >::Zero = DiffusionTensor3D<T>( NumericTraits<T>::Zero ); \ +template<> \ +const DiffusionTensor3D<T> NumericTraits< DiffusionTensor3D<T> >::One = DiffusionTensor3D<T>( NumericTraits<T>::One ); + +#else // ITK_USE_NUMERICTRAITS_PARTIAL_SPECIALIZATION + +#define DIFFUSIONTENSOR3DPIXELSTATICTRAITSMACRO( T ) \ +const DiffusionTensor3D<T> NumericTraits< DiffusionTensor3D<T> >::Zero = DiffusionTensor3D<T>( NumericTraits<T>::Zero ); \ +const DiffusionTensor3D<T> NumericTraits< DiffusionTensor3D<T> >::One = DiffusionTensor3D<T>( NumericTraits<T>::One ); + +#endif // ITK_USE_NUMERICTRAITS_PARTIAL_SPECIALIZATION + +// +// List here the specializations of the Traits: +// + +DIFFUSIONTENSOR3DPIXELSTATICTRAITSMACRO( char ); +DIFFUSIONTENSOR3DPIXELSTATICTRAITSMACRO( unsigned char ); +DIFFUSIONTENSOR3DPIXELSTATICTRAITSMACRO( short ); +DIFFUSIONTENSOR3DPIXELSTATICTRAITSMACRO( unsigned short ); +DIFFUSIONTENSOR3DPIXELSTATICTRAITSMACRO( int ); +DIFFUSIONTENSOR3DPIXELSTATICTRAITSMACRO( unsigned int ); +DIFFUSIONTENSOR3DPIXELSTATICTRAITSMACRO( long ); +DIFFUSIONTENSOR3DPIXELSTATICTRAITSMACRO( unsigned long ); +DIFFUSIONTENSOR3DPIXELSTATICTRAITSMACRO( float ); +DIFFUSIONTENSOR3DPIXELSTATICTRAITSMACRO( double ); +#ifdef ITK_TYPE_USE_LONG_LONG +DIFFUSIONTENSOR3DPIXELSTATICTRAITSMACRO( long long ); +DIFFUSIONTENSOR3DPIXELSTATICTRAITSMACRO( unsigned long long ); +#endif // ITK_TYPE_USE_LONG_LONG + +} // end namespace itk diff --git a/Utilities/ITK/Code/Common/itkNumericTraitsDiffusionTensor3DPixel.h b/Utilities/ITK/Code/Common/itkNumericTraitsDiffusionTensor3DPixel.h new file mode 100755 index 0000000000000000000000000000000000000000..52e043e72f21d8dbbd4efb6cebbe6b7bd604dfa1 --- /dev/null +++ b/Utilities/ITK/Code/Common/itkNumericTraitsDiffusionTensor3DPixel.h @@ -0,0 +1,160 @@ +/*========================================================================= + + Program: Insight Segmentation & Registration Toolkit + Module: $RCSfile: itkNumericTraitsDiffusionTensor3DPixel.h,v $ + Language: C++ + Date: $Date: 2010-04-09 21:21:37 $ + Version: $Revision: 1.3 $ + + Copyright (c) Insight Software Consortium. All rights reserved. + See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef __itkNumericTraitsDiffusionTensor3DPixel_h +#define __itkNumericTraitsDiffusionTensor3DPixel_h + +#include "itkNumericTraitsFixedArrayPixel.h" +#include "itkDiffusionTensor3D.h" + +// This file is meant to define numeric traits for tensor pixels types in itk + +namespace itk +{ + +// +// First we define a macro that can be customized to be used for a sequence of +// specializations or for a generic template instantiation. This Macro covers +// the implementation for both partial specialization and total +// specializaion by defining certain macros. +// +#ifdef ITK_USE_NUMERIC_TRAITS_PARTIAL_SPECIALIZATION + +#define itkNumericTraitsDiffusionTensor3DMacro(GENERIC_ARRAY, T) \ + template < typename T > \ + class NumericTraits<GENERIC_ARRAY< T > > \ + { \ + private: \ + \ + typedef typename NumericTraits<T>::AbsType ElementAbsType; \ + typedef typename NumericTraits<T>::AccumulateType ElementAccumulateType; \ + typedef typename NumericTraits<T>::FloatType ElementFloatType; \ + typedef typename NumericTraits<T>::PrintType ElementPrintType; \ + typedef typename NumericTraits<T>::RealType ElementRealType; \ + \ + public: \ + \ + typedef T ValueType; \ + typedef GENERIC_ARRAY<T> Self; \ + \ + typedef GENERIC_ARRAY<ElementAbsType> AbsType; \ + typedef GENERIC_ARRAY<ElementAccumulateType> AccumulateType; \ + typedef GENERIC_ARRAY<ElementFloatType> FloatType; \ + typedef GENERIC_ARRAY<ElementPrintType> PrintType; \ + typedef GENERIC_ARRAY<ElementRealType> RealType; \ + \ + typedef ElementRealType ScalarRealType; \ + \ + static const Self max() \ + { \ + return Self( NumericTraits< T >::max() ); \ + } \ + static const Self min() \ + { \ + return Self( NumericTraits< T >::min() ); \ + } \ + static const Self NonpositiveMin() \ + { \ + return Self( NumericTraits< T >::NonpositiveMin() ); \ + } \ + static const Self ZeroValue() \ + { \ + return Self( NumericTraits<T>::ZeroValue() ); \ + } \ + static const Self OneValue() \ + { \ + return Self( NumericTraits<T>::OneValue() ); \ + } \ + static const Self ITKCommon_EXPORT Zero; \ + static const Self ITKCommon_EXPORT One; \ +}; + + +itkNumericTraitsDiffusionTensor3DMacro(DiffusionTensor3D, T) + +#else // ITK_USE_NUMERIC_TRAITS_PARTIAL_SPECIALIZATION + +#define itkNumericTraitsDiffusionTensor3DMacro(GENERIC_ARRAY, T) \ +template< > \ + class NumericTraits<GENERIC_ARRAY< T > > \ + { \ + private: \ + \ + typedef NumericTraits<T>::AbsType ElementAbsType; \ + typedef NumericTraits<T>::AccumulateType ElementAccumulateType; \ + typedef NumericTraits<T>::FloatType ElementFloatType; \ + typedef NumericTraits<T>::PrintType ElementPrintType; \ + typedef NumericTraits<T>::RealType ElementRealType; \ + \ + public: \ + \ + typedef T ValueType; \ + typedef GENERIC_ARRAY<T> Self; \ + \ + typedef GENERIC_ARRAY<ElementAbsType> AbsType; \ + typedef GENERIC_ARRAY<ElementAccumulateType> AccumulateType; \ + typedef GENERIC_ARRAY<ElementFloatType> FloatType; \ + typedef GENERIC_ARRAY<ElementPrintType> PrintType; \ + typedef GENERIC_ARRAY<ElementRealType> RealType; \ + \ + typedef ElementRealType ScalarRealType; \ + \ + static const Self max() \ + { \ + return Self( NumericTraits< T >::max() ); \ + } \ + static const Self min() \ + { \ + return Self( NumericTraits< T >::min() ); \ + } \ + static const Self NonpositiveMin() \ + { \ + return Self( NumericTraits< T >::NonpositiveMin() ); \ + } \ + static const Self ZeroValue() \ + { \ + return Self( NumericTraits<T>::ZeroValue() ); \ + } \ + static const Self OneValue() \ + { \ + return Self( NumericTraits<T>::OneValue() ); \ + } \ + static const Self ITKCommon_EXPORT Zero; \ + static const Self ITKCommon_EXPORT One; \ +}; + +itkNumericTraitsDiffusionTensor3DMacro( DiffusionTensor3D, char ); +itkNumericTraitsDiffusionTensor3DMacro( DiffusionTensor3D, unsigned char ); +itkNumericTraitsDiffusionTensor3DMacro( DiffusionTensor3D, signed char ); +itkNumericTraitsDiffusionTensor3DMacro( DiffusionTensor3D, short ); +itkNumericTraitsDiffusionTensor3DMacro( DiffusionTensor3D, unsigned short ); +itkNumericTraitsDiffusionTensor3DMacro( DiffusionTensor3D, int ); +itkNumericTraitsDiffusionTensor3DMacro( DiffusionTensor3D, unsigned int ); +itkNumericTraitsDiffusionTensor3DMacro( DiffusionTensor3D, long ); +itkNumericTraitsDiffusionTensor3DMacro( DiffusionTensor3D, unsigned long ); +itkNumericTraitsDiffusionTensor3DMacro( DiffusionTensor3D, float ); +itkNumericTraitsDiffusionTensor3DMacro( DiffusionTensor3D, double ); +itkNumericTraitsDiffusionTensor3DMacro( DiffusionTensor3D, long double ); +#ifdef ITK_TYPE_USE_LONG_LONG +itkNumericTraitsDiffusionTensor3DMacro( DiffusionTensor3D, long long ); +itkNumericTraitsDiffusionTensor3DMacro( DiffusionTensor3D, unsigned long long ); +#endif // ITK_TYPE_USE_LONG_LONG + +#endif // ITK_USE_NUMERIC_TRAITS_PARTIAL_SPECIALIZATION + +} // end namespace itk + +#endif // __itkNumericTraitsTensorPixel_h diff --git a/Utilities/ITK/Code/Common/itkNumericTraitsFixedArrayPixel.cxx b/Utilities/ITK/Code/Common/itkNumericTraitsFixedArrayPixel.cxx index 0e954261d26e36e162a4c4e6746e345e956d28ff..9f505a1317f76093de839f881160e015b2c7e57d 100644 --- a/Utilities/ITK/Code/Common/itkNumericTraitsFixedArrayPixel.cxx +++ b/Utilities/ITK/Code/Common/itkNumericTraitsFixedArrayPixel.cxx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkNumericTraitsFixedArrayPixel.cxx,v $ Language: C++ - Date: $Date: 2008-05-08 00:34:38 $ - Version: $Revision: 1.1 $ + Date: $Date: 2010-04-10 16:22:29 $ + Version: $Revision: 1.4 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -19,4 +19,22 @@ namespace itk { +itkStaticNumericTraitsGenericArrayDimensionsMacro( FixedArray, char ); +itkStaticNumericTraitsGenericArrayDimensionsMacro( FixedArray, unsigned char ); +itkStaticNumericTraitsGenericArrayDimensionsMacro( FixedArray, signed char ); +itkStaticNumericTraitsGenericArrayDimensionsMacro( FixedArray, short ); +itkStaticNumericTraitsGenericArrayDimensionsMacro( FixedArray, unsigned short ); +itkStaticNumericTraitsGenericArrayDimensionsMacro( FixedArray, int ); +itkStaticNumericTraitsGenericArrayDimensionsMacro( FixedArray, unsigned int ); +itkStaticNumericTraitsGenericArrayDimensionsMacro( FixedArray, long ); +itkStaticNumericTraitsGenericArrayDimensionsMacro( FixedArray, unsigned long ); + +// +// Subsequent Types can be found in +// +// itkNumericTraitsFixedArrayPixel2.cxx +// +// This was split in two files in order to help the Sun CC 5.6 compiler to +// manage the size of the compilation unit. +// } // end namespace itk diff --git a/Utilities/ITK/Code/Common/itkNumericTraitsFixedArrayPixel.h b/Utilities/ITK/Code/Common/itkNumericTraitsFixedArrayPixel.h index 3a50560f444c9800e8a20cac45814a1f29705e5c..5c564e6a7f73e74e8b416ff9d37cc76a84fe1943 100644 --- a/Utilities/ITK/Code/Common/itkNumericTraitsFixedArrayPixel.h +++ b/Utilities/ITK/Code/Common/itkNumericTraitsFixedArrayPixel.h @@ -3,14 +3,14 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkNumericTraitsFixedArrayPixel.h,v $ Language: C++ - Date: $Date: 2009-02-06 20:53:13 $ - Version: $Revision: 1.4 $ + Date: $Date: 2009-12-03 14:14:30 $ + Version: $Revision: 1.8 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -20,1101 +20,174 @@ #include "itkNumericTraits.h" #include "itkFixedArray.h" -// This file defines numeric traits for vector pixels types in itk -// TODO: Add doxygen tags.. namespace itk { -template <> class NumericTraits<FixedArray<unsigned char, 1 > > { -public: - typedef unsigned char ValueType; - typedef FixedArray<unsigned char, 1> PrintType; - typedef FixedArray<unsigned char, 1> AbsType; - typedef FixedArray<unsigned short, 1> AccumulateType; - typedef FixedArray<double, 1> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 1> FloatType; -}; -template <> class NumericTraits<FixedArray<signed char, 1> > { -public: - typedef signed char ValueType; - typedef FixedArray<signed char, 1> PrintType; - typedef FixedArray<unsigned char, 1> AbsType; - typedef FixedArray<short, 1> AccumulateType; - typedef FixedArray<double, 1> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 1> FloatType; -}; -template <> class NumericTraits<FixedArray<char, 1> > { -public: - typedef char ValueType; - typedef FixedArray<char, 1> PrintType; - typedef FixedArray<unsigned char, 1> AbsType; - typedef FixedArray<short, 1> AccumulateType; - typedef FixedArray<double, 1> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 1> FloatType; -}; -template <> class NumericTraits<FixedArray<short, 1> > { -public: - typedef short ValueType; - typedef FixedArray<short, 1> PrintType; - typedef FixedArray<unsigned short, 1> AbsType; - typedef FixedArray<int, 1> AccumulateType; - typedef FixedArray<double, 1> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 1> FloatType; -}; -template <> class NumericTraits<FixedArray<unsigned short, 1> > { -public: - typedef unsigned short ValueType; - typedef FixedArray<unsigned short, 1> PrintType; - typedef FixedArray<unsigned short, 1> AbsType; - typedef FixedArray<unsigned int, 1> AccumulateType; - typedef FixedArray<double, 1> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 1> FloatType; -}; -template <> class NumericTraits<FixedArray<int, 1> > { -public: - typedef int ValueType; - typedef FixedArray<int, 1> PrintType; - typedef FixedArray<unsigned int, 1> AbsType; - typedef FixedArray<long, 1> AccumulateType; - typedef FixedArray<double, 1> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 1> FloatType; -}; -template <> class NumericTraits<FixedArray<unsigned int, 1> > { -public: - typedef unsigned int ValueType; - typedef FixedArray<unsigned int, 1> PrintType; - typedef FixedArray<unsigned int, 1> AbsType; - typedef FixedArray<unsigned long, 1> AccumulateType; - typedef FixedArray<double, 1> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 1> FloatType; -}; -template <> class NumericTraits<FixedArray<long, 1> > { -public: - typedef long ValueType; - typedef FixedArray<long, 1> PrintType; - typedef FixedArray<unsigned long, 1> AbsType; - typedef FixedArray<long, 1> AccumulateType; - typedef FixedArray<double, 1> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 1> FloatType; -}; -template <> class NumericTraits<FixedArray<unsigned long, 1> > { -public: - typedef unsigned long ValueType; - typedef FixedArray<unsigned long, 1> PrintType; - typedef FixedArray<unsigned long, 1> AbsType; - typedef FixedArray<unsigned long, 1> AccumulateType; - typedef FixedArray<double, 1> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 1> FloatType; -}; -template <> class NumericTraits<FixedArray<float, 1> > { -public: - typedef float ValueType; - typedef FixedArray<float, 1> PrintType; - typedef FixedArray<float, 1> AbsType; - typedef FixedArray<double, 1> AccumulateType; - typedef FixedArray<double, 1> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 1> FloatType; -}; -template <> class NumericTraits<FixedArray<double, 1> > { -public: - typedef double ValueType; - typedef FixedArray<double, 1> PrintType; - typedef FixedArray<double, 1> AbsType; - typedef FixedArray<long double, 1> AccumulateType; - typedef FixedArray<double, 1> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 1> FloatType; -}; -template <> class NumericTraits<FixedArray<long double, 1> > { -public: - typedef long double ValueType; - typedef FixedArray<long double, 1> PrintType; - typedef FixedArray<long double, 1> AbsType; - typedef FixedArray<long double, 1> AccumulateType; - typedef FixedArray<long double, 1> RealType; - typedef long double ScalarRealType; - typedef FixedArray<float, 1> FloatType; -}; - - -template <> class NumericTraits<FixedArray<unsigned char, 2 > > { -public: - typedef unsigned char ValueType; - typedef FixedArray<unsigned char, 2> PrintType; - typedef FixedArray<unsigned char, 2> AbsType; - typedef FixedArray<unsigned short, 2> AccumulateType; - typedef FixedArray<double, 2> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 2> FloatType; -}; -template <> class NumericTraits<FixedArray<signed char, 2> > { -public: - typedef signed char ValueType; - typedef FixedArray<signed char, 2> PrintType; - typedef FixedArray<unsigned char, 2> AbsType; - typedef FixedArray<short, 2> AccumulateType; - typedef FixedArray<double, 2> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 2> FloatType; -}; -template <> class NumericTraits<FixedArray<char, 2> > { -public: - typedef char ValueType; - typedef FixedArray<char, 2> PrintType; - typedef FixedArray<unsigned char, 2> AbsType; - typedef FixedArray<short, 2> AccumulateType; - typedef FixedArray<double, 2> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 2> FloatType; -}; -template <> class NumericTraits<FixedArray<short, 2> > { -public: - typedef short ValueType; - typedef FixedArray<short, 2> PrintType; - typedef FixedArray<unsigned short, 2> AbsType; - typedef FixedArray<int, 2> AccumulateType; - typedef FixedArray<double, 2> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 2> FloatType; -}; -template <> class NumericTraits<FixedArray<unsigned short, 2> > { -public: - typedef unsigned short ValueType; - typedef FixedArray<unsigned short, 2> PrintType; - typedef FixedArray<unsigned short, 2> AbsType; - typedef FixedArray<unsigned int, 2> AccumulateType; - typedef FixedArray<double, 2> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 2> FloatType; -}; -template <> class NumericTraits<FixedArray<int, 2> > { -public: - typedef int ValueType; - typedef FixedArray<int, 2> PrintType; - typedef FixedArray<unsigned int, 2> AbsType; - typedef FixedArray<long, 2> AccumulateType; - typedef FixedArray<double, 2> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 2> FloatType; -}; -template <> class NumericTraits<FixedArray<unsigned int, 2> > { -public: - typedef unsigned int ValueType; - typedef FixedArray<unsigned int, 2> PrintType; - typedef FixedArray<unsigned int, 2> AbsType; - typedef FixedArray<unsigned long, 2> AccumulateType; - typedef FixedArray<double, 2> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 2> FloatType; -}; -template <> class NumericTraits<FixedArray<long, 2> > { -public: - typedef long ValueType; - typedef FixedArray<long, 2> PrintType; - typedef FixedArray<unsigned long, 2> AbsType; - typedef FixedArray<long, 2> AccumulateType; - typedef FixedArray<double, 2> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 2> FloatType; -}; -template <> class NumericTraits<FixedArray<unsigned long, 2> > { -public: - typedef unsigned long ValueType; - typedef FixedArray<unsigned long, 2> PrintType; - typedef FixedArray<unsigned long, 2> AbsType; - typedef FixedArray<unsigned long, 2> AccumulateType; - typedef FixedArray<double, 2> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 2> FloatType; -}; -template <> class NumericTraits<FixedArray<float, 2> > { -public: - typedef float ValueType; - typedef FixedArray<float, 2> PrintType; - typedef FixedArray<float, 2> AbsType; - typedef FixedArray<double, 2> AccumulateType; - typedef FixedArray<double, 2> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 2> FloatType; -}; -template <> class NumericTraits<FixedArray<double, 2> > { -public: - typedef double ValueType; - typedef FixedArray<double, 2> PrintType; - typedef FixedArray<double, 2> AbsType; - typedef FixedArray<long double, 2> AccumulateType; - typedef FixedArray<double, 2> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 2> FloatType; -}; -template <> class NumericTraits<FixedArray<long double, 2> > { -public: - typedef long double ValueType; - typedef FixedArray<long double, 2> PrintType; - typedef FixedArray<long double, 2> AbsType; - typedef FixedArray<long double, 2> AccumulateType; - typedef FixedArray<long double, 2> RealType; - typedef long double ScalarRealType; - typedef FixedArray<float, 2> FloatType; -}; - -template <> class NumericTraits<FixedArray<unsigned char, 3 > > { -public: - typedef unsigned char ValueType; - typedef FixedArray<unsigned char, 3> PrintType; - typedef FixedArray<unsigned char, 3> AbsType; - typedef FixedArray<unsigned short, 3> AccumulateType; - typedef FixedArray<double, 3> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 3> FloatType; -}; -template <> class NumericTraits<FixedArray<signed char, 3> > { -public: - typedef signed char ValueType; - typedef FixedArray<signed char, 3> PrintType; - typedef FixedArray<unsigned char, 3> AbsType; - typedef FixedArray<short, 3> AccumulateType; - typedef FixedArray<double, 3> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 3> FloatType; -}; -template <> class NumericTraits<FixedArray<char, 3> > { -public: - typedef char ValueType; - typedef FixedArray<char, 3> PrintType; - typedef FixedArray<unsigned char, 3> AbsType; - typedef FixedArray<short, 3> AccumulateType; - typedef FixedArray<double, 3> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 3> FloatType; -}; -template <> class NumericTraits<FixedArray<short, 3> > { -public: - typedef short ValueType; - typedef FixedArray<short, 3> PrintType; - typedef FixedArray<unsigned short, 3> AbsType; - typedef FixedArray<int, 3> AccumulateType; - typedef FixedArray<double, 3> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 3> FloatType; -}; -template <> class NumericTraits<FixedArray<unsigned short, 3> > { -public: - typedef unsigned short ValueType; - typedef FixedArray<unsigned short, 3> PrintType; - typedef FixedArray<unsigned short, 3> AbsType; - typedef FixedArray<unsigned int, 3> AccumulateType; - typedef FixedArray<double, 3> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 3> FloatType; -}; -template <> class NumericTraits<FixedArray<int, 3> > { -public: - typedef int ValueType; - typedef FixedArray<int, 3> PrintType; - typedef FixedArray<unsigned int, 3> AbsType; - typedef FixedArray<long, 3> AccumulateType; - typedef FixedArray<double, 3> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 3> FloatType; -}; -template <> class NumericTraits<FixedArray<unsigned int, 3> > { -public: - typedef unsigned int ValueType; - typedef FixedArray<unsigned int, 3> PrintType; - typedef FixedArray<unsigned int, 3> AbsType; - typedef FixedArray<unsigned long, 3> AccumulateType; - typedef FixedArray<double, 3> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 3> FloatType; -}; -template <> class NumericTraits<FixedArray<long, 3> > { -public: - typedef long ValueType; - typedef FixedArray<long, 3> PrintType; - typedef FixedArray<unsigned long, 3> AbsType; - typedef FixedArray<long, 3> AccumulateType; - typedef FixedArray<double, 3> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 3> FloatType; -}; -template <> class NumericTraits<FixedArray<unsigned long, 3> > { -public: - typedef unsigned long ValueType; - typedef FixedArray<unsigned long, 3> PrintType; - typedef FixedArray<unsigned long, 3> AbsType; - typedef FixedArray<unsigned long, 3> AccumulateType; - typedef FixedArray<double, 3> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 3> FloatType; -}; -template <> class NumericTraits<FixedArray<float, 3> > { -public: - typedef float ValueType; - typedef FixedArray<float, 3> PrintType; - typedef FixedArray<float, 3> AbsType; - typedef FixedArray<double, 3> AccumulateType; - typedef FixedArray<double, 3> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 3> FloatType; -}; -template <> class NumericTraits<FixedArray<double, 3> > { -public: - typedef double ValueType; - typedef FixedArray<double, 3> PrintType; - typedef FixedArray<double, 3> AbsType; - typedef FixedArray<long double, 3> AccumulateType; - typedef FixedArray<double, 3> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 3> FloatType; -}; -template <> class NumericTraits<FixedArray<long double, 3> > { -public: - typedef long double ValueType; - typedef FixedArray<long double, 3> PrintType; - typedef FixedArray<long double, 3> AbsType; - typedef FixedArray<long double, 3> AccumulateType; - typedef FixedArray<long double, 3> RealType; - typedef long double ScalarRealType; - typedef FixedArray<float, 3> FloatType; -}; -template <> class NumericTraits<FixedArray<unsigned char, 4 > > { -public: - typedef unsigned char ValueType; - typedef FixedArray<unsigned char, 4> PrintType; - typedef FixedArray<unsigned char, 4> AbsType; - typedef FixedArray<unsigned short, 4> AccumulateType; - typedef FixedArray<double, 4> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 4> FloatType; -}; -template <> class NumericTraits<FixedArray<signed char, 4> > { -public: - typedef signed char ValueType; - typedef FixedArray<signed char, 4> PrintType; - typedef FixedArray<unsigned char, 4> AbsType; - typedef FixedArray<short, 4> AccumulateType; - typedef FixedArray<double, 4> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 4> FloatType; -}; -template <> class NumericTraits<FixedArray<char, 4> > { -public: - typedef char ValueType; - typedef FixedArray<char, 4> PrintType; - typedef FixedArray<unsigned char, 4> AbsType; - typedef FixedArray<short, 4> AccumulateType; - typedef FixedArray<double, 4> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 4> FloatType; -}; -template <> class NumericTraits<FixedArray<short, 4> > { -public: - typedef short ValueType; - typedef FixedArray<short, 4> PrintType; - typedef FixedArray<unsigned short, 4> AbsType; - typedef FixedArray<int, 4> AccumulateType; - typedef FixedArray<double, 4> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 4> FloatType; -}; -template <> class NumericTraits<FixedArray<unsigned short, 4> > { -public: - typedef unsigned short ValueType; - typedef FixedArray<unsigned short, 4> PrintType; - typedef FixedArray<unsigned short, 4> AbsType; - typedef FixedArray<unsigned int, 4> AccumulateType; - typedef FixedArray<double, 4> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 4> FloatType; -}; -template <> class NumericTraits<FixedArray<int, 4> > { -public: - typedef int ValueType; - typedef FixedArray<int, 4> PrintType; - typedef FixedArray<unsigned int, 4> AbsType; - typedef FixedArray<long, 4> AccumulateType; - typedef FixedArray<double, 4> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 4> FloatType; -}; -template <> class NumericTraits<FixedArray<unsigned int, 4> > { -public: - typedef unsigned int ValueType; - typedef FixedArray<unsigned int, 4> PrintType; - typedef FixedArray<unsigned int, 4> AbsType; - typedef FixedArray<unsigned long, 4> AccumulateType; - typedef FixedArray<double, 4> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 4> FloatType; -}; -template <> class NumericTraits<FixedArray<long, 4> > { -public: - typedef long ValueType; - typedef FixedArray<long, 4> PrintType; - typedef FixedArray<unsigned long, 4> AbsType; - typedef FixedArray<long, 4> AccumulateType; - typedef FixedArray<double, 4> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 4> FloatType; -}; -template <> class NumericTraits<FixedArray<unsigned long, 4> > { -public: - typedef unsigned long ValueType; - typedef FixedArray<unsigned long, 4> PrintType; - typedef FixedArray<unsigned long, 4> AbsType; - typedef FixedArray<unsigned long, 4> AccumulateType; - typedef FixedArray<double, 4> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 4> FloatType; -}; -template <> class NumericTraits<FixedArray<float, 4> > { -public: - typedef float ValueType; - typedef FixedArray<float, 4> PrintType; - typedef FixedArray<float, 4> AbsType; - typedef FixedArray<double, 4> AccumulateType; - typedef FixedArray<double, 4> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 4> FloatType; -}; -template <> class NumericTraits<FixedArray<double, 4> > { -public: - typedef double ValueType; - typedef FixedArray<double, 4> PrintType; - typedef FixedArray<double, 4> AbsType; - typedef FixedArray<long double, 4> AccumulateType; - typedef FixedArray<double, 4> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 4> FloatType; -}; -template <> class NumericTraits<FixedArray<long double, 4> > { -public: - typedef long double ValueType; - typedef FixedArray<long double, 4> PrintType; - typedef FixedArray<long double, 4> AbsType; - typedef FixedArray<long double, 4> AccumulateType; - typedef FixedArray<long double, 4> RealType; - typedef long double ScalarRealType; - typedef FixedArray<float, 4> FloatType; -}; -template <> class NumericTraits<FixedArray<unsigned char, 5 > > { -public: - typedef unsigned char ValueType; - typedef FixedArray<unsigned char, 5> PrintType; - typedef FixedArray<unsigned char, 5> AbsType; - typedef FixedArray<unsigned short, 5> AccumulateType; - typedef FixedArray<double, 5> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 5> FloatType; -}; -template <> class NumericTraits<FixedArray<signed char, 5> > { -public: - typedef signed char ValueType; - typedef FixedArray<signed char, 5> PrintType; - typedef FixedArray<unsigned char, 5> AbsType; - typedef FixedArray<short, 5> AccumulateType; - typedef FixedArray<double, 5> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 5> FloatType; -}; -template <> class NumericTraits<FixedArray<char, 5> > { -public: - typedef char ValueType; - typedef FixedArray<char, 5> PrintType; - typedef FixedArray<unsigned char, 5> AbsType; - typedef FixedArray<short, 5> AccumulateType; - typedef FixedArray<double, 5> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 5> FloatType; -}; -template <> class NumericTraits<FixedArray<short, 5> > { -public: - typedef short ValueType; - typedef FixedArray<short, 5> PrintType; - typedef FixedArray<unsigned short, 5> AbsType; - typedef FixedArray<int, 5> AccumulateType; - typedef FixedArray<double, 5> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 5> FloatType; -}; -template <> class NumericTraits<FixedArray<unsigned short, 5> > { -public: - typedef unsigned short ValueType; - typedef FixedArray<unsigned short, 5> PrintType; - typedef FixedArray<unsigned short, 5> AbsType; - typedef FixedArray<unsigned int, 5> AccumulateType; - typedef FixedArray<double, 5> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 5> FloatType; -}; -template <> class NumericTraits<FixedArray<int, 5> > { -public: - typedef int ValueType; - typedef FixedArray<int, 5> PrintType; - typedef FixedArray<unsigned int, 5> AbsType; - typedef FixedArray<long, 5> AccumulateType; - typedef FixedArray<double, 5> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 5> FloatType; -}; -template <> class NumericTraits<FixedArray<unsigned int, 5> > { -public: - typedef unsigned int ValueType; - typedef FixedArray<unsigned int, 5> PrintType; - typedef FixedArray<unsigned int, 5> AbsType; - typedef FixedArray<unsigned long, 5> AccumulateType; - typedef FixedArray<double, 5> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 5> FloatType; -}; -template <> class NumericTraits<FixedArray<long, 5> > { -public: - typedef long ValueType; - typedef FixedArray<long, 5> PrintType; - typedef FixedArray<unsigned long, 5> AbsType; - typedef FixedArray<long, 5> AccumulateType; - typedef FixedArray<double, 5> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 5> FloatType; -}; -template <> class NumericTraits<FixedArray<unsigned long, 5> > { -public: - typedef unsigned long ValueType; - typedef FixedArray<unsigned long, 5> PrintType; - typedef FixedArray<unsigned long, 5> AbsType; - typedef FixedArray<unsigned long, 5> AccumulateType; - typedef FixedArray<double, 5> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 5> FloatType; -}; -template <> class NumericTraits<FixedArray<float, 5> > { -public: - typedef float ValueType; - typedef FixedArray<float, 5> PrintType; - typedef FixedArray<float, 5> AbsType; - typedef FixedArray<double, 5> AccumulateType; - typedef FixedArray<double, 5> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 5> FloatType; -}; -template <> class NumericTraits<FixedArray<double, 5> > { -public: - typedef double ValueType; - typedef FixedArray<double, 5> PrintType; - typedef FixedArray<double, 5> AbsType; - typedef FixedArray<long double, 5> AccumulateType; - typedef FixedArray<double, 5> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 5> FloatType; -}; -template <> class NumericTraits<FixedArray<long double, 5> > { -public: - typedef long double ValueType; - typedef FixedArray<long double, 5> PrintType; - typedef FixedArray<long double, 5> AbsType; - typedef FixedArray<long double, 5> AccumulateType; - typedef FixedArray<long double, 5> RealType; - typedef long double ScalarRealType; - typedef FixedArray<float, 5> FloatType; -}; - -template <> class NumericTraits<FixedArray<unsigned char, 6 > > { -public: - typedef unsigned char ValueType; - typedef FixedArray<unsigned char, 6> PrintType; - typedef FixedArray<unsigned char, 6> AbsType; - typedef FixedArray<unsigned short, 6> AccumulateType; - typedef FixedArray<double, 6> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 6> FloatType; -}; -template <> class NumericTraits<FixedArray<signed char, 6> > { -public: - typedef signed char ValueType; - typedef FixedArray<signed char, 6> PrintType; - typedef FixedArray<unsigned char, 6> AbsType; - typedef FixedArray<short, 6> AccumulateType; - typedef FixedArray<double, 6> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 6> FloatType; -}; -template <> class NumericTraits<FixedArray<char, 6> > { -public: - typedef char ValueType; - typedef FixedArray<char, 6> PrintType; - typedef FixedArray<unsigned char, 6> AbsType; - typedef FixedArray<short, 6> AccumulateType; - typedef FixedArray<double, 6> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 6> FloatType; -}; -template <> class NumericTraits<FixedArray<short, 6> > { -public: - typedef short ValueType; - typedef FixedArray<short, 6> PrintType; - typedef FixedArray<unsigned short, 6> AbsType; - typedef FixedArray<int, 6> AccumulateType; - typedef FixedArray<double, 6> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 6> FloatType; -}; -template <> class NumericTraits<FixedArray<unsigned short, 6> > { -public: - typedef unsigned short ValueType; - typedef FixedArray<unsigned short, 6> PrintType; - typedef FixedArray<unsigned short, 6> AbsType; - typedef FixedArray<unsigned int, 6> AccumulateType; - typedef FixedArray<double, 6> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 6> FloatType; -}; -template <> class NumericTraits<FixedArray<int, 6> > { -public: - typedef int ValueType; - typedef FixedArray<int, 6> PrintType; - typedef FixedArray<unsigned int, 6> AbsType; - typedef FixedArray<long, 6> AccumulateType; - typedef FixedArray<double, 6> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 6> FloatType; -}; -template <> class NumericTraits<FixedArray<unsigned int, 6> > { -public: - typedef unsigned int ValueType; - typedef FixedArray<unsigned int, 6> PrintType; - typedef FixedArray<unsigned int, 6> AbsType; - typedef FixedArray<unsigned long, 6> AccumulateType; - typedef FixedArray<double, 6> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 6> FloatType; -}; -template <> class NumericTraits<FixedArray<long, 6> > { -public: - typedef long ValueType; - typedef FixedArray<long, 6> PrintType; - typedef FixedArray<unsigned long, 6> AbsType; - typedef FixedArray<long, 6> AccumulateType; - typedef FixedArray<double, 6> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 6> FloatType; -}; -template <> class NumericTraits<FixedArray<unsigned long, 6> > { -public: - typedef unsigned long ValueType; - typedef FixedArray<unsigned long, 6> PrintType; - typedef FixedArray<unsigned long, 6> AbsType; - typedef FixedArray<unsigned long, 6> AccumulateType; - typedef FixedArray<double, 6> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 6> FloatType; -}; -template <> class NumericTraits<FixedArray<float, 6> > { -public: - typedef float ValueType; - typedef FixedArray<float, 6> PrintType; - typedef FixedArray<float, 6> AbsType; - typedef FixedArray<double, 6> AccumulateType; - typedef FixedArray<double, 6> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 6> FloatType; -}; -template <> class NumericTraits<FixedArray<double, 6> > { -public: - typedef double ValueType; - typedef FixedArray<double, 6> PrintType; - typedef FixedArray<double, 6> AbsType; - typedef FixedArray<long double, 6> AccumulateType; - typedef FixedArray<double, 6> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 6> FloatType; -}; -template <> class NumericTraits<FixedArray<long double, 6> > { -public: - typedef long double ValueType; - typedef FixedArray<long double, 6> PrintType; - typedef FixedArray<long double, 6> AbsType; - typedef FixedArray<long double, 6> AccumulateType; - typedef FixedArray<long double, 6> RealType; - typedef long double ScalarRealType; - typedef FixedArray<float, 6> FloatType; -}; - -template <> class NumericTraits<FixedArray<unsigned char, 7 > > { -public: - typedef unsigned char ValueType; - typedef FixedArray<unsigned char, 7> PrintType; - typedef FixedArray<unsigned char, 7> AbsType; - typedef FixedArray<unsigned short, 7> AccumulateType; - typedef FixedArray<double, 7> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 7> FloatType; -}; -template <> class NumericTraits<FixedArray<signed char, 7> > { -public: - typedef signed char ValueType; - typedef FixedArray<signed char, 7> PrintType; - typedef FixedArray<unsigned char, 7> AbsType; - typedef FixedArray<short, 7> AccumulateType; - typedef FixedArray<double, 7> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 7> FloatType; -}; -template <> class NumericTraits<FixedArray<char, 7> > { -public: - typedef char ValueType; - typedef FixedArray<char, 7> PrintType; - typedef FixedArray<unsigned char, 7> AbsType; - typedef FixedArray<short, 7> AccumulateType; - typedef FixedArray<double, 7> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 7> FloatType; -}; -template <> class NumericTraits<FixedArray<short, 7> > { -public: - typedef short ValueType; - typedef FixedArray<short, 7> PrintType; - typedef FixedArray<unsigned short, 7> AbsType; - typedef FixedArray<int, 7> AccumulateType; - typedef FixedArray<double, 7> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 7> FloatType; -}; -template <> class NumericTraits<FixedArray<unsigned short, 7> > { -public: - typedef unsigned short ValueType; - typedef FixedArray<unsigned short, 7> PrintType; - typedef FixedArray<unsigned short, 7> AbsType; - typedef FixedArray<unsigned int, 7> AccumulateType; - typedef FixedArray<double, 7> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 7> FloatType; -}; -template <> class NumericTraits<FixedArray<int, 7> > { -public: - typedef int ValueType; - typedef FixedArray<int, 7> PrintType; - typedef FixedArray<unsigned int, 7> AbsType; - typedef FixedArray<long, 7> AccumulateType; - typedef FixedArray<double, 7> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 7> FloatType; -}; -template <> class NumericTraits<FixedArray<unsigned int, 7> > { -public: - typedef unsigned int ValueType; - typedef FixedArray<unsigned int, 7> PrintType; - typedef FixedArray<unsigned int, 7> AbsType; - typedef FixedArray<unsigned long, 7> AccumulateType; - typedef FixedArray<double, 7> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 7> FloatType; -}; -template <> class NumericTraits<FixedArray<long, 7> > { -public: - typedef long ValueType; - typedef FixedArray<long, 7> PrintType; - typedef FixedArray<unsigned long, 7> AbsType; - typedef FixedArray<long, 7> AccumulateType; - typedef FixedArray<double, 7> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 7> FloatType; -}; -template <> class NumericTraits<FixedArray<unsigned long, 7> > { -public: - typedef unsigned long ValueType; - typedef FixedArray<unsigned long, 7> PrintType; - typedef FixedArray<unsigned long, 7> AbsType; - typedef FixedArray<unsigned long, 7> AccumulateType; - typedef FixedArray<double, 7> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 7> FloatType; -}; -template <> class NumericTraits<FixedArray<float, 7> > { -public: - typedef float ValueType; - typedef FixedArray<float, 7> PrintType; - typedef FixedArray<float, 7> AbsType; - typedef FixedArray<double, 7> AccumulateType; - typedef FixedArray<double, 7> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 7> FloatType; -}; -template <> class NumericTraits<FixedArray<double, 7> > { -public: - typedef double ValueType; - typedef FixedArray<double, 7> PrintType; - typedef FixedArray<double, 7> AbsType; - typedef FixedArray<long double, 7> AccumulateType; - typedef FixedArray<double, 7> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 7> FloatType; -}; -template <> class NumericTraits<FixedArray<long double, 7> > { -public: - typedef long double ValueType; - typedef FixedArray<long double, 7> PrintType; - typedef FixedArray<long double, 7> AbsType; - typedef FixedArray<long double, 7> AccumulateType; - typedef FixedArray<long double, 7> RealType; - typedef long double ScalarRealType; - typedef FixedArray<float, 7> FloatType; -}; - -template <> class NumericTraits<FixedArray<unsigned char, 8 > > { -public: - typedef unsigned char ValueType; - typedef FixedArray<unsigned char, 8> PrintType; - typedef FixedArray<unsigned char, 8> AbsType; - typedef FixedArray<unsigned short, 8> AccumulateType; - typedef FixedArray<double, 8> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 8> FloatType; -}; -template <> class NumericTraits<FixedArray<signed char, 8> > { -public: - typedef signed char ValueType; - typedef FixedArray<signed char, 8> PrintType; - typedef FixedArray<unsigned char, 8> AbsType; - typedef FixedArray<short, 8> AccumulateType; - typedef FixedArray<double, 8> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 8> FloatType; -}; -template <> class NumericTraits<FixedArray<char, 8> > { -public: - typedef char ValueType; - typedef FixedArray<char, 8> PrintType; - typedef FixedArray<unsigned char, 8> AbsType; - typedef FixedArray<short, 8> AccumulateType; - typedef FixedArray<double, 8> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 8> FloatType; -}; -template <> class NumericTraits<FixedArray<short, 8> > { -public: - typedef short ValueType; - typedef FixedArray<short, 8> PrintType; - typedef FixedArray<unsigned short, 8> AbsType; - typedef FixedArray<int, 8> AccumulateType; - typedef FixedArray<double, 8> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 8> FloatType; -}; -template <> class NumericTraits<FixedArray<unsigned short, 8> > { -public: - typedef unsigned short ValueType; - typedef FixedArray<unsigned short, 8> PrintType; - typedef FixedArray<unsigned short, 8> AbsType; - typedef FixedArray<unsigned int, 8> AccumulateType; - typedef FixedArray<double, 8> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 8> FloatType; -}; -template <> class NumericTraits<FixedArray<int, 8> > { -public: - typedef int ValueType; - typedef FixedArray<int, 8> PrintType; - typedef FixedArray<unsigned int, 8> AbsType; - typedef FixedArray<long, 8> AccumulateType; - typedef FixedArray<double, 8> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 8> FloatType; -}; -template <> class NumericTraits<FixedArray<unsigned int, 8> > { -public: - typedef unsigned int ValueType; - typedef FixedArray<unsigned int, 8> PrintType; - typedef FixedArray<unsigned int, 8> AbsType; - typedef FixedArray<unsigned long, 8> AccumulateType; - typedef FixedArray<double, 8> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 8> FloatType; -}; -template <> class NumericTraits<FixedArray<long, 8> > { -public: - typedef long ValueType; - typedef FixedArray<long, 8> PrintType; - typedef FixedArray<unsigned long, 8> AbsType; - typedef FixedArray<long, 8> AccumulateType; - typedef FixedArray<double, 8> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 8> FloatType; -}; -template <> class NumericTraits<FixedArray<unsigned long, 8> > { -public: - typedef unsigned long ValueType; - typedef FixedArray<unsigned long, 8> PrintType; - typedef FixedArray<unsigned long, 8> AbsType; - typedef FixedArray<unsigned long, 8> AccumulateType; - typedef FixedArray<double, 8> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 8> FloatType; -}; -template <> class NumericTraits<FixedArray<float, 8> > { -public: - typedef float ValueType; - typedef FixedArray<float, 8> PrintType; - typedef FixedArray<float, 8> AbsType; - typedef FixedArray<double, 8> AccumulateType; - typedef FixedArray<double, 8> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 8> FloatType; -}; -template <> class NumericTraits<FixedArray<double, 8> > { -public: - typedef double ValueType; - typedef FixedArray<double, 8> PrintType; - typedef FixedArray<double, 8> AbsType; - typedef FixedArray<long double, 8> AccumulateType; - typedef FixedArray<double, 8> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 8> FloatType; -}; -template <> class NumericTraits<FixedArray<long double, 8> > { -public: - typedef long double ValueType; - typedef FixedArray<long double, 8> PrintType; - typedef FixedArray<long double, 8> AbsType; - typedef FixedArray<long double, 8> AccumulateType; - typedef FixedArray<long double, 8> RealType; - typedef long double ScalarRealType; - typedef FixedArray<float, 8> FloatType; -}; - -template <> class NumericTraits<FixedArray<unsigned char, 9 > > { -public: - typedef unsigned char ValueType; - typedef FixedArray<unsigned char, 9> PrintType; - typedef FixedArray<unsigned char, 9> AbsType; - typedef FixedArray<unsigned short, 9> AccumulateType; - typedef FixedArray<double, 9> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 9> FloatType; -}; -template <> class NumericTraits<FixedArray<signed char, 9> > { -public: - typedef signed char ValueType; - typedef FixedArray<signed char, 9> PrintType; - typedef FixedArray<unsigned char, 9> AbsType; - typedef FixedArray<short, 9> AccumulateType; - typedef FixedArray<double, 9> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 9> FloatType; -}; -template <> class NumericTraits<FixedArray<char, 9> > { -public: - typedef char ValueType; - typedef FixedArray<char, 9> PrintType; - typedef FixedArray<unsigned char, 9> AbsType; - typedef FixedArray<short, 9> AccumulateType; - typedef FixedArray<double, 9> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 9> FloatType; -}; -template <> class NumericTraits<FixedArray<short, 9> > { -public: - typedef short ValueType; - typedef FixedArray<short, 9> PrintType; - typedef FixedArray<unsigned short, 9> AbsType; - typedef FixedArray<int, 9> AccumulateType; - typedef FixedArray<double, 9> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 9> FloatType; -}; -template <> class NumericTraits<FixedArray<unsigned short, 9> > { -public: - typedef unsigned short ValueType; - typedef FixedArray<unsigned short, 9> PrintType; - typedef FixedArray<unsigned short, 9> AbsType; - typedef FixedArray<unsigned int, 9> AccumulateType; - typedef FixedArray<double, 9> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 9> FloatType; -}; -template <> class NumericTraits<FixedArray<int, 9> > { -public: - typedef int ValueType; - typedef FixedArray<int, 9> PrintType; - typedef FixedArray<unsigned int, 9> AbsType; - typedef FixedArray<long, 9> AccumulateType; - typedef FixedArray<double, 9> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 9> FloatType; -}; -template <> class NumericTraits<FixedArray<unsigned int, 9> > { -public: - typedef unsigned int ValueType; - typedef FixedArray<unsigned int, 9> PrintType; - typedef FixedArray<unsigned int, 9> AbsType; - typedef FixedArray<unsigned long, 9> AccumulateType; - typedef FixedArray<double, 9> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 9> FloatType; -}; -template <> class NumericTraits<FixedArray<long, 9> > { -public: - typedef long ValueType; - typedef FixedArray<long, 9> PrintType; - typedef FixedArray<unsigned long, 9> AbsType; - typedef FixedArray<long, 9> AccumulateType; - typedef FixedArray<double, 9> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 9> FloatType; -}; -template <> class NumericTraits<FixedArray<unsigned long, 9> > { -public: - typedef unsigned long ValueType; - typedef FixedArray<unsigned long, 9> PrintType; - typedef FixedArray<unsigned long, 9> AbsType; - typedef FixedArray<unsigned long, 9> AccumulateType; - typedef FixedArray<double, 9> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 9> FloatType; -}; -template <> class NumericTraits<FixedArray<float, 9> > { -public: - typedef float ValueType; - typedef FixedArray<float, 9> PrintType; - typedef FixedArray<float, 9> AbsType; - typedef FixedArray<double, 9> AccumulateType; - typedef FixedArray<double, 9> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 9> FloatType; -}; -template <> class NumericTraits<FixedArray<double, 9> > { -public: - typedef double ValueType; - typedef FixedArray<double, 9> PrintType; - typedef FixedArray<double, 9> AbsType; - typedef FixedArray<long double, 9> AccumulateType; - typedef FixedArray<double, 9> RealType; - typedef double ScalarRealType; - typedef FixedArray<float, 9> FloatType; -}; -template <> class NumericTraits<FixedArray<long double, 9> > { -public: - typedef long double ValueType; - typedef FixedArray<long double, 9> PrintType; - typedef FixedArray<long double, 9> AbsType; - typedef FixedArray<long double, 9> AccumulateType; - typedef FixedArray<long double, 9> RealType; - typedef long double ScalarRealType; - typedef FixedArray<float, 9> FloatType; -}; +// +// First we define a macro that can be customized to be used for a sequence of +// specializations or for a generic template instantiation. This Macro covers +// the implementation for both partial specialization and total +// specializaion by defining certain macros. +// +#define itkNumericTraitsGenericArrayMacro(GENERIC_ARRAY, T, D) \ + template < ITK_NUMERIC_TRAITS_TEMPLATE_ARGUMENTS > \ + class NumericTraits<GENERIC_ARRAY< T, D > > \ + { \ + private: \ + \ + typedef ITK_NUMERIC_TRAITS_TYPENAME NumericTraits<T>::AbsType ElementAbsType; \ + typedef ITK_NUMERIC_TRAITS_TYPENAME NumericTraits<T>::AccumulateType ElementAccumulateType; \ + typedef ITK_NUMERIC_TRAITS_TYPENAME NumericTraits<T>::FloatType ElementFloatType; \ + typedef ITK_NUMERIC_TRAITS_TYPENAME NumericTraits<T>::PrintType ElementPrintType; \ + typedef ITK_NUMERIC_TRAITS_TYPENAME NumericTraits<T>::RealType ElementRealType; \ + \ + public: \ + \ + typedef T ValueType; \ + typedef GENERIC_ARRAY<T, D> Self; \ + \ + typedef GENERIC_ARRAY<ElementAbsType, D> AbsType; \ + typedef GENERIC_ARRAY<ElementAccumulateType, D> AccumulateType; \ + typedef GENERIC_ARRAY<ElementFloatType, D> FloatType; \ + typedef GENERIC_ARRAY<ElementPrintType, D> PrintType; \ + typedef GENERIC_ARRAY<ElementRealType, D> RealType; \ + \ + typedef ElementRealType ScalarRealType; \ + \ + static const Self max() \ + { \ + return Self( NumericTraits< T >::max() ); \ + } \ + static const Self min() \ + { \ + return Self( NumericTraits< T >::min() ); \ + } \ + static const Self NonpositiveMin() \ + { \ + return Self( NumericTraits< T >::NonpositiveMin() ); \ + } \ + static const Self ZeroValue() \ + { \ + return Self( NumericTraits<T>::ZeroValue() ); \ + } \ + static const Self OneValue() \ + { \ + return Self( NumericTraits<T>::OneValue() ); \ + } \ + static const Self ITKCommon_EXPORT Zero; \ + static const Self ITKCommon_EXPORT One; \ +}; + + +#ifdef ITK_USE_NUMERIC_TRAITS_PARTIAL_SPECIALIZATION + + +// For all the good compilers, we provide here a generic implementation +// based on creating types of FixedArray whose components are the types of the +// NumericTraits from the original RGBAPixel components. This implementation +// require support for partial specializations, since it is based on +// the concept that: +// +// NumericTraits<FixedArray< T > > is defined piecewise by +// FixedArray< NumericTraits< T > > +// +#define ITK_NUMERIC_TRAITS_TYPENAME typename +#define ITK_NUMERIC_TRAITS_TEMPLATE_ARGUMENTS typename T, unsigned int D + + +#define itkNumericTraitsGenericArrayScalarsDimensionsMacro( GENERIC_ARRAY ) \ + itkNumericTraitsGenericArrayMacro( GENERIC_ARRAY, T, D ); + +// a macro to define and initialize static member variables +#define itkStaticNumericTraitsGenericArrayMacro( GENERIC_ARRAY, T, D ) \ + template< > const GENERIC_ARRAY<T,D> NumericTraits< GENERIC_ARRAY<T,D> >::Zero = GENERIC_ARRAY<T,D>( NumericTraits<T>::Zero ); \ + template< > const GENERIC_ARRAY<T,D> NumericTraits< GENERIC_ARRAY<T,D> >::One = GENERIC_ARRAY<T,D>( NumericTraits<T>::One ); + + +#else // ITK_USE_NUMERICTRAITS_PARTIAL_SPECIALIZATION + +// For the "bad" compilers we need total specialization of the +// NumericTraits. That means over the the types and the dimension of +// the array. We add a macro to instantiate the NumericTrait macro over +// only the dimensions. Then manually instantiated for all they type, +// which may have compile time conditionals. + + +// These two symbols below are defined empty on purpose +#define ITK_NUMERIC_TRAITS_TYPENAME +#define ITK_NUMERIC_TRAITS_TEMPLATE_ARGUMENTS + +// +// List here the array dimension specializations of these Traits: +// +#define itkNumericTraitsGenericArrayDimensionsMacro( GENERIC_ARRAY, T ) \ + itkNumericTraitsGenericArrayMacro( GENERIC_ARRAY, T, 1 ); \ + itkNumericTraitsGenericArrayMacro( GENERIC_ARRAY, T, 2 ); \ + itkNumericTraitsGenericArrayMacro( GENERIC_ARRAY, T, 3 ); \ + itkNumericTraitsGenericArrayMacro( GENERIC_ARRAY, T, 4 ); \ + itkNumericTraitsGenericArrayMacro( GENERIC_ARRAY, T, 5 ); \ + itkNumericTraitsGenericArrayMacro( GENERIC_ARRAY, T, 6 ); \ + itkNumericTraitsGenericArrayMacro( GENERIC_ARRAY, T, 7 ); \ + itkNumericTraitsGenericArrayMacro( GENERIC_ARRAY, T, 8 ); \ + itkNumericTraitsGenericArrayMacro( GENERIC_ARRAY, T, 9 ); \ + itkNumericTraitsGenericArrayMacro( GENERIC_ARRAY, T, 10 ); + +// a macro to define and initialize static member variables +#define itkStaticNumericTraitsGenericArrayMacro( GENERIC_ARRAY, T, D ) \ + const GENERIC_ARRAY<T,D> NumericTraits< GENERIC_ARRAY<T,D> >::Zero = GENERIC_ARRAY<T,D>( NumericTraits<T>::Zero ); \ + const GENERIC_ARRAY<T,D> NumericTraits< GENERIC_ARRAY<T,D> >::One = GENERIC_ARRAY<T,D>( NumericTraits<T>::One ); + +#endif // ITK_USE_NUMERICTRAITS_PARTIAL_SPECIALIZATION + + +// +// List here the array dimension specializations of these static +// Traits: +// +#define itkStaticNumericTraitsGenericArrayDimensionsMacro( GENERIC_ARRAY, T ) \ + itkStaticNumericTraitsGenericArrayMacro( GENERIC_ARRAY, T, 1 ); \ + itkStaticNumericTraitsGenericArrayMacro( GENERIC_ARRAY, T, 2 ); \ + itkStaticNumericTraitsGenericArrayMacro( GENERIC_ARRAY, T, 3 ); \ + itkStaticNumericTraitsGenericArrayMacro( GENERIC_ARRAY, T, 4 ); \ + itkStaticNumericTraitsGenericArrayMacro( GENERIC_ARRAY, T, 5 ); \ + itkStaticNumericTraitsGenericArrayMacro( GENERIC_ARRAY, T, 6 ); \ + itkStaticNumericTraitsGenericArrayMacro( GENERIC_ARRAY, T, 7 ); \ + itkStaticNumericTraitsGenericArrayMacro( GENERIC_ARRAY, T, 8 ); \ + itkStaticNumericTraitsGenericArrayMacro( GENERIC_ARRAY, T, 9 ); \ + itkStaticNumericTraitsGenericArrayMacro( GENERIC_ARRAY, T, 10 ); + + +// +// Instantiate the macros to declare the NumericTraits for the +// FixedArray types. +// +#ifdef ITK_USE_NUMERIC_TRAITS_PARTIAL_SPECIALIZATION + +itkNumericTraitsGenericArrayScalarsDimensionsMacro( FixedArray ); + +#else // ITK_USE_NUMERIC_TRAITS_PARTIAL_SPECIALIZATION + +itkNumericTraitsGenericArrayDimensionsMacro( FixedArray, char ); +itkNumericTraitsGenericArrayDimensionsMacro( FixedArray, unsigned char ); +itkNumericTraitsGenericArrayDimensionsMacro( FixedArray, signed char ); +itkNumericTraitsGenericArrayDimensionsMacro( FixedArray, short ); +itkNumericTraitsGenericArrayDimensionsMacro( FixedArray, unsigned short ); +itkNumericTraitsGenericArrayDimensionsMacro( FixedArray, int ); +itkNumericTraitsGenericArrayDimensionsMacro( FixedArray, unsigned int ); +itkNumericTraitsGenericArrayDimensionsMacro( FixedArray, long ); +itkNumericTraitsGenericArrayDimensionsMacro( FixedArray, unsigned long ); +itkNumericTraitsGenericArrayDimensionsMacro( FixedArray, float ); +itkNumericTraitsGenericArrayDimensionsMacro( FixedArray, double ); +itkNumericTraitsGenericArrayDimensionsMacro( FixedArray, long double ); +#ifdef ITK_TYPE_USE_LONG_LONG +itkNumericTraitsGenericArrayDimensionsMacro( FixedArray, long long ); +itkNumericTraitsGenericArrayDimensionsMacro( FixedArray, unsigned long long ); +#endif // ITK_TYPE_USE_LONG_LONG + +#endif // ITK_USE_NUMERIC_TRAITS_PARTIAL_SPECIALIZATION } // end namespace itk -#endif // __itkNumericTraitsFixedArrayPixel_h +#endif // __itkNumericTraitsFixedArrayPixel_h diff --git a/Utilities/ITK/Code/Common/itkNumericTraitsFixedArrayPixel2.cxx b/Utilities/ITK/Code/Common/itkNumericTraitsFixedArrayPixel2.cxx new file mode 100644 index 0000000000000000000000000000000000000000..8f8fb1278872167e71b5d55dd9df5ccc8f90a9d8 --- /dev/null +++ b/Utilities/ITK/Code/Common/itkNumericTraitsFixedArrayPixel2.cxx @@ -0,0 +1,39 @@ +/*========================================================================= + + Program: Insight Segmentation & Registration Toolkit + Module: $RCSfile: itkNumericTraitsFixedArrayPixel2.cxx,v $ + Language: C++ + Date: $Date: 2010-04-10 16:22:29 $ + Version: $Revision: 1.1 $ + + Copyright (c) Insight Software Consortium. All rights reserved. + See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#include "itkNumericTraitsFixedArrayPixel.h" + +namespace itk +{ + +// +// Previous Types can be found in the file +// +// itkNumericTraitsFixedArrayPixel.cxx +// +// This was split in two files in order to help the Sun CC 5.6 compiler to +// manage the size of the compilation unit. +// + +itkStaticNumericTraitsGenericArrayDimensionsMacro( FixedArray, float ); +itkStaticNumericTraitsGenericArrayDimensionsMacro( FixedArray, double ); +itkStaticNumericTraitsGenericArrayDimensionsMacro( FixedArray, long double ); +#ifdef ITK_TYPE_USE_LONG_LONG +itkStaticNumericTraitsGenericArrayDimensionsMacro( FixedArray, long long ); +itkStaticNumericTraitsGenericArrayDimensionsMacro( FixedArray, unsigned long long ); +#endif // ITK_TYPE_USE_LONG_LONG + +} // end namespace itk diff --git a/Utilities/ITK/Code/Common/itkNumericTraitsRGBAPixel.h b/Utilities/ITK/Code/Common/itkNumericTraitsRGBAPixel.h index 5ea94427ac29afc2614478564390c802decb427e..7a0b5bbc473aa966c503a6f3c0de9227813c8f12 100644 --- a/Utilities/ITK/Code/Common/itkNumericTraitsRGBAPixel.h +++ b/Utilities/ITK/Code/Common/itkNumericTraitsRGBAPixel.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkNumericTraitsRGBAPixel.h,v $ Language: C++ - Date: $Date: 2009-07-30 20:51:30 $ - Version: $Revision: 1.7 $ + Date: $Date: 2010-04-09 02:47:24 $ + Version: $Revision: 1.11 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -52,58 +52,40 @@ public: \ \ typedef ElementRealType ScalarRealType; \ \ - static const Self max( const Self & a ) \ + static const Self max( const Self & ) \ { \ - Self b; \ - b.Fill( NumericTraits< T >::max() ); \ - return b; \ + return Self( NumericTraits< T >::max() ); \ } \ - static const Self min( const Self & a ) \ + static const Self min( const Self & ) \ { \ - Self b; \ - b.Fill( NumericTraits< T >::min() ); \ - return b; \ + return Self( NumericTraits< T >::min() ); \ } \ static const Self max() \ { \ - Self b; \ - b.Fill( NumericTraits< T >::max() ); \ - return b; \ + return Self( NumericTraits< T >::max() ); \ } \ static const Self min() \ { \ - Self b; \ - b.Fill( NumericTraits< T >::min() ); \ - return b; \ + return Self( NumericTraits< T >::min() ); \ } \ static const Self NonpositiveMin() \ { \ - return NumericTraits< Self >::min(); \ + return Self ( NumericTraits< ValueType >::NonpositiveMin() ); \ } \ static const Self ZeroValue() \ { \ - Self b; \ - b.Fill( NumericTraits< T >::Zero ); \ - return b; \ + return Self( NumericTraits< T >::Zero ); \ } \ static const Self OneValue() \ { \ - Self b; \ - b.Fill( NumericTraits< T >::One ); \ - return b; \ + return Self( NumericTraits< T >::One ); \ } \ static const Self ITKCommon_EXPORT Zero; \ static const Self ITKCommon_EXPORT One; \ }; -// -// Visual Studio 6.0 is not capable of managing the template implementation -// defined at the end of this file. Therefore we provide an alternative -// primitive implementation based on macros that define explicit -// instantiations. -// -#if defined( _MSC_VER ) && ( _MSC_VER < 1310 ) +#ifndef ITK_USE_NUMERIC_TRAITS_PARTIAL_SPECIALIZATION // These two symbols below are defined empty on purpose #define _TYPENAME_ @@ -130,8 +112,8 @@ itkNumericTraitsRGBAPixelMacro( double ); // NumericTraits from the original RGBAPixel components. This implementation // doesn't require specializations, since it is based on the concept that // -// NumericTraits< RGBAPixle< T > > is defined piecewise by -// RGBAPixle< NumericTraits< T > > +// NumericTraits< RGBAPixel< T > > is defined piecewise by +// RGBAPixel< NumericTraits< T > > // // // By defining the following symbols, the Macro above gets customized to become @@ -145,7 +127,7 @@ itkNumericTraitsRGBAPixelMacro( double ); // itkNumericTraitsRGBAPixelMacro( T ); -#endif +#endif // ITK_USE_NUMERIC_TRAITS_PARTIAL_SPECIALIZATION // // Finally, to avoid contamination of other files with the symbols defined diff --git a/Utilities/ITK/Code/Common/itkNumericTraitsRGBPixel.h b/Utilities/ITK/Code/Common/itkNumericTraitsRGBPixel.h index 59deaf6afe9fd2f11a89dc84b68533f1e71ae9a8..21dbb8160f091baf4dbc6dc75e4cb1e12046f05b 100644 --- a/Utilities/ITK/Code/Common/itkNumericTraitsRGBPixel.h +++ b/Utilities/ITK/Code/Common/itkNumericTraitsRGBPixel.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkNumericTraitsRGBPixel.h,v $ Language: C++ - Date: $Date: 2009-07-30 20:51:30 $ - Version: $Revision: 1.17 $ + Date: $Date: 2010-04-09 02:47:24 $ + Version: $Revision: 1.21 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -52,58 +52,40 @@ public: \ \ typedef ElementRealType ScalarRealType; \ \ - static const Self max( const Self & a ) \ + static const Self max( const Self & ) \ { \ - Self b; \ - b.Fill( NumericTraits< T >::max() ); \ - return b; \ + return Self( NumericTraits< T >::max() ); \ } \ - static const Self min( const Self & a ) \ + static const Self min( const Self & ) \ { \ - Self b; \ - b.Fill( NumericTraits< T >::min() ); \ - return b; \ + return Self( NumericTraits< T >::min() ); \ } \ static const Self max() \ { \ - Self b; \ - b.Fill( NumericTraits< T >::max() ); \ - return b; \ + return Self( NumericTraits< T >::max() ); \ } \ static const Self min() \ { \ - Self b; \ - b.Fill( NumericTraits< T >::min() ); \ - return b; \ + return Self( NumericTraits< T >::min() ); \ } \ static const Self NonpositiveMin() \ { \ - return NumericTraits< Self >::min(); \ + return Self( NumericTraits< ValueType >::NonpositiveMin() ); \ } \ static const Self ZeroValue() \ { \ - Self b; \ - b.Fill( NumericTraits< T >::Zero ); \ - return b; \ + return Self( NumericTraits< T >::Zero ); \ } \ static const Self OneValue() \ { \ - Self b; \ - b.Fill( NumericTraits< T >::One ); \ - return b; \ + return Self( NumericTraits< T >::One ); \ } \ static const Self ITKCommon_EXPORT Zero; \ static const Self ITKCommon_EXPORT One; \ }; -// -// Visual Studio 6.0 is not capable of managing the template implementation -// defined at the end of this file. Therefore we provide an alternative -// primitive implementation based on macros that define explicit -// instantiations. -// -#if defined( _MSC_VER ) && ( _MSC_VER < 1310 ) +#ifndef ITK_USE_NUMERIC_TRAITS_PARTIAL_SPECIALIZATION // These two symbols below are defined empty on purpose #define _TYPENAME_ @@ -145,7 +127,7 @@ itkNumericTraitsRGBPixelMacro( double ); // itkNumericTraitsRGBPixelMacro( T ); -#endif +#endif // ITK_USE_NUMERIC_TRAITS_PARTIAL_SPECIALIZATION // // Finally, to avoid contamination of other files with the symbols defined diff --git a/Utilities/ITK/Code/Common/itkNumericTraitsTensorPixel.cxx b/Utilities/ITK/Code/Common/itkNumericTraitsTensorPixel.cxx index e6ecd47cd9692dc8ec57e99833bd67e89342b689..8d4155bcbd0426505ae6054b9b091458f2905740 100644 --- a/Utilities/ITK/Code/Common/itkNumericTraitsTensorPixel.cxx +++ b/Utilities/ITK/Code/Common/itkNumericTraitsTensorPixel.cxx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkNumericTraitsTensorPixel.cxx,v $ Language: C++ - Date: $Date: 2009-02-06 20:53:13 $ - Version: $Revision: 1.2 $ + Date: $Date: 2010-04-10 16:22:29 $ + Version: $Revision: 1.5 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -18,8 +18,24 @@ namespace itk { -const SymmetricSecondRankTensor<double , 2> - NumericTraits<SymmetricSecondRankTensor<double, 2> >::Zero = - SymmetricSecondRankTensor<double , 2>( NumericTraits<double >::Zero ); + +itkStaticNumericTraitsGenericArrayDimensionsMacro( SymmetricSecondRankTensor, char ); +itkStaticNumericTraitsGenericArrayDimensionsMacro( SymmetricSecondRankTensor, unsigned char ); +itkStaticNumericTraitsGenericArrayDimensionsMacro( SymmetricSecondRankTensor, signed char ); +itkStaticNumericTraitsGenericArrayDimensionsMacro( SymmetricSecondRankTensor, short ); +itkStaticNumericTraitsGenericArrayDimensionsMacro( SymmetricSecondRankTensor, unsigned short ); +itkStaticNumericTraitsGenericArrayDimensionsMacro( SymmetricSecondRankTensor, int ); +itkStaticNumericTraitsGenericArrayDimensionsMacro( SymmetricSecondRankTensor, unsigned int ); +itkStaticNumericTraitsGenericArrayDimensionsMacro( SymmetricSecondRankTensor, long ); +itkStaticNumericTraitsGenericArrayDimensionsMacro( SymmetricSecondRankTensor, unsigned long ); + +// +// Subsequent Types can be found in the file +// +// itkNumericTraitsTensorPixel2.cxx +// +// This was split in two files in order to help the Sun CC 5.6 compiler to +// manage the size of the compilation unit. +// } // end namespace itk diff --git a/Utilities/ITK/Code/Common/itkNumericTraitsTensorPixel.h b/Utilities/ITK/Code/Common/itkNumericTraitsTensorPixel.h index 4adc52eb0a869baef4c879fc4ef5d5cf7def723f..e307cbb8f2a9786d6fc7bb49b56cb86da6b4d0c5 100644 --- a/Utilities/ITK/Code/Common/itkNumericTraitsTensorPixel.h +++ b/Utilities/ITK/Code/Common/itkNumericTraitsTensorPixel.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkNumericTraitsTensorPixel.h,v $ Language: C++ - Date: $Date: 2009-02-06 20:53:13 $ - Version: $Revision: 1.11 $ + Date: $Date: 2010-04-09 21:23:14 $ + Version: $Revision: 1.14 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -17,996 +17,44 @@ #ifndef __itkNumericTraitsTensorPixel_h #define __itkNumericTraitsTensorPixel_h -#include "itkNumericTraits.h" +#include "itkNumericTraitsFixedArrayPixel.h" #include "itkSymmetricSecondRankTensor.h" -#include "itkDiffusionTensor3D.h" // This file is meant to define numeric traits for tensor pixels types in itk namespace itk { -template <> class NumericTraits<SymmetricSecondRankTensor<unsigned char, 1 > > { -public: - typedef unsigned char ValueType; - typedef SymmetricSecondRankTensor<unsigned char, 1> PrintType; - typedef SymmetricSecondRankTensor<unsigned char, 1> AbsType; - typedef SymmetricSecondRankTensor<unsigned short, 1> AccumulateType; - typedef SymmetricSecondRankTensor<double, 1> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<signed char, 1> > { -public: - typedef signed char ValueType; - typedef SymmetricSecondRankTensor<signed char, 1> PrintType; - typedef SymmetricSecondRankTensor<unsigned char, 1> AbsType; - typedef SymmetricSecondRankTensor<short, 1> AccumulateType; - typedef SymmetricSecondRankTensor<double, 1> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<char, 1> > { -public: - typedef char ValueType; - typedef SymmetricSecondRankTensor<char, 1> PrintType; - typedef SymmetricSecondRankTensor<unsigned char, 1> AbsType; - typedef SymmetricSecondRankTensor<short, 1> AccumulateType; - typedef SymmetricSecondRankTensor<double, 1> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<short, 1> > { -public: - typedef short ValueType; - typedef SymmetricSecondRankTensor<short, 1> PrintType; - typedef SymmetricSecondRankTensor<unsigned short, 1> AbsType; - typedef SymmetricSecondRankTensor<int, 1> AccumulateType; - typedef SymmetricSecondRankTensor<double, 1> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<unsigned short, 1> > { -public: - typedef unsigned short ValueType; - typedef SymmetricSecondRankTensor<unsigned short, 1> PrintType; - typedef SymmetricSecondRankTensor<unsigned short, 1> AbsType; - typedef SymmetricSecondRankTensor<unsigned int, 1> AccumulateType; - typedef SymmetricSecondRankTensor<double, 1> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<int, 1> > { -public: - typedef int ValueType; - typedef SymmetricSecondRankTensor<int, 1> PrintType; - typedef SymmetricSecondRankTensor<unsigned int, 1> AbsType; - typedef SymmetricSecondRankTensor<long, 1> AccumulateType; - typedef SymmetricSecondRankTensor<double, 1> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<unsigned int, 1> > { -public: - typedef unsigned int ValueType; - typedef SymmetricSecondRankTensor<unsigned int, 1> PrintType; - typedef SymmetricSecondRankTensor<unsigned int, 1> AbsType; - typedef SymmetricSecondRankTensor<unsigned long, 1> AccumulateType; - typedef SymmetricSecondRankTensor<double, 1> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<long, 1> > { -public: - typedef long ValueType; - typedef SymmetricSecondRankTensor<long, 1> PrintType; - typedef SymmetricSecondRankTensor<unsigned long, 1> AbsType; - typedef SymmetricSecondRankTensor<long, 1> AccumulateType; - typedef SymmetricSecondRankTensor<double, 1> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<unsigned long, 1> > { -public: - typedef unsigned long ValueType; - typedef SymmetricSecondRankTensor<unsigned long, 1> PrintType; - typedef SymmetricSecondRankTensor<unsigned long, 1> AbsType; - typedef SymmetricSecondRankTensor<unsigned long, 1> AccumulateType; - typedef SymmetricSecondRankTensor<double, 1> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<float, 1> > { -public: - typedef float ValueType; - typedef SymmetricSecondRankTensor<float, 1> PrintType; - typedef SymmetricSecondRankTensor<float, 1> AbsType; - typedef SymmetricSecondRankTensor<double, 1> AccumulateType; - typedef SymmetricSecondRankTensor<double, 1> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<double, 1> > { -public: - typedef double ValueType; - typedef SymmetricSecondRankTensor<double, 1> PrintType; - typedef SymmetricSecondRankTensor<double, 1> AbsType; - typedef SymmetricSecondRankTensor<long double, 1> AccumulateType; - typedef SymmetricSecondRankTensor<double, 1> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<long double, 1> > { -public: - typedef long double ValueType; - typedef SymmetricSecondRankTensor<long double, 1> PrintType; - typedef SymmetricSecondRankTensor<long double, 1> AbsType; - typedef SymmetricSecondRankTensor<long double, 1> AccumulateType; - typedef SymmetricSecondRankTensor<long double, 1> RealType; - typedef long double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<unsigned char, 2 > > { -public: - typedef unsigned char ValueType; - typedef SymmetricSecondRankTensor<unsigned char, 2> PrintType; - typedef SymmetricSecondRankTensor<unsigned char, 2> AbsType; - typedef SymmetricSecondRankTensor<unsigned short, 2> AccumulateType; - typedef SymmetricSecondRankTensor<double, 2> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<signed char, 2> > { -public: - typedef signed char ValueType; - typedef SymmetricSecondRankTensor<signed char, 2> PrintType; - typedef SymmetricSecondRankTensor<unsigned char, 2> AbsType; - typedef SymmetricSecondRankTensor<short, 2> AccumulateType; - typedef SymmetricSecondRankTensor<double, 2> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<char, 2> > { -public: - typedef char ValueType; - typedef SymmetricSecondRankTensor<char, 2> PrintType; - typedef SymmetricSecondRankTensor<unsigned char, 2> AbsType; - typedef SymmetricSecondRankTensor<short, 2> AccumulateType; - typedef SymmetricSecondRankTensor<double, 2> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<short, 2> > { -public: - typedef short ValueType; - typedef SymmetricSecondRankTensor<short, 2> PrintType; - typedef SymmetricSecondRankTensor<unsigned short, 2> AbsType; - typedef SymmetricSecondRankTensor<int, 2> AccumulateType; - typedef SymmetricSecondRankTensor<double, 2> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<unsigned short, 2> > { -public: - typedef unsigned short ValueType; - typedef SymmetricSecondRankTensor<unsigned short, 2> PrintType; - typedef SymmetricSecondRankTensor<unsigned short, 2> AbsType; - typedef SymmetricSecondRankTensor<unsigned int, 2> AccumulateType; - typedef SymmetricSecondRankTensor<double, 2> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<int, 2> > { -public: - typedef int ValueType; - typedef SymmetricSecondRankTensor<int, 2> PrintType; - typedef SymmetricSecondRankTensor<unsigned int, 2> AbsType; - typedef SymmetricSecondRankTensor<long, 2> AccumulateType; - typedef SymmetricSecondRankTensor<double, 2> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<unsigned int, 2> > { -public: - typedef unsigned int ValueType; - typedef SymmetricSecondRankTensor<unsigned int, 2> PrintType; - typedef SymmetricSecondRankTensor<unsigned int, 2> AbsType; - typedef SymmetricSecondRankTensor<unsigned long, 2> AccumulateType; - typedef SymmetricSecondRankTensor<double, 2> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<long, 2> > { -public: - typedef long ValueType; - typedef SymmetricSecondRankTensor<long, 2> PrintType; - typedef SymmetricSecondRankTensor<unsigned long, 2> AbsType; - typedef SymmetricSecondRankTensor<long, 2> AccumulateType; - typedef SymmetricSecondRankTensor<double, 2> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<unsigned long, 2> > { -public: - typedef unsigned long ValueType; - typedef SymmetricSecondRankTensor<unsigned long, 2> PrintType; - typedef SymmetricSecondRankTensor<unsigned long, 2> AbsType; - typedef SymmetricSecondRankTensor<unsigned long, 2> AccumulateType; - typedef SymmetricSecondRankTensor<double, 2> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<float, 2> > { -public: - typedef float ValueType; - typedef SymmetricSecondRankTensor<float, 2> PrintType; - typedef SymmetricSecondRankTensor<float, 2> AbsType; - typedef SymmetricSecondRankTensor<double, 2> AccumulateType; - typedef SymmetricSecondRankTensor<double, 2> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<double, 2> > { -public: - typedef double ValueType; - typedef SymmetricSecondRankTensor<double, 2> PrintType; - typedef SymmetricSecondRankTensor<double, 2> AbsType; - typedef SymmetricSecondRankTensor<long double, 2> AccumulateType; - typedef SymmetricSecondRankTensor<double, 2> RealType; - typedef double ScalarRealType; - static const SymmetricSecondRankTensor< double,2 > ITKCommon_EXPORT Zero; - static SymmetricSecondRankTensor<double,2> ZeroValue() { return Zero; } -}; -template <> class NumericTraits<SymmetricSecondRankTensor<long double, 2> > { -public: - typedef long double ValueType; - typedef SymmetricSecondRankTensor<long double, 2> PrintType; - typedef SymmetricSecondRankTensor<long double, 2> AbsType; - typedef SymmetricSecondRankTensor<long double, 2> AccumulateType; - typedef SymmetricSecondRankTensor<long double, 2> RealType; - typedef long double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<unsigned char, 3 > > { -public: - typedef unsigned char ValueType; - typedef SymmetricSecondRankTensor<unsigned char, 3> PrintType; - typedef SymmetricSecondRankTensor<unsigned char, 3> AbsType; - typedef SymmetricSecondRankTensor<unsigned short, 3> AccumulateType; - typedef SymmetricSecondRankTensor<double, 3> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<signed char, 3> > { -public: - typedef signed char ValueType; - typedef SymmetricSecondRankTensor<signed char, 3> PrintType; - typedef SymmetricSecondRankTensor<unsigned char, 3> AbsType; - typedef SymmetricSecondRankTensor<short, 3> AccumulateType; - typedef SymmetricSecondRankTensor<double, 3> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<char, 3> > { -public: - typedef char ValueType; - typedef SymmetricSecondRankTensor<char, 3> PrintType; - typedef SymmetricSecondRankTensor<unsigned char, 3> AbsType; - typedef SymmetricSecondRankTensor<short, 3> AccumulateType; - typedef SymmetricSecondRankTensor<double, 3> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<short, 3> > { -public: - typedef short ValueType; - typedef SymmetricSecondRankTensor<short, 3> PrintType; - typedef SymmetricSecondRankTensor<unsigned short, 3> AbsType; - typedef SymmetricSecondRankTensor<int, 3> AccumulateType; - typedef SymmetricSecondRankTensor<double, 3> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<unsigned short, 3> > { -public: - typedef unsigned short ValueType; - typedef SymmetricSecondRankTensor<unsigned short, 3> PrintType; - typedef SymmetricSecondRankTensor<unsigned short, 3> AbsType; - typedef SymmetricSecondRankTensor<unsigned int, 3> AccumulateType; - typedef SymmetricSecondRankTensor<double, 3> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<int, 3> > { -public: - typedef int ValueType; - typedef SymmetricSecondRankTensor<int, 3> PrintType; - typedef SymmetricSecondRankTensor<unsigned int, 3> AbsType; - typedef SymmetricSecondRankTensor<long, 3> AccumulateType; - typedef SymmetricSecondRankTensor<double, 3> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<unsigned int, 3> > { -public: - typedef unsigned int ValueType; - typedef SymmetricSecondRankTensor<unsigned int, 3> PrintType; - typedef SymmetricSecondRankTensor<unsigned int, 3> AbsType; - typedef SymmetricSecondRankTensor<unsigned long, 3> AccumulateType; - typedef SymmetricSecondRankTensor<double, 3> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<long, 3> > { -public: - typedef long ValueType; - typedef SymmetricSecondRankTensor<long, 3> PrintType; - typedef SymmetricSecondRankTensor<unsigned long, 3> AbsType; - typedef SymmetricSecondRankTensor<long, 3> AccumulateType; - typedef SymmetricSecondRankTensor<double, 3> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<unsigned long, 3> > { -public: - typedef unsigned long ValueType; - typedef SymmetricSecondRankTensor<unsigned long, 3> PrintType; - typedef SymmetricSecondRankTensor<unsigned long, 3> AbsType; - typedef SymmetricSecondRankTensor<unsigned long, 3> AccumulateType; - typedef SymmetricSecondRankTensor<double, 3> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<float, 3> > { -public: - typedef float ValueType; - typedef SymmetricSecondRankTensor<float, 3> PrintType; - typedef SymmetricSecondRankTensor<float, 3> AbsType; - typedef SymmetricSecondRankTensor<double, 3> AccumulateType; - typedef SymmetricSecondRankTensor<double, 3> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<double, 3> > { -public: - typedef double ValueType; - typedef SymmetricSecondRankTensor<double, 3> PrintType; - typedef SymmetricSecondRankTensor<double, 3> AbsType; - typedef SymmetricSecondRankTensor<long double, 3> AccumulateType; - typedef SymmetricSecondRankTensor<double, 3> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<long double, 3> > { -public: - typedef long double ValueType; - typedef SymmetricSecondRankTensor<long double, 3> PrintType; - typedef SymmetricSecondRankTensor<long double, 3> AbsType; - typedef SymmetricSecondRankTensor<long double, 3> AccumulateType; - typedef SymmetricSecondRankTensor<long double, 3> RealType; - typedef long double ScalarRealType; -}; +// +// Instantiate the macros to declare the NumericTraits for the +// SymmetricSecondRankTensor types. +// +#ifdef ITK_USE_NUMERIC_TRAITS_PARTIAL_SPECIALIZATION -template <> class NumericTraits<SymmetricSecondRankTensor<unsigned char, 4 > > { -public: - typedef unsigned char ValueType; - typedef SymmetricSecondRankTensor<unsigned char, 4> PrintType; - typedef SymmetricSecondRankTensor<unsigned char, 4> AbsType; - typedef SymmetricSecondRankTensor<unsigned short, 4> AccumulateType; - typedef SymmetricSecondRankTensor<double, 4> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<signed char, 4> > { -public: - typedef signed char ValueType; - typedef SymmetricSecondRankTensor<signed char, 4> PrintType; - typedef SymmetricSecondRankTensor<unsigned char, 4> AbsType; - typedef SymmetricSecondRankTensor<short, 4> AccumulateType; - typedef SymmetricSecondRankTensor<double, 4> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<char, 4> > { -public: - typedef char ValueType; - typedef SymmetricSecondRankTensor<char, 4> PrintType; - typedef SymmetricSecondRankTensor<unsigned char, 4> AbsType; - typedef SymmetricSecondRankTensor<short, 4> AccumulateType; - typedef SymmetricSecondRankTensor<double, 4> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<short, 4> > { -public: - typedef short ValueType; - typedef SymmetricSecondRankTensor<short, 4> PrintType; - typedef SymmetricSecondRankTensor<unsigned short, 4> AbsType; - typedef SymmetricSecondRankTensor<int, 4> AccumulateType; - typedef SymmetricSecondRankTensor<double, 4> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<unsigned short, 4> > { -public: - typedef unsigned short ValueType; - typedef SymmetricSecondRankTensor<unsigned short, 4> PrintType; - typedef SymmetricSecondRankTensor<unsigned short, 4> AbsType; - typedef SymmetricSecondRankTensor<unsigned int, 4> AccumulateType; - typedef SymmetricSecondRankTensor<double, 4> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<int, 4> > { -public: - typedef int ValueType; - typedef SymmetricSecondRankTensor<int, 4> PrintType; - typedef SymmetricSecondRankTensor<unsigned int, 4> AbsType; - typedef SymmetricSecondRankTensor<long, 4> AccumulateType; - typedef SymmetricSecondRankTensor<double, 4> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<unsigned int, 4> > { -public: - typedef unsigned int ValueType; - typedef SymmetricSecondRankTensor<unsigned int, 4> PrintType; - typedef SymmetricSecondRankTensor<unsigned int, 4> AbsType; - typedef SymmetricSecondRankTensor<unsigned long, 4> AccumulateType; - typedef SymmetricSecondRankTensor<double, 4> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<long, 4> > { -public: - typedef long ValueType; - typedef SymmetricSecondRankTensor<long, 4> PrintType; - typedef SymmetricSecondRankTensor<unsigned long, 4> AbsType; - typedef SymmetricSecondRankTensor<long, 4> AccumulateType; - typedef SymmetricSecondRankTensor<double, 4> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<unsigned long, 4> > { -public: - typedef unsigned long ValueType; - typedef SymmetricSecondRankTensor<unsigned long, 4> PrintType; - typedef SymmetricSecondRankTensor<unsigned long, 4> AbsType; - typedef SymmetricSecondRankTensor<unsigned long, 4> AccumulateType; - typedef SymmetricSecondRankTensor<double, 4> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<float, 4> > { -public: - typedef float ValueType; - typedef SymmetricSecondRankTensor<float, 4> PrintType; - typedef SymmetricSecondRankTensor<float, 4> AbsType; - typedef SymmetricSecondRankTensor<double, 4> AccumulateType; - typedef SymmetricSecondRankTensor<double, 4> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<double, 4> > { -public: - typedef double ValueType; - typedef SymmetricSecondRankTensor<double, 4> PrintType; - typedef SymmetricSecondRankTensor<double, 4> AbsType; - typedef SymmetricSecondRankTensor<long double, 4> AccumulateType; - typedef SymmetricSecondRankTensor<double, 4> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<long double, 4> > { -public: - typedef long double ValueType; - typedef SymmetricSecondRankTensor<long double, 4> PrintType; - typedef SymmetricSecondRankTensor<long double, 4> AbsType; - typedef SymmetricSecondRankTensor<long double, 4> AccumulateType; - typedef SymmetricSecondRankTensor<long double, 4> RealType; - typedef long double ScalarRealType; -}; +itkNumericTraitsGenericArrayScalarsDimensionsMacro( SymmetricSecondRankTensor ); -template <> class NumericTraits<SymmetricSecondRankTensor<unsigned char, 5 > > { -public: - typedef unsigned char ValueType; - typedef SymmetricSecondRankTensor<unsigned char, 5> PrintType; - typedef SymmetricSecondRankTensor<unsigned char, 5> AbsType; - typedef SymmetricSecondRankTensor<unsigned short, 5> AccumulateType; - typedef SymmetricSecondRankTensor<double, 5> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<signed char, 5> > { -public: - typedef signed char ValueType; - typedef SymmetricSecondRankTensor<signed char, 5> PrintType; - typedef SymmetricSecondRankTensor<unsigned char, 5> AbsType; - typedef SymmetricSecondRankTensor<short, 5> AccumulateType; - typedef SymmetricSecondRankTensor<double, 5> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<char, 5> > { -public: - typedef char ValueType; - typedef SymmetricSecondRankTensor<char, 5> PrintType; - typedef SymmetricSecondRankTensor<unsigned char, 5> AbsType; - typedef SymmetricSecondRankTensor<short, 5> AccumulateType; - typedef SymmetricSecondRankTensor<double, 5> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<short, 5> > { -public: - typedef short ValueType; - typedef SymmetricSecondRankTensor<short, 5> PrintType; - typedef SymmetricSecondRankTensor<unsigned short, 5> AbsType; - typedef SymmetricSecondRankTensor<int, 5> AccumulateType; - typedef SymmetricSecondRankTensor<double, 5> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<unsigned short, 5> > { -public: - typedef unsigned short ValueType; - typedef SymmetricSecondRankTensor<unsigned short, 5> PrintType; - typedef SymmetricSecondRankTensor<unsigned short, 5> AbsType; - typedef SymmetricSecondRankTensor<unsigned int, 5> AccumulateType; - typedef SymmetricSecondRankTensor<double, 5> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<int, 5> > { -public: - typedef int ValueType; - typedef SymmetricSecondRankTensor<int, 5> PrintType; - typedef SymmetricSecondRankTensor<unsigned int, 5> AbsType; - typedef SymmetricSecondRankTensor<long, 5> AccumulateType; - typedef SymmetricSecondRankTensor<double, 5> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<unsigned int, 5> > { -public: - typedef unsigned int ValueType; - typedef SymmetricSecondRankTensor<unsigned int, 5> PrintType; - typedef SymmetricSecondRankTensor<unsigned int, 5> AbsType; - typedef SymmetricSecondRankTensor<unsigned long, 5> AccumulateType; - typedef SymmetricSecondRankTensor<double, 5> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<long, 5> > { -public: - typedef long ValueType; - typedef SymmetricSecondRankTensor<long, 5> PrintType; - typedef SymmetricSecondRankTensor<unsigned long, 5> AbsType; - typedef SymmetricSecondRankTensor<long, 5> AccumulateType; - typedef SymmetricSecondRankTensor<double, 5> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<unsigned long, 5> > { -public: - typedef unsigned long ValueType; - typedef SymmetricSecondRankTensor<unsigned long, 5> PrintType; - typedef SymmetricSecondRankTensor<unsigned long, 5> AbsType; - typedef SymmetricSecondRankTensor<unsigned long, 5> AccumulateType; - typedef SymmetricSecondRankTensor<double, 5> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<float, 5> > { -public: - typedef float ValueType; - typedef SymmetricSecondRankTensor<float, 5> PrintType; - typedef SymmetricSecondRankTensor<float, 5> AbsType; - typedef SymmetricSecondRankTensor<double, 5> AccumulateType; - typedef SymmetricSecondRankTensor<double, 5> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<double, 5> > { -public: - typedef double ValueType; - typedef SymmetricSecondRankTensor<double, 5> PrintType; - typedef SymmetricSecondRankTensor<double, 5> AbsType; - typedef SymmetricSecondRankTensor<long double, 5> AccumulateType; - typedef SymmetricSecondRankTensor<double, 5> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<long double, 5> > { -public: - typedef long double ValueType; - typedef SymmetricSecondRankTensor<long double, 5> PrintType; - typedef SymmetricSecondRankTensor<long double, 5> AbsType; - typedef SymmetricSecondRankTensor<long double, 5> AccumulateType; - typedef SymmetricSecondRankTensor<long double, 5> RealType; - typedef long double ScalarRealType; -}; +#else // ITK_USE_NUMERIC_TRAITS_PARTIAL_SPECIALIZATION -template <> class NumericTraits<SymmetricSecondRankTensor<unsigned char, 6 > > { -public: - typedef unsigned char ValueType; - typedef SymmetricSecondRankTensor<unsigned char, 6> PrintType; - typedef SymmetricSecondRankTensor<unsigned char, 6> AbsType; - typedef SymmetricSecondRankTensor<unsigned short, 6> AccumulateType; - typedef SymmetricSecondRankTensor<double, 6> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<signed char, 6> > { -public: - typedef signed char ValueType; - typedef SymmetricSecondRankTensor<signed char, 6> PrintType; - typedef SymmetricSecondRankTensor<unsigned char, 6> AbsType; - typedef SymmetricSecondRankTensor<short, 6> AccumulateType; - typedef SymmetricSecondRankTensor<double, 6> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<char, 6> > { -public: - typedef char ValueType; - typedef SymmetricSecondRankTensor<char, 6> PrintType; - typedef SymmetricSecondRankTensor<unsigned char, 6> AbsType; - typedef SymmetricSecondRankTensor<short, 6> AccumulateType; - typedef SymmetricSecondRankTensor<double, 6> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<short, 6> > { -public: - typedef short ValueType; - typedef SymmetricSecondRankTensor<short, 6> PrintType; - typedef SymmetricSecondRankTensor<unsigned short, 6> AbsType; - typedef SymmetricSecondRankTensor<int, 6> AccumulateType; - typedef SymmetricSecondRankTensor<double, 6> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<unsigned short, 6> > { -public: - typedef unsigned short ValueType; - typedef SymmetricSecondRankTensor<unsigned short, 6> PrintType; - typedef SymmetricSecondRankTensor<unsigned short, 6> AbsType; - typedef SymmetricSecondRankTensor<unsigned int, 6> AccumulateType; - typedef SymmetricSecondRankTensor<double, 6> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<int, 6> > { -public: - typedef int ValueType; - typedef SymmetricSecondRankTensor<int, 6> PrintType; - typedef SymmetricSecondRankTensor<unsigned int, 6> AbsType; - typedef SymmetricSecondRankTensor<long, 6> AccumulateType; - typedef SymmetricSecondRankTensor<double, 6> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<unsigned int, 6> > { -public: - typedef unsigned int ValueType; - typedef SymmetricSecondRankTensor<unsigned int, 6> PrintType; - typedef SymmetricSecondRankTensor<unsigned int, 6> AbsType; - typedef SymmetricSecondRankTensor<unsigned long, 6> AccumulateType; - typedef SymmetricSecondRankTensor<double, 6> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<long, 6> > { -public: - typedef long ValueType; - typedef SymmetricSecondRankTensor<long, 6> PrintType; - typedef SymmetricSecondRankTensor<unsigned long, 6> AbsType; - typedef SymmetricSecondRankTensor<long, 6> AccumulateType; - typedef SymmetricSecondRankTensor<double, 6> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<unsigned long, 6> > { -public: - typedef unsigned long ValueType; - typedef SymmetricSecondRankTensor<unsigned long, 6> PrintType; - typedef SymmetricSecondRankTensor<unsigned long, 6> AbsType; - typedef SymmetricSecondRankTensor<unsigned long, 6> AccumulateType; - typedef SymmetricSecondRankTensor<double, 6> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<float, 6> > { -public: - typedef float ValueType; - typedef SymmetricSecondRankTensor<float, 6> PrintType; - typedef SymmetricSecondRankTensor<float, 6> AbsType; - typedef SymmetricSecondRankTensor<double, 6> AccumulateType; - typedef SymmetricSecondRankTensor<double, 6> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<double, 6> > { -public: - typedef double ValueType; - typedef SymmetricSecondRankTensor<double, 6> PrintType; - typedef SymmetricSecondRankTensor<double, 6> AbsType; - typedef SymmetricSecondRankTensor<long double, 6> AccumulateType; - typedef SymmetricSecondRankTensor<double, 6> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<long double, 6> > { -public: - typedef long double ValueType; - typedef SymmetricSecondRankTensor<long double, 6> PrintType; - typedef SymmetricSecondRankTensor<long double, 6> AbsType; - typedef SymmetricSecondRankTensor<long double, 6> AccumulateType; - typedef SymmetricSecondRankTensor<long double, 6> RealType; - typedef long double ScalarRealType; -}; +itkNumericTraitsGenericArrayDimensionsMacro( SymmetricSecondRankTensor, char ); +itkNumericTraitsGenericArrayDimensionsMacro( SymmetricSecondRankTensor, unsigned char ); +itkNumericTraitsGenericArrayDimensionsMacro( SymmetricSecondRankTensor, signed char ); +itkNumericTraitsGenericArrayDimensionsMacro( SymmetricSecondRankTensor, short ); +itkNumericTraitsGenericArrayDimensionsMacro( SymmetricSecondRankTensor, unsigned short ); +itkNumericTraitsGenericArrayDimensionsMacro( SymmetricSecondRankTensor, int ); +itkNumericTraitsGenericArrayDimensionsMacro( SymmetricSecondRankTensor, unsigned int ); +itkNumericTraitsGenericArrayDimensionsMacro( SymmetricSecondRankTensor, long ); +itkNumericTraitsGenericArrayDimensionsMacro( SymmetricSecondRankTensor, unsigned long ); +itkNumericTraitsGenericArrayDimensionsMacro( SymmetricSecondRankTensor, float ); +itkNumericTraitsGenericArrayDimensionsMacro( SymmetricSecondRankTensor, double ); +itkNumericTraitsGenericArrayDimensionsMacro( SymmetricSecondRankTensor, long double ); +#ifdef ITK_TYPE_USE_LONG_LONG +itkNumericTraitsGenericArrayDimensionsMacro( SymmetricSecondRankTensor, long long ); +itkNumericTraitsGenericArrayDimensionsMacro( SymmetricSecondRankTensor, unsigned long long ); +#endif // ITK_TYPE_USE_LONG_LONG -template <> class NumericTraits<SymmetricSecondRankTensor<unsigned char, 7 > > { -public: - typedef unsigned char ValueType; - typedef SymmetricSecondRankTensor<unsigned char, 7> PrintType; - typedef SymmetricSecondRankTensor<unsigned char, 7> AbsType; - typedef SymmetricSecondRankTensor<unsigned short, 7> AccumulateType; - typedef SymmetricSecondRankTensor<double, 7> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<signed char, 7> > { -public: - typedef signed char ValueType; - typedef SymmetricSecondRankTensor<signed char, 7> PrintType; - typedef SymmetricSecondRankTensor<unsigned char, 7> AbsType; - typedef SymmetricSecondRankTensor<short, 7> AccumulateType; - typedef SymmetricSecondRankTensor<double, 7> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<char, 7> > { -public: - typedef char ValueType; - typedef SymmetricSecondRankTensor<char, 7> PrintType; - typedef SymmetricSecondRankTensor<unsigned char, 7> AbsType; - typedef SymmetricSecondRankTensor<short, 7> AccumulateType; - typedef SymmetricSecondRankTensor<double, 7> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<short, 7> > { -public: - typedef short ValueType; - typedef SymmetricSecondRankTensor<short, 7> PrintType; - typedef SymmetricSecondRankTensor<unsigned short, 7> AbsType; - typedef SymmetricSecondRankTensor<int, 7> AccumulateType; - typedef SymmetricSecondRankTensor<double, 7> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<unsigned short, 7> > { -public: - typedef unsigned short ValueType; - typedef SymmetricSecondRankTensor<unsigned short, 7> PrintType; - typedef SymmetricSecondRankTensor<unsigned short, 7> AbsType; - typedef SymmetricSecondRankTensor<unsigned int, 7> AccumulateType; - typedef SymmetricSecondRankTensor<double, 7> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<int, 7> > { -public: - typedef int ValueType; - typedef SymmetricSecondRankTensor<int, 7> PrintType; - typedef SymmetricSecondRankTensor<unsigned int, 7> AbsType; - typedef SymmetricSecondRankTensor<long, 7> AccumulateType; - typedef SymmetricSecondRankTensor<double, 7> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<unsigned int, 7> > { -public: - typedef unsigned int ValueType; - typedef SymmetricSecondRankTensor<unsigned int, 7> PrintType; - typedef SymmetricSecondRankTensor<unsigned int, 7> AbsType; - typedef SymmetricSecondRankTensor<unsigned long, 7> AccumulateType; - typedef SymmetricSecondRankTensor<double, 7> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<long, 7> > { -public: - typedef long ValueType; - typedef SymmetricSecondRankTensor<long, 7> PrintType; - typedef SymmetricSecondRankTensor<unsigned long, 7> AbsType; - typedef SymmetricSecondRankTensor<long, 7> AccumulateType; - typedef SymmetricSecondRankTensor<double, 7> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<unsigned long, 7> > { -public: - typedef unsigned long ValueType; - typedef SymmetricSecondRankTensor<unsigned long, 7> PrintType; - typedef SymmetricSecondRankTensor<unsigned long, 7> AbsType; - typedef SymmetricSecondRankTensor<unsigned long, 7> AccumulateType; - typedef SymmetricSecondRankTensor<double, 7> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<float, 7> > { -public: - typedef float ValueType; - typedef SymmetricSecondRankTensor<float, 7> PrintType; - typedef SymmetricSecondRankTensor<float, 7> AbsType; - typedef SymmetricSecondRankTensor<double, 7> AccumulateType; - typedef SymmetricSecondRankTensor<double, 7> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<double, 7> > { -public: - typedef double ValueType; - typedef SymmetricSecondRankTensor<double, 7> PrintType; - typedef SymmetricSecondRankTensor<double, 7> AbsType; - typedef SymmetricSecondRankTensor<long double, 7> AccumulateType; - typedef SymmetricSecondRankTensor<double, 7> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<long double, 7> > { -public: - typedef long double ValueType; - typedef SymmetricSecondRankTensor<long double, 7> PrintType; - typedef SymmetricSecondRankTensor<long double, 7> AbsType; - typedef SymmetricSecondRankTensor<long double, 7> AccumulateType; - typedef SymmetricSecondRankTensor<long double, 7> RealType; - typedef long double ScalarRealType; -}; +#endif // ITK_USE_NUMERIC_TRAITS_PARTIAL_SPECIALIZATION -template <> class NumericTraits<SymmetricSecondRankTensor<unsigned char, 8 > > { -public: - typedef unsigned char ValueType; - typedef SymmetricSecondRankTensor<unsigned char, 8> PrintType; - typedef SymmetricSecondRankTensor<unsigned char, 8> AbsType; - typedef SymmetricSecondRankTensor<unsigned short, 8> AccumulateType; - typedef SymmetricSecondRankTensor<double, 8> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<signed char, 8> > { -public: - typedef signed char ValueType; - typedef SymmetricSecondRankTensor<signed char, 8> PrintType; - typedef SymmetricSecondRankTensor<unsigned char, 8> AbsType; - typedef SymmetricSecondRankTensor<short, 8> AccumulateType; - typedef SymmetricSecondRankTensor<double, 8> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<char, 8> > { -public: - typedef char ValueType; - typedef SymmetricSecondRankTensor<char, 8> PrintType; - typedef SymmetricSecondRankTensor<unsigned char, 8> AbsType; - typedef SymmetricSecondRankTensor<short, 8> AccumulateType; - typedef SymmetricSecondRankTensor<double, 8> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<short, 8> > { -public: - typedef short ValueType; - typedef SymmetricSecondRankTensor<short, 8> PrintType; - typedef SymmetricSecondRankTensor<unsigned short, 8> AbsType; - typedef SymmetricSecondRankTensor<int, 8> AccumulateType; - typedef SymmetricSecondRankTensor<double, 8> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<unsigned short, 8> > { -public: - typedef unsigned short ValueType; - typedef SymmetricSecondRankTensor<unsigned short, 8> PrintType; - typedef SymmetricSecondRankTensor<unsigned short, 8> AbsType; - typedef SymmetricSecondRankTensor<unsigned int, 8> AccumulateType; - typedef SymmetricSecondRankTensor<double, 8> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<int, 8> > { -public: - typedef int ValueType; - typedef SymmetricSecondRankTensor<int, 8> PrintType; - typedef SymmetricSecondRankTensor<unsigned int, 8> AbsType; - typedef SymmetricSecondRankTensor<long, 8> AccumulateType; - typedef SymmetricSecondRankTensor<double, 8> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<unsigned int, 8> > { -public: - typedef unsigned int ValueType; - typedef SymmetricSecondRankTensor<unsigned int, 8> PrintType; - typedef SymmetricSecondRankTensor<unsigned int, 8> AbsType; - typedef SymmetricSecondRankTensor<unsigned long, 8> AccumulateType; - typedef SymmetricSecondRankTensor<double, 8> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<long, 8> > { -public: - typedef long ValueType; - typedef SymmetricSecondRankTensor<long, 8> PrintType; - typedef SymmetricSecondRankTensor<unsigned long, 8> AbsType; - typedef SymmetricSecondRankTensor<long, 8> AccumulateType; - typedef SymmetricSecondRankTensor<double, 8> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<unsigned long, 8> > { -public: - typedef unsigned long ValueType; - typedef SymmetricSecondRankTensor<unsigned long, 8> PrintType; - typedef SymmetricSecondRankTensor<unsigned long, 8> AbsType; - typedef SymmetricSecondRankTensor<unsigned long, 8> AccumulateType; - typedef SymmetricSecondRankTensor<double, 8> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<float, 8> > { -public: - typedef float ValueType; - typedef SymmetricSecondRankTensor<float, 8> PrintType; - typedef SymmetricSecondRankTensor<float, 8> AbsType; - typedef SymmetricSecondRankTensor<double, 8> AccumulateType; - typedef SymmetricSecondRankTensor<double, 8> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<double, 8> > { -public: - typedef double ValueType; - typedef SymmetricSecondRankTensor<double, 8> PrintType; - typedef SymmetricSecondRankTensor<double, 8> AbsType; - typedef SymmetricSecondRankTensor<long double, 8> AccumulateType; - typedef SymmetricSecondRankTensor<double, 8> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<long double, 8> > { -public: - typedef long double ValueType; - typedef SymmetricSecondRankTensor<long double, 8> PrintType; - typedef SymmetricSecondRankTensor<long double, 8> AbsType; - typedef SymmetricSecondRankTensor<long double, 8> AccumulateType; - typedef SymmetricSecondRankTensor<long double, 8> RealType; - typedef long double ScalarRealType; -}; - -template <> class NumericTraits<SymmetricSecondRankTensor<unsigned char, 9 > > { -public: - typedef unsigned char ValueType; - typedef SymmetricSecondRankTensor<unsigned char, 9> PrintType; - typedef SymmetricSecondRankTensor<unsigned char, 9> AbsType; - typedef SymmetricSecondRankTensor<unsigned short, 9> AccumulateType; - typedef SymmetricSecondRankTensor<double, 9> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<signed char, 9> > { -public: - typedef signed char ValueType; - typedef SymmetricSecondRankTensor<signed char, 9> PrintType; - typedef SymmetricSecondRankTensor<unsigned char, 9> AbsType; - typedef SymmetricSecondRankTensor<short, 9> AccumulateType; - typedef SymmetricSecondRankTensor<double, 9> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<char, 9> > { -public: - typedef char ValueType; - typedef SymmetricSecondRankTensor<char, 9> PrintType; - typedef SymmetricSecondRankTensor<unsigned char, 9> AbsType; - typedef SymmetricSecondRankTensor<short, 9> AccumulateType; - typedef SymmetricSecondRankTensor<double, 9> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<short, 9> > { -public: - typedef short ValueType; - typedef SymmetricSecondRankTensor<short, 9> PrintType; - typedef SymmetricSecondRankTensor<unsigned short, 9> AbsType; - typedef SymmetricSecondRankTensor<int, 9> AccumulateType; - typedef SymmetricSecondRankTensor<double, 9> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<unsigned short, 9> > { -public: - typedef unsigned short ValueType; - typedef SymmetricSecondRankTensor<unsigned short, 9> PrintType; - typedef SymmetricSecondRankTensor<unsigned short, 9> AbsType; - typedef SymmetricSecondRankTensor<unsigned int, 9> AccumulateType; - typedef SymmetricSecondRankTensor<double, 9> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<int, 9> > { -public: - typedef int ValueType; - typedef SymmetricSecondRankTensor<int, 9> PrintType; - typedef SymmetricSecondRankTensor<unsigned int, 9> AbsType; - typedef SymmetricSecondRankTensor<long, 9> AccumulateType; - typedef SymmetricSecondRankTensor<double, 9> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<unsigned int, 9> > { -public: - typedef unsigned int ValueType; - typedef SymmetricSecondRankTensor<unsigned int, 9> PrintType; - typedef SymmetricSecondRankTensor<unsigned int, 9> AbsType; - typedef SymmetricSecondRankTensor<unsigned long, 9> AccumulateType; - typedef SymmetricSecondRankTensor<double, 9> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<long, 9> > { -public: - typedef long ValueType; - typedef SymmetricSecondRankTensor<long, 9> PrintType; - typedef SymmetricSecondRankTensor<unsigned long, 9> AbsType; - typedef SymmetricSecondRankTensor<long, 9> AccumulateType; - typedef SymmetricSecondRankTensor<double, 9> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<unsigned long, 9> > { -public: - typedef unsigned long ValueType; - typedef SymmetricSecondRankTensor<unsigned long, 9> PrintType; - typedef SymmetricSecondRankTensor<unsigned long, 9> AbsType; - typedef SymmetricSecondRankTensor<unsigned long, 9> AccumulateType; - typedef SymmetricSecondRankTensor<double, 9> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<float, 9> > { -public: - typedef float ValueType; - typedef SymmetricSecondRankTensor<float, 9> PrintType; - typedef SymmetricSecondRankTensor<float, 9> AbsType; - typedef SymmetricSecondRankTensor<double, 9> AccumulateType; - typedef SymmetricSecondRankTensor<double, 9> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<double, 9> > { -public: - typedef double ValueType; - typedef SymmetricSecondRankTensor<double, 9> PrintType; - typedef SymmetricSecondRankTensor<double, 9> AbsType; - typedef SymmetricSecondRankTensor<long double, 9> AccumulateType; - typedef SymmetricSecondRankTensor<double, 9> RealType; - typedef double ScalarRealType; -}; -template <> class NumericTraits<SymmetricSecondRankTensor<long double, 9> > { -public: - typedef long double ValueType; - typedef SymmetricSecondRankTensor<long double, 9> PrintType; - typedef SymmetricSecondRankTensor<long double, 9> AbsType; - typedef SymmetricSecondRankTensor<long double, 9> AccumulateType; - typedef SymmetricSecondRankTensor<long double, 9> RealType; - typedef long double ScalarRealType; -}; } // end namespace itk #endif // __itkNumericTraitsTensorPixel_h diff --git a/Utilities/ITK/Code/Common/itkNumericTraitsTensorPixel2.cxx b/Utilities/ITK/Code/Common/itkNumericTraitsTensorPixel2.cxx new file mode 100644 index 0000000000000000000000000000000000000000..41ed4e55daddcf9a039c1f4d96cb9c92c3c57e62 --- /dev/null +++ b/Utilities/ITK/Code/Common/itkNumericTraitsTensorPixel2.cxx @@ -0,0 +1,39 @@ +/*========================================================================= + + Program: Insight Segmentation & Registration Toolkit + Module: $RCSfile: itkNumericTraitsTensorPixel2.cxx,v $ + Language: C++ + Date: $Date: 2010-04-10 16:22:25 $ + Version: $Revision: 1.1 $ + + Copyright (c) Insight Software Consortium. All rights reserved. + See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#include "itkNumericTraitsTensorPixel.h" + +namespace itk +{ + +// +// Previous Types can be found in the file +// +// itkNumericTraitsFixedArrayPixel.cxx +// +// This was split in two files in order to help the Sun CC 5.6 compiler to +// manage the size of the compilation unit. +// + +itkStaticNumericTraitsGenericArrayDimensionsMacro( SymmetricSecondRankTensor, float ); +itkStaticNumericTraitsGenericArrayDimensionsMacro( SymmetricSecondRankTensor, double ); +itkStaticNumericTraitsGenericArrayDimensionsMacro( SymmetricSecondRankTensor, long double ); +#ifdef ITK_TYPE_USE_LONG_LONG +itkStaticNumericTraitsGenericArrayDimensionsMacro( SymmetricSecondRankTensor, long long ); +itkStaticNumericTraitsGenericArrayDimensionsMacro( SymmetricSecondRankTensor, unsigned long long ); +#endif // ITK_TYPE_USE_LONG_LONG + +} // end namespace itk diff --git a/Utilities/ITK/Code/Common/itkNumericTraitsVariableLengthVectorPixel.h b/Utilities/ITK/Code/Common/itkNumericTraitsVariableLengthVectorPixel.h index a4168b04b4864a65fb4581e5426a75ab05f2506e..fead1308a0974346f77134b7c559e0d652b1d91c 100644 --- a/Utilities/ITK/Code/Common/itkNumericTraitsVariableLengthVectorPixel.h +++ b/Utilities/ITK/Code/Common/itkNumericTraitsVariableLengthVectorPixel.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkNumericTraitsVariableLengthVectorPixel.h,v $ Language: C++ - Date: $Date: 2009-07-30 20:51:30 $ - Version: $Revision: 1.7 $ + Date: $Date: 2009-12-01 16:53:10 $ + Version: $Revision: 1.8 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -91,13 +91,7 @@ public: \ }; -// -// Visual Studio 6.0 is not capable of managing the template implementation -// defined at the end of this file. Therefore we provide an alternative -// primitive implementation based on macros that define explicit -// instantiations. -// -#if defined( _MSC_VER ) && ( _MSC_VER < 1310 ) +#ifndef ITK_USE_NUMERIC_TRAITS_PARTIAL_SPECIALIZATION // These two symbols below are defined empty on purpose #define _TYPENAME_ @@ -140,7 +134,7 @@ itkNumericTraitsVariableLengthVectorPixelMacro( double ); // itkNumericTraitsVariableLengthVectorPixelMacro( T ); -#endif +#endif // ITK_USE_NUMERIC_TRAITS_PARTIAL_SPECIALIZATION // // Finally, to avoid contamination of other files with the symbols defined diff --git a/Utilities/ITK/Code/Common/itkNumericTraitsVectorPixel.cxx b/Utilities/ITK/Code/Common/itkNumericTraitsVectorPixel.cxx index f42476cc2cf0e2f329cbe0c1c8ae1a49e25a19e4..a3682ccaeb8195af1565599ec23b3f03d5267c60 100644 --- a/Utilities/ITK/Code/Common/itkNumericTraitsVectorPixel.cxx +++ b/Utilities/ITK/Code/Common/itkNumericTraitsVectorPixel.cxx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkNumericTraitsVectorPixel.cxx,v $ Language: C++ - Date: $Date: 2008-07-07 22:57:43 $ - Version: $Revision: 1.6 $ + Date: $Date: 2009-12-01 16:53:08 $ + Version: $Revision: 1.8 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -19,43 +19,21 @@ namespace itk { -// -// Helper macro for defining the traits of the Vector type for a given component type and dimension -// -#define VECTORSTATICTRAITSMACRO( T, N ) \ -const Vector<T,N> NumericTraits<Vector<T,N> >::Zero = Vector<T,N>( NumericTraits<T>::Zero ); \ -const Vector<T,N> NumericTraits<Vector<T,N> >::One = Vector<T,N>( NumericTraits<T>::One ); \ -Vector<T,N> NumericTraits<Vector<T,N> >::ZeroValue() { return NumericTraits<Vector<T,N> >::Zero; } \ -Vector<T,N> NumericTraits<Vector<T,N> >::OneValue() { return NumericTraits<Vector<T,N> >::One; } - -// -// Helper macro for defining the traits of Vector<T,k> for k in [1:9] -// -#define VECTORSTATICTRAITSMACROFORONETYPE(T) \ -VECTORSTATICTRAITSMACRO(T,1 ); \ -VECTORSTATICTRAITSMACRO(T,2 ); \ -VECTORSTATICTRAITSMACRO(T,3 ); \ -VECTORSTATICTRAITSMACRO(T,4 ); \ -VECTORSTATICTRAITSMACRO(T,5 ); \ -VECTORSTATICTRAITSMACRO(T,6 ); \ -VECTORSTATICTRAITSMACRO(T,7 ); \ -VECTORSTATICTRAITSMACRO(T,8 ); \ -VECTORSTATICTRAITSMACRO(T,9 ); - -// -// Calls to macros for defining the traits of Vector for different component types -// -VECTORSTATICTRAITSMACROFORONETYPE( unsigned char ); -VECTORSTATICTRAITSMACROFORONETYPE( signed char ); -VECTORSTATICTRAITSMACROFORONETYPE( char ); -VECTORSTATICTRAITSMACROFORONETYPE( short ); -VECTORSTATICTRAITSMACROFORONETYPE( unsigned short ); -VECTORSTATICTRAITSMACROFORONETYPE( int ); -VECTORSTATICTRAITSMACROFORONETYPE( unsigned int ); -VECTORSTATICTRAITSMACROFORONETYPE( long ); -VECTORSTATICTRAITSMACROFORONETYPE( unsigned long ); -VECTORSTATICTRAITSMACROFORONETYPE( float ); -VECTORSTATICTRAITSMACROFORONETYPE( double ); -VECTORSTATICTRAITSMACROFORONETYPE( long double ); +itkStaticNumericTraitsGenericArrayDimensionsMacro( Vector, char ); +itkStaticNumericTraitsGenericArrayDimensionsMacro( Vector, unsigned char ); +itkStaticNumericTraitsGenericArrayDimensionsMacro( Vector, signed char ); +itkStaticNumericTraitsGenericArrayDimensionsMacro( Vector, short ); +itkStaticNumericTraitsGenericArrayDimensionsMacro( Vector, unsigned short ); +itkStaticNumericTraitsGenericArrayDimensionsMacro( Vector, int ); +itkStaticNumericTraitsGenericArrayDimensionsMacro( Vector, unsigned int ); +itkStaticNumericTraitsGenericArrayDimensionsMacro( Vector, long ); +itkStaticNumericTraitsGenericArrayDimensionsMacro( Vector, unsigned long ); +itkStaticNumericTraitsGenericArrayDimensionsMacro( Vector, float ); +itkStaticNumericTraitsGenericArrayDimensionsMacro( Vector, double ); +itkStaticNumericTraitsGenericArrayDimensionsMacro( Vector, long double ); +#ifdef ITK_TYPE_USE_LONG_LONG +itkStaticNumericTraitsGenericArrayDimensionsMacro( Vector, long long ); +itkStaticNumericTraitsGenericArrayDimensionsMacro( Vector, unsigned long long ); +#endif // ITK_TYPE_USE_LONG_LONG } // end namespace itk diff --git a/Utilities/ITK/Code/Common/itkNumericTraitsVectorPixel.h b/Utilities/ITK/Code/Common/itkNumericTraitsVectorPixel.h index 7e290be722131dcbe6be569e3b6faa628ce1a17b..d0c2b6ee3b68903944a7846f85352d0745973697 100644 --- a/Utilities/ITK/Code/Common/itkNumericTraitsVectorPixel.h +++ b/Utilities/ITK/Code/Common/itkNumericTraitsVectorPixel.h @@ -1,10 +1,10 @@ - /*========================================================================= +/*========================================================================= Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkNumericTraitsVectorPixel.h,v $ Language: C++ - Date: $Date: 2009-03-03 15:07:54 $ - Version: $Revision: 1.16 $ + Date: $Date: 2009-12-01 16:53:06 $ + Version: $Revision: 1.18 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -17,1532 +17,42 @@ #ifndef __itkNumericTraitsVectorPixel_h #define __itkNumericTraitsVectorPixel_h -#include "itkNumericTraits.h" +#include "itkNumericTraitsFixedArrayPixel.h" #include "itkVector.h" -// This file defines numeric traits for vector pixels types in itk -// TODO: Add doxygen tags.. namespace itk { -template <> class NumericTraits<Vector<unsigned char, 1 > > { -public: - typedef unsigned char ValueType; - typedef Vector<unsigned char, 1> PrintType; - typedef Vector<unsigned char, 1> AbsType; - typedef Vector<unsigned short, 1> AccumulateType; - typedef Vector<double, 1> RealType; - typedef double ScalarRealType; - typedef Vector<float, 1> FloatType; - static const Vector<unsigned char, 1> ITKCommon_EXPORT Zero; - static const Vector<unsigned char, 1> ITKCommon_EXPORT One; - static Vector<unsigned char,1> ITKCommon_EXPORT ZeroValue(); - static Vector<unsigned char,1> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<signed char, 1> > { -public: - typedef signed char ValueType; - typedef Vector<signed char, 1> PrintType; - typedef Vector<unsigned char, 1> AbsType; - typedef Vector<short, 1> AccumulateType; - typedef Vector<double, 1> RealType; - typedef double ScalarRealType; - typedef Vector<float, 1> FloatType; - static const Vector<signed char, 1> ITKCommon_EXPORT Zero; - static const Vector<signed char, 1> ITKCommon_EXPORT One; - static Vector<signed char,1> ITKCommon_EXPORT ZeroValue(); - static Vector<signed char,1> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<char, 1> > { -public: - typedef char ValueType; - typedef Vector<char, 1> PrintType; - typedef Vector<unsigned char, 1> AbsType; - typedef Vector<short, 1> AccumulateType; - typedef Vector<double, 1> RealType; - typedef double ScalarRealType; - typedef Vector<float, 1> FloatType; - static const Vector<char, 1> ITKCommon_EXPORT Zero; - static const Vector<char, 1> ITKCommon_EXPORT One; - static Vector<char,1> ITKCommon_EXPORT ZeroValue(); - static Vector<char,1> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<short, 1> > { -public: - typedef short ValueType; - typedef Vector<short, 1> PrintType; - typedef Vector<unsigned short, 1> AbsType; - typedef Vector<int, 1> AccumulateType; - typedef Vector<double, 1> RealType; - typedef double ScalarRealType; - typedef Vector<float, 1> FloatType; - static const Vector<short, 1> ITKCommon_EXPORT Zero; - static const Vector<short, 1> ITKCommon_EXPORT One; - static Vector<short,1> ITKCommon_EXPORT ZeroValue(); - static Vector<short,1> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<unsigned short, 1> > { -public: - typedef unsigned short ValueType; - typedef Vector<unsigned short, 1> PrintType; - typedef Vector<unsigned short, 1> AbsType; - typedef Vector<unsigned int, 1> AccumulateType; - typedef Vector<double, 1> RealType; - typedef double ScalarRealType; - typedef Vector<float, 1> FloatType; - static const Vector<unsigned short, 1> ITKCommon_EXPORT Zero; - static const Vector<unsigned short, 1> ITKCommon_EXPORT One; - static Vector<unsigned short,1> ITKCommon_EXPORT ZeroValue(); - static Vector<unsigned short,1> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<int, 1> > { -public: - typedef int ValueType; - typedef Vector<int, 1> PrintType; - typedef Vector<unsigned int, 1> AbsType; - typedef Vector<long, 1> AccumulateType; - typedef Vector<double, 1> RealType; - typedef double ScalarRealType; - typedef Vector<float, 1> FloatType; - static const Vector<int, 1> ITKCommon_EXPORT Zero; - static const Vector<int, 1> ITKCommon_EXPORT One; - static Vector<int,1> ITKCommon_EXPORT ZeroValue(); - static Vector<int,1> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<unsigned int, 1> > { -public: - typedef unsigned int ValueType; - typedef Vector<unsigned int, 1> PrintType; - typedef Vector<unsigned int, 1> AbsType; - typedef Vector<unsigned long, 1> AccumulateType; - typedef Vector<double, 1> RealType; - typedef double ScalarRealType; - typedef Vector<float, 1> FloatType; - static const Vector<unsigned int, 1> ITKCommon_EXPORT Zero; - static const Vector<unsigned int, 1> ITKCommon_EXPORT One; - static Vector<unsigned int,1> ITKCommon_EXPORT ZeroValue(); - static Vector<unsigned int,1> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<long, 1> > { -public: - typedef long ValueType; - typedef Vector<long, 1> PrintType; - typedef Vector<unsigned long, 1> AbsType; - typedef Vector<long, 1> AccumulateType; - typedef Vector<double, 1> RealType; - typedef double ScalarRealType; - typedef Vector<float, 1> FloatType; - static const Vector<long, 1> ITKCommon_EXPORT Zero; - static const Vector<long, 1> ITKCommon_EXPORT One; - static Vector<long,1> ITKCommon_EXPORT ZeroValue(); - static Vector<long,1> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<unsigned long, 1> > { -public: - typedef unsigned long ValueType; - typedef Vector<unsigned long, 1> PrintType; - typedef Vector<unsigned long, 1> AbsType; - typedef Vector<unsigned long, 1> AccumulateType; - typedef Vector<double, 1> RealType; - typedef double ScalarRealType; - typedef Vector<float, 1> FloatType; - static const Vector<unsigned long, 1> ITKCommon_EXPORT Zero; - static const Vector<unsigned long, 1> ITKCommon_EXPORT One; - static Vector<unsigned long,1> ITKCommon_EXPORT ZeroValue(); - static Vector<unsigned long,1> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<float, 1> > { -public: - typedef float ValueType; - typedef Vector<float, 1> PrintType; - typedef Vector<float, 1> AbsType; - typedef Vector<double, 1> AccumulateType; - typedef Vector<double, 1> RealType; - typedef double ScalarRealType; - typedef Vector<float, 1> FloatType; - static const Vector<float, 1> ITKCommon_EXPORT Zero; - static const Vector<float, 1> ITKCommon_EXPORT One; - static Vector<float, 1> ITKCommon_EXPORT ZeroValue(); - static Vector<float, 1> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<double, 1> > { -public: - typedef double ValueType; - typedef Vector<double, 1> PrintType; - typedef Vector<double, 1> AbsType; - typedef Vector<long double, 1> AccumulateType; - typedef Vector<double, 1> RealType; - typedef double ScalarRealType; - typedef Vector<float, 1> FloatType; - static const Vector<double, 1> ITKCommon_EXPORT Zero; - static const Vector<double, 1> ITKCommon_EXPORT One; - static Vector<double, 1> ITKCommon_EXPORT ZeroValue(); - static Vector<double, 1> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<long double, 1> > { -public: - typedef long double ValueType; - typedef Vector<long double, 1> PrintType; - typedef Vector<long double, 1> AbsType; - typedef Vector<long double, 1> AccumulateType; - typedef Vector<long double, 1> RealType; - typedef long double ScalarRealType; - typedef Vector<float, 1> FloatType; - static const Vector<long double, 1> ITKCommon_EXPORT Zero; - static const Vector<long double, 1> ITKCommon_EXPORT One; - static Vector<long double, 1> ITKCommon_EXPORT ZeroValue(); - static Vector<long double, 1> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<unsigned char, 2 > > { -public: - typedef unsigned char ValueType; - typedef Vector<unsigned char, 2> PrintType; - typedef Vector<unsigned char, 2> AbsType; - typedef Vector<unsigned short, 2> AccumulateType; - typedef Vector<double, 2> RealType; - typedef double ScalarRealType; - typedef Vector<float, 2> FloatType; - static const Vector<unsigned char, 2> ITKCommon_EXPORT Zero; - static const Vector<unsigned char, 2> ITKCommon_EXPORT One; - static Vector<unsigned char,2> ITKCommon_EXPORT ZeroValue(); - static Vector<unsigned char,2> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<signed char, 2> > { -public: - typedef signed char ValueType; - typedef Vector<signed char, 2> PrintType; - typedef Vector<unsigned char, 2> AbsType; - typedef Vector<short, 2> AccumulateType; - typedef Vector<double, 2> RealType; - typedef double ScalarRealType; - typedef Vector<float, 2> FloatType; - static const Vector<signed char, 2> ITKCommon_EXPORT Zero; - static const Vector<signed char, 2> ITKCommon_EXPORT One; - static Vector<signed char,2> ITKCommon_EXPORT ZeroValue(); - static Vector<signed char,2> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<char, 2> > { -public: - typedef char ValueType; - typedef Vector<char, 2> PrintType; - typedef Vector<unsigned char, 2> AbsType; - typedef Vector<short, 2> AccumulateType; - typedef Vector<double, 2> RealType; - typedef double ScalarRealType; - typedef Vector<float, 2> FloatType; - static const Vector<char, 2> ITKCommon_EXPORT Zero; - static const Vector<char, 2> ITKCommon_EXPORT One; - static Vector<char,2> ITKCommon_EXPORT ZeroValue(); - static Vector<char,2> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<short, 2> > { -public: - typedef short ValueType; - typedef Vector<short, 2> PrintType; - typedef Vector<unsigned short, 2> AbsType; - typedef Vector<int, 2> AccumulateType; - typedef Vector<double, 2> RealType; - typedef double ScalarRealType; - typedef Vector<float, 2> FloatType; - static const Vector<short, 2> ITKCommon_EXPORT Zero; - static const Vector<short, 2> ITKCommon_EXPORT One; - static Vector<short,2> ITKCommon_EXPORT ZeroValue(); - static Vector<short,2> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<unsigned short, 2> > { -public: - typedef unsigned short ValueType; - typedef Vector<unsigned short, 2> PrintType; - typedef Vector<unsigned short, 2> AbsType; - typedef Vector<unsigned int, 2> AccumulateType; - typedef Vector<double, 2> RealType; - typedef double ScalarRealType; - typedef Vector<float, 2> FloatType; - static const Vector<unsigned short, 2> ITKCommon_EXPORT Zero; - static const Vector<unsigned short, 2> ITKCommon_EXPORT One; - static Vector<unsigned short,2> ITKCommon_EXPORT ZeroValue(); - static Vector<unsigned short,2> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<int, 2> > { -public: - typedef int ValueType; - typedef Vector<int, 2> PrintType; - typedef Vector<unsigned int, 2> AbsType; - typedef Vector<long, 2> AccumulateType; - typedef Vector<double, 2> RealType; - typedef double ScalarRealType; - typedef Vector<float, 2> FloatType; - static const Vector<int, 2> ITKCommon_EXPORT Zero; - static const Vector<int, 2> ITKCommon_EXPORT One; - static Vector<int,2> ITKCommon_EXPORT ZeroValue(); - static Vector<int,2> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<unsigned int, 2> > { -public: - typedef unsigned int ValueType; - typedef Vector<unsigned int, 2> PrintType; - typedef Vector<unsigned int, 2> AbsType; - typedef Vector<unsigned long, 2> AccumulateType; - typedef Vector<double, 2> RealType; - typedef double ScalarRealType; - typedef Vector<float, 2> FloatType; - static const Vector<unsigned int, 2> ITKCommon_EXPORT Zero; - static const Vector<unsigned int, 2> ITKCommon_EXPORT One; - static Vector<unsigned int,2> ITKCommon_EXPORT ZeroValue(); - static Vector<unsigned int,2> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<long, 2> > { -public: - typedef long ValueType; - typedef Vector<long, 2> PrintType; - typedef Vector<unsigned long, 2> AbsType; - typedef Vector<long, 2> AccumulateType; - typedef Vector<double, 2> RealType; - typedef double ScalarRealType; - typedef Vector<float, 2> FloatType; - static const Vector<long, 2> ITKCommon_EXPORT Zero; - static const Vector<long, 2> ITKCommon_EXPORT One; - static Vector<long,2> ITKCommon_EXPORT ZeroValue(); - static Vector<long,2> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<unsigned long, 2> > { -public: - typedef unsigned long ValueType; - typedef Vector<unsigned long, 2> PrintType; - typedef Vector<unsigned long, 2> AbsType; - typedef Vector<unsigned long, 2> AccumulateType; - typedef Vector<double, 2> RealType; - typedef double ScalarRealType; - typedef Vector<float, 2> FloatType; - static const Vector<unsigned long, 2> ITKCommon_EXPORT Zero; - static const Vector<unsigned long, 2> ITKCommon_EXPORT One; - static Vector<unsigned long,2> ITKCommon_EXPORT ZeroValue(); - static Vector<unsigned long,2> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<float, 2> > { -public: - typedef float ValueType; - typedef Vector<float, 2> PrintType; - typedef Vector<float, 2> AbsType; - typedef Vector<double, 2> AccumulateType; - typedef Vector<double, 2> RealType; - typedef double ScalarRealType; - typedef Vector<float, 2> FloatType; - static const Vector<float, 2> ITKCommon_EXPORT Zero; - static const Vector<float, 2> ITKCommon_EXPORT One; - static Vector<float, 2> ITKCommon_EXPORT ZeroValue(); - static Vector<float, 2> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<double, 2> > { -public: - typedef double ValueType; - typedef Vector<double, 2> PrintType; - typedef Vector<double, 2> AbsType; - typedef Vector<long double, 2> AccumulateType; - typedef Vector<double, 2> RealType; - typedef double ScalarRealType; - typedef Vector<float, 2> FloatType; - static const Vector<double, 2> ITKCommon_EXPORT Zero; - static const Vector<double, 2> ITKCommon_EXPORT One; - static Vector<double, 2> ITKCommon_EXPORT ZeroValue(); - static Vector<double, 2> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<long double, 2> > { -public: - typedef long double ValueType; - typedef Vector<long double, 2> PrintType; - typedef Vector<long double, 2> AbsType; - typedef Vector<long double, 2> AccumulateType; - typedef Vector<long double, 2> RealType; - typedef long double ScalarRealType; - typedef Vector<float, 2> FloatType; - static const Vector<long double, 2> ITKCommon_EXPORT Zero; - static const Vector<long double, 2> ITKCommon_EXPORT One; - static Vector<long double, 2> ITKCommon_EXPORT ZeroValue(); - static Vector<long double, 2> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<unsigned char, 3 > > { -public: - typedef unsigned char ValueType; - typedef Vector<unsigned char, 3> PrintType; - typedef Vector<unsigned char, 3> AbsType; - typedef Vector<unsigned short, 3> AccumulateType; - typedef Vector<double, 3> RealType; - typedef double ScalarRealType; - typedef Vector<float, 3> FloatType; - static const Vector<unsigned char, 3> ITKCommon_EXPORT Zero; - static const Vector<unsigned char, 3> ITKCommon_EXPORT One; - static Vector<unsigned char,3> ITKCommon_EXPORT ZeroValue(); - static Vector<unsigned char,3> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<signed char, 3> > { -public: - typedef signed char ValueType; - typedef Vector<signed char, 3> PrintType; - typedef Vector<unsigned char, 3> AbsType; - typedef Vector<short, 3> AccumulateType; - typedef Vector<double, 3> RealType; - typedef double ScalarRealType; - typedef Vector<float, 3> FloatType; - static const Vector<signed char, 3> ITKCommon_EXPORT Zero; - static const Vector<signed char, 3> ITKCommon_EXPORT One; - static Vector<signed char,3> ITKCommon_EXPORT ZeroValue(); - static Vector<signed char,3> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<char, 3> > { -public: - typedef char ValueType; - typedef Vector<char, 3> PrintType; - typedef Vector<unsigned char, 3> AbsType; - typedef Vector<short, 3> AccumulateType; - typedef Vector<double, 3> RealType; - typedef double ScalarRealType; - typedef Vector<float, 3> FloatType; - static const Vector<char, 3> ITKCommon_EXPORT Zero; - static const Vector<char, 3> ITKCommon_EXPORT One; - static Vector<char,3> ITKCommon_EXPORT ZeroValue(); - static Vector<char,3> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<short, 3> > { -public: - typedef short ValueType; - typedef Vector<short, 3> PrintType; - typedef Vector<unsigned short, 3> AbsType; - typedef Vector<int, 3> AccumulateType; - typedef Vector<double, 3> RealType; - typedef double ScalarRealType; - typedef Vector<float, 3> FloatType; - static const Vector<short, 3> ITKCommon_EXPORT Zero; - static const Vector<short, 3> ITKCommon_EXPORT One; - static Vector<short,3> ITKCommon_EXPORT ZeroValue(); - static Vector<short,3> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<unsigned short, 3> > { -public: - typedef unsigned short ValueType; - typedef Vector<unsigned short, 3> PrintType; - typedef Vector<unsigned short, 3> AbsType; - typedef Vector<unsigned int, 3> AccumulateType; - typedef Vector<double, 3> RealType; - typedef double ScalarRealType; - typedef Vector<float, 3> FloatType; - static const Vector<unsigned short, 3> ITKCommon_EXPORT Zero; - static const Vector<unsigned short, 3> ITKCommon_EXPORT One; - static Vector<unsigned short,3> ITKCommon_EXPORT ZeroValue(); - static Vector<unsigned short,3> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<int, 3> > { -public: - typedef int ValueType; - typedef Vector<int, 3> PrintType; - typedef Vector<unsigned int, 3> AbsType; - typedef Vector<long, 3> AccumulateType; - typedef Vector<double, 3> RealType; - typedef double ScalarRealType; - typedef Vector<float, 3> FloatType; - static const Vector<int, 3> ITKCommon_EXPORT Zero; - static const Vector<int, 3> ITKCommon_EXPORT One; - static Vector<int,3> ITKCommon_EXPORT ZeroValue(); - static Vector<int,3> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<unsigned int, 3> > { -public: - typedef unsigned int ValueType; - typedef Vector<unsigned int, 3> PrintType; - typedef Vector<unsigned int, 3> AbsType; - typedef Vector<unsigned long, 3> AccumulateType; - typedef Vector<double, 3> RealType; - typedef double ScalarRealType; - typedef Vector<float, 3> FloatType; - static const Vector<unsigned int, 3> ITKCommon_EXPORT Zero; - static const Vector<unsigned int, 3> ITKCommon_EXPORT One; - static Vector<unsigned int,3> ITKCommon_EXPORT ZeroValue(); - static Vector<unsigned int,3> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<long, 3> > { -public: - typedef long ValueType; - typedef Vector<long, 3> PrintType; - typedef Vector<unsigned long, 3> AbsType; - typedef Vector<long, 3> AccumulateType; - typedef Vector<double, 3> RealType; - typedef double ScalarRealType; - typedef Vector<float, 3> FloatType; - static const Vector<long, 3> ITKCommon_EXPORT Zero; - static const Vector<long, 3> ITKCommon_EXPORT One; - static Vector<long,3> ITKCommon_EXPORT ZeroValue(); - static Vector<long,3> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<unsigned long, 3> > { -public: - typedef unsigned long ValueType; - typedef Vector<unsigned long, 3> PrintType; - typedef Vector<unsigned long, 3> AbsType; - typedef Vector<unsigned long, 3> AccumulateType; - typedef Vector<double, 3> RealType; - typedef double ScalarRealType; - typedef Vector<float, 3> FloatType; - static const Vector<unsigned long, 3> ITKCommon_EXPORT Zero; - static const Vector<unsigned long, 3> ITKCommon_EXPORT One; - static Vector<unsigned long,3> ITKCommon_EXPORT ZeroValue(); - static Vector<unsigned long,3> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<float, 3> > { -public: - typedef float ValueType; - typedef Vector<float, 3> PrintType; - typedef Vector<float, 3> AbsType; - typedef Vector<double, 3> AccumulateType; - typedef Vector<double, 3> RealType; - typedef double ScalarRealType; - typedef Vector<float, 3> FloatType; - static const Vector<float, 3> ITKCommon_EXPORT Zero; - static const Vector<float, 3> ITKCommon_EXPORT One; - static Vector<float, 3> ITKCommon_EXPORT ZeroValue(); - static Vector<float, 3> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<double, 3> > { -public: - typedef double ValueType; - typedef Vector<double, 3> PrintType; - typedef Vector<double, 3> AbsType; - typedef Vector<long double, 3> AccumulateType; - typedef Vector<double, 3> RealType; - typedef double ScalarRealType; - typedef Vector<float, 3> FloatType; - static const Vector<double, 3> ITKCommon_EXPORT Zero; - static const Vector<double, 3> ITKCommon_EXPORT One; - static Vector<double, 3> ITKCommon_EXPORT ZeroValue(); - static Vector<double, 3> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<long double, 3> > { -public: - typedef long double ValueType; - typedef Vector<long double, 3> PrintType; - typedef Vector<long double, 3> AbsType; - typedef Vector<long double, 3> AccumulateType; - typedef Vector<long double, 3> RealType; - typedef long double ScalarRealType; - typedef Vector<float, 3> FloatType; - static const Vector<long double, 3> ITKCommon_EXPORT Zero; - static const Vector<long double, 3> ITKCommon_EXPORT One; - static Vector<long double, 3> ITKCommon_EXPORT ZeroValue(); - static Vector<long double, 3> ITKCommon_EXPORT OneValue(); -}; - -template <> class NumericTraits<Vector<unsigned char, 4 > > { -public: - typedef unsigned char ValueType; - typedef Vector<unsigned char, 4> PrintType; - typedef Vector<unsigned char, 4> AbsType; - typedef Vector<unsigned short, 4> AccumulateType; - typedef Vector<double, 4> RealType; - typedef double ScalarRealType; - typedef Vector<float, 4> FloatType; - static const Vector<unsigned char, 4> ITKCommon_EXPORT Zero; - static const Vector<unsigned char, 4> ITKCommon_EXPORT One; - static Vector<unsigned char,4> ITKCommon_EXPORT ZeroValue(); - static Vector<unsigned char,4> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<signed char, 4> > { -public: - typedef signed char ValueType; - typedef Vector<signed char, 4> PrintType; - typedef Vector<unsigned char, 4> AbsType; - typedef Vector<short, 4> AccumulateType; - typedef Vector<double, 4> RealType; - typedef double ScalarRealType; - typedef Vector<float, 4> FloatType; - static const Vector<signed char, 4> ITKCommon_EXPORT Zero; - static const Vector<signed char, 4> ITKCommon_EXPORT One; - static Vector<signed char,4> ITKCommon_EXPORT ZeroValue(); - static Vector<signed char,4> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<char, 4> > { -public: - typedef char ValueType; - typedef Vector<char, 4> PrintType; - typedef Vector<unsigned char, 4> AbsType; - typedef Vector<short, 4> AccumulateType; - typedef Vector<double, 4> RealType; - typedef double ScalarRealType; - typedef Vector<float, 4> FloatType; - static const Vector<char, 4> ITKCommon_EXPORT Zero; - static const Vector<char, 4> ITKCommon_EXPORT One; - static Vector<char,4> ITKCommon_EXPORT ZeroValue(); - static Vector<char,4> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<short, 4> > { -public: - typedef short ValueType; - typedef Vector<short, 4> PrintType; - typedef Vector<unsigned short, 4> AbsType; - typedef Vector<int, 4> AccumulateType; - typedef Vector<double, 4> RealType; - typedef double ScalarRealType; - typedef Vector<float, 4> FloatType; - static const Vector<short, 4> ITKCommon_EXPORT Zero; - static const Vector<short, 4> ITKCommon_EXPORT One; - static Vector<short,4> ITKCommon_EXPORT ZeroValue(); - static Vector<short,4> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<unsigned short, 4> > { -public: - typedef unsigned short ValueType; - typedef Vector<unsigned short, 4> PrintType; - typedef Vector<unsigned short, 4> AbsType; - typedef Vector<unsigned int, 4> AccumulateType; - typedef Vector<double, 4> RealType; - typedef double ScalarRealType; - typedef Vector<float, 4> FloatType; - static const Vector<unsigned short, 4> ITKCommon_EXPORT Zero; - static const Vector<unsigned short, 4> ITKCommon_EXPORT One; - static Vector<unsigned short,4> ITKCommon_EXPORT ZeroValue(); - static Vector<unsigned short,4> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<int, 4> > { -public: - typedef int ValueType; - typedef Vector<int, 4> PrintType; - typedef Vector<unsigned int, 4> AbsType; - typedef Vector<long, 4> AccumulateType; - typedef Vector<double, 4> RealType; - typedef double ScalarRealType; - typedef Vector<float, 4> FloatType; - static const Vector<int, 4> ITKCommon_EXPORT Zero; - static const Vector<int, 4> ITKCommon_EXPORT One; - static Vector<int,4> ITKCommon_EXPORT ZeroValue(); - static Vector<int,4> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<unsigned int, 4> > { -public: - typedef unsigned int ValueType; - typedef Vector<unsigned int, 4> PrintType; - typedef Vector<unsigned int, 4> AbsType; - typedef Vector<unsigned long, 4> AccumulateType; - typedef Vector<double, 4> RealType; - typedef double ScalarRealType; - typedef Vector<float, 4> FloatType; - static const Vector<unsigned int, 4> ITKCommon_EXPORT Zero; - static const Vector<unsigned int, 4> ITKCommon_EXPORT One; - static Vector<unsigned int,4> ITKCommon_EXPORT ZeroValue(); - static Vector<unsigned int,4> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<long, 4> > { -public: - typedef long ValueType; - typedef Vector<long, 4> PrintType; - typedef Vector<unsigned long, 4> AbsType; - typedef Vector<long, 4> AccumulateType; - typedef Vector<double, 4> RealType; - typedef double ScalarRealType; - typedef Vector<float, 4> FloatType; - static const Vector<long, 4> ITKCommon_EXPORT Zero; - static const Vector<long, 4> ITKCommon_EXPORT One; - static Vector<long,4> ITKCommon_EXPORT ZeroValue(); - static Vector<long,4> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<unsigned long, 4> > { -public: - typedef unsigned long ValueType; - typedef Vector<unsigned long, 4> PrintType; - typedef Vector<unsigned long, 4> AbsType; - typedef Vector<unsigned long, 4> AccumulateType; - typedef Vector<double, 4> RealType; - typedef double ScalarRealType; - typedef Vector<float, 4> FloatType; - static const Vector<unsigned long, 4> ITKCommon_EXPORT Zero; - static const Vector<unsigned long, 4> ITKCommon_EXPORT One; - static Vector<unsigned long,4> ITKCommon_EXPORT ZeroValue(); - static Vector<unsigned long,4> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<float, 4> > { -public: - typedef float ValueType; - typedef Vector<float, 4> PrintType; - typedef Vector<float, 4> AbsType; - typedef Vector<double, 4> AccumulateType; - typedef Vector<double, 4> RealType; - typedef double ScalarRealType; - typedef Vector<float, 4> FloatType; - static const Vector<float, 4> ITKCommon_EXPORT Zero; - static const Vector<float, 4> ITKCommon_EXPORT One; - static Vector<float, 4> ITKCommon_EXPORT ZeroValue(); - static Vector<float, 4> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<double, 4> > { -public: - typedef double ValueType; - typedef Vector<double, 4> PrintType; - typedef Vector<double, 4> AbsType; - typedef Vector<long double, 4> AccumulateType; - typedef Vector<double, 4> RealType; - typedef double ScalarRealType; - typedef Vector<float, 4> FloatType; - static const Vector<double, 4> ITKCommon_EXPORT Zero; - static const Vector<double, 4> ITKCommon_EXPORT One; - static Vector<double, 4> ITKCommon_EXPORT ZeroValue(); - static Vector<double, 4> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<long double, 4> > { -public: - typedef long double ValueType; - typedef Vector<long double, 4> PrintType; - typedef Vector<long double, 4> AbsType; - typedef Vector<long double, 4> AccumulateType; - typedef Vector<long double, 4> RealType; - typedef long double ScalarRealType; - typedef Vector<float, 4> FloatType; - static const Vector<long double, 4> ITKCommon_EXPORT Zero; - static const Vector<long double, 4> ITKCommon_EXPORT One; - static Vector<long double, 4> ITKCommon_EXPORT ZeroValue(); - static Vector<long double, 4> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<unsigned char, 5 > > { -public: - typedef unsigned char ValueType; - typedef Vector<unsigned char, 5> PrintType; - typedef Vector<unsigned char, 5> AbsType; - typedef Vector<unsigned short, 5> AccumulateType; - typedef Vector<double, 5> RealType; - typedef double ScalarRealType; - typedef Vector<float, 5> FloatType; - static const Vector<unsigned char, 5> ITKCommon_EXPORT Zero; - static const Vector<unsigned char, 5> ITKCommon_EXPORT One; - static Vector<unsigned char,5> ITKCommon_EXPORT ZeroValue(); - static Vector<unsigned char,5> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<signed char, 5> > { -public: - typedef signed char ValueType; - typedef Vector<signed char, 5> PrintType; - typedef Vector<unsigned char, 5> AbsType; - typedef Vector<short, 5> AccumulateType; - typedef Vector<double, 5> RealType; - typedef double ScalarRealType; - typedef Vector<float, 5> FloatType; - static const Vector<signed char, 5> ITKCommon_EXPORT Zero; - static const Vector<signed char, 5> ITKCommon_EXPORT One; - static Vector<signed char,5> ITKCommon_EXPORT ZeroValue(); - static Vector<signed char,5> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<char, 5> > { -public: - typedef char ValueType; - typedef Vector<char, 5> PrintType; - typedef Vector<unsigned char, 5> AbsType; - typedef Vector<short, 5> AccumulateType; - typedef Vector<double, 5> RealType; - typedef double ScalarRealType; - typedef Vector<float, 5> FloatType; - static const Vector<char, 5> ITKCommon_EXPORT Zero; - static const Vector<char, 5> ITKCommon_EXPORT One; - static Vector<char,5> ITKCommon_EXPORT ZeroValue(); - static Vector<char,5> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<short, 5> > { -public: - typedef short ValueType; - typedef Vector<short, 5> PrintType; - typedef Vector<unsigned short, 5> AbsType; - typedef Vector<int, 5> AccumulateType; - typedef Vector<double, 5> RealType; - typedef double ScalarRealType; - typedef Vector<float, 5> FloatType; - static const Vector<short, 5> ITKCommon_EXPORT Zero; - static const Vector<short, 5> ITKCommon_EXPORT One; - static Vector<short,5> ITKCommon_EXPORT ZeroValue(); - static Vector<short,5> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<unsigned short, 5> > { -public: - typedef unsigned short ValueType; - typedef Vector<unsigned short, 5> PrintType; - typedef Vector<unsigned short, 5> AbsType; - typedef Vector<unsigned int, 5> AccumulateType; - typedef Vector<double, 5> RealType; - typedef double ScalarRealType; - typedef Vector<float, 5> FloatType; - static const Vector<unsigned short, 5> ITKCommon_EXPORT Zero; - static const Vector<unsigned short, 5> ITKCommon_EXPORT One; - static Vector<unsigned short,5> ITKCommon_EXPORT ZeroValue(); - static Vector<unsigned short,5> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<int, 5> > { -public: - typedef int ValueType; - typedef Vector<int, 5> PrintType; - typedef Vector<unsigned int, 5> AbsType; - typedef Vector<long, 5> AccumulateType; - typedef Vector<double, 5> RealType; - typedef double ScalarRealType; - typedef Vector<float, 5> FloatType; - static const Vector<int, 5> ITKCommon_EXPORT Zero; - static const Vector<int, 5> ITKCommon_EXPORT One; - static Vector<int,5> ITKCommon_EXPORT ZeroValue(); - static Vector<int,5> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<unsigned int, 5> > { -public: - typedef unsigned int ValueType; - typedef Vector<unsigned int, 5> PrintType; - typedef Vector<unsigned int, 5> AbsType; - typedef Vector<unsigned long, 5> AccumulateType; - typedef Vector<double, 5> RealType; - typedef double ScalarRealType; - typedef Vector<float, 5> FloatType; - static const Vector<unsigned int, 5> ITKCommon_EXPORT Zero; - static const Vector<unsigned int, 5> ITKCommon_EXPORT One; - static Vector<unsigned int,5> ITKCommon_EXPORT ZeroValue(); - static Vector<unsigned int,5> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<long, 5> > { -public: - typedef long ValueType; - typedef Vector<long, 5> PrintType; - typedef Vector<unsigned long, 5> AbsType; - typedef Vector<long, 5> AccumulateType; - typedef Vector<double, 5> RealType; - typedef double ScalarRealType; - typedef Vector<float, 5> FloatType; - static const Vector<long, 5> ITKCommon_EXPORT Zero; - static const Vector<long, 5> ITKCommon_EXPORT One; - static Vector<long,5> ITKCommon_EXPORT ZeroValue(); - static Vector<long,5> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<unsigned long, 5> > { -public: - typedef unsigned long ValueType; - typedef Vector<unsigned long, 5> PrintType; - typedef Vector<unsigned long, 5> AbsType; - typedef Vector<unsigned long, 5> AccumulateType; - typedef Vector<double, 5> RealType; - typedef double ScalarRealType; - typedef Vector<float, 5> FloatType; - static const Vector<unsigned long, 5> ITKCommon_EXPORT Zero; - static const Vector<unsigned long, 5> ITKCommon_EXPORT One; - static Vector<unsigned long,5> ITKCommon_EXPORT ZeroValue(); - static Vector<unsigned long,5> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<float, 5> > { -public: - typedef float ValueType; - typedef Vector<float, 5> PrintType; - typedef Vector<float, 5> AbsType; - typedef Vector<double, 5> AccumulateType; - typedef Vector<double, 5> RealType; - typedef double ScalarRealType; - typedef Vector<float, 5> FloatType; - static const Vector<float, 5> ITKCommon_EXPORT Zero; - static const Vector<float, 5> ITKCommon_EXPORT One; - static Vector<float, 5> ITKCommon_EXPORT ZeroValue(); - static Vector<float, 5> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<double, 5> > { -public: - typedef double ValueType; - typedef Vector<double, 5> PrintType; - typedef Vector<double, 5> AbsType; - typedef Vector<long double, 5> AccumulateType; - typedef Vector<double, 5> RealType; - typedef double ScalarRealType; - typedef Vector<float, 5> FloatType; - static const Vector<double, 5> ITKCommon_EXPORT Zero; - static const Vector<double, 5> ITKCommon_EXPORT One; - static Vector<double, 5> ITKCommon_EXPORT ZeroValue(); - static Vector<double, 5> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<long double, 5> > { -public: - typedef long double ValueType; - typedef Vector<long double, 5> PrintType; - typedef Vector<long double, 5> AbsType; - typedef Vector<long double, 5> AccumulateType; - typedef Vector<long double, 5> RealType; - typedef long double ScalarRealType; - typedef Vector<float, 5> FloatType; - static const Vector<long double, 5> ITKCommon_EXPORT Zero; - static const Vector<long double, 5> ITKCommon_EXPORT One; - static Vector<long double, 5> ITKCommon_EXPORT ZeroValue(); - static Vector<long double, 5> ITKCommon_EXPORT OneValue(); -}; - -template <> class NumericTraits<Vector<unsigned char, 6 > > { -public: - typedef unsigned char ValueType; - typedef Vector<unsigned char, 6> PrintType; - typedef Vector<unsigned char, 6> AbsType; - typedef Vector<unsigned short, 6> AccumulateType; - typedef Vector<double, 6> RealType; - typedef double ScalarRealType; - typedef Vector<float, 6> FloatType; - static const Vector<unsigned char, 6> ITKCommon_EXPORT Zero; - static const Vector<unsigned char, 6> ITKCommon_EXPORT One; - static Vector<unsigned char,6> ITKCommon_EXPORT ZeroValue(); - static Vector<unsigned char,6> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<signed char, 6> > { -public: - typedef signed char ValueType; - typedef Vector<signed char, 6> PrintType; - typedef Vector<unsigned char, 6> AbsType; - typedef Vector<short, 6> AccumulateType; - typedef Vector<double, 6> RealType; - typedef double ScalarRealType; - typedef Vector<float, 6> FloatType; - static const Vector<signed char, 6> ITKCommon_EXPORT Zero; - static const Vector<signed char, 6> ITKCommon_EXPORT One; - static Vector<signed char,6> ITKCommon_EXPORT ZeroValue(); - static Vector<signed char,6> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<char, 6> > { -public: - typedef char ValueType; - typedef Vector<char, 6> PrintType; - typedef Vector<unsigned char, 6> AbsType; - typedef Vector<short, 6> AccumulateType; - typedef Vector<double, 6> RealType; - typedef double ScalarRealType; - typedef Vector<float, 6> FloatType; - static const Vector<char, 6> ITKCommon_EXPORT Zero; - static const Vector<char, 6> ITKCommon_EXPORT One; - static Vector<char,6> ITKCommon_EXPORT ZeroValue(); - static Vector<char,6> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<short, 6> > { -public: - typedef short ValueType; - typedef Vector<short, 6> PrintType; - typedef Vector<unsigned short, 6> AbsType; - typedef Vector<int, 6> AccumulateType; - typedef Vector<double, 6> RealType; - typedef double ScalarRealType; - typedef Vector<float, 6> FloatType; - static const Vector<short, 6> ITKCommon_EXPORT Zero; - static const Vector<short, 6> ITKCommon_EXPORT One; - static Vector<short,6> ITKCommon_EXPORT ZeroValue(); - static Vector<short,6> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<unsigned short, 6> > { -public: - typedef unsigned short ValueType; - typedef Vector<unsigned short, 6> PrintType; - typedef Vector<unsigned short, 6> AbsType; - typedef Vector<unsigned int, 6> AccumulateType; - typedef Vector<double, 6> RealType; - typedef double ScalarRealType; - typedef Vector<float, 6> FloatType; - static const Vector<unsigned short, 6> ITKCommon_EXPORT Zero; - static const Vector<unsigned short, 6> ITKCommon_EXPORT One; - static Vector<unsigned short,6> ITKCommon_EXPORT ZeroValue(); - static Vector<unsigned short,6> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<int, 6> > { -public: - typedef int ValueType; - typedef Vector<int, 6> PrintType; - typedef Vector<unsigned int, 6> AbsType; - typedef Vector<long, 6> AccumulateType; - typedef Vector<double, 6> RealType; - typedef double ScalarRealType; - typedef Vector<float, 6> FloatType; - static const Vector<int, 6> ITKCommon_EXPORT Zero; - static const Vector<int, 6> ITKCommon_EXPORT One; - static Vector<int,6> ITKCommon_EXPORT ZeroValue(); - static Vector<int,6> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<unsigned int, 6> > { -public: - typedef unsigned int ValueType; - typedef Vector<unsigned int, 6> PrintType; - typedef Vector<unsigned int, 6> AbsType; - typedef Vector<unsigned long, 6> AccumulateType; - typedef Vector<double, 6> RealType; - typedef double ScalarRealType; - typedef Vector<float, 6> FloatType; - static const Vector<unsigned int, 6> ITKCommon_EXPORT Zero; - static const Vector<unsigned int, 6> ITKCommon_EXPORT One; - static Vector<unsigned int,6> ITKCommon_EXPORT ZeroValue(); - static Vector<unsigned int,6> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<long, 6> > { -public: - typedef long ValueType; - typedef Vector<long, 6> PrintType; - typedef Vector<unsigned long, 6> AbsType; - typedef Vector<long, 6> AccumulateType; - typedef Vector<double, 6> RealType; - typedef double ScalarRealType; - typedef Vector<float, 6> FloatType; - static const Vector<long, 6> ITKCommon_EXPORT Zero; - static const Vector<long, 6> ITKCommon_EXPORT One; - static Vector<long,6> ITKCommon_EXPORT ZeroValue(); - static Vector<long,6> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<unsigned long, 6> > { -public: - typedef unsigned long ValueType; - typedef Vector<unsigned long, 6> PrintType; - typedef Vector<unsigned long, 6> AbsType; - typedef Vector<unsigned long, 6> AccumulateType; - typedef Vector<double, 6> RealType; - typedef double ScalarRealType; - typedef Vector<float, 6> FloatType; - static const Vector<unsigned long, 6> ITKCommon_EXPORT Zero; - static const Vector<unsigned long, 6> ITKCommon_EXPORT One; - static Vector<unsigned long,6> ITKCommon_EXPORT ZeroValue(); - static Vector<unsigned long,6> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<float, 6> > { -public: - typedef float ValueType; - typedef Vector<float, 6> PrintType; - typedef Vector<float, 6> AbsType; - typedef Vector<double, 6> AccumulateType; - typedef Vector<double, 6> RealType; - typedef double ScalarRealType; - typedef Vector<float, 6> FloatType; - static const Vector<float, 6> ITKCommon_EXPORT Zero; - static const Vector<float, 6> ITKCommon_EXPORT One; - static Vector<float, 6> ITKCommon_EXPORT ZeroValue(); - static Vector<float, 6> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<double, 6> > { -public: - typedef double ValueType; - typedef Vector<double, 6> PrintType; - typedef Vector<double, 6> AbsType; - typedef Vector<long double, 6> AccumulateType; - typedef Vector<double, 6> RealType; - typedef double ScalarRealType; - typedef Vector<float, 6> FloatType; - static const Vector<double, 6> ITKCommon_EXPORT Zero; - static const Vector<double, 6> ITKCommon_EXPORT One; - static Vector<double, 6> ITKCommon_EXPORT ZeroValue(); - static Vector<double, 6> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<long double, 6> > { -public: - typedef long double ValueType; - typedef Vector<long double, 6> PrintType; - typedef Vector<long double, 6> AbsType; - typedef Vector<long double, 6> AccumulateType; - typedef Vector<long double, 6> RealType; - typedef long double ScalarRealType; - typedef Vector<float, 6> FloatType; - static const Vector<long double, 6> ITKCommon_EXPORT Zero; - static const Vector<long double, 6> ITKCommon_EXPORT One; - static Vector<long double, 6> ITKCommon_EXPORT ZeroValue(); - static Vector<long double, 6> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<unsigned char, 7 > > { -public: - typedef unsigned char ValueType; - typedef Vector<unsigned char, 7> PrintType; - typedef Vector<unsigned char, 7> AbsType; - typedef Vector<unsigned short, 7> AccumulateType; - typedef Vector<double, 7> RealType; - typedef double ScalarRealType; - typedef Vector<float, 7> FloatType; - static const Vector<unsigned char, 7> ITKCommon_EXPORT Zero; - static const Vector<unsigned char, 7> ITKCommon_EXPORT One; - static Vector<unsigned char,7> ITKCommon_EXPORT ZeroValue(); - static Vector<unsigned char,7> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<signed char, 7> > { -public: - typedef signed char ValueType; - typedef Vector<signed char, 7> PrintType; - typedef Vector<unsigned char, 7> AbsType; - typedef Vector<short, 7> AccumulateType; - typedef Vector<double, 7> RealType; - typedef double ScalarRealType; - typedef Vector<float, 7> FloatType; - static const Vector<signed char, 7> ITKCommon_EXPORT Zero; - static const Vector<signed char, 7> ITKCommon_EXPORT One; - static Vector<signed char,7> ITKCommon_EXPORT ZeroValue(); - static Vector<signed char,7> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<char, 7> > { -public: - typedef char ValueType; - typedef Vector<char, 7> PrintType; - typedef Vector<unsigned char, 7> AbsType; - typedef Vector<short, 7> AccumulateType; - typedef Vector<double, 7> RealType; - typedef double ScalarRealType; - typedef Vector<float, 7> FloatType; - static const Vector<char, 7> ITKCommon_EXPORT Zero; - static const Vector<char, 7> ITKCommon_EXPORT One; - static Vector<char,7> ITKCommon_EXPORT ZeroValue(); - static Vector<char,7> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<short, 7> > { -public: - typedef short ValueType; - typedef Vector<short, 7> PrintType; - typedef Vector<unsigned short, 7> AbsType; - typedef Vector<int, 7> AccumulateType; - typedef Vector<double, 7> RealType; - typedef double ScalarRealType; - typedef Vector<float, 7> FloatType; - static const Vector<short, 7> ITKCommon_EXPORT Zero; - static const Vector<short, 7> ITKCommon_EXPORT One; - static Vector<short,7> ITKCommon_EXPORT ZeroValue(); - static Vector<short,7> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<unsigned short, 7> > { -public: - typedef unsigned short ValueType; - typedef Vector<unsigned short, 7> PrintType; - typedef Vector<unsigned short, 7> AbsType; - typedef Vector<unsigned int, 7> AccumulateType; - typedef Vector<double, 7> RealType; - typedef double ScalarRealType; - typedef Vector<float, 7> FloatType; - static const Vector<unsigned short, 7> ITKCommon_EXPORT Zero; - static const Vector<unsigned short, 7> ITKCommon_EXPORT One; - static Vector<unsigned short,7> ITKCommon_EXPORT ZeroValue(); - static Vector<unsigned short,7> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<int, 7> > { -public: - typedef int ValueType; - typedef Vector<int, 7> PrintType; - typedef Vector<unsigned int, 7> AbsType; - typedef Vector<long, 7> AccumulateType; - typedef Vector<double, 7> RealType; - typedef double ScalarRealType; - typedef Vector<float, 7> FloatType; - static const Vector<int, 7> ITKCommon_EXPORT Zero; - static const Vector<int, 7> ITKCommon_EXPORT One; - static Vector<int,7> ITKCommon_EXPORT ZeroValue(); - static Vector<int,7> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<unsigned int, 7> > { -public: - typedef unsigned int ValueType; - typedef Vector<unsigned int, 7> PrintType; - typedef Vector<unsigned int, 7> AbsType; - typedef Vector<unsigned long, 7> AccumulateType; - typedef Vector<double, 7> RealType; - typedef double ScalarRealType; - typedef Vector<float, 7> FloatType; - static const Vector<unsigned int, 7> ITKCommon_EXPORT Zero; - static const Vector<unsigned int, 7> ITKCommon_EXPORT One; - static Vector<unsigned int,7> ITKCommon_EXPORT ZeroValue(); - static Vector<unsigned int,7> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<long, 7> > { -public: - typedef long ValueType; - typedef Vector<long, 7> PrintType; - typedef Vector<unsigned long, 7> AbsType; - typedef Vector<long, 7> AccumulateType; - typedef Vector<double, 7> RealType; - typedef double ScalarRealType; - typedef Vector<float, 7> FloatType; - static const Vector<long, 7> ITKCommon_EXPORT Zero; - static const Vector<long, 7> ITKCommon_EXPORT One; - static Vector<long,7> ITKCommon_EXPORT ZeroValue(); - static Vector<long,7> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<unsigned long, 7> > { -public: - typedef unsigned long ValueType; - typedef Vector<unsigned long, 7> PrintType; - typedef Vector<unsigned long, 7> AbsType; - typedef Vector<unsigned long, 7> AccumulateType; - typedef Vector<double, 7> RealType; - typedef double ScalarRealType; - typedef Vector<float, 7> FloatType; - static const Vector<unsigned long, 7> ITKCommon_EXPORT Zero; - static const Vector<unsigned long, 7> ITKCommon_EXPORT One; - static Vector<unsigned long,7> ITKCommon_EXPORT ZeroValue(); - static Vector<unsigned long,7> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<float, 7> > { -public: - typedef float ValueType; - typedef Vector<float, 7> PrintType; - typedef Vector<float, 7> AbsType; - typedef Vector<double, 7> AccumulateType; - typedef Vector<double, 7> RealType; - typedef double ScalarRealType; - typedef Vector<float, 7> FloatType; - static const Vector<float, 7> ITKCommon_EXPORT Zero; - static const Vector<float, 7> ITKCommon_EXPORT One; - static Vector<float, 7> ITKCommon_EXPORT ZeroValue(); - static Vector<float, 7> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<double, 7> > { -public: - typedef double ValueType; - typedef Vector<double, 7> PrintType; - typedef Vector<double, 7> AbsType; - typedef Vector<long double, 7> AccumulateType; - typedef Vector<double, 7> RealType; - typedef double ScalarRealType; - typedef Vector<float, 7> FloatType; - static const Vector<double, 7> ITKCommon_EXPORT Zero; - static const Vector<double, 7> ITKCommon_EXPORT One; - static Vector<double, 7> ITKCommon_EXPORT ZeroValue(); - static Vector<double, 7> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<long double, 7> > { -public: - typedef long double ValueType; - typedef Vector<long double, 7> PrintType; - typedef Vector<long double, 7> AbsType; - typedef Vector<long double, 7> AccumulateType; - typedef Vector<long double, 7> RealType; - typedef long double ScalarRealType; - typedef Vector<float, 7> FloatType; - static const Vector<long double, 7> ITKCommon_EXPORT Zero; - static const Vector<long double, 7> ITKCommon_EXPORT One; - static Vector<long double, 7> ITKCommon_EXPORT ZeroValue(); - static Vector<long double, 7> ITKCommon_EXPORT OneValue(); -}; - -template <> class NumericTraits<Vector<unsigned char, 8 > > { -public: - typedef unsigned char ValueType; - typedef Vector<unsigned char, 8> PrintType; - typedef Vector<unsigned char, 8> AbsType; - typedef Vector<unsigned short, 8> AccumulateType; - typedef Vector<double, 8> RealType; - typedef double ScalarRealType; - typedef Vector<float, 8> FloatType; - static const Vector<unsigned char, 8> ITKCommon_EXPORT Zero; - static const Vector<unsigned char, 8> ITKCommon_EXPORT One; - static Vector<unsigned char,8> ITKCommon_EXPORT ZeroValue(); - static Vector<unsigned char,8> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<signed char, 8> > { -public: - typedef signed char ValueType; - typedef Vector<signed char, 8> PrintType; - typedef Vector<unsigned char, 8> AbsType; - typedef Vector<short, 8> AccumulateType; - typedef Vector<double, 8> RealType; - typedef double ScalarRealType; - typedef Vector<float, 8> FloatType; - static const Vector<signed char, 8> ITKCommon_EXPORT Zero; - static const Vector<signed char, 8> ITKCommon_EXPORT One; - static Vector<signed char,8> ITKCommon_EXPORT ZeroValue(); - static Vector<signed char,8> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<char, 8> > { -public: - typedef char ValueType; - typedef Vector<char, 8> PrintType; - typedef Vector<unsigned char, 8> AbsType; - typedef Vector<short, 8> AccumulateType; - typedef Vector<double, 8> RealType; - typedef double ScalarRealType; - typedef Vector<float, 8> FloatType; - static const Vector<char, 8> ITKCommon_EXPORT Zero; - static const Vector<char, 8> ITKCommon_EXPORT One; - static Vector<char,8> ITKCommon_EXPORT ZeroValue(); - static Vector<char,8> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<short, 8> > { -public: - typedef short ValueType; - typedef Vector<short, 8> PrintType; - typedef Vector<unsigned short, 8> AbsType; - typedef Vector<int, 8> AccumulateType; - typedef Vector<double, 8> RealType; - typedef double ScalarRealType; - typedef Vector<float, 8> FloatType; - static const Vector<short, 8> ITKCommon_EXPORT Zero; - static const Vector<short, 8> ITKCommon_EXPORT One; - static Vector<short,8> ITKCommon_EXPORT ZeroValue(); - static Vector<short,8> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<unsigned short, 8> > { -public: - typedef unsigned short ValueType; - typedef Vector<unsigned short, 8> PrintType; - typedef Vector<unsigned short, 8> AbsType; - typedef Vector<unsigned int, 8> AccumulateType; - typedef Vector<double, 8> RealType; - typedef double ScalarRealType; - typedef Vector<float, 8> FloatType; - static const Vector<unsigned short, 8> ITKCommon_EXPORT Zero; - static const Vector<unsigned short, 8> ITKCommon_EXPORT One; - static Vector<unsigned short,8> ITKCommon_EXPORT ZeroValue(); - static Vector<unsigned short,8> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<int, 8> > { -public: - typedef int ValueType; - typedef Vector<int, 8> PrintType; - typedef Vector<unsigned int, 8> AbsType; - typedef Vector<long, 8> AccumulateType; - typedef Vector<double, 8> RealType; - typedef double ScalarRealType; - typedef Vector<float, 8> FloatType; - static const Vector<int, 8> ITKCommon_EXPORT Zero; - static const Vector<int, 8> ITKCommon_EXPORT One; - static Vector<int,8> ITKCommon_EXPORT ZeroValue(); - static Vector<int,8> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<unsigned int, 8> > { -public: - typedef unsigned int ValueType; - typedef Vector<unsigned int, 8> PrintType; - typedef Vector<unsigned int, 8> AbsType; - typedef Vector<unsigned long, 8> AccumulateType; - typedef Vector<double, 8> RealType; - typedef double ScalarRealType; - typedef Vector<float, 8> FloatType; - static const Vector<unsigned int, 8> ITKCommon_EXPORT Zero; - static const Vector<unsigned int, 8> ITKCommon_EXPORT One; - static Vector<unsigned int,8> ITKCommon_EXPORT ZeroValue(); - static Vector<unsigned int,8> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<long, 8> > { -public: - typedef long ValueType; - typedef Vector<long, 8> PrintType; - typedef Vector<unsigned long, 8> AbsType; - typedef Vector<long, 8> AccumulateType; - typedef Vector<double, 8> RealType; - typedef double ScalarRealType; - typedef Vector<float, 8> FloatType; - static const Vector<long, 8> ITKCommon_EXPORT Zero; - static const Vector<long, 8> ITKCommon_EXPORT One; - static Vector<long,8> ITKCommon_EXPORT ZeroValue(); - static Vector<long,8> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<unsigned long, 8> > { -public: - typedef unsigned long ValueType; - typedef Vector<unsigned long, 8> PrintType; - typedef Vector<unsigned long, 8> AbsType; - typedef Vector<unsigned long, 8> AccumulateType; - typedef Vector<double, 8> RealType; - typedef double ScalarRealType; - typedef Vector<float, 8> FloatType; - static const Vector<unsigned long, 8> ITKCommon_EXPORT Zero; - static const Vector<unsigned long, 8> ITKCommon_EXPORT One; - static Vector<unsigned long,8> ITKCommon_EXPORT ZeroValue(); - static Vector<unsigned long,8> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<float, 8> > { -public: - typedef float ValueType; - typedef Vector<float, 8> PrintType; - typedef Vector<float, 8> AbsType; - typedef Vector<double, 8> AccumulateType; - typedef Vector<double, 8> RealType; - typedef double ScalarRealType; - typedef Vector<float, 8> FloatType; - static const Vector<float, 8> ITKCommon_EXPORT Zero; - static const Vector<float, 8> ITKCommon_EXPORT One; - static Vector<float, 8> ITKCommon_EXPORT ZeroValue(); - static Vector<float, 8> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<double, 8> > { -public: - typedef double ValueType; - typedef Vector<double, 8> PrintType; - typedef Vector<double, 8> AbsType; - typedef Vector<long double, 8> AccumulateType; - typedef Vector<double, 8> RealType; - typedef double ScalarRealType; - typedef Vector<float, 8> FloatType; - static const Vector<double, 8> ITKCommon_EXPORT Zero; - static const Vector<double, 8> ITKCommon_EXPORT One; - static Vector<double, 8> ITKCommon_EXPORT ZeroValue(); - static Vector<double, 8> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<long double, 8> > { -public: - typedef long double ValueType; - typedef Vector<long double, 8> PrintType; - typedef Vector<long double, 8> AbsType; - typedef Vector<long double, 8> AccumulateType; - typedef Vector<long double, 8> RealType; - typedef long double ScalarRealType; - typedef Vector<float, 8> FloatType; - static const Vector<long double, 8> ITKCommon_EXPORT Zero; - static const Vector<long double, 8> ITKCommon_EXPORT One; - static Vector<long double, 8> ITKCommon_EXPORT ZeroValue(); - static Vector<long double, 8> ITKCommon_EXPORT OneValue(); -}; - -template <> class NumericTraits<Vector<unsigned char, 9 > > { -public: - typedef unsigned char ValueType; - typedef Vector<unsigned char, 9> PrintType; - typedef Vector<unsigned char, 9> AbsType; - typedef Vector<unsigned short, 9> AccumulateType; - typedef Vector<double, 9> RealType; - typedef double ScalarRealType; - typedef Vector<float, 9> FloatType; - static const Vector<unsigned char, 9> ITKCommon_EXPORT Zero; - static const Vector<unsigned char, 9> ITKCommon_EXPORT One; - static Vector<unsigned char,9> ITKCommon_EXPORT ZeroValue(); - static Vector<unsigned char,9> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<signed char, 9> > { -public: - typedef signed char ValueType; - typedef Vector<signed char, 9> PrintType; - typedef Vector<unsigned char, 9> AbsType; - typedef Vector<short, 9> AccumulateType; - typedef Vector<double, 9> RealType; - typedef double ScalarRealType; - typedef Vector<float, 9> FloatType; - static const Vector<signed char, 9> ITKCommon_EXPORT Zero; - static const Vector<signed char, 9> ITKCommon_EXPORT One; - static Vector<signed char,9> ITKCommon_EXPORT ZeroValue(); - static Vector<signed char,9> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<char, 9> > { -public: - typedef char ValueType; - typedef Vector<char, 9> PrintType; - typedef Vector<unsigned char, 9> AbsType; - typedef Vector<short, 9> AccumulateType; - typedef Vector<double, 9> RealType; - typedef double ScalarRealType; - typedef Vector<float, 9> FloatType; - static const Vector<char, 9> ITKCommon_EXPORT Zero; - static const Vector<char, 9> ITKCommon_EXPORT One; - static Vector<char,9> ITKCommon_EXPORT ZeroValue(); - static Vector<char,9> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<short, 9> > { -public: - typedef short ValueType; - typedef Vector<short, 9> PrintType; - typedef Vector<unsigned short, 9> AbsType; - typedef Vector<int, 9> AccumulateType; - typedef Vector<double, 9> RealType; - typedef double ScalarRealType; - typedef Vector<float, 9> FloatType; - static const Vector<short, 9> ITKCommon_EXPORT Zero; - static const Vector<short, 9> ITKCommon_EXPORT One; - static Vector<short,9> ITKCommon_EXPORT ZeroValue(); - static Vector<short,9> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<unsigned short, 9> > { -public: - typedef unsigned short ValueType; - typedef Vector<unsigned short, 9> PrintType; - typedef Vector<unsigned short, 9> AbsType; - typedef Vector<unsigned int, 9> AccumulateType; - typedef Vector<double, 9> RealType; - typedef double ScalarRealType; - typedef Vector<float, 9> FloatType; - static const Vector<unsigned short, 9> ITKCommon_EXPORT Zero; - static const Vector<unsigned short, 9> ITKCommon_EXPORT One; - static Vector<unsigned short,9> ITKCommon_EXPORT ZeroValue(); - static Vector<unsigned short,9> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<int, 9> > { -public: - typedef int ValueType; - typedef Vector<int, 9> PrintType; - typedef Vector<unsigned int, 9> AbsType; - typedef Vector<long, 9> AccumulateType; - typedef Vector<double, 9> RealType; - typedef double ScalarRealType; - typedef Vector<float, 9> FloatType; - static const Vector<int, 9> ITKCommon_EXPORT Zero; - static const Vector<int, 9> ITKCommon_EXPORT One; - static Vector<int,9> ITKCommon_EXPORT ZeroValue(); - static Vector<int,9> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<unsigned int, 9> > { -public: - typedef unsigned int ValueType; - typedef Vector<unsigned int, 9> PrintType; - typedef Vector<unsigned int, 9> AbsType; - typedef Vector<unsigned long, 9> AccumulateType; - typedef Vector<double, 9> RealType; - typedef double ScalarRealType; - typedef Vector<float, 9> FloatType; - static const Vector<unsigned int, 9> ITKCommon_EXPORT Zero; - static const Vector<unsigned int, 9> ITKCommon_EXPORT One; - static Vector<unsigned int,9> ITKCommon_EXPORT ZeroValue(); - static Vector<unsigned int,9> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<long, 9> > { -public: - typedef long ValueType; - typedef Vector<long, 9> PrintType; - typedef Vector<unsigned long, 9> AbsType; - typedef Vector<long, 9> AccumulateType; - typedef Vector<double, 9> RealType; - typedef double ScalarRealType; - typedef Vector<float, 9> FloatType; - static const Vector<long, 9> ITKCommon_EXPORT Zero; - static const Vector<long, 9> ITKCommon_EXPORT One; - static Vector<long,9> ITKCommon_EXPORT ZeroValue(); - static Vector<long,9> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<unsigned long, 9> > { -public: - typedef unsigned long ValueType; - typedef Vector<unsigned long, 9> PrintType; - typedef Vector<unsigned long, 9> AbsType; - typedef Vector<unsigned long, 9> AccumulateType; - typedef Vector<double, 9> RealType; - typedef double ScalarRealType; - typedef Vector<float, 9> FloatType; - static const Vector<unsigned long, 9> ITKCommon_EXPORT Zero; - static const Vector<unsigned long, 9> ITKCommon_EXPORT One; - static Vector<unsigned long,9> ITKCommon_EXPORT ZeroValue(); - static Vector<unsigned long,9> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<float, 9> > { -public: - typedef float ValueType; - typedef Vector<float, 9> PrintType; - typedef Vector<float, 9> AbsType; - typedef Vector<double, 9> AccumulateType; - typedef Vector<double, 9> RealType; - typedef double ScalarRealType; - typedef Vector<float, 9> FloatType; - static const Vector<float, 9> ITKCommon_EXPORT Zero; - static const Vector<float, 9> ITKCommon_EXPORT One; - static Vector<float, 9> ITKCommon_EXPORT ZeroValue(); - static Vector<float, 9> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<double, 9> > { -public: - typedef double ValueType; - typedef Vector<double, 9> PrintType; - typedef Vector<double, 9> AbsType; - typedef Vector<long double, 9> AccumulateType; - typedef Vector<double, 9> RealType; - typedef double ScalarRealType; - typedef Vector<float, 9> FloatType; - static const Vector<double, 9> ITKCommon_EXPORT Zero; - static const Vector<double, 9> ITKCommon_EXPORT One; - static Vector<double, 9> ITKCommon_EXPORT ZeroValue(); - static Vector<double, 9> ITKCommon_EXPORT OneValue(); -}; -template <> class NumericTraits<Vector<long double, 9> > { -public: - typedef long double ValueType; - typedef Vector<long double, 9> PrintType; - typedef Vector<long double, 9> AbsType; - typedef Vector<long double, 9> AccumulateType; - typedef Vector<long double, 9> RealType; - typedef long double ScalarRealType; - typedef Vector<float, 9> FloatType; - static const Vector<long double, 9> ITKCommon_EXPORT Zero; - static const Vector<long double, 9> ITKCommon_EXPORT One; - static Vector<long double, 9> ITKCommon_EXPORT ZeroValue(); - static Vector<long double, 9> ITKCommon_EXPORT OneValue(); -}; +// +// Instantiate the macros to declare the NumericTraits for the +// Vector types. +// +#ifdef ITK_USE_NUMERIC_TRAITS_PARTIAL_SPECIALIZATION + +itkNumericTraitsGenericArrayScalarsDimensionsMacro( Vector ); + +#else // ITK_USE_NUMERIC_TRAITS_PARTIAL_SPECIALIZATION + +itkNumericTraitsGenericArrayDimensionsMacro( Vector, char ); +itkNumericTraitsGenericArrayDimensionsMacro( Vector, unsigned char ); +itkNumericTraitsGenericArrayDimensionsMacro( Vector, signed char ); +itkNumericTraitsGenericArrayDimensionsMacro( Vector, short ); +itkNumericTraitsGenericArrayDimensionsMacro( Vector, unsigned short ); +itkNumericTraitsGenericArrayDimensionsMacro( Vector, int ); +itkNumericTraitsGenericArrayDimensionsMacro( Vector, unsigned int ); +itkNumericTraitsGenericArrayDimensionsMacro( Vector, long ); +itkNumericTraitsGenericArrayDimensionsMacro( Vector, unsigned long ); +itkNumericTraitsGenericArrayDimensionsMacro( Vector, float ); +itkNumericTraitsGenericArrayDimensionsMacro( Vector, double ); +itkNumericTraitsGenericArrayDimensionsMacro( Vector, long double ); +#ifdef ITK_TYPE_USE_LONG_LONG +itkNumericTraitsGenericArrayDimensionsMacro( Vector, long long ); +itkNumericTraitsGenericArrayDimensionsMacro( Vector, unsigned long long ); +#endif // ITK_TYPE_USE_LONG_LONG + +#endif // ITK_USE_NUMERIC_TRAITS_PARTIAL_SPECIALIZATION } // end namespace itk diff --git a/Utilities/ITK/Code/Common/itkObjectFactoryBase.cxx b/Utilities/ITK/Code/Common/itkObjectFactoryBase.cxx index e404a7b7cb6511a8b407c63065343a6c65f27713..1d460f9f504ca280fde34164a9de040c1b6c1735 100644 --- a/Utilities/ITK/Code/Common/itkObjectFactoryBase.cxx +++ b/Utilities/ITK/Code/Common/itkObjectFactoryBase.cxx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkObjectFactoryBase.cxx,v $ Language: C++ - Date: $Date: 2009-08-23 12:25:21 $ - Version: $Revision: 1.59 $ + Date: $Date: 2009-12-23 14:55:37 $ + Version: $Revision: 1.60 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -141,11 +141,8 @@ ObjectFactoryBase i = m_RegisteredFactories->begin(); i != m_RegisteredFactories->end(); ++i ) { - LightObject::Pointer newobject = (*i)->CreateObject(itkclassname); - if(newobject) - { - created.push_back(newobject); - } + std::list<LightObject::Pointer> moreObjects = (*i)->CreateAllObject( itkclassname ); + created.splice( created.end(), moreObjects ); } return created; } @@ -572,6 +569,25 @@ ObjectFactoryBase } +std::list<LightObject::Pointer> +ObjectFactoryBase +::CreateAllObject(const char* itkclassname) +{ + OverRideMap::iterator start = m_OverrideMap->lower_bound(itkclassname); + OverRideMap::iterator end = m_OverrideMap->upper_bound(itkclassname); + + std::list<LightObject::Pointer> created; + + for ( OverRideMap::iterator i = start; i != end; ++i ) + { + if ( i != m_OverrideMap->end() && (*i).second.m_EnabledFlag) + { + created.push_back( (*i).second.m_CreateObject->CreateObject() ); + } + } + return created; +} + /** * */ diff --git a/Utilities/ITK/Code/Common/itkObjectFactoryBase.h b/Utilities/ITK/Code/Common/itkObjectFactoryBase.h index bf749654b5006b2a02a4638c929f2c21d7351eee..cf9a3487ddf86cf442de6efab20748aaa2905ea3 100644 --- a/Utilities/ITK/Code/Common/itkObjectFactoryBase.h +++ b/Utilities/ITK/Code/Common/itkObjectFactoryBase.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkObjectFactoryBase.h,v $ Language: C++ - Date: $Date: 2007-11-08 16:50:05 $ - Version: $Revision: 1.37 $ + Date: $Date: 2009-12-23 14:55:37 $ + Version: $Revision: 1.38 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -152,7 +152,13 @@ protected: * It should create the named itk object or return 0 if that object * is not supported by the factory implementation. */ virtual LightObject::Pointer CreateObject(const char* itkclassname ); - + + /** This method creates all the objects with the class overide of + * itkclass name, which are provide by this object + */ + virtual std::list<LightObject::Pointer> + CreateAllObject(const char* itkclassname); + ObjectFactoryBase(); virtual ~ObjectFactoryBase(); diff --git a/Utilities/ITK/Code/Common/itkPoint.h b/Utilities/ITK/Code/Common/itkPoint.h index 76fcd9d26305a2bb2c10b41454f7eb127369a273..7ae080a5f7cd68e30fa409f9172f7fa25948a3fe 100644 --- a/Utilities/ITK/Code/Common/itkPoint.h +++ b/Utilities/ITK/Code/Common/itkPoint.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkPoint.h,v $ Language: C++ - Date: $Date: 2009-06-14 11:52:00 $ - Version: $Revision: 1.69 $ + Date: $Date: 2010-03-24 21:51:55 $ + Version: $Revision: 1.70 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -231,7 +231,7 @@ public: for(unsigned int i=0; i<NPointDimension; i++ ) { const RealType component = static_cast< RealType >( pa[i] ); - const ValueType difference = (*this)[i] - component; + const RealType difference = static_cast< RealType >( (*this)[i] ) - component; sum += difference * difference; } return sum; diff --git a/Utilities/ITK/Code/Common/itkProgressReporter.cxx b/Utilities/ITK/Code/Common/itkProgressReporter.cxx index 4c4ecbb8053f4bee7bf44759c241b9481253f708..7ff13f6ce11222c89774f2746356be28c27cf115 100644 --- a/Utilities/ITK/Code/Common/itkProgressReporter.cxx +++ b/Utilities/ITK/Code/Common/itkProgressReporter.cxx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkProgressReporter.cxx,v $ Language: C++ - Date: $Date: 2005-08-24 20:36:52 $ - Version: $Revision: 1.8 $ + Date: $Date: 2009-11-24 02:27:27 $ + Version: $Revision: 1.9 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -50,7 +50,7 @@ ProgressReporter::ProgressReporter(ProcessObject* filter, int threadId, // Calculate the interval for updates. m_PixelsPerUpdate = static_cast<unsigned long>(numPixels/numUpdates); - m_InverseNumberOfPixels = 1.0 / numPixels; + m_InverseNumberOfPixels = 1.0f / numPixels; // Only thread 0 should update progress. (But all threads need to // count pixels so they can check the abort flag.) diff --git a/Utilities/ITK/Code/Common/itkQuaternionRigidTransform.h b/Utilities/ITK/Code/Common/itkQuaternionRigidTransform.h index d30c343982d308d050898bfaceb406e848c080f1..ea8ca98e9b223bfca7bddba610b682e0ff4f82a2 100644 --- a/Utilities/ITK/Code/Common/itkQuaternionRigidTransform.h +++ b/Utilities/ITK/Code/Common/itkQuaternionRigidTransform.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkQuaternionRigidTransform.h,v $ Language: C++ - Date: $Date: 2009-03-03 15:08:23 $ - Version: $Revision: 1.30 $ + Date: $Date: 2009-11-29 01:38:00 $ + Version: $Revision: 1.32 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -69,12 +69,14 @@ public: /** Parameters Type */ typedef typename Superclass::ParametersType ParametersType; + typedef typename Superclass::ParametersValueType ParametersValueType; typedef typename Superclass::JacobianType JacobianType; typedef typename Superclass::ScalarType ScalarType; typedef typename Superclass::InputPointType InputPointType; typedef typename Superclass::OutputPointType OutputPointType; typedef typename Superclass::InputVectorType InputVectorType; typedef typename Superclass::OutputVectorType OutputVectorType; + typedef typename Superclass::OutputVectorValueType OutputVectorValueType; typedef typename Superclass::InputVnlVectorType InputVnlVectorType; typedef typename Superclass::OutputVnlVectorType OutputVnlVectorType; typedef typename Superclass::InputCovariantVectorType diff --git a/Utilities/ITK/Code/Common/itkQuaternionRigidTransform.txx b/Utilities/ITK/Code/Common/itkQuaternionRigidTransform.txx index e2d9af67b03c63dfc08c8a06f72563214292ae52..2f9f7eeea0e6a2a92d6e9c4a56c58525269ff65a 100644 --- a/Utilities/ITK/Code/Common/itkQuaternionRigidTransform.txx +++ b/Utilities/ITK/Code/Common/itkQuaternionRigidTransform.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkQuaternionRigidTransform.txx,v $ Language: C++ - Date: $Date: 2009-03-03 15:08:28 $ - Version: $Revision: 1.31 $ + Date: $Date: 2010-03-30 15:20:02 $ + Version: $Revision: 1.34 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. diff --git a/Utilities/ITK/Code/Common/itkRGBToLuminanceImageAdaptor.h b/Utilities/ITK/Code/Common/itkRGBToLuminanceImageAdaptor.h old mode 100644 new mode 100755 index c0deda49926ea4301b5b4143d32df0733181d38c..75b18232d17a612db7c5f0d93270713d33d0baa7 --- a/Utilities/ITK/Code/Common/itkRGBToLuminanceImageAdaptor.h +++ b/Utilities/ITK/Code/Common/itkRGBToLuminanceImageAdaptor.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkRGBToLuminanceImageAdaptor.h,v $ Language: C++ - Date: $Date: 2009-03-03 15:08:44 $ - Version: $Revision: 1.2 $ + Date: $Date: 2009-09-19 19:56:20 $ + Version: $Revision: 1.3 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -28,7 +28,7 @@ namespace Accessor { * \brief Give access to Luminance of a color pixel type. * * RGBToLuminancePixelAccessor is templated over an internal type and an - * external type representation. This class cast the input applies the funtion + * external type representation. This class cast the input applies the function * to it and cast the result according to the types defined as template * parameters. The input pixel type must support the GetLuminance() method. * This is the case of the RGBPixel class for example. diff --git a/Utilities/ITK/Code/Common/itkRigid2DTransform.h b/Utilities/ITK/Code/Common/itkRigid2DTransform.h index 49a23cde30635344264da21e2de4d12a5be8c6ef..524cb53b41ca5e1319f2f0de59ed6a054a6a81c2 100644 --- a/Utilities/ITK/Code/Common/itkRigid2DTransform.h +++ b/Utilities/ITK/Code/Common/itkRigid2DTransform.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkRigid2DTransform.h,v $ Language: C++ - Date: $Date: 2009-04-09 09:23:21 $ - Version: $Revision: 1.23 $ + Date: $Date: 2009-11-29 01:38:00 $ + Version: $Revision: 1.26 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -80,20 +80,24 @@ public: typedef typename Superclass::ScalarType ScalarType; /** Parameters type. */ - typedef typename Superclass::ParametersType ParametersType; + typedef typename Superclass::ParametersType ParametersType; + typedef typename Superclass::ParametersValueType ParametersValueType; /** Jacobian type. */ typedef typename Superclass::JacobianType JacobianType; /// Standard matrix type for this class - typedef typename Superclass::MatrixType MatrixType; + typedef typename Superclass::MatrixType MatrixType; + typedef typename Superclass::MatrixValueType MatrixValueType; /// Standard vector type for this class - typedef typename Superclass::OffsetType OffsetType; + typedef typename Superclass::OffsetType OffsetType; + typedef typename Superclass::OffsetValueType OffsetValueType; /// Standard vector type for this class - typedef typename Superclass::InputVectorType InputVectorType; - typedef typename Superclass::OutputVectorType OutputVectorType; + typedef typename Superclass::InputVectorType InputVectorType; + typedef typename Superclass::OutputVectorType OutputVectorType; + typedef typename Superclass::OutputVectorValueType OutputVectorValueType; /// Standard covariant vector type for this class typedef typename Superclass::InputCovariantVectorType InputCovariantVectorType; @@ -108,7 +112,7 @@ public: typedef typename Superclass::OutputPointType OutputPointType; /** Base inverse transform type. This type should not be changed to the - * concrete inverse transform type or inheritance would be lost.*/ + * concrete inverse transform type or inheritance would be lost. */ typedef typename Superclass::InverseTransformBaseType InverseTransformBaseType; typedef typename InverseTransformBaseType::Pointer InverseTransformBasePointer; diff --git a/Utilities/ITK/Code/Common/itkRigid2DTransform.txx b/Utilities/ITK/Code/Common/itkRigid2DTransform.txx index 6b333bc93677038acf12ca6b008ebd1d393ff4f4..d5934123a5da11eaf94de4820dd9e723723bdcb8 100644 --- a/Utilities/ITK/Code/Common/itkRigid2DTransform.txx +++ b/Utilities/ITK/Code/Common/itkRigid2DTransform.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkRigid2DTransform.txx,v $ Language: C++ - Date: $Date: 2009-04-09 09:23:21 $ - Version: $Revision: 1.27 $ + Date: $Date: 2010-03-30 15:20:02 $ + Version: $Revision: 1.30 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -222,8 +222,8 @@ void Rigid2DTransform<TScalarType> ::ComputeMatrix( void ) { - const double ca = vcl_cos(m_Angle ); - const double sa = vcl_sin(m_Angle ); + const MatrixValueType ca = vcl_cos(m_Angle); + const MatrixValueType sa = vcl_sin(m_Angle); MatrixType rotationMatrix; rotationMatrix[0][0]= ca; rotationMatrix[0][1]=-sa; @@ -242,10 +242,12 @@ SetParameters( const ParametersType & parameters ) itkDebugMacro( << "Setting parameters " << parameters ); // Set angle - this->SetVarAngle( parameters[0] ); + const TScalarType angle = parameters[0]; + this->SetVarAngle( angle ); // Set translation OutputVectorType translation; + for(unsigned int i=0; i < OutputSpaceDimension; i++) { translation[i] = parameters[i+1]; diff --git a/Utilities/ITK/Code/Common/itkRigid3DPerspectiveTransform.h b/Utilities/ITK/Code/Common/itkRigid3DPerspectiveTransform.h index 713733cad583b4b14a1b6a7b280c11eec8955388..1b6d851b5309f0c3908e8d3fcf42f60152251a1c 100644 --- a/Utilities/ITK/Code/Common/itkRigid3DPerspectiveTransform.h +++ b/Utilities/ITK/Code/Common/itkRigid3DPerspectiveTransform.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkRigid3DPerspectiveTransform.h,v $ Language: C++ - Date: $Date: 2009-03-03 15:08:57 $ - Version: $Revision: 1.31 $ + Date: $Date: 2009-11-28 15:53:15 $ + Version: $Revision: 1.32 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -69,6 +69,7 @@ public: /** Parameters type. */ typedef typename Superclass::ParametersType ParametersType; + typedef typename ParametersType::ValueType ParameterValueType; /** Jacobian type. */ typedef typename Superclass::JacobianType JacobianType; @@ -78,13 +79,14 @@ public: /** Standard vector type for this class. */ typedef Vector<TScalarType, itkGetStaticConstMacro(InputSpaceDimension)> OffsetType; + typedef typename OffsetType::ValueType OffsetValueType; /** Standard vector type for this class. */ - typedef Vector<TScalarType, itkGetStaticConstMacro(InputSpaceDimension)> InputVectorType; - typedef Vector<TScalarType, itkGetStaticConstMacro(OutputSpaceDimension)> OutputVectorType; + typedef Vector<TScalarType, itkGetStaticConstMacro(InputSpaceDimension)> InputVectorType; + typedef Vector<TScalarType, itkGetStaticConstMacro(OutputSpaceDimension)> OutputVectorType; /** Standard coordinate point type for this class. */ - typedef Point<TScalarType, itkGetStaticConstMacro(InputSpaceDimension)> InputPointType; + typedef Point<TScalarType, itkGetStaticConstMacro(InputSpaceDimension)> InputPointType; typedef Point<TScalarType, itkGetStaticConstMacro(OutputSpaceDimension)> OutputPointType; /** Standard vnl_quaternion type. */ @@ -94,6 +96,7 @@ public: typedef Versor<TScalarType> VersorType; typedef typename VersorType::VectorType AxisType; typedef typename VersorType::ValueType AngleType; + typedef typename AxisType::ValueType AxisValueType; /** Get offset of an Rigid3DPerspectiveTransform * This method returns the value of the offset of the diff --git a/Utilities/ITK/Code/Common/itkRigid3DPerspectiveTransform.txx b/Utilities/ITK/Code/Common/itkRigid3DPerspectiveTransform.txx index c49e7d1a0aed527602034ddf4f3ed40f0534ed65..948d20c4df7e5faa758e27b425e87faf3abf5970 100644 --- a/Utilities/ITK/Code/Common/itkRigid3DPerspectiveTransform.txx +++ b/Utilities/ITK/Code/Common/itkRigid3DPerspectiveTransform.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkRigid3DPerspectiveTransform.txx,v $ Language: C++ - Date: $Date: 2009-03-03 15:08:59 $ - Version: $Revision: 1.31 $ + Date: $Date: 2010-03-30 15:20:02 $ + Version: $Revision: 1.33 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -84,7 +84,7 @@ Rigid3DPerspectiveTransform<TScalarType> axis[1] = parameters[1]; norm += parameters[2]*parameters[2]; axis[2] = parameters[2]; - if( norm > 0) + if( norm > NumericTraits<double>::Zero ) { norm = vcl_sqrt(norm); } diff --git a/Utilities/ITK/Code/Common/itkRigid3DTransform.h b/Utilities/ITK/Code/Common/itkRigid3DTransform.h index f422bedc855469c075f1090e1e19d54b6687cd84..9d9eb7eb1d0bc4cd48c16b60ab61b746312f63c9 100644 --- a/Utilities/ITK/Code/Common/itkRigid3DTransform.h +++ b/Utilities/ITK/Code/Common/itkRigid3DTransform.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkRigid3DTransform.h,v $ Language: C++ - Date: $Date: 2009-06-17 12:17:38 $ - Version: $Revision: 1.41 $ + Date: $Date: 2009-11-28 15:58:04 $ + Version: $Revision: 1.43 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -70,10 +70,12 @@ public: itkStaticConstMacro(ParametersDimension, unsigned int, 12); typedef typename Superclass::ParametersType ParametersType; + typedef typename Superclass::ParametersValueType ParametersValueType; typedef typename Superclass::JacobianType JacobianType; typedef typename Superclass::ScalarType ScalarType; typedef typename Superclass::InputVectorType InputVectorType; typedef typename Superclass::OutputVectorType OutputVectorType; + typedef typename Superclass::OutputVectorValueType OutputVectorValueType; typedef typename Superclass::InputCovariantVectorType InputCovariantVectorType; typedef typename Superclass::OutputCovariantVectorType @@ -84,12 +86,13 @@ public: typedef typename Superclass::OutputPointType OutputPointType; typedef typename Superclass::MatrixType MatrixType; typedef typename Superclass::InverseMatrixType InverseMatrixType; + typedef typename Superclass::MatrixValueType MatrixValueType; typedef typename Superclass::CenterType CenterType; typedef typename Superclass::TranslationType TranslationType; typedef typename Superclass::OffsetType OffsetType; /** Base inverse transform type. This type should not be changed to the - * concrete inverse transform type or inheritance would be lost.*/ + * concrete inverse transform type or inheritance would be lost. */ typedef typename Superclass::InverseTransformBaseType InverseTransformBaseType; typedef typename InverseTransformBaseType::Pointer InverseTransformBasePointer; diff --git a/Utilities/ITK/Code/Common/itkRigid3DTransform.txx b/Utilities/ITK/Code/Common/itkRigid3DTransform.txx index 1c627227d62c978ec92a6c94deb8348927a94e83..5b12d359aaa3b64bddaad98079c7ef2ccdad4fcd 100644 --- a/Utilities/ITK/Code/Common/itkRigid3DTransform.txx +++ b/Utilities/ITK/Code/Common/itkRigid3DTransform.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkRigid3DTransform.txx,v $ Language: C++ - Date: $Date: 2009-04-09 09:23:21 $ - Version: $Revision: 1.38 $ + Date: $Date: 2010-03-30 15:20:02 $ + Version: $Revision: 1.40 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. diff --git a/Utilities/ITK/Code/Common/itkScalableAffineTransform.h b/Utilities/ITK/Code/Common/itkScalableAffineTransform.h old mode 100644 new mode 100755 index c17c17d813ac6721d9cbf8b9abbbf55ad25ae12a..ceb049a70540e1796778b31c66b024f85633efbd --- a/Utilities/ITK/Code/Common/itkScalableAffineTransform.h +++ b/Utilities/ITK/Code/Common/itkScalableAffineTransform.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkScalableAffineTransform.h,v $ Language: C++ - Date: $Date: 2009-04-09 09:23:21 $ - Version: $Revision: 1.5 $ + Date: $Date: 2009-11-28 15:58:04 $ + Version: $Revision: 1.7 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -63,6 +63,7 @@ public: /** Types taken from the Superclass */ typedef typename Superclass::ParametersType ParametersType; + typedef typename Superclass::ParametersValueType ParametersValueType; typedef typename Superclass::JacobianType JacobianType; typedef typename Superclass::ScalarType ScalarType; typedef typename Superclass::InputVectorType InputVectorType; @@ -74,13 +75,14 @@ public: typedef typename Superclass::InputPointType InputPointType; typedef typename Superclass::OutputPointType OutputPointType; typedef typename Superclass::MatrixType MatrixType; + typedef typename Superclass::MatrixValueType MatrixValueType; typedef typename Superclass::InverseMatrixType InverseMatrixType; typedef typename Superclass::CenterType CenterType; typedef typename Superclass::OffsetType OffsetType; typedef typename Superclass::TranslationType TranslationType; /** Base inverse transform type. This type should not be changed to the - * concrete inverse transform type or inheritance would be lost.*/ + * concrete inverse transform type or inheritance would be lost. */ typedef typename Superclass::InverseTransformBaseType InverseTransformBaseType; typedef typename InverseTransformBaseType::Pointer InverseTransformBasePointer; diff --git a/Utilities/ITK/Code/Common/itkScalableAffineTransform.txx b/Utilities/ITK/Code/Common/itkScalableAffineTransform.txx old mode 100644 new mode 100755 index df09d2c83c42ede9f3c4ef948b3f9c8b53f15c8f..4485176a3bade19709b60e76d8ae93002586b3b7 --- a/Utilities/ITK/Code/Common/itkScalableAffineTransform.txx +++ b/Utilities/ITK/Code/Common/itkScalableAffineTransform.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkScalableAffineTransform.txx,v $ Language: C++ - Date: $Date: 2009-04-09 09:23:21 $ - Version: $Revision: 1.5 $ + Date: $Date: 2010-03-30 15:20:02 $ + Version: $Revision: 1.8 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -181,19 +181,19 @@ ScalableAffineTransform<TScalarType, NDimensions> if ( i < NDimensions ) { MatrixType mat; + typename MatrixType::InternalMatrixType & imat = mat.GetVnlMatrix(); for (i=0; i<NDimensions; i++) { if(m_MatrixScale[i] != 0 && m_Scale[i] != 0) { - mat.GetVnlMatrix().put(i, i, m_Scale[i]/m_MatrixScale[i] - * this->GetMatrix()[i][i]); + imat.put(i, i, m_Scale[i]/m_MatrixScale[i] * this->GetMatrix()[i][i]); m_MatrixScale[i] = m_Scale[i]; } else { m_Scale[i] = 1; m_MatrixScale[i] = 1; - mat.GetVnlMatrix().put(i, i, this->GetMatrix()[i][i]); + imat.put(i, i, this->GetMatrix()[i][i]); } } Superclass::SetVarMatrix(mat); diff --git a/Utilities/ITK/Code/Common/itkScaleLogarithmicTransform.h b/Utilities/ITK/Code/Common/itkScaleLogarithmicTransform.h index fa128a7b08f992c286f08dfe4c78d767739c9eba..3c0d13862be9a3e581120b45373f5d31b0416bc6 100644 --- a/Utilities/ITK/Code/Common/itkScaleLogarithmicTransform.h +++ b/Utilities/ITK/Code/Common/itkScaleLogarithmicTransform.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkScaleLogarithmicTransform.h,v $ Language: C++ - Date: $Date: 2009-03-03 15:09:07 $ - Version: $Revision: 1.4 $ + Date: $Date: 2009-11-24 02:27:27 $ + Version: $Revision: 1.5 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -61,12 +61,14 @@ public: /** Parameters type. */ typedef typename Superclass::ParametersType ParametersType; + typedef typename ParametersType::ValueType ParametersValueType; /** Jacobian type. */ typedef typename Superclass::JacobianType JacobianType; /** Standard vector type for this class. */ typedef typename Superclass::ScaleType ScaleType; + typedef typename ScaleType::ValueType ScalesValueType; /** Standard vector type for this class. */ typedef typename Superclass::InputVectorType InputVectorType; diff --git a/Utilities/ITK/Code/Common/itkScaleLogarithmicTransform.txx b/Utilities/ITK/Code/Common/itkScaleLogarithmicTransform.txx index 2027b3b57037ee223f23da689762748016dc60b3..5904d8d06bad2a83c5098423011662be9212dc04 100644 --- a/Utilities/ITK/Code/Common/itkScaleLogarithmicTransform.txx +++ b/Utilities/ITK/Code/Common/itkScaleLogarithmicTransform.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkScaleLogarithmicTransform.txx,v $ Language: C++ - Date: $Date: 2009-03-03 15:09:08 $ - Version: $Revision: 1.6 $ + Date: $Date: 2010-03-30 15:20:02 $ + Version: $Revision: 1.8 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. diff --git a/Utilities/ITK/Code/Common/itkScaleSkewVersor3DTransform.h b/Utilities/ITK/Code/Common/itkScaleSkewVersor3DTransform.h index 0db6519710d8935be07ccfafd215af13cc8b8b34..8a1e3a988d3fe1d506a4e041dec5a42b8e8eb4ef 100644 --- a/Utilities/ITK/Code/Common/itkScaleSkewVersor3DTransform.h +++ b/Utilities/ITK/Code/Common/itkScaleSkewVersor3DTransform.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkScaleSkewVersor3DTransform.h,v $ Language: C++ - Date: $Date: 2009-03-03 15:09:08 $ - Version: $Revision: 1.14 $ + Date: $Date: 2009-11-24 15:25:11 $ + Version: $Revision: 1.16 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -96,6 +96,14 @@ public: ScaleVectorType; typedef Vector<TScalarType, 6 > SkewVectorType; + typedef typename ScaleVectorType::ValueType ScaleVectorValueType; + typedef typename SkewVectorType::ValueType SkewVectorValueType; + typedef typename TranslationType::ValueType TranslationValueType; + + typedef typename Superclass::AxisValueType AxisValueType; + typedef typename Superclass::ParameterValueType ParameterValueType; + + /** Directly set the matrix of the transform. * * \sa MatrixOffsetTransformBase::SetMatrix() */ diff --git a/Utilities/ITK/Code/Common/itkScaleSkewVersor3DTransform.txx b/Utilities/ITK/Code/Common/itkScaleSkewVersor3DTransform.txx index 6058e59aeeb1cd096cd0f2179271bd02839be47f..8bca5c403043719f6539c2bf424cb9145bee3dc4 100644 --- a/Utilities/ITK/Code/Common/itkScaleSkewVersor3DTransform.txx +++ b/Utilities/ITK/Code/Common/itkScaleSkewVersor3DTransform.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkScaleSkewVersor3DTransform.txx,v $ Language: C++ - Date: $Date: 2009-03-03 15:09:08 $ - Version: $Revision: 1.17 $ + Date: $Date: 2010-03-30 15:20:02 $ + Version: $Revision: 1.20 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -18,6 +18,7 @@ #define __itkScaleSkewVersor3DTransform_txx #include "itkScaleSkewVersor3DTransform.h" +#include "itkMath.h" namespace itk @@ -29,8 +30,8 @@ ScaleSkewVersor3DTransform<TScalarType> ::ScaleSkewVersor3DTransform() : Superclass(OutputSpaceDimension, ParametersDimension) { - m_Scale.Fill( 1.0 ); - m_Skew.Fill( 0.0 ); + m_Scale.Fill( NumericTraits<TScalarType>::One ); + m_Skew.Fill( NumericTraits<TScalarType>::Zero ); } @@ -120,6 +121,7 @@ ScaleSkewVersor3DTransform<TScalarType> newTranslation[0] = parameters[3]; newTranslation[1] = parameters[4]; newTranslation[2] = parameters[5]; + this->SetVarTranslation(newTranslation); this->ComputeMatrix(); this->ComputeOffset(); @@ -178,8 +180,8 @@ void ScaleSkewVersor3DTransform<TScalarType> ::SetIdentity() { - m_Scale.Fill( 1.0 ); - m_Skew.Fill( 0.0 ); + m_Scale.Fill( NumericTraits< ScaleVectorValueType >::One ); + m_Skew.Fill( NumericTraits< SkewVectorValueType >::Zero ); Superclass::SetIdentity(); } diff --git a/Utilities/ITK/Code/Common/itkScaleTransform.txx b/Utilities/ITK/Code/Common/itkScaleTransform.txx index abae0d1a53f0fef4ce272835a28c000e488ce879..6024278e31ec00836d8ded6c0a2589a602d63184 100644 --- a/Utilities/ITK/Code/Common/itkScaleTransform.txx +++ b/Utilities/ITK/Code/Common/itkScaleTransform.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkScaleTransform.txx,v $ Language: C++ - Date: $Date: 2009-04-09 09:23:21 $ - Version: $Revision: 1.23 $ + Date: $Date: 2010-03-30 15:20:02 $ + Version: $Revision: 1.26 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -18,6 +18,7 @@ #define __itkScaleTransform_txx #include "itkScaleTransform.h" +#include "itkMath.h" namespace itk @@ -49,6 +50,7 @@ void ScaleTransform<ScalarType, NDimensions> ::SetParameters( const ParametersType & parameters ) { + typedef typename ParametersType::ValueType ParameterValueType; for( unsigned int i=0; i<SpaceDimension; i++ ) { m_Scale[i] = parameters[i]; @@ -193,7 +195,7 @@ GetInverse(Self* inverse) const for( unsigned int i=0; i<SpaceDimension; i++ ) { - inverse->m_Scale[i] = 1.0 / m_Scale[i]; + inverse->m_Scale[i] = NumericTraits< double >::One / m_Scale[i]; } return true; @@ -206,7 +208,11 @@ ScaleTransform<ScalarType, NDimensions> ::GetInverseTransform() const { Pointer inv = New(); - return GetInverse(inv) ? inv.GetPointer() : NULL; + if( this->GetInverse(inv) ) + { + return inv.GetPointer(); + } + return NULL; } diff --git a/Utilities/ITK/Code/Common/itkScatterMatrixImageFunction.h b/Utilities/ITK/Code/Common/itkScatterMatrixImageFunction.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Common/itkScatterMatrixImageFunction.txx b/Utilities/ITK/Code/Common/itkScatterMatrixImageFunction.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Common/itkSemaphore.h b/Utilities/ITK/Code/Common/itkSemaphore.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Common/itkSimilarity2DTransform.h b/Utilities/ITK/Code/Common/itkSimilarity2DTransform.h index 319863bb2bcbe7dd1c272bbf747fe39dcd9f6338..cefb080e6e68925946f9555eb52a5082d4e13095 100644 --- a/Utilities/ITK/Code/Common/itkSimilarity2DTransform.h +++ b/Utilities/ITK/Code/Common/itkSimilarity2DTransform.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkSimilarity2DTransform.h,v $ Language: C++ - Date: $Date: 2009-04-09 09:23:21 $ - Version: $Revision: 1.13 $ + Date: $Date: 2009-11-28 15:58:04 $ + Version: $Revision: 1.15 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -87,16 +87,19 @@ public: typedef TScalarType ScaleType; /** Parameters type. */ - typedef typename Superclass::ParametersType ParametersType; + typedef typename Superclass::ParametersType ParametersType; + typedef typename Superclass::ParametersValueType ParametersValueType; /** Jacobian type. */ typedef typename Superclass::JacobianType JacobianType; /** Offset type. */ - typedef typename Superclass::OffsetType OffsetType; + typedef typename Superclass::OffsetType OffsetType; + typedef typename Superclass::OffsetValueType OffsetValueType; /** Matrix type. */ - typedef typename Superclass::MatrixType MatrixType; + typedef typename Superclass::MatrixType MatrixType; + typedef typename Superclass::MatrixValueType MatrixValueType; /** Point type. */ typedef typename Superclass::InputPointType InputPointType; @@ -115,7 +118,7 @@ public: typedef typename Superclass::OutputVnlVectorType OutputVnlVectorType; /** Base inverse transform type. This type should not be changed to the - * concrete inverse transform type or inheritance would be lost.*/ + * concrete inverse transform type or inheritance would be lost. */ typedef typename Superclass::InverseTransformBaseType InverseTransformBaseType; typedef typename InverseTransformBaseType::Pointer InverseTransformBasePointer; diff --git a/Utilities/ITK/Code/Common/itkSimilarity2DTransform.txx b/Utilities/ITK/Code/Common/itkSimilarity2DTransform.txx index 85005184f7ba1a3c58027d892de404e33748c699..04d6fa620e873d1b46acbb71d71f19a1db4d73e2 100644 --- a/Utilities/ITK/Code/Common/itkSimilarity2DTransform.txx +++ b/Utilities/ITK/Code/Common/itkSimilarity2DTransform.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkSimilarity2DTransform.txx,v $ Language: C++ - Date: $Date: 2009-04-09 09:23:21 $ - Version: $Revision: 1.25 $ + Date: $Date: 2010-03-30 15:20:02 $ + Version: $Revision: 1.27 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -51,10 +51,12 @@ Similarity2DTransform<TScalarType> itkDebugMacro( << "Setting parameters " << parameters ); // Set scale - this->SetVarScale( parameters[0] ); + const TScalarType scale = parameters[0]; + this->SetVarScale( scale ); // Set angle - this->SetVarAngle( parameters[1] ); + const TScalarType angle = parameters[1]; + this->SetVarAngle( angle ); // Set translation OffsetType translation; @@ -121,8 +123,8 @@ Similarity2DTransform<TScalarType> const double cc = vcl_cos(angle ); const double ss = vcl_sin(angle ); - const double ca = cc * m_Scale; - const double sa = ss * m_Scale; + const MatrixValueType ca = cc * m_Scale; + const MatrixValueType sa = ss * m_Scale; MatrixType matrix; matrix[0][0]= ca; matrix[0][1]=-sa; @@ -236,7 +238,7 @@ GetInverse( Self* inverse) const } inverse->SetCenter( this->GetCenter() ); // inverse have the same center - inverse->SetScale( 1.0 / this->GetScale() ); + inverse->SetScale( NumericTraits<double>::One / this->GetScale() ); inverse->SetAngle( -this->GetAngle() ); inverse->SetTranslation( -( this->GetInverseMatrix() * this->GetTranslation() ) ); @@ -250,7 +252,11 @@ Similarity2DTransform<TScalarType> ::GetInverseTransform() const { Pointer inv = New(); - return GetInverse(inv) ? inv.GetPointer() : NULL; + if( this->GetInverse(inv) ) + { + return inv.GetPointer(); + } + return NULL; } // Create and return a clone of the transformation diff --git a/Utilities/ITK/Code/Common/itkSimpleFilterWatcher.cxx b/Utilities/ITK/Code/Common/itkSimpleFilterWatcher.cxx old mode 100644 new mode 100755 index 215d526b9af9bcb58b6c9f06b8550f693a643029..bb6df5623c53f4657949876a80d3d2a4de51702b --- a/Utilities/ITK/Code/Common/itkSimpleFilterWatcher.cxx +++ b/Utilities/ITK/Code/Common/itkSimpleFilterWatcher.cxx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkSimpleFilterWatcher.cxx,v $ Language: C++ - Date: $Date: 2009-03-03 15:09:25 $ - Version: $Revision: 1.6 $ + Date: $Date: 2009-10-04 13:12:33 $ + Version: $Revision: 1.8 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -31,6 +31,7 @@ SimpleFilterWatcher m_Steps = 0; m_Comment = comment; m_TestAbort = false; + m_Iterations = 0; #if defined(_COMPILER_VERSION) && (_COMPILER_VERSION == 730) m_Quiet = true; #else @@ -76,6 +77,7 @@ SimpleFilterWatcher m_Steps = 0; m_Comment = "Not watching an object"; m_TestAbort = false; + m_Iterations = 0; #if defined(_COMPILER_VERSION) && (_COMPILER_VERSION == 730) m_Quiet = true; #else @@ -117,6 +119,7 @@ SimpleFilterWatcher m_TimeProbe = watch.m_TimeProbe; m_Process = watch.m_Process; m_Steps = watch.m_Steps; + m_Iterations = watch.m_Iterations; m_Comment = watch.m_Comment; m_TestAbort = watch.m_TestAbort; m_Quiet = watch.m_Quiet; @@ -194,6 +197,7 @@ SimpleFilterWatcher m_TimeProbe = watch.m_TimeProbe; m_Process = watch.m_Process; m_Steps = watch.m_Steps; + m_Iterations = watch.m_Iterations; m_Comment = watch.m_Comment; m_TestAbort = watch.m_TestAbort; m_Quiet = watch.m_Quiet; diff --git a/Utilities/ITK/Code/Common/itkSimpleFilterWatcher.h b/Utilities/ITK/Code/Common/itkSimpleFilterWatcher.h old mode 100644 new mode 100755 index aa1feeb2c4fcef92d00f204c1766359dfdcbf617..f8ac3c23e0908b83402def8af98880755f3df8b1 --- a/Utilities/ITK/Code/Common/itkSimpleFilterWatcher.h +++ b/Utilities/ITK/Code/Common/itkSimpleFilterWatcher.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkSimpleFilterWatcher.h,v $ Language: C++ - Date: $Date: 2009-03-03 15:09:25 $ - Version: $Revision: 1.10 $ + Date: $Date: 2009-10-02 12:39:50 $ + Version: $Revision: 1.11 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -26,7 +26,8 @@ namespace itk { /** \class SimpleFilterWatcher - * \brief Simple mechanism for monitoring the pipeline events of a filter and reporting these events to std::cout + * \brief Simple mechanism for monitoring the pipeline events of a filter + * and reporting these events to std::cout. * * SimpleFilterWatcher provides a simple mechanism for monitoring the * execution of filter. SimpleFilterWatcher is a stack-based object @@ -110,7 +111,7 @@ public: void SetIterations(int val) {m_Iterations=val;} int GetIterations() {return m_Iterations;} - /** Set/Get the quiet mode boolean. If true, verbose progess is + /** Set/Get the quiet mode boolean. If true, verbose progress is * reported. */ void SetQuiet(bool val) {m_Quiet=val;} bool GetQuiet() {return m_Quiet;} diff --git a/Utilities/ITK/Code/Common/itkSinImageAdaptor.h b/Utilities/ITK/Code/Common/itkSinImageAdaptor.h index b187b214cfc02a5c0653a8d24c9971ead971f9b8..91b30e4bb32449ef5e22cf783821317dd6172bca 100644 --- a/Utilities/ITK/Code/Common/itkSinImageAdaptor.h +++ b/Utilities/ITK/Code/Common/itkSinImageAdaptor.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkSinImageAdaptor.h,v $ Language: C++ - Date: $Date: 2006-04-01 13:44:21 $ - Version: $Revision: 1.13 $ + Date: $Date: 2009-09-19 19:56:20 $ + Version: $Revision: 1.14 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -29,7 +29,7 @@ namespace Accessor { * * SinPixelAccessor is templated over an internal type and an * external type representation. This class cast the input - * applies the funtion to it and cast the result according + * applies the function to it and cast the result according * to the types defined as template parameters * * \ingroup ImageAdaptors diff --git a/Utilities/ITK/Code/Common/itkSmapsFileParser.cxx b/Utilities/ITK/Code/Common/itkSmapsFileParser.cxx index 752965dd2dc29113f946d33dcda1209ac4f33d2f..e04fe6ba3267548511ecbb4f6b69ac0d20b23801 100644 --- a/Utilities/ITK/Code/Common/itkSmapsFileParser.cxx +++ b/Utilities/ITK/Code/Common/itkSmapsFileParser.cxx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkSmapsFileParser.cxx,v $ Language: C++ - Date: $Date: 2009-04-05 10:56:46 $ - Version: $Revision: 1.3 $ + Date: $Date: 2009-11-24 02:27:28 $ + Version: $Revision: 1.4 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -74,7 +74,7 @@ ITKCommon_EXPORT std::istream& operator>>(std::istream &in, SmapsRecord &record } std::string token; - int lastPos = in.tellg(); + std::streampos lastPos = in.tellg(); // a token is defined with the following expression: "token: N kB" while ( std::getline(in,token,':').good() ) { diff --git a/Utilities/ITK/Code/Common/itkSmartPointerForwardReferenceProcessObject.cxx b/Utilities/ITK/Code/Common/itkSmartPointerForwardReferenceProcessObject.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Common/itkSobelOperator.h b/Utilities/ITK/Code/Common/itkSobelOperator.h index b34967e73c97b9e23bd7783720b4f90b7bbf33e6..3a291358eb25234252fcc77aa0e97c7fb8f58aa8 100644 --- a/Utilities/ITK/Code/Common/itkSobelOperator.h +++ b/Utilities/ITK/Code/Common/itkSobelOperator.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkSobelOperator.h,v $ Language: C++ - Date: $Date: 2009-03-03 15:09:30 $ - Version: $Revision: 1.10 $ + Date: $Date: 2010-02-26 05:28:25 $ + Version: $Revision: 1.11 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -33,12 +33,13 @@ namespace itk { * applied a NeighborhoodIterator using the NeighborhoodInnerProduct * method. To create the operator: * - * 1) Set the direction by calling \code{SetDirection} - * 2) call \code{CreateOperator()} + * 1) Set the direction by calling \code SetDirection \endcode + * 2) call \code CreateOperator() \endcode * 3) You may optionally scale the coefficients of this operator using the - * \code{ScaleCoefficients} method. This is useful if you want to take the - * spacing of the image into account when computing the edge strength. Apply - * the scaling only after calling to \code{CreateOperator}. + * \code ScaleCoefficients \endcode method. This is useful if you + * want to take the spacing of the image into account when computing + * the edge strength. Apply the scaling only after calling to + * \code CreateOperator \endcode. * * The Sobel Operator in vertical direction for 2 dimensions is * \verbatim @@ -71,8 +72,8 @@ namespace itk { * x-1 x x+1 * \endverbatim * - * The \code{x} kernel is just rotated as required to obtain the kernel in the - * \code{y} and \code{z} directions. + * The \c x kernel is just rotated as required to obtain the kernel in the + * \c y and \c z directions. * * \sa NeighborhoodOperator * \sa Neighborhood diff --git a/Utilities/ITK/Code/Common/itkSphereSpatialFunction.txx b/Utilities/ITK/Code/Common/itkSphereSpatialFunction.txx index ed8296e1b288a9f97ff22a2a79a5626a0f9a854d..bf8c27b1f9d168310b72e55c52488293e76beb31 100644 --- a/Utilities/ITK/Code/Common/itkSphereSpatialFunction.txx +++ b/Utilities/ITK/Code/Common/itkSphereSpatialFunction.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkSphereSpatialFunction.txx,v $ Language: C++ - Date: $Date: 2003-09-10 14:29:26 $ - Version: $Revision: 1.14 $ + Date: $Date: 2009-11-24 02:27:28 $ + Version: $Revision: 1.15 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -28,7 +28,7 @@ SphereSpatialFunction<VImageDimension,TInput> { m_Radius = 1.0; - m_Center.Fill(0.0); + m_Center.Fill(0.0f); } template <unsigned int VImageDimension,typename TInput> diff --git a/Utilities/ITK/Code/Common/itkSqrtImageAdaptor.h b/Utilities/ITK/Code/Common/itkSqrtImageAdaptor.h index fd5b6ae5f72b2a90e493ba3cbc7138615248662e..4ebeb50575d6a63ca23337e25f8e85ce73d6be6e 100644 --- a/Utilities/ITK/Code/Common/itkSqrtImageAdaptor.h +++ b/Utilities/ITK/Code/Common/itkSqrtImageAdaptor.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkSqrtImageAdaptor.h,v $ Language: C++ - Date: $Date: 2006-03-19 04:36:59 $ - Version: $Revision: 1.13 $ + Date: $Date: 2009-09-19 19:56:20 $ + Version: $Revision: 1.14 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -29,7 +29,7 @@ namespace Accessor { * * SqrtPixelAccessor is templated over an internal type and an * external type representation. This class cast the input - * applies the funtion to it and cast the result according + * applies the function to it and cast the result according * to the types defined as template parameters * * \ingroup ImageAdaptors diff --git a/Utilities/ITK/Code/Common/itkSumOfSquaresImageFunction.h b/Utilities/ITK/Code/Common/itkSumOfSquaresImageFunction.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Common/itkSumOfSquaresImageFunction.txx b/Utilities/ITK/Code/Common/itkSumOfSquaresImageFunction.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Common/itkSymmetricSecondRankTensor.h b/Utilities/ITK/Code/Common/itkSymmetricSecondRankTensor.h index d48b852f31a8f0765bd0ce43b7bb7eae997a9eab..a28b03f5adbfd45f18d69f439641e7767deb4323 100644 --- a/Utilities/ITK/Code/Common/itkSymmetricSecondRankTensor.h +++ b/Utilities/ITK/Code/Common/itkSymmetricSecondRankTensor.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkSymmetricSecondRankTensor.h,v $ Language: C++ - Date: $Date: 2009-03-03 15:09:43 $ - Version: $Revision: 1.26 $ + Date: $Date: 2010-04-09 21:25:10 $ + Version: $Revision: 1.29 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -108,14 +108,25 @@ public: SymmetricSecondRankTensor (const ComponentType& r) { this->Fill(r); } + /** Constructor to enable casting... */ + template < typename TCoordRepB > + SymmetricSecondRankTensor( const SymmetricSecondRankTensor<TCoordRepB,NDimension> & pa ): + BaseArray(pa) { } + typedef ComponentType ComponentArrayType[ itkGetStaticConstMacro(InternalDimension) ]; /** Pass-through constructor for the Array base class. */ - SymmetricSecondRankTensor(const Self& r): BaseArray(r) {} SymmetricSecondRankTensor(const ComponentArrayType r): BaseArray(r) {} - + + /** Templated Pass-through assignment for the Array base class. */ + template < typename TCoordRepB > + Self& operator= ( const SymmetricSecondRankTensor<TCoordRepB,NDimension> & pa ) + { + BaseArray::operator=(pa); + return *this; + } + /** Pass-through assignment operator for the Array base class. */ - Self& operator= (const Self& r); Self& operator= (const ComponentType& r); Self& operator= (const ComponentArrayType r); diff --git a/Utilities/ITK/Code/Common/itkSymmetricSecondRankTensor.txx b/Utilities/ITK/Code/Common/itkSymmetricSecondRankTensor.txx index 9ff8e1a35885f490691b84e9c4ff97247d4c617a..d10a4fd09f2cd8d16c3bbeea8a584d46857083b1 100644 --- a/Utilities/ITK/Code/Common/itkSymmetricSecondRankTensor.txx +++ b/Utilities/ITK/Code/Common/itkSymmetricSecondRankTensor.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkSymmetricSecondRankTensor.txx,v $ Language: C++ - Date: $Date: 2009-03-03 15:09:43 $ - Version: $Revision: 1.15 $ + Date: $Date: 2010-03-17 16:34:47 $ + Version: $Revision: 1.16 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -23,18 +23,6 @@ namespace itk { -/** - * Assignment Operator - */ -template<class T,unsigned int NDimension> -SymmetricSecondRankTensor<T,NDimension>& -SymmetricSecondRankTensor<T,NDimension> -::operator= (const Self& r) -{ - BaseArray::operator=(r); - return *this; -} - /** * Assignment Operator from a scalar constant diff --git a/Utilities/ITK/Code/Common/itkTanImageAdaptor.h b/Utilities/ITK/Code/Common/itkTanImageAdaptor.h index b4c5fc3d4e81bf8def9b07690382367accc870e2..d4c2abbfe0496a60f7d15fd94bc7d26c13a34639 100644 --- a/Utilities/ITK/Code/Common/itkTanImageAdaptor.h +++ b/Utilities/ITK/Code/Common/itkTanImageAdaptor.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkTanImageAdaptor.h,v $ Language: C++ - Date: $Date: 2009-03-03 15:09:43 $ - Version: $Revision: 1.13 $ + Date: $Date: 2009-09-19 19:53:16 $ + Version: $Revision: 1.14 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -29,7 +29,7 @@ namespace Accessor { * * TanPixelAccessor is templated over an internal type and an * external type representation. This class cast the input - * applies the funtion to it and cast the result according + * applies the function to it and cast the result according * to the types defined as template parameters * * \ingroup ImageAdaptors diff --git a/Utilities/ITK/Code/Common/itkTextOutput.cxx b/Utilities/ITK/Code/Common/itkTextOutput.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Common/itkTransform.h b/Utilities/ITK/Code/Common/itkTransform.h index 31b5080473fb6658c9ccd509027d4d35c6cb5b79..fdf9984cd4a86f74565c5769335439d5d918275e 100644 --- a/Utilities/ITK/Code/Common/itkTransform.h +++ b/Utilities/ITK/Code/Common/itkTransform.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkTransform.h,v $ Language: C++ - Date: $Date: 2009-09-08 01:00:58 $ - Version: $Revision: 1.72 $ + Date: $Date: 2009-11-28 15:53:16 $ + Version: $Revision: 1.73 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -95,6 +95,7 @@ public: /** Type of the input parameters. */ typedef typename Superclass::ParametersType ParametersType; + typedef typename Superclass::ParametersValueType ParametersValueType; /** Type of the Jacobian matrix. */ typedef Array2D< double > JacobianType; diff --git a/Utilities/ITK/Code/Common/itkTransformBase.h b/Utilities/ITK/Code/Common/itkTransformBase.h index fbe3a017814e0068654e1d50181ebf8a3ab15382..e7fb87ac563e35e5f446917f588bed44155fc950 100644 --- a/Utilities/ITK/Code/Common/itkTransformBase.h +++ b/Utilities/ITK/Code/Common/itkTransformBase.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkTransformBase.h,v $ Language: C++ - Date: $Date: 2009-03-03 15:10:26 $ - Version: $Revision: 1.8 $ + Date: $Date: 2009-11-28 15:53:16 $ + Version: $Revision: 1.9 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -46,7 +46,8 @@ public: typedef SmartPointer< const Self > ConstPointer; /** Type of the input parameters. */ - typedef Array< double > ParametersType; + typedef double ParametersValueType; + typedef Array< ParametersValueType > ParametersType; /** Run-time type information (and related methods). */ itkTypeMacro( TransformBase, Object ); diff --git a/Utilities/ITK/Code/Common/itkTranslationTransform.txx b/Utilities/ITK/Code/Common/itkTranslationTransform.txx index 5c0a340eee467566ddbdcfe2408c25f76ea9e212..d490f5cdf77de2d471821fd9a2e89f5700ba6a4b 100644 --- a/Utilities/ITK/Code/Common/itkTranslationTransform.txx +++ b/Utilities/ITK/Code/Common/itkTranslationTransform.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkTranslationTransform.txx,v $ Language: C++ - Date: $Date: 2009-04-09 09:23:26 $ - Version: $Revision: 1.33 $ + Date: $Date: 2010-03-30 15:20:02 $ + Version: $Revision: 1.35 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -18,6 +18,7 @@ #define __itkTranslationTransform_txx #include "itkTranslationTransform.h" +#include "itkMath.h" namespace itk @@ -58,6 +59,7 @@ void TranslationTransform<TScalarType, NDimensions> ::SetParameters( const ParametersType & parameters ) { + typedef typename ParametersType::ValueType ParameterValueType; bool modified = false; for( unsigned int i=0; i<SpaceDimension; i++ ) { diff --git a/Utilities/ITK/Code/Common/itkTriangleCell.txx b/Utilities/ITK/Code/Common/itkTriangleCell.txx index ff9d34eb8dd7ea75554d47666e796dc4bc785f7e..f09345465ff993e33a7d15dc746aeafdb43d8642 100644 --- a/Utilities/ITK/Code/Common/itkTriangleCell.txx +++ b/Utilities/ITK/Code/Common/itkTriangleCell.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkTriangleCell.txx,v $ Language: C++ - Date: $Date: 2009-03-03 15:11:04 $ - Version: $Revision: 1.55 $ + Date: $Date: 2009-11-24 02:27:28 $ + Version: $Revision: 1.56 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -520,6 +520,7 @@ TriangleCell< TCellInterface > // u32 is orthogonal to v12 // const double dotproduct = v12 * v32; + typedef typename VectorType::ValueType VectorValueType; VectorType u12 = v12 - v32 * ( dotproduct / v32.GetSquaredNorm() ); VectorType u32 = v32 - v12 * ( dotproduct / v12.GetSquaredNorm() ); diff --git a/Utilities/ITK/Code/Common/itkVectorInterpolateImageFunction.h b/Utilities/ITK/Code/Common/itkVectorInterpolateImageFunction.h index c3136bd72eec291ace4feaaf607a4597a79a3b7d..68be59b6bd691516d0e46ff333749df69164b9f3 100644 --- a/Utilities/ITK/Code/Common/itkVectorInterpolateImageFunction.h +++ b/Utilities/ITK/Code/Common/itkVectorInterpolateImageFunction.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkVectorInterpolateImageFunction.h,v $ Language: C++ - Date: $Date: 2009-03-03 15:11:40 $ - Version: $Revision: 1.24 $ + Date: $Date: 2009-10-29 11:18:44 $ + Version: $Revision: 1.25 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -90,7 +90,8 @@ public: typedef typename Superclass::PointType PointType; /** Index typedef support. */ - typedef typename Superclass::IndexType IndexType; + typedef typename Superclass::IndexType IndexType; + typedef typename Superclass::IndexValueType IndexValueType; /** ContinuousIndex typedef support. */ typedef typename Superclass::ContinuousIndexType ContinuousIndexType; diff --git a/Utilities/ITK/Code/Common/itkVectorLinearInterpolateImageFunction.h b/Utilities/ITK/Code/Common/itkVectorLinearInterpolateImageFunction.h index d8b9d0092d3b4d9ed254ffd770542c600602e721..858ce9a4824017f1f5b0185e5ec87aeb21572479 100644 --- a/Utilities/ITK/Code/Common/itkVectorLinearInterpolateImageFunction.h +++ b/Utilities/ITK/Code/Common/itkVectorLinearInterpolateImageFunction.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkVectorLinearInterpolateImageFunction.h,v $ Language: C++ - Date: $Date: 2009-03-03 15:11:41 $ - Version: $Revision: 1.16 $ + Date: $Date: 2009-10-29 11:18:45 $ + Version: $Revision: 1.17 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -70,7 +70,8 @@ public: itkStaticConstMacro(ImageDimension, unsigned int,Superclass::ImageDimension); /** Index typedef support. */ - typedef typename Superclass::IndexType IndexType; + typedef typename Superclass::IndexType IndexType; + typedef typename Superclass::IndexValueType IndexValueType; /** ContinuousIndex typedef support. */ typedef typename Superclass::ContinuousIndexType ContinuousIndexType; diff --git a/Utilities/ITK/Code/Common/itkVectorLinearInterpolateImageFunction.txx b/Utilities/ITK/Code/Common/itkVectorLinearInterpolateImageFunction.txx index 522de396c21d9226628ca6420966ec23a0a9817b..b7aaaf7d3bc077bc571033f4d133ffbd7b011291 100644 --- a/Utilities/ITK/Code/Common/itkVectorLinearInterpolateImageFunction.txx +++ b/Utilities/ITK/Code/Common/itkVectorLinearInterpolateImageFunction.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkVectorLinearInterpolateImageFunction.txx,v $ Language: C++ - Date: $Date: 2009-05-07 14:03:49 $ - Version: $Revision: 1.16 $ + Date: $Date: 2009-10-29 11:18:50 $ + Version: $Revision: 1.17 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -72,29 +72,13 @@ VectorLinearInterpolateImageFunction< TInputImage, TCoordRep > * Compute base index = closet index below point * Compute distance from point to base index */ - signed long baseIndex[ImageDimension]; + IndexType baseIndex; double distance[ImageDimension]; - long tIndex; for( dim = 0; dim < ImageDimension; dim++ ) { - // The following "if" block is equivalent to the following line without - // having to call floor. - // baseIndex[dim] = (long) vcl_floor(index[dim] ); - if (index[dim] >= 0.0) - { - baseIndex[dim] = (long) index[dim]; - } - else - { - tIndex = (long) index[dim]; - if (double(tIndex) != index[dim]) - { - tIndex--; - } - baseIndex[dim] = tIndex; - } - distance[dim] = index[dim] - double( baseIndex[dim] ); + baseIndex[dim] = Math::Floor< IndexValueType >( index[dim] ); + distance[dim] = index[dim] - static_cast< double >( baseIndex[dim] ); } /** diff --git a/Utilities/ITK/Code/Common/itkVectorNearestNeighborInterpolateImageFunction.h b/Utilities/ITK/Code/Common/itkVectorNearestNeighborInterpolateImageFunction.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Common/itkVersion.h b/Utilities/ITK/Code/Common/itkVersion.h index ffdcedb32611a32b5e0ce96a98adba68189c54aa..f968bc1db3867010d8105b79eee7cc697cb80075 100644 --- a/Utilities/ITK/Code/Common/itkVersion.h +++ b/Utilities/ITK/Code/Common/itkVersion.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkVersion.h,v $ Language: C++ - Date: $Date: 2009-09-15 02:00:06 $ - Version: $Revision: 1.3157 $ + Date: $Date: 2010-04-15 02:00:36 $ + Version: $Revision: 1.3363 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -28,7 +28,7 @@ #define ITK_VERSION ITK_VERSION_TO_STRING(ITK_VERSION_MAJOR) "." \ ITK_VERSION_TO_STRING(ITK_VERSION_MINOR) "." \ ITK_VERSION_TO_STRING(ITK_VERSION_PATCH) -#define ITK_SOURCE_VERSION "itk version " ITK_VERSION ", itk source $Revision: 1.3157 $, $Date: 2009-09-15 02:00:06 $ (GMT)" +#define ITK_SOURCE_VERSION "itk version " ITK_VERSION ", itk source $Revision: 1.3363 $, $Date: 2010-04-15 02:00:36 $ (GMT)" namespace itk { diff --git a/Utilities/ITK/Code/Common/itkVersor.txx b/Utilities/ITK/Code/Common/itkVersor.txx index 7818240b0c56b4233d462bc97566491a3215eb65..99d65d0ef2ebcdb7275a56946b168a703d04c467 100644 --- a/Utilities/ITK/Code/Common/itkVersor.txx +++ b/Utilities/ITK/Code/Common/itkVersor.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkVersor.txx,v $ Language: C++ - Date: $Date: 2008-12-18 04:34:28 $ - Version: $Revision: 1.29 $ + Date: $Date: 2010-03-30 15:20:02 $ + Version: $Revision: 1.32 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -21,6 +21,7 @@ #include "itkVector.h" #include "itkNumericTraits.h" #include "itkExceptionObject.h" +#include "itkMath.h" namespace itk @@ -412,7 +413,7 @@ Versor<T> if( m(0,0) > m(1,1) && m(0,0) > m(2,2) ) { const double s = 2.0 * vcl_sqrt(1.0 + m(0,0) - m(1,1) - m(2,2)); - m_X = 0.25 * s; + m_X =0.25 * s; m_Y = (m(0,1) + m(1,0)) / s; m_Z = (m(0,2) + m(2,0)) / s; m_W = (m(1,2) - m(2,1)) / s; @@ -447,9 +448,9 @@ void Versor<T> ::Set( const VectorType & axis ) { - + typedef typename VectorType::RealValueType VectorRealValueType; const ValueType sinangle2 = axis.GetNorm(); - if( sinangle2 > 1.0 ) + if( sinangle2 > NumericTraits<ValueType>::One ) { ExceptionObject exception; exception.SetDescription("Trying to initialize a Versor with " \ @@ -458,7 +459,7 @@ Versor<T> throw exception; } - const ValueType cosangle2 = vcl_sqrt(1.0 - sinangle2 * sinangle2 ); + const ValueType cosangle2 = vcl_sqrt( NumericTraits<double>::One - sinangle2 * sinangle2 ); m_X = axis[0]; m_Y = axis[1]; diff --git a/Utilities/ITK/Code/Common/itkVersorRigid3DTransform.h b/Utilities/ITK/Code/Common/itkVersorRigid3DTransform.h index 9bec7cf580a423c0265726d170524dde9dfedf34..d0574cb42f34e486350fe614a4f029ea0b0a3ada 100644 --- a/Utilities/ITK/Code/Common/itkVersorRigid3DTransform.h +++ b/Utilities/ITK/Code/Common/itkVersorRigid3DTransform.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkVersorRigid3DTransform.h,v $ Language: C++ - Date: $Date: 2009-04-13 23:41:53 $ - Version: $Revision: 1.28 $ + Date: $Date: 2009-11-24 15:25:15 $ + Version: $Revision: 1.30 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -91,6 +91,10 @@ public: typedef typename Superclass::AxisType AxisType; typedef typename Superclass::AngleType AngleType; + typedef typename Superclass::AxisValueType AxisValueType; + typedef typename Superclass::TranslationValueType TranslationValueType; + typedef typename Superclass::ParameterValueType ParameterValueType; + /** Set the transformation from a container of parameters * This is typically used by optimizers. * There are 6 parameters. The first three represent the diff --git a/Utilities/ITK/Code/Common/itkVersorRigid3DTransform.txx b/Utilities/ITK/Code/Common/itkVersorRigid3DTransform.txx index c50e5df9bcc43c51e13deb72fff6c8f676450869..ec9ceb7bc57d5f395503e39d9f30cd3f428116c8 100644 --- a/Utilities/ITK/Code/Common/itkVersorRigid3DTransform.txx +++ b/Utilities/ITK/Code/Common/itkVersorRigid3DTransform.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkVersorRigid3DTransform.txx,v $ Language: C++ - Date: $Date: 2006-03-19 04:36:59 $ - Version: $Revision: 1.32 $ + Date: $Date: 2010-03-30 15:20:02 $ + Version: $Revision: 1.34 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. diff --git a/Utilities/ITK/Code/Common/itkVersorTransform.h b/Utilities/ITK/Code/Common/itkVersorTransform.h index 530d5a7a3f3bdf398ff25cb7646b3a49ebb83ed5..361fdfbe21b3a1e0fd29ec64409e58959e38168c 100644 --- a/Utilities/ITK/Code/Common/itkVersorTransform.h +++ b/Utilities/ITK/Code/Common/itkVersorTransform.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkVersorTransform.h,v $ Language: C++ - Date: $Date: 2009-06-14 12:30:09 $ - Version: $Revision: 1.19 $ + Date: $Date: 2009-11-24 02:27:28 $ + Version: $Revision: 1.20 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -94,6 +94,8 @@ public: typedef Versor<TScalarType> VersorType; typedef typename VersorType::VectorType AxisType; typedef typename VersorType::ValueType AngleType; + typedef typename AxisType::ValueType AxisValueType; + typedef typename ParametersType::ValueType ParameterValueType; /** * Set the transformation from a container of parameters diff --git a/Utilities/ITK/Code/Common/itkVersorTransform.txx b/Utilities/ITK/Code/Common/itkVersorTransform.txx index 69c2857a812a3e845f580688cd4b7be19f4c2f91..51e6613e45ad6519d49cbd022456fb2f3b2dce09 100644 --- a/Utilities/ITK/Code/Common/itkVersorTransform.txx +++ b/Utilities/ITK/Code/Common/itkVersorTransform.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkVersorTransform.txx,v $ Language: C++ - Date: $Date: 2006-08-09 04:35:32 $ - Version: $Revision: 1.17 $ + Date: $Date: 2010-03-30 15:20:44 $ + Version: $Revision: 1.19 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -18,6 +18,7 @@ #define __itkVersorTransform_txx #include "itkVersorTransform.h" +#include "itkMath.h" namespace itk diff --git a/Utilities/ITK/Code/Common/itkWindowedSincInterpolateImageFunction.h b/Utilities/ITK/Code/Common/itkWindowedSincInterpolateImageFunction.h index 4b278422ff0d4201ed27c39fd736901d5c0d4977..58562583318bc59a49df8407560f344835013bd2 100644 --- a/Utilities/ITK/Code/Common/itkWindowedSincInterpolateImageFunction.h +++ b/Utilities/ITK/Code/Common/itkWindowedSincInterpolateImageFunction.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkWindowedSincInterpolateImageFunction.h,v $ Language: C++ - Date: $Date: 2009-04-06 00:05:54 $ - Version: $Revision: 1.9 $ + Date: $Date: 2009-10-29 11:18:58 $ + Version: $Revision: 1.10 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -276,7 +276,8 @@ public: itkStaticConstMacro(ImageDimension, unsigned int,Superclass::ImageDimension); /** Index typedef support. */ - typedef typename Superclass::IndexType IndexType; + typedef typename Superclass::IndexType IndexType; + typedef typename Superclass::IndexValueType IndexValueType; /** Image type definition */ typedef TInputImage ImageType; diff --git a/Utilities/ITK/Code/Common/itkWindowedSincInterpolateImageFunction.txx b/Utilities/ITK/Code/Common/itkWindowedSincInterpolateImageFunction.txx index 4192080026f8189ed2580aea196a67fde51d994a..80a63e38b83206e57751fd7ca276e0bbe485b9a1 100644 --- a/Utilities/ITK/Code/Common/itkWindowedSincInterpolateImageFunction.txx +++ b/Utilities/ITK/Code/Common/itkWindowedSincInterpolateImageFunction.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkWindowedSincInterpolateImageFunction.txx,v $ Language: C++ - Date: $Date: 2006-03-19 04:36:59 $ - Version: $Revision: 1.12 $ + Date: $Date: 2009-10-29 11:18:59 $ + Version: $Revision: 1.13 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -200,31 +200,15 @@ WindowedSincInterpolateImageFunction<TInputImage,VRadius, const ContinuousIndexType& index) const { unsigned int dim; - Index<ImageDimension> baseIndex; + IndexType baseIndex; double distance[ImageDimension]; // Compute the integer index based on the continuous one by // 'flooring' the index for( dim = 0; dim < ImageDimension; dim++ ) { - // The following "if" block is equivalent to the following line without - // having to call floor. - // baseIndex[dim] = (long) vcl_floor(index[dim] ); - if (index[dim] >= 0.0) - { - baseIndex[dim] = (long) index[dim]; - } - else - { - long tIndex = (long) index[dim]; - if (double(tIndex) != index[dim]) - { - tIndex--; - } - baseIndex[dim] = tIndex; - } - - distance[dim] = index[dim] - double( baseIndex[dim] ); + baseIndex[dim] = Math::Floor<IndexValueType>( index[dim] ); + distance[dim] = index[dim] - static_cast< double >( baseIndex[dim] ); } // cout << "Sampling at index " << index << " discrete " << baseIndex << endl; diff --git a/Utilities/ITK/Code/Common/vnl_vector+size_t-.cxx b/Utilities/ITK/Code/Common/vnl_vector+size_t-.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/IO/CMakeLists.txt b/Utilities/ITK/Code/IO/CMakeLists.txt index 104b0c012d08a10d8f5c8077ae389febba5064d2..b1d2902cbda21f55ce281aa4787326ddd7d240b4 100644 --- a/Utilities/ITK/Code/IO/CMakeLists.txt +++ b/Utilities/ITK/Code/IO/CMakeLists.txt @@ -147,10 +147,16 @@ IF(NOT ITK_INSTALL_NO_LIBRARIES) ARCHIVE DESTINATION ${ITK_INSTALL_LIB_DIR_CM24} COMPONENT Development) ENDIF(NOT ITK_INSTALL_NO_LIBRARIES) +IF(ITK_USE_FLAT_DIRECTORY_INSTALL) + SET( ITK_INSTALL_INCLUDE_DIR_CM24_IO ${ITK_INSTALL_INCLUDE_DIR_CM24}) +ELSE(ITK_USE_FLAT_DIRECTORY_INSTALL) + SET( ITK_INSTALL_INCLUDE_DIR_CM24_IO ${ITK_INSTALL_INCLUDE_DIR_CM24}/IO) +ENDIF(ITK_USE_FLAT_DIRECTORY_INSTALL) + IF(NOT ITK_INSTALL_NO_DEVELOPMENT) FILE(GLOB __files1 "${CMAKE_CURRENT_SOURCE_DIR}/*.h") FILE(GLOB __files2 "${CMAKE_CURRENT_SOURCE_DIR}/*.txx") INSTALL(FILES ${__files1} ${__files2} - DESTINATION ${ITK_INSTALL_INCLUDE_DIR_CM24}/IO + DESTINATION ${ITK_INSTALL_INCLUDE_DIR_CM24_IO} COMPONENT Development) ENDIF(NOT ITK_INSTALL_NO_DEVELOPMENT) diff --git a/Utilities/ITK/Code/IO/itkAnalyzeImageIO.cxx b/Utilities/ITK/Code/IO/itkAnalyzeImageIO.cxx index cea43d104aeb128b8620ebe5be968802080406ca..524687d9751ba4ce5a65a9cf23c59769cb995664 100644 --- a/Utilities/ITK/Code/IO/itkAnalyzeImageIO.cxx +++ b/Utilities/ITK/Code/IO/itkAnalyzeImageIO.cxx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkAnalyzeImageIO.cxx,v $ Language: C++ - Date: $Date: 2009-04-30 23:08:50 $ - Version: $Revision: 1.99 $ + Date: $Date: 2010-02-08 19:48:02 $ + Version: $Revision: 1.104 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -72,6 +72,9 @@ const short int DataTypeKey[12] = SPMANALYZE_DT_UNSIGNED_INT }; +// due to gzip and other io limitations this is the maximum size to +// read at one time +const unsigned int ANALYZE_MAXIMUM_IO_CHUNK = itk::NumericTraits<unsigned int>::max()/4; static std::string GetExtension( const std::string& filename ) @@ -135,8 +138,10 @@ static std::string GetImageFileName( const std::string& filename ) void AnalyzeImageIO::SwapBytesIfNecessary( void* buffer, - unsigned long numberOfPixels ) + SizeType _numberOfPixels ) { + // todo check for overflow error + size_t numberOfPixels = static_cast<size_t>( _numberOfPixels ); if ( m_ByteOrder == LittleEndian ) { switch(m_ComponentType) @@ -680,15 +685,7 @@ void AnalyzeImageIO::DefineHeaderObjectDataType() void AnalyzeImageIO::Read(void* buffer) { - unsigned int dim; - const unsigned int dimensions = this->GetNumberOfDimensions(); - unsigned int numberOfPixels = 1; - for(dim=0; dim< dimensions; dim++ ) - { - numberOfPixels *= m_Dimensions[ dim ]; - } - - char * const p = static_cast<char *>(buffer); + //4 cases to handle //1: given .hdr and image is .img //2: given .img @@ -699,46 +696,95 @@ void AnalyzeImageIO::Read(void* buffer) /* Returns proper name for cases 1,2,3 */ std::string ImageFileName = GetImageFileName( m_FileName ); - //NOTE: gzFile operations act just like FILE * operations when the files - // are not in gzip fromat. - // This greatly simplifies the following code, and gzFile types are used - // everywhere. - // In addition, it has the added benifit of reading gzip compressed image - // files that do not have a .gz ending. + // NOTE: gzFile operations act just like FILE * operations when the + // files are not in gzip fromat.This greatly simplifies the + // following code, and gzFile types are used everywhere. In + // addition, it has the added benifit of reading gzip compressed + // image files that do not have a .gz ending. + /// + gzFile file_p = ::gzopen( ImageFileName.c_str(), "rb" ); - if( file_p == NULL ) + try // try block to ensure we close the file { - /* Do a separate check to take care of case #4 */ - ImageFileName += ".gz"; - file_p = ::gzopen( ImageFileName.c_str(), "rb" ); if( file_p == NULL ) { - ExceptionObject exception(__FILE__, __LINE__); - std::string message = - "Analyze Data File can not be read:" - " The following files were attempted:\n "; - message += GetImageFileName( m_FileName ); - message += '\n'; - message += ImageFileName; - message += '\n'; - exception.SetDescription(message.c_str()); - exception.SetLocation(ITK_LOCATION); - throw exception; + /* Do a separate check to take care of case #4 */ + ImageFileName += ".gz"; + file_p = ::gzopen( ImageFileName.c_str(), "rb" ); + if( file_p == NULL ) + { + itkExceptionMacro( <<"Analyze Data File can not be read: " + << " The following files were attempted:\n " + << GetImageFileName( m_FileName ) << "\n" + << ImageFileName << "\n" ); + } } - } - // Seek through the file to the correct position, This is only necessary - // when readin in sub-volumes - // const long int total_offset = static_cast<long int>(tempX * tempY * - // start_slice * m_dataSize) - // + static_cast<long int>(tempX * tempY * total_z * start_time * - // m_dataSize); - // ::gzseek( file_p, total_offset, SEEK_SET ); + // Apply the offset if any. + // From itkAnalyzeDbh.h: + // Byte offset in the .img file at which voxels start. + // If value is negative specifies that the absolute value is + // applied for every image in the file. + z_off_t byteOffset = static_cast<z_off_t>(fabs(m_Hdr.dime.vox_offset)); + if (byteOffset > 0) + { + if ( ::gzseek(file_p, byteOffset, SEEK_SET) == -1 ) + { + itkExceptionMacro ( << "Analyze Data File can not be read: " + << " Unable to seek to the vox_offset: " + << byteOffset << "\n" ); + } + } + + + // CAVEAT: gzread in particular only accepts "unsigned int" for the + // number of bytes to read, thus limiting the amount which may be + // read in a single operation on some platforms to a different limit + // than the corresponding fread operation. + + //size of the maximum chunk to read , if the file is larger than this it will be read as several chunks. + //This is due to the limitation of 'unsigned int' in the gzread() function. + static const unsigned int maxChunk = ANALYZE_MAXIMUM_IO_CHUNK; + + char * p = static_cast<char *>(buffer); + + SizeType bytesRemaining = this->GetImageSizeInBytes(); + while ( bytesRemaining ) + { + unsigned int bytesToRead = bytesRemaining > static_cast<SizeType>(maxChunk) + ? maxChunk : static_cast<unsigned int>(bytesRemaining); + + int retval = ::gzread( file_p, p, bytesToRead ); + + // + // check for error from gzread + // careful .. due to unsigned/signed conversion the + // real return value could be -1 if a chunk equal to 2^32-1 is allowed! + // + if( retval != static_cast<int>(bytesToRead) ) + { + itkExceptionMacro( << "Analyze Data File : gzread returned bad value: " + << retval << "\n" ); + + } - // read image in - ::gzread( file_p, p, static_cast< unsigned >( this->GetImageSizeInBytes() ) ); - gzclose( file_p ); - SwapBytesIfNecessary( buffer, numberOfPixels ); + p += bytesToRead; + bytesRemaining -= bytesToRead; + } + + gzclose( file_p ); + file_p = NULL; + SwapBytesIfNecessary( buffer, this->GetImageSizeInPixels() ); + } + catch (...) + { + // close file and rethrow + if ( file_p != NULL ) + { + gzclose( file_p ); + } + throw; + } } @@ -753,7 +799,7 @@ bool AnalyzeImageIO::CanReadFile( const char* FileNameToRead ) if(filenameext != std::string(".hdr") && filenameext != std::string(".img.gz") && filenameext != std::string(".img") - ) + ) { return false; } @@ -850,6 +896,10 @@ void AnalyzeImageIO::ReadImageInformation() { numberOfDimensions++; } + else + { + itkWarningMacro( "AnalyzeImageIO is ignoring dimension " << idx << " with value " << this->m_Hdr.dime.dim[idx] ); + } } } @@ -1156,6 +1206,19 @@ void AnalyzeImageIO ::WriteImageInformation(void) { + // First of all we need to not go any further if there's + // a dimension of the image that won't fit in a 16 bit short. + for(unsigned int i = 0; i < this->GetNumberOfDimensions(); i++) + { + unsigned int curdim(this->GetDimensions(i)); + if(curdim > static_cast<unsigned int>(NumericTraits<short>::max())) + { + itkExceptionMacro( << "Dimension(" << i << ") = " << curdim + << " is greater than maximum possible dimension " + << NumericTraits<short>::max() ); + + } + } unsigned int dim; if(this->GetPixelType() == RGB) { @@ -1333,15 +1396,14 @@ AnalyzeImageIO // Check for image dimensions to be smaller enough to fit in // a short int. First generate the number that is the maximum allowable. - typedef itk::Size<3>::SizeValueType SizeValueType; const SizeValueType maximumNumberOfPixelsAllowedInOneDimension = - itk::NumericTraits<unsigned short>::max() - 1; + itk::NumericTraits<short>::max(); for( dim=0; dim< this->GetNumberOfDimensions(); dim++ ) { const SizeValueType numberOfPixelsAlongThisDimension = m_Dimensions[ dim ]; - if( numberOfPixelsAlongThisDimension >= maximumNumberOfPixelsAllowedInOneDimension ) + if( numberOfPixelsAlongThisDimension > maximumNumberOfPixelsAllowedInOneDimension ) { itkExceptionMacro("Number of pixels along dimension " << dim << " is " << numberOfPixelsAlongThisDimension << @@ -1502,33 +1564,53 @@ AnalyzeImageIO // "const voidp" is "void* const", not "const void*". voidp p = const_cast<voidp>(buffer); const std::string ImageFileName = GetImageFileName( m_FileName ); - const std::string fileExt=GetExtension( m_FileName ); + const std::string fileExt = GetExtension( m_FileName ); // Check case where image is acually a compressed image - if(!fileExt.compare( ".gz" )) + + if(!fileExt.compare( ".img.gz" )) { // Open the *.img.gz file for writing. gzFile file_p = ::gzopen( ImageFileName.c_str(), "wb" ); if( file_p==NULL ) { - ExceptionObject exception(__FILE__, __LINE__); - std::string ErrorMessage="Error, Can not write compressed image file for "; - ErrorMessage += m_FileName; - exception.SetDescription(ErrorMessage.c_str()); - exception.SetLocation(ITK_LOCATION); - throw exception; + itkExceptionMacro( << "Error, Can not write compressed image file for " << m_FileName ); } - - if(::gzwrite(file_p,p, - static_cast< unsigned >(this->GetImageSizeInBytes())) == -1) + + try // try block to ensure file gets closed { - ExceptionObject exception(__FILE__, __LINE__); - std::string ErrorMessage="Error, Can not write compressed image file for "; - ErrorMessage += m_FileName; - exception.SetDescription(ErrorMessage.c_str()); - exception.SetLocation(ITK_LOCATION); - throw exception; + // CAVEAT: gzwrite in particular only accepts "unsigned int" for the + // number of bytes to read, thus limiting the amount which may be + // read in a single operation on some platforms to a different limit + // than the corresponding fread operation. + + static const unsigned int maxChunk = ANALYZE_MAXIMUM_IO_CHUNK; + + SizeType bytesRemaining = this->GetImageSizeInBytes(); + while ( bytesRemaining ) + { + unsigned int bytesToWrite = bytesRemaining > static_cast<SizeType>(maxChunk) + ? maxChunk : static_cast<unsigned int>(bytesRemaining); + + if( ::gzwrite(file_p, p, bytesToWrite ) != static_cast<int>(bytesToWrite) ) + { + itkExceptionMacro( << "Error, Can not write compressed image file for "<< m_FileName ); + } + p = static_cast<char *>( p ) + bytesToWrite; + bytesRemaining -= bytesToWrite; + } + ::gzclose( file_p ); + file_p = NULL; + } + catch (...) + { + // close file and rethrow exception + if ( file_p != NULL ) + { + ::gzclose( file_p ); + } + throw; } - ::gzclose( file_p ); + //RemoveFile FileNameToRead.img so that it does not get confused with //FileNameToRead.img.gz //The following is a hack that can be used to remove ambiguity when an @@ -1536,7 +1618,7 @@ AnalyzeImageIO //This results in one *.hdr file being assosiated with a *.img and a // *.img.gz image file. //DEBUG -- Will this work under windows? - std::string unusedbaseimgname= GetRootName(GetHeaderFileName(m_FileName)); + std::string unusedbaseimgname = GetRootName(GetHeaderFileName(m_FileName)); unusedbaseimgname += ".img"; itksys::SystemTools::RemoveFile(unusedbaseimgname.c_str()); } @@ -1547,31 +1629,23 @@ AnalyzeImageIO local_OutputStream.open( ImageFileName.c_str(), std::ios::out | std::ios::binary ); if( !local_OutputStream ) { - ExceptionObject exception(__FILE__, __LINE__); - std::string ErrorMessage="Error opening image data file for writing."; - ErrorMessage += m_FileName; - exception.SetDescription(ErrorMessage.c_str()); - exception.SetLocation(ITK_LOCATION); - throw exception; + itkExceptionMacro( << "Error opening image data file for writing." + << m_FileName ); } local_OutputStream.write((const char *)p, static_cast< std::streamsize >( this->GetImageSizeInBytes() ) ); bool success = !local_OutputStream.bad(); local_OutputStream.close(); if( !success ) { - ExceptionObject exception(__FILE__, __LINE__); - std::string ErrorMessage="Error writing image data."; - ErrorMessage += m_FileName; - exception.SetDescription(ErrorMessage.c_str()); - exception.SetLocation(ITK_LOCATION); - throw exception; + itkExceptionMacro( << "Error writing image data." + << m_FileName ); } //RemoveFile FileNameToRead.img.gz so that it does not get confused with FileNameToRead.img //The following is a hack that can be used to remove ambiguity when an //uncompressed image is read, and then written as compressed. //This results in one *.hdr file being assosiated with a *.img and a *.img.gz image file. //DEBUG -- Will this work under windows? - std::string unusedbaseimgname= GetRootName(GetHeaderFileName(m_FileName)); + std::string unusedbaseimgname = GetRootName(GetHeaderFileName(m_FileName)); unusedbaseimgname += ".img.gz"; itksys::SystemTools::RemoveFile(unusedbaseimgname.c_str()); } diff --git a/Utilities/ITK/Code/IO/itkAnalyzeImageIO.h b/Utilities/ITK/Code/IO/itkAnalyzeImageIO.h index 9953e71ce049b31070434f22b23ff489aba9f606..f2f92ba9c7a7efa2328b259f90d6647326216303 100644 --- a/Utilities/ITK/Code/IO/itkAnalyzeImageIO.h +++ b/Utilities/ITK/Code/IO/itkAnalyzeImageIO.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkAnalyzeImageIO.h,v $ Language: C++ - Date: $Date: 2009-02-22 05:53:41 $ - Version: $Revision: 1.22 $ + Date: $Date: 2010-01-27 15:18:36 $ + Version: $Revision: 1.23 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -178,7 +178,7 @@ private: AnalyzeImageIO(const Self&); //purposely not implemented void operator=(const Self&); //purposely not implemented -void SwapBytesIfNecessary(void * buffer, unsigned long numberOfPixels); +void SwapBytesIfNecessary(void * buffer, SizeType numberOfPixels); /** * \author Hans J. Johnson * Performs byte swapping of the Analyze Image header if necessary. diff --git a/Utilities/ITK/Code/IO/itkArchetypeSeriesFileNames.cxx b/Utilities/ITK/Code/IO/itkArchetypeSeriesFileNames.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/IO/itkArchetypeSeriesFileNames.h b/Utilities/ITK/Code/IO/itkArchetypeSeriesFileNames.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/IO/itkBMPImageIO.cxx b/Utilities/ITK/Code/IO/itkBMPImageIO.cxx index 2d6e6d4f9bede96226621df67cddcae4b4a3aa9e..13a5a3b00ee809bc63a95686e1274d2b9e1ac2e3 100644 --- a/Utilities/ITK/Code/IO/itkBMPImageIO.cxx +++ b/Utilities/ITK/Code/IO/itkBMPImageIO.cxx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkBMPImageIO.cxx,v $ Language: C++ - Date: $Date: 2009-06-16 07:58:47 $ - Version: $Revision: 1.32 $ + Date: $Date: 2009-10-27 16:05:53 $ + Version: $Revision: 1.33 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -877,10 +877,8 @@ BMPImageIO // The specification calls for a signed integer, but // here we force it to be an unsigned integer to avoid // dealing with directions in a subterraneous way. - const unsigned int horizontalResolution = - static_cast<unsigned int>( Math::Round( 1000.0 / m_Spacing[0] ) ); - const unsigned int verticalResolution = - static_cast<unsigned int>( Math::Round( 1000.0 / m_Spacing[1] ) ); + const unsigned int horizontalResolution = Math::Round<unsigned int>( 1000.0 / m_Spacing[0] ); + const unsigned int verticalResolution = Math::Round<unsigned int>( 1000.0 / m_Spacing[1] ); this->Write32BitsInteger( horizontalResolution ); this->Write32BitsInteger( verticalResolution ); diff --git a/Utilities/ITK/Code/IO/itkConvertPixelBuffer.txx b/Utilities/ITK/Code/IO/itkConvertPixelBuffer.txx index 5b61f9629345bdca510e646389177ddcde496d6f..f36a1bfdc1c5bf170fa509a04810f034ffa89454 100644 --- a/Utilities/ITK/Code/IO/itkConvertPixelBuffer.txx +++ b/Utilities/ITK/Code/IO/itkConvertPixelBuffer.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkConvertPixelBuffer.txx,v $ Language: C++ - Date: $Date: 2009-08-11 12:45:09 $ - Version: $Revision: 1.26 $ + Date: $Date: 2009-11-22 19:35:57 $ + Version: $Revision: 1.27 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -253,7 +253,7 @@ ConvertPixelBuffer<InputPixelType, OutputPixelType, OutputConvertTraits> // NOTE: The scale factors are converted to whole numbers for // precision ptrdiff_t diff = inputNumberOfComponents - 4; - InputPixelType* endInput = inputData + size*inputNumberOfComponents; + InputPixelType* endInput = inputData + size * (size_t)inputNumberOfComponents; while(inputData != endInput) { double tempval = @@ -382,7 +382,7 @@ ConvertPixelBuffer<InputPixelType, OutputPixelType, OutputConvertTraits> else { ptrdiff_t diff = inputNumberOfComponents - 3; - InputPixelType* endInput = inputData + size * inputNumberOfComponents; + InputPixelType* endInput = inputData + size * (size_t)inputNumberOfComponents; while(inputData != endInput) { OutputConvertTraits::SetNthComponent(0, *outputData, @@ -520,7 +520,7 @@ ConvertPixelBuffer<InputPixelType, OutputPixelType, OutputConvertTraits> else { ptrdiff_t diff = inputNumberOfComponents - 4; - InputPixelType* endInput = inputData + size * inputNumberOfComponents; + InputPixelType* endInput = inputData + size * (size_t)inputNumberOfComponents; while(inputData != endInput) { OutputConvertTraits::SetNthComponent(0, *outputData, @@ -662,7 +662,7 @@ ConvertPixelBuffer<InputPixelType, OutputPixelType, OutputConvertTraits> size_t size) { ptrdiff_t diff = inputNumberOfComponents - 2; - InputPixelType* endInput = inputData + size * inputNumberOfComponents; + InputPixelType* endInput = inputData + size * (size_t)inputNumberOfComponents; while(inputData != endInput) { OutputConvertTraits::SetNthComponent(0, *outputData, @@ -687,7 +687,7 @@ ConvertPixelBuffer<InputPixelType, OutputPixelType, OutputConvertTraits> int inputNumberOfComponents, OutputPixelType* outputData , size_t size) { - size_t length = static_cast< size_t >(size* inputNumberOfComponents); + size_t length = size* (size_t)inputNumberOfComponents; for( size_t i=0; i< length; i++ ) { OutputConvertTraits::SetNthComponent( 0, *outputData, diff --git a/Utilities/ITK/Code/IO/itkDICOMImageIO2.cxx b/Utilities/ITK/Code/IO/itkDICOMImageIO2.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/IO/itkDICOMImageIO2.h b/Utilities/ITK/Code/IO/itkDICOMImageIO2.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/IO/itkDICOMImageIO2Factory.cxx b/Utilities/ITK/Code/IO/itkDICOMImageIO2Factory.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/IO/itkDICOMImageIO2Factory.h b/Utilities/ITK/Code/IO/itkDICOMImageIO2Factory.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/IO/itkGDCMImageIO.cxx b/Utilities/ITK/Code/IO/itkGDCMImageIO.cxx index 99d0e39ac8fb25b27124ee3b9a4a6cdde079a377..2a39993cbfa20712c46ca45c7575ae678155841a 100644 --- a/Utilities/ITK/Code/IO/itkGDCMImageIO.cxx +++ b/Utilities/ITK/Code/IO/itkGDCMImageIO.cxx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkGDCMImageIO.cxx,v $ Language: C++ - Date: $Date: 2009-08-20 08:20:53 $ - Version: $Revision: 1.161 $ + Date: $Date: 2009-12-03 14:09:13 $ + Version: $Revision: 1.170 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -19,6 +19,7 @@ =========================================================================*/ #include "gdcmFile.h" +#include "itkVersion.h" #include "itkGDCMImageIO.h" #include "itkIOCommon.h" #include "itkPoint.h" @@ -42,6 +43,8 @@ #include "gdcmDictSet.h" // access to dictionary #else #include "gdcmImageHelper.h" +#include "gdcmFileExplicitFilter.h" +#include "gdcmImageChangeTransferSyntax.h" #include "gdcmDataSetHelper.h" #include "gdcmStringFilter.h" #include "gdcmImageApplyLookupTable.h" @@ -72,9 +75,11 @@ public: }; // Initialize static members -/* + +/* WARNING GDCM 1.x only WARNING Those options have no effect on GDCM 2.x as parsing is fast enough + * * m_LoadPrivateTagsDefault: - * When this flag is set to false, GDCM will try to use the value stored in each private Group Length attribute value. + * When this flag is set to false, GDCM 1.x will try to use the value stored in each private Group Length attribute value. * This is a modest optimization feature that can be found in some ACR-NEMA file and/or DICOM pre-2008 file. * Because it is required by the standard that DICOM file reader can read file where Group Length attribute value * would be invalid, turning this flag to off, on the one hand might lead to some speed improvement, but on the @@ -1201,7 +1206,8 @@ void GDCMImageIO::InternalReadImageInformation(std::ifstream& file) * Old behavior was to skip SQ, Pixel Data element. I decided that it is not safe to mime64 * VR::UN element. There used to be a bug in gdcm 1.2.0 and VR:UN element. */ - if ( tag.IsPublic() && vr != gdcm::VR::SQ && tag != gdcm::Tag(0x7fe0,0x0010) /* && vr != gdcm::VR::UN*/ ) + if ( (m_LoadPrivateTags || tag.IsPublic()) && vr != gdcm::VR::SQ + && tag != gdcm::Tag(0x7fe0,0x0010) /* && vr != gdcm::VR::UN*/ ) { const gdcm::ByteValue *bv = ref.GetByteValue(); if( bv ) @@ -1226,7 +1232,7 @@ void GDCMImageIO::InternalReadImageInformation(std::ifstream& file) else /* if ( vr & gdcm::VR::VRASCII ) */ { // Only copying field from the public DICOM dictionary - if( tag.IsPublic() ) + if( m_LoadPrivateTags || tag.IsPublic() ) { EncapsulateMetaData<std::string>(dico, PrintAsPipeSeparatedString(tag), sf.ToString( tag ) ); } @@ -1492,24 +1498,24 @@ void GDCMImageIO::Write(const void* buffer) { str.str(""); str << m_Direction[0][0] << "\\" - << m_Direction[1][0] << "\\"; + << m_Direction[0][1] << "\\"; /* * This is where the 3rd component of the direction is being lost * ITK mechanism does not support 2D image, placed in 3D world... */ if( m_Direction.size() == 3 ) { - str << m_Direction[2][0] << "\\"; + str << m_Direction[0][2] << "\\"; } else { str << 0. << "\\"; } - str << m_Direction[0][1] << "\\" + str << m_Direction[1][0] << "\\" << m_Direction[1][1] << "\\"; if( m_Direction.size() == 3 ) { - str << m_Direction[2][1]; + str << m_Direction[1][2]; } else { @@ -1844,6 +1850,11 @@ void GDCMImageIO::Write(const void* buffer) // global static: gdcm::UIDGenerator::SetRoot( m_UIDPrefix.c_str() ); + // echo "ITK" | od -b + gdcm::FileMetaInformation::AppendImplementationClassUID( "111.124.113" ); + const std::string project_name = std::string("GDCM/ITK ") + itk::Version::GetITKVersion(); + gdcm::FileMetaInformation::SetSourceApplicationEntityTitle( project_name.c_str() ); + gdcm::ImageWriter writer; gdcm::DataSet &header = writer.GetFile().GetDataSet(); gdcm::Global &g = gdcm::Global::GetInstance(); @@ -1856,6 +1867,9 @@ void GDCMImageIO::Write(const void* buffer) //Smarter approach using real iterators itk::MetaDataDictionary::ConstIterator itr = dict.Begin(); itk::MetaDataDictionary::ConstIterator end = dict.End(); + gdcm::StringFilter sf; + sf.SetFile( writer.GetFile() ); + while(itr != end) { const std::string &key = itr->first; //Needed for bcc32 @@ -1902,8 +1916,15 @@ void GDCMImageIO::Write(const void* buffer) if(!tag.IsGroupLength()) // Get rid of group length, they are not useful { gdcm::DataElement de( tag ); + if( dictEntry.GetVR().IsVRFile() ) + de.SetVR( dictEntry.GetVR() ); +#if GDCM_MAJOR_VERSION == 2 && GDCM_MINOR_VERSION <= 12 + // This will not work in the vast majority of cases but to get at least something working in GDCM 2.0.12 de.SetByteValue( value.c_str(), value.size() ); - de.SetVR( dictEntry.GetVR() ); +#else + std::string si = sf.FromString( tag, value.c_str(), value.size() ); + de.SetByteValue( si.c_str(), si.size() ); +#endif header.Insert( de ); //value, tag.GetGroup(), tag.GetElement()); } } @@ -1950,7 +1971,9 @@ void GDCMImageIO::Write(const void* buffer) //std::cout << header << std::endl; //this->SetNumberOfDimensions(3); - gdcm::Image &image = writer.GetImage(); + //gdcm::Image &image = writer.GetImage(); + gdcm::SmartPointer<gdcm::Image> simage = new gdcm::Image; + gdcm::Image &image = *simage; image.SetNumberOfDimensions( 2 ); // good default image.SetDimension(0, m_Dimensions[0] ); image.SetDimension(1, m_Dimensions[1] ); @@ -1967,6 +1990,56 @@ void GDCMImageIO::Write(const void* buffer) image.SetNumberOfDimensions( 3 ); image.SetDimension(2, m_Dimensions[2] ); } + + // Do the direction now: + image.SetDirectionCosines(0,m_Direction[0][0]); + image.SetDirectionCosines(1,m_Direction[0][1]); + image.SetDirectionCosines(2,m_Direction[0][2]); + image.SetDirectionCosines(3,m_Direction[1][0]); + image.SetDirectionCosines(4,m_Direction[1][1]); + image.SetDirectionCosines(5,m_Direction[1][2]); + + // reset any previous value: + m_RescaleSlope = 1.0; + m_RescaleIntercept = 0.0; + + // Get user defined rescale slope/intercept + std::string rescaleintercept; + ExposeMetaData<std::string>(dict, "0028|1052" , rescaleintercept); + std::string rescaleslope; + ExposeMetaData<std::string>(dict, "0028|1053" , rescaleslope); + if( rescaleintercept != "" && rescaleslope != "" ) + { + itksys_ios::stringstream sstr1; + sstr1 << rescaleintercept; + if( ! (sstr1 >> m_RescaleIntercept) ) + { + itkExceptionMacro( "Problem reading RescaleIntercept: " << rescaleintercept ); + } + itksys_ios::stringstream sstr2; + sstr2 << rescaleslope; + if( !(sstr2 >> m_RescaleSlope) ) + { + itkExceptionMacro( "Problem reading RescaleSlope: " << rescaleslope ); + } + // header->InsertValEntry( "US", 0x0028, 0x1054 ); // Rescale Type + } + else if( rescaleintercept != "" || rescaleslope != "" ) // xor + { + itkExceptionMacro( "Both RescaleSlope & RescaleIntercept need to be present" ); + } + + // Handle the bitDepth: + std::string bitsAllocated; + std::string bitsStored; + std::string highBit; + std::string pixelRep; + // Get user defined bit representation: + ExposeMetaData<std::string>(dict, "0028|0100", bitsAllocated); + ExposeMetaData<std::string>(dict, "0028|0101", bitsStored); + ExposeMetaData<std::string>(dict, "0028|0102", highBit); + ExposeMetaData<std::string>(dict, "0028|0103", pixelRep); + gdcm::PixelFormat pixeltype = gdcm::PixelFormat::UNKNOWN; switch (this->GetComponentType()) { @@ -1989,8 +2062,12 @@ void GDCMImageIO::Write(const void* buffer) pixeltype = gdcm::PixelFormat::UINT32; break; //Disabling FLOAT and DOUBLE for now... - //case ImageIOBase::FLOAT: - //case ImageIOBase::DOUBLE: + case ImageIOBase::FLOAT: + pixeltype = gdcm::PixelFormat::FLOAT32; + break; + case ImageIOBase::DOUBLE: + pixeltype = gdcm::PixelFormat::FLOAT64; + break; default: itkExceptionMacro(<<"DICOM does not support this component type"); } @@ -2011,18 +2088,95 @@ void GDCMImageIO::Write(const void* buffer) } pixeltype.SetSamplesPerPixel( this->GetNumberOfComponents() ); + // Compute the outpixeltype + gdcm::PixelFormat outpixeltype = gdcm::PixelFormat::UNKNOWN; + if( pixeltype == gdcm::PixelFormat::FLOAT32 || pixeltype == gdcm::PixelFormat::FLOAT64 ) + { + if( bitsAllocated != "" && bitsStored != "" && highBit != "" && pixelRep != "" ) + { + outpixeltype.SetBitsAllocated( atoi(bitsAllocated.c_str()) ); + outpixeltype.SetBitsStored( atoi(bitsStored.c_str()) ); + outpixeltype.SetHighBit( atoi(highBit.c_str()) ); + outpixeltype.SetPixelRepresentation( atoi(pixelRep.c_str()) ); + if( this->GetNumberOfComponents() != 1 ) + { + itkExceptionMacro(<<"Sorry Dave I can't do that" ); + } + assert( outpixeltype != gdcm::PixelFormat::UNKNOWN ); + } + else + { + itkExceptionMacro(<<"A Floating point buffer was passed but the stored pixel type was not specified." + "This is currently not supported" ); + } + } + image.SetPhotometricInterpretation( pi ); - image.SetPixelFormat( pixeltype ); + if( outpixeltype != gdcm::PixelFormat::UNKNOWN ) + image.SetPixelFormat( outpixeltype ); + else + image.SetPixelFormat( pixeltype ); unsigned long len = image.GetBufferLength(); size_t numberOfBytes = this->GetImageSizeInBytes(); - assert( len == numberOfBytes ); gdcm::DataElement pixeldata( gdcm::Tag(0x7fe0,0x0010) ); - // only do a straight copy: - pixeldata.SetByteValue( (char*)buffer, numberOfBytes ); + // Handle rescaler here: + // Whenever shift / scale is needed... do it ! + if( m_RescaleIntercept != 0 || m_RescaleSlope != 1 ) + { + // rescale from float to unsigned short + gdcm::Rescaler ir; + ir.SetIntercept( m_RescaleIntercept ); + ir.SetSlope( m_RescaleSlope ); + ir.SetPixelFormat( pixeltype ); + ir.SetMinMaxForPixelType( outpixeltype.GetMin(), outpixeltype.GetMax() ); + image.SetIntercept( m_RescaleIntercept ); + image.SetSlope( m_RescaleSlope ); + char* copy = new char[len]; + ir.InverseRescale(copy,(char*)buffer,numberOfBytes ); + pixeldata.SetByteValue( copy, len); + delete[] copy; + } + else + { + assert( len == numberOfBytes ); + // only do a straight copy: + pixeldata.SetByteValue( (char*)buffer, numberOfBytes ); + } image.SetDataElement( pixeldata ); + + // Handle compression here: + // If user ask to use compression: + if( m_UseCompression ) + { + gdcm::ImageChangeTransferSyntax change; + if( m_CompressionType == JPEG ) + { + change.SetTransferSyntax( gdcm::TransferSyntax::JPEGLosslessProcess14_1 ); + } + else if ( m_CompressionType == JPEG2000 ) + { + change.SetTransferSyntax( gdcm::TransferSyntax::JPEG2000Lossless ); + } + else + { + itkExceptionMacro(<< "Unknown compression type" ); + } + change.SetInput( image ); + bool b = change.Change(); + if( !b ) + { + itkExceptionMacro(<< "Could not change the Transfer Syntax for Compression" ); + } + writer.SetImage( change.GetOutput() ); + } + else + { + writer.SetImage( image ); + } + if( !m_KeepOriginalUID ) { // UID generation part: @@ -2037,20 +2191,31 @@ void GDCMImageIO::Write(const void* buffer) m_FrameOfReferenceInstanceUID = uid.Generate(); } //std::string uid = uid.Generate(); - const char *studyuid = m_StudyInstanceUID.c_str(); - { - gdcm::DataElement de( gdcm::Tag(0x0020,0x000d) ); // Study - de.SetByteValue( studyuid, strlen(studyuid) ); - de.SetVR( gdcm::Attribute<0x0020, 0x000d>::GetVR() ); - header.Insert( de ); + const char *studyuid = m_StudyInstanceUID.c_str(); + { + gdcm::DataElement de( gdcm::Tag(0x0020,0x000d) ); // Study + de.SetByteValue( studyuid, strlen(studyuid) ); + de.SetVR( gdcm::Attribute<0x0020, 0x000d>::GetVR() ); + header.Insert( de ); + } + const char *seriesuid = m_SeriesInstanceUID.c_str(); + { + gdcm::DataElement de( gdcm::Tag(0x0020,0x000e) ); // Series + de.SetByteValue( seriesuid, strlen(seriesuid) ); + de.SetVR( gdcm::Attribute<0x0020, 0x000e>::GetVR() ); + header.Insert( de ); + } } - const char *seriesuid = m_SeriesInstanceUID.c_str(); + + if( image.GetTransferSyntax() != gdcm::TransferSyntax::ImplicitVRLittleEndian ) { - gdcm::DataElement de( gdcm::Tag(0x0020,0x000e) ); // Series - de.SetByteValue( seriesuid, strlen(seriesuid) ); - de.SetVR( gdcm::Attribute<0x0020, 0x000e>::GetVR() ); - header.Insert( de ); - } + gdcm::FileExplicitFilter fef; + //fef.SetChangePrivateTags( true ); + fef.SetFile( writer.GetFile() ); + if(!fef.Change()) + { + itkExceptionMacro(<<"Failed to change to Explicit Transfer Syntax"); + } } const char *filename = m_FileName.c_str(); diff --git a/Utilities/ITK/Code/IO/itkGDCMImageIO.h b/Utilities/ITK/Code/IO/itkGDCMImageIO.h index 780d8fecc5cd287779aebdfdc3d3dc485d5d65db..1804d5891f3ae8a1c1a363aab224142139c518f0 100644 --- a/Utilities/ITK/Code/IO/itkGDCMImageIO.h +++ b/Utilities/ITK/Code/IO/itkGDCMImageIO.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkGDCMImageIO.h,v $ Language: C++ - Date: $Date: 2009-04-25 12:25:42 $ - Version: $Revision: 1.39 $ + Date: $Date: 2010-03-12 18:47:12 $ + Version: $Revision: 1.41 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -91,6 +91,11 @@ public: /** Reads the data from disk into the memory buffer provided. */ virtual void Read(void* buffer); + /** Get the original component type of the image. This differs from + * ComponentType which may change as a function of rescale slope and + * intercept. */ + itkGetEnumMacro(InternalComponentType,IOComponentType); + /*-------- This part of the interfaces deals with writing data. ----- */ /** Determine the file type. Returns true if this ImageIO can write the @@ -173,12 +178,14 @@ public: * this binary structure in memory since it can consume lot of memory. Therefore * any field that is bigger than the default value 0xfff is discarded and just seek'd * This method allow advanced user to force the reading of such field + * \warning this is a GDCM 1.x only option, no effect on GDCM 2.x */ itkSetMacro(MaxSizeLoadEntry, long); /** Parse any sequences in the DICOM file. Defaults to the value of * LoadSequencesDefault. Loading DICOM files is faster when * sequences are not needed. + * \warning this is a GDCM 1.x only option, no effect on GDCM 2.x */ itkSetMacro(LoadSequences, bool); itkGetConstMacro(LoadSequences, bool); @@ -187,6 +194,7 @@ public: /** Parse any private tags in the DICOM file. Defaults to the value * of LoadPrivateTagsDefault. Loading DICOM files is faster when * private tags are not needed. + * \warning this is a GDCM 1.x only option, no effect on GDCM 2.x */ itkSetMacro(LoadPrivateTags, bool); itkGetConstMacro(LoadPrivateTags, bool); @@ -197,7 +205,9 @@ public: * ivar LoadSequences is initialized to the value of * LoadSequencesDefault. This method is useful when relying on the * IO factory mechanism to load images rather than specifying a - * particular ImageIO object on the readers. Default is false. */ + * particular ImageIO object on the readers. Default is false. + * \warning this is a GDCM 1.x only option, no effect on GDCM 2.x + */ static void SetLoadSequencesDefault(bool b) { m_LoadSequencesDefault = b; } static void LoadSequencesDefaultOn() @@ -212,7 +222,9 @@ public: * ivar LoadPrivateTags is initialized to the value of * LoadPrivateTagsDefault. This method is useful when relying on the * IO factory mechanism to load images rather than specifying a - * particular ImageIO object on the readers. Default is false. */ + * particular ImageIO object on the readers. Default is false. + * \warning this is a GDCM 1.x only option, no effect on GDCM 2.x + */ static void SetLoadPrivateTagsDefault(bool b) { m_LoadPrivateTagsDefault = b; } static void LoadPrivateTagsDefaultOn() diff --git a/Utilities/ITK/Code/IO/itkGDCMImageIOFactory.cxx b/Utilities/ITK/Code/IO/itkGDCMImageIOFactory.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/IO/itkGDCMImageIOFactory.h b/Utilities/ITK/Code/IO/itkGDCMImageIOFactory.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/IO/itkGDCMSeriesFileNames.cxx b/Utilities/ITK/Code/IO/itkGDCMSeriesFileNames.cxx index 3eae4cf77f5512991c083a6c83bcbf066ac9f573..84103b50d48f86746c6a72dc8167b640d9550877 100644 --- a/Utilities/ITK/Code/IO/itkGDCMSeriesFileNames.cxx +++ b/Utilities/ITK/Code/IO/itkGDCMSeriesFileNames.cxx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkGDCMSeriesFileNames.cxx,v $ Language: C++ - Date: $Date: 2008-10-01 12:26:11 $ - Version: $Revision: 1.36 $ + Date: $Date: 2010-02-25 00:55:49 $ + Version: $Revision: 1.37 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -299,6 +299,14 @@ void GDCMSeriesFileNames::PrintSelf(std::ostream& os, Indent indent) const os << indent << "OutputFilenames[" << i << "]: " << m_OutputFileNames[i] << std::endl; } } + +void GDCMSeriesFileNames::SetUseSeriesDetails( bool useSeriesDetails) +{ + m_UseSeriesDetails = useSeriesDetails; + m_SerieHelper->SetUseSeriesDetails( m_UseSeriesDetails ); + m_SerieHelper->CreateDefaultUniqueSeriesIdentifier(); +} + } //namespace ITK #endif diff --git a/Utilities/ITK/Code/IO/itkGDCMSeriesFileNames.h b/Utilities/ITK/Code/IO/itkGDCMSeriesFileNames.h index bf2326ebbb2e4c9cbfa7626502f3565ba57c1a2b..ad4567ddd2e8cccb415fa20081e9ef6fe7d89a05 100644 --- a/Utilities/ITK/Code/IO/itkGDCMSeriesFileNames.h +++ b/Utilities/ITK/Code/IO/itkGDCMSeriesFileNames.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkGDCMSeriesFileNames.h,v $ Language: C++ - Date: $Date: 2009-04-25 12:25:42 $ - Version: $Revision: 1.18 $ + Date: $Date: 2010-02-25 00:55:49 $ + Version: $Revision: 1.19 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -119,12 +119,7 @@ public: * and SeriesName to identify when a single SeriesUID contains * multiple 3D volumes - as can occur with perfusion and DTI imaging */ - void SetUseSeriesDetails( bool useSeriesDetails) - { - m_UseSeriesDetails = useSeriesDetails; - m_SerieHelper->SetUseSeriesDetails( m_UseSeriesDetails ); - m_SerieHelper->CreateDefaultUniqueSeriesIdentifier(); - } + void SetUseSeriesDetails( bool useSeriesDetails); /** Returns true if using additional series information such as ProtocolName * and SeriesName to identify when a single SeriesUID contains diff --git a/Utilities/ITK/Code/IO/itkIOCommon.cxx b/Utilities/ITK/Code/IO/itkIOCommon.cxx index 35238096402c8351eed8384241918b0e06680c08..dc9013c32e4c8ecd001afeeb72ac2d39937a27a3 100644 --- a/Utilities/ITK/Code/IO/itkIOCommon.cxx +++ b/Utilities/ITK/Code/IO/itkIOCommon.cxx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkIOCommon.cxx,v $ Language: C++ - Date: $Date: 2009-04-05 10:56:48 $ - Version: $Revision: 1.29 $ + Date: $Date: 2009-12-03 14:09:13 $ + Version: $Revision: 1.32 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. diff --git a/Utilities/ITK/Code/IO/itkIOCommon.h b/Utilities/ITK/Code/IO/itkIOCommon.h index 34c8a14cb01808e3d296262b9fef7f9fd0014f44..42701fd0898ab67b19955d10a2eed396b937bdd7 100644 --- a/Utilities/ITK/Code/IO/itkIOCommon.h +++ b/Utilities/ITK/Code/IO/itkIOCommon.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkIOCommon.h,v $ Language: C++ - Date: $Date: 2008-05-27 11:41:08 $ - Version: $Revision: 1.27 $ + Date: $Date: 2009-12-03 14:09:14 $ + Version: $Revision: 1.30 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. diff --git a/Utilities/ITK/Code/IO/itkImageFileReader.txx b/Utilities/ITK/Code/IO/itkImageFileReader.txx index a708ea8369f2e7eb500e9b66045d620b5c029771..9099fe63e8d242d2bc7a6df823068c7360f51f07 100644 --- a/Utilities/ITK/Code/IO/itkImageFileReader.txx +++ b/Utilities/ITK/Code/IO/itkImageFileReader.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkImageFileReader.txx,v $ Language: C++ - Date: $Date: 2009-08-11 12:45:07 $ - Version: $Revision: 1.88 $ + Date: $Date: 2010-04-12 13:10:45 $ + Version: $Revision: 1.90 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -329,8 +329,12 @@ ImageFileReader<TOutputImage, ConvertPixelTraits> ImageIOAdaptor::Convert( m_ActualIORegion, streamableRegion, largestRegion.GetIndex() ); // Check whether the imageRequestedRegion is fully contained inside the - // streamable region - if( !streamableRegion.IsInside( imageRequestedRegion ) ) + // streamable region. Since, ImageRegion::IsInside regards zero + // sized regions, as not being inside any other region, we must + // specially check this condition to enable zero sized regions to + // pass the region propagation phase of the pipeline. + if( !streamableRegion.IsInside( imageRequestedRegion ) + && imageRequestedRegion.GetNumberOfPixels() != 0) { // we must use a InvalidRequestedRegionError since // DataObject::PropagateRequestedRegion() has an exception @@ -357,7 +361,6 @@ void ImageFileReader<TOutputImage, ConvertPixelTraits> { typename TOutputImage::Pointer output = this->GetOutput(); - typename TOutputImage::RegionType requestedRegion = output->GetRequestedRegion(); itkDebugMacro ( << "ImageFileReader::GenerateData() \n" << "Allocating the buffer with the EnlargedRequestedRegion \n" @@ -387,7 +390,7 @@ void ImageFileReader<TOutputImage, ConvertPixelTraits> itkDebugMacro (<< "Setting imageIO IORegion to: " << m_ActualIORegion ); m_ImageIO->SetIORegion( m_ActualIORegion ); - + char *loadBuffer = 0; // the size of the buffer is computed based on the actual number of // pixels to be read and the actual size of the pixels to be read @@ -411,10 +414,13 @@ void ImageFileReader<TOutputImage, ConvertPixelTraits> loadBuffer = new char[ sizeOfActualIORegion ]; m_ImageIO->Read( static_cast< void *>(loadBuffer) ); - this->DoConvertBuffer(static_cast< void *>(loadBuffer), m_ActualIORegion.GetNumberOfPixels() ); + // See note below as to why the buffered region is needed and + // not actualIOregion + this->DoConvertBuffer(static_cast< void *>(loadBuffer), output->GetBufferedRegion().GetNumberOfPixels() ); } - else if ( m_ActualIORegion.GetNumberOfPixels() != requestedRegion.GetNumberOfPixels() ) + else if ( m_ActualIORegion.GetNumberOfPixels() != output->GetBufferedRegion().GetNumberOfPixels() ) { + // NOTE: // for the number of pixels read and the number of pixels // requested to not match, the dimensions of the two regions may // be different, therefore we buffer and copy the pixels diff --git a/Utilities/ITK/Code/IO/itkImageIOBase.cxx b/Utilities/ITK/Code/IO/itkImageIOBase.cxx index 362726419c45038bd35954bf52500dfe62c75200..a80cc40163119cdde5b724347ada7d3046525421 100644 --- a/Utilities/ITK/Code/IO/itkImageIOBase.cxx +++ b/Utilities/ITK/Code/IO/itkImageIOBase.cxx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkImageIOBase.cxx,v $ Language: C++ - Date: $Date: 2009-05-19 19:26:25 $ - Version: $Revision: 1.85 $ + Date: $Date: 2010-02-24 14:40:36 $ + Version: $Revision: 1.89 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -581,7 +581,7 @@ ImageIOBase ::ReadBufferAsBinary(std::istream& is, void *buffer, ImageIOBase::SizeType num) { - const std::streamsize numberOfBytesToBeRead = static_cast< std::streamsize>( num ); + const std::streamsize numberOfBytesToBeRead = Math::CastWithRangeCheck< std::streamsize>( num ); is.read( static_cast<char *>( buffer ), numberOfBytesToBeRead ); @@ -751,10 +751,12 @@ template <class TComponent> void WriteBuffer(std::ostream& os, const TComponent *buffer, ImageIOBase::SizeType num) { const TComponent *ptr = buffer; + typedef typename itk::NumericTraits<TComponent>::PrintType PrintType; for (ImageIOBase::SizeType i=0; i < num; i++) { - if ( !(i%6) && i ) os << "\n"; - os << *ptr++ << " "; + if ( !(i%6) && i ) + os << "\n"; + os << PrintType(*ptr++) << " "; } } } @@ -853,10 +855,14 @@ void ImageIOBase::WriteBufferAsASCII(std::ostream& os, const void *buffer, template <class TComponent> void ReadBuffer(std::istream& is, TComponent *buffer, ImageIOBase::SizeType num) { + + typedef typename itk::NumericTraits<TComponent>::PrintType PrintType; + PrintType temp; TComponent *ptr = buffer; for( ImageIOBase::SizeType i=0; i < num; i++, ptr++ ) { - is >> *ptr; + is >> temp; + *ptr = static_cast<TComponent>( temp ); } } @@ -965,8 +971,8 @@ ImageIOBase::GetActualNumberOfSplitsForWritingCanStreamWrite(unsigned int number // determine the actual number of pieces that will be generated ImageIORegion::SizeType::value_type range = regionSize[splitAxis]; - int valuesPerPiece = (int)vcl_ceil(range/double(numberOfRequestedSplits)); - int maxPieceUsed = (int)vcl_ceil(range/double(valuesPerPiece)) - 1; + int valuesPerPiece = Math::Ceil<int>(range/double(numberOfRequestedSplits)); + int maxPieceUsed = Math::Ceil<int>(range/double(valuesPerPiece)) - 1; return maxPieceUsed+1; } @@ -1024,8 +1030,8 @@ ImageIOBase::GetSplitRegionForWritingCanStreamWrite(unsigned int ithPiece, // determine the actual number of pieces that will be generated ImageIORegion::SizeType::value_type range = regionSize[splitAxis]; - int valuesPerPiece = (int)vcl_ceil(range/(double)numberOfActualSplits); - int maxPieceUsed = (int)vcl_ceil(range/(double)valuesPerPiece) - 1; + int valuesPerPiece = Math::Ceil<int>(range/(double)numberOfActualSplits); + int maxPieceUsed = Math::Ceil<int>(range/(double)valuesPerPiece) - 1; // Split the region if ((int) ithPiece < maxPieceUsed) diff --git a/Utilities/ITK/Code/IO/itkImageIOBase.h b/Utilities/ITK/Code/IO/itkImageIOBase.h index 575163a2a6d1325795687857d3316852e9f528d8..854f826e9268739e6ea68940f75beb402c61c059 100644 --- a/Utilities/ITK/Code/IO/itkImageIOBase.h +++ b/Utilities/ITK/Code/IO/itkImageIOBase.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkImageIOBase.h,v $ Language: C++ - Date: $Date: 2009-07-02 13:16:48 $ - Version: $Revision: 1.54 $ + Date: $Date: 2009-11-29 15:51:11 $ + Version: $Revision: 1.56 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -70,6 +70,10 @@ public: itkSetStringMacro(FileName); itkGetStringMacro(FileName); + /** Types for managing image size and image index components. */ + typedef long IndexValueType; + typedef unsigned long SizeValueType; + /** * \class UnknownType * Used to return information when types are unknown. @@ -248,6 +252,9 @@ public: /** Type for representing size of bytes, and or positions along a file */ typedef std::streamoff SizeType; + /** Type for representing size of bytes, and or positions along a memory buffer */ + typedef size_t BufferSizeType; + /** Convenient method for accessing the number of bytes to get to * the next pixel. Returns m_Strides[1]; * @@ -436,7 +443,7 @@ protected: ImageIORegion m_IORegion; /** The array which stores the number of pixels in the x, y, z directions. */ - std::vector<unsigned int> m_Dimensions; + std::vector< SizeValueType > m_Dimensions; /** The array which stores the spacing of pixels in the * x, y, z directions. */ diff --git a/Utilities/ITK/Code/IO/itkImageSeriesReader.h b/Utilities/ITK/Code/IO/itkImageSeriesReader.h old mode 100644 new mode 100755 index 4eb791bb243a81c10e903b09082d85238416f136..16b53766c081042d90c551cfe86c56c62b2ab6cb --- a/Utilities/ITK/Code/IO/itkImageSeriesReader.h +++ b/Utilities/ITK/Code/IO/itkImageSeriesReader.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkImageSeriesReader.h,v $ Language: C++ - Date: $Date: 2009-07-30 20:00:00 $ - Version: $Revision: 1.18 $ + Date: $Date: 2010-03-29 14:54:22 $ + Version: $Revision: 1.19 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -124,6 +124,19 @@ public: itkSetObjectMacro(ImageIO,ImageIOBase); itkGetObjectMacro(ImageIO,ImageIOBase); + /** \brief Set/Get MetaDataDictionaryArrayUpdate enables the updating of + * the MetaDataDictionaryArray. + * + * By default this is enabled. It may be advantageous to disable + * this feature when streaming, if this array is not need, as it may + * redure the number of times each file is read. + * + * /sa GetMetaDataDictionaryArray() + */ + itkSetMacro(MetaDataDictionaryArrayUpdate,bool); + itkGetConstMacro(MetaDataDictionaryArrayUpdate,bool); + itkBooleanMacro(MetaDataDictionaryArrayUpdate); + /** Prepare the allocation of the output image during the first back * propagation of the pipeline. */ virtual void GenerateOutputInformation(void); @@ -135,7 +148,8 @@ public: * enlarge the RequestedRegion to the size of the image on disk. */ virtual void EnlargeOutputRequestedRegion(DataObject *output); - /** Get access to the Array of MetaDataDictionaries */ + /** Get access to the Array of MetaDataDictionaries which are +* updated in the GenerateData methods */ DictionaryArrayRawPointer GetMetaDataDictionaryArray() const; /** Set the stream On or Off */ @@ -144,7 +158,8 @@ public: itkBooleanMacro(UseStreaming); protected: - ImageSeriesReader() : m_ImageIO(0), m_ReverseOrder(false), m_UseStreaming(true) {}; + ImageSeriesReader() : m_ImageIO(0), m_ReverseOrder(false), + m_UseStreaming(true), m_MetaDataDictionaryArrayUpdate(true) {}; ~ImageSeriesReader(); void PrintSelf(std::ostream& os, Indent indent) const; @@ -180,6 +195,14 @@ private: typedef ImageFileReader<TOutputImage> ReaderType; int ComputeMovingDimensionIndex( ReaderType * reader ); + + + + /** Modified time of the MetaDataDictionaryArray */ + TimeStamp m_MetaDataDictionaryArrayMTime; + + /** Indicated if the MMDA should be updated */ + bool m_MetaDataDictionaryArrayUpdate; }; } //namespace ITK diff --git a/Utilities/ITK/Code/IO/itkImageSeriesReader.txx b/Utilities/ITK/Code/IO/itkImageSeriesReader.txx old mode 100644 new mode 100755 index 457a1d2a986e8b178900a5c62c3b73dd40a1308e..292808b67a43db850468cf42594362eb9f370f96 --- a/Utilities/ITK/Code/IO/itkImageSeriesReader.txx +++ b/Utilities/ITK/Code/IO/itkImageSeriesReader.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkImageSeriesReader.txx,v $ Language: C++ - Date: $Date: 2009-07-30 20:00:00 $ - Version: $Revision: 1.38 $ + Date: $Date: 2010-03-29 14:54:21 $ + Version: $Revision: 1.39 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -67,6 +67,9 @@ void ImageSeriesReader<TOutputImage> { os << indent << "ImageIO: (null)" << "\n"; } + + os << indent << "MetaDataDictionaryArrayMTime: " << m_MetaDataDictionaryArrayMTime << std::endl; + os << indent << "MetaDataDictionaryArrayUpdate: " << m_MetaDataDictionaryArrayUpdate << std::endl; } @@ -114,7 +117,8 @@ void ImageSeriesReader<TOutputImage> origin.Fill(0.0); std::string key("ITK_ImageOrigin"); - // Clear the eventual previous content of the MetaDictionary array + + // Clear the previous content of the MetaDictionary array if( m_MetaDataDictionaryArray.size() ) { for(unsigned int i=0; i<m_MetaDataDictionaryArray.size(); i++) @@ -132,7 +136,7 @@ void ImageSeriesReader<TOutputImage> const int numberOfFiles = static_cast<int>(m_FileNames.size()); - for ( int i = 0; i != numberOfFiles; ++i ) + for ( int i = 0; i < 2 && i < numberOfFiles; ++i ) { const int iFileName = ( m_ReverseOrder ? numberOfFiles - i - 1: i ); @@ -146,15 +150,6 @@ void ImageSeriesReader<TOutputImage> // update the MetaDataDictionary and output information reader->UpdateOutputInformation(); - // Deep copy the MetaDataDictionary into the array - if ( reader->GetImageIO() ) - { - DictionaryRawPointer newDictionary = new DictionaryType; - *newDictionary = reader->GetImageIO()->GetMetaDataDictionary(); - m_MetaDataDictionaryArray.push_back( newDictionary ); - } - - if (m_FileNames.size() == 1) { // ---------------------------- @@ -314,18 +309,15 @@ void ImageSeriesReader<TOutputImage> requestedRegion.GetNumberOfPixels(), 100 ); + // We utilize the modified time of the output information to + // know when the meta array needs to be updated, when the output + // information is updated so should the meta array. + // Each file can not be read in the UpdateOutputInformation methods + // due to the poor performance of reading each file a second time there. + bool needToUpdateMetaDataDictionaryArray = + this->m_OutputInformationMTime > this->m_MetaDataDictionaryArrayMTime && + m_MetaDataDictionaryArrayUpdate; - // Clear the eventual previous content of the MetaDictionary array - // shouldn't this be done in the generate output info? - if( m_MetaDataDictionaryArray.size() ) - { - for(unsigned int i=0; i<m_MetaDataDictionaryArray.size(); i++) - { - // each element is a raw pointer, delete them. - delete m_MetaDataDictionaryArray[i]; - } - } - m_MetaDataDictionaryArray.clear(); ImageRegionIterator<TOutputImage> ot (output, requestedRegion ); IndexType sliceStartIndex = requestedRegion.GetIndex(); @@ -338,14 +330,17 @@ void ImageSeriesReader<TOutputImage> sliceStartIndex[this->m_NumberOfDimensionsInImage] = i; } - // if this slice in not in the requested region then skip this file - if( !requestedRegion.IsInside(sliceStartIndex) ) + const bool insideRequestedRegion = requestedRegion.IsInside(sliceStartIndex); + const int iFileName = ( m_ReverseOrder ? numberOfFiles - i - 1: i ); + + // check if we need this slice + if( !insideRequestedRegion && !needToUpdateMetaDataDictionaryArray ) { continue; } - const int iFileName = ( m_ReverseOrder ? numberOfFiles - i - 1: i ); + // configure reader typename ReaderType::Pointer reader = ReaderType::New(); reader->SetFileName( m_FileNames[iFileName].c_str() ); if ( m_ImageIO ) @@ -354,16 +349,31 @@ void ImageSeriesReader<TOutputImage> } reader->SetUseStreaming( m_UseStreaming ); reader->GetOutput()->SetRequestedRegion( sliceRegionToRequest ); - reader->Update(); + + // update the data or info + if( !insideRequestedRegion ) + { + reader->UpdateOutputInformation(); + } + else + { + reader->Update(); + } // Deep copy the MetaDataDictionary into the array - if ( reader->GetImageIO() ) + if ( reader->GetImageIO() && needToUpdateMetaDataDictionaryArray ) { DictionaryRawPointer newDictionary = new DictionaryType; *newDictionary = reader->GetImageIO()->GetMetaDataDictionary(); m_MetaDataDictionaryArray.push_back( newDictionary ); } + // if we only needed the info continue to next slice + if ( !insideRequestedRegion ) + { + continue; + } + if ( reader->GetOutput()->GetLargestPossibleRegion().GetSize() != validSize ) { itkExceptionMacro(<< "Size mismatch! The size of " @@ -374,8 +384,8 @@ void ImageSeriesReader<TOutputImage> << validSize << " from file " << m_FileNames[m_ReverseOrder ? m_FileNames.size()-1 : 0].c_str()); - } - + } + // set the iterator for this slice ot.SetIndex( sliceStartIndex ); @@ -390,6 +400,12 @@ void ImageSeriesReader<TOutputImage> progress.CompletedPixel(); } } + + // update the time if we modified the meta array + if ( needToUpdateMetaDataDictionaryArray ) + { + m_MetaDataDictionaryArrayMTime.Modified(); + } } @@ -399,6 +415,12 @@ ImageSeriesReader<TOutputImage>::DictionaryArrayRawPointer ImageSeriesReader<TOutputImage> ::GetMetaDataDictionaryArray() const { + // this warning has been introduced in 3.17 due to a change in + // behavior. It may be removed in the future. + if (this->m_OutputInformationMTime > this->m_MetaDataDictionaryArrayMTime ) + { + itkWarningMacro( "The MetaDataDictionaryArray is not up to date. This is no longer updated in the UpdateOutputInformation method but in GenerateData.") + } return & m_MetaDataDictionaryArray; } diff --git a/Utilities/ITK/Code/IO/itkImageSeriesWriter.h b/Utilities/ITK/Code/IO/itkImageSeriesWriter.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/IO/itkImageSeriesWriter.txx b/Utilities/ITK/Code/IO/itkImageSeriesWriter.txx old mode 100644 new mode 100755 index e999d886f60aa8ad0db82ea0bd35cea65a96261b..46910421d05f210050dcca379f47307cbef37a3a --- a/Utilities/ITK/Code/IO/itkImageSeriesWriter.txx +++ b/Utilities/ITK/Code/IO/itkImageSeriesWriter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkImageSeriesWriter.txx,v $ Language: C++ - Date: $Date: 2009-05-11 19:26:54 $ - Version: $Revision: 1.33 $ + Date: $Date: 2009-12-03 14:09:14 $ + Version: $Revision: 1.36 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. diff --git a/Utilities/ITK/Code/IO/itkJPEGImageIO.cxx b/Utilities/ITK/Code/IO/itkJPEGImageIO.cxx index 883303fc7c770cf978dd344bb5c67fe139f332a3..7dea718f5491de876b4bf4d44c9cf487062fb12a 100644 --- a/Utilities/ITK/Code/IO/itkJPEGImageIO.cxx +++ b/Utilities/ITK/Code/IO/itkJPEGImageIO.cxx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkJPEGImageIO.cxx,v $ Language: C++ - Date: $Date: 2009-04-23 15:21:52 $ - Version: $Revision: 1.27 $ + Date: $Date: 2009-12-15 20:01:01 $ + Version: $Revision: 1.28 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -451,10 +451,8 @@ void JPEGImageIO::WriteImageInformation(void) void JPEGImageIO::Write(const void* buffer) { - ImageIORegion ioRegion = this->GetIORegion(); - - // Make sure the region to be written is 2D - if ( ioRegion.GetRegionDimension() != 2 ) + // the IORegion is not requred to be set so we must use GetNumberOfDimensions + if ( this->GetNumberOfDimensions() != 2 ) { itkExceptionMacro(<<"JPEG Writer can only write 2-dimensional images"); } diff --git a/Utilities/ITK/Code/IO/itkMetaArrayReader.cxx b/Utilities/ITK/Code/IO/itkMetaArrayReader.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/IO/itkMetaArrayReader.h b/Utilities/ITK/Code/IO/itkMetaArrayReader.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/IO/itkMetaArrayWriter.cxx b/Utilities/ITK/Code/IO/itkMetaArrayWriter.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/IO/itkMetaArrayWriter.h b/Utilities/ITK/Code/IO/itkMetaArrayWriter.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/IO/itkMetaImageIO.cxx b/Utilities/ITK/Code/IO/itkMetaImageIO.cxx index eedb4b91e51c6dc5685cf07f64a1181a99f30dc9..ecd6505ec13c4c3979ea9abd7a1b49a059d5bfd0 100644 --- a/Utilities/ITK/Code/IO/itkMetaImageIO.cxx +++ b/Utilities/ITK/Code/IO/itkMetaImageIO.cxx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkMetaImageIO.cxx,v $ Language: C++ - Date: $Date: 2009-07-07 22:03:39 $ - Version: $Revision: 1.102 $ + Date: $Date: 2009-12-15 14:28:19 $ + Version: $Revision: 1.104 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -894,17 +894,26 @@ void MetaImageIO::Read(void* buffer) delete [] indexMin; delete [] indexMax; + + + m_MetaImage.ElementByteOrderFix( m_IORegion.GetNumberOfPixels() ); + } - else if(!m_MetaImage.Read(m_FileName.c_str(), true, buffer)) + else { - itkExceptionMacro("File cannot be read: " - << this->GetFileName() << " for reading." - << std::endl - << "Reason: " - << itksys::SystemTools::GetLastSystemError()); + if(!m_MetaImage.Read(m_FileName.c_str(), true, buffer)) + { + itkExceptionMacro("File cannot be read: " + << this->GetFileName() << " for reading." + << std::endl + << "Reason: " + << itksys::SystemTools::GetLastSystemError()); + } + + // since we are not streaming m_IORegion may not be set, so + m_MetaImage.ElementByteOrderFix( this->GetImageSizeInPixels() ); } - m_MetaImage.ElementByteOrderFix( m_IORegion.GetNumberOfPixels() ); } MetaImage * MetaImageIO::GetMetaImagePointer(void) @@ -1450,7 +1459,7 @@ MetaImageIO::GetActualNumberOfSplitsForWriting(unsigned int numberOfRequestedSpl itkDebugMacro("Requested streaming and compression"); itkDebugMacro("Meta IO is not streaming now!"); } - return 1; + return 1; } if (!itksys::SystemTools::FileExists( m_FileName.c_str() )) @@ -1547,7 +1556,7 @@ MetaImageIO::GetActualNumberOfSplitsForWriting(unsigned int numberOfRequestedSpl { // we are going be streaming - // need to remove the file incase the file doesn't match out + // need to remove the file incase the file doesn't match our // current header/meta data information if (!itksys::SystemTools::RemoveFile(m_FileName.c_str())) itkExceptionMacro("Unable to remove file for streaming: " << m_FileName); diff --git a/Utilities/ITK/Code/IO/itkNiftiImageIO.cxx b/Utilities/ITK/Code/IO/itkNiftiImageIO.cxx index 0b486f86ceeddc28a0f80813e3ffa68d71136c90..ef6cb52c1ad12a1f271f60dba048c205a662fdc4 100644 --- a/Utilities/ITK/Code/IO/itkNiftiImageIO.cxx +++ b/Utilities/ITK/Code/IO/itkNiftiImageIO.cxx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkNiftiImageIO.cxx,v $ Language: C++ - Date: $Date: 2009-07-29 02:41:20 $ - Version: $Revision: 1.85 $ + Date: $Date: 2009-11-22 13:33:11 $ + Version: $Revision: 1.87 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -736,6 +736,166 @@ NiftiImageIO return false; } +// This method adds the available header information to the +// metadata dictionary. +void NiftiImageIO::SetImageIOMetadataFromNIfTI() +{ + int swap = 0; + nifti_1_header *header = nifti_read_header(this->GetFileName(), &swap, true); + if (header) + { + // Encapsulate as many header information as possible. + MetaDataDictionary &thisDic = this->GetMetaDataDictionary(); + + std::ostringstream dim_info; + dim_info << header->dim_info; + EncapsulateMetaData<std::string>(thisDic, "dim_info", dim_info.str()); + + for (int idx = 0; idx < 8; idx++) + { + std::ostringstream dim; + dim << header->dim[idx]; + std::ostringstream dimKey; + dimKey << "dim[" << idx << "]"; + EncapsulateMetaData<std::string>(thisDic, dimKey.str(), dim.str()); + } + + std::ostringstream intent_p1; + intent_p1 << header->intent_p1; + EncapsulateMetaData<std::string>(thisDic, "intent_p1", intent_p1.str()); + + std::ostringstream intent_p2; + intent_p2 << header->intent_p2; + EncapsulateMetaData<std::string>(thisDic, "intent_p2", intent_p2.str()); + + std::ostringstream intent_p3; + intent_p3 << header->intent_p3; + EncapsulateMetaData<std::string>(thisDic, "intent_p3", intent_p3.str()); + + std::ostringstream intent_code; + intent_code << header->intent_code; + EncapsulateMetaData<std::string>(thisDic, "intent_code", intent_code.str()); + + std::ostringstream datatype; + datatype << header->datatype; + EncapsulateMetaData<std::string>(thisDic, "datatype", datatype.str()); + + std::ostringstream bitpix; + bitpix << header->bitpix; + EncapsulateMetaData<std::string>(thisDic, "bitpix", bitpix.str()); + + std::ostringstream slice_start; + slice_start << header->slice_start; + EncapsulateMetaData<std::string>(thisDic, "slice_start", slice_start.str()); + + for (int idx = 0; idx < 8; idx++) + { + std::ostringstream pixdim; + pixdim << header->pixdim[idx]; + std::ostringstream pixdimKey; + pixdimKey << "pixdim[" << idx << "]"; + EncapsulateMetaData<std::string>(thisDic, pixdimKey.str(), pixdim.str()); + } + + std::ostringstream vox_offset; + vox_offset << header->vox_offset; + EncapsulateMetaData<std::string>(thisDic, "vox_offset", vox_offset.str()); + + std::ostringstream scl_slope; + scl_slope << header->scl_slope; + EncapsulateMetaData<std::string>(thisDic, "scl_slope", scl_slope.str()); + + std::ostringstream scl_inter; + scl_inter << header->scl_inter; + EncapsulateMetaData<std::string>(thisDic, "scl_inter", scl_inter.str()); + + std::ostringstream slice_end; + slice_end << header->slice_end; + EncapsulateMetaData<std::string>(thisDic, "slice_end", slice_end.str()); + + std::ostringstream slice_code; + slice_code << header->slice_code; + EncapsulateMetaData<std::string>(thisDic, "slice_code", slice_code.str()); + + std::ostringstream xyzt_units; + xyzt_units << header->xyzt_units; + EncapsulateMetaData<std::string>(thisDic, "xyzt_units", xyzt_units.str()); + + std::ostringstream cal_max; + cal_max << header->cal_max; + EncapsulateMetaData<std::string>(thisDic, "cal_max", cal_max.str()); + + std::ostringstream cal_min; + cal_min << header->cal_min; + EncapsulateMetaData<std::string>(thisDic, "cal_min", cal_min.str()); + + std::ostringstream slice_duration; + slice_duration << header->slice_duration; + EncapsulateMetaData<std::string>(thisDic, "slice_duration", slice_duration.str()); + + std::ostringstream toffset; + toffset << header->toffset; + EncapsulateMetaData<std::string>(thisDic, "toffset", toffset.str()); + + std::ostringstream descrip; + descrip << header->descrip; + EncapsulateMetaData<std::string>(thisDic, "descrip", descrip.str()); + + std::ostringstream aux_file; + aux_file << header->aux_file; + EncapsulateMetaData<std::string>(thisDic, "aux_file", aux_file.str()); + + std::ostringstream qform_code; + qform_code << header->qform_code; + EncapsulateMetaData<std::string>(thisDic, "qform_code", qform_code.str()); + + std::ostringstream sform_code; + sform_code << header->sform_code; + EncapsulateMetaData<std::string>(thisDic, "sform_code", sform_code.str()); + + std::ostringstream quatern_b; + quatern_b << header->quatern_b; + EncapsulateMetaData<std::string>(thisDic, "quatern_b", quatern_b.str()); + + std::ostringstream quatern_c; + quatern_c << header->quatern_c; + EncapsulateMetaData<std::string>(thisDic, "quatern_c", quatern_c.str()); + + std::ostringstream quatern_d; + quatern_d << header->quatern_d; + EncapsulateMetaData<std::string>(thisDic, "quatern_d", quatern_d.str()); + + std::ostringstream qoffset_x; + qoffset_x << header->qoffset_x; + EncapsulateMetaData<std::string>(thisDic, "qoffset_x", qoffset_x.str()); + + std::ostringstream qoffset_y; + qoffset_y << header->qoffset_y; + EncapsulateMetaData<std::string>(thisDic, "qoffset_y", qoffset_y.str()); + + std::ostringstream qoffset_z; + qoffset_z << header->qoffset_z; + EncapsulateMetaData<std::string>(thisDic, "qoffset_z", qoffset_z.str()); + + std::ostringstream srow_x; + srow_x << header->srow_x[0] << " " << header->srow_x[1] << " " << header->srow_x[2] << " " << header->srow_x[3]; + EncapsulateMetaData<std::string>(thisDic, "srow_x", srow_x.str()); + + std::ostringstream srow_y; + srow_y << header->srow_y[0] << " " << header->srow_y[1] << " " << header->srow_y[2] << " " << header->srow_y[3]; + EncapsulateMetaData<std::string>(thisDic, "srow_y", srow_y.str()); + + std::ostringstream srow_z; + srow_z << header->srow_z[0] << " " << header->srow_z[1] << " " << header->srow_z[2] << " " << header->srow_z[3]; + EncapsulateMetaData<std::string>(thisDic, "srow_z", srow_z.str()); + + std::ostringstream intent_name; + intent_name << header->intent_name; + EncapsulateMetaData<std::string>(thisDic, "intent_name", intent_name.str()); + free(header); + } +} + void NiftiImageIO ::ReadImageInformation() @@ -1113,6 +1273,9 @@ NiftiImageIO // set the image orientation this->SetImageIOOrientationFromNIfTI(dims); + // Set the metadata. + this->SetImageIOMetadataFromNIfTI(); + //Important hist fields std::string description(this->m_NiftiImage->descrip); EncapsulateMetaData<std::string>(this->GetMetaDataDictionary(), diff --git a/Utilities/ITK/Code/IO/itkNiftiImageIO.h b/Utilities/ITK/Code/IO/itkNiftiImageIO.h index 9ad8d8f09be64dc859b7996194c8cc6ec0a22cb5..ba65acfab35f85b9225d708d8c06de960491e27f 100644 --- a/Utilities/ITK/Code/IO/itkNiftiImageIO.h +++ b/Utilities/ITK/Code/IO/itkNiftiImageIO.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkNiftiImageIO.h,v $ Language: C++ - Date: $Date: 2009-04-25 12:25:44 $ - Version: $Revision: 1.15 $ + Date: $Date: 2009-11-03 19:07:08 $ + Version: $Revision: 1.16 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -114,6 +114,7 @@ private: void DefineHeaderObjectDataType(); void SetNIfTIOrientationFromImageIO(unsigned short int origdims, unsigned short int dims); void SetImageIOOrientationFromNIfTI(unsigned short int dims); + void SetImageIOMetadataFromNIfTI(); nifti_image * m_NiftiImage; double m_RescaleSlope; diff --git a/Utilities/ITK/Code/IO/itkNrrdImageIO.cxx b/Utilities/ITK/Code/IO/itkNrrdImageIO.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/IO/itkRawImageIO.h b/Utilities/ITK/Code/IO/itkRawImageIO.h index f99289f86a175c6c999dd4aee365b1aef6ae6a7c..edf884a679c7efee23586acb3b98087dd59bfef3 100644 --- a/Utilities/ITK/Code/IO/itkRawImageIO.h +++ b/Utilities/ITK/Code/IO/itkRawImageIO.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkRawImageIO.h,v $ Language: C++ - Date: $Date: 2009-04-25 12:25:45 $ - Version: $Revision: 1.34 $ + Date: $Date: 2009-09-29 14:43:53 $ + Version: $Revision: 1.35 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -36,7 +36,7 @@ namespace itk * * This class reads and writes 2D or 3D images. Because raw data has * little useful information built into the format, - * so the user is responsible for specifying pixel type, + * the user is responsible for specifying pixel type, * dimensions, spacing, origin, header type, and so on. (Note: the * pixel type and image dimension is defined via the template parameter.) * diff --git a/Utilities/ITK/Code/IO/itkStimulateImageIO.cxx b/Utilities/ITK/Code/IO/itkStimulateImageIO.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/IO/itkStimulateImageIO.h b/Utilities/ITK/Code/IO/itkStimulateImageIO.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/IO/itkStimulateImageIOFactory.cxx b/Utilities/ITK/Code/IO/itkStimulateImageIOFactory.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/IO/itkStimulateImageIOFactory.h b/Utilities/ITK/Code/IO/itkStimulateImageIOFactory.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/IO/itkTransformFileReader.cxx b/Utilities/ITK/Code/IO/itkTransformFileReader.cxx index 0169ad720c220c6590b4943c07d56b2e76c83514..37709baabf27589321b45e7dc43f6470dc3173ae 100644 --- a/Utilities/ITK/Code/IO/itkTransformFileReader.cxx +++ b/Utilities/ITK/Code/IO/itkTransformFileReader.cxx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkTransformFileReader.cxx,v $ Language: C++ - Date: $Date: 2008-05-13 18:46:18 $ - Version: $Revision: 1.25 $ + Date: $Date: 2010-02-08 20:23:21 $ + Version: $Revision: 1.26 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -108,10 +108,21 @@ void TransformFileReader bool haveFixedParameters = false; bool haveParameters = false; + // + // check for line end convention + std::string line_end("\n"); + if(data.find('\n') == std::string::npos) + { + if(data.find('\r') == std::string::npos) + { + itkExceptionMacro ( "No line ending character found, not a valid ITK Transform TXT file" ); + } + line_end = "\r"; + } while ( position < data.size() ) { // Find the next string - std::string::size_type end = data.find ( "\n", position ); + std::string::size_type end = data.find ( line_end, position ); std::string line = trim ( data.substr ( position, end - position ) ); position = end+1; itkDebugMacro ("Found line: \"" << line << "\"" ); diff --git a/Utilities/ITK/Code/IO/itkVTKImageIO.cxx b/Utilities/ITK/Code/IO/itkVTKImageIO.cxx index 8a67f230ad0e6e984dfb870e1434746f8676e272..8f515a0ae018bf8977d308ce1b5d6740e49f1bea 100644 --- a/Utilities/ITK/Code/IO/itkVTKImageIO.cxx +++ b/Utilities/ITK/Code/IO/itkVTKImageIO.cxx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkVTKImageIO.cxx,v $ Language: C++ - Date: $Date: 2009-04-05 10:56:48 $ - Version: $Revision: 1.48 $ + Date: $Date: 2009-11-29 15:54:05 $ + Version: $Revision: 1.49 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -367,8 +367,6 @@ void VTKImageIO::Read(void* buffer) { std::ifstream file; - typedef ::size_t BufferSizeType; - this->InternalReadImageInformation(file); //We are positioned at the data. The data is read depending on whether @@ -506,7 +504,7 @@ void VTKImageIO::Write(const void* buffer) else //binary { int size = this->GetComponentSize(); - typedef ::size_t BufferSizeType; + const BufferSizeType numbytes = static_cast<BufferSizeType>( this->GetImageSizeInBytes() ); char * tempmemory=new char[numbytes]; memcpy(tempmemory,buffer,numbytes); diff --git a/Utilities/ITK/Code/Numerics/CMakeLists.txt b/Utilities/ITK/Code/Numerics/CMakeLists.txt index ba91cc246515e1d229b5dd6bed16ff8796be9fe2..6392718c78997c174fa63900d99b3756df30b3fa 100644 --- a/Utilities/ITK/Code/Numerics/CMakeLists.txt +++ b/Utilities/ITK/Code/Numerics/CMakeLists.txt @@ -50,10 +50,17 @@ IF(NOT ITK_INSTALL_NO_LIBRARIES) ARCHIVE DESTINATION ${ITK_INSTALL_LIB_DIR_CM24} COMPONENT Development) ENDIF(NOT ITK_INSTALL_NO_LIBRARIES) +IF(ITK_USE_FLAT_DIRECTORY_INSTALL) + SET( ITK_INSTALL_INCLUDE_DIR_CM24_NUMERICS ${ITK_INSTALL_INCLUDE_DIR_CM24}) +ELSE(ITK_USE_FLAT_DIRECTORY_INSTALL) + SET( ITK_INSTALL_INCLUDE_DIR_CM24_NUMERICS ${ITK_INSTALL_INCLUDE_DIR_CM24}/Numerics) +ENDIF(ITK_USE_FLAT_DIRECTORY_INSTALL) + + IF(NOT ITK_INSTALL_NO_DEVELOPMENT) FILE(GLOB __files1 "${CMAKE_CURRENT_SOURCE_DIR}/*.h") FILE(GLOB __files2 "${CMAKE_CURRENT_SOURCE_DIR}/*.txx") INSTALL(FILES ${__files1} ${__files2} - DESTINATION ${ITK_INSTALL_INCLUDE_DIR_CM24}/Numerics + DESTINATION ${ITK_INSTALL_INCLUDE_DIR_CM24_NUMERICS} COMPONENT Development) ENDIF(NOT ITK_INSTALL_NO_DEVELOPMENT) diff --git a/Utilities/ITK/Code/Numerics/FEM/CMakeLists.txt b/Utilities/ITK/Code/Numerics/FEM/CMakeLists.txt index 7a295544f405d4e9887cb17e3f2497b252cc1abd..9c2deb0b06702da361d7214815f947c6ccdbd466 100644 --- a/Utilities/ITK/Code/Numerics/FEM/CMakeLists.txt +++ b/Utilities/ITK/Code/Numerics/FEM/CMakeLists.txt @@ -220,10 +220,17 @@ IF(NOT ITK_INSTALL_NO_LIBRARIES) ARCHIVE DESTINATION ${ITK_INSTALL_LIB_DIR_CM24} COMPONENT Development) ENDIF(NOT ITK_INSTALL_NO_LIBRARIES) +IF(ITK_USE_FLAT_DIRECTORY_INSTALL) + SET( ITK_INSTALL_INCLUDE_DIR_CM24_NUMERICS_FEM ${ITK_INSTALL_INCLUDE_DIR_CM24}) +ELSE(ITK_USE_FLAT_DIRECTORY_INSTALL) + SET( ITK_INSTALL_INCLUDE_DIR_CM24_NUMERICS_FEM ${ITK_INSTALL_INCLUDE_DIR_CM24}/Numerics/FEM) +ENDIF(ITK_USE_FLAT_DIRECTORY_INSTALL) + + IF(NOT ITK_INSTALL_NO_DEVELOPMENT) FILE(GLOB __files1 "${CMAKE_CURRENT_SOURCE_DIR}/*.h") FILE(GLOB __files2 "${CMAKE_CURRENT_SOURCE_DIR}/*.txx") INSTALL(FILES ${__files1} ${__files2} - DESTINATION ${ITK_INSTALL_INCLUDE_DIR_CM24}/Numerics/FEM + DESTINATION ${ITK_INSTALL_INCLUDE_DIR_CM24_NUMERICS_FEM} COMPONENT Development) ENDIF(NOT ITK_INSTALL_NO_DEVELOPMENT) diff --git a/Utilities/ITK/Code/Numerics/FEM/dsrc2c.c b/Utilities/ITK/Code/Numerics/FEM/dsrc2c.c index 2518e292f227fbf55064666694a990a2965c30e1..6728afa43e1d36910e20c0f9366ada018811dce6 100644 --- a/Utilities/ITK/Code/Numerics/FEM/dsrc2c.c +++ b/Utilities/ITK/Code/Numerics/FEM/dsrc2c.c @@ -302,15 +302,24 @@ int jcg_(integer *n, integer *ia, integer *ja, doublereal *a, doublereal *rhs, d return 0; if (iparm[10] == 0) - timj1 = dsrc_timer_((real*)0); + { + timj1 = (real)( dsrc_timer_((real*)0) ); + } if (itcom1_1.level < 3) - echout_(iparm, rparm, &c__1); + { + echout_(iparm, rparm, &c__1); + } else - echall_(n, ia, ja, a, rhs, iparm, rparm, &c__1); + { + echall_(n, ia, ja, a, rhs, iparm, rparm, &c__1); + } + temp = itcom3_1.drelpr * 500.; if (itcom3_1.zeta < temp) - itcom3_1.zeta = temp; + { + itcom3_1.zeta = temp; + } time1 = rparm[8]; time2 = rparm[9]; @@ -381,7 +390,9 @@ L170: goto L370; if (iparm[10] == 0) - timi1 = dsrc_timer_((real*)0); + { + timi1 = (real)( dsrc_timer_((real*)0) ); + } /* ... COMPUTE INITIAL PSEUDO-RESIDUAL */ @@ -424,7 +435,7 @@ L240: /* ... ITMAX HAS BEEN REACHED */ if (iparm[10] == 0) { - timi2 = dsrc_timer_((real*)0); + timi2 = (real)( dsrc_timer_((real*)0) ); time1 = (doublereal) (timi2 - timi1); } ier = 13; @@ -437,7 +448,7 @@ L240: L280: if (iparm[10] == 0) { - timi2 = dsrc_timer_((real*)0); + timi2 = (real)( dsrc_timer_((real*)0) ); time1 = (doublereal) (timi2 - timi1); } @@ -482,7 +493,7 @@ L340: iparm[7] -= (itcom1_1.itmax - itcom1_1.in) << 1; if (iparm[10] == 0) { - timj2 = dsrc_timer_((real*)0); + timj2 = (real)( dsrc_timer_((real*)0) ); time2 = (doublereal) (timj2 - timj1); } if (itcom1_1.isym != 0) @@ -650,7 +661,7 @@ int jsi_(integer *n, integer *ia, integer *ja, doublereal *a, doublereal *rhs, d return 0; if (iparm[10] == 0) - timj1 = dsrc_timer_((real*)0); + timj1 = (real)( dsrc_timer_((real*)0) ); if (itcom1_1.level < 3) echout_(iparm, rparm, &c__2); @@ -724,7 +735,9 @@ L170: goto L360; if (iparm[10] == 0) - timi1 = dsrc_timer_((real*)0); + { + timi1 = (real)( dsrc_timer_((real*)0) ); + } /* ... ITERATION SEQUENCE */ @@ -761,7 +774,7 @@ L230: /* ... ITMAX HAS BEEN REACHED */ if (iparm[10] == 0) { - timi2 = dsrc_timer_((real*)0); + timi2 = (real)( dsrc_timer_((real*)0) ); time1 = (doublereal) (timi2 - timi1); } ier = 23; @@ -774,7 +787,7 @@ L230: L270: if (iparm[10] == 0) { - timi2 = dsrc_timer_((real*)0); + timi2 = (real)( dsrc_timer_((real*)0) ); time1 = (doublereal) (timi2 - timi1); } @@ -818,7 +831,7 @@ L330: /* ... SET RETURN PARAMETERS IN IPARM AND RPARM */ if (iparm[10] == 0) { - timj2 = dsrc_timer_((real*)0); + timj2 = (real)( dsrc_timer_((real*)0) ); time2 = (doublereal) (timj2 - timj1); } if (iparm[2] == 0) { @@ -980,7 +993,9 @@ int sor_(integer *n, integer *ia, integer *ja, doublereal *a, doublereal *rhs, d return 0; if (iparm[10] == 0) - timj1 = dsrc_timer_((real*)0); + { + timj1 = (real)( dsrc_timer_((real*)0) ); + } if (itcom1_1.level < 3) echout_(iparm, rparm, &c__3); @@ -1055,7 +1070,7 @@ L170: goto L360; if (iparm[10] == 0) - timi1 = dsrc_timer_((real*)0); + timi1 = (real)( dsrc_timer_((real*)0) ); /* ... ITERATION SEQUENCE */ @@ -1076,7 +1091,7 @@ L170: /* ... ITMAX HAS BEEN REACHED */ if (iparm[10] == 0) { - timi2 = dsrc_timer_((real*)0); + timi2 = (real)( dsrc_timer_((real*)0) ); time1 = (doublereal) (timi2 - timi1); } ier = 33; @@ -1089,7 +1104,7 @@ L170: L270: if (iparm[10] == 0) { - timi2 = dsrc_timer_((real*)0); + timi2 = (real)( dsrc_timer_((real*)0) ); time1 = (doublereal) (timi2 - timi1); } @@ -1128,7 +1143,7 @@ L330: /* ... SET RETURN PARAMETERS IN IPARM AND RPARM */ if (iparm[10] == 0) { - timj2 = dsrc_timer_((real*)0); + timj2 = (real)( dsrc_timer_((real*)0) ); time2 = (doublereal) (timj2 - timj1); } if (iparm[2] == 0) { @@ -1301,7 +1316,7 @@ int ssorcg_(integer *n, integer *ia, integer *ja, doublereal *a, doublereal *rhs return 0; if (iparm[10] == 0) - timj1 = dsrc_timer_((real*)0); + timj1 = (real)( dsrc_timer_((real*)0) ); if (itcom1_1.level < 3) echout_(iparm, rparm, &c__4); @@ -1383,7 +1398,7 @@ L170: goto L390; if (iparm[10] == 0) - timi1 = dsrc_timer_((real*)0); + timi1 = (real)( dsrc_timer_((real*)0) ); /* ... SPECIAL PROCEDURE FOR FULLY ADAPTIVE CASE. */ @@ -1442,7 +1457,7 @@ L260: /* ... ITMAX HAS BEEN REACHED */ if (iparm[10] == 0) { - timi2 = dsrc_timer_((real*)0); + timi2 = (real)( dsrc_timer_((real*)0) ); time1 = (doublereal) (timi2 - timi1); } ier = 43; @@ -1455,7 +1470,7 @@ L260: L300: if (iparm[10] == 0) { - timi2 = dsrc_timer_((real*)0); + timi2 = (real)( dsrc_timer_((real*)0) ); time1 = (doublereal) (timi2 - timi1); } @@ -1499,7 +1514,7 @@ L360: /* ... SET RETURN PARAMETERS IN IPARM AND RPARM */ if (iparm[10] == 0) { - timj2 = dsrc_timer_((real*)0); + timj2 = (real)( dsrc_timer_((real*)0) ); time2 = (doublereal) (timj2 - timj1); } iparm[7] -= (itcom1_1.itmax - itcom1_1.in) << 1; @@ -1675,7 +1690,7 @@ int ssorsi_(integer *n, integer *ia, integer *ja, doublereal *a, doublereal *rhs return 0; if (iparm[10] == 0) - timj1 = dsrc_timer_((real*)0); + timj1 = (real)( dsrc_timer_((real*)0) ); if (itcom1_1.level < 3) echout_(iparm, rparm, &c__5); @@ -1750,7 +1765,7 @@ L170: goto L380; if (iparm[10] == 0) - timi1 = dsrc_timer_((real*)0); + timi1 = (real)( dsrc_timer_((real*)0) ); /* ... SPECIAL PROCEDURE FOR FULLY ADAPTIVE CASE. */ @@ -1802,7 +1817,7 @@ L250: /* ... ITMAX HAS BEEN REACHED */ if (iparm[10] == 0) { - timi2 = dsrc_timer_((real*)0); + timi2 = (real)( dsrc_timer_((real*)0) ); time1 = (doublereal) (timi2 - timi1); } ier = 53; @@ -1815,7 +1830,7 @@ L250: L290: if (iparm[10] == 0) { - timi2 = dsrc_timer_((real*)0); + timi2 = (real)( dsrc_timer_((real*)0) ); time1 = (doublereal) (timi2 - timi1); } @@ -1859,7 +1874,7 @@ L350: /* ... SET RETURN PARAMETERS IN IPARM AND RPARM */ if (iparm[10] == 0) { - timj2 = dsrc_timer_((real*)0); + timj2 = (real)( dsrc_timer_((real*)0) ); time2 = (doublereal) (timj2 - timj1); } if (iparm[2] == 0) { @@ -2030,7 +2045,7 @@ int rscg_(integer *n, integer *ia, integer *ja, doublereal *a, doublereal *rhs, return 0; if (iparm[10] == 0) - timj1 = dsrc_timer_((real*)0); + timj1 = (real)( dsrc_timer_((real*)0) ); if (itcom1_1.level < 3) echout_(iparm, rparm, &c__6); @@ -2122,7 +2137,7 @@ int rscg_(integer *n, integer *ia, integer *ja, doublereal *a, doublereal *rhs, goto L430; if (iparm[10] == 0) - timi1 = dsrc_timer_((real*)0); + timi1 = (real)( dsrc_timer_((real*)0) ); /* ... INITIALIZE FORWARD PSEUDO-RESIDUAL */ @@ -2171,7 +2186,7 @@ L290: /* ... ITMAX HAS BEEN REACHED */ if (iparm[10] == 0) { - timi2 = dsrc_timer_((real*)0); + timi2 = (real)( dsrc_timer_((real*)0) ); time1 = (doublereal) (timi2 - timi1); } ier = 63; @@ -2184,7 +2199,7 @@ L290: L330: if (iparm[10] == 0) { - timi2 = dsrc_timer_((real*)0); + timi2 = (real)( dsrc_timer_((real*)0) ); time1 = (doublereal) (timi2 - timi1); } @@ -2233,7 +2248,7 @@ L400: /* ... SET RETURN PARAMETERS IN IPARM AND RPARM */ if (iparm[10] == 0) { - timj2 = dsrc_timer_((real*)0); + timj2 = (real)( dsrc_timer_((real*)0) ); time2 = (doublereal) (timj2 - timj1); } iparm[7] -= (itcom1_1.itmax - itcom1_1.in) << 1; @@ -2402,7 +2417,7 @@ int rssi_(integer *n, integer *ia, integer *ja, doublereal *a, doublereal *rhs, return 0; if (iparm[10] == 0) - timj1 = dsrc_timer_((real*)0); + timj1 = (real)( dsrc_timer_((real*)0) ); if (itcom1_1.level < 3) echout_(iparm, rparm, &c__7); @@ -2487,7 +2502,7 @@ int rssi_(integer *n, integer *ia, integer *ja, doublereal *a, doublereal *rhs, goto L420; if (iparm[10] == 0) - timi1 = dsrc_timer_((real*)0); + timi1 = (real)( dsrc_timer_((real*)0) ); /* ... ITERATION SEQUENCE */ @@ -2528,7 +2543,7 @@ L280: /* ... ITMAX HAS BEEN REACHED */ if (iparm[10] == 0) { - timi2 = dsrc_timer_((real*)0); + timi2 = (real)( dsrc_timer_((real*)0) ); time1 = (doublereal) (timi2 - timi1); } ier = 73; @@ -2541,7 +2556,7 @@ L280: L320: if (iparm[10] == 0) { - timi2 = dsrc_timer_((real*)0); + timi2 = (real)( dsrc_timer_((real*)0) ); time1 = (doublereal) (timi2 - timi1); } @@ -2590,7 +2605,7 @@ L390: /* ... SET RETURN PARAMETERS IN IPARM AND RPARM */ if (iparm[10] == 0) { - timj2 = dsrc_timer_((real*)0); + timj2 = (real)( dsrc_timer_((real*)0) ); time2 = (doublereal) (timj2 - timj1); } if (iparm[2] == 0) { diff --git a/Utilities/ITK/Code/Numerics/FEM/itkFEMLinearSystemWrapperDenseVNL.h b/Utilities/ITK/Code/Numerics/FEM/itkFEMLinearSystemWrapperDenseVNL.h index 599e08ace75a16248e604b2dd5c6a428b9251fc3..02e9d9141c026cf5e4a7e4ec4b2cc92c980e0d4c 100644 --- a/Utilities/ITK/Code/Numerics/FEM/itkFEMLinearSystemWrapperDenseVNL.h +++ b/Utilities/ITK/Code/Numerics/FEM/itkFEMLinearSystemWrapperDenseVNL.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkFEMLinearSystemWrapperDenseVNL.h,v $ Language: C++ - Date: $Date: 2009-01-29 21:55:14 $ - Version: $Revision: 1.8 $ + Date: $Date: 2010-01-31 19:28:28 $ + Version: $Revision: 1.9 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -21,7 +21,6 @@ #include "vnl/vnl_matrix.h" #include "vnl/vnl_vector.h" #include "vnl/algo/vnl_svd.h" -#include <vnl/algo/vnl_lsqr.h> #include <vector> diff --git a/Utilities/ITK/Code/Numerics/FEM/itkFEMLoadImplementationGenericLandmarkLoad.cxx b/Utilities/ITK/Code/Numerics/FEM/itkFEMLoadImplementationGenericLandmarkLoad.cxx index b2fff8a42b814b279ba46536412bc5406a0165ac..8c188d8243a395225a55b4de0d6b36c122a7bb34 100644 --- a/Utilities/ITK/Code/Numerics/FEM/itkFEMLoadImplementationGenericLandmarkLoad.cxx +++ b/Utilities/ITK/Code/Numerics/FEM/itkFEMLoadImplementationGenericLandmarkLoad.cxx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkFEMLoadImplementationGenericLandmarkLoad.cxx,v $ Language: C++ - Date: $Date: 2009-01-30 21:10:18 $ - Version: $Revision: 1.10 $ + Date: $Date: 2009-11-28 23:13:15 $ + Version: $Revision: 1.11 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -35,7 +35,9 @@ LoadImplementationGenericLandmarkLoad const unsigned int NnDOF=element->GetNumberOfDegreesOfFreedomPerNode(); const unsigned int Nnodes=element->GetNumberOfNodes(); - Element::VectorType force( NnDOF, 0.0 ), disp( NnDOF, 0.0 ), new_source (NnDOF, 0.0); + Element::VectorType force( NnDOF, 0.0 ); + Element::VectorType disp( NnDOF, 0.0 ); + Element::VectorType new_source (NnDOF, 0.0); Element::VectorType shapeF; Fe.set_size(element->GetNumberOfDegreesOfFreedom()); @@ -65,8 +67,11 @@ LoadImplementationGenericLandmarkLoad new_source = (load->GetTarget() - new_source); // std::cout << " force = " << force << " distance " << new_source.magnitude() << std::endl; - float curdist=new_source.magnitude(); - if (curdist < 1.0) force.fill(0.0); + Element::Float curdist = new_source.magnitude(); + if ( curdist < 1.0 ) + { + force.fill(0.0); + } std::cout << " LM distance " << curdist << std::endl; // "Integrate" at the location of the point load diff --git a/Utilities/ITK/Code/Numerics/FEM/itkFEMSolver.cxx b/Utilities/ITK/Code/Numerics/FEM/itkFEMSolver.cxx index b361ac214394d5dfadfcf2840004bde6d67f3487..67b631c61dcf5015cfd9332ce1bf90e7c86764e7 100644 --- a/Utilities/ITK/Code/Numerics/FEM/itkFEMSolver.cxx +++ b/Utilities/ITK/Code/Numerics/FEM/itkFEMSolver.cxx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkFEMSolver.cxx,v $ Language: C++ - Date: $Date: 2009-01-30 21:53:03 $ - Version: $Revision: 1.57 $ + Date: $Date: 2010-03-30 15:20:02 $ + Version: $Revision: 1.59 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -619,7 +619,7 @@ void Solver::UpdateDisplacements() Solver::Float Solver::GetDeformationEnergy(unsigned int SolutionIndex) { - float U=0.0; + Solver::Float U = 0.0f; Element::MatrixType LocalSolution; for(ElementArray::iterator e=el.begin(); e != el.end(); e++) diff --git a/Utilities/ITK/Code/Numerics/FEM/itkFEMSolverCrankNicolson.cxx b/Utilities/ITK/Code/Numerics/FEM/itkFEMSolverCrankNicolson.cxx index 45df55d602b571a5d3cfdc421b0daa28fb063f27..09f96471d63d9805e4cb7a031fd007e8c641e918 100644 --- a/Utilities/ITK/Code/Numerics/FEM/itkFEMSolverCrankNicolson.cxx +++ b/Utilities/ITK/Code/Numerics/FEM/itkFEMSolverCrankNicolson.cxx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkFEMSolverCrankNicolson.cxx,v $ Language: C++ - Date: $Date: 2009-04-05 23:09:19 $ - Version: $Revision: 1.40 $ + Date: $Date: 2010-03-30 15:20:01 $ + Version: $Revision: 1.42 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. diff --git a/Utilities/ITK/Code/Numerics/FEM/itkFEMSolverCrankNicolson.h b/Utilities/ITK/Code/Numerics/FEM/itkFEMSolverCrankNicolson.h index 3914f73f725edf9ecfb2bceda525cff57f37f91d..df57284e3a822b1cefc09469cc1bb48e53eba844 100644 --- a/Utilities/ITK/Code/Numerics/FEM/itkFEMSolverCrankNicolson.h +++ b/Utilities/ITK/Code/Numerics/FEM/itkFEMSolverCrankNicolson.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkFEMSolverCrankNicolson.h,v $ Language: C++ - Date: $Date: 2009-01-30 21:53:03 $ - Version: $Revision: 1.19 $ + Date: $Date: 2010-02-26 05:28:25 $ + Version: $Revision: 1.21 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -30,7 +30,6 @@ #include "vnl/algo/vnl_svd.h" #include "vnl/algo/vnl_cholesky.h" #include <vnl/vnl_sparse_matrix_linear_system.h> -#include <vnl/algo/vnl_lsqr.h> #include <math.h> @@ -45,20 +44,22 @@ namespace fem { * This is the main class used for solving FEM time-dependent problems. * It solves the following problem: * - * ( M + alpha*dt* K )*U_t=(M - (1.- alpha)*dt* K)* U_{t-1} + dt*(alpha*f_{n+1} + (1-alpha)*f_n) + * \f[ + * ( M + \alpha*dt* K )*U_t=(M - (1.- \alpha)*dt* K)* U_{t-1} + dt*(\alpha*f_{n+1} + (1-\alpha)*f_n) + * \f] * - * which is the Crank-Nicolson formulation of the static problem if alpha=0.5. + * which is the Crank-Nicolson formulation of the static problem if \f$\alpha=0.5\f$. * The static solution is gained if : - * rho = 0.0; alpha = 1.0; dt = 1.0; + * \f$\rho = 0.0\f$; \f$\alpha = 1.0\f$; \f$dt = 1.0\f$; * Practically, it is good to set rho to something small (for the itpack solver). - * The advantage of choosing alpha=0.5 is that the solution is then stable for any + * The advantage of choosing \f$\alpha=0.5\f$ is that the solution is then stable for any * choice of time step, dt. This class inherits and uses most of the Solver class * functionality. One must call AssembleKandM instead of AssembleK and * AssembleFforTimeStep instead of AssembleF. * FIXMEs: 1) Members should be privatized, etc. * 2) We should also account for the contribution to the force from essential BCs. - * Basically there are terms involving M * (\dot g_b) and K * g_b - * where g_b is the essential BC vector. + * Basically there are terms involving \f$ M * (\dot g_b) \f$ and \f$ K * g_b \f$ + * where\f$ g_b\f$ is the essential BC vector. */ class SolverCrankNicolson : public Solver { diff --git a/Utilities/ITK/Code/Numerics/NeuralNetworks/CMakeLists.txt b/Utilities/ITK/Code/Numerics/NeuralNetworks/CMakeLists.txt index e34f14b7894e50b15faa97bb6dd2cc0f2f84ec85..3e28263d47297d43ae5fb70cbb8e8082c4e2a206 100644 --- a/Utilities/ITK/Code/Numerics/NeuralNetworks/CMakeLists.txt +++ b/Utilities/ITK/Code/Numerics/NeuralNetworks/CMakeLists.txt @@ -1,7 +1,15 @@ + +IF(ITK_USE_FLAT_DIRECTORY_INSTALL) + SET( ITK_INSTALL_INCLUDE_DIR_CM24_NUMERICS_NEURALNETWORKS ${ITK_INSTALL_INCLUDE_DIR_CM24}) +ELSE(ITK_USE_FLAT_DIRECTORY_INSTALL) + SET( ITK_INSTALL_INCLUDE_DIR_CM24_NUMERICS_NEURALNETWORKS ${ITK_INSTALL_INCLUDE_DIR_CM24}/Numerics/NeuralNetworks) +ENDIF(ITK_USE_FLAT_DIRECTORY_INSTALL) + + IF(NOT ITK_INSTALL_NO_DEVELOPMENT) FILE(GLOB __files1 "${CMAKE_CURRENT_SOURCE_DIR}/*.h") FILE(GLOB __files2 "${CMAKE_CURRENT_SOURCE_DIR}/*.txx") INSTALL(FILES ${__files1} ${__files2} - DESTINATION ${ITK_INSTALL_INCLUDE_DIR_CM24}/Numerics/NeuralNetworks + DESTINATION ${ITK_INSTALL_INCLUDE_DIR_CM24_NUMERICS_NEURALNETWORKS} COMPONENT Development) ENDIF(NOT ITK_INSTALL_NO_DEVELOPMENT) diff --git a/Utilities/ITK/Code/Numerics/NeuralNetworks/itkTransferFunctionBase.h b/Utilities/ITK/Code/Numerics/NeuralNetworks/itkTransferFunctionBase.h index 7945d49314efa82823b1062ca012618fd8062674..41afca2628095077a007c7210c2d0fa9a0ca0143 100644 --- a/Utilities/ITK/Code/Numerics/NeuralNetworks/itkTransferFunctionBase.h +++ b/Utilities/ITK/Code/Numerics/NeuralNetworks/itkTransferFunctionBase.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkTransferFunctionBase.h,v $ Language: C++ - Date: $Date: 2009-01-28 21:04:59 $ - Version: $Revision: 1.3 $ + Date: $Date: 2009-11-04 07:27:06 $ + Version: $Revision: 1.4 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -32,10 +32,10 @@ class TransferFunctionBase : public FunctionBase<ScalarType, ScalarType> public: /** Standard class typedefs. */ - typedef TransferFunctionBase Self; - typedef FunctionBase<ScalarType, double> Superclass; - typedef SmartPointer<Self> Pointer; - typedef SmartPointer<const Self> ConstPointer; + typedef TransferFunctionBase Self; + typedef FunctionBase<ScalarType, ScalarType> Superclass; + typedef SmartPointer<Self> Pointer; + typedef SmartPointer<const Self> ConstPointer; /** Run-time type information (and related methods). */ itkTypeMacro(TransferFunctionBase, FunctionBase); diff --git a/Utilities/ITK/Code/Numerics/Statistics/CMakeLists.txt b/Utilities/ITK/Code/Numerics/Statistics/CMakeLists.txt index 8c53e54ffa22b80897875104a1613ee9e5141fdb..425637f15402748bee3822c8dec6b0523e32ff38 100644 --- a/Utilities/ITK/Code/Numerics/Statistics/CMakeLists.txt +++ b/Utilities/ITK/Code/Numerics/Statistics/CMakeLists.txt @@ -24,11 +24,18 @@ IF(NOT ITK_INSTALL_NO_LIBRARIES) ARCHIVE DESTINATION ${ITK_INSTALL_LIB_DIR_CM24} COMPONENT Development) ENDIF(NOT ITK_INSTALL_NO_LIBRARIES) +IF(ITK_USE_FLAT_DIRECTORY_INSTALL) + SET( ITK_INSTALL_INCLUDE_DIR_CM24_NUMERICS_STATISTICS ${ITK_INSTALL_INCLUDE_DIR_CM24}) +ELSE(ITK_USE_FLAT_DIRECTORY_INSTALL) + SET( ITK_INSTALL_INCLUDE_DIR_CM24_NUMERICS_STATISTICS ${ITK_INSTALL_INCLUDE_DIR_CM24}/Numerics/Statistics) +ENDIF(ITK_USE_FLAT_DIRECTORY_INSTALL) + + IF(NOT ITK_INSTALL_NO_DEVELOPMENT) FILE(GLOB __files1 "${CMAKE_CURRENT_SOURCE_DIR}/*.h") FILE(GLOB __files2 "${CMAKE_CURRENT_SOURCE_DIR}/*.txx") INSTALL(FILES ${__files1} ${__files2} - DESTINATION ${ITK_INSTALL_INCLUDE_DIR_CM24}/Numerics/Statistics + DESTINATION ${ITK_INSTALL_INCLUDE_DIR_CM24_NUMERICS_STATISTICS} COMPONENT Development) ENDIF(NOT ITK_INSTALL_NO_DEVELOPMENT) diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkDenseFrequencyContainer.cxx b/Utilities/ITK/Code/Numerics/Statistics/itkDenseFrequencyContainer.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkDistanceMetric.h b/Utilities/ITK/Code/Numerics/Statistics/itkDistanceMetric.h old mode 100644 new mode 100755 index e350725754411511fb52f77026486a989ab3ca1a..83ee72e089019f45987b90a09e218c0d2beb88aa --- a/Utilities/ITK/Code/Numerics/Statistics/itkDistanceMetric.h +++ b/Utilities/ITK/Code/Numerics/Statistics/itkDistanceMetric.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkDistanceMetric.h,v $ Language: C++ - Date: $Date: 2009-03-04 15:23:46 $ - Version: $Revision: 1.13 $ + Date: $Date: 2010-02-02 13:45:16 $ + Version: $Revision: 1.14 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -60,6 +60,8 @@ public: /** Standard typedefs */ typedef DistanceMetric Self; typedef MembershipFunctionBase< TVector > Superclass; + typedef SmartPointer< Self > Pointer; + typedef SmartPointer<const Self> ConstPointer; typedef typename Superclass::MeasurementVectorSizeType MeasurementVectorSizeType; diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkDistanceMetric.txx b/Utilities/ITK/Code/Numerics/Statistics/itkDistanceMetric.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkEuclideanDistance.h b/Utilities/ITK/Code/Numerics/Statistics/itkEuclideanDistance.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkEuclideanDistance.txx b/Utilities/ITK/Code/Numerics/Statistics/itkEuclideanDistance.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkExpectationMaximizationMixtureModelEstimator.h b/Utilities/ITK/Code/Numerics/Statistics/itkExpectationMaximizationMixtureModelEstimator.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkExpectationMaximizationMixtureModelEstimator.txx b/Utilities/ITK/Code/Numerics/Statistics/itkExpectationMaximizationMixtureModelEstimator.txx old mode 100644 new mode 100755 index 309917795de8a3c4e64a6ba32a16b66c28e22eb1..d6ab34360789b5b6fa2f031bf63ff7ee2854c269 --- a/Utilities/ITK/Code/Numerics/Statistics/itkExpectationMaximizationMixtureModelEstimator.txx +++ b/Utilities/ITK/Code/Numerics/Statistics/itkExpectationMaximizationMixtureModelEstimator.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkExpectationMaximizationMixtureModelEstimator.txx,v $ Language: C++ - Date: $Date: 2009-03-04 15:23:47 $ - Version: $Revision: 1.17 $ + Date: $Date: 2009-09-19 19:39:36 $ + Version: $Revision: 1.18 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -68,7 +68,7 @@ typename ExpectationMaximizationMixtureModelEstimator< TSample >::ProportionVect ExpectationMaximizationMixtureModelEstimator< TSample > ::GetInitialProportions() { - return m_InitialProportions; + return &m_InitialProportions; } template< class TSample > diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkGaussianGoodnessOfFitComponent.h b/Utilities/ITK/Code/Numerics/Statistics/itkGaussianGoodnessOfFitComponent.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkGaussianGoodnessOfFitComponent.txx b/Utilities/ITK/Code/Numerics/Statistics/itkGaussianGoodnessOfFitComponent.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkGaussianMixtureModelComponent.h b/Utilities/ITK/Code/Numerics/Statistics/itkGaussianMixtureModelComponent.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkGaussianMixtureModelComponent.txx b/Utilities/ITK/Code/Numerics/Statistics/itkGaussianMixtureModelComponent.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkGoodnessOfFitComponentBase.h b/Utilities/ITK/Code/Numerics/Statistics/itkGoodnessOfFitComponentBase.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkGoodnessOfFitComponentBase.txx b/Utilities/ITK/Code/Numerics/Statistics/itkGoodnessOfFitComponentBase.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkGoodnessOfFitFunctionBase.h b/Utilities/ITK/Code/Numerics/Statistics/itkGoodnessOfFitFunctionBase.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkGoodnessOfFitFunctionBase.txx b/Utilities/ITK/Code/Numerics/Statistics/itkGoodnessOfFitFunctionBase.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkGoodnessOfFitMixtureModelCostFunction.h b/Utilities/ITK/Code/Numerics/Statistics/itkGoodnessOfFitMixtureModelCostFunction.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkGoodnessOfFitMixtureModelCostFunction.txx b/Utilities/ITK/Code/Numerics/Statistics/itkGoodnessOfFitMixtureModelCostFunction.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkImageToCooccurrenceListAdaptor.h b/Utilities/ITK/Code/Numerics/Statistics/itkImageToCooccurrenceListAdaptor.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkImageToCooccurrenceListAdaptor.txx b/Utilities/ITK/Code/Numerics/Statistics/itkImageToCooccurrenceListAdaptor.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkImageToHistogramGenerator.h b/Utilities/ITK/Code/Numerics/Statistics/itkImageToHistogramGenerator.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkImageToHistogramGenerator.txx b/Utilities/ITK/Code/Numerics/Statistics/itkImageToHistogramGenerator.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkKdTree.h b/Utilities/ITK/Code/Numerics/Statistics/itkKdTree.h old mode 100644 new mode 100755 index 08700c5a5f02c7368b846bdc073a7753381937c0..1d3eae5ac31cb7ce4cfd701f80765e00104828ca --- a/Utilities/ITK/Code/Numerics/Statistics/itkKdTree.h +++ b/Utilities/ITK/Code/Numerics/Statistics/itkKdTree.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkKdTree.h,v $ Language: C++ - Date: $Date: 2009-03-04 15:23:51 $ - Version: $Revision: 1.28 $ + Date: $Date: 2010-02-04 20:09:18 $ + Version: $Revision: 1.30 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -55,6 +55,9 @@ namespace Statistics { * \c MeasurementVectorSize has been removed to allow the length of a measurement * vector to be specified at run time. The \c typedef for \c CentroidType has * been changed from Array to FixedArray. + * + * \warning This class has been reported as not being thread safe. See + * http://www.itk.org/pipermail/insight-users/2009-November/034247.html * * \sa KdTreeNonterminalNode, KdTreeWeightedCentroidNonterminalNode, * KdTreeTerminalNode @@ -214,7 +217,10 @@ struct KdTreeWeightedCentroidNonterminalNode: public KdTreeNode< TSample > Superclass* right, CentroidType ¢roid, unsigned int size); - virtual ~KdTreeWeightedCentroidNonterminalNode() {} + virtual ~KdTreeWeightedCentroidNonterminalNode() + { + } + virtual bool IsTerminal() const { return false; } @@ -289,7 +295,10 @@ struct KdTreeTerminalNode: public KdTreeNode< TSample > KdTreeTerminalNode() {} - virtual ~KdTreeTerminalNode() {} + virtual ~KdTreeTerminalNode() + { + this->m_InstanceIdentifiers.clear(); + } bool IsTerminal() const { return true; } @@ -503,7 +512,13 @@ public: /** Sets the root node of the KdTree that is a result of * KdTreeGenerator or WeightedCentroidKdTreeGenerator. */ void SetRoot(KdTreeNodeType* root) - { m_Root = root; } + { + if( this->m_Root ) + { + this->DeleteNode( this->m_Root ); + } + this->m_Root = root; + } /** Returns the pointer to the root node. */ KdTreeNodeType* GetRoot() diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkKdTree.txx b/Utilities/ITK/Code/Numerics/Statistics/itkKdTree.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkKdTreeBasedKmeansEstimator.h b/Utilities/ITK/Code/Numerics/Statistics/itkKdTreeBasedKmeansEstimator.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkKdTreeBasedKmeansEstimator.txx b/Utilities/ITK/Code/Numerics/Statistics/itkKdTreeBasedKmeansEstimator.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkKdTreeGenerator.h b/Utilities/ITK/Code/Numerics/Statistics/itkKdTreeGenerator.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkKdTreeGenerator.txx b/Utilities/ITK/Code/Numerics/Statistics/itkKdTreeGenerator.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkListSampleBase.h b/Utilities/ITK/Code/Numerics/Statistics/itkListSampleBase.h old mode 100644 new mode 100755 index 35c13a3cb8f39e9ea850a559995e06e4076ae5d9..d074a86bfd04cbdf7cbae38104b84e7d7d648691 --- a/Utilities/ITK/Code/Numerics/Statistics/itkListSampleBase.h +++ b/Utilities/ITK/Code/Numerics/Statistics/itkListSampleBase.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkListSampleBase.h,v $ Language: C++ - Date: $Date: 2009-03-04 15:23:53 $ - Version: $Revision: 1.11 $ + Date: $Date: 2010-02-02 13:45:16 $ + Version: $Revision: 1.12 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -51,6 +51,8 @@ public: /** Standard class typedef. */ typedef ListSampleBase Self; typedef Sample< TMeasurementVector > Superclass; + typedef SmartPointer< Self > Pointer; + typedef SmartPointer<const Self> ConstPointer; /** Standard macros */ itkTypeMacro(ListSampleBase, Sample); diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkListSampleToHistogramGenerator.h b/Utilities/ITK/Code/Numerics/Statistics/itkListSampleToHistogramGenerator.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkListSampleToHistogramGenerator.txx b/Utilities/ITK/Code/Numerics/Statistics/itkListSampleToHistogramGenerator.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkLogLikelihoodGoodnessOfFitFunction.h b/Utilities/ITK/Code/Numerics/Statistics/itkLogLikelihoodGoodnessOfFitFunction.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkLogLikelihoodGoodnessOfFitFunction.txx b/Utilities/ITK/Code/Numerics/Statistics/itkLogLikelihoodGoodnessOfFitFunction.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkMembershipFunctionBase.h b/Utilities/ITK/Code/Numerics/Statistics/itkMembershipFunctionBase.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkMixtureModelComponentBase.h b/Utilities/ITK/Code/Numerics/Statistics/itkMixtureModelComponentBase.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkMixtureModelComponentBase.txx b/Utilities/ITK/Code/Numerics/Statistics/itkMixtureModelComponentBase.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkNeighborhoodSampler.h b/Utilities/ITK/Code/Numerics/Statistics/itkNeighborhoodSampler.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkNeighborhoodSampler.txx b/Utilities/ITK/Code/Numerics/Statistics/itkNeighborhoodSampler.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkPointSetToListAdaptor.h b/Utilities/ITK/Code/Numerics/Statistics/itkPointSetToListAdaptor.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkPointSetToListAdaptor.txx b/Utilities/ITK/Code/Numerics/Statistics/itkPointSetToListAdaptor.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkRandomVariateGeneratorBase.h b/Utilities/ITK/Code/Numerics/Statistics/itkRandomVariateGeneratorBase.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkSampleAlgorithmBase.h b/Utilities/ITK/Code/Numerics/Statistics/itkSampleAlgorithmBase.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkSampleAlgorithmBase.txx b/Utilities/ITK/Code/Numerics/Statistics/itkSampleAlgorithmBase.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkSampleClassifierWithMask.h b/Utilities/ITK/Code/Numerics/Statistics/itkSampleClassifierWithMask.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkSampleClassifierWithMask.txx b/Utilities/ITK/Code/Numerics/Statistics/itkSampleClassifierWithMask.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkSampleToHistogramProjectionFilter.h b/Utilities/ITK/Code/Numerics/Statistics/itkSampleToHistogramProjectionFilter.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkSampleToHistogramProjectionFilter.txx b/Utilities/ITK/Code/Numerics/Statistics/itkSampleToHistogramProjectionFilter.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkScalarImageToGreyLevelCooccurrenceMatrixGenerator.h b/Utilities/ITK/Code/Numerics/Statistics/itkScalarImageToGreyLevelCooccurrenceMatrixGenerator.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkScalarImageToGreyLevelCooccurrenceMatrixGenerator.txx b/Utilities/ITK/Code/Numerics/Statistics/itkScalarImageToGreyLevelCooccurrenceMatrixGenerator.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkScalarImageToHistogramGenerator.h b/Utilities/ITK/Code/Numerics/Statistics/itkScalarImageToHistogramGenerator.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkScalarImageToHistogramGenerator.txx b/Utilities/ITK/Code/Numerics/Statistics/itkScalarImageToHistogramGenerator.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkSelectiveSubsampleGenerator.h b/Utilities/ITK/Code/Numerics/Statistics/itkSelectiveSubsampleGenerator.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkSelectiveSubsampleGenerator.txx b/Utilities/ITK/Code/Numerics/Statistics/itkSelectiveSubsampleGenerator.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkSparseFrequencyContainer.cxx b/Utilities/ITK/Code/Numerics/Statistics/itkSparseFrequencyContainer.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkStatisticsAlgorithm.h b/Utilities/ITK/Code/Numerics/Statistics/itkStatisticsAlgorithm.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkStatisticsAlgorithm.txx b/Utilities/ITK/Code/Numerics/Statistics/itkStatisticsAlgorithm.txx old mode 100644 new mode 100755 index 54a8ed7e1ea6f851af93eb3cdbae836239040615..f8d6fa91e734647baf05d3a71e9b237bbc9a5523 --- a/Utilities/ITK/Code/Numerics/Statistics/itkStatisticsAlgorithm.txx +++ b/Utilities/ITK/Code/Numerics/Statistics/itkStatisticsAlgorithm.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkStatisticsAlgorithm.txx,v $ Language: C++ - Date: $Date: 2009-03-04 19:29:54 $ - Version: $Revision: 1.25 $ + Date: $Date: 2010-01-22 22:16:14 $ + Version: $Revision: 1.26 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -548,8 +548,11 @@ inline void InsertSort(TSubsample* sample, backwardIndex = backwardSearchBegin; while (backwardIndex > beginIndex) { - if (sample->GetMeasurementVectorByIndex(backwardIndex)[activeDimension] < - sample->GetMeasurementVectorByIndex(backwardIndex - 1)[activeDimension]) + typedef typename TSubsample::MeasurementType MeasurementType; + const MeasurementType value1 = sample->GetMeasurementVectorByIndex(backwardIndex)[activeDimension]; + const MeasurementType value2 = sample->GetMeasurementVectorByIndex(backwardIndex - 1)[activeDimension]; + + if( value1 < value2 ) { sample->Swap(backwardIndex, backwardIndex - 1); } diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkSubsample.h b/Utilities/ITK/Code/Numerics/Statistics/itkSubsample.h index 3c2556c7f20c4d56beccbaa6e53caddfcc1c7794..9989898483f515d85f62dd9b409b9427f07df7da 100644 --- a/Utilities/ITK/Code/Numerics/Statistics/itkSubsample.h +++ b/Utilities/ITK/Code/Numerics/Statistics/itkSubsample.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkSubsample.h,v $ Language: C++ - Date: $Date: 2009-03-04 19:29:54 $ - Version: $Revision: 1.32 $ + Date: $Date: 2010-01-21 22:26:12 $ + Version: $Revision: 1.33 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -130,7 +130,7 @@ public: void Swap(int index1, int index2); - MeasurementVectorType GetMeasurementVectorByIndex(int index) const; + const MeasurementVectorType & GetMeasurementVectorByIndex(int index) const; FrequencyType GetFrequencyByIndex(int index) const; diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkSubsample.txx b/Utilities/ITK/Code/Numerics/Statistics/itkSubsample.txx index 5e503499c890ebec38bb9edfa3e9eb481c509b9d..793126e5c8c992b6c0fa9ae60b2fdaed1c3cd6fe 100644 --- a/Utilities/ITK/Code/Numerics/Statistics/itkSubsample.txx +++ b/Utilities/ITK/Code/Numerics/Statistics/itkSubsample.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkSubsample.txx,v $ Language: C++ - Date: $Date: 2009-03-04 19:29:54 $ - Version: $Revision: 1.19 $ + Date: $Date: 2010-01-21 22:26:14 $ + Version: $Revision: 1.20 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -54,7 +54,7 @@ Subsample< TSample > } template< class TSample > -inline typename Subsample< TSample >::MeasurementVectorType +inline const typename Subsample< TSample >::MeasurementVectorType & Subsample< TSample > ::GetMeasurementVectorByIndex(int index) const { diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkWeightedCovarianceCalculator.h b/Utilities/ITK/Code/Numerics/Statistics/itkWeightedCovarianceCalculator.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkWeightedCovarianceCalculator.txx b/Utilities/ITK/Code/Numerics/Statistics/itkWeightedCovarianceCalculator.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkWeightedMeanCalculator.h b/Utilities/ITK/Code/Numerics/Statistics/itkWeightedMeanCalculator.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/Statistics/itkWeightedMeanCalculator.txx b/Utilities/ITK/Code/Numerics/Statistics/itkWeightedMeanCalculator.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/cvsrmvend b/Utilities/ITK/Code/Numerics/cvsrmvend old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/itkCumulativeGaussianOptimizer.cxx b/Utilities/ITK/Code/Numerics/itkCumulativeGaussianOptimizer.cxx index b7e2b8cc982ee7294c0d201188f3b38e3602f9f5..e9cc77bf4a89c38555f74920b3cec3475e660133 100644 --- a/Utilities/ITK/Code/Numerics/itkCumulativeGaussianOptimizer.cxx +++ b/Utilities/ITK/Code/Numerics/itkCumulativeGaussianOptimizer.cxx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkCumulativeGaussianOptimizer.cxx,v $ Language: C++ - Date: $Date: 2009-08-07 15:27:39 $ - Version: $Revision: 1.19 $ + Date: $Date: 2009-10-27 16:05:46 $ + Version: $Revision: 1.20 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -19,6 +19,7 @@ #include "itkCumulativeGaussianOptimizer.h" #include "assert.h" +#include "itkMath.h" namespace itk { diff --git a/Utilities/ITK/Code/Numerics/itkFRPROptimizer.cxx b/Utilities/ITK/Code/Numerics/itkFRPROptimizer.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/itkFRPROptimizer.h b/Utilities/ITK/Code/Numerics/itkFRPROptimizer.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/itkLBFGSBOptimizer.cxx b/Utilities/ITK/Code/Numerics/itkLBFGSBOptimizer.cxx index 713f3b0b9589b221fc2aad8fa28e9cea241bc8f4..fee4ac285bc06829b4456c50a831266d7850c949 100644 --- a/Utilities/ITK/Code/Numerics/itkLBFGSBOptimizer.cxx +++ b/Utilities/ITK/Code/Numerics/itkLBFGSBOptimizer.cxx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkLBFGSBOptimizer.cxx,v $ Language: C++ - Date: $Date: 2009-06-24 12:02:51 $ - Version: $Revision: 1.17 $ + Date: $Date: 2009-10-08 15:14:25 $ + Version: $Revision: 1.18 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -64,6 +64,7 @@ LBFGSBOptimizer { m_OptimizerInitialized = false; m_VnlOptimizer = 0; + m_Trace = false; m_LowerBound = InternalBoundValueType(0); m_UpperBound = InternalBoundValueType(0); @@ -99,6 +100,15 @@ LBFGSBOptimizer ::PrintSelf( std::ostream& os, Indent indent) const { Superclass::PrintSelf(os, indent); + os << indent << "Trace: "; + if ( m_Trace ) + { + os << "On"; + } + else + { os << "Off"; + } + os << std::endl; os << indent << "LowerBound: " << m_LowerBound << std::endl; os << indent << "UpperBound: " << m_UpperBound << std::endl; @@ -135,6 +145,27 @@ LBFGSBOptimizer } } +/** + * Set the optimizer trace flag + */ +void +LBFGSBOptimizer +::SetTrace( bool flag ) +{ + if ( flag == m_Trace ) + { + return; + } + + m_Trace = flag; + if ( m_OptimizerInitialized ) + { + m_VnlOptimizer->set_trace( m_Trace ); + } + + this->Modified(); +} + /** * Set lower bound */ diff --git a/Utilities/ITK/Code/Numerics/itkLBFGSBOptimizer.h b/Utilities/ITK/Code/Numerics/itkLBFGSBOptimizer.h index e6dc263f0b6bf6107b6f5ebf24c6909ff42e4347..60494a6422d0d470de70472e3db9a0e8de88bdec 100644 --- a/Utilities/ITK/Code/Numerics/itkLBFGSBOptimizer.h +++ b/Utilities/ITK/Code/Numerics/itkLBFGSBOptimizer.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkLBFGSBOptimizer.h,v $ Language: C++ - Date: $Date: 2009-06-24 12:02:52 $ - Version: $Revision: 1.9 $ + Date: $Date: 2009-10-08 15:14:26 $ + Version: $Revision: 1.10 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -98,6 +98,13 @@ public: /** Plug in a Cost Function into the optimizer */ virtual void SetCostFunction( SingleValuedCostFunction * costFunction ); + /** Set/Get the optimizer trace flag. If set to true, the optimizer + * prints out information every iteration. + */ + virtual void SetTrace( bool flag ); + itkGetMacro( Trace, bool ); + itkBooleanMacro( Trace ); + /** Set the lower bound value for each variable. */ virtual void SetLowerBound( const BoundValueType & value ); virtual const BoundValueType & GetLowerBound(); @@ -177,6 +184,7 @@ private: // counts, etc. friend class LBFGSBOptimizerHelper; + bool m_Trace; bool m_OptimizerInitialized; InternalOptimizerType * m_VnlOptimizer; mutable OStringStream m_StopConditionDescription; diff --git a/Utilities/ITK/Code/Numerics/itkLBFGSOptimizer.cxx b/Utilities/ITK/Code/Numerics/itkLBFGSOptimizer.cxx index 60a7ab039dec06847c6ed91c4dcbdc67eb1db221..ac058763b30618cfe6edd5e2f1962c166a6466a4 100644 --- a/Utilities/ITK/Code/Numerics/itkLBFGSOptimizer.cxx +++ b/Utilities/ITK/Code/Numerics/itkLBFGSOptimizer.cxx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkLBFGSOptimizer.cxx,v $ Language: C++ - Date: $Date: 2009-06-24 12:02:52 $ - Version: $Revision: 1.22 $ + Date: $Date: 2009-09-16 15:19:20 $ + Version: $Revision: 1.23 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -183,9 +183,9 @@ LBFGSOptimizer /** Return Current Value */ LBFGSOptimizer::MeasureType LBFGSOptimizer -::GetValue() +::GetValue() const { - return this->GetNonConstCostFunctionAdaptor()->f(this->GetCurrentPosition()); + return this->GetCachedValue(); } /** diff --git a/Utilities/ITK/Code/Numerics/itkLBFGSOptimizer.h b/Utilities/ITK/Code/Numerics/itkLBFGSOptimizer.h index 0c1860301cf547b4ca0587a662045d61af3384ec..ef61f86f60f0d498b1af7692683a9a9ca24becaf 100644 --- a/Utilities/ITK/Code/Numerics/itkLBFGSOptimizer.h +++ b/Utilities/ITK/Code/Numerics/itkLBFGSOptimizer.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkLBFGSOptimizer.h,v $ Language: C++ - Date: $Date: 2009-06-24 12:02:52 $ - Version: $Revision: 1.21 $ + Date: $Date: 2009-09-16 15:19:20 $ + Version: $Revision: 1.22 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -95,7 +95,7 @@ public: itkGetMacro( DefaultStepLength, double ); /** Return Current Value */ - MeasureType GetValue(); + MeasureType GetValue() const; /** Get the reason for termination */ const std::string GetStopConditionDescription() const; diff --git a/Utilities/ITK/Code/Numerics/itkOnePlusOneEvolutionaryOptimizer.cxx b/Utilities/ITK/Code/Numerics/itkOnePlusOneEvolutionaryOptimizer.cxx index 275400f9d764bb79f0d2f0ee4fee51453ea3ecb9..e176440b6076149a3e85956f311d7409cebfff7a 100644 --- a/Utilities/ITK/Code/Numerics/itkOnePlusOneEvolutionaryOptimizer.cxx +++ b/Utilities/ITK/Code/Numerics/itkOnePlusOneEvolutionaryOptimizer.cxx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkOnePlusOneEvolutionaryOptimizer.cxx,v $ Language: C++ - Date: $Date: 2009-06-24 12:02:52 $ - Version: $Revision: 1.38 $ + Date: $Date: 2009-09-23 15:07:36 $ + Version: $Revision: 1.39 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -329,19 +329,19 @@ OnePlusOneEvolutionaryOptimizer { os << indent << "Random Generator " << "(none)" << std::endl; } - os << indent << "Maximum Iteration " << m_MaximumIteration << std::endl; - os << indent << "Epsilon " << m_Epsilon << std::endl; - os << indent << "Initial Radius " << m_InitialRadius << std::endl; - os << indent << "Growth Fractor " << m_GrowthFactor << std::endl; - os << indent << "Shrink Fractor " << m_ShrinkFactor << std::endl; - os << indent << "Initialized " << m_Initialized << std::endl; - os << indent << "Current Cost " << m_CurrentCost << std::endl; - os << indent << "Current Iteration " << m_CurrentIteration << std::endl; - os << indent << "Frobenius Norm " << m_FrobeniusNorm << std::endl; - os << indent << "Maximize On/Off " << m_Maximize << std::endl; - os << indent << "CatchGetValueException " << m_CatchGetValueException + os << indent << "Maximum Iteration " << GetMaximumIteration() << std::endl; + os << indent << "Epsilon " << GetEpsilon() << std::endl; + os << indent << "Initial Radius " << GetInitialRadius() << std::endl; + os << indent << "Growth Fractor " << GetGrowthFactor() << std::endl; + os << indent << "Shrink Fractor " << GetShrinkFactor() << std::endl; + os << indent << "Initialized " << GetInitialized() << std::endl; + os << indent << "Current Cost " << GetCurrentCost() << std::endl; + os << indent << "Current Iteration " << GetCurrentIteration() << std::endl; + os << indent << "Frobenius Norm " << GetFrobeniusNorm() << std::endl; + os << indent << "Maximize On/Off " << GetMaximize() << std::endl; + os << indent << "CatchGetValueException " << GetCatchGetValueException() << std::endl; - os << indent << "MetricWorstPossibleValue " << m_MetricWorstPossibleValue + os << indent << "MetricWorstPossibleValue " << GetMetricWorstPossibleValue() << std::endl; } diff --git a/Utilities/ITK/Code/Numerics/itkOnePlusOneEvolutionaryOptimizer.h b/Utilities/ITK/Code/Numerics/itkOnePlusOneEvolutionaryOptimizer.h index 25037ca137cebd9153fe323ffe093ce39b3cf229..f6a799b3675ab10d21a386bbfa0f59826318a83f 100644 --- a/Utilities/ITK/Code/Numerics/itkOnePlusOneEvolutionaryOptimizer.h +++ b/Utilities/ITK/Code/Numerics/itkOnePlusOneEvolutionaryOptimizer.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkOnePlusOneEvolutionaryOptimizer.h,v $ Language: C++ - Date: $Date: 2009-06-24 12:02:53 $ - Version: $Revision: 1.25 $ + Date: $Date: 2009-09-23 16:07:39 $ + Version: $Revision: 1.27 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -92,6 +92,16 @@ public: /** Set if the Optimizer should Maximize the metric */ itkSetMacro( Maximize, bool ); itkBooleanMacro( Maximize ); + itkGetConstReferenceMacro( Maximize, bool ); + + bool GetMinimize( ) const + { return !m_Maximize; } + void SetMinimize(bool v) + { this->SetMaximize(!v); } + void MinimizeOn(void) + { SetMaximize( false ); } + void MinimizeOff(void) + { SetMaximize( true ); } /** Set/Get maximum iteration limit. */ itkSetMacro( MaximumIteration, unsigned int ); @@ -135,6 +145,9 @@ public: /** Return Current Iteration */ itkGetConstReferenceMacro( CurrentIteration, unsigned int); + /** Return if optimizer has been initialized */ + itkGetConstReferenceMacro( Initialized, bool); + /** Start optimization. * Optimization will stop when it meets either of two termination conditions, * the maximum iteration limit or epsilon (minimal search radius) */ @@ -146,10 +159,10 @@ public: void StopOptimization() { m_Stop = true; } - itkGetMacro(CatchGetValueException, bool); + itkGetConstReferenceMacro(CatchGetValueException, bool); itkSetMacro(CatchGetValueException, bool); - itkGetMacro(MetricWorstPossibleValue, double); + itkGetConstReferenceMacro(MetricWorstPossibleValue, double); itkSetMacro(MetricWorstPossibleValue, double); const std::string GetStopConditionDescription() const; diff --git a/Utilities/ITK/Code/Numerics/itkPowellOptimizer.cxx b/Utilities/ITK/Code/Numerics/itkPowellOptimizer.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Numerics/itkPowellOptimizer.h b/Utilities/ITK/Code/Numerics/itkPowellOptimizer.h old mode 100644 new mode 100755 index 2c25c9dffa3a377897bd30e751bb15bfae722bb6..f25cbab6f5267ef7b6ea0fb60aa0548a76c75436 --- a/Utilities/ITK/Code/Numerics/itkPowellOptimizer.h +++ b/Utilities/ITK/Code/Numerics/itkPowellOptimizer.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkPowellOptimizer.h,v $ Language: C++ - Date: $Date: 2009-06-24 12:02:54 $ - Version: $Revision: 1.12 $ + Date: $Date: 2009-09-23 16:07:42 $ + Version: $Revision: 1.14 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -82,6 +82,7 @@ public: /** Set if the Optimizer should Maximize the metric */ itkSetMacro( Maximize, bool ); + itkBooleanMacro( Maximize); itkGetConstReferenceMacro( Maximize, bool ); /** Set/Get maximum iteration limit. */ @@ -127,10 +128,10 @@ public: void StopOptimization() { m_Stop = true; } - itkGetMacro(CatchGetValueException, bool); + itkGetConstReferenceMacro(CatchGetValueException, bool); itkSetMacro(CatchGetValueException, bool); - itkGetMacro(MetricWorstPossibleValue, double); + itkGetConstReferenceMacro(MetricWorstPossibleValue, double); itkSetMacro(MetricWorstPossibleValue, double); const std::string GetStopConditionDescription() const; diff --git a/Utilities/ITK/Code/Numerics/itkSPSAOptimizer.cxx b/Utilities/ITK/Code/Numerics/itkSPSAOptimizer.cxx index a0dc36041d6aa2f3b834049cffa11699c1c825f1..fcf9d08ba59ac40b2865b5ff93446da58ac62e93 100644 --- a/Utilities/ITK/Code/Numerics/itkSPSAOptimizer.cxx +++ b/Utilities/ITK/Code/Numerics/itkSPSAOptimizer.cxx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkSPSAOptimizer.cxx,v $ Language: C++ - Date: $Date: 2009-06-24 12:02:54 $ - Version: $Revision: 1.14 $ + Date: $Date: 2009-10-27 16:05:45 $ + Version: $Revision: 1.16 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -21,8 +21,9 @@ #include "itkCommand.h" #include "itkEventObject.h" #include "itkExceptionObject.h" +#include "itkMath.h" -#include "vnl/vnl_math.h" +#include "itkMath.h" namespace itk @@ -349,7 +350,7 @@ void SPSAOptimizer for ( unsigned int j = 0; j < spaceDimension; j++ ) { /** Generate randomly -1 or 1. */ - m_Delta[ j ] = 2 * Math::Round( this->m_Generator->GetUniformVariate (0.0f, 1.0f) ) - 1; + m_Delta[ j ] = 2 * Math::Round<int>( this->m_Generator->GetUniformVariate (0.0f, 1.0f) ) - 1; /** * Take scales into account. The perturbation of a parameter that has a diff --git a/Utilities/ITK/Code/Numerics/itkSymmetricEigenSystem.h b/Utilities/ITK/Code/Numerics/itkSymmetricEigenSystem.h old mode 100644 new mode 100755 index 3a01b4fea957e13a5608ba266c2fbd6a2bb3bd6b..ce129efa0848dead9c5a2809f193313748a43ad2 --- a/Utilities/ITK/Code/Numerics/itkSymmetricEigenSystem.h +++ b/Utilities/ITK/Code/Numerics/itkSymmetricEigenSystem.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkSymmetricEigenSystem.h,v $ Language: C++ - Date: $Date: 2007-03-22 21:39:38 $ - Version: $Revision: 1.8 $ + Date: $Date: 2009-11-22 13:34:53 $ + Version: $Revision: 1.9 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -92,16 +92,16 @@ public: /** returns the eigen vectors in a 2D array */ EigenVectorArrayType* GetEigenVectors() - { return &m_EigenVectors; } + { return &m_EigenVectors; } /** returns the eigen values in an 1D array */ EigenValueArrayType* GetEigenValues() - { return &m_EigenValues; } + { return &m_EigenValues; } /** dummy method that calls the GenerateData method to * produce the eigen vectors and values. */ void Update() - { this->GenerateData(); } + { this->GenerateData(); } protected: SymmetricEigenSystem(); diff --git a/Utilities/ITK/Code/Numerics/itkSymmetricEigenSystem.txx b/Utilities/ITK/Code/Numerics/itkSymmetricEigenSystem.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Patented/CMakeLists.txt b/Utilities/ITK/Code/Patented/CMakeLists.txt index c8d6b106894d9ee3684673fe2379cd9b28ac180d..6079c652c858d48a3b06ec67cea7e7b172e36e6e 100644 --- a/Utilities/ITK/Code/Patented/CMakeLists.txt +++ b/Utilities/ITK/Code/Patented/CMakeLists.txt @@ -1,3 +1,16 @@ + +IF(ITK_USE_FLAT_DIRECTORY_INSTALL) + SET( ITK_INSTALL_INCLUDE_DIR_CM24_PATENTED ${ITK_INSTALL_INCLUDE_DIR_CM24}) +ELSE(ITK_USE_FLAT_DIRECTORY_INSTALL) + SET( ITK_INSTALL_INCLUDE_DIR_CM24_PATENTED ${ITK_INSTALL_INCLUDE_DIR_CM24}/Patented) +ENDIF(ITK_USE_FLAT_DIRECTORY_INSTALL) + + IF(NOT ITK_INSTALL_NO_DEVELOPMENT) - INSTALL_FILES(${ITK_INSTALL_INCLUDE_DIR}/Patented "(\\.h|\\.txx)$") + FILE(GLOB __files1 "${CMAKE_CURRENT_SOURCE_DIR}/*.h") + FILE(GLOB __files2 "${CMAKE_CURRENT_SOURCE_DIR}/*.txx") + INSTALL(FILES ${__files1} ${__files2} + DESTINATION ${ITK_INSTALL_INCLUDE_DIR_CM24_PATENTED} + COMPONENT Development) + ENDIF(NOT ITK_INSTALL_NO_DEVELOPMENT) diff --git a/Utilities/ITK/Code/Patented/itkSimpleFuzzyConnectednessImageFilterBase.txx b/Utilities/ITK/Code/Patented/itkSimpleFuzzyConnectednessImageFilterBase.txx index f120845d23aa0edaefaead0b4e700f139a6fe0c0..ed605d8dd65c26f74e2e95bf53dad02903e60910 100644 --- a/Utilities/ITK/Code/Patented/itkSimpleFuzzyConnectednessImageFilterBase.txx +++ b/Utilities/ITK/Code/Patented/itkSimpleFuzzyConnectednessImageFilterBase.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkSimpleFuzzyConnectednessImageFilterBase.txx,v $ Language: C++ - Date: $Date: 2009-02-01 13:08:41 $ - Version: $Revision: 1.4 $ + Date: $Date: 2009-09-16 20:46:14 $ + Version: $Revision: 1.5 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -195,6 +195,8 @@ SimpleFuzzyConnectednessImageFilterBase<TInputImage,TOutputImage> m_FuzzyScene->Allocate(); m_FuzzyScene->FillBuffer( 0 ); + m_FuzzyScene->CopyInformation(m_InputImage); + RegionType region1; region1.SetSize(m_Size); region1.SetIndex(index); diff --git a/Utilities/ITK/Code/Review/CMakeLists.txt b/Utilities/ITK/Code/Review/CMakeLists.txt index 6803085012985e2e9af196b259ae0b135c09ea7b..12d52b7d8481dcafff98b1003535721b3bc52d51 100644 --- a/Utilities/ITK/Code/Review/CMakeLists.txt +++ b/Utilities/ITK/Code/Review/CMakeLists.txt @@ -9,6 +9,7 @@ SET(ITKIOReview_SRCS itkPhilipsPAR.cxx itkVoxBoCUBImageIO.cxx itkVoxBoCUBImageIOFactory.cxx + itkGaborKernelFunction.cxx ) ADD_LIBRARY(ITKIOReview ${ITK_REVIEW_BUILD_TYPE} ${ITKIOReview_SRCS}) @@ -131,11 +132,18 @@ ENDIF(ITK_LIBRARY_PROPERTIES) # install the development files +IF(ITK_USE_FLAT_DIRECTORY_INSTALL) + SET( ITK_INSTALL_INCLUDE_DIR_CM24_REVIEW ${ITK_INSTALL_INCLUDE_DIR_CM24}) +ELSE(ITK_USE_FLAT_DIRECTORY_INSTALL) + SET( ITK_INSTALL_INCLUDE_DIR_CM24_REVIEW ${ITK_INSTALL_INCLUDE_DIR_CM24}/Review) +ENDIF(ITK_USE_FLAT_DIRECTORY_INSTALL) + + IF(NOT ITK_INSTALL_NO_DEVELOPMENT) FILE(GLOB __files1 "${CMAKE_CURRENT_SOURCE_DIR}/*.h") FILE(GLOB __files2 "${CMAKE_CURRENT_SOURCE_DIR}/*.txx") INSTALL(FILES ${__files1} ${__files2} - DESTINATION ${ITK_INSTALL_INCLUDE_DIR_CM24}/Review + DESTINATION ${ITK_INSTALL_INCLUDE_DIR_CM24_REVIEW} COMPONENT Development) ENDIF(NOT ITK_INSTALL_NO_DEVELOPMENT) # Warn the user about the license issues and lack of stability of the API diff --git a/Utilities/ITK/Code/Review/Statistics/CMakeLists.txt b/Utilities/ITK/Code/Review/Statistics/CMakeLists.txt index cb6a30ea74b1bd91628ab4347a582195a795ad70..f967f68eed89ba60d6abb8c824535f6bfc6d6182 100644 --- a/Utilities/ITK/Code/Review/Statistics/CMakeLists.txt +++ b/Utilities/ITK/Code/Review/Statistics/CMakeLists.txt @@ -28,11 +28,18 @@ IF(NOT ITK_INSTALL_NO_LIBRARIES) ARCHIVE DESTINATION ${ITK_INSTALL_LIB_DIR_CM24} COMPONENT Development) ENDIF(NOT ITK_INSTALL_NO_LIBRARIES) +IF(ITK_USE_FLAT_DIRECTORY_INSTALL) + SET( ITK_INSTALL_INCLUDE_DIR_CM24_REVIEW_STATISTICS ${ITK_INSTALL_INCLUDE_DIR_CM24}) +ELSE(ITK_USE_FLAT_DIRECTORY_INSTALL) + SET( ITK_INSTALL_INCLUDE_DIR_CM24_REVIEW_STATISTICS ${ITK_INSTALL_INCLUDE_DIR_CM24}/Review/Statistics) +ENDIF(ITK_USE_FLAT_DIRECTORY_INSTALL) + + IF(NOT ITK_INSTALL_NO_DEVELOPMENT) FILE(GLOB __files1 "${CMAKE_CURRENT_SOURCE_DIR}/*.h") FILE(GLOB __files2 "${CMAKE_CURRENT_SOURCE_DIR}/*.txx") INSTALL(FILES ${__files1} ${__files2} - DESTINATION ${ITK_INSTALL_INCLUDE_DIR_CM24}/Review/Statistics + DESTINATION ${ITK_INSTALL_INCLUDE_DIR_CM24_REVIEW_STATISTICS} COMPONENT Development) ENDIF(NOT ITK_INSTALL_NO_DEVELOPMENT) diff --git a/Utilities/ITK/Code/Review/Statistics/itkEuclideanDistanceMetric.txx b/Utilities/ITK/Code/Review/Statistics/itkEuclideanDistanceMetric.txx index 0a3a403b2f90f34c02e6a23b6deb22066e4c7284..1672d22e03e34a3b9dae8ca8b84cc6654cbfd013 100644 --- a/Utilities/ITK/Code/Review/Statistics/itkEuclideanDistanceMetric.txx +++ b/Utilities/ITK/Code/Review/Statistics/itkEuclideanDistanceMetric.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkEuclideanDistanceMetric.txx,v $ Language: C++ - Date: $Date: 2009-05-22 19:26:30 $ - Version: $Revision: 1.2 $ + Date: $Date: 2010-01-31 20:01:46 $ + Version: $Revision: 1.3 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -35,15 +35,17 @@ EuclideanDistanceMetric< TVector > MeasurementVectorTraits::Assert( this->GetOrigin(), measurementVectorSize, "EuclideanDistanceMetric::Evaluate Origin and input vector have different lengths"); - double temp, distance = NumericTraits< double >::Zero; - + double sumOfSquares = NumericTraits< double >::Zero; + for(unsigned int i = 0; i < measurementVectorSize; i++) { - temp = this->GetOrigin()[i] - x[i]; - distance += temp * temp; + const double temp = this->GetOrigin()[i] - x[i]; + sumOfSquares += temp * temp; } - return vcl_sqrt(distance); + const double distance = vcl_sqrt( sumOfSquares ); + + return distance; } template< class TVector > @@ -57,14 +59,17 @@ EuclideanDistanceMetric< TVector > itkExceptionMacro( << "The two measurement vectors have unequal size" ); } - double temp, distance = NumericTraits< double >::Zero; + double sumOfSquares = NumericTraits< double >::Zero; + for(unsigned int i = 0; i < measurementVectorSize; i++) { - temp = x1[i] - x2[i]; - distance += temp * temp; + const double temp = x1[i] - x2[i]; + sumOfSquares += temp * temp; } - - return vcl_sqrt(distance); + + const double distance = vcl_sqrt( sumOfSquares ); + + return distance; } template< class TVector > @@ -72,8 +77,8 @@ inline double EuclideanDistanceMetric< TVector > ::Evaluate(const ValueType &a, const ValueType &b) const { - double temp = a - b; - return vcl_sqrt(temp * temp); + const double temp = a - b; + return vcl_abs( temp ); } } // end of namespace Statistics diff --git a/Utilities/ITK/Code/Review/Statistics/itkKdTree.h b/Utilities/ITK/Code/Review/Statistics/itkKdTree.h index 53de0cf9f6636bd25235ed950322786c12075268..15d9503e7453ca2f11ba071907df8910cb0cba8e 100644 --- a/Utilities/ITK/Code/Review/Statistics/itkKdTree.h +++ b/Utilities/ITK/Code/Review/Statistics/itkKdTree.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkKdTree.h,v $ Language: C++ - Date: $Date: 2009-05-02 05:43:56 $ - Version: $Revision: 1.1 $ + Date: $Date: 2010-02-04 20:21:48 $ + Version: $Revision: 1.2 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -326,7 +326,10 @@ struct KdTreeTerminalNode: public KdTreeNode< TSample > KdTreeTerminalNode() {} - virtual ~KdTreeTerminalNode() {} + virtual ~KdTreeTerminalNode() + { + this->m_InstanceIdentifiers.clear(); + } bool IsTerminal() const { @@ -574,7 +577,11 @@ public: * KdTreeGenerator or WeightedCentroidKdTreeGenerator. */ void SetRoot(KdTreeNodeType* root) { - m_Root = root; + if( this->m_Root ) + { + this->DeleteNode( this->m_Root ); + } + this->m_Root = root; } /** Returns the pointer to the root node. */ @@ -682,7 +689,7 @@ public: { ConstIterator iter = m_Sample->End(); return iter; - } + } protected: /** Constructor */ diff --git a/Utilities/ITK/Code/Review/Statistics/itkMeasurementVectorTraits.h b/Utilities/ITK/Code/Review/Statistics/itkMeasurementVectorTraits.h index 57b0e92c782628ff45e59a953305b1934849f4b3..ef5b1f0a4f9bccd55549931e154d1f61bf522967 100644 --- a/Utilities/ITK/Code/Review/Statistics/itkMeasurementVectorTraits.h +++ b/Utilities/ITK/Code/Review/Statistics/itkMeasurementVectorTraits.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkMeasurementVectorTraits.h,v $ Language: C++ - Date: $Date: 2009-08-08 14:39:59 $ - Version: $Revision: 1.4 $ + Date: $Date: 2009-11-18 12:46:05 $ + Version: $Revision: 1.5 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -32,47 +32,6 @@ #include <vector> -/** THIS DECLARATION OF NUMERICTRAITS IS HERE TEMPORARILY - * - * It should be moved to the Insight/Code/Common/itkNumericTraits.h file - * when the new framework is integrated into ITK - * - */ -#ifdef _WIN64 - -namespace itk { - -/** \class NumericTraits<unsigned long> - * \brief Define traits for type unsigned long. - * \ingroup DataRepresentation - */ -template <> -class NumericTraits< std::vector<int>::size_type > : public vcl_numeric_limits< std::vector<int>::size_type > { -public: - typedef std::vector<int>::size_type SelfType; - typedef SelfType ValueType; - typedef SelfType PrintType; - typedef SelfType AbsType; - typedef SelfType AccumulateType; - typedef long double RealType; - typedef RealType ScalarRealType; - typedef long double FloatType; - - static const SelfType ITKCommon_EXPORT Zero; - static const SelfType ITKCommon_EXPORT One; - - static SelfType NonpositiveMin() { return min(); } - static bool IsPositive(SelfType val) { return val != Zero; } - static bool IsNonpositive(SelfType val) { return val == Zero; } - static bool IsNegative(SelfType) { return false; } - static bool IsNonnegative(SelfType) {return true; } - static SelfType ZeroValue() { return Zero; } -}; -} - -#endif - - namespace itk { namespace Statistics diff --git a/Utilities/ITK/Code/Review/Statistics/itkScalarImageToHistogramGenerator.txx b/Utilities/ITK/Code/Review/Statistics/itkScalarImageToHistogramGenerator.txx index 819dfc46b58539924e0d0f237001a831555ca480..d0578d0d25860428c120bf89a4ce95fbd09609f9 100644 --- a/Utilities/ITK/Code/Review/Statistics/itkScalarImageToHistogramGenerator.txx +++ b/Utilities/ITK/Code/Review/Statistics/itkScalarImageToHistogramGenerator.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkScalarImageToHistogramGenerator.txx,v $ Language: C++ - Date: $Date: 2009-08-17 18:29:01 $ - Version: $Revision: 1.4 $ + Date: $Date: 2009-12-11 23:33:55 $ + Version: $Revision: 1.7 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -77,6 +77,7 @@ ScalarImageToHistogramGenerator< TImage > { typedef typename GeneratorType::HistogramMeasurementVectorType MeasurementVectorType; MeasurementVectorType minVector; + MeasurementVectorTraits::SetLength(minVector,1); minVector[0] = minimumValue; m_HistogramGenerator->SetHistogramBinMinimum( minVector ); } @@ -89,6 +90,7 @@ ScalarImageToHistogramGenerator< TImage > { typedef typename GeneratorType::HistogramMeasurementVectorType MeasurementVectorType; MeasurementVectorType maxVector; + MeasurementVectorTraits::SetLength(maxVector,1); maxVector[0] = maximumValue; m_HistogramGenerator->SetHistogramBinMaximum( maxVector ); } diff --git a/Utilities/ITK/Code/Review/Statistics/itkStatisticsAlgorithm.txx b/Utilities/ITK/Code/Review/Statistics/itkStatisticsAlgorithm.txx index 2d78960be8d158f556ecee04bb60ac4f785e5aff..e63baf106e11c09002309ca09937eb7754c02e8b 100644 --- a/Utilities/ITK/Code/Review/Statistics/itkStatisticsAlgorithm.txx +++ b/Utilities/ITK/Code/Review/Statistics/itkStatisticsAlgorithm.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkStatisticsAlgorithm.txx,v $ Language: C++ - Date: $Date: 2009-05-02 05:44:00 $ - Version: $Revision: 1.1 $ + Date: $Date: 2010-01-22 22:05:10 $ + Version: $Revision: 1.2 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -556,8 +556,11 @@ inline void InsertSort(TSubsample* sample, backwardIndex = backwardSearchBegin; while (backwardIndex > beginIndex) { - if (sample->GetMeasurementVectorByIndex(backwardIndex)[activeDimension] < - sample->GetMeasurementVectorByIndex(backwardIndex - 1)[activeDimension]) + typedef typename TSubsample::MeasurementType MeasurementType; + const MeasurementType value1 = sample->GetMeasurementVectorByIndex(backwardIndex)[activeDimension]; + const MeasurementType value2 = sample->GetMeasurementVectorByIndex(backwardIndex - 1)[activeDimension]; + + if( value1 < value2 ) { sample->Swap(backwardIndex, backwardIndex - 1); } diff --git a/Utilities/ITK/Code/Review/Statistics/itkSubsample.h b/Utilities/ITK/Code/Review/Statistics/itkSubsample.h index eb9f926c1382543fb1edf546ad43b5e276dfa1d4..47d1d8287d60389ab3f0b2ecacae77e73e353e9a 100644 --- a/Utilities/ITK/Code/Review/Statistics/itkSubsample.h +++ b/Utilities/ITK/Code/Review/Statistics/itkSubsample.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkSubsample.h,v $ Language: C++ - Date: $Date: 2009-06-15 12:40:37 $ - Version: $Revision: 1.3 $ + Date: $Date: 2010-01-21 22:03:39 $ + Version: $Revision: 1.4 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -107,7 +107,7 @@ public: InstanceIdentifier GetInstanceIdentifier( unsigned int index ); - MeasurementVectorType GetMeasurementVectorByIndex(unsigned int index) const; + const MeasurementVectorType & GetMeasurementVectorByIndex(unsigned int index) const; AbsoluteFrequencyType GetFrequencyByIndex(unsigned int index) const; diff --git a/Utilities/ITK/Code/Review/Statistics/itkSubsample.txx b/Utilities/ITK/Code/Review/Statistics/itkSubsample.txx index 6db53da5d3a5ca6377b9af97a34275c0f40cc3bd..e29eb9c89fbabf92c5a125d8782b24c244599470 100644 --- a/Utilities/ITK/Code/Review/Statistics/itkSubsample.txx +++ b/Utilities/ITK/Code/Review/Statistics/itkSubsample.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkSubsample.txx,v $ Language: C++ - Date: $Date: 2009-05-02 05:44:00 $ - Version: $Revision: 1.1 $ + Date: $Date: 2010-01-21 22:03:40 $ + Version: $Revision: 1.2 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -183,7 +183,7 @@ Subsample< TSample > } template< class TSample > -inline typename Subsample< TSample >::MeasurementVectorType +inline const typename Subsample< TSample >::MeasurementVectorType & Subsample< TSample > ::GetMeasurementVectorByIndex(unsigned int index) const { diff --git a/Utilities/ITK/Code/Review/VNLIterativeSparseSolverTraits.h b/Utilities/ITK/Code/Review/VNLIterativeSparseSolverTraits.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Review/VNLSparseLUSolverTraits.h b/Utilities/ITK/Code/Review/VNLSparseLUSolverTraits.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Review/itkAggregateLabelMapFilter.h b/Utilities/ITK/Code/Review/itkAggregateLabelMapFilter.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Review/itkAggregateLabelMapFilter.txx b/Utilities/ITK/Code/Review/itkAggregateLabelMapFilter.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Review/itkAnchorUtilities.txx b/Utilities/ITK/Code/Review/itkAnchorUtilities.txx index e219ec41e79afec3f19467543474a061e0109472..95b9c7835771a7ea2d388e955e5dbe7f262cc12f 100644 --- a/Utilities/ITK/Code/Review/itkAnchorUtilities.txx +++ b/Utilities/ITK/Code/Review/itkAnchorUtilities.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkAnchorUtilities.txx,v $ Language: C++ - Date: $Date: 2009-05-08 19:48:04 $ - Version: $Revision: 1.5 $ + Date: $Date: 2010-03-02 03:40:37 $ + Version: $Revision: 1.6 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -26,10 +26,10 @@ namespace itk { /** -* \class AnchorUtilities - * \brief functionality in common for anchor openings/closings and - * erosions/dilation - * +* AnchorUtilities +* functionality in common for anchor openings/closings and +* erosions/dilation +* **/ #if 0 template <class TImage, class TBres, class TLine> diff --git a/Utilities/ITK/Code/Review/itkAutoCropLabelMapFilter.h b/Utilities/ITK/Code/Review/itkAutoCropLabelMapFilter.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Review/itkAutoCropLabelMapFilter.txx b/Utilities/ITK/Code/Review/itkAutoCropLabelMapFilter.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Review/itkBSplineScatteredDataPointSetToImageFilter.h b/Utilities/ITK/Code/Review/itkBSplineScatteredDataPointSetToImageFilter.h index 5a935450b5209186aeabdb7676bb3947b89c1248..1a0f060facb74af587ce2338a3ec1b28d556d7e8 100644 --- a/Utilities/ITK/Code/Review/itkBSplineScatteredDataPointSetToImageFilter.h +++ b/Utilities/ITK/Code/Review/itkBSplineScatteredDataPointSetToImageFilter.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkBSplineScatteredDataPointSetToImageFilter.h,v $ Language: C++ - Date: $Date: 2009-04-20 14:53:42 $ - Version: $Revision: 1.8 $ + Date: $Date: 2010-03-02 19:26:09 $ + Version: $Revision: 1.12 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -30,29 +30,27 @@ namespace itk { -/** \class BSplineScatteredDataPointSetToImageFilter.h +/** \class BSplineScatteredDataPointSetToImageFilter * \brief Image filter which provides a B-spline output approximation. * * Given an n-D image with scattered data, this filter finds * a fast approximation to that irregularly spaced data using uniform * B-splines. The traditional method of inverting the observation * matrix to find a least-squares fit is made obsolete. Therefore, - * memory issues are not a concern and inverting large matrices are - * unnecessary. The reference below gives the algorithm for 2-D images - * and cubic splines. This class generalizes that work to encompass n-D - * images and any *feasible* B-spline order. + * memory issues are not a concern and inverting large matrices is + * not applicable. In addition, this allows fitting to be multi-threaded. + * This class generalizes from Lee's original paper to encompass + * n-D data in m-D parametric space and any *feasible* B-spline order as well + * as the option of specifying a confidence value for each point. * * In addition to specifying the input point set, one must specify the number - * of control points. If one wishes to use the multilevel component of + * of control points. The specified number of control points must be + * > m_SplineOrder. If one wishes to use the multilevel component of * this algorithm, one must also specify the number of levels in the * hierarchy. If this is desired, the number of control points becomes * the number of control points for the coarsest level. The algorithm * then increases the number of control points at each level so that - * the B-spline n-D grid is refined to twice the previous level. The - * scattered data is specified by the pixel values. - * - * Note that the specified number of control points must be > m_SplineOrder. - * + * the B-spline n-D grid is refined to twice the previous level. * * \author Nicholas J. Tustison * @@ -65,6 +63,7 @@ namespace itk * with Multilevel B-Splines", IEEE Transactions on Visualization and * Computer Graphics, 3(3):228-244, 1997. * + * \par REFERENCE * N.J. Tustison and J.C. Gee, "Generalized n-D C^k Scattered Data Approximation * with COnfidence Values", Proceedings of the MIAR conference, August 2006. */ @@ -85,7 +84,7 @@ public: /** Extract dimension from input and output image. */ itkStaticConstMacro( ImageDimension, unsigned int, - TOutputImage::ImageDimension ); + TOutputImage::ImageDimension ); typedef TOutputImage ImageType; typedef TInputPointSet PointSetType; @@ -107,8 +106,10 @@ public: typedef VectorContainer<unsigned, RealType> WeightsContainerType; typedef Image<PointDataType, itkGetStaticConstMacro( ImageDimension )> PointDataImageType; + typedef typename PointDataImageType::Pointer PointDataImagePointer; typedef Image<RealType, itkGetStaticConstMacro( ImageDimension )> RealImageType; + typedef typename RealImageType::Pointer RealImagePointer; typedef FixedArray<unsigned, itkGetStaticConstMacro( ImageDimension )> ArrayType; typedef VariableSizeMatrix<RealType> GradientType; @@ -136,6 +137,20 @@ public: itkGetConstReferenceMacro( NumberOfControlPoints, ArrayType ); itkGetConstReferenceMacro( CurrentNumberOfControlPoints, ArrayType ); + /** This array of 0/1 values defines whether a particular dimension of the + * parametric space is to be considered periodic or not. For example, if you + * are using interpolating along a 1D closed curve, the array type will have + * size 1, and you should set the first element of this array to the value + * "1". In the case that you were interpolating in a planar surface with + * cylindrical topology, the array type will have two components, and you + * should set to "1" the component that goes around the cylinder, and set to + * "0" the component that goes from the top of the cylinder to the bottom. + * This will indicate the periodity of that parameter to the filter. + * Internally, in order to make periodic the domain of the parameter, the + * filter will reuse some of the points at the beginning of the domain as if + * they were also located at the end of the domain. The number of points to + * be reused will depend on the spline order. As a user, you don't need to + * replicate the points, the filter will do this for you. */ itkSetMacro( CloseDimension, ArrayType ); itkGetConstReferenceMacro( CloseDimension, ArrayType ); @@ -148,8 +163,8 @@ public: /** * Get the control point lattice. */ - itkSetMacro( PhiLattice, typename PointDataImageType::Pointer ); - itkGetConstMacro( PhiLattice, typename PointDataImageType::Pointer ); + itkSetMacro( PhiLattice, PointDataImagePointer ); + itkGetConstMacro( PhiLattice, PointDataImagePointer ); /** * Evaluate the resulting B-spline object at a specified @@ -187,6 +202,18 @@ protected: virtual ~BSplineScatteredDataPointSetToImageFilter(); void PrintSelf( std::ostream& os, Indent indent ) const; + /** Multithreaded function which generates the control point lattice. */ + void ThreadedGenerateData( const RegionType&, int ); + void BeforeThreadedGenerateData(); + void AfterThreadedGenerateData(); + + /** Only the points are divided among the threads, so always return + * a valid number */ + int SplitRequestedRegion(int, int, RegionType&) + { + return this->GetNumberOfThreads(); + } + void GenerateData(); private: @@ -195,15 +222,12 @@ private: BSplineScatteredDataPointSetToImageFilter(const Self&); void operator=(const Self&); - void GenerateControlLattice(); - void RefineControlLattice(); + void RefineControlPointLattice(); void UpdatePointSet(); void GenerateOutputImage(); void GenerateOutputImageFast(); - void CollapsePhiLattice( PointDataImageType *, - PointDataImageType *, - RealType, unsigned int ); - + void CollapsePhiLattice( PointDataImageType *, PointDataImageType *, + RealType, unsigned int ); bool m_DoMultilevel; bool m_GenerateOutputImage; @@ -227,6 +251,9 @@ private: typename KernelOrder2Type::Pointer m_KernelOrder2; typename KernelOrder3Type::Pointer m_KernelOrder3; + std::vector<RealImagePointer> m_OmegaLatticePerThread; + std::vector<PointDataImagePointer> m_DeltaLatticePerThread; + RealType m_BSplineEpsilon; vnl_matrix<RealType> diff --git a/Utilities/ITK/Code/Review/itkBSplineScatteredDataPointSetToImageFilter.txx b/Utilities/ITK/Code/Review/itkBSplineScatteredDataPointSetToImageFilter.txx index 2b726c3cee356caa81a42a8f32557c7d7f2d9b42..04573a05d45a737fa396d6acccf2b9191dcfcd96 100644 --- a/Utilities/ITK/Code/Review/itkBSplineScatteredDataPointSetToImageFilter.txx +++ b/Utilities/ITK/Code/Review/itkBSplineScatteredDataPointSetToImageFilter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkBSplineScatteredDataPointSetToImageFilter.txx,v $ Language: C++ - Date: $Date: 2009-04-20 17:34:43 $ - Version: $Revision: 1.17 $ + Date: $Date: 2009-10-02 12:36:37 $ + Version: $Revision: 1.20 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -231,7 +231,7 @@ BSplineScatteredDataPointSetToImageFilter<TInputPointSet, TOutputImage> * Perform some error checking on the input */ if( this->m_UsePointWeights && - ( this->m_PointWeights->Size() != this->GetInput()->GetNumberOfPoints() ) ) + ( this->m_PointWeights->Size() != this->GetInput()->GetNumberOfPoints() ) ) { itkExceptionMacro( "The number of weight points and input points must be equal." ); @@ -288,7 +288,23 @@ BSplineScatteredDataPointSetToImageFilter<TInputPointSet, TOutputImage> this->m_CurrentLevel = 0; this->m_CurrentNumberOfControlPoints = this->m_NumberOfControlPoints; - this->GenerateControlLattice(); + /** + * Set up multithread processing to handle generating the + * control point lattice. + */ + typename ImageSource<TOutputImage>::ThreadStruct str1; + str1.Filter = this; + + this->GetMultiThreader()->SetNumberOfThreads( this->GetNumberOfThreads() ); + this->GetMultiThreader()->SetSingleMethod( this->ThreaderCallback, &str1 ); + + /** + * Multithread the generation of the control point lattice. + */ + this->BeforeThreadedGenerateData(); + this->GetMultiThreader()->SingleMethodExecute(); + this->AfterThreadedGenerateData(); + this->UpdatePointSet(); if( this->m_DoMultilevel ) @@ -314,7 +330,7 @@ BSplineScatteredDataPointSetToImageFilter<TInputPointSet, TOutputImage> { ItPsi.Set( ItPhi.Get() + ItPsi.Get() ); } - this->RefineControlLattice(); + this->RefineControlPointLattice(); for( unsigned int i = 0; i < ImageDimension; i++ ) { @@ -332,9 +348,10 @@ BSplineScatteredDataPointSetToImageFilter<TInputPointSet, TOutputImage> RealType avg_p = 0.0; RealType totalWeight = 0.0; - typename PointDataContainerType::Iterator ItIn, ItOut; - ItIn = this->m_InputPointData->Begin(); - ItOut = this->m_OutputPointData->Begin(); + typename PointDataContainerType::Iterator ItIn + = this->m_InputPointData->Begin(); + typename PointDataContainerType::Iterator ItOut + = this->m_OutputPointData->Begin(); while( ItIn != this->m_InputPointData->End() ) { this->m_InputPointData->InsertElement( @@ -356,7 +373,23 @@ BSplineScatteredDataPointSetToImageFilter<TInputPointSet, TOutputImage> "The average weighted difference norm of the point set is " << avg_p / totalWeight ); } - this->GenerateControlLattice(); + /** + * Set up multithread processing to handle generating the + * control point lattice. + */ + typename ImageSource<TOutputImage>::ThreadStruct str2; + str2.Filter = this; + + this->GetMultiThreader()->SetNumberOfThreads( this->GetNumberOfThreads() ); + this->GetMultiThreader()->SetSingleMethod( this->ThreaderCallback, &str2 ); + + /** + * Multithread the generation of the control point lattice. + */ + this->BeforeThreadedGenerateData(); + this->GetMultiThreader()->SingleMethodExecute(); + this->AfterThreadedGenerateData(); + this->UpdatePointSet(); } @@ -369,7 +402,7 @@ BSplineScatteredDataPointSetToImageFilter<TInputPointSet, TOutputImage> for( ItPsi.GoToBegin(), ItPhi.GoToBegin(); !ItPsi.IsAtEnd(); ++ItPsi, ++ItPhi ) { - ItPsi.Set( ItPhi.Get()+ItPsi.Get() ); + ItPsi.Set( ItPhi.Get() + ItPsi.Get() ); } typedef ImageDuplicator<PointDataImageType> ImageDuplicatorType; @@ -391,171 +424,28 @@ BSplineScatteredDataPointSetToImageFilter<TInputPointSet, TOutputImage> template <class TInputPointSet, class TOutputImage> void BSplineScatteredDataPointSetToImageFilter<TInputPointSet, TOutputImage> -::RefineControlLattice() +::BeforeThreadedGenerateData() { - ArrayType NumberOfNewControlPoints = this->m_CurrentNumberOfControlPoints; - for( unsigned int i = 0; i < ImageDimension; i++ ) - { - if( this->m_CurrentLevel < this->m_NumberOfLevels[i] ) - { - NumberOfNewControlPoints[i] - = 2*NumberOfNewControlPoints[i]-this->m_SplineOrder[i]; - } - } - typename RealImageType::RegionType::SizeType size; - for( unsigned int i = 0; i < ImageDimension; i++ ) - { - if( this->m_CloseDimension[i] ) - { - size[i] = NumberOfNewControlPoints[i] - this->m_SplineOrder[i]; - } - else - { - size[i] = NumberOfNewControlPoints[i]; - } - } - - typename PointDataImageType::Pointer RefinedLattice - = PointDataImageType::New(); - RefinedLattice->SetRegions( size ); - RefinedLattice->Allocate(); - PointDataType data; - data.Fill( 0.0 ); - RefinedLattice->FillBuffer( data ); - - typename PointDataImageType::IndexType idx; - typename PointDataImageType::IndexType idx_Psi; - typename PointDataImageType::IndexType tmp; - typename PointDataImageType::IndexType tmp_Psi; - typename PointDataImageType::IndexType off; - typename PointDataImageType::IndexType off_Psi; - typename PointDataImageType::RegionType::SizeType size_Psi; - - size.Fill( 2 ); - unsigned int N = 1; - for( unsigned int i = 0; i < ImageDimension; i++ ) - { - N *= ( this->m_SplineOrder[i] + 1 ); - size_Psi[i] = this->m_SplineOrder[i] + 1; - } - - ImageRegionIteratorWithIndex<PointDataImageType> - It( RefinedLattice, RefinedLattice->GetLargestPossibleRegion() ); - - It.GoToBegin(); - while( !It.IsAtEnd() ) - { - idx = It.GetIndex(); - for( unsigned int i = 0; i < ImageDimension; i++ ) - { - if( this->m_CurrentLevel < this->m_NumberOfLevels[i] ) - { - idx_Psi[i] = static_cast<unsigned int>( 0.5*idx[i] ); - } - else - { - idx_Psi[i] = static_cast<unsigned int>( idx[i] ); - } - } - - for( unsigned int i = 0; i < ( 2 << (ImageDimension-1) ); i++ ) - { - - PointDataType sum( 0.0 ); - PointDataType val; - off = this->NumberToIndex( i, size ); - - bool OutOfBoundary = false; - for( unsigned int j = 0; j < ImageDimension; j++ ) - { - tmp[j] = idx[j] + off[j]; - if( tmp[j] >= static_cast<int>( NumberOfNewControlPoints[j] ) - && !this->m_CloseDimension[j] ) - { - OutOfBoundary = true; - break; - } - if( this->m_CloseDimension[j] ) - { - tmp[j] %= RefinedLattice->GetLargestPossibleRegion().GetSize()[j]; - } - } - if( OutOfBoundary ) - { - continue; - } - - for( unsigned int j = 0; j < N; j++ ) - { - off_Psi = this->NumberToIndex( j, size_Psi ); - - bool IsOutOfBoundary = false; - for( unsigned int k = 0; k < ImageDimension; k++ ) - { - tmp_Psi[k] = idx_Psi[k] + off_Psi[k]; - if( tmp_Psi[k] >= - static_cast<int>( this->m_CurrentNumberOfControlPoints[k] ) - && !this->m_CloseDimension[k] ) - { - IsOutOfBoundary = true; - break; - } - if( this->m_CloseDimension[k] ) - { - tmp_Psi[k] %= - this->m_PsiLattice->GetLargestPossibleRegion().GetSize()[k]; - } - } - if( IsOutOfBoundary ) - { - continue; - } - RealType coeff = 1.0; - for( unsigned int k = 0; k < ImageDimension; k++ ) - { - coeff *= this->m_RefinedLatticeCoefficients[k]( off[k], off_Psi[k] ); - } - val = this->m_PsiLattice->GetPixel( tmp_Psi ); - val *= coeff; - sum += val; - } - RefinedLattice->SetPixel( tmp, sum ); - } - - bool IsEvenIndex = false; - while( !IsEvenIndex && !It.IsAtEnd() ) - { - ++It; - idx = It.GetIndex(); - IsEvenIndex = true; - for( unsigned int i = 0; i < ImageDimension; i++ ) - { - if( idx[i] % 2 ) - { - IsEvenIndex = false; - } - } - } - } - - typedef ImageDuplicator<PointDataImageType> ImageDuplicatorType; - typename ImageDuplicatorType::Pointer Duplicator = ImageDuplicatorType::New(); - Duplicator->SetInputImage( RefinedLattice ); - Duplicator->Update(); - this->m_PsiLattice = Duplicator->GetOutput(); + this->m_DeltaLatticePerThread.resize( this->GetNumberOfThreads() ); + this->m_OmegaLatticePerThread.resize( this->GetNumberOfThreads() ); } template <class TInputPointSet, class TOutputImage> void BSplineScatteredDataPointSetToImageFilter<TInputPointSet, TOutputImage> -::GenerateControlLattice() +::ThreadedGenerateData( const RegionType &itkNotUsed(region), int threadId ) { + /** + * Ignore the output region as we're only interested in dividing the + * points among the threads. + */ typename RealImageType::RegionType::SizeType size; for( unsigned int i = 0; i < ImageDimension; i++ ) { if( this->m_CloseDimension[i] ) { - size[i] = this->m_CurrentNumberOfControlPoints[i]-this->m_SplineOrder[i]; + size[i] = this->m_CurrentNumberOfControlPoints[i] + - this->m_SplineOrder[i]; } else { @@ -563,20 +453,15 @@ BSplineScatteredDataPointSetToImageFilter<TInputPointSet, TOutputImage> } } - this->m_PhiLattice = PointDataImageType::New(); - this->m_PhiLattice->SetRegions( size ); - this->m_PhiLattice->Allocate(); - this->m_PhiLattice->FillBuffer( 0.0 ); - - typename RealImageType::Pointer omega = RealImageType::New(); - omega->SetRegions( size ); - omega->Allocate(); - omega->FillBuffer( 0.0 ); + this->m_OmegaLatticePerThread[threadId] = RealImageType::New(); + this->m_OmegaLatticePerThread[threadId]->SetRegions( size ); + this->m_OmegaLatticePerThread[threadId]->Allocate(); + this->m_OmegaLatticePerThread[threadId]->FillBuffer( 0.0 ); - typename PointDataImageType::Pointer delta = PointDataImageType::New(); - delta->SetRegions( size ); - delta->Allocate(); - delta->FillBuffer( 0.0 ); + this->m_DeltaLatticePerThread[threadId] = PointDataImageType::New(); + this->m_DeltaLatticePerThread[threadId]->SetRegions( size ); + this->m_DeltaLatticePerThread[threadId]->Allocate(); + this->m_DeltaLatticePerThread[threadId]->FillBuffer( 0.0 ); for( unsigned int i = 0; i < ImageDimension; i++ ) { @@ -605,14 +490,26 @@ BSplineScatteredDataPointSetToImageFilter<TInputPointSet, TOutputImage> * this->m_Spacing[i] ); } - typename PointDataContainerType::ConstIterator It; - for( It = this->m_InputPointData->Begin(); - It != this->m_InputPointData->End(); ++It ) + /** + * Determine which points should be handled by this particular thread. + */ + int numberOfThreads = this->GetNumberOfThreads(); + unsigned long numberOfPointsPerThread = static_cast<unsigned long>( + this->GetInput()->GetNumberOfPoints() / numberOfThreads ); + + unsigned int start = threadId * numberOfPointsPerThread; + unsigned int end = start + numberOfPointsPerThread; + if( threadId == this->GetNumberOfThreads() - 1 ) + { + end = this->GetInput()->GetNumberOfPoints(); + } + + for( unsigned int n = start; n < end; n++ ) { PointType point; point.Fill( 0.0 ); - this->GetInput()->GetPoint( It.Index(), &point ); + this->GetInput()->GetPoint( n, &point ); for( unsigned int i = 0; i < ImageDimension; i++ ) { @@ -685,43 +582,97 @@ BSplineScatteredDataPointSetToImageFilter<TInputPointSet, TOutputImage> idx[i] += static_cast<unsigned>( p[i] ); if( this->m_CloseDimension[i] ) { - idx[i] %= delta->GetLargestPossibleRegion().GetSize()[i]; + idx[i] %= this->m_DeltaLatticePerThread[threadId] + ->GetLargestPossibleRegion().GetSize()[i]; } } - RealType wc = this->m_PointWeights->GetElement( It.Index() ); + RealType wc = this->m_PointWeights->GetElement( n ); RealType t = Itw.Get(); - if(idx[0]>=0 && idx[1]>=0 && static_cast<typename RealImageType::RegionType::SizeValueType>(idx[0])< omega->GetLargestPossibleRegion().GetSize()[0] && static_cast<typename RealImageType::RegionType::SizeValueType>(idx[1])< omega->GetLargestPossibleRegion().GetSize()[1]) - omega->SetPixel( idx, omega->GetPixel( idx ) + wc*t*t ); - + this->m_OmegaLatticePerThread[threadId]->SetPixel( idx, + this->m_OmegaLatticePerThread[threadId]->GetPixel( idx ) + wc*t*t ); - PointDataType data = It.Value(); + PointDataType data = this->m_InputPointData->GetElement( n ); data *= ( t / w2_sum ); Itp.Set( data ); data *= ( t * t * wc ); + this->m_DeltaLatticePerThread[threadId]->SetPixel( + idx, this->m_DeltaLatticePerThread[threadId]->GetPixel( idx ) + data ); + } + } +} - if(idx[0]>=0 && idx[1]>=0 && static_cast<typename PointDataImageType::RegionType::SizeValueType>(idx[0])< delta->GetLargestPossibleRegion().GetSize()[0] && static_cast<typename PointDataImageType::RegionType::SizeValueType>(idx[1])< delta->GetLargestPossibleRegion().GetSize()[1]) - { - delta->SetPixel( idx, delta->GetPixel( idx ) + data ); - delta->GetPixel( idx ) + data; +template <class TInputPointSet, class TOutputImage> +void +BSplineScatteredDataPointSetToImageFilter<TInputPointSet, TOutputImage> +::AfterThreadedGenerateData() +{ + /** + * Accumulate all the delta lattice and omega lattice values to + * calculate the final phi lattice. + */ + ImageRegionIterator<PointDataImageType> ItD( + this->m_DeltaLatticePerThread[0], + this->m_DeltaLatticePerThread[0]->GetLargestPossibleRegion() ); + ImageRegionIterator<RealImageType> ItO( + this->m_OmegaLatticePerThread[0], + this->m_OmegaLatticePerThread[0]->GetLargestPossibleRegion() ); + + for( int n = 1; n < this->GetNumberOfThreads(); n++ ) + { + ImageRegionIterator<PointDataImageType> Itd( + this->m_DeltaLatticePerThread[n], + this->m_DeltaLatticePerThread[n]->GetLargestPossibleRegion() ); + ImageRegionIterator<RealImageType> Ito( + this->m_OmegaLatticePerThread[n], + this->m_OmegaLatticePerThread[n]->GetLargestPossibleRegion() ); + + ItD.GoToBegin(); + ItO.GoToBegin(); + Itd.GoToBegin(); + Ito.GoToBegin(); + while( !ItD.IsAtEnd() ) + { + ItD.Set( ItD.Get() + Itd.Get() ); + ItO.Set( ItO.Get() + Ito.Get() ); + + ++ItD; + ++ItO; + ++Itd; + ++Ito; } } + + /** + * Generate the control point lattice + */ + typename RealImageType::RegionType::SizeType size; + for( unsigned int i = 0; i < ImageDimension; i++ ) + { + if( this->m_CloseDimension[i] ) + { + size[i] = this->m_CurrentNumberOfControlPoints[i]-this->m_SplineOrder[i]; + } + else + { + size[i] = this->m_CurrentNumberOfControlPoints[i]; + } } + this->m_PhiLattice = PointDataImageType::New(); + this->m_PhiLattice->SetRegions( size ); + this->m_PhiLattice->Allocate(); + this->m_PhiLattice->FillBuffer( 0.0 ); - ImageRegionIterator<PointDataImageType> - Itl( this->m_PhiLattice, this->m_PhiLattice->GetLargestPossibleRegion() ); - ImageRegionIterator<PointDataImageType> - Itd( delta, delta->GetLargestPossibleRegion() ); - ImageRegionIterator<RealImageType> - Ito( omega, omega->GetLargestPossibleRegion() ); + ImageRegionIterator<PointDataImageType> ItP( + this->m_PhiLattice, this->m_PhiLattice->GetLargestPossibleRegion() ); - for( Itl.GoToBegin(), Ito.GoToBegin(), Itd.GoToBegin(); - !Itl.IsAtEnd(); ++Itl, ++Ito, ++Itd ) + for( ItP.GoToBegin(), ItO.GoToBegin(), ItD.GoToBegin(); + !ItP.IsAtEnd(); ++ItP, ++ItO, ++ItD ) { PointDataType P; P.Fill( 0 ); - if( Ito.Get() != 0 ) + if( ItO.Get() != 0 ) { - P = Itd.Get() / Ito.Get(); + P = ItD.Get() / ItO.Get(); for( unsigned int i = 0; i < P.Size(); i++ ) { if( vnl_math_isnan( P[i] ) || vnl_math_isinf( P[i] ) ) @@ -729,9 +680,165 @@ BSplineScatteredDataPointSetToImageFilter<TInputPointSet, TOutputImage> P[i] = 0; } } - Itl.Set( P ); + ItP.Set( P ); + } + } +} + +template <class TInputPointSet, class TOutputImage> +void +BSplineScatteredDataPointSetToImageFilter<TInputPointSet, TOutputImage> +::RefineControlPointLattice() +{ + ArrayType NumberOfNewControlPoints = this->m_CurrentNumberOfControlPoints; + for( unsigned int i = 0; i < ImageDimension; i++ ) + { + if( this->m_CurrentLevel < this->m_NumberOfLevels[i] ) + { + NumberOfNewControlPoints[i] + = 2*NumberOfNewControlPoints[i]-this->m_SplineOrder[i]; + } + } + typename RealImageType::RegionType::SizeType size; + for( unsigned int i = 0; i < ImageDimension; i++ ) + { + if( this->m_CloseDimension[i] ) + { + size[i] = NumberOfNewControlPoints[i] - this->m_SplineOrder[i]; + } + else + { + size[i] = NumberOfNewControlPoints[i]; + } + } + + typename PointDataImageType::Pointer RefinedLattice + = PointDataImageType::New(); + RefinedLattice->SetRegions( size ); + RefinedLattice->Allocate(); + PointDataType data; + data.Fill( 0.0 ); + RefinedLattice->FillBuffer( data ); + + typename PointDataImageType::IndexType idx; + typename PointDataImageType::IndexType idx_Psi; + typename PointDataImageType::IndexType tmp; + typename PointDataImageType::IndexType tmp_Psi; + typename PointDataImageType::IndexType off; + typename PointDataImageType::IndexType off_Psi; + typename PointDataImageType::RegionType::SizeType size_Psi; + + size.Fill( 2 ); + unsigned int N = 1; + for( unsigned int i = 0; i < ImageDimension; i++ ) + { + N *= ( this->m_SplineOrder[i] + 1 ); + size_Psi[i] = this->m_SplineOrder[i] + 1; + } + + ImageRegionIteratorWithIndex<PointDataImageType> + It( RefinedLattice, RefinedLattice->GetLargestPossibleRegion() ); + + It.GoToBegin(); + while( !It.IsAtEnd() ) + { + idx = It.GetIndex(); + for( unsigned int i = 0; i < ImageDimension; i++ ) + { + if( this->m_CurrentLevel < this->m_NumberOfLevels[i] ) + { + idx_Psi[i] = static_cast<unsigned int>( 0.5*idx[i] ); + } + else + { + idx_Psi[i] = static_cast<unsigned int>( idx[i] ); + } + } + + for( unsigned int i = 0; i < ( 2 << (ImageDimension-1) ); i++ ) + { + PointDataType sum( 0.0 ); + PointDataType val( 0.0 ); + off = this->NumberToIndex( i, size ); + + bool OutOfBoundary = false; + for( unsigned int j = 0; j < ImageDimension; j++ ) + { + tmp[j] = idx[j] + off[j]; + if( tmp[j] >= static_cast<int>( NumberOfNewControlPoints[j] ) + && !this->m_CloseDimension[j] ) + { + OutOfBoundary = true; + break; + } + if( this->m_CloseDimension[j] ) + { + tmp[j] %= RefinedLattice->GetLargestPossibleRegion().GetSize()[j]; + } + } + if( OutOfBoundary ) + { + continue; + } + + for( unsigned int j = 0; j < N; j++ ) + { + off_Psi = this->NumberToIndex( j, size_Psi ); + + bool IsOutOfBoundary = false; + for( unsigned int k = 0; k < ImageDimension; k++ ) + { + tmp_Psi[k] = idx_Psi[k] + off_Psi[k]; + if( tmp_Psi[k] >= + static_cast<int>( this->m_CurrentNumberOfControlPoints[k] ) + && !this->m_CloseDimension[k] ) + { + IsOutOfBoundary = true; + break; + } + if( this->m_CloseDimension[k] ) + { + tmp_Psi[k] %= + this->m_PsiLattice->GetLargestPossibleRegion().GetSize()[k]; + } + } + if( IsOutOfBoundary ) + { + continue; + } + RealType coeff = 1.0; + for( unsigned int k = 0; k < ImageDimension; k++ ) + { + coeff *= this->m_RefinedLatticeCoefficients[k]( off[k], off_Psi[k] ); + } + val = this->m_PsiLattice->GetPixel( tmp_Psi ); + val *= coeff; + sum += val; + } + RefinedLattice->SetPixel( tmp, sum ); + } + + bool IsEvenIndex = false; + while( !IsEvenIndex && !It.IsAtEnd() ) + { + ++It; + idx = It.GetIndex(); + IsEvenIndex = true; + for( unsigned int i = 0; i < ImageDimension; i++ ) + { + if( idx[i] % 2 ) + { + IsEvenIndex = false; + } + } } } + + typedef ImageDuplicator<PointDataImageType> ImageDuplicatorType; + typename ImageDuplicatorType::Pointer Duplicator = ImageDuplicatorType::New(); + Duplicator->SetInputImage( RefinedLattice ); + Duplicator->Update(); + this->m_PsiLattice = Duplicator->GetOutput(); } template <class TInputPointSet, class TOutputImage> @@ -929,8 +1036,7 @@ template <class TInputPointSet, class TOutputImage> void BSplineScatteredDataPointSetToImageFilter<TInputPointSet, TOutputImage> ::CollapsePhiLattice( PointDataImageType *lattice, - PointDataImageType *collapsedLattice, - RealType u, unsigned int dimension ) + PointDataImageType *collapsedLattice, RealType u, unsigned int dimension ) { ImageRegionIteratorWithIndex<PointDataImageType> It ( collapsedLattice, collapsedLattice->GetLargestPossibleRegion() ); diff --git a/Utilities/ITK/Code/Review/itkBinaryImageToLabelMapFilter.h b/Utilities/ITK/Code/Review/itkBinaryImageToLabelMapFilter.h index 465d89a728b2482bad12316636fa5ff5ad248770..5d80cf9490b72700f67572b381e375d3733adb0c 100644 --- a/Utilities/ITK/Code/Review/itkBinaryImageToLabelMapFilter.h +++ b/Utilities/ITK/Code/Review/itkBinaryImageToLabelMapFilter.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkBinaryImageToLabelMapFilter.h,v $ Language: C++ - Date: $Date: 2009-07-22 21:25:55 $ - Version: $Revision: 1.3 $ + Date: $Date: 2010-02-27 22:02:33 $ + Version: $Revision: 1.4 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -25,6 +25,8 @@ #include <map> #include "itkProgressReporter.h" #include "itkBarrier.h" +#include "itkLabelMap.h" +#include "itkLabelObject.h" //PATCH OTB #include "itkLabelMap.h" diff --git a/Utilities/ITK/Code/Review/itkBinaryImageToLabelMapFilter.txx b/Utilities/ITK/Code/Review/itkBinaryImageToLabelMapFilter.txx index b0ed794d442fbc57487af9a63b28bdcd9b78b3bc..0e481a158e7b70da7391ddc433065dd3e6deaf2f 100644 --- a/Utilities/ITK/Code/Review/itkBinaryImageToLabelMapFilter.txx +++ b/Utilities/ITK/Code/Review/itkBinaryImageToLabelMapFilter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkBinaryImageToLabelMapFilter.txx,v $ Language: C++ - Date: $Date: 2009-08-24 13:34:42 $ - Version: $Revision: 1.9 $ + Date: $Date: 2009-10-13 09:59:46 $ + Version: $Revision: 1.12 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -124,7 +124,7 @@ BinaryImageToLabelMapFilter< TInputImage, TOutputImage > SizeValueType pixelcountForThread = outputRegionForThread.GetNumberOfPixels(); SizeValueType xsizeForThread = outputRegionForThread.GetSize()[0]; SizeValueType linecountForThread = pixelcountForThread/xsizeForThread; - ProgressReporter progress(this, threadId, linecountForThread); + ProgressReporter progress(this, threadId, linecountForThread, 75, 0.0f, 0.75f); // find the split axis IndexType outputRegionIdx = output->GetRequestedRegion().GetIndex(); @@ -340,13 +340,14 @@ BinaryImageToLabelMapFilter< TInputImage, TOutputImage > SizeValueType xsize = output->GetRequestedRegion().GetSize()[0]; SizeValueType linecount = pixelcount/xsize; unsigned long int totalLabs = CreateConsecutive(); - ProgressReporter progress(this, 0, linecount); + ProgressReporter progress(this, 0, linecount, 25, 0.75f, 0.25f); // check for overflow exception here if( totalLabs > static_cast<unsigned long int>( NumericTraits<OutputPixelType>::max() ) ) { itkExceptionMacro( - << "Number of objects greater than maximum of output pixel type " ); + << "Number of objects (" << totalLabs << ") greater than maximum of output pixel type (" + << static_cast<typename NumericTraits<OutputImagePixelType>::PrintType>(NumericTraits<OutputPixelType>::max()) << ")." ); } for (SizeValueType ThisIdx = 0; ThisIdx<linecount; ThisIdx++) @@ -481,18 +482,18 @@ BinaryImageToLabelMapFilter< TInputImage, TOutputImage > OffsetValueType nStart = nIt->where[0]; OffsetValueType nLast = nStart + nIt->length - 1; // there are a few ways that neighbouring lines might overlap - // neighbor S E - // current S E - //------------------------------------------ - // neighbor S E - // current S E - //------------------------------------------ - // neighbor S E - // current S E - //------------------------------------------ - // neighbor S E - // current S E - //------------------------------------------ + // neighbor S------------------E + // current S------------------------E + //------------- + // neighbor S------------------E + // current S----------------E + //------------- + // neighbor S------------------E + // current S------------------E + //------------- + // neighbor S------------------E + // current S-------E + //------------- OffsetValueType ss1 = nStart - offset; // OffsetValueType ss2 = nStart + offset; OffsetValueType ee1 = nLast - offset; @@ -504,30 +505,22 @@ BinaryImageToLabelMapFilter< TInputImage, TOutputImage > // case 1 eq = true; } - else + else if ((ss1 <= cStart) && (ee2 >= cLast)) { - if ((ss1 <= cLast) && (ee2 >= cLast)) - { - // case 2 - eq = true; - } - else - { - if ((ss1 <= cStart) && (ee2 >= cStart)) - { - // case 3 - eq = true; - } - else - { - if ((ss1 <= cStart) && (ee2 >= cLast)) - { - // case 4 - eq = true; - } - } - } + // case 4 - must be tested before case 2 to not be detected as a case 2 + eq = true; + } + else if ((ss1 <= cLast) && (ee2 >= cLast)) + { + // case 2 + eq = true; } + else if ((ss1 <= cStart) && (ee2 >= cStart)) + { + // case 3 + eq = true; + } + if (eq) { LinkLabels(nIt->label, cIt->label); diff --git a/Utilities/ITK/Code/Review/itkBruker2DSEQImageIO.cxx b/Utilities/ITK/Code/Review/itkBruker2DSEQImageIO.cxx index 085fdae1ca3080a9c62b7ebf331bf0c5b315c312..e4bc73695d05a8fdbfb8a14aac5359b65e09a6db 100644 --- a/Utilities/ITK/Code/Review/itkBruker2DSEQImageIO.cxx +++ b/Utilities/ITK/Code/Review/itkBruker2DSEQImageIO.cxx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkBruker2DSEQImageIO.cxx,v $ Language: C++ - Date: $Date: 2009-03-16 17:11:53 $ - Version: $Revision: 1.7 $ + Date: $Date: 2009-12-01 18:04:54 $ + Version: $Revision: 1.9 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -26,6 +26,7 @@ #include <stdlib.h> #include <vector> #include <algorithm> +#include <locale> /** * \author Don C. Bigler @@ -258,8 +259,9 @@ void Bruker2DSEQImageIO::Read(void* buffer) itksys::SystemTools::ConvertToUnixSlashes(file2Dseq); /* Try to open the file */ std::ifstream twodseq_InputStream; - twodseq_InputStream.open( file2Dseq.c_str(), - std::ios::in | std::ios::binary ); + twodseq_InputStream.imbue(std::locale::classic()); + twodseq_InputStream.open( file2Dseq.c_str(), std::ios::in | std::ios::binary ); + if( twodseq_InputStream.fail() ) { OStringStream message; @@ -271,7 +273,9 @@ void Bruker2DSEQImageIO::Read(void* buffer) ITK_LOCATION); throw exception; } - twodseq_InputStream.read(p, this->GetImageSizeInBytes()); + + twodseq_InputStream.read(p, Math::CastWithRangeCheck< std::streamsize, SizeType >( this->GetImageSizeInBytes() ) ); + if( twodseq_InputStream.fail() ) { OStringStream message; @@ -331,6 +335,7 @@ bool Bruker2DSEQImageIO::CanReadFile( const char* FileNameToRead ) { return false; } + reco_InputStream.imbue(std::locale::classic()); while( !reco_InputStream.eof() ) { reco_InputStream.getline(readFileBuffer, sizeof(readFileBuffer)); @@ -388,6 +393,7 @@ bool Bruker2DSEQImageIO::CanReadFile( const char* FileNameToRead ) { return false; } + d3proc_InputStream.imbue(std::locale::classic()); while( !d3proc_InputStream.eof() ) { d3proc_InputStream.getline(readFileBuffer, sizeof(readFileBuffer)); @@ -570,6 +576,7 @@ void Bruker2DSEQImageIO::ReadImageInformation() ITK_LOCATION); throw exception; } + d3proc_InputStream.imbue(std::locale::classic()); while( !d3proc_InputStream.eof() ) { d3proc_InputStream.getline(readFileBuffer, sizeof(readFileBuffer)); @@ -694,6 +701,7 @@ void Bruker2DSEQImageIO::ReadImageInformation() ITK_LOCATION); throw exception; } + reco_InputStream.imbue(std::locale::classic()); while( !reco_InputStream.eof() ) { reco_InputStream.getline(readFileBuffer, sizeof(readFileBuffer)); @@ -1027,6 +1035,7 @@ void Bruker2DSEQImageIO::ReadImageInformation() ITK_LOCATION); throw exception; } + acqp_InputStream.imbue(std::locale::classic()); while( !acqp_InputStream.eof() ) { int numEchoes = 0; diff --git a/Utilities/ITK/Code/Review/itkBruker2DSEQImageIO.h b/Utilities/ITK/Code/Review/itkBruker2DSEQImageIO.h index c3e08c5d92a958ed3d52e5cf17f430826f379864..b0ee20944320b384289b46b8535f0bcb8fb88cc4 100644 --- a/Utilities/ITK/Code/Review/itkBruker2DSEQImageIO.h +++ b/Utilities/ITK/Code/Review/itkBruker2DSEQImageIO.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkBruker2DSEQImageIO.h,v $ Language: C++ - Date: $Date: 2008-06-23 22:04:35 $ - Version: $Revision: 1.4 $ + Date: $Date: 2010-01-22 10:03:46 $ + Version: $Revision: 1.5 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -151,7 +151,7 @@ public: /*-------- This part of the interfaces deals with writing data. ----- */ /** Determine if the file can be written with this ImageIO implementation. - * \param FileNameToWrite The name of the file to test for writing. + * FileNameToWrite The name of the file to test for writing. * \author Don C. Bigler * \post This function will always return false (Not implemented). * \return Returns true if this ImageIO can write the file specified. diff --git a/Utilities/ITK/Code/Review/itkChangeLabelLabelMapFilter.h b/Utilities/ITK/Code/Review/itkChangeLabelLabelMapFilter.h index e4ceabd05bbc1d8018bfb31f38f71cce5d64c1a2..95e5286606c1fe0a42ac09666c1da4daf731300d 100644 --- a/Utilities/ITK/Code/Review/itkChangeLabelLabelMapFilter.h +++ b/Utilities/ITK/Code/Review/itkChangeLabelLabelMapFilter.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkChangeLabelLabelMapFilter.h,v $ Language: C++ - Date: $Date: 2009-08-04 20:25:11 $ - Version: $Revision: 1.5 $ + Date: $Date: 2009-10-12 18:55:34 $ + Version: $Revision: 1.6 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -105,14 +105,6 @@ private: ChangeLabelLabelMapFilter(const Self&); //purposely not implemented void operator=(const Self&); //purposely not implemented - void MoveLabelsToTemporaryArray(); - void ChangeBackgroundIfNeeded(); - void RestoreLabelObjectsAndChangeLabels(); - - typedef typename std::deque< typename LabelObjectType::Pointer > VectorType; - - VectorType m_LabelObjectsToBeRelabeled; - }; // end of class } // end namespace itk diff --git a/Utilities/ITK/Code/Review/itkChangeLabelLabelMapFilter.txx b/Utilities/ITK/Code/Review/itkChangeLabelLabelMapFilter.txx index 100a5a9cfb82ef94da7ef8923758fa9c38124e3d..65d336303b44666a33758d39a3d8142452783a0b 100644 --- a/Utilities/ITK/Code/Review/itkChangeLabelLabelMapFilter.txx +++ b/Utilities/ITK/Code/Review/itkChangeLabelLabelMapFilter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkChangeLabelLabelMapFilter.txx,v $ Language: C++ - Date: $Date: 2009-07-20 19:05:50 $ - Version: $Revision: 1.5 $ + Date: $Date: 2009-10-13 16:17:36 $ + Version: $Revision: 1.7 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -80,26 +80,21 @@ void ChangeLabelLabelMapFilter<TImage> ::GenerateData() { - this->MoveLabelsToTemporaryArray(); - this->ChangeBackgroundIfNeeded(); - this->RestoreLabelObjectsAndChangeLabels(); -} + // MoveLabelsToTemporaryArray -template <class TImage> -void -ChangeLabelLabelMapFilter<TImage> -::MoveLabelsToTemporaryArray() -{ // Allocate the output this->AllocateOutputs(); ImageType * output = this->GetOutput(); // Report the progress - ProgressReporter progress( this, 0, m_MapOfLabelToBeReplaced.size() ); + ProgressReporter progress( this, 0, m_MapOfLabelToBeReplaced.size() * 2 ); // First remove the ones to change and store them elsewhere to process later - this->m_LabelObjectsToBeRelabeled.clear(); + typedef typename LabelObjectType::Pointer LabelObjectPointer; + typedef std::deque< LabelObjectPointer > VectorType; + + VectorType labelObjectsToBeRelabeled; ChangeMapIterator pairToReplace = m_MapOfLabelToBeReplaced.begin(); @@ -111,7 +106,7 @@ ChangeLabelLabelMapFilter<TImage> { if( output->HasLabel( labelToBeReplaced ) ) { - this->m_LabelObjectsToBeRelabeled.push_back( output->GetLabelObject( labelToBeReplaced ) ); + labelObjectsToBeRelabeled.push_back( output->GetLabelObject( labelToBeReplaced ) ); output->RemoveLabel( labelToBeReplaced ); } } @@ -120,14 +115,7 @@ ChangeLabelLabelMapFilter<TImage> pairToReplace++; } -} - -template <class TImage> -void -ChangeLabelLabelMapFilter<TImage> -::ChangeBackgroundIfNeeded() -{ - ImageType * output = this->GetOutput(); + // ChangeBackgroundIfNeeded // Check if the background is among the list of labels to relabel. ChangeMapIterator backgroundLabelItr = m_MapOfLabelToBeReplaced.find( output->GetBackgroundValue() ); @@ -148,23 +136,14 @@ ChangeLabelLabelMapFilter<TImage> output->SetBackgroundValue( newLabelForBackground ); } } -} - -template <class TImage> -void -ChangeLabelLabelMapFilter<TImage> -::RestoreLabelObjectsAndChangeLabels() -{ - ImageType * output = this->GetOutput(); + // RestoreLabelObjectsAndChangeLabels // Put the objects back in the map, with the updated label typedef typename VectorType::iterator LabelObjectIterator; - LabelObjectIterator labelObjectItr = this->m_LabelObjectsToBeRelabeled.begin(); - - ProgressReporter progress( this, 0, 1 ); + LabelObjectIterator labelObjectItr = labelObjectsToBeRelabeled.begin(); - while( labelObjectItr != this->m_LabelObjectsToBeRelabeled.end() ) + while( labelObjectItr != labelObjectsToBeRelabeled.end() ) { LabelObjectType * labelObjectSource = *labelObjectItr; PixelType newLabel = m_MapOfLabelToBeReplaced[ labelObjectSource->GetLabel() ]; diff --git a/Utilities/ITK/Code/Review/itkConformalFlatteningMeshFilter.h b/Utilities/ITK/Code/Review/itkConformalFlatteningMeshFilter.h index e740c7a0af69cd7f39ae64719051c66d547b8055..00f1dc57c3f8a76ebbf63b76464ba70fafe62400 100644 --- a/Utilities/ITK/Code/Review/itkConformalFlatteningMeshFilter.h +++ b/Utilities/ITK/Code/Review/itkConformalFlatteningMeshFilter.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkConformalFlatteningMeshFilter.h,v $ Language: C++ - Date: $Date: 2008-07-09 20:17:38 $ - Version: $Revision: 1.12 $ + Date: $Date: 2009-09-17 11:14:57 $ + Version: $Revision: 1.13 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -54,7 +54,7 @@ public: typedef SmartPointer<Self> Pointer; typedef SmartPointer<const Self> ConstPointer; - typedef typename InputMeshType::Pointer InputMeshPointer; + typedef typename InputMeshType::ConstPointer InputMeshConstPointer; typedef typename OutputMeshType::Pointer OutputMeshPointer; typedef typename InputMeshType::PointType InputPointType; typedef typename OutputMeshType::PointType OutputPointType; @@ -69,8 +69,6 @@ public: /** Run-time type information (and related methods). */ itkTypeMacro(ConformalFlatteningMeshFilter,MeshToMeshFilter); - void SetInput(TInputMesh *input); - /** Convenient constants obtained from TMeshTraits template parameter. */ itkStaticConstMacro(InputPointDimension, unsigned int, ::itk::GetMeshDimension< TInputMesh >::PointDimension ); diff --git a/Utilities/ITK/Code/Review/itkConformalFlatteningMeshFilter.txx b/Utilities/ITK/Code/Review/itkConformalFlatteningMeshFilter.txx index 161e8a14aaf00717080d52c499c3ce4e9e36a30e..e2ec8dd87a6fa8e2504e3b36690091d6eef95a7f 100644 --- a/Utilities/ITK/Code/Review/itkConformalFlatteningMeshFilter.txx +++ b/Utilities/ITK/Code/Review/itkConformalFlatteningMeshFilter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkConformalFlatteningMeshFilter.txx,v $ Language: C++ - Date: $Date: 2009-07-11 12:16:37 $ - Version: $Revision: 1.30 $ + Date: $Date: 2009-09-17 11:14:57 $ + Version: $Revision: 1.31 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -101,16 +101,6 @@ ConformalFlatteningMeshFilter< TInputMesh, TOutputMesh > Superclass::PrintSelf(os,indent); } -/** - * - */ -template <class TInputMesh, class TOutputMesh> -void -ConformalFlatteningMeshFilter< TInputMesh, TOutputMesh > -::SetInput(TInputMesh *input) -{ - this->ProcessObject::SetNthInput(0, input); -} /** * This method causes the filter to generate its output. @@ -123,13 +113,14 @@ ConformalFlatteningMeshFilter< TInputMesh, TOutputMesh > typedef typename TInputMesh::PointsContainer InputPointsContainer; typedef typename TOutputMesh::PointsContainer OutputPointsContainer; - typedef typename TInputMesh::PointsContainerPointer - InputPointsContainerPointer; + typedef typename TInputMesh::PointsContainerConstPointer + InputPointsContainerConstPointer; + typedef typename TOutputMesh::PointsContainerPointer OutputPointsContainerPointer; - InputMeshPointer inputMesh = this->GetInput(); - OutputMeshPointer outputMesh = this->GetOutput(); + InputMeshConstPointer inputMesh = this->GetInput(); + OutputMeshPointer outputMesh = this->GetOutput(); if( !inputMesh ) { @@ -143,7 +134,6 @@ ConformalFlatteningMeshFilter< TInputMesh, TOutputMesh > outputMesh->SetBufferedRegion( outputMesh->GetRequestedRegion() ); - InputPointsContainerPointer inPoints = inputMesh->GetPoints(); OutputPointsContainerPointer outPoints = outputMesh->GetPoints(); const unsigned int numberOfPoints = inputMesh->GetNumberOfPoints(); @@ -151,7 +141,7 @@ ConformalFlatteningMeshFilter< TInputMesh, TOutputMesh > outPoints->Reserve( numberOfPoints ); outPoints->Squeeze(); // in case the previous mesh had // allocated a larger memory - + unsigned int i; SparseMatrixCoordType D(numberOfPoints,numberOfPoints); @@ -468,7 +458,7 @@ ConformalFlatteningMeshFilter< TInputMesh, TOutputMesh > numIter += numIter/10; // let the iteration times a little more than the dimension double tol = 1e-6; - + for ( i = 0; i <= numIter; ++i) { VectorCoordType Dxd; @@ -545,12 +535,12 @@ ConformalFlatteningMeshFilter< TInputMesh, TOutputMesh > std::vector<double> v_r2(numberOfPoints); std::vector<double>::iterator itv_r2=v_r2.begin(); - - for (i = 0; i < numberOfPoints; ++i, ++itv_r2) + + for (i = 0; i < numberOfPoints; ++i, ++itv_r2) { *itv_r2 = x(i)*x(i) + y(i)*y(i); } - + std::sort(v_r2.begin(), v_r2.end()); unsigned int uiMidPointIdx = 0; if( numberOfPoints % 2 ) @@ -619,11 +609,10 @@ ConformalFlatteningMeshFilter< TInputMesh, TOutputMesh > << " " << bounds[4] << " " << bounds[5]); //Create duplicate references to the rest of data on the mesh - - outputMesh->SetPointData( inputMesh->GetPointData() ); - outputMesh->SetCellLinks( inputMesh->GetCellLinks() ); - outputMesh->SetCells( inputMesh->GetCells() ); - outputMesh->SetCellData( inputMesh->GetCellData() ); + this->CopyInputMeshToOutputMeshPointData(); + this->CopyInputMeshToOutputMeshCellLinks(); + this->CopyInputMeshToOutputMeshCells(); + this->CopyInputMeshToOutputMeshCellData(); unsigned int maxDimension = TInputMesh::MaxTopologicalDimension; diff --git a/Utilities/ITK/Code/Review/itkContourExtractor2DImageFilter.h b/Utilities/ITK/Code/Review/itkContourExtractor2DImageFilter.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Review/itkContourExtractor2DImageFilter.txx b/Utilities/ITK/Code/Review/itkContourExtractor2DImageFilter.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Review/itkConvolutionImageFilter.txx b/Utilities/ITK/Code/Review/itkConvolutionImageFilter.txx index a900ce6de9ae1771c5f703e0a05f6ad953e8b8b9..f3b120efe0bb6d8a60304847a9ea43950124968d 100644 --- a/Utilities/ITK/Code/Review/itkConvolutionImageFilter.txx +++ b/Utilities/ITK/Code/Review/itkConvolutionImageFilter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkConvolutionImageFilter.txx,v $ Language: C++ -Date: $Date: 2009-02-23 18:40:36 $ -Version: $Revision: 1.9 $ +Date: $Date: 2009-10-29 15:03:32 $ +Version: $Revision: 1.10 $ Copyright (c) Insight Software Consortium. All rights reser See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for detail. @@ -60,8 +60,8 @@ ConvolutionImageFilter<TInputImage, TOutputImage> RadiusType radius; for( unsigned int i = 0; i < ImageDimension; i++ ) { - radius[i] = static_cast< SizeValueType >( vcl_floor( 0.5 * - this->GetImageKernelInput()->GetLargestPossibleRegion().GetSize()[i] ) ); + radius[i] = Math::Floor< SizeValueType >( 0.5 * + this->GetImageKernelInput()->GetLargestPossibleRegion().GetSize()[i] ); } double scalingFactor = 1.0; diff --git a/Utilities/ITK/Code/Review/itkCoxDeBoorBSplineKernelFunction.h b/Utilities/ITK/Code/Review/itkCoxDeBoorBSplineKernelFunction.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Review/itkCoxDeBoorBSplineKernelFunction.txx b/Utilities/ITK/Code/Review/itkCoxDeBoorBSplineKernelFunction.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Review/itkCustomColormapFunctor.txx b/Utilities/ITK/Code/Review/itkCustomColormapFunctor.txx index 7768e8202d2d39a29126b777a7983f28fe707d4f..988ff2d3962b872adc4f73b1bbcf7931200923e8 100644 --- a/Utilities/ITK/Code/Review/itkCustomColormapFunctor.txx +++ b/Utilities/ITK/Code/Review/itkCustomColormapFunctor.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkCustomColormapFunctor.txx,v $ Language: C++ - Date: $Date: 2009-05-15 02:47:59 $ - Version: $Revision: 1.1 $ + Date: $Date: 2009-10-29 15:03:32 $ + Version: $Revision: 1.2 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -40,9 +40,9 @@ CustomColormapFunctor<TScalar, TRGBPixel> else if ( this->m_RedChannel.size() > 1 ) { RealType size = static_cast<RealType>( this->m_RedChannel.size() ); - RealType index = vcl_ceil( value * ( size - 1.0 ) ); - RealType p1 = this->m_RedChannel[static_cast<unsigned int>( index )]; - RealType m1 = this->m_RedChannel[static_cast<unsigned int>( index-1 )]; + unsigned int index = Math::Ceil<unsigned int>( value * ( size - 1.0 ) ); + RealType p1 = this->m_RedChannel[index]; + RealType m1 = this->m_RedChannel[index-1u]; RealType d = p1 - m1; red = d * ( size - 1.0 ) * ( value - ( index - 1.0 )/( size - 1.0 ) ) + m1; @@ -56,9 +56,9 @@ CustomColormapFunctor<TScalar, TRGBPixel> else if ( this->m_GreenChannel.size() > 1 ) { RealType size = static_cast<RealType>( this->m_GreenChannel.size() ); - RealType index = vcl_ceil( value * ( size - 1.0 ) ); - RealType p1 = this->m_GreenChannel[static_cast<unsigned int>( index )]; - RealType m1 = this->m_GreenChannel[static_cast<unsigned int>( index-1 )]; + unsigned int index = Math::Ceil<unsigned int>( value * ( size - 1.0 ) ); + RealType p1 = this->m_GreenChannel[index]; + RealType m1 = this->m_GreenChannel[index-1u]; RealType d = p1 - m1; green = d * ( size - 1.0 ) * ( value - ( index - 1.0 )/( size - 1.0 ) ) + m1; @@ -72,9 +72,9 @@ CustomColormapFunctor<TScalar, TRGBPixel> else if ( this->m_BlueChannel.size() > 1 ) { RealType size = static_cast<RealType>( this->m_BlueChannel.size() ); - RealType index = vcl_ceil( value * ( size - 1.0 ) ); - RealType p1 = this->m_BlueChannel[static_cast<unsigned int>( index )]; - RealType m1 = this->m_BlueChannel[static_cast<unsigned int>( index-1 )]; + unsigned int index = Math::Ceil<unsigned int>( value * ( size - 1.0 ) ); + RealType p1 = this->m_BlueChannel[index]; + RealType m1 = this->m_BlueChannel[index-1u]; RealType d = p1 - m1; blue = d * ( size - 1.0 ) * ( value - ( index - 1.0 )/( size - 1.0 ) ) + m1; diff --git a/Utilities/ITK/Code/Review/itkDiffeomorphicDemonsRegistrationFilter.h b/Utilities/ITK/Code/Review/itkDiffeomorphicDemonsRegistrationFilter.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Review/itkDiffeomorphicDemonsRegistrationFilter.txx b/Utilities/ITK/Code/Review/itkDiffeomorphicDemonsRegistrationFilter.txx old mode 100644 new mode 100755 index ae19a522bf442ccf1d4152d21be14286b5ca1874..f604349b79bc850b26f5e217a21a855fb533f8cb --- a/Utilities/ITK/Code/Review/itkDiffeomorphicDemonsRegistrationFilter.txx +++ b/Utilities/ITK/Code/Review/itkDiffeomorphicDemonsRegistrationFilter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkDiffeomorphicDemonsRegistrationFilter.txx,v $ Language: C++ - Date: $Date: 2009-04-05 23:09:19 $ - Version: $Revision: 1.9 $ + Date: $Date: 2009-10-29 15:03:32 $ + Version: $Revision: 1.10 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -301,7 +301,7 @@ DiffeomorphicDemonsRegistrationFilter<TFixedImage,TMovingImage,TDeformationField unsigned int numiter = 0; if ( numiterfloat > 0.0 ) { - numiter = static_cast<unsigned int>( vcl_ceil(numiterfloat) ); + numiter = Math::Ceil<unsigned int>( numiterfloat ); } m_Exponentiator->AutomaticNumberOfIterationsOff(); diff --git a/Utilities/ITK/Code/Review/itkDirectFourierReconstructionImageToImageFilter.txx b/Utilities/ITK/Code/Review/itkDirectFourierReconstructionImageToImageFilter.txx index d19957e7fd420ccc1557cc5b9ec33a9ab0250497..94cd4b1ea6347c3ccb4d065b3a8637bba1403998 100644 --- a/Utilities/ITK/Code/Review/itkDirectFourierReconstructionImageToImageFilter.txx +++ b/Utilities/ITK/Code/Review/itkDirectFourierReconstructionImageToImageFilter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkDirectFourierReconstructionImageToImageFilter.txx,v $ Language: C++ - Date: $Date: 2009-05-06 22:00:34 $ - Version: $Revision: 1.6 $ + Date: $Date: 2009-10-29 15:03:32 $ + Version: $Revision: 1.7 $ Copyright ( c ) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -188,7 +188,8 @@ template< class TInputPixelType, class TOutputPixelType > typename InputImageType::IndexType inputROIStart = inputROI.GetIndex(); // the number of projections needed to cover 180 degrees - const unsigned int alpha_size = static_cast< unsigned int >( vcl_floor( ( 180 * ( inputROISize[m_AlphaDirection] ) ) / m_AlphaRange ) ); + const unsigned int alpha_size = Math::Floor< unsigned int >( + ( 180 * ( inputROISize[m_AlphaDirection] ) ) / m_AlphaRange ); const double last_alpha_size = 1 + ( 180.0 * ( inputROISize[m_AlphaDirection] ) ) / m_AlphaRange - alpha_size; inputROIStart[m_AlphaDirection] += ( inputROISize[m_AlphaDirection] - alpha_size ) / 2; inputROISize[m_AlphaDirection] = alpha_size; @@ -363,7 +364,7 @@ template< class TInputPixelType, class TOutputPixelType > FFTLineType::PixelType out; // radial BSpline / linear angle interpolation - a_lo = static_cast< unsigned int >( vcl_floor( alpha ) ); + a_lo = Math::Floor< unsigned int >( alpha ); if ( a_lo < alpha_size - 1 ) // no date-line crossing { diff --git a/Utilities/ITK/Code/Review/itkDiscreteGaussianDerivativeImageFilter.h b/Utilities/ITK/Code/Review/itkDiscreteGaussianDerivativeImageFilter.h index 1615fa385c1b074130a0c689a882dfa1fb4d730f..adcce2def10b4b61642924fc9d6555d5d6486542 100644 --- a/Utilities/ITK/Code/Review/itkDiscreteGaussianDerivativeImageFilter.h +++ b/Utilities/ITK/Code/Review/itkDiscreteGaussianDerivativeImageFilter.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkDiscreteGaussianDerivativeImageFilter.h,v $ Language: C++ - Date: $Date: 2009-04-23 03:43:41 $ - Version: $Revision: 1.6 $ + Date: $Date: 2010-01-28 21:57:38 $ + Version: $Revision: 1.7 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -125,90 +125,30 @@ public: * to the same values. */ void SetOrder (const typename OrderArrayType::ValueType v) { - m_Order.Fill(v); + OrderArrayType a; + a.Fill(v); + this->SetOrder(a); } void SetVariance (const typename ArrayType::ValueType v) { - m_Variance.Fill(v); + ArrayType a; + a.Fill(v); + this->SetVariance(a); } void SetMaximumError (const typename ArrayType::ValueType v) { - m_MaximumError.Fill(v); + ArrayType a; + a.Fill(v); + this->SetMaximumError(a); } - void SetOrder (const unsigned int *v) - { - OrderArrayType dv; - for (unsigned int i = 0; i < ImageDimension; i++) - { - dv[i] = v[i]; - } - this->SetOrder(dv); - } - - void SetVariance (const double *v) - { - ArrayType dv; - for (unsigned int i = 0; i < ImageDimension; i++) - { - dv[i] = v[i]; - } - this->SetVariance(dv); - } - - void SetVariance (const float *v) - { - ArrayType dv; - for (unsigned int i = 0; i < ImageDimension; i++) - { - dv[i] = v[i]; - } - this->SetVariance(dv); - } - - void SetMaximumError (const double *v) - { - ArrayType dv; - for (unsigned int i = 0; i < ImageDimension; i++) - { - dv[i] = v[i]; - } - this->SetMaximumError(dv); - } - - void SetMaximumError (const float *v) - { - ArrayType dv; - for (unsigned int i = 0; i < ImageDimension; i++) - { - dv[i] = v[i]; - } - this->SetMaximumError(dv); - } - - /** Use the image spacing information in calculations. Use this option if you - * want to specify Gaussian variance in real world units. Default is - * ImageSpacingOn. */ - void SetUseImageSpacingOn() { this->SetUseImageSpacing(true); } - - /** Ignore the image spacing. Use this option if you want to specify Gaussian - variance in pixels. Default is ImageSpacingOn. */ - void SetUseImageSpacingOff() { this->SetUseImageSpacing(false); } - /** Set/Get whether or not the filter will use the spacing of the input - image in its calculations */ + image in its calculations. Default is ImageSpacingOn. */ itkSetMacro(UseImageSpacing, bool); itkGetConstMacro(UseImageSpacing, bool); - - /** DiscreteGaussianDerivativeImageFilter needs a larger input requested region - * than the output requested region (larger by the size of the - * Gaussian kernel). As such, DiscreteGaussianDerivativeImageFilter needs to - * provide an implementation for GenerateInputRequestedRegion() in - * order to inform the pipeline execution model. - * \sa ImageToImageFilter::GenerateInputRequestedRegion() */ - virtual void GenerateInputRequestedRegion() throw(InvalidRequestedRegionError); + itkBooleanMacro(UseImageSpacing); #ifdef ITK_USE_CONCEPT_CHECKING /** Begin concept checking */ @@ -230,6 +170,14 @@ protected: virtual ~DiscreteGaussianDerivativeImageFilter() {} void PrintSelf(std::ostream& os, Indent indent) const; + /** DiscreteGaussianDerivativeImageFilter needs a larger input requested region + * than the output requested region (larger by the size of the + * Gaussian kernel). As such, DiscreteGaussianDerivativeImageFilter needs to + * provide an implementation for GenerateInputRequestedRegion() in + * order to inform the pipeline execution model. + * \sa ImageToImageFilter::GenerateInputRequestedRegion() */ + virtual void GenerateInputRequestedRegion() throw(InvalidRequestedRegionError); + /** Standard pipeline method. While this class does not implement a * ThreadedGenerateData(), its GenerateData() delegates all * calculations to an NeighborhoodOperatorImageFilter. Since the diff --git a/Utilities/ITK/Code/Review/itkDiscreteGaussianDerivativeImageFunction.h b/Utilities/ITK/Code/Review/itkDiscreteGaussianDerivativeImageFunction.h index a3be57561d3fb1cf75785c3194fbb42ca5d5359c..db1802e25e6771fb2e4eac82d32f13a4df74c30f 100644 --- a/Utilities/ITK/Code/Review/itkDiscreteGaussianDerivativeImageFunction.h +++ b/Utilities/ITK/Code/Review/itkDiscreteGaussianDerivativeImageFunction.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkDiscreteGaussianDerivativeImageFunction.h,v $ Language: C++ - Date: $Date: 2009-04-23 03:43:41 $ - Version: $Revision: 1.10 $ + Date: $Date: 2009-10-29 11:19:14 $ + Version: $Revision: 1.11 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -71,6 +71,7 @@ public: typedef typename Superclass::InputImageType InputImageType; typedef typename Superclass::InputPixelType InputPixelType; typedef typename Superclass::IndexType IndexType; + typedef typename Superclass::IndexValueType IndexValueType; typedef typename Superclass::ContinuousIndexType ContinuousIndexType; typedef typename Superclass::PointType PointType; diff --git a/Utilities/ITK/Code/Review/itkDiscreteGaussianDerivativeImageFunction.txx b/Utilities/ITK/Code/Review/itkDiscreteGaussianDerivativeImageFunction.txx index 8cfdd1c6242e974da9837f0f1058f84a7b8437b1..0434cc1ea3ba641de348e5b8193a13cc81e22135 100644 --- a/Utilities/ITK/Code/Review/itkDiscreteGaussianDerivativeImageFunction.txx +++ b/Utilities/ITK/Code/Review/itkDiscreteGaussianDerivativeImageFunction.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkDiscreteGaussianDerivativeImageFunction.txx,v $ Language: C++ - Date: $Date: 2008-12-06 13:28:10 $ - Version: $Revision: 1.4 $ + Date: $Date: 2009-10-29 11:19:15 $ + Version: $Revision: 1.5 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -229,29 +229,13 @@ DiscreteGaussianDerivativeImageFunction<TInputImage,TOutput> // Compute base index = closet index below point // Compute distance from point to base index - signed long baseIndex[ImageDimension2]; + IndexType baseIndex; double distance[ImageDimension2]; - long tIndex; for( dim = 0; dim < ImageDimension2; dim++ ) { - // The following "if" block is equivalent to the following line without - // having to call floor. - // baseIndex[dim] = (long) vcl_floor(index[dim] ); - if (cindex[dim] >= 0.0) - { - baseIndex[dim] = (long) cindex[dim]; - } - else - { - tIndex = (long) cindex[dim]; - if (double(tIndex) != cindex[dim]) - { - tIndex--; - } - baseIndex[dim] = tIndex; - } - distance[dim] = cindex[dim] - double( baseIndex[dim] ); + baseIndex[dim] = Math::Floor<signed long>( cindex[dim] ); + distance[dim] = cindex[dim] - static_cast< double >( baseIndex[dim] ); } // Interpolated value is the weighted sum of each of the surrounding diff --git a/Utilities/ITK/Code/Review/itkDiscreteGradientMagnitudeGaussianImageFunction.h b/Utilities/ITK/Code/Review/itkDiscreteGradientMagnitudeGaussianImageFunction.h index fcd86c37896c2b82257ba7f6a420a9cc034b0c9e..feeade24ccbcee39b1b4e4e32503a18030c43929 100644 --- a/Utilities/ITK/Code/Review/itkDiscreteGradientMagnitudeGaussianImageFunction.h +++ b/Utilities/ITK/Code/Review/itkDiscreteGradientMagnitudeGaussianImageFunction.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkDiscreteGradientMagnitudeGaussianImageFunction.h,v $ Language: C++ - Date: $Date: 2009-04-23 03:43:41 $ - Version: $Revision: 1.8 $ + Date: $Date: 2009-10-29 11:19:16 $ + Version: $Revision: 1.9 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -71,6 +71,7 @@ public: typedef typename Superclass::InputImageType InputImageType; typedef typename Superclass::InputPixelType InputPixelType; typedef typename Superclass::IndexType IndexType; + typedef typename Superclass::IndexValueType IndexValueType; typedef typename Superclass::ContinuousIndexType ContinuousIndexType; typedef typename Superclass::PointType PointType; diff --git a/Utilities/ITK/Code/Review/itkDiscreteGradientMagnitudeGaussianImageFunction.txx b/Utilities/ITK/Code/Review/itkDiscreteGradientMagnitudeGaussianImageFunction.txx index cfc75d4049a69fe25e33a8afd2cff1f2952adbc5..d2c7e38224943e64d44c0862016eff043e8518f1 100644 --- a/Utilities/ITK/Code/Review/itkDiscreteGradientMagnitudeGaussianImageFunction.txx +++ b/Utilities/ITK/Code/Review/itkDiscreteGradientMagnitudeGaussianImageFunction.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkDiscreteGradientMagnitudeGaussianImageFunction.txx,v $ Language: C++ - Date: $Date: 2008-12-06 13:28:10 $ - Version: $Revision: 1.6 $ + Date: $Date: 2009-10-29 11:19:16 $ + Version: $Revision: 1.7 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -261,29 +261,13 @@ DiscreteGradientMagnitudeGaussianImageFunction<TInputImage,TOutput> // Compute base index = closet index below point // Compute distance from point to base index - signed long baseIndex[ImageDimension2]; + IndexType baseIndex; double distance[ImageDimension2]; - long tIndex; for( dim = 0; dim < ImageDimension2; dim++ ) { - // The following "if" block is equivalent to the following line without - // having to call floor. - // baseIndex[dim] = (long) vcl_floor(index[dim] ); - if (cindex[dim] >= 0.0) - { - baseIndex[dim] = (long) cindex[dim]; - } - else - { - tIndex = (long) cindex[dim]; - if (double(tIndex) != cindex[dim]) - { - tIndex--; - } - baseIndex[dim] = tIndex; - } - distance[dim] = cindex[dim] - double( baseIndex[dim] ); + baseIndex[dim] = Math::Floor<IndexValueType>( cindex[dim] ); + distance[dim] = cindex[dim] - static_cast< double >( baseIndex[dim] ); } // Interpolated value is the weighted sum of each of the surrounding diff --git a/Utilities/ITK/Code/Review/itkDiscreteHessianGaussianImageFunction.h b/Utilities/ITK/Code/Review/itkDiscreteHessianGaussianImageFunction.h index f6d7ae8cc44d0b2474c136622dffb965febc85f8..8c78ab15eec78578d38275d58c7ce7c60a40c904 100644 --- a/Utilities/ITK/Code/Review/itkDiscreteHessianGaussianImageFunction.h +++ b/Utilities/ITK/Code/Review/itkDiscreteHessianGaussianImageFunction.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkDiscreteHessianGaussianImageFunction.h,v $ Language: C++ - Date: $Date: 2009-04-23 03:43:41 $ - Version: $Revision: 1.8 $ + Date: $Date: 2009-10-29 11:19:17 $ + Version: $Revision: 1.9 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -74,6 +74,7 @@ public: typedef typename Superclass::InputImageType InputImageType; typedef typename Superclass::InputPixelType InputPixelType; typedef typename Superclass::IndexType IndexType; + typedef typename Superclass::IndexValueType IndexValueType; typedef typename Superclass::ContinuousIndexType ContinuousIndexType; typedef typename Superclass::PointType PointType; diff --git a/Utilities/ITK/Code/Review/itkDiscreteHessianGaussianImageFunction.txx b/Utilities/ITK/Code/Review/itkDiscreteHessianGaussianImageFunction.txx index e5f1d6e58bc510628a10b9e1ea126df2234d0cb7..af636a4fccee85ad774c3e36e57a129032e86bf6 100644 --- a/Utilities/ITK/Code/Review/itkDiscreteHessianGaussianImageFunction.txx +++ b/Utilities/ITK/Code/Review/itkDiscreteHessianGaussianImageFunction.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkDiscreteHessianGaussianImageFunction.txx,v $ Language: C++ - Date: $Date: 2008-12-06 13:28:10 $ - Version: $Revision: 1.7 $ + Date: $Date: 2009-10-29 11:19:18 $ + Version: $Revision: 1.8 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -268,29 +268,13 @@ DiscreteHessianGaussianImageFunction<TInputImage,TOutput> // Compute base index = closet index below point // Compute distance from point to base index - signed long baseIndex[ImageDimension2]; + IndexType baseIndex; double distance[ImageDimension2]; - long tIndex; for( dim = 0; dim < ImageDimension2; dim++ ) { - // The following "if" block is equivalent to the following line without - // having to call floor. - // baseIndex[dim] = (long) vcl_floor(index[dim] ); - if (cindex[dim] >= 0.0) - { - baseIndex[dim] = (long) cindex[dim]; - } - else - { - tIndex = (long) cindex[dim]; - if (double(tIndex) != cindex[dim]) - { - tIndex--; - } - baseIndex[dim] = tIndex; - } - distance[dim] = cindex[dim] - double( baseIndex[dim] ); + baseIndex[dim] = Math::Floor<IndexValueType>( cindex[dim] ); + distance[dim] = cindex[dim] - static_cast< double >( baseIndex[dim] ); } // Interpolated value is the weighted sum of each of the surrounding diff --git a/Utilities/ITK/Code/Review/itkExponentialDeformationFieldImageFilter.h b/Utilities/ITK/Code/Review/itkExponentialDeformationFieldImageFilter.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Review/itkExponentialDeformationFieldImageFilter.txx b/Utilities/ITK/Code/Review/itkExponentialDeformationFieldImageFilter.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Review/itkFFTWComplexToComplexImageFilter.h b/Utilities/ITK/Code/Review/itkFFTWComplexToComplexImageFilter.h index d7de577fab57b4a04ae9ac8038fb9e4f62c261d3..3965b771704623d0785a8c3c6f0c2084ae16b5bd 100644 --- a/Utilities/ITK/Code/Review/itkFFTWComplexToComplexImageFilter.h +++ b/Utilities/ITK/Code/Review/itkFFTWComplexToComplexImageFilter.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkFFTWComplexToComplexImageFilter.h,v $ Language: C++ - Date: $Date: 2009-08-13 03:19:20 $ - Version: $Revision: 1.3 $ + Date: $Date: 2010-02-26 05:28:25 $ + Version: $Revision: 1.4 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -26,7 +26,7 @@ namespace itk { /** \class FFTWComplexToComplexImageFilter - * /brief Implements an API to enable the Fourier transform or the inverse + * \brief Implements an API to enable the Fourier transform or the inverse * Fourier transform of images with complex valued voxels to be computed using * either FFTW from MIT or the FFTW interface in Intel MKL. * diff --git a/Utilities/ITK/Code/Review/itkFlatStructuringElement.txx b/Utilities/ITK/Code/Review/itkFlatStructuringElement.txx index a55c72dcf421f4c7ca2c75c154d35e236b97fd78..81b34ac3afe310dbc040a984d6ed90c57509c89f 100644 --- a/Utilities/ITK/Code/Review/itkFlatStructuringElement.txx +++ b/Utilities/ITK/Code/Review/itkFlatStructuringElement.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkFlatStructuringElement.txx,v $ Language: C++ - Date: $Date: 2009-04-06 16:49:33 $ - Version: $Revision: 1.19 $ + Date: $Date: 2010-01-22 09:19:36 $ + Version: $Revision: 1.20 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -163,7 +163,7 @@ FlatStructuringElement<VDimension> FlatStructuringElement<VDimension> // set up vectors normal to the faces - only put in 3 points for // each face: // face 1 - LType PP; + LType PP(0.0); FacetType Fc; b /= 2.0; c /= 2.0; @@ -335,7 +335,7 @@ FlatStructuringElement<VDimension> FlatStructuringElement<VDimension> // set up vectors normal to the faces - only put in 3 points for // each face: // face 1 - LType PP; + LType PP(0.0); FacetType Fc; PP[0]=0;PP[1]=b;PP[2]=-a; @@ -535,7 +535,7 @@ FlatStructuringElement<VDimension> FlatStructuringElement<VDimension> FacetArray.resize( facets ); // original corners of octahedron - LType P0, P1, P2, P3, P4, P5; + LType P0(0.0), P1(0.0), P2(0.0), P3(0.0), P4(0.0), P5(0.0); P0[0]=0; P0[1]=0; P0[2]=1; P1[0]=0; P1[1]=0; P1[2]=-1; P2[0]=-1.0/sqrt2;P2[1]=-1/sqrt2;P2[2]=0; diff --git a/Utilities/ITK/Code/Review/itkGaborImageSource.h b/Utilities/ITK/Code/Review/itkGaborImageSource.h new file mode 100644 index 0000000000000000000000000000000000000000..fb6cd97d8e9ec0724250139baf85cd3b6fa0a95c --- /dev/null +++ b/Utilities/ITK/Code/Review/itkGaborImageSource.h @@ -0,0 +1,145 @@ +/*========================================================================= + + Program: Insight Segmentation & Registration Toolkit + Module: $RCSfile: itkGaborImageSource.h,v $ + Language: C++ + Date: $Date: 2009-10-03 16:15:16 $ + Version: $Revision: 1.1 $ + + Copyright (c) Insight Software Consortium. All rights reserved. + See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef __itkGaborImageSource_h +#define __itkGaborImageSource_h + +#include "itkImageSource.h" +#include "itkFixedArray.h" + +namespace itk +{ + +/** \class GaborImageSource + * \brief Generate an n-dimensional image of a Gabor filter. + * + * GaborImageSource generates an image of either the real + * (i.e. symmetric) or complex (i.e. antisymmetric) part + * of the Gabor filter with the orientation directed along + * the x-axis. The GaborKernelFunction is used to evaluate + * the contribution along the x-axis whereas a non-normalized + * 1-D Gaussian envelope provides the contribution in each of + * the remaining N dimensions. Orientation can be manipulated + * via the Transform classes of the toolkit. + * + * The output image may be of any dimension. + * + * This implementation was contributed as a paper to the Insight Journal + * http://hdl.handle.net/1926/500 + * + * \ingroup DataSources + */ +template <typename TOutputImage> +class ITK_EXPORT GaborImageSource : public ImageSource<TOutputImage> +{ +public: + + /** Standard class typedefs. */ + typedef GaborImageSource Self; + typedef ImageSource<TOutputImage> Superclass; + typedef SmartPointer<Self> Pointer; + typedef SmartPointer<const Self> ConstPointer; + + /** Output image typedefs */ + typedef TOutputImage OutputImageType; + typedef typename OutputImageType::PixelType PixelType; + typedef typename OutputImageType::RegionType RegionType; + typedef typename OutputImageType::SpacingType SpacingType; + typedef typename OutputImageType::PointType PointType; + typedef typename OutputImageType::DirectionType DirectionType; + + typedef typename RegionType::SizeType SizeType; + + /** Run-time type information (and related methods). */ + itkTypeMacro( GaborImageSource, ImageSource ); + + /** Method for creation through the object factory. */ + itkNewMacro( Self ); + + /** Dimensionality of the output image */ + itkStaticConstMacro( ImageDimension, unsigned int, + OutputImageType::ImageDimension ); + + /** Type used to store gabor parameters. */ + typedef FixedArray<double, + itkGetStaticConstMacro( ImageDimension )> ArrayType; + + itkSetMacro( Size, SizeType ); + itkGetConstReferenceMacro( Size, SizeType ); + + itkSetMacro( Spacing, SpacingType ); + itkGetConstReferenceMacro( Spacing, SpacingType ); + + itkSetMacro( Origin, PointType ); + itkGetConstReferenceMacro( Origin, PointType ); + + itkSetMacro( Direction, DirectionType ); + itkGetConstReferenceMacro( Direction, DirectionType ); + + itkSetMacro( Sigma, ArrayType ); + itkGetConstReferenceMacro( Sigma, ArrayType ); + + itkSetMacro( Mean, ArrayType ); + itkGetConstReferenceMacro( Mean, ArrayType ); + + itkSetMacro( Frequency, double ); + itkGetConstReferenceMacro( Frequency, double ); + + itkSetMacro( CalculateImaginaryPart, bool ); + itkGetConstReferenceMacro( CalculateImaginaryPart, bool ); + itkBooleanMacro( CalculateImaginaryPart ); + +protected: + GaborImageSource(); + ~GaborImageSource(); + void PrintSelf(std::ostream& os, Indent indent) const; + void GenerateData(); + virtual void GenerateOutputInformation(); + +private: + GaborImageSource( const GaborImageSource& ); //purposely not implemented + void operator=( const GaborImageSource& ); //purposely not implemented + + SizeType m_Size; //size of the output image + SpacingType m_Spacing; //spacing + PointType m_Origin; //origin + DirectionType m_Direction; //direciton + + /** Parameters for the Gabor. */ + + /** Evaluate using the complex part */ + bool m_CalculateImaginaryPart; + + /** Modulation frequency of the sine or cosine component */ + double m_Frequency; + + /** Evaluate using a stretched gabor filter (ensure zero dc response) */ + double m_PhaseOffset; + + /** The standard deviation in each direction. */ + ArrayType m_Sigma; + + /** The mean in each direction. */ + ArrayType m_Mean; +}; + +} // end namespace itk + +#ifndef ITK_MANUAL_INSTANTIATION +#include "itkGaborImageSource.txx" +#endif + +#endif diff --git a/Utilities/ITK/Code/Review/itkGaborImageSource.txx b/Utilities/ITK/Code/Review/itkGaborImageSource.txx new file mode 100644 index 0000000000000000000000000000000000000000..06bcd1e83e75959b07b1303e7a99dee518999afe --- /dev/null +++ b/Utilities/ITK/Code/Review/itkGaborImageSource.txx @@ -0,0 +1,158 @@ +/*========================================================================= + + Program: Insight Segmentation & Registration Toolkit + Module: $RCSfile: itkGaborImageSource.txx,v $ + Language: C++ + Date: $Date: 2009-10-03 16:15:16 $ + Version: $Revision: 1.1 $ + + Copyright (c) Insight Software Consortium. All rights reserved. + See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef __itkGaborImageSource_txx +#define __itkGaborImageSource_txx + +#include "itkGaborKernelFunction.h" +#include "itkGaborImageSource.h" +#include "itkImageRegionIteratorWithIndex.h" +#include "itkProgressReporter.h" +#include "itkObjectFactory.h" + +namespace itk +{ + +template <class TOutputImage> +GaborImageSource<TOutputImage> +::GaborImageSource() +{ + //Initial image is 64 wide in each direction. + for (unsigned int i = 0; i < ImageDimension; i++) + { + this->m_Size[i] = 64; + this->m_Spacing[i] = 1.0; + this->m_Origin[i] = 0.0; + } + + this->m_Direction.SetIdentity(); + + // Gabor parameters, defined so that the gaussian + // is centered in the default image + this->m_Mean.Fill( 32.0 ); + this->m_Sigma.Fill( 16.0 ); + + this->m_CalculateImaginaryPart = false; + this->m_Frequency = 0.4; + this->m_PhaseOffset = 0.0; + +} + +template <class TOutputImage> +GaborImageSource<TOutputImage> +::~GaborImageSource() +{ +} + +//---------------------------------------------------------------------------- +template <class TOutputImage> +void +GaborImageSource<TOutputImage> +::GenerateOutputInformation() +{ + OutputImageType *output; + typename OutputImageType::IndexType index = {{0}}; + + output = this->GetOutput( 0 ); + + typename OutputImageType::RegionType largestPossibleRegion; + largestPossibleRegion.SetSize( this->m_Size ); + largestPossibleRegion.SetIndex( index ); + output->SetLargestPossibleRegion( largestPossibleRegion ); + + output->SetSpacing( this->m_Spacing ); + output->SetOrigin( this->m_Origin ); + output->SetDirection( this->m_Direction ); +} + +template <class TOutputImage> +void +GaborImageSource<TOutputImage> +::GenerateData() +{ + typename OutputImageType::Pointer outputPtr = this->GetOutput(); + + // allocate the output buffer + outputPtr->SetBufferedRegion( outputPtr->GetRequestedRegion() ); + outputPtr->Allocate(); + + // Create and initialize a new gaussian function + typedef GaborKernelFunction KernelFunctionType; + typename KernelFunctionType::Pointer gabor = KernelFunctionType::New(); + + gabor->SetSigma( this->m_Sigma[0] ); + gabor->SetFrequency( this->m_Frequency ); + gabor->SetPhaseOffset( this->m_PhaseOffset ); + gabor->SetCalculateImaginaryPart( this->m_CalculateImaginaryPart ); + + // Create an iterator that will walk the output region + ImageRegionIteratorWithIndex<OutputImageType> + outIt( outputPtr, outputPtr->GetRequestedRegion() ); + + // The position at which the function is evaluated + Point<double, ImageDimension> evalPoint; + + ProgressReporter progress( this, 0, + outputPtr->GetRequestedRegion().GetNumberOfPixels() ); + + // Walk the output image, evaluating the spatial function at each pixel + for ( outIt.GoToBegin(); !outIt.IsAtEnd(); ++outIt ) + { + typename OutputImageType::IndexType index = outIt.GetIndex(); + outputPtr->TransformIndexToPhysicalPoint( index, evalPoint ); + double sum = 0.0; + for ( unsigned int i = 1; i < ImageDimension; i++ ) + { + sum += vnl_math_sqr( ( evalPoint[i] - this->m_Mean[i] ) / this->m_Sigma[i] ); + } + double value = vcl_exp( -0.5 * sum ) * gabor->Evaluate( evalPoint[0] - this->m_Mean[0] ); + + // Set the pixel value to the function value + outIt.Set( static_cast<PixelType>( value ) ); + progress.CompletedPixel(); + } +} + +template <class TOutputImage> +void +GaborImageSource<TOutputImage> +::PrintSelf( std::ostream& os, Indent indent ) const +{ + Superclass::PrintSelf( os,indent ); + + os << indent << "Image parameters: " << std::endl; + os << indent << " Size: " << this->GetSize() << std::endl; + os << indent << " Origin: " << this->GetOrigin() << std::endl; + os << indent << " Spacing: " << this->GetSpacing() << std::endl; + os << indent << " Direction: " << this->GetDirection() << std::endl; + + os << indent << "Gabor filter parameters: " << std::endl; + os << indent << " Sigma: " << this->GetSigma() << std::endl; + os << indent << " Mean: " << this->GetMean() << std::endl; + os << indent << " Frequency: " << this->GetFrequency() << std::endl; + if ( this->GetCalculateImaginaryPart() ) + { + os << indent << " Calculate complex part: true " << std::endl; + } + else + { + os << indent << " Calculate complex part: false " << std::endl; + } +} + +} // end namespace itk + +#endif diff --git a/Utilities/ITK/Code/Review/itkGaborKernelFunction.cxx b/Utilities/ITK/Code/Review/itkGaborKernelFunction.cxx new file mode 100644 index 0000000000000000000000000000000000000000..ab1079e2cd12059c6c42f06aa4535dbabe245ee4 --- /dev/null +++ b/Utilities/ITK/Code/Review/itkGaborKernelFunction.cxx @@ -0,0 +1,45 @@ +/*========================================================================= + + Program: Insight Segmentation & Registration Toolkit + Module: $RCSfile: itkGaborKernelFunction.cxx,v $ + Language: C++ + Date: $Date: 2009-10-03 16:15:16 $ + Version: $Revision: 1.1 $ + + Copyright (c) Insight Software Consortium. All rights reserved. + See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#include "itkGaborKernelFunction.h" + +namespace itk +{ + +GaborKernelFunction::GaborKernelFunction() +{ + this->m_CalculateImaginaryPart = false; + this->m_Sigma = 1.0; + this->m_Frequency = 0.4; + this->m_PhaseOffset = 0.0; +} + +GaborKernelFunction::~GaborKernelFunction() +{ +} + +void GaborKernelFunction::PrintSelf(std::ostream& os, Indent indent) const +{ + Superclass::PrintSelf(os, indent); + + os << indent << "Sigma: " << this->GetSigma() << std::endl; + os << indent << "Frequency: " << this->GetFrequency() << std::endl; + os << indent << "PhaseOffset: " << this->GetPhaseOffset() << std::endl; + os << indent << "CalculateImaginaryPart: " << this->GetCalculateImaginaryPart() << std::endl; + +} + +} // namespace itk diff --git a/Utilities/ITK/Code/Review/itkGaborKernelFunction.h b/Utilities/ITK/Code/Review/itkGaborKernelFunction.h new file mode 100644 index 0000000000000000000000000000000000000000..49213c1cafa601a4dd61125b74d353373759d57b --- /dev/null +++ b/Utilities/ITK/Code/Review/itkGaborKernelFunction.h @@ -0,0 +1,117 @@ +/*========================================================================= + + Program: Insight Segmentation & Registration Toolkit + Module: $RCSfile: itkGaborKernelFunction.h,v $ + Language: C++ + Date: $Date: 2009-10-05 12:53:50 $ + Version: $Revision: 1.2 $ + + Copyright (c) Insight Software Consortium. All rights reserved. + See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef __itkGaborKernelFunction_h +#define __itkGaborKernelFunction_h + +#include "itkKernelFunction.h" +#include "vnl/vnl_math.h" +#include <math.h> + +namespace itk +{ + +/** \class GaborKernelFunction + * \brief Gabor kernel used for various computer vision tasks. + * + * This class encapsulates a complex Gabor kernel used for + * various computer vision tasks such as texture segmentation, + * motion analysis, and object recognition. It is essentially + * a complex sinusoid enveloped within a gaussian. + * See the discussion in + * + * Andreas Klein, Forester Lee, and Amir A. Amini, "Quantitative + * Coronary Angiography with Deformable Spline Models", IEEE-TMI + * 16(5):468-482, October 1997. + * + * for a basic discussion including additional references. + * + * This implementation was contributed as a paper to the Insight Journal + * http://hdl.handle.net/1926/500 + * + * \sa KernelFunction + * + * \ingroup Functions + */ +class ITK_EXPORT GaborKernelFunction : public KernelFunction +{ +public: + /** Standard class typedefs. */ + typedef GaborKernelFunction Self; + typedef KernelFunction Superclass; + typedef SmartPointer<Self> Pointer; + + /** Method for creation through the object factory. */ + itkNewMacro( Self ); + + /** Run-time type information (and related methods). */ + itkTypeMacro( GaborKernelFunction, KernelFunction ); + + /** Evaluate the function. */ + inline double Evaluate ( const double &u ) const + { + double parameter = vnl_math_sqr( u / this->m_Sigma ); + double envelope = vcl_exp( -0.5 * parameter ); + double phase = 2.0 * vnl_math::pi * this->m_Frequency * u + + this->m_PhaseOffset; + if ( this->m_CalculateImaginaryPart ) + { + return envelope * vcl_sin( phase ); + } + else + { + return envelope * vcl_cos( phase ); + } + } + + itkSetMacro( Sigma, double ); + itkGetConstMacro( Sigma, double ); + + itkSetMacro( Frequency, double ); + itkGetConstMacro( Frequency, double ); + + itkSetMacro( PhaseOffset, double ); + itkGetConstMacro( PhaseOffset, double ); + + itkSetMacro( CalculateImaginaryPart, bool ); + itkGetConstMacro( CalculateImaginaryPart, bool ); + itkBooleanMacro( CalculateImaginaryPart ); + +protected: + GaborKernelFunction(); + ~GaborKernelFunction(); + void PrintSelf( std::ostream& os, Indent indent ) const; + +private: + GaborKernelFunction( const Self& ); //purposely not implemented + void operator=( const Self& ); //purposely not implemented + + /** Standard deviation of the Gaussian envelope */ + double m_Sigma; + + /** Modulation frequency of the sine or cosine component */ + double m_Frequency; + + /** Phase offset of the sine or cosine component */ + double m_PhaseOffset; + + /** Evaluate using the complex part */ + bool m_CalculateImaginaryPart; +}; + +} // end namespace itk + +#endif diff --git a/Utilities/ITK/Code/Review/itkGridForwardWarpImageFilter.txx b/Utilities/ITK/Code/Review/itkGridForwardWarpImageFilter.txx index 119668beeb95b96350e1833fed0435f4d3920132..e40c61f74ecd454a28f5f5d2d135b98de5a1dbb9 100644 --- a/Utilities/ITK/Code/Review/itkGridForwardWarpImageFilter.txx +++ b/Utilities/ITK/Code/Review/itkGridForwardWarpImageFilter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkGridForwardWarpImageFilter.txx,v $ Language: C++ - Date: $Date: 2009-06-16 07:58:47 $ - Version: $Revision: 1.5 $ + Date: $Date: 2009-10-27 18:12:48 $ + Version: $Revision: 1.7 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -97,6 +97,8 @@ GridForwardWarpImageFilter<TDeformationField,TOutputImage> // Bresenham line iterator typedef LineIterator<OutputImageType> LineIteratorType; + typedef typename IndexType::IndexValueType IndexValueType; + IndexType index, refIndex, targetIndex; ContinuousIndex<float, ImageDimension> contindex; DisplacementType displacement; @@ -129,7 +131,7 @@ GridForwardWarpImageFilter<TDeformationField,TOutputImage> inside = false; break; } - refIndex[j] = Math::Round(contindex[j]); + refIndex[j] = Math::Round<IndexValueType>(contindex[j]); } if( inside ) @@ -156,7 +158,7 @@ GridForwardWarpImageFilter<TDeformationField,TOutputImage> targetIn = false; break; } - targetIndex[j] = Math::Round(contindex[j]); + targetIndex[j] = Math::Round<IndexValueType>(contindex[j]); } if( targetIn ) diff --git a/Utilities/ITK/Code/Review/itkGridImageSource.txx b/Utilities/ITK/Code/Review/itkGridImageSource.txx index 1b1615b62c5906052f2a9daa4522b599a5941b23..bfdca19bdcbd5290e5bfdb312e5176c22aad5ccf 100644 --- a/Utilities/ITK/Code/Review/itkGridImageSource.txx +++ b/Utilities/ITK/Code/Review/itkGridImageSource.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkGridImageSource.txx,v $ Language: C++ - Date: $Date: 2009-05-15 13:03:47 $ - Version: $Revision: 1.2 $ + Date: $Date: 2009-10-29 15:03:32 $ + Version: $Revision: 1.3 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -70,8 +70,8 @@ GridImageSource<TOutputImage> It.SetDirection( i ); /** Add two extra functions in the front and one in the back to ensure coverage */ - unsigned int numberOfGaussians = static_cast<unsigned int>( - vcl_ceil( this->m_Size[i]*this->m_Spacing[i]/this->m_GridSpacing[i] ) + 4 ); + unsigned int numberOfGaussians = Math::Ceil<unsigned int>( + this->m_Size[i]*this->m_Spacing[i]/this->m_GridSpacing[i] ) + 4u; for ( It.GoToBegin(); !It.IsAtEndOfLine(); ++It ) { typename ImageType::IndexType index = It.GetIndex(); diff --git a/Utilities/ITK/Code/Review/itkHessianToObjectnessMeasureImageFilter.h b/Utilities/ITK/Code/Review/itkHessianToObjectnessMeasureImageFilter.h index 22a45117d2ec15223fc394d2ff4bde52752995a0..b86183c932aa50d40308de8c0abf32828fd22389 100644 --- a/Utilities/ITK/Code/Review/itkHessianToObjectnessMeasureImageFilter.h +++ b/Utilities/ITK/Code/Review/itkHessianToObjectnessMeasureImageFilter.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkHessianToObjectnessMeasureImageFilter.h,v $ Language: C++ - Date: $Date: 2009-07-01 12:43:38 $ - Version: $Revision: 1.6 $ + Date: $Date: 2010-01-31 12:39:34 $ + Version: $Revision: 1.8 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -32,7 +32,7 @@ namespace itk * images, with M<N. * The filter takes an image of a Hessian pixels ( SymmetricSecondRankTensor pixels * pixels ) and produces an enhanced image. The Hessian input image can be produced - * using itkHessianSmoothedRecursiveGaussianImageFilter. + * using itk::HessianRecursiveGaussianImageFilter. * * * \par References @@ -85,6 +85,9 @@ public: /** Method for creation through the object factory. */ itkNewMacro(Self); + /** Runtime information support. */ + itkTypeMacro( HessianToObjectnessMeasureImageFilter, ImageToImageFilter ); + /** Set/Get Alpha, the weight corresponding to R_A * (the ratio of the smallest eigenvalue that has to be large to the larger ones). * Smaller values lead to increased sensitivity to the object dimensionality. */ diff --git a/Utilities/ITK/Code/Review/itkInPlaceLabelMapFilter.h b/Utilities/ITK/Code/Review/itkInPlaceLabelMapFilter.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Review/itkInPlaceLabelMapFilter.txx b/Utilities/ITK/Code/Review/itkInPlaceLabelMapFilter.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Review/itkKernelImageFilter.txx b/Utilities/ITK/Code/Review/itkKernelImageFilter.txx index 319fffe4d046bfbefb0fbe48a0db681cd725fd4a..a4ab759811b4babab66f44a7a5efb279c0dc37a5 100644 --- a/Utilities/ITK/Code/Review/itkKernelImageFilter.txx +++ b/Utilities/ITK/Code/Review/itkKernelImageFilter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkKernelImageFilter.txx,v $ Language: C++ - Date: $Date: 2008-08-12 12:55:28 $ - Version: $Revision: 1.3 $ + Date: $Date: 2009-09-24 15:52:06 $ + Version: $Revision: 1.4 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -28,7 +28,7 @@ template <class TInputImage, class TOutputImage, class TKernel> KernelImageFilter<TInputImage, TOutputImage, TKernel> ::KernelImageFilter() { - this->SetRadius( 1 ); + this->SetRadius( 1UL ); } diff --git a/Utilities/ITK/Code/Review/itkLabelGeometryImageFilter.h b/Utilities/ITK/Code/Review/itkLabelGeometryImageFilter.h new file mode 100644 index 0000000000000000000000000000000000000000..ca23297ea91d6b0981438aceb9711b42fe9a21f3 --- /dev/null +++ b/Utilities/ITK/Code/Review/itkLabelGeometryImageFilter.h @@ -0,0 +1,500 @@ +/*========================================================================= + + Program: Insight Segmentation & Registration Toolkit + Module: $RCSfile: itkLabelGeometryImageFilter.h,v $ + Language: C++ + Date: $Date: 2010-01-24 14:09:29 $ + Version: $Revision: 1.3 $ + + Copyright (c) Insight Software Consortium. All rights reserved. + See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef __itkLabelGeometryImageFilter_h +#define __itkLabelGeometryImageFilter_h + +#include "itkImageToImageFilter.h" +#include "itkNumericTraits.h" +#include "itkArray.h" +#include "itkSimpleDataObjectDecorator.h" +#include "itk_hash_map.h" +#include "itkFastMutexLock.h" +#include <vector> +#include <vnl/algo/vnl_symmetric_eigensystem.h> +#include <vnl/vnl_det.h> +#include <vnl/vnl_math.h> +#include <vcl_cmath.h> + + +namespace itk { + +/** \class LabelGeometryImageFilter + * \brief Given a label map and an optional intensity image, compute + * geometric features. + * + * This filter enables the measurement of geometric features of all objects in + * a labeled ND volume. This labeled volume can represent, for instance, a + * medical image segmented into different anatomical structures or a microscope + * image segmented into individual cells. This filter is closely related to the + * itkLabelStatisticsImageFilter, which measures statistics of image regions + * defined by a labeled mask such as min, max, and mean intensity, intensity + * standard deviation, and bounding boxes. This filter, however, measures the + * geometry of the labeled regions themselves. + * + * It calculates features similar to the regionprops command of Matlab. The + * set of measurements that it enables include: volume, centroid, eigenvalues, + * eigenvectors, axes lenghts, eccentricity, elongation, orientation, bounding + * box, oriented bounding box, and rotation matrix. These features are based + * solely on the labeled mask itself. It also calculates integrated intensity + * and weighted centroid, which are measured on an intensity image under the + * labeled mask. These features represent the set of currently calculated + * features, but the framework of the filter is designed so that it can be + * easily expanded to measure a wide variety of other features. + * + * \authors Dirk Padfield and James Miller. + * + * This work is part of the National Alliance for Medical Image + * Computing (NAMIC), funded by the National Institutes of Health + * through the NIH Roadmap for Medical Research, Grant U54 EB005149. + * Information on the National Centers for Biomedical Computing + * can be obtained from http://nihroadmap.nih.gov/bioinformatics. + * + * This filter was contributed in the Insight Journal paper: + * "A Label Geometry Image Filter for Multiple Object Measurement" + * by Padfield D., Miller J + * http://www.insight-journal.org/browse/publication/301 + * http://hdl.handle.net/1926/1493 + * + */ +template<class TLabelImage, class TIntensityImage = TLabelImage> +class ITK_EXPORT LabelGeometryImageFilter : + public ImageToImageFilter<TLabelImage, TIntensityImage> +{ +public: + /** Standard Self typedef */ + typedef LabelGeometryImageFilter Self; + typedef ImageToImageFilter<TLabelImage,TIntensityImage> Superclass; + typedef SmartPointer<Self> Pointer; + typedef SmartPointer<const Self> ConstPointer; + + /** Method for creation through the object factory. */ + itkNewMacro(Self); + + /** Runtime information support. */ + itkTypeMacro(LabelGeometryImageFilter, ImageToImageFilter); + + /** Image related typedefs. */ + typedef TIntensityImage IntensityImageType; + typedef typename TIntensityImage::Pointer InputImagePointer; + typedef typename TIntensityImage::RegionType RegionType; + typedef typename TIntensityImage::SizeType SizeType; + typedef typename TIntensityImage::IndexType IndexType; + typedef typename TIntensityImage::PixelType PixelType; + + /** Label image related typedefs. */ + typedef TLabelImage LabelImageType; + typedef typename TLabelImage::Pointer LabelImagePointer; + typedef typename TLabelImage::RegionType LabelRegionType; + typedef typename TLabelImage::SizeType LabelSizeType; + typedef typename TLabelImage::IndexType LabelIndexType; + typedef typename TLabelImage::PixelType LabelPixelType; + typedef typename TLabelImage::PointType LabelPointType; + + /** Image related typedefs. */ + itkStaticConstMacro(ImageDimension, unsigned int, + TLabelImage::ImageDimension ); + + /** Type to use for computations. */ + typedef typename NumericTraits<PixelType>::RealType RealType; + + /** Smart Pointer type to a DataObject. */ + typedef typename DataObject::Pointer DataObjectPointer; + + /** Type of DataObjects used for scalar outputs */ + typedef SimpleDataObjectDecorator<RealType> RealObjectType; + + /** Bounding Box-related typedefs */ + typedef itk::FixedArray<typename LabelIndexType::IndexValueType,itkGetStaticConstMacro(ImageDimension)*2> BoundingBoxType; + typedef itk::FixedArray< float,itkGetStaticConstMacro(ImageDimension)*2> BoundingBoxFloatType; + + //typedef itk::FixedArray< LabelPointType,vcl_pow(2.0,itkGetStaticConstMacro(ImageDimension))> BoundingBoxVerticesType; + typedef std::vector< LabelPointType > BoundingBoxVerticesType; + + /** Axes Length-related typedefs */ + typedef itk::FixedArray<RealType,itkGetStaticConstMacro(ImageDimension)> AxesLengthType; + + /** Index array typedefs */ + typedef itk::FixedArray< typename LabelIndexType::IndexValueType, itkGetStaticConstMacro(ImageDimension) > IndexArrayType; + + /** vector of labels */ + typedef std::vector< LabelPixelType > LabelsType; + + /** vector of indices */ + typedef std::vector< LabelIndexType > LabelIndicesType; + + /** Vector type */ + typedef std::vector< double > VectorType; + + /** Matrix type */ + typedef vnl_matrix<double> MatrixType; + + /** \class LabelGeometry + * \brief Geometry stored per label + */ + class LabelGeometry + { + public: + // default constructor + LabelGeometry() + { + // initialized to the default values + this->m_Label = 0; + this->m_Sum = NumericTraits<RealType>::Zero; + + const unsigned int imageDimension = itkGetStaticConstMacro(ImageDimension); + + //m_BoundingBox.resize(imageDimension*2); + for (unsigned int i = 0; i < imageDimension * 2; i += 2) + { + m_BoundingBox[i] = NumericTraits<ITK_TYPENAME IndexType::IndexValueType>::max(); + m_BoundingBox[i+1] = NumericTraits<ITK_TYPENAME IndexType::IndexValueType>::NonpositiveMin(); + } + + m_BoundingBoxVolume = 0; + m_BoundingBoxSize.Fill(0); + m_PixelIndices.clear(); + m_Centroid.Fill( 0 ); + m_WeightedCentroid.Fill( 0 ); + m_ZeroOrderMoment = 0; + m_FirstOrderRawMoments.Fill( 0 ); + m_FirstOrderWeightedRawMoments.Fill( 0 ); + m_Eigenvalues.resize(ImageDimension); + m_Eigenvalues.clear(); + m_Eigenvectors.set_size(ImageDimension,ImageDimension); + m_Eigenvectors.fill(0); + m_AxesLength.Fill( 0 ); + m_Eccentricity = 1; + m_Elongation = 1; + m_Orientation = 0; + LabelPointType emptyPoint; + emptyPoint.Fill( 0 ); + unsigned int numberOfVertices = (unsigned int)vcl_pow( (double)2, (int)ImageDimension ); + m_OrientedBoundingBoxVertices.resize(numberOfVertices,emptyPoint); + m_OrientedBoundingBoxVolume = 0; + m_OrientedBoundingBoxSize.Fill(0); + m_OrientedLabelImage = LabelImageType::New(); + m_OrientedIntensityImage = IntensityImageType::New(); + m_OrientedBoundingBoxOrigin.Fill( 0 ); + m_RotationMatrix.set_size(ImageDimension,ImageDimension); + m_RotationMatrix.fill( 0.0 ); + + m_SecondOrderRawMoments.set_size(ImageDimension,ImageDimension); + m_SecondOrderCentralMoments.set_size(ImageDimension,ImageDimension); + for( unsigned int i = 0; i < ImageDimension; i++ ) + { + for( unsigned int j = 0; j < ImageDimension; j++ ) + { + m_SecondOrderRawMoments(i,j) = 0; + m_SecondOrderCentralMoments(i,j) = 0; + } + } + } + + LabelPixelType m_Label; + RealType m_Sum; + LabelPointType m_Centroid; + LabelPointType m_WeightedCentroid; + unsigned long m_ZeroOrderMoment; + IndexArrayType m_FirstOrderRawMoments; + IndexArrayType m_FirstOrderWeightedRawMoments; + unsigned long m_FirstOrderRawCrossMoment; + RealType m_FirstOrderCentralCrossMoment; + MatrixType m_SecondOrderRawMoments; + MatrixType m_SecondOrderCentralMoments; + VectorType m_Eigenvalues; + MatrixType m_Eigenvectors; + FixedArray<float,itkGetStaticConstMacro(ImageDimension)> m_AxesLength; + RealType m_Eccentricity; + RealType m_Elongation; + RealType m_Orientation; + BoundingBoxType m_BoundingBox; + LabelSizeType m_BoundingBoxSize; + RealType m_BoundingBoxVolume; + LabelIndicesType m_PixelIndices; + BoundingBoxVerticesType m_OrientedBoundingBoxVertices; + RealType m_OrientedBoundingBoxVolume; + LabelPointType m_OrientedBoundingBoxSize; + typename LabelImageType::Pointer m_OrientedLabelImage; + typename IntensityImageType::Pointer m_OrientedIntensityImage; + MatrixType m_RotationMatrix; + LabelPointType m_OrientedBoundingBoxOrigin; + }; + + /** Type of the map used to store data per label */ + // Map from the label to the class storing all of the geometry information. + typedef itk::hash_map<LabelPixelType, LabelGeometry> MapType; + typedef typename itk::hash_map<LabelPixelType, LabelGeometry>::iterator MapIterator; + typedef typename itk::hash_map<LabelPixelType, LabelGeometry>::const_iterator MapConstIterator; + + // Macros for enabling the calculation of additional features. + itkGetMacro(CalculatePixelIndices, bool); + itkBooleanMacro(CalculatePixelIndices); + void SetCalculatePixelIndices( const bool value ) + { + // CalculateOrientedBoundingBox, CalculateOrientedLabelImage, and + // CalculateOrientedIntensityImage all need CalculatePixelIndices to be turned + // on if they are turned on. So, CalculatePixelIndices cannot be + // turned off if any of these flags are turned on. + if( value == false ) + { + if( (this->m_CalculateOrientedBoundingBox == true) || + (this->m_CalculateOrientedLabelRegions == true) || + (this->m_CalculateOrientedIntensityRegions == true) ) + { + // We cannot change the value, so return. + return; + } + } + + if ( this->m_CalculatePixelIndices != value ) + { + this->m_CalculatePixelIndices = value; + this->Modified(); + } + } + + itkGetMacro(CalculateOrientedBoundingBox, bool); + itkBooleanMacro(CalculateOrientedBoundingBox); + void SetCalculateOrientedBoundingBox( const bool value ) + { + + if (this->m_CalculateOrientedBoundingBox != value) + { + this->m_CalculateOrientedBoundingBox = value; + this->Modified(); + } + + // CalculateOrientedBoundingBox needs + // CalculatePixelIndices to be turned on. + if( value == true ) + { + this->SetCalculatePixelIndices( true ); + } + + } + + itkGetMacro(CalculateOrientedLabelRegions, bool); + itkBooleanMacro(CalculateOrientedLabelRegions); + void SetCalculateOrientedLabelRegions( const bool value ) + { + if (this->m_CalculateOrientedLabelRegions != value) + { + this->m_CalculateOrientedLabelRegions = value; + this->Modified(); + + // CalculateOrientedLabelImage needs + // CalculateOrientedBoundingBox to be turned on. + if( value == true ) + { + SetCalculateOrientedBoundingBox( true ); + } + } + } + + itkGetMacro(CalculateOrientedIntensityRegions, bool); + itkBooleanMacro(CalculateOrientedIntensityRegions); + void SetCalculateOrientedIntensityRegions( const bool value ) + { + if (this->m_CalculateOrientedIntensityRegions != value) + { + this->m_CalculateOrientedIntensityRegions = value; + this->Modified(); + + // CalculateOrientedIntensityImage needs + // CalculateOrientedBoundingBox to be turned on. + if( value == true ) + { + this->SetCalculateOrientedBoundingBox( true ); + } + } + } + + /** Set the intensity image */ + void SetIntensityInput(const TIntensityImage *input ) + { + // Process object is not const-correct so the const casting is required. + this->SetNthInput(1, const_cast<TIntensityImage *>(input) ); + } + + /** Get the label image */ + const TIntensityImage * GetIntensityInput() const + { + return static_cast<TIntensityImage*>(const_cast<DataObject *>(this->ProcessObject::GetInput(1))); + } + + /** Does the specified label exist? Can only be called after + * a call to Update(). */ + bool HasLabel(LabelPixelType label) const + { + return m_LabelGeometryMapper.find(label) != m_LabelGeometryMapper.end(); + } + + /** Get the number of labels used */ + unsigned long GetNumberOfObjects() const + { + return m_LabelGeometryMapper.size(); + } + unsigned long GetNumberOfLabels() const + { + return this->GetNumberOfObjects(); + } + + /** Get the labels that are in the image. */ + std::vector< LabelPixelType > GetLabels() const + { + return m_AllLabels; + } + + /** Return the all pixel indices for a label. */ + LabelIndicesType GetPixelIndices( LabelPixelType label) const; + + /** Return the number of pixels for a label. This is the same as + * the volume and the zero order moment */ + unsigned long GetVolume(LabelPixelType label) const; + + /** Return the number of pixels for all labels. */ + //std::vector<unsigned long> GetAllCounts() const; + + /** Return the computed integrated pixel intensity for a label. */ + RealType GetIntegratedIntensity(LabelPixelType label) const; + + /** Return the unweighted centroid for a label. */ + LabelPointType GetCentroid( LabelPixelType label) const; + + /** Return the weighted centroid for a label. */ + LabelPointType GetWeightedCentroid( LabelPixelType label) const; + + /** Return the eigenvalues as a vector. */ + VectorType GetEigenvalues (LabelPixelType label) const; + + /** Return the eigenvectors as a matrix. */ + MatrixType GetEigenvectors (LabelPixelType label) const; + + /** Return the axes length for a label. */ + AxesLengthType GetAxesLength( LabelPixelType label) const; + + /** Return the minor axis length for a label. This is a convenience + * class that returns the shortest length from GetAxesLength. */ + RealType GetMinorAxisLength( LabelPixelType label) const; + + /** Return the major axis length for a label. This is a convenience + * class that returns the longest length from GetAxesLength. */ + RealType GetMajorAxisLength( LabelPixelType label) const; + + /** Return the eccentricity for a label. */ + RealType GetEccentricity( LabelPixelType label) const; + + /** Return the elongation for a label. This is defined as the + * length of the major axis divided by the length of the minor axis. */ + RealType GetElongation( LabelPixelType label) const; + + /** Return the orientation for a label defined in radians. */ + RealType GetOrientation( LabelPixelType label) const; + + /** Return the computed bounding box for a label. + * This is organized in min/max pairs as [min(X), max(X), min(Y), + * max(Y), min(Z), max(Z),...] */ + BoundingBoxType GetBoundingBox(LabelPixelType label) const; + + /** Return the volume of the bounding box. */ + RealType GetBoundingBoxVolume(LabelPixelType label) const; + + /** Return the size of the bounding box. */ + LabelSizeType GetBoundingBoxSize(LabelPixelType label) const; + + /** Return the oriented bounding box vertices. The order of the + * vertices corresponds with binary counting, where min is zero and + * max is one. For example, in 2D, binary counting will give + * [0,0],[0,1],[1,0],[1,1], which corresponds to + * [minX,minY],[minX,maxY],[maxX,minY],[maxX,maxY]. Each + * vertex is defined as an ND point. */ + BoundingBoxVerticesType GetOrientedBoundingBoxVertices(LabelPixelType label) const; + + /** Return the volume of the oriented bounding box. */ + RealType GetOrientedBoundingBoxVolume(LabelPixelType label) const; + + /** Return the size of the oriented bounding box. */ + LabelPointType GetOrientedBoundingBoxSize(LabelPixelType label) const; + + /** Return the origin of the oriented bounding box. */ + LabelPointType GetOrientedBoundingBoxOrigin(LabelPixelType label) const; + + /** Return the rotation matrix defined by the + * eigenvalues/eigenvectors. */ + MatrixType GetRotationMatrix(LabelPixelType label) const; + + /** Return the region defined by the bounding box. */ + RegionType GetRegion(LabelPixelType label) const; + + /** Return the label region defined by the oriented bounding box. */ + TLabelImage *GetOrientedLabelImage( LabelPixelType label) const; + + /** Return the intensity region defined by the oriented bounding + * box. */ + TIntensityImage * GetOrientedIntensityImage( LabelPixelType label) const; + + +#ifdef ITK_USE_CONCEPT_CHECKING + /** Begin concept checking */ + itkConceptMacro(InputHasNumericTraitsCheck, + (Concept::HasNumericTraits<PixelType>)); + /** End concept checking */ +#endif + +protected: + LabelGeometryImageFilter(); + ~LabelGeometryImageFilter(){}; + void PrintSelf(std::ostream& os, Indent indent) const; + + void GenerateData(); + +private: + LabelGeometryImageFilter(const Self&); //purposely not implemented + void operator=(const Self&); //purposely not implemented + + bool CalculateOrientedBoundingBoxVertices(vnl_symmetric_eigensystem<double> eig, LabelGeometry & m_LabelGeometry); + + bool m_CalculatePixelIndices; + bool m_CalculateOrientedBoundingBox; + bool m_CalculateOrientedLabelRegions; + bool m_CalculateOrientedIntensityRegions; + + MapType m_LabelGeometryMapper; + LabelGeometry m_LabelGeometry; + LabelsType m_AllLabels; + + SimpleFastMutexLock m_Mutex; + +}; // end of class + +template<class TLabelImage, class TIntensityImage> +typename LabelGeometryImageFilter<TLabelImage,TIntensityImage>::MatrixType CalculateRotationMatrix(vnl_symmetric_eigensystem<double> eig); + +template<class TLabelImage, class TIntensityImage, class TGenericImage> +bool CalculateOrientedImage( + LabelGeometryImageFilter<TLabelImage, TIntensityImage> *filter, + vnl_symmetric_eigensystem<double> eig, + typename LabelGeometryImageFilter<TLabelImage,TIntensityImage>::LabelGeometry & labelGeometry, + bool useLabelImage = true); + +} // end namespace itk + +#ifndef ITK_MANUAL_INSTANTIATION +#include "itkLabelGeometryImageFilter.txx" +#endif + +#endif diff --git a/Utilities/ITK/Code/Review/itkLabelGeometryImageFilter.txx b/Utilities/ITK/Code/Review/itkLabelGeometryImageFilter.txx new file mode 100644 index 0000000000000000000000000000000000000000..6b3b9d179996dad010e0683a1f9b197d0015bf8f --- /dev/null +++ b/Utilities/ITK/Code/Review/itkLabelGeometryImageFilter.txx @@ -0,0 +1,1107 @@ +/*========================================================================= + + Program: Insight Segmentation & Registration Toolkit + Module: $RCSfile: itkLabelGeometryImageFilter.txx,v $ + Language: C++ + Date: $Date: 2010-04-04 14:46:21 $ + Version: $Revision: 1.10 $ + + Copyright (c) Insight Software Consortium. All rights reserved. + See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +/*========================================================================= +* +* Authors: Dirk Padfield and James Miller. +* +* This work is part of the National Alliance for Medical Image +* Computing (NAMIC), funded by the National Institutes of Health +* through the NIH Roadmap for Medical Research, Grant U54 EB005149. +* Information on the National Centers for Biomedical Computing +* can be obtained from http://nihroadmap.nih.gov/bioinformatics. +* +*=========================================================================*/ + +#ifndef __itkLabelGeometryImageFilter_txx +#define __itkLabelGeometryImageFilter_txx + +#include "itkLabelGeometryImageFilter.h" + +#include "itkImageRegionIterator.h" +#include "itkImageRegionConstIterator.h" +#include "itkImageRegionConstIteratorWithIndex.h" +#include "itkNumericTraits.h" +#include "itkProgressReporter.h" +#include "itkCastImageFilter.h" + +#include "itkAffineTransform.h" +#include "itkResampleImageFilter.h" +#include "itkLinearInterpolateImageFunction.h" +#include "itkBSplineInterpolateImageFunction.h" +#include "itkNearestNeighborInterpolateImageFunction.h" + +namespace itk { + +#if defined(__GNUC__) && (__GNUC__ <= 2) //NOTE: This class needs a mutex for gnu 2.95 +/** Used for mutex locking */ +#define LOCK_HASHMAP this->m_Mutex.Lock() +#define UNLOCK_HASHMAP this->m_Mutex.Unlock() +#else +#define LOCK_HASHMAP +#define UNLOCK_HASHMAP +#endif + +// +// Helper functions +// +template<class TLabelImage, class TIntensityImage> +typename LabelGeometryImageFilter<TLabelImage,TIntensityImage>::MatrixType +CalculateRotationMatrix(vnl_symmetric_eigensystem<double> eig) +{ + typename LabelGeometryImageFilter<TLabelImage,TIntensityImage>::MatrixType + rotationMatrix(TLabelImage::ImageDimension,TLabelImage::ImageDimension,0); + for( unsigned int i = 0; i < TLabelImage::ImageDimension; i++ ) + { + rotationMatrix.set_column(i,eig.get_eigenvector(i) ); + } + // After vnl_symmetric_eigensystem, the columns of V are the eigenvectors, sorted by increasing eigenvalue, from most negative to most positive. + // First reorder the eigenvectors by decreasing eigenvalue. + rotationMatrix.fliplr(); + + // Next, check whether the determinant of the matrix is negative. + // If it is, then the vectors do not follow the right-hand rule. We + // can fix this by making one of them negative. Make the last + // eigenvector (with smallest eigenvalue) negative. + float matrixDet; + if( TLabelImage::ImageDimension == 2 ) + { + matrixDet = vnl_det(rotationMatrix[0], rotationMatrix[1]); + } + else if( TLabelImage::ImageDimension == 3 ) + { + matrixDet = vnl_det(rotationMatrix[0], rotationMatrix[1], rotationMatrix[2]); + } + else + { + matrixDet = 0.0f; + std::cerr << "ERROR: Determinant cannot be calculated for this dimension!" << std::endl; + } + + if( matrixDet < 0 ) + { + rotationMatrix.set_column(TLabelImage::ImageDimension-1,-rotationMatrix.get_column(TLabelImage::ImageDimension-1)); + } + + // Transpose the matrix to yield the rotation matrix. + rotationMatrix.inplace_transpose(); + + return rotationMatrix; +} + +template<class TLabelImage, class TIntensityImage, class TGenericImage> +bool +CalculateOrientedImage( + LabelGeometryImageFilter<TLabelImage,TIntensityImage> *filter, + vnl_symmetric_eigensystem<double> eig, + typename LabelGeometryImageFilter<TLabelImage,TIntensityImage>::LabelGeometry & labelGeometry, + bool useLabelImage) +{ + // CalculateOrientedBoundingBoxVertices needs to have already been + // called. This is taken care of by the flags. + + // Rotate the original object to align with the coordinate + // system defined by the eigenvectors. + // Since the resampler moves from the output image to the input + // image, we take the transpose of the rotation matrix. + typename LabelGeometryImageFilter<TLabelImage,TIntensityImage>::MatrixType vnl_RotationMatrix = CalculateRotationMatrix<TLabelImage,TIntensityImage>(eig); + vnl_RotationMatrix.inplace_transpose(); + + // Set up the transform. Here the center of rotation is the + // centroid of the object, the rotation matrix is specified by the + // eigenvectors, and there is no translation. + typedef itk::AffineTransform< double, TLabelImage::ImageDimension > TransformType; + typename TransformType::Pointer transform = TransformType::New(); + typename TransformType::MatrixType rotationMatrix( vnl_RotationMatrix ); + typename TransformType::CenterType center; + center = labelGeometry.m_Centroid; + typename TransformType::OutputVectorType translation; + translation.Fill( 0 ); + transform->SetCenter( center ); + transform->SetTranslation( translation ); + transform->SetMatrix( rotationMatrix ); + + typedef itk::ResampleImageFilter< TGenericImage, TGenericImage > ResampleFilterType; + typename ResampleFilterType::Pointer resampler = ResampleFilterType::New(); + + // The m_OrientedBoundingBoxSize is specified to float precision. + // Here we need an integer size large enough to contain all of the points, so we take the ceil of it. + // We also need to ensure that that bounding box is not outside of + // the image bounds. + typename ResampleFilterType::SizeType boundingBoxSize; + for( unsigned int i = 0; i < TLabelImage::ImageDimension; i++ ) + { + boundingBoxSize[i] = (typename ResampleFilterType::SizeType::SizeValueType)vcl_ceil(labelGeometry.m_OrientedBoundingBoxSize[i]); + } + + resampler->SetTransform( transform ); + resampler->SetSize( boundingBoxSize ); + resampler->SetOutputSpacing( filter->GetInput()->GetSpacing() ); + resampler->SetOutputOrigin( labelGeometry.m_OrientedBoundingBoxOrigin ); + + if( useLabelImage ) + { + // Set up the interpolator. + // Use a nearest neighbor interpolator since these are labeled images. + typedef itk::NearestNeighborInterpolateImageFunction< TGenericImage,double > InterpolatorType; + typename InterpolatorType::Pointer interpolator = InterpolatorType::New(); + resampler->SetInterpolator( interpolator ); + + // Cast the type to enable compilation. + typedef itk::CastImageFilter< TLabelImage, TGenericImage > CastType; + typename CastType::Pointer caster = CastType::New(); + caster->SetInput( filter->GetInput() ); + resampler->SetInput( caster->GetOutput() ); + resampler->Update(); + labelGeometry.m_OrientedLabelImage->Graft( resampler->GetOutput() ); + } + else + { + // If there is no intensity input defined, return; + if( !filter->GetIntensityInput() ) + { + return true; + } + + // Set up the interpolator. + // Use a linear interpolator since these are intensity images. + typedef itk::LinearInterpolateImageFunction< TGenericImage,double > InterpolatorType; + typename InterpolatorType::Pointer interpolator = InterpolatorType::New(); + resampler->SetInterpolator( interpolator ); + + // Cast the type to enable compilation. + typedef itk::CastImageFilter< TIntensityImage, TGenericImage > CastType; + typename CastType::Pointer caster = CastType::New(); + caster->SetInput( filter->GetIntensityInput() ); + resampler->SetInput( caster->GetOutput() ); + resampler->Update(); + labelGeometry.m_OrientedIntensityImage->Graft( resampler->GetOutput() ); + } + + return true; +} + +template<class TLabelImage, class TIntensityImage> +LabelGeometryImageFilter<TLabelImage, TIntensityImage> +::LabelGeometryImageFilter() +{ + this->SetNumberOfRequiredInputs(1); + m_CalculatePixelIndices = false; + m_CalculateOrientedBoundingBox = false; + m_CalculateOrientedLabelRegions = false; + m_CalculateOrientedIntensityRegions = false; +} + +template<class TLabelImage, class TIntensityImage> +void +LabelGeometryImageFilter<TLabelImage, TIntensityImage> +::GenerateData() +{ + LabelPixelType label; + + // Iterator over the label image. + ImageRegionConstIterator<TLabelImage> labelIt (this->GetInput(), + this->GetInput()->GetBufferedRegion()); + + typedef ImageRegionConstIteratorWithIndex<TLabelImage> ImageIteratorWithIndexType; + + // Iterator over the mapping from labels to geometry values. + MapIterator mapIt; + + // Do the work + while (!labelIt.IsAtEnd()) + { + label = labelIt.Get(); + + mapIt = m_LabelGeometryMapper.find( label ); + + // Is the label already in the mapper? + // If not, create a new geometry object. + if (mapIt == m_LabelGeometryMapper.end()) + { + typedef typename MapType::value_type MapValueType; + + LOCK_HASHMAP; + // map insert is defined as: pair<iterator, bool> insert(const value_type& x) + mapIt = m_LabelGeometryMapper.insert( MapValueType(label,LabelGeometry()) ).first; + + UNLOCK_HASHMAP; + } + + // Update the geometry values. + + // LABEL + (*mapIt).second.m_Label = label; + + // BOUNDING BOX + // The bounding box is defined in (min, max) pairs, such as (xmin,xmax,ymin,ymax,zmin,zmax). + typename ImageIteratorWithIndexType::IndexType index = labelIt.GetIndex(); + for ( unsigned int i = 0; i < ( 2 * ImageDimension); i += 2 ) + { + // Update min + if ((*mapIt).second.m_BoundingBox[i] > index[i/2]) + { + (*mapIt).second.m_BoundingBox[i] = index[i/2]; + } + // Update max + if ((*mapIt).second.m_BoundingBox[i + 1] < index[i/2]) + { + (*mapIt).second.m_BoundingBox[i + 1] = index[i/2]; + } + } + + // VOLUME + (*mapIt).second.m_ZeroOrderMoment++; + + for (unsigned int i = 0; i < ImageDimension; i++ ) + { + // FIRST ORDER RAW MOMENTS + (*mapIt).second.m_FirstOrderRawMoments[i] += index[i]; + } + + // SECOND ORDER RAW MOMENTS + // Even for ND, the second order moments can be found from just + // two nested loops since second order moments consider only + // interactions between pairs of indices. + for( unsigned int i = 0; i < ImageDimension; i++ ) + { + // It is only necessary to fill in half of the matrix since it is symmetric. + for( unsigned int j = 0; j < ImageDimension; j++ ) + { + (*mapIt).second.m_SecondOrderRawMoments(i,j) += index[i]*index[j]; + } + } + + if( m_CalculatePixelIndices == true ) + { + // Pixel location list + (*mapIt).second.m_PixelIndices.push_back( index ); + } + + ++labelIt; + } + + const TIntensityImage * intensityImage = this->GetIntensityInput(); + + // If an intensity image is defined, we can also calculate further + // features. + if( intensityImage ) + { + RealType value; + + // Iterator over the intensity image. + typedef ImageRegionConstIteratorWithIndex<TIntensityImage> IntensityImageIteratorType; + + IntensityImageIteratorType it( intensityImage, intensityImage->GetBufferedRegion() ); + + typename IntensityImageIteratorType::IndexType index; + + labelIt.GoToBegin(); + + while( !it.IsAtEnd() ) + { + label = labelIt.Get(); + mapIt = m_LabelGeometryMapper.find( label ); + + value = static_cast<RealType>(it.Get()); + index = it.GetIndex(); + + // INTEGRATED PIXEL VALUE + (*mapIt).second.m_Sum += value; + + for (unsigned int i = 0; i < ImageDimension; i++ ) + { + // FIRST ORDER WEIGHTED RAW MOMENTS + (*mapIt).second.m_FirstOrderWeightedRawMoments[i] += index[i] * (typename LabelIndexType::IndexValueType)value; + } + + ++it; + ++labelIt; + } + } + + + // If there is no intensity input defined, the oriented + // intensity regions cannot be calculated. + if( !intensityImage ) + { + if( m_CalculateOrientedIntensityRegions ) + { + std::cerr << "ERROR: An input intensity image must be used in order to calculate the oriented intensity image." << std::endl; + } + m_CalculateOrientedIntensityRegions = false; + } + + + // We need to add to the second order moment the second order + // moment of a pixel. This can be derived analytically. The first + // order moment of a pixel can be shown to be 0, and the first order + // cross moment can also be shown to be 0. The second order moment + // can be shown to be 1/12. + float pixelSecondOrderCentralMoment = 1.0f / 12.0f; + + // Now that the m_LabelGeometryMapper has been updated for all + // pixels in the image, we can calculate other geometrical values. + // Loop through all labels of the image. + for( mapIt = m_LabelGeometryMapper.begin(); mapIt != m_LabelGeometryMapper.end(); mapIt++ ) + { + + // Update the bounding box measurements. + (*mapIt).second.m_BoundingBoxVolume = 1; + for( unsigned int i = 0; i < ImageDimension; i++ ) + { + (*mapIt).second.m_BoundingBoxSize[i] = (*mapIt).second.m_BoundingBox[2*i+1] - (*mapIt).second.m_BoundingBox[2*i] + 1; + (*mapIt).second.m_BoundingBoxVolume = (*mapIt).second.m_BoundingBoxVolume * (*mapIt).second.m_BoundingBoxSize[i]; + } + + for( unsigned int i = 0; i < ImageDimension; i++ ) + { + // Normalize the centroid sum by the count to get the centroid. + (*mapIt).second.m_Centroid[i] = static_cast<typename LabelPointType::ValueType>((*mapIt).second.m_FirstOrderRawMoments[i]) / (*mapIt).second.m_ZeroOrderMoment; + + // This is the weighted sum. It only calculates correctly if + // the intensity image is defined. + if (!intensityImage) + { + (*mapIt).second.m_WeightedCentroid[i] = 0.0; + } + else + { + (*mapIt).second.m_WeightedCentroid[i] = static_cast<typename LabelPointType::ValueType>((*mapIt).second.m_FirstOrderWeightedRawMoments[i]) / (*mapIt).second.m_Sum; + } + } + + // Using the raw moments, we can calculate the central moments. + MatrixType normalizedSecondOrderCentralMoments(ImageDimension,ImageDimension,0); + for( unsigned int i = 0; i < ImageDimension; i++ ) + { + for( unsigned int j = 0; j < ImageDimension; j++ ) + { + normalizedSecondOrderCentralMoments(i,j) = ((*mapIt).second.m_SecondOrderRawMoments(i,j))/((*mapIt).second.m_ZeroOrderMoment) - (*mapIt).second.m_Centroid[i] * (*mapIt).second.m_Centroid[j]; + // We need to add to the second order moment the second order + // moment of a pixel. This can be derived analytically. + if( i == j ) + { + normalizedSecondOrderCentralMoments(i,j) += pixelSecondOrderCentralMoment; + } + } + } + + // Compute the eigenvalues/eigenvectors of the covariance matrix. + // The result is stored in increasing eigenvalues with + // corresponding eigenvectors. + vnl_symmetric_eigensystem<double> eig(normalizedSecondOrderCentralMoments); + + // Calculate the eigenvalues/eigenvectors + VectorType eigenvalues(ImageDimension,0); + MatrixType eigenvectors(ImageDimension,ImageDimension,0); + for( unsigned int i = 0; i < ImageDimension; i++ ) + { + eigenvectors.set_column(i,eig.get_eigenvector(i)); + eigenvalues[i] = eig.get_eigenvalue(i); + } + (*mapIt).second.m_Eigenvalues = eigenvalues; + (*mapIt).second.m_Eigenvectors = eigenvectors; + + + itk::FixedArray<float,ImageDimension> axesLength; + for( unsigned int i = 0; i < ImageDimension; i++ ) + { + axesLength[i] = 4 * vcl_sqrt( eigenvalues[i] ); + } + (*mapIt).second.m_AxesLength = axesLength; + + // The following three features are currently only defined in 2D. + (*mapIt).second.m_Eccentricity = vcl_sqrt((eigenvalues[1] - eigenvalues[0])/eigenvalues[1]); + (*mapIt).second.m_Elongation = axesLength[1]/axesLength[0]; + (*mapIt).second.m_Orientation = vcl_atan2( eig.get_eigenvector(1)[1], eig.get_eigenvector(1)[0]); + + if( m_CalculateOrientedBoundingBox == true ) + { + // Calculate the oriented bounding box using the eigenvectors. + CalculateOrientedBoundingBoxVertices(eig, (*mapIt).second ); + } + if( m_CalculateOrientedLabelRegions == true ) + { + CalculateOrientedImage<TLabelImage, TIntensityImage, LabelImageType>( + this, eig, (*mapIt).second, true ); + } + if( m_CalculateOrientedIntensityRegions == true ) + { + // If there is no intensity input defined, the oriented + // intensity regions cannot be calculated. + if( this->GetIntensityInput() ) + { + CalculateOrientedImage<TLabelImage, TIntensityImage, IntensityImageType>( + this, eig, (*mapIt).second, false ); + } + } + + m_AllLabels.push_back( (*mapIt).first ); + } +} + + +template<class TLabelImage, class TIntensityImage> +bool +LabelGeometryImageFilter<TLabelImage, TIntensityImage> +::CalculateOrientedBoundingBoxVertices(vnl_symmetric_eigensystem<double> eig, LabelGeometry & labelGeometry) +{ + // Calculate the oriented bounding box using the eigenvectors. + // For each label, the pixels are rotated to the new coordinate + // system defined by the eigenvectors. The bounding boxes are + // calculated in this space, and then they are rotated back to the + // original coordinate system to define the oriented bounding boxes. + // The reverse rotation is the transpose of the rotation matrix. + + // m_PixelIndices needs to have already been calculated. This is + // handled by the flags. + + MatrixType rotationMatrix = CalculateRotationMatrix<TLabelImage,TIntensityImage>(eig); + MatrixType inverseRotationMatrix = rotationMatrix.transpose(); + + labelGeometry.m_RotationMatrix = rotationMatrix; + + // Convert the pixel locations to a vnl_matrix. + // Subtract the centroid of the region so that the rotation will + // be about the center of the region. + MatrixType pixelLocations(ImageDimension, labelGeometry.m_PixelIndices.size(), 0); + for( unsigned int i = 0; i < labelGeometry.m_PixelIndices.size(); i++ ) + { + for( unsigned int j = 0; j < ImageDimension; j++ ) + { + pixelLocations(j,i) = labelGeometry.m_PixelIndices[i][j] - labelGeometry.m_Centroid[j]; + } + } + + // Rotate the points by the rotation matrix from the eigenvectors. + MatrixType transformedPixelLocations = rotationMatrix * pixelLocations; + + // Find the min and max of the point locations in this new + // coordinate system. These values will be float, so we use a + // BoundingBoxFloatType rather than BoundingBoxType. + // The bounding box order is [minX,maxX,minY,maxY,...] + BoundingBoxFloatType transformedBoundingBox; + // Initialize the bounding box values. + for (unsigned int i = 0; i < ImageDimension * 2; i += 2) + { + transformedBoundingBox[i] = NumericTraits<float>::max(); + transformedBoundingBox[i+1] = NumericTraits<float>::NonpositiveMin(); + } + + for( unsigned int column = 0; column < transformedPixelLocations.columns(); column++ ) + { + for (unsigned int i = 0; i < ( 2 * ImageDimension); i += 2 ) + { + // Update min + if (transformedBoundingBox[i] > transformedPixelLocations(i/2,column) ) + { + transformedBoundingBox[i] = transformedPixelLocations(i/2,column); + } + // Update max + if (transformedBoundingBox[i + 1] < transformedPixelLocations(i/2,column) ) + { + transformedBoundingBox[i + 1] = transformedPixelLocations(i/2,column); + } + } + } + + // Add 0.5 pixel buffers on each side of the bounding box to be sure to + // encompass the pixels and not cut through them. + for( unsigned int i = 0; i < (2 * ImageDimension); i += 2 ) + { + // If the index corresponds with a min, subtract 0.5. + transformedBoundingBox[i] -= 0.5; + // Otherwise, add 0.5. + transformedBoundingBox[i+1] += 0.5; + } + + // The bounding box volume can be calculated directly from the + // transformed bounding box. + // Since 0.5 was already added to the border of the bounding box, + // it is not necessary to add 1 to the range to get the correct range. + labelGeometry.m_OrientedBoundingBoxVolume = 1; + for( unsigned int i = 0; i < (2 * ImageDimension); i += 2 ) + { + labelGeometry.m_OrientedBoundingBoxSize[i/2] = transformedBoundingBox[i+1] - transformedBoundingBox[i]; + labelGeometry.m_OrientedBoundingBoxVolume *= transformedBoundingBox[i+1] - transformedBoundingBox[i]; + } + + // The bounding box cannot be transformed directly because an + // oriented bounding box cannot be specified simply by the min and + // max in each dimension. Instead, the oriented bounding box is + // specified by the points corresponding to the vertices of the + // oriented bounding box. We find these from the oriented + // bounding box and transform them back to the original coordinate frame. + // The order of the vertices corresponds with binary counting, + // where min is zero and max is one. For example, in 2D, binary + // counting will give [0,0],[0,1],[1,0],[1,1], which corresponds + // to [minX,minY],[minX,maxY],[maxX,minY],[maxX,maxY]. + // Loop through each dimension of the bounding box and find all of the vertices. + unsigned int numberOfVertices = + (unsigned int)vcl_pow( 2.0, (int)ImageDimension ); + MatrixType transformedBoundingBoxVertices(ImageDimension,numberOfVertices ,0); + int val; + LabelIndexType binaryIndex; + int arrayIndex; + for( unsigned int i = 0; i < numberOfVertices; i++ ) + { + val = i; + for( unsigned int j = 0; j < ImageDimension; j++ ) + { + // This is the binary index as described above. + binaryIndex[j] = val%2; + val = val/2; + // This is the index into the transformedBoundingBox array + // corresponding to the binaryIndex. + arrayIndex = binaryIndex[j] + 2*j; + transformedBoundingBoxVertices(j,i) = transformedBoundingBox[arrayIndex]; + } + } + + + // Transform the transformed bounding box vertices back to the + // original coordinate system. + MatrixType orientedBoundingBoxVertices = inverseRotationMatrix * transformedBoundingBoxVertices; + + // Add the centroid back to each of the vertices since it was + // subtracted when the points were rotated. + for( unsigned int i = 0; i < orientedBoundingBoxVertices.columns(); i++ ) + { + for( unsigned int j = 0; j < ImageDimension; j++ ) + { + orientedBoundingBoxVertices(j,i) += labelGeometry.m_Centroid[j]; + // Copy the oriented bounding box vertices back to a vector of + // points for the mapper. + labelGeometry.m_OrientedBoundingBoxVertices[i][j] = orientedBoundingBoxVertices(j,i); + } + } + + // Find the origin of the oriented bounding box. + for( unsigned int i = 0; i < ImageDimension; i++ ) + { + labelGeometry.m_OrientedBoundingBoxOrigin[i] = transformedBoundingBox[2*i] + labelGeometry.m_Centroid[i]; + } + + return true; +} + +template<class TLabelImage, class TIntensityImage> +typename LabelGeometryImageFilter<TLabelImage, TIntensityImage>::LabelIndicesType +LabelGeometryImageFilter<TLabelImage, TIntensityImage> +::GetPixelIndices(LabelPixelType label) const +{ + MapConstIterator mapIt; + mapIt = m_LabelGeometryMapper.find( label ); + if ( mapIt == m_LabelGeometryMapper.end() ) + { + // label does not exist, return a default value + LabelIndicesType emptyVector; + emptyVector.clear(); + return emptyVector; + } + else + { + return (*mapIt).second.m_PixelIndices; + } +} + + +template<class TLabelImage, class TIntensityImage> +unsigned long +LabelGeometryImageFilter<TLabelImage, TIntensityImage> +::GetVolume(LabelPixelType label) const +{ + MapConstIterator mapIt; + mapIt = m_LabelGeometryMapper.find( label ); + if ( mapIt == m_LabelGeometryMapper.end() ) + { + // label does not exist, return a default value + return 0; + } + else + { + return (*mapIt).second.m_ZeroOrderMoment; + } +} +template<class TLabelImage, class TIntensityImage> +typename LabelGeometryImageFilter<TLabelImage, TIntensityImage>::RealType +LabelGeometryImageFilter<TLabelImage, TIntensityImage> +::GetIntegratedIntensity(LabelPixelType label) const +{ + MapConstIterator mapIt; + mapIt = m_LabelGeometryMapper.find( label ); + if ( mapIt == m_LabelGeometryMapper.end() ) + { + // label does not exist, return a default value + return NumericTraits<RealType>::Zero; + } + else + { + return (*mapIt).second.m_Sum; + } +} + +template<class TLabelImage, class TIntensityImage> +typename LabelGeometryImageFilter<TLabelImage, TIntensityImage>::LabelPointType +LabelGeometryImageFilter<TLabelImage, TIntensityImage> +::GetCentroid(LabelPixelType label) const +{ + MapConstIterator mapIt; + mapIt = m_LabelGeometryMapper.find( label ); + if ( mapIt == m_LabelGeometryMapper.end() ) + { + // label does not exist, return a default value + LabelPointType emptyCentroid; + emptyCentroid.Fill( NumericTraits<ITK_TYPENAME LabelPointType::ValueType>::Zero); + return emptyCentroid; + } + else + { + return (*mapIt).second.m_Centroid; + } +} + +template<class TLabelImage, class TIntensityImage> +typename LabelGeometryImageFilter<TLabelImage, TIntensityImage>::LabelPointType +LabelGeometryImageFilter<TLabelImage, TIntensityImage> +::GetWeightedCentroid(LabelPixelType label) const +{ + MapConstIterator mapIt; + mapIt = m_LabelGeometryMapper.find( label ); + if ( mapIt == m_LabelGeometryMapper.end() ) + { + // label does not exist, return a default value + LabelPointType emptyCentroid; + emptyCentroid.Fill( NumericTraits<ITK_TYPENAME LabelPointType::ValueType>::Zero); + return emptyCentroid; + } + else + { + return (*mapIt).second.m_WeightedCentroid; + } +} + +template<class TLabelImage, class TIntensityImage> +typename LabelGeometryImageFilter<TLabelImage, TIntensityImage>::VectorType +LabelGeometryImageFilter<TLabelImage, TIntensityImage> +::GetEigenvalues(LabelPixelType label) const +{ + MapConstIterator mapIt; + mapIt = m_LabelGeometryMapper.find( label ); + if ( mapIt == m_LabelGeometryMapper.end() ) + { + // label does not exist, return a default value + VectorType emptyVector(ImageDimension,0); + return emptyVector; + } + else + { + return (*mapIt).second.m_Eigenvalues; + } +} + +template<class TLabelImage, class TIntensityImage> +typename LabelGeometryImageFilter<TLabelImage, TIntensityImage>::MatrixType +LabelGeometryImageFilter<TLabelImage, TIntensityImage> +::GetEigenvectors(LabelPixelType label) const +{ + MapConstIterator mapIt; + mapIt = m_LabelGeometryMapper.find( label ); + if ( mapIt == m_LabelGeometryMapper.end() ) + { + // label does not exist, return a default value + MatrixType emptyMatrix(ImageDimension,ImageDimension,0); + return emptyMatrix; + } + else + { + return (*mapIt).second.m_Eigenvectors; + } +} + + +template<class TLabelImage, class TIntensityImage> +typename LabelGeometryImageFilter<TLabelImage, TIntensityImage>::AxesLengthType +LabelGeometryImageFilter<TLabelImage, TIntensityImage> +::GetAxesLength(LabelPixelType label) const +{ + MapConstIterator mapIt; + mapIt = m_LabelGeometryMapper.find( label ); + if ( mapIt == m_LabelGeometryMapper.end() ) + { + // label does not exist, return a default value + LabelPointType emptyAxesLength; + emptyAxesLength.Fill( NumericTraits<ITK_TYPENAME AxesLengthType::ValueType>::Zero); + return emptyAxesLength; + } + else + { + return (*mapIt).second.m_AxesLength; + } +} + +template<class TLabelImage, class TIntensityImage> +typename LabelGeometryImageFilter<TLabelImage, TIntensityImage>::RealType +LabelGeometryImageFilter<TLabelImage, TIntensityImage> +::GetMinorAxisLength(LabelPixelType label) const +{ + AxesLengthType axisLength = GetAxesLength(label); + return axisLength[0]; +} + +template<class TLabelImage, class TIntensityImage> +typename LabelGeometryImageFilter<TLabelImage, TIntensityImage>::RealType +LabelGeometryImageFilter<TLabelImage, TIntensityImage> +::GetMajorAxisLength(LabelPixelType label) const +{ + AxesLengthType axisLength = GetAxesLength(label); + return axisLength[ImageDimension-1]; +} + +template<class TLabelImage, class TIntensityImage> +typename LabelGeometryImageFilter<TLabelImage, TIntensityImage>::RealType +LabelGeometryImageFilter<TLabelImage, TIntensityImage> +::GetEccentricity(LabelPixelType label) const +{ + MapConstIterator mapIt; + mapIt = m_LabelGeometryMapper.find( label ); + if ( mapIt == m_LabelGeometryMapper.end() ) + { + // label does not exist, return a default value + return NumericTraits<RealType>::Zero; + } + else + { + return (*mapIt).second.m_Eccentricity; + } +} +template<class TLabelImage, class TIntensityImage> +typename LabelGeometryImageFilter<TLabelImage, TIntensityImage>::RealType +LabelGeometryImageFilter<TLabelImage, TIntensityImage> +::GetElongation(LabelPixelType label) const +{ + MapConstIterator mapIt; + mapIt = m_LabelGeometryMapper.find( label ); + if ( mapIt == m_LabelGeometryMapper.end() ) + { + // label does not exist, return a default value + return NumericTraits<RealType>::Zero; + } + else + { + return (*mapIt).second.m_Elongation; + } +} + +template<class TLabelImage, class TIntensityImage> +typename LabelGeometryImageFilter<TLabelImage, TIntensityImage>::RealType +LabelGeometryImageFilter<TLabelImage, TIntensityImage> +::GetOrientation(LabelPixelType label) const +{ + MapConstIterator mapIt; + mapIt = m_LabelGeometryMapper.find( label ); + if ( mapIt == m_LabelGeometryMapper.end() ) + { + // label does not exist, return a default value + return NumericTraits<RealType>::Zero; + } + else + { + return (*mapIt).second.m_Orientation; + } +} + +template<class TLabelImage, class TIntensityImage> +typename LabelGeometryImageFilter<TLabelImage, TIntensityImage>::BoundingBoxType +LabelGeometryImageFilter<TLabelImage, TIntensityImage> +::GetBoundingBox(LabelPixelType label) const +{ + MapConstIterator mapIt; + mapIt = m_LabelGeometryMapper.find( label ); + if ( mapIt == m_LabelGeometryMapper.end() ) + { + BoundingBoxType emptyBox; + emptyBox.Fill( NumericTraits<ITK_TYPENAME BoundingBoxType::ValueType>::Zero); + // label does not exist, return a default value + return emptyBox; + } + else + { + return (*mapIt).second.m_BoundingBox; + } +} + +template<class TLabelImage, class TIntensityImage> +typename LabelGeometryImageFilter<TLabelImage, TIntensityImage>::RealType +LabelGeometryImageFilter<TLabelImage, TIntensityImage> +::GetBoundingBoxVolume(LabelPixelType label) const +{ + MapConstIterator mapIt; + mapIt = m_LabelGeometryMapper.find( label ); + if ( mapIt == m_LabelGeometryMapper.end() ) + { + // label does not exist, return a default value + return NumericTraits<RealType>::Zero; + } + else + { + return (*mapIt).second.m_BoundingBoxVolume; + } +} + +template<class TLabelImage, class TIntensityImage> +typename LabelGeometryImageFilter<TLabelImage, TIntensityImage>::LabelSizeType +LabelGeometryImageFilter<TLabelImage, TIntensityImage> +::GetBoundingBoxSize(LabelPixelType label) const +{ + MapConstIterator mapIt; + mapIt = m_LabelGeometryMapper.find( label ); + if ( mapIt == m_LabelGeometryMapper.end() ) + { + // label does not exist, return a default value + LabelSizeType emptySize; + emptySize.Fill( NumericTraits<ITK_TYPENAME LabelSizeType::SizeValueType>::Zero); + return emptySize; + } + else + { + return (*mapIt).second.m_BoundingBoxSize; + } +} + + +template<class TLabelImage, class TIntensityImage> +typename LabelGeometryImageFilter<TLabelImage, TIntensityImage>::BoundingBoxVerticesType +LabelGeometryImageFilter<TLabelImage, TIntensityImage> +::GetOrientedBoundingBoxVertices(LabelPixelType label) const +{ + unsigned int numberOfVertices = + (unsigned int)vcl_pow( 2.0, (int)ImageDimension ); + MapConstIterator mapIt; + mapIt = m_LabelGeometryMapper.find( label ); + if ( mapIt == m_LabelGeometryMapper.end() ) + { + // label does not exist, return a default value + LabelPointType emptyPoint; + emptyPoint.Fill( 0 ); + BoundingBoxVerticesType emptyVertices; + emptyVertices.resize(numberOfVertices,emptyPoint); + return emptyVertices; + } + else + { + return (*mapIt).second.m_OrientedBoundingBoxVertices; + } +} + + +template<class TLabelImage, class TIntensityImage> +typename LabelGeometryImageFilter<TLabelImage, TIntensityImage>::RealType +LabelGeometryImageFilter<TLabelImage, TIntensityImage> +::GetOrientedBoundingBoxVolume(LabelPixelType label) const +{ + MapConstIterator mapIt; + mapIt = m_LabelGeometryMapper.find( label ); + if ( mapIt == m_LabelGeometryMapper.end() ) + { + // label does not exist, return a default value + return NumericTraits<RealType>::Zero; + } + else + { + return (*mapIt).second.m_OrientedBoundingBoxVolume; + } +} + +template<class TLabelImage, class TIntensityImage> +typename LabelGeometryImageFilter<TLabelImage, TIntensityImage>::LabelPointType +LabelGeometryImageFilter<TLabelImage, TIntensityImage> +::GetOrientedBoundingBoxSize(LabelPixelType label) const +{ + MapConstIterator mapIt; + mapIt = m_LabelGeometryMapper.find( label ); + if ( mapIt == m_LabelGeometryMapper.end() ) + { + // label does not exist, return a default value +// LabelSizeType emptySize; +// emptySize.Fill( NumericTraits<LabelSizeType::SizeValueType>::Zero); +// return emptySize; + LabelPointType emptySize; + emptySize.Fill( NumericTraits<ITK_TYPENAME LabelPointType::ValueType>::Zero); + return emptySize; + } + else + { + return (*mapIt).second.m_OrientedBoundingBoxSize; + } +} + +template<class TLabelImage, class TIntensityImage> +typename LabelGeometryImageFilter<TLabelImage, TIntensityImage>::LabelPointType +LabelGeometryImageFilter<TLabelImage, TIntensityImage> +::GetOrientedBoundingBoxOrigin(LabelPixelType label) const +{ + MapConstIterator mapIt; + mapIt = m_LabelGeometryMapper.find( label ); + if ( mapIt == m_LabelGeometryMapper.end() ) + { + // label does not exist, return a default value + LabelPointType emptySize; + emptySize.Fill( NumericTraits<ITK_TYPENAME LabelPointType::ValueType>::Zero); + return emptySize; + } + else + { + return (*mapIt).second.m_OrientedBoundingBoxOrigin; + } +} + +template<class TLabelImage, class TIntensityImage> +typename LabelGeometryImageFilter<TLabelImage, TIntensityImage>::MatrixType +LabelGeometryImageFilter<TLabelImage, TIntensityImage> +::GetRotationMatrix(LabelPixelType label) const +{ + MapConstIterator mapIt; + mapIt = m_LabelGeometryMapper.find( label ); + if ( mapIt == m_LabelGeometryMapper.end() ) + { + // label does not exist, return a default value + MatrixType emptyMatrix(ImageDimension,ImageDimension,0); + return emptyMatrix; + } + else + { + return (*mapIt).second.m_RotationMatrix; + } +} + +template<class TLabelImage, class TIntensityImage> +typename LabelGeometryImageFilter<TLabelImage, TIntensityImage>::RegionType +LabelGeometryImageFilter<TLabelImage, TIntensityImage> +::GetRegion(LabelPixelType label) const +{ + MapConstIterator mapIt; + mapIt = m_LabelGeometryMapper.find( label ); + + if ( mapIt == m_LabelGeometryMapper.end() ) + { + RegionType emptyRegion; + // label does not exist, return a default value + return emptyRegion; + } + else + { + BoundingBoxType bbox = this->GetBoundingBox( label ); + IndexType index; + SizeType size; + + unsigned int dimension = bbox.Size() / 2; + + for (unsigned int i = 0; i < dimension; i++) + { + index[i] = bbox[2*i]; + size[i] = bbox[2*i+1] - bbox[2*i] + 1; + } + RegionType region; + region.SetSize(size); + region.SetIndex(index); + + return region; + } +} + + +template<class TLabelImage, class TIntensityImage> +TLabelImage * +LabelGeometryImageFilter<TLabelImage, TIntensityImage> +::GetOrientedLabelImage(LabelPixelType label) const +{ + MapConstIterator mapIt; + mapIt = m_LabelGeometryMapper.find( label ); + if ( mapIt == m_LabelGeometryMapper.end() ) + { + // label does not exist, return a default value + return NULL; + } + else + { + return (*mapIt).second.m_OrientedLabelImage; + } +} + +template<class TLabelImage, class TIntensityImage> +TIntensityImage * +LabelGeometryImageFilter<TLabelImage, TIntensityImage> +::GetOrientedIntensityImage(LabelPixelType label) const +{ + MapConstIterator mapIt; + mapIt = m_LabelGeometryMapper.find( label ); + if ( mapIt == m_LabelGeometryMapper.end() ) + { + // label does not exist, return a default value + return NULL; + } + else + { + return (*mapIt).second.m_OrientedIntensityImage; + } +} + + +template <class TImage, class TLabelImage> +void +LabelGeometryImageFilter<TImage, TLabelImage> +::PrintSelf(std::ostream& os, Indent indent) const +{ + Superclass::PrintSelf(os,indent); + + os << indent << "Number of labels: " << m_LabelGeometryMapper.size() + << std::endl; + + MapConstIterator mapIt; + for( mapIt = m_LabelGeometryMapper.begin(); mapIt != m_LabelGeometryMapper.end(); mapIt++ ) + { + os << indent << "Label[" << (unsigned long)((*mapIt).second.m_Label) << "]: "; + os << "\t Volume: " << (*mapIt).second.m_ZeroOrderMoment; + os << "\t Integrated Intensity: " << (*mapIt).second.m_Sum; + os << "\t Centroid: " << (*mapIt).second.m_Centroid; + os << "\t Weighted Centroid: " << (*mapIt).second.m_WeightedCentroid; + os << "\t Axes Length: " << (*mapIt).second.m_AxesLength; + os << "\t Eccentricity: " << (*mapIt).second.m_Eccentricity; + os << "\t Elongation: " << (*mapIt).second.m_Elongation; + os << "\t Orientation: " << (*mapIt).second.m_Orientation; + os << "\t Bounding box: " << (*mapIt).second.m_BoundingBox; + os << "\t Bounding box volume: " << (*mapIt).second.m_BoundingBoxVolume; + os << "\t Bounding box size: " << (*mapIt).second.m_BoundingBoxSize; + // Oriented bounding box verticies + os << "\t Oriented bounding box volume: " << (*mapIt).second.m_OrientedBoundingBoxVolume; + os << "\t Oriented bounding box size: " << (*mapIt).second.m_OrientedBoundingBoxSize; + // Rotation matrix + os << std::endl; + os << "\t Calculate oriented intensity regions: " << m_CalculateOrientedIntensityRegions; + os << "\t Calculate pixel indices: " << m_CalculatePixelIndices; + os << "\t Calculate oriented bounding box: " << m_CalculateOrientedBoundingBox; + os << "\t Calculate oriented label regions: " << m_CalculateOrientedLabelRegions; + os << "\n\n"; + } + +} + + +}// end namespace itk +#endif diff --git a/Utilities/ITK/Code/Review/itkLabelMap.h b/Utilities/ITK/Code/Review/itkLabelMap.h index fe7170c53a6b75c860f626de319730966eeb7ad1..72ac57c4f0bc3d67601381724aa6de3a19f6b081 100644 --- a/Utilities/ITK/Code/Review/itkLabelMap.h +++ b/Utilities/ITK/Code/Review/itkLabelMap.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkLabelMap.h,v $ Language: C++ - Date: $Date: 2009-05-14 21:08:43 $ - Version: $Revision: 1.3 $ + Date: $Date: 2009-12-10 10:55:21 $ + Version: $Revision: 1.4 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -268,6 +268,11 @@ public: this->PrintLabelObjects( std::cerr ); } + /** + * Optimize the line representation of all the lable objects referenced in the LabelMap + */ + void Optimize(); + protected: LabelMap(); virtual ~LabelMap() {}; diff --git a/Utilities/ITK/Code/Review/itkLabelMap.txx b/Utilities/ITK/Code/Review/itkLabelMap.txx index d7f39c685ec6ff6f8899be40d958b586622be284..1be256657180d91f87c1d8769f49453dd80e71c6 100644 --- a/Utilities/ITK/Code/Review/itkLabelMap.txx +++ b/Utilities/ITK/Code/Review/itkLabelMap.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkLabelMap.txx,v $ Language: C++ - Date: $Date: 2009-07-07 18:41:40 $ - Version: $Revision: 1.3 $ + Date: $Date: 2009-12-10 10:55:21 $ + Version: $Revision: 1.6 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -61,7 +61,7 @@ void LabelMap<TLabelObject> ::Initialize() { - m_LabelObjectContainer.clear(); + this->ClearLabels(); } @@ -420,7 +420,11 @@ void LabelMap<TLabelObject> ::ClearLabels() { - m_LabelObjectContainer.clear(); + if( !m_LabelObjectContainer.empty() ) + { + m_LabelObjectContainer.clear(); + this->Modified(); + } } @@ -500,6 +504,21 @@ LabelMap<TLabelObject> } } + +template<class TLabelObject > +void +LabelMap<TLabelObject> +::Optimize() +{ + for( typename LabelObjectContainerType::const_iterator it = m_LabelObjectContainer.begin(); + it != m_LabelObjectContainer.end(); + it++ ) + { + itkAssertOrThrowMacro( (it->second.IsNotNull()), "Null label" ); + it->second->Optimize(); + } +} + } // end namespace itk #endif diff --git a/Utilities/ITK/Code/Review/itkLabelObject.txx b/Utilities/ITK/Code/Review/itkLabelObject.txx index 9c41a2dc93cfdf5a22d70ecae8566ea6c86507be..133cd292095e5788cb9c867ece6ee23e7046747a 100644 --- a/Utilities/ITK/Code/Review/itkLabelObject.txx +++ b/Utilities/ITK/Code/Review/itkLabelObject.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkLabelObject.txx,v $ Language: C++ - Date: $Date: 2009-08-10 16:38:36 $ - Version: $Revision: 1.12 $ + Date: $Date: 2009-12-04 14:21:07 $ + Version: $Revision: 1.13 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -105,8 +105,6 @@ void LabelObject<TLabel, VImageDimension>:: AddIndex( const IndexType & idx ) { - itkAssertOrThrowMacro( (!this->HasIndex( idx )), "Index out of range" ); - if( !m_LineContainer.empty() ) { // can we use the last line to add that index ? @@ -141,7 +139,6 @@ void LabelObject<TLabel, VImageDimension>:: AddLine( const LineType & line ) { - // TODO: add an assert to be sure that some indexes in the line are not already stored here m_LineContainer.push_back( line ); } diff --git a/Utilities/ITK/Code/Review/itkMINC2ImageIOFactory.cxx b/Utilities/ITK/Code/Review/itkMINC2ImageIOFactory.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Review/itkMINC2ImageIOFactory.h b/Utilities/ITK/Code/Review/itkMINC2ImageIOFactory.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Review/itkMovingHistogramMorphologicalGradientImageFilter.h b/Utilities/ITK/Code/Review/itkMovingHistogramMorphologicalGradientImageFilter.h index 48f4085d833c0792f1d8d6929925903527be1c1c..30973b292eaf82e16756bd9836680188acd0a4f0 100644 --- a/Utilities/ITK/Code/Review/itkMovingHistogramMorphologicalGradientImageFilter.h +++ b/Utilities/ITK/Code/Review/itkMovingHistogramMorphologicalGradientImageFilter.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkMovingHistogramMorphologicalGradientImageFilter.h,v $ Language: C++ - Date: $Date: 2009-06-03 12:48:05 $ - Version: $Revision: 1.5 $ + Date: $Date: 2009-09-19 19:10:37 $ + Version: $Revision: 1.6 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -29,7 +29,8 @@ class MorphologicalGradientHistogram public: MorphologicalGradientHistogram() { - if( UseVectorBasedAlgorithm() ) + m_UseVectorBasedAlgorithm = UseVectorBasedAlgorithm(); + if( m_UseVectorBasedAlgorithm ) { initVector(); } } ~MorphologicalGradientHistogram(){} @@ -51,7 +52,7 @@ public: inline void AddPixel( const TInputPixel &p ) { - if( UseVectorBasedAlgorithm() ) + if( m_UseVectorBasedAlgorithm ) { AddPixelVector( p ); } else { AddPixelMap( p ); } @@ -59,7 +60,7 @@ public: inline void RemovePixel( const TInputPixel &p ) { - if( UseVectorBasedAlgorithm() ) + if( m_UseVectorBasedAlgorithm ) { RemovePixelVector( p ); } else { RemovePixelMap( p ); } @@ -67,7 +68,7 @@ public: inline TInputPixel GetValue( const TInputPixel & ) { - if( UseVectorBasedAlgorithm() ) + if( m_UseVectorBasedAlgorithm ) { return GetValueVector(); } else { return GetValueMap(); } @@ -85,7 +86,8 @@ public: || typeid(TInputPixel) == typeid(bool); } - + bool m_UseVectorBasedAlgorithm; + // // the map based algorithm // diff --git a/Utilities/ITK/Code/Review/itkMovingHistogramMorphologyImageFilter.h b/Utilities/ITK/Code/Review/itkMovingHistogramMorphologyImageFilter.h index 8f4cb571fce00457e28fee03140477c8f66fa152..fa6840f9ea8b40f79bb9e878e36a8c0da5d7e545 100644 --- a/Utilities/ITK/Code/Review/itkMovingHistogramMorphologyImageFilter.h +++ b/Utilities/ITK/Code/Review/itkMovingHistogramMorphologyImageFilter.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkMovingHistogramMorphologyImageFilter.h,v $ Language: C++ - Date: $Date: 2009-06-03 12:48:05 $ - Version: $Revision: 1.5 $ + Date: $Date: 2009-09-19 19:10:37 $ + Version: $Revision: 1.6 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -30,7 +30,8 @@ class MorphologyHistogram public: MorphologyHistogram() { - if( UseVectorBasedAlgorithm() ) + m_UseVectorBasedAlgorithm = UseVectorBasedAlgorithm(); + if( m_UseVectorBasedAlgorithm ) { initVector(); } } ~MorphologyHistogram(){} @@ -52,7 +53,7 @@ public: inline void AddBoundary() { - if( UseVectorBasedAlgorithm() ) + if( m_UseVectorBasedAlgorithm ) { AddBoundaryVector(); } else { AddBoundaryMap(); } @@ -60,7 +61,7 @@ public: inline void RemoveBoundary() { - if( UseVectorBasedAlgorithm() ) + if( m_UseVectorBasedAlgorithm ) { RemoveBoundaryVector(); } else { RemoveBoundaryMap(); } @@ -68,7 +69,7 @@ public: inline void AddPixel( const TInputPixel &p ) { - if( UseVectorBasedAlgorithm() ) + if( m_UseVectorBasedAlgorithm ) { AddPixelVector( p ); } else { AddPixelMap( p ); } @@ -76,7 +77,7 @@ public: inline void RemovePixel( const TInputPixel &p ) { - if( UseVectorBasedAlgorithm() ) + if( m_UseVectorBasedAlgorithm ) { RemovePixelVector( p ); } else { RemovePixelMap( p ); } @@ -84,7 +85,7 @@ public: inline TInputPixel GetValue( const TInputPixel & ) { - if( UseVectorBasedAlgorithm() ) + if( m_UseVectorBasedAlgorithm ) { return GetValueVector(); } else { return GetValueMap(); } @@ -102,7 +103,8 @@ public: || typeid(TInputPixel) == typeid(bool); } - + bool m_UseVectorBasedAlgorithm; + // // the map based algorithm // diff --git a/Utilities/ITK/Code/Review/itkMultiScaleHessianBasedMeasureImageFilter.h b/Utilities/ITK/Code/Review/itkMultiScaleHessianBasedMeasureImageFilter.h index 34bc2003cc2f11b3c7175ad1cd9a833c70e388bf..d1eaa336cb12f93579a7da3979857b807d414ac0 100644 --- a/Utilities/ITK/Code/Review/itkMultiScaleHessianBasedMeasureImageFilter.h +++ b/Utilities/ITK/Code/Review/itkMultiScaleHessianBasedMeasureImageFilter.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkMultiScaleHessianBasedMeasureImageFilter.h,v $ Language: C++ - Date: $Date: 2009-04-23 03:43:42 $ - Version: $Revision: 1.9 $ + Date: $Date: 2010-02-04 12:16:43 $ + Version: $Revision: 1.10 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -98,6 +98,10 @@ public: /** Method for creation through the object factory. */ itkNewMacro(Self); + /** Runtime information support. */ + itkTypeMacro(MultiScaleHessianBasedMeasureImageFilter, + ImageToImageFilter); + /** Set/Get macros for SigmaMin */ itkSetMacro(SigmaMinimum, double); itkGetConstMacro(SigmaMinimum, double); diff --git a/Utilities/ITK/Code/Review/itkMultiphaseDenseFiniteDifferenceImageFilter.h b/Utilities/ITK/Code/Review/itkMultiphaseDenseFiniteDifferenceImageFilter.h index ed7664e3d19aa0d96b85b1e17367999bcab99a40..0e8485e45ba7230ff84bca58ffc06b20a74efb2e 100644 --- a/Utilities/ITK/Code/Review/itkMultiphaseDenseFiniteDifferenceImageFilter.h +++ b/Utilities/ITK/Code/Review/itkMultiphaseDenseFiniteDifferenceImageFilter.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkMultiphaseDenseFiniteDifferenceImageFilter.h,v $ Language: C++ - Date: $Date: 2009-07-29 15:13:55 $ - Version: $Revision: 1.4 $ + Date: $Date: 2010-02-25 14:19:24 $ + Version: $Revision: 1.6 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -108,7 +108,7 @@ public: /** Standard class typedefs */ typedef MultiphaseDenseFiniteDifferenceImageFilter Self; typedef MultiphaseFiniteDifferenceImageFilter< TInputImage, - TFeatureImage, TOutputImage, TFunction > Superclass; + TFeatureImage, TOutputImage, TFunction, TIdCell > Superclass; typedef SmartPointer<Self> Pointer; typedef SmartPointer<const Self> ConstPointer; @@ -188,15 +188,21 @@ public: /** End concept checking */ #endif + itkSetMacro( ReinitializeCounter, unsigned int ); + itkGetMacro( ReinitializeCounter, unsigned int ); + protected: MultiphaseDenseFiniteDifferenceImageFilter() { this->m_ReinitializeCounter = 1; - this->m_UpdateCounter = 0; // FIXME: Should this be a bool ? + // FIXME: this->m_UpdateCounter really used? + // this->m_UpdateCounter = 0; // FIXME: Should this be a bool ? } ~MultiphaseDenseFiniteDifferenceImageFilter() {} + virtual void PrintSelf( std::ostream&, Indent indent ) const; + /** A simple method to copy the data from the input to the output. ( Supports * "read-only" image adaptors in the case where the input image type converts * to a different output image type. ) */ @@ -209,7 +215,7 @@ protected: virtual void ApplyUpdate(TimeStepType dt); unsigned int m_ReinitializeCounter; // FIXME: Should this be a boolean ? - unsigned int m_UpdateCounter; // FIXME: Should this be a boolean ? + // unsigned int m_UpdateCounter; // FIXME: Should this be a boolean ? private: MultiphaseDenseFiniteDifferenceImageFilter(const Self&); diff --git a/Utilities/ITK/Code/Review/itkMultiphaseDenseFiniteDifferenceImageFilter.txx b/Utilities/ITK/Code/Review/itkMultiphaseDenseFiniteDifferenceImageFilter.txx index 5241dcb8aa1fa968c3d35923f52f5e9eef7e1c40..1dcae2ed93f48f773feb310f10712f4f1cf17207 100644 --- a/Utilities/ITK/Code/Review/itkMultiphaseDenseFiniteDifferenceImageFilter.txx +++ b/Utilities/ITK/Code/Review/itkMultiphaseDenseFiniteDifferenceImageFilter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkMultiphaseDenseFiniteDifferenceImageFilter.txx,v $ Language: C++ - Date: $Date: 2009-07-29 15:14:02 $ - Version: $Revision: 1.6 $ + Date: $Date: 2010-02-25 14:19:24 $ + Version: $Revision: 1.9 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -23,6 +23,18 @@ namespace itk { +template < class TInputImage, class TFeatureImage, class TOutputImage, + class TFunction, typename TIdCell > +void +MultiphaseDenseFiniteDifferenceImageFilter< TInputImage, TFeatureImage, + TOutputImage, TFunction, TIdCell > +::PrintSelf( std::ostream& os, Indent indent ) const +{ + Superclass::PrintSelf( os, indent ); + + os << indent << "m_ReinitializeCounter: " <<m_ReinitializeCounter <<std::endl; +} + template < class TInputImage, class TFeatureImage, class TOutputImage, class TFunction, typename TIdCell > void @@ -31,6 +43,7 @@ MultiphaseDenseFiniteDifferenceImageFilter< TInputImage, TFeatureImage, ::CopyInputToOutput() { OutputImagePointer output = this->GetOutput(); + output->FillBuffer( 0 ); for( IdCellType i = 0; i < this->m_FunctionCount; i++ ) { @@ -67,10 +80,6 @@ MultiphaseDenseFiniteDifferenceImageFilter< TInputImage, TFeatureImage, { out.Value() = p; } - else - { - out.Value() = 0; - } ++in; ++out; } @@ -192,6 +201,7 @@ MultiphaseDenseFiniteDifferenceImageFilter< TInputImage, TFeatureImage, double rms_change_accumulator = 0; double den = 0; IdCellType i; + InputPixelType val; for( i = 0; i < this->m_FunctionCount; i++ ) { @@ -212,15 +222,17 @@ MultiphaseDenseFiniteDifferenceImageFilter< TInputImage, TFeatureImage, // it is this->m_LevelSet[i]->GetLargestPossibleRegion() InputRegionType region = this->m_LevelSet[i]->GetRequestedRegion(); - ImageRegionIterator< InputImageType > u ( m_UpdateBuffers[i], region ); - ImageRegionIterator< InputImageType > o ( this->m_LevelSet[i], region ); + ImageRegionIterator< InputImageType > u( m_UpdateBuffers[i], region ); + ImageRegionIterator< InputImageType > o( this->m_LevelSet[i], region ); u.GoToBegin(); o.GoToBegin(); while( !u.IsAtEnd() ) { - u.Set( o.Value() + static_cast< InputPixelType > ( dt ) * u.Get() ); + val = static_cast< InputPixelType > ( dt ) * u.Get(); + o.Set( o.Value() + val ); + rms_change_accumulator += static_cast<double> ( vnl_math_sqr( val ) ); ++u; ++o; } @@ -232,7 +244,7 @@ MultiphaseDenseFiniteDifferenceImageFilter< TInputImage, TFeatureImage, thresh->SetUpperThreshold( 0 ); thresh->SetInsideValue( 1 ); thresh->SetOutsideValue( 0 ); - thresh->SetInput( m_UpdateBuffers[i] ); + thresh->SetInput( this->m_LevelSet[i] ); thresh->Update(); MaurerPointer maurer = MaurerType::New(); @@ -244,11 +256,11 @@ MultiphaseDenseFiniteDifferenceImageFilter< TInputImage, TFeatureImage, ImageRegionIterator< InputImageType > it ( maurer->GetOutput(), region ); + rms_change_accumulator = 0; + o.GoToBegin(); it.GoToBegin(); - InputPixelType val; - while( !o.IsAtEnd() ) { val = it.Value(); diff --git a/Utilities/ITK/Code/Review/itkMultiphaseSparseFiniteDifferenceImageFilter.txx b/Utilities/ITK/Code/Review/itkMultiphaseSparseFiniteDifferenceImageFilter.txx index 674a1cf6b45db00c1b0f7b0b502c2da99915217c..37de5482ec7351b2a01caac0be14766d7e1fd05f 100644 --- a/Utilities/ITK/Code/Review/itkMultiphaseSparseFiniteDifferenceImageFilter.txx +++ b/Utilities/ITK/Code/Review/itkMultiphaseSparseFiniteDifferenceImageFilter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkMultiphaseSparseFiniteDifferenceImageFilter.txx,v $ Language: C++ - Date: $Date: 2009-09-10 01:17:34 $ - Version: $Revision: 1.18 $ + Date: $Date: 2010-02-24 19:27:48 $ + Version: $Revision: 1.19 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -86,6 +86,62 @@ MultiphaseSparseFiniteDifferenceImageFilter< TInputImage, TFeatureImage, TOutput this->m_BoundsCheckingActive = false; } +template<class TInputImage, class TFeatureImage, class TOutputImage, class TFunction, typename TIdCell > +void +MultiphaseSparseFiniteDifferenceImageFilter< TInputImage, TFeatureImage, TOutputImage, TFunction, TIdCell > +::CopyInputToOutput() +{ + for( IdCellType i = 0; i < this->m_FunctionCount; i++ ) + { + InputImagePointer input = this->m_LevelSet[i]; + + // This is used as a temporary buffer + InputImagePointer tempImage = InputImageType::New(); + tempImage->SetRegions( input->GetRequestedRegion() ); + tempImage->CopyInformation( input ); + tempImage->Allocate(); + + // Compute Heaviside of input image + // Copy input to temp + InputRegionType region = input->GetRequestedRegion(); + ImageRegionIterator< InputImageType > lIt( input, region ); + ImageRegionIterator< InputImageType > tIt( tempImage, region ); + + lIt.GoToBegin(); + tIt.GoToBegin(); + + while( !lIt.IsAtEnd() ) + { + tIt.Set( lIt.Get() ); + ++tIt; + ++lIt; + } + + // TODO: Can the zeroCrossingFilter have the same input and output? + ZeroCrossingFilterPointer zeroCrossingFilter = ZeroCrossingFilterType::New(); + zeroCrossingFilter->SetInput( tempImage ); + zeroCrossingFilter->SetBackgroundValue( m_ValueOne ); + zeroCrossingFilter->SetForegroundValue( m_ValueZero ); + zeroCrossingFilter->Update(); + + // The levelset image has a 0 where the zero contour exists and + outside and - inside + ImageRegionIterator< InputImageType > zIt( zeroCrossingFilter->GetOutput(), region ); + + lIt.GoToBegin(); + zIt.GoToBegin(); + + while( !lIt.IsAtEnd() ) + { + if ( zIt.Get() == 0 ) + { + lIt.Set( 0 ); + } + ++zIt; + ++lIt; + } + } +} + template < class TInputImage, class TFeatureImage, class TOutputImage, class TFunction, typename TIdCell > typename MultiphaseSparseFiniteDifferenceImageFilter< TInputImage, TFeatureImage, TOutputImage, TFunction, TIdCell >::TimeStepType @@ -903,62 +959,6 @@ MultiphaseSparseFiniteDifferenceImageFilter< TInputImage, TFeatureImage, } } -template<class TInputImage, class TFeatureImage, class TOutputImage, class TFunction, typename TIdCell > -void -MultiphaseSparseFiniteDifferenceImageFilter< TInputImage, TFeatureImage, TOutputImage, TFunction, TIdCell > -::CopyInputToOutput() -{ - for( IdCellType i = 0; i < this->m_FunctionCount; i++ ) - { - InputImagePointer input = this->m_LevelSet[i]; - - // This is used as a temporary buffer - InputImagePointer tempImage = InputImageType::New(); - tempImage->SetRegions( input->GetRequestedRegion() ); - tempImage->CopyInformation( input ); - tempImage->Allocate(); - - // Compute Heaviside of input image - // Copy input to temp - InputRegionType region = input->GetRequestedRegion(); - ImageRegionIterator< InputImageType > lIt( input, region ); - ImageRegionIterator< InputImageType > tIt( tempImage, region ); - - lIt.GoToBegin(); - tIt.GoToBegin(); - - while( !lIt.IsAtEnd() ) - { - tIt.Set( lIt.Get() ); - ++tIt; - ++lIt; - } - - // TODO: Can the zeroCrossingFilter have the same input and output? - ZeroCrossingFilterPointer zeroCrossingFilter = ZeroCrossingFilterType::New(); - zeroCrossingFilter->SetInput( tempImage ); - zeroCrossingFilter->SetBackgroundValue( m_ValueOne ); - zeroCrossingFilter->SetForegroundValue( m_ValueZero ); - zeroCrossingFilter->Update(); - - // The levelset image has a 0 where the zero contour exists and + outside and - inside - ImageRegionIterator< InputImageType > zIt( zeroCrossingFilter->GetOutput(), region ); - - lIt.GoToBegin(); - zIt.GoToBegin(); - - while( !lIt.IsAtEnd() ) - { - if ( zIt.Get() == 0 ) - { - lIt.Set( 0 ); - } - ++zIt; - ++lIt; - } - } -} - template< class TInputImage, class TFeatureImage, class TOutputImage, class TFunction, typename TIdCell > void MultiphaseSparseFiniteDifferenceImageFilter< TInputImage, TFeatureImage, TOutputImage, TFunction, TIdCell > diff --git a/Utilities/ITK/Code/Review/itkOptAdaptiveHistogramEqualizationImageFilter.h b/Utilities/ITK/Code/Review/itkOptAdaptiveHistogramEqualizationImageFilter.h index 2635ac1f8d5672b0eb132410313709f0ad7937b2..992fc9ade553bc765012c35b2e1b27ee86fd1c94 100644 --- a/Utilities/ITK/Code/Review/itkOptAdaptiveHistogramEqualizationImageFilter.h +++ b/Utilities/ITK/Code/Review/itkOptAdaptiveHistogramEqualizationImageFilter.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkOptAdaptiveHistogramEqualizationImageFilter.h,v $ Language: C++ - Date: $Date: 2009-04-23 03:43:42 $ - Version: $Revision: 1.4 $ + Date: $Date: 2010-03-02 03:40:37 $ + Version: $Revision: 1.5 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -24,7 +24,7 @@ namespace itk { /** - * \class tAdaptiveHistogramEqualizationImageFilter + * \class AdaptiveHistogramEqualizationImageFilter * \brief Power Law Adaptive Histogram Equalization * * Histogram equalization modifies the contrast in an image. The diff --git a/Utilities/ITK/Code/Review/itkOptBSplineInterpolateImageFunction.h b/Utilities/ITK/Code/Review/itkOptBSplineInterpolateImageFunction.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Review/itkOptBSplineInterpolateImageFunction.txx b/Utilities/ITK/Code/Review/itkOptBSplineInterpolateImageFunction.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Review/itkOptImageToImageMetric.h b/Utilities/ITK/Code/Review/itkOptImageToImageMetric.h old mode 100644 new mode 100755 index 8a8819e0aee08ae4bd724bba5ca7cafebbf60cd0..f9ebd740131e246a2db2bca42f5300b3a4db0406 --- a/Utilities/ITK/Code/Review/itkOptImageToImageMetric.h +++ b/Utilities/ITK/Code/Review/itkOptImageToImageMetric.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkOptImageToImageMetric.h,v $ Language: C++ - Date: $Date: 2009-08-20 09:08:41 $ - Version: $Revision: 1.31 $ + Date: $Date: 2010-03-05 16:15:37 $ + Version: $Revision: 1.34 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -319,6 +319,14 @@ public: itkSetMacro(UseCachingOfBSplineWeights,bool); itkGetConstReferenceMacro(UseCachingOfBSplineWeights,bool); itkBooleanMacro(UseCachingOfBSplineWeights); + + typedef MultiThreader MultiThreaderType; + /** Get the Threader. */ + itkGetConstObjectMacro( Threader, MultiThreaderType ); + const TransformPointer* GetThreaderTransform() + { + return m_ThreaderTransform; + } protected: ImageToImageMetric(); @@ -358,13 +366,13 @@ protected: typedef std::vector<FixedImageSamplePoint> FixedImageSampleContainer; /** Uniformly select a sample set from the fixed image domain. */ - virtual void SampleFixedImageDomain( FixedImageSampleContainer & samples) const; + virtual void SampleFixedImageRegion( FixedImageSampleContainer & samples) const; virtual void SampleFixedImageIndexes( FixedImageSampleContainer & samples) const; /** Gather all the pixels from the fixed image domain. */ - virtual void SampleFullFixedImageDomain( FixedImageSampleContainer & + virtual void SampleFullFixedImageRegion( FixedImageSampleContainer & samples) const; /** Container to store a set of points and fixed image values. */ @@ -507,8 +515,6 @@ protected: * Types and variables related to multi-threading */ - typedef MultiThreader MultiThreaderType; - struct MultiThreaderParameterType { ImageToImageMetric * metric; @@ -570,7 +576,7 @@ protected: /** Synchronizes the threader transforms with the transform * member variable. */ - void SynchronizeTransforms() const; + virtual void SynchronizeTransforms() const; private: ImageToImageMetric(const Self&); //purposely not implemented diff --git a/Utilities/ITK/Code/Review/itkOptImageToImageMetric.txx b/Utilities/ITK/Code/Review/itkOptImageToImageMetric.txx old mode 100644 new mode 100755 index b997ac8eb5d512c211f2acff3acf82fc8c1428ad..ed7b7a39ee69e5f0b1f2278a35d3c09ed1d2163c --- a/Utilities/ITK/Code/Review/itkOptImageToImageMetric.txx +++ b/Utilities/ITK/Code/Review/itkOptImageToImageMetric.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkOptImageToImageMetric.txx,v $ Language: C++ - Date: $Date: 2009-08-24 17:42:02 $ - Version: $Revision: 1.37 $ + Date: $Date: 2010-03-27 20:54:43 $ + Version: $Revision: 1.40 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -105,6 +105,18 @@ ImageToImageMetric<TFixedImage,TMovingImage> delete [] m_ThreaderTransform; } m_ThreaderTransform = NULL; + + if( this->m_ThreaderBSplineTransformWeights != NULL ) + { + delete [] this->m_ThreaderBSplineTransformWeights; + } + this->m_ThreaderBSplineTransformWeights = NULL; + + if( this->m_ThreaderBSplineTransformIndices != NULL ) + { + delete [] this->m_ThreaderBSplineTransformIndices; + } + this->m_ThreaderBSplineTransformIndices = NULL; } /** @@ -388,7 +400,7 @@ ImageToImageMetric<TFixedImage,TMovingImage> // Take all the pixels within the fixed image region) // to create the sample points list. // - SampleFullFixedImageDomain( m_FixedImageSamples ); + SampleFullFixedImageRegion( m_FixedImageSamples ); } else { @@ -406,7 +418,7 @@ ImageToImageMetric<TFixedImage,TMovingImage> // Uniformly sample the fixed image (within the fixed image region) // to create the sample points list. // - SampleFixedImageDomain( m_FixedImageSamples ); + SampleFixedImageRegion( m_FixedImageSamples ); } } @@ -489,11 +501,13 @@ ImageToImageMetric<TFixedImage,TMovingImage> { delete [] this->m_ThreaderBSplineTransformWeights; } - + this->m_ThreaderBSplineTransformWeights = NULL; + if( this->m_ThreaderBSplineTransformIndices != NULL ) { delete [] this->m_ThreaderBSplineTransformIndices; } + this->m_ThreaderBSplineTransformIndices = NULL; if( this->m_UseCachingOfBSplineWeights ) { @@ -570,7 +584,7 @@ ImageToImageMetric<TFixedImage,TMovingImage> template < class TFixedImage, class TMovingImage > void ImageToImageMetric<TFixedImage,TMovingImage> -::SampleFixedImageDomain( FixedImageSampleContainer & samples ) const +::SampleFixedImageRegion( FixedImageSampleContainer & samples ) const { if( samples.size() != m_NumberOfFixedImageSamples ) { @@ -686,7 +700,7 @@ ImageToImageMetric<TFixedImage,TMovingImage> template < class TFixedImage, class TMovingImage > void ImageToImageMetric<TFixedImage,TMovingImage> -::SampleFullFixedImageDomain( FixedImageSampleContainer& samples ) const +::SampleFullFixedImageRegion( FixedImageSampleContainer& samples ) const { if( samples.size() != m_NumberOfFixedImageSamples ) @@ -1193,7 +1207,7 @@ ImageToImageMetric<TFixedImage,TMovingImage> this->SynchronizeTransforms(); m_Threader->SetSingleMethod(GetValueMultiThreaded, - (void *)(&m_ThreaderParameter)); + const_cast<void *>(static_cast<const void *>(&m_ThreaderParameter))); m_Threader->SingleMethodExecute(); for( unsigned int threadID = 0; threadID<m_NumberOfThreads-1; threadID++ ) @@ -1208,7 +1222,7 @@ ImageToImageMetric<TFixedImage,TMovingImage> ::GetValueMultiThreadedPostProcessInitiate( void ) const { m_Threader->SetSingleMethod(GetValueMultiThreadedPostProcess, - (void *)(&m_ThreaderParameter)); + const_cast<void *>(static_cast<const void *>(&m_ThreaderParameter))); m_Threader->SingleMethodExecute(); } @@ -1357,7 +1371,7 @@ ImageToImageMetric<TFixedImage,TMovingImage> this->SynchronizeTransforms(); m_Threader->SetSingleMethod(GetValueAndDerivativeMultiThreaded, - (void *)(&m_ThreaderParameter)); + const_cast<void *>(static_cast<const void *>(&m_ThreaderParameter))); m_Threader->SingleMethodExecute(); for( unsigned int threadID = 0; threadID<m_NumberOfThreads-1; threadID++ ) diff --git a/Utilities/ITK/Code/Review/itkOptLinearInterpolateImageFunction.h b/Utilities/ITK/Code/Review/itkOptLinearInterpolateImageFunction.h old mode 100644 new mode 100755 index dc5c08bd40ce602b4932f11402da11376c62bfda..039535a16ab51ae4edf0fa16ad709a7f1eb1cab5 --- a/Utilities/ITK/Code/Review/itkOptLinearInterpolateImageFunction.h +++ b/Utilities/ITK/Code/Review/itkOptLinearInterpolateImageFunction.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkOptLinearInterpolateImageFunction.h,v $ Language: C++ - Date: $Date: 2009-07-29 07:38:01 $ - Version: $Revision: 1.7 $ + Date: $Date: 2009-10-29 11:19:19 $ + Version: $Revision: 1.11 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -72,7 +72,8 @@ public: itkStaticConstMacro(ImageDimension, unsigned int,Superclass::ImageDimension); /** Index typedef support. */ - typedef typename Superclass::IndexType IndexType; + typedef typename Superclass::IndexType IndexType; + typedef typename Superclass::IndexValueType IndexValueType; /** ContinuousIndex typedef support. */ typedef typename Superclass::ContinuousIndexType ContinuousIndexType; @@ -118,7 +119,7 @@ private: { IndexType basei; - basei[0] = Math::Floor(index[0]); + basei[0] = Math::Floor<IndexValueType>(index[0]); if( basei[0] < this->m_StartIndex[0] ) { basei[0] = this->m_StartIndex[0]; @@ -148,14 +149,14 @@ private: { IndexType basei; - basei[0] = Math::Floor(index[0]); + basei[0] = Math::Floor<IndexValueType>(index[0]); if( basei[0] < this->m_StartIndex[0] ) { basei[0] = this->m_StartIndex[0]; } const double distance0 = index[0] - static_cast<double>(basei[0]); - basei[1] = Math::Floor(index[1]); + basei[1] = Math::Floor<IndexValueType>(index[1]); if( basei[1] < this->m_StartIndex[1] ) { basei[1] = this->m_StartIndex[1]; @@ -226,21 +227,21 @@ private: { IndexType basei; - basei[0] = Math::Floor(index[0]); + basei[0] = Math::Floor<IndexValueType>(index[0]); if( basei[0] < this->m_StartIndex[0] ) { basei[0] = this->m_StartIndex[0]; } const double distance0 = index[0] - static_cast<double>(basei[0]); - basei[1] = Math::Floor(index[1]); + basei[1] = Math::Floor<IndexValueType>(index[1]); if( basei[1] < this->m_StartIndex[1] ) { basei[1] = this->m_StartIndex[1]; } const double distance1 = index[1] - static_cast<double>(basei[1]); - basei[2] = Math::Floor(index[2]); + basei[2] = Math::Floor<IndexValueType>(index[2]); if( basei[2] < this->m_StartIndex[2] ) { basei[2] = this->m_StartIndex[2]; @@ -252,7 +253,6 @@ private: return( static_cast<OutputType>( this->GetInputImage()->GetPixel( basei ) ) ); } - typedef typename IndexType::IndexValueType IndexValueType; const RealType val000 = this->GetInputImage()->GetPixel( basei ); diff --git a/Utilities/ITK/Code/Review/itkOptLinearInterpolateImageFunction.txx b/Utilities/ITK/Code/Review/itkOptLinearInterpolateImageFunction.txx old mode 100644 new mode 100755 index 9813cf2e7540686dbcbe1421691d767324482141..bbd492ce58e0b1755c5675e2e640f23e35b888d8 --- a/Utilities/ITK/Code/Review/itkOptLinearInterpolateImageFunction.txx +++ b/Utilities/ITK/Code/Review/itkOptLinearInterpolateImageFunction.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkOptLinearInterpolateImageFunction.txx,v $ Language: C++ - Date: $Date: 2009-07-29 07:38:01 $ - Version: $Revision: 1.7 $ + Date: $Date: 2009-10-29 11:19:19 $ + Version: $Revision: 1.9 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -75,12 +75,12 @@ LinearInterpolateImageFunction< TInputImage, TCoordRep > * Compute base index = closet index below point * Compute distance from point to base index */ - signed long baseIndex[ImageDimension]; + IndexType baseIndex; double distance[ImageDimension]; for( dim = 0; dim < ImageDimension; dim++ ) { - baseIndex[dim] = Math::Floor( index[dim] ); + baseIndex[dim] = Math::Floor<IndexValueType>( index[dim] ); distance[dim] = index[dim] - static_cast< double >( baseIndex[dim] ); } diff --git a/Utilities/ITK/Code/Review/itkOptMatchCardinalityImageToImageMetric.h b/Utilities/ITK/Code/Review/itkOptMatchCardinalityImageToImageMetric.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Review/itkOptMatchCardinalityImageToImageMetric.txx b/Utilities/ITK/Code/Review/itkOptMatchCardinalityImageToImageMetric.txx old mode 100644 new mode 100755 index a5d9946b42e48c03a1a191495478a2a9482f9d39..f43b1ffb3fb43372d9945c034ce3f797f6e6d40d --- a/Utilities/ITK/Code/Review/itkOptMatchCardinalityImageToImageMetric.txx +++ b/Utilities/ITK/Code/Review/itkOptMatchCardinalityImageToImageMetric.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkOptMatchCardinalityImageToImageMetric.txx,v $ Language: C++ - Date: $Date: 2009-04-06 13:46:38 $ - Version: $Revision: 1.5 $ + Date: $Date: 2009-10-29 15:03:32 $ + Version: $Revision: 1.6 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -226,8 +226,8 @@ MatchCardinalityImageToImageMetric<TFixedImage, TMovingImage> // determine the actual number of pieces that will be generated typename FixedImageRegionType::SizeType::SizeValueType range = fixedRegionSize[splitAxis]; - int valuesPerThread = (int)vcl_ceil(range/(double)num); - int maxThreadIdUsed = (int)vcl_ceil(range/(double)valuesPerThread) - 1; + int valuesPerThread = Math::Ceil<int>(range/(double)num); + int maxThreadIdUsed = Math::Ceil<int>(range/(double)valuesPerThread) - 1; // Split the region if (i < maxThreadIdUsed) diff --git a/Utilities/ITK/Code/Review/itkOptMattesMutualInformationImageToImageMetric.h b/Utilities/ITK/Code/Review/itkOptMattesMutualInformationImageToImageMetric.h old mode 100644 new mode 100755 index 77521e439faa01693a12fb80ccbf585e43ed4c7b..2af9ca3fd6e629fa6c41859903897dd557a84b6a --- a/Utilities/ITK/Code/Review/itkOptMattesMutualInformationImageToImageMetric.h +++ b/Utilities/ITK/Code/Review/itkOptMattesMutualInformationImageToImageMetric.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkOptMattesMutualInformationImageToImageMetric.h,v $ Language: C++ - Date: $Date: 2009-07-28 21:47:09 $ - Version: $Revision: 1.7 $ + Date: $Date: 2009-11-02 15:37:04 $ + Version: $Revision: 1.9 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -158,6 +158,8 @@ public: typedef typename Superclass::WeightsValueType WeightsValueType; typedef typename Superclass::IndexValueType IndexValueType; + typedef typename FixedImageType::OffsetValueType OffsetValueType; + /** The moving image dimension. */ itkStaticConstMacro( MovingImageDimension, unsigned int, MovingImageType::ImageDimension ); @@ -183,9 +185,13 @@ public: MeasureType & Value, DerivativeType & Derivative ) const; - /** Number of bins to used in the histogram. Typical value is 50. */ + /** Number of bins to used in the histogram. Typical value is + * 50. The minimum value is 5 due to the padding required by the Parzen + * windowing with a cubic-BSpline kernel. Note that even if the metric + * is used on binary images, the number of bins should at least be + * equal to five. */ itkSetClampMacro( NumberOfHistogramBins, unsigned long, - 1, NumericTraits<unsigned long>::max() ); + 5, NumericTraits<unsigned long>::max() ); itkGetConstReferenceMacro( NumberOfHistogramBins, unsigned long); /** This variable selects the method to be used for computing the Metric diff --git a/Utilities/ITK/Code/Review/itkOptMattesMutualInformationImageToImageMetric.txx b/Utilities/ITK/Code/Review/itkOptMattesMutualInformationImageToImageMetric.txx old mode 100644 new mode 100755 index b80676948f700591a89ef1c5a9cb98e486458c81..d9253594bc696034c69a9dc845c467d0b9891cda --- a/Utilities/ITK/Code/Review/itkOptMattesMutualInformationImageToImageMetric.txx +++ b/Utilities/ITK/Code/Review/itkOptMattesMutualInformationImageToImageMetric.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkOptMattesMutualInformationImageToImageMetric.txx,v $ Language: C++ - Date: $Date: 2009-08-25 11:48:31 $ - Version: $Revision: 1.33 $ + Date: $Date: 2009-10-26 02:57:19 $ + Version: $Revision: 1.34 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -466,16 +466,21 @@ MattesMutualInformationImageToImageMetric<TFixedImage,TMovingImage> double windowTerm = static_cast<double>( (*iter).value ) / m_FixedImageBinSize - m_FixedImageNormalizedMin; - unsigned int pindex = static_cast<unsigned int>( windowTerm ); + OffsetValueType pindex = static_cast<OffsetValueType>( windowTerm ); // Make sure the extreme values are in valid bins if ( pindex < 2 ) { pindex = 2; } - else if ( pindex > (m_NumberOfHistogramBins - 3) ) + else { - pindex = m_NumberOfHistogramBins - 3; + const OffsetValueType nindex = + static_cast< OffsetValueType >( this->m_NumberOfHistogramBins ) - 3; + if ( pindex > nindex ) + { + pindex = nindex; + } } (*iter).valueIndex = pindex; @@ -542,15 +547,20 @@ MattesMutualInformationImageToImageMetric<TFixedImage,TMovingImage> / m_MovingImageBinSize - m_MovingImageNormalizedMin; // Same as floor - unsigned int movingImageParzenWindowIndex = - static_cast<unsigned int>( movingImageParzenWindowTerm ); + OffsetValueType movingImageParzenWindowIndex = + static_cast<OffsetValueType>( movingImageParzenWindowTerm ); if( movingImageParzenWindowIndex < 2 ) { movingImageParzenWindowIndex = 2; } - else if( movingImageParzenWindowIndex > (m_NumberOfHistogramBins - 3) ) + else { - movingImageParzenWindowIndex = m_NumberOfHistogramBins - 3; + const OffsetValueType nindex = + static_cast< OffsetValueType >( this->m_NumberOfHistogramBins ) - 3; + if( movingImageParzenWindowIndex > nindex ) + { + movingImageParzenWindowIndex = nindex; + } } unsigned int fixedImageParzenWindowIndex = @@ -837,17 +847,22 @@ MattesMutualInformationImageToImageMetric<TFixedImage,TMovingImage> double movingImageParzenWindowTerm = movingImageValue / m_MovingImageBinSize - m_MovingImageNormalizedMin; - unsigned int movingImageParzenWindowIndex = - static_cast<unsigned int>( movingImageParzenWindowTerm ); + OffsetValueType movingImageParzenWindowIndex = + static_cast<OffsetValueType>( movingImageParzenWindowTerm ); // Make sure the extreme values are in valid bins if ( movingImageParzenWindowIndex < 2 ) { movingImageParzenWindowIndex = 2; } - else if ( movingImageParzenWindowIndex > (m_NumberOfHistogramBins - 3) ) + else { - movingImageParzenWindowIndex = m_NumberOfHistogramBins - 3; + const OffsetValueType nindex = + static_cast< OffsetValueType >( this->m_NumberOfHistogramBins ) - 3; + if ( movingImageParzenWindowIndex > nindex ) + { + movingImageParzenWindowIndex = nindex; + } } // Since a zero-order BSpline (box car) kernel is used for diff --git a/Utilities/ITK/Code/Review/itkOptMeanSquaresImageToImageMetric.h b/Utilities/ITK/Code/Review/itkOptMeanSquaresImageToImageMetric.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Review/itkOptMeanSquaresImageToImageMetric.txx b/Utilities/ITK/Code/Review/itkOptMeanSquaresImageToImageMetric.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Review/itkOptResampleImageFilter.h b/Utilities/ITK/Code/Review/itkOptResampleImageFilter.h old mode 100644 new mode 100755 index 9b4df52c8c62789dbce96108cebeb6905d43f492..34811888fc86df4aed7a75b9fe37ff7f1803c4c7 --- a/Utilities/ITK/Code/Review/itkOptResampleImageFilter.h +++ b/Utilities/ITK/Code/Review/itkOptResampleImageFilter.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkOptResampleImageFilter.h,v $ Language: C++ - Date: $Date: 2009-04-23 03:43:42 $ - Version: $Revision: 1.7 $ + Date: $Date: 2009-09-16 15:34:33 $ + Version: $Revision: 1.8 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -100,6 +100,9 @@ public: itkStaticConstMacro(InputImageDimension, unsigned int, TInputImage::ImageDimension); + /** base type for images of the current ImageDimension */ + typedef ImageBase<itkGetStaticConstMacro(ImageDimension)> ImageBaseType; + /** Image pixel value typedef. */ typedef typename TOutputImage::PixelType PixelType; typedef typename TInputImage::PixelType InputPixelType; @@ -202,22 +205,7 @@ public: itkGetConstReferenceMacro(OutputDirection, DirectionType); /** Helper method to set the output parameters based on this image */ - void SetOutputParametersFromImage ( typename OutputImageType::Pointer Image ) - { - this->SetOutputOrigin ( Image->GetOrigin() ); - this->SetOutputSpacing ( Image->GetSpacing() ); - this->SetOutputDirection ( Image->GetDirection() ); - this->SetSize ( Image->GetLargestPossibleRegion().GetSize() ); - } - - /** Helper method to set the output parameters based on this image */ - void SetOutputParametersFromConstImage ( typename OutputImageType::ConstPointer Image ) - { - this->SetOutputOrigin ( Image->GetOrigin() ); - this->SetOutputSpacing ( Image->GetSpacing() ); - this->SetOutputDirection ( Image->GetDirection() ); - this->SetSize ( Image->GetLargestPossibleRegion().GetSize() ); - } + void SetOutputParametersFromImage ( const ImageBaseType * image ); /** Set the start index of the output largest possible region. * The default is an index of all zeros. */ diff --git a/Utilities/ITK/Code/Review/itkOptResampleImageFilter.txx b/Utilities/ITK/Code/Review/itkOptResampleImageFilter.txx old mode 100644 new mode 100755 index c9ec7e72a3681f59fc5d2efabc4e1d0c1f3606af..cfb2932a0321288d865909e691e12cc886019042 --- a/Utilities/ITK/Code/Review/itkOptResampleImageFilter.txx +++ b/Utilities/ITK/Code/Review/itkOptResampleImageFilter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkOptResampleImageFilter.txx,v $ Language: C++ - Date: $Date: 2009-08-24 13:49:19 $ - Version: $Revision: 1.9 $ + Date: $Date: 2009-09-16 15:34:33 $ + Version: $Revision: 1.10 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -126,6 +126,20 @@ ResampleImageFilter<TInputImage,TOutputImage,TInterpolatorPrecisionType> this->SetOutputOrigin( p ); } +/** Helper method to set the output parameters based on this image */ +template <class TInputImage, + class TOutputImage, + class TInterpolatorPrecisionType> +void +ResampleImageFilter<TInputImage,TOutputImage,TInterpolatorPrecisionType> +::SetOutputParametersFromImage ( const ImageBaseType * image ) +{ + this->SetOutputOrigin ( image->GetOrigin() ); + this->SetOutputSpacing ( image->GetSpacing() ); + this->SetOutputDirection ( image->GetDirection() ); + this->SetOutputStartIndex ( image->GetLargestPossibleRegion().GetIndex() ); + this->SetSize ( image->GetLargestPossibleRegion().GetSize() ); +} /** * Set up state of filter before multi-threading. diff --git a/Utilities/ITK/Code/Review/itkOptSimpleContourExtractorImageFilter.h b/Utilities/ITK/Code/Review/itkOptSimpleContourExtractorImageFilter.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Review/itkOptSimpleContourExtractorImageFilter.txx b/Utilities/ITK/Code/Review/itkOptSimpleContourExtractorImageFilter.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Review/itkPhilipsPAR.cxx b/Utilities/ITK/Code/Review/itkPhilipsPAR.cxx index 3c914ccb7aa64788a2ef5a07425cf46924599160..47e3525148b4131db4b61cb408ffd2b50d34b929 100644 --- a/Utilities/ITK/Code/Review/itkPhilipsPAR.cxx +++ b/Utilities/ITK/Code/Review/itkPhilipsPAR.cxx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkPhilipsPAR.cxx,v $ Language: C++ - Date: $Date: 2009-04-29 12:17:22 $ - Version: $Revision: 1.11 $ + Date: $Date: 2009-11-22 13:42:42 $ + Version: $Revision: 1.13 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -2203,7 +2203,7 @@ bool PhilipsPAR::GetDiffusionGradientOrientationAndBValues(std::string parFile, lineIncrement = 101; } - try + try { this->ReadPAR(parFile, &tempPar); } @@ -2262,7 +2262,7 @@ bool PhilipsPAR::GetLabelTypesASL(std::string parFile, int aslLabelNumber = -1; int lineIncrement = 101; - try + try { this->ReadPAR(parFile, &tempPar); } diff --git a/Utilities/ITK/Code/Review/itkPhilipsRECImageIO.cxx b/Utilities/ITK/Code/Review/itkPhilipsRECImageIO.cxx index 04194a4accde05614dd2f58ebaba670b26fc8e2b..6abcd72104742b8dac6da1eb430f1d9ab71e3b90 100644 --- a/Utilities/ITK/Code/Review/itkPhilipsRECImageIO.cxx +++ b/Utilities/ITK/Code/Review/itkPhilipsRECImageIO.cxx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkPhilipsRECImageIO.cxx,v $ Language: C++ - Date: $Date: 2009-04-29 12:20:40 $ - Version: $Revision: 1.13 $ + Date: $Date: 2009-11-29 02:06:56 $ + Version: $Revision: 1.14 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -450,9 +450,13 @@ void PhilipsRECImageIO::PrintSelf(std::ostream& os, Indent indent) const Superclass::PrintSelf(os, indent); } -int PhilipsRECImageIO::GetSliceIndex(int index) +PhilipsRECImageIO::IndexValueType +PhilipsRECImageIO::GetSliceIndex(IndexValueType index) const { - if( (index < 0) || (index > (int)(this->m_SliceIndex->size()-1)) ) + IndexValueType maximumSliceNumber = + Math::CastWithRangeCheck< IndexValueType, size_t >( this->m_SliceIndex->size() ) - 1; + + if( (index < 0) || (index > maximumSliceNumber ) ) { return -1; } @@ -501,12 +505,13 @@ void PhilipsRECImageIO::Read(void* buffer) } // read image a slice at a time (sorted). - unsigned int imageSliceSizeInBytes = this->GetImageSizeInBytes() - /(this->m_Dimensions[2]*this->m_Dimensions[3]); - for(unsigned int slice=0; slice<this->m_Dimensions[2]*this->m_Dimensions[3]; - slice++) + const SizeType numberOfPixelsInOneSlice = this->m_Dimensions[2]*this->m_Dimensions[3]; // BUG ? + + SizeType imageSliceSizeInBytes = this->GetImageSizeInBytes() / numberOfPixelsInOneSlice; + + for( IndexValueType slice=0; slice < numberOfPixelsInOneSlice; slice++) { - int realIndex = this->GetSliceIndex((int)slice); + IndexValueType realIndex = this->GetSliceIndex((int)slice); if( realIndex < 0 ) { OStringStream message; @@ -519,8 +524,10 @@ void PhilipsRECImageIO::Read(void* buffer) ITK_LOCATION); throw exception; } - ::gzseek( file_p, (unsigned int)realIndex*imageSliceSizeInBytes, SEEK_SET ); - ::gzread( file_p, p+(slice*imageSliceSizeInBytes), imageSliceSizeInBytes); + const z_off_t offset = Math::CastWithRangeCheck< z_off_t, SizeType >( realIndex * imageSliceSizeInBytes ); + ::gzseek( file_p, offset, SEEK_SET ); + ::gzread( file_p, p+(slice*imageSliceSizeInBytes), + Math::CastWithRangeCheck< unsigned int, SizeType >( imageSliceSizeInBytes) ); } gzclose( file_p ); SwapBytesIfNecessary( buffer, numberOfPixels ); @@ -580,7 +587,7 @@ void PhilipsRECImageIO::ReadImageInformation() PhilipsPAR::Pointer philipsPAR = PhilipsPAR::New(); try { - philipsPAR->ReadPAR( HeaderFileName, &par); + philipsPAR->ReadPAR( HeaderFileName, &par); } catch(itk::ExceptionObject &err) { diff --git a/Utilities/ITK/Code/Review/itkPhilipsRECImageIO.h b/Utilities/ITK/Code/Review/itkPhilipsRECImageIO.h index 15541b7767505d518aa2e532beb81180af90c5b3..473a59892cd713d2545d2b25f617360d252c8d1f 100644 --- a/Utilities/ITK/Code/Review/itkPhilipsRECImageIO.h +++ b/Utilities/ITK/Code/Review/itkPhilipsRECImageIO.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkPhilipsRECImageIO.h,v $ Language: C++ - Date: $Date: 2009-03-19 14:20:58 $ - Version: $Revision: 1.6 $ + Date: $Date: 2010-01-22 10:03:46 $ + Version: $Revision: 1.8 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -81,7 +81,8 @@ public: * 4 = Special/Processed. */ typedef vnl_vector_fixed< int, 8 > ImageTypesType; typedef vnl_vector_fixed< int, 8 > ScanningSequencesType; - typedef std::vector< int > SliceIndexType; + typedef Superclass::IndexValueType IndexValueType; + typedef std::vector< IndexValueType > SliceIndexType; typedef vnl_vector_fixed< double, 3 > ImageTypeRescaleValuesType; typedef VectorContainer< unsigned int, ImageTypeRescaleValuesType > @@ -118,7 +119,7 @@ public: /*-------- This part of the interfaces deals with writing data. ----- */ /** Determine if the file can be written with this ImageIO implementation. - * \param FileNameToWrite The name of the file to test for writing. + * FileNameToWrite The name of the file to test for writing. * \author Don C. Bigler * \post This function will always return false (Not implemented). * \return Returns true if this ImageIO can write the file specified. @@ -151,7 +152,7 @@ private: PhilipsRECImageIO(const Self&); //purposely not implemented void operator=(const Self&); //purposely not implemented void SwapBytesIfNecessary(void * buffer, unsigned long numberOfPixels); - int GetSliceIndex(int index); + IndexValueType GetSliceIndex(IndexValueType index) const; SliceIndexType * m_SliceIndex; ImageIOBase::ByteOrder m_MachineByteOrder; diff --git a/Utilities/ITK/Code/Review/itkPriorityQueueContainer.h b/Utilities/ITK/Code/Review/itkPriorityQueueContainer.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Review/itkQuadEdgeMeshBorderTransform.h b/Utilities/ITK/Code/Review/itkQuadEdgeMeshBorderTransform.h old mode 100644 new mode 100755 index 161eab2e669b5f7df1fa876684bcb5da92577836..0ce9825eb081f85e999bdb7f1d597e580247a9c2 --- a/Utilities/ITK/Code/Review/itkQuadEdgeMeshBorderTransform.h +++ b/Utilities/ITK/Code/Review/itkQuadEdgeMeshBorderTransform.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkQuadEdgeMeshBorderTransform.h,v $ Language: C++ - Date: $Date: 2009-04-23 03:43:42 $ - Version: $Revision: 1.5 $ + Date: $Date: 2009-09-17 11:14:57 $ + Version: $Revision: 1.6 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -44,7 +44,7 @@ public: typedef SmartPointer< const Self > ConstPointer; typedef TInputMesh InputMeshType; - typedef typename InputMeshType::Pointer InputMeshPointer; + typedef typename InputMeshType::ConstPointer InputMeshConstPointer; typedef typename InputMeshType::CoordRepType InputCoordRepType; typedef typename InputMeshType::PointType InputPointType; typedef typename InputMeshType::Traits InputTraits; diff --git a/Utilities/ITK/Code/Review/itkQuadEdgeMeshBorderTransform.txx b/Utilities/ITK/Code/Review/itkQuadEdgeMeshBorderTransform.txx old mode 100644 new mode 100755 index 50805f61f92dec9d205bf09263ef2427590270bd..ca29fbf43353667791bbd786e549680de2e57091 --- a/Utilities/ITK/Code/Review/itkQuadEdgeMeshBorderTransform.txx +++ b/Utilities/ITK/Code/Review/itkQuadEdgeMeshBorderTransform.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkQuadEdgeMeshBorderTransform.txx,v $ Language: C++ - Date: $Date: 2009-04-22 01:41:44 $ - Version: $Revision: 1.8 $ + Date: $Date: 2009-11-22 23:27:38 $ + Version: $Revision: 1.10 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -60,7 +60,7 @@ QuadEdgeMeshBorderTransform< TInputMesh, TOutputMesh > BoundaryRepresentativeEdgesPointer boundaryRepresentativeEdges = BoundaryRepresentativeEdgesType::New( ); - InputMeshPointer input = this->GetInput( ); + InputMeshConstPointer input = this->GetInput( ); InputEdgeListType* list = boundaryRepresentativeEdges->Evaluate( *input ); InputQEType* bdryEdge = ( *list->begin( ) ); @@ -75,6 +75,7 @@ QuadEdgeMeshBorderTransform< TInputMesh, TOutputMesh > } this->m_Border.resize( i ); + delete list; } @@ -95,9 +96,9 @@ QuadEdgeMeshBorderTransform< TInputMesh, TOutputMesh >:: ComputeLongestBorder( ) { BoundaryRepresentativeEdgesPointer - boundaryRepresentativeEdges = BoundaryRepresentativeEdgesType::New( ); + boundaryRepresentativeEdges = BoundaryRepresentativeEdgesType::New( ); - InputMeshPointer input = this->GetInput( ); + InputMeshConstPointer input = this->GetInput( ); InputEdgeListPointerType list = boundaryRepresentativeEdges->Evaluate( *input ); @@ -134,9 +135,9 @@ QuadEdgeMeshBorderTransform< TInputMesh, TOutputMesh >:: ComputeLargestBorder( ) { BoundaryRepresentativeEdgesPointer - boundaryRepresentativeEdges = BoundaryRepresentativeEdgesType::New( ); + boundaryRepresentativeEdges = BoundaryRepresentativeEdgesType::New( ); - InputMeshPointer input = this->GetInput( ); + InputMeshConstPointer input = this->GetInput( ); InputEdgeListType* list = boundaryRepresentativeEdges->Evaluate( *input ); @@ -164,8 +165,9 @@ ComputeLargestBorder( ) oborder_it = b_it; } } - return oborder_it; + delete list; + return oborder_it; } @@ -175,11 +177,11 @@ void QuadEdgeMeshBorderTransform< TInputMesh, TOutputMesh > ::DiskTransform( ) { - InputMeshPointer input = this->GetInput( ); + InputMeshConstPointer input = this->GetInput( ); size_t NbBoundaryPt = this->m_BoundaryPtMap.size( ); - InputCoordRepType r = RadiusMaxSquare( ); + InputCoordRepType r = this->RadiusMaxSquare( ); InputCoordRepType two_r = 2.0 * r; InputCoordRepType inv_two_r = 1.0 / two_r; @@ -248,9 +250,9 @@ typename QuadEdgeMeshBorderTransform< TInputMesh, TOutputMesh >::InputCoordRepTy QuadEdgeMeshBorderTransform< TInputMesh, TOutputMesh > ::RadiusMaxSquare( ) { - InputMeshPointer input = this->GetInput( ); + InputMeshConstPointer input = this->GetInput( ); - InputPointType center = GetMeshBarycentre( ); + InputPointType center = this->GetMeshBarycentre( ); InputCoordRepType oRmax( 0.), r; @@ -282,19 +284,18 @@ typename QuadEdgeMeshBorderTransform< TInputMesh, TOutputMesh >::InputPointType QuadEdgeMeshBorderTransform< TInputMesh, TOutputMesh > ::GetMeshBarycentre( ) { - InputMeshPointer input = this->GetInput( ); + InputMeshConstPointer input = this->GetInput( ); InputPointType oCenter; oCenter.Fill( 0.0 ); - InputPointsContainer* points = input->GetPoints( ); + const InputPointsContainer * points = input->GetPoints( ); InputPointType pt; unsigned int i; - for( InputPointsContainerConstIterator PointIterator = points->Begin( ); - PointIterator != points->End( ); - ++PointIterator ) + InputPointsContainerConstIterator PointIterator = points->Begin( ); + while( PointIterator != points->End( ) ) { pt = PointIterator.Value( ); @@ -302,6 +303,7 @@ QuadEdgeMeshBorderTransform< TInputMesh, TOutputMesh > { oCenter[i] += pt[i]; } + ++PointIterator; } InputCoordRepType invNbOfPoints = 1.0 / @@ -327,12 +329,15 @@ void QuadEdgeMeshBorderTransform< TInputMesh, TOutputMesh > { default: case SQUARE_BORDER_TRANSFORM: - ArcLengthSquareTransform( ); - break; - + { + this->ArcLengthSquareTransform( ); + break; + } case DISK_BORDER_TRANSFORM: - DiskTransform( ); - break; + { + this->DiskTransform( ); + break; + } } } @@ -346,7 +351,7 @@ QuadEdgeMeshBorderTransform< TInputMesh, TOutputMesh > BoundaryRepresentativeEdgesPointer boundaryRepresentativeEdges = BoundaryRepresentativeEdgesType::New( ); - InputMeshPointer input = this->GetInput( ); + InputMeshConstPointer input = this->GetInput( ); InputEdgeListType* list = boundaryRepresentativeEdges->Evaluate( *input ); InputQEType* bdryEdge = ( *list->begin( ) ); @@ -430,6 +435,8 @@ QuadEdgeMeshBorderTransform< TInputMesh, TOutputMesh > pt[1] = - this->m_Radius + ( Length[i] - 3.0 * EdgeLength ); this->m_Border[ i++ ] = pt; } + + delete list; } diff --git a/Utilities/ITK/Code/Review/itkQuadEdgeMeshDecimationQuadricElementHelper.h b/Utilities/ITK/Code/Review/itkQuadEdgeMeshDecimationQuadricElementHelper.h index aff15a993d3cd6495a22e289a413ab0b7718e7a4..a4025484f1c685029eb58338daeed700acb82232 100644 --- a/Utilities/ITK/Code/Review/itkQuadEdgeMeshDecimationQuadricElementHelper.h +++ b/Utilities/ITK/Code/Review/itkQuadEdgeMeshDecimationQuadricElementHelper.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkQuadEdgeMeshDecimationQuadricElementHelper.h,v $ Language: C++ - Date: $Date: 2008-10-01 18:36:29 $ - Version: $Revision: 1.5 $ + Date: $Date: 2010-03-24 21:51:55 $ + Version: $Revision: 1.8 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -42,10 +42,6 @@ public: itkStaticConstMacro(NumberOfCoefficients, unsigned int, PointDimension * ( PointDimension + 1 ) / 2 + PointDimension + 1); -// static const unsigned int PointDimension = PointType::PointDimension; -// static const unsigned int NumberOfCoefficients = -// PointDimension * ( PointDimension + 1 ) / 2 + PointDimension + 1; - typedef typename PointType::VectorType VectorType; typedef vnl_matrix< CoordType > VNLMatrixType; typedef vnl_vector_fixed< CoordType, @@ -58,7 +54,9 @@ public: QuadEdgeMeshDecimationQuadricElementHelper(): m_Coefficients( itk::NumericTraits< CoordType >::Zero ), m_A( PointDimension, PointDimension, itk::NumericTraits< CoordType >::Zero ), - m_B( itk::NumericTraits< CoordType >::Zero ) + m_B( itk::NumericTraits< CoordType >::Zero ), + m_SVDAbsoluteThreshold( static_cast< CoordType >( 1e-6 ) ), + m_SVDRelativeThreshold( static_cast< CoordType >( 1e-3 ) ) { this->m_Rank = PointDimension; } @@ -66,7 +64,9 @@ public: QuadEdgeMeshDecimationQuadricElementHelper( const CoefficientVectorType& iCoefficients ): m_Coefficients( iCoefficients ), m_A( PointDimension, PointDimension, itk::NumericTraits< CoordType >::Zero ), - m_B( itk::NumericTraits< CoordType >::Zero ) + m_B( itk::NumericTraits< CoordType >::Zero ), + m_SVDAbsoluteThreshold( static_cast< CoordType >( 1e-3 ) ), + m_SVDRelativeThreshold( static_cast< CoordType >( 1e-3 ) ) { this->m_Rank = PointDimension; this->ComputeAMatrixAndBVector(); @@ -98,54 +98,69 @@ public: } ///TODO this method should be really optimized!!! - inline CoordType ComputeError( const PointType& iP ) + inline CoordType ComputeError( const PointType& iP ) const { + // ComputeAMatrixAndBVector(); + vnl_svd< CoordType > svd( m_A, m_SVDAbsoluteThreshold ); + svd.zero_out_relative( m_SVDRelativeThreshold ); + CoordType oError = inner_product( iP.GetVnlVector(), svd.recompose() * iP.GetVnlVector() ); + + return this->m_Coefficients[ this->m_Coefficients.size() - 1] - oError; + /* CoordType oError( 0. ); - + std::vector< CoordType > pt( PointDimension + 1, 1. ); - unsigned int dim1 = 0; - unsigned int k =0; + unsigned int dim1( 0 ), dim2, k( 0 ); while( dim1 < PointDimension ) { pt[dim1] = iP[dim1]; - dim1++; + ++dim1; } - for( dim1 = 0; dim1 < PointDimension + 1; dim1++ ) + for( dim1 = 0; dim1 < PointDimension + 1; ++dim1 ) { oError += this->m_Coefficients[k++] * pt[dim1] * pt[dim1]; - for( unsigned int dim2 = dim1 + 1; dim2 < PointDimension + 1; dim2++ ) + for( dim2 = dim1 + 1; dim2 < PointDimension + 1; ++dim2 ) { oError += 2. * this->m_Coefficients[k++] * pt[dim1] * pt[dim2]; } } - return oError; + oError += this->m_Coefficients[k++]; + + return oError;*/ } ///TODO this method should be really optimized!!! - inline CoordType ComputeErrorAtOptimalLocation() - { - return ComputeError( ComputeOptimalLocation() ); - } + inline CoordType ComputeErrorAtOptimalLocation( const PointType& iP ) + { + PointType optimal_location = ComputeOptimalLocation( iP ); + return ComputeError( optimal_location ); + } - PointType ComputeOptimalLocation() - { + PointType ComputeOptimalLocation( const PointType& iP ) + { ComputeAMatrixAndBVector(); - vnl_svd< CoordType > svd( m_A ); - svd.zero_out_relative( 1e-10 ); + + vnl_svd< CoordType > svd( m_A, m_SVDAbsoluteThreshold ); + svd.zero_out_relative( m_SVDRelativeThreshold ); + m_Rank = svd.rank(); - VNLVectorType location = svd.solve( m_B.as_vector() ); + VNLVectorType y = m_B.as_vector() - m_A * iP.GetVnlVector(); + + VNLVectorType displacement = svd.solve( y ); PointType oP; for( unsigned int dim = 0; dim < PointDimension; dim++ ) - oP[dim] = location[dim]; + { + oP[dim] = iP[dim] + displacement[dim]; + } return oP; - } + } ///TODO to be implemented!!! PointType ComputeOptimalLocation( @@ -153,42 +168,43 @@ public: { } - PointType ComputeOptimalLocation( - const CoordType& iValue ) - { - ComputeAMatrixAndBVector(); - vnl_svd< CoordType > svd( m_A ); - svd.zero.zero_out_relative( iValue ); - m_Rank = svd.rank(); - - VNLVectorType location = svd.solve( m_B ); - PointType oP; - - for( unsigned int dim = 0; dim < PointDimension; dim++ ) - oP[dim] = location[dim]; - - return oP; - } +// PointType ComputeOptimalLocation( +// const CoordType& iValue ) +// { +// ComputeAMatrixAndBVector(); +// vnl_svd< CoordType > svd( m_A ); +// svd.zero.zero_out_relative( iValue ); +// m_Rank = svd.rank(); +// +// VNLVectorType location = svd.solve( m_B ); +// PointType oP; +// +// for( unsigned int dim = 0; dim < PointDimension; dim++ ) +// oP[dim] = location[dim]; +// +// return oP; +// } void AddTriangle( const PointType& iP1, const PointType& iP2, const PointType& iP3, const CoordType& iWeight = static_cast< CoordType >( 1. ) ) { - AddPoint( iP1, TriangleType::ComputeNormal( iP1, iP2, iP3 ), iWeight ); + VectorType N = TriangleType::ComputeNormal( iP1, iP2, iP3 ); + AddPoint( iP1, N, iWeight ); } void AddPoint( const PointType& iP, const VectorType& iN, const CoordType& iWeight = static_cast< CoordType >( 1. ) ) { - unsigned int k = 0; + unsigned int k( 0 ), dim1, dim2; CoordType d = -iN * iP.GetVectorFromOrigin(); - for( unsigned int dim1 = 0; dim1 < PointDimension; dim1++ ) + for( dim1 = 0; dim1 < PointDimension; ++dim1 ) { - for( unsigned int dim2 = dim1; dim2 < PointDimension; dim2++ ) + for( dim2 = dim1; dim2 < PointDimension; ++dim2 ) { this->m_Coefficients[k++] += iWeight * iN[dim1] * iN[dim2]; } @@ -249,19 +265,23 @@ protected: VNLMatrixType m_A; VNLVectorType m_B; unsigned int m_Rank; + CoordType m_SVDAbsoluteThreshold; + CoordType m_SVDRelativeThreshold; + //bool m_MatrixFilled; void ComputeAMatrixAndBVector() { - unsigned int k = 0; + unsigned int k( 0 ), dim1, dim2; - for( unsigned int dim1 = 0; dim1 < PointDimension; dim1++ ) + for( dim1 = 0; dim1 < PointDimension; ++dim1 ) { - for( unsigned int dim2 = dim1; dim2 < PointDimension; dim2++ ) + for( dim2 = dim1; dim2 < PointDimension; ++dim2 ) { m_A[dim1][dim2] = m_A[dim2][dim1] = m_Coefficients[k++]; } m_B[dim1] = - m_Coefficients[k++]; } + //m_MatrixFilled = true; } }; diff --git a/Utilities/ITK/Code/Review/itkQuadEdgeMeshDiscreteCurvatureEstimator.h b/Utilities/ITK/Code/Review/itkQuadEdgeMeshDiscreteCurvatureEstimator.h index 08e8600ed0b77e03db1b12ebfd24f26c254b1500..14c05b85727b14e0b72467bd5747c4dfd50ab1a2 100644 --- a/Utilities/ITK/Code/Review/itkQuadEdgeMeshDiscreteCurvatureEstimator.h +++ b/Utilities/ITK/Code/Review/itkQuadEdgeMeshDiscreteCurvatureEstimator.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkQuadEdgeMeshDiscreteCurvatureEstimator.h,v $ Language: C++ - Date: $Date: 2009-04-22 01:41:45 $ - Version: $Revision: 1.3 $ + Date: $Date: 2010-01-14 18:19:08 $ + Version: $Revision: 1.4 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -120,12 +120,15 @@ protected: OutputMeshPointer output = this->GetOutput(); OutputPointsContainerPointer points = output->GetPoints(); + OutputPointsContainerIterator p_it = points->Begin(); - for( OutputPointsContainerIterator p_it = points->Begin(); - p_it != points->End(); - p_it++ ) + OutputCurvatureType curvature; + + while( p_it != points->End() ) { - output->SetPointData( p_it->Index(), EstimateCurvature( p_it->Value() ) ); + curvature = EstimateCurvature( p_it->Value() ); + output->SetPointData( p_it->Index(), curvature ); + ++p_it; } } diff --git a/Utilities/ITK/Code/Review/itkQuadEdgeMeshDiscreteMeanCurvatureEstimator.h b/Utilities/ITK/Code/Review/itkQuadEdgeMeshDiscreteMeanCurvatureEstimator.h index 1b4d80459845f5dabaf03391048df460c00d7688..62ecd49b8187d04886351166ea8fd182e4be7cdf 100644 --- a/Utilities/ITK/Code/Review/itkQuadEdgeMeshDiscreteMeanCurvatureEstimator.h +++ b/Utilities/ITK/Code/Review/itkQuadEdgeMeshDiscreteMeanCurvatureEstimator.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkQuadEdgeMeshDiscreteMeanCurvatureEstimator.h,v $ Language: C++ - Date: $Date: 2008-10-01 22:00:55 $ - Version: $Revision: 1.2 $ + Date: $Date: 2010-01-14 18:19:08 $ + Version: $Revision: 1.3 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -30,7 +30,6 @@ namespace itk * authors: Mark Meyer, Mathieu Desbrun, Peter Schroder, Alan H. Barr * conference: VisMath '02 * location: Berlin (Germany) - * \author: Arnaud Gelas, Alexandre Gouaillard */ template< class TInputMesh, class TOutputMesh > class QuadEdgeMeshDiscreteMeanCurvatureEstimator : @@ -57,7 +56,7 @@ public: typedef typename Superclass::OutputQEType OutputQEType; typedef typename Superclass::OutputMeshTraits OutputMeshTraits; typedef typename Superclass::OutputCurvatureType OutputCurvatureType; - + typedef typename Superclass::TriangleType TriangleType; /** Run-time type information (and related methods). */ @@ -79,40 +78,72 @@ protected: OutputQEType* qe = iP.GetEdge( ); OutputCurvatureType oH( 0. ); + OutputVectorType Laplace; Laplace.Fill( 0. ); - + + OutputCurvatureType area( 0. ); + OutputVectorType normal; + normal.Fill( 0. ); + if( qe != 0 ) { - CoefficientType coefficent; + if( qe != qe->GetOnext() ) + { + CoefficientType coefficent; - OutputQEType* qe_it = qe; - OutputQEType* qe_it2; - OutputCurvatureType area( 0. ); - OutputPointType q0, q1; - OutputVectorType u; + OutputQEType* qe_it = qe; + OutputQEType* qe_it2; + + OutputCurvatureType temp_area; + OutputCoordType temp_coeff; + + OutputPointType q0, q1; + OutputVectorType face_normal; - if( qe_it != qe_it->GetOnext() ) - { - qe_it = qe; do { qe_it2 = qe_it->GetOnext(); q0 = output->GetPoint( qe_it->GetDestination() ); - Laplace += coefficent( output, qe_it ) * ( iP - q0 ); - area += ComputeMixedArea( qe_it, qe_it2 ); + q1 = output->GetPoint( qe_it2->GetDestination() ); + + temp_coeff = coefficent( output, qe_it ); + Laplace += temp_coeff * ( iP - q0 ); + + temp_area = ComputeMixedArea( qe_it, qe_it2 ); + area += temp_area; + + face_normal = TriangleType::ComputeNormal( q0, iP, q1 ); + normal += face_normal; + qe_it = qe_it2; } while( qe_it != qe ); - Laplace *= ( area > 1e-6 ? 0.25 /area : 0. ); - oH = Laplace.GetNorm(); + + if( area < 1e-6 ) + { + oH = 0.; + } + else + { + if( normal.GetSquaredNorm() > 0. ) + { + normal.Normalize(); + Laplace *= 0.25 / area; + oH = Laplace * normal; + } + else + { + oH = 0.; + } + } } } return oH; } private: - QuadEdgeMeshDiscreteMeanCurvatureEstimator( const Self& ); // purposely not implemented - void operator = ( const Self& ); // purposely not implemented + QuadEdgeMeshDiscreteMeanCurvatureEstimator( const Self& ); // purposely not implemented + void operator = ( const Self& ); // purposely not implemented }; diff --git a/Utilities/ITK/Code/Review/itkQuadEdgeMeshDiscretePrincipalCurvaturesEstimator.h b/Utilities/ITK/Code/Review/itkQuadEdgeMeshDiscretePrincipalCurvaturesEstimator.h index ff142cc494fb943a7a6b458e607a1a57382fe9b8..5e7a73a3e228e56ef50d99d85266c704d70b15d7 100644 --- a/Utilities/ITK/Code/Review/itkQuadEdgeMeshDiscretePrincipalCurvaturesEstimator.h +++ b/Utilities/ITK/Code/Review/itkQuadEdgeMeshDiscretePrincipalCurvaturesEstimator.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkQuadEdgeMeshDiscretePrincipalCurvaturesEstimator.h,v $ Language: C++ - Date: $Date: 2008-10-01 23:03:04 $ - Version: $Revision: 1.2 $ + Date: $Date: 2010-01-14 19:03:21 $ + Version: $Revision: 1.3 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -69,7 +69,7 @@ protected: OutputCurvatureType m_Gaussian; OutputCurvatureType m_Mean; - + void ComputeMeanAndGaussianCurvatures( const OutputPointType& iP ) { OutputMeshPointer output = this->GetOutput(); @@ -77,50 +77,70 @@ protected: OutputQEType* qe = iP.GetEdge( ); m_Mean = 0.; m_Gaussian = 0.; - + if( qe != 0 ) { OutputVectorType Laplace; Laplace.Fill( 0. ); - - CoefficientType coefficent; OutputQEType* qe_it = qe; - OutputQEType* qe_it2; + OutputCurvatureType area( 0. ), sum_theta( 0. ); - OutputPointType q0, q1; - OutputVectorType u; if( qe_it != qe_it->GetOnext() ) { qe_it = qe; + OutputQEType* qe_it2; + + OutputPointType q0, q1; + OutputVectorType face_normal; + + OutputVectorType normal; + normal.Fill( 0. ); + + OutputCurvatureType temp_area; + OutputCoordType temp_coeff; + + CoefficientType coefficent; + do { qe_it2 = qe_it->GetOnext(); q0 = output->GetPoint( qe_it->GetDestination() ); q1 = output->GetPoint( qe_it2->GetDestination() ); - - Laplace += coefficent( output, qe_it ) * ( iP - q0 ); + + temp_coeff = coefficent( output, qe_it ); + Laplace += temp_coeff * ( iP - q0 ); + // Compute Angle; sum_theta += static_cast< OutputCurvatureType >( TriangleType::ComputeAngle( q0, iP, q1 ) ); - - area += ComputeMixedArea( qe_it, qe_it2 ); + + temp_area = ComputeMixedArea( qe_it, qe_it2 ); + area += temp_area; + + face_normal = TriangleType::ComputeNormal( q0, iP, q1 ); + normal += face_normal; + qe_it = qe_it2; } while( qe_it != qe ); - area = ( area > 1e-10 ? ( 1. / area ) : 0. ); - Laplace *= 0.25 * area; - m_Mean = Laplace.GetNorm(); - m_Gaussian = ( 2. * vnl_math::pi - sum_theta ) * area; + + if( area > 1e-10 ) + { + area = 1. / area; + Laplace *= 0.25 * area; + m_Mean = Laplace * normal; + m_Gaussian = ( 2. * vnl_math::pi - sum_theta ) * area; + } } } } - + virtual OutputCurvatureType ComputeDelta( ) { return vnl_math_max( 0., m_Mean * m_Mean - m_Gaussian ); } - + private: QuadEdgeMeshDiscretePrincipalCurvaturesEstimator( const Self& ); // purposely not implemented void operator = ( const Self& ); // purposely not implemented diff --git a/Utilities/ITK/Code/Review/itkQuadEdgeMeshEdgeMergeDecimationFilter.txx b/Utilities/ITK/Code/Review/itkQuadEdgeMeshEdgeMergeDecimationFilter.txx index fe3ab8ae76ca5aab7a03b3692b26ca81ec50220b..5fcae570948bda01ea7e127f44ccdb59d8b7eb40 100644 --- a/Utilities/ITK/Code/Review/itkQuadEdgeMeshEdgeMergeDecimationFilter.txx +++ b/Utilities/ITK/Code/Review/itkQuadEdgeMeshEdgeMergeDecimationFilter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkQuadEdgeMeshEdgeMergeDecimationFilter.txx,v $ Language: C++ - Date: $Date: 2009-03-25 14:58:44 $ - Version: $Revision: 1.11 $ + Date: $Date: 2010-03-24 21:51:55 $ + Version: $Revision: 1.12 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -42,13 +42,16 @@ QuadEdgeMeshEdgeMergeDecimationFilter< TInput, TOutput, TCriterion >:: { edge = m_PriorityQueue->Peek()->m_Element; m_PriorityQueue->Pop(); - delete m_QueueMapper[edge]; - m_QueueMapper.erase( edge ); + + QueueMapIterator it = m_QueueMapper.find( edge ); + delete it->second; + m_QueueMapper.erase( it ); } } template< class TInput, class TOutput, class TCriterion > -void QuadEdgeMeshEdgeMergeDecimationFilter< TInput, TOutput, TCriterion >:: +void +QuadEdgeMeshEdgeMergeDecimationFilter< TInput, TOutput, TCriterion >:: FillPriorityQueue() { OutputMeshPointer output = this->GetOutput(); @@ -61,7 +64,9 @@ FillPriorityQueue() while( it != end ) { - if ( ( edge = dynamic_cast< OutputEdgeCellType* >( it.Value( ) ) ) ) + edge = dynamic_cast< OutputEdgeCellType* >( it.Value( ) ); + + if ( edge ) { PushElement( edge->GetQEGeom( ) ); } @@ -70,7 +75,8 @@ FillPriorityQueue() } template< class TInput, class TOutput, class TCriterion > -void QuadEdgeMeshEdgeMergeDecimationFilter< TInput, TOutput, TCriterion >:: +void +QuadEdgeMeshEdgeMergeDecimationFilter< TInput, TOutput, TCriterion >:: PushElement( OutputQEType* iEdge ) { OutputPointIdentifier id_org = iEdge->GetOrigin(); @@ -87,7 +93,8 @@ PushElement( OutputQEType* iEdge ) } template< class TInput, class TOutput, class TCriterion > -bool QuadEdgeMeshEdgeMergeDecimationFilter< TInput, TOutput, TCriterion >:: +bool +QuadEdgeMeshEdgeMergeDecimationFilter< TInput, TOutput, TCriterion >:: #ifdef NDEBUG IsEdgeOKToBeProcessed( OutputQEType* iEdge ) #else @@ -148,7 +155,8 @@ IsEdgeOKToBeProcessed( OutputQEType* ) } template< class TInput, class TOutput, class TCriterion > -void QuadEdgeMeshEdgeMergeDecimationFilter< TInput, TOutput, TCriterion >:: +void +QuadEdgeMeshEdgeMergeDecimationFilter< TInput, TOutput, TCriterion >:: Extract() { OutputMeshPointer output = this->GetOutput(); @@ -159,13 +167,15 @@ Extract() m_Priority = m_PriorityQueue->Peek( )->m_Priority; m_PriorityQueue->Pop(); - delete m_QueueMapper[m_Element]; - m_QueueMapper.erase( m_Element ); + QueueMapIterator it = m_QueueMapper.find( m_Element ); + delete it->second; + m_QueueMapper.erase( it ); } while ( !IsEdgeOKToBeProcessed( m_Element ) ); } template< class TInput, class TOutput, class TCriterion > -void QuadEdgeMeshEdgeMergeDecimationFilter< TInput, TOutput, TCriterion >:: +void +QuadEdgeMeshEdgeMergeDecimationFilter< TInput, TOutput, TCriterion >:: DeleteElement( OutputQEType* iEdge ) { if ( iEdge ) // this test can be removed @@ -187,7 +197,8 @@ DeleteElement( OutputQEType* iEdge ) } template< class TInput, class TOutput, class TCriterion > -void QuadEdgeMeshEdgeMergeDecimationFilter< TInput, TOutput, TCriterion >:: +void +QuadEdgeMeshEdgeMergeDecimationFilter< TInput, TOutput, TCriterion >:: PushOrUpdateElement( OutputQEType* iEdge ) { OutputQEType* temp = iEdge; @@ -219,7 +230,8 @@ PushOrUpdateElement( OutputQEType* iEdge ) template< class TInput, class TOutput, class TCriterion > -void QuadEdgeMeshEdgeMergeDecimationFilter< TInput, TOutput, TCriterion >:: +void +QuadEdgeMeshEdgeMergeDecimationFilter< TInput, TOutput, TCriterion >:: JoinVertexFailed( ) { typename OperatorType::EdgeStatusType @@ -277,7 +289,8 @@ this->m_Iteration ); } template< class TInput, class TOutput, class TCriterion > -void QuadEdgeMeshEdgeMergeDecimationFilter< TInput, TOutput, TCriterion >:: +void +QuadEdgeMeshEdgeMergeDecimationFilter< TInput, TOutput, TCriterion >:: DeletePoint( const OutputPointIdentifier& iIdToBeDeleted, const OutputPointIdentifier& iRemaining ) { @@ -286,7 +299,8 @@ DeletePoint( const OutputPointIdentifier& iIdToBeDeleted, } template< class TInput, class TOutput, class TCriterion > -bool QuadEdgeMeshEdgeMergeDecimationFilter< TInput, TOutput, TCriterion >:: +bool +QuadEdgeMeshEdgeMergeDecimationFilter< TInput, TOutput, TCriterion >:: ProcessWithoutAnyTopologicalGuarantee() { OutputMeshPointer output = this->GetOutput(); @@ -299,16 +313,22 @@ ProcessWithoutAnyTopologicalGuarantee() bool to_be_processed( true ); if ( m_Relocate ) + { pt = Relocate( m_Element ); + } else + { pt = output->GetPoint( idx ); + } ///TODO use CheckOrientation!!! // if( m_CheckOrientation ) // to_be_processed = CheckOrientation( m_Element, idx, pt ); if( !to_be_processed ) + { return false; + } std::list< OutputQEType* > list_qe_to_be_deleted; OutputQEType* temp = m_Element->GetOnext(); @@ -326,21 +346,24 @@ ProcessWithoutAnyTopologicalGuarantee() temp = temp->GetOnext(); } - for( typename std::list< OutputQEType* >::iterator - it = list_qe_to_be_deleted.begin(); - it != list_qe_to_be_deleted.end(); - ++it ) + typename std::list< OutputQEType* >::iterator + it = list_qe_to_be_deleted.begin(); + + while( it != list_qe_to_be_deleted.end() ) { DeleteElement( *it ); + ++it; } if ( !m_JoinVertexFunction->Evaluate( m_Element ) ) { - for( typename std::list< OutputQEType* >::iterator - it = list_qe_to_be_deleted.begin(); - it != list_qe_to_be_deleted.end(); - ++it ) + it = list_qe_to_be_deleted.begin(); + + while( it != list_qe_to_be_deleted.end() ) + { PushOrUpdateElement( *it ); + ++it; + } JoinVertexFailed(); } @@ -378,8 +401,8 @@ ProcessWithoutAnyTopologicalGuarantee() template< class TInput, class TOutput, class TCriterion > -unsigned int QuadEdgeMeshEdgeMergeDecimationFilter< TInput, TOutput, TCriterion ->:: +unsigned int +QuadEdgeMeshEdgeMergeDecimationFilter< TInput, TOutput, TCriterion >:: CheckQEProcessingStatus( ) { OutputQEType* qe = m_Element; @@ -467,7 +490,8 @@ CheckQEProcessingStatus( ) } template< class TInput, class TOutput, class TCriterion > -bool QuadEdgeMeshEdgeMergeDecimationFilter< TInput, TOutput, TCriterion >:: +bool +QuadEdgeMeshEdgeMergeDecimationFilter< TInput, TOutput, TCriterion >:: ProcessWithTopologicalGuarantee() { if( m_Priority.first ) @@ -480,7 +504,8 @@ ProcessWithTopologicalGuarantee() } template< class TInput, class TOutput, class TCriterion > -size_t QuadEdgeMeshEdgeMergeDecimationFilter< TInput, TOutput, TCriterion >:: +size_t +QuadEdgeMeshEdgeMergeDecimationFilter< TInput, TOutput, TCriterion >:: NumberOfCommonVerticesIn0Ring( ) { OutputQEType* qe = m_Element; @@ -514,7 +539,8 @@ NumberOfCommonVerticesIn0Ring( ) template< class TInput, class TOutput, class TCriterion > -void QuadEdgeMeshEdgeMergeDecimationFilter< TInput, TOutput, TCriterion >:: +void +QuadEdgeMeshEdgeMergeDecimationFilter< TInput, TOutput, TCriterion >:: RemoveSamosa() { DeleteElement( m_Element->GetLnext( ) ); @@ -524,7 +550,8 @@ RemoveSamosa() } template< class TInput, class TOutput, class TCriterion > -void QuadEdgeMeshEdgeMergeDecimationFilter< TInput, TOutput, TCriterion >:: +void +QuadEdgeMeshEdgeMergeDecimationFilter< TInput, TOutput, TCriterion >:: TagElementOut( OutputQEType* iEdge ) { QueueMapIterator map_it = m_QueueMapper.find( iEdge ); @@ -546,7 +573,8 @@ TagElementOut( OutputQEType* iEdge ) } template< class TInput, class TOutput, class TCriterion > -void QuadEdgeMeshEdgeMergeDecimationFilter< TInput, TOutput, TCriterion >:: +void +QuadEdgeMeshEdgeMergeDecimationFilter< TInput, TOutput, TCriterion >:: RemoveEye() { OutputQEType* qe = m_Element; @@ -564,7 +592,8 @@ RemoveEye() } template< class TInput, class TOutput, class TCriterion > -bool QuadEdgeMeshEdgeMergeDecimationFilter< TInput, TOutput, TCriterion >:: +bool +QuadEdgeMeshEdgeMergeDecimationFilter< TInput, TOutput, TCriterion >:: IsCriterionSatisfied() { if( m_PriorityQueue->Empty() ) diff --git a/Utilities/ITK/Code/Review/itkQuadEdgeMeshEulerOperatorCreateCenterVertexFunction.h b/Utilities/ITK/Code/Review/itkQuadEdgeMeshEulerOperatorCreateCenterVertexFunction.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Review/itkQuadEdgeMeshEulerOperatorCreateCenterVertexFunction.txx b/Utilities/ITK/Code/Review/itkQuadEdgeMeshEulerOperatorCreateCenterVertexFunction.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Review/itkQuadEdgeMeshEulerOperatorDeleteCenterVertexFunction.h b/Utilities/ITK/Code/Review/itkQuadEdgeMeshEulerOperatorDeleteCenterVertexFunction.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Review/itkQuadEdgeMeshEulerOperatorDeleteCenterVertexFunction.txx b/Utilities/ITK/Code/Review/itkQuadEdgeMeshEulerOperatorDeleteCenterVertexFunction.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Review/itkQuadEdgeMeshEulerOperatorFlipEdgeFunction.h b/Utilities/ITK/Code/Review/itkQuadEdgeMeshEulerOperatorFlipEdgeFunction.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Review/itkQuadEdgeMeshEulerOperatorFlipEdgeFunction.txx b/Utilities/ITK/Code/Review/itkQuadEdgeMeshEulerOperatorFlipEdgeFunction.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Review/itkQuadEdgeMeshEulerOperatorJoinFacetFunction.h b/Utilities/ITK/Code/Review/itkQuadEdgeMeshEulerOperatorJoinFacetFunction.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Review/itkQuadEdgeMeshEulerOperatorJoinFacetFunction.txx b/Utilities/ITK/Code/Review/itkQuadEdgeMeshEulerOperatorJoinFacetFunction.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Review/itkQuadEdgeMeshEulerOperatorJoinVertexFunction.h b/Utilities/ITK/Code/Review/itkQuadEdgeMeshEulerOperatorJoinVertexFunction.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Review/itkQuadEdgeMeshEulerOperatorJoinVertexFunction.txx b/Utilities/ITK/Code/Review/itkQuadEdgeMeshEulerOperatorJoinVertexFunction.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Review/itkQuadEdgeMeshEulerOperatorSplitEdgeFunction.h b/Utilities/ITK/Code/Review/itkQuadEdgeMeshEulerOperatorSplitEdgeFunction.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Review/itkQuadEdgeMeshEulerOperatorSplitFacetFunction.h b/Utilities/ITK/Code/Review/itkQuadEdgeMeshEulerOperatorSplitFacetFunction.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Review/itkQuadEdgeMeshEulerOperatorSplitFacetFunction.txx b/Utilities/ITK/Code/Review/itkQuadEdgeMeshEulerOperatorSplitFacetFunction.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Review/itkQuadEdgeMeshEulerOperatorSplitVertexFunction.h b/Utilities/ITK/Code/Review/itkQuadEdgeMeshEulerOperatorSplitVertexFunction.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Review/itkQuadEdgeMeshEulerOperatorSplitVertexFunction.txx b/Utilities/ITK/Code/Review/itkQuadEdgeMeshEulerOperatorSplitVertexFunction.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Review/itkQuadEdgeMeshFrontIterator.h b/Utilities/ITK/Code/Review/itkQuadEdgeMeshFrontIterator.h index 757dd07cfbec2ac4c20c2653a44e73ee5c83f6a6..5e3216ade96eb613050d52bf75cc7f04bef932a3 100644 --- a/Utilities/ITK/Code/Review/itkQuadEdgeMeshFrontIterator.h +++ b/Utilities/ITK/Code/Review/itkQuadEdgeMeshFrontIterator.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkQuadEdgeMeshFrontIterator.h,v $ Language: C++ - Date: $Date: 2009-08-05 20:26:37 $ - Version: $Revision: 1.8 $ + Date: $Date: 2009-12-15 15:37:44 $ + Version: $Revision: 1.9 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -128,7 +128,7 @@ protected: typedef FrontType* FrontTypePointer; /** Whether an Origin (i.e. a vertex or a face since we either deal with - * primal or dual edges) was allready visited. + * primal or dual edges) was already visited. */ typedef MapContainer< QEOriginType, bool > IsVisitedContainerType; typedef typename IsVisitedContainerType::Pointer IsVisitedPointerType; @@ -138,7 +138,7 @@ public: QuadEdgeMeshFrontBaseIterator( MeshType* mesh = (MeshType*)0, bool start = true, QEType* seed = (QEType*)0 ); - virtual ~QuadEdgeMeshFrontBaseIterator( ) { } + virtual ~QuadEdgeMeshFrontBaseIterator( ); Self& operator=( const Self& r ) { diff --git a/Utilities/ITK/Code/Review/itkQuadEdgeMeshFrontIterator.txx b/Utilities/ITK/Code/Review/itkQuadEdgeMeshFrontIterator.txx index bef86bb3ce462e2049cf18474b9b33ec7acd1c4e..cd7559e46a796e2cfd1be22621bf8f9794ba4d09 100644 --- a/Utilities/ITK/Code/Review/itkQuadEdgeMeshFrontIterator.txx +++ b/Utilities/ITK/Code/Review/itkQuadEdgeMeshFrontIterator.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkQuadEdgeMeshFrontIterator.txx,v $ Language: C++ - Date: $Date: 2009-02-10 05:07:50 $ - Version: $Revision: 1.9 $ + Date: $Date: 2009-12-15 15:37:47 $ + Version: $Revision: 1.10 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -54,6 +54,17 @@ QuadEdgeMeshFrontBaseIterator( MeshType* mesh, m_CurrentEdge = seed; } +// --------------------------------------------------------------------- +template< class TMesh, class TQE > +QuadEdgeMeshFrontBaseIterator< TMesh, TQE >:: +~QuadEdgeMeshFrontBaseIterator( ) +{ + if( m_Front ) + { + delete m_Front; + } +} + // --------------------------------------------------------------------- template< class TMesh, class TQE > QuadEdgeMeshFrontBaseIterator< TMesh, TQE >& diff --git a/Utilities/ITK/Code/Review/itkQuadEdgeMeshFunctionBase.h b/Utilities/ITK/Code/Review/itkQuadEdgeMeshFunctionBase.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Review/itkQuadEdgeMeshLineCell.txx b/Utilities/ITK/Code/Review/itkQuadEdgeMeshLineCell.txx index cbe16dceef3093b2f843d10d97d32f39ecc7bb20..e686d5d86db48c1118883582c5aebe4f6401ea32 100644 --- a/Utilities/ITK/Code/Review/itkQuadEdgeMeshLineCell.txx +++ b/Utilities/ITK/Code/Review/itkQuadEdgeMeshLineCell.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkQuadEdgeMeshLineCell.txx,v $ Language: C++ - Date: $Date: 2009-07-30 21:17:33 $ - Version: $Revision: 1.17 $ + Date: $Date: 2009-12-13 15:28:13 $ + Version: $Revision: 1.18 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -75,16 +75,22 @@ QuadEdgeMeshLineCell< TCellInterface > else { FoundNullPointer = true; + delete m_QuadEdgeGeom->GetRot( )->GetRot( ); //e2 + delete m_QuadEdgeGeom->GetRot( ); //e1 + delete m_QuadEdgeGeom; } } else { FoundNullPointer = true; + delete m_QuadEdgeGeom->GetRot( ); //e1 + delete m_QuadEdgeGeom; } } else { FoundNullPointer = true; + delete m_QuadEdgeGeom; } } else diff --git a/Utilities/ITK/Code/Review/itkQuadEdgeMeshNormalFilter.h b/Utilities/ITK/Code/Review/itkQuadEdgeMeshNormalFilter.h index f976b9e6a60231a904b57c214b96e9da08407157..fc279c3f7fa296b42cb611b26515844c57e97f5a 100644 --- a/Utilities/ITK/Code/Review/itkQuadEdgeMeshNormalFilter.h +++ b/Utilities/ITK/Code/Review/itkQuadEdgeMeshNormalFilter.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkQuadEdgeMeshNormalFilter.h,v $ Language: C++ - Date: $Date: 2009-04-23 03:43:42 $ - Version: $Revision: 1.3 $ + Date: $Date: 2010-03-17 18:42:55 $ + Version: $Revision: 1.4 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -28,11 +28,39 @@ namespace itk * * \brief Filter which computes normals to faces and vertices and store it in * the output mesh. + * Normals to face are first computed, then normals to vertices are computed + * as linear combination of neighbor face normals, i.e. + * $f[ + * n_v = \frac{\sum_{i=0}^{#f} \omega_i \cdot n_i}{\| \sum_{k=0}^{#f} \omega_x \cdot n_k\|} + * $f] + * + * The difference between each method relies in the definition of the weight + * \f$ \omega_i \f$ that you can specify by the method SetWeight. + * + * GOURAUD \f$ \omega_i = 1\f$ [1] + * THURMER \f$ \omega_i = \text{Angle of the considered triangle at the given vertex \f$ [2] + * AREA \f$ \omega_i = \text{Area}(t_i)$ [3] + * + * These weights are defined in the literature: + * [1] Henri Gouraud. + * Continuous shading of curved surfaces. + * IEEE Transaction on Computers, 20(6):623-629, 1971 + * [2] Shuangshuang Jin, Robert R. Lewis, and David West. + * A comparison of algorithms for vertex normal computation. + * The Visual Computer, 21(1-2):71–82, 2005. + * [3] Grit Thurmer and Charles A. Wuthrich. + * Computing vertex normals from polygonal facets. + * Journal of Graphic Tools, 3(1):43–46, 1998. + * + * \note By default the weight is set to the TURMER weight. + * * \todo Fix run-time issues regarding the difference between the Traits of * TInputMesh and the one of TOutputMesh. Right now, it only works if * TInputMesh::MeshTraits == TOutputMesh::MeshTraits * (and of course it requires that the output have some itk::Vector for point * data and cell data. + * + * */ template< class TInputMesh, class TOutputMesh > class QuadEdgeMeshNormalFilter : diff --git a/Utilities/ITK/Code/Review/itkQuadEdgeMeshNormalFilter.txx b/Utilities/ITK/Code/Review/itkQuadEdgeMeshNormalFilter.txx index 976dbf1a287d8e9ef3b1bfd1e6ebb48a660e4f03..6533009dc40817a2de0b7189b0e0707c6feac43d 100644 --- a/Utilities/ITK/Code/Review/itkQuadEdgeMeshNormalFilter.txx +++ b/Utilities/ITK/Code/Review/itkQuadEdgeMeshNormalFilter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkQuadEdgeMeshNormalFilter.txx,v $ Language: C++ - Date: $Date: 2009-04-22 01:41:45 $ - Version: $Revision: 1.5 $ + Date: $Date: 2010-03-17 19:51:07 $ + Version: $Revision: 1.6 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -169,8 +169,11 @@ QuadEdgeMeshNormalFilter< TInputMesh, TOutputMesh > { default: case GOURAUD: + { return static_cast< OutputVertexNormalComponentType >( 1. ); + } case THURMER: + { // this implementation may be included inside itkTriangle switch( internal_id ) { @@ -187,11 +190,27 @@ QuadEdgeMeshNormalFilter< TInputMesh, TOutputMesh > v = pt[1] - pt[2]; break; } + typename OutputVectorType::RealValueType norm2_u = u.GetSquaredNorm(); + if( norm2_u > vnl_math::eps ) + { + norm2_u = 1. / norm2_u; + u *= norm2_u; + } + + typename OutputVectorType::RealValueType norm2_v = v.GetSquaredNorm(); + if( norm2_v > vnl_math::eps ) + { + norm2_v = 1. / norm2_v; + v *= norm2_v; + } return static_cast< OutputVertexNormalComponentType >( vcl_acos( u * v ) ); + } case AREA: + { return static_cast< OutputVertexNormalComponentType >( TriangleType::ComputeArea( pt[0], pt[1], pt[2] ) ); + } } } else diff --git a/Utilities/ITK/Code/Review/itkQuadEdgeMeshParam.h b/Utilities/ITK/Code/Review/itkQuadEdgeMeshParam.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Review/itkQuadEdgeMeshParam.txx b/Utilities/ITK/Code/Review/itkQuadEdgeMeshParam.txx old mode 100644 new mode 100755 index 9185544ecc5523e7998e61e604daa903a1daac28..1438ceddb8705b743bc2cd9914fae5683880ed5e --- a/Utilities/ITK/Code/Review/itkQuadEdgeMeshParam.txx +++ b/Utilities/ITK/Code/Review/itkQuadEdgeMeshParam.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkQuadEdgeMeshParam.txx,v $ Language: C++ - Date: $Date: 2009-05-13 21:52:25 $ - Version: $Revision: 1.5 $ + Date: $Date: 2009-09-17 11:14:57 $ + Version: $Revision: 1.6 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -54,9 +54,9 @@ void QuadEdgeMeshParam< TInputMesh, TOutputMesh, TSolverTraits > ::ComputeListOfInteriorVertices( ) { - InputMeshPointer input = this->GetInput( ); + InputMeshConstPointer input = this->GetInput( ); - typename InputPointsContainer::Pointer points = input->GetPoints( ); + typename InputPointsContainer::ConstPointer points = input->GetPoints( ); InputPointIdentifier k( 0 ); InputPointIdentifier id( 0 ); @@ -93,7 +93,7 @@ void QuadEdgeMeshParam< TInputMesh, TOutputMesh, TSolverTraits > ::FillMatrix( MatrixType& iM, VectorType& ioBx, VectorType& ioBy ) { - InputMeshPointer input = this->GetInput( ); + InputMeshConstPointer input = this->GetInput( ); OutputMeshPointer output = this->GetOutput( ); SolverTraits traits; @@ -167,7 +167,7 @@ QuadEdgeMeshParam< TInputMesh, TOutputMesh, TSolverTraits > { this->CopyInputMeshToOutputMesh( ); - InputMeshPointer input = this->GetInput( ); + InputMeshConstPointer input = this->GetInput( ); OutputMeshType* output = this->GetOutput( ); if( m_BorderTransform.IsNotNull( ) ) diff --git a/Utilities/ITK/Code/Review/itkQuadEdgeMeshParamMatrixCoefficients.h b/Utilities/ITK/Code/Review/itkQuadEdgeMeshParamMatrixCoefficients.h old mode 100644 new mode 100755 index c18080a96eaa019666b8ab4a71150d6663196b8c..b710f3078dd3de415f0ea060a84c950d2cf1c233 --- a/Utilities/ITK/Code/Review/itkQuadEdgeMeshParamMatrixCoefficients.h +++ b/Utilities/ITK/Code/Review/itkQuadEdgeMeshParamMatrixCoefficients.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkQuadEdgeMeshParamMatrixCoefficients.h,v $ Language: C++ - Date: $Date: 2008-10-03 21:55:06 $ - Version: $Revision: 1.3 $ + Date: $Date: 2009-09-17 11:14:57 $ + Version: $Revision: 1.4 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -41,7 +41,7 @@ public: virtual ~MatrixCoefficients( ) {} virtual InputCoordRepType operator ( ) - ( InputMeshType* iMesh, InputQEType* iEdge ) const = 0; + ( const InputMeshType* iMesh, InputQEType* iEdge ) const = 0; }; /** \class OnesMatrixCoefficients @@ -67,7 +67,7 @@ public: * \param[in] iEdge * \return \f$ 1 \f$ */ - InputCoordRepType operator ( ) ( InputMeshType * itkNotUsed( iMesh ), + InputCoordRepType operator ( ) ( const InputMeshType * itkNotUsed( iMesh ), InputQEType * itkNotUsed( iEdge ) ) const { return 1.0; @@ -101,7 +101,7 @@ public: * \param[in] iEdge * \return \f$ \frac{1}{\|\boldsymbol{p1} - \boldsymbol{p2} \|} \f$ */ - InputCoordRepType operator () ( InputMeshType* iMesh, InputQEType* iEdge ) const + InputCoordRepType operator () ( const InputMeshType* iMesh, InputQEType* iEdge ) const { InputPointIdentifier id1 = iEdge->GetOrigin( ); InputPointIdentifier id2 = iEdge->GetDestination( ); @@ -141,7 +141,7 @@ public: * \param[in] iEdge * \return \f$ \text{cot} \alpha_{ij} + \text{cot} \beta_{ij} \f$ */ - InputCoordRepType operator ( ) ( InputMeshType* iMesh, InputQEType* iEdge ) const + InputCoordRepType operator ( ) ( const InputMeshType* iMesh, InputQEType* iEdge ) const { InputPointIdentifier id1 = iEdge->GetOrigin( ); InputPointIdentifier id2 = iEdge->GetDestination( ); @@ -194,7 +194,7 @@ public: * \return \f$ \frac{\text{cot} \gamma_{ij} + \text{cot} \delta_{ij}}{\|\boldsymbol{p1} - \boldsymbol{p2} \|} \f$ */ - InputCoordRepType operator ( ) ( InputMeshType* iMesh, InputQEType* iEdge ) const + InputCoordRepType operator ( ) ( const InputMeshType* iMesh, InputQEType* iEdge ) const { InputPointIdentifier id1 = iEdge->GetOrigin( ); InputPointType pt1 = iMesh->GetPoint( id1 ); @@ -245,7 +245,7 @@ public: m_Lambda( iLambda ) { } - InputCoordRepType operator ( ) ( InputMeshType* iMesh, + InputCoordRepType operator ( ) ( const InputMeshType* iMesh, InputQEType* iEdge ) const { AuthalicMatrixCoefficients< TInputMesh > authalic; @@ -284,7 +284,7 @@ public: HarmonicMatrixCoefficients() { } - InputCoordRepType operator () ( InputMeshType* iMesh, InputQEType* iEdge ) const + InputCoordRepType operator () ( const InputMeshType* iMesh, InputQEType* iEdge ) const { InputPointIdentifier id1 = iEdge->GetOrigin( ); InputPointIdentifier id2 = iEdge->GetDestination( ); diff --git a/Utilities/ITK/Code/Review/itkQuadEdgeMeshPoint.h b/Utilities/ITK/Code/Review/itkQuadEdgeMeshPoint.h index 6ca6c5f48235a82579dd895579c8a1038c791c72..0a6c705e46b8d2b3ff97080bf04668271d50c499 100644 --- a/Utilities/ITK/Code/Review/itkQuadEdgeMeshPoint.h +++ b/Utilities/ITK/Code/Review/itkQuadEdgeMeshPoint.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkQuadEdgeMeshPoint.h,v $ Language: C++ - Date: $Date: 2009-09-08 20:00:56 $ - Version: $Revision: 1.12 $ + Date: $Date: 2010-02-19 19:42:45 $ + Version: $Revision: 1.13 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -73,6 +73,9 @@ public: /** Accessor on m_Edge */ void SetEdge( TQuadEdge * inputEdge ); + /** Set the coordinates from a standard itk::Point */ + void SetPoint( const Superclass & point ); + /** Accessor on m_Edge */ TQuadEdge * GetEdge(); TQuadEdge * GetEdge() const; diff --git a/Utilities/ITK/Code/Review/itkQuadEdgeMeshPoint.txx b/Utilities/ITK/Code/Review/itkQuadEdgeMeshPoint.txx index 21580c4970f1e24d02813311e5064ff675d6811c..a8f251a461a9210344b96584628166122556de6b 100644 --- a/Utilities/ITK/Code/Review/itkQuadEdgeMeshPoint.txx +++ b/Utilities/ITK/Code/Review/itkQuadEdgeMeshPoint.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkQuadEdgeMeshPoint.txx,v $ Language: C++ - Date: $Date: 2008-07-19 14:49:01 $ - Version: $Revision: 1.8 $ + Date: $Date: 2010-02-19 19:42:45 $ + Version: $Revision: 1.9 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -85,8 +85,8 @@ QuadEdgeMeshPoint< TCoordRep, VPointDimension, TQuadEdge > ::operator=( const ValueType r[VPointDimension] ) { this->Superclass::operator=( r ); - this->Initialize( ); - return( *this ); + this->Initialize( ); + return( *this ); } template< class TCoordRep, unsigned int VPointDimension, typename TQuadEdge > @@ -153,6 +153,19 @@ QuadEdgeMeshPoint< TCoordRep, VPointDimension, TQuadEdge > return(m_Edge); } + +/** Set Point Coordinates + * + */ +template< class TCoordRep, unsigned int VPointDimension, typename TQuadEdge > +void +QuadEdgeMeshPoint< TCoordRep, VPointDimension, TQuadEdge > +::SetPoint( const Superclass & point ) +{ + this->Superclass::operator=( point ); +} + + } #endif diff --git a/Utilities/ITK/Code/Review/itkQuadEdgeMeshQuadricDecimation.h b/Utilities/ITK/Code/Review/itkQuadEdgeMeshQuadricDecimation.h index 0f7c735562528d66615fdcc1385b0ece4e74629f..9f2f686c8173b8190dc36bb186845777148b6690 100644 --- a/Utilities/ITK/Code/Review/itkQuadEdgeMeshQuadricDecimation.h +++ b/Utilities/ITK/Code/Review/itkQuadEdgeMeshQuadricDecimation.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkQuadEdgeMeshQuadricDecimation.h,v $ Language: C++ - Date: $Date: 2008-10-03 22:23:46 $ - Version: $Revision: 1.4 $ + Date: $Date: 2010-03-24 21:51:55 $ + Version: $Revision: 1.5 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -132,7 +132,7 @@ protected: { p[i] = output->GetPoint( id[i] ); } - + oQ.AddTriangle( p[0], p[1], p[2] ); } @@ -146,14 +146,27 @@ protected: OutputPointIdentifier id_org = iEdge->GetOrigin(); OutputPointIdentifier id_dest = iEdge->GetDestination(); QuadricElementType Q = m_Quadric[ id_org ] + m_Quadric[ id_dest ]; - return static_cast< MeasureType >( Q.ComputeErrorAtOptimalLocation() ); + + OutputMeshPointer output = this->GetOutput(); + + OutputPointType org = output->GetPoint( id_org ); + OutputPointType dest = output->GetPoint( id_dest ); + + OutputPointType mid; + mid.SetToMidPoint( org, dest ); + OutputPointType p = Q.ComputeOptimalLocation( mid ); + + return static_cast< MeasureType >( Q.ComputeError( p ) ); } virtual void DeletePoint( const OutputPointIdentifier& iIdToBeDeleted, const OutputPointIdentifier& iRemaining ) { Superclass::DeletePoint( iIdToBeDeleted, iRemaining ); - m_Quadric[iRemaining] += m_Quadric[iIdToBeDeleted]; + + QuadricElementMapIterator it = m_Quadric.find( iIdToBeDeleted ); + m_Quadric[iRemaining] += it->second; + m_Quadric.erase( it ); } /** @@ -166,7 +179,16 @@ protected: OutputPointIdentifier id_org = iEdge->GetOrigin(); OutputPointIdentifier id_dest = iEdge->GetDestination(); QuadricElementType Q = m_Quadric[ id_org ] + m_Quadric[ id_dest ]; - return Q.ComputeOptimalLocation(); + + OutputMeshPointer output = this->GetOutput(); + + OutputPointType org = output->GetPoint( id_org ); + OutputPointType dest = output->GetPoint( id_dest ); + + OutputPointType mid; + mid.SetToMidPoint( org, dest ); + + return Q.ComputeOptimalLocation( mid ); } private: diff --git a/Utilities/ITK/Code/Review/itkQuadEdgeMeshSmoothing.txx b/Utilities/ITK/Code/Review/itkQuadEdgeMeshSmoothing.txx index 42bb04213bead3aa4006568645f9601541e5d6e8..20c191615d9e721c4e113b12a2b1b269fd25f487 100644 --- a/Utilities/ITK/Code/Review/itkQuadEdgeMeshSmoothing.txx +++ b/Utilities/ITK/Code/Review/itkQuadEdgeMeshSmoothing.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkQuadEdgeMeshSmoothing.txx,v $ Language: C++ - Date: $Date: 2009-04-22 01:41:45 $ - Version: $Revision: 1.2 $ + Date: $Date: 2009-09-22 20:57:29 $ + Version: $Revision: 1.4 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -18,6 +18,8 @@ #ifndef __itkQuadEdgeMeshSmoothing_txx #define __itkQuadEdgeMeshSmoothing_txx +#include "itkQuadEdgeMeshSmoothing.h" + namespace itk { template< class TInputMesh, class TOutputMesh > @@ -42,7 +44,7 @@ template< class TInputMesh, class TOutputMesh > void QuadEdgeMeshSmoothing< TInputMesh, TOutputMesh >:: GenerateData() { - OutputMeshPointer mesh; + OutputMeshPointer mesh = OutputMeshType::New(); OutputPointsContainerPointer temp = OutputPointsContainer::New(); temp->Reserve( this->GetInput()->GetNumberOfPoints() ); @@ -85,7 +87,7 @@ GenerateData() } else { - mesh = this->GetInput(); + this->CopyMeshToMesh(this->GetInput(), mesh); } } diff --git a/Utilities/ITK/Code/Review/itkQuadEdgeMeshToQuadEdgeMeshFilter.h b/Utilities/ITK/Code/Review/itkQuadEdgeMeshToQuadEdgeMeshFilter.h index f739943f77af767f64b07b4e29a79faca1698807..8af970656195f5f1258459c27a29d0149f9a493d 100644 --- a/Utilities/ITK/Code/Review/itkQuadEdgeMeshToQuadEdgeMeshFilter.h +++ b/Utilities/ITK/Code/Review/itkQuadEdgeMeshToQuadEdgeMeshFilter.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkQuadEdgeMeshToQuadEdgeMeshFilter.h,v $ Language: C++ - Date: $Date: 2009-07-13 23:02:40 $ - Version: $Revision: 1.10 $ + Date: $Date: 2009-09-22 20:57:29 $ + Version: $Revision: 1.12 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -103,6 +103,7 @@ protected: QuadEdgeMeshToQuadEdgeMeshFilter(); virtual ~QuadEdgeMeshToQuadEdgeMeshFilter() { } + virtual void CopyMeshToMesh(const TInputMesh * in, TOutputMesh * out); virtual void CopyInputMeshToOutputMesh(); virtual void CopyInputMeshToOutputMeshGeometry(); virtual void CopyInputMeshToOutputMeshPoints(); @@ -117,6 +118,176 @@ private: void operator=( const Self& ); // Not impl. }; +// +// Helper functions that copy selected pieces of a Mesh. +// These functions should be templated here in order to +// facilitate their reuse in multiple scenarios. +// + +// --------------------------------------------------------------------- +template< class TInputMesh, class TOutputMesh > +void CopyMeshToMeshCellData( const TInputMesh * in, TOutputMesh * out ) +{ + + typedef typename TInputMesh::CellDataContainer InputCellDataContainer; + typedef typename TOutputMesh::CellDataContainer OutputCellDataContainer; + typedef typename InputCellDataContainer::ConstPointer InputCellDataContainerConstPointer; + typedef typename OutputCellDataContainer::Pointer OutputCellDataContainerPointer; + + InputCellDataContainerConstPointer inputCellData = in->GetCellData(); + + if( inputCellData.IsNull() ) + { + // There is nothing to copy + return; + } + + OutputCellDataContainerPointer outputCellData = OutputCellDataContainer::New(); + outputCellData->Reserve( inputCellData->Size() ); + + // Copy point data + typedef typename InputCellDataContainer::ConstIterator InputCellDataContainerConstIterator; + InputCellDataContainerConstIterator inIt = inputCellData->Begin(); + while( inIt != inputCellData->End() ) + { + outputCellData->SetElement( inIt.Index(), inIt.Value() ); + inIt++; + } + + out->SetCellData( outputCellData ); +} + + +// --------------------------------------------------------------------- +template< class TInputMesh, class TOutputMesh > +void CopyMeshToMeshPointData( const TInputMesh * in, TOutputMesh * out ) +{ + + typedef typename TOutputMesh::PointDataContainer OutputPointDataContainer; + typedef typename OutputPointDataContainer::Pointer OutputPointDataContainerPointer; + typedef typename TInputMesh::PointDataContainer InputPointDataContainer; + + const InputPointDataContainer * inputPointData = in->GetPointData(); + + if( inputPointData == NULL ) + { + // There is nothing to copy + return; + } + + OutputPointDataContainerPointer outputPointData = OutputPointDataContainer::New(); + outputPointData->Reserve( inputPointData->Size() ); + + // Copy point data + typedef typename InputPointDataContainer::ConstIterator InputPointDataContainerConstIterator; + InputPointDataContainerConstIterator inIt = inputPointData->Begin(); + while( inIt != inputPointData->End() ) + { + outputPointData->SetElement( inIt.Index(), inIt.Value() ); + inIt++; + } + + out->SetPointData( outputPointData ); +} + + +// --------------------------------------------------------------------- +template< class TInputMesh, class TOutputMesh > +void CopyMeshToMeshCells( const TInputMesh * in, TOutputMesh * out ) +{ + // Copy cells + typedef typename TInputMesh::CellsContainer InputCellsContainer; + typedef typename InputCellsContainer::ConstPointer InputCellsContainerConstPointer; + typedef typename InputCellsContainer::ConstIterator InputCellsContainerConstIterator; + typedef typename TInputMesh::PolygonCellType InputPolygonCellType; + typedef typename TInputMesh::PointIdList InputPointIdList; + typedef typename TInputMesh::CellTraits InputCellTraits; + typedef typename InputCellTraits::PointIdInternalIterator + InputPointsIdInternalIterator; + + out->SetCellsAllocationMethod( TOutputMesh::CellsAllocatedDynamicallyCellByCell ); + + InputCellsContainerConstPointer inCells = in->GetCells(); + + if( inCells ) + { + InputCellsContainerConstIterator cIt = inCells->Begin(); + while( cIt != inCells->End() ) + { + InputPolygonCellType * pe = dynamic_cast< InputPolygonCellType* >( cIt.Value()); + if( pe ) + { + InputPointIdList points; + InputPointsIdInternalIterator pit = pe->InternalPointIdsBegin(); + while( pit != pe->InternalPointIdsEnd( ) ) + { + points.push_back( ( *pit ) ); + ++pit; + } + out->AddFaceWithSecurePointList( points, false ); + } + cIt++; + } + } +} + + +// --------------------------------------------------------------------- +template< class TInputMesh, class TOutputMesh > +void CopyMeshToMeshEdgeCells( const TInputMesh * in, TOutputMesh * out ) +{ + // Copy Edge Cells + typedef typename TInputMesh::CellsContainer InputCellsContainer; + typedef typename InputCellsContainer::ConstPointer InputCellsContainerConstPointer; + typedef typename InputCellsContainer::ConstIterator InputCellsContainerConstIterator; + typedef typename TInputMesh::EdgeCellType InputEdgeCellType; + + InputCellsContainerConstPointer inEdgeCells = in->GetEdgeCells(); + + if( inEdgeCells ) + { + InputCellsContainerConstIterator ecIt = inEdgeCells->Begin(); + while( ecIt != inEdgeCells->End() ) + { + InputEdgeCellType* pe = dynamic_cast< InputEdgeCellType* >( ecIt.Value()); + if( pe ) + { + out->AddEdgeWithSecurePointList( pe->GetQEGeom()->GetOrigin(), + pe->GetQEGeom()->GetDestination() ); + } + ecIt++; + } + } +} + + +// --------------------------------------------------------------------- +template< class TInputMesh, class TOutputMesh > +void CopyMeshToMeshPoints( const TInputMesh * in, TOutputMesh * out ) +{ + // Copy points + typedef typename TInputMesh::PointsContainer InputPointsContainer; + typedef typename InputPointsContainer::ConstPointer InputPointsContainerConstPointer; + typedef typename InputPointsContainer::ConstIterator InputPointsContainerConstIterator; + typedef typename TOutputMesh::PointType OutputPointType; + + InputPointsContainerConstPointer inPoints = in->GetPoints(); + + if( inPoints ) + { + InputPointsContainerConstIterator inIt = inPoints->Begin(); + OutputPointType pOut; + + while( inIt != inPoints->End() ) + { + pOut.CastFrom( inIt.Value() ); + out->SetPoint( inIt.Index(), pOut ); + inIt++; + } + } +} + + } // end namespace itk #ifndef ITK_MANUAL_INSTANTIATION diff --git a/Utilities/ITK/Code/Review/itkQuadEdgeMeshToQuadEdgeMeshFilter.txx b/Utilities/ITK/Code/Review/itkQuadEdgeMeshToQuadEdgeMeshFilter.txx index 173c6b09942b4a69166f07696cdebc4e9e13dcfd..546efabb54bac26bd117bfb52cd04222ae26448c 100644 --- a/Utilities/ITK/Code/Review/itkQuadEdgeMeshToQuadEdgeMeshFilter.txx +++ b/Utilities/ITK/Code/Review/itkQuadEdgeMeshToQuadEdgeMeshFilter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkQuadEdgeMeshToQuadEdgeMeshFilter.txx,v $ Language: C++ - Date: $Date: 2009-07-13 23:02:46 $ - Version: $Revision: 1.17 $ + Date: $Date: 2009-09-22 20:57:30 $ + Version: $Revision: 1.19 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -22,6 +22,7 @@ namespace itk { + // --------------------------------------------------------------------- template< class TInputMesh, class TOutputMesh > QuadEdgeMeshToQuadEdgeMeshFilter< TInputMesh, TOutputMesh > @@ -33,6 +34,19 @@ QuadEdgeMeshToQuadEdgeMeshFilter< TInputMesh, TOutputMesh > this->Superclass::SetNthOutput( 0, OutputMeshType::New() ); } +// --------------------------------------------------------------------- +template< class TInputMesh, class TOutputMesh > +void +QuadEdgeMeshToQuadEdgeMeshFilter< TInputMesh, TOutputMesh > +::CopyMeshToMesh(const TInputMesh * in, TOutputMesh * out) +{ + CopyMeshToMeshPoints(in, out); + CopyMeshToMeshEdgeCells(in, out); + CopyMeshToMeshCells(in, out); + CopyMeshToMeshPointData(in, out); + CopyMeshToMeshCellData(in, out); +} + // --------------------------------------------------------------------- template< class TInputMesh, class TOutputMesh > void @@ -70,52 +84,23 @@ void QuadEdgeMeshToQuadEdgeMeshFilter< TInputMesh, TOutputMesh > ::CopyInputMeshToOutputMeshPoints() { + const InputMeshType * in = this->GetInput(); + OutputMeshType * out = this->GetOutput(); - InputMeshConstPointer in = this->GetInput(); - OutputMeshPointer out = this->GetOutput(); - - // Copy points - InputPointsContainerConstPointer inPoints = in->GetPoints(); - - if( inPoints ) - { - InputPointsContainerConstIterator inIt = inPoints->Begin(); - while( inIt != inPoints->End() ) - { - OutputPointType pOut; - pOut.CastFrom( inIt.Value() ); - out->SetPoint( inIt.Index(), pOut ); - inIt++; - } - } + CopyMeshToMeshPoints( in, out ); } + // --------------------------------------------------------------------- template< class TInputMesh, class TOutputMesh > void QuadEdgeMeshToQuadEdgeMeshFilter< TInputMesh, TOutputMesh > ::CopyInputMeshToOutputMeshEdgeCells() { - InputMeshConstPointer in = this->GetInput(); - OutputMeshPointer out = this->GetOutput(); - - // Copy Edge Cells - InputCellsContainerConstPointer inEdgeCells = in->GetEdgeCells(); - - if( inEdgeCells ) - { - InputCellsContainerConstIterator ecIt = inEdgeCells->Begin(); - while( ecIt != inEdgeCells->End() ) - { - InputEdgeCellType* pe = dynamic_cast< InputEdgeCellType* >( ecIt.Value()); - if( pe ) - { - out->AddEdgeWithSecurePointList( pe->GetQEGeom()->GetOrigin(), - pe->GetQEGeom()->GetDestination() ); - } - ecIt++; - } - } + const InputMeshType * in = this->GetInput(); + OutputMeshType * out = this->GetOutput(); + + CopyMeshToMeshEdgeCells( in, out ); } @@ -125,32 +110,10 @@ void QuadEdgeMeshToQuadEdgeMeshFilter< TInputMesh, TOutputMesh > ::CopyInputMeshToOutputMeshCells() { - InputMeshConstPointer in = this->GetInput(); - OutputMeshPointer out = this->GetOutput(); - - // Copy cells - InputCellsContainerConstPointer inCells = in->GetCells(); - - if( inCells ) - { - InputCellsContainerConstIterator cIt = inCells->Begin(); - while( cIt != inCells->End() ) - { - InputPolygonCellType * pe = dynamic_cast< InputPolygonCellType* >( cIt.Value()); - if( pe ) - { - InputPointIdList points; - InputPointsIdInternalIterator pit = pe->InternalPointIdsBegin(); - while( pit != pe->InternalPointIdsEnd( ) ) - { - points.push_back( ( *pit ) ); - ++pit; - } - out->AddFaceWithSecurePointList( points, false ); - } - cIt++; - } - } + const InputMeshType * in = this->GetInput(); + OutputMeshType * out = this->GetOutput(); + + CopyMeshToMeshCells( in, out ); } // --------------------------------------------------------------------- @@ -160,33 +123,10 @@ QuadEdgeMeshToQuadEdgeMeshFilter< TInputMesh, TOutputMesh > ::CopyInputMeshToOutputMeshPointData() { - InputMeshConstPointer in = this->GetInput(); - OutputMeshPointer out = this->GetOutput(); + const InputMeshType * in = this->GetInput(); + OutputMeshType * out = this->GetOutput(); - typedef typename OutputPointDataContainer::Pointer OutputPointDataContainerPointer; - - InputPointDataContainerConstPointer inputPointData = in->GetPointData(); - - if( inputPointData.IsNull() ) - { - // There is nothing to copy - itkWarningMacro("Input mesh point data is NULL"); - return; - } - - OutputPointDataContainerPointer outputPointData = OutputPointDataContainer::New(); - outputPointData->Reserve( inputPointData->Size() ); - - // Copy point data - typedef typename InputPointDataContainer::ConstIterator InputPointDataContainerConstIterator; - InputPointDataContainerConstIterator inIt = inputPointData->Begin(); - while( inIt != inputPointData->End() ) - { - outputPointData->SetElement( inIt.Index(), inIt.Value() ); - inIt++; - } - - out->SetPointData( outputPointData ); + CopyMeshToMeshPointData( in, out ); } @@ -197,34 +137,12 @@ QuadEdgeMeshToQuadEdgeMeshFilter< TInputMesh, TOutputMesh > ::CopyInputMeshToOutputMeshCellData() { - InputMeshConstPointer in = this->GetInput(); - OutputMeshPointer out = this->GetOutput(); - - typedef typename InputCellDataContainer::ConstPointer InputCellDataContainerConstPointer; - typedef typename OutputCellDataContainer::Pointer OutputCellDataContainerPointer; + const InputMeshType * in = this->GetInput(); + OutputMeshType * out = this->GetOutput(); - InputCellDataContainerConstPointer inputCellData = in->GetCellData(); - - if( inputCellData.IsNull() ) - { - // There is nothing to copy - return; - } - - OutputCellDataContainerPointer outputCellData = OutputCellDataContainer::New(); - outputCellData->Reserve( inputCellData->Size() ); - - // Copy point data - typedef typename InputCellDataContainer::ConstIterator InputCellDataContainerConstIterator; - InputCellDataContainerConstIterator inIt = inputCellData->Begin(); - while( inIt != inputCellData->End() ) - { - outputCellData->SetElement( inIt.Index(), inIt.Value() ); - inIt++; - } - - out->SetCellData( outputCellData ); + CopyMeshToMeshCellData( in, out ); } + } // end namespace itk #endif diff --git a/Utilities/ITK/Code/Review/itkQuadEdgeMeshTopologyChecker.txx b/Utilities/ITK/Code/Review/itkQuadEdgeMeshTopologyChecker.txx index f1cfc5ce2f8d05682bc75b78ad99e81aee5c0933..f735198978adc4db55d77698378cb94b83c92d7f 100644 --- a/Utilities/ITK/Code/Review/itkQuadEdgeMeshTopologyChecker.txx +++ b/Utilities/ITK/Code/Review/itkQuadEdgeMeshTopologyChecker.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkQuadEdgeMeshTopologyChecker.txx,v $ Language: C++ - Date: $Date: 2007-12-16 05:14:14 $ - Version: $Revision: 1.9 $ + Date: $Date: 2009-11-22 23:27:38 $ + Version: $Revision: 1.10 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -56,7 +56,10 @@ QuadEdgeMeshTopologyChecker< TMesh > // Number of USED faces unsigned long numFaces = m_Mesh->ComputeNumberOfFaces( ); // Number of Boundaries - unsigned long numBounds = boundaryEdges->Evaluate( (*m_Mesh) )->size( ); + typename BoundaryEdges::OutputType + listOfBoundaries = boundaryEdges->Evaluate( (*m_Mesh) ); + unsigned long numBounds = listOfBoundaries->size( ); + delete listOfBoundaries; /** * Number of points diff --git a/Utilities/ITK/Code/Review/itkQuadEdgeMeshZipMeshFunction.h b/Utilities/ITK/Code/Review/itkQuadEdgeMeshZipMeshFunction.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Review/itkQuadEdgeMeshZipMeshFunction.txx b/Utilities/ITK/Code/Review/itkQuadEdgeMeshZipMeshFunction.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Review/itkRegionBasedLevelSetFunction.h b/Utilities/ITK/Code/Review/itkRegionBasedLevelSetFunction.h index 5f8b67cbc981337c665580375e911e60a23abcc6..73d846d80aa2795847bdd13a6e4be997f960149d 100644 --- a/Utilities/ITK/Code/Review/itkRegionBasedLevelSetFunction.h +++ b/Utilities/ITK/Code/Review/itkRegionBasedLevelSetFunction.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkRegionBasedLevelSetFunction.h,v $ Language: C++ - Date: $Date: 2009-08-06 01:46:47 $ - Version: $Revision: 1.18 $ + Date: $Date: 2010-02-24 22:42:16 $ + Version: $Revision: 1.19 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -188,7 +188,7 @@ public: TimeStepType ComputeGlobalTimeStep(void *GlobalData) const; /** Compute the equation value. */ - PixelType ComputeUpdate(const NeighborhoodType &neighborhood, + virtual PixelType ComputeUpdate(const NeighborhoodType &neighborhood, void *globalData, const FloatOffsetType& = FloatOffsetType(0.0)); void SetInitialImage(InputImageType *f) diff --git a/Utilities/ITK/Code/Review/itkRegionBasedLevelSetFunction.txx b/Utilities/ITK/Code/Review/itkRegionBasedLevelSetFunction.txx index 0c731104445878f6269904c1c78e013e17fc59d9..815c0c0ae5b981d62682c950046a95f4bc595963 100644 --- a/Utilities/ITK/Code/Review/itkRegionBasedLevelSetFunction.txx +++ b/Utilities/ITK/Code/Review/itkRegionBasedLevelSetFunction.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkRegionBasedLevelSetFunction.txx,v $ Language: C++ - Date: $Date: 2009-08-06 16:09:56 $ - Version: $Revision: 1.28 $ + Date: $Date: 2010-02-24 19:27:48 $ + Version: $Revision: 1.29 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -414,7 +414,8 @@ RegionBasedLevelSetFunction< TInput, TFeature, TSharedData > const ScalarValueType& itkNotUsed( inputPixel ), const InputIndexType& inputIndex ) { - ScalarValueType product = 1; // computes if it belongs to background + // computes if it belongs to background + ScalarValueType product = 1; // Assuming only 1 level set function to be present FeatureIndexType featIndex = static_cast< FeatureIndexType >( inputIndex ); @@ -426,8 +427,7 @@ const InputIndexType& inputIndex ) // This conditional statement computes the amount of overlap s // and the presence of background pr - if ( ( this->m_SharedData->m_FunctionCount > 1 ) && - ( this->m_OverlapPenaltyWeight != NumericTraits<ScalarValueType>::Zero ) ) + if( this->m_SharedData->m_FunctionCount > 1 ) { featIndex = this->m_SharedData->m_LevelSetDataPointerVector[this->m_FunctionId]->GetFeatureIndex( inputIndex ); overlapTerm = this->m_OverlapPenaltyWeight * diff --git a/Utilities/ITK/Code/Review/itkRelabelLabelMapFilter.h b/Utilities/ITK/Code/Review/itkRelabelLabelMapFilter.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Review/itkRelabelLabelMapFilter.txx b/Utilities/ITK/Code/Review/itkRelabelLabelMapFilter.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Review/itkScalarChanAndVeseDenseLevelSetImageFilter.h b/Utilities/ITK/Code/Review/itkScalarChanAndVeseDenseLevelSetImageFilter.h index 507fe5a3270c35ea68aec041d874eff1df0cf642..ce4d420a22e371e58c6e319923dbeb59e56bdde8 100644 --- a/Utilities/ITK/Code/Review/itkScalarChanAndVeseDenseLevelSetImageFilter.h +++ b/Utilities/ITK/Code/Review/itkScalarChanAndVeseDenseLevelSetImageFilter.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkScalarChanAndVeseDenseLevelSetImageFilter.h,v $ Language: C++ - Date: $Date: 2009-07-29 15:14:09 $ - Version: $Revision: 1.6 $ + Date: $Date: 2010-02-22 23:40:23 $ + Version: $Revision: 1.9 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -20,8 +20,10 @@ #include "itkMultiphaseDenseFiniteDifferenceImageFilter.h" #include "itkRegionOfInterestImageFilter.h" +#include "itkScalarChanAndVeseLevelSetFunction.h" - +namespace itk +{ /** \class ScalarChanAndVeseDenseLevelSetImageFilter * \brief Dense implementation of the Chan and Vese multiphase level set image filter. * @@ -30,7 +32,7 @@ * * "An active contour model without edges" * T. Chan and L. Vese. - * In Scale-Space Theories in Computer Vision, pages 141–151, 1999. + * In Scale-Space Theories in Computer Vision, pages 141-151, 1999. * * \author Mosaliganti K., Smith B., Gelas A., Gouaillard A., Megason S. * @@ -53,10 +55,9 @@ * http://hdl.handle.net/1926/1533 * */ -namespace itk -{ -template < class TInputImage, class TFeatureImage, class TOutputImage, class TFunction, - class TSharedData > +template < class TInputImage, class TFeatureImage, class TOutputImage, + class TFunction=ScalarChanAndVeseLevelSetFunction< TInputImage, TFeatureImage >, + class TSharedData=ITK_TYPENAME TFunction::SharedDataType > class ITK_EXPORT ScalarChanAndVeseDenseLevelSetImageFilter: public MultiphaseDenseFiniteDifferenceImageFilter< TInputImage, TFeatureImage, TOutputImage, TFunction > diff --git a/Utilities/ITK/Code/Review/itkScalarChanAndVeseLevelSetFunction.h b/Utilities/ITK/Code/Review/itkScalarChanAndVeseLevelSetFunction.h index eb944fb8be16543422ae51aa3ad1772b964613e1..f0344f40007bd61ec1f7b7bdf30dd9fd515f5762 100644 --- a/Utilities/ITK/Code/Review/itkScalarChanAndVeseLevelSetFunction.h +++ b/Utilities/ITK/Code/Review/itkScalarChanAndVeseLevelSetFunction.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkScalarChanAndVeseLevelSetFunction.h,v $ Language: C++ - Date: $Date: 2009-06-12 09:44:02 $ - Version: $Revision: 1.10 $ + Date: $Date: 2010-02-03 18:57:22 $ + Version: $Revision: 1.11 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -19,6 +19,8 @@ #define __itkScalarChanAndVeseLevelSetFunction_h #include "itkScalarRegionBasedLevelSetFunction.h" +#include "itkScalarChanAndVeseLevelSetFunctionData.h" +#include "itkConstrainedRegionBasedLevelSetFunctionSharedData.h" namespace itk { @@ -35,7 +37,7 @@ namespace itk { * * "An active contour model without edges" * T. Chan and L. Vese. - * In Scale-Space Theories in Computer Vision, pages 141–151, 1999. + * In Scale-Space Theories in Computer Vision, pages 141-151, 1999. * * "Segmenting and Tracking Fluorescent Cells in Dynamic 3-D * Microscopy With Coupled Active Surfaces" @@ -64,7 +66,8 @@ namespace itk { */ template < class TInputImage, class TFeatureImage, -class TSharedData > +class TSharedData=ConstrainedRegionBasedLevelSetFunctionSharedData< TInputImage, TFeatureImage, + ScalarChanAndVeseLevelSetFunctionData< TInputImage, TFeatureImage > > > class ITK_EXPORT ScalarChanAndVeseLevelSetFunction : public ScalarRegionBasedLevelSetFunction< TInputImage, TFeatureImage, TSharedData > { diff --git a/Utilities/ITK/Code/Review/itkScalarChanAndVeseSparseLevelSetImageFilter.h b/Utilities/ITK/Code/Review/itkScalarChanAndVeseSparseLevelSetImageFilter.h index 348ac3f15ecd904e473151d02aa6ffc8ef55403f..53ee0df8c34422e8673b66d9cdb0b14ba5f54894 100644 --- a/Utilities/ITK/Code/Review/itkScalarChanAndVeseSparseLevelSetImageFilter.h +++ b/Utilities/ITK/Code/Review/itkScalarChanAndVeseSparseLevelSetImageFilter.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkScalarChanAndVeseSparseLevelSetImageFilter.h,v $ Language: C++ - Date: $Date: 2009-07-29 15:14:15 $ - Version: $Revision: 1.8 $ + Date: $Date: 2010-02-22 23:40:23 $ + Version: $Revision: 1.11 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -20,7 +20,10 @@ #include "itkMultiphaseSparseFiniteDifferenceImageFilter.h" #include "itkRegionOfInterestImageFilter.h" +#include "itkScalarChanAndVeseLevelSetFunction.h" +namespace itk +{ /** \class ScalarChanAndVeseSparseLevelSetImageFilter * \brief Sparse implementation of the Chan and Vese multiphase level set image filter. * @@ -29,7 +32,7 @@ * * "An active contour model without edges" * T. Chan and L. Vese. - * In Scale-Space Theories in Computer Vision, pages 141–151, 1999. + * In Scale-Space Theories in Computer Vision, pages 141-151, 1999. * * \author Mosaliganti K., Smith B., Gelas A., Gouaillard A., Megason S. * @@ -52,10 +55,10 @@ * http://hdl.handle.net/1926/1533 * */ -namespace itk -{ -template < class TInputImage, class TFeatureImage, class TOutputImage, class TFunction, - class TSharedData, typename TIdCell = unsigned int > +template < class TInputImage, class TFeatureImage, class TOutputImage, + class TFunction=ScalarChanAndVeseLevelSetFunction< TInputImage, TFeatureImage >, + class TSharedData=ITK_TYPENAME TFunction::SharedDataType, + typename TIdCell = unsigned int > class ITK_EXPORT ScalarChanAndVeseSparseLevelSetImageFilter : public MultiphaseSparseFiniteDifferenceImageFilter< TInputImage, TFeatureImage, TOutputImage, TFunction, TIdCell > diff --git a/Utilities/ITK/Code/Review/itkScalarRegionBasedLevelSetFunction.h b/Utilities/ITK/Code/Review/itkScalarRegionBasedLevelSetFunction.h index 5d7df3d2b3775648c75941d4f14417a665f9c77b..ba19918b7d3bb9891bb1e289353b5ba9877bf8a2 100644 --- a/Utilities/ITK/Code/Review/itkScalarRegionBasedLevelSetFunction.h +++ b/Utilities/ITK/Code/Review/itkScalarRegionBasedLevelSetFunction.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkScalarRegionBasedLevelSetFunction.h,v $ Language: C++ - Date: $Date: 2009-06-12 09:44:02 $ - Version: $Revision: 1.9 $ + Date: $Date: 2010-02-02 13:58:06 $ + Version: $Revision: 1.10 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -21,6 +21,7 @@ #include "itkRegionBasedLevelSetFunction.h" #include "itkNeighborhoodIterator.h" #include "itkImageRegionConstIterator.h" +#include "itkImageRegionIteratorWithIndex.h" namespace itk { diff --git a/Utilities/ITK/Code/Review/itkShapeLabelMapFilter.txx b/Utilities/ITK/Code/Review/itkShapeLabelMapFilter.txx index 0f2a87cbdf2410442d8bf6d58825aa1aaab871cb..ecbe1c4c1ef1fd07869bbed27b3efa2a97ff404f 100644 --- a/Utilities/ITK/Code/Review/itkShapeLabelMapFilter.txx +++ b/Utilities/ITK/Code/Review/itkShapeLabelMapFilter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkShapeLabelMapFilter.txx,v $ Language: C++ - Date: $Date: 2009-08-02 14:57:08 $ - Version: $Revision: 1.6 $ + Date: $Date: 2009-11-06 22:22:47 $ + Version: $Revision: 1.7 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -384,7 +384,8 @@ ShapeLabelMapFilter<TImage, TLabelImage> labelObject->SetEquivalentEllipsoidSize( ellipsoidSize ); labelObject->SetBinaryFlatness( flatness ); - if( m_ComputeFeretDiameter ) + // Don't compute the Feret Diameter on the 0 label! + if( m_ComputeFeretDiameter && labelObject->GetLabel() != 0 ) { this->ComputeFeretDiameter( labelObject ); } diff --git a/Utilities/ITK/Code/Review/itkShapeLabelObject.h b/Utilities/ITK/Code/Review/itkShapeLabelObject.h index 1ad155619e0e66d3ceb66ed895649aac7ef68cec..33899e41ec337403b97722fa63f5dc4f2ad51b21 100644 --- a/Utilities/ITK/Code/Review/itkShapeLabelObject.h +++ b/Utilities/ITK/Code/Review/itkShapeLabelObject.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkShapeLabelObject.h,v $ Language: C++ - Date: $Date: 2009-08-11 14:24:44 $ - Version: $Revision: 1.5 $ + Date: $Date: 2009-12-18 19:14:48 $ + Version: $Revision: 1.6 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -546,12 +546,12 @@ protected: os << indent << "BinaryPrincipalMoments: " << m_BinaryPrincipalMoments << std::endl; os << indent << "BinaryPrincipalAxes: " << std::endl << m_BinaryPrincipalAxes; os << indent << "BinaryElongation: " << m_BinaryElongation << std::endl; + os << indent << "BinaryFlatness: " << m_BinaryFlatness << std::endl; os << indent << "Perimeter: " << m_Perimeter << std::endl; os << indent << "Roundness: " << m_Roundness << std::endl; os << indent << "EquivalentRadius: " << m_EquivalentRadius << std::endl; os << indent << "EquivalentPerimeter: " << m_EquivalentPerimeter << std::endl; os << indent << "EquivalentEllipsoidSize: " << m_EquivalentEllipsoidSize << std::endl; - os << indent << "BinaryFlatness: " << m_BinaryElongation << std::endl; } private: diff --git a/Utilities/ITK/Code/Review/itkSharedMorphologyUtilities.txx b/Utilities/ITK/Code/Review/itkSharedMorphologyUtilities.txx index 9e2196b4dd6a03b7fe327e9dbe90c0aa0e2d24b8..855236775281e2ff716e838bcd395a8863f7ce7c 100644 --- a/Utilities/ITK/Code/Review/itkSharedMorphologyUtilities.txx +++ b/Utilities/ITK/Code/Review/itkSharedMorphologyUtilities.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkSharedMorphologyUtilities.txx,v $ Language: C++ - Date: $Date: 2009-04-06 13:46:38 $ - Version: $Revision: 1.9 $ + Date: $Date: 2009-10-29 15:03:32 $ + Version: $Revision: 1.10 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -378,7 +378,7 @@ FaceCalculatorType; { if (i != NonFaceDim) { - int Pad = (int)vcl_ceil((float)(NonFaceLen) * line[i]/vcl_fabs(line[NonFaceDim])); + int Pad = Math::Ceil<int>((float)(NonFaceLen) * line[i]/vcl_fabs(line[NonFaceDim])); if (Pad < 0) { // just increase the size - no need to change the start diff --git a/Utilities/ITK/Code/Review/itkShiftScaleLabelMapFilter.h b/Utilities/ITK/Code/Review/itkShiftScaleLabelMapFilter.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Review/itkShiftScaleLabelMapFilter.txx b/Utilities/ITK/Code/Review/itkShiftScaleLabelMapFilter.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/Review/itkStatisticsUniqueLabelMapFilter.txx b/Utilities/ITK/Code/Review/itkStatisticsUniqueLabelMapFilter.txx index 4444192783596a985d94b5b3233d5ba5cb730a36..15de7e2b4d1f33d7c2e6b6ae715ce6ab37862331 100644 --- a/Utilities/ITK/Code/Review/itkStatisticsUniqueLabelMapFilter.txx +++ b/Utilities/ITK/Code/Review/itkStatisticsUniqueLabelMapFilter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkStatisticsUniqueLabelMapFilter.txx,v $ Language: C++ - Date: $Date: 2009-08-07 13:57:20 $ - Version: $Revision: 1.1 $ + Date: $Date: 2009-09-19 19:13:11 $ + Version: $Revision: 1.2 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -18,6 +18,7 @@ #define __itkStatisticsUniqueLabelMapFilter_txx #include "itkStatisticsUniqueLabelMapFilter.h" +#include "itkStatisticsLabelObjectAccessors.h" namespace itk { diff --git a/Utilities/ITK/Code/Review/itkStochasticFractalDimensionImageFilter.h b/Utilities/ITK/Code/Review/itkStochasticFractalDimensionImageFilter.h index 4f382f51e01700a3734e0d833bfb82e0ef34015c..651e1d334b63f16ca9ea45a0265b9a1f0e40aabd 100644 --- a/Utilities/ITK/Code/Review/itkStochasticFractalDimensionImageFilter.h +++ b/Utilities/ITK/Code/Review/itkStochasticFractalDimensionImageFilter.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkStochasticFractalDimensionImageFilter.h,v $ Language: C++ - Date: $Date: 2009-04-30 01:58:27 $ - Version: $Revision: 1.1 $ + Date: $Date: 2010-02-04 12:15:05 $ + Version: $Revision: 1.2 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -26,7 +26,7 @@ namespace itk { /** \class StochasticFractalDimensionImageFilter * \brief This filter computes the stochastic fractal dimension of the input image. * - * The methodology is based on Madelbrot’s fractal theory and the concept of + * The methodology is based on Madelbrot's fractal theory and the concept of * fractional Brownian motion and yields images which have been used for * classification and edge enhancement. * diff --git a/Utilities/ITK/Code/Review/itkTxtTransformIO.cxx b/Utilities/ITK/Code/Review/itkTxtTransformIO.cxx index 5fad35cad63cf7cefa2b337d88dfde9bdc440774..8dd29ba94306eb8d2f8c5b1d455a4f985c2323ce 100644 --- a/Utilities/ITK/Code/Review/itkTxtTransformIO.cxx +++ b/Utilities/ITK/Code/Review/itkTxtTransformIO.cxx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkTxtTransformIO.cxx,v $ Language: C++ - Date: $Date: 2009-05-11 16:37:34 $ - Version: $Revision: 1.5 $ + Date: $Date: 2010-02-08 20:24:36 $ + Version: $Revision: 1.6 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -122,11 +122,21 @@ Read() TmpFixedParameterArray.clear(); bool haveFixedParameters = false; bool haveParameters = false; - + // + // check for line end convention + std::string line_end("\n"); + if(data.find('\n') == std::string::npos) + { + if(data.find('\r') == std::string::npos) + { + itkExceptionMacro ( "No line ending character found, not a valid ITK Transform TXT file" ); + } + line_end = "\r"; + } while ( position < data.size() ) { // Find the next string - std::string::size_type end = data.find ( "\n", position ); + std::string::size_type end = data.find ( line_end, position ); std::string line = trim ( data.substr ( position, end - position ) ); position = end+1; itkDebugMacro ("Found line: \"" << line << "\"" ); diff --git a/Utilities/ITK/Code/Review/itkVTKPolyDataReader.h b/Utilities/ITK/Code/Review/itkVTKPolyDataReader.h index 93965b02fc994b72d361cf6132b597c331ffb3df..45ba0d1940e160c14990bd883fc2fdbbd1e2e207 100644 --- a/Utilities/ITK/Code/Review/itkVTKPolyDataReader.h +++ b/Utilities/ITK/Code/Review/itkVTKPolyDataReader.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkVTKPolyDataReader.h,v $ Language: C++ - Date: $Date: 2008-01-15 19:10:40 $ - Version: $Revision: 1.8 $ + Date: $Date: 2009-09-16 19:25:13 $ + Version: $Revision: 1.9 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -29,8 +29,10 @@ namespace itk * \brief * Reads a vtkPolyData file and create an itkMesh. * - * Caveat: itkVTKPolyDataReader can only read triangle meshes. - * Use vtkTriangleFilter to convert your mesh to a triangle mesh. + * Caveat1: itkVTKPolyDataReader can only read triangle meshes. + * Use vtkTriangleFilter to convert your mesh to a triangle mesh. + * Caviet2: itkVTKPolyDataReader can only read vtk legacy files. + * Caveat3: itkVTKPolyDataReader cannot read binary vtk files. */ template <class TOutputMesh> class VTKPolyDataReader : public MeshSource<TOutputMesh> @@ -86,6 +88,12 @@ public: itkSetStringMacro(FileName); itkGetStringMacro(FileName); + /** Get the file version line */ + itkGetStringMacro(Version); + + /** Get the file header line */ + itkGetStringMacro(Header); + protected: VTKPolyDataReader(); ~VTKPolyDataReader() {} @@ -95,11 +103,15 @@ protected: void GenerateData(); /** Filename to read */ - std::string m_FileName; private: VTKPolyDataReader(const Self&); // purposely not implemented void operator=(const Self&); // purposely not implemented + + std::string m_FileName; + std::string m_Header; + std::string m_Version; + }; } // end namespace itk diff --git a/Utilities/ITK/Code/Review/itkVTKPolyDataReader.txx b/Utilities/ITK/Code/Review/itkVTKPolyDataReader.txx index 5ab9d1b19befc11ae719db5e0b2d4c260ad2dfc0..42656992d7433797827beffa4aaaca3a08ccde02 100644 --- a/Utilities/ITK/Code/Review/itkVTKPolyDataReader.txx +++ b/Utilities/ITK/Code/Review/itkVTKPolyDataReader.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkVTKPolyDataReader.txx,v $ Language: C++ - Date: $Date: 2009-06-02 12:48:35 $ - Version: $Revision: 1.16 $ + Date: $Date: 2009-12-02 18:13:18 $ + Version: $Revision: 1.19 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -52,7 +52,7 @@ VTKPolyDataReader<TOutputMesh> if( m_FileName == "" ) { - itkExceptionMacro("No input FileName"); + itkExceptionMacro(<< "No input FileName"); } // @@ -62,22 +62,67 @@ VTKPolyDataReader<TOutputMesh> if( !inputFile.is_open() ) { - itkExceptionMacro("Unable to open file\n" - "inputFilename= " << m_FileName ); + itkExceptionMacro(<< "Unable to open file\n" + << "inputFilename= " << m_FileName ); } + inputFile.imbue(std::locale::classic()); std::string line; + // The first line must be "# vtk DataFile Version x.x" where x.x can + // vary + std::getline( inputFile, m_Version, '\n' ); + if (inputFile.fail()) + { + itkExceptionMacro(<< "Error reading file: " << m_FileName + << "\nUnexpected end-of-file trying to read first line."); + } + if (m_Version.find("# vtk DataFile Version ") == std::string::npos) + { + itkExceptionMacro(<< "Error reading file: " << m_FileName + << "\nOnly vtk legacy format files can be read." + << "\nThis file does not start with the line: # vtk DataFile Version x.x where x.x is the version."); + } + + // Next is a one line description + std::getline( inputFile, m_Header, '\n' ); + if (inputFile.eof()) + { + itkExceptionMacro(<< "Error reading file: " << m_FileName + << "\nUnexpected end-of-file trying to read header."); + } + + // Next is the file format + std::getline( inputFile, line, '\n' ); + if (inputFile.eof()) + { + itkExceptionMacro(<< "Error reading file: " << m_FileName + << "\nUnexpected end-of-file trying to file format."); + } + if (line.find("ASCII") == std::string::npos) + { + itkExceptionMacro(<< "Error reading file: " << m_FileName + << "\nFile format is " << line + << " but only ASCII files can be read."); + } + + bool foundPoints = false; while( !inputFile.eof() ) { - std::getline( inputFile, line ); + std::getline( inputFile, line, '\n' ); if( line.find("POINTS") != std::string::npos ) { + foundPoints = true; break; } } + if (!foundPoints) + { + itkExceptionMacro(<< "Error reading file: " << m_FileName + << "\nUnexpected end-of-file before finding POINTS."); + } itkDebugMacro("POINTS line" << line ); std::string pointLine( line, strlen("POINTS "), line.length() ); @@ -87,16 +132,18 @@ VTKPolyDataReader<TOutputMesh> if( sscanf(pointLine.c_str(),"%d",&numberOfPoints) != 1 ) { - itkExceptionMacro("ERROR: Failed to read numberOfPoints\n" - " pointLine= " << pointLine ); + itkExceptionMacro(<< "Error reading file: " << m_FileName + << "\nFailed to read numberOfPoints.\n" + << " pointLine= " << pointLine ); } itkDebugMacro("numberOfPoints= " << numberOfPoints ); if( numberOfPoints < 1 ) { - itkExceptionMacro("numberOfPoints < 1" - << " numberOfPoints= " << numberOfPoints ); + itkExceptionMacro(<< "Error reading file: " << m_FileName + << "numberOfPoints < 1" + << " numberOfPoints line= " << numberOfPoints ); } outputMesh->GetPoints()->Reserve( numberOfPoints ); @@ -110,13 +157,35 @@ VTKPolyDataReader<TOutputMesh> for( int i=0; i < numberOfPoints; i++ ) { inputFile >> point; + if (inputFile.eof()) + { + itkExceptionMacro(<< "Error while reading file: " << m_FileName + << "\nUnexpected end-of-file trying to read points."); + } + if (inputFile.fail()) + { + itkExceptionMacro(<< "Error reading file: " << m_FileName + << "\nInput could not be interpreted as a point."); + } outputMesh->SetPoint( i, point ); } // Continue searching for the POLYGONS line - while( !inputFile.eof() && line.find("POLYGONS") == std::string::npos ) + bool foundPolygons = false; + while( !inputFile.eof() ) { - std::getline( inputFile, line ); + std::getline( inputFile, line, '\n' ); + if (line.find("POLYGONS") != std::string::npos ) + { + foundPolygons = true; + break; + } + } + + if (!foundPolygons) + { + itkExceptionMacro(<< "Error reading file: " << m_FileName + << "\nUnexpected end-of-file before finding POLYGONS."); } itkDebugMacro( "POLYGONS line" << line ); @@ -134,8 +203,9 @@ VTKPolyDataReader<TOutputMesh> if( sscanf( polygonLine.c_str(), "%ld %ld", &numberOfPolygons, &numberOfIndices ) != 2 ) { - itkExceptionMacro("ERROR: Failed to read numberOfPolygons from subline2" - "\npolygonLine= " << polygonLine ); + itkExceptionMacro(<< "Error reading file: " << m_FileName + << "\nFailed to read numberOfPolygons from subline2" + << "\npolygonLine = " << polygonLine ); } itkDebugMacro("numberOfPolygons " << numberOfPolygons ); @@ -143,15 +213,17 @@ VTKPolyDataReader<TOutputMesh> if( numberOfPolygons < 1 ) { - itkExceptionMacro("ERROR: numberOfPolygons < 1\nnumberOfPolygons= " - << numberOfPolygons ); + itkExceptionMacro(<< "Error reading file: " << m_FileName + << "\nnumberOfPolygons < 1\nnumberOfPolygons= " + << numberOfPolygons ); } if( numberOfIndices < numberOfPolygons ) { - itkExceptionMacro("ERROR: numberOfIndices < numberOfPolygons\n" - << "numberOfIndices= " << numberOfIndices << "\n" - << "numberOfPolygons= " << numberOfPolygons ); + itkExceptionMacro(<< "Error reading file: " << m_FileName + << "\nnumberOfIndices < numberOfPolygons\n" + << "numberOfIndices= " << numberOfIndices << "\n" + << "numberOfPolygons= " << numberOfPolygons ); } // @@ -163,49 +235,56 @@ VTKPolyDataReader<TOutputMesh> for(CellIdentifier i=0; i<numberOfPolygons; i++) { + std::getline( inputFile, line, '\n' ); if( inputFile.eof() ) { - itkExceptionMacro("Failed to read " << numberOfPolygons - << " polygons before the end of file"); + itkExceptionMacro(<< "Error reading file: " << m_FileName + << "\nFailed to read " << numberOfPolygons + << " polygons before the end of file." + << " Only read " << i+1); } - std::getline( inputFile, line ); - if( line.find("DATA") != std::string::npos ) { - itkExceptionMacro("Read keyword DATA"); + itkExceptionMacro(<< "Error reading file: " << m_FileName + << "\nRead keyword DATA"); } int got; if( (got = sscanf( line.c_str(), "%ld %ld %ld %ld", &numberOfCellPoints, &ids[0], &ids[1], &ids[2] )) != 4 ) { - itkExceptionMacro("Error parsing POLYGON cell. Expected 4 items but got " + itkExceptionMacro(<< "Error reading file: " << m_FileName + << "\nError parsing POLYGON cell. Expected 4 items but got " << got << std::endl << "Line is: " << line); } if( numberOfCellPoints != 3 ) { - itkExceptionMacro("ERROR: numberOfCellPoints != 3\n" - << "numberOfCellPoints= " << numberOfCellPoints - << "itkVTKPolyDataReader can only read triangles"); + itkExceptionMacro(<< "Error reading file: " << m_FileName + << "\nnumberOfCellPoints != 3\n" + << "numberOfCellPoints= " << numberOfCellPoints + << ". VTKPolyDataReader can only read triangles"); } if( static_cast<long>(ids[0]) < 0 || static_cast<long>(ids[1]) < 0 || static_cast<long>(ids[2]) < 0 ) { - itkExceptionMacro("ERROR: Incorrect point ids\n" - "ids=" << ids[0] << " " << ids[1] << " " << ids[2]); + itkExceptionMacro(<< "Error reading file: " << m_FileName + << "point ids must be >= 0.\n" + "ids=" << ids[0] << " " << ids[1] << " " << ids[2]); } if( static_cast<long>(ids[0]) >= numberOfPoints || static_cast<long>(ids[1]) >= numberOfPoints || static_cast<long>(ids[2]) >= numberOfPoints ) { - itkExceptionMacro("ERROR: Incorrect point ids\n" - << "ids=" << ids[0] << " " << ids[1] << " " << ids[2]); + itkExceptionMacro(<< "Error reading file: " << m_FileName + << "Point ids must be < number of points: " + << numberOfPoints + << "\nids= " << ids[0] << " " << ids[1] << " " << ids[2]); } CellAutoPointer cell; @@ -223,7 +302,7 @@ VTKPolyDataReader<TOutputMesh> while( !inputFile.eof() ) { - std::getline( inputFile, line ); + std::getline( inputFile, line, '\n' ); if( line.find("POINT_DATA") != std::string::npos ) { @@ -244,19 +323,21 @@ VTKPolyDataReader<TOutputMesh> // Skip two lines if (!inputFile.eof()) { - std::getline( inputFile, line ); + std::getline( inputFile, line, '\n' ); } else { - itkExceptionMacro("Unexpected end-of-file while trying to read POINT_DATA."); + itkExceptionMacro(<< "Error reading file: " << m_FileName + << "\nUnexpected end-of-file while trying to read POINT_DATA."); } if (!inputFile.eof()) { - std::getline( inputFile, line ); + std::getline( inputFile, line, '\n' ); } else { - itkExceptionMacro("Unexpected end-of-file while trying to read POINT_DATA."); + itkExceptionMacro(<< "Error reading file: " << m_FileName + << "\nUnexpected end-of-file while trying to read POINT_DATA."); } double pointData; @@ -265,13 +346,14 @@ VTKPolyDataReader<TOutputMesh> { if (inputFile.eof()) { - itkExceptionMacro("Unexpected end-of-file while trying to read POINT_DATA." << "Failed while trying to reading point data for id: " << pid); + itkExceptionMacro(<< "Error reading file: " << m_FileName + << "\nUnexpected end-of-file while trying to read POINT_DATA." + << "Failed while trying to reading point data for id: " << pid); } inputFile >> pointData; outputMesh->SetPointData( pid, pointData ); } } - inputFile.close(); } @@ -283,6 +365,8 @@ VTKPolyDataReader<TOutputMesh> Superclass::PrintSelf(os,indent); os << indent << "FileName: " << m_FileName << std::endl; + os << indent << "Version: " << m_Version << std::endl; + os << indent << "Header: " << m_Header << std::endl; } } //end of namespace itk diff --git a/Utilities/ITK/Code/Review/itkVTKPolyDataWriter.txx b/Utilities/ITK/Code/Review/itkVTKPolyDataWriter.txx index 3ab6f9fca2b5cf94878e224cff99f4ad7bc8b870..55aea8f14f7e6f85a71b10b680869a4a9995fab8 100644 --- a/Utilities/ITK/Code/Review/itkVTKPolyDataWriter.txx +++ b/Utilities/ITK/Code/Review/itkVTKPolyDataWriter.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkVTKPolyDataWriter.txx,v $ Language: C++ - Date: $Date: 2009-05-15 19:12:49 $ - Version: $Revision: 1.14 $ + Date: $Date: 2009-12-02 18:13:21 $ + Version: $Revision: 1.15 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -99,6 +99,7 @@ VTKPolyDataWriter<TInputMesh> return; } + outputFile.imbue(std::locale::classic()); outputFile << "# vtk DataFile Version 2.0" << std::endl; outputFile << "File written by itkVTKPolyDataWriter" << std::endl; outputFile << "ASCII" << std::endl; diff --git a/Utilities/ITK/Code/Review/itkVectorLinearInterpolateNearestNeighborExtrapolateImageFunction.h b/Utilities/ITK/Code/Review/itkVectorLinearInterpolateNearestNeighborExtrapolateImageFunction.h index 7946435df9312b200e1cf6b99326858763343f1b..8181514c7bf2102a080daa3da366655eb725e322 100644 --- a/Utilities/ITK/Code/Review/itkVectorLinearInterpolateNearestNeighborExtrapolateImageFunction.h +++ b/Utilities/ITK/Code/Review/itkVectorLinearInterpolateNearestNeighborExtrapolateImageFunction.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkVectorLinearInterpolateNearestNeighborExtrapolateImageFunction.h,v $ Language: C++ - Date: $Date: 2008-09-30 14:04:52 $ - Version: $Revision: 1.6 $ + Date: $Date: 2009-10-29 11:19:20 $ + Version: $Revision: 1.7 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -85,6 +85,7 @@ public: /** Index typedef support. */ typedef typename Superclass::IndexType IndexType; + typedef typename Superclass::IndexValueType IndexValueType; /** ContinuousIndex typedef support. */ typedef typename Superclass::ContinuousIndexType ContinuousIndexType; diff --git a/Utilities/ITK/Code/Review/itkVectorLinearInterpolateNearestNeighborExtrapolateImageFunction.txx b/Utilities/ITK/Code/Review/itkVectorLinearInterpolateNearestNeighborExtrapolateImageFunction.txx index 928ff46b7f96bc8cb2d836bedfb0e0737b7cc3f9..cf9a8aecf6993fa34c2dc44788460b947aa0e5c5 100644 --- a/Utilities/ITK/Code/Review/itkVectorLinearInterpolateNearestNeighborExtrapolateImageFunction.txx +++ b/Utilities/ITK/Code/Review/itkVectorLinearInterpolateNearestNeighborExtrapolateImageFunction.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkVectorLinearInterpolateNearestNeighborExtrapolateImageFunction.txx,v $ Language: C++ - Date: $Date: 2009-04-23 03:43:42 $ - Version: $Revision: 1.4 $ + Date: $Date: 2009-10-29 11:19:21 $ + Version: $Revision: 1.5 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -72,19 +72,19 @@ VectorLinearInterpolateNearestNeighborExtrapolateImageFunction< TInputImage, TCo * Compute base index = closest index below point * Compute distance from point to base index */ - signed long baseIndex[ImageDimension]; + IndexType baseIndex; IndexType neighIndex; double distance[ImageDimension]; for( dim = 0; dim < ImageDimension; dim++ ) { - baseIndex[dim] = (long) vcl_floor(index[dim] ); + baseIndex[dim] = Math::Floor<IndexValueType>( index[dim] ); if( baseIndex[dim] >= this->m_StartIndex[dim] ) { if( baseIndex[dim] < this->m_EndIndex[dim] ) { - distance[dim] = index[dim] - double( baseIndex[dim] ); + distance[dim] = index[dim] - static_cast<double>( baseIndex[dim] ); } else { diff --git a/Utilities/ITK/Code/Review/itkVoxBoCUBImageIO.cxx b/Utilities/ITK/Code/Review/itkVoxBoCUBImageIO.cxx index 8f6e6fb16c7a8c2e7d7af30c5059f8a32510cd92..15062fa011fc576a68a7c36e566413ec2605f279 100644 --- a/Utilities/ITK/Code/Review/itkVoxBoCUBImageIO.cxx +++ b/Utilities/ITK/Code/Review/itkVoxBoCUBImageIO.cxx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkVoxBoCUBImageIO.cxx,v $ Language: C++ - Date: $Date: 2008-10-04 14:13:19 $ - Version: $Revision: 1.11 $ + Date: $Date: 2009-11-29 02:06:56 $ + Version: $Revision: 1.12 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -53,9 +53,11 @@ public: GenericCUBFileAdaptor() {} virtual ~GenericCUBFileAdaptor() {} + typedef ImageIOBase::SizeType SizeType; + virtual unsigned char ReadByte() = 0; - virtual void ReadData(void *data, unsigned long bytes) = 0; - virtual void WriteData(const void *data, unsigned long bytes) = 0; + virtual void ReadData(void *data, SizeType bytes) = 0; + virtual void WriteData(const void *data, SizeType bytes) = 0; std::string ReadHeader() { @@ -128,7 +130,7 @@ public: return static_cast<unsigned char>(byte); } - void ReadData(void *data, unsigned long bytes) + void ReadData(void *data, SizeType bytes) { if(m_GzFile == NULL) { @@ -137,7 +139,8 @@ public: throw exception; } - size_t bread = ::gzread(m_GzFile, data, bytes); + unsigned int numberOfBytesToRead = Math::CastWithRangeCheck< unsigned int, SizeType >( bytes ); + SizeType bread = ::gzread(m_GzFile, data, numberOfBytesToRead ); if( bread != bytes ) { itksys_ios::ostringstream oss; @@ -151,7 +154,7 @@ public: } } - void WriteData(const void *data, unsigned long bytes) + void WriteData(const void *data, SizeType bytes) { if(m_GzFile == NULL) { @@ -160,7 +163,8 @@ public: throw exception; } - size_t bwritten = ::gzwrite(m_GzFile, const_cast<void *>(data), bytes); + unsigned int numberOfBytesToWrite = Math::CastWithRangeCheck< unsigned int, SizeType >( bytes ); + SizeType bwritten = ::gzwrite(m_GzFile, const_cast<void *>(data), numberOfBytesToWrite); if( bwritten != bytes ) { ExceptionObject exception; @@ -215,7 +219,7 @@ public: return static_cast<unsigned char>(byte); } - void ReadData(void *data, unsigned long bytes) + void ReadData(void *data, SizeType bytes) { if(m_File == NULL) { @@ -224,7 +228,8 @@ public: throw exception; } - size_t bread = fread(data, 1, bytes, m_File); + const size_t numberOfBytesToRead = Math::CastWithRangeCheck< size_t, SizeType >( bytes ); + SizeType bread = fread(data, NumericTraits<size_t>::One, numberOfBytesToRead, m_File); if( bread != bytes ) { itksys_ios::ostringstream oss; @@ -238,7 +243,7 @@ public: } } - void WriteData(const void *data, unsigned long bytes) + void WriteData(const void *data, SizeType bytes) { if(m_File == NULL) { @@ -247,7 +252,8 @@ public: throw exception; } - size_t bwritten = fwrite(data, 1, bytes, m_File); + const size_t numberOfBytesToWrite = Math::CastWithRangeCheck< size_t, SizeType >( bytes ); + SizeType bwritten = fwrite(data, NumericTraits<size_t>::One, numberOfBytesToWrite, m_File); if( bwritten != bytes ) { ExceptionObject exception; @@ -272,9 +278,11 @@ template<typename TPixel> class VoxBoCUBImageIOSwapHelper { public: - typedef ImageIOBase::ByteOrder ByteOrder; + typedef ImageIOBase::ByteOrder ByteOrder; + typedef ImageIOBase::BufferSizeType BufferSizeType; + static void SwapIfNecessary( - void *buffer, unsigned long numberOfBytes, ByteOrder dataByteOrder) + void *buffer, BufferSizeType numberOfBytes, ByteOrder dataByteOrder) { if ( dataByteOrder == ImageIOBase::LittleEndian ) { @@ -444,8 +452,10 @@ void VoxBoCUBImageIO::Read(void* buffer) throw exception; } - m_Reader->ReadData(buffer, GetImageSizeInBytes()); - this->SwapBytesIfNecessary(buffer, GetImageSizeInBytes()); + BufferSizeType numberOfBytesToRead = + Math::CastWithRangeCheck< BufferSizeType, SizeType >( this->GetImageSizeInBytes() ); + m_Reader->ReadData( buffer, numberOfBytesToRead ); + this->SwapBytesIfNecessary(buffer, numberOfBytesToRead ); } /** @@ -725,7 +735,7 @@ VoxBoCUBImageIO { m_Writer = CreateWriter(m_FileName.c_str()); WriteImageInformation(); - m_Writer->WriteData(buffer, GetImageSizeInBytes()); + m_Writer->WriteData(buffer, this->GetImageSizeInBytes()); delete m_Writer; m_Writer=NULL; } @@ -829,7 +839,7 @@ VoxBoCUBImageIO void VoxBoCUBImageIO -::SwapBytesIfNecessary(void *buffer, unsigned long numberOfBytes) +::SwapBytesIfNecessary(void *buffer, BufferSizeType numberOfBytes) { if(m_ComponentType == CHAR) { diff --git a/Utilities/ITK/Code/Review/itkVoxBoCUBImageIO.h b/Utilities/ITK/Code/Review/itkVoxBoCUBImageIO.h index d33122dad18c2afc66fbb3900c0804bc4365f2a4..4f2326afa7aaf9f7bf6c1ebde75c2be33713c7d1 100644 --- a/Utilities/ITK/Code/Review/itkVoxBoCUBImageIO.h +++ b/Utilities/ITK/Code/Review/itkVoxBoCUBImageIO.h @@ -3,7 +3,7 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkVoxBoCUBImageIO.h,v $ Language: C++ - Date: $Date: 2008-06-18 19:28:57 $ + Date: $Date: 2009-11-29 02:06:56 $ Version: $1.0$ Copyright (c) Insight Software Consortium. All rights reserved. @@ -114,7 +114,7 @@ private: InverseOrientationMap m_InverseOrientationMap; // Method to swap bytes in read buffer - void SwapBytesIfNecessary(void *buffer, unsigned long numberOfBytes); + void SwapBytesIfNecessary(void *buffer, BufferSizeType numberOfBytes); // Strings used in VoxBo files static const char * m_VB_IDENTIFIER_SYSTEM; diff --git a/Utilities/ITK/Code/SpatialObject/CMakeLists.txt b/Utilities/ITK/Code/SpatialObject/CMakeLists.txt index 0920cd603e900604b31531e4d6e72119f16bcac9..772df1e352c6d4df820a94f5b53451423ae7cf1a 100644 --- a/Utilities/ITK/Code/SpatialObject/CMakeLists.txt +++ b/Utilities/ITK/Code/SpatialObject/CMakeLists.txt @@ -17,10 +17,16 @@ IF(NOT ITK_INSTALL_NO_LIBRARIES) ARCHIVE DESTINATION ${ITK_INSTALL_LIB_DIR_CM24} COMPONENT Development) ENDIF(NOT ITK_INSTALL_NO_LIBRARIES) +IF(ITK_USE_FLAT_DIRECTORY_INSTALL) + SET( ITK_INSTALL_INCLUDE_DIR_CM24_SPATIALOBJECTS ${ITK_INSTALL_INCLUDE_DIR_CM24}) +ELSE(ITK_USE_FLAT_DIRECTORY_INSTALL) + SET( ITK_INSTALL_INCLUDE_DIR_CM24_SPATIALOBJECTS ${ITK_INSTALL_INCLUDE_DIR_CM24}/SpatialObject) +ENDIF(ITK_USE_FLAT_DIRECTORY_INSTALL) + IF(NOT ITK_INSTALL_NO_DEVELOPMENT) FILE(GLOB __files1 "${CMAKE_CURRENT_SOURCE_DIR}/*.h") FILE(GLOB __files2 "${CMAKE_CURRENT_SOURCE_DIR}/*.txx") INSTALL(FILES ${__files1} ${__files2} - DESTINATION ${ITK_INSTALL_INCLUDE_DIR_CM24}/SpatialObject + DESTINATION ${ITK_INSTALL_INCLUDE_DIR_CM24_SPATIALOBJECTS} COMPONENT Development) ENDIF(NOT ITK_INSTALL_NO_DEVELOPMENT) diff --git a/Utilities/ITK/Code/SpatialObject/itkDTITubeSpatialObject.h b/Utilities/ITK/Code/SpatialObject/itkDTITubeSpatialObject.h index 22a9fd756137b24b7633209545e40e653a885a14..fbb068903545334ca2653cec59256673f2f1c9fa 100644 --- a/Utilities/ITK/Code/SpatialObject/itkDTITubeSpatialObject.h +++ b/Utilities/ITK/Code/SpatialObject/itkDTITubeSpatialObject.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkDTITubeSpatialObject.h,v $ Language: C++ - Date: $Date: 2009-04-07 14:33:56 $ - Version: $Revision: 1.5 $ + Date: $Date: 2010-01-26 13:57:57 $ + Version: $Revision: 1.6 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -75,6 +75,10 @@ protected: /** Method to print the object.*/ virtual void PrintSelf( std::ostream& os, Indent indent ) const; +private: + DTITubeSpatialObject(const Self&); //purposely not implemented + void operator=(const Self&); //purposely not implemented + }; } // end namespace itk diff --git a/Utilities/ITK/Code/SpatialObject/itkImageMaskSpatialObject.h b/Utilities/ITK/Code/SpatialObject/itkImageMaskSpatialObject.h index 0340f03624c3d758b2af47e709215dc3eb14126c..04b40f90e94a6f67f9fd050ca0039b8cf11fba8d 100644 --- a/Utilities/ITK/Code/SpatialObject/itkImageMaskSpatialObject.h +++ b/Utilities/ITK/Code/SpatialObject/itkImageMaskSpatialObject.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkImageMaskSpatialObject.h,v $ Language: C++ - Date: $Date: 2009-04-07 14:34:01 $ - Version: $Revision: 1.7 $ + Date: $Date: 2009-11-03 12:20:44 $ + Version: $Revision: 1.8 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -52,6 +52,7 @@ public: typedef typename Superclass::ImagePointer ImagePointer; typedef typename Superclass::IndexType IndexType; typedef typename Superclass::RegionType RegionType; + typedef typename Superclass::SizeType SizeType; typedef typename Superclass::TransformType TransformType; typedef typename Superclass::PointType PointType; typedef typename Superclass::BoundingBoxType BoundingBoxType; diff --git a/Utilities/ITK/Code/SpatialObject/itkImageMaskSpatialObject.txx b/Utilities/ITK/Code/SpatialObject/itkImageMaskSpatialObject.txx index f90551391a45ab752a1bffb968a9b082743b4c99..d1e4df7a0ab364a91f1d990fff9c7202961374b0 100644 --- a/Utilities/ITK/Code/SpatialObject/itkImageMaskSpatialObject.txx +++ b/Utilities/ITK/Code/SpatialObject/itkImageMaskSpatialObject.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkImageMaskSpatialObject.txx,v $ Language: C++ - Date: $Date: 2009-01-28 20:10:27 $ - Version: $Revision: 1.19 $ + Date: $Date: 2009-11-03 12:20:44 $ + Version: $Revision: 1.21 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -123,9 +123,11 @@ ImageMaskSpatialObject< TDimension > ImagePointer image = this->GetImage(); - IndexType index; - typename RegionType::SizeType size; + typedef typename SizeType::SizeValueType SizeValueType; + IndexType index; + SizeType size; + if( ImageType::ImageDimension == 3) { @@ -220,8 +222,19 @@ ImageMaskSpatialObject< TDimension > IndexType tmpIndex = it.GetIndex(); for ( unsigned int i = 0; i < ImageType::ImageDimension; ++i ) { - index[ i ] = index[ i ] < tmpIndex[ i ] ? index[ i ] : tmpIndex[ i ]; - size[ i ] = (long)size[ i ] > tmpIndex[ i ] ? size[ i ] : tmpIndex[ i ]; + + if ( index[ i ] > tmpIndex[ i ] ) + { + index[ i ] = tmpIndex[ i ]; + } + + const SizeValueType tmpSize = static_cast< SizeValueType >( tmpIndex[ i ] ); + + if ( size[ i ] < tmpSize ) + { + size[ i ] = tmpSize; + } + } } ++it; diff --git a/Utilities/ITK/Code/SpatialObject/itkImageSpatialObject.txx b/Utilities/ITK/Code/SpatialObject/itkImageSpatialObject.txx index 55fa2d49f593d0319631c3fa48b05ce16530165b..5cbcad541b3d7203b05ca244c5d279b0bb2c3503 100644 --- a/Utilities/ITK/Code/SpatialObject/itkImageSpatialObject.txx +++ b/Utilities/ITK/Code/SpatialObject/itkImageSpatialObject.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkImageSpatialObject.txx,v $ Language: C++ - Date: $Date: 2009-04-07 14:34:02 $ - Version: $Revision: 1.61 $ + Date: $Date: 2010-02-02 19:07:36 $ + Version: $Revision: 1.62 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -178,11 +178,13 @@ ImageSpatialObject< TDimension, PixelType > ::ValueAt( const PointType & point, double & value, unsigned int depth, char * name ) const { + bool returnValue = false; + if( IsEvaluableAt( point, 0, name ) ) { if( !this->SetInternalInverseTransformToWorldToIndexTransform() ) { - return false; + return returnValue; } PointType p = this->GetInternalInverseTransform()->TransformPoint(point); @@ -198,7 +200,7 @@ ImageSpatialObject< TDimension, PixelType > DefaultConvertPixelTraits<InterpolatorOutputType>::GetScalarValue( m_Interpolator->EvaluateAtContinuousIndex(index))); - return true; + returnValue = true; } else { @@ -207,15 +209,15 @@ ImageSpatialObject< TDimension, PixelType > double val; Superclass::ValueAt(point, val, depth, name); value = val; - return true; + returnValue = true; } else { value = this->GetDefaultOutsideValue(); - return false; + returnValue = false; } } - return false; + return returnValue; } /** Compute the bounds of the image */ diff --git a/Utilities/ITK/Code/SpatialObject/itkLandmarkSpatialObject.h b/Utilities/ITK/Code/SpatialObject/itkLandmarkSpatialObject.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/SpatialObject/itkLandmarkSpatialObject.txx b/Utilities/ITK/Code/SpatialObject/itkLandmarkSpatialObject.txx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Code/SpatialObject/itkPolygonSpatialObject.txx b/Utilities/ITK/Code/SpatialObject/itkPolygonSpatialObject.txx index 9107d34be94ac19cadfa6d7ced3922079df65625..f295a342a44485c3c578ed6895970db3cdc06253 100644 --- a/Utilities/ITK/Code/SpatialObject/itkPolygonSpatialObject.txx +++ b/Utilities/ITK/Code/SpatialObject/itkPolygonSpatialObject.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkPolygonSpatialObject.txx,v $ Language: C++ -Date: $Date: 2009-04-08 18:27:47 $ -Version: $Revision: 1.26 $ +Date: $Date: 2009-12-03 06:15:25 $ +Version: $Revision: 1.29 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -29,6 +29,11 @@ PolygonGroupOrientation PolygonSpatialObject<TDimension> ::Plane() const { + if (Self::ObjectDimension == 2) + { + return Axial; + } + PolygonGroupOrientation plane; // local typedef to shut up the compiler... @@ -58,11 +63,11 @@ PolygonSpatialObject<TDimension> } else if(min[0] != max[0] && min[1] == max[1] && min[2] != max[2]) { - plane = Axial; + plane = Coronal; } else if(min[0] != max[0] && min[1] != max[1] && min[2] == max[2]) { - plane = Coronal; + plane = Axial; } else { @@ -149,10 +154,10 @@ PolygonSpatialObject<TDimension> X = 1; Y = 2; break; case Axial: - X = 0; Y = 2; + X = 0; Y = 1; break; case Coronal: - X = 0; Y = 1; + X = 0; Y = 2; break; default: ExceptionObject exception(__FILE__, __LINE__); @@ -417,10 +422,10 @@ PolygonSpatialObject<TDimension> X = 1; Y = 2; break; case Axial: - X = 0; Y = 2; + X = 0; Y = 1; break; case Coronal: - X = 0; Y = 1; + X = 0; Y = 2; break; default: ExceptionObject exception(__FILE__, __LINE__); @@ -481,6 +486,7 @@ PolygonSpatialObject<TDimension> } } } + return oddNodes; } diff --git a/Utilities/ITK/Code/SpatialObject/itkTubeSpatialObject.h b/Utilities/ITK/Code/SpatialObject/itkTubeSpatialObject.h index 67870c2d509876eed4791263c9bdedd4b2a5eac7..35039507ac1ea80be05102a632529dae109a12b1 100644 --- a/Utilities/ITK/Code/SpatialObject/itkTubeSpatialObject.h +++ b/Utilities/ITK/Code/SpatialObject/itkTubeSpatialObject.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkTubeSpatialObject.h,v $ Language: C++ - Date: $Date: 2009-04-07 14:34:17 $ - Version: $Revision: 1.47 $ + Date: $Date: 2010-01-21 22:33:38 $ + Version: $Revision: 1.48 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -154,7 +154,6 @@ public: protected: - PointListType m_Points; int m_ParentPoint; unsigned int m_EndType; @@ -171,7 +170,11 @@ protected: /** TimeStamps */ mutable unsigned long m_OldMTime; mutable unsigned long m_IndexToWorldTransformMTime; - + +private: + TubeSpatialObject(const Self&); //purposely not implemented + void operator=(const Self&); //purposely not implemented + }; } // end namespace itk diff --git a/Utilities/ITK/Code/SpatialObject/itkTubeSpatialObjectPoint.txx b/Utilities/ITK/Code/SpatialObject/itkTubeSpatialObjectPoint.txx index 66ed3ce8513ffd6c1f6840ac0ce3ef0d61053658..02d5c351e99d73458ed6c143531e22424332b3b5 100644 --- a/Utilities/ITK/Code/SpatialObject/itkTubeSpatialObjectPoint.txx +++ b/Utilities/ITK/Code/SpatialObject/itkTubeSpatialObjectPoint.txx @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module:$RCSfile: itkTubeSpatialObjectPoint.txx,v $ Language:C++ -Date:$Date: 2004-12-14 00:31:22 $ -Version: $Revision: 1.10 $ +Date:$Date: 2010-01-21 22:29:55 $ +Version: $Revision: 1.11 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -174,6 +174,14 @@ TubeSpatialObjectPoint< TPointDimension > m_Normal2[1] = v21; } +template< unsigned int TPointDimension > +unsigned short int +TubeSpatialObjectPoint< TPointDimension > +::GetNumDimensions( void ) const +{ + return m_NumDimensions; +} + template< unsigned int TPointDimension > void TubeSpatialObjectPoint< TPointDimension > diff --git a/Utilities/ITK/Code/SpatialObject/itkVesselTubeSpatialObject.h b/Utilities/ITK/Code/SpatialObject/itkVesselTubeSpatialObject.h index 2248e0a697bda10ee5dc5912a78b95ecd4cef357..e3d09ee8d02df2c004d05826009c9ed42270918b 100644 --- a/Utilities/ITK/Code/SpatialObject/itkVesselTubeSpatialObject.h +++ b/Utilities/ITK/Code/SpatialObject/itkVesselTubeSpatialObject.h @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkVesselTubeSpatialObject.h,v $ Language: C++ - Date: $Date: 2009-04-07 14:34:18 $ - Version: $Revision: 1.5 $ + Date: $Date: 2010-01-26 13:57:59 $ + Version: $Revision: 1.6 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -75,6 +75,10 @@ protected: /** Method to print the object.*/ virtual void PrintSelf( std::ostream& os, Indent indent ) const; +private: + VesselTubeSpatialObject(const Self&); //purposely not implemented + void operator=(const Self&); //purposely not implemented + }; } // end namespace itk diff --git a/Utilities/ITK/ITKConfig.cmake.in b/Utilities/ITK/ITKConfig.cmake.in index f9ec8487793365f15bf26cf3f5f3e143b7bc6262..79915a729f878c036249587c571074f837a948d8 100644 --- a/Utilities/ITK/ITKConfig.cmake.in +++ b/Utilities/ITK/ITKConfig.cmake.in @@ -63,6 +63,8 @@ SET(ITK_USE_REVIEW_STATISTICS "@ITK_USE_REVIEW_STATISTICS@") SET(ITK_USE_TRANSFORM_IO_FACTORIES "@ITK_USE_TRANSFORM_IO_FACTORIES@") SET(ITK_USE_OPTIMIZED_REGISTRATION_METHODS "@ITK_USE_OPTIMIZED_REGISTRATION_METHODS@") SET(ITK_USE_ORIENTED_IMAGE_DIRECTION "@ITK_USE_ORIENTED_IMAGE_DIRECTION@") +SET(ITK_USE_CENTERED_PIXEL_COORDINATES_CONSISTENTLY "@ITK_USE_CENTERED_PIXEL_COORDINATES_CONSISTENTLY@") +SET(ITK_USE_REGION_VALIDATION_IN_ITERATORS "@ITK_USE_REGION_VALIDATION_IN_ITERATORS@") # The VXL_DIR setting used to build ITK. Set if ITK_USE_SYSTEM_VXL is true. # same for gdcm diff --git a/Utilities/ITK/Utilities/CMakeLists.txt b/Utilities/ITK/Utilities/CMakeLists.txt index 60e62ebebb7deef969263a85622ba1274c4ac93a..34e58b506cc470130205982c84d672a48076aa1c 100644 --- a/Utilities/ITK/Utilities/CMakeLists.txt +++ b/Utilities/ITK/Utilities/CMakeLists.txt @@ -53,7 +53,7 @@ ITK_THIRD_PARTY_SUBDIR(GDCM gdcm) # # Handle the special case of building libxml2 -# Fetch libxml2 using subversion if requested +# Fetch libxml2 using subversion if requested IF(ITK_USE_LIBXML2) IF(NOT ITK_USE_SYSTEM_LIBXML2) IF(EXISTS "${ITK_BINARY_DIR}/Utilities/itklibxml2/VERSION_2_6_27_1.txt") @@ -78,7 +78,7 @@ IF(ITK_USE_LIBXML2) SET(svnDir "${ITK_BINARY_DIR}/Utilities") FILE(WRITE ${ITK_BINARY_DIR}/Utilities/t "t\n") EXECUTE_PROCESS( - COMMAND "${SVNCOMMAND}" ${svnCmd} ${svnRevFlag} ${svnRevNum} ${svnSite} ${svnDir} + COMMAND "${SVNCOMMAND}" ${svnCmd} ${svnRevFlag} ${svnRevNum} ${svnSite} ${svnDir} INPUT_FILE ${ITK_BINARY_DIR}/Utilities/t OUTPUT_VARIABLE svnOutput ERROR_VARIABLE svnError @@ -86,7 +86,7 @@ IF(ITK_USE_LIBXML2) ) # Result should be 0 on success IF(NOT svnResult) - ADD_SUBDIRECTORY( "${ITK_BINARY_DIR}/Utilities/itklibxml2" + ADD_SUBDIRECTORY( "${ITK_BINARY_DIR}/Utilities/itklibxml2" "${ITK_BINARY_DIR}/Utilities/itklibxml2" ) ELSE(NOT svnResult) MESSAGE(FATAL_ERROR "SVN checkout of itklibxml2 failed with error = ${svnError}") @@ -148,6 +148,14 @@ IF(NOT ITK_INSTALL_NO_DEVELOPMENT) ENDIF(NOT ITK_INSTALL_NO_DEVELOPMENT) #----------------------------------------------------------------------------- + +IF(ITK_USE_FLAT_DIRECTORY_INSTALL) + SET( ITK_INSTALL_INCLUDE_DIR_CM24_UTILITIES ${ITK_INSTALL_INCLUDE_DIR_CM24}) +ELSE(ITK_USE_FLAT_DIRECTORY_INSTALL) + SET( ITK_INSTALL_INCLUDE_DIR_CM24_UTILITIES ${ITK_INSTALL_INCLUDE_DIR_CM24}/Utilities) +ENDIF(ITK_USE_FLAT_DIRECTORY_INSTALL) + + IF(NOT ITK_INSTALL_NO_DEVELOPMENT) INSTALL(FILES ${ITK_BINARY_DIR}/Utilities/itkThirdParty.h @@ -156,13 +164,13 @@ IF(NOT ITK_INSTALL_NO_DEVELOPMENT) ${ITK_SOURCE_DIR}/Utilities/itk_png.h ${ITK_SOURCE_DIR}/Utilities/metaIOConfig.h ${ITK_BINARY_DIR}/Utilities/NrrdIO/NrrdConfigure.h - DESTINATION ${ITK_INSTALL_INCLUDE_DIR_CM24}/Utilities + DESTINATION ${ITK_INSTALL_INCLUDE_DIR_CM24_UTILITIES} COMPONENT Development ) IF(ITK_USE_LIBXML2) INSTALL(FILES "${ITK_BINARY_DIR}/Utilities/itk_libxml2.h" - DESTINATION "${ITK_INSTALL_INCLUDE_DIR_CM24}/Utilities" + DESTINATION "${ITK_INSTALL_INCLUDE_DIR_CM24_UTILITIES}" COMPONENT Development ) ENDIF(ITK_USE_LIBXML2) diff --git a/Utilities/ITK/Utilities/DICOMParser/CMakeLists.txt b/Utilities/ITK/Utilities/DICOMParser/CMakeLists.txt index 751a906b916ceb8c0c2b4b9ddcdb51c6245cbd11..7a71b5084caaa0467d0da451895ba652e1f90589 100644 --- a/Utilities/ITK/Utilities/DICOMParser/CMakeLists.txt +++ b/Utilities/ITK/Utilities/DICOMParser/CMakeLists.txt @@ -67,10 +67,17 @@ IF(NOT ITK_INSTALL_NO_LIBRARIES) ARCHIVE DESTINATION ${ITK_INSTALL_LIB_DIR_CM24} COMPONENT Development) ENDIF(NOT ITK_INSTALL_NO_LIBRARIES) +IF(ITK_USE_FLAT_DIRECTORY_INSTALL) + SET( ITK_INSTALL_INCLUDE_DIR_CM24_UTILITIES ${ITK_INSTALL_INCLUDE_DIR_CM24}) +ELSE(ITK_USE_FLAT_DIRECTORY_INSTALL) + SET( ITK_INSTALL_INCLUDE_DIR_CM24_UTILITIES ${ITK_INSTALL_INCLUDE_DIR_CM24}/Utilities) +ENDIF(ITK_USE_FLAT_DIRECTORY_INSTALL) + + IF(NOT ITK_INSTALL_NO_DEVELOPMENT) FILE(GLOB __files1 "${CMAKE_CURRENT_SOURCE_DIR}/*.h") FILE(GLOB __files2 "${CMAKE_CURRENT_SOURCE_DIR}/*.txx") INSTALL(FILES ${__files1} ${__files2} ${PROJECT_BINARY_DIR}/DICOMCMakeConfig.h - DESTINATION ${ITK_INSTALL_INCLUDE_DIR_CM24}/Utilities + DESTINATION ${ITK_INSTALL_INCLUDE_DIR_CM24_UTILITIES} COMPONENT Development) ENDIF(NOT ITK_INSTALL_NO_DEVELOPMENT) diff --git a/Utilities/ITK/Utilities/DICOMParser/Copyright.txt b/Utilities/ITK/Utilities/DICOMParser/Copyright.txt old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Utilities/DICOMParser/DICOMAppHelper.cxx b/Utilities/ITK/Utilities/DICOMParser/DICOMAppHelper.cxx index b4bf549ab49a6b98fbb7496c48906f3db315b656..677d41ce182ddbe3a901ae1a2f75ed026a95cd04 100644 --- a/Utilities/ITK/Utilities/DICOMParser/DICOMAppHelper.cxx +++ b/Utilities/ITK/Utilities/DICOMParser/DICOMAppHelper.cxx @@ -3,8 +3,8 @@ Program: DICOMParser Module: $RCSfile: DICOMAppHelper.cxx,v $ Language: C++ - Date: $Date: 2005-03-15 17:00:37 $ - Version: $Revision: 1.72 $ + Date: $Date: 2009-11-21 19:44:58 $ + Version: $Revision: 1.73 $ Copyright (c) 2003 Matt Turek All rights reserved. @@ -139,15 +139,15 @@ DICOMAppHelper::DICOMAppHelper() this->FileCount = 0; this->BitsAllocated = 8; this->ByteSwapData = false; - this->PixelSpacing[0] = this->PixelSpacing[1] = this->PixelSpacing[2] = 1.0; + this->PixelSpacing[0] = this->PixelSpacing[1] = this->PixelSpacing[2] = 1.0f; this->Dimensions[0] = this->Dimensions[1] = 0; this->Width = this->Height = 0; this->PhotometricInterpretation = NULL; this->TransferSyntaxUID = NULL; this->CurrentSeriesUID = ""; this->InstanceUID = ""; - this->RescaleOffset = 0.0; - this->RescaleSlope = 1.0; + this->RescaleOffset = 0.0f; + this->RescaleSlope = 1.0f; this->ImageData = NULL; this->ImageDataLengthInBytes = 0; @@ -980,9 +980,9 @@ void DICOMAppHelper::ImagePositionPatientCallback(DICOMParser *, else { // no actual position specified, default to the origin - ord.ImagePositionPatient[0] = 0.0; - ord.ImagePositionPatient[1] = 0.0; - ord.ImagePositionPatient[2] = 0.0; + ord.ImagePositionPatient[0] = 0.0f; + ord.ImagePositionPatient[1] = 0.0f; + ord.ImagePositionPatient[2] = 0.0f; } // insert into the map @@ -1005,9 +1005,9 @@ void DICOMAppHelper::ImagePositionPatientCallback(DICOMParser *, else { // no actual position specified, default to the origin - (*it).second.ImagePositionPatient[0] = 0.0; - (*it).second.ImagePositionPatient[1] = 0.0; - (*it).second.ImagePositionPatient[2] = 0.0; + (*it).second.ImagePositionPatient[0] = 0.0f; + (*it).second.ImagePositionPatient[1] = 0.0f; + (*it).second.ImagePositionPatient[2] = 0.0f; } // cache the value @@ -1044,12 +1044,12 @@ void DICOMAppHelper::ImageOrientationPatientCallback(DICOMParser *, else { // no orientation defined, default to an standard axial orientation - ord.ImageOrientationPatient[0] = 1.0; - ord.ImageOrientationPatient[1] = 0.0; - ord.ImageOrientationPatient[2] = 0.0; - ord.ImageOrientationPatient[3] = 0.0; - ord.ImageOrientationPatient[4] = 1.0; - ord.ImageOrientationPatient[5] = 0.0; + ord.ImageOrientationPatient[0] = 1.0f; + ord.ImageOrientationPatient[1] = 0.0f; + ord.ImageOrientationPatient[2] = 0.0f; + ord.ImageOrientationPatient[3] = 0.0f; + ord.ImageOrientationPatient[4] = 1.0f; + ord.ImageOrientationPatient[5] = 0.0f; } // insert into the map @@ -1071,12 +1071,12 @@ void DICOMAppHelper::ImageOrientationPatientCallback(DICOMParser *, else { // no orientation defined, default to an standard axial orientation - (*it).second.ImageOrientationPatient[0] = 1.0; - (*it).second.ImageOrientationPatient[1] = 0.0; - (*it).second.ImageOrientationPatient[2] = 0.0; - (*it).second.ImageOrientationPatient[3] = 0.0; - (*it).second.ImageOrientationPatient[4] = 1.0; - (*it).second.ImageOrientationPatient[5] = 0.0; + (*it).second.ImageOrientationPatient[0] = 1.0f; + (*it).second.ImageOrientationPatient[1] = 0.0f; + (*it).second.ImageOrientationPatient[2] = 0.0f; + (*it).second.ImageOrientationPatient[3] = 0.0f; + (*it).second.ImageOrientationPatient[4] = 1.0f; + (*it).second.ImageOrientationPatient[5] = 0.0f; } } } @@ -1180,7 +1180,7 @@ void DICOMAppHelper::PixelSpacingCallback(DICOMParser *parser, if (group == 0x0028 && element == 0x0030) { - float fval = 1.0; // defaul of 1mm + float fval = 1.0f; // defaul of 1mm if (len > 0) { fval = DICOMFile::ReturnAsFloat(val, parser->GetDICOMFile()->GetPlatformIsBigEndian()); @@ -1205,7 +1205,7 @@ void DICOMAppHelper::PixelSpacingCallback(DICOMParser *parser, } else if (group == 0x0018 && element == 0x0050) { - float fval = 1.0; // defaul of 1mm + float fval = 1.0f; // defaul of 1mm if (len > 0) { fval = DICOMFile::ReturnAsFloat(val, parser->GetDICOMFile()->GetPlatformIsBigEndian()); @@ -1664,7 +1664,7 @@ void DICOMAppHelper::RescaleOffsetCallback( DICOMParser *parser, unsigned char* val, quadbyte len) { - float fval = 0.0; + float fval = 0.0f; if (len > 0) { @@ -1684,7 +1684,7 @@ void DICOMAppHelper::RescaleSlopeCallback(DICOMParser *parser, unsigned char* val, quadbyte len) { - float fval = 1.0; + float fval = 1.0f; if (len > 0) { diff --git a/Utilities/ITK/Utilities/DICOMParser/DICOMCMakeConfig.h.in b/Utilities/ITK/Utilities/DICOMParser/DICOMCMakeConfig.h.in old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Utilities/DICOMParser/DICOMConfig.h b/Utilities/ITK/Utilities/DICOMParser/DICOMConfig.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Utilities/DICOMParser/DICOMSource.cxx b/Utilities/ITK/Utilities/DICOMParser/DICOMSource.cxx index 8ec58db0294c976148d0c4c1c333027cdbae9e86..8fed86fa9d3af7e70cffa913428c427e9c73f4d0 100644 --- a/Utilities/ITK/Utilities/DICOMParser/DICOMSource.cxx +++ b/Utilities/ITK/Utilities/DICOMParser/DICOMSource.cxx @@ -3,8 +3,8 @@ Program: DICOMParser Module: $RCSfile: DICOMSource.cxx,v $ Language: C++ - Date: $Date: 2009-04-05 10:56:58 $ - Version: $Revision: 1.3 $ + Date: $Date: 2009-11-21 19:44:58 $ + Version: $Revision: 1.4 $ Copyright (c) 2003 Matt Turek All rights reserved. @@ -142,7 +142,7 @@ quadbyte DICOMSource::ReadNBytes(int len) float DICOMSource::ReadAsciiFloat(int len) { - float ret=0.0; + float ret=0.0f; char* val = new char[len+1]; diff --git a/Utilities/ITK/Utilities/Dart/PrintSelfCheck.tcl b/Utilities/ITK/Utilities/Dart/PrintSelfCheck.tcl index ade29a0aaaec623d9389d08cf98c093fffcc2713..e1cb52fe55c1be121edeb8f051e7e62fd5f7c913 100644 --- a/Utilities/ITK/Utilities/Dart/PrintSelfCheck.tcl +++ b/Utilities/ITK/Utilities/Dart/PrintSelfCheck.tcl @@ -299,6 +299,16 @@ proc check_printself { filename } { set ivar [string range $token 2 end] set ivar [string trim $ivar] + if { [list_contains "$class_name.i.$ivar"] == 1 } { + set class_list($class_name.i.$ivar) 1 + } elseif { $verbose } { + puts "\tIvar Issue:\t\tCan't find $class_name.i.$ivar" + } + } elseif { [string match Get* "$token"] == 1 } { + set token_end [expr [string wordend $data $start ] - 1] + set ivar [string range $token 3 end] + set ivar [string trim $ivar] + if { [list_contains "$class_name.i.$ivar"] == 1 } { set class_list($class_name.i.$ivar) 1 } elseif { $verbose } { diff --git a/Utilities/ITK/Utilities/Doxygen/cvsVersionFilter.sh b/Utilities/ITK/Utilities/Doxygen/cvsVersionFilter.sh old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Utilities/Doxygen/doxygen.config.in b/Utilities/ITK/Utilities/Doxygen/doxygen.config.in index 46067ee33fce4c5cc7234e7998c6287efb55a883..c0cdfedb835377411ca634804b37c378e349e09a 100644 --- a/Utilities/ITK/Utilities/Doxygen/doxygen.config.in +++ b/Utilities/ITK/Utilities/Doxygen/doxygen.config.in @@ -483,6 +483,7 @@ EXCLUDE = "@ITK_SOURCE_DIR@/Code/Common/itkPixelTraits.h" \ "@ITK_SOURCE_DIR@/Code/Common/itkNumericTraitsTensorPixel.h" \ "@ITK_SOURCE_DIR@/Code/Common/itkNumericTraitsCovariantVectorPixel.h" \ "@ITK_SOURCE_DIR@/Code/Common/itkNumericTraitsVariableLengthVectorPixel.h" \ + "@ITK_SOURCE_DIR@/Code/Common/itkMathDetail.h" \ "@ITK_SOURCE_DIR@/Code/IO/itkPixelData.h" \ "@ITK_SOURCE_DIR@/Code/IO/itkAnalyzeDbh.h" @@ -1014,6 +1015,13 @@ INCLUDE_FILE_PATTERNS = # instead of the = operator. PREDEFINED = "itkNotUsed(x)="\ + "itkStaticConstMacro(name,type,value)=static const type name = value"\ + "itkSetInputMacro(name, type, number)= \ + virtual void Set##name##Input(const type *_arg); \ + virtual void SetInput##number(const type *_arg);" \ + "itkGetInputMacro(name, type, number)= \ + virtual const type * Get##name##Input() const; \ + virtual const type * GetInput##number() const;" \ "itkSetMacro(name,type)= \ virtual void Set##name (type _arg);" \ "itkGetMacro(name,type)= \ @@ -1036,8 +1044,24 @@ PREDEFINED = "itkNotUsed(x)="\ virtual const type* Get##name ();" \ "itkGetConstReferenceMacro(name,type)= \ virtual const type& Get##name ();" \ + "itkSetEnumMacro(name,type)= \ + virtual void Set##name (const type _arg);" \ + "itkGetEnumMacro(name,type)= \ + virtual type Get##name () const;" \ "itkGetConstReferenceObjectMacro(name,type)= \ virtual const type::Pointer& Get##name () const;" \ + "itkSetDecoratedInputMacro(name, type, number)= \ + virtual void Set##name##Input(const SimpleDataObjectDecorator<type> *_arg); \ + virtual void SetInput##number(const SimpleDataObjectDecorator<type> *_arg); \ + virtual const SimpleDataObjectDecorator<type> * Get##name##Input() const; \ + virtual const SimpleDataObjectDecorator<type> * GetInput##number() const; \ + virtual void Set##name(const type &_arg);" \ + "itkSetDecoratedObjectInputMacro(name, type, number)= \ + virtual void Set##name##Input(const DataObjectDecorator<type> *_arg); \ + virtual void SetInput##number(const DataObjectDecorator<type> *_arg); \ + virtual const DataObjectDecorator<type> * Get##name##Input() const; \ + virtual const DataObjectDecorator<type> * GetInput##number() const; \ + virtual void Set##name(const type *_arg);" \ "itkBooleanMacro(name)= \ virtual void name##On (); \ virtual void name##Off ();" \ @@ -1075,6 +1099,9 @@ PREDEFINED = "itkNotUsed(x)="\ virtual type* Get##name () const;" \ "itkNewMacro(type)= \ static Pointer New();" \ + "itkFactorylessNewMacro(x)= \ + static Pointer New(void); \ + virtual ::itk::LightObject::Pointer CreateAnother(void) const;" \ "itkTypeMacro(thisClass,superclass)= \ virtual const char *GetNameOfClass() const;" \ "itkEventMacro(thisClass,superclass)= \ @@ -1087,6 +1114,8 @@ PREDEFINED = "itkNotUsed(x)="\ std::numeric_limits" \ "ITK_TYPENAME= \ typename" \ + "itkTemplateFloatingToIntegerMacro(name)= \ + template <TReturn, typename TInput> name( TInput x )" \ "FEM_ABSTRACT_CLASS(thisClass,parentClass)= \ public: \ /** Standard "Self" typedef.*/ \ @@ -1112,12 +1141,13 @@ PREDEFINED = "itkNotUsed(x)="\ static Self::Pointer New() \ { return new Self(); } \ private:" \ - "FREEVERSION" "ERROR_CHECKING" \ + "FREEVERSION" "ERROR_CHECKING" \ "HAS_TIFF" "HAS_JPEG" "HAS_NETLIB" "HAS_PNG" "HAS_ZLIB" \ "HAS_GLUT" "HAS_QT" \ "VCL_USE_NATIVE_STL=1" "VCL_USE_NATIVE_COMPLEX=1" \ "VCL_HAS_BOOL=1" "VXL_BIG_ENDIAN=1" "VXL_LITTLE_ENDIAN=0"\ - "VNL_DLL_DATA=" "size_t=vcl_size_t" + "VNL_DLL_DATA=" "size_t=vcl_size_t"\ + "ITK_HAS_INT_64" # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then diff --git a/Utilities/ITK/Utilities/Doxygen/itkdoxygen.pl.in b/Utilities/ITK/Utilities/Doxygen/itkdoxygen.pl.in old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Utilities/Doxygen/vxl_doxy.pl b/Utilities/ITK/Utilities/Doxygen/vxl_doxy.pl old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Utilities/KWStyle/ITKOverwrite.txt b/Utilities/ITK/Utilities/KWStyle/ITKOverwrite.txt index 4a636ac48938687da3a6aa1c3b1219134a71d42e..1c16d914b9d91351885a66568e59ae5da5aff40a 100644 --- a/Utilities/ITK/Utilities/KWStyle/ITKOverwrite.txt +++ b/Utilities/ITK/Utilities/KWStyle/ITKOverwrite.txt @@ -103,3 +103,4 @@ itkKdTreeGenerator.h InternalVariables Disable itkNormalVariateGenerator.h InternalVariables Disable itkStatisticsTypesTest.cxx Typedefs Disable itkLabelStatisticsImageFilter.h Indent Disable +itkIntTypes.h Typedefs Disable diff --git a/Utilities/ITK/Utilities/MetaIO/.svnrev b/Utilities/ITK/Utilities/MetaIO/.svnrev index e2a83a8ce3c7e2098c21145f578ff91b7541c16a..dfac53b0c4c76e690a689ad7a23fe770d6082340 100644 --- a/Utilities/ITK/Utilities/MetaIO/.svnrev +++ b/Utilities/ITK/Utilities/MetaIO/.svnrev @@ -1 +1 @@ -855 \ No newline at end of file +1641 \ No newline at end of file diff --git a/Utilities/ITK/Utilities/MetaIO/metaArray.cxx b/Utilities/ITK/Utilities/MetaIO/metaArray.cxx index 53267996125f8b927291e84c143929f1bed0f4b2..169d43984ce552bba817181f1e8762b0f90ab967 100644 --- a/Utilities/ITK/Utilities/MetaIO/metaArray.cxx +++ b/Utilities/ITK/Utilities/MetaIO/metaArray.cxx @@ -3,8 +3,8 @@ Program: MetaIO Module: $RCSfile: metaArray.cxx,v $ Language: C++ - Date: $Date: 2009-06-21 21:54:05 $ - Version: $Revision: 1.10 $ + Date: $Date: 2009-11-21 18:59:39 $ + Version: $Revision: 1.11 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -1156,7 +1156,7 @@ M_ReadElements(METAIO_STREAM::ifstream * _fstream, void * _data, } unsigned char* compr = new unsigned char[m_CompressedElementDataSize]; - _fstream->read((char *)compr, m_CompressedElementDataSize); + _fstream->read((char *)compr, (size_t)m_CompressedElementDataSize); MET_PerformUncompression(compr, m_CompressedElementDataSize, (unsigned char *)_data, readSize); @@ -1198,7 +1198,7 @@ M_ReadElements(METAIO_STREAM::ifstream * _fstream, void * _data, // bool MetaArray:: M_WriteElements(METAIO_STREAM::ofstream * _fstream, const void * _data, - int _dataQuantity) + METAIO_STL::streamoff _dataQuantity) { bool localData = false; METAIO_STREAM::ofstream* tmpWriteStream; @@ -1256,7 +1256,7 @@ M_WriteElements(METAIO_STREAM::ofstream * _fstream, const void * _data, } else { - tmpWriteStream->write( (const char *)_data, _dataQuantity ); + tmpWriteStream->write( (const char *)_data, (size_t)_dataQuantity ); } if(!localData) diff --git a/Utilities/ITK/Utilities/MetaIO/metaArray.h b/Utilities/ITK/Utilities/MetaIO/metaArray.h index 4fb5703ee7770e1cdc4b1c4eed6ef4af14c19309..5e3e06c7e0aa3acc2d6f674013b58e1518e9103a 100644 --- a/Utilities/ITK/Utilities/MetaIO/metaArray.h +++ b/Utilities/ITK/Utilities/MetaIO/metaArray.h @@ -3,8 +3,8 @@ Program: MetaIO Module: $RCSfile: metaArray.h,v $ Language: C++ - Date: $Date: 2008-04-09 01:44:29 $ - Version: $Revision: 1.6 $ + Date: $Date: 2009-11-21 18:59:39 $ + Version: $Revision: 1.7 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -187,7 +187,7 @@ class METAIO_EXPORT MetaArray : public MetaForm bool m_AutoFreeElementData; - unsigned int m_CompressedElementDataSize; + METAIO_STL::streamoff m_CompressedElementDataSize; char m_ElementDataFileName[255]; @@ -207,7 +207,7 @@ class METAIO_EXPORT MetaArray : public MetaForm bool M_WriteElements(METAIO_STREAM::ofstream * _fstream, const void * _data, - int _dataQuantity); + METAIO_STL::streamoff _dataQuantity); }; diff --git a/Utilities/ITK/Utilities/MetaIO/metaBlob.cxx b/Utilities/ITK/Utilities/MetaIO/metaBlob.cxx index db9c530dd6ced031885fa82e493f1df1c303add1..33beab9342310274c6deec206537035b7849e041 100644 --- a/Utilities/ITK/Utilities/MetaIO/metaBlob.cxx +++ b/Utilities/ITK/Utilities/MetaIO/metaBlob.cxx @@ -3,8 +3,8 @@ Program: MetaIO Module: $RCSfile: metaBlob.cxx,v $ Language: C++ - Date: $Date: 2008-04-09 01:44:28 $ - Version: $Revision: 1.28 $ + Date: $Date: 2009-11-21 18:59:39 $ + Version: $Revision: 1.29 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -40,10 +40,10 @@ BlobPnt(int dim) } //Color is red by default - m_Color[0]=1.0; - m_Color[1]=0.0; - m_Color[2]=0.0; - m_Color[3]=1.0; + m_Color[0]=1.0f; + m_Color[1]=0.0f; + m_Color[2]=0.0f; + m_Color[3]=1.0f; } BlobPnt:: diff --git a/Utilities/ITK/Utilities/MetaIO/metaContour.cxx b/Utilities/ITK/Utilities/MetaIO/metaContour.cxx index b78b1f605f53f55e1f3662cc6dfae441a5856348..3cf0c618f63e657ff488d8add61ba8b9e3312b60 100644 --- a/Utilities/ITK/Utilities/MetaIO/metaContour.cxx +++ b/Utilities/ITK/Utilities/MetaIO/metaContour.cxx @@ -3,8 +3,8 @@ Program: MetaIO Module: $RCSfile: metaContour.cxx,v $ Language: C++ - Date: $Date: 2008-04-24 19:13:40 $ - Version: $Revision: 1.16 $ + Date: $Date: 2009-11-21 18:59:39 $ + Version: $Revision: 1.17 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -44,10 +44,10 @@ ContourControlPnt(int dim) m_V[i] = 0; } //Color is red by default - m_Color[0]=1.0; - m_Color[1]=0.0; - m_Color[2]=0.0; - m_Color[3]=1.0; + m_Color[0]=1.0f; + m_Color[1]=0.0f; + m_Color[2]=0.0f; + m_Color[3]=1.0f; } ContourControlPnt:: diff --git a/Utilities/ITK/Utilities/MetaIO/metaContour.h b/Utilities/ITK/Utilities/MetaIO/metaContour.h index 3a90a680ff2a804abb5f99f4cf8ea746e5b4e6c1..f51717fff6b90c21b7a8588ca5f0b7c112f39b0e 100644 --- a/Utilities/ITK/Utilities/MetaIO/metaContour.h +++ b/Utilities/ITK/Utilities/MetaIO/metaContour.h @@ -3,8 +3,8 @@ Program: MetaIO Module: $RCSfile: metaContour.h,v $ Language: C++ - Date: $Date: 2008-04-09 01:44:29 $ - Version: $Revision: 1.9 $ + Date: $Date: 2009-11-21 18:59:39 $ + Version: $Revision: 1.10 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -68,10 +68,10 @@ public: m_Id = 0; m_X = new float[m_Dim]; //Color is red by default - m_Color[0]=1.0; - m_Color[1]=0.0; - m_Color[2]=0.0; - m_Color[3]=1.0; + m_Color[0]=1.0f; + m_Color[1]=0.0f; + m_Color[2]=0.0f; + m_Color[3]=1.0f; } ~ContourInterpolatedPnt() diff --git a/Utilities/ITK/Utilities/MetaIO/metaImage.cxx b/Utilities/ITK/Utilities/MetaIO/metaImage.cxx index 098ae60194122b993ab695ee2efe0319c6bdb98b..ed95f458862e04b00e5d8005ef05665ff0ed911e 100644 --- a/Utilities/ITK/Utilities/MetaIO/metaImage.cxx +++ b/Utilities/ITK/Utilities/MetaIO/metaImage.cxx @@ -3,8 +3,8 @@ Program: MetaIO Module: $RCSfile: metaImage.cxx,v $ Language: C++ - Date: $Date: 2009-07-20 15:34:20 $ - Version: $Revision: 1.119 $ + Date: $Date: 2009-12-07 20:48:04 $ + Version: $Revision: 1.125 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -43,10 +43,59 @@ #include <signal.h> /* sigprocmask */ #endif +namespace { + +void openReadStream(METAIO_STREAM::ifstream & inputStream, const char * fname) +{ +#ifdef __sgi + inputStream.open( fname, METAIO_STREAM::ios::in ); +#else + inputStream.open( fname, METAIO_STREAM::ios::in | + METAIO_STREAM::ios::binary ); +#endif +} + +void openWriteStream(METAIO_STREAM::ofstream & outputStream, const char * fname, bool append) +{ +// Some older sgi compilers have a error in the ofstream constructor +// that requires a file to exist for output +#ifdef __sgi + { + METAIO_STREAM::ofstream tFile(fname, METAIO_STREAM::ios::out); + tFile.close(); + } +#endif + + if(!append) + { +#ifdef __sgi + outputStream.open(fname, METAIO_STREAM::ios::out); +#else + outputStream.open(fname, METAIO_STREAM::ios::binary | + METAIO_STREAM::ios::out); +#endif + } + else + { +#ifdef __sgi + outputStream.open(fname, METAIO_STREAM::ios::app | + METAIO_STREAM::ios::out); +#else + outputStream.open(fname, METAIO_STREAM::ios::binary | + METAIO_STREAM::ios::app | + METAIO_STREAM::ios::out); +#endif + } +} + +} // end anonymous namespace + #if (METAIO_USE_NAMESPACE) namespace METAIO_NAMESPACE { #endif +// 1 Gigabyte is the maximum chunk to read/write in on function call +static const METAIO_STL::streamoff MaxIOChunk = 1024*1024*1024; // // MetaImage Constructors @@ -574,7 +623,7 @@ DimSize(int _i) const // // // -METAIO_STL::streamsize MetaImage:: +METAIO_STL::streamoff MetaImage:: Quantity(void) const { return m_Quantity; @@ -583,13 +632,13 @@ Quantity(void) const // // // -const METAIO_STL::streamsize * MetaImage:: +const METAIO_STL::streamoff * MetaImage:: SubQuantity(void) const { return m_SubQuantity; } -METAIO_STL::streamsize MetaImage:: +METAIO_STL::streamoff MetaImage:: SubQuantity(int _i) const { return m_SubQuantity[_i]; @@ -697,11 +746,11 @@ ElementNumberOfChannels(int _elementNumberOfChannels) // // void MetaImage:: -ElementByteOrderSwap(METAIO_STL::streamsize _quantity) +ElementByteOrderSwap(METAIO_STL::streamoff _quantity) { // use the user provided value if provided or the internal ivar - METAIO_STL::streamsize quantity = _quantity ? _quantity : m_Quantity; + METAIO_STL::streamoff quantity = _quantity ? _quantity : m_Quantity; if(META_DEBUG) { @@ -755,7 +804,7 @@ ElementByteOrderSwap(METAIO_STL::streamsize _quantity) } bool MetaImage:: -ElementByteOrderFix(METAIO_STL::streamsize _quantity) +ElementByteOrderFix(METAIO_STL::streamoff _quantity) { if(m_BinaryDataByteOrderMSB != MET_SystemByteOrderMSB()) { @@ -901,7 +950,7 @@ ElementData(void) } double MetaImage:: -ElementData(METAIO_STL::streamsize _i) const +ElementData(METAIO_STL::streamoff _i) const { double tf = 0; MET_ValueToDouble(m_ElementType, m_ElementData, _i, &tf); @@ -910,7 +959,7 @@ ElementData(METAIO_STL::streamsize _i) const } bool MetaImage:: -ElementData(METAIO_STL::streamsize _i, double _v) +ElementData(METAIO_STL::streamoff _i, double _v) { if(_i<m_Quantity) { @@ -1111,12 +1160,7 @@ CanRead(const char *_headerName) const // Now check the file content METAIO_STREAM::ifstream inputStream; -#ifdef __sgi - inputStream.open( fname.c_str(), METAIO_STREAM::ios::in ); -#else - inputStream.open( fname.c_str(), METAIO_STREAM::ios::in | - METAIO_STREAM::ios::binary ); -#endif + openReadStream(inputStream, fname.c_str()); if( inputStream.fail() ) { @@ -1165,14 +1209,9 @@ Read(const char *_headerName, bool _readElements, void * _buffer) METAIO_STREAM::ifstream * tmpReadStream = new METAIO_STREAM::ifstream; -#ifdef __sgi - tmpReadStream->open(m_FileName, METAIO_STREAM::ios::in); -#else - tmpReadStream->open(m_FileName, METAIO_STREAM::ios::binary | - METAIO_STREAM::ios::in); -#endif + openReadStream(*tmpReadStream, m_FileName); - if(!tmpReadStream->rdbuf()->is_open()) + if(!tmpReadStream->is_open()) { delete tmpReadStream; return false; @@ -1299,13 +1338,8 @@ ReadStream(int _nDims, strcpy(fName, s); } -#ifdef __sgi - readStreamTemp->open(fName, METAIO_STREAM::ios::in); -#else - readStreamTemp->open(fName, METAIO_STREAM::ios::binary | - METAIO_STREAM::ios::in); -#endif - if(!readStreamTemp->rdbuf()->is_open()) + openReadStream(*readStreamTemp, fName); + if(!readStreamTemp->is_open()) { METAIO_STREAM::cerr << "MetaImage: Read: cannot open slice" << METAIO_STREAM::endl; @@ -1360,13 +1394,8 @@ ReadStream(int _nDims, { strcpy(fName, s); } -#ifdef __sgi - readStreamTemp->open(fName, METAIO_STREAM::ios::in); -#else - readStreamTemp->open(fName, METAIO_STREAM::ios::binary - | METAIO_STREAM::ios::in); -#endif - if(!readStreamTemp->rdbuf()->is_open()) + openReadStream(*readStreamTemp,fName); + if(!readStreamTemp->is_open()) { METAIO_STREAM::cerr << "MetaImage: Read: cannot construct file" << METAIO_STREAM::endl; @@ -1401,14 +1430,8 @@ ReadStream(int _nDims, METAIO_STREAM::ifstream* readStreamTemp = new METAIO_STREAM::ifstream; -#ifdef __sgi - readStreamTemp->open(fName, METAIO_STREAM::ios::in); -#else - readStreamTemp->open(fName, METAIO_STREAM::ios::binary | - METAIO_STREAM::ios::in); -#endif - - if(!readStreamTemp->rdbuf()->is_open()) + openReadStream(*readStreamTemp,fName); + if(!readStreamTemp->is_open()) { METAIO_STREAM::cerr << "MetaImage: Read: Cannot open data file" << METAIO_STREAM::endl; @@ -1506,37 +1529,9 @@ Write(const char *_headName, METAIO_STREAM::ofstream * tmpWriteStream = new METAIO_STREAM::ofstream; -// Some older sgi compilers have a error in the ofstream constructor -// that requires a file to exist for output -#ifdef __sgi - { - METAIO_STREAM::ofstream tFile(m_FileName, METAIO_STREAM::ios::out); - tFile.close(); - } -#endif - - if(!_append) - { -#ifdef __sgi - tmpWriteStream->open(m_FileName, METAIO_STREAM::ios::out); -#else - tmpWriteStream->open(m_FileName, METAIO_STREAM::ios::binary | - METAIO_STREAM::ios::out); -#endif - } - else - { -#ifdef __sgi - tmpWriteStream->open(m_FileName, METAIO_STREAM::ios::app | - METAIO_STREAM::ios::out); -#else - tmpWriteStream->open(m_FileName, METAIO_STREAM::ios::binary | - METAIO_STREAM::ios::app | - METAIO_STREAM::ios::out); -#endif - } + openWriteStream(*tmpWriteStream, m_FileName, _append); - if(!tmpWriteStream->rdbuf()->is_open()) + if(!tmpWriteStream->is_open()) { if(!userDataFileName) { @@ -1707,7 +1702,7 @@ bool MetaImage::WriteROI( int * _indexMin, int * _indexMax, NULL, false ); // no memory allocation METAIO_STL::string filename = ElementDataFileName(); - unsigned long dataPos = 0; + METAIO_STL::streampos dataPos = 0; // local file if( filename == "LOCAL" ) @@ -1757,12 +1752,12 @@ bool MetaImage::WriteROI( int * _indexMin, int * _indexMax, int elementNumberOfBytes = elementSize*m_ElementNumberOfChannels; // seek to the end and write one byte to allocate the entire file size - unsigned long seekpos = m_Quantity*elementNumberOfBytes; + METAIO_STL::streamoff seekoff = m_Quantity*elementNumberOfBytes; tmpWriteStream->seekp(0, METAIO_STREAM::ios::end); - if ((unsigned long)(tmpWriteStream->tellp()) != dataPos+seekpos) + if (tmpWriteStream->tellp() != (dataPos+seekoff)) { - seekpos = seekpos - 1; - tmpWriteStream->seekp(dataPos+seekpos, METAIO_STREAM::ios::beg); + seekoff = seekoff - 1; + tmpWriteStream->seekp(dataPos+seekoff, METAIO_STREAM::ios::beg); const char zerobyte = 0; tmpWriteStream->write(&zerobyte, 1); } @@ -1862,37 +1857,9 @@ bool MetaImage::WriteROI( int * _indexMin, int * _indexMax, METAIO_STREAM::ofstream * tmpWriteStream = new METAIO_STREAM::ofstream; - // Some older sgi compilers have a error in the ofstream constructor - // that requires a file to exist for output - #ifdef __sgi - { - METAIO_STREAM::ofstream tFile(m_FileName, METAIO_STREAM::ios::out); - tFile.close(); - } - #endif + openWriteStream(*tmpWriteStream, m_FileName, _append); - if(!_append) - { - #ifdef __sgi - tmpWriteStream->open(m_FileName, METAIO_STREAM::ios::out); - #else - tmpWriteStream->open(m_FileName, METAIO_STREAM::ios::binary | - METAIO_STREAM::ios::out); - #endif - } - else - { - #ifdef __sgi - tmpWriteStream->open(m_FileName, METAIO_STREAM::ios::app | - METAIO_STREAM::ios::out); - #else - tmpWriteStream->open(m_FileName, METAIO_STREAM::ios::binary | - METAIO_STREAM::ios::app | - METAIO_STREAM::ios::out); - #endif - } - - if(!tmpWriteStream->rdbuf()->is_open()) + if(!tmpWriteStream->is_open()) { if(!userDataFileName) { @@ -1914,7 +1881,7 @@ bool MetaImage::WriteROI( int * _indexMin, int * _indexMax, M_SetupWriteFields(); M_Write(); - unsigned long dataPos = m_WriteStream->tellp(); + METAIO_STL::streampos dataPos = m_WriteStream->tellp(); // If data is in a separate file, set dataPos and point to that file. // ( we've already verified the name isn't LIST and doesn't @@ -1925,41 +1892,8 @@ bool MetaImage::WriteROI( int * _indexMin, int * _indexMax, tmpWriteStream->close(); dataPos = 0; - - // Some older sgi compilers have a error in the ofstream constructor - // that requires a file to exist for output - #ifdef __sgi - { - METAIO_STREAM::ofstream tFile( m_ElementDataFileName, - METAIO_STREAM::ios::out ); - tFile.close(); - } - #endif - - if( !_append ) - { - #ifdef __sgi - tmpWriteStream->open( m_ElementDataFileName, - METAIO_STREAM::ios::out ); - #else - tmpWriteStream->open( m_ElementDataFileName, - METAIO_STREAM::ios::binary | - METAIO_STREAM::ios::out ); - #endif - } - else - { - #ifdef __sgi - tmpWriteStream->open( m_ElementDataFileName, - METAIO_STREAM::ios::app | - METAIO_STREAM::ios::out ); - #else - tmpWriteStream->open( m_ElementDataFileName, - METAIO_STREAM::ios::binary | - METAIO_STREAM::ios::app | - METAIO_STREAM::ios::out ); - #endif - } + + openWriteStream(*tmpWriteStream, m_ElementDataFileName, _append); m_WriteStream = tmpWriteStream; } @@ -1968,9 +1902,9 @@ bool MetaImage::WriteROI( int * _indexMin, int * _indexMax, int elementNumberOfBytes = elementSize*m_ElementNumberOfChannels; // write the last byte in the file to allocate it - unsigned long seekpos = m_Quantity * elementNumberOfBytes; - seekpos -= 1; - m_WriteStream->seekp(seekpos, METAIO_STREAM::ios::cur); + METAIO_STL::streamoff seekoff = m_Quantity * elementNumberOfBytes; + seekoff -= 1; + m_WriteStream->seekp(seekoff, METAIO_STREAM::ios::cur); const char zerobyte = 0; m_WriteStream->write(&zerobyte, 1); @@ -1994,7 +1928,7 @@ bool MetaImage::WriteROI( int * _indexMin, int * _indexMax, bool MetaImage:: M_WriteElementsROI(METAIO_STREAM::ofstream * _fstream, const void * _data, - unsigned long _dataPos, + METAIO_STL::streampos _dataPos, int * _indexMin, int* _indexMax ) { @@ -2003,7 +1937,6 @@ M_WriteElementsROI(METAIO_STREAM::ofstream * _fstream, int elementSize; MET_SizeOfType(m_ElementType, &elementSize); const int elementNumberOfBytes = elementSize*m_ElementNumberOfChannels; - const long elementsToWrite = _indexMax[0] - _indexMin[0] + 1; // Write the IO region line by line int * currentIndex = new int[m_NDims]; @@ -2012,33 +1945,46 @@ M_WriteElementsROI(METAIO_STREAM::ofstream * _fstream, currentIndex[i] = _indexMin[i]; } + // Optimize the size of the buffer to written depending on the + // region shape + // This calculate the number of continuous bytes in the file + // which can be written + METAIO_STL::streamoff elementsToWrite = 1; + int movingDirection = 0; + do + { + elementsToWrite *= _indexMax[movingDirection] - _indexMin[movingDirection] + 1; + ++movingDirection; + } + while(movingDirection < m_NDims + && _indexMin[movingDirection-1] == 0 + && _indexMax[movingDirection-1] == m_DimSize[movingDirection-1]-1); + // write line by line bool done = false; while(!done) { // Seek to the right position - unsigned long seekpos = _dataPos; + METAIO_STL::streamoff seekoff = _dataPos; for(int i=0; i<m_NDims; i++) { - seekpos += m_SubQuantity[i] * currentIndex[i] * elementNumberOfBytes; + seekoff += m_SubQuantity[i] * currentIndex[i] * elementNumberOfBytes; } - _fstream->seekp( seekpos, METAIO_STREAM::ios::beg ); - - // Write the line - _fstream->write( data, elementsToWrite*elementNumberOfBytes ); - data += elementsToWrite*elementNumberOfBytes; + _fstream->seekp( seekoff, METAIO_STREAM::ios::beg ); + + M_WriteElementData( _fstream, data, elementsToWrite ); + data += elementsToWrite * elementNumberOfBytes; - if(m_NDims>1) - { - currentIndex[1]++; - } - else + // check if there is only one write needed + if( movingDirection >= m_NDims ) { - done = true; + break; } + + ++currentIndex[movingDirection]; // Check if we are still in the region - for( int j=1; j<m_NDims; j++ ) + for( int j=movingDirection; j<m_NDims; j++ ) { if( currentIndex[j] > _indexMax[j] ) { @@ -2054,7 +2000,7 @@ M_WriteElementsROI(METAIO_STREAM::ofstream * _fstream, } } } - } // end writing line by line loop + } // end writing loop delete [] currentIndex; @@ -2432,7 +2378,7 @@ M_Read(void) // bool MetaImage:: M_ReadElements(METAIO_STREAM::ifstream * _fstream, void * _data, - METAIO_STL::streamsize _dataQuantity) + METAIO_STL::streamoff _dataQuantity) { if(META_DEBUG) { @@ -2452,7 +2398,7 @@ M_ReadElements(METAIO_STREAM::ifstream * _fstream, void * _data, int elementSize; MET_SizeOfType(m_ElementType, &elementSize); - METAIO_STL::streamsize readSize = _dataQuantity*m_ElementNumberOfChannels*elementSize; + METAIO_STL::streamoff readSize = _dataQuantity*m_ElementNumberOfChannels*elementSize; if(META_DEBUG) { METAIO_STREAM::cout << "MetaImage: M_ReadElements: ReadSize = " @@ -2484,7 +2430,8 @@ M_ReadElements(METAIO_STREAM::ifstream * _fstream, void * _data, } unsigned char* compr = new unsigned char[m_CompressedDataSize]; - _fstream->read((char *)compr, m_CompressedDataSize); + + M_ReadElementData( _fstream, compr, m_CompressedDataSize ); MET_PerformUncompression(compr, m_CompressedDataSize, (unsigned char *)_data, readSize); @@ -2500,28 +2447,16 @@ M_ReadElements(METAIO_STREAM::ifstream * _fstream, void * _data, { if(!m_BinaryData) { - double tf; - MET_SizeOfType(m_ElementType, &elementSize); - for(int i=0; i<_dataQuantity; i++) - { - *_fstream >> tf; - MET_DoubleToValue(tf, m_ElementType, _data, i); - _fstream->get(); - } + + M_ReadElementData( _fstream, _data, _dataQuantity ); + } else { - _fstream->read((char *)_data, readSize); - METAIO_STL::streamsize gc = _fstream->gcount(); - if(gc != readSize) - { - METAIO_STREAM::cerr - << "MetaImage: M_ReadElements: data not read completely" - << METAIO_STREAM::endl; - METAIO_STREAM::cerr << " ideal = " << readSize << " : actual = " << gc - << METAIO_STREAM::endl; + + if ( !M_ReadElementData( _fstream, _data, _dataQuantity ) ) return false; - } + } } @@ -2531,7 +2466,7 @@ M_ReadElements(METAIO_STREAM::ifstream * _fstream, void * _data, bool MetaImage:: M_WriteElements(METAIO_STREAM::ofstream * _fstream, const void * _data, - METAIO_STL::streamsize _dataQuantity) + METAIO_STL::streamoff _dataQuantity) { if(!strcmp(m_ElementDataFileName, "LOCAL")) @@ -2558,29 +2493,20 @@ M_WriteElements(METAIO_STREAM::ofstream * _fstream, char fName[255]; int elementSize; MET_SizeOfType(m_ElementType, &elementSize); - METAIO_STL::streamsize elementNumberOfBytes = elementSize*m_ElementNumberOfChannels; - METAIO_STL::streamsize sliceNumberOfBytes = m_SubQuantity[m_NDims-1]*elementNumberOfBytes; + METAIO_STL::streamoff elementNumberOfBytes = elementSize*m_ElementNumberOfChannels; + METAIO_STL::streamoff sliceNumberOfBytes = m_SubQuantity[m_NDims-1]*elementNumberOfBytes; METAIO_STREAM::ofstream* writeStreamTemp = new METAIO_STREAM::ofstream; for(i=1; i<=m_DimSize[m_NDims-1]; i++) { sprintf(fName, dataFileName, i); -// Some older sgi compilers have a error in the ofstream constructor -// that requires a file to exist for output -#ifdef __sgi - { - METAIO_STREAM::ofstream tFile(fName, METAIO_STREAM::ios::out); - tFile.close(); - } - writeStreamTemp->open(fName, METAIO_STREAM::ios::out); -#else - writeStreamTemp->open(fName, METAIO_STREAM::ios::binary | - METAIO_STREAM::ios::out); -#endif + openWriteStream(*writeStreamTemp, fName, false); if(!m_CompressedData) { + // BUG? This looks wrong to me as the third parameter should + // contain the number of elements/quantity, not number of bytes -BCL MetaImage::M_WriteElementData(writeStreamTemp, &(((const char *)_data)[(i-1)*sliceNumberOfBytes]), sliceNumberOfBytes); @@ -2588,7 +2514,7 @@ M_WriteElements(METAIO_STREAM::ofstream * _fstream, else { unsigned char * compressedData = NULL; - unsigned int compressedDataSize = 0; + METAIO_STL::streamoff compressedDataSize = 0; // Compress the data slice by slice compressedData = MET_PerformCompression( @@ -2611,20 +2537,8 @@ M_WriteElements(METAIO_STREAM::ofstream * _fstream, } else // write the image in one unique other file { -// Some older sgi compilers have a error in the ofstream constructor -// that requires a file to exist for output METAIO_STREAM::ofstream* writeStreamTemp = new METAIO_STREAM::ofstream; - -#ifdef __sgi - { - METAIO_STREAM::ofstream tFile(dataFileName, METAIO_STREAM::ios::out); - tFile.close(); - } - writeStreamTemp->open(dataFileName, METAIO_STREAM::ios::out); -#else - writeStreamTemp->open(dataFileName, METAIO_STREAM::ios::binary | - METAIO_STREAM::ios::out); -#endif + openWriteStream(*writeStreamTemp, dataFileName, false); MetaImage::M_WriteElementData(writeStreamTemp, _data, _dataQuantity); @@ -2640,12 +2554,13 @@ M_WriteElements(METAIO_STREAM::ofstream * _fstream, bool MetaImage:: M_WriteElementData(METAIO_STREAM::ofstream * _fstream, const void * _data, - METAIO_STL::streamsize _dataQuantity) + METAIO_STL::streamoff _dataQuantity) { if(!m_BinaryData) { + double tf; - for(METAIO_STL::streamsize i=0; i<_dataQuantity; i++) + for(METAIO_STL::streamoff i=0; i<_dataQuantity; i++) { MET_ValueToDouble(m_ElementType, _data, i, &tf); if((i+1)/10 == (double)(i+1.0)/10.0) @@ -2662,18 +2577,42 @@ M_WriteElementData(METAIO_STREAM::ofstream * _fstream, { if(m_CompressedData) { - _fstream->write( (const char *)_data, _dataQuantity ); + // the data is writen in writes no bigger then MaxIOChunk + METAIO_STL::streamoff bytesRemaining = _dataQuantity; + while ( bytesRemaining ) + { + METAIO_STL::streamoff chunkToWrite = bytesRemaining > MaxIOChunk ? MaxIOChunk : bytesRemaining; + _fstream->write( (const char *)_data, (size_t)chunkToWrite ); + _data = (const char *)(_data) + chunkToWrite; // <- Note: data is changed + bytesRemaining -= chunkToWrite; + } } else { int elementSize; MET_SizeOfType(m_ElementType, &elementSize); - METAIO_STL::streamsize elementNumberOfBytes = elementSize*m_ElementNumberOfChannels; + METAIO_STL::streamoff elementNumberOfBytes = elementSize*m_ElementNumberOfChannels; - _fstream->write( (const char *)_data, - _dataQuantity * elementNumberOfBytes ); + // the data is writen in writes no bigger then MaxIOChunk + METAIO_STL::streamoff bytesRemaining = _dataQuantity * elementNumberOfBytes; + while ( bytesRemaining ) + { + METAIO_STL::streamoff chunkToWrite = bytesRemaining > MaxIOChunk ? MaxIOChunk : bytesRemaining; + _fstream->write( (const char *)_data, (size_t)chunkToWrite ); + _data = (const char *)(_data) + chunkToWrite; // <- Note: _data is changed + bytesRemaining -= chunkToWrite; + } } } + + // check the the io stream did not fail in the process of writing + if ( _fstream->fail() ) + { + METAIO_STREAM::cerr + << "MetaImage: M_WriteElementsData: file stream is fail after write" + << METAIO_STREAM::endl; + return false; + } return true; } @@ -2701,14 +2640,9 @@ ReadROI(int * _indexMin, int * _indexMax, METAIO_STREAM::ifstream * tmpReadStream = new METAIO_STREAM::ifstream; -#ifdef __sgi - tmpReadStream->open(m_FileName, METAIO_STREAM::ios::in); -#else - tmpReadStream->open(m_FileName, METAIO_STREAM::ios::binary | - METAIO_STREAM::ios::in); -#endif + openReadStream(*tmpReadStream, m_FileName); - if(!tmpReadStream->rdbuf()->is_open()) + if(!tmpReadStream->is_open()) { delete tmpReadStream; return false; @@ -2766,7 +2700,7 @@ bool MetaImage::ReadROIStream(int * _indexMin, int * _indexMax, } // Streaming related. We need to update some of the fields - METAIO_STL::streamsize quantity = 1; + METAIO_STL::streamoff quantity = 1; int i; size_t j; for(i=0; i<m_NDims; i++) @@ -2844,13 +2778,8 @@ bool MetaImage::ReadROIStream(int * _indexMin, int * _indexMax, strcpy(fName, s); } -#ifdef __sgi - readStreamTemp->open(fName, METAIO_STREAM::ios::in); -#else - readStreamTemp->open(fName, METAIO_STREAM::ios::binary | - METAIO_STREAM::ios::in); -#endif - if(!readStreamTemp->rdbuf()->is_open()) + openReadStream(*readStreamTemp, fName); + if(!readStreamTemp->is_open()) { METAIO_STREAM::cerr << "MetaImage: Read: cannot open slice" << METAIO_STREAM::endl; @@ -2929,14 +2858,9 @@ bool MetaImage::ReadROIStream(int * _indexMin, int * _indexMax, strcpy(fName, s); } - -#ifdef __sgi - readStreamTemp->open(fName, METAIO_STREAM::ios::in); -#else - readStreamTemp->open(fName, METAIO_STREAM::ios::binary - | METAIO_STREAM::ios::in); -#endif - if(!readStreamTemp->rdbuf()->is_open()) + + openReadStream(*readStreamTemp, fName); + if(!readStreamTemp->is_open()) { METAIO_STREAM::cerr << "MetaImage: Read: cannot construct file" << METAIO_STREAM::endl; @@ -2991,14 +2915,9 @@ bool MetaImage::ReadROIStream(int * _indexMin, int * _indexMax, METAIO_STREAM::ifstream* readStreamTemp = new METAIO_STREAM::ifstream; -#ifdef __sgi - readStreamTemp->open(fName, METAIO_STREAM::ios::in); -#else - readStreamTemp->open(fName, METAIO_STREAM::ios::binary | - METAIO_STREAM::ios::in); -#endif + openReadStream(*readStreamTemp, fName); - if(!readStreamTemp->rdbuf()->is_open()) + if(!readStreamTemp->is_open()) { METAIO_STREAM::cerr << "MetaImage: ReadROI: Cannot open data file" << METAIO_STREAM::endl; @@ -3024,9 +2943,9 @@ bool MetaImage::ReadROIStream(int * _indexMin, int * _indexMax, /** Read an ROI */ bool MetaImage:: M_ReadElementsROI(METAIO_STREAM::ifstream * _fstream, void * _data, - METAIO_STL::streamsize _dataQuantity, + METAIO_STL::streamoff _dataQuantity, int* _indexMin, int* _indexMax,unsigned int subSamplingFactor, - METAIO_STL::streamsize _totalDataQuantity) + METAIO_STL::streamoff _totalDataQuantity) { if(_totalDataQuantity ==0) { @@ -3058,7 +2977,9 @@ M_ReadElementsROI(METAIO_STREAM::ifstream * _fstream, void * _data, int elementSize; MET_SizeOfType(m_ElementType, &elementSize); - METAIO_STL::streamsize readSize = _dataQuantity*m_ElementNumberOfChannels*elementSize; + METAIO_STL::streamoff readSize = _dataQuantity*m_ElementNumberOfChannels*elementSize; + int elementNumberOfBytes = elementSize*m_ElementNumberOfChannels; + if(META_DEBUG) { METAIO_STREAM::cout << "MetaImage: M_ReadElementsROI: ReadSize = " @@ -3072,12 +2993,12 @@ M_ReadElementsROI(METAIO_STREAM::ifstream * _fstream, void * _data, METAIO_STREAM::cout << "MetaImage: M_ReadElementsROI: Skipping header" << METAIO_STREAM::endl; } - METAIO_STL::streamsize headSize = _totalDataQuantity*m_ElementNumberOfChannels*elementSize; + METAIO_STL::streamoff headSize = _totalDataQuantity*m_ElementNumberOfChannels*elementSize; _fstream->seekg(-headSize, METAIO_STREAM::ios::end); } - unsigned long dataPos = _fstream->tellg(); - METAIO_STL::streamsize i; + METAIO_STL::streampos dataPos = _fstream->tellg(); + METAIO_STL::streamoff i; // If compressed we inflate if(m_BinaryData && m_CompressedData) @@ -3101,39 +3022,44 @@ M_ReadElementsROI(METAIO_STREAM::ifstream * _fstream, void * _data, // Optimize the size of the buffer to read depending on the // region shape - METAIO_STL::streamsize readLine = _indexMax[0] - _indexMin[0] + 1; - int movingDirection = 1; - while(movingDirection < m_NDims - && _indexMin[movingDirection] == 0 - && _indexMax[movingDirection] == m_DimSize[movingDirection]-1) - { - readLine *= _indexMax[movingDirection] - _indexMin[movingDirection] + 1; - movingDirection++; + // This calculate the number of continuous bytes in the file + // which can be read + METAIO_STL::streamoff elementsToRead = 1; + int movingDirection = 0; + do + { + elementsToRead *= _indexMax[movingDirection] - _indexMin[movingDirection] + 1; + ++movingDirection; } + while(subSamplingFactor == 1 + && movingDirection < m_NDims + && _indexMin[movingDirection-1] == 0 + && _indexMax[movingDirection-1] == m_DimSize[movingDirection-1]-1); - readLine *= m_ElementNumberOfChannels*elementSize; - long gc = 0; + METAIO_STL::streamoff bytesToRead = elementsToRead*elementNumberOfBytes; + METAIO_STL::streamoff gc = 0; bool done = false; while(!done) { // Seek to the right position - unsigned long seekpos = 0; + METAIO_STL::streamoff seekoff = 0; for(i=0; i<m_NDims; i++) { - seekpos += m_SubQuantity[i]*m_ElementNumberOfChannels*elementSize*currentIndex[i]; + seekoff += m_SubQuantity[i]*elementNumberOfBytes*currentIndex[i]; } + if(subSamplingFactor > 1) { - unsigned char* subdata = new unsigned char[readLine]; + unsigned char* subdata = new unsigned char[bytesToRead]; - MET_UncompressStream(_fstream, seekpos, subdata, - readLine, m_CompressedDataSize, + MET_UncompressStream(_fstream, seekoff, subdata, + bytesToRead, m_CompressedDataSize, m_CompressionTable); - for(METAIO_STL::streamsize p=0; - p<readLine; + for(METAIO_STL::streamoff p=0; + p<bytesToRead; p+=(subSamplingFactor*m_ElementNumberOfChannels*elementSize)) { for(int s=0; s<m_ElementNumberOfChannels*elementSize; s++) @@ -3147,15 +3073,15 @@ M_ReadElementsROI(METAIO_STREAM::ifstream * _fstream, void * _data, } else { - METAIO_STL::streamsize read = MET_UncompressStream( - _fstream, seekpos, data, - readLine, m_CompressedDataSize, + METAIO_STL::streamoff read = MET_UncompressStream( + _fstream, seekoff, data, + bytesToRead, m_CompressedDataSize, m_CompressionTable); - data += readLine; + data += bytesToRead; gc += read; } - if(gc == _dataQuantity*m_ElementNumberOfChannels*elementSize) + if(gc == readSize) { break; } @@ -3213,38 +3139,44 @@ M_ReadElementsROI(METAIO_STREAM::ifstream * _fstream, void * _data, } // Optimize the size of the buffer to read depending on the - // region shape - METAIO_STL::streamsize readLine = _indexMax[0] - _indexMin[0] + 1; - int movingDirection = 1; - while(movingDirection < m_NDims - && subSamplingFactor == 1 && _indexMin[movingDirection] == 0 - && _indexMax[movingDirection] == m_DimSize[movingDirection]-1) + // region shape + // This calculate the number of continuous bytes in the file + // which can be read + METAIO_STL::streamoff elementsToRead = 1; + int movingDirection = 0; + do { - readLine *= _indexMax[movingDirection] - _indexMin[movingDirection] + 1; - movingDirection++; + elementsToRead *= _indexMax[movingDirection] - _indexMin[movingDirection] + 1; + ++movingDirection; } + while(subSamplingFactor == 1 + && movingDirection < m_NDims + && _indexMin[movingDirection-1] == 0 + && _indexMax[movingDirection-1] == m_DimSize[movingDirection-1]-1); - readLine *= m_ElementNumberOfChannels*elementSize; - long gc = 0; + + + //readLine *= m_ElementNumberOfChannels*elementSize; + METAIO_STL::streamoff gc = 0; bool done = false; while(!done) { // Seek to the right position - unsigned long seekpos = 0; + METAIO_STL::streamoff seekoff = 0; for(i=0;i<m_NDims;i++) { - seekpos += m_SubQuantity[i]*m_ElementNumberOfChannels*elementSize*currentIndex[i]; + seekoff += m_SubQuantity[i]*m_ElementNumberOfChannels*elementSize*currentIndex[i]; } - _fstream->seekg(dataPos+seekpos, METAIO_STREAM::ios::beg); + _fstream->seekg(dataPos+seekoff, METAIO_STREAM::ios::beg); // Read a line if(subSamplingFactor > 1) { if(!m_BinaryData) // Not binary data { - for(i=0; i<readLine; i+=subSamplingFactor) + for(i=0; i<elementsToRead; i+=subSamplingFactor) { *_fstream >> tf; MET_DoubleToValue(tf, m_ElementType, _data, i); @@ -3257,13 +3189,15 @@ M_ReadElementsROI(METAIO_STREAM::ifstream * _fstream, void * _data, } else // Binary data { - char* subdata = new char[readLine]; - _fstream->read(subdata, readLine); - for(METAIO_STL::streamsize p=0; - p<readLine; - p+=(subSamplingFactor*m_ElementNumberOfChannels*elementSize)) + char* subdata = new char[elementsToRead*elementNumberOfBytes]; + + _fstream->read(subdata, size_t(elementsToRead*elementNumberOfBytes)); + + for(METAIO_STL::streamoff p=0; + p<elementsToRead*elementNumberOfBytes; + p+=(subSamplingFactor*elementNumberOfBytes)) { - for(int s=0;s<m_ElementNumberOfChannels*elementSize;s++) + for(int s=0;s<elementNumberOfBytes;s++) { *data = subdata[p+s]; gc++; @@ -3277,59 +3211,55 @@ M_ReadElementsROI(METAIO_STREAM::ifstream * _fstream, void * _data, { if(!m_BinaryData) // Not binary data { - for(i=0;i<readLine; i++) - { - *_fstream >> tf; - MET_DoubleToValue(tf, m_ElementType, _data, i); - _fstream->get(); - gc++; - } + // anyone using ROI reading of ASCII?? + // does this work? what about incrementing data? + // what about data sizes and random access of file? + METAIO_STL::streamoff blockSize = elementsToRead*m_ElementNumberOfChannels*elementSize; + M_ReadElementData( _fstream, data, (size_t)blockSize ); + gc += blockSize; + } else // binary data { - _fstream->read(data, readLine); - gc += _fstream->gcount(); - data += _fstream->gcount(); + + M_ReadElementData( _fstream, data, elementsToRead ); + gc += elementsToRead*elementNumberOfBytes; + data += elementsToRead*elementNumberOfBytes; } } - if(gc == _dataQuantity*m_ElementNumberOfChannels*elementSize) + // I don't think this check is really needed -BCL + if(gc == readSize) { break; } - // Go forward - if(m_NDims == 1) + // check if there is only one read needed + if ( movingDirection >= m_NDims ) { break; } - if( movingDirection < m_NDims ) + // Go forward + currentIndex[movingDirection] += subSamplingFactor; + + // Check if we are still in the region + for(i=movingDirection;i<m_NDims;i++) { - currentIndex[movingDirection] += subSamplingFactor; - - // Check if we are still in the region - for(i=1;i<m_NDims;i++) + if(currentIndex[i]>_indexMax[i]) { - if(currentIndex[i]>_indexMax[i]) + if(i==m_NDims-1) { - if(i==m_NDims-1) - { - done = true; - break; - } - else - { - currentIndex[i] = _indexMin[i]; - currentIndex[i+1] += subSamplingFactor; - } + done = true; + break; + } + else + { + currentIndex[i] = _indexMin[i]; + currentIndex[i+1] += subSamplingFactor; } } } - else - { - done = true; - } } delete [] currentIndex; @@ -3348,7 +3278,89 @@ M_ReadElementsROI(METAIO_STREAM::ifstream * _fstream, void * _data, return true; } + +bool MetaImage:: +M_ReadElementData(METAIO_STREAM::ifstream * _fstream, + void * _data, + METAIO_STL::streamoff _dataQuantity) +{ + // NOTE: this method is different from WriteElementData + METAIO_STL::streamoff gc = 0; + + if(!m_BinaryData) + { + double tf; + + for(int i=0; i<_dataQuantity; i++) + { + *_fstream >> tf; + MET_DoubleToValue(tf, m_ElementType, _data, i); + _fstream->get(); + ++gc; + } + } + else + { + if(m_CompressedData) + { + + // the data is read with calls no bigger then MaxIOChunk + METAIO_STL::streamoff bytesRemaining = _dataQuantity; + while ( bytesRemaining ) + { + METAIO_STL::streamoff chunkToRead = bytesRemaining > MaxIOChunk ? MaxIOChunk : bytesRemaining; + _fstream->read( (char *)_data, (size_t)chunkToRead ); + _data = (char *)(_data) + chunkToRead; + bytesRemaining -= chunkToRead; + gc += _fstream->gcount(); + } + + } + else + { + int elementSize; + MET_SizeOfType(m_ElementType, &elementSize); + METAIO_STL::streamoff elementNumberOfBytes = elementSize*m_ElementNumberOfChannels; + + // the data is read with calls no bigger then MaxIOChunk + METAIO_STL::streamoff bytesRemaining = _dataQuantity * elementNumberOfBytes; + while ( bytesRemaining ) + { + METAIO_STL::streamoff chunkToRead = bytesRemaining > MaxIOChunk ? MaxIOChunk : bytesRemaining; + _fstream->read( (char *)_data, (size_t)chunkToRead ); + _data = (char *)(_data) + chunkToRead; + bytesRemaining -= chunkToRead; + gc += _fstream->gcount(); + } + // convert to number of bytes so that it'll match gc's units + _dataQuantity *= elementNumberOfBytes; + } + } + + // check that we actually read the correct number of bytes + if( gc != _dataQuantity ) + { + METAIO_STREAM::cerr + << "MetaImage: M_ReadElementsData: data not read completely" + << METAIO_STREAM::endl; + METAIO_STREAM::cerr << " ideal = " << _dataQuantity << " : actual = " << gc + << METAIO_STREAM::endl; + return false; + } + + // check the the io stream did not fail in the process of reading + if ( _fstream->fail() ) + { + METAIO_STREAM::cerr + << "MetaImage: M_ReadElementsData: file stream is fail after read" + << METAIO_STREAM::endl; + return false; + } + + return true; + } + + #if (METAIO_USE_NAMESPACE) }; #endif - diff --git a/Utilities/ITK/Utilities/MetaIO/metaImage.h b/Utilities/ITK/Utilities/MetaIO/metaImage.h index e32963b319b5894c564f574ca07ae80f81d74747..39eb0e42011b6294277994ee18dee75784d787f7 100644 --- a/Utilities/ITK/Utilities/MetaIO/metaImage.h +++ b/Utilities/ITK/Utilities/MetaIO/metaImage.h @@ -3,8 +3,8 @@ Program: MetaIO Module: $RCSfile: metaImage.h,v $ Language: C++ - Date: $Date: 2009-07-07 20:04:04 $ - Version: $Revision: 1.33 $ + Date: $Date: 2009-11-21 18:59:39 $ + Version: $Revision: 1.35 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -138,14 +138,14 @@ class METAIO_EXPORT MetaImage : public MetaObject // Quantity() // Not a field in file // Total number of elements in image (Prod(dimSize[i])) - METAIO_STL::streamsize Quantity(void) const; + METAIO_STL::streamoff Quantity(void) const; // SubQuantity(...) // Not a field in file // Number of elements in image spanning sub-dimensions // E.g., elements per line, 2D sub-image, 3D sub-volume, - const METAIO_STL::streamsize * SubQuantity(void) const; - METAIO_STL::streamsize SubQuantity(int _i) const; + const METAIO_STL::streamoff * SubQuantity(void) const; + METAIO_STL::streamoff SubQuantity(int _i) const; // SequenceID(...) // Optional Field @@ -181,8 +181,8 @@ class METAIO_EXPORT MetaImage : public MetaObject // if streaming is used, then the size of buffer in total number // of elements, should be passed as an argument, otherwise the // internal value Quantity() will be used - void ElementByteOrderSwap( METAIO_STL::streamsize _quantity = 0); - bool ElementByteOrderFix( METAIO_STL::streamsize _quantity = 0); + void ElementByteOrderSwap( METAIO_STL::streamoff _quantity = 0); + bool ElementByteOrderFix( METAIO_STL::streamoff _quantity = 0); // Min(...) Max(...) // The default max returned is the largest allowed by @@ -222,8 +222,8 @@ class METAIO_EXPORT MetaImage : public MetaObject // // void * ElementData(void); - double ElementData(METAIO_STL::streamsize _i) const; - bool ElementData(METAIO_STL::streamsize _i, double _v); + double ElementData(METAIO_STL::streamoff _i) const; + bool ElementData(METAIO_STL::streamoff _i, double _v); void ElementData(void * _data, bool _autoFreeElementData=false); // ConverTo(...) @@ -304,8 +304,8 @@ class METAIO_EXPORT MetaImage : public MetaObject MET_CompressionTableType* m_CompressionTable; int m_DimSize[10]; - METAIO_STL::streamsize m_SubQuantity[10]; - METAIO_STL::streamsize m_Quantity; + METAIO_STL::streamoff m_SubQuantity[10]; + METAIO_STL::streamoff m_Quantity; int m_HeaderSize; @@ -342,29 +342,33 @@ class METAIO_EXPORT MetaImage : public MetaObject bool M_ReadElements(METAIO_STREAM::ifstream * _fstream, void * _data, - METAIO_STL::streamsize _dataQuantity); + METAIO_STL::streamoff _dataQuantity); bool M_ReadElementsROI(METAIO_STREAM::ifstream * _fstream, void * _data, - METAIO_STL::streamsize _dataQuantity, + METAIO_STL::streamoff _dataQuantity, int * _indexMin, int* _indexMax, unsigned int subSamplingFactor=1, - METAIO_STL::streamsize _totalDataQuantity=0); + METAIO_STL::streamoff _totalDataQuantity=0); + + bool M_ReadElementData(METAIO_STREAM::ifstream * _fstream, + void * _data, + METAIO_STL::streamoff _dataQuantity); bool M_WriteElements(METAIO_STREAM::ofstream * _fstream, const void * _data, - METAIO_STL::streamsize _dataQuantity); + METAIO_STL::streamoff _dataQuantity); bool M_WriteElementsROI(METAIO_STREAM::ofstream * _fstream, const void * _data, - unsigned long _dataPos, + METAIO_STL::streampos _dataPos, int * _indexMin, int* _indexMax); bool M_WriteElementData(METAIO_STREAM::ofstream * _fstream, const void * _data, - METAIO_STL::streamsize _dataQuantity); + METAIO_STL::streamoff _dataQuantity); bool M_FileExists(const char* filename) const; diff --git a/Utilities/ITK/Utilities/MetaIO/metaLandmark.cxx b/Utilities/ITK/Utilities/MetaIO/metaLandmark.cxx index 2be4af083301ba2078845dec9bd5b6cd288a7971..95bb913738e4ec7b29b76a16e2fb735ce6b6ad89 100644 --- a/Utilities/ITK/Utilities/MetaIO/metaLandmark.cxx +++ b/Utilities/ITK/Utilities/MetaIO/metaLandmark.cxx @@ -3,8 +3,8 @@ Program: MetaIO Module: $RCSfile: metaLandmark.cxx,v $ Language: C++ - Date: $Date: 2008-04-09 01:44:28 $ - Version: $Revision: 1.15 $ + Date: $Date: 2009-11-21 18:59:39 $ + Version: $Revision: 1.16 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -40,10 +40,10 @@ LandmarkPnt(int dim) } //Color is red by default - m_Color[0]=1.0; - m_Color[1]=0.0; - m_Color[2]=0.0; - m_Color[3]=1.0; + m_Color[0]=1.0f; + m_Color[1]=0.0f; + m_Color[2]=0.0f; + m_Color[3]=1.0f; } LandmarkPnt:: @@ -333,12 +333,12 @@ M_Read(void) { int elementSize; MET_SizeOfType(m_ElementType, &elementSize); - int readSize = m_NPoints*(m_NDims+4)*elementSize; + METAIO_STL::streamsize readSize = m_NPoints*(m_NDims+4)*elementSize; char* _data = new char[readSize]; m_ReadStream->read((char *)_data, readSize); - int gc = m_ReadStream->gcount(); + METAIO_STL::streamsize gc = m_ReadStream->gcount(); if(gc != readSize) { METAIO_STREAM::cout << "MetaLandmark: m_Read: data not read completely" diff --git a/Utilities/ITK/Utilities/MetaIO/metaLine.cxx b/Utilities/ITK/Utilities/MetaIO/metaLine.cxx index 68b715c733747ea8cb5f961d3383e398a474b4a9..d35a63ed4b340b4f149e48a7b25f921c2542793a 100644 --- a/Utilities/ITK/Utilities/MetaIO/metaLine.cxx +++ b/Utilities/ITK/Utilities/MetaIO/metaLine.cxx @@ -3,8 +3,8 @@ Program: MetaIO Module: $RCSfile: metaLine.cxx,v $ Language: C++ - Date: $Date: 2008-04-09 01:44:28 $ - Version: $Revision: 1.31 $ + Date: $Date: 2009-11-21 18:59:39 $ + Version: $Revision: 1.32 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -48,10 +48,10 @@ LinePnt(int dim) } //Color is red by default - m_Color[0]=1.0; - m_Color[1]=0.0; - m_Color[2]=0.0; - m_Color[3]=1.0; + m_Color[0]=1.0f; + m_Color[1]=0.0f; + m_Color[2]=0.0f; + m_Color[3]=1.0f; } LinePnt:: diff --git a/Utilities/ITK/Utilities/MetaIO/metaMesh.cxx b/Utilities/ITK/Utilities/MetaIO/metaMesh.cxx index 4f2105262bc7827cc5860db929826ebff0dfa6c4..c8d2b7667b46b74bf0ae80e44b6f913449c99613 100644 --- a/Utilities/ITK/Utilities/MetaIO/metaMesh.cxx +++ b/Utilities/ITK/Utilities/MetaIO/metaMesh.cxx @@ -3,8 +3,8 @@ Program: MetaIO Module: $RCSfile: metaMesh.cxx,v $ Language: C++ - Date: $Date: 2008-04-24 19:13:40 $ - Version: $Revision: 1.24 $ + Date: $Date: 2009-11-21 18:59:39 $ + Version: $Revision: 1.25 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -701,7 +701,7 @@ M_Read(void) } } - long int pos = m_ReadStream->tellg(); + METAIO_STL::streampos pos = m_ReadStream->tellg(); // Now reading the cell links MetaObject::ClearFields(); diff --git a/Utilities/ITK/Utilities/MetaIO/metaObject.cxx b/Utilities/ITK/Utilities/MetaIO/metaObject.cxx index d4abde1ddd791cde7259e7c25f5f5baf75161f8a..855fc901c8cc12df1ed96bcb6df5f895d5619430 100644 --- a/Utilities/ITK/Utilities/MetaIO/metaObject.cxx +++ b/Utilities/ITK/Utilities/MetaIO/metaObject.cxx @@ -3,8 +3,8 @@ Program: MetaIO Module: $RCSfile: metaObject.cxx,v $ Language: C++ - Date: $Date: 2008-04-09 09:54:25 $ - Version: $Revision: 1.52 $ + Date: $Date: 2009-11-21 18:59:39 $ + Version: $Revision: 1.53 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -1044,10 +1044,10 @@ Clear(void) memset(m_Color, 0, 4*sizeof(float)); m_ID = -1; - m_Color[0]=1.0; - m_Color[1]=1.0; - m_Color[2]=1.0; - m_Color[3]=1.0; // white by default + m_Color[0]=1.0f; + m_Color[1]=1.0f; + m_Color[2]=1.0f; + m_Color[3]=1.0f; // white by default m_ParentID = -1; strcpy(m_AcquisitionDate, ""); m_BinaryData = false; diff --git a/Utilities/ITK/Utilities/MetaIO/metaObject.h b/Utilities/ITK/Utilities/MetaIO/metaObject.h index 1208adb89ac1fe85242a35c6685ea0088b1bf3ed..814d1c9c46d2f81d60a80e7ed9b5f2583ff2a4d0 100644 --- a/Utilities/ITK/Utilities/MetaIO/metaObject.h +++ b/Utilities/ITK/Utilities/MetaIO/metaObject.h @@ -3,8 +3,8 @@ Program: MetaIO Module: $RCSfile: metaObject.h,v $ Language: C++ - Date: $Date: 2008-04-09 01:44:29 $ - Version: $Revision: 1.32 $ + Date: $Date: 2009-11-21 18:59:39 $ + Version: $Revision: 1.33 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -82,7 +82,7 @@ class METAIO_EXPORT MetaObject bool m_BinaryDataByteOrderMSB; - unsigned int m_CompressedDataSize; + METAIO_STL::streamoff m_CompressedDataSize; // Used internally to set if the dataSize should be written bool m_WriteCompressedDataSize; bool m_CompressedData; diff --git a/Utilities/ITK/Utilities/MetaIO/metaSurface.cxx b/Utilities/ITK/Utilities/MetaIO/metaSurface.cxx index 515a97fd149caa7a0b47a3f28f09a7b4f4eda88d..cc1cb404e4257809a04bf886c4e425b8d1b3cdc8 100644 --- a/Utilities/ITK/Utilities/MetaIO/metaSurface.cxx +++ b/Utilities/ITK/Utilities/MetaIO/metaSurface.cxx @@ -3,8 +3,8 @@ Program: MetaIO Module: $RCSfile: metaSurface.cxx,v $ Language: C++ - Date: $Date: 2008-04-09 01:44:28 $ - Version: $Revision: 1.25 $ + Date: $Date: 2009-11-21 18:59:39 $ + Version: $Revision: 1.26 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -41,10 +41,10 @@ SurfacePnt(int dim) m_V[i] = 0; } //Color is red by default - m_Color[0]=1.0; - m_Color[1]=0.0; - m_Color[2]=0.0; - m_Color[3]=1.0; + m_Color[0]=1.0f; + m_Color[1]=0.0f; + m_Color[2]=0.0f; + m_Color[3]=1.0f; } SurfacePnt:: diff --git a/Utilities/ITK/Utilities/MetaIO/metaTube.cxx b/Utilities/ITK/Utilities/MetaIO/metaTube.cxx index ef76186519441a1bf90ff55d251e76c69cf1eeda..e10fac4d98e8032aa5c5b7d14033d1d872ebd467 100644 --- a/Utilities/ITK/Utilities/MetaIO/metaTube.cxx +++ b/Utilities/ITK/Utilities/MetaIO/metaTube.cxx @@ -3,8 +3,8 @@ Program: MetaIO Module: $RCSfile: metaTube.cxx,v $ Language: C++ - Date: $Date: 2008-04-09 01:44:28 $ - Version: $Revision: 1.34 $ + Date: $Date: 2009-11-21 18:59:39 $ + Version: $Revision: 1.35 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -46,10 +46,10 @@ TubePnt(int dim) } m_R=0; //Color is red by default - m_Color[0]=1.0; - m_Color[1]=0.0; - m_Color[2]=0.0; - m_Color[3]=1.0; + m_Color[0]=1.0f; + m_Color[1]=0.0f; + m_Color[2]=0.0f; + m_Color[3]=1.0f; m_ID = -1; } diff --git a/Utilities/ITK/Utilities/MetaIO/metaUtils.cxx b/Utilities/ITK/Utilities/MetaIO/metaUtils.cxx index 53d5fd33dbc3c09d076df11464ca39948a62e616..b8f1b79c88d66495f4e845ede9611692b941b023 100644 --- a/Utilities/ITK/Utilities/MetaIO/metaUtils.cxx +++ b/Utilities/ITK/Utilities/MetaIO/metaUtils.cxx @@ -3,8 +3,8 @@ Program: MetaIO Module: $RCSfile: metaUtils.cxx,v $ Language: C++ - Date: $Date: 2009-07-08 15:54:08 $ - Version: $Revision: 1.58 $ + Date: $Date: 2010-03-10 21:54:04 $ + Version: $Revision: 1.62 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -123,7 +123,7 @@ bool MET_SystemByteOrderMSB(void) // METAIO_STL::string MET_ReadForm(METAIO_STREAM::istream &_fp) { - unsigned int pos = _fp.tellg(); + METAIO_STL::streampos pos = _fp.tellg(); METAIO_STL::vector<MET_FieldRecordType *> fields; MET_FieldRecordType* mF = new MET_FieldRecordType; MET_InitReadField(mF, "Form", MET_STRING, false); @@ -153,7 +153,7 @@ METAIO_STL::string MET_ReadForm(METAIO_STREAM::istream &_fp) // METAIO_STL::string MET_ReadType(METAIO_STREAM::istream &_fp) { - unsigned int pos = _fp.tellg(); + METAIO_STL::streampos pos = _fp.tellg(); METAIO_STL::vector<MET_FieldRecordType *> fields; MET_FieldRecordType* mF = new MET_FieldRecordType; MET_InitReadField(mF, "ObjectType", MET_STRING, false); @@ -183,7 +183,7 @@ METAIO_STL::string MET_ReadType(METAIO_STREAM::istream &_fp) // char* MET_ReadSubType(METAIO_STREAM::istream &_fp) { - unsigned int pos = _fp.tellg(); + METAIO_STL::streampos pos = _fp.tellg(); METAIO_STL::vector<MET_FieldRecordType *> fields; MET_FieldRecordType* mF; mF = new MET_FieldRecordType; @@ -251,7 +251,7 @@ bool MET_TypeToString(MET_ValueEnumType _vType, char *_s) // Value to Double // bool MET_ValueToDouble(MET_ValueEnumType _type, const void *_data, - METAIO_STL::streamsize _index, + METAIO_STL::streamoff _index, double *_value) { switch(_type) @@ -324,7 +324,7 @@ bool MET_ValueToDouble(MET_ValueEnumType _type, const void *_data, bool MET_DoubleToValue(double _value, MET_ValueEnumType _type, void *_data, - METAIO_STL::streamsize _index) + METAIO_STL::streamoff _index) { switch(_type) { @@ -387,7 +387,7 @@ bool MET_DoubleToValue(double _value, } bool MET_ValueToValue(MET_ValueEnumType _fromType, const void *_fromData, - METAIO_STL::streamsize _index, + METAIO_STL::streamoff _index, MET_ValueEnumType _toType, void *_toData, double _fromMin, double _fromMax, double _toMin, double _toMax) @@ -468,29 +468,29 @@ bool MET_ValueToValue(MET_ValueEnumType _fromType, const void *_fromData, // Uncompress a stream given an uncompressedSeekPosition METAIO_EXPORT -long MET_UncompressStream(METAIO_STREAM::ifstream * stream, - METAIO_STL::streamsize uncompressedSeekPosition, +METAIO_STL::streamoff MET_UncompressStream(METAIO_STREAM::ifstream * stream, + METAIO_STL::streamoff uncompressedSeekPosition, unsigned char * uncompressedData, - METAIO_STL::streamsize uncompressedDataSize, - METAIO_STL::streamsize compressedDataSize, + METAIO_STL::streamoff uncompressedDataSize, + METAIO_STL::streamoff compressedDataSize, MET_CompressionTableType * compressionTable ) { // Keep the currentpos of the string - METAIO_STL::streamsize currentPos = stream->tellg(); - if(currentPos == -1) + METAIO_STL::streampos currentPos = stream->tellg(); + if(currentPos == METAIO_STL::streampos(-1)) { METAIO_STREAM::cout << "MET_UncompressStream: ERROR Stream is not valid!" << METAIO_STREAM::endl; return -1; } - long read = 0; + METAIO_STL::streamoff read = 0; //METAIO_STREAM::cout << "Wanted Seek = " << uncompressedSeekPosition << METAIO_STREAM::endl; //METAIO_STREAM::cout << "Wanted size = " << uncompressedDataSize << METAIO_STREAM::endl; // Size of the output buffer - unsigned long buffersize = 1000; + METAIO_STL::streamoff buffersize = 1000; // We try to guess the compression rate // Note that sometime the size of the input buffer @@ -498,8 +498,8 @@ long MET_UncompressStream(METAIO_STREAM::ifstream * stream, // We assume that they are equal double compressionRate = 1; - long zseekpos = 0; - long seekpos = 0; + METAIO_STL::streamoff zseekpos = 0; + METAIO_STL::streamoff seekpos = 0; bool firstchunk = true; // Allocate the stream if necessary @@ -535,14 +535,14 @@ long MET_UncompressStream(METAIO_STREAM::ifstream * stream, } char* buffer = compressionTable->buffer; - unsigned long start = uncompressedSeekPosition-((*it).uncompressedOffset-compressionTable->bufferSize); + METAIO_STL::streamoff start = uncompressedSeekPosition-((*it).uncompressedOffset-compressionTable->bufferSize); buffer += start; - unsigned long readSize = uncompressedDataSize; - unsigned long sizeInBuffer = compressionTable->bufferSize-start; + METAIO_STL::streamoff readSize = uncompressedDataSize; + METAIO_STL::streamoff sizeInBuffer = compressionTable->bufferSize-start; if(readSize>sizeInBuffer) { - memcpy(uncompressedData,buffer,sizeInBuffer); + memcpy(uncompressedData,buffer,(size_t)sizeInBuffer); uncompressedData += sizeInBuffer; zseekpos = (*it).compressedOffset; seekpos = (*it).uncompressedOffset; @@ -551,7 +551,7 @@ long MET_UncompressStream(METAIO_STREAM::ifstream * stream, } else // read from buffer and return { - memcpy(uncompressedData,buffer,readSize); + memcpy(uncompressedData,buffer,(size_t)readSize); return uncompressedDataSize; } } @@ -564,10 +564,10 @@ long MET_UncompressStream(METAIO_STREAM::ifstream * stream, //METAIO_STREAM::cout << "Using = " << seekpos << " : " << zseekpos << METAIO_STREAM::endl; - while(seekpos < (long)uncompressedSeekPosition+uncompressedDataSize) + while(seekpos < uncompressedSeekPosition+uncompressedDataSize) { // If we are reading the current buffer we read everything - if(seekpos >= (long)uncompressedSeekPosition) + if(seekpos >= uncompressedSeekPosition) { buffersize = uncompressedSeekPosition+uncompressedDataSize-seekpos; firstchunk = false; @@ -575,22 +575,23 @@ long MET_UncompressStream(METAIO_STREAM::ifstream * stream, unsigned char* outdata = new unsigned char[buffersize]; - d_stream->avail_out = buffersize; + d_stream->avail_out = (uInt)( buffersize ); // How many byte from compressed streamed should we read - unsigned long inputBufferSize = (unsigned long)(buffersize/compressionRate); + METAIO_STL::streamoff inputBufferSize = (METAIO_STL::streamoff)(buffersize/compressionRate); + if(inputBufferSize == 0) { inputBufferSize = 1; } - if((long)(currentPos+zseekpos+inputBufferSize) > compressedDataSize) + if((currentPos+zseekpos+inputBufferSize) > compressedDataSize) { inputBufferSize = compressedDataSize-zseekpos; } unsigned char* inputBuffer = new unsigned char[inputBufferSize]; stream->seekg(currentPos+zseekpos,METAIO_STREAM::ios::beg); - stream->read((char *)inputBuffer, inputBufferSize); + stream->read((char *)inputBuffer, (size_t)inputBufferSize); d_stream->next_in = inputBuffer; d_stream->avail_in = stream->gcount(); @@ -598,39 +599,39 @@ long MET_UncompressStream(METAIO_STREAM::ifstream * stream, inflate(d_stream, Z_NO_FLUSH); - unsigned long previousSeekpos = seekpos; + METAIO_STL::streampos previousSeekpos = seekpos; seekpos += buffersize-d_stream->avail_out; zseekpos += stream->gcount()-d_stream->avail_in; // Store the last buffer into memory in case we need it // in the near future. - long previousBufferSize = seekpos-previousSeekpos; + METAIO_STL::streamoff previousBufferSize = seekpos-previousSeekpos; if(previousBufferSize>1000) { // WARNING: We probably need to offset outdata at some point... previousBufferSize = 1000; } - memcpy(compressionTable->buffer,outdata,previousBufferSize); + memcpy(compressionTable->buffer,outdata,(size_t)previousBufferSize); compressionTable->bufferSize = previousBufferSize; //METAIO_STREAM::cout << "Current pos = " << seekpos << " : " << zseekpos << METAIO_STREAM::endl; // If go further than the uncompressedSeekPosition we start writing the stream - if(seekpos >= (long)uncompressedSeekPosition) + if(seekpos >= uncompressedSeekPosition) { if(firstchunk) { outdata += uncompressedSeekPosition-previousSeekpos; - METAIO_STL::streamsize writeSize = seekpos-uncompressedSeekPosition; + METAIO_STL::streamoff writeSize = seekpos-uncompressedSeekPosition; if(writeSize > uncompressedDataSize) { writeSize = uncompressedDataSize; } - memcpy(uncompressedData,outdata,writeSize); + memcpy(uncompressedData,outdata,(size_t)writeSize); // Restore the position of the buffer outdata -= uncompressedSeekPosition-previousSeekpos; @@ -642,8 +643,8 @@ long MET_UncompressStream(METAIO_STREAM::ifstream * stream, } else // read everything { - METAIO_STL::streamsize writeSize = seekpos-previousSeekpos; - memcpy(uncompressedData,outdata,writeSize); + METAIO_STL::streamoff writeSize = seekpos-previousSeekpos; + memcpy(uncompressedData,outdata,(size_t)writeSize); if(writeSize > uncompressedDataSize) { writeSize = uncompressedDataSize; @@ -672,8 +673,8 @@ long MET_UncompressStream(METAIO_STREAM::ifstream * stream, // // unsigned char * MET_PerformCompression(const unsigned char * source, - METAIO_STL::streamsize sourceSize, - unsigned int * compressedDataSize) + METAIO_STL::streamoff sourceSize, + METAIO_STL::streamoff * compressedDataSize) { unsigned char * compressedData; @@ -686,7 +687,7 @@ unsigned char * MET_PerformCompression(const unsigned char * source, // Choices are Z_BEST_SPEED,Z_BEST_COMPRESSION,Z_DEFAULT_COMPRESSION int compression_rate = Z_DEFAULT_COMPRESSION; - METAIO_STL::streamsize buffer_size = sourceSize; + METAIO_STL::streamoff buffer_size = sourceSize; unsigned char * input_buffer = const_cast<unsigned char *>(source); unsigned char * output_buffer = new unsigned char[buffer_size]; @@ -694,13 +695,13 @@ unsigned char * MET_PerformCompression(const unsigned char * source, deflateInit(&z, compression_rate); - z.avail_in = buffer_size; + z.avail_in = (uInt)buffer_size; z.next_in = input_buffer; z.next_out = output_buffer; - z.avail_out = buffer_size; + z.avail_out = (uInt)buffer_size; - METAIO_STL::streamsize count; - METAIO_STL::streamsize j=0; + METAIO_STL::streamoff count; + METAIO_STL::streamoff j=0; // Perform the compression for ( ; ; ) { @@ -715,12 +716,12 @@ unsigned char * MET_PerformCompression(const unsigned char * source, if(j+count>=buffer_size) { unsigned char* compressedDataTemp = new unsigned char[j+count+1]; - memcpy(compressedDataTemp,compressedData,buffer_size); + memcpy(compressedDataTemp,compressedData,(size_t)buffer_size); delete [] compressedData; compressedData = compressedDataTemp; } - memcpy((char*)compressedData+j, (char *)output_buffer, count); + memcpy((char*)compressedData+j, (char *)output_buffer, (size_t)count); } break; } @@ -732,16 +733,16 @@ unsigned char * MET_PerformCompression(const unsigned char * source, if(j+count>=buffer_size) { unsigned char* compressedDataTemp = new unsigned char[j+count+1]; - memcpy(compressedDataTemp,compressedData,buffer_size); + memcpy(compressedDataTemp,compressedData,(size_t)buffer_size); delete [] compressedData; compressedData = compressedDataTemp; } - memcpy((char*)compressedData+j, (char*)output_buffer, count); + memcpy((char*)compressedData+j, (char*)output_buffer, (size_t)count); } j += count; z.next_out = output_buffer; - z.avail_out = buffer_size; + z.avail_out = (uInt)buffer_size; } delete [] output_buffer; @@ -758,9 +759,9 @@ unsigned char * MET_PerformCompression(const unsigned char * source, // // bool MET_PerformUncompression(const unsigned char * sourceCompressed, - METAIO_STL::streamsize sourceCompressedSize, + METAIO_STL::streamoff sourceCompressedSize, unsigned char * uncompressedData, - METAIO_STL::streamsize uncompressedDataSize) + METAIO_STL::streamoff uncompressedDataSize) { z_stream d_stream; @@ -770,12 +771,12 @@ bool MET_PerformUncompression(const unsigned char * sourceCompressed, inflateInit(&d_stream); d_stream.next_in = const_cast<unsigned char *>(sourceCompressed); - d_stream.avail_in = sourceCompressedSize; + d_stream.avail_in = (uInt)sourceCompressedSize; for (;;) { d_stream.next_out = (unsigned char *)uncompressedData; - d_stream.avail_out = uncompressedDataSize; + d_stream.avail_out = (uInt)uncompressedDataSize; int err = inflate(&d_stream, Z_NO_FLUSH); if((err == Z_STREAM_END) @@ -801,16 +802,16 @@ bool MET_PerformUncompression(const unsigned char * sourceCompressed, // bool MET_StringToWordArray(const char *s, int *n, char ***val) { - long l = static_cast<long>( strlen(s) ); + ptrdiff_t l = strlen(s); - int p = 0; + ptrdiff_t p = 0; while(p<l && s[p] == ' ') { p++; } *n = 0; - int pp = p; + ptrdiff_t pp = p; bool space = false; while(pp<l) { @@ -841,7 +842,7 @@ bool MET_StringToWordArray(const char *s, int *n, char ***val) *val = new char *[*n]; - long i, j; + ptrdiff_t i, j; for(i=0; i<*n; i++) { if(p == l) @@ -872,9 +873,9 @@ bool MET_GetFilePath(const char *_fName, char *_fPath) { long i; - long l = static_cast<long>( strlen(_fName) ); + size_t l = strlen(_fName); - for(i=l-1; i>=0; i--) + for(i=(long)l-1; i>=0; i--) if(_fName[i] == '\\' || _fName[i] == '/') break; @@ -1037,7 +1038,8 @@ bool MET_Read(METAIO_STREAM::istream &fp, { char s[1024]; - int i, j; + int i; + size_t j; METAIO_STL::vector<MET_FieldRecordType *>::iterator fieldIter; @@ -1136,7 +1138,7 @@ bool MET_Read(METAIO_STREAM::istream &fp, } MET_CHAR_TYPE * str = (MET_CHAR_TYPE *)((*fieldIter)->value); fp.getline( str, 500 ); - j = static_cast<long>( strlen(str) ) - 1; + j = strlen(str) - 1; while(!isprint(str[j]) || isspace(str[j])) { str[j--] = '\0'; @@ -1166,7 +1168,7 @@ bool MET_Read(METAIO_STREAM::istream &fp, { (*fieldIter)->length = (int)((*fields)[(*fieldIter)->dependsOn]->value[0]); - for(j=0; j<(*fieldIter)->length; j++) + for(j=0; j<(size_t)(*fieldIter)->length; j++) { fp >> (*fieldIter)->value[j]; } @@ -1180,7 +1182,7 @@ bool MET_Read(METAIO_STREAM::istream &fp, << METAIO_STREAM::endl; return false; } - for(j=0; j<(*fieldIter)->length; j++) + for(j=0; j<(size_t)(*fieldIter)->length; j++) { fp >> (*fieldIter)->value[j]; } @@ -1199,7 +1201,7 @@ bool MET_Read(METAIO_STREAM::istream &fp, { (*fieldIter)->length = (int)((*fields)[(*fieldIter)->dependsOn]->value[0]); - for(j=0; j<(*fieldIter)->length*(*fieldIter)->length; + for(j=0; j<(size_t)(*fieldIter)->length*(*fieldIter)->length; j++) { fp >> (*fieldIter)->value[j]; @@ -1214,7 +1216,7 @@ bool MET_Read(METAIO_STREAM::istream &fp, << METAIO_STREAM::endl; return false; } - for(j=0; j<(*fieldIter)->length*(*fieldIter)->length; j++) + for(j=0; j<(size_t)(*fieldIter)->length*(*fieldIter)->length; j++) { fp >> (*fieldIter)->value[j]; } diff --git a/Utilities/ITK/Utilities/MetaIO/metaUtils.h b/Utilities/ITK/Utilities/MetaIO/metaUtils.h index e3ac8f3f57f7d89613641ec36020998c68861b43..172d07a11835153dfe4b9b5bb57edf481791e9c9 100644 --- a/Utilities/ITK/Utilities/MetaIO/metaUtils.h +++ b/Utilities/ITK/Utilities/MetaIO/metaUtils.h @@ -3,8 +3,8 @@ Program: MetaIO Module: $RCSfile: metaUtils.h,v $ Language: C++ - Date: $Date: 2009-06-21 21:54:05 $ - Version: $Revision: 1.44 $ + Date: $Date: 2009-11-21 18:59:39 $ + Version: $Revision: 1.45 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -68,8 +68,8 @@ extern int META_DEBUG; // Types used for storing the compression table typedef struct MET_CompressionOffset { - METAIO_STL::streamsize uncompressedOffset; - METAIO_STL::streamsize compressedOffset; + METAIO_STL::streamoff uncompressedOffset; + METAIO_STL::streamoff compressedOffset; } MET_CompressionOffsetType; typedef METAIO_STL::vector<MET_CompressionOffsetType> @@ -80,7 +80,7 @@ typedef struct MET_CompressionTable MET_CompressionOffsetListType offsetList; z_stream* compressedStream; char* buffer; - METAIO_STL::streamsize bufferSize; + METAIO_STL::streamoff bufferSize; } MET_CompressionTableType; ///////////////////////////////////////////////////////// @@ -287,19 +287,19 @@ MET_ValueEnumType MET_GetValueEnumType(const METAIO_STL::type_info & ptype) METAIO_EXPORT bool MET_ValueToDouble(MET_ValueEnumType _pType, const void *_data, - METAIO_STL::streamsize _index, + METAIO_STL::streamoff _index, double *_value); METAIO_EXPORT bool MET_DoubleToValue(double _value, MET_ValueEnumType _type, void *_data, - METAIO_STL::streamsize _index); + METAIO_STL::streamoff _index); METAIO_EXPORT bool MET_ValueToValue(MET_ValueEnumType _fromType, const void *_fromData, - METAIO_STL::streamsize _index, + METAIO_STL::streamoff _index, MET_ValueEnumType _toType, void *_toData, double _fromMin=0, double _fromMax=0, @@ -307,22 +307,22 @@ bool MET_ValueToValue(MET_ValueEnumType _fromType, METAIO_EXPORT unsigned char * MET_PerformCompression(const unsigned char * source, - METAIO_STL::streamsize sourceSize, - unsigned int * compressedDataSize); + METAIO_STL::streamoff sourceSize, + METAIO_STL::streamoff * compressedDataSize); METAIO_EXPORT bool MET_PerformUncompression(const unsigned char * sourceCompressed, - METAIO_STL::streamsize sourceCompressedSize, + METAIO_STL::streamoff sourceCompressedSize, unsigned char * uncompressedData, - METAIO_STL::streamsize uncompressedDataSize); + METAIO_STL::streamoff uncompressedDataSize); // Uncompress a stream given an uncompressedSeekPosition METAIO_EXPORT -long MET_UncompressStream(METAIO_STREAM::ifstream * stream, - METAIO_STL::streamsize uncompressedSeekPosition, +METAIO_STL::streamoff MET_UncompressStream(METAIO_STREAM::ifstream * stream, + METAIO_STL::streamoff uncompressedSeekPosition, unsigned char * uncompressedData, - METAIO_STL::streamsize uncompressedDataSize, - METAIO_STL::streamsize compressedDataSize, + METAIO_STL::streamoff uncompressedDataSize, + METAIO_STL::streamoff compressedDataSize, MET_CompressionTableType * compressionTable); diff --git a/Utilities/ITK/Utilities/MetaIO/metaVesselTube.cxx b/Utilities/ITK/Utilities/MetaIO/metaVesselTube.cxx index 9a62006d878fade34b6ebd9a8797838bdc8d7219..e058974e3cfc6457120b47aeb1e57ca4c97b6c32 100644 --- a/Utilities/ITK/Utilities/MetaIO/metaVesselTube.cxx +++ b/Utilities/ITK/Utilities/MetaIO/metaVesselTube.cxx @@ -3,8 +3,8 @@ Program: MetaIO Module: $RCSfile: metaVesselTube.cxx,v $ Language: C++ - Date: $Date: 2008-04-09 01:44:27 $ - Version: $Revision: 1.17 $ + Date: $Date: 2009-11-21 18:59:39 $ + Version: $Revision: 1.18 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -55,10 +55,10 @@ VesselTubePnt(int dim) m_Mark=false; //Color is red by default - m_Color[0]=1.0; - m_Color[1]=0.0; - m_Color[2]=0.0; - m_Color[3]=1.0; + m_Color[0]=1.0f; + m_Color[1]=0.0f; + m_Color[2]=0.0f; + m_Color[3]=1.0f; m_ID = -1; } diff --git a/Utilities/ITK/Utilities/NrrdIO/754.c b/Utilities/ITK/Utilities/NrrdIO/754.c index e4561129c041e92056e4516791835329175cc2d4..fb9bbc7686b2d2837e327776854538b855e15948 100644 --- a/Utilities/ITK/Utilities/NrrdIO/754.c +++ b/Utilities/ITK/Utilities/NrrdIO/754.c @@ -1,6 +1,6 @@ /* NrrdIO: stand-alone code for basic nrrd functionality - Copyright (C) 2005 Gordon Kindlmann + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah This software is provided 'as-is', without any express or implied @@ -22,7 +22,6 @@ 3. This notice may not be removed or altered from any source distribution. */ - #include "NrrdIO.h" #include "privateAir.h" #include "teemEndian.h" @@ -350,13 +349,13 @@ airFPClass_d(double val) { f.v = val; sign = f.c.sign; - expo = f.c.expo; /* this seems to be a WIN32 bug: on a quiet-NaN, f.c.exp - should be non-zero, but it was completely zero, so that - this function returned airFP_NEG_DENORM instead of - airFP_QNAN */ + expo = f.c.expo; /* this seems to be a WIN32 bug: on a quiet-NaN, f.c.exp + should be non-zero, but it was completely zero, so + that this function returned airFP_NEG_DENORM instead + of airFP_QNAN */ mant0 = f.c.mant0; mant1 = f.c.mant1; - hibit = mant0 >> 20; + hibit = mant0 >> 19; index = ((!!sign) << 2) | ((!!expo) << 1) | (!!mant0 || !!mant1); switch(index) { diff --git a/Utilities/ITK/Utilities/NrrdIO/CMakeLists.txt b/Utilities/ITK/Utilities/NrrdIO/CMakeLists.txt index e2c044324dabd98de1bc5734e5b5a6a5a4e7e3a2..7ab92596c77766b1e62b1ab141cdfe8ca36b19f4 100644 --- a/Utilities/ITK/Utilities/NrrdIO/CMakeLists.txt +++ b/Utilities/ITK/Utilities/NrrdIO/CMakeLists.txt @@ -9,8 +9,8 @@ INCLUDE_REGULAR_EXPRESSION("^.*.h$") # SET(nrrdio_SRCS 754.c mop.c array.c parseAir.c dio.c sane.c endianAir.c -string.c enum.c miscAir.c biffbiff.c accessors.c defaultsNrrd.c enumsNrrd.c -arraysNrrd.c methodsNrrd.c reorder.c axis.c simple.c comment.c +string.c enum.c miscAir.c biffbiff.c biffmsg.c accessors.c defaultsNrrd.c +enumsNrrd.c arraysNrrd.c methodsNrrd.c reorder.c axis.c simple.c comment.c keyvalue.c endianNrrd.c parseNrrd.c gzio.c read.c write.c format.c formatNRRD.c encoding.c encodingRaw.c encodingAscii.c encodingHex.c encodingGzip.c subset.c encodingBzip2.c formatEPS.c formatPNG.c @@ -30,11 +30,11 @@ INCLUDE_DIRECTORIES( ) # Set compiler flags for endian-ness. -IF(CMAKE_WORDS_BIGENDIAN) - ADD_DEFINITIONS(-DTEEM_ENDIAN=4321) -ELSE(CMAKE_WORDS_BIGENDIAN) - ADD_DEFINITIONS(-DTEEM_ENDIAN=1234) -ENDIF(CMAKE_WORDS_BIGENDIAN) +#IF(CMAKE_WORDS_BIGENDIAN) +# ADD_DEFINITIONS(-DTEEM_ENDIAN=4321) +#ELSE(CMAKE_WORDS_BIGENDIAN) +# ADD_DEFINITIONS(-DTEEM_ENDIAN=1234) +#ENDIF(CMAKE_WORDS_BIGENDIAN) #The QNANHIBIT variable is configured by the root level CMakeLists.txt IF(QNANHIBIT) @@ -71,10 +71,17 @@ IF(NOT ITK_INSTALL_NO_LIBRARIES) ) ENDIF(NOT ITK_INSTALL_NO_LIBRARIES) +IF(ITK_USE_FLAT_DIRECTORY_INSTALL) + SET( ITK_INSTALL_INCLUDE_DIR_CM24_UTILITIES_NRRDIO ${ITK_INSTALL_INCLUDE_DIR_CM24}) +ELSE(ITK_USE_FLAT_DIRECTORY_INSTALL) + SET( ITK_INSTALL_INCLUDE_DIR_CM24_UTILITIES_NRRDIO ${ITK_INSTALL_INCLUDE_DIR_CM24}/Utilities/NrrdIO) +ENDIF(ITK_USE_FLAT_DIRECTORY_INSTALL) + + IF(NOT ITK_INSTALL_NO_DEVELOPMENT) FILE(GLOB __files "${CMAKE_CURRENT_SOURCE_DIR}/*.h") INSTALL(FILES ${__files} - DESTINATION ${ITK_INSTALL_INCLUDE_DIR_CM24}/Utilities/NrrdIO + DESTINATION ${ITK_INSTALL_INCLUDE_DIR_CM24_UTILITIES_NRRDIO} COMPONENT Development) ENDIF(NOT ITK_INSTALL_NO_DEVELOPMENT) diff --git a/Utilities/ITK/Utilities/NrrdIO/NrrdConfigure.h.in b/Utilities/ITK/Utilities/NrrdIO/NrrdConfigure.h.in index e1a0c86c4e0c6e5337dd01f8aed9331e7bb08847..87842291fe820cb242603931d60ac4727af1842d 100644 --- a/Utilities/ITK/Utilities/NrrdIO/NrrdConfigure.h.in +++ b/Utilities/ITK/Utilities/NrrdIO/NrrdConfigure.h.in @@ -16,3 +16,26 @@ #else #define TEEM_32BIT 1 #endif + + +/* what byte order */ +/* All compilers that support Mac OS X define either __BIG_ENDIAN__ or + __LITTLE_ENDIAN__ to match the endianness of the architecture being + compiled for. This is not necessarily the same as the architecture of + the machine doing the building. In order to support Universal Binaries on + Mac OS X, we prefer those defines to decide the endianness. + On other platform, we use the result of the TRY_RUN. */ +#if !defined(__APPLE__) + #if @CMAKE_WORDS_BIGENDIAN@ + #define TEEM_ENDIAN 4321 + #else + #define TEEM_ENDIAN 1234 + #endif +#else + #if defined(__BIG_ENDIAN__) + #define TEEM_ENDIAN 4321 + #else + #define TEEM_ENDIAN 1234 + #endif +#endif + diff --git a/Utilities/ITK/Utilities/NrrdIO/NrrdIO.h b/Utilities/ITK/Utilities/NrrdIO/NrrdIO.h index 03990c6ee530fa184b6d3ddae8a9b7ff59cf733e..82258cf0dfe50692328d863deb485fcb9064af59 100644 --- a/Utilities/ITK/Utilities/NrrdIO/NrrdIO.h +++ b/Utilities/ITK/Utilities/NrrdIO/NrrdIO.h @@ -1,6 +1,6 @@ /* NrrdIO: stand-alone code for basic nrrd functionality - Copyright (C) 2005 Gordon Kindlmann + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah This software is provided 'as-is', without any express or implied @@ -31,11 +31,27 @@ #include <stdarg.h> #include <float.h> -#define TEEM_VERSION_MAJOR 1 /* 1 digit */ -#define TEEM_VERSION_MINOR 9 /* 1 or 2 digits */ -#define TEEM_VERSION_RELEASE 0 /* 1 or 2 digits */ -#define TEEM_VERSION 10900 /* can be compared numerically */ -#define TEEM_VERSION_STRING "1.9.0" /* cannot be compared numerically */ +/* +******** TEEM_VERSION +** +** TEEM_VERSION is a single (decimal) number that will always increase +** monotically, and the _MAJOR, _MINOR, _PATCH are also numbers that +** can be used to implement pre-processor logic about specifc +** versions. The TEEM_VERSION_STRING is used in the (existing) char +** *airTeemVersion (added in version 1.9.0). Yes, keeping these in +** sync is currently a manual operation. +** +** NOTE: Significant API changes (aside from API additions) should NOT +** occur with changes in patch level, only with major or minor version +** changes. +** +** NOTE: ../../CMakeLists.txt's Teem_VERSION variables must be in sync +*/ +#define TEEM_VERSION_MAJOR 1 /* must be 1 digit */ +#define TEEM_VERSION_MINOR 11 /* 1 or 2 digits */ +#define TEEM_VERSION_PATCH 00 /* 1 or 2 digits */ +#define TEEM_VERSION 11100 /* can be easily compared numerically */ +#define TEEM_VERSION_STRING "1.11.0" /* cannot be so easily compared */ /* THE FOLLOWING INCLUDE IS ONLY FOR THE ITK DISTRIBUTION. This header mangles the symbols in the NrrdIO library, preventing @@ -46,16 +62,15 @@ extern "C" { #endif -/* define TEEM_API */ #define TEEM_BUILD 1 #if defined(_WIN32) && !defined(__CYGWIN__) && !defined(TEEM_STATIC) -# if defined(TEEM_BUILD) -# define TEEM_API extern __declspec(dllexport) +# if defined(TEEM_BUILD) || defined(air_EXPORTS) || defined(teem_EXPORTS) +# define NRRDIO_EXPORT extern __declspec(dllexport) # else -# define TEEM_API extern __declspec(dllimport) +# define NRRDIO_EXPORT extern __declspec(dllimport) # endif #else /* TEEM_STATIC || UNIX */ -# define TEEM_API extern +# define NRRDIO_EXPORT extern #endif #if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__MINGW32__) @@ -85,7 +100,7 @@ typedef unsigned long long airULLong; /* enum.c: enum value <--> string conversion utility */ typedef struct { - char name[AIR_STRLEN_SMALL]; + const char *name; /* what are these things? */ unsigned int M; /* If "val" is NULL, the the valid enum values are from 1 @@ -95,15 +110,16 @@ typedef struct { represented by strings str[1] through str[M]), and the unknown/invalid value is val[0]. In both cases, str[0] is the string to represent an unknown/invalid value */ - char (*str)[AIR_STRLEN_SMALL]; + const char **str; /* "canonical" textual representation of the enum values */ - int *val; /* non-NULL iff valid values in the enum are not [1..M], and/or + const int *val; + /* non-NULL iff valid values in the enum are not [1..M], and/or if value for unknown/invalid is not zero */ - char (*desc)[AIR_STRLEN_MED]; + const char **desc; /* desc[i] is a short description of the enum values represented by str[i] (thereby starting with the unknown value), to be used to by things like hest */ - char (*strEqv)[AIR_STRLEN_SMALL]; + const char **strEqv; /* All the variations in strings recognized in mapping from string to value (the values in valEqv). This **MUST** be terminated by a zero-length string ("") so as to signify @@ -111,7 +127,8 @@ typedef struct { for unknown/invalid. If "strEqv" is NULL, then mapping from string to value is done by traversing "str", and "valEqv" is ignored. */ - int *valEqv; /* The values corresponding to the strings in strEqv; there + const int *valEqv; + /* The values corresponding to the strings in strEqv; there should be one integer for each non-zero-length string in strEqv: strEqv[i] is a valid string representation for value valEqv[i]. This should not contain the value for @@ -119,13 +136,16 @@ typedef struct { NULL. */ int sense; /* require case matching on strings */ } airEnum; -TEEM_API int airEnumUnknown(airEnum *enm); -TEEM_API int airEnumValCheck(airEnum *enm, int val); -TEEM_API const char *airEnumStr(airEnum *enm, int val); -TEEM_API const char *airEnumDesc(airEnum *enm, int val); -TEEM_API int airEnumVal(airEnum *enm, const char *str); -TEEM_API char *airEnumFmtDesc(airEnum *enm, int val, int canon, - const char *fmt); +NRRDIO_EXPORT int airEnumUnknown(const airEnum *enm); +NRRDIO_EXPORT int airEnumLast(const airEnum *enm); +NRRDIO_EXPORT int airEnumValCheck(const airEnum *enm, int val); +NRRDIO_EXPORT const char *airEnumStr(const airEnum *enm, int val); +NRRDIO_EXPORT const char *airEnumDesc(const airEnum *enm, int val); +NRRDIO_EXPORT int airEnumVal(const airEnum *enm, const char *str); +NRRDIO_EXPORT char *airEnumFmtDesc(const airEnum *enm, int val, int canon, + const char *fmt); +NRRDIO_EXPORT void airEnumPrint(FILE *file, const airEnum *enm); + /* ******** airEndian enum @@ -141,8 +161,8 @@ enum { airEndianLast }; /* endianAir.c */ -TEEM_API airEnum *airEndian; -TEEM_API const int airMyEndian; +NRRDIO_EXPORT const airEnum *const airEndian; +NRRDIO_EXPORT const int airMyEndian; /* array.c: poor-man's dynamically resizable arrays */ typedef struct { @@ -183,17 +203,17 @@ typedef struct { void (*doneCB)(void *); /* called on addresses of invalidated elements */ } airArray; -TEEM_API airArray *airArrayNew(void **dataP, unsigned int *lenP, size_t unit, - unsigned int incr); -TEEM_API void airArrayStructCB(airArray *a, void (*initCB)(void *), - void (*doneCB)(void *)); -TEEM_API void airArrayPointerCB(airArray *a, void *(*allocCB)(void), - void *(*freeCB)(void *)); -TEEM_API void airArrayLenSet(airArray *a, unsigned int newlen); -TEEM_API void airArrayLenPreSet(airArray *a, unsigned int newlen); -TEEM_API unsigned int airArrayLenIncr(airArray *a, int delta); -TEEM_API airArray *airArrayNix(airArray *a); -TEEM_API airArray *airArrayNuke(airArray *a); +NRRDIO_EXPORT airArray *airArrayNew(void **dataP, unsigned int *lenP, size_t unit, + unsigned int incr); +NRRDIO_EXPORT void airArrayStructCB(airArray *a, void (*initCB)(void *), + void (*doneCB)(void *)); +NRRDIO_EXPORT void airArrayPointerCB(airArray *a, void *(*allocCB)(void), + void *(*freeCB)(void *)); +NRRDIO_EXPORT void airArrayLenSet(airArray *a, unsigned int newlen); +NRRDIO_EXPORT void airArrayLenPreSet(airArray *a, unsigned int newlen); +NRRDIO_EXPORT unsigned int airArrayLenIncr(airArray *a, int delta); +NRRDIO_EXPORT airArray *airArrayNix(airArray *a); +NRRDIO_EXPORT airArray *airArrayNuke(airArray *a); /* @@ -206,7 +226,7 @@ TEEM_API airArray *airArrayNuke(airArray *a); ** ieee.h, ieeefp.h, fp_class.h. This is because IEEE 754 hasn't ** defined standard values for these, so everyone does it differently. ** -** This enum uses underscores (against teem convention) to help +** This enum uses underscores (against Teem convention) to help ** legibility while also conforming to the spirit of the somewhat ** standard naming conventions */ @@ -233,37 +253,37 @@ typedef union { airULLong i; double d; } airDouble; -TEEM_API const int airMyQNaNHiBit; -TEEM_API float airFPPartsToVal_f(unsigned int sign, - unsigned int expo, - unsigned int mant); -TEEM_API void airFPValToParts_f(unsigned int *signP, - unsigned int *expoP, - unsigned int *mantP, float v); -TEEM_API double airFPPartsToVal_d(unsigned int sign, - unsigned int expo, - unsigned int mant0, - unsigned int mant1); -TEEM_API void airFPValToParts_d(unsigned int *signP, - unsigned int *expoP, - unsigned int *mant0P, - unsigned int *mant1P, - double v); -TEEM_API float airFPGen_f(int cls); -TEEM_API double airFPGen_d(int cls); -TEEM_API int airFPClass_f(float val); -TEEM_API int airFPClass_d(double val); -TEEM_API void airFPFprintf_f(FILE *file, float val); -TEEM_API void airFPFprintf_d(FILE *file, double val); -TEEM_API const airFloat airFloatQNaN; -TEEM_API const airFloat airFloatSNaN; -TEEM_API const airFloat airFloatPosInf; -TEEM_API const airFloat airFloatNegInf; -TEEM_API float airNaN(void); -TEEM_API int airIsNaN(double d); -TEEM_API int airIsInf_f(float f); -TEEM_API int airIsInf_d(double d); -TEEM_API int airExists(double d); +NRRDIO_EXPORT const int airMyQNaNHiBit; +NRRDIO_EXPORT float airFPPartsToVal_f(unsigned int sign, + unsigned int expo, + unsigned int mant); +NRRDIO_EXPORT void airFPValToParts_f(unsigned int *signP, + unsigned int *expoP, + unsigned int *mantP, float v); +NRRDIO_EXPORT double airFPPartsToVal_d(unsigned int sign, + unsigned int expo, + unsigned int mant0, + unsigned int mant1); +NRRDIO_EXPORT void airFPValToParts_d(unsigned int *signP, + unsigned int *expoP, + unsigned int *mant0P, + unsigned int *mant1P, + double v); +NRRDIO_EXPORT float airFPGen_f(int cls); +NRRDIO_EXPORT double airFPGen_d(int cls); +NRRDIO_EXPORT int airFPClass_f(float val); +NRRDIO_EXPORT int airFPClass_d(double val); +NRRDIO_EXPORT void airFPFprintf_f(FILE *file, float val); +NRRDIO_EXPORT void airFPFprintf_d(FILE *file, double val); +NRRDIO_EXPORT const airFloat airFloatQNaN; +NRRDIO_EXPORT const airFloat airFloatSNaN; +NRRDIO_EXPORT const airFloat airFloatPosInf; +NRRDIO_EXPORT const airFloat airFloatNegInf; +NRRDIO_EXPORT float airNaN(void); +NRRDIO_EXPORT int airIsNaN(double d); +NRRDIO_EXPORT int airIsInf_f(float f); +NRRDIO_EXPORT int airIsInf_d(double d); +NRRDIO_EXPORT int airExists(double d); /* @@ -278,64 +298,65 @@ enum { airTypeBool, /* 1 */ airTypeInt, /* 2 */ airTypeUInt, /* 3 */ - airTypeSize_t, /* 4 */ - airTypeFloat, /* 5 */ - airTypeDouble, /* 6 */ - airTypeChar, /* 7 */ - airTypeString, /* 8 */ - airTypeEnum, /* 9 */ - airTypeOther, /* 10 */ + airTypeLongInt, /* 4 */ + airTypeSize_t, /* 5 */ + airTypeFloat, /* 6 */ + airTypeDouble, /* 7 */ + airTypeChar, /* 8 */ + airTypeString, /* 9 */ + airTypeEnum, /* 10 */ + airTypeOther, /* 11 */ airTypeLast }; -#define AIR_TYPE_MAX 10 +#define AIR_TYPE_MAX 11 /* parseAir.c */ -TEEM_API double airAtod(const char *str); -TEEM_API int airSingleSscanf(const char *str, const char *fmt, void *ptr); -TEEM_API airEnum *airBool; -TEEM_API unsigned int airParseStrB(int *out, const char *s, - const char *ct, unsigned int n, - ... /* (nothing used) */); -TEEM_API unsigned int airParseStrI(int *out, const char *s, - const char *ct, unsigned int n, - ... /* (nothing used) */); -TEEM_API unsigned int airParseStrUI(unsigned int *out, const char *s, - const char *ct, unsigned int n, - ... /* (nothing used) */); -TEEM_API unsigned int airParseStrZ(size_t *out, const char *s, - const char *ct, unsigned int n, - ... /* (nothing used) */); -TEEM_API unsigned int airParseStrF(float *out, const char *s, - const char *ct, unsigned int n, - ... /* (nothing used) */); -TEEM_API unsigned int airParseStrD(double *out, const char *s, - const char *ct, unsigned int n, - ... /* (nothing used) */); -TEEM_API unsigned int airParseStrC(char *out, const char *s, - const char *ct, unsigned int n, - ... /* (nothing used) */); -TEEM_API unsigned int airParseStrS(char **out, const char *s, - const char *ct, unsigned int n, - ... /* REQUIRED even if n>1: int greedy */); -TEEM_API unsigned int airParseStrE(int *out, const char *s, - const char *ct, unsigned int n, - ... /* REQUIRED: airEnum *e */); -TEEM_API unsigned int (*airParseStr[AIR_TYPE_MAX+1])(void *, const char *, - const char *, - unsigned int, ...); +NRRDIO_EXPORT double airAtod(const char *str); +NRRDIO_EXPORT int airSingleSscanf(const char *str, const char *fmt, void *ptr); +NRRDIO_EXPORT const airEnum *const airBool; +NRRDIO_EXPORT unsigned int airParseStrB(int *out, const char *s, + const char *ct, unsigned int n, + ... /* (nothing used) */); +NRRDIO_EXPORT unsigned int airParseStrI(int *out, const char *s, + const char *ct, unsigned int n, + ... /* (nothing used) */); +NRRDIO_EXPORT unsigned int airParseStrUI(unsigned int *out, const char *s, + const char *ct, unsigned int n, + ... /* (nothing used) */); +NRRDIO_EXPORT unsigned int airParseStrZ(size_t *out, const char *s, + const char *ct, unsigned int n, + ... /* (nothing used) */); +NRRDIO_EXPORT unsigned int airParseStrF(float *out, const char *s, + const char *ct, unsigned int n, + ... /* (nothing used) */); +NRRDIO_EXPORT unsigned int airParseStrD(double *out, const char *s, + const char *ct, unsigned int n, + ... /* (nothing used) */); +NRRDIO_EXPORT unsigned int airParseStrC(char *out, const char *s, + const char *ct, unsigned int n, + ... /* (nothing used) */); +NRRDIO_EXPORT unsigned int airParseStrS(char **out, const char *s, + const char *ct, unsigned int n, + ... /* REQ'D even if n>1: int greedy */); +NRRDIO_EXPORT unsigned int airParseStrE(int *out, const char *s, + const char *ct, unsigned int n, + ... /* REQUIRED: airEnum *e */); +NRRDIO_EXPORT unsigned int (*airParseStr[AIR_TYPE_MAX+1])(void *, const char *, + const char *, + unsigned int, ...); /* string.c */ -TEEM_API char *airStrdup(const char *s); -TEEM_API size_t airStrlen(const char *s); -TEEM_API int airStrtokQuoting; -TEEM_API char *airStrtok(char *s, const char *ct, char **last); -TEEM_API unsigned int airStrntok(const char *s, const char *ct); -TEEM_API char *airStrtrans(char *s, char from, char to); -TEEM_API int airEndsWith(const char *s, const char *suff); -TEEM_API char *airUnescape(char *s); -TEEM_API char *airOneLinify(char *s); -TEEM_API char *airToLower(char *str); -TEEM_API char *airToUpper(char *str); -TEEM_API unsigned int airOneLine(FILE *file, char *line, int size); +NRRDIO_EXPORT char *airStrdup(const char *s); +NRRDIO_EXPORT size_t airStrlen(const char *s); +NRRDIO_EXPORT int airStrtokQuoting; +NRRDIO_EXPORT char *airStrtok(char *s, const char *ct, char **last); +NRRDIO_EXPORT unsigned int airStrntok(const char *s, const char *ct); +NRRDIO_EXPORT char *airStrtrans(char *s, char from, char to); +NRRDIO_EXPORT int airEndsWith(const char *s, const char *suff); +NRRDIO_EXPORT char *airUnescape(char *s); +NRRDIO_EXPORT char *airOneLinify(char *s); +NRRDIO_EXPORT char *airToLower(char *str); +NRRDIO_EXPORT char *airToUpper(char *str); +NRRDIO_EXPORT unsigned int airOneLine(FILE *file, char *line, int size); /* sane.c */ /* @@ -353,26 +374,27 @@ enum { airInsane_FltDblFPClass, /* 5: double -> float assignment messed up the airFPClass_f() of the value */ airInsane_QNaNHiBit, /* 6: airMyQNaNHiBit is wrong */ - airInsane_dio, /* 7: airMyDio set to something invalid */ - airInsane_32Bit, /* 8: airMy32Bit is wrong */ - airInsane_UCSize, /* 9: unsigned char isn't 8 bits */ - airInsane_FISize, /* 10: sizeof(float), sizeof(int) not 4 */ - airInsane_DLSize /* 11: sizeof(double), sizeof(airLLong) not 8 */ + airInsane_AIR_NAN, /* 7: airFPClass_f(AIR_QNAN,AIR_SNAN) wrong */ + airInsane_dio, /* 8: airMyDio set to something invalid */ + airInsane_32Bit, /* 9: airMy32Bit is wrong */ + airInsane_UCSize, /* 10: unsigned char isn't 8 bits */ + airInsane_FISize, /* 11: sizeof(float), sizeof(int) not 4 */ + airInsane_DLSize /* 12: sizeof(double), sizeof(airLLong) not 8 */ }; -#define AIR_INSANE_MAX 11 -TEEM_API const char *airInsaneErr(int insane); -TEEM_API int airSanity(void); +#define AIR_INSANE_MAX 12 +NRRDIO_EXPORT const char *airInsaneErr(int insane); +NRRDIO_EXPORT int airSanity(void); /* miscAir.c */ -TEEM_API const char *airTeemVersion; -TEEM_API const char *airTeemReleaseDate; -TEEM_API void *airNull(void); -TEEM_API void *airSetNull(void **ptrP); -TEEM_API void *airFree(void *ptr); -TEEM_API FILE *airFopen(const char *name, FILE *std, const char *mode); -TEEM_API FILE *airFclose(FILE *file); -TEEM_API int airSinglePrintf(FILE *file, char *str, const char *fmt, ...); -TEEM_API const int airMy32Bit; +NRRDIO_EXPORT const char *airTeemVersion; +NRRDIO_EXPORT const char *airTeemReleaseDate; +NRRDIO_EXPORT void *airNull(void); +NRRDIO_EXPORT void *airSetNull(void **ptrP); +NRRDIO_EXPORT void *airFree(void *ptr); +NRRDIO_EXPORT FILE *airFopen(const char *name, FILE *std, const char *mode); +NRRDIO_EXPORT FILE *airFclose(FILE *file); +NRRDIO_EXPORT int airSinglePrintf(FILE *file, char *str, const char *fmt, ...); +NRRDIO_EXPORT const int airMy32Bit; /* dio.c */ /* @@ -397,14 +419,14 @@ enum { airNoDio_disable /* 12: someone disabled it with airDisableDio */ }; #define AIR_NODIO_MAX 12 -TEEM_API const char *airNoDioErr(int noDio); -TEEM_API const int airMyDio; -TEEM_API int airDisableDio; -TEEM_API void airDioInfo(int *align, int *min, int *max, int fd); -TEEM_API int airDioTest(int fd, const void *ptr, size_t size); -TEEM_API void *airDioMalloc(size_t size, int fd); -TEEM_API size_t airDioRead(int fd, void *ptr, size_t size); -TEEM_API size_t airDioWrite(int fd, const void *ptr, size_t size); +NRRDIO_EXPORT const char *airNoDioErr(int noDio); +NRRDIO_EXPORT const int airMyDio; +NRRDIO_EXPORT int airDisableDio; +NRRDIO_EXPORT void airDioInfo(int *align, int *min, int *max, int fd); +NRRDIO_EXPORT int airDioTest(int fd, const void *ptr, size_t size); +NRRDIO_EXPORT void *airDioMalloc(size_t size, int fd); +NRRDIO_EXPORT size_t airDioRead(int fd, void *ptr, size_t size); +NRRDIO_EXPORT size_t airDioWrite(int fd, const void *ptr, size_t size); /* mop.c: clean-up utilities */ enum { @@ -419,16 +441,16 @@ typedef struct { airMopper mop; /* the function to which does the processing */ int when; /* from the airMopWhen enum */ } airMop; -TEEM_API airArray *airMopNew(void); -TEEM_API void airMopAdd(airArray *arr, void *ptr, airMopper mop, int when); -TEEM_API void airMopSub(airArray *arr, void *ptr, airMopper mop); -TEEM_API void airMopMem(airArray *arr, void *_ptrP, int when); -TEEM_API void airMopUnMem(airArray *arr, void *_ptrP); -TEEM_API void airMopPrint(airArray *arr, const void *_str, int when); -TEEM_API void airMopDone(airArray *arr, int error); -TEEM_API void airMopError(airArray *arr); -TEEM_API void airMopOkay(airArray *arr); -TEEM_API void airMopDebug(airArray *arr); +NRRDIO_EXPORT airArray *airMopNew(void); +NRRDIO_EXPORT int airMopAdd(airArray *arr, void *ptr, airMopper mop, int when); +NRRDIO_EXPORT void airMopSub(airArray *arr, void *ptr, airMopper mop); +NRRDIO_EXPORT void airMopMem(airArray *arr, void *_ptrP, int when); +NRRDIO_EXPORT void airMopUnMem(airArray *arr, void *_ptrP); +NRRDIO_EXPORT void airMopPrint(airArray *arr, const void *_str, int when); +NRRDIO_EXPORT void airMopDone(airArray *arr, int error); +NRRDIO_EXPORT void airMopError(airArray *arr); +NRRDIO_EXPORT void airMopOkay(airArray *arr); +NRRDIO_EXPORT void airMopDebug(airArray *arr); /******* the interminable sea of defines and macros *******/ @@ -444,13 +466,31 @@ TEEM_API void airMopDebug(airArray *arr); */ #define AIR_UNUSED(x) (void)(x) +/* +******** AIR_CAST +** +** just a cast, but with the added ability to grep for it more easily, +** since casts should probably always be revisited and reconsidered. +*/ +#define AIR_CAST(t, v) ((t)(v)) + +/* +******** AIR_CALLOC +** +** slightly simpler wrapper around cast and calloc +** +** HEY note that "T" is not guarded by parentheses in its first usage, +** as arguments in Teem macros normally are +*/ +#define AIR_CALLOC(N, T) (T*)(calloc((N), sizeof(T))) + /* ******** AIR_ENDIAN, AIR_QNANHIBIT, AIR_DIO ** ** These reflect particulars of hardware which we're running on. ** The reason to have these in addition to TEEM_ENDIAN, TEEM_DIO, etc., ** is that those are not by default defined for every source-file -** compilation: the teem library has to define NEED_ENDIAN, NEED_DIO, etc, +** compilation: the Teem library has to define NEED_ENDIAN, NEED_DIO, etc, ** and these in turn generate appropriate compile command-line flags ** by Common.mk. By having these defined here, they become available ** to anyone who simply links against the air library (and includes air.h), @@ -497,10 +537,7 @@ TEEM_API void airMopDebug(airArray *arr); ** (80-bit) floating point registers, such as Intel chips- where the ** same initial value 1) directly read from the register, versus 2) ** saved to memory and loaded back, may end up being different. I -** have yet to produce this behavior, or convince myself it can't -** happen. If you have problems, then use the version of the macro -** which is a function call to airExists_d(), and please email me: -** gk@bwh.harvard.edu +** have yet to produce this behavior, or convince myself it can't happen. ** ** The reason to #define AIR_EXISTS as airExists_d is that on some ** optimizing compilers, the !((x) - (x)) doesn't work. This has been @@ -530,7 +567,7 @@ TEEM_API void airMopDebug(airArray *arr); */ #define AIR_MAX(a,b) ((a) > (b) ? (a) : (b)) #define AIR_MIN(a,b) ((a) < (b) ? (a) : (b)) -#define AIR_ABS(a) ((a) > 0 ? (a) : -(a)) +#define AIR_ABS(a) ((a) > 0.0f ? (a) : -(a)) /* ******** AIR_COMPARE(a,b) @@ -550,7 +587,7 @@ TEEM_API void airMopDebug(airArray *arr); ** defined by the first and third arguments ** ** AIR_IN_OP is new name for old AIR_BETWEEN -** AIR_IN_CL is new name for odl AIR_INSIDE +** AIR_IN_CL is new name for old AIR_INSIDE */ #define AIR_IN_OP(a,b,c) ((a) < (b) && (b) < (c)) /* closed interval */ #define AIR_IN_CL(a,b,c) ((a) <= (b) && (b) <= (c)) /* open interval */ @@ -601,6 +638,10 @@ TEEM_API void airMopDebug(airArray *arr); ** It is the callers responsibility to make sure I-i and O-o are ** both non-zero. Strictly speaking, real problems arise only when ** when I-i is zero: division by zero generates either NaN or infinity +** +** NOTE that "x" is evaluated only once (which makes this more useful), +** as is "I" and "O" (usually not so important); "i" and "o" are each +** evaluated twice */ #define AIR_AFFINE(i,x,I,o,O) ( \ ((double)(O)-(o))*((double)(x)-(i)) / ((double)(I)-(i)) + (o)) @@ -618,6 +659,8 @@ TEEM_API void airMopDebug(airArray *arr); ** ** It is the callers responsibility to make sure I-i and O-o are ** both non-zero +** +** NOTE that all arguments are evaluated only once */ #define AIR_DELTA(i,x,I,o,O) ( \ ((double)(O)-(o))*((double)(x)) / ((double)(I)-(i)) ) @@ -629,44 +672,50 @@ TEEM_API void airMopDebug(airArray *arr); */ #define AIR_ROUNDUP(x) ((int)(floor((x)+0.5))) #define AIR_ROUNDDOWN(x) ((int)(ceil((x)-0.5))) +#define AIR_ROUNDUP_UI(x) ((unsigned int)(floor((x)+0.5))) +#define AIR_ROUNDDOWN_UI(x) ((unsigned int)(ceil((x)-0.5))) /* ******** _AIR_SIZE_T_CNV, _AIR_PTRDIFF_T_CNV, ** -** Conversion sequence to use when printf/fprintf/sprintf-ing a value of +** Format specifiers to use when printf/fprintf/sprintf-ing a value of ** type size_t or ptrdiff_t. In C99, this is done with "%z" and "%t", -** respecitvely. +** respectively. ** -** This is not a useful macro for the world at large- only for teem +** This is not a useful macro for the world at large- only for Teem ** source files. Why: we need to leave this as a bare string, so that ** we can exploit C's implicit string concatenation in forming a ** format string. Therefore, unlike the definition of AIR_ENDIAN, -** AIR_DIO, etc, AIR_SIZE_T_CNV can NOT just refer to a const variable +** AIR_DIO, etc, _AIR_SIZE_T_CNV can NOT just refer to a const variable ** (like airMyEndian). Therefore, TEEM_32BIT has to be defined for -** ALL source files which want to use AIR_SIZE_T_CNV, and to be -** conservative, that's all teem files. The converse is, since there is -** no expectation that other projects which use teem will be defining -** TEEM_32BIT, this is not useful outside teem, thus the leading _. +** ALL source files which want to use _AIR_SIZE_T_CNV, and to be safe, +** that's all Teem files. The converse is, since there is no +** expectation that other projects which use Teem will be defining +** TEEM_32BIT, this is not useful outside Teem, thus the leading _. +** +** http://www.viva64.com/art-1-2-710804781.html for size conventions. +** +** It appears that 32 bit APPLE uses ld for size_t and int for ptrdiff. */ -#ifdef __APPLE__ -# define _AIR_SIZE_T_CNV "%lu" -# define _AIR_PTRDIFF_T_CNV "%d" -#else -# if TEEM_32BIT == 0 -# ifdef _WIN64 -# define _AIR_SIZE_T_CNV "%I64u" -# define _AIR_PTRDIFF_T_CNV "%I64d" -# else -# define _AIR_SIZE_T_CNV "%lu" -# define _AIR_PTRDIFF_T_CNV "%ld" -# endif -# elif TEEM_32BIT == 1 -# define _AIR_SIZE_T_CNV "%u" +#if TEEM_32BIT == 0 +# ifdef _WIN64 +# define _AIR_SIZE_T_CNV "%I64u" +# define _AIR_PTRDIFF_T_CNV "%I64d" +# else +# define _AIR_SIZE_T_CNV "%lu" +# define _AIR_PTRDIFF_T_CNV "%ld" +# endif +#elif TEEM_32BIT == 1 +# ifdef __APPLE__ +# define _AIR_SIZE_T_CNV "%lu" # define _AIR_PTRDIFF_T_CNV "%d" # else -# define _AIR_SIZE_T_CNV "(no _AIR_SIZE_T_CNV w/out TEEM_32BIT %*d)" -# define _AIR_PTRDIFF_T_CNV "(no _AIR_PTRDIFF_T_CNV w/out TEEM_32BIT %*d)" +# define _AIR_SIZE_T_CNV "%u" +# define _AIR_PTRDIFF_T_CNV "%d" # endif +#else +# define _AIR_SIZE_T_CNV "(no _AIR_SIZE_T_CNV w/out TEEM_32BIT %*d)" +# define _AIR_PTRDIFF_T_CNV "(no _AIR_PTRDIFF_T_CNV w/out TEEM_32BIT %*d)" #endif #ifdef __cplusplus @@ -681,20 +730,81 @@ TEEM_API void airMopDebug(airArray *arr); extern "C" { #endif -#define BIFF_MAXKEYLEN 128 /* maximum allowed key length (not counting - the null termination) */ - -TEEM_API void biffAdd(const char *key, const char *err); -TEEM_API void biffMaybeAdd(const char *key, const char *err, int useBiff); -TEEM_API int biffCheck(const char *key); -TEEM_API void biffDone(const char *key); -TEEM_API void biffMove(const char *destKey, const char *err, - const char *srcKey); -TEEM_API char *biffGet(const char *key); -TEEM_API int biffGetStrlen(const char *key); -TEEM_API void biffSetStr(char *str, const char *key); -TEEM_API char *biffGetDone(const char *key); -TEEM_API void biffSetStrDone(char *str, const char *key); +/* +** biffMsg struct +** +** externally usable thing for holding error messages +*/ +typedef struct { + char *key; /* string for identifying the general source + of the error message; set once, at time + of biffMsg creation */ + char **err; /* array of error strings; the err array itself + is NOT null-terminated */ + unsigned int errNum; /* length of "err" == # strings stored */ + airArray *errArr; /* air array for err and num */ +} biffMsg; + +/* biffmsg.c */ +NRRDIO_EXPORT biffMsg *biffMsgNew(const char *key); +NRRDIO_EXPORT biffMsg *biffMsgNix(biffMsg *msg); +NRRDIO_EXPORT void biffMsgAdd(biffMsg *msg, const char *err); +NRRDIO_EXPORT void biffMsgAddVL(biffMsg *msg, const char *errfmt, va_list args); +NRRDIO_EXPORT void biffMsgAddf(biffMsg *msg, const char *errfmt, ...) +#ifdef __GNUC__ +__attribute__ ((format(printf,2,3))) +#endif +; +NRRDIO_EXPORT void biffMsgClear(biffMsg *msg); +NRRDIO_EXPORT unsigned int biffMsgLineLenMax(const biffMsg *msg); +NRRDIO_EXPORT void biffMsgMove(biffMsg *dest, biffMsg *src, + const char *err); +NRRDIO_EXPORT void biffMsgMoveVL(biffMsg *dest, biffMsg *src, + const char *errfmt, va_list args); +NRRDIO_EXPORT void biffMsgMovef(biffMsg *dest, biffMsg *src, + const char *errfmt, ...) +#ifdef __GNUC__ +__attribute__ ((format(printf,3,4))) +#endif +; +NRRDIO_EXPORT unsigned int biffMsgStrlen(const biffMsg *msg); +NRRDIO_EXPORT char *biffMsgStrAlloc(const biffMsg *msg); +NRRDIO_EXPORT void biffMsgStrSet(char *ret, const biffMsg *msg); +NRRDIO_EXPORT char *biffMsgStrGet(const biffMsg *msg); +NRRDIO_EXPORT biffMsg *biffMsgNoop; + +/* biffbiff.c */ +NRRDIO_EXPORT void biffAdd(const char *key, const char *err); +NRRDIO_EXPORT void biffAddVL(const char *key, const char *errfmt, va_list args); +NRRDIO_EXPORT void biffAddf(const char *key, const char *errfmt, ...) +#ifdef __GNUC__ + __attribute__ ((format(printf,2,3))) +#endif +; +NRRDIO_EXPORT void biffMaybeAdd(const char *key, const char *err, int useBiff); +NRRDIO_EXPORT void biffMaybeAddf(int useBiff, const char *key, + const char *errfmt, ... ) +#ifdef __GNUC__ +__attribute__ ((format(printf,3,4))) +#endif +; +NRRDIO_EXPORT char *biffGet(const char *key); +NRRDIO_EXPORT int biffGetStrlen(const char *key); +NRRDIO_EXPORT void biffSetStr(char *str, const char *key); +NRRDIO_EXPORT int biffCheck(const char *key); +NRRDIO_EXPORT void biffDone(const char *key); +NRRDIO_EXPORT void biffMove(const char *destKey, const char *err, + const char *srcKey); +NRRDIO_EXPORT void biffMoveVL(const char *destKey, const char *srcKey, + const char *errfmt, va_list args); +NRRDIO_EXPORT void biffMovef(const char *destKey, const char *srcKey, + const char *errfmt, ...) +#ifdef __GNUC__ +__attribute__ ((format(printf,3,4))) +#endif +; +NRRDIO_EXPORT char *biffGetDone(const char *key); +NRRDIO_EXPORT void biffSetStrDone(char *str, const char *key); #ifdef __cplusplus } @@ -729,7 +839,7 @@ extern "C" { (that is more like 3), but is the max number of parms of any NrrdKernel used by anyone using - teem, such as in gage. + Teem, such as in gage. Enforcing one global max simplifies implementation. */ @@ -841,7 +951,7 @@ enum { }; /* -******** nrrdFormatType enum +******** nrrdFormatType* enum ** ** the different file formats which nrrd supports */ @@ -859,7 +969,7 @@ enum { #define NRRD_FORMAT_TYPE_MAX 6 /* -******** nrrdBoundary enum +******** nrrdBoundary* enum ** ** when resampling, how to deal with the ends of a scanline */ @@ -871,12 +981,13 @@ enum { nrrdBoundaryWeight, /* 4: normalize the weighting on the existing samples; ONLY sensible for a strictly positive kernel which integrates to unity (as in blurring) */ + nrrdBoundaryMirror, /* 5: mirror folding */ nrrdBoundaryLast }; -#define NRRD_BOUNDARY_MAX 4 +#define NRRD_BOUNDARY_MAX 5 /* -******** nrrdType enum +******** nrrdType* enum ** ** all the different types, identified by integer ** @@ -1018,7 +1129,7 @@ enum { nrrdKind3Gradient, /* 20: 3-component covariant vector */ nrrdKind3Normal, /* 21: 3-component covector, assumed normalized */ nrrdKind4Vector, /* 22: 4-component vector */ - nrrdKindQuaternion, /* 23: (x,y,z,w), not necessarily normalized */ + nrrdKindQuaternion, /* 23: (w,x,y,z), not necessarily normalized */ nrrdKind2DSymMatrix, /* 24: Mxx Mxy Myy */ nrrdKind2DMaskedSymMatrix, /* 25: mask Mxx Mxy Myy */ nrrdKind2DMatrix, /* 26: Mxx Mxy Myx Myy */ @@ -1288,6 +1399,7 @@ enum { space */ nrrdSpacingStatusLast }; +#define NRRD_SPACING_STATUS_MAX 4 /* ******** nrrdOriginStatus* enum @@ -1415,16 +1527,21 @@ do { \ ** and dimension "dim", calculates the linear index, and stores it in ** "I". */ -#define NRRD_INDEX_GEN(I, coord, size, dim) \ -do { \ - int d; \ - for (d=(dim)-1, (I)=(coord)[d--]; \ - d >= 0; \ - d--) { \ - (I) = (coord)[d] + (size)[d]*(I); \ - } \ -} while (0) - +#define NRRD_INDEX_GEN(I, coord, size, dim) \ +{ \ + int d; \ + d = (dim) - 1; \ + if ( (d) >= 0 ) \ + { \ + (I) = (coord)[d]; \ + d--; \ + while( d >= 0 ) \ + { \ + (I) = (coord)[d] + (size)[d] * (I); \ + d--; \ + } \ + } \ +} /* ******** NRRD_COORD_GEN ** @@ -1451,9 +1568,9 @@ do { \ #include <errno.h> +#include <stddef.h> /* for ptrdiff_t */ -#include <stddef.h> /* for ptrdiff_t */ #ifdef __cplusplus extern "C" { @@ -1462,7 +1579,7 @@ extern "C" { #define NRRD nrrdBiffKey /* -******** NrrdAxis struct +******** NrrdAxisInfo struct ** ** all the information which can sensibly be associated with ** one axis of a nrrd. The only member which MUST be explicitly @@ -1579,9 +1696,11 @@ typedef struct { in the "measurement frame" to those in the world space described by spaceDim (and hopefully space). Coeff [i][j] is - column i and row j. There are no - semantics linking this to the "kind" of - any axis, for a variety of reasons */ + *column* i & *row* j, which is probably + the *transpose* of what you expect. + There are no semantics linking this to + the "kind" of any axis, for a variety + of reasons */ size_t blockSize; /* for nrrdTypeBlock, block byte size */ double oldMin, oldMax; /* if non-NaN, and if nrrd is of integral type, extremal values for the array @@ -1702,11 +1821,22 @@ typedef struct NrrdIoState_t { style format string, not in the sense of a file format. This may need header-relative path processing. */ - **dataFN; /* ON READ + WRITE: array of data filenames. These + **dataFN, /* ON READ + WRITE: array of data filenames. These are not passed directly to fopen, they may need header-relative path processing. Like the cmtArr in the Nrrd, this array is not NULL- terminated */ + *headerStringWrite; /* ON WRITE: string from to which the header can + be written. On write, it is assumed allocated + for as long as it needs to be (probably via a + first pass with learningHeaderStrlen). NOTE: + It is the non-NULL-ity of this which signifies + the intent to do string-based writing */ + const char + *headerStringRead; /* ON READ: like headerStringWrite, but for + reading the header from. NOTE: It is the + non-NULL-ity of this which signifies the + intent to do string-based reading */ airArray *dataFNArr; /* for managing the above */ FILE *headerFile, /* if non-NULL, the file from which the NRRD @@ -1731,13 +1861,21 @@ typedef struct NrrdIoState_t { something with the formatting, then what is the max number of values to write on a line */ - lineSkip; /* if dataFile non-NULL, the number of + lineSkip, /* if dataFile non-NULL, the number of lines in dataFile that should be skipped over (so as to bypass another form of ASCII header preceeding raw data) */ - int dataFNMin, /* used with dataFNFormat to identify ...*/ - dataFNMax, /* ... all the multiple detached datafiles */ + headerStrlen, /* ON WRITE, for NRRDs, if learningHeaderStrlen, + the learned strlen of the header so far */ + headerStrpos; /* ON READ, for NRRDs, if headerStringRead is + non-NULL, the current location of reading + in the header */ + long int byteSkip; /* exactly like lineSkip, but bytes + instead of lines. First the lines are + skipped, then the bytes */ + int dataFNMin, /* used with dataFNFormat to identify .. */ + dataFNMax, /* .. all the multiple detached datafiles */ dataFNStep, /* how to step from max to min */ dataFNIndex, /* which of the data files are being read */ pos, /* line[pos] is beginning of stuff which @@ -1745,9 +1883,6 @@ typedef struct NrrdIoState_t { endian, /* endian-ness of the data in file, for those encoding/type combinations for which it matters (from nrrdEndian) */ - byteSkip, /* exactly like lineSkip, but bytes - instead of lines. First the lines are - skipped, then the bytes */ seen[NRRD_FIELD_MAX+1], /* for error checking in header parsing */ detachedHeader, /* ON WRITE: request for file (NRRD format only) to be split into distinct header and data. @@ -1780,9 +1915,12 @@ typedef struct NrrdIoState_t { zlibStrategy, /* zlib compression strategy, can be one of the nrrdZlibStrategy enums, default is nrrdZlibStrategyDefault. */ - bzip2BlockSize; /* block size used for compression, + bzip2BlockSize, /* block size used for compression, roughly equivalent to better but slower (1-9, -1 for default[9]). */ + learningHeaderStrlen; /* ON WRITE, for nrrds, learn and save the total + length of header into headerStrlen. This is + used to allocate a buffer for header */ void *oldData; /* ON READ: if non-NULL, pointer to space that has already been allocated for oldDataSize */ size_t oldDataSize; /* ON READ: size of mem pointed to by oldData */ @@ -1795,21 +1933,22 @@ typedef struct NrrdIoState_t { } NrrdIoState; -/******** defaults (nrrdDef..) and state (nrrdState..) */ +/******** defaults (nrrdDefault..) and state (nrrdState..) */ /* defaultsNrrd.c */ -TEEM_API const NrrdEncoding *nrrdDefWriteEncoding; -TEEM_API int nrrdDefWriteBareText; -TEEM_API int nrrdDefWriteCharsPerLine; -TEEM_API int nrrdDefWriteValsPerLine; -TEEM_API int nrrdDefCenter; -TEEM_API double nrrdDefSpacing; -TEEM_API int nrrdStateVerboseIO; -TEEM_API int nrrdStateAlwaysSetContent; -TEEM_API int nrrdStateDisableContent; -TEEM_API char *nrrdStateUnknownContent; -TEEM_API int nrrdStateGrayscaleImage3D; -TEEM_API int nrrdStateKeyValueReturnInternalPointers; -TEEM_API int nrrdStateKindNoop; +NRRDIO_EXPORT int nrrdDefaultWriteEncodingType; +NRRDIO_EXPORT int nrrdDefaultWriteBareText; +NRRDIO_EXPORT unsigned int nrrdDefaultWriteCharsPerLine; +NRRDIO_EXPORT unsigned int nrrdDefaultWriteValsPerLine; +NRRDIO_EXPORT int nrrdDefaultCenter; +NRRDIO_EXPORT double nrrdDefaultSpacing; +NRRDIO_EXPORT int nrrdStateVerboseIO; +NRRDIO_EXPORT int nrrdStateKeyValuePairsPropagate; +NRRDIO_EXPORT int nrrdStateAlwaysSetContent; +NRRDIO_EXPORT int nrrdStateDisableContent; +NRRDIO_EXPORT char *nrrdStateUnknownContent; +NRRDIO_EXPORT int nrrdStateGrayscaleImage3D; +NRRDIO_EXPORT int nrrdStateKeyValueReturnInternalPointers; +NRRDIO_EXPORT int nrrdStateKindNoop; /******** all the airEnums used through-out nrrd */ /* @@ -1818,214 +1957,266 @@ TEEM_API int nrrdStateKindNoop; ** name is best used for the airEnums here */ /* enumsNrrd.c */ -TEEM_API airEnum *nrrdFormatType; -TEEM_API airEnum *nrrdType; -TEEM_API airEnum *nrrdEncodingType; -TEEM_API airEnum *nrrdCenter; -TEEM_API airEnum *nrrdKind; -TEEM_API airEnum *nrrdField; -TEEM_API airEnum *nrrdSpace; +NRRDIO_EXPORT const airEnum *const nrrdFormatType; +NRRDIO_EXPORT const airEnum *const nrrdType; +NRRDIO_EXPORT const airEnum *const nrrdEncodingType; +NRRDIO_EXPORT const airEnum *const nrrdCenter; +NRRDIO_EXPORT const airEnum *const nrrdKind; +NRRDIO_EXPORT const airEnum *const nrrdField; +NRRDIO_EXPORT const airEnum *const nrrdSpace; +NRRDIO_EXPORT const airEnum *const nrrdSpacingStatus; /******** arrays of things (poor-man's functions/predicates) */ /* arraysNrrd.c */ -TEEM_API const char nrrdTypePrintfStr[][AIR_STRLEN_SMALL]; -TEEM_API const size_t nrrdTypeSize[]; -TEEM_API const double nrrdTypeMin[]; -TEEM_API const double nrrdTypeMax[]; -TEEM_API const int nrrdTypeIsIntegral[]; -TEEM_API const int nrrdTypeIsUnsigned[]; -TEEM_API const double nrrdTypeNumberOfValues[]; +NRRDIO_EXPORT const char nrrdTypePrintfStr[][AIR_STRLEN_SMALL]; +NRRDIO_EXPORT const size_t nrrdTypeSize[]; +NRRDIO_EXPORT const double nrrdTypeMin[]; +NRRDIO_EXPORT const double nrrdTypeMax[]; +NRRDIO_EXPORT const int nrrdTypeIsIntegral[]; +NRRDIO_EXPORT const int nrrdTypeIsUnsigned[]; +NRRDIO_EXPORT const double nrrdTypeNumberOfValues[]; /******** pseudo-constructors, pseudo-destructors, and such */ /* methodsNrrd.c */ -TEEM_API NrrdIoState *nrrdIoStateNew(void); -TEEM_API void nrrdIoStateInit(NrrdIoState *nio); -TEEM_API NrrdIoState *nrrdIoStateNix(NrrdIoState *nio); -TEEM_API void nrrdInit(Nrrd *nrrd); -TEEM_API Nrrd *nrrdNew(void); -TEEM_API Nrrd *nrrdNix(Nrrd *nrrd); -TEEM_API Nrrd *nrrdEmpty(Nrrd *nrrd); -TEEM_API Nrrd *nrrdNuke(Nrrd *nrrd); -TEEM_API int nrrdWrap_nva(Nrrd *nrrd, void *data, int type, - unsigned int dim, const size_t *size); -TEEM_API int nrrdWrap(Nrrd *nrrd, void *data, int type, unsigned int dim, - ... /* sx, sy, .., axis(dim-1) size */); -TEEM_API void nrrdBasicInfoInit(Nrrd *nrrd, int excludeBitflag); -TEEM_API int nrrdBasicInfoCopy(Nrrd *nout, const Nrrd *nin, - int excludeBitflag); -TEEM_API int nrrdCopy(Nrrd *nout, const Nrrd *nin); -TEEM_API int nrrdAlloc_nva(Nrrd *nrrd, int type, unsigned int dim, - const size_t *size); -TEEM_API int nrrdAlloc(Nrrd *nrrd, int type, unsigned int dim, - ... /* sx, sy, .., axis(dim-1) size */); -TEEM_API int nrrdMaybeAlloc_nva(Nrrd *nrrd, int type, unsigned int dim, - const size_t *size); -TEEM_API int nrrdMaybeAlloc(Nrrd *nrrd, int type, unsigned int dim, - ... /* sx, sy, .., axis(dim-1) size */); -TEEM_API int nrrdPPM(Nrrd *, size_t sx, size_t sy); -TEEM_API int nrrdPGM(Nrrd *, size_t sx, size_t sy); +NRRDIO_EXPORT NrrdIoState *nrrdIoStateNew(void); +NRRDIO_EXPORT void nrrdIoStateInit(NrrdIoState *nio); +NRRDIO_EXPORT NrrdIoState *nrrdIoStateNix(NrrdIoState *nio); +NRRDIO_EXPORT void nrrdInit(Nrrd *nrrd); +NRRDIO_EXPORT Nrrd *nrrdNew(void); +NRRDIO_EXPORT Nrrd *nrrdNix(Nrrd *nrrd); +NRRDIO_EXPORT Nrrd *nrrdEmpty(Nrrd *nrrd); +NRRDIO_EXPORT Nrrd *nrrdNuke(Nrrd *nrrd); +NRRDIO_EXPORT int nrrdWrap_nva(Nrrd *nrrd, void *data, int type, + unsigned int dim, const size_t *size); +NRRDIO_EXPORT int nrrdWrap_va(Nrrd *nrrd, void *data, int type, unsigned int dim, + ... /* size_t sx, sy, .., axis(dim-1) size */); +NRRDIO_EXPORT void nrrdBasicInfoInit(Nrrd *nrrd, int excludeBitflag); +NRRDIO_EXPORT int nrrdBasicInfoCopy(Nrrd *nout, const Nrrd *nin, + int excludeBitflag); +NRRDIO_EXPORT int nrrdCopy(Nrrd *nout, const Nrrd *nin); +NRRDIO_EXPORT int nrrdAlloc_nva(Nrrd *nrrd, int type, unsigned int dim, + const size_t *size); +NRRDIO_EXPORT int nrrdAlloc_va(Nrrd *nrrd, int type, unsigned int dim, + ... /* size_t sx, sy, .., axis(dim-1) size */); +NRRDIO_EXPORT int nrrdMaybeAlloc_nva(Nrrd *nrrd, int type, unsigned int dim, + const size_t *size); +NRRDIO_EXPORT int nrrdMaybeAlloc_va(Nrrd *nrrd, int type, unsigned int dim, + ... /* size_t sx, sy, .., ax(dim-1) size */); +NRRDIO_EXPORT int nrrdPPM(Nrrd *, size_t sx, size_t sy); +NRRDIO_EXPORT int nrrdPGM(Nrrd *, size_t sx, size_t sy); /******** axis info related */ /* axis.c */ -TEEM_API int nrrdKindIsDomain(int kind); -TEEM_API unsigned int nrrdKindSize(int kind); -TEEM_API int nrrdAxisInfoCopy(Nrrd *nout, const Nrrd *nin, - const int *axmap, int excludeBitflag); -TEEM_API void nrrdAxisInfoSet_nva(Nrrd *nin, int axInfo, const void *info); -TEEM_API void nrrdAxisInfoSet(Nrrd *nin, int axInfo, - ... /* const void* */); -TEEM_API void nrrdAxisInfoGet_nva(const Nrrd *nrrd, int axInfo, void *info); -TEEM_API void nrrdAxisInfoGet(const Nrrd *nrrd, int axInfo, - ... /* void* */); -TEEM_API double nrrdAxisInfoPos(const Nrrd *nrrd, unsigned int ax, double idx); -TEEM_API double nrrdAxisInfoIdx(const Nrrd *nrrd, unsigned int ax, double pos); -TEEM_API void nrrdAxisInfoPosRange(double *loP, double *hiP, - const Nrrd *nrrd, unsigned int ax, - double loIdx, double hiIdx); -TEEM_API void nrrdAxisInfoIdxRange(double *loP, double *hiP, - const Nrrd *nrrd, unsigned int ax, - double loPos, double hiPos); -TEEM_API void nrrdAxisInfoSpacingSet(Nrrd *nrrd, unsigned int ax); -TEEM_API void nrrdAxisInfoMinMaxSet(Nrrd *nrrd, unsigned int ax, - int defCenter); -TEEM_API unsigned int nrrdDomainAxesGet(Nrrd *nrrd, - unsigned int axisIdx[NRRD_DIM_MAX]); -TEEM_API unsigned int nrrdRangeAxesGet(Nrrd *nrrd, - unsigned int axisIdx[NRRD_DIM_MAX]); -TEEM_API int nrrdSpacingCalculate(const Nrrd *nrrd, unsigned int ax, - double *spacing, - double vector[NRRD_SPACE_DIM_MAX]); +NRRDIO_EXPORT int nrrdKindIsDomain(int kind); +NRRDIO_EXPORT unsigned int nrrdKindSize(int kind); +NRRDIO_EXPORT int nrrdAxisInfoCopy(Nrrd *nout, const Nrrd *nin, + const int *axmap, int excludeBitflag); +NRRDIO_EXPORT void nrrdAxisInfoSet_nva(Nrrd *nin, int axInfo, const void *info); +NRRDIO_EXPORT void nrrdAxisInfoSet_va(Nrrd *nin, int axInfo, + ... /* const void* */); +NRRDIO_EXPORT void nrrdAxisInfoGet_nva(const Nrrd *nrrd, int axInfo, void *info); +NRRDIO_EXPORT void nrrdAxisInfoGet_va(const Nrrd *nrrd, int axInfo, + ... /* ??? */); +NRRDIO_EXPORT double nrrdAxisInfoPos(const Nrrd *nrrd, unsigned int ax, + double idx); +NRRDIO_EXPORT double nrrdAxisInfoIdx(const Nrrd *nrrd, unsigned int ax, + double pos); +NRRDIO_EXPORT void nrrdAxisInfoPosRange(double *loP, double *hiP, + const Nrrd *nrrd, unsigned int ax, + double loIdx, double hiIdx); +NRRDIO_EXPORT void nrrdAxisInfoIdxRange(double *loP, double *hiP, + const Nrrd *nrrd, unsigned int ax, + double loPos, double hiPos); +NRRDIO_EXPORT void nrrdAxisInfoSpacingSet(Nrrd *nrrd, unsigned int ax); +NRRDIO_EXPORT void nrrdAxisInfoMinMaxSet(Nrrd *nrrd, unsigned int ax, + int defCenter); +NRRDIO_EXPORT unsigned int nrrdDomainAxesGet(const Nrrd *nrrd, + unsigned int axisIdx[NRRD_DIM_MAX]); +NRRDIO_EXPORT unsigned int nrrdRangeAxesGet(const Nrrd *nrrd, + unsigned int axisIdx[NRRD_DIM_MAX]); +NRRDIO_EXPORT unsigned int nrrdSpatialAxesGet(const Nrrd *nrrd, + unsigned int + axisIdx[NRRD_DIM_MAX]); +NRRDIO_EXPORT unsigned int nrrdNonSpatialAxesGet(const Nrrd *nrrd, + unsigned int + axisIdx[NRRD_DIM_MAX]); +NRRDIO_EXPORT int nrrdSpacingCalculate(const Nrrd *nrrd, unsigned int ax, + double *spacing, + double vector[NRRD_SPACE_DIM_MAX]); +NRRDIO_EXPORT int nrrdOrientationReduce(Nrrd *nout, const Nrrd *nin, + int setMinsFromOrigin); /******** simple things */ /* simple.c */ -TEEM_API const char *nrrdBiffKey; -TEEM_API unsigned int nrrdSpaceDimension(int space); -TEEM_API int nrrdSpaceSet(Nrrd *nrrd, int space); -TEEM_API int nrrdSpaceDimensionSet(Nrrd *nrrd, unsigned int spaceDim); -TEEM_API void nrrdSpaceGet(const Nrrd *nrrd, int *space, - unsigned int *spaceDim); -TEEM_API unsigned int nrrdSpaceOriginGet(const Nrrd *nrrd, - double vector[NRRD_SPACE_DIM_MAX]); -TEEM_API int nrrdSpaceOriginSet(Nrrd *nrrd, - double vector[NRRD_SPACE_DIM_MAX]); -TEEM_API int nrrdOriginCalculate(const Nrrd *nrrd, - unsigned int *axisIdx, - unsigned int axisIdxNum, - int defaultCenter, double *origin); -TEEM_API int nrrdContentSet(Nrrd *nout, const char *func, - const Nrrd *nin, const char *format, - ... /* printf-style arg list */ ); -TEEM_API void nrrdDescribe(FILE *file, const Nrrd *nrrd); -TEEM_API int nrrdCheck(const Nrrd *nrrd); -TEEM_API int _nrrdCheck(const Nrrd *nrrd, int checkData, int useBiff); -TEEM_API size_t nrrdElementSize(const Nrrd *nrrd); -TEEM_API size_t nrrdElementNumber(const Nrrd *nrrd); -TEEM_API int nrrdSanity(void); -TEEM_API int nrrdSameSize(const Nrrd *n1, const Nrrd *n2, int useBiff); +NRRDIO_EXPORT const char *nrrdBiffKey; +NRRDIO_EXPORT unsigned int nrrdSpaceDimension(int space); +NRRDIO_EXPORT int nrrdSpaceSet(Nrrd *nrrd, int space); +NRRDIO_EXPORT int nrrdSpaceDimensionSet(Nrrd *nrrd, unsigned int spaceDim); +NRRDIO_EXPORT unsigned int nrrdSpaceOriginGet(const Nrrd *nrrd, + double vector[NRRD_SPACE_DIM_MAX]); +NRRDIO_EXPORT int nrrdSpaceOriginSet(Nrrd *nrrd, + double vector[NRRD_SPACE_DIM_MAX]); +NRRDIO_EXPORT int nrrdOriginCalculate(const Nrrd *nrrd, + unsigned int *axisIdx, + unsigned int axisIdxNum, + int defaultCenter, double *origin); +NRRDIO_EXPORT int nrrdContentSet_va(Nrrd *nout, const char *func, + const Nrrd *nin, const char *format, + ... /* printf-style arg list */ ); +NRRDIO_EXPORT void nrrdDescribe(FILE *file, const Nrrd *nrrd); +NRRDIO_EXPORT int nrrdCheck(const Nrrd *nrrd); +NRRDIO_EXPORT int _nrrdCheck(const Nrrd *nrrd, int checkData, int useBiff); +NRRDIO_EXPORT size_t nrrdElementSize(const Nrrd *nrrd); +NRRDIO_EXPORT size_t nrrdElementNumber(const Nrrd *nrrd); +NRRDIO_EXPORT int nrrdSanity(void); +NRRDIO_EXPORT int nrrdSameSize(const Nrrd *n1, const Nrrd *n2, int useBiff); +NRRDIO_EXPORT void nrrdSpaceVecCopy(double dst[NRRD_SPACE_DIM_MAX], + const double src[NRRD_SPACE_DIM_MAX]); +NRRDIO_EXPORT void nrrdSpaceVecScaleAdd2(double sum[NRRD_SPACE_DIM_MAX], + double sclA, + const double vecA[NRRD_SPACE_DIM_MAX], + double sclB, + const double vecB[NRRD_SPACE_DIM_MAX]); +NRRDIO_EXPORT void nrrdSpaceVecScale(double out[NRRD_SPACE_DIM_MAX], + double scl, + const double vec[NRRD_SPACE_DIM_MAX]); +NRRDIO_EXPORT double nrrdSpaceVecNorm(int sdim, + const double vec[NRRD_SPACE_DIM_MAX]); +NRRDIO_EXPORT void nrrdSpaceVecSetNaN(double vec[NRRD_SPACE_DIM_MAX]); /******** comments related */ /* comment.c */ -TEEM_API int nrrdCommentAdd(Nrrd *nrrd, const char *str); -TEEM_API void nrrdCommentClear(Nrrd *nrrd); -TEEM_API int nrrdCommentCopy(Nrrd *nout, const Nrrd *nin); +NRRDIO_EXPORT int nrrdCommentAdd(Nrrd *nrrd, const char *str); +NRRDIO_EXPORT void nrrdCommentClear(Nrrd *nrrd); +NRRDIO_EXPORT int nrrdCommentCopy(Nrrd *nout, const Nrrd *nin); /******** key/value pairs */ /* keyvalue.c */ -TEEM_API unsigned int nrrdKeyValueSize(const Nrrd *nrrd); -TEEM_API int nrrdKeyValueAdd(Nrrd *nrrd, const char *key, const char *value); -TEEM_API char *nrrdKeyValueGet(const Nrrd *nrrd, const char *key); -TEEM_API void nrrdKeyValueIndex(const Nrrd *nrrd, - char **keyP, char **valueP, unsigned int ki); -TEEM_API int nrrdKeyValueErase(Nrrd *nrrd, const char *key); -TEEM_API void nrrdKeyValueClear(Nrrd *nrrd); -TEEM_API int nrrdKeyValueCopy(Nrrd *nout, const Nrrd *nin); +NRRDIO_EXPORT unsigned int nrrdKeyValueSize(const Nrrd *nrrd); +NRRDIO_EXPORT int nrrdKeyValueAdd(Nrrd *nrrd, + const char *key, const char *value); +NRRDIO_EXPORT char *nrrdKeyValueGet(const Nrrd *nrrd, const char *key); +NRRDIO_EXPORT void nrrdKeyValueIndex(const Nrrd *nrrd, + char **keyP, char **valueP, + unsigned int ki); +NRRDIO_EXPORT int nrrdKeyValueErase(Nrrd *nrrd, const char *key); +NRRDIO_EXPORT void nrrdKeyValueClear(Nrrd *nrrd); +NRRDIO_EXPORT int nrrdKeyValueCopy(Nrrd *nout, const Nrrd *nin); /******** endian related */ /* endianNrrd.c */ -TEEM_API void nrrdSwapEndian(Nrrd *nrrd); +NRRDIO_EXPORT void nrrdSwapEndian(Nrrd *nrrd); /******** getting information to and from files */ /* formatXXX.c */ -TEEM_API const NrrdFormat *const nrrdFormatNRRD; -TEEM_API const NrrdFormat *const nrrdFormatPNM; -TEEM_API const NrrdFormat *const nrrdFormatPNG; -TEEM_API const NrrdFormat *const nrrdFormatVTK; -TEEM_API const NrrdFormat *const nrrdFormatText; -TEEM_API const NrrdFormat *const nrrdFormatEPS; +NRRDIO_EXPORT const NrrdFormat *const nrrdFormatNRRD; +NRRDIO_EXPORT const NrrdFormat *const nrrdFormatPNM; +NRRDIO_EXPORT const NrrdFormat *const nrrdFormatPNG; +NRRDIO_EXPORT const NrrdFormat *const nrrdFormatVTK; +NRRDIO_EXPORT const NrrdFormat *const nrrdFormatText; +NRRDIO_EXPORT const NrrdFormat *const nrrdFormatEPS; /* format.c */ -TEEM_API const NrrdFormat *const nrrdFormatUnknown; -TEEM_API const NrrdFormat * +NRRDIO_EXPORT const NrrdFormat *const nrrdFormatUnknown; +NRRDIO_EXPORT const NrrdFormat * const nrrdFormatArray[NRRD_FORMAT_TYPE_MAX+1]; + /* encodingXXX.c */ -TEEM_API const NrrdEncoding *const nrrdEncodingRaw; -TEEM_API const NrrdEncoding *const nrrdEncodingAscii; -TEEM_API const NrrdEncoding *const nrrdEncodingHex; -TEEM_API const NrrdEncoding *const nrrdEncodingGzip; -TEEM_API const NrrdEncoding *const nrrdEncodingBzip2; +NRRDIO_EXPORT const NrrdEncoding *const nrrdEncodingRaw; +NRRDIO_EXPORT const NrrdEncoding *const nrrdEncodingAscii; +NRRDIO_EXPORT const NrrdEncoding *const nrrdEncodingHex; +NRRDIO_EXPORT const NrrdEncoding *const nrrdEncodingGzip; +NRRDIO_EXPORT const NrrdEncoding *const nrrdEncodingBzip2; /* encoding.c */ -TEEM_API const NrrdEncoding *const nrrdEncodingUnknown; -TEEM_API const NrrdEncoding * +NRRDIO_EXPORT const NrrdEncoding *const nrrdEncodingUnknown; +NRRDIO_EXPORT const NrrdEncoding * const nrrdEncodingArray[NRRD_ENCODING_TYPE_MAX+1]; + /* parseNrrd.c */ /* this needs the "FILE *file" first arg for the sole reason that parsing a "data file: " field which identifies a LIST must then read in all the data filenames from the same file */ -TEEM_API int (*nrrdFieldInfoParse[NRRD_FIELD_MAX+1])(FILE *file, Nrrd *nrrd, - NrrdIoState *nio, - int useBiff); +NRRDIO_EXPORT int (*nrrdFieldInfoParse[NRRD_FIELD_MAX+1])(FILE *file, Nrrd *nrrd, + NrrdIoState *nio, + int useBiff); +NRRDIO_EXPORT unsigned int _nrrdDataFNNumber(NrrdIoState *nio); +NRRDIO_EXPORT int _nrrdContainsPercentThisAndMore(const char *str, char thss); +NRRDIO_EXPORT int _nrrdDataFNCheck(NrrdIoState *nio, Nrrd *nrrd, int useBiff); + /* read.c */ -TEEM_API int nrrdLineSkip(FILE *dataFile, NrrdIoState *nio); -TEEM_API int nrrdByteSkip(FILE *dataFile, Nrrd *nrrd, NrrdIoState *nio); -TEEM_API int nrrdLoad(Nrrd *nrrd, const char *filename, NrrdIoState *nio); -TEEM_API int nrrdRead(Nrrd *nrrd, FILE *file, NrrdIoState *nio); +NRRDIO_EXPORT int _nrrdOneLine(unsigned int *lenP, NrrdIoState *nio, FILE *file); +NRRDIO_EXPORT int nrrdLineSkip(FILE *dataFile, NrrdIoState *nio); +NRRDIO_EXPORT int nrrdByteSkip(FILE *dataFile, Nrrd *nrrd, NrrdIoState *nio); +NRRDIO_EXPORT int nrrdLoad(Nrrd *nrrd, const char *filename, NrrdIoState *nio); +NRRDIO_EXPORT int nrrdLoadMulti(Nrrd *const *nin, unsigned int ninLen, + const char *fnameFormat, + unsigned int numStart, NrrdIoState *nio); +NRRDIO_EXPORT int nrrdRead(Nrrd *nrrd, FILE *file, NrrdIoState *nio); +NRRDIO_EXPORT int nrrdStringRead(Nrrd *nrrd, const char *string, + NrrdIoState *nio); + /* write.c */ -TEEM_API int nrrdIoStateSet(NrrdIoState *nio, int parm, int value); -TEEM_API int nrrdIoStateEncodingSet(NrrdIoState *nio, - const NrrdEncoding *encoding); -TEEM_API int nrrdIoStateFormatSet(NrrdIoState *nio, - const NrrdFormat *format); -TEEM_API int nrrdIoStateGet(NrrdIoState *nio, int parm); -TEEM_API const NrrdEncoding *nrrdIoStateEncodingGet(NrrdIoState *nio); -TEEM_API const NrrdFormat *nrrdIoStateFormatGet(NrrdIoState *nio); -TEEM_API int nrrdSave(const char *filename, const Nrrd *nrrd, - NrrdIoState *nio); -TEEM_API int nrrdWrite(FILE *file, const Nrrd *nrrd, - NrrdIoState *nio); +NRRDIO_EXPORT int nrrdIoStateSet(NrrdIoState *nio, int parm, int value); +NRRDIO_EXPORT int nrrdIoStateEncodingSet(NrrdIoState *nio, + const NrrdEncoding *encoding); +NRRDIO_EXPORT int nrrdIoStateFormatSet(NrrdIoState *nio, + const NrrdFormat *format); +NRRDIO_EXPORT int nrrdIoStateGet(NrrdIoState *nio, int parm); +NRRDIO_EXPORT const NrrdEncoding *nrrdIoStateEncodingGet(NrrdIoState *nio); +NRRDIO_EXPORT const NrrdFormat *nrrdIoStateFormatGet(NrrdIoState *nio); +NRRDIO_EXPORT int nrrdSave(const char *filename, const Nrrd *nrrd, + NrrdIoState *nio); +NRRDIO_EXPORT int nrrdSaveMulti(const char *fnameFormat, + const Nrrd *const *nin, unsigned int ninLen, + unsigned int numStart, NrrdIoState *nio); +NRRDIO_EXPORT int nrrdWrite(FILE *file, const Nrrd *nrrd, + NrrdIoState *nio); +NRRDIO_EXPORT int nrrdStringWrite(char **stringP, const Nrrd *nrrd, + NrrdIoState *nio); /******** getting value into and out of an array of general type, and all other simplistic functionality pseudo-parameterized by type */ /* accessors.c */ -TEEM_API int (*nrrdILoad[NRRD_TYPE_MAX+1])(const void *v); -TEEM_API float (*nrrdFLoad[NRRD_TYPE_MAX+1])(const void *v); -TEEM_API double (*nrrdDLoad[NRRD_TYPE_MAX+1])(const void *v); -TEEM_API int (*nrrdIStore[NRRD_TYPE_MAX+1])(void *v, int j); -TEEM_API float (*nrrdFStore[NRRD_TYPE_MAX+1])(void *v, float f); -TEEM_API double (*nrrdDStore[NRRD_TYPE_MAX+1])(void *v, double d); -TEEM_API int (*nrrdILookup[NRRD_TYPE_MAX+1])(const void *v, size_t I); -TEEM_API float (*nrrdFLookup[NRRD_TYPE_MAX+1])(const void *v, size_t I); -TEEM_API double (*nrrdDLookup[NRRD_TYPE_MAX+1])(const void *v, size_t I); -TEEM_API int (*nrrdIInsert[NRRD_TYPE_MAX+1])(void *v, size_t I, int j); -TEEM_API float (*nrrdFInsert[NRRD_TYPE_MAX+1])(void *v, size_t I, float f); -TEEM_API double (*nrrdDInsert[NRRD_TYPE_MAX+1])(void *v, size_t I, double d); -TEEM_API int (*nrrdSprint[NRRD_TYPE_MAX+1])(char *, const void *); +NRRDIO_EXPORT double (*nrrdDLoad[NRRD_TYPE_MAX+1])(const void *v); +NRRDIO_EXPORT float (*nrrdFLoad[NRRD_TYPE_MAX+1])(const void *v); +NRRDIO_EXPORT int (*nrrdILoad[NRRD_TYPE_MAX+1])(const void *v); +NRRDIO_EXPORT unsigned int (*nrrdUILoad[NRRD_TYPE_MAX+1])(const void *v); +NRRDIO_EXPORT double (*nrrdDStore[NRRD_TYPE_MAX+1])(void *v, double d); +NRRDIO_EXPORT float (*nrrdFStore[NRRD_TYPE_MAX+1])(void *v, float f); +NRRDIO_EXPORT int (*nrrdIStore[NRRD_TYPE_MAX+1])(void *v, int j); +NRRDIO_EXPORT unsigned int (*nrrdUIStore[NRRD_TYPE_MAX+1])(void *v, + unsigned int j); +NRRDIO_EXPORT double (*nrrdDLookup[NRRD_TYPE_MAX+1])(const void *v, size_t I); +NRRDIO_EXPORT float (*nrrdFLookup[NRRD_TYPE_MAX+1])(const void *v, size_t I); +NRRDIO_EXPORT int (*nrrdILookup[NRRD_TYPE_MAX+1])(const void *v, size_t I); +NRRDIO_EXPORT unsigned int (*nrrdUILookup[NRRD_TYPE_MAX+1])(const void *v, + size_t I); +NRRDIO_EXPORT double (*nrrdDInsert[NRRD_TYPE_MAX+1])(void *v, size_t I, + double d); +NRRDIO_EXPORT float (*nrrdFInsert[NRRD_TYPE_MAX+1])(void *v, size_t I, + float f); +NRRDIO_EXPORT int (*nrrdIInsert[NRRD_TYPE_MAX+1])(void *v, size_t I, + int j); +NRRDIO_EXPORT unsigned int (*nrrdUIInsert[NRRD_TYPE_MAX+1])(void *v, size_t I, + unsigned int j); +NRRDIO_EXPORT int (*nrrdSprint[NRRD_TYPE_MAX+1])(char *, const void *); /******** permuting, shuffling, and all flavors of reshaping */ /* reorder.c */ -TEEM_API int nrrdAxesInsert(Nrrd *nout, const Nrrd *nin, unsigned int ax); -TEEM_API int nrrdInvertPerm(unsigned int *invp, const unsigned int *perm, - unsigned int n); -TEEM_API int nrrdAxesPermute(Nrrd *nout, const Nrrd *nin, - const unsigned int *axes); -TEEM_API int nrrdShuffle(Nrrd *nout, const Nrrd *nin, unsigned int axis, - const size_t *perm); +NRRDIO_EXPORT int nrrdAxesInsert(Nrrd *nout, const Nrrd *nin, unsigned int ax); +NRRDIO_EXPORT int nrrdInvertPerm(unsigned int *invp, const unsigned int *perm, + unsigned int n); +NRRDIO_EXPORT int nrrdAxesPermute(Nrrd *nout, const Nrrd *nin, + const unsigned int *axes); +NRRDIO_EXPORT int nrrdShuffle(Nrrd *nout, const Nrrd *nin, unsigned int axis, + const size_t *perm); /******** sampling, slicing, cropping */ /* subset.c */ -TEEM_API int nrrdSlice(Nrrd *nout, const Nrrd *nin, - unsigned int axis, size_t pos); -TEEM_API int nrrdCrop(Nrrd *nout, const Nrrd *nin, - size_t *min, size_t *max); +NRRDIO_EXPORT int nrrdSlice(Nrrd *nout, const Nrrd *nin, + unsigned int axis, size_t pos); +NRRDIO_EXPORT int nrrdCrop(Nrrd *nout, const Nrrd *nin, + size_t *min, size_t *max); #ifdef __cplusplus } diff --git a/Utilities/ITK/Utilities/NrrdIO/accessors.c b/Utilities/ITK/Utilities/NrrdIO/accessors.c index 9b0c0968ec182370c60282382594195647f72dc8..42138ffeb892e9861f50d50adfacf015285177ee 100644 --- a/Utilities/ITK/Utilities/NrrdIO/accessors.c +++ b/Utilities/ITK/Utilities/NrrdIO/accessors.c @@ -1,6 +1,6 @@ /* NrrdIO: stand-alone code for basic nrrd functionality - Copyright (C) 2005 Gordon Kindlmann + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah This software is provided 'as-is', without any express or implied @@ -72,10 +72,15 @@ _nrrdLoad##TA##TB(TB *v) { \ #define LOAD_LIST(TA, TB) \ (TA (*)(const void *))_nrrdLoad##TA##TB, +MAP(LOAD_DEF, UI) MAP(LOAD_DEF, JN) MAP(LOAD_DEF, FL) MAP(LOAD_DEF, DB) +unsigned int (* +nrrdUILoad[NRRD_TYPE_MAX+1])(const void*) = { + NULL, MAP(LOAD_LIST, UI) NULL +}; int (* nrrdILoad[NRRD_TYPE_MAX+1])(const void*) = { NULL, MAP(LOAD_LIST, JN) NULL @@ -105,10 +110,15 @@ _nrrdStore##TA##TB(TB *v, TA j) { \ #define STORE_LIST(TA, TB) \ (TA (*)(void *, TA))_nrrdStore##TA##TB, +MAP(STORE_DEF, UI) MAP(STORE_DEF, JN) MAP(STORE_DEF, FL) MAP(STORE_DEF, DB) +unsigned int (* +nrrdUIStore[NRRD_TYPE_MAX+1])(void *, unsigned int) = { + NULL, MAP(STORE_LIST, UI) NULL +}; int (* nrrdIStore[NRRD_TYPE_MAX+1])(void *, int) = { NULL, MAP(STORE_LIST, JN) NULL @@ -136,10 +146,15 @@ _nrrdLookup##TA##TB(TB *v, size_t I) { \ #define LOOKUP_LIST(TA, TB) \ (TA (*)(const void*, size_t))_nrrdLookup##TA##TB, +MAP(LOOKUP_DEF, UI) MAP(LOOKUP_DEF, JN) MAP(LOOKUP_DEF, FL) MAP(LOOKUP_DEF, DB) +unsigned int (* +nrrdUILookup[NRRD_TYPE_MAX+1])(const void *, size_t) = { + NULL, MAP(LOOKUP_LIST, UI) NULL +}; int (* nrrdILookup[NRRD_TYPE_MAX+1])(const void *, size_t) = { NULL, MAP(LOOKUP_LIST, JN) NULL @@ -169,10 +184,15 @@ _nrrdInsert##TA##TB(TB *v, size_t I, TA j) { \ #define INSERT_LIST(TA, TB) \ (TA (*)(void*, size_t, TA))_nrrdInsert##TA##TB, +MAP(INSERT_DEF, UI) MAP(INSERT_DEF, JN) MAP(INSERT_DEF, FL) MAP(INSERT_DEF, DB) +unsigned int (* +nrrdUIInsert[NRRD_TYPE_MAX+1])(void *, size_t, unsigned int) = { + NULL, MAP(INSERT_LIST, UI) NULL +}; int (* nrrdIInsert[NRRD_TYPE_MAX+1])(void *, size_t, int) = { NULL, MAP(INSERT_LIST, JN) NULL @@ -191,25 +211,28 @@ nrrdDInsert[NRRD_TYPE_MAX+1])(void *, size_t, double) = { ** ** Dereferences pointer v and sprintf()s that value into given string s, ** returns the result of sprintf() +** +** There is obviously no provision for ensuring that the sprint'ing +** doesn't overflow the buffer, which is unfortunate... */ -int _nrrdSprintCH(char *s, const CH *v) { return sprintf(s, "%d", *v); } -int _nrrdSprintUC(char *s, const UC *v) { return sprintf(s, "%u", *v); } -int _nrrdSprintSH(char *s, const SH *v) { return sprintf(s, "%d", *v); } -int _nrrdSprintUS(char *s, const US *v) { return sprintf(s, "%u", *v); } -int _nrrdSprintIN(char *s, const JN *v) { return sprintf(s, "%d", *v); } -int _nrrdSprintUI(char *s, const UI *v) { return sprintf(s, "%u", *v); } -int _nrrdSprintLL(char *s, const LL *v) { +static int _nrrdSprintCH(char *s, const CH *v) { return sprintf(s, "%d", *v); } +static int _nrrdSprintUC(char *s, const UC *v) { return sprintf(s, "%u", *v); } +static int _nrrdSprintSH(char *s, const SH *v) { return sprintf(s, "%d", *v); } +static int _nrrdSprintUS(char *s, const US *v) { return sprintf(s, "%u", *v); } +static int _nrrdSprintIN(char *s, const JN *v) { return sprintf(s, "%d", *v); } +static int _nrrdSprintUI(char *s, const UI *v) { return sprintf(s, "%u", *v); } +static int _nrrdSprintLL(char *s, const LL *v) { return sprintf(s, AIR_LLONG_FMT, *v); } -int _nrrdSprintUL(char *s, const UL *v) { +static int _nrrdSprintUL(char *s, const UL *v) { return sprintf(s, AIR_ULLONG_FMT, *v); } /* HEY: sizeof(float) and sizeof(double) assumed here, since we're basing "8" and "17" on 6 == FLT_DIG and 15 == DBL_DIG, which are digits of precision for floats and doubles, respectively */ -int _nrrdSprintFL(char *s, const FL *v) { +static int _nrrdSprintFL(char *s, const FL *v) { return airSinglePrintf(NULL, s, "%.8g", (double)(*v)); } -int _nrrdSprintDB(char *s, const DB *v) { +static int _nrrdSprintDB(char *s, const DB *v) { return airSinglePrintf(NULL, s, "%.17g", *v); } int (* nrrdSprint[NRRD_TYPE_MAX+1])(char *, const void *) = { diff --git a/Utilities/ITK/Utilities/NrrdIO/array.c b/Utilities/ITK/Utilities/NrrdIO/array.c index f728e25c094f32b80a8785238ce3207cf9486a55..cbaaa54ea00f5356d126263b3a63079d0870981e 100644 --- a/Utilities/ITK/Utilities/NrrdIO/array.c +++ b/Utilities/ITK/Utilities/NrrdIO/array.c @@ -1,6 +1,6 @@ /* NrrdIO: stand-alone code for basic nrrd functionality - Copyright (C) 2005 Gordon Kindlmann + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah This software is provided 'as-is', without any express or implied @@ -22,7 +22,6 @@ 3. This notice may not be removed or altered from any source distribution. */ - #include "NrrdIO.h" void @@ -72,7 +71,7 @@ airArrayNew(void **dataP, unsigned int *lenP, size_t unit, unsigned int incr) { return NULL; } - a = (airArray *)calloc(1, sizeof(airArray)); + a = AIR_CALLOC(1, airArray); if (!a) { return NULL; } @@ -141,6 +140,7 @@ airArrayPointerCB(airArray *a, */ void airArrayLenPreSet(airArray *a, unsigned int newlen) { + /* char me[]="airArrayLenPreSet"; */ unsigned int newsize; void *newdata; @@ -153,22 +153,35 @@ airArrayLenPreSet(airArray *a, unsigned int newlen) { a->noReallocWhenSmaller = AIR_FALSE; } else { newsize = (newlen-1)/a->incr + 1; + /* + fprintf(stderr, "!%s: newlen = %u, incr = %u -> newsize = %u\n", me, + newlen, a->incr, newsize); + fprintf(stderr, "!%s: a->size = %u, a->len = %u, a->unit = %u\n", me, + a->size, a->len, a->unit); + */ if (newsize > a->size) { newdata = calloc(newsize*a->incr, a->unit); + /* + fprintf(stderr, "!%s: a->data = %p, newdata = %p\n", me, + a->data, newdata); + */ if (!newdata) { free(a->data); _airSetData(a, NULL); return; } - memcpy(newdata, a->data, AIR_MIN(a->len*a->unit, - newsize*a->incr*a->unit)); - free(a->data); + if (a->data) { + memcpy(newdata, a->data, AIR_MIN(a->len*a->unit, + newsize*a->incr*a->unit)); + free(a->data); + } _airSetData(a, newdata); a->size = newsize; } a->noReallocWhenSmaller = AIR_TRUE; } + /* fprintf(stderr, "!%s: returning data %p\n", me, a->data); */ return; } @@ -191,8 +204,8 @@ airArrayLenPreSet(airArray *a, unsigned int newlen) { */ void airArrayLenSet(airArray *a, unsigned int newlen) { - unsigned int newsize; - int ii; + /* char me[]="airArrayLenSet"; */ + unsigned int ii, newsize; void *addr, *newdata; if (!a) { @@ -206,8 +219,10 @@ airArrayLenSet(airArray *a, unsigned int newlen) { } /* call freeCB/doneCB on all the elements which are going bye-bye */ + /* Wed Sep 12 14:40:45 EDT 2007: the order in which these called is + now ascending, instead of descending (as was the way before) */ if (newlen < a->len && (a->freeCB || a->doneCB)) { - for (ii=a->len-1; ii>=(int)newlen; ii--) { + for (ii=newlen; ii<a->len; ii++) { addr = (char*)(a->data) + ii*a->unit; if (a->freeCB) { (a->freeCB)(*((void**)addr)); @@ -248,7 +263,7 @@ airArrayLenSet(airArray *a, unsigned int newlen) { /* call allocCB/initCB on newly created elements */ if (newlen > a->len && (a->allocCB || a->initCB)) { - for (ii=newlen; ii<(int)(a->len); ii++) { + for (ii=a->len; ii<newlen; ii++) { addr = (char*)(a->data) + ii*a->unit; if (a->allocCB) { *((void**)addr) = (a->allocCB)(); @@ -272,9 +287,14 @@ airArrayLenSet(airArray *a, unsigned int newlen) { ** no error, delta > 0: return index of 1st element in newly allocated ** segment (a->len before length was increased) ** no error, delta <= 0: return 0, and a->data unchanged +** +** HEY: it is apparently not clear how to do error checking (aside from +** looking at a->data) when there was NO data previously allocated, and the +** first index of the newly allocated data is zero... */ unsigned int airArrayLenIncr(airArray *a, int delta) { + /* char me[]="airArrayLenIncr"; */ unsigned int oldlen, ret; if (!a) { diff --git a/Utilities/ITK/Utilities/NrrdIO/arraysNrrd.c b/Utilities/ITK/Utilities/NrrdIO/arraysNrrd.c index d9e11585d64b1b7e054f2b4ca0c40299dce6cb29..990a12b2e170b2cb5254af27cc97195a647b0a54 100644 --- a/Utilities/ITK/Utilities/NrrdIO/arraysNrrd.c +++ b/Utilities/ITK/Utilities/NrrdIO/arraysNrrd.c @@ -1,6 +1,6 @@ /* NrrdIO: stand-alone code for basic nrrd functionality - Copyright (C) 2005 Gordon Kindlmann + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah This software is provided 'as-is', without any express or implied diff --git a/Utilities/ITK/Utilities/NrrdIO/axis.c b/Utilities/ITK/Utilities/NrrdIO/axis.c index 3ecefc357383e5f9457db082deb2a6bad5544689..67befcc9a73fe9c5cfd106049ad3f3afeb9c6251 100644 --- a/Utilities/ITK/Utilities/NrrdIO/axis.c +++ b/Utilities/ITK/Utilities/NrrdIO/axis.c @@ -1,6 +1,6 @@ /* NrrdIO: stand-alone code for basic nrrd functionality - Copyright (C) 2005 Gordon Kindlmann + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah This software is provided 'as-is', without any express or implied @@ -81,7 +81,7 @@ nrrdKindIsDomain(int kind) { */ unsigned int nrrdKindSize(int kind) { - char me[]="nrrdKindSize"; + static const char me[]="nrrdKindSize"; int ret; if (!( AIR_IN_OP(nrrdKindUnknown, kind, nrrdKindLast) )) { @@ -172,7 +172,7 @@ _nrrdKindAltered(int kindIn, int resampling) { kindOut = nrrdKindUnknown; /* HEY: setting the kindOut to unknown is arguably not a no-op. It is more like pointedly and stubbornly simplistic. So maybe - nrrdStateKindNoop could be renamed ... */ + nrrdStateKindNoop could be renamed .. */ } else { if (nrrdKindIsDomain(kindIn) || (0 == nrrdKindSize(kindIn) && !resampling)) { @@ -394,7 +394,7 @@ nrrdAxisInfoSet_nva(Nrrd *nrrd, int axInfo, const void *_info) { } /* -******** nrrdAxisInfoSet() +******** nrrdAxisInfoSet_va() ** ** var args front-end for nrrdAxisInfoSet_nva ** @@ -411,7 +411,7 @@ nrrdAxisInfoSet_nva(Nrrd *nrrd, int axInfo, const void *_info) { ** nrrdAxisInfoUnits: char* */ void -nrrdAxisInfoSet(Nrrd *nrrd, int axInfo, ...) { +nrrdAxisInfoSet_va(Nrrd *nrrd, int axInfo, ...) { NRRD_TYPE_BIGGEST *buffer[NRRD_DIM_MAX]; _nrrdAxisInfoSetPtrs info; unsigned int ai, si; @@ -593,7 +593,7 @@ nrrdAxisInfoGet_nva(const Nrrd *nrrd, int axInfo, void *_info) { ** nrrdAxisInfoUnits: char** */ void -nrrdAxisInfoGet(const Nrrd *nrrd, int axInfo, ...) { +nrrdAxisInfoGet_va(const Nrrd *nrrd, int axInfo, ...) { void *buffer[NRRD_DIM_MAX], *ptr; _nrrdAxisInfoGetPtrs info; unsigned int ai, si; @@ -665,7 +665,7 @@ nrrdAxisInfoGet(const Nrrd *nrrd, int axInfo, ...) { ** _nrrdCenter() ** ** for nrrdCenterCell and nrrdCenterNode, return will be the same -** as input. Converts nrrdCenterUnknown into nrrdDefCenter, +** as input. Converts nrrdCenterUnknown into nrrdDefaultCenter, ** and then clamps to (nrrdCenterUnknown+1, nrrdCenterLast-1). ** ** Thus, this ALWAYS returns nrrdCenterNode or nrrdCenterCell @@ -675,7 +675,7 @@ int _nrrdCenter(int center) { center = (nrrdCenterUnknown == center - ? nrrdDefCenter + ? nrrdDefaultCenter : center); center = AIR_CLAMP(nrrdCenterUnknown+1, center, nrrdCenterLast-1); return center; @@ -704,7 +704,7 @@ _nrrdCenter2(int center, int defCenter) { double nrrdAxisInfoPos(const Nrrd *nrrd, unsigned int ax, double idx) { int center; - unsigned int size; + size_t size; double min, max; if (!( nrrd && ax <= nrrd->dim-1 )) { @@ -713,7 +713,7 @@ nrrdAxisInfoPos(const Nrrd *nrrd, unsigned int ax, double idx) { center = _nrrdCenter(nrrd->axis[ax].center); min = nrrd->axis[ax].min; max = nrrd->axis[ax].max; - size = (unsigned int)(nrrd->axis[ax].size); + size = nrrd->axis[ax].size; return NRRD_POS(center, min, max, size, idx); } @@ -730,7 +730,7 @@ nrrdAxisInfoPos(const Nrrd *nrrd, unsigned int ax, double idx) { double nrrdAxisInfoIdx(const Nrrd *nrrd, unsigned int ax, double pos) { int center; - unsigned int size; + size_t size; double min, max; if (!( nrrd && ax <= nrrd->dim-1 )) { @@ -739,7 +739,7 @@ nrrdAxisInfoIdx(const Nrrd *nrrd, unsigned int ax, double pos) { center = _nrrdCenter(nrrd->axis[ax].center); min = nrrd->axis[ax].min; max = nrrd->axis[ax].max; - size = (unsigned int)(nrrd->axis[ax].size); + size = nrrd->axis[ax].size; return NRRD_IDX(center, min, max, size, pos); } @@ -756,7 +756,7 @@ nrrdAxisInfoPosRange(double *loP, double *hiP, const Nrrd *nrrd, unsigned int ax, double loIdx, double hiIdx) { int center, flip = 0; - unsigned size; + size_t size; double min, max, tmp; if (!( loP && hiP && nrrd && ax <= nrrd->dim-1 )) { @@ -766,7 +766,7 @@ nrrdAxisInfoPosRange(double *loP, double *hiP, center = _nrrdCenter(nrrd->axis[ax].center); min = nrrd->axis[ax].min; max = nrrd->axis[ax].max; - size = (unsigned)(nrrd->axis[ax].size); + size = nrrd->axis[ax].size; if (loIdx > hiIdx) { flip = 1; @@ -808,7 +808,7 @@ nrrdAxisInfoIdxRange(double *loP, double *hiP, const Nrrd *nrrd, unsigned int ax, double loPos, double hiPos) { int center, flip = 0; - unsigned size; + size_t size; double min, max, tmp; if (!( loP && hiP && nrrd && ax <= nrrd->dim-1 )) { @@ -818,7 +818,7 @@ nrrdAxisInfoIdxRange(double *loP, double *hiP, center = _nrrdCenter(nrrd->axis[ax].center); min = nrrd->axis[ax].min; max = nrrd->axis[ax].max; - size = (unsigned)(nrrd->axis[ax].size); + size = nrrd->axis[ax].size; if (loPos > hiPos) { flip = 1; @@ -856,8 +856,8 @@ nrrdAxisInfoSpacingSet(Nrrd *nrrd, unsigned int ax) { max = nrrd->axis[ax].max; if (!( AIR_EXISTS(min) && AIR_EXISTS(max) )) { /* there's no actual basis on which to set the spacing information, - but we have to set it something, so here goes ... */ - nrrd->axis[ax].spacing = nrrdDefSpacing; + but we have to set it something, so here goes .. */ + nrrd->axis[ax].spacing = nrrdDefaultSpacing; return; } @@ -888,7 +888,7 @@ nrrdAxisInfoMinMaxSet(Nrrd *nrrd, unsigned int ax, int defCenter) { center = _nrrdCenter2(nrrd->axis[ax].center, defCenter); spacing = nrrd->axis[ax].spacing; if (!AIR_EXISTS(spacing)) - spacing = nrrdDefSpacing; + spacing = nrrdDefaultSpacing; if (nrrdCenterCell == center) { nrrd->axis[ax].min = 0; nrrd->axis[ax].max = spacing*nrrd->axis[ax].size; @@ -903,16 +903,17 @@ nrrdAxisInfoMinMaxSet(Nrrd *nrrd, unsigned int ax, int defCenter) { /* ******** nrrdDomainAxesGet ** -** learns which are the domain (resample-able) axes of an image, in -** other words, the axes which correspond to independent variables. -** The return value is the number of domain axes, and that many values -** are set in the given axisIdx[] array +** Based on the per-axis "kind" field, learns which are the domain +** (resample-able) axes of an image, in other words, the axes which +** correspond to independent variables. The return value is the +** number of domain axes, and that many values are set in the given +** axisIdx[] array ** ** NOTE: this takes a wild guess that an unset (nrrdKindUnknown) kind ** is a domain axis. */ unsigned int -nrrdDomainAxesGet(Nrrd *nrrd, unsigned int axisIdx[NRRD_DIM_MAX]) { +nrrdDomainAxesGet(const Nrrd *nrrd, unsigned int axisIdx[NRRD_DIM_MAX]) { unsigned int domAxi, axi; if (!( nrrd && axisIdx )) { @@ -928,16 +929,52 @@ nrrdDomainAxesGet(Nrrd *nrrd, unsigned int axisIdx[NRRD_DIM_MAX]) { return domAxi; } +int +_nrrdSpaceVecExists(const Nrrd *nrrd, unsigned int axi) { + unsigned int sai; + int ret; + + if (!( nrrd && axi < nrrd->dim && nrrd->spaceDim )) { + ret = AIR_FALSE; + } else { + ret = AIR_TRUE; + for (sai=0; sai<nrrd->spaceDim; sai++) { + ret &= AIR_EXISTS(nrrd->axis[axi].spaceDirection[sai]); + } + } + return ret; +} + +unsigned int +nrrdSpatialAxesGet(const Nrrd *nrrd, unsigned int axisIdx[NRRD_DIM_MAX]) { + unsigned int spcAxi, axi; + + if (!( nrrd && axisIdx && nrrd->spaceDim)) { + return 0; + } + spcAxi = 0; + for (axi=0; axi<nrrd->dim; axi++) { + if (_nrrdSpaceVecExists(nrrd, axi)) { + axisIdx[spcAxi++] = axi; + } + } + return spcAxi; +} + /* ******** nrrdRangeAxesGet ** -** learns which are the range (non-resample-able) axes of an image, in -** other words, the axes which correspond to dependent variables. The -** return value is the number of range axes; that number of values -** are set in the given axisIdx[] array +** Based on the per-axis "kind" field, learns which are the range +** (non-resample-able) axes of an image, in other words, the axes +** which correspond to dependent variables. The return value is the +** number of range axes; that number of values are set in the given +** axisIdx[] array +** +** Note: this really is as simple as returning the complement of the +** axis selected by nrrdDomainAxesGet() */ unsigned int -nrrdRangeAxesGet(Nrrd *nrrd, unsigned int axisIdx[NRRD_DIM_MAX]) { +nrrdRangeAxesGet(const Nrrd *nrrd, unsigned int axisIdx[NRRD_DIM_MAX]) { unsigned int domNum, domIdx[NRRD_DIM_MAX], rngAxi, axi, ii, isDom; if (!( nrrd && axisIdx )) { @@ -957,6 +994,28 @@ nrrdRangeAxesGet(Nrrd *nrrd, unsigned int axisIdx[NRRD_DIM_MAX]) { return rngAxi; } +unsigned int +nrrdNonSpatialAxesGet(const Nrrd *nrrd, unsigned int axisIdx[NRRD_DIM_MAX]) { + unsigned int spcNum, spcIdx[NRRD_DIM_MAX], nspAxi, axi, ii, isSpc; + + if (!( nrrd && axisIdx )) { + return 0; + } + /* HEY: copy and paste, should refactor with above */ + spcNum = nrrdSpatialAxesGet(nrrd, spcIdx); + nspAxi = 0; + for (axi=0; axi<nrrd->dim; axi++) { + isSpc = AIR_FALSE; + for (ii=0; ii<spcNum; ii++) { /* yes, inefficient */ + isSpc |= axi == spcIdx[ii]; + } + if (!isSpc) { + axisIdx[nspAxi++] = axi; + } + } + return nspAxi; +} + /* ******** nrrdSpacingCalculate @@ -1015,7 +1074,7 @@ nrrdSpacingCalculate(const Nrrd *nrrd, unsigned int ax, *spacing = AIR_NAN; } if (vector) { - _nrrdSpaceVecSetNaN(vector); + nrrdSpaceVecSetNaN(vector); } } else { if (AIR_EXISTS(nrrd->axis[ax].spacing)) { @@ -1025,20 +1084,59 @@ nrrdSpacingCalculate(const Nrrd *nrrd, unsigned int ax, ret = nrrdSpacingStatusScalarNoSpace; } *spacing = nrrd->axis[ax].spacing; - _nrrdSpaceVecSetNaN(vector); + nrrdSpaceVecSetNaN(vector); } else { - if (nrrd->spaceDim > 0) { + if (nrrd->spaceDim > 0 && _nrrdSpaceVecExists(nrrd, ax)) { ret = nrrdSpacingStatusDirection; - *spacing = _nrrdSpaceVecNorm(nrrd->spaceDim, - nrrd->axis[ax].spaceDirection); - _nrrdSpaceVecScale(vector, 1.0/(*spacing), - nrrd->axis[ax].spaceDirection); + *spacing = nrrdSpaceVecNorm(nrrd->spaceDim, + nrrd->axis[ax].spaceDirection); + nrrdSpaceVecScale(vector, 1.0/(*spacing), + nrrd->axis[ax].spaceDirection); } else { ret = nrrdSpacingStatusNone; *spacing = AIR_NAN; - _nrrdSpaceVecSetNaN(vector); + nrrdSpaceVecSetNaN(vector); } } } return ret; } + +int +nrrdOrientationReduce(Nrrd *nout, const Nrrd *nin, + int setMinsFromOrigin) { + static const char me[]="nrrdOrientationReduce"; + unsigned int spatialAxisNum, spatialAxisIdx[NRRD_DIM_MAX], saxii; + NrrdAxisInfo *axis; + + if (!(nout && nin)) { + biffAddf(NRRD, "%s: got NULL spacing", me); + return 1; + } + + if (nout != nin) { + if (nrrdCopy(nout, nin)) { + biffAddf(NRRD, "%s: trouble doing initial copying", me); + return 1; + } + } + if (!nout->spaceDim) { + /* we're done! */ + return 0; + } + spatialAxisNum = nrrdSpatialAxesGet(nout, spatialAxisIdx); + for (saxii=0; saxii<spatialAxisNum; saxii++) { + axis = nout->axis + spatialAxisIdx[saxii]; + axis->spacing = nrrdSpaceVecNorm(nout->spaceDim, + axis->spaceDirection); + if (setMinsFromOrigin) { + axis->min = (saxii < nout->spaceDim + ? nout->spaceOrigin[saxii] + : AIR_NAN); + } + } + nrrdSpaceSet(nout, nrrdSpaceUnknown); + + return 0; +} + diff --git a/Utilities/ITK/Utilities/NrrdIO/biff.h b/Utilities/ITK/Utilities/NrrdIO/biff.h new file mode 100644 index 0000000000000000000000000000000000000000..997e1cadf8a5ecdf9c13f8ae2c687d1fce01f086 --- /dev/null +++ b/Utilities/ITK/Utilities/NrrdIO/biff.h @@ -0,0 +1,130 @@ +/* + Teem: Tools to process and visualize scientific data and images + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann + Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License + (LGPL) as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + The terms of redistributing and/or modifying this software also + include exceptions to the LGPL that facilitate static linking. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this library; if not, write to Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef BIFF_HAS_BEEN_INCLUDED +#define BIFF_HAS_BEEN_INCLUDED + +/* ---- BEGIN non-NrrdIO */ + +#include <stdio.h> +#include <string.h> +#include <stdarg.h> + +#include "NrrdIO.h" + +#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(TEEM_STATIC) +# if defined(TEEM_BUILD) || defined(biff_EXPORTS) || defined(teem_EXPORTS) +# define BIFF_EXPORT extern __declspec(dllexport) +# else +# define BIFF_EXPORT extern __declspec(dllimport) +# endif +#else /* TEEM_STATIC || UNIX */ +# define BIFF_EXPORT extern +#endif +/* ---- END non-NrrdIO */ + + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** biffMsg struct +** +** externally usable thing for holding error messages +*/ +typedef struct { + char *key; /* string for identifying the general source + of the error message; set once, at time + of biffMsg creation */ + char **err; /* array of error strings; the err array itself + is NOT null-terminated */ + unsigned int errNum; /* length of "err" == # strings stored */ + airArray *errArr; /* air array for err and num */ +} biffMsg; + +/* biffmsg.c */ +BIFF_EXPORT biffMsg *biffMsgNew(const char *key); +BIFF_EXPORT biffMsg *biffMsgNix(biffMsg *msg); +BIFF_EXPORT void biffMsgAdd(biffMsg *msg, const char *err); +BIFF_EXPORT void biffMsgAddVL(biffMsg *msg, const char *errfmt, va_list args); +BIFF_EXPORT void biffMsgAddf(biffMsg *msg, const char *errfmt, ...) +#ifdef __GNUC__ +__attribute__ ((format(printf,2,3))) +#endif +; +BIFF_EXPORT void biffMsgClear(biffMsg *msg); +BIFF_EXPORT unsigned int biffMsgLineLenMax(const biffMsg *msg); +BIFF_EXPORT void biffMsgMove(biffMsg *dest, biffMsg *src, + const char *err); +BIFF_EXPORT void biffMsgMoveVL(biffMsg *dest, biffMsg *src, + const char *errfmt, va_list args); +BIFF_EXPORT void biffMsgMovef(biffMsg *dest, biffMsg *src, + const char *errfmt, ...) +#ifdef __GNUC__ +__attribute__ ((format(printf,3,4))) +#endif +; +BIFF_EXPORT unsigned int biffMsgStrlen(const biffMsg *msg); +BIFF_EXPORT char *biffMsgStrAlloc(const biffMsg *msg); +BIFF_EXPORT void biffMsgStrSet(char *ret, const biffMsg *msg); +BIFF_EXPORT char *biffMsgStrGet(const biffMsg *msg); +BIFF_EXPORT biffMsg *biffMsgNoop; + +/* biffbiff.c */ +BIFF_EXPORT void biffAdd(const char *key, const char *err); +BIFF_EXPORT void biffAddVL(const char *key, const char *errfmt, va_list args); +BIFF_EXPORT void biffAddf(const char *key, const char *errfmt, ...) +#ifdef __GNUC__ + __attribute__ ((format(printf,2,3))) +#endif +; +BIFF_EXPORT void biffMaybeAdd(const char *key, const char *err, int useBiff); +BIFF_EXPORT void biffMaybeAddf(int useBiff, const char *key, + const char *errfmt, ... ) +#ifdef __GNUC__ +__attribute__ ((format(printf,3,4))) +#endif +; +BIFF_EXPORT char *biffGet(const char *key); +BIFF_EXPORT int biffGetStrlen(const char *key); +BIFF_EXPORT void biffSetStr(char *str, const char *key); +BIFF_EXPORT int biffCheck(const char *key); +BIFF_EXPORT void biffDone(const char *key); +BIFF_EXPORT void biffMove(const char *destKey, const char *err, + const char *srcKey); +BIFF_EXPORT void biffMoveVL(const char *destKey, const char *srcKey, + const char *errfmt, va_list args); +BIFF_EXPORT void biffMovef(const char *destKey, const char *srcKey, + const char *errfmt, ...) +#ifdef __GNUC__ +__attribute__ ((format(printf,3,4))) +#endif +; +BIFF_EXPORT char *biffGetDone(const char *key); +BIFF_EXPORT void biffSetStrDone(char *str, const char *key); + +#ifdef __cplusplus +} +#endif + +#endif /* BIFF_HAS_BEEN_INCLUDED */ diff --git a/Utilities/ITK/Utilities/NrrdIO/biffbiff.c b/Utilities/ITK/Utilities/NrrdIO/biffbiff.c index dbeeb91ffb1e53eced40a68ffa449c9a5852cd70..9799b491125d7d50d304a23fa775052f737aaa1f 100644 --- a/Utilities/ITK/Utilities/NrrdIO/biffbiff.c +++ b/Utilities/ITK/Utilities/NrrdIO/biffbiff.c @@ -1,6 +1,6 @@ /* NrrdIO: stand-alone code for basic nrrd functionality - Copyright (C) 2005 Gordon Kindlmann + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah This software is provided 'as-is', without any express or implied @@ -22,300 +22,206 @@ 3. This notice may not be removed or altered from any source distribution. */ - #include "NrrdIO.h" -/* -** This is mostly garbage. -** It needs to be re-written. -** I apologize. -*/ - -/* -** _biffEntry struct -** -** hold information and messages associated with one key -*/ -typedef struct { - char key[BIFF_MAXKEYLEN+1]; /* the key */ - char **err; /* array of error strings; the err array itself - is NOT null-terminated */ - unsigned int num; /* length of "err" == # strings stored */ - airArray *AA; /* air array for err and num */ -} _biffEntry; - -_biffEntry **_biffErr=NULL; /* master array of _biffEntry pointers */ -unsigned int _biffNum=0; /* length of _biffErr == # keys maintained */ -int _biffIdx=-1; /* hack: index of latest key found */ -airArray *_biffAA=NULL; /* air array of _biffErr and _biffNum */ +static biffMsg ** +_bmsg=NULL; /* master array of biffMsg pointers */ +static unsigned int +_bmsgNum=0; /* length of _biffErr == # keys maintained */ +static airArray * +_bmsgArr=NULL; /* air array of _biffErr and _biffNum */ -#define _BIFF_INCR 2 +#define __INCR 2 typedef union { - _biffEntry ***b; + biffMsg ***b; void **v; } _beu; /* -** _biffInit() +** _bmsgStart() ** ** allocates data structers needed by biff. Panics and exit(1)s if -** anything goes wrong. Can be harmlessly called multiple times. +** anything goes wrong. +** +** NOTE: Can be harmlessly called multiple times. */ void -_biffInit(void) { - char me[]="_biffInit"; +_bmsgStart(void) { + static const char me[]="[biff] _bmsgStart"; _beu uu; - uu.b = &_biffErr; - if (!_biffAA) { - _biffAA = airArrayNew(uu.v, &_biffNum, sizeof(_biffEntry*), _BIFF_INCR); - if (!_biffAA) { - fprintf(stderr, "%s: PANIC: couldn't allocate internal data\n", me); - exit(1); - } + if (_bmsgArr) { + /* its non-NULL, must have been called already */ + return; } + uu.b = &_bmsg; + _bmsgArr = airArrayNew(uu.v, &_bmsgNum, sizeof(biffMsg*), __INCR); + if (!_bmsgArr) { + fprintf(stderr, "%s: PANIC: couldn't allocate internal data\n", me); + exit(1); + } + /* airArrayPointerCB(_bmsgArr, NULL, biffMsgNix); */ + /* HEY: not using any pointer callbacks here? */ return; } void -_biffNuke(void) { +_bmsgFinish(void) { - if (_biffAA) { - /* setting to NULL is needed to put biff back in initial state - so that next calls to biff re-trigger _biffInit() */ - _biffAA = airArrayNuke(_biffAA); + if (_bmsgArr) { + /* setting _bmsgArr to NULL is needed to put biff back in initial state + so that next calls to biff re-trigger _bmsgStart() */ + _bmsgArr = airArrayNuke(_bmsgArr); } return; } /* -** _biffCheckKey() +** _bmsgFind() ** -** makes sure given key is kosher. Panics and exit(1)s if given a NULL key -** or if key is too long +** returns the biffMsg (in _bmsg) of the entry with the given key, or +** NULL if it was not found */ -void -_biffCheckKey(const char *key) { - char me[] = "_biffCheckKey"; +biffMsg * +_bmsgFind(const char *key) { + static const char me[]="[biff] _bmsgFind"; + biffMsg *msg; + unsigned int ii; if (!key) { - fprintf(stderr, "%s: PANIC: given NULL key\n", me); + fprintf(stderr, "%s: PANIC got NULL key", me); exit(1); } - if (strlen(key) > BIFF_MAXKEYLEN) { - fprintf(stderr, "%s: PANIC: key \"%s\" exceeds %d chars\n", - me, key, BIFF_MAXKEYLEN); - exit(1); + msg = NULL; + if (_bmsgNum) { + for (ii=0; ii<_bmsgNum; ii++) { + if (!strcmp(_bmsg[ii]->key, key)) { + msg = _bmsg[ii]; + break; + } + } } - return; + return msg; } /* -** _biffFindKey() -** -** returns a pointer to the entry which contains the given key, or -** NULL if it was not found +** assumes that msg really is in _bmsg[] */ -_biffEntry * -_biffFindKey(const char *key) { - int ii=-1; - _biffEntry *ent; - - if (_biffNum) { - for (ii=0; ii<(int)_biffNum; ii++) { - /* printf("HEY: comparing key[%d]=\"%s\" to \"%s\"\n", - ii, _biffErr[i]->key, key); */ - if (!strcmp(_biffErr[ii]->key, key)) { - break; - } - } - if (ii == (int)_biffNum) { - ii = -1; +unsigned int +_bmsgFindIdx(biffMsg *msg) { + unsigned int ii; + + for (ii=0; ii<_bmsgNum; ii++) { + if (msg == _bmsg[ii]) { + break; } } - /* printf("HEY: index(\"%s\") = %d\n", key, ii); */ - if (-1 == ii) { - ent = NULL; - _biffIdx = -1; - } - else { - ent = _biffErr[ii]; - _biffIdx = ii; - } - return ent; + return ii; } /* -** _biffNewEntry() +** _bmsgAdd() ** -** creates and initializes one new _biffEntry, returning a pointer to it -** panics and exit(1)s if there is a problem. +** if given key already has a biffMsg in _bmsg, returns that. +** otherise, adds a new biffMsg for given key to _bmsg, and returns it +** panics and exit(1)s if there is a problem */ -_biffEntry * -_biffNewEntry(const char *key) { - char me[]="_biffInitEntry"; - _biffEntry *ent; - - ent = (_biffEntry *)calloc(1, sizeof(_biffEntry)); - if (!ent) { - fprintf(stderr, "%s: couldn't make entry for new key \"%s\"\n", me, key); - exit(1); +biffMsg * +_bmsgAdd(const char *key) { + static const char me[]="[biff] _bmsgAdd"; + unsigned int ii; + biffMsg *msg; + + msg = NULL; + /* find if key exists already */ + for (ii=0; ii<_bmsgNum; ii++) { + if (!strcmp(key, _bmsg[ii]->key)) { + msg = _bmsg[ii]; + break; + } } - strcpy(ent->key, key); - ent->AA = airArrayNew((void**)&(ent->err), - &(ent->num), sizeof(char*), _BIFF_INCR); - if (!ent->AA) { - fprintf(stderr, "%s: couldn't make array for new key \"%s\"\n", me, key); - exit(1); + if (!msg) { + /* have to add new biffMsg */ + ii = airArrayLenIncr(_bmsgArr, 1); + if (!_bmsg) { + fprintf(stderr, "%s: PANIC: couldn't accomodate one more key\n", me); + exit(1); + } + msg = _bmsg[ii] = biffMsgNew(key); } - airArrayPointerCB(ent->AA, NULL, airFree); - return ent; + return msg; } +/***********************************************************************/ +/***********************************************************************/ + /* -** _biffNukeEntry() +******** biffAdd() ** -** deletes given entry, and all info contained therein +** Adds string "err" at key "key", whether or not there are any +** existing messages there. Since biffSet() was killed +** Wed Apr 20 11:11:51 EDT 2005, this has become the main biff +** function. */ void -_biffNukeEntry(_biffEntry *ent) { +biffAdd(const char *key, const char *err) { + biffMsg *msg; - if (ent) { - airArrayLenSet(ent->AA, 0); - airArrayNuke(ent->AA); - free(ent); - } + _bmsgStart(); + msg = _bmsgAdd(key); + biffMsgAdd(msg, err); return; } -/* -** _biffAddKey() -** -** adds a key to _biffErr, and returns a pointer to the new entry -** assumes that given key does NOT appear in current list. -** panics and exit(1)s if there is a problem -*/ -_biffEntry * -_biffAddKey(const char *key) { - char me[]="_biffAddKey"; - int ii, newIdx; - _biffEntry *ent; - - /* find index of new key */ - for (ii=0; ii<(int)_biffNum; ii++) { - if (strcmp(key, _biffErr[ii]->key) < 0) { - /* we've hit the one which comes after the new key */ - break; - } - } - /* if the for loop was never broken, _biffNum is the correct new index */ - newIdx = ii; - /* printf("HEY: index(new key \"%s\") = %d\n", key, ii); */ - - airArrayLenIncr(_biffAA, 1); - if (!_biffAA->data) { - fprintf(stderr, "%s: PANIC: couldn't accomodate one more key\n", me); - exit(1); - } - - /* _biffNum is now one bigger */ - for (ii=_biffNum-2; ii>=newIdx; ii--) { - _biffErr[ii+1] = _biffErr[ii]; - } - ent = _biffErr[newIdx] = _biffNewEntry(key); +void +biffAddVL(const char *key, const char *errfmt, va_list args) { + biffMsg *msg; - return ent; + _bmsgStart(); + msg = _bmsgAdd(key); + biffMsgAddVL(msg, errfmt, args); + return; } /* -** _biffAddErr() +******** biffAddf() ** -** adds a given message to the given entry. The message is processed to -** convert all whitespace into ' ', and to eliminate whitespace at the -** end of the message. -** panics and exit(1)s if there is a problem +** Adds string "err" at key "key", whether or not there are any +** existing messages there. This version accepts a printf style +** format string as input. */ void -_biffAddErr(_biffEntry *e, const char *err) { - char *buf, me[]="_biffAddErr"; - int ii; - size_t len; - - /* printf("%s: HEY(before): err[%s]->num = %d\n", me, e->key, e->num); */ - airArrayLenIncr(e->AA, 1); - if (!e->AA->data) { - fprintf(stderr, "%s: PANIC: couldn't add message for key %s\n", - me, e->key); - exit(1); - } - /* printf("%s: HEY(after): err[%s]->num = %d\n", me, e->key, e->num); */ - buf = airStrdup(err); - len = strlen(buf); - for (ii=0; ii<=((int)len)-1; ii++) { - if (isspace((int) buf[ii])) { - buf[ii] = ' '; - } - } - ii = (int)(len)-1; - while (isspace((int) buf[ii])) { - buf[ii--] = 0; - } - /* printf("%s: HEY(after): err[%s]->num = %d\n", me, e->key, e->num); */ - /* printf("%s: HEY: err[%s][%d] now \"%s\"\n", me, e->key, e->num-1, buf); */ - e->err[e->num-1] = buf; - return; -} - -void -_biffFindMaxAndSum(unsigned int *maxP, unsigned int *sumP, _biffEntry *ent) { - unsigned int ii, len; - - if (!ent->num) { - /* there's a key, but no error messages. Odd. */ - *maxP = 1; - *sumP = 1; - return; - } +biffAddf(const char *key, const char *errfmt, ...) { + va_list args; - *maxP = *sumP = 0; - for (ii=0; ii<ent->num; ii++) { - len = (unsigned int)(strlen(ent->err[ii]) + strlen(ent->key) + strlen("[] \n")); - *sumP += len; - *maxP = AIR_MAX(*maxP, len); - } - *sumP += 1; - *maxP += 1; + va_start(args, errfmt); + biffAddVL(key, errfmt, args); + va_end(args); return; } -/***********************************************************************/ -/***********************************************************************/ - +#if 0 /* -******** biffAdd() +******** biffAddf_e ** -** Adds string "err" at key "key", whether or not there are any -** existing messages there. Since biffSet() was killed -** Wed Apr 20 11:11:51 EDT 2005, this has become the main biff -** function. +** calls (eventually) biffMsgAdd if msg is non-NULL, otherwise calls +** biffAdd if msg is NULL. */ void -biffAdd(const char *key, const char *err) { - _biffEntry *ent; +biffAddf_e(biffMsg *msg, const char *key, const char *errfmt, ...) { + va_list args; - _biffInit(); - _biffCheckKey(key); - - ent = _biffFindKey(key); - if (!ent) { - ent = _biffAddKey(key); + va_start(args, errfmt); + if (msg) { + biffMsgAddVL(msg, errfmt, args); + } else { + biffAddVL(key, errfmt, args); } - - /* add the new message */ - _biffAddErr(ent, err); + va_end(args); return; } +#endif /* ******** biffMaybeAdd() @@ -332,17 +238,14 @@ biffMaybeAdd(const char *key, const char *err, int useBiff) { } void -_biffGetStr(char *ret, char *buf, _biffEntry *ent) { - int ii; - - if (!ent->num) { - /* there's a key, but no error messages. Odd. */ - strcpy(ret, ""); - } - for (ii=ent->num-1; ii>=0; ii--) { - sprintf(buf, "[%s] %s\n", ent->key, ent->err[ii]); - strcat(ret, buf); +biffMaybeAddf(int useBiff, const char *key, const char *errfmt, ...) { + va_list args; + + va_start(args, errfmt); + if (useBiff) { + biffAddVL(key, errfmt, args); } + va_end(args); return; } @@ -352,33 +255,40 @@ _biffGetStr(char *ret, char *buf, _biffEntry *ent) { ** creates a string which records all the errors at given key and ** returns it. Returns NULL in case of error. This function should ** be considered a glorified strdup(): it is the callers responsibility -** to free this string later +** to free() this string later */ char * biffGet(const char *key) { - unsigned int max, sum; - char me[] = "biffGet", *ret, *buf; - _biffEntry *ent; - - _biffInit(); - _biffCheckKey(key); - ent = _biffFindKey(key); - if (!ent) { - /* error: not a key we remember seeing */ + static const char me[]="biffGet"; + char *ret; + biffMsg *msg; + + _bmsgStart(); + msg = _bmsgFind(key); + if (!msg) { + static const char err[]="[%s] No information for this key!"; + size_t errlen; fprintf(stderr, "%s: WARNING: no information for key \"%s\"\n", me, key); - return NULL; + errlen = strlen(err)+strlen(key)+1; + ret = AIR_CALLOC(errlen, char); + if (!ret) { + fprintf(stderr, "%s: PANIC: unable to allocate buffer\n", me); + exit(1); + } +#if defined(WIN32) || defined(_WIN32) + _snprintf(ret, errlen, err, key); +#else + snprintf(ret, errlen, err, key); +#endif + return ret; } - _biffFindMaxAndSum(&max, &sum, ent); - buf = (char*)calloc(max, sizeof(char)); - ret = (char*)calloc(sum, sizeof(char)); - if (!(buf && ret)) { - fprintf(stderr, "%s: PANIC: unable to allocate buffers\n", me); + ret = AIR_CALLOC(biffMsgStrlen(msg)+1, char); + if (!ret) { + fprintf(stderr, "%s: PANIC: unable to allocate buffer\n", me); exit(1); } - _biffGetStr(ret, buf, ent); - free(buf); - + biffMsgStrSet(ret, msg); return ret; } @@ -390,21 +300,20 @@ biffGet(const char *key) { */ int biffGetStrlen(const char *key) { - unsigned int max, sum; - char me[] = "biffGetStrlen"; - _biffEntry *ent; - - _biffInit(); - _biffCheckKey(key); - ent = _biffFindKey(key); - if (!ent) { - /* error: not a key we remember seeing */ + static const char me[]="biffGetStrlen"; + biffMsg *msg; + unsigned int len; + + _bmsgStart(); + msg = _bmsgFind(key); + if (!msg) { fprintf(stderr, "%s: WARNING: no information for key \"%s\"\n", me, key); return 0; } - - _biffFindMaxAndSum(&max, &sum, ent); - return sum; + len = biffMsgStrlen(msg); + len += 1; /* GLK forgets if the convention is that the caller allocates + for one more to include '\0'; this is safer */ + return len; } /* @@ -415,32 +324,21 @@ biffGetStrlen(const char *key) { */ void biffSetStr(char *str, const char *key) { - unsigned int max, sum; - char me[] = "biffSetStr", *buf; - _biffEntry *ent; + static const char me[]="biffSetStr"; + biffMsg *msg; if (!str) { - fprintf(stderr, "%s: ERROR: got NULL buffer \"%s\"\n", me, key); + fprintf(stderr, "%s: ERROR: got NULL buffer for \"%s\"\n", me, key); return; } - _biffInit(); - _biffCheckKey(key); - ent = _biffFindKey(key); - if (!ent) { - /* error: not a key we remember seeing */ + _bmsgStart(); + msg = _bmsgFind(key); + if (!msg) { fprintf(stderr, "%s: WARNING: no information for key \"%s\"\n", me, key); return; } - - _biffFindMaxAndSum(&max, &sum, ent); - buf = (char*)calloc(max, sizeof(char)); - if (!buf) { - fprintf(stderr, "%s: PANIC: unable to allocate buffer\n", me); - exit(1); - } - _biffGetStr(str, buf, ent); - free(buf); + biffMsgStrSet(str, msg); return; } @@ -453,99 +351,93 @@ biffSetStr(char *str, const char *key) { */ int biffCheck(const char *key) { - _biffEntry *ent; + biffMsg *msg; - _biffInit(); - _biffCheckKey(key); - - ent = _biffFindKey(key); - if (!ent) { + _bmsgStart(); + msg = _bmsgFind(key); + if (!msg) { return 0; } - return ent->num; + return msg->errNum; } /* ******** biffDone() ** -** frees everything associated with given key, and shrinks list of keys +** frees everything associated with given key, and shrinks list of keys, +** and calls _bmsgFinish() if there are no keys left */ void biffDone(const char *key) { - char me[]="biffDone"; - int i, idx; - _biffEntry *ent; + static const char me[]="biffDone"; + unsigned int idx; + biffMsg *msg; - _biffInit(); - _biffCheckKey(key); - - ent = _biffFindKey(key); - if (!ent) { + _bmsgStart(); + + msg = _bmsgFind(key); + if (!msg) { fprintf(stderr, "%s: WARNING: no information for key \"%s\"\n", me, key); return; } - idx = _biffIdx; - - _biffNukeEntry(ent); - for (i=idx; i<(int)_biffNum-1; i++) { - _biffErr[i] = _biffErr[i+1]; + idx = _bmsgFindIdx(msg); + biffMsgNix(msg); + if (_bmsgNum > 1) { + /* if we have more than one key in action, move the last biffMsg + to the position that was just cleared up */ + _bmsg[idx] = _bmsg[_bmsgNum-1]; + } + airArrayLenIncr(_bmsgArr, -1); + /* if that was the last key, close shop */ + if (!_bmsgArr->len) { + _bmsgFinish(); } - airArrayLenIncr(_biffAA, -1); return; } void biffMove(const char *destKey, const char *err, const char *srcKey) { - unsigned int ii; - size_t len; // to match signature of strlen() on 64 bits - size_t max; - char me[] = "biffMove", *buf; - _biffEntry *dest, *src; - - _biffInit(); - _biffCheckKey(destKey); - _biffCheckKey(srcKey); - - /* if srcKey and destKey are the same, this degenerates to biffAdd() */ - if (!strcmp(destKey, srcKey)) { - biffAdd(srcKey, err); - return; - } + static const char me[]="biffMove"; + biffMsg *dest, *src; - dest = _biffFindKey(destKey); - if (!dest) { - dest = _biffAddKey(destKey); - } - src = _biffFindKey(srcKey); + _bmsgStart(); + dest = _bmsgAdd(destKey); + src = _bmsgFind(srcKey); if (!src) { fprintf(stderr, "%s: WARNING: key \"%s\" unknown\n", me, srcKey); return; } + biffMsgMove(dest, src, err); + return; +} - max = 0; - for (ii=0; ii<src->num; ii++) { - len = strlen(src->err[ii]) + strlen(src->key) + 4; - max = AIR_MAX(max, len); - } - buf = (char*)calloc(max+1, sizeof(char)); - if (!buf) { - fprintf(stderr, "%s: PANIC: can't allocate buffer\n", me); - exit(1); +void +biffMoveVL(const char *destKey, const char *srcKey, + const char *errfmt, va_list args) { + static const char me[]="biffMovev"; + biffMsg *dest, *src; + + _bmsgStart(); + dest = _bmsgAdd(destKey); + src = _bmsgFind(srcKey); + if (!src) { + fprintf(stderr, "%s: WARNING: key \"%s\" unknown\n", me, srcKey); + return; } + biffMsgMoveVL(dest, src, errfmt, args); + return; +} - for (ii=0; ii<src->num; ii++) { - sprintf(buf, "[%s] %s", srcKey, src->err[ii]); - /* printf("%s: HEY: moving \"%s\" to %s\n", me, buf, destKey); */ - _biffAddErr(dest, buf); - } - if (err) { - _biffAddErr(dest, err); - } - biffDone(srcKey); - free(buf); +void +biffMovef(const char *destKey, const char *srcKey, + const char *errfmt, ...) { + va_list args; + va_start(args, errfmt); + biffMoveVL(destKey, srcKey, errfmt, args); + va_end(args); return; } @@ -553,12 +445,10 @@ char * biffGetDone(const char *key) { char *ret; - _biffInit(); - _biffCheckKey(key); + _bmsgStart(); ret = biffGet(key); - biffDone(key); - _biffNuke(); + biffDone(key); /* will call _bmsgFinish if this is the last key */ return ret; } @@ -566,12 +456,10 @@ biffGetDone(const char *key) { void biffSetStrDone(char *str, const char *key) { - _biffInit(); - _biffCheckKey(key); + _bmsgStart(); biffSetStr(str, key); - biffDone(key); - _biffNuke(); + biffDone(key); /* will call _bmsgFinish if this is the last key */ return; } diff --git a/Utilities/ITK/Utilities/NrrdIO/biffmsg.c b/Utilities/ITK/Utilities/NrrdIO/biffmsg.c new file mode 100644 index 0000000000000000000000000000000000000000..b481e662a755c8699329029d85ea89a367b87b46 --- /dev/null +++ b/Utilities/ITK/Utilities/NrrdIO/biffmsg.c @@ -0,0 +1,312 @@ +/* + NrrdIO: stand-alone code for basic nrrd functionality + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann + Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any + damages arising from the use of this software. + + Permission is granted to anyone to use this software for any + purpose, including commercial applications, and to alter it and + redistribute it freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product + documentation would be appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must + not be misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "NrrdIO.h" + +/* +** with the Nov'09 re-write of biff, this sourcefile becomes the only +** place where a static buffer is used for message handling; this +** should eventually be avoided by using things like asprintf and +** vasprintf which allocated the string as needed +*/ +#define _HACK_STRLEN AIR_STRLEN_HUGE +#define _MSG_INCR 2 + +biffMsg * +biffMsgNew(const char *key) { + static const char me[]="biffMsgNew"; + biffMsg *msg; + + if (!key) { + fprintf(stderr, "%s: PANIC got NULL key\n", me); + exit(1); + } + msg = AIR_CALLOC(1, biffMsg); + if (msg) { + msg->key = airStrdup(key); + msg->err = NULL; + msg->errNum = 0; + msg->errArr = airArrayNew(AIR_CAST(void**, &(msg->err)), + &(msg->errNum), sizeof(char*), _MSG_INCR); + if (msg->errArr) { + airArrayPointerCB(msg->errArr, NULL, airFree); + } + } + if (!( msg && msg->key && msg->errArr )) { + fprintf(stderr, "%s: PANIC couldn't calloc new msg\n", me); + exit(1); + } + return msg; +} + +biffMsg * +biffMsgNix(biffMsg *msg) { + + if (msg && msg != biffMsgNoop) { + airFree(msg->key); + airArrayLenSet(msg->errArr, 0); /* frees all msg->err[i] */ + airArrayNuke(msg->errArr); + airFree(msg); + } + return NULL; +} + +/* +** adds a given message to the given entry. The message is processed to +** convert all whitespace into ' ', and to eliminate whitespace at the +** end of the message. +*/ +void +biffMsgAdd(biffMsg *msg, const char *err) { + static const char me[]="biffMsgAdd"; + unsigned int idx; + + if (biffMsgNoop == msg) { + return; + } + if (!( msg && err )) { + fprintf(stderr, "%s: PANIC got NULL msg (%p) or err (%p)\n", me, msg, err); + exit(1); + } + idx = airArrayLenIncr(msg->errArr, 1); + if (!msg->err) { + fprintf(stderr, "%s: PANIC: couldn't add message to %s\n", me, msg->key); + exit(1); + } + if (!( msg->err[idx] = airOneLinify(airStrdup(err)) )) { + fprintf(stderr, "%s: PANIC: couldn't alloc message to %s\n", me, msg->key); + exit(1); + } + return; +} + +void +biffMsgAddVL(biffMsg *msg, const char *errfmt, va_list args) { + char errstr[_HACK_STRLEN]; + + vsprintf(errstr, errfmt, args); + biffMsgAdd(msg, errstr); + return; +} + +void +biffMsgAddf(biffMsg *msg, const char *errfmt, ...) { + va_list args; + + va_start(args, errfmt); + biffMsgAddVL(msg, errfmt, args); + va_end(args); + return; +} + +void +biffMsgClear(biffMsg *msg) { + + if (biffMsgNoop == msg) { + return; + } + airArrayLenSet(msg->errArr, 0); /* frees all msg->err[i] */ + /* but msg->key stays allocated */ + return; +} + +/* +** max length of line formatted "[<key>] <err>\n" +*/ +unsigned int +biffMsgLineLenMax(const biffMsg *msg) { + unsigned int ii, len, maxlen; + + if (biffMsgNoop == msg) { + return 0; + } + maxlen = 0; + for (ii=0; ii<msg->errNum; ii++) { + len = AIR_CAST(unsigned int, strlen(msg->err[ii]) + strlen(msg->key) + strlen("[] \n")); + maxlen = AIR_MAX(maxlen, len); + } + return maxlen; +} + +/* +******** biffMsgMove +** +** "src" is not const because we clear it after moving things out +*/ +void +biffMsgMove(biffMsg *dest, biffMsg *src, const char *err) { + static const char me[]="biffMsgMove"; + unsigned int ii; + char *buff; + + if (biffMsgNoop == dest || biffMsgNoop == src) { + return; + } + if (!( dest && src )) { + fprintf(stderr, "%s: PANIC got NULL msg (%p %p)\n", me, dest, src); + exit(1); + } + /* if src and dest are same, this degenerates to biffMsgAdd */ + if (dest == src && airStrlen(err)) { + biffMsgAdd(dest, err); + return; + } + + buff = AIR_CALLOC(biffMsgLineLenMax(src)+1, char); + if (!buff) { + fprintf(stderr, "%s: PANIC: can't allocate buffer\n", me); + exit(1); + } + for (ii=0; ii<src->errNum; ii++) { + sprintf(buff, "[%s] %s", src->key, src->err[ii]); + biffMsgAdd(dest, buff); + } + free(buff); + biffMsgClear(src); + if (airStrlen(err)) { + biffMsgAdd(dest, err); + } + return; +} + +void +biffMsgMoveVL(biffMsg *dest, biffMsg *src, + const char *errfmt, va_list args) { + char errstr[_HACK_STRLEN]; + + vsprintf(errstr, errfmt, args); + biffMsgMove(dest, src, errstr); + return; +} + +void +biffMsgMovef(biffMsg *dest, biffMsg *src, const char *errfmt, ...) { + va_list args; + + va_start(args, errfmt); + biffMsgMoveVL(dest, src, errfmt, args); + va_end(args); + return; +} + +/* +******** biffMsgStrlen +** +** returns length of string (not including null termination, as usual) +** of the error message that will be generated by biffMsgStrSet +*/ +unsigned int +biffMsgStrlen(const biffMsg *msg) { + static const char me[]="biffMsgStrlen"; + unsigned int ii, len; + + if (biffMsgNoop == msg) { + return 0; + } + if (!( msg )) { + fprintf(stderr, "%s: PANIC got NULL msg %p\n", me, msg); + exit(1); + } + + len = 0; + for (ii=0; ii<msg->errNum; ii++) { + len += AIR_CAST(unsigned int, strlen(msg->key) + strlen(msg->err[ii]) + strlen("[] \n")); + } + return len+1; +} + +char * +biffMsgStrAlloc(const biffMsg *msg) { + static const char me[]="biffMsgStrAlloc"; + char *ret; + unsigned int len; + + if (biffMsgNoop == msg) { + return NULL; + } + len = biffMsgStrlen(msg); + ret = AIR_CALLOC(len+1, char); + if (!ret) { + fprintf(stderr, "%s: PANIC couldn't alloc string", me); + exit(1); + } + return ret; +} + +/* +** ret is assumed to be allocated for biffMsgStrlen()+1, or is the +** the return from biffMsgStrAlloc +*/ +void +biffMsgStrSet(char *ret, const biffMsg *msg) { + static const char me[]="biffMsgStrSet"; + char *buff; + unsigned int ii; + + if (biffMsgNoop == msg) { + return; + } + buff = AIR_CALLOC(biffMsgLineLenMax(msg)+1, char); + if (!buff) { + fprintf(stderr, "%s: PANIC couldn't alloc buffer", me); + exit(1); + } + strcpy(ret, ""); + for (ii=msg->errNum; ii>0; ii--) { + sprintf(buff, "[%s] %s\n", msg->key, msg->err[ii-1]); + strcat(ret, buff); + } + free(buff); +} + +char * +biffMsgStrGet(const biffMsg *msg) { + char *ret; + + if (biffMsgNoop == msg) { + return NULL; + } + ret = biffMsgStrAlloc(msg); + biffMsgStrSet(ret, msg); + return ret; +} + +biffMsg +_biffMsgNoop = { + NULL, + NULL, + 0, + NULL +}; + +/* +******** biffMsgNoop +** +** pass this instead of a real biffMsg (allocated by biffMsgNew) as a +** flag to say, "don't bother, really". This turns all the biffMsg +** functions into no-ops (except that var-args are still consumed +** where they are used) +*/ +biffMsg * +biffMsgNoop = &_biffMsgNoop; diff --git a/Utilities/ITK/Utilities/NrrdIO/comment.c b/Utilities/ITK/Utilities/NrrdIO/comment.c index e71c6d8bc6dbd5f037f24168dad52fe9c78aebc9..53ea3e9a78ca95abcbc24c2b82c90ac4732083b1 100644 --- a/Utilities/ITK/Utilities/NrrdIO/comment.c +++ b/Utilities/ITK/Utilities/NrrdIO/comment.c @@ -1,6 +1,6 @@ /* NrrdIO: stand-alone code for basic nrrd functionality - Copyright (C) 2005 Gordon Kindlmann + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah This software is provided 'as-is', without any express or implied @@ -35,7 +35,8 @@ */ int nrrdCommentAdd(Nrrd *nrrd, const char *_str) { - char /* me[]="nrrdCommentAdd", err[512], */ *str; + /* static const char me[]="nrrdCommentAdd";*/ + char *str; int i; if (!(nrrd && _str)) { @@ -100,7 +101,7 @@ nrrdCommentClear(Nrrd *nrrd) { */ int nrrdCommentCopy(Nrrd *nout, const Nrrd *nin) { - /* char me[]="nrrdCommentCopy", err[512]; */ + /* static const char me[]="nrrdCommentCopy"; */ int numc, i, E; if (!(nout && nin)) { diff --git a/Utilities/ITK/Utilities/NrrdIO/defaultsNrrd.c b/Utilities/ITK/Utilities/NrrdIO/defaultsNrrd.c index f78a307d14d93a1e56a2539d8f136f2457f90fee..c13172bd1390b04d67db7300ddc4088d9aed5037 100644 --- a/Utilities/ITK/Utilities/NrrdIO/defaultsNrrd.c +++ b/Utilities/ITK/Utilities/NrrdIO/defaultsNrrd.c @@ -1,6 +1,6 @@ /* NrrdIO: stand-alone code for basic nrrd functionality - Copyright (C) 2005 Gordon Kindlmann + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah This software is provided 'as-is', without any express or implied @@ -35,27 +35,28 @@ ** What IS a "default"? A default is the assertion of a certain ** choice in situations where the user hasn't set it explicitly, but ** COULD. The pad value in resampling is a good example: it is set by -** a constructor to nrrdDefRsmpPadValue, but the user can also set it +** a constructor to nrrdDefaultResamplePadValue, but the user can also set it ** explicitly. */ -const NrrdEncoding *nrrdDefWriteEncoding = &_nrrdEncodingRaw; -int nrrdDefWriteBareText = AIR_TRUE; -int nrrdDefWriteCharsPerLine = 75; -int nrrdDefWriteValsPerLine = 8; -int nrrdDefCenter = nrrdCenterCell; -double nrrdDefSpacing = 1.0; +int nrrdDefaultWriteEncodingType = nrrdEncodingTypeRaw; +int nrrdDefaultWriteBareText = AIR_TRUE; +unsigned int nrrdDefaultWriteCharsPerLine = 75; +unsigned int nrrdDefaultWriteValsPerLine = 8; +int nrrdDefaultCenter = nrrdCenterCell; +double nrrdDefaultSpacing = 1.0; /* these aren't really "defaults" because there's no other channel for specifying this information. It is just global state. Obviously, like defaults, they are not thread-safe if different threads ever set them differently. */ int nrrdStateVerboseIO = 0; +int nrrdStateKeyValuePairsPropagate = AIR_FALSE; int nrrdStateAlwaysSetContent = AIR_TRUE; int nrrdStateDisableContent = AIR_FALSE; char *nrrdStateUnknownContent = NRRD_UNKNOWN; int nrrdStateGrayscaleImage3D = AIR_FALSE; -/* there is no sane reason to change this default initialization */ +/* there is no sane reason to change this initialization */ int nrrdStateKeyValueReturnInternalPointers = AIR_FALSE; /* Making the default for this be AIR_TRUE means that nrrd is not only completely conservative about updating kind, but purposely stupid. diff --git a/Utilities/ITK/Utilities/NrrdIO/dio.c b/Utilities/ITK/Utilities/NrrdIO/dio.c index 1d530759359cf98ce0a1a07b73456c22224155d2..6f522ca34a84083ac0e1eff9dd18607d26f587e7 100644 --- a/Utilities/ITK/Utilities/NrrdIO/dio.c +++ b/Utilities/ITK/Utilities/NrrdIO/dio.c @@ -1,6 +1,6 @@ /* NrrdIO: stand-alone code for basic nrrd functionality - Copyright (C) 2005 Gordon Kindlmann + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah This software is provided 'as-is', without any express or implied @@ -22,7 +22,6 @@ 3. This notice may not be removed or altered from any source distribution. */ - #include "NrrdIO.h" #include "teemDio.h" diff --git a/Utilities/ITK/Utilities/NrrdIO/encoding.c b/Utilities/ITK/Utilities/NrrdIO/encoding.c index a6ad768f5aa8918bf6efd8c2c21f72a6fe709047..ee898cc347b51df7d36e015f1ddb2a917a2a7315 100644 --- a/Utilities/ITK/Utilities/NrrdIO/encoding.c +++ b/Utilities/ITK/Utilities/NrrdIO/encoding.c @@ -1,6 +1,6 @@ /* NrrdIO: stand-alone code for basic nrrd functionality - Copyright (C) 2005 Gordon Kindlmann + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah This software is provided 'as-is', without any express or implied @@ -37,7 +37,7 @@ ** or vice versa. ** -- respect nrrdStateVerboseIO with messages to stderr, if possible ** -- in case of error, put text error messages into biff via -** biffAdd(NRRD, <error char*>) +** biffAddf(NRRD, <error char*> ...) ** ** The "unknown" encoding below is intended to serve as a template for ** any new encodings being developed. @@ -55,7 +55,7 @@ int _nrrdEncodingUnknown_read(FILE *file, void *data, size_t elementNum, Nrrd *nrrd, struct NrrdIoState_t *nio) { - char me[]="_nrrdEncodingUnknown_read", err[AIR_STRLEN_MED]; + static const char me[]="_nrrdEncodingUnknown_read"; /* insert code here, and remove error handling below */ AIR_UNUSED(file); @@ -64,8 +64,7 @@ _nrrdEncodingUnknown_read(FILE *file, void *data, AIR_UNUSED(nrrd); AIR_UNUSED(nio); - sprintf(err, "%s: ERROR!!! trying to read unknown encoding", me); - biffAdd(NRRD, err); + biffAddf(NRRD, "%s: ERROR!!! trying to read unknown encoding", me); return 1; } @@ -73,7 +72,7 @@ int _nrrdEncodingUnknown_write(FILE *file, const void *data, size_t elementNum, const Nrrd *nrrd, struct NrrdIoState_t *nio) { - char me[]="_nrrdEncodingUnknown_write", err[AIR_STRLEN_MED]; + static const char me[]="_nrrdEncodingUnknown_write"; /* insert code here, and remove error handling below */ AIR_UNUSED(file); @@ -82,8 +81,7 @@ _nrrdEncodingUnknown_write(FILE *file, const void *data, AIR_UNUSED(nrrd); AIR_UNUSED(nio); - sprintf(err, "%s: ERROR!!! trying to write unknown encoding", me); - biffAdd(NRRD, err); + biffAddf(NRRD, "%s: ERROR!!! trying to write unknown encoding", me); return 1; } diff --git a/Utilities/ITK/Utilities/NrrdIO/encodingAscii.c b/Utilities/ITK/Utilities/NrrdIO/encodingAscii.c index d370293aaa683e844b3cf54c73b13752fe7e459c..02accdf18cf6d0bd2ab2343c658bca4e73864450 100644 --- a/Utilities/ITK/Utilities/NrrdIO/encodingAscii.c +++ b/Utilities/ITK/Utilities/NrrdIO/encodingAscii.c @@ -1,6 +1,6 @@ /* NrrdIO: stand-alone code for basic nrrd functionality - Copyright (C) 2005 Gordon Kindlmann + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah This software is provided 'as-is', without any express or implied @@ -34,46 +34,55 @@ _nrrdEncodingAscii_available(void) { int _nrrdEncodingAscii_read(FILE *file, void *_data, size_t elNum, Nrrd *nrrd, NrrdIoState *nio) { - char me[]="_nrrdEncodingAscii_read", err[AIR_STRLEN_MED], - numbStr[AIR_STRLEN_HUGE]; /* HEY: fix this */ + static const char me[]="_nrrdEncodingAscii_read"; + char numbStr[AIR_STRLEN_HUGE]; /* HEY: fix this */ + char *nstr; size_t I; char *data; int tmp; AIR_UNUSED(nio); if (nrrdTypeBlock == nrrd->type) { - sprintf(err, "%s: can't read nrrd type %s from %s", me, - airEnumStr(nrrdType, nrrdTypeBlock), - nrrdEncodingAscii->name); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: can't read nrrd type %s from %s", me, + airEnumStr(nrrdType, nrrdTypeBlock), + nrrdEncodingAscii->name); + return 1; } data = (char*)_data; - for (I=0; I<elNum; I++) { + I = 0; + while (I < elNum) { if (1 != fscanf(file, "%s", numbStr)) { - sprintf(err, "%s: couldn't parse element " _AIR_SIZE_T_CNV - " of " _AIR_SIZE_T_CNV, me, I+1, elNum); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: couldn't parse element " _AIR_SIZE_T_CNV + " of " _AIR_SIZE_T_CNV, me, I+1, elNum); + return 1; + } + if (!strcmp(",", numbStr)) { + /* its an isolated comma, not a value, pass over this */ + continue; } + /* get past any commas prefixing a number (without space) */ + nstr = numbStr + strspn(numbStr, ","); if (nrrd->type >= nrrdTypeInt) { /* sscanf supports putting value directly into this type */ - if (1 != airSingleSscanf(numbStr, nrrdTypePrintfStr[nrrd->type], + if (1 != airSingleSscanf(nstr, nrrdTypePrintfStr[nrrd->type], (void*)(data + I*nrrdElementSize(nrrd)))) { - sprintf(err, "%s: couln't parse %s " _AIR_SIZE_T_CNV - " of " _AIR_SIZE_T_CNV " (\"%s\")", me, - airEnumStr(nrrdType, nrrd->type), - I+1, elNum, numbStr); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: couln't parse %s " _AIR_SIZE_T_CNV + " of " _AIR_SIZE_T_CNV " (\"%s\")", me, + airEnumStr(nrrdType, nrrd->type), + I+1, elNum, nstr); + return 1; } } else { /* sscanf value into an int first */ - if (1 != airSingleSscanf(numbStr, "%d", &tmp)) { - sprintf(err, "%s: couln't parse element " _AIR_SIZE_T_CNV - " of " _AIR_SIZE_T_CNV " (\"%s\")", - me, I+1, elNum, numbStr); - biffAdd(NRRD, err); return 1; + if (1 != airSingleSscanf(nstr, "%d", &tmp)) { + biffAddf(NRRD, "%s: couln't parse element " _AIR_SIZE_T_CNV + " of " _AIR_SIZE_T_CNV " (\"%s\")", + me, I+1, elNum, nstr); + return 1; } nrrdIInsert[nrrd->type](data, I, tmp); } + I++; } return 0; @@ -82,17 +91,17 @@ _nrrdEncodingAscii_read(FILE *file, void *_data, size_t elNum, int _nrrdEncodingAscii_write(FILE *file, const void *_data, size_t elNum, const Nrrd *nrrd, NrrdIoState *nio) { - char me[]="_nrrdEncodingAscii_write", err[AIR_STRLEN_MED], - buff[AIR_STRLEN_MED]; - unsigned int bufflen, linelen; + static const char me[]="_nrrdEncodingAscii_write"; + char buff[AIR_STRLEN_MED]; + size_t bufflen, linelen; const char *data; size_t I; if (nrrdTypeBlock == nrrd->type) { - sprintf(err, "%s: can't write nrrd type %s to %s", me, - airEnumStr(nrrdType, nrrdTypeBlock), - nrrdEncodingAscii->name); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: can't write nrrd type %s to %s", me, + airEnumStr(nrrdType, nrrdTypeBlock), + nrrdEncodingAscii->name); + return 1; } data = (char*)_data; linelen = 0; @@ -105,7 +114,7 @@ _nrrdEncodingAscii_write(FILE *file, const void *_data, size_t elNum, fprintf(file, "%s%c", buff, (I+1)%(nrrd->axis[0].size) ? ' ' : '\n'); } else { - bufflen = (unsigned int)strlen(buff); + bufflen = strlen(buff); if (linelen+bufflen+1 <= nio->charsPerLine) { fprintf(file, "%s%s", I ? " " : "", buff); linelen += (I ? 1 : 0) + bufflen; diff --git a/Utilities/ITK/Utilities/NrrdIO/encodingBzip2.c b/Utilities/ITK/Utilities/NrrdIO/encodingBzip2.c index c21bd5a288251ce7a60ecc4e0e41edb65f45726f..9b3dbea8f1fd87d4a156059d4d0bd011334f21bf 100644 --- a/Utilities/ITK/Utilities/NrrdIO/encodingBzip2.c +++ b/Utilities/ITK/Utilities/NrrdIO/encodingBzip2.c @@ -1,6 +1,6 @@ /* NrrdIO: stand-alone code for basic nrrd functionality - Copyright (C) 2005 Gordon Kindlmann + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah This software is provided 'as-is', without any express or implied diff --git a/Utilities/ITK/Utilities/NrrdIO/encodingGzip.c b/Utilities/ITK/Utilities/NrrdIO/encodingGzip.c index 67f85a014f53c7934e8d6090e6d23141dd4eaf5d..58da10ce609fbe477307efb2c27b3538e70706c3 100644 --- a/Utilities/ITK/Utilities/NrrdIO/encodingGzip.c +++ b/Utilities/ITK/Utilities/NrrdIO/encodingGzip.c @@ -1,6 +1,6 @@ /* NrrdIO: stand-alone code for basic nrrd functionality - Copyright (C) 2005 Gordon Kindlmann + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah This software is provided 'as-is', without any express or implied @@ -25,6 +25,12 @@ #include "NrrdIO.h" #include "privateNrrd.h" +typedef union { + char **c; + void **v; +} ptrHack; + + int _nrrdEncodingGzip_available(void) { @@ -35,94 +41,139 @@ _nrrdEncodingGzip_available(void) { #endif } +/* +** nio->byteSkip < 0 functionality contributed by Katharina Quintus +*/ int _nrrdEncodingGzip_read(FILE *file, void *_data, size_t elNum, Nrrd *nrrd, NrrdIoState *nio) { - char me[]="_nrrdEncodingGzip_read", err[AIR_STRLEN_MED]; + static const char me[]="_nrrdEncodingGzip_read"; #if TEEM_ZLIB - size_t bsize, total_read, block_size; - int i, error; + size_t sizeData, sizeRed, sizeChunk; + int error; + long int bi; unsigned int read; char *data; gzFile gzfin; - - bsize = nrrdElementSize(nrrd)*elNum; + ptrHack hack; + sizeData = nrrdElementSize(nrrd)*elNum; /* Create the gzFile for reading in the gzipped data. */ if ((gzfin = _nrrdGzOpen(file, "rb")) == Z_NULL) { /* there was a problem */ - sprintf(err, "%s: error opening gzFile", me); - biffAdd(NRRD, err); + biffAddf(NRRD, "%s: error opening gzFile", me); return 1; } - - /* Here is where we do the byte skipping. */ - for(i = 0; i < nio->byteSkip; i++) { - unsigned char b; - /* Check to see if a single byte was able to be read. */ - if (_nrrdGzRead(gzfin, &b, 1, &read) != 0 || read != 1) { - sprintf(err, "%s: hit an error skipping byte %d of %d", - me, i, nio->byteSkip); - biffAdd(NRRD, err); + + /* keeps track of how many bytes have been successfully read in */ + sizeRed = 0; + + /* zlib can only handle data sizes up to UINT_MAX ==> if there's more + than UINT_MAX bytes to read in, we read in in chunks */ + sizeChunk = AIR_MIN(sizeData, UINT_MAX); + + if (nio->byteSkip < 0) { + /* We don't know the size of the size to skip before the data, so + decompress the data first into a temporary memory buffer. Then + the byteskipping is then just memcpy-ing the appropriate region + of memory from "buff" into the given "_data" pointer */ + char *buff; + airArray *buffArr; + + /* setting the airArray increment to twice the chunk size means that for + headers that are small compared to the data, the airArray never + actually has to reallocate. The unit is 1 because we are managing + the reading in terms of bytes (sizeof(char)==1 by definition) */ + buff = NULL; + hack.c = &buff; + buffArr = airArrayNew(hack.v, NULL, 1, 2*sizeChunk); + airArrayLenSet(buffArr, sizeChunk); + if (!( buffArr && buffArr->data )) { + biffAddf(NRRD, "%s: couldn't initialize airArray\n", me); return 1; } - } - - /* zlib can handle data sizes up to UINT_MAX, so we can't just - pass in the size, because it might be too large for an - unsigned int. Therefore it must be read in chunks - if the size is larger than UINT_MAX. */ - if (bsize <= UINT_MAX) { - block_size = bsize; + + /* we keep reading in chunks as long as there hasn't been an error, + and we haven't hit EOF (EOF signified by read == 0). Unlike the + code below (for positive byteskip), we are obligated to read until + the bitter end, and can't update sizeChunk to encompass only the + required data. Cast on third arg ok because of AIR_MIN use above */ + while (!(error = _nrrdGzRead(gzfin, buff + sizeRed, + AIR_CAST(unsigned int, sizeChunk), + &read)) + && read > 0) { + sizeRed += read; + if (read >= sizeChunk) { + /* we were able to read as much data as we requested, maybe there is + more, so we need to make our temp buffer bigger */ + airArrayLenIncr(buffArr, sizeChunk); + if (!buffArr->data) { + biffAddf(NRRD, "%s: couldn't re-allocate data buffer", me); + return 1; + } + } + } + if (error) { + biffAddf(NRRD, "%s: error reading from gzFile", me); + return 1; + } + if (sizeRed < sizeData + (-nio->byteSkip - 1)) { + biffAddf(NRRD, "%s: expected " _AIR_SIZE_T_CNV + " bytes and received only " + _AIR_SIZE_T_CNV " bytes", me, + AIR_CAST(size_t, sizeData + (-nio->byteSkip - 1)), sizeRed); + return 1; + } + /* also handles nio->byteSkip == -N-1 signifying extra N bytes at end */ + memcpy(_data, buff + sizeRed - sizeData - (-nio->byteSkip - 1), sizeData); + airArrayNuke(buffArr); } else { - block_size = UINT_MAX; - } - - /* This counter will help us to make sure that we read as much data - as we think we should. */ - total_read = 0; - /* Pointer to the blocks as we read them. */ - data = (char *)_data; - - /* Ok, now we can begin reading. */ - while ((error = _nrrdGzRead(gzfin, data, (unsigned int)block_size, &read)) == 0 - && read > 0) { - /* Increment the data pointer to the next available spot. */ - data += read; - total_read += read; - /* We only want to read as much data as we need, so we need to check - to make sure that we don't request data that might be there but that - we don't want. This will reduce block_size when we get to the last - block (which may be smaller than block_size). - */ - if (bsize >= total_read - && bsize - total_read < block_size) { - block_size = bsize - total_read; + /* no negative byteskip: after byteskipping, we can read directly + into given data buffer */ + if (nio->byteSkip > 0) { + for (bi=0; bi<nio->byteSkip; bi++) { + unsigned char b; + /* Check to see if a single byte was able to be read. */ + if (_nrrdGzRead(gzfin, &b, 1, &read) != 0 || read != 1) { + biffAddf(NRRD, "%s: hit an error skipping byte %ld of %ld", + me, bi, nio->byteSkip); + return 1; + } + } + } + /* Pointer to chunks as we read them. */ + data = AIR_CAST(char *, _data); + while (!(error = _nrrdGzRead(gzfin, data, sizeChunk, &read)) + && read > 0) { + /* Increment the data pointer to the next available chunk. */ + data += read; + sizeRed += read; + /* We only want to read as much data as we need, so we need to check + to make sure that we don't request data that might be there but that + we don't want. This will reduce sizeChunk when we get to the last + block (which may be smaller than sizeChunk). */ + if (sizeData >= sizeRed + && sizeData - sizeRed < sizeChunk) { + sizeChunk = sizeData - sizeRed; + } + } + if (error) { + biffAddf(NRRD, "%s: error reading from gzFile", me); + return 1; + } + /* Check to see if we got out as much as we thought we should. */ + if (sizeRed != sizeData) { + biffAddf(NRRD, "%s: expected " _AIR_SIZE_T_CNV " bytes and received " + _AIR_SIZE_T_CNV " bytes", + me, sizeData, sizeRed); + return 1; } - } - - /* Check if we stopped because of an error. */ - if (error != 0) - { - sprintf(err, "%s: error reading from gzFile", me); - biffAdd(NRRD, err); - return 1; } /* Close the gzFile. Since _nrrdGzClose does not close the FILE* we will not encounter problems when dataFile is closed later. */ - if (_nrrdGzClose(gzfin) != 0) { - sprintf(err, "%s: error closing gzFile", me); - biffAdd(NRRD, err); - return 1; - } - - /* Check to see if we got out as much as we thought we should. */ - if (total_read != bsize) { - sprintf(err, "%s: expected " _AIR_SIZE_T_CNV " bytes and received " - _AIR_SIZE_T_CNV " bytes", - me, bsize, total_read); - biffAdd(NRRD, err); + if (_nrrdGzClose(gzfin)) { + biffAddf(NRRD, "%s: error closing gzFile", me); return 1; } @@ -133,23 +184,23 @@ _nrrdEncodingGzip_read(FILE *file, void *_data, size_t elNum, AIR_UNUSED(elNum); AIR_UNUSED(nrrd); AIR_UNUSED(nio); - sprintf(err, "%s: sorry, this nrrd not compiled with gzip enabled", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: sorry, this nrrd not compiled with gzip enabled", me); + return 1; #endif } int _nrrdEncodingGzip_write(FILE *file, const void *_data, size_t elNum, const Nrrd *nrrd, NrrdIoState *nio) { - char me[]="_nrrdEncodingGzip_write", err[AIR_STRLEN_MED]; + static const char me[]="_nrrdEncodingGzip_write"; #if TEEM_ZLIB - size_t bsize, total_written, block_size; + size_t sizeData, sizeWrit, sizeChunk; int fmt_i=0, error; char *data, fmt[4]; gzFile gzfout; unsigned int wrote; - bsize = nrrdElementSize(nrrd)*elNum; + sizeData = nrrdElementSize(nrrd)*elNum; /* Set format string based on the NrrdIoState parameters. */ fmt[fmt_i++] = 'w'; @@ -171,65 +222,55 @@ _nrrdEncodingGzip_write(FILE *file, const void *_data, size_t elNum, /* Create the gzFile for writing in the gzipped data. */ if ((gzfout = _nrrdGzOpen(file, fmt)) == Z_NULL) { /* there was a problem */ - sprintf(err, "%s: error opening gzFile", me); - biffAdd(NRRD, err); + biffAddf(NRRD, "%s: error opening gzFile", me); return 1; } + + /* zlib can only handle data sizes up to UINT_MAX ==> if there's more + than UINT_MAX bytes to write out, we write out in chunks */ + sizeChunk = AIR_MIN(sizeData, UINT_MAX); - /* zlib can handle data sizes up to UINT_MAX, so we can't just - pass in the bsize, because it might be too large for an - unsigned int. Therefore it must be read in chunks - if the bsize is larger than UINT_MAX. */ - if (bsize <= UINT_MAX) { - block_size = bsize; - } else { - block_size = UINT_MAX; - } - - /* This counter will help us to make sure that we write as much data - as we think we should. */ - total_written = 0; - /* Pointer to the blocks as we write them. */ + /* keeps track of what how much has been successfully written */ + sizeWrit = 0; + /* Pointer to the chunks as we write them. */ data = (char *)_data; - /* Ok, now we can begin writing. */ - while ((error = _nrrdGzWrite(gzfout, data, (unsigned int)block_size, &wrote)) == 0 + /* Ok, now we can begin writing. Cast on third arg ok because of + AIR_MIN use above */ + while ((error = _nrrdGzWrite(gzfout, data, + AIR_CAST(unsigned int, sizeChunk), + &wrote)) == 0 && wrote > 0) { /* Increment the data pointer to the next available spot. */ data += wrote; - total_written += wrote; + sizeWrit += wrote; /* We only want to write as much data as we need, so we need to check to make sure that we don't write more data than is there. This - will reduce block_size when we get to the last block (which may - be smaller than block_size). + will reduce sizeChunk when we get to the last block (which may + be smaller than sizeChunk). */ - if (bsize >= total_written - && (unsigned int)(bsize - total_written) < block_size) - block_size = bsize - total_written; + if (sizeData >= sizeWrit + && (unsigned int)(sizeData - sizeWrit) < sizeChunk) + sizeChunk = sizeData - sizeWrit; } - /* Check if we stopped because of an error. */ - if (error != 0) - { - sprintf(err, "%s: error reading from gzFile", me); - biffAdd(NRRD, err); + if (error) { + biffAddf(NRRD, "%s: error writing to gzFile", me); return 1; } - - /* Close the gzFile. Since _nrrdGzClose does not close the FILE* we - will not encounter problems when dataFile is closed later. */ - if (_nrrdGzClose(gzfout) != 0) { - sprintf(err, "%s: error closing gzFile", me); - biffAdd(NRRD, err); + + /* Check to see if we wrote out as much as we thought we should. */ + if (sizeWrit != sizeData) { + biffAddf(NRRD, "%s: expected to write " _AIR_SIZE_T_CNV + " bytes, but only wrote " _AIR_SIZE_T_CNV, + me, sizeData, sizeWrit); return 1; } - /* Check to see if we got out as much as we thought we should. */ - if (total_written != bsize) { - sprintf(err, "%s: expected to write " _AIR_SIZE_T_CNV " bytes, but only " - "wrote " _AIR_SIZE_T_CNV, - me, bsize, total_written); - biffAdd(NRRD, err); + /* Close the gzFile. Since _nrrdGzClose does not close the FILE* we + will not encounter problems when dataFile is closed later. */ + if (_nrrdGzClose(gzfout)) { + biffAddf(NRRD, "%s: error closing gzFile", me); return 1; } @@ -240,9 +281,9 @@ _nrrdEncodingGzip_write(FILE *file, const void *_data, size_t elNum, AIR_UNUSED(elNum); AIR_UNUSED(nrrd); AIR_UNUSED(nio); - sprintf(err, "%s: sorry, this nrrd not compiled with zlib " - "(needed for gzip) enabled", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: sorry, this nrrd not compiled with zlib " + "(needed for gzip) enabled", me); + return 1; #endif } diff --git a/Utilities/ITK/Utilities/NrrdIO/encodingHex.c b/Utilities/ITK/Utilities/NrrdIO/encodingHex.c index 0009004dc1f92efe873497c2cefaf3f5e61929f9..cc5aa2159530c08d6ac657811a9e40e75b1f4cbc 100644 --- a/Utilities/ITK/Utilities/NrrdIO/encodingHex.c +++ b/Utilities/ITK/Utilities/NrrdIO/encodingHex.c @@ -1,6 +1,6 @@ /* NrrdIO: stand-alone code for basic nrrd functionality - Copyright (C) 2005 Gordon Kindlmann + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah This software is provided 'as-is', without any express or implied @@ -64,7 +64,7 @@ _nrrdEncodingHex_available(void) { int _nrrdEncodingHex_read(FILE *file, void *_data, size_t elNum, Nrrd *nrrd, NrrdIoState *nio) { - char me[]="_nrrdEncodingHex_read", err[AIR_STRLEN_MED]; + static const char me[]="_nrrdEncodingHex_read"; size_t nibIdx, nibNum; unsigned char *data; int car=0, nib; @@ -74,8 +74,8 @@ _nrrdEncodingHex_read(FILE *file, void *_data, size_t elNum, nibIdx = 0; nibNum = 2*elNum*nrrdElementSize(nrrd); if (nibNum/elNum != 2*nrrdElementSize(nrrd)) { - sprintf(err, "%s: size_t can't hold 2*(#bytes in array)\n", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: size_t can't hold 2*(#bytes in array)\n", me); + return 1; } while (nibIdx < nibNum) { car = fgetc(file); @@ -89,21 +89,21 @@ _nrrdEncodingHex_read(FILE *file, void *_data, size_t elNum, /* its white space */ continue; } - *data += (unsigned char)(nib << (4*(1-(nibIdx & 1)))); + *data += AIR_CAST(unsigned int, nib << (4*(1-(nibIdx & 1)))); data += nibIdx & 1; nibIdx++; } if (nibIdx != nibNum) { if (EOF == car) { - sprintf(err, "%s: hit EOF getting " - "byte " _AIR_SIZE_T_CNV " of " _AIR_SIZE_T_CNV, - me, nibIdx/2, nibNum/2); + biffAddf(NRRD, "%s: hit EOF getting " + "byte " _AIR_SIZE_T_CNV " of " _AIR_SIZE_T_CNV, + me, nibIdx/2, nibNum/2); } else { - sprintf(err, "%s: hit invalid character ('%c') getting " - "byte " _AIR_SIZE_T_CNV " of " _AIR_SIZE_T_CNV, - me, car, nibIdx/2, nibNum/2); + biffAddf(NRRD, "%s: hit invalid character ('%c') getting " + "byte " _AIR_SIZE_T_CNV " of " _AIR_SIZE_T_CNV, + me, car, nibIdx/2, nibNum/2); } - biffAdd(NRRD, err); return 1; + return 1; } return 0; } @@ -111,21 +111,25 @@ _nrrdEncodingHex_read(FILE *file, void *_data, size_t elNum, int _nrrdEncodingHex_write(FILE *file, const void *_data, size_t elNum, const Nrrd *nrrd, NrrdIoState *nio) { - /* char me[]="_nrrdEncodingHex_write", err[AIR_STRLEN_MED]; */ + /* static const char me[]="_nrrdEncodingHex_write"; */ unsigned char *data; size_t byteIdx, byteNum; + unsigned int bytesPerLine; - AIR_UNUSED(nio); + bytesPerLine = AIR_MAX(1, nio->charsPerLine/2); data = (unsigned char*)_data; byteNum = elNum*nrrdElementSize(nrrd); for (byteIdx=0; byteIdx<byteNum; byteIdx++) { fprintf(file, "%c%c", _nrrdWriteHexTable[(*data)>>4], _nrrdWriteHexTable[(*data)&15]); - if (34 == byteIdx%35) + if (bytesPerLine-1 == byteIdx % bytesPerLine) { fprintf(file, "\n"); + } data++; } + /* just to be sure, we always end with a carraige return */ + fprintf(file, "\n"); return 0; } diff --git a/Utilities/ITK/Utilities/NrrdIO/encodingRaw.c b/Utilities/ITK/Utilities/NrrdIO/encodingRaw.c index 50cfc0174f3498be6794a5bcc70cef5b91681574..bbceb135e4f3475567d484c2c30dad5a6e6763ca 100644 --- a/Utilities/ITK/Utilities/NrrdIO/encodingRaw.c +++ b/Utilities/ITK/Utilities/NrrdIO/encodingRaw.c @@ -1,6 +1,6 @@ /* NrrdIO: stand-alone code for basic nrrd functionality - Copyright (C) 2005 Gordon Kindlmann + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah This software is provided 'as-is', without any express or implied @@ -34,10 +34,13 @@ _nrrdEncodingRaw_available(void) { int _nrrdEncodingRaw_read(FILE *file, void *data, size_t elementNum, Nrrd *nrrd, NrrdIoState *nio) { - char me[]="_nrrdEncodingRaw_read", err[AIR_STRLEN_MED]; + static const char me[]="_nrrdEncodingRaw_read"; size_t ret, bsize; int fd, dio, car; long savePos; + char *data_c; + size_t elementSize, maxChunkSize, remainder, chunkSize; + size_t retTmp; bsize = nrrdElementSize(nrrd)*elementNum; if (nio->format->usesDIO) { @@ -53,11 +56,11 @@ _nrrdEncodingRaw_read(FILE *file, void *data, size_t elementNum, } ret = airDioRead(fd, data, bsize); if (ret != bsize) { - sprintf(err, "%s: airDioRead got read only " - _AIR_SIZE_T_CNV " of " _AIR_SIZE_T_CNV " bytes " - "(%g%% of expected)", me, - ret, bsize, 100.0*ret/bsize); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: airDioRead got read only " + _AIR_SIZE_T_CNV " of " _AIR_SIZE_T_CNV " bytes " + "(%g%% of expected)", me, + ret, bsize, 100.0*ret/bsize); + return 1; } } else { if (2 <= nrrdStateVerboseIO) { @@ -65,15 +68,47 @@ _nrrdEncodingRaw_read(FILE *file, void *data, size_t elementNum, fprintf(stderr, "with fread(), not DIO: %s ...", airNoDioErr(dio)); } } + + /* HEY: There's a bug in fread/fwrite in gcc 4.2.1 (with SnowLeopard). + When it reads/writes a >=2GB data array, it pretends to succeed + (i.e. the return value is the right number) but it hasn't + actually read/written the data. The work-around is to loop + over the data, reading/writing 1GB (or smaller) chunks. */ + ret = 0; + data_c = (char *)data; + elementSize = nrrdElementSize(nrrd); + maxChunkSize = 1024 * 1024 * 1024 / elementSize; + while(ret < elementNum) { + remainder = elementNum-ret; + if (remainder < maxChunkSize) { + chunkSize = remainder; + } else { + chunkSize = maxChunkSize; + } + retTmp = + fread(&(data_c[ret*elementSize]), elementSize, chunkSize, file); + ret += retTmp; + if (retTmp != chunkSize) { + biffAddf(NRRD, "%s: fread got read only " + _AIR_SIZE_T_CNV " " _AIR_SIZE_T_CNV "-sized things, not " + _AIR_SIZE_T_CNV " (%g%% of expected)", me, + ret, nrrdElementSize(nrrd), elementNum, + 100.0*ret/elementNum); + return 1; + } + } + /* HEY: Here's the old version of the above code. ret = fread(data, nrrdElementSize(nrrd), elementNum, file); if (ret != elementNum) { - sprintf(err, "%s: fread got read only " - _AIR_SIZE_T_CNV " " _AIR_SIZE_T_CNV "-sized things, not " - _AIR_SIZE_T_CNV " (%g%% of expected)", me, - ret, nrrdElementSize(nrrd), elementNum, - 100.0*ret/elementNum); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: fread got read only " + _AIR_SIZE_T_CNV " " _AIR_SIZE_T_CNV "-sized things, not " + _AIR_SIZE_T_CNV " (%g%% of expected)", me, + ret, nrrdElementSize(nrrd), elementNum, + 100.0*ret/elementNum); + return 1; } + */ + car = fgetc(file); if (1 <= nrrdStateVerboseIO && EOF != car) { fprintf(stderr, "%s: WARNING: finished reading raw data, " @@ -96,9 +131,12 @@ _nrrdEncodingRaw_read(FILE *file, void *data, size_t elementNum, int _nrrdEncodingRaw_write(FILE *file, const void *data, size_t elementNum, const Nrrd *nrrd, NrrdIoState *nio) { - char me[]="_nrrdEncodingRaw_write", err[AIR_STRLEN_MED]; + static const char me[]="_nrrdEncodingRaw_write"; int fd, dio; size_t ret, bsize; + char *data_c; + size_t elementSize, maxChunkSize, remainder, chunkSize; + size_t retTmp; bsize = nrrdElementSize(nrrd)*elementNum; if (nio->format->usesDIO) { @@ -114,11 +152,11 @@ _nrrdEncodingRaw_write(FILE *file, const void *data, size_t elementNum, } ret = airDioWrite(fd, data, bsize); if (ret != bsize) { - sprintf(err, "%s: airDioWrite wrote only " - _AIR_SIZE_T_CNV " of " _AIR_SIZE_T_CNV " bytes " - "(%g%% of expected)", me, - ret, bsize, 100.0*ret/bsize); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: airDioWrite wrote only " + _AIR_SIZE_T_CNV " of " _AIR_SIZE_T_CNV " bytes " + "(%g%% of expected)", me, + ret, bsize, 100.0*ret/bsize); + return 1; } } else { if (2 <= nrrdStateVerboseIO) { @@ -126,20 +164,52 @@ _nrrdEncodingRaw_write(FILE *file, const void *data, size_t elementNum, fprintf(stderr, "with fread(), not DIO: %s ...", airNoDioErr(dio)); } } + + /* HEY: There's a bug in fread/fwrite in gcc 4.2.1 (with SnowLeopard). + When it reads/writes a >=2GB data array, it pretends to succeed + (i.e. the return value is the right number) but it hasn't + actually read/written the data. The work-around is to loop + over the data, reading/writing 1GB (or smaller) chunks. */ + ret = 0; + data_c = (char *)data; + elementSize = nrrdElementSize(nrrd); + maxChunkSize = 1024 * 1024 * 1024 / elementSize; + while(ret < elementNum) { + remainder = elementNum-ret; + if (remainder < maxChunkSize) { + chunkSize = remainder; + } else { + chunkSize = maxChunkSize; + } + retTmp = + fwrite(&(data_c[ret*elementSize]), elementSize, chunkSize, file); + ret += retTmp; + if (retTmp != chunkSize) { + biffAddf(NRRD, "%s: fwrite wrote only " + _AIR_SIZE_T_CNV " " _AIR_SIZE_T_CNV "-sized things, not " + _AIR_SIZE_T_CNV " (%g%% of expected)", me, + ret, nrrdElementSize(nrrd), elementNum, + 100.0*ret/elementNum); + return 1; + } + } + /* HEY: Here's the old version of the above code. ret = fwrite(data, nrrdElementSize(nrrd), elementNum, file); if (ret != elementNum) { - sprintf(err, "%s: fwrite wrote read only " - _AIR_SIZE_T_CNV " " _AIR_SIZE_T_CNV "-sized things, not " - _AIR_SIZE_T_CNV " (%g%% of expected)", me, - ret, nrrdElementSize(nrrd), elementNum, - 100.0*ret/elementNum); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: fwrite wrote only " + _AIR_SIZE_T_CNV " " _AIR_SIZE_T_CNV "-sized things, not " + _AIR_SIZE_T_CNV " (%g%% of expected)", me, + ret, nrrdElementSize(nrrd), elementNum, + 100.0*ret/elementNum); + return 1; } + */ + fflush(file); /* if (ferror(file)) { - sprintf(err, "%s: ferror returned non-zero", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: ferror returned non-zero", me); + return 1; } */ } diff --git a/Utilities/ITK/Utilities/NrrdIO/endianAir.c b/Utilities/ITK/Utilities/NrrdIO/endianAir.c index d8ccbcd8869b3df3b797676a3dba52e8782c8346..d4181b269e73865e0f5245ea42c211e3b50ad32a 100644 --- a/Utilities/ITK/Utilities/NrrdIO/endianAir.c +++ b/Utilities/ITK/Utilities/NrrdIO/endianAir.c @@ -1,6 +1,6 @@ /* NrrdIO: stand-alone code for basic nrrd functionality - Copyright (C) 2005 Gordon Kindlmann + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah This software is provided 'as-is', without any express or implied @@ -22,7 +22,6 @@ 3. This notice may not be removed or altered from any source distribution. */ - #include "NrrdIO.h" #include "teemEndian.h" @@ -37,28 +36,28 @@ const int airMyEndian = 1234; const int airMyEndian = 4321; #endif -char -_airEndianStr[][AIR_STRLEN_SMALL] = { +const char * +_airEndianStr[] = { "(unknown endian)", "little", "big" }; -char -_airEndianDesc[][AIR_STRLEN_MED] = { +const char * +_airEndianDesc[] = { "unknown endianness", "Intel and compatible", "Everyone besides Intel and compatible" }; -int +const int _airEndianVal[] = { airEndianUnknown, airEndianLittle, airEndianBig, }; -airEnum +const airEnum _airEndian = { "endian", 2, @@ -68,6 +67,6 @@ _airEndian = { AIR_FALSE }; -airEnum * +const airEnum *const airEndian = &_airEndian; diff --git a/Utilities/ITK/Utilities/NrrdIO/endianNrrd.c b/Utilities/ITK/Utilities/NrrdIO/endianNrrd.c index 4dacf3ef42fcaeedf891b0daffd8ac6174ae4b3a..41247eb17f15ddbb8ae6750c8139f00038b4162c 100644 --- a/Utilities/ITK/Utilities/NrrdIO/endianNrrd.c +++ b/Utilities/ITK/Utilities/NrrdIO/endianNrrd.c @@ -1,6 +1,6 @@ /* NrrdIO: stand-alone code for basic nrrd functionality - Copyright (C) 2005 Gordon Kindlmann + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah This software is provided 'as-is', without any express or implied diff --git a/Utilities/ITK/Utilities/NrrdIO/enum.c b/Utilities/ITK/Utilities/NrrdIO/enum.c index a51216ee7979b0d4870cbb8421b840369bf13c17..e11a5cbc17fdacadb93001c9cc3c3cc67d6c3027 100644 --- a/Utilities/ITK/Utilities/NrrdIO/enum.c +++ b/Utilities/ITK/Utilities/NrrdIO/enum.c @@ -1,6 +1,6 @@ /* NrrdIO: stand-alone code for basic nrrd functionality - Copyright (C) 2005 Gordon Kindlmann + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah This software is provided 'as-is', without any express or implied @@ -30,7 +30,7 @@ ** return the value representing "unknown" in an enum */ int -airEnumUnknown(airEnum *enm) { +airEnumUnknown(const airEnum *enm) { if (enm && enm->val) { return enm->val[0]; @@ -39,6 +39,21 @@ airEnumUnknown(airEnum *enm) { } } +/* +******** airEnumLast +** +** return the highest value representing a known value +*/ +int +airEnumLast(const airEnum *enm) { + + if (enm && enm->val) { + return enm->val[enm->M]; + } else { + return enm->M; + } +} + /* ** _airEnumIndex() ** @@ -47,7 +62,7 @@ airEnumUnknown(airEnum *enm) { ** given an invalid enum value, we return zero. */ unsigned int -_airEnumIndex(airEnum *enm, int val) { +_airEnumIndex(const airEnum *enm, int val) { unsigned int ii, ret; ret = 0; @@ -64,14 +79,18 @@ _airEnumIndex(airEnum *enm, int val) { return ret; } +/* +** returns non-zero if there is an error: given "val" is *not* +** a valid value of the airEnum "enm" +*/ int -airEnumValCheck(airEnum *enm, int val) { +airEnumValCheck(const airEnum *enm, int val) { return (0 == _airEnumIndex(enm, val)); } const char * -airEnumStr(airEnum *enm, int val) { +airEnumStr(const airEnum *enm, int val) { int idx; idx = _airEnumIndex(enm, val); @@ -79,7 +98,7 @@ airEnumStr(airEnum *enm, int val) { } const char * -airEnumDesc(airEnum *enm, int val) { +airEnumDesc(const airEnum *enm, int val) { int idx; idx = _airEnumIndex(enm, val); @@ -87,7 +106,7 @@ airEnumDesc(airEnum *enm, int val) { } int -airEnumVal(airEnum *enm, const char *str) { +airEnumVal(const airEnum *enm, const char *str) { char *strCpy, test[AIR_STRLEN_SMALL]; unsigned int ii; @@ -101,6 +120,8 @@ airEnumVal(airEnum *enm, const char *str) { } if (enm->strEqv) { + /* want strlen and not airStrlen here because the strEqv array + should be terminated by a non-null empty string */ for (ii=0; strlen(enm->strEqv[ii]); ii++) { strncpy(test, enm->strEqv[ii], AIR_STRLEN_SMALL); test[AIR_STRLEN_SMALL-1] = '\0'; @@ -146,8 +167,9 @@ airEnumVal(airEnum *enm, const char *str) { ** when there is a strEqv[]/valEqv[] pair defining a shorter string) */ char * -airEnumFmtDesc(airEnum *enm, int val, int canon, const char *fmt) { - char *buff, *desc, ident[AIR_STRLEN_SMALL]; +airEnumFmtDesc(const airEnum *enm, int val, int canon, const char *fmt) { + const char *desc; + char *buff, ident[AIR_STRLEN_SMALL]; const char *_ident; int i; size_t len; @@ -160,28 +182,89 @@ airEnumFmtDesc(airEnum *enm, int val, int canon, const char *fmt) { } _ident = airEnumStr(enm, val); if (!canon && enm->strEqv) { - len = strlen(_ident); - for (i=0; strlen(enm->strEqv[i]); i++) { + len = airStrlen(_ident); + for (i=0; airStrlen(enm->strEqv[i]); i++) { if (val != enm->valEqv[i]) { /* this isn't a string representing the value we care about */ continue; } - if (strlen(enm->strEqv[i]) < len) { + if (airStrlen(enm->strEqv[i]) < len) { /* this one is shorter */ - len = strlen(enm->strEqv[i]); + len = airStrlen(enm->strEqv[i]); _ident = enm->strEqv[i]; } } } - strcpy(ident, _ident); + strncpy(ident, _ident, AIR_STRLEN_SMALL); + ident[AIR_STRLEN_SMALL-1] = '\0'; if (!enm->sense) { airToLower(ident); } desc = enm->desc[_airEnumIndex(enm, val)]; - buff = (char *)calloc(strlen(fmt) + strlen(ident) + strlen(desc) + 1, - sizeof(char)); + buff = AIR_CALLOC(airStrlen(fmt) + airStrlen(ident) + + airStrlen(desc) + 1, char); if (buff) { sprintf(buff, fmt, ident, desc); } return buff; } + +static void +_enumPrintVal(FILE *file, const airEnum *enm, int ii) { + + if (enm->desc) { + fprintf(file, "desc: %s\n", enm->desc[ii]); + } + if (enm->strEqv) { + unsigned int jj; + fprintf(file, "eqv:"); fflush(file); + jj = 0; + while (airStrlen(enm->strEqv[jj])) { + if (enm->valEqv[jj] == (enm->val + ? enm->val[ii] + : ii)) { + fprintf(file, " \"%s\"", enm->strEqv[jj]); + } + jj++; + } + fprintf(file, "\n"); + } +} + +void +airEnumPrint(FILE *file, const airEnum *enm) { + int ii; /* this should arguable be unsigned int, but + airEnum values were kept as "int", even after + the great unsigned conversion */ + + if (!(file && enm)) { + return; + } + + if (airStrlen(enm->name)) { + fprintf(file, "airEnum \"%s\":\n", enm->name); + } else { + fprintf(file, "airEnum (NO NAME!):\n"); + } + fprintf(file, "(%s case sensitive)\n", (enm->sense ? "yes, is" : "is not")); + if (enm->val) { + fprintf(file, "Values (%u valid) given explicitly\n", enm->M); + fprintf(file, "--- (0) %d: \"%s\"\n", enm->val[0], enm->str[0]); + for (ii=1; ii<=AIR_CAST(int, enm->M); ii++) { + fprintf(file, "--- (%d) %d: \"%s\" == \"%s\"\n", ii, + enm->val[ii], enm->str[ii], + airEnumStr(enm, enm->val[ii])); + _enumPrintVal(file, enm, ii); + } + } else { + /* enm->val NULL */ + fprintf(file, "Values implicit; [1,%u] valid\n", enm->M); + fprintf(file, "--- 0: \"%s\"\n", enm->str[0]); + for (ii=1; ii<=AIR_CAST(int, enm->M); ii++) { + fprintf(file, "--- %d: %s == %s\n", ii, enm->str[ii], + airEnumStr(enm, ii)); + _enumPrintVal(file, enm, ii); + } + } + return; +} diff --git a/Utilities/ITK/Utilities/NrrdIO/enumsNrrd.c b/Utilities/ITK/Utilities/NrrdIO/enumsNrrd.c index 679167b6ed557be61cdfeb543afe10d5fc8b8f86..ef40992a1caa58a6f3107fd904419d73f7810d9d 100644 --- a/Utilities/ITK/Utilities/NrrdIO/enumsNrrd.c +++ b/Utilities/ITK/Utilities/NrrdIO/enumsNrrd.c @@ -1,6 +1,6 @@ /* NrrdIO: stand-alone code for basic nrrd functionality - Copyright (C) 2005 Gordon Kindlmann + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah This software is provided 'as-is', without any express or implied @@ -48,8 +48,8 @@ /* ------------------------ nrrdFormat ------------------------- */ -char -_nrrdFormatTypeStr[NRRD_FORMAT_TYPE_MAX+1][AIR_STRLEN_SMALL] = { +const char * +_nrrdFormatTypeStr[NRRD_FORMAT_TYPE_MAX+1] = { "(unknown_format)", "nrrd", "pnm", @@ -59,8 +59,8 @@ _nrrdFormatTypeStr[NRRD_FORMAT_TYPE_MAX+1][AIR_STRLEN_SMALL] = { "eps", }; -char -_nrrdFormatTypeDesc[NRRD_FORMAT_TYPE_MAX+1][AIR_STRLEN_MED] = { +const char * +_nrrdFormatTypeDesc[NRRD_FORMAT_TYPE_MAX+1] = { "unknown_format", "native format for nearly raw raster data", "Portable aNy Map: includes PGM for grayscale and PPM for color", @@ -70,8 +70,8 @@ _nrrdFormatTypeDesc[NRRD_FORMAT_TYPE_MAX+1][AIR_STRLEN_MED] = { "Encapsulated PostScript images", }; -char -_nrrdFormatTypeStrEqv[][AIR_STRLEN_SMALL] = { +const char * +_nrrdFormatTypeStrEqv[] = { "nrrd", "pnm", "png", @@ -81,7 +81,7 @@ _nrrdFormatTypeStrEqv[][AIR_STRLEN_SMALL] = { "" }; -int +const int _nrrdFormatTypeValEqv[] = { nrrdFormatTypeNRRD, nrrdFormatTypePNM, @@ -100,13 +100,13 @@ _nrrdFormatType = { _nrrdFormatTypeStrEqv, _nrrdFormatTypeValEqv, AIR_FALSE }; -airEnum * +const airEnum *const nrrdFormatType = &_nrrdFormatType; /* ------------------------ nrrdType ------------------------- */ -char -_nrrdTypeStr[NRRD_TYPE_MAX+1][AIR_STRLEN_SMALL] = { +const char * +_nrrdTypeStr[NRRD_TYPE_MAX+1] = { "(unknown_type)", "signed char", "unsigned char", @@ -121,8 +121,8 @@ _nrrdTypeStr[NRRD_TYPE_MAX+1][AIR_STRLEN_SMALL] = { "block", }; -char -_nrrdTypeDesc[NRRD_TYPE_MAX+1][AIR_STRLEN_MED] = { +const char * +_nrrdTypeDesc[NRRD_TYPE_MAX+1] = { "unknown type", "signed 1-byte integer", "unsigned 1-byte integer", @@ -149,8 +149,8 @@ _nrrdTypeDesc[NRRD_TYPE_MAX+1][AIR_STRLEN_MED] = { #define ntDB nrrdTypeDouble #define ntBL nrrdTypeBlock -char -_nrrdTypeStrEqv[][AIR_STRLEN_SMALL] = { +const char * +_nrrdTypeStrEqv[] = { "signed char", /* but NOT just "char" */ "int8", "int8_t", "uchar", "unsigned char", "uint8", "uint8_t", "short", "short int", "signed short", "signed short int", "int16", "int16_t", @@ -167,7 +167,7 @@ _nrrdTypeStrEqv[][AIR_STRLEN_SMALL] = { "" }; -int +const int _nrrdTypeValEqv[] = { ntCH, ntCH, ntCH, ntUC, ntUC, ntUC, ntUC, @@ -191,13 +191,13 @@ _nrrdType = { _nrrdTypeStrEqv, _nrrdTypeValEqv, AIR_FALSE }; -airEnum * +const airEnum *const nrrdType = &_nrrdType; /* ------------------------ nrrdEncodingType ------------------------- */ -char -_nrrdEncodingTypeStr[NRRD_ENCODING_TYPE_MAX+1][AIR_STRLEN_SMALL] = { +const char * +_nrrdEncodingTypeStr[NRRD_ENCODING_TYPE_MAX+1] = { "(unknown_encoding)", "raw", "ascii", @@ -206,8 +206,8 @@ _nrrdEncodingTypeStr[NRRD_ENCODING_TYPE_MAX+1][AIR_STRLEN_SMALL] = { "bz2", }; -char -_nrrdEncodingTypeDesc[NRRD_ENCODING_TYPE_MAX+1][AIR_STRLEN_MED] = { +const char * +_nrrdEncodingTypeDesc[NRRD_ENCODING_TYPE_MAX+1] = { "unknown encoding", "file is byte-for-byte same as memory representation", "values written out in ASCII", @@ -216,8 +216,8 @@ _nrrdEncodingTypeDesc[NRRD_ENCODING_TYPE_MAX+1][AIR_STRLEN_MED] = { "bzip2 compression of binary encoding", }; -char -_nrrdEncodingTypeStrEqv[][AIR_STRLEN_SMALL] = { +const char * +_nrrdEncodingTypeStrEqv[] = { "(unknown_encoding)", "raw", "txt", "text", "ascii", @@ -227,7 +227,7 @@ _nrrdEncodingTypeStrEqv[][AIR_STRLEN_SMALL] = { "" }; -int +const int _nrrdEncodingTypeValEqv[] = { nrrdEncodingTypeUnknown, nrrdEncodingTypeRaw, @@ -246,20 +246,20 @@ _nrrdEncodingType = { _nrrdEncodingTypeStrEqv, _nrrdEncodingTypeValEqv, AIR_FALSE }; -airEnum * +const airEnum *const nrrdEncodingType = &_nrrdEncodingType; /* ------------------------ nrrdCenter ------------------------- */ -char -_nrrdCenterStr[NRRD_CENTER_MAX+1][AIR_STRLEN_SMALL] = { +const char * +_nrrdCenterStr[NRRD_CENTER_MAX+1] = { "(unknown_center)", "node", "cell", }; -char -_nrrdCenterDesc[NRRD_CENTER_MAX+1][AIR_STRLEN_MED] = { +const char * +_nrrdCenterDesc[NRRD_CENTER_MAX+1] = { "unknown centering", "samples are at boundaries between elements along axis", "samples are at centers of elements along axis", @@ -274,7 +274,7 @@ _nrrdCenter_enum = { NULL, NULL, AIR_FALSE }; -airEnum * +const airEnum *const nrrdCenter = &_nrrdCenter_enum; /* ------------------------ nrrdKind ------------------------- */ @@ -307,7 +307,7 @@ nrrdCenter = &_nrrdCenter_enum; nrrdKind3Gradient, * 20: 3-component covariant vector * nrrdKind3Normal, * 21: 3-component covector, assumed normalized * nrrdKind4Vector, * 22: 4-component vector * - nrrdKindQuaternion, * 23: (x,y,z,w), not necessarily normalized * + nrrdKindQuaternion, * 23: (w,x,y,z), not necessarily normalized * nrrdKind2DSymMatrix, * 24: Mxx Mxy Myy * nrrdKind2DMaskedSymMatrix, * 25: mask Mxx Mxy Myy * nrrdKind2DMatrix, * 26: Mxx Mxy Myx Myy * @@ -318,8 +318,8 @@ nrrdCenter = &_nrrdCenter_enum; nrrdKind3DMaskedMatrix, * 31: mask Mxx Mxy Mxz Myx Myy Myz Mzx Mzy Mzz * */ -char -_nrrdKindStr[NRRD_KIND_MAX+1][AIR_STRLEN_SMALL] = { +const char * +_nrrdKindStr[NRRD_KIND_MAX+1] = { "(unknown_kind)", "domain", "space", @@ -354,8 +354,8 @@ _nrrdKindStr[NRRD_KIND_MAX+1][AIR_STRLEN_SMALL] = { "3D-masked-matrix", }; -char -_nrrdKindDesc[NRRD_KIND_MAX+1][AIR_STRLEN_MED] = { +const char * +_nrrdKindDesc[NRRD_KIND_MAX+1] = { "unknown kind", "a domain variable of the function which the nrrd samples", "a spatial domain, like the axes of a measured volume image", @@ -390,8 +390,8 @@ _nrrdKindDesc[NRRD_KIND_MAX+1][AIR_STRLEN_MED] = { "mask plus 9 elements of general 3D matrix: mask Mxx Mxy Mxz Myx Myy Myz Mzx Mzy Mzz", }; -char -_nrrdKindStr_Eqv[][AIR_STRLEN_SMALL] = { +const char * +_nrrdKindStr_Eqv[] = { "domain", "space", "time", @@ -486,13 +486,13 @@ _nrrdKind_enum = { _nrrdKindStr_Eqv, _nrrdKindVal_Eqv, AIR_FALSE }; -airEnum * +const airEnum *const nrrdKind = &_nrrdKind_enum; /* ------------------------ nrrdField ------------------------- */ -char -_nrrdFieldStr[NRRD_FIELD_MAX+1][AIR_STRLEN_SMALL] = { +const char * +_nrrdFieldStr[NRRD_FIELD_MAX+1] = { "Ernesto \"Che\" Guevara", "#", "content", @@ -528,8 +528,8 @@ _nrrdFieldStr[NRRD_FIELD_MAX+1][AIR_STRLEN_SMALL] = { "data file", }; -char -_nrrdFieldDesc[NRRD_FIELD_MAX+1][AIR_STRLEN_MED] = { +const char * +_nrrdFieldDesc[NRRD_FIELD_MAX+1] = { "unknown field identifier", "comment", "short description of whole array and/or its provenance", @@ -565,8 +565,8 @@ _nrrdFieldDesc[NRRD_FIELD_MAX+1][AIR_STRLEN_MED] = { "with detached headers, where is data to be found", }; -char -_nrrdFieldStrEqv[][AIR_STRLEN_SMALL] = { +const char * +_nrrdFieldStrEqv[] = { "#", "content", "number", @@ -602,7 +602,7 @@ _nrrdFieldStrEqv[][AIR_STRLEN_SMALL] = { "" }; -int +const int _nrrdFieldValEqv[] = { nrrdField_comment, nrrdField_content, @@ -647,7 +647,7 @@ _nrrdField = { _nrrdFieldStrEqv, _nrrdFieldValEqv, AIR_FALSE /* field identifiers not case sensitive */ }; -airEnum * +const airEnum *const nrrdField = &_nrrdField; /* ------------------------ nrrdSpace ------------------------- */ @@ -669,8 +669,8 @@ nrrdField = &_nrrdField; nrrdSpaceLast */ -char -_nrrdSpaceStr[NRRD_SPACE_MAX+1][AIR_STRLEN_SMALL] = { +const char * +_nrrdSpaceStr[NRRD_SPACE_MAX+1] = { "(unknown_space)", "right-anterior-superior", "left-anterior-superior", @@ -686,8 +686,8 @@ _nrrdSpaceStr[NRRD_SPACE_MAX+1][AIR_STRLEN_SMALL] = { "3D-left-handed-time", }; -char -_nrrdSpaceDesc[NRRD_SPACE_MAX+1][AIR_STRLEN_MED] = { +const char * +_nrrdSpaceDesc[NRRD_SPACE_MAX+1] = { "unknown space", "right-anterior-superior (used in NIFTI-1 and SPL's 3D Slicer)", "left-anterior-superior (used in Analyze 7.5)", @@ -703,8 +703,8 @@ _nrrdSpaceDesc[NRRD_SPACE_MAX+1][AIR_STRLEN_MED] = { "3D-left-handed-time", }; -char -_nrrdSpaceStrEqv[][AIR_STRLEN_SMALL] = { +const char * +_nrrdSpaceStrEqv[] = { "(unknown_space)", "right-anterior-superior", "right anterior superior", "rightanteriorsuperior", "RAS", @@ -729,7 +729,7 @@ _nrrdSpaceStrEqv[][AIR_STRLEN_SMALL] = { "" }; -int +const int _nrrdSpaceValEqv[] = { nrrdSpaceUnknown, nrrdSpaceRightAnteriorSuperior, nrrdSpaceRightAnteriorSuperior, @@ -763,6 +763,38 @@ _nrrdSpace = { _nrrdSpaceStrEqv, _nrrdSpaceValEqv, AIR_FALSE }; -airEnum * +const airEnum *const nrrdSpace = &_nrrdSpace; +/* ------------------------ nrrdSpacingStatus ------------------------- */ + +const char * +_nrrdSpacingStatusStr[NRRD_SPACING_STATUS_MAX+1] = { + "(unknown_status)", + "none", + "scalarNoSpace", + "scalarWithSpace", + "direction", +}; + +const char * +_nrrdSpacingStatusDesc[NRRD_BOUNDARY_MAX+1] = { + "unknown spacing status behavior", + "neither axis->spacing nor axis->spaceDirection set", + "axis->spacing set normally", + "axis->spacing set, with surround space (?)", + "axis->spaceDirection set normally", +}; + +airEnum +_nrrdSpacingStatus = { + "spacing status", + NRRD_SPACING_STATUS_MAX, + _nrrdSpacingStatusStr, NULL, + _nrrdSpacingStatusDesc, + NULL, NULL, + AIR_FALSE +}; +const airEnum *const +nrrdSpacingStatus = &_nrrdSpacingStatus; + diff --git a/Utilities/ITK/Utilities/NrrdIO/format.c b/Utilities/ITK/Utilities/NrrdIO/format.c index 7db7e725f63dd203be8e1dada0c0ce00918dc09f..2bbcd232151b81ba597270ba5edafa3454bb71cd 100644 --- a/Utilities/ITK/Utilities/NrrdIO/format.c +++ b/Utilities/ITK/Utilities/NrrdIO/format.c @@ -1,6 +1,6 @@ /* NrrdIO: stand-alone code for basic nrrd functionality - Copyright (C) 2005 Gordon Kindlmann + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah This software is provided 'as-is', without any express or implied @@ -64,12 +64,11 @@ _nrrdFormatUnknown_nameLooksLike(const char *filename) { int _nrrdFormatUnknown_fitsInto(const Nrrd *nrrd, const NrrdEncoding *encoding, int useBiff) { - char me[]="_nrrdFormatUnknown_fitsInto", err[AIR_STRLEN_MED]; + static const char me[]="_nrrdFormatUnknown_fitsInto"; if (!(nrrd && encoding)) { - sprintf(err, "%s: got NULL nrrd (%p) or encoding (%p)", - me, nrrd, encoding); - biffMaybeAdd(NRRD, err, useBiff); + biffMaybeAddf(useBiff, NRRD, "%s: got NULL nrrd (%p) or encoding (%p)", + me, AIR_CAST(void*, nrrd), AIR_CAST(void*, encoding)); return AIR_FALSE; } @@ -90,30 +89,28 @@ _nrrdFormatUnknown_contentStartsLike(NrrdIoState *nio) { int _nrrdFormatUnknown_read(FILE *file, Nrrd *nrrd, NrrdIoState *nio) { - char me[]="_nrrdFormatUnknown_read", err[AIR_STRLEN_MED]; + static const char me[]="_nrrdFormatUnknown_read"; /* insert code here, and remove error handling below */ AIR_UNUSED(file); AIR_UNUSED(nrrd); AIR_UNUSED(nio); - sprintf(err, "%s: ERROR!!! trying to read unknown format", me); - biffAdd(NRRD, err); + biffAddf(NRRD, "%s: ERROR!!! trying to read unknown format", me); return 1; } int _nrrdFormatUnknown_write(FILE *file, const Nrrd *nrrd, NrrdIoState *nio) { - char me[]="_nrrdFormatUnknown_write", err[AIR_STRLEN_MED]; + static const char me[]="_nrrdFormatUnknown_write"; /* insert code here, and remove error handling below */ AIR_UNUSED(file); AIR_UNUSED(nrrd); AIR_UNUSED(nio); - sprintf(err, "%s: ERROR!!! trying to write unknown format", me); - biffAdd(NRRD, err); + biffAddf(NRRD, "%s: ERROR!!! trying to write unknown format", me); return 1; } diff --git a/Utilities/ITK/Utilities/NrrdIO/formatEPS.c b/Utilities/ITK/Utilities/NrrdIO/formatEPS.c index 92233c92a290edd7eb63a739de35043d717234af..5c0cd4786a7f93e3df0fd944e304175e1513afac 100644 --- a/Utilities/ITK/Utilities/NrrdIO/formatEPS.c +++ b/Utilities/ITK/Utilities/NrrdIO/formatEPS.c @@ -1,6 +1,6 @@ /* NrrdIO: stand-alone code for basic nrrd functionality - Copyright (C) 2005 Gordon Kindlmann + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah This software is provided 'as-is', without any express or implied diff --git a/Utilities/ITK/Utilities/NrrdIO/formatNRRD.c b/Utilities/ITK/Utilities/NrrdIO/formatNRRD.c index 8140457ba4d01773eb9f7b663497ea1ee67e91a1..940e660c3d272b22b91e2449cf91b2422ef150e7 100644 --- a/Utilities/ITK/Utilities/NrrdIO/formatNRRD.c +++ b/Utilities/ITK/Utilities/NrrdIO/formatNRRD.c @@ -1,6 +1,6 @@ /* NrrdIO: stand-alone code for basic nrrd functionality - Copyright (C) 2005 Gordon Kindlmann + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah This software is provided 'as-is', without any express or implied @@ -45,17 +45,28 @@ nrrdIoStateDataFileIterBegin(NrrdIoState *nio) { return; } -#define _NEED_PATH(str) ('/' != (str)[0] && strcmp("-", (str))) +/* this macro suggested by Bryan Worthen */ +/* if str = '-', strcmp() is 0, && short circuits, return false +** else str != '-' +** if str[1] = ':', its probably a windows full path, != is 0, return false +** else str[1] != ':' +** if str[0] = '/', its a normal full path, return false +*/ +#define _NEED_PATH(str) (strcmp("-", (str)) \ + && ':' != (str)[1] \ + && '/' != (str)[0]) /* ** this is responsible for the header-relative path processing ** ** NOTE: if the filename is "-", then because it does not start with '/', ** it would normally be prefixed by nio->path, so it needs special handling +** +** NOTE: this should work okay with nio->headerStringRead, I think ... */ int nrrdIoStateDataFileIterNext(FILE **fileP, NrrdIoState *nio, int reading) { - char me[]="nrrdIoStateDataFileIterNext", *err; + static const char me[]="nrrdIoStateDataFileIterNext"; char *fname=NULL; int ii, needPath; unsigned int num, fi; @@ -66,20 +77,14 @@ nrrdIoStateDataFileIterNext(FILE **fileP, NrrdIoState *nio, int reading) { airMopAdd(mop, (void*)fileP, (airMopper)airSetNull, airMopOnError); if (!fileP) { - if ((err = (char*)malloc(AIR_STRLEN_MED))) { - sprintf(err, "%s: got NULL pointer", me); - biffAdd(NRRD, err); free(err); - } + biffAddf(NRRD, "%s: got NULL pointer", me); airMopError(mop); return 1; } if (!_nrrdDataFNNumber(nio)) { - if ((err = (char*)malloc(AIR_STRLEN_MED))) { - sprintf(err, "%s: there appear to be zero datafiles!", me); - biffAdd(NRRD, err); free(err); - } + biffAddf(NRRD, "%s: there appear to be zero datafiles!", me); airMopError(mop); return 1; } - + nio->dataFNIndex++; if (nio->dataFNIndex >= (int)_nrrdDataFNNumber(nio)) { /* there is no next data file, but we don't make that an error */ @@ -104,18 +109,12 @@ nrrdIoStateDataFileIterNext(FILE **fileP, NrrdIoState *nio, int reading) { } } if (needPath && !airStrlen(nio->path)) { - if ((err = (char*)malloc(AIR_STRLEN_MED))) { - sprintf(err, "%s: need nio->path for header-relative datafiles", me); - biffAdd(NRRD, err); free(err); - } + biffAddf(NRRD, "%s: need nio->path for header-relative datafiles", me); airMopError(mop); return 1; } fname = (char*)malloc(airStrlen(nio->path) + strlen("/") + maxl + 1); if (!fname) { - if ((err = (char*)malloc(AIR_STRLEN_MED))) { - sprintf(err, "%s: couldn't allocate filename buffer", me); - biffAdd(NRRD, err); free(err); - } + biffAddf(NRRD, "%s: couldn't allocate filename buffer", me); airMopError(mop); return 1; } airMopAdd(mop, fname, airFree, airMopAlways); @@ -157,17 +156,20 @@ nrrdIoStateDataFileIterNext(FILE **fileP, NrrdIoState *nio, int reading) { if (nio->dataFNFormat || nio->dataFNArr->len) { *fileP = airFopen(fname, reading ? stdin : stdout, reading ? "rb" : "wb"); if (!(*fileP)) { - if ((err = (char*)malloc(strlen(fname) + AIR_STRLEN_MED))) { - sprintf(err, "%s: couldn't open \"%s\" (data file %d of %d) for %s", - me, fname, nio->dataFNIndex+1, (int)_nrrdDataFNNumber(nio), - reading ? "reading" : "writing"); - biffAdd(NRRD, err); free(err); - } + biffAddf(NRRD, "%s: couldn't open \"%s\" (data file %d of %d) for %s", + me, fname, nio->dataFNIndex+1, (int)_nrrdDataFNNumber(nio), + reading ? "reading" : "writing"); airMopError(mop); return 1; } } else { /* data file is attached */ - *fileP = nio->headerFile; + if (nio->headerStringRead) { + /* except we were never reading from a file to begin with, but this + isn't an error */ + *fileP = NULL; + } else { + *fileP = nio->headerFile; + } } airMopOkay(mop); @@ -215,12 +217,11 @@ _nrrdFormatNRRD_nameLooksLike(const char *filename) { int _nrrdFormatNRRD_fitsInto(const Nrrd *nrrd, const NrrdEncoding *encoding, int useBiff) { - char me[]="_nrrdFormatNRRD_fitsInto", err[AIR_STRLEN_MED]; + static const char me[]="_nrrdFormatNRRD_fitsInto"; if (!( nrrd && encoding )) { - sprintf(err, "%s: got NULL nrrd (%p) or encoding (%p)", - me, nrrd, encoding); - biffMaybeAdd(NRRD, err, useBiff); + biffMaybeAddf(useBiff, NRRD, "%s: got NULL nrrd (%p) or encoding (%p)", + me, AIR_CAST(void*, nrrd), AIR_CAST(void*, encoding)); return AIR_FALSE; } @@ -253,39 +254,39 @@ _nrrdFormatNRRD_contentStartsLike(NrrdIoState *nio) { ** */ int -_nrrdHeaderCheck (Nrrd *nrrd, NrrdIoState *nio, int checkSeen) { - char me[]="_nrrdHeaderCheck", err[AIR_STRLEN_MED]; +_nrrdHeaderCheck(Nrrd *nrrd, NrrdIoState *nio, int checkSeen) { + static const char me[]="_nrrdHeaderCheck"; int i; if (checkSeen) { for (i=1; i<=NRRD_FIELD_MAX; i++) { if (_nrrdFieldRequired[i] && !nio->seen[i]) { - sprintf(err, "%s: didn't see required field: %s", - me, airEnumStr(nrrdField, i)); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: didn't see required field: %s", + me, airEnumStr(nrrdField, i)); + return 1; } } } if (nrrdTypeBlock == nrrd->type && !nrrd->blockSize) { - sprintf(err, "%s: type is %s, but missing field: %s", me, - airEnumStr(nrrdType, nrrdTypeBlock), - airEnumStr(nrrdField, nrrdField_block_size)); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: type is %s, but missing field: %s", me, + airEnumStr(nrrdType, nrrdTypeBlock), + airEnumStr(nrrdField, nrrdField_block_size)); + return 1; } if (!nrrdElementSize(nrrd)) { - sprintf(err, "%s: nrrd reports zero element size!", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: nrrd reports zero element size!", me); + return 1; } /* _nrrdReadNrrdParse_sizes() checks axis[i].size, which completely determines the return of nrrdElementNumber() */ if (airEndianUnknown == nio->endian && nio->encoding->endianMatters && 1 != nrrdElementSize(nrrd)) { - sprintf(err, "%s: type (%s) and encoding (%s) require %s info", me, - airEnumStr(nrrdType, nrrd->type), - nio->encoding->name, - airEnumStr(nrrdField, nrrdField_endian)); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: type (%s) and encoding (%s) require %s info", me, + airEnumStr(nrrdType, nrrd->type), + nio->encoding->name, + airEnumStr(nrrdField, nrrdField_endian)); + return 1; } /* we don't really try to enforce consistency with the @@ -298,20 +299,19 @@ _nrrdHeaderCheck (Nrrd *nrrd, NrrdIoState *nio, int checkSeen) { } /* -** NOTE: currently, this will read advanced NRRD format features -** from old NRRD files (with old magic), such as key/value pairs -** from a NRRD0001 file, without any complaints even though strictly -** speaking these are violations of the format. +** NOTE: currently, this will read, without complaints or errors, +** newer NRRD format features from older NRRD files (as indicated by +** magic), such as key/value pairs from a NRRD0001 file, even though +** strictly speaking these are violations of the format. ** ** NOTE: by giving a NULL "file", you can make this function basically ** do the work of reading in datafiles, without any header parsing */ int _nrrdFormatNRRD_read(FILE *file, Nrrd *nrrd, NrrdIoState *nio) { - char me[]="_nrrdFormatNRRD_read", - *err; /* NOTE: err really does have to be dynamically - allocated because of the arbitrary-sized input lines - that it may have to copy */ + static const char me[]="_nrrdFormatNRRD_read"; + /* Dynamically allocated for space reasons. */ + /* MWC: These strlen usages look really unsafe. */ int ret; unsigned int llen; size_t valsPerPiece; @@ -322,93 +322,75 @@ _nrrdFormatNRRD_read(FILE *file, Nrrd *nrrd, NrrdIoState *nio) { nrrdIoStateDataFileIterNext() */ nio->headerFile = file; - if (file) { + /* HEY: GLK forgets the context in which file might be reasonably NULL + but on Fri Sep 23 09:48:41 EDT 2005 this was "if (file) { ..." */ + /* nio->headerStringRead is NULL whenever IO from string is not being done */ + if (file || nio->headerStringRead) { if (!_nrrdFormatNRRD_contentStartsLike(nio)) { - if ((err = (char*)malloc(AIR_STRLEN_MED))) { - sprintf(err, "%s: this doesn't look like a %s file", me, - nrrdFormatNRRD->name); - biffAdd(NRRD, err); free(err); - } + biffAddf(NRRD, "%s: this doesn't look like a %s file", me, + nrrdFormatNRRD->name); return 1; } /* parse all the header lines */ do { nio->pos = 0; if (_nrrdOneLine(&llen, nio, file)) { - if ((err = (char*)malloc(AIR_STRLEN_MED))) { - sprintf(err, "%s: trouble getting line of header", me); - biffAdd(NRRD, err); free(err); - } + biffAddf(NRRD, "%s: trouble getting line of header", me); return 1; } if (llen > 1) { ret = _nrrdReadNrrdParseField(nio, AIR_TRUE); if (!ret) { - if ((err = (char*)malloc(AIR_STRLEN_MED + strlen(nio->line)))) { - sprintf(err, "%s: trouble parsing field in \"%s\"", me, nio->line); - biffAdd(NRRD, err); free(err); - } + biffAddf(NRRD, "%s: trouble parsing field in \"%s\"", + me, nio->line); return 1; } /* comments and key/values are allowed multiple times */ if (nio->seen[ret] && !(ret == nrrdField_comment || ret == nrrdField_keyvalue)) { - if ((err = (char*)malloc(AIR_STRLEN_MED))) { - sprintf(err, "%s: already set field %s", me, - airEnumStr(nrrdField, ret)); - biffAdd(NRRD, err); free(err); - } + biffAddf(NRRD, "%s: already set field %s", me, + airEnumStr(nrrdField, ret)); return 1; } if (nrrdFieldInfoParse[ret](file, nrrd, nio, AIR_TRUE)) { - if ((err = (char*)malloc(AIR_STRLEN_MED))) { - /* HEY: this error message should be printing out all the - per-axis fields, not just the first - HEY: if your stupid parsing functions didn't modify - nio->line then you wouldn't have this problem ... */ - sprintf(err, "%s: trouble parsing %s info \"%s\"", me, - airEnumStr(nrrdField, ret), nio->line + nio->pos); - biffAdd(NRRD, err); free(err); - } + /* HEY: this error message should be printing out all the + per-axis fields, not just the first + HEY: if your stupid parsing functions didn't modify + nio->line then you wouldn't have this problem ... */ + biffAddf(NRRD, "%s: trouble parsing %s info \"%s\"", me, + airEnumStr(nrrdField, ret), nio->line + nio->pos); return 1; } nio->seen[ret] = AIR_TRUE; } } while (llen > 1); /* either - 0 == llen: we're at EOF, or + 0 == llen: we're at EOF (or end of nio->headerStringRead), or 1 == llen: we just read the empty line seperating header from data */ - if (0 == llen + if (0 == llen + && !nio->headerStringRead && !nio->dataFNFormat && 0 == nio->dataFNArr->len) { - /* we're at EOF, but there's apparently no seperate data file */ - if ((err = (char*)malloc(AIR_STRLEN_MED))) { - sprintf(err, "%s: hit end of header, but no \"%s\" given", me, - airEnumStr(nrrdField, nrrdField_data_file)); - biffAdd(NRRD, err); free(err); - } + /* we're at EOF, we're not reading from a string, but there's + apparently no seperate data file */ + biffAddf(NRRD, "%s: hit end of header, but no \"%s\" given", me, + airEnumStr(nrrdField, nrrdField_data_file)); return 1; } } if (_nrrdHeaderCheck(nrrd, nio, !!file)) { - if ((err = (char*)malloc(AIR_STRLEN_MED))) { - sprintf(err, "%s: %s", me, - (llen ? "finished reading header, but there were problems" - : "hit EOF before seeing a complete valid header")); - biffAdd(NRRD, err); free(err); - } + biffAddf(NRRD, "%s: %s", me, + (llen ? "finished reading header, but there were problems" + : "hit EOF before seeing a complete valid header")); return 1; } - - /* we seemed to have read in a valid header; now allocate the memory */ - /* for directIO-compatible allocation we need to get the first datafile */ + /* we seemed to have read in a valid header; now allocate the memory. + For directIO-compatible allocation we need to get the first datafile */ nrrdIoStateDataFileIterBegin(nio); + /* NOTE: if nio->headerStringRead, this may set dataFile to NULL */ if (nrrdIoStateDataFileIterNext(&dataFile, nio, AIR_TRUE)) { - if ((err = (char*)malloc(AIR_STRLEN_MED))) { - sprintf(err, "%s: couldn't open the first datafile", me); - biffAdd(NRRD, err); free(err); - } + biffAddf(NRRD, "%s: couldn't open the first datafile", me); return 1; } if (nio->skipData) { @@ -416,10 +398,7 @@ _nrrdFormatNRRD_read(FILE *file, Nrrd *nrrd, NrrdIoState *nio) { data = NULL; } else { if (_nrrdCalloc(nrrd, nio, dataFile)) { - if ((err = (char*)malloc(AIR_STRLEN_MED))) { - sprintf(err, "%s: couldn't allocate memory for data", me); - biffAdd(NRRD, err); free(err); - } + biffAddf(NRRD, "%s: couldn't allocate memory for data", me); return 1; } data = (char*)nrrd->data; @@ -430,23 +409,17 @@ _nrrdFormatNRRD_read(FILE *file, Nrrd *nrrd, NrrdIoState *nio) { caller might have set keepNrrdDataFileOpen, in which case you need to do any line or byte skipping if it is specified */ valsPerPiece = nrrdElementNumber(nrrd)/_nrrdDataFNNumber(nio); - do { + while (dataFile) { /* ---------------- skip, if need be */ if (nrrdLineSkip(dataFile, nio)) { - if ((err = (char*)malloc(AIR_STRLEN_MED))) { - sprintf(err, "%s: couldn't skip lines", me); - biffAdd(NRRD, err); free(err); - } + biffAddf(NRRD, "%s: couldn't skip lines", me); return 1; } if (!nio->encoding->isCompression) { /* bytes are skipped here for non-compression encodings, but are skipped within the decompressed stream for compression encodings */ if (nrrdByteSkip(dataFile, nrrd, nio)) { - if ((err = (char*)malloc(AIR_STRLEN_MED))) { - sprintf(err, "%s: couldn't skip bytes", me); - biffAdd(NRRD, err); free(err); - } + biffAddf(NRRD, "%s: couldn't skip bytes", me); return 1; } } @@ -460,10 +433,7 @@ _nrrdFormatNRRD_read(FILE *file, Nrrd *nrrd, NrrdIoState *nio) { if (2 <= nrrdStateVerboseIO) { fprintf(stderr, "error!\n"); } - if ((err = (char*)malloc(AIR_STRLEN_MED))) { - sprintf(err, "%s:", me); - biffAdd(NRRD, err); free(err); - } + biffAddf(NRRD, "%s:", me); return 1; } } @@ -480,15 +450,12 @@ _nrrdFormatNRRD_read(FILE *file, Nrrd *nrrd, NrrdIoState *nio) { } data += valsPerPiece*nrrdElementSize(nrrd); if (nrrdIoStateDataFileIterNext(&dataFile, nio, AIR_TRUE)) { - if ((err = (char*)malloc(AIR_STRLEN_MED))) { - sprintf(err, "%s: couldn't get the next datafile", me); - biffAdd(NRRD, err); free(err); - } + biffAddf(NRRD, "%s: couldn't get the next datafile", me); return 1; } - } while (dataFile); + } - if (airEndianUnknown != nio->endian) { + if (airEndianUnknown != nio->endian && nrrd->data) { /* we positively know the endianness of data just read */ if (1 < nrrdElementSize(nrrd) && nio->encoding->endianMatters @@ -500,7 +467,7 @@ _nrrdFormatNRRD_read(FILE *file, Nrrd *nrrd, NrrdIoState *nio) { } nrrdSwapEndian(nrrd); if (2 <= nrrdStateVerboseIO) { - fprintf(stderr, "done)"); + fprintf(stderr, "done)\n"); fflush(stderr); } } @@ -511,7 +478,8 @@ _nrrdFormatNRRD_read(FILE *file, Nrrd *nrrd, NrrdIoState *nio) { int _nrrdFormatNRRD_write(FILE *file, const Nrrd *nrrd, NrrdIoState *nio) { - char me[]="_nrrdFormatNRRD_write", err[AIR_STRLEN_MED], *tmp; + static const char me[]="_nrrdFormatNRRD_write"; + char strbuf[AIR_STRLEN_MED], *strptr, *tmp; int ii; unsigned int jj; airArray *mop; @@ -521,15 +489,23 @@ _nrrdFormatNRRD_write(FILE *file, const Nrrd *nrrd, NrrdIoState *nio) { mop = airMopNew(); + if (!(file + || nio->headerStringWrite + || nio->learningHeaderStrlen)) { + biffAddf(NRRD, "%s: have no file or string to write to, nor are " + "learning header string length", me); + airMopError(mop); return 1; + } if (nrrdTypeBlock == nrrd->type && nrrdEncodingAscii == nio->encoding) { - sprintf(err, "%s: can't write nrrd type %s to %s", me, - airEnumStr(nrrdType, nrrdTypeBlock), - nrrdEncodingAscii->name); - biffAdd(NRRD, err); airMopError(mop); return 1; + biffAddf(NRRD, "%s: can't write nrrd type %s with %s encoding", me, + airEnumStr(nrrdType, nrrdTypeBlock), + nrrdEncodingAscii->name); + airMopError(mop); return 1; } /* record where the header is being written to for the sake of - nrrdIoStateDataFileIterNext() */ + nrrdIoStateDataFileIterNext(). This may be NULL if + nio->headerStringWrite is non-NULL */ nio->headerFile = file; /* we have to make sure that the data filename information is set @@ -549,53 +525,122 @@ _nrrdFormatNRRD_write(FILE *file, const Nrrd *nrrd, NrrdIoState *nio) { which is a useful way for the user to explicitly set the output data filename (as with unu make -od) */ if (!( !!airStrlen(nio->path) && !!airStrlen(nio->base) )) { - sprintf(err, "%s: can't create data file name: nio's " - "path and base empty", me); - biffAdd(NRRD, err); airMopError(mop); return 1; + biffAddf(NRRD, "%s: can't create data file name: nio's " + "path and base empty", me); + airMopError(mop); return 1; } tmp = (char*)malloc(strlen(nio->base) + strlen(".") + strlen(nio->encoding->suffix) + 1); if (!tmp) { - sprintf(err, "%s: couldn't allocate data filename", me); - biffAdd(NRRD, err); airMopError(mop); return 1; + biffAddf(NRRD, "%s: couldn't allocate data filename", me); + airMopError(mop); return 1; } airMopAdd(mop, tmp, airFree, airMopOnError); sprintf(tmp, "%s.%s", nio->base, nio->encoding->suffix); jj = airArrayLenIncr(nio->dataFNArr, 1); /* HEY error checking */ nio->dataFN[jj] = tmp; } - - fprintf(file, "%s%04d\n", MAGIC, _nrrdFormatNRRD_whichVersion(nrrd, nio)); - /* print out the advertisement about where to get the file format */ - fprintf(file, "# %s\n", _nrrdFormatURLLine0); - fprintf(file, "# %s\n", _nrrdFormatURLLine1); + /* the magic is in fact the first thing to be written */ + if (file) { + fprintf(file, "%s%04d\n", MAGIC, _nrrdFormatNRRD_whichVersion(nrrd, nio)); + } else if (nio->headerStringWrite) { + sprintf(nio->headerStringWrite, "%s%04d\n", + MAGIC, _nrrdFormatNRRD_whichVersion(nrrd, nio)); + } else { + nio->headerStrlen = AIR_CAST(unsigned int, strlen(MAGIC) + strlen("0000")) + 1; + } + + /* write the advertisement about where to get the file format */ + if (file) { + fprintf(file, "# %s\n", _nrrdFormatURLLine0); + fprintf(file, "# %s\n", _nrrdFormatURLLine1); + } else if (nio->headerStringWrite) { + sprintf(strbuf, "# %s\n", _nrrdFormatURLLine0); + strcat(nio->headerStringWrite, strbuf); + sprintf(strbuf, "# %s\n", _nrrdFormatURLLine1); + strcat(nio->headerStringWrite, strbuf); + } else { + nio->headerStrlen += sprintf(strbuf, "# %s\n", _nrrdFormatURLLine0); + nio->headerStrlen += sprintf(strbuf, "# %s\n", _nrrdFormatURLLine1); + } /* this is where the majority of the header printing happens */ for (ii=1; ii<=NRRD_FIELD_MAX; ii++) { if (_nrrdFieldInteresting(nrrd, nio, ii)) { - _nrrdFprintFieldInfo (file, "", nrrd, nio, ii); + if (file) { + _nrrdFprintFieldInfo (file, "", nrrd, nio, ii); + } else if (nio->headerStringWrite) { + _nrrdSprintFieldInfo(&strptr, "", nrrd, nio, ii); + if (strptr) { + strcat(nio->headerStringWrite, strptr); + strcat(nio->headerStringWrite, "\n"); + free(strptr); + strptr = NULL; + } + } else { + _nrrdSprintFieldInfo(&strptr, "", nrrd, nio, ii); + if (strptr) { + nio->headerStrlen += AIR_CAST(unsigned int, strlen(strptr)); + nio->headerStrlen += AIR_CAST(unsigned int, strlen("\n")); + free(strptr); + strptr = NULL; + } + } } } /* comments and key/values handled differently */ for (jj=0; jj<nrrd->cmtArr->len; jj++) { - fprintf(file, "%c %s\n", NRRD_COMMENT_CHAR, nrrd->cmt[jj]); + if (file) { + fprintf(file, "%c %s\n", NRRD_COMMENT_CHAR, nrrd->cmt[jj]); + } else if (nio->headerStringWrite) { + strptr = (char*)malloc(1 + strlen(" ") + + strlen(nrrd->cmt[jj]) + strlen("\n") + 1); + sprintf(strptr, "%c %s\n", NRRD_COMMENT_CHAR, nrrd->cmt[jj]); + strcat(nio->headerStringWrite, strptr); + free(strptr); + strptr = NULL; + } else { + nio->headerStrlen += (1 + AIR_CAST(unsigned int, strlen(" ") + + strlen(nrrd->cmt[jj]) + strlen("\n")) + 1); + } } for (jj=0; jj<nrrd->kvpArr->len; jj++) { - _nrrdKeyValueFwrite(file, NULL, nrrd->kvp[0 + 2*jj], nrrd->kvp[1 + 2*jj]); + if (file) { + _nrrdKeyValueWrite(file, NULL, + NULL, nrrd->kvp[0 + 2*jj], nrrd->kvp[1 + 2*jj]); + } else if (nio->headerStringWrite) { + _nrrdKeyValueWrite(NULL, &strptr, + NULL, nrrd->kvp[0 + 2*jj], nrrd->kvp[1 + 2*jj]); + if (strptr) { + strcat(nio->headerStringWrite, strptr); + free(strptr); + strptr = NULL; + } + } else { + _nrrdKeyValueWrite(NULL, &strptr, + NULL, nrrd->kvp[0 + 2*jj], nrrd->kvp[1 + 2*jj]); + if (strptr) { + nio->headerStrlen += AIR_CAST(unsigned int, strlen(strptr)); + free(strptr); + strptr = NULL; + } + } } - if (!( nio->detachedHeader || _nrrdDataFNNumber(nio) > 1 )) { - fprintf(file, "\n"); + if (file) { + if (!( nio->detachedHeader || _nrrdDataFNNumber(nio) > 1 )) { + fprintf(file, "\n"); + } } - if (!nio->skipData) { + if (file && !nio->skipData) { nrrdIoStateDataFileIterBegin(nio); if (nrrdIoStateDataFileIterNext(&dataFile, nio, AIR_FALSE)) { - sprintf(err, "%s: couldn't write the first datafile", me); - biffAdd(NRRD, err); airMopError(mop); return 1; + biffAddf(NRRD, "%s: couldn't write the first datafile", me); + airMopError(mop); return 1; } valsPerPiece = nrrdElementNumber(nrrd)/_nrrdDataFNNumber(nio); @@ -610,8 +655,8 @@ _nrrdFormatNRRD_write(FILE *file, const Nrrd *nrrd, NrrdIoState *nio) { if (2 <= nrrdStateVerboseIO) { fprintf(stderr, "error!\n"); } - sprintf(err, "%s: couldn't write %s data", me, nio->encoding->name); - biffAdd(NRRD, err); airMopError(mop); return 1; + biffAddf(NRRD, "%s: couldn't write %s data", me, nio->encoding->name); + airMopError(mop); return 1; } if (2 <= nrrdStateVerboseIO) { fprintf(stderr, "done)\n"); @@ -622,8 +667,8 @@ _nrrdFormatNRRD_write(FILE *file, const Nrrd *nrrd, NrrdIoState *nio) { } data += valsPerPiece*nrrdElementSize(nrrd); if (nrrdIoStateDataFileIterNext(&dataFile, nio, AIR_TRUE)) { - sprintf(err, "%s: couldn't get the next datafile", me); - biffAdd(NRRD, err); airMopError(mop); return 1; + biffAddf(NRRD, "%s: couldn't get the next datafile", me); + airMopError(mop); return 1; } } while (dataFile); } diff --git a/Utilities/ITK/Utilities/NrrdIO/formatPNG.c b/Utilities/ITK/Utilities/NrrdIO/formatPNG.c index 55045120f5ec63c3b20862772a574dbdf1ca890a..b6aad20a6783646aa4668743c6f1ffe87b4bb084 100644 --- a/Utilities/ITK/Utilities/NrrdIO/formatPNG.c +++ b/Utilities/ITK/Utilities/NrrdIO/formatPNG.c @@ -1,6 +1,6 @@ /* NrrdIO: stand-alone code for basic nrrd functionality - Copyright (C) 2005 Gordon Kindlmann + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah This software is provided 'as-is', without any express or implied diff --git a/Utilities/ITK/Utilities/NrrdIO/formatPNM.c b/Utilities/ITK/Utilities/NrrdIO/formatPNM.c index b646359d34da493dc2176d07a799c16c12a86d5a..dc8a4ce4343f83785638423b2a140187dd2d1115 100644 --- a/Utilities/ITK/Utilities/NrrdIO/formatPNM.c +++ b/Utilities/ITK/Utilities/NrrdIO/formatPNM.c @@ -1,6 +1,6 @@ /* NrrdIO: stand-alone code for basic nrrd functionality - Copyright (C) 2005 Gordon Kindlmann + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah This software is provided 'as-is', without any express or implied diff --git a/Utilities/ITK/Utilities/NrrdIO/formatText.c b/Utilities/ITK/Utilities/NrrdIO/formatText.c index d180efa504411406572e20a83a60ac2fdea34187..59edb228fcbc94f895fce13d09dab9e510bf3248 100644 --- a/Utilities/ITK/Utilities/NrrdIO/formatText.c +++ b/Utilities/ITK/Utilities/NrrdIO/formatText.c @@ -1,6 +1,6 @@ /* NrrdIO: stand-alone code for basic nrrd functionality - Copyright (C) 2005 Gordon Kindlmann + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah This software is provided 'as-is', without any express or implied diff --git a/Utilities/ITK/Utilities/NrrdIO/formatVTK.c b/Utilities/ITK/Utilities/NrrdIO/formatVTK.c index 4cf6612a3fe00e3b06d606fccab3089f5c77ed79..b28c195c4846dd16307c7aee330c6e103c3fe8dd 100644 --- a/Utilities/ITK/Utilities/NrrdIO/formatVTK.c +++ b/Utilities/ITK/Utilities/NrrdIO/formatVTK.c @@ -1,6 +1,6 @@ /* NrrdIO: stand-alone code for basic nrrd functionality - Copyright (C) 2005 Gordon Kindlmann + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah This software is provided 'as-is', without any express or implied diff --git a/Utilities/ITK/Utilities/NrrdIO/gzio.c b/Utilities/ITK/Utilities/NrrdIO/gzio.c index e8bb06e98a9843654874e3be68c70b96dcf68b81..540954a2fa2e65efb19fe3071e5cb042d82e5d52 100644 --- a/Utilities/ITK/Utilities/NrrdIO/gzio.c +++ b/Utilities/ITK/Utilities/NrrdIO/gzio.c @@ -1,6 +1,6 @@ /* NrrdIO: stand-alone code for basic nrrd functionality - Copyright (C) 2005 Gordon Kindlmann + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah This software is provided 'as-is', without any express or implied @@ -120,17 +120,12 @@ static const char *_nrrdGzErrMsg[10] = { #define _NRRD_GZ_ERR_MSG(err) _nrrdGzErrMsg[Z_NEED_DICT-(err)] -static int _nrrdGzGetByte (_NrrdGzStream *s); -static void _nrrdGzCheckHeader (_NrrdGzStream *s); -static int _nrrdGzDestroy (_NrrdGzStream *s); -static int _nrrdGzDoFlush (gzFile file, int flush); -static void _nrrdGzPutLong (FILE *file, uLong x); -static uLong _nrrdGzGetLong (_NrrdGzStream *s); - -gzFile _nrrdGzOpen (FILE* fd, const char *mode); -int _nrrdGzClose (gzFile file); -int _nrrdGzRead (gzFile file, voidp buf, unsigned int len, unsigned int* read); -int _nrrdGzWrite (gzFile file, const voidp buf, unsigned int len, unsigned int* written); +/* some forward declarations for things in this file */ +static void _nrrdGzCheckHeader(_NrrdGzStream *s); +static int _nrrdGzDestroy(_NrrdGzStream *s); +static int _nrrdGzDoFlush(gzFile file, int flush); +static void _nrrdGzPutLong(FILE *file, uLong x); +static uLong _nrrdGzGetLong(_NrrdGzStream *s); /* ** _nrrdGzOpen() @@ -163,7 +158,7 @@ int _nrrdGzWrite (gzFile file, const voidp buf, unsigned int len, unsigned int* */ gzFile _nrrdGzOpen(FILE* fd, const char* mode) { - char me[] = "_nrrdGzOpen", err[AIR_STRLEN_MED]; + static const char me[]="_nrrdGzOpen"; int error; int level = Z_DEFAULT_COMPRESSION; /* compression level */ int strategy = Z_DEFAULT_STRATEGY; /* compression strategy */ @@ -173,15 +168,13 @@ _nrrdGzOpen(FILE* fd, const char* mode) { char *m = fmode; if (!mode) { - sprintf(err, "%s: no file mode specified", me); - biffAdd(NRRD, err); + biffAddf(NRRD, "%s: no file mode specified", me); return Z_NULL; } /* allocate stream struct */ s = (_NrrdGzStream *)calloc(1, sizeof(_NrrdGzStream)); if (!s) { - sprintf(err, "%s: failed to allocate stream buffer", me); - biffAdd(NRRD, err); + biffAddf(NRRD, "%s: failed to allocate stream buffer", me); return Z_NULL; } /* initialize stream struct */ @@ -213,11 +206,10 @@ _nrrdGzOpen(FILE* fd, const char* mode) { } } while (*p++ && m != fmode + sizeof(fmode)); if (s->mode == '\0') { - sprintf(err, "%s: invalid file mode", me); - biffAdd(NRRD, err); + biffAddf(NRRD, "%s: invalid file mode", me); return _nrrdGzDestroy(s), (gzFile)Z_NULL; } - + if (s->mode == 'w') { error = deflateInit2(&(s->stream), level, Z_DEFLATED, -MAX_WBITS, _NRRD_DEF_MEM_LEVEL, @@ -226,8 +218,7 @@ _nrrdGzOpen(FILE* fd, const char* mode) { s->stream.next_out = s->outbuf = (Byte*)calloc(1, _NRRD_Z_BUFSIZE); if (error != Z_OK || s->outbuf == Z_NULL) { - sprintf(err, "%s: stream init failed", me); - biffAdd(NRRD, err); + biffAddf(NRRD, "%s: stream init failed", me); return _nrrdGzDestroy(s), (gzFile)Z_NULL; } } else { @@ -241,8 +232,7 @@ _nrrdGzOpen(FILE* fd, const char* mode) { * present after the compressed stream. */ if (error != Z_OK || s->inbuf == Z_NULL) { - sprintf(err, "%s: stream init failed", me); - biffAdd(NRRD, err); + biffAddf(NRRD, "%s: stream init failed", me); return _nrrdGzDestroy(s), (gzFile)Z_NULL; } } @@ -250,8 +240,7 @@ _nrrdGzOpen(FILE* fd, const char* mode) { errno = 0; s->file = fd; if (s->file == NULL) { - sprintf(err, "%s: null file pointer", me); - biffAdd(NRRD, err); + biffAddf(NRRD, "%s: null file pointer", me); return _nrrdGzDestroy(s), (gzFile)Z_NULL; } if (s->mode == 'w') { @@ -282,22 +271,19 @@ _nrrdGzOpen(FILE* fd, const char* mode) { ** and deallocates the (de)compression state. */ int -_nrrdGzClose (gzFile file) -{ - char me[] = "_nrrdGzClose", err[AIR_STRLEN_MED]; +_nrrdGzClose (gzFile file) { + static const char me[]="_nrrdGzClose"; int error; _NrrdGzStream *s = (_NrrdGzStream*)file; if (s == NULL) { - sprintf(err, "%s: invalid stream", me); - biffAdd(NRRD, err); + biffAddf(NRRD, "%s: invalid stream", me); return 1; } if (s->mode == 'w') { error = _nrrdGzDoFlush(file, Z_FINISH); if (error != Z_OK) { - sprintf(err, "%s: failed to flush pending data", me); - biffAdd(NRRD, err); + biffAddf(NRRD, "%s: failed to flush pending data", me); return _nrrdGzDestroy((_NrrdGzStream*)file); } _nrrdGzPutLong(s->file, s->crc); @@ -313,22 +299,20 @@ _nrrdGzClose (gzFile file) ** Returns the number of bytes actually read (0 for end of file). */ int -_nrrdGzRead (gzFile file, voidp buf, unsigned int len, unsigned int* read) { - char me[] = "_nrrdGzRead", err[AIR_STRLEN_MED]; +_nrrdGzRead(gzFile file, voidp buf, unsigned int len, unsigned int* read) { + static const char me[]="_nrrdGzRead"; _NrrdGzStream *s = (_NrrdGzStream*)file; Bytef *start = (Bytef*)buf; /* starting point for crc computation */ Byte *next_out; /* == stream.next_out but not forced far (for MSDOS) */ if (s == NULL || s->mode != 'r') { - sprintf(err, "%s: invalid stream or file mode", me); - biffAdd(NRRD, err); + biffAddf(NRRD, "%s: invalid stream or file mode", me); *read = 0; return 1; } if (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO) { - sprintf(err, "%s: data read error", me); - biffAdd(NRRD, err); + biffAddf(NRRD, "%s: data read error", me); *read = 0; return 1; } @@ -357,8 +341,8 @@ _nrrdGzRead (gzFile file, voidp buf, unsigned int len, unsigned int* read) { s->stream.avail_in -= n; } if (s->stream.avail_out > 0) { - s->stream.avail_out -= - (uInt)fread(next_out, 1, s->stream.avail_out, s->file); + s->stream.avail_out -= (uInt)fread(next_out, 1, s->stream.avail_out, + s->file); } len -= s->stream.avail_out; s->stream.total_in += len; @@ -422,14 +406,13 @@ _nrrdGzRead (gzFile file, voidp buf, unsigned int len, unsigned int* read) { ** Returns the number of bytes actually written (0 in case of error). */ int -_nrrdGzWrite (gzFile file, const voidp buf, unsigned int len, - unsigned int* written) { - char me[] = "_nrrdGzWrite", err[AIR_STRLEN_MED]; +_nrrdGzWrite(gzFile file, const voidp buf, unsigned int len, + unsigned int* written) { + static const char me[]="_nrrdGzWrite"; _NrrdGzStream *s = (_NrrdGzStream*)file; if (s == NULL || s->mode != 'w') { - sprintf(err, "%s: invalid stream or file mode", me); - biffAdd(NRRD, err); + biffAddf(NRRD, "%s: invalid stream or file mode", me); *written = 0; return 1; } @@ -442,8 +425,7 @@ _nrrdGzWrite (gzFile file, const voidp buf, unsigned int len, s->stream.next_out = s->outbuf; if (fwrite(s->outbuf, 1, _NRRD_Z_BUFSIZE, s->file) != _NRRD_Z_BUFSIZE) { s->z_err = Z_ERRNO; - sprintf(err, "%s: failed to write to file", me); - biffAdd(NRRD, err); + biffAddf(NRRD, "%s: failed to write to file", me); break; } s->stream.avail_out = _NRRD_Z_BUFSIZE; @@ -466,7 +448,7 @@ _nrrdGzWrite (gzFile file, const voidp buf, unsigned int len, */ static int _nrrdGzGetByte(_NrrdGzStream *s) { - char me[] = "_nrrdGzGetByte", err[AIR_STRLEN_MED]; + static const char me[]="_nrrdGzGetByte"; if (s->z_eof) return EOF; if (s->stream.avail_in == 0) { @@ -475,8 +457,7 @@ _nrrdGzGetByte(_NrrdGzStream *s) { if (s->stream.avail_in == 0) { s->z_eof = 1; if (ferror(s->file)) { - sprintf(err, "%s: failed to read from file", me); - biffAdd(NRRD, err); + biffAddf(NRRD, "%s: failed to read from file", me); s->z_err = Z_ERRNO; } return EOF; @@ -500,7 +481,7 @@ _nrrdGzGetByte(_NrrdGzStream *s) { */ static void _nrrdGzCheckHeader(_NrrdGzStream *s) { - char me[] = "_nrrdGzCheckHeader", err[AIR_STRLEN_MED]; + static const char me[]="_nrrdGzCheckHeader"; int method; /* method byte */ int flags; /* flags byte */ uInt len; @@ -522,8 +503,7 @@ _nrrdGzCheckHeader(_NrrdGzStream *s) { method = _nrrdGzGetByte(s); flags = _nrrdGzGetByte(s); if (method != Z_DEFLATED || (flags & _NRRD_RESERVED) != 0) { - sprintf(err, "%s: gzip compression method is not deflate", me); - biffAdd(NRRD, err); + biffAddf(NRRD, "%s: gzip compression method is not deflate", me); s->z_err = Z_DATA_ERROR; return; } @@ -558,12 +538,11 @@ _nrrdGzCheckHeader(_NrrdGzStream *s) { */ static int _nrrdGzDestroy(_NrrdGzStream *s) { - char me[] = "_nrrdGzDestroy", err[AIR_STRLEN_MED]; + static const char me[]="_nrrdGzDestroy"; int error = Z_OK; if (s == NULL) { - sprintf(err, "%s: invalid stream", me); - biffAdd(NRRD, err); + biffAddf(NRRD, "%s: invalid stream", me); return 1; } s->msg = (char *)airFree(s->msg); @@ -575,17 +554,15 @@ _nrrdGzDestroy(_NrrdGzStream *s) { } } if (error != Z_OK) { - sprintf(err, "%s: %s", me, _NRRD_GZ_ERR_MSG(error)); - biffAdd(NRRD, err); + biffAddf(NRRD, "%s: %s", me, _NRRD_GZ_ERR_MSG(error)); } if (s->z_err < 0) error = s->z_err; if (error != Z_OK) { - sprintf(err, "%s: %s", me, _NRRD_GZ_ERR_MSG(error)); - biffAdd(NRRD, err); + biffAddf(NRRD, "%s: %s", me, _NRRD_GZ_ERR_MSG(error)); } s->inbuf = (Byte *)airFree(s->inbuf); s->outbuf = (Byte *)airFree(s->outbuf); - airFree(s); + airFree(s); /* avoiding unused value warnings, no NULL set */ return error != Z_OK; } @@ -596,19 +573,17 @@ _nrrdGzDestroy(_NrrdGzStream *s) { ** flush is the same as in the deflate() function. */ static int -_nrrdGzDoFlush(gzFile file, int flush) -{ - char me[] = "_nrrdGzDoFlush", err[AIR_STRLEN_MED]; +_nrrdGzDoFlush(gzFile file, int flush) { + static const char me[]="_nrrdGzDoFlush"; uInt len; int done = 0; _NrrdGzStream *s = (_NrrdGzStream*)file; if (s == NULL || s->mode != 'w') { - sprintf(err, "%s: invalid stream or file mode", me); - biffAdd(NRRD, err); + biffAddf(NRRD, "%s: invalid stream or file mode", me); return Z_STREAM_ERROR; } - + s->stream.avail_in = 0; /* should be zero already anyway */ for (;;) { diff --git a/Utilities/ITK/Utilities/NrrdIO/itk_NrrdIO_mangle.h b/Utilities/ITK/Utilities/NrrdIO/itk_NrrdIO_mangle.h index 80e67b44987f7f69c2feeb07596703d5ebc493eb..f0b76937a5128b8ea68946c2519a153957af496f 100644 --- a/Utilities/ITK/Utilities/NrrdIO/itk_NrrdIO_mangle.h +++ b/Utilities/ITK/Utilities/NrrdIO/itk_NrrdIO_mangle.h @@ -75,6 +75,7 @@ read-only (R) things (seen on Linux) and "other" (S) things #define airParseStrE itk_airParseStrE #define airParseStrF itk_airParseStrF #define airParseStrI itk_airParseStrI +#define airParseStrLI itk_airParseStrLI #define airParseStrS itk_airParseStrS #define airParseStrUI itk_airParseStrUI #define airParseStrZ itk_airParseStrZ @@ -111,8 +112,11 @@ read-only (R) things (seen on Linux) and "other" (S) things #define airToUpper itk_airToUpper #define airUnescape itk_airUnescape #define _airEnumIndex itk__airEnumIndex +#define _enumPrintVal itk__enumPrintVal #define airEnumDesc itk_airEnumDesc #define airEnumFmtDesc itk_airEnumFmtDesc +#define airEnumLast itk_airEnumLast +#define airEnumPrint itk_airEnumPrint #define airEnumStr itk_airEnumStr #define airEnumUnknown itk_airEnumUnknown #define airEnumVal itk_airEnumVal @@ -127,30 +131,45 @@ read-only (R) things (seen on Linux) and "other" (S) things #define airSinglePrintf itk_airSinglePrintf #define airTeemReleaseDate itk_airTeemReleaseDate #define airTeemVersion itk_airTeemVersion -#define _biffAA itk__biffAA -#define _biffAddErr itk__biffAddErr -#define _biffAddKey itk__biffAddKey -#define _biffCheckKey itk__biffCheckKey -#define _biffErr itk__biffErr -#define _biffFindKey itk__biffFindKey -#define _biffFindMaxAndSum itk__biffFindMaxAndSum -#define _biffGetStr itk__biffGetStr -#define _biffIdx itk__biffIdx -#define _biffInit itk__biffInit -#define _biffNewEntry itk__biffNewEntry -#define _biffNuke itk__biffNuke -#define _biffNukeEntry itk__biffNukeEntry -#define _biffNum itk__biffNum +#define _bmsg itk__bmsg +#define _bmsgAdd itk__bmsgAdd +#define _bmsgArr itk__bmsgArr +#define _bmsgFind itk__bmsgFind +#define _bmsgFindIdx itk__bmsgFindIdx +#define _bmsgFinish itk__bmsgFinish +#define _bmsgNum itk__bmsgNum +#define _bmsgStart itk__bmsgStart #define biffAdd itk_biffAdd +#define biffAddVL itk_biffAddVL +#define biffAddf itk_biffAddf #define biffCheck itk_biffCheck #define biffDone itk_biffDone #define biffGet itk_biffGet #define biffGetDone itk_biffGetDone #define biffGetStrlen itk_biffGetStrlen #define biffMaybeAdd itk_biffMaybeAdd +#define biffMaybeAddf itk_biffMaybeAddf #define biffMove itk_biffMove +#define biffMoveVL itk_biffMoveVL +#define biffMovef itk_biffMovef #define biffSetStr itk_biffSetStr #define biffSetStrDone itk_biffSetStrDone +#define _biffMsgNoop itk__biffMsgNoop +#define biffMsgAdd itk_biffMsgAdd +#define biffMsgAddVL itk_biffMsgAddVL +#define biffMsgAddf itk_biffMsgAddf +#define biffMsgClear itk_biffMsgClear +#define biffMsgLineLenMax itk_biffMsgLineLenMax +#define biffMsgMove itk_biffMsgMove +#define biffMsgMoveVL itk_biffMsgMoveVL +#define biffMsgMovef itk_biffMsgMovef +#define biffMsgNew itk_biffMsgNew +#define biffMsgNix itk_biffMsgNix +#define biffMsgNoop itk_biffMsgNoop +#define biffMsgStrAlloc itk_biffMsgStrAlloc +#define biffMsgStrGet itk_biffMsgStrGet +#define biffMsgStrSet itk_biffMsgStrSet +#define biffMsgStrlen itk_biffMsgStrlen #define _nrrdInsertDBCH itk__nrrdInsertDBCH #define _nrrdInsertDBDB itk__nrrdInsertDBDB #define _nrrdInsertDBFL itk__nrrdInsertDBFL @@ -181,6 +200,16 @@ read-only (R) things (seen on Linux) and "other" (S) things #define _nrrdInsertJNUI itk__nrrdInsertJNUI #define _nrrdInsertJNUL itk__nrrdInsertJNUL #define _nrrdInsertJNUS itk__nrrdInsertJNUS +#define _nrrdInsertUICH itk__nrrdInsertUICH +#define _nrrdInsertUIDB itk__nrrdInsertUIDB +#define _nrrdInsertUIFL itk__nrrdInsertUIFL +#define _nrrdInsertUIJN itk__nrrdInsertUIJN +#define _nrrdInsertUILL itk__nrrdInsertUILL +#define _nrrdInsertUISH itk__nrrdInsertUISH +#define _nrrdInsertUIUC itk__nrrdInsertUIUC +#define _nrrdInsertUIUI itk__nrrdInsertUIUI +#define _nrrdInsertUIUL itk__nrrdInsertUIUL +#define _nrrdInsertUIUS itk__nrrdInsertUIUS #define _nrrdLoadDBCH itk__nrrdLoadDBCH #define _nrrdLoadDBDB itk__nrrdLoadDBDB #define _nrrdLoadDBFL itk__nrrdLoadDBFL @@ -211,6 +240,16 @@ read-only (R) things (seen on Linux) and "other" (S) things #define _nrrdLoadJNUI itk__nrrdLoadJNUI #define _nrrdLoadJNUL itk__nrrdLoadJNUL #define _nrrdLoadJNUS itk__nrrdLoadJNUS +#define _nrrdLoadUICH itk__nrrdLoadUICH +#define _nrrdLoadUIDB itk__nrrdLoadUIDB +#define _nrrdLoadUIFL itk__nrrdLoadUIFL +#define _nrrdLoadUIJN itk__nrrdLoadUIJN +#define _nrrdLoadUILL itk__nrrdLoadUILL +#define _nrrdLoadUISH itk__nrrdLoadUISH +#define _nrrdLoadUIUC itk__nrrdLoadUIUC +#define _nrrdLoadUIUI itk__nrrdLoadUIUI +#define _nrrdLoadUIUL itk__nrrdLoadUIUL +#define _nrrdLoadUIUS itk__nrrdLoadUIUS #define _nrrdLookupDBCH itk__nrrdLookupDBCH #define _nrrdLookupDBDB itk__nrrdLookupDBDB #define _nrrdLookupDBFL itk__nrrdLookupDBFL @@ -241,6 +280,16 @@ read-only (R) things (seen on Linux) and "other" (S) things #define _nrrdLookupJNUI itk__nrrdLookupJNUI #define _nrrdLookupJNUL itk__nrrdLookupJNUL #define _nrrdLookupJNUS itk__nrrdLookupJNUS +#define _nrrdLookupUICH itk__nrrdLookupUICH +#define _nrrdLookupUIDB itk__nrrdLookupUIDB +#define _nrrdLookupUIFL itk__nrrdLookupUIFL +#define _nrrdLookupUIJN itk__nrrdLookupUIJN +#define _nrrdLookupUILL itk__nrrdLookupUILL +#define _nrrdLookupUISH itk__nrrdLookupUISH +#define _nrrdLookupUIUC itk__nrrdLookupUIUC +#define _nrrdLookupUIUI itk__nrrdLookupUIUI +#define _nrrdLookupUIUL itk__nrrdLookupUIUL +#define _nrrdLookupUIUS itk__nrrdLookupUIUS #define _nrrdSprintCH itk__nrrdSprintCH #define _nrrdSprintDB itk__nrrdSprintDB #define _nrrdSprintFL itk__nrrdSprintFL @@ -281,6 +330,16 @@ read-only (R) things (seen on Linux) and "other" (S) things #define _nrrdStoreJNUI itk__nrrdStoreJNUI #define _nrrdStoreJNUL itk__nrrdStoreJNUL #define _nrrdStoreJNUS itk__nrrdStoreJNUS +#define _nrrdStoreUICH itk__nrrdStoreUICH +#define _nrrdStoreUIDB itk__nrrdStoreUIDB +#define _nrrdStoreUIFL itk__nrrdStoreUIFL +#define _nrrdStoreUIJN itk__nrrdStoreUIJN +#define _nrrdStoreUILL itk__nrrdStoreUILL +#define _nrrdStoreUISH itk__nrrdStoreUISH +#define _nrrdStoreUIUC itk__nrrdStoreUIUC +#define _nrrdStoreUIUI itk__nrrdStoreUIUI +#define _nrrdStoreUIUL itk__nrrdStoreUIUL +#define _nrrdStoreUIUS itk__nrrdStoreUIUS #define nrrdDInsert itk_nrrdDInsert #define nrrdDLoad itk_nrrdDLoad #define nrrdDLookup itk_nrrdDLookup @@ -294,15 +353,20 @@ read-only (R) things (seen on Linux) and "other" (S) things #define nrrdILookup itk_nrrdILookup #define nrrdIStore itk_nrrdIStore #define nrrdSprint itk_nrrdSprint -#define nrrdDefCenter itk_nrrdDefCenter -#define nrrdDefSpacing itk_nrrdDefSpacing -#define nrrdDefWriteBareText itk_nrrdDefWriteBareText -#define nrrdDefWriteCharsPerLine itk_nrrdDefWriteCharsPerLine -#define nrrdDefWriteEncoding itk_nrrdDefWriteEncoding -#define nrrdDefWriteValsPerLine itk_nrrdDefWriteValsPerLine +#define nrrdUIInsert itk_nrrdUIInsert +#define nrrdUILoad itk_nrrdUILoad +#define nrrdUILookup itk_nrrdUILookup +#define nrrdUIStore itk_nrrdUIStore +#define nrrdDefaultCenter itk_nrrdDefaultCenter +#define nrrdDefaultSpacing itk_nrrdDefaultSpacing +#define nrrdDefaultWriteBareText itk_nrrdDefaultWriteBareText +#define nrrdDefaultWriteCharsPerLine itk_nrrdDefaultWriteCharsPerLine +#define nrrdDefaultWriteEncodingType itk_nrrdDefaultWriteEncodingType +#define nrrdDefaultWriteValsPerLine itk_nrrdDefaultWriteValsPerLine #define nrrdStateAlwaysSetContent itk_nrrdStateAlwaysSetContent #define nrrdStateDisableContent itk_nrrdStateDisableContent #define nrrdStateGrayscaleImage3D itk_nrrdStateGrayscaleImage3D +#define nrrdStateKeyValuePairsPropagate itk_nrrdStateKeyValuePairsPropagate #define nrrdStateKeyValueReturnInternalPointers itk_nrrdStateKeyValueReturnInternalPointers #define nrrdStateKindNoop itk_nrrdStateKindNoop #define nrrdStateUnknownContent itk_nrrdStateUnknownContent @@ -335,6 +399,9 @@ read-only (R) things (seen on Linux) and "other" (S) things #define _nrrdSpaceStr itk__nrrdSpaceStr #define _nrrdSpaceStrEqv itk__nrrdSpaceStrEqv #define _nrrdSpaceValEqv itk__nrrdSpaceValEqv +#define _nrrdSpacingStatus itk__nrrdSpacingStatus +#define _nrrdSpacingStatusDesc itk__nrrdSpacingStatusDesc +#define _nrrdSpacingStatusStr itk__nrrdSpacingStatusStr #define _nrrdType itk__nrrdType #define _nrrdTypeDesc itk__nrrdTypeDesc #define _nrrdTypeStr itk__nrrdTypeStr @@ -346,6 +413,7 @@ read-only (R) things (seen on Linux) and "other" (S) things #define nrrdFormatType itk_nrrdFormatType #define nrrdKind itk_nrrdKind #define nrrdSpace itk_nrrdSpace +#define nrrdSpacingStatus itk_nrrdSpacingStatus #define nrrdType itk_nrrdType #define _nrrdFieldOnePerAxis itk__nrrdFieldOnePerAxis #define _nrrdFieldRequired itk__nrrdFieldRequired @@ -358,60 +426,107 @@ read-only (R) things (seen on Linux) and "other" (S) things #define nrrdTypeNumberOfValues itk_nrrdTypeNumberOfValues #define nrrdTypePrintfStr itk_nrrdTypePrintfStr #define nrrdTypeSize itk_nrrdTypeSize +#define _nrrdAxisInfoInit itk__nrrdAxisInfoInit +#define _nrrdAxisInfoNewInit itk__nrrdAxisInfoNewInit #define _nrrdCopy itk__nrrdCopy #define _nrrdSizeCheck itk__nrrdSizeCheck -#define nrrdAlloc itk_nrrdAlloc #define nrrdAlloc_nva itk_nrrdAlloc_nva +#define nrrdAlloc_va itk_nrrdAlloc_va +#define nrrdAxisInfoCopy itk_nrrdAxisInfoCopy +#define nrrdAxisInfoGet_nva itk_nrrdAxisInfoGet_nva +#define nrrdAxisInfoSet_nva itk_nrrdAxisInfoSet_nva #define nrrdBasicInfoCopy itk_nrrdBasicInfoCopy #define nrrdBasicInfoInit itk_nrrdBasicInfoInit +#define nrrdBiffKey itk_nrrdBiffKey +#define nrrdCommentClear itk_nrrdCommentClear +#define nrrdCommentCopy itk_nrrdCommentCopy #define nrrdCopy itk_nrrdCopy +#define nrrdDefaultWriteBareText itk_nrrdDefaultWriteBareText +#define nrrdDefaultWriteCharsPerLine itk_nrrdDefaultWriteCharsPerLine +#define nrrdDefaultWriteValsPerLine itk_nrrdDefaultWriteValsPerLine +#define nrrdElementNumber itk_nrrdElementNumber +#define nrrdElementSize itk_nrrdElementSize #define nrrdEmpty itk_nrrdEmpty +#define nrrdEncodingUnknown itk_nrrdEncodingUnknown +#define nrrdFormatUnknown itk_nrrdFormatUnknown #define nrrdInit itk_nrrdInit #define nrrdIoStateInit itk_nrrdIoStateInit #define nrrdIoStateNew itk_nrrdIoStateNew #define nrrdIoStateNix itk_nrrdIoStateNix -#define nrrdMaybeAlloc itk_nrrdMaybeAlloc +#define nrrdKeyValueClear itk_nrrdKeyValueClear +#define nrrdKeyValueCopy itk_nrrdKeyValueCopy #define nrrdMaybeAlloc_nva itk_nrrdMaybeAlloc_nva +#define nrrdMaybeAlloc_va itk_nrrdMaybeAlloc_va #define nrrdNew itk_nrrdNew #define nrrdNix itk_nrrdNix #define nrrdNuke itk_nrrdNuke #define nrrdPGM itk_nrrdPGM #define nrrdPPM itk_nrrdPPM -#define nrrdPeripheralCopy itk_nrrdPeripheralCopy -#define nrrdPeripheralInit itk_nrrdPeripheralInit -#define nrrdWrap itk_nrrdWrap +#define nrrdType itk_nrrdType +#define nrrdTypeSize itk_nrrdTypeSize #define nrrdWrap_nva itk_nrrdWrap_nva +#define nrrdWrap_va itk_nrrdWrap_va +#define _nrrdAxisInfoCopy itk__nrrdAxisInfoCopy +#define _nrrdAxisInfoInit itk__nrrdAxisInfoInit +#define _nrrdCopy itk__nrrdCopy +#define _nrrdKindAltered itk__nrrdKindAltered #define nrrdAxesInsert itk_nrrdAxesInsert #define nrrdAxesPermute itk_nrrdAxesPermute +#define nrrdAxisInfoCopy itk_nrrdAxisInfoCopy +#define nrrdAxisInfoGet_nva itk_nrrdAxisInfoGet_nva +#define nrrdBasicInfoCopy itk_nrrdBasicInfoCopy +#define nrrdBiffKey itk_nrrdBiffKey +#define nrrdContentSet_va itk_nrrdContentSet_va +#define nrrdCopy itk_nrrdCopy +#define nrrdElementNumber itk_nrrdElementNumber +#define nrrdElementSize itk_nrrdElementSize #define nrrdInvertPerm itk_nrrdInvertPerm +#define nrrdKindSize itk_nrrdKindSize +#define nrrdMaybeAlloc_nva itk_nrrdMaybeAlloc_nva #define nrrdShuffle itk_nrrdShuffle +#define nrrdStateKeyValuePairsPropagate itk_nrrdStateKeyValuePairsPropagate +#define nrrdStateKindNoop itk_nrrdStateKindNoop #define _nrrdAxisInfoCopy itk__nrrdAxisInfoCopy #define _nrrdAxisInfoInit itk__nrrdAxisInfoInit #define _nrrdAxisInfoNewInit itk__nrrdAxisInfoNewInit #define _nrrdCenter itk__nrrdCenter #define _nrrdCenter2 itk__nrrdCenter2 +#define _nrrdCheck itk__nrrdCheck #define _nrrdKindAltered itk__nrrdKindAltered +#define _nrrdSpaceVecExists itk__nrrdSpaceVecExists #define nrrdAxisInfoCopy itk_nrrdAxisInfoCopy -#define nrrdAxisInfoGet itk_nrrdAxisInfoGet #define nrrdAxisInfoGet_nva itk_nrrdAxisInfoGet_nva +#define nrrdAxisInfoGet_va itk_nrrdAxisInfoGet_va #define nrrdAxisInfoIdx itk_nrrdAxisInfoIdx #define nrrdAxisInfoIdxRange itk_nrrdAxisInfoIdxRange #define nrrdAxisInfoMinMaxSet itk_nrrdAxisInfoMinMaxSet #define nrrdAxisInfoPos itk_nrrdAxisInfoPos #define nrrdAxisInfoPosRange itk_nrrdAxisInfoPosRange -#define nrrdAxisInfoSet itk_nrrdAxisInfoSet #define nrrdAxisInfoSet_nva itk_nrrdAxisInfoSet_nva +#define nrrdAxisInfoSet_va itk_nrrdAxisInfoSet_va #define nrrdAxisInfoSpacingSet itk_nrrdAxisInfoSpacingSet +#define nrrdBiffKey itk_nrrdBiffKey +#define nrrdCopy itk_nrrdCopy +#define nrrdDefaultCenter itk_nrrdDefaultCenter +#define nrrdDefaultSpacing itk_nrrdDefaultSpacing #define nrrdDomainAxesGet itk_nrrdDomainAxesGet #define nrrdKindIsDomain itk_nrrdKindIsDomain #define nrrdKindSize itk_nrrdKindSize +#define nrrdNonSpatialAxesGet itk_nrrdNonSpatialAxesGet +#define nrrdOrientationReduce itk_nrrdOrientationReduce #define nrrdRangeAxesGet itk_nrrdRangeAxesGet +#define nrrdSpaceSet itk_nrrdSpaceSet +#define nrrdSpaceVecNorm itk_nrrdSpaceVecNorm +#define nrrdSpaceVecScale itk_nrrdSpaceVecScale +#define nrrdSpaceVecSetNaN itk_nrrdSpaceVecSetNaN #define nrrdSpacingCalculate itk_nrrdSpacingCalculate +#define nrrdSpatialAxesGet itk_nrrdSpatialAxesGet +#define nrrdStateKindNoop itk_nrrdStateKindNoop #define _nrrdCheck itk__nrrdCheck #define _nrrdCheckEnums itk__nrrdCheckEnums #define _nrrdContentGet itk__nrrdContentGet -#define _nrrdContentSet itk__nrrdContentSet #define _nrrdContentSet_nva itk__nrrdContentSet_nva +#define _nrrdContentSet_va itk__nrrdContentSet_va #define _nrrdFieldCheck itk__nrrdFieldCheck #define _nrrdFieldCheckSpaceInfo itk__nrrdFieldCheckSpaceInfo #define _nrrdFieldCheck_axis_maxs itk__nrrdFieldCheck_axis_maxs @@ -436,31 +551,50 @@ read-only (R) things (seen on Linux) and "other" (S) things #define _nrrdFieldCheck_thicknesses itk__nrrdFieldCheck_thicknesses #define _nrrdFieldCheck_type itk__nrrdFieldCheck_type #define _nrrdFieldCheck_units itk__nrrdFieldCheck_units -#define _nrrdSpaceVecNorm itk__nrrdSpaceVecNorm -#define _nrrdSpaceVecScale itk__nrrdSpaceVecScale -#define _nrrdSpaceVecScaleAdd2 itk__nrrdSpaceVecScaleAdd2 -#define _nrrdSpaceVecSetNaN itk__nrrdSpaceVecSetNaN +#define _nrrdSizeCheck itk__nrrdSizeCheck #define _nrrdSplitSizes itk__nrrdSplitSizes +#define nrrdAxisInfoGet_nva itk_nrrdAxisInfoGet_nva #define nrrdBiffKey itk_nrrdBiffKey +#define nrrdCenter itk_nrrdCenter #define nrrdCheck itk_nrrdCheck -#define nrrdContentSet itk_nrrdContentSet +#define nrrdContentSet_va itk_nrrdContentSet_va +#define nrrdDefaultCenter itk_nrrdDefaultCenter +#define nrrdDefaultWriteEncodingType itk_nrrdDefaultWriteEncodingType #define nrrdDescribe itk_nrrdDescribe #define nrrdElementNumber itk_nrrdElementNumber #define nrrdElementSize itk_nrrdElementSize +#define nrrdEncodingType itk_nrrdEncodingType +#define nrrdField itk_nrrdField +#define nrrdKind itk_nrrdKind +#define nrrdKindSize itk_nrrdKindSize #define nrrdOriginCalculate itk_nrrdOriginCalculate #define nrrdSameSize itk_nrrdSameSize #define nrrdSanity itk_nrrdSanity +#define nrrdSpace itk_nrrdSpace #define nrrdSpaceDimension itk_nrrdSpaceDimension #define nrrdSpaceDimensionSet itk_nrrdSpaceDimensionSet #define nrrdSpaceOriginGet itk_nrrdSpaceOriginGet #define nrrdSpaceOriginSet itk_nrrdSpaceOriginSet #define nrrdSpaceSet itk_nrrdSpaceSet +#define nrrdSpaceVecCopy itk_nrrdSpaceVecCopy +#define nrrdSpaceVecNorm itk_nrrdSpaceVecNorm +#define nrrdSpaceVecScale itk_nrrdSpaceVecScale +#define nrrdSpaceVecScaleAdd2 itk_nrrdSpaceVecScaleAdd2 +#define nrrdSpaceVecSetNaN itk_nrrdSpaceVecSetNaN +#define nrrdStateAlwaysSetContent itk_nrrdStateAlwaysSetContent +#define nrrdStateDisableContent itk_nrrdStateDisableContent +#define nrrdStateUnknownContent itk_nrrdStateUnknownContent +#define nrrdType itk_nrrdType +#define nrrdTypeIsIntegral itk_nrrdTypeIsIntegral +#define nrrdTypeSize itk_nrrdTypeSize +#define _nrrdFormatURLLine0 itk__nrrdFormatURLLine0 +#define _nrrdFormatURLLine1 itk__nrrdFormatURLLine1 #define nrrdCommentAdd itk_nrrdCommentAdd #define nrrdCommentClear itk_nrrdCommentClear #define nrrdCommentCopy itk_nrrdCommentCopy -#define _nrrdFwriteEscaped itk__nrrdFwriteEscaped -#define _nrrdKeyValueFwrite itk__nrrdKeyValueFwrite #define _nrrdKeyValueIdxFind itk__nrrdKeyValueIdxFind +#define _nrrdKeyValueWrite itk__nrrdKeyValueWrite +#define _nrrdWriteEscaped itk__nrrdWriteEscaped #define nrrdKeyValueAdd itk_nrrdKeyValueAdd #define nrrdKeyValueClear itk_nrrdKeyValueClear #define nrrdKeyValueCopy itk_nrrdKeyValueCopy @@ -468,17 +602,25 @@ read-only (R) things (seen on Linux) and "other" (S) things #define nrrdKeyValueGet itk_nrrdKeyValueGet #define nrrdKeyValueIndex itk_nrrdKeyValueIndex #define nrrdKeyValueSize itk_nrrdKeyValueSize +#define nrrdStateKeyValueReturnInternalPointers itk_nrrdStateKeyValueReturnInternalPointers #define _nrrdBlockEndian itk__nrrdBlockEndian #define _nrrdNoopEndian itk__nrrdNoopEndian #define _nrrdSwap16Endian itk__nrrdSwap16Endian #define _nrrdSwap32Endian itk__nrrdSwap32Endian #define _nrrdSwap64Endian itk__nrrdSwap64Endian #define _nrrdSwapEndian itk__nrrdSwapEndian +#define nrrdElementNumber itk_nrrdElementNumber #define nrrdSwapEndian itk_nrrdSwapEndian -#define _nrrdContainsPercentDAndMore itk__nrrdContainsPercentDAndMore +#define nrrdType itk_nrrdType +#define _nrrdContainsPercentThisAndMore itk__nrrdContainsPercentThisAndMore #define _nrrdDataFNCheck itk__nrrdDataFNCheck #define _nrrdDataFNNumber itk__nrrdDataFNNumber +#define _nrrdFieldCheck itk__nrrdFieldCheck +#define _nrrdFieldSep itk__nrrdFieldSep #define _nrrdGetQuotedString itk__nrrdGetQuotedString +#define _nrrdHeaderCheck itk__nrrdHeaderCheck +#define _nrrdNoSpaceVector itk__nrrdNoSpaceVector +#define _nrrdOneLine itk__nrrdOneLine #define _nrrdReadNrrdParseField itk__nrrdReadNrrdParseField #define _nrrdReadNrrdParse_axis_maxs itk__nrrdReadNrrdParse_axis_maxs #define _nrrdReadNrrdParse_axis_mins itk__nrrdReadNrrdParse_axis_mins @@ -514,38 +656,109 @@ read-only (R) things (seen on Linux) and "other" (S) things #define _nrrdReadNrrdParse_type itk__nrrdReadNrrdParse_type #define _nrrdReadNrrdParse_units itk__nrrdReadNrrdParse_units #define _nrrdSpaceVectorParse itk__nrrdSpaceVectorParse +#define _nrrdSplitSizes itk__nrrdSplitSizes +#define nrrdAxisInfoSet_nva itk_nrrdAxisInfoSet_nva +#define nrrdBiffKey itk_nrrdBiffKey +#define nrrdCenter itk_nrrdCenter +#define nrrdCommentAdd itk_nrrdCommentAdd +#define nrrdEncodingArray itk_nrrdEncodingArray +#define nrrdEncodingType itk_nrrdEncodingType +#define nrrdField itk_nrrdField #define nrrdFieldInfoParse itk_nrrdFieldInfoParse +#define nrrdKeyValueAdd itk_nrrdKeyValueAdd +#define nrrdKind itk_nrrdKind +#define nrrdSpace itk_nrrdSpace +#define nrrdSpaceSet itk_nrrdSpaceSet +#define nrrdType itk_nrrdType +#define _nrrdGzCheckHeader itk__nrrdGzCheckHeader #define _nrrdGzClose itk__nrrdGzClose +#define _nrrdGzDestroy itk__nrrdGzDestroy #define _nrrdGzDummySymbol itk__nrrdGzDummySymbol +#define _nrrdGzErrMsg itk__nrrdGzErrMsg +#define _nrrdGzGetByte itk__nrrdGzGetByte #define _nrrdGzOpen itk__nrrdGzOpen #define _nrrdGzRead itk__nrrdGzRead #define _nrrdGzWrite itk__nrrdGzWrite +#define nrrdBiffKey itk_nrrdBiffKey #define _nrrdCalloc itk__nrrdCalloc +#define _nrrdCheck itk__nrrdCheck +#define _nrrdContainsPercentThisAndMore itk__nrrdContainsPercentThisAndMore +#define _nrrdDataFNNumber itk__nrrdDataFNNumber #define _nrrdFieldSep itk__nrrdFieldSep +#define _nrrdHeaderStringOneLine itk__nrrdHeaderStringOneLine +#define _nrrdHeaderStringOneLineStrlen itk__nrrdHeaderStringOneLineStrlen +#define _nrrdLineSep itk__nrrdLineSep #define _nrrdNoSpaceVector itk__nrrdNoSpaceVector #define _nrrdOneLine itk__nrrdOneLine +#define _nrrdRead itk__nrrdRead #define _nrrdRelativePathFlag itk__nrrdRelativePathFlag #define _nrrdSplitName itk__nrrdSplitName #define _nrrdTextSep itk__nrrdTextSep +#define nrrdAxesInsert itk_nrrdAxesInsert +#define nrrdBiffKey itk_nrrdBiffKey #define nrrdByteSkip itk_nrrdByteSkip +#define nrrdElementNumber itk_nrrdElementNumber +#define nrrdElementSize itk_nrrdElementSize +#define nrrdEncodingRaw itk_nrrdEncodingRaw +#define nrrdFormatArray itk_nrrdFormatArray +#define nrrdFormatNRRD itk_nrrdFormatNRRD +#define nrrdFormatUnknown itk_nrrdFormatUnknown +#define nrrdInit itk_nrrdInit +#define nrrdIoStateNew itk_nrrdIoStateNew +#define nrrdIoStateNix itk_nrrdIoStateNix #define nrrdLineSkip itk_nrrdLineSkip #define nrrdLoad itk_nrrdLoad +#define nrrdLoadMulti itk_nrrdLoadMulti #define nrrdRead itk_nrrdRead +#define nrrdSanity itk_nrrdSanity +#define nrrdStateGrayscaleImage3D itk_nrrdStateGrayscaleImage3D +#define nrrdStateVerboseIO itk_nrrdStateVerboseIO +#define nrrdStringRead itk_nrrdStringRead +#define _nrrdContainsPercentThisAndMore itk__nrrdContainsPercentThisAndMore #define _nrrdEncodingMaybeSet itk__nrrdEncodingMaybeSet #define _nrrdFieldInteresting itk__nrrdFieldInteresting #define _nrrdFormatMaybeGuess itk__nrrdFormatMaybeGuess #define _nrrdFormatMaybeSet itk__nrrdFormatMaybeSet +#define _nrrdFormatNRRD_whichVersion itk__nrrdFormatNRRD_whichVersion #define _nrrdFprintFieldInfo itk__nrrdFprintFieldInfo +#define _nrrdNoSpaceVector itk__nrrdNoSpaceVector +#define _nrrdSplitName itk__nrrdSplitName #define _nrrdSprintFieldInfo itk__nrrdSprintFieldInfo #define _nrrdStrcatSpaceVector itk__nrrdStrcatSpaceVector +#define _nrrdWrite itk__nrrdWrite +#define nrrdBiffKey itk_nrrdBiffKey +#define nrrdCenter itk_nrrdCenter +#define nrrdCheck itk_nrrdCheck +#define nrrdDefaultWriteEncodingType itk_nrrdDefaultWriteEncodingType +#define nrrdElementNumber itk_nrrdElementNumber +#define nrrdElementSize itk_nrrdElementSize +#define nrrdEncodingArray itk_nrrdEncodingArray +#define nrrdEncodingUnknown itk_nrrdEncodingUnknown +#define nrrdField itk_nrrdField +#define nrrdFormatArray itk_nrrdFormatArray +#define nrrdFormatNRRD itk_nrrdFormatNRRD +#define nrrdFormatUnknown itk_nrrdFormatUnknown #define nrrdIoStateEncodingGet itk_nrrdIoStateEncodingGet #define nrrdIoStateEncodingSet itk_nrrdIoStateEncodingSet #define nrrdIoStateFormatGet itk_nrrdIoStateFormatGet #define nrrdIoStateFormatSet itk_nrrdIoStateFormatSet #define nrrdIoStateGet itk_nrrdIoStateGet +#define nrrdIoStateNew itk_nrrdIoStateNew +#define nrrdIoStateNix itk_nrrdIoStateNix #define nrrdIoStateSet itk_nrrdIoStateSet +#define nrrdKind itk_nrrdKind #define nrrdSave itk_nrrdSave +#define nrrdSaveMulti itk_nrrdSaveMulti +#define nrrdSpace itk_nrrdSpace +#define nrrdStateVerboseIO itk_nrrdStateVerboseIO +#define nrrdStringWrite itk_nrrdStringWrite +#define nrrdType itk_nrrdType #define nrrdWrite itk_nrrdWrite +#define _nrrdFormatEPS itk__nrrdFormatEPS +#define _nrrdFormatNRRD itk__nrrdFormatNRRD +#define _nrrdFormatPNG itk__nrrdFormatPNG +#define _nrrdFormatPNM itk__nrrdFormatPNM +#define _nrrdFormatText itk__nrrdFormatText #define _nrrdFormatUnknown itk__nrrdFormatUnknown #define _nrrdFormatUnknown_available itk__nrrdFormatUnknown_available #define _nrrdFormatUnknown_contentStartsLike itk__nrrdFormatUnknown_contentStartsLike @@ -553,8 +766,14 @@ read-only (R) things (seen on Linux) and "other" (S) things #define _nrrdFormatUnknown_nameLooksLike itk__nrrdFormatUnknown_nameLooksLike #define _nrrdFormatUnknown_read itk__nrrdFormatUnknown_read #define _nrrdFormatUnknown_write itk__nrrdFormatUnknown_write +#define _nrrdFormatVTK itk__nrrdFormatVTK +#define nrrdBiffKey itk_nrrdBiffKey #define nrrdFormatArray itk_nrrdFormatArray #define nrrdFormatUnknown itk_nrrdFormatUnknown +#define _nrrdCalloc itk__nrrdCalloc +#define _nrrdDataFNNumber itk__nrrdDataFNNumber +#define _nrrdFieldInteresting itk__nrrdFieldInteresting +#define _nrrdFieldRequired itk__nrrdFieldRequired #define _nrrdFormatNRRD itk__nrrdFormatNRRD #define _nrrdFormatNRRD_available itk__nrrdFormatNRRD_available #define _nrrdFormatNRRD_contentStartsLike itk__nrrdFormatNRRD_contentStartsLike @@ -565,44 +784,98 @@ read-only (R) things (seen on Linux) and "other" (S) things #define _nrrdFormatNRRD_write itk__nrrdFormatNRRD_write #define _nrrdFormatURLLine0 itk__nrrdFormatURLLine0 #define _nrrdFormatURLLine1 itk__nrrdFormatURLLine1 +#define _nrrdFprintFieldInfo itk__nrrdFprintFieldInfo #define _nrrdHeaderCheck itk__nrrdHeaderCheck +#define _nrrdKeyValueWrite itk__nrrdKeyValueWrite +#define _nrrdOneLine itk__nrrdOneLine +#define _nrrdReadNrrdParseField itk__nrrdReadNrrdParseField +#define _nrrdSprintFieldInfo itk__nrrdSprintFieldInfo +#define nrrdBiffKey itk_nrrdBiffKey +#define nrrdByteSkip itk_nrrdByteSkip +#define nrrdElementNumber itk_nrrdElementNumber +#define nrrdElementSize itk_nrrdElementSize +#define nrrdEncodingAscii itk_nrrdEncodingAscii +#define nrrdField itk_nrrdField +#define nrrdFieldInfoParse itk_nrrdFieldInfoParse #define nrrdFormatNRRD itk_nrrdFormatNRRD #define nrrdIoStateDataFileIterBegin itk_nrrdIoStateDataFileIterBegin #define nrrdIoStateDataFileIterNext itk_nrrdIoStateDataFileIterNext +#define nrrdKeyValueSize itk_nrrdKeyValueSize +#define nrrdLineSkip itk_nrrdLineSkip +#define nrrdStateVerboseIO itk_nrrdStateVerboseIO +#define nrrdSwapEndian itk_nrrdSwapEndian +#define nrrdType itk_nrrdType +#define _nrrdEncodingAscii itk__nrrdEncodingAscii +#define _nrrdEncodingBzip2 itk__nrrdEncodingBzip2 +#define _nrrdEncodingGzip itk__nrrdEncodingGzip +#define _nrrdEncodingHex itk__nrrdEncodingHex +#define _nrrdEncodingRaw itk__nrrdEncodingRaw #define _nrrdEncodingUnknown itk__nrrdEncodingUnknown #define _nrrdEncodingUnknown_available itk__nrrdEncodingUnknown_available #define _nrrdEncodingUnknown_read itk__nrrdEncodingUnknown_read #define _nrrdEncodingUnknown_write itk__nrrdEncodingUnknown_write +#define nrrdBiffKey itk_nrrdBiffKey #define nrrdEncodingArray itk_nrrdEncodingArray #define nrrdEncodingUnknown itk_nrrdEncodingUnknown #define _nrrdEncodingRaw itk__nrrdEncodingRaw #define _nrrdEncodingRaw_available itk__nrrdEncodingRaw_available #define _nrrdEncodingRaw_read itk__nrrdEncodingRaw_read #define _nrrdEncodingRaw_write itk__nrrdEncodingRaw_write +#define nrrdBiffKey itk_nrrdBiffKey +#define nrrdElementSize itk_nrrdElementSize #define nrrdEncodingRaw itk_nrrdEncodingRaw +#define nrrdStateVerboseIO itk_nrrdStateVerboseIO #define _nrrdEncodingAscii itk__nrrdEncodingAscii #define _nrrdEncodingAscii_available itk__nrrdEncodingAscii_available #define _nrrdEncodingAscii_read itk__nrrdEncodingAscii_read #define _nrrdEncodingAscii_write itk__nrrdEncodingAscii_write +#define nrrdBiffKey itk_nrrdBiffKey +#define nrrdElementSize itk_nrrdElementSize #define nrrdEncodingAscii itk_nrrdEncodingAscii +#define nrrdIInsert itk_nrrdIInsert +#define nrrdSprint itk_nrrdSprint +#define nrrdType itk_nrrdType +#define nrrdTypePrintfStr itk_nrrdTypePrintfStr #define _nrrdEncodingHex itk__nrrdEncodingHex #define _nrrdEncodingHex_available itk__nrrdEncodingHex_available #define _nrrdEncodingHex_read itk__nrrdEncodingHex_read #define _nrrdEncodingHex_write itk__nrrdEncodingHex_write #define _nrrdReadHexTable itk__nrrdReadHexTable #define _nrrdWriteHexTable itk__nrrdWriteHexTable +#define nrrdBiffKey itk_nrrdBiffKey +#define nrrdElementSize itk_nrrdElementSize #define nrrdEncodingHex itk_nrrdEncodingHex #define _nrrdEncodingGzip itk__nrrdEncodingGzip #define _nrrdEncodingGzip_available itk__nrrdEncodingGzip_available #define _nrrdEncodingGzip_read itk__nrrdEncodingGzip_read #define _nrrdEncodingGzip_write itk__nrrdEncodingGzip_write +#define _nrrdGzClose itk__nrrdGzClose +#define _nrrdGzOpen itk__nrrdGzOpen +#define _nrrdGzRead itk__nrrdGzRead +#define _nrrdGzWrite itk__nrrdGzWrite +#define nrrdBiffKey itk_nrrdBiffKey +#define nrrdElementSize itk_nrrdElementSize #define nrrdEncodingGzip itk_nrrdEncodingGzip +#define _nrrdKindAltered itk__nrrdKindAltered +#define nrrdAxisInfoCopy itk_nrrdAxisInfoCopy +#define nrrdAxisInfoGet_nva itk_nrrdAxisInfoGet_nva +#define nrrdAxisInfoPosRange itk_nrrdAxisInfoPosRange +#define nrrdBasicInfoCopy itk_nrrdBasicInfoCopy +#define nrrdBiffKey itk_nrrdBiffKey +#define nrrdContentSet_va itk_nrrdContentSet_va #define nrrdCrop itk_nrrdCrop +#define nrrdElementSize itk_nrrdElementSize +#define nrrdMaybeAlloc_nva itk_nrrdMaybeAlloc_nva #define nrrdSlice itk_nrrdSlice +#define nrrdSpaceVecCopy itk_nrrdSpaceVecCopy +#define nrrdSpaceVecScaleAdd2 itk_nrrdSpaceVecScaleAdd2 +#define nrrdStateKeyValuePairsPropagate itk_nrrdStateKeyValuePairsPropagate +#define nrrdStateKindNoop itk_nrrdStateKindNoop #define _nrrdEncodingBzip2 itk__nrrdEncodingBzip2 #define _nrrdEncodingBzip2_available itk__nrrdEncodingBzip2_available #define _nrrdEncodingBzip2_read itk__nrrdEncodingBzip2_read #define _nrrdEncodingBzip2_write itk__nrrdEncodingBzip2_write +#define nrrdBiffKey itk_nrrdBiffKey #define nrrdEncodingBzip2 itk_nrrdEncodingBzip2 #define _nrrdFormatEPS itk__nrrdFormatEPS #define _nrrdFormatEPS_available itk__nrrdFormatEPS_available @@ -611,6 +884,7 @@ read-only (R) things (seen on Linux) and "other" (S) things #define _nrrdFormatEPS_nameLooksLike itk__nrrdFormatEPS_nameLooksLike #define _nrrdFormatEPS_read itk__nrrdFormatEPS_read #define _nrrdFormatEPS_write itk__nrrdFormatEPS_write +#define nrrdBiffKey itk_nrrdBiffKey #define nrrdFormatEPS itk_nrrdFormatEPS #define _nrrdFormatPNG itk__nrrdFormatPNG #define _nrrdFormatPNG_available itk__nrrdFormatPNG_available @@ -619,6 +893,7 @@ read-only (R) things (seen on Linux) and "other" (S) things #define _nrrdFormatPNG_nameLooksLike itk__nrrdFormatPNG_nameLooksLike #define _nrrdFormatPNG_read itk__nrrdFormatPNG_read #define _nrrdFormatPNG_write itk__nrrdFormatPNG_write +#define nrrdBiffKey itk_nrrdBiffKey #define nrrdFormatPNG itk_nrrdFormatPNG #define _nrrdFormatPNM itk__nrrdFormatPNM #define _nrrdFormatPNM_available itk__nrrdFormatPNM_available @@ -627,6 +902,7 @@ read-only (R) things (seen on Linux) and "other" (S) things #define _nrrdFormatPNM_nameLooksLike itk__nrrdFormatPNM_nameLooksLike #define _nrrdFormatPNM_read itk__nrrdFormatPNM_read #define _nrrdFormatPNM_write itk__nrrdFormatPNM_write +#define nrrdBiffKey itk_nrrdBiffKey #define nrrdFormatPNM itk_nrrdFormatPNM #define _nrrdFormatText itk__nrrdFormatText #define _nrrdFormatText_available itk__nrrdFormatText_available @@ -635,6 +911,7 @@ read-only (R) things (seen on Linux) and "other" (S) things #define _nrrdFormatText_nameLooksLike itk__nrrdFormatText_nameLooksLike #define _nrrdFormatText_read itk__nrrdFormatText_read #define _nrrdFormatText_write itk__nrrdFormatText_write +#define nrrdBiffKey itk_nrrdBiffKey #define nrrdFormatText itk_nrrdFormatText #define _nrrdFormatVTK itk__nrrdFormatVTK #define _nrrdFormatVTK_available itk__nrrdFormatVTK_available @@ -643,5 +920,6 @@ read-only (R) things (seen on Linux) and "other" (S) things #define _nrrdFormatVTK_nameLooksLike itk__nrrdFormatVTK_nameLooksLike #define _nrrdFormatVTK_read itk__nrrdFormatVTK_read #define _nrrdFormatVTK_write itk__nrrdFormatVTK_write +#define nrrdBiffKey itk_nrrdBiffKey #define nrrdFormatVTK itk_nrrdFormatVTK #endif /* __itk_NrrdIO_mangle_h */ diff --git a/Utilities/ITK/Utilities/NrrdIO/keyvalue.c b/Utilities/ITK/Utilities/NrrdIO/keyvalue.c index 10bcfaa9ba281714b61e61d9fbe4cb6b727d193f..67666bdf99bc269030e7cff45bf7213caf29fd8d 100644 --- a/Utilities/ITK/Utilities/NrrdIO/keyvalue.c +++ b/Utilities/ITK/Utilities/NrrdIO/keyvalue.c @@ -1,6 +1,6 @@ /* NrrdIO: stand-alone code for basic nrrd functionality - Copyright (C) 2005 Gordon Kindlmann + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah This software is provided 'as-is', without any express or implied @@ -140,6 +140,8 @@ nrrdKeyValueErase(Nrrd *nrrd, const char *key) { ** ** This will COPY the given strings, and so does not depend on ** them existing past the return of this function +** +** does NOT use BIFF */ int nrrdKeyValueAdd(Nrrd *nrrd, const char *key, const char *value) { @@ -172,6 +174,8 @@ nrrdKeyValueAdd(Nrrd *nrrd, const char *key, const char *value) { ** "inside" the nrrd struct (pointers which you had better not free()!) ** is controlled by nrrdStateKeyValueReturnInternalPointers, which defaults ** to AIR_FALSE +** +** does NOT use BIFF */ char * nrrdKeyValueGet(const Nrrd *nrrd, const char *key) { @@ -195,19 +199,33 @@ nrrdKeyValueGet(const Nrrd *nrrd, const char *key) { } void -_nrrdFwriteEscaped(FILE *file, const char *str) { - size_t ci; +_nrrdWriteEscaped(FILE *file, char *dst, const char *str) { + size_t ci, sl; for (ci=0; ci<strlen(str); ci++) { switch(str[ci]) { case '\n': - fprintf(file, "\\n"); + if (file) { + fprintf(file, "\\n"); + } else { + strcat(dst, "\\n"); + } break; case '\\': - fprintf(file, "\\\\"); + if (file) { + fprintf(file, "\\\\"); + } else { + strcat(dst, "\\\\"); + } break; default: - fputc(str[ci], file); + if (file) { + fputc(str[ci], file); + } else { + sl = strlen(dst); + dst[sl++] = str[ci]; + dst[sl] = '\0'; + } break; } } @@ -215,25 +233,44 @@ _nrrdFwriteEscaped(FILE *file, const char *str) { } /* -** _nrrdKeyValueFwrite +** _nrrdKeyValueWrite ** ** writes a given key and value to a file, starting with the given ** prefix (if non-NULL), and ending with "\n" */ int -_nrrdKeyValueFwrite(FILE *file, const char *prefix, - const char *key, const char *value) { +_nrrdKeyValueWrite(FILE *file, char **stringP, const char *prefix, + const char *key, const char *value) { - if (!( file && key && value )) { + if (!( (file || stringP) && key && value )) { return 1; } + if (stringP) { + /* 2*strlen() because at worst all characters will be escaped */ + *stringP = (char *)malloc(airStrlen(prefix) + 2*airStrlen(key) + + strlen(":=") + 2*airStrlen(value) + + strlen("\n") + 1); + /* HEY error checking */ + strcpy(*stringP, ""); + } if (prefix) { - fprintf(file, "%s", prefix); + if (file) { + fprintf(file, "%s", prefix); + } else { + strcat(*stringP, prefix); + } + } + if (file) { + _nrrdWriteEscaped(file, NULL, key); + fprintf(file, ":="); + _nrrdWriteEscaped(file, NULL, value); + fprintf(file, "\n"); + } else { + _nrrdWriteEscaped(NULL, *stringP, key); + strcat(*stringP, ":="); + _nrrdWriteEscaped(NULL, *stringP, value); + strcat(*stringP, "\n"); } - _nrrdFwriteEscaped(file, key); - fprintf(file, ":="); - _nrrdFwriteEscaped(file, value); - fprintf(file, "\n"); return 0; } diff --git a/Utilities/ITK/Utilities/NrrdIO/mangle.pl b/Utilities/ITK/Utilities/NrrdIO/mangle.pl index ac83d939c4524151eb129fbb01bfea1764fb5eaa..37c44fa966c0ea3edafcbd3ccd43415f08caca17 100644 --- a/Utilities/ITK/Utilities/NrrdIO/mangle.pl +++ b/Utilities/ITK/Utilities/NrrdIO/mangle.pl @@ -60,17 +60,32 @@ print "This uses nm to list all text (T), data (D) symbols, as well\n"; print "read-only (R) things (seen on Linux) and \"other\" (S) things\n"; print "(seen on Mac). On Macs, the preceeding underscore is removed.\n"; print "*/\n"; +print "Also ensures that a few others starting with nrrd are included, and\n"; +print "prevents variables ending with .N* where N is some number, from inclusion.\n"; print "\n"; open(NM, "nm libNrrdIO.a |"); while (<NM>) { - if (m/ [TDRS] /) { - s|.* [TDRS] (.*)|$1|g; + if (m/.* .* .*\.[0-9]/) { + next; + } + if (m/ [TBDRStb] /) { + s|.* [TBDRStb] (.*)|$1|g; if ($mac) { s|^_||g; } chop; $sym = $_; print "#define ${sym} ${prefix}_${sym}\n"; + } else { + if (m/nrrd/) { + s|.* . (.*nrrd*)|$1|g; + if ($mac) { + s|^_||g; + } + chop; + $sym = $_; + print "#define ${sym} ${prefix}_${sym}\n"; + } } } close(NM); diff --git a/Utilities/ITK/Utilities/NrrdIO/methodsNrrd.c b/Utilities/ITK/Utilities/NrrdIO/methodsNrrd.c index 43dde29f196d18cd3c91ea413a6e5541c75ba7d1..835290482ef1df1f5dd299e4ffe9404aec251b66 100644 --- a/Utilities/ITK/Utilities/NrrdIO/methodsNrrd.c +++ b/Utilities/ITK/Utilities/NrrdIO/methodsNrrd.c @@ -1,6 +1,6 @@ /* NrrdIO: stand-alone code for basic nrrd functionality - Copyright (C) 2005 Gordon Kindlmann + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah This software is provided 'as-is', without any express or implied @@ -24,8 +24,9 @@ #include "NrrdIO.h" #include "privateNrrd.h" -#include "teem32bit.h" +/* +Wed Sep 14 05:55:40 EDT 2005: these are no longer used void nrrdPeripheralInit(Nrrd *nrrd) { @@ -53,17 +54,21 @@ nrrdPeripheralCopy(Nrrd *nout, const Nrrd *nin) { | NRRD_BASIC_INFO_KEYVALUEPAIRS_BIT); return 0; } - +*/ + /* ------------------------------------------------------------ */ void -nrrdIoStateInit (NrrdIoState *nio) { +nrrdIoStateInit(NrrdIoState *nio) { if (nio) { nio->path = (char *)airFree(nio->path); nio->base = (char *)airFree(nio->base); nio->line = (char *)airFree(nio->line); nio->dataFNFormat = (char *)airFree(nio->dataFNFormat); + /* the way IO to/from strings works, I don't think this should be freed */ + nio->headerStringRead = NULL; + nio->headerStringWrite = NULL; airArrayLenSet(nio->dataFNArr, 0); /* closing this is always someone else's responsibility */ nio->headerFile = NULL; @@ -77,17 +82,20 @@ nrrdIoStateInit (NrrdIoState *nio) { nio->pos = 0; nio->endian = airEndianUnknown; nio->lineSkip = 0; + nio->headerStrlen = 0; + nio->headerStrpos = 0; nio->byteSkip = 0; memset(nio->seen, 0, (NRRD_FIELD_MAX+1)*sizeof(int)); nio->detachedHeader = AIR_FALSE; - nio->bareText = nrrdDefWriteBareText; - nio->charsPerLine = nrrdDefWriteCharsPerLine; - nio->valsPerLine = nrrdDefWriteValsPerLine; + nio->bareText = nrrdDefaultWriteBareText; + nio->charsPerLine = nrrdDefaultWriteCharsPerLine; + nio->valsPerLine = nrrdDefaultWriteValsPerLine; nio->skipData = AIR_FALSE; nio->keepNrrdDataFileOpen = AIR_FALSE; nio->zlibLevel = -1; nio->zlibStrategy = nrrdZlibStrategyDefault; nio->bzip2BlockSize = -1; + nio->learningHeaderStrlen = AIR_FALSE; nio->oldData = NULL; nio->oldDataSize = 0; nio->format = nrrdFormatUnknown; @@ -97,7 +105,7 @@ nrrdIoStateInit (NrrdIoState *nio) { } NrrdIoState * -nrrdIoStateNew (void) { +nrrdIoStateNew(void) { NrrdIoState *nio; nio = (NrrdIoState *)calloc(1, sizeof(NrrdIoState)); @@ -107,6 +115,8 @@ nrrdIoStateNew (void) { nio->line = NULL; nio->dataFNFormat = NULL; nio->dataFN = NULL; + nio->headerStringRead = NULL; + nio->headerStringWrite = NULL; nio->dataFNArr = airArrayNew((void**)(&(nio->dataFN)), NULL, sizeof(char *), NRRD_FILENAME_INCR); airArrayPointerCB(nio->dataFNArr, airNull, airFree); @@ -118,7 +128,7 @@ nrrdIoStateNew (void) { } NrrdIoState * -nrrdIoStateNix (NrrdIoState *nio) { +nrrdIoStateNix(NrrdIoState *nio) { nio->path = (char *)airFree(nio->path); nio->base = (char *)airFree(nio->base); @@ -146,7 +156,7 @@ nrrdIoStateNix (NrrdIoState *nio) { ** the bitflag communicates which fields should *not* be initialized */ void -nrrdBasicInfoInit (Nrrd *nrrd, int bitflag) { +nrrdBasicInfoInit(Nrrd *nrrd, int bitflag) { int dd, ee; if (!nrrd) { @@ -220,8 +230,8 @@ nrrdBasicInfoInit (Nrrd *nrrd, int bitflag) { ** the bitflag communicates which fields should *not* be copied */ int -nrrdBasicInfoCopy (Nrrd *dest, const Nrrd *src, int bitflag) { - char me[]="nrrdBasicInfoCopy", err[AIR_STRLEN_MED]; +nrrdBasicInfoCopy(Nrrd *dest, const Nrrd *src, int bitflag) { + static const char me[]="nrrdBasicInfoCopy"; unsigned int dd, ee; if (!( dest && src )) @@ -247,16 +257,16 @@ nrrdBasicInfoCopy (Nrrd *dest, const Nrrd *src, int bitflag) { dest->content = (char *)airFree(dest->content); dest->content = airStrdup(src->content); if (src->content && !dest->content) { - sprintf(err, "%s: couldn't copy content", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: couldn't copy content", me); + return 1; } } if (!(NRRD_BASIC_INFO_SAMPLEUNITS_BIT & bitflag)) { dest->sampleUnits = (char *)airFree(dest->sampleUnits); dest->sampleUnits = airStrdup(src->sampleUnits); if (src->sampleUnits && !dest->sampleUnits) { - sprintf(err, "%s: couldn't copy sampleUnits", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: couldn't copy sampleUnits", me); + return 1; } } if (!(NRRD_BASIC_INFO_SPACE_BIT & bitflag)) { @@ -270,8 +280,8 @@ nrrdBasicInfoCopy (Nrrd *dest, const Nrrd *src, int bitflag) { dest->spaceUnits[dd] = (char *)airFree(dest->spaceUnits[dd]); dest->spaceUnits[dd] = airStrdup(src->spaceUnits[dd]); if (src->spaceUnits[dd] && !dest->spaceUnits[dd]) { - sprintf(err, "%s: couldn't copy spaceUnits[%d]", me, dd); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: couldn't copy spaceUnits[%d]", me, dd); + return 1; } } for (dd=src->spaceDim; dd<NRRD_SPACE_DIM_MAX; dd++) { @@ -309,14 +319,14 @@ nrrdBasicInfoCopy (Nrrd *dest, const Nrrd *src, int bitflag) { } if (!(NRRD_BASIC_INFO_COMMENTS_BIT & bitflag)) { if (nrrdCommentCopy(dest, src)) { - sprintf(err, "%s: trouble copying comments", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: trouble copying comments", me); + return 1; } } if (!(NRRD_BASIC_INFO_KEYVALUEPAIRS_BIT & bitflag)) { if (nrrdKeyValueCopy(dest, src)) { - sprintf(err, "%s: trouble copying key/value pairs", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: trouble copying key/value pairs", me); + return 1; } } return 0; @@ -330,7 +340,7 @@ nrrdBasicInfoCopy (Nrrd *dest, const Nrrd *src, int bitflag) { ** just sets values to 0, NaN, "", NULL, or Unknown */ void -nrrdInit (Nrrd *nrrd) { +nrrdInit(Nrrd *nrrd) { int ii; if (nrrd) { @@ -350,13 +360,14 @@ nrrdInit (Nrrd *nrrd) { ** this does NOT use biff */ Nrrd * -nrrdNew (void) { +nrrdNew(void) { int ii; Nrrd *nrrd; nrrd = (Nrrd*)(calloc(1, sizeof(Nrrd))); - if (!nrrd) + if (!nrrd) { return NULL; + } /* explicitly set pointers to NULL, since calloc isn't officially guaranteed to do that. */ @@ -405,7 +416,7 @@ nrrdNew (void) { ** this does NOT use biff */ Nrrd * -nrrdNix (Nrrd *nrrd) { +nrrdNix(Nrrd *nrrd) { int ii; if (nrrd) { @@ -434,7 +445,7 @@ nrrdNix (Nrrd *nrrd) { ** any comments. */ Nrrd * -nrrdEmpty (Nrrd *nrrd) { +nrrdEmpty(Nrrd *nrrd) { if (nrrd) { nrrd->data = airFree(nrrd->data); @@ -451,7 +462,7 @@ nrrdEmpty (Nrrd *nrrd) { ** always returns NULL */ Nrrd * -nrrdNuke (Nrrd *nrrd) { +nrrdNuke(Nrrd *nrrd) { if (nrrd) { nrrdEmpty(nrrd); @@ -463,22 +474,23 @@ nrrdNuke (Nrrd *nrrd) { /* ------------------------------------------------------------ */ int -_nrrdSizeCheck (const size_t *size, unsigned int dim, int useBiff) { - char me[]="_nrrdSizeCheck", err[AIR_STRLEN_MED]; +_nrrdSizeCheck(const size_t *size, unsigned int dim, int useBiff) { + static const char me[]="_nrrdSizeCheck"; size_t num, pre; unsigned int ai; pre = num = 1; for (ai=0; ai<dim; ai++) { if (!size[ai]) { - sprintf(err, "%s: axis %u size is zero!", me, ai); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: axis %u size is zero!", me, ai); + return 1; } num *= size[ai]; if (num/size[ai] != pre) { - sprintf(err, "%s: total # of elements too large to be represented in " - "type size_t, so too large for current architecture", me); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: total # of elements too large to be represented in " + "type size_t, so too large for current architecture", me); + return 1; } pre *= size[ai]; } @@ -497,27 +509,27 @@ _nrrdSizeCheck (const size_t *size, unsigned int dim, int useBiff) { ** set nrrd->blockSize at some other time. */ int -nrrdWrap_nva (Nrrd *nrrd, void *data, int type, - unsigned int dim, const size_t *size) { - char me[]="nrrdWrap_nva", err[AIR_STRLEN_MED]; +nrrdWrap_nva(Nrrd *nrrd, void *data, int type, + unsigned int dim, const size_t *size) { + static const char me[]="nrrdWrap_nva"; if (!(nrrd && size)) { - sprintf(err, "%s: got NULL pointer", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: got NULL pointer", me); + return 1; } nrrd->data = data; nrrd->type = type; nrrd->dim = dim; if (_nrrdSizeCheck(size, dim, AIR_TRUE)) { - sprintf(err, "%s:", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s:", me); + return 1; } nrrdAxisInfoSet_nva(nrrd, nrrdAxisInfoSize, size); return 0; } /* -******** nrrdWrap() +******** nrrdWrap_va() ** ** Minimal var args wrapper around nrrdWrap_nva, with the advantage of ** taking all the axes sizes as the var args. @@ -529,15 +541,15 @@ nrrdWrap_nva (Nrrd *nrrd, void *data, int type, ** This does use biff. */ int -nrrdWrap (Nrrd *nrrd, void *data, int type, unsigned int dim, ...) { - char me[] = "nrrdWrap", err[AIR_STRLEN_MED]; +nrrdWrap_va(Nrrd *nrrd, void *data, int type, unsigned int dim, ...) { + static const char me[]="nrrdWrap_va"; va_list ap; size_t size[NRRD_DIM_MAX]; unsigned int ai; if (!(nrrd && data)) { - sprintf(err, "%s: got NULL pointer", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: got NULL pointer", me); + return 1; } va_start(ap, dim); for (ai=0; ai<dim; ai++) { @@ -550,7 +562,7 @@ nrrdWrap (Nrrd *nrrd, void *data, int type, unsigned int dim, ...) { /* void -_nrrdTraverse (Nrrd *nrrd) { +_nrrdTraverse(Nrrd *nrrd) { char *test, tval; size_t I, N; int S; @@ -566,38 +578,38 @@ _nrrdTraverse (Nrrd *nrrd) { */ int -_nrrdCopy (Nrrd *nout, const Nrrd *nin, int bitflag) { - char me[]="_nrrdCopy", err[AIR_STRLEN_MED]; +_nrrdCopy(Nrrd *nout, const Nrrd *nin, int bitflag) { + static const char me[]="_nrrdCopy"; size_t size[NRRD_DIM_MAX]; if (!(nin && nout)) { - sprintf(err, "%s: got NULL pointer", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: got NULL pointer", me); + return 1; } if (nout == nin) { /* its not the case that we have nothing to do- the semantics of copying cannot be achieved if the input and output nrrd are the same; this is an error */ - sprintf(err, "%s: nout==nin disallowed", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: nout==nin disallowed", me); + return 1; } if (!nrrdElementSize(nin)) { - sprintf(err, "%s: input nrrd reports zero element size!", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: input nrrd reports zero element size!", me); + return 1; } nrrdAxisInfoGet_nva(nin, nrrdAxisInfoSize, size); if (nin->data) { if (nrrdMaybeAlloc_nva(nout, nin->type, nin->dim, size)) { - sprintf(err, "%s: couldn't allocate data", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: couldn't allocate data", me); + return 1; } memcpy(nout->data, nin->data, nrrdElementNumber(nin)*nrrdElementSize(nin)); } else { /* someone is trying to copy structs without data, fine fine fine */ if (nrrdWrap_nva(nout, NULL, nin->type, nin->dim, size)) { - sprintf(err, "%s: couldn't allocate data", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: couldn't allocate data", me); + return 1; } } nrrdAxisInfoCopy(nout, nin, NULL, NRRD_AXIS_INFO_SIZE_BIT); @@ -605,10 +617,10 @@ _nrrdCopy (Nrrd *nout, const Nrrd *nin, int bitflag) { harmlessly unset and set type and dim */ nrrdBasicInfoInit(nout, NRRD_BASIC_INFO_DATA_BIT | bitflag); if (nrrdBasicInfoCopy(nout, nin, NRRD_BASIC_INFO_DATA_BIT | bitflag)) { - sprintf(err, "%s: trouble copying basic info", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: trouble copying basic info", me); + return 1; } - + return 0; } @@ -622,11 +634,11 @@ _nrrdCopy (Nrrd *nout, const Nrrd *nin, int bitflag) { */ int nrrdCopy(Nrrd *nout, const Nrrd *nin) { - char me[]="nrrdCopy", err[AIR_STRLEN_MED]; + static const char me[]="nrrdCopy"; if (_nrrdCopy(nout, nin, NRRD_BASIC_INFO_NONE)) { - sprintf(err, "%s:", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s:", me); + return 1; } return 0; } @@ -647,70 +659,70 @@ nrrdCopy(Nrrd *nout, const Nrrd *nin) { ** ** Note to Gordon: don't get clever and change ANY axis-specific ** information here. It may be very convenient to set that before -** nrrdAlloc() or nrrdMaybeAlloc() +** nrrdAlloc or nrrdMaybeAlloc ** ** Note: This function DOES use biff */ int -nrrdAlloc_nva (Nrrd *nrrd, int type, unsigned int dim, const size_t *size) { - char me[] = "nrrdAlloc_nva", err[AIR_STRLEN_MED]; - size_t num; - size_t esize; +nrrdAlloc_nva(Nrrd *nrrd, int type, unsigned int dim, const size_t *size) { + static const char me[]="nrrdAlloc_nva"; + size_t num, esize; if (!(nrrd && size)) { - sprintf(err, "%s: got NULL pointer", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: got NULL pointer", me); + return 1; } if (airEnumValCheck(nrrdType, type)) { - sprintf(err, "%s: type (%d) is invalid", me, type); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: type (%d) is invalid", me, type); + return 1; } if (nrrdTypeBlock == type) { if (!(0 < nrrd->blockSize)) { - sprintf(err, "%s: given nrrd->blockSize " _AIR_SIZE_T_CNV " invalid", - me, nrrd->blockSize); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: given nrrd->blockSize " _AIR_SIZE_T_CNV " invalid", + me, nrrd->blockSize); + return 1; } } if (!AIR_IN_CL(1, dim, NRRD_DIM_MAX)) { - sprintf(err, "%s: dim (%d) not in valid range [1,%d]", - me, dim, NRRD_DIM_MAX); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: dim (%d) not in valid range [1,%d]", + me, dim, NRRD_DIM_MAX); + return 1; } nrrd->data = airFree(nrrd->data); if (nrrdWrap_nva(nrrd, NULL, type, dim, size)) { - sprintf(err, "%s:", me); - biffAdd(NRRD, err); return 1 ; + biffAddf(NRRD, "%s:", me); + return 1 ; } num = nrrdElementNumber(nrrd); esize = nrrdElementSize(nrrd); nrrd->data = calloc(num, esize); if (!(nrrd->data)) { - sprintf(err, "%s: calloc(" _AIR_SIZE_T_CNV ",%zd) failed", - me, num, esize); - biffAdd(NRRD, err); return 1 ; + biffAddf(NRRD, "%s: calloc(" _AIR_SIZE_T_CNV "," + _AIR_SIZE_T_CNV ") failed", + me, num, esize); + return 1 ; } return 0; } /* -******** nrrdAlloc() +******** nrrdAlloc_va() ** ** Handy wrapper around nrrdAlloc_nva, which takes, as its vararg list, ** all the axes sizes. */ int -nrrdAlloc (Nrrd *nrrd, int type, unsigned int dim, ...) { - char me[]="nrrdAlloc", err[AIR_STRLEN_MED]; +nrrdAlloc_va(Nrrd *nrrd, int type, unsigned int dim, ...) { + static const char me[]="nrrdAlloc_va"; size_t size[NRRD_DIM_MAX]; unsigned int ai; va_list ap; if (!nrrd) { - sprintf(err, "%s: got NULL pointer", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: got NULL pointer", me); + return 1; } va_start(ap, dim); for (ai=0; ai<dim; ai++) { @@ -718,8 +730,8 @@ nrrdAlloc (Nrrd *nrrd, int type, unsigned int dim, ...) { } va_end(ap); if (nrrdAlloc_nva(nrrd, type, dim, size)) { - sprintf(err, "%s:", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s:", me); + return 1; } return 0; } @@ -734,40 +746,40 @@ nrrdAlloc (Nrrd *nrrd, int type, unsigned int dim, ...) { ** also subscribes to the "don't mess with peripheral information" philosophy */ int -nrrdMaybeAlloc_nva (Nrrd *nrrd, int type, - unsigned int dim, const size_t *size) { - char me[]="nrrdMaybeAlloc_nva", err[AIR_STRLEN_MED]; +nrrdMaybeAlloc_nva(Nrrd *nrrd, int type, + unsigned int dim, const size_t *size) { + static const char me[]="nrrdMaybeAlloc_nva"; size_t sizeWant, sizeHave, numWant, elementSizeWant; int need; unsigned int ai; if (!nrrd) { - sprintf(err, "%s: got NULL pointer", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: got NULL pointer", me); + return 1; } if (airEnumValCheck(nrrdType, type)) { - sprintf(err, "%s: type (%d) is invalid", me, type); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: type (%d) is invalid", me, type); + return 1; } if (nrrdTypeBlock == type) { if (nrrdTypeBlock == nrrd->type) { - sprintf(err, "%s: can't change from one block nrrd to another", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: can't change from one block nrrd to another", me); + return 1; } if (!(0 < nrrd->blockSize)) { - sprintf(err, "%s: given nrrd->blockSize " _AIR_SIZE_T_CNV " invalid", - me, nrrd->blockSize); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: given nrrd->blockSize " + _AIR_SIZE_T_CNV " invalid", me, nrrd->blockSize); + return 1; } elementSizeWant = nrrd->blockSize; } else { elementSizeWant = nrrdTypeSize[type]; } if (_nrrdSizeCheck(size, dim, AIR_TRUE)) { - sprintf(err, "%s:", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s:", me); + return 1; } - + if (!(nrrd->data)) { need = 1; } else { @@ -776,8 +788,8 @@ nrrdMaybeAlloc_nva (Nrrd *nrrd, int type, numWant *= size[ai]; } if (!nrrdElementSize(nrrd)) { - sprintf(err, "%s: nrrd reports zero element size!", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: nrrd reports zero element size!", me); + return 1; } sizeHave = nrrdElementNumber(nrrd) * nrrdElementSize(nrrd); /* fprintf(stderr, "##%s: sizeHave = %d * %d = %d\n", me, @@ -792,13 +804,13 @@ nrrdMaybeAlloc_nva (Nrrd *nrrd, int type, } if (need) { if (nrrdAlloc_nva(nrrd, type, dim, size)) { - sprintf(err, "%s:", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s:", me); + return 1; } } else { if (nrrdWrap_nva(nrrd, nrrd->data, type, dim, size)) { - sprintf(err, "%s:", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s:", me); + return 1; } /* but we do have to initialize memory! */ memset(nrrd->data, 0, nrrdElementNumber(nrrd)*nrrdElementSize(nrrd)); @@ -808,21 +820,21 @@ nrrdMaybeAlloc_nva (Nrrd *nrrd, int type, } /* -******** nrrdMaybeAlloc() +******** nrrdMaybeAlloc_va() ** ** Handy wrapper around nrrdAlloc, which takes, as its vararg list ** all the axes sizes, thereby calculating the total number. */ int -nrrdMaybeAlloc (Nrrd *nrrd, int type, unsigned int dim, ...) { - char me[]="nrrdMaybeAlloc", err[AIR_STRLEN_MED]; +nrrdMaybeAlloc_va(Nrrd *nrrd, int type, unsigned int dim, ...) { + static const char me[]="nrrdMaybeAlloc_va"; size_t size[NRRD_DIM_MAX]; unsigned int ai; va_list ap; if (!nrrd) { - sprintf(err, "%s: got NULL pointer", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: got NULL pointer", me); + return 1; } va_start(ap, dim); for (ai=0; ai<dim; ai++) { @@ -830,8 +842,8 @@ nrrdMaybeAlloc (Nrrd *nrrd, int type, unsigned int dim, ...) { } va_end(ap); if (nrrdMaybeAlloc_nva(nrrd, type, dim, size)) { - sprintf(err, "%s:", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s:", me); + return 1; } return 0; } @@ -844,13 +856,14 @@ nrrdMaybeAlloc (Nrrd *nrrd, int type, unsigned int dim, ...) { ** "don't mess with peripheral information" */ int -nrrdPPM (Nrrd *ppm, size_t sx, size_t sy) { - char me[]="nrrdPPM", err[AIR_STRLEN_MED]; +nrrdPPM(Nrrd *ppm, size_t sx, size_t sy) { + static const char me[]="nrrdPPM"; - if (nrrdMaybeAlloc(ppm, nrrdTypeUChar, 3, 3, sx, sy)) { - sprintf(err, "%s: couldn't allocate " _AIR_SIZE_T_CNV - " x " _AIR_SIZE_T_CNV " 24-bit image", me, sx, sy); - biffAdd(NRRD, err); return 1; + if (nrrdMaybeAlloc_va(ppm, nrrdTypeUChar, 3, + AIR_CAST(size_t, 3), sx, sy)) { + biffAddf(NRRD, "%s: couldn't allocate " _AIR_SIZE_T_CNV + " x " _AIR_SIZE_T_CNV " 24-bit image", me, sx, sy); + return 1; } return 0; } @@ -863,13 +876,13 @@ nrrdPPM (Nrrd *ppm, size_t sx, size_t sy) { ** "don't mess with peripheral information" */ int -nrrdPGM (Nrrd *pgm, size_t sx, size_t sy) { - char me[]="nrrdNewPGM", err[AIR_STRLEN_MED]; +nrrdPGM(Nrrd *pgm, size_t sx, size_t sy) { + static const char me[]="nrrdPGM"; - if (nrrdMaybeAlloc(pgm, nrrdTypeUChar, 2, sx, sy)) { - sprintf(err, "%s: couldn't allocate " _AIR_SIZE_T_CNV - " x " _AIR_SIZE_T_CNV " 8-bit image", me, sx, sy); - biffAdd(NRRD, err); + if (nrrdMaybeAlloc_va(pgm, nrrdTypeUChar, 2, + sx, sy)) { + biffAddf(NRRD, "%s: couldn't allocate " _AIR_SIZE_T_CNV + " x " _AIR_SIZE_T_CNV " 8-bit image", me, sx, sy); return 1; } return 0; diff --git a/Utilities/ITK/Utilities/NrrdIO/miscAir.c b/Utilities/ITK/Utilities/NrrdIO/miscAir.c index 92072608aee54cf29f6985d8e43de682aed75dc3..9320101724950251ec3ef22be8a68c9bbc45d7ac 100644 --- a/Utilities/ITK/Utilities/NrrdIO/miscAir.c +++ b/Utilities/ITK/Utilities/NrrdIO/miscAir.c @@ -1,6 +1,6 @@ /* NrrdIO: stand-alone code for basic nrrd functionality - Copyright (C) 2005 Gordon Kindlmann + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah This software is provided 'as-is', without any express or implied @@ -22,7 +22,6 @@ 3. This notice may not be removed or altered from any source distribution. */ - #include "NrrdIO.h" #include "teem32bit.h" /* timer functions */ @@ -39,13 +38,13 @@ ******** airTeemReleaseDate ** ** updated with each release to contain a string representation of -** the teem version number and release date. Originated in version 1.5; +** the Teem version number and release date. Originated in version 1.5; ** use of TEEM_VERSION #defines started in 1.9 */ const char * airTeemVersion = TEEM_VERSION_STRING; const char * -airTeemReleaseDate = "26 August 2005"; +airTeemReleaseDate = "late 2009 or early 2010"; double _airSanityHelper(double val) { @@ -157,16 +156,16 @@ airFclose(FILE *file) { */ int airSinglePrintf(FILE *file, char *str, const char *_fmt, ...) { - char *fmt; - float valF=0; - double valD=0; + char *fmt, buff[AIR_STRLEN_LARGE]; + double val=0, gVal, fVal; int ret, isF, isD, cls; char *conv=NULL, *p0, *p1, *p2, *p3, *p4, *p5; va_list ap; va_start(ap, _fmt); fmt = airStrdup(_fmt); - + + /* this is needlessly complicated; the "l" modifier is a no-op */ p0 = strstr(fmt, "%e"); p1 = strstr(fmt, "%f"); p2 = strstr(fmt, "%g"); @@ -175,6 +174,9 @@ airSinglePrintf(FILE *file, char *str, const char *_fmt, ...) { p5 = strstr(fmt, "%lg"); isF = p0 || p1 || p2; isD = p3 || p4 || p5; + /* the code here says "isF" and "isD" as if it means "is float" or + "is double". It really should be "is2" or "is3", as in, + "is 2-character conversion sequence, or "is 3-character..." */ if (isF) { conv = p0 ? p0 : (p1 ? p1 : p2); } @@ -182,16 +184,10 @@ airSinglePrintf(FILE *file, char *str, const char *_fmt, ...) { conv = p3 ? p3 : (p4 ? p4 : p5); } if (isF || isD) { - if (isF) { - /* use "double" instead of "float" because var args are _always_ - subject to old-style C type promotions: float promotes to double */ - valF = (float)(va_arg(ap, double)); - cls = airFPClass_f(valF); - } - else { - valD = va_arg(ap, double); - cls = airFPClass_d(valD); - } + /* use "double" instead of "float" because var args are _always_ + subject to old-style C type promotions: float promotes to double */ + val = va_arg(ap, double); + cls = airFPClass_d(val); switch (cls) { case airFP_SNAN: case airFP_QNAN: @@ -199,8 +195,7 @@ airSinglePrintf(FILE *file, char *str, const char *_fmt, ...) { case airFP_NEG_INF: if (isF) { memcpy(conv, "%s", 2); - } - else { + } else { /* this sneakiness allows us to replace a 3-character conversion sequence for a double (such as %lg) with a 3-character conversion for a string, which we know has at most 4 characters */ @@ -221,16 +216,26 @@ airSinglePrintf(FILE *file, char *str, const char *_fmt, ...) { ret = PRINT(file, str, fmt, "-inf"); break; default: - if (isF) { - ret = PRINT(file, str, fmt, valF); - } - else { - ret = PRINT(file, str, fmt, valD); + if (p2 || p5) { + /* got "%g" or "%lg", see if it would be better to use "%f" */ + sprintf(buff, "%f", val); + sscanf(buff, "%lf", &fVal); + sprintf(buff, "%g", val); + sscanf(buff, "%lf", &gVal); + if (fVal != gVal) { + /* using %g (or %lg) lost precision!! Use %f (or %lf) instead */ + if (p2) { + memcpy(conv, "%f", 2); + } else { + memcpy(conv, "%lf", 3); + } + } } + ret = PRINT(file, str, fmt, val); break; } - } - else { + } else { + /* conversion sequence is neither for float nor double */ ret = file ? vfprintf(file, fmt, ap) : vsprintf(str, fmt, ap); } @@ -245,4 +250,3 @@ const int airMy32Bit = 1; const int airMy32Bit = 0; #endif - diff --git a/Utilities/ITK/Utilities/NrrdIO/mop.c b/Utilities/ITK/Utilities/NrrdIO/mop.c index 7bcc9804df7b9c2bf220b65dbb6ec98e713e49c6..592c629ceaa26485432b3d8591eae95071be1af8 100644 --- a/Utilities/ITK/Utilities/NrrdIO/mop.c +++ b/Utilities/ITK/Utilities/NrrdIO/mop.c @@ -1,6 +1,6 @@ /* NrrdIO: stand-alone code for basic nrrd functionality - Copyright (C) 2005 Gordon Kindlmann + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah This software is provided 'as-is', without any express or implied @@ -65,13 +65,25 @@ airMopNew() { return airArrayNew(NULL, NULL, sizeof(airMop), AIR_MOP_INCR); } -void +/* +** this always returns 0, to facilitate this weird idiom: +** +** if (!(nmeasr = nrrdNew()) +** || airMopAdd(mop, nmeasr, (airMopper)nrrdNuke, airMopAlways) +** || !(nsize = nrrdNew()) +** || airMopAdd(mop, nsize, (airMopper)nrrdNuke, airMopAlways) +** || !(pair = AIR_CAST(ccpair *, calloc(pctx->CCNum, sizeof(ccpair)))) +** || airMopAdd(mop, pair, airFree, airMopAlways)) { +** +** GLK may regret this. +*/ +int airMopAdd(airArray *arr, void *ptr, airMopper mop, int when) { airMop *mops; unsigned int ii; if (!arr) { - return; + return 0; } mops = (airMop *)arr->data; @@ -80,7 +92,7 @@ airMopAdd(airArray *arr, void *ptr, airMopper mop, int when) { if (mops[ii].ptr == ptr && mops[ii].mop == mop) { mops[ii].when = when; /* we're done */ - return; + return 0; } } /* this is a new ptr */ @@ -89,7 +101,7 @@ airMopAdd(airArray *arr, void *ptr, airMopper mop, int when) { mops[ii].ptr = ptr; mops[ii].mop = mop; mops[ii].when = when; - return; + return 0; } void diff --git a/Utilities/ITK/Utilities/NrrdIO/parseAir.c b/Utilities/ITK/Utilities/NrrdIO/parseAir.c index aa1886340757e755470ad2e8bfdc39e7efc2007f..8352ff0646ff450d57e25b4d30d6995124d839ca 100644 --- a/Utilities/ITK/Utilities/NrrdIO/parseAir.c +++ b/Utilities/ITK/Utilities/NrrdIO/parseAir.c @@ -1,6 +1,6 @@ /* NrrdIO: stand-alone code for basic nrrd functionality - Copyright (C) 2005 Gordon Kindlmann + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah This software is provided 'as-is', without any express or implied @@ -22,44 +22,43 @@ 3. This notice may not be removed or altered from any source distribution. */ - #include "NrrdIO.h" -char -_airBoolStr[][AIR_STRLEN_SMALL] = { +const char * +_airBoolStr[] = { "(unknown bool)", "false", "true" }; -char -_airBoolDesc[][AIR_STRLEN_MED] = { +const char * +_airBoolDesc[] = { "unknown boolean", "false", "true" }; -int +const int _airBoolVal[] = { -1, AIR_FALSE, AIR_TRUE }; -char -_airBoolStrEqv[][AIR_STRLEN_SMALL] = { +const char * +_airBoolStrEqv[] = { "0", "no", "n", "false", "f", "off", "nope", "1", "yes", "y", "true", "t", "on", "yea", "" }; -int +const int _airBoolValEqv[] = { AIR_FALSE, AIR_FALSE, AIR_FALSE, AIR_FALSE, AIR_FALSE, AIR_FALSE, AIR_FALSE, AIR_TRUE, AIR_TRUE, AIR_TRUE, AIR_TRUE, AIR_TRUE, AIR_TRUE, AIR_TRUE }; -airEnum +const airEnum _airBool = { "boolean", 2, @@ -71,7 +70,7 @@ _airBool = { AIR_FALSE }; -airEnum * +const airEnum *const airBool = &_airBool; double @@ -117,7 +116,7 @@ airSingleSscanf(const char *str, const char *fmt, void *ptr) { } else { /* we were given a float pointer */ - *((float *)(ptr)) = (float)val; + *((float *)(ptr)) = AIR_CAST(float, val); } free(tmp); return 1; @@ -179,6 +178,9 @@ airParseStrI(_PARSE_STR_ARGS(int)) { _PARSE_STR_BODY("%d") } unsigned int airParseStrUI(_PARSE_STR_ARGS(unsigned int)) { _PARSE_STR_BODY("%u") } +unsigned int +airParseStrLI(_PARSE_STR_ARGS(long int)) { _PARSE_STR_BODY("%ld") } + unsigned int airParseStrZ(_PARSE_STR_ARGS(size_t)) { _PARSE_STR_BODY(_AIR_SIZE_T_CNV) } @@ -352,6 +354,8 @@ unsigned int unsigned int, ...))airParseStrI, (unsigned int (*)(void *, const char *, const char *, unsigned int, ...))airParseStrUI, + (unsigned int (*)(void *, const char *, const char *, + unsigned int, ...))airParseStrLI, (unsigned int (*)(void *, const char *, const char *, unsigned int, ...))airParseStrZ, (unsigned int (*)(void *, const char *, const char *, diff --git a/Utilities/ITK/Utilities/NrrdIO/parseNrrd.c b/Utilities/ITK/Utilities/NrrdIO/parseNrrd.c index 43d6b0dc5eec025bc7951b4561ae8aae960160cf..86becc950d324f53914988be96449965a151294b 100644 --- a/Utilities/ITK/Utilities/NrrdIO/parseNrrd.c +++ b/Utilities/ITK/Utilities/NrrdIO/parseNrrd.c @@ -1,6 +1,6 @@ /* NrrdIO: stand-alone code for basic nrrd functionality - Copyright (C) 2005 Gordon Kindlmann + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah This software is provided 'as-is', without any express or implied @@ -31,9 +31,9 @@ ** This is for parsing the stuff BEFORE the colon */ int -_nrrdReadNrrdParseField (NrrdIoState *nio, int useBiff) { - char me[]="_nrrdReadNrrdParseField", err[AIR_STRLEN_MED], *next, - *buff, *colon, *keysep; +_nrrdReadNrrdParseField(NrrdIoState *nio, int useBiff) { + static const char me[]="_nrrdReadNrrdParseField"; + char *next, *buff, *colon, *keysep; int ret, fld=nrrdField_unknown, noField, badField=AIR_FALSE; next = nio->line + nio->pos; @@ -44,10 +44,10 @@ _nrrdReadNrrdParseField (NrrdIoState *nio, int useBiff) { } if (!( buff = airStrdup(next) )) { - sprintf(err, "%s: couldn't allocate buffer!", me); - biffMaybeAdd(NRRD, err, useBiff); return nrrdField_unknown; + biffMaybeAddf(useBiff, NRRD, "%s: couldn't allocate buffer!", me); + return nrrdField_unknown; } - + /* #1: "...if you see a colon, then look for an equal sign..." */ /* Look for colon: if no colon, or failed to parse as a field, look for @@ -66,12 +66,15 @@ _nrrdReadNrrdParseField (NrrdIoState *nio, int useBiff) { keysep = strstr(buff, ":="); if (!keysep) { if (noField) { - sprintf(err, "%s: didn't see \": \" or \":=\" in line", me); + biffMaybeAddf(useBiff, NRRD, + "%s: didn't see \": \" or \":=\" in line", + me); } else { - sprintf(err, "%s: failed to parse \"%s\" as field identifier", - me, buff); + biffMaybeAddf(useBiff, NRRD, + "%s: failed to parse \"%s\" as field identifier", + me, buff); } - free(buff); biffMaybeAdd(NRRD, err, useBiff); return nrrdField_unknown; + free(buff); return nrrdField_unknown; } free(buff); @@ -85,7 +88,7 @@ _nrrdReadNrrdParseField (NrrdIoState *nio, int useBiff) { /* skip whitespace prior to start of first field descriptor */ next += strspn(next, _nrrdFieldSep); - nio->pos = next - nio->line; + nio->pos = AIR_CAST(int, next - nio->line); ret = fld; } @@ -101,8 +104,8 @@ _nrrdReadNrrdParseField (NrrdIoState *nio, int useBiff) { */ int -_nrrdReadNrrdParse_nonfield (FILE *file, Nrrd *nrrd, - NrrdIoState *nio, int useBiff) { +_nrrdReadNrrdParse_nonfield(FILE *file, Nrrd *nrrd, + NrrdIoState *nio, int useBiff) { AIR_UNUSED(file); AIR_UNUSED(nrrd); AIR_UNUSED(nio); @@ -120,47 +123,47 @@ _nrrdReadNrrdParse_nonfield (FILE *file, Nrrd *nrrd, } int -_nrrdReadNrrdParse_comment (FILE *file, Nrrd *nrrd, - NrrdIoState *nio, int useBiff) { - char me[]="_nrrdReadNrrdParse_comment", err[AIR_STRLEN_MED]; +_nrrdReadNrrdParse_comment(FILE *file, Nrrd *nrrd, + NrrdIoState *nio, int useBiff) { + static const char me[]="_nrrdReadNrrdParse_comment"; char *info; AIR_UNUSED(file); info = nio->line + nio->pos; /* this skips the '#' at nio->line[nio->pos] and any other ' ' and '#' */ if (nrrdCommentAdd(nrrd, info)) { - sprintf(err, "%s: trouble adding comment", me); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: trouble adding comment", me); + return 1; } return 0; } int -_nrrdReadNrrdParse_content (FILE *file, Nrrd *nrrd, - NrrdIoState *nio, int useBiff) { - char me[]="_nrrdReadNrrdParse_content", err[AIR_STRLEN_MED]; +_nrrdReadNrrdParse_content(FILE *file, Nrrd *nrrd, + NrrdIoState *nio, int useBiff) { + static const char me[]="_nrrdReadNrrdParse_content"; char *info; AIR_UNUSED(file); info = nio->line + nio->pos; if (strlen(info) && !(nrrd->content = airStrdup(info))) { - sprintf(err, "%s: couldn't strdup() content", me); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: couldn't strdup() content", me); + return 1; } return 0; } int -_nrrdReadNrrdParse_number (FILE *file, Nrrd *nrrd, - NrrdIoState *nio, int useBiff) { +_nrrdReadNrrdParse_number(FILE *file, Nrrd *nrrd, + NrrdIoState *nio, int useBiff) { /* - char me[]="_nrrdReadNrrdParse_number", err[AIR_STRLEN_MED]; + static const char me[]="_nrrdReadNrrdParse_number"; char *info; info = nio->line + nio->pos; if (1 != sscanf(info, NRRD_BIG_INT_PRINTF, &(nrrd->num))) { - sprintf(err, "%s: couldn't parse number \"%s\"", me, info); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: couldn't parse number \"%s\"", me, info); return 1; } */ @@ -169,7 +172,7 @@ _nrrdReadNrrdParse_number (FILE *file, Nrrd *nrrd, AIR_UNUSED(nio); AIR_UNUSED(useBiff); /* It was decided to just completely ignore this field. "number" is - ** entirely redundant with the (required) sizes field, and there no + ** entirely redundant with the (required) sizes field, and there is no ** need to save it to, or learn it from, the header. In fact the "num" ** field was eliminated from the Nrrd struct some time ago, in favor of ** the nrrdElementNumber() function. It may seem odd or unfortunate that @@ -183,34 +186,35 @@ _nrrdReadNrrdParse_number (FILE *file, Nrrd *nrrd, } int -_nrrdReadNrrdParse_type (FILE *file, Nrrd *nrrd, - NrrdIoState *nio, int useBiff) { - char me[]="_nrrdReadNrrdParse_type", err[AIR_STRLEN_MED]; +_nrrdReadNrrdParse_type(FILE *file, Nrrd *nrrd, + NrrdIoState *nio, int useBiff) { + static const char me[]="_nrrdReadNrrdParse_type"; char *info; AIR_UNUSED(file); info = nio->line + nio->pos; if (!(nrrd->type = airEnumVal(nrrdType, info))) { - sprintf(err, "%s: couldn't parse type \"%s\"", me, info); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: couldn't parse type \"%s\"", me, info); + return 1; } if (_nrrdFieldCheck[nrrdField_type](nrrd, useBiff)) { - sprintf(err, "%s: trouble", me); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: trouble", me); + return 1; } return 0; } -#define _PARSE_ONE_VAL(FIELD, CONV, TYPE) \ - if (1 != sscanf(info, CONV, &(FIELD))) { \ - sprintf(err, "%s: couldn't parse " TYPE " from \"%s\"", me, info); \ - biffMaybeAdd(NRRD, err, useBiff); return 1; \ +#define _PARSE_ONE_VAL(FIELD, CONV, TYPE) \ + if (1 != sscanf(info, CONV, &(FIELD))) { \ + biffMaybeAddf(useBiff, NRRD, "%s: couldn't parse " TYPE \ + " from \"%s\"", me, info); \ + return 1; \ } int -_nrrdReadNrrdParse_block_size (FILE *file, Nrrd *nrrd, - NrrdIoState *nio, int useBiff) { - char me[]="_nrrdReadNrrdParse_block_size", err[AIR_STRLEN_MED]; +_nrrdReadNrrdParse_block_size(FILE *file, Nrrd *nrrd, + NrrdIoState *nio, int useBiff) { + static const char me[]="_nrrdReadNrrdParse_block_size"; char *info; AIR_UNUSED(file); @@ -222,17 +226,17 @@ _nrrdReadNrrdParse_block_size (FILE *file, Nrrd *nrrd, } int -_nrrdReadNrrdParse_dimension (FILE *file, Nrrd *nrrd, - NrrdIoState *nio, int useBiff) { - char me[]="_nrrdReadNrrdParse_dimension", err[AIR_STRLEN_MED]; +_nrrdReadNrrdParse_dimension(FILE *file, Nrrd *nrrd, + NrrdIoState *nio, int useBiff) { + static const char me[]="_nrrdReadNrrdParse_dimension"; char *info; AIR_UNUSED(file); info = nio->line + nio->pos; _PARSE_ONE_VAL(nrrd->dim, "%u", "unsigned int"); if (_nrrdFieldCheck[nrrdField_dimension](nrrd, useBiff)) { - sprintf(err, "%s: trouble", me); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: trouble", me); + return 1; } return 0; } @@ -242,29 +246,32 @@ _nrrdReadNrrdParse_dimension (FILE *file, Nrrd *nrrd, ** to zero, and, _nrrdReadNrrdParse_dimension() won't allow it to be ** set to anything outside the range [1, NRRD_DIM_MAX] */ -#define _CHECK_HAVE_DIM \ - if (0 == nrrd->dim) { \ - sprintf(err, "%s: don't yet have a valid dimension", me); \ - biffMaybeAdd(NRRD, err, useBiff); return 1; \ +#define _CHECK_HAVE_DIM \ + if (0 == nrrd->dim) { \ + biffMaybeAddf(useBiff, NRRD, \ + "%s: don't yet have a valid dimension", me); \ + return 1; \ } -#define _CHECK_HAVE_SPACE_DIM \ - if (0 == nrrd->spaceDim) { \ - sprintf(err, "%s: don't yet have a valid space dimension", me); \ - biffMaybeAdd(NRRD, err, useBiff); return 1; \ +#define _CHECK_HAVE_SPACE_DIM \ + if (0 == nrrd->spaceDim) { \ + biffMaybeAddf(useBiff, NRRD, \ + "%s: don't yet have a valid space dimension", me); \ + return 1; \ } -#define _CHECK_GOT_ALL_VALUES \ - if (nrrd->dim != ret) { \ - sprintf(err, "%s: parsed %d values, but dimension is %d", \ - me, ret, nrrd->dim); \ - biffMaybeAdd(NRRD, err, useBiff); return 1; \ +#define _CHECK_GOT_ALL_VALUES \ + if (nrrd->dim != ret) { \ + biffMaybeAddf(useBiff, NRRD, \ + "%s: parsed %d values, but dimension is %d", \ + me, ret, nrrd->dim); \ + return 1; \ } int -_nrrdReadNrrdParse_sizes (FILE *file, Nrrd *nrrd, - NrrdIoState *nio, int useBiff) { - char me[]="_nrrdReadNrrdParse_sizes", err[AIR_STRLEN_MED]; +_nrrdReadNrrdParse_sizes(FILE *file, Nrrd *nrrd, + NrrdIoState *nio, int useBiff) { + static const char me[]="_nrrdReadNrrdParse_sizes"; unsigned int ret; size_t val[NRRD_DIM_MAX]; char *info; @@ -277,21 +284,22 @@ _nrrdReadNrrdParse_sizes (FILE *file, Nrrd *nrrd, nrrdAxisInfoSet_nva(nrrd, nrrdAxisInfoSize, val); /* HEY: this is a very imperfect check of excess info */ if (nrrd->dim+1 == airParseStrZ(val, info, _nrrdFieldSep, nrrd->dim+1)) { - sprintf(err, "%s: seem to have more than expected %d sizes", - me, nrrd->dim); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: seem to have more than expected %d sizes", + me, nrrd->dim); + return 1; } if (_nrrdFieldCheck[nrrdField_sizes](nrrd, useBiff)) { - sprintf(err, "%s: trouble", me); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: trouble", me); + return 1; } return 0; } int -_nrrdReadNrrdParse_spacings (FILE *file, Nrrd *nrrd, - NrrdIoState *nio, int useBiff) { - char me[]="_nrrdReadNrrdParse_spacings", err[AIR_STRLEN_MED]; +_nrrdReadNrrdParse_spacings(FILE *file, Nrrd *nrrd, + NrrdIoState *nio, int useBiff) { + static const char me[]="_nrrdReadNrrdParse_spacings"; unsigned int ret; double val[NRRD_DIM_MAX]; char *info; @@ -304,21 +312,22 @@ _nrrdReadNrrdParse_spacings (FILE *file, Nrrd *nrrd, nrrdAxisInfoSet_nva(nrrd, nrrdAxisInfoSpacing, val); /* HEY: this is a very imperfect check of excess info */ if (nrrd->dim+1 == airParseStrD(val, info, _nrrdFieldSep, nrrd->dim+1)) { - sprintf(err, "%s: seem to have more than expected %d spacings", - me, nrrd->dim); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: seem to have more than expected %d spacings", + me, nrrd->dim); + return 1; } if (_nrrdFieldCheck[nrrdField_spacings](nrrd, useBiff)) { - sprintf(err, "%s: trouble", me); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: trouble", me); + return 1; } return 0; } int -_nrrdReadNrrdParse_thicknesses (FILE *file, Nrrd *nrrd, - NrrdIoState *nio, int useBiff) { - char me[]="_nrrdReadNrrdParse_thicknesses", err[AIR_STRLEN_MED]; +_nrrdReadNrrdParse_thicknesses(FILE *file, Nrrd *nrrd, + NrrdIoState *nio, int useBiff) { + static const char me[]="_nrrdReadNrrdParse_thicknesses"; unsigned int ret; double val[NRRD_DIM_MAX]; char *info; @@ -331,21 +340,22 @@ _nrrdReadNrrdParse_thicknesses (FILE *file, Nrrd *nrrd, nrrdAxisInfoSet_nva(nrrd, nrrdAxisInfoThickness, val); /* HEY: this is a very imperfect check of excess info */ if (nrrd->dim+1 == airParseStrD(val, info, _nrrdFieldSep, nrrd->dim+1)) { - sprintf(err, "%s: seem to have more than expected %d thicknesses", - me, nrrd->dim); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: seem to have more than expected %d thicknesses", + me, nrrd->dim); + return 1; } if (_nrrdFieldCheck[nrrdField_thicknesses](nrrd, useBiff)) { - sprintf(err, "%s: trouble", me); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: trouble", me); + return 1; } return 0; } int -_nrrdReadNrrdParse_axis_mins (FILE *file, Nrrd *nrrd, - NrrdIoState *nio, int useBiff) { - char me[]="_nrrdReadNrrdParse_axis_mins", err[AIR_STRLEN_MED]; +_nrrdReadNrrdParse_axis_mins(FILE *file, Nrrd *nrrd, + NrrdIoState *nio, int useBiff) { + static const char me[]="_nrrdReadNrrdParse_axis_mins"; unsigned int ret; double val[NRRD_DIM_MAX]; char *info; @@ -358,21 +368,22 @@ _nrrdReadNrrdParse_axis_mins (FILE *file, Nrrd *nrrd, nrrdAxisInfoSet_nva(nrrd, nrrdAxisInfoMin, val); /* HEY: this is a very imperfect check of excess info */ if (nrrd->dim+1 == airParseStrD(val, info, _nrrdFieldSep, nrrd->dim+1)) { - sprintf(err, "%s: seem to have more than expected %d axis mins", - me, nrrd->dim); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: seem to have more than expected %d axis mins", + me, nrrd->dim); + return 1; } if (_nrrdFieldCheck[nrrdField_axis_mins](nrrd, useBiff)) { - sprintf(err, "%s: trouble", me); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: trouble", me); + return 1; } return 0; } int -_nrrdReadNrrdParse_axis_maxs (FILE *file, Nrrd *nrrd, - NrrdIoState *nio, int useBiff) { - char me[]="_nrrdReadNrrdParse_axis_maxs", err[AIR_STRLEN_MED]; +_nrrdReadNrrdParse_axis_maxs(FILE *file, Nrrd *nrrd, + NrrdIoState *nio, int useBiff) { + static const char me[]="_nrrdReadNrrdParse_axis_maxs"; unsigned int ret; double val[NRRD_DIM_MAX]; char *info; @@ -385,13 +396,14 @@ _nrrdReadNrrdParse_axis_maxs (FILE *file, Nrrd *nrrd, nrrdAxisInfoSet_nva(nrrd, nrrdAxisInfoMax, val); /* HEY: this is a very imperfect check of excess info */ if (nrrd->dim+1 == airParseStrD(val, info, _nrrdFieldSep, nrrd->dim+1)) { - sprintf(err, "%s: seem to have more than expected %d axis maxs", - me, nrrd->dim); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: seem to have more than expected %d axis maxs", + me, nrrd->dim); + return 1; } if (_nrrdFieldCheck[nrrdField_axis_maxs](nrrd, useBiff)) { - sprintf(err, "%s: trouble", me); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: trouble", me); + return 1; } return 0; } @@ -399,22 +411,24 @@ _nrrdReadNrrdParse_axis_maxs (FILE *file, Nrrd *nrrd, int _nrrdSpaceVectorParse(double val[NRRD_SPACE_DIM_MAX], char **hhP, unsigned int spaceDim, int useBiff) { - char me[]="_nrrdSpaceVectorParse", err[AIR_STRLEN_MED], - *hh, *buff, sep[]=",)"; + static const char me[]="_nrrdSpaceVectorParse"; + char *hh, *buff, sep[]=",)"; airArray *mop; - unsigned int ret, dd, length; + unsigned int ret, dd; + size_t length; mop = airMopNew(); hh = *hhP; /* skip past space */ - length = (unsigned int)strspn(hh, _nrrdFieldSep); + length = strspn(hh, _nrrdFieldSep); hh += length; /* make sure we have something */ if (!*hh) { - sprintf(err, "%s: hit end of string before seeing (", me); - biffMaybeAdd(NRRD, err, useBiff); airMopError(mop); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: hit end of string before seeing (", me); + airMopError(mop); return 1; } /* first, see if we're getting the non-vector */ if ( (strstr(hh, _nrrdNoSpaceVector) == hh) ) { @@ -424,23 +438,27 @@ _nrrdSpaceVectorParse(double val[NRRD_SPACE_DIM_MAX], for (dd=0; dd<spaceDim; dd++) { val[dd] = AIR_NAN; } - length += (unsigned int)strlen(_nrrdNoSpaceVector); + length += strlen(_nrrdNoSpaceVector); } else { /* we got something that started out looking like the non-vector */ - sprintf(err, "%s: couldn't parse non-vector \"%s\"", me, hh); - biffMaybeAdd(NRRD, err, useBiff); airMopError(mop); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: couldn't parse non-vector \"%s\"", me, hh); + airMopError(mop); return 1; } } else { /* this isn't a non-vector */ /* make sure we have an open paren */ if ('(' != *hh) { - sprintf(err, "%s: first vector in \"%s\" didn't start with '('", me, hh); - biffMaybeAdd(NRRD, err, useBiff); airMopError(mop); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: first vector in \"%s\" didn't start with '('", + me, hh); + airMopError(mop); return 1; } /* copy string (including open paren) for local fiddling */ if (!(buff = airStrdup(hh))) { - sprintf(err, "%s: couldn't allocate local buffer", me); - biffMaybeAdd(NRRD, err, useBiff); airMopError(mop); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: couldn't allocate local buffer", me); + airMopError(mop); return 1; } airMopAdd(mop, buff, airFree, airMopAlways); /* scan for close paren */ @@ -453,26 +471,29 @@ _nrrdSpaceVectorParse(double val[NRRD_SPACE_DIM_MAX], } } if (')' != *hh) { - sprintf(err, "%s: didn't see ')' at end of first vector in \"%s\"", - me, hh); - biffMaybeAdd(NRRD, err, useBiff); airMopError(mop); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: didn't see ')' at end of first vector in \"%s\"", + me, hh); + airMopError(mop); return 1; } /* terminate at end paren */ *(hh+1) = 0; - length += (unsigned int)strlen(buff); + length += strlen(buff); /* see if we have too many fields */ ret = airStrntok(buff+1, sep); if (ret > spaceDim) { - sprintf(err, "%s: space dimension is %d, but seem to have %d " - "coefficients", me, spaceDim, ret); - biffMaybeAdd(NRRD, err, useBiff); airMopError(mop); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: space dimension is %d, but seem to have %d " + "coefficients", me, spaceDim, ret); + airMopError(mop); return 1; } /* try to parse the values */ ret = airParseStrD(val, buff+1, ",", spaceDim); if (spaceDim != ret) { - sprintf(err, "%s: parsed %d values, but space dimension is %d", - me, ret, spaceDim); - biffMaybeAdd(NRRD, err, useBiff); airMopError(mop); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: parsed %d values, but space dimension is %d", + me, ret, spaceDim); + airMopError(mop); return 1; } } /* probably not useful */ @@ -482,15 +503,18 @@ _nrrdSpaceVectorParse(double val[NRRD_SPACE_DIM_MAX], /* make sure all coefficients exist or not together */ for (dd=1; dd<spaceDim; dd++) { if (!!AIR_EXISTS(val[0]) ^ !!AIR_EXISTS(val[dd])) { - sprintf(err, "%s: existance of all space vector coefficients must " - "be consistent (val[0] not like val[%d])", me, dd); - biffMaybeAdd(NRRD, err, useBiff); airMopError(mop); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: existance of all space vector " + "coefficients must be consistent (val[0] not like " + "val[%d])", me, dd); + airMopError(mop); return 1; } } for (dd=0; dd<spaceDim; dd++) { if (airIsInf_d(val[dd])) { - sprintf(err, "%s: vector coefficient %d can't be infinite", me, dd); - biffMaybeAdd(NRRD, err, useBiff); airMopError(mop); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: vector coefficient %d can't be infinite", + me, dd); + airMopError(mop); return 1; } } *hhP += length; @@ -499,9 +523,9 @@ _nrrdSpaceVectorParse(double val[NRRD_SPACE_DIM_MAX], } int -_nrrdReadNrrdParse_space_directions (FILE *file, Nrrd *nrrd, - NrrdIoState *nio, int useBiff) { - char me[]="_nrrdReadNrrdParse_space_directions", err[AIR_STRLEN_MED]; +_nrrdReadNrrdParse_space_directions(FILE *file, Nrrd *nrrd, + NrrdIoState *nio, int useBiff) { + static const char me[]="_nrrdReadNrrdParse_space_directions"; unsigned int dd; char *info; @@ -513,27 +537,29 @@ _nrrdReadNrrdParse_space_directions (FILE *file, Nrrd *nrrd, for (dd=0; dd<nrrd->dim; dd++) { if (_nrrdSpaceVectorParse(nrrd->axis[dd].spaceDirection, &info, nrrd->spaceDim, useBiff)) { - sprintf(err, "%s: trouble getting space vector %d of %d", - me, dd+1, nrrd->dim); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: trouble getting space vector %d of %d", + me, dd+1, nrrd->dim); + return 1; } } if (strlen(info) != strspn(info, _nrrdFieldSep)) { - sprintf(err, "%s: seem to have more than expected %d directions", - me, nrrd->dim); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: seem to have more than expected %d directions", + me, nrrd->dim); + return 1; } if (_nrrdFieldCheck[nrrdField_space_directions](nrrd, useBiff)) { - sprintf(err, "%s: trouble", me); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: trouble", me); + return 1; } return 0; } int -_nrrdReadNrrdParse_centers (FILE *file, Nrrd *nrrd, - NrrdIoState *nio, int useBiff) { - char me[]="_nrrdReadNrrdParse_centers", err[AIR_STRLEN_MED]; +_nrrdReadNrrdParse_centers(FILE *file, Nrrd *nrrd, + NrrdIoState *nio, int useBiff) { + static const char me[]="_nrrdReadNrrdParse_centers"; unsigned int ai; char *tok, *info, *last; airArray *mop; @@ -546,9 +572,10 @@ _nrrdReadNrrdParse_centers (FILE *file, Nrrd *nrrd, for (ai=0; ai<nrrd->dim; ai++) { tok = airStrtok(!ai ? info : NULL, _nrrdFieldSep, &last); if (!tok) { - sprintf(err, "%s: couldn't extract string for center %d of %d", - me, ai+1, nrrd->dim); - biffMaybeAdd(NRRD, err, useBiff); airMopError(mop); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: couldn't extract string for center %d of %d", + me, ai+1, nrrd->dim); + airMopError(mop); return 1; } if (!strcmp(tok, NRRD_UNKNOWN)) { nrrd->axis[ai].center = nrrdCenterUnknown; @@ -559,28 +586,30 @@ _nrrdReadNrrdParse_centers (FILE *file, Nrrd *nrrd, continue; } if (!(nrrd->axis[ai].center = airEnumVal(nrrdCenter, tok))) { - sprintf(err, "%s: couldn't parse center \"%s\" for axis %d", - me, tok, ai); - biffMaybeAdd(NRRD, err, useBiff); airMopError(mop); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: couldn't parse center \"%s\" for axis %d", + me, tok, ai); + airMopError(mop); return 1; } } if (airStrtok(!ai ? info : NULL, _nrrdFieldSep, &last)) { - sprintf(err, "%s: seem to have more than expected %d centers", - me, nrrd->dim); - biffMaybeAdd(NRRD, err, useBiff); airMopError(mop); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: seem to have more than expected %d centers", + me, nrrd->dim); + airMopError(mop); return 1; } if (_nrrdFieldCheck[nrrdField_centers](nrrd, useBiff)) { - sprintf(err, "%s: trouble", me); - biffMaybeAdd(NRRD, err, useBiff); airMopError(mop); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: trouble", me); + airMopError(mop); return 1; } airMopOkay(mop); return 0; } int -_nrrdReadNrrdParse_kinds (FILE *file, Nrrd *nrrd, - NrrdIoState *nio, int useBiff) { - char me[]="_nrrdReadNrrdParse_kinds", err[AIR_STRLEN_MED]; +_nrrdReadNrrdParse_kinds(FILE *file, Nrrd *nrrd, + NrrdIoState *nio, int useBiff) { + static const char me[]="_nrrdReadNrrdParse_kinds"; unsigned int ai; char *info, *tok, *last; airArray *mop; @@ -593,9 +622,10 @@ _nrrdReadNrrdParse_kinds (FILE *file, Nrrd *nrrd, for (ai=0; ai<nrrd->dim; ai++) { tok = airStrtok(!ai ? info : NULL, _nrrdFieldSep, &last); if (!tok) { - sprintf(err, "%s: couldn't extract string for kind %d of %d", - me, ai+1, nrrd->dim); - biffMaybeAdd(NRRD, err, useBiff); airMopError(mop); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: couldn't extract string for kind %d of %d", + me, ai+1, nrrd->dim); + airMopError(mop); return 1; } if (!strcmp(tok, NRRD_UNKNOWN)) { nrrd->axis[ai].kind = nrrdKindUnknown; @@ -606,23 +636,25 @@ _nrrdReadNrrdParse_kinds (FILE *file, Nrrd *nrrd, continue; } if (!(nrrd->axis[ai].kind = airEnumVal(nrrdKind, tok))) { - sprintf(err, "%s: couldn't parse \"%s\" kind %d of %d", - me, tok, ai+1, nrrd->dim); - biffMaybeAdd(NRRD, err, useBiff); airMopError(mop); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: couldn't parse \"%s\" kind %d of %d", + me, tok, ai+1, nrrd->dim); + airMopError(mop); return 1; } } if (airStrtok(!ai ? info : NULL, _nrrdFieldSep, &last)) { - sprintf(err, "%s: seem to have more than expected %d kinds", - me, nrrd->dim); - biffMaybeAdd(NRRD, err, useBiff); airMopError(mop); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: seem to have more than expected %d kinds", + me, nrrd->dim); + airMopError(mop); return 1; } /* can't run this now because kinds can come before sizes, in which case the kind/size check in _nrrdFieldCheck_kinds will incorrectly flag an error ... if (_nrrdFieldCheck[nrrdField_kinds](nrrd, useBiff)) { - sprintf(err, "%s: trouble", me); - biffMaybeAdd(NRRD, err, useBiff); airMopError(mop); return 1; - } + biffMaybeAddf(useBiff, NRRD, "%s: trouble", me); + airMopError(mop); return 1; + } */ airMopOkay(mop); return 0; @@ -635,7 +667,8 @@ typedef union { char * _nrrdGetQuotedString(char **hP, int useBiff) { - char me[]="_nrrdGetQuotedString", err[AIR_STRLEN_MED], *h, *buff, *ret; + static const char me[]="_nrrdGetQuotedString"; + char *h, *buff, *ret; airArray *buffArr; int pos; _chpu uu; @@ -648,13 +681,14 @@ _nrrdGetQuotedString(char **hP, int useBiff) { /* make sure we have something */ if (!*h) { - sprintf(err, "%s: hit end of string before seeing opening \"", me); - biffMaybeAdd(NRRD, err, useBiff); return NULL; + biffMaybeAddf(useBiff, NRRD, + "%s: hit end of string before seeing opening \"", me); + return NULL; } /* make sure we have a starting quote */ if ('"' != *h) { - sprintf(err, "%s: didn't start with \"", me); - biffMaybeAdd(NRRD, err, useBiff); return NULL; + biffMaybeAddf(useBiff, NRRD, "%s: didn't start with \"", me); + return NULL; } h++; @@ -663,8 +697,8 @@ _nrrdGetQuotedString(char **hP, int useBiff) { uu.c = &buff; buffArr = airArrayNew(uu.v, NULL, sizeof(char), 2); if (!buffArr) { - sprintf(err, "%s: couldn't create airArray", me); - biffMaybeAdd(NRRD, err, useBiff); return NULL; + biffMaybeAddf(useBiff, NRRD, "%s: couldn't create airArray", me); + return NULL; } pos = airArrayLenIncr(buffArr, 1); /* pos should get 0 */ while (h[pos]) { @@ -679,8 +713,8 @@ _nrrdGetQuotedString(char **hP, int useBiff) { pos = airArrayLenIncr(buffArr, 1); } if ('\"' != h[pos]) { - sprintf(err, "%s: didn't see ending \" soon enough", me); - biffMaybeAdd(NRRD, err, useBiff); return NULL; + biffMaybeAddf(useBiff, NRRD, "%s: didn't see ending \" soon enough", me); + return NULL; } h += pos + 1; buff[pos] = 0; @@ -693,9 +727,9 @@ _nrrdGetQuotedString(char **hP, int useBiff) { } int -_nrrdReadNrrdParse_labels (FILE *file, Nrrd *nrrd, - NrrdIoState *nio, int useBiff) { - char me[]="_nrrdReadNrrdParse_labels", err[AIR_STRLEN_MED]; +_nrrdReadNrrdParse_labels(FILE *file, Nrrd *nrrd, + NrrdIoState *nio, int useBiff) { + static const char me[]="_nrrdReadNrrdParse_labels"; char *h; /* this is the "here" pointer which gradually progresses through all the labels (for all axes) */ unsigned int ai; @@ -710,27 +744,28 @@ _nrrdReadNrrdParse_labels (FILE *file, Nrrd *nrrd, h = info; for (ai=0; ai<nrrd->dim; ai++) { if (!( nrrd->axis[ai].label = _nrrdGetQuotedString(&h, useBiff) )) { - sprintf(err, "%s: couldn't get get label %d of %d\n", - me, ai+1, nrrd->dim); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: couldn't get get label %d of %d\n", + me, ai+1, nrrd->dim); + return 1; } } if (strlen(h) != strspn(h, _nrrdFieldSep)) { - sprintf(err, "%s: seem to have more than expected %d labels", - me, nrrd->dim); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: seem to have more than expected %d labels", + me, nrrd->dim); + return 1; } if (_nrrdFieldCheck[nrrdField_labels](nrrd, useBiff)) { - sprintf(err, "%s: trouble", me); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: trouble", me); + return 1; } return 0; } int -_nrrdReadNrrdParse_units (FILE *file, Nrrd *nrrd, - NrrdIoState *nio, int useBiff) { - char me[]="_nrrdReadNrrdParse_units", err[AIR_STRLEN_MED]; +_nrrdReadNrrdParse_units(FILE *file, Nrrd *nrrd, + NrrdIoState *nio, int useBiff) { + static const char me[]="_nrrdReadNrrdParse_units"; char *h; /* this is the "here" pointer which gradually progresses through all the units (for all axes) */ unsigned int ai; @@ -745,19 +780,20 @@ _nrrdReadNrrdParse_units (FILE *file, Nrrd *nrrd, h = info; for (ai=0; ai<nrrd->dim; ai++) { if (!( nrrd->axis[ai].units = _nrrdGetQuotedString(&h, useBiff) )) { - sprintf(err, "%s: couldn't get get unit %d of %d\n", - me, ai+1, nrrd->dim); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: couldn't get get unit %d of %d\n", + me, ai+1, nrrd->dim); + return 1; } } if (strlen(h) != strspn(h, _nrrdFieldSep)) { - sprintf(err, "%s: seem to have more than expected %d units", - me, nrrd->dim); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: seem to have more than expected %d units", + me, nrrd->dim); + return 1; } if (_nrrdFieldCheck[nrrdField_units](nrrd, useBiff)) { - sprintf(err, "%s: trouble", me); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: trouble", me); + return 1; } return 0; } @@ -780,8 +816,8 @@ _nrrdReadNrrdParse_min (FILE *file, Nrrd *nrrd, } int -_nrrdReadNrrdParse_max (FILE *file, Nrrd *nrrd, - NrrdIoState *nio, int useBiff) { +_nrrdReadNrrdParse_max(FILE *file, Nrrd *nrrd, + NrrdIoState *nio, int useBiff) { AIR_UNUSED(file); AIR_UNUSED(nrrd); @@ -794,57 +830,58 @@ _nrrdReadNrrdParse_max (FILE *file, Nrrd *nrrd, } int -_nrrdReadNrrdParse_old_min (FILE *file, Nrrd *nrrd, - NrrdIoState *nio, int useBiff) { - char me[]="_nrrdReadNrrdParse_old_min", err[AIR_STRLEN_MED]; +_nrrdReadNrrdParse_old_min(FILE *file, Nrrd *nrrd, + NrrdIoState *nio, int useBiff) { + static const char me[]="_nrrdReadNrrdParse_old_min"; char *info; AIR_UNUSED(file); info = nio->line + nio->pos; _PARSE_ONE_VAL(nrrd->oldMin, "%lg", "double"); if (_nrrdFieldCheck[nrrdField_old_min](nrrd, useBiff)) { - sprintf(err, "%s: trouble", me); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: trouble", me); + return 1; } return 0; } int -_nrrdReadNrrdParse_old_max (FILE *file, Nrrd *nrrd, - NrrdIoState *nio, int useBiff) { - char me[]="_nrrdReadNrrdParse_old_max", err[AIR_STRLEN_MED]; +_nrrdReadNrrdParse_old_max(FILE *file, Nrrd *nrrd, + NrrdIoState *nio, int useBiff) { + static const char me[]="_nrrdReadNrrdParse_old_max"; char *info; AIR_UNUSED(file); info = nio->line + nio->pos; _PARSE_ONE_VAL(nrrd->oldMax, "%lg", "double"); if (_nrrdFieldCheck[nrrdField_old_max](nrrd, useBiff)) { - sprintf(err, "%s: trouble", me); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: trouble", me); + return 1; } return 0; } int -_nrrdReadNrrdParse_endian (FILE *file, Nrrd *nrrd, - NrrdIoState *nio, int useBiff) { - char me[]="_nrrdReadNrrdParse_endian", err[AIR_STRLEN_MED]; +_nrrdReadNrrdParse_endian(FILE *file, Nrrd *nrrd, + NrrdIoState *nio, int useBiff) { + static const char me[]="_nrrdReadNrrdParse_endian"; char *info; AIR_UNUSED(file); AIR_UNUSED(nrrd); info = nio->line + nio->pos; if (!(nio->endian = airEnumVal(airEndian, info))) { - sprintf(err, "%s: couldn't parse endian \"%s\"", me, info); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: couldn't parse endian \"%s\"", me, info); + return 1; } return 0; } int -_nrrdReadNrrdParse_encoding (FILE *file, Nrrd *nrrd, - NrrdIoState *nio, int useBiff) { - char me[]="_nrrdReadNrrdParse_encoding", err[AIR_STRLEN_MED]; +_nrrdReadNrrdParse_encoding(FILE *file, Nrrd *nrrd, + NrrdIoState *nio, int useBiff) { + static const char me[]="_nrrdReadNrrdParse_encoding"; char *info; int etype; @@ -852,8 +889,9 @@ _nrrdReadNrrdParse_encoding (FILE *file, Nrrd *nrrd, AIR_UNUSED(nrrd); info = nio->line + nio->pos; if (!(etype = airEnumVal(nrrdEncodingType, info))) { - sprintf(err, "%s: couldn't parse encoding \"%s\"", me, info); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: couldn't parse encoding \"%s\"", me, info); + return 1; } nio->encoding = nrrdEncodingArray[etype]; @@ -861,9 +899,9 @@ _nrrdReadNrrdParse_encoding (FILE *file, Nrrd *nrrd, } int -_nrrdReadNrrdParse_line_skip (FILE *file, Nrrd *nrrd, - NrrdIoState *nio, int useBiff) { - char me[]="_nrrdReadNrrdParse_line_skip", err[AIR_STRLEN_MED]; +_nrrdReadNrrdParse_line_skip(FILE *file, Nrrd *nrrd, + NrrdIoState *nio, int useBiff) { + static const char me[]="_nrrdReadNrrdParse_line_skip"; char *info; AIR_UNUSED(file); @@ -872,48 +910,51 @@ _nrrdReadNrrdParse_line_skip (FILE *file, Nrrd *nrrd, _PARSE_ONE_VAL(nio->lineSkip, "%u", "unsigned int"); /* now that its unsigned, what error checking can I do? if (!(0 <= nio->lineSkip)) { - sprintf(err, "%s: lineSkip value %d invalid", me, nio->lineSkip); - biffMaybeAdd(NRRD, err, useBiff); return 1; - } + biffMaybeAddf(useBiff, NRRD, + "%s: lineSkip value %d invalid", me, nio->lineSkip); + return 1; + } */ return 0; } int -_nrrdReadNrrdParse_byte_skip (FILE *file, Nrrd *nrrd, - NrrdIoState *nio, int useBiff) { - char me[]="_nrrdReadNrrdParse_byte_skip", err[AIR_STRLEN_MED]; +_nrrdReadNrrdParse_byte_skip(FILE *file, Nrrd *nrrd, + NrrdIoState *nio, int useBiff) { + static const char me[]="_nrrdReadNrrdParse_byte_skip"; char *info; - + AIR_UNUSED(file); AIR_UNUSED(nrrd); info = nio->line + nio->pos; - _PARSE_ONE_VAL(nio->byteSkip, "%d", "int"); + _PARSE_ONE_VAL(nio->byteSkip, "%ld", "long int"); if (!(-1 <= nio->byteSkip)) { - sprintf(err, "%s: byteSkip value %d invalid", me, nio->byteSkip); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: byteSkip value %ld invalid", me, nio->byteSkip); + return 1; } return 0; } int -_nrrdReadNrrdParse_keyvalue (FILE *file, Nrrd *nrrd, - NrrdIoState *nio, int useBiff) { - char me[]="_nrrdReadNrrdParse_keyvalue", err[AIR_STRLEN_MED]; +_nrrdReadNrrdParse_keyvalue(FILE *file, Nrrd *nrrd, + NrrdIoState *nio, int useBiff) { + static const char me[]="_nrrdReadNrrdParse_keyvalue"; char *keysep, *line, *key, *value; AIR_UNUSED(file); /* we know this will find something */ line = airStrdup(nio->line); if (!line) { - sprintf(err, "%s: can't allocate parse line", me); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: can't allocate parse line", me); + return 1; } keysep = strstr(line, ":="); if (!keysep) { - sprintf(err, "%s: didn't see \":=\" key/value delimiter in \"%s\"", - me, line); - free(line); biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: didn't see \":=\" key/value delimiter in \"%s\"", + me, line); + free(line); return 1; } keysep[0] = 0; keysep[1] = 0; @@ -931,78 +972,83 @@ _nrrdReadNrrdParse_keyvalue (FILE *file, Nrrd *nrrd, } int -_nrrdReadNrrdParse_sample_units (FILE *file, Nrrd *nrrd, - NrrdIoState *nio, int useBiff) { - char me[]="_nrrdReadNrrdParse_sample_units", err[AIR_STRLEN_MED]; +_nrrdReadNrrdParse_sample_units(FILE *file, Nrrd *nrrd, + NrrdIoState *nio, int useBiff) { + static const char me[]="_nrrdReadNrrdParse_sample_units"; char *info; AIR_UNUSED(file); info = nio->line + nio->pos; if (strlen(info) && !(nrrd->sampleUnits = airStrdup(info))) { - sprintf(err, "%s: couldn't strdup() sampleUnits", me); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: couldn't strdup() sampleUnits", me); + return 1; } if (_nrrdFieldCheck[nrrdField_sample_units](nrrd, useBiff)) { - sprintf(err, "%s: trouble", me); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: trouble", me); + return 1; } return 0; } int -_nrrdReadNrrdParse_space (FILE *file, Nrrd *nrrd, - NrrdIoState *nio, int useBiff) { - char me[]="_nrrdReadNrrdParse_space", err[AIR_STRLEN_MED], *info; +_nrrdReadNrrdParse_space(FILE *file, Nrrd *nrrd, + NrrdIoState *nio, int useBiff) { + static const char me[]="_nrrdReadNrrdParse_space"; + char *info; int space; AIR_UNUSED(file); info = nio->line + nio->pos; if (nio->seen[nrrdField_space_dimension]) { - sprintf(err, "%s: can't specify space after specifying " - "space dimension (%d)", me, nrrd->spaceDim); - biffAdd(NRRD, err); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: can't specify space after specifying " + "space dimension (%d)", me, nrrd->spaceDim); + return 1; } if (!(space = airEnumVal(nrrdSpace, info))) { - sprintf(err, "%s: couldn't parse space \"%s\"", me, info); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: couldn't parse space \"%s\"", me, info); + return 1; } if (nrrdSpaceSet(nrrd, space)) { - sprintf(err, "%s: trouble", me); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: trouble", me); + return 1; } if (_nrrdFieldCheck[nrrdField_space](nrrd, useBiff)) { - sprintf(err, "%s: trouble", me); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: trouble", me); + return 1; } return 0; } int -_nrrdReadNrrdParse_space_dimension (FILE *file, Nrrd *nrrd, - NrrdIoState *nio, int useBiff) { - char me[]="_nrrdReadNrrdParse_space_dimension", err[AIR_STRLEN_MED]; +_nrrdReadNrrdParse_space_dimension(FILE *file, Nrrd *nrrd, + NrrdIoState *nio, int useBiff) { + static const char me[]="_nrrdReadNrrdParse_space_dimension"; char *info; AIR_UNUSED(file); info = nio->line + nio->pos; if (nio->seen[nrrdField_space]) { - sprintf(err, "%s: can't specify space dimension after specifying " - "space (%s)", me, airEnumStr(nrrdSpace, nrrd->space)); - biffAdd(NRRD, err); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: can't specify space dimension after specifying " + "space (%s)", me, airEnumStr(nrrdSpace, nrrd->space)); + return 1; } - _PARSE_ONE_VAL(nrrd->spaceDim, "%d", "int"); + _PARSE_ONE_VAL(nrrd->spaceDim, "%u", "unsigned int"); if (_nrrdFieldCheck[nrrdField_space_dimension](nrrd, useBiff)) { - sprintf(err, "%s: trouble", me); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: trouble", me); + return 1; } return 0; } int -_nrrdReadNrrdParse_space_units (FILE *file, Nrrd *nrrd, - NrrdIoState *nio, int useBiff) { - char me[]="_nrrdReadNrrdParse_space_units", err[AIR_STRLEN_MED]; +_nrrdReadNrrdParse_space_units(FILE *file, Nrrd *nrrd, + NrrdIoState *nio, int useBiff) { + static const char me[]="_nrrdReadNrrdParse_space_units"; char *h; /* this is the "here" pointer which gradually progresses through all the units (for all axes) */ unsigned int ai; @@ -1017,27 +1063,28 @@ _nrrdReadNrrdParse_space_units (FILE *file, Nrrd *nrrd, h = info; for (ai=0; ai<nrrd->spaceDim; ai++) { if (!( nrrd->spaceUnits[ai] = _nrrdGetQuotedString(&h, useBiff) )) { - sprintf(err, "%s: couldn't get get space unit %d of %d", - me, ai+1, nrrd->spaceDim); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: couldn't get get space unit %d of %d", + me, ai+1, nrrd->spaceDim); + return 1; } } if (_nrrdGetQuotedString(&h, AIR_FALSE)) { - sprintf(err, "%s: seemed to have more than expected %d space units", - me, nrrd->spaceDim); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: seemed to have more than expected %d space units", + me, nrrd->spaceDim); + return 1; } if (_nrrdFieldCheck[nrrdField_space_units](nrrd, useBiff)) { - sprintf(err, "%s: trouble", me); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: trouble", me); + return 1; } return 0; } int -_nrrdReadNrrdParse_space_origin (FILE *file, Nrrd *nrrd, - NrrdIoState *nio, int useBiff) { - char me[]="_nrrdReadNrrdParse_space_origin", err[AIR_STRLEN_MED]; +_nrrdReadNrrdParse_space_origin(FILE *file, Nrrd *nrrd, + NrrdIoState *nio, int useBiff) { + static const char me[]="_nrrdReadNrrdParse_space_origin"; char *info; AIR_UNUSED(file); @@ -1047,20 +1094,21 @@ _nrrdReadNrrdParse_space_origin (FILE *file, Nrrd *nrrd, if (_nrrdSpaceVectorParse(nrrd->spaceOrigin, &info, nrrd->spaceDim, useBiff)) { - sprintf(err, "%s: couldn't parse origin \"%s\"", me, info); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: couldn't parse origin \"%s\"", me, info); + return 1; } if (_nrrdFieldCheck[nrrdField_space_origin](nrrd, useBiff)) { - sprintf(err, "%s: trouble", me); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: trouble", me); + return 1; } return 0; } int -_nrrdReadNrrdParse_measurement_frame (FILE *file, Nrrd *nrrd, - NrrdIoState *nio, int useBiff) { - char me[]="_nrrdReadNrrdParse_measurement_frame", err[AIR_STRLEN_MED]; +_nrrdReadNrrdParse_measurement_frame(FILE *file, Nrrd *nrrd, + NrrdIoState *nio, int useBiff) { + static const char me[]="_nrrdReadNrrdParse_measurement_frame"; double colvec[NRRD_SPACE_DIM_MAX]; unsigned int dd, ii; char *info; @@ -1073,9 +1121,10 @@ _nrrdReadNrrdParse_measurement_frame (FILE *file, Nrrd *nrrd, for (dd=0; dd<nrrd->spaceDim; dd++) { /* we are going through the *columns* of the mf matrix */ if (_nrrdSpaceVectorParse(colvec, &info, nrrd->spaceDim, useBiff)) { - sprintf(err, "%s: trouble getting space vector %d of %d", - me, dd+1, nrrd->spaceDim); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: trouble getting space vector %d of %d", + me, dd+1, nrrd->spaceDim); + return 1; } for (ii=0; ii<NRRD_SPACE_DIM_MAX; ii++) { nrrd->measurementFrame[dd][ii] = (ii < nrrd->spaceDim @@ -1084,9 +1133,10 @@ _nrrdReadNrrdParse_measurement_frame (FILE *file, Nrrd *nrrd, } } if (strlen(info) != strspn(info, _nrrdFieldSep)) { - sprintf(err, "%s: seem to have more than expected %d directions", - me, nrrd->spaceDim); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: seem to have more than expected %d directions", + me, nrrd->spaceDim); + return 1; } for (dd=nrrd->spaceDim; dd<NRRD_SPACE_DIM_MAX; dd++) { for (ii=0; ii<NRRD_SPACE_DIM_MAX; ii++) { @@ -1094,15 +1144,15 @@ _nrrdReadNrrdParse_measurement_frame (FILE *file, Nrrd *nrrd, } } if (_nrrdFieldCheck[nrrdField_measurement_frame](nrrd, useBiff)) { - sprintf(err, "%s: trouble", me); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: trouble", me); + return 1; } return 0; } int -_nrrdContainsPercentDAndMore(char *str) { - char *hh, *tmp; +_nrrdContainsPercentThisAndMore(const char *str, char thss) { + const char *hh, *tmp; tmp = str; do { @@ -1119,7 +1169,7 @@ _nrrdContainsPercentDAndMore(char *str) { } while (tmp[0]); hh++; hh += strspn(hh, "0123456789"); - if (!( hh[0] == 'd' )) { + if (!( hh[0] == thss )) { return 0; } hh += strcspn(hh, _nrrdFieldSep); @@ -1151,38 +1201,53 @@ _nrrdDataFNNumber(NrrdIoState *nio) { return ret; } +/* +** this always requires that the per-axis size fields have been set +*/ int _nrrdDataFNCheck(NrrdIoState *nio, Nrrd *nrrd, int useBiff) { - char me[]="_nrrdDataFNCheck", err[AIR_STRLEN_MED]; + static const char me[]="_nrrdDataFNCheck"; size_t pieceSize, pieceNum; + if (!nio->seen[nrrdField_sizes]) { + biffMaybeAddf(useBiff, NRRD, "%s: sorry, currently can't handle " + "multiple detached data files without first knowing " + "the \"%s\" field", + me, airEnumStr(nrrdField, nrrdField_sizes)); + return 1; + } if (nio->dataFileDim < nrrd->dim) { + /* this requires that the per-axis size fields have been set */ _nrrdSplitSizes(&pieceSize, &pieceNum, nrrd, nio->dataFileDim); if (pieceNum != _nrrdDataFNNumber(nio)) { - sprintf(err, "%s: expected %d filenames (of %d-D pieces) but got %d", - me, (int)pieceNum, nio->dataFileDim, - (int)_nrrdDataFNNumber(nio)); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: expected %d filenames (of %d-D pieces) " + "but got %d", me, + (int)pieceNum, nio->dataFileDim, /* HEY use AIR_CAST? */ + (int)_nrrdDataFNNumber(nio)); /* HEY use AIR_CAST? */ + return 1; } } else { /* we're getting data in "slabs" with the same dimension as the nrrd, so for simplicity we assume that they're all equal size */ if (_nrrdDataFNNumber(nio) > nrrd->axis[nrrd->dim-1].size) { - sprintf(err, "%s: can't have more pieces (%d) than axis %d " - "slices (" _AIR_SIZE_T_CNV ") when nrrd dimension and " - "datafile dimension are both %d", me, - (int)_nrrdDataFNNumber(nio), - nrrd->dim-1, nrrd->axis[nrrd->dim-1].size, - nrrd->dim); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: can't have more pieces (%d) than axis %d " + "slices (" _AIR_SIZE_T_CNV ") when nrrd dimension and " + "datafile dimension are both %d", me, + (int)_nrrdDataFNNumber(nio), /* HEY use AIR_CAST? */ + nrrd->dim-1, nrrd->axis[nrrd->dim-1].size, + nrrd->dim); + return 1; } if ((double)nrrd->axis[nrrd->dim-1].size/_nrrdDataFNNumber(nio) != nrrd->axis[nrrd->dim-1].size/_nrrdDataFNNumber(nio)) { - sprintf(err, "%s: number of datafiles (%d) doesn't divide into " - "number of axis %d slices (" _AIR_SIZE_T_CNV ")", me, - (int)_nrrdDataFNNumber(nio), - nrrd->dim-1, nrrd->axis[nrrd->dim-1].size); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: number of datafiles (%d) doesn't divide into " + "number of axis %d slices (" _AIR_SIZE_T_CNV ")", me, + (int)_nrrdDataFNNumber(nio), + nrrd->dim-1, nrrd->axis[nrrd->dim-1].size); + return 1; } } return 0; @@ -1200,9 +1265,9 @@ _nrrdDataFNCheck(NrrdIoState *nio, Nrrd *nrrd, int useBiff) { ** nio->path. */ int -_nrrdReadNrrdParse_data_file (FILE *ffile, Nrrd *nrrd, - NrrdIoState *nio, int useBiff) { - char me[]="_nrrdReadNrrdParse_data_file", err[AIR_STRLEN_MED]; +_nrrdReadNrrdParse_data_file(FILE *ffile, Nrrd *nrrd, + NrrdIoState *nio, int useBiff) { + static const char me[]="_nrrdReadNrrdParse_data_file"; char *info, *nums; unsigned int linelen; int tmp; @@ -1211,72 +1276,89 @@ _nrrdReadNrrdParse_data_file (FILE *ffile, Nrrd *nrrd, mop = airMopNew(); info = airStrdup(nio->line + nio->pos); if (!info) { - sprintf(err, "%s: couldn't copy line!", me); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: couldn't copy line!", me); + return 1; } airMopAdd(mop, info, airFree, airMopAlways); - if (_nrrdContainsPercentDAndMore(info)) { + /* HEY: this change should be made someday + if (_nrrdContainsPercentThisAndMore(info, 'd') + || _nrrdContainsPercentThisAndMore(info, 'u')) { */ + if (_nrrdContainsPercentThisAndMore(info, 'd')) { /* ---------------------------------------------------------- */ /* --------- format.%d <min> <max> <step> [<dim>] ----------- */ /* ---------------------------------------------------------- */ + size_t sspn; + _CHECK_HAVE_DIM; nums = info + strcspn(info, _nrrdFieldSep); - tmp = (int)strspn(nums, _nrrdFieldSep); + sspn = strspn(nums, _nrrdFieldSep); nums[0] = 0; /* terminate so that format is now in info */ - nums += tmp; + nums += sspn; if (!( 3 == sscanf(nums, "%d %d %d",&(nio->dataFNMin), &(nio->dataFNMax), &(nio->dataFNStep)) )) { - sprintf(err, "%s: couldn't parse three ints (min, max, step) after " - "data filename template", me); - biffMaybeAdd(NRRD, err, useBiff); airMopError(mop); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: couldn't parse three ints (min, max, step) after " + "data filename template", me); + airMopError(mop); return 1; } - if ( 4 == sscanf(nums, "%d %d %d %d", &(nio->dataFNMin), + if ( 4 == sscanf(nums, "%d %d %d %u", &(nio->dataFNMin), &(nio->dataFNMax), &(nio->dataFNStep), &(nio->dataFileDim)) ) { if (!( nio->dataFileDim >= 1 && nio->dataFileDim <= nrrd->dim )) { - sprintf(err, "%s: datafile dimension %d outside valid range [1,%d]", - me, nio->dataFileDim, nrrd->dim); - biffMaybeAdd(NRRD, err, useBiff); airMopError(mop); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: datafile dimension %d outside valid range [1,%d]", + me, nio->dataFileDim, nrrd->dim); + airMopError(mop); return 1; } } else { nio->dataFileDim = nrrd->dim-1; } if (0 == nio->dataFNStep) { - sprintf(err, "%s: file number step must be non-zero", me); - biffMaybeAdd(NRRD, err, useBiff); airMopError(mop); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: file number step must be non-zero", me); + airMopError(mop); return 1; } if ((nio->dataFNMax - nio->dataFNMin)*(nio->dataFNStep) < 0) { - sprintf(err, "%s: file number max %d not approached from min %d " - "by step %d", me, - nio->dataFNMax, nio->dataFNMin, nio->dataFNStep); - biffMaybeAdd(NRRD, err, useBiff); airMopError(mop); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: file number max %d not approached from min %d " + "by step %d", me, + nio->dataFNMax, nio->dataFNMin, nio->dataFNStep); + airMopError(mop); return 1; } if (!( nio->dataFNFormat = airStrdup(info) )) { - sprintf(err, "%s: couldn't copy data filename format", me); - biffMaybeAdd(NRRD, err, useBiff); airMopError(mop); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: couldn't copy data filename format", me); + airMopError(mop); return 1; + } + if (_nrrdDataFNCheck(nio, nrrd, useBiff)) { + biffMaybeAddf(useBiff, NRRD, + "%s: trouble with number of datafiles", me); + airMopError(mop); return 1; } } else if (!strncmp(info, NRRD_LIST_FLAG, strlen(NRRD_LIST_FLAG))) { /* ---------------------------------------------------------- */ /* ------------------------- LIST --------------------------- */ /* ---------------------------------------------------------- */ + _CHECK_HAVE_DIM; if (_nrrdHeaderCheck(nrrd, nio, AIR_TRUE)) { - sprintf(err, "%s: NRRD header is incomplete. \"" NRRD_LIST_FLAG - "\" data file specification must be contiguous with " - "end of header!", me); - biffMaybeAdd(NRRD, err, useBiff); airMopError(mop); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: NRRD header is incomplete. \"" + NRRD_LIST_FLAG "\" data file specification must be " + "contiguous with end of header!", me); + airMopError(mop); return 1; } info += strlen(NRRD_LIST_FLAG); if (info[0]) { - if (1 == sscanf(info, "%d", &(nio->dataFileDim))) { + if (1 == sscanf(info, "%u", &(nio->dataFileDim))) { if (!( nio->dataFileDim >= 1 && nio->dataFileDim <= nrrd->dim )) { - sprintf(err, "%s: datafile dimension %d outside valid range [1,%d]", - me, nio->dataFileDim, nrrd->dim); - biffMaybeAdd(NRRD, err, useBiff); airMopError(mop); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: datafile dimension %d outside " + "valid range [1,%d]", + me, nio->dataFileDim, nrrd->dim); + airMopError(mop); return 1; } } else { - sprintf(err, "%s: couldn't parse info after \"" - NRRD_LIST_FLAG "\" as an int", me); - biffMaybeAdd(NRRD, err, useBiff); airMopError(mop); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: couldn't parse info after \"" + NRRD_LIST_FLAG "\" as an int", me); + airMopError(mop); return 1; } } else { /* nothing after NRRD_LIST_FLAG, so dataFileDim is implicit */ @@ -1287,27 +1369,29 @@ _nrrdReadNrrdParse_data_file (FILE *ffile, Nrrd *nrrd, /* yes, nio->line is re-used/over-written here, but I don't think that's a problem */ if (_nrrdOneLine(&linelen, nio, ffile)) { - sprintf(err, "%s: trouble getting file name line", me); - biffMaybeAdd(NRRD, err, useBiff); airMopError(mop); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: trouble getting file name line", me); + airMopError(mop); return 1; } if (linelen > 0) { tmp = airArrayLenIncr(nio->dataFNArr, 1); nio->dataFN[tmp] = airStrdup(nio->line); } } while (linelen > 0); - + if (_nrrdDataFNCheck(nio, nrrd, useBiff)) { + biffMaybeAddf(useBiff, NRRD, + "%s: trouble with number of datafiles", me); + airMopError(mop); return 1; + } } else { /* ---------------------------------------------------------- */ /* -------------------- (single filename) ------------------- */ /* ---------------------------------------------------------- */ - /* there is apparently only a single detached data file */ + /* there is apparently only a single detached data file; for + this its okay to not yet know nrrd->dim */ tmp = airArrayLenIncr(nio->dataFNArr, 1); nio->dataFN[tmp] = airStrdup(info); - nio->dataFileDim = nrrd->dim; - } - if (_nrrdDataFNCheck(nio, nrrd, useBiff)) { - sprintf(err, "%s: trouble with number of datafiles", me); - biffMaybeAdd(NRRD, err, useBiff); airMopError(mop); return 1; + nio->dataFileDim = 0; } airMopOkay(mop); return 0; diff --git a/Utilities/ITK/Utilities/NrrdIO/pre-GNUmakefile b/Utilities/ITK/Utilities/NrrdIO/pre-GNUmakefile index 1055e82e56cfea5b1c98b99989c966fea1665fd8..bd2ef6a4736845c264d7104745f5b3316c3dcad0 100644 --- a/Utilities/ITK/Utilities/NrrdIO/pre-GNUmakefile +++ b/Utilities/ITK/Utilities/NrrdIO/pre-GNUmakefile @@ -1,6 +1,6 @@ # # NrrdIO: stand-alone code for basic nrrd functionality -# Copyright (C) 2005 Gordon Kindlmann +# Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann # Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah # # This software is provided 'as-is', without any express or implied @@ -28,7 +28,7 @@ ### ### for the NrrdIO in ITK: ### -### cvs update +### svn update ### rm -f itk_NrrdIO_mangle.h ### touch itk_NrrdIO_mangle.h ### make -f pre-GNUmakefile clean @@ -41,7 +41,7 @@ ### ### for the NrrdIO in Teem: ### -### cvs update +### svn update ### make -f pre-GNUmakefile clean ### make -f pre-GNUmakefile ### make -f sample-GNUmakefile @@ -80,7 +80,7 @@ TEEM_HDRS = $(addprefix teem/, \ NEED_AIR = $(addprefix air/, \ 754.c mop.c array.c parseAir.c dio.c \ sane.c endianAir.c string.c enum.c miscAir.c) -NEED_BIFF = biff/biffbiff.c +NEED_BIFF = $(addprefix biff/, biffbiff.c biffmsg.c) NEED_NRRD = $(addprefix nrrd/, \ accessors.c defaultsNrrd.c enumsNrrd.c arraysNrrd.c methodsNrrd.c \ reorder.c axis.c simple.c comment.c keyvalue.c endianNrrd.c \ @@ -96,13 +96,18 @@ NEED_PRIV_HDRS = air/privateAir.h nrrd/privateNrrd.h ### from air, biff, and nrrd ### .PHONY: all -all: $(TEEM_HDRS) $(NEED_SRCS) $(NEED_PRIV_HDRS) NrrdIO.h NrrdIO_Srcs.txt +all: $(TEEM_HDRS) $(NEED_SRCS) $(NEED_PRIV_HDRS) NrrdIO.h $(ITK_SRC_ROOT)/Utilities/itk_zlib.h NrrdIO_Srcs.txt ### NrrdIO.h is basically the result of cat'ing together all the ### teem headers in $(NEED_HDRS), but we do need to "unteem" them. ### -$(NEED_PUB_HDRS) $(NEED_PRIV_HDRS): - tail +20 $(TEEM_SRC_ROOT)/src/$@ \ +$(NEED_PUB_HDRS): + tail --lines=+22 $(TEEM_SRC_ROOT)/src/$@ \ + | perl unteem.pl \ + | grep -v HAS_BEEN_INCLUDED > $(notdir $@) +$(NEED_PRIV_HDRS): + tail --lines=+22 $(TEEM_SRC_ROOT)/src/$@ \ + | cat preamble.c - \ | perl unteem.pl \ | grep -v HAS_BEEN_INCLUDED > $(notdir $@) NrrdIO.h: $(NEED_PUB_HDRS) @@ -118,7 +123,7 @@ NrrdIO_Srcs.txt: ### The teem*.h headers: we need only change the pre-amble here ### teem/%.h: - tail +20 $(TEEM_SRC_ROOT)/include/$(notdir $@) \ + tail --lines=+22 $(TEEM_SRC_ROOT)/include/$(notdir $@) \ | cat preamble.c - > $(notdir $@) ### The rest: by design, these targets have the library names as part @@ -126,7 +131,7 @@ teem/%.h: ### source file without any VPATH games ### %.h %.c: - tail +20 $(TEEM_SRC_ROOT)/src/$@ \ + tail --lines=+22 $(TEEM_SRC_ROOT)/src/$@ \ | cat preamble.c - \ | perl unteem.pl \ | grep -v HAS_BEEN_INCLUDED > $(notdir $@) diff --git a/Utilities/ITK/Utilities/NrrdIO/preamble.c b/Utilities/ITK/Utilities/NrrdIO/preamble.c index 451ecf0043460785f8e5a5047742aa243a5d92dd..b3e91fd7a3f26c68fa26e82ba4dfa046dc5afc9e 100644 --- a/Utilities/ITK/Utilities/NrrdIO/preamble.c +++ b/Utilities/ITK/Utilities/NrrdIO/preamble.c @@ -1,6 +1,6 @@ /* NrrdIO: stand-alone code for basic nrrd functionality - Copyright (C) 2005 Gordon Kindlmann + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah This software is provided 'as-is', without any express or implied diff --git a/Utilities/ITK/Utilities/NrrdIO/privateAir.h b/Utilities/ITK/Utilities/NrrdIO/privateAir.h index 83b69dfad826ed1fd178857e8b951e38da8afad6..17e16414b2f0583cc259b8ec6c5aed59796e6812 100644 --- a/Utilities/ITK/Utilities/NrrdIO/privateAir.h +++ b/Utilities/ITK/Utilities/NrrdIO/privateAir.h @@ -1,3 +1,26 @@ +/* + NrrdIO: stand-alone code for basic nrrd functionality + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann + Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any + damages arising from the use of this software. + + Permission is granted to anyone to use this software for any + purpose, including commercial applications, and to alter it and + redistribute it freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product + documentation would be appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must + not be misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source distribution. +*/ #include "teemEndian.h" #include "teemQnanhibit.h" @@ -57,4 +80,3 @@ typedef union { double v; } _airDouble; - diff --git a/Utilities/ITK/Utilities/NrrdIO/privateNrrd.h b/Utilities/ITK/Utilities/NrrdIO/privateNrrd.h index fa9fcd4e102758263c02008ee83825b691fe1e02..fe8f9ba984def82f82b2c02bf34fbf3d6a2b6efa 100644 --- a/Utilities/ITK/Utilities/NrrdIO/privateNrrd.h +++ b/Utilities/ITK/Utilities/NrrdIO/privateNrrd.h @@ -1,3 +1,26 @@ +/* + NrrdIO: stand-alone code for basic nrrd functionality + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann + Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any + damages arising from the use of this software. + + Permission is granted to anyone to use this software for any + purpose, including commercial applications, and to alter it and + redistribute it freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product + documentation would be appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must + not be misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source distribution. +*/ #ifdef _WIN32 @@ -41,8 +64,8 @@ typedef union { } _nrrdAxisInfoGetPtrs; /* keyvalue.c */ -extern int _nrrdKeyValueFwrite(FILE *file, const char *prefix, - const char *key, const char *value); +extern int _nrrdKeyValueWrite(FILE *file, char **stringP, const char *prefix, + const char *key, const char *value); /* formatXXX.c */ extern const char *_nrrdFormatURLLine0; @@ -64,8 +87,7 @@ extern const NrrdEncoding _nrrdEncodingGzip; extern const NrrdEncoding _nrrdEncodingBzip2; /* read.c */ -extern int _nrrdOneLine (unsigned int *lenP, NrrdIoState *nio, FILE *file); -extern int _nrrdCalloc (Nrrd *nrrd, NrrdIoState *nio, FILE *file); +extern int _nrrdCalloc(Nrrd *nrrd, NrrdIoState *nio, FILE *file); extern char _nrrdFieldSep[]; /* arrays.c */ @@ -80,24 +102,12 @@ extern char *_nrrdContentGet(const Nrrd *nin); extern int _nrrdContentSet_nva(Nrrd *nout, const char *func, char *content, const char *format, va_list arg); -extern int _nrrdContentSet(Nrrd *nout, const char *func, - char *content, const char *format, ...); +extern int _nrrdContentSet_va(Nrrd *nout, const char *func, + char *content, const char *format, ...); extern int _nrrdFieldCheckSpaceInfo(const Nrrd *nrrd, int useBiff); extern int (*_nrrdFieldCheck[NRRD_FIELD_MAX+1])(const Nrrd *nrrd, int useBiff); extern void _nrrdSplitSizes(size_t *pieceSize, size_t *pieceNum, Nrrd *nrrd, unsigned int listDim); -extern void _nrrdSpaceVecScaleAdd2(double sum[NRRD_SPACE_DIM_MAX], - double sclA, - const double vecA[NRRD_SPACE_DIM_MAX], - double sclB, - const double vecB[NRRD_SPACE_DIM_MAX]); -extern void _nrrdSpaceVecScale(double out[NRRD_SPACE_DIM_MAX], - double scl, - const double vec[NRRD_SPACE_DIM_MAX]); -extern double _nrrdSpaceVecNorm(int sdim, - const double vec[NRRD_SPACE_DIM_MAX]); -extern void _nrrdSpaceVecSetNaN(double vec[NRRD_SPACE_DIM_MAX]); - /* axis.c */ extern int _nrrdKindAltered(int kindIn, int resampling); @@ -110,6 +120,7 @@ extern int _nrrdCenter2(int center, int def); /* convert.c */ extern void (*_nrrdConv[][NRRD_TYPE_MAX+1])(void *, const void *, size_t); +extern void (*_nrrdClampConv[][NRRD_TYPE_MAX+1])(void *, const void *, size_t); /* read.c */ extern char _nrrdFieldStr[NRRD_FIELD_MAX+1][AIR_STRLEN_SMALL]; @@ -130,10 +141,7 @@ extern void _nrrdFprintFieldInfo(FILE *file, char *prefix, int field); /* parseNrrd.c */ -extern int _nrrdDataFNCheck(NrrdIoState *nio, Nrrd *nrrd, int useBiff); -extern int _nrrdContainsPercentDAndMore(char *str); extern int _nrrdReadNrrdParseField(NrrdIoState *nio, int useBiff); -extern unsigned int _nrrdDataFNNumber(NrrdIoState *nio); /* methodsNrrd.c */ extern void nrrdPeripheralInit(Nrrd *nrrd); @@ -143,8 +151,14 @@ extern int _nrrdSizeCheck(const size_t *size, unsigned int dim, int useBiff); extern void _nrrdTraverse(Nrrd *nrrd); #if TEEM_ZLIB +#if TEEM_VTK_MANGLE +#include "vtk_zlib_mangle.h" +#endif +//The procedure to checkout this file from NrrdIO repository has +//#include <zlib.h> instead, but this line must be edited as below +//for ITK to build without turning on ITK_USE_SYSTEM_ZLIB. #include "itk_zlib.h" - + /* gzio.c */ extern gzFile _nrrdGzOpen(FILE* fd, const char *mode); extern int _nrrdGzClose(gzFile file); diff --git a/Utilities/ITK/Utilities/NrrdIO/read.c b/Utilities/ITK/Utilities/NrrdIO/read.c index 17a395f950ba3432fcee657231638130511efb20..ff7dad0d99bd43f46b759e68603f669490d1fab6 100644 --- a/Utilities/ITK/Utilities/NrrdIO/read.c +++ b/Utilities/ITK/Utilities/NrrdIO/read.c @@ -1,6 +1,6 @@ /* NrrdIO: stand-alone code for basic nrrd functionality - Copyright (C) 2005 Gordon Kindlmann + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah This software is provided 'as-is', without any express or implied @@ -22,7 +22,6 @@ 3. This notice may not be removed or altered from any source distribution. */ - #include "NrrdIO.h" #include "privateNrrd.h" @@ -30,10 +29,9 @@ #include <bzlib.h> #endif -#include "teem32bit.h" - char _nrrdRelativePathFlag[] = "./"; char _nrrdFieldSep[] = " \t"; +char _nrrdLineSep[] = "\r\n"; char _nrrdNoSpaceVector[] = "none"; char _nrrdTextSep[] = " ,\t"; @@ -42,6 +40,35 @@ typedef union { void **v; } _cppu; +/* +** return length of next "line" in nio->headerStringRead +*/ +unsigned int +_nrrdHeaderStringOneLineStrlen(NrrdIoState *nio) { + + return AIR_CAST(unsigned int, + strcspn(nio->headerStringRead + + nio->headerStrpos, _nrrdLineSep)); +} + +/* +** read next "line" in nio->headerStringRead +*/ +unsigned int +_nrrdHeaderStringOneLine(NrrdIoState *nio) { + unsigned int len1, len2; + + len1 = _nrrdHeaderStringOneLineStrlen(nio); + strncpy(nio->line, nio->headerStringRead + nio->headerStrpos, len1); + nio->line[len1] = '\0'; + nio->headerStrpos += len1; + len2 = AIR_CAST(unsigned int, + strspn(nio->headerStringRead + + nio->headerStrpos, _nrrdLineSep)); + nio->headerStrpos += len2; + return len1; +} + /* ** _nrrdOneLine ** @@ -56,36 +83,60 @@ typedef union { ** Does use biff */ int -_nrrdOneLine (unsigned int *lenP, NrrdIoState *nio, FILE *file) { - char me[]="_nrrdOneLine", err[AIR_STRLEN_MED], **line; +_nrrdOneLine(unsigned int *lenP, NrrdIoState *nio, FILE *file) { + static const char me[]="_nrrdOneLine"; + char **line; airArray *mop, *lineArr; int lineIdx; _cppu u; - unsigned int len; + unsigned int len, needLen; - if (!( lenP && nio && file)) { - sprintf(err, "%s: got NULL pointer (%p, %p, %p)", me, - lenP, nio, file); - biffAdd(NRRD, err); return 1; + if (!( lenP && nio && (file || nio->headerStringRead))) { + biffAddf(NRRD, "%s: got NULL pointer (%p, %p, %p/%p)", me, + AIR_CAST(void*, lenP), AIR_CAST(void*, nio), + AIR_CAST(void*, file), nio->headerStringRead); + return 1; } if (0 == nio->lineLen) { /* nio->line hasn't been allocated for anything */ - nio->line = (char*)calloc(3, sizeof(char)); nio->lineLen = 3; + nio->line = (char*)malloc(nio->lineLen); + if (!nio->line) { + biffAddf(NRRD, "%s: couldn't alloc %d-char line\n", me, nio->lineLen); + *lenP = 0; return 1; + } + } + if (file) { + len = airOneLine(file, nio->line, nio->lineLen); + } else { + /* NOTE: NULL-ity error check above makes this safe */ + needLen = _nrrdHeaderStringOneLineStrlen(nio); + if (needLen+1 > nio->lineLen) { + nio->lineLen = needLen+1; + airFree(nio->line); /* lose previous allocated line */ + nio->line = (char*)malloc(nio->lineLen); + if (!nio->line) { + biffAddf(NRRD, "%s: couldn't alloc %d-char line\n", + me, nio->lineLen); + *lenP = 0; return 1; + } + } + len = _nrrdHeaderStringOneLine(nio); } - len = airOneLine(file, nio->line, nio->lineLen); if (len <= nio->lineLen) { - /* otherwise we hit EOF before a newline, or the line (possibly empty) - fit within the nio->line, neither of which is an error here */ + /* otherwise we hit EOF (or end of nio->headerStringRead) before a + newline, or the line (possibly empty) fit within the nio->line, + neither of which is an error here */ *lenP = len; } else { /* line didn't fit in buffer, so we have to increase line buffer size and put the line together in pieces */ + /* NOTE: this will never happen when reading from nio->headerStringRead */ u.c = &line; lineArr = airArrayNew(u.v, NULL, sizeof(char *), 1); if (!lineArr) { - sprintf(err, "%s: couldn't allocate airArray", me); - biffAdd(NRRD, err); *lenP = 0; return 1; + biffAddf(NRRD, "%s: couldn't allocate airArray", me); + *lenP = 0; return 1; } airArrayPointerCB(lineArr, airNull, airFree); mop = airMopNew(); @@ -93,37 +144,39 @@ _nrrdOneLine (unsigned int *lenP, NrrdIoState *nio, FILE *file) { while (len == nio->lineLen+1) { lineIdx = airArrayLenIncr(lineArr, 1); if (-1 == lineIdx) { - sprintf(err, "%s: couldn't increment line buffer array", me); - biffAdd(NRRD, err); *lenP = 0; airMopError(mop); return 1; + biffAddf(NRRD, "%s: couldn't increment line buffer array", me); + *lenP = 0; airMopError(mop); return 1; } line[lineIdx] = nio->line; nio->lineLen *= 2; nio->line = (char*)malloc(nio->lineLen); if (!nio->line) { - sprintf(err, "%s: couldn't alloc %d-char line\n", me, nio->lineLen); - biffAdd(NRRD, err); *lenP = 0; airMopError(mop); return 1; + biffAddf(NRRD, "%s: couldn't alloc %d-char line\n", + me, nio->lineLen); + *lenP = 0; airMopError(mop); return 1; } len = airOneLine(file, nio->line, nio->lineLen); } /* last part did fit in nio->line buffer, also save this into line[] */ lineIdx = airArrayLenIncr(lineArr, 1); if (!lineArr->data) { - sprintf(err, "%s: couldn't increment line buffer array", me); - biffAdd(NRRD, err); *lenP = 0; airMopError(mop); return 1; + biffAddf(NRRD, "%s: couldn't increment line buffer array", me); + *lenP = 0; airMopError(mop); return 1; } line[lineIdx] = nio->line; nio->lineLen *= 3; /* for good measure */ nio->line = (char*)malloc(nio->lineLen); if (!nio->line) { - sprintf(err, "%s: couldn't alloc %d-char line\n", me, nio->lineLen); - biffAdd(NRRD, err); *lenP = 0; airMopError(mop); return 1; + biffAddf(NRRD, "%s: couldn't alloc %d-char line\n", me, nio->lineLen); + *lenP = 0; airMopError(mop); return 1; } /* now concatenate everything into a new nio->line */ strcpy(nio->line, ""); for (lineIdx=0; lineIdx<(int)lineArr->len; lineIdx++) { strcat(nio->line, line[lineIdx]); } - *lenP = (unsigned int)(strlen(nio->line) + 1); + /* HEY: API is bad: *lenP should be a size_t pointer! */ + *lenP = AIR_CAST(unsigned int, strlen(nio->line)) + 1; airMopError(mop); } return 0; @@ -145,8 +198,8 @@ _nrrdOneLine (unsigned int *lenP, NrrdIoState *nio, FILE *file) { ** NOTE: this assumes the checking that is done by _nrrdHeaderCheck */ int -_nrrdCalloc (Nrrd *nrrd, NrrdIoState *nio, FILE *file) { - char me[]="_nrrdCalloc", err[AIR_STRLEN_MED]; +_nrrdCalloc(Nrrd *nrrd, NrrdIoState *nio, FILE *file) { + static const char me[]="_nrrdCalloc"; size_t needDataSize; int fd; @@ -169,10 +222,10 @@ _nrrdCalloc (Nrrd *nrrd, NrrdIoState *nio, FILE *file) { nrrd->data = malloc(needDataSize); } if (!nrrd->data) { - sprintf(err, "%s: couldn't allocate " _AIR_SIZE_T_CNV - " things of size " _AIR_SIZE_T_CNV, - me, nrrdElementNumber(nrrd), nrrdElementSize(nrrd)); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: couldn't allocate " _AIR_SIZE_T_CNV + " things of size " _AIR_SIZE_T_CNV, + me, nrrdElementNumber(nrrd), nrrdElementSize(nrrd)); + return 1; } } /* make it look like it came from calloc(), as used by nrrdNew() */ @@ -187,9 +240,9 @@ _nrrdCalloc (Nrrd *nrrd, NrrdIoState *nio, FILE *file) { ** uses the NrrdIoState for its line buffer (used by _nrrdOneLine) */ int -nrrdLineSkip (FILE *dataFile, NrrdIoState *nio) { +nrrdLineSkip(FILE *dataFile, NrrdIoState *nio) { + static const char me[]="nrrdLineSkip"; unsigned int lsi, skipRet; - char me[]="nrrdLineSkip", err[AIR_STRLEN_MED]; /* For compressed data: If you don't actually have ascii headers on top of your gzipped data then you will potentially huge lines @@ -197,20 +250,20 @@ nrrdLineSkip (FILE *dataFile, NrrdIoState *nio) { "Garbage in, Garbage out." */ if (!( dataFile && nio )) { - sprintf(err, "%s: got NULL pointer", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: got NULL pointer", me); + return 1; } - + for (lsi=0; lsi<nio->lineSkip; lsi++) { if (_nrrdOneLine(&skipRet, nio, dataFile)) { - sprintf(err, "%s: error skipping line %u of %u", - me, lsi+1, nio->lineSkip); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: error skipping line %u of %u", + me, lsi+1, nio->lineSkip); + return 1; } if (!skipRet) { - sprintf(err, "%s: hit EOF skipping line %u of %u", - me, lsi+1, nio->lineSkip); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: hit EOF skipping line %u of %u", + me, lsi+1, nio->lineSkip); + return 1; } } return 0; @@ -224,48 +277,46 @@ nrrdLineSkip (FILE *dataFile, NrrdIoState *nio) { ** with -1 == byteSkip */ int -nrrdByteSkip (FILE *dataFile, Nrrd *nrrd, NrrdIoState *nio) { - int i, skipRet; - char me[]="nrrdByteSkip", err[AIR_STRLEN_MED]; +nrrdByteSkip(FILE *dataFile, Nrrd *nrrd, NrrdIoState *nio) { + static const char me[]="nrrdByteSkip"; + int skipRet; + long bi, backHack; size_t bsize; if (!( dataFile && nrrd && nio )) { - sprintf(err, "%s: got NULL pointer", me); - biffAdd(NRRD, err); return 1; - } - if (nio->byteSkip < -1) { - sprintf(err, "%s: byteSkip %d not valid", me, nio->byteSkip); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: got NULL pointer", me); + return 1; } - if (-1 == nio->byteSkip) { + if (-1 >= nio->byteSkip) { if (nrrdEncodingRaw != nio->encoding) { - sprintf(err, "%s: can do backwards byte skip only in %s " - "encoding, not %s", me, - nrrdEncodingRaw->name, nio->encoding->name); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: can do backwards byte skip only in %s " + "encoding, not %s", me, + nrrdEncodingRaw->name, nio->encoding->name); + return 1; } if (stdin == dataFile) { - sprintf(err, "%s: can't fseek on stdin", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: can't fseek on stdin", me); + return 1; } bsize = nrrdElementNumber(nrrd)/_nrrdDataFNNumber(nio); bsize *= nrrdElementSize(nrrd); - if (fseek(dataFile, -((long)bsize), SEEK_END)) { - sprintf(err, "%s: failed to fseek(dataFile, " _AIR_SIZE_T_CNV - ", SEEK_END)", me, bsize); - biffAdd(NRRD, err); return 1; + backHack = -nio->byteSkip - 1; + if (fseek(dataFile, -((long)(bsize + backHack)), SEEK_END)) { + biffAddf(NRRD, "%s: failed to fseek(dataFile, " _AIR_SIZE_T_CNV + ", SEEK_END)", me, bsize); + return 1; } if (nrrdStateVerboseIO >= 2) { fprintf(stderr, "(%s: actually skipped %d bytes)\n", me, (int)ftell(dataFile)); } } else { - for (i=1; i<=nio->byteSkip; i++) { + for (bi=1; bi<=nio->byteSkip; bi++) { skipRet = fgetc(dataFile); if (EOF == skipRet) { - sprintf(err, "%s: hit EOF skipping byte %d of %d", - me, i, nio->byteSkip); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: hit EOF skipping byte %ld of %ld", + me, bi, nio->byteSkip); + return 1; } } } @@ -273,40 +324,50 @@ nrrdByteSkip (FILE *dataFile, Nrrd *nrrd, NrrdIoState *nio) { } /* -******** nrrdRead() -** -** read in nrrd from a given file. The main job of this function is to -** start reading the file, to determine the format, and then call the -** appropriate format's reader. This means that the various encoding -** (data) readers can assume that nio->format is usefully set. +** _nrrdRead() ** -** The only input information that nio is used for is nio->path, so that -** detached header-relative data files can be found. +** read in nrrd from a given file *OR* given string. The main job of +** this function is to start reading the file/string, to determine the +** format, and then call the appropriate format's reader. This means +** that the various encoding (data) readers can assume that +** nio->format is usefully set. ** +** If (file), the only input information that nio is used for is +** nio->path, so that detached header-relative data files can be +** found. If (string), the headerStr-related fields in the _nio will +** be set/used */ int -nrrdRead (Nrrd *nrrd, FILE *file, NrrdIoState *nio) { - char me[]="nrrdRead", err[AIR_STRLEN_MED]; +_nrrdRead(Nrrd *nrrd, FILE *file, const char *string, NrrdIoState *_nio) { + static const char me[]="_nrrdRead"; unsigned int llen; + NrrdIoState *nio; int nfi; airArray *mop; /* sanity check, for good measure */ if (!nrrdSanity()) { - sprintf(err, "%s: sanity check FAILED: have to fix and re-compile", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: sanity check FAILED: have to fix and re-compile", + me); + return 1; } - - if (!(file && nrrd)) { - sprintf(err, "%s: got NULL pointer", me); - biffAdd(NRRD, err); return 1; + + if (!((file || string) && nrrd)) { + biffAddf(NRRD, "%s: got NULL pointer", me); + return 1; + } + if (file && string) { + biffAddf(NRRD, "%s: can't read from both file and string", me); + return 1; } mop = airMopNew(); - if (!nio) { + if (_nio) { + nio = _nio; + } else { nio = nrrdIoStateNew(); if (!nio) { - sprintf(err, "%s: couldn't alloc I/O struct", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: couldn't alloc I/O struct", me); + return 1; } airMopAdd(mop, nio, (airMopper)nrrdIoStateNix, airMopAlways); } @@ -326,13 +387,17 @@ nrrdRead (Nrrd *nrrd, FILE *file, NrrdIoState *nio) { /* initialize given nrrd (but we have thwarted freeing existing memory) */ nrrdInit(nrrd); + /* tell the nio where to find the string to read from */ + nio->headerStringRead = string; + if (_nrrdOneLine(&llen, nio, file)) { - sprintf(err, "%s: error getting first line (containing \"magic\")", me); - biffAdd(NRRD, err); airMopError(mop); return 1; + biffAddf(NRRD, "%s: error getting first line (containing \"magic\")", + me); + airMopError(mop); return 1; } if (!llen) { - sprintf(err, "%s: immediately hit EOF", me); - biffAdd(NRRD, err); airMopError(mop); return 1; + biffAddf(NRRD, "%s: immediately hit EOF", me); + airMopError(mop); return 1; } nio->format = nrrdFormatUnknown; @@ -345,22 +410,27 @@ nrrdRead (Nrrd *nrrd, FILE *file, NrrdIoState *nio) { } } if (nrrdFormatUnknown == nio->format) { - sprintf(err, "%s: couldn't parse \"%s\" as magic or beginning of " - "any recognized format", me, nio->line); - biffAdd(NRRD, err); airMopError(mop); return 1; + biffAddf(NRRD, "%s: couldn't parse \"%s\" as magic or beginning of " + "any recognized format", me, nio->line); + airMopError(mop); return 1; + } + if (string && nrrdFormatNRRD != nio->format) { + biffAddf(NRRD, "%s: sorry, can only read %s files from strings (not %s)", + me, nrrdFormatNRRD->name, nio->format->name); + airMopError(mop); return 1; } /* try to read the file */ if (nio->format->read(file, nrrd, nio)) { - sprintf(err, "%s: trouble reading %s file", me, nio->format->name); - biffAdd(NRRD, err); airMopError(mop); return 1; + biffAddf(NRRD, "%s: trouble reading %s file", me, nio->format->name); + airMopError(mop); return 1; } - + /* reshape up grayscale images, if desired */ if (nio->format->isImage && 2 == nrrd->dim && nrrdStateGrayscaleImage3D) { if (nrrdAxesInsert(nrrd, nrrd, 0)) { - sprintf(err, "%s:", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s:", me); + return 1; } } @@ -375,14 +445,50 @@ nrrdRead (Nrrd *nrrd, FILE *file, NrrdIoState *nio) { except that we (probably stupidly) allow nrrd->data to be NULL, given the possibility of using nio->skipData */ if (_nrrdCheck(nrrd, AIR_FALSE, AIR_TRUE)) { - sprintf(err, "%s: problem with nrrd after reading", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: problem with nrrd after reading", me); + return 1; } - + airMopOkay(mop); return 0; } +/* +******** nrrdRead() +** +** now just a wrapper around _nrrdRead(); reads a NRRD from a FILE * +*/ +int +nrrdRead(Nrrd *nrrd, FILE *file, NrrdIoState *_nio) { + static const char me[]="nrrdRead"; + + if (_nrrdRead(nrrd, file, NULL, _nio)) { + biffAddf(NRRD, "%s: trouble", me); + return 1; + } + return 0; +} + +/* +******** nrrdStringRead() +** +** also a wrapper around _nrrdRead(); reads a NRRD from a char *. +** +** Because the same underlying _nrrdRead() is used, the same semantics +** about using existing nrrd->data when possible applies, as does the +** action of nrrdStateGrayscaleImage3D +*/ +int +nrrdStringRead(Nrrd *nrrd, const char *string, NrrdIoState *_nio) { + static const char me[]="nrrdRead"; + + if (_nrrdRead(nrrd, NULL, string, _nio)) { + biffAddf(NRRD, "%s: trouble", me); + return 1; + } + return 0; +} + /* ** _nrrdSplitName() ** @@ -395,9 +501,8 @@ nrrdRead (Nrrd *nrrd, FILE *file, NrrdIoState *nio) { ** ".", and the name is copied into base. */ void -_nrrdSplitName (char **dirP, char **baseP, const char *name) { +_nrrdSplitName(char **dirP, char **baseP, const char *name) { char *where; - char separator; if (dirP) { *dirP = (char *)airFree(*dirP); @@ -405,19 +510,7 @@ _nrrdSplitName (char **dirP, char **baseP, const char *name) { if (baseP) { *baseP = (char *)airFree(*baseP); } - - /* for unix, the separator is '/' */ - separator = '/'; - - /* for windows, the separator might be '\' */ -#ifdef _WIN32 - if (strchr(name, '\\')) { - separator = '\\'; - } -#endif - - where = strrchr(name, separator); - + where = strrchr(name, '/'); /* we found a valid break if the last directory character is somewhere in the string except the last character */ if (where && airStrlen(where) > 1) { @@ -504,21 +597,21 @@ I plan on shamelessly copying this, just like I shamelessly copied the ** */ int -nrrdLoad (Nrrd *nrrd, const char *filename, NrrdIoState *nio) { - char me[]="nrrdLoad", err[AIR_STRLEN_MED]; +nrrdLoad(Nrrd *nrrd, const char *filename, NrrdIoState *nio) { + static const char me[]="nrrdLoad"; FILE *file; airArray *mop; if (!(nrrd && filename)) { - sprintf(err, "%s: got NULL pointer", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: got NULL pointer", me); + return 1; } mop = airMopNew(); if (!nio) { nio = nrrdIoStateNew(); if (!nio) { - sprintf(err, "%s: couldn't alloc I/O struct", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: couldn't alloc I/O struct", me); + return 1; } airMopAdd(mop, nio, (airMopper)nrrdIoStateNix, airMopAlways); } @@ -530,16 +623,16 @@ nrrdLoad (Nrrd *nrrd, const char *filename, NrrdIoState *nio) { /* printf("!%s: |%s|%s|\n", me, nio->dir, nio->base); */ if (!( file = airFopen(filename, stdin, "rb") )) { - sprintf(err, "%s: fopen(\"%s\",\"rb\") failed: %s", - me, filename, strerror(errno)); - biffAdd(NRRD, err); airMopError(mop); return 2; + biffAddf(NRRD, "%s: fopen(\"%s\",\"rb\") failed: %s", + me, filename, strerror(errno)); + airMopError(mop); return 2; } airMopAdd(mop, file, (airMopper)airFclose, airMopOnError); /* non-error exiting is handled below */ if (nrrdRead(nrrd, file, nio)) { - sprintf(err, "%s: trouble reading \"%s\"", me, filename); - biffAdd(NRRD, err); airMopError(mop); return 1; + biffAddf(NRRD, "%s: trouble reading \"%s\"", me, filename); + airMopError(mop); return 1; } if (nrrdFormatNRRD == nio->format @@ -556,3 +649,50 @@ nrrdLoad (Nrrd *nrrd, const char *filename, NrrdIoState *nio) { airMopOkay(mop); return 0; } + +int +nrrdLoadMulti(Nrrd *const *nin, unsigned int ninLen, + const char *fnameFormat, + unsigned int numStart, NrrdIoState *nio) { + static const char me[]="nrrdLoadMulti"; + char *fname; + airArray *mop; + unsigned int nii; + + if (!(nin && fnameFormat)) { + biffAddf(NRRD, "%s: got NULL pointer", me); + return 1; + } + if (!( _nrrdContainsPercentThisAndMore(fnameFormat, 'u') )) { + biffAddf(NRRD, "%s: given format \"%s\" doesn't seem to " + "have the \"%%u\" conversion specification to sprintf " + "an unsigned int\n", me, fnameFormat); + return 1; + } + + mop = airMopNew(); + /* should be big enough for the number replacing the format sequence */ + fname = AIR_CAST(char *, malloc(strlen(fnameFormat) + 128)); + if (!(fname)) { + biffAddf(NRRD, "%s: couldn't allocate local fname buffer", me); + airMopError(mop); return 1; + } + airMopAdd(mop, fname, airFree, airMopAlways); + + for (nii=0; nii<ninLen; nii++) { + unsigned int num; + num = numStart + nii; + sprintf(fname, fnameFormat, num); + if (nrrdLoad(nin[nii], fname, nio)) { + biffAddf(NRRD, "%s: trouble loading nin[%u] from %s", me, nii, fname); + airMopError(mop); return 1; + } + /* HEY: GLK hopes that the nio doesn't have any state that needs + resetting, but we can't call nrrdIoStateInit() because that + would negate the purpose of sending in the nio for all but the + first saved nrrd */ + } + + airMopOkay(mop); + return 0; +} diff --git a/Utilities/ITK/Utilities/NrrdIO/reorder.c b/Utilities/ITK/Utilities/NrrdIO/reorder.c index 04841d36779d441b6fe845397f36ea53f80c73a4..a451346576363022688f7fad416fb54df36d78e1 100644 --- a/Utilities/ITK/Utilities/NrrdIO/reorder.c +++ b/Utilities/ITK/Utilities/NrrdIO/reorder.c @@ -1,6 +1,6 @@ /* NrrdIO: stand-alone code for basic nrrd functionality - Copyright (C) 2005 Gordon Kindlmann + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah This software is provided 'as-is', without any express or implied @@ -22,15 +22,9 @@ 3. This notice may not be removed or altered from any source distribution. */ -#if defined(__GNUC__) && (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) -#pragma GCC diagnostic ignored "-Warray-bounds" -#endif - #include "NrrdIO.h" #include "privateNrrd.h" -#include "teem32bit.h" - /* ******** nrrdInvertPerm() ** @@ -41,31 +35,32 @@ */ int nrrdInvertPerm(unsigned int *invp, const unsigned int *pp, unsigned int nn) { - char me[]="nrrdInvertPerm", err[AIR_STRLEN_MED]; + static const char me[]="nrrdInvertPerm"; int problem; unsigned int ii; if (!(invp && pp && nn > 0)) { - sprintf(err, "%s: got NULL pointer or non-positive nn (%d)", me, nn); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: got NULL pointer or non-positive nn (%d)", me, nn); + return 1; } /* use the given array "invp" as a temp buffer for validity checking */ memset(invp, 0, nn*sizeof(int)); for (ii=0; ii<nn; ii++) { if (!( pp[ii] <= nn-1)) { - sprintf(err, "%s: permutation element #%d == %d out of bounds [0,%d]", - me, ii, pp[ii], nn-1); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, + "%s: permutation element #%d == %d out of bounds [0,%d]", + me, ii, pp[ii], nn-1); + return 1; } invp[pp[ii]]++; } problem = AIR_FALSE; for (ii=0; ii<nn; ii++) { if (1 != invp[ii]) { - sprintf(err, "%s: element #%d mapped to %d times (should be once)", - me, ii, invp[ii]); - biffAdd(NRRD, err); problem = AIR_TRUE; + biffAddf(NRRD, "%s: element #%d mapped to %d times (should be once)", + me, ii, invp[ii]); + problem = AIR_TRUE; } } if (problem) { @@ -89,28 +84,30 @@ nrrdInvertPerm(unsigned int *invp, const unsigned int *pp, unsigned int nn) { */ int nrrdAxesInsert(Nrrd *nout, const Nrrd *nin, unsigned int axis) { - char me[]="nrrdAxesInsert", func[]="axinsert", err[AIR_STRLEN_MED]; + static const char me[]="nrrdAxesInsert", func[]="axinsert"; unsigned int ai; if (!(nout && nin)) { - sprintf(err, "%s: got NULL pointer", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: got NULL pointer", me); + return 1; } if (!( axis <= nin->dim )) { - sprintf(err, "%s: given axis (%d) outside valid range [0, %d]", - me, axis, nin->dim); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: given axis (%d) outside valid range [0, %d]", + me, axis, nin->dim); + return 1; } if (NRRD_DIM_MAX == nin->dim) { - sprintf(err, "%s: given nrrd already at NRRD_DIM_MAX (%d)", - me, NRRD_DIM_MAX); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: given nrrd already at NRRD_DIM_MAX (%d)", + me, NRRD_DIM_MAX); + return 1; } if (nout != nin) { if (_nrrdCopy(nout, nin, (NRRD_BASIC_INFO_COMMENTS_BIT - | NRRD_BASIC_INFO_KEYVALUEPAIRS_BIT))) { - sprintf(err, "%s:", me); - biffAdd(NRRD, err); return 1; + | (nrrdStateKeyValuePairsPropagate + ? 0 + : NRRD_BASIC_INFO_KEYVALUEPAIRS_BIT)))) { + biffAddf(NRRD, "%s:", me); + return 1; } } nout->dim = 1 + nin->dim; @@ -125,9 +122,9 @@ nrrdAxesInsert(Nrrd *nout, const Nrrd *nin, unsigned int axis) { nout->axis[axis].kind = nrrdKindStub; } nout->axis[axis].size = 1; - if (nrrdContentSet(nout, func, nin, "%d", axis)) { - sprintf(err, "%s:", me); - biffAdd(NRRD, err); return 1; + if (nrrdContentSet_va(nout, func, nin, "%d", axis)) { + biffAddf(NRRD, "%s:", me); + return 1; } /* all basic info has already been copied by nrrdCopy() above */ return 0; @@ -154,20 +151,19 @@ nrrdAxesInsert(Nrrd *nout, const Nrrd *nin, unsigned int axis) { */ int nrrdAxesPermute(Nrrd *nout, const Nrrd *nin, const unsigned int *axes) { - char me[]="nrrdAxesPermute", func[]="permute", err[AIR_STRLEN_MED], - buff1[NRRD_DIM_MAX*30], buff2[AIR_STRLEN_SMALL]; + static const char me[]="nrrdAxesPermute", func[]="permute"; + char buff1[NRRD_DIM_MAX*30], buff2[AIR_STRLEN_SMALL]; size_t idxOut, idxIn, /* indices for input and output scanlines */ lineSize, /* size of block of memory which can be moved contiguously from input to output, thought of as a "scanline" */ numLines, /* how many "scanlines" there are to permute */ szIn[NRRD_DIM_MAX], *lszIn, - szOut[NRRD_DIM_MAX], *lszOut; - char *dataIn, *dataOut; - int axmap[NRRD_DIM_MAX]; - unsigned int + szOut[NRRD_DIM_MAX], *lszOut, cIn[NRRD_DIM_MAX], cOut[NRRD_DIM_MAX]; + char *dataIn, *dataOut; + int axmap[NRRD_DIM_MAX]; unsigned int ai, /* running index along dimensions */ lowPax, /* lowest axis which is "p"ermutated */ @@ -179,18 +175,18 @@ nrrdAxesPermute(Nrrd *nout, const Nrrd *nin, const unsigned int *axes) { mop = airMopNew(); if (!(nin && nout && axes)) { - sprintf(err, "%s: got NULL pointer", me); - biffAdd(NRRD, err); airMopError(mop); return 1; + biffAddf(NRRD, "%s: got NULL pointer", me); + airMopError(mop); return 1; } /* we don't actually need ip[], computing it is for error checking */ if (nrrdInvertPerm(ip, axes, nin->dim)) { - sprintf(err, "%s: couldn't compute axis permutation inverse", me); - biffAdd(NRRD, err); airMopError(mop); return 1; + biffAddf(NRRD, "%s: couldn't compute axis permutation inverse", me); + airMopError(mop); return 1; } - /* this shouldn't actually be necessary ... */ + /* this shouldn't actually be necessary .. */ if (!nrrdElementSize(nin)) { - sprintf(err, "%s: nrrd reports zero element size!", me); - biffAdd(NRRD, err); airMopError(mop); return 1; + biffAddf(NRRD, "%s: nrrd reports zero element size!", me); + airMopError(mop); return 1; } for (ai=0; ai<nin->dim && axes[ai] == ai; ai++) @@ -200,15 +196,15 @@ nrrdAxesPermute(Nrrd *nout, const Nrrd *nin, const unsigned int *axes) { /* allocate output by initial copy */ if (nout != nin) { if (nrrdCopy(nout, nin)) { - sprintf(err, "%s: trouble copying input", me); - biffAdd(NRRD, err); airMopError(mop); return 1; + biffAddf(NRRD, "%s: trouble copying input", me); + airMopError(mop); return 1; } dataIn = (char*)nin->data; } else { dataIn = (char*)calloc(nrrdElementNumber(nin), nrrdElementSize(nin)); if (!dataIn) { - sprintf(err, "%s: couldn't create local copy of data", me); - biffAdd(NRRD, err); airMopError(mop); return 1; + biffAddf(NRRD, "%s: couldn't create local copy of data", me); + airMopError(mop); return 1; } airMopAdd(mop, dataIn, airFree, airMopAlways); memcpy(dataIn, nin->data, nrrdElementNumber(nin)*nrrdElementSize(nin)); @@ -222,8 +218,8 @@ nrrdAxesPermute(Nrrd *nout, const Nrrd *nin, const unsigned int *axes) { } nrrdAxisInfoGet_nva(nin, nrrdAxisInfoSize, szIn); if (nrrdAxisInfoCopy(nout, nin, axmap, NRRD_AXIS_INFO_NONE)) { - sprintf(err, "%s:", me); - biffAdd(NRRD, err); airMopError(mop); return 1; + biffAddf(NRRD, "%s:", me); + airMopError(mop); return 1; } nrrdAxisInfoGet_nva(nout, nrrdAxisInfoSize, szOut); /* the skinny */ @@ -236,13 +232,13 @@ nrrdAxesPermute(Nrrd *nout, const Nrrd *nin, const unsigned int *axes) { lszIn = szIn + lowPax; lszOut = szOut + lowPax; ldim = nin->dim - lowPax; - memset(laxes, 0, NRRD_DIM_MAX*sizeof(int)); + memset(laxes, 0, NRRD_DIM_MAX*sizeof(unsigned int)); for (ai=0; ai<ldim; ai++) { laxes[ai] = axes[ai+lowPax]-lowPax; } dataOut = (char *)nout->data; - memset(cIn, 0, NRRD_DIM_MAX*sizeof(int)); - memset(cOut, 0, NRRD_DIM_MAX*sizeof(int)); + memset(cIn, 0, NRRD_DIM_MAX*sizeof(size_t)); + memset(cOut, 0, NRRD_DIM_MAX*sizeof(size_t)); for (idxOut=0; idxOut<numLines; idxOut++) { /* in our representation of the coordinates of the start of the scanlines that we're copying, we are not even storing all the @@ -261,9 +257,9 @@ nrrdAxesPermute(Nrrd *nout, const Nrrd *nin, const unsigned int *axes) { sprintf(buff2, "%s%d", (ai ? "," : ""), axes[ai]); strcat(buff1, buff2); } - if (nrrdContentSet(nout, func, nin, "%s", buff1)) { - sprintf(err, "%s:", me); - biffAdd(NRRD, err); airMopError(mop); return 1; + if (nrrdContentSet_va(nout, func, nin, "%s", buff1)) { + biffAddf(NRRD, "%s:", me); + airMopError(mop); return 1; } if (nout != nin) { if (nrrdBasicInfoCopy(nout, nin, @@ -273,9 +269,11 @@ nrrdAxesPermute(Nrrd *nout, const Nrrd *nin, const unsigned int *axes) { | NRRD_BASIC_INFO_DIMENSION_BIT | NRRD_BASIC_INFO_CONTENT_BIT | NRRD_BASIC_INFO_COMMENTS_BIT - | NRRD_BASIC_INFO_KEYVALUEPAIRS_BIT)) { - sprintf(err, "%s:", me); - biffAdd(NRRD, err); airMopError(mop); return 1; + | (nrrdStateKeyValuePairsPropagate + ? 0 + : NRRD_BASIC_INFO_KEYVALUEPAIRS_BIT))) { + biffAddf(NRRD, "%s:", me); + airMopError(mop); return 1; } } } @@ -304,8 +302,23 @@ nrrdAxesPermute(Nrrd *nout, const Nrrd *nin, const unsigned int *axes) { int nrrdShuffle(Nrrd *nout, const Nrrd *nin, unsigned int axis, const size_t *perm) { - char me[]="nrrdShuffle", func[]="shuffle", err[AIR_STRLEN_MED], - buff1[NRRD_DIM_MAX*30], buff2[AIR_STRLEN_SMALL]; + static const char me[]="nrrdShuffle", func[]="shuffle"; + char buff2[AIR_STRLEN_SMALL]; + /* Sun Feb 8 13:13:58 CST 2009: There was a memory bug here caused + by using the same buff1[NRRD_DIM_MAX*30] declaration that had + worked fine for nrrdAxesPermute and nrrdReshape, but does NOT + work here because now samples along an axes are re-ordered, not + axes, so its often not allocated for long enough to hold the + string that's printed to it. Ideally there'd be another argument + that says whether to document the shuffle in the content string, + which would mean an API change. Or, we can use a secret + heuristic (or maybe later a nrrdState variable) for determining + when an axis is short enough to make documenting the shuffle + interesting. This is useful since functions like nrrdFlip() + probably do *not* need the shuffle (the sample reversal) to be + documented for long axes */ +#define LONGEST_INTERESTING_AXIS 42 + char buff1[LONGEST_INTERESTING_AXIS*30]; unsigned int ai, ldim, len, cIn[NRRD_DIM_MAX+1], @@ -314,41 +327,41 @@ nrrdShuffle(Nrrd *nout, const Nrrd *nin, unsigned int axis, char *dataIn, *dataOut; if (!(nin && nout && perm)) { - sprintf(err, "%s: got NULL pointer", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: got NULL pointer", me); + return 1; } if (nout == nin) { - sprintf(err, "%s: nout==nin disallowed", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: nout==nin disallowed", me); + return 1; } if (!( axis < nin->dim )) { - sprintf(err, "%s: axis %d outside valid range [0,%d]", - me, axis, nin->dim-1); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: axis %d outside valid range [0,%d]", + me, axis, nin->dim-1); + return 1; } - len = (unsigned int)(nin->axis[axis].size); + len = AIR_CAST(unsigned int, nin->axis[axis].size); for (ai=0; ai<len; ai++) { if (!( perm[ai] < len )) { - sprintf(err, "%s: perm[%d] (" _AIR_SIZE_T_CNV - ") outside valid range [0,%d]", me, ai, perm[ai], len-1); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: perm[%d] (" _AIR_SIZE_T_CNV + ") outside valid range [0,%d]", me, ai, perm[ai], len-1); + return 1; } } - /* this shouldn't actually be necessary ... */ + /* this shouldn't actually be necessary .. */ if (!nrrdElementSize(nin)) { - sprintf(err, "%s: nrrd reports zero element size!", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: nrrd reports zero element size!", me); + return 1; } /* set information in new volume */ nout->blockSize = nin->blockSize; nrrdAxisInfoGet_nva(nin, nrrdAxisInfoSize, size); if (nrrdMaybeAlloc_nva(nout, nin->type, nin->dim, size)) { - sprintf(err, "%s: failed to allocate output", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: failed to allocate output", me); + return 1; } if (nrrdAxisInfoCopy(nout, nin, NULL, NRRD_AXIS_INFO_NONE)) { - sprintf(err, "%s:", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s:", me); + return 1; } /* the min and max along the shuffled axis are now meaningless */ nout->axis[axis].min = nout->axis[axis].max = AIR_NAN; @@ -385,21 +398,29 @@ nrrdShuffle(Nrrd *nout, const Nrrd *nin, unsigned int axis, memset(cOut, 0, (NRRD_DIM_MAX+1)*sizeof(int)); for (idxOut=0; idxOut<numLines; idxOut++) { memcpy(cIn, cOut, ldim*sizeof(int)); - cIn[0] = (unsigned int)(perm[cOut[0]]); + cIn[0] = AIR_CAST(unsigned int, perm[cOut[0]]); NRRD_INDEX_GEN(idxIn, cIn, lsize, ldim); NRRD_INDEX_GEN(idxOut, cOut, lsize, ldim); memcpy(dataOut + idxOut*lineSize, dataIn + idxIn*lineSize, lineSize); NRRD_COORD_INCR(cOut, lsize, ldim, 0); } - /* content */ - strcpy(buff1, ""); - for (ai=0; ai<nin->dim; ai++) { - sprintf(buff2, "%s" _AIR_SIZE_T_CNV, (ai ? "," : ""), perm[ai]); - strcat(buff1, buff2); - } - if (nrrdContentSet(nout, func, nin, "%s", buff1)) { - sprintf(err, "%s:", me); - biffAdd(NRRD, err); return 1; + /* Set content. The LONGEST_INTERESTING_AXIS hack avoids the + previous array out-of-bounds bug */ + if (len <= LONGEST_INTERESTING_AXIS) { + strcpy(buff1, ""); + for (ai=0; ai<len; ai++) { + sprintf(buff2, "%s" _AIR_SIZE_T_CNV, (ai ? "," : ""), perm[ai]); + strcat(buff1, buff2); + } + if (nrrdContentSet_va(nout, func, nin, "%s", buff1)) { + biffAddf(NRRD, "%s:", me); + return 1; + } + } else { + if (nrrdContentSet_va(nout, func, nin, "")) { + biffAddf(NRRD, "%s:", me); + return 1; + } } if (nrrdBasicInfoCopy(nout, nin, NRRD_BASIC_INFO_DATA_BIT @@ -408,11 +429,14 @@ nrrdShuffle(Nrrd *nout, const Nrrd *nin, unsigned int axis, | NRRD_BASIC_INFO_DIMENSION_BIT | NRRD_BASIC_INFO_CONTENT_BIT | NRRD_BASIC_INFO_COMMENTS_BIT - | NRRD_BASIC_INFO_KEYVALUEPAIRS_BIT)) { - sprintf(err, "%s:", me); - biffAdd(NRRD, err); return 1; + | (nrrdStateKeyValuePairsPropagate + ? 0 + : NRRD_BASIC_INFO_KEYVALUEPAIRS_BIT))) { + biffAddf(NRRD, "%s:", me); + return 1; } - + return 0; +#undef LONGEST_INTERESTING_AXIS } diff --git a/Utilities/ITK/Utilities/NrrdIO/sample-GNUmakefile b/Utilities/ITK/Utilities/NrrdIO/sample-GNUmakefile index 3ca8eeccd0187229e27725f9fdc6bbfd7d7a0258..275d53f7a5f94e2456e072fd48d903be5e0c0f99 100644 --- a/Utilities/ITK/Utilities/NrrdIO/sample-GNUmakefile +++ b/Utilities/ITK/Utilities/NrrdIO/sample-GNUmakefile @@ -1,6 +1,6 @@ # # NrrdIO: stand-alone code for basic nrrd functionality -# Copyright (C) 2005 Gordon Kindlmann +# Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann # Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah # # This software is provided 'as-is', without any express or implied @@ -45,12 +45,12 @@ PLATFORM_DEFS = \ -DTEEM_DIO=0 \ -DTEEM_32BIT=1 \ - -DTEEM_ENDIAN=4321 \ + -DTEEM_ENDIAN=1234 \ -DTEEM_QNANHIBIT=1 ### Any architecture-specific flags to cc ### -CCFLAGS = -O3 -ffloat-store -W -Wall +CCFLAGS = -O3 -ffloat-store -W -Wall -I$(ITK_BIN_ROOT)/Utilities -I$(ITK_SRC_ROOT)/Utilities ### This also has to be set per-architecture- whether or not we need to ### run ranlib on libraries created via ar @@ -62,11 +62,11 @@ RANLIB = ranlib ### find the zlib includes and libraries ### ZLIB_IPATH = -ZLIB_LPATH = +ZLIB_LPATH =$(ITK_BIN_ROOT)/bin/libitkzlib.a ### We'll build the static libNrrdIO library, and one test program ### -ALL = libNrrdIO.a sampleIO +ALL = libNrrdIO.a sampleIO all: $(ALL) ### The libNrrdIO library is built from the objects from the source files diff --git a/Utilities/ITK/Utilities/NrrdIO/sampleIO.c b/Utilities/ITK/Utilities/NrrdIO/sampleIO.c index 39a8f8c041f3b4ee3abe6d4a22aef8f0b8a23583..999241576b3b44928500e4d946f218f547819495 100644 --- a/Utilities/ITK/Utilities/NrrdIO/sampleIO.c +++ b/Utilities/ITK/Utilities/NrrdIO/sampleIO.c @@ -1,6 +1,6 @@ /* NrrdIO: stand-alone code for basic nrrd functionality - Copyright (C) 2005 Gordon Kindlmann + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah This software is provided 'as-is', without any express or implied diff --git a/Utilities/ITK/Utilities/NrrdIO/sane.c b/Utilities/ITK/Utilities/NrrdIO/sane.c index d3b925dd65d5daa3d56e550edf5ce7444ef3dc45..c6ad83e325015f11a9bfae290085ee934549b677 100644 --- a/Utilities/ITK/Utilities/NrrdIO/sane.c +++ b/Utilities/ITK/Utilities/NrrdIO/sane.c @@ -1,6 +1,6 @@ /* NrrdIO: stand-alone code for basic nrrd functionality - Copyright (C) 2005 Gordon Kindlmann + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah This software is provided 'as-is', without any express or implied @@ -99,6 +99,22 @@ airSanity(void) { if (AIR_QNANHIBIT != (int)mant) { return airInsane_QNaNHiBit; } + + if (!( airFP_QNAN == airFPClass_f(AIR_NAN) + && airFP_QNAN == airFPClass_f(AIR_QNAN) + +#if !defined(__APPLE__) && ( defined(_MSC_VER) || _MSC_VER < 1400 ) /* VS2005 converts SNAN to QNAN */ + && airFP_SNAN == airFPClass_f(AIR_SNAN) +#endif + && airFP_QNAN == airFPClass_d(AIR_NAN) + && airFP_QNAN == airFPClass_d(AIR_QNAN) )) { + /* we don't bother checking for + airFP_SNAN == airFPClass_d(AIR_SNAN) because + on some platforms the signal-ness of the NaN + is not preserved in double-float conversion */ + + return airInsane_AIR_NAN; + } if (!(airFP_QNAN == airFPClass_f(nanF) && airFP_POS_INF == airFPClass_f(pinfF) && airFP_NEG_INF == airFPClass_f(ninfF))) { @@ -140,6 +156,7 @@ _airInsaneErr[AIR_INSANE_MAX+1][AIR_STRLEN_MED] = { "AIR_EXISTS(NaN) was true", "air_FPClass_f() wrong after double->float assignment", "TEEM_QNANHIBIT is wrong", + "airFPClass(AIR_QNAN,AIR_SNAN) wrong", "TEEM_DIO has invalid value", "TEEM_32BIT is wrong", "unsigned char isn't 8 bits", diff --git a/Utilities/ITK/Utilities/NrrdIO/simple.c b/Utilities/ITK/Utilities/NrrdIO/simple.c index 1cbc46c6314b20ec062ffa5b0341a1174ea51458..e716cd6102343668c8cc7ee3ddc3a3e1a686eafd 100644 --- a/Utilities/ITK/Utilities/NrrdIO/simple.c +++ b/Utilities/ITK/Utilities/NrrdIO/simple.c @@ -1,6 +1,6 @@ /* NrrdIO: stand-alone code for basic nrrd functionality - Copyright (C) 2005 Gordon Kindlmann + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah This software is provided 'as-is', without any express or implied @@ -25,7 +25,6 @@ #include "NrrdIO.h" #include "privateNrrd.h" -#include "teem32bit.h" #include <limits.h> const char * @@ -42,9 +41,9 @@ nrrdBiffKey = "nrrd"; */ unsigned int nrrdSpaceDimension(int space) { - char me[]="nrrdSpaceDimension"; + static const char me[]="nrrdSpaceDimension"; int ret; - + if (!( AIR_IN_OP(nrrdSpaceUnknown, space, nrrdSpaceLast) )) { /* they gave us invalid or unknown space */ return 0; @@ -77,24 +76,37 @@ nrrdSpaceDimension(int space) { /* ******** nrrdSpaceSet ** -** What to use to set space, when a value from nrrdSpace enum is known +** What to use to set space, when a value from nrrdSpace enum is known, +** or, to nullify all space-related information when passed nrrdSpaceUnknown */ int nrrdSpaceSet(Nrrd *nrrd, int space) { - char me[]="nrrdSpaceSet", err[AIR_STRLEN_MED]; + static const char me[]="nrrdSpaceSet"; + unsigned axi, saxi; if (!nrrd) { - sprintf(err, "%s: got NULL pointer", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: got NULL pointer", me); + return 1; } - if (nrrdSpaceUnknown != space) { + if (nrrdSpaceUnknown == space) { + nrrd->space = nrrdSpaceUnknown; + nrrd->spaceDim = 0; + for (axi=0; axi<NRRD_DIM_MAX; axi++) { + nrrdSpaceVecSetNaN(nrrd->axis[axi].spaceDirection); + } + for (saxi=0; saxi<NRRD_SPACE_DIM_MAX; saxi++) { + airFree(nrrd->spaceUnits[saxi]); + nrrd->spaceUnits[saxi] = NULL; + } + nrrdSpaceVecSetNaN(nrrd->spaceOrigin); + } else { if (airEnumValCheck(nrrdSpace, space)) { - sprintf(err, "%s: given space (%d) not valid", me, space); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: given space (%d) not valid", me, space); + return 1; } + nrrd->space = space; + nrrd->spaceDim = nrrdSpaceDimension(space); } - nrrd->space = space; - nrrd->spaceDim = nrrdSpaceDimension(space); return 0; } @@ -106,15 +118,15 @@ nrrdSpaceSet(Nrrd *nrrd, int space) { */ int nrrdSpaceDimensionSet(Nrrd *nrrd, unsigned int spaceDim) { - char me[]="nrrdSpaceDimensionSet", err[AIR_STRLEN_MED]; + static const char me[]="nrrdSpaceDimensionSet"; if (!nrrd) { - sprintf(err, "%s: got NULL pointer", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: got NULL pointer", me); + return 1; } if (!( spaceDim <= NRRD_SPACE_DIM_MAX )) { - sprintf(err, "%s: given spaceDim (%u) not valid", me, spaceDim); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: given spaceDim (%u) not valid", me, spaceDim); + return 1; } nrrd->space = nrrdSpaceUnknown; nrrd->spaceDim = spaceDim; @@ -158,18 +170,18 @@ nrrdSpaceOriginGet(const Nrrd *nrrd, int nrrdSpaceOriginSet(Nrrd *nrrd, double vector[NRRD_SPACE_DIM_MAX]) { - char me[]="nrrdSpaceOriginSet", err[AIR_STRLEN_MED]; + static const char me[]="nrrdSpaceOriginSet"; unsigned int sdi; if (!( nrrd && vector )) { - sprintf(err, "%s: got NULL pointer", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: got NULL pointer", me); + return 1; } if (!( 0 < nrrd->spaceDim && nrrd->spaceDim <= NRRD_SPACE_DIM_MAX )) { - sprintf(err, "%s: set spaceDim %d not valid", me, nrrd->spaceDim); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: set spaceDim %d not valid", me, nrrd->spaceDim); + return 1; } - + for (sdi=0; sdi<nrrd->spaceDim; sdi++) { nrrd->spaceOrigin[sdi] = vector[sdi]; } @@ -204,8 +216,8 @@ nrrdSpaceOriginSet(Nrrd *nrrd, ** ** nrrdOriginStatusNoMin: can't compute "origin" without axis->min ** -** nrrdOriginStatusNoMaxOrSpacing: can't compute origin without either -** axis->max or axis->spacing +** nrrdOriginStatusNoMaxOrSpacing: can't compute origin without (axis->min +** and) either axis->max or axis->spacing ** ** nrrdOriginStatusOkay: all is well */ @@ -214,7 +226,7 @@ nrrdOriginCalculate(const Nrrd *nrrd, unsigned int *axisIdx, unsigned int axisIdxNum, int defaultCenter, double *origin) { const NrrdAxisInfo *axis[NRRD_SPACE_DIM_MAX]; - int center, size, okay, gotSpace, gotMin, gotMaxOrSpacing; + int center, okay, gotSpace, gotMin, gotMaxOrSpacing; unsigned int ai; double min, spacing; @@ -276,7 +288,8 @@ nrrdOriginCalculate(const Nrrd *nrrd, } for (ai=0; ai<axisIdxNum; ai++) { - size = (int)(axis[ai]->size); + size_t size; + size = axis[ai]->size; min = axis[ai]->min; center = (nrrdCenterUnknown != axis[ai]->center ? axis[ai]->center @@ -291,33 +304,58 @@ nrrdOriginCalculate(const Nrrd *nrrd, } void -_nrrdSpaceVecScaleAdd2(double sum[NRRD_SPACE_DIM_MAX], +nrrdSpaceVecCopy(double dst[NRRD_SPACE_DIM_MAX], + const double src[NRRD_SPACE_DIM_MAX]) { + int ii; + + for (ii=0; ii<NRRD_SPACE_DIM_MAX; ii++) { + dst[ii] = src[ii]; + } +} + +/* +** NOTE: since this was created until Wed Sep 21 13:34:17 EDT 2005, +** nrrdSpaceVecScaleAdd2 and nrrdSpaceVecScale would treat a +** non-existent vector coefficient as 0.0. The reason for this had +** to do with how the function is used. For example, in nrrdCrop +** +** _nrrdSpaceVecCopy(nout->spaceOrigin, nin->spaceOrigin); +** for (ai=0; ai<nin->dim; ai++) { +** _nrrdSpaceVecScaleAdd2(nout->spaceOrigin, +** 1.0, nout->spaceOrigin, +** min[ai], nin->axis[ai].spaceDirection); +** } +** +** but the problem with this is that non-spatial axes end up clobbering +** the existance of otherwise existing spaceOrigin and spaceDirections. +** It was decided, however, that this logic should be outside the +** arithmetic functions below, not inside. NOTE: the old functionality +** is stuck in ITK 2.2, via NrrdIO. +*/ + +void +nrrdSpaceVecScaleAdd2(double sum[NRRD_SPACE_DIM_MAX], double sclA, const double vecA[NRRD_SPACE_DIM_MAX], double sclB, const double vecB[NRRD_SPACE_DIM_MAX]) { int ii; - double A, B; for (ii=0; ii<NRRD_SPACE_DIM_MAX; ii++) { - A = AIR_EXISTS(vecA[ii]) ? vecA[ii] : 0; - B = AIR_EXISTS(vecB[ii]) ? vecB[ii] : 0; - sum[ii] = sclA*A + sclB*B; + sum[ii] = sclA*vecA[ii] + sclB*vecB[ii]; } } void -_nrrdSpaceVecScale(double out[NRRD_SPACE_DIM_MAX], +nrrdSpaceVecScale(double out[NRRD_SPACE_DIM_MAX], double scl, const double vec[NRRD_SPACE_DIM_MAX]) { int ii; - double v; for (ii=0; ii<NRRD_SPACE_DIM_MAX; ii++) { - v = AIR_EXISTS(vec[ii]) ? vec[ii] : 0; - out[ii] = scl*v; + out[ii] = scl*vec[ii]; } } double -_nrrdSpaceVecNorm(int sdim, const double vec[NRRD_SPACE_DIM_MAX]) { +nrrdSpaceVecNorm(int sdim, const double vec[NRRD_SPACE_DIM_MAX]) { int di; double nn; @@ -329,7 +367,7 @@ _nrrdSpaceVecNorm(int sdim, const double vec[NRRD_SPACE_DIM_MAX]) { } void -_nrrdSpaceVecSetNaN(double vec[NRRD_SPACE_DIM_MAX]) { +nrrdSpaceVecSetNaN(double vec[NRRD_SPACE_DIM_MAX]) { int di; for (di=0; di<NRRD_SPACE_DIM_MAX; di++) { @@ -346,7 +384,7 @@ _nrrdSpaceVecSetNaN(double vec[NRRD_SPACE_DIM_MAX]) { */ char * _nrrdContentGet(const Nrrd *nin) { - char me[]="_nrrdContentGet"; + static const char me[]="_nrrdContentGet"; char *ret; ret = ((nin && nin->content) ? @@ -360,14 +398,15 @@ _nrrdContentGet(const Nrrd *nin) { } int -_nrrdContentSet_nva (Nrrd *nout, const char *func, - char *content, const char *format, va_list arg) { - char me[]="_nrrdContentSet_nva", err[AIR_STRLEN_MED], *buff; +_nrrdContentSet_nva(Nrrd *nout, const char *func, + char *content, const char *format, va_list arg) { + static const char me[]="_nrrdContentSet_nva"; + char *buff; buff = (char *)malloc(128*AIR_STRLEN_HUGE); if (!buff) { - sprintf(err, "%s: couln't alloc buffer!", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: couln't alloc buffer!", me); + return 1; } nout->content = (char *)airFree(nout->content); @@ -384,8 +423,8 @@ _nrrdContentSet_nva (Nrrd *nout, const char *func, + 1 /* ')' */ + 1, sizeof(char)); /* '\0' */ if (!nout->content) { - sprintf(err, "%s: couln't alloc output content!", me); - biffAdd(NRRD, err); airFree(buff); return 1; + biffAddf(NRRD, "%s: couln't alloc output content!", me); + airFree(buff); return 1; } sprintf(nout->content, "%s(%s%s%s)", func, content, airStrlen(buff) ? "," : "", buff); @@ -394,15 +433,15 @@ _nrrdContentSet_nva (Nrrd *nout, const char *func, } int -_nrrdContentSet (Nrrd *nout, const char *func, - char *content, const char *format, ...) { - char me[]="_nrrdContentSet", err[AIR_STRLEN_MED]; +_nrrdContentSet_va(Nrrd *nout, const char *func, + char *content, const char *format, ...) { + static const char me[]="_nrrdContentSet_va"; va_list ap; va_start(ap, format); if (_nrrdContentSet_nva(nout, func, content, format, ap)) { - sprintf(err, "%s:", me); - biffAdd(NRRD, err); free(content); return 1; + biffAddf(NRRD, "%s:", me); + free(content); return 1; } va_end(ap); @@ -423,15 +462,15 @@ _nrrdContentSet (Nrrd *nout, const char *func, ** Does allow nout==nin, which requires some care. */ int -nrrdContentSet (Nrrd *nout, const char *func, - const Nrrd *nin, const char *format, ...) { - char me[]="nrrdContentSet", err[AIR_STRLEN_MED]; +nrrdContentSet_va(Nrrd *nout, const char *func, + const Nrrd *nin, const char *format, ...) { + static const char me[]="nrrdContentSet_va"; va_list ap; char *content; if (!(nout && func && nin && format)) { - sprintf(err, "%s: got NULL pointer", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: got NULL pointer", me); + return 1; } if (nrrdStateDisableContent) { /* we kill content always */ @@ -449,8 +488,8 @@ nrrdContentSet (Nrrd *nout, const char *func, content = _nrrdContentGet(nin); va_start(ap, format); if (_nrrdContentSet_nva(nout, func, content, format, ap)) { - sprintf(err, "%s:", me); - biffAdd(NRRD, err); va_end(ap); free(content); return 1; + biffAddf(NRRD, "%s:", me); + va_end(ap); free(content); return 1; } va_end(ap); free(content); @@ -464,7 +503,7 @@ nrrdContentSet (Nrrd *nout, const char *func, ** writes verbose description of nrrd to given file */ void -nrrdDescribe (FILE *file, const Nrrd *nrrd) { +nrrdDescribe(FILE *file, const Nrrd *nrrd) { unsigned int ai; if (file && nrrd) { @@ -527,36 +566,39 @@ nrrdDescribe (FILE *file, const Nrrd *nrrd) { */ int _nrrdFieldCheckSpaceInfo(const Nrrd *nrrd, int useBiff) { - char me[]="_nrrdFieldCheckSpaceInfo", err[AIR_STRLEN_MED]; + static const char me[]="_nrrdFieldCheckSpaceInfo"; unsigned int dd, ii; int exists; if (!( !nrrd->space || !airEnumValCheck(nrrdSpace, nrrd->space) )) { - sprintf(err, "%s: space %d invalid", me, nrrd->space); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: space %d invalid", + me, nrrd->space); + return 1; } if (!( nrrd->spaceDim <= NRRD_SPACE_DIM_MAX )) { - sprintf(err, "%s: space dimension %d is outside valid range " - "[0,NRRD_SPACE_DIM_MAX] = [0,%d]", - me, nrrd->dim, NRRD_SPACE_DIM_MAX); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: space dimension %d is outside " + "valid range [0,NRRD_SPACE_DIM_MAX] = [0,%d]", + me, nrrd->dim, NRRD_SPACE_DIM_MAX); + return 1; } if (nrrd->spaceDim) { if (nrrd->space) { if (nrrdSpaceDimension(nrrd->space) != nrrd->spaceDim) { - sprintf(err, "%s: space %s has dimension %d but spaceDim is %d", - me, airEnumStr(nrrdSpace, nrrd->space), - nrrdSpaceDimension(nrrd->space), nrrd->spaceDim); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: space %s has dimension %d but spaceDim is %d", + me, airEnumStr(nrrdSpace, nrrd->space), + nrrdSpaceDimension(nrrd->space), nrrd->spaceDim); + return 1; } } /* check that all coeffs of spaceOrigin have consistent existance */ exists = AIR_EXISTS(nrrd->spaceOrigin[0]); for (ii=0; ii<nrrd->spaceDim; ii++) { if (exists ^ AIR_EXISTS(nrrd->spaceOrigin[ii])) { - sprintf(err, "%s: existance of space origin coefficients must " - "be consistent (val[0] not like val[%d])", me, ii); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: existance of space origin coefficients must " + "be consistent (val[0] not like val[%d])", me, ii); + return 1; } } /* check that all coeffs of measurementFrame have consistent existance */ @@ -564,10 +606,11 @@ _nrrdFieldCheckSpaceInfo(const Nrrd *nrrd, int useBiff) { for (dd=0; dd<nrrd->spaceDim; dd++) { for (ii=0; ii<nrrd->spaceDim; ii++) { if (exists ^ AIR_EXISTS(nrrd->measurementFrame[dd][ii])) { - sprintf(err, "%s: existance of measurement frame coefficients must " - "be consistent: [col][row] [%d][%d] not like [0][0])", - me, dd, ii); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: existance of measurement frame coefficients " + "must be consistent: [col][row] [%d][%d] not " + "like [0][0])", me, dd, ii); + return 1; } } } @@ -576,10 +619,10 @@ _nrrdFieldCheckSpaceInfo(const Nrrd *nrrd, int useBiff) { exists = AIR_EXISTS(nrrd->axis[dd].spaceDirection[0]); for (ii=1; ii<nrrd->spaceDim; ii++) { if (exists ^ AIR_EXISTS(nrrd->axis[dd].spaceDirection[ii])) { - sprintf(err, "%s: existance of space direction %d coefficients " - "must be consistent (val[0] not like val[%d])", me, - dd, ii); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: existance of space direction %d coefficients " + "must be consistent (val[0] not like val[%d])", me, + dd, ii); return 1; } } if (exists) { @@ -587,18 +630,21 @@ _nrrdFieldCheckSpaceInfo(const Nrrd *nrrd, int useBiff) { || AIR_EXISTS(nrrd->axis[dd].max) || AIR_EXISTS(nrrd->axis[dd].spacing) || airStrlen(nrrd->axis[dd].units)) { - sprintf(err, "%s: axis[%d] has a direction vector, and so can't " - "have min, max, spacing, or units set", me, dd); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: axis[%d] has a direction vector, and so can't " + "have min, max, spacing, or units set", me, dd); + return 1; } } } } else { /* else there's not supposed to be anything in "space" */ if (nrrd->space) { - sprintf(err, "%s: space %s can't be set with spaceDim %d", - me, airEnumStr(nrrdSpace, nrrd->space), nrrd->spaceDim); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: space %s can't be set with spaceDim %d", + me, airEnumStr(nrrdSpace, nrrd->space), + nrrd->spaceDim); + return 1; } /* -------- */ exists = AIR_FALSE; @@ -606,8 +652,9 @@ _nrrdFieldCheckSpaceInfo(const Nrrd *nrrd, int useBiff) { exists |= airStrlen(nrrd->spaceUnits[dd]); } if (exists) { - sprintf(err, "%s: spaceDim is 0, but space units is set", me); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: spaceDim is 0, but space units is set", me); + return 1; } /* -------- */ exists = AIR_FALSE; @@ -615,8 +662,9 @@ _nrrdFieldCheckSpaceInfo(const Nrrd *nrrd, int useBiff) { exists |= AIR_EXISTS(nrrd->spaceOrigin[dd]); } if (exists) { - sprintf(err, "%s: spaceDim is 0, but space origin is set", me); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: spaceDim is 0, but space origin is set", me); + return 1; } /* -------- */ exists = AIR_FALSE; @@ -626,8 +674,9 @@ _nrrdFieldCheckSpaceInfo(const Nrrd *nrrd, int useBiff) { } } if (exists) { - sprintf(err, "%s: spaceDim is 0, but space directions are set", me); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: spaceDim is 0, but space directions are set", me); + return 1; } } return 0; @@ -654,105 +703,109 @@ _nrrdFieldCheck_noop(const Nrrd *nrrd, int useBiff) { int _nrrdFieldCheck_type(const Nrrd *nrrd, int useBiff) { - char me[]="_nrrdFieldCheck_type", err[AIR_STRLEN_MED]; + static const char me[]="_nrrdFieldCheck_type"; if (airEnumValCheck(nrrdType, nrrd->type)) { - sprintf(err, "%s: type (%d) is not valid", me, nrrd->type); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: type (%d) is not valid", me, nrrd->type); + return 1; } return 0; } int _nrrdFieldCheck_block_size(const Nrrd *nrrd, int useBiff) { - char me[]="_nrrdFieldCheck_block_size", err[AIR_STRLEN_MED]; + static const char me[]="_nrrdFieldCheck_block_size"; if (nrrdTypeBlock == nrrd->type && (!(0 < nrrd->blockSize)) ) { - sprintf(err, "%s: type is %s but nrrd->blockSize (" - _AIR_SIZE_T_CNV ") invalid", me, - airEnumStr(nrrdType, nrrdTypeBlock), - nrrd->blockSize); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: type is %s but nrrd->blockSize (" + _AIR_SIZE_T_CNV ") invalid", me, + airEnumStr(nrrdType, nrrdTypeBlock), + nrrd->blockSize); return 1; } if (nrrdTypeBlock != nrrd->type && (0 < nrrd->blockSize)) { - sprintf(err, "%s: type is %s (not block) but blockSize is " - _AIR_SIZE_T_CNV, me, - airEnumStr(nrrdType, nrrd->type), nrrd->blockSize); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: type is %s (not block) but blockSize is " + _AIR_SIZE_T_CNV, me, + airEnumStr(nrrdType, nrrd->type), nrrd->blockSize); + return 1; } return 0; } int _nrrdFieldCheck_dimension(const Nrrd *nrrd, int useBiff) { - char me[]="_nrrdFieldCheck_dimension", err[AIR_STRLEN_MED]; + static const char me[]="_nrrdFieldCheck_dimension"; if (!AIR_IN_CL(1, nrrd->dim, NRRD_DIM_MAX)) { - sprintf(err, "%s: dimension %u is outside valid range [1,%d]", - me, nrrd->dim, NRRD_DIM_MAX); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: dimension %u is outside valid range [1,%d]", + me, nrrd->dim, NRRD_DIM_MAX); + return 1; } return 0; } int _nrrdFieldCheck_space(const Nrrd *nrrd, int useBiff) { - char me[]="_nrrdFieldCheck_space", err[AIR_STRLEN_MED]; + static const char me[]="_nrrdFieldCheck_space"; if (_nrrdFieldCheckSpaceInfo(nrrd, useBiff)) { - sprintf(err, "%s: trouble", me); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: trouble", me); + return 1; } return 0; } int _nrrdFieldCheck_space_dimension(const Nrrd *nrrd, int useBiff) { - char me[]="_nrrdFieldCheck_space_dimension", err[AIR_STRLEN_MED]; + static const char me[]="_nrrdFieldCheck_space_dimension"; if (_nrrdFieldCheckSpaceInfo(nrrd, useBiff)) { - sprintf(err, "%s: trouble", me); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: trouble", me); + return 1; } return 0; } int _nrrdFieldCheck_sizes(const Nrrd *nrrd, int useBiff) { - char me[]="_nrrdFieldCheck_sizes", err[AIR_STRLEN_MED]; + static const char me[]="_nrrdFieldCheck_sizes"; size_t size[NRRD_DIM_MAX]; nrrdAxisInfoGet_nva(nrrd, nrrdAxisInfoSize, size); if (_nrrdSizeCheck(size, nrrd->dim, useBiff)) { - sprintf(err, "%s: trouble with array sizes", me); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: trouble with array sizes", me); + return 1; } return 0; } int _nrrdFieldCheck_spacings(const Nrrd *nrrd, int useBiff) { - char me[]="_nrrdFieldCheck_spacings", err[AIR_STRLEN_MED]; + static const char me[]="_nrrdFieldCheck_spacings"; double val[NRRD_DIM_MAX]; unsigned int ai; nrrdAxisInfoGet_nva(nrrd, nrrdAxisInfoSpacing, val); for (ai=0; ai<nrrd->dim; ai++) { if (!( !airIsInf_d(val[ai]) && (airIsNaN(val[ai]) || (0 != val[ai])) )) { - sprintf(err, "%s: axis %d spacing (%g) invalid", me, ai, val[ai]); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: axis %d spacing (%g) invalid", me, ai, val[ai]); + return 1; } } if (_nrrdFieldCheckSpaceInfo(nrrd, useBiff)) { - sprintf(err, "%s: trouble", me); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: trouble", me); + return 1; } return 0; } int _nrrdFieldCheck_thicknesses(const Nrrd *nrrd, int useBiff) { - char me[]="_nrrdFieldCheck_thicknesses", err[AIR_STRLEN_MED]; + static const char me[]="_nrrdFieldCheck_thicknesses"; double val[NRRD_DIM_MAX]; unsigned int ai; @@ -761,8 +814,9 @@ _nrrdFieldCheck_thicknesses(const Nrrd *nrrd, int useBiff) { /* note that unlike spacing, we allow zero thickness, but it makes no sense to be negative */ if (!( !airIsInf_d(val[ai]) && (airIsNaN(val[ai]) || (0 <= val[ai])) )) { - sprintf(err, "%s: axis %d thickness (%g) invalid", me, ai, val[ai]); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: axis %d thickness (%g) invalid", me, ai, val[ai]); + return 1; } } return 0; @@ -770,7 +824,7 @@ _nrrdFieldCheck_thicknesses(const Nrrd *nrrd, int useBiff) { int _nrrdFieldCheck_axis_mins(const Nrrd *nrrd, int useBiff) { - char me[]="_nrrdFieldCheck_axis_mins", err[AIR_STRLEN_MED]; + static const char me[]="_nrrdFieldCheck_axis_mins"; double val[NRRD_DIM_MAX]; unsigned int ai; int ret; @@ -778,14 +832,14 @@ _nrrdFieldCheck_axis_mins(const Nrrd *nrrd, int useBiff) { nrrdAxisInfoGet_nva(nrrd, nrrdAxisInfoMin, val); for (ai=0; ai<nrrd->dim; ai++) { if ((ret=airIsInf_d(val[ai]))) { - sprintf(err, "%s: axis %d min %sinf invalid", - me, ai, 1==ret ? "+" : "-"); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: axis %d min %sinf invalid", + me, ai, 1==ret ? "+" : "-"); + return 1; } } if (_nrrdFieldCheckSpaceInfo(nrrd, useBiff)) { - sprintf(err, "%s: trouble", me); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: trouble", me); + return 1; } /* HEY: contemplate checking min != max, but what about stub axes ... */ return 0; @@ -793,7 +847,7 @@ _nrrdFieldCheck_axis_mins(const Nrrd *nrrd, int useBiff) { int _nrrdFieldCheck_axis_maxs(const Nrrd *nrrd, int useBiff) { - char me[]="_nrrdFieldCheck_axis_maxs", err[AIR_STRLEN_MED]; + static const char me[]="_nrrdFieldCheck_axis_maxs"; double val[NRRD_DIM_MAX]; unsigned int ai; int ret; @@ -801,14 +855,14 @@ _nrrdFieldCheck_axis_maxs(const Nrrd *nrrd, int useBiff) { nrrdAxisInfoGet_nva(nrrd, nrrdAxisInfoMax, val); for (ai=0; ai<nrrd->dim; ai++) { if ((ret=airIsInf_d(val[ai]))) { - sprintf(err, "%s: axis %d max %sinf invalid", - me, ai, 1==ret ? "+" : "-"); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: axis %d max %sinf invalid", + me, ai, 1==ret ? "+" : "-"); + return 1; } } if (_nrrdFieldCheckSpaceInfo(nrrd, useBiff)) { - sprintf(err, "%s: trouble", me); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: trouble", me); + return 1; } /* HEY: contemplate checking min != max, but what about stub axes ... */ return 0; @@ -816,18 +870,18 @@ _nrrdFieldCheck_axis_maxs(const Nrrd *nrrd, int useBiff) { int _nrrdFieldCheck_space_directions(const Nrrd *nrrd, int useBiff) { - char me[]="_nrrdFieldCheck_space_directions", err[AIR_STRLEN_MED]; + static const char me[]="_nrrdFieldCheck_space_directions"; if (_nrrdFieldCheckSpaceInfo(nrrd, useBiff)) { - sprintf(err, "%s: space info problem", me); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: space info problem", me); + return 1; } return 0; } int _nrrdFieldCheck_centers(const Nrrd *nrrd, int useBiff) { - char me[]="_nrrdFieldCheck_centers", err[AIR_STRLEN_MED]; + static const char me[]="_nrrdFieldCheck_centers"; unsigned int ai; int val[NRRD_DIM_MAX]; @@ -835,8 +889,9 @@ _nrrdFieldCheck_centers(const Nrrd *nrrd, int useBiff) { for (ai=0; ai<nrrd->dim; ai++) { if (!( nrrdCenterUnknown == val[ai] || !airEnumValCheck(nrrdCenter, val[ai]) )) { - sprintf(err, "%s: axis %d center %d invalid", me, ai, val[ai]); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: axis %d center %d invalid", + me, ai, val[ai]); + return 1; } } return 0; @@ -844,7 +899,7 @@ _nrrdFieldCheck_centers(const Nrrd *nrrd, int useBiff) { int _nrrdFieldCheck_kinds(const Nrrd *nrrd, int useBiff) { - char me[]="_nrrdFieldCheck_kinds", err[AIR_STRLEN_MED]; + static const char me[]="_nrrdFieldCheck_kinds"; int val[NRRD_DIM_MAX]; unsigned int wantLen, ai; @@ -852,15 +907,17 @@ _nrrdFieldCheck_kinds(const Nrrd *nrrd, int useBiff) { for (ai=0; ai<nrrd->dim; ai++) { if (!( nrrdKindUnknown == val[ai] || !airEnumValCheck(nrrdKind, val[ai]) )) { - sprintf(err, "%s: axis %d kind %d invalid", me, ai, val[ai]); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: axis %d kind %d invalid", me, ai, val[ai]); + return 1; } wantLen = nrrdKindSize(val[ai]); if (wantLen && wantLen != nrrd->axis[ai].size) { - sprintf(err, "%s: axis %d kind %s requires size %d, but have " - _AIR_SIZE_T_CNV, me, - ai, airEnumStr(nrrdKind, val[ai]), wantLen, nrrd->axis[ai].size); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: axis %d kind %s requires size %d, but have " + _AIR_SIZE_T_CNV, me, ai, airEnumStr(nrrdKind, val[ai]), + wantLen, nrrd->axis[ai].size); + return 1; } } return 0; @@ -868,7 +925,7 @@ _nrrdFieldCheck_kinds(const Nrrd *nrrd, int useBiff) { int _nrrdFieldCheck_labels(const Nrrd *nrrd, int useBiff) { - /* char me[]="_nrrdFieldCheck_labels", err[AIR_STRLEN_MED]; */ + /* char me[]="_nrrdFieldCheck_labels"; */ AIR_UNUSED(nrrd); AIR_UNUSED(useBiff); @@ -882,25 +939,26 @@ _nrrdFieldCheck_labels(const Nrrd *nrrd, int useBiff) { int _nrrdFieldCheck_units(const Nrrd *nrrd, int useBiff) { - char me[]="_nrrdFieldCheck_units", err[AIR_STRLEN_MED]; + static const char me[]="_nrrdFieldCheck_units"; /* as with labels- the strings themselves don't need checking themselves */ /* but per-axis units cannot be set for axes with space directions ... */ if (_nrrdFieldCheckSpaceInfo(nrrd, useBiff)) { - sprintf(err, "%s: space info problem", me); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: space info problem", me); + return 1; } return 0; } int _nrrdFieldCheck_old_min(const Nrrd *nrrd, int useBiff) { - char me[]="_nrrdFieldCheck_old_min", err[AIR_STRLEN_MED]; + static const char me[]="_nrrdFieldCheck_old_min"; int ret; if ((ret=airIsInf_d(nrrd->oldMin))) { - sprintf(err, "%s: old min %sinf invalid", me, 1==ret ? "+" : "-"); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: old min %sinf invalid", me, 1==ret ? "+" : "-"); + return 1; } /* oldMin == oldMax is perfectly valid */ return 0; @@ -908,12 +966,13 @@ _nrrdFieldCheck_old_min(const Nrrd *nrrd, int useBiff) { int _nrrdFieldCheck_old_max(const Nrrd *nrrd, int useBiff) { - char me[]="_nrrdFieldCheck_old_max", err[AIR_STRLEN_MED]; + static const char me[]="_nrrdFieldCheck_old_max"; int ret; if ((ret=airIsInf_d(nrrd->oldMax))) { - sprintf(err, "%s: old max %sinf invalid", me, 1==ret ? "+" : "-"); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, + "%s: old max %sinf invalid", me, 1==ret ? "+" : "-"); + return 1; } /* oldMin == oldMax is perfectly valid */ return 0; @@ -921,7 +980,7 @@ _nrrdFieldCheck_old_max(const Nrrd *nrrd, int useBiff) { int _nrrdFieldCheck_keyvalue(const Nrrd *nrrd, int useBiff) { - /* char me[]="_nrrdFieldCheck_keyvalue", err[AIR_STRLEN_MED]; */ + /* char me[]="_nrrdFieldCheck_keyvalue"; */ AIR_UNUSED(nrrd); AIR_UNUSED(useBiff); @@ -934,39 +993,39 @@ _nrrdFieldCheck_keyvalue(const Nrrd *nrrd, int useBiff) { int _nrrdFieldCheck_space_units(const Nrrd *nrrd, int useBiff) { - char me[]="_nrrdFieldCheck_space_units", err[AIR_STRLEN_MED]; + static const char me[]="_nrrdFieldCheck_space_units"; /* not sure if there's anything to specifically check for the space units themselves ... */ if (_nrrdFieldCheckSpaceInfo(nrrd, useBiff)) { - sprintf(err, "%s: space info problem", me); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: space info problem", me); + return 1; } return 0; } int _nrrdFieldCheck_space_origin(const Nrrd *nrrd, int useBiff) { - char me[]="_nrrdFieldCheck_space_origin", err[AIR_STRLEN_MED]; + static const char me[]="_nrrdFieldCheck_space_origin"; /* pre-Fri Feb 11 04:25:36 EST 2005, I thought that the spaceOrigin must be known to describe the space/orientation stuff, but that's too restrictive, which is why below says AIR_FALSE instead of AIR_TRUE */ if (_nrrdFieldCheckSpaceInfo(nrrd, useBiff)) { - sprintf(err, "%s: space info problem", me); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: space info problem", me); + return 1; } return 0; } int _nrrdFieldCheck_measurement_frame(const Nrrd *nrrd, int useBiff) { - char me[]="_nrrdFieldCheck_measurement_frame", err[AIR_STRLEN_MED]; + static const char me[]="_nrrdFieldCheck_measurement_frame"; if (_nrrdFieldCheckSpaceInfo(nrrd, useBiff)) { - sprintf(err, "%s: space info problem", me); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: space info problem", me); + return 1; } return 0; } @@ -1009,26 +1068,27 @@ int }; int -_nrrdCheck (const Nrrd *nrrd, int checkData, int useBiff) { - char me[]="_nrrdCheck", err[AIR_STRLEN_MED]; +_nrrdCheck(const Nrrd *nrrd, int checkData, int useBiff) { + static const char me[]="_nrrdCheck"; int fi; if (!nrrd) { - sprintf(err, "%s: got NULL pointer", me); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: got NULL pointer", me); + return 1; } if (checkData) { if (!(nrrd->data)) { - sprintf(err, "%s: nrrd has NULL data pointer", me); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: nrrd %p has NULL data pointer", + me, nrrd); + return 1; } } for (fi=nrrdField_unknown+1; fi<nrrdField_last; fi++) { /* yes, this will call _nrrdFieldCheckSpaceInfo() many many times */ if (_nrrdFieldCheck[fi](nrrd, AIR_TRUE)) { - sprintf(err, "%s: trouble with %s field", me, - airEnumStr(nrrdField, fi)); - biffMaybeAdd(NRRD, err, useBiff); return 1; + biffMaybeAddf(useBiff, NRRD, "%s: trouble with %s field", me, + airEnumStr(nrrdField, fi)); + return 1; } } return 0; @@ -1045,12 +1105,12 @@ _nrrdCheck (const Nrrd *nrrd, int checkData, int useBiff) { ** required to do the data reading. */ int -nrrdCheck (const Nrrd *nrrd) { - char me[]="nrrdCheck", err[AIR_STRLEN_MED]; +nrrdCheck(const Nrrd *nrrd) { + static const char me[]="nrrdCheck"; if (_nrrdCheck(nrrd, AIR_TRUE, AIR_TRUE)) { - sprintf(err, "%s: trouble", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: trouble", me); + return 1; } return 0; } @@ -1066,26 +1126,24 @@ nrrdCheck (const Nrrd *nrrd) { ** can be generated according to useBiff */ int -nrrdSameSize (const Nrrd *n1, const Nrrd *n2, int useBiff) { - char me[]="nrrdSameSize", err[AIR_STRLEN_MED]; +nrrdSameSize(const Nrrd *n1, const Nrrd *n2, int useBiff) { + static const char me[]="nrrdSameSize"; unsigned int ai; if (!(n1 && n2)) { - sprintf(err, "%s: got NULL pointer", me); - biffMaybeAdd(NRRD, err, useBiff); + biffMaybeAddf(useBiff, NRRD, "%s: got NULL pointer", me); return 0; } if (n1->dim != n2->dim) { - sprintf(err, "%s: n1->dim (%d) != n2->dim (%d)", me, n1->dim, n2->dim); - biffMaybeAdd(NRRD, err, useBiff); + biffMaybeAddf(useBiff, NRRD, "%s: n1->dim (%d) != n2->dim (%d)", + me, n1->dim, n2->dim); return 0; } for (ai=0; ai<n1->dim; ai++) { if (n1->axis[ai].size != n2->axis[ai].size) { - sprintf(err, "%s: n1->axis[%d].size (" _AIR_SIZE_T_CNV - ") != n2->axis[%d].size (" _AIR_SIZE_T_CNV ")", - me, ai, n1->axis[ai].size, ai, n2->axis[ai].size); - biffMaybeAdd(NRRD, err, useBiff); + biffMaybeAddf(useBiff, NRRD, "%s: n1->axis[%d].size (" _AIR_SIZE_T_CNV + ") != n2->axis[%d].size (" _AIR_SIZE_T_CNV ")", + me, ai, n1->axis[ai].size, ai, n2->axis[ai].size); return 0; } } @@ -1156,6 +1214,9 @@ nrrdElementNumber (const Nrrd *nrrd) { return num; } +/* +** obviously, this requires that the per-axis size fields have been set +*/ void _nrrdSplitSizes(size_t *pieceSize, size_t *pieceNum, Nrrd *nrrd, unsigned int split) { @@ -1199,7 +1260,7 @@ _nrrdSplitSizes(size_t *pieceSize, size_t *pieceNum, Nrrd *nrrd, */ /* int -nrrdHasNonExistSet (Nrrd *nrrd) { +nrrdHasNonExistSet(Nrrd *nrrd) { size_t I, N; float val; @@ -1224,9 +1285,9 @@ nrrdHasNonExistSet (Nrrd *nrrd) { */ int -_nrrdCheckEnums (void) { - char me[]="_nrrdCheckEnums", err[AIR_STRLEN_MED], - which[AIR_STRLEN_SMALL]; +_nrrdCheckEnums(void) { + static const char me[]="_nrrdCheckEnums"; + char which[AIR_STRLEN_SMALL]; if (nrrdFormatTypeLast-1 != NRRD_FORMAT_TYPE_MAX) { strcpy(which, "nrrdFormat"); goto err; @@ -1255,21 +1316,23 @@ _nrrdCheckEnums (void) { return 0; err: - sprintf(err, "%s: Last vs. MAX incompatibility for %s enum", me, which); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: Last vs. MAX incompatibility for %s enum", me, which); + return 1; } /* -******** nrrdSanity() +****** nrrdSanity ** ** makes sure that all the basic assumptions of nrrd hold for ** the architecture/etc which we're currently running on. ** ** returns 1 if all is okay, 0 if there is a problem +** +** biffMsg *msg is allowed to be NULL */ int -nrrdSanity (void) { - char me[]="nrrdSanity", err[AIR_STRLEN_MED]; +nrrdSanity(void) { + static const char me[]="nrrdSanity"; int aret, type; size_t maxsize; airLLong tmpLLI; @@ -1287,19 +1350,29 @@ nrrdSanity (void) { aret = airSanity(); if (aret != airInsane_not) { - sprintf(err, "%s: airSanity() failed: %s", me, airInsaneErr(aret)); - biffAdd(NRRD, err); return 0; + if (airInsane_32Bit == aret) { + biffAddf(NRRD, "%s: (sizeof(size_t) == %u, not %u)", me, + AIR_CAST(unsigned int, sizeof(size_t)), + AIR_32BIT ? 4 : 8); + } + biffAddf(NRRD, "%s: airSanity() failed: %s", me, + airInsaneErr(aret)); + return 0; } - if (!nrrdDefWriteEncoding) { - sprintf(err, "%s: nrrdDefWriteEncoding is NULL", me); - biffAdd(NRRD, err); return 0; + if (airEnumValCheck(nrrdEncodingType, nrrdDefaultWriteEncodingType)) { + biffAddf(NRRD, + "%s: nrrdDefaultWriteEncodingType (%d) not in valid " + "range [%d,%d]", me, nrrdDefaultWriteEncodingType, + nrrdEncodingTypeUnknown+1, nrrdEncodingTypeLast-1); + return 0; } - if (airEnumValCheck(nrrdCenter, nrrdDefCenter)) { - sprintf(err, "%s: nrrdDefCenter (%d) not in valid range [%d,%d]", - me, nrrdDefCenter, - nrrdCenterUnknown+1, nrrdCenterLast-1); - biffAdd(NRRD, err); return 0; + if (airEnumValCheck(nrrdCenter, nrrdDefaultCenter)) { + biffAddf(NRRD, + "%s: nrrdDefaultCenter (%d) not in valid range [%d,%d]", + me, nrrdDefaultCenter, + nrrdCenterUnknown+1, nrrdCenterLast-1); + return 0; } if (!( nrrdTypeSize[nrrdTypeChar] == sizeof(char) @@ -1312,101 +1385,106 @@ nrrdSanity (void) { && nrrdTypeSize[nrrdTypeULLong] == sizeof(airULLong) && nrrdTypeSize[nrrdTypeFloat] == sizeof(float) && nrrdTypeSize[nrrdTypeDouble] == sizeof(double) )) { - sprintf(err, "%s: sizeof() for nrrd types has problem: " - "expected (%d,%d,%d,%d,%d,%d,%d,%d,%d,%d) " - "but got (%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)", me, - (int)nrrdTypeSize[nrrdTypeChar], - (int)nrrdTypeSize[nrrdTypeUChar], - (int)nrrdTypeSize[nrrdTypeShort], - (int)nrrdTypeSize[nrrdTypeUShort], - (int)nrrdTypeSize[nrrdTypeInt], - (int)nrrdTypeSize[nrrdTypeUInt], - (int)nrrdTypeSize[nrrdTypeLLong], - (int)nrrdTypeSize[nrrdTypeULLong], - (int)nrrdTypeSize[nrrdTypeFloat], - (int)nrrdTypeSize[nrrdTypeDouble], - (int)sizeof(char), - (int)sizeof(unsigned char), - (int)sizeof(short), - (int)sizeof(unsigned short), - (int)sizeof(int), - (int)sizeof(unsigned int), - (int)sizeof(airLLong), - (int)sizeof(airULLong), - (int)sizeof(float), - (int)sizeof(double)); - biffAdd(NRRD, err); return 0; + biffAddf(NRRD, "%s: sizeof() for nrrd types has problem: " + "expected (%u,%u,%u,%u,%u,%u,%u,%u,%u,%u) " + "but got (%u,%u,%u,%u,%u,%u,%u,%u,%u,%u)", me, + AIR_CAST(unsigned int, nrrdTypeSize[nrrdTypeChar]), + AIR_CAST(unsigned int, nrrdTypeSize[nrrdTypeUChar]), + AIR_CAST(unsigned int, nrrdTypeSize[nrrdTypeShort]), + AIR_CAST(unsigned int, nrrdTypeSize[nrrdTypeUShort]), + AIR_CAST(unsigned int, nrrdTypeSize[nrrdTypeInt]), + AIR_CAST(unsigned int, nrrdTypeSize[nrrdTypeUInt]), + AIR_CAST(unsigned int, nrrdTypeSize[nrrdTypeLLong]), + AIR_CAST(unsigned int, nrrdTypeSize[nrrdTypeULLong]), + AIR_CAST(unsigned int, nrrdTypeSize[nrrdTypeFloat]), + AIR_CAST(unsigned int, nrrdTypeSize[nrrdTypeDouble]), + AIR_CAST(unsigned int, sizeof(char)), + AIR_CAST(unsigned int, sizeof(unsigned char)), + AIR_CAST(unsigned int, sizeof(short)), + AIR_CAST(unsigned int, sizeof(unsigned short)), + AIR_CAST(unsigned int, sizeof(int)), + AIR_CAST(unsigned int, sizeof(unsigned int)), + AIR_CAST(unsigned int, sizeof(airLLong)), + AIR_CAST(unsigned int, sizeof(airULLong)), + AIR_CAST(unsigned int, sizeof(float)), + AIR_CAST(unsigned int, sizeof(double))); + return 0; } - + /* check on NRRD_TYPE_SIZE_MAX */ maxsize = 0; for (type=nrrdTypeUnknown+1; type<=nrrdTypeLast-2; type++) { maxsize = AIR_MAX(maxsize, nrrdTypeSize[type]); } if (maxsize != NRRD_TYPE_SIZE_MAX) { - sprintf(err, "%s: actual max type size is %d != %d == NRRD_TYPE_SIZE_MAX", - me, (int)maxsize, NRRD_TYPE_SIZE_MAX); - biffAdd(NRRD, err); return 0; + biffAddf(NRRD, + "%s: actual max type size is %u != %u == NRRD_TYPE_SIZE_MAX", + me, AIR_CAST(unsigned int, maxsize), NRRD_TYPE_SIZE_MAX); + return 0; } /* check on NRRD_TYPE_BIGGEST */ if (maxsize != sizeof(NRRD_TYPE_BIGGEST)) { - sprintf(err, "%s: actual max type size is %d != " - "%d == sizeof(NRRD_TYPE_BIGGEST)", - me, (int)maxsize, (int)sizeof(NRRD_TYPE_BIGGEST)); - biffAdd(NRRD, err); return 0; + biffAddf(NRRD, "%s: actual max type size is %u != " + "%u == sizeof(NRRD_TYPE_BIGGEST)", + me, AIR_CAST(unsigned int, maxsize), + AIR_CAST(unsigned int, sizeof(NRRD_TYPE_BIGGEST))); + return 0; } /* nrrd-defined type min/max values */ tmpLLI = NRRD_LLONG_MAX; if (tmpLLI != NRRD_LLONG_MAX) { - sprintf(err, "%s: long long int can't hold NRRD_LLONG_MAX (" - AIR_ULLONG_FMT ")", me, - NRRD_LLONG_MAX); - biffAdd(NRRD, err); return 0; + biffAddf(NRRD, "%s: long long int can't hold NRRD_LLONG_MAX (" + AIR_ULLONG_FMT ")", me, + NRRD_LLONG_MAX); + return 0; } tmpLLI += 1; if (NRRD_LLONG_MIN != tmpLLI) { - sprintf(err, "%s: long long int min (" AIR_LLONG_FMT ") or max (" - AIR_LLONG_FMT ") incorrect", me, - NRRD_LLONG_MIN, NRRD_LLONG_MAX); - biffAdd(NRRD, err); return 0; + biffAddf(NRRD, "%s: long long int min (" AIR_LLONG_FMT + ") or max (" AIR_LLONG_FMT ") incorrect", me, + NRRD_LLONG_MIN, NRRD_LLONG_MAX); + return 0; } tmpULLI = NRRD_ULLONG_MAX; if (tmpULLI != NRRD_ULLONG_MAX) { - sprintf(err, - "%s: unsigned long long int can't hold NRRD_ULLONG_MAX (" - AIR_ULLONG_FMT ")", - me, NRRD_ULLONG_MAX); - biffAdd(NRRD, err); return 0; + biffAddf(NRRD, + "%s: unsigned long long int can't hold NRRD_ULLONG_MAX (" + AIR_ULLONG_FMT ")", + me, NRRD_ULLONG_MAX); + return 0; } tmpULLI += 1; if (tmpULLI != 0) { - sprintf(err, "%s: unsigned long long int max (" AIR_ULLONG_FMT - ") incorrect", me, - NRRD_ULLONG_MAX); - biffAdd(NRRD, err); return 0; + biffAddf(NRRD, + "%s: unsigned long long int max (" AIR_ULLONG_FMT + ") incorrect", me, NRRD_ULLONG_MAX); + return 0; } if (_nrrdCheckEnums()) { - sprintf(err, "%s: problem with enum definition", me); - biffAdd(NRRD, err); return 0; + biffAddf(NRRD, "%s: problem with enum definition", me); + return 0; } if (!( NRRD_DIM_MAX >= 3 )) { - sprintf(err, "%s: NRRD_DIM_MAX == %d seems awfully small, doesn't it?", - me, NRRD_DIM_MAX); - biffAdd(NRRD, err); return 0; + biffAddf(NRRD, + "%s: NRRD_DIM_MAX == %u seems awfully small, doesn't it?", + me, NRRD_DIM_MAX); + return 0; } if (!nrrdTypeIsIntegral[nrrdTypeBlock]) { - sprintf(err, "%s: nrrdTypeInteger[nrrdTypeBlock] is not true, things " - "could get wacky", me); - biffAdd(NRRD, err); return 0; + biffAddf(NRRD, + "%s: nrrdTypeInteger[nrrdTypeBlock] is not true, things " + "could get wacky", me); + return 0; } - /* HEY: any other assumptions built into teem? */ + /* HEY: any other assumptions built into Teem? */ _nrrdSanity = 1; return 1; } + diff --git a/Utilities/ITK/Utilities/NrrdIO/string.c b/Utilities/ITK/Utilities/NrrdIO/string.c index 75c76faaa71a0b1321970830eac034ee66449e7a..903de47aff6132cf1079a759baaee189978d048d 100644 --- a/Utilities/ITK/Utilities/NrrdIO/string.c +++ b/Utilities/ITK/Utilities/NrrdIO/string.c @@ -1,6 +1,6 @@ /* NrrdIO: stand-alone code for basic nrrd functionality - Copyright (C) 2005 Gordon Kindlmann + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah This software is provided 'as-is', without any express or implied @@ -143,8 +143,7 @@ airStrntok(const char *_s, const char *ct) { char * airStrtrans(char *s, char from, char to) { - size_t i; // to match the signature of strlen in 64 bits - size_t l; + size_t i, l; if (s) { l = strlen(s); @@ -181,7 +180,7 @@ airEndsWith(const char *s, const char *suff) { */ char * airUnescape(char *s) { - size_t i, j, len; // to match signature of strlen in 64 bits + size_t i, j, len; int found=0; len = airStrlen(s); @@ -217,7 +216,7 @@ airUnescape(char *s) { */ char * airOneLinify(char *s) { - size_t i, j, len; // to match the signature of airStrlen() + size_t i, j, len; len = airStrlen(s); if (!len) @@ -225,11 +224,11 @@ airOneLinify(char *s) { /* convert white space to space (' '), and delete unprintables */ for (i=0; i<len; i++) { - if (isspace((int) s[i])) { + if (isspace(AIR_CAST(int, s[i]))) { s[i] = ' '; continue; } - if (!isprint((int) s[i])) { + if (!isprint(AIR_CAST(int, s[i]))) { for (j=i; j<len; j++) { /* this will copy the '\0' at the end */ s[j] = s[j+1]; @@ -249,9 +248,9 @@ airOneLinify(char *s) { } /* lose trailing white space */ - len = airStrlen(s); - for (i=len-1; ((int)i)>=0 && ' ' == s[i]; i--) { - s[i] = '\0'; + i = airStrlen(s); + if (' ' == s[i-1]) { + s[i-1] = '\0'; } return s; @@ -270,7 +269,7 @@ airToLower(char *str) { if (str) { c = str; while (*c) { - *c = tolower(*c); + *c = tolower((int) *c); c++; } } @@ -290,7 +289,7 @@ airToUpper(char *str) { if (str) { c = str; while (*c) { - *c = toupper(*c); + *c = toupper((int) *c); c++; } } diff --git a/Utilities/ITK/Utilities/NrrdIO/subset.c b/Utilities/ITK/Utilities/NrrdIO/subset.c index 722db03aac06651b1031fb2b6c0bbe7a854535b8..e1c61cf6a5970e10525af64ff6d1ff94ffd5b72c 100644 --- a/Utilities/ITK/Utilities/NrrdIO/subset.c +++ b/Utilities/ITK/Utilities/NrrdIO/subset.c @@ -1,6 +1,6 @@ /* NrrdIO: stand-alone code for basic nrrd functionality - Copyright (C) 2005 Gordon Kindlmann + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah This software is provided 'as-is', without any express or implied @@ -22,10 +22,6 @@ 3. This notice may not be removed or altered from any source distribution. */ -#if defined(__GNUC__) && (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) -#pragma GCC diagnostic ignored "-Warray-bounds" -#endif - #include "NrrdIO.h" #include "privateNrrd.h" @@ -44,7 +40,7 @@ */ int nrrdSlice(Nrrd *nout, const Nrrd *nin, unsigned int saxi, size_t pos) { - char me[]="nrrdSlice", func[]="slice", err[AIR_STRLEN_MED]; + static const char me[]="nrrdSlice", func[]="slice"; size_t I, rowLen, /* length of segment */ @@ -56,34 +52,35 @@ nrrdSlice(Nrrd *nout, const Nrrd *nin, unsigned int saxi, size_t pos) { char *src, *dest; if (!(nin && nout)) { - sprintf(err, "%s: got NULL pointer", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: got NULL pointer", me); + return 1; } if (nout == nin) { - sprintf(err, "%s: nout==nin disallowed", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: nout==nin disallowed", me); + return 1; } if (1 == nin->dim) { - sprintf(err, "%s: can't slice a 1-D nrrd; use nrrd{I,F,D}Lookup[]", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: can't slice a 1-D nrrd; use nrrd{I,F,D}Lookup[]", + me); + return 1; } if (!( saxi < nin->dim )) { - sprintf(err, "%s: slice axis %d out of bounds (0 to %d)", - me, saxi, nin->dim-1); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: slice axis %d out of bounds (0 to %d)", + me, saxi, nin->dim-1); + return 1; } if (!( pos < nin->axis[saxi].size )) { - sprintf(err, "%s: position " _AIR_SIZE_T_CNV - " out of bounds (0 to " _AIR_SIZE_T_CNV ")", - me, pos, nin->axis[saxi].size-1); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: position " _AIR_SIZE_T_CNV + " out of bounds (0 to " _AIR_SIZE_T_CNV ")", + me, pos, nin->axis[saxi].size-1); + return 1; } - /* this shouldn't actually be necessary ... */ + /* this shouldn't actually be necessary .. */ if (!nrrdElementSize(nin)) { - sprintf(err, "%s: nrrd reports zero element size!", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: nrrd reports zero element size!", me); + return 1; } - + /* set up control variables */ rowLen = colLen = 1; for (ai=0; ai<nin->dim; ai++) { @@ -103,10 +100,10 @@ nrrdSlice(Nrrd *nout, const Nrrd *nin, unsigned int saxi, size_t pos) { } nout->blockSize = nin->blockSize; if (nrrdMaybeAlloc_nva(nout, nin->type, outdim, szOut)) { - sprintf(err, "%s: failed to create slice", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: failed to create slice", me); + return 1; } - + /* the skinny */ src = (char *)nin->data; dest = (char *)nout->data; @@ -120,31 +117,37 @@ nrrdSlice(Nrrd *nout, const Nrrd *nin, unsigned int saxi, size_t pos) { /* copy the peripheral information */ if (nrrdAxisInfoCopy(nout, nin, map, NRRD_AXIS_INFO_NONE)) { - sprintf(err, "%s:", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s:", me); + return 1; } - if (nrrdContentSet(nout, func, nin, "%d,%d", saxi, pos)) { - sprintf(err, "%s:", me); - biffAdd(NRRD, err); return 1; + if (nrrdContentSet_va(nout, func, nin, "%d,%d", saxi, pos)) { + biffAddf(NRRD, "%s:", me); + return 1; } if (nrrdBasicInfoCopy(nout, nin, NRRD_BASIC_INFO_DATA_BIT | NRRD_BASIC_INFO_TYPE_BIT | NRRD_BASIC_INFO_BLOCKSIZE_BIT | NRRD_BASIC_INFO_DIMENSION_BIT + | NRRD_BASIC_INFO_SPACEORIGIN_BIT | NRRD_BASIC_INFO_CONTENT_BIT | NRRD_BASIC_INFO_COMMENTS_BIT - | NRRD_BASIC_INFO_KEYVALUEPAIRS_BIT)) { - sprintf(err, "%s:", me); - biffAdd(NRRD, err); return 1; + | (nrrdStateKeyValuePairsPropagate + ? 0 + : NRRD_BASIC_INFO_KEYVALUEPAIRS_BIT))) { + biffAddf(NRRD, "%s:", me); + return 1; } - /* but we can set the origin more accurately */ - if (AIR_EXISTS(nout->spaceOrigin[0])) { - _nrrdSpaceVecScaleAdd2(nout->spaceOrigin, - 1.0, nin->spaceOrigin, - pos, nin->axis[saxi].spaceDirection); + /* translate origin if this was a spatial axis, otherwise copy */ + /* note that if there is no spatial info at all, this is all harmless */ + if (AIR_EXISTS(nin->axis[saxi].spaceDirection[0])) { + nrrdSpaceVecScaleAdd2(nout->spaceOrigin, + 1.0, nin->spaceOrigin, + AIR_CAST(double, pos), + nin->axis[saxi].spaceDirection); + } else { + nrrdSpaceVecCopy(nout->spaceOrigin, nin->spaceOrigin); } - return 0; } @@ -157,8 +160,8 @@ nrrdSlice(Nrrd *nout, const Nrrd *nin, unsigned int saxi, size_t pos) { */ int nrrdCrop(Nrrd *nout, const Nrrd *nin, size_t *min, size_t *max) { - char me[]="nrrdCrop", func[] = "crop", err[AIR_STRLEN_MED], - buff1[NRRD_DIM_MAX*30], buff2[AIR_STRLEN_SMALL]; + static const char me[]="nrrdCrop", func[] = "crop"; + char buff1[NRRD_DIM_MAX*30], buff2[AIR_STRLEN_SMALL]; unsigned int ai; size_t I, lineSize, /* #bytes in one scanline to be copied */ @@ -173,34 +176,34 @@ nrrdCrop(Nrrd *nout, const Nrrd *nin, size_t *min, size_t *max) { /* errors */ if (!(nout && nin && min && max)) { - sprintf(err, "%s: got NULL pointer", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: got NULL pointer", me); + return 1; } if (nout == nin) { - sprintf(err, "%s: nout==nin disallowed", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: nout==nin disallowed", me); + return 1; } for (ai=0; ai<nin->dim; ai++) { if (!(min[ai] <= max[ai])) { - sprintf(err, "%s: axis %d min (" _AIR_SIZE_T_CNV - ") not <= max (" _AIR_SIZE_T_CNV ")", - me, ai, min[ai], max[ai]); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: axis %d min (" _AIR_SIZE_T_CNV + ") not <= max (" _AIR_SIZE_T_CNV ")", + me, ai, min[ai], max[ai]); + return 1; } if (!( min[ai] < nin->axis[ai].size && max[ai] < nin->axis[ai].size )) { - sprintf(err, "%s: axis %d min (" _AIR_SIZE_T_CNV - ") or max (" _AIR_SIZE_T_CNV ") out of bounds [0," - _AIR_SIZE_T_CNV "]", - me, ai, min[ai], max[ai], nin->axis[ai].size-1); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: axis %d min (" _AIR_SIZE_T_CNV + ") or max (" _AIR_SIZE_T_CNV ") out of bounds [0," + _AIR_SIZE_T_CNV "]", + me, ai, min[ai], max[ai], nin->axis[ai].size-1); + return 1; } } - /* this shouldn't actually be necessary ... */ + /* this shouldn't actually be necessary .. */ if (!nrrdElementSize(nin)) { - sprintf(err, "%s: nrrd reports zero element size!", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: nrrd reports zero element size!", me); + return 1; } - + /* allocate */ nrrdAxisInfoGet_nva(nin, nrrdAxisInfoSize, szIn); numLines = 1; @@ -212,8 +215,8 @@ nrrdCrop(Nrrd *nout, const Nrrd *nin, size_t *min, size_t *max) { } nout->blockSize = nin->blockSize; if (nrrdMaybeAlloc_nva(nout, nin->type, nin->dim, szOut)) { - sprintf(err, "%s:", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s:", me); + return 1; } lineSize = szOut[0]*nrrdElementSize(nin); @@ -251,12 +254,13 @@ nrrdCrop(Nrrd *nout, const Nrrd *nin, size_t *min, size_t *max) { if (nrrdAxisInfoCopy(nout, nin, NULL, (NRRD_AXIS_INFO_SIZE_BIT | NRRD_AXIS_INFO_MIN_BIT | NRRD_AXIS_INFO_MAX_BIT ))) { - sprintf(err, "%s:", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s:", me); + return 1; } for (ai=0; ai<nin->dim; ai++) { nrrdAxisInfoPosRange(&(nout->axis[ai].min), &(nout->axis[ai].max), - nin, ai, min[ai], max[ai]); + nin, ai, AIR_CAST(double, min[ai]), + AIR_CAST(double, max[ai])); /* do the safe thing first */ nout->axis[ai].kind = _nrrdKindAltered(nin->axis[ai].kind, AIR_FALSE); /* try cleverness */ @@ -303,27 +307,32 @@ nrrdCrop(Nrrd *nout, const Nrrd *nin, size_t *min, size_t *max) { (ai ? "x" : ""), min[ai], max[ai]); strcat(buff1, buff2); } - if (nrrdContentSet(nout, func, nin, "%s", buff1)) { - sprintf(err, "%s:", me); - biffAdd(NRRD, err); return 1; + if (nrrdContentSet_va(nout, func, nin, "%s", buff1)) { + biffAddf(NRRD, "%s:", me); + return 1; } if (nrrdBasicInfoCopy(nout, nin, NRRD_BASIC_INFO_DATA_BIT | NRRD_BASIC_INFO_TYPE_BIT | NRRD_BASIC_INFO_BLOCKSIZE_BIT | NRRD_BASIC_INFO_DIMENSION_BIT + | NRRD_BASIC_INFO_SPACEORIGIN_BIT | NRRD_BASIC_INFO_CONTENT_BIT | NRRD_BASIC_INFO_COMMENTS_BIT - | NRRD_BASIC_INFO_KEYVALUEPAIRS_BIT)) { - sprintf(err, "%s:", me); - biffAdd(NRRD, err); return 1; + | (nrrdStateKeyValuePairsPropagate + ? 0 + : NRRD_BASIC_INFO_KEYVALUEPAIRS_BIT))) { + biffAddf(NRRD, "%s:", me); + return 1; } - /* but we can set the origin more accurately */ - if (AIR_EXISTS(nout->spaceOrigin[0])) { - for (ai=0; ai<nin->dim; ai++) { - _nrrdSpaceVecScaleAdd2(nout->spaceOrigin, - 1.0, nout->spaceOrigin, - min[ai], nin->axis[ai].spaceDirection); + /* copy origin, then shift it along the spatial axes */ + nrrdSpaceVecCopy(nout->spaceOrigin, nin->spaceOrigin); + for (ai=0; ai<nin->dim; ai++) { + if (AIR_EXISTS(nin->axis[ai].spaceDirection[0])) { + nrrdSpaceVecScaleAdd2(nout->spaceOrigin, + 1.0, nout->spaceOrigin, + AIR_CAST(double, min[ai]), + nin->axis[ai].spaceDirection); } } diff --git a/Utilities/ITK/Utilities/NrrdIO/teem32bit.h b/Utilities/ITK/Utilities/NrrdIO/teem32bit.h index 99c0a24b0d0d415c7d99b13d6c5d1fb115fea808..621bc8a2b9b172fa687fd1fc99ebeed970c10447 100644 --- a/Utilities/ITK/Utilities/NrrdIO/teem32bit.h +++ b/Utilities/ITK/Utilities/NrrdIO/teem32bit.h @@ -1,6 +1,6 @@ /* NrrdIO: stand-alone code for basic nrrd functionality - Copyright (C) 2005 Gordon Kindlmann + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah This software is provided 'as-is', without any express or implied @@ -22,6 +22,7 @@ 3. This notice may not be removed or altered from any source distribution. */ + /* ** the end result of this is that the source file which includes ** this can be sure that TEEM_32BIT is set, and can be sure that diff --git a/Utilities/ITK/Utilities/NrrdIO/teemDio.h b/Utilities/ITK/Utilities/NrrdIO/teemDio.h index a693e1b46c681bc508a57c5606a0e6b3a016bdd2..51d2c789758d5ac917a4e210ca4dde3f10bea06f 100644 --- a/Utilities/ITK/Utilities/NrrdIO/teemDio.h +++ b/Utilities/ITK/Utilities/NrrdIO/teemDio.h @@ -1,6 +1,6 @@ /* NrrdIO: stand-alone code for basic nrrd functionality - Copyright (C) 2005 Gordon Kindlmann + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah This software is provided 'as-is', without any express or implied @@ -22,6 +22,7 @@ 3. This notice may not be removed or altered from any source distribution. */ + /* ** the end result of this is that the source file which includes ** this can be sure that TEEM_DIO is set, and can be sure that diff --git a/Utilities/ITK/Utilities/NrrdIO/teemEndian.h b/Utilities/ITK/Utilities/NrrdIO/teemEndian.h index 22125847323bf65964658ef64c0531f462a0e887..5f3f39e7f57c12bbfca72dcd96998a390bb4f44d 100644 --- a/Utilities/ITK/Utilities/NrrdIO/teemEndian.h +++ b/Utilities/ITK/Utilities/NrrdIO/teemEndian.h @@ -1,6 +1,6 @@ /* NrrdIO: stand-alone code for basic nrrd functionality - Copyright (C) 2005 Gordon Kindlmann + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah This software is provided 'as-is', without any express or implied @@ -22,6 +22,7 @@ 3. This notice may not be removed or altered from any source distribution. */ + /* ** the end result of this is that the source file which includes ** this can be sure that TEEM_ENDIAN is set, and can be sure that diff --git a/Utilities/ITK/Utilities/NrrdIO/teemPng.h b/Utilities/ITK/Utilities/NrrdIO/teemPng.h index 128d527031bb4f930f73391779af50aebe3501ba..97151cef7cfd5131efa71273100822e12cc1302a 100644 --- a/Utilities/ITK/Utilities/NrrdIO/teemPng.h +++ b/Utilities/ITK/Utilities/NrrdIO/teemPng.h @@ -1,6 +1,6 @@ /* NrrdIO: stand-alone code for basic nrrd functionality - Copyright (C) 2005 Gordon Kindlmann + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah This software is provided 'as-is', without any express or implied @@ -22,6 +22,7 @@ 3. This notice may not be removed or altered from any source distribution. */ + /* ** the end result of this is that the source file which includes ** this can be sure that TEEM_ZLIB is set, so that the required @@ -33,3 +34,7 @@ # error TEEM_PNG set, but TEEM_ZLIB not set # endif #endif + +#if TEEM_PNG && TEEM_VTK_MANGLE +#include "vtk_png_mangle.h" +#endif diff --git a/Utilities/ITK/Utilities/NrrdIO/teemQnanhibit.h b/Utilities/ITK/Utilities/NrrdIO/teemQnanhibit.h index ef0b461bff101d283bbedf206b4ee5c931f9d443..f4a08613fec0aa7e5aa057d25df751e26f545397 100644 --- a/Utilities/ITK/Utilities/NrrdIO/teemQnanhibit.h +++ b/Utilities/ITK/Utilities/NrrdIO/teemQnanhibit.h @@ -1,6 +1,6 @@ /* NrrdIO: stand-alone code for basic nrrd functionality - Copyright (C) 2005 Gordon Kindlmann + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah This software is provided 'as-is', without any express or implied @@ -22,6 +22,7 @@ 3. This notice may not be removed or altered from any source distribution. */ + /* ** the end result of this is that the source file which includes ** this can be sure that TEEM_QNANHIBIT is set, and can be sure that diff --git a/Utilities/ITK/Utilities/NrrdIO/unteem.pl b/Utilities/ITK/Utilities/NrrdIO/unteem.pl index 3a9a3899dd7a597d35dfdfc0ef9342758aaca5aa..1a626d376bf4c056a531a964d726954bf6dbd7c6 100644 --- a/Utilities/ITK/Utilities/NrrdIO/unteem.pl +++ b/Utilities/ITK/Utilities/NrrdIO/unteem.pl @@ -50,6 +50,9 @@ while (<>) { s|\/\* NrrdIO-hack-001 \*\/|#define TEEM_BUILD 1|g; s|.* \/\* NrrdIO-hack-002 \*\/|#if 1|g; s|.* \/\* NrrdIO-hack-003 \*\/|int nrrdStateVerboseIO = 0;|g; + s|AIR_EXPORT|NRRDIO_EXPORT|g; + s|BIFF_EXPORT|NRRDIO_EXPORT|g; + s|NRRD_EXPORT|NRRDIO_EXPORT|g; print if $printing; $printing = 1 if (m/END non-NrrdIO/); diff --git a/Utilities/ITK/Utilities/NrrdIO/write.c b/Utilities/ITK/Utilities/NrrdIO/write.c index db2c6933d09507428e6bc349a32dde9efb033aa1..ef5c3cdd8700d4aea13a77008701dc6cf97cce1e 100644 --- a/Utilities/ITK/Utilities/NrrdIO/write.c +++ b/Utilities/ITK/Utilities/NrrdIO/write.c @@ -1,6 +1,6 @@ /* NrrdIO: stand-alone code for basic nrrd functionality - Copyright (C) 2005 Gordon Kindlmann + Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah This software is provided 'as-is', without any express or implied @@ -24,7 +24,6 @@ #include "NrrdIO.h" #include "privateNrrd.h" -#include "teem32bit.h" /* #include <sys/types.h> @@ -32,17 +31,18 @@ */ int -nrrdIoStateSet (NrrdIoState *nio, int parm, int value) { - char me[]="nrrdIoStateSet", err[AIR_STRLEN_MED]; +nrrdIoStateSet(NrrdIoState *nio, int parm, int value) { + static const char me[]="nrrdIoStateSet"; + if (!nio) { - sprintf(err, "%s: got NULL pointer", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: got NULL pointer", me); + return 1; } if (!( AIR_IN_OP(nrrdIoStateUnknown, parm, nrrdIoStateLast) )) { - sprintf(err, "%s: identifier %d not in valid range [%d,%d]", me, - parm, nrrdIoStateUnknown+1, nrrdIoStateLast-1); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: identifier %d not in valid range [%d,%d]", me, + parm, nrrdIoStateUnknown+1, nrrdIoStateLast-1); + return 1; } switch (parm) { case nrrdIoStateDetachedHeader: @@ -53,15 +53,15 @@ nrrdIoStateSet (NrrdIoState *nio, int parm, int value) { break; case nrrdIoStateCharsPerLine: if (value < 40) { - sprintf(err, "%s: %d charsPerLine is awfully small", me, value); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: %d charsPerLine is awfully small", me, value); + return 1; } nio->charsPerLine = value; break; case nrrdIoStateValsPerLine: if (value < 4) { - sprintf(err, "%s: %d valsPerLine is awfully small", me, value); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: %d valsPerLine is awfully small", me, value); + return 1; } nio->valsPerLine = value; break; @@ -73,22 +73,22 @@ nrrdIoStateSet (NrrdIoState *nio, int parm, int value) { break; case nrrdIoStateZlibLevel: if (!( AIR_IN_CL(-1, value, 9) )) { - sprintf(err, "%s: zlibLevel %d invalid", me, value); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: zlibLevel %d invalid", me, value); + return 1; } nio->zlibLevel = value; break; case nrrdIoStateZlibStrategy: if (!( AIR_IN_OP(nrrdZlibStrategyUnknown, value, nrrdZlibStrategyLast) )) { - sprintf(err, "%s: zlibStrategy %d invalid", me, value); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: zlibStrategy %d invalid", me, value); + return 1; } nio->zlibStrategy = value; break; case nrrdIoStateBzip2BlockSize: if (!( AIR_IN_CL(-1, value, 9) )) { - sprintf(err, "%s: bzip2BlockSize %d invalid", me, value); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: bzip2BlockSize %d invalid", me, value); + return 1; } nio->bzip2BlockSize = value; break; @@ -100,41 +100,42 @@ nrrdIoStateSet (NrrdIoState *nio, int parm, int value) { } int -nrrdIoStateEncodingSet (NrrdIoState *nio, const NrrdEncoding *encoding) { - char me[]="nrrdIoStateEncodingSet", err[AIR_STRLEN_MED]; +nrrdIoStateEncodingSet(NrrdIoState *nio, const NrrdEncoding *encoding) { + static const char me[]="nrrdIoStateEncodingSet"; if (!( nio && encoding )) { - sprintf(err, "%s: got NULL pointer", me); if (nio) { nio->encoding = nrrdEncodingUnknown; } - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: got NULL pointer", me); + return 1; } if (!encoding->available()) { - sprintf(err, "%s: %s encoding isn't actually available", me, - encoding->name); nio->encoding = nrrdEncodingUnknown; - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: %s encoding isn't actually available", me, + encoding->name); + return 1; } nio->encoding = encoding; return 0; } int -nrrdIoStateFormatSet (NrrdIoState *nio, const NrrdFormat *format) { - char me[]="nrrdIoStateFormatSet", err[AIR_STRLEN_MED]; +nrrdIoStateFormatSet(NrrdIoState *nio, const NrrdFormat *format) { + static const char me[]="nrrdIoStateFormatSet"; if (!( nio && format )) { - sprintf(err, "%s: got NULL pointer", me); if (nio) { nio->format = nrrdFormatUnknown; } - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: got NULL pointer", me); + return 1; } if (!format->available()) { - sprintf(err, "%s: %s format isn't actually available", me, format->name); nio->format = nrrdFormatUnknown; - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: %s format isn't actually available", me, + format->name); + return 1; } nio->format = format; return 0; @@ -144,8 +145,8 @@ nrrdIoStateFormatSet (NrrdIoState *nio, const NrrdFormat *format) { ** no biff */ int -nrrdIoStateGet (NrrdIoState *nio, int parm) { - char me[]="nrrdIoStateGet"; +nrrdIoStateGet(NrrdIoState *nio, int parm) { + static const char me[]="nrrdIoStateGet"; int value; if (!nio) { @@ -195,7 +196,7 @@ nrrdIoStateGet (NrrdIoState *nio, int parm) { ** no biff */ const NrrdEncoding * -nrrdIoStateEncodingGet (NrrdIoState *nio) { +nrrdIoStateEncodingGet(NrrdIoState *nio) { return nio ? nio->encoding : nrrdEncodingUnknown; } @@ -204,7 +205,7 @@ nrrdIoStateEncodingGet (NrrdIoState *nio) { ** no biff */ const NrrdFormat * -nrrdIoStateFormatGet (NrrdIoState *nio) { +nrrdIoStateFormatGet(NrrdIoState *nio) { return nio ? nio->format : nrrdFormatUnknown; } @@ -219,7 +220,7 @@ _nrrdStrcatSpaceVector(char *str, int spaceDim, strcat(str, "("); for (dd=0; dd<spaceDim; dd++) { strcpy(buff, ""); - airSinglePrintf(NULL, buff, "%lg", val[dd]); + airSinglePrintf(NULL, buff, "%.17g", val[dd]); strcat(str, buff); sprintf(buff, "%s", dd < spaceDim-1 ? "," : ")"); strcat(str, buff); @@ -231,7 +232,7 @@ _nrrdStrcatSpaceVector(char *str, int spaceDim, } int -_nrrdFieldInteresting (const Nrrd *nrrd, NrrdIoState *nio, int field) { +_nrrdFieldInteresting(const Nrrd *nrrd, NrrdIoState *nio, int field) { int ret; unsigned int ai; @@ -354,7 +355,7 @@ _nrrdFieldInteresting (const Nrrd *nrrd, NrrdIoState *nio, int field) { being printed explicity), so they are never "interesting" */ break; case nrrdField_sample_units: - ret = (int)airStrlen(nrrd->sampleUnits); + ret = !!airStrlen(nrrd->sampleUnits); break; case nrrdField_space_units: for (ai=0; ai<nrrd->spaceDim; ai++) { @@ -398,19 +399,20 @@ _nrrdFieldInteresting (const Nrrd *nrrd, NrrdIoState *nio, int field) { ** the per-axis information), but many only make sense in NRRD files. ** This is just one example of NRRD-format-specific stuff that is not ** in formatNRRD.c -** -** HEY: the use of "10", "20", and "30" as stand-ins for "maximum -** number of characters that might be used for printing this integral -** value" is getting pretty tiresome... */ void -_nrrdSprintFieldInfo (char **strP, char *prefix, - const Nrrd *nrrd, NrrdIoState *nio, int field) { - char me[]="_nrrdSprintFieldInfo", buff[AIR_STRLEN_MED], *fnb; +_nrrdSprintFieldInfo(char **strP, char *prefix, + const Nrrd *nrrd, NrrdIoState *nio, int field) { + static const char me[]="_nrrdSprintFieldInfo"; + char buff[AIR_STRLEN_MED], *fnb; double colvec[NRRD_SPACE_DIM_MAX]; const char *fs; - unsigned int ii, dd; - int fslen, fdlen, endi, maxl; + unsigned int ii, dd, + uintStrlen = 11, + size_tStrlen = 33, + doubleStrlen = 513; + size_t fslen, fdlen, maxl; + int endi; if (!( strP && prefix && nrrd @@ -423,7 +425,7 @@ _nrrdSprintFieldInfo (char **strP, char *prefix, } fs = airEnumStr(nrrdField, field); - fslen = (int)(strlen(prefix) + strlen(fs) + strlen(": ") + 1); + fslen = strlen(prefix) + strlen(fs) + strlen(": ") + 1; switch (field) { case nrrdField_comment: case nrrdField_keyvalue: @@ -437,7 +439,7 @@ _nrrdSprintFieldInfo (char **strP, char *prefix, sprintf(*strP, "%s%s: %s", prefix, fs, nrrd->content); break; case nrrdField_number: - *strP = (char *)calloc(fslen + 30, sizeof(char)); + *strP = (char *)calloc(fslen + size_tStrlen, sizeof(char)); sprintf(*strP, "%s%s: " _AIR_SIZE_T_CNV, prefix, fs, nrrdElementNumber(nrrd)); break; @@ -447,11 +449,11 @@ _nrrdSprintFieldInfo (char **strP, char *prefix, sprintf(*strP, "%s%s: %s", prefix, fs, airEnumStr(nrrdType, nrrd->type)); break; case nrrdField_block_size: - *strP = (char *)calloc(fslen + 20, sizeof(char)); + *strP = (char *)calloc(fslen + size_tStrlen, sizeof(char)); sprintf(*strP, "%s%s: " _AIR_SIZE_T_CNV, prefix, fs, nrrd->blockSize); break; case nrrdField_dimension: - *strP = (char *)calloc(fslen + 10, sizeof(char)); + *strP = (char *)calloc(fslen + uintStrlen, sizeof(char)); sprintf(*strP, "%s%s: %d", prefix, fs, nrrd->dim); break; case nrrdField_space: @@ -460,12 +462,12 @@ _nrrdSprintFieldInfo (char **strP, char *prefix, sprintf(*strP, "%s%s: %s", prefix, fs, airEnumStr(nrrdSpace, nrrd->space)); break; case nrrdField_space_dimension: - *strP = (char *)calloc(fslen + 10, sizeof(char)); + *strP = (char *)calloc(fslen + uintStrlen, sizeof(char)); sprintf(*strP, "%s%s: %d", prefix, fs, nrrd->spaceDim); break; /* ---- begin per-axis fields ---- */ case nrrdField_sizes: - *strP = (char *)calloc(fslen + nrrd->dim*10, sizeof(char)); + *strP = (char *)calloc(fslen + nrrd->dim*(size_tStrlen + 1), sizeof(char)); sprintf(*strP, "%s%s:", prefix, fs); for (ii=0; ii<nrrd->dim; ii++) { sprintf(buff, " " _AIR_SIZE_T_CNV, nrrd->axis[ii].size); @@ -473,40 +475,41 @@ _nrrdSprintFieldInfo (char **strP, char *prefix, } break; case nrrdField_spacings: - *strP = (char *)calloc(fslen + nrrd->dim*30, sizeof(char)); + *strP = (char *)calloc(fslen + nrrd->dim*(doubleStrlen + 1), sizeof(char)); sprintf(*strP, "%s%s:", prefix, fs); for (ii=0; ii<nrrd->dim; ii++) { - airSinglePrintf(NULL, buff, " %lg", nrrd->axis[ii].spacing); + airSinglePrintf(NULL, buff, " %.17g", nrrd->axis[ii].spacing); strcat(*strP, buff); } break; case nrrdField_thicknesses: - *strP = (char *)calloc(fslen + nrrd->dim*30, sizeof(char)); + *strP = (char *)calloc(fslen + nrrd->dim*(doubleStrlen + 1), sizeof(char)); sprintf(*strP, "%s%s:", prefix, fs); for (ii=0; ii<nrrd->dim; ii++) { - airSinglePrintf(NULL, buff, " %lg", nrrd->axis[ii].thickness); + airSinglePrintf(NULL, buff, " %.17g", nrrd->axis[ii].thickness); strcat(*strP, buff); } break; case nrrdField_axis_mins: - *strP = (char *)calloc(fslen + nrrd->dim*30, sizeof(char)); + *strP = (char *)calloc(fslen + nrrd->dim*(doubleStrlen + 1), sizeof(char)); sprintf(*strP, "%s%s:", prefix, fs); for (ii=0; ii<nrrd->dim; ii++) { - airSinglePrintf(NULL, buff, " %lg", nrrd->axis[ii].min); + airSinglePrintf(NULL, buff, " %g", nrrd->axis[ii].min); strcat(*strP, buff); } break; case nrrdField_axis_maxs: - *strP = (char *)calloc(fslen + nrrd->dim*30, sizeof(char)); + *strP = (char *)calloc(fslen + nrrd->dim*(doubleStrlen + 1), sizeof(char)); sprintf(*strP, "%s%s:", prefix, fs); for (ii=0; ii<nrrd->dim; ii++) { - airSinglePrintf(NULL, buff, " %lg", nrrd->axis[ii].max); + airSinglePrintf(NULL, buff, " %g", nrrd->axis[ii].max); strcat(*strP, buff); } break; case nrrdField_space_directions: *strP = (char *)calloc(fslen + - nrrd->dim*nrrd->spaceDim*(30 + strlen("(,) ")), + nrrd->dim*nrrd->spaceDim*(doubleStrlen + + strlen("(,) ")), sizeof(char)); sprintf(*strP, "%s%s: ", prefix, fs); for (ii=0; ii<nrrd->dim; ii++) { @@ -520,7 +523,7 @@ _nrrdSprintFieldInfo (char **strP, char *prefix, case nrrdField_centers: fdlen = 0; for (ii=0; ii<nrrd->dim; ii++) { - fdlen += 1 + (int)airStrlen(nrrd->axis[ii].center + fdlen += 1 + airStrlen(nrrd->axis[ii].center ? airEnumStr(nrrdCenter, nrrd->axis[ii].center) : NRRD_UNKNOWN); } @@ -537,7 +540,7 @@ _nrrdSprintFieldInfo (char **strP, char *prefix, case nrrdField_kinds: fdlen = 0; for (ii=0; ii<nrrd->dim; ii++) { - fdlen += 1 + (int)airStrlen(nrrd->axis[ii].kind + fdlen += 1 + airStrlen(nrrd->axis[ii].kind ? airEnumStr(nrrdKind, nrrd->axis[ii].kind) : NRRD_UNKNOWN); } @@ -554,7 +557,7 @@ _nrrdSprintFieldInfo (char **strP, char *prefix, case nrrdField_labels: fdlen = 0; for (ii=0; ii<nrrd->dim; ii++) { - fdlen += (int)airStrlen(nrrd->axis[ii].label) + 4; + fdlen += airStrlen(nrrd->axis[ii].label) + 4; } *strP = (char *)calloc(fslen + fdlen, sizeof(char)); sprintf(*strP, "%s%s:", prefix, fs); @@ -569,7 +572,7 @@ _nrrdSprintFieldInfo (char **strP, char *prefix, case nrrdField_units: fdlen = 0; for (ii=0; ii<nrrd->dim; ii++) { - fdlen += (int)airStrlen(nrrd->axis[ii].units) + 4; + fdlen += airStrlen(nrrd->axis[ii].units) + 4; } *strP = (char *)calloc(fslen + fdlen, sizeof(char)); sprintf(*strP, "%s%s:", prefix, fs); @@ -585,20 +588,20 @@ _nrrdSprintFieldInfo (char **strP, char *prefix, case nrrdField_min: case nrrdField_max: /* we're basically a no-op, now that these fields became meaningless */ - *strP = (char *)calloc(fslen + 30, sizeof(char)); + *strP = (char *)calloc(fslen + doubleStrlen, sizeof(char)); sprintf(*strP, "%s%s: 0.0", prefix, fs); strcat(*strP, buff); break; case nrrdField_old_min: - *strP = (char *)calloc(fslen + 30, sizeof(char)); + *strP = (char *)calloc(fslen + doubleStrlen, sizeof(char)); sprintf(*strP, "%s%s: ", prefix, fs); - airSinglePrintf(NULL, buff, "%lg", nrrd->oldMin); + airSinglePrintf(NULL, buff, "%g", nrrd->oldMin); strcat(*strP, buff); break; case nrrdField_old_max: - *strP = (char *)calloc(fslen + 30, sizeof(char)); + *strP = (char *)calloc(fslen + doubleStrlen, sizeof(char)); sprintf(*strP, "%s%s: ", prefix, fs); - airSinglePrintf(NULL, buff, "%lg", nrrd->oldMax); + airSinglePrintf(NULL, buff, "%g", nrrd->oldMax); strcat(*strP, buff); break; case nrrdField_endian: @@ -622,12 +625,12 @@ _nrrdSprintFieldInfo (char **strP, char *prefix, sprintf(*strP, "%s%s: %s", prefix, fs, nio->encoding->name); break; case nrrdField_line_skip: - *strP = (char *)calloc(fslen + 20, sizeof(char)); + *strP = (char *)calloc(fslen + uintStrlen, sizeof(char)); sprintf(*strP, "%s%s: %d", prefix, fs, nio->lineSkip); break; case nrrdField_byte_skip: - *strP = (char *)calloc(fslen + 20, sizeof(char)); - sprintf(*strP, "%s%s: %d", prefix, fs, nio->byteSkip); + *strP = (char *)calloc(fslen + uintStrlen, sizeof(char)); + sprintf(*strP, "%s%s: %ld", prefix, fs, nio->byteSkip); break; case nrrdField_sample_units: airOneLinify(nrrd->sampleUnits); @@ -637,7 +640,7 @@ _nrrdSprintFieldInfo (char **strP, char *prefix, case nrrdField_space_units: fdlen = 0; for (ii=0; ii<nrrd->spaceDim; ii++) { - fdlen += (int)airStrlen(nrrd->spaceUnits[ii]) + 4; + fdlen += airStrlen(nrrd->spaceUnits[ii]) + 4; } *strP = (char *)calloc(fslen + fdlen, sizeof(char)); sprintf(*strP, "%s%s:", prefix, fs); @@ -650,14 +653,16 @@ _nrrdSprintFieldInfo (char **strP, char *prefix, } break; case nrrdField_space_origin: - *strP = (char *)calloc(fslen + nrrd->spaceDim*(30 + strlen("(,) ")), + *strP = (char *)calloc(fslen + nrrd->spaceDim*(doubleStrlen + + strlen("(,) ")), sizeof(char)); sprintf(*strP, "%s%s: ", prefix, fs); _nrrdStrcatSpaceVector(*strP, nrrd->spaceDim, nrrd->spaceOrigin); break; case nrrdField_measurement_frame: *strP = (char *)calloc(fslen + (nrrd->spaceDim* - nrrd->spaceDim*(30 + strlen("(,) "))), + nrrd->spaceDim*(doubleStrlen + + strlen("(,) "))), sizeof(char)); sprintf(*strP, "%s%s: ", prefix, fs); for (dd=0; dd<nrrd->spaceDim; dd++) { @@ -677,8 +682,7 @@ _nrrdSprintFieldInfo (char **strP, char *prefix, the filenames */ /* error checking elsewhere: assumes there is data file info */ if (nio->dataFNFormat) { - *strP = (char *)calloc(fslen + strlen(nio->dataFNFormat) - + 10 + 10 + 10 + 10, + *strP = (char *)calloc(fslen + strlen(nio->dataFNFormat) + 4*uintStrlen, sizeof(char)); if (nio->dataFileDim == nrrd->dim-1) { sprintf(*strP, "%s%s: %s %d %d %d", prefix, fs, nio->dataFNFormat, @@ -691,12 +695,13 @@ _nrrdSprintFieldInfo (char **strP, char *prefix, } else if (nio->dataFNArr->len > 1) { maxl = 0; for (ii=0; ii<nio->dataFNArr->len; ii++) { - maxl = AIR_MAX(maxl, (int)strlen(nio->dataFN[ii])); + maxl = AIR_MAX(maxl, strlen(nio->dataFN[ii])); } - *strP = (char *)calloc(fslen + strlen(NRRD_LIST_FLAG) + 10 - + nio->dataFNArr->len * (maxl + 1), + *strP = (char *)calloc(fslen + strlen(NRRD_LIST_FLAG) + + uintStrlen + nio->dataFNArr->len * (maxl + 1), sizeof(char)); - fnb = (char *)calloc(fslen + strlen(NRRD_LIST_FLAG) + 10 + maxl + 1, + fnb = (char *)calloc(fslen + strlen(NRRD_LIST_FLAG) + + uintStrlen + maxl + 1, sizeof(char)); if (nio->dataFileDim == nrrd->dim-1) { sprintf(*strP, "%s%s: LIST\n", prefix, fs); @@ -739,8 +744,8 @@ _nrrdSprintFieldInfo (char **strP, char *prefix, ** a file. Same caveats here: use _nrrdFieldInteresting */ void -_nrrdFprintFieldInfo (FILE *file, char *prefix, - const Nrrd *nrrd, NrrdIoState *nio, int field) { +_nrrdFprintFieldInfo(FILE *file, char *prefix, + const Nrrd *nrrd, NrrdIoState *nio, int field) { char *line=NULL; _nrrdSprintFieldInfo(&line, prefix, nrrd, nio, field); @@ -753,19 +758,23 @@ _nrrdFprintFieldInfo (FILE *file, char *prefix, int _nrrdEncodingMaybeSet(NrrdIoState *nio) { - char me[]="_nrrdEncodingMaybeSet", err[AIR_STRLEN_MED]; + static const char me[]="_nrrdEncodingMaybeSet"; + if (!nio) { + biffAddf(NRRD, "%s: got NULL pointer", me); + return 1; + } if (!nio->encoding) { - sprintf(err, "%s: invalid (NULL) encoding", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: invalid (NULL) encoding", me); + return 1; } if (nrrdEncodingUnknown == nio->encoding) { - nio->encoding = nrrdDefWriteEncoding; + nio->encoding = nrrdEncodingArray[nrrdDefaultWriteEncodingType]; } if (!nio->encoding->available()) { - sprintf(err, "%s: %s encoding not available in this teem build", - me, nio->encoding->name); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: %s encoding not available in this Teem build", + me, nio->encoding->name); + return 1; } return 0; } @@ -777,14 +786,15 @@ _nrrdEncodingMaybeSet(NrrdIoState *nio) { ** we must set nio->format to something useful/non-trivial */ int -_nrrdFormatMaybeGuess (const Nrrd *nrrd, NrrdIoState *nio, - const char *filename) { - char me[]="_nrrdFormatMaybeGuess", err[AIR_STRLEN_MED], mesg[AIR_STRLEN_MED]; +_nrrdFormatMaybeGuess(const Nrrd *nrrd, NrrdIoState *nio, + const char *filename) { + static const char me[]="_nrrdFormatMaybeGuess"; + char mesg[AIR_STRLEN_MED]; int fi, guessed, available, fits; if (!nio->format) { - sprintf(err, "%s: got invalid (NULL) format", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: got invalid (NULL) format", me); + return 1; } if (nrrdFormatUnknown == nio->format) { for (fi = nrrdFormatTypeUnknown+1; @@ -809,7 +819,7 @@ _nrrdFormatMaybeGuess (const Nrrd *nrrd, NrrdIoState *nio, if (!( available && fits )) { sprintf(mesg, "can not use %s format: %s", nio->format->name, (!available - ? "not available in this teem build" + ? "not available in this Teem build" : "array doesn\'t fit")); if (guessed) { if (1 <= nrrdStateVerboseIO) { @@ -818,8 +828,8 @@ _nrrdFormatMaybeGuess (const Nrrd *nrrd, NrrdIoState *nio, nio->format = nrrdFormatNRRD; } else { /* problem: this was the format someone explicitly requested */ - sprintf(err, "%s: %s", me, mesg); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: %s", me, mesg); + return 1; } } @@ -828,71 +838,139 @@ _nrrdFormatMaybeGuess (const Nrrd *nrrd, NrrdIoState *nio, int _nrrdFormatMaybeSet(NrrdIoState *nio) { - char me[]="_nrrdFormatMaybeSet", err[AIR_STRLEN_MED]; + static const char me[]="_nrrdFormatMaybeSet"; if (!nio->format) { - sprintf(err, "%s: invalid (NULL) format", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: invalid (NULL) format", me); + return 1; } if (nrrdFormatUnknown == nio->format) { nio->format = nrrdFormatNRRD; } if (!nio->format->available()) { - sprintf(err, "%s: %s format not available in this teem build", - me, nio->format->name); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: %s format not available in this Teem build", + me, nio->format->name); + return 1; } return 0; } /* -******** nrrdWrite +** _nrrdWrite ** -** Write a nrrd to given file, using the format and and encoding indicated -** in nio. There is no cleverness from this point on: all writing parameters -** must be given explicitly, and their appropriateness is explicitly tested +** Write a nrrd to given file or string (allocated by nrrd), using the +** format and and encoding indicated in nio. Cleverness should be +** isolated and collected here: by the time nio->format->write() is +** called, all writing parameters must be given explicitly, and their +** appropriateness is explicitly tested */ int -nrrdWrite (FILE *file, const Nrrd *nrrd, NrrdIoState *nio) { - char me[]="nrrdWrite", err[AIR_STRLEN_MED]; +_nrrdWrite(FILE *file, char **stringP, const Nrrd *nrrd, NrrdIoState *_nio) { + static const char me[]="_nrrdWrite"; + NrrdIoState *nio; airArray *mop; - if (!(file && nrrd)) { - sprintf(err, "%s: got NULL pointer", me); - biffAdd(NRRD, err); return 1; + if (!((file || stringP) && nrrd)) { + biffAddf(NRRD, "%s: got NULL pointer", me); + return 1; + } + if (file && stringP) { + biffAddf(NRRD, "%s: can't write to both file and string", me); + return 1; } if (nrrdCheck(nrrd)) { - sprintf(err, "%s:", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s:", me); + return 1; } mop = airMopNew(); - if (!nio) { + if (_nio) { + nio = _nio; + } else { nio = nrrdIoStateNew(); if (!nio) { - sprintf(err, "%s: couldn't alloc local NrrdIoState", me); - biffAdd(NRRD, err); airMopError(mop); return 1; + biffAddf(NRRD, "%s: couldn't alloc local NrrdIoState", me); + airMopError(mop); return 1; } airMopAdd(mop, nio, (airMopper)nrrdIoStateNix, airMopAlways); } if (_nrrdEncodingMaybeSet(nio) || _nrrdFormatMaybeSet(nio)) { - sprintf(err, "%s: ", me); - biffAdd(NRRD, err); airMopError(mop); return 1; + biffAddf(NRRD, "%s: ", me); + airMopError(mop); return 1; } if (nio->byteSkip || nio->lineSkip) { /* NOTE: unu make bypasses this by calling nrrdFormatNRRD->write() directly */ - sprintf(err, "%s: can't generate line or byte skips on data write", me); - biffAdd(NRRD, err); airMopError(mop); return 1; + biffAddf(NRRD, "%s: can't generate line or byte skips on data write", me); + airMopError(mop); return 1; } - - /* call the writer appropriate for the format */ - if (nio->format->write(file, nrrd, nio)) { - sprintf(err, "%s:", me); - biffAdd(NRRD, err); airMopError(mop); return 1; + + if (stringP) { + if (nrrdFormatNRRD != nio->format) { + biffAddf(NRRD, "%s: sorry, can only write %s files to strings (not %s)", + me, nrrdFormatNRRD->name, nio->format->name); + airMopError(mop); return 1; + } + /* we do this in two passes; first see how much room is needed + for the header, then allocate, then write the header */ + nio->learningHeaderStrlen = AIR_TRUE; + if (nio->format->write(NULL, nrrd, nio)) { + biffAddf(NRRD, "%s:", me); + airMopError(mop); return 1; + } + *stringP = (char*)malloc(nio->headerStrlen + 1); + if (!*stringP) { + biffAddf(NRRD, "%s: couldn't allocate header string (%u len )", + me, nio->headerStrlen); + airMopError(mop); return 1; + } + nio->learningHeaderStrlen = AIR_FALSE; + nio->headerStringWrite = *stringP; + if (nio->format->write(NULL, nrrd, nio)) { + biffAddf(NRRD, "%s:", me); + airMopError(mop); return 1; + } + } else { + /* call the writer appropriate for the format */ + if (nio->format->write(file, nrrd, nio)) { + biffAddf(NRRD, "%s:", me); + airMopError(mop); return 1; + } } - airMopOkay(mop); + airMopOkay(mop); + return 0; +} + +/* +******** nrrdWrite +** +** wrapper around _nrrdWrite; writes to a FILE* +*/ +int +nrrdWrite(FILE *file, const Nrrd *nrrd, NrrdIoState *_nio) { + static const char me[]="nrrdWrite"; + + if (_nrrdWrite(file, NULL, nrrd, _nio)) { + biffAddf(NRRD, "%s: trouble", me); + return 1; + } + return 0; +} + +/* +******** nrrdStringWrite +** +** wrapper around _nrrdWrite; *allocates* and writes to a string +*/ +int +nrrdStringWrite(char **stringP, const Nrrd *nrrd, NrrdIoState *_nio) { + static const char me[]="nrrdStringWrite"; + + if (_nrrdWrite(NULL, stringP, nrrd, _nio)) { + biffAddf(NRRD, "%s: trouble", me); + return 1; + } return 0; } @@ -907,30 +985,30 @@ nrrdWrite (FILE *file, const Nrrd *nrrd, NrrdIoState *nio) { ** game, the data file is ALWAYS header relative. */ int -nrrdSave (const char *filename, const Nrrd *nrrd, NrrdIoState *nio) { - char me[]="nrrdSave", err[AIR_STRLEN_MED]; +nrrdSave(const char *filename, const Nrrd *nrrd, NrrdIoState *nio) { + static const char me[]="nrrdSave"; FILE *file; airArray *mop; if (!(nrrd && filename)) { - sprintf(err, "%s: got NULL pointer", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: got NULL pointer", me); + return 1; } mop = airMopNew(); if (!nio) { nio = nrrdIoStateNew(); if (!nio) { - sprintf(err, "%s: couldn't alloc local NrrdIoState", me); - biffAdd(NRRD, err); return 1; + biffAddf(NRRD, "%s: couldn't alloc local NrrdIoState", me); + return 1; } airMopAdd(mop, nio, (airMopper)nrrdIoStateNix, airMopAlways); } if (_nrrdEncodingMaybeSet(nio) || _nrrdFormatMaybeGuess(nrrd, nio, filename)) { - sprintf(err, "%s: ", me); - biffAdd(NRRD, err); airMopError(mop); return 1; + biffAddf(NRRD, "%s: ", me); + airMopError(mop); return 1; } - + if (nrrdFormatNRRD == nio->format && airEndsWith(filename, NRRD_EXT_NHDR)) { nio->detachedHeader = AIR_TRUE; @@ -943,15 +1021,61 @@ nrrdSave (const char *filename, const Nrrd *nrrd, NrrdIoState *nio) { } if (!( file = airFopen(filename, stdout, "wb") )) { - sprintf(err, "%s: couldn't fopen(\"%s\",\"wb\"): %s", - me, filename, strerror(errno)); - biffAdd(NRRD, err); airMopError(mop); return 1; + biffAddf(NRRD, "%s: couldn't fopen(\"%s\",\"wb\"): %s", + me, filename, strerror(errno)); + airMopError(mop); return 1; } airMopAdd(mop, file, (airMopper)airFclose, airMopAlways); if (nrrdWrite(file, nrrd, nio)) { - sprintf(err, "%s:", me); - biffAdd(NRRD, err); airMopError(mop); return 1; + biffAddf(NRRD, "%s:", me); + airMopError(mop); return 1; + } + + airMopOkay(mop); + return 0; +} + +int +nrrdSaveMulti(const char *fnameFormat, const Nrrd *const *nin, + unsigned int ninLen, unsigned int numStart, NrrdIoState *nio) { + static const char me[]="nrrdSaveMulti"; + char *fname; + airArray *mop; + unsigned int nii; + + if (!( fnameFormat && nin )) { + biffAddf(NRRD, "%s: got NULL pointer", me); + return 1; + } + if (!( _nrrdContainsPercentThisAndMore(fnameFormat, 'u') )) { + biffAddf(NRRD, "%s: given format \"%s\" doesn't seem to " + "have the \"%%u\" conversion specification to sprintf " + "an unsigned int\n", me, fnameFormat); + return 1; + } + + mop = airMopNew(); + /* should be big enough for the number replacing the format sequence */ + fname = AIR_CAST(char *, malloc(strlen(fnameFormat) + 128)); + if (!(fname)) { + biffAddf(NRRD, "%s: couldn't allocate local fname buffer", me); + airMopError(mop); return 1; + } + airMopAdd(mop, fname, airFree, airMopAlways); + + for (nii=0; nii<ninLen; nii++) { + unsigned int num; + num = numStart + nii; + sprintf(fname, fnameFormat, num); + if (nrrdSave(fname, nin[nii], nio)) { + biffAddf(NRRD, "%s: trouble saving nin[%u] to %s", me, nii, fname); + airMopError(mop); return 1; + } + /* HEY: GLK hopes that the nio doesn't have any state that needs + resetting, but we can't call nrrdIoStateInit() because that + would negate the purpose of sending in the nio for all but the + first saved nrrd */ } airMopOkay(mop); diff --git a/Utilities/ITK/Utilities/README.itklibxml2 b/Utilities/ITK/Utilities/README.itklibxml2 old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Utilities/expat/CMakeLists.txt b/Utilities/ITK/Utilities/expat/CMakeLists.txt index 6f8c0e44356dc43b8896456e3ac3348829c98457..63af56b84a1fc6d2d4499e2550a8e5230df854df 100644 --- a/Utilities/ITK/Utilities/expat/CMakeLists.txt +++ b/Utilities/ITK/Utilities/expat/CMakeLists.txt @@ -37,10 +37,17 @@ IF(NOT ITK_INSTALL_NO_LIBRARIES) ARCHIVE DESTINATION ${ITK_INSTALL_LIB_DIR_CM24} COMPONENT Development) ENDIF(NOT ITK_INSTALL_NO_LIBRARIES) +IF(ITK_USE_FLAT_DIRECTORY_INSTALL) + SET( ITK_INSTALL_INCLUDE_DIR_CM24_UTILITIES_EXPAT ${ITK_INSTALL_INCLUDE_DIR_CM24}) +ELSE(ITK_USE_FLAT_DIRECTORY_INSTALL) + SET( ITK_INSTALL_INCLUDE_DIR_CM24_UTILITIES_EXPAT ${ITK_INSTALL_INCLUDE_DIR_CM24}/Utilities/expat) +ENDIF(ITK_USE_FLAT_DIRECTORY_INSTALL) + + IF(NOT ITK_INSTALL_NO_DEVELOPMENT) INSTALL(FILES ${ITKEXPAT_BINARY_DIR}/expatDllConfig.h ${ITKEXPAT_SOURCE_DIR}/expat.h - DESTINATION ${ITK_INSTALL_INCLUDE_DIR_CM24}/Utilities/expat + DESTINATION ${ITK_INSTALL_INCLUDE_DIR_CM24_UTILITIES_EXPAT} COMPONENT Development) ENDIF(NOT ITK_INSTALL_NO_DEVELOPMENT) diff --git a/Utilities/ITK/Utilities/gdcm/gdcmConfigure.h.in b/Utilities/ITK/Utilities/gdcm/gdcmConfigure.h.in index 5adc9c380c55f80490eebe56945f8ddc31fe429f..d51f7c4b35ebd24de5543858c2f320a5f7cbba29 100644 --- a/Utilities/ITK/Utilities/gdcm/gdcmConfigure.h.in +++ b/Utilities/ITK/Utilities/gdcm/gdcmConfigure.h.in @@ -1,19 +1,19 @@ /*========================================================================= - + Program: gdcm Module: $RCSfile: gdcmConfigure.h.in,v $ Language: C++ Date: $Date: 2008-05-19 06:58:31 $ Version: $Revision: 1.14 $ - + Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details. - + This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. - + =========================================================================*/ #ifndef __gdcmConfigure_h diff --git a/Utilities/ITK/Utilities/gdcm/src/CMakeLists.txt b/Utilities/ITK/Utilities/gdcm/src/CMakeLists.txt index 8ee0af4991a05ebdf16478600244e5b1e14e052a..6865141e43977721b4cf0f6ce4b12a7bff29d976 100644 --- a/Utilities/ITK/Utilities/gdcm/src/CMakeLists.txt +++ b/Utilities/ITK/Utilities/gdcm/src/CMakeLists.txt @@ -83,9 +83,15 @@ IF(CMAKE_SYSTEM MATCHES "SunOS.*") TARGET_LINK_LIBRARIES(itkgdcm socket nsl) ENDIF(CMAKE_SYSTEM MATCHES "SunOS.*") +IF(ITK_USE_FLAT_DIRECTORY_INSTALL) + SET( ITK_INSTALL_INCLUDE_DIR_CM24_GDCM_SRC ${ITK_INSTALL_INCLUDE_DIR_CM24}) +ELSE(ITK_USE_FLAT_DIRECTORY_INSTALL) + SET( ITK_INSTALL_INCLUDE_DIR_CM24_GDCM_SRC ${ITK_INSTALL_INCLUDE_DIR_CM24}/gdcm/src) +ENDIF(ITK_USE_FLAT_DIRECTORY_INSTALL) + FILE(GLOB __files "${CMAKE_CURRENT_SOURCE_DIR}/*.h") INSTALL(FILES ${__files} - DESTINATION ${ITK_INSTALL_INCLUDE_DIR_CM24}/gdcm/src + DESTINATION ${ITK_INSTALL_INCLUDE_DIR_CM24_GDCM_SRC} COMPONENT Development) IF(ITK_LIBRARY_PROPERTIES) SET_TARGET_PROPERTIES(itkgdcm PROPERTIES ${ITK_LIBRARY_PROPERTIES}) diff --git a/Utilities/ITK/Utilities/gdcm/src/gdcmDicomDir.cxx b/Utilities/ITK/Utilities/gdcm/src/gdcmDicomDir.cxx index cdf4d8afdad97daf2ebf8649822dd1e02f1a252b..2ceb8b2b4eac5166112c5f9b35013334b20acbf8 100644 --- a/Utilities/ITK/Utilities/gdcm/src/gdcmDicomDir.cxx +++ b/Utilities/ITK/Utilities/gdcm/src/gdcmDicomDir.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDir.cxx,v $ Language: C++ - Date: $Date: 2008-05-26 00:47:50 $ - Version: $Revision: 1.13 $ + Date: $Date: 2009-11-21 20:00:35 $ + Version: $Revision: 1.14 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -739,7 +739,7 @@ void DicomDir::Initialize() ProgressArg = NULL; EndArg = NULL; - Progress = 0.0; + Progress = 0.0f; Abort = false; MetaElems = NULL; diff --git a/Utilities/ITK/Utilities/gdcm/src/gdcmDocument.cxx b/Utilities/ITK/Utilities/gdcm/src/gdcmDocument.cxx index 2f1c9d2cbc5556b55638d42f1d7cbac1ac7e4aaa..39ca39354412eb94b320f56b5ffc1676f801cdaf 100644 --- a/Utilities/ITK/Utilities/gdcm/src/gdcmDocument.cxx +++ b/Utilities/ITK/Utilities/gdcm/src/gdcmDocument.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocument.cxx,v $ Language: C++ - Date: $Date: 2009-04-05 10:56:58 $ - Version: $Revision: 1.32 $ + Date: $Date: 2009-11-21 20:00:35 $ + Version: $Revision: 1.33 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -162,7 +162,7 @@ bool Document::DoTheLoadingDocumentJob( ) // Computes the total length of the file Fp->seekg(0, std::ios::end); // Once per Document ! - long lgt = Fp->tellg(); // Once per Document ! + std::streampos lgt = Fp->tellg(); // Once per Document ! Fp->seekg(0, std::ios::beg); // Once per Document ! // CheckSwap returns a boolean @@ -175,13 +175,13 @@ bool Document::DoTheLoadingDocumentJob( ) return false; } - long beg = Fp->tellg(); // just after DICOM preamble (if any) + std::streampos beg = Fp->tellg(); // just after DICOM preamble (if any) lgt -= beg; // remaining length to parse // Recursive call. // Loading is done during parsing - ParseDES( this, beg, lgt, false); // delim_mode is first defaulted to false + ParseDES( this, (long)beg, (long)lgt, false); // delim_mode is first defaulted to false if ( IsEmpty() ) { @@ -798,7 +798,7 @@ void Document::LoadDocEntrySafe(DocEntry *entry) { if ( Fp ) { - long PositionOnEntry = Fp->tellg(); + std::streampos PositionOnEntry = Fp->tellg(); LoadDocEntry(entry); Fp->seekg(PositionOnEntry, std::ios::beg); } @@ -1144,7 +1144,7 @@ void Document::ParseDES(DocEntrySet *set, long offset, if( sscanf( strLgrGroup.c_str(), "%ud", &lgrGroup) == 1 ) { gdcmDebugMacro( "Skipping: " << lgrGroup << " bytes" ); - long startpos = Fp->tellg(); + std::streampos startpos = Fp->tellg(); Fp->seekg(lgrGroup, std::ios::cur); // Let's detect some easy case: when value is larger than file size: Fp->peek(); @@ -1295,7 +1295,7 @@ void Document::ParseSQ( SeqEntry *seqEntry, { int SQItemNumber = 0; bool dlm_mod; - long offsetStartCurrentSQItem = offset; + std::streampos offsetStartCurrentSQItem = offset; while (true) { @@ -1337,7 +1337,7 @@ void Document::ParseSQ( SeqEntry *seqEntry, delete newDocEntry; // fill up the current SQItem, starting at the beginning of fff0,e000 - ParseDES(itemSQ, offsetStartCurrentSQItem, l+8, dlm_mod); + ParseDES(itemSQ, (long)offsetStartCurrentSQItem, l+8, dlm_mod); offsetStartCurrentSQItem = Fp->tellg(); @@ -1640,14 +1640,14 @@ void Document::FindDocEntryLength( DocEntry *entry, std::string vr ) gdcmWarningMacro( " Computing the length failed for " << entry->GetKey() <<" in " <<GetFileName()); - long currentPosition = Fp->tellg(); // Only for gdcm-JPEG-LossLess3a.dcm-like + std::streampos currentPosition = Fp->tellg(); // Only for gdcm-JPEG-LossLess3a.dcm-like Fp->seekg(0L,std::ios::end); // Only for gdcm-JPEG-LossLess3a.dcm-like - long lengthUntilEOF = (long)(Fp->tellg())-currentPosition; // Only for gdcm-JPEG-LossLess3a.dcm-like + std::streamoff lengthUntilEOF = Fp->tellg()-currentPosition; // Only for gdcm-JPEG-LossLess3a.dcm-like Fp->seekg(currentPosition, std::ios::beg); // Only for gdcm-JPEG-LossLess3a.dcm-like - entry->SetReadLength(lengthUntilEOF); - entry->SetLength(lengthUntilEOF); + entry->SetReadLength( (uint32_t)lengthUntilEOF ); + entry->SetLength( (uint32_t)lengthUntilEOF ); return; } entry->SetReadLength(lengthOB); @@ -1697,7 +1697,7 @@ uint32_t Document::FindDocEntryLengthOBOrOW() throw( FormatUnexpected ) { // See PS 3.5-2001, section A.4 p. 49 on encapsulation of encoded pixel data. - long positionOnEntry = Fp->tellg(); // Only for OB,OW DataElements + std::streampos positionOnEntry = Fp->tellg(); // Only for OB,OW DataElements bool foundSequenceDelimiter = false; uint32_t totalLength = 0; @@ -1756,7 +1756,7 @@ std::string Document::FindDocEntryVR() if ( Filetype != ExplicitVR ) return GDCM_UNKNOWN; - long positionOnEntry = Fp->tellg(); + std::streampos positionOnEntry = Fp->tellg(); // Warning: we believe this is explicit VR (Value Representation) because // we used a heuristic that found "UL" in the first tag. Alas this // doesn't guarantee that all the tags will be in explicit VR. In some @@ -2066,7 +2066,7 @@ bool Document::IsDocEntryAnInteger(DocEntry *entry) // test is useless (and might even look a bit paranoid), when we // encounter such an ill-formed image, we simply display a warning // message and proceed on parsing (while crossing fingers). - long filePosition = Fp->tellg(); // Only when elem 0x0000 length is not 4 (?!?) + std::streampos filePosition = Fp->tellg(); // Only when elem 0x0000 length is not 4 (?!?) (void)filePosition; gdcmWarningMacro( "Erroneous Group Length element length on : (" << std::hex << group << " , " << elem @@ -2405,9 +2405,9 @@ DocEntry *Document::ReadNextDocEntry() if ( newEntry->GetGroup() != 0xfffe ) { std::string msg; - int offset = Fp->tellg(); + std::streampos offset = Fp->tellg(); msg = Util::Format("Entry (%04x,%04x) at 0x(%x) should be Explicit VR\n", - newEntry->GetGroup(), newEntry->GetElement(), offset ); + newEntry->GetGroup(), newEntry->GetElement(), (size_t)offset ); gdcmWarningMacro( msg.c_str() ); } } @@ -2425,7 +2425,7 @@ DocEntry *Document::ReadNextDocEntry() return 0; } - newEntry->SetOffset(Fp->tellg()); // for each DocEntry + newEntry->SetOffset( (size_t)( Fp->tellg() ) ); // for each DocEntry return newEntry; } diff --git a/Utilities/ITK/Utilities/gdcm/src/gdcmElementSet.cxx b/Utilities/ITK/Utilities/gdcm/src/gdcmElementSet.cxx index 4141d5d597871bb6ea1e2cf296ca9584e9225176..5fd947f9d294eae2b1bc98e5f71f6374debe5d46 100644 --- a/Utilities/ITK/Utilities/gdcm/src/gdcmElementSet.cxx +++ b/Utilities/ITK/Utilities/gdcm/src/gdcmElementSet.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmElementSet.cxx,v $ Language: C++ - Date: $Date: 2008-11-30 14:00:30 $ - Version: $Revision: 1.7 $ + Date: $Date: 2009-12-02 09:46:25 $ + Version: $Revision: 1.8 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -95,7 +95,6 @@ bool ElementSet::RemoveEntry( DocEntry *entryToRemove) return true; } - delete entryToRemove; gdcmWarningMacro( "Key not present : " << key); return false ; } diff --git a/Utilities/ITK/Utilities/gdcm/src/gdcmFile.cxx b/Utilities/ITK/Utilities/gdcm/src/gdcmFile.cxx index 2b3b43d63b754417ec29bffe37952b3bbe09dde8..93d13a9d7336ab2116f04dd453ffd08fb526a65b 100644 --- a/Utilities/ITK/Utilities/gdcm/src/gdcmFile.cxx +++ b/Utilities/ITK/Utilities/gdcm/src/gdcmFile.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmFile.cxx,v $ Language: C++ - Date: $Date: 2009-04-29 21:40:53 $ - Version: $Revision: 1.28 $ + Date: $Date: 2010-01-10 17:52:05 $ + Version: $Revision: 1.29 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -759,6 +759,11 @@ float File::GetZSpacing() float File::GetXOrigin() { float xImPos, yImPos, zImPos; + if ( GetOriginFromSequence(xImPos, yImPos, zImPos) ) + { + return xImPos; + } + std::string strImPos = GetEntryValue(0x0020,0x0032); if ( strImPos == GDCM_UNFOUND ) @@ -780,6 +785,68 @@ float File::GetXOrigin() return xImPos; } +// Special case: +// ts["1.2.840.10008.5.1.4.1.1.4.1"] = "Enhanced MR Image Storage"; +bool File::GetOriginFromSequence(float &xorigin, float &yorigin, float &zorigin) +{ + + xorigin = yorigin = zorigin = 0.0; + + TS *ts = Global::GetTS(); + std::string sopclassuid_used; + // D 0002|0002 [UI] [Media Storage SOP Class UID] + const std::string &mediastoragesopclassuid_str = GetEntryValue(0x0002,0x0002); + const std::string &mediastoragesopclassuid = ts->GetValue(mediastoragesopclassuid_str); + //D 0008|0016 [UI] [SOP Class UID] + const std::string &sopclassuid_str = GetEntryValue(0x0008,0x0016); + const std::string &sopclassuid = ts->GetValue(sopclassuid_str); + if ( mediastoragesopclassuid == GDCM_UNFOUND && sopclassuid == GDCM_UNFOUND ) + { + return false; + } + else + { + if( mediastoragesopclassuid == sopclassuid ) + { + sopclassuid_used = mediastoragesopclassuid; + } + else + { + gdcmWarningMacro( "Inconsistant SOP Class UID: " + << mediastoragesopclassuid << " and " << sopclassuid ); + return false; + } + } + // ok we have now the correct SOP Class UID + if( sopclassuid_used == "Enhanced MR Image Storage" ) + { + SeqEntry *PerframeFunctionalGroupsSequence = GetSeqEntry(0x5200,0x9230); + unsigned int n = PerframeFunctionalGroupsSequence->GetNumberOfSQItems(); + if( !n ) return false; + SQItem *item1 = PerframeFunctionalGroupsSequence->GetFirstSQItem(); + DocEntry *p = item1->GetDocEntry(0x0020,0x9113); + if( !p ) return false; + SeqEntry *seq = dynamic_cast<SeqEntry*>(p); + unsigned int n1 = seq->GetNumberOfSQItems(); + if( !n1 ) return false; + SQItem *item2 = seq->GetFirstSQItem(); + // D 0020|0032 [DS] [Image Position Patient] [3] + DocEntry *p2 = item2->GetDocEntry(0x0020,0x0032); + if( !p2 ) return false; + ContentEntry *entry = dynamic_cast<ContentEntry *>(p2); + std::string origin = entry->GetValue(); + if ( sscanf( origin.c_str(), "%f \\ %f \\%f ", + &xorigin, &yorigin, &zorigin) != 3 ) + { + gdcmWarningMacro( "wrong Image Position Patient (0020,0032). " + << "Less than 3 values were found." ); + return false; + } + return true; + } + return false; +} + /** * \brief gets the info from 0020,0032 : Image Position Patient * else from 0020,0030 : Image Position (RET) @@ -789,6 +856,11 @@ float File::GetXOrigin() float File::GetYOrigin() { float xImPos, yImPos, zImPos; + if ( GetOriginFromSequence(xImPos, yImPos, zImPos) ) + { + return yImPos; + } + std::string strImPos = GetEntryValue(0x0020,0x0032); if ( strImPos == GDCM_UNFOUND) @@ -821,6 +893,11 @@ float File::GetYOrigin() float File::GetZOrigin() { float xImPos, yImPos, zImPos; + if ( GetOriginFromSequence(xImPos, yImPos, zImPos) ) + { + return zImPos; + } + std::string strImPos = GetEntryValue(0x0020,0x0032); if ( strImPos != GDCM_UNFOUND ) @@ -885,6 +962,69 @@ float File::GetZOrigin() return 0.; // Hopeless } +// Special case: +// ts["1.2.840.10008.5.1.4.1.1.4.1"] = "Enhanced MR Image Storage"; +bool File::GetImageOrientationFromSequence(float io[6]) +{ + //io is supposed to be float[6] + io[0] = io[4] = 1.; + io[1] = io[2] = io[3] = io[5] = 0.; + + TS *ts = Global::GetTS(); + std::string sopclassuid_used; + // D 0002|0002 [UI] [Media Storage SOP Class UID] + const std::string &mediastoragesopclassuid_str = GetEntryValue(0x0002,0x0002); + const std::string &mediastoragesopclassuid = ts->GetValue(mediastoragesopclassuid_str); + //D 0008|0016 [UI] [SOP Class UID] + const std::string &sopclassuid_str = GetEntryValue(0x0008,0x0016); + const std::string &sopclassuid = ts->GetValue(sopclassuid_str); + if ( mediastoragesopclassuid == GDCM_UNFOUND && sopclassuid == GDCM_UNFOUND ) + { + return false; + } + else + { + if( mediastoragesopclassuid == sopclassuid ) + { + sopclassuid_used = mediastoragesopclassuid; + } + else + { + gdcmWarningMacro( "Inconsistant SOP Class UID: " + << mediastoragesopclassuid << " and " << sopclassuid ); + return false; + } + } + // ok we have now the correct SOP Class UID + if( sopclassuid_used == "Enhanced MR Image Storage" ) + { + SeqEntry *PerframeFunctionalGroupsSequence = GetSeqEntry(0x5200,0x9230); + unsigned int n = PerframeFunctionalGroupsSequence->GetNumberOfSQItems(); + if( !n ) return false; + SQItem *item1 = PerframeFunctionalGroupsSequence->GetFirstSQItem(); + DocEntry *p = item1->GetDocEntry(0x0020,0x9116); + if( !p ) return false; + SeqEntry *seq = dynamic_cast<SeqEntry*>(p); + unsigned int n1 = seq->GetNumberOfSQItems(); + if( !n1 ) return false; + SQItem *item2 = seq->GetFirstSQItem(); + // D 0020|0037 [DS] [ImageOrientation] [6] + DocEntry *p2 = item2->GetDocEntry(0x0020,0x0037); + if( !p2 ) return false; + ContentEntry *entry = dynamic_cast<ContentEntry *>(p2); + std::string orientation = entry->GetValue(); + if ( sscanf( orientation.c_str(), "%f \\ %f \\%f \\%f \\%f \\%f ", + &io[0], &io[1], &io[2], &io[3], &io[4], &io[5]) != 6 ) + { + gdcmWarningMacro( "wrong Image Orientation Patient (0020,0037). " + << "Less than 6 values were found." ); + return false; + } + return true; + } + return false; +} + /** * \brief gets the info from 0020,0037 : Image Orientation Patient * or from 0020 0035 : Image Orientation (RET) @@ -895,6 +1035,11 @@ float File::GetZOrigin() */ bool File::GetImageOrientationPatient( float iop[6] ) { + if ( GetImageOrientationFromSequence(iop) ) + { + return true; + } + std::string strImOriPat; //iop is supposed to be float[6] iop[0] = iop[4] = 1.; diff --git a/Utilities/ITK/Utilities/gdcm/src/gdcmFile.h b/Utilities/ITK/Utilities/gdcm/src/gdcmFile.h index ba19e8c17c76f6b74ea3f35cc15557f28d6a18ba..3476f83dfe40e438f65621543e6d78687a284065 100644 --- a/Utilities/ITK/Utilities/gdcm/src/gdcmFile.h +++ b/Utilities/ITK/Utilities/gdcm/src/gdcmFile.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmFile.h,v $ Language: C++ - Date: $Date: 2007-02-21 23:50:03 $ - Version: $Revision: 1.8 $ + Date: $Date: 2010-01-10 17:52:05 $ + Version: $Revision: 1.9 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -137,8 +137,10 @@ public: float GetXOrigin(); float GetYOrigin(); float GetZOrigin(); + bool GetOriginFromSequence(float &xorigin, float &yorigin, float &zorigin); bool GetImageOrientationPatient( float iop[6] ); + bool GetImageOrientationFromSequence( float iop[6] ); int GetBitsStored(); int GetBitsAllocated(); diff --git a/Utilities/ITK/Utilities/itkExtHdrs/CMakeLists.txt b/Utilities/ITK/Utilities/itkExtHdrs/CMakeLists.txt index 6dbb51fb33324576fa69168e9f15c24af335b68e..3a46d968e3a835fc2e05abd34cf661f97289ab36 100644 --- a/Utilities/ITK/Utilities/itkExtHdrs/CMakeLists.txt +++ b/Utilities/ITK/Utilities/itkExtHdrs/CMakeLists.txt @@ -1,9 +1,16 @@ PROJECT(ITKEXTHDRS) +IF(ITK_USE_FLAT_DIRECTORY_INSTALL) + SET( ITK_INSTALL_INCLUDE_DIR_CM24_UTILITIES_ITKEXTHDRS ${ITK_INSTALL_INCLUDE_DIR_CM24}) +ELSE(ITK_USE_FLAT_DIRECTORY_INSTALL) + SET( ITK_INSTALL_INCLUDE_DIR_CM24_UTILITIES_ITKEXTHDRS ${ITK_INSTALL_INCLUDE_DIR_CM24}/Utilities/itkExtHdrs) +ENDIF(ITK_USE_FLAT_DIRECTORY_INSTALL) + + IF(NOT ITK_INSTALL_NO_DEVELOPMENT) - FILE(GLOB __files "${CMAKE_CURRENT_SOURCE_DIR}/*.h") + FILE(GLOB __files "${CMAKE_CURRENT_SOURCE_DIR}/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp") INSTALL(FILES ${__files} - DESTINATION ${ITK_INSTALL_INCLUDE_DIR_CM24}/Utilities/itkExtHdrs + DESTINATION ${ITK_INSTALL_INCLUDE_DIR_CM24_UTILITIES_ITKEXTHDRS} COMPONENT Development) ENDIF(NOT ITK_INSTALL_NO_DEVELOPMENT) diff --git a/Utilities/ITK/Utilities/itkExtHdrs/fdstream.hpp b/Utilities/ITK/Utilities/itkExtHdrs/fdstream.hpp new file mode 100644 index 0000000000000000000000000000000000000000..ea4cbae94edbb1ba55cfd7236ec7fd4423cb18cf --- /dev/null +++ b/Utilities/ITK/Utilities/itkExtHdrs/fdstream.hpp @@ -0,0 +1,186 @@ +/* The following code declares classes to read from and write to + * file descriptore or file handles. + * + * See + * http://www.josuttis.com/cppcode + * for details and the latest version. + * + * - open: + * - integrating BUFSIZ on some systems? + * - optimized reading of multiple characters + * - stream for reading AND writing + * - i18n + * + * (C) Copyright Nicolai M. Josuttis 2001. + * Permission to copy, use, modify, sell and distribute this software + * is granted provided this copyright notice appears in all copies. + * This software is provided "as is" without express or implied + * warranty, and with no claim as to its suitability for any purpose. + * + * Version: Jul 28, 2002 + * History: + * Jul 28, 2002: bugfix memcpy() => memmove() + * fdinbuf::underflow(): cast for return statements + * Aug 05, 2001: first public version + */ +/* Modifications by Tom Vercauteren: + * Use cmake to check for unistd.h + * Borland needs io.h + * Replaced int by ptrdiff_t when it makes sense + * Use itk namespace instead of boost + */ +#ifndef __fdstream_hpp +#define __fdstream_hpp + +#include <istream> +#include <ostream> +#include <streambuf> +// for EOF: +#include <cstdio> +// for memmove(): +#include <cstring> + + +// low-level read and write functions +#ifdef ITK_HAVE_UNISTD_H +# include <unistd.h> +#else +# include <io.h> +#endif + + +// BEGIN namespace +namespace itk { + + +/************************************************************ + * fdostream + * - a stream that writes on a file descriptor + ************************************************************/ + + +class fdoutbuf : public std::streambuf { + protected: + int fd; // file descriptor + public: + // constructor + fdoutbuf (int _fd) : fd(_fd) { + } + protected: + // write one character + virtual int_type overflow (int_type c) { + if (c != EOF) { + char z = c; + if (write (fd, &z, 1) != 1) { + return EOF; + } + } + return c; + } + // write multiple characters + virtual + std::streamsize xsputn (const char* s, + std::streamsize num) { + return write(fd,s,num); + } +}; + +class fdostream : public std::ostream { + protected: + fdoutbuf buf; + public: + fdostream (int fd) : std::ostream(0), buf(fd) { + rdbuf(&buf); + } +}; + + +/************************************************************ + * fdistream + * - a stream that reads on a file descriptor + ************************************************************/ + +class fdinbuf : public std::streambuf { + protected: + int fd; // file descriptor + protected: + /* data buffer: + * - at most, pbSize characters in putback area plus + * - at most, bufSize characters in ordinary read buffer + */ + static const ptrdiff_t pbSize = 4; // size of putback area + static const ptrdiff_t bufSize = 1024; // size of the data buffer + char buffer[bufSize+pbSize]; // data buffer + + public: + /* constructor + * - initialize file descriptor + * - initialize empty data buffer + * - no putback area + * => force underflow() + */ + fdinbuf (int _fd) : fd(_fd) { + setg (buffer+pbSize, // beginning of putback area + buffer+pbSize, // read position + buffer+pbSize); // end position + } + + protected: + // insert new characters into the buffer + virtual int_type underflow () { +#ifndef _MSC_VER + using std::memmove; +#endif + + // is read position before end of buffer? + if (gptr() < egptr()) { + return traits_type::to_int_type(*gptr()); + } + + /* process size of putback area + * - use number of characters read + * - but at most size of putback area + */ + ptrdiff_t numPutback; + numPutback = gptr() - eback(); + if (numPutback > pbSize) { + numPutback = pbSize; + } + + /* copy up to pbSize characters previously read into + * the putback area + */ + memmove (buffer+(pbSize-numPutback), gptr()-numPutback, + numPutback); + + // read at most bufSize new characters + int num; + num = read (fd, buffer+pbSize, bufSize); + if (num <= 0) { + // ERROR or EOF + return EOF; + } + + // reset buffer pointers + setg (buffer+(pbSize-numPutback), // beginning of putback area + buffer+pbSize, // read position + buffer+pbSize+num); // end of buffer + + // return next character + return traits_type::to_int_type(*gptr()); + } +}; + +class fdistream : public std::istream { + protected: + fdinbuf buf; + public: + fdistream (int fd) : std::istream(0), buf(fd) { + rdbuf(&buf); + } +}; + + +} // END namespace + +#endif /*include guard*/ diff --git a/Utilities/ITK/Utilities/itkjpeg/jcdiffct.c b/Utilities/ITK/Utilities/itkjpeg/jcdiffct.c index d3953425c259f936c862c1205137d2c738d26b20..ed9d37aceca820fe8727a24684f583c68a49e3ef 100644 --- a/Utilities/ITK/Utilities/itkjpeg/jcdiffct.c +++ b/Utilities/ITK/Utilities/itkjpeg/jcdiffct.c @@ -387,18 +387,18 @@ jinit_c_diff_controller (j_compress_ptr cinfo, boolean need_full_buffer) #ifdef FULL_SAMP_BUFFER_SUPPORTED /* Allocate a full-image virtual array for each component, */ /* padded to a multiple of samp_factor differences in each direction. */ - int ci; - jpeg_component_info *compptr; + int cix; + jpeg_component_info *compptr2; - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - diff->whole_image[ci] = (*cinfo->mem->request_virt_sarray) + for (cix = 0, compptr2 = cinfo->comp_info; cix < cinfo->num_components; + cix++, compptr2++) { + diff->whole_image[cix] = (*cinfo->mem->request_virt_sarray) ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, - (JDIMENSION) jround_up((long) compptr->width_in_data_units, - (long) compptr->h_samp_factor), - (JDIMENSION) jround_up((long) compptr->height_in_data_units, - (long) compptr->v_samp_factor), - (JDIMENSION) compptr->v_samp_factor); + (JDIMENSION) jround_up((long) compptr2->width_in_data_units, + (long) compptr2->h_samp_factor), + (JDIMENSION) jround_up((long) compptr2->height_in_data_units, + (long) compptr2->v_samp_factor), + (JDIMENSION) compptr2->v_samp_factor); } #else ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); diff --git a/Utilities/ITK/Utilities/itkjpeg/jcmarker.c b/Utilities/ITK/Utilities/itkjpeg/jcmarker.c index fc388d579b44f0cb43cfb3cecf58558067713d4a..e8d466ac953323ec3c1df944da78bf68bdebabc8 100644 --- a/Utilities/ITK/Utilities/itkjpeg/jcmarker.c +++ b/Utilities/ITK/Utilities/itkjpeg/jcmarker.c @@ -141,16 +141,16 @@ emit_2bytes (j_compress_ptr cinfo, int value) */ LOCAL(int) -emit_dqt (j_compress_ptr cinfo, int index) +emit_dqt (j_compress_ptr cinfo, int cindex) /* Emit a DQT marker */ /* Returns the precision used (0 = 8bits, 1 = 16bits) for baseline checking */ { - JQUANT_TBL * qtbl = cinfo->quant_tbl_ptrs[index]; + JQUANT_TBL * qtbl = cinfo->quant_tbl_ptrs[cindex]; int prec; int i; if (qtbl == NULL) - ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, index); + ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, cindex); prec = 0; for (i = 0; i < DCTSIZE2; i++) { @@ -163,7 +163,7 @@ emit_dqt (j_compress_ptr cinfo, int index) emit_2bytes(cinfo, prec ? DCTSIZE2*2 + 1 + 2 : DCTSIZE2 + 1 + 2); - emit_byte(cinfo, index + (prec<<4)); + emit_byte(cinfo, cindex + (prec<<4)); for (i = 0; i < DCTSIZE2; i++) { /* The table entries must be emitted in zigzag order. */ @@ -181,21 +181,21 @@ emit_dqt (j_compress_ptr cinfo, int index) LOCAL(void) -emit_dht (j_compress_ptr cinfo, int index, boolean is_ac) +emit_dht (j_compress_ptr cinfo, int cindex, boolean is_ac) /* Emit a DHT marker */ { JHUFF_TBL * htbl; int length, i; if (is_ac) { - htbl = cinfo->ac_huff_tbl_ptrs[index]; - index += 0x10; /* output index has AC bit set */ + htbl = cinfo->ac_huff_tbl_ptrs[cindex]; + cindex += 0x10; /* output cindex has AC bit set */ } else { - htbl = cinfo->dc_huff_tbl_ptrs[index]; + htbl = cinfo->dc_huff_tbl_ptrs[cindex]; } if (htbl == NULL) - ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, index); + ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, cindex); if (! htbl->sent_table) { emit_marker(cinfo, M_DHT); @@ -205,7 +205,7 @@ emit_dht (j_compress_ptr cinfo, int index, boolean is_ac) length += htbl->bits[i]; emit_2bytes(cinfo, length + 2 + 1 + 16); - emit_byte(cinfo, index); + emit_byte(cinfo, cindex); for (i = 1; i <= 16; i++) emit_byte(cinfo, htbl->bits[i]); diff --git a/Utilities/ITK/Utilities/itkjpeg/jdmarker.c b/Utilities/ITK/Utilities/itkjpeg/jdmarker.c index e280621b295bc88d09d159c4ec75a665073c2920..676bf809f06e7738e1b9d80428cc5d24fe17064d 100644 --- a/Utilities/ITK/Utilities/itkjpeg/jdmarker.c +++ b/Utilities/ITK/Utilities/itkjpeg/jdmarker.c @@ -376,29 +376,29 @@ get_dac (j_decompress_ptr cinfo) /* Process a DAC marker */ { INT32 length; - int index, val; + int cindex, val; INPUT_VARS(cinfo); INPUT_2BYTES(cinfo, length, return FALSE); length -= 2; while (length > 0) { - INPUT_BYTE(cinfo, index, return FALSE); + INPUT_BYTE(cinfo, cindex, return FALSE); INPUT_BYTE(cinfo, val, return FALSE); length -= 2; - TRACEMS2(cinfo, 1, JTRC_DAC, index, val); + TRACEMS2(cinfo, 1, JTRC_DAC, cindex, val); - if (index < 0 || index >= (2*NUM_ARITH_TBLS)) - ERREXIT1(cinfo, JERR_DAC_INDEX, index); + if (cindex < 0 || cindex >= (2*NUM_ARITH_TBLS)) + ERREXIT1(cinfo, JERR_DAC_INDEX, cindex); - if (index >= NUM_ARITH_TBLS) { /* define AC table */ - cinfo->arith_ac_K[index-NUM_ARITH_TBLS] = (UINT8) val; + if (cindex >= NUM_ARITH_TBLS) { /* define AC table */ + cinfo->arith_ac_K[cindex-NUM_ARITH_TBLS] = (UINT8) val; } else { /* define DC table */ - cinfo->arith_dc_L[index] = (UINT8) (val & 0x0F); - cinfo->arith_dc_U[index] = (UINT8) (val >> 4); - if (cinfo->arith_dc_L[index] > cinfo->arith_dc_U[index]) + cinfo->arith_dc_L[cindex] = (UINT8) (val & 0x0F); + cinfo->arith_dc_U[cindex] = (UINT8) (val >> 4); + if (cinfo->arith_dc_L[cindex] > cinfo->arith_dc_U[cindex]) ERREXIT1(cinfo, JERR_DAC_VALUE, val); } } @@ -424,7 +424,7 @@ get_dht (j_decompress_ptr cinfo) INT32 length; UINT8 bits[17]; UINT8 huffval[256]; - int i, index, count; + int i, cindex, count; JHUFF_TBL **htblptr; INPUT_VARS(cinfo); @@ -432,9 +432,9 @@ get_dht (j_decompress_ptr cinfo) length -= 2; while (length > 16) { - INPUT_BYTE(cinfo, index, return FALSE); + INPUT_BYTE(cinfo, cindex, return FALSE); - TRACEMS1(cinfo, 1, JTRC_DHT, index); + TRACEMS1(cinfo, 1, JTRC_DHT, cindex); bits[0] = 0; count = 0; @@ -463,15 +463,15 @@ get_dht (j_decompress_ptr cinfo) length -= count; - if (index & 0x10) { /* AC table definition */ - index -= 0x10; - htblptr = &cinfo->ac_huff_tbl_ptrs[index]; + if (cindex & 0x10) { /* AC table definition */ + cindex -= 0x10; + htblptr = &cinfo->ac_huff_tbl_ptrs[cindex]; } else { /* DC table definition */ - htblptr = &cinfo->dc_huff_tbl_ptrs[index]; + htblptr = &cinfo->dc_huff_tbl_ptrs[cindex]; } - if (index < 0 || index >= NUM_HUFF_TBLS) - ERREXIT1(cinfo, JERR_DHT_INDEX, index); + if (cindex < 0 || cindex >= NUM_HUFF_TBLS) + ERREXIT1(cinfo, JERR_DHT_INDEX, cindex); if (*htblptr == NULL) *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo); diff --git a/Utilities/ITK/Utilities/itkpng/CMakeLists.txt b/Utilities/ITK/Utilities/itkpng/CMakeLists.txt index 957aa8e18a27dd97914d798f530859b9fa3cfc67..a26997fa0a49d09268bc018051c51e0880ecc301 100644 --- a/Utilities/ITK/Utilities/itkpng/CMakeLists.txt +++ b/Utilities/ITK/Utilities/itkpng/CMakeLists.txt @@ -40,13 +40,19 @@ IF(NOT ITK_INSTALL_NO_LIBRARIES) ARCHIVE DESTINATION ${ITK_INSTALL_LIB_DIR_CM24} COMPONENT Development) ENDIF(NOT ITK_INSTALL_NO_LIBRARIES) +IF(ITK_USE_FLAT_DIRECTORY_INSTALL) + SET( ITK_INSTALL_INCLUDE_DIR_CM24_UTILITIES_ITKPNG ${ITK_INSTALL_INCLUDE_DIR_CM24}) +ELSE(ITK_USE_FLAT_DIRECTORY_INSTALL) + SET( ITK_INSTALL_INCLUDE_DIR_CM24_UTILITIES_ITKPNG ${ITK_INSTALL_INCLUDE_DIR_CM24}/Utilities/itkpng) +ENDIF(ITK_USE_FLAT_DIRECTORY_INSTALL) + IF(NOT ITK_INSTALL_NO_DEVELOPMENT) INSTALL(FILES ${ITKPNG_BINARY_DIR}/pngDllConfig.h ${ITKPNG_SOURCE_DIR}/png.h ${ITKPNG_SOURCE_DIR}/pngconf.h ${ITKPNG_SOURCE_DIR}/itk_png_mangle.h - DESTINATION ${ITK_INSTALL_INCLUDE_DIR_CM24}/Utilities/itkpng + DESTINATION ${ITK_INSTALL_INCLUDE_DIR_CM24_UTILITIES_ITKPNG} COMPONENT Development) ENDIF(NOT ITK_INSTALL_NO_DEVELOPMENT) diff --git a/Utilities/ITK/Utilities/itktiff/CMakeLists.txt b/Utilities/ITK/Utilities/itktiff/CMakeLists.txt index 9e3373b070c740f7e67c098ac1f3d10907db82c7..3de799548f75c3fef888f69dd803b89d040c6fcc 100644 --- a/Utilities/ITK/Utilities/itktiff/CMakeLists.txt +++ b/Utilities/ITK/Utilities/itktiff/CMakeLists.txt @@ -153,6 +153,13 @@ IF(NOT ITK_INSTALL_NO_LIBRARIES) ARCHIVE DESTINATION ${ITK_INSTALL_LIB_DIR_CM24} COMPONENT Development) ENDIF(NOT ITK_INSTALL_NO_LIBRARIES) +IF(ITK_USE_FLAT_DIRECTORY_INSTALL) + SET( ITK_INSTALL_INCLUDE_DIR_CM24_UTILITIES_TIFF ${ITK_INSTALL_INCLUDE_DIR_CM24}) +ELSE(ITK_USE_FLAT_DIRECTORY_INSTALL) + SET( ITK_INSTALL_INCLUDE_DIR_CM24_UTILITIES_TIFF ${ITK_INSTALL_INCLUDE_DIR_CM24}/Utilities/itktiff) +ENDIF(ITK_USE_FLAT_DIRECTORY_INSTALL) + + IF(NOT ITK_INSTALL_NO_DEVELOPMENT) INSTALL(FILES ${ITKTIFF_BINARY_DIR}/tiffDllConfig.h @@ -161,7 +168,7 @@ IF(NOT ITK_INSTALL_NO_DEVELOPMENT) ${ITKTIFF_SOURCE_DIR}/tiff.h ${ITKTIFF_SOURCE_DIR}/tiffio.h ${ITKTIFF_SOURCE_DIR}/tconf.h - DESTINATION ${ITK_INSTALL_INCLUDE_DIR_CM24}/Utilities/itktiff + DESTINATION ${ITK_INSTALL_INCLUDE_DIR_CM24_UTILITIES_TIFF} COMPONENT Development) ENDIF(NOT ITK_INSTALL_NO_DEVELOPMENT) diff --git a/Utilities/ITK/Utilities/itktiff/tif_luv.c b/Utilities/ITK/Utilities/itktiff/tif_luv.c index 03bd1b683e7712acf429a37473b1fa4aeb6320bd..80d3d8412a5ff9348712ee857225282f60c26a01 100644 --- a/Utilities/ITK/Utilities/itktiff/tif_luv.c +++ b/Utilities/ITK/Utilities/itktiff/tif_luv.c @@ -1,4 +1,4 @@ -/* $Id: tif_luv.c,v 1.2 2007-01-04 16:46:32 ibanez Exp $ */ +/* $Id: tif_luv.c,v 1.3 2009-11-15 21:04:22 ibanez Exp $ */ /* * Copyright (c) 1997 Greg Ward Larson @@ -875,7 +875,7 @@ LogLuv24toXYZ(uint32 p, float XYZ[3]) /* decode luminance */ L = LogL10toY(p>>14 & 0x3ff); if (L <= 0.) { - XYZ[0] = XYZ[1] = XYZ[2] = 0.; + XYZ[0] = XYZ[1] = XYZ[2] = (float)(0.0); return; } /* decode color */ @@ -1015,7 +1015,7 @@ LogLuv32toXYZ(uint32 p, float XYZ[3]) /* decode luminance */ L = LogL16toY((int)p >> 16); if (L <= 0.) { - XYZ[0] = XYZ[1] = XYZ[2] = 0.; + XYZ[0] = XYZ[1] = XYZ[2] = (float)(0.0); return; } /* decode color */ diff --git a/Utilities/ITK/Utilities/itktiff/tif_unix.c b/Utilities/ITK/Utilities/itktiff/tif_unix.c index 39c745dc05c27ca041c1555372b1c056768e92d4..7ce1381a54063a4ca40c1692ec37918ac8bbe7d5 100644 --- a/Utilities/ITK/Utilities/itktiff/tif_unix.c +++ b/Utilities/ITK/Utilities/itktiff/tif_unix.c @@ -1,4 +1,4 @@ -/* $Id: tif_unix.c,v 1.1 2006-09-28 15:30:39 king Exp $ */ +/* $Id: tif_unix.c,v 1.2 2009-11-15 21:04:22 ibanez Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -110,7 +110,7 @@ static void _tiffUnmapProc(thandle_t fd, tdata_t base, toff_t size) { (void) fd; - (void) munmap(base, (off_t) size); + (void) munmap(base, (size_t) size); } #else /* !HAVE_MMAP */ static int diff --git a/Utilities/ITK/Utilities/itktiff/tiff.h b/Utilities/ITK/Utilities/itktiff/tiff.h index 53b30e801bf4ce4c9bc10209f0fff6aada465343..824d6f8ad2b24ca19deca773eff3cae92f9b2188 100644 --- a/Utilities/ITK/Utilities/itktiff/tiff.h +++ b/Utilities/ITK/Utilities/itktiff/tiff.h @@ -1,5 +1,5 @@ #include "itk_tiff_mangle.h" -/* $Id: tiff.h,v 1.1 2006-09-28 15:30:39 king Exp $ */ +/* $Id: tiff.h,v 1.2 2009-11-20 17:52:41 glehmann Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -82,7 +82,7 @@ typedef signed char int8; /* NB: non-ANSI compilers may not grok */ typedef unsigned char uint8; typedef short int16; typedef unsigned short uint16; /* sizeof (uint16) must == 2 */ -#if defined(__alpha) || (defined(_MIPS_SZLONG) && _MIPS_SZLONG == 64) || defined(__LP64__) || defined(__arch64__) +#if defined(__amd64) || defined(__alpha) || (defined(_MIPS_SZLONG) && _MIPS_SZLONG == 64) || defined(__LP64__) || defined(__arch64__) typedef int int32; typedef unsigned int uint32; /* sizeof (uint32) must == 4 */ #else diff --git a/Utilities/ITK/Utilities/itkzlib/CMakeLists.txt b/Utilities/ITK/Utilities/itkzlib/CMakeLists.txt index d676e8cb8aabb38b69304bb74b4d090f8538d08f..2ca0a4f52c30091d7b3da55e9a9c40e7f2701c84 100644 --- a/Utilities/ITK/Utilities/itkzlib/CMakeLists.txt +++ b/Utilities/ITK/Utilities/itkzlib/CMakeLists.txt @@ -44,12 +44,18 @@ IF(NOT ITK_INSTALL_NO_LIBRARIES) ARCHIVE DESTINATION ${ITK_INSTALL_LIB_DIR_CM24} COMPONENT Development) ENDIF(NOT ITK_INSTALL_NO_LIBRARIES) +IF(ITK_USE_FLAT_DIRECTORY_INSTALL) + SET( ITK_INSTALL_INCLUDE_DIR_CM24_UTILITIES_ZLIB ${ITK_INSTALL_INCLUDE_DIR_CM24}) +ELSE(ITK_USE_FLAT_DIRECTORY_INSTALL) + SET( ITK_INSTALL_INCLUDE_DIR_CM24_UTILITIES_ZLIB ${ITK_INSTALL_INCLUDE_DIR_CM24}/Utilities/itkzlib) +ENDIF(ITK_USE_FLAT_DIRECTORY_INSTALL) + IF(NOT ITK_INSTALL_NO_DEVELOPMENT) INSTALL(FILES ${ITKZLIB_SOURCE_DIR}/zlib.h ${ITKZLIB_SOURCE_DIR}/zconf.h ${ITKZLIB_SOURCE_DIR}/itk_zlib_mangle.h ${ITKZLIB_BINARY_DIR}/zlibDllConfig.h - DESTINATION ${ITK_INSTALL_INCLUDE_DIR_CM24}/Utilities/itkzlib + DESTINATION ${ITK_INSTALL_INCLUDE_DIR_CM24_UTILITIES_ZLIB} COMPONENT Development) ENDIF(NOT ITK_INSTALL_NO_DEVELOPMENT) diff --git a/Utilities/ITK/Utilities/itkzlib/deflate.c b/Utilities/ITK/Utilities/itkzlib/deflate.c index 89ce37c036625aa8b5aa3c3bd4556cf472fdae1e..ce711a0fc591f937942d764aa4d7955dbb439376 100644 --- a/Utilities/ITK/Utilities/itkzlib/deflate.c +++ b/Utilities/ITK/Utilities/itkzlib/deflate.c @@ -47,7 +47,7 @@ * */ -/* @(#) $Id: deflate.c,v 1.2 2007-08-14 14:02:42 seanmcbride Exp $ */ +/* @(#) $Id: deflate.c,v 1.3 2010-01-20 17:49:37 partyd Exp $ */ #include "deflate.h" @@ -285,6 +285,13 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH); s->window = (Bytef *) ZALLOC(strm, s->w_size, 2*sizeof(Byte)); + + // The following memset eliminates the valgrind uninitialized warning + // "swept under the carpet" here: + // http://www.zlib.net/zlib_faq.html#faq36 + // + memset(s->window, 0, s->w_size*2*sizeof(Byte)); + s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos)); s->head = (Posf *) ZALLOC(strm, s->hash_size, sizeof(Pos)); diff --git a/Utilities/ITK/Utilities/kwsys/Base64.c b/Utilities/ITK/Utilities/kwsys/Base64.c index 7af6d8cd9327fe59ee2a44143b0f06cd002c0898..d07bdd01b66040d88f6ac5b3730dbf6bc57dcffa 100644 --- a/Utilities/ITK/Utilities/kwsys/Base64.c +++ b/Utilities/ITK/Utilities/kwsys/Base64.c @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: Base64.c,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #include "kwsysPrivate.h" #include KWSYS_HEADER(Base64.h) diff --git a/Utilities/ITK/Utilities/kwsys/Base64.h.in b/Utilities/ITK/Utilities/kwsys/Base64.h.in index 3300a3996e622c1693fa7ccf827f973243f5a523..3468007687e2849c6a2abe252abbe844ec4bbfa2 100644 --- a/Utilities/ITK/Utilities/kwsys/Base64.h.in +++ b/Utilities/ITK/Utilities/kwsys/Base64.h.in @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: Base64.h.in,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #ifndef @KWSYS_NAMESPACE@_Base64_h #define @KWSYS_NAMESPACE@_Base64_h diff --git a/Utilities/ITK/Utilities/kwsys/CMakeLists.txt b/Utilities/ITK/Utilities/kwsys/CMakeLists.txt index 9e7b1279437e686f6d4dd569ac44aeb692c9b58d..62042e86e6442674057fcd828eaa54faef1d6fb3 100644 --- a/Utilities/ITK/Utilities/kwsys/CMakeLists.txt +++ b/Utilities/ITK/Utilities/kwsys/CMakeLists.txt @@ -1,15 +1,13 @@ #============================================================================= +# KWSys - Kitware System Library +# Copyright 2000-2009 Kitware, Inc., Insight Software Consortium # -# Program: KWSys - Kitware System Library -# Module: $RCSfile: CMakeLists.txt,v $ -# -# Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. -# See Copyright.txt or http://www.kitware.com/Copyright.htm for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even -# the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -# PURPOSE. See the above copyright notices for more information. +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. # +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. #============================================================================= # The Kitware System Library is intended to be included in other @@ -55,6 +53,8 @@ # KWSYS_INSTALL_INCLUDE_DIR kwsys should be installed by a "make install". # The values should be specified relative to # the installation prefix and NOT start with '/'. +# KWSYS_INSTALL_DOC_DIR = The installation target directory for documentation +# such as copyright information. # # KWSYS_INSTALL_COMPONENT_NAME_RUNTIME = Name of runtime and development # KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT installation components. @@ -103,6 +103,14 @@ # any outside mailing list and no documentation of the change will be # written. +CMAKE_MINIMUM_REQUIRED(VERSION 2.4.5 FATAL_ERROR) +IF(COMMAND CMAKE_POLICY) + CMAKE_POLICY(SET CMP0003 NEW) +ENDIF(COMMAND CMAKE_POLICY) + +# Allow empty endif() and such with CMake 2.4. +SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS 1) + #----------------------------------------------------------------------------- # If a namespace is not specified, use "kwsys" and enable testing. # This should be the case only when kwsys is not included inside @@ -111,12 +119,6 @@ IF(NOT KWSYS_NAMESPACE) SET(KWSYS_NAMESPACE "kwsys") SET(KWSYS_STANDALONE 1) ENDIF(NOT KWSYS_NAMESPACE) -IF(KWSYS_STANDALONE) - CMAKE_MINIMUM_REQUIRED(VERSION 2.4) - IF(COMMAND CMAKE_POLICY) - CMAKE_POLICY(SET CMP0003 NEW) - ENDIF(COMMAND CMAKE_POLICY) -ENDIF(KWSYS_STANDALONE) #----------------------------------------------------------------------------- # The project name is that of the specified namespace. @@ -139,11 +141,16 @@ IF(COMMAND SET_PROPERTY) "KWSYS_HEADER(%)=<${KWSYS_NAMESPACE}/%>" ) ENDIF(COMMAND SET_PROPERTY) +# add option to disable memory cleanup at exit of putenv memory +IF(DEFINED KWSYS_DO_NOT_CLEAN_PUTENV) + SET(KWSYS_DO_NOT_CLEAN_PUTENV 1) +ELSE(DEFINED KWSYS_DO_NOT_CLEAN_PUTENV) + SET(KWSYS_DO_NOT_CLEAN_PUTENV 0) +ENDIF(DEFINED KWSYS_DO_NOT_CLEAN_PUTENV) # Select library components. IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) SET(KWSYS_ENABLE_C 1) - # Enable all components. SET(KWSYS_USE_Base64 1) SET(KWSYS_USE_Directory 1) @@ -294,13 +301,6 @@ ELSE(COMMAND INSTALL) SET(KWSYS_INSTALL_LIB_DIR) ENDIF(COMMAND INSTALL) -# Work-around for CMake 1.6.7 bug in custom command dependencies when -# there is no executable output path. -IF(NOT EXECUTABLE_OUTPUT_PATH) - SET(EXECUTABLE_OUTPUT_PATH "${PROJECT_BINARY_DIR}" CACHE PATH - "Output directory for executables.") -ENDIF(NOT EXECUTABLE_OUTPUT_PATH) - # Generated source files will need this header. STRING(COMPARE EQUAL "${PROJECT_SOURCE_DIR}" "${PROJECT_BINARY_DIR}" KWSYS_IN_SOURCE_BUILD) @@ -469,19 +469,54 @@ IF(UNIX) ENDIF(UNIX) IF(KWSYS_USE_FundamentalType) - # Determine type sizes. - CHECK_TYPE_SIZE("char" KWSYS_SIZEOF_CHAR) - CHECK_TYPE_SIZE("short" KWSYS_SIZEOF_SHORT) - CHECK_TYPE_SIZE("int" KWSYS_SIZEOF_INT) - CHECK_TYPE_SIZE("long" KWSYS_SIZEOF_LONG) - CHECK_TYPE_SIZE("long long" KWSYS_SIZEOF_LONG_LONG) - CHECK_TYPE_SIZE("__int64" KWSYS_SIZEOF___INT64) - IF(NOT KWSYS_SIZEOF_LONG_LONG) - SET(KWSYS_SIZEOF_LONG_LONG 0) - ENDIF(NOT KWSYS_SIZEOF_LONG_LONG) - IF(NOT KWSYS_SIZEOF___INT64) - SET(KWSYS_SIZEOF___INT64 0) - ENDIF(NOT KWSYS_SIZEOF___INT64) + # Look for type size helper macros. + KWSYS_PLATFORM_INFO_TEST(C KWSYS_C_TYPE_MACROS + "Checking for C type size macros") + SET(macro_regex ".*INFO:macro\\[([^]]*)\\].*") + FOREACH(info ${KWSYS_C_TYPE_MACROS}) + IF("${info}" MATCHES "${macro_regex}") + STRING(REGEX REPLACE "${macro_regex}" "\\1" macro "${info}") + SET(KWSYS_C_HAS_MACRO_${macro} 1) + ENDIF() + ENDFOREACH() + + # Determine type sizes at preprocessing time if possible, and + # otherwise fall back to a try-compile. + SET(KWSYS_C_TYPE_NAME_CHAR "char") + SET(KWSYS_C_TYPE_NAME_SHORT "short") + SET(KWSYS_C_TYPE_NAME_INT "int") + SET(KWSYS_C_TYPE_NAME_LONG "long") + SET(KWSYS_C_TYPE_NAME_LONG_LONG "long long") + SET(KWSYS_C_TYPE_NAME___INT64 "__int64") + FOREACH(type CHAR SHORT INT LONG LONG_LONG __INT64) + IF(KWSYS_C_HAS_MACRO___SIZEOF_${type}__) + # Use __SIZEOF_${type}__ macro. + SET(KWSYS_SIZEOF_${type} TRUE) + SET(KWSYS_C_CODE_SIZEOF_${type} "#define ${KWSYS_NAMESPACE}_SIZEOF_${type} __SIZEOF_${type}__") + ELSEIF(KWSYS_C_HAS_MACRO___${type}_MAX__) + # Use __${type}_MAX__ macro. + SET(KWSYS_SIZEOF_${type} TRUE) + SET(KWSYS_C_CODE_SIZEOF_${type} "#if __${type}_MAX__ == 0x7f +# define ${KWSYS_NAMESPACE}_SIZEOF_${type} 1 +#elif __${type}_MAX__ == 0x7fff +# define ${KWSYS_NAMESPACE}_SIZEOF_${type} 2 +#elif __${type}_MAX__ == 0x7fffffff +# define ${KWSYS_NAMESPACE}_SIZEOF_${type} 4 +#elif __${type}_MAX__>>32 == 0x7fffffff +# define ${KWSYS_NAMESPACE}_SIZEOF_${type} 8 +#else +# error \"Cannot determine sizeof(${KWSYS_C_TYPE_NAME_${type}}).\" +#endif") + ELSE() + # Configure a hard-coded type size. + CHECK_TYPE_SIZE("${KWSYS_C_TYPE_NAME_${type}}" KWSYS_SIZEOF_${type}) + IF(NOT KWSYS_SIZEOF_${type}) + SET(KWSYS_SIZEOF_${type} 0) + ENDIF() + SET(KWSYS_C_CODE_SIZEOF_${type} + "#define ${KWSYS_NAMESPACE}_SIZEOF_${type} ${KWSYS_SIZEOF_${type}}") + ENDIF() + ENDFOREACH() # Check uniqueness of types. IF(KWSYS_SIZEOF___INT64) @@ -525,8 +560,9 @@ ENDIF(KWSYS_USE_FundamentalType) IF(KWSYS_USE_IOStream) # Determine whether iostreams support long long. - CHECK_TYPE_SIZE("long long" KWSYS_SIZEOF_LONG_LONG) - IF(KWSYS_SIZEOF_LONG_LONG) + KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_LONG_LONG + "Checking whether C++ compiler has 'long long'" DIRECT) + IF(KWSYS_CXX_HAS_LONG_LONG) SET(KWSYS_PLATFORM_CXX_TEST_DEFINES -DKWSYS_IOS_USE_ANSI=${KWSYS_IOS_USE_ANSI} -DKWSYS_IOS_HAVE_STD=${KWSYS_IOS_HAVE_STD}) @@ -535,10 +571,10 @@ IF(KWSYS_USE_IOStream) KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_HAS_OSTREAM_LONG_LONG "Checking if ostream supports long long" DIRECT) SET(KWSYS_PLATFORM_CXX_TEST_DEFINES) - ELSE(KWSYS_SIZEOF_LONG_LONG) + ELSE() SET(KWSYS_IOS_HAS_ISTREAM_LONG_LONG 0) SET(KWSYS_IOS_HAS_OSTREAM_LONG_LONG 0) - ENDIF(KWSYS_SIZEOF_LONG_LONG) + ENDIF() ENDIF(KWSYS_USE_IOStream) IF(KWSYS_NAMESPACE MATCHES "^kwsys$") @@ -568,6 +604,22 @@ ENDIF(NOT KWSYS_HEADER_ROOT) SET(KWSYS_HEADER_DIR "${KWSYS_HEADER_ROOT}/${KWSYS_NAMESPACE}") INCLUDE_DIRECTORIES(${KWSYS_HEADER_ROOT}) +#----------------------------------------------------------------------------- +IF(KWSYS_INSTALL_DOC_DIR) + # Assign the license to the runtime component since it must be + # distributed with binary forms of this software. + IF(KWSYS_INSTALL_COMPONENT_NAME_RUNTIME) + SET(KWSYS_INSTALL_LICENSE_OPTIONS ${KWSYS_INSTALL_LICENSE_OPTIONS} + COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_RUNTIME} + ) + ENDIF(KWSYS_INSTALL_COMPONENT_NAME_RUNTIME) + + # Install the license under the documentation directory. + INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/Copyright.txt + DESTINATION ${KWSYS_INSTALL_DOC_DIR}/${KWSYS_NAMESPACE} + ${KWSYS_INSTALL_LICENSE_OPTIONS}) +ENDIF(KWSYS_INSTALL_DOC_DIR) + #----------------------------------------------------------------------------- # Create STL header wrappers to block warnings in the STL headers and # give standard names by which they may be included. @@ -968,6 +1020,7 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) # If kwsys contains the DynamicLoader, need extra library ADD_LIBRARY(${KWSYS_NAMESPACE}TestDynload MODULE testDynload.c) KWSYS_SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestDynload PROPERTY LABELS ${KWSYS_LABELS_LIB}) + ADD_DEPENDENCIES(${KWSYS_NAMESPACE}TestDynload ${KWSYS_NAMESPACE}) ENDIF(KWSYS_USE_DynamicLoader) CREATE_TEST_SOURCELIST( KWSYS_CXX_TEST_SRCS ${KWSYS_NAMESPACE}TestsCxx.cxx @@ -1036,12 +1089,18 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) KWSYS_SET_PROPERTY(TEST kwsys.testProcess-${n} PROPERTY LABELS ${KWSYS_LABELS_TEST}) ENDFOREACH(n) + # Some Apple compilers produce bad optimizations in this source. + IF(APPLE AND "${CMAKE_C_COMPILER_ID}" MATCHES "^(GNU|LLVM)$") + SET_SOURCE_FILES_PROPERTIES(testProcess.c PROPERTIES COMPILE_FLAGS -O0) + ENDIF() + # Test SharedForward CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/testSharedForward.c.in ${PROJECT_BINARY_DIR}/testSharedForward.c @ONLY IMMEDIATE) ADD_EXECUTABLE(${KWSYS_NAMESPACE}TestSharedForward ${PROJECT_BINARY_DIR}/testSharedForward.c) KWSYS_SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestSharedForward PROPERTY LABELS ${KWSYS_LABELS_EXE}) + ADD_DEPENDENCIES(${KWSYS_NAMESPACE}TestSharedForward ${KWSYS_NAMESPACE}_c) ADD_TEST(kwsys.testSharedForward ${EXEC_DIR}/${KWSYS_NAMESPACE}TestSharedForward 1) KWSYS_SET_PROPERTY(TEST kwsys.testSharedForward PROPERTY LABELS ${KWSYS_LABELS_TEST}) diff --git a/Utilities/ITK/Utilities/kwsys/CPU.h.in b/Utilities/ITK/Utilities/kwsys/CPU.h.in index a7ac863130c4846fe2ed2331ff432b8e41ba4aec..ecd29d1338b316648033e0708efef1872a55aea8 100644 --- a/Utilities/ITK/Utilities/kwsys/CPU.h.in +++ b/Utilities/ITK/Utilities/kwsys/CPU.h.in @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: CPU.h.in,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #ifndef @KWSYS_NAMESPACE@_CPU_h #define @KWSYS_NAMESPACE@_CPU_h diff --git a/Utilities/ITK/Utilities/kwsys/CTestConfig.cmake b/Utilities/ITK/Utilities/kwsys/CTestConfig.cmake index e4e7b0da127a62faeb0985f25674fa7024789008..9ab6ed86cbbff5fcbac419f513eb841c051c9279 100644 --- a/Utilities/ITK/Utilities/kwsys/CTestConfig.cmake +++ b/Utilities/ITK/Utilities/kwsys/CTestConfig.cmake @@ -1,3 +1,14 @@ +#============================================================================= +# KWSys - Kitware System Library +# Copyright 2000-2009 Kitware, Inc., Insight Software Consortium +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= set (CTEST_PROJECT_NAME "kwsys") set (CTEST_NIGHTLY_START_TIME "21:00:00 EDT") set (CTEST_DART_SERVER_VERSION "2") diff --git a/Utilities/ITK/Utilities/kwsys/CommandLineArguments.cxx b/Utilities/ITK/Utilities/kwsys/CommandLineArguments.cxx index 8d35b0993a4ae70bbbc378ee4729f1e34c71e748..9f43a47c8f532b44a6c3fd903f4544d333527d7d 100644 --- a/Utilities/ITK/Utilities/kwsys/CommandLineArguments.cxx +++ b/Utilities/ITK/Utilities/kwsys/CommandLineArguments.cxx @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: CommandLineArguments.cxx,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #include "kwsysPrivate.h" #include KWSYS_HEADER(CommandLineArguments.hxx) diff --git a/Utilities/ITK/Utilities/kwsys/CommandLineArguments.hxx.in b/Utilities/ITK/Utilities/kwsys/CommandLineArguments.hxx.in index 1f2bed68899b2ddf0b4721da4d8413e3563b020a..68e9600ef2533e47ccbaac61cb240f5552fbee65 100644 --- a/Utilities/ITK/Utilities/kwsys/CommandLineArguments.hxx.in +++ b/Utilities/ITK/Utilities/kwsys/CommandLineArguments.hxx.in @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: CommandLineArguments.hxx.in,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #ifndef @KWSYS_NAMESPACE@_CommandLineArguments_hxx #define @KWSYS_NAMESPACE@_CommandLineArguments_hxx diff --git a/Utilities/ITK/Utilities/kwsys/Configure.h.in b/Utilities/ITK/Utilities/kwsys/Configure.h.in index 847ce3c4350b9829296b3ade429ae30a4f7f284b..97b2c5d0ef626a9fdca9c72612b85f63b3063f05 100644 --- a/Utilities/ITK/Utilities/kwsys/Configure.h.in +++ b/Utilities/ITK/Utilities/kwsys/Configure.h.in @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: Configure.h.in,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #ifndef @KWSYS_NAMESPACE@_Configure_h #define @KWSYS_NAMESPACE@_Configure_h @@ -27,6 +25,9 @@ # if defined(__BORLANDC__) # pragma warn -8027 /* function not inlined. */ # endif +# if defined(__INTEL_COMPILER) +# pragma warning (disable: 1572) /* floating-point equality test */ +# endif #endif /* Whether kwsys namespace is "kwsys". */ @@ -87,11 +88,17 @@ #endif /* Setup the export macro. */ -#if defined(_WIN32) && @KWSYS_BUILD_SHARED@ -# if defined(@KWSYS_NAMESPACE@_EXPORTS) -# define @KWSYS_NAMESPACE@_EXPORT __declspec(dllexport) +#if @KWSYS_BUILD_SHARED@ +# if defined(_WIN32) || defined(__CYGWIN__) +# if defined(@KWSYS_NAMESPACE@_EXPORTS) +# define @KWSYS_NAMESPACE@_EXPORT __declspec(dllexport) +# else +# define @KWSYS_NAMESPACE@_EXPORT __declspec(dllimport) +# endif +# elif __GNUC__ >= 4 +# define @KWSYS_NAMESPACE@_EXPORT __attribute__ ((visibility("default"))) # else -# define @KWSYS_NAMESPACE@_EXPORT __declspec(dllimport) +# define @KWSYS_NAMESPACE@_EXPORT # endif #else # define @KWSYS_NAMESPACE@_EXPORT diff --git a/Utilities/ITK/Utilities/kwsys/Configure.hxx.in b/Utilities/ITK/Utilities/kwsys/Configure.hxx.in index cdf6d93d9db18c1ce6570e194de2673387201180..9310d94fa1d11d100961406751b40fbcfaa89f0d 100644 --- a/Utilities/ITK/Utilities/kwsys/Configure.hxx.in +++ b/Utilities/ITK/Utilities/kwsys/Configure.hxx.in @@ -1,22 +1,29 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: Configure.hxx.in,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #ifndef @KWSYS_NAMESPACE@_Configure_hxx #define @KWSYS_NAMESPACE@_Configure_hxx /* Include C configuration. */ #include <@KWSYS_NAMESPACE@/Configure.h> +/* Disable cleanup of putenv memory for issues with GCOV */ +#if @KWSYS_DO_NOT_CLEAN_PUTENV@ +#define KWSYS_DO_NOT_CLEAN_PUTENV +#else +#undef KWSYS_DO_NOT_CLEAN_PUTENV +#endif + + + /* Whether ANSI C++ stream headers are to be used. */ #define @KWSYS_NAMESPACE@_IOS_USE_ANSI @KWSYS_IOS_USE_ANSI@ diff --git a/Utilities/ITK/Utilities/kwsys/Copyright.txt b/Utilities/ITK/Utilities/kwsys/Copyright.txt index 86e0e7375fe42bdcb8a896bcbffa11fb48cb415e..1549a7d5f5b629f96b403fbbe80ee10ad64e305d 100644 --- a/Utilities/ITK/Utilities/kwsys/Copyright.txt +++ b/Utilities/ITK/Utilities/kwsys/Copyright.txt @@ -1,33 +1,31 @@ -Copyright (c) 2000-2003 Kitware, Inc., Insight Consortium. +KWSys - Kitware System Library +Copyright 2000-2009 Kitware, Inc., Insight Software Consortium All rights reserved. Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: +modification, are permitted provided that the following conditions +are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the - distribution. +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. - * Neither the name of Kitware nor the names of any contributors may - be used to endorse or promote products derived from this software - without specific prior written permission. - - * Modified source versions must be plainly marked as such, and must - not be misrepresented as being the original software. +* Neither the names of Kitware, Inc., the Insight Software Consortium, + nor the names of their contributors may be used to endorse or promote + products derived from this software without specific prior written + permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR -CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/Utilities/ITK/Utilities/kwsys/DateStamp.h.in b/Utilities/ITK/Utilities/kwsys/DateStamp.h.in index efaad35c58df624f0ab39f66e00f6ddbab385bc1..c3d0099492f7812ecdab02b282833b53b234f930 100644 --- a/Utilities/ITK/Utilities/kwsys/DateStamp.h.in +++ b/Utilities/ITK/Utilities/kwsys/DateStamp.h.in @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: DateStamp.h.in,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #ifndef @KWSYS_NAMESPACE@_DateStamp_h #define @KWSYS_NAMESPACE@_DateStamp_h diff --git a/Utilities/ITK/Utilities/kwsys/Directory.cxx b/Utilities/ITK/Utilities/kwsys/Directory.cxx index b408e123634891fc8e195bd04116ee9e58d8ba31..b88474781917cc02fba332bbf69be7b46c088e6b 100644 --- a/Utilities/ITK/Utilities/kwsys/Directory.cxx +++ b/Utilities/ITK/Utilities/kwsys/Directory.cxx @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: Directory.cxx,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #include "kwsysPrivate.h" #include KWSYS_HEADER(Directory.hxx) diff --git a/Utilities/ITK/Utilities/kwsys/Directory.hxx.in b/Utilities/ITK/Utilities/kwsys/Directory.hxx.in index 0be75ef9ed7d3a08be5fd76464935cbd354fc4f6..05217c46d798cb3dc54f736a08363cc74fc8b1fc 100644 --- a/Utilities/ITK/Utilities/kwsys/Directory.hxx.in +++ b/Utilities/ITK/Utilities/kwsys/Directory.hxx.in @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: Directory.hxx.in,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #ifndef @KWSYS_NAMESPACE@_Directory_hxx #define @KWSYS_NAMESPACE@_Directory_hxx diff --git a/Utilities/ITK/Utilities/kwsys/DynamicLoader.cxx b/Utilities/ITK/Utilities/kwsys/DynamicLoader.cxx index 6d0671d9440fbabfa89b7ef48c647d0160dae5a5..58e02c76bd66c1ec95940d3c5b580c1812fb4262 100644 --- a/Utilities/ITK/Utilities/kwsys/DynamicLoader.cxx +++ b/Utilities/ITK/Utilities/kwsys/DynamicLoader.cxx @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: DynamicLoader.cxx,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #include "kwsysPrivate.h" #include KWSYS_HEADER(DynamicLoader.hxx) @@ -446,7 +444,7 @@ const char* DynamicLoader::LastError() // 5. Implementation for systems without dynamic libs // __gnu_blrts__ is IBM BlueGene/L // __LIBCATAMOUNT__ is defined on Catamount on Cray compute nodes -#if defined(__gnu_blrts__) || defined(__LIBCATAMOUNT__) +#if defined(__gnu_blrts__) || defined(__LIBCATAMOUNT__) || defined(__CRAYXT_COMPUTE_LINUX_TARGET) #include <string.h> // for strerror() #define DYNAMICLOADER_DEFINED 1 diff --git a/Utilities/ITK/Utilities/kwsys/DynamicLoader.hxx.in b/Utilities/ITK/Utilities/kwsys/DynamicLoader.hxx.in index d3a4c58524e2e33973f583649ff33651b8c2fe97..325e956fe55a97a9dfebcc88dbefcb6d2c19fa8d 100644 --- a/Utilities/ITK/Utilities/kwsys/DynamicLoader.hxx.in +++ b/Utilities/ITK/Utilities/kwsys/DynamicLoader.hxx.in @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: DynamicLoader.hxx.in,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #ifndef @KWSYS_NAMESPACE@_DynamicLoader_hxx #define @KWSYS_NAMESPACE@_DynamicLoader_hxx diff --git a/Utilities/ITK/Utilities/kwsys/EncodeExecutable.c b/Utilities/ITK/Utilities/kwsys/EncodeExecutable.c index 7e96fa90da44910b0d0fd3e22eb7f48f375d647f..ba474b89cba11d5de1bbe09e3a17e1fbf305cfc8 100644 --- a/Utilities/ITK/Utilities/kwsys/EncodeExecutable.c +++ b/Utilities/ITK/Utilities/kwsys/EncodeExecutable.c @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: EncodeExecutable.c,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #include <stdio.h> #ifdef __WATCOMC__ #define _unlink unlink diff --git a/Utilities/ITK/Utilities/kwsys/FundamentalType.h.in b/Utilities/ITK/Utilities/kwsys/FundamentalType.h.in index 5d057343e681a8cc91d68f0abcf5206539ceb664..ff200633afcda92270b200344d87bb35b9baca21 100644 --- a/Utilities/ITK/Utilities/kwsys/FundamentalType.h.in +++ b/Utilities/ITK/Utilities/kwsys/FundamentalType.h.in @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: FundamentalType.h.in,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #ifndef @KWSYS_NAMESPACE@_FundamentalType_h #define @KWSYS_NAMESPACE@_FundamentalType_h @@ -38,12 +36,12 @@ #endif /* The size of fundamental types. Types that do not exist have size 0. */ -#define @KWSYS_NAMESPACE@_SIZEOF_CHAR @KWSYS_SIZEOF_CHAR@ -#define @KWSYS_NAMESPACE@_SIZEOF_SHORT @KWSYS_SIZEOF_SHORT@ -#define @KWSYS_NAMESPACE@_SIZEOF_INT @KWSYS_SIZEOF_INT@ -#define @KWSYS_NAMESPACE@_SIZEOF_LONG @KWSYS_SIZEOF_LONG@ -#define @KWSYS_NAMESPACE@_SIZEOF_LONG_LONG @KWSYS_SIZEOF_LONG_LONG@ -#define @KWSYS_NAMESPACE@_SIZEOF___INT64 @KWSYS_SIZEOF___INT64@ +@KWSYS_C_CODE_SIZEOF_CHAR@ +@KWSYS_C_CODE_SIZEOF_SHORT@ +@KWSYS_C_CODE_SIZEOF_INT@ +@KWSYS_C_CODE_SIZEOF_LONG@ +@KWSYS_C_CODE_SIZEOF_LONG_LONG@ +@KWSYS_C_CODE_SIZEOF___INT64@ /* Whether types "long long" and "__int64" are enabled. If a type is enabled then it is a unique fundamental type. */ diff --git a/Utilities/ITK/Utilities/kwsys/Glob.cxx b/Utilities/ITK/Utilities/kwsys/Glob.cxx index 9feeae352ef96f5382768203ccef1430008991e3..c1f5100997e672d6f44428107d76a75dd9c363cf 100644 --- a/Utilities/ITK/Utilities/kwsys/Glob.cxx +++ b/Utilities/ITK/Utilities/kwsys/Glob.cxx @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: Glob.cxx,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #include "kwsysPrivate.h" #include KWSYS_HEADER(Glob.hxx) diff --git a/Utilities/ITK/Utilities/kwsys/Glob.hxx.in b/Utilities/ITK/Utilities/kwsys/Glob.hxx.in index 33afcf92dd48fded947357731ec43d0c008e0a16..cb050ee28cc5df3b18031f283e126901f8ab4b9a 100644 --- a/Utilities/ITK/Utilities/kwsys/Glob.hxx.in +++ b/Utilities/ITK/Utilities/kwsys/Glob.hxx.in @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: Glob.hxx.in,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #ifndef @KWSYS_NAMESPACE@_Glob_hxx #define @KWSYS_NAMESPACE@_Glob_hxx diff --git a/Utilities/ITK/Utilities/kwsys/IOStream.cxx b/Utilities/ITK/Utilities/kwsys/IOStream.cxx index ab710cf8503117bf10673d1f8992dd93ab01b6ed..57b696eb359738bb4e3fdec78298f54523ec07ca 100644 --- a/Utilities/ITK/Utilities/kwsys/IOStream.cxx +++ b/Utilities/ITK/Utilities/kwsys/IOStream.cxx @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: IOStream.cxx,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #include "kwsysPrivate.h" #include KWSYS_HEADER(Configure.hxx) diff --git a/Utilities/ITK/Utilities/kwsys/IOStream.hxx.in b/Utilities/ITK/Utilities/kwsys/IOStream.hxx.in index 152ff5eaec6e3b316477fcbd34745e62058ff5e5..9eb99e0585d0c8aa5b7681d92cb03c028383d7d0 100644 --- a/Utilities/ITK/Utilities/kwsys/IOStream.hxx.in +++ b/Utilities/ITK/Utilities/kwsys/IOStream.hxx.in @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: IOStream.hxx.in,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #ifndef @KWSYS_NAMESPACE@_IOStream_hxx #define @KWSYS_NAMESPACE@_IOStream_hxx diff --git a/Utilities/ITK/Utilities/kwsys/MD5.c b/Utilities/ITK/Utilities/kwsys/MD5.c index 07314f4fe9ecbf683d6904564a3c163afbc4f47f..1ea0a66b1f25b2018e85fb52f39ed3723580f9d1 100644 --- a/Utilities/ITK/Utilities/kwsys/MD5.c +++ b/Utilities/ITK/Utilities/kwsys/MD5.c @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: MD5.c,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #include "kwsysPrivate.h" #include KWSYS_HEADER(MD5.h) @@ -54,7 +52,6 @@ ghost@aladdin.com */ -/* $Id: MD5.c,v 1.3 2009-07-08 20:18:19 david.cole Exp $ */ /* Independent implementation of MD5 (RFC 1321). diff --git a/Utilities/ITK/Utilities/kwsys/MD5.h.in b/Utilities/ITK/Utilities/kwsys/MD5.h.in index ae46d21fc39b2fc25608e5ed78c3d20a4f339084..33344317db2fecf12fdf51c8f96ea674b97f882c 100644 --- a/Utilities/ITK/Utilities/kwsys/MD5.h.in +++ b/Utilities/ITK/Utilities/kwsys/MD5.h.in @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: MD5.h.in,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #ifndef @KWSYS_NAMESPACE@_MD5_h #define @KWSYS_NAMESPACE@_MD5_h diff --git a/Utilities/ITK/Utilities/kwsys/Process.h.in b/Utilities/ITK/Utilities/kwsys/Process.h.in index 1c76c5a155442e77ad89f1f9be153a6d42df2f22..c5995eac1d5066ef9f27889c977280816615ed03 100644 --- a/Utilities/ITK/Utilities/kwsys/Process.h.in +++ b/Utilities/ITK/Utilities/kwsys/Process.h.in @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: Process.h.in,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #ifndef @KWSYS_NAMESPACE@_Process_h #define @KWSYS_NAMESPACE@_Process_h diff --git a/Utilities/ITK/Utilities/kwsys/ProcessFwd9x.c b/Utilities/ITK/Utilities/kwsys/ProcessFwd9x.c index 17494241b62f9b2f77c720adbbd89279cbb8e726..536c54b67097649ba70f8c787bef356a26f55512 100644 --- a/Utilities/ITK/Utilities/kwsys/ProcessFwd9x.c +++ b/Utilities/ITK/Utilities/kwsys/ProcessFwd9x.c @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: ProcessFwd9x.c,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ /* On Windows9x platforms, this executable is spawned between a parent diff --git a/Utilities/ITK/Utilities/kwsys/ProcessUNIX.c b/Utilities/ITK/Utilities/kwsys/ProcessUNIX.c index 51b209e6e3a1846ac1770c68b7434bf172dd8fdb..57f7b16ec80623d4155a912619d819d875af3be5 100644 --- a/Utilities/ITK/Utilities/kwsys/ProcessUNIX.c +++ b/Utilities/ITK/Utilities/kwsys/ProcessUNIX.c @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: ProcessUNIX.c,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #include "kwsysPrivate.h" #include KWSYS_HEADER(Process.h) #include KWSYS_HEADER(System.h) @@ -1877,9 +1875,8 @@ static int kwsysProcessSetupOutputPipeFile(int* p, const char* name) /* Close the existing descriptor. */ kwsysProcessCleanupDescriptor(p); - /* Open a file for the pipe to write (permissions 644). */ - if((fout = open(name, O_WRONLY | O_CREAT | O_TRUNC, - S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) < 0) + /* Open a file for the pipe to write. */ + if((fout = open(name, O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0) { return 0; } @@ -1923,7 +1920,7 @@ static int kwsysProcessGetTimeoutTime(kwsysProcess* cp, double* userTimeout, { /* The first time this is called, we need to calculate the time at which the child will timeout. */ - if(cp->Timeout && cp->TimeoutTime.tv_sec < 0) + if(cp->Timeout > 0 && cp->TimeoutTime.tv_sec < 0) { kwsysProcessTime length = kwsysProcessTimeFromDouble(cp->Timeout); cp->TimeoutTime = kwsysProcessTimeAdd(cp->StartTime, length); @@ -2376,12 +2373,17 @@ static pid_t kwsysProcessFork(kwsysProcess* cp, Here we define the command to call on each platform and the corresponding parsing format string. The parsing format should have two integers to store: the pid and then the ppid. */ -#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) +#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) \ + || defined(__FreeBSD_kernel__) # define KWSYSPE_PS_COMMAND "ps axo pid,ppid" # define KWSYSPE_PS_FORMAT "%d %d\n" -#elif defined(__hpux) || defined(__sparc) || defined(__sgi) || defined(_AIX) +#elif defined(__hpux) || defined(__sun__) || defined(__sgi) || defined(_AIX) \ + || defined(__sparc) # define KWSYSPE_PS_COMMAND "ps -ef" # define KWSYSPE_PS_FORMAT "%*s %d %d %*[^\n]\n" +#elif defined(__QNX__) +# define KWSYSPE_PS_COMMAND "ps -Af" +# define KWSYSPE_PS_FORMAT "%*d %d %d %*[^\n]\n" #elif defined(__CYGWIN__) # define KWSYSPE_PS_COMMAND "ps aux" # define KWSYSPE_PS_FORMAT "%d %d %*[^\n]\n" @@ -2394,13 +2396,8 @@ static void kwsysProcessKill(pid_t process_id) DIR* procdir; #endif - /* Kill the process now to make sure it does not create more - children. Do not reap it yet so we can identify its existing - children. There is a small race condition here. If the child - forks after we begin looking for children below but before it - receives this kill signal we might miss a child. Also we might - not be able to catch up to a fork bomb. */ - kill(process_id, SIGKILL); + /* Suspend the process to be sure it will not create more children. */ + kill(process_id, SIGSTOP); /* Kill all children if we can find them. */ #if defined(__linux__) || defined(__CYGWIN__) @@ -2488,6 +2485,19 @@ static void kwsysProcessKill(pid_t process_id) } #endif } + + /* Kill the process. */ + kill(process_id, SIGKILL); + +#if defined(__APPLE__) + /* On OS X 10.3 the above SIGSTOP occasionally prevents the SIGKILL + from working. Just in case, we resume the child and kill it + again. There is a small race condition in this obscure case. If + the child manages to fork again between these two signals, we + will not catch its children. */ + kill(process_id, SIGCONT); + kill(process_id, SIGKILL); +#endif } /*--------------------------------------------------------------------------*/ @@ -2712,7 +2722,7 @@ static void kwsysProcessesSignalHandler(int signum kwsysProcess_ssize_t status= read(cp->PipeReadEnds[KWSYSPE_PIPE_SIGNAL], &buf, 1); status=write(cp->SignalPipe, &buf, 1); - + (void)status; } } diff --git a/Utilities/ITK/Utilities/kwsys/ProcessWin32.c b/Utilities/ITK/Utilities/kwsys/ProcessWin32.c index 0ab9b602ed0edc0f474e719b552b716b46e8b346..c5ea6db20624bed431b8e93de90f16345293b4b4 100644 --- a/Utilities/ITK/Utilities/kwsys/ProcessWin32.c +++ b/Utilities/ITK/Utilities/kwsys/ProcessWin32.c @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: ProcessWin32.c,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #include "kwsysPrivate.h" #include KWSYS_HEADER(Process.h) #include KWSYS_HEADER(System.h) @@ -2518,6 +2516,11 @@ struct _SYSTEM_PROCESS_INFORMATION /*--------------------------------------------------------------------------*/ /* Toolhelp32 API definitions. */ #define TH32CS_SNAPPROCESS 0x00000002 +#if defined(_WIN64) +typedef unsigned __int64 ProcessULONG_PTR; +#else +typedef unsigned long ProcessULONG_PTR; +#endif typedef struct tagPROCESSENTRY32 PROCESSENTRY32; typedef PROCESSENTRY32* LPPROCESSENTRY32; struct tagPROCESSENTRY32 @@ -2525,7 +2528,7 @@ struct tagPROCESSENTRY32 DWORD dwSize; DWORD cntUsage; DWORD th32ProcessID; - DWORD th32DefaultHeapID; + ProcessULONG_PTR th32DefaultHeapID; DWORD th32ModuleID; DWORD cntThreads; DWORD th32ParentProcessID; diff --git a/Utilities/ITK/Utilities/kwsys/Registry.cxx b/Utilities/ITK/Utilities/kwsys/Registry.cxx index 9dd0560f87556623ef3f7236f19d70b62faeef59..284e8ad71c89eb54c332d83a65cebb38e2438120 100644 --- a/Utilities/ITK/Utilities/kwsys/Registry.cxx +++ b/Utilities/ITK/Utilities/kwsys/Registry.cxx @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: Registry.cxx,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #include "kwsysPrivate.h" #include KWSYS_HEADER(Registry.hxx) diff --git a/Utilities/ITK/Utilities/kwsys/Registry.hxx.in b/Utilities/ITK/Utilities/kwsys/Registry.hxx.in index c7f29bb5ec75d007055b6fd3df7eebf8be49a5b8..ed9b0107267a82cce46518e66c1d3aea3c435d25 100644 --- a/Utilities/ITK/Utilities/kwsys/Registry.hxx.in +++ b/Utilities/ITK/Utilities/kwsys/Registry.hxx.in @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: Registry.hxx.in,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #ifndef @KWSYS_NAMESPACE@_Registry_hxx #define @KWSYS_NAMESPACE@_Registry_hxx diff --git a/Utilities/ITK/Utilities/kwsys/RegularExpression.cxx b/Utilities/ITK/Utilities/kwsys/RegularExpression.cxx index abec755cdf6b82383dcebc7e1fcec8c0c10e3588..f6eeebae40fa506ada9f5d8293a3284640d659b8 100644 --- a/Utilities/ITK/Utilities/kwsys/RegularExpression.cxx +++ b/Utilities/ITK/Utilities/kwsys/RegularExpression.cxx @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: RegularExpression.cxx,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ // // Copyright (C) 1991 Texas Instruments Incorporated. // diff --git a/Utilities/ITK/Utilities/kwsys/RegularExpression.hxx.in b/Utilities/ITK/Utilities/kwsys/RegularExpression.hxx.in index 48c00477f765e9a4ae4f22fe64b3cc25e2c3497d..62e9cad23b2c0440cbb41db070c5ad068d33c6f0 100644 --- a/Utilities/ITK/Utilities/kwsys/RegularExpression.hxx.in +++ b/Utilities/ITK/Utilities/kwsys/RegularExpression.hxx.in @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: RegularExpression.hxx.in,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ // Original Copyright notice: // Copyright (C) 1991 Texas Instruments Incorporated. // diff --git a/Utilities/ITK/Utilities/kwsys/SharedForward.h.in b/Utilities/ITK/Utilities/kwsys/SharedForward.h.in index fe85f78ccbd2e3ba1afb0cae11afd77e181becd9..da62d843b780846c74b98b297268208c85a7494e 100644 --- a/Utilities/ITK/Utilities/kwsys/SharedForward.h.in +++ b/Utilities/ITK/Utilities/kwsys/SharedForward.h.in @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: SharedForward.h.in,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #ifndef @KWSYS_NAMESPACE@_SharedForward_h #define @KWSYS_NAMESPACE@_SharedForward_h @@ -196,31 +194,27 @@ static const char kwsys_shared_forward_path_slash[2] = {KWSYS_SHARED_FORWARD_PAT # define KWSYS_SHARED_FORWARD_LDD "ldd" # define KWSYS_SHARED_FORWARD_LDD_N 1 # define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH" -#endif /* FreeBSD */ -#if defined(__FreeBSD__) +#elif defined(__FreeBSD__) # define KWSYS_SHARED_FORWARD_LDD "ldd" # define KWSYS_SHARED_FORWARD_LDD_N 1 # define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH" -#endif /* OSX */ -#if defined(__APPLE__) +#elif defined(__APPLE__) # define KWSYS_SHARED_FORWARD_LDD "otool", "-L" # define KWSYS_SHARED_FORWARD_LDD_N 2 # define KWSYS_SHARED_FORWARD_LDPATH "DYLD_LIBRARY_PATH" -#endif /* AIX */ -#if defined(_AIX) +#elif defined(_AIX) # define KWSYS_SHARED_FORWARD_LDD "dump", "-H" # define KWSYS_SHARED_FORWARD_LDD_N 2 # define KWSYS_SHARED_FORWARD_LDPATH "LIBPATH" -#endif /* SUN */ -#if defined(__sparc) && !defined(__linux) +#elif defined(__sun) # define KWSYS_SHARED_FORWARD_LDD "ldd" # define KWSYS_SHARED_FORWARD_LDD_N 1 # include <sys/isa_defs.h> @@ -229,10 +223,9 @@ static const char kwsys_shared_forward_path_slash[2] = {KWSYS_SHARED_FORWARD_PAT # elif defined(_LP64) # define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH_64" # endif -#endif /* HP-UX */ -#if defined(__hpux) +#elif defined(__hpux) # define KWSYS_SHARED_FORWARD_LDD "chatr" # define KWSYS_SHARED_FORWARD_LDD_N 1 # if defined(__LP64__) @@ -240,10 +233,9 @@ static const char kwsys_shared_forward_path_slash[2] = {KWSYS_SHARED_FORWARD_PAT # else # define KWSYS_SHARED_FORWARD_LDPATH "SHLIB_PATH" # endif -#endif /* SGI MIPS */ -#if defined(__sgi) && defined(_MIPS_SIM) +#elif defined(__sgi) && defined(_MIPS_SIM) # define KWSYS_SHARED_FORWARD_LDD "ldd" # define KWSYS_SHARED_FORWARD_LDD_N 1 # if _MIPS_SIM == _ABIO32 @@ -253,19 +245,19 @@ static const char kwsys_shared_forward_path_slash[2] = {KWSYS_SHARED_FORWARD_PAT # elif _MIPS_SIM == _ABI64 # define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY64_PATH" # endif -#endif + +/* Cygwin */ +#elif defined(__CYGWIN__) +# define KWSYS_SHARED_FORWARD_LDD "cygcheck" /* TODO: cygwin 1.7 has ldd */ +# define KWSYS_SHARED_FORWARD_LDD_N 1 +# define KWSYS_SHARED_FORWARD_LDPATH "PATH" /* Windows */ -#if defined(_WIN32) -# if defined(__CYGWIN__) -# define KWSYS_SHARED_FORWARD_LDD "cygcheck" -# define KWSYS_SHARED_FORWARD_LDD_N 1 -# endif +#elif defined(_WIN32) # define KWSYS_SHARED_FORWARD_LDPATH "PATH" -#endif /* Guess on this unknown system. */ -#if !defined(KWSYS_SHARED_FORWARD_LDPATH) +#else # define KWSYS_SHARED_FORWARD_LDD "ldd" # define KWSYS_SHARED_FORWARD_LDD_N 1 # define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH" diff --git a/Utilities/ITK/Utilities/kwsys/String.c b/Utilities/ITK/Utilities/kwsys/String.c index c0b2b9f83ce1673c2411a432c429a2d06bca24d4..ed4a6c52a8fd34793afa6843d7dbdf98a856407a 100644 --- a/Utilities/ITK/Utilities/kwsys/String.c +++ b/Utilities/ITK/Utilities/kwsys/String.c @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: String.c,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #ifdef KWSYS_STRING_C /* All code in this source file is conditionally compiled to work-around diff --git a/Utilities/ITK/Utilities/kwsys/String.h.in b/Utilities/ITK/Utilities/kwsys/String.h.in index 4bb9782d07490c2c7b8147cbd35347c792850a73..f5bab6e1a6815394d1dd1826bf21b458a82c788f 100644 --- a/Utilities/ITK/Utilities/kwsys/String.h.in +++ b/Utilities/ITK/Utilities/kwsys/String.h.in @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: String.h.in,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #ifndef @KWSYS_NAMESPACE@_String_h #define @KWSYS_NAMESPACE@_String_h diff --git a/Utilities/ITK/Utilities/kwsys/String.hxx.in b/Utilities/ITK/Utilities/kwsys/String.hxx.in index 164a2ae27486e7c06a939a34544c44120d54a60a..4386c9eb72893fc67122fb998eedd62ba3d30a4e 100644 --- a/Utilities/ITK/Utilities/kwsys/String.hxx.in +++ b/Utilities/ITK/Utilities/kwsys/String.hxx.in @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: String.hxx.in,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #ifndef @KWSYS_NAMESPACE@_String_hxx #define @KWSYS_NAMESPACE@_String_hxx @@ -27,7 +25,7 @@ namespace @KWSYS_NAMESPACE@ * simply a subclass of this type with the same interface so that the * name is shorter in debugging symbols and error messages. */ -class @KWSYS_NAMESPACE@_EXPORT String: public @KWSYS_NAMESPACE@_stl::string +class String: public @KWSYS_NAMESPACE@_stl::string { /** The original string type. */ typedef @KWSYS_NAMESPACE@_stl::string stl_string; diff --git a/Utilities/ITK/Utilities/kwsys/System.c b/Utilities/ITK/Utilities/kwsys/System.c index 9277d794b92f2357c0ccdc54d3988e5a67bc006f..5d178bfa27b98f562fd4e126849a0db5b451af63 100644 --- a/Utilities/ITK/Utilities/kwsys/System.c +++ b/Utilities/ITK/Utilities/kwsys/System.c @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: System.c,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #include "kwsysPrivate.h" #include KWSYS_HEADER(System.h) diff --git a/Utilities/ITK/Utilities/kwsys/System.h.in b/Utilities/ITK/Utilities/kwsys/System.h.in index 32111797aae4a084d3e432ec846a3fce8bc98ab4..549db900cc6590a84865c16b8d4f5f26916dd30c 100644 --- a/Utilities/ITK/Utilities/kwsys/System.h.in +++ b/Utilities/ITK/Utilities/kwsys/System.h.in @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: System.h.in,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #ifndef @KWSYS_NAMESPACE@_System_h #define @KWSYS_NAMESPACE@_System_h diff --git a/Utilities/ITK/Utilities/kwsys/SystemInformation.cxx b/Utilities/ITK/Utilities/kwsys/SystemInformation.cxx index 191250674dc994c466d1e095ab3fa7cfab77ee5e..936c1f71ba80f92912f97346848d4c7d698deafb 100644 --- a/Utilities/ITK/Utilities/kwsys/SystemInformation.cxx +++ b/Utilities/ITK/Utilities/kwsys/SystemInformation.cxx @@ -1,22 +1,30 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: BatchMake - Module: $RCSfile: SystemInformation.cxx,v $ - Language: C++ - Date: $Date: 2009-05-20 13:50:20 $ - Version: $Revision: 1.45 $ - Copyright (c) 2005 Insight Consortium. All rights reserved. - See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #ifdef _WIN32 # include <winsock.h> // WSADATA, include before sys/types.h #endif +// TODO: +// We need an alternative implementation for many functions in this file +// when USE_ASM_INSTRUCTIONS gets defined as 0. +// +// Consider using these on Win32/Win64 for some of them: +// +// IsProcessorFeaturePresent +// http://msdn.microsoft.com/en-us/library/ms724482(VS.85).aspx +// +// GetProcessMemoryInfo +// http://msdn.microsoft.com/en-us/library/ms683219(VS.85).aspx + #include "kwsysPrivate.h" #include KWSYS_HEADER(FundamentalType.h) #include KWSYS_HEADER(stl/string) @@ -26,6 +34,7 @@ #include KWSYS_HEADER(Process.h) #include KWSYS_HEADER(ios/iostream) #include KWSYS_HEADER(ios/sstream) + // Work-around CMake dependency scanning limitation. This must // duplicate the above list of headers. #if 0 @@ -40,7 +49,6 @@ # include "kwsys_ios_iostream.h.in" #endif - #ifndef WIN32 # include <sys/utsname.h> // int uname(struct utsname *buf); #endif @@ -80,7 +88,6 @@ #include <string.h> - namespace KWSYS_NAMESPACE { @@ -93,12 +100,13 @@ namespace KWSYS_NAMESPACE # error "No Long Long" #endif + // Define SystemInformationImplementation class typedef void (*DELAY_FUNC)(unsigned int uiMS); - -class SystemInformationImplementation -{ + +class SystemInformationImplementation +{ public: SystemInformationImplementation (); ~SystemInformationImplementation (); @@ -132,21 +140,22 @@ public: bool DoesCPUSupportCPUID(); // Retrieve memory information in megabyte. - unsigned long GetTotalVirtualMemory(); - unsigned long GetAvailableVirtualMemory(); - unsigned long GetTotalPhysicalMemory(); - unsigned long GetAvailablePhysicalMemory(); + size_t GetTotalVirtualMemory(); + size_t GetAvailableVirtualMemory(); + size_t GetTotalPhysicalMemory(); + size_t GetAvailablePhysicalMemory(); /** Run the different checks */ void RunCPUCheck(); void RunOSCheck(); void RunMemoryCheck(); + public: #define VENDOR_STRING_LENGTH (12 + 1) #define CHIPNAME_STRING_LENGTH (48 + 1) #define SERIALNUMBER_STRING_LENGTH (29 + 1) - typedef struct tagID + typedef struct tagID { int Type; int Family; @@ -159,14 +168,14 @@ public: char SerialNumber[SERIALNUMBER_STRING_LENGTH]; } ID; - typedef struct tagCPUPowerManagement + typedef struct tagCPUPowerManagement { bool HasVoltageID; bool HasFrequencyID; bool HasTempSenseDiode; } CPUPowerManagement; - typedef struct tagCPUExtendedFeatures + typedef struct tagCPUExtendedFeatures { bool Has3DNow; bool Has3DNowPlus; @@ -177,9 +186,9 @@ public: unsigned int LogicalProcessorsPerPhysical; int APIC_ID; CPUPowerManagement PowerManagement; - } CPUExtendedFeatures; - - typedef struct CPUtagFeatures + } CPUExtendedFeatures; + + typedef struct CPUtagFeatures { bool HasFPU; bool HasTSC; @@ -200,13 +209,14 @@ public: int L3CacheSize; CPUExtendedFeatures ExtendedFeatures; } CPUFeatures; - - enum Manufacturer + + enum Manufacturer { - AMD, Intel, NSC, UMC, Cyrix, NexGen, IDT, Rise, Transmeta, Sun, IBM, Motorola, UnknownManufacturer + AMD, Intel, NSC, UMC, Cyrix, NexGen, IDT, Rise, Transmeta, Sun, IBM, + Motorola, UnknownManufacturer }; -protected: +protected: // Functions. bool RetrieveCPUFeatures(); bool RetrieveCPUIdentity(); @@ -220,7 +230,7 @@ protected: bool RetrieveCPUPowerManagement(); bool RetrieveClassicalCPUIdentity(); bool RetrieveExtendedCPUIdentity(); - + Manufacturer ChipManufacturer; CPUFeatures Features; ID ChipID; @@ -246,6 +256,8 @@ protected: // For Mac bool ParseSysCtl(); + void CallSwVers(); + void TrimNewline(kwsys_stl::string&); kwsys_stl::string ExtractValueFromSysCtl(const char* word); kwsys_stl::string SysCtlBuffer; @@ -259,10 +271,10 @@ protected: // Evaluate the memory information. int QueryMemory(); - unsigned long TotalVirtualMemory; - unsigned long AvailableVirtualMemory; - unsigned long TotalPhysicalMemory; - unsigned long AvailablePhysicalMemory; + size_t TotalVirtualMemory; + size_t AvailableVirtualMemory; + size_t TotalPhysicalMemory; + size_t AvailablePhysicalMemory; size_t CurrentPositionInFile; @@ -274,17 +286,14 @@ protected: kwsys_stl::string OSVersion; kwsys_stl::string OSPlatform; }; - - - - + SystemInformation::SystemInformation() { this->Implementation = new SystemInformationImplementation; } -SystemInformation::~SystemInformation () +SystemInformation::~SystemInformation() { delete this->Implementation; } @@ -293,54 +302,67 @@ const char * SystemInformation::GetVendorString() { return this->Implementation->GetVendorString(); } + const char * SystemInformation::GetVendorID() { return this->Implementation->GetVendorID(); } + kwsys_stl::string SystemInformation::GetTypeID() { return this->Implementation->GetTypeID(); } + kwsys_stl::string SystemInformation::GetFamilyID() { return this->Implementation->GetFamilyID(); } + kwsys_stl::string SystemInformation::GetModelID() { return this->Implementation->GetModelID(); } + kwsys_stl::string SystemInformation::GetSteppingCode() { return this->Implementation->GetSteppingCode(); } + const char * SystemInformation::GetExtendedProcessorName() { return this->Implementation->GetExtendedProcessorName(); } + const char * SystemInformation::GetProcessorSerialNumber() { return this->Implementation->GetProcessorSerialNumber(); } + int SystemInformation::GetProcessorCacheSize() { return this->Implementation->GetProcessorCacheSize(); } + unsigned int SystemInformation::GetLogicalProcessorsPerPhysical() { return this->Implementation->GetLogicalProcessorsPerPhysical(); } + float SystemInformation::GetProcessorClockFrequency() { return this->Implementation->GetProcessorClockFrequency(); } + int SystemInformation::GetProcessorAPICID() { return this->Implementation->GetProcessorAPICID(); } + int SystemInformation::GetProcessorCacheXSize(long int l) { return this->Implementation->GetProcessorCacheXSize(l); } + bool SystemInformation::DoesCPUSupportFeature(long int i) { return this->Implementation->DoesCPUSupportFeature(i); @@ -350,18 +372,22 @@ const char * SystemInformation::GetOSName() { return this->Implementation->GetOSName(); } + const char * SystemInformation::GetHostname() { return this->Implementation->GetHostname(); } + const char * SystemInformation::GetOSRelease() { return this->Implementation->GetOSRelease(); } + const char * SystemInformation::GetOSVersion() { return this->Implementation->GetOSVersion(); } + const char * SystemInformation::GetOSPlatform() { return this->Implementation->GetOSPlatform(); @@ -376,6 +402,7 @@ unsigned int SystemInformation::GetNumberOfLogicalCPU() // per physical cpu { return this->Implementation->GetNumberOfLogicalCPU(); } + unsigned int SystemInformation::GetNumberOfPhysicalCPU() { return this->Implementation->GetNumberOfPhysicalCPU(); @@ -387,20 +414,22 @@ bool SystemInformation::DoesCPUSupportCPUID() } // Retrieve memory information in megabyte. -unsigned long SystemInformation::GetTotalVirtualMemory() +size_t SystemInformation::GetTotalVirtualMemory() { return this->Implementation->GetTotalVirtualMemory(); } -unsigned long SystemInformation::GetAvailableVirtualMemory() + +size_t SystemInformation::GetAvailableVirtualMemory() { return this->Implementation->GetAvailableVirtualMemory(); } -unsigned long SystemInformation::GetTotalPhysicalMemory() + +size_t SystemInformation::GetTotalPhysicalMemory() { return this->Implementation->GetTotalPhysicalMemory(); } -unsigned long SystemInformation::GetAvailablePhysicalMemory() +size_t SystemInformation::GetAvailablePhysicalMemory() { return this->Implementation->GetAvailablePhysicalMemory(); } @@ -410,17 +439,18 @@ void SystemInformation::RunCPUCheck() { this->Implementation->RunCPUCheck(); } + void SystemInformation::RunOSCheck() { this->Implementation->RunOSCheck(); } + void SystemInformation::RunMemoryCheck() { this->Implementation->RunMemoryCheck(); } - // -------------------------------------------------------------- // SystemInformationImplementation starts here @@ -442,29 +472,29 @@ void SystemInformation::RunMemoryCheck() #define CPUID_INSTRUCTION _asm _emit 0x0f _asm _emit 0xa2 #endif -#define MMX_FEATURE 0x00000001 -#define MMX_PLUS_FEATURE 0x00000002 -#define SSE_FEATURE 0x00000004 -#define SSE2_FEATURE 0x00000008 +#define MMX_FEATURE 0x00000001 +#define MMX_PLUS_FEATURE 0x00000002 +#define SSE_FEATURE 0x00000004 +#define SSE2_FEATURE 0x00000008 #define AMD_3DNOW_FEATURE 0x00000010 -#define AMD_3DNOW_PLUS_FEATURE 0x00000020 -#define IA64_FEATURE 0x00000040 -#define MP_CAPABLE 0x00000080 -#define HYPERTHREAD_FEATURE 0x00000100 -#define SERIALNUMBER_FEATURE 0x00000200 -#define APIC_FEATURE 0x00000400 -#define SSE_FP_FEATURE 0x00000800 +#define AMD_3DNOW_PLUS_FEATURE 0x00000020 +#define IA64_FEATURE 0x00000040 +#define MP_CAPABLE 0x00000080 +#define HYPERTHREAD_FEATURE 0x00000100 +#define SERIALNUMBER_FEATURE 0x00000200 +#define APIC_FEATURE 0x00000400 +#define SSE_FP_FEATURE 0x00000800 #define SSE_MMX_FEATURE 0x00001000 -#define CMOV_FEATURE 0x00002000 -#define MTRR_FEATURE 0x00004000 +#define CMOV_FEATURE 0x00002000 +#define MTRR_FEATURE 0x00004000 #define L1CACHE_FEATURE 0x00008000 #define L2CACHE_FEATURE 0x00010000 #define L3CACHE_FEATURE 0x00020000 -#define ACPI_FEATURE 0x00040000 -#define THERMALMONITOR_FEATURE 0x00080000 -#define TEMPSENSEDIODE_FEATURE 0x00100000 -#define FREQUENCYID_FEATURE 0x00200000 -#define VOLTAGEID_FREQUENCY 0x00400000 +#define ACPI_FEATURE 0x00040000 +#define THERMALMONITOR_FEATURE 0x00080000 +#define TEMPSENSEDIODE_FEATURE 0x00100000 +#define FREQUENCYID_FEATURE 0x00200000 +#define VOLTAGEID_FREQUENCY 0x00400000 // Status Flag #define HT_NOT_CAPABLE 0 @@ -491,7 +521,6 @@ void SystemInformation::RunMemoryCheck() // Default value = 0xff if HT is not supported - SystemInformationImplementation::SystemInformationImplementation() { this->TotalVirtualMemory = 0; @@ -520,32 +549,48 @@ void SystemInformationImplementation::RunCPUCheck() { #ifdef WIN32 // Check to see if this processor supports CPUID. - if (DoesCPUSupportCPUID()) + bool supportsCPUID = DoesCPUSupportCPUID(); + + if (supportsCPUID) { // Retrieve the CPU details. RetrieveCPUIdentity(); RetrieveCPUFeatures(); - if (!RetrieveCPUClockSpeed()) - { - RetrieveClassicalCPUClockSpeed(); - } + } - // Attempt to retrieve cache information. + // These two may be called without support for the CPUID instruction. + // (But if the instruction is there, they should be called *after* + // the above call to RetrieveCPUIdentity... that's why the two if + // blocks exist with the same "if (supportsCPUID)" logic... + // + if (!RetrieveCPUClockSpeed()) + { + RetrieveClassicalCPUClockSpeed(); + } + + if (supportsCPUID) + { + // Retrieve cache information. if (!RetrieveCPUCacheDetails()) { RetrieveClassicalCPUCacheDetails(); } + // Retrieve the extended CPU details. if (!RetrieveExtendedCPUIdentity()) { RetrieveClassicalCPUIdentity(); } + RetrieveExtendedCPUFeatures(); + RetrieveCPUPowerManagement(); // Now attempt to retrieve the serial number (if possible). RetrieveProcessorSerialNumber(); } + this->CPUCount(); + #elif defined(__APPLE__) this->ParseSysCtl(); #elif defined (__SVR4) && defined (__sun) @@ -561,7 +606,7 @@ void SystemInformationImplementation::RunOSCheck() { this->QueryOSInformation(); } - + void SystemInformationImplementation::RunMemoryCheck() { #if defined(__APPLE__) @@ -615,7 +660,7 @@ const char* SystemInformationImplementation::GetOSPlatform() const char * SystemInformationImplementation::GetVendorID() { // Return the vendor ID. - switch (this->ChipManufacturer) + switch (this->ChipManufacturer) { case Intel: return "Intel Corporation"; @@ -718,7 +763,7 @@ int SystemInformationImplementation::GetProcessorCacheSize() /** Return the chosen cache size. */ int SystemInformationImplementation::GetProcessorCacheXSize(long int dwCacheID) { - switch (dwCacheID) + switch (dwCacheID) { case L1CACHE_FEATURE: return this->Features.L1CacheSize; @@ -730,6 +775,7 @@ int SystemInformationImplementation::GetProcessorCacheXSize(long int dwCacheID) return -1; } + bool SystemInformationImplementation::DoesCPUSupportFeature(long int dwFeature) { bool bHasFeature = false; @@ -803,6 +849,7 @@ bool SystemInformationImplementation::DoesCPUSupportFeature(long int dwFeature) return bHasFeature; } + void SystemInformationImplementation::Delay(unsigned int uiMS) { #ifdef WIN32 @@ -824,6 +871,7 @@ void SystemInformationImplementation::Delay(unsigned int uiMS) (void)uiMS; } + bool SystemInformationImplementation::DoesCPUSupportCPUID() { #if USE_ASM_INSTRUCTIONS @@ -859,19 +907,20 @@ bool SystemInformationImplementation::DoesCPUSupportCPUID() // The cpuid instruction succeeded. return true; + #else // Assume no cpuid instruction. return false; #endif } + bool SystemInformationImplementation::RetrieveCPUFeatures() { #if USE_ASM_INSTRUCTIONS int localCPUFeatures = 0; int localCPUAdvanced = 0; - // Use assembly to detect CPUID information... __try { _asm { @@ -907,17 +956,17 @@ bool SystemInformationImplementation::RetrieveCPUFeatures() } // Retrieve the features of CPU present. - this->Features.HasFPU = ((localCPUFeatures & 0x00000001) != 0); // FPU Present --> Bit 0 - this->Features.HasTSC = ((localCPUFeatures & 0x00000010) != 0); // TSC Present --> Bit 4 + this->Features.HasFPU = ((localCPUFeatures & 0x00000001) != 0); // FPU Present --> Bit 0 + this->Features.HasTSC = ((localCPUFeatures & 0x00000010) != 0); // TSC Present --> Bit 4 this->Features.HasAPIC = ((localCPUFeatures & 0x00000200) != 0); // APIC Present --> Bit 9 this->Features.HasMTRR = ((localCPUFeatures & 0x00001000) != 0); // MTRR Present --> Bit 12 this->Features.HasCMOV = ((localCPUFeatures & 0x00008000) != 0); // CMOV Present --> Bit 15 this->Features.HasSerial = ((localCPUFeatures & 0x00040000) != 0); // Serial Present --> Bit 18 this->Features.HasACPI = ((localCPUFeatures & 0x00400000) != 0); // ACPI Capable --> Bit 22 - this->Features.HasMMX = ((localCPUFeatures & 0x00800000) != 0); // MMX Present --> Bit 23 - this->Features.HasSSE = ((localCPUFeatures & 0x02000000) != 0); // SSE Present --> Bit 25 + this->Features.HasMMX = ((localCPUFeatures & 0x00800000) != 0); // MMX Present --> Bit 23 + this->Features.HasSSE = ((localCPUFeatures & 0x02000000) != 0); // SSE Present --> Bit 25 this->Features.HasSSE2 = ((localCPUFeatures & 0x04000000) != 0); // SSE2 Present --> Bit 26 - this->Features.HasThermal = ((localCPUFeatures & 0x20000000) != 0); // Thermal Monitor Present --> Bit 29 + this->Features.HasThermal = ((localCPUFeatures & 0x20000000) != 0); // Thermal Monitor Present --> Bit 29 this->Features.HasIA64 = ((localCPUFeatures & 0x40000000) != 0); // IA64 Present --> Bit 30 // Retrieve extended SSE capabilities if SSE is available. @@ -961,15 +1010,19 @@ bool SystemInformationImplementation::RetrieveCPUFeatures() this->Features.ExtendedFeatures.APIC_ID = ((localCPUAdvanced & 0xFF000000) >> 24); } } -#endif + return true; + +#else + return false; +#endif } /** Find the manufacturer given the vendor id */ void SystemInformationImplementation::FindManufacturer() { - if (strcmp (this->ChipID.Vendor, "GenuineIntel") == 0) this->ChipManufacturer = Intel; // Intel Corp. + if (strcmp (this->ChipID.Vendor, "GenuineIntel") == 0) this->ChipManufacturer = Intel; // Intel Corp. else if (strcmp (this->ChipID.Vendor, "UMC UMC UMC ") == 0) this->ChipManufacturer = UMC; // United Microelectronics Corp. else if (strcmp (this->ChipID.Vendor, "AuthenticAMD") == 0) this->ChipManufacturer = AMD; // Advanced Micro Devices else if (strcmp (this->ChipID.Vendor, "AMD ISBETTER") == 0) this->ChipManufacturer = AMD; // Advanced Micro Devices (1994) @@ -983,9 +1036,10 @@ void SystemInformationImplementation::FindManufacturer() else if (strcmp (this->ChipID.Vendor, "Sun") == 0) this->ChipManufacturer = Sun; // Sun Microelectronics else if (strcmp (this->ChipID.Vendor, "IBM") == 0) this->ChipManufacturer = IBM; // IBM Microelectronics else if (strcmp (this->ChipID.Vendor, "Motorola") == 0) this->ChipManufacturer = Motorola; // Motorola Microelectronics - else this->ChipManufacturer = UnknownManufacturer; // Unknown manufacturer + else this->ChipManufacturer = UnknownManufacturer; // Unknown manufacturer } + /** */ bool SystemInformationImplementation::RetrieveCPUIdentity() { @@ -1054,11 +1108,15 @@ bool SystemInformationImplementation::RetrieveCPUIdentity() this->ChipID.Family = ((localCPUSignature & 0x00000F00) >> 8); // Bits 11..8 Used this->ChipID.Model = ((localCPUSignature & 0x000000F0) >> 4); // Bits 7..4 Used this->ChipID.Revision = ((localCPUSignature & 0x0000000F) >> 0); // Bits 3..0 Used -#endif return true; + +#else + return false; +#endif } + /** */ bool SystemInformationImplementation::RetrieveCPUCacheDetails() { @@ -1176,6 +1234,7 @@ bool SystemInformationImplementation::RetrieveCPUCacheDetails() return ((this->Features.L1CacheSize == -1) && (this->Features.L2CacheSize == -1)) ? false : true; } + /** */ bool SystemInformationImplementation::RetrieveClassicalCPUCacheDetails() { @@ -1372,18 +1431,51 @@ bool SystemInformationImplementation::RetrieveClassicalCPUCacheDetails() this->Features.L3CacheSize = L3Unified; } -#endif return true; + +#else + return false; +#endif } + /** */ bool SystemInformationImplementation::RetrieveCPUClockSpeed() { + bool retrieved = false; + #if _WIN32 - // First of all we check to see if the RDTSC (0x0F, 0x31) instruction is supported. - if (!this->Features.HasTSC) + // First of all we check to see if the RDTSC (0x0F, 0x31) instruction is + // supported. If not, we fallback to trying to read this value from the + // registry: + // + if (!this->Features.HasTSC) { - return false; + HKEY hKey = NULL; + LONG err = RegOpenKeyEx(HKEY_LOCAL_MACHINE, + "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", 0, + KEY_READ, &hKey); + + if (ERROR_SUCCESS == err) + { + DWORD dwType = 0; + DWORD data = 0; + DWORD dwSize = sizeof(DWORD); + + err = RegQueryValueEx(hKey, "~MHz", 0, + &dwType, (LPBYTE) &data, &dwSize); + + if (ERROR_SUCCESS == err) + { + this->CPUSpeedInMHz = (float) data; + retrieved = true; + } + + RegCloseKey(hKey); + hKey = NULL; + } + + return retrieved; } unsigned int uiRepetitions = 1; @@ -1391,7 +1483,7 @@ bool SystemInformationImplementation::RetrieveCPUClockSpeed() __int64 i64Total = 0; __int64 i64Overhead = 0; - for (unsigned int nCounter = 0; nCounter < uiRepetitions; nCounter ++) + for (unsigned int nCounter = 0; nCounter < uiRepetitions; nCounter ++) { i64Total += GetCyclesDifference (SystemInformationImplementation::Delay, uiMSecPerRepetition); @@ -1409,12 +1501,13 @@ bool SystemInformationImplementation::RetrieveCPUClockSpeed() // Save the CPU speed. this->CPUSpeedInMHz = (float) i64Total; - return true; -#else - return false; + retrieved = true; #endif + + return retrieved; } + /** */ bool SystemInformationImplementation::RetrieveClassicalCPUClockSpeed() { @@ -1468,11 +1561,15 @@ bool SystemInformationImplementation::RetrieveClassicalCPUClockSpeed() // Save the clock speed. this->Features.CPUSpeed = (int) dFrequency; -#else + return true; + +#else + return false; #endif } + /** */ bool SystemInformationImplementation::RetrieveCPUExtendedLevelSupport(int CPULevelToCheck) { @@ -1518,7 +1615,7 @@ bool SystemInformationImplementation::RetrieveCPUExtendedLevelSupport(int CPULev return false; } } - + #if USE_ASM_INSTRUCTIONS // Use assembly to detect CPUID information... @@ -1566,6 +1663,7 @@ bool SystemInformationImplementation::RetrieveCPUExtendedLevelSupport(int CPULev return true; } + /** */ bool SystemInformationImplementation::RetrieveExtendedCPUFeatures() { @@ -1581,6 +1679,7 @@ bool SystemInformationImplementation::RetrieveExtendedCPUFeatures() { return false; } + #if USE_ASM_INSTRUCTIONS int localCPUExtendedFeatures = 0; @@ -1636,11 +1735,15 @@ bool SystemInformationImplementation::RetrieveExtendedCPUFeatures() { this->Features.ExtendedFeatures.HasMMXPlus = ((localCPUExtendedFeatures & 0x01000000) != 0); // Cyrix specific: Extended MMX --> Bit 24 } -#endif return true; + +#else + return false; +#endif } + /** */ bool SystemInformationImplementation::RetrieveProcessorSerialNumber() { @@ -1653,7 +1756,6 @@ bool SystemInformationImplementation::RetrieveProcessorSerialNumber() #if USE_ASM_INSTRUCTIONS int SerialNumber[3]; - // Use assembly to detect CPUID information... __try { _asm { @@ -1703,14 +1805,18 @@ bool SystemInformationImplementation::RetrieveProcessorSerialNumber() ((SerialNumber[2] & 0x00ff0000) >> 16), ((SerialNumber[2] & 0x0000ff00) >> 8), ((SerialNumber[2] & 0x000000ff) >> 0)); -#endif return true; + +#else + return false; +#endif } + /** */ bool SystemInformationImplementation::RetrieveCPUPowerManagement() -{ +{ // Check to see if what we are about to do is supported... if (!RetrieveCPUExtendedLevelSupport(static_cast<int>(0x80000007))) { @@ -1760,11 +1866,14 @@ bool SystemInformationImplementation::RetrieveCPUPowerManagement() this->Features.ExtendedFeatures.PowerManagement.HasFrequencyID = ((localCPUPowerManagement & 0x00000002) != 0); this->Features.ExtendedFeatures.PowerManagement.HasVoltageID = ((localCPUPowerManagement & 0x00000004) != 0); -#endif - return true; + +#else + return false; +#endif } + /** */ bool SystemInformationImplementation::RetrieveExtendedCPUIdentity() { @@ -1775,7 +1884,7 @@ bool SystemInformationImplementation::RetrieveExtendedCPUIdentity() return false; if (!RetrieveCPUExtendedLevelSupport(static_cast<int>(0x80000004))) return false; - + #if USE_ASM_INSTRUCTIONS int ProcessorNameStartPos = 0; int CPUExtendedIdentity[12]; @@ -1871,11 +1980,15 @@ bool SystemInformationImplementation::RetrieveExtendedCPUIdentity() // Now move the name forward so that there is no white space. memmove(this->ChipID.ProcessorName, &(this->ChipID.ProcessorName[ProcessorNameStartPos]), (CHIPNAME_STRING_LENGTH - ProcessorNameStartPos)); } -#endif return true; + +#else + return false; +#endif } + /** */ bool SystemInformationImplementation::RetrieveClassicalCPUIdentity() { @@ -2152,6 +2265,7 @@ bool SystemInformationImplementation::RetrieveClassicalCPUIdentity() return true; } + /** Extract a value from the CPUInfo file */ kwsys_stl::string SystemInformationImplementation::ExtractValueFromCpuInfoFile(kwsys_stl::string buffer,const char* word,size_t init) { @@ -2281,17 +2395,24 @@ int SystemInformationImplementation::QueryMemory() #elif _WIN32 #if _MSC_VER < 1300 MEMORYSTATUS ms; + unsigned long tv, tp, av, ap; + ms.dwLength = sizeof(ms); GlobalMemoryStatus(&ms); -#define MEM_VAL(value) dw##value + #define MEM_VAL(value) dw##value #else MEMORYSTATUSEX ms; - GlobalMemoryStatusEx(&ms); + DWORDLONG tv, tp, av, ap; + ms.dwLength = sizeof(ms); + if (0 == GlobalMemoryStatusEx(&ms)) + { + return 0; + } #define MEM_VAL(value) ull##value #endif - unsigned long tv = ms.MEM_VAL(TotalVirtual); - unsigned long tp = ms.MEM_VAL(TotalPhys); - unsigned long av = ms.MEM_VAL(AvailVirtual); - unsigned long ap = ms.MEM_VAL(AvailPhys); + tv = ms.MEM_VAL(TotalVirtual); + tp = ms.MEM_VAL(TotalPhys); + av = ms.MEM_VAL(AvailVirtual); + ap = ms.MEM_VAL(AvailPhys); this->TotalVirtualMemory = tv>>10>>10; this->TotalPhysicalMemory = tp>>10>>10; this->AvailableVirtualMemory = av>>10>>10; @@ -2448,24 +2569,24 @@ int SystemInformationImplementation::QueryMemory() } /** */ -unsigned long SystemInformationImplementation::GetTotalVirtualMemory() +size_t SystemInformationImplementation::GetTotalVirtualMemory() { return this->TotalVirtualMemory; } /** */ -unsigned long SystemInformationImplementation::GetAvailableVirtualMemory() +size_t SystemInformationImplementation::GetAvailableVirtualMemory() { return this->AvailableVirtualMemory; } -unsigned long SystemInformationImplementation::GetTotalPhysicalMemory() +size_t SystemInformationImplementation::GetTotalPhysicalMemory() { return this->TotalPhysicalMemory; } /** */ -unsigned long SystemInformationImplementation::GetAvailablePhysicalMemory() +size_t SystemInformationImplementation::GetAvailablePhysicalMemory() { return this->AvailablePhysicalMemory; } @@ -2517,6 +2638,7 @@ LongLong SystemInformationImplementation::GetCyclesDifference (DELAY_FUNC DelayF #endif } + /** Compute the delay overhead */ void SystemInformationImplementation::DelayOverhead(unsigned int uiMS) { @@ -2546,6 +2668,7 @@ void SystemInformationImplementation::DelayOverhead(unsigned int uiMS) unsigned char SystemInformationImplementation::LogicalCPUPerPhysicalCPU(void) { unsigned int Regebx = 0; + #if USE_ASM_INSTRUCTIONS if (!this->IsHyperThreadingSupported()) { @@ -2572,9 +2695,11 @@ unsigned char SystemInformationImplementation::LogicalCPUPerPhysicalCPU(void) return static_cast<unsigned char>(cores_per_package); } #endif + return static_cast<unsigned char> ((Regebx & NUM_LOGICAL_BITS) >> 16); } + /** Works only for windows */ unsigned int SystemInformationImplementation::IsHyperThreadingSupported() { @@ -2621,10 +2746,12 @@ unsigned int SystemInformationImplementation::IsHyperThreadingSupported() return 0; // Not genuine Intel processor } + /** Return the APIC Id. Works only for windows. */ unsigned char SystemInformationImplementation::GetAPICId() { unsigned int Regebx = 0; + #if USE_ASM_INSTRUCTIONS if (!this->IsHyperThreadingSupported()) { @@ -2637,9 +2764,11 @@ unsigned char SystemInformationImplementation::GetAPICId() mov Regebx, ebx } #endif + return static_cast<unsigned char>((Regebx & INITIAL_APIC_ID_BITS) >> 24); } + /** Count the number of CPUs. Works only on windows. */ int SystemInformationImplementation::CPUCount() { @@ -2753,18 +2882,21 @@ int SystemInformationImplementation::CPUCount() #endif } + /** Return the number of logical CPUs on the system */ unsigned int SystemInformationImplementation::GetNumberOfLogicalCPU() { return this->NumberOfLogicalCPU; } + /** Return the number of physical CPUs on the system */ unsigned int SystemInformationImplementation::GetNumberOfPhysicalCPU() { return this->NumberOfPhysicalCPU; } + /** For Mac use sysctlbyname calls to find system info */ bool SystemInformationImplementation::ParseSysCtl() { @@ -2773,7 +2905,7 @@ bool SystemInformationImplementation::ParseSysCtl() uint64_t value = 0; size_t len = sizeof(value); sysctlbyname("hw.memsize", &value, &len, NULL, 0); - this->TotalPhysicalMemory = value/1048576; + this->TotalPhysicalMemory = static_cast< size_t >( value/1048576 ); // Parse values for Mac this->AvailablePhysicalMemory = 0; @@ -2784,7 +2916,7 @@ bool SystemInformationImplementation::ParseSysCtl() { err = sysctlbyname("hw.pagesize", &value, &len, NULL, 0); int64_t available_memory = vmstat.free_count * value; - this->AvailablePhysicalMemory = available_memory / 1048576; + this->AvailablePhysicalMemory = static_cast< size_t >( available_memory / 1048576 ); } #ifdef VM_SWAPUSAGE @@ -2796,8 +2928,8 @@ bool SystemInformationImplementation::ParseSysCtl() err = sysctl(mib, miblen, &swap, &len, NULL, 0); if (err == 0) { - this->AvailableVirtualMemory = swap.xsu_avail/1048576; - this->TotalVirtualMemory = swap.xsu_total/1048576; + this->AvailableVirtualMemory = static_cast< size_t >( swap.xsu_avail/1048576 ); + this->TotalVirtualMemory = static_cast< size_t >( swap.xsu_total/1048576 ); } #else this->AvailableVirtualMemory = 0; @@ -2813,7 +2945,7 @@ bool SystemInformationImplementation::ParseSysCtl() len = sizeof(value); sysctlbyname("hw.cpufrequency", &value, &len, NULL, 0); - this->CPUSpeedInMHz = value / 1048576; + this->CPUSpeedInMHz = static_cast< float >( value )/ 1048576; // Chip family @@ -2861,14 +2993,14 @@ bool SystemInformationImplementation::ParseSysCtl() // Chip Model len = sizeof(value); err = sysctlbyname("machdep.cpu.model", &value, &len, NULL, 0); - this->ChipID.Model = value; + this->ChipID.Model = static_cast< int >( value ); } // Cache size len = sizeof(value); err = sysctlbyname("hw.l1icachesize", &value, &len, NULL, 0); - this->Features.L1CacheSize = value; + this->Features.L1CacheSize = static_cast< int >( value ); err = sysctlbyname("hw.l2cachesize", &value, &len, NULL, 0); - this->Features.L2CacheSize = value; + this->Features.L2CacheSize = static_cast< int >( value ); return true; #else @@ -2876,6 +3008,7 @@ bool SystemInformationImplementation::ParseSysCtl() #endif } + /** Extract a value from sysctl command */ kwsys_stl::string SystemInformationImplementation::ExtractValueFromSysCtl(const char* word) { @@ -2892,6 +3025,7 @@ kwsys_stl::string SystemInformationImplementation::ExtractValueFromSysCtl(const return ""; } + /** Run a given process */ kwsys_stl::string SystemInformationImplementation::RunProcess(kwsys_stl::vector<const char*> args) { @@ -2952,7 +3086,7 @@ kwsys_stl::string SystemInformationImplementation::RunProcess(kwsys_stl::vector< } return buffer; } - + kwsys_stl::string SystemInformationImplementation::ParseValueFromKStat(const char* arguments) { @@ -3010,17 +3144,18 @@ kwsys_stl::string SystemInformationImplementation::ParseValueFromKStat(const cha if(buffer[i] == ' ' || buffer[i] == '\t') { break; - } + } if(buffer[i] != '\n' && buffer[i] != '\r') { kwsys_stl::string val = value; value = buffer[i]; value += val; - } + } } return value; } + /** Querying for system information from Solaris */ bool SystemInformationImplementation::QuerySolarisInfo() { @@ -3066,6 +3201,7 @@ bool SystemInformationImplementation::QuerySolarisInfo() return true; } + /** Querying for system information from Haiku OS */ bool SystemInformationImplementation::QueryHaikuInfo() { @@ -3131,10 +3267,14 @@ bool SystemInformationImplementation::QueryHaikuInfo() this->Features.L1CacheSize = 0; this->Features.L2CacheSize = 0; -#endif return true; + +#else + return false; +#endif } + /** Query the operating system information */ bool SystemInformationImplementation::QueryOSInformation() { @@ -3360,6 +3500,12 @@ bool SystemInformationImplementation::QueryOSInformation() WSACleanup( ); } this->Hostname = name; + + const char* arch = getenv("PROCESSOR_ARCHITECTURE"); + if(arch) + { + this->OSPlatform = arch; + } #else @@ -3373,16 +3519,74 @@ bool SystemInformationImplementation::QueryOSInformation() this->OSVersion = unameInfo.version; this->OSPlatform = unameInfo.machine; } + +#ifdef __APPLE__ + this->CallSwVers(); +#endif + #endif return true; } + +void SystemInformationImplementation::CallSwVers() +{ +#ifdef __APPLE__ + kwsys_stl::string output; + kwsys_stl::vector<const char*> args; + args.clear(); + + args.push_back("sw_vers"); + args.push_back("-productName"); + args.push_back(0); + output = this->RunProcess(args); + this->TrimNewline(output); + this->OSName = output; + args.clear(); + + args.push_back("sw_vers"); + args.push_back("-productVersion"); + args.push_back(0); + output = this->RunProcess(args); + this->TrimNewline(output); + this->OSRelease = output; + args.clear(); + + args.push_back("sw_vers"); + args.push_back("-buildVersion"); + args.push_back(0); + output = this->RunProcess(args); + this->TrimNewline(output); + this->OSVersion = output; +#endif +} + + +void SystemInformationImplementation::TrimNewline(kwsys_stl::string& output) +{ + // remove \r + kwsys_stl::string::size_type pos=0; + while((pos = output.find("\r", pos)) != kwsys_stl::string::npos) + { + output.erase(pos); + } + + // remove \n + pos = 0; + while((pos = output.find("\n", pos)) != kwsys_stl::string::npos) + { + output.erase(pos); + } +} + + /** Return true if the machine is 64 bits */ bool SystemInformationImplementation::Is64Bits() { return (sizeof(void*) == 8); } + } // namespace @KWSYS_NAMESPACE@ diff --git a/Utilities/ITK/Utilities/kwsys/SystemInformation.hxx.in b/Utilities/ITK/Utilities/kwsys/SystemInformation.hxx.in index b56a01f0e25424188ab791fa8e5e898432dbd55a..b6ebe6aee50b25e80cea1199580b8e6d9a7dc993 100644 --- a/Utilities/ITK/Utilities/kwsys/SystemInformation.hxx.in +++ b/Utilities/ITK/Utilities/kwsys/SystemInformation.hxx.in @@ -1,18 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: SystemInformation.hxx.in,v $ - Language: C++ - Date: $Date: 2009-03-20 02:48:05 $ - Version: $Revision: 1.9 $ - Copyright (c) 2005 Insight Consortium. All rights reserved. - See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #ifndef @KWSYS_NAMESPACE@_SystemInformation_h #define @KWSYS_NAMESPACE@_SystemInformation_h @@ -23,6 +19,7 @@ # define kwsys_ios @KWSYS_NAMESPACE@_ios #endif #include <@KWSYS_NAMESPACE@/stl/string> +#include <stddef.h> /* size_t */ namespace @KWSYS_NAMESPACE@ { @@ -67,10 +64,10 @@ public: bool DoesCPUSupportCPUID(); // Retrieve memory information in megabyte. - unsigned long GetTotalVirtualMemory(); - unsigned long GetAvailableVirtualMemory(); - unsigned long GetTotalPhysicalMemory(); - unsigned long GetAvailablePhysicalMemory(); + size_t GetTotalVirtualMemory(); + size_t GetAvailableVirtualMemory(); + size_t GetTotalPhysicalMemory(); + size_t GetAvailablePhysicalMemory(); /** Run the different checks */ void RunCPUCheck(); diff --git a/Utilities/ITK/Utilities/kwsys/SystemTools.cxx b/Utilities/ITK/Utilities/kwsys/SystemTools.cxx index 848446abe9ddaf6e45c991122ef2388ee357feb4..9ab0fdf105fb6a384772a2851dba902a2782edf5 100644 --- a/Utilities/ITK/Utilities/kwsys/SystemTools.cxx +++ b/Utilities/ITK/Utilities/kwsys/SystemTools.cxx @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: SystemTools.cxx,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #include "kwsysPrivate.h" #include KWSYS_HEADER(RegularExpression.hxx) #include KWSYS_HEADER(SystemTools.hxx) @@ -64,9 +62,16 @@ #include <signal.h> /* sigprocmask */ #endif -// Windows API. Some parts used even on cygwin. +// Windows API. #if defined(_WIN32) # include <windows.h> +#elif defined (__CYGWIN__) +# include <windows.h> +# undef _WIN32 +#endif + +#ifdef __CYGWIN__ +extern "C" void cygwin_conv_to_win32_path(const char *path, char *win32_path); #endif // getpwnam doesn't exist on Windows and Cray Xt3/Catamount @@ -282,7 +287,7 @@ extern int putenv (char *__string) __THROW; # define FTIME _ftime # define TIMEB _timeb # endif -#elif defined( __CYGWIN__ ) || defined( __linux__ ) +#elif defined( __CYGWIN__ ) || defined( __linux__ ) || defined(__APPLE__) # include <sys/time.h> # include <time.h> # define HAVE_GETTIMEOFDAY @@ -410,11 +415,13 @@ public: kwsysDeletingCharVector::~kwsysDeletingCharVector() { +#ifndef KWSYS_DO_NOT_CLEAN_PUTENV for(kwsys_stl::vector<char*>::iterator i = this->begin(); i != this->end(); ++i) { delete []*i; } +#endif } bool SystemTools::PutEnv(const char* value) { @@ -892,39 +899,69 @@ bool SystemTools::SameFile(const char* file1, const char* file2) #endif } - -// return true if the file exists -bool SystemTools::FileExists(const char* filename, bool isFile) +//---------------------------------------------------------------------------- +#if defined(_WIN32) || defined(__CYGWIN__) +static bool WindowsFileExists(const char* filename) { -#ifdef _MSC_VER -# define access _access -#endif -#ifndef R_OK -# define R_OK 04 + WIN32_FILE_ATTRIBUTE_DATA fd; + return GetFileAttributesExA(filename, GetFileExInfoStandard, &fd) != 0; +} #endif -#ifdef __SYLLABLE__ - if ((filename !=0) && (*filename == 0)) +//---------------------------------------------------------------------------- +bool SystemTools::FileExists(const char* filename) +{ + if(!(filename && *filename)) { return false; - } + } +#if defined(__CYGWIN__) + // Convert filename to native windows path if possible. + char winpath[MAX_PATH]; + if(SystemTools::PathCygwinToWin32(filename, winpath)) + { + return WindowsFileExists(winpath); + } + return access(filename, R_OK) == 0; +#elif defined(_WIN32) + return WindowsFileExists(filename); +#else + return access(filename, R_OK) == 0; #endif +} - if ( access(filename, R_OK) != 0 ) +//---------------------------------------------------------------------------- +bool SystemTools::FileExists(const char* filename, bool isFile) +{ + if(SystemTools::FileExists(filename)) { - return false; + // If isFile is set return not FileIsDirectory, + // so this will only be true if it is a file + return !isFile || !SystemTools::FileIsDirectory(filename); + } + return false; +} + +//---------------------------------------------------------------------------- +#ifdef __CYGWIN__ +bool SystemTools::PathCygwinToWin32(const char *path, char *win32_path) +{ + SystemToolsTranslationMap::iterator i = + SystemTools::Cyg2Win32Map->find(path); + + if (i != SystemTools::Cyg2Win32Map->end()) + { + strncpy(win32_path, i->second.c_str(), MAX_PATH); } else { - // If isFile is set return not FileIsDirectory, - // so this will only be true if it is a file - if(isFile) - { - return !SystemTools::FileIsDirectory(filename); - } - return true; + cygwin_conv_to_win32_path(path, win32_path); + SystemToolsTranslationMap::value_type entry(path, win32_path); + SystemTools::Cyg2Win32Map->insert(entry); } + return win32_path[0] != 0; } +#endif bool SystemTools::Touch(const char* filename, bool create) { @@ -2577,7 +2614,7 @@ bool SystemTools::FileIsDirectory(const char* name) struct stat fs; if(stat(name, &fs) == 0) { -#if defined( _WIN32 ) +#if defined( _WIN32 ) && !defined(__CYGWIN__) return ((fs.st_mode & _S_IFDIR) != 0); #else return S_ISDIR(fs.st_mode); @@ -3028,38 +3065,35 @@ kwsys_stl::string SystemTools::RelativePath(const char* local, const char* remot return relativePath; } -// OK, some fun stuff to get the actual case of a given path. -// Basically, you just need to call ShortPath, then GetLongPathName, -// However, GetLongPathName is not implemented on windows NT and 95, -// so we have to simulate it on those versions #ifdef _WIN32 -int OldWindowsGetLongPath(kwsys_stl::string const& shortPath, - kwsys_stl::string& longPath ) +static int GetCasePathName(const kwsys_stl::string & pathIn, + kwsys_stl::string & casePath) { - kwsys_stl::string::size_type iFound = shortPath.rfind('/'); - if (iFound > 1 && iFound != shortPath.npos) + kwsys_stl::string::size_type iFound = pathIn.rfind('/'); + if (iFound > 1 && iFound != pathIn.npos) { // recurse to peel off components // - if (OldWindowsGetLongPath(shortPath.substr(0, iFound), longPath) > 0) + if (GetCasePathName(pathIn.substr(0, iFound), casePath) > 0) { - longPath += '/'; - if (shortPath[1] != '/') + casePath += '/'; + if (pathIn[1] != '/') { WIN32_FIND_DATA findData; // append the long component name to the path // - if (INVALID_HANDLE_VALUE != ::FindFirstFile - (shortPath.c_str(), &findData)) + HANDLE hFind = ::FindFirstFile(pathIn.c_str(), &findData); + if (INVALID_HANDLE_VALUE != hFind) { - longPath += findData.cFileName; + casePath += findData.cFileName; + ::FindClose(hFind); } else { // if FindFirstFile fails, return the error code // - longPath = ""; + casePath = ""; return 0; } } @@ -3067,37 +3101,9 @@ int OldWindowsGetLongPath(kwsys_stl::string const& shortPath, } else { - longPath = shortPath; - } - return (int)longPath.size(); -} - - -int PortableGetLongPathName(const char* pathIn, - kwsys_stl::string & longPath) -{ - HMODULE lh = LoadLibrary("Kernel32.dll"); - if(lh) - { - FARPROC proc = GetProcAddress(lh, "GetLongPathNameA"); - if(proc) - { - typedef DWORD (WINAPI * GetLongFunctionPtr) (LPCSTR,LPSTR,DWORD); - GetLongFunctionPtr func = (GetLongFunctionPtr)proc; - char buffer[MAX_PATH+1]; - int len = (*func)(pathIn, buffer, MAX_PATH+1); - if(len == 0 || len > MAX_PATH+1) - { - FreeLibrary(lh); - return 0; - } - longPath = buffer; - FreeLibrary(lh); - return len; - } - FreeLibrary(lh); + casePath = pathIn; } - return OldWindowsGetLongPath(pathIn, longPath); + return (int)casePath.size(); } #endif @@ -3116,29 +3122,19 @@ kwsys_stl::string SystemTools::GetActualCaseForPath(const char* p) { return i->second; } - kwsys_stl::string shortPath; - if(!SystemTools::GetShortPath(p, shortPath)) - { - return p; - } - kwsys_stl::string longPath; - int len = PortableGetLongPathName(shortPath.c_str(), longPath); + kwsys_stl::string casePath; + int len = GetCasePathName(p, casePath); if(len == 0 || len > MAX_PATH+1) { return p; } - // Use original path if conversion back to a long path failed. - if(longPath == shortPath) - { - longPath = p; - } // make sure drive letter is always upper case - if(longPath.size() > 1 && longPath[1] == ':') + if(casePath.size() > 1 && casePath[1] == ':') { - longPath[0] = toupper(longPath[0]); + casePath[0] = toupper(casePath[0]); } - (*SystemTools::LongPathMap)[p] = longPath; - return longPath; + (*SystemTools::LongPathMap)[p] = casePath; + return casePath; #endif } @@ -3922,7 +3918,20 @@ bool SystemTools::GetLineFromStream(kwsys_ios::istream& is, line = ""; long leftToRead = sizeLimit; - + + // Early short circuit return if stream is no good. Just return + // false and the empty line. (Probably means caller tried to + // create a file stream with a non-existent file name...) + // + if(!is) + { + if(has_newline) + { + *has_newline = false; + } + return false; + } + // If no characters are read from the stream, the end of file has // been reached. Clear the fail bit just before reading. while(!haveNewline && @@ -4536,6 +4545,9 @@ bool SystemTools::ParseURL( const kwsys_stl::string& URL, unsigned int SystemToolsManagerCount; SystemToolsTranslationMap *SystemTools::TranslationMap; SystemToolsTranslationMap *SystemTools::LongPathMap; +#ifdef __CYGWIN__ +SystemToolsTranslationMap *SystemTools::Cyg2Win32Map; +#endif // SystemToolsManager manages the SystemTools singleton. // SystemToolsManager should be included in any translation unit @@ -4581,6 +4593,9 @@ void SystemTools::ClassInitialize() // Allocate the translation map first. SystemTools::TranslationMap = new SystemToolsTranslationMap; SystemTools::LongPathMap = new SystemToolsTranslationMap; +#ifdef __CYGWIN__ + SystemTools::Cyg2Win32Map = new SystemToolsTranslationMap; +#endif // Add some special translation paths for unix. These are not added // for windows because drive letters need to be maintained. Also, @@ -4637,6 +4652,9 @@ void SystemTools::ClassFinalize() { delete SystemTools::TranslationMap; delete SystemTools::LongPathMap; +#ifdef __CYGWIN__ + delete SystemTools::Cyg2Win32Map; +#endif } diff --git a/Utilities/ITK/Utilities/kwsys/SystemTools.hxx.in b/Utilities/ITK/Utilities/kwsys/SystemTools.hxx.in index d5fc6fe0a5399f93245978f92ece08ebe506874a..fd35742d330f915e3424969e8cc95cccf81bf6d3 100644 --- a/Utilities/ITK/Utilities/kwsys/SystemTools.hxx.in +++ b/Utilities/ITK/Utilities/kwsys/SystemTools.hxx.in @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: SystemTools.hxx.in,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #ifndef @KWSYS_NAMESPACE@_SystemTools_hxx #define @KWSYS_NAMESPACE@_SystemTools_hxx @@ -275,7 +273,17 @@ public: * not a directory. If isFile = false, then return true * if it is a file or a directory. */ - static bool FileExists(const char* filename, bool isFile=false); + static bool FileExists(const char* filename, bool isFile); + static bool FileExists(const char* filename); + + /** + * Converts Cygwin path to Win32 path. Uses dictionary container for + * caching and calls to cygwin_conv_to_win32_path from Cygwin dll + * for actual translation. Returns true on success, else false. + */ +#ifdef __CYGWIN__ + static bool PathCygwinToWin32(const char *path, char *win32_path); +#endif /** * Return file length @@ -890,6 +898,9 @@ private: */ static SystemToolsTranslationMap *TranslationMap; static SystemToolsTranslationMap *LongPathMap; +#ifdef __CYGWIN__ + static SystemToolsTranslationMap *Cyg2Win32Map; +#endif friend class SystemToolsManager; }; diff --git a/Utilities/ITK/Utilities/kwsys/Terminal.c b/Utilities/ITK/Utilities/kwsys/Terminal.c index 421962c22614f11cdde90bafffe28bc1dd2593ca..3bf257996b15d3e210d5a4fdf320d3a95302c525 100644 --- a/Utilities/ITK/Utilities/kwsys/Terminal.c +++ b/Utilities/ITK/Utilities/kwsys/Terminal.c @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: Terminal.c,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #include "kwsysPrivate.h" #include KWSYS_HEADER(Terminal.h) diff --git a/Utilities/ITK/Utilities/kwsys/Terminal.h.in b/Utilities/ITK/Utilities/kwsys/Terminal.h.in index 3b0f9247dba243f316d48712e6a5c9643c5db37c..108cba0174cf2d60d79982a1b063592bc511c099 100644 --- a/Utilities/ITK/Utilities/kwsys/Terminal.h.in +++ b/Utilities/ITK/Utilities/kwsys/Terminal.h.in @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: Terminal.h.in,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #ifndef @KWSYS_NAMESPACE@_Terminal_h #define @KWSYS_NAMESPACE@_Terminal_h diff --git a/Utilities/ITK/Utilities/kwsys/auto_ptr.hxx.in b/Utilities/ITK/Utilities/kwsys/auto_ptr.hxx.in index 104972c34df8aa0d3c643d2fb056f3f1dc0929d3..857b1db3cf69746ad9dbc0a64f2257a6ad6de41b 100644 --- a/Utilities/ITK/Utilities/kwsys/auto_ptr.hxx.in +++ b/Utilities/ITK/Utilities/kwsys/auto_ptr.hxx.in @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: auto_ptr.hxx.in,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #ifndef @KWSYS_NAMESPACE@_auto_ptr_hxx #define @KWSYS_NAMESPACE@_auto_ptr_hxx diff --git a/Utilities/ITK/Utilities/kwsys/hash_fun.hxx.in b/Utilities/ITK/Utilities/kwsys/hash_fun.hxx.in index 36044b697eea614a4beec0d3e76de48bac361dd3..f21efc54f2a8367c7c1564a04ddd6e51815a4308 100644 --- a/Utilities/ITK/Utilities/kwsys/hash_fun.hxx.in +++ b/Utilities/ITK/Utilities/kwsys/hash_fun.hxx.in @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: hash_fun.hxx.in,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ /* * Copyright (c) 1996 * Silicon Graphics Computer Systems, Inc. diff --git a/Utilities/ITK/Utilities/kwsys/hash_map.hxx.in b/Utilities/ITK/Utilities/kwsys/hash_map.hxx.in index 2d374c3290b3ab48be4fd4bc032a5efed0d7fb3e..6d4379d8e7b6f2c333c28f5b113275e120360ffe 100644 --- a/Utilities/ITK/Utilities/kwsys/hash_map.hxx.in +++ b/Utilities/ITK/Utilities/kwsys/hash_map.hxx.in @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: hash_map.hxx.in,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ /* * Copyright (c) 1996 * Silicon Graphics Computer Systems, Inc. diff --git a/Utilities/ITK/Utilities/kwsys/hash_set.hxx.in b/Utilities/ITK/Utilities/kwsys/hash_set.hxx.in index 106e56de2b75ac61a344f97e1cd3d9b6f42968bd..5ee01a594314cb16e643c96baac9bc55bff0274e 100644 --- a/Utilities/ITK/Utilities/kwsys/hash_set.hxx.in +++ b/Utilities/ITK/Utilities/kwsys/hash_set.hxx.in @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: hash_set.hxx.in,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ /* * Copyright (c) 1996 * Silicon Graphics Computer Systems, Inc. diff --git a/Utilities/ITK/Utilities/kwsys/hashtable.hxx.in b/Utilities/ITK/Utilities/kwsys/hashtable.hxx.in index 12e76d26761572544864cc9f0e0cff3bfd41768c..b36c9753c9703ac4399a16fcdb0cc22d5a67f53f 100644 --- a/Utilities/ITK/Utilities/kwsys/hashtable.hxx.in +++ b/Utilities/ITK/Utilities/kwsys/hashtable.hxx.in @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: hashtable.hxx.in,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ /* * Copyright (c) 1996 * Silicon Graphics Computer Systems, Inc. diff --git a/Utilities/ITK/Utilities/kwsys/kwsysDateStamp.cmake b/Utilities/ITK/Utilities/kwsys/kwsysDateStamp.cmake index 8e64e4a5b71c0a5297212c5e5d233a14a8903a56..fdac8dbc9ea9a85425f984db88bb02873d2b8934 100644 --- a/Utilities/ITK/Utilities/kwsys/kwsysDateStamp.cmake +++ b/Utilities/ITK/Utilities/kwsys/kwsysDateStamp.cmake @@ -1,10 +1,21 @@ # Do not edit! Generated by kwsysDateStamp.py +#============================================================================= +# KWSys - Kitware System Library +# Copyright 2000-2009 Kitware, Inc., Insight Software Consortium +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= # KWSys version date year component. Format is CCYY. -SET(KWSYS_DATE_STAMP_YEAR 2009) +SET(KWSYS_DATE_STAMP_YEAR 2010) # KWSys version date month component. Format is MM. -SET(KWSYS_DATE_STAMP_MONTH 09) +SET(KWSYS_DATE_STAMP_MONTH 04) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 14) +SET(KWSYS_DATE_STAMP_DAY 15) diff --git a/Utilities/ITK/Utilities/kwsys/kwsysDateStamp.py b/Utilities/ITK/Utilities/kwsys/kwsysDateStamp.py old mode 100644 new mode 100755 index e719a42169b051d0c5e30b86500bd04974c8d250..bd2e49a276b9ebb8881648c3b56338437b8d61ce --- a/Utilities/ITK/Utilities/kwsys/kwsysDateStamp.py +++ b/Utilities/ITK/Utilities/kwsys/kwsysDateStamp.py @@ -1,4 +1,15 @@ #!/usr/bin/python +#============================================================================= +# KWSys - Kitware System Library +# Copyright 2000-2009 Kitware, Inc., Insight Software Consortium +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= import sys,os import time @@ -18,6 +29,17 @@ ct = time.localtime() # Write the CMake code describing the date. fout.write("""# Do not edit! Generated by kwsysDateStamp.py +#============================================================================= +# KWSys - Kitware System Library +# Copyright 2000-2009 Kitware, Inc., Insight Software Consortium +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= # KWSys version date year component. Format is CCYY. SET(KWSYS_DATE_STAMP_YEAR %04u) diff --git a/Utilities/ITK/Utilities/kwsys/kwsysHeaderDump.pl b/Utilities/ITK/Utilities/kwsys/kwsysHeaderDump.pl old mode 100644 new mode 100755 index 4631b9187b2b3b749d10d4461f5ddcfd7baf4d17..0dc4a52046cfc0785748b3d33a9704c3702bd5ed --- a/Utilities/ITK/Utilities/kwsys/kwsysHeaderDump.pl +++ b/Utilities/ITK/Utilities/kwsys/kwsysHeaderDump.pl @@ -1,15 +1,15 @@ #!/usr/bin/perl +#============================================================================= +# KWSys - Kitware System Library +# Copyright 2000-2009 Kitware, Inc., Insight Software Consortium # -# Program: KWSys - Kitware System Library -# Module: $RCSfile: kwsysHeaderDump.pl,v $ -# -# Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. -# See Copyright.txt or http://www.kitware.com/Copyright.htm for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even -# the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -# PURPOSE. See the above copyright notices for more information. +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. # +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= if ( $#ARGV+1 < 2 ) { diff --git a/Utilities/ITK/Utilities/kwsys/kwsysPlatformTests.cmake b/Utilities/ITK/Utilities/kwsys/kwsysPlatformTests.cmake index 5c942af25657a5c77cf5500dc53ae667a4da7b38..d042450ee8dd8ca89f37f5e11984a2aae6dd2b4f 100644 --- a/Utilities/ITK/Utilities/kwsys/kwsysPlatformTests.cmake +++ b/Utilities/ITK/Utilities/kwsys/kwsysPlatformTests.cmake @@ -1,3 +1,14 @@ +#============================================================================= +# KWSys - Kitware System Library +# Copyright 2000-2009 Kitware, Inc., Insight Software Consortium +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= SET(KWSYS_PLATFORM_TEST_FILE_C kwsysPlatformTestsC.c) SET(KWSYS_PLATFORM_TEST_FILE_CXX kwsysPlatformTestsCXX.cxx) @@ -151,3 +162,55 @@ MACRO(KWSYS_PLATFORM_CXX_TEST_RUN var description invert) SET(KWSYS_PLATFORM_TEST_DEFINES) SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS) ENDMACRO(KWSYS_PLATFORM_CXX_TEST_RUN) + +#----------------------------------------------------------------------------- +# KWSYS_PLATFORM_INFO_TEST(lang var description) +# +# Compile test named by ${var} and store INFO strings extracted from binary. +MACRO(KWSYS_PLATFORM_INFO_TEST lang var description) + # We can implement this macro on CMake 2.6 and above. + IF("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.6) + SET(${var} "") + ELSE() + # Choose a location for the result binary. + SET(KWSYS_PLATFORM_INFO_FILE + ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${var}.bin) + + # Compile the test binary. + IF(NOT EXISTS ${KWSYS_PLATFORM_INFO_FILE}) + MESSAGE(STATUS "${description}") + TRY_COMPILE(${var}_COMPILED + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/${KWSYS_PLATFORM_TEST_FILE_${lang}} + COMPILE_DEFINITIONS -DTEST_${var} + ${KWSYS_PLATFORM_${lang}_TEST_DEFINES} + ${KWSYS_PLATFORM_${lang}_TEST_EXTRA_FLAGS} + OUTPUT_VARIABLE OUTPUT + COPY_FILE ${KWSYS_PLATFORM_INFO_FILE} + ) + IF(${var}_COMPILED) + FILE(APPEND + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "${description} compiled with the following output:\n${OUTPUT}\n\n") + ELSE() + FILE(APPEND + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "${description} failed to compile with the following output:\n${OUTPUT}\n\n") + ENDIF() + IF(${var}_COMPILED) + MESSAGE(STATUS "${description} - compiled") + ELSE() + MESSAGE(STATUS "${description} - failed") + ENDIF() + ENDIF() + + # Parse info strings out of the compiled binary. + IF(${var}_COMPILED) + FILE(STRINGS ${KWSYS_PLATFORM_INFO_FILE} ${var} REGEX "INFO:[A-Za-z0-9]+\\[[^]]*\\]") + ELSE() + SET(${var} "") + ENDIF() + + SET(KWSYS_PLATFORM_INFO_FILE) + ENDIF() +ENDMACRO() diff --git a/Utilities/ITK/Utilities/kwsys/kwsysPlatformTestsC.c b/Utilities/ITK/Utilities/kwsys/kwsysPlatformTestsC.c index 58b22f3a56744dbc326dd35441fb8cc669cbf024..e602964bb75ef161fd04312a2ec64373592fe6ce 100644 --- a/Utilities/ITK/Utilities/kwsys/kwsysPlatformTestsC.c +++ b/Utilities/ITK/Utilities/kwsys/kwsysPlatformTestsC.c @@ -1,3 +1,14 @@ +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ /* Macros to define main() in a cross-platform way. @@ -49,3 +60,41 @@ int KWSYS_PLATFORM_TEST_C_MAIN() return f(n); } #endif + +/*--------------------------------------------------------------------------*/ +#ifdef TEST_KWSYS_C_TYPE_MACROS +char* info_macros = +#if defined(__SIZEOF_SHORT__) +"INFO:macro[__SIZEOF_SHORT__]\n" +#endif +#if defined(__SIZEOF_INT__) +"INFO:macro[__SIZEOF_INT__]\n" +#endif +#if defined(__SIZEOF_LONG__) +"INFO:macro[__SIZEOF_LONG__]\n" +#endif +#if defined(__SIZEOF_LONG_LONG__) +"INFO:macro[__SIZEOF_LONG_LONG__]\n" +#endif +#if defined(__SHORT_MAX__) +"INFO:macro[__SHORT_MAX__]\n" +#endif +#if defined(__INT_MAX__) +"INFO:macro[__INT_MAX__]\n" +#endif +#if defined(__LONG_MAX__) +"INFO:macro[__LONG_MAX__]\n" +#endif +#if defined(__LONG_LONG_MAX__) +"INFO:macro[__LONG_LONG_MAX__]\n" +#endif + ""; + +int KWSYS_PLATFORM_TEST_C_MAIN_ARGS(argc, argv) +{ + int require = 0; + require += info_macros[argc]; + (void)argv; + return require; +} +#endif diff --git a/Utilities/ITK/Utilities/kwsys/kwsysPlatformTestsCXX.cxx b/Utilities/ITK/Utilities/kwsys/kwsysPlatformTestsCXX.cxx index 502e2d88b170b36f2acd40e5f09a01e03888036f..903be9bdb2f4e86624844a91d4bdac31d5e022f5 100644 --- a/Utilities/ITK/Utilities/kwsys/kwsysPlatformTestsCXX.cxx +++ b/Utilities/ITK/Utilities/kwsys/kwsysPlatformTestsCXX.cxx @@ -1,3 +1,14 @@ +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ // Setup for tests that use result of stl namespace test. #if defined(KWSYS_STL_HAVE_STD) # if KWSYS_STL_HAVE_STD @@ -102,6 +113,15 @@ void f(size_t) {} int main() { return 0; } #endif +#ifdef TEST_KWSYS_CXX_HAS_LONG_LONG +long long f(long long n) { return n; } +int main() +{ + long long n = 0; + return static_cast<int>(f(n)); +} +#endif + #ifdef TEST_KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS template <class T> class A; template <class T> int f(A<T>&); diff --git a/Utilities/ITK/Utilities/kwsys/kwsysPrivate.h b/Utilities/ITK/Utilities/kwsys/kwsysPrivate.h index a40a7210d72244510b6d68aa95afe40d04bf5e84..3a26c26fbdf6a1164256106b1da2f044cb3d4538 100644 --- a/Utilities/ITK/Utilities/kwsys/kwsysPrivate.h +++ b/Utilities/ITK/Utilities/kwsys/kwsysPrivate.h @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: kwsysPrivate.h,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #ifndef KWSYS_NAMESPACE # error "Do not include kwsysPrivate.h outside of kwsys c and cxx files." #endif diff --git a/Utilities/ITK/Utilities/kwsys/kwsys_cstddef.hxx.in b/Utilities/ITK/Utilities/kwsys/kwsys_cstddef.hxx.in index 2c957593f7f0841498af9bb79b9b40ef7eea8a9b..925c030846388badcb8b1cbb3a0efa27b1ce9f77 100644 --- a/Utilities/ITK/Utilities/kwsys/kwsys_cstddef.hxx.in +++ b/Utilities/ITK/Utilities/kwsys/kwsys_cstddef.hxx.in @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: kwsys_cstddef.hxx.in,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #ifndef @KWSYS_NAMESPACE@_cstddef #define @KWSYS_NAMESPACE@_cstddef diff --git a/Utilities/ITK/Utilities/kwsys/kwsys_ios_fstream.h.in b/Utilities/ITK/Utilities/kwsys/kwsys_ios_fstream.h.in index b20ac0e92ebe562724b98b6f262791ad0c6b8ac6..4b1a8cfcc403d86e2668202ad17fd7c5944541dc 100644 --- a/Utilities/ITK/Utilities/kwsys/kwsys_ios_fstream.h.in +++ b/Utilities/ITK/Utilities/kwsys/kwsys_ios_fstream.h.in @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: kwsys_ios_fstream.h.in,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #ifndef @KWSYS_NAMESPACE@_ios_fstream #define @KWSYS_NAMESPACE@_ios_fstream diff --git a/Utilities/ITK/Utilities/kwsys/kwsys_ios_iosfwd.h.in b/Utilities/ITK/Utilities/kwsys/kwsys_ios_iosfwd.h.in index 484fddaa3f9c51b2a9e6e15145c6df8f13e976db..f4fafebc259cd6eb0dd91b174fa63425e3973b6f 100644 --- a/Utilities/ITK/Utilities/kwsys/kwsys_ios_iosfwd.h.in +++ b/Utilities/ITK/Utilities/kwsys/kwsys_ios_iosfwd.h.in @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: kwsys_ios_iosfwd.h.in,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #ifndef @KWSYS_NAMESPACE@_ios_iosfwd #define @KWSYS_NAMESPACE@_ios_iosfwd diff --git a/Utilities/ITK/Utilities/kwsys/kwsys_ios_iostream.h.in b/Utilities/ITK/Utilities/kwsys/kwsys_ios_iostream.h.in index 7378f671aa51bb44f87b6860206635df83753f57..43fc4d57901cd294c035fd434dcf3334b36b83d6 100644 --- a/Utilities/ITK/Utilities/kwsys/kwsys_ios_iostream.h.in +++ b/Utilities/ITK/Utilities/kwsys/kwsys_ios_iostream.h.in @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: kwsys_ios_iostream.h.in,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #ifndef @KWSYS_NAMESPACE@_ios_iostream #define @KWSYS_NAMESPACE@_ios_iostream diff --git a/Utilities/ITK/Utilities/kwsys/kwsys_ios_sstream.h.in b/Utilities/ITK/Utilities/kwsys/kwsys_ios_sstream.h.in index c8b1e868284d7492f884f50594d6fa3ae1fddedc..29d250c7a6bbb84a31f5cd530e6dbb99b584ab57 100644 --- a/Utilities/ITK/Utilities/kwsys/kwsys_ios_sstream.h.in +++ b/Utilities/ITK/Utilities/kwsys/kwsys_ios_sstream.h.in @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: kwsys_ios_sstream.h.in,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #ifndef @KWSYS_NAMESPACE@_ios_sstream #define @KWSYS_NAMESPACE@_ios_sstream diff --git a/Utilities/ITK/Utilities/kwsys/kwsys_stl.hxx.in b/Utilities/ITK/Utilities/kwsys/kwsys_stl.hxx.in index 8c2d9ea02485831a065d8e4f3510b8e64fe3abaa..610e6d47115f30cb6474b6e574c1cddd01677c93 100644 --- a/Utilities/ITK/Utilities/kwsys/kwsys_stl.hxx.in +++ b/Utilities/ITK/Utilities/kwsys/kwsys_stl.hxx.in @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: kwsys_stl.hxx.in,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #ifndef @KWSYS_NAMESPACE@_stl_@KWSYS_STL_HEADER@ #define @KWSYS_NAMESPACE@_stl_@KWSYS_STL_HEADER@ diff --git a/Utilities/ITK/Utilities/kwsys/kwsys_stl_string.hxx.in b/Utilities/ITK/Utilities/kwsys/kwsys_stl_string.hxx.in index 8334328a38a9705d2427ea2336fd9957721be36d..cd312cb8e38cb6b405a25c9302ea3dc40d19e955 100644 --- a/Utilities/ITK/Utilities/kwsys/kwsys_stl_string.hxx.in +++ b/Utilities/ITK/Utilities/kwsys/kwsys_stl_string.hxx.in @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: kwsys_stl_string.hxx.in,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ // This header is extra code for <@KWSYS_NAMESPACE@/stl/string>. #if !defined(@KWSYS_NAMESPACE@_stl_string_including_hxx) diff --git a/Utilities/ITK/Utilities/kwsys/testAutoPtr.cxx b/Utilities/ITK/Utilities/kwsys/testAutoPtr.cxx index 8351272a3e239eadff28edb6f073bc137cc7bfb9..747d869e24aa314fe326e33681d3b535d304ac7e 100644 --- a/Utilities/ITK/Utilities/kwsys/testAutoPtr.cxx +++ b/Utilities/ITK/Utilities/kwsys/testAutoPtr.cxx @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: testAutoPtr.cxx,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #ifdef __BORLANDC__ # pragma warn -8027 /* 'for' not inlined. */ # pragma warn -8026 /* exception not inlined. */ diff --git a/Utilities/ITK/Utilities/kwsys/testCommandLineArguments.cxx b/Utilities/ITK/Utilities/kwsys/testCommandLineArguments.cxx index 758b7e8c9d169e91afd391ba4bce187b79758e89..e75a87e867fa1e10a194ede364f3087d90299de4 100644 --- a/Utilities/ITK/Utilities/kwsys/testCommandLineArguments.cxx +++ b/Utilities/ITK/Utilities/kwsys/testCommandLineArguments.cxx @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: testCommandLineArguments.cxx,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #include "kwsysPrivate.h" #include KWSYS_HEADER(CommandLineArguments.hxx) #include KWSYS_HEADER(ios/iostream) diff --git a/Utilities/ITK/Utilities/kwsys/testCommandLineArguments1.cxx b/Utilities/ITK/Utilities/kwsys/testCommandLineArguments1.cxx index 1a2505b830dc599c41a8fe98855eb6da34487c9c..0860c2abc5a174683ff2c3bea03fa81afe4d86e5 100644 --- a/Utilities/ITK/Utilities/kwsys/testCommandLineArguments1.cxx +++ b/Utilities/ITK/Utilities/kwsys/testCommandLineArguments1.cxx @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: testCommandLineArguments1.cxx,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #include "kwsysPrivate.h" #include KWSYS_HEADER(CommandLineArguments.hxx) #include KWSYS_HEADER(ios/iostream) diff --git a/Utilities/ITK/Utilities/kwsys/testDynamicLoader.cxx b/Utilities/ITK/Utilities/kwsys/testDynamicLoader.cxx index c1695994758f300176c39a28021f816cc31126d2..a7adbcad9fcd2ea664cf41485215849a176f589b 100644 --- a/Utilities/ITK/Utilities/kwsys/testDynamicLoader.cxx +++ b/Utilities/ITK/Utilities/kwsys/testDynamicLoader.cxx @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: testDynamicLoader.cxx,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #include "kwsysPrivate.h" #include KWSYS_HEADER(DynamicLoader.hxx) diff --git a/Utilities/ITK/Utilities/kwsys/testDynload.c b/Utilities/ITK/Utilities/kwsys/testDynload.c index 67c33c35a09f0d6fe40c0ab521e2ce29176123fb..ba60becbd0502af2f9c509fc6898485d8016e264 100644 --- a/Utilities/ITK/Utilities/kwsys/testDynload.c +++ b/Utilities/ITK/Utilities/kwsys/testDynload.c @@ -1,3 +1,14 @@ +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #ifdef _WIN32 #define DL_EXPORT __declspec( dllexport ) #else diff --git a/Utilities/ITK/Utilities/kwsys/testEncode.c b/Utilities/ITK/Utilities/kwsys/testEncode.c index 5ea180d512fc3806663a742117b79d2887bf81fb..26d483b6f9d51290ce3f063b466ae9d615b7ca43 100644 --- a/Utilities/ITK/Utilities/kwsys/testEncode.c +++ b/Utilities/ITK/Utilities/kwsys/testEncode.c @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: testEncode.c,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #include "kwsysPrivate.h" #include KWSYS_HEADER(MD5.h) @@ -24,9 +22,9 @@ #include <string.h> static const unsigned char testMD5input1[] = -" Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved.\n" -" See Copyright.txt or http://www.kitware.com/Copyright.htm for details.\n"; -static const char testMD5output1[] = "04051e509e81ef0b1612ddf0e52ca89e"; +" A quick brown fox jumps over the lazy dog.\n" +" This is sample text for MD5 sum input.\n"; +static const char testMD5output1[] = "8f146af46ed4f267921bb937d4d3500c"; static const int testMD5input2len = 28; static const unsigned char testMD5input2[] = "the cow jumped over the moon"; diff --git a/Utilities/ITK/Utilities/kwsys/testFail.c b/Utilities/ITK/Utilities/kwsys/testFail.c index c9d62f48c9885f3007107a4d172e9db782ff64e9..7e062c1751d016cfafff8d6d1480ee26247ae7e4 100644 --- a/Utilities/ITK/Utilities/kwsys/testFail.c +++ b/Utilities/ITK/Utilities/kwsys/testFail.c @@ -1,3 +1,14 @@ +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #include <stdio.h> #include <stdlib.h> #include <string.h> diff --git a/Utilities/ITK/Utilities/kwsys/testHashSTL.cxx b/Utilities/ITK/Utilities/kwsys/testHashSTL.cxx index a3a0666d05e286ffe8d8fce4043649a894dd70e5..b861a5b32f49a4b742f3e4f4abfdb63a22f10235 100644 --- a/Utilities/ITK/Utilities/kwsys/testHashSTL.cxx +++ b/Utilities/ITK/Utilities/kwsys/testHashSTL.cxx @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: testHashSTL.cxx,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #include "kwsysPrivate.h" #include KWSYS_HEADER(hash_map.hxx) #include KWSYS_HEADER(hash_set.hxx) diff --git a/Utilities/ITK/Utilities/kwsys/testIOS.cxx b/Utilities/ITK/Utilities/kwsys/testIOS.cxx index 2839109278ff1f7b90e2eea6eeb376308c4e9388..3b971e268763f0b3224894f34be06bf6a0124ddf 100644 --- a/Utilities/ITK/Utilities/kwsys/testIOS.cxx +++ b/Utilities/ITK/Utilities/kwsys/testIOS.cxx @@ -1,3 +1,14 @@ +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #include "kwsysPrivate.h" #include KWSYS_HEADER(stl/vector) #include KWSYS_HEADER(ios/sstream) diff --git a/Utilities/ITK/Utilities/kwsys/testProcess.c b/Utilities/ITK/Utilities/kwsys/testProcess.c index b38279dd5c6541e0897edf66cd86e7911d9b40bb..0060c4d1ff3ba0a8ea80f585c7217881c59491ff 100644 --- a/Utilities/ITK/Utilities/kwsys/testProcess.c +++ b/Utilities/ITK/Utilities/kwsys/testProcess.c @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: testProcess.c,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #include "kwsysPrivate.h" #include KWSYS_HEADER(Process.h) @@ -268,7 +266,7 @@ int runChild2(kwsysProcess* kp, } else { - fwrite(data, 1, length, stdout); + fwrite(data, 1, (size_t) length, stdout); fflush(stdout); } } diff --git a/Utilities/ITK/Utilities/kwsys/testRegistry.cxx b/Utilities/ITK/Utilities/kwsys/testRegistry.cxx index f2435585a1915d7bfcfd0a629fe8f4e4647d72be..7e9b0d49b44c4aa2672f4e82f783f746d0531354 100644 --- a/Utilities/ITK/Utilities/kwsys/testRegistry.cxx +++ b/Utilities/ITK/Utilities/kwsys/testRegistry.cxx @@ -1,17 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: ParaView - Module: $RCSfile: testRegistry.cxx,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc. - All rights reserved. - See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #include "kwsysPrivate.h" #include KWSYS_HEADER(Registry.hxx) diff --git a/Utilities/ITK/Utilities/kwsys/testSharedForward.c.in b/Utilities/ITK/Utilities/kwsys/testSharedForward.c.in index e441aef1997c907c66b670cca290445325c360bb..ee753efa33c06c0ad1920abe1de350e5e9e708cd 100644 --- a/Utilities/ITK/Utilities/kwsys/testSharedForward.c.in +++ b/Utilities/ITK/Utilities/kwsys/testSharedForward.c.in @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: testSharedForward.c.in,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #if defined(CMAKE_INTDIR) # define CONFIG_DIR_PRE CMAKE_INTDIR "/" # define CONFIG_DIR_POST "/" CMAKE_INTDIR diff --git a/Utilities/ITK/Utilities/kwsys/testSystemInformation.cxx b/Utilities/ITK/Utilities/kwsys/testSystemInformation.cxx index 061458a4c75d43b07ede519a5c5b408852bf3df2..b3afc9de992732cfc72bd4b1a92cf3031fc8b2b7 100644 --- a/Utilities/ITK/Utilities/kwsys/testSystemInformation.cxx +++ b/Utilities/ITK/Utilities/kwsys/testSystemInformation.cxx @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: testSystemInformation.cxx,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #include "kwsysPrivate.h" #include KWSYS_HEADER(SystemInformation.hxx) #include KWSYS_HEADER(ios/iostream) diff --git a/Utilities/ITK/Utilities/kwsys/testSystemTools.cxx b/Utilities/ITK/Utilities/kwsys/testSystemTools.cxx index 65d42edc25801467963ce0bc1951e9660845957b..ad35c340b7609a403f65d51c94f4fd270b5a3dc8 100644 --- a/Utilities/ITK/Utilities/kwsys/testSystemTools.cxx +++ b/Utilities/ITK/Utilities/kwsys/testSystemTools.cxx @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: testSystemTools.cxx,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #include "kwsysPrivate.h" #if defined(_MSC_VER) diff --git a/Utilities/ITK/Utilities/kwsys/testSystemTools.h.in b/Utilities/ITK/Utilities/kwsys/testSystemTools.h.in index e0d7b326aa58364bc89c23c55389c82e621374dc..4b94bb6afa053e10ac90866895d58a56db2cd0cc 100644 --- a/Utilities/ITK/Utilities/kwsys/testSystemTools.h.in +++ b/Utilities/ITK/Utilities/kwsys/testSystemTools.h.in @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: testSystemTools.h.in,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #ifndef @KWSYS_NAMESPACE@_testSystemtools_h #define @KWSYS_NAMESPACE@_testSystemtools_h diff --git a/Utilities/ITK/Utilities/kwsys/testTerminal.c b/Utilities/ITK/Utilities/kwsys/testTerminal.c index 856b5cc44527f22a7291a7249f28898b25261a04..0d2d7a77b361ff14cfd64726f9414a12b4cef6cb 100644 --- a/Utilities/ITK/Utilities/kwsys/testTerminal.c +++ b/Utilities/ITK/Utilities/kwsys/testTerminal.c @@ -1,16 +1,14 @@ -/*========================================================================= +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - Program: KWSys - Kitware System Library - Module: $RCSfile: testTerminal.c,v $ + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. - Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ #include "kwsysPrivate.h" #include KWSYS_HEADER(Terminal.h) diff --git a/Utilities/ITK/Utilities/metaIOConfig.h b/Utilities/ITK/Utilities/metaIOConfig.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Utilities/nifti/CMakeLists.txt b/Utilities/ITK/Utilities/nifti/CMakeLists.txt index 3915e3679afe81cfb711d86d8780e18b3f86136b..7078cac825649f911e90a48942772c63b82931f3 100644 --- a/Utilities/ITK/Utilities/nifti/CMakeLists.txt +++ b/Utilities/ITK/Utilities/nifti/CMakeLists.txt @@ -30,7 +30,13 @@ IF("${ITK_VERSION_MAJOR}" GREATER 0.0) SET(NIFTI_LIBRARY_PROPERTIES ${ITK_LIBRARY_PROPERTIES}) SET(NIFTI_INSTALL_BIN_DIR "${ITK_INSTALL_BIN_DIR_CM24}") SET(NIFTI_INSTALL_LIB_DIR "${ITK_INSTALL_LIB_DIR_CM24}") - SET(NIFTI_INSTALL_INCLUDE_DIR "${ITK_INSTALL_INCLUDE_DIR_CM24}/Utilities") + + IF(ITK_USE_FLAT_DIRECTORY_INSTALL) + SET(NIFTI_INSTALL_INCLUDE_DIR "${ITK_INSTALL_INCLUDE_DIR_CM24}") + ELSE(ITK_USE_FLAT_DIRECTORY_INSTALL) + SET(NIFTI_INSTALL_INCLUDE_DIR "${ITK_INSTALL_INCLUDE_DIR_CM24}/Utilities") + ENDIF(ITK_USE_FLAT_DIRECTORY_INSTALL) + SET(NIFTI_ZLIB_LIBRARIES ${ITK_ZLIB_LIBRARIES}) SET(NIFTI_INSTALL_NO_DEVELOPMENT ${ITK_INSTALL_NO_DEVELOPMENT}) SET(NIFTI_INSTALL_NO_LIBRARIES ${ITK_INSTALL_NO_LIBRARIES}) diff --git a/Utilities/ITK/Utilities/nifti/Testing/nifti_regress_test/@show.diffs b/Utilities/ITK/Utilities/nifti/Testing/nifti_regress_test/@show.diffs old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Utilities/nifti/Testing/nifti_regress_test/@test b/Utilities/ITK/Utilities/nifti/Testing/nifti_regress_test/@test old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Utilities/nifti/nifticdf/Makefile b/Utilities/ITK/Utilities/nifti/nifticdf/Makefile old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Utilities/nifti/niftilib/nifti1_io.c b/Utilities/ITK/Utilities/nifti/niftilib/nifti1_io.c index ec16fc3f83c209cc55a038139c62db5e535a71ee..3eed2ae52e6ba0bb175468059b344f0ee990ce11 100644 --- a/Utilities/ITK/Utilities/nifti/niftilib/nifti1_io.c +++ b/Utilities/ITK/Utilities/nifti/niftilib/nifti1_io.c @@ -1465,7 +1465,7 @@ mat44 nifti_quatern_to_mat44( float qb, float qc, float qd, /* last row is always [ 0 0 0 1 ] */ - R.m[3][0]=R.m[3][1]=R.m[3][2] = 0.0 ; R.m[3][3]= 1.0 ; + R.m[3][0]=R.m[3][1]=R.m[3][2] = 0.0f ; R.m[3][3]= 1.0f ; /* compute a parameter from b,c,d */ @@ -1486,15 +1486,15 @@ mat44 nifti_quatern_to_mat44( float qb, float qc, float qd, if( qfac < 0.0 ) zd = -zd ; /* left handedness? */ - R.m[0][0] = (a*a+b*b-c*c-d*d) * xd ; + R.m[0][0] = (float)( (a*a+b*b-c*c-d*d) * xd) ; R.m[0][1] = 2.0l * (b*c-a*d ) * yd ; R.m[0][2] = 2.0l * (b*d+a*c ) * zd ; R.m[1][0] = 2.0l * (b*c+a*d ) * xd ; - R.m[1][1] = (a*a+c*c-b*b-d*d) * yd ; + R.m[1][1] = (float)( (a*a+c*c-b*b-d*d) * yd) ; R.m[1][2] = 2.0l * (c*d-a*b ) * zd ; R.m[2][0] = 2.0l * (b*d-a*c ) * xd ; R.m[2][1] = 2.0l * (c*d+a*b ) * yd ; - R.m[2][2] = (a*a+d*d-c*c-b*b) * zd ; + R.m[2][2] = (float)( (a*a+d*d-c*c-b*b) * zd) ; /* load offsets */ @@ -1560,7 +1560,7 @@ void nifti_mat44_to_quatern( mat44 R , /* assign the output lengths */ - ASSIF(dx,xd) ; ASSIF(dy,yd) ; ASSIF(dz,zd) ; + ASSIF(dx,(float)xd) ; ASSIF(dy,(float)yd) ; ASSIF(dz,(float)zd) ; /* normalize the columns */ @@ -1580,9 +1580,9 @@ void nifti_mat44_to_quatern( mat44 R , will result in the inverse orthogonal matrix at this point. If we just orthogonalized the columns, this wouldn't necessarily hold. */ - Q.m[0][0] = r11 ; Q.m[0][1] = r12 ; Q.m[0][2] = r13 ; /* load Q */ - Q.m[1][0] = r21 ; Q.m[1][1] = r22 ; Q.m[1][2] = r23 ; - Q.m[2][0] = r31 ; Q.m[2][1] = r32 ; Q.m[2][2] = r33 ; + Q.m[0][0] = (float)r11 ; Q.m[0][1] = (float)r12 ; Q.m[0][2] = (float)r13 ; /* load Q */ + Q.m[1][0] = (float)r21 ; Q.m[1][1] = (float)r22 ; Q.m[1][2] = (float)r23 ; + Q.m[2][0] = (float)r31 ; Q.m[2][1] = (float)r32 ; Q.m[2][2] = (float)r33 ; P = nifti_mat33_polar(Q) ; /* P is orthog matrix closest to Q */ @@ -1600,9 +1600,9 @@ void nifti_mat44_to_quatern( mat44 R , +r21*r32*r13+r31*r12*r23-r31*r22*r13 ; /* should be -1 or 1 */ if( zd > 0 ){ /* proper */ - ASSIF(qfac,1.0) ; + ASSIF(qfac,1.0f) ; } else { /* improper ==> flip 3rd column */ - ASSIF(qfac,-1.0) ; + ASSIF(qfac,-1.0f) ; r13 = -r13 ; r23 = -r23 ; r33 = -r33 ; } @@ -1638,7 +1638,7 @@ void nifti_mat44_to_quatern( mat44 R , if( a < 0.0l ){ b=-b ; c=-c ; d=-d; a=-a; } } - ASSIF(qb,b) ; ASSIF(qc,c) ; ASSIF(qd,d) ; + ASSIF(qb,(float)b) ; ASSIF(qc,(float)c) ; ASSIF(qd,(float)d) ; return ; } @@ -1673,23 +1673,23 @@ mat44 nifti_mat44_inverse( mat44 R ) if( deti != 0.0l ) deti = 1.0l / deti ; - Q.m[0][0] = deti*( r22*r33-r32*r23) ; - Q.m[0][1] = deti*(-r12*r33+r32*r13) ; - Q.m[0][2] = deti*( r12*r23-r22*r13) ; - Q.m[0][3] = deti*(-r12*r23*v3+r12*v2*r33+r22*r13*v3 - -r22*v1*r33-r32*r13*v2+r32*v1*r23) ; + Q.m[0][0] = (float)( deti*( r22*r33-r32*r23) ) ; + Q.m[0][1] = (float)( deti*(-r12*r33+r32*r13) ) ; + Q.m[0][2] = (float)( deti*( r12*r23-r22*r13) ) ; + Q.m[0][3] = (float)( deti*(-r12*r23*v3+r12*v2*r33+r22*r13*v3 + -r22*v1*r33-r32*r13*v2+r32*v1*r23) ) ; - Q.m[1][0] = deti*(-r21*r33+r31*r23) ; - Q.m[1][1] = deti*( r11*r33-r31*r13) ; - Q.m[1][2] = deti*(-r11*r23+r21*r13) ; - Q.m[1][3] = deti*( r11*r23*v3-r11*v2*r33-r21*r13*v3 - +r21*v1*r33+r31*r13*v2-r31*v1*r23) ; + Q.m[1][0] = (float)( deti*(-r21*r33+r31*r23) ) ; + Q.m[1][1] = (float)( deti*( r11*r33-r31*r13) ) ; + Q.m[1][2] = (float)( deti*(-r11*r23+r21*r13) ) ; + Q.m[1][3] = (float)( deti*( r11*r23*v3-r11*v2*r33-r21*r13*v3 + +r21*v1*r33+r31*r13*v2-r31*v1*r23) ) ; - Q.m[2][0] = deti*( r21*r32-r31*r22) ; - Q.m[2][1] = deti*(-r11*r32+r31*r12) ; - Q.m[2][2] = deti*( r11*r22-r21*r12) ; - Q.m[2][3] = deti*(-r11*r22*v3+r11*r32*v2+r21*r12*v3 - -r21*r32*v1-r31*r12*v2+r31*r22*v1) ; + Q.m[2][0] = (float)( deti*( r21*r32-r31*r22) ) ; + Q.m[2][1] = (float)( deti*(-r11*r32+r31*r12) ) ; + Q.m[2][2] = (float)( deti*( r11*r22-r21*r12) ) ; + Q.m[2][3] = (float)( deti*(-r11*r22*v3+r11*r32*v2+r21*r12*v3 + -r21*r32*v1-r31*r12*v2+r31*r22*v1) ) ; Q.m[3][0] = Q.m[3][1] = Q.m[3][2] = 0.0l ; Q.m[3][3] = (deti == 0.0l) ? 0.0l : 1.0l ; /* failure flag if deti == 0 */ @@ -1746,7 +1746,7 @@ mat44 nifti_make_orthog_mat44( float r11, float r12, float r13 , val = Q.m[0][0]*Q.m[0][0] + Q.m[0][1]*Q.m[0][1] + Q.m[0][2]*Q.m[0][2] ; if( val > 0.0l ){ val = 1.0l / sqrt(val) ; - Q.m[0][0] *= val ; Q.m[0][1] *= val ; Q.m[0][2] *= val ; + Q.m[0][0] *= (float)val ; Q.m[0][1] *= (float)val ; Q.m[0][2] *= (float)val ; } else { Q.m[0][0] = 1.0l ; Q.m[0][1] = 0.0l ; Q.m[0][2] = 0.0l ; } @@ -1756,7 +1756,7 @@ mat44 nifti_make_orthog_mat44( float r11, float r12, float r13 , val = Q.m[1][0]*Q.m[1][0] + Q.m[1][1]*Q.m[1][1] + Q.m[1][2]*Q.m[1][2] ; if( val > 0.0l ){ val = 1.0l / sqrt(val) ; - Q.m[1][0] *= val ; Q.m[1][1] *= val ; Q.m[1][2] *= val ; + Q.m[1][0] *= (float)val ; Q.m[1][1] *= (float)val ; Q.m[1][2] *= (float)val ; } else { Q.m[1][0] = 0.0l ; Q.m[1][1] = 1.0l ; Q.m[1][2] = 0.0l ; } @@ -1766,7 +1766,7 @@ mat44 nifti_make_orthog_mat44( float r11, float r12, float r13 , val = Q.m[2][0]*Q.m[2][0] + Q.m[2][1]*Q.m[2][1] + Q.m[2][2]*Q.m[2][2] ; if( val > 0.0l ){ val = 1.0l / sqrt(val) ; - Q.m[2][0] *= val ; Q.m[2][1] *= val ; Q.m[2][2] *= val ; + Q.m[2][0] *= (float)val ; Q.m[2][1] *= (float)val ; Q.m[2][2] *= (float)val ; } else { Q.m[2][0] = Q.m[0][1]*Q.m[1][2] - Q.m[0][2]*Q.m[1][1] ; /* cross */ Q.m[2][1] = Q.m[0][2]*Q.m[1][0] - Q.m[0][0]*Q.m[1][2] ; /* product */ @@ -1779,7 +1779,7 @@ mat44 nifti_make_orthog_mat44( float r11, float r12, float r13 , R.m[1][0] = P.m[1][0] ; R.m[1][1] = P.m[1][1] ; R.m[1][2] = P.m[1][2] ; R.m[2][0] = P.m[2][0] ; R.m[2][1] = P.m[2][1] ; R.m[2][2] = P.m[2][2] ; - R.m[0][3] = R.m[1][3] = R.m[2][3] = 0.0 ; return R ; + R.m[0][3] = R.m[1][3] = R.m[2][3] = 0.0f ; return R ; } /*----------------------------------------------------------------------*/ @@ -1799,17 +1799,17 @@ mat33 nifti_mat33_inverse( mat33 R ) /* inverse of 3x3 matrix */ if( deti != 0.0l ) deti = 1.0l / deti ; - Q.m[0][0] = deti*( r22*r33-r32*r23) ; - Q.m[0][1] = deti*(-r12*r33+r32*r13) ; - Q.m[0][2] = deti*( r12*r23-r22*r13) ; + Q.m[0][0] = (float)( deti*( r22*r33-r32*r23) ) ; + Q.m[0][1] = (float)( deti*(-r12*r33+r32*r13) ) ; + Q.m[0][2] = (float)( deti*( r12*r23-r22*r13) ) ; - Q.m[1][0] = deti*(-r21*r33+r31*r23) ; - Q.m[1][1] = deti*( r11*r33-r31*r13) ; - Q.m[1][2] = deti*(-r11*r23+r21*r13) ; + Q.m[1][0] = (float)( deti*(-r21*r33+r31*r23) ) ; + Q.m[1][1] = (float)( deti*( r11*r33-r31*r13) ) ; + Q.m[1][2] = (float)( deti*(-r11*r23+r21*r13) ) ; - Q.m[2][0] = deti*( r21*r32-r31*r22) ; - Q.m[2][1] = deti*(-r11*r32+r31*r12) ; - Q.m[2][2] = deti*( r11*r22-r21*r12) ; + Q.m[2][0] = (float)( deti*( r21*r32-r31*r22) ) ; + Q.m[2][1] = (float)( deti*(-r11*r32+r31*r12) ) ; + Q.m[2][2] = (float)( deti*( r11*r22-r21*r12) ) ; return Q ; } @@ -1825,8 +1825,8 @@ float nifti_mat33_determ( mat33 R ) /* determinant of 3x3 matrix */ r21 = R.m[1][0]; r22 = R.m[1][1]; r23 = R.m[1][2]; /* [ r21 r22 r23 ] */ r31 = R.m[2][0]; r32 = R.m[2][1]; r33 = R.m[2][2]; /* [ r31 r32 r33 ] */ - return r11*r22*r33-r11*r32*r23-r21*r12*r33 - +r21*r32*r13+r31*r12*r23-r31*r22*r13 ; + return (float)(r11*r22*r33-r11*r32*r23-r21*r12*r33 + +r21*r32*r13+r31*r12*r23-r31*r22*r13) ; } /*----------------------------------------------------------------------*/ @@ -1836,9 +1836,9 @@ float nifti_mat33_rownorm( mat33 A ) /* max row norm of 3x3 matrix */ { float r1,r2,r3 ; - r1 = fabs(A.m[0][0])+fabs(A.m[0][1])+fabs(A.m[0][2]) ; - r2 = fabs(A.m[1][0])+fabs(A.m[1][1])+fabs(A.m[1][2]) ; - r3 = fabs(A.m[2][0])+fabs(A.m[2][1])+fabs(A.m[2][2]) ; + r1 = (float)( fabs(A.m[0][0])+fabs(A.m[0][1])+fabs(A.m[0][2]) ) ; + r2 = (float)( fabs(A.m[1][0])+fabs(A.m[1][1])+fabs(A.m[1][2]) ) ; + r3 = (float)( fabs(A.m[2][0])+fabs(A.m[2][1])+fabs(A.m[2][2]) ) ; if( r1 < r2 ) r1 = r2 ; if( r1 < r3 ) r1 = r3 ; return r1 ; @@ -1851,9 +1851,9 @@ float nifti_mat33_colnorm( mat33 A ) /* max column norm of 3x3 matrix */ { float r1,r2,r3 ; - r1 = fabs(A.m[0][0])+fabs(A.m[1][0])+fabs(A.m[2][0]) ; - r2 = fabs(A.m[0][1])+fabs(A.m[1][1])+fabs(A.m[2][1]) ; - r3 = fabs(A.m[0][2])+fabs(A.m[1][2])+fabs(A.m[2][2]) ; + r1 = (float)( fabs(A.m[0][0])+fabs(A.m[1][0])+fabs(A.m[2][0]) ) ; + r2 = (float)( fabs(A.m[0][1])+fabs(A.m[1][1])+fabs(A.m[2][1]) ) ; + r3 = (float)( fabs(A.m[0][2])+fabs(A.m[1][2])+fabs(A.m[2][2]) ) ; if( r1 < r2 ) r1 = r2 ; if( r1 < r3 ) r1 = r3 ; return r1 ; @@ -1884,7 +1884,7 @@ mat33 nifti_mat33_mul( mat33 A , mat33 B ) /* multiply 2 3x3 matrices */ mat33 nifti_mat33_polar( mat33 A ) { mat33 X , Y , Z ; - float alp,bet,gam,gmi , dif=1.0 ; + float alp,bet,gam,gmi , dif=1.0f ; int k=0 ; X = A ; @@ -1893,7 +1893,7 @@ mat33 nifti_mat33_polar( mat33 A ) gam = nifti_mat33_determ(X) ; while( gam == 0.0 ){ /* perturb matrix */ - gam = 0.00001 * ( 0.001 + nifti_mat33_rownorm(X) ) ; + gam = (float)( 0.00001 * ( 0.001 + nifti_mat33_rownorm(X) ) ) ; X.m[0][0] += gam ; X.m[1][1] += gam ; X.m[2][2] += gam ; gam = nifti_mat33_determ(X) ; } @@ -1901,28 +1901,28 @@ mat33 nifti_mat33_polar( mat33 A ) while(1){ Y = nifti_mat33_inverse(X) ; if( dif > 0.3 ){ /* far from convergence */ - alp = sqrt( nifti_mat33_rownorm(X) * nifti_mat33_colnorm(X) ) ; - bet = sqrt( nifti_mat33_rownorm(Y) * nifti_mat33_colnorm(Y) ) ; - gam = sqrt( bet / alp ) ; - gmi = 1.0 / gam ; + alp = (float)( sqrt( nifti_mat33_rownorm(X) * nifti_mat33_colnorm(X) ) ) ; + bet = (float)( sqrt( nifti_mat33_rownorm(Y) * nifti_mat33_colnorm(Y) ) ) ; + gam = (float)( sqrt( bet / alp ) ) ; + gmi = (float)( 1.0 / gam ) ; } else { - gam = gmi = 1.0 ; /* close to convergence */ + gam = gmi = 1.0f ; /* close to convergence */ } - Z.m[0][0] = 0.5 * ( gam*X.m[0][0] + gmi*Y.m[0][0] ) ; - Z.m[0][1] = 0.5 * ( gam*X.m[0][1] + gmi*Y.m[1][0] ) ; - Z.m[0][2] = 0.5 * ( gam*X.m[0][2] + gmi*Y.m[2][0] ) ; - Z.m[1][0] = 0.5 * ( gam*X.m[1][0] + gmi*Y.m[0][1] ) ; - Z.m[1][1] = 0.5 * ( gam*X.m[1][1] + gmi*Y.m[1][1] ) ; - Z.m[1][2] = 0.5 * ( gam*X.m[1][2] + gmi*Y.m[2][1] ) ; - Z.m[2][0] = 0.5 * ( gam*X.m[2][0] + gmi*Y.m[0][2] ) ; - Z.m[2][1] = 0.5 * ( gam*X.m[2][1] + gmi*Y.m[1][2] ) ; - Z.m[2][2] = 0.5 * ( gam*X.m[2][2] + gmi*Y.m[2][2] ) ; - - dif = fabs(Z.m[0][0]-X.m[0][0])+fabs(Z.m[0][1]-X.m[0][1]) + Z.m[0][0] = (float)( 0.5 * ( gam*X.m[0][0] + gmi*Y.m[0][0] ) ) ; + Z.m[0][1] = (float)( 0.5 * ( gam*X.m[0][1] + gmi*Y.m[1][0] ) ) ; + Z.m[0][2] = (float)( 0.5 * ( gam*X.m[0][2] + gmi*Y.m[2][0] ) ) ; + Z.m[1][0] = (float)( 0.5 * ( gam*X.m[1][0] + gmi*Y.m[0][1] ) ) ; + Z.m[1][1] = (float)( 0.5 * ( gam*X.m[1][1] + gmi*Y.m[1][1] ) ) ; + Z.m[1][2] = (float)( 0.5 * ( gam*X.m[1][2] + gmi*Y.m[2][1] ) ) ; + Z.m[2][0] = (float)( 0.5 * ( gam*X.m[2][0] + gmi*Y.m[0][2] ) ) ; + Z.m[2][1] = (float)( 0.5 * ( gam*X.m[2][1] + gmi*Y.m[1][2] ) ) ; + Z.m[2][2] = (float)( 0.5 * ( gam*X.m[2][2] + gmi*Y.m[2][2] ) ) ; + + dif = (float)( fabs(Z.m[0][0]-X.m[0][0])+fabs(Z.m[0][1]-X.m[0][1]) +fabs(Z.m[0][2]-X.m[0][2])+fabs(Z.m[1][0]-X.m[1][0]) +fabs(Z.m[1][1]-X.m[1][1])+fabs(Z.m[1][2]-X.m[1][2]) +fabs(Z.m[2][0]-X.m[2][0])+fabs(Z.m[2][1]-X.m[2][1]) - +fabs(Z.m[2][2]-X.m[2][2]) ; + +fabs(Z.m[2][2]-X.m[2][2]) ); k = k+1 ; if( k > 100 || dif < 3.e-6 ) break ; /* convergence or exhaustion */ @@ -1979,13 +1979,13 @@ void nifti_mat44_to_orientation( mat44 R , int *icod, int *jcod, int *kcod ) /* normalize i axis */ - val = sqrt( xi*xi + yi*yi + zi*zi ) ; + val = (float)sqrt( xi*xi + yi*yi + zi*zi ) ; if( val == 0.0 ) return ; /* stupid input */ xi /= val ; yi /= val ; zi /= val ; /* normalize j axis */ - val = sqrt( xj*xj + yj*yj + zj*zj ) ; + val = (float)sqrt( xj*xj + yj*yj + zj*zj ) ; if( val == 0.0 ) return ; /* stupid input */ xj /= val ; yj /= val ; zj /= val ; @@ -1994,14 +1994,14 @@ void nifti_mat44_to_orientation( mat44 R , int *icod, int *jcod, int *kcod ) val = xi*xj + yi*yj + zi*zj ; /* dot product between i and j */ if( fabs(val) > 1.e-4 ){ xj -= val*xi ; yj -= val*yi ; zj -= val*zi ; - val = sqrt( xj*xj + yj*yj + zj*zj ) ; /* must renormalize */ + val = (float)sqrt( xj*xj + yj*yj + zj*zj ) ; /* must renormalize */ if( val == 0.0 ) return ; /* j was parallel to i? */ xj /= val ; yj /= val ; zj /= val ; } /* normalize k axis; if it is zero, make it the cross product i x j */ - val = sqrt( xk*xk + yk*yk + zk*zk ) ; + val = (float)sqrt( xk*xk + yk*yk + zk*zk ) ; if( val == 0.0 ){ xk = yi*zj-zi*yj; yk = zi*xj-zj*xi ; zk=xi*yj-yi*xj ; } else { xk /= val ; yk /= val ; zk /= val ; } @@ -2010,7 +2010,7 @@ void nifti_mat44_to_orientation( mat44 R , int *icod, int *jcod, int *kcod ) val = xi*xk + yi*yk + zi*zk ; /* dot product between i and k */ if( fabs(val) > 1.e-4 ){ xk -= val*xi ; yk -= val*yi ; zk -= val*zi ; - val = sqrt( xk*xk + yk*yk + zk*zk ) ; + val = (float)sqrt( xk*xk + yk*yk + zk*zk ) ; if( val == 0.0 ) return ; /* bad */ xk /= val ; yk /= val ; zk /= val ; } @@ -2020,7 +2020,7 @@ void nifti_mat44_to_orientation( mat44 R , int *icod, int *jcod, int *kcod ) val = xj*xk + yj*yk + zj*zk ; /* dot product between j and k */ if( fabs(val) > 1.e-4 ){ xk -= val*xj ; yk -= val*yj ; zk -= val*zj ; - val = sqrt( xk*xk + yk*yk + zk*zk ) ; + val = (float)sqrt( xk*xk + yk*yk + zk*zk ) ; if( val == 0.0 ) return ; /* bad */ xk /= val ; yk /= val ; zk /= val ; } @@ -2041,7 +2041,7 @@ void nifti_mat44_to_orientation( mat44 R , int *icod, int *jcod, int *kcod ) /* Despite the formidable looking 6 nested loops, there are only 3*3*3*2*2*2 = 216 passes, which will run very quickly. */ - vbest = -666.0 ; ibest=pbest=qbest=rbest=1 ; jbest=2 ; kbest=3 ; + vbest = -666.0f ; ibest=pbest=qbest=rbest=1 ; jbest=2 ; kbest=3 ; for( i=1 ; i <= 3 ; i++ ){ /* i = column number to use for row #1 */ for( j=1 ; j <= 3 ; j++ ){ /* j = column number to use for row #2 */ if( i == j ) continue ; @@ -2049,7 +2049,7 @@ void nifti_mat44_to_orientation( mat44 R , int *icod, int *jcod, int *kcod ) if( i == k || j == k ) continue ; P.m[0][0] = P.m[0][1] = P.m[0][2] = P.m[1][0] = P.m[1][1] = P.m[1][2] = - P.m[2][0] = P.m[2][1] = P.m[2][2] = 0.0 ; + P.m[2][0] = P.m[2][1] = P.m[2][2] = 0.0f ; for( p=-1 ; p <= 1 ; p+=2 ){ /* p,q,r are -1 or +1 */ for( q=-1 ; q <= 1 ; q+=2 ){ /* and go into rows #1,2,3 */ for( r=-1 ; r <= 1 ; r+=2 ){ @@ -3192,7 +3192,7 @@ static int fileext_compare(const char * test_ext, const char * known_ext) /* if here, strings are different but need to check upper-case */ - for(c = 0; c < len; c++ ) caps[c] = toupper(known_ext[c]); + for(c = 0; c < len; c++ ) caps[c] = toupper((int) known_ext[c]); caps[c] = '\0'; return strcmp(test_ext, caps); @@ -3217,7 +3217,7 @@ static int fileext_n_compare(const char * test_ext, if( len > 7 ) return cmp; /* if here, strings are different but need to check upper-case */ - for(c = 0; c < len; c++ ) caps[c] = toupper(known_ext[c]); + for(c = 0; c < len; c++ ) caps[c] = toupper((int) known_ext[c]); caps[c] = '\0'; return strncmp(test_ext, caps, maxlen); @@ -3232,8 +3232,8 @@ static int is_uppercase(const char * str) if( !str || !*str ) return 0; for(c = 0; c < strlen(str); c++ ) { - if( islower(str[c]) ) return 0; - if( !hasupper && isupper(str[c]) ) hasupper = 1; + if( islower((int) str[c]) ) return 0; + if( !hasupper && isupper((int) str[c]) ) hasupper = 1; } return hasupper; @@ -3248,8 +3248,8 @@ static int is_mixedcase(const char * str) if( !str || !*str ) return 0; for(c = 0; c < strlen(str); c++ ) { - if( !haslower && islower(str[c]) ) haslower = 1; - if( !hasupper && isupper(str[c]) ) hasupper = 1; + if( !haslower && islower((int) str[c]) ) haslower = 1; + if( !hasupper && isupper((int) str[c]) ) hasupper = 1; if( haslower && hasupper ) return 1; } @@ -3265,7 +3265,7 @@ static int make_uppercase(char * str) if( !str || !*str ) return 0; for(c = 0; c < strlen(str); c++ ) - if( islower(str[c]) ) str[c] = toupper(str[c]); + if( islower((int) str[c]) ) str[c] = toupper((int) str[c]); return 0; } @@ -3277,7 +3277,7 @@ static int make_lowercase(char * str) if( !str || !*str ) return 0; for(c = 0; c < strlen(str); c++ ) - if( isupper(str[c]) ) str[c] = tolower(str[c]); + if( isupper((int) str[c]) ) str[c] = tolower((int) str[c]); return 0; } @@ -3646,7 +3646,7 @@ nifti_image* nifti_convert_nhdr2nim(struct nifti_1_header nhdr, for( ii=1 ; ii <= nhdr.dim[0] ; ii++ ){ if( nhdr.pixdim[ii] == 0.0 || - !IS_GOOD_FLOAT(nhdr.pixdim[ii]) ) nhdr.pixdim[ii] = 1.0 ; + !IS_GOOD_FLOAT(nhdr.pixdim[ii]) ) nhdr.pixdim[ii] = 1.0f ; } is_onefile = is_nifti && NIFTI_ONEFILE(nhdr) ; @@ -3702,14 +3702,14 @@ nifti_image* nifti_convert_nhdr2nim(struct nifti_1_header nhdr, /* off diagonal is zero */ - nim->qto_xyz.m[0][1]=nim->qto_xyz.m[0][2]=nim->qto_xyz.m[0][3] = 0.0; - nim->qto_xyz.m[1][0]=nim->qto_xyz.m[1][2]=nim->qto_xyz.m[1][3] = 0.0; - nim->qto_xyz.m[2][0]=nim->qto_xyz.m[2][1]=nim->qto_xyz.m[2][3] = 0.0; + nim->qto_xyz.m[0][1]=nim->qto_xyz.m[0][2]=nim->qto_xyz.m[0][3] = 0.0f; + nim->qto_xyz.m[1][0]=nim->qto_xyz.m[1][2]=nim->qto_xyz.m[1][3] = 0.0f; + nim->qto_xyz.m[2][0]=nim->qto_xyz.m[2][1]=nim->qto_xyz.m[2][3] = 0.0f; /* last row is always [ 0 0 0 1 ] */ - nim->qto_xyz.m[3][0]=nim->qto_xyz.m[3][1]=nim->qto_xyz.m[3][2] = 0.0; - nim->qto_xyz.m[3][3]= 1.0 ; + nim->qto_xyz.m[3][0]=nim->qto_xyz.m[3][1]=nim->qto_xyz.m[3][2] = 0.0f; + nim->qto_xyz.m[3][3]= 1.0f ; nim->qform_code = NIFTI_XFORM_UNKNOWN ; @@ -3725,7 +3725,7 @@ nifti_image* nifti_convert_nhdr2nim(struct nifti_1_header nhdr, nim->qoffset_y = FIXED_FLOAT(nhdr.qoffset_y) ; nim->qoffset_z = FIXED_FLOAT(nhdr.qoffset_z) ; - nim->qfac = (nhdr.pixdim[0] < 0.0) ? -1.0 : 1.0 ; /* left-handedness? */ + nim->qfac = (nhdr.pixdim[0] < 0.0) ? -1.0f : 1.0f ; /* left-handedness? */ nim->qto_xyz = nifti_quatern_to_mat44( nim->quatern_b, nim->quatern_c, nim->quatern_d, @@ -3772,8 +3772,8 @@ nifti_image* nifti_convert_nhdr2nim(struct nifti_1_header nhdr, /* last row is always [ 0 0 0 1 ] */ - nim->sto_xyz.m[3][0]=nim->sto_xyz.m[3][1]=nim->sto_xyz.m[3][2] = 0.0; - nim->sto_xyz.m[3][3]= 1.0 ; + nim->sto_xyz.m[3][0]=nim->sto_xyz.m[3][1]=nim->sto_xyz.m[3][2] = 0.0f; + nim->sto_xyz.m[3][3]= 1.0f ; nim->sto_ijk = nifti_mat44_inverse( nim->sto_xyz ) ; @@ -5226,9 +5226,9 @@ nifti_image* nifti_simple_init_nim(void) nhdr.dim[1] = 1 ; nhdr.dim[2] = 1 ; nhdr.dim[3] = 1 ; nhdr.dim[4] = 0 ; - nhdr.pixdim[0] = 0.0 ; - nhdr.pixdim[1] = 1.0 ; nhdr.pixdim[2] = 1.0 ; - nhdr.pixdim[3] = 1.0 ; + nhdr.pixdim[0] = 0.0f ; + nhdr.pixdim[1] = 1.0f ; nhdr.pixdim[2] = 1.0f ; + nhdr.pixdim[3] = 1.0f ; nhdr.datatype = DT_FLOAT32 ; nifti_datatype_sizes( nhdr.datatype , &nbyper, &swapsize ); @@ -5305,10 +5305,10 @@ nifti_1_header * nifti_make_new_header(const int arg_dims[], int arg_dtype) /* init dim and pixdim */ nhdr->dim[0] = dim[0] ; - nhdr->pixdim[0] = 0.0; + nhdr->pixdim[0] = 0.0f; for( c = 1; c <= dim[0]; c++ ) { nhdr->dim[c] = dim[c]; - nhdr->pixdim[c] = 1.0; + nhdr->pixdim[c] = 1.0f; } nhdr->datatype = dtype ; @@ -5394,7 +5394,7 @@ struct nifti_1_header nifti_convert_nim2nhdr(const nifti_image * nim) nhdr.dim[4] = nim->nt ; nhdr.dim[5] = nim->nu ; nhdr.dim[6] = nim->nv ; nhdr.dim[7] = nim->nw ; - nhdr.pixdim[0] = 0.0 ; + nhdr.pixdim[0] = 0.0f ; nhdr.pixdim[1] = nim->dx ; nhdr.pixdim[2] = nim->dy ; nhdr.pixdim[3] = nim->dz ; nhdr.pixdim[4] = nim->dt ; nhdr.pixdim[5] = nim->du ; nhdr.pixdim[6] = nim->dv ; @@ -5427,10 +5427,10 @@ struct nifti_1_header nifti_convert_nim2nhdr(const nifti_image * nim) if( nim->nifti_type == NIFTI_FTYPE_NIFTI1_1 ) strcpy(nhdr.magic,"n+1") ; else strcpy(nhdr.magic,"ni1") ; - nhdr.pixdim[1] = fabs(nhdr.pixdim[1]) ; nhdr.pixdim[2] = fabs(nhdr.pixdim[2]) ; - nhdr.pixdim[3] = fabs(nhdr.pixdim[3]) ; nhdr.pixdim[4] = fabs(nhdr.pixdim[4]) ; - nhdr.pixdim[5] = fabs(nhdr.pixdim[5]) ; nhdr.pixdim[6] = fabs(nhdr.pixdim[6]) ; - nhdr.pixdim[7] = fabs(nhdr.pixdim[7]) ; + nhdr.pixdim[1] = (float)fabs(nhdr.pixdim[1]) ; nhdr.pixdim[2] = (float)fabs(nhdr.pixdim[2]) ; + nhdr.pixdim[3] = (float)fabs(nhdr.pixdim[3]) ; nhdr.pixdim[4] = (float)fabs(nhdr.pixdim[4]) ; + nhdr.pixdim[5] = (float)fabs(nhdr.pixdim[5]) ; nhdr.pixdim[6] = (float)fabs(nhdr.pixdim[6]) ; + nhdr.pixdim[7] = (float)fabs(nhdr.pixdim[7]) ; nhdr.intent_code = nim->intent_code ; nhdr.intent_p1 = nim->intent_p1 ; @@ -5453,7 +5453,7 @@ struct nifti_1_header nifti_convert_nim2nhdr(const nifti_image * nim) nhdr.qoffset_x = nim->qoffset_x ; nhdr.qoffset_y = nim->qoffset_y ; nhdr.qoffset_z = nim->qoffset_z ; - nhdr.pixdim[0] = (nim->qfac >= 0.0) ? 1.0 : -1.0 ; + nhdr.pixdim[0] = (nim->qfac >= 0.0) ? 1.0f : -1.0f ; } if( nim->sform_code > 0 ){ @@ -5942,7 +5942,7 @@ static int unescape_string( char *str ) else if( ii+3 < ll && str[ii+1] == '#' && - isdigit(str[ii+2]) ){ /* &#dec; */ + isdigit((int) str[ii+2]) ){ /* &#dec; */ unsigned int val='?' ; int kk=ii+3 ; while( kk < ll && kk != ';' ) kk++ ; @@ -5953,7 +5953,7 @@ static int unescape_string( char *str ) else if( ii+4 < ll && str[ii+1] == '#' && str[ii+2] == 'x' && - isxdigit(str[ii+3]) ){ /* &#hex; */ + isxdigit((int) str[ii+3]) ){ /* &#hex; */ unsigned int val='?' ; int kk=ii+4 ; while( kk < ll && kk != ';' ) kk++ ; @@ -6310,11 +6310,11 @@ int nifti_short_order(void) /* determine this CPU's byte order */ /* macro to check lhs string against "n1"; if it matches, interpret rhs string as a number, and put it into nim->"n2" */ -#define QQNUM(n1,n2) if( strcmp(lhs,#n1)==0 ) nim->n2=strtod(rhs,NULL) +#define QQNUM(n1,n2,tt) if( strcmp(lhs,#n1)==0 ) nim->n2=(tt)strtod(rhs,NULL) /* same, but where "n1" == "n2" */ -#define QNUM(nam) QQNUM(nam,nam) +#define QNUM(nam,tt) QQNUM(nam,nam,tt) /* macro to check lhs string against "nam"; if it matches, put rhs string into nim->"nam" string, with max length = "ml" */ @@ -6357,7 +6357,7 @@ nifti_image *nifti_image_from_ascii( const char *str, int * bytes_read ) = nim->nu = nim->nv = nim->nw = 1 ; nim->dx = nim->dy = nim->dz = nim->dt = nim->du = nim->dv = nim->dw = 0 ; - nim->qfac = 1.0 ; + nim->qfac = 1.0f ; nim->byteorder = nifti_short_order() ; @@ -6429,54 +6429,54 @@ nifti_image *nifti_image_from_ascii( const char *str, int * bytes_read ) if( strcmp(rhs,"MSB_FIRST") == 0 ) nim->byteorder = MSB_FIRST ; if( strcmp(rhs,"LSB_FIRST") == 0 ) nim->byteorder = LSB_FIRST ; } - else QQNUM(image_offset,iname_offset) ; - else QNUM(datatype) ; - else QNUM(ndim) ; - else QNUM(nx) ; - else QNUM(ny) ; - else QNUM(nz) ; - else QNUM(nt) ; - else QNUM(nu) ; - else QNUM(nv) ; - else QNUM(nw) ; - else QNUM(dx) ; - else QNUM(dy) ; - else QNUM(dz) ; - else QNUM(dt) ; - else QNUM(du) ; - else QNUM(dv) ; - else QNUM(dw) ; - else QNUM(cal_min) ; - else QNUM(cal_max) ; - else QNUM(scl_slope) ; - else QNUM(scl_inter) ; - else QNUM(intent_code) ; - else QNUM(intent_p1) ; - else QNUM(intent_p2) ; - else QNUM(intent_p3) ; + else QQNUM(image_offset,iname_offset,int) ; + else QNUM(datatype,short int) ; + else QNUM(ndim,int) ; + else QNUM(nx,int) ; + else QNUM(ny,int) ; + else QNUM(nz,int) ; + else QNUM(nt,int) ; + else QNUM(nu,int) ; + else QNUM(nv,int) ; + else QNUM(nw,int) ; + else QNUM(dx,float) ; + else QNUM(dy,float) ; + else QNUM(dz,float) ; + else QNUM(dt,float) ; + else QNUM(du,float) ; + else QNUM(dv,float) ; + else QNUM(dw,float) ; + else QNUM(cal_min,float) ; + else QNUM(cal_max,float) ; + else QNUM(scl_slope,float) ; + else QNUM(scl_inter,float) ; + else QNUM(intent_code,short) ; + else QNUM(intent_p1,float) ; + else QNUM(intent_p2,float) ; + else QNUM(intent_p3,float) ; else QSTR(intent_name,15) ; - else QNUM(toffset) ; - else QNUM(xyz_units) ; - else QNUM(time_units) ; + else QNUM(toffset,float) ; + else QNUM(xyz_units,int) ; + else QNUM(time_units,int) ; else QSTR(descrip,79) ; else QSTR(aux_file,23) ; - else QNUM(qform_code) ; - else QNUM(quatern_b) ; - else QNUM(quatern_c) ; - else QNUM(quatern_d) ; - else QNUM(qoffset_x) ; - else QNUM(qoffset_y) ; - else QNUM(qoffset_z) ; - else QNUM(qfac) ; - else QNUM(sform_code) ; - else QNUM(freq_dim) ; - else QNUM(phase_dim) ; - else QNUM(slice_dim) ; - else QNUM(slice_code) ; - else QNUM(slice_start) ; - else QNUM(slice_end) ; - else QNUM(slice_duration) ; - else QNUM(num_ext) ; + else QNUM(qform_code,int) ; + else QNUM(quatern_b,float) ; + else QNUM(quatern_c,float) ; + else QNUM(quatern_d,float) ; + else QNUM(qoffset_x,float) ; + else QNUM(qoffset_y,float) ; + else QNUM(qoffset_z,float) ; + else QNUM(qfac,float) ; + else QNUM(sform_code,int) ; + else QNUM(freq_dim,int) ; + else QNUM(phase_dim,int) ; + else QNUM(slice_dim,int) ; + else QNUM(slice_code,int) ; + else QNUM(slice_start,int) ; + else QNUM(slice_end,int) ; + else QNUM(slice_duration,float) ; + else QNUM(num_ext,int) ; } /* end of while loop */ @@ -6509,8 +6509,8 @@ nifti_image *nifti_image_from_ascii( const char *str, int * bytes_read ) nim->qfac ) ; else nim->qto_xyz = nifti_quatern_to_mat44( - 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , - nim->dx , nim->dy , nim->dz , 0.0 ) ; + 0.0f , 0.0f , 0.0f , 0.0f , 0.0f , 0.0f , + nim->dx , nim->dy , nim->dz , 0.0f ) ; nim->qto_ijk = nifti_mat44_inverse( nim->qto_xyz ) ; diff --git a/Utilities/ITK/Utilities/openjpeg/event.c b/Utilities/ITK/Utilities/openjpeg/event.c index c8ae53916cabf95f1f934be2e05c8aca6373bd39..46410e2c594d9777b6de31b839c6aa307d736a5a 100644 --- a/Utilities/ITK/Utilities/openjpeg/event.c +++ b/Utilities/ITK/Utilities/openjpeg/event.c @@ -111,7 +111,7 @@ bool opj_event_msg(opj_common_ptr cinfo, int event_type, const char *fmt, ...) { for (i = 0, j = 0; i < str_length; ++i) { if (fmt[i] == '%') { if (i + 1 < str_length) { - switch(tolower(fmt[i + 1])) { + switch(tolower((int) fmt[i + 1])) { case '%' : message[j++] = '%'; break; diff --git a/Utilities/ITK/Utilities/vxl/config/cmake/DSPTemplates/mex/configure b/Utilities/ITK/Utilities/vxl/config/cmake/DSPTemplates/mex/configure old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Utilities/vxl/config/cmake/DSPTemplates/mex/install-sh b/Utilities/ITK/Utilities/vxl/config/cmake/DSPTemplates/mex/install-sh old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Utilities/vxl/config/cmake/Modules/CheckPrototypeExists.cxx.in b/Utilities/ITK/Utilities/vxl/config/cmake/Modules/CheckPrototypeExists.cxx.in old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Utilities/vxl/config/cmake/Modules/CheckPrototypeExistsCXX.cmake b/Utilities/ITK/Utilities/vxl/config/cmake/Modules/CheckPrototypeExistsCXX.cmake old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Utilities/vxl/config/cmake/Modules/FindDCMTK.cmake b/Utilities/ITK/Utilities/vxl/config/cmake/Modules/FindDCMTK.cmake old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Utilities/vxl/config/cmake/Modules/NewCMake/FindDCMTK.cmake b/Utilities/ITK/Utilities/vxl/config/cmake/Modules/NewCMake/FindDCMTK.cmake old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Utilities/vxl/core/vnl/Templates/vnl_matrix_fixed+double.1.6-.cxx b/Utilities/ITK/Utilities/vxl/core/vnl/Templates/vnl_matrix_fixed+double.1.6-.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Utilities/vxl/core/vnl/Templates/vnl_matrix_fixed+double.2.8-.cxx b/Utilities/ITK/Utilities/vxl/core/vnl/Templates/vnl_matrix_fixed+double.2.8-.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Utilities/vxl/core/vnl/Templates/vnl_matrix_fixed+double.2.9-.cxx b/Utilities/ITK/Utilities/vxl/core/vnl/Templates/vnl_matrix_fixed+double.2.9-.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Utilities/vxl/core/vnl/Templates/vnl_matrix_fixed+double.3.6-.cxx b/Utilities/ITK/Utilities/vxl/core/vnl/Templates/vnl_matrix_fixed+double.3.6-.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Utilities/vxl/core/vnl/Templates/vnl_matrix_fixed+double.3.9-.cxx b/Utilities/ITK/Utilities/vxl/core/vnl/Templates/vnl_matrix_fixed+double.3.9-.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Utilities/vxl/core/vnl/Templates/vnl_matrix_fixed+double.4.20-.cxx b/Utilities/ITK/Utilities/vxl/core/vnl/Templates/vnl_matrix_fixed+double.4.20-.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Utilities/vxl/core/vnl/Templates/vnl_matrix_fixed+double.6.1-.cxx b/Utilities/ITK/Utilities/vxl/core/vnl/Templates/vnl_matrix_fixed+double.6.1-.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Utilities/vxl/core/vnl/Templates/vnl_matrix_fixed+double.6.3-.cxx b/Utilities/ITK/Utilities/vxl/core/vnl/Templates/vnl_matrix_fixed+double.6.3-.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Utilities/vxl/core/vnl/Templates/vnl_matrix_fixed+float.2.3-.cxx b/Utilities/ITK/Utilities/vxl/core/vnl/Templates/vnl_matrix_fixed+float.2.3-.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Utilities/vxl/core/vnl/Templates/vnl_matrix_fixed+float.6.6-.cxx b/Utilities/ITK/Utilities/vxl/core/vnl/Templates/vnl_matrix_fixed+float.6.6-.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Utilities/vxl/core/vnl/Templates/vnl_quaternion+float-.cxx b/Utilities/ITK/Utilities/vxl/core/vnl/Templates/vnl_quaternion+float-.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Utilities/vxl/core/vnl/Templates/vnl_vector_fixed+double.20-.cxx b/Utilities/ITK/Utilities/vxl/core/vnl/Templates/vnl_vector_fixed+double.20-.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Utilities/vxl/core/vnl/algo/CMakeLists.txt b/Utilities/ITK/Utilities/vxl/core/vnl/algo/CMakeLists.txt index 1dd872c17543640d9651575ef199bdaf5b5d88ce..329f3cdc90f027f6a3e8b22e75ed0e6834180047 100644 --- a/Utilities/ITK/Utilities/vxl/core/vnl/algo/CMakeLists.txt +++ b/Utilities/ITK/Utilities/vxl/core/vnl/algo/CMakeLists.txt @@ -26,7 +26,10 @@ IF(NETLIB_FOUND) # vnl_svd_economy csvdc_ dsvdc_ ssvdc_ zsvdc_ # vnl_symmetric_eigensystem rs_ - INCLUDE_DIRECTORIES( ${NETLIB_INCLUDE_DIR} ) + INCLUDE_DIRECTORIES( + ${NETLIB_INCLUDE_DIR} + ${NETLIB_INCLUDE_DIR}/linalg + ) SET( vnl_algo_sources vnl_algo_fwd.h @@ -63,7 +66,6 @@ IF(NETLIB_FOUND) vnl_brent_minimizer.cxx vnl_brent_minimizer.h # equation solvers - vnl_rpoly_roots.cxx vnl_rpoly_roots.h vnl_cpoly_roots.cxx vnl_cpoly_roots.h vnl_rnpoly_solve.cxx vnl_rnpoly_solve.h vnl_fit_parabola.h @@ -92,7 +94,7 @@ IF(NETLIB_FOUND) AUX_SOURCE_DIRECTORY(Templates vnl_algo_sources) ADD_LIBRARY( itkvnl_algo ${vnl_algo_sources}) - TARGET_LINK_LIBRARIES( itkvnl_algo ${NETLIB_LIBRARIES} itkvnl ) + TARGET_LINK_LIBRARIES( itkvnl_algo ${NETLIB_LIBRARIES} itkvnl itkv3p_lsqr ) IF(ITK_LIBRARY_PROPERTIES) SET_TARGET_PROPERTIES(itkvnl_algo PROPERTIES ${ITK_LIBRARY_PROPERTIES}) ENDIF(ITK_LIBRARY_PROPERTIES) diff --git a/Utilities/ITK/Utilities/vxl/core/vnl/algo/tests/CMakeLists.txt b/Utilities/ITK/Utilities/vxl/core/vnl/algo/tests/CMakeLists.txt index 5964d94069d9dfe4bda8a3bbcef56ebd881fc0d4..2c04f00201f2724595f59ea82543f742fa0eb9b2 100644 --- a/Utilities/ITK/Utilities/vxl/core/vnl/algo/tests/CMakeLists.txt +++ b/Utilities/ITK/Utilities/vxl/core/vnl/algo/tests/CMakeLists.txt @@ -35,7 +35,6 @@ IF(NETLIB_FOUND) test_rank.cxx test_real_eigensystem.cxx test_rnpoly_roots.cxx - test_rpoly_roots.cxx test_sparse_matrix.cxx test_svd.cxx #test_symmetric_eigensystem.cxx # Removing for ITK: needs vul @@ -72,7 +71,6 @@ IF(NETLIB_FOUND) ADD_TEST( vnl_test_rank ${EXECUTABLE_OUTPUT_PATH}/vnl_algo_test_all test_rank ) ADD_TEST( vnl_test_real_eigensystem ${EXECUTABLE_OUTPUT_PATH}/vnl_algo_test_all test_real_eigensystem ) ADD_TEST( vnl_test_rnpoly_roots ${EXECUTABLE_OUTPUT_PATH}/vnl_algo_test_all test_rnpoly_roots ) - ADD_TEST( vnl_test_rpoly_roots ${EXECUTABLE_OUTPUT_PATH}/vnl_algo_test_all test_rpoly_roots ) ADD_TEST( vnl_test_integral ${EXECUTABLE_OUTPUT_PATH}/vnl_algo_test_all test_integral ) ADD_TEST( vnl_test_solve_qp ${EXECUTABLE_OUTPUT_PATH}/vnl_algo_test_all test_solve_qp ) ADD_TEST( vnl_test_sparse_lu ${EXECUTABLE_OUTPUT_PATH}/vnl_algo_test_all test_sparse_lu ) diff --git a/Utilities/ITK/Utilities/vxl/core/vnl/algo/tests/test_driver.cxx b/Utilities/ITK/Utilities/vxl/core/vnl/algo/tests/test_driver.cxx index b0d3d3605a0d8fc69dd24904690e95a76e73d3f6..afdd4b7f2c1f3637fd6e7d9a94e244a338e6fd0b 100644 --- a/Utilities/ITK/Utilities/vxl/core/vnl/algo/tests/test_driver.cxx +++ b/Utilities/ITK/Utilities/vxl/core/vnl/algo/tests/test_driver.cxx @@ -22,7 +22,6 @@ DECLARE( test_qsvd ); DECLARE( test_rational ); DECLARE( test_real_eigensystem ); DECLARE( test_rnpoly_roots ); -DECLARE( test_rpoly_roots ); DECLARE( test_sparse_matrix ); DECLARE( test_integral ); DECLARE( test_svd ); @@ -58,7 +57,6 @@ register_tests() REGISTER( test_real_eigensystem ); REGISTER( test_integral ); REGISTER( test_rnpoly_roots ); - REGISTER( test_rpoly_roots ); REGISTER( test_sparse_matrix ); REGISTER( test_svd ); //REGISTER( test_symmetric_eigensystem ); diff --git a/Utilities/ITK/Utilities/vxl/core/vnl/algo/tests/test_include.cxx b/Utilities/ITK/Utilities/vxl/core/vnl/algo/tests/test_include.cxx index 4b231fc0a57af2d6edce1acfcb8b3550f7291d8b..a332486b278b1dc5b2a0098f22e24c4d7d7fb78e 100644 --- a/Utilities/ITK/Utilities/vxl/core/vnl/algo/tests/test_include.cxx +++ b/Utilities/ITK/Utilities/vxl/core/vnl/algo/tests/test_include.cxx @@ -33,7 +33,6 @@ #include <vnl/algo/vnl_qr.h> #include <vnl/algo/vnl_real_eigensystem.h> #include <vnl/algo/vnl_rnpoly_solve.h> -#include <vnl/algo/vnl_rpoly_roots.h> #include <vnl/algo/vnl_scatter_3x3.h> #include <vnl/algo/vnl_simpson_integral.h> #include <vnl/algo/vnl_solve_qp.h> diff --git a/Utilities/ITK/Utilities/vxl/core/vnl/algo/tests/test_rpoly_roots.cxx b/Utilities/ITK/Utilities/vxl/core/vnl/algo/tests/test_rpoly_roots.cxx deleted file mode 100644 index 99982bc2d8dec9e001d0e4938f2e997940943cf4..0000000000000000000000000000000000000000 --- a/Utilities/ITK/Utilities/vxl/core/vnl/algo/tests/test_rpoly_roots.cxx +++ /dev/null @@ -1,23 +0,0 @@ -#include <vnl/vnl_real_polynomial.h> -#include <vnl/algo/vnl_rpoly_roots.h> - -#include <testlib/testlib_test.h> - -void test_rpoly_roots() -{ - double coeffs[] = {5, 4, 3, 2, 1}; - vnl_vector<double> a(coeffs, 5); - - vnl_rpoly_roots roots(a); - - testlib_test_assert("Result sizes", (roots.real().size() == 4) && (roots.imag().size() == 4)); - testlib_test_assert("Complex size", (roots.roots().size() == 4)); - //testlib_test_assert("degree", roots.degree() == 4); - - // Evaluate results - vnl_real_polynomial p(a); - for (int i = 0; i < p.degree(); ++i) - testlib_test_assert("Root residual", vcl_abs(p.evaluate(roots[i])) < 1e-12); -} - -TESTMAIN(test_rpoly_roots); diff --git a/Utilities/ITK/Utilities/vxl/core/vnl/algo/tests/test_sparse_lu.cxx b/Utilities/ITK/Utilities/vxl/core/vnl/algo/tests/test_sparse_lu.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Utilities/vxl/core/vnl/algo/vnl_lsqr.cxx b/Utilities/ITK/Utilities/vxl/core/vnl/algo/vnl_lsqr.cxx index 41e8846d4e56eb59b5a342ab0300cdfc0d01d641..62244cba3e1d65429820aba92f08ebfbe0f3b721 100644 --- a/Utilities/ITK/Utilities/vxl/core/vnl/algo/vnl_lsqr.cxx +++ b/Utilities/ITK/Utilities/vxl/core/vnl/algo/vnl_lsqr.cxx @@ -16,6 +16,73 @@ #include <vnl/algo/vnl_netlib.h> // lsqr_() +#include "lsqrBase.h" + +class lsqrVNL : public lsqrBase +{ +public: + + lsqrVNL() + { + this->ls_ = NULL; + } + + virtual ~lsqrVNL() + { + } + + /** + * computes y = y + A*x without altering x, + * where A is a matrix of dimensions A[m][n]. + * The size of the vector x is n. + * The size of the vector y is m. + */ + void Aprod1(unsigned int m, unsigned int n, const double * x, double * y ) const + { + vnl_vector_ref<double> x_ref(n, const_cast<double*>(x) ); + vnl_vector_ref<double> y_ref(m,y); + + vnl_vector_ref<double> tmp(m,rw); + this->ls_->multiply(x_ref, tmp); + y_ref += tmp; + } + + + /** + * computes x = x + A'*y without altering y, + * where A is a matrix of dimensions A[m][n]. + * The size of the vector x is n. + * The size of the vector y is m. + */ + void Aprod2(unsigned int m, unsigned int n, double * x, const double * y ) const + { + vnl_vector_ref<double> x_ref(n,x); + vnl_vector_ref<double> y_ref(m, const_cast<double*>( y ) ); + + vnl_vector_ref<double> tmp(n,rw); + this->ls_->transpose_multiply(y_ref, tmp); + x_ref += tmp; + } + + /** Set the linear system to be solved A*x = b. */ + void SetLinearSystem( vnl_linear_system * inls ) + { + this->ls_ = inls; + } + + void SetWorkingSpace( double * inrw ) + { + this->rw = inrw; + } + +private: + + vnl_linear_system * ls_; + + double * rw; +}; + + vnl_lsqr::~vnl_lsqr() { } @@ -23,6 +90,11 @@ vnl_lsqr::~vnl_lsqr() // Requires number_of_residuals() of workspace in rw. int vnl_lsqr::aprod_(long* mode, long* m, long* n, double* x, double* y, long* /*leniw*/, long* /*lenrw*/, long* /*iw*/, double* rw, void* userdata) { + // + // THIS CODE IS DEPRECATED + // THE FUNCTIONALITY HAS BEEN MOVED TO THE lsqrVNL class above. + // THE FUNCTIONS IS CONSERVED HERE ONLY FOR BACKWARD COMPATIBILITY. + // vnl_lsqr* self = static_cast<vnl_lsqr*>(userdata); // If MODE = 1, compute y = y + A*x. @@ -73,16 +145,34 @@ int vnl_lsqr::minimize(vnl_vector<double>& result) vnl_vector<double> rhs(m); ls_->get_rhs(rhs); + lsqrVNL solver; + + solver.SetDamp( damp ); + solver.SetLinearSystem( this->ls_ ); + solver.SetWorkingSpace( &rw[0] ); + solver.SetMaximumNumberOfIterations( max_iter_ ); + solver.SetStandardErrorEstimates( &se[0] ); + solver.SetToleranceA( atol ); + solver.SetToleranceB( btol ); + + solver.Solve( m, n, rhs.data_block(), result.data_block() ); + +#ifdef THIS_CODE_IS_DISABLED_BECAUSE_THE_LSQR_CODE_FROM_NETLIB_WAS_COPYRIGHTED_BY_ACM v3p_netlib_lsqr_( &m, &n, aprod_, &damp, &leniw, &lenrw, iw, &rw[0], rhs.data_block(), &v[0], &w[0], result.data_block(), &se[0], &atol, &btol, &conlim, &max_iter_, &nout, &return_code_, &num_iter_, &anorm, &acond, &rnorm, &arnorm, &xnorm, this); +#endif - resid_norm_estimate_ = rnorm; - result_norm_estimate_ = xnorm; - A_condition_estimate_ = acond; + resid_norm_estimate_ = solver.GetFinalEstimateOfNormRbar(); + result_norm_estimate_ = solver.GetFinalEstimateOfNormOfX(); + A_condition_estimate_ = solver.GetConditionNumberEstimateOfAbar(); + return_code_ = solver.GetStoppingReason(); + num_iter_ = solver.GetNumberOfIterationsPerformed(); + anorm = solver.GetFrobeniusNormEstimateOfAbar(); + arnorm = solver.GetFinalEstimateOfNormOfResiduals(); #if 0 vcl_cerr << "A Fro norm estimate = " << anorm << vcl_endl diff --git a/Utilities/ITK/Utilities/vxl/core/vnl/algo/vnl_lsqr.h b/Utilities/ITK/Utilities/vxl/core/vnl/algo/vnl_lsqr.h index 546871a8189542fdfab878347f2c7dc964ad44df..666c0ed21a7b8143bed266766b4e0e3a81efe5b9 100644 --- a/Utilities/ITK/Utilities/vxl/core/vnl/algo/vnl_lsqr.h +++ b/Utilities/ITK/Utilities/vxl/core/vnl/algo/vnl_lsqr.h @@ -13,6 +13,13 @@ // of Paige and Saunders (ACM TOMS 583). The sparse system is encapsulated // by a vnl_linear_system. // +// The LSQR code from netlib was copyrighted by ACM, therefore it had to +// be removed, and has been replaced with code taken from +// http://www.stanford.edu/group/SOL/software.html +// Thas was distributed under a BSD license. The Fortran90 files were +// manually translated to C++ to create the solverBase class. +// +// // \author David Capel, capes@robots // \date July 2000 // diff --git a/Utilities/ITK/Utilities/vxl/core/vnl/algo/vnl_rpoly_roots.cxx b/Utilities/ITK/Utilities/vxl/core/vnl/algo/vnl_rpoly_roots.cxx deleted file mode 100644 index e31b66c88e954c24bc32bf425de9b2ea0982c7f2..0000000000000000000000000000000000000000 --- a/Utilities/ITK/Utilities/vxl/core/vnl/algo/vnl_rpoly_roots.cxx +++ /dev/null @@ -1,96 +0,0 @@ -// This is core/vnl/algo/vnl_rpoly_roots.cxx -#ifdef VCL_NEEDS_PRAGMA_INTERFACE -#pragma implementation -#endif -//: -// \file -// -// \author Andrew W. Fitzgibbon, Oxford RRG -// \date 06 Aug 96 -// -//----------------------------------------------------------------------------- - -#include "vnl_rpoly_roots.h" - -#include <vcl_cmath.h> // for fabs() -#include <vcl_iostream.h> -#include <vcl_complex.h> -#include <vnl/algo/vnl_netlib.h> // rpoly_() -#include <vnl/vnl_real_polynomial.h> - -// - The constructor calculates the roots. This is the most efficient interface -// as all the result variables are initialized to the correct size. -// The polynomial is $ a[0] x^d + a[1] x^{d-1} + \cdots + a[d] = 0 $. -// Note that if the routine fails, not all roots will be found. In this case, -// the "realroots" and "roots" functions will return fewer than n roots. -vnl_rpoly_roots::vnl_rpoly_roots(const vnl_vector<double>& a) - : coeffs_(a), r_(coeffs_.size()-1), i_(coeffs_.size()-1) -{ - // fsm : if the coefficients are NaNs then rpoly_ gets stuck in an - // infinite loop. of course, the caller shouldn't pass in NaNs, but - // it would be nice to get an error message instead of hanging. - a.assert_finite(); - - compute(); -} - -vnl_rpoly_roots::vnl_rpoly_roots(const vnl_real_polynomial& poly) - : coeffs_(poly.coefficients()), r_(poly.degree()), i_(poly.degree()) -{ - poly.coefficients().assert_finite(); - - compute(); -} - -// - Complex vector of all roots. -vnl_vector<vcl_complex<double> > vnl_rpoly_roots::roots() const -{ - vnl_vector<vcl_complex<double> > ret(num_roots_found_); - for (int i = 0; i < num_roots_found_; ++i) - ret[i] = vcl_complex<double>(r_[i], i_[i]); - return ret; -} - -// - Return real roots only. Roots are real if the absolute value -// of their imaginary part is less than the optional argument TOL. -// TOL defaults to 1e-12 [untested] -vnl_vector<double> vnl_rpoly_roots::realroots(double tol) const -{ - int c = 0; - for (int i = 0; i < num_roots_found_; ++i) - if (vcl_fabs(i_[i]) < tol) - ++c; - - vnl_vector<double> ret(c); - c = 0; - {for (int i = 0; i < num_roots_found_; ++i) - if (vcl_fabs(i_[i]) < tol) - ret[c++] = r_[i];} - - return ret; -} - -//: Compute roots using Jenkins-Traub algorithm. -// Calls rpoly and interprets failure codes. -bool vnl_rpoly_roots::compute() -{ - long fail = 0; - long n = coeffs_.size() - 1; - v3p_netlib_rpoly_global_t rpoly_global; - v3p_netlib_rpoly_(coeffs_.data_block(), &n, - r_.data_block(), i_.data_block(), &fail, &rpoly_global); - - if (!fail) { - num_roots_found_ = n; - return true; - } - - num_roots_found_ = n; - - if (coeffs_[0] == 0.0) - vcl_cerr << "vnl_rpoly_roots: Leading coefficient is zero. Not allowed.\n"; - else - vcl_cerr << "vnl_rpoly_roots: Calculation failed, only " << n << " roots found\n"; - - return false; -} diff --git a/Utilities/ITK/Utilities/vxl/core/vnl/algo/vnl_sparse_lu.cxx b/Utilities/ITK/Utilities/vxl/core/vnl/algo/vnl_sparse_lu.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Utilities/vxl/core/vnl/algo/vnl_sparse_lu.h b/Utilities/ITK/Utilities/vxl/core/vnl/algo/vnl_sparse_lu.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Utilities/vxl/core/vnl/io/Templates/vnl_io_matrix_fixed+double.3.3-.cxx b/Utilities/ITK/Utilities/vxl/core/vnl/io/Templates/vnl_io_matrix_fixed+double.3.3-.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Utilities/vxl/core/vnl/tests/test_quaternion.cxx b/Utilities/ITK/Utilities/vxl/core/vnl/tests/test_quaternion.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Utilities/vxl/core/vnl/vnl_math.cxx b/Utilities/ITK/Utilities/vxl/core/vnl/vnl_math.cxx index 948a7d9353b93fa814a3dc2512840ba15b939b82..cc237e542193f3e2265cc6e052c60f48d5639edf 100644 --- a/Utilities/ITK/Utilities/vxl/core/vnl/vnl_math.cxx +++ b/Utilities/ITK/Utilities/vxl/core/vnl/vnl_math.cxx @@ -10,7 +10,7 @@ #if defined(VCL_VC) || defined(__MINGW32__) // I don't think we need this, because <ieeefp.h> is available -- fsm -# include <Float.h> // for 'isnan' and 'finite' +# include <float.h> // for 'isnan' and 'finite' // # define isnan _isnan # define finite _finite # define finitef _finite diff --git a/Utilities/ITK/Utilities/vxl/core/vnl/vnl_matrix.h b/Utilities/ITK/Utilities/vxl/core/vnl/vnl_matrix.h index 6d606fd08acb8ffded5d6da6eb45cd2fe2b641de..818f0039e9a825aac7f7bf67a002f05b8af201a1 100644 --- a/Utilities/ITK/Utilities/vxl/core/vnl/vnl_matrix.h +++ b/Utilities/ITK/Utilities/vxl/core/vnl/vnl_matrix.h @@ -424,9 +424,12 @@ class vnl_matrix //: abort if size is not as expected // This function does or tests nothing if NDEBUG is defined +#ifdef NDEBUG + void assert_size(unsigned, unsigned ) const + { +#else void assert_size(unsigned r, unsigned c) const { -#ifndef NDEBUG assert_size_internal(r, c); #endif } diff --git a/Utilities/ITK/Utilities/vxl/core/vnl/vnl_matrix_fixed.h b/Utilities/ITK/Utilities/vxl/core/vnl/vnl_matrix_fixed.h index 9779e61d45346acc8cc6eaba8f9770ed42559127..f0cdc0ab3ffd5eb5519fc02b4f6f23bec5ec1f62 100644 --- a/Utilities/ITK/Utilities/vxl/core/vnl/vnl_matrix_fixed.h +++ b/Utilities/ITK/Utilities/vxl/core/vnl/vnl_matrix_fixed.h @@ -497,9 +497,12 @@ class vnl_matrix_fixed VNL_MATRIX_FIXED_VCL60_WORKAROUND //: abort if size is not as expected // This function does or tests nothing if NDEBUG is defined +#ifdef NDEBUG + void assert_size(unsigned, unsigned ) const + { +#else void assert_size(unsigned nr_rows, unsigned nr_cols) const { -#ifndef NDEBUG assert_size_internal(nr_rows, nr_cols); #endif } diff --git a/Utilities/ITK/Utilities/vxl/core/vnl/vnl_matrix_fixed_ref.h b/Utilities/ITK/Utilities/vxl/core/vnl/vnl_matrix_fixed_ref.h index 6df60194bee292b236062a702dc5bcd16d75100b..5bd7e18799bf6d65299acac9d2f88f23af1de100 100644 --- a/Utilities/ITK/Utilities/vxl/core/vnl/vnl_matrix_fixed_ref.h +++ b/Utilities/ITK/Utilities/vxl/core/vnl/vnl_matrix_fixed_ref.h @@ -340,9 +340,12 @@ class vnl_matrix_fixed_ref_const //: abort if size is not as expected // This function does or tests nothing if NDEBUG is defined +#ifdef NDEBUG + void assert_size(unsigned, unsigned ) const + { +#else void assert_size(unsigned rows, unsigned cols) const { -#ifndef NDEBUG assert_size_internal(rows, cols); #endif } diff --git a/Utilities/ITK/Utilities/vxl/core/vnl/vnl_sse.h b/Utilities/ITK/Utilities/vxl/core/vnl/vnl_sse.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Utilities/vxl/core/vnl/xio/Templates/vnl_xio_matrix_fixed+double.3.3-.cxx b/Utilities/ITK/Utilities/vxl/core/vnl/xio/Templates/vnl_xio_matrix_fixed+double.3.3-.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Utilities/vxl/core/vnl/xio/Templates/vnl_xio_quaternion+float-.cxx b/Utilities/ITK/Utilities/vxl/core/vnl/xio/Templates/vnl_xio_quaternion+float-.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Utilities/vxl/v3p/netlib/CMakeLists.txt b/Utilities/ITK/Utilities/vxl/v3p/netlib/CMakeLists.txt index ef0c3d02b4893de91c3e8582582ec1a99e2315d9..4e2b00d30057016bd9217e8f7aa4a1c134777d72 100644 --- a/Utilities/ITK/Utilities/vxl/v3p/netlib/CMakeLists.txt +++ b/Utilities/ITK/Utilities/vxl/v3p/netlib/CMakeLists.txt @@ -318,10 +318,6 @@ SET(V3P_NETLIB_opt_SOURCES opt/lbfgsb.c opt/lbfgsb.h ) SET(V3P_NETLIB_linalg_SOURCES - linalg/lsqr.c linalg/lsqr.h - ) -SET(V3P_NETLIB_toms_SOURCES - toms/rpoly.c toms/rpoly.h ) SET(V3P_NETLIB_datapac_SOURCES datapac/camsun.c datapac/camsun.h @@ -357,7 +353,6 @@ SET(v3p_netlib_sources ${V3P_NETLIB_minpack_SOURCES} ${V3P_NETLIB_opt_SOURCES} ${V3P_NETLIB_linalg_SOURCES} - ${V3P_NETLIB_toms_SOURCES} ${V3P_NETLIB_datapac_SOURCES} ${V3P_NETLIB_mathews_SOURCES} ${V3P_NETLIB_sparse_SOURCES} @@ -440,3 +435,5 @@ ENDIF(NOT VXL_INSTALL_NO_LIBRARIES) IF(NOT VXL_INSTALL_NO_DEVELOPMENT) INSTALL_NOBASE_HEADER_FILES(${VXL_INSTALL_ROOT}/v3p/netlib ${v3p_netlib_sources}) ENDIF(NOT VXL_INSTALL_NO_DEVELOPMENT) + +SUBDIRS(linalg) diff --git a/Utilities/ITK/Utilities/vxl/v3p/netlib/blas/caxpy.c b/Utilities/ITK/Utilities/vxl/v3p/netlib/blas/caxpy.c index 762c69485e0d106a6bd211876b75051a806bdfb3..3928b7f63cbf0f1745cb8b966d3c1e95e850dc72 100644 --- a/Utilities/ITK/Utilities/vxl/v3p/netlib/blas/caxpy.c +++ b/Utilities/ITK/Utilities/vxl/v3p/netlib/blas/caxpy.c @@ -48,8 +48,9 @@ extern "C" { return 0; } /*< if (abs(real(ca)) + abs(aimag(ca)) .eq. 0.0 ) return >*/ - if ((r__1 = ca->r, dabs(r__1)) + (r__2 = r_imag(ca), dabs(r__2)) == ( - float)0.) { + r__1 = ca->r; + r__2 = (real)(r_imag(ca)); + if ( dabs(r__1) + dabs(r__2) == (real)0.) { return 0; } /*< if(incx.eq.1.and.incy.eq.1)go to 20 >*/ diff --git a/Utilities/ITK/Utilities/vxl/v3p/netlib/libf2c/c_div.c b/Utilities/ITK/Utilities/vxl/v3p/netlib/libf2c/c_div.c index ac2fec4e81a8e861357347a60058067560af325b..4502bbb4dbca103f0576ec2f7ec4086d68bedc3a 100644 --- a/Utilities/ITK/Utilities/vxl/v3p/netlib/libf2c/c_div.c +++ b/Utilities/ITK/Utilities/vxl/v3p/netlib/libf2c/c_div.c @@ -36,7 +36,7 @@ void c_div(complex *c, complex *a, complex *b) ratio = (double)b->r / b->i ; den = b->i * (1 + ratio*ratio); cr = (a->r*ratio + a->i) / den; - c->i = (a->i*ratio - a->r) / den; + c->i = (real)((a->i*ratio - a->r) / den); } else @@ -44,9 +44,9 @@ void c_div(complex *c, complex *a, complex *b) ratio = (double)b->i / b->r ; den = b->r * (1 + ratio*ratio); cr = (a->r + a->i*ratio) / den; - c->i = (a->i - a->r*ratio) / den; + c->i = (real)((a->i - a->r*ratio) / den); } - c->r = cr; + c->r = (real)cr; } #ifdef __cplusplus } diff --git a/Utilities/ITK/Utilities/vxl/v3p/netlib/libf2c/c_sqrt.c b/Utilities/ITK/Utilities/vxl/v3p/netlib/libf2c/c_sqrt.c index 20f4ecee3b1820094ffa3702beab230cb37ace35..ace5bf153b4b076c96d7bfab1a3fdea1057afb34 100644 --- a/Utilities/ITK/Utilities/vxl/v3p/netlib/libf2c/c_sqrt.c +++ b/Utilities/ITK/Utilities/vxl/v3p/netlib/libf2c/c_sqrt.c @@ -22,21 +22,21 @@ void c_sqrt(complex *r, complex *z) double zi = z->i, zr = z->r; if( (mag = f__cabs(zr, zi)) == 0.) - r->r = r->i = 0.; + r->r = r->i = 0.0f; else if(zr > 0) { - r->r = t = sqrt(0.5 * (mag + zr) ); + r->r = (real)(t = sqrt(0.5 * (mag + zr) )); t = zi / t; - r->i = 0.5 * t; + r->i = (real)( 0.5 * t); } else { t = sqrt(0.5 * (mag - zr) ); if(zi < 0) t = -t; - r->i = t; + r->i = (real)t; t = zi / t; - r->r = 0.5 * t; + r->r = (real)(0.5 * t); } } #ifdef __cplusplus diff --git a/Utilities/ITK/Utilities/vxl/v3p/netlib/libf2c/cabs.c b/Utilities/ITK/Utilities/vxl/v3p/netlib/libf2c/cabs.c index 34375609dee0ee005bfe09a8c1963e05cd03d080..77fe8ab84f8c45390526ef76849c9c408740a7d4 100644 --- a/Utilities/ITK/Utilities/vxl/v3p/netlib/libf2c/cabs.c +++ b/Utilities/ITK/Utilities/vxl/v3p/netlib/libf2c/cabs.c @@ -5,32 +5,32 @@ #ifdef KR_headers extern double sqrt(); -double f__cabs(real, imag) double real, imag; +double f__cabs(real_value, imag_value) double real_value, imag_value; #else #undef abs #include "math.h" #ifdef __cplusplus extern "C" { #endif -double f__cabs(double real, double imag) +double f__cabs(double real_value, double imag_value) #endif { double temp; -if(real < 0) - real = -real; -if(imag < 0) - imag = -imag; -if(imag > real){ - temp = real; - real = imag; - imag = temp; +if(real_value < 0) + real_value = -real_value; +if(imag_value < 0) + imag_value = -imag_value; +if(imag_value > real_value){ + temp = real_value; + real_value = imag_value; + imag_value = temp; } -if((real+imag) == real) - return(real); +if((real_value+imag_value) == real_value) + return(real_value); -temp = imag/real; -temp = real*sqrt(1.0 + temp*temp); /*overflow!!*/ +temp = imag_value/real_value; +temp = real_value*sqrt(1.0 + temp*temp); /*overflow!!*/ return(temp); } #ifdef __cplusplus diff --git a/Utilities/ITK/Utilities/vxl/v3p/netlib/linalg/CMakeLists.txt b/Utilities/ITK/Utilities/vxl/v3p/netlib/linalg/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..ea24157d7b389c74a215eb5f2b71b838519cc377 --- /dev/null +++ b/Utilities/ITK/Utilities/vxl/v3p/netlib/linalg/CMakeLists.txt @@ -0,0 +1,28 @@ +# v3p/netlib/linalg/CMakeLists.txt + +PROJECT( lsqr ) + +# List sources for each library component. +SET(V3P_NETLIB_lsqr_SOURCES + lsqrBase.h + lsqrBase.cxx + ) + +# Create a library . +ADD_LIBRARY(itkv3p_lsqr ${V3P_NETLIB_lsqr_SOURCES}) +IF(UNIX) + TARGET_LINK_LIBRARIES( itkv3p_lsqr m ) +ENDIF(UNIX) +IF(ITK_LIBRARY_PROPERTIES) + SET_TARGET_PROPERTIES(itkv3p_lsqr PROPERTIES ${ITK_LIBRARY_PROPERTIES}) +ENDIF(ITK_LIBRARY_PROPERTIES) + +IF(NOT VXL_INSTALL_NO_LIBRARIES) + INSTALL(TARGETS itkv3p_lsqr + RUNTIME DESTINATION ${VXL_INSTALL_BIN_DIR_CM24} COMPONENT RuntimeLibraries + LIBRARY DESTINATION ${VXL_INSTALL_LIB_DIR_CM24} COMPONENT RuntimeLibraries + ARCHIVE DESTINATION ${VXL_INSTALL_LIB_DIR_CM24} COMPONENT Development) +ENDIF(NOT VXL_INSTALL_NO_LIBRARIES) +IF(NOT VXL_INSTALL_NO_DEVELOPMENT) + INSTALL_NOBASE_HEADER_FILES(${VXL_INSTALL_ROOT}/v3p/netlib ${V3P_NETLIB_lsqr_SOURCES}) +ENDIF(NOT VXL_INSTALL_NO_DEVELOPMENT) diff --git a/Utilities/ITK/Utilities/vxl/v3p/netlib/linalg/lsqr.P b/Utilities/ITK/Utilities/vxl/v3p/netlib/linalg/lsqr.P deleted file mode 100644 index a3dfe059508b21306aff6e881a5340f713adcb8c..0000000000000000000000000000000000000000 --- a/Utilities/ITK/Utilities/vxl/v3p/netlib/linalg/lsqr.P +++ /dev/null @@ -1,4 +0,0 @@ -extern int lsqr_(integer *m, integer *n, S_fp aprod, doublereal *damp, integer *leniw, integer *lenrw, integer *iw, doublereal *rw, doublereal *u, doublereal *v, doublereal *w, doublereal *x, doublereal *se, doublereal *atol, doublereal *btol, doublereal *conlim, integer *itnlim, integer *nout, integer *istop, integer *itn, doublereal *anorm, doublereal *acond, doublereal *rnorm, doublereal *arnorm, doublereal *xnorm); -/*:ref: dnrm2_ 7 3 4 7 4 */ -/*:ref: dscal_ 14 4 4 7 7 4 */ -/*:ref: dcopy_ 14 5 4 7 4 7 4 */ diff --git a/Utilities/ITK/Utilities/vxl/v3p/netlib/linalg/lsqr.c b/Utilities/ITK/Utilities/vxl/v3p/netlib/linalg/lsqr.c deleted file mode 100644 index aa306c4c393fdb9ee2d0abfdfe221aded14a6e7e..0000000000000000000000000000000000000000 --- a/Utilities/ITK/Utilities/vxl/v3p/netlib/linalg/lsqr.c +++ /dev/null @@ -1,855 +0,0 @@ -/* linalg/lsqr.f -- translated by f2c (version 20050501). - You must link the resulting object file with libf2c: - on Microsoft Windows system, link with libf2c.lib; - on Linux or Unix systems, link with .../path/to/libf2c.a -lm - or, if you install libf2c.a in a standard place, with -lf2c -lm - -- in that order, at the end of the command line, as in - cc *.o -lf2c -lm - Source for libf2c is in /netlib/f2c/libf2c.zip, e.g., - - http://www.netlib.org/f2c/libf2c.zip -*/ - -#ifdef __cplusplus -extern "C" { -#endif -#include "v3p_netlib.h" - -/* Table of constant values */ - -static integer c__1 = 1; -static integer c__2 = 2; - -/* From arpa!sol-michael.stanford.edu!mike 5 May 89 23:53:00 PDT */ -/*< >*/ -/* Subroutine */ int lsqr_(integer *m, integer *n, - int (*aprod)(v3p_netlib_integer*, - v3p_netlib_integer*, - v3p_netlib_integer*, - v3p_netlib_doublereal*, - v3p_netlib_doublereal*, - v3p_netlib_integer*, - v3p_netlib_integer*, - v3p_netlib_integer*, - v3p_netlib_doublereal*, - void*), - doublereal * - damp, integer *leniw, integer *lenrw, integer *iw, doublereal *rw, - doublereal *u, doublereal *v, doublereal *w, doublereal *x, - doublereal *se, doublereal *atol, doublereal *btol, doublereal * - conlim, integer *itnlim, integer *nout, integer *istop, integer *itn, - doublereal *anorm, doublereal *acond, doublereal *rnorm, doublereal * - arnorm, doublereal *xnorm, void* userdata) -{ - /* System generated locals */ - integer i__1; - doublereal d__1, d__2; - - /* Builtin functions */ - double sqrt(doublereal); - - /* Local variables */ - integer i__; - doublereal t, z__, t1, t2, t3, cs, sn, cs1, cs2, sn1, sn2, phi, rho, tau, - psi, rhs, res1, res2, alfa, beta, zbar, ctol, rtol; - extern doublereal dnrm2_(integer *, doublereal *, integer *); - doublereal test1, test2, test3, gamma; - extern /* Subroutine */ int dscal_(integer *, doublereal *, doublereal *, - integer *); - doublereal delta, theta, bnorm; - extern /* Subroutine */ int dcopy_(integer *, doublereal *, integer *, - doublereal *, integer *); - integer nconv, nstop; - doublereal rhbar1, rhbar2, gambar, phibar, rhobar, bbnorm, ddnorm, dampsq, - xxnorm; - -/*< EXTERNAL APROD >*/ -/*< INTEGER M, N, LENIW, LENRW, ITNLIM, NOUT, ISTOP, ITN >*/ -/*< INTEGER IW(LENIW) >*/ -/*< >*/ -/* ----------------------------------------------------------------------- */ - -/* LSQR finds a solution x to the following problems: */ - -/* 1. Unsymmetric equations -- solve A*x = b */ - -/* 2. Linear least squares -- solve A*x = b */ -/* in the least-squares sense */ - -/* 3. Damped least squares -- solve ( A )*x = ( b ) */ -/* ( damp*I ) ( 0 ) */ -/* in the least-squares sense */ - -/* where A is a matrix with m rows and n columns, b is an */ -/* m-vector, and damp is a scalar. (All quantities are real.) */ -/* The matrix A is intended to be large and sparse. It is accessed */ -/* by means of subroutine calls of the form */ - -/* CALL APROD ( mode, m, n, x, y, LENIW, LENRW, IW, RW ) */ - -/* which must perform the following functions: */ - -/* If MODE = 1, compute y = y + A*x. */ -/* If MODE = 2, compute x = x + A(transpose)*y. */ - -/* The vectors x and y are input parameters in both cases. */ -/* If mode = 1, y should be altered without changing x. */ -/* If mode = 2, x should be altered without changing y. */ -/* The parameters LENIW, LENRW, IW, RW may be used for workspace */ -/* as described below. */ - -/* The rhs vector b is input via U, and subsequently overwritten. */ - - -/* Note: LSQR uses an iterative method to approximate the solution. */ -/* The number of iterations required to reach a certain accuracy */ -/* depends strongly on the scaling of the problem. Poor scaling of */ -/* the rows or columns of A should therefore be avoided where */ -/* possible. */ - -/* For example, in problem 1 the solution is unaltered by */ -/* row-scaling. If a row of A is very small or large compared to */ -/* the other rows of A, the corresponding row of ( A b ) should be */ -/* scaled up or down. */ - -/* In problems 1 and 2, the solution x is easily recovered */ -/* following column-scaling. Unless better information is known, */ -/* the nonzero columns of A should be scaled so that they all have */ -/* the same Euclidean norm (e.g., 1.0). */ - -/* In problem 3, there is no freedom to re-scale if damp is */ -/* nonzero. However, the value of damp should be assigned only */ -/* after attention has been paid to the scaling of A. */ - -/* The parameter damp is intended to help regularize */ -/* ill-conditioned systems, by preventing the true solution from */ -/* being very large. Another aid to regularization is provided by */ -/* the parameter ACOND, which may be used to terminate iterations */ -/* before the computed solution becomes very large. */ - - -/* Notation */ -/* -------- */ - -/* The following quantities are used in discussing the subroutine */ -/* parameters: */ - -/* Abar = ( A ), bbar = ( b ) */ -/* ( damp*I ) ( 0 ) */ - -/* r = b - A*x, rbar = bbar - Abar*x */ - -/* rnorm = sqrt( norm(r)**2 + damp**2 * norm(x)**2 ) */ -/* = norm( rbar ) */ - -/* RELPR = the relative precision of floating-point arithmetic */ -/* on the machine being used. For example, on the IBM 370, */ -/* RELPR is about 1.0E-6 and 1.0D-16 in single and double */ -/* precision respectively. */ - -/* LSQR minimizes the function rnorm with respect to x. */ - - -/* Parameters */ -/* ---------- */ - -/* M input m, the number of rows in A. */ - -/* N input n, the number of columns in A. */ - -/* APROD external See above. */ - -/* DAMP input The damping parameter for problem 3 above. */ -/* (DAMP should be 0.0 for problems 1 and 2.) */ -/* If the system A*x = b is incompatible, values */ -/* of DAMP in the range 0 to sqrt(RELPR)*norm(A) */ -/* will probably have a negligible effect. */ -/* Larger values of DAMP will tend to decrease */ -/* the norm of x and reduce the number of */ -/* iterations required by LSQR. */ - -/* The work per iteration and the storage needed */ -/* by LSQR are the same for all values of DAMP. */ - -/* LENIW input The length of the workspace array IW. */ -/* LENRW input The length of the workspace array RW. */ -/* IW workspace An integer array of length LENIW. */ -/* RW workspace A real array of length LENRW. */ - -/* Note: LSQR does not explicitly use the previous four */ -/* parameters, but passes them to subroutine APROD for */ -/* possible use as workspace. If APROD does not need */ -/* IW or RW, the values LENIW = 1 or LENRW = 1 should */ -/* be used, and the actual parameters corresponding to */ -/* IW or RW may be any convenient array of suitable type. */ - -/* U(M) input The rhs vector b. Beware that U is */ -/* over-written by LSQR. */ - -/* V(N) workspace */ -/* W(N) workspace */ - -/* X(N) output Returns the computed solution x. */ - -/* SE(N) output Returns standard error estimates for the */ -/* components of X. For each i, SE(i) is set */ -/* to the value rnorm * sqrt( sigma(i,i) / T ), */ -/* where sigma(i,i) is an estimate of the i-th */ -/* diagonal of the inverse of Abar(transpose)*Abar */ -/* and T = 1 if m .le. n, */ -/* T = m - n if m .gt. n and damp = 0, */ -/* T = m if damp .ne. 0. */ - -/* ATOL input An estimate of the relative error in the data */ -/* defining the matrix A. For example, */ -/* if A is accurate to about 6 digits, set */ -/* ATOL = 1.0E-6 . */ - -/* BTOL input An extimate of the relative error in the data */ -/* defining the rhs vector b. For example, */ -/* if b is accurate to about 6 digits, set */ -/* BTOL = 1.0E-6 . */ - -/* CONLIM input An upper limit on cond(Abar), the apparent */ -/* condition number of the matrix Abar. */ -/* Iterations will be terminated if a computed */ -/* estimate of cond(Abar) exceeds CONLIM. */ -/* This is intended to prevent certain small or */ -/* zero singular values of A or Abar from */ -/* coming into effect and causing unwanted growth */ -/* in the computed solution. */ - -/* CONLIM and DAMP may be used separately or */ -/* together to regularize ill-conditioned systems. */ - -/* Normally, CONLIM should be in the range */ -/* 1000 to 1/RELPR. */ -/* Suggested value: */ -/* CONLIM = 1/(100*RELPR) for compatible systems, */ -/* CONLIM = 1/(10*sqrt(RELPR)) for least squares. */ - -/* Note: If the user is not concerned about the parameters */ -/* ATOL, BTOL and CONLIM, any or all of them may be set */ -/* to zero. The effect will be the same as the values */ -/* RELPR, RELPR and 1/RELPR respectively. */ - -/* ITNLIM input An upper limit on the number of iterations. */ -/* Suggested value: */ -/* ITNLIM = n/2 for well-conditioned systems */ -/* with clustered singular values, */ -/* ITNLIM = 4*n otherwise. */ - -/* NOUT input File number for printed output. If positive, */ -/* a summary will be printed on file NOUT. */ - -/* ISTOP output An integer giving the reason for termination: */ - -/* 0 x = 0 is the exact solution. */ -/* No iterations were performed. */ - -/* 1 The equations A*x = b are probably */ -/* compatible. Norm(A*x - b) is sufficiently */ -/* small, given the values of ATOL and BTOL. */ - -/* 2 The system A*x = b is probably not */ -/* compatible. A least-squares solution has */ -/* been obtained that is sufficiently accurate, */ -/* given the value of ATOL. */ - -/* 3 An estimate of cond(Abar) has exceeded */ -/* CONLIM. The system A*x = b appears to be */ -/* ill-conditioned. Otherwise, there could be an */ -/* error in subroutine APROD. */ - -/* 4 The equations A*x = b are probably */ -/* compatible. Norm(A*x - b) is as small as */ -/* seems reasonable on this machine. */ - -/* 5 The system A*x = b is probably not */ -/* compatible. A least-squares solution has */ -/* been obtained that is as accurate as seems */ -/* reasonable on this machine. */ - -/* 6 Cond(Abar) seems to be so large that there is */ -/* no point in doing further iterations, */ -/* given the precision of this machine. */ -/* There could be an error in subroutine APROD. */ - -/* 7 The iteration limit ITNLIM was reached. */ - -/* ITN output The number of iterations performed. */ - -/* ANORM output An estimate of the Frobenius norm of Abar. */ -/* This is the square-root of the sum of squares */ -/* of the elements of Abar. */ -/* If DAMP is small and if the columns of A */ -/* have all been scaled to have length 1.0, */ -/* ANORM should increase to roughly sqrt(n). */ -/* A radically different value for ANORM may */ -/* indicate an error in subroutine APROD (there */ -/* may be an inconsistency between modes 1 and 2). */ - -/* ACOND output An estimate of cond(Abar), the condition */ -/* number of Abar. A very high value of ACOND */ -/* may again indicate an error in APROD. */ - -/* RNORM output An estimate of the final value of norm(rbar), */ -/* the function being minimized (see notation */ -/* above). This will be small if A*x = b has */ -/* a solution. */ - -/* ARNORM output An estimate of the final value of */ -/* norm( Abar(transpose)*rbar ), the norm of */ -/* the residual for the usual normal equations. */ -/* This should be small in all cases. (ARNORM */ -/* will often be smaller than the true value */ -/* computed from the output vector X.) */ - -/* XNORM output An estimate of the norm of the final */ -/* solution vector X. */ - - -/* Subroutines and functions used */ -/* ------------------------------ */ - -/* USER APROD */ -/* BLAS DCOPY, DNRM2, DSCAL (see Lawson et al. below) */ - - -/* Precision */ -/* --------- */ - -/* The number of iterations required by LSQR will usually decrease */ -/* if the computation is performed in higher precision. To convert */ -/* LSQR between single and double precision, change the words */ -/* DOUBLE PRECISION */ -/* DCOPY, DNRM2, DSCAL */ -/* to the appropriate FORTRAN and BLAS equivalents. */ -/* Also change 'D+' or 'E+' in the PARAMETER statement. */ - - -/* References */ -/* ---------- */ - -/* C.C. Paige and M.A. Saunders, LSQR: An algorithm for sparse */ -/* linear equations and sparse least squares, */ -/* ACM Transactions on Mathematical Software 8, 1 (March 1982), */ -/* pp. 43-71. */ - -/* C.C. Paige and M.A. Saunders, Algorithm 583, LSQR: Sparse */ -/* linear equations and least-squares problems, */ -/* ACM Transactions on Mathematical Software 8, 2 (June 1982), */ -/* pp. 195-209. */ - -/* C.L. Lawson, R.J. Hanson, D.R. Kincaid and F.T. Krogh, */ -/* Basic linear algebra subprograms for Fortran usage, */ -/* ACM Transactions on Mathematical Software 5, 3 (Sept 1979), */ -/* pp. 308-323 and 324-325. */ -/* ----------------------------------------------------------------------- */ - - -/* LSQR development: */ -/* 22 Feb 1982: LSQR sent to ACM TOMS to become Algorithm 583. */ -/* 15 Sep 1985: Final F66 version. LSQR sent to "misc" in netlib. */ -/* 13 Oct 1987: Bug (Robert Davies, DSIR). Have to delete */ -/* IF ( (ONE + DABS(T)) .LE. ONE ) GO TO 200 */ -/* from loop 200. The test was an attempt to reduce */ -/* underflows, but caused W(I) not to be updated. */ -/* 17 Mar 1989: First F77 version. */ -/* 04 May 1989: Bug (David Gay, AT&T). When the second BETA is zero, */ -/* RNORM = 0 and */ -/* TEST2 = ARNORM / (ANORM * RNORM) overflows. */ -/* Fixed by testing for RNORM = 0. */ -/* 05 May 1989: Sent to "misc" in netlib. */ - -/* Michael A. Saunders (na.saunders @ NA-net.stanford.edu) */ -/* Department of Operations Research */ -/* Stanford University */ -/* Stanford, CA 94305-4022. */ -/* ----------------------------------------------------------------------- */ -/* Intrinsics and local variables */ -/*< INTRINSIC ABS, MOD, SQRT >*/ -/*< INTEGER I, NCONV, NSTOP >*/ -/*< DOUBLE PRECISION DNRM2 >*/ -/*< >*/ -/*< DOUBLE PRECISION ZERO, ONE >*/ -/*< PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 ) >*/ -/* CHARACTER*16 ENTER, EXIT */ -/* CHARACTER*60 MSG(0:7) */ -/* DATA ENTER /' Enter LSQR. '/, */ -/* $ EXIT /' Exit LSQR. '/ */ -/* DATA MSG */ -/* $ / 'The exact solution is X = 0', */ -/* $ 'Ax - b is small enough, given ATOL, BTOL', */ -/* $ 'The least-squares solution is good enough, given ATOL', */ -/* $ 'The estimate of cond(Abar) has exceeded CONLIM', */ -/* $ 'Ax - b is small enough for this machine', */ -/* $ 'The least-squares solution is good enough for this machine', */ -/* $ 'Cond(Abar) seems to be too large for this machine', */ -/* $ 'The iteration limit has been reached' / */ -/* ----------------------------------------------------------------------- */ -/* Initialize. */ -/* IF (NOUT .GT. 0) */ -/* $ WRITE(NOUT, 1000) ENTER, M, N, DAMP, ATOL, CONLIM, BTOL, ITNLIM */ -/*< ITN = 0 >*/ - /* Parameter adjustments */ - --u; - --se; - --x; - --w; - --v; - --iw; - --rw; - - /* Function Body */ - *itn = 0; -/*< ISTOP = 0 >*/ - *istop = 0; -/*< NSTOP = 0 >*/ - nstop = 0; -/*< CTOL = ZERO >*/ - ctol = 0.; -/*< IF (CONLIM .GT. ZERO) CTOL = ONE / CONLIM >*/ - if (*conlim > 0.) { - ctol = 1. / *conlim; - } -/*< ANORM = ZERO >*/ - *anorm = 0.; -/*< ACOND = ZERO >*/ - *acond = 0.; -/*< BBNORM = ZERO >*/ - bbnorm = 0.; -/*< DAMPSQ = DAMP**2 >*/ -/* Computing 2nd power */ - d__1 = *damp; - dampsq = d__1 * d__1; -/*< DDNORM = ZERO >*/ - ddnorm = 0.; -/*< RES2 = ZERO >*/ - res2 = 0.; -/*< XNORM = ZERO >*/ - *xnorm = 0.; -/*< XXNORM = ZERO >*/ - xxnorm = 0.; -/*< CS2 = - ONE >*/ - cs2 = -1.; -/*< SN2 = ZERO >*/ - sn2 = 0.; -/*< Z = ZERO >*/ - z__ = 0.; -/*< DO 10 I = 1, N >*/ - i__1 = *n; - for (i__ = 1; i__ <= i__1; ++i__) { -/*< V(I) = ZERO >*/ - v[i__] = 0.; -/*< X(I) = ZERO >*/ - x[i__] = 0.; -/*< SE(I) = ZERO >*/ - se[i__] = 0.; -/*< 10 CONTINUE >*/ -/* L10: */ - } -/* Set up the first vectors U and V for the bidiagonalization. */ -/* These satisfy BETA*U = b, ALFA*V = A(transpose)*U. */ -/*< ALFA = ZERO >*/ - alfa = 0.; -/*< BETA = DNRM2 ( M, U, 1 ) >*/ - beta = dnrm2_(m, &u[1], &c__1); -/*< IF (BETA .GT. ZERO) THEN >*/ - if (beta > 0.) { -/*< CALL DSCAL ( M, (ONE / BETA), U, 1 ) >*/ - d__1 = 1. / beta; - dscal_(m, &d__1, &u[1], &c__1); -/*< CALL APROD ( 2, M, N, V, U, LENIW, LENRW, IW, RW ) >*/ - (*aprod)(&c__2, m, n, &v[1], &u[1], leniw, lenrw, &iw[1], &rw[1], - userdata); -/*< ALFA = DNRM2 ( N, V, 1 ) >*/ - alfa = dnrm2_(n, &v[1], &c__1); -/*< END IF >*/ - } -/*< IF (ALFA .GT. ZERO) THEN >*/ - if (alfa > 0.) { -/*< CALL DSCAL ( N, (ONE / ALFA), V, 1 ) >*/ - d__1 = 1. / alfa; - dscal_(n, &d__1, &v[1], &c__1); -/*< CALL DCOPY ( N, V, 1, W, 1 ) >*/ - dcopy_(n, &v[1], &c__1, &w[1], &c__1); -/*< END IF >*/ - } -/*< ARNORM = ALFA * BETA >*/ - *arnorm = alfa * beta; -/*< IF (ARNORM .EQ. ZERO) GO TO 800 >*/ - if (*arnorm == 0.) { - goto L800; - } -/*< RHOBAR = ALFA >*/ - rhobar = alfa; -/*< PHIBAR = BETA >*/ - phibar = beta; -/*< BNORM = BETA >*/ - bnorm = beta; -/*< RNORM = BETA >*/ - *rnorm = beta; -/* IF (NOUT .GT. 0 ) THEN */ -/* IF (DAMPSQ .EQ. ZERO) THEN */ -/* WRITE(NOUT, 1200) */ -/* ELSE */ -/* WRITE(NOUT, 1300) */ -/* END IF */ -/* TEST1 = ONE */ -/* TEST2 = ALFA / BETA */ -/* WRITE(NOUT, 1500) ITN, X(1), RNORM, TEST1, TEST2 */ -/* WRITE(NOUT, 1600) */ -/* END IF */ -/* ------------------------------------------------------------------ */ -/* Main iteration loop. */ -/* ------------------------------------------------------------------ */ -/*< 100 ITN = ITN + 1 >*/ -L100: - ++(*itn); -/* Perform the next step of the bidiagonalization to obtain the */ -/* next BETA, U, ALFA, V. These satisfy the relations */ -/* BETA*U = A*V - ALFA*U, */ -/* ALFA*V = A(transpose)*U - BETA*V. */ -/*< CALL DSCAL ( M, (- ALFA), U, 1 ) >*/ - d__1 = -alfa; - dscal_(m, &d__1, &u[1], &c__1); -/*< CALL APROD ( 1, M, N, V, U, LENIW, LENRW, IW, RW ) >*/ - (*aprod)(&c__1, m, n, &v[1], &u[1], leniw, lenrw, &iw[1], &rw[1], - userdata); -/*< BETA = DNRM2 ( M, U, 1 ) >*/ - beta = dnrm2_(m, &u[1], &c__1); -/*< BBNORM = BBNORM + ALFA**2 + BETA**2 + DAMPSQ >*/ -/* Computing 2nd power */ - d__1 = alfa; -/* Computing 2nd power */ - d__2 = beta; - bbnorm = bbnorm + d__1 * d__1 + d__2 * d__2 + dampsq; -/*< IF (BETA .GT. ZERO) THEN >*/ - if (beta > 0.) { -/*< CALL DSCAL ( M, (ONE / BETA), U, 1 ) >*/ - d__1 = 1. / beta; - dscal_(m, &d__1, &u[1], &c__1); -/*< CALL DSCAL ( N, (- BETA), V, 1 ) >*/ - d__1 = -beta; - dscal_(n, &d__1, &v[1], &c__1); -/*< CALL APROD ( 2, M, N, V, U, LENIW, LENRW, IW, RW ) >*/ - (*aprod)(&c__2, m, n, &v[1], &u[1], leniw, lenrw, &iw[1], &rw[1], - userdata); -/*< ALFA = DNRM2 ( N, V, 1 ) >*/ - alfa = dnrm2_(n, &v[1], &c__1); -/*< IF (ALFA .GT. ZERO) THEN >*/ - if (alfa > 0.) { -/*< CALL DSCAL ( N, (ONE / ALFA), V, 1 ) >*/ - d__1 = 1. / alfa; - dscal_(n, &d__1, &v[1], &c__1); -/*< END IF >*/ - } -/*< END IF >*/ - } -/* Use a plane rotation to eliminate the damping parameter. */ -/* This alters the diagonal (RHOBAR) of the lower-bidiagonal matrix. */ -/*< RHBAR2 = RHOBAR**2 + DAMPSQ >*/ -/* Computing 2nd power */ - d__1 = rhobar; - rhbar2 = d__1 * d__1 + dampsq; -/*< RHBAR1 = SQRT( RHBAR2 ) >*/ - rhbar1 = sqrt(rhbar2); -/*< CS1 = RHOBAR / RHBAR1 >*/ - cs1 = rhobar / rhbar1; -/*< SN1 = DAMP / RHBAR1 >*/ - sn1 = *damp / rhbar1; -/*< PSI = SN1 * PHIBAR >*/ - psi = sn1 * phibar; -/*< PHIBAR = CS1 * PHIBAR >*/ - phibar = cs1 * phibar; -/* Use a plane rotation to eliminate the subdiagonal element (BETA) */ -/* of the lower-bidiagonal matrix, giving an upper-bidiagonal matrix. */ -/*< RHO = SQRT( RHBAR2 + BETA**2 ) >*/ -/* Computing 2nd power */ - d__1 = beta; - rho = sqrt(rhbar2 + d__1 * d__1); -/*< CS = RHBAR1 / RHO >*/ - cs = rhbar1 / rho; -/*< SN = BETA / RHO >*/ - sn = beta / rho; -/*< THETA = SN * ALFA >*/ - theta = sn * alfa; -/*< RHOBAR = - CS * ALFA >*/ - rhobar = -cs * alfa; -/*< PHI = CS * PHIBAR >*/ - phi = cs * phibar; -/*< PHIBAR = SN * PHIBAR >*/ - phibar = sn * phibar; -/*< TAU = SN * PHI >*/ - tau = sn * phi; -/* Update X, W and the standard error estimates. */ -/*< T1 = PHI / RHO >*/ - t1 = phi / rho; -/*< T2 = - THETA / RHO >*/ - t2 = -theta / rho; -/*< T3 = ONE / RHO >*/ - t3 = 1. / rho; -/*< DO 200 I = 1, N >*/ - i__1 = *n; - for (i__ = 1; i__ <= i__1; ++i__) { -/*< T = W(I) >*/ - t = w[i__]; -/*< X(I) = T1*T + X(I) >*/ - x[i__] = t1 * t + x[i__]; -/*< W(I) = T2*T + V(I) >*/ - w[i__] = t2 * t + v[i__]; -/*< T = (T3*T)**2 >*/ -/* Computing 2nd power */ - d__1 = t3 * t; - t = d__1 * d__1; -/*< SE(I) = T + SE(I) >*/ - se[i__] = t + se[i__]; -/*< DDNORM = T + DDNORM >*/ - ddnorm = t + ddnorm; -/*< 200 CONTINUE >*/ -/* L200: */ - } -/* Use a plane rotation on the right to eliminate the */ -/* super-diagonal element (THETA) of the upper-bidiagonal matrix. */ -/* Then use the result to estimate norm(X). */ -/*< DELTA = SN2 * RHO >*/ - delta = sn2 * rho; -/*< GAMBAR = - CS2 * RHO >*/ - gambar = -cs2 * rho; -/*< RHS = PHI - DELTA * Z >*/ - rhs = phi - delta * z__; -/*< ZBAR = RHS / GAMBAR >*/ - zbar = rhs / gambar; -/*< XNORM = SQRT( XXNORM + ZBAR **2 ) >*/ -/* Computing 2nd power */ - d__1 = zbar; - *xnorm = sqrt(xxnorm + d__1 * d__1); -/*< GAMMA = SQRT( GAMBAR**2 + THETA**2 ) >*/ -/* Computing 2nd power */ - d__1 = gambar; -/* Computing 2nd power */ - d__2 = theta; - gamma = sqrt(d__1 * d__1 + d__2 * d__2); -/*< CS2 = GAMBAR / GAMMA >*/ - cs2 = gambar / gamma; -/*< SN2 = THETA / GAMMA >*/ - sn2 = theta / gamma; -/*< Z = RHS / GAMMA >*/ - z__ = rhs / gamma; -/*< XXNORM = XXNORM + Z**2 >*/ -/* Computing 2nd power */ - d__1 = z__; - xxnorm += d__1 * d__1; -/* Test for convergence. */ -/* First, estimate the norm and condition of the matrix Abar, */ -/* and the norms of rbar and Abar(transpose)*rbar. */ -/*< ANORM = SQRT( BBNORM ) >*/ - *anorm = sqrt(bbnorm); -/*< ACOND = ANORM * SQRT( DDNORM ) >*/ - *acond = *anorm * sqrt(ddnorm); -/*< RES1 = PHIBAR**2 >*/ -/* Computing 2nd power */ - d__1 = phibar; - res1 = d__1 * d__1; -/*< RES2 = RES2 + PSI**2 >*/ -/* Computing 2nd power */ - d__1 = psi; - res2 += d__1 * d__1; -/*< RNORM = SQRT( RES1 + RES2 ) >*/ - *rnorm = sqrt(res1 + res2); -/*< ARNORM = ALFA * ABS( TAU ) >*/ - *arnorm = alfa * abs(tau); -/* Now use these norms to estimate certain other quantities, */ -/* some of which will be small near a solution. */ -/*< TEST1 = RNORM / BNORM >*/ - test1 = *rnorm / bnorm; -/*< TEST2 = ZERO >*/ - test2 = 0.; -/*< IF (RNORM .GT. ZERO) TEST2 = ARNORM / (ANORM * RNORM) >*/ - if (*rnorm > 0.) { - test2 = *arnorm / (*anorm * *rnorm); - } -/*< TEST3 = ONE / ACOND >*/ - test3 = 1. / *acond; -/*< T1 = TEST1 / (ONE + ANORM * XNORM / BNORM) >*/ - t1 = test1 / (*anorm * *xnorm / bnorm + 1.); -/*< RTOL = BTOL + ATOL * ANORM * XNORM / BNORM >*/ - rtol = *btol + *atol * *anorm * *xnorm / bnorm; -/* The following tests guard against extremely small values of */ -/* ATOL, BTOL or CTOL. (The user may have set any or all of */ -/* the parameters ATOL, BTOL, CONLIM to zero.) */ -/* The effect is equivalent to the normal tests using */ -/* ATOL = RELPR, BTOL = RELPR, CONLIM = 1/RELPR. */ -/*< T3 = ONE + TEST3 >*/ - t3 = test3 + 1.; -/*< T2 = ONE + TEST2 >*/ - t2 = test2 + 1.; -/*< T1 = ONE + T1 >*/ - t1 += 1.; -/*< IF (ITN .GE. ITNLIM) ISTOP = 7 >*/ - if (*itn >= *itnlim) { - *istop = 7; - } -/*< IF (T3 .LE. ONE ) ISTOP = 6 >*/ - if (t3 <= 1.) { - *istop = 6; - } -/*< IF (T2 .LE. ONE ) ISTOP = 5 >*/ - if (t2 <= 1.) { - *istop = 5; - } -/*< IF (T1 .LE. ONE ) ISTOP = 4 >*/ - if (t1 <= 1.) { - *istop = 4; - } -/* Allow for tolerances set by the user. */ -/*< IF (TEST3 .LE. CTOL) ISTOP = 3 >*/ - if (test3 <= ctol) { - *istop = 3; - } -/*< IF (TEST2 .LE. ATOL) ISTOP = 2 >*/ - if (test2 <= *atol) { - *istop = 2; - } -/*< IF (TEST1 .LE. RTOL) ISTOP = 1 >*/ - if (test1 <= rtol) { - *istop = 1; - } -/* ================================================================== */ -/* See if it is time to print something. */ -/*< IF (NOUT .LE. 0 ) GO TO 600 >*/ - if (*nout <= 0) { - goto L600; - } -/*< IF (N .LE. 40 ) GO TO 400 >*/ - if (*n <= 40) { - goto L400; - } -/*< IF (ITN .LE. 10 ) GO TO 400 >*/ - if (*itn <= 10) { - goto L400; - } -/*< IF (ITN .GE. ITNLIM-10) GO TO 400 >*/ - if (*itn >= *itnlim - 10) { - goto L400; - } -/*< IF (MOD(ITN,10) .EQ. 0 ) GO TO 400 >*/ - if (*itn % 10 == 0) { - goto L400; - } -/*< IF (TEST3 .LE. 2.0*CTOL) GO TO 400 >*/ - if (test3 <= ctol * (float)2.) { - goto L400; - } -/*< IF (TEST2 .LE. 10.0*ATOL) GO TO 400 >*/ - if (test2 <= *atol * (float)10.) { - goto L400; - } -/*< IF (TEST1 .LE. 10.0*RTOL) GO TO 400 >*/ - if (test1 <= rtol * (float)10.) { - goto L400; - } -/*< IF (ISTOP .NE. 0 ) GO TO 400 >*/ - if (*istop != 0) { - goto L400; - } -/*< GO TO 600 >*/ - goto L600; -/* Print a line for this iteration. */ -/*< 400 IF (1 .EQ. 1) GO TO 600 >*/ -L400: - if (TRUE_) { - goto L600; - } -/* 400 WRITE(NOUT, 1500) ITN, X(1), RNORM, TEST1, TEST2, ANORM, ACOND */ -/* IF (MOD(ITN,10) .EQ. 0) WRITE(NOUT, 1600) */ -/* ================================================================== */ -/* Stop if appropriate. */ -/* The convergence criteria are required to be met on NCONV */ -/* consecutive iterations, where NCONV is set below. */ -/* Suggested value: NCONV = 1, 2 or 3. */ -/*< 600 IF (ISTOP .EQ. 0) NSTOP = 0 >*/ -L600: - if (*istop == 0) { - nstop = 0; - } -/*< IF (ISTOP .EQ. 0) GO TO 100 >*/ - if (*istop == 0) { - goto L100; - } -/*< NCONV = 1 >*/ - nconv = 1; -/*< NSTOP = NSTOP + 1 >*/ - ++nstop; -/*< IF (NSTOP .LT. NCONV .AND. ITN .LT. ITNLIM) ISTOP = 0 >*/ - if (nstop < nconv && *itn < *itnlim) { - *istop = 0; - } -/*< IF (ISTOP .EQ. 0) GO TO 100 >*/ - if (*istop == 0) { - goto L100; - } -/* ------------------------------------------------------------------ */ -/* End of iteration loop. */ -/* ------------------------------------------------------------------ */ -/* Finish off the standard error estimates. */ -/*< T = ONE >*/ - t = 1.; -/*< IF (M .GT. N ) T = M - N >*/ - if (*m > *n) { - t = (doublereal) (*m - *n); - } -/*< IF (DAMPSQ .GT. ZERO) T = M >*/ - if (dampsq > 0.) { - t = (doublereal) (*m); - } -/*< T = RNORM / SQRT( T ) >*/ - t = *rnorm / sqrt(t); -/*< DO 700 I = 1, N >*/ - i__1 = *n; - for (i__ = 1; i__ <= i__1; ++i__) { -/*< SE(I) = T * SQRT( SE(I) ) >*/ - se[i__] = t * sqrt(se[i__]); -/*< 700 CONTINUE >*/ -/* L700: */ - } -/* Print the stopping condition. */ -/*< 800 IF (1 .EQ. 1) GO TO 900 >*/ -L800: - if (TRUE_) { - goto L900; - } -/* 800 IF (NOUT .GT. 0) THEN */ -/* WRITE(NOUT, 2000) EXIT, ISTOP, ITN, */ -/* $ EXIT, ANORM, ACOND, */ -/* $ EXIT, RNORM, ARNORM, */ -/* $ EXIT, BNORM, XNORM */ -/* WRITE(NOUT, 3000) EXIT, MSG(ISTOP) */ -/* END IF */ -/*< 900 RETURN >*/ -L900: - return 0; -/* ------------------------------------------------------------------ */ -/*< 1 >*/ -/* L1000: */ -/*< 1 >*/ -/* L1200: */ -/*< 1 >*/ -/* L1300: */ -/*< 1500 FORMAT(1P, I6, 2E17.9, 4E10.2) >*/ -/* L1500: */ -/*< 1600 FORMAT(1X) >*/ -/* L1600: */ -/*< 2 >*/ -/* L2000: */ -/*< 3000 FORMAT( A, 6X, A ) >*/ -/* L3000: */ -/* ------------------------------------------------------------------ */ -/* End of LSQR */ -/*< END >*/ -} /* lsqr_ */ - -#ifdef __cplusplus - } -#endif diff --git a/Utilities/ITK/Utilities/vxl/v3p/netlib/linalg/lsqr.f b/Utilities/ITK/Utilities/vxl/v3p/netlib/linalg/lsqr.f deleted file mode 100644 index 5cb3eaa2a0de014be7d36643b41ee8a9373729d5..0000000000000000000000000000000000000000 --- a/Utilities/ITK/Utilities/vxl/v3p/netlib/linalg/lsqr.f +++ /dev/null @@ -1,611 +0,0 @@ -* From arpa!sol-michael.stanford.edu!mike 5 May 89 23:53:00 PDT - SUBROUTINE LSQR ( M, N, APROD, DAMP, - $ LENIW, LENRW, IW, RW, - $ U, V, W, X, SE, - $ ATOL, BTOL, CONLIM, ITNLIM, NOUT, - $ ISTOP, ITN, ANORM, ACOND, RNORM, ARNORM, XNORM) - - EXTERNAL APROD - INTEGER M, N, LENIW, LENRW, ITNLIM, NOUT, ISTOP, ITN - INTEGER IW(LENIW) - DOUBLE PRECISION RW(LENRW), U(M), V(N), W(N), X(N), SE(N), - $ ATOL, BTOL, CONLIM, DAMP, - $ ANORM, ACOND, RNORM, ARNORM, XNORM -*----------------------------------------------------------------------- -* -* LSQR finds a solution x to the following problems: -* -* 1. Unsymmetric equations -- solve A*x = b -* -* 2. Linear least squares -- solve A*x = b -* in the least-squares sense -* -* 3. Damped least squares -- solve ( A )*x = ( b ) -* ( damp*I ) ( 0 ) -* in the least-squares sense -* -* where A is a matrix with m rows and n columns, b is an -* m-vector, and damp is a scalar. (All quantities are real.) -* The matrix A is intended to be large and sparse. It is accessed -* by means of subroutine calls of the form -* -* CALL APROD ( mode, m, n, x, y, LENIW, LENRW, IW, RW ) -* -* which must perform the following functions: -* -* If MODE = 1, compute y = y + A*x. -* If MODE = 2, compute x = x + A(transpose)*y. -* -* The vectors x and y are input parameters in both cases. -* If mode = 1, y should be altered without changing x. -* If mode = 2, x should be altered without changing y. -* The parameters LENIW, LENRW, IW, RW may be used for workspace -* as described below. -* -* The rhs vector b is input via U, and subsequently overwritten. -* -* -* Note: LSQR uses an iterative method to approximate the solution. -* The number of iterations required to reach a certain accuracy -* depends strongly on the scaling of the problem. Poor scaling of -* the rows or columns of A should therefore be avoided where -* possible. -* -* For example, in problem 1 the solution is unaltered by -* row-scaling. If a row of A is very small or large compared to -* the other rows of A, the corresponding row of ( A b ) should be -* scaled up or down. -* -* In problems 1 and 2, the solution x is easily recovered -* following column-scaling. Unless better information is known, -* the nonzero columns of A should be scaled so that they all have -* the same Euclidean norm (e.g., 1.0). -* -* In problem 3, there is no freedom to re-scale if damp is -* nonzero. However, the value of damp should be assigned only -* after attention has been paid to the scaling of A. -* -* The parameter damp is intended to help regularize -* ill-conditioned systems, by preventing the true solution from -* being very large. Another aid to regularization is provided by -* the parameter ACOND, which may be used to terminate iterations -* before the computed solution becomes very large. -* -* -* Notation -* -------- -* -* The following quantities are used in discussing the subroutine -* parameters: -* -* Abar = ( A ), bbar = ( b ) -* ( damp*I ) ( 0 ) -* -* r = b - A*x, rbar = bbar - Abar*x -* -* rnorm = sqrt( norm(r)**2 + damp**2 * norm(x)**2 ) -* = norm( rbar ) -* -* RELPR = the relative precision of floating-point arithmetic -* on the machine being used. For example, on the IBM 370, -* RELPR is about 1.0E-6 and 1.0D-16 in single and double -* precision respectively. -* -* LSQR minimizes the function rnorm with respect to x. -* -* -* Parameters -* ---------- -* -* M input m, the number of rows in A. -* -* N input n, the number of columns in A. -* -* APROD external See above. -* -* DAMP input The damping parameter for problem 3 above. -* (DAMP should be 0.0 for problems 1 and 2.) -* If the system A*x = b is incompatible, values -* of DAMP in the range 0 to sqrt(RELPR)*norm(A) -* will probably have a negligible effect. -* Larger values of DAMP will tend to decrease -* the norm of x and reduce the number of -* iterations required by LSQR. -* -* The work per iteration and the storage needed -* by LSQR are the same for all values of DAMP. -* -* LENIW input The length of the workspace array IW. -* LENRW input The length of the workspace array RW. -* IW workspace An integer array of length LENIW. -* RW workspace A real array of length LENRW. -* -* Note: LSQR does not explicitly use the previous four -* parameters, but passes them to subroutine APROD for -* possible use as workspace. If APROD does not need -* IW or RW, the values LENIW = 1 or LENRW = 1 should -* be used, and the actual parameters corresponding to -* IW or RW may be any convenient array of suitable type. -* -* U(M) input The rhs vector b. Beware that U is -* over-written by LSQR. -* -* V(N) workspace -* W(N) workspace -* -* X(N) output Returns the computed solution x. -* -* SE(N) output Returns standard error estimates for the -* components of X. For each i, SE(i) is set -* to the value rnorm * sqrt( sigma(i,i) / T ), -* where sigma(i,i) is an estimate of the i-th -* diagonal of the inverse of Abar(transpose)*Abar -* and T = 1 if m .le. n, -* T = m - n if m .gt. n and damp = 0, -* T = m if damp .ne. 0. -* -* ATOL input An estimate of the relative error in the data -* defining the matrix A. For example, -* if A is accurate to about 6 digits, set -* ATOL = 1.0E-6 . -* -* BTOL input An extimate of the relative error in the data -* defining the rhs vector b. For example, -* if b is accurate to about 6 digits, set -* BTOL = 1.0E-6 . -* -* CONLIM input An upper limit on cond(Abar), the apparent -* condition number of the matrix Abar. -* Iterations will be terminated if a computed -* estimate of cond(Abar) exceeds CONLIM. -* This is intended to prevent certain small or -* zero singular values of A or Abar from -* coming into effect and causing unwanted growth -* in the computed solution. -* -* CONLIM and DAMP may be used separately or -* together to regularize ill-conditioned systems. -* -* Normally, CONLIM should be in the range -* 1000 to 1/RELPR. -* Suggested value: -* CONLIM = 1/(100*RELPR) for compatible systems, -* CONLIM = 1/(10*sqrt(RELPR)) for least squares. -* -* Note: If the user is not concerned about the parameters -* ATOL, BTOL and CONLIM, any or all of them may be set -* to zero. The effect will be the same as the values -* RELPR, RELPR and 1/RELPR respectively. -* -* ITNLIM input An upper limit on the number of iterations. -* Suggested value: -* ITNLIM = n/2 for well-conditioned systems -* with clustered singular values, -* ITNLIM = 4*n otherwise. -* -* NOUT input File number for printed output. If positive, -* a summary will be printed on file NOUT. -* -* ISTOP output An integer giving the reason for termination: -* -* 0 x = 0 is the exact solution. -* No iterations were performed. -* -* 1 The equations A*x = b are probably -* compatible. Norm(A*x - b) is sufficiently -* small, given the values of ATOL and BTOL. -* -* 2 The system A*x = b is probably not -* compatible. A least-squares solution has -* been obtained that is sufficiently accurate, -* given the value of ATOL. -* -* 3 An estimate of cond(Abar) has exceeded -* CONLIM. The system A*x = b appears to be -* ill-conditioned. Otherwise, there could be an -* error in subroutine APROD. -* -* 4 The equations A*x = b are probably -* compatible. Norm(A*x - b) is as small as -* seems reasonable on this machine. -* -* 5 The system A*x = b is probably not -* compatible. A least-squares solution has -* been obtained that is as accurate as seems -* reasonable on this machine. -* -* 6 Cond(Abar) seems to be so large that there is -* no point in doing further iterations, -* given the precision of this machine. -* There could be an error in subroutine APROD. -* -* 7 The iteration limit ITNLIM was reached. -* -* ITN output The number of iterations performed. -* -* ANORM output An estimate of the Frobenius norm of Abar. -* This is the square-root of the sum of squares -* of the elements of Abar. -* If DAMP is small and if the columns of A -* have all been scaled to have length 1.0, -* ANORM should increase to roughly sqrt(n). -* A radically different value for ANORM may -* indicate an error in subroutine APROD (there -* may be an inconsistency between modes 1 and 2). -* -* ACOND output An estimate of cond(Abar), the condition -* number of Abar. A very high value of ACOND -* may again indicate an error in APROD. -* -* RNORM output An estimate of the final value of norm(rbar), -* the function being minimized (see notation -* above). This will be small if A*x = b has -* a solution. -* -* ARNORM output An estimate of the final value of -* norm( Abar(transpose)*rbar ), the norm of -* the residual for the usual normal equations. -* This should be small in all cases. (ARNORM -* will often be smaller than the true value -* computed from the output vector X.) -* -* XNORM output An estimate of the norm of the final -* solution vector X. -* -* -* Subroutines and functions used -* ------------------------------ -* -* USER APROD -* BLAS DCOPY, DNRM2, DSCAL (see Lawson et al. below) -* -* -* Precision -* --------- -* -* The number of iterations required by LSQR will usually decrease -* if the computation is performed in higher precision. To convert -* LSQR between single and double precision, change the words -* DOUBLE PRECISION -* DCOPY, DNRM2, DSCAL -* to the appropriate FORTRAN and BLAS equivalents. -* Also change 'D+' or 'E+' in the PARAMETER statement. -* -* -* References -* ---------- -* -* C.C. Paige and M.A. Saunders, LSQR: An algorithm for sparse -* linear equations and sparse least squares, -* ACM Transactions on Mathematical Software 8, 1 (March 1982), -* pp. 43-71. -* -* C.C. Paige and M.A. Saunders, Algorithm 583, LSQR: Sparse -* linear equations and least-squares problems, -* ACM Transactions on Mathematical Software 8, 2 (June 1982), -* pp. 195-209. -* -* C.L. Lawson, R.J. Hanson, D.R. Kincaid and F.T. Krogh, -* Basic linear algebra subprograms for Fortran usage, -* ACM Transactions on Mathematical Software 5, 3 (Sept 1979), -* pp. 308-323 and 324-325. -*----------------------------------------------------------------------- -* -* -* LSQR development: -* 22 Feb 1982: LSQR sent to ACM TOMS to become Algorithm 583. -* 15 Sep 1985: Final F66 version. LSQR sent to "misc" in netlib. -* 13 Oct 1987: Bug (Robert Davies, DSIR). Have to delete -* IF ( (ONE + DABS(T)) .LE. ONE ) GO TO 200 -* from loop 200. The test was an attempt to reduce -* underflows, but caused W(I) not to be updated. -* 17 Mar 1989: First F77 version. -* 04 May 1989: Bug (David Gay, AT&T). When the second BETA is zero, -* RNORM = 0 and -* TEST2 = ARNORM / (ANORM * RNORM) overflows. -* Fixed by testing for RNORM = 0. -* 05 May 1989: Sent to "misc" in netlib. -* -* Michael A. Saunders (na.saunders @ NA-net.stanford.edu) -* Department of Operations Research -* Stanford University -* Stanford, CA 94305-4022. -*----------------------------------------------------------------------- - -* Intrinsics and local variables - - INTRINSIC ABS, MOD, SQRT - INTEGER I, NCONV, NSTOP - DOUBLE PRECISION DNRM2 - DOUBLE PRECISION ALFA, BBNORM, BETA, BNORM, - $ CS, CS1, CS2, CTOL, DAMPSQ, DDNORM, DELTA, - $ GAMMA, GAMBAR, PHI, PHIBAR, PSI, - $ RES1, RES2, RHO, RHOBAR, RHBAR1, RHBAR2, - $ RHS, RTOL, SN, SN1, SN2, - $ T, TAU, TEST1, TEST2, TEST3, - $ THETA, T1, T2, T3, XXNORM, Z, ZBAR - - DOUBLE PRECISION ZERO, ONE - PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 ) - -C CHARACTER*16 ENTER, EXIT -C CHARACTER*60 MSG(0:7) - -C DATA ENTER /' Enter LSQR. '/, -C $ EXIT /' Exit LSQR. '/ - -C DATA MSG -C $ / 'The exact solution is X = 0', -C $ 'Ax - b is small enough, given ATOL, BTOL', -C $ 'The least-squares solution is good enough, given ATOL', -C $ 'The estimate of cond(Abar) has exceeded CONLIM', -C $ 'Ax - b is small enough for this machine', -C $ 'The least-squares solution is good enough for this machine', -C $ 'Cond(Abar) seems to be too large for this machine', -C $ 'The iteration limit has been reached' / -*----------------------------------------------------------------------- - - -* Initialize. - -C IF (NOUT .GT. 0) -C $ WRITE(NOUT, 1000) ENTER, M, N, DAMP, ATOL, CONLIM, BTOL, ITNLIM - ITN = 0 - ISTOP = 0 - NSTOP = 0 - CTOL = ZERO - IF (CONLIM .GT. ZERO) CTOL = ONE / CONLIM - ANORM = ZERO - ACOND = ZERO - BBNORM = ZERO - DAMPSQ = DAMP**2 - DDNORM = ZERO - RES2 = ZERO - XNORM = ZERO - XXNORM = ZERO - CS2 = - ONE - SN2 = ZERO - Z = ZERO - - DO 10 I = 1, N - V(I) = ZERO - X(I) = ZERO - SE(I) = ZERO - 10 CONTINUE - -* Set up the first vectors U and V for the bidiagonalization. -* These satisfy BETA*U = b, ALFA*V = A(transpose)*U. - - ALFA = ZERO - BETA = DNRM2 ( M, U, 1 ) - - IF (BETA .GT. ZERO) THEN - CALL DSCAL ( M, (ONE / BETA), U, 1 ) - CALL APROD ( 2, M, N, V, U, LENIW, LENRW, IW, RW ) - ALFA = DNRM2 ( N, V, 1 ) - END IF - - IF (ALFA .GT. ZERO) THEN - CALL DSCAL ( N, (ONE / ALFA), V, 1 ) - CALL DCOPY ( N, V, 1, W, 1 ) - END IF - - ARNORM = ALFA * BETA - IF (ARNORM .EQ. ZERO) GO TO 800 - - RHOBAR = ALFA - PHIBAR = BETA - BNORM = BETA - RNORM = BETA - -C IF (NOUT .GT. 0 ) THEN -C IF (DAMPSQ .EQ. ZERO) THEN -C WRITE(NOUT, 1200) -C ELSE -C WRITE(NOUT, 1300) -C END IF -C TEST1 = ONE -C TEST2 = ALFA / BETA -C WRITE(NOUT, 1500) ITN, X(1), RNORM, TEST1, TEST2 -C WRITE(NOUT, 1600) -C END IF - -* ------------------------------------------------------------------ -* Main iteration loop. -* ------------------------------------------------------------------ - 100 ITN = ITN + 1 - -* Perform the next step of the bidiagonalization to obtain the -* next BETA, U, ALFA, V. These satisfy the relations -* BETA*U = A*V - ALFA*U, -* ALFA*V = A(transpose)*U - BETA*V. - - CALL DSCAL ( M, (- ALFA), U, 1 ) - CALL APROD ( 1, M, N, V, U, LENIW, LENRW, IW, RW ) - BETA = DNRM2 ( M, U, 1 ) - BBNORM = BBNORM + ALFA**2 + BETA**2 + DAMPSQ - - IF (BETA .GT. ZERO) THEN - CALL DSCAL ( M, (ONE / BETA), U, 1 ) - CALL DSCAL ( N, (- BETA), V, 1 ) - CALL APROD ( 2, M, N, V, U, LENIW, LENRW, IW, RW ) - ALFA = DNRM2 ( N, V, 1 ) - IF (ALFA .GT. ZERO) THEN - CALL DSCAL ( N, (ONE / ALFA), V, 1 ) - END IF - END IF - -* Use a plane rotation to eliminate the damping parameter. -* This alters the diagonal (RHOBAR) of the lower-bidiagonal matrix. - - RHBAR2 = RHOBAR**2 + DAMPSQ - RHBAR1 = SQRT( RHBAR2 ) - CS1 = RHOBAR / RHBAR1 - SN1 = DAMP / RHBAR1 - PSI = SN1 * PHIBAR - PHIBAR = CS1 * PHIBAR - -* Use a plane rotation to eliminate the subdiagonal element (BETA) -* of the lower-bidiagonal matrix, giving an upper-bidiagonal matrix. - - RHO = SQRT( RHBAR2 + BETA**2 ) - CS = RHBAR1 / RHO - SN = BETA / RHO - THETA = SN * ALFA - RHOBAR = - CS * ALFA - PHI = CS * PHIBAR - PHIBAR = SN * PHIBAR - TAU = SN * PHI - -* Update X, W and the standard error estimates. - - T1 = PHI / RHO - T2 = - THETA / RHO - T3 = ONE / RHO - - DO 200 I = 1, N - T = W(I) - X(I) = T1*T + X(I) - W(I) = T2*T + V(I) - T = (T3*T)**2 - SE(I) = T + SE(I) - DDNORM = T + DDNORM - 200 CONTINUE - -* Use a plane rotation on the right to eliminate the -* super-diagonal element (THETA) of the upper-bidiagonal matrix. -* Then use the result to estimate norm(X). - - DELTA = SN2 * RHO - GAMBAR = - CS2 * RHO - RHS = PHI - DELTA * Z - ZBAR = RHS / GAMBAR - XNORM = SQRT( XXNORM + ZBAR **2 ) - GAMMA = SQRT( GAMBAR**2 + THETA**2 ) - CS2 = GAMBAR / GAMMA - SN2 = THETA / GAMMA - Z = RHS / GAMMA - XXNORM = XXNORM + Z**2 - -* Test for convergence. -* First, estimate the norm and condition of the matrix Abar, -* and the norms of rbar and Abar(transpose)*rbar. - - ANORM = SQRT( BBNORM ) - ACOND = ANORM * SQRT( DDNORM ) - RES1 = PHIBAR**2 - RES2 = RES2 + PSI**2 - RNORM = SQRT( RES1 + RES2 ) - ARNORM = ALFA * ABS( TAU ) - -* Now use these norms to estimate certain other quantities, -* some of which will be small near a solution. - - TEST1 = RNORM / BNORM - TEST2 = ZERO - IF (RNORM .GT. ZERO) TEST2 = ARNORM / (ANORM * RNORM) - TEST3 = ONE / ACOND - T1 = TEST1 / (ONE + ANORM * XNORM / BNORM) - RTOL = BTOL + ATOL * ANORM * XNORM / BNORM - -* The following tests guard against extremely small values of -* ATOL, BTOL or CTOL. (The user may have set any or all of -* the parameters ATOL, BTOL, CONLIM to zero.) -* The effect is equivalent to the normal tests using -* ATOL = RELPR, BTOL = RELPR, CONLIM = 1/RELPR. - - T3 = ONE + TEST3 - T2 = ONE + TEST2 - T1 = ONE + T1 - IF (ITN .GE. ITNLIM) ISTOP = 7 - IF (T3 .LE. ONE ) ISTOP = 6 - IF (T2 .LE. ONE ) ISTOP = 5 - IF (T1 .LE. ONE ) ISTOP = 4 - -* Allow for tolerances set by the user. - - IF (TEST3 .LE. CTOL) ISTOP = 3 - IF (TEST2 .LE. ATOL) ISTOP = 2 - IF (TEST1 .LE. RTOL) ISTOP = 1 -* ================================================================== - -* See if it is time to print something. - - IF (NOUT .LE. 0 ) GO TO 600 - IF (N .LE. 40 ) GO TO 400 - IF (ITN .LE. 10 ) GO TO 400 - IF (ITN .GE. ITNLIM-10) GO TO 400 - IF (MOD(ITN,10) .EQ. 0 ) GO TO 400 - IF (TEST3 .LE. 2.0*CTOL) GO TO 400 - IF (TEST2 .LE. 10.0*ATOL) GO TO 400 - IF (TEST1 .LE. 10.0*RTOL) GO TO 400 - IF (ISTOP .NE. 0 ) GO TO 400 - GO TO 600 - -* Print a line for this iteration. - - 400 IF (1 .EQ. 1) GO TO 600 -C 400 WRITE(NOUT, 1500) ITN, X(1), RNORM, TEST1, TEST2, ANORM, ACOND -C IF (MOD(ITN,10) .EQ. 0) WRITE(NOUT, 1600) -* ================================================================== - -* Stop if appropriate. -* The convergence criteria are required to be met on NCONV -* consecutive iterations, where NCONV is set below. -* Suggested value: NCONV = 1, 2 or 3. - - 600 IF (ISTOP .EQ. 0) NSTOP = 0 - IF (ISTOP .EQ. 0) GO TO 100 - NCONV = 1 - NSTOP = NSTOP + 1 - IF (NSTOP .LT. NCONV .AND. ITN .LT. ITNLIM) ISTOP = 0 - IF (ISTOP .EQ. 0) GO TO 100 -* ------------------------------------------------------------------ -* End of iteration loop. -* ------------------------------------------------------------------ - - -* Finish off the standard error estimates. - - T = ONE - IF (M .GT. N ) T = M - N - IF (DAMPSQ .GT. ZERO) T = M - T = RNORM / SQRT( T ) - - DO 700 I = 1, N - SE(I) = T * SQRT( SE(I) ) - 700 CONTINUE - -* Print the stopping condition. - - 800 IF (1 .EQ. 1) GO TO 900 -C 800 IF (NOUT .GT. 0) THEN -C WRITE(NOUT, 2000) EXIT, ISTOP, ITN, -C $ EXIT, ANORM, ACOND, -C $ EXIT, RNORM, ARNORM, -C $ EXIT, BNORM, XNORM -C WRITE(NOUT, 3000) EXIT, MSG(ISTOP) -C END IF - - 900 RETURN - -* ------------------------------------------------------------------ - 1000 FORMAT(// 1P, A, ' Least-squares solution of A*x = b' - $ / ' The matrix A has', I7, ' rows and', I7, ' columns' - $ / ' The damping parameter is DAMP =', E10.2 - $ / ' ATOL =', E10.2, 15X, 'CONLIM =', E10.2 - $ / ' BTOL =', E10.2, 15X, 'ITNLIM =', I10) - 1200 FORMAT(// ' Itn x(1) Function', - $ ' Compatible LS Norm A Cond A' /) - 1300 FORMAT(// ' Itn x(1) Function', - $ ' Compatible LS Norm Abar Cond Abar' /) - 1500 FORMAT(1P, I6, 2E17.9, 4E10.2) - 1600 FORMAT(1X) - 2000 FORMAT(/ 1P, A, 6X, 'ISTOP =', I3, 16X, 'ITN =', I9 - $ / A, 6X, 'ANORM =', E13.5, 6X, 'ACOND =', E13.5 - $ / A, 6X, 'RNORM =', E13.5, 6X, 'ARNORM =', E13.5, - $ / A, 6X, 'BNORM =', E13.5, 6X, 'XNORM =', E13.5) - 3000 FORMAT( A, 6X, A ) -* ------------------------------------------------------------------ -* End of LSQR - END diff --git a/Utilities/ITK/Utilities/vxl/v3p/netlib/linalg/lsqr.h b/Utilities/ITK/Utilities/vxl/v3p/netlib/linalg/lsqr.h deleted file mode 100644 index 0062b72cded22be73b43baaf2de59f02d575efa3..0000000000000000000000000000000000000000 --- a/Utilities/ITK/Utilities/vxl/v3p/netlib/linalg/lsqr.h +++ /dev/null @@ -1,38 +0,0 @@ -/*: Solves A*x = b */ -extern int v3p_netlib_lsqr_( - v3p_netlib_integer *m, - v3p_netlib_integer *n, - int (*aprod)(v3p_netlib_integer*, - v3p_netlib_integer*, - v3p_netlib_integer*, - v3p_netlib_doublereal*, - v3p_netlib_doublereal*, - v3p_netlib_integer*, - v3p_netlib_integer*, - v3p_netlib_integer*, - v3p_netlib_doublereal*, - void*), - v3p_netlib_doublereal *damp, - v3p_netlib_integer *leniw, - v3p_netlib_integer *lenrw, - v3p_netlib_integer *iw, - v3p_netlib_doublereal *rw, - v3p_netlib_doublereal *u, - v3p_netlib_doublereal *v, - v3p_netlib_doublereal *w, - v3p_netlib_doublereal *x, - v3p_netlib_doublereal *se, - v3p_netlib_doublereal *atol, - v3p_netlib_doublereal *btol, - v3p_netlib_doublereal *conlim, - v3p_netlib_integer *itnlim, - v3p_netlib_integer *nout, - v3p_netlib_integer *istop, - v3p_netlib_integer *itn, - v3p_netlib_doublereal *anorm, - v3p_netlib_doublereal *acond, - v3p_netlib_doublereal *rnorm, - v3p_netlib_doublereal *arnorm, - v3p_netlib_doublereal *xnorm, - void* userdata - ); diff --git a/Utilities/ITK/Utilities/vxl/v3p/netlib/linalg/lsqrBase.cxx b/Utilities/ITK/Utilities/vxl/v3p/netlib/linalg/lsqrBase.cxx new file mode 100644 index 0000000000000000000000000000000000000000..4d3fad7a4f17cbfacdefb0fbe9caa5cba82149c0 --- /dev/null +++ b/Utilities/ITK/Utilities/vxl/v3p/netlib/linalg/lsqrBase.cxx @@ -0,0 +1,821 @@ +/*========================================================================= + + Program: Insight Segmentation & Registration Toolkit + Language: C++ + Date: $Date: 2010-04-14 20:49:34 $ + Version: $Revision: 1.4 $ + + Copyright (c) Insight Software Consortium. All rights reserved. + See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "lsqrBase.h" +#include <math.h> + +#define Abs(x) ((x) >= 0 ? (x) : -(x)) + +#define CopyVector(n,x,y) \ + { \ + const double * xp = x; \ + const double * xend = xp + n; \ + double * yp = y; \ + while( xp != xend ) \ + { \ + *yp++ = *xp++; \ + } \ + } + +#define AccumulateVector(n,x,y) \ + { \ + const double * xp = x; \ + const double * xend = xp + n; \ + double * yp = y; \ + while( xp != xend ) \ + { \ + *yp++ += *xp++; \ + } \ + } + +#define AssignValueToVectorElements(n1,n2,v,x) \ + { \ + double * xp = x + n1; \ + double * xend = x + n2; \ + while( xp != xend ) \ + { \ + *xp++ = v; \ + } \ + } + +#define AssignScalarValueToVectorElements(n1,n2,v,x) \ + { \ + double * xp = x + n1; \ + double * xend = x + n2; \ + while( xp != xend ) \ + { \ + *xp++ = v; \ + } \ + } + +#define ElementWiseProductVector(n1,n2,x,y,z) \ + { \ + const double * xp = x + n1; \ + const double * xend = x + n2; \ + double * yp = y; \ + double * zp = z; \ + while( xp != xend ) \ + { \ + *zp++ = *xp++ * *yp++; \ + } \ + } + + + +lsqrBase::lsqrBase() +{ + this->eps = 1e-16; + this->atol = 1e-6; + this->btol = 1e-6; + this->conlim = 1.0 / ( 10 * sqrt( this->eps ) ); + this->itnlim = 10; + this->nout = NULL; + this->istop = 0; + this->itn = 0; + this->Anorm = 0.0; + this->Acond = 0.0; + this->rnorm = 0.0; + this->Arnorm = 0.0; + this->xnorm = 0.0; + this->bnorm = 0.0; + this->dxmax = 0.0; + this->maxdx = 0; + this->wantse = false; + this->se = NULL; + this->damp = 0.0; + this->damped = false; +} + + +lsqrBase::~lsqrBase() +{ +} + + +unsigned int +lsqrBase::GetStoppingReason() const +{ + return this->istop; +} + + +unsigned int +lsqrBase::GetNumberOfIterationsPerformed() const +{ + return this->itn; +} + + +double +lsqrBase::GetFrobeniusNormEstimateOfAbar() const +{ + return this->Anorm; +} + + +double +lsqrBase::GetConditionNumberEstimateOfAbar() const +{ + return this->Acond; +} + + +double +lsqrBase::GetFinalEstimateOfNormRbar() const +{ + return this->rnorm; +} + + +double +lsqrBase::GetFinalEstimateOfNormOfResiduals() const +{ + return this->Arnorm; +} + + +double +lsqrBase::GetFinalEstimateOfNormOfX() const +{ + return this->xnorm; +} + + +void +lsqrBase::SetStandardErrorEstimatesFlag(bool flag) +{ + this->wantse = flag; +} + + +void +lsqrBase::SetEpsilon( double value ) +{ + this->eps = value; +} + + +void +lsqrBase::SetDamp( double value ) +{ + this->damp = value; +} + + +void +lsqrBase::SetToleranceA( double value ) +{ + this->atol = value; +} + + +void +lsqrBase::SetToleranceB( double value ) +{ + this->btol = value; +} + + +void +lsqrBase::SetMaximumNumberOfIterations( unsigned int value ) +{ + this->itnlim = value; +} + + +void +lsqrBase::SetUpperLimitOnConditional( double value ) +{ + this->conlim = value; +} + + +void +lsqrBase::SetStandardErrorEstimates( double * array ) +{ + this->se = array; +} + + +void +lsqrBase::SetOutputStream( std::ostream & os ) +{ + this->nout = &os; +} + + +/** + * returns sqrt( a**2 + b**2 ) + * with precautions to avoid overflow. + */ +double +lsqrBase::D2Norm( double a, double b ) const +{ + const double scale = Abs(a) + Abs(b); + const double zero = 0.0; + + if( scale == zero ) + { + return zero; + } + + const double sa = a / scale; + const double sb = b / scale; + + return scale * sqrt( sa * sa + sb * sb ); +} + + +/** Simplified for this use from the BLAS version. */ +void +lsqrBase::Scale( unsigned int n, double factor, double *x ) const +{ + double * xend = x + n; + while( x != xend ) + { + *x++ *= factor; + } +} + + +/** Simplified for this use from the BLAS version. */ +double +lsqrBase::Dnrm2( unsigned int n, const double *x ) const +{ + double magnitudeOfLargestElement = 0.0; + + double sumOfSquaresScaled = 1.0; + + for ( unsigned int i = 0; i < n; i++ ) + { + if ( x[i] != 0.0 ) + { + double dx = x[i]; + const double absxi = Abs(dx); + + if ( magnitudeOfLargestElement < absxi ) + { + // rescale the sum to the range of the new element + dx = magnitudeOfLargestElement / absxi; + sumOfSquaresScaled = sumOfSquaresScaled * (dx * dx) + 1.0; + magnitudeOfLargestElement = absxi; + } + else + { + // rescale the new element to the range of the sum + dx = absxi / magnitudeOfLargestElement; + sumOfSquaresScaled += dx * dx; + } + } + } + + const double norm = magnitudeOfLargestElement * sqrt( sumOfSquaresScaled ); + + return norm; +} + + +/** + * + * The array b must have size m + * + */ +void lsqrBase:: +Solve( unsigned int m, unsigned int n, const double * b, double * x ) +{ + const double zero = 0.0; + const double one = 1.0; + + if( this->nout ) + { + (*this->nout) << "Enter LSQR " << std::endl; + (*this->nout) << m << ", " << n << std::endl; + (*this->nout) << this->damp << ", " << this->wantse << std::endl; + (*this->nout) << this->atol << ", " << this->conlim << std::endl; + (*this->nout) << this->btol << ", " << this->itnlim << std::endl; + } + + this->damped = ( this->damp > zero ); + + this->itn = 0; + this->istop = 0; + + unsigned int nstop = 0; + this->maxdx = 0; + + double ctol = zero; + if( this->conlim > zero ) + { + ctol = one / this->conlim; + } + + this->Anorm = zero; + this->Acond = zero; + + double dnorm = zero; + this->dxmax = zero; + double res2 = zero; + double psi = zero; + + this->xnorm = zero; + + double xnorm1 = zero; + double cs2 = -one; + double sn2 = zero; + double z = zero; + + double * u = new double[m]; + double * v = new double[n]; + double * w = new double[n]; + + //------------------------------------------------------------------- + // Set up the first vectors u and v for the bidiagonalization. + // These satisfy beta*u = b, alpha*v = A(transpose)*u. + //------------------------------------------------------------------- + CopyVector( m, b, u ); + AssignScalarValueToVectorElements( 0, n, zero, v ); + AssignScalarValueToVectorElements( 0, n, zero, w ); + AssignScalarValueToVectorElements( 0, n, zero, x ); + + if( this->wantse ) + { + AssignScalarValueToVectorElements( 0, n, zero, se ); + } + + double alpha = zero; + + double beta = this->Dnrm2( m, u ); + + if( beta > zero ) + { + this->Scale( m, ( one / beta ), u ); + this->Aprod2( m, n, v, u ); // v = A'*u + alpha = this->Dnrm2( n, v ); + } + + if( alpha > zero ) + { + this->Scale( n, ( one / alpha ), v ); + CopyVector( n, v, w ); + } + + this->Arnorm = alpha * beta; + + if ( this->Arnorm == zero ) + { + this->TerminationPrintOut(); + + // Release locally allocated arrays. + delete [] u; + delete [] v; + delete [] w; + + return; + } + + double rhobar = alpha; + double phibar = beta; + + this->bnorm = beta; + this->rnorm = beta; + + double test1 = 0.0; + double test2 = 0.0; + + + if ( this->nout ) + { + if ( damped ) + { + (*this->nout) << " Itn x(0) Function"\ + " Compatible LS Norm Abar Cond Abar alfa_opt" << std::endl; + } + else + { + (*this->nout) << " Itn x(0) Function"\ + " Compatible LS Norm A Cond A" << std::endl; + } + + test1 = one; + test2 = alpha / beta; + + this->nout->width(6); + (*this->nout) << this->itn; + this->nout->precision(9); + this->nout->width(17); + (*this->nout) << x[0] << " "; + this->nout->precision(2); + this->nout->width(10); + (*this->nout) << rnorm << " "; + this->nout->precision(1); + this->nout->width(9); + (*this->nout) << test1 << " "; + (*this->nout) << test2 << " "; + (*this->nout) << std::endl; + } + + + double temp; + double test3; + double rtol; + + + // + // Main itertation loop + // + do { + + this->itn++; + + //---------------------------------------------------------------- + // Perform the next step of the bidiagonalization to obtain the + // next beta, u, alpha, v. These satisfy + // beta*u = A*v - alpha*u, + // alpha*v = A'*u - beta*v. + //---------------------------------------------------------------- + this->Scale( m, (-alpha), u ); + + this->Aprod1( m, n, v, u ); // u = A * v + + beta = this->Dnrm2( m, u ); + + // + // Accumulate Anorm = ||Bk|| = norm([alpha beta damp]). + // + temp = this->D2Norm( alpha, beta ); + temp = this->D2Norm( temp , damp ); + this->Anorm = this->D2Norm( this->Anorm, temp ); + + if ( beta > zero ) + { + this->Scale( m, (one/beta), u ); + this->Scale( n, (- beta), v ); + this->Aprod2( m, n, v, u ); // v = A'*u + + alpha = this->Dnrm2( n, v ); + + if ( alpha > zero ) + { + this->Scale( n, (one/alpha), v ); + } + } + + //---------------------------------------------------------------- + // Use a plane rotation to eliminate the damping parameter. + // This alters the diagonal (rhobar) of the lower-bidiagonal matrix. + //--------------------------------------------------------------- + double rhbar1 = rhobar; + + if ( damped ) + { + rhbar1 = this->D2Norm( rhobar, damp ); + const double cs1 = rhobar / rhbar1; + const double sn1 = this->damp / rhbar1; + psi = sn1 * phibar; + phibar = cs1 * phibar; + } + + //---------------------------------------------------------------- + // Use a plane rotation to eliminate the subdiagonal element (beta) + // of the lower-bidiagonal matrix, giving an upper-bidiagonal matrix. + //---------------------------------------------------------------- + double rho = this->D2Norm( rhbar1, beta ); + double cs = rhbar1/rho; + double sn = beta /rho; + double theta = sn * alpha; + rhobar = - cs * alpha; + double phi = cs * phibar; + phibar = sn * phibar; + double tau = sn * phi; + + + //---------------------------------------------------------------- + // Update x, w and (perhaps) the standard error estimates. + //--------------------------------------------------------------- + double t1 = phi / rho; + double t2 = - theta / rho; + double t3 = one / rho; + double dknorm = zero; + + if ( this->wantse ) + { + for ( unsigned int i = 0; i < n; i++ ) + { + double t = w[i]; + x[i] = t1 * t + x[i]; + w[i] = t2 * t + v[i]; + t = ( t3 * t ) * ( t3 * t ); + se[i] = t + se[i]; + dknorm = t + dknorm; + } + } + else + { + for ( unsigned int i = 0; i < n; i++ ) + { + double t = w[i]; + x[i] = t1 * t + x[i]; + w[i] = t2 * t + v[i]; + dknorm = ( t3 * t )*( t3 * t ) + dknorm; + } + } + + + //---------------------------------------------------------------- + // Monitor the norm of d_k, the update to x. + // dknorm = norm( d_k ) + // dnorm = norm( D_k ), where D_k = (d_1, d_2, ..., d_k ) + // dxk = norm( phi_k d_k ), where new x = x_k + phi_k d_k. + //---------------------------------------------------------------- + dknorm = sqrt( dknorm ); + dnorm = this->D2Norm( dnorm, dknorm ); + double dxk = fabs( phi* dknorm ); + if ( this->dxmax < dxk) + { + this->dxmax = dxk; + this->maxdx = this->itn; + } + + + //---------------------------------------------------------------- + // Use a plane rotation on the right to eliminate the + // super-diagonal element (theta) of the upper-bidiagonal matrix. + // Then use the result to estimate norm(x). + //---------------------------------------------------------------- + const double delta = sn2 * rho; + const double gambar = - cs2 * rho; + const double rhs = phi - delta * z; + const double zbar = rhs /gambar; + this->xnorm = this->D2Norm( xnorm1, zbar ); + const double gamma = this->D2Norm( gambar, theta ); + cs2 = gambar / gamma; + sn2 = theta / gamma; + z = rhs / gamma; + xnorm1 = this->D2Norm( xnorm1, z ); + + //---------------------------------------------------------------- + // Test for convergence. + // First, estimate the norm and condition of the matrix Abar, + // and the norms of rbar and Abar(transpose)*rbar. + //---------------------------------------------------------------- + this->Acond = this->Anorm * dnorm; + res2 = this->D2Norm( res2, psi ); + this->rnorm = this->D2Norm( res2, phibar ); + + this->rnorm += 1e-30; // Prevent rnorm == 0.0 + this->Arnorm = alpha * fabs( tau ); + + + // Now use these norms to estimate certain other quantities, + // some of which will be small near a solution. + + const double alfopt = sqrt( this->rnorm / ( dnorm * this->xnorm ) ); + test1 = this->rnorm / bnorm; + test2 = zero; + test2 = this->Arnorm / ( this->Anorm * this->rnorm ); + test3 = one / this->Acond; + t1 = test1 / ( one + this->Anorm* xnorm / bnorm ); + rtol = btol + atol* this->Anorm* xnorm / bnorm; + + + // The following tests guard against extremely small values of + // atol, btol or ctol. (The user may have set any or all of + // the parameters atol, btol, conlim to zero.) + // The effect is equivalent to the normal tests using + // atol = eps, btol = eps, conlim = 1/eps. + + t3 = one + test3; + t2 = one + test2; + t1 = one + t1; + if ( this->itn >= this->itnlim ) istop = 5; + if ( t3 <= one ) istop = 4; + if ( t2 <= one ) istop = 2; + if ( t1 <= one ) istop = 1; + + + // Allow for tolerances set by the user. + + if ( test3 <= ctol ) istop = 4; + if ( test2 <= this->atol ) istop = 2; + if ( test1 <= rtol ) istop = 1; + + + //---------------------------------------------------------------- + // See if it is time to print something. + //---------------------------------------------------------------- + bool prnt = false; + if (nout > 0) + { + if (n <= 40) prnt = true; + if (this->itn <= 10) prnt = true; + if (this->itn >= this->itnlim-10) prnt = true; + if ( (this->itn % 10) == 0) prnt = true; + if (test3 <= 2.0*ctol) prnt = true; + if (test2 <= 10.0*atol) prnt = true; + if (test1 <= 10.0*rtol) prnt = true; + if (istop != 0) prnt = true; + + if ( prnt ) // Print a line for this iteration. + { + this->nout->width(6); + (*this->nout) << this->itn << " "; + this->nout->precision(9); + this->nout->precision(17); + (*this->nout) << x[0] << " "; + this->nout->precision(2); + this->nout->precision(10); + (*this->nout) << rnorm << " "; + this->nout->precision(1); + this->nout->precision(9); + (*this->nout) << test1 << " "; + (*this->nout) << test2 << " "; + (*this->nout) << this->Anorm << " "; + (*this->nout) << this->Acond << " "; + (*this->nout) << alfopt << " "; + (*this->nout) << std::endl; + } + } + + + //---------------------------------------------------------------- + // Stop if appropriate. + // The convergence criteria are required to be met on nconv + // consecutive iterations, where nconv is set below. + // Suggested value: nconv = 1, 2 or 3. + //---------------------------------------------------------------- + + if (istop == 0) + { + nstop = 0; + } + else + { + const unsigned int nconv = 1; + nstop = nstop + 1; + + if ( ( nstop < nconv ) && ( this->itn < this->itnlim ) ) + { + istop = 0; + } + } + + } while ( istop == 0); + + //=================================================================== + // End of iteration loop. + //=================================================================== + + + if ( this->wantse ) // Finish off the + { // standard error estimates. + double t = one; + + if ( m > n ) + { + t = m - n; + } + + if ( damped ) + { + t = m; + } + + t = this->rnorm / sqrt(t); + + for ( unsigned int i = 0; i < n; i++ ) + { + se[i] = t * sqrt( se[i] ); + } + } + + this->TerminationPrintOut(); + + // Release locally allocated arrays. + delete [] u; + delete [] v; + delete [] w; +} + + +void lsqrBase:: +TerminationPrintOut() +{ + // Decide if istop = 2 or 3. + if ( this->damped && this->istop == 2) + { + this->istop = 3; + } + + if ( this->nout ) + { + std::string exitt = " Exit LSQR. "; + + (*this->nout) << exitt.c_str(); + (*this->nout) << "istop = "; + this->nout->width(6); + (*this->nout) << istop; + + (*this->nout) << " itn = "; + this->nout->width(15); + (*this->nout) << this->itn; + + (*this->nout) << std::endl; + + (*this->nout) << exitt.c_str(); + (*this->nout) << "Anorm = "; + this->nout->precision(5); + this->nout->width(12); + (*this->nout) << this->Anorm; + + (*this->nout) << "Acond = "; + this->nout->precision(5); + this->nout->width(12); + (*this->nout) << this->Acond; + + (*this->nout) << std::endl; + + (*this->nout) << exitt.c_str(); + (*this->nout) << "bnorm = "; + this->nout->precision(5); + this->nout->width(12); + (*this->nout) << this->bnorm; + + (*this->nout) << "xnorm = "; + this->nout->precision(5); + this->nout->width(12); + (*this->nout) << this->xnorm; + + (*this->nout) << std::endl; + + (*this->nout) << exitt.c_str(); + (*this->nout) << "rnorm = "; + this->nout->precision(5); + this->nout->width(12); + (*this->nout) << this->rnorm; + + (*this->nout) << "Arnorm = "; + this->nout->precision(5); + this->nout->width(12); + (*this->nout) << this->Arnorm; + + (*this->nout) << std::endl; + + (*this->nout) << exitt.c_str(); + (*this->nout) << "max dx = "; + this->nout->precision(1); + this->nout->width(8); + (*this->nout) << this->dxmax; + + (*this->nout) << " occurred at itn = "; + this->nout->width(8); + (*this->nout) << this->maxdx; + this->nout->precision(1); + this->nout->width(8); + + (*this->nout) << std::endl; + + (*this->nout) << exitt.c_str(); + (*this->nout) << this->dxmax / (this->xnorm+1.0e-30); + + (*this->nout) << std::endl; + + (*this->nout) << exitt.c_str(); + + switch( this->istop ) + { + case 0: + (*this->nout) << "The exact solution is x = 0 " << std::endl; + break; + case 1: + (*this->nout) << "'A solution to Ax = b was found, given atol, btol " << std::endl; + break; + case 2: + (*this->nout) << "'A least-squares solution was found, given atol " << std::endl; + break; + case 3: + (*this->nout) << " 'A damped least-squares solution was found, given atol " << std::endl; + break; + case 4: + (*this->nout) << " 'Cond(Abar) seems to be too large, given conlim " << std::endl; + break; + case 5: + (*this->nout) << " 'The iteration limit was reached " << std::endl; + break; + } + + } + +} diff --git a/Utilities/ITK/Utilities/vxl/v3p/netlib/linalg/lsqrBase.h b/Utilities/ITK/Utilities/vxl/v3p/netlib/linalg/lsqrBase.h new file mode 100644 index 0000000000000000000000000000000000000000..5f2b0956cae08810f3395517fb52491595906f4e --- /dev/null +++ b/Utilities/ITK/Utilities/vxl/v3p/netlib/linalg/lsqrBase.h @@ -0,0 +1,335 @@ +/*========================================================================= + + Program: Insight Segmentation & Registration Toolkit + Language: C++ + Date: $Date: 2010-04-14 19:43:36 $ + Version: $Revision: 1.2 $ + + Copyright (c) Insight Software Consortium. All rights reserved. + See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef __itk_lsqr_h +#define __itk_lsqr_h + +#include <iostream> + + +/** \class lsqrBase + * + * \brief implement a solver for a set of linear equations. + * + * LSQR finds a solution x to the following problems: + * + * 1. Unsymmetric equations: Solve A*x = b + * + * 2. Linear least squares: Solve A*x = b + * in the least-squares sense + * + * 3. Damped least squares: Solve ( A )*x = ( b ) + * ( damp*I ) ( 0 ) + * in the least-squares sense + * + * where A is a matrix with m rows and n columns, b is an m-vector, + * and damp is a scalar. (All quantities are real.) + * The matrix A is treated as a linear operator. It is accessed + * by means of subroutine calls with the following purpose: + * + * call Aprod1(m,n,x,y) must compute y = y + A*x without altering x. + * call Aprod2(m,n,x,y) must compute x = x + A'*y without altering y. + * + * LSQR uses an iterative method to approximate the solution. + * The number of iterations required to reach a certain accuracy + * depends strongly on the scaling of the problem. Poor scaling of + * the rows or columns of A should therefore be avoided where + * possible. + * + * For example, in problem 1 the solution is unaltered by + * row-scaling. If a row of A is very small or large compared to + * the other rows of A, the corresponding row of ( A b ) should be + * scaled up or down. + * + * In problems 1 and 2, the solution x is easily recovered + * following column-scaling. Unless better information is known, + * the nonzero columns of A should be scaled so that they all have + * the same Euclidean norm (e.g., 1.0). + * + * In problem 3, there is no freedom to re-scale if damp is + * nonzero. However, the value of damp should be assigned only + * after attention has been paid to the scaling of A. + * + * The parameter damp is intended to help regularize + * ill-conditioned systems, by preventing the true solution from + * being very large. Another aid to regularization is provided by + * the parameter Acond, which may be used to terminate iterations + * before the computed solution becomes very large. + * + * This class is a direct C++ translation from the Fortran90 version + * of the solver that is available at + * http://www.stanford.edu/group/SOL/software.html + * distributed under a BSD license. + * + * This class is a replacement for the lsqr code taken from netlib. + * That code had to be removed because it is copyrighted by ACM and + * its license was incompatible with a BSD license. + * + */ +class lsqrBase +{ +public: + + lsqrBase(); + virtual ~lsqrBase(); + + /** + * computes y = y + A*x without altering x, + * where A is a matrix of dimensions A[m][n]. + * The size of the vector x is n. + * The size of the vector y is m. + */ + virtual void Aprod1(unsigned int m, unsigned int n, const double * x, double * y ) const = 0; + + /** + * computes x = x + A'*y without altering y, + * where A is a matrix of dimensions A[m][n]. + * The size of the vector x is n. + * The size of the vector y is m. + */ + virtual void Aprod2(unsigned int m, unsigned int n, double * x, const double * y ) const = 0; + + /** + * returns sqrt( a**2 + b**2 ) + * with precautions to avoid overflow. + */ + double D2Norm( double a, double b ) const; + + /** + * returns sqrt( x' * x ) + * with precautions to avoid overflow. + */ + double Dnrm2( unsigned int n, const double *x ) const; + + /** + * Scale a vector by multiplying with a constant + */ + void Scale( unsigned int n, double factor, double *x ) const; + + /** A logical variable to say if the array se(*) of standard error estimates + * should be computed. If m > n or damp > 0, the system is overdetermined + * and the standard errors may be useful. (See the first LSQR reference.) + * Otherwise (m <= n and damp = 0) they do not mean much. Some time and + * storage can be saved by setting wantse = .false. and using any convenient + * array for se(*), which won't be touched. If you call this method with the + * flag ON, then you MUST provide a working memory array to store the standard + * error estimates, via the method SetStandardErrorEstimates() + */ + void SetStandardErrorEstimatesFlag( bool ); + + /** An estimate of the relative error in the data + * defining the matrix A. For example, if A is + * accurate to about 6 digits, set atol = 1.0e-6. + */ + void SetToleranceA( double ); + + /** An estimate of the relative error in the data + * defining the rhs b. For example, if b is + * accurate to about 6 digits, set btol = 1.0e-6. + */ + void SetToleranceB( double ); + + /** An upper limit on cond(Abar), the apparent + * condition number of the matrix Abar. + * Iterations will be terminated if a computed + * estimate of cond(Abar) exceeds conlim. + * This is intended to prevent certain small or + * zero singular values of A or Abar from + * coming into effect and causing unwanted growth + * in the computed solution. + * + * conlim and damp may be used separately or + * together to regularize ill-conditioned systems. + * + * Normally, conlim should be in the range + * 1000 to 1/eps. + * Suggested value: + * conlim = 1/(100*eps) for compatible systems, + * conlim = 1/(10*sqrt(eps)) for least squares. + * + * Note: Any or all of atol, btol, conlim may be set to zero. + * The effect will be the same as the values eps, eps, 1/eps. + * + */ + void SetUpperLimitOnConditional( double ); + + /** the relative precision of floating-point arithmetic. + * On most machines, eps is about 1.0e-7 and 1.0e-16 + * in single and double precision respectively. + * We expect eps to be about 1e-16 always. + */ + void SetEpsilon( double ); + + /** + * The damping parameter for problem 3 above. + * (damp should be 0.0 for problems 1 and 2.) + * If the system A*x = b is incompatible, values + * of damp in the range 0 to sqrt(eps)*norm(A) + * will probably have a negligible effect. + * Larger values of damp will tend to decrease + * the norm of x and reduce the number of + * iterations required by LSQR. + * + * The work per iteration and the storage needed + * by LSQR are the same for all values of damp. + * + */ + void SetDamp( double ); + + /** An upper limit on the number of iterations. + * Suggested value: + * itnlim = n/2 for well-conditioned systems + * with clustered singular values, + * itnlim = 4*n otherwise. + */ + void SetMaximumNumberOfIterations( unsigned int ); + + /** + * If provided, a summary will be printed out to this stream during + * the execution of the Solve function. + */ + void SetOutputStream( std::ostream & os ); + + /** Provide the array where the standard error estimates will be stored. + * You MUST provide this working memory array if you turn on the computation + * of standard error estimates with teh method SetStandardErrorEstimatesFlag(). + */ + void SetStandardErrorEstimates( double * array ); + + /** + * Returns an integer giving the reason for termination: + * + * 0 x = 0 is the exact solution. + * No iterations were performed. + * + * 1 The equations A*x = b are probably compatible. + * Norm(A*x - b) is sufficiently small, given the + * values of atol and btol. + * + * 2 damp is zero. The system A*x = b is probably + * not compatible. A least-squares solution has + * been obtained that is sufficiently accurate, + * given the value of atol. + * + * 3 damp is nonzero. A damped least-squares + * solution has been obtained that is sufficiently + * accurate, given the value of atol. + * + * 4 An estimate of cond(Abar) has exceeded conlim. + * The system A*x = b appears to be ill-conditioned, + * or there could be an error in Aprod1 or Aprod2. + * + * 5 The iteration limit itnlim was reached. + * + */ + unsigned int GetStoppingReason() const; + + + /** Returns the actual number of iterations performed. */ + unsigned int GetNumberOfIterationsPerformed() const; + + + /** + * An estimate of the Frobenius norm of Abar. + * This is the square-root of the sum of squares + * of the elements of Abar. + * If damp is small and the columns of A + * have all been scaled to have length 1.0, + * Anorm should increase to roughly sqrt(n). + * A radically different value for Anorm may + * indicate an error in Aprod1 or Aprod2. + */ + double GetFrobeniusNormEstimateOfAbar() const; + + + /** + * An estimate of cond(Abar), the condition + * number of Abar. A very high value of Acond + * may again indicate an error in Aprod1 or Aprod2. + */ + double GetConditionNumberEstimateOfAbar() const; + + + /** An estimate of the final value of norm(rbar), + * the function being minimized (see notation + * above). This will be small if A*x = b has + * a solution. + */ + double GetFinalEstimateOfNormRbar() const; + + + /** An estimate of the final value of + * norm( Abar(transpose)*rbar ), the norm of + * the residual for the normal equations. + * This should be small in all cases. (Arnorm + * will often be smaller than the true value + * computed from the output vector x.) + */ + double GetFinalEstimateOfNormOfResiduals() const; + + + /** + * An estimate of norm(x) for the final solution x. + */ + double GetFinalEstimateOfNormOfX() const; + + + /** + * Execute the solver + * + * solves Ax = b or min ||Ax - b|| with or without damping, + * + * m is the size of the input vector b + * n is the size of the output vector x + */ + void Solve( unsigned int m, unsigned int n, const double * b, double * x ); + +private: + + void TerminationPrintOut(); + + double * wm; // work vector + double * wn; // work vector + + double Anorm; + double Acond; + double bnorm; + double rnorm; + double Arnorm; + double xnorm; + double dxmax; + + double atol; + double btol; + double conlim; + + double eps; + double damp; + bool damped; + + unsigned int itnlim; + unsigned int itn; + + unsigned int istop; + + unsigned int maxdx; + + std::ostream * nout; + + bool wantse; + double * se; +}; + +#endif diff --git a/Utilities/ITK/Utilities/vxl/v3p/netlib/sparse/documentation.txt b/Utilities/ITK/Utilities/vxl/v3p/netlib/sparse/documentation.txt old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Utilities/vxl/v3p/netlib/sparse/readme.txt b/Utilities/ITK/Utilities/vxl/v3p/netlib/sparse/readme.txt old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Utilities/vxl/v3p/netlib/sparse/spAllocate.c b/Utilities/ITK/Utilities/vxl/v3p/netlib/sparse/spAllocate.c old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Utilities/vxl/v3p/netlib/sparse/spBuild.c b/Utilities/ITK/Utilities/vxl/v3p/netlib/sparse/spBuild.c old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Utilities/vxl/v3p/netlib/sparse/spConfig.h b/Utilities/ITK/Utilities/vxl/v3p/netlib/sparse/spConfig.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Utilities/vxl/v3p/netlib/sparse/spDefs.h b/Utilities/ITK/Utilities/vxl/v3p/netlib/sparse/spDefs.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Utilities/vxl/v3p/netlib/sparse/spFactor.c b/Utilities/ITK/Utilities/vxl/v3p/netlib/sparse/spFactor.c old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Utilities/vxl/v3p/netlib/sparse/spMatrix.h b/Utilities/ITK/Utilities/vxl/v3p/netlib/sparse/spMatrix.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Utilities/vxl/v3p/netlib/sparse/spOutput.c b/Utilities/ITK/Utilities/vxl/v3p/netlib/sparse/spOutput.c old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Utilities/vxl/v3p/netlib/sparse/spSolve.c b/Utilities/ITK/Utilities/vxl/v3p/netlib/sparse/spSolve.c old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Utilities/vxl/v3p/netlib/sparse/spUtils.c b/Utilities/ITK/Utilities/vxl/v3p/netlib/sparse/spUtils.c old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Utilities/vxl/v3p/netlib/tests/CMakeLists.txt b/Utilities/ITK/Utilities/vxl/v3p/netlib/tests/CMakeLists.txt index 579656fc97e6fecaccd5a367a41285fb5e935467..768ce24f14deb1206e93883621fc932ef9af1a14 100644 --- a/Utilities/ITK/Utilities/vxl/v3p/netlib/tests/CMakeLists.txt +++ b/Utilities/ITK/Utilities/vxl/v3p/netlib/tests/CMakeLists.txt @@ -8,9 +8,9 @@ IF(BUILD_TESTING) ADD_TEST( netlib_test_lbfgsb ${EXECUTABLE_OUTPUT_PATH}/netlib_lbfgsb_example ) TARGET_LINK_LIBRARIES(netlib_lbfgsb_example itkv3p_netlib) # test - ADD_EXECUTABLE( netlib_lsqr_test lsqr-test.c ) - ADD_TEST( netlib_test_lsqr ${EXECUTABLE_OUTPUT_PATH}/netlib_lsqr_test ) - TARGET_LINK_LIBRARIES(netlib_lsqr_test itkv3p_netlib) + # FIXME ADD_EXECUTABLE( netlib_lsqr_test lsqr-test.c ) + # FIXME ADD_TEST( netlib_test_lsqr ${EXECUTABLE_OUTPUT_PATH}/netlib_lsqr_test ) + # FIXME TARGET_LINK_LIBRARIES(netlib_lsqr_test itkv3p_netlib) # test ADD_EXECUTABLE( netlib_slamch_test slamch-test.c ) ADD_TEST( netlib_test_slamch ${EXECUTABLE_OUTPUT_PATH}/netlib_slamch_test ) diff --git a/Utilities/ITK/Utilities/vxl/v3p/netlib/toms/rpoly.P b/Utilities/ITK/Utilities/vxl/v3p/netlib/toms/rpoly.P deleted file mode 100644 index 4e4895ff4276c0a0c6a4755a9de9a130f68625b5..0000000000000000000000000000000000000000 --- a/Utilities/ITK/Utilities/vxl/v3p/netlib/toms/rpoly.P +++ /dev/null @@ -1 +0,0 @@ -extern int rpoly_(doublereal *op, integer *degree, doublereal *zeror, doublereal *zeroi, logical *fail); diff --git a/Utilities/ITK/Utilities/vxl/v3p/netlib/toms/rpoly.c b/Utilities/ITK/Utilities/vxl/v3p/netlib/toms/rpoly.c deleted file mode 100644 index e632e5cac295da8f89914f465f20753497c49c71..0000000000000000000000000000000000000000 --- a/Utilities/ITK/Utilities/vxl/v3p/netlib/toms/rpoly.c +++ /dev/null @@ -1,913 +0,0 @@ -#include "v3p_netlib.h" - -#undef abs -#undef min -#undef max -#include <math.h> -#define abs(x) ((x) >= 0 ? (x) : -(x)) -#define min(a,b) ((a) <= (b) ? (a) : (b)) -#define max(a,b) ((a) >= (b) ? (a) : (b)) - -static void calcsc_(integer *type, - v3p_netlib_rpoly_global_t* v3p_netlib_rpoly_global_arg); -static void fxshfr_(integer *l2, integer *nz, - v3p_netlib_rpoly_global_t* v3p_netlib_rpoly_global_arg); -static void newest_(integer *type, doublereal *uu, doublereal *vv, - v3p_netlib_rpoly_global_t* v3p_netlib_rpoly_global_arg); -static void nextk_(integer *type, - v3p_netlib_rpoly_global_t* v3p_netlib_rpoly_global_arg); -static void quadit_(doublereal *uu, doublereal *vv, integer *nz, - v3p_netlib_rpoly_global_t* v3p_netlib_rpoly_global_arg); -static void realit_(doublereal *sss, integer *nz, integer *iflag, - v3p_netlib_rpoly_global_t* v3p_netlib_rpoly_global_arg); -static void quadsd_(integer *nn, doublereal *u, doublereal *v, - doublereal *p, doublereal *q, doublereal *a, - doublereal *b); -static void quad_(doublereal *a, doublereal *b1, doublereal *c, - doublereal *sr, doublereal *si, doublereal *lr, - doublereal *li); - -#define global_1 (*v3p_netlib_rpoly_global_arg) - -/* Table of constant values */ -static doublereal c_b41 = 1.; - -#ifdef _MSC_VER -// This needs to be before the start of the function that contains the offending code -# pragma warning ( disable : 4756) -#endif - -/* ====================================================================== */ -/* NIST Guide to Available Math Software. */ -/* Fullsource for module 493 from package TOMS. */ -/* Retrieved from NETLIB on Wed Jul 3 11:47:53 1996. */ -/* ====================================================================== */ - -/* Subroutine */ void rpoly_( - doublereal* op, integer* degree, - doublereal* zeror, doublereal* zeroi, - logical* fail, - v3p_netlib_rpoly_global_t* v3p_netlib_rpoly_global_arg - ) -{ - /* Builtin functions */ - double log(doublereal), pow_di(doublereal *, integer *), exp(doublereal); - - /* System generated locals */ - integer i__1; - - /* Local variables */ - doublereal base; - doublereal temp[101]; - real cosr, sinr; - integer i, j, l; - doublereal t; - real x, infin; - logical zerok; - doublereal aa, bb, cc; - real df, ff; - integer jj; - real sc, lo, dx, pt[101], xm; - integer nz; - doublereal factor; - real xx, yy, smalno; - integer nm1; - real bnd, min_, max_; - integer cnt; - real xxx; - -/* FINDS THE ZEROS OF A REAL POLYNOMIAL */ -/* OP - DOUBLE PRECISION VECTOR OF COEFFICIENTS IN */ -/* ORDER OF DECREASING POWERS. */ -/* DEGREE - INTEGER DEGREE OF POLYNOMIAL. */ -/* ZEROR, ZEROI - OUTPUT DOUBLE PRECISION VECTORS OF */ -/* REAL AND IMAGINARY PARTS OF THE */ -/* ZEROS. */ -/* FAIL - OUTPUT LOGICAL PARAMETER, TRUE ONLY IF */ -/* LEADING COEFFICIENT IS ZERO OR IF RPOLY */ -/* HAS FOUND FEWER THAN DEGREE ZEROS. */ -/* IN THE LATTER CASE DEGREE IS RESET TO */ -/* THE NUMBER OF ZEROS FOUND. */ -/* TO CHANGE THE SIZE OF POLYNOMIALS WHICH CAN BE */ -/* SOLVED, RESET THE DIMENSIONS OF THE ARRAYS IN THE */ -/* COMMON AREA AND IN THE FOLLOWING DECLARATIONS. */ -/* THE SUBROUTINE USES SINGLE PRECISION CALCULATIONS */ -/* FOR SCALING, BOUNDS AND ERROR CALCULATIONS. ALL */ -/* CALCULATIONS FOR THE ITERATIONS ARE DONE IN DOUBLE */ -/* PRECISION. */ -/* THE FOLLOWING STATEMENTS SET MACHINE CONSTANTS USED */ -/* IN VARIOUS PARTS OF THE PROGRAM. THE MEANING OF THE */ -/* FOUR CONSTANTS ARE... */ -/* ETA THE MAXIMUM RELATIVE REPRESENTATION ERROR */ -/* WHICH CAN BE DESCRIBED AS THE SMALLEST */ -/* POSITIVE FLOATING POINT NUMBER SUCH THAT */ -/* 1.D0+ETA IS GREATER THAN 1. */ -/* INFIN THE LARGEST FLOATING-POINT NUMBER. */ -/* SMALNO THE SMALLEST POSITIVE FLOATING-POINT NUMBER */ -/* IF THE EXPONENT RANGE DIFFERS IN SINGLE AND */ -/* DOUBLE PRECISION THEN SMALNO AND INFIN */ -/* SHOULD INDICATE THE SMALLER RANGE. */ -/* BASE THE BASE OF THE FLOATING-POINT NUMBER */ -/* SYSTEM USED. */ -/* THE VALUES BELOW CORRESPOND TO THE BURROUGHS B6700 */ -/* changed for sparc, but these seem better -- awf */ - - base = 2.0; - global_1.eta = 2.23e-16f; - infin = 3.40282346638528860e+38f; - smalno = 1e-33f; -/* ARE AND MRE REFER TO THE UNIT ERROR IN + AND * */ -/* RESPECTIVELY. THEY ARE ASSUMED TO BE THE SAME AS */ -/* ETA. */ - global_1.are = global_1.eta; - global_1.mre = global_1.eta; - lo = smalno / global_1.eta; -/* INITIALIZATION OF CONSTANTS FOR SHIFT ROTATION */ - xx = 0.70710678f; - yy = -xx; - cosr = -0.069756474f; - sinr = 0.99756405f; - *fail = FALSE_; - global_1.n = *degree; - global_1.nn = global_1.n + 1; -/* ALGORITHM FAILS IF THE LEADING COEFFICIENT IS ZERO. */ - if (op[0] == 0.) { - *fail = TRUE_; - *degree = 0; - return; - } -/* REMOVE THE ZEROS AT THE ORIGIN IF ANY */ - while (op[global_1.nn - 1] == 0.) { - j = *degree - global_1.n; - zeror[j] = 0.; - zeroi[j] = 0.; - --global_1.nn; - --global_1.n; - } -/* MAKE A COPY OF THE COEFFICIENTS */ - for (i = 0; i < global_1.nn; ++i) { - global_1.p[i] = op[i]; - } -/* START THE ALGORITHM FOR ONE ZERO */ -L40: - if (global_1.n > 2) { - goto L60; - } - if (global_1.n < 1) { - return; - } -/* CALCULATE THE FINAL ZERO OR PAIR OF ZEROS */ - if (global_1.n != 2) { - zeror[*degree-1] = -global_1.p[1] / global_1.p[0]; - zeroi[*degree-1] = 0.; - return; - } - quad_(global_1.p, &global_1.p[1], &global_1.p[2], - &zeror[*degree-2], &zeroi[*degree-2], &zeror[*degree-1], &zeroi[*degree-1]); - return; -/* FIND LARGEST AND SMALLEST MODULI OF COEFFICIENTS. */ -L60: - max_ = 0.0f; - min_ = infin; - for (i = 0; i < global_1.nn; ++i) { - x = (real)abs(global_1.p[i]); - if (x > max_) { - max_ = x; - } - if (x != 0.0f && x < min_) { - min_ = x; - } - } -/* SCALE IF THERE ARE LARGE OR VERY SMALL COEFFICIENTS */ -/* COMPUTES A SCALE FACTOR TO MULTIPLY THE */ -/* COEFFICIENTS OF THE POLYNOMIAL. THE SCALING IS DONE */ -/* TO AVOID OVERFLOW AND TO AVOID UNDETECTED UNDERFLOW */ -/* INTERFERING WITH THE CONVERGENCE CRITERION. */ -/* THE FACTOR IS A POWER OF THE BASE */ - sc = lo / min_; - if (sc > 1.0f) { - goto L80; - } - if (max_ < 10.0f) { - goto L110; - } - if (sc == 0.0f) { - sc = smalno; - } - goto L90; -L80: - if (infin / sc < max_) { - goto L110; - } -L90: - l = (int)(log((doublereal)sc) / log(base) + 0.5); - factor = base; - factor = pow_di(&factor, &l); - if (factor == 1.) { - goto L110; - } - for (i = 0; i < global_1.nn; ++i) { - global_1.p[i] *= factor; - } -/* COMPUTE LOWER BOUND ON MODULI OF ZEROS. */ -L110: - for (i = 0; i < global_1.nn; ++i) { - pt[i] = (real)abs(global_1.p[i]); - } - pt[global_1.nn - 1] = -pt[global_1.nn - 1]; -/* COMPUTE UPPER ESTIMATE OF BOUND */ - x = (real)exp((log(-pt[global_1.nn - 1]) - log(pt[0])) / global_1.n); - if (pt[global_1.n - 1] == 0.0f) { - goto L130; - } -/* IF NEWTON STEP AT THE ORIGIN IS BETTER, USE IT. */ - xm = -pt[global_1.nn - 1] / pt[global_1.n - 1]; - if (xm < x) { - x = xm; - } -/* CHOP THE INTERVAL (0,X) UNTIL FF .LE. 0 */ -L130: - xm = x * 0.1f; - ff = pt[0]; - for (i = 1; i < global_1.nn; ++i) { - ff = ff * xm + pt[i]; - } - if (ff > 0.0f) { - x = xm; - goto L130; - } - dx = x; -/* DO NEWTON ITERATION UNTIL X CONVERGES TO TWO */ -/* DECIMAL PLACES */ - while (abs(dx/x) > 0.005f) { - ff = pt[0]; - df = ff; - for (i = 1; i < global_1.n; ++i) { - ff = ff * x + pt[i]; - df = df * x + ff; - } - ff = ff * x + pt[global_1.nn - 1]; - dx = ff / df; - x -= dx; - } - bnd = x; -/* COMPUTE THE DERIVATIVE AS THE INITIAL K POLYNOMIAL */ -/* AND DO 5 STEPS WITH NO SHIFT */ - nm1 = global_1.n - 1; - for (i = 1; i < global_1.n; ++i) { - global_1.k[i] = (global_1.nn - i - 1) * global_1.p[i] / global_1.n; - } - global_1.k[0] = global_1.p[0]; - aa = global_1.p[global_1.nn - 1]; - bb = global_1.p[global_1.n - 1]; - zerok = global_1.k[global_1.n - 1] == 0.; - for (jj = 1; jj <= 5; ++jj) { - cc = global_1.k[global_1.n - 1]; - if (zerok) { /* USE UNSCALED FORM OF RECURRENCE */ - for (i = 0; i < nm1; ++i) { - j = global_1.nn - i - 2; - global_1.k[j] = global_1.k[j - 1]; - } - global_1.k[0] = 0.; - zerok = global_1.k[global_1.n - 1] == 0.; - } - else { /* USE SCALED FORM OF RECURRENCE */ - t = -aa / cc; - for (i = 0; i < nm1; ++i) { - j = global_1.nn - i - 2; - global_1.k[j] = t * global_1.k[j - 1] + global_1.p[j]; - } - global_1.k[0] = global_1.p[0]; - zerok = abs(global_1.k[global_1.n - 1]) <= abs(bb) * global_1.eta * 10.0; - } - } -/* SAVE K FOR RESTARTS WITH NEW SHIFTS */ - for (i = 0; i < global_1.n; ++i) { - temp[i] = global_1.k[i]; - } -/* LOOP TO SELECT THE QUADRATIC CORRESPONDING TO EACH */ -/* NEW SHIFT */ - for (cnt = 1; cnt <= 20; ++cnt) { -/* QUADRATIC CORRESPONDS TO A DOUBLE SHIFT TO A */ -/* NON-REAL POINT AND ITS COMPLEX CONJUGATE. THE POINT */ -/* HAS MODULUS BND AND AMPLITUDE ROTATED BY 94 DEGREES */ -/* FROM THE PREVIOUS SHIFT */ - xxx = cosr * xx - sinr * yy; - yy = sinr * xx + cosr * yy; - xx = xxx; - global_1.sr = bnd * xx; - global_1.si = bnd * yy; - global_1.u = global_1.sr * -2.; - global_1.v = bnd; -/* SECOND STAGE CALCULATION, FIXED QUADRATIC */ - i__1 = cnt * 20; - fxshfr_(&i__1, &nz, v3p_netlib_rpoly_global_arg); - if (nz == 0) { - goto L260; - } -/* THE SECOND STAGE JUMPS DIRECTLY TO ONE OF THE THIRD */ -/* STAGE ITERATIONS AND RETURNS HERE IF SUCCESSFUL. */ -/* DEFLATE THE POLYNOMIAL, STORE THE ZERO OR ZEROS AND */ -/* RETURN TO THE MAIN ALGORITHM. */ - j = *degree - global_1.n; - zeror[j] = global_1.szr; - zeroi[j] = global_1.szi; - global_1.nn -= nz; - global_1.n = global_1.nn - 1; - for (i = 0; i < global_1.nn; ++i) { - global_1.p[i] = global_1.qp[i]; - } - if (nz == 1) { - goto L40; - } - zeror[j + 1] = global_1.lzr; - zeroi[j + 1] = global_1.lzi; - goto L40; -/* IF THE ITERATION IS UNSUCCESSFUL ANOTHER QUADRATIC */ -/* IS CHOSEN AFTER RESTORING K */ -L260: - for (i = 0; i < global_1.n; ++i) { - global_1.k[i] = temp[i]; - } - } -/* RETURN WITH FAILURE IF NO CONVERGENCE WITH 20 */ -/* SHIFTS */ - *fail = TRUE_; - *degree -= global_1.n; -} /* rpoly_ */ - -/* Subroutine */ -static void fxshfr_(integer *l2, integer *nz, - v3p_netlib_rpoly_global_t* v3p_netlib_rpoly_global_arg) -{ - /* Local variables */ - integer type; - logical stry, vtry; - integer i, j, iflag; - doublereal s; - real betas, betav; - logical spass; - logical vpass; - doublereal ui, vi; - real ts, tv, vv; - real ots=0, otv=0, tss; - doublereal ss, oss, ovv, svu, svv; - real tvv; - -/* COMPUTES UP TO L2 FIXED SHIFT K-POLYNOMIALS, */ -/* TESTING FOR CONVERGENCE IN THE LINEAR OR QUADRATIC */ -/* CASE. INITIATES ONE OF THE VARIABLE SHIFT */ -/* ITERATIONS AND RETURNS WITH THE NUMBER OF ZEROS */ -/* FOUND. */ -/* L2 - LIMIT OF FIXED SHIFT STEPS */ -/* NZ - NUMBER OF ZEROS FOUND */ - *nz = 0; - betav = .25f; - betas = .25f; - oss = global_1.sr; - ovv = global_1.v; -/* EVALUATE POLYNOMIAL BY SYNTHETIC DIVISION */ - quadsd_(&global_1.nn, &global_1.u, &global_1.v, global_1.p, global_1.qp, &global_1.a, &global_1.b); - calcsc_(&type, v3p_netlib_rpoly_global_arg); - for (j = 1; j <= *l2; ++j) { -/* CALCULATE NEXT K POLYNOMIAL AND ESTIMATE V */ - nextk_(&type, v3p_netlib_rpoly_global_arg); - calcsc_(&type, v3p_netlib_rpoly_global_arg); - newest_(&type, &ui, &vi, v3p_netlib_rpoly_global_arg); - vv = (real)vi; -/* ESTIMATE S */ - ss = 0.0; - if (global_1.k[global_1.n - 1] != 0.) { - ss = -global_1.p[global_1.nn - 1] / global_1.k[global_1.n - 1]; - } - tv = 1.0f; - ts = 1.0f; - if (j == 1 || type == 3) { - goto L70; - } -/* COMPUTE RELATIVE MEASURES OF CONVERGENCE OF S AND V */ -/* SEQUENCES */ - if (vv != 0.0f) { - tv = (real)abs((vv - ovv) / vv); - } - if (ss != 0.0) { - ts = (real)abs((ss - oss) / ss); - } -/* IF DECREASING, MULTIPLY TWO MOST RECENT */ -/* CONVERGENCE MEASURES */ - tvv = 1.0f; - if (tv < otv) { - tvv = tv * otv; - } - tss = 1.0f; - if (ts < ots) { - tss = ts * ots; - } -/* COMPARE WITH CONVERGENCE CRITERIA */ - vpass = tvv < betav; - spass = tss < betas; - if (! (spass || vpass)) { - goto L70; - } -/* AT LEAST ONE SEQUENCE HAS PASSED THE CONVERGENCE */ -/* TEST. STORE VARIABLES BEFORE ITERATING */ - svu = global_1.u; - svv = global_1.v; - for (i = 1; i <= global_1.n; ++i) { - global_1.svk[i - 1] = global_1.k[i - 1]; - } - s = ss; -/* CHOOSE ITERATION ACCORDING TO THE FASTEST */ -/* CONVERGING SEQUENCE */ - vtry = FALSE_; - stry = FALSE_; - if (spass && (! vpass || tss < tvv)) { - goto L40; - } -L20: - quadit_(&ui, &vi, nz, v3p_netlib_rpoly_global_arg); - if (*nz > 0) { - return; - } -/* QUADRATIC ITERATION HAS FAILED. FLAG THAT IT HAS */ -/* BEEN TRIED AND DECREASE THE CONVERGENCE CRITERION. */ - vtry = TRUE_; - betav *= 0.25f; -/* TRY LINEAR ITERATION IF IT HAS NOT BEEN TRIED AND */ -/* THE S SEQUENCE IS CONVERGING */ - if (stry || ! spass) { - goto L50; - } - for (i = 1; i <= global_1.n; ++i) { - global_1.k[i - 1] = global_1.svk[i - 1]; - } -L40: - realit_(&s, nz, &iflag, v3p_netlib_rpoly_global_arg); - if (*nz > 0) { - return; - } -/* LINEAR ITERATION HAS FAILED. FLAG THAT IT HAS BEEN */ -/* TRIED AND DECREASE THE CONVERGENCE CRITERION */ - stry = TRUE_; - betas *= 0.25f; -/* IF LINEAR ITERATION SIGNALS AN ALMOST DOUBLE REAL */ -/* ZERO ATTEMPT QUADRATIC ITERATION */ - if (iflag != 0) { - ui = -(s + s); - vi = s * s; - goto L20; - } -/* RESTORE VARIABLES */ -L50: - global_1.u = svu; - global_1.v = svv; - for (i = 1; i <= global_1.n; ++i) { - global_1.k[i - 1] = global_1.svk[i - 1]; - } -/* TRY QUADRATIC ITERATION IF IT HAS NOT BEEN TRIED */ -/* AND THE V SEQUENCE IS CONVERGING */ - if (vpass && ! vtry) { - goto L20; - } -/* RECOMPUTE QP AND SCALAR VALUES TO CONTINUE THE */ -/* SECOND STAGE */ - quadsd_(&global_1.nn, &global_1.u, &global_1.v, global_1.p, global_1.qp, &global_1.a, &global_1.b); - calcsc_(&type, v3p_netlib_rpoly_global_arg); -L70: - ovv = vv; - oss = ss; - otv = tv; - ots = ts; - } -} /* fxshfr_ */ - -/* Subroutine */ -static void quadit_(doublereal *uu, doublereal *vv, integer *nz, - v3p_netlib_rpoly_global_t* v3p_netlib_rpoly_global_arg) -{ - /* Local variables */ - integer type, i, j; - doublereal t; - logical tried; - real ee; - doublereal ui, vi; - real mp, zm; - real relstp=0, omp=0; - -/* VARIABLE-SHIFT K-POLYNOMIAL ITERATION FOR A */ -/* QUADRATIC FACTOR CONVERGES ONLY IF THE ZEROS ARE */ -/* EQUIMODULAR OR NEARLY SO. */ -/* UU,VV - COEFFICIENTS OF STARTING QUADRATIC */ -/* NZ - NUMBER OF ZERO FOUND */ - *nz = 0; - tried = FALSE_; - global_1.u = *uu; - global_1.v = *vv; - j = 0; -/* MAIN LOOP */ -L10: - quad_(&c_b41, &global_1.u, &global_1.v, &global_1.szr, &global_1.szi, &global_1.lzr, &global_1.lzi); -/* RETURN IF ROOTS OF THE QUADRATIC ARE REAL AND NOT */ -/* CLOSE TO MULTIPLE OR NEARLY EQUAL AND OF OPPOSITE */ -/* SIGN */ - if (abs(abs(global_1.szr) - abs(global_1.lzr)) > abs(global_1.lzr) * .01) { - return; - } -/* EVALUATE POLYNOMIAL BY QUADRATIC SYNTHETIC DIVISION */ - quadsd_(&global_1.nn, &global_1.u, &global_1.v, global_1.p, global_1.qp, &global_1.a, &global_1.b); - mp = (real)abs(global_1.a - global_1.szr * global_1.b) - + (real)abs(global_1.szi * global_1.b); -/* COMPUTE A RIGOROUS BOUND ON THE ROUNDING ERROR IN */ -/* EVALUTING P */ - zm = (real)sqrt(abs(global_1.v)); - ee = (real)abs(global_1.qp[0]) * 2.0f; - t = -global_1.szr * global_1.b; - for (i = 2; i <= global_1.n; ++i) { - ee = ee * zm + (real)abs(global_1.qp[i - 1]); - } - ee = ee * zm + (real)abs(global_1.a + t); - ee = (real)((global_1.mre * 5.0 + global_1.are * 4.0) * ee - - (global_1.mre * 5.0 + global_1.are * 2.0) * (abs(global_1.a + t) + abs(global_1.b) * zm) - + global_1.are * 2.0 * abs(t)); -/* ITERATION HAS CONVERGED SUFFICIENTLY IF THE */ -/* POLYNOMIAL VALUE IS LESS THAN 20 TIMES THIS BOUND */ - if (mp <= ee * 20.0f) { - *nz = 2; - return; - } -/* STOP ITERATION AFTER 20 STEPS */ - if (++j > 20) { - return; - } - if (j < 2) { - goto L50; - } - if (relstp > 0.01f || mp < omp || tried) { - goto L50; - } -/* A CLUSTER APPEARS TO BE STALLING THE CONVERGENCE. */ -/* FIVE FIXED SHIFT STEPS ARE TAKEN WITH A U,V CLOSE */ -/* TO THE CLUSTER */ - if (relstp < global_1.eta) { - relstp = global_1.eta; - } - relstp = (float)sqrt(relstp); - global_1.u -= global_1.u * relstp; - global_1.v += global_1.v * relstp; - quadsd_(&global_1.nn, &global_1.u, &global_1.v, global_1.p, global_1.qp, &global_1.a, &global_1.b); - for (i = 1; i <= 5; ++i) { - calcsc_(&type, v3p_netlib_rpoly_global_arg); - nextk_(&type, v3p_netlib_rpoly_global_arg); - } - tried = TRUE_; - j = 0; -L50: - omp = mp; -/* CALCULATE NEXT K POLYNOMIAL AND NEW U AND V */ - calcsc_(&type, v3p_netlib_rpoly_global_arg); - nextk_(&type, v3p_netlib_rpoly_global_arg); - calcsc_(&type, v3p_netlib_rpoly_global_arg); - newest_(&type, &ui, &vi, v3p_netlib_rpoly_global_arg); -/* IF VI IS ZERO THE ITERATION IS NOT CONVERGING */ - if (vi == 0.) { - return; - } - relstp = (real)abs((vi - global_1.v) / vi); - global_1.u = ui; - global_1.v = vi; - goto L10; -} /* quadit_ */ - -/* Subroutine */ -static void realit_(doublereal *sss, integer *nz, integer *iflag, - v3p_netlib_rpoly_global_t* v3p_netlib_rpoly_global_arg) -{ - /* Local variables */ - integer i, j; - doublereal s, t=0; - real ee, mp, ms; - doublereal kv, pv; - real omp=0; - -/* VARIABLE-SHIFT H POLYNOMIAL ITERATION FOR A REAL */ -/* ZERO. */ -/* SSS - STARTING ITERATE */ -/* NZ - NUMBER OF ZERO FOUND */ -/* IFLAG - FLAG TO INDICATE A PAIR OF ZEROS NEAR REAL */ -/* AXIS. */ - *nz = 0; - s = *sss; - *iflag = 0; - j = 0; -/* MAIN LOOP */ -L10: - pv = global_1.p[0]; -/* EVALUATE P AT S */ - global_1.qp[0] = pv; - for (i = 2; i <= global_1.nn; ++i) { - pv = pv * s + global_1.p[i - 1]; - global_1.qp[i - 1] = pv; - } - mp = (real)abs(pv); -/* COMPUTE A RIGOROUS BOUND ON THE ERROR IN EVALUATING */ -/* P */ - ms = (real)abs(s); - ee = (real)(global_1.mre / (global_1.are + global_1.mre) * abs(global_1.qp[0])); - for (i = 2; i <= global_1.nn; ++i) { - ee = ee * ms + (real)abs(global_1.qp[i - 1]); - } -/* ITERATION HAS CONVERGED SUFFICIENTLY IF THE */ -/* POLYNOMIAL VALUE IS LESS THAN 20 TIMES THIS BOUND */ - if (mp <= ((global_1.are + global_1.mre) * ee - global_1.mre * mp) * 20.0f) { - *nz = 1; - global_1.szr = s; - global_1.szi = 0.; - return; - } -/* STOP ITERATION AFTER 10 STEPS */ - if (++j > 10) { - return; - } - if (j < 2) { - goto L50; - } - if (abs(t) > abs(s - t) * 0.001 || mp <= omp) { - goto L50; - } -/* A CLUSTER OF ZEROS NEAR THE REAL AXIS HAS BEEN */ -/* ENCOUNTERED RETURN WITH IFLAG SET TO INITIATE A */ -/* QUADRATIC ITERATION */ - *iflag = 1; - *sss = s; - return; -/* RETURN IF THE POLYNOMIAL VALUE HAS INCREASED */ -/* SIGNIFICANTLY */ -L50: - omp = mp; -/* COMPUTE T, THE NEXT POLYNOMIAL, AND THE NEW ITERATE */ - kv = global_1.k[0]; - global_1.qk[0] = kv; - for (i = 2; i <= global_1.n; ++i) { - kv = kv * s + global_1.k[i - 1]; - global_1.qk[i - 1] = kv; - } - if (abs(kv) <= abs(global_1.k[global_1.n - 1]) * 10.0 * global_1.eta) { - goto L80; - } -/* USE THE SCALED FORM OF THE RECURRENCE IF THE VALUE */ -/* OF K AT S IS NONZERO */ - t = -pv / kv; - global_1.k[0] = global_1.qp[0]; - for (i = 2; i <= global_1.n; ++i) { - global_1.k[i - 1] = t * global_1.qk[i - 2] + global_1.qp[i - 1]; - } - goto L100; -/* USE UNSCALED FORM */ -L80: - global_1.k[0] = 0.; - for (i = 2; i <= global_1.n; ++i) { - global_1.k[i - 1] = global_1.qk[i - 2]; - } -L100: - kv = global_1.k[0]; - for (i = 2; i <= global_1.n; ++i) { - kv = kv * s + global_1.k[i - 1]; - } - t = 0.; - if (abs(kv) > abs(global_1.k[global_1.n - 1]) * 10.0 * global_1.eta) { - t = -pv / kv; - } - s += t; - goto L10; -} /* realit_ */ - -/* Subroutine */ -static void calcsc_(integer *type, - v3p_netlib_rpoly_global_t* v3p_netlib_rpoly_global_arg) -{ -/* THIS ROUTINE CALCULATES SCALAR QUANTITIES USED TO */ -/* COMPUTE THE NEXT K POLYNOMIAL AND NEW ESTIMATES OF */ -/* THE QUADRATIC COEFFICIENTS. */ -/* TYPE - INTEGER VARIABLE SET HERE INDICATING HOW THE */ -/* CALCULATIONS ARE NORMALIZED TO AVOID OVERFLOW */ -/* SYNTHETIC DIVISION OF K BY THE QUADRATIC 1,U,V */ - quadsd_(&global_1.n, &global_1.u, &global_1.v, global_1.k, global_1.qk, &global_1.c, &global_1.d); - if (abs(global_1.c) > abs(global_1.k[global_1.n - 1]) * 100.0 * global_1.eta) { - goto L10; - } - if (abs(global_1.d) > abs(global_1.k[global_1.n - 2]) * 100.0 * global_1.eta) { - goto L10; - } - *type = 3; -/* TYPE=3 INDICATES THE QUADRATIC IS ALMOST A FACTOR */ -/* OF K */ - return; -L10: - if (abs(global_1.d) < abs(global_1.c)) { - goto L20; - } - *type = 2; -/* TYPE=2 INDICATES THAT ALL FORMULAS ARE DIVIDED BY D */ - global_1.e = global_1.a / global_1.d; - global_1.f = global_1.c / global_1.d; - global_1.g = global_1.u * global_1.b; - global_1.h = global_1.v * global_1.b; - global_1.a3 = (global_1.a + global_1.g) * global_1.e + global_1.h * (global_1.b / global_1.d); - global_1.a1 = global_1.b * global_1.f - global_1.a; - global_1.a7 = (global_1.f + global_1.u) * global_1.a + global_1.h; - return; -L20: - *type = 1; -/* TYPE=1 INDICATES THAT ALL FORMULAS ARE DIVIDED BY C */ - global_1.e = global_1.a / global_1.c; - global_1.f = global_1.d / global_1.c; - global_1.g = global_1.u * global_1.e; - global_1.h = global_1.v * global_1.b; - global_1.a3 = global_1.a * global_1.e + (global_1.h / global_1.c + global_1.g) * global_1.b; - global_1.a1 = global_1.b - global_1.a * (global_1.d / global_1.c); - global_1.a7 = global_1.a + global_1.g * global_1.d + global_1.h * global_1.f; - return; -} /* calcsc_ */ - -/* Subroutine */ -static void nextk_(integer *type, - v3p_netlib_rpoly_global_t* v3p_netlib_rpoly_global_arg) -{ - /* Local variables */ - doublereal temp; - integer i; - -/* COMPUTES THE NEXT K POLYNOMIALS USING SCALARS */ -/* COMPUTED IN CALCSC */ - if (*type == 3) { - goto L40; - } - temp = global_1.a; - if (*type == 1) { - temp = global_1.b; - } - if (abs(global_1.a1) > abs(temp) * global_1.eta * 10.0) { - goto L20; - } -/* IF A1 IS NEARLY ZERO THEN USE A SPECIAL FORM OF THE */ -/* RECURRENCE */ - global_1.k[0] = 0.; - global_1.k[1] = -global_1.a7 * global_1.qp[0]; - for (i = 3; i <= global_1.n; ++i) { - global_1.k[i - 1] = global_1.a3 * global_1.qk[i - 3] - global_1.a7 * global_1.qp[i - 2]; - } - return; -/* USE SCALED FORM OF THE RECURRENCE */ -L20: - global_1.a7 /= global_1.a1; - global_1.a3 /= global_1.a1; - global_1.k[0] = global_1.qp[0]; - global_1.k[1] = global_1.qp[1] - global_1.a7 * global_1.qp[0]; - for (i = 3; i <= global_1.n; ++i) { - global_1.k[i - 1] = global_1.a3 * global_1.qk[i - 3] - global_1.a7 * global_1.qp[i - 2] + global_1.qp[i - 1]; - } - return; -/* USE UNSCALED FORM OF THE RECURRENCE IF TYPE IS 3 */ -L40: - global_1.k[0] = 0.; - global_1.k[1] = 0.; - for (i = 3; i <= global_1.n; ++i) { - global_1.k[i - 1] = global_1.qk[i - 3]; - } -} /* nextk_ */ - -/* Subroutine */ -static void newest_(integer *type, doublereal *uu, doublereal *vv, - v3p_netlib_rpoly_global_t* v3p_netlib_rpoly_global_arg) -{ - doublereal temp, a4, a5, b1, b2, c1, c2, c3, c4; - -/* COMPUTE NEW ESTIMATES OF THE QUADRATIC COEFFICIENTS */ -/* USING THE SCALARS COMPUTED IN CALCSC. */ -/* USE FORMULAS APPROPRIATE TO SETTING OF TYPE. */ - if (*type == 3) { - goto L30; - } - if (*type == 2) { - goto L10; - } - a4 = global_1.a + global_1.u * global_1.b + global_1.h * global_1.f; - a5 = global_1.c + (global_1.u + global_1.v * global_1.f) * global_1.d; - goto L20; -L10: - a4 = (global_1.a + global_1.g) * global_1.f + global_1.h; - a5 = (global_1.f + global_1.u) * global_1.c + global_1.v * global_1.d; -/* EVALUATE NEW QUADRATIC COEFFICIENTS. */ -L20: - b1 = -global_1.k[global_1.n - 1] / global_1.p[global_1.nn - 1]; - b2 = -(global_1.k[global_1.n - 2] + b1 * global_1.p[global_1.n - 1]) / global_1.p[global_1.nn - 1]; - c1 = global_1.v * b2 * global_1.a1; - c2 = b1 * global_1.a7; - c3 = b1 * b1 * global_1.a3; - c4 = c1 - c2 - c3; - temp = a5 + b1 * a4 - c4; - if (temp == 0.) { - goto L30; - } - *uu = global_1.u - (global_1.u * (c3 + c2) + global_1.v * (b1 * global_1.a1 + b2 * global_1.a7)) / temp; - *vv = global_1.v * (c4 / temp + 1.0); - return; -/* IF TYPE=3 THE QUADRATIC IS ZEROED */ -L30: - *uu = 0.; - *vv = 0.; - return; -} /* newest_ */ - -/* Subroutine */ -static void quadsd_( - integer *nn, doublereal *u, doublereal *v, - doublereal *p, doublereal *q, doublereal *a, doublereal *b) -{ - /* Local variables */ - doublereal c; - integer i; - -/* DIVIDES P BY THE QUADRATIC 1,U,V PLACING THE */ -/* QUOTIENT IN Q AND THE REMAINDER IN A,B */ - - *b = p[0]; - q[0] = *b; - *a = p[1] - *u * *b; - q[1] = *a; - for (i = 2; i < *nn; ++i) { - c = p[i] - *u * *a - *v * *b; - q[i] = c; - *b = *a; - *a = c; - } - return; -} /* quadsd_ */ - -/* Subroutine */ -static void quad_( - doublereal *a, doublereal *b1, doublereal *c, - doublereal *sr, doublereal *si, doublereal *lr, doublereal *li - ) -{ - /* Local variables */ - doublereal b, d, e; - -/* CALCULATE THE ZEROS OF THE QUADRATIC A*Z**2+B1*Z+C. */ -/* THE QUADRATIC FORMULA, MODIFIED TO AVOID */ -/* OVERFLOW, IS USED TO FIND THE LARGER ZERO IF THE */ -/* ZEROS ARE REAL AND BOTH ZEROS ARE COMPLEX. */ -/* THE SMALLER REAL ZERO IS FOUND DIRECTLY FROM THE */ -/* PRODUCT OF THE ZEROS C/A. */ - if (*a != 0.) { - goto L20; - } - *sr = 0.; - if (*b1 != 0.) { - *sr = -(*c) / *b1; - } - *lr = 0.; -L10: - *si = 0.; - *li = 0.; - return; -L20: - if (*c == 0.) { - *sr = 0.; - *lr = -(*b1) / *a; - goto L10; - } -/* COMPUTE DISCRIMINANT AVOIDING OVERFLOW */ - b = *b1 / 2.; - if (abs(b) >= abs(*c)) { - e = 1. - *a / b * (*c / b); - d = sqrt(abs(e)) * abs(b); - } - else { - e = *a; - if (*c < 0.) { - e = -(*a); - } - e = b * (b / abs(*c)) - e; - d = sqrt(abs(e)) * sqrt(abs(*c)); - } - if (e < 0.) { - goto L60; - } -/* REAL ZEROS */ - if (b >= 0.) { - d = -d; - } - *lr = (-b + d) / *a; - *sr = 0.; - if (*lr != 0.) { - *sr = *c / *lr / *a; - } - goto L10; -/* COMPLEX CONJUGATE ZEROS */ -L60: - *sr = -b / *a; - *lr = *sr; - *si = abs(d / *a); - *li = -(*si); -} /* quad_ */ diff --git a/Utilities/ITK/Utilities/vxl/v3p/netlib/toms/rpoly.f b/Utilities/ITK/Utilities/vxl/v3p/netlib/toms/rpoly.f deleted file mode 100644 index 213bf18e4043584a5c74470811c9cb3de12082fc..0000000000000000000000000000000000000000 --- a/Utilities/ITK/Utilities/vxl/v3p/netlib/toms/rpoly.f +++ /dev/null @@ -1,721 +0,0 @@ - SUBROUTINE RPOLY(OP, DEGREE, ZEROR, ZEROI, RPO 10 - * FAIL) -C FINDS THE ZEROS OF A REAL POLYNOMIAL -C OP - DOUBLE PRECISION VECTOR OF COEFFICIENTS IN -C ORDER OF DECREASING POWERS. -C DEGREE - INTEGER DEGREE OF POLYNOMIAL. -C ZEROR, ZEROI - OUTPUT DOUBLE PRECISION VECTORS OF -C REAL AND IMAGINARY PARTS OF THE -C ZEROS. -C FAIL - OUTPUT LOGICAL PARAMETER, TRUE ONLY IF -C LEADING COEFFICIENT IS ZERO OR IF RPOLY -C HAS FOUND FEWER THAN DEGREE ZEROS. -C IN THE LATTER CASE DEGREE IS RESET TO -C THE NUMBER OF ZEROS FOUND. -C TO CHANGE THE SIZE OF POLYNOMIALS WHICH CAN BE -C SOLVED, RESET THE DIMENSIONS OF THE ARRAYS IN THE -C COMMON AREA AND IN THE FOLLOWING DECLARATIONS. -C THE SUBROUTINE USES SINGLE PRECISION CALCULATIONS -C FOR SCALING, BOUNDS AND ERROR CALCULATIONS. ALL -C CALCULATIONS FOR THE ITERATIONS ARE DONE IN DOUBLE -C PRECISION. - COMMON /GLOBAL/ P, QP, K, QK, SVK, SR, SI, U, - * V, A, B, C, D, A1, A2, A3, A6, A7, E, F, G, - * H, SZR, SZI, LZR, LZI, ETA, ARE, MRE, N, NN - DOUBLE PRECISION P(101), QP(101), K(101), - * QK(101), SVK(101), SR, SI, U, V, A, B, C, D, - * A1, A2, A3, A6, A7, E, F, G, H, SZR, SZI, - * LZR, LZI - REAL ETA, ARE, MRE - INTEGER N, NN - DOUBLE PRECISION OP(101), TEMP(101), - * ZEROR(100), ZEROI(100), T, AA, BB, CC, DABS, - * FACTOR - REAL PT(101), LO, MAX, MIN, XX, YY, COSR, - * SINR, XXX, X, SC, BND, XM, FF, DF, DX, INFIN, - * SMALNO, BASE - INTEGER DEGREE, CNT, NZ, I, J, JJ, NM1 - LOGICAL FAIL, ZEROK -C THE FOLLOWING STATEMENTS SET MACHINE CONSTANTS USED -C IN VARIOUS PARTS OF THE PROGRAM. THE MEANING OF THE -C FOUR CONSTANTS ARE... -C ETA THE MAXIMUM RELATIVE REPRESENTATION ERROR -C WHICH CAN BE DESCRIBED AS THE SMALLEST -C POSITIVE FLOATING POINT NUMBER SUCH THAT -C 1.D0+ETA IS GREATER THAN 1. -C INFINY THE LARGEST FLOATING-POINT NUMBER. -C SMALNO THE SMALLEST POSITIVE FLOATING-POINT NUMBER -C IF THE EXPONENT RANGE DIFFERS IN SINGLE AND -C DOUBLE PRECISION THEN SMALNO AND INFIN -C SHOULD INDICATE THE SMALLER RANGE. -C BASE THE BASE OF THE FLOATING-POINT NUMBER -C SYSTEM USED. -C THE VALUES BELOW CORRESPOND TO THE BURROUGHS B6700 - BASE = 8. - ETA = .5*BASE**(1-26) - INFIN = 4.3E68 - SMALNO = 1.0E-45 -C ARE AND MRE REFER TO THE UNIT ERROR IN + AND * -C RESPECTIVELY. THEY ARE ASSUMED TO BE THE SAME AS -C ETA. - ARE = ETA - MRE = ETA - LO = SMALNO/ETA -C INITIALIZATION OF CONSTANTS FOR SHIFT ROTATION - XX = .70710678 - YY = -XX - COSR = -.069756474 - SINR = .99756405 - FAIL = .FALSE. - N = DEGREE - NN = N + 1 -C ALGORITHM FAILS IF THE LEADING COEFFICIENT IS ZERO. - IF (OP(1).NE.0.D0) GO TO 10 - FAIL = .TRUE. - DEGREE = 0 - RETURN -C REMOVE THE ZEROS AT THE ORIGIN IF ANY - 10 IF (OP(NN).NE.0.0D0) GO TO 20 - J = DEGREE - N + 1 - ZEROR(J) = 0.D0 - ZEROI(J) = 0.D0 - NN = NN - 1 - N = N - 1 - GO TO 10 -C MAKE A COPY OF THE COEFFICIENTS - 20 DO 30 I=1,NN - P(I) = OP(I) - 30 CONTINUE -C START THE ALGORITHM FOR ONE ZERO - 40 IF (N.GT.2) GO TO 60 - IF (N.LT.1) RETURN -C CALCULATE THE FINAL ZERO OR PAIR OF ZEROS - IF (N.EQ.2) GO TO 50 - ZEROR(DEGREE) = -P(2)/P(1) - ZEROI(DEGREE) = 0.0D0 - RETURN - 50 CALL QUAD(P(1), P(2), P(3), ZEROR(DEGREE-1), - * ZEROI(DEGREE-1), ZEROR(DEGREE), ZEROI(DEGREE)) - RETURN -C FIND LARGEST AND SMALLEST MODULI OF COEFFICIENTS. - 60 MAX = 0. - MIN = INFIN - DO 70 I=1,NN - X = ABS(SNGL(P(I))) - IF (X.GT.MAX) MAX = X - IF (X.NE.0. .AND. X.LT.MIN) MIN = X - 70 CONTINUE -C SCALE IF THERE ARE LARGE OR VERY SMALL COEFFICIENTS -C COMPUTES A SCALE FACTOR TO MULTIPLY THE -C COEFFICIENTS OF THE POLYNOMIAL. THE SCALING IS DONE -C TO AVOID OVERFLOW AND TO AVOID UNDETECTED UNDERFLOW -C INTERFERING WITH THE CONVERGENCE CRITERION. -C THE FACTOR IS A POWER OF THE BASE - SC = LO/MIN - IF (SC.GT.1.0) GO TO 80 - IF (MAX.LT.10.) GO TO 110 - IF (SC.EQ.0.) SC = SMALNO - GO TO 90 - 80 IF (INFIN/SC.LT.MAX) GO TO 110 - 90 L = ALOG(SC)/ALOG(BASE) + .5 - FACTOR = (BASE*1.0D0)**L - IF (FACTOR.EQ.1.D0) GO TO 110 - DO 100 I=1,NN - P(I) = FACTOR*P(I) - 100 CONTINUE -C COMPUTE LOWER BOUND ON MODULI OF ZEROS. - 110 DO 120 I=1,NN - PT(I) = ABS(SNGL(P(I))) - 120 CONTINUE - PT(NN) = -PT(NN) -C COMPUTE UPPER ESTIMATE OF BOUND - X = EXP((ALOG(-PT(NN))-ALOG(PT(1)))/FLOAT(N)) - IF (PT(N).EQ.0.) GO TO 130 -C IF NEWTON STEP AT THE ORIGIN IS BETTER, USE IT. - XM = -PT(NN)/PT(N) - IF (XM.LT.X) X = XM -C CHOP THE INTERVAL (0,X) UNTIL FF .LE. 0 - 130 XM = X*.1 - FF = PT(1) - DO 140 I=2,NN - FF = FF*XM + PT(I) - 140 CONTINUE - IF (FF.LE.0.) GO TO 150 - X = XM - GO TO 130 - 150 DX = X -C DO NEWTON ITERATION UNTIL X CONVERGES TO TWO -C DECIMAL PLACES - 160 IF (ABS(DX/X).LE..005) GO TO 180 - FF = PT(1) - DF = FF - DO 170 I=2,N - FF = FF*X + PT(I) - DF = DF*X + FF - 170 CONTINUE - FF = FF*X + PT(NN) - DX = FF/DF - X = X - DX - GO TO 160 - 180 BND = X -C COMPUTE THE DERIVATIVE AS THE INITIAL K POLYNOMIAL -C AND DO 5 STEPS WITH NO SHIFT - NM1 = N - 1 - DO 190 I=2,N - K(I) = FLOAT(NN-I)*P(I)/FLOAT(N) - 190 CONTINUE - K(1) = P(1) - AA = P(NN) - BB = P(N) - ZEROK = K(N).EQ.0.D0 - DO 230 JJ=1,5 - CC = K(N) - IF (ZEROK) GO TO 210 -C USE SCALED FORM OF RECURRENCE IF VALUE OF K AT 0 IS -C NONZERO - T = -AA/CC - DO 200 I=1,NM1 - J = NN - I - K(J) = T*K(J-1) + P(J) - 200 CONTINUE - K(1) = P(1) - ZEROK = DABS(K(N)).LE.DABS(BB)*ETA*10. - GO TO 230 -C USE UNSCALED FORM OF RECURRENCE - 210 DO 220 I=1,NM1 - J = NN - I - K(J) = K(J-1) - 220 CONTINUE - K(1) = 0.D0 - ZEROK = K(N).EQ.0.D0 - 230 CONTINUE -C SAVE K FOR RESTARTS WITH NEW SHIFTS - DO 240 I=1,N - TEMP(I) = K(I) - 240 CONTINUE -C LOOP TO SELECT THE QUADRATIC CORRESPONDING TO EACH -C NEW SHIFT - DO 280 CNT=1,20 -C QUADRATIC CORRESPONDS TO A DOUBLE SHIFT TO A -C NON-REAL POINT AND ITS COMPLEX CONJUGATE. THE POINT -C HAS MODULUS BND AND AMPLITUDE ROTATED BY 94 DEGREES -C FROM THE PREVIOUS SHIFT - XXX = COSR*XX - SINR*YY - YY = SINR*XX + COSR*YY - XX = XXX - SR = BND*XX - SI = BND*YY - U = -2.0D0*SR - V = BND -C SECOND STAGE CALCULATION, FIXED QUADRATIC - CALL FXSHFR(20*CNT, NZ) - IF (NZ.EQ.0) GO TO 260 -C THE SECOND STAGE JUMPS DIRECTLY TO ONE OF THE THIRD -C STAGE ITERATIONS AND RETURNS HERE IF SUCCESSFUL. -C DEFLATE THE POLYNOMIAL, STORE THE ZERO OR ZEROS AND -C RETURN TO THE MAIN ALGORITHM. - J = DEGREE - N + 1 - ZEROR(J) = SZR - ZEROI(J) = SZI - NN = NN - NZ - N = NN - 1 - DO 250 I=1,NN - P(I) = QP(I) - 250 CONTINUE - IF (NZ.EQ.1) GO TO 40 - ZEROR(J+1) = LZR - ZEROI(J+1) = LZI - GO TO 40 -C IF THE ITERATION IS UNSUCCESSFUL ANOTHER QUADRATIC -C IS CHOSEN AFTER RESTORING K - 260 DO 270 I=1,N - K(I) = TEMP(I) - 270 CONTINUE - 280 CONTINUE -C RETURN WITH FAILURE IF NO CONVERGENCE WITH 20 -C SHIFTS - FAIL = .TRUE. - DEGREE = DEGREE - N - RETURN - END - SUBROUTINE FXSHFR(L2, NZ) FXS 10 -C COMPUTES UP TO L2 FIXED SHIFT K-POLYNOMIALS, -C TESTING FOR CONVERGENCE IN THE LINEAR OR QUADRATIC -C CASE. INITIATES ONE OF THE VARIABLE SHIFT -C ITERATIONS AND RETURNS WITH THE NUMBER OF ZEROS -C FOUND. -C L2 - LIMIT OF FIXED SHIFT STEPS -C NZ - NUMBER OF ZEROS FOUND - COMMON /GLOBAL/ P, QP, K, QK, SVK, SR, SI, U, - * V, A, B, C, D, A1, A2, A3, A6, A7, E, F, G, - * H, SZR, SZI, LZR, LZI, ETA, ARE, MRE, N, NN - DOUBLE PRECISION P(101), QP(101), K(101), - * QK(101), SVK(101), SR, SI, U, V, A, B, C, D, - * A1, A2, A3, A6, A7, E, F, G, H, SZR, SZI, - * LZR, LZI - REAL ETA, ARE, MRE - INTEGER N, NN - DOUBLE PRECISION SVU, SVV, UI, VI, S - REAL BETAS, BETAV, OSS, OVV, SS, VV, TS, TV, - * OTS, OTV, TVV, TSS - INTEGER L2, NZ, TYPE, I, J, IFLAG - LOGICAL VPASS, SPASS, VTRY, STRY - NZ = 0 - BETAV = .25 - BETAS = .25 - OSS = SR - OVV = V -C EVALUATE POLYNOMIAL BY SYNTHETIC DIVISION - CALL QUADSD(NN, U, V, P, QP, A, B) - CALL CALCSC(TYPE) - DO 80 J=1,L2 -C CALCULATE NEXT K POLYNOMIAL AND ESTIMATE V - CALL NEXTK(TYPE) - CALL CALCSC(TYPE) - CALL NEWEST(TYPE, UI, VI) - VV = VI -C ESTIMATE S - SS = 0. - IF (K(N).NE.0.D0) SS = -P(NN)/K(N) - TV = 1. - TS = 1. - IF (J.EQ.1 .OR. TYPE.EQ.3) GO TO 70 -C COMPUTE RELATIVE MEASURES OF CONVERGENCE OF S AND V -C SEQUENCES - IF (VV.NE.0.) TV = ABS((VV-OVV)/VV) - IF (SS.NE.0.) TS = ABS((SS-OSS)/SS) -C IF DECREASING, MULTIPLY TWO MOST RECENT -C CONVERGENCE MEASURES - TVV = 1. - IF (TV.LT.OTV) TVV = TV*OTV - TSS = 1. - IF (TS.LT.OTS) TSS = TS*OTS -C COMPARE WITH CONVERGENCE CRITERIA - VPASS = TVV.LT.BETAV - SPASS = TSS.LT.BETAS - IF (.NOT.(SPASS .OR. VPASS)) GO TO 70 -C AT LEAST ONE SEQUENCE HAS PASSED THE CONVERGENCE -C TEST. STORE VARIABLES BEFORE ITERATING - SVU = U - SVV = V - DO 10 I=1,N - SVK(I) = K(I) - 10 CONTINUE - S = SS -C CHOOSE ITERATION ACCORDING TO THE FASTEST -C CONVERGING SEQUENCE - VTRY = .FALSE. - STRY = .FALSE. - IF (SPASS .AND. ((.NOT.VPASS) .OR. - * TSS.LT.TVV)) GO TO 40 - 20 CALL QUADIT(UI, VI, NZ) - IF (NZ.GT.0) RETURN -C QUADRATIC ITERATION HAS FAILED. FLAG THAT IT HAS -C BEEN TRIED AND DECREASE THE CONVERGENCE CRITERION. - VTRY = .TRUE. - BETAV = BETAV*.25 -C TRY LINEAR ITERATION IF IT HAS NOT BEEN TRIED AND -C THE S SEQUENCE IS CONVERGING - IF (STRY .OR. (.NOT.SPASS)) GO TO 50 - DO 30 I=1,N - K(I) = SVK(I) - 30 CONTINUE - 40 CALL REALIT(S, NZ, IFLAG) - IF (NZ.GT.0) RETURN -C LINEAR ITERATION HAS FAILED. FLAG THAT IT HAS BEEN -C TRIED AND DECREASE THE CONVERGENCE CRITERION - STRY = .TRUE. - BETAS = BETAS*.25 - IF (IFLAG.EQ.0) GO TO 50 -C IF LINEAR ITERATION SIGNALS AN ALMOST DOUBLE REAL -C ZERO ATTEMPT QUADRATIC INTERATION - UI = -(S+S) - VI = S*S - GO TO 20 -C RESTORE VARIABLES - 50 U = SVU - V = SVV - DO 60 I=1,N - K(I) = SVK(I) - 60 CONTINUE -C TRY QUADRATIC ITERATION IF IT HAS NOT BEEN TRIED -C AND THE V SEQUENCE IS CONVERGING - IF (VPASS .AND. (.NOT.VTRY)) GO TO 20 -C RECOMPUTE QP AND SCALAR VALUES TO CONTINUE THE -C SECOND STAGE - CALL QUADSD(NN, U, V, P, QP, A, B) - CALL CALCSC(TYPE) - 70 OVV = VV - OSS = SS - OTV = TV - OTS = TS - 80 CONTINUE - RETURN - END - SUBROUTINE QUADIT(UU, VV, NZ) QUA 10 -C VARIABLE-SHIFT K-POLYNOMIAL ITERATION FOR A -C QUADRATIC FACTOR CONVERGES ONLY IF THE ZEROS ARE -C EQUIMODULAR OR NEARLY SO. -C UU,VV - COEFFICIENTS OF STARTING QUADRATIC -C NZ - NUMBER OF ZERO FOUND - COMMON /GLOBAL/ P, QP, K, QK, SVK, SR, SI, U, - * V, A, B, C, D, A1, A2, A3, A6, A7, E, F, G, - * H, SZR, SZI, LZR, LZI, ETA, ARE, MRE, N, NN - DOUBLE PRECISION P(101), QP(101), K(101), - * QK(101), SVK(101), SR, SI, U, V, A, B, C, D, - * A1, A2, A3, A6, A7, E, F, G, H, SZR, SZI, - * LZR, LZI - REAL ETA, ARE, MRE - INTEGER N, NN - DOUBLE PRECISION UI, VI, UU, VV, DABS - REAL MS, MP, OMP, EE, RELSTP, T, ZM - INTEGER NZ, TYPE, I, J - LOGICAL TRIED - NZ = 0 - TRIED = .FALSE. - U = UU - V = VV - J = 0 -C MAIN LOOP - 10 CALL QUAD(1.D0, U, V, SZR, SZI, LZR, LZI) -C RETURN IF ROOTS OF THE QUADRATIC ARE REAL AND NOT -C CLOSE TO MULTIPLE OR NEARLY EQUAL AND OF OPPOSITE -C SIGN - IF (DABS(DABS(SZR)-DABS(LZR)).GT..01D0* - * DABS(LZR)) RETURN -C EVALUATE POLYNOMIAL BY QUADRATIC SYNTHETIC DIVISION - CALL QUADSD(NN, U, V, P, QP, A, B) - MP = DABS(A-SZR*B) + DABS(SZI*B) -C COMPUTE A RIGOROUS BOUND ON THE ROUNDING ERROR IN -C EVALUTING P - ZM = SQRT(ABS(SNGL(V))) - EE = 2.*ABS(SNGL(QP(1))) - T = -SZR*B - DO 20 I=2,N - EE = EE*ZM + ABS(SNGL(QP(I))) - 20 CONTINUE - EE = EE*ZM + ABS(SNGL(A)+T) - EE = (5.*MRE+4.*ARE)*EE - (5.*MRE+2.*ARE)* - * (ABS(SNGL(A)+T)+ABS(SNGL(B))*ZM) + - * 2.*ARE*ABS(T) -C ITERATION HAS CONVERGED SUFFICIENTLY IF THE -C POLYNOMIAL VALUE IS LESS THAN 20 TIMES THIS BOUND - IF (MP.GT.20.*EE) GO TO 30 - NZ = 2 - RETURN - 30 J = J + 1 -C STOP ITERATION AFTER 20 STEPS - IF (J.GT.20) RETURN - IF (J.LT.2) GO TO 50 - IF (RELSTP.GT..01 .OR. MP.LT.OMP .OR. TRIED) - * GO TO 50 -C A CLUSTER APPEARS TO BE STALLING THE CONVERGENCE. -C FIVE FIXED SHIFT STEPS ARE TAKEN WITH A U,V CLOSE -C TO THE CLUSTER - IF (RELSTP.LT.ETA) RELSTP = ETA - RELSTP = SQRT(RELSTP) - U = U - U*RELSTP - V = V + V*RELSTP - CALL QUADSD(NN, U, V, P, QP, A, B) - DO 40 I=1,5 - CALL CALCSC(TYPE) - CALL NEXTK(TYPE) - 40 CONTINUE - TRIED = .TRUE. - J = 0 - 50 OMP = MP -C CALCULATE NEXT K POLYNOMIAL AND NEW U AND V - CALL CALCSC(TYPE) - CALL NEXTK(TYPE) - CALL CALCSC(TYPE) - CALL NEWEST(TYPE, UI, VI) -C IF VI IS ZERO THE ITERATION IS NOT CONVERGING - IF (VI.EQ.0.D0) RETURN - RELSTP = DABS((VI-V)/VI) - U = UI - V = VI - GO TO 10 - END - SUBROUTINE REALIT(SSS, NZ, IFLAG) REA 10 -C VARIABLE-SHIFT H POLYNOMIAL ITERATION FOR A REAL -C ZERO. -C SSS - STARTING ITERATE -C NZ - NUMBER OF ZERO FOUND -C IFLAG - FLAG TO INDICATE A PAIR OF ZEROS NEAR REAL -C AXIS. - COMMON /GLOBAL/ P, QP, K, QK, SVK, SR, SI, U, - * V, A, B, C, D, A1, A2, A3, A6, A7, E, F, G, - * H, SZR, SZI, LZR, LZI, ETA, ARE, MRE, N, NN - DOUBLE PRECISION P(101), QP(101), K(101), - * QK(101), SVK(101), SR, SI, U, V, A, B, C, D, - * A1, A2, A3, A6, A7, E, F, G, H, SZR, SZI, - * LZR, LZI - REAL ETA, ARE, MRE - INTEGER N, NN - DOUBLE PRECISION PV, KV, T, S, SSS, DABS - REAL MS, MP, OMP, EE - INTEGER NZ, IFLAG, I, J, NM1 - NM1 = N - 1 - NZ = 0 - S = SSS - IFLAG = 0 - J = 0 -C MAIN LOOP - 10 PV = P(1) -C EVALUATE P AT S - QP(1) = PV - DO 20 I=2,NN - PV = PV*S + P(I) - QP(I) = PV - 20 CONTINUE - MP = DABS(PV) -C COMPUTE A RIGOROUS BOUND ON THE ERROR IN EVALUATING -C P - MS = DABS(S) - EE = (MRE/(ARE+MRE))*ABS(SNGL(QP(1))) - DO 30 I=2,NN - EE = EE*MS + ABS(SNGL(QP(I))) - 30 CONTINUE -C ITERATION HAS CONVERGED SUFFICIENTLY IF THE -C POLYNOMIAL VALUE IS LESS THAN 20 TIMES THIS BOUND - IF (MP.GT.20.*((ARE+MRE)*EE-MRE*MP)) GO TO 40 - NZ = 1 - SZR = S - SZI = 0.D0 - RETURN - 40 J = J + 1 -C STOP ITERATION AFTER 10 STEPS - IF (J.GT.10) RETURN - IF (J.LT.2) GO TO 50 - IF (DABS(T).GT..001*DABS(S-T) .OR. MP.LE.OMP) - * GO TO 50 -C A CLUSTER OF ZEROS NEAR THE REAL AXIS HAS BEEN -C ENCOUNTERED RETURN WITH IFLAG SET TO INITIATE A -C QUADRATIC ITERATION - IFLAG = 1 - SSS = S - RETURN -C RETURN IF THE POLYNOMIAL VALUE HAS INCREASED -C SIGNIFICANTLY - 50 OMP = MP -C COMPUTE T, THE NEXT POLYNOMIAL, AND THE NEW ITERATE - KV = K(1) - QK(1) = KV - DO 60 I=2,N - KV = KV*S + K(I) - QK(I) = KV - 60 CONTINUE - IF (DABS(KV).LE.DABS(K(N))*10.*ETA) GO TO 80 -C USE THE SCALED FORM OF THE RECURRENCE IF THE VALUE -C OF K AT S IS NONZERO - T = -PV/KV - K(1) = QP(1) - DO 70 I=2,N - K(I) = T*QK(I-1) + QP(I) - 70 CONTINUE - GO TO 100 -C USE UNSCALED FORM - 80 K(1) = 0.0D0 - DO 90 I=2,N - K(I) = QK(I-1) - 90 CONTINUE - 100 KV = K(1) - DO 110 I=2,N - KV = KV*S + K(I) - 110 CONTINUE - T = 0.D0 - IF (DABS(KV).GT.DABS(K(N))*10.*ETA) T = -PV/KV - S = S + T - GO TO 10 - END - SUBROUTINE CALCSC(TYPE) CAL 10 -C THIS ROUTINE CALCULATES SCALAR QUANTITIES USED TO -C COMPUTE THE NEXT K POLYNOMIAL AND NEW ESTIMATES OF -C THE QUADRATIC COEFFICIENTS. -C TYPE - INTEGER VARIABLE SET HERE INDICATING HOW THE -C CALCULATIONS ARE NORMALIZED TO AVOID OVERFLOW - COMMON /GLOBAL/ P, QP, K, QK, SVK, SR, SI, U, - * V, A, B, C, D, A1, A2, A3, A6, A7, E, F, G, - * H, SZR, SZI, LZR, LZI, ETA, ARE, MRE, N, NN - DOUBLE PRECISION P(101), QP(101), K(101), - * QK(101), SVK(101), SR, SI, U, V, A, B, C, D, - * A1, A2, A3, A6, A7, E, F, G, H, SZR, SZI, - * LZR, LZI - REAL ETA, ARE, MRE - INTEGER N, NN - DOUBLE PRECISION DABS - INTEGER TYPE -C SYNTHETIC DIVISION OF K BY THE QUADRATIC 1,U,V - CALL QUADSD(N, U, V, K, QK, C, D) - IF (DABS(C).GT.DABS(K(N))*100.*ETA) GO TO 10 - IF (DABS(D).GT.DABS(K(N-1))*100.*ETA) GO TO 10 - TYPE = 3 -C TYPE=3 INDICATES THE QUADRATIC IS ALMOST A FACTOR -C OF K - RETURN - 10 IF (DABS(D).LT.DABS(C)) GO TO 20 - TYPE = 2 -C TYPE=2 INDICATES THAT ALL FORMULAS ARE DIVIDED BY D - E = A/D - F = C/D - G = U*B - H = V*B - A3 = (A+G)*E + H*(B/D) - A1 = B*F - A - A7 = (F+U)*A + H - RETURN - 20 TYPE = 1 -C TYPE=1 INDICATES THAT ALL FORMULAS ARE DIVIDED BY C - E = A/C - F = D/C - G = U*E - H = V*B - A3 = A*E + (H/C+G)*B - A1 = B - A*(D/C) - A7 = A + G*D + H*F - RETURN - END - SUBROUTINE NEXTK(TYPE) NEX 10 -C COMPUTES THE NEXT K POLYNOMIALS USING SCALARS -C COMPUTED IN CALCSC - COMMON /GLOBAL/ P, QP, K, QK, SVK, SR, SI, U, - * V, A, B, C, D, A1, A2, A3, A6, A7, E, F, G, - * H, SZR, SZI, LZR, LZI, ETA, ARE, MRE, N, NN - DOUBLE PRECISION P(101), QP(101), K(101), - * QK(101), SVK(101), SR, SI, U, V, A, B, C, D, - * A1, A2, A3, A6, A7, E, F, G, H, SZR, SZI, - * LZR, LZI - REAL ETA, ARE, MRE - INTEGER N, NN - DOUBLE PRECISION TEMP, DABS - INTEGER TYPE - IF (TYPE.EQ.3) GO TO 40 - TEMP = A - IF (TYPE.EQ.1) TEMP = B - IF (DABS(A1).GT.DABS(TEMP)*ETA*10.) GO TO 20 -C IF A1 IS NEARLY ZERO THEN USE A SPECIAL FORM OF THE -C RECURRENCE - K(1) = 0.D0 - K(2) = -A7*QP(1) - DO 10 I=3,N - K(I) = A3*QK(I-2) - A7*QP(I-1) - 10 CONTINUE - RETURN -C USE SCALED FORM OF THE RECURRENCE - 20 A7 = A7/A1 - A3 = A3/A1 - K(1) = QP(1) - K(2) = QP(2) - A7*QP(1) - DO 30 I=3,N - K(I) = A3*QK(I-2) - A7*QP(I-1) + QP(I) - 30 CONTINUE - RETURN -C USE UNSCALED FORM OF THE RECURRENCE IF TYPE IS 3 - 40 K(1) = 0.D0 - K(2) = 0.D0 - DO 50 I=3,N - K(I) = QK(I-2) - 50 CONTINUE - RETURN - END - SUBROUTINE NEWEST(TYPE, UU, VV) NEW 10 -C COMPUTE NEW ESTIMATES OF THE QUADRATIC COEFFICIENTS -C USING THE SCALARS COMPUTED IN CALCSC. - COMMON /GLOBAL/ P, QP, K, QK, SVK, SR, SI, U, - * V, A, B, C, D, A1, A2, A3, A6, A7, E, F, G, - * H, SZR, SZI, LZR, LZI, ETA, ARE, MRE, N, NN - DOUBLE PRECISION P(101), QP(101), K(101), - * QK(101), SVK(101), SR, SI, U, V, A, B, C, D, - * A1, A2, A3, A6, A7, E, F, G, H, SZR, SZI, - * LZR, LZI - REAL ETA, ARE, MRE - INTEGER N, NN - DOUBLE PRECISION A4, A5, B1, B2, C1, C2, C3, - * C4, TEMP, UU, VV - INTEGER TYPE -C USE FORMULAS APPROPRIATE TO SETTING OF TYPE. - IF (TYPE.EQ.3) GO TO 30 - IF (TYPE.EQ.2) GO TO 10 - A4 = A + U*B + H*F - A5 = C + (U+V*F)*D - GO TO 20 - 10 A4 = (A+G)*F + H - A5 = (F+U)*C + V*D -C EVALUATE NEW QUADRATIC COEFFICIENTS. - 20 B1 = -K(N)/P(NN) - B2 = -(K(N-1)+B1*P(N))/P(NN) - C1 = V*B2*A1 - C2 = B1*A7 - C3 = B1*B1*A3 - C4 = C1 - C2 - C3 - TEMP = A5 + B1*A4 - C4 - IF (TEMP.EQ.0.D0) GO TO 30 - UU = U - (U*(C3+C2)+V*(B1*A1+B2*A7))/TEMP - VV = V*(1.+C4/TEMP) - RETURN -C IF TYPE=3 THE QUADRATIC IS ZEROED - 30 UU = 0.D0 - VV = 0.D0 - RETURN - END - SUBROUTINE QUADSD(NN, U, V, P, Q, A, B) QUA 10 -C DIVIDES P BY THE QUADRATIC 1,U,V PLACING THE -C QUOTIENT IN Q AND THE REMAINDER IN A,B - DOUBLE PRECISION P(NN), Q(NN), U, V, A, B, C - INTEGER I - B = P(1) - Q(1) = B - A = P(2) - U*B - Q(2) = A - DO 10 I=3,NN - C = P(I) - U*A - V*B - Q(I) = C - B = A - A = C - 10 CONTINUE - RETURN - END - SUBROUTINE QUAD(A, B1, C, SR, SI, LR, LI) QUA 10 -C CALCULATE THE ZEROS OF THE QUADRATIC A*Z**2+B1*Z+C. -C THE QUADRATIC FORMULA, MODIFIED TO AVOID -C OVERFLOW, IS USED TO FIND THE LARGER ZERO IF THE -C ZEROS ARE REAL AND BOTH ZEROS ARE COMPLEX. -C THE SMALLER REAL ZERO IS FOUND DIRECTLY FROM THE -C PRODUCT OF THE ZEROS C/A. - DOUBLE PRECISION A, B1, C, SR, SI, LR, LI, B, - * D, E, DABS, DSQRT - IF (A.NE.0.D0) GO TO 20 - SR = 0.D0 - IF (B1.NE.0.D0) SR = -C/B1 - LR = 0.D0 - 10 SI = 0.D0 - LI = 0.D0 - RETURN - 20 IF (C.NE.0.D0) GO TO 30 - SR = 0.D0 - LR = -B1/A - GO TO 10 -C COMPUTE DISCRIMINANT AVOIDING OVERFLOW - 30 B = B1/2.D0 - IF (DABS(B).LT.DABS(C)) GO TO 40 - E = 1.D0 - (A/B)*(C/B) - D = DSQRT(DABS(E))*DABS(B) - GO TO 50 - 40 E = A - IF (C.LT.0.D0) E = -A - E = B*(B/DABS(C)) - E - D = DSQRT(DABS(E))*DSQRT(DABS(C)) - 50 IF (E.LT.0.D0) GO TO 60 -C REAL ZEROS - IF (B.GE.0.D0) D = -D - LR = (-B+D)/A - SR = 0.D0 - IF (LR.NE.0.D0) SR = (C/LR)/A - GO TO 10 -C COMPLEX CONJUGATE ZEROS - 60 SR = -B/A - LR = SR - SI = DABS(D/A) - LI = -SI - RETURN - END diff --git a/Utilities/ITK/Utilities/vxl/v3p/netlib/toms/rpoly.h b/Utilities/ITK/Utilities/vxl/v3p/netlib/toms/rpoly.h deleted file mode 100644 index e86dfa01c8ab5b6fa016b1c5ac180d2db216f351..0000000000000000000000000000000000000000 --- a/Utilities/ITK/Utilities/vxl/v3p/netlib/toms/rpoly.h +++ /dev/null @@ -1,20 +0,0 @@ -typedef struct v3p_netlib_rpoly_global_s v3p_netlib_rpoly_global_t; - -/*: Finds the zeros of a real polynomial */ -extern void v3p_netlib_rpoly_( - v3p_netlib_doublereal *op, - v3p_netlib_integer *degree, - v3p_netlib_doublereal *zeror, - v3p_netlib_doublereal *zeroi, - v3p_netlib_logical *fail, - v3p_netlib_rpoly_global_t* v3p_netlib_rpoly_global_arg - ); -struct v3p_netlib_rpoly_global_s -{ - v3p_netlib_doublereal p[101], qp[101], k[101], qk[101], svk[101]; - v3p_netlib_doublereal sr, si, u, v, a, b, c, d; - v3p_netlib_doublereal a1, a2, a3, a6, a7, e, f, g; - v3p_netlib_doublereal h, szr, szi, lzr, lzi; - v3p_netlib_real eta, are, mre; - v3p_netlib_integer n, nn; -}; diff --git a/Utilities/ITK/Utilities/vxl/v3p/netlib/v3p_netlib_prototypes.h b/Utilities/ITK/Utilities/vxl/v3p/netlib/v3p_netlib_prototypes.h index 789b8f4dc6bd431ffdfc8b53233a4d369b35b704..66e6a93ef977b1ec99c2f0ac431e7bf4b1880463 100644 --- a/Utilities/ITK/Utilities/vxl/v3p/netlib/v3p_netlib_prototypes.h +++ b/Utilities/ITK/Utilities/vxl/v3p/netlib/v3p_netlib_prototypes.h @@ -223,8 +223,7 @@ #include "minpack/qrsolv.h" #include "opt/lbfgs.h" #include "opt/lbfgsb.h" -#include "linalg/lsqr.h" -#include "toms/rpoly.h" +// #include "linalg/lsqr.h" Removde due to ACM Copyright #include "datapac/camsun.h" #include "mathews/adaquad.h" #include "mathews/simpson.h" diff --git a/Utilities/ITK/Utilities/vxl/vcl/generic/zap.pl b/Utilities/ITK/Utilities/vxl/vcl/generic/zap.pl old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Utilities/vxl/vcl/iso/generate.sh b/Utilities/ITK/Utilities/vxl/vcl/iso/generate.sh old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Utilities/vxl/vcl/tests/test_memory.cxx b/Utilities/ITK/Utilities/vxl/vcl/tests/test_memory.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Utilities/vxl/vcl/win32-vc60/vcl_memory.h b/Utilities/ITK/Utilities/vxl/vcl/win32-vc60/vcl_memory.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/Algorithms/CMakeLists.txt b/Utilities/ITK/Wrapping/CSwig/Algorithms/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/Algorithms/wrap_ITKAlgorithmsJava.cxx b/Utilities/ITK/Wrapping/CSwig/Algorithms/wrap_ITKAlgorithmsJava.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/Algorithms/wrap_ITKAlgorithmsPython.cxx b/Utilities/ITK/Wrapping/CSwig/Algorithms/wrap_ITKAlgorithmsPython.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/Algorithms/wrap_ITKAlgorithmsTcl.cxx b/Utilities/ITK/Wrapping/CSwig/Algorithms/wrap_ITKAlgorithmsTcl.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/CMakeLists.txt b/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/MakeConsistentWrappedClasses.sh b/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/MakeConsistentWrappedClasses.sh old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_ITKBasicFiltersA.cxx b/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_ITKBasicFiltersA.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_ITKBasicFiltersAJava.cxx b/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_ITKBasicFiltersAJava.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_ITKBasicFiltersAPython.cxx b/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_ITKBasicFiltersAPython.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_ITKBasicFiltersATcl.cxx b/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_ITKBasicFiltersATcl.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_itkAnisotropicDiffusionImageFilter_2D.cxx b/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_itkAnisotropicDiffusionImageFilter_2D.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_itkAnisotropicDiffusionImageFilter_3D.cxx b/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_itkAnisotropicDiffusionImageFilter_3D.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_itkBinaryDilateImageFilter.cxx b/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_itkBinaryDilateImageFilter.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_itkBinaryErodeImageFilter.cxx b/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_itkBinaryErodeImageFilter.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_itkBinaryThresholdImageFilter.cxx b/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_itkBinaryThresholdImageFilter.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_itkCannyEdgeDetectionImageFilter.cxx b/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_itkCannyEdgeDetectionImageFilter.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_itkChangeInformationImageFilter.cxx b/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_itkChangeInformationImageFilter.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_itkConfidenceConnectedImageFilter.cxx b/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_itkConfidenceConnectedImageFilter.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_itkConnectedThresholdImageFilter.cxx b/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_itkConnectedThresholdImageFilter.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_itkCurvatureAnisotropicDiffusionImageFilter.cxx b/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_itkCurvatureAnisotropicDiffusionImageFilter.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_itkDanielssonDistanceMapImageFilter.cxx b/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_itkDanielssonDistanceMapImageFilter.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_itkExtractImageFilter.cxx b/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_itkExtractImageFilter.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_itkFlipImageFilter.cxx b/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_itkFlipImageFilter.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_itkGradientAnisotropicDiffusionImageFilter.cxx b/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_itkGradientAnisotropicDiffusionImageFilter.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_itkGrayscaleDilateImageFilter.cxx b/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_itkGrayscaleDilateImageFilter.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_itkGrayscaleErodeImageFilter.cxx b/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_itkGrayscaleErodeImageFilter.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_itkImportImageFilter.cxx b/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_itkImportImageFilter.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_itkIsolatedConnectedImageFilter.cxx b/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_itkIsolatedConnectedImageFilter.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_itkLaplacianImageFilter.cxx b/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_itkLaplacianImageFilter.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_itkMinimumMaximumImageCalculator.cxx b/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_itkMinimumMaximumImageCalculator.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_itkSobelEdgeDetectionImageFilter.cxx b/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_itkSobelEdgeDetectionImageFilter.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_itkTernaryMagnitudeImageFilter.cxx b/Utilities/ITK/Wrapping/CSwig/BasicFiltersA/wrap_itkTernaryMagnitudeImageFilter.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/CMakeLists.txt b/Utilities/ITK/Wrapping/CSwig/CMakeLists.txt old mode 100644 new mode 100755 index c50ca6736742abea1f2f39766e32211fce43c3f9..18e6cbbc4d4dad07fa66a40a209fe6f799f89896 --- a/Utilities/ITK/Wrapping/CSwig/CMakeLists.txt +++ b/Utilities/ITK/Wrapping/CSwig/CMakeLists.txt @@ -303,6 +303,13 @@ SET(SWIG_INC ${ITK_TOP}/Wrapping/CSwig/IO ${ITK_TOP}/Wrapping/CSwig/Algorithms ) +IF(ITK_USE_SYSTEM_VXL) + SET(SWIG_INC + ${SWIG_INC} + ${VXL_VCL_INCLUDE_DIR} + ${VXL_CORE_INCLUDE_DIR} + ) +ENDIF(ITK_USE_SYSTEM_VXL) ADD_DEFINITIONS(-DSWIG_GLOBAL) SET(ITK_KITS VXLNumerics CommonA CommonB Numerics diff --git a/Utilities/ITK/Wrapping/CSwig/CommonA/CMakeLists.txt b/Utilities/ITK/Wrapping/CSwig/CommonA/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/CommonA/SwigExtras.i b/Utilities/ITK/Wrapping/CSwig/CommonA/SwigExtras.i old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/CommonA/SwigGetTclInterp.i b/Utilities/ITK/Wrapping/CSwig/CommonA/SwigGetTclInterp.i old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/CommonA/itkCommand.i b/Utilities/ITK/Wrapping/CSwig/CommonA/itkCommand.i old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/CommonA/itkJavaCommand.h b/Utilities/ITK/Wrapping/CSwig/CommonA/itkJavaCommand.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/CommonA/wrap_ITKCommonAPython.cxx b/Utilities/ITK/Wrapping/CSwig/CommonA/wrap_ITKCommonAPython.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/CommonA/wrap_ITKCommonATcl.cxx b/Utilities/ITK/Wrapping/CSwig/CommonA/wrap_ITKCommonATcl.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/CommonA/wrap_ITKCommonBase.cxx b/Utilities/ITK/Wrapping/CSwig/CommonA/wrap_ITKCommonBase.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/CommonA/wrap_ITKInterpolators.cxx b/Utilities/ITK/Wrapping/CSwig/CommonA/wrap_ITKInterpolators.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/CommonA/wrap_ITKRegions.cxx b/Utilities/ITK/Wrapping/CSwig/CommonA/wrap_ITKRegions.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/CommonA/wrap_itkArray.cxx b/Utilities/ITK/Wrapping/CSwig/CommonA/wrap_itkArray.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/CommonA/wrap_itkBinaryBallStructuringElement.cxx b/Utilities/ITK/Wrapping/CSwig/CommonA/wrap_itkBinaryBallStructuringElement.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/CommonA/wrap_itkContinuousIndex.cxx b/Utilities/ITK/Wrapping/CSwig/CommonA/wrap_itkContinuousIndex.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/CommonA/wrap_itkDifferenceImageFilter.cxx b/Utilities/ITK/Wrapping/CSwig/CommonA/wrap_itkDifferenceImageFilter.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/CommonA/wrap_itkEventObject.cxx b/Utilities/ITK/Wrapping/CSwig/CommonA/wrap_itkEventObject.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/CommonA/wrap_itkFiniteDifferenceFunction.cxx b/Utilities/ITK/Wrapping/CSwig/CommonA/wrap_itkFiniteDifferenceFunction.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/CommonA/wrap_itkFixedArray.cxx b/Utilities/ITK/Wrapping/CSwig/CommonA/wrap_itkFixedArray.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/CommonA/wrap_itkImageToImageFilter_2D.cxx b/Utilities/ITK/Wrapping/CSwig/CommonA/wrap_itkImageToImageFilter_2D.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/CommonA/wrap_itkImageToImageFilter_3D.cxx b/Utilities/ITK/Wrapping/CSwig/CommonA/wrap_itkImageToImageFilter_3D.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/CommonA/wrap_itkIndex.cxx b/Utilities/ITK/Wrapping/CSwig/CommonA/wrap_itkIndex.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/CommonA/wrap_itkNeighborhood.cxx b/Utilities/ITK/Wrapping/CSwig/CommonA/wrap_itkNeighborhood.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/CommonA/wrap_itkPoint.cxx b/Utilities/ITK/Wrapping/CSwig/CommonA/wrap_itkPoint.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/CommonA/wrap_itkSize.cxx b/Utilities/ITK/Wrapping/CSwig/CommonA/wrap_itkSize.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/CommonA/wrap_itkVector.cxx b/Utilities/ITK/Wrapping/CSwig/CommonA/wrap_itkVector.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/CommonB/CMakeLists.txt b/Utilities/ITK/Wrapping/CSwig/CommonB/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/CommonB/wrap_ITKCommonB.cxx b/Utilities/ITK/Wrapping/CSwig/CommonB/wrap_ITKCommonB.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/CommonB/wrap_ITKCommonBPython.cxx b/Utilities/ITK/Wrapping/CSwig/CommonB/wrap_ITKCommonBPython.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/CommonB/wrap_ITKCommonBTcl.cxx b/Utilities/ITK/Wrapping/CSwig/CommonB/wrap_ITKCommonBTcl.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/CommonB/wrap_ITKKernelDeformableTransforms.cxx b/Utilities/ITK/Wrapping/CSwig/CommonB/wrap_ITKKernelDeformableTransforms.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/CommonB/wrap_ITKRigidTransforms.cxx b/Utilities/ITK/Wrapping/CSwig/CommonB/wrap_ITKRigidTransforms.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/CommonB/wrap_ITKSimilarityTransforms.cxx b/Utilities/ITK/Wrapping/CSwig/CommonB/wrap_ITKSimilarityTransforms.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/CommonB/wrap_itkAffineTransform.cxx b/Utilities/ITK/Wrapping/CSwig/CommonB/wrap_itkAffineTransform.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/CommonB/wrap_itkAzimuthElevationToCartesianTransform.cxx b/Utilities/ITK/Wrapping/CSwig/CommonB/wrap_itkAzimuthElevationToCartesianTransform.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/CommonB/wrap_itkBSplineDeformableTransform.cxx b/Utilities/ITK/Wrapping/CSwig/CommonB/wrap_itkBSplineDeformableTransform.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/CommonB/wrap_itkIdentityTransform.cxx b/Utilities/ITK/Wrapping/CSwig/CommonB/wrap_itkIdentityTransform.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/CommonB/wrap_itkMatrixOffsetTransformBase.cxx b/Utilities/ITK/Wrapping/CSwig/CommonB/wrap_itkMatrixOffsetTransformBase.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/CommonB/wrap_itkScaleTransform.cxx b/Utilities/ITK/Wrapping/CSwig/CommonB/wrap_itkScaleTransform.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/CommonB/wrap_itkTransform.cxx b/Utilities/ITK/Wrapping/CSwig/CommonB/wrap_itkTransform.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/CommonB/wrap_itkTranslationTransform.cxx b/Utilities/ITK/Wrapping/CSwig/CommonB/wrap_itkTranslationTransform.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/CommonB/wrap_itkVersorTransform.cxx b/Utilities/ITK/Wrapping/CSwig/CommonB/wrap_itkVersorTransform.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/IO/CMakeLists.txt b/Utilities/ITK/Wrapping/CSwig/IO/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/IO/wrap_ITKIOJava.cxx b/Utilities/ITK/Wrapping/CSwig/IO/wrap_ITKIOJava.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/IO/wrap_ITKIOPython.cxx b/Utilities/ITK/Wrapping/CSwig/IO/wrap_ITKIOPython.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/IO/wrap_ITKIOTcl.cxx b/Utilities/ITK/Wrapping/CSwig/IO/wrap_ITKIOTcl.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/Java/CMakeLists.txt b/Utilities/ITK/Wrapping/CSwig/Java/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/Java/ITKJavaJarDummyLibrary.c b/Utilities/ITK/Wrapping/CSwig/Java/ITKJavaJarDummyLibrary.c old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/Master.mdx.in b/Utilities/ITK/Wrapping/CSwig/Master.mdx.in old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/Numerics/CMakeLists.txt b/Utilities/ITK/Wrapping/CSwig/Numerics/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/Numerics/wrap_ITKCostFunctions.cxx b/Utilities/ITK/Wrapping/CSwig/Numerics/wrap_ITKCostFunctions.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/Numerics/wrap_ITKNumerics.cxx b/Utilities/ITK/Wrapping/CSwig/Numerics/wrap_ITKNumerics.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/Numerics/wrap_ITKNumericsJava.cxx b/Utilities/ITK/Wrapping/CSwig/Numerics/wrap_ITKNumericsJava.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/Numerics/wrap_ITKNumericsPython.cxx b/Utilities/ITK/Wrapping/CSwig/Numerics/wrap_ITKNumericsPython.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/Numerics/wrap_ITKNumericsTcl.cxx b/Utilities/ITK/Wrapping/CSwig/Numerics/wrap_ITKNumericsTcl.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/Numerics/wrap_ITKOptimizers.cxx b/Utilities/ITK/Wrapping/CSwig/Numerics/wrap_ITKOptimizers.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/Patented/CMakeLists.txt b/Utilities/ITK/Wrapping/CSwig/Patented/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/Patented/wrap_ITKPatentedJava.cxx b/Utilities/ITK/Wrapping/CSwig/Patented/wrap_ITKPatentedJava.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/Patented/wrap_ITKPatentedPython.cxx b/Utilities/ITK/Wrapping/CSwig/Patented/wrap_ITKPatentedPython.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/Patented/wrap_ITKPatentedTcl.cxx b/Utilities/ITK/Wrapping/CSwig/Patented/wrap_ITKPatentedTcl.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/README b/Utilities/ITK/Wrapping/CSwig/README old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/SwigInc.txt.in b/Utilities/ITK/Wrapping/CSwig/SwigInc.txt.in old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/SwigRuntime/CMakeLists.txt b/Utilities/ITK/Wrapping/CSwig/SwigRuntime/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/SwigRuntime/JavaCWD.cxx b/Utilities/ITK/Wrapping/CSwig/SwigRuntime/JavaCWD.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/SwigRuntime/JavaCWD.h b/Utilities/ITK/Wrapping/CSwig/SwigRuntime/JavaCWD.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/SwigRuntime/JavaCWD.i b/Utilities/ITK/Wrapping/CSwig/SwigRuntime/JavaCWD.i old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/SwigRuntime/swigrun.h b/Utilities/ITK/Wrapping/CSwig/SwigRuntime/swigrun.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/Tcl/CMakeLists.txt b/Utilities/ITK/Wrapping/CSwig/Tcl/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/Tcl/itkTclAppInit.cxx b/Utilities/ITK/Wrapping/CSwig/Tcl/itkTclAppInit.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/Tests/Java/cannyEdgeDetectionImageFilter.java b/Utilities/ITK/Wrapping/CSwig/Tests/Java/cannyEdgeDetectionImageFilter.java old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/Tests/Python/cannyEdgeDetectionImageFilter.py b/Utilities/ITK/Wrapping/CSwig/Tests/Python/cannyEdgeDetectionImageFilter.py old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/Tests/Python/testObject.py b/Utilities/ITK/Wrapping/CSwig/Tests/Python/testObject.py old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/Tests/Tcl/randomImage.tcl b/Utilities/ITK/Wrapping/CSwig/Tests/Tcl/randomImage.tcl old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/Tests/Tcl/testDirectory.tcl b/Utilities/ITK/Wrapping/CSwig/Tests/Tcl/testDirectory.tcl old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/Tests/Tcl/testObject.tcl b/Utilities/ITK/Wrapping/CSwig/Tests/Tcl/testObject.tcl old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/VXLNumerics/CMakeLists.txt b/Utilities/ITK/Wrapping/CSwig/VXLNumerics/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/VXLNumerics/wrap_VXLNumerics.cxx b/Utilities/ITK/Wrapping/CSwig/VXLNumerics/wrap_VXLNumerics.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/VXLNumerics/wrap_VXLNumerics.h b/Utilities/ITK/Wrapping/CSwig/VXLNumerics/wrap_VXLNumerics.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/VXLNumerics/wrap_VXLNumericsJava.cxx b/Utilities/ITK/Wrapping/CSwig/VXLNumerics/wrap_VXLNumericsJava.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/VXLNumerics/wrap_VXLNumericsPerl.cxx b/Utilities/ITK/Wrapping/CSwig/VXLNumerics/wrap_VXLNumericsPerl.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/VXLNumerics/wrap_VXLNumericsPython.cxx b/Utilities/ITK/Wrapping/CSwig/VXLNumerics/wrap_VXLNumericsPython.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/VXLNumerics/wrap_VXLNumericsTcl.cxx b/Utilities/ITK/Wrapping/CSwig/VXLNumerics/wrap_VXLNumericsTcl.cxx old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/empty.depend.in b/Utilities/ITK/Wrapping/CSwig/empty.depend.in old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/itkCSwigBinaryBallStructuringElement.h b/Utilities/ITK/Wrapping/CSwig/itkCSwigBinaryBallStructuringElement.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/itkCSwigImages.h b/Utilities/ITK/Wrapping/CSwig/itkCSwigImages.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/CSwig/itkCSwigMacros.h b/Utilities/ITK/Wrapping/CSwig/itkCSwigMacros.h old mode 100644 new mode 100755 diff --git a/Utilities/ITK/Wrapping/WrapITK/Modules/SegmentationAndThreshold/wrap_itkBayesianClassifierImageFilter.cmake b/Utilities/ITK/Wrapping/WrapITK/Modules/SegmentationAndThreshold/wrap_itkBayesianClassifierImageFilter.cmake index 51408843e269acb3e669d7145ada9faecdf14e72..008a68a943e1769fa30b7a9c7b8984a70e407e08 100644 --- a/Utilities/ITK/Wrapping/WrapITK/Modules/SegmentationAndThreshold/wrap_itkBayesianClassifierImageFilter.cmake +++ b/Utilities/ITK/Wrapping/WrapITK/Modules/SegmentationAndThreshold/wrap_itkBayesianClassifierImageFilter.cmake @@ -3,7 +3,7 @@ WRAP_CLASS("itk::BayesianClassifierImageFilter" POINTER) FOREACH(t ${WRAP_ITK_SCALAR}) FOREACH(t2 ${WRAP_ITK_INT}) FOREACH(t3 ${WRAP_ITK_REAL}) - WRAP_TEMPLATE("${ITKM_VI${t}${d}}${ITKM_${t2}}${ITKM_${t3}}" "${ITKT_VI${t}${d}}, ${ITKT_${t2}}, ${ITKT_${t3}}") + WRAP_TEMPLATE("${ITKM_VI${t}${d}}${ITKM_${t2}}${ITKM_${t3}}${ITKM_${t3}}" "${ITKT_VI${t}${d}}, ${ITKT_${t2}}, ${ITKT_${t3}}, ${ITKT_${t3}}") ENDFOREACH(t3) ENDFOREACH(t2) ENDFOREACH(t) diff --git a/Utilities/ITK/itkConfigure.h.in b/Utilities/ITK/itkConfigure.h.in index ad3448223071a3b3466056a8b88e634595ab8fa2..62d0364ad97f7e414bc03e707c7ec03a99b1e727 100644 --- a/Utilities/ITK/itkConfigure.h.in +++ b/Utilities/ITK/itkConfigure.h.in @@ -3,8 +3,8 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkConfigure.h.in,v $ Language: C++ - Date: $Date: 2009-06-16 07:58:46 $ - Version: $Revision: 1.33 $ + Date: $Date: 2010-01-13 14:19:07 $ + Version: $Revision: 1.41 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -88,12 +88,63 @@ #cmakedefine ITK_USE_REGION_VALIDATION_IN_ITERATORS #cmakedefine ITK_USE_TEMPLATE_META_PROGRAMMING_LOOP_UNROLLING #cmakedefine ITK_USE_DEPRECATED_LEVELSET_INTERPOLATION +#cmakedefine ITK_USE_DEPRECATED_FAST_MARCHING #cmakedefine ITK_USE_REVIEW #cmakedefine ITK_SUPPORTS_TEMPLATED_FRIEND_FUNCTION_WITH_TEMPLATE_ARGUMENTS #cmakedefine ITK_SUPPORTS_TEMPLATED_FRIEND_FUNCTION_WITH_EMPTY_BRACKETS #cmakedefine ITK_SUPPORTS_TEMPLATED_FRIEND_FUNCTION_WITH_NULL_STRING +#cmakedefine ITK_SUPPORTS_WCHAR_T_FILENAME_CSTYLEIO +#cmakedefine ITK_SUPPORTS_WCHAR_T_FILENAME_IOSTREAMS_CONSTRUCTORS +#cmakedefine ITK_SUPPORTS_FDSTREAM_HPP + +/* + * TODO: this should be changed to a compile time test for the needed + * feature and then defined as a cmake variable + */ +#if !(defined( _MSC_VER ) && ( _MSC_VER < 1310 )) +#define ITK_USE_NUMERIC_TRAITS_PARTIAL_SPECIALIZATION +#endif + +/* + * The @HAVE_INCLUDE_H@ gets replaced with "1" or "", this define is + * to remap these values to 0 and 1 + */ +#define ITK_CMAKEDEFINE_VAR_1 1 +#define ITK_CMAKEDEFINE_VAR_ 0 + +/* + * Check Include files defines. We use the CMake standard names in the + * cmake files to reduce extra calls for checking header, but then + * conditionally defined them here with an ITK_ prefix to prevent + * collisions and re defined warnings. + */ +#if ITK_CMAKEDEFINE_VAR_@HAVE_FENV_H@ +# define ITK_HAVE_FENV_H +#endif /* HAVE_FENV_H */ +#if ITK_CMAKEDEFINE_VAR_@HAVE_SYS_TYPES_H@ +# define ITK_HAVE_SYS_TYPES_H +#endif /* HAVE_SYS_TYPES_H */ +#if ITK_CMAKEDEFINE_VAR_@HAVE_STDINT_H@ +# define ITK_HAVE_STDINT_H +#endif /* HAVE_STDINT_H */ +#if ITK_CMAKEDEFINE_VAR_@HAVE_STDDEF_H@ +# define ITK_HAVE_STDDEF_H +#endif /* HAVE_STDDEF_H */ +#if ITK_CMAKEDEFINE_VAR_@HAVE_UNISTD_H@ +# define ITK_HAVE_UNISTD_H +#endif /* HAVE_UNISTD_H */ + +#undef ITK_CMAKEDEFINE_VAR_1 +#undef ITK_CMAKEDEFINE_VAR_ + + +/* + * Enable ITK usage of and long long + */ +#cmakedefine ITK_TYPE_USE_LONG_LONG #define ITK_VERSION_MAJOR @ITK_VERSION_MAJOR@ #define ITK_VERSION_MINOR @ITK_VERSION_MINOR@ #define ITK_VERSION_PATCH @ITK_VERSION_PATCH@ #define ITK_VERSION_STRING "@ITK_VERSION_STRING@" + diff --git a/Utilities/ITK/itkIncludeDirectories.cmake b/Utilities/ITK/itkIncludeDirectories.cmake index a3c6c011086ab8ae80e4bd799e68832e5e2e060d..afd81128f7d6deb83712567f5a24e76a892ecaf3 100644 --- a/Utilities/ITK/itkIncludeDirectories.cmake +++ b/Utilities/ITK/itkIncludeDirectories.cmake @@ -32,8 +32,8 @@ SET(ITK_INCLUDE_DIRS_BUILD_TREE ${ITK_INCLUDE_DIRS_BUILD_TREE} ${ITK_BINARY_DIR}/Utilities/NrrdIO ${ITK_SOURCE_DIR}/Utilities/DICOMParser ${ITK_BINARY_DIR}/Utilities/DICOMParser -# ${ITK_BINARY_DIR}/Utilities/expat -# ${ITK_SOURCE_DIR}/Utilities/expat +# ${ITK_BINARY_DIR}/Utilities/expat +# ${ITK_SOURCE_DIR}/Utilities/expat ${ITK_SOURCE_DIR}/../otbexpat ${ITK_SOURCE_DIR}/Utilities/nifti/niftilib ${ITK_SOURCE_DIR}/Utilities/nifti/znzlib @@ -147,7 +147,7 @@ SET(ITK_INCLUDE_RELATIVE_DIRS ${ITK_INCLUDE_RELATIVE_DIRS} Utilities/MetaIO Utilities/NrrdIO Utilities/DICOMParser -# Utilities/expat +# Utilities/expat ../otbexpat Utilities/nifti/niftilib Utilities/nifti/znzlib