Skip to content

Commit

Permalink
Merge pull request #98 from untereiner/develop
Browse files Browse the repository at this point in the history
[export] ADD pointset export feature
  • Loading branch information
Lionel Untereiner authored Feb 24, 2020
2 parents 5c77908 + d2d39f2 commit 9fda0bc
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 7 deletions.
10 changes: 8 additions & 2 deletions schnapps/plugins/export/export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <schnapps/plugins/export/export.h>
#include <schnapps/plugins/export/export_dialog.h>
#include <schnapps/plugins/cmap_provider/cmap_provider.h>
#include <schnapps/plugins/cmap_provider/cmap0_handler.h>
#include <schnapps/plugins/cmap_provider/cmap2_handler.h>
#include <schnapps/plugins/cmap_provider/cmap3_handler.h>

Expand Down Expand Up @@ -62,7 +63,7 @@ bool Plugin_Export::enable()

export_dialog_ = new ExportDialog(schnapps_, this);

export_mesh_action_ = schnapps_->add_menu_action("File;Export Mesh", "export surface/volume mesh");
export_mesh_action_ = schnapps_->add_menu_action("File;Export Mesh", "export point set/surface/volume mesh");
connect(export_mesh_action_, SIGNAL(triggered()), this, SLOT(export_mesh_from_file_dialog()));

return true;
Expand All @@ -82,7 +83,12 @@ void Plugin_Export::export_mesh(Object* mhg, cgogn::io::ExportOptions export_par
{
if (mhg)
{
if (CMap2Handler* m2h = dynamic_cast<CMap2Handler*>(mhg))
if(CMap0Handler* m0h = dynamic_cast<CMap0Handler*>(mhg))
{
CMap0& cmap0 = *m0h->map();
cgogn::io::export_point_set(cmap0, export_params);
}
else if (CMap2Handler* m2h = dynamic_cast<CMap2Handler*>(mhg))
{
CMap2& cmap2 = *m2h->map();
cgogn::io::export_surface(cmap2, export_params);
Expand Down
2 changes: 1 addition & 1 deletion schnapps/plugins/export/export.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class PLUGIN_EXPORT_EXPORT Plugin_Export : public PluginProcessing
Q_INTERFACES(schnapps::Plugin)

public:

using CMap0Handler = plugin_cmap_provider::CMap0Handler;
using CMap2Handler = plugin_cmap_provider::CMap2Handler;
using CMap3Handler = plugin_cmap_provider::CMap3Handler;

Expand Down
49 changes: 46 additions & 3 deletions schnapps/plugins/export/export_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include <schnapps/core/schnapps.h>
#include <schnapps/plugins/cmap_provider/cmap_provider.h>
#include <schnapps/plugins/cmap_provider/cmap0_handler.h>
#include <schnapps/plugins/cmap_provider/cmap2_handler.h>
#include <schnapps/plugins/cmap_provider/cmap3_handler.h>

Expand Down Expand Up @@ -72,9 +73,17 @@ void ExportDialog::selected_map_changed(const QString& map_name)
list_vertexAttributes->clear();
list_cellAttributes->clear();


auto m0 = plugin_->map_provider()->cmap0(map_name);
auto m2 = plugin_->map_provider()->cmap2(map_name);
auto m3 = plugin_->map_provider()->cmap3(map_name);
if (m2)

if(m0)
{
selected_map_ = m0;
selected_map_changed(m0);
}
else if (m2)
{
selected_map_ = m2;
selected_map_changed(m2);
Expand All @@ -87,6 +96,22 @@ void ExportDialog::selected_map_changed(const QString& map_name)
}
}

void ExportDialog::selected_map_changed(const plugin_cmap_provider::CMap0Handler* h)
{
if (!h)
return;

const CMap0& m = *h->map();
const auto& vert_att_cont = m.attribute_container<CMap0::Vertex::ORBIT>();
for (const auto& att_name : vert_att_cont.names())
{
combo_positionSelection->addItem(QString::fromStdString(att_name));
QListWidgetItem* item = new QListWidgetItem(QString::fromStdString(att_name), list_vertexAttributes);
item->setCheckState(Qt::Unchecked);
}

}

void ExportDialog::selected_map_changed(const plugin_cmap_provider::CMap2Handler* h)
{
if (!h)
Expand Down Expand Up @@ -190,13 +215,31 @@ void ExportDialog::export_validated()
.binary(check_binary->isChecked())
.compress(check_compress->isChecked());

if (auto m0 = dynamic_cast<plugin_cmap_provider::CMap0Handler*>(selected_map_))
export_map(m0, export_params);
if (auto m2 = dynamic_cast<plugin_cmap_provider::CMap2Handler*>(selected_map_))
export_map(m2, export_params);
if (auto m3 = dynamic_cast<plugin_cmap_provider::CMap3Handler*>(selected_map_))
export_map(m3, export_params);
}
}

void ExportDialog::export_map(plugin_cmap_provider::CMap0Handler* h, cgogn::io::ExportOptions& opt)
{
if (!h)
return;

opt.position_attribute(CMap0::Vertex::ORBIT, combo_positionSelection->currentText().toStdString());
for (int32 i = 0; i < list_vertexAttributes->count(); ++i)
{
QListWidgetItem* item = list_vertexAttributes->item(i);
if (item->flags() & Qt::ItemIsEnabled)
opt.add_attribute(CMap0::Vertex::ORBIT, item->text().toStdString());
}

plugin_->export_mesh(h, opt);
}

void ExportDialog::export_map(plugin_cmap_provider::CMap2Handler* h, cgogn::io::ExportOptions& opt)
{
if (!h)
Expand Down Expand Up @@ -245,13 +288,13 @@ void ExportDialog::export_map(plugin_cmap_provider::CMap3Handler* h, cgogn::io::

void ExportDialog::map_added(Object* mhg)
{
if (mhg && (dynamic_cast<plugin_cmap_provider::CMap2Handler*>(mhg) || dynamic_cast<plugin_cmap_provider::CMap3Handler*>(mhg)))
if (mhg && (dynamic_cast<plugin_cmap_provider::CMap0Handler*>(mhg) || dynamic_cast<plugin_cmap_provider::CMap2Handler*>(mhg) || dynamic_cast<plugin_cmap_provider::CMap3Handler*>(mhg)))
combo_mapSelection->addItem(mhg->name());
}

void ExportDialog::map_removed(Object* mhg)
{
if (mhg && (dynamic_cast<plugin_cmap_provider::CMap2Handler*>(mhg) || dynamic_cast<plugin_cmap_provider::CMap3Handler*>(mhg)))
if (mhg && (dynamic_cast<plugin_cmap_provider::CMap0Handler*>(mhg) || dynamic_cast<plugin_cmap_provider::CMap2Handler*>(mhg) || dynamic_cast<plugin_cmap_provider::CMap3Handler*>(mhg)))
{
if (mhg == selected_map_)
selected_map_ = nullptr;
Expand Down
9 changes: 8 additions & 1 deletion schnapps/plugins/export/export_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ namespace schnapps
class SCHNApps;
class Object;

namespace plugin_cmap_provider
{
class Plugin_CMapProvider;
class CMap0Handler;
}

namespace plugin_cmap_provider
{
class Plugin_CMapProvider;
Expand Down Expand Up @@ -79,9 +85,10 @@ private slots:
void map_removed(Object*);

private:

void selected_map_changed(const plugin_cmap_provider::CMap0Handler* h);
void selected_map_changed(const plugin_cmap_provider::CMap2Handler* h);
void selected_map_changed(const plugin_cmap_provider::CMap3Handler* h);
void export_map(plugin_cmap_provider::CMap0Handler* h, cgogn::io::ExportOptions& opt);
void export_map(plugin_cmap_provider::CMap2Handler* h, cgogn::io::ExportOptions& opt);
void export_map(plugin_cmap_provider::CMap3Handler* h, cgogn::io::ExportOptions& opt);

Expand Down

0 comments on commit 9fda0bc

Please sign in to comment.