Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions register_selection_tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ void RegisterSelectionTools(ProMeshRegistry& reg, string baseGrp)
grp = baseGrp + "/Edges/Coordinate Based";
reg.add_function("SelectEdgeByCoordinate", &SelectElemByCoordinate<Edge>, grp, "",
"mesh # coordinate", TOOLTIP_SELECT_EDGE_BY_COORDINATE)
.add_function("SelectClosestEdge", &SelectClosestEdge, grp, "",
"mesh # coordinate", TOOLTIP_SELECT_CLOSEST_EDGE)
.add_function("SelectEdgeByCylindricalCoordinate", &SelectElemByCylindricalCoordinate<Edge>, grp, "",
"mesh # rho # phi # z", TOOLTIP_SELECT_EDGE_BY_CYL_COORDINATE)
.add_function("SelectEdgesInBox", &SelectElementsInBox<Edge>, grp, "",
Expand Down
25 changes: 25 additions & 0 deletions tools/selection_tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,31 @@ void SelectSubsetEdgesByDirection(
maxDeviationAngle, selectFlipped);
}

Edge* SelectClosestEdge(
Mesh* m,
const vector3& coord)
{
Grid& grid = m->grid();
Mesh::position_accessor_t& aaPos = m->position_accessor();

Edge* bestEdge = NULL;
number bestDist;

for(EdgeIterator eIter = grid.begin<Edge>(); eIter != grid.end<Edge>(); ++eIter){
number dist = DistancePointToLine(coord, aaPos[(*eIter)->vertex(0)], aaPos[(*eIter)->vertex(1)]);

if(bestEdge == NULL || dist < bestDist){
bestDist = dist;
bestEdge = *eIter;
}
}

if(bestEdge)
m->selector().select(bestEdge);

return bestEdge;
}

////////////////////////////////////////////////////////////////////////////////
// FACES
void SelectBoundaryFaces(Mesh* obj)
Expand Down
5 changes: 5 additions & 0 deletions tools/selection_tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
#define TOOLTIP_SELECT_VOLUMES_BY_TYPE "Selects all volumes of a given type."
#define TOOLTIP_SELECT_VERTEX_BY_COORDINATE "Selects a vertex given a coordinate."
#define TOOLTIP_SELECT_EDGE_BY_COORDINATE "Selects the edge whose center is closest to the specified coordinate."
#define TOOLTIP_SELECT_CLOSEST_EDGE "Selects the edge closest to the specified coordinate with respect to its perpendicular distance (or distance to the closest edge vertex resp., if the projection lies outside of the line segment)."
#define TOOLTIP_SELECT_FACE_BY_COORDINATE "Selects the face whose center is closest to the specified coordinate."
#define TOOLTIP_SELECT_VOLUME_BY_COORDINATE "Selects the volume whose center is closest to the specified coordinate."
#define TOOLTIP_SELECT_VERTEX_BY_CYL_COORDINATE "Selects a vertex given a cylindrical coordinate."
Expand Down Expand Up @@ -334,6 +335,10 @@ void SelectSubsetEdgesByDirection(
number maxDeviationAngle,
bool selectFlipped);

Edge* SelectClosestEdge(
Mesh* m,
const vector3& coord);

void SelectBoundaryFaces(Mesh* obj);

void SelectInnerFaces(Mesh* obj);
Expand Down