16 init(associatedCloud);
21 assert(cld !=
nullptr);
26 QString waypoints = obj->
getMetaData(
"waypoints").toString();
27 for (QString str : waypoints.split(
",")) {
29 int pID = str.toInt();
35 QVariantMap* map =
new QVariantMap();
36 map->insert(
"waypoints", waypoints);
49 for (
unsigned i = 0; i < obj->
size(); i++) {
60 if (obj->
size() == 0) {
81 void ccTrace::updateMetadata() {
82 QVariantMap* map =
new QVariantMap();
83 map->insert(
"ccCompassType",
"Trace");
84 map->insert(
"search_r", m_search_r);
105 if (inCircle(&start, &end, &Q)) {
132 bool ccTrace::inCircle(
const CCVector3* segStart,
137 segStart->
z - query->
z);
139 segEnd->
z - query->
z);
146 return QS.dot(QE) < 0;
169 m_maxIterations = maxIterations;
173 for (
unsigned i = 1; i <
m_waypoints.size(); i++) {
182 start, end, m_search_r);
197 start, end, m_search_r);
221 QVariantMap* map =
new QVariantMap();
222 QString waypoints =
"";
224 for (
unsigned i = 0; i <
m_waypoints.size(); i++) {
225 waypoints += QString::number(
m_waypoints[i]) +
",";
228 map->insert(
"waypoints", waypoints);
242 for (std::deque<int> seg :
m_trace) {
261 return std::deque<int>();
268 m_start_rgb[0] = s.
r;
269 m_start_rgb[1] = s.
g;
270 m_start_rgb[2] = s.
b;
292 std::priority_queue<Node*, std::vector<Node*>, Compare>
295 std::vector<Node*> nodes;
303 Node* current =
nullptr;
306 int smallest_cost = 999999;
308 float cur_d2, next_d2;
311 int bufferSize = 500000;
314 Node* node_buffer =
new Node[bufferSize];
315 nodes.push_back(node_buffer);
324 unsigned char level =
325 oct->findBestLevelForAGivenNeighbourhoodSizeExtraction(m_search_r);
328 node_buffer[0].set(start, 0,
nullptr);
329 openQueue.push(&node_buffer[0]);
332 visited[start] =
true;
334 while (openQueue.size() > 0)
337 if (iter_count > m_maxIterations) {
339 for (Node* n : nodes) {
344 return std::deque<int>();
350 current = openQueue.top();
351 current_idx = current->index;
356 if (current_idx == end)
358 std::deque<int>
path;
362 while (current->index != start) {
363 current = current->previous;
364 path.push_front(current->index);
367 path.push_front(start);
370 for (Node* n : nodes) {
382 cur_d2 = (cur->
x - end_v->
x) * (cur->
x - end_v->
x) +
383 (cur->
y - end_v->
y) * (cur->
y - end_v->
y) +
384 (cur->
z - end_v->
z) * (cur->
z - end_v->
z);
388 m_neighbours.clear();
390 oct->getPointsInSphericalNeighbourhood(
394 for (
size_t i = 0; i < m_neighbours.size(); i++) {
395 m_p = m_neighbours[i];
416 static_cast<ScalarType
>(
422 cost += current->total_cost;
425 if (nodeCount == bufferSize) {
427 node_buffer =
new Node[bufferSize];
428 nodes.push_back(node_buffer);
433 node_buffer[nodeCount].set(m_p.
pointIndex, cost, current);
436 openQueue.push(&node_buffer[nodeCount]);
447 return std::deque<int>();
487 (p1_rgb.
r - p2_rgb.
r) * (p1_rgb.
r - p2_rgb.
r) +
488 (p1_rgb.
g - p2_rgb.
g) * (p1_rgb.
g - p2_rgb.
g) +
489 (p1_rgb.
b - p2_rgb.
b) * (p1_rgb.
b - p2_rgb.
b)) +
493 sqrt((p1_rgb.
r - m_start_rgb[0]) *
494 (p1_rgb.
r - m_start_rgb[0]) +
495 (p1_rgb.
g - m_start_rgb[1]) *
496 (p1_rgb.
g - m_start_rgb[1]) +
497 (p1_rgb.
b - m_start_rgb[2]) *
498 (p1_rgb.
b - m_start_rgb[2])) +
500 sqrt((p1_rgb.
r - m_end_rgb[0]) *
501 (p1_rgb.
r - m_end_rgb[0]) +
502 (p1_rgb.
g - m_end_rgb[1]) *
503 (p1_rgb.
g - m_end_rgb[1]) +
504 (p1_rgb.
b - m_end_rgb[2]) *
505 (p1_rgb.
b - m_end_rgb[2])) +
507 sqrt((p2_rgb.
r - m_start_rgb[0]) *
508 (p2_rgb.
r - m_start_rgb[0]) +
509 (p2_rgb.
g - m_start_rgb[1]) *
510 (p2_rgb.
g - m_start_rgb[1]) +
511 (p2_rgb.
b - m_start_rgb[2]) *
512 (p2_rgb.
b - m_start_rgb[2])) +
514 sqrt((p2_rgb.
r - m_end_rgb[0]) *
515 (p2_rgb.
r - m_end_rgb[0]) +
516 (p2_rgb.
g - m_end_rgb[1]) *
517 (p2_rgb.
g - m_end_rgb[1]) +
518 (p2_rgb.
b - m_end_rgb[2]) *
519 (p2_rgb.
b - m_end_rgb[2]))) /
530 return (p2_rgb.
r + p2_rgb.
g +
555 if (m_neighbours.size() >
558 m_neighbours.push_back(
563 &m_neighbours,
static_cast<unsigned>(m_neighbours.size()));
567 cloudViewer::Neighbourhood::CurvatureType::MEAN_CURV);
569 m_neighbours.erase(m_neighbours.end() -
605 int p_value = p2_rgb.
r + p2_rgb.
g + p2_rgb.
b;
607 if (m_neighbours.size() >
614 for (
int i = 0; i < m_neighbours.size(); i++) {
619 double norm2 = deltaPos.
norm2d();
623 int c_value = (
static_cast<int>(c.
r) + c.
g) + c.
b;
629 int deltaValue = p_value - c_value;
636 sum.x += deltaPos.
x *
640 sum.y += deltaPos.
y * deltaValue;
641 sum.z += deltaPos.
z * deltaValue;
645 float gradient = sum.norm() / m_neighbours.size();
650 gradient =
std::min(gradient, 765 / search_r);
651 gradient *= search_r;
652 return 765 - gradient;
693 i,
static_cast<ScalarType
>((
static_cast<int>(col.
r) + col.
g) +
700 float roughnessKernelSize = m_search_r;
726 false,
false, &pDlg,
octree.data());
778 cloudViewer::Neighbourhood::CurvatureType::MEAN_CURV,
818 float min_planarity) {
822 if (
size() < 3)
return 0;
830 std::vector<double> eigValues;
834 std::sort(eigValues.rbegin(), eigValues.rend());
836 float y = eigValues[1];
837 float z = eigValues[2];
840 float planarity = 1.0f - z / y;
841 if (planarity < min_planarity) {
860 for (
unsigned i = 0; i <
size(); i++) {
870 if (acos(n_avg.
dot(n)) <
871 0.01745329251 * surface_effect_tolerance)
885 int vertexCount =
static_cast<int>(
m_cloud->
size());
886 for (
const std::deque<int>& seg :
m_trace) {
888 if (p >= 0 && p < vertexCount) {
907 unsigned char level = oct->findBestLevelForAGivenPopulationPerCell(2);
915 for (
unsigned int i = 0; i < 30; i++) {
917 int r = (rand() * rand()) %
921 nCloud->
clear(
false);
923 oct->findPointNeighbourhood(
m_cloud->
getPoint(r), nCloud, 2, level, d);
932 double d = dsum / 30;
956 new ccSphere(1.0f, 0,
"PointMarker", 6));
984 if (entityPickingMode) {
1017 double unitD = viewportParams.
zFar /
1020 scale =
static_cast<float>(
1037 for (
const std::deque<int>& seg :
m_trace) {
1060 for (
const std::deque<int>& seg :
m_trace) {
1070 fmin(pSize, 4) * 0.2;
1072 viewportParams.
zFar > 0) {
1079 double unitD = viewportParams.
zFar /
1082 scale =
static_cast<float>(
1107 return object->getMetaData(
"ccCompassType")
constexpr PointCoordinateType PC_ONE
'1' as a PointCoordinateType value
Vector3Tpl< PointCoordinateType > CCVector3
Default 3D Vector.
float PointCoordinateType
Type of the coordinates of a (N-D) point.
static QSharedPointer< ccSphere > c_unitPointMarker(0)
static bool Warning(const char *format,...)
Prints out a formatted warning message in console.
static bool Error(const char *format,...)
Display an error dialog with formatted message.
Jacobi eigen vectors/values decomposition.
Type dot(const Vector3Tpl &v) const
Dot product.
Type norm2() const
Returns vector square norm.
double norm2d() const
Returns vector square norm (forces double precision output)
static Vector3Tpl fromArray(const int a[3])
Constructor from an int array.
virtual void getDrawingParameters(glDrawParams ¶ms) const
Returns main OpenGL parameters for this entity.
static ccFitPlane * Fit(cloudViewer::GenericIndexedCloudPersist *cloud, double *rms)
void updateAttributes(float rms, float search_r)
T * data()
Returns a pointer to internal data.
virtual ccOctree::Shared computeOctree(cloudViewer::GenericProgressCallback *progressCb=nullptr, bool autoAddChild=true)
Computes the cloud octree.
virtual ccOctree::Shared getOctree() const
Returns the associated octree (if any)
Hierarchical CLOUDVIEWER Object.
ecvColor::Rgb getMeasurementColour() const
static const CCVector3 & GetNormal(unsigned normIndex)
Static access to ccNormalVectors::getNormal.
virtual QString getName() const
Returns object name.
virtual unsigned getUniqueID() const
Returns object unique ID.
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.
QSharedPointer< ccOctree > Shared
Shared pointer.
CCVector3 getNormal() const override
Returns the entity normal.
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
const CompressedNormType & getPointNormalIndex(unsigned pointIndex) const override
Returns compressed normal corresponding to a given point.
int addScalarField(const char *uniqueName) override
Creates a new scalar field and registers it.
bool hasNormals() const override
Returns whether normals are enabled or not.
bool hasDisplayedScalarField() const override
Returns whether an active scalar field is available or not.
bool hasColors() const override
Returns whether colors are enabled or not.
void deleteScalarField(int index) override
Deletes a specific scalar field.
ccScalarField * getCurrentDisplayedScalarField() const
Returns the currently displayed scalar (or 0 if none)
const ecvColor::Rgb & getPointColor(unsigned pointIndex) const override
Returns color corresponding to a given point.
PointCoordinateType m_width
Width of the line.
A scalar field associated to display-related parameters.
int getSegmentCostScalar(int p1, int p2)
std::vector< int > m_previous
int getSegmentCostDist(int p1, int p2)
std::deque< int > optimizeSegment(int start, int end, int offset=0)
std::vector< int > m_waypoints
int getSegmentCostScalarInv(int p1, int p2)
int insertWaypoint(int pointId)
ccFitPlane * fitPlane(int surface_effect_tolerance=10, float min_planarity=0.75f)
void bakePathToScalarField()
int getSegmentCostRGB(int p1, int p2)
static bool isTrace(ccHObject *object)
void buildCurvatureCost(QWidget *parent)
bool isGradientPrecomputed()
int getSegmentCostLight(int p1, int p2)
int getSegmentCostGrad(int p1, int p2, float search_r)
int getSegmentCostDark(int p1, int p2)
int getSegmentCost(int p1, int p2)
virtual void drawMeOnly(CC_DRAW_CONTEXT &context) override
Draws the entity only (not its children)
std::vector< std::deque< int > > m_trace
void buildGradientCost(QWidget *parent)
ccTrace(ccPointCloud *associatedCloud)
float calculateOptimumSearchRadius()
bool isCurvaturePrecomputed()
bool optimizePath(int maxIterations=1000000)
int getSegmentCostCurve(int p1, int p2)
A kind of ReferenceCloud based on the DgmOctree::NeighboursSet structure.
const CCVector3 * getPoint(unsigned index) const override
Returns the ith point.
std::vector< PointDescriptor > NeighboursSet
A set of neighbours.
ScalarType computeCurvature(const CCVector3 &P, CurvatureType cType)
Computes the curvature of a set of point (by fitting a 2.5D quadric)
cloudViewer::SquareMatrixd computeCovarianceMatrix()
Computes the covariance matrix.
int getScalarFieldIndexByName(const char *name) const
Returns the index of a scalar field represented by its name.
void setCurrentOutScalarField(int index)
Sets the OUTPUT scalar field.
ScalarField * getScalarField(int index) const
Returns a pointer to a specific scalar field.
void setPointScalarValue(unsigned pointIndex, ScalarType value) override
void setCurrentScalarField(int index)
Sets both the INPUT & OUTPUT scalar field.
unsigned size() const override
ScalarType getPointScalarValue(unsigned pointIndex) const override
void setCurrentInScalarField(int index)
Sets the INPUT scalar field.
const CCVector3 * getPoint(unsigned index) const override
void clear(bool unusedParam=true) override
Clears the cloud.
A very simple point cloud (no point duplication)
virtual bool addPointIndex(unsigned globalIndex)
Point global index insertion mechanism.
virtual GenericIndexedCloudPersist * getAssociatedCloud()
Returns the associated (source) cloud.
unsigned size() const override
Returns the number of points.
void invalidateBoundingBox()
Invalidates the bounding-box.
virtual unsigned getPointGlobalIndex(unsigned localIndex) const
virtual void clear(bool releaseMemory=false)
Clears the cloud.
virtual void setAssociatedCloud(GenericIndexedCloudPersist *cloud)
Sets the associated (source) cloud.
A simple scalar field (to be associated to a point cloud)
virtual void computeMinAndMax()
Determines the min and max values.
ScalarType getMin() const
Returns the minimum value.
ScalarType & getValue(std::size_t index)
ScalarType getMax() const
Returns the maximum value.
Graphical progress indicator (thread-safe)
Standard parameters for GL displays/viewports.
bool perspectiveView
Perspective view state.
double zFar
Actual perspective 'zFar' value.
#define MACRO_Draw3D(context)
#define MACRO_Foreground(context)
#define MACRO_EntityPicking(context)
static const std::string path
bool GreaterThanEpsilon(float x)
Test a floating point number against our epsilon (a very small number).
OpenGL camera parameters.
ccGLMatrixd modelViewMat
Model view matrix (GL_MODELVIEW)
int drawingFlags
Drawing options (see below)
unsigned char defaultLineWidth
TransformInfo transformInfo
unsigned char defaultPointSize
Structure used during nearest neighbour search.
const CCVector3 * point
Point.
unsigned pointIndex
Point index.
Display parameters of a 3D entity.
bool showColors
Display colors.
bool showNorms
Display normals.