diff --git a/src/Base/Axis.cpp b/src/Base/Axis.cpp
index 6b615cece2..45959d991b 100644
--- a/src/Base/Axis.cpp
+++ b/src/Base/Axis.cpp
@@ -27,10 +27,9 @@
using namespace Base;
Axis::Axis(const Vector3d& Orig, const Vector3d& Dir)
- : _base{Orig}
- , _dir{Dir}
-{
-}
+ : _base {Orig}
+ , _dir {Dir}
+{}
void Axis::reverse()
{
@@ -49,24 +48,24 @@ void Axis::move(const Vector3d& MovVec)
_base += MovVec;
}
-bool Axis::operator ==(const Axis& that) const
+bool Axis::operator==(const Axis& that) const
{
return (this->_base == that._base) && (this->_dir == that._dir);
}
-bool Axis::operator !=(const Axis& that) const
+bool Axis::operator!=(const Axis& that) const
{
return !(*this == that);
}
-Axis& Axis::operator *=(const Placement &p)
+Axis& Axis::operator*=(const Placement& p)
{
p.multVec(this->_base, this->_base);
p.getRotation().multVec(this->_dir, this->_dir);
return *this;
}
-Axis Axis::operator *(const Placement &p) const
+Axis Axis::operator*(const Placement& p) const
{
Axis a(*this);
a *= p;
diff --git a/src/Base/Axis.h b/src/Base/Axis.h
index 3a2b963c38..b0ef8b04b3 100644
--- a/src/Base/Axis.h
+++ b/src/Base/Axis.h
@@ -27,7 +27,8 @@
#include "Placement.h"
#include "Vector3D.h"
-namespace Base {
+namespace Base
+{
/**
* The Axis class.
@@ -41,12 +42,24 @@ public:
Axis(Axis&&) = default;
Axis(const Vector3d& Orig, const Vector3d& Dir);
/// Destruction
- ~Axis () = default;
+ ~Axis() = default;
- const Vector3d& getBase() const {return _base;}
- const Vector3d& getDirection() const {return _dir;}
- void setBase(const Vector3d& Orig) {_base=Orig;}
- void setDirection(const Vector3d& Dir) {_dir=Dir;}
+ const Vector3d& getBase() const
+ {
+ return _base;
+ }
+ const Vector3d& getDirection() const
+ {
+ return _dir;
+ }
+ void setBase(const Vector3d& Orig)
+ {
+ _base = Orig;
+ }
+ void setDirection(const Vector3d& Dir)
+ {
+ _dir = Dir;
+ }
void reverse();
Axis reversed() const;
@@ -54,12 +67,12 @@ public:
/** Operators. */
//@{
- Axis& operator *=(const Placement &p);
- Axis operator *(const Placement &p) const;
- bool operator ==(const Axis&) const;
- bool operator !=(const Axis&) const;
- Axis& operator =(const Axis&) = default;
- Axis& operator =(Axis&&) = default;
+ Axis& operator*=(const Placement& p);
+ Axis operator*(const Placement& p) const;
+ bool operator==(const Axis&) const;
+ bool operator!=(const Axis&) const;
+ Axis& operator=(const Axis&) = default;
+ Axis& operator=(Axis&&) = default;
//@}
private:
@@ -67,6 +80,6 @@ private:
Vector3d _dir;
};
-} // namespace Base
+} // namespace Base
-#endif // BASE_AXIS_H
+#endif // BASE_AXIS_H
diff --git a/src/Base/AxisPy.xml b/src/Base/AxisPy.xml
index 65efaf8413..4f4798b001 100644
--- a/src/Base/AxisPy.xml
+++ b/src/Base/AxisPy.xml
@@ -13,18 +13,18 @@
FatherNamespace="Base">
- Base.Axis class.
+ Base.Axis class.
-An Axis defines a direction and a position (base) in 3D space.
+An Axis defines a direction and a position (base) in 3D space.
-The following constructors are supported:
+The following constructors are supported:
Axis()
-Empty constructor.
+Empty constructor.
Axis(axis)
Copy constructor.
-axis : Base.Axis
+axis : Base.Axis
Axis(base, direction)
Define from a position and a direction.
@@ -34,34 +34,34 @@ direction : Base.Vector
>
- copy() -> Base.Axis
+ copy() -> Base.Axis
Returns a copy of this Axis.
- move(vector) -> None
+ move(vector) -> None
-Move the axis base along the given vector.
+Move the axis base along the given vector.
-vector : Base.Vector
+vector : Base.Vector
Vector by which to move the axis.
- multiply(placement) -> Base.Axis
+ multiply(placement) -> Base.Axis
-Multiply this axis by a placement.
+Multiply this axis by a placement.
-placement : Base.Placement
+placement : Base.Placement
Placement by which to multiply the axis.
- reversed() -> Base.Axis
+ reversed() -> Base.Axis
Compute the reversed axis. This returns a new Base.Axis with
the original direction reversed.
diff --git a/src/Base/AxisPyImp.cpp b/src/Base/AxisPyImp.cpp
index d4e0e199ae..57de505bf5 100644
--- a/src/Base/AxisPyImp.cpp
+++ b/src/Base/AxisPyImp.cpp
@@ -39,14 +39,15 @@ std::string AxisPy::representation() const
AxisPy::PointerType ptr = getAxisPtr();
std::stringstream str;
str << "Axis [Base=(";
- str << ptr->getBase().x << ","<< ptr->getBase().y << "," << ptr->getBase().z;
+ str << ptr->getBase().x << "," << ptr->getBase().y << "," << ptr->getBase().z;
str << "), Direction=(";
- str << ptr->getDirection().x << ","<< ptr->getDirection().y << "," << ptr->getDirection().z << ")]";
+ str << ptr->getDirection().x << "," << ptr->getDirection().y << "," << ptr->getDirection().z
+ << ")]";
return str.str();
}
-PyObject *AxisPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper
+PyObject* AxisPy::PyMake(struct _typeobject*, PyObject*, PyObject*) // Python wrapper
{
// create a new instance of AxisPy and the Twin object
return new AxisPy(new Axis);
@@ -55,22 +56,21 @@ PyObject *AxisPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Pytho
// constructor method
int AxisPy::PyInit(PyObject* args, PyObject* /*kwd*/)
{
- PyObject* o{};
+ PyObject* o {};
if (PyArg_ParseTuple(args, "")) {
return 0;
}
PyErr_Clear();
if (PyArg_ParseTuple(args, "O!", &(Base::AxisPy::Type), &o)) {
- Base::Axis *a = static_cast(o)->getAxisPtr();
+ Base::Axis* a = static_cast(o)->getAxisPtr();
*(getAxisPtr()) = *a;
return 0;
}
PyErr_Clear();
- PyObject* d{};
- if (PyArg_ParseTuple(args, "O!O!", &(Base::VectorPy::Type), &o,
- &(Base::VectorPy::Type), &d)) {
+ PyObject* d {};
+ if (PyArg_ParseTuple(args, "O!O!", &(Base::VectorPy::Type), &o, &(Base::VectorPy::Type), &d)) {
// NOTE: The first parameter defines the base (origin) and the second the direction.
*getAxisPtr() = Base::Axis(static_cast(o)->value(),
static_cast(d)->value());
@@ -81,42 +81,46 @@ int AxisPy::PyInit(PyObject* args, PyObject* /*kwd*/)
return -1;
}
-PyObject* AxisPy::move(PyObject * args)
+PyObject* AxisPy::move(PyObject* args)
{
- PyObject *vec{};
- if (!PyArg_ParseTuple(args, "O!", &(VectorPy::Type), &vec))
+ PyObject* vec {};
+ if (!PyArg_ParseTuple(args, "O!", &(VectorPy::Type), &vec)) {
return nullptr;
+ }
getAxisPtr()->move(static_cast(vec)->value());
Py_Return;
}
-PyObject* AxisPy::multiply(PyObject * args)
+PyObject* AxisPy::multiply(PyObject* args)
{
- PyObject *plm{};
- if (!PyArg_ParseTuple(args, "O!", &(PlacementPy::Type), &plm))
+ PyObject* plm {};
+ if (!PyArg_ParseTuple(args, "O!", &(PlacementPy::Type), &plm)) {
return nullptr;
+ }
Axis mult = (*getAxisPtr()) * (*static_cast(plm)->getPlacementPtr());
return new AxisPy(new Axis(mult));
}
-PyObject* AxisPy::copy(PyObject * args)
+PyObject* AxisPy::copy(PyObject* args)
{
- if (!PyArg_ParseTuple(args, ""))
+ if (!PyArg_ParseTuple(args, "")) {
return nullptr;
+ }
return new AxisPy(new Axis(*getAxisPtr()));
}
-PyObject* AxisPy::reversed(PyObject * args)
+PyObject* AxisPy::reversed(PyObject* args)
{
- if (!PyArg_ParseTuple(args, ""))
+ if (!PyArg_ParseTuple(args, "")) {
return nullptr;
+ }
Base::Axis a = getAxisPtr()->reversed();
return new AxisPy(new Axis(a));
}
Py::Object AxisPy::getBase() const
{
- return Py::Vector(getAxisPtr()->getBase()); // NOLINT
+ return Py::Vector(getAxisPtr()->getBase()); // NOLINT
}
void AxisPy::setBase(Py::Object arg)
@@ -126,7 +130,7 @@ void AxisPy::setBase(Py::Object arg)
Py::Object AxisPy::getDirection() const
{
- return Py::Vector(getAxisPtr()->getDirection()); // NOLINT
+ return Py::Vector(getAxisPtr()->getDirection()); // NOLINT
}
void AxisPy::setDirection(Py::Object arg)
@@ -134,7 +138,7 @@ void AxisPy::setDirection(Py::Object arg)
getAxisPtr()->setDirection(Py::Vector(arg).toVector());
}
-PyObject *AxisPy::getCustomAttributes(const char* /*attr*/) const
+PyObject* AxisPy::getCustomAttributes(const char* /*attr*/) const
{
return nullptr;
}
@@ -143,4 +147,3 @@ int AxisPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
{
return 0;
}
-
diff --git a/src/Base/BaseClass.cpp b/src/Base/BaseClass.cpp
index a734dfee9e..2d6f024aca 100644
--- a/src/Base/BaseClass.cpp
+++ b/src/Base/BaseClass.cpp
@@ -24,7 +24,7 @@
#include "PreCompiled.h"
#ifndef _PreComp_
-# include
+#include
#endif
#include "BaseClass.h"
@@ -32,7 +32,7 @@
using namespace Base;
-Type BaseClass::classTypeId = Base::Type::badType();
+Type BaseClass::classTypeId = Base::Type::badType(); // NOLINT
//**************************************************************************
@@ -64,9 +64,7 @@ void BaseClass::init()
/* Set up entry in the type system. */
BaseClass::classTypeId =
- Type::createType(Type::badType(),
- "Base::BaseClass",
- BaseClass::create);
+ Type::createType(Type::badType(), "Base::BaseClass", BaseClass::create);
}
Type BaseClass::getClassTypeId()
@@ -80,7 +78,9 @@ Type BaseClass::getTypeId() const
}
-void BaseClass::initSubclass(Base::Type &toInit,const char* ClassName, const char *ParentName,
+void BaseClass::initSubclass(Base::Type& toInit,
+ const char* ClassName,
+ const char* ParentName,
Type::instantiationMethod method)
{
// don't init twice!
@@ -88,7 +88,7 @@ void BaseClass::initSubclass(Base::Type &toInit,const char* ClassName, const cha
// get the parent class
Base::Type parentType(Base::Type::fromName(ParentName));
// forgot init parent!
- assert(parentType != Base::Type::badType() );
+ assert(parentType != Base::Type::badType());
// create the new type
toInit = Base::Type::createType(parentType, ClassName, method);
@@ -104,13 +104,13 @@ void BaseClass::initSubclass(Base::Type &toInit,const char* ClassName, const cha
*
* The default implementation returns 'None'.
*/
-PyObject *BaseClass::getPyObject()
+PyObject* BaseClass::getPyObject()
{
assert(0);
Py_Return;
}
-void BaseClass::setPyObject(PyObject *)
+void BaseClass::setPyObject(PyObject*)
{
assert(0);
}
diff --git a/src/Base/BaseClass.h b/src/Base/BaseClass.h
index 6d5abd285e..af78ec9aaa 100644
--- a/src/Base/BaseClass.h
+++ b/src/Base/BaseClass.h
@@ -31,72 +31,104 @@ using PyObject = struct _object;
/// define for subclassing Base::BaseClass
-#define TYPESYSTEM_HEADER() \
-public: \
- static Base::Type getClassTypeId(void); \
- virtual Base::Type getTypeId(void) const; \
- static void init(void);\
- static void *create(void);\
-private: \
- static Base::Type classTypeId
+#define TYPESYSTEM_HEADER() \
+public: \
+ static Base::Type getClassTypeId(void); \
+ virtual Base::Type getTypeId(void) const; \
+ static void init(void); \
+ static void* create(void); \
+ \
+private: \
+ static Base::Type classTypeId
/// Like TYPESYSTEM_HEADER, but declare getTypeId as 'override'
-#define TYPESYSTEM_HEADER_WITH_OVERRIDE() \
-public: \
- static Base::Type getClassTypeId(void); \
- virtual Base::Type getTypeId(void) const override; \
- static void init(void);\
- static void *create(void);\
-private: \
- static Base::Type classTypeId
+#define TYPESYSTEM_HEADER_WITH_OVERRIDE() \
+public: \
+ static Base::Type getClassTypeId(void); \
+ virtual Base::Type getTypeId(void) const override; \
+ static void init(void); \
+ static void* create(void); \
+ \
+private: \
+ static Base::Type classTypeId
/// define to implement a subclass of Base::BaseClass
-#define TYPESYSTEM_SOURCE_P(_class_) \
-Base::Type _class_::getClassTypeId(void) { return _class_::classTypeId; } \
-Base::Type _class_::getTypeId(void) const { return _class_::classTypeId; } \
-Base::Type _class_::classTypeId = Base::Type::badType(); \
-void * _class_::create(void){\
- return new _class_ ();\
-}
+#define TYPESYSTEM_SOURCE_P(_class_) \
+ Base::Type _class_::getClassTypeId(void) \
+ { \
+ return _class_::classTypeId; \
+ } \
+ Base::Type _class_::getTypeId(void) const \
+ { \
+ return _class_::classTypeId; \
+ } \
+ Base::Type _class_::classTypeId = Base::Type::badType(); \
+ void* _class_::create(void) \
+ { \
+ return new _class_(); \
+ }
/// define to implement a subclass of Base::BaseClass
-#define TYPESYSTEM_SOURCE_TEMPLATE_P(_class_) \
-template<> Base::Type _class_::getClassTypeId(void) { return _class_::classTypeId; } \
-template<> Base::Type _class_::getTypeId(void) const { return _class_::classTypeId; } \
-template<> void * _class_::create(void){\
- return new _class_ ();\
-}
+#define TYPESYSTEM_SOURCE_TEMPLATE_P(_class_) \
+ template<> \
+ Base::Type _class_::getClassTypeId(void) \
+ { \
+ return _class_::classTypeId; \
+ } \
+ template<> \
+ Base::Type _class_::getTypeId(void) const \
+ { \
+ return _class_::classTypeId; \
+ } \
+ template<> \
+ void* _class_::create(void) \
+ { \
+ return new _class_(); \
+ }
/// define to implement a subclass of Base::BaseClass
-#define TYPESYSTEM_SOURCE_ABSTRACT_P(_class_) \
-Base::Type _class_::getClassTypeId(void) { return _class_::classTypeId; } \
-Base::Type _class_::getTypeId(void) const { return _class_::classTypeId; } \
-Base::Type _class_::classTypeId = Base::Type::badType(); \
-void * _class_::create(void){return 0;}
+#define TYPESYSTEM_SOURCE_ABSTRACT_P(_class_) \
+ Base::Type _class_::getClassTypeId(void) \
+ { \
+ return _class_::classTypeId; \
+ } \
+ Base::Type _class_::getTypeId(void) const \
+ { \
+ return _class_::classTypeId; \
+ } \
+ Base::Type _class_::classTypeId = Base::Type::badType(); \
+ void* _class_::create(void) \
+ { \
+ return 0; \
+ }
/// define to implement a subclass of Base::BaseClass
-#define TYPESYSTEM_SOURCE(_class_, _parentclass_) \
-TYPESYSTEM_SOURCE_P(_class_)\
-void _class_::init(void){\
- initSubclass(_class_::classTypeId, #_class_ , #_parentclass_, &(_class_::create) ); \
-}
+#define TYPESYSTEM_SOURCE(_class_, _parentclass_) \
+ TYPESYSTEM_SOURCE_P(_class_) \
+ void _class_::init(void) \
+ { \
+ initSubclass(_class_::classTypeId, #_class_, #_parentclass_, &(_class_::create)); \
+ }
/// define to implement a subclass of Base::BaseClass
-#define TYPESYSTEM_SOURCE_TEMPLATE_T(_class_, _parentclass_) \
-TYPESYSTEM_SOURCE_TEMPLATE_P(_class_)\
-template<> void _class_::init(void){\
- initSubclass(_class_::classTypeId, #_class_ , #_parentclass_, &(_class_::create) ); \
-}
+#define TYPESYSTEM_SOURCE_TEMPLATE_T(_class_, _parentclass_) \
+ TYPESYSTEM_SOURCE_TEMPLATE_P(_class_) \
+ template<> \
+ void _class_::init(void) \
+ { \
+ initSubclass(_class_::classTypeId, #_class_, #_parentclass_, &(_class_::create)); \
+ }
/// define to implement a subclass of Base::BaseClass
-#define TYPESYSTEM_SOURCE_ABSTRACT(_class_, _parentclass_) \
-TYPESYSTEM_SOURCE_ABSTRACT_P(_class_)\
-void _class_::init(void){\
- initSubclass(_class_::classTypeId, #_class_ , #_parentclass_, &(_class_::create) ); \
-}
+#define TYPESYSTEM_SOURCE_ABSTRACT(_class_, _parentclass_) \
+ TYPESYSTEM_SOURCE_ABSTRACT_P(_class_) \
+ void _class_::init(void) \
+ { \
+ initSubclass(_class_::classTypeId, #_class_, #_parentclass_, &(_class_::create)); \
+ }
namespace Base
{
@@ -104,54 +136,69 @@ namespace Base
class BaseExport BaseClass
{
public:
- static Type getClassTypeId();
- virtual Type getTypeId() const;
- bool isDerivedFrom(const Type type) const {return getTypeId().isDerivedFrom(type);}
+ static Type getClassTypeId();
+ virtual Type getTypeId() const;
+ bool isDerivedFrom(const Type type) const
+ {
+ return getTypeId().isDerivedFrom(type);
+ }
- static void init();
+ static void init();
- virtual PyObject *getPyObject();
- virtual void setPyObject(PyObject *);
+ virtual PyObject* getPyObject();
+ virtual void setPyObject(PyObject*);
- static void *create(){return nullptr;}
+ static void* create()
+ {
+ return nullptr;
+ }
- template
- bool is() const
- {
- return getTypeId() == T::getClassTypeId();
- }
+ template
+ bool is() const
+ {
+ return getTypeId() == T::getClassTypeId();
+ }
+
+ template
+ bool isDerivedFrom() const
+ {
+ return getTypeId().isDerivedFrom(T::getClassTypeId());
+ }
- template
- bool isDerivedFrom() const
- {
- return getTypeId().isDerivedFrom(T::getClassTypeId());
- }
private:
- static Type classTypeId;
+ static Type classTypeId; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
+
protected:
- static void initSubclass(Base::Type &toInit,const char* ClassName, const char *ParentName, Type::instantiationMethod method=nullptr);
+ static void initSubclass(Base::Type& toInit,
+ const char* ClassName,
+ const char* ParentName,
+ Type::instantiationMethod method = nullptr);
public:
- /// Construction
- BaseClass();
- BaseClass(const BaseClass&) = default;
- BaseClass& operator=(const BaseClass&) = default;
- /// Destruction
- virtual ~BaseClass();
-
+ /// Construction
+ BaseClass();
+ BaseClass(const BaseClass&) = default;
+ BaseClass& operator=(const BaseClass&) = default;
+ BaseClass(BaseClass&&) = default;
+ BaseClass& operator=(BaseClass&&) = default;
+ /// Destruction
+ virtual ~BaseClass();
};
/**
- * Template that works just like dynamic_cast, but expects the argument to
- * inherit from Base::BaseClass.
- *
- */
-template T * freecad_dynamic_cast(Base::BaseClass * t)
+ * Template that works just like dynamic_cast, but expects the argument to
+ * inherit from Base::BaseClass.
+ *
+ */
+template
+T* freecad_dynamic_cast(Base::BaseClass* t)
{
- if (t && t->isDerivedFrom(T::getClassTypeId()))
+ if (t && t->isDerivedFrom(T::getClassTypeId())) {
return static_cast(t);
- else
+ }
+ else {
return nullptr;
+ }
}
/**
@@ -159,16 +206,18 @@ template T * freecad_dynamic_cast(Base::BaseClass * t)
* inherit from a const Base::BaseClass.
*
*/
-template const T * freecad_dynamic_cast(const Base::BaseClass * t)
+template
+const T* freecad_dynamic_cast(const Base::BaseClass* t)
{
- if (t && t->isDerivedFrom(T::getClassTypeId()))
+ if (t && t->isDerivedFrom(T::getClassTypeId())) {
return static_cast(t);
- else
+ }
+ else {
return nullptr;
+ }
}
-} //namespace Base
-
-#endif // BASE_BASECLASS_H
+} // namespace Base
+#endif // BASE_BASECLASS_H
diff --git a/src/Base/BaseClassPyImp.cpp b/src/Base/BaseClassPyImp.cpp
index 8aca46f3a7..e444c0c84a 100644
--- a/src/Base/BaseClassPyImp.cpp
+++ b/src/Base/BaseClassPyImp.cpp
@@ -36,27 +36,32 @@ std::string BaseClassPy::representation() const
}
-PyObject* BaseClassPy::isDerivedFrom(PyObject *args)
+PyObject* BaseClassPy::isDerivedFrom(PyObject* args)
{
- char *name{};
- if (!PyArg_ParseTuple(args, "s", &name))
+ char* name {};
+ if (!PyArg_ParseTuple(args, "s", &name)) {
return nullptr;
+ }
+ // clang-format off
Base::Type type = Base::Type::fromName(name);
bool valid = (type != Base::Type::badType() && getBaseClassPtr()->getTypeId().isDerivedFrom(type));
return PyBool_FromLong(valid ? 1 : 0);
+ // clang-format on
}
-PyObject* BaseClassPy::getAllDerivedFrom(PyObject *args)
+PyObject* BaseClassPy::getAllDerivedFrom(PyObject* args)
{
- if (!PyArg_ParseTuple(args, ""))
+ if (!PyArg_ParseTuple(args, "")) {
return nullptr;
+ }
std::vector ary;
Base::Type::getAllDerivedFrom(getBaseClassPtr()->getTypeId(), ary);
Py::List res;
- for (const auto & it : ary)
+ for (const auto& it : ary) {
res.append(Py::String(it.getName()));
+ }
return Py::new_reference_to(res);
}
@@ -70,15 +75,17 @@ Py::String BaseClassPy::getModule() const
std::string module(getBaseClassPtr()->getTypeId().getName());
std::string::size_type pos = module.find_first_of("::");
- if (pos != std::string::npos)
+ if (pos != std::string::npos) {
module = std::string(module, 0, pos);
- else
+ }
+ else {
module.clear();
+ }
return {module};
}
-PyObject *BaseClassPy::getCustomAttributes(const char* /*attr*/) const
+PyObject* BaseClassPy::getCustomAttributes(const char* /*attr*/) const
{
return nullptr;
}
@@ -87,5 +94,3 @@ int BaseClassPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
{
return 0;
}
-
-
diff --git a/src/Base/BindingManager.cpp b/src/Base/BindingManager.cpp
index 1b3c34363d..5bac684214 100644
--- a/src/Base/BindingManager.cpp
+++ b/src/Base/BindingManager.cpp
@@ -30,10 +30,11 @@
using namespace Base;
-struct BindingManager::BindingManagerPrivate {
+struct BindingManager::BindingManagerPrivate
+{
std::unordered_map wrapperMapper;
- bool hasWrapper(const void *cptr)
+ bool hasWrapper(const void* cptr)
{
auto it = wrapperMapper.find(cptr);
return it != wrapperMapper.end();
@@ -71,12 +72,11 @@ BindingManager& BindingManager::instance()
BindingManager::BindingManager()
: p(new BindingManagerPrivate)
-{
-}
+{}
BindingManager::~BindingManager() = default;
-bool BindingManager::hasWrapper(const void *cptr)
+bool BindingManager::hasWrapper(const void* cptr)
{
return p->hasWrapper(cptr);
}
diff --git a/src/Base/BindingManager.h b/src/Base/BindingManager.h
index 641c1656c2..74aac9e287 100644
--- a/src/Base/BindingManager.h
+++ b/src/Base/BindingManager.h
@@ -37,13 +37,18 @@ class BaseExport BindingManager
public:
static BindingManager& instance();
- bool hasWrapper(const void *cptr);
+ bool hasWrapper(const void* cptr);
void registerWrapper(const void* cptr, PyObject* pyObj);
void releaseWrapper(const void* cptr, PyObject* pyObj);
PyObject* retrieveWrapper(const void* cptr);
+ BindingManager(const BindingManager&) = delete;
+ BindingManager(BindingManager&&) = delete;
+ BindingManager& operator=(const BindingManager&) = delete;
+ BindingManager& operator=(BindingManager&&) = delete;
+
private:
BindingManager();
~BindingManager();
@@ -52,6 +57,6 @@ private:
std::unique_ptr p;
};
-}
+} // namespace Base
-#endif // BASE_BINDINGMANAGER_H
+#endif // BASE_BINDINGMANAGER_H
diff --git a/src/Base/Bitmask.h b/src/Base/Bitmask.h
index 13b2f40352..1c6c0792b9 100644
--- a/src/Base/Bitmask.h
+++ b/src/Base/Bitmask.h
@@ -44,6 +44,7 @@
@endcode
*/
+// clang-format off
// Based on https://stackoverflow.com/questions/1448396/how-to-use-enums-as-flags-in-c
template struct enum_traits {};
@@ -128,5 +129,6 @@ public:
}
};
}
+// clang-format on
#endif
diff --git a/src/Base/BoundBox.h b/src/Base/BoundBox.h
index 2155d49e67..1ed4dd748c 100644
--- a/src/Base/BoundBox.h
+++ b/src/Base/BoundBox.h
@@ -31,12 +31,13 @@
#include "ViewProj.h"
-namespace Base {
+namespace Base
+{
class ViewProjMethod;
/** The 3D bounding box class. */
-template
+template
class BoundBox3
{
// helper function
@@ -58,47 +59,47 @@ public:
//@}
/** Builds box from pairs of x,y,z values. */
- inline explicit BoundBox3 (Precision fMinX = std::numeric_limits::max(),
- Precision fMinY = std::numeric_limits::max(),
- Precision fMinZ = std::numeric_limits::max(),
- Precision fMaxX = -std::numeric_limits::max(),
- Precision fMaxY = -std::numeric_limits::max(),
- Precision fMaxZ = -std::numeric_limits::max());
- BoundBox3 (const BoundBox3 &rcBB) = default;
- BoundBox3 (BoundBox3 &&rcBB) noexcept = default;
+ inline explicit BoundBox3(Precision fMinX = std::numeric_limits::max(),
+ Precision fMinY = std::numeric_limits::max(),
+ Precision fMinZ = std::numeric_limits::max(),
+ Precision fMaxX = -std::numeric_limits::max(),
+ Precision fMaxY = -std::numeric_limits::max(),
+ Precision fMaxZ = -std::numeric_limits::max());
+ BoundBox3(const BoundBox3& rcBB) = default;
+ BoundBox3(BoundBox3&& rcBB) noexcept = default;
/** Builds box from an array of points. */
- inline BoundBox3 (const Vector3 *pclVect, std::size_t ulCt);
+ inline BoundBox3(const Vector3* pclVect, std::size_t ulCt);
/** Defines a bounding box around the center \a rcCnt with the
* distances \a fDistance in each coordinate.
*/
- BoundBox3 (const Vector3& point, Precision distance);
- ~BoundBox3 ();
+ BoundBox3(const Vector3& point, Precision distance);
+ ~BoundBox3();
/// Assignment operator
- inline BoundBox3& operator = (const BoundBox3 &rcBound) = default;
- inline BoundBox3& operator = (BoundBox3 &&rcBound) noexcept = default;
+ inline BoundBox3& operator=(const BoundBox3& rcBound) = default;
+ inline BoundBox3& operator=(BoundBox3&& rcBound) noexcept = default;
/** Methods for intersection, cuttÃng and union of bounding boxes */
//@{
/** Checks for intersection. */
- inline bool Intersect (const BoundBox3 &rcBB) const;
+ inline bool Intersect(const BoundBox3& rcBB) const;
/** Checks for intersection. */
- inline bool operator && (const BoundBox3 &rcBB) const;
+ inline bool operator&&(const BoundBox3& rcBB) const;
/** Checks for intersection. */
- inline bool Intersect (const BoundBox2d &rcBB) const;
+ inline bool Intersect(const BoundBox2d& rcBB) const;
/** Checks for intersection. */
- inline bool operator && (const BoundBox2d &rcBB) const;
+ inline bool operator&&(const BoundBox2d& rcBB) const;
/** Computes the intersection between two bounding boxes.
- * The result is also a bounding box.
- */
- BoundBox3 Intersected (const BoundBox3 &rcBB) const;
+ * The result is also a bounding box.
+ */
+ BoundBox3 Intersected(const BoundBox3& rcBB) const;
/** The union of two bounding boxes. */
- BoundBox3 United (const BoundBox3 &rcBB) const;
+ BoundBox3 United(const BoundBox3& rcBB) const;
/** Appends the point to the box. The box can grow but not shrink. */
- inline void Add (const Vector3 &rclVect);
+ inline void Add(const Vector3& rclVect);
/** Appends the bounding box to this box. The box can grow but not shrink. */
- inline void Add (const BoundBox3 &rcBB);
+ inline void Add(const BoundBox3& rcBB);
//@}
/** Test methods */
@@ -106,36 +107,56 @@ public:
/** Checks if this point lies inside the box.
* @note It's up to the client programmer to make sure that this bounding box is valid.
*/
- inline bool IsInBox (const Vector3 &rcVct) const;
+ inline bool IsInBox(const Vector3& rcVct) const;
/** Checks if this 3D box lies inside the box.
* @note It's up to the client programmer to make sure that both bounding boxes are valid.
*/
- inline bool IsInBox (const BoundBox3 &rcBB) const;
+ inline bool IsInBox(const BoundBox3& rcBB) const;
/** Checks if this 2D box lies inside the box.
* @note It's up to the client programmer to make sure that both bounding boxes are valid.
*/
- inline bool IsInBox (const BoundBox2d &rcbb) const;
+ inline bool IsInBox(const BoundBox2d& rcbb) const;
/** Checks whether the bounding box is valid. */
- bool IsValid () const;
+ bool IsValid() const;
//@}
- enum OCTANT {OCT_LDB = 0, OCT_RDB, OCT_LUB, OCT_RUB,
- OCT_LDF, OCT_RDF, OCT_LUF, OCT_RUF};
- bool GetOctantFromVector (const Vector3 &rclVct, OCTANT &rclOctant) const;
- BoundBox3 CalcOctant (typename BoundBox3::OCTANT Octant) const;
-
- enum SIDE { LEFT =0, RIGHT=1, TOP=2, BOTTOM=3, FRONT=4, BACK=5, INVALID=255 };
- enum CORNER {
- TLB = 0, // top-left-back
- TLF = 1, // top-left-front
- TRF = 2, // top-right-front
- TRB = 3, // top-right-back
- BLB = 4, // bottom-left-back
- BLF = 5, // bottom-left-front
- BRF = 6, // bottom-right-front
- BRB = 7, // bottom-right-back
+ enum OCTANT
+ {
+ OCT_LDB = 0,
+ OCT_RDB,
+ OCT_LUB,
+ OCT_RUB,
+ OCT_LDF,
+ OCT_RDF,
+ OCT_LUF,
+ OCT_RUF
};
- enum EDGE {
+ bool GetOctantFromVector(const Vector3& rclVct, OCTANT& rclOctant) const;
+ BoundBox3 CalcOctant(typename BoundBox3::OCTANT Octant) const;
+
+ enum SIDE
+ {
+ LEFT = 0,
+ RIGHT = 1,
+ TOP = 2,
+ BOTTOM = 3,
+ FRONT = 4,
+ BACK = 5,
+ INVALID = 255
+ };
+ enum CORNER
+ {
+ TLB = 0, // top-left-back
+ TLF = 1, // top-left-front
+ TRF = 2, // top-right-front
+ TRB = 3, // top-right-back
+ BLB = 4, // bottom-left-back
+ BLF = 5, // bottom-left-front
+ BRF = 6, // bottom-right-front
+ BRB = 7, // bottom-right-back
+ };
+ enum EDGE
+ {
TLB_TLF = 0,
TLF_TRF = 1,
TRF_TRB = 2,
@@ -153,52 +174,52 @@ public:
/**
* Returns the corner point \a usPoint.
*/
- inline Vector3 CalcPoint (unsigned short usPoint) const;
+ inline Vector3 CalcPoint(unsigned short usPoint) const;
/** Returns the plane of the given side. */
- void CalcPlane (unsigned short usPlane, Vector3& rBase,
- Vector3& rNormal) const;
+ void
+ CalcPlane(unsigned short usPlane, Vector3& rBase, Vector3& rNormal) const;
/** Calculates the two points of an edge.
*/
- bool CalcEdge (unsigned short usEdge, Vector3& rcP0, Vector3& rcP1) const;
+ bool CalcEdge(unsigned short usEdge, Vector3& rcP0, Vector3& rcP1) const;
/** Intersection point of an inner search ray with the bounding box, built of
* the base \a rcVct and the direction \a rcVctDir. \a rcVct must lie inside the
* bounding box.
*/
- bool IntersectionPoint (const Vector3 &rcVct,
- const Vector3 &rcVctDir,
- Vector3& cVctRes,
- Precision epsilon) const;
+ bool IntersectionPoint(const Vector3& rcVct,
+ const Vector3& rcVctDir,
+ Vector3& cVctRes,
+ Precision epsilon) const;
/** Checks for intersection with line incl. search tolerance. */
- bool IsCutLine (const Vector3& rcBase,
- const Vector3& rcDir,
- Precision fTolerance = 0.0F) const;
+ bool IsCutLine(const Vector3& rcBase,
+ const Vector3& rcDir,
+ Precision fTolerance = 0.0F) const;
/** Checks if this plane specified by (point,normal) cuts this box.
* @note It's up to the client programmer to make sure that this bounding box is valid.
*/
- inline bool IsCutPlane (const Vector3 &rclBase,
- const Vector3 &rclNormal) const;
+ inline bool IsCutPlane(const Vector3& rclBase,
+ const Vector3& rclNormal) const;
/** Computes the intersection points of line and bounding box. */
- bool IntersectWithLine (const Vector3& rcBase,
- const Vector3& rcDir,
- Vector3& rcP0,
- Vector3& rcP1) const;
+ bool IntersectWithLine(const Vector3& rcBase,
+ const Vector3& rcDir,
+ Vector3& rcP0,
+ Vector3& rcP1) const;
/** Computes the intersection point of line and a plane of the bounding box. */
- bool IntersectPlaneWithLine (unsigned short usSide,
- const Vector3& rcBase,
- const Vector3& rcDir,
- Vector3& rcP0) const;
+ bool IntersectPlaneWithLine(unsigned short usSide,
+ const Vector3& rcBase,
+ const Vector3& rcDir,
+ Vector3& rcP0) const;
/** Returns the side of the bounding box the ray exits. */
- typename BoundBox3::SIDE GetSideFromRay (const Vector3 &rclPt,
- const Vector3 &rclDir) const;
+ typename BoundBox3::SIDE GetSideFromRay(const Vector3& rclPt,
+ const Vector3& rclDir) const;
/** Returns the side of the bounding box the ray exits. */
- typename BoundBox3::SIDE GetSideFromRay (const Vector3 &rclPt,
- const Vector3 &rclDir,
- Vector3& rcInt) const;
+ typename BoundBox3::SIDE GetSideFromRay(const Vector3& rclPt,
+ const Vector3& rclDir,
+ Vector3& rcInt) const;
/**
* Searches for the closest point of the bounding box.
*/
- Vector3 ClosestPoint (const Vector3 &rclPt) const;
+ Vector3 ClosestPoint(const Vector3& rclPt) const;
/** Projects the box onto a plane and returns a 2D box. */
BoundBox2d ProjectBox(const ViewProjMethod* proj) const;
/** Transform the corners of this box with the given matrix and create a new bounding box.
@@ -207,56 +228,56 @@ public:
BoundBox3 Transformed(const Matrix4D& mat) const;
/** Returns the center of the box. */
- inline Vector3 GetCenter () const;
+ inline Vector3 GetCenter() const;
/** Returns the minimum point of the box. */
- inline Vector3 GetMinimum () const;
+ inline Vector3 GetMinimum() const;
/** Returns the maximum point of the box. */
- inline Vector3 GetMaximum () const;
+ inline Vector3 GetMaximum() const;
/** Compute the diagonal length of this bounding box.
* @note It's up to the client programmer to make sure that this bounding box is valid.
*/
- inline Precision CalcDiagonalLength () const;
- void SetVoid ();
+ inline Precision CalcDiagonalLength() const;
+ void SetVoid();
/** Enlarges the box with \a fLen. */
- inline void Enlarge (Precision fLen);
+ inline void Enlarge(Precision fLen);
/** Shrinks the box with \a fLen. */
- inline void Shrink (Precision fLen);
+ inline void Shrink(Precision fLen);
/** Calculates expansion in x-direction. */
- inline Precision LengthX () const;
+ inline Precision LengthX() const;
/** Calculates expansion in y-direction. */
- inline Precision LengthY () const;
+ inline Precision LengthY() const;
/** Calculates expansion in z-direction. */
- inline Precision LengthZ () const;
+ inline Precision LengthZ() const;
/** Calculates the volume. If the box is invalid a negative value is returned */
- inline Precision Volume () const;
+ inline Precision Volume() const;
/** Moves in x-direction. */
- inline void MoveX (Precision value);
+ inline void MoveX(Precision value);
/** Moves in y-direction. */
- inline void MoveY (Precision value);
+ inline void MoveY(Precision value);
/** Moves in z-direction. */
- inline void MoveZ (Precision value);
+ inline void MoveZ(Precision value);
/** Scales in x-direction. */
- inline void ScaleX (Precision value);
+ inline void ScaleX(Precision value);
/** Scales in y-direction. */
- inline void ScaleY (Precision value);
+ inline void ScaleY(Precision value);
/** Scales in z-direction. */
- inline void ScaleZ (Precision value);
+ inline void ScaleZ(Precision value);
/** Prints the values to stream. */
- void Print (std::ostream&) const;
+ void Print(std::ostream&) const;
};
-template
+template
bool BoundBox3::isOnRayW(Precision min, Precision max, Precision val)
{
// Checks if point val lies on the ray [min,max]
return ((min <= val) && (val <= max));
}
-template
+template
bool BoundBox3::isOnRayS(Precision min, Precision max, Precision val)
{
// Checks if point val lies on the ray [min,max[
@@ -264,26 +285,33 @@ bool BoundBox3::isOnRayS(Precision min, Precision max, Precision val)
}
// NOLINTBEGIN(bugprone-easily-swappable-parameters)
-template
-inline BoundBox3::BoundBox3 (Precision fMinX, Precision fMinY, Precision fMinZ,
- Precision fMaxX, Precision fMaxY, Precision fMaxZ)
- : MinX(fMinX), MinY(fMinY), MinZ(fMinZ),
- MaxX(fMaxX), MaxY(fMaxY), MaxZ(fMaxZ)
-{
-}
+template
+inline BoundBox3::BoundBox3(Precision fMinX,
+ Precision fMinY,
+ Precision fMinZ,
+ Precision fMaxX,
+ Precision fMaxY,
+ Precision fMaxZ)
+ : MinX(fMinX)
+ , MinY(fMinY)
+ , MinZ(fMinZ)
+ , MaxX(fMaxX)
+ , MaxY(fMaxY)
+ , MaxZ(fMaxZ)
+{}
// NOLINTEND(bugprone-easily-swappable-parameters)
-template
-inline BoundBox3::BoundBox3 (const Vector3 *pclVect, std::size_t ulCt)
- : MinX( std::numeric_limits::max())
- , MinY( std::numeric_limits::max())
- , MinZ( std::numeric_limits::max())
- , MaxX(-std::numeric_limits::max())
- , MaxY(-std::numeric_limits::max())
- , MaxZ(-std::numeric_limits::max())
+template
+inline BoundBox3::BoundBox3(const Vector3* pclVect, std::size_t ulCt)
+ : MinX(std::numeric_limits::max())
+ , MinY(std::numeric_limits::max())
+ , MinZ(std::numeric_limits::max())
+ , MaxX(-std::numeric_limits::max())
+ , MaxY(-std::numeric_limits::max())
+ , MaxZ(-std::numeric_limits::max())
{
- const Vector3 *pI = nullptr;
- const Vector3 *pEnd = pclVect + ulCt;
+ const Vector3* pI = nullptr;
+ const Vector3* pEnd = pclVect + ulCt;
for (pI = pclVect; pI < pEnd; ++pI) {
MinX = std::min(MinX, pI->x);
MinY = std::min(MinY, pI->y);
@@ -294,22 +322,21 @@ inline BoundBox3::BoundBox3 (const Vector3 *pclVect, std::
}
}
-template
-inline BoundBox3::BoundBox3 (const Vector3& point, Precision distance)
+template
+inline BoundBox3::BoundBox3(const Vector3& point, Precision distance)
: MinX(point.x - distance)
, MinY(point.y - distance)
, MinZ(point.z - distance)
, MaxX(point.x + distance)
, MaxY(point.y + distance)
, MaxZ(point.z + distance)
-{
-}
+{}
-template
-inline BoundBox3::~BoundBox3 () = default;
+template
+inline BoundBox3::~BoundBox3() = default;
-template
-inline bool BoundBox3::Intersect (const BoundBox3 &rcBB) const
+template
+inline bool BoundBox3::Intersect(const BoundBox3& rcBB) const
{
if (rcBB.MaxX < this->MinX || rcBB.MinX > this->MaxX) {
return false;
@@ -323,14 +350,14 @@ inline bool BoundBox3::Intersect (const BoundBox3 &rcBB) c
return true;
}
-template
-bool BoundBox3::operator && (const BoundBox3 &rcBB) const
+template
+bool BoundBox3::operator&&(const BoundBox3& rcBB) const
{
return Intersect(rcBB);
}
-template
-inline bool BoundBox3::Intersect (const BoundBox2d &rcBB) const
+template
+inline bool BoundBox3::Intersect(const BoundBox2d& rcBB) const
{
if (rcBB.MaxX < this->MinX || rcBB.MinX > this->MaxX) {
return false;
@@ -341,45 +368,45 @@ inline bool BoundBox3::Intersect (const BoundBox2d &rcBB) const
return true;
}
-template
-inline bool BoundBox3::operator && (const BoundBox2d &rcBB) const
+template
+inline bool BoundBox3::operator&&(const BoundBox2d& rcBB) const
{
return Intersect(rcBB);
}
-template
+template
inline BoundBox3
-BoundBox3::Intersected(const BoundBox3 &rcBB) const
+BoundBox3::Intersected(const BoundBox3& rcBB) const
{
BoundBox3 cBBRes;
- cBBRes.MinX = std::max (MinX, rcBB.MinX);
- cBBRes.MaxX = std::min (MaxX, rcBB.MaxX);
- cBBRes.MinY = std::max (MinY, rcBB.MinY);
- cBBRes.MaxY = std::min (MaxY, rcBB.MaxY);
- cBBRes.MinZ = std::max (MinZ, rcBB.MinZ);
- cBBRes.MaxZ = std::min (MaxZ, rcBB.MaxZ);
+ cBBRes.MinX = std::max(MinX, rcBB.MinX);
+ cBBRes.MaxX = std::min(MaxX, rcBB.MaxX);
+ cBBRes.MinY = std::max(MinY, rcBB.MinY);
+ cBBRes.MaxY = std::min(MaxY, rcBB.MaxY);
+ cBBRes.MinZ = std::max(MinZ, rcBB.MinZ);
+ cBBRes.MaxZ = std::min(MaxZ, rcBB.MaxZ);
return cBBRes;
}
-template
-inline BoundBox3 BoundBox3::United(const BoundBox3 &rcBB) const
+template
+inline BoundBox3 BoundBox3::United(const BoundBox3& rcBB) const
{
BoundBox3 cBBRes;
- cBBRes.MinX = std::min (MinX, rcBB.MinX);
- cBBRes.MaxX = std::max (MaxX, rcBB.MaxX);
- cBBRes.MinY = std::min (MinY, rcBB.MinY);
- cBBRes.MaxY = std::max (MaxY, rcBB.MaxY);
- cBBRes.MinZ = std::min (MinZ, rcBB.MinZ);
- cBBRes.MaxZ = std::max (MaxZ, rcBB.MaxZ);
+ cBBRes.MinX = std::min(MinX, rcBB.MinX);
+ cBBRes.MaxX = std::max(MaxX, rcBB.MaxX);
+ cBBRes.MinY = std::min(MinY, rcBB.MinY);
+ cBBRes.MaxY = std::max(MaxY, rcBB.MaxY);
+ cBBRes.MinZ = std::min