36 #include <vtkImageData.h>
52 mMaxRenderSize = 10 * pow(10.0,6);
91 mMaxRenderSize = voxels;
93 mMaxRenderSize = 10 * pow(10.0,6);
95 this->updateRepsInView();
100 return mMaxRenderSize;
105 mVisualizerType = type;
107 this->updateRepsInView();
110 bool MultiVolume3DRepProducer::contains(
ImagePtr image)
const
112 if (std::count(m2DImages.begin(), m2DImages.end(), image))
114 if (std::count(m3DImages.begin(), m3DImages.end(), image))
121 if (this->contains(image))
126 connect(image.get(), SIGNAL(clipPlanesChanged()),
this, SIGNAL(
imagesChanged()));
127 connect(image.get(), SIGNAL(cropBoxChanged()),
this, SIGNAL(
imagesChanged()));
132 if(this->is2DImage(image))
133 m2DImages.push_back(image);
135 m3DImages.push_back(image);
138 this->updateRepsInView();
144 removedImage = this->removeImageFromVector(uid, m2DImages);
146 removedImage = this->removeImageFromVector(uid, m3DImages);
150 disconnect(removedImage.get(), SIGNAL(clipPlanesChanged()),
this, SIGNAL(
imagesChanged()));
151 disconnect(removedImage.get(), SIGNAL(cropBoxChanged()),
this, SIGNAL(
imagesChanged()));
155 this->updateRepsInView();
158 ImagePtr MultiVolume3DRepProducer::removeImageFromVector(QString uid, std::vector<ImagePtr> &images)
161 for (
unsigned i=0; i<images.size(); ++i)
163 if (images[i]->getUid()!=uid)
166 images.erase(images.begin()+i);
177 void MultiVolume3DRepProducer::updateRepsInView()
183 void MultiVolume3DRepProducer::clearReps()
194 for (
unsigned i=0; i<mReps.size(); ++i)
195 mView->removeRep(mReps[i]);
198 void MultiVolume3DRepProducer::fillReps()
201 this->addRepsToView();
204 void MultiVolume3DRepProducer::addRepsToView()
209 for (
unsigned i=0; i<mReps.size(); ++i)
210 mView->addRep(mReps[i]);
213 void MultiVolume3DRepProducer::rebuildReps()
215 if(!m2DImages.empty())
216 this->rebuild2DReps();
217 if(!m3DImages.empty())
218 this->rebuild3DReps();
221 void MultiVolume3DRepProducer::rebuild2DReps()
223 for (
unsigned i=0; i<m2DImages.size(); ++i)
224 this->buildSscImage2DRep3D(m2DImages[i]);
227 void MultiVolume3DRepProducer::rebuild3DReps()
229 if (this->isSingleVolumeRenderer())
231 for (
unsigned i=0; i<m3DImages.size(); ++i)
232 this->buildSingleVolumeRenderer(m3DImages[i]);
234 else if (mVisualizerType==
"vtkOpenGLGPUMultiVolumeRayCastMapper")
236 this->buildVtkOpenGLGPUMultiVolumeRayCastMapper();
240 reportError(QString(
"No visualizer found for string=%1").arg(mVisualizerType));
244 void MultiVolume3DRepProducer::buildVtkOpenGLGPUMultiVolumeRayCastMapper()
246 #ifdef CX_BUILD_MEHDI_VTKMULTIVOLUME
249 rep->setImages(m3DImages);
250 mReps.push_back(rep);
251 #endif //CX_BUILD_MEHDI_VTKMULTIVOLUME
254 bool MultiVolume3DRepProducer::is2DImage(
ImagePtr image)
const
257 return image->getBaseVtkImageData()->GetDimensions()[2]==1;
261 void MultiVolume3DRepProducer::buildSingleVolumeRenderer(
ImagePtr image)
263 if (mVisualizerType==
"vtkVolumeTextureMapper3D")
265 this->buildVtkVolumeTextureMapper3D(image);
267 else if (mVisualizerType==
"vtkGPUVolumeRayCastMapper")
269 this->buildVtkGPUVolumeRayCastMapper(image);
273 reportError(QString(
"No visualizer found for string=%1").arg(mVisualizerType));
278 bool MultiVolume3DRepProducer::isSingleVolumeRenderer()
const
280 QStringList singleTypes;
281 singleTypes <<
"vtkVolumeTextureMapper3D" <<
"vtkGPUVolumeRayCastMapper";
282 return singleTypes.count(mVisualizerType);
285 void MultiVolume3DRepProducer::buildSscImage2DRep3D(
ImagePtr image)
288 rep->setImage(image);
289 mReps.push_back(rep);
292 void MultiVolume3DRepProducer::buildVtkVolumeTextureMapper3D(
ImagePtr image)
298 rep->setUseVolumeTextureMapper();
301 rep->setImage(image);
302 mReps.push_back(rep);
305 void MultiVolume3DRepProducer::buildVtkGPUVolumeRayCastMapper(
ImagePtr image)
308 rep->setUseGPUVolumeRayCastMapper();
311 rep->setImage(image);
312 mReps.push_back(rep);
void reportError(QString msg)
void setMaxRenderSize(int voxels)
boost::shared_ptr< class Image > ImagePtr
void removeImage(QString uid)
boost::shared_ptr< class View > ViewPtr
void setView(ViewPtr view)
std::vector< RepPtr > getAllReps()
MultiVolume3DRepProducer()
boost::shared_ptr< class MehdiGPURayCastMultiVolumeRep > MehdiGPURayCastMultiVolumeRepPtr
void addImage(ImagePtr image)
boost::shared_ptr< class Image2DRep3D > Image2DRep3DPtr
void removeRepsFromView()
int getMaxRenderSize() const
void setVisualizerType(QString type)
static VolumetricRepPtr New(QString uid="")
static Image2DRep3DPtr New(QString uid="")
boost::shared_ptr< class VolumetricRep > VolumetricRepPtr
~MultiVolume3DRepProducer()