CGAL::Polyhedron_3<Traits>

转自:http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Polyhedron_ref/Class_Polyhedron_3.html#Cross_link_anchor_1110

Definition

A polyhedral surface Polyhedron_3<Traits> consists of vertices V, edges E, facets F and an incidence relation on them. Each edge is represented by two halfedges with opposite orientations.

 

Halfedge Diagram

Vertices represent points in 3d-space. Edges are straight line segments between two endpoints. Facets are planar polygons without holes defined by the circular sequence of halfedges along their boundary. The polyhedral surface itself can have holes. The halfedges along the boundary of a hole are called border halfedges and have no incident facet. An edge is a border edge if one of its halfedges is a border halfedge. A surface is closed if it contains no border halfedges. A closed surface is a boundary representation for polyhedra in three dimensions. The convention is that the halfedges are oriented counterclockwise around facets as seen from the outside of the polyhedron. An implication is that the halfedges are oriented clockwise around the vertices. The notion of the solid side of a facet as defined by the halfedge orientation extends to polyhedral surfaces with border edges although they do not define a closed object. If normal vectors are considered for the facets, normals point outwards (following the right hand rule).

The strict definition can be found in [Ket99]. One implication of this definition is that the polyhedral surface is always an orientable and oriented 2-manifold with border edges, i.e., the neighborhood of each point on the polyhedral surface is either homeomorphic to a disc or to a half disc, except for vertices where many holes and surfaces with boundary can join. Another implication is that the smallest representable surface is a triangle (for polyhedral surfaces with border edges) or a tetrahedron (for polyhedra). Boundary representations of orientable 2-manifolds are closed under Euler operations. They are extended with operations that create or close holes in the surface.

Other intersections besides the incidence relation are not allowed, although they are not automatically handled, since self intersections are not easy to check efficiently. Polyhedron_3<Traits> does only maintain the combinatorial integrity of the polyhedral surface (using Euler operations) and does not consider the coordinates of the points or any geometric information.

The class Polyhedron_3<Traits> can represent polyhedral surfaces as well as polyhedra. The interface is designed in such a way that it is easy to ignore border edges and work only with polyhedra.

The sequence of edges can be ordered in the data structure on request such that the sequence starts with the non-border edges and ends with the border edges. Border edges are then itself ordered such that the halfedge which is incident to the facet comes first and the halfedge incident to the hole comes thereafter. This normalization step counts simultaneously the number of border edges. This number is zero if and only if the surface is a closed polyhedron. Note that this class does not maintain this counter nor the halfedge order during further modifications. There is no automatic caching done for auxiliary information.

#include <CGAL/Polyhedron_3.h>

Parameters

The full template declaration of Polyhedron_3<Traits> states four template parameters:

template <class PolyhedronTraits_3,
class PolyhedronItems_3 = CGAL::Polyhedron_items_3,
template < class T, class I> class HalfedgeDS = CGAL::HalfedgeDS_default,
class Alloc = CGAL_ALLOCATOR(int)>
class Polyhedron_3;

The first parameter requires a model of the PolyhedronTraits_3 concept as argument, for example CGAL::Polyhedron_traits_3. The second parameter expects a model of the PolyhedronItems_3 concept. By default, the class CGAL::Polyhedron_items_3 is preselected. The third parameter is a class template. A model of the HalfedgeDS concept is expected. By default, the class CGAL::HalfedgeDS_default is preselected, which is a list based implementation of the halfedge data structure. The fourth parameter Alloc requires a standard allocator for STL container classes. The rebind mechanism from Alloc will be used to create appropriate allocators internally. A default is provided with the macro CGAL_ALLOCATOR(int) from the <CGAL/memory.h> header file.

Types

Polyhedron_3<Traits>::Traits
 traits class selected for PolyhedronTraits_3.

Polyhedron_3<Traits>::Items
 items class selected for PolyhedronItems_3.

Polyhedron_3<Traits>::HalfedgeDS
 instantiated halfedge data structure.

 
Polyhedron_3<Traits>::size_type
 size type of HalfedgeDS.

Polyhedron_3<Traits>::difference_type
 difference type of HalfedgeDS.

Polyhedron_3<Traits>::iterator_category
 iterator category of HalfedgeDS for all iterators.

Polyhedron_3<Traits>::circulator_category
 circulator category of all circulators; bidirectional category if the Items::Halfedge provides a prev() member function, otherwise forward category.

Polyhedron_3<Traits>::allocator_type
 allocator type Alloc.

 
Polyhedron_3<Traits>::Vertex
 vertex type.

Polyhedron_3<Traits>::Halfedge
 halfedge type.

Polyhedron_3<Traits>::Facet
 facet type.

 
Polyhedron_3<Traits>::Point_3
 point stored in vertices.

Polyhedron_3<Traits>::Plane_3
 plane equation stored in facets (if supported).

The following handles, iterators, and circulators have appropriate non-mutable counterparts, i.e., const_handle, const_iterator, and const_circulator. The mutable types are assignable to their non-mutable counterparts. Both circulators are assignable to the Halfedge_iterator. The iterators are assignable to the respective handle types. Wherever the handles appear in function parameter lists, the corresponding iterators can be used as well. For convenience, the Edge_iterator enumerates every other halfedge. It is based on the CGAL::N_step_adaptor class. For convenience, the Point_iterator enumerates all points in the polyhedral surface in the same order as the Vertex_iterator, but with the value type Point. It is based on the CGAL::Iterator_project adaptor. Similarly, a Plane_iterator is provided.

Polyhedron_3<Traits>::Vertex_handle
 handle to vertex.

Polyhedron_3<Traits>::Halfedge_handle
 handle to halfedge.

Polyhedron_3<Traits>::Facet_handle
 handle to facet.

 
Polyhedron_3<Traits>::Vertex_iterator
 iterator over all vertices.

Polyhedron_3<Traits>::Halfedge_iterator
 iterator over all halfedges.

Polyhedron_3<Traits>::Facet_iterator
 iterator over all facets.

 
Polyhedron_3<Traits>::Halfedge_around_vertex_circulator
 circulator of halfedges around a vertex (cw).

Polyhedron_3<Traits>::Halfedge_around_facet_circulator
 circulator of halfedges around a facet (ccw).

 
Polyhedron_3<Traits>::Edge_iterator
 iterator over all edges (every other halfedge).

Polyhedron_3<Traits>::Point_iterator
 iterator over all points.

Polyhedron_3<Traits>::Plane_iterator
 iterator over all plane equations.

Types for Tagging Optional Features

The following types are equal to either CGAL::Tag_true or CGAL::Tag_false, depending on whether the named feature is supported or not.

Polyhedron_3<Traits>::Supports_vertex_halfedge
 Vertex::halfedge().

Polyhedron_3<Traits>::Supports_vertex_point
 Vertex::point().

Polyhedron_3<Traits>::Supports_halfedge_prev
 Halfedge::prev().

Polyhedron_3<Traits>::Supports_halfedge_vertex
 Halfedge::vertex().

Polyhedron_3<Traits>::Supports_halfedge_facet
 Halfedge::facet().

Polyhedron_3<Traits>::Supports_facet_halfedge
 Facet::halfedge().

Polyhedron_3<Traits>::Supports_facet_plane
 Facet::plane().

Polyhedron_3<Traits>::Supports_removal
 supports removal of individual elements.

Creation

Polyhedron_3<Traits> P ( Traits traits = Traits());
 
Polyhedron_3<Traits> P ( size_type v, size_type h, size_type f, Traits traits = Traits());
 a polyhedron P with storage reserved for v vertices, h halfedges, and f facets. The reservation sizes are a hint for optimizing storage allocation.

void P.reserve ( size_type v, size_type h, size_type f)
  reserve storage for v vertices, h halfedges, and f facets. The reservation sizes are a hint for optimizing storage allocation. If the capacity is already greater than the requested size nothing happens. If the capacity changes all iterators and circulators might invalidate.
 
Halfedge_handle P.make_tetrahedron () a tetrahedron is added to the polyhedral surface. Returns a halfedge of the tetrahedron.
 
Halfedge_handle P.make_tetrahedron ( Point p1, Point p2, Point p3, Point p4)
  a tetrahedron is added to the polyhedral surface with its vertices initialized to p1, p2, p3, and p4. Returns that halfedge of the tetrahedron which incident vertex is initialized to p1. The incident vertex of the next halfedge is p2, and the vertex thereafter is p3. The remaining fourth vertex is initialized to p4.
 
Halfedge_handle P.make_triangle () a triangle with border edges is added to the polyhedral surface. Returns a non-border halfedge of the triangle.
 
Halfedge_handle P.make_triangle ( Point p1, Point p2, Point p3)
  a triangle with border edges is added to the polyhedral surface with its vertices initialized to p1, p2, and p3. Returns that non-border halfedge of the triangle which incident vertex is initialized to p1. The incident vertex of the next halfedge is p2, and the vertex thereafter is p3.

Access Member Functions

bool P.empty () const returns true if P is empty.
 
size_type P.size_of_vertices () const number of vertices.
size_type P.size_of_halfedges () const number of halfedges (incl. border halfedges).
size_type P.size_of_facets () const number of facets.
 
size_type P.capacity_of_vertices () const space reserved for vertices.
size_type P.capacity_of_halfedges () const space reserved for halfedges.
size_type P.capacity_of_facets () const space reserved for facets.
 
size_t P.bytes () const bytes used for the polyhedron.
size_t P.bytes_reserved () const bytes reserved for the polyhedron.
 
allocator_type P.get_allocator () const allocator object.
 
Vertex_iterator P.vertices_begin () iterator over all vertices.
Vertex_iterator P.vertices_end () past-the-end iterator.
Halfedge_iterator P.halfedges_begin () iterator over all halfedges.
Halfedge_iterator P.halfedges_end () past-the-end iterator.
Facet_iterator P.facets_begin () iterator over all facets (excluding holes).
Facet_iterator P.facets_end () past-the-end iterator.
 
Edge_iterator P.edges_begin () iterator over all edges.
Edge_iterator P.edges_end () past-the-end iterator.
 
Point_iterator P.points_begin () iterator over all points.
Point_iterator P.points_end () past-the-end iterator.
 
Plane_iterator P.planes_begin () iterator over all plane equations.
Plane_iterator P.planes_end () past-the-end iterator.
 
Traits P.traits () const returns the traits class.

Combinatorial Predicates

bool P.is_closed () const returns true if there are no border edges.
 
bool P.is_pure_bivalent () const returns true if all vertices have exactly two incident edges.
 
bool P.is_pure_trivalent () const returns true if all vertices have exactly three incident edges.
 
bool P.is_pure_triangle () const returns true if all facets are triangles.
 
bool P.is_pure_quad () const returns true if all facets are quadrilaterals.
 
bool P.is_triangle ( Halfedge_const_handle h) const
  true iff the connected component denoted by h is a triangle.
 
bool P.is_tetrahedron ( Halfedge_const_handle h) const
  true iff the connected component denoted by h is a tetrahedron.

Euler Operators (Combinatorial Modifications)

The following Euler operations modify consistently the combinatorial structure of the polyhedral surface. The geometry remains unchanged.

Euler Operator: Facet 

 

Halfedge_handle P.split_facet ( Halfedge_handle h, Halfedge_handle g)
  splits the facet incident to h and g into two facets with a new diagonal between the two vertices denoted by h and g respectively. The second (new) facet is a copy of the first facet. Returns h->next() after the operation, i.e., the new diagonal. The new face is to the right of the new diagonal, the old face is to the left. The time is proportional to the distance from h to g around the facet.
Precondition: h and g are incident to the same facet. h != g (no loops). h->next() != g and g->next() != h (no multi-edges).
 
Halfedge_handle P.join_facet ( Halfedge_handle h)
  joins the two facets incident to h. The facet incident to h->opposite() gets removed. Both facets might be holes. Returns the predecessor of h around the facet. The invariant join_facet( split_facet( h, g)) returns h and keeps the polyhedron unchanged. The time is proportional to the size of the facet removed and the time to compute h->prev().
Precondition: The degree of both vertices incident to h is at least three (no antennas).
Requirement: Supports_removal CGAL::Tag_true.

Euler Operator: Vertex 

 

Halfedge_handle P.split_vertex ( Halfedge_handle h, Halfedge_handle g)
  splits the vertex incident to h and g into two vertices, the old vertex remains and a new copy is created, and connects them with a new edge. Let hnew be h->next()->opposite() after the split, i.e., a halfedge of the new edge. The split regroups the halfedges around the two vertices. The halfedge sequence hnew, g->next()->opposite(), , h remains around the old vertex, while the halfedge sequence hnew->opposite(), h->next()->opposite() (before the split), , g is regrouped around the new vertex. The split returns hnew, i.e., the new halfedge incident to the old vertex. The time is proportional to the distance from h to g around the vertex.
Precondition: h and g are incident to the same vertex. h != g (antennas are not allowed).
Note: A special application of the split is split_vertex(h,h->next()->opposite()) which is equivalent to an edge split of the halfedge h->next() that creates a new vertex on the halfedge h->next(). See also split_edge(h) below.
 
Halfedge_handle P.join_vertex ( Halfedge_handle h)
  joins the two vertices incident to h. The vertex denoted by h->opposite() gets removed. Returns the predecessor of h around the vertex, i.e., h->opposite()->prev(). The invariant join_vertex( split_vertex( h, g)) returns h and keeps the polyhedron unchanged. The time is proportional to the degree of the vertex removed and the time to compute h->prev() and h->opposite()->prev().
Precondition: The size of both facets incident to h is at least four (no multi-edges).
Requirement: Supports_removal CGAL::Tag_true.
 
Halfedge_handle P.split_edge ( Halfedge_handle h)
  splits the halfedge h into two halfedges inserting a new vertex that is a copy of h->opposite()->vertex(). Is equivalent to split_vertex( h->prev(), h->opposite()). The call of prev() can make this method slower than a direct call of split_vertex() if the previous halfedge is already known and computing it would be costly when the halfedge data structure does not support the prev() member function. Returns the new halfedge hnew pointing to the inserted vertex. The new halfedge is followed by the old halfedge, i.e., hnew->next() == h.
 
Halfedge_handle P.flip_edge ( Halfedge_handle h) performs an edge flip. It returns h after rotating the edge h one vertex in the direction of the face orientation.
Precondition: h != Halfedge_handle() and both facets incident to h are triangles.

Euler Operator: Center Vertex 

 

Halfedge_handle P.create_center_vertex ( Halfedge_handle h)
  barycentric triangulation of h->facet(). Creates a new vertex, a copy of h->vertex(), and connects it to each vertex incident to h->facet() splitting h->facet() into triangles. h remains incident to the original facet, all other triangles are copies of this facet. Returns the halfedge h->next() after the operation, i.e., a halfedge pointing to the new vertex. The time is proportional to the size of the facet.
Precondition: h is not a border halfedge.
 
Halfedge_handle P.erase_center_vertex ( Halfedge_handle g)
  reverses create_center_vertex. Erases the vertex pointed to by g and all incident halfedges thereby merging all incident facets. Only g->facet() remains. The neighborhood of g->vertex() may not be triangulated, it can have larger facets. Returns the halfedge g->prev(). Thus, the invariant h == erase_center_vertex( create_center_vertex(h)) holds if h is not a border halfedge. The time is proportional to the sum of the size of all incident facets.
Precondition: None of the incident facets of g->vertex() is a hole. There are at least two distinct facets incident to the facets that are incident to g->vertex(). (This prevents the operation from collapsing a volume into two facets glued together with opposite orientations, such as would happen with any vertex of a tetrahedron.)
Requirement: Supports_removal CGAL::Tag_true.

Euler Operators Modifying Genus

Euler Operator: Loop

 

Halfedge_handle P.split_loop ( Halfedge_handle h, Halfedge_handle i, Halfedge_handle j)
  cuts the polyhedron into two parts along the cycle (h,i,j) (edge j runs on the backside of the three dimensional figure above). Three new vertices (one copy for each vertex in the cycle) and three new halfedges (one copy for each halfedge in the cycle), and two new triangles are created. h,i,j will be incident to the first new triangle. The return value will be the halfedge incident to the second new triangle which is the copy of h-opposite().
Precondition: h,i,j denote distinct, consecutive vertices of the polyhedron and form a cycle: i.e., h->vertex() == i->opposite()->vertex(), , j->vertex() == h->opposite()->vertex(). The six facets incident to h,i,j are all distinct.
 
Halfedge_handle P.join_loop ( Halfedge_handle h, Halfedge_handle g)
  glues the boundary of the two facets denoted by h and g together and returns h. Both facets and the vertices along the facet denoted by g gets removed. Both facets may be holes. The invariant join_loop( h, split_loop( h, i, j)) returns h and keeps the polyhedron unchanged.
Precondition: The facets denoted by h and g are different and have equal degree (i.e., number of edges).
Requirement: Supports_removal CGAL::Tag_true.

Modifying Facets and Holes

Halfedge_handle P.make_hole ( Halfedge_handle h) removes the incident facet of h and changes all halfedges incident to the facet into border edges. Returns h. See erase_facet(h) for a more generalized variant.
Precondition: None of the incident halfedges of the facet is a border edge.
Requirement: Supports_removal CGAL::Tag_true.
 
Halfedge_handle P.fill_hole ( Halfedge_handle h) fills a hole with a newly created facet. Makes all border halfedges of the hole denoted by h incident to the new facet. Returns h.
Precondition: h.is_border().

Modifying Facets and Holes: add_vertex_and_facet_to_border()

 

Halfedge_handle P.add_vertex_and_facet_to_border ( Halfedge_handle h, Halfedge_handle g)
  creates a new facet within the hole incident to h and g by connecting the tip of g with the tip of h with two new halfedges and a new vertex and filling this separated part of the hole with a new facet, such that the new facet is incident to g. Returns the halfedge of the new edge that is incident to the new facet and the new vertex.
Precondition: h->is_border(), g->is_border(), h != g, and g can be reached along the same hole starting with h.

Modifying Facets and Holes: add_facet_to_border()

 

Halfedge_handle P.add_facet_to_border ( Halfedge_handle h, Halfedge_handle g)
  creates a new facet within the hole incident to h and g by connecting the vertex denoted by g with the vertex denoted by h with a new halfedge and filling this separated part of the hole with a new facet, such that the new facet is incident to g. Returns the halfedge of the new edge that is incident to the new facet.
Precondition: h->is_border(), g->is_border(), h != g, h->next() != g, and g can be reached along the same hole starting with h.

Erasing

void P.erase_facet ( Halfedge_handle h)
  removes the incident facet of h and changes all halfedges incident to the facet into border edges or removes them from the polyhedral surface if they were already border edges. If this creates isolated vertices they get removed as well. See make_hole(h) for a more specialized variant.
Precondition: h->is_border() == false.
Requirement: Supports_removal CGAL::Tag_true.
 
void P.erase_connected_component ( Halfedge_handle h)
  removes the vertices, halfedges, and facets that belong to the connected component of h.
Requirement: Supports_removal CGAL::Tag_true.
 
unsigned int P.keep_largest_connected_components ( unsigned int nb_components_to_keep)
  Erases the small connected components and the isolated vertices. Keep nb_components_to_keep largest connected components. Returns the number of connected components erased (ignoring isolated vertices).
Requirement: supports vertices, halfedges, and removal operation.
 
void P.clear () removes all vertices, halfedges, and facets.

Operations with Border Halfedges

Halfedges incident to a hole are called border halfedges. An halfedge is a border edge if itself or its opposite halfedge are border halfedges. The only requirement to work with border halfedges is that the Halfedge class provides a member function is_border() returning a bool. Usually, the halfedge data structure supports facets and a NULL facet pointer will indicate a border halfedge, but this is not the only possibility. The is_border() predicate divides the edges into two classes, the border edges and the non-border edges. The following normalization reorganizes the sequential storage of the edges such that the non-border edges precede the border edges, and that for each border edge the latter one of the two halfedges is a border halfedge (the first one is a non-border halfedge in conformance with the polyhedral surface definition). The normalization stores the number of border halfedges and the halfedge iterator the border edges start at within the data structure. Halfedge insertion or removal and changing the border status of a halfedge invalidate these values. They are not automatically updated.

void P.normalize_border () sorts halfedges such that the non-border edges precede the border edges. For each border edge the halfedge iterator will reference the halfedge incident to the facet right before the halfedge incident to the hole.
 
size_type P.size_of_border_halfedges () const
  number of border halfedges.
Precondition: last normalize_border() call still valid, see above.
 
size_type P.size_of_border_edges () const number of border edges. Since each border edge of a polyhedral surface has exactly one border halfedge, this number is equal to size_of_border_halfedges().
Precondition: last normalize_border() call still valid, see above.
 
Halfedge_iterator P.border_halfedges_begin () halfedge iterator starting with the border edges. The range [halfedges_begin(), border_halfedges_begin()) denotes all non-border halfedges. The range [border_halfedges_begin(), halfedges_end()) denotes all border edges.
Precondition: last normalize_border() call still valid, see above.
 
Edge_iterator P.border_edges_begin () edge iterator starting with the border edges. The range [edges_begin(), border_edges_begin()) denotes all non-border edges. The range [border_edges_begin(), edges_end()) denotes all border edges.
Precondition: last normalize_border() call still valid, see above.

Miscellaneous

void P.inside_out () reverses facet orientations (incl. plane equations if supported).
 
bool P.is_valid ( bool verbose = false, int level = 0) const
  returns true if the polyhedral surface is combinatorially consistent. If verbose is true, statistics are printed to cerr. For level == 1 the normalization of the border edges is checked too. This method checks in particular level 3 of CGAL::Halfedge_data_structure_decorator::is_valid from page 26.3 and that each facet is at least a triangle and that the two incident facets of a non-border edge are distinct.
 
bool P.normalized_border_is_valid ( bool verbose = false) const
  returns true if the border halfedges are in normalized representation, which is when enumerating all halfedges with the iterator: The non-border edges precede the border edges and for border edges, the second halfedge is the border halfedge. The halfedge iterator border_halfedges_begin() denotes the first border edge. If verbose is true, statistics are printed to cerr.

void P.delegate ( CGAL::Modifier_base<HDS>& m)
  calls the operator() of the modifier m. See CGAL::Modifier_base for a description of modifier design and its usage.
Precondition: The polyhedral surface must be valid when the modifier returns from execution.

See Also

CGAL::Polyhedron_3<Traits>::Vertex
CGAL::Polyhedron_3<Traits>::Halfedge
CGAL::Polyhedron_3<Traits>::Facet
PolyhedronTraits_3
CGAL::Polyhedron_traits_3<Kernel>
PolyhedronItems_3
CGAL::Polyhedron_items_3
HalfedgeDS
CGAL::HalfedgeDS_default
CGAL::Polyhedron_incremental_builder_3<HDS>
CGAL::Modifier_base
.

Example

This example program instantiates a polyhedron using the default traits class and creates a tetrahedron.

File: examples/Polyhedron/polyhedron_prog_simple.cpp

 

生成开始于 0:28... 1>------ 已启动生成: 项目: TestOpenGL, 配置: Release x64 ------ 1>AmbientLight.cpp 1>CncEngine.cpp 1>E:\临时项目\CGAL\TestOpenGL\TestOpenGL\CncEngine.cpp(450,7): error C2039: "generator_params": 不是 "CGAL::Named_function_parameters<CGAL::Surface_mesh<Geometry::Point_3>::Property_map<CGAL::Surface_mesh<Geometry::Point_3>::Vertex_index,CGAL::Point_3<Kernel_>>,CGAL::internal_np::vertex_point_t,CGAL::internal_np::No_property>" 的成员 1>E:\临时项目\CGAL\TestOpenGL\TestOpenGL\CncEngine.cpp(450,7): error C2039: with 1>E:\临时项目\CGAL\TestOpenGL\TestOpenGL\CncEngine.cpp(450,7): error C2039: [ 1>E:\临时项目\CGAL\TestOpenGL\TestOpenGL\CncEngine.cpp(450,7): error C2039: Kernel_=CGAL::Epeck 1>E:\临时项目\CGAL\TestOpenGL\TestOpenGL\CncEngine.cpp(450,7): error C2039: ] 1>(编译源文件“/CncEngine.cpp”) 1> E:\临时项目\CGAL\TestOpenGL\inc\CGAL-6.0.1\include\CGAL\Named_function_parameters.h(336,8): 1> 参见“CGAL::Named_function_parameters<CGAL::Surface_mesh<Geometry::Point_3>::Property_map<CGAL::Surface_mesh<Geometry::Point_3>::Vertex_index,CGAL::Point_3<Kernel_>>,CGAL::internal_np::vertex_point_t,CGAL::internal_np::No_property>”的声明 1> with 1> [ 1> Kernel_=CGAL::Epeck 1> ] 1>E:\临时项目\CGAL\TestOpenGL\TestOpenGL\CncEngine.cpp(451,25): error C2039: "delaunay_mesher": 不是 "CGAL::parameters" 的成员 1>(编译源文件“/CncEngine.cpp”) 1> E:\临时项目\CGAL\TestOpenGL\inc\CGAL-6.0.1\include\CGAL\Named_function_parameters.h(426,11): 1> 参见“CGAL::parameters”的声明 1>E:\临时项目\CGAL\TestOpenGL\TestOpenGL\CncEngine.cpp(451,25): error C3861: “delaunay_mesher”: 找不到标识符 1>(编译源文件“/CncEngine.cpp”) 1>E:\临时项目\CGAL\TestOpenGL\TestOpenGL\CncEngine.cpp(445,18): error C2440: “初始化”: 无法从“OutputIterator”转换为“bool” 1>E:\临时项目\CGAL\TestOpenGL\TestOpenGL\CncEngine.cpp(445,18): error C2440: with 1>E:\临时项目\CGAL\TestOpenGL\TestOpenGL\CncEngine.cpp(445,18): error C2440: [ 1>E:\临时项目\CGAL\TestOpenGL\TestOpenGL\CncEngine.cpp(445,18): error C2440: OutputIterator=std::back_in
最新发布
03-15
<think>嗯,用户在使用CGAL 6.0.1时遇到了编译错误,涉及C2039和C3861错误,具体是关于Named_function_parameters.h头文件以及delaunay_mesher和generator_params成员不存在的问题。我需要先理解这些错误的可能原因。 首先,用户提到的C2039错误通常表示编译器找不到某个成员或标识符,而C3861则是指标识符未找到。结合错误信息,可能的原因包括头文件缺失、命名空间变化或API更新。CGAL在版本升级时可能会有一些API变动,特别是从旧版本升级到6.0.1时,某些函数或参数可能被弃用或移动到不同的命名空间。 接下来,查看用户提供的引用内容。引用[1]提到了CGAL::Triangulation_2及其子类,如Delaunay_triangulation_2,这可能与Delaunay网格生成相关。引用[3]提到了配置问题,比如缺少DLL或依赖库的问题,但用户的问题更可能是代码层面的,而非运行时依赖。引用[4]提到了Surface_Mesh的使用,可能和网格处理有关,但当前问题集中在编译错误,所以可能需要关注头文件和API的变化。 CGAL 6.0.1中的generator_params和delaunay_mesher可能属于旧版本的API。例如,Named_function_parameters.h可能在较新版本中被替换为更现代的命名参数机制。用户可能在代码中使用了旧的命名参数方式,导致编译器找不到对应的头文件和成员。 查阅CGAL的文档更新日志,发现从版本5.x到6.x,部分命名参数的使用方式有所调整。例如,旧版本可能使用generator_params来传递参数,而新版本可能需要使用命名参数函数,如parameters::mesh或parameters::lloyd等。此外,头文件Named_function_parameters.h可能在6.0.1中已被弃用,替换为其他头文件或直接使用参数生成器。 因此,解决方案可能包括更新头文件引用,替换旧的命名参数调用方式,并检查相关的命名空间。例如,将#include <CGAL/Named_function_parameters.h>替换为新的头文件,或者直接使用parameters命名空间下的新函数。另外,delaunay_mesher可能已被整合到不同的模块中,需要使用新的函数名或方法。 还需要检查用户的代码中是否有遗漏的命名空间,比如是否缺少CGAL::或某个子命名空间。此外,确保所有相关的CGAL模块在编译时正确链接,例如可能需要添加特定的编译选项或库依赖,如引用[2]中提到的Qt组件链接方式。 总结可能的解决步骤:更新头文件、替换命名参数语法、检查API变更文档、确保正确命名空间和链接库。此外,参考用户提供的引用[3],可能需要检查系统环境变量和依赖库的路径,尽管问题更可能出在代码兼容性上。</think>### 解答:修复CGAL 6.0.1中`generator_params`和`delaunay_mesher`编译错误 #### 1. **错误原因分析** - **C2039错误**:`generator_params`或`delaunay_mesher`成员未声明,通常由以下原因导致: - **API变更**:CGAL 6.x版本可能弃用了旧版本的命名参数机制(例如`generator_params`)[^1]。 - **头文件缺失**:`Named_function_parameters.h`可能在CGAL 6.0.1中已合并或重命名。 - **C3861错误**:标识符未找到,通常与命名空间或函数名变更有关。 --- #### 2. **具体修复步骤** ##### (1) **更新头文件引用** - **旧代码**中可能包含: ```cpp #include <CGAL/Named_function_parameters.h> ``` - **新版本**中需替换为: ```cpp #include <CGAL/boost/helpers/named_params.h> // 或者检查最新文档确认头文件 ``` ##### (2) **替换命名参数语法** - **旧版参数传递方式**(已弃用): ```cpp CGAL::make_delaunay_mesh_3(...).delaunay_mesher(...).generator_params(...) ``` - **新版参数传递方式**: ```cpp #include <CGAL/Mesh_3/parameters.h> using namespace CGAL::parameters; // 使用命名参数函数(如parameters::mesh) CGAL::make_delaunay_mesh_3(..., mesh(...).lloyd(...)); ``` ##### (3) **检查API变更** - **`delaunay_mesher`**:可能已被整合为独立的函数,例如: ```cpp CGAL::refine_Delaunay_mesh_3(...); // 具体名称需参考CGAL 6.0文档 ``` ##### (4) **配置验证** - 确保CMakeLists正确链接CGAL模块: ```cmake find_package(CGAL REQUIRED COMPONENTS Core) # 根据需要添加组件[^2] target_link_libraries(your_target PRIVATE CGAL::CGAL) ``` --- #### 3. **代码示例修正** ```cpp #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> // 关键头文件变更 using namespace CGAL::parameters; // 使用新命名空间 int main() { // 使用新版参数传递 CGAL::Mesh_criteria_3<Tr> criteria( facet_angle=30, facet_size=0.1, cell_radius_edge_ratio=2 ); // 生成网格 CGAL::make_mesh_3<C3t3>(domain, criteria); } ``` --- #### 4. **补充建议** - **查阅文档**:参考[CGAL 6.0手册](https://doc.cgal.org/latest/Manual/)中关于Delaunay网格生成的章节。 - **依赖检查**:确保系统已正确安装MPFR、GMP等依赖库(避免类似`mpfr_get_d`未定义错误)[^3]。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值