15 #include <vtkImageData.h> 31 mMaxRenderSize = 10 * pow(10.0,6);
70 mMaxRenderSize = voxels;
72 mMaxRenderSize = 10 * pow(10.0,6);
74 this->updateRepsInView();
79 return mMaxRenderSize;
84 mVisualizerType = type;
86 this->updateRepsInView();
89 bool MultiVolume3DRepProducer::contains(
ImagePtr image)
const 91 if (std::count(m2DImages.begin(), m2DImages.end(), image))
93 if (std::count(m3DImages.begin(), m3DImages.end(), image))
100 if (this->contains(image))
105 connect(image.get(), SIGNAL(clipPlanesChanged()),
this, SIGNAL(
imagesChanged()));
106 connect(image.get(), SIGNAL(cropBoxChanged()),
this, SIGNAL(
imagesChanged()));
111 if(image && image->is2D())
112 m2DImages.push_back(image);
114 m3DImages.push_back(image);
117 this->updateRepsInView();
123 removedImage = this->removeImageFromVector(uid, m2DImages);
125 removedImage = this->removeImageFromVector(uid, m3DImages);
129 disconnect(removedImage.get(), SIGNAL(clipPlanesChanged()),
this, SIGNAL(
imagesChanged()));
130 disconnect(removedImage.get(), SIGNAL(cropBoxChanged()),
this, SIGNAL(
imagesChanged()));
134 this->updateRepsInView();
137 ImagePtr MultiVolume3DRepProducer::removeImageFromVector(QString uid, std::vector<ImagePtr> &images)
140 for (
unsigned i=0; i<images.size(); ++i)
142 if (images[i]->getUid()!=uid)
145 images.erase(images.begin()+i);
156 void MultiVolume3DRepProducer::updateRepsInView()
162 void MultiVolume3DRepProducer::clearReps()
173 for (
unsigned i=0; i<mReps.size(); ++i)
174 mView->removeRep(mReps[i]);
177 void MultiVolume3DRepProducer::fillReps()
180 this->addRepsToView();
183 void MultiVolume3DRepProducer::addRepsToView()
188 for (
unsigned i=0; i<mReps.size(); ++i)
189 mView->addRep(mReps[i]);
192 void MultiVolume3DRepProducer::rebuildReps()
194 if(!m2DImages.empty())
195 this->rebuild2DReps();
196 if(!m3DImages.empty())
197 this->rebuild3DReps();
200 void MultiVolume3DRepProducer::rebuild2DReps()
202 for (
unsigned i=0; i<m2DImages.size(); ++i)
203 this->buildSscImage2DRep3D(m2DImages[i]);
206 void MultiVolume3DRepProducer::rebuild3DReps()
208 if (this->isSingleVolumeRenderer())
210 for (
unsigned i=0; i<m3DImages.size(); ++i)
211 this->buildSingleVolumeRenderer(m3DImages[i]);
213 else if (mVisualizerType==
"vtkOpenGLGPUMultiVolumeRayCastMapper")
215 this->buildVtkOpenGLGPUMultiVolumeRayCastMapper();
219 reportError(QString(
"No visualizer found for string=%1").arg(mVisualizerType));
223 void MultiVolume3DRepProducer::buildVtkOpenGLGPUMultiVolumeRayCastMapper()
225 #ifdef CX_BUILD_MEHDI_VTKMULTIVOLUME 228 rep->setImages(m3DImages);
229 mReps.push_back(rep);
230 #endif //CX_BUILD_MEHDI_VTKMULTIVOLUME 233 void MultiVolume3DRepProducer::buildSingleVolumeRenderer(
ImagePtr image)
235 if (mVisualizerType==
"vtkVolumeTextureMapper3D")
237 this->buildVtkVolumeTextureMapper3D(image);
239 else if (mVisualizerType==
"vtkGPUVolumeRayCastMapper")
241 this->buildVtkGPUVolumeRayCastMapper(image);
245 reportError(QString(
"No visualizer found for string=%1").arg(mVisualizerType));
250 bool MultiVolume3DRepProducer::isSingleVolumeRenderer()
const 252 QStringList singleTypes;
253 singleTypes <<
"vtkVolumeTextureMapper3D" <<
"vtkGPUVolumeRayCastMapper";
254 return singleTypes.count(mVisualizerType);
257 void MultiVolume3DRepProducer::buildSscImage2DRep3D(
ImagePtr image)
260 rep->setImage(image);
261 mReps.push_back(rep);
264 void MultiVolume3DRepProducer::buildVtkVolumeTextureMapper3D(
ImagePtr image)
270 rep->setUseVolumeTextureMapper();
273 rep->setImage(image);
274 mReps.push_back(rep);
277 void MultiVolume3DRepProducer::buildVtkGPUVolumeRayCastMapper(
ImagePtr image)
280 rep->setUseGPUVolumeRayCastMapper();
283 rep->setImage(image);
284 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()
Namespace for all CustusX production code.