50 #define MESHREPAIRPLUGINT_CC
52 #include "MeshRepairPlugin.hh"
56 template<
typename MeshT>
61 std::vector< unsigned int > valence;
62 std::vector< typename MeshT::VertexHandle > vhandles;
66 bool selected =
false;
69 for (
typename MeshT::FaceIter f_it = _mesh.faces_begin(); f_it != _mesh.faces_end() ; ++f_it)
70 if ( _mesh.status(*f_it).selected() ) {
80 for (
typename MeshT::VertexIter v_it = _mesh.vertices_begin(); v_it != _mesh.vertices_end(); ++v_it) {
84 for (
typename MeshT::VertexFaceIter vf_it = _mesh.vf_iter(*v_it); !tagged && vf_it.is_valid(); ++vf_it)
85 if (_mesh.status(*vf_it).selected())
88 _mesh.status(*v_it).set_tagged(tagged);
93 _mesh.add_property(vmap);
96 for (
typename MeshT::VertexIter v_it = _mesh.vertices_begin(); v_it != _mesh.vertices_end(); ++v_it) {
98 typename MeshT::VertexHandle vh = *v_it;
100 if (_mesh.status(*v_it).tagged() )
101 for (
typename MeshT::VertexFaceIter vf_it = _mesh.vf_iter(*v_it); vf_it.is_valid(); ++vf_it)
103 if (!_mesh.status(*vf_it).tagged()) {
105 typename MeshT::Point tmpPoint = _mesh.point(*v_it);
108 vh = _mesh.add_vertex( tmpPoint );
111 _mesh.status(vh).set_tagged(
true);
114 _mesh.status(*v_it).set_tagged(
false);
118 _mesh.property(vmap, *v_it) = vh;
122 for (
typename MeshT::FaceIter f_it = _mesh.faces_begin(); f_it != _mesh.faces_end(); ++f_it) {
124 if (_mesh.status(*f_it).selected()) {
127 typename MeshT::FaceVertexIter fv_it = _mesh.fv_iter(*f_it);
129 valence.push_back(_mesh.valence(*f_it));
130 while (fv_it.is_valid()) {
131 vhandles.push_back(*fv_it);
136 _mesh.delete_face(*f_it,
false);
143 for (std::size_t i = 0; i < valence.size(); i++) {
145 std::vector<typename MeshT::VertexHandle> faceVertices;
150 for (
unsigned int j = 1; j <= valence[i]; ++j)
151 faceVertices.push_back(_mesh.property(vmap,vhandles[pos - j]) );
153 _mesh.add_face(faceVertices);
156 _mesh.remove_property(vmap);
160 std::vector < typename MeshT::Point > points;
163 points.reserve(_mesh.n_vertices() );
164 for (
typename MeshT::VertexIter v_it = _mesh.vertices_begin(); v_it != _mesh.vertices_end(); ++v_it)
165 points.push_back(_mesh.point(*v_it));
168 const unsigned int n_VerticesPerFace = _mesh.is_trimesh() ? 3 : 4;
171 std::vector< typename MeshT::VertexHandle > vhandles;
172 vhandles.reserve( _mesh.n_faces() * n_VerticesPerFace);
173 for (
typename MeshT::FaceIter f_it = _mesh.faces_begin(); f_it != _mesh.faces_end(); ++f_it) {
175 valence.push_back( _mesh.valence(*f_it) );
177 for (
typename MeshT::FaceVertexIter fv_it = _mesh.fv_iter(*f_it); fv_it.is_valid(); ++fv_it)
178 vhandles.push_back(*fv_it);
185 for (
unsigned int i = 0; i < points.size(); ++i)
186 _mesh.add_vertex(points[i]);
191 for (std::size_t i = 0; i < valence.size(); i++) {
193 std::vector<typename MeshT::VertexHandle> faceVertices;
198 for (
unsigned int j = 1; j <= valence[i]; ++j)
199 faceVertices.push_back(vhandles[pos - j]);
201 _mesh.add_face(faceVertices);
207 _mesh.garbage_collection();
208 _mesh.update_normals();
void flipOrientation(int _objectId)
Flips the normals of all selected faces by changing the vertex order.