43#include "MeshRepairPlugin.hh"
51 emit scriptInfo(
"selectEdgesShorterThan(" + QString::number(_objectId) +
", " + QString::number(_length) +
")" );
59 emit scriptInfo(
"selectEdgesLongerThan(" + QString::number(_objectId) +
", " + QString::number(_length) +
")" );
74 MeshSelection::clearEdgeSelection(triMesh);
77 for (
auto e_it : triMesh->edges()) {
83 if ( (p1 - p2).norm() > _length)
84 triMesh->status(e_it).set_selected(
true);
86 if ( (p1 - p2).norm() < _length)
87 triMesh->status(e_it).set_selected(
true);
103 MeshSelection::clearEdgeSelection(polyMesh);
106 for (
auto e_it : polyMesh->edges()) {
112 if ( (p1 - p2).norm() > _length)
113 polyMesh->status(e_it).set_selected(
true);
115 if ( (p1 - p2).norm() < _length)
116 polyMesh->status(e_it).set_selected(
true);
126 emit log(
LOGERR,tr(
"Unsupported Object Type for edge selection") );
141 for (
auto e_it : triMesh->edges()) {
143 if (!triMesh->status(e_it).deleted() && triMesh->status(e_it).selected()) {
151 const bool feature0 = triMesh->status(v0).feature();
152 const bool feature1 = triMesh->status(v1).feature();
153 const bool featureE = triMesh->status(e_it).feature();
158 if ((!boundary1 || boundary0) && (!feature1 || (feature0 && featureE)) && triMesh->is_collapse_ok(
160 triMesh->collapse(e_it.h0());
161 else if ((!boundary0 || boundary1) && (!feature0 || (feature1 && featureE)) && triMesh->is_collapse_ok(
163 triMesh->collapse(e_it.h1());
167 triMesh->garbage_collection();
168 triMesh->update_normals();
171 emit createBackup(_objectId,
"Removed selected Edges",
UPDATE_ALL);
172 emit scriptInfo(
"removeSelectedEdges(" + QString::number(_objectId) +
")");
177 emit log(
LOGERR, tr(
"Unsupported Object Type for edge removal"));
192 MeshSelection::clearEdgeSelection(triMesh);
194 double maxAngle = cos(_angle * M_PI / 180.0);
197 for (
auto e_it : triMesh->edges()) {
200 if (!triMesh->status(e_it).deleted() && !triMesh->status(e_it).feature() && triMesh->is_flip_ok(e_it)) {
203 for (
unsigned int h = 0; h < 2; ++h) {
205 const TriMesh::Point& a = triMesh->point(triMesh->from_vertex_handle(hh));
206 const TriMesh::Point& b = triMesh->point(triMesh->to_vertex_handle(hh));
207 hh = triMesh->next_halfedge_handle(hh);
208 const TriMesh::Point& c = triMesh->point(triMesh->to_vertex_handle(hh));
210 const double angle = ((a - c).normalize() | (b - c).normalize());
212 if (angle < maxAngle) {
215 triMesh->status(e_it).set_selected(
true);
227 emit createBackup(_objectId, tr(
"Removed cap edges"),
UPDATE_ALL);
230 emit createBackup(_objectId, tr(
"Selected cap edges"),
UPDATE_ALL);
233 "detectSkinnyTriangleByAngle(" + QString::number(_objectId) +
"," + QString::number(_angle) +
","
234 + (_remove?
"TRUE":
"FALSE") +
")");
239 emit log(
LOGERR, tr(
"Unsupported Object Type for Cap detection!"));
254 unsigned int count = 0;
256 if (trimesh_o != 0) {
264 MeshSelection::clearEdgeSelection(mesh);
269 for (
auto e_it : mesh->edges()) {
270 if (!e_it.is_boundary()) {
271 a = (mesh->normal(e_it.h0().face()) | mesh->normal(
275 mesh->status(e_it.h0().edge()). set_selected(
true);
281 }
else if (polymesh_o != 0) {
289 MeshSelection::clearEdgeSelection(mesh);
294 for (
auto e_it : mesh->edges()) {
295 if (!e_it.is_boundary()) {
296 a = (mesh->normal(e_it.h0().face()) | mesh->normal(
300 mesh->status(e_it.h0().edge()). set_selected(
true);
311 emit scriptInfo(
"detectFoldover(" + QString::number(_objectId) +
", " + QString::number(_angle) +
")");
314 "Selected " + QString::number(count) +
" fold-overs on object " + QString::number(_objectId)
315 +
" with angle greater than " + QString::number(_angle) +
".");
Functions for selection on a mesh.
MeshT * mesh()
return a pointer to the mesh
void removeSelectedEdges(int _objectId)
Removes all selected edges.
void detectSkinnyTriangleByAngle(int _objectId, double _angle, bool _remove)
Detect/Remove edges where neighboring faces form angle > _angle degrees.
void selectEdgesLongerThan(int _objectId, double _length)
Selects all edges of an object which are larger than the given length.
void detectFoldover(int _objectId, float _angle)
Detect folded-over configurations by the dihedral angle.
void selectEdgesShorterThan(int _objectId, double _length)
Selects all edges of an object which are shorter than the given length.
void selectionEdgeLength(int _objectId, double _length, bool _larger)
select edges based on length
Kernel::Scalar Scalar
Scalar type.
Kernel::FaceHandle FaceHandle
Scalar type.
Kernel::HalfedgeHandle HalfedgeHandle
Scalar type.
Kernel::Point Point
Coordinate type.
bool is_boundary() const
Returns true iff the handle is boundary.
Type for a Meshobject containing a poly mesh.
Type for a MeshObject containing a triangle mesh.
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
const UpdateType UPDATE_SELECTION(UpdateTypeSet(16))
Selection updated.
bool getMesh(int _identifier, PolyMesh *&_mesh)
Get the Poly Mesh which has the given identifier.
bool getObject(const int _identifier, BaseObject *&_object)
Get the object which has the given identifier.
SmartVertexHandle from() const
Returns vertex at start of halfedge.
SmartVertexHandle to() const
Returns vertex pointed to by halfedge.
Smart version of VertexHandle contains a pointer to the corresponding mesh and allows easier access t...