How to program the ccbox to the corresponding position

Feel free to ask any question here
Post Reply
lmh
Posts: 2
Joined: Fri Aug 12, 2022 3:28 am

How to program the ccbox to the corresponding position

Post by lmh »

hi all,
I'm learning to write a plugin to compare two point cloud files, I got some difference point sets between the two point clouds, which I recorded with bounding boxes in AABB and OBB format. In the end, I would like to convert these bounding boxes into corresponding "ccbox"es that can be embedded and displayed at the corresponding position in the point cloud when the user selects them from the DB tree.
But the end result shows that their coordinates don't seem to match, what can I do to get the ccbox to display in the correct position in the point cloud?

Thanks a lot!

ref code is:
.......
int aabb_list_size =result_json["bounding_boxes"]["boxes_num"] ;
for (auto i = 0; i < aabb_list_size; ++i)
{
float max_point_x = result_json["bounding_boxes"]["aabb"]["max_point"][0] ;
float max_point_y = result_json["bounding_boxes"]["aabb"]["max_point"][1] ;
float max_point_z = result_json["bounding_boxes"]["aabb"]["max_point"][2] ;
float min_point_x = result_json["bounding_boxes"]["aabb"]["min_point"][0] ;
float min_point_y = result_json["bounding_boxes"]["aabb"]["min_point"][1] ;
float min_point_z = result_json["bounding_boxes"]["aabb"]["min_point"][2] ;

QString boxname = QString::asprintf("aabb_%d", i);
CCVector3f min_pt (min_point_x, min_point_y, min_point_z);
CCVector3f max_pt(max_point_x, max_point_y, max_point_z);
CCVector3f pos_pt = ( max_pt + min_pt ) / 2;
ccBox* box = new ccBox( max_pt - min_pt, nullptr, boxname);

//--------how to move this ccbox---------? ?

out_cloud_cc->addChild(box);
}
emit newEntity(out_cloud_cc);

ref effect is:
Attachments
effect.png
effect.png (1.14 MiB) Viewed 767 times
daniel
Site Admin
Posts: 7717
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: How to program the ccbox to the corresponding position

Post by daniel »

I guess you have to pass a transformation matrix to the ccBox contructor so as to move the box at the right position.

This is the second parameter of the constructor. Instead of nullptr, try:
ccGLMatrix shiftMat;
shiftMat.setTranslation(pos_pt);
ccBox* box = new ccBox( max_pt - min_pt, &shiftMat, boxname);
Daniel, CloudCompare admin
Post Reply