49 const size_t& child_index)
53 child_index_(child_index) {}
83 static std::shared_ptr<OctreeNode> ConstructFromJsonValue(
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;
194 static std::function<std::shared_ptr<OctreeLeafNode>()> GetInitFunction();
202 static std::function<void(std::shared_ptr<OctreeLeafNode>)>
203 GetUpdateFunction(
const Eigen::Vector3d&
color);
205 bool ConvertToJsonValue(
Json::Value& value)
const override;
206 bool ConvertFromJsonValue(
const Json::Value& value)
override;
209 Eigen::Vector3d color_ = Eigen::Vector3d(0, 0, 0);
221 std::shared_ptr<OctreeLeafNode> Clone()
const override;
227 static std::function<std::shared_ptr<OctreeLeafNode>()> GetInitFunction();
236 static std::function<void(std::shared_ptr<OctreeLeafNode>)>
237 GetUpdateFunction(
size_t index,
const Eigen::Vector3d&
color);
239 bool ConvertToJsonValue(
Json::Value& value)
const override;
240 bool ConvertFromJsonValue(
const Json::Value& value)
override;
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) {}
284 virtual ccBBox getOwnBB(
bool withGLFeatures =
false)
override;
288 inline virtual bool IsEmpty()
const override {
289 return root_node_ ==
nullptr;
291 virtual Eigen::Vector3d GetMinBound()
const override;
292 virtual Eigen::Vector3d GetMaxBound()
const override;
293 virtual Eigen::Vector3d GetCenter()
const override;
294 virtual ccBBox GetAxisAlignedBoundingBox()
const override;
296 virtual Octree&
Transform(
const Eigen::Matrix4d& transformation)
override;
297 virtual Octree& Translate(
const Eigen::Vector3d& translation,
298 bool relative =
true)
override;
299 virtual Octree& Scale(
const double s,
300 const Eigen::Vector3d& center)
override;
301 virtual Octree& Rotate(
const Eigen::Matrix3d& R,
302 const Eigen::Vector3d& center)
override;
303 bool ConvertToJsonValue(
Json::Value& value)
const override;
304 bool ConvertFromJsonValue(
const Json::Value& value)
override;
313 void ConvertFromPointCloud(
const ccPointCloud& point_cloud,
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>>
384 LocateLeafNode(
const Eigen::Vector3d& point)
const;
392 static bool IsPointInBound(
const Eigen::Vector3d& point,
393 const Eigen::Vector3d&
origin,
400 std::shared_ptr<geometry::VoxelGrid> ToVoxelGrid()
const;
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>)>&