43 #include "VolumeMeshSelectionPlugin.hh" 61 PrimitiveType _primitiveType,
bool _deselection) {
69 VertexIter v_it(_mesh->vertices_begin()), v_end(_mesh->vertices_end());
70 for (; v_it != v_end; ++v_it)
71 status[*v_it].set_tagged(
false);
74 for (v_it = _mesh->vertices_begin(); v_it != v_end; ++v_it) {
76 proj = _state.
project(_mesh->vertex(*v_it));
78 if (_region->contains(QPoint((
int)proj[0], _state.
context_height()- (int)proj[1]))) {
80 status[*v_it].set_tagged(
true);
83 status[*v_it].set_selected(!_deselection);
89 EdgeIter e_it(_mesh->edges_begin()), e_end(_mesh->edges_end());
91 for (; e_it != e_end; ++e_it)
93 VertexHandle v1 = _mesh->halfedge(_mesh->halfedge_handle(*e_it, 0)).to_vertex();
94 VertexHandle v2 = _mesh->halfedge(_mesh->halfedge_handle(*e_it, 1)).to_vertex();
97 if (status[v1].tagged() && status[v2].tagged()) {
99 status[*e_it].set_selected(!_deselection);
105 FaceIter f_it(_mesh->faces_begin()), f_end(_mesh->faces_end());
107 for (; f_it != f_end; ++f_it) {
108 const std::vector<HalfEdgeHandle>& halfedges = _mesh->face(*f_it).halfedges();
109 bool all_fv_tagged =
true;
111 for (std::size_t i = 0; i < halfedges.size(); ++i) {
112 VertexHandle v = _mesh->halfedge(halfedges[i]).to_vertex();
113 all_fv_tagged &= status[v].tagged();
119 status[*f_it].set_selected(!_deselection);
125 CellIter c_it(_mesh->cells_begin()), c_end(_mesh->cells_end());
127 for (; c_it != c_end; ++c_it) {
128 bool all_cv_tagged =
true;
129 for (
CellVertexIter cv_it(_mesh->cv_iter(*c_it)); cv_it.valid(); ++cv_it) {
130 all_cv_tagged &= status[*cv_it].tagged();
135 status[*c_it].set_selected(!_deselection);
153 template<
class MeshT>
155 PrimitiveType _primitiveTypes,
bool _deselection)
159 FaceHandle hitFace(_fh);
161 if (!_mesh->is_boundary(hitFace))
166 if (!_mesh->is_boundary(hitHalfFace))
167 hitHalfFace = _mesh->halfface_handle(hitFace, 1);
172 HalfFaceIter hf_it(_mesh->halffaces_begin()), hf_end(_mesh->halffaces_end());
173 for (; hf_it != hf_end; ++hf_it)
175 status[*hf_it].set_tagged(
false);
178 status[hitHalfFace].set_tagged(
true);
180 std::stack<HalfFaceHandle> hf_handles;
181 hf_handles.push(hitHalfFace);
184 typename MeshT::PointT n1 = normals[hitHalfFace];
185 double maxAngle = _maxAngle / 180.0 * M_PI;
189 while (!hf_handles.empty())
196 if (status[*bhfhf_it].tagged())
199 typename MeshT::PointT n2 = normals[*bhfhf_it];
201 double angle = std::acos(n1 | n2);
203 if (angle <= maxAngle) {
204 status[*bhfhf_it].set_tagged(
true);
205 hf_handles.push(*bhfhf_it);
211 for (hf_it = _mesh->halffaces_begin(); hf_it != hf_end; ++hf_it)
213 if (status[*hf_it].tagged())
215 FaceHandle fh = _mesh->face_handle(*hf_it);
219 status[*hfv_it].set_selected(!_deselection);
223 std::vector<HalfEdgeHandle>
const& halfedges = _mesh->face(fh).halfedges();
225 for (std::size_t i = 0; i < halfedges.size(); ++i)
226 status[_mesh->edge_handle(halfedges[i])].set_selected(!_deselection);
230 status[fh].set_selected(!_deselection);
Vec3d project(const Vec3d &_point) const
project point in world coordinates to window coordinates
bool volumeSelection(MeshT *_mesh, ACG::GLState &_state, QRegion *_region, PrimitiveType _primitiveTypes, bool _deselection)
Surface volume selection tool.
void floodFillSelection(MeshT *_mesh, uint _fh, double _maxAngle, PrimitiveType _primitiveTypes, bool _deselection)
Select all entities that are connected (and do not exceed the maximum dihedral angle) ...
PrimitiveType faceType_
Handle to selection environment.
PrimitiveType cellType_
Handle to selection environment.
PrimitiveType edgeType_
Handle to selection environment.
PrimitiveType vertexType_
Primitive type handles:
int context_height() const
get gl context height