CGAL / cgal

The public CGAL repository, see the README below
https://github.com/CGAL/cgal#readme
Other
4.99k stars 1.39k forks source link

Failed to creat a complex domain using surface patches #3887

Closed wangbowenll closed 5 years ago

wangbowenll commented 5 years ago

Issue Details

Dear researcher I build a geological model.This is a typically geological model which has fault、structum and terrain features. Those need to be protected.I created a domain with some surface patches. Patches are composed of model surfaces. The subdomain indexes order given are corresponded by the input-polyhedra.but there is a wrong.it is "0x00007FF658BFAA63 There is an unhandled exception (in mesh_polyhedral_complex.exe): 0xC0000005: An access violation occurred while writing to location 0x000001FBC4146E68." i think the model maybe has problem.Because i do not have enough confidence to comfirm it is right. so what should i do to achieve it? U6V2HV7 R92KOPI0R@`S7MD

This is the file

file (2).zip

Source Code

#define CGAL_CONCURRENT_MESH_3
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>

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

#include <CGAL/Polyhedral_complex_mesh_domain_3.h>
#include <CGAL/make_mesh_3.h>

#include <cstdlib>

// Domain
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Mesh_polyhedron_3<K>::type Polyhedron;
typedef CGAL::Polyhedral_complex_mesh_domain_3<K,Polyhedron> Mesh_domain;

#ifdef CGAL_CONCURRENT_MESH_3
typedef CGAL::Parallel_tag Concurrency_tag;
#else
typedef CGAL::Sequential_tag Concurrency_tag;
#endif

// Triangulation
typedef CGAL::Mesh_triangulation_3<Mesh_domain,CGAL::Default,Concurrency_tag>::type Tr;

typedef CGAL::Mesh_complex_3_in_triangulation_3<
  Tr,Mesh_domain::Corner_index,Mesh_domain::Curve_index> C3t3;

// Criteria
typedef CGAL::Mesh_criteria_3<Tr> Mesh_criteria;

// To avoid verbose function and named parameters call
using namespace CGAL::parameters;

const char* const filenames[] = {   
     "data/6/01.off",
     "data/6/21.off",
     "data/6/02.off",
     "data/6/32.off",
     "data/6/03.off",
     "data/6/43.off",
     "data/6/04.off",
     "data/6/54.off",
     "data/6/53.off",
     "data/6/52.off",
     "data/6/51.off",
     "data/6/05.off",
     "data/6/06.off",
     "data/6/76.off",
     "data/6/07.off",
     "data/6/87.off",
     "data/6/08.off",
     "data/6/58.off",
     "data/6/57.off",
     "data/6/56.off",   
     "data/6/05-2.off", 

 };

const std::pair<int, int> incident_subdomains[] = {
  std::make_pair(0, 1),
  std::make_pair(2, 1),
  std::make_pair(0, 2),
  std::make_pair(3, 2),
  std::make_pair(0, 3),
  std::make_pair(4, 3),
  std::make_pair(0, 4),
  std::make_pair(5, 4),
  std::make_pair(5, 3),
  std::make_pair(5, 2),
  std::make_pair(5, 1),
  std::make_pair(0, 5),
  std::make_pair(0, 6),
  std::make_pair(7, 6),
  std::make_pair(0, 7),
  std::make_pair(8, 7),
  std::make_pair(0, 8),
  std::make_pair(5, 8),
  std::make_pair(5, 7),
  std::make_pair(5, 6),
  std::make_pair(0, 5),

};

int main()
{
  const std::size_t nb_patches = sizeof(filenames) / sizeof(const char*);

  CGAL_assertion(sizeof(incident_subdomains) ==
                 nb_patches * sizeof(std::pair<int, int>));

  std::vector<Polyhedron> patches(nb_patches);

  for(std::size_t i = 0; i < nb_patches; ++i) {
    std::ifstream input(filenames[i]);
    if(!(input >> patches[i])) {
      std::cerr << "Error reading " << filenames[i] << " as a polyhedron!\n";
      return EXIT_FAILURE;
      }
    else
    {
        std::cout << "reading " << filenames[i] << " as a polyhedron!\n";
    }
    }

  // Create domain
  Mesh_domain domain(patches.begin(), patches.end(),
                     incident_subdomains, incident_subdomains+nb_patches);

  domain.detect_features(); //includes detection of borders

  std::cout << "detect feature is done\n" ;

  // Mesh criteria
  Mesh_criteria criteria(edge_size = 5,
      facet_angle = 25, facet_size = 5, facet_distance = 5,
      cell_radius_edge_ratio = 2, cell_size =10);

  // Mesh generation
  C3t3 c3t3 = CGAL::make_mesh_3<C3t3>(domain, criteria);
  /*no_exude(),
      perturb(sliver_bound = 10, time_limit = 15)*/

  // Output
  std::ofstream medit_file("remadis.mesh");
  c3t3.output_to_medit(medit_file,false,true);

  return EXIT_SUCCESS;
}

Environment

sloriot commented 5 years ago

There is an error while trying to unzip the attached file:

  End-of-central-directory signature not found.  Either this file is not
  a zipfile, or it constitutes one disk of a multi-part archive.  In the
  latter case the central directory and zipfile comment will be found on
  the last disk(s) of this archive.
janetournois commented 5 years ago

@sloriot I could uncompress and zip it file2.zip

@wangbowenll I will have a look at it, thanks for this new data set

wangbowenll commented 5 years ago

There is an error while trying to unzip the attached file:

  End-of-central-directory signature not found.  Either this file is not
  a zipfile, or it constitutes one disk of a multi-part archive.  In the
  latter case the central directory and zipfile comment will be found on
  the last disk(s) of this archive.

Dear sloriot @sloriot I have re-update the file. off file.zip

janetournois commented 5 years ago

As mentioned in issues #3852 and #3870, you should make sure that

wangbowenll commented 5 years ago

As mentioned in issues #3852 and #3870, you should make sure that

  • sub-surfaces are exactly conformal (exact same points, same segments on boundaries that should represent the same boundary)
  • pairs of subdomains are given like pair<subdomainA, subdomainB> such as subdomainA is on the positively oriented "side" of the triangulated surface

Dear janetournois Thanks for you help and guide.I am really appreciated to you .I will check my model again. but there is still question. when inputing surface,what should be done to know the oriention. I read documation about meshdomain3 and meshdomainwithfeatures3. but i cannot find reletive function to know the surface oriention so that pairs of subdomains given always wrong.

janetournois commented 5 years ago

The answer is not in the meshing documentation. You can use CGAL::orientation() to check the orientation of faces on polyhedral surfaces, seen from inside incident subdomains.

wangbowenll commented 5 years ago

Dear @janetournois Thanks for you guide.I check the orientation of surface patches. and the point p,q,r can be found in OFF file.but it still have exception. what am i missing except orientation and subdomain index. #3897