Moved osgVolume::ImageUtils to osg::ImageUtils, updated wrappers, and started moving osgvolume example across to create osgVolume subgraphs
This commit is contained in:
parent
9b4c6e25ea
commit
458993fa88
@ -60,7 +60,9 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include <osgVolume/ImageUtils>
|
#include <osg/ImageUtils>
|
||||||
|
#include <osgVolume/Volume>
|
||||||
|
#include <osgVolume/VolumeTile>
|
||||||
|
|
||||||
typedef std::vector< osg::ref_ptr<osg::Image> > ImageList;
|
typedef std::vector< osg::ref_ptr<osg::Image> > ImageList;
|
||||||
|
|
||||||
@ -1519,8 +1521,8 @@ osg::Image* readRaw(int sizeX, int sizeY, int sizeZ, int numberBytesPerComponent
|
|||||||
{
|
{
|
||||||
// compute range of values
|
// compute range of values
|
||||||
osg::Vec4 minValue, maxValue;
|
osg::Vec4 minValue, maxValue;
|
||||||
osgVolume::computeMinMax(image.get(), minValue, maxValue);
|
osg::computeMinMax(image.get(), minValue, maxValue);
|
||||||
osgVolume::modifyImage(image.get(),ScaleOperator(1.0f/maxValue.r()));
|
osg::modifyImage(image.get(),ScaleOperator(1.0f/maxValue.r()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1545,12 +1547,12 @@ osg::Image* readRaw(int sizeX, int sizeY, int sizeZ, int numberBytesPerComponent
|
|||||||
writeOp._pos = 0;
|
writeOp._pos = 0;
|
||||||
|
|
||||||
// read the pixels into readOp's _colour array
|
// read the pixels into readOp's _colour array
|
||||||
osgVolume::readRow(sizeS, pixelFormat, dataType, image->data(0,t,r), readOp);
|
osg::readRow(sizeS, pixelFormat, dataType, image->data(0,t,r), readOp);
|
||||||
|
|
||||||
// pass readOp's _colour array contents over to writeOp (note this is just a pointer swap).
|
// pass readOp's _colour array contents over to writeOp (note this is just a pointer swap).
|
||||||
writeOp._colours.swap(readOp._colours);
|
writeOp._colours.swap(readOp._colours);
|
||||||
|
|
||||||
osgVolume::modifyRow(sizeS, pixelFormat, GL_UNSIGNED_BYTE, new_image->data(0,t,r), writeOp);
|
osg::modifyRow(sizeS, pixelFormat, GL_UNSIGNED_BYTE, new_image->data(0,t,r), writeOp);
|
||||||
|
|
||||||
// return readOp's _colour array contents back to its rightful owner.
|
// return readOp's _colour array contents back to its rightful owner.
|
||||||
writeOp._colours.swap(readOp._colours);
|
writeOp._colours.swap(readOp._colours);
|
||||||
@ -1617,19 +1619,19 @@ osg::Image* doColourSpaceConversion(ColourSpaceOperation op, osg::Image* image,
|
|||||||
case (MODULATE_ALPHA_BY_LUMINANCE):
|
case (MODULATE_ALPHA_BY_LUMINANCE):
|
||||||
{
|
{
|
||||||
std::cout<<"doing conversion MODULATE_ALPHA_BY_LUMINANCE"<<std::endl;
|
std::cout<<"doing conversion MODULATE_ALPHA_BY_LUMINANCE"<<std::endl;
|
||||||
osgVolume::modifyImage(image,ModulateAlphaByLuminanceOperator());
|
osg::modifyImage(image,ModulateAlphaByLuminanceOperator());
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
case (MODULATE_ALPHA_BY_COLOUR):
|
case (MODULATE_ALPHA_BY_COLOUR):
|
||||||
{
|
{
|
||||||
std::cout<<"doing conversion MODULATE_ALPHA_BY_COLOUR"<<std::endl;
|
std::cout<<"doing conversion MODULATE_ALPHA_BY_COLOUR"<<std::endl;
|
||||||
osgVolume::modifyImage(image,ModulateAlphaByColourOperator(colour));
|
osg::modifyImage(image,ModulateAlphaByColourOperator(colour));
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
case (REPLACE_ALPHA_WITH_LUMINANACE):
|
case (REPLACE_ALPHA_WITH_LUMINANACE):
|
||||||
{
|
{
|
||||||
std::cout<<"doing conversion REPLACE_ALPHA_WITH_LUMINANACE"<<std::endl;
|
std::cout<<"doing conversion REPLACE_ALPHA_WITH_LUMINANACE"<<std::endl;
|
||||||
osgVolume::modifyImage(image,ReplaceAlphaWithLuminanceOperator());
|
osg::modifyImage(image,ReplaceAlphaWithLuminanceOperator());
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
case (REPLACE_RGB_WITH_LUMINANCE):
|
case (REPLACE_RGB_WITH_LUMINANCE):
|
||||||
@ -1637,7 +1639,7 @@ osg::Image* doColourSpaceConversion(ColourSpaceOperation op, osg::Image* image,
|
|||||||
std::cout<<"doing conversion REPLACE_ALPHA_WITH_LUMINANACE"<<std::endl;
|
std::cout<<"doing conversion REPLACE_ALPHA_WITH_LUMINANACE"<<std::endl;
|
||||||
osg::Image* newImage = new osg::Image;
|
osg::Image* newImage = new osg::Image;
|
||||||
newImage->allocateImage(image->s(), image->t(), image->r(), GL_LUMINANCE, image->getDataType());
|
newImage->allocateImage(image->s(), image->t(), image->r(), GL_LUMINANCE, image->getDataType());
|
||||||
osgVolume::copyImage(image, 0, 0, 0, image->s(), image->t(), image->r(),
|
osg::copyImage(image, 0, 0, 0, image->s(), image->t(), image->r(),
|
||||||
newImage, 0, 0, 0, false);
|
newImage, 0, 0, 0, false);
|
||||||
return newImage;
|
return newImage;
|
||||||
}
|
}
|
||||||
@ -1694,7 +1696,7 @@ osg::Image* applyTransferFunction(osg::Image* image, osg::TransferFunction1D* tr
|
|||||||
output_image->allocateImage(image->s(),image->t(), image->r(), GL_RGBA, GL_UNSIGNED_BYTE);
|
output_image->allocateImage(image->s(),image->t(), image->r(), GL_RGBA, GL_UNSIGNED_BYTE);
|
||||||
|
|
||||||
ApplyTransferFunctionOperator op(transferFunction, output_image->data());
|
ApplyTransferFunctionOperator op(transferFunction, output_image->data());
|
||||||
osgVolume::readImage(image,op);
|
osg::readImage(image,op);
|
||||||
|
|
||||||
return output_image;
|
return output_image;
|
||||||
}
|
}
|
||||||
@ -1938,6 +1940,10 @@ int main( int argc, char **argv )
|
|||||||
unsigned int numComponentsDesired = 0;
|
unsigned int numComponentsDesired = 0;
|
||||||
while(arguments.read("--num-components", numComponentsDesired)) {}
|
while(arguments.read("--num-components", numComponentsDesired)) {}
|
||||||
|
|
||||||
|
bool useOsgVolume = true;
|
||||||
|
while(arguments.read("--osgVolume")) { useOsgVolume = true; }
|
||||||
|
while(arguments.read("--no-osgVolume")) { useOsgVolume = false; }
|
||||||
|
|
||||||
bool useShader = true;
|
bool useShader = true;
|
||||||
while(arguments.read("--shader")) { useShader = true; }
|
while(arguments.read("--shader")) { useShader = true; }
|
||||||
while(arguments.read("--no-shader")) { useShader = true; }
|
while(arguments.read("--no-shader")) { useShader = true; }
|
||||||
@ -2139,7 +2145,7 @@ int main( int argc, char **argv )
|
|||||||
++itr)
|
++itr)
|
||||||
{
|
{
|
||||||
osg::Vec4 localMinValue, localMaxValue;
|
osg::Vec4 localMinValue, localMaxValue;
|
||||||
if (osgVolume::computeMinMax(itr->get(), localMinValue, localMaxValue))
|
if (osg::computeMinMax(itr->get(), localMinValue, localMaxValue))
|
||||||
{
|
{
|
||||||
if (localMinValue.r()<minValue.r()) minValue.r() = localMinValue.r();
|
if (localMinValue.r()<minValue.r()) minValue.r() = localMinValue.r();
|
||||||
if (localMinValue.g()<minValue.g()) minValue.g() = localMinValue.g();
|
if (localMinValue.g()<minValue.g()) minValue.g() = localMinValue.g();
|
||||||
@ -2187,7 +2193,7 @@ int main( int argc, char **argv )
|
|||||||
itr != images.end();
|
itr != images.end();
|
||||||
++itr)
|
++itr)
|
||||||
{
|
{
|
||||||
osgVolume::offsetAndScaleImage(itr->get(),
|
osg::offsetAndScaleImage(itr->get(),
|
||||||
osg::Vec4(offset, offset, offset, offset),
|
osg::Vec4(offset, offset, offset, offset),
|
||||||
osg::Vec4(scale, scale, scale, scale));
|
osg::Vec4(scale, scale, scale, scale));
|
||||||
}
|
}
|
||||||
@ -2201,7 +2207,7 @@ int main( int argc, char **argv )
|
|||||||
itr != images.end();
|
itr != images.end();
|
||||||
++itr)
|
++itr)
|
||||||
{
|
{
|
||||||
osgVolume::offsetAndScaleImage(itr->get(),
|
osg::offsetAndScaleImage(itr->get(),
|
||||||
osg::Vec4(offset, offset, offset, offset),
|
osg::Vec4(offset, offset, offset, offset),
|
||||||
osg::Vec4(1.0f, 1.0f, 1.0f, 1.0f));
|
osg::Vec4(1.0f, 1.0f, 1.0f, 1.0f));
|
||||||
}
|
}
|
||||||
@ -2280,6 +2286,20 @@ int main( int argc, char **argv )
|
|||||||
// create a model from the images.
|
// create a model from the images.
|
||||||
osg::Node* rootNode = 0;
|
osg::Node* rootNode = 0;
|
||||||
|
|
||||||
|
if (useOsgVolume)
|
||||||
|
{
|
||||||
|
|
||||||
|
osg::ref_ptr<osgVolume::Volume> volume = new osgVolume::Volume;
|
||||||
|
osg::ref_ptr<osgVolume::VolumeTile> tile = new osgVolume::VolumeTile;
|
||||||
|
osg::ref_ptr<osgVolume::Layer> layer = new osgVolume::ImageLayer(image_3d);
|
||||||
|
tile->addLayer(layer.get());
|
||||||
|
volume->addChild(tile);
|
||||||
|
|
||||||
|
rootNode = volume.get();
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
if (useShader)
|
if (useShader)
|
||||||
{
|
{
|
||||||
rootNode = createShaderModel(shadingModel,
|
rootNode = createShaderModel(shadingModel,
|
||||||
@ -2308,6 +2328,7 @@ int main( int argc, char **argv )
|
|||||||
|
|
||||||
rootNode = mt;
|
rootNode = mt;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!outputFile.empty())
|
if (!outputFile.empty())
|
||||||
{
|
{
|
||||||
|
@ -11,14 +11,14 @@
|
|||||||
* OpenSceneGraph Public License for more details.
|
* OpenSceneGraph Public License for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef OSGVOLUME_IMAGEUTILS
|
#ifndef OSG_IMAGEUTILS
|
||||||
#define OSGVOLUME_IMAGEUTILS 1
|
#define OSG_IMAGEUTILS 1
|
||||||
|
|
||||||
#include <osgVolume/Export>
|
#include <osg/Export>
|
||||||
|
|
||||||
#include <osg/Image>
|
#include <osg/Image>
|
||||||
|
|
||||||
namespace osgVolume {
|
namespace osg {
|
||||||
|
|
||||||
template <typename T, class O>
|
template <typename T, class O>
|
||||||
void _readRow(unsigned int num, GLenum pixelFormat, const T* data,float scale, O& operation)
|
void _readRow(unsigned int num, GLenum pixelFormat, const T* data,float scale, O& operation)
|
||||||
@ -121,17 +121,17 @@ void modifyImage(osg::Image* image, const M& operation)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Compute the min max colour values in the image.*/
|
/** Compute the min max colour values in the image.*/
|
||||||
extern OSGVOLUME_EXPORT bool computeMinMax(const osg::Image* image, osg::Vec4& min, osg::Vec4& max);
|
extern OSG_EXPORT bool computeMinMax(const osg::Image* image, osg::Vec4& min, osg::Vec4& max);
|
||||||
|
|
||||||
/** Compute the min max colour values in the image.*/
|
/** Compute the min max colour values in the image.*/
|
||||||
extern OSGVOLUME_EXPORT bool offsetAndScaleImage(osg::Image* image, const osg::Vec4& offset, const osg::Vec4& scale);
|
extern OSG_EXPORT bool offsetAndScaleImage(osg::Image* image, const osg::Vec4& offset, const osg::Vec4& scale);
|
||||||
|
|
||||||
/** Compute source image to destination image.*/
|
/** Compute source image to destination image.*/
|
||||||
extern OSGVOLUME_EXPORT bool copyImage(const osg::Image* srcImage, int src_s, int src_t, int src_r, int width, int height, int depth,
|
extern OSG_EXPORT bool copyImage(const osg::Image* srcImage, int src_s, int src_t, int src_r, int width, int height, int depth,
|
||||||
osg::Image* destImage, int dest_s, int dest_t, int dest_r, bool doRescale = false);
|
osg::Image* destImage, int dest_s, int dest_t, int dest_r, bool doRescale = false);
|
||||||
|
|
||||||
/** Compute the min max colour values in the image.*/
|
/** Compute the min max colour values in the image.*/
|
||||||
extern OSGVOLUME_EXPORT bool clearImageToColor(osg::Image* image, const osg::Vec4& colour);
|
extern OSG_EXPORT bool clearImageToColor(osg::Image* image, const osg::Vec4& colour);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -27,6 +27,8 @@ class OSGVOLUME_EXPORT Locator : public osg::Object
|
|||||||
|
|
||||||
Locator() {}
|
Locator() {}
|
||||||
|
|
||||||
|
Locator(const osg::Matrixd& transform) { setTransform(transform); }
|
||||||
|
|
||||||
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
|
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
|
||||||
Locator(const Locator& locator,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY):
|
Locator(const Locator& locator,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY):
|
||||||
osg::Object(locator, copyop),
|
osg::Object(locator, copyop),
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include <osgDB/ReaderWriter>
|
#include <osgDB/ReaderWriter>
|
||||||
|
|
||||||
|
#include <osgVolume/Layer>
|
||||||
#include <osgVolume/VolumeTechnique>
|
#include <osgVolume/VolumeTechnique>
|
||||||
|
|
||||||
namespace osgVolume {
|
namespace osgVolume {
|
||||||
@ -109,14 +110,19 @@ class OSGVOLUME_EXPORT VolumeTile : public osg::Group
|
|||||||
const TileID& getTileID() const { return _tileID; }
|
const TileID& getTileID() const { return _tileID; }
|
||||||
|
|
||||||
|
|
||||||
void setLocator(osg::RefMatrix* locator) { _locator = locator; }
|
void setLocator(Locator* locator) { _locator = locator; }
|
||||||
osg::RefMatrix* getLocator() { return _locator.get(); }
|
Locator* getLocator() { return _locator.get(); }
|
||||||
const osg::RefMatrix* getLocator() const { return _locator.get(); }
|
const Locator* getLocator() const { return _locator.get(); }
|
||||||
|
|
||||||
|
|
||||||
void setImage(unsigned int i, osg::Image* image);
|
void setLayer(unsigned int i, Layer* layer);
|
||||||
osg::Image* getImage(unsigned int i) { return i<_images.size() ? _images[i].get() : 0; }
|
Layer* getLayer(unsigned int i) { return i<_layers.size() ? _layers[i].get() : 0; }
|
||||||
const osg::Image* getImage(unsigned int i) const { return i<_images.size() ? _images[i].get() : 0; }
|
const Layer* getImage(unsigned int i) const { return i<_layers.size() ? _layers[i].get() : 0; }
|
||||||
|
|
||||||
|
void addLayer(Layer* layer) { if (layer) _layers.push_back(layer); }
|
||||||
|
|
||||||
|
unsigned int getNumLayers() { return _layers.size(); }
|
||||||
|
|
||||||
|
|
||||||
/** Set the VolumeTechnique*/
|
/** Set the VolumeTechnique*/
|
||||||
void setVolumeTechnique(VolumeTechnique* VolumeTechnique);
|
void setVolumeTechnique(VolumeTechnique* VolumeTechnique);
|
||||||
@ -152,10 +158,10 @@ class OSGVOLUME_EXPORT VolumeTile : public osg::Group
|
|||||||
|
|
||||||
osg::ref_ptr<VolumeTechnique> _volumeTechnique;
|
osg::ref_ptr<VolumeTechnique> _volumeTechnique;
|
||||||
|
|
||||||
osg::ref_ptr<osg::RefMatrix> _locator;
|
osg::ref_ptr<Locator> _locator;
|
||||||
|
|
||||||
typedef std::vector< osg::ref_ptr<osg::Image> > Images;
|
typedef std::vector< osg::ref_ptr<Layer> > Layers;
|
||||||
Images _images;
|
Layers _layers;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -82,6 +82,7 @@ SET(LIB_PUBLIC_HEADERS
|
|||||||
${HEADER_PATH}/Image
|
${HEADER_PATH}/Image
|
||||||
${HEADER_PATH}/ImageSequence
|
${HEADER_PATH}/ImageSequence
|
||||||
${HEADER_PATH}/ImageStream
|
${HEADER_PATH}/ImageStream
|
||||||
|
${HEADER_PATH}/ImageUtils
|
||||||
${HEADER_PATH}/io_utils
|
${HEADER_PATH}/io_utils
|
||||||
${HEADER_PATH}/KdTree
|
${HEADER_PATH}/KdTree
|
||||||
${HEADER_PATH}/Light
|
${HEADER_PATH}/Light
|
||||||
@ -241,6 +242,7 @@ ADD_LIBRARY(${LIB_NAME}
|
|||||||
Image.cpp
|
Image.cpp
|
||||||
ImageSequence.cpp
|
ImageSequence.cpp
|
||||||
ImageStream.cpp
|
ImageStream.cpp
|
||||||
|
ImageUtils.cpp
|
||||||
KdTree.cpp
|
KdTree.cpp
|
||||||
Light.cpp
|
Light.cpp
|
||||||
LightModel.cpp
|
LightModel.cpp
|
||||||
|
@ -13,11 +13,12 @@
|
|||||||
|
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <osg/Math>
|
#include <osg/Math>
|
||||||
#include <osg/Notify>
|
#include <osg/Notify>
|
||||||
#include <osgVolume/ImageUtils>
|
#include <osg/ImageUtils>
|
||||||
|
|
||||||
namespace osgVolume
|
namespace osg
|
||||||
{
|
{
|
||||||
|
|
||||||
struct FindRangeOperator
|
struct FindRangeOperator
|
||||||
@ -89,7 +90,7 @@ bool computeMinMax(const osg::Image* image, osg::Vec4& minValue, osg::Vec4& maxV
|
|||||||
{
|
{
|
||||||
if (!image) return false;
|
if (!image) return false;
|
||||||
|
|
||||||
osgVolume::FindRangeOperator rangeOp;
|
osg::FindRangeOperator rangeOp;
|
||||||
readImage(image, rangeOp);
|
readImage(image, rangeOp);
|
||||||
minValue.r() = rangeOp._rmin;
|
minValue.r() = rangeOp._rmin;
|
||||||
minValue.g() = rangeOp._gmin;
|
minValue.g() = rangeOp._gmin;
|
||||||
@ -111,7 +112,7 @@ bool offsetAndScaleImage(osg::Image* image, const osg::Vec4& offset, const osg::
|
|||||||
{
|
{
|
||||||
if (!image) return false;
|
if (!image) return false;
|
||||||
|
|
||||||
osgVolume::modifyImage(image,osgVolume::OffsetAndScaleOperator(offset, scale));
|
osg::modifyImage(image,osg::OffsetAndScaleOperator(offset, scale));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -302,12 +303,12 @@ bool copyImage(const osg::Image* srcImage, int src_s, int src_t, int src_r, int
|
|||||||
writeOp._pos = 0;
|
writeOp._pos = 0;
|
||||||
|
|
||||||
// read the pixels into readOp's _colour array
|
// read the pixels into readOp's _colour array
|
||||||
osgVolume::readRow(width, srcImage->getPixelFormat(), srcImage->getDataType(), srcImage->data(src_s,src_t+row,src_r+slice), readOp);
|
osg::readRow(width, srcImage->getPixelFormat(), srcImage->getDataType(), srcImage->data(src_s,src_t+row,src_r+slice), readOp);
|
||||||
|
|
||||||
// pass readOp's _colour array contents over to writeOp (note this is just a pointer swap).
|
// pass readOp's _colour array contents over to writeOp (note this is just a pointer swap).
|
||||||
writeOp._colours.swap(readOp._colours);
|
writeOp._colours.swap(readOp._colours);
|
||||||
|
|
||||||
osgVolume::modifyRow(width, destImage->getPixelFormat(), destImage->getDataType(), destImage->data(dest_s, dest_t+row,dest_r+slice), writeOp);
|
osg::modifyRow(width, destImage->getPixelFormat(), destImage->getDataType(), destImage->data(dest_s, dest_t+row,dest_r+slice), writeOp);
|
||||||
|
|
||||||
// return readOp's _colour array contents back to its rightful owner.
|
// return readOp's _colour array contents back to its rightful owner.
|
||||||
writeOp._colours.swap(readOp._colours);
|
writeOp._colours.swap(readOp._colours);
|
@ -8,6 +8,7 @@
|
|||||||
#include <osg/Geode>
|
#include <osg/Geode>
|
||||||
#include <osg/GL>
|
#include <osg/GL>
|
||||||
#include <osg/io_utils>
|
#include <osg/io_utils>
|
||||||
|
#include <osg/ImageUtils>
|
||||||
|
|
||||||
#include <osgDB/FileNameUtils>
|
#include <osgDB/FileNameUtils>
|
||||||
#include <osgDB/FileUtils>
|
#include <osgDB/FileUtils>
|
||||||
@ -15,7 +16,6 @@
|
|||||||
|
|
||||||
#include <osgVolume/Volume>
|
#include <osgVolume/Volume>
|
||||||
#include <osgVolume/VolumeTile>
|
#include <osgVolume/VolumeTile>
|
||||||
#include <osgVolume/ImageUtils>
|
|
||||||
|
|
||||||
#ifdef USE_DCMTK
|
#ifdef USE_DCMTK
|
||||||
#define HAVE_CONFIG_H
|
#define HAVE_CONFIG_H
|
||||||
@ -121,7 +121,10 @@ class ReaderWriterDICOM : public osgDB::ReaderWriter
|
|||||||
|
|
||||||
osg::ref_ptr<osgVolume::VolumeTile> tile = new osgVolume::VolumeTile;
|
osg::ref_ptr<osgVolume::VolumeTile> tile = new osgVolume::VolumeTile;
|
||||||
tile->setVolume(volume.get());
|
tile->setVolume(volume.get());
|
||||||
tile->setImage(0, result.getImage());
|
|
||||||
|
osg::ref_ptr<osgVolume::Layer> layer= new osgVolume::ImageLayer(result.getImage());
|
||||||
|
|
||||||
|
tile->addLayer(layer.get());
|
||||||
|
|
||||||
// get matrix providing size of texels (in mm)
|
// get matrix providing size of texels (in mm)
|
||||||
osg::RefMatrix* matrix = dynamic_cast<osg::RefMatrix*>(result.getImage()->getUserData());
|
osg::RefMatrix* matrix = dynamic_cast<osg::RefMatrix*>(result.getImage()->getUserData());
|
||||||
@ -134,7 +137,7 @@ class ReaderWriterDICOM : public osgDB::ReaderWriter
|
|||||||
osg::Vec3d scale(osg::Vec3(result.getImage()->s(),result.getImage()->t(), result.getImage()->r()));
|
osg::Vec3d scale(osg::Vec3(result.getImage()->s(),result.getImage()->t(), result.getImage()->r()));
|
||||||
matrix->postMultScale(scale);
|
matrix->postMultScale(scale);
|
||||||
|
|
||||||
tile->setLocator(matrix);
|
tile->setLocator(new osgVolume::Locator(*matrix));
|
||||||
|
|
||||||
result.getImage()->setUserData(0);
|
result.getImage()->setUserData(0);
|
||||||
|
|
||||||
@ -637,13 +640,13 @@ class ReaderWriterDICOM : public osgDB::ReaderWriter
|
|||||||
image->allocateImage(dcmImage->getWidth(), dcmImage->getHeight(), totalNumSlices,
|
image->allocateImage(dcmImage->getWidth(), dcmImage->getHeight(), totalNumSlices,
|
||||||
pixelFormat, dataType);
|
pixelFormat, dataType);
|
||||||
|
|
||||||
osgVolume::copyImage(previous_image.get(), 0,0,0, previous_image->s(), previous_image->t(), imageNum,
|
osg::copyImage(previous_image.get(), 0,0,0, previous_image->s(), previous_image->t(), imageNum,
|
||||||
image.get(), 0, 0, 0,
|
image.get(), 0, 0, 0,
|
||||||
false);
|
false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
osgVolume::copyImage(imageAdapter.get(), 0,0,0, imageAdapter->s(), imageAdapter->t(), imageAdapter->r(),
|
osg::copyImage(imageAdapter.get(), 0,0,0, imageAdapter->s(), imageAdapter->t(), imageAdapter->r(),
|
||||||
image.get(), 0, 0, imageNum,
|
image.get(), 0, 0, imageNum,
|
||||||
false);
|
false);
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ INCLUDE_DIRECTORIES( ${CAIRO_INCLUDE_DIRS} ${POPPLER_INCLUDE_DIRS} )
|
|||||||
LINK_DIRECTORIES(${CAIRO_LIBRARY_DIRS} ${POPPLER_LIB_DIRS})
|
LINK_DIRECTORIES(${CAIRO_LIBRARY_DIRS} ${POPPLER_LIB_DIRS})
|
||||||
SET(TARGET_EXTERNAL_LIBRARIES ${CAIRO_LIBRARIES} ${POPPLER_LIBRARIES} )
|
SET(TARGET_EXTERNAL_LIBRARIES ${CAIRO_LIBRARIES} ${POPPLER_LIBRARIES} )
|
||||||
|
|
||||||
SET(TARGET_ADDED_LIBRARIES osgWidget osgVolume)
|
SET(TARGET_ADDED_LIBRARIES osgWidget)
|
||||||
|
|
||||||
#### end var setup ###
|
#### end var setup ###
|
||||||
SETUP_PLUGIN(pdf pdf)
|
SETUP_PLUGIN(pdf pdf)
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
#include <osgDB/FileUtils>
|
#include <osgDB/FileUtils>
|
||||||
|
|
||||||
#include <osgWidget/PdfReader>
|
#include <osgWidget/PdfReader>
|
||||||
#include <osgVolume/ImageUtils>
|
#include <osg/ImageUtils>
|
||||||
|
|
||||||
#include <cairo.h>
|
#include <cairo.h>
|
||||||
#include <poppler.h>
|
#include <poppler.h>
|
||||||
@ -200,7 +200,7 @@ class PopplerPdfImage : public osgWidget::PdfImage
|
|||||||
|
|
||||||
_cairoImage->create((unsigned int)(w*2.0),(unsigned int)(h*2.0));
|
_cairoImage->create((unsigned int)(w*2.0),(unsigned int)(h*2.0));
|
||||||
|
|
||||||
osgVolume::clearImageToColor(this, _backgroundColor);
|
osg::clearImageToColor(this, _backgroundColor);
|
||||||
|
|
||||||
cairo_save(_cairoImage->getContext());
|
cairo_save(_cairoImage->getContext());
|
||||||
|
|
||||||
|
@ -9,7 +9,6 @@ SET(LIB_NAME osgVolume)
|
|||||||
SET(HEADER_PATH ${OpenSceneGraph_SOURCE_DIR}/include/${LIB_NAME})
|
SET(HEADER_PATH ${OpenSceneGraph_SOURCE_DIR}/include/${LIB_NAME})
|
||||||
SET(LIB_PUBLIC_HEADERS
|
SET(LIB_PUBLIC_HEADERS
|
||||||
${HEADER_PATH}/Export
|
${HEADER_PATH}/Export
|
||||||
${HEADER_PATH}/ImageUtils
|
|
||||||
${HEADER_PATH}/Version
|
${HEADER_PATH}/Version
|
||||||
${HEADER_PATH}/Volume
|
${HEADER_PATH}/Volume
|
||||||
${HEADER_PATH}/Locator
|
${HEADER_PATH}/Locator
|
||||||
@ -22,7 +21,6 @@ SET(LIB_PUBLIC_HEADERS
|
|||||||
ADD_LIBRARY(${LIB_NAME}
|
ADD_LIBRARY(${LIB_NAME}
|
||||||
${OPENSCENEGRAPH_USER_DEFINED_DYNAMIC_OR_STATIC}
|
${OPENSCENEGRAPH_USER_DEFINED_DYNAMIC_OR_STATIC}
|
||||||
${LIB_PUBLIC_HEADERS}
|
${LIB_PUBLIC_HEADERS}
|
||||||
ImageUtils.cpp
|
|
||||||
Version.cpp
|
Version.cpp
|
||||||
Volume.cpp
|
Volume.cpp
|
||||||
VolumeTechnique.cpp
|
VolumeTechnique.cpp
|
||||||
|
@ -35,9 +35,9 @@ VolumeTile::VolumeTile(const VolumeTile& volumeTile,const osg::CopyOp& copyop):
|
|||||||
_volume(0),
|
_volume(0),
|
||||||
_dirty(false),
|
_dirty(false),
|
||||||
_hasBeenTraversal(false),
|
_hasBeenTraversal(false),
|
||||||
_images(volumeTile._images)
|
_layers(volumeTile._layers)
|
||||||
{
|
{
|
||||||
if (volumeTile.getVolumeTechnique())
|
if (volumeTile.getVolumeTechnique()) ;
|
||||||
{
|
{
|
||||||
setVolumeTechnique(osg::clone(volumeTile.getVolumeTechnique()));
|
setVolumeTechnique(osg::clone(volumeTile.getVolumeTechnique()));
|
||||||
}
|
}
|
||||||
@ -48,6 +48,13 @@ VolumeTile::~VolumeTile()
|
|||||||
if (_volume) setVolume(0);
|
if (_volume) setVolume(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VolumeTile::setLayer(unsigned int i, Layer* layer)
|
||||||
|
{
|
||||||
|
if (_layers.size() <= i) _layers.resize(i+1);
|
||||||
|
|
||||||
|
_layers[i] = layer;
|
||||||
|
}
|
||||||
|
|
||||||
void VolumeTile::setVolume(Volume* volume)
|
void VolumeTile::setVolume(Volume* volume)
|
||||||
{
|
{
|
||||||
if (_volume == volume) return;
|
if (_volume == volume) return;
|
||||||
|
@ -30,6 +30,11 @@ BEGIN_OBJECT_REFLECTOR(osgVolume::Locator)
|
|||||||
I_Constructor0(____Locator,
|
I_Constructor0(____Locator,
|
||||||
"",
|
"",
|
||||||
"");
|
"");
|
||||||
|
I_Constructor1(IN, const osg::Matrixd &, transform,
|
||||||
|
Properties::NON_EXPLICIT,
|
||||||
|
____Locator__C5_osg_Matrixd_R1,
|
||||||
|
"",
|
||||||
|
"");
|
||||||
I_ConstructorWithDefaults2(IN, const osgVolume::Locator &, locator, , IN, const osg::CopyOp &, copyop, osg::CopyOp::SHALLOW_COPY,
|
I_ConstructorWithDefaults2(IN, const osgVolume::Locator &, locator, , IN, const osg::CopyOp &, copyop, osg::CopyOp::SHALLOW_COPY,
|
||||||
____Locator__C5_Locator_R1__C5_osg_CopyOp_R1,
|
____Locator__C5_Locator_R1__C5_osg_CopyOp_R1,
|
||||||
"Copy constructor using CopyOp to manage deep vs shallow copy. ",
|
"Copy constructor using CopyOp to manage deep vs shallow copy. ",
|
||||||
|
@ -12,10 +12,10 @@
|
|||||||
|
|
||||||
#include <osg/BoundingSphere>
|
#include <osg/BoundingSphere>
|
||||||
#include <osg/CopyOp>
|
#include <osg/CopyOp>
|
||||||
#include <osg/Image>
|
|
||||||
#include <osg/Matrix>
|
|
||||||
#include <osg/NodeVisitor>
|
#include <osg/NodeVisitor>
|
||||||
#include <osg/Object>
|
#include <osg/Object>
|
||||||
|
#include <osgVolume/Layer>
|
||||||
|
#include <osgVolume/Locator>
|
||||||
#include <osgVolume/Volume>
|
#include <osgVolume/Volume>
|
||||||
#include <osgVolume/VolumeTechnique>
|
#include <osgVolume/VolumeTechnique>
|
||||||
#include <osgVolume/VolumeTile>
|
#include <osgVolume/VolumeTile>
|
||||||
@ -123,34 +123,44 @@ BEGIN_OBJECT_REFLECTOR(osgVolume::VolumeTile)
|
|||||||
__C5_TileID_R1__getTileID,
|
__C5_TileID_R1__getTileID,
|
||||||
"Get the TileID (layer, x,y,z) of the VolumeTile. ",
|
"Get the TileID (layer, x,y,z) of the VolumeTile. ",
|
||||||
"");
|
"");
|
||||||
I_Method1(void, setLocator, IN, osg::RefMatrix *, locator,
|
I_Method1(void, setLocator, IN, osgVolume::Locator *, locator,
|
||||||
Properties::NON_VIRTUAL,
|
Properties::NON_VIRTUAL,
|
||||||
__void__setLocator__osg_RefMatrix_P1,
|
__void__setLocator__Locator_P1,
|
||||||
"",
|
"",
|
||||||
"");
|
"");
|
||||||
I_Method0(osg::RefMatrix *, getLocator,
|
I_Method0(osgVolume::Locator *, getLocator,
|
||||||
Properties::NON_VIRTUAL,
|
Properties::NON_VIRTUAL,
|
||||||
__osg_RefMatrix_P1__getLocator,
|
__Locator_P1__getLocator,
|
||||||
"",
|
"",
|
||||||
"");
|
"");
|
||||||
I_Method0(const osg::RefMatrix *, getLocator,
|
I_Method0(const osgVolume::Locator *, getLocator,
|
||||||
Properties::NON_VIRTUAL,
|
Properties::NON_VIRTUAL,
|
||||||
__C5_osg_RefMatrix_P1__getLocator,
|
__C5_Locator_P1__getLocator,
|
||||||
"",
|
"",
|
||||||
"");
|
"");
|
||||||
I_Method2(void, setImage, IN, unsigned int, i, IN, osg::Image *, image,
|
I_Method2(void, setLayer, IN, unsigned int, i, IN, osgVolume::Layer *, layer,
|
||||||
Properties::NON_VIRTUAL,
|
Properties::NON_VIRTUAL,
|
||||||
__void__setImage__unsigned_int__osg_Image_P1,
|
__void__setLayer__unsigned_int__Layer_P1,
|
||||||
"",
|
"",
|
||||||
"");
|
"");
|
||||||
I_Method1(osg::Image *, getImage, IN, unsigned int, i,
|
I_Method1(osgVolume::Layer *, getLayer, IN, unsigned int, i,
|
||||||
Properties::NON_VIRTUAL,
|
Properties::NON_VIRTUAL,
|
||||||
__osg_Image_P1__getImage__unsigned_int,
|
__Layer_P1__getLayer__unsigned_int,
|
||||||
"",
|
"",
|
||||||
"");
|
"");
|
||||||
I_Method1(const osg::Image *, getImage, IN, unsigned int, i,
|
I_Method1(const osgVolume::Layer *, getImage, IN, unsigned int, i,
|
||||||
Properties::NON_VIRTUAL,
|
Properties::NON_VIRTUAL,
|
||||||
__C5_osg_Image_P1__getImage__unsigned_int,
|
__C5_Layer_P1__getImage__unsigned_int,
|
||||||
|
"",
|
||||||
|
"");
|
||||||
|
I_Method1(void, addLayer, IN, osgVolume::Layer *, layer,
|
||||||
|
Properties::NON_VIRTUAL,
|
||||||
|
__void__addLayer__Layer_P1,
|
||||||
|
"",
|
||||||
|
"");
|
||||||
|
I_Method0(unsigned int, getNumLayers,
|
||||||
|
Properties::NON_VIRTUAL,
|
||||||
|
__unsigned_int__getNumLayers,
|
||||||
"",
|
"",
|
||||||
"");
|
"");
|
||||||
I_Method1(void, setVolumeTechnique, IN, osgVolume::VolumeTechnique *, VolumeTechnique,
|
I_Method1(void, setVolumeTechnique, IN, osgVolume::VolumeTechnique *, VolumeTechnique,
|
||||||
@ -186,13 +196,16 @@ BEGIN_OBJECT_REFLECTOR(osgVolume::VolumeTile)
|
|||||||
I_SimpleProperty(bool, Dirty,
|
I_SimpleProperty(bool, Dirty,
|
||||||
__bool__getDirty,
|
__bool__getDirty,
|
||||||
__void__setDirty__bool);
|
__void__setDirty__bool);
|
||||||
I_IndexedProperty(osg::Image *, Image,
|
I_ArrayProperty(osgVolume::Layer *, Layer,
|
||||||
__osg_Image_P1__getImage__unsigned_int,
|
__Layer_P1__getLayer__unsigned_int,
|
||||||
__void__setImage__unsigned_int__osg_Image_P1,
|
__void__setLayer__unsigned_int__Layer_P1,
|
||||||
|
__unsigned_int__getNumLayers,
|
||||||
|
__void__addLayer__Layer_P1,
|
||||||
|
0,
|
||||||
0);
|
0);
|
||||||
I_SimpleProperty(osg::RefMatrix *, Locator,
|
I_SimpleProperty(osgVolume::Locator *, Locator,
|
||||||
__osg_RefMatrix_P1__getLocator,
|
__Locator_P1__getLocator,
|
||||||
__void__setLocator__osg_RefMatrix_P1);
|
__void__setLocator__Locator_P1);
|
||||||
I_SimpleProperty(const osgVolume::TileID &, TileID,
|
I_SimpleProperty(const osgVolume::TileID &, TileID,
|
||||||
__C5_TileID_R1__getTileID,
|
__C5_TileID_R1__getTileID,
|
||||||
__void__setTileID__C5_TileID_R1);
|
__void__setTileID__C5_TileID_R1);
|
||||||
|
Loading…
Reference in New Issue
Block a user