mirror of https://github.com/CGAL/cgal
Add a selection item for edges marked in the om file
This commit is contained in:
parent
4832f06ae4
commit
496019ae4e
|
|
@ -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.")
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
@ -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;
|
||||
|
|
@ -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(...){}
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
@ -59,4 +70,4 @@ bool read_OM(std::string fname, SM& sm, VSelectionPM vspm, EFeaturePM efpm)
|
|||
} // namespace IO
|
||||
} // namespace CGAL
|
||||
|
||||
|
||||
#endif // CGAL_IO_OM
|
||||
Loading…
Reference in New Issue