ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
cvSelectionExporter.h
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 #pragma once
9 
10 #include "qPCL.h"
11 
12 // LOCAL
13 #include "cvSelectionData.h"
14 
15 // Qt
16 #include <QList>
17 #include <QString>
18 
19 // STL
20 #include <functional>
21 
22 // Forward declarations
23 class ccHObject;
24 class ccMesh;
25 class ccPointCloud;
26 class vtkPolyData;
27 class QWidget;
28 
43 public:
47  struct ExportOptions {
48  QString name; //< Name for the created object
49  bool addToScene; //< Whether to add to scene directly
50  bool saveToFile; //< Whether to save to file
51  QString filename; //< Output filename (if saveToFile=true)
52  bool writeAscii; //< Use ASCII format (if supported)
53  bool compressed; //< Use compression (if supported)
54  QWidget* parentWidget; //< Parent widget for dialogs
55 
56  // Constructor with default values
58  : addToScene(false),
59  saveToFile(false),
60  writeAscii(false),
61  compressed(false),
62  parentWidget(nullptr) {}
63  };
64 
73  static ccMesh* exportToMesh(vtkPolyData* polyData,
74  const cvSelectionData& selectionData,
75  const ExportOptions& options = ExportOptions());
76 
85  static ccPointCloud* exportToPointCloud(
86  vtkPolyData* polyData,
87  const cvSelectionData& selectionData,
88  const ExportOptions& options = ExportOptions());
89 
90  //=========================================================================
91  // Direct Extraction from ccPointCloud/ccMesh (bypasses VTK conversion)
92  //=========================================================================
93 
107  static ccPointCloud* exportFromSourceCloud(
109  const cvSelectionData& selectionData,
110  const ExportOptions& options = ExportOptions());
111 
124  static ccMesh* exportFromSourceMesh(
125  ccMesh* sourceMesh,
126  const cvSelectionData& selectionData,
127  const ExportOptions& options = ExportOptions());
128 
138  static bool exportToFile(vtkPolyData* polyData,
139  const cvSelectionData& selectionData,
140  const QString& filename,
141  bool writeAscii = false,
142  bool compressed = false);
143 
150  static vtkPolyData* extractSelection(vtkPolyData* polyData,
151  const cvSelectionData& selectionData);
152 
153  //=========================================================================
154  // Batch Export Functionality
155  //=========================================================================
156 
164  static QList<ccMesh*> batchExportToMeshes(
165  vtkPolyData* polyData,
166  const QList<cvSelectionData>& selections,
167  const QString& baseName = "Selection");
168 
176  static QList<ccPointCloud*> batchExportToPointClouds(
177  vtkPolyData* polyData,
178  const QList<cvSelectionData>& selections,
179  const QString& baseName = "Selection");
180 
191  static int batchExportToFiles(
192  vtkPolyData* polyData,
193  const QList<cvSelectionData>& selections,
194  const QString& outputDir,
195  const QString& format,
196  const QString& baseName = "selection",
197  std::function<void(int)> progressCallback = nullptr);
198 
207  static bool exportNumbered(vtkPolyData* polyData,
208  const cvSelectionData& selection,
209  const QString& outputPath,
210  int number);
211 
222  static bool saveObjectToFileWithDialog(ccHObject* object,
223  bool isMesh,
224  QWidget* parent = nullptr);
225 
226 private:
231  static ccMesh* vtkPolyDataToCCMesh(vtkPolyData* polyData,
232  const QString& name);
233 
238  static ccPointCloud* vtkPolyDataToCCPointCloud(vtkPolyData* polyData,
239  const QString& name);
240 
249  static bool saveObjectToFile(ccHObject* object,
250  const QString& filename,
251  bool writeAscii = false,
252  bool compressed = false);
253 };
Compressed compressed
std::string filename
filament::Texture::InternalFormat format
std::string name
Hierarchical CLOUDVIEWER Object.
Definition: ecvHObject.h:25
Triangular mesh.
Definition: ecvMesh.h:35
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
Encapsulates selection data without exposing VTK types.
Helper class for exporting selections to CloudViewer objects or files.
ccGenericPointCloud * sourceCloud
#define QPCL_ENGINE_LIB_API
Definition: qPCL.h:15
Options for exporting selections.