Skip to content

Commit 19253de

Browse files
authored
simplify main classes to remove excess templating (#382)
1 parent 1da43a2 commit 19253de

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+630
-725
lines changed

include/polyscope/camera_view.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,11 @@ namespace polyscope {
1717
// Forward declare structure
1818
class CameraView;
1919

20-
/*
21-
// Forward declare quantity types (currently there are none)
22-
template <> // Specialize the quantity type
23-
struct QuantityTypeHelper<CameraView> {
24-
typedef CameraViewQuantity type;
25-
};
26-
*/
27-
2820
struct CameraViewPickResult {
2921
// currently nothing, just following the same pattern as other structures
3022
};
3123

32-
class CameraView : public QuantityStructure<CameraView> {
24+
class CameraView : public Structure {
3325
public:
3426
// === Member functions ===
3527

include/polyscope/color_bar.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ class ColorBar {
3232
Quantity& parent;
3333
std::pair<double, double> colormapRange; // in DATA values, not [0,1]
3434

35-
void exportColorbarToSVG(const std::string& filename);
35+
void exportColorbarToSVG(const std::string& filename);
3636

3737
// Getters and setters
3838

3939
void setOnscreenColorbarEnabled(bool newEnabled);
4040
bool getOnscreenColorbarEnabled();
41-
41+
4242
// Location in screen coords. (-1,-1), means "place automatically" (default)
4343
void setOnscreenColorbarLocation(glm::vec2 newScreenCoords);
4444
glm::vec2 getOnscreenColorbarLocation();

include/polyscope/color_image_quantity.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class ColorImageQuantity : public ImageQuantity {
2727

2828
// == Setters and getters
2929

30-
ColorImageQuantity* setEnabled(bool newEnabled) override;
30+
void setEnabled(bool newEnabled) override;
3131

3232
ColorImageQuantity* setIsPremultiplied(bool val);
3333
bool getIsPremultiplied();

include/polyscope/curve_network.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,13 @@ class CurveNetworkNodeVectorQuantity;
3131
class CurveNetworkEdgeVectorQuantity;
3232

3333

34-
template <> // Specialize the quantity type
35-
struct QuantityTypeHelper<CurveNetwork> {
36-
typedef CurveNetworkQuantity type;
37-
};
38-
3934
struct CurveNetworkPickResult {
4035
CurveNetworkElement elementType; // which kind of element did we click
4136
int64_t index; // index of the clicked element
4237
float tEdge = -1; // if the pick is an edge, the t-value in [0,1] along the edge
4338
};
4439

45-
class CurveNetwork : public QuantityStructure<CurveNetwork> {
40+
class CurveNetwork : public Structure {
4641
public:
4742
// === Member functions ===
4843

include/polyscope/curve_network_quantity.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77

88
namespace polyscope {
99

10-
// Forward declare
1110
class CurveNetwork;
1211

13-
// Extend Quantity<CurveNetwork>
14-
class CurveNetworkQuantity : public QuantityS<CurveNetwork> {
12+
class CurveNetworkQuantity : public Quantity {
1513
public:
1614
CurveNetworkQuantity(std::string name, CurveNetwork& parentStructure, bool dominates = false);
1715
virtual ~CurveNetworkQuantity() {};
1816

17+
CurveNetwork& parent; // shadows and hides the generic member in Quantity
18+
1919
// Build GUI info an element
2020
virtual void buildNodeInfoGUI(size_t vInd);
2121
virtual void buildEdgeInfoGUI(size_t fInd);

include/polyscope/floating_quantity.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ class FloatingQuantity : public Quantity {
1414
virtual ~FloatingQuantity() {};
1515

1616
virtual void buildUI() override;
17-
18-
virtual FloatingQuantity* setEnabled(bool newEnabled) = 0;
1917
};
2018

2119

include/polyscope/floating_quantity_structure.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class ScalarImageQuantity;
3131
class ColorImageQuantity;
3232

3333

34-
class FloatingQuantityStructure : public QuantityStructure<FloatingQuantityStructure> {
34+
class FloatingQuantityStructure : public Structure {
3535
public:
3636
// === Member functions ===
3737

include/polyscope/implicit_helpers.h

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ struct ImplicitRenderOpts {
7979

8080
// Populate the custom-filled entries of opts according to the policy above.
8181
template <class S>
82-
void resolveImplicitRenderOpts(QuantityStructure<S>* parent, ImplicitRenderOpts& opts);
82+
void resolveImplicitRenderOpts(S* parent, ImplicitRenderOpts& opts);
8383

8484
// === Depth/geometry/shape only render functions
8585

@@ -102,15 +102,13 @@ void resolveImplicitRenderOpts(QuantityStructure<S>* parent, ImplicitRenderOpts&
102102
// handles more general implicit functions. See the options struct for other options.
103103

104104
template <class Func, class S>
105-
DepthRenderImageQuantity* renderImplicitSurface(QuantityStructure<S>* parent, std::string name, Func&& func,
106-
ImplicitRenderMode mode,
105+
DepthRenderImageQuantity* renderImplicitSurface(S* parent, std::string name, Func&& func, ImplicitRenderMode mode,
107106
ImplicitRenderOpts opts = ImplicitRenderOpts());
108107
template <class Func>
109108
DepthRenderImageQuantity* renderImplicitSurface(std::string name, Func&& func, ImplicitRenderMode mode,
110109
ImplicitRenderOpts opts = ImplicitRenderOpts());
111110
template <class Func, class S>
112-
DepthRenderImageQuantity* renderImplicitSurfaceBatch(QuantityStructure<S>* parent, std::string name, Func&& func,
113-
ImplicitRenderMode mode,
111+
DepthRenderImageQuantity* renderImplicitSurfaceBatch(S* parent, std::string name, Func&& func, ImplicitRenderMode mode,
114112
ImplicitRenderOpts opts = ImplicitRenderOpts());
115113
template <class Func>
116114
DepthRenderImageQuantity* renderImplicitSurfaceBatch(std::string name, Func&& func, ImplicitRenderMode mode,
@@ -121,16 +119,16 @@ DepthRenderImageQuantity* renderImplicitSurfaceBatch(std::string name, Func&& fu
121119
// Like the implicit surface renderers above, but additionally take a color
122120

123121
template <class Func, class FuncColor, class S>
124-
ColorRenderImageQuantity* renderImplicitSurfaceColor(QuantityStructure<S>* parent, std::string name, Func&& func,
125-
FuncColor&& funcColor, ImplicitRenderMode mode,
122+
ColorRenderImageQuantity* renderImplicitSurfaceColor(S* parent, std::string name, Func&& func, FuncColor&& funcColor,
123+
ImplicitRenderMode mode,
126124
ImplicitRenderOpts opts = ImplicitRenderOpts());
127125
template <class Func, class FuncColor>
128126
ColorRenderImageQuantity* renderImplicitSurfaceColor(std::string name, Func&& func, FuncColor&& funcColor,
129127
ImplicitRenderMode mode,
130128
ImplicitRenderOpts opts = ImplicitRenderOpts());
131129

132130
template <class Func, class FuncColor, class S>
133-
ColorRenderImageQuantity* renderImplicitSurfaceColorBatch(QuantityStructure<S>* parent, std::string name, Func&& func,
131+
ColorRenderImageQuantity* renderImplicitSurfaceColorBatch(S* parent, std::string name, Func&& func,
134132
FuncColor&& funcColor, ImplicitRenderMode mode,
135133
ImplicitRenderOpts opts = ImplicitRenderOpts());
136134
template <class Func, class FuncColor>
@@ -143,17 +141,17 @@ ColorRenderImageQuantity* renderImplicitSurfaceColorBatch(std::string name, Func
143141
// Like the implicit surface renderers above, but additionally take a scalar and colormap it, etc
144142

145143
template <class Func, class FuncScalar, class S>
146-
ScalarRenderImageQuantity* renderImplicitSurfaceScalar(QuantityStructure<S>* parent, std::string name, Func&& func,
147-
FuncScalar&& funcScalar, ImplicitRenderMode mode,
148-
ImplicitRenderOpts opts = ImplicitRenderOpts(),
149-
DataType dataType = DataType::STANDARD);
144+
ScalarRenderImageQuantity*
145+
renderImplicitSurfaceScalar(S* parent, std::string name, Func&& func, FuncScalar&& funcScalar, ImplicitRenderMode mode,
146+
ImplicitRenderOpts opts = ImplicitRenderOpts(), DataType dataType = DataType::STANDARD);
147+
150148
template <class Func, class FuncScalar>
151149
ScalarRenderImageQuantity*
152150
renderImplicitSurfaceScalar(std::string name, Func&& func, FuncScalar&& funcScalar, ImplicitRenderMode mode,
153151
ImplicitRenderOpts opts = ImplicitRenderOpts(), DataType dataType = DataType::STANDARD);
154152

155153
template <class Func, class FuncScalar, class S>
156-
ScalarRenderImageQuantity* renderImplicitSurfaceScalarBatch(QuantityStructure<S>* parent, std::string name, Func&& func,
154+
ScalarRenderImageQuantity* renderImplicitSurfaceScalarBatch(S* parent, std::string name, Func&& func,
157155
FuncScalar&& funcScalar, ImplicitRenderMode mode,
158156
ImplicitRenderOpts opts = ImplicitRenderOpts(),
159157
DataType dataType = DataType::STANDARD);
@@ -169,7 +167,7 @@ ScalarRenderImageQuantity* renderImplicitSurfaceScalarBatch(std::string name, Fu
169167
// Whereas the other functions shade based on normals, this one just renders surface depth and color directly.
170168

171169
template <class Func, class FuncColor, class S>
172-
RawColorRenderImageQuantity* renderImplicitSurfaceRawColor(QuantityStructure<S>* parent, std::string name, Func&& func,
170+
RawColorRenderImageQuantity* renderImplicitSurfaceRawColor(S* parent, std::string name, Func&& func,
173171
FuncColor&& funcColor, ImplicitRenderMode mode,
174172
ImplicitRenderOpts opts = ImplicitRenderOpts());
175173
template <class Func, class FuncColor>
@@ -178,9 +176,9 @@ RawColorRenderImageQuantity* renderImplicitSurfaceRawColor(std::string name, Fun
178176
ImplicitRenderOpts opts = ImplicitRenderOpts());
179177

180178
template <class Func, class FuncColor, class S>
181-
RawColorRenderImageQuantity*
182-
renderImplicitSurfaceRawColorBatch(QuantityStructure<S>* parent, std::string name, Func&& func, FuncColor&& funcColor,
183-
ImplicitRenderMode mode, ImplicitRenderOpts opts = ImplicitRenderOpts());
179+
RawColorRenderImageQuantity* renderImplicitSurfaceRawColorBatch(S* parent, std::string name, Func&& func,
180+
FuncColor&& funcColor, ImplicitRenderMode mode,
181+
ImplicitRenderOpts opts = ImplicitRenderOpts());
184182
template <class Func, class FuncColor>
185183
RawColorRenderImageQuantity* renderImplicitSurfaceRawColorBatch(std::string name, Func&& func, FuncColor&& funcColor,
186184
ImplicitRenderMode mode,

include/polyscope/implicit_helpers.ipp

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
namespace polyscope {
1616

1717
template <class S>
18-
void resolveImplicitRenderOpts(QuantityStructure<S>* parent, ImplicitRenderOpts& opts) {
18+
void resolveImplicitRenderOpts(S* parent, ImplicitRenderOpts& opts) {
1919

2020
// see comment in the ImplicitRenderOpts struct for the logic that this function implements
2121

@@ -249,8 +249,8 @@ DepthRenderImageQuantity* renderImplicitSurfaceBatch(std::string name, Func&& fu
249249
}
250250

251251
template <class Func, class S>
252-
DepthRenderImageQuantity* renderImplicitSurface(QuantityStructure<S>* parent, std::string name, Func&& func,
253-
ImplicitRenderMode mode, ImplicitRenderOpts opts) {
252+
DepthRenderImageQuantity* renderImplicitSurface(S* parent, std::string name, Func&& func, ImplicitRenderMode mode,
253+
ImplicitRenderOpts opts) {
254254

255255
// Bootstrap on the batch version
256256
auto batchFunc = [&](const float* pos_ptr, float* result_ptr, size_t size) {
@@ -269,8 +269,8 @@ DepthRenderImageQuantity* renderImplicitSurface(QuantityStructure<S>* parent, st
269269

270270

271271
template <class Func, class S>
272-
DepthRenderImageQuantity* renderImplicitSurfaceBatch(QuantityStructure<S>* parent, std::string name, Func&& func,
273-
ImplicitRenderMode mode, ImplicitRenderOpts opts) {
272+
DepthRenderImageQuantity* renderImplicitSurfaceBatch(S* parent, std::string name, Func&& func, ImplicitRenderMode mode,
273+
ImplicitRenderOpts opts) {
274274

275275
resolveImplicitRenderOpts(parent, opts);
276276

@@ -307,9 +307,8 @@ ColorRenderImageQuantity* renderImplicitSurfaceColorBatch(std::string name, Func
307307

308308

309309
template <class Func, class FuncColor, class S>
310-
ColorRenderImageQuantity* renderImplicitSurfaceColor(QuantityStructure<S>* parent, std::string name, Func&& func,
311-
FuncColor&& funcColor, ImplicitRenderMode mode,
312-
ImplicitRenderOpts opts) {
310+
ColorRenderImageQuantity* renderImplicitSurfaceColor(S* parent, std::string name, Func&& func, FuncColor&& funcColor,
311+
ImplicitRenderMode mode, ImplicitRenderOpts opts) {
313312

314313
// Bootstrap on the batch version
315314
auto batchFunc = [&](const float* pos_ptr, float* result_ptr, size_t size) {
@@ -344,7 +343,7 @@ ColorRenderImageQuantity* renderImplicitSurfaceColor(QuantityStructure<S>* paren
344343

345344

346345
template <class Func, class FuncColor, class S>
347-
ColorRenderImageQuantity* renderImplicitSurfaceColorBatch(QuantityStructure<S>* parent, std::string name, Func&& func,
346+
ColorRenderImageQuantity* renderImplicitSurfaceColorBatch(S* parent, std::string name, Func&& func,
348347
FuncColor&& funcColor, ImplicitRenderMode mode,
349348
ImplicitRenderOpts opts) {
350349

@@ -399,7 +398,7 @@ ScalarRenderImageQuantity* renderImplicitSurfaceScalarBatch(std::string name, Fu
399398
}
400399

401400
template <class Func, class FuncScalar, class S>
402-
ScalarRenderImageQuantity* renderImplicitSurfaceScalar(QuantityStructure<S>* parent, std::string name, Func&& func,
401+
ScalarRenderImageQuantity* renderImplicitSurfaceScalar(S* parent, std::string name, Func&& func,
403402
FuncScalar&& funcScalar, ImplicitRenderMode mode,
404403
ImplicitRenderOpts opts, DataType dataType) {
405404

@@ -430,7 +429,7 @@ ScalarRenderImageQuantity* renderImplicitSurfaceScalar(QuantityStructure<S>* par
430429
}
431430

432431
template <class Func, class FuncScalar, class S>
433-
ScalarRenderImageQuantity* renderImplicitSurfaceScalarBatch(QuantityStructure<S>* parent, std::string name, Func&& func,
432+
ScalarRenderImageQuantity* renderImplicitSurfaceScalarBatch(S* parent, std::string name, Func&& func,
434433
FuncScalar&& funcScalar, ImplicitRenderMode mode,
435434
ImplicitRenderOpts opts, DataType dataType) {
436435

@@ -483,7 +482,7 @@ RawColorRenderImageQuantity* renderImplicitSurfaceRawColorBatch(std::string name
483482

484483

485484
template <class Func, class FuncColor, class S>
486-
RawColorRenderImageQuantity* renderImplicitSurfaceRawColor(QuantityStructure<S>* parent, std::string name, Func&& func,
485+
RawColorRenderImageQuantity* renderImplicitSurfaceRawColor(S* parent, std::string name, Func&& func,
487486
FuncColor&& funcColor, ImplicitRenderMode mode,
488487
ImplicitRenderOpts opts) {
489488

@@ -520,9 +519,9 @@ RawColorRenderImageQuantity* renderImplicitSurfaceRawColor(QuantityStructure<S>*
520519

521520

522521
template <class Func, class FuncColor, class S>
523-
RawColorRenderImageQuantity* renderImplicitSurfaceRawColorBatch(QuantityStructure<S>* parent, std::string name,
524-
Func&& func, FuncColor&& funcColor,
525-
ImplicitRenderMode mode, ImplicitRenderOpts opts) {
522+
RawColorRenderImageQuantity* renderImplicitSurfaceRawColorBatch(S* parent, std::string name, Func&& func,
523+
FuncColor&& funcColor, ImplicitRenderMode mode,
524+
ImplicitRenderOpts opts) {
526525

527526
resolveImplicitRenderOpts(parent, opts);
528527

include/polyscope/point_cloud.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#include "polyscope/color_management.h"
77
#include "polyscope/persistent_value.h"
88
#include "polyscope/pick.h"
9-
#include "polyscope/point_cloud_quantity.h"
109
#include "polyscope/polyscope.h"
1110
#include "polyscope/render/engine.h"
1211
#include "polyscope/render/managed_buffer.h"
@@ -16,6 +15,7 @@
1615

1716
#include "polyscope/point_cloud_color_quantity.h"
1817
#include "polyscope/point_cloud_parameterization_quantity.h"
18+
#include "polyscope/point_cloud_quantity.h"
1919
#include "polyscope/point_cloud_scalar_quantity.h"
2020
#include "polyscope/point_cloud_vector_quantity.h"
2121

@@ -33,16 +33,11 @@ class PointCloudParameterizationQuantity;
3333
class PointCloudVectorQuantity;
3434

3535

36-
template <> // Specialize the quantity type
37-
struct QuantityTypeHelper<PointCloud> {
38-
typedef PointCloudQuantity type;
39-
};
40-
4136
struct PointCloudPickResult {
4237
int64_t index;
4338
};
4439

45-
class PointCloud : public QuantityStructure<PointCloud> {
40+
class PointCloud : public Structure {
4641
public:
4742
// === Member functions ===
4843

0 commit comments

Comments
 (0)