1 /*========================================================================= 2 3 Program: Visualization Toolkit 4 Module: vtkGraphAnnotationLayersFilter.h 5 6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 7 All rights reserved. 8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 9 10 This software is distributed WITHOUT ANY WARRANTY; without even 11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 12 PURPOSE. See the above copyright notice for more information. 13 14 =========================================================================*/ 15 16 /** 17 * @class vtkGraphAnnotationLayersFilter 18 * @brief Produce filled convex hulls around 19 * subsets of vertices in a vtkGraph. 20 * 21 * 22 * Produces a vtkPolyData comprised of filled polygons of the convex hull 23 * of a cluster. Alternatively, you may choose to output bounding rectangles. 24 * Clusters with fewer than three vertices are artificially expanded to 25 * ensure visibility (see vtkConvexHull2D). 26 * 27 * The first input is a vtkGraph with points, possibly set by 28 * passing the graph through vtkGraphLayout (z-values are ignored). The second 29 * input is a vtkAnnotationsLayer containing vtkSelectionNodeS of vertex 30 * ids (the 'clusters' output of vtkTulipReader for example). 31 * 32 * Setting OutlineOn() additionally produces outlines of the clusters on 33 * output port 1. 34 * 35 * Three arrays are added to the cells of the output: "Hull id"; "Hull name"; 36 * and "Hull color". 37 * 38 * Note: This filter operates in the x,y-plane and as such works best with an 39 * interactor style that does not allow camera rotation, such as 40 * vtkInteractorStyleRubberBand2D. 41 * 42 * @sa 43 * vtkContext2D 44 * 45 * @par Thanks: 46 * Thanks to Colin Myers, University of Leeds for providing this implementation. 47 */ 48 49 #ifndef vtkGraphAnnotationLayersFilter_h 50 #define vtkGraphAnnotationLayersFilter_h 51 52 #include "vtkPolyDataAlgorithm.h" 53 #include "vtkRenderingAnnotationModule.h" // For export macro 54 #include "vtkSmartPointer.h" // needed for ivars 55 56 class vtkAppendPolyData; 57 class vtkConvexHull2D; 58 class vtkRenderer; 59 60 class VTKRENDERINGANNOTATION_EXPORT vtkGraphAnnotationLayersFilter : public vtkPolyDataAlgorithm 61 { 62 public: 63 static vtkGraphAnnotationLayersFilter* New(); 64 vtkTypeMacro(vtkGraphAnnotationLayersFilter, vtkPolyDataAlgorithm); 65 void PrintSelf(ostream& os, vtkIndent indent) override; 66 67 ///@{ 68 /** 69 * Produce outlines of the hulls on output port 1. 70 */ 71 void OutlineOn(); 72 void OutlineOff(); 73 void SetOutline(bool b); 74 ///@} 75 76 /** 77 * Scale each hull by the amount specified. Defaults to 1.0. 78 */ 79 void SetScaleFactor(double scale); 80 81 /** 82 * Set the shape of the hulls to bounding rectangle. 83 */ 84 void SetHullShapeToBoundingRectangle(); 85 86 /** 87 * Set the shape of the hulls to convex hull. Default. 88 */ 89 void SetHullShapeToConvexHull(); 90 91 /** 92 * Set the minimum x,y-dimensions of each hull in world coordinates. Defaults 93 * to 1.0. Set to 0.0 to disable. 94 */ 95 void SetMinHullSizeInWorld(double size); 96 97 /** 98 * Set the minimum x,y-dimensions of each hull in pixels. You must also set a 99 * vtkRenderer. Defaults to 1. Set to 0 to disable. 100 */ 101 void SetMinHullSizeInDisplay(int size); 102 103 /** 104 * Renderer needed for MinHullSizeInDisplay calculation. Not reference counted. 105 */ 106 void SetRenderer(vtkRenderer* renderer); 107 108 /** 109 * The modified time of this filter. 110 */ 111 vtkMTimeType GetMTime() override; 112 113 protected: 114 vtkGraphAnnotationLayersFilter(); 115 ~vtkGraphAnnotationLayersFilter() override; 116 117 /** 118 * This is called by the superclass. This is the method you should override. 119 */ 120 int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override; 121 122 /** 123 * Set the input to vtkGraph and vtkAnnotationLayers. 124 */ 125 int FillInputPortInformation(int port, vtkInformation* info) override; 126 127 private: 128 vtkGraphAnnotationLayersFilter(const vtkGraphAnnotationLayersFilter&) = delete; 129 void operator=(const vtkGraphAnnotationLayersFilter&) = delete; 130 131 vtkSmartPointer<vtkAppendPolyData> HullAppend; 132 vtkSmartPointer<vtkAppendPolyData> OutlineAppend; 133 vtkSmartPointer<vtkConvexHull2D> ConvexHullFilter; 134 }; 135 136 #endif // vtkGraphAnnotationLayersFilter_h 137