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(image && image->is2D())
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 void MultiVolume3DRepProducer::buildSingleVolumeRenderer(
ImagePtr image)
256 if (mVisualizerType==
"vtkVolumeTextureMapper3D")
258 this->buildVtkVolumeTextureMapper3D(image);
260 else if (mVisualizerType==
"vtkGPUVolumeRayCastMapper")
262 this->buildVtkGPUVolumeRayCastMapper(image);
266 reportError(QString(
"No visualizer found for string=%1").arg(mVisualizerType));
271 bool MultiVolume3DRepProducer::isSingleVolumeRenderer()
const 273 QStringList singleTypes;
274 singleTypes <<
"vtkVolumeTextureMapper3D" <<
"vtkGPUVolumeRayCastMapper";
275 return singleTypes.count(mVisualizerType);
278 void MultiVolume3DRepProducer::buildSscImage2DRep3D(
ImagePtr image)
281 rep->setImage(image);
282 mReps.push_back(rep);
285 void MultiVolume3DRepProducer::buildVtkVolumeTextureMapper3D(
ImagePtr image)
291 rep->setUseVolumeTextureMapper();
294 rep->setImage(image);
295 mReps.push_back(rep);
298 void MultiVolume3DRepProducer::buildVtkGPUVolumeRayCastMapper(
ImagePtr image)
301 rep->setUseGPUVolumeRayCastMapper();
304 rep->setImage(image);
305 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.