ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ccTopologyRelation.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 "ccTopologyRelation.h"
9 
10 #include "ccGeoObject.h"
11 
12 // pass ctors straight to PointPair
14  int older_id,
15  int younger_id,
16  int type)
17  : ccPointPair(associatedCloud) {
18  m_older_id = older_id;
19  m_younger_id = younger_id;
20  m_type = type;
21 
23 }
24 
26  // retrive metadata values
27  if (obj->hasMetaData("RelationType")) {
28  m_type = obj->getMetaData("RelationType").toInt();
29  }
30 
31  if (obj->hasMetaData("Older_ID")) {
32  m_older_id = obj->getMetaData("Older_ID").toInt();
33  }
34 
35  if (obj->hasMetaData("Younger_ID")) {
36  m_older_id = obj->getMetaData("Younger_ID").toInt();
37  }
38 
39  // update
41 }
42 
44  // add metadata tag defining the ccCompass class type
45  QVariantMap* map = new QVariantMap();
46  map->insert("ccCompassType", "TopologyRelation");
47  map->insert("RelationType", m_type);
48  map->insert("Older_ID", m_older_id);
49  map->insert("Younger_ID", m_younger_id);
50  setMetaData(*map, true);
51 
52  showNameIn3D(true);
53 }
54 
56  ccGeoObject* younger) {
57  // get underlying point cloud
58  ccPointCloud* c = dynamic_cast<ccPointCloud*>(getAssociatedCloud());
59  assert(c);
60 
61  // clear points, both in cloud and in our underlying polyline
62  clear();
63  c->clear();
64  c->setEnabled(false);
65  c->setVisible(false); // should be hidden
66 
67  // make room for start and end points in underlying cloud
68  c->reserve(2);
69 
70  // calculate centroids for graphics
71  CCVector3 old_P =
72  older->getBB_recursive().getCenter(); // first geoObject centroid
73  CCVector3 young_P = younger->getBB_recursive()
74  .getCenter(); // second geoObject centroid
75 
76  // add start/end points too point cloud
77  c->addPoint(old_P);
78  c->addPoint(young_P);
79 
80  // add polyline points (these will then cause the underlying points in the
81  // cloud to be drawn)
82  addPointIndex(1); // arrow points to older object
83  addPointIndex(0);
84 
85  // set name
86  switch (m_type) {
88  setName(older->getName() + " Equivalent to " + younger->getName());
89  break;
91  setName(older->getName() + " Precedes " + younger->getName());
92  break;
94  setName(older->getName() + " Follows " + younger->getName());
95  break;
97  setName(older->getName() + " Younger than " + younger->getName());
98  break;
100  setName(older->getName() + " Older than " + younger->getName());
101  break;
103  setName(older->getName() + " Not Older than " + younger->getName());
104  break;
106  setName(older->getName() + " Not Younger than " +
107  younger->getName());
108  break;
109  default:
110  setName(older->getName() + " Unknown Relationship to " +
111  younger->getName());
112  }
113 
114  showNameIn3D(true);
115 }
116 
117 // returns the youuger GeoObject
118 int ccTopologyRelation::getYoungerID() { return m_younger_id; }
119 
120 // returns the older GeoObjects
121 int ccTopologyRelation::getOlderID() { return m_older_id; }
122 
123 // return the type of this relationship
124 int ccTopologyRelation::getType() { return m_type; }
125 
126 // get the type of this relationship
127 void ccTopologyRelation::setType(int topologyType) { m_type = topologyType; }
128 
130  switch (type) {
145  default:
147  }
148 }
149 
150 // returns true if object is a lineation
152  if (object->hasMetaData("ccCompassType")) {
153  return object->getMetaData("ccCompassType")
154  .toString()
155  .contains("TopologyRelation");
156  }
157  return false;
158 }
char type
virtual void setVisible(bool state)
Sets entity visibility.
virtual void showNameIn3D(bool state)
Sets whether name should be displayed in 3D.
Hierarchical CLOUDVIEWER Object.
Definition: ecvHObject.h:25
virtual ccBBox getBB_recursive(bool withGLFeatures=false, bool onlyEnabledChildren=true)
Returns the bounding-box of this entity and it's children.
virtual QString getName() const
Returns object name.
Definition: ecvObject.h:72
void setMetaData(const QString &key, const QVariant &data)
Sets a meta-data element.
QVariant getMetaData(const QString &key) const
Returns a given associated meta data.
bool hasMetaData(const QString &key) const
Returns whether a meta-data element with the given key exists or not.
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
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
bool reserve(unsigned numberOfPoints) override
Reserves memory for all the active features.
void clear() override
Clears the entity from all its points and features.
Colored polyline.
Definition: ecvPolyline.h:24
static int invertType(int type)
static const int UNKNOWN
static const int NOT_OLDER_THAN
static const int EQUIVALENCE
static const int IMMEDIATELY_PRECEDES
static const int OLDER_THAN
void updateMetadata() override
static const int YOUNGER_THAN
static const int IMMEDIATELY_FOLLOWS
void constructGraphic(ccGeoObject *older, ccGeoObject *younger)
static const int NOT_YOUNGER_THAN
ccTopologyRelation(ccPointCloud *associatedCloud, int older_id, int younger_id, int type)
static bool isTopologyRelation(ccHObject *obj)
void setType(int topologyType)
Vector3Tpl< T > getCenter() const
Returns center.
Definition: BoundingBox.h:164
void addPoint(const CCVector3 &P)
Adds a 3D point to the database.
void clear(bool unusedParam=true) override
Clears the cloud.
Definition: Polyline.cpp:15
virtual bool addPointIndex(unsigned globalIndex)
Point global index insertion mechanism.
virtual GenericIndexedCloudPersist * getAssociatedCloud()
Returns the associated (source) cloud.