49 const size_t& child_index)
53 child_index_(child_index) {}
84 const Json::Value& value);
109 OctreeInternalNode() : children_(8) {}
110 static std::shared_ptr<OctreeNodeInfo> GetInsertionNodeInfo(
111 const std::shared_ptr<OctreeNodeInfo>& node_info,
112 const Eigen::Vector3d&
point);
118 static std::function<std::shared_ptr<OctreeInternalNode>()>
124 static std::function<void(std::shared_ptr<OctreeInternalNode>)>
127 bool ConvertToJsonValue(Json::Value& value)
const override;
128 bool ConvertFromJsonValue(
const Json::Value& value)
override;
135 std::vector<std::shared_ptr<OctreeNode>> children_;
142 class CV_DB_LIB_API OctreeInternalPointNode :
public OctreeInternalNode {
146 OctreeInternalPointNode() : OctreeInternalNode() {}
152 static std::function<std::shared_ptr<OctreeInternalNode>()>
159 static std::function<void(std::shared_ptr<OctreeInternalNode>)>
160 GetUpdateFunction(
size_t idx);
162 bool ConvertToJsonValue(Json::Value& value)
const override;
163 bool ConvertFromJsonValue(
const Json::Value& value)
override;
167 std::vector<size_t> indices_;
177 virtual std::shared_ptr<OctreeLeafNode>
Clone()
const = 0;
188 std::shared_ptr<OctreeLeafNode>
Clone()
const override;
202 static std::function<void(std::shared_ptr<OctreeLeafNode>)>
209 Eigen::Vector3d color_ = Eigen::Vector3d(0, 0, 0);
221 std::shared_ptr<OctreeLeafNode>
Clone()
const override;
236 static std::function<void(std::shared_ptr<OctreeLeafNode>)>
258 Octree(
const size_t& max_depth,
const char*
name =
"Octree2")
266 const Eigen::Vector3d& origin,
268 const char*
name =
"Octree2")
272 max_depth_(max_depth) {}
288 inline virtual bool IsEmpty()
const override {
289 return root_node_ ==
nullptr;
298 bool relative =
true)
override;
300 const Eigen::Vector3d& center)
override;
302 const Eigen::Vector3d& center)
override;
314 double size_expand = 0.01);
317 std::shared_ptr<OctreeNode> root_node_ =
nullptr;
345 const Eigen::Vector3d&
point,
346 const std::function<std::shared_ptr<OctreeLeafNode>()>& fl_init,
347 const std::function<
void(std::shared_ptr<OctreeLeafNode>)>&
349 const std::function<std::shared_ptr<OctreeInternalNode>()>&
351 const std::function<
void(std::shared_ptr<OctreeInternalNode>)>&
352 fi_update =
nullptr);
362 const std::function<
bool(
const std::shared_ptr<OctreeNode>&,
363 const std::shared_ptr<OctreeNodeInfo>&)>&
374 const std::function<
bool(
const std::shared_ptr<OctreeNode>&,
375 const std::shared_ptr<OctreeNodeInfo>&)>&
378 std::pair<std::shared_ptr<OctreeLeafNode>, std::shared_ptr<OctreeNodeInfo>>
393 const Eigen::Vector3d& origin,
406 static void TraverseRecurse(
407 const std::shared_ptr<OctreeNode>& node,
408 const std::shared_ptr<OctreeNodeInfo>& node_info,
409 const std::function<
bool(
const std::shared_ptr<OctreeNode>&,
410 const std::shared_ptr<OctreeNodeInfo>&)>&
413 void InsertPointRecurse(
414 const std::shared_ptr<OctreeNode>& node,
415 const std::shared_ptr<OctreeNodeInfo>& node_info,
416 const Eigen::Vector3d&
point,
417 const std::function<std::shared_ptr<OctreeLeafNode>()>& f_l_init,
418 const std::function<
void(std::shared_ptr<OctreeLeafNode>)>&
420 const std::function<std::shared_ptr<OctreeInternalNode>()>&
422 const std::function<
void(std::shared_ptr<OctreeInternalNode>)>&
int64_t CV_CLASS_ENUM
Type of object type flags (64 bits)
Hierarchical CLOUDVIEWER Object.
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
OctreeColorLeafNode class is an OctreeLeafNode containing color.
static std::function< void(std::shared_ptr< OctreeLeafNode >)> GetUpdateFunction(const Eigen::Vector3d &color)
Get lambda function for updating OctreeLeafNode.
std::shared_ptr< OctreeLeafNode > Clone() const override
Clone this OctreeLeafNode.
bool operator==(const OctreeLeafNode &other) const override
bool ConvertFromJsonValue(const Json::Value &value) override
bool ConvertToJsonValue(Json::Value &value) const override
static std::function< std::shared_ptr< OctreeLeafNode >)> GetInitFunction()
Get lambda function for initializing OctreeLeafNode.
OctreeLeafNode base class.
virtual std::shared_ptr< OctreeLeafNode > Clone() const =0
Clone this OctreeLeafNode.
virtual bool operator==(const OctreeLeafNode &other) const =0
OctreeNode's information.
OctreeNodeInfo(const Eigen::Vector3d &origin, const double &size, const size_t &depth, const size_t &child_index)
Parameterized Constructor.
OctreeNodeInfo()
Default Constructor.
double size_
Size of the node.
Eigen::Vector3d origin_
Origin coordinate of the node.
size_t depth_
Depth of the node to the root. The root is of depth 0.
The base class for octree node.
OctreeNode()
Default Constructor.
static std::shared_ptr< OctreeNode > ConstructFromJsonValue(const Json::Value &value)
Factory function to construct an OctreeNode by parsing the json value.
OctreePointColorLeafNode class is an OctreeColorLeafNode containing a list of indices corresponding t...
std::vector< size_t > indices_
Associated point indices with this node.
bool ConvertToJsonValue(Json::Value &value) const override
std::shared_ptr< OctreeLeafNode > Clone() const override
Clone this OctreeLeafNode.
bool ConvertFromJsonValue(const Json::Value &value) override
static std::function< void(std::shared_ptr< OctreeLeafNode >)> GetUpdateFunction(size_t index, const Eigen::Vector3d &color)
Get lambda function for updating OctreeLeafNode.
bool operator==(const OctreeLeafNode &other) const override
static std::function< std::shared_ptr< OctreeLeafNode >)> GetInitFunction()
Get lambda function for initializing OctreeLeafNode.
void CreateFromVoxelGrid(const geometry::VoxelGrid &voxel_grid)
Convert from voxel grid.
virtual ccBBox GetAxisAlignedBoundingBox() const override
Returns an axis-aligned bounding box of the geometry.
std::pair< std::shared_ptr< OctreeLeafNode >, std::shared_ptr< OctreeNodeInfo > > LocateLeafNode(const Eigen::Vector3d &point) const
Returns leaf OctreeNode and OctreeNodeInfo where the querypoint should reside.
Octree(const char *name="Octree2")
Default Constructor.
virtual Octree & Scale(const double s, const Eigen::Vector3d ¢er) override
Apply scaling to the geometry coordinates. Given a scaling factor , and center , a given point is tr...
virtual Eigen::Vector3d GetCenter() const override
Returns the center of the geometry coordinates.
virtual Octree & Translate(const Eigen::Vector3d &translation, bool relative=true) override
Apply translation to the geometry coordinates.
bool ConvertToJsonValue(Json::Value &value) const override
virtual CV_CLASS_ENUM getClassID() const override
Returns unique class ID.
void ConvertFromPointCloud(const ccPointCloud &point_cloud, double size_expand=0.01)
Convert octree from point cloud.
bool operator==(const Octree &other) const
Returns true if the Octree is completely the same, used for testing.
virtual bool isSerializable() const override
Returns whether object is serializable of not.
virtual ecvOrientedBBox GetOrientedBoundingBox() const override
virtual bool IsEmpty() const override
void InsertPoint(const Eigen::Vector3d &point, const std::function< std::shared_ptr< OctreeLeafNode >()> &fl_init, const std::function< void(std::shared_ptr< OctreeLeafNode >)> &fl_update, const std::function< std::shared_ptr< OctreeInternalNode >()> &fi_init=nullptr, const std::function< void(std::shared_ptr< OctreeInternalNode >)> &fi_update=nullptr)
Insert a point to the octree.
void Traverse(const std::function< bool(const std::shared_ptr< OctreeNode > &, const std::shared_ptr< OctreeNodeInfo > &)> &f) const
Const version of Traverse. DFS traversal of Octree from the root, with callback function called for e...
std::shared_ptr< geometry::VoxelGrid > ToVoxelGrid() const
Convert to VoxelGrid.
virtual Octree & Rotate(const Eigen::Matrix3d &R, const Eigen::Vector3d ¢er) override
Apply rotation to the geometry coordinates and normals. Given a rotation matrix , and center ,...
Octree(const size_t &max_depth, const char *name="Octree2")
Parameterized Constructor.
void Traverse(const std::function< bool(const std::shared_ptr< OctreeNode > &, const std::shared_ptr< OctreeNodeInfo > &)> &f)
DFS traversal of Octree from the root, with callback function called for each node.
Octree(const Octree &src_octree, const char *name="Octree2")
virtual ccBBox getOwnBB(bool withGLFeatures=false) override
Returns the entity's own bounding-box.
Octree(const size_t &max_depth, const Eigen::Vector3d &origin, const double &size, const char *name="Octree2")
Parameterized Constructor.
static bool IsPointInBound(const Eigen::Vector3d &point, const Eigen::Vector3d &origin, const double &size)
Return true if point within bound, that is, origin <= point < origin + size.
virtual Eigen::Vector3d GetMinBound() const override
Returns min bounds for geometry coordinates.
virtual Eigen::Vector3d GetMaxBound() const override
Returns max bounds for geometry coordinates.
virtual Octree & Transform(const Eigen::Matrix4d &transformation) override
Apply transformation (4x4 matrix) to the geometry coordinates.
bool ConvertFromJsonValue(const Json::Value &value) override
VoxelGrid is a collection of voxels which are aligned in grid.
Generic file read and write utility for python interface.