Commit ab289c50 authored by David Bommes's avatar David Bommes

added dihedral angle threshold for edge selection

parent d5ce1c1e
......@@ -55,7 +55,8 @@
//==== Edge selections
//=========================================================
void MeshObjectSelectionPlugin::selectEdges( int objectId , IdList _edgeList ) {
void MeshObjectSelectionPlugin::selectEdges( int objectId , IdList _edgeList, const double _dihedral_angle_threshold ) {
update_dihedral_angle_threshold_from_ui();
if(_edgeList.empty() ) return;
......@@ -66,9 +67,9 @@ void MeshObjectSelectionPlugin::selectEdges( int objectId , IdList _edgeList ) {
}
if ( object->dataType() == DATA_TRIANGLE_MESH )
MeshSelection::selectEdges(PluginFunctions::triMesh(object), _edgeList);
MeshSelection::selectEdges(PluginFunctions::triMesh(object), _edgeList, _dihedral_angle_threshold);
else if ( object->dataType() == DATA_POLY_MESH )
MeshSelection::selectEdges(PluginFunctions::polyMesh(object), _edgeList);
MeshSelection::selectEdges(PluginFunctions::polyMesh(object), _edgeList, _dihedral_angle_threshold);
else {
emit log(LOGERR,tr("selectEdges : Unsupported object Type") );
return;
......
......@@ -120,7 +120,9 @@ conversionDialog_(0),
colorButtonSelection_(0),
colorButtonArea_(0),
colorButtonHandle_(0),
colorButtonFeature_(0){
colorButtonFeature_(0),
dihedral_angle_threshold_(0.0)
{
}
MeshObjectSelectionPlugin::~MeshObjectSelectionPlugin() {
......@@ -1915,7 +1917,7 @@ void MeshObjectSelectionPlugin::lassoSelect(QRegion& _region,
}
}
if (!_deselection)
selectEdges(bod->id(), elements);
selectEdges(bod->id(), elements, dihedral_angle_threshold_);
else
unselectEdges(bod->id(), elements);
alreadySelectedObjects.insert(list[i].first);
......@@ -1951,7 +1953,8 @@ void MeshObjectSelectionPlugin::lassoSelect(QRegion& _region,
if (!_deselection)
{
//on selection: select picked edges, convert to halfedge selection
selectEdges(bod->id(), elements);
update_dihedral_angle_threshold_from_ui();
selectEdges(bod->id(), elements, dihedral_angle_threshold_);
}
else
{
......@@ -2251,6 +2254,20 @@ void MeshObjectSelectionPlugin::addedEmptyObject(int _id )
}
void MeshObjectSelectionPlugin::set_dihedral_angle_threshold(const double _a)
{
dihedral_angle_threshold_ = _a;
}
double MeshObjectSelectionPlugin::get_dihedral_angle_threshold()
{
return dihedral_angle_threshold_;
}
void MeshObjectSelectionPlugin::update_dihedral_angle_threshold_from_ui()
{
dihedral_angle_threshold_ = OpenFlipperQSettings().value("SelectionBasePlugin/MinDihedralAngle", double()).toDouble();
}
#if QT_VERSION < 0x050000
Q_EXPORT_PLUGIN2(meshobjectselectionplugin, MeshObjectSelectionPlugin);
......
......@@ -358,10 +358,10 @@ public slots:
//==========================================
/// Select given Edges
void selectEdges(int objectId, IdList _vertexList);
void selectEdges(int objectId, IdList _edgeList, const double _dihedral_angle_threshold = 0.0);
/// Unselect given Edges
void unselectEdges(int objectId, IdList _vertexList);
void unselectEdges(int objectId, IdList _edgeList);
/// Select all Edges
void selectAllEdges(int objectId);
......@@ -481,6 +481,16 @@ public slots:
/// Convert the selection on all target objects
void conversion(const QString& _from, const QString& _to, bool _deselect);
public:
/// set dihedral angle threshold for edge selection
void set_dihedral_angle_threshold(const double _a);
/// get dihedral angle threshold for edge selection
double get_dihedral_angle_threshold();
private:
void update_dihedral_angle_threshold_from_ui();
/** @} */
//===========================================================================
......@@ -590,6 +600,8 @@ private:
ACG::Vec4f handleColor_;
ACG::Vec4f featureColor_;
double dihedral_angle_threshold_;
/** @} */
};
......
......@@ -315,16 +315,19 @@ void MeshObjectSelectionPlugin::paintSphereSelection(MeshT* _mesh
if( (_primitiveType & edgeType_) || (_primitiveType & halfedgeType_)) {
update_dihedral_angle_threshold_from_ui();
for( size_t i=0; i < edge_handles.size(); i++) {
if (_primitiveType & halfedgeType_) {
_mesh->status( _mesh->halfedge_handle(edge_handles[i],0) ).set_selected(sel) ;
_mesh->status( _mesh->halfedge_handle(edge_handles[i],1) ).set_selected(sel) ;
}
if (_primitiveType & halfedgeType_)
if(!_mesh->has_face_normals() || std::abs(_mesh->calc_dihedral_angle_fast(edge_handles[i])) >= dihedral_angle_threshold_)
{
_mesh->status( _mesh->halfedge_handle(edge_handles[i],0) ).set_selected(sel) ;
_mesh->status( _mesh->halfedge_handle(edge_handles[i],1) ).set_selected(sel) ;
}
if (_primitiveType & edgeType_)
_mesh->status(edge_handles[i]).set_selected(sel);
if(!_mesh->has_face_normals() || std::abs(_mesh->calc_dihedral_angle_fast(edge_handles[i])) >= dihedral_angle_threshold_)
_mesh->status(edge_handles[i]).set_selected(sel);
}
}
......@@ -410,6 +413,7 @@ bool MeshObjectSelectionPlugin::volumeSelection(MeshT* _mesh, int _objectId, ACG
}
if( (_primitiveType & edgeType_) || (_primitiveType & halfedgeType_) ) {
update_dihedral_angle_threshold_from_ui();
typename MeshT::EdgeIter e_it, e_end(_mesh->edges_end());
for(e_it=_mesh->edges_begin(); e_it!=e_end; ++e_it) {
......@@ -417,13 +421,15 @@ bool MeshObjectSelectionPlugin::volumeSelection(MeshT* _mesh, int _objectId, ACG
_mesh->status(_mesh->to_vertex_handle(_mesh->halfedge_handle(*e_it, 1))).tagged()) {
if(_primitiveType & edgeType_)
_mesh->status(*e_it).set_selected(!_deselection);
if(!_mesh->has_face_normals() || std::abs(_mesh->calc_dihedral_angle_fast(*e_it)) >= dihedral_angle_threshold_)
_mesh->status(*e_it).set_selected(!_deselection);
if(_primitiveType & halfedgeType_) {
if(_primitiveType & halfedgeType_)
if(!_mesh->has_face_normals() || std::abs(_mesh->calc_dihedral_angle_fast(*e_it)) >= dihedral_angle_threshold_)
{
_mesh->status(_mesh->halfedge_handle(*e_it,0)).set_selected(!_deselection);
_mesh->status(_mesh->halfedge_handle(*e_it,1)).set_selected(!_deselection);
}
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment