@@ -241,8 +241,17 @@ ShapeWorksStudioApp::ShapeWorksStudioApp() {
241241 connect (ui_->action_export_all_subjects_particle_scalars , &QAction::triggered, this ,
242242 &ShapeWorksStudioApp::action_export_all_subjects_particle_scalars_triggered);
243243
244- connect (ui_->action_export_current_mesh , &QAction::triggered, this ,
245- &ShapeWorksStudioApp::action_export_current_mesh_triggered);
244+ connect (ui_->action_export_current_mesh , &QAction::triggered, this , [&]() {
245+ // get the first index of the visualizer (top left lightbox item)
246+ int index = visualizer_->get_lightbox ()->get_start_shape ();
247+ ShapeWorksStudioApp::action_export_current_mesh_triggered (index);
248+ });
249+
250+ connect (ui_->action_export_current_mesh_clipped , &QAction::triggered, this , [&]() {
251+ // get the first index of the visualizer (top left lightbox item)
252+ int index = visualizer_->get_lightbox ()->get_start_shape ();
253+ ShapeWorksStudioApp::action_export_current_mesh_triggered (index, true );
254+ });
246255
247256 connect (ui_->save_as_swproj , &QAction::triggered, this , &ShapeWorksStudioApp::save_as_swproj_clicked);
248257 connect (ui_->save_as_xlsx , &QAction::triggered, this , &ShapeWorksStudioApp::save_as_xlsx_clicked);
@@ -951,10 +960,15 @@ void ShapeWorksStudioApp::handle_lightbox_right_click(int index) {
951960 QMenu* menu = new QMenu (nullptr );
952961 menu->setAttribute (Qt::WA_DeleteOnClose);
953962 QAction* export_mesh_action = menu->addAction (" Export Mesh" );
963+ QAction* export_clipped_mesh_action = nullptr ;
954964 QAction* mark_excluded_action = nullptr ;
955965 QAction* unmark_excluded_action = nullptr ;
956966 QAction* mark_fixed_action = nullptr ;
957967 QAction* unmark_fixed_action = nullptr ;
968+
969+ if (shape->has_constraints ()) {
970+ export_clipped_mesh_action = menu->addAction (" Export Clipped Mesh" );
971+ }
958972 if (shape->is_subject () && !shape->is_excluded ()) {
959973 mark_excluded_action = menu->addAction (" Mark as excluded" );
960974 }
@@ -971,7 +985,9 @@ void ShapeWorksStudioApp::handle_lightbox_right_click(int index) {
971985 menu->popup (QCursor::pos ());
972986 connect (menu, &QMenu::triggered, menu, [=](QAction* action) {
973987 if (action == export_mesh_action) {
974- action_export_current_mesh_triggered (index);
988+ action_export_current_mesh_triggered (index, false );
989+ } else if (action == export_clipped_mesh_action) {
990+ action_export_current_mesh_triggered (index, true );
975991 } else if (action == mark_excluded_action) {
976992 shape->get_subject ()->set_excluded (true );
977993 } else if (action == unmark_excluded_action) {
@@ -1617,19 +1633,20 @@ void ShapeWorksStudioApp::on_action_preferences_triggered() {
16171633}
16181634
16191635// ---------------------------------------------------------------------------
1620- void ShapeWorksStudioApp::action_export_current_mesh_triggered (int index) {
1636+ void ShapeWorksStudioApp::action_export_current_mesh_triggered (int index, bool clip_constraints ) {
16211637 bool single = StudioUtils::ask_multiple_domains_as_single (this , session_->get_project ());
16221638
1623- QString filename = ExportUtils::get_save_filename (this , tr (" Export Mesh" ), get_mesh_file_filter (), " .vtk" );
1639+ QString filename =
1640+ ExportUtils::get_save_filename (this , tr (" Export Mesh" ), ExportUtils::get_mesh_file_filter (), " .vtk" );
16241641 if (filename.isEmpty ()) {
16251642 return ;
16261643 }
16271644
16281645 if (single) {
1629- StudioUtils::write_mesh (visualizer_->get_current_mesh (index), filename);
1646+ StudioUtils::write_mesh (visualizer_->get_current_mesh (index, clip_constraints ), filename);
16301647 SW_MESSAGE (" Wrote: " + filename.toStdString ());
16311648 } else {
1632- auto meshes = visualizer_->get_current_meshes_transformed (index);
1649+ auto meshes = visualizer_->get_current_meshes_transformed (index, clip_constraints );
16331650 auto domain_names = session_->get_project ()->get_domain_names ();
16341651
16351652 if (meshes.empty ()) {
@@ -1756,7 +1773,7 @@ void ShapeWorksStudioApp::on_action_export_mesh_scalars_triggered() {
17561773 }
17571774
17581775 if (single) {
1759- auto poly_data = visualizer_->get_current_mesh (0 );
1776+ auto poly_data = visualizer_->get_current_mesh (0 , false );
17601777 write_scalars (poly_data, filename);
17611778 } else {
17621779 auto meshes = visualizer_->get_current_meshes_transformed (0 );
@@ -2092,11 +2109,6 @@ bool ShapeWorksStudioApp::write_particle_file(std::string filename, Eigen::Vecto
20922109 return true ;
20932110}
20942111
2095- // ---------------------------------------------------------------------------
2096- QString ShapeWorksStudioApp::get_mesh_file_filter () {
2097- return tr (" VTK files (*.vtk);;PLY files (*.ply);;VTP files (*.vtp);;OBJ files (*.obj);;STL files (*.stl)" );
2098- }
2099-
21002112// ---------------------------------------------------------------------------
21012113void ShapeWorksStudioApp::update_feature_map_selection (int index) {
21022114 QString feature_map = ui_->features ->itemText (index);
0 commit comments