35 #include <vtkImageShrink3D.h> 36 #include <vtkMarchingCubes.h> 37 #include <vtkWindowedSincPolyDataFilter.h> 38 #include <vtkTriangleFilter.h> 39 #include <vtkDecimatePro.h> 40 #include <vtkPolyDataNormals.h> 41 #include <vtkImageData.h> 71 return "contour_filter";
78 "<p><i>Find the surface of a binary volume using marching cubes.</i></p>" 79 "<p>- Optional factor 2 reduction</p>" 80 "<p>- Marching Cubes contouring</p>" 81 "<p>- Optional Windowed Sinc smoothing</p>" 82 "<p>- Decimation of triangles</p>" 94 "Reduce input volumes resolution by a factor of 2 in all directions.",
false, root);
100 "Smooth the output contour",
true, root);
106 "Preserve mesh topology during reduction",
true, root);
112 "Values from this threshold and above will be included",
121 "Reduce number of triangles in output surface",
123 retval->setInternal2Display(100);
130 "Color of output model.",
131 QColor(
"green"), root);
140 connect(mSurfaceThresholdOption.get(), SIGNAL(
changed()),
this, SLOT(thresholdSlot()));
155 temp->setValueName(
"Input");
156 temp->setHelp(
"Select image input for contouring");
157 connect(temp.get(), SIGNAL(dataChanged(QString)),
this, SLOT(imageChangedSlot(QString)));
166 temp->setValueName(
"Output");
167 temp->setHelp(
"Output contour");
179 void ContourFilter::stopPreview()
182 mPreviewImage->stopThresholdPreview();
183 mPreviewImage.reset();
186 void ContourFilter::imageChangedSlot(QString uid)
196 image->getBaseVtkImageData()->GetExtent(extent);
197 mReduceResolutionOption->setHelp(
"Current input resolution: " +
qstring_cast(extent[1])
203 void ContourFilter::thresholdSlot()
207 mPreviewImage = boost::dynamic_pointer_cast<
Image>(
mInputTypes[0]->getData());
210 Eigen::Vector2d threshold = Eigen::Vector2d(mSurfaceThresholdOption->getValue(), mPreviewImage->getMax());
211 mPreviewImage->startThresholdPreview(threshold);
238 mRawResult = this->
execute(input->getBaseVtkImageData(),
239 surfaceThresholdOption->getValue(),
240 reduceResolutionOption->getValue(),
241 smoothingOption->getValue(),
242 preserveTopologyOption->getValue(),
243 decimationOption->getValue());
249 bool reduceResolution,
251 bool preserveTopology,
262 shrinker->SetInputData(input);
263 shrinker->SetShrinkFactors(2,2,2);
270 convert->SetInputConnection(shrinker->GetOutputPort());
272 convert->SetInputData(input);
274 convert->SetValue(0, threshold);
286 smoother->SetInputData(cubesPolyData);
287 smoother->SetNumberOfIterations(15);
288 smoother->SetBoundarySmoothing(
false);
289 smoother->SetFeatureEdgeSmoothing(
false);
290 smoother->SetNormalizeCoordinates(
true);
291 smoother->SetFeatureAngle(120);
292 smoother->SetPassBand(0.3);
294 cubesPolyData = smoother->GetOutput();
303 if (decimation > 0.000001)
305 trifilt->SetInputData(cubesPolyData);
307 deci->SetInputConnection(trifilt->GetOutputPort());
308 deci->SetTargetReduction(decimation);
309 deci->SetPreserveTopology(preserveTopology);
312 cubesPolyData = deci->GetOutput();
315 normals->SetInputData(cubesPolyData);
318 cubesPolyData->DeepCopy(normals->GetOutput());
320 return cubesPolyData;
345 if (!contour || !base)
350 MeshPtr output = patient->createSpecificData<
Mesh>(uid, name);
355 output->get_rMd_History()->setRegistration(base->get_rMd());
356 output->get_rMd_History()->setParentSpace(base->getUid());
358 output->setColor(color);
360 patient->insertData(output);
QString qstring_cast(const T &val)
vtkSmartPointer< class vtkDecimatePro > vtkDecimateProPtr
static BoolPropertyPtr initialize(const QString &uid, QString name, QString help, bool value, QDomNode root=QDomNode())
std::vector< SelectDataStringPropertyBasePtr > mInputTypes
QDomElement mCopiedOptions
DoublePropertyPtr getSurfaceThresholdOption(QDomElement root)
vtkSmartPointer< class vtkMarchingCubes > vtkMarchingCubesPtr
boost::shared_ptr< class ColorProperty > ColorPropertyPtr
virtual void createOptions()
boost::shared_ptr< class VisServices > VisServicesPtr
virtual void setActive(bool on)
virtual bool preProcess()
Utility class for describing a bounded numeric range.
boost::shared_ptr< class Image > ImagePtr
vtkSmartPointer< class vtkWindowedSincPolyDataFilter > vtkWindowedSincPolyDataFilterPtr
ColorPropertyPtr getColorOption(QDomElement root)
BoolPropertyPtr getPreserveTopologyOption(QDomElement root)
std::vector< PropertyPtr > mOptionsAdapters
boost::shared_ptr< class SelectDataStringPropertyBase > SelectDataStringPropertyBasePtr
virtual void createInputTypes()
virtual QString getHelp() const
static QString getNameSuffix()
void setVtkPolyData(const vtkPolyDataPtr &polyData)
virtual QString getType() const
virtual void createOutputTypes()
BoolPropertyPtr getSmoothingOption(QDomElement root)
vtkSmartPointer< class vtkPolyDataNormals > vtkPolyDataNormalsPtr
DoublePropertyPtr getDecimationOption(QDomElement root)
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
ContourFilter(VisServicesPtr services)
vtkSmartPointer< class vtkTriangleFilter > vtkTriangleFilterPtr
vtkSmartPointer< class vtkImageShrink3D > vtkImageShrink3DPtr
ImagePtr getCopiedInputImage(int index=0)
virtual void setActive(bool on)
vtkSmartPointer< vtkPolyData > vtkPolyDataPtr
boost::shared_ptr< class DoubleProperty > DoublePropertyPtr
virtual QString getName() const
BoolPropertyPtr getReduceResolutionOption(QDomElement root)
std::vector< SelectDataStringPropertyBasePtr > mOutputTypes
static DoublePropertyPtr initialize(const QString &uid, QString name, QString help, double value, DoubleRange range, int decimals, QDomNode root=QDomNode())
static StringPropertySelectMeshPtr New(PatientModelServicePtr patientModelService)
virtual bool postProcess()
static StringPropertySelectImagePtr New(PatientModelServicePtr patientModelService)
static ColorPropertyPtr initialize(const QString &uid, QString name, QString help, QColor value, QDomNode root=QDomNode())
boost::shared_ptr< class BoolProperty > BoolPropertyPtr
boost::shared_ptr< class Mesh > MeshPtr
void updateThresholdFromImageChange(QString uid, DoublePropertyPtr threshold)
Namespace for all CustusX production code.