21 #ifdef LIBMESH_HAVE_TRIANGLE 51 _triangulation_type(GENERATE_CONVEX_HULL),
52 _insert_extra_points(false),
53 _smooth_after_generating(true),
63 const bool have_holes = ((
_holes !=
nullptr) && (!
_holes->empty()));
77 std::vector<Point> original_points;
80 original_points.push_back(*node);
91 for (std::size_t np=0, n=0; np<2*original_points.size(); ++np)
108 unsigned int n_hole_points = 0;
112 for (std::size_t i=0; i<
_holes->size(); ++i)
113 n_hole_points += (*
_holes)[i]->n_points();
117 TriangleWrapper::triangulateio initial;
118 TriangleWrapper::triangulateio
final;
124 initial.numberofpoints =
_mesh.
n_nodes() + n_hole_points;
125 initial.pointlist =
static_cast<REAL*
>(std::malloc(initial.numberofpoints * 2 *
sizeof(
REAL)));
131 initial.numberofsegments = initial.numberofpoints;
135 initial.numberofsegments = this->segments.size();
139 initial.numberofsegments = n_hole_points;
145 if (initial.numberofsegments > 0)
147 initial.segmentlist =
static_cast<int *
> (std::malloc(initial.numberofsegments * 2 *
sizeof(
int)));
155 unsigned int hole_offset=0;
158 for (std::size_t i=0; i<
_holes->size(); ++i)
160 for (
unsigned int ctr=0, h=0; h<(*_holes)[i]->n_points(); ctr+=2, ++h)
162 Point p = (*_holes)[i]->point(h);
164 const unsigned int index0 = 2*hole_offset+ctr;
165 const unsigned int index1 = 2*hole_offset+ctr+1;
168 initial.pointlist[index0] = p(0);
169 initial.pointlist[index1] = p(1);
172 initial.segmentlist[index0] = hole_offset+h;
173 initial.segmentlist[index1] = (h==(*_holes)[i]->n_points()-1) ? hole_offset : hole_offset+h+1;
177 hole_offset += (*_holes)[i]->n_points();
189 initial.pointlist[index] = (*node)(0);
190 initial.pointlist[index+1] = (*node)(1);
199 initial.segmentlist[index] = hole_offset+n;
200 initial.segmentlist[index+1] = (n==
_mesh.
n_nodes()-1) ? hole_offset : hole_offset+n+1;
210 for (std::size_t ctr=0, s=0; s<this->
segments.size(); ctr+=2, ++s)
212 const unsigned int index0 = 2*hole_offset+ctr;
213 const unsigned int index1 = 2*hole_offset+ctr+1;
215 initial.segmentlist[index0] = hole_offset + this->
segments[s].first;
216 initial.segmentlist[index1] = hole_offset + this->
segments[s].second;
224 initial.numberofholes =
_holes->size();
225 initial.holelist =
static_cast<REAL*
>(std::malloc(initial.numberofholes * 2 *
sizeof(
REAL)));
226 for (std::size_t i=0, ctr=0; i<
_holes->size(); ++i, ctr+=2)
228 Point inside_point = (*_holes)[i]->inside();
229 initial.holelist[ctr] = inside_point(0);
230 initial.holelist[ctr+1] = inside_point(1);
252 std::ostringstream flags;
273 libmesh_error_msg(
"ERROR: INVALID_TRIANGULATION_TYPE selected!");
276 libmesh_error_msg(
"Unrecognized _triangulation_type");
296 libmesh_error_msg(
"ERROR: Unrecognized triangular element type.");
318 TriangleWrapper::triangulate(const_cast<char *>(flags.str().c_str()),
353 #endif // LIBMESH_HAVE_TRIANGLE
virtual void smooth() override
static const Real TOLERANCE
TriangulationType _triangulation_type
virtual Node * add_point(const Point &p, const dof_id_type id=DofObject::invalid_id, const processor_id_type proc_id=DofObject::invalid_processor_id)=0
const std::vector< Hole * > * _holes
Base class for Replicated and Distributed meshes.
void copy_tri_to_mesh(const triangulateio &triangle_data_input, UnstructuredMesh &mesh_output, const ElemType type)
bool _insert_extra_points
virtual SimpleRange< node_iterator > node_ptr_range()=0
void init(triangulateio &t)
void prepare_for_use(const bool skip_renumber_nodes_and_elements=false, const bool skip_find_neighbors=false)
void set_mesh_dimension(unsigned char d)
std::vector< std::pair< unsigned int, unsigned int > > segments
bool _smooth_after_generating
void destroy(triangulateio &t, IO_Type)
A geometric point in (x,y,z) space.
virtual dof_id_type n_nodes() const =0
TriangleInterface(UnstructuredMesh &mesh)