Base: Add ComplexGeoData::centerOfGravity helper
This adds a simple quality of life helper returning center of gravity as std::optional instead of C style method accepting reference and returning bool to indicate method success.
This commit is contained in:
@@ -184,6 +184,17 @@ bool ComplexGeoData::getCenterOfGravity(Base::Vector3d& unused) const
|
||||
return false;
|
||||
}
|
||||
|
||||
std::optional<Base::Vector3d> ComplexGeoData::centerOfGravity() const
|
||||
{
|
||||
Base::Vector3d centerOfGravity;
|
||||
|
||||
if (getCenterOfGravity(centerOfGravity)) {
|
||||
return centerOfGravity;
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
const std::string& ComplexGeoData::elementMapPrefix()
|
||||
{
|
||||
static std::string prefix(ELEMENT_MAP_PREFIX);
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
#define APP_COMPLEX_GEO_DATA_H
|
||||
|
||||
#include <algorithm>
|
||||
#include <optional>
|
||||
|
||||
#include <Base/Handle.h>
|
||||
#include <Base/Matrix.h>
|
||||
#include <Base/Persistence.h>
|
||||
@@ -200,6 +202,7 @@ public:
|
||||
* The default implementation only returns false.
|
||||
*/
|
||||
virtual bool getCenterOfGravity(Base::Vector3d& center) const;
|
||||
virtual std::optional<Base::Vector3d> centerOfGravity() const;
|
||||
//@}
|
||||
|
||||
static const std::string& elementMapPrefix();
|
||||
|
||||
Reference in New Issue
Block a user