Changeset 8964 for OpenSceneGraph/trunk/examples/osgvolume/osgvolume.cpp
- Timestamp:
- 10/02/08 17:45:08 (5 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/examples/osgvolume/osgvolume.cpp
r8961 r8964 38 38 #include <osg/BlendEquation> 39 39 #include <osg/TransferFunction> 40 #include <osg/MatrixTransform> 40 41 41 42 #include <osgDB/Registry> … … 2020 2021 if (osgDB::getLowerCaseFileExtension(filename)=="dicom") 2021 2022 { 2022 images.push_back(osgDB::readImageFile( filename )); 2023 // not an option so assume string is a filename. 2024 osg::Image *image = osgDB::readImageFile(filename); 2025 if(image) 2026 { 2027 images.push_back(image); 2028 } 2023 2029 } 2024 2030 else … … 2033 2039 if (fileType == osgDB::DIRECTORY) 2034 2040 { 2035 osgDB::DirectoryContents contents = osgDB::getDirectoryContents(filename); 2036 2037 std::sort(contents.begin(), contents.end()); 2038 2039 ImageList imageList; 2040 for(osgDB::DirectoryContents::iterator itr = contents.begin(); 2041 itr != contents.end(); 2042 ++itr) 2041 osg::Image *image = osgDB::readImageFile(filename+".dicom"); 2042 if(image) 2043 2043 { 2044 std::string localFile = filename + "/" + *itr; 2045 std::cout<<"contents = "<<localFile<<std::endl; 2046 if (osgDB::fileType(localFile) == osgDB::REGULAR_FILE) 2047 { 2048 // not an option so assume string is a filename. 2049 osg::Image *image = osgDB::readImageFile(localFile); 2050 if(image) 2051 { 2052 imageList.push_back(image); 2053 } 2054 } 2055 } 2056 2057 // pack the textures into a single texture. 2058 ProcessRow processRow; 2059 images.push_back(createTexture3D(imageList, processRow, numComponentsDesired, s_maximumTextureSize, t_maximumTextureSize, r_maximumTextureSize, resizeToPowerOfTwo)); 2060 2044 images.push_back(image); 2045 } 2061 2046 } 2062 2047 else if (fileType == osgDB::REGULAR_FILE) … … 2099 2084 2100 2085 2101 #if 12102 2086 osg::RefMatrix* matrix = dynamic_cast<osg::RefMatrix*>(images.front()->getUserData()); 2087 #if 0 2103 2088 if (matrix) 2104 2089 { … … 2110 2095 #endif 2111 2096 2112 osg::Vec4 minValue, maxValue; 2097 osg::Vec4 minValue(FLT_MAX, FLT_MAX, FLT_MAX, FLT_MAX); 2098 osg::Vec4 maxValue(-FLT_MAX, -FLT_MAX, -FLT_MAX, -FLT_MAX); 2113 2099 bool computeMinMax = false; 2114 2100 for(Images::iterator itr = images.begin(); … … 2116 2102 ++itr) 2117 2103 { 2118 #if 0 2119 osg::RefMatrix* matrix = dynamic_cast<osg::RefMatrix*>((*itr)->getUserData()); 2120 if (matrix) 2121 { 2122 std::cout<<"matrix = "<<*matrix<<std::endl; 2123 } 2124 #endif 2125 if (osgVolume::computeMinMax(itr->get(), minValue, maxValue)) computeMinMax = true; 2126 } 2127 2104 osg::Vec4 localMinValue, localMaxValue; 2105 if (osgVolume::computeMinMax(itr->get(), localMinValue, localMaxValue)) 2106 { 2107 if (localMinValue.r()<minValue.r()) minValue.r() = localMinValue.r(); 2108 if (localMinValue.g()<minValue.g()) minValue.g() = localMinValue.g(); 2109 if (localMinValue.b()<minValue.b()) minValue.b() = localMinValue.b(); 2110 if (localMinValue.a()<minValue.a()) minValue.a() = localMinValue.a(); 2111 2112 if (localMaxValue.r()>maxValue.r()) maxValue.r() = localMaxValue.r(); 2113 if (localMaxValue.g()>maxValue.g()) maxValue.g() = localMaxValue.g(); 2114 if (localMaxValue.b()>maxValue.b()) maxValue.b() = localMaxValue.b(); 2115 if (localMaxValue.a()>maxValue.a()) maxValue.a() = localMaxValue.a(); 2116 2117 osg::notify(osg::NOTICE)<<" ("<<localMinValue<<") ("<<localMaxValue<<") "<<(*itr)->getFileName()<<std::endl; 2118 2119 computeMinMax = true; 2120 } 2121 } 2128 2122 2129 2123 if (computeMinMax) … … 2189 2183 2190 2184 osg::ref_ptr<osg::ImageSequence> imageSequence = new osg::ImageSequence; 2185 imageSequence->setLength(10.0); 2191 2186 image_3d = imageSequence.get(); 2192 2187 for(Images::iterator itr = images.begin(); … … 2243 2238 } 2244 2239 2240 if (matrix && rootNode) 2241 { 2242 osg::MatrixTransform* mt = new osg::MatrixTransform; 2243 mt->setMatrix(*matrix); 2244 mt->addChild(rootNode); 2245 2246 rootNode = mt; 2247 } 2248 2245 2249 if (!outputFile.empty()) 2246 2250 {
