VTK  9.3.1
vtkSimple2DLayoutStrategy.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-FileCopyrightText: Copyright 2008 Sandia Corporation
3 // SPDX-License-Identifier: LicenseRef-BSD-3-Clause-Sandia-USGov
25 #ifndef vtkSimple2DLayoutStrategy_h
26 #define vtkSimple2DLayoutStrategy_h
27 
28 #include "vtkGraphLayoutStrategy.h"
29 #include "vtkInfovisLayoutModule.h" // For export macro
30 
31 VTK_ABI_NAMESPACE_BEGIN
32 class vtkFloatArray;
33 
34 class VTKINFOVISLAYOUT_EXPORT vtkSimple2DLayoutStrategy : public vtkGraphLayoutStrategy
35 {
36 public:
38 
40  void PrintSelf(ostream& os, vtkIndent indent) override;
41 
43 
48  vtkSetClampMacro(RandomSeed, int, 0, VTK_INT_MAX);
49  vtkGetMacro(RandomSeed, int);
51 
53 
61  vtkSetClampMacro(MaxNumberOfIterations, int, 0, VTK_INT_MAX);
62  vtkGetMacro(MaxNumberOfIterations, int);
64 
66 
73  vtkSetClampMacro(IterationsPerLayout, int, 0, VTK_INT_MAX);
74  vtkGetMacro(IterationsPerLayout, int);
76 
78 
84  vtkSetClampMacro(InitialTemperature, float, 0.0, VTK_FLOAT_MAX);
85  vtkGetMacro(InitialTemperature, float);
87 
89 
97  vtkSetClampMacro(CoolDownRate, double, 0.01, VTK_DOUBLE_MAX);
98  vtkGetMacro(CoolDownRate, double);
100 
102 
109  vtkSetMacro(Jitter, bool);
110  vtkGetMacro(Jitter, bool);
112 
114 
118  vtkSetMacro(RestDistance, float);
119  vtkGetMacro(RestDistance, float);
121 
126  void Initialize() override;
127 
135  void Layout() override;
136 
141  int IsLayoutComplete() override { return this->LayoutComplete; }
142 
143 protected:
145  ~vtkSimple2DLayoutStrategy() override;
146 
147  int MaxNumberOfIterations; // Maximum number of iterations.
149  float CoolDownRate; // Cool-down rate. Note: Higher # = Slower rate.
150 
151 private:
152  // An edge consists of two vertices joined together.
153  // This struct acts as a "pointer" to those two vertices.
154  struct vtkLayoutEdge_t
155  {
156  vtkIdType from;
157  vtkIdType to;
158  float weight;
159  };
160  using vtkLayoutEdge = struct vtkLayoutEdge_t;
161 
162  // These are for storage of repulsion and attraction
163  vtkFloatArray* RepulsionArray;
164  vtkFloatArray* AttractionArray;
165  vtkLayoutEdge* EdgeArray;
166 
167  int RandomSeed;
168  int IterationsPerLayout;
169  int TotalIterations;
170  int LayoutComplete;
171  float Temp;
172  float RestDistance;
173  bool Jitter;
174 
176  void operator=(const vtkSimple2DLayoutStrategy&) = delete;
177 };
178 
179 VTK_ABI_NAMESPACE_END
180 #endif
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
#define VTK_DOUBLE_MAX
Definition: vtkType.h:154
#define VTK_INT_MAX
Definition: vtkType.h:144
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:30
int vtkIdType
Definition: vtkType.h:315
int IsLayoutComplete() override
I'm an iterative layout so this method lets the caller know if I'm done laying out the graph...
a simple 2D graph layout
abstract superclass for all graph layout strategies
#define VTK_FLOAT_MAX
Definition: vtkType.h:152
a simple class to control print indentation
Definition: vtkIndent.h:28
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
virtual void Initialize()
This method allows the layout strategy to do initialization of data structures or whatever else it mi...
virtual void Layout()=0
This is the layout method where the graph that was set in SetGraph() is laid out. ...