Commit e3040403 authored by Jan Möbius's avatar Jan Möbius

OM 3 fixes

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@17216 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 97feebaf
......@@ -80,8 +80,8 @@ void BoundarySnappingT<MeshT>::snap(double _epsilon)
// collect all boundary vertices
for (typename MeshT::VertexIter v_iter = mesh_.vertices_begin(); v_iter != mesh_.vertices_end(); ++v_iter)
if (mesh_.is_boundary(v_iter) && mesh_.status(v_iter).selected())
v_boundary.push_back(v_iter);
if (mesh_.is_boundary(*v_iter) && mesh_.status(*v_iter).selected())
v_boundary.push_back(*v_iter);
//two maps
// vertexDistMap saves the vertex and his distances as pairs
......@@ -147,9 +147,9 @@ void BoundarySnappingT<MeshT>::snap(double _epsilon)
//if so, it is not usable
v_2 = iter->first;
for(typename MeshT::VertexFaceIter vf_iter = mesh_.vf_begin(v_1); vf_iter && v_2.is_valid(); ++vf_iter)
for (typename MeshT::FaceVertexIter fv_iter = mesh_.fv_begin(vf_iter.handle()); fv_iter && v_2.is_valid(); ++fv_iter)
if (fv_iter.handle() == v_2)
for(typename MeshT::VertexFaceIter vf_iter = mesh_.vf_begin(v_1); vf_iter.is_valid() && v_2.is_valid(); ++vf_iter)
for (typename MeshT::FaceVertexIter fv_iter = mesh_.fv_begin(*vf_iter); fv_iter.is_valid() && v_2.is_valid(); ++fv_iter)
if (*fv_iter == v_2)
v_2 = typename MeshT::VertexHandle();
validPair = v_2.is_valid() && !mesh_.status(v_2).deleted() && mesh_.is_boundary(v_2);
......@@ -176,9 +176,9 @@ void BoundarySnappingT<MeshT>::snap(double _epsilon)
vertexVertexMap[v_old].erase(v_newIter);
//save all faces, because faces will be added/deleted
std::vector<typename MeshT::FaceHandle> faces;
for (typename MeshT::VertexFaceIter vf_iter = mesh_.vf_begin(v_old); vf_iter; ++vf_iter)
if (!mesh_.status(vf_iter).deleted())
faces.push_back(vf_iter);
for (typename MeshT::VertexFaceIter vf_iter = mesh_.vf_begin(v_old); vf_iter.is_valid(); ++vf_iter)
if (!mesh_.status(*vf_iter).deleted())
faces.push_back(*vf_iter);
//replace v_old with v_new by creating new faces with v_new instead of v_old if possible
for (typename std::vector<typename MeshT::FaceHandle>::iterator f_iter = faces.begin(); f_iter !=faces.end(); ++f_iter)
......@@ -189,8 +189,8 @@ void BoundarySnappingT<MeshT>::snap(double _epsilon)
//get face vertices
std::vector<typename MeshT::VertexHandle> f_vertices;
for(typename MeshT::FaceVertexIter fv_iter = mesh_.fv_begin(fHandle); fv_iter; ++fv_iter)
f_vertices.push_back( fv_iter.handle() );
for(typename MeshT::FaceVertexIter fv_iter = mesh_.fv_begin(fHandle); fv_iter.is_valid(); ++fv_iter)
f_vertices.push_back( *fv_iter );
mesh_.delete_face(fHandle,false);
......
......@@ -81,16 +81,16 @@ void MeshRepairPlugin::selectionEdgeLength(int _objectId, double _length, bool _
// Iterate over all edges
for (e_it = triMesh->edges_begin(); e_it != e_end ; ++e_it) {
TriMesh::HalfedgeHandle he = triMesh->halfedge_handle( e_it, 0 );
TriMesh::HalfedgeHandle he = triMesh->halfedge_handle( *e_it, 0 );
TriMesh::Point p1 = triMesh->point( triMesh->from_vertex_handle( he ) );
TriMesh::Point p2 = triMesh->point( triMesh->to_vertex_handle( he ) );
if ( _larger ) {
if ( (p1 - p2).norm() > _length)
triMesh->status(e_it).set_selected(true);
triMesh->status(*e_it).set_selected(true);
} else {
if ( (p1 - p2).norm() < _length)
triMesh->status(e_it).set_selected(true);
triMesh->status(*e_it).set_selected(true);
}
}
......@@ -112,16 +112,16 @@ void MeshRepairPlugin::selectionEdgeLength(int _objectId, double _length, bool _
// Iterate over all edges
for (e_it = polyMesh->edges_begin(); e_it != e_end ; ++e_it) {
PolyMesh::HalfedgeHandle he = polyMesh->halfedge_handle( e_it, 0 );
PolyMesh::HalfedgeHandle he = polyMesh->halfedge_handle( *e_it, 0 );
PolyMesh::Point p1 = polyMesh->point( polyMesh->from_vertex_handle( he ) );
PolyMesh::Point p2 = polyMesh->point( polyMesh->to_vertex_handle( he ) );
if ( _larger ) {
if ( (p1 - p2).norm() > _length)
polyMesh->status(e_it).set_selected(true);
polyMesh->status(*e_it).set_selected(true);
} else {
if ( (p1 - p2).norm() < _length)
polyMesh->status(e_it).set_selected(true);
polyMesh->status(*e_it).set_selected(true);
}
}
......@@ -150,27 +150,27 @@ void MeshRepairPlugin::removeSelectedEdges(int _objectId) {
for (e_it = triMesh->edges_begin(); e_it != e_end; ++e_it) {
if (!triMesh->status(e_it).deleted() && triMesh->status(e_it).selected()) {
if (!triMesh->status(*e_it).deleted() && triMesh->status(*e_it).selected()) {
const TriMesh::VHandle v0 = triMesh->to_vertex_handle(triMesh->halfedge_handle(e_it, 0));
const TriMesh::VHandle v1 = triMesh->to_vertex_handle(triMesh->halfedge_handle(e_it, 1));
const TriMesh::VHandle v0 = triMesh->to_vertex_handle(triMesh->halfedge_handle(*e_it, 0));
const TriMesh::VHandle v1 = triMesh->to_vertex_handle(triMesh->halfedge_handle(*e_it, 1));
const bool boundary0 = triMesh->is_boundary(v0);
const bool boundary1 = triMesh->is_boundary(v1);
const bool feature0 = triMesh->status(v0).feature();
const bool feature1 = triMesh->status(v1).feature();
const bool featureE = triMesh->status(e_it).feature();
const bool featureE = triMesh->status(*e_it).feature();
// Collapsing v1 into vo:
// collapse is ok, if collapsed vertex is not a feature vertex or the target vertex is a feature
// and if we collapse along an feature edge or if the collapsed vertex is not a feature
if ((!boundary1 || boundary0) && (!feature1 || (feature0 && featureE)) && triMesh->is_collapse_ok(
triMesh->halfedge_handle(e_it, 0)))
triMesh->collapse(triMesh->halfedge_handle(e_it, 0));
triMesh->halfedge_handle(*e_it, 0)))
triMesh->collapse(triMesh->halfedge_handle(*e_it, 0));
else if ((!boundary0 || boundary1) && (!feature0 || (feature1 && featureE)) && triMesh->is_collapse_ok(
triMesh->halfedge_handle(e_it, 1)))
triMesh->collapse(triMesh->halfedge_handle(e_it, 1));
triMesh->halfedge_handle(*e_it, 1)))
triMesh->collapse(triMesh->halfedge_handle(*e_it, 1));
}
}
......@@ -208,11 +208,11 @@ void MeshRepairPlugin::detectSkinnyTriangleByAngle(int _objectId, double _angle,
for (e_it = triMesh->edges_begin(); e_it != e_end; ++e_it) {
// Check prerequisites
if (!triMesh->status(e_it).deleted() && !triMesh->status(e_it).feature() && triMesh->is_flip_ok(e_it)) {
if (!triMesh->status(*e_it).deleted() && !triMesh->status(*e_it).feature() && triMesh->is_flip_ok(*e_it)) {
// For both halfedges
for (unsigned int h = 0; h < 2; ++h) {
TriMesh::HalfedgeHandle hh = triMesh->halfedge_handle(e_it.handle(), h);
TriMesh::HalfedgeHandle hh = triMesh->halfedge_handle(*e_it, h);
const TriMesh::Point& a = triMesh->point(triMesh->from_vertex_handle(hh));
const TriMesh::Point& b = triMesh->point(triMesh->to_vertex_handle(hh));
hh = triMesh->next_halfedge_handle(hh);
......@@ -223,11 +223,11 @@ void MeshRepairPlugin::detectSkinnyTriangleByAngle(int _objectId, double _angle,
if (angle < maxAngle) {
// selcet it
triMesh->status(e_it).set_selected(true);
triMesh->status(*e_it).set_selected(true);
// remove it if requested
if (_remove)
triMesh->flip(e_it);
triMesh->flip(*e_it);
}
}
}
......@@ -279,12 +279,12 @@ void MeshRepairPlugin::detectFoldover(int _objectId, float _angle) {
TriMesh::Scalar a, cosa = cos(_angle / 180.0 * M_PI);
for (e_it = mesh->edges_begin(); e_it != e_end; ++e_it) {
if (!mesh->is_boundary(e_it)) {
a = (mesh->normal(mesh->face_handle(mesh->halfedge_handle(e_it, 0))) | mesh->normal(
mesh->face_handle(mesh->halfedge_handle(e_it, 1))));
if (!mesh->is_boundary(*e_it)) {
a = (mesh->normal(mesh->face_handle(mesh->halfedge_handle(*e_it, 0))) | mesh->normal(
mesh->face_handle(mesh->halfedge_handle(*e_it, 1))));
if (a < cosa) {
mesh->status(mesh->edge_handle(mesh->halfedge_handle(e_it, 0))). set_selected(true);
mesh->status(mesh->edge_handle(mesh->halfedge_handle(*e_it, 0))). set_selected(true);
++count;
}
}
......@@ -305,12 +305,12 @@ void MeshRepairPlugin::detectFoldover(int _objectId, float _angle) {
PolyMesh::Scalar a, cosa = cos(_angle / 180.0 * M_PI);
for (e_it = mesh->edges_begin(); e_it != e_end; ++e_it) {
if (!mesh->is_boundary(e_it)) {
a = (mesh->normal(mesh->face_handle(mesh->halfedge_handle(e_it, 0))) | mesh->normal(
mesh->face_handle(mesh->halfedge_handle(e_it, 1))));
if (!mesh->is_boundary(*e_it)) {
a = (mesh->normal(mesh->face_handle(mesh->halfedge_handle(*e_it, 0))) | mesh->normal(
mesh->face_handle(mesh->halfedge_handle(*e_it, 1))));
if (a < cosa) {
mesh->status(mesh->edge_handle(mesh->halfedge_handle(e_it, 0))). set_selected(true);
mesh->status(mesh->edge_handle(mesh->halfedge_handle(*e_it, 0))). set_selected(true);
++count;
}
}
......
......@@ -69,14 +69,14 @@ MeshRepairPlugin::detectTriangleAspect(int _objectId, float _aspect) {
TriMesh::FEIter fe_it;
for (f_it = mesh->faces_begin(); f_it != f_end; ++f_it) {
fv_it = mesh->fv_iter(f_it);
fv_it = mesh->fv_iter(*f_it);
const TriMesh::Point& p0 = mesh->point(fv_it);
const TriMesh::Point& p1 = mesh->point(++fv_it);
const TriMesh::Point& p2 = mesh->point(++fv_it);
const TriMesh::Point& p0 = mesh->point(*fv_it);
const TriMesh::Point& p1 = mesh->point(*(++fv_it));
const TriMesh::Point& p2 = mesh->point(*(++fv_it));
if (ACG::Geometry::aspectRatio(p0, p1, p2) > _aspect) {
mesh->status(f_it).set_selected(true);
mesh->status(*f_it).set_selected(true);
++count;
}
}
......
......@@ -388,10 +388,10 @@ bool MeshFixing<MeshT>::fix()
// add faces
for (typename MeshT::FaceIter f_it = mesh_.faces_begin(); f_it != mesh_.faces_end(); ++f_it)
{
const ACG::Vec3d p0 = mesh_.point( fv_it = mesh_.fv_iter(f_it) );
const ACG::Vec3d p1 = mesh_.point(++fv_it);
const ACG::Vec3d p2 = mesh_.point(++fv_it);
fv_it = mesh_.fv_iter(*f_it);
const ACG::Vec3d p0 = mesh_.point( *(fv_it) );
const ACG::Vec3d p1 = mesh_.point(*(++fv_it));
const ACG::Vec3d p2 = mesh_.point(*(++fv_it));
add_face(p0, p1, p2);
......
......@@ -18,7 +18,7 @@ void MeshRepairPlugin::flipOrientation(MeshT& _mesh)
// Check if a face is selected
for (typename MeshT::FaceIter f_it = _mesh.faces_begin(); f_it != _mesh.faces_end() ; ++f_it)
if ( _mesh.status(f_it).selected() ) {
if ( _mesh.status(*f_it).selected() ) {
selected = true;
break;
}
......@@ -32,11 +32,11 @@ void MeshRepairPlugin::flipOrientation(MeshT& _mesh)
bool tagged = false;
for (typename MeshT::VertexFaceIter vf_it = _mesh.vf_iter(v_it); !tagged && vf_it; ++vf_it)
if (_mesh.status(vf_it).selected())
for (typename MeshT::VertexFaceIter vf_it = _mesh.vf_iter(*v_it); !tagged && vf_it.is_valid(); ++vf_it)
if (_mesh.status(*vf_it).selected())
tagged = true;
_mesh.status(v_it).set_tagged(tagged);
_mesh.status(*v_it).set_tagged(tagged);
}
// Remember the vertex mapping for the duplication
......@@ -46,14 +46,14 @@ void MeshRepairPlugin::flipOrientation(MeshT& _mesh)
// duplicate vertices that are incident to tagged and un-tagged faces
for (typename MeshT::VertexIter v_it = _mesh.vertices_begin(); v_it != _mesh.vertices_end(); ++v_it) {
typename MeshT::VertexHandle vh = v_it.handle();
typename MeshT::VertexHandle vh = *v_it;
if (_mesh.status(v_it).tagged() )
for (typename MeshT::VertexFaceIter vf_it = _mesh.vf_iter(v_it); vf_it; ++vf_it)
if (_mesh.status(*v_it).tagged() )
for (typename MeshT::VertexFaceIter vf_it = _mesh.vf_iter(*v_it); vf_it.is_valid(); ++vf_it)
if (!_mesh.status(vf_it).tagged()) {
if (!_mesh.status(*vf_it).tagged()) {
typename MeshT::Point tmpPoint = _mesh.point(v_it);
typename MeshT::Point tmpPoint = _mesh.point(*v_it);
// Duplicate the vertex
vh = _mesh.add_vertex( tmpPoint );
......@@ -62,29 +62,29 @@ void MeshRepairPlugin::flipOrientation(MeshT& _mesh)
_mesh.status(vh).set_tagged(true);
// The original vertex is already duplicated, so we don't need to do it again!
_mesh.status(v_it).set_tagged(false);
_mesh.status(*v_it).set_tagged(false);
break;
}
_mesh.property(vmap, v_it) = vh;
_mesh.property(vmap, *v_it) = vh;
}
// Delete the old faces and collect their information
for (typename MeshT::FaceIter f_it = _mesh.faces_begin(); f_it != _mesh.faces_end(); ++f_it) {
if (_mesh.status(f_it).selected()) {
if (_mesh.status(*f_it).selected()) {
// Collect vertex handles
typename MeshT::FaceVertexIter fv_it = _mesh.fv_iter(f_it);
typename MeshT::FaceVertexIter fv_it = _mesh.fv_iter(*f_it);
valence.push_back(_mesh.valence(f_it));
while (fv_it) {
vhandles.push_back(fv_it.handle());
valence.push_back(_mesh.valence(*f_it));
while (fv_it.is_valid()) {
vhandles.push_back(*fv_it);
++fv_it;
}
// delete the corresponding face
_mesh.delete_face(f_it, false);
_mesh.delete_face(*f_it, false);
}
}
......@@ -113,7 +113,7 @@ void MeshRepairPlugin::flipOrientation(MeshT& _mesh)
// store vertices
points.reserve(_mesh.n_vertices() );
for (typename MeshT::VertexIter v_it = _mesh.vertices_begin(); v_it != _mesh.vertices_end(); ++v_it)
points.push_back(_mesh.point(v_it));
points.push_back(_mesh.point(*v_it));
// Better approximation of vector size for storing the handles
const unsigned int n_VerticesPerFace = _mesh.is_trimesh() ? 3 : 4;
......@@ -123,10 +123,10 @@ void MeshRepairPlugin::flipOrientation(MeshT& _mesh)
vhandles.reserve( _mesh.n_faces() * n_VerticesPerFace);
for (typename MeshT::FaceIter f_it = _mesh.faces_begin(); f_it != _mesh.faces_end(); ++f_it) {
valence.push_back( _mesh.valence(f_it) );
valence.push_back( _mesh.valence(*f_it) );
for (typename MeshT::FaceVertexIter fv_it = _mesh.fv_iter(f_it); fv_it; ++fv_it)
vhandles.push_back(fv_it.handle());
for (typename MeshT::FaceVertexIter fv_it = _mesh.fv_iter(*f_it); fv_it.is_valid(); ++fv_it)
vhandles.push_back(*fv_it);
}
// Remove all entities from the mesh
......
......@@ -79,22 +79,22 @@ void NonManifoldVertexFixingT<MeshT>::fix()
for (typename MeshT::VertexIter v_iter = mesh_.vertices_begin(); v_iter != mesh_.vertices_end(); ++v_iter)
{
// unmark all faces
for (typename MeshT::VertexFaceIter vf_iter = mesh_.vf_begin(v_iter); vf_iter; ++vf_iter)
mesh_.property(component,vf_iter.handle()) = 0;
for (typename MeshT::VertexFaceIter vf_iter = mesh_.vf_begin(*v_iter); vf_iter.is_valid(); ++vf_iter)
mesh_.property(component,*vf_iter) = 0;
size_t componentCount = 1;
//search and isolate new components
//shared vertices will be duplicated
for (typename MeshT::VertexFaceIter vf_iter = mesh_.vf_begin(v_iter); vf_iter; ++vf_iter)
for (typename MeshT::VertexFaceIter vf_iter = mesh_.vf_begin(*v_iter); vf_iter.is_valid(); ++vf_iter)
{
//get the first face in the component
std::vector<typename MeshT::FaceHandle> checkNeighbour;
if(mesh_.property(component,vf_iter.handle()) == 0)
if(mesh_.property(component,*vf_iter) == 0)
{
mesh_.property(component,vf_iter.handle()) = componentCount;
checkNeighbour.push_back(vf_iter.handle());
mesh_.property(component,*vf_iter) = componentCount;
checkNeighbour.push_back(*vf_iter);
}
// if a reference face was found, a new component exists
......@@ -102,7 +102,7 @@ void NonManifoldVertexFixingT<MeshT>::fix()
typename MeshT::VertexHandle v_new;
if (componentCount > 1 && !checkNeighbour.empty())
{
typename MeshT::Point p = mesh_.point(v_iter.handle());
typename MeshT::Point p = mesh_.point(*v_iter);
v_new = mesh_.add_vertex(p);
}
......@@ -114,19 +114,19 @@ void NonManifoldVertexFixingT<MeshT>::fix()
std::vector<typename MeshT::VertexHandle> f_vertices;
// get all neighbor faces of face
for (typename MeshT::FaceVertexIter fv_iter = mesh_.fv_begin(face); fv_iter; ++fv_iter)
for (typename MeshT::FaceVertexIter fv_iter = mesh_.fv_begin(face); fv_iter.is_valid(); ++fv_iter)
{
f_vertices.push_back(fv_iter.handle());
if (fv_iter.handle() != v_iter)
f_vertices.push_back(*fv_iter);
if (*fv_iter != *v_iter)
{
//find the next neighbor face over edge v_iter and fv_iter
typename MeshT::FaceHandle nf;
for (typename MeshT::VertexFaceIter nf_iter = mesh_.vf_begin(v_iter); nf_iter && !nf.is_valid(); ++nf_iter)
for (typename MeshT::VertexFaceIter nf_iter = mesh_.vf_begin(*v_iter); nf_iter.is_valid() && !nf.is_valid(); ++nf_iter)
{
if (nf_iter.handle() != face)
for (typename MeshT::FaceVertexIter nfv_iter = mesh_.fv_begin(nf_iter); nfv_iter && !nf.is_valid(); ++nfv_iter)
if (nfv_iter.handle() == fv_iter.handle())
nf = nf_iter.handle();
if (*nf_iter != face)
for (typename MeshT::FaceVertexIter nfv_iter = mesh_.fv_begin(*nf_iter); nfv_iter.is_valid() && !nf.is_valid(); ++nfv_iter)
if (*nfv_iter == *fv_iter)
nf = *nf_iter;
}
//if such a face was found, it is in the same component as the reference face
......@@ -141,7 +141,7 @@ void NonManifoldVertexFixingT<MeshT>::fix()
//if one face wasn't found in the component = 1 run, then it is a new component, due to split
if (componentCount > 1 && v_new.is_valid())
{
std::replace(f_vertices.begin(),f_vertices.end(),v_iter.handle(),v_new);
std::replace(f_vertices.begin(),f_vertices.end(),*v_iter,v_new);
mesh_.delete_face(face,false);
mesh_.add_face(f_vertices);
......
......@@ -72,19 +72,19 @@ void MeshRepairPlugin::detectFlatValence3Vertices(int _objectId, double _angle)
for (v_it=mesh->vertices_begin(); v_it!=v_end; ++v_it)
{
if (!mesh->status(v_it).deleted() && !mesh->is_boundary(v_it) && mesh->valence(v_it) == 3)
if (!mesh->status(*v_it).deleted() && !mesh->is_boundary(*v_it) && mesh->valence(*v_it) == 3)
{
vf_it = mesh->vf_iter(v_it);
const TriMesh::Normal& n0 = mesh->normal(vf_it);
const TriMesh::Normal& n1 = mesh->normal(++vf_it);
const TriMesh::Normal& n2 = mesh->normal(++vf_it);
vf_it = mesh->vf_iter(*v_it);
const TriMesh::Normal& n0 = mesh->normal(*vf_it);
const TriMesh::Normal& n1 = mesh->normal(*(++vf_it));
const TriMesh::Normal& n2 = mesh->normal(*(++vf_it));
if ( (n0|n1) > cosangle &&
(n0|n2) > cosangle &&
(n1|n2) > cosangle )
{
mesh->status(v_it).set_selected(true);
mesh->status(*v_it).set_selected(true);
++count;
}
}
......@@ -123,12 +123,12 @@ void MeshRepairPlugin::removeSelectedVal3Vertices(int _objectId) {
std::vector<TriMesh::VertexHandle> vh(3);
for (v_it = mesh->vertices_begin(); v_it != v_end; ++v_it) {
vf_it = mesh->vf_iter(v_it);
if ((mesh->status(v_it).selected()) && !mesh->status(v_it).feature() && mesh->valence(v_it) == 3) {
for (i = 0, vv_it = mesh->vv_iter(v_it); vv_it; ++vv_it, ++i)
vh[2 - i] = vv_it.handle();
vf_it = mesh->vf_iter(*v_it);
if ((mesh->status(*v_it).selected()) && !mesh->status(*v_it).feature() && mesh->valence(*v_it) == 3) {
for (i = 0, vv_it = mesh->vv_iter(*v_it); vv_it.is_valid(); ++vv_it, ++i)
vh[2 - i] = *vv_it;
mesh->delete_vertex(v_it, false);
mesh->delete_vertex(*v_it, false);
mesh->add_face(vh);
++count;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment