Commit 396c3ddb authored by David Gobbi's avatar David Gobbi
Browse files

PERF: update PolyDataToImageStencil with a faster, more robust algorithm

parent e1fcbdba
This diff is collapsed.
......@@ -12,36 +12,62 @@
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkPolyDataToImageStencil - clip an image with polydata
// .SECTION Description
// vtkPolyDataToImageStencil will convert a vtkPolyData into an image
// that can be used with vtkImageStencil or other vtk classes that apply
// a stencil to an image.
// .SECTION see also
// vtkPolyData vtkImageStencil vtkImplicitFunctionToImageStencil
/*=========================================================================
Copyright (c) 2004 Atamai, Inc.
Use, modification and redistribution of the software, in source or
binary forms, are permitted provided that the following terms and
conditions are met:
1) Redistribution of the source code, in verbatim or modified
form, must retain the above copyright notice, this license,
the following disclaimer, and any notices that refer to this
license and/or the following disclaimer.
2) Redistribution in binary form must include the above copyright
notice, a copy of this license and the following disclaimer
in the documentation or with other materials provided with the
distribution.
3) Modified copies of the source code must be clearly marked as such,
and must not be misrepresented as verbatim copies of the source code.
THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS"
WITHOUT EXPRESSED OR IMPLIED WARRANTY INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. IN NO EVENT SHALL ANY COPYRIGHT HOLDER OR OTHER PARTY WHO MAY
MODIFY AND/OR REDISTRIBUTE THE SOFTWARE UNDER THE TERMS OF THIS LICENSE
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, LOSS OF DATA OR DATA BECOMING INACCURATE
OR LOSS OF PROFIT OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF
THE USE OR INABILITY TO USE THE SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
=========================================================================*/
// .NAME vtkPolyDataToImageStencil
#ifndef __vtkPolyDataToImageStencil_h
#define __vtkPolyDataToImageStencil_h
#include "vtkImageStencilSource.h"
#include "vtkPolyData.h"
class vtkPolyData;
class vtkOBBTree;
class vtkMergePoints;
class vtkImageData;
class VTK_HYBRID_EXPORT vtkPolyDataToImageStencil : public vtkImageStencilSource
class VTK_EXPORT vtkPolyDataToImageStencil : public vtkImageStencilSource
{
public:
static vtkPolyDataToImageStencil *New();
vtkTypeRevisionMacro(vtkPolyDataToImageStencil, vtkImageStencilSource);
static vtkPolyDataToImageStencil* New();
vtkTypeMacro(vtkPolyDataToImageStencil, vtkImageStencilSource);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Specify the polydata to convert into a stencil.
virtual void SetInput(vtkPolyData *input);
virtual vtkPolyData *GetInput();
// Specify the implicit function to convert into a stencil.
virtual void SetInput(vtkPolyData*);
vtkPolyData *GetInput();
// Description:
// Set a vtkImageData that has the Spacing, Origin, and
// WholeExtent that will be used for the stencil. This
......@@ -75,21 +101,26 @@ public:
vtkGetVector6Macro(OutputWholeExtent, int);
// Description:
// Set the tolerance for doing spatial searches of the polydata.
vtkSetMacro(Tolerance, double);
vtkGetMacro(Tolerance, double);
// Obsolete methods. The tolerance was used by an earlier version of
// this class.
VTK_LEGACY(virtual void SetTolerance(double tolerance));
VTK_LEGACY(virtual double GetTolerance());
protected:
vtkPolyDataToImageStencil();
~vtkPolyDataToImageStencil();
void ThreadedExecute(vtkImageStencilData *output,
int extent[6], int threadId);
static void DataSetCutter(vtkDataSet *input, vtkPolyData *output,
double z, vtkMergePoints *locator);
virtual int RequestData(vtkInformation *, vtkInformationVector **,
vtkInformationVector *);
virtual int RequestInformation(vtkInformation *, vtkInformationVector **,
vtkInformationVector *);
double Tolerance;
vtkOBBTree *OBBTree;
virtual int FillInputPortInformation(int, vtkInformation*);
// Description:
// Set in subclasses where the primary input is not a vtkImageData.
......@@ -101,8 +132,10 @@ protected:
double OutputOrigin[3];
double OutputSpacing[3];
virtual void ReportReferences(vtkGarbageCollector*);
virtual int FillInputPortInformation(int, vtkInformation*);
#ifndef VTK_LEGACY_REMOVE
double Tolerance;
#endif /* VTK_LEGACY_REMOVE */
private:
vtkPolyDataToImageStencil(const vtkPolyDataToImageStencil&); // Not implemented.
void operator=(const vtkPolyDataToImageStencil&); // Not implemented.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment