14 #include <vtkImageShrink3D.h> 15 #include <vtkMarchingCubes.h> 16 #include <vtkWindowedSincPolyDataFilter.h> 17 #include <vtkTriangleFilter.h> 18 #include <vtkDecimatePro.h> 19 #include <vtkPolyDataNormals.h> 20 #include <vtkImageData.h> 50 return "contour_filter";
57 "<p><i>Find the surface of a binary volume using marching cubes.</i></p>" 58 "<p>- Optional factor 2 reduction</p>" 59 "<p>- Marching Cubes contouring</p>" 60 "<p>- Optional Windowed Sinc smoothing</p>" 61 "<p>- Decimation of triangles</p>" 73 "Reduce input volumes resolution by a factor of 2 in all directions.",
false, root);
79 "Smooth the output contour",
true, root);
85 "Preserve mesh topology during reduction",
true, root);
91 "Values from this threshold and above will be included",
100 "Reduce number of triangles in output surface",
102 retval->setInternal2Display(100);
109 "Color of output model.",
110 QColor(
"green"), root);
119 connect(mSurfaceThresholdOption.get(), SIGNAL(
changed()),
this, SLOT(thresholdSlot()));
134 temp->setValueName(
"Input");
135 temp->setHelp(
"Select image input for contouring");
136 connect(temp.get(), SIGNAL(dataChanged(QString)),
this, SLOT(imageChangedSlot(QString)));
145 temp->setValueName(
"Output");
146 temp->setHelp(
"Output contour");
158 void ContourFilter::stopPreview()
161 mPreviewImage->stopThresholdPreview();
162 mPreviewImage.reset();
165 void ContourFilter::imageChangedSlot(QString uid)
175 image->getBaseVtkImageData()->GetExtent(extent);
176 mReduceResolutionOption->setHelp(
"Current input resolution: " +
qstring_cast(extent[1])
182 void ContourFilter::thresholdSlot()
186 mPreviewImage = boost::dynamic_pointer_cast<
Image>(
mInputTypes[0]->getData());
189 Eigen::Vector2d threshold = Eigen::Vector2d(mSurfaceThresholdOption->getValue(), mPreviewImage->getMax());
190 mPreviewImage->startThresholdPreview(threshold);
217 mRawResult = this->
execute(input->getBaseVtkImageData(),
218 surfaceThresholdOption->getValue(),
219 reduceResolutionOption->getValue(),
220 smoothingOption->getValue(),
221 preserveTopologyOption->getValue(),
222 decimationOption->getValue());
228 bool reduceResolution,
230 bool preserveTopology,
241 shrinker->SetInputData(input);
242 shrinker->SetShrinkFactors(2,2,2);
249 convert->SetInputConnection(shrinker->GetOutputPort());
251 convert->SetInputData(input);
253 convert->SetValue(0, threshold);
265 smoother->SetInputData(cubesPolyData);
266 smoother->SetNumberOfIterations(15);
267 smoother->SetBoundarySmoothing(
false);
268 smoother->SetFeatureEdgeSmoothing(
false);
269 smoother->SetNormalizeCoordinates(
true);
270 smoother->SetFeatureAngle(120);
271 smoother->SetPassBand(0.3);
273 cubesPolyData = smoother->GetOutput();
282 if (decimation > 0.000001)
284 trifilt->SetInputData(cubesPolyData);
286 deci->SetInputConnection(trifilt->GetOutputPort());
287 deci->SetTargetReduction(decimation);
288 deci->SetPreserveTopology(preserveTopology);
291 cubesPolyData = deci->GetOutput();
294 normals->SetInputData(cubesPolyData);
297 cubesPolyData->DeepCopy(normals->GetOutput());
299 return cubesPolyData;
324 if (!contour || !base)
329 MeshPtr output = patient->createSpecificData<
Mesh>(uid, name);
334 output->get_rMd_History()->setRegistration(base->get_rMd());
335 output->get_rMd_History()->setParentSpace(base->getUid());
337 output->setColor(color);
339 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.