50 #include "VolumeMeshSelectionPlugin.hh"
68 PrimitiveType _primitiveType,
bool _deselection) {
76 VertexIter v_it(_mesh->vertices_begin()), v_end(_mesh->vertices_end());
77 for (; v_it != v_end; ++v_it)
78 status[*v_it].set_tagged(
false);
81 for (v_it = _mesh->vertices_begin(); v_it != v_end; ++v_it) {
83 proj = _state.
project(_mesh->vertex(*v_it));
85 if (_region->contains(QPoint((
int)proj[0], _state.
context_height()- (int)proj[1]))) {
87 status[*v_it].set_tagged(
true);
90 status[*v_it].set_selected(!_deselection);
96 EdgeIter e_it(_mesh->edges_begin()), e_end(_mesh->edges_end());
98 for (; e_it != e_end; ++e_it)
100 VertexHandle v1 = _mesh->halfedge(_mesh->halfedge_handle(*e_it, 0)).to_vertex();
101 VertexHandle v2 = _mesh->halfedge(_mesh->halfedge_handle(*e_it, 1)).to_vertex();
104 if (status[v1].tagged() && status[v2].tagged()) {
106 status[*e_it].set_selected(!_deselection);
112 FaceIter f_it(_mesh->faces_begin()), f_end(_mesh->faces_end());
114 for (; f_it != f_end; ++f_it) {
115 const std::vector<HalfEdgeHandle>& halfedges = _mesh->face(*f_it).halfedges();
116 bool all_fv_tagged =
true;
118 for (std::size_t i = 0; i < halfedges.size(); ++i) {
119 VertexHandle v = _mesh->halfedge(halfedges[i]).to_vertex();
120 all_fv_tagged &= status[v].tagged();
126 status[*f_it].set_selected(!_deselection);
132 CellIter c_it(_mesh->cells_begin()), c_end(_mesh->cells_end());
134 for (; c_it != c_end; ++c_it) {
135 bool all_cv_tagged =
true;
136 for (
CellVertexIter cv_it(_mesh->cv_iter(*c_it)); cv_it.valid(); ++cv_it) {
137 all_cv_tagged &= status[*cv_it].tagged();
142 status[*c_it].set_selected(!_deselection);
160 template<
class MeshT>
162 PrimitiveType _primitiveTypes,
bool _deselection)
168 if (!_mesh->is_boundary(hitFace))
173 if (!_mesh->is_boundary(hitHalfFace))
174 hitHalfFace = _mesh->halfface_handle(hitFace, 1);
179 HalfFaceIter hf_it(_mesh->halffaces_begin()), hf_end(_mesh->halffaces_end());
180 for (; hf_it != hf_end; ++hf_it)
182 status[*hf_it].set_tagged(
false);
185 status[hitHalfFace].set_tagged(
true);
187 std::stack<HalfFaceHandle> hf_handles;
188 hf_handles.push(hitHalfFace);
191 typename MeshT::PointT n1 = normals[hitHalfFace];
192 double maxAngle = _maxAngle / 180.0 * M_PI;
196 while (!hf_handles.empty())
203 if (status[*bhfhf_it].tagged())
206 typename MeshT::PointT n2 = normals[*bhfhf_it];
208 double angle = std::acos(n1 | n2);
210 if (angle <= maxAngle) {
211 status[*bhfhf_it].set_tagged(
true);
212 hf_handles.push(*bhfhf_it);
218 for (hf_it = _mesh->halffaces_begin(); hf_it != hf_end; ++hf_it)
220 if (status[*hf_it].tagged())
226 status[*hfv_it].set_selected(!_deselection);
230 std::vector<HalfEdgeHandle>
const& halfedges = _mesh->face(fh).halfedges();
232 for (std::size_t i = 0; i < halfedges.size(); ++i)
233 status[_mesh->edge_handle(halfedges[i])].set_selected(!_deselection);
237 status[fh].set_selected(!_deselection);
int context_height() const
get gl context height
PrimitiveType edgeType_
Handle to selection environment.
PrimitiveType cellType_
Handle to selection environment.
PrimitiveType faceType_
Handle to selection environment.
bool volumeSelection(MeshT *_mesh, ACG::GLState &_state, QRegion *_region, PrimitiveType _primitiveTypes, bool _deselection)
Surface volume selection tool.
PrimitiveType vertexType_
Primitive type handles:
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) ...
Vec3d project(const Vec3d &_point) const
project point in world coordinates to window coordinates