61 const bool have_holes = ((
_holes !=
nullptr) && (!
_holes->empty()));
81 TriangleWrapper::triangulateio initial;
82 TriangleWrapper::triangulateio
final;
83 TriangleWrapper::triangulateio voronoi;
90 initial.numberofpoints =
_mesh.
n_nodes() + n_hole_points;
91 initial.pointlist =
static_cast<REAL*
>(std::malloc(initial.numberofpoints * 2 *
sizeof(
REAL)));
97 initial.numberofsegments = initial.numberofpoints;
101 initial.numberofsegments = this->
segments.size() + n_hole_points;
105 initial.numberofsegments = n_hole_points;
108 if (initial.numberofsegments > 0)
110 initial.segmentlist =
static_cast<int *
> (std::malloc(initial.numberofsegments * 2 *
sizeof(
int)));
112 initial.segmentmarkerlist =
static_cast<int *
> (std::malloc(initial.numberofsegments *
sizeof(
int)));
120 unsigned int hole_offset=0;
123 for (
const auto & hole : *
_holes)
125 for (
unsigned int ctr=0, h=0, i=0, hsism=hole->segment_indices().size()-1; i<hsism; ++i)
127 unsigned int begp = hole_offset + hole->segment_indices()[i];
128 unsigned int endp = hole->segment_indices()[i+1];
130 for (; h<endp; ctr+=2, ++h)
132 Point p = hole->point(h);
134 const unsigned int index0 = 2*hole_offset+ctr;
135 const unsigned int index1 = 2*hole_offset+ctr+1;
138 initial.pointlist[index0] = p(0);
139 initial.pointlist[index1] = p(1);
142 initial.segmentlist[index0] = hole_offset+h;
143 initial.segmentlist[index1] = (h == endp - 1) ? begp : hole_offset + h + 1;
146 initial.segmentmarkerlist[hole_offset+h] = 1;
151 hole_offset += hole->n_points();
156 std::vector<unsigned int> libmesh_id_to_pointlist_index(
_mesh.
max_node_id());
159 for (
auto & node :
_mesh.node_ptr_range())
164 initial.pointlist[index] = (*node)(0);
165 initial.pointlist[index+1] = (*node)(1);
166 libmesh_id_to_pointlist_index[node->id()] = ctr/2;
175 initial.segmentlist[index] = hole_offset+n;
176 initial.segmentlist[index+1] = (n==
_mesh.
n_nodes()-1) ? hole_offset : hole_offset+n+1;
178 initial.segmentmarkerlist[hole_offset + n] = (*_markers)[n];
188 for (std::size_t ctr=0, s=0, ss=this->
segments.size(); s<ss; ctr+=2, ++s)
190 const unsigned int index0 = 2*hole_offset+ctr;
191 const unsigned int index1 = 2*hole_offset+ctr+1;
193 initial.segmentlist[index0] = hole_offset +
194 libmesh_id_to_pointlist_index[this->
segments[s].first];
195 initial.segmentlist[index1] = hole_offset +
196 libmesh_id_to_pointlist_index[this->segments[s].second];
198 initial.segmentmarkerlist[hole_offset + s] = (*_markers)[s];
206 initial.numberofholes =
_holes->size();
207 initial.holelist =
static_cast<REAL*
>(std::malloc(initial.numberofholes * 2 *
sizeof(
REAL)));
208 for (std::size_t i=0, ctr=0, hs=
_holes->size(); i<hs; ++i, ctr+=2)
210 Point inside_point = (*_holes)[i]->inside();
211 initial.holelist[ctr] = inside_point(0);
212 initial.holelist[ctr+1] = inside_point(1);
218 initial.numberofregions =
_regions->size();
219 initial.regionlist =
static_cast<REAL*
>(std::malloc(initial.numberofregions * 4 *
sizeof(
REAL)));
220 for (std::size_t i=0, ctr=0, rs=
_regions->size(); i<rs; ++i, ctr+=4)
222 Point inside_point = (*_regions)[i]->inside();
223 initial.regionlist[ctr] = inside_point(0);
224 initial.regionlist[ctr+1] = inside_point(1);
225 initial.regionlist[ctr+2] = (*_regions)[i]->attribute();
226 initial.regionlist[ctr+3] = (*_regions)[i]->max_area();
250 std::ostringstream flags;
279 libmesh_error_msg(
"ERROR: INVALID_TRIANGULATION_TYPE selected!");
282 libmesh_error_msg(
"Unrecognized _triangulation_type");
330 TriangleWrapper::triangulate(
const_cast<char *
>(flags.str().c_str()),
343 TriangleWrapper::triangulate(
const_cast<char *
>(flags.str().c_str()),