ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
cvSelectionExporter Class Reference

Helper class for exporting selections to CloudViewer objects or files. More...

#include <cvSelectionExporter.h>

Classes

struct  ExportOptions
 Options for exporting selections. More...
 

Static Public Member Functions

static ccMeshexportToMesh (vtkPolyData *polyData, const cvSelectionData &selectionData, const ExportOptions &options=ExportOptions())
 Export selected cells to ccMesh. More...
 
static ccPointCloudexportToPointCloud (vtkPolyData *polyData, const cvSelectionData &selectionData, const ExportOptions &options=ExportOptions())
 Export selected points to ccPointCloud. More...
 
static ccPointCloudexportFromSourceCloud (ccPointCloud *sourceCloud, const cvSelectionData &selectionData, const ExportOptions &options=ExportOptions())
 Export selected points directly from source ccPointCloud. More...
 
static ccMeshexportFromSourceMesh (ccMesh *sourceMesh, const cvSelectionData &selectionData, const ExportOptions &options=ExportOptions())
 Export selected cells directly from source ccMesh. More...
 
static bool exportToFile (vtkPolyData *polyData, const cvSelectionData &selectionData, const QString &filename, bool writeAscii=false, bool compressed=false)
 Export selection to file (uses CV_io module) More...
 
static vtkPolyData * extractSelection (vtkPolyData *polyData, const cvSelectionData &selectionData)
 Extract selected geometry as new vtkPolyData. More...
 
static QList< ccMesh * > batchExportToMeshes (vtkPolyData *polyData, const QList< cvSelectionData > &selections, const QString &baseName="Selection")
 Export multiple selections to meshes. More...
 
static QList< ccPointCloud * > batchExportToPointClouds (vtkPolyData *polyData, const QList< cvSelectionData > &selections, const QString &baseName="Selection")
 Export multiple selections to point clouds. More...
 
static int batchExportToFiles (vtkPolyData *polyData, const QList< cvSelectionData > &selections, const QString &outputDir, const QString &format, const QString &baseName="selection", std::function< void(int)> progressCallback=nullptr)
 Export multiple selections to files. More...
 
static bool exportNumbered (vtkPolyData *polyData, const cvSelectionData &selection, const QString &outputPath, int number)
 Export selection with numbered naming. More...
 
static bool saveObjectToFileWithDialog (ccHObject *object, bool isMesh, QWidget *parent=nullptr)
 Save a ccHObject to file with file dialog Uses QFileDialog to let user choose filename and format Remembers last used path and filter using QSettings. More...
 

Detailed Description

Helper class for exporting selections to CloudViewer objects or files.

Provides functionality to convert VTK selections to:

  • ccMesh (from selected cells)
  • ccPointCloud (from selected points)
  • Various file formats (OBJ, PLY, STL, BIN, etc.) - uses CV_io module
  • Direct import to scene/rendering window

Based on ParaView's selection extraction filters:

  • vtkExtractSelection
  • pqExtractSelectionsReaction

Definition at line 42 of file cvSelectionExporter.h.

Member Function Documentation

◆ batchExportToFiles()

int cvSelectionExporter::batchExportToFiles ( vtkPolyData *  polyData,
const QList< cvSelectionData > &  selections,
const QString &  outputDir,
const QString &  format,
const QString &  baseName = "selection",
std::function< void(int)>  progressCallback = nullptr 
)
static

Export multiple selections to files.

Parameters
polyDataSource mesh data
selectionsList of selections
outputDirOutput directory
formatFile format ("obj", "ply", "stl", "bin")
baseNameBase name for files
progressCallbackOptional callback for progress updates (0-100)
Returns
Number of successfully exported files

Definition at line 1064 of file cvSelectionExporter.cpp.

References CVLog::Error(), exportToFile(), filename, format, cvSelectionData::isEmpty(), CVLog::Print(), and CVLog::Warning().

◆ batchExportToMeshes()

QList< ccMesh * > cvSelectionExporter::batchExportToMeshes ( vtkPolyData *  polyData,
const QList< cvSelectionData > &  selections,
const QString &  baseName = "Selection" 
)
static

Export multiple selections to meshes.

Parameters
polyDataSource mesh data
selectionsList of selections (all must be CELLS)
baseNameBase name for meshes (e.g., "Selection")
Returns
List of created meshes

Definition at line 942 of file cvSelectionExporter.cpp.

References cvSelectionData::CELLS, CVLog::Error(), exportToMesh(), name, cvSelectionExporter::ExportOptions::name, CVLog::Print(), and CVLog::Warning().

◆ batchExportToPointClouds()

QList< ccPointCloud * > cvSelectionExporter::batchExportToPointClouds ( vtkPolyData *  polyData,
const QList< cvSelectionData > &  selections,
const QString &  baseName = "Selection" 
)
static

Export multiple selections to point clouds.

Parameters
polyDataSource mesh data
selectionsList of selections (all must be POINTS)
baseNameBase name for clouds
Returns
List of created point clouds

Definition at line 1003 of file cvSelectionExporter.cpp.

References CVLog::Error(), exportToPointCloud(), name, cvSelectionExporter::ExportOptions::name, cvSelectionData::POINTS, CVLog::Print(), and CVLog::Warning().

◆ exportFromSourceCloud()

ccPointCloud * cvSelectionExporter::exportFromSourceCloud ( ccPointCloud sourceCloud,
const cvSelectionData selectionData,
const ExportOptions options = ExportOptions() 
)
static

Export selected points directly from source ccPointCloud.

This method bypasses VTK→ccPointCloud conversion by using the source ccPointCloud's partialClone method directly with selected indices. This preserves all scalar fields, normals, RGB colors, etc.

Parameters
sourceCloudSource point cloud (original data)
selectionDataSelection data (must be POINTS)
optionsExport options
Returns
Pointer to created ccPointCloud, or nullptr on failure
Note
Caller takes ownership of returned object if not added to scene

Definition at line 178 of file cvSelectionExporter.cpp.

References cloudViewer::ReferenceCloud::addPointIndex(), cvSelectionExporter::ExportOptions::compressed, CVLog::Error(), cvSelectionData::fieldAssociation(), cvSelectionExporter::ExportOptions::filename, cvSelectionData::ids(), cvSelectionData::isEmpty(), cvSelectionExporter::ExportOptions::name, cvSelectionData::POINTS, CVLog::PrintVerbose(), cloudViewer::ReferenceCloud::reserve(), result, cvSelectionExporter::ExportOptions::saveToFile, cloudViewer::GenericCloud::size(), sourceCloud, CVLog::Warning(), cvSelectionExporter::ExportOptions::writeAscii, ccPointCloud::WRN_OUT_OF_MEM_FOR_COLORS, ccPointCloud::WRN_OUT_OF_MEM_FOR_FWF, ccPointCloud::WRN_OUT_OF_MEM_FOR_NORMALS, and ccPointCloud::WRN_OUT_OF_MEM_FOR_SFS.

◆ exportFromSourceMesh()

ccMesh * cvSelectionExporter::exportFromSourceMesh ( ccMesh sourceMesh,
const cvSelectionData selectionData,
const ExportOptions options = ExportOptions() 
)
static

Export selected cells directly from source ccMesh.

This method bypasses VTK→ccMesh conversion by extracting triangles directly from the source ccMesh using selected cell indices.

Parameters
sourceMeshSource mesh (original data)
selectionDataSelection data (must be CELLS)
optionsExport options
Returns
Pointer to created ccMesh, or nullptr on failure
Note
Caller takes ownership of returned object if not added to scene

Definition at line 302 of file cvSelectionExporter.cpp.

References cvSelectionData::CELLS, ccDrawableObject::colorsShown(), cvSelectionExporter::ExportOptions::compressed, CVLog::Error(), cvSelectionData::fieldAssociation(), cvSelectionExporter::ExportOptions::filename, cvSelectionData::ids(), cvSelectionData::isEmpty(), ccGenericMesh::materialsShown(), cvSelectionExporter::ExportOptions::name, ccMesh::normalsShown(), ccMesh::partialClone(), CVLog::Print(), CVLog::PrintVerbose(), result, cvSelectionExporter::ExportOptions::saveToFile, ccDrawableObject::sfShown(), ccMesh::size(), CVLog::Warning(), and cvSelectionExporter::ExportOptions::writeAscii.

◆ exportNumbered()

bool cvSelectionExporter::exportNumbered ( vtkPolyData *  polyData,
const cvSelectionData selection,
const QString &  outputPath,
int  number 
)
static

Export selection with numbered naming.

Parameters
polyDataSource mesh data
selectionSelection data
outputPathFull output path with number placeholder (%1)
numberFile number
Returns
True on success

Definition at line 1145 of file cvSelectionExporter.cpp.

References exportToFile(), filename, format, and cvSelectionData::isEmpty().

◆ exportToFile()

bool cvSelectionExporter::exportToFile ( vtkPolyData *  polyData,
const cvSelectionData selectionData,
const QString &  filename,
bool  writeAscii = false,
bool  compressed = false 
)
static

Export selection to file (uses CV_io module)

Parameters
polyDataSource mesh data
selectionDataSelection data
filenameOutput filename (extension determines format)
writeAsciiUse ASCII format if supported
compressedUse compression if supported
Returns
True on success

Definition at line 403 of file cvSelectionExporter.cpp.

References cvSelectionData::CELLS, compressed, CVLog::Error(), extractSelection(), cvSelectionData::fieldAssociation(), filename, cvSelectionData::isEmpty(), and CVLog::Print().

Referenced by batchExportToFiles(), and exportNumbered().

◆ exportToMesh()

ccMesh * cvSelectionExporter::exportToMesh ( vtkPolyData *  polyData,
const cvSelectionData selectionData,
const ExportOptions options = ExportOptions() 
)
static

Export selected cells to ccMesh.

Parameters
polyDataSource mesh data
selectionDataSelection data (must be CELLS)
optionsExport options
Returns
Pointer to created ccMesh, or nullptr on failure
Note
Caller takes ownership of returned object if not added to scene

Definition at line 60 of file cvSelectionExporter.cpp.

References cvSelectionData::CELLS, cvSelectionExporter::ExportOptions::compressed, cvSelectionData::count(), CVLog::Error(), extractSelection(), cvSelectionData::fieldAssociation(), cvSelectionExporter::ExportOptions::filename, cvSelectionData::isEmpty(), cvSelectionExporter::ExportOptions::name, CVLog::Print(), cvSelectionExporter::ExportOptions::saveToFile, ccMesh::size(), CVLog::Warning(), and cvSelectionExporter::ExportOptions::writeAscii.

Referenced by batchExportToMeshes().

◆ exportToPointCloud()

ccPointCloud * cvSelectionExporter::exportToPointCloud ( vtkPolyData *  polyData,
const cvSelectionData selectionData,
const ExportOptions options = ExportOptions() 
)
static

◆ extractSelection()

vtkPolyData * cvSelectionExporter::extractSelection ( vtkPolyData *  polyData,
const cvSelectionData selectionData 
)
static

Extract selected geometry as new vtkPolyData.

Parameters
polyDataSource mesh data
selectionDataSelection data
Returns
Extracted vtkPolyData (caller must delete), or nullptr on failure

Definition at line 454 of file cvSelectionExporter.cpp.

References a, CVLog::Error(), cvSelectionData::fieldAssociation(), cvSelectionData::isEmpty(), cvSelectionData::POINTS, CVLog::PrintVerbose(), result, cvSelectionData::vtkArray(), and CVLog::Warning().

Referenced by exportToFile(), exportToMesh(), and exportToPointCloud().

◆ saveObjectToFileWithDialog()

bool cvSelectionExporter::saveObjectToFileWithDialog ( ccHObject object,
bool  isMesh,
QWidget *  parent = nullptr 
)
static

Save a ccHObject to file with file dialog Uses QFileDialog to let user choose filename and format Remembers last used path and filter using QSettings.

Parameters
objectObject to save
isMeshTrue if object is a mesh, false if point cloud
parentParent widget for dialog (can be nullptr)
Returns
True if save succeeded, false if cancelled or failed

Definition at line 844 of file cvSelectionExporter.cpp.

References FileIOFilter::SaveParameters::alwaysDisplaySaveDialog, CC_FERR_NO_ERROR, CVLog::Error(), FileIOFilter::GetFilters(), CV_TYPES::MESH, FileIOFilter::SaveParameters::parentWidget, CV_TYPES::POINT_CLOUD, CVLog::Print(), result, and FileIOFilter::SaveToFile().


The documentation for this class was generated from the following files: