Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] Fwd: Isotropic remeshing failed with is_valid_polygon_mesh()

Subject: CGAL users discussion list

List archive

[cgal-discuss] Fwd: Isotropic remeshing failed with is_valid_polygon_mesh()


Chronological Thread 
  • From: Yaoyu Hu <>
  • To:
  • Subject: [cgal-discuss] Fwd: Isotropic remeshing failed with is_valid_polygon_mesh()
  • Date: Sun, 6 Sep 2020 00:57:16 -0400
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None ; spf=Pass ; spf=None
  • Ironport-phdr: 9a23:dpUoQRykHLmorwnXCy+O+j09IxM/srCxBDY+r6Qd2usVIJqq85mqBkHD//Il1AaPAdyFrase16GG6ujJYi8p2d65qncMcZhBBVcuqP49uEgeOvODElDxN/XwbiY3T4xoXV5h+GynYwAOQJ6tL1LdrWev4jEMBx7xKRR6JvjvGo7Vks+7y/2+94fcbglVhTexe65+IAu5oAnetcQanJZpJ7osxBfOvnZGYfldy3lyJVKUkRb858Ow84Bm/i9Npf8v9NNOXLvjcaggQrNWEDopM2Yu5M32rhbDVheA5mEdUmoNjBVFBRXO4QzgUZfwtiv6sfd92DWfMMbrQ704RSiu4qF2QxDvlSkHKiU58HnJhcNskKJVrhWhpxllzI7VZoGeKf5yc6zZcN8fQ2dKQ8RfWDFbAo6kYIQPAegOM+ZWoYf+ulUAswexCBKpBO/z0DJFnGP60bE43uknDArI3BYgH9ULsHnMrtr6LqASUOCozKLVzzvDcu5d1DD96IjVchEuu/aMXLJtccbMzUQiFALIg06fqYzgJTyV1+ANv3KH4OpnUOKikmgqoBx+rTaz3MkjkJXJhp4LxVDe8yV02Ik4KN62RkNmYNOoDJpduz2VOYZrX84sTG9mtDgmxrAHtpO3YCcExZopyRPCdvGKc4qF7g/iWeiRIjp1hX1rdK65ih2v/0agzej8WdO10FZMtidKjtbMuWoJ1xDJ7ciHUPR98l+91jaAzQ/T7vtILVozlarBJJ4t2rEwlp0UsUTMGi/5hl/6g7ORdkUh/OWj9ufpYq3+q5OCK4N5jhvyP6cul8ClHOg0LAsDU3KU9Om90rDo4Ff3T69QjvIsl6nUqJDaKtofpq6+GwJV15ws6xe7Dzu/3tUYmGQLIEtLeB+IjoXlIV7OIPf/Dfewh1Sjji1nyOzBPr3kGpnNL37Dn6n9fbtl9UJQ1A4+wcpc6p9UEL0NPez/V0zruNHXDxI1Kwm0zPzmCNV52IMeQ2WPAqqBPaPSrF+J5vggI+6MZY8IpTrwL/so6v/1gH82nF8SZ6ip3Z8NZH+kGfRmJl2VYWDwjdcZDWcKog0+QfT2h12NSzFTY2++UL895jEgFI2mEJzDRpu2jbya3Ca7G4VWaXpcBlCNF3fobYSEVO0WZCKcOM8y2gADALOuQotk2RC1vxLh0JJmKPDV82sWr8HNzt9wstzakgAvvRxpR5CdznCESHBpxzJYGRc52al+pQp2zVLVgvswuOBRCdEGv6ABaQw9L5OJk70jVoLCHznZd9LMc26IB9WrBTZrE4A0yt4KJll4QpCs0k6F0C2tDLsY0beMAc5sq/6O7z3KP894jk3++uw5lVB/G5lAMGSnguh08A2BX9eYwXXcrL6jcOEn5ACI8W6CyWSUu0QBCVx/VKzEWTYUYU6E9Nk=

Sorry for the duplicated messages. 

I did not specify my CGAL version in the last email. `git status` tells me that I am using CGAL 5.0.2.

Thanks!

---------- Forwarded message ---------
From: Yaoyu Hu <>
Date: Sun, Sep 6, 2020 at 12:47 AM
Subject: Isotropic remeshing failed with is_valid_polygon_mesh()
To: <>


Hi,

I was trying to use CGAL::Polygon_mesh_processing::isotropic_remeshing() to remesh a CGAL::Surface_mesh. However, I got the following error message:

========== Error message begins. ==========

terminate called after throwing an instance of 'CGAL::Assertion_exception'
  what():  CGAL ERROR: assertion violation!
Expr: is_valid_polygon_mesh(mesh_)
File: /home/yaoyu/Libraries/cgal/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h
Line: 1037

========== Error message ends. ==========

I was trying the code listed at https://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2isotropic_remeshing_example_8cpp-example.html and I enclosed the source file. I am not sure about the reason why CGAL thinks the Surface_mesh is not a valid polygon mesh.

The input mesh is in PLY format and you could find the file at https://drive.google.com/file/d/1Z9AMfRnbkJGmDuUOc7ZAdMAvbhhhx_Vn/view?usp=sharing

One thing that might be interesting is that if I use the CGAL Polyhedron Demo program to load and do the isotropic remeshing, no errors are encountered. 

Any comments are appreciated.

Thank you!

Yaoyu
//
// Created by yaoyu on 9/6/20.
//

#include <fstream>
#include <iostream>
#include <string>

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

// Namespace.
namespace PMP = CGAL::Polygon_mesh_processing;

// CGAL typedefs.
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel_t;
typedef Kernel_t::Point_3                                   Point3_t;
typedef CGAL::Surface_mesh<Point3_t>                        SurfaceMesh_t;

typedef boost::graph_traits< SurfaceMesh_t >::face_descriptor DescFace_t;
typedef boost::graph_traits< SurfaceMesh_t >::edge_descriptor DescEdge_t;
typedef boost::graph_traits< SurfaceMesh_t >::halfedge_descriptor DescHalfedge_t;
typedef boost::graph_traits< SurfaceMesh_t >::vertex_descriptor DescVert_t;

template < typename PT >
void read_mesh_ply(const std::string &fn,
                   CGAL::Surface_mesh<PT> &sm ) {

    std::ifstream ifs { fn };

    if ( !ifs ) {
        std::stringstream ss;
        ss << "Cannot open " << fn << " for reading. ";
        throw std::runtime_error( ss.str() );
    }

    if ( !CGAL::read_ply( ifs, sm ) ) {
        std::stringstream ss;
        ss << "read_ply() from " << fn << " failed. ";
        throw std::runtime_error( ss.str() );
    }

    ifs.close();
}

struct halfedge2edge
{
    halfedge2edge(const SurfaceMesh_t &m, std::vector<DescEdge_t> &edges)
            : m_mesh(m), m_edges(edges)
    {}

    void operator()(const DescHalfedge_t &h) const
    {
        m_edges.push_back(edge(h, m_mesh));
    }

    const SurfaceMesh_t& m_mesh;
    std::vector<DescEdge_t>& m_edges;
};

static void isotropic_remesh( SurfaceMesh_t &mesh, double targetLength, int iters ) {
    // Border.
    std::cout << "Split border...\n";
    std::vector<DescEdge_t> border;
    PMP::border_halfedges(faces(mesh),
                          mesh,
                          boost::make_function_output_iterator(halfedge2edge(mesh, border)));
    PMP::split_long_edges(border, targetLength, mesh);

    // Perform smooth.
    std::cout << "Start remeshing... \n";
    PMP::isotropic_remeshing(
            faces( mesh ),
            targetLength,
            mesh,
            PMP::parameters::number_of_iterations(iters)
                    .protect_constraints(true) );
}

int main( int argc, char **argv ) {
    std::cout << "Hello, RemeshingTest! \n";

    // Load the mesh from the PLY file.
    SurfaceMesh_t mesh;
    read_mesh_ply( argv[1], mesh);

    // Remesh.
    isotropic_remesh( mesh, 0.02, 1 );

    return 0;
}



Archive powered by MHonArc 2.6.19+.

Top of Page