MeVisLab Toolbox Reference
mlPCLModule.h
Go to the documentation of this file.
1 // Copyright (c) Fraunhofer MEVIS, Germany. All rights reserved.
2 // **InsertLicense** code author="Wolf Spindler"
3 //----------------------------------------------------------------------------------
5 
12 //----------------------------------------------------------------------------------
13 #pragma once
14 
15 #include "MLPCLSupportSystem.h"
16 #include <mlModuleIncludes.h>
18 #include <mlPCLBaseObject.h>
19 
20 ML_START_NAMESPACE
21 
22 //----------------------------------------------------------------------------------
24 //----------------------------------------------------------------------------------
26 {
27 public:
36  PCLModule(int numImageInputs=0, int numImageOutputs=0,
37  int numPCLInputs=0, int numPCLOutputs=0,
38  bool createEnumAndNotify=false);
39 
41  ~PCLModule() override;
42 
44  BaseField &getInputPCLBaseObjectField(size_t inIdx) const;
45 
48 
53 
56  PCLBaseObject *getInputPCLBaseObject(size_t inIdx) const;
57 
59  BaseField &getOutputPCLBaseObjectField(size_t inIdx) const;
60 
62  PCLBaseObject *getOutputPCLBaseObject(size_t inIdx) const;
63 
65  void setOutputPCLBaseObject(size_t outIdx, PCLBaseObjectPtr baseObjPtr);
66 
69 
74 
80  template <typename PCL_OBJECT_PTR_TYPE>
81  inline void setOutputPCLObject(size_t outIdx,
82  PCL_OBJECT_PTR_TYPE outputPCLObjectPtr)
83  {
84  PCLBaseObject *outBaseObject = getOutputPCLBaseObject(outIdx);
85  if (!outBaseObject){
86  // Create a new base object if there is still no one.
87  PCLBaseObjectPtr outBaseObjectPtr(new PCLBaseObject(MLPCLObjectPtrsContainer(outputPCLObjectPtr)));
88  setOutputPCLBaseObject(outIdx, outBaseObjectPtr); // Also touches since base value is set.
89  }
90  else{
91  outBaseObject->getPCLObjectPtrsContainer().setPCLObjectPointer(outputPCLObjectPtr);
92  getOutputPCLBaseObjectField(outIdx).touch();
93  }
94  }
95 
100  inline void clearOutputPCLPointers(size_t outIdx)
101  {
102  setOutputPCLObject(outIdx, MLPointCloudXYZPtr());
103  }
104 
106  std::vector<PCLBaseObjectPtr> getNonNullConnectedInputPCLBaseObjects() const;
107 
111  bool hasValidInputPointCloudPointer(size_t inIdx);
112 
117 
120 
123 
125  void setStatusString(const std::string &statusStr);
126 
128  std::string getStatusString() const;
129 
132 
133 protected:
135  void handleNotification (Field* field) override;
136 
138  bool _needsUpdate(Field *field) const;
139 
143  virtual void _updateConnectionStatus();
144 
145 private:
146 
148  StringField *_statusFld;
149 
151  EnumField *_updateModeFld;
152 
154  NotifyField *_updateFld;
155 
157  std::vector<BaseField*> _pclInputConnectors;
158 
160  std::vector<BaseField*> _pclOutputConnectors;
161 
164 
167 };
168 
169 ML_END_NAMESPACE
170 
Project global and OS specific declarations.
#define MLPCLSUPPORT_EXPORT
If included by external modules, exported symbols are declared as import symbols.
Field to encapsulate a pointer to an ML base object.
Definition: mlFields.h:1187
Field to encapsulate an enumerated value.
Definition: mlFields.h:363
Base class for all fields used in the ML.
Definition: mlField.h:73
Base class for an image processing module of the ML.
Definition: mlModule.h:156
Field without value for notifications.
Definition: mlFields.h:1049
Base object containing pointers (as MLPCLObjectPtrsContainer) to objects from the Point Cloud Library...
MLPCLObjectPtrsContainer & getPCLObjectPtrsContainer()
Returns the internal MLPCLObjectPtrsContainer container as modifiable object to get access to the poi...
ML Module base class for algorithms from the Point Cloud Library (PCL).
Definition: mlPCLModule.h:26
PCLBaseObject * getOutputPCLBaseObject(size_t inIdx) const
Returns the PCL base object of the idx'th output connector if it exists, accessing non existing index...
bool _needsUpdate(Field *field) const
If _updateModeFld and _updateFld settings with field require an update then true is returned,...
MLPCLObjectPtrsContainer getInputPCLObjectPtrsContainer(size_t inIdx)
Convenience function which returns an PointCloudPointers pointer for an existing input PCLBaseObject ...
~PCLModule() override
Destructor.
const StringField & getStatusStringField() const
Returns a constant reference to the status string field, for example to compare to it in handle Notif...
size_t getNumInputPCLBaseObjectFields() const
Returns the number of PCLBaseObject input connectors.
bool hasValidInputPointCloudPointer(size_t inIdx)
Returns true if at input inIdx a valid point cloud is connected (which, however, could contain only z...
PCLModule(int numImageInputs=0, int numImageOutputs=0, int numPCLInputs=0, int numPCLOutputs=0, bool createEnumAndNotify=false)
Constructor which created numImageInputs image inputs, numImageOutputs image outputs,...
void setStatusString(const std::string &statusStr)
Sets a status string in the status field.
BaseField & getOutputPCLBaseObjectField(size_t inIdx) const
Returns the base field of the idx'th output connector if it exists, accessing non existing indexes is...
void clearOutputPCLPointers(size_t outIdx)
Resets all point cloud pointers at outIdx to nullptr; if no output base object exists then one is cre...
Definition: mlPCLModule.h:100
void handleNotification(Field *field) override
Handles field changes of the field field.
size_t getNumOutputPCLBaseObjectFields() const
Returns the number of PCLBaseObject output connectors.
void setOutputPCLObject(size_t outIdx, PCL_OBJECT_PTR_TYPE outputPCLObjectPtr)
Sets a new PCL object at output outIdx; if no base object exists one is created (which always touches...
Definition: mlPCLModule.h:81
EnumField * getUpdateModeFieldPointer() const
Returns the update mode field if it has been created in the constructor, otherwise nullptr is returne...
std::string getStatusString() const
Sets a status string in the status field.
MLPCLObjectPtrsContainer getOutputPCLObjectPtrsContainer(size_t inIdx)
Convenience function which returns an PointCloudPointers container for an existing output PCLBaseObje...
NotifyField * getUpdateFieldPointer() const
Returns the update field if it has been created in the constructor, otherwise nullptr is returned.
virtual void _updateConnectionStatus()
If there is at least one input connector for a point cloud then this updates the status field with in...
BaseField & getInputPCLBaseObjectField(size_t inIdx) const
Returns the base field of the idx'th input connector if it exists, accessing non existing indexes is ...
void setOutputPCLBaseObject(size_t outIdx, PCLBaseObjectPtr baseObjPtr)
Sets the PCL base object of the idx'th output connector if it exists, using non existing indexes is n...
std::vector< PCLBaseObjectPtr > getNonNullConnectedInputPCLBaseObjects() const
Returns a vector of all connected non nullptr PCLBaseObjects.
PCLBaseObject * getInputPCLBaseObject(size_t inIdx) const
Returns the PCL base object of the idx'th input connector if it exists, accessing non existing indexe...
bool hasValidInputPolygonMeshPointer(size_t inIdx)
Returns true if at input inIdx a valid polygon mesh is connected (which, however, could be empty!...
Field to encapsulate a string value.
Definition: mlFields.h:1000
#define ML_MODULE_CLASS_HEADER(className)
Like ML_CLASS_HEADER for the usage of derived classes from Module.
Base object containing pointers (as MLPCLObjectPtrsContainer) to objects from the Point Cloud Library...
A container with pointers from the PCL (Point Cloud Library) passed in BaseObjects between PCL module...
#define ML_PCL_TEST_INTERFACE_NO_OVERRIDE(BASE_OBJECT_NAME)
Implements a dedicated interface for PCL related modules which is required in automatic tests.
pcl::PointCloud< pcl::PointXYZ >::Ptr MLPointCloudXYZPtr
The basic pointer type of a point cloud type used in the PCL MeVisLab binding.
Definition: mlPCLTypes.h:86
A container with pointers from the PCL (Point Cloud Library) passed in BaseObjects between PCL module...
void setPCLObjectPointer(MLPointCloudXYZPtr pcPtr)
Setting a new container object clearing all other ones.