Skip to content

Commit

Permalink
Add a selection item for edges marked in the om file
Browse files Browse the repository at this point in the history
  • Loading branch information
afabri committed Aug 22, 2024
1 parent 4832f06 commit 496019a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Lab/demo/Lab/Plugins/IO/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ find_package(OpenMesh)
if(OpenMesh_FOUND)
include(UseOpenMesh)
cgal_lab_plugin(om_plugin OM_io_plugin KEYWORDS Viewer PMP)
target_link_libraries(om_plugin PUBLIC scene_surface_mesh_item scene_polygon_soup_item)
target_link_libraries(om_plugin PUBLIC scene_surface_mesh_item scene_polygon_soup_item scene_selection_item)
target_link_libraries(om_plugin PRIVATE ${OPENMESH_LIBRARIES})
else()
message(STATUS "NOTICE: the OM IO plugin needs OpenMesh libraries and will not be compiled.")
Expand Down
20 changes: 16 additions & 4 deletions Lab/demo/Lab/Plugins/IO/OM_io_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

#include <CGAL/Three/CGAL_Lab_io_plugin_interface.h>
#include <CGAL/Three/Three.h>
#include "Scene_polyhedron_selection_item.h"

#include <CGAL/IO/OM.h>
#include <CGAL/boost/graph/io.h>
#include <CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h>

#include <QColor>
#include <QString>
Expand Down Expand Up @@ -90,7 +90,8 @@ load(QFileInfo fileinfo, bool& ok, bool add_to_scene){
// Try building a surface_mesh
SMesh* SM = new SMesh();
if (CGAL::IO::read_OM((const char*)fileinfo.filePath().toUtf8(), *SM, sm_selected_pmap, sm_feature_pmap))
{/*
{
/*
std::cout << "vertex selection values:\n";
for(auto v : vertices(*SM)){
std::cout << std::boolalpha << get(sm_selected_pmap, v) << std::endl;
Expand All @@ -108,11 +109,22 @@ load(QFileInfo fileinfo, bool& ok, bool add_to_scene){
}
else{
Scene_surface_mesh_item* item = new Scene_surface_mesh_item(SM);

Scene_polyhedron_selection_item* selection_item = new Scene_polyhedron_selection_item(item, CGAL::Three::Three::mainWindow());
bool selected = false;
for(auto e : edges(*SM)){
if(get(sm_feature_pmap, e)){
selection_item->selected_edges.insert(e);
selected = true;
}
}
item->setName(fileinfo.completeBaseName());
ok = true;
if(add_to_scene)
if(add_to_scene){
CGAL::Three::Three::scene()->addItem(item);
return QList<Scene_item*>()<<item;
CGAL::Three::Three::scene()->addItem(selection_item);
}
return QList<Scene_item*>()<<item << selection_item;
}
}
catch(...){}
Expand Down
15 changes: 13 additions & 2 deletions Stream_support/include/CGAL/IO/OM.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
#pragma once
// Copyright (c) 2024 GeometryFactory
//
// This file is part of CGAL (www.cgal.org);
//
// $URL$
// $Id$
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author(s) : Andreas Fabri

#ifndef CGAL_IO_OM_H
#define CGAL_IO_OM_H

#include <OpenMesh/Core/IO/MeshIO.hh>
#include <OpenMesh/Core/Mesh/TriMesh_ArrayKernelT.hh>
Expand Down Expand Up @@ -59,4 +70,4 @@ bool read_OM(std::string fname, SM& sm, VSelectionPM vspm, EFeaturePM efpm)
} // namespace IO
} // namespace CGAL


#endif // CGAL_IO_OM

0 comments on commit 496019a

Please sign in to comment.