43 #include "MeshRepairPlugin.hh" 51 emit scriptInfo(
"selectEdgesShorterThan(" + QString::number(_objectId) +
", " + QString::number(_length) +
")" );
59 emit scriptInfo(
"selectEdgesLongerThan(" + QString::number(_objectId) +
", " + QString::number(_length) +
")" );
73 TriMesh::EdgeIter e_it, e_end=triMesh->edges_end();
76 MeshSelection::clearEdgeSelection(triMesh);
79 for (e_it = triMesh->edges_begin(); e_it != e_end ; ++e_it) {
80 TriMesh::HalfedgeHandle he = triMesh->halfedge_handle( *e_it, 0 );
81 TriMesh::Point p1 = triMesh->point( triMesh->from_vertex_handle( he ) );
82 TriMesh::Point p2 = triMesh->point( triMesh->to_vertex_handle( he ) );
85 if ( (p1 - p2).norm() > _length)
86 triMesh->status(*e_it).set_selected(
true);
88 if ( (p1 - p2).norm() < _length)
89 triMesh->status(*e_it).set_selected(
true);
104 PolyMesh::EdgeIter e_it, e_end=polyMesh->edges_end();
107 MeshSelection::clearEdgeSelection(polyMesh);
110 for (e_it = polyMesh->edges_begin(); e_it != e_end ; ++e_it) {
111 PolyMesh::HalfedgeHandle he = polyMesh->halfedge_handle( *e_it, 0 );
112 PolyMesh::Point p1 = polyMesh->point( polyMesh->from_vertex_handle( he ) );
113 PolyMesh::Point p2 = polyMesh->point( polyMesh->to_vertex_handle( he ) );
116 if ( (p1 - p2).norm() > _length)
117 polyMesh->status(*e_it).set_selected(
true);
119 if ( (p1 - p2).norm() < _length)
120 polyMesh->status(*e_it).set_selected(
true);
130 emit log(
LOGERR,tr(
"Unsupported Object Type for edge selection") );
145 TriMesh::EdgeIter e_it, e_end = triMesh->edges_end();
147 for (e_it = triMesh->edges_begin(); e_it != e_end; ++e_it) {
149 if (!triMesh->status(*e_it).deleted() && triMesh->status(*e_it).selected()) {
151 const TriMesh::VHandle v0 = triMesh->to_vertex_handle(triMesh->halfedge_handle(*e_it, 0));
152 const TriMesh::VHandle v1 = triMesh->to_vertex_handle(triMesh->halfedge_handle(*e_it, 1));
154 const bool boundary0 = triMesh->is_boundary(v0);
155 const bool boundary1 = triMesh->is_boundary(v1);
157 const bool feature0 = triMesh->status(v0).feature();
158 const bool feature1 = triMesh->status(v1).feature();
159 const bool featureE = triMesh->status(*e_it).feature();
164 if ((!boundary1 || boundary0) && (!feature1 || (feature0 && featureE)) && triMesh->is_collapse_ok(
165 triMesh->halfedge_handle(*e_it, 0)))
166 triMesh->collapse(triMesh->halfedge_handle(*e_it, 0));
167 else if ((!boundary0 || boundary1) && (!feature0 || (feature1 && featureE)) && triMesh->is_collapse_ok(
168 triMesh->halfedge_handle(*e_it, 1)))
169 triMesh->collapse(triMesh->halfedge_handle(*e_it, 1));
173 triMesh->garbage_collection();
177 emit createBackup(_objectId,
"Removed selected Edges",
UPDATE_ALL);
178 emit scriptInfo(
"removeSelectedEdges(" + QString::number(_objectId) +
")");
183 emit log(
LOGERR, tr(
"Unsupported Object Type for edge removal"));
198 MeshSelection::clearEdgeSelection(triMesh);
200 double maxAngle = cos(_angle * M_PI / 180.0);
202 TriMesh::EdgeIter e_it, e_end = triMesh->edges_end();
204 for (e_it = triMesh->edges_begin(); e_it != e_end; ++e_it) {
207 if (!triMesh->status(*e_it).deleted() && !triMesh->status(*e_it).feature() && triMesh->is_flip_ok(*e_it)) {
210 for (
unsigned int h = 0; h < 2; ++h) {
211 TriMesh::HalfedgeHandle hh = triMesh->halfedge_handle(*e_it, h);
212 const TriMesh::Point& a = triMesh->point(triMesh->from_vertex_handle(hh));
213 const TriMesh::Point& b = triMesh->point(triMesh->to_vertex_handle(hh));
214 hh = triMesh->next_halfedge_handle(hh);
215 const TriMesh::Point& c = triMesh->point(triMesh->to_vertex_handle(hh));
217 angle = ((a - c).normalize() | (b - c).normalize());
219 if (angle < maxAngle) {
222 triMesh->status(*e_it).set_selected(
true);
226 triMesh->flip(*e_it);
234 emit createBackup(_objectId, tr(
"Removed cap edges"),
UPDATE_ALL);
237 emit createBackup(_objectId, tr(
"Selected cap edges"),
UPDATE_ALL);
240 "detectSkinnyTriangleByAngle(" + QString::number(_objectId) +
"," + QString::number(_angle) +
"," 246 emit log(
LOGERR, tr(
"Unsupported Object Type for Cap detection!"));
261 unsigned int count = 0;
263 if (trimesh_o != 0) {
271 MeshSelection::clearEdgeSelection(mesh);
273 TriMesh::EdgeIter e_it, e_end(mesh->edges_end());
274 TriMesh::FaceHandle fh;
277 for (e_it = mesh->edges_begin(); e_it != e_end; ++e_it) {
278 if (!mesh->is_boundary(*e_it)) {
279 a = (mesh->normal(mesh->face_handle(mesh->halfedge_handle(*e_it, 0))) | mesh->normal(
280 mesh->face_handle(mesh->halfedge_handle(*e_it, 1))));
283 mesh->status(mesh->edge_handle(mesh->halfedge_handle(*e_it, 0))). set_selected(
true);
289 }
else if (polymesh_o != 0) {
297 MeshSelection::clearEdgeSelection(mesh);
299 PolyMesh::EdgeIter e_it, e_end(mesh->edges_end());
300 PolyMesh::FaceHandle fh;
303 for (e_it = mesh->edges_begin(); e_it != e_end; ++e_it) {
304 if (!mesh->is_boundary(*e_it)) {
305 a = (mesh->normal(mesh->face_handle(mesh->halfedge_handle(*e_it, 0))) | mesh->normal(
306 mesh->face_handle(mesh->halfedge_handle(*e_it, 1))));
309 mesh->status(mesh->edge_handle(mesh->halfedge_handle(*e_it, 0))). set_selected(
true);
320 emit scriptInfo(
"detectFoldover(" + QString::number(_objectId) +
", " + QString::number(_angle) +
")");
323 "Selected " + QString::number(count) +
" fold-overs on object " + QString::number(_objectId)
324 +
" with angle greater than " + QString::number(_angle) +
".");
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
Kernel::Point Point
Coordinate type.
const UpdateType UPDATE_SELECTION(UpdateTypeSet(1)<< 4)
Selection updated.
Kernel::Scalar Scalar
Scalar type.
void detectSkinnyTriangleByAngle(int _objectId, double _angle, bool _remove)
Detect/Remove edges where neighboring faces form angle > _angle degrees.
MeshT * mesh()
return a pointer to the mesh
void detectFoldover(int _objectId, float _angle)
Detect folded-over configurations by the dihedral angle.
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.
Type for a MeshObject containing a triangle mesh.
Functions for selection on a mesh.
void selectEdgesLongerThan(int _objectId, double _length)
Selects all edges of an object which are larger than the given length.
void selectEdgesShorterThan(int _objectId, double _length)
Selects all edges of an object which are shorter than the given length.
void removeSelectedEdges(int _objectId)
Removes all selected edges.
void selectionEdgeLength(int _objectId, double _length, bool _larger)
select edges based on length
Type for a Meshobject containing a poly mesh.
void update_normals()
Compute normals for all primitives.