make_mesh_3 assertion violation in Triangulation_ds_cell_base_3

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

make_mesh_3 assertion violation in Triangulation_ds_cell_base_3

Kim
Dear everyone,

I am trying to use make_mesh_3 in parallel mode. While my code runs without
any problems in sequential mode in parallel mode I am getting the following
error:
   what():  CGAL ERROR: assertion violation!
   Expr: v == V[3]
   File: ./libs/CGAL/CGAL-5.1/include/CGAL/Triangulation_ds_cell_base_3.h
   Line: 93

The relevant code snippets are as follows:
typedef CGAL::Labeled_mesh_domain_3<Kernel> Implicit_domain;
typedef CGAL::Mesh_triangulation_3<Implicit_domain, CGAL::Default,
Concurrency_tag>::type VTr;
typedef CGAL::Mesh_complex_3_in_triangulation_3<VTr> C3t3;
typedef CGAL::Mesh_criteria_3<VTr> Mesh_criteria;

///////

aClassContainingTPMSequations *tpms

///////

auto myImplicitFunction = [dist, tpms](const Point_3 &p) {
  return dist->signed_distance_function(p, dist->
poissonReconstructionFunction, tpms);
}; // To pass function on as a static member

Implicit_domain domain =
Implicit_domain::create_implicit_mesh_domain(myImplicitFunction,
boundingBox);

Mesh_criteria criteria(CGAL::parameters::facet_angle = facetAngle,
                               CGAL::parameters::facet_size = facetSize,
                               CGAL::parameters::facet_distance = facetDistance);
C3t3 c3t3 = CGAL::make_mesh_3<C3t3>(domain, criteria,
CGAL::parameters::manifold());

///////


I also tried running make_mesh_3 without manifold() in which case it just
keeps on running forever.

Hopefully someone can point me in the right direction.

Kind regards,
Kim



--
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: make_mesh_3 assertion violation in Triangulation_ds_cell_base_3

Laurent Rineau (CGAL/GeometryFactory)
On Friday, September 18, 2020 4:27:23 PM CEST Kim wrote:
> auto myImplicitFunction = [dist, tpms](const Point_3 &p) {
>   return dist->signed_distance_function(p, dist->
> poissonReconstructionFunction, tpms);
> }; // To pass function on as a static member

If your code crashes only in parallel mode, then perhaps there is something in
that object `myImplicitFunction` that is not thread-safe.

--
Laurent Rineau, PhD
R&D Engineer at GeometryFactory           http://www.geometryfactory.com/
Release Manager of the CGAL Project       http://www.cgal.org/




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


Kim
Reply | Threaded
Open this post in threaded view
|

Re: make_mesh_3 assertion violation in Triangulation_ds_cell_base_3

Kim
Dear Laurent,

I see I forgot to make a small edit in what I posted to make clear what
'myImplicitFunction' is. At the moment 'myImplicitFunction' is just a
Poisson_reconstruction_function. Defining the domain as I do above is at the
moment the same as defining it as bellow which I think should be
thread-safe. Or am I missing something?

Poisson_reconstruction_function *poissonSurfaceReconstruction;
poissonSurfaceReconstruction = new
Poisson_reconstruction_function(points.begin(), points.end(),                                                              
CGAL::First_of_pair_property_map<Point_with_normal>(),                                                            
CGAL::Second_of_pair_property_map<Point_with_normal>());

Implicit_domain domain =
 
Implicit_domain::create_implicit_mesh_domain(*poissonSurfaceReconstruction,
boundingBox);

Kind regards,
Kim




--
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: make_mesh_3 assertion violation in Triangulation_ds_cell_base_3

Laurent Rineau (CGAL/GeometryFactory)
On Friday, September 18, 2020 6:13:52 PM CEST Kim wrote:

> Poisson_reconstruction_function *poissonSurfaceReconstruction;
> poissonSurfaceReconstruction = new
> Poisson_reconstruction_function(points.begin(), points.end(),
> CGAL::First_of_pair_property_map<Point_with_normal>(),
> CGAL::Second_of_pair_property_map<Point_with_normal>());
>
> Implicit_domain domain =
>
> Implicit_domain::create_implicit_mesh_domain(*poissonSurfaceReconstruction,
> boundingBox);

Just to be sure: have you called

    poissonSurfaceReconstruction->compute_implicit_function()

in a non-parallel context? If that function is lazily called in a parallel
context, then be sure to synchronize its call, because that call is not
reentrant.

--
Laurent Rineau, PhD
R&D Engineer at GeometryFactory           http://www.geometryfactory.com/
Release Manager of the CGAL Project       http://www.cgal.org/




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


Kim
Reply | Threaded
Open this post in threaded view
|

Re: make_mesh_3 assertion violation in Triangulation_ds_cell_base_3

Kim
Yes, I call poissonSurfaceReconstruction->compute_implicit_function() in a
non-parallel context.

Bellow I have added a minimal example that results in the assertion
violation when I compile it for parallel use but works fine when I compile
it for non-parallel use. Probably should have created and posted it from the
beginning, my apologies I didn't.

Input file:  cylinder.xyz
<http://cgal-discuss.949826.n4.nabble.com/file/t376247/cylinder.xyz>  

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Poisson_reconstruction_function.h>
#include <CGAL/Point_with_normal_3.h>
#include <CGAL/property_map.h>
#include <CGAL/IO/read_xyz_points.h>

#include <CGAL/Labeled_mesh_domain_3.h>
#include <CGAL/Mesh_triangulation_3.h>
#include <CGAL/Mesh_complex_3_in_triangulation_3.h>
#include <CGAL/Mesh_criteria_3.h>
#include <CGAL/make_mesh_3.h>

#include <vector>
#include <algorithm>
#include <fstream>
#include <iostream>
#include <sstream>

typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef Kernel::FT FT;
typedef Kernel::Point_3 Point_3;
typedef Kernel::Vector_3 Vector_3;
typedef Kernel::Sphere_3 Sphere_3;

typedef CGAL::Parallel_if_available_tag Concurrency_tag;

typedef std::pair<Point_3, Vector_3> Point_with_normal;
typedef std::vector<Point_with_normal> PointList;
typedef CGAL::Poisson_reconstruction_function<Kernel>
Poisson_reconstruction_function;

typedef CGAL::Labeled_mesh_domain_3<Kernel> Implicit_domain;
typedef CGAL::Mesh_triangulation_3<Implicit_domain, CGAL::Default,
Concurrency_tag>::type VTr;
typedef CGAL::Mesh_complex_3_in_triangulation_3<VTr> C3t3;
typedef CGAL::Mesh_criteria_3<VTr> Mesh_criteria;

int main(void) {
    PointList points;
    std::ifstream stream("cylinder.xyz");
    if (!stream ||
        !CGAL::read_xyz_points(stream, std::back_inserter(points),
                                CGAL::parameters::
                                  point_map(CGAL::First_of_pair_property_map<Point_with_normal>()).
                                  normal_map(CGAL::Second_of_pair_property_map<Point_with_normal>())))
    {
      std::cerr << "Error: cannot read file" << std::endl;
      return EXIT_FAILURE;
    }

        // Create implicit function
        Poisson_reconstruction_function *poissonSurfaceReconstruction;
        poissonSurfaceReconstruction = NULL;
        poissonSurfaceReconstruction = new Poisson_reconstruction_function(
                points.begin(), points.end(),
                CGAL::First_of_pair_property_map<Point_with_normal>(),
                CGAL::Second_of_pair_property_map<Point_with_normal>());

        // Computes the Poisson indicator function f().
        if ( ! poissonSurfaceReconstruction->compute_implicit_function() )
                throw "ERROR_POISSON_LINEAR_SOLVER_FAILED";

        // Determine bounding box
        CGAL::Bbox_3 boundingBox(-10, -10, -10, 10, 10, 10);
        Implicit_domain domain = Implicit_domain::create_implicit_mesh_domain(
                *poissonSurfaceReconstruction, boundingBox);

        Mesh_criteria criteria(CGAL::parameters::facet_angle = 30,
                               CGAL::parameters::facet_size = 4,
                               CGAL::parameters::facet_distance = 0.1);
        // Generate mesh
        C3t3 c3t3 = CGAL::make_mesh_3<C3t3>(domain, criteria,
                                            CGAL::parameters::manifold());

        // Write output to .mesh file
        std::ofstream medit_file("out.mesh");
        c3t3.output_to_medit(medit_file);
        medit_file.close();

        delete(poissonSurfaceReconstruction);

  return EXIT_SUCCESS;
}


And to give the complete picture, below the pertinent information regarding
the compilation:

g++ -ggdb -I./include -I/usr/include/eigen3 -I./libs/CGAL/CGAL-5.1/include
-I./libs/oneTBB/include/tbb -DTBBROOT=./libs/oneTBB/include/tbb
-DCGAL_CONCURRENT_MESH_3 -DCGAL_LINKED_WITH_TBB   -c -o src/test_error.o
src/test_error.cpp
In file included from
./libs/CGAL/CGAL-5.1/include/CGAL/Mesh_3/Worksharing_data_structures.h:26,
                 from
./libs/CGAL/CGAL-5.1/include/CGAL/Mesh_3/Mesher_level.h:27,
                 from
./libs/CGAL/CGAL-5.1/include/CGAL/Mesh_3/Refine_facets_3.h:25,
                 from
./libs/CGAL/CGAL-5.1/include/CGAL/Mesh_3/Mesher_3.h:32,
                 from ./libs/CGAL/CGAL-5.1/include/CGAL/refine_mesh_3.h:28,
                 from ./libs/CGAL/CGAL-5.1/include/CGAL/make_mesh_3.h:26,
                 from src/test_error.cpp:11:
/usr/local/include/tbb/task.h:21:139: note: #pragma message: TBB Warning:
tbb/task.h is deprecated. For details, please see Deprecated Features
appendix in the TBB reference manual.
 #pragma message("TBB Warning: tbb/task.h is deprecated. For details, please
see Deprecated Features appendix in the TBB reference manual.")
                                                                                                                                         
^
rm -rf main
g++ -ggdb -I./include -I/usr/include/eigen3 -I./libs/CGAL/CGAL-5.1/include
-I./libs/oneTBB/include/tbb -DTBBROOT=./libs/oneTBB/include/tbb
-DCGAL_CONCURRENT_MESH_3 -DCGAL_LINKED_WITH_TBB -o main src/test_error.o
-L./libs/oneTBB/build/linux_intel64_gcc_cc8.3.0_libc2.28_kernel4.4.0_release
-Wl,-rpath,./libs/oneTBB/build/linux_intel64_gcc_cc8.3.0_libc2.28_kernel4.4.0_release
-lgmp -lmpfr -frounding-math -lpthread -ltbb -ltbbmalloc
#rm -rf src/*.o



--
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: make_mesh_3 assertion violation in Triangulation_ds_cell_base_3

Laurent Rineau (CGAL/GeometryFactory)
On Sunday, September 20, 2020 9:14:51 PM CEST Kim wrote:
> Yes, I call poissonSurfaceReconstruction->compute_implicit_function() in a
> non-parallel context.
>
> Bellow I have added a minimal example that results in the assertion
> violation when I compile it for parallel use but works fine when I compile
> it for non-parallel use. Probably should have created and posted it from the
> beginning, my apologies I didn't.

Thanks for the repro.

I could reproduce it, and I found out that Poisson_reconstruction_function.h
is not thread-safe: have a look at include/CGAL/
Poisson_reconstruction_function.h:851

The value cell->info() is initialized lazily in a non-safe way.

--
Laurent Rineau, PhD
R&D Engineer at GeometryFactory           http://www.geometryfactory.com/
Release Manager of the CGAL Project       http://www.cgal.org/




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