Detection of non_manifold_vertex and non_manifold_edgesn in a mesh

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Detection of non_manifold_vertex and non_manifold_edgesn in a mesh

sergio
This post was updated on .
After check  C:\dev\CGAL-4.12\include\CGAL\Polygon_mesh_processing\repair.h I
found some lines that let it detect non manifold_vertex and non
manifold_edges. I added these lines into individual functions to be used. I
would like to resolve missing definitions adding the correct headers to the
following adapted functions. For example TriangleMesh is not found it. How
can fix these functions definition?

//
----------------------------------------------------------------------------
// manifold-vertex
// ----------------------------------------------------------------------
#include <boost/foreach.hpp>
#include <CGAL/boost/graph/iterator.h>

#include <CGAL/Polygon_mesh_processing/repair.h>
#include <CGAL/Polygon_mesh_processing/internal/repair_extra.h>
#include <CGAL/Polygon_mesh_processing/corefinement.h>

// manifold-vertex
typedef boost::graph_traits<TriangleMesh> GT;
typedef typename GT::halfedge_descriptor halfedge_descriptor;


void test_non_manifold_vertex()
{
        bool non_manifold_vertex_removed = false; //here non-manifold is for the 1D
polyline
        std::vector<halfedge_descriptor> boundary_hedges;
        BOOST_FOREACH(face_descriptor fh, cc_faces)
        {
                halfedge_descriptor h = halfedge(fh, tm);
                for (int i = 0; i < 3; ++i)
                {
                        if (is_border(opposite(h, tm), tm) ||
                                cc_faces.count(face(opposite(h, tm), tm)) == 0)
                        {
                                boundary_hedges.push_back(h);
                        }
                        h = next(h, tm);
                }
        }
}



void test_non_manifold_edges()
{
      // make sure that the hole filling is valid, we check that no
      // edge already in the mesh is present in patch.
      bool non_manifold_edge_found = false;
      BOOST_FOREACH(const Face_indices& triangle, patch)
      {
        cpp11::array<int, 6> edges =
          make_array(triangle.first, triangle.second,
                     triangle.second, triangle.third,
                     triangle.third, triangle.first);
        for (int k=0; k<3; ++k)
        {
          int vi=edges[2*k], vj=edges[2*k+1];
          // ignore boundary edges
          if (vi+1==vj || (vj==0 &&
static_cast<std::size_t>(vi)==border_vertices.size()-1) )
            continue;
          halfedge_descriptor h = halfedge(border_vertices[vi],
border_vertices[vj], tm).first;
          if (h!=boost::graph_traits<TriangleMesh>::null_halfedge() &&
              cc_interior_edges.count(edge(h, tm))==0)
          {
            non_manifold_edge_found=true;
            break;
          }
        }
        if (non_manifold_edge_found) break;
      }
}



--
Sent from: http://cgal-discuss.949826.n4.nabble.com/

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss


Reply | Threaded
Open this post in threaded view
|

Re: Detection of non_manifold_vertex in mesh

andreas.fabri

TriangleMesh is not a class but a template parameter.

You must include the header of Surface_mesh or Polyhedron_3


On 6/5/2018 3:54 PM, sergio wrote:
After check  C:\dev\CGAL-4.12\include\CGAL\Polygon_mesh_processing\repair.h I
found some lines that let it detect non manifold_vertex and non
manifold_edges. I added these lines into individual functions to be used. I
would like to resolve missing definitions adding the correct headers to the
following adapted functions. For example TriangleMesh is not found it. How
can fix these functions definition?

//
----------------------------------------------------------------------------
// manifold-vertex
// ----------------------------------------------------------------------
#include <boost/foreach.hpp>
#include <CGAL/boost/graph/iterator.h>

#include <CGAL/Polygon_mesh_processing/repair.h>
#include <CGAL/Polygon_mesh_processing/internal/repair_extra.h>
#include <CGAL/Polygon_mesh_processing/corefinement.h>

// manifold-vertex
typedef boost::graph_traits<TriangleMesh> GT;
typedef typename GT::halfedge_descriptor halfedge_descriptor;


void test_non_manifold_vertex()
{
	bool non_manifold_vertex_removed = false; //here non-manifold is for the 1D
polyline
	std::vector<halfedge_descriptor> boundary_hedges;
	BOOST_FOREACH(face_descriptor fh, cc_faces)
	{
		halfedge_descriptor h = halfedge(fh, tm);
		for (int i = 0; i < 3; ++i)
		{
			if (is_border(opposite(h, tm), tm) ||
				cc_faces.count(face(opposite(h, tm), tm)) == 0)
			{
				boundary_hedges.push_back(h);
			}
			h = next(h, tm);
		}
	}
}



void test_non_manifold_edges()
{
      // make sure that the hole filling is valid, we check that no
      // edge already in the mesh is present in patch.
      bool non_manifold_edge_found = false;
      BOOST_FOREACH(const Face_indices& triangle, patch)
      {
        cpp11::array<int, 6> edges =
          make_array(triangle.first, triangle.second,
                     triangle.second, triangle.third,
                     triangle.third, triangle.first);
        for (int k=0; k<3; ++k)
        {
          int vi=edges[2*k], vj=edges[2*k+1];
          // ignore boundary edges
          if (vi+1==vj || (vj==0 &&
static_cast<std::size_t>(vi)==border_vertices.size()-1) )
            continue;
          halfedge_descriptor h = halfedge(border_vertices[vi],
border_vertices[vj], tm).first;
          if (h!=boost::graph_traits<TriangleMesh>::null_halfedge() &&
              cc_interior_edges.count(edge(h, tm))==0)
          {
            non_manifold_edge_found=true;
            break;
          }
        }
        if (non_manifold_edge_found) break;
      }
}



--
Sent from: http://cgal-discuss.949826.n4.nabble.com/


-- 
Andreas Fabri, PhD
Chief Officer, GeometryFactory
Editor, The CGAL Project

phone: +33.492.954.912    skype: andreas.fabri
Reply | Threaded
Open this post in threaded view
|

Re: Detection of non_manifold_vertex in mesh

sergio
Hello,

This is my implementation and checking with the file
cube_nonmanifold_vertex.off

OFF
10 13 0
-1 -1 -1
-1 1 -1
1 1 -1
1 -1 -1
-1 -1 1
-1 1 1
1 1 1
1 -1 1
*2 2 2
2 2 1*
3  0 1 3
3  3 1 2
3  0 4 1
3  1 4 5
3  3 2 7
3  7 2 6
3  4 0 3
3  7 4 3
3  6 4 7
3  6 5 4
3  1 5 6
3  2 1 6
*3  6 8 9*

we can check that after mesh is pass for polygon_soup_to_polygon_mesh the
non-manifold is remove. What I want to do is to detect the non manifold
vertex. What wrong?



#include <CGAL/Surface_mesh.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>

#include <iostream>
#include <fstream>
#include <list>

#include <CGAL/IO/OFF_reader.h>
#include <CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h>


typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef Kernel::Point_3                                      Point;
typedef CGAL::Surface_mesh<Point>                            Mesh;
typedef Mesh::Face_index face_descriptor;
typedef typename Mesh::halfedge_index halfedge_descriptor;

bool getMeshFromPolygonSoup(const char* filename, Mesh &mesh)
{
        std::ifstream input(filename);
        if (!input)
        {
                std::cerr << "Cannot open file " << std::endl;
                return false;
        }
        std::vector<Point> points;
        std::vector< std::vector<std::size_t> > polygons;
        if (!CGAL::read_OFF(input, points, polygons))
        {
                std::cerr << "Error parsing the OFF file " << std::endl;
                return false;
        }
        CGAL::Polygon_mesh_processing::polygon_soup_to_polygon_mesh(points,
polygons, mesh);
        return true;
}

void check_manifold_vertex(const Mesh& mesh)
{
        std::set<face_descriptor> faces_;
        BOOST_FOREACH(face_descriptor fd, faces(mesh)) {
                // ids are between [0, number_of_segments -1]
                faces_.insert(fd);
        }


        std::vector<halfedge_descriptor> boundary_hedges;

        BOOST_FOREACH(face_descriptor fh, faces_)
        {
                std::cout << "halfedge" << std::endl;
                halfedge_descriptor h = halfedge(fh, mesh);
                for (int i = 0; i < 3; ++i)
                {
                        std::cout << "vertex" <<i<< std::endl;
                        if (is_border(opposite(h, mesh), mesh) || faces_.count(face(opposite(h,
mesh), mesh)) == 0)
                        {
                                std::cout << "boundary edge" << std::endl;
                                boundary_hedges.push_back(h);

                        }
                        h = next(h, mesh);
                }

        }
}

int main(int, char** argv)
{
        Mesh sm;
        getMeshFromPolygonSoup(argv[1], sm);
        check_manifold_vertex(sm);

       
        return 0;
}



--
Sent from: http://cgal-discuss.949826.n4.nabble.com/

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss