Currently job artifacts in CI/CD pipelines on LRZ GitLab never expire. Starting from Wed 26.1.2022 the default expiration time will be 30 days (GitLab default). Currently existing artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

campvis.i 17.5 KB
Newer Older
1
%module campvis
2

3
%include factory.i
4
%include std_pair.i
5
%include std_string.i
6
7
%include std_vector.i

8
%import "ext/cgt/bindings/cgt.i"
9
%include "ext/sigslot/sigslot.i"
10

11
%{
12
#include "core/datastructures/abstractdata.h"
13
#include "core/datastructures/dataseries.h"
14
#include "core/datastructures/imagedata.h"
15
#include "core/properties/allproperties.h"
16
#include "core/pipeline/abstractprocessor.h"
17
#include "core/pipeline/abstractworkflow.h"
18
19
#include "core/pipeline/autoevaluationpipeline.h"
#include "core/pipeline/visualizationprocessor.h"
20
#include "core/classification/tfgeometry1d.h"
21
#include "core/classification/tfgeometry2d.h"
22
#include "core/classification/geometry1dtransferfunction.h"
23
24
#include "core/classification/simpletransferfunction.h"
#include "core/classification/geometry2dtransferfunction.h"
25
26
27
%}


28
29
30
31
32
33
%inline {
static const char* const SOURCE_DIR = CAMPVIS_SOURCE_DIR;

// Template specialisations and instantiations required to get signals to work in Lua
namespace sigslot {
    template<>
34
    struct LuaConnectionArgTraits<campvis::AbstractProcessor*> { static const char* const typeName; };
35
    const char* const LuaConnectionArgTraits<campvis::AbstractProcessor*>::typeName = "campvis::AbstractProcessor *";
36
37
38
39
40
41
42
43

    template<>
    struct LuaConnectionArgTraits<campvis::DataHandle> { static const char* const typeName; };
    const char* const LuaConnectionArgTraits<campvis::DataHandle>::typeName = "campvis::DataHandle *";

    template<>
    struct LuaConnectionArgTraits<std::string> { static const char* const typeName; };
    const char* const LuaConnectionArgTraits<std::string>::typeName = "std::string *";
44
45
46
47
48
}
}


%template(sigslot_signal1_AbstractProcessor) sigslot::signal1<campvis::AbstractProcessor*>;
49
%template(sigslot_signal2_string_DataHandle) sigslot::signal2<std::string, campvis::DataHandle>;
50

51
52
53
%template(PairStringDataHandle) std::pair<std::string, campvis::DataHandle>;
%template(VectorOfPairStringDataHandle) std::vector< std::pair< std::string, campvis::DataHandle> >;

54

55
namespace campvis {
56
57

    class AbstractProperty {
58
    public:
59
        AbstractProperty(const std::string& name, const std::string& title);
60
        virtual ~AbstractProperty();
61

62
63
        virtual void init();
        virtual void deinit();
64

65
66
        const std::string& getName() const;
        const std::string& getTitle() const;
67

68
69
70
71
        bool isVisible() const;
        void setVisible(bool isVisible);

        virtual void addSharedProperty(AbstractProperty* prop);
72
    };
73

74
75
76
77
78
79
80
81
82
83
    class ButtonProperty : public AbstractProperty {
    public:
        ButtonProperty(const std::string& name, const std::string& title);
        virtual ~ButtonProperty();

        void click();

        sigslot::signal0 s_clicked;
    };

84
85
    template<typename T>
    class GenericProperty : public AbstractProperty {
86
    public:
87
        GenericProperty(const std::string& name, const std::string& title, const T& value);
88
89
90
91
        virtual ~GenericProperty();

        const T& getValue() const;
        virtual void setValue(const T& value);
92
93
    };

94
95
96
    %template(BoolProperty) GenericProperty<bool>;
    typedef GenericProperty<bool> BoolProperty;

97
98
99
    %template(StringProperty) GenericProperty<std::string>;
    typedef GenericProperty<std::string> StringProperty;

100
101
    /* DataNameProperty */

102
103
104
105
106
107
108
109
    class DataNameProperty : public StringProperty {
    public:
        enum DataAccessInfo {
            READ,
            WRITE
        };

        DataNameProperty(const std::string& name, const std::string& title, const std::string& value,
110
                         DataAccessInfo access);
111
112
113
        virtual ~DataNameProperty();
    };

114
    /* NumericProperty */
115
116

    template<typename T>
117
    class NumericProperty : public GenericProperty<T> {
118
119
120
121
122
123
124
    public:
        NumericProperty(
            const std::string& name,
            const std::string& title,
            const T& value,
            const T& minValue,
            const T& maxValue,
125
            const T& stepValue = T(1));
126
127
128
129

        virtual ~NumericProperty();
    };

Hossain Mahmud's avatar
Hossain Mahmud committed
130
    
131
132
133
134
    %template(IntGenericProperty) GenericProperty< int >;
    %template(IntProperty) NumericProperty< int >;
    typedef NumericProperty< int > IntProperty;

135
136
137
    %template(Ivec2GenericProperty) GenericProperty< cgt::Vector2<int> >;
    %template(IVec2Property) NumericProperty< cgt::Vector2<int> >;
    typedef NumericProperty< cgt::Vector2<int> > IVec2Property;
138

139
140
141
142
143
144
145
146
147
148
    %template(Ivec3GenericProperty) GenericProperty< cgt::Vector3<int> >;
    %template(IVec3Property) NumericProperty< cgt::Vector3<int> >;
    typedef NumericProperty< cgt::Vector3<int> > IVec3Property;

    %template(Ivec4GenericProperty) GenericProperty< cgt::Vector4<int> >;
    %template(IVec4Property) NumericProperty< cgt::Vector4<int> >;
    typedef NumericProperty< cgt::Vector4<int> > IVec4Property;



149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
    template<typename T>
    struct FloatingPointPropertyTraits {};

    template<>
    struct FloatingPointPropertyTraits<float> {
        typedef int DecimalsType;
    };

    %template() FloatingPointPropertyTraits<float>;

    template<typename T>
    class FloatingPointProperty : public NumericProperty<T> {
    public:
        typedef typename FloatingPointPropertyTraits<T>::DecimalsType DecimalsType;

        FloatingPointProperty(
            const std::string& name,
            const std::string& title,
            const T& value,
            const T& minValue,
            const T& maxValue,
            const T& stepValue = T(0.01f),
171
            const DecimalsType& decimals = DecimalsType(3));
172
173
174
175
176
177
178
179
180

        virtual ~FloatingPointProperty();
    };

    %template(FloatGenericProperty) GenericProperty<float>;
    %template(FloatNumericProperty) NumericProperty<float>;
    %template(FloatProperty) FloatingPointProperty<float>;
    typedef FloatingPointProperty< float > FloatProperty;

181
182
183
184
185
186
187
188
189
190
191
192
193
194
    %template(Vec2GenericProperty) GenericProperty< cgt::Vector2<float> >;
    %template(Vec2NumericProperty) NumericProperty< cgt::Vector2<float> >;
    %template(Vec2Property) FloatingPointProperty< cgt::Vector2<float> >;
    typedef FloatingPointProperty< cgt::Vector2<float> > Vec2Property;

    %template(Vec3GenericProperty) GenericProperty< cgt::Vector3<float> >;
    %template(Vec3NumericProperty) NumericProperty< cgt::Vector3<float> >;
    %template(Vec3Property) FloatingPointProperty< cgt::Vector3<float> >;
    typedef FloatingPointProperty< cgt::Vector3<float> > Vec3Property;

    %template(Vec4GenericProperty) GenericProperty< cgt::Vector4<float> >;
    %template(Vec4NumericProperty) NumericProperty< cgt::Vector4<float> >;
    %template(Vec4Property) FloatingPointProperty< cgt::Vector4<float> >;
    typedef FloatingPointProperty< cgt::Vector4<float> > Vec4Property;
195

Hossain Mahmud's avatar
Hossain Mahmud committed
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
    /* OptionProperty */
        
    class AbstractOptionProperty : public IntProperty {
    public:
        AbstractOptionProperty(const std::string& name, const std::string& title);
        virtual ~AbstractOptionProperty();
        virtual const std::string& getOptionId() = 0;
        virtual void selectById(const std::string& id) = 0;
    };

    template<typename T>
    class GenericOptionProperty : public AbstractOptionProperty {
    public:		
        GenericOptionProperty(
            const std::string& name, 
            const std::string& title, 
            const GenericOption<T>* options,
            int count);		
        virtual ~GenericOptionProperty();		
        const std::string& getOptionId();
        void selectById(const std::string& id);
    };

219
220
221
222
223
224
225
    /* TFGeometry1D */

    %nodefaultctor TFGeometry1D;

    class TFGeometry1D {
    public:
        virtual ~TFGeometry1D();
226
        static TFGeometry1D* createQuad(const cgt::vec2& interval, const cgt::col4& leftColor, const cgt::col4& rightColor);
227
228
229
    
        void addKeyPoint(float position, float alpha);
        void addKeyPoint(float position, const cgt::col4& color);
230
231
232
233
234
235
236
237
238
239
    };

    /* TFGeometry2D */

    %nodefaultctor TFGeometry2D;

    class TFGeometry2D {
    public:
        virtual ~TFGeometry2D();
        static TFGeometry2D* createQuad(const cgt::vec2& ll, const cgt::vec2& ur, const cgt::col4& color);
240
241
242
243
244
245
    };

    /* AbstractTransferFunction */

    class AbstractTransferFunction {
    public:
246
        AbstractTransferFunction(const cgt::svec3& size, const cgt::vec2& intensityDomain = cgt::vec2(0.f, 1.f));
247
248
249
250
251
        virtual ~AbstractTransferFunction();

        virtual AbstractTransferFunction* clone() const = 0;
    };

252
253
254
255
256
257
    /* SimpleTransferFunction */
    class SimpleTransferFunction : public AbstractTransferFunction {
    public: 
        SimpleTransferFunction(size_t size, const cgt::vec2& intensityDomain = cgt::vec2(0.f, 1.f));
        virtual ~SimpleTransferFunction();
        virtual SimpleTransferFunction* clone() const;
258
259
        void setLeftColor(const cgt::col4& color);
        void setRightColor(const cgt::col4& color);
260
261
262

    };

263
264
265
266
267
    /* GenericGeometryTransferFunction */

    template<class T>
    class GenericGeometryTransferFunction : public AbstractTransferFunction {
    public:
268
        GenericGeometryTransferFunction(const cgt::vec3& size, const cgt::vec2& intensityDomain = cgt::vec2(0.f, 1.f));
269
270
        virtual ~GenericGeometryTransferFunction();

271
        %apply SWIGTYPE *DISOWN {T* geometry};
272
        void addGeometry(T* geometry);
273
        %clear T* geometry;
274
    };
275
    
276
277
278
279
280
281
    /* Geometry1DTransferFunction */

    %template(GenericGeometryTransferFunction_TFGeometry1D) GenericGeometryTransferFunction<TFGeometry1D>;

    class Geometry1DTransferFunction : public GenericGeometryTransferFunction<TFGeometry1D> {
    public:
282
        Geometry1DTransferFunction(size_t size, const cgt::vec2& intensityDomain = cgt::vec2(0.f, 1.f));
283
284
285
286
287
        virtual ~Geometry1DTransferFunction();

        virtual Geometry1DTransferFunction* clone() const;
    };

288
289
290
291
292
293
294
295
296
297
298
299
    /* Geometry2DTransferFunction */

    %template(GenericGeometryTransferFunction_TFGeometry2D) GenericGeometryTransferFunction<TFGeometry2D>;

    class Geometry2DTransferFunction : public GenericGeometryTransferFunction<TFGeometry2D> {
    public:
        Geometry2DTransferFunction(const cgt::svec2& size, const cgt::vec2& intensityDomain = cgt::vec2(0.f, 1.f));
        virtual ~Geometry2DTransferFunction();

        virtual Geometry2DTransferFunction* clone() const;
    };

300
301
302
303
    /* TransferFunctionProperty */

    class TransferFunctionProperty : public AbstractProperty {
    public:
304
        %apply SWIGTYPE *DISOWN {AbstractTransferFunction* tf};
305
        TransferFunctionProperty(const std::string& name, const std::string& title, AbstractTransferFunction* tf);
306
307
308
309
        virtual ~TransferFunctionProperty();

        AbstractTransferFunction* getTF();
        void replaceTF(AbstractTransferFunction* tf);
310
        %clear AbstractTransferFunction* tf;
311
312
    };

313
314
315
316
317
318
319
    /* IHasWorldBounds */

    class IHasWorldBounds {
    public:
        IHasWorldBounds();
        virtual ~IHasWorldBounds();

320
        virtual cgt::Bounds getWorldBounds() const = 0;
321
322
323
324
325
326
327
328
329
    };

    /* AbstractData */

    class AbstractData {
    public:
        AbstractData();
        virtual ~AbstractData();

330
331
        virtual size_t getLocalMemoryFootprint() const = 0;
        virtual size_t getVideoMemoryFootprint() const = 0;
332
333
        virtual AbstractData* clone() const = 0;
    };
334
    
335
336
    /* DataHandle */

337
338
339
    /* Downcast the return value of DataHandle::getData to appropriate subclass */
    %factory(const AbstractData* campvis::DataHandle::getData, const campvis::ImageData);

340
    %apply SWIGTYPE *DISOWN {AbstractData* data};
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
    class DataHandle {
    public:
        explicit DataHandle(AbstractData* data = 0);
        DataHandle(const DataHandle& rhs);
        DataHandle& operator=(const DataHandle& rhs);
        virtual ~DataHandle();

        const AbstractData* getData() const;
    };

    /* DataSeries */

    class DataSeries : public AbstractData {
    public:
        DataSeries();
        virtual ~DataSeries();
        virtual DataSeries* clone() const;
        
        void addData(AbstractData* data);
        void addData(DataHandle dh);

        size_t getNumDatas() const;
        DataHandle getData(size_t index) const;

    protected:
        std::vector<DataHandle> _data;    ///< the images of this series
    };
368
369
370
371
372

    /* ImageData */

    class ImageData : public AbstractData, public IHasWorldBounds {
    public:
373
        ImageData(size_t dimensionality, const cgt::svec3& size, size_t numChannels);
374
375
376
        virtual ~ImageData();

        virtual ImageData* clone() const;
377
        virtual cgt::Bounds getWorldBounds() const;
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
    };

    /* DataContainer */

    class DataContainer {
    public:
        DataContainer(const std::string& name);
        ~DataContainer();

        DataHandle addData(const std::string& name, AbstractData* data);
        void addDataHandle(const std::string& name, const DataHandle& dh);
        bool hasData(const std::string& name) const;
        DataHandle getData(const std::string& name) const;
        void removeData(const std::string& name);
        void clear();
393

394
395
        std::vector< std::pair< std::string, DataHandle> > getDataHandlesCopy() const;

396
397
        %immutable;
        sigslot::signal0 s_changed;
398
        sigslot::signal2<std::string, DataHandle> s_dataAdded;
399
        %mutable;
400
    };
401
402

    %clear AbstractData* data;
Hossain Mahmud's avatar
Hossain Mahmud committed
403
404
405
406
407
    
    /* Down casting or super classes.
     * Down casting follows the order of declaration.
     * Declare the classes as child first according to the class hierarchy.
     */
408
409
410

    /* Downcast the return value of HasPropertyCollection::getProperty to appropriate subclass */
    %factory(AbstractProperty* campvis::HasPropertyCollection::getProperty,
Hossain Mahmud's avatar
Hossain Mahmud committed
411
             campvis::AbstractOptionProperty, campvis::IntProperty, campvis::IVec2Property, campvis::IVec3Property, campvis::IVec4Property,
412
             campvis::FloatProperty, campvis::Vec2Property, campvis::Vec3Property, campvis::Vec4Property,
413
             campvis::TransferFunctionProperty,
414
             campvis::DataNameProperty, campvis::StringProperty, campvis::ButtonProperty, campvis::BoolProperty);
415
416
417

    /* Downcast the return value of HasPropertyCollection::getNestedProperty to appropriate subclass */
    %factory(AbstractProperty* campvis::HasPropertyCollection::getNestedProperty,
Hossain Mahmud's avatar
Hossain Mahmud committed
418
             campvis::AbstractOptionProperty, campvis::IntProperty, campvis::IVec2Property, campvis::IVec3Property, campvis::IVec4Property,
419
             campvis::FloatProperty, campvis::Vec2Property, campvis::Vec3Property, campvis::Vec4Property,
420
             campvis::TransferFunctionProperty,
421
             campvis::DataNameProperty, campvis::StringProperty, campvis::ButtonProperty, campvis::BoolProperty);
422
423
424
425
426
427
428
429

    /* HasPropertyCollection */

    class HasPropertyCollection  {
    public:
        HasPropertyCollection();
        virtual ~HasPropertyCollection() = 0;

430
431
        virtual void addProperty(AbstractProperty& prop);
        void removeProperty(AbstractProperty& prop);
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
        AbstractProperty* getProperty(const std::string& name) const;
        AbstractProperty* getNestedProperty(const std::string& name) const;
    };

    /* AbstractProcessor */

    class AbstractProcessor : public HasPropertyCollection {
    public:
        enum InvalidationLevel {
            VALID               = 0,
            INVALID_RESULT      = 1 << 0,
            INVALID_SHADER      = 1 << 1,
            INVALID_PROPERTIES  = 1 << 2,
            FIRST_FREE_TO_USE_INVALIDATION_LEVEL = 1 << 3
        };

        const std::string getName() const = 0;
449
450
        void addProperty(AbstractProperty& prop, int invalidationLevel);
        void setPropertyInvalidationLevel(AbstractProperty& prop, int invalidationLevel);
451

452
        void process(DataContainer& data);
453

454
455
        %immutable;
        sigslot::signal1<AbstractProcessor*> s_validated;
456
        sigslot::signal1<AbstractProcessor*> s_invalidated;
457
        %mutable;
458
459
460
461
462
463
    };

    /* AbstractPipeline */

    class AbstractPipeline : public HasPropertyCollection {
    public:
464
        AbstractPipeline(DataContainer& dc);
465
466
        virtual ~AbstractPipeline();

467
        virtual std::string getName() const = 0;
468
469
470

        const DataContainer& getDataContainer() const;
        DataContainer& getDataContainer();
Hossain Mahmud's avatar
Hossain Mahmud committed
471
        
472
473
        virtual void addProcessor(AbstractProcessor* processor);
        virtual void executePipeline() = 0;
474
        AbstractProcessor* getProcessor(const std::string& name) const;
475
        AbstractProcessor* getProcessor(size_t index) const;
476

477
        %immutable;
478
479
        sigslot::signal0 s_init;
        sigslot::signal0 s_deinit;
480
        %mutable;
481
482
483
484
485
486
    };

    /* AutoEvaluationPipeline */

    class AutoEvaluationPipeline : public AbstractPipeline {
    public:
487
488
489
490
        AutoEvaluationPipeline(DataContainer& dataContainer, const std::string& pipelineName);
        virtual ~AutoEvaluationPipeline();
        
        std::string getName() const;
491
492
        virtual void addProcessor(AbstractProcessor* processor);

493
        void addEventListenerToBack(cgt::EventListener* e);
494
        virtual void executePipeline();
495
    };
496

497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
    class AbstractWorkflow : public HasPropertyCollection {
    public:
        AbstractWorkflow(const std::string& title);
        virtual ~AbstractWorkflow();

        virtual std::vector<AbstractPipeline*> getPipelines() = 0;
        virtual const std::string getName() const = 0;

        virtual void init();
        virtual void deinit();

        DataContainer* getDataContainer();

        virtual bool isStageAvailable(int stage) const;
        int getCurrentStageId() const;
        void setCurrentStage(int stage);

514
        %immutable;
515
516
        sigslot::signal2<int, int> s_stageChanged;
        sigslot::signal0 s_stageAvailabilityChanged;
517
        %mutable;
518
519
520
    };


521
522
523
524
525
526
    /* VisualizationProcessor */

    class VisualizationProcessor : public AbstractProcessor {
    public:
        explicit VisualizationProcessor(IVec2Property* viewportSizeProp);
        ~VisualizationProcessor();
527
    };
528
}
529
530

%luacode {
531
  print("Module campvis-core loaded")
532
}