pcb 4.1.1
An interactive printed circuit board layout editor.

surface.c File Reference

#include <stdlib.h>
#include <math.h>
#include <string.h>
#include "gts.h"
#include "gts-private.h"
Include dependency graph for surface.c:

Go to the source code of this file.

Data Structures

struct  _GtsSurfaceTraverse

Defines

#define HEAP_INSERT_EDGE(h, e)   (GTS_OBJECT (e)->reserved = gts_eheap_insert (h, e))
#define HEAP_REMOVE_EDGE(h, e)
#define GTS_M_ICOSAHEDRON_X
#define GTS_M_ICOSAHEDRON_Y
#define GTS_M_ICOSAHEDRON_Z   0.0

Functions

static void destroy_foreach_face (GtsFace *f, GtsSurface *s)
static void surface_destroy (GtsObject *object)
static void surface_write (GtsObject *object, FILE *fptr)
static void surface_class_init (GtsSurfaceClass *klass)
static void surface_init (GtsSurface *surface)
GtsSurfaceClassgts_surface_class (void)
GtsSurfacegts_surface_new (GtsSurfaceClass *klass, GtsFaceClass *face_class, GtsEdgeClass *edge_class, GtsVertexClass *vertex_class)
void gts_surface_add_face (GtsSurface *s, GtsFace *f)
void gts_surface_remove_face (GtsSurface *s, GtsFace *f)
guint gts_surface_read (GtsSurface *surface, GtsFile *f)
static void sum_area (GtsFace *f, gdouble *area)
gdouble gts_surface_area (GtsSurface *s)
void gts_range_init (GtsRange *r)
void gts_range_reset (GtsRange *r)
void gts_range_add_value (GtsRange *r, gdouble val)
void gts_range_update (GtsRange *r)
void gts_range_print (GtsRange *r, FILE *fptr)
static void stats_foreach_vertex (GtsVertex *v, GtsSurfaceStats *stats)
static void stats_foreach_edge (GtsEdge *e, GtsSurfaceStats *stats)
static void stats_foreach_face (GtsTriangle *t, GtsSurfaceStats *stats)
void gts_surface_stats (GtsSurface *s, GtsSurfaceStats *stats)
static void quality_foreach_edge (GtsSegment *s, GtsSurfaceQualityStats *stats)
static void quality_foreach_face (GtsTriangle *t, GtsSurfaceQualityStats *stats)
void gts_surface_quality_stats (GtsSurface *s, GtsSurfaceQualityStats *stats)
void gts_surface_print_stats (GtsSurface *s, FILE *fptr)
static void write_vertex (GtsPoint *p, gpointer *data)
static void write_edge (GtsSegment *s, gpointer *data)
static void write_face (GtsTriangle *t, gpointer *data)
void gts_surface_write (GtsSurface *s, FILE *fptr)
static void write_vertex_oogl (GtsPoint *p, gpointer *data)
static void write_face_oogl (GtsTriangle *t, FILE *fp)
void gts_surface_write_oogl (GtsSurface *s, FILE *fptr)
static void write_vertex_vtk (GtsPoint *p, gpointer *data)
static void write_face_vtk (GtsTriangle *t, FILE *fp)
void gts_surface_write_vtk (GtsSurface *s, FILE *fptr)
static void write_edge_oogl_boundary (GtsSegment *s, gpointer *data)
void gts_surface_write_oogl_boundary (GtsSurface *s, FILE *fptr)
static void vertex_foreach_face (GtsTriangle *t, gpointer t_data, gpointer *info)
void gts_surface_foreach_vertex (GtsSurface *s, GtsFunc func, gpointer data)
static void edge_foreach_face (GtsTriangle *t, gpointer t_data, gpointer *info)
void gts_surface_foreach_edge (GtsSurface *s, GtsFunc func, gpointer data)
static void foreach_face (GtsFace *f, gpointer t_data, gpointer *info)
void gts_surface_foreach_face (GtsSurface *s, GtsFunc func, gpointer data)
static gboolean foreach_face_remove (GtsFace *f, gpointer t_data, gpointer *info)
guint gts_surface_foreach_face_remove (GtsSurface *s, GtsFunc func, gpointer data)
static void midvertex_insertion (GtsEdge *e, GtsSurface *surface, GtsEHeap *heap, GtsRefineFunc refine_func, gpointer refine_data, GtsVertexClass *vertex_class, GtsEdgeClass *edge_class)
static gdouble edge_length2_inverse (GtsSegment *s)
static void create_heap_refine (GtsEdge *e, GtsEHeap *heap)
void gts_surface_refine (GtsSurface *surface, GtsKeyFunc cost_func, gpointer cost_data, GtsRefineFunc refine_func, gpointer refine_data, GtsStopFunc stop_func, gpointer stop_data)
static GSList * edge_triangles (GtsEdge *e1, GtsEdge *e)
static void replace_vertex (GSList *i, GtsVertex *v1, GtsVertex *v)
gboolean gts_edge_collapse_creates_fold (GtsEdge *e, GtsVertex *v, gdouble max)
gboolean gts_edge_collapse_is_valid (GtsEdge *e)
static GtsVertexedge_collapse (GtsEdge *e, GtsEHeap *heap, GtsCoarsenFunc coarsen_func, gpointer coarsen_data, GtsVertexClass *klass, gdouble maxcosine2)
static void update_2nd_closest_neighbors (GtsVertex *v, GtsEHeap *heap)
static gdouble edge_length2 (GtsEdge *e)
static void create_heap_coarsen (GtsEdge *e, GtsEHeap *heap)
void gts_surface_coarsen (GtsSurface *surface, GtsKeyFunc cost_func, gpointer cost_data, GtsCoarsenFunc coarsen_func, gpointer coarsen_data, GtsStopFunc stop_func, gpointer stop_data, gdouble minangle)
gboolean gts_coarsen_stop_number (gdouble cost, guint nedge, guint *min_number)
gboolean gts_coarsen_stop_cost (gdouble cost, guint nedge, gdouble *max_cost)
static guint generate_icosahedron (GtsSurface *s)
static GtsVertexunit_sphere_arc_midvertex (GtsSegment *s, GtsVertexClass *vertex_class)
static void tessellate_face (GtsFace *f, GtsSurface *s, GtsRefineFunc refine_func, gpointer refine_data, GtsVertexClass *vertex_class, GtsEdgeClass *edge_class)
static void create_array_tessellate (GtsFace *f, GPtrArray *array)
void gts_surface_tessellate (GtsSurface *s, GtsRefineFunc refine_func, gpointer refine_data)
GtsSurfacegts_surface_generate_sphere (GtsSurface *s, guint geodesation_order)
static void foreach_vertex_copy (GtsPoint *p, GtsVertexClass *klass)
static void foreach_edge_copy (GtsSegment *s, GtsEdgeClass *klass)
static void foreach_face_copy (GtsTriangle *t, GtsSurface *s)
GtsSurfacegts_surface_copy (GtsSurface *s1, GtsSurface *s2)
static void merge_foreach_face (GtsFace *f, GtsSurface *s)
void gts_surface_merge (GtsSurface *s, GtsSurface *with)
static void manifold_foreach_edge (GtsEdge *e, gpointer *data)
gboolean gts_surface_is_manifold (GtsSurface *s)
static void closed_foreach_edge (GtsEdge *e, gpointer *data)
gboolean gts_surface_is_closed (GtsSurface *s)
static void orientable_foreach_edge (GtsEdge *e, gpointer *data)
gboolean gts_surface_is_orientable (GtsSurface *s)
static void volume_foreach_face (GtsTriangle *t, gdouble *volume)
gdouble gts_surface_volume (GtsSurface *s)
static void center_of_mass_foreach_face (GtsTriangle *t, gpointer *data)
gdouble gts_surface_center_of_mass (GtsSurface *s, GtsVector cm)
static void center_of_area_foreach_face (GtsTriangle *t, gpointer *data)
gdouble gts_surface_center_of_area (GtsSurface *s, GtsVector cm)
static void number_foreach (gpointer data, guint *n)
guint gts_surface_vertex_number (GtsSurface *s)
guint gts_surface_edge_number (GtsSurface *s)
guint gts_surface_face_number (GtsSurface *s)
static void build_list_face (GtsTriangle *t, GSList **list)
static void build_list_boundary (GtsEdge *e, GSList **list)
void gts_surface_distance (GtsSurface *s1, GtsSurface *s2, gdouble delta, GtsRange *face_range, GtsRange *boundary_range)
static void surface_boundary (GtsEdge *e, gpointer *data)
GSList * gts_surface_boundary (GtsSurface *surface)
GtsSurfaceTraversegts_surface_traverse_new (GtsSurface *s, GtsFace *f)
static void push_neighbor (GtsFace *v, gpointer *data)
GtsFacegts_surface_traverse_next (GtsSurfaceTraverse *t, guint *level)
void gts_surface_traverse_destroy (GtsSurfaceTraverse *t)
static void traverse_manifold (GtsTriangle *t, GtsSurface *s)
static void non_manifold_edges (GtsEdge *e, gpointer *data)
static void traverse_boundary (GtsEdge *e, gpointer *data)
static void traverse_remaining (GtsFace *f, gpointer *data)
GSList * gts_surface_split (GtsSurface *s)

Define Documentation

#define GTS_M_ICOSAHEDRON_X
Value:
/* sqrt(sqrt(5)+1)/sqrt(2*sqrt(5)) */ \
  0.850650808352039932181540497063011072240401406

Definition at line 1742 of file surface.c.

Referenced by generate_icosahedron().

#define GTS_M_ICOSAHEDRON_Y
Value:
/* sqrt(2)/sqrt(5+sqrt(5))         */ \
  0.525731112119133606025669084847876607285497935

Definition at line 1744 of file surface.c.

Referenced by generate_icosahedron().

#define GTS_M_ICOSAHEDRON_Z   0.0

Definition at line 1746 of file surface.c.

Referenced by generate_icosahedron().

#define HEAP_INSERT_EDGE (   h,
 
)    (GTS_OBJECT (e)->reserved = gts_eheap_insert (h, e))

Definition at line 1491 of file surface.c.

Referenced by create_heap_coarsen(), and update_2nd_closest_neighbors().

#define HEAP_REMOVE_EDGE (   h,
 
)
Value:
(gts_eheap_remove (h, GTS_OBJECT (e)->reserved),\
                                GTS_OBJECT (e)->reserved = NULL)

Definition at line 1492 of file surface.c.

Referenced by edge_collapse(), and update_2nd_closest_neighbors().


Function Documentation

static void build_list_boundary ( GtsEdge e,
GSList **  list 
) [static]

Definition at line 2438 of file surface.c.

References gts_bbox_class(), gts_bbox_segment(), gts_edge_is_boundary(), and GTS_SEGMENT.

Referenced by gts_surface_distance().

Here is the call graph for this function:

static void build_list_face ( GtsTriangle t,
GSList **  list 
) [static]

Definition at line 2433 of file surface.c.

References gts_bbox_class(), and gts_bbox_triangle().

Referenced by gts_surface_distance().

Here is the call graph for this function:

static void center_of_area_foreach_face ( GtsTriangle t,
gpointer *  data 
) [static]

Definition at line 2324 of file surface.c.

References GTS_POINT, gts_triangle_area(), gts_triangle_vertices(), _GtsPoint::x, _GtsPoint::y, and _GtsPoint::z.

Referenced by gts_surface_center_of_area().

Here is the call graph for this function:

static void center_of_mass_foreach_face ( GtsTriangle t,
gpointer *  data 
) [static]

Definition at line 2256 of file surface.c.

References GTS_POINT, gts_triangle_vertices(), _GtsPoint::x, _GtsPoint::y, and _GtsPoint::z.

Referenced by gts_surface_center_of_mass().

Here is the call graph for this function:

static void closed_foreach_edge ( GtsEdge e,
gpointer *  data 
) [static]

Definition at line 2148 of file surface.c.

References FALSE, and gts_edge_face_number().

Referenced by gts_surface_is_closed().

Here is the call graph for this function:

static void create_array_tessellate ( GtsFace f,
GPtrArray *  array 
) [static]

Definition at line 1981 of file surface.c.

Referenced by gts_surface_tessellate().

static void create_heap_coarsen ( GtsEdge e,
GtsEHeap heap 
) [static]

Definition at line 1617 of file surface.c.

References HEAP_INSERT_EDGE.

Referenced by gts_surface_coarsen().

static void create_heap_refine ( GtsEdge e,
GtsEHeap heap 
) [static]

Definition at line 1241 of file surface.c.

References gts_eheap_insert().

Referenced by gts_surface_refine().

Here is the call graph for this function:

static void destroy_foreach_face ( GtsFace f,
GtsSurface s 
) [static]

Definition at line 27 of file surface.c.

References gts_allow_floating_faces, GTS_OBJECT, gts_object_destroy(), GTS_OBJECT_DESTROYED, and _GtsFace::surfaces.

Referenced by surface_destroy().

Here is the call graph for this function:

static GtsVertex* edge_collapse ( GtsEdge e,
GtsEHeap heap,
GtsCoarsenFunc  coarsen_func,
gpointer  coarsen_data,
GtsVertexClass klass,
gdouble  maxcosine2 
) [static]
static void edge_foreach_face ( GtsTriangle t,
gpointer  t_data,
gpointer *  info 
) [static]

Definition at line 998 of file surface.c.

References _GtsTriangle::e1, _GtsTriangle::e2, _GtsTriangle::e3, FALSE, and hash().

Referenced by gts_surface_foreach_edge().

Here is the call graph for this function:

static gdouble edge_length2 ( GtsEdge e) [static]

Definition at line 1611 of file surface.c.

References GTS_POINT, gts_point_distance2(), and GTS_SEGMENT.

Referenced by gts_surface_coarsen().

Here is the call graph for this function:

static gdouble edge_length2_inverse ( GtsSegment s) [static]

Definition at line 1236 of file surface.c.

References GTS_POINT, gts_point_distance2(), _GtsSegment::v1, and _GtsSegment::v2.

Referenced by gts_surface_refine().

Here is the call graph for this function:

static GSList* edge_triangles ( GtsEdge e1,
GtsEdge e 
) [static]
static void foreach_edge_copy ( GtsSegment s,
GtsEdgeClass klass 
) [static]

Definition at line 2056 of file surface.c.

References gts_edge_new(), GTS_OBJECT, _GtsSegment::v1, and _GtsSegment::v2.

Referenced by gts_surface_copy().

Here is the call graph for this function:

static void foreach_face ( GtsFace f,
gpointer  t_data,
gpointer *  info 
) [static]

Definition at line 1060 of file surface.c.

References FALSE.

Referenced by gts_surface_foreach_face().

static void foreach_face_copy ( GtsTriangle t,
GtsSurface s 
) [static]

Definition at line 2063 of file surface.c.

References _GtsTriangle::e1, _GtsTriangle::e2, _GtsTriangle::e3, _GtsSurface::face_class, gts_face_new(), GTS_OBJECT, and gts_surface_add_face().

Referenced by gts_surface_copy().

Here is the call graph for this function:

static gboolean foreach_face_remove ( GtsFace f,
gpointer  t_data,
gpointer *  info 
) [static]

Definition at line 1126 of file surface.c.

References FALSE, gts_allow_floating_faces, GTS_OBJECT, gts_object_destroy(), GTS_OBJECT_DESTROYED, GTS_SURFACE_CLASS, _GtsFace::surfaces, and TRUE.

Referenced by gts_surface_foreach_face_remove().

Here is the call graph for this function:

static void foreach_vertex_copy ( GtsPoint p,
GtsVertexClass klass 
) [static]

Definition at line 2051 of file surface.c.

References GTS_OBJECT, gts_vertex_new(), _GtsPoint::x, _GtsPoint::y, and _GtsPoint::z.

Referenced by gts_surface_copy().

Here is the call graph for this function:

static guint generate_icosahedron ( GtsSurface s) [static]
gboolean gts_coarsen_stop_cost ( gdouble  cost,
guint  nedge,
gdouble *  max_cost 
)

gts_coarsen_stop_cost: : the cost of the edge collapse considered. : the current number of edges of the surface being simplified. : a pointer to the maximum cost allowed for an edge collapse.

This function is to be used as the argument of gts_surface_coarsen() or gts_psurface_new().

Returns: TRUE if the cost of the edge collapse considered is larger than given by , FALSE otherwise.

Definition at line 1731 of file surface.c.

References FALSE, and TRUE.

gboolean gts_coarsen_stop_number ( gdouble  cost,
guint  nedge,
guint *  min_number 
)

gts_coarsen_stop_number: : the cost of the edge collapse considered. : the current number of edges of the surface being simplified. : a pointer to the minimum number of edges desired for the surface being simplified.

This function is to be used as the argument of gts_surface_coarsen() or gts_psurface_new().

Returns: TRUE if the edge collapse would create a surface with a smaller number of edges than given by , FALSE otherwise.

Definition at line 1708 of file surface.c.

References FALSE, and TRUE.

gboolean gts_edge_collapse_creates_fold ( GtsEdge e,
GtsVertex v,
gdouble  max 
)

gts_edge_collapse_creates_fold: : a GtsEdge. : a GtsVertex. : the maximum value of the square of the cosine of the angle between two triangles.

Returns: TRUE if collapsing edge to vertex would create faces making an angle the cosine squared of which would be larger than max, FALSE otherwise.

Definition at line 1367 of file surface.c.

References _GtsTriangle::e1, _GtsTriangle::e2, _GtsTriangle::e3, edge_triangles(), FALSE, GTS_EDGE, GTS_IS_EDGE, GTS_SEGMENT, gts_triangle_edge_opposite(), gts_triangles_are_folded(), gts_vertex_triangles(), replace_vertex(), s, _GtsVertex::segments, _GtsEdge::triangles, TRUE, _GtsSegment::v1, and _GtsSegment::v2.

Referenced by edge_collapse().

Here is the call graph for this function:

gboolean gts_edge_collapse_is_valid ( GtsEdge e)

gts_edge_collapse_is_valid: : a GtsEdge.

An implementation of the topological constraints described in the "Mesh Optimization" article of Hoppe et al (1993).

Returns: TRUE if can be collapsed without violation of the topological constraints, FALSE otherwise.

Definition at line 1446 of file surface.c.

References _GtsTriangle::e1, _GtsTriangle::e2, _GtsTriangle::e3, FALSE, gts_edge_belongs_to_tetrahedron(), gts_edge_is_boundary(), GTS_IS_EDGE, GTS_SEGMENT, gts_triangle_use_edges(), gts_vertex_is_boundary(), _GtsEdge::triangles, and TRUE.

Referenced by edge_collapse().

Here is the call graph for this function:

void gts_range_print ( GtsRange r,
FILE *  fptr 
)

gts_range_print: : a GtsRange. : a file pointer.

Writes a text representation of in .

Definition at line 505 of file surface.c.

References _GtsRange::max, _GtsRange::mean, _GtsRange::min, and _GtsRange::stddev.

Referenced by gts_graph_partition_print_stats(), gts_graph_print_stats(), and gts_surface_print_stats().

void gts_range_reset ( GtsRange r)

gts_range_reset: : a GtsRange.

Sets all the fields of to 0.

Definition at line 448 of file surface.c.

References _GtsRange::max, _GtsRange::min, _GtsRange::n, _GtsRange::sum, and _GtsRange::sum2.

Referenced by gts_surface_distance().

gdouble gts_surface_area ( GtsSurface s)

gts_surface_area: : a GtsSurface.

Returns: the area of obtained as the sum of the signed areas of its faces.

Definition at line 419 of file surface.c.

References gts_surface_foreach_face(), and sum_area().

Here is the call graph for this function:

GSList* gts_surface_boundary ( GtsSurface surface)

gts_surface_boundary: : a GtsSurface.

Returns: a list of GtsEdge boundary of .

Definition at line 2518 of file surface.c.

References gts_surface_foreach_edge(), and surface_boundary().

Referenced by gts_delaunay_remove_hull().

Here is the call graph for this function:

gdouble gts_surface_center_of_area ( GtsSurface s,
GtsVector  cm 
)

gts_surface_center_of_area: : a GtsSurface. : a GtsVector.

Fills with the coordinates of the center of area of .

Returns: the area of surface .

Definition at line 2355 of file surface.c.

References center_of_area_foreach_face(), and gts_surface_foreach_face().

Here is the call graph for this function:

gdouble gts_surface_center_of_mass ( GtsSurface s,
GtsVector  cm 
)

gts_surface_center_of_mass: : a GtsSurface. : a GtsVector.

Fills with the coordinates of the center of mass of .

Returns: the signed volume of the domain bounded by the surface .

Definition at line 2302 of file surface.c.

References center_of_mass_foreach_face(), and gts_surface_foreach_face().

Here is the call graph for this function:

GtsSurfaceClass* gts_surface_class ( void  )

gts_surface_class:

Returns: the GtsSurfaceClass.

Definition at line 97 of file surface.c.

References gts_object_class(), gts_object_class_new(), surface_class_init(), and surface_init().

Referenced by build_cdt(), delaunay_create_from_vertices(), gts_surface_inter_new(), surface_destroy(), surface_inter_new(), and triangulate_face().

Here is the call graph for this function:

void gts_surface_coarsen ( GtsSurface surface,
GtsKeyFunc  cost_func,
gpointer  cost_data,
GtsCoarsenFunc  coarsen_func,
gpointer  coarsen_data,
GtsStopFunc  stop_func,
gpointer  stop_data,
gdouble  minangle 
)

gts_surface_coarsen: : a GtsSurface. : a function returning the cost for a given edge. : user data to be passed to . : a #GtsCoarsenVertexFunc. : user data to be passed to . : a GtsStopFunc. : user data to be passed to . : minimum angle between two neighboring triangles.

The edges of are sorted according to to create a priority heap (a GtsEHeap). The edges are extracted in turn from the top of the heap and collapsed (i.e. the vertices are replaced by the vertex returned by the function) until the functions returns TRUE.

If is set to NULL, the edges are sorted according to their length squared (the shortest is on top).

If is set to NULL gts_segment_midvertex() is used.

The minimum angle is used to avoid introducing faces which would be folded.

Definition at line 1646 of file surface.c.

References create_heap_coarsen(), edge_collapse(), edge_length2(), FALSE, gts_allow_floating_edges, gts_edge_face_number(), gts_eheap_destroy(), gts_eheap_foreach(), gts_eheap_freeze(), gts_eheap_new(), gts_eheap_remove_top(), gts_eheap_size(), gts_eheap_thaw(), GTS_OBJECT, gts_object_reset_reserved(), gts_segment_midvertex(), gts_surface_foreach_edge(), TRUE, update_2nd_closest_neighbors(), and _GtsSurface::vertex_class.

Here is the call graph for this function:

GtsSurface* gts_surface_copy ( GtsSurface s1,
GtsSurface s2 
)

gts_surface_copy: : a GtsSurface. : a GtsSurface.

Add a copy of all the faces, edges and vertices of to .

Returns: .

Definition at line 2081 of file surface.c.

References _GtsSurface::edge_class, foreach_edge_copy(), foreach_face_copy(), foreach_vertex_copy(), gts_object_reset_reserved(), gts_surface_foreach_edge(), gts_surface_foreach_face(), gts_surface_foreach_vertex(), and _GtsSurface::vertex_class.

Here is the call graph for this function:

void gts_surface_distance ( GtsSurface s1,
GtsSurface s2,
gdouble  delta,
GtsRange face_range,
GtsRange boundary_range 
)

gts_surface_distance: : a GtsSurface. : a GtsSurface. : a spatial increment defined as the percentage of the diagonal of the bounding box of . : a GtsRange. : a GtsRange.

Using the gts_bb_tree_surface_distance() and gts_bb_tree_surface_boundary_distance() functions fills and with the min, max and average Euclidean (minimum) distances between the faces of and the faces of and between the boundary edges of and .

Definition at line 2460 of file surface.c.

References build_list_boundary(), build_list_face(), gts_bb_tree_destroy(), gts_bb_tree_new(), gts_bb_tree_surface_boundary_distance(), gts_bb_tree_surface_distance(), gts_point_segment_distance(), gts_point_triangle_distance(), gts_range_reset(), gts_surface_foreach_edge(), gts_surface_foreach_face(), and TRUE.

Here is the call graph for this function:

guint gts_surface_edge_number ( GtsSurface s)

gts_surface_edge_number: : a GtsSurface.

Returns: the number of edges of .

Definition at line 2405 of file surface.c.

References gts_surface_foreach_edge(), n, and number_foreach().

Here is the call graph for this function:

guint gts_surface_face_number ( GtsSurface s)

gts_surface_face_number: : a GtsSurface.

Returns: the number of faces of

Definition at line 2422 of file surface.c.

References _GtsSurface::faces.

guint gts_surface_foreach_face_remove ( GtsSurface s,
GtsFunc  func,
gpointer  data 
)

gts_surface_foreach_face_remove: : a GtsSurface. : a GtsFunc. : user data to be passed to .

Calls once for each face of . If returns TRUE the corresponding face is removed from (and destroyed if it does not belong to any other surface and gts_allow_floating_faces is set to FALSE).

Returns: the number of faces removed from .

Definition at line 1161 of file surface.c.

References _GtsSurface::faces, FALSE, foreach_face_remove(), _GtsSurface::keep_faces, n, s, and TRUE.

Here is the call graph for this function:

void gts_surface_foreach_vertex ( GtsSurface s,
GtsFunc  func,
gpointer  data 
)

gts_surface_foreach_vertex: : a GtsSurface. : a GtsFunc. : user data to be passed to .

Calls once for each vertex of .

Definition at line 970 of file surface.c.

References _GtsSurface::faces, FALSE, _GtsSurface::keep_faces, TRUE, and vertex_foreach_face().

Referenced by gts_bbox_surface(), gts_psurface_close(), gts_psurface_write(), gts_surface_copy(), gts_surface_stats(), gts_surface_vertex_number(), gts_surface_write(), gts_surface_write_oogl(), gts_surface_write_vtk(), and toporouter_draw_surface().

Here is the call graph for this function:

GtsSurface* gts_surface_generate_sphere ( GtsSurface s,
guint  geodesation_order 
)

gts_surface_generate_sphere: : a GtsSurface. : a #guint.

Add a triangulated unit sphere generated by recursive subdivision to . First approximation is an isocahedron; each level of refinement () increases the number of triangles by a factor of 4. http://mathworld.wolfram.com/GeodesicDome.html

Returns: .

Definition at line 2035 of file surface.c.

References generate_icosahedron(), gts_surface_tessellate(), and s.

Here is the call graph for this function:

gboolean gts_surface_is_closed ( GtsSurface s)

gts_surface_is_closed: : a GtsSurface.

Returns: TRUE if is a closed surface, FALSE otherwise. Note that a closed surface is also a manifold.

Definition at line 2165 of file surface.c.

References closed_foreach_edge(), FALSE, gts_surface_foreach_edge(), s, and TRUE.

Here is the call graph for this function:

gboolean gts_surface_is_manifold ( GtsSurface s)

gts_surface_is_manifold: : a GtsSurface.

Returns: TRUE if the surface is a manifold, FALSE otherwise.

Definition at line 2135 of file surface.c.

References FALSE, gts_surface_foreach_edge(), manifold_foreach_edge(), s, and TRUE.

Here is the call graph for this function:

gboolean gts_surface_is_orientable ( GtsSurface s)

gts_surface_is_orientable: : a GtsSurface.

Returns: TRUE if all the faces of have compatible orientation as checked by gts_faces_are_compatible(), FALSE otherwise. Note that an orientable surface is also a manifold.

Definition at line 2209 of file surface.c.

References FALSE, gts_surface_foreach_edge(), orientable_foreach_edge(), s, and TRUE.

Here is the call graph for this function:

void gts_surface_merge ( GtsSurface s,
GtsSurface with 
)

gts_surface_merge: : a GtsSurface. : another GtsSurface.

Adds all the faces of which do not already belong to to .

Definition at line 2111 of file surface.c.

References gts_surface_foreach_face(), and merge_foreach_face().

Referenced by triangulate_face().

Here is the call graph for this function:

void gts_surface_quality_stats ( GtsSurface s,
GtsSurfaceQualityStats stats 
)
guint gts_surface_read ( GtsSurface surface,
GtsFile f 
)

gts_surface_read: : a GtsSurface. : a GtsFile.

Add to the data read from . The format of the file pointed to by is as described in gts_surface_write().

Returns: 0 if successful or the line number at which the parsing stopped in case of error (in which case the field of is set to a description of the error which occured).

Definition at line 216 of file surface.c.

References _GtsSurface::edge_class, f, _GtsSurface::face_class, FALSE, gts_allow_floating_vertices, gts_edge_new(), GTS_ERROR, gts_face_new(), gts_file_error(), gts_file_first_token_after(), gts_file_next_token(), GTS_INT, GTS_OBJECT, GTS_OBJECT_CLASS, gts_object_destroy(), gts_object_new(), GTS_POINT_CLASS, GTS_STRING, gts_surface_add_face(), GTS_VERTEX, _GtsFile::line, n, _GtsFile::token, TRUE, _GtsFile::type, and _GtsSurface::vertex_class.

Here is the call graph for this function:

void gts_surface_refine ( GtsSurface surface,
GtsKeyFunc  cost_func,
gpointer  cost_data,
GtsRefineFunc  refine_func,
gpointer  refine_data,
GtsStopFunc  stop_func,
gpointer  stop_data 
)

gts_surface_refine: : a GtsSurface. : a function returning the cost for a given edge. : user data to be passed to . : a GtsRefineFunc. : user data to be passed to . : a GtsStopFunc. : user data to be passed to .

Refine using a midvertex insertion technique. All the edges of are ordered according to . The edges are then processed in order until returns TRUE. Each edge is split in two and new edges and faces are created.

If is set to NULL, the edges are sorted according to their length squared (the longest is on top).

If is set to NULL gts_segment_midvertex() is used.

Definition at line 1267 of file surface.c.

References create_heap_refine(), _GtsSurface::edge_class, edge_length2_inverse(), gts_edge_face_number(), gts_eheap_destroy(), gts_eheap_freeze(), gts_eheap_new(), gts_eheap_remove_top(), gts_eheap_size(), gts_eheap_thaw(), gts_segment_midvertex(), gts_surface_foreach_edge(), midvertex_insertion(), and _GtsSurface::vertex_class.

Here is the call graph for this function:

GSList* gts_surface_split ( GtsSurface s)

gts_surface_split: : a GtsSurface.

Splits a surface into connected and manifold components.

Returns: a list of new GtsSurface.

Definition at line 2726 of file surface.c.

References gts_surface_foreach_edge(), gts_surface_foreach_face(), s, traverse_boundary(), and traverse_remaining().

Here is the call graph for this function:

void gts_surface_tessellate ( GtsSurface s,
GtsRefineFunc  refine_func,
gpointer  refine_data 
)

gts_surface_tessellate: : a GtsSurface. : a GtsRefineFunc. : user data to be passed to .

Tessellate each triangle of with 4 triangles: the number of triangles is increased by a factor of 4. http://mathworld.wolfram.com/GeodesicDome.html

If is set to NULL a mid arc function is used: if the surface is a polyhedron with the unit sphere as circum sphere, then gts_surface_tessellate() corresponds to a geodesation step (see gts_surface_generate_sphere()).

Definition at line 2002 of file surface.c.

References create_array_tessellate(), _GtsSurface::edge_class, gts_surface_foreach_face(), tessellate_face(), TRUE, unit_sphere_arc_midvertex(), and _GtsSurface::vertex_class.

Referenced by gts_surface_generate_sphere().

Here is the call graph for this function:

void gts_surface_traverse_destroy ( GtsSurfaceTraverse t)

gts_surface_traverse_destroy: : a GtsSurfaceTraverse.

Frees all the memory allocated for .

Definition at line 2607 of file surface.c.

References gts_fifo_destroy(), gts_object_reset_reserved(), gts_surface_foreach_face(), _GtsSurfaceTraverse::q, and _GtsSurfaceTraverse::s.

Referenced by build_cdt().

Here is the call graph for this function:

GtsSurfaceTraverse* gts_surface_traverse_new ( GtsSurface s,
GtsFace f 
)

gts_surface_traverse_new: : a GtsSurface. : a GtsFace belonging to .

Returns: a new GtsSurfaceTraverse, initialized to start traversing from face of surface .

Definition at line 2545 of file surface.c.

References gts_face_has_parent_surface(), gts_fifo_new(), gts_fifo_push(), GTS_OBJECT, _GtsSurfaceTraverse::q, s, and _GtsSurfaceTraverse::s.

Referenced by build_cdt().

Here is the call graph for this function:

GtsFace* gts_surface_traverse_next ( GtsSurfaceTraverse t,
guint *  level 
)

gts_surface_traverse_next: : a GtsSurfaceTraverse. : a pointer to a guint or NULL.

Returns: the next face of the traversal in breadth-first order or NULL if no faces are left. If if not NULL, it is filled with the level of the returned face (0 for the initial face, 1 for its neighbors and so on).

Definition at line 2581 of file surface.c.

References gts_face_foreach_neighbor(), gts_fifo_pop(), GTS_OBJECT, push_neighbor(), _GtsSurfaceTraverse::q, _GtsSurfaceTraverse::s, and u().

Here is the call graph for this function:

guint gts_surface_vertex_number ( GtsSurface s)

gts_surface_vertex_number: : a GtsSurface.

Returns: the number of vertices of .

Definition at line 2388 of file surface.c.

References gts_surface_foreach_vertex(), n, and number_foreach().

Referenced by gts_hsurface_new(), gts_psurface_new(), and gts_psurface_open().

Here is the call graph for this function:

gdouble gts_surface_volume ( GtsSurface s)

gts_surface_volume: : a GtsSurface.

Returns: the signed volume of the domain bounded by the surface . It makes sense only if is a closed and orientable manifold.

Definition at line 2245 of file surface.c.

References gts_surface_foreach_face(), and volume_foreach_face().

Here is the call graph for this function:

void gts_surface_write ( GtsSurface s,
FILE *  fptr 
)

gts_surface_write: : a GtsSurface. : a file pointer.

Writes in the file an ASCII representation of . The file format is as follows.

All the lines beginning with GTS_COMMENTS are ignored. The first line contains three unsigned integers separated by spaces. The first integer is the number of vertices, nv, the second is the number of edges, ne and the third is the number of faces, nf.

Follows nv lines containing the x, y and z coordinates of the vertices. Follows ne lines containing the two indices (starting from one) of the vertices of each edge. Follows nf lines containing the three ordered indices (also starting from one) of the edges of each face.

The format described above is the least common denominator to all GTS files. Consistent with an object-oriented approach, the GTS file format is extensible. Each of the lines of the file can be extended with user-specific attributes accessible through the read() and write() virtual methods of each of the objects written (surface, vertices, edges or faces). When read with different object classes, these extra attributes are just ignored.

Definition at line 738 of file surface.c.

References _GtsSurfaceStats::edges_per_vertex, _GtsSurfaceStats::faces_per_edge, GTS_OBJECT, GTS_POINT_CLASS, gts_surface_foreach_edge(), gts_surface_foreach_face(), gts_surface_foreach_vertex(), gts_surface_stats(), _GtsRange::n, n, _GtsSurfaceStats::n_faces, _GtsSurface::vertex_class, write_edge(), write_face(), and write_vertex().

Referenced by build_cdt(), gts_delaunay_add_constraint(), and gts_psurface_write().

Here is the call graph for this function:

void gts_surface_write_oogl ( GtsSurface s,
FILE *  fptr 
)

gts_surface_write_oogl: : a GtsSurface. : a file pointer.

Writes in the file an OOGL (Geomview) representation of .

Definition at line 809 of file surface.c.

References _GtsSurfaceStats::edges_per_vertex, _GtsSurfaceStats::faces_per_edge, GTS_OBJECT_CLASS, gts_object_reset_reserved(), gts_surface_foreach_face(), gts_surface_foreach_vertex(), gts_surface_stats(), _GtsRange::n, n, _GtsSurfaceStats::n_faces, _GtsSurface::vertex_class, write_face_oogl(), and write_vertex_oogl().

Here is the call graph for this function:

void gts_surface_write_oogl_boundary ( GtsSurface s,
FILE *  fptr 
)

gts_surface_write_oogl_boundary: : a GtsSurface. : a file pointer.

Writes in the file an OOGL (Geomview) representation of the boundary of .

Definition at line 914 of file surface.c.

References gts_surface_foreach_edge(), s, and write_edge_oogl_boundary().

Here is the call graph for this function:

void gts_surface_write_vtk ( GtsSurface s,
FILE *  fptr 
)

gts_surface_write_vtk: : a GtsSurface. : a file pointer.

Writes in the file a VTK representation of .

Definition at line 860 of file surface.c.

References _GtsSurfaceStats::edges_per_vertex, gts_object_reset_reserved(), gts_surface_foreach_face(), gts_surface_foreach_vertex(), gts_surface_stats(), _GtsRange::n, n, _GtsSurfaceStats::n_faces, write_face_vtk(), and write_vertex_vtk().

Here is the call graph for this function:

static void manifold_foreach_edge ( GtsEdge e,
gpointer *  data 
) [static]

Definition at line 2119 of file surface.c.

References FALSE, and gts_edge_face_number().

Referenced by gts_surface_is_manifold().

Here is the call graph for this function:

static void merge_foreach_face ( GtsFace f,
GtsSurface s 
) [static]

Definition at line 2097 of file surface.c.

References gts_surface_add_face().

Referenced by gts_surface_merge().

Here is the call graph for this function:

static void midvertex_insertion ( GtsEdge e,
GtsSurface surface,
GtsEHeap heap,
GtsRefineFunc  refine_func,
gpointer  refine_data,
GtsVertexClass vertex_class,
GtsEdgeClass edge_class 
) [static]
static void non_manifold_edges ( GtsEdge e,
gpointer *  data 
) [static]

Definition at line 2642 of file surface.c.

References gts_edge_face_number(), gts_face_has_parent_surface(), and _GtsEdge::triangles.

Referenced by traverse_boundary(), and traverse_remaining().

Here is the call graph for this function:

static void number_foreach ( gpointer  data,
guint *  n 
) [static]

Definition at line 2377 of file surface.c.

Referenced by gts_surface_edge_number(), and gts_surface_vertex_number().

static void orientable_foreach_edge ( GtsEdge e,
gpointer *  data 
) [static]

Definition at line 2178 of file surface.c.

References f, FALSE, gts_face_has_parent_surface(), GTS_IS_FACE, GTS_TRIANGLE, gts_triangles_are_compatible(), and _GtsEdge::triangles.

Referenced by gts_surface_is_orientable().

Here is the call graph for this function:

static void push_neighbor ( GtsFace v,
gpointer *  data 
) [static]

Definition at line 2562 of file surface.c.

References gts_fifo_push(), and GTS_OBJECT.

Referenced by gts_surface_traverse_next().

Here is the call graph for this function:

static void quality_foreach_edge ( GtsSegment s,
GtsSurfaceQualityStats stats 
) [static]
static void quality_foreach_face ( GtsTriangle t,
GtsSurfaceQualityStats stats 
) [static]
static void replace_vertex ( GSList *  i,
GtsVertex v1,
GtsVertex v 
) [static]

Definition at line 1344 of file surface.c.

References _GtsSegment::v1, and _GtsSegment::v2.

Referenced by gts_edge_collapse_creates_fold().

static void stats_foreach_face ( GtsTriangle t,
GtsSurfaceStats stats 
) [static]
static void stats_foreach_vertex ( GtsVertex v,
GtsSurfaceStats stats 
) [static]

Definition at line 513 of file surface.c.

References _GtsSurfaceStats::edges_per_vertex, gts_edge_has_parent_surface(), GTS_IS_EDGE, gts_range_add_value(), _GtsSurfaceStats::parent, and _GtsVertex::segments.

Referenced by gts_surface_stats().

Here is the call graph for this function:

static void sum_area ( GtsFace f,
gdouble *  area 
) [static]

Definition at line 408 of file surface.c.

References GTS_TRIANGLE, and gts_triangle_area().

Referenced by gts_surface_area().

Here is the call graph for this function:

static void surface_boundary ( GtsEdge e,
gpointer *  data 
) [static]

Definition at line 2504 of file surface.c.

References gts_edge_is_boundary().

Referenced by gts_surface_boundary().

Here is the call graph for this function:

static void surface_class_init ( GtsSurfaceClass klass) [static]

Definition at line 60 of file surface.c.

References _GtsSurfaceClass::add_face, GTS_OBJECT_CLASS, _GtsSurfaceClass::remove_face, surface_destroy(), and surface_write().

Referenced by gts_surface_class().

Here is the call graph for this function:

static void surface_destroy ( GtsObject object) [static]

Definition at line 35 of file surface.c.

References destroy_foreach_face(), _GtsSurface::faces, GTS_OBJECT_CLASS, GTS_SURFACE, gts_surface_class(), and gts_surface_foreach_face().

Referenced by surface_class_init().

Here is the call graph for this function:

static void surface_init ( GtsSurface surface) [static]
static void surface_write ( GtsObject object,
FILE *  fptr 
) [static]
static void tessellate_face ( GtsFace f,
GtsSurface s,
GtsRefineFunc  refine_func,
gpointer  refine_data,
GtsVertexClass vertex_class,
GtsEdgeClass edge_class 
) [static]
static void traverse_boundary ( GtsEdge e,
gpointer *  data 
) [static]
static void traverse_manifold ( GtsTriangle t,
GtsSurface s 
) [static]

Definition at line 2616 of file surface.c.

References _GtsTriangle::e1, _GtsTriangle::e2, _GtsTriangle::e3, GTS_FACE, gts_surface_add_face(), and _GtsEdge::triangles.

Referenced by traverse_boundary(), and traverse_remaining().

Here is the call graph for this function:

static void traverse_remaining ( GtsFace f,
gpointer *  data 
) [static]
static GtsVertex* unit_sphere_arc_midvertex ( GtsSegment s,
GtsVertexClass vertex_class 
) [static]

Definition at line 1830 of file surface.c.

References GTS_POINT, gts_vertex_new(), _GtsSegment::v1, _GtsSegment::v2, _GtsPoint::x, x, _GtsPoint::y, y, and _GtsPoint::z.

Referenced by gts_surface_tessellate().

Here is the call graph for this function:

static void update_2nd_closest_neighbors ( GtsVertex v,
GtsEHeap heap 
) [static]
static void vertex_foreach_face ( GtsTriangle t,
gpointer  t_data,
gpointer *  info 
) [static]

Definition at line 933 of file surface.c.

References _GtsTriangle::e1, FALSE, GTS_SEGMENT, gts_triangle_vertex, hash(), _GtsSegment::v1, and _GtsSegment::v2.

Referenced by gts_surface_foreach_vertex().

Here is the call graph for this function:

static void volume_foreach_face ( GtsTriangle t,
gdouble *  volume 
) [static]

Definition at line 2222 of file surface.c.

References GTS_POINT, gts_triangle_vertices(), _GtsPoint::x, _GtsPoint::y, and _GtsPoint::z.

Referenced by gts_surface_volume().

Here is the call graph for this function:

static void write_edge ( GtsSegment s,
gpointer *  data 
) [static]

Definition at line 688 of file surface.c.

References GTS_OBJECT, _GtsSegment::v1, and _GtsSegment::v2.

Referenced by gts_surface_write().

static void write_edge_oogl_boundary ( GtsSegment s,
gpointer *  data 
) [static]

Definition at line 888 of file surface.c.

References _GtsColor::b, c, _GtsColor::g, GTS_EDGE, gts_edge_is_boundary(), GTS_OBJECT, GTS_POINT, _GtsColor::r, _GtsSegment::v1, and _GtsSegment::v2.

Referenced by gts_surface_write_oogl_boundary().

Here is the call graph for this function:

static void write_face ( GtsTriangle t,
gpointer *  data 
) [static]

Definition at line 700 of file surface.c.

References _GtsTriangle::e1, _GtsTriangle::e2, _GtsTriangle::e3, and GTS_OBJECT.

Referenced by gts_surface_write().

static void write_face_oogl ( GtsTriangle t,
FILE *  fp 
) [static]

Definition at line 786 of file surface.c.

References _GtsColor::b, c, _GtsColor::g, GTS_OBJECT, gts_triangle_vertices(), and _GtsColor::r.

Referenced by gts_surface_write_oogl().

Here is the call graph for this function:

static void write_face_vtk ( GtsTriangle t,
FILE *  fp 
) [static]

Definition at line 843 of file surface.c.

References GTS_OBJECT, and gts_triangle_vertices().

Referenced by gts_surface_write_vtk().

Here is the call graph for this function:

static void write_vertex ( GtsPoint p,
gpointer *  data 
) [static]

Definition at line 679 of file surface.c.

References GTS_OBJECT, and GTS_POINT_CLASS.

Referenced by gts_surface_write().

static void write_vertex_oogl ( GtsPoint p,
gpointer *  data 
) [static]
static void write_vertex_vtk ( GtsPoint p,
gpointer *  data 
) [static]

Definition at line 835 of file surface.c.

References fp, GTS_OBJECT, _GtsPoint::x, _GtsPoint::y, and _GtsPoint::z.

Referenced by gts_surface_write_vtk().