44 #define MESHREPAIRPLUGINT_CC 46 #include "MeshRepairPlugin.hh" 50 template<
typename MeshT>
55 std::vector< unsigned int > valence;
56 std::vector< typename MeshT::VertexHandle > vhandles;
60 bool selected =
false;
63 for (
typename MeshT::FaceIter f_it = _mesh.faces_begin(); f_it != _mesh.faces_end() ; ++f_it)
64 if ( _mesh.status(*f_it).selected() ) {
74 for (
typename MeshT::VertexIter v_it = _mesh.vertices_begin(); v_it != _mesh.vertices_end(); ++v_it) {
78 for (
typename MeshT::VertexFaceIter vf_it = _mesh.vf_iter(*v_it); !tagged && vf_it.is_valid(); ++vf_it)
79 if (_mesh.status(*vf_it).selected())
82 _mesh.status(*v_it).set_tagged(tagged);
87 _mesh.add_property(vmap);
90 for (
typename MeshT::VertexIter v_it = _mesh.vertices_begin(); v_it != _mesh.vertices_end(); ++v_it) {
92 typename MeshT::VertexHandle vh = *v_it;
94 if (_mesh.status(*v_it).tagged() )
95 for (
typename MeshT::VertexFaceIter vf_it = _mesh.vf_iter(*v_it); vf_it.is_valid(); ++vf_it)
97 if (!_mesh.status(*vf_it).tagged()) {
99 typename MeshT::Point tmpPoint = _mesh.point(*v_it);
102 vh = _mesh.add_vertex( tmpPoint );
105 _mesh.status(vh).set_tagged(
true);
108 _mesh.status(*v_it).set_tagged(
false);
112 _mesh.property(vmap, *v_it) = vh;
116 for (
typename MeshT::FaceIter f_it = _mesh.faces_begin(); f_it != _mesh.faces_end(); ++f_it) {
118 if (_mesh.status(*f_it).selected()) {
121 typename MeshT::FaceVertexIter fv_it = _mesh.fv_iter(*f_it);
123 valence.push_back(_mesh.valence(*f_it));
124 while (fv_it.is_valid()) {
125 vhandles.push_back(*fv_it);
130 _mesh.delete_face(*f_it,
false);
137 for (std::size_t i = 0; i < valence.size(); i++) {
139 std::vector<typename MeshT::VertexHandle> faceVertices;
144 for (
unsigned int j = 1; j <= valence[i]; ++j)
145 faceVertices.push_back(_mesh.property(vmap,vhandles[pos - j]) );
147 _mesh.add_face(faceVertices);
150 _mesh.remove_property(vmap);
154 std::vector < typename MeshT::Point > points;
157 points.reserve(_mesh.n_vertices() );
158 for (
typename MeshT::VertexIter v_it = _mesh.vertices_begin(); v_it != _mesh.vertices_end(); ++v_it)
159 points.push_back(_mesh.point(*v_it));
162 const unsigned int n_VerticesPerFace = _mesh.is_trimesh() ? 3 : 4;
165 std::vector< typename MeshT::VertexHandle > vhandles;
166 vhandles.reserve( _mesh.n_faces() * n_VerticesPerFace);
167 for (
typename MeshT::FaceIter f_it = _mesh.faces_begin(); f_it != _mesh.faces_end(); ++f_it) {
169 valence.push_back( _mesh.valence(*f_it) );
171 for (
typename MeshT::FaceVertexIter fv_it = _mesh.fv_iter(*f_it); fv_it.is_valid(); ++fv_it)
172 vhandles.push_back(*fv_it);
179 for (
unsigned int i = 0; i < points.size(); ++i)
180 _mesh.add_vertex(points[i]);
185 for (std::size_t i = 0; i < valence.size(); i++) {
187 std::vector<typename MeshT::VertexHandle> faceVertices;
192 for (
unsigned int j = 1; j <= valence[i]; ++j)
193 faceVertices.push_back(vhandles[pos - j]);
195 _mesh.add_face(faceVertices);
201 _mesh.garbage_collection();
202 _mesh.update_normals();
void flipOrientation(int _objectId)
Flips the normals of all selected faces by changing the vertex order.