ACloudViewer
3.9.4
A Modern Library for 3D Data Processing
ccFitPlaneTool.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 "
ccFitPlaneTool.h
"
9
10
// CV_DB_LIB
11
// #include <ecvPointCloud.h>
12
13
ccFitPlaneTool::ccFitPlaneTool
() :
ccTool
() {}
14
15
ccFitPlaneTool::~ccFitPlaneTool
() {
16
if
(
m_mouseCircle
) {
17
assert(
false
);
// we should never end up here...
18
m_mouseCircle
->
ownerIsDead
();
19
delete
m_mouseCircle
;
20
m_mouseCircle
=
nullptr
;
21
}
22
}
23
24
// called when the tool is set to active (for initialization)
25
void
ccFitPlaneTool::toolActivated
() {
26
m_mouseCircle
=
new
ccMouseCircle
(
ecvDisplayTools::GetCurrentScreen
());
27
m_mouseCircle
->
setVisible
(
true
);
28
29
// set orthographic view (as this tool doesn't work in perspective mode)
30
ecvDisplayTools::SetPerspectiveState
(
false
,
true
);
31
}
32
33
// called when the tool is set to disactive (for cleanup)
34
void
ccFitPlaneTool::toolDisactivated
() {
35
if
(
m_mouseCircle
) {
36
m_mouseCircle
->
setVisible
(
false
);
37
delete
m_mouseCircle
;
38
m_mouseCircle
=
nullptr
;
39
}
40
}
41
42
// called when a point in a point cloud gets picked while this tool is active
43
void
ccFitPlaneTool::pointPicked
(
ccHObject
* insertPoint,
44
unsigned
itemIdx,
45
ccPointCloud
* cloud,
46
const
CCVector3
& P) {
47
// get or generate octree
48
ccOctree::Shared
oct = cloud->
getOctree
();
49
if
(!oct) {
50
oct = cloud->
computeOctree
();
// if the user clicked "no" when asked to
51
// compute the octree then tough....
52
}
53
54
// nearest neighbour search
55
float
r =
m_mouseCircle
->
getRadiusWorld
();
56
unsigned
char
level =
57
oct->findBestLevelForAGivenNeighbourhoodSizeExtraction(r);
58
cloudViewer::DgmOctree::NeighboursSet
set;
59
int
n = oct->getPointsInSphericalNeighbourhood(P,
PointCoordinateType
(r),
60
set, level);
61
// Put data in a point cloud class and encapsulate as a "neighbourhood"
62
cloudViewer::DgmOctreeReferenceCloud
nCloud(&set, n);
63
cloudViewer::Neighbourhood
Z(&nCloud);
64
65
// Fit plane!
66
double
rms = 0.0;
// output for rms
67
ccFitPlane
* pPlane =
ccFitPlane::Fit
(&nCloud, &rms);
68
69
if
(pPlane)
// valid fit
70
{
71
pPlane->
updateAttributes
(rms,
m_mouseCircle
->
getRadiusWorld
());
72
73
// make plane to add to display
74
pPlane->
setVisible
(
true
);
75
pPlane->
setSelectionBehavior
(
ccHObject::SELECTION_IGNORED
);
76
77
// add plane to scene graph
78
insertPoint->
addChild
(pPlane);
79
// pPlane->setDisplay(m_app->getActiveWindow());
80
// pPlane->prepareDisplayForRefresh_recursive(); //not sure what this
81
// does, but it looks like fun
82
83
// add plane to TOC
84
m_app
->
addToDB
(pPlane,
false
,
false
,
false
,
false
);
85
86
// report orientation to console for convenience
87
m_app
->
dispToConsole
(
88
QString(
"[ccCompass] Surface orientation estimate = "
+
89
pPlane->
getName
()),
90
ecvMainAppInterface::STD_CONSOLE_MESSAGE
);
91
}
92
}
PointCoordinateType
float PointCoordinateType
Type of the coordinates of a (N-D) point.
Definition:
CVTypes.h:16
ccFitPlaneTool.h
Vector3Tpl< PointCoordinateType >
ccDrawableObject::setVisible
virtual void setVisible(bool state)
Sets entity visibility.
Definition:
ecvDrawableObject.h:40
ccFitPlaneTool::~ccFitPlaneTool
virtual ~ccFitPlaneTool()
Definition:
ccFitPlaneTool.cpp:15
ccFitPlaneTool::toolActivated
void toolActivated() override
Definition:
ccFitPlaneTool.cpp:25
ccFitPlaneTool::toolDisactivated
void toolDisactivated() override
Definition:
ccFitPlaneTool.cpp:34
ccFitPlaneTool::m_mouseCircle
ccMouseCircle * m_mouseCircle
Definition:
ccFitPlaneTool.h:39
ccFitPlaneTool::ccFitPlaneTool
ccFitPlaneTool()
Definition:
ccFitPlaneTool.cpp:13
ccFitPlaneTool::pointPicked
void pointPicked(ccHObject *insertPoint, unsigned itemIdx, ccPointCloud *cloud, const CCVector3 &P) override
Definition:
ccFitPlaneTool.cpp:43
ccFitPlane
Definition:
ccFitPlane.h:19
ccFitPlane::Fit
static ccFitPlane * Fit(cloudViewer::GenericIndexedCloudPersist *cloud, double *rms)
Definition:
ccFitPlane.cpp:120
ccFitPlane::updateAttributes
void updateAttributes(float rms, float search_r)
Definition:
ccFitPlane.cpp:56
ccGenericPointCloud::computeOctree
virtual ccOctree::Shared computeOctree(cloudViewer::GenericProgressCallback *progressCb=nullptr, bool autoAddChild=true)
Computes the cloud octree.
ccGenericPointCloud::getOctree
virtual ccOctree::Shared getOctree() const
Returns the associated octree (if any)
ccHObject
Hierarchical CLOUDVIEWER Object.
Definition:
ecvHObject.h:25
ccHObject::SELECTION_IGNORED
@ SELECTION_IGNORED
Definition:
ecvHObject.h:608
ccHObject::addChild
virtual bool addChild(ccHObject *child, int dependencyFlags=DP_PARENT_OF_OTHER, int insertIndex=-1)
Adds a child.
ccHObject::setSelectionBehavior
virtual void setSelectionBehavior(SelectionBehavior mode)
Sets selection behavior (when displayed)
Definition:
ecvHObject.h:616
ccMouseCircle
Definition:
ccMouseCircle.h:24
ccMouseCircle::ownerIsDead
void ownerIsDead()
Definition:
ccMouseCircle.h:41
ccMouseCircle::getRadiusWorld
float getRadiusWorld()
Definition:
ccMouseCircle.cpp:59
ccObject::getName
virtual QString getName() const
Returns object name.
Definition:
ecvObject.h:72
ccOctree::Shared
QSharedPointer< ccOctree > Shared
Shared pointer.
Definition:
ecvOctree.h:32
ccPointCloud
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
Definition:
ecvPointCloud.h:147
ccTool
Definition:
ccTool.h:18
ccTool::m_app
ecvMainAppInterface * m_app
Definition:
ccTool.h:67
cloudViewer::DgmOctreeReferenceCloud
A kind of ReferenceCloud based on the DgmOctree::NeighboursSet structure.
Definition:
DgmOctreeReferenceCloud.h:18
cloudViewer::DgmOctree::NeighboursSet
std::vector< PointDescriptor > NeighboursSet
A set of neighbours.
Definition:
DgmOctree.h:133
cloudViewer::Neighbourhood
Definition:
Neighbourhood.h:25
ecvDisplayTools::GetCurrentScreen
static QWidget * GetCurrentScreen()
Definition:
ecvDisplayTools.h:666
ecvDisplayTools::SetPerspectiveState
static void SetPerspectiveState(bool state, bool objectCenteredView)
Set perspective state/mode.
ecvMainAppInterface::STD_CONSOLE_MESSAGE
@ STD_CONSOLE_MESSAGE
Definition:
ecvMainAppInterface.h:117
ecvMainAppInterface::addToDB
virtual void addToDB(ccHObject *obj, bool updateZoom=false, bool autoExpandDBTree=true, bool checkDimensions=false, bool autoRedraw=true)=0
ecvMainAppInterface::dispToConsole
virtual void dispToConsole(QString message, ConsoleMessageLevel level=STD_CONSOLE_MESSAGE)=0
plugins
core
Standard
qCompass
src
ccFitPlaneTool.cpp
Generated on Wed Jan 28 2026 09:01:07 for ACloudViewer by
1.9.1