-
Notifications
You must be signed in to change notification settings - Fork 122
/
vtkSplatterPlotFactory.h
151 lines (115 loc) · 4.83 KB
/
vtkSplatterPlotFactory.h
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#ifndef MANTID_VATES_vtkSplatterPlotFactory_H_
#define MANTID_VATES_vtkSplatterPlotFactory_H_
#include "MantidAPI/IMDEventWorkspace.h"
#include "MantidAPI/IMDHistoWorkspace.h"
#include "MantidAPI/IMDNode.h"
#include "MantidMDEvents/MDEventFactory.h"
#include "MantidMDEvents/MDEventWorkspace.h"
#include "MantidVatesAPI/ThresholdRange.h"
#include "MantidVatesAPI/vtkDataSetFactory.h"
#include <vtkPoints.h>
#include <boost/shared_ptr.hpp>
using Mantid::MDEvents::MDEventWorkspace;
namespace Mantid
{
namespace VATES
{
/**
* Factory that creates a simple "splatter plot" data set composed of points
* of a selection of the events in a MDEventWorkspace.
*
* @date August 16, 2011
*
* Copyright © 2010 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge National Laboratory & European Spallation Source
*
* This file is part of Mantid.
*
* Mantid is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* Mantid is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* File change history is stored at: <https://github.com/mantidproject/mantid>
* Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class DLLExport vtkSplatterPlotFactory : public vtkDataSetFactory
{
public:
/// Constructor
vtkSplatterPlotFactory(ThresholdRange_scptr thresholdRange,
const std::string& scalarName,
const size_t numPoints = 150000,
const double percentToUse = 5.0);
/// Destructor
virtual ~vtkSplatterPlotFactory();
/// Factory Method. Should also handle delegation to successors.
virtual vtkDataSet* create(ProgressAction& progressUpdating) const;
/// Initalize with a target workspace.
virtual void initialize(Mantid::API::Workspace_sptr);
/// Get the name of the type.
virtual std::string getFactoryTypeName() const
{
return "vtkSplatterPlotFactory";
}
/// Set upper limit on the number of points that will be plotted
virtual void SetNumberOfPoints(size_t points);
/// Set percentage of boxes from which points will be plotted
virtual void SetPercentToUse(double percentToUse);
/// Set the time value.
void setTime(double timeStep);
private:
template<typename MDE, size_t nd>
void doCreate(typename MDEventWorkspace<MDE, nd>::sptr ws) const;
///Check if the MDHisto workspace is 3D or 4D in nature
bool doMDHisto4D(Mantid::API::IMDHistoWorkspace_sptr workspace) const;
/// Generate the vtkDataSet from the objects input MDHistoWorkspace
void doCreateMDHisto(Mantid::API::IMDHistoWorkspace_sptr workspace) const;
/// Set the signals and the valid points which are to be displayed
double extractScalarSignal(Mantid::API::IMDHistoWorkspace_sptr workspace,
bool do4D, const int x, const int y, const int z) const;
/// Set the points and point ids for a hexahedron structure.
void setPointsAndPointIdsForHex(vtkPoints* points,
std::vector<vtkIdType> &pointIDs,
Mantid::coord_t out[3],
double signalScalar,
Mantid::coord_t steps[3]) const;
/// Template Method pattern to validate the factory before use.
virtual void validate() const;
/// Threshold range strategy.
ThresholdRange_scptr m_thresholdRange;
/// Scalar name to provide on dataset.
const std::string m_scalarName;
/// Member workspace to generate vtkdataset from.
Mantid::API::IMDWorkspace_sptr m_workspace;
/// Approximate number of points to plot
size_t m_numPoints;
/// Size of the initial portion of the sorted list of boxes to use.
double m_percentToUse;
/// Flag indicating whether or not the sorted list must be built
mutable bool m_buildSortedList;
/// Save name of current workspace so we can re-sort if it changes
mutable std::string m_wsName;
/// Data set that will be generated
mutable vtkDataSet *dataSet;
/// We are slicing down from > 3 dimensions
mutable bool slice;
/// Mask for choosing along which dimensions to slice
mutable bool *sliceMask;
/// Implicit function to define which boxes to render.
mutable Mantid::Geometry::MDImplicitFunction *sliceImplicitFunction;
/// Variable to hold sorted list, so sort doesn't have to be repeated
mutable std::vector< Mantid::API::IMDNode * > m_sortedBoxes;
/// Time value.
double m_time;
};
}
}
#endif