ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
geometry.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 // CV_CORE_LIB
9 #include <BoundingBox.h>
10 
11 // CV_DB_LIB
12 #include <Image.h>
13 #include <LineSet.h>
14 #include <Octree.h>
15 #include <RGBDImage.h>
16 #include <VoxelGrid.h>
17 #include <ecv2DLabel.h>
18 #include <ecv2DViewportLabel.h>
19 #include <ecv2DViewportObject.h>
20 #include <ecvBox.h>
21 #include <ecvCameraSensor.h>
22 #include <ecvCone.h>
23 #include <ecvCoordinateSystem.h>
24 #include <ecvCylinder.h>
25 #include <ecvDish.h>
26 #include <ecvExtru.h>
27 #include <ecvFacet.h>
28 #include <ecvGBLSensor.h>
29 #include <ecvHObject.h>
30 #include <ecvHObjectCaster.h>
31 #include <ecvImage.h>
32 #include <ecvKdTree.h>
33 #include <ecvMesh.h>
34 #include <ecvOctreeProxy.h>
35 #include <ecvPlane.h>
36 #include <ecvPointCloud.h>
37 #include <ecvPolyline.h>
38 #include <ecvQuadric.h>
39 #include <ecvSensor.h>
40 #include <ecvShiftedObject.h>
41 #include <ecvSphere.h>
42 #include <ecvSubMesh.h>
43 #include <ecvTorus.h>
44 
46 #include "pybind/docstring.h"
49 
50 #ifdef _MSC_VER
51 #pragma warning(disable : 4715)
52 #endif
53 
54 namespace cloudViewer {
55 namespace geometry {
56 
57 void pybind_geometry_classes(py::module& m) {
58  // cloudViewer.geometry functions
59  m.def("get_rotation_matrix_from_xyz", &ccHObject::GetRotationMatrixFromXYZ,
60  "rotation"_a);
61  m.def("get_rotation_matrix_from_yzx", &ccHObject::GetRotationMatrixFromYZX,
62  "rotation"_a);
63  m.def("get_rotation_matrix_from_zxy", &ccHObject::GetRotationMatrixFromZXY,
64  "rotation"_a);
65  m.def("get_rotation_matrix_from_xzy", &ccHObject::GetRotationMatrixFromXZY,
66  "rotation"_a);
67  m.def("get_rotation_matrix_from_zyx", &ccHObject::GetRotationMatrixFromZYX,
68  "rotation"_a);
69  m.def("get_rotation_matrix_from_yxz", &ccHObject::GetRotationMatrixFromYXZ,
70  "rotation"_a);
71  m.def("get_rotation_matrix_from_axis_angle",
73  m.def("get_rotation_matrix_from_euler_angle",
75  m.def("get_rotation_matrix_from_quaternion",
77 
78  m.def(
79  "ToPointCloud",
80  [](ccHObject& entity) {
81  if (ccHObjectCaster::ToPointCloud(&entity)) {
82  return std::ref(*ccHObjectCaster::ToPointCloud(&entity));
83  } else {
85  "[ccHObjectCaster] converting failed!");
86  return std::ref(*std::make_shared<ccPointCloud>());
87  }
88  },
89  "Converts current object to 'equivalent' ccPointCloud", "entity"_a);
90  m.def(
91  "ToPolyline",
92  [](ccHObject& entity) {
93  if (ccHObjectCaster::ToPolyline(&entity)) {
94  return std::ref(*ccHObjectCaster::ToPolyline(&entity));
95  } else {
97  "[ccHObjectCaster] converting failed!");
98  return std::ref(*std::make_shared<ccPolyline>(nullptr));
99  }
100  },
101  "Converts current object to ccPolyline (if possible)", "entity"_a);
102  m.def(
103  "ToFacet",
104  [](ccHObject& entity) {
105  if (ccHObjectCaster::ToFacet(&entity)) {
106  return std::ref(*ccHObjectCaster::ToFacet(&entity));
107  } else {
109  "[ccHObjectCaster] converting failed!");
110  return std::ref(*std::make_shared<ccFacet>());
111  }
112  },
113  "Converts current object to ccFacet (if possible)", "entity"_a);
114  m.def(
115  "ToMesh",
116  [](ccHObject& entity) {
117  if (ccHObjectCaster::ToMesh(&entity)) {
118  return std::ref(*ccHObjectCaster::ToMesh(&entity));
119  } else {
121  "[ccHObjectCaster] converting failed!");
122  return std::ref(*std::make_shared<ccMesh>());
123  }
124  },
125  "Converts current object to ccMesh (if possible)", "entity"_a);
126  m.def(
127  "ToSubMesh",
128  [](ccHObject& entity) {
129  if (ccHObjectCaster::ToSubMesh(&entity)) {
130  return std::ref(*ccHObjectCaster::ToSubMesh(&entity));
131  } else {
133  "[ccHObjectCaster] converting failed!");
134  return std::ref(*std::make_shared<ccSubMesh>(nullptr));
135  }
136  },
137  "Converts current object to ccSubMesh (if possible)", "entity"_a);
138  m.def(
139  "ToQuadric",
140  [](ccHObject& entity) {
141  if (ccHObjectCaster::ToQuadric(&entity)) {
142  return std::ref(*ccHObjectCaster::ToQuadric(&entity));
143  } else {
145  "[ccHObjectCaster] converting failed!");
146  return std::ref(*std::make_shared<ccQuadric>());
147  }
148  },
149  "Converts current object to ccQuadric (if possible)", "entity"_a);
150  m.def(
151  "ToBox",
152  [](ccHObject& entity) {
153  if (ccHObjectCaster::ToBox(&entity)) {
154  return std::ref(*ccHObjectCaster::ToBox(&entity));
155  } else {
157  "[ccHObjectCaster] converting failed!");
158  return std::ref(*std::make_shared<ccBox>());
159  }
160  },
161  "Converts current object to ccBox (if possible)", "entity"_a);
162  m.def(
163  "ToSphere",
164  [](ccHObject& entity) {
165  if (ccHObjectCaster::ToSphere(&entity)) {
166  return std::ref(*ccHObjectCaster::ToSphere(&entity));
167  } else {
169  "[ccHObjectCaster] converting failed!");
170  return std::ref(*std::make_shared<ccSphere>());
171  }
172  },
173  "Converts current object to ccSphere (if possible)", "entity"_a);
174  m.def(
175  "ToCylinder",
176  [](ccHObject& entity) {
177  if (ccHObjectCaster::ToCylinder(&entity)) {
178  return std::ref(*ccHObjectCaster::ToCylinder(&entity));
179  } else {
181  "[ccHObjectCaster] converting failed!");
182  return std::ref(*std::make_shared<ccCylinder>());
183  }
184  },
185  "Converts current object to ccCylinder (if possible)", "entity"_a);
186  m.def(
187  "ToCoordinateSystem",
188  [](ccHObject& entity) {
190  return std::ref(
192  } else {
194  "[ccHObjectCaster] converting failed!");
195  return std::ref(*std::make_shared<ccCoordinateSystem>());
196  }
197  },
198  "Converts current object to ccCoordinateSystem (if possible)",
199  "entity"_a);
200  m.def(
201  "ToCone",
202  [](ccHObject& entity) {
203  if (ccHObjectCaster::ToCone(&entity)) {
204  return std::ref(*ccHObjectCaster::ToCone(&entity));
205  } else {
207  "[ccHObjectCaster] converting failed!");
208  return std::ref(*std::make_shared<ccCone>());
209  }
210  },
211  "Converts current object to ccCone (if possible)", "entity"_a);
212  m.def(
213  "ToPlane",
214  [](ccHObject& entity) {
215  if (ccHObjectCaster::ToPlane(&entity)) {
216  return std::ref(*ccHObjectCaster::ToPlane(&entity));
217  } else {
219  "[ccHObjectCaster] converting failed!");
220  return std::ref(*std::make_shared<ccPlane>());
221  }
222  },
223  "Converts current object to ccPlane (if possible)", "entity"_a);
224  m.def(
225  "ToDish",
226  [](ccHObject& entity) {
227  if (ccHObjectCaster::ToDish(&entity)) {
228  return std::ref(*ccHObjectCaster::ToDish(&entity));
229  } else {
231  "[ccHObjectCaster] converting failed!");
232  return std::ref(*std::make_shared<ccDish>());
233  }
234  },
235  "Converts current object to ccDish (if possible)", "entity"_a);
236  m.def(
237  "ToExtru",
238  [](ccHObject& entity) {
239  if (ccHObjectCaster::ToExtru(&entity)) {
240  return std::ref(*ccHObjectCaster::ToExtru(&entity));
241  } else {
243  "[ccHObjectCaster] converting failed!");
244  return std::ref(*std::make_shared<ccExtru>());
245  }
246  },
247  "Converts current object to ccExtru (if possible)", "entity"_a);
248  m.def(
249  "ToTorus",
250  [](ccHObject& entity) {
251  if (ccHObjectCaster::ToTorus(&entity)) {
252  return std::ref(*ccHObjectCaster::ToTorus(&entity));
253  } else {
255  "[ccHObjectCaster] converting failed!");
256  return std::ref(*std::make_shared<ccTorus>());
257  }
258  },
259  "Converts current object to ccTorus (if possible)", "entity"_a);
260 
261  m.def(
262  "ToOctreeProxy",
263  [](ccHObject& entity) {
264  if (ccHObjectCaster::ToOctreeProxy(&entity)) {
265  return std::ref(*ccHObjectCaster::ToOctreeProxy(&entity));
266  } else {
268  "[ccHObjectCaster] converting failed!");
269  return std::ref(*std::make_shared<ccOctreeProxy>());
270  }
271  },
272  "Converts current object to ccOctreeProxy (if possible)",
273  "entity"_a);
274  m.def(
275  "ToKdTree",
276  [](ccHObject& entity) {
277  if (ccHObjectCaster::ToKdTree(&entity)) {
278  return std::ref(*ccHObjectCaster::ToKdTree(&entity));
279  } else {
281  "[ccHObjectCaster] converting failed!");
282  auto pcd = std::make_shared<ccPointCloud>();
283  return std::ref(*std::make_shared<ccKdTree>(pcd.get()));
284  }
285  },
286  "Converts current object to ccKdTree (if possible)", "entity"_a);
287  m.def(
288  "ToSensor",
289  [](ccHObject& entity) {
290  if (ccHObjectCaster::ToSensor(&entity)) {
291  return std::ref(*ccHObjectCaster::ToSensor(&entity));
292  } else {
294  "[ccHObjectCaster] converting failed!");
295  return std::ref(*std::make_shared<ccSensor>("Invalid"));
296  }
297  },
298  "Converts current object to ccSensor (if possible)", "entity"_a);
299  m.def(
300  "ToGBLSensor",
301  [](ccHObject& entity) {
302  if (ccHObjectCaster::ToGBLSensor(&entity)) {
303  return std::ref(*ccHObjectCaster::ToGBLSensor(&entity));
304  } else {
306  "[ccHObjectCaster] converting failed!");
307  return std::ref(*std::make_shared<ccGBLSensor>());
308  }
309  },
310  "Converts current object to ccGBLSensor (if possible)", "entity"_a);
311  m.def(
312  "ToCameraSensor",
313  [](ccHObject& entity) {
314  if (ccHObjectCaster::ToCameraSensor(&entity)) {
315  return std::ref(*ccHObjectCaster::ToCameraSensor(&entity));
316  } else {
318  "[ccHObjectCaster] converting failed!");
319  return std::ref(*std::make_shared<ccCameraSensor>());
320  }
321  },
322  "Converts current object to ccCameraSensor (if possible)",
323  "entity"_a);
324  m.def(
325  "ToImage",
326  [](ccHObject& entity) {
327  if (ccHObjectCaster::ToImage(&entity)) {
328  return std::ref(*ccHObjectCaster::ToImage(&entity));
329  } else {
331  "[ccHObjectCaster] converting failed!");
332  return std::ref(*std::make_shared<ccImage>());
333  }
334  },
335  "Converts current object to ccImage (if possible)", "entity"_a);
336 
337  m.def(
338  "To2DLabel",
339  [](ccHObject& entity) {
340  if (ccHObjectCaster::To2DLabel(&entity)) {
341  return std::ref(*ccHObjectCaster::To2DLabel(&entity));
342  } else {
344  "[ccHObjectCaster] converting failed!");
345  return std::ref(*std::make_shared<cc2DLabel>());
346  }
347  },
348  "Converts current object to cc2DLabel (if possible)", "entity"_a);
349  m.def(
350  "To2DViewportLabel",
351  [](ccHObject& entity) {
352  if (ccHObjectCaster::To2DViewportLabel(&entity)) {
353  return std::ref(
355  } else {
357  "[ccHObjectCaster] converting failed!");
358  return std::ref(*std::make_shared<cc2DViewportLabel>());
359  }
360  },
361  "Converts current object to cc2DViewportLabel (if possible)",
362  "entity"_a);
363  m.def(
364  "To2DViewportObject",
365  [](ccHObject& entity) {
367  return std::ref(
369  } else {
371  "[ccHObjectCaster] converting failed!");
372  return std::ref(*std::make_shared<cc2DViewportObject>());
373  }
374  },
375  "Converts current object to cc2DViewportObject (if possible)",
376  "entity"_a);
377  m.def(
378  "ToTransBuffer",
379  [](ccHObject& entity) {
380  if (ccHObjectCaster::ToTransBuffer(&entity)) {
381  return std::ref(*ccHObjectCaster::ToTransBuffer(&entity));
382  } else {
384  "[ccHObjectCaster] converting failed!");
385  return std::ref(
386  *std::make_shared<ccIndexedTransformationBuffer>());
387  }
388  },
389  "Converts current object to ccIndexedTransformationBuffer (if "
390  "possible)",
391  "entity"_a);
392  m.def(
393  "ToImage2",
394  [](ccHObject& entity) {
395  if (ccHObjectCaster::ToImage2(&entity)) {
396  return std::ref(*ccHObjectCaster::ToImage2(&entity));
397  } else {
399  "[ccHObjectCaster] converting failed!");
400  return std::ref(*std::make_shared<Image>());
401  }
402  },
403  "Converts current object to Image (if possible)", "entity"_a);
404  m.def(
405  "ToRGBDImage",
406  [](ccHObject& entity) {
407  if (ccHObjectCaster::ToRGBDImage(&entity)) {
408  return std::ref(*ccHObjectCaster::ToRGBDImage(&entity));
409  } else {
411  "[ccHObjectCaster] converting failed!");
412  return std::ref(*std::make_shared<RGBDImage>());
413  }
414  },
415  "Converts current object to RGBDImage (if possible)", "entity"_a);
416  m.def(
417  "ToVoxelGrid",
418  [](ccHObject& entity) {
419  if (ccHObjectCaster::ToVoxelGrid(&entity)) {
420  return std::ref(*ccHObjectCaster::ToVoxelGrid(&entity));
421  } else {
423  "[ccHObjectCaster] converting failed!");
424  return std::ref(*std::make_shared<VoxelGrid>());
425  }
426  },
427  "Converts current object to VoxelGrid (if possible)", "entity"_a);
428  m.def(
429  "ToLineSet",
430  [](ccHObject& entity) {
431  if (ccHObjectCaster::ToLineSet(&entity)) {
432  return std::ref(*ccHObjectCaster::ToLineSet(&entity));
433  } else {
435  "[ccHObjectCaster] converting failed!");
436  return std::ref(*std::make_shared<LineSet>());
437  }
438  },
439  "Converts current object to LineSet (if possible)", "entity"_a);
440  m.def(
441  "ToOctree2",
442  [](ccHObject& entity) {
443  if (ccHObjectCaster::ToOctree2(&entity)) {
444  return std::ref(*ccHObjectCaster::ToOctree2(&entity));
445  } else {
447  "[ccHObjectCaster] converting failed!");
448  return std::ref(*std::make_shared<Octree>());
449  }
450  },
451  "Converts current object to Octree (if possible)", "entity"_a);
452  m.def(
453  "ToBBox",
454  [](ccHObject& entity) {
455  if (ccHObjectCaster::ToBBox(&entity)) {
456  return std::ref(*ccHObjectCaster::ToBBox(&entity));
457  } else {
459  "[ccHObjectCaster] converting failed!");
460  return std::ref(*std::make_shared<ccBBox>());
461  }
462  },
463  "Converts current object to ccBBox (if possible)", "entity"_a);
464  m.def(
465  "ToOrientedBBox",
466  [](ccHObject& entity) {
467  if (ccHObjectCaster::ToOrientedBBox(&entity)) {
468  return std::ref(*ccHObjectCaster::ToOrientedBBox(&entity));
469  } else {
471  "[ccHObjectCaster] converting failed!");
472  return std::ref(*std::make_shared<ecvOrientedBBox>());
473  }
474  },
475  "Converts current object to ecvOrientedBBox (if possible)",
476  "entity"_a);
477 
478  py::class_<ccObject, PyObjectBase<ccObject>, std::shared_ptr<ccObject>>
479  geometry(m, "ccObject", "The base geometry class.");
480  geometry.def("get_unique_id", &ccObject::getUniqueID,
481  "Returns object unique ID.")
482  .def("set_unique_id", &ccObject::setUniqueID, "Changes unique ID.",
483  "ID"_a)
484  .def(
485  "get_name",
486  [](const ccObject& obj) {
487  return obj.getName().toStdString();
488  },
489  "Returns object name.")
490  .def(
491  "set_name",
492  [](ccObject& obj, const std::string& name) {
493  obj.setName(name.c_str());
494  },
495  "Sets object name.")
496  .def("is_leaf", &ccObject::isLeaf,
497  "Returns whether the geometry is leaf.")
498  .def("is_custom", &ccObject::isCustom,
499  "Returns whether the geometry is custom.")
500  .def("is_hierarchy", &ccObject::isHierarchy,
501  "Returns whether the geometry is hierarchy.")
502  .def("is_kind_of", &ccObject::isKindOf,
503  "Returns whether the geometry is kind of the type pointed.",
504  "type"_a)
505  .def("is_a", &ccObject::isA,
506  "Returns whether the geometry is a type pointed.", "type"_a);
507  docstring::ClassMethodDocInject(m, "ccObject", "get_unique_id");
508  docstring::ClassMethodDocInject(m, "ccObject", "set_unique_id");
509  docstring::ClassMethodDocInject(m, "ccObject", "get_name");
510  docstring::ClassMethodDocInject(m, "ccObject", "set_name");
511  docstring::ClassMethodDocInject(m, "ccObject", "is_leaf");
512  docstring::ClassMethodDocInject(m, "ccObject", "is_custom");
513  docstring::ClassMethodDocInject(m, "ccObject", "is_hierarchy");
514  docstring::ClassMethodDocInject(m, "ccObject", "is_kind_of");
515  docstring::ClassMethodDocInject(m, "ccObject", "is_a");
516 
517  // cloudViewer.geometry.Geometry.Type
518  // must use py::enum_ instead of py::native_enum
519  py::enum_<CV_TYPES::GeometryType> geometry_type(geometry, "Type",
520  py::arithmetic());
521  // Trick to write docs without listing the members in the enum class again.
522  geometry_type.attr("__doc__") = docstring::static_property(
523  py::cpp_function([](py::handle arg) -> std::string {
524  return "Enum class for Geometry types.";
525  }),
526  py::none(), py::none(), "");
527 
528  geometry_type.value("CUSTOM_H_OBJECT", CV_TYPES::CUSTOM_H_OBJECT)
529  .value("MESH", CV_TYPES::MESH)
530  .value("LINESET", CV_TYPES::LINESET)
531  .value("FACET", CV_TYPES::FACET)
532  .value("SUB_MESH", CV_TYPES::SUB_MESH)
533  .value("MESH_GROUP", CV_TYPES::MESH_GROUP)
534  .value("POINT_CLOUD", CV_TYPES::POINT_CLOUD)
535  .value("VOXEL_GRID", CV_TYPES::VOXEL_GRID)
536  .value("POLY_LINE", CV_TYPES::POLY_LINE)
537  .value("IMAGE", CV_TYPES::IMAGE)
538  .value("IMAGE2", CV_TYPES::IMAGE2)
539  .value("RGBD_IMAGE", CV_TYPES::RGBD_IMAGE)
540  .value("TETRA_MESH", CV_TYPES::TETRA_MESH)
541  .value("POINT_KDTREE", CV_TYPES::POINT_KDTREE)
542  .value("POINT_OCTREE", CV_TYPES::POINT_OCTREE)
543  .value("POINT_OCTREE2", CV_TYPES::POINT_OCTREE2)
544  .value("BBOX", CV_TYPES::BBOX)
545  .value("ORIENTED_BBOX", CV_TYPES::ORIENTED_BBOX)
546  .value("PRIMITIVE", CV_TYPES::PRIMITIVE)
547  .value("PLANE", CV_TYPES::PLANE)
548  .value("SPHERE", CV_TYPES::SPHERE)
549  .value("TORUS", CV_TYPES::TORUS)
550  .value("CONE", CV_TYPES::CONE)
551  .value("OLD_CYLINDER_ID", CV_TYPES::OLD_CYLINDER_ID)
552  .value("CYLINDER", CV_TYPES::CYLINDER)
553  .value("BOX", CV_TYPES::BOX)
554  .value("DISH", CV_TYPES::DISH)
555  .value("EXTRU", CV_TYPES::EXTRU)
556  .value("QUADRIC", CV_TYPES::QUADRIC)
557  .value("LABEL_2D", CV_TYPES::LABEL_2D)
558  .value("SENSOR", CV_TYPES::SENSOR)
559  .value("GBL_SENSOR", CV_TYPES::GBL_SENSOR)
560  .value("CAMERA_SENSOR", CV_TYPES::CAMERA_SENSOR)
561  .value("MATERIAL_SET", CV_TYPES::MATERIAL_SET)
562  .value("VIEWPORT_2D_LABEL", CV_TYPES::VIEWPORT_2D_LABEL)
563  .value("VIEWPORT_2D_OBJECT", CV_TYPES::VIEWPORT_2D_OBJECT)
564  .export_values();
565 
566  // cloudViewer.geometry.ccDrawableObject
567  py::class_<ccDrawableObject, PyDrawableObjectBase<ccDrawableObject>,
568  std::shared_ptr<ccDrawableObject>>
569  drawableObject(m, "ccDrawableObject",
570  "The Generic interface for (3D) drawable entities.");
571  drawableObject
572  .def("__repr__",
573  [](const ccDrawableObject& painter) {
574  return std::string(
575  "Generic interface for (3D) drawable entities");
576  })
577  .def("is_visible", &ccDrawableObject::isVisible,
578  "Returns whether entity is visible or not.")
579  .def("set_visible", &ccDrawableObject::setVisible,
580  "Sets entity visibility.", "state"_a)
581  .def("toggle_visibility", &ccDrawableObject::toggleVisibility,
582  "Toggles visibility.")
583  .def("is_visiblity_locked", &ccDrawableObject::isVisibilityLocked,
584  "Returns whether visibility is locked or not.")
585  .def("lock_visibility", &ccDrawableObject::lockVisibility,
586  "Locks/unlocks visibility.", "state"_a)
587  .def("is_selected", &ccDrawableObject::isSelected,
588  "Returns whether entity is selected or not.")
589  .def("set_selected", &ccDrawableObject::setSelected,
590  "Selects/Unselects entity.", "state"_a)
591  .def("has_colors", &ccDrawableObject::hasColors,
592  "Returns whether colors are enabled or not.")
593  .def("colors_shown", &ccDrawableObject::colorsShown,
594  "Returns whether colors are shown or not.")
595  .def("show_colors", &ccDrawableObject::showColors,
596  "Sets colors visibility.", "state"_a)
597  .def("toggle_colors", &ccDrawableObject::toggleColors,
598  "Toggles colors display state.")
599  .def("has_normals", &ccDrawableObject::hasNormals,
600  "Returns whether normals are enabled or not.")
601  .def("normals_shown", &ccDrawableObject::normalsShown,
602  "Returns whether normals are shown or not.")
603  .def("show_normals", &ccDrawableObject::showNormals,
604  "Sets normals visibility.", "state"_a)
605  .def("toggle_normals", &ccDrawableObject::toggleNormals,
606  "Toggles normals display state.")
607  .def("has_displayed_scalar_field",
609  "Returns whether an active scalar field is available or not.")
610  .def("has_scalar_fields", &ccDrawableObject::hasScalarFields,
611  "Returns whether one or more scalar fields are instantiated.")
612  .def("show_sf", &ccDrawableObject::showSF,
613  "Sets active scalar field visibility.", "state"_a)
614  .def("toggle_sf", &ccDrawableObject::toggleSF,
615  "Toggles SF display state.")
616  .def("sf_shown", &ccDrawableObject::sfShown,
617  "Returns whether active scalar field is visible.")
618  .def("toggle_materials", &ccDrawableObject::toggleMaterials,
619  "Toggles material display state.")
620  .def("show_3d_name", &ccDrawableObject::showNameIn3D,
621  "Sets whether name should be displayed in 3D.", "state"_a)
622  .def("name_3d_shown", &ccDrawableObject::nameShownIn3D,
623  "Returns whether name is displayed in 3D or not.")
624  .def("toggle_show_name", &ccDrawableObject::toggleShowName,
625  "Toggles name in 3D display state.")
626  .def("get_opacity", &ccDrawableObject::getOpacity, "Get opacity.")
627  .def("set_opacity", &ccDrawableObject::setOpacity,
628  "Set opacity activation state.", "opacity"_a)
629  .def("is_color_overriden", &ccDrawableObject::isColorOverridden,
630  "Returns whether colors are currently overridden by a "
631  "temporary (unique) color.")
632  .def(
633  "get_temp_color",
634  [](ccDrawableObject& painter) {
635  return ecvColor::Rgb::ToEigen(painter.getTempColor());
636  },
637  "Returns current temporary (unique) color.")
638  .def(
639  "set_temp_color",
640  [](ccDrawableObject& painter, const Eigen::Vector3d& color,
641  bool auto_activate) {
643  auto_activate);
644  },
645  "Sets current temporary (unique).", "color"_a,
646  "auto_activate"_a = true)
647  .def("enable_temp_color", &ccDrawableObject::enableTempColor,
648  "Set temporary color activation state.", "state"_a)
649  .def(
650  "set_gl_transformation",
651  [](ccDrawableObject& painter,
652  const Eigen::Matrix4d& transformation) {
653  painter.setGLTransformation(
654  ccGLMatrix::FromEigenMatrix(transformation));
655  },
656  "Associates entity with a GL transformation (rotation + "
657  "translation).",
658  "transformation"_a)
659  .def("enable_gl_transformation",
661  "Enables/disables associated GL transformation.", "state"_a)
662  .def("is_gl_trans_enabled", &ccDrawableObject::isGLTransEnabled,
663  "Returns whether a GL transformation is enabled or not.")
664  .def(
665  "get_gl_transformation",
666  [](const ccDrawableObject& painter) {
668  painter.getGLTransformation());
669  },
670  "Returns associated GL transformation.")
671  .def("reset_gl_transformation",
673  "Resets associated GL transformation.")
674  .def(
675  "rotate_gl",
676  [](ccDrawableObject& painter,
677  const Eigen::Matrix4d& rotation) {
678  painter.rotateGL(ccGLMatrix::FromEigenMatrix(rotation));
679  },
680  "Multiplies (left) current GL transformation by a rotation "
681  "matrix.",
682  "rotation"_a)
683  .def(
684  "translate_gl",
685  [](ccDrawableObject& painter,
686  const Eigen::Vector3d& translation) {
687  painter.translateGL(CCVector3::fromArray(translation));
688  },
689  "Translates current GL transformation by a rotation "
690  "matrix.",
691  "translation"_a);
692  docstring::ClassMethodDocInject(m, "ccDrawableObject", "is_visible");
693  docstring::ClassMethodDocInject(m, "ccDrawableObject", "set_visible");
694  docstring::ClassMethodDocInject(m, "ccDrawableObject", "toggle_visibility");
695  docstring::ClassMethodDocInject(m, "ccDrawableObject",
696  "is_visiblity_locked");
697  docstring::ClassMethodDocInject(m, "ccDrawableObject", "lock_visibility");
698  docstring::ClassMethodDocInject(m, "ccDrawableObject", "is_selected");
699  docstring::ClassMethodDocInject(m, "ccDrawableObject", "set_selected");
700  docstring::ClassMethodDocInject(m, "ccDrawableObject", "has_colors");
701  docstring::ClassMethodDocInject(m, "ccDrawableObject", "colors_shown");
702  docstring::ClassMethodDocInject(m, "ccDrawableObject", "show_colors");
703  docstring::ClassMethodDocInject(m, "ccDrawableObject", "toggle_colors");
704  docstring::ClassMethodDocInject(m, "ccDrawableObject", "has_normals");
705  docstring::ClassMethodDocInject(m, "ccDrawableObject", "normals_shown");
706  docstring::ClassMethodDocInject(m, "ccDrawableObject", "show_normals");
707  docstring::ClassMethodDocInject(m, "ccDrawableObject", "toggle_normals");
708  docstring::ClassMethodDocInject(m, "ccDrawableObject",
709  "has_displayed_scalar_field");
710  docstring::ClassMethodDocInject(m, "ccDrawableObject", "has_scalar_fields");
711  docstring::ClassMethodDocInject(m, "ccDrawableObject", "show_sf");
712  docstring::ClassMethodDocInject(m, "ccDrawableObject", "toggle_sf");
713  docstring::ClassMethodDocInject(m, "ccDrawableObject", "sf_shown");
714  docstring::ClassMethodDocInject(m, "ccDrawableObject", "toggle_materials");
715  docstring::ClassMethodDocInject(m, "ccDrawableObject", "show_3d_name");
716  docstring::ClassMethodDocInject(m, "ccDrawableObject", "name_3d_shown");
717  docstring::ClassMethodDocInject(m, "ccDrawableObject", "toggle_show_name");
718  docstring::ClassMethodDocInject(m, "ccDrawableObject", "get_opacity");
719  docstring::ClassMethodDocInject(m, "ccDrawableObject", "set_opacity");
720  docstring::ClassMethodDocInject(m, "ccDrawableObject",
721  "is_color_overriden");
722  docstring::ClassMethodDocInject(m, "ccDrawableObject", "get_temp_color");
724  m, "ccDrawableObject", "set_temp_color",
725  {{"color", "rgb color"},
726  {"auto_activate", "auto activates temporary color"}});
727  docstring::ClassMethodDocInject(m, "ccDrawableObject", "enable_temp_color");
728  docstring::ClassMethodDocInject(m, "ccDrawableObject",
729  "set_gl_transformation");
730  docstring::ClassMethodDocInject(m, "ccDrawableObject",
731  "get_gl_transformation");
732  docstring::ClassMethodDocInject(m, "ccDrawableObject",
733  "enable_gl_transformation");
734  docstring::ClassMethodDocInject(m, "ccDrawableObject",
735  "is_gl_trans_enabled");
736  docstring::ClassMethodDocInject(m, "ccDrawableObject",
737  "reset_gl_transformation");
738  docstring::ClassMethodDocInject(m, "ccDrawableObject", "rotate_gl");
739  docstring::ClassMethodDocInject(m, "ccDrawableObject", "translate_gl");
740 
741  // cloudViewer.geometry
742  py::class_<ccHObject, PyGeometry<ccHObject>, std::shared_ptr<ccHObject>,
744  geometry3d(m, "ccHObject", py::multiple_inheritance(),
745  "The geometry 3D class.");
746  geometry3d
747  .def("__repr__",
748  [](const ccHObject& geometry) {
749  return std::string(
750  "The ccHObject base class for 3D Geometries.");
751  })
752  .def("get_class_id", &ccHObject::getClassID, "Returns class ID.")
753  .def("is_group", &ccHObject::isGroup,
754  "Returns whether the instance is a group.")
755  .def("get_parent", &ccHObject::getParent, "Returns parent object.")
756  .def("add_child", &ccHObject::addChild, "Adds a child.", "child"_a,
757  "dependencyFlags"_a = 24, "insertIndex"_a = -1)
758  .def("get_child", &ccHObject::getChild, "Returns the ith child.",
759  "childPos"_a)
760  .def("remove_child",
761  py::overload_cast<ccHObject*>(&ccHObject::removeChild),
762  "Removes a specific child.", "child"_a)
763  .def("remove_child",
764  py::overload_cast<int>(&ccHObject::removeChild),
765  "Removes a specific child given its index.", "pos"_a)
766  .def("remove_all_children", &ccHObject::removeAllChildren,
767  "Clear all children in the geometry.")
768  .def("set_pointSize_recursive", &ccHObject::setPointSizeRecursive,
769  "Sets the point size.", "pSize"_a)
770  .def("set_lineWidth_recursive", &ccHObject::setLineWidthRecursive,
771  "Sets the line width.", "width"_a)
772  .def("is_serializable", &ccHObject::isSerializable,
773  "Returns whether the instance is a serializable.")
774  .def("is_empty", &ccHObject::IsEmpty,
775  "Returns ``True`` if the geometry is empty.")
776  .def("get_min_bound", &ccHObject::GetMinBound,
777  "Returns min bounds for geometry coordinates.")
778  .def("get_max_bound", &ccHObject::GetMaxBound,
779  "Returns max bounds for geometry coordinates.")
780  .def("get_min_2Dbound", &ccHObject::GetMin2DBound,
781  "Returns min 2d bounds for geometry coordinates.")
782  .def("get_max_2Dbound", &ccHObject::GetMax2DBound,
783  "Returns max 2d bounds for geometry coordinates.")
784  .def("get_center", &ccHObject::GetCenter,
785  "Returns the center of the geometry coordinates.")
786  .def("get_own_bounding_box", &ccHObject::getOwnBB,
787  "Returns an axis-aligned bounding box of the geometry.",
788  "withGLFeatures"_a = false)
789  .def("get_axis_aligned_bounding_box",
791  "Returns an axis-aligned bounding box of the geometry.")
792  .def("get_oriented_bounding_box",
794  "Returns an oriented bounding box of the geometry.")
795  .def("transform", &ccHObject::Transform,
796  "Apply transformation (4x4 matrix) to the geometry "
797  "coordinates.")
798  .def("translate", &ccHObject::Translate,
799  "Apply translation to the geometry coordinates.",
800  "translation"_a, "relative"_a = true)
801  .def("scale", py::overload_cast<double>(&ccHObject::Scale),
802  "Apply scaling to the geometry coordinates.", "scale"_a)
803  .def("scale",
804  py::overload_cast<double, const Eigen::Vector3d&>(
806  "Apply scaling to the geometry coordinates.", "scale"_a,
807  "center"_a)
808  .def("rotate",
809  py::overload_cast<const Eigen::Matrix3d&>(&ccHObject::Rotate),
810  "Apply rotation to the geometry coordinates and normals.",
811  "R"_a)
812  .def("rotate",
813  py::overload_cast<const Eigen::Matrix3d&,
814  const Eigen::Vector3d&>(&ccHObject::Rotate),
815  "Apply rotation to the geometry coordinates and normals.",
816  "R"_a, "center"_a)
817  .def(
818  "to_file",
819  [](const ccHObject& entity, const std::string& filename,
820  short dataVersion) {
821  QFile out(filename.c_str());
822  if (!out.open(QIODevice::WriteOnly)) {
823  return false;
824  }
825  return entity.toFile(out, dataVersion);
826  },
827  "Saves data to binary stream.", "filename"_a,
828  "data_version"_a)
829  .def("minimum_file_version", &ccHObject::minimumFileVersion,
830  "Returns the minimum file version required to save this "
831  "object")
832  .def(
833  "from_file",
834  [](ccHObject& entity, const std::string& filename,
835  short dataVersion, int flags) {
836  QFile in(filename.c_str());
837  if (!in.open(QIODevice::ReadOnly)) {
838  return false;
839  }
840  ccSerializableObject::LoadedIDMap oldToNewIDMap;
841  return entity.fromFile(in, dataVersion, flags,
842  oldToNewIDMap);
843  },
844  "Loads data from binary stream.", "filename"_a,
845  "dataVersion"_a, "flags"_a)
846  .def("get_glTransformation_history",
848  "Returns the transformation 'history' matrix.")
849  .def("set_glTransformation_history",
851  "Sets the transformation 'history' matrix (handle with "
852  "care!).",
853  "mat"_a)
854  .def("reset_glTransformation_history",
856  "Resets the transformation 'history' matrix.")
857  .def("find", &ccHObject::find,
858  "Finds an entity in this object hierarchy.", "unique_id"_a)
859  .def("get_children_number", &ccHObject::getChildrenNumber,
860  "Returns the number of children.")
861  .def(
862  "filter_children",
863  [](const ccHObject& entity, bool recursive /*=false*/,
864  CV_CLASS_ENUM filter /*=CV_TYPES::OBJECT*/,
865  bool strict /*=false*/) {
866  ccHObject::Container filteredChildren;
867  entity.filterChildren(filteredChildren, recursive,
868  filter, strict);
869  std::vector<std::shared_ptr<ccHObject>> container;
870  for (auto child : filteredChildren) {
871  const_cast<ccHObject&>(entity).detachChild(child);
872  container.push_back(
873  std::shared_ptr<ccHObject>(child));
874  }
875  return container;
876  },
877  "Collects the children corresponding to a certain pattern.",
878  "recursive"_a = false, "filter"_a = CV_TYPES::OBJECT,
879  "strict"_a = false)
880  .def_static("New",
881  py::overload_cast<CV_CLASS_ENUM, const char*>(
882  &ccHObject::New),
883  "objectType"_a, "name"_a = nullptr)
884  .def_static("New",
885  py::overload_cast<const QString&, const QString&,
886  const char*>(&ccHObject::New),
887  "pluginId"_a, "classId"_a, "name"_a = nullptr)
888  .def_static("get_rotation_matrix_from_xyz",
890  .def_static("get_rotation_matrix_from_yzx",
892  .def_static("get_rotation_matrix_from_zxy",
894  .def_static("get_rotation_matrix_from_xzy",
896  .def_static("get_rotation_matrix_from_zyx",
898  .def_static("get_rotation_matrix_from_yxz",
900  .def_static("get_rotation_matrix_from_axis_angle",
902  "rotation"_a)
903  .def_static("get_rotation_matrix_from_euler_angle",
905  "rotation"_a)
906  .def_static("get_rotation_matrix_from_quaternion",
908  "rotation"_a);
909  docstring::ClassMethodDocInject(m, "ccHObject", "get_class_id");
910  docstring::ClassMethodDocInject(m, "ccHObject", "is_group");
911  docstring::ClassMethodDocInject(m, "ccHObject", "get_parent");
912  docstring::ClassMethodDocInject(m, "ccHObject", "remove_all_children");
914  m, "ccHObject", "add_child",
915  {{"child", "child instance geometry"},
916  {"dependencyFlags", "dependency flags"},
917  {"insertIndex",
918  "insertion index "
919  "(if <0, child is simply appended to the children list)"}});
920  docstring::ClassMethodDocInject(m, "ccHObject", "get_child",
921  {{"childPos", "child position"}});
922  docstring::ClassMethodDocInject(m, "ccHObject", "set_pointSize_recursive",
923  {{"pSize", "point size"}});
924  docstring::ClassMethodDocInject(m, "ccHObject", "set_lineWidth_recursive",
925  {{"width", "line width"}});
926  docstring::ClassMethodDocInject(m, "ccHObject", "is_serializable");
927  docstring::ClassMethodDocInject(m, "ccHObject", "is_empty");
928  docstring::ClassMethodDocInject(m, "ccHObject", "get_min_bound");
929  docstring::ClassMethodDocInject(m, "ccHObject", "get_max_bound");
930  docstring::ClassMethodDocInject(m, "ccHObject", "get_min_2Dbound");
931  docstring::ClassMethodDocInject(m, "ccHObject", "get_max_2Dbound");
932  docstring::ClassMethodDocInject(m, "ccHObject", "get_center");
934  m, "ccHObject", "get_own_bounding_box",
935  {{"withGLFeatures", "whether use openGL features."}});
936  docstring::ClassMethodDocInject(m, "ccHObject",
937  "get_axis_aligned_bounding_box");
938  docstring::ClassMethodDocInject(m, "ccHObject",
939  "get_oriented_bounding_box");
940  docstring::ClassMethodDocInject(m, "ccHObject", "transform");
942  m, "ccHObject", "translate",
943  {{"translation", "A 3D vector to transform the geometry"},
944  {"relative",
945  "If true, the translation vector is directly added to the "
946  "geometry "
947  "coordinates. Otherwise, the center is moved to the translation "
948  "vector."}});
950  m, "ccHObject", "scale",
951  {{"s",
952  "The scale parameter that is multiplied to the points/vertices "
953  "of the geometry"},
954  {"center", "Scale center used for transformation"}});
956  m, "ccHObject", "rotate",
957  {{"R", "The rotation matrix"},
958  {"center", "Rotation center used for transformation"}});
959  docstring::ClassMethodDocInject(m, "ccHObject", "to_file",
960  {{"out", "output file (already opened)"}});
962  m, "ccHObject", "from_file",
963  {{"in", "input file (already opened)"},
964  {"dataVersion", "file version"},
965  {"flags",
966  "deserialization flags (see "
967  "ccSerializableObject::DeserializationFlags)"}});
968  docstring::ClassMethodDocInject(m, "ccHObject",
969  "get_glTransformation_history");
971  m, "ccHObject", "set_glTransformation_history",
972  {{"mat", "transformation 'history' matrix"}});
973  docstring::ClassMethodDocInject(m, "ccHObject",
974  "reset_glTransformation_history");
975  docstring::ClassMethodDocInject(m, "ccHObject", "find");
976  docstring::ClassMethodDocInject(m, "ccHObject", "get_children_number");
978  m, "ccHObject", "filter_children",
979  {{"recursive", "specifies if the search should be recursive"},
980  {"filter", "pattern for children selection"},
981  {"strict",
982  "whether the search is strict on the type "
983  "(i.e 'isA') or not (i.e. 'isKindOf')"}});
984 
985  // cloudViewer.geometry.ccPlanarEntityInterface
986  py::class_<ccPlanarEntityInterface,
988  std::shared_ptr<ccPlanarEntityInterface>>
989  planarEntityInterface(m, "ccPlanarEntityInterface",
990  "The Interface for a planar entity.");
991  planarEntityInterface
992  .def("__repr__",
993  [](const ccPlanarEntityInterface& planarEI) {
994  CCVector3 normal = planarEI.getNormal();
995  std::string info = fmt::format(
996  "ccPlanarEntityInterface with normal ({}, {}, "
997  "{}), show normal vector {}",
998  normal.x, normal.y, normal.z,
999  planarEI.normalVectorIsShown() ? "True" : "False");
1000  })
1001  .def(
1002  "get_normal",
1003  [](const ccPlanarEntityInterface& planarEI) {
1004  return CCVector3d::fromArray(planarEI.getNormal());
1005  },
1006  "Returns the entity normal")
1007  .def("show_normal_vector",
1009  "Show normal vector.", "state"_a)
1010  .def("normal_vector_is_shown",
1012  "Whether normal vector is shown or not.");
1013  docstring::ClassMethodDocInject(m, "ccPlanarEntityInterface", "get_normal");
1014  docstring::ClassMethodDocInject(m, "ccPlanarEntityInterface",
1015  "normal_vector_is_shown");
1016  docstring::ClassMethodDocInject(m, "ccPlanarEntityInterface",
1017  "show_normal_vector",
1018  {{"state", "normal vector shown flag."}});
1019 }
1020 
1021 void pybind_geometry(py::module& m) {
1022  py::module m_submodule = m.def_submodule("geometry");
1023  pybind_geometry_classes(m_submodule);
1024  pybind_kdtreeflann(m_submodule);
1025  pybind_cloudbase(m_submodule);
1026  pybind_pointcloud(m_submodule);
1027  pybind_keypoint(m_submodule);
1028  pybind_voxelgrid(m_submodule);
1029  pybind_lineset(m_submodule);
1030  pybind_meshbase(m_submodule);
1031  pybind_trianglemesh(m_submodule);
1032  pybind_halfedgetrianglemesh(m_submodule);
1033  pybind_tetramesh(m_submodule);
1034  pybind_image(m_submodule);
1035  pybind_primitives(m_submodule);
1036  pybind_facet(m_submodule);
1037  pybind_polyline(m_submodule);
1038  pybind_cloudbase_methods(m_submodule);
1039  pybind_pointcloud_methods(m_submodule);
1040  pybind_voxelgrid_methods(m_submodule);
1041  pybind_meshbase_methods(m_submodule);
1042  pybind_primitives_methods(m_submodule);
1043  pybind_facet_methods(m_submodule);
1044  pybind_polyline_methods(m_submodule);
1045  pybind_lineset_methods(m_submodule);
1046  pybind_image_methods(m_submodule);
1047  pybind_octree_methods(m_submodule);
1048  pybind_octree(m_submodule);
1049  pybind_boundingvolume(m_submodule);
1050 }
1051 
1052 } // namespace geometry
1053 } // namespace cloudViewer
int64_t CV_CLASS_ENUM
Type of object type flags (64 bits)
Definition: CVTypes.h:97
std::string filename
filament::Texture::InternalFormat format
double normal[3]
std::string name
math::float4 color
static Vector3Tpl fromArray(const int a[3])
Constructor from an int array.
Definition: CVGeom.h:268
Generic interface for (3D) drawable entities.
virtual void translateGL(const CCVector3 &trans)
Translates current GL transformation by a rotation matrix.
virtual void toggleVisibility()
Toggles visibility.
virtual bool colorsShown() const
Returns whether colors are shown or not.
virtual float getOpacity() const
virtual bool isVisible() const
Returns whether entity is visible or not.
virtual void setTempColor(const ecvColor::Rgb &col, bool autoActivate=true)
Sets current temporary (unique)
virtual bool isVisibilityLocked() const
Returns whether visibility is locked or not.
virtual bool hasDisplayedScalarField() const
Returns whether an active scalar field is available or not.
virtual void toggleNormals()
Toggles normals display state.
virtual bool hasColors() const
Returns whether colors are enabled or not.
virtual void lockVisibility(bool state)
Locks/unlocks visibility.
virtual void enableGLTransformation(bool state)
Enables/disables associated GL transformation.
virtual void setVisible(bool state)
Sets entity visibility.
virtual bool sfShown() const
Returns whether active scalar field is visible.
virtual bool isGLTransEnabled() const
Returns whether a GL transformation is enabled or not.
virtual bool normalsShown() const
Returns whether normals are shown or not.
virtual const ccGLMatrix & getGLTransformation() const
Returns associated GL transformation.
virtual bool hasNormals() const
Returns whether normals are enabled or not.
virtual bool isColorOverridden() const
virtual void toggleSF()
Toggles SF display state.
virtual void toggleMaterials()
Toggles material display state.
virtual void toggleColors()
Toggles colors display state.
virtual bool isSelected() const
Returns whether entity is selected or not.
virtual void toggleShowName()
Toggles name in 3D display state.
virtual void showNameIn3D(bool state)
Sets whether name should be displayed in 3D.
virtual bool nameShownIn3D() const
Returns whether name is displayed in 3D or not.
virtual void enableTempColor(bool state)
Set temporary color activation state.
virtual void showNormals(bool state)
Sets normals visibility.
virtual void showColors(bool state)
Sets colors visibility.
virtual void showSF(bool state)
Sets active scalarfield visibility.
virtual const ecvColor::Rgb & getTempColor() const
Returns current temporary (unique) color.
virtual void setOpacity(float opacity)
Set opacity activation state.
virtual void rotateGL(const ccGLMatrix &rotMat)
Multiplies (left) current GL transformation by a rotation matrix.
virtual bool hasScalarFields() const
Returns whether one or more scalar fields are instantiated.
virtual void resetGLTransformation()
Resets associated GL transformation.
virtual void setGLTransformation(const ccGLMatrix &trans)
Associates entity with a GL transformation (rotation + translation)
virtual void setSelected(bool state)
Selects/Unselects entity.
static ccGLMatrixTpl< float > FromEigenMatrix(const Eigen::Matrix< double, 4, 4 > &mat)
static Eigen::Matrix< float, 4, 4 > ToEigenMatrix4(const ccGLMatrixTpl< float > &mat)
static ccMesh * ToMesh(ccHObject *obj)
Converts current object to ccMesh (if possible)
static ccPointCloud * ToPointCloud(ccHObject *obj, bool *isLockedVertices=nullptr)
Converts current object to 'equivalent' ccPointCloud.
static ccBBox * ToBBox(ccHObject *obj)
static cc2DViewportLabel * To2DViewportLabel(ccHObject *obj)
Converts current object to cc2DViewportLabel (if possible)
static cloudViewer::geometry::Image * ToImage2(ccHObject *obj)
static ccCameraSensor * ToCameraSensor(ccHObject *obj)
static ccCylinder * ToCylinder(ccHObject *obj)
Converts current object to ccCylinder (if possible)
static cloudViewer::geometry::Octree * ToOctree2(ccHObject *obj)
static ccDish * ToDish(ccHObject *obj)
Converts current object to ccDish (if possible)
static ccOctreeProxy * ToOctreeProxy(ccHObject *obj)
Converts current object to ccOctreeProxy (if possible)
static cloudViewer::geometry::LineSet * ToLineSet(ccHObject *obj)
static ccKdTree * ToKdTree(ccHObject *obj)
Converts current object to ccKdTree (if possible)
static cloudViewer::geometry::RGBDImage * ToRGBDImage(ccHObject *obj)
static ccExtru * ToExtru(ccHObject *obj)
Converts current object to ccExtru (if possible)
static ccPolyline * ToPolyline(ccHObject *obj)
Converts current object to ccPolyline (if possible)
static cc2DLabel * To2DLabel(ccHObject *obj)
Converts current object to cc2DLabel (if possible)
static ccSensor * ToSensor(ccHObject *obj)
Converts current object to ccSensor (if possible)
static cc2DViewportObject * To2DViewportObject(ccHObject *obj)
Converts current object to cc2DViewportObject (if possible)
static ccCoordinateSystem * ToCoordinateSystem(ccHObject *obj)
Converts current object to ccCoordinateSystem (if possible)
static ccBox * ToBox(ccHObject *obj)
Converts current object to ccBox (if possible)
static ccImage * ToImage(ccHObject *obj)
static ccSubMesh * ToSubMesh(ccHObject *obj)
Converts current object to ccSubMesh (if possible)
static ccFacet * ToFacet(ccHObject *obj)
Converts current object to ccFacet (if possible)
static ecvOrientedBBox * ToOrientedBBox(ccHObject *obj)
static ccIndexedTransformationBuffer * ToTransBuffer(ccHObject *obj)
Converts current object to ccIndexedTransformationBuffer (if possible)
static ccSphere * ToSphere(ccHObject *obj)
Converts current object to ccSphere (if possible)
static ccQuadric * ToQuadric(ccHObject *obj)
Converts current object to ccQuadric (if possible)
static ccCone * ToCone(ccHObject *obj)
Converts current object to ccCone (if possible)
static cloudViewer::geometry::VoxelGrid * ToVoxelGrid(ccHObject *obj)
static ccGBLSensor * ToGBLSensor(ccHObject *obj)
static ccPlane * ToPlane(ccHObject *obj)
Converts current object to ccPlane (if possible)
static ccTorus * ToTorus(ccHObject *obj)
Converts current object to ccTorus (if possible)
Hierarchical CLOUDVIEWER Object.
Definition: ecvHObject.h:25
static Eigen::Matrix3d GetRotationMatrixFromYXZ(const Eigen::Vector3d &rotation)
Get Rotation Matrix from YXZ RotationType.
void setLineWidthRecursive(PointCoordinateType width)
virtual ccHObject & Scale(const double s, const Eigen::Vector3d &center)
Apply scaling to the geometry coordinates. Given a scaling factor , and center , a given point is tr...
Definition: ecvHObject.h:176
virtual ccBBox getOwnBB(bool withGLFeatures=false)
Returns the entity's own bounding-box.
virtual const ccGLMatrix & getGLTransformationHistory() const
Returns the transformation 'history' matrix.
Definition: ecvHObject.h:631
static Eigen::Matrix3d GetRotationMatrixFromYZX(const Eigen::Vector3d &rotation)
Get Rotation Matrix from YZX RotationType.
ccHObject * find(unsigned uniqueID)
Finds an entity in this object hierarchy.
bool toFile(QFile &out, short dataVersion) const override
Saves data to binary stream.
virtual ccBBox GetAxisAlignedBoundingBox() const
Returns an axis-aligned bounding box of the geometry.
virtual ecvOrientedBBox GetOrientedBoundingBox() const
static Eigen::Matrix3d GetRotationMatrixFromEulerAngle(const Eigen::Vector3d &rotation)
Get Rotation Matrix from Euler angle.
virtual Eigen::Vector3d GetCenter() const
Returns the center of the geometry coordinates.
Definition: ecvHObject.h:150
bool isSerializable() const override
Returns whether object is serializable of not.
virtual ccHObject & Translate(const Eigen::Vector3d &translation, bool relative=true)
Apply translation to the geometry coordinates.
Definition: ecvHObject.h:165
void removeAllChildren()
Removes all children.
short minimumFileVersion() const override
Returns the minimum file version required to save this instance.
virtual ccHObject & Rotate(const Eigen::Matrix3d &R, const Eigen::Vector3d &center)
Apply rotation to the geometry coordinates and normals. Given a rotation matrix , and center ,...
Definition: ecvHObject.h:186
virtual Eigen::Vector2d GetMax2DBound() const
Definition: ecvHObject.h:148
unsigned getChildrenNumber() const
Returns the number of children.
Definition: ecvHObject.h:312
void setPointSizeRecursive(int pSize)
virtual bool addChild(ccHObject *child, int dependencyFlags=DP_PARENT_OF_OTHER, int insertIndex=-1)
Adds a child.
virtual void setGLTransformationHistory(const ccGLMatrix &mat)
Sets the transformation 'history' matrix (handle with care!)
Definition: ecvHObject.h:635
static Eigen::Matrix3d GetRotationMatrixFromXYZ(const Eigen::Vector3d &rotation)
Get Rotation Matrix from XYZ RotationType.
virtual bool IsEmpty() const
Definition: ecvHObject.h:142
static Eigen::Matrix3d GetRotationMatrixFromZXY(const Eigen::Vector3d &rotation)
Get Rotation Matrix from ZXY RotationType.
static Eigen::Matrix3d GetRotationMatrixFromQuaternion(const Eigen::Vector4d &rotation)
Get Rotation Matrix from Quaternion.
virtual Eigen::Vector3d GetMaxBound() const
Returns max bounds for geometry coordinates.
Definition: ecvHObject.h:147
ccHObject * getParent() const
Returns parent object.
Definition: ecvHObject.h:245
virtual Eigen::Vector3d GetMinBound() const
Returns min bounds for geometry coordinates.
Definition: ecvHObject.h:144
static Eigen::Matrix3d GetRotationMatrixFromAxisAngle(const Eigen::Vector3d &rotation)
Get Rotation Matrix from AxisAngle RotationType.
void removeChild(ccHObject *child)
unsigned filterChildren(Container &filteredChildren, bool recursive=false, CV_CLASS_ENUM filter=CV_TYPES::OBJECT, bool strict=false) const
Collects the children corresponding to a certain pattern.
virtual ccHObject & Transform(const Eigen::Matrix4d &transformation)
Apply transformation (4x4 matrix) to the geometry coordinates.
Definition: ecvHObject.h:157
static ccHObject * New(CV_CLASS_ENUM objectType, const char *name=nullptr)
Static factory.
bool fromFile(QFile &in, short dataVersion, int flags, LoadedIDMap &oldToNewIDMap) override
Loads data from binary stream.
std::vector< ccHObject * > Container
Standard instances container (for children, etc.)
Definition: ecvHObject.h:337
virtual void resetGLTransformationHistory()
Resets the transformation 'history' matrix.
Definition: ecvHObject.h:639
static Eigen::Matrix3d GetRotationMatrixFromZYX(const Eigen::Vector3d &rotation)
Get Rotation Matrix from ZYX RotationType.
virtual Eigen::Vector2d GetMin2DBound() const
Definition: ecvHObject.h:145
ccHObject * getChild(unsigned childPos) const
Returns the ith child.
Definition: ecvHObject.h:325
CV_CLASS_ENUM getClassID() const override
Returns class ID.
Definition: ecvHObject.h:232
static Eigen::Matrix3d GetRotationMatrixFromXZY(const Eigen::Vector3d &rotation)
Get Rotation Matrix from XZY RotationType.
bool isGroup() const
Returns whether the instance is a group.
Definition: ecvHObject.h:237
Generic "CLOUDVIEWER Object" template.
Definition: ecvObject.h:49
virtual QString getName() const
Returns object name.
Definition: ecvObject.h:72
virtual unsigned getUniqueID() const
Returns object unique ID.
Definition: ecvObject.h:86
bool isA(CV_CLASS_ENUM type) const
Definition: ecvObject.h:131
virtual void setName(const QString &name)
Sets object name.
Definition: ecvObject.h:75
bool isCustom() const
Definition: ecvObject.h:123
bool isHierarchy() const
Definition: ecvObject.h:124
bool isLeaf() const
Definition: ecvObject.h:122
virtual void setUniqueID(unsigned ID)
Changes unique ID.
bool isKindOf(CV_CLASS_ENUM type) const
Definition: ecvObject.h:128
Interface for a planar entity.
void showNormalVector(bool state)
Show normal vector.
bool normalVectorIsShown() const
Whether normal vector is shown or not.
virtual CCVector3 getNormal() const =0
Returns the entity normal.
QMultiMap< unsigned, unsigned > LoadedIDMap
Map of loaded unique IDs (old ID --> new ID)
constexpr static RgbTpl FromEigen(const Eigen::Vector3d &t)
Definition: ecvColorTypes.h:86
static Eigen::Vector3d ToEigen(const Type col[3])
Definition: ecvColorTypes.h:72
#define LogWarning(...)
Definition: Logging.h:72
@ SENSOR
Definition: CVTypes.h:116
@ CUSTOM_H_OBJECT
Definition: CVTypes.h:179
@ VIEWPORT_2D_OBJECT
Definition: CVTypes.h:141
@ PRIMITIVE
Definition: CVTypes.h:119
@ MESH
Definition: CVTypes.h:105
@ GBL_SENSOR
Definition: CVTypes.h:117
@ TETRA_MESH
Definition: CVTypes.h:149
@ IMAGE
Definition: CVTypes.h:114
@ CONE
Definition: CVTypes.h:123
@ MESH_GROUP
Definition: CVTypes.h:107
@ POINT_CLOUD
Definition: CVTypes.h:104
@ DISH
Definition: CVTypes.h:129
@ VOXEL_GRID
Definition: CVTypes.h:151
@ LABEL_2D
Definition: CVTypes.h:140
@ POLY_LINE
Definition: CVTypes.h:112
@ POINT_KDTREE
Definition: CVTypes.h:111
@ FACET
Definition: CVTypes.h:109
@ SUB_MESH
Definition: CVTypes.h:106
@ LINESET
Definition: CVTypes.h:152
@ QUADRIC
Definition: CVTypes.h:131
@ RGBD_IMAGE
Definition: CVTypes.h:158
@ OLD_CYLINDER_ID
Definition: CVTypes.h:124
@ POINT_OCTREE
Definition: CVTypes.h:110
@ TORUS
Definition: CVTypes.h:122
@ EXTRU
Definition: CVTypes.h:130
@ IMAGE2
Definition: CVTypes.h:156
@ SPHERE
Definition: CVTypes.h:121
@ MATERIAL_SET
Definition: CVTypes.h:132
@ CAMERA_SENSOR
Definition: CVTypes.h:118
@ PLANE
Definition: CVTypes.h:120
@ POINT_OCTREE2
Definition: CVTypes.h:157
@ VIEWPORT_2D_LABEL
Definition: CVTypes.h:142
@ BBOX
Definition: CVTypes.h:154
@ CYLINDER
Definition: CVTypes.h:126
@ OBJECT
Definition: CVTypes.h:102
@ ORIENTED_BBOX
Definition: CVTypes.h:155
void ClassMethodDocInject(py::module &pybind_module, const std::string &class_name, const std::string &function_name, const std::unordered_map< std::string, std::string > &map_parameter_body_docs)
Definition: docstring.cpp:27
py::handle static_property
Definition: docstring.cpp:24
void pybind_geometry_classes(py::module &m)
Definition: geometry.cpp:57
void pybind_meshbase_methods(py::module &m)
Definition: meshbase.cpp:509
void pybind_octree_methods(py::module &m)
Definition: octree.cpp:348
void pybind_voxelgrid(py::module &m)
Definition: voxelgrid.cpp:24
void pybind_image_methods(py::module &m)
Definition: image.cpp:274
void pybind_geometry(py::module &m)
Definition: geometry.cpp:1021
void pybind_pointcloud(py::module &m)
Definition: pointcloud.cpp:28
void pybind_polyline(py::module &m)
Definition: polyline.cpp:31
void pybind_tetramesh(py::module &m)
Definition: tetramesh.cpp:18
void pybind_image(py::module &m)
Definition: image.cpp:40
void pybind_primitives_methods(py::module &m)
void pybind_facet(py::module &m)
Definition: facet.cpp:30
void pybind_lineset(py::module &m)
Definition: lineset.cpp:20
void pybind_pointcloud_methods(py::module &m)
void pybind_cloudbase(py::module &m)
Definition: cloudbase.cpp:30
void pybind_kdtreeflann(py::module &m)
Definition: kdtreeflann.cpp:17
void pybind_boundingvolume(py::module &m)
void pybind_meshbase(py::module &m)
Definition: meshbase.cpp:24
void pybind_cloudbase_methods(py::module &m)
Definition: cloudbase.cpp:479
void pybind_voxelgrid_methods(py::module &m)
Definition: voxelgrid.cpp:244
void pybind_octree(py::module &m)
Definition: octree.cpp:38
void pybind_halfedgetrianglemesh(py::module &m)
void pybind_keypoint(py::module &m)
Definition: keypoint.cpp:52
void pybind_lineset_methods(py::module &m)
Definition: lineset.cpp:129
void pybind_trianglemesh(py::module &m)
void pybind_polyline_methods(py::module &m)
Definition: polyline.cpp:277
void pybind_facet_methods(py::module &m)
Definition: facet.cpp:237
void pybind_primitives(py::module &m)
Definition: primitives.cpp:37
Generic file read and write utility for python interface.