improve point import and export
This commit is contained in:
@@ -55,7 +55,7 @@ void PointsAlgos::Load(PointKernel &points, const char *FileName)
|
||||
if (!File.isReadable())
|
||||
throw Base::FileException("File to load not existing or not readable", FileName);
|
||||
|
||||
if (File.extension() == "asc" ||File.extension() == "ASC")
|
||||
if (File.hasExtension("asc"))
|
||||
LoadAscii(points,FileName);
|
||||
else
|
||||
throw Base::RuntimeError("Unknown ending");
|
||||
|
||||
@@ -2,6 +2,7 @@ include_directories(
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${Boost_INCLUDE_DIRS}
|
||||
${COIN3D_INCLUDE_DIRS}
|
||||
${EIGEN3_INCLUDE_DIR}
|
||||
${PYTHON_INCLUDE_DIRS}
|
||||
${ZLIB_INCLUDE_DIR}
|
||||
${XercesC_INCLUDE_DIRS}
|
||||
|
||||
@@ -74,8 +74,8 @@ void CmdPointsImport::activated(int iMsg)
|
||||
Q_UNUSED(iMsg);
|
||||
|
||||
QString fn = Gui::FileDialog::getOpenFileName(Gui::getMainWindow(),
|
||||
QString::null, QString(), QString::fromLatin1("%1 (*.asc);;%2 (*.*)")
|
||||
.arg(QObject::tr("Ascii Points")).arg(QObject::tr("All Files")));
|
||||
QString::null, QString(), QString::fromLatin1("%1 (*.asc *.pcd *.ply);;%2 (*.*)")
|
||||
.arg(QObject::tr("Point formats")).arg(QObject::tr("All Files")));
|
||||
if (fn.isEmpty())
|
||||
return;
|
||||
|
||||
@@ -83,13 +83,11 @@ void CmdPointsImport::activated(int iMsg)
|
||||
QFileInfo fi;
|
||||
fi.setFile(fn);
|
||||
|
||||
Gui::Document* doc = getActiveGuiDocument();
|
||||
openCommand("Import points");
|
||||
QByteArray name = fi.baseName().toLatin1();
|
||||
Points::Feature* pts = static_cast<Points::Feature*>(getActiveGuiDocument()->getDocument()->
|
||||
addObject("Points::Feature", static_cast<const char*>(name)));
|
||||
Points::PointKernel* kernel = pts->Points.startEditing();
|
||||
kernel->load(static_cast<const char*>(fn.toLatin1()));
|
||||
pts->Points.finishEditing();
|
||||
addModule(Command::App, "Points");
|
||||
doCommand(Command::Doc, "Points.insert(\"%s\", \"%s\")",
|
||||
fn.toUtf8().data(), doc->getDocument()->getName());
|
||||
commitCommand();
|
||||
|
||||
updateActive();
|
||||
@@ -122,20 +120,18 @@ void CmdPointsExport::activated(int iMsg)
|
||||
{
|
||||
Q_UNUSED(iMsg);
|
||||
|
||||
addModule(Command::App, "Points");
|
||||
std::vector<App::DocumentObject*> points = getSelection().getObjectsOfType(Points::Feature::getClassTypeId());
|
||||
for (std::vector<App::DocumentObject*>::const_iterator it = points.begin(); it != points.end(); ++it) {
|
||||
QString fn = Gui::FileDialog::getSaveFileName(Gui::getMainWindow(),
|
||||
QString::null, QString(), QString::fromLatin1("%1 (*.asc);;%2 (*.*)")
|
||||
.arg(QObject::tr("Ascii Points")).arg(QObject::tr("All Files")));
|
||||
QString::null, QString(), QString::fromLatin1("%1 (*.asc *.pcd *.ply);;%2 (*.*)")
|
||||
.arg(QObject::tr("Point formats")).arg(QObject::tr("All Files")));
|
||||
if (fn.isEmpty())
|
||||
break;
|
||||
|
||||
if (!fn.isEmpty()) {
|
||||
QFileInfo fi;
|
||||
fi.setFile(fn);
|
||||
|
||||
Points::Feature* pts = static_cast<Points::Feature*>(*it);
|
||||
pts->Points.getValue().save(static_cast<const char*>(fn.toLatin1()));
|
||||
doCommand(Command::Doc, "Points.export([App.ActiveDocument.%s], \"%s\")",
|
||||
(*it)->getNameInDocument(), fn.toUtf8().data());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,10 +28,5 @@
|
||||
|
||||
|
||||
# Append the open handler
|
||||
FreeCAD.addImportType("Point formats (*.asc)","Points")
|
||||
FreeCAD.addImportType("PLY points (*.ply)","Points")
|
||||
FreeCAD.addImportType("PCD points (*.pcd)","Points")
|
||||
|
||||
FreeCAD.addExportType("Point formats (*.asc)","Points")
|
||||
FreeCAD.addExportType("PLY points (*.ply)","Points")
|
||||
FreeCAD.addExportType("PCD points (*.pcd)","Points")
|
||||
FreeCAD.addImportType("Point formats (*.asc *.pcd *.ply)","Points")
|
||||
FreeCAD.addExportType("Point formats (*.asc *.pcd *.ply)","Points")
|
||||
|
||||
Reference in New Issue
Block a user