ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ecvHObject.cpp
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #include "ecvHObject.h"
9 
10 #include "ecvBBox.h"
11 
12 // Objects handled by factory
13 #include "ecv2DLabel.h"
14 #include "ecv2DViewportLabel.h"
15 #include "ecvBox.h"
16 #include "ecvCameraSensor.h"
17 #include "ecvCircle.h"
18 #include "ecvCoordinateSystem.h"
19 #include "ecvCustomObject.h"
20 #include "ecvCylinder.h"
21 #include "ecvDisc.h"
22 #include "ecvDish.h"
23 #include "ecvDisplayTools.h"
24 #include "ecvExternalFactory.h"
25 #include "ecvExtru.h"
26 #include "ecvFacet.h"
27 #include "ecvGBLSensor.h"
28 #include "ecvGuiParameters.h"
29 #include "ecvHObjectCaster.h"
30 #include "ecvImage.h"
32 #include "ecvKdTree.h"
33 #include "ecvMaterialSet.h"
34 #include "ecvMeshGroup.h"
35 #include "ecvPlane.h"
36 #include "ecvPointCloud.h"
37 #include "ecvPolyline.h"
38 #include "ecvQuadric.h"
39 #include "ecvSphere.h"
40 #include "ecvSubMesh.h"
41 #include "ecvTorus.h"
42 
43 // CV_CORE_LIB
44 #include <CVTools.h>
45 #include <Eigen.h>
46 #include <Logging.h>
47 
48 #include <Eigen/Dense>
49 #include <numeric>
50 
51 // Qt
52 #include <QIcon>
53 
54 ccHObject::ccHObject(QString name /*=QString()*/)
55  : ccObject(name),
57  m_parent(nullptr),
58  m_selectionBehavior(SELECTION_AA_BBOX),
59  m_isDeleting(false) {
60  setVisible(false);
61  lockVisibility(true);
63 }
64 
66  : ccObject(object),
67  ccDrawableObject(object),
68  m_parent(nullptr),
69  m_selectionBehavior(object.m_selectionBehavior),
70  m_isDeleting(false) {
72 }
73 
75  m_isDeleting = true;
76 
77  // process dependencies
78  for (std::map<ccHObject*, int>::const_iterator it = m_dependencies.begin();
79  it != m_dependencies.end(); ++it) {
80  assert(it->first);
81  // notify deletion to other object?
82  if ((it->second & DP_NOTIFY_OTHER_ON_DELETE) ==
84  it->first->onDeletionOf(this);
85  }
86 
87  // delete other object?
88  if ((it->second & DP_DELETE_OTHER) == DP_DELETE_OTHER) {
89  it->first->removeDependencyFlag(
90  this,
91  DP_NOTIFY_OTHER_ON_DELETE); // in order to avoid any loop!
92  // delete object
93  if (it->first->isShareable())
94  dynamic_cast<CCShareable*>(it->first)->release();
95  else
96  delete it->first;
97  }
98  }
99  m_dependencies.clear();
100 
102 }
103 
105  // the associated display bounding-box is (potentially) deprecated!!!
107  return;
108  }
109 
114  }
115 
116  // process dependencies
117  for (std::map<ccHObject*, int>::const_iterator it = m_dependencies.begin();
118  it != m_dependencies.end(); ++it) {
119  assert(it->first);
120  // notify deletion to other object?
121  if ((it->second & DP_NOTIFY_OTHER_ON_UPDATE) ==
123  it->first->onUpdateOf(this);
124  }
125  }
126 }
127 
128 ccHObject* ccHObject::New(CV_CLASS_ENUM objectType, const char* name /*=0*/) {
129  switch (objectType) {
131  return new ccHObject(name);
133  return new ccPointCloud(name);
134  case CV_TYPES::MESH:
135  // warning: no associated vertices --> retrieved later
136  return new ccMesh(nullptr);
137  case CV_TYPES::SUB_MESH:
138  // warning: no associated mesh --> retrieved later
139  return new ccSubMesh(nullptr);
141  // warning: deprecated
142  CVLog::Warning("[ccHObject::New] Mesh groups are deprecated!");
143  // warning: no associated vertices --> retrieved later
144  return new ccMeshGroup();
145  case CV_TYPES::POLY_LINE:
146  // warning: no associated vertices --> retrieved later
147  return new ccPolyline(nullptr);
148  case CV_TYPES::CIRCLE:
149  return new ccCircle();
150  case CV_TYPES::FACET:
151  return new ccFacet();
153  return new ccMaterialSet();
155  return new NormsTableType();
157  return new NormsIndexesTableType();
159  return new ColorsTableType();
161  return new TextureCoordsContainer();
162  case CV_TYPES::IMAGE:
163  return new ccImage();
165  return nullptr; // deprecated
167  // warning: default sensor type set in constructor (see
168  // CCLib::GroundBasedLidarSensor::setRotationOrder)
169  return new ccGBLSensor();
171  return new ccCameraSensor();
172  case CV_TYPES::LABEL_2D:
173  return new cc2DLabel(name);
175  return new cc2DViewportObject(name);
177  return new cc2DViewportLabel(name);
178  case CV_TYPES::PLANE:
179  return new ccPlane(name);
180  case CV_TYPES::SPHERE:
181  return new ccSphere(name);
182  case CV_TYPES::TORUS:
183  return new ccTorus(name);
184  case CV_TYPES::CYLINDER:
186  return new ccCylinder(name);
187  case CV_TYPES::BOX:
188  return new ccBox(name);
189  case CV_TYPES::CONE:
190  return new ccCone(name);
191  case CV_TYPES::DISC:
192  return new ccDisc(name);
193  case CV_TYPES::DISH:
194  return new ccDish(name);
195  case CV_TYPES::EXTRU:
196  return new ccExtru(name);
197  case CV_TYPES::QUADRIC:
198  return new ccQuadric(name);
202  return new ccCustomHObject(name);
204  return new ccCustomLeafObject(name);
206  return new ccCoordinateSystem(name);
209  // construction this way is not supported (yet)
211  "[ccHObject::New] This object (type %i) can't be "
212  "constructed this way (yet)!",
213  objectType);
214  break;
215  default:
216  // unhandled ID
217  CVLog::ErrorDebug("[ccHObject::New] Invalid object type (%i)!",
218  objectType);
219  break;
220  }
221 
222  return nullptr;
223 }
224 
225 ccHObject* ccHObject::New(const QString& pluginId,
226  const QString& classId,
227  const char* name) {
228  ccExternalFactory::Container::Shared externalFactories =
230  if (!externalFactories) {
231  return nullptr;
232  }
233 
234  ccExternalFactory* factory = externalFactories->getFactoryByName(pluginId);
235  if (!factory) {
236  return nullptr;
237  }
238 
239  ccHObject* obj = factory->buildObject(classId);
240 
241  if (name && obj) {
242  obj->setName(name);
243  }
244 
245  return obj;
246 }
247 
248 QIcon ccHObject::getIcon() const { return QIcon(); }
249 
251 void ccHObject::ResizeAndPaintUniformColor(std::vector<Eigen::Vector3d>& colors,
252  const size_t size,
253  const Eigen::Vector3d& color) {
254  colors.resize(size);
255  Eigen::Vector3d clipped_color = color;
256  if (color.minCoeff() < 0 || color.maxCoeff() > 1) {
258  "[ccHObject::ResizeAndPaintUniformColor] invalid color in "
259  "PaintUniformColor, clipping to [0, 1]");
260  clipped_color = clipped_color.array()
261  .max(Eigen::Vector3d(0, 0, 0).array())
262  .matrix();
263  clipped_color = clipped_color.array()
264  .min(Eigen::Vector3d(1, 1, 1).array())
265  .matrix();
266  }
267  for (size_t i = 0; i < size; i++) {
268  colors[i] = clipped_color;
269  }
270 }
271 
273  const std::vector<Eigen::Vector3d>& points) {
274  if (points.empty()) {
275  return Eigen::Vector3d(0.0, 0.0, 0.0);
276  }
277  return std::accumulate(
278  points.begin(), points.end(), points[0],
279  [](const Eigen::Vector3d& a, const Eigen::Vector3d& b) {
280  return a.array().min(b.array()).matrix();
281  });
282 }
283 
285  const std::vector<Eigen::Vector3d>& points) {
286  if (points.empty()) {
287  return Eigen::Vector3d(0.0, 0.0, 0.0);
288  }
289  return std::accumulate(
290  points.begin(), points.end(), points[0],
291  [](const Eigen::Vector3d& a, const Eigen::Vector3d& b) {
292  return a.array().max(b.array()).matrix();
293  });
294 }
295 
296 Eigen::Vector3d ccHObject::ComputeCenter(
297  const std::vector<Eigen::Vector3d>& points) {
298  Eigen::Vector3d center(0, 0, 0);
299  if (points.empty()) {
300  return center;
301  }
302  center = std::accumulate(points.begin(), points.end(), center);
303  center /= double(points.size());
304  return center;
305 }
306 
307 void ccHObject::TransformPoints(const Eigen::Matrix4d& transformation,
308  std::vector<Eigen::Vector3d>& points) {
309  for (auto& point : points) {
310  Eigen::Vector4d new_point =
311  transformation *
312  Eigen::Vector4d(point(0), point(1), point(2), 1.0);
313  point = new_point.head<3>() / new_point(3);
314  }
315 }
316 
317 void ccHObject::TransformNormals(const Eigen::Matrix4d& transformation,
318  std::vector<Eigen::Vector3d>& normals) {
319  for (auto& normal : normals) {
320  Eigen::Vector4d new_normal =
321  transformation *
322  Eigen::Vector4d(normal(0), normal(1), normal(2), 0.0);
323  normal = new_normal.head<3>();
324  }
325 }
326 
328  const Eigen::Matrix4d& transformation,
329  std::vector<Eigen::Matrix3d>& covariances) {
330  RotateCovariances(transformation.block<3, 3>(0, 0), covariances);
331 }
332 
333 void ccHObject::TranslatePoints(const Eigen::Vector3d& translation,
334  std::vector<Eigen::Vector3d>& points,
335  bool relative) {
336  Eigen::Vector3d transform = translation;
337  if (!relative) {
338  transform -= ComputeCenter(points);
339  }
340  for (auto& point : points) {
341  point += transform;
342  }
343 }
344 
345 void ccHObject::ScalePoints(const double scale,
346  std::vector<Eigen::Vector3d>& points,
347  const Eigen::Vector3d& center) {
348  for (auto& point : points) {
349  point = (point - center) * scale + center;
350  }
351 }
352 
353 void ccHObject::RotatePoints(const Eigen::Matrix3d& R,
354  std::vector<Eigen::Vector3d>& points,
355  const Eigen::Vector3d& center) {
356  for (auto& point : points) {
357  point = R * (point - center) + center;
358  }
359 }
360 
361 void ccHObject::RotateNormals(const Eigen::Matrix3d& R,
362  std::vector<Eigen::Vector3d>& normals) {
363  for (auto& normal : normals) {
364  normal = R * normal;
365  }
366 }
367 
371 void ccHObject::RotateCovariances(const Eigen::Matrix3d& R,
372  std::vector<Eigen::Matrix3d>& covariances) {
373  for (auto& covariance : covariances) {
374  covariance = R * covariance * R.transpose();
375  }
376 }
377 
379  const Eigen::Vector3d& rotation) {
383 }
384 
386  const Eigen::Vector3d& rotation) {
390 }
391 
393  const Eigen::Vector3d& rotation) {
397 }
398 
400  const Eigen::Vector3d& rotation) {
404 }
405 
407  const Eigen::Vector3d& rotation) {
411 }
412 
414  const Eigen::Vector3d& rotation) {
418 }
419 
421  const Eigen::Vector3d& rotation) {
422  const double phi = rotation.norm();
423  return Eigen::AngleAxisd(phi, rotation / phi).toRotationMatrix();
424 }
425 
427  const Eigen::Vector4d& rotation) {
428  return Eigen::Quaterniond(rotation(0), rotation(1), rotation(2),
429  rotation(3))
430  .normalized()
431  .toRotationMatrix();
432 }
433 
435  const Eigen::Vector3d& rotation) {
436  Eigen::AngleAxisd rollAngle(
437  Eigen::AngleAxisd(rotation(2), Eigen::Vector3d::UnitX()));
438  Eigen::AngleAxisd pitchAngle(
439  Eigen::AngleAxisd(rotation(1), Eigen::Vector3d::UnitY()));
440  Eigen::AngleAxisd yawAngle(
441  Eigen::AngleAxisd(rotation(0), Eigen::Vector3d::UnitZ()));
442  Eigen::Matrix3d rotation_matrix;
443  rotation_matrix = yawAngle * pitchAngle * rollAngle;
444  return rotation_matrix;
445 }
446 
448 
450  return ecvOrientedBBox();
451 }
452 
454 
456  int flags,
457  bool additive /*=true*/) {
458  if (!otherObject || flags < 0) {
459  CVLog::Error("[ccHObject::addDependency] Invalid arguments");
460  assert(false);
461  return;
462  } else if (flags == 0) {
463  return;
464  }
465 
466  if (additive) {
467  // look for already defined flags for this object
468  std::map<ccHObject*, int>::iterator it =
469  m_dependencies.find(otherObject);
470  if (it != m_dependencies.end()) {
471  // nothing changes? we stop here (especially to avoid infinite
472  // loop when setting the DP_NOTIFY_OTHER_ON_DELETE flag below!)
473  if ((it->second & flags) == flags) return;
474  flags |= it->second;
475  }
476  }
477  assert(flags != 0);
478 
479  m_dependencies[otherObject] = flags;
480 
481  // whenever we add a dependency, we must be sure to be notified
482  // by the other object when its deleted! Otherwise we'll keep
483  // bad pointers in the dependency list...
484  otherObject->addDependency(this, DP_NOTIFY_OTHER_ON_DELETE);
485 }
486 
488  std::map<ccHObject*, int>::const_iterator it =
489  m_dependencies.find(const_cast<ccHObject*>(
490  otherObject)); // DGM: not sure why erase won't accept a
491  // const pointer?! We try to modify the map
492  // here, not the pointer object!
493 
494  return (it != m_dependencies.end() ? it->second : 0);
495 }
496 
498  m_dependencies.erase(const_cast<ccHObject*>(
499  otherObject)); // DGM: not sure why erase won't accept a const
500  // pointer?! We try to modify the map here, not the
501  // pointer object!
502  if (!otherObject->m_isDeleting)
504 }
505 
507  DEPENDENCY_FLAGS flag) {
508  int flags = getDependencyFlagsWith(otherObject);
509  if ((flags & flag) == flag) {
510  flags = (flags & (~flag));
511  // either update the flags (if some bits remain)
512  if (flags != 0)
513  m_dependencies[otherObject] = flags;
514  else // otherwise remove the dependency
515  m_dependencies.erase(otherObject);
516  }
517 }
518 
520  // remove any dependency declared with this object
521  // and remove it from the children list as well (in case of)
522  // DGM: we can't call 'detachChild' as this method will try to
523  // modify the child contents!
524  removeDependencyWith(const_cast<ccHObject*>(
525  obj)); // this method will only modify the dependency flags of obj
526 
527  int pos = getChildIndex(obj);
528  if (pos >= 0) {
529  // we can't swap children as we want to keep the order!
530  m_children.erase(m_children.begin() + pos);
531  }
532 }
533 
535  int dependencyFlags /*=DP_PARENT_OF_OTHER*/,
536  int insertIndex /*=-1*/) {
537  if (!child) {
538  assert(false);
539  return false;
540  }
541  if (std::find(m_children.begin(), m_children.end(), child) !=
542  m_children.end()) {
543  CVLog::ErrorDebug("[ccHObject::addChild] Object is already a child!");
544  return false;
545  }
546 
547  if (isLeaf()) {
549  "[ccHObject::addChild] Leaf objects shouldn't have any child!");
550  return false;
551  }
552 
553  // insert child
554  try {
555  if (insertIndex < 0 ||
556  static_cast<size_t>(insertIndex) >= m_children.size())
557  m_children.push_back(child);
558  else
559  m_children.insert(m_children.begin() + insertIndex, child);
560  } catch (const std::bad_alloc&) {
561  // not enough memory!
562  return false;
563  }
564 
565  // we want to be notified whenever this child is deleted!
566  child->addDependency(
567  this, DP_NOTIFY_OTHER_ON_DELETE); // DGM: potentially redundant
568  // with calls to 'addDependency'
569  // but we can't miss that ;)
570 
571  if (dependencyFlags != 0) {
572  addDependency(child, dependencyFlags);
573  }
574 
575  // the strongest link: between a parent and a child ;)
576  if ((dependencyFlags & DP_PARENT_OF_OTHER) == DP_PARENT_OF_OTHER) {
577  child->setParent(this);
578  if (child->isShareable()) dynamic_cast<CCShareable*>(child)->link();
579  }
580 
581  return true;
582 }
583 
584 unsigned int ccHObject::getChildCountRecursive() const {
585  unsigned int count = static_cast<unsigned>(m_children.size());
586 
587  for (auto child : m_children) {
588  count += child->getChildCountRecursive();
589  }
590 
591  return count;
592 }
593 
594 ccHObject* ccHObject::find(unsigned uniqueID) {
595  // found the right item?
596  if (getUniqueID() == uniqueID) {
597  return this;
598  }
599 
600  // otherwise we are going to test all children recursively
601  for (unsigned i = 0; i < getChildrenNumber(); ++i) {
602  ccHObject* match = getChild(i)->find(uniqueID);
603  if (match) {
604  return match;
605  }
606  }
607 
608  return nullptr;
609 }
610 
611 unsigned ccHObject::filterChildren(Container& filteredChildren,
612  bool recursive /*=false*/,
613  CV_CLASS_ENUM filter /*=CV_TYPES::OBJECT*/,
614  bool strict /*=false*/) const {
615  for (auto child : m_children) {
616  if ((!strict && child->isKindOf(filter)) ||
617  (strict && child->isA(filter))) {
618  // if (!inDisplay || child->getDisplay() == inDisplay)
619  //{
620  // warning: we have to handle unicity as a sibling may be in the
621  // same container as its parent!
622  if (std::find(filteredChildren.begin(), filteredChildren.end(),
623  child) ==
624  filteredChildren.end()) // not yet in output vector?
625  {
626  filteredChildren.push_back(child);
627  }
628  //}
629  }
630 
631  if (recursive) {
632  child->filterChildren(filteredChildren, true, filter, strict);
633  }
634  }
635 
636  return static_cast<unsigned>(filteredChildren.size());
637 }
638 
639 int ccHObject::getChildIndex(const ccHObject* child) const {
640  for (size_t i = 0; i < m_children.size(); ++i)
641  if (m_children[i] == child) return static_cast<int>(i);
642 
643  return -1;
644 }
645 
646 void ccHObject::transferChild(ccHObject* child, ccHObject& newParent) {
647  assert(child);
648 
649  // remove link from old parent
650  int childDependencyFlags = child->getDependencyFlagsWith(this);
651  int parentDependencyFlags = getDependencyFlagsWith(child);
652 
653  detachChild(child); // automatically removes any dependency with this
654  // object
655 
656  newParent.addChild(child, parentDependencyFlags);
657  child->addDependency(&newParent, childDependencyFlags);
658 
659  // after a successful transfer, either the parent is 'newParent' or a null
660  // pointer
661  assert(child->getParent() == &newParent || child->getParent() == nullptr);
662 }
663 
665  bool forceFatherDependent /*=false*/) {
666  for (auto child : m_children) {
667  // remove link from old parent
668  int childDependencyFlags = child->getDependencyFlagsWith(this);
669  int fatherDependencyFlags = getDependencyFlagsWith(child);
670 
671  // we must explicitely remove any dependency with the child as we don't
672  // call 'detachChild'
673  removeDependencyWith(child);
674  child->removeDependencyWith(this);
675 
676  newParent.addChild(child, fatherDependencyFlags);
677  child->addDependency(&newParent, childDependencyFlags);
678 
679  // after a successful transfer, either the parent is 'newParent' or a
680  // null pointer
681  assert(child->getParent() == &newParent ||
682  child->getParent() == nullptr);
683  }
684  m_children.clear();
685 }
686 
687 void ccHObject::swapChildren(unsigned firstChildIndex,
688  unsigned secondChildIndex) {
689  assert(firstChildIndex < m_children.size());
690  assert(secondChildIndex < m_children.size());
691 
692  std::swap(m_children[firstChildIndex], m_children[secondChildIndex]);
693 }
694 
695 int ccHObject::getIndex() const {
696  return (m_parent ? m_parent->getChildIndex(this) : -1);
697 }
698 
699 bool ccHObject::isAncestorOf(const ccHObject* anObject) const {
700  assert(anObject);
701  ccHObject* parent = anObject->getParent();
702  if (!parent) return false;
703 
704  if (parent == this) return true;
705 
706  return isAncestorOf(parent);
707 }
708 
709 void ccHObject::removeFromRenderScreen(bool recursive) {
711  context.removeViewID = getViewId();
712  context.removeEntityType = getEntityType();
714 
715  if (this->isKindOf(CV_TYPES::FACET) || this->isKindOf(CV_TYPES::PLANE)) {
717  plane->showNormalVector(false);
718  plane->clearNormalVector(context);
719  }
720 
721  if (this->isKindOf(CV_TYPES::SENSOR)) {
722  ccSensor* sensor = ccHObjectCaster::ToSensor(this);
723  sensor->clearDrawings();
724  }
725 
726  if (this->isKindOf(CV_TYPES::PRIMITIVE)) {
728  if (prim) {
729  prim->clearDrawings();
730  }
731  }
732 
733  if (recursive) {
734  for (auto child : m_children) {
735  child->removeFromRenderScreen(true);
736  }
737  }
738 }
739 
741  trans.toIdentity();
742  bool hasGLTrans = false;
743 
744  // recurse among ancestors to get the absolute GL transformation
745  const ccHObject* obj = this;
746  while (obj) {
747  if (obj->isGLTransEnabled()) {
748  trans = trans * obj->getGLTransformation();
749  hasGLTrans = true;
750  }
751  obj = obj->getParent();
752  }
753 
754  return hasGLTrans;
755 }
756 
757 ccBBox ccHObject::getOwnBB(bool withGLFeatures /*=false*/) { return ccBBox(); }
758 
759 ccBBox ccHObject::getBB_recursive(bool withGLFeatures /*=false*/,
760  bool onlyEnabledChildren /*=true*/) {
761  ccBBox box = getOwnBB(withGLFeatures);
762 
763  for (auto child : m_children) {
764  if (!onlyEnabledChildren || child->isEnabled()) {
765  box += child->getBB_recursive(withGLFeatures, onlyEnabledChildren);
766  }
767  }
768 
769  return box;
770 }
771 
772 void ccHObject::setRedrawFlagRecursive(bool redraw /*=false*/) {
773  // 2D Label or 2DLabel ViewPort
775  setRedraw(redraw);
776  }
777 
778  for (auto child : m_children) {
779  child->setRedrawFlagRecursive(redraw);
780  }
781 }
782 
784  setForceRedraw(redraw);
785 
786  for (auto child : m_children) {
787  child->setForceRedrawRecursive(redraw);
788  }
789 }
790 
792  if (this->isKindOf(CV_TYPES::POINT_CLOUD)) {
794  if (cloud && cloud->getPointSize() != pSize) {
795  cloud->setPointSize(pSize);
796  }
797  }
798 
799  for (auto child : m_children) {
800  child->setPointSizeRecursive(pSize);
801  }
802 }
803 
805  if (this->isKindOf(CV_TYPES::POLY_LINE)) {
807  if (poly && poly->getWidth() != with) {
808  poly->setWidth(with);
809  }
810  }
811 
812  for (auto child : m_children) {
813  child->setLineWidthRecursive(with);
814  }
815 }
816 
818  ccBBox box;
819  box = getOwnBB(true);
820 
821  for (auto child : m_children) {
822  if (child->isEnabled()) {
823  ccBBox childBox = child->getDisplayBB_recursive(true);
824  if (child->isGLTransEnabled()) {
825  childBox = childBox * child->getGLTransformation();
826  }
827  box += childBox;
828  }
829  }
830 
831  if (!relative && box.isValid()) {
832  // get absolute bounding-box?
833  ccGLMatrix trans;
835  box = box * trans;
836  }
837 
838  return box;
839 }
840 
841 void ccHObject::getTypeID_recursive(std::vector<removeInfo>& rmInfos,
842  bool relative) {
843  removeInfo rminfo;
844  rminfo.removeId = getViewId();
845  rminfo.removeType = getEntityType();
846  if (rminfo.removeType == ENTITY_TYPE::ECV_OCTREE) {
847  ccOctree* octree =
848  ccHObjectCaster::ToOctree(find(rminfo.removeId.toUInt()));
849  if (octree) {
850  // remove temp octree model from rendering window
851  octree->setVisible(false);
853  octree->draw(context);
854  }
855  } else if (rminfo.removeType == ENTITY_TYPE::ECV_KDTREE) {
856  ccKdTree* kdtree =
857  ccHObjectCaster::ToKdTree(find(rminfo.removeId.toUInt()));
858  if (kdtree) {
859  // remove temp octree model from rendering window
860  kdtree->setEnabled(false);
862  kdtree->draw(context);
863  }
864  } else if (rminfo.removeType == ENTITY_TYPE::ECV_MESH) {
865  ccHObject* obj = find(rminfo.removeId.toUInt());
866 
867  // try clear plane
869  if (plane) {
870  // remove temp octree model from rendering window
871  plane->showNormalVector(false);
873  plane->glDrawNormal(context, CCVector3(), 1.0);
874  }
875 
876  // try clear primitives
878  if (prim) {
879  prim->clearDrawings();
880  }
881  } else if (rminfo.removeType == ENTITY_TYPE::ECV_2DLABLE) {
882  ccHObject* obj = find(rminfo.removeId.toUInt());
884  if (label) {
885  // clear
886  label->clearLabel(false);
887  }
888  } else if (rminfo.removeType == ENTITY_TYPE::ECV_2DLABLE_VIEWPORT) {
889  ccHObject* obj = find(rminfo.removeId.toUInt());
890  cc2DViewportLabel* labelViewPort =
892  if (labelViewPort) {
893  // clear
894  labelViewPort->clear2Dviews();
895  }
896  } else if (rminfo.removeType == ENTITY_TYPE::ECV_SENSOR) {
897  ccHObject* obj = find(rminfo.removeId.toUInt());
898  ccSensor* sensor = ccHObjectCaster::ToSensor(obj);
899  if (sensor) {
900  // clear
901  sensor->clearDrawings();
902  }
903  }
904 
905  // need to remove 3D name if shown
906  if (nameShownIn3D()) {
907  showNameIn3D(false);
910  }
911  rmInfos.push_back(rminfo);
912 
913  if (relative) {
914  for (auto child : m_children) {
915  child->getTypeID_recursive(rmInfos, true);
916  }
917  }
918 }
919 
920 void ccHObject::getTypeID_recursive(std::vector<hideInfo>& hdInfos,
921  bool relative) {
922  hideInfo hdinfo;
923  hdinfo.hideId = getViewId();
924  hdinfo.hideType = getEntityType();
925  hdInfos.push_back(hdinfo);
926 
927  if (relative) {
928  for (auto child : m_children) {
929  child->getTypeID_recursive(hdInfos, true);
930  }
931  }
932 }
933 
934 bool ccHObject::isDisplayed() const { return isVisible() && isBranchEnabled(); }
935 
937  if (!isEnabled()) return false;
938 
939  if (m_parent) return m_parent->isBranchEnabled();
940 
941  return true;
942 }
943 
946 }
947 
949  const ccGLMatrix* transInput /*=nullptr*/) {
950  ccGLMatrix transTemp;
951  const ccGLMatrix* transToApply = transInput;
952 
953  if (m_glTransEnabled) {
954  if (!transInput) {
955  // if no transformation is provided (by father)
956  // we initiate it with the current one
957  transToApply = &m_glTrans;
958  } else {
959  transTemp = *transInput * m_glTrans;
960  transToApply = &transTemp;
961  }
962  }
963 
964  if (transToApply) {
965  applyGLTransformation(*transToApply);
967  }
968 
969  for (auto child : m_children)
970  child->applyGLTransformation_recursive(transToApply);
971 
973 }
974 
976  unsigned id = getUniqueID();
977 
978  for (auto child : m_children) {
979  unsigned childMaxID = child->findMaxUniqueID_recursive();
980  if (id < childMaxID) {
981  id = childMaxID;
982  }
983  }
984 
985  return id;
986 }
987 
989  if (!child) {
990  assert(false);
991  return;
992  }
993 
994  // remove any dependency (bilateral)
995  removeDependencyWith(child);
996  child->removeDependencyWith(this);
997 
998  if (child->getParent() == this) {
999  child->setParent(nullptr);
1000  }
1001 
1002  int pos = getChildIndex(child);
1003  if (pos >= 0) {
1004  // we can't swap children as we want to keep the order!
1005  m_children.erase(m_children.begin() + pos);
1006  }
1007 }
1008 
1010  trans.toIdentity();
1011  return getOwnBB();
1012 }
1013 
1016  return;
1017  }
1018 
1019  switch (getSelectionBehavior()) {
1020  case SELECTION_AA_BBOX:
1021  getDisplayBB_recursive(true).draw(context, col);
1022  break;
1023 
1024  case SELECTION_FIT_BBOX: {
1025  ccGLMatrix trans;
1026  ccBBox box = getOwnFitBB(trans);
1027  if (box.isValid()) {
1028  ecvOrientedBBox obb =
1031  obb.draw(context, col);
1032  }
1033  } break;
1034 
1035  case SELECTION_IGNORED:
1036  break;
1037 
1038  default:
1039  assert(false);
1040  }
1041 }
1042 
1044  for (auto child : m_children) {
1045  // remove any dependency (bilateral)
1046  removeDependencyWith(child);
1047  child->removeDependencyWith(this);
1048 
1049  if (child->getParent() == this) {
1050  child->setParent(nullptr);
1051  }
1052  }
1053  m_children.clear();
1054 }
1055 
1057  int pos = getChildIndex(child);
1058  if (pos >= 0) {
1059  removeChild(pos);
1060  }
1061 }
1062 
1063 void ccHObject::removeChild(int pos) {
1064  if (pos < 0 || static_cast<size_t>(pos) >= m_children.size()) {
1065  assert(false);
1066  return;
1067  }
1068 
1069  ccHObject* child = m_children[pos];
1070 
1071  // we can't swap as we want to keep the order!
1072  //(DGM: do this BEFORE deleting the object (otherwise
1073  // the dependency mechanism can 'backfire' ;)
1074  m_children.erase(m_children.begin() + pos);
1075 
1076  // backup dependency flags
1077  int flags = getDependencyFlagsWith(child);
1078 
1079  // remove any dependency
1080  removeDependencyWith(child);
1081  // child->removeDependencyWith(this); //DGM: no, don't do this otherwise
1082  // this entity won't be warned that the child has been removed!
1083 
1084  if ((flags & DP_DELETE_OTHER) == DP_DELETE_OTHER) {
1085  // delete object
1086  if (child->isShareable()) {
1087  dynamic_cast<CCShareable*>(child)->release();
1088  } else { /* if (!child->isA(CV_TYPES::POINT_OCTREE))*/
1089  delete child;
1090  }
1091  } else if (child->getParent() == this) {
1092  child->setParent(nullptr);
1093  }
1094 }
1095 
1097  while (!m_children.empty()) {
1098  ccHObject* child = m_children.back();
1099  m_children.pop_back();
1100 
1101  int flags = getDependencyFlagsWith(child);
1102  if ((flags & DP_DELETE_OTHER) == DP_DELETE_OTHER) {
1103  if (child->isShareable()) {
1104  dynamic_cast<CCShareable*>(child)->release();
1105  } else {
1106  delete child;
1107  }
1108  }
1109  }
1110 }
1111 
1113  // we only handle pure CV_TYPES::HIERARCHY_OBJECT here (object groups)
1114  return (getClassID() == CV_TYPES::HIERARCHY_OBJECT);
1115 }
1116 
1117 bool ccHObject::toFile(QFile& out, short dataVersion) const {
1118  assert(out.isOpen() && (out.openMode() & QIODevice::WriteOnly));
1119 
1120  // Version validation
1121  if (dataVersion < 23) {
1122  assert(false);
1123  return false;
1124  }
1125 
1126  // write 'ccObject' header
1127  if (!ccObject::toFile(out, dataVersion)) return false;
1128 
1129  // write own data
1130  if (!toFile_MeOnly(out, dataVersion)) return false;
1131 
1132  //(serializable) child count (dataVersion >= 20)
1133  uint32_t serializableCount = 0;
1134  for (auto child : m_children) {
1135  if (child->isSerializable()) {
1136  ++serializableCount;
1137  }
1138  }
1139 
1140  if (out.write(reinterpret_cast<const char*>(&serializableCount),
1141  sizeof(uint32_t)) < 0)
1142  return WriteError();
1143 
1144  // write serializable children (if any)
1145  for (auto child : m_children) {
1146  if (child->isSerializable()) {
1147  if (!child->toFile(out, dataVersion)) return false;
1148  }
1149  }
1150 
1151  // write current selection behavior (dataVersion >= 23)
1152  if (out.write(reinterpret_cast<const char*>(&m_selectionBehavior),
1153  sizeof(SelectionBehavior)) < 0)
1154  return WriteError();
1155 
1156  // write transformation history (dataVersion >= 45)
1157  if (dataVersion >= 45) {
1158  m_glTransHistory.toFile(out, dataVersion);
1159  }
1160 
1161  return true;
1162 }
1163 
1165  short minVersion = m_glTransHistory.isIdentity() ? 23 : 45;
1166  minVersion = std::max(minVersion, ccObject::minimumFileVersion());
1167  minVersion = std::max(minVersion, minimumFileVersion_MeOnly());
1168 
1169  // write serializable children (if any)
1170  for (auto child : m_children) {
1171  minVersion = std::max(minVersion, child->minimumFileVersion());
1172  }
1173 
1174  return minVersion;
1175 }
1176 
1177 bool ccHObject::fromFile(QFile& in,
1178  short dataVersion,
1179  int flags,
1180  LoadedIDMap& oldToNewIDMap) {
1181  if (!fromFileNoChildren(in, dataVersion, flags, oldToNewIDMap))
1182  return false;
1183 
1184  //(serializable) child count (dataVersion>=20)
1185  uint32_t serializableCount = 0;
1186  if (in.read(reinterpret_cast<char*>(&serializableCount), 4) < 0)
1187  return ReadError();
1188 
1189  // read serializable children (if any)
1190  for (uint32_t i = 0; i < serializableCount; ++i) {
1191  // read children class ID
1192  CV_CLASS_ENUM classID = ReadClassIDFromFile(in, dataVersion);
1193  if (classID == CV_TYPES::OBJECT) return false;
1194 
1195  if (dataVersion >= 35 && dataVersion <= 47 &&
1196  ((classID & CC_CUSTOM_BIT) != 0)) {
1197  // bug fix: for a long time the CC_CAMERA_BIT and CC_QUADRIC_BIT
1198  // were wrongly defined with two bits instead of one! The additional
1199  // and wrongly defined bit was the CC_CUSTOM_BIT :(
1200  if ((classID & CV_TYPES::CAMERA_SENSOR) ==
1202  (classID & CV_TYPES::QUADRIC) == CV_TYPES::QUADRIC) {
1203  classID &= (~CC_CUSTOM_BIT);
1204  }
1205  }
1206 
1207  // create corresponding child object
1208  ccHObject* child = New(classID);
1209 
1210  // specific case of custom objects (defined by plugins)
1211  if ((classID & CV_TYPES::CUSTOM_H_OBJECT) ==
1213  // store current position
1214  size_t originalFilePos = in.pos();
1215  // we need to load the custom object as plain ccCustomHobject
1216  child->fromFileNoChildren(in, dataVersion, flags, oldToNewIDMap);
1217  // go back to original position
1218  in.seek(originalFilePos);
1219  // get custom object name and plugin name
1220  QString childName = child->getName();
1221  QString classId =
1222  child->getMetaData(
1224  .toString();
1225  QString pluginId =
1226  child->getMetaData(
1228  .toString();
1229  // dont' need this instance anymore
1230  delete child;
1231  child = nullptr;
1232 
1233  // try to get a new object from external factories
1234  ccHObject* newChild = ccHObject::New(pluginId, classId);
1235  if (newChild) // found a plugin that can deserialize it
1236  {
1237  child = newChild;
1238  } else {
1240  QString("[ccHObject::fromFile] Couldn't find a plugin "
1241  "able to deserialize custom object '%1' "
1242  "(class_ID = %2 / plugin_ID = %3)")
1243  .arg(childName)
1244  .arg(classID)
1245  .arg(pluginId));
1246  return false; // FIXME: for now simply return false. We may
1247  // want to skip it but I'm not sure if there is a
1248  // simple way of doing that
1249  }
1250  }
1251 
1252  assert(child && child->isSerializable());
1253  if (child) {
1254  if (child->fromFile(in, dataVersion, flags, oldToNewIDMap)) {
1255  // FIXME
1256  // addChild(child,child->getFlagState(CC_FATHER_DEPENDENT));
1257  addChild(child);
1258  } else {
1259  // delete child; //we can't do this as the object might be
1260  // invalid
1261  return false;
1262  }
1263  } else {
1264  return CorruptError();
1265  }
1266  }
1267 
1268  // read the selection behavior (dataVersion>=23)
1269  if (dataVersion >= 23) {
1270  if (in.read(reinterpret_cast<char*>(&m_selectionBehavior),
1271  sizeof(SelectionBehavior)) < 0) {
1272  return ReadError();
1273  }
1274  } else {
1276  }
1277 
1278  // read transformation history (dataVersion >= 45)
1279  if (dataVersion >= 45) {
1280  if (!m_glTransHistory.fromFile(in, dataVersion, flags, oldToNewIDMap)) {
1281  return false;
1282  }
1283  }
1284 
1285  return true;
1286 }
1287 
1289  short dataVersion,
1290  int flags,
1291  LoadedIDMap& oldToNewIDMap) {
1292  assert(in.isOpen() && (in.openMode() & QIODevice::ReadOnly));
1293 
1294  // read 'ccObject' header
1295  if (!ccObject::fromFile(in, dataVersion, flags, oldToNewIDMap))
1296  return false;
1297 
1298  // read own data
1299  return fromFile_MeOnly(in, dataVersion, flags, oldToNewIDMap);
1300 }
1301 
1302 bool ccHObject::toFile_MeOnly(QFile& out, short dataVersion) const {
1303  assert(out.isOpen() && (out.openMode() & QIODevice::WriteOnly));
1304 
1305  // Version validation
1306  if (dataVersion < 20) {
1307  assert(false);
1308  return false;
1309  }
1310 
1311  /*** ccHObject takes in charge the ccDrawableObject properties (which is not
1312  * a ccSerializableObject) ***/
1313 
1314  //'visible' state (dataVersion>=20)
1315  if (out.write(reinterpret_cast<const char*>(&m_visible), sizeof(bool)) < 0)
1316  return WriteError();
1317  //'lockedVisibility' state (dataVersion>=20)
1318  if (out.write(reinterpret_cast<const char*>(&m_lockedVisibility),
1319  sizeof(bool)) < 0)
1320  return WriteError();
1321  //'colorsDisplayed' state (dataVersion>=20)
1322  if (out.write(reinterpret_cast<const char*>(&m_colorsDisplayed),
1323  sizeof(bool)) < 0)
1324  return WriteError();
1325  //'normalsDisplayed' state (dataVersion>=20)
1326  if (out.write(reinterpret_cast<const char*>(&m_normalsDisplayed),
1327  sizeof(bool)) < 0)
1328  return WriteError();
1329  //'sfDisplayed' state (dataVersion>=20)
1330  if (out.write(reinterpret_cast<const char*>(&m_sfDisplayed), sizeof(bool)) <
1331  0)
1332  return WriteError();
1333  //'colorIsOverridden' state (dataVersion>=20)
1334  if (out.write(reinterpret_cast<const char*>(&m_colorIsOverridden),
1335  sizeof(bool)) < 0)
1336  return WriteError();
1337  if (m_colorIsOverridden) {
1338  //'tempColor' (dataVersion>=20)
1339  if (out.write(reinterpret_cast<const char*>(m_tempColor.rgb),
1340  sizeof(ColorCompType) * 3) < 0) {
1341  return WriteError();
1342  }
1343  }
1344  //'glTransEnabled' state (dataVersion>=20)
1345  if (out.write(reinterpret_cast<const char*>(&m_glTransEnabled),
1346  sizeof(bool)) < 0)
1347  return WriteError();
1348  if (m_glTransEnabled) {
1349  if (!m_glTrans.toFile(out, dataVersion)) {
1350  return false;
1351  }
1352  }
1353 
1354  //'showNameIn3D' state (dataVersion>=24)
1355  if (dataVersion >= 24) {
1356  if (out.write(reinterpret_cast<const char*>(&m_showNameIn3D),
1357  sizeof(bool)) < 0)
1358  return WriteError();
1359  }
1360 
1361  return true;
1362 }
1363 
1365  // Determine minimum version based on feature usage:
1366  // - Version 20: Basic drawable properties
1367  // - Version 24: showNameIn3D state
1368  return m_showNameIn3D ? 24 : 20;
1369 }
1370 
1372  short dataVersion,
1373  int flags,
1374  LoadedIDMap& oldToNewIDMap) {
1375  assert(in.isOpen() && (in.openMode() & QIODevice::ReadOnly));
1376 
1377  /*** ccHObject takes in charge the ccDrawableObject properties (which is not
1378  * a ccSerializableObject) ***/
1379 
1380  //'visible' state (dataVersion>=20)
1381  if (in.read(reinterpret_cast<char*>(&m_visible), sizeof(bool)) < 0)
1382  return ReadError();
1383  //'lockedVisibility' state (dataVersion>=20)
1384  if (in.read(reinterpret_cast<char*>(&m_lockedVisibility), sizeof(bool)) < 0)
1385  return ReadError();
1386  //'colorsDisplayed' state (dataVersion>=20)
1387  if (in.read(reinterpret_cast<char*>(&m_colorsDisplayed), sizeof(bool)) < 0)
1388  return ReadError();
1389  //'normalsDisplayed' state (dataVersion>=20)
1390  if (in.read(reinterpret_cast<char*>(&m_normalsDisplayed), sizeof(bool)) < 0)
1391  return ReadError();
1392  //'sfDisplayed' state (dataVersion>=20)
1393  if (in.read(reinterpret_cast<char*>(&m_sfDisplayed), sizeof(bool)) < 0)
1394  return ReadError();
1395  //'colorIsOverriden' state (dataVersion>=20)
1396  if (in.read(reinterpret_cast<char*>(&m_colorIsOverridden), sizeof(bool)) <
1397  0)
1398  return ReadError();
1399  if (m_colorIsOverridden) {
1400  //'tempColor' (dataVersion>=20)
1401  if (in.read(reinterpret_cast<char*>(m_tempColor.rgb),
1402  sizeof(ColorCompType) * 3) < 0)
1403  return ReadError();
1404  }
1405  //'glTransEnabled' state (dataVersion>=20)
1406  if (in.read(reinterpret_cast<char*>(&m_glTransEnabled), sizeof(bool)) < 0)
1407  return ReadError();
1408  if (m_glTransEnabled) {
1409  if (!m_glTrans.fromFile(in, dataVersion, flags, oldToNewIDMap)) {
1410  m_glTransEnabled = false;
1411  return false;
1412  }
1413  }
1414 
1415  //'showNameIn3D' state (dataVersion>=24)
1416  if (dataVersion >= 24) {
1417  if (in.read(reinterpret_cast<char*>(&m_showNameIn3D), sizeof(bool)) <
1418  0) {
1419  return ReadError();
1420  }
1421  } else {
1422  m_showNameIn3D = false;
1423  }
1424 
1425  return true;
1426 }
1427 
1429  QFont font = ecvDisplayTools::GetTextDisplayFont(); // takes rendering zoom
1430  // into account!
1432  getName(), static_cast<int>(m_nameIn3DPos.x),
1433  static_cast<int>(m_nameIn3DPos.y),
1435  0.75f, nullptr, &font);
1436 }
1437 
1439  // for polyline fast removement
1440  if (getRemoveFlag()) {
1442  context.removeViewID = getViewId();
1444  return;
1445  }
1446 
1447  // are we currently drawing objects in 2D or 3D?
1448  bool draw3D = MACRO_Draw3D(context);
1449 
1452  hideObject_recursive(true);
1453  // no need to do anything
1454  return;
1455  }
1456 
1457  // the entity must be either visible or selected, and of course it should be
1458  // displayed in this context
1459  bool drawInThisContext = ((m_visible || m_selected));
1460  context.visible = m_visible;
1461  context.opacity = getOpacity();
1462 
1463  if (!isFixedId()) {
1464  context.viewID = getViewId();
1465  }
1466 
1467  if (draw3D) {
1468  // apply 3D 'temporary' transformation (for display only)
1469  if (m_glTransEnabled) {
1470  // context.transformInfo.setRotMat(m_glTrans);
1471  }
1472 
1473  // LOD for clouds is enabled?
1474  if (context.decimateCloudOnMove && context.currentLODLevel > 0) {
1475  // only for real clouds
1476  drawInThisContext &= isA(CV_TYPES::POINT_CLOUD);
1477  }
1478  }
1479 
1480  // draw entity
1481  if (m_visible && drawInThisContext && context.forceRedraw) {
1482  if ((!m_selected || !MACRO_SkipSelected(context)) &&
1484  // enable clipping planes (if any)
1485  bool useClipPlanes = (draw3D && !m_clipPlanes.empty());
1486  if (useClipPlanes) {
1487  toggleClipPlanes(context, true);
1488  }
1489 
1491 
1492  // disable clipping planes (if any)
1493  if (useClipPlanes) {
1494  toggleClipPlanes(context, false);
1495  }
1496  }
1497  }
1498 
1499  // hide or show entities
1500  {
1502  bool hasExist = ecvDisplayTools::HideShowEntities(context);
1503  if (!context.forceRedraw && m_forceRedraw && !hasExist) {
1506  setForceRedraw(false);
1507  CC_DRAW_CONTEXT newContext = context;
1508  newContext.forceRedraw = true;
1509  setRedrawFlagRecursive(true);
1510  draw(newContext);
1511  }
1512  }
1513  }
1514 
1515  // draw name - container objects are not visible but can still show a name
1517  if (MACRO_Draw3D(context)) {
1518  // we have to comute the 2D position during the 3D pass!
1519  ccBBox bBox = getBB_recursive(
1520  true); // DGM: take the OpenGL features into account (as
1521  // some entities are purely 'GL'!)
1522  if (bBox.isValid()) {
1523  ccGLCameraParameters camera;
1525 
1526  CCVector3 C = bBox.getCenter();
1527  camera.project(C, m_nameIn3DPos);
1528  }
1529  } else if (MACRO_Draw2D(context) && MACRO_Foreground(context)) {
1530  // then we can display the name during the 2D pass
1531  drawNameIn3D();
1532  }
1533  } else {
1534  // label2d name have been managed by itself
1535  if (!isKindOf(CV_TYPES::LABEL_2D)) {
1540  }
1541  }
1542 
1543  // draw entity's children
1544  for (auto child : m_children) {
1545  child->draw(context);
1546  }
1547 
1548  // if the entity is currently selected, we draw its bounding-box
1549  if (m_selected && draw3D && drawInThisContext &&
1550  !MACRO_EntityPicking(context) && context.currentLODLevel == 0) {
1551  // Check if BoundingBox should be shown
1552  const ecvGui::ParamStruct& params = ecvGui::Parameters();
1553  bool shouldShowBB = params.showBBOnSelected;
1554 
1555  // Check if Axes Grid is visible - if so, ALWAYS hide BoundingBox
1556  // (unconditionally, regardless of showBBOnSelected setting)
1558  AxesGridProperties axesGridProps;
1560  context.viewID, axesGridProps);
1561  if (axesGridProps.visible) {
1562  shouldShowBB =
1563  false; // Force hide BBox when axes grid is visible
1564  }
1565  }
1566 
1567  if (shouldShowBB) {
1568  CC_DRAW_CONTEXT tempContext = context;
1569  tempContext.meshRenderingMode =
1571  tempContext.viewID = getViewId();
1572  // Apply BoundingBox color, opacity and line width from parameters
1573  tempContext.bbDefaultCol = params.bbDefaultCol;
1574  tempContext.opacity = params.bbOpacity;
1575  tempContext.defaultLineWidth =
1576  static_cast<unsigned char>(params.bbLineWidth);
1577  tempContext.currentLineWidth = tempContext.defaultLineWidth;
1578  drawBB(tempContext, params.bbDefaultCol);
1579  tempContext.viewID = getViewId();
1580  showBB(tempContext);
1581  } else {
1582  // Hide BoundingBox if not should show
1583  CC_DRAW_CONTEXT tempContext = context;
1584  tempContext.viewID = getViewId();
1585  hideBB(tempContext);
1586  }
1587  }
1588 
1589  if (!m_selected && draw3D) {
1591  context.viewID = getViewId();
1592  hideBB(context);
1593  }
1594 
1595  // reset redraw flag to true and forceRedraw flag to false(default)
1596  setRedraw(true);
1597  setForceRedraw(false);
1598 }
1599 
1601  if (nameShownIn3D()) {
1602  ccBBox bBox = getBB_recursive(
1603  true); // DGM: take the OpenGL features into account (as some
1604  // entities are purely 'GL'!)
1605  if (bBox.isValid()) {
1606  ccGLCameraParameters camera;
1608 
1609  CCVector3 C = bBox.getCenter();
1610  camera.project(C, m_nameIn3DPos);
1611 
1612  // clear history name 3D
1615 
1616  // draw name in 3D
1617  drawNameIn3D();
1618  }
1619  }
1620 
1621  for (auto child : m_children) {
1622  child->updateNameIn3DRecursive();
1623  }
1624 }
1625 
1627  context.hideShowEntityType =
1629 }
1630 
1633 }
1634 
1636  context.removeEntityType =
1638 }
1639 
1641  context.hideShowEntityType = ENTITY_TYPE::ECV_SHAPE;
1642  context.viewID = QString("BBox-") + context.viewID;
1643  context.visible = false;
1645 }
1646 
1648  context.hideShowEntityType = ENTITY_TYPE::ECV_SHAPE;
1649  context.viewID = QString("BBox-") + context.viewID;
1650  context.visible = true;
1652 }
1653 
1655  bool withGLFeatures /*=false*/) {
1656  // by default this method returns the local bounding-box!
1657  ccBBox box = getOwnBB(false);
1660 }
1661 
1662 bool ccHObject::getOwnGlobalBB(CCVector3d& minCorner, CCVector3d& maxCorner) {
1663  // by default this method returns the local bounding-box!
1664  ccBBox box = getOwnBB(false);
1665  minCorner = CCVector3d::fromArray(box.minCorner().u);
1666  maxCorner = CCVector3d::fromArray(box.maxCorner().u);
1667  return box.isValid();
1668 }
1669 
1671  bool withGLFeatures /*=false*/, bool onlyEnabledChildren /*=true*/) {
1672  GlobalBoundingBox box = getOwnGlobalBB(withGLFeatures);
1673 
1674  for (auto child : m_children) {
1675  if (!onlyEnabledChildren || child->isEnabled()) {
1676  box += child->getGlobalBB_recursive(withGLFeatures,
1677  onlyEnabledChildren);
1678  }
1679  }
1680 
1681  return box;
1682 }
1683 
1684 void ccHObject::hideObject_recursive(bool recursive) {
1685  // hide obj recursively.
1686  std::vector<hideInfo> hdInfos;
1688  getTypeID_recursive(hdInfos, recursive);
1689  context.visible = false;
1690  for (const hideInfo& hdInfo : hdInfos) {
1691  if (hdInfo.hideType == ENTITY_TYPE::ECV_NONE) continue;
1692 
1693  context.hideShowEntityType = hdInfo.hideType;
1694  context.viewID = hdInfo.hideId;
1695  // hide obj bbox
1696  hideBB(context);
1697  context.viewID = hdInfo.hideId;
1698 
1699  ccHObject* obj = find(hdInfo.hideId.toUInt());
1700 
1701  if (hdInfo.hideType == ENTITY_TYPE::ECV_2DLABLE) {
1702  assert(obj && obj->isA(CV_TYPES::LABEL_2D));
1703  cc2DLabel* label2d = ccHObjectCaster::To2DLabel(obj);
1704  label2d->setEnabled(false);
1705  label2d->updateLabel();
1706  continue;
1707  } else if (hdInfo.hideType == ENTITY_TYPE::ECV_2DLABLE_VIEWPORT) {
1708  assert(obj && obj->isA(CV_TYPES::VIEWPORT_2D_LABEL));
1709  cc2DViewportLabel* label2d =
1711  label2d->setEnabled(false);
1712  label2d->update2DLabelView(context, true);
1713  continue;
1714  } else if (hdInfo.hideType == ENTITY_TYPE::ECV_SENSOR) {
1715  ccSensor* sensor = ccHObjectCaster::ToSensor(obj);
1716  if (sensor) {
1717  sensor->hideShowDrawings(context);
1718  continue;
1719  }
1720  } else if (hdInfo.hideType == ENTITY_TYPE::ECV_MESH) {
1721  // try hide primitives
1723  if (prim) {
1724  prim->hideShowDrawings(context);
1725  continue;
1726  }
1727  }
1728 
1729  context.viewID = hdInfo.hideId;
1731  }
1732 }
1733 
1734 void ccHObject::redrawDisplay(bool forceRedraw /* = true*/,
1735  bool only2D /* = false*/) {
1736  ecvDisplayTools::RedrawDisplay(only2D, forceRedraw);
1737 }
1738 
1741 
1744 
1745  bool isEnabled = false;
1746 };
1747 
1749  try {
1750  m_displayStateStack.emplace_back(new HObjectDisplayState(*this));
1751  } catch (const std::bad_alloc&) {
1752  CVLog::Warning("Not enough memory to push the current display state");
1753  return false;
1754  }
1755 
1756  return true;
1757 }
1758 
1759 void ccHObject::popDisplayState(bool apply /*=true*/) {
1760  if (!m_displayStateStack.empty()) {
1761  const DisplayState::Shared state = m_displayStateStack.back();
1762  if (state && apply) {
1763  HObjectDisplayState* hState =
1764  static_cast<HObjectDisplayState*>(state.data());
1765  if (hState->isEnabled != isEnabled()) {
1766  setEnabled(hState->isEnabled);
1767  }
1768  applyDisplayState(*state);
1769  }
1770  m_displayStateStack.pop_back();
1771  }
1772 }
Vector3Tpl< PointCoordinateType > CCVector3
Default 3D Vector.
Definition: CVGeom.h:798
float PointCoordinateType
Type of the coordinates of a (N-D) point.
Definition: CVTypes.h:16
int64_t CV_CLASS_ENUM
Type of object type flags (64 bits)
Definition: CVTypes.h:97
#define CC_CUSTOM_BIT
Definition: CVTypes.h:43
double normal[3]
int size
std::string name
int count
int points
math::float4 color
Eigen::Matrix3d rotation
Definition: VoxelGridIO.cpp:27
static bool ErrorDebug(const char *format,...)
Same as Error, but works only in Debug mode.
Definition: CVLog.cpp:181
static bool Warning(const char *format,...)
Prints out a formatted warning message in console.
Definition: CVLog.cpp:133
static bool Error(const char *format,...)
Display an error dialog with formatted message.
Definition: CVLog.cpp:143
Array of RGB colors for each point.
Array of compressed 3D normals (single index)
Array of (uncompressed) 3D normals (Nx,Ny,Nz)
Array of 2D texture coordinates.
Type y
Definition: CVGeom.h:137
Type u[3]
Definition: CVGeom.h:139
Type x
Definition: CVGeom.h:137
static Vector3Tpl fromArray(const int a[3])
Constructor from an int array.
Definition: CVGeom.h:268
2D label (typically attached to points)
Definition: ecv2DLabel.h:22
void updateLabel()
Definition: ecv2DLabel.cpp:312
void clearLabel(bool ignoreCaption=true)
Definition: ecv2DLabel.cpp:303
2D viewport label
void update2DLabelView(CC_DRAW_CONTEXT &context, bool updateScreen=true)
2D viewport object
Bounding box structure.
Definition: ecvBBox.h:25
void draw(CC_DRAW_CONTEXT &context) override
Draws entity and its children.
Definition: ecvBBox.cpp:68
Box (primitive)
Definition: ecvBox.h:16
Camera (projective) sensor.
Circle (as a polyline)
Definition: ecvCircle.h:16
Cone (primitive)
Definition: ecvCone.h:16
Coordinate System (primitive)
Custom hierarchy object.
static QString DefautMetaDataClassName()
Returns the default key for the "class name" metadata.
static QString DefautMetaDataPluginName()
Returns the default key for the "plugin name" metadata.
Custom leaf object.
Cylinder (primitive)
Definition: ecvCylinder.h:16
Disc (primitive)
Definition: ecvDisc.h:16
Dish.
Definition: ecvDish.h:16
Generic interface for (3D) drawable entities.
bool m_sfDisplayed
Specifies whether scalar field should be displayed.
virtual float getOpacity() const
virtual bool isVisible() const
Returns whether entity is visible or not.
bool m_colorsDisplayed
Specifies whether colors should be displayed.
virtual void lockVisibility(bool state)
Locks/unlocks visibility.
virtual void setVisible(bool state)
Sets entity visibility.
virtual bool isFixedId()
bool m_visible
Specifies whether the object is visible or not.
virtual void applyDisplayState(const DisplayState &state)
Applies a display state.
virtual bool isGLTransEnabled() const
Returns whether a GL transformation is enabled or not.
virtual const ccGLMatrix & getGLTransformation() const
Returns associated GL transformation.
virtual void toggleClipPlanes(CC_DRAW_CONTEXT &context, bool enable)
Enables or disables clipping planes (OpenGL)
bool m_glTransEnabled
Current GL transformation activation state.
virtual void setRedraw(bool state)
Sets entity redraw mode.
ccGLMatrix m_glTrans
Current GL transformation.
bool m_selected
Specifies whether the object is selected or not.
virtual void showNameIn3D(bool state)
Sets whether name should be displayed in 3D.
CCVector3d m_nameIn3DPos
Last 2D position of the '3D' name.
virtual bool nameShownIn3D() const
Returns whether name is displayed in 3D or not.
bool m_lockedVisibility
Specifies whether the visibility can be changed by user or not.
std::vector< DisplayState::Shared > m_displayStateStack
The stack of pushed display states.
bool m_showNameIn3D
Whether name is displayed in 3D or not.
virtual void setForceRedraw(bool state)
Sets force redraw.
virtual void resetGLTransformation()
Resets associated GL transformation.
bool m_colorIsOverridden
Temporary (unique) color activation state.
bool m_normalsDisplayed
Specifies whether normals should be displayed.
ccClipPlaneSet m_clipPlanes
Active clipping planes (used for display only)
ecvColor::Rgb m_tempColor
Temporary (unique) color.
static Container::Shared GetUniqueInstance()
QSharedPointer< Container > Shared
Shared pointer type.
virtual ccHObject * buildObject(const QString &metaName)=0
Custom object building method.
Profile extrusion (primitive)
Definition: ecvExtru.h:17
Facet.
Definition: ecvFacet.h:25
Ground-based Laser sensor.
Definition: ecvGBLSensor.h:26
bool fromFile(QFile &in, short dataVersion, int flags, LoadedIDMap &oldToNewIDMap) override
Loads data from binary stream.
virtual bool isIdentity() const
Returns whether this matrix is equal to identity.
bool toFile(QFile &out, short dataVersion) const override
Saves data to binary stream.
virtual void toIdentity()
Sets matrix to identity.
static Eigen::Matrix< double, 4, 4 > ToEigenMatrix4(const ccGLMatrixTpl< float > &mat)
Float version of ccGLMatrixTpl.
Definition: ecvGLMatrix.h:19
A 3D cloud interface with associated features (color, normals, octree, etc.)
unsigned char getPointSize() const
Returns current point size.
void setPointSize(unsigned size=0)
Sets point size.
Generic primitive interface.
virtual void clearDrawings()
virtual void hideShowDrawings(CC_DRAW_CONTEXT &context)
static ccPolyline * ToPolyline(ccHObject *obj)
Converts current object to ccPolyline (if possible)
static cc2DViewportLabel * To2DViewportLabel(ccHObject *obj)
Converts current object to cc2DViewportLabel (if possible)
static ccSensor * ToSensor(ccHObject *obj)
Converts current object to ccSensor (if possible)
static ccGenericPrimitive * ToPrimitive(ccHObject *obj)
Converts current object to ccGenericPrimitive (if possible)
static ccOctree * ToOctree(ccHObject *obj)
Converts current object to ccOctree (if possible)
static ccPlanarEntityInterface * ToPlanarEntity(ccHObject *obj)
Converts current object to ccPlanarEntityInterface (if possible)
static ccKdTree * ToKdTree(ccHObject *obj)
Converts current object to ccKdTree (if possible)
static ccGenericPointCloud * ToGenericPointCloud(ccHObject *obj, bool *isLockedVertices=nullptr)
Converts current object to 'equivalent' ccGenericPointCloud.
static cc2DLabel * To2DLabel(ccHObject *obj)
Converts current object to cc2DLabel (if possible)
Hierarchical CLOUDVIEWER Object.
Definition: ecvHObject.h:25
virtual void notifyGeometryUpdate()
Definition: ecvHObject.cpp:104
static Eigen::Matrix3d GetRotationMatrixFromAxisAngle(const Eigen::Vector3d &rotation)
Get Rotation Matrix from AxisAngle RotationType.
Definition: ecvHObject.cpp:420
static Eigen::Vector3d ComputeMinBound(const std::vector< Eigen::Vector3d > &points)
Compute min bound of a list points.
Definition: ecvHObject.cpp:272
virtual ecvOrientedBBox GetOrientedBoundingBox() const
Definition: ecvHObject.cpp:449
void setLineWidthRecursive(PointCoordinateType width)
Definition: ecvHObject.cpp:804
virtual SelectionBehavior getSelectionBehavior() const
Returns selection behavior.
Definition: ecvHObject.h:621
bool fromFileNoChildren(QFile &in, short dataVersion, int flags, LoadedIDMap &oldToNewIDMap)
Custom version of ccSerializableObject::fromFile.
static Eigen::Matrix3d GetRotationMatrixFromYXZ(const Eigen::Vector3d &rotation)
Get Rotation Matrix from YXZ RotationType.
Definition: ecvHObject.cpp:413
void hideBB(CC_DRAW_CONTEXT context)
virtual void redrawDisplay(bool forceRedraw=true, bool only2D=false)
Redraws associated display.
static Eigen::Matrix3d GetRotationMatrixFromEulerAngle(const Eigen::Vector3d &rotation)
Get Rotation Matrix from Euler angle.
Definition: ecvHObject.cpp:434
static Eigen::Matrix3d GetRotationMatrixFromXYZ(const Eigen::Vector3d &rotation)
Get Rotation Matrix from XYZ RotationType.
Definition: ecvHObject.cpp:378
virtual void drawMeOnly(CC_DRAW_CONTEXT &context)
Draws the entity only (not its children)
Definition: ecvHObject.h:655
void draw(CC_DRAW_CONTEXT &context) override
Draws entity and its children.
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.
Definition: ecvHObject.h:652
void setHideShowType(CC_DRAW_CONTEXT &context)
virtual ccBBox getBB_recursive(bool withGLFeatures=false, bool onlyEnabledChildren=true)
Returns the bounding-box of this entity and it's children.
Definition: ecvHObject.cpp:759
virtual GlobalBoundingBox getOwnGlobalBB(bool withGLFeatures=false)
bool m_isDeleting
Flag to safely handle dependencies when the object is being deleted.
Definition: ecvHObject.h:730
SelectionBehavior
Behavior when selected.
Definition: ecvHObject.h:605
@ SELECTION_FIT_BBOX
Definition: ecvHObject.h:607
@ SELECTION_AA_BBOX
Definition: ecvHObject.h:606
@ SELECTION_IGNORED
Definition: ecvHObject.h:608
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.
Definition: ecvHObject.cpp:251
cloudViewer::BoundingBoxTpl< double > GlobalBoundingBox
Global (non-shifted) bounding-box.
Definition: ecvHObject.h:436
virtual bool isShareable() const
Returns whether object is shareable or not.
Definition: ecvHObject.h:602
bool getAbsoluteGLTransformation(ccGLMatrix &trans) const
Definition: ecvHObject.cpp:740
ccGLMatrix m_glTransHistory
Cumulative GL transformation.
Definition: ecvHObject.h:727
ENTITY_TYPE getEntityType() const
virtual short minimumFileVersion_MeOnly() const
void transferChildren(ccHObject &newParent, bool forceFatherDependent=false)
Transfer all children to another parent.
Definition: ecvHObject.cpp:664
int getChildIndex(const ccHObject *aChild) const
Returns child index.
Definition: ecvHObject.cpp:639
void removeFromRenderScreen(bool recursive=true)
Definition: ecvHObject.cpp:709
virtual bool fromFile_MeOnly(QFile &in, short dataVersion, int flags, LoadedIDMap &oldToNewIDMap)
Loads own object data.
int getIndex() const
Returns index relatively to its parent or -1 if no parent.
Definition: ecvHObject.cpp:695
static Eigen::Vector3d ComputeCenter(const std::vector< Eigen::Vector3d > &points)
Computer center of a list of points.
Definition: ecvHObject.cpp:296
bool isSerializable() const override
Returns whether object is serializable of not.
int getDependencyFlagsWith(const ccHObject *otherObject)
Returns the dependency flags with a given object.
Definition: ecvHObject.cpp:487
void removeAllChildren()
Removes all children.
SelectionBehavior m_selectionBehavior
Selection behavior.
Definition: ecvHObject.h:715
std::map< ccHObject *, int > m_dependencies
Dependencies map.
Definition: ecvHObject.h:721
short minimumFileVersion() const override
Returns the minimum file version required to save this instance.
static void RotateCovariances(const Eigen::Matrix3d &R, std::vector< Eigen::Matrix3d > &covariances)
Rotate all covariance matrices with the rotation matrix R.
Definition: ecvHObject.cpp:371
void removeDependencyWith(ccHObject *otherObject)
Removes any dependency flags with a given object.
Definition: ecvHObject.cpp:497
ccHObject * find(unsigned uniqueID)
Finds an entity in this object hierarchy.
Definition: ecvHObject.cpp:594
void addDependency(ccHObject *otherObject, int flags, bool additive=true)
Adds a new dependence (additive or not)
Definition: ecvHObject.cpp:455
void detachChild(ccHObject *child)
Detaches a specific child.
Definition: ecvHObject.cpp:988
virtual bool isDisplayed() const
Returns whether the object is actually displayed (visible) or not.
Definition: ecvHObject.cpp:934
bool isAncestorOf(const ccHObject *anObject) const
Returns true if the current object is an ancestor of the specified one.
Definition: ecvHObject.cpp:699
static void RotateNormals(const Eigen::Matrix3d &R, std::vector< Eigen::Vector3d > &normals)
Rotate all normals with the rotation matrix R.
Definition: ecvHObject.cpp:361
virtual bool toFile_MeOnly(QFile &out, short dataVersion) const
Save own object data.
QString getViewId() const
Definition: ecvHObject.h:225
static void TransformNormals(const Eigen::Matrix4d &transformation, std::vector< Eigen::Vector3d > &normals)
Transforms the normals with the transformation matrix.
Definition: ecvHObject.cpp:317
void applyGLTransformation_recursive(const ccGLMatrix *trans=nullptr)
Applies the active OpenGL transformation to the entity (recursive)
Definition: ecvHObject.cpp:948
unsigned getChildrenNumber() const
Returns the number of children.
Definition: ecvHObject.h:312
void setPointSizeRecursive(int pSize)
Definition: ecvHObject.cpp:791
virtual void drawNameIn3D()
Draws the entity name in 3D.
virtual ccBBox getDisplayBB_recursive(bool relative)
Returns the bounding-box of this entity and it's children WHEN DISPLAYED.
Definition: ecvHObject.cpp:817
unsigned int getChildCountRecursive() const
Returns the total number of children under this object recursively.
Definition: ecvHObject.cpp:584
virtual ccBBox getOwnFitBB(ccGLMatrix &trans)
Returns best-fit bounding-box (if available)
virtual void drawBB(CC_DRAW_CONTEXT &context, const ecvColor::Rgb &col)
Draws the entity (and its children) bounding-box.
void getTypeID_recursive(std::vector< removeInfo > &rmInfos, bool relative)
Definition: ecvHObject.cpp:841
void setRedrawFlagRecursive(bool redraw=false)
Definition: ecvHObject.cpp:772
virtual void applyGLTransformation(const ccGLMatrix &trans)
Applies a GL transformation to the entity.
Definition: ecvHObject.cpp:944
void updateNameIn3DRecursive()
static ccHObject * New(CV_CLASS_ENUM objectType, const char *name=nullptr)
Static factory.
Definition: ecvHObject.cpp:128
static void TranslatePoints(const Eigen::Vector3d &translation, std::vector< Eigen::Vector3d > &points, bool relative)
Apply translation to the geometry coordinates.
Definition: ecvHObject.cpp:333
DEPENDENCY_FLAGS
Dependency flags.
Definition: ecvHObject.h:257
@ DP_NOTIFY_OTHER_ON_DELETE
Definition: ecvHObject.h:259
@ DP_DELETE_OTHER
Definition: ecvHObject.h:265
@ DP_PARENT_OF_OTHER
Definition: ecvHObject.h:266
@ DP_NOTIFY_OTHER_ON_UPDATE
Definition: ecvHObject.h:261
unsigned findMaxUniqueID_recursive() const
Returns the max 'unique ID' of this entity and its siblings.
Definition: ecvHObject.cpp:975
static Eigen::Matrix3d GetRotationMatrixFromZYX(const Eigen::Vector3d &rotation)
Get Rotation Matrix from ZYX RotationType.
Definition: ecvHObject.cpp:406
ccHObject * getParent() const
Returns parent object.
Definition: ecvHObject.h:245
void detachAllChildren()
Removes a specific child.
ccHObject(QString name=QString())
Default constructor.
Definition: ecvHObject.cpp:54
virtual bool isBranchEnabled() const
Returns whether the object and all its ancestors are enabled.
Definition: ecvHObject.cpp:936
static Eigen::Matrix3d GetRotationMatrixFromQuaternion(const Eigen::Vector4d &rotation)
Get Rotation Matrix from Quaternion.
Definition: ecvHObject.cpp:426
static void RotatePoints(const Eigen::Matrix3d &R, std::vector< Eigen::Vector3d > &points, const Eigen::Vector3d &center)
Rotate all points with the rotation matrix R.
Definition: ecvHObject.cpp:353
void transferChild(ccHObject *child, ccHObject &newParent)
Transfer a given child to another parent.
Definition: ecvHObject.cpp:646
virtual ~ccHObject() override
Default destructor.
Definition: ecvHObject.cpp:74
void removeDependencyFlag(ccHObject *otherObject, DEPENDENCY_FLAGS flag)
Removes a given dependency flag.
Definition: ecvHObject.cpp:506
ccHObject * m_parent
Parent.
Definition: ecvHObject.h:709
void removeChild(ccHObject *child)
virtual GlobalBoundingBox getGlobalBB_recursive(bool withGLFeatures=false, bool onlyEnabledChildren=true)
Returns the global bounding-box of this entity and it's children.
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.
Definition: ecvHObject.cpp:611
bool pushDisplayState() override
Pushes the current display state (overridden)
virtual bool addChild(ccHObject *child, int dependencyFlags=DP_PARENT_OF_OTHER, int insertIndex=-1)
Adds a child.
Definition: ecvHObject.cpp:534
void swapChildren(unsigned firstChildIndex, unsigned secondChildIndex)
Swaps two children.
Definition: ecvHObject.cpp:687
static void TransformPoints(const Eigen::Matrix4d &transformation, std::vector< Eigen::Vector3d > &points)
Transforms all points with the transformation matrix.
Definition: ecvHObject.cpp:307
virtual void onDeletionOf(const ccHObject *obj)
This method is called when another object is deleted.
Definition: ecvHObject.cpp:519
virtual ccBBox getOwnBB(bool withGLFeatures=false)
Returns the entity's own bounding-box.
Definition: ecvHObject.cpp:757
bool fromFile(QFile &in, short dataVersion, int flags, LoadedIDMap &oldToNewIDMap) override
Loads data from binary stream.
static Eigen::Matrix3d GetRotationMatrixFromXZY(const Eigen::Vector3d &rotation)
Get Rotation Matrix from XZY RotationType.
Definition: ecvHObject.cpp:399
static Eigen::Matrix3d GetRotationMatrixFromYZX(const Eigen::Vector3d &rotation)
Get Rotation Matrix from YZX RotationType.
Definition: ecvHObject.cpp:385
std::vector< ccHObject * > Container
Standard instances container (for children, etc.)
Definition: ecvHObject.h:337
static void ScalePoints(const double scale, std::vector< Eigen::Vector3d > &points, const Eigen::Vector3d &center)
Scale the coordinates of all points by the scaling factor scale.
Definition: ecvHObject.cpp:345
void setForceRedrawRecursive(bool redraw=false)
Definition: ecvHObject.cpp:783
virtual ccBBox GetAxisAlignedBoundingBox() const
Returns an axis-aligned bounding box of the geometry.
Definition: ecvHObject.cpp:447
static void TransformCovariances(const Eigen::Matrix4d &transformation, std::vector< Eigen::Matrix3d > &covariances)
Transforms all covariance matrices with the transformation.
Definition: ecvHObject.cpp:327
void popDisplayState(bool apply=true) override
Pops the last pushed display state (overridden)
static Eigen::Matrix3d GetRotationMatrixFromZXY(const Eigen::Vector3d &rotation)
Get Rotation Matrix from ZXY RotationType.
Definition: ecvHObject.cpp:392
void showBB(CC_DRAW_CONTEXT context)
static Eigen::Vector3d ComputeMaxBound(const std::vector< Eigen::Vector3d > &points)
Compute max bound of a list points.
Definition: ecvHObject.cpp:284
ccHObject * getChild(unsigned childPos) const
Returns the ith child.
Definition: ecvHObject.h:325
Container m_children
Children.
Definition: ecvHObject.h:712
virtual QIcon getIcon() const
Returns the icon associated to this entity.
Definition: ecvHObject.cpp:248
CV_CLASS_ENUM getClassID() const override
Returns class ID.
Definition: ecvHObject.h:232
void hideObject_recursive(bool recursive)
Generic image.
Definition: ecvImage.h:19
KD-tree structure.
Definition: ecvKdTree.h:25
Mesh (triangle) material.
Triangular mesh.
Definition: ecvMesh.h:35
Generic "CLOUDVIEWER Object" template.
Definition: ecvObject.h:49
virtual bool getRemoveFlag()
Returns removeFlag.
Definition: ecvObject.h:83
short minimumFileVersion() const override
Returns the minimum file version required to save this instance.
Definition: ecvObject.cpp:187
virtual QString getName() const
Returns object name.
Definition: ecvObject.h:72
virtual unsigned getUniqueID() const
Returns object unique ID.
Definition: ecvObject.h:86
bool isA(CV_CLASS_ENUM type) const
Definition: ecvObject.h:131
static CV_CLASS_ENUM ReadClassIDFromFile(QFile &in, short dataVersion)
Helper: reads out class ID from a binary stream.
Definition: ecvObject.cpp:189
QVariant getMetaData(const QString &key) const
Returns a given associated meta data.
Definition: ecvObject.cpp:208
virtual void setName(const QString &name)
Sets object name.
Definition: ecvObject.h:75
virtual void setEnabled(bool state)
Sets the "enabled" property.
Definition: ecvObject.h:102
bool isLeaf() const
Definition: ecvObject.h:122
virtual bool isEnabled() const
Returns whether the object is enabled or not.
Definition: ecvObject.h:97
bool toFile(QFile &out, short dataVersion) const override
Saves data to binary stream.
Definition: ecvObject.cpp:127
bool fromFile(QFile &in, short dataVersion, int flags, LoadedIDMap &oldToNewIDMap) override
Reimplemented from ccSerializableObject::fromFile.
Definition: ecvObject.cpp:234
bool isKindOf(CV_CLASS_ENUM type) const
Definition: ecvObject.h:128
Octree structure.
Definition: ecvOctree.h:27
Interface for a planar entity.
void glDrawNormal(CC_DRAW_CONTEXT &context, const CCVector3 &pos, float scale, const ecvColor::Rgb *color=0)
Draws a normal vector (OpenGL)
void clearNormalVector(CC_DRAW_CONTEXT &context)
void showNormalVector(bool state)
Show normal vector.
Plane (primitive)
Definition: ecvPlane.h:18
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
Colored polyline.
Definition: ecvPolyline.h:24
PointCoordinateType getWidth() const
Returns the width of the line.
Definition: ecvPolyline.h:94
void setWidth(PointCoordinateType width)
Sets the width of the line.
Quadric (primitive)
Definition: ecvQuadric.h:16
Generic sensor interface.
Definition: ecvSensor.h:27
virtual void hideShowDrawings(CC_DRAW_CONTEXT &context)
Definition: ecvSensor.cpp:56
virtual void clearDrawings()
Definition: ecvSensor.cpp:54
static bool CorruptError()
Sends a custom error message (corrupted file) and returns 'false'.
QMultiMap< unsigned, unsigned > LoadedIDMap
Map of loaded unique IDs (old ID --> new ID)
static bool ReadError()
Sends a custom error message (read error) and returns 'false'.
static bool WriteError()
Sends a custom error message (write error) and returns 'false'.
Sphere (primitive)
Definition: ecvSphere.h:16
A sub-mesh.
Definition: ecvSubMesh.h:19
Torus (primitive)
Definition: ecvTorus.h:16
Bounding box structure.
Definition: BoundingBox.h:25
Vector3Tpl< T > getCenter() const
Returns center.
Definition: BoundingBox.h:164
const Vector3Tpl< T > & maxCorner() const
Returns max corner (const)
Definition: BoundingBox.h:156
const Vector3Tpl< T > & minCorner() const
Returns min corner (const)
Definition: BoundingBox.h:154
bool isValid() const
Returns whether bounding box is valid or not.
Definition: BoundingBox.h:203
RGB color structure.
Definition: ecvColorTypes.h:49
static ecvDisplayTools * TheInstance()
static void RemoveEntities(const ccHObject *obj)
static void RemoveWidgets(const WIDGETS_PARAMETER &param, bool update=false)
static QFont GetTextDisplayFont()
static void GetGLCameraParameters(ccGLCameraParameters &params)
Returns the current OpenGL camera parameters.
static void InvalidateViewport()
static void RemoveBB(CC_DRAW_CONTEXT context)
static bool HideShowEntities(const ccHObject *obj, bool visible)
static QMainWindow * GetMainWindow()
static void Deprecate3DLayer()
static ENTITY_TYPE ConvertToEntityType(const CV_CLASS_ENUM &type)
virtual void getDataAxesGridProperties(const QString &viewID, AxesGridProperties &props, int viewport=0) const
Get Data Axes Grid properties (Virtual interface for derived classes)
static void RedrawDisplay(bool only2D=false, bool forceRedraw=true)
static QWidget * GetCurrentScreen()
static void DisplayText(const QString &text, int x, int y, unsigned char align=ALIGN_DEFAULT, float bkgAlpha=0.0f, const unsigned char *rgbColor=nullptr, const QFont *font=nullptr, const QString &id="")
Displays a string at a given 2D position.
static const ParamStruct & Parameters()
Returns the stored values of each parameter.
static ecvOrientedBBox CreateFromAxisAlignedBoundingBox(const ccBBox &aabox)
virtual ecvOrientedBBox & Transform(const Eigen::Matrix4d &transformation) override
Apply transformation (4x4 matrix) to the geometry coordinates.
void draw(CC_DRAW_CONTEXT &context) override
Draws entity and its children.
double colors[3]
double normals[3]
#define LogWarning(...)
Definition: Logging.h:72
unsigned char ColorCompType
Default color components type (R,G and B)
Definition: ecvColorTypes.h:29
#define MACRO_SkipUnselected(context)
#define MACRO_Draw2D(context)
#define MACRO_Draw3D(context)
@ ECV_WIREFRAME_MODE
#define MACRO_Foreground(context)
#define MACRO_EntityPicking(context)
@ WIDGET_RECTANGLE_2D
@ WIDGET_T2D
ENTITY_TYPE
@ ECV_SENSOR
@ ECV_KDTREE
@ ECV_MESH
@ ECV_NONE
@ ECV_OCTREE
@ ECV_2DLABLE
@ ECV_SHAPE
@ ECV_2DLABLE_VIEWPORT
#define MACRO_SkipSelected(context)
a[190]
ImGuiContext * context
Definition: Window.cpp:76
@ SENSOR
Definition: CVTypes.h:116
@ HIERARCHY_OBJECT
Definition: CVTypes.h:103
@ CUSTOM_H_OBJECT
Definition: CVTypes.h:179
@ VIEWPORT_2D_OBJECT
Definition: CVTypes.h:141
@ PRIMITIVE
Definition: CVTypes.h:119
@ MESH
Definition: CVTypes.h:105
@ GBL_SENSOR
Definition: CVTypes.h:117
@ NORMAL_INDEXES_ARRAY
Definition: CVTypes.h:135
@ CALIBRATED_IMAGE
Definition: CVTypes.h:115
@ RGB_COLOR_ARRAY
Definition: CVTypes.h:137
@ IMAGE
Definition: CVTypes.h:114
@ COORDINATESYSTEM
Definition: CVTypes.h:145
@ TRANS_BUFFER
Definition: CVTypes.h:144
@ CONE
Definition: CVTypes.h:123
@ MESH_GROUP
Definition: CVTypes.h:107
@ POINT_CLOUD
Definition: CVTypes.h:104
@ TEX_COORDS_ARRAY
Definition: CVTypes.h:139
@ DISH
Definition: CVTypes.h:129
@ NORMALS_ARRAY
Definition: CVTypes.h:134
@ CIRCLE
Definition: CVTypes.h:113
@ LABEL_2D
Definition: CVTypes.h:140
@ POLY_LINE
Definition: CVTypes.h:112
@ POINT_KDTREE
Definition: CVTypes.h:111
@ FACET
Definition: CVTypes.h:109
@ SUB_MESH
Definition: CVTypes.h:106
@ QUADRIC
Definition: CVTypes.h:131
@ OLD_CYLINDER_ID
Definition: CVTypes.h:124
@ POINT_OCTREE
Definition: CVTypes.h:110
@ TORUS
Definition: CVTypes.h:122
@ EXTRU
Definition: CVTypes.h:130
@ CUSTOM_LEAF_OBJECT
Definition: CVTypes.h:180
@ SPHERE
Definition: CVTypes.h:121
@ MATERIAL_SET
Definition: CVTypes.h:132
@ CAMERA_SENSOR
Definition: CVTypes.h:118
@ PLANE
Definition: CVTypes.h:120
@ DISC
Definition: CVTypes.h:146
@ VIEWPORT_2D_LABEL
Definition: CVTypes.h:142
@ CYLINDER
Definition: CVTypes.h:126
@ OBJECT
Definition: CVTypes.h:102
Eigen::Matrix3d RotationMatrixX(double radians)
Definition: Eigen.cpp:248
Eigen::Matrix3d RotationMatrixY(double radians)
Definition: Eigen.cpp:255
Eigen::Matrix3d RotationMatrixZ(double radians)
Definition: Eigen.cpp:262
void swap(cloudViewer::core::SmallVectorImpl< T > &LHS, cloudViewer::core::SmallVectorImpl< T > &RHS)
Implement std::swap in terms of SmallVector swap.
Definition: SmallVector.h:1370
cloudViewer::DgmOctree * octree
Data Axes Grid properties structure Encapsulates all properties for vtkCubeAxesActor configuration.
HObjectDisplayState(const ccHObject &obj)
QSharedPointer< DisplayState > Shared
OpenGL camera parameters.
bool project(const CCVector3d &input3D, CCVector3d &output2D, bool *inFrustum=nullptr) const
Projects a 3D point in 2D (+ normalized 'z' coordinate)
Display context.
ecvColor::Rgbub bbDefaultCol
Default bounding-box color.
unsigned char defaultLineWidth
unsigned char currentLineWidth
MESH_RENDERING_MODE meshRenderingMode
GUI parameters.
double bbOpacity
Bounding-box opacity (0.0 to 1.0)
ecvColor::Rgbub bbDefaultCol
Bounding-boxes color.
unsigned bbLineWidth
Bounding-box line width.
bool showBBOnSelected
Show bounding-box on selected objects.
ENTITY_TYPE hideType
Hide type.
QString hideId
Hide viewId.
to be removed structure
ENTITY_TYPE removeType
Remove type.
QString removeId
Remove viewId.