ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ecvOctreeSpinBox.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 "ecvOctreeSpinBox.h"
9 
10 // cloudViewer
11 #include <CVMiscTools.h>
12 
13 // CV_DB_LIB
14 #include "ecvBBox.h"
15 #include "ecvGenericPointCloud.h"
16 #include "ecvOctree.h"
17 
18 ccOctreeSpinBox::ccOctreeSpinBox(QWidget* parent /*=0*/)
19  : QSpinBox(parent), m_octreeBoxWidth(0) {
21 
22  // we'll catch any modification of the spinbox value and update the suffix
23  // consequently
24  connect(this, SIGNAL(valueChanged(int)), this, SLOT(onValueChange(int)));
25 }
26 
28  if (!cloud) {
29  assert(false);
30  return;
31  }
32 
33  if (cloud->getOctree()) {
34  setOctree(cloud->getOctree().data());
35  } else {
36  ccBBox box = cloud->getOwnBB(false);
38  box.maxCorner());
40  onValueChange(value());
41  }
42 }
43 
45  if (octree) {
46  m_octreeBoxWidth = static_cast<double>(octree->getCellSize(0));
47  onValueChange(value());
48  } else {
49  m_octreeBoxWidth = 0;
50  setSuffix(QString());
51  }
52 }
53 
55  if (m_octreeBoxWidth > 0) {
56  if (level >=
57  0 /* && level <= cloudViewer::DgmOctree::MAX_OCTREE_LEVEL*/) {
58  double cs = m_octreeBoxWidth / pow(2.0, static_cast<double>(level));
59  setSuffix(QString(" (grid step = %1)").arg(cs));
60  } else {
61  // invalid level?!
62  setSuffix(QString());
63  }
64  }
65 }
Bounding box structure.
Definition: ecvBBox.h:25
A 3D cloud interface with associated features (color, normals, octree, etc.)
virtual ccOctree::Shared getOctree() const
Returns the associated octree (if any)
ccBBox getOwnBB(bool withGLFeatures=false) override
Returns the entity's own bounding-box.
void onValueChange(int)
Called each time the spinbox value changes.
double m_octreeBoxWidth
Corresponding octree base size.
void setOctree(cloudViewer::DgmOctree *octree)
Inits the dialog with an octree.
void setCloud(ccGenericPointCloud *cloud)
ccOctreeSpinBox(QWidget *parent=0)
Default constructor.
const Vector3Tpl< T > & maxCorner() const
Returns max corner (const)
Definition: BoundingBox.h:156
T getMaxBoxDim() const
Returns maximal box dimension.
Definition: BoundingBox.h:185
const Vector3Tpl< T > & minCorner() const
Returns min corner (const)
Definition: BoundingBox.h:154
static void MakeMinAndMaxCubical(CCVector3 &dimMin, CCVector3 &dimMax, double enlargeFactor=0.01)
Transforms a 3D box into a 3D cube.
Definition: CVMiscTools.cpp:88
The octree structure used throughout the library.
Definition: DgmOctree.h:39
static const int MAX_OCTREE_LEVEL
Max octree subdivision level.
Definition: DgmOctree.h:67
const PointCoordinateType & getCellSize(unsigned char level) const
Returns the octree cells length for a given level of subdivision.
Definition: DgmOctree.h:494
cloudViewer::DgmOctree * octree