11 #ifndef MESH_PROCESS_SELECTION_HPP
12 #define MESH_PROCESS_SELECTION_HPP
30 setName(
"Mesh/Selection/Select All");
31 setDesc(
"Select all vertices of the current mesh");
36 if(!checkState().mesh(MESH_NON_EMPTY | MESH_SHOW_MESH))
38 return run(currentMesh());
55 setName(
"Mesh/Selection/Select Bad Normals");
56 setDesc(
"Select all vertices of the current mesh with normals that cannot be calculated");
61 if(!checkState().mesh(MESH_NON_EMPTY | MESH_SHOW_MESH))
63 return run(currentMesh());
80 setName(
"Mesh/Selection/Unselect");
81 setDesc(
"Unselect the vertices of the current mesh");
86 if(!checkState().mesh(MESH_NON_EMPTY | MESH_SHOW_MESH))
88 return run(currentMesh());
105 setName(
"Mesh/Selection/Invert Selection");
106 setDesc(
"Invert the selection of the current mesh.");
111 if(!checkState().mesh(MESH_NON_EMPTY | MESH_SHOW_MESH))
113 return run(currentMesh());
130 setName(
"Mesh/Selection/Select Unlabeled");
131 setDesc(
"Add to or replace the selection with the unlabeled vertices.");
133 addParm(
"Replace selection",
"Replace selection",
"No",booleanChoice());
138 if(!checkState().mesh(MESH_NON_EMPTY | MESH_SHOW_MESH))
141 return run(currentMesh(), replace);
144 bool run(
Mesh* m,
bool replace);
158 setName(
"Mesh/Selection/Select Labeled");
159 setDesc(
"Add to or replace the selection with the labeled vertices.");
161 addParm(
"Replace selection",
"Replace selection",
"No",booleanChoice());
166 if(!checkState().mesh(MESH_NON_EMPTY | MESH_SHOW_MESH))
169 return run(currentMesh(), replace);
172 bool run(
Mesh* m,
bool replace);
184 setName(
"Mesh/Selection/Select Labels");
185 setDesc(
"Add to or replace the selection with the labeled vertices.");
187 addParm(
"Labels",
"List of labels to select, 0 for current",
"0");
188 addParm(
"Replace Selection",
"Replace selection",
"No", booleanChoice());
193 if(!checkState().mesh(MESH_NON_EMPTY | MESH_SHOW_MESH))
195 bool replaceSelection =
stringToBool(parm(
"Replace Selection"));
196 Mesh *mesh = currentMesh();
198 throw QString(
"%1::run No current mesh:");
201 for(
auto s : parm(
"Labels").split(QRegExp(
"[ ,;:]"))) {
205 int label = s.toInt();
208 labels.insert(label);
210 return run(mesh, labels, replaceSelection);
212 bool run(
Mesh* m,
const IntSet &labels,
bool replace =
false);
223 setName(
"Mesh/Selection/Select By Valence");
224 setDesc(
"Select vertices by Valence");
226 addParm(
"Begin Valence",
"",
"1");
227 addParm(
"End Valence",
"",
"5");
232 if(!checkState().mesh(MESH_NON_EMPTY | MESH_SHOW_MESH))
234 return run(currentMesh(), parm(
"Begin Valence").toInt(), parm(
"End Valence").toInt());
237 bool run(
Mesh* m,
int start,
int end);
251 setName(
"Mesh/Selection/Unselect Label");
252 setDesc(
"Remove the vertices of a given label (0 for current label) from the selection.");
254 addParm(
"Label (0 for current)",
"Label (0 for current)",
"0");
259 if(!checkState().mesh(MESH_NON_EMPTY | MESH_SHOW_MESH))
261 return run(currentMesh(), parm(
"Label (0 for current)").toInt());
264 bool run(
Mesh* m,
int label);
278 setName(
"Mesh/Selection/Select Clip Region");
279 setDesc(
"Add vertices in clip region to selection.");
284 if(!checkState().mesh(MESH_NON_EMPTY | MESH_SHOW_MESH))
286 return run(currentMesh());
304 setName(
"Mesh/Selection/Extend to Whole Cells");
305 setDesc(
"Extend Selection to Whole Cells");
310 if(!checkState().mesh(MESH_NON_EMPTY | MESH_SHOW_MESH))
312 return run(currentMesh());
330 setName(
"Mesh/Selection/Select Duplicate Cells");
331 setDesc(
"Select cells with duplicate labels.");
336 if(!checkState().mesh(MESH_NON_EMPTY | MESH_SHOW_MESH))
338 return run(currentMesh());
356 setName(
"Mesh/Selection/Extend by Connectivity");
357 setDesc(
"Extend the selection to connected regions");
358 setIcon(QIcon(
":/images/SelectConnected.png"));
363 if(!checkState().mesh(MESH_NON_EMPTY))
365 return run(currentMesh());
384 setName(
"Mesh/Selection/Extend Selection by Normal");
385 setDesc(
"Selects vertices according to how close their normal is compared to pre-selected reference vertices.");
386 setIcon(QIcon(
":/images/SelectConnected.png"));
388 addParm(
"Tolerance",
"Tolerance threshold of the scalar of the averaged normal of selected vertices and other vertices",
"0.01");
393 if(!checkState().mesh())
395 Mesh *m = currentMesh();
396 return run(m, parm(
"Tolerance").toDouble());
399 bool run(
Mesh *m,
double tolerance);
414 setName(
"Mesh/Selection/Select Shared Triangles");
415 setDesc(
"Select triangles shared by several cells");
416 setIcon(QIcon(
":/images/Triangle.png"));
421 if(!checkState().mesh(MESH_NON_EMPTY))
423 return run(currentMesh());
441 setName(
"Mesh/Selection/Area of Selected Triangles");
442 setDesc(
"Returns the area of all selected triangles. Either triangles with all 3 vertices selected or triangles with at least one selected vertex");
443 setIcon(QIcon(
":/images/Hex.png"));
445 addParm(
"Mode",
"Mode",
"Tris inside Vtxs", QStringList() <<
"Tris inside Vtxs" <<
"Tris neighboring Vtxs");
450 if(!checkState().mesh(MESH_NON_EMPTY))
452 Mesh* m = currentMesh();
453 return run(m, parm(
"Mode"));
456 bool run(
Mesh* m, QString mode);
471 setName(
"Mesh/Selection/Count Selected Cells");
472 setDesc(
"Counts how many cells are selected and prints information about selected labels in the console window");
473 setIcon(QIcon(
":/images/Hex.png"));
478 Mesh* m = currentMesh();
496 setName(
"Mesh/Selection/Extend Selection By Neighbors");
497 setDesc(
"Extend Selection By Neighbor Vertices");
498 setIcon(QIcon(
":/images/Hex.png"));
500 addParm(
"Shrink Selection",
"Shrink Selection instead of extending it",
"No",booleanChoice());
505 Mesh* m = currentMesh();
509 bool run(
Mesh* m,
bool shrink);
525 setName(
"Mesh/Selection/Select Special");
526 setDesc(
"Selects vertices of a particular type");
527 setIcon(QIcon(
":/images/LayerFiles.png"));
529 addParm(
"Inner Border",
"Inner Border",
"Yes",booleanChoice());
530 addParm(
"Outer Border",
"Outer Border",
"No",booleanChoice());
531 addParm(
"Junctions",
"Junctions",
"No",booleanChoice());
532 addParm(
"Cell Vtxs",
"Cell Vtxs",
"No",booleanChoice());
539 if(!checkState().mesh())
541 Mesh *m = currentMesh();
545 bool run(
Mesh *m,
bool borderIn,
bool borderOut,
bool junctions,
bool cells);
558 setName(
"Mesh/Selection/Select Short Walls");
559 setDesc(
"Selects cell walls shorter than a given threshold.");
560 setIcon(QIcon(
":/images/open.png"));
562 addParm(
"Junction Merging Threshold",
"Junction Merging Threshold",
"0.1");
563 addParm(
"Exclusive",
"never select two touching walls",
"Yes", booleanChoice());
568 Mesh* m = currentMesh();
569 return run(m, parm(
"Junction Merging Threshold").toDouble(),
stringToBool(parm(
"Exclusive")));
571 bool run(
Mesh* m,
double threshold,
bool exclusive);
584 setName(
"Mesh/Selection/Distance Selected Cells");
585 setDesc(
"Outputs the distance of selected cells on the console");
586 setIcon(QIcon(
":/images/open.png"));
592 Mesh* m = currentMesh();