Commit 89cb255e authored by Jan Möbius's avatar Jan Möbius

More cleanup

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@15722 383ad7c9-94d9-4d36-a494-682f7c89f535
parent bcda6b71
This diff is collapsed.
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen *
* www.openflipper.org *
* *
*--------------------------------------------------------------------------- *
* This file is part of OpenFlipper. *
* *
* OpenFlipper is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version with the *
* following exceptions: *
* *
* If other files instantiate templates or use macros *
* or inline functions from this file, or you compile this file and *
* link it with other files to produce an executable, this file does *
* not by itself cause the resulting executable to be covered by the *
* GNU Lesser General Public License. This exception does not however *
* invalidate any other reasons why the executable file might be *
* covered by the GNU Lesser General Public License. *
* *
* OpenFlipper is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU LesserGeneral Public *
* License along with OpenFlipper. If not, *
* see <http://www.gnu.org/licenses/>. *
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision$ *
* $LastChangedBy$ *
* $Date$ *
* *
\*===========================================================================*/
#include "MeshRepairPlugin.hh"
//-----------------------------------------------------------------------------
void
MeshRepairPlugin::detectTriangleAspect(int _objectId, float _aspect) {
// get the target mesh
TriMesh* mesh = 0;
PluginFunctions::getMesh(_objectId, mesh);
if (mesh) {
unsigned int count(0);
// Clear current face selection
MeshSelection::clearFaceSelection(mesh);
TriMesh::FaceIter f_it, f_end(mesh->faces_end());
TriMesh::FVIter fv_it;
TriMesh::FEIter fe_it;
for (f_it = mesh->faces_begin(); f_it != f_end; ++f_it) {
fv_it = mesh->fv_iter(f_it);
const TriMesh::Point& p0 = mesh->point(fv_it);
const TriMesh::Point& p1 = mesh->point(++fv_it);
const TriMesh::Point& p2 = mesh->point(++fv_it);
if (ACG::Geometry::aspectRatio(p0, p1, p2) > _aspect) {
mesh->status(f_it).set_selected(true);
++count;
}
}
if (count > 0) {
emit updatedObject(_objectId, UPDATE_SELECTION);
emit createBackup(_objectId, "Select triangles", UPDATE_SELECTION);
emit scriptInfo( "detectTriangleAspect(" + QString::number(_objectId) + ", " + QString::number(_aspect) + ")" );
}
emit log(
"Selected " + QString::number(count) + " triangles on object " + QString::number(_objectId)
+ " with aspect ratio greater than " + QString::number(_aspect) + ".");
} else {
emit log("Cannot detect skinny triangles on non-trimesh " + QString::number(_objectId) + ".");
}
}
//-----------------------------------------------------------------------------
void
MeshRepairPlugin::flipOrientation(int _objectId) {
// get the target mesh
TriMesh* triMesh = 0;
PolyMesh* polyMesh = 0;
PluginFunctions::getMesh(_objectId,triMesh);
PluginFunctions::getMesh(_objectId,polyMesh);
if (triMesh)
flipOrientationSelected(triMesh);
else if (polyMesh)
flipOrientationSelected(polyMesh);
else
emit log( LOGERR,tr("Unsupported Object Type for normal flipping!") );
emit updatedObject(_objectId, UPDATE_ALL);
emit createBackup( _objectId, "Flipped Normals", UPDATE_ALL);
emit scriptInfo( "flipOrientation(" + QString::number(_objectId) + ")" );
}
//-----------------------------------------------------------------------------
......@@ -489,7 +489,7 @@ There is no automatic algorithm to fix these foldovers here. So you will have to
<item>
<widget class="QPushButton" name="triangleAspectButton">
<property name="toolTip">
<string>Selects all triangles with an aspect ratio greater than the given ratio. If this ratio is very large, only very skinny triangles will be selected.</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Selects all triangles with an aspect ratio greater than the given one. If this ratio is very large, only very skinny triangles will be selected.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Select triangles</string>
......@@ -538,7 +538,7 @@ There is no automatic algorithm to fix these foldovers here. So you will have to
<item>
<widget class="QPushButton" name="flipOrientation">
<property name="toolTip">
<string>Flip the normals of all selected faces on the target meshes. This can be used to manually fix foldovers detected in &quot;Edge operations&quot;.</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Flip the normals of all selected faces on the target meshes by reversing the vertex order. This can be used to manually fix foldovers detected in &amp;quot;Edge operations&amp;quot;.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="statusTip">
<string>Flip the normals of all target meshes</string>
......
This diff is collapsed.
......@@ -179,26 +179,57 @@ private slots:
public slots:
// ==================================================
// Vertex operations
// ==================================================
/** \brief Detect valence 3 vertices with faces that lie in the plane of their adjacent triangles
*
*/
void detectFlatValence3Vertices(int _objectId, double _angle);
/// Remove all selected valence 3 vertices
void removeSelectedVal3Vertices(int _objectId);
/// Removes all selected edges
// ==================================================
// Edge operations
// ==================================================
/** \brief Selects all edges of an object which are shorter than the given length
*
* @param _objectId Id of the object
* @param _length maximal edge length to select
*/
void selectEdgesShorterThan(int _objectId,double _length);
/** \brief Selects all edges of an object which are larger than the given length
*
* @param _objectId Id of the object
* @param _length Minimal edge length to select
*/
void selectEdgesLongerThan(int _objectId,double _length);
/** \brief Removes all selected edges
*
* @param _objectId Id of the object
*/
void removeSelectedEdges(int _objectId);
/// Detect/Remove edges where neighboring faces form angle > _angle degrees
/** \brief Detect/Remove edges where neighboring faces form angle > _angle degrees
*
* @param _objectId Id of the object
* @param _angle minimal angle to detect
* @param _remove Detect them or also remove them?
*/
void detectSkinnyTriangleByAngle(int _objectId, double _angle, bool _remove);
/// Detect folded-over configurations
/** \brief Detect folded-over configurations by the dihedral angle
*
* @param _objectId Id of the object
* @param _angle Minimal dihedral angle that will be selected
*/
void detectFoldover(int _objectId, float _angle);
/// Selects all edges of an object which are shorter than the given length
void selectEdgesShorterThan(int _objectId,double _length);
/// Selects all edges of an object which are larger than the given length
void selectEdgesLongerThan(int _objectId,double _length);
/// Detect valence 3 vertices with faces that lie in the plane of their adjacent triangles
void detectFlatValence3Vertices(int _objectId, double _angle);
// ==================================================
// Face operations
......
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen *
* www.openflipper.org *
* *
*--------------------------------------------------------------------------- *
* This file is part of OpenFlipper. *
* *
* OpenFlipper is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version with the *
* following exceptions: *
* *
* If other files instantiate templates or use macros *
* or inline functions from this file, or you compile this file and *
* link it with other files to produce an executable, this file does *
* not by itself cause the resulting executable to be covered by the *
* GNU Lesser General Public License. This exception does not however *
* invalidate any other reasons why the executable file might be *
* covered by the GNU Lesser General Public License. *
* *
* OpenFlipper is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU LesserGeneral Public *
* License along with OpenFlipper. If not, *
* see <http://www.gnu.org/licenses/>. *
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision$ *
* $LastChangedBy$ *
* $Date$ *
* *
\*===========================================================================*/
#include "MeshRepairPlugin.hh"
//-----------------------------------------------------------------------------
void MeshRepairPlugin::detectFlatValence3Vertices(int _objectId, double _angle) {
unsigned int count(0);
// get the target mesh
TriMesh* mesh = 0;
PluginFunctions::getMesh(_objectId,mesh);
if ( mesh ) {
// Clear current triangle selection
MeshSelection::clearVertexSelection(mesh);
TriMesh::VertexIter v_it, v_end(mesh->vertices_end());
TriMesh::VVIter vv_it;
TriMesh::VFIter vf_it;
TriMesh::FaceHandle fh;
std::vector<TriMesh::VertexHandle> vh(3);
TriMesh::Scalar cosangle(cos(_angle/180.0*M_PI));
for (v_it=mesh->vertices_begin(); v_it!=v_end; ++v_it)
{
if (!mesh->status(v_it).deleted() && !mesh->is_boundary(v_it) && mesh->valence(v_it) == 3)
{
vf_it = mesh->vf_iter(v_it);
const TriMesh::Normal& n0 = mesh->normal(vf_it);
const TriMesh::Normal& n1 = mesh->normal(++vf_it);
const TriMesh::Normal& n2 = mesh->normal(++vf_it);
if ( (n0|n1) > cosangle &&
(n0|n2) > cosangle &&
(n1|n2) > cosangle )
{
mesh->status(v_it).set_selected(true);
++count;
}
}
}
}
else {
emit log(LOGERR, "Cannot detect flat triangles on non-trimesh " + QString::number(_objectId) + ".");
}
if (count > 0) {
emit updatedObject(_objectId, UPDATE_SELECTION);
emit createBackup(_objectId, "Select vertices", UPDATE_SELECTION);
}
emit log (LOGINFO,"Selected " + QString::number(count) + " vertices on object " + QString::number(_objectId) + " with face angle difference smaller than " + QString::number(_angle) + ".");
emit scriptInfo( "detectFlatValence3Vertices(" + QString::number(_objectId) + ", " + QString::number(_angle) + ")" );
}
//-----------------------------------------------------------------------------
void MeshRepairPlugin::removeSelectedVal3Vertices(int _objectId) {
unsigned int count = 0;
// get the target mesh
TriMesh* mesh = 0;
PluginFunctions::getMesh(_objectId, mesh);
if (mesh) {
TriMesh::VertexIter v_it, v_end(mesh->vertices_end());
TriMesh::VVIter vv_it;
TriMesh::VFIter vf_it;
int i;
std::vector<TriMesh::VertexHandle> vh(3);
for (v_it = mesh->vertices_begin(); v_it != v_end; ++v_it) {
vf_it = mesh->vf_iter(v_it);
if ((mesh->status(v_it).selected()) && !mesh->status(v_it).feature() && mesh->valence(v_it) == 3) {
for (i = 0, vv_it = mesh->vv_iter(v_it); vv_it; ++vv_it, ++i)
vh[2 - i] = vv_it.handle();
mesh->delete_vertex(v_it, false);
mesh->add_face(vh);
++count;
}
}
if (count > 0)
mesh->garbage_collection();
}
if (count > 0) {
emit updatedObject(_objectId, UPDATE_ALL);
emit createBackup(_objectId, "Delete/merge selected vertices", UPDATE_ALL);
}
emit log("Deleted " + QString::number(count) + " vertices on object " + QString::number(_objectId) + ".");
}
//-----------------------------------------------------------------------------
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