Fail in computing the corefinement of two simple triangulated surface meshes

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

Fail in computing the corefinement of two simple triangulated surface meshes

coz.mars123
Hello.

I have a problem when computing the corefirement of two simple triangulated
surface meshes. The following code raised an exception when running. I think
the error came from the input 2 "ConeClosed.off" because when I replaced it
with "blobby.off", the corefirement was successfully computed.
But I don't know what is wrong here.
Please suggest me how to fix the problem. Thanks a lot.

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Polygon_mesh_processing/corefinement.h>
#include <fstream>
#include <CGAL/draw_surface_mesh.h>
#include <CGAL/Surface_mesh_simplification/edge_collapse.h>

typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Surface_mesh<K::Point_3>             Mesh;
typedef K::Point_3 Point;
namespace PMP = CGAL::Polygon_mesh_processing;

int main(int argc, char* argv[])
{
        const char* filename1 = (argc > 1) ? argv[1] : "data/cuboid.off";
        const char* filename2 = (argc > 2) ? argv[2] : "data/ConeClosed.off";
        //const char* filename2 = (argc > 2) ? argv[2] : "data/blobby.off";

       
        std::ifstream input(filename1);
        Mesh mesh1, mesh2;
        if (!input || !(input >> mesh1))
        {
                std::cerr << "First mesh is not a valid off file." << std::endl;
                return 1;
        }
        input.close();

        input.open(filename2);

        if (!input || !(input >> mesh2))
        {
                std::cerr << "Second mesh is not a valid off file." << std::endl;
                return 1;
        }
        input.close();

        Mesh out;
        bool valid_union = PMP::corefine_and_compute_union(mesh1, mesh2, out);

        if (valid_union)
        {
                std::cout << "Union was successfully computed\n";
                std::ofstream output("union.off");
                output << out;
                CGAL::draw(out);
                return 0;
        }
        std::cout << "Union could not be computed\n";
        return 1;
}


Cuboid.off
<http://cgal-discuss.949826.n4.nabble.com/file/t376147/Cuboid.off>  
ConeClosed.off
<http://cgal-discuss.949826.n4.nabble.com/file/t376147/ConeClosed.off>  
blobby.off
<http://cgal-discuss.949826.n4.nabble.com/file/t376147/blobby.off>  



--
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: Fail in computing the corefinement of two simple triangulated surface meshes

Sebastien Loriot (GeometryFactory)
ConeClosed.off is not closed: it contains duplicated edges.
If you call stitch_borders(mesh2) right after reading the mesh, it
  should work.

Sebastien.

On 9/12/19 4:32 PM, coz.mars123 wrote:

> Hello.
>
> I have a problem when computing the corefirement of two simple triangulated
> surface meshes. The following code raised an exception when running. I think
> the error came from the input 2 "ConeClosed.off" because when I replaced it
> with "blobby.off", the corefirement was successfully computed.
> But I don't know what is wrong here.
> Please suggest me how to fix the problem. Thanks a lot.
>
> #include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
> #include <CGAL/Surface_mesh.h>
> #include <CGAL/Polygon_mesh_processing/corefinement.h>
> #include <fstream>
> #include <CGAL/draw_surface_mesh.h>
> #include <CGAL/Surface_mesh_simplification/edge_collapse.h>
>
> typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
> typedef CGAL::Surface_mesh<K::Point_3>             Mesh;
> typedef K::Point_3 Point;
> namespace PMP = CGAL::Polygon_mesh_processing;
>
> int main(int argc, char* argv[])
> {
> const char* filename1 = (argc > 1) ? argv[1] : "data/cuboid.off";
> const char* filename2 = (argc > 2) ? argv[2] : "data/ConeClosed.off";
> //const char* filename2 = (argc > 2) ? argv[2] : "data/blobby.off";
>
>
> std::ifstream input(filename1);
> Mesh mesh1, mesh2;
> if (!input || !(input >> mesh1))
> {
> std::cerr << "First mesh is not a valid off file." << std::endl;
> return 1;
> }
> input.close();
>
> input.open(filename2);
>
> if (!input || !(input >> mesh2))
> {
> std::cerr << "Second mesh is not a valid off file." << std::endl;
> return 1;
> }
> input.close();
>
> Mesh out;
> bool valid_union = PMP::corefine_and_compute_union(mesh1, mesh2, out);
>
> if (valid_union)
> {
> std::cout << "Union was successfully computed\n";
> std::ofstream output("union.off");
> output << out;
> CGAL::draw(out);
> return 0;
> }
> std::cout << "Union could not be computed\n";
> return 1;
> }
>
>
> Cuboid.off
> <http://cgal-discuss.949826.n4.nabble.com/file/t376147/Cuboid.off>
> ConeClosed.off
> <http://cgal-discuss.949826.n4.nabble.com/file/t376147/ConeClosed.off>
> blobby.off
> <http://cgal-discuss.949826.n4.nabble.com/file/t376147/blobby.off>
>
>
>
> --
> 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: Fail in computing the corefinement of two simple triangulated surface meshes

coz.mars123
It works now. Thank you very much !



--
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