ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ccCommandLine.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 <pybind11/pybind11.h>
9 #include <pybind11/stl.h>
10 #include <pybind11/stl_bind.h>
11 
13 #include <ecvGenericMesh.h>
14 
15 #include "../../wrapper/pycc/src/casters.h"
16 
17 namespace py = pybind11;
18 using namespace pybind11::literals;
19 
20 PYBIND11_MAKE_OPAQUE(std::vector<CLCloudDesc>);
21 PYBIND11_MAKE_OPAQUE(std::vector<CLMeshDesc>);
22 
23 void define_ccCommandLine(py::module &m)
24 {
25 
26  py::bind_vector<std::vector<CLCloudDesc>>(m, "CLCloudDescVector");
27  py::bind_vector<std::vector<CLMeshDesc>>(m, "CLMeshDescVector");
28 
29  py::enum_<CL_ENTITY_TYPE>(m, "CL_ENTITY_TYPE")
30  .value("GROUP", CL_ENTITY_TYPE::GROUP)
31  .value("CLOUD", CL_ENTITY_TYPE::CLOUD)
32  .value("MESH", CL_ENTITY_TYPE::MESH);
33 
34  py::class_<CLEntityDesc>(m, "CLEntityDesc")
35  .def_readonly("basename", &CLEntityDesc::basename)
36  .def_readonly("path", &CLEntityDesc::path)
37  .def_readonly("indexInFile", &CLEntityDesc::indexInFile)
38  .def("getEntity",
40  py::return_value_policy::reference);
41 
42  py::class_<CLGroupDesc, CLEntityDesc>(m, "CLGroupDesc")
43  .def_readonly("groupEntity", &CLGroupDesc::groupEntity, py::return_value_policy::reference);
44 
45  py::class_<CLCloudDesc, CLEntityDesc>(m, "CLCloudDesc")
46  .def_readonly("pc", &CLCloudDesc::pc, py::return_value_policy::reference);
47 
48  py::class_<CLMeshDesc, CLEntityDesc>(m, "CLMeshDesc")
49  .def_readonly("mesh", &CLMeshDesc::mesh, py::return_value_policy::reference);
50 
51  py::class_<ccCommandLineInterface> PyccCommandLineInterface(m, "ccCommandLineInterface");
52 
53  py::enum_<ccCommandLineInterface::ExportOption>(PyccCommandLineInterface, "ExportOption");
54 
55  py::class_<ccCommandLineInterface::GlobalShiftOptions> PyGlobalShiftOptions(
56  PyccCommandLineInterface, "GlobalShiftOptions");
57 
58  py::enum_<ccCommandLineInterface::GlobalShiftOptions::Mode>(PyGlobalShiftOptions, "Mode")
59  .value("NO_GLOBAL_SHIFT", ccCommandLineInterface::GlobalShiftOptions::Mode::NO_GLOBAL_SHIFT)
60  .value("AUTO_GLOBAL_SHIFT",
61  ccCommandLineInterface::GlobalShiftOptions::Mode::AUTO_GLOBAL_SHIFT)
62  .value("FIRST_GLOBAL_SHIFT",
63  ccCommandLineInterface::GlobalShiftOptions::Mode::FIRST_GLOBAL_SHIFT)
64  .value("CUSTOM_GLOBAL_SHIFT",
65  ccCommandLineInterface::GlobalShiftOptions::Mode::CUSTOM_GLOBAL_SHIFT)
66  .export_values();
67 
68  PyGlobalShiftOptions.def_readwrite("mode", &ccCommandLineInterface::GlobalShiftOptions::mode)
69  .def_readwrite("customGlobalShift",
71  .def(py::init<>());
72 
73  PyccCommandLineInterface
74  .def("clouds",
75  (std::vector<CLCloudDesc> &
77  py::return_value_policy::reference)
78  .def("meshes",
79  (std::vector<CLMeshDesc> &
81  .def("getExportFilename",
83  "entityDesc"_a,
84  "extension"_a = QString(),
85  "suffix"_a = QString(),
86  "baseOutputFilename"_a = nullptr,
87  "forceNoTimestamp"_a = false)
88  .def("exportEntity",
90  "entityDesc"_a,
91  "suffix"_a = QString(),
92  "outputFilename"_a = nullptr,
94  .def("saveCloud",
96  "suffix"_a = QString(),
97  "allAtOnce"_a = false,
98  "allAtOnceFileName"_a = nullptr)
99  .def("saveMeshes",
101  "suffix"_a = QString(),
102  "allAtOnce"_a = false,
103  "allAtOnceFileName"_a = nullptr)
104  .def(
105  "importFile",
106  [](ccCommandLineInterface &self,
107  QString filename,
109  { return self.importFile(filename, opts); },
110  "filename"_a,
111  "opts"_a);
112 }
std::string filename
void define_ccCommandLine(py::module &m)
PYBIND11_MAKE_OPAQUE(std::vector< CLCloudDesc >)
Command line interface.
virtual bool saveClouds(QString suffix=QString(), bool allAtOnce=false, const QString *allAtOnceFileName=nullptr)=0
Saves all clouds.
virtual QString getExportFilename(const CLEntityDesc &entityDesc, QString extension=QString(), QString suffix=QString(), QString *baseOutputFilename=nullptr, bool forceNoTimestamp=false) const =0
Returns the name of a to-be-exported entity.
virtual QString exportEntity(CLEntityDesc &entityDesc, const QString &suffix=QString(), QString *outputFilename=nullptr, ccCommandLineInterface::ExportOptions options=ExportOption::NoOptions)=0
Exports a cloud or a mesh.
virtual std::vector< CLMeshDesc > & meshes()
Currently opened meshes and their filename.
virtual bool saveMeshes(QString suffix=QString(), bool allAtOnce=false, const QString *allAtOnceFileName=nullptr)=0
Saves all meshes.
virtual std::vector< CLCloudDesc > & clouds()
Currently opened point clouds and their filename.
Hierarchical CLOUDVIEWER Object.
Definition: ecvHObject.h:25
ccPointCloud * pc
Loaded entity description.
virtual ccHObject * getEntity()=0
ccHObject * groupEntity
ccGenericMesh * mesh