53 const QString& classId,
54 const char*
name =
nullptr);
60 const std::vector<Eigen::Vector3d>&
points);
63 const std::vector<Eigen::Vector3d>&
points);
66 const std::vector<Eigen::Vector3d>&
points);
75 const Eigen::Vector3d&
color);
82 std::vector<Eigen::Vector3d>&
points);
88 std::vector<Eigen::Vector3d>&
normals);
95 std::vector<Eigen::Matrix3d>& covariances);
105 std::vector<Eigen::Vector3d>&
points,
116 std::vector<Eigen::Vector3d>&
points,
117 const Eigen::Vector3d& center);
125 std::vector<Eigen::Vector3d>&
points,
126 const Eigen::Vector3d& center);
132 std::vector<Eigen::Vector3d>&
normals);
139 std::vector<Eigen::Matrix3d>& covariances);
144 virtual Eigen::Vector3d
GetMinBound()
const {
return Eigen::Vector3d(); }
147 virtual Eigen::Vector3d
GetMaxBound()
const {
return Eigen::Vector3d(); }
150 virtual Eigen::Vector3d
GetCenter()
const {
return Eigen::Vector3d(); }
166 bool relative =
true) {
187 const Eigen::Vector3d& center) {
191 return Rotate(R, GetCenter());
196 const Eigen::Vector3d& rotation);
199 const Eigen::Vector3d& rotation);
202 const Eigen::Vector3d& rotation);
205 const Eigen::Vector3d& rotation);
208 const Eigen::Vector3d& rotation);
211 const Eigen::Vector3d& rotation);
214 const Eigen::Vector3d& rotation);
217 const Eigen::Vector4d& rotation);
220 const Eigen::Vector3d& rotation);
259 DP_NOTIFY_OTHER_ON_DELETE = 1,
261 DP_NOTIFY_OTHER_ON_UPDATE =
266 DP_PARENT_OF_OTHER = 24,
306 int dependencyFlags = DP_PARENT_OF_OTHER,
307 int insertIndex = -1);
313 return static_cast<unsigned>(m_children.size());
326 return (childPos < getChildrenNumber() ? m_children[childPos]
340 using Shared = QSharedPointer<ccHObject>;
353 bool recursive =
false,
355 bool strict =
false)
const;
385 void swapChildren(
unsigned firstChildIndex,
unsigned secondChildIndex);
393 bool forceFatherDependent =
false);
397 return (m_children.empty() ?
nullptr : m_children.front());
401 return (m_children.empty() ?
nullptr : m_children.back());
433 bool onlyEnabledChildren =
true);
464 bool withGLFeatures =
false,
bool onlyEnabledChildren =
true);
519 #define ccHObject_recursive_call0(baseName, recursiveName) \
520 inline virtual void recursiveName() { \
522 for (Container::iterator it = m_children.begin(); \
523 it != m_children.end(); ++it) \
524 (*it)->recursiveName(); \
528 #define ccHObject_recursive_call1(baseName, param1Type, recursiveName) \
529 inline virtual void recursiveName(param1Type p) { \
531 for (Container::iterator it = m_children.begin(); \
532 it != m_children.end(); ++it) \
533 (*it)->recursiveName(p); \
541 setSelected_recursive)
543 toggleActivation_recursive)
545 toggleVisibility_recursive)
547 toggleColors_recursive)
549 resetGLTransformationHistory,
550 resetGLTransformationHistory_recursive)
553 toggleNormals_recursive)
559 toggleShowName_recursive);
577 bool toFile(QFile& out,
short dataVersion)
const override;
617 m_selectionBehavior = mode;
622 return m_selectionBehavior;
632 return m_glTransHistory;
636 m_glTransHistory = mat;
640 m_glTransHistory.toIdentity();
745 size_t count = origin.size();
746 for (
size_t i = 0; i <
count; ++i) {
748 bool isSiblingOfAnotherOne =
false;
749 for (
size_t j = 0; j <
count; ++j) {
750 if (i != j && origin[j]->isAncestorOf(origin[i])) {
751 isSiblingOfAnotherOne =
true;
756 if (!isSiblingOfAnotherOne) {
757 dest.
addChild(origin[i], dependencyFlags);
float PointCoordinateType
Type of the coordinates of a (N-D) point.
int64_t CV_CLASS_ENUM
Type of object type flags (64 bits)
Generic interface for (3D) drawable entities.
Float version of ccGLMatrixTpl.
Hierarchical CLOUDVIEWER Object.
virtual void notifyGeometryUpdate()
virtual bool toFile_MeOnly(QFile &out, short dataVersion) const
Save own object data.
static Eigen::Vector3d ComputeCenter(const std::vector< Eigen::Vector3d > &points)
Computer center of a list of points.
static void RotatePoints(const Eigen::Matrix3d &R, std::vector< Eigen::Vector3d > &points, const Eigen::Vector3d ¢er)
Rotate all points with the rotation matrix R.
static Eigen::Matrix3d GetRotationMatrixFromYXZ(const Eigen::Vector3d &rotation)
Get Rotation Matrix from YXZ RotationType.
void setLineWidthRecursive(PointCoordinateType width)
virtual void onDeletionOf(const ccHObject *obj)
This method is called when another object is deleted.
virtual SelectionBehavior getSelectionBehavior() const
Returns selection behavior.
static void ResizeAndPaintUniformColor(std::vector< Eigen::Vector3d > &colors, std::size_t size, const Eigen::Vector3d &color)
Resizes the colors vector and paints a uniform color.
virtual ccHObject & Scale(const double s, const Eigen::Vector3d ¢er)
Apply scaling to the geometry coordinates. Given a scaling factor , and center , a given point is tr...
bool fromFileNoChildren(QFile &in, short dataVersion, int flags, LoadedIDMap &oldToNewIDMap)
Custom version of ccSerializableObject::fromFile.
void hideBB(CC_DRAW_CONTEXT context)
virtual ccBBox getOwnBB(bool withGLFeatures=false)
Returns the entity's own bounding-box.
virtual const ccGLMatrix & getGLTransformationHistory() const
Returns the transformation 'history' matrix.
static Eigen::Matrix3d GetRotationMatrixFromYZX(const Eigen::Vector3d &rotation)
Get Rotation Matrix from YZX RotationType.
virtual void drawMeOnly(CC_DRAW_CONTEXT &context)
Draws the entity only (not its children)
void draw(CC_DRAW_CONTEXT &context) override
Draws entity and its children.
QSharedPointer< ccHObject > Shared
Shared pointer.
ccHObject * find(unsigned uniqueID)
Finds an entity in this object hierarchy.
void setRemoveType(CC_DRAW_CONTEXT &context)
bool toFile(QFile &out, short dataVersion) const override
Saves data to binary stream.
virtual void setParent(ccHObject *anObject)
Sets parent object.
void setHideShowType(CC_DRAW_CONTEXT &context)
bool m_isDeleting
Flag to safely handle dependencies when the object is being deleted.
SelectionBehavior
Behavior when selected.
virtual ccBBox GetAxisAlignedBoundingBox() const
Returns an axis-aligned bounding box of the geometry.
virtual bool isShareable() const
Returns whether object is shareable or not.
bool getAbsoluteGLTransformation(ccGLMatrix &trans) const
virtual bool isDisplayed() const
Returns whether the object is actually displayed (visible) or not.
ccHObject * getLastChild() const
Shortcut: returns last child.
ccGLMatrix m_glTransHistory
Cumulative GL transformation.
static Eigen::Vector3d ComputeMaxBound(const std::vector< Eigen::Vector3d > &points)
Compute max bound of a list points.
ENTITY_TYPE getEntityType() const
void transferChildren(ccHObject &newParent, bool forceFatherDependent=false)
Transfer all children to another parent.
virtual ecvOrientedBBox GetOrientedBoundingBox() const
int getChildIndex(const ccHObject *aChild) const
Returns child index.
void removeFromRenderScreen(bool recursive=true)
static ccHObject * New(const QString &pluginId, const QString &classId, const char *name=nullptr)
Static factory (version to be used by external plugin factories)
static Eigen::Matrix3d GetRotationMatrixFromEulerAngle(const Eigen::Vector3d &rotation)
Get Rotation Matrix from Euler angle.
virtual Eigen::Vector3d GetCenter() const
Returns the center of the geometry coordinates.
int getIndex() const
Returns index relatively to its parent or -1 if no parent.
bool isSerializable() const override
Returns whether object is serializable of not.
virtual ccHObject & Translate(const Eigen::Vector3d &translation, bool relative=true)
Apply translation to the geometry coordinates.
int getDependencyFlagsWith(const ccHObject *otherObject)
Returns the dependency flags with a given object.
virtual void onUpdateOf(ccHObject *obj)
This method is called when another object (geometry) is updated.
void removeAllChildren()
Removes all children.
SelectionBehavior m_selectionBehavior
Selection behavior.
virtual short minimumFileVersion_MeOnly() const
std::map< ccHObject *, int > m_dependencies
Dependencies map.
short minimumFileVersion() const override
Returns the minimum file version required to save this instance.
virtual ccBBox getDisplayBB_recursive(bool relative)
Returns the bounding-box of this entity and it's children WHEN DISPLAYED.
void removeDependencyWith(ccHObject *otherObject)
Removes any dependency flags with a given object.
virtual ccHObject & Rotate(const Eigen::Matrix3d &R, const Eigen::Vector3d ¢er)
Apply rotation to the geometry coordinates and normals. Given a rotation matrix , and center ,...
void addDependency(ccHObject *otherObject, int flags, bool additive=true)
Adds a new dependence (additive or not)
ccHObject * getFirstChild() const
Shortcut: returns first child.
std::vector< Shared > SharedContainer
Shared instances container (for children, etc.)
void detachChild(ccHObject *child)
Detaches a specific child.
static void TransformNormals(const Eigen::Matrix4d &transformation, std::vector< Eigen::Vector3d > &normals)
Transforms the normals with the transformation matrix.
virtual ccBBox getOwnFitBB(ccGLMatrix &trans)
Returns best-fit bounding-box (if available)
bool isAncestorOf(const ccHObject *anObject) const
Returns true if the current object is an ancestor of the specified one.
virtual Eigen::Vector2d GetMax2DBound() const
virtual ~ccHObject() override
Default destructor.
QString getViewId() const
void applyGLTransformation_recursive(const ccGLMatrix *trans=nullptr)
Applies the active OpenGL transformation to the entity (recursive)
virtual ccHObject & Scale(const double s)
unsigned getChildrenNumber() const
Returns the number of children.
void setPointSizeRecursive(int pSize)
virtual bool addChild(ccHObject *child, int dependencyFlags=DP_PARENT_OF_OTHER, int insertIndex=-1)
Adds a child.
unsigned int getChildCountRecursive() const
Returns the total number of children under this object recursively.
virtual bool fromFile_MeOnly(QFile &in, short dataVersion, int flags, LoadedIDMap &oldToNewIDMap)
Loads own object data.
virtual unsigned getUniqueIDForDisplay() const
Returns object unqiue ID used for display.
virtual void setGLTransformationHistory(const ccGLMatrix &mat)
Sets the transformation 'history' matrix (handle with care!)
void getTypeID_recursive(std::vector< removeInfo > &rmInfos, bool relative)
void setRedrawFlagRecursive(bool redraw=false)
void updateNameIn3DRecursive()
static void ScalePoints(const double scale, std::vector< Eigen::Vector3d > &points, const Eigen::Vector3d ¢er)
Scale the coordinates of all points by the scaling factor scale.
static Eigen::Matrix3d GetRotationMatrixFromXYZ(const Eigen::Vector3d &rotation)
Get Rotation Matrix from XYZ RotationType.
ccHObject(const ccHObject &object)
Copy constructor.
virtual bool IsEmpty() const
virtual void setSelectionBehavior(SelectionBehavior mode)
Sets selection behavior (when displayed)
static Eigen::Matrix3d GetRotationMatrixFromZXY(const Eigen::Vector3d &rotation)
Get Rotation Matrix from ZXY RotationType.
static Eigen::Matrix3d GetRotationMatrixFromQuaternion(const Eigen::Vector4d &rotation)
Get Rotation Matrix from Quaternion.
static Eigen::Vector3d ComputeMinBound(const std::vector< Eigen::Vector3d > &points)
Compute min bound of a list points.
virtual void drawBB(CC_DRAW_CONTEXT &context, const ecvColor::Rgb &col)
Draws the entity (and its children) bounding-box.
DEPENDENCY_FLAGS
Dependency flags.
unsigned findMaxUniqueID_recursive() const
Returns the max 'unique ID' of this entity and its siblings.
virtual ccBBox getBB_recursive(bool withGLFeatures=false, bool onlyEnabledChildren=true)
Returns the bounding-box of this entity and it's children.
virtual Eigen::Vector3d GetMaxBound() const
Returns max bounds for geometry coordinates.
ccHObject * getParent() const
Returns parent object.
void detachAllChildren()
Removes a specific child.
ccHObject(QString name=QString())
Default constructor.
virtual bool isBranchEnabled() const
Returns whether the object and all its ancestors are enabled.
void getTypeID_recursive(std::vector< hideInfo > &hdInfos, bool relative)
virtual Eigen::Vector3d GetMinBound() const
Returns min bounds for geometry coordinates.
static Eigen::Matrix3d GetRotationMatrixFromAxisAngle(const Eigen::Vector3d &rotation)
Get Rotation Matrix from AxisAngle RotationType.
void transferChild(ccHObject *child, ccHObject &newParent)
Transfer a given child to another parent.
static void TransformPoints(const Eigen::Matrix4d &transformation, std::vector< Eigen::Vector3d > &points)
Transforms all points with the transformation matrix.
virtual void redrawDisplay(bool forceRedraw=true, bool only2D=false)
Redraws associated display.
void removeDependencyFlag(ccHObject *otherObject, DEPENDENCY_FLAGS flag)
Removes a given dependency flag.
ccHObject * m_parent
Parent.
virtual GlobalBoundingBox getGlobalBB_recursive(bool withGLFeatures=false, bool onlyEnabledChildren=true)
Returns the global bounding-box of this entity and it's children.
virtual ccHObject & Rotate(const Eigen::Matrix3d &R)
static void TranslatePoints(const Eigen::Vector3d &translation, std::vector< Eigen::Vector3d > &points, bool relative)
Apply translation to the geometry coordinates.
void removeChild(ccHObject *child)
void removeChild(int pos)
Removes a specific child given its index.
virtual GlobalBoundingBox getOwnGlobalBB(bool withGLFeatures=false)
virtual QIcon getIcon() const
Returns the icon associated to this entity.
unsigned filterChildren(Container &filteredChildren, bool recursive=false, CV_CLASS_ENUM filter=CV_TYPES::OBJECT, bool strict=false) const
Collects the children corresponding to a certain pattern.
virtual void drawNameIn3D()
Draws the entity name in 3D.
virtual ccHObject & Transform(const Eigen::Matrix4d &transformation)
Apply transformation (4x4 matrix) to the geometry coordinates.
static ccHObject * New(CV_CLASS_ENUM objectType, const char *name=nullptr)
Static factory.
bool pushDisplayState() override
Pushes the current display state (overridden)
void swapChildren(unsigned firstChildIndex, unsigned secondChildIndex)
Swaps two children.
static void RotateNormals(const Eigen::Matrix3d &R, std::vector< Eigen::Vector3d > &normals)
Rotate all normals with the rotation matrix R.
static void RotateCovariances(const Eigen::Matrix3d &R, std::vector< Eigen::Matrix3d > &covariances)
Rotate all covariance matrices with the rotation matrix R.
bool fromFile(QFile &in, short dataVersion, int flags, LoadedIDMap &oldToNewIDMap) override
Loads data from binary stream.
virtual void applyGLTransformation(const ccGLMatrix &trans)
Applies a GL transformation to the entity.
virtual bool getOwnGlobalBB(CCVector3d &minCorner, CCVector3d &maxCorner)
std::vector< ccHObject * > Container
Standard instances container (for children, etc.)
virtual void resetGLTransformationHistory()
Resets the transformation 'history' matrix.
void setForceRedrawRecursive(bool redraw=false)
static Eigen::Matrix3d GetRotationMatrixFromZYX(const Eigen::Vector3d &rotation)
Get Rotation Matrix from ZYX RotationType.
void popDisplayState(bool apply=true) override
Pops the last pushed display state (overridden)
void showBB(CC_DRAW_CONTEXT context)
virtual Eigen::Vector2d GetMin2DBound() const
ccHObject * getChild(unsigned childPos) const
Returns the ith child.
Container m_children
Children.
static void TransformCovariances(const Eigen::Matrix4d &transformation, std::vector< Eigen::Matrix3d > &covariances)
Transforms all covariance matrices with the transformation.
CV_CLASS_ENUM getClassID() const override
Returns class ID.
static Eigen::Matrix3d GetRotationMatrixFromXZY(const Eigen::Vector3d &rotation)
Get Rotation Matrix from XZY RotationType.
bool isGroup() const
Returns whether the instance is a group.
void hideObject_recursive(bool recursive)
Generic "CLOUDVIEWER Object" template.
virtual unsigned getUniqueID() const
Returns object unique ID.
virtual CV_CLASS_ENUM getClassID() const =0
Returns class ID.
QMultiMap< unsigned, unsigned > LoadedIDMap
Map of loaded unique IDs (old ID --> new ID)
#define ccHObject_recursive_call1(baseName, param1Type, recursiveName)
void ConvertToGroup(const ccHObject::Container &origin, ccHObject &dest, int dependencyFlags=ccHObject::DP_NONE)
Puts all entities inside a container in a group.
#define ccHObject_recursive_call0(baseName, recursiveName)