File: vtkImageStencilDataFlip.h

package info (click to toggle)
volview 3.4-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 25,204 kB
  • sloc: cpp: 132,585; ansic: 11,612; tcl: 236; sh: 64; makefile: 25; xml: 8
file content (112 lines) | stat: -rw-r--r-- 4,553 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*=========================================================================

  Copyright (c) Kitware, Inc.
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/VolViewCopyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/
// .NAME vtkImageStencilDataFlip  flips a vtkImageStencilData 
// 
// .SECTION Description
// vtkImageStencilDataFlip will create a stencil with complementary extents.
// 
// There are subtle differences between this class and just using a 
// 
// \code
// vtkImageStencilData->GetNextExtent (...,..., iter = -1)
// \endcode
// 
// This class can return an inverted stencil with much larger extents than 
// the one specified.  
//
// .SECTION Motivation
// This class was written as one of a collection of classes intented for contour
// segmentation. The user would draw a contour and the contour would be 
// rasterized. The rasterization was done only within the extents of the 
// contour, to save time. The rasterization resulted in a \c vtkImageStencilData
// with extents the same as the contour. We then needed a class that could 
// conveniently flip stencils to give us the the regions outside the contour,
// (since a segmentation might cut away or cut everything but the contour).
// The stencil needed to be flipped not with respect to the extents of the 
// stencil data itself, but with respect to the extents of the image, (the 
// extents of the image can be much larger than the one of the contour).
// 
// .SECTION Parameters and Usage
// There are 2 ways to use this class.
//
// 1. To flip a vtkImageStencilData
// \code
// myvtkImageStencilDataFlip->SetInput( myvtkImageStencilData );
// myvtkImageStencilDataFlip->Update();
// myFlippedStencilData = myvtkImageStencilDataFlip->GetOutput();
// \endcode
//
// 2. To flip with respect to a larger extent. 
// \code
// myvtkImageStencilDataFlip->SetInput( myvtkImageStencilData );
// myvtkImageStencilDataFlip->SetFlipExtent(sliceExtent);
// myvtkImageStencilDataFlip->Update();
// myFlippedStencilData = myvtkImageStencilDataFlip->GetOutput();
// \endcode
//
#ifndef __vtkImageStencilDataFlip_h
#define __vtkImageStencilDataFlip_h

#include "vtkImageStencilSource.h"

class VTK_EXPORT vtkImageStencilDataFlip : public vtkImageStencilSource
{
public:
  static vtkImageStencilDataFlip *New();
  vtkTypeRevisionMacro( vtkImageStencilDataFlip, vtkImageStencilSource );
  void PrintSelf(ostream &os, vtkIndent indent);

  // Description:
  // Specify the stencil data to invert
  void SetInput(vtkImageStencilData *input);
  vtkImageStencilData *GetInput();

  // Description:
  // Optionally you may specify extents that are larger than the current 
  // extents of the stencil. (Repeat LARGER, no checking is performed to 
  // ensure this). If this is done, the stencil will be flipped with 
  // respect to these extents. (The extents computed are such that anything 
  // outside the stencil or outside the extents of the stencilData set as 
  // input via SetInput() is 1. Everything within the stencil is 0). If no
  // extents are set, the extents of the stencil are used.
  vtkSetVector6Macro(FlipExtent, int);  
  vtkGetVector6Macro(FlipExtent, int);

protected:
  vtkImageStencilDataFlip();
  ~vtkImageStencilDataFlip();

  virtual int RequestData(vtkInformation *, vtkInformationVector **, 
                                            vtkInformationVector *);

  // The input extent is the same as the one for the stencil data. The ouptut
  // extent should not always be copied to the input. The output extent will 
  // be the FlipExtent if one is specified; if not specified, it will be the
  // same as the input stencil
  virtual int RequestUpdateExtent (vtkInformation *, vtkInformationVector **, 
                                                     vtkInformationVector *);
  virtual int RequestInformation( vtkInformation *, vtkInformationVector **, 
                                         vtkInformationVector *outputVector);
  
  // Specify explicitly that we can handle only ImageStencilData as input.
  virtual int FillInputPortInformation(int, vtkInformation*);

  int FlipExtent[6];
   
private:
  vtkImageStencilDataFlip(const vtkImageStencilDataFlip&);  // Not implemented.
  void operator=(const vtkImageStencilDataFlip&);  // Not implemented.

};

#endif