19 #include "libmesh/libmesh_config.h" 
   21 #ifdef LIBMESH_HAVE_TRIANGLE 
   26 #include "libmesh/mesh_triangle_interface.h" 
   27 #include "libmesh/unstructured_mesh.h" 
   28 #include "libmesh/face_tri3.h" 
   29 #include "libmesh/face_tri6.h" 
   30 #include "libmesh/mesh_generation.h" 
   31 #include "libmesh/mesh_smoother_laplace.h" 
   32 #include "libmesh/boundary_info.h" 
   33 #include "libmesh/mesh_triangle_holes.h" 
   34 #include "libmesh/mesh_triangle_wrapper.h" 
   35 #include "libmesh/enum_elem_type.h" 
   53     _triangulation_type(GENERATE_CONVEX_HULL),
 
   54     _insert_extra_points(false),
 
   55     _smooth_after_generating(true),
 
   66   const bool have_holes = ((
_holes != 
nullptr) && (!
_holes->empty()));
 
   80       std::vector<Point> original_points;
 
   83         original_points.push_back(*node);
 
   94       for (std::size_t np=0, n=0, tops=2*original_points.size(); np<tops; ++np)
 
  113   unsigned int n_hole_points = 0;
 
  116     for (
const auto & hole : *
_holes)
 
  118       n_hole_points += hole->n_points();
 
  123       libmesh_assert_greater(hole->segment_indices().size(), 1);
 
  124       libmesh_assert_equal_to(hole->segment_indices().back(), hole->n_points());
 
  128   TriangleWrapper::triangulateio initial;
 
  129   TriangleWrapper::triangulateio 
final;
 
  130   TriangleWrapper::triangulateio voronoi;
 
  137   initial.numberofpoints = 
_mesh.
n_nodes() + n_hole_points;
 
  138   initial.pointlist      = static_cast<REAL*>(std::malloc(initial.numberofpoints * 2 * 
sizeof(
REAL)));
 
  144         initial.numberofsegments = initial.numberofpoints;
 
  148         initial.numberofsegments = this->segments.size() + n_hole_points;
 
  152     initial.numberofsegments = n_hole_points; 
 
  155   if (initial.numberofsegments > 0)
 
  157       initial.segmentlist = static_cast<int *> (std::malloc(initial.numberofsegments * 2 * 
sizeof(
int)));
 
  159         initial.segmentmarkerlist = static_cast<int *> (std::malloc(initial.numberofsegments * 
sizeof(
int)));
 
  167   unsigned int hole_offset=0;
 
  170     for (
const auto & hole : *
_holes)
 
  172         for (
unsigned int ctr=0, h=0, i=0, hsism=hole->segment_indices().size()-1; i<hsism; ++i)
 
  174             unsigned int begp = hole_offset + hole->segment_indices()[i];
 
  175             unsigned int endp = hole->segment_indices()[i+1];
 
  177             for (; h<endp; ctr+=2, ++h)
 
  179                 Point p = hole->point(h);
 
  181                 const unsigned int index0 = 2*hole_offset+ctr;
 
  182                 const unsigned int index1 = 2*hole_offset+ctr+1;
 
  185                 initial.pointlist[index0] = p(0);
 
  186                 initial.pointlist[index1] = p(1);
 
  189                 initial.segmentlist[index0] = hole_offset+h;
 
  190                 initial.segmentlist[index1] = (h == endp - 1) ? begp : hole_offset + h + 1; 
 
  193                   initial.segmentmarkerlist[hole_offset+h] = 1;
 
  198         hole_offset += hole->n_points();
 
  210         initial.pointlist[index] = (*node)(0);
 
  211         initial.pointlist[index+1] = (*node)(1);
 
  220                 initial.segmentlist[index] = hole_offset+n;
 
  221                 initial.segmentlist[index+1] = (n==
_mesh.
n_nodes()-1) ? hole_offset : hole_offset+n+1; 
 
  223                   initial.segmentmarkerlist[hole_offset + n] = (*_markers)[n];
 
  233   for (std::size_t ctr=0, s=0, ss=this->
segments.size(); s<ss; ctr+=2, ++s)
 
  235       const unsigned int index0 = 2*hole_offset+ctr;
 
  236       const unsigned int index1 = 2*hole_offset+ctr+1;
 
  238       initial.segmentlist[index0] = hole_offset + this->
segments[s].first;
 
  239       initial.segmentlist[index1] = hole_offset + this->
segments[s].second;
 
  241         initial.segmentmarkerlist[hole_offset + s] = (*_markers)[s];
 
  249       initial.numberofholes = 
_holes->size();
 
  250       initial.holelist      = static_cast<REAL*>(std::malloc(initial.numberofholes * 2 * 
sizeof(
REAL)));
 
  251       for (std::size_t i=0, ctr=0, hs=
_holes->size(); i<hs; ++i, ctr+=2)
 
  253           Point inside_point = (*_holes)[i]->inside();
 
  254           initial.holelist[ctr]   = inside_point(0);
 
  255           initial.holelist[ctr+1] = inside_point(1);
 
  261       initial.numberofregions = 
_regions->size();
 
  262       initial.regionlist      = static_cast<REAL*>(std::malloc(initial.numberofregions * 4 * 
sizeof(
REAL)));
 
  263       for (std::size_t i=0, ctr=0, rs=
_regions->size(); i<rs; ++i, ctr+=4)
 
  265           Point inside_point = (*_regions)[i]->inside();
 
  266           initial.regionlist[ctr]   = inside_point(0);
 
  267           initial.regionlist[ctr+1] = inside_point(1);
 
  268           initial.regionlist[ctr+2] = (*_regions)[i]->attribute();
 
  269           initial.regionlist[ctr+3] = (*_regions)[i]->max_area();
 
  293   std::ostringstream flags;
 
  322       libmesh_error_msg(
"ERROR: INVALID_TRIANGULATION_TYPE selected!");
 
  325       libmesh_error_msg(
"Unrecognized _triangulation_type");
 
  345       libmesh_error_msg(
"ERROR: Unrecognized triangular element type.");
 
  373     TriangleWrapper::triangulate(const_cast<char *>(flags.str().c_str()),
 
  386     TriangleWrapper::triangulate(const_cast<char *>(flags.str().c_str()),
 
  423 #endif // LIBMESH_HAVE_TRIANGLE