hid/common/hidgl.c: Add support for rendering "fullpoly" polygons
[geda-pcb/pcjc2.git] / gts / gts.h
blob9397230bff55846e5da2a95fcbc74ac8deb363fe
1 /* GTS - Library for the manipulation of triangulated surfaces
2 * Copyright (C) 1999 Stéphane Popinet
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
20 #ifndef __GTS_H__
21 #define __GTS_H__
23 #include <stdio.h>
24 #include <glib.h>
26 #define GTS_MAJOR_VERSION 0
27 #define GTS_MINOR_VERSION 7
28 #define GTS_MICRO_VERSION 6
30 #ifdef __cplusplus
31 extern "C" {
32 #endif /* __cplusplus */
34 /* Added based on glib.h by M J Loehr 01/01/01 */
35 /* GTS version.
36 * we prefix variable declarations so they can
37 * properly get exported in windows dlls.
39 #ifdef NATIVE_WIN32
40 # ifdef GTS_COMPILATION
41 # define GTS_C_VAR __declspec(dllexport)
42 # else /* not GTS_COMPILATION */
43 # define GTS_C_VAR extern __declspec(dllimport)
44 # endif /* not GTS_COMPILATION */
45 #else /* not NATIVE_WIN32 */
46 # define GTS_C_VAR extern
47 #endif /* not NATIVE_WIN32 */
49 GTS_C_VAR const guint gts_major_version;
50 GTS_C_VAR const guint gts_minor_version;
51 GTS_C_VAR const guint gts_micro_version;
52 GTS_C_VAR const guint gts_interface_age;
53 GTS_C_VAR const guint gts_binary_age;
55 #define GTS_CHECK_VERSION(major,minor,micro) \
56 (gts_major_version > (major) || \
57 (gts_major_version == (major) && gts_minor_version > (minor)) || \
58 (gts_major_version == (major) && gts_minor_version == (minor) && \
59 gts_micro_version >= (micro)))
61 #define GTS_COMMENTS "#!"
62 #define GTS_MAINTAINER "popinet@users.sourceforge.net"
67 void gts_predicates_init();
70 /* Class declarations for base types */
72 typedef struct _GtsObjectClassInfo GtsObjectClassInfo;
73 typedef struct _GtsObject GtsObject;
74 typedef struct _GtsObjectClass GtsObjectClass;
75 typedef struct _GtsPoint GtsPoint;
76 typedef struct _GtsPointClass GtsPointClass;
77 typedef struct _GtsVertex GtsVertex;
78 typedef struct _GtsVertexClass GtsVertexClass;
79 typedef struct _GtsSegment GtsSegment;
80 typedef struct _GtsSegmentClass GtsSegmentClass;
81 typedef struct _GtsEdge GtsEdge;
82 typedef struct _GtsEdgeClass GtsEdgeClass;
83 typedef struct _GtsTriangle GtsTriangle;
84 typedef struct _GtsTriangleClass GtsTriangleClass;
85 typedef struct _GtsFace GtsFace;
86 typedef struct _GtsFaceClass GtsFaceClass;
87 typedef struct _GtsBBox GtsBBox;
88 typedef struct _GtsBBoxClass GtsBBoxClass;
89 typedef struct _GtsSurface GtsSurface;
90 typedef struct _GtsSurfaceClass GtsSurfaceClass;
92 typedef void (*GtsObjectClassInitFunc) (GtsObjectClass * objclass);
93 typedef void (*GtsObjectInitFunc) (GtsObject * obj);
94 typedef void (*GtsArgSetFunc) (GtsObject * obj);
95 typedef void (*GtsArgGetFunc) (GtsObject * obj);
97 typedef gdouble GtsVector[3];
98 typedef gdouble GtsVector4[4];
99 typedef GtsVector4 GtsMatrix;
101 * GtsKeyFunc:
102 * @item: A pointer to an item to be stored in the heap.
103 * @data: User data passed to gts_eheap_new().
105 * Returns: the value of the key for the given item.
107 typedef gdouble (*GtsKeyFunc) (gpointer item,
108 gpointer data);
109 typedef enum
111 GTS_OUT = -1,
112 GTS_ON = 0,
113 GTS_IN = 1
114 } GtsIntersect;
116 typedef struct _GtsColor GtsColor;
118 struct _GtsColor {
119 gfloat r, g, b;
122 typedef gint (*GtsFunc) (gpointer item,
123 gpointer data);
125 /* misc.c */
127 typedef struct _GtsFile GtsFile;
129 typedef enum {
130 GTS_NONE = 1 << 8,
131 GTS_INT = 1 << 9,
132 GTS_UINT = 1 << 10,
133 GTS_FLOAT = 1 << 11,
134 GTS_DOUBLE = 1 << 12,
135 GTS_STRING = 1 << 13,
136 GTS_FILE = 1 << 14,
137 GTS_ERROR = 1 << 15
138 } GtsTokenType;
140 struct _GtsFile {
141 FILE * fp;
142 gchar * s, * s1;
143 guint line, pos;
144 GString * token;
145 GtsTokenType type;
146 gchar * error;
148 guint curline, curpos;
149 guint scope, scope_max;
150 gint next_token;
151 gchar * delimiters;
152 gchar * comments;
153 gchar * tokens;
156 typedef struct _GtsFileVariable GtsFileVariable;
158 struct _GtsFileVariable {
159 GtsTokenType type;
160 gchar name[30];
161 gboolean unique;
162 gpointer data;
163 gboolean set;
164 guint line, pos;
168 GtsFile * gts_file_new (FILE * fp);
169 GtsFile * gts_file_new_from_string (const gchar * s);
170 void gts_file_verror (GtsFile * f,
171 const gchar * format,
172 va_list args);
173 void gts_file_error (GtsFile * f,
174 const gchar * format,
175 ...);
176 gint gts_file_getc (GtsFile * f);
177 guint gts_file_read (GtsFile * f,
178 gpointer ptr,
179 guint size,
180 guint nmemb);
181 gint gts_file_getc_scope (GtsFile * f);
182 void gts_file_next_token (GtsFile * f);
183 void gts_file_first_token_after (GtsFile * f,
184 GtsTokenType type);
185 void gts_file_assign_start (GtsFile * f,
186 GtsFileVariable * vars);
187 GtsFileVariable * gts_file_assign_next (GtsFile * f,
188 GtsFileVariable * vars);
189 void gts_file_assign_variables (GtsFile * f,
190 GtsFileVariable * vars);
191 void gts_file_variable_error (GtsFile * f,
192 GtsFileVariable * vars,
193 const gchar * name,
194 const gchar * format,
195 ...);
196 void gts_file_destroy (GtsFile * f);
198 /* Objects: object.c */
200 #ifdef GTS_CHECK_CASTS
201 # define GTS_OBJECT_CAST(obj, type, klass) ((type *) gts_object_check_cast (obj, klass))
202 # define GTS_OBJECT_CLASS_CAST(objklass, type, klass) ((type *) gts_object_class_check_cast (objklass, klass))
203 #else /* not GTS_CHECK_CASTS */
204 # define GTS_OBJECT_CAST(obj, type, klass) ((type *) (obj))
205 # define GTS_OBJECT_CLASS_CAST(objklass, type, klass) ((type *) (objklass))
206 #endif /* not GTS_CHECK_CASTS */
208 #define GTS_CLASS_NAME_LENGTH 40
209 #define GTS_OBJECT(obj) GTS_OBJECT_CAST (obj,\
210 GtsObject,\
211 gts_object_class ())
212 #define GTS_OBJECT_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
213 GtsObjectClass,\
214 gts_object_class())
215 #define GTS_IS_OBJECT(obj) (gts_object_is_from_class (obj,\
216 gts_object_class ()))
218 typedef enum
220 GTS_DESTROYED = 1 << 0,
221 GTS_USER_FLAG = 1 /* user flags start from here */
222 } GtsObjectFlags;
224 #define GTS_OBJECT_FLAGS(obj) (GTS_OBJECT (obj)->flags)
225 #define GTS_OBJECT_DESTROYED(obj) ((GTS_OBJECT_FLAGS (obj) & GTS_DESTROYED) != 0)
226 #define GTS_OBJECT_SET_FLAGS(obj,flag) G_STMT_START{ (GTS_OBJECT_FLAGS (obj) |= (flag)); }G_STMT_END
227 #define GTS_OBJECT_UNSET_FLAGS(obj,flag) G_STMT_START{ (GTS_OBJECT_FLAGS (obj) &= ~(flag)); }G_STMT_END
229 struct _GtsObjectClassInfo {
230 gchar name[GTS_CLASS_NAME_LENGTH];
231 guint object_size;
232 guint class_size;
233 GtsObjectClassInitFunc class_init_func;
234 GtsObjectInitFunc object_init_func;
235 GtsArgSetFunc arg_set_func;
236 GtsArgGetFunc arg_get_func;
239 struct _GtsObject {
240 GtsObjectClass * klass;
242 gpointer reserved;
243 guint32 flags;
246 struct _GtsObjectClass {
247 GtsObjectClassInfo info;
248 GtsObjectClass * parent_class;
250 void (* clone) (GtsObject *, GtsObject *);
251 void (* destroy) (GtsObject *);
252 void (* read) (GtsObject **, GtsFile *);
253 void (* write) (GtsObject *, FILE *);
254 GtsColor (* color) (GtsObject *);
255 void (* attributes) (GtsObject *, GtsObject *);
258 gpointer gts_object_class_new (GtsObjectClass * parent_class,
259 GtsObjectClassInfo * info);
260 GtsObjectClass * gts_object_class (void);
261 gpointer gts_object_check_cast (gpointer object,
262 gpointer klass);
263 gpointer gts_object_class_check_cast (gpointer klass,
264 gpointer from);
266 static inline
267 gpointer gts_object_is_from_class (gpointer object,
268 gpointer klass)
270 GtsObjectClass * c;
272 g_return_val_if_fail (klass != NULL, NULL);
274 if (object == NULL)
275 return NULL;
277 c = ((GtsObject *) object)->klass;
279 g_return_val_if_fail (c != NULL, NULL);
281 while (c) {
282 if (c == klass)
283 return object;
284 c = c->parent_class;
287 return NULL;
290 static inline
291 gpointer gts_object_class_is_from_class (gpointer klass,
292 gpointer from)
294 GtsObjectClass * c;
296 g_return_val_if_fail (klass != NULL, NULL);
297 g_return_val_if_fail (from != NULL, NULL);
299 c = (GtsObjectClass *) klass;
300 while (c) {
301 if (c == from)
302 return klass;
303 c = c->parent_class;
306 return NULL;
309 GtsObjectClass * gts_object_class_from_name (const gchar * name);
311 GtsObject * gts_object_new (GtsObjectClass * klass);
312 GtsObject * gts_object_clone (GtsObject * object);
313 void gts_object_attributes (GtsObject * object,
314 GtsObject * from);
315 void gts_object_init (GtsObject * object,
316 GtsObjectClass * klass);
317 void gts_object_reset_reserved (GtsObject * object);
318 void gts_object_destroy (GtsObject * object);
319 void gts_finalize (void);
321 /* Ranges: surface.c */
322 typedef struct _GtsRange GtsRange;
324 struct _GtsRange {
325 gdouble min, max, sum, sum2, mean, stddev;
326 guint n;
329 void gts_range_init (GtsRange * r);
330 void gts_range_reset (GtsRange * r);
331 void gts_range_add_value (GtsRange * r,
332 gdouble val);
333 void gts_range_update (GtsRange * r);
334 void gts_range_print (GtsRange * r,
335 FILE * fptr);
337 /* Points: point.c */
339 #define GTS_IS_POINT(obj) (gts_object_is_from_class (obj,\
340 gts_point_class ()))
341 #define GTS_POINT(obj) GTS_OBJECT_CAST (obj,\
342 GtsPoint,\
343 gts_point_class ())
344 #define GTS_POINT_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
345 GtsPointClass,\
346 gts_point_class ())
348 struct _GtsPoint {
349 GtsObject object;
351 gdouble x, y, z; /* must be contiguous (cast to robust functions) */
354 struct _GtsPointClass {
355 GtsObjectClass parent_class;
356 gboolean binary;
359 GtsPointClass * gts_point_class (void);
360 GtsPoint * gts_point_new (GtsPointClass * klass,
361 gdouble x,
362 gdouble y,
363 gdouble z);
364 void gts_point_set (GtsPoint * p,
365 gdouble x,
366 gdouble y,
367 gdouble z);
368 #define gts_point_is_in_rectangle(p, p1, p2) ((p)->x >= (p1)->x &&\
369 (p)->x <= (p2)->x &&\
370 (p)->y >= (p1)->y &&\
371 (p)->y <= (p2)->y &&\
372 (p)->z >= (p1)->z &&\
373 (p)->z <= (p2)->z)
374 GtsPoint * gts_segment_triangle_intersection (GtsSegment * s,
375 GtsTriangle * t,
376 gboolean boundary,
377 GtsPointClass * klass);
378 void gts_point_transform (GtsPoint * p,
379 GtsMatrix * m);
380 gdouble gts_point_distance (GtsPoint * p1,
381 GtsPoint * p2);
382 gdouble gts_point_distance2 (GtsPoint * p1,
383 GtsPoint * p2);
384 gdouble gts_point_orientation_3d (GtsPoint * p1,
385 GtsPoint * p2,
386 GtsPoint * p3,
387 GtsPoint * p4);
388 gint gts_point_orientation_3d_sos (GtsPoint * p1,
389 GtsPoint * p2,
390 GtsPoint * p3,
391 GtsPoint * p4);
392 GtsIntersect gts_point_is_in_triangle (GtsPoint * p,
393 GtsTriangle * t);
394 gdouble gts_point_in_circle (GtsPoint * p,
395 GtsPoint * p1,
396 GtsPoint * p2,
397 GtsPoint * p3);
398 gdouble gts_point_in_sphere (GtsPoint * p,
399 GtsPoint * p1,
400 GtsPoint * p2,
401 GtsPoint * p3,
402 GtsPoint * p4);
403 gdouble gts_point_in_triangle_circle (GtsPoint * p,
404 GtsTriangle * t);
405 gdouble gts_point_orientation (GtsPoint * p1,
406 GtsPoint * p2,
407 GtsPoint * p3);
408 gint gts_point_orientation_sos (GtsPoint * p1,
409 GtsPoint * p2,
410 GtsPoint * p3);
411 gdouble gts_point_segment_distance2 (GtsPoint * p,
412 GtsSegment * s);
413 gdouble gts_point_segment_distance (GtsPoint * p,
414 GtsSegment * s);
415 void gts_point_segment_closest (GtsPoint * p,
416 GtsSegment * s,
417 GtsPoint * closest);
418 gdouble gts_point_triangle_distance2 (GtsPoint * p,
419 GtsTriangle * t);
420 gdouble gts_point_triangle_distance (GtsPoint * p,
421 GtsTriangle * t);
422 void gts_point_triangle_closest (GtsPoint * p,
423 GtsTriangle * t,
424 GtsPoint * closest);
425 gboolean gts_point_is_inside_surface (GtsPoint * p,
426 GNode * tree,
427 gboolean is_open);
429 /* Vertices: vertex.c */
431 #define GTS_IS_VERTEX(obj) (gts_object_is_from_class (obj,\
432 gts_vertex_class ()))
433 #define GTS_VERTEX(obj) GTS_OBJECT_CAST (obj,\
434 GtsVertex,\
435 gts_vertex_class ())
436 #define GTS_VERTEX_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
437 GtsVertexClass,\
438 gts_vertex_class ())
439 struct _GtsVertex {
440 GtsPoint p;
442 GSList * segments;
445 struct _GtsVertexClass {
446 GtsPointClass parent_class;
448 void (* intersection_attributes) (GtsVertex *,
449 GtsObject *,
450 GtsObject *);
453 GTS_C_VAR
454 gboolean gts_allow_floating_vertices;
456 GtsVertexClass * gts_vertex_class (void);
457 GtsVertex * gts_vertex_new (GtsVertexClass * klass,
458 gdouble x,
459 gdouble y,
460 gdouble z);
461 void gts_vertex_replace (GtsVertex * v,
462 GtsVertex * with);
463 gboolean gts_vertex_is_unattached (GtsVertex * v);
464 GtsSegment * gts_vertices_are_connected (GtsVertex * v1,
465 GtsVertex * v2);
466 GSList * gts_vertex_triangles (GtsVertex * v,
467 GSList * list);
468 GSList * gts_vertex_faces (GtsVertex * v,
469 GtsSurface * surface,
470 GSList * list);
471 GSList * gts_vertex_neighbors (GtsVertex * v,
472 GSList * list,
473 GtsSurface * surface);
474 GSList * gts_vertices_from_segments (GSList * segments);
475 gboolean gts_vertex_is_boundary (GtsVertex * v,
476 GtsSurface * surface);
477 GList * gts_vertices_merge (GList * vertices,
478 gdouble epsilon,
479 gboolean (* check) (GtsVertex *, GtsVertex *));
480 GSList * gts_vertex_fan_oriented (GtsVertex * v,
481 GtsSurface * surface);
482 guint gts_vertex_is_contact (GtsVertex * v, gboolean sever);
484 /* GtsVertexNormal: Header */
486 typedef struct _GtsVertexNormal GtsVertexNormal;
488 struct _GtsVertexNormal {
489 /*< private >*/
490 GtsVertex parent;
492 /*< public >*/
493 GtsVector n;
496 #define GTS_VERTEX_NORMAL(obj) GTS_OBJECT_CAST (obj,\
497 GtsVertexNormal,\
498 gts_vertex_normal_class ())
499 #define GTS_IS_VERTEX_NORMAL(obj) (gts_object_is_from_class (obj,\
500 gts_vertex_normal_class ()))
502 GtsVertexClass * gts_vertex_normal_class (void);
504 /* GtsColorVertex: Header */
506 typedef struct _GtsColorVertex GtsColorVertex;
508 struct _GtsColorVertex {
509 /*< private >*/
510 GtsVertex parent;
512 /*< public >*/
513 GtsColor c;
516 #define GTS_COLOR_VERTEX(obj) GTS_OBJECT_CAST (obj,\
517 GtsColorVertex,\
518 gts_color_vertex_class ())
519 #define GTS_IS_COLOR_VERTEX(obj) (gts_object_is_from_class (obj,\
520 gts_color_vertex_class ()))
522 GtsVertexClass * gts_color_vertex_class (void);
524 /* Segments: segment.c */
526 #define GTS_IS_SEGMENT(obj) (gts_object_is_from_class (obj,\
527 gts_segment_class ()))
528 #define GTS_SEGMENT(obj) GTS_OBJECT_CAST (obj,\
529 GtsSegment,\
530 gts_segment_class ())
531 #define GTS_SEGMENT_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
532 GtsSegmentClass,\
533 gts_segment_class ())
535 struct _GtsSegment {
536 GtsObject object;
538 GtsVertex * v1;
539 GtsVertex * v2;
542 struct _GtsSegmentClass {
543 GtsObjectClass parent_class;
546 GtsSegmentClass * gts_segment_class (void);
547 GtsSegment * gts_segment_new (GtsSegmentClass * klass,
548 GtsVertex * v1,
549 GtsVertex * v2);
550 #define gts_segment_connect(s, e1, e2) (((s)->v1 == e1 &&\
551 (s)->v2 == e2) || \
552 ((s)->v1 == e2 &&\
553 (s)->v2 == e1))
554 #define gts_segments_are_identical(s1, s2) (((s1)->v1 == (s2)->v1 &&\
555 (s1)->v2 == (s2)->v2)\
557 ((s1)->v1 == (s2)->v2 &&\
558 (s1)->v2 == (s2)->v1))
559 #define gts_segments_touch(s1, s2) ((s1)->v1 == (s2)->v1 ||\
560 (s1)->v1 == (s2)->v2 ||\
561 (s1)->v2 == (s2)->v1 ||\
562 (s1)->v2 == (s2)->v2)
563 GtsIntersect gts_segments_are_intersecting (GtsSegment * s1,
564 GtsSegment * s2);
565 GtsSegment * gts_segment_is_duplicate (GtsSegment * s);
566 GtsVertex * gts_segment_midvertex (GtsSegment * s,
567 GtsVertexClass * klass);
568 GSList * gts_segments_from_vertices (GSList * vertices);
569 gboolean gts_segment_is_ok (GtsSegment * s);
571 /* Edges: edge.c */
573 #define GTS_IS_EDGE(obj) (gts_object_is_from_class (obj,\
574 gts_edge_class ()))
575 #define GTS_EDGE(obj) GTS_OBJECT_CAST (obj,\
576 GtsEdge,\
577 gts_edge_class ())
578 #define GTS_EDGE_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
579 GtsEdgeClass,\
580 gts_edge_class ())
582 struct _GtsEdge {
583 GtsSegment segment;
585 GSList * triangles;
588 struct _GtsEdgeClass {
589 GtsSegmentClass parent_class;
592 GTS_C_VAR
593 gboolean gts_allow_floating_edges;
595 GtsEdgeClass * gts_edge_class (void);
596 GtsEdge * gts_edge_new (GtsEdgeClass * klass,
597 GtsVertex * v1,
598 GtsVertex * v2);
600 * gts_edge_is_unattached:
601 * @s: a #GtsEdge.
603 * Evaluates to %TRUE if no triangles uses @s as an edge, %FALSE otherwise.
605 #define gts_edge_is_unattached(s) ((s)->triangles == NULL ? TRUE : FALSE)
606 GtsFace * gts_edge_has_parent_surface (GtsEdge * e,
607 GtsSurface * surface);
608 GtsFace * gts_edge_has_any_parent_surface (GtsEdge * e);
609 GtsFace * gts_edge_is_boundary (GtsEdge * e,
610 GtsSurface * surface);
611 void gts_edge_replace (GtsEdge * e,
612 GtsEdge * with);
613 GSList * gts_edges_from_vertices (GSList * vertices,
614 GtsSurface * parent);
615 guint gts_edge_face_number (GtsEdge * e,
616 GtsSurface * s);
617 gboolean gts_edge_collapse_is_valid (GtsEdge * e);
618 gboolean gts_edge_collapse_creates_fold (GtsEdge * e,
619 GtsVertex * v,
620 gdouble max);
621 GtsEdge * gts_edge_is_duplicate (GtsEdge * e);
622 GList * gts_edges_merge (GList * edges);
623 gboolean gts_edge_belongs_to_tetrahedron (GtsEdge * e);
624 guint gts_edge_is_contact (GtsEdge * e);
625 void gts_edge_swap (GtsEdge * e,
626 GtsSurface * s);
627 gboolean gts_edge_manifold_faces (GtsEdge * e,
628 GtsSurface * s,
629 GtsFace ** f1,
630 GtsFace ** f2);
632 /* Triangles: triangle.c */
634 #define GTS_IS_TRIANGLE(obj) (gts_object_is_from_class (obj,\
635 gts_triangle_class ()))
636 #define GTS_TRIANGLE(obj) GTS_OBJECT_CAST (obj,\
637 GtsTriangle,\
638 gts_triangle_class ())
639 #define GTS_TRIANGLE_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
640 GtsTriangleClass,\
641 gts_triangle_class ())
643 struct _GtsTriangle {
644 GtsObject object;
646 GtsEdge * e1;
647 GtsEdge * e2;
648 GtsEdge * e3;
651 struct _GtsTriangleClass {
652 GtsObjectClass parent_class;
655 GtsTriangleClass * gts_triangle_class (void);
656 void gts_triangle_set (GtsTriangle * triangle,
657 GtsEdge * e1,
658 GtsEdge * e2,
659 GtsEdge * e3);
660 GtsTriangle * gts_triangle_new (GtsTriangleClass * klass,
661 GtsEdge * e1,
662 GtsEdge * e2,
663 GtsEdge * e3);
664 #define gts_triangle_vertex(t) (GTS_SEGMENT (GTS_TRIANGLE (t)->e1)->v1 ==\
665 GTS_SEGMENT (GTS_TRIANGLE (t)->e2)->v1 || \
666 GTS_SEGMENT (GTS_TRIANGLE (t)->e1)->v2 ==\
667 GTS_SEGMENT (GTS_TRIANGLE (t)->e2)->v1 ? \
668 GTS_SEGMENT (GTS_TRIANGLE (t)->e2)->v2 :\
669 GTS_SEGMENT (GTS_TRIANGLE (t)->e2)->v1)
670 GtsVertex * gts_triangle_vertex_opposite (GtsTriangle * t,
671 GtsEdge * e);
672 GtsEdge * gts_triangle_edge_opposite (GtsTriangle * t,
673 GtsVertex * v);
674 gdouble gts_triangles_angle (GtsTriangle * t1,
675 GtsTriangle * t2);
676 gboolean gts_triangles_are_compatible (GtsTriangle * t1,
677 GtsTriangle * t2,
678 GtsEdge * e);
679 gdouble gts_triangle_area (GtsTriangle * t);
680 gdouble gts_triangle_perimeter (GtsTriangle * t);
681 gdouble gts_triangle_quality (GtsTriangle * t);
682 void gts_triangle_normal (GtsTriangle * t,
683 gdouble * x,
684 gdouble * y,
685 gdouble * z);
686 gdouble gts_triangle_orientation (GtsTriangle * t);
687 void gts_triangle_revert (GtsTriangle * t);
688 GSList * gts_triangles_from_edges (GSList * edges);
689 void gts_triangle_vertices_edges (GtsTriangle * t,
690 GtsEdge * e,
691 GtsVertex ** v1,
692 GtsVertex ** v2,
693 GtsVertex ** v3,
694 GtsEdge ** e1,
695 GtsEdge ** e2,
696 GtsEdge ** e3);
697 GtsTriangle * gts_triangle_enclosing (GtsTriangleClass * klass,
698 GSList * points,
699 gdouble scale);
700 guint gts_triangle_neighbor_number (GtsTriangle * t);
701 GSList * gts_triangle_neighbors (GtsTriangle * t);
702 GtsEdge * gts_triangles_common_edge (GtsTriangle * t1,
703 GtsTriangle * t2);
704 GtsTriangle * gts_triangle_is_duplicate (GtsTriangle * t);
705 GtsTriangle * gts_triangle_use_edges (GtsEdge * e1,
706 GtsEdge * e2,
707 GtsEdge * e3);
708 gboolean gts_triangle_is_ok (GtsTriangle * t);
709 void gts_triangle_vertices (GtsTriangle * t,
710 GtsVertex ** v1,
711 GtsVertex ** v2,
712 GtsVertex ** v3);
713 GtsPoint * gts_triangle_circumcircle_center (GtsTriangle * t,
714 GtsPointClass * point_class);
715 gboolean gts_triangles_are_folded (GSList * triangles,
716 GtsVertex * A, GtsVertex * B,
717 gdouble max);
718 GtsObject * gts_triangle_is_stabbed (GtsTriangle * t,
719 GtsPoint * p,
720 gdouble * orientation);
721 void gts_triangle_interpolate_height (GtsTriangle * t,
722 GtsPoint * p);
724 /* Faces: face.c */
726 #define GTS_IS_FACE(obj) (gts_object_is_from_class (obj,\
727 gts_face_class ()))
728 #define GTS_FACE(obj) GTS_OBJECT_CAST (obj,\
729 GtsFace,\
730 gts_face_class ())
731 #define GTS_FACE_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
732 GtsFaceClass,\
733 gts_face_class ())
735 struct _GtsFace {
736 GtsTriangle triangle;
738 GSList * surfaces;
741 struct _GtsFaceClass {
742 GtsTriangleClass parent_class;
745 GTS_C_VAR
746 gboolean gts_allow_floating_faces;
748 GtsFaceClass * gts_face_class (void);
749 GtsFace * gts_face_new (GtsFaceClass * klass,
750 GtsEdge * e1,
751 GtsEdge * e2,
752 GtsEdge * e3);
753 gboolean gts_face_has_parent_surface (GtsFace * f,
754 GtsSurface * s);
755 GSList * gts_faces_from_edges (GSList * edges,
756 GtsSurface * s);
757 guint gts_face_neighbor_number (GtsFace * f,
758 GtsSurface * s);
759 GSList * gts_face_neighbors (GtsFace * f,
760 GtsSurface * s);
761 void gts_face_foreach_neighbor (GtsFace * f,
762 GtsSurface * s,
763 GtsFunc func,
764 gpointer data);
765 gboolean gts_face_is_compatible (GtsFace * f,
766 GtsSurface * s);
768 /* Matrices: matrix.c */
770 #define gts_vector_cross(C,A,B) ((C)[0] = (A)[1]*(B)[2] - (A)[2]*(B)[1],\
771 (C)[1] = (A)[2]*(B)[0] - (A)[0]*(B)[2],\
772 (C)[2] = (A)[0]*(B)[1] - (A)[1]*(B)[0])
774 #define gts_vector_init(v, p1, p2) ((v)[0] = (p2)->x - (p1)->x,\
775 (v)[1] = (p2)->y - (p1)->y,\
776 (v)[2] = (p2)->z - (p1)->z)
777 #define gts_vector_scalar(v1, v2) ((v1)[0]*(v2)[0] +\
778 (v1)[1]*(v2)[1] +\
779 (v1)[2]*(v2)[2])
780 #define gts_vector_norm(v) (sqrt ((v)[0]*(v)[0] +\
781 (v)[1]*(v)[1] +\
782 (v)[2]*(v)[2]))
783 #define gts_vector_normalize(v) {\
784 gdouble __gts_n = gts_vector_norm (v);\
785 if (__gts_n > 0.) {\
786 (v)[0] /= __gts_n;\
787 (v)[1] /= __gts_n;\
788 (v)[2] /= __gts_n;\
791 GtsMatrix * gts_matrix_new (gdouble a00, gdouble a01, gdouble a02, gdouble a03,
792 gdouble a10, gdouble a11, gdouble a12, gdouble a13,
793 gdouble a20, gdouble a21, gdouble a22, gdouble a23,
794 gdouble a30, gdouble a31, gdouble a32, gdouble a33);
795 void gts_matrix_assign (GtsMatrix * m,
796 gdouble a00, gdouble a01, gdouble a02, gdouble a03,
797 gdouble a10, gdouble a11, gdouble a12, gdouble a13,
798 gdouble a20, gdouble a21, gdouble a22, gdouble a23,
799 gdouble a30, gdouble a31, gdouble a32, gdouble a33);
800 GtsMatrix * gts_matrix_projection (GtsTriangle * t);
801 GtsMatrix * gts_matrix_transpose (GtsMatrix * m);
802 gdouble gts_matrix_determinant (GtsMatrix * m);
803 GtsMatrix * gts_matrix_inverse (GtsMatrix * m);
804 GtsMatrix * gts_matrix3_inverse (GtsMatrix * m);
805 void gts_matrix_print (GtsMatrix * m,
806 FILE * fptr);
807 guint gts_matrix_compatible_row (GtsMatrix * A,
808 GtsVector b,
809 guint n,
810 GtsVector A1,
811 gdouble b1);
812 guint gts_matrix_quadratic_optimization (GtsMatrix * A,
813 GtsVector b,
814 guint n,
815 GtsMatrix * H,
816 GtsVector c);
817 GtsMatrix * gts_matrix_product (GtsMatrix * m1,
818 GtsMatrix * m2);
819 GtsMatrix * gts_matrix_zero (GtsMatrix * m);
820 GtsMatrix * gts_matrix_identity (GtsMatrix * m);
821 GtsMatrix * gts_matrix_scale (GtsMatrix * m,
822 GtsVector s);
823 GtsMatrix * gts_matrix_translate (GtsMatrix * m,
824 GtsVector t);
825 GtsMatrix * gts_matrix_rotate (GtsMatrix * m,
826 GtsVector r,
827 gdouble angle);
828 void gts_matrix_destroy (GtsMatrix * m);
829 void gts_vector_print (GtsVector v,
830 FILE * fptr);
831 void gts_vector4_print (GtsVector4 v,
832 FILE * fptr);
834 /* Kdtrees: kdtree.c */
836 #define gts_kdtree_destroy(tree) g_node_destroy(tree)
838 GNode * gts_kdtree_new (GPtrArray * points,
839 int (*compare)
840 (const void *,
841 const void *));
842 GSList * gts_kdtree_range (GNode * tree,
843 GtsBBox * bbox,
844 int (*compare)
845 (const void *,
846 const void *));
848 /* Bboxtrees: bbtree.c */
851 * GtsBBTreeTraverseFunc:
852 * @bb1: a #GtsBBox.
853 * @bb2: another #GtsBBox.
854 * @data: user data passed to the function.
856 * User function called for each pair of overlapping bounding
857 * boxes. See gts_bb_tree_traverse_overlapping().
859 typedef void (*GtsBBTreeTraverseFunc) (GtsBBox * bb1,
860 GtsBBox * bb2,
861 gpointer data);
863 * GtsBBoxDistFunc:
864 * @p: a #GtsPoint.
865 * @bounded: an object bounded by a #GtsBBox.
867 * User function returning the (minimum) distance between the object
868 * defined by @bounded and point @p.
870 * Returns: the distance between @p and @bounded.
872 typedef gdouble (*GtsBBoxDistFunc) (GtsPoint * p,
873 gpointer bounded);
875 * GtsBBoxClosestFunc:
876 * @p: a #GtsPoint.
877 * @bounded: an object bounded by a #GtsBBox.
879 * User function returning a #GtsPoint belonging to the object defined
880 * by @bounded and closest to @p.
882 * Returns: a #GtsPoint.
884 typedef GtsPoint * (*GtsBBoxClosestFunc) (GtsPoint * p,
885 gpointer bounded);
888 * GTS_IS_BBOX:
889 * @obj: a #GtsObject.
891 * Evaluates to %TRUE if @obj is a #GtsBBox, %FALSE otherwise.
893 #define GTS_IS_BBOX(obj) (gts_object_is_from_class (obj,\
894 gts_bbox_class ()))
896 * GTS_BBOX:
897 * @obj: a #GtsObject.
899 * Casts @obj to #GtsBBox.
901 #define GTS_BBOX(obj) GTS_OBJECT_CAST (obj,\
902 GtsBBox,\
903 gts_bbox_class ())
905 * GTS_BBOX_CLASS:
906 * @klass: a descendant of #GtsBBoxClass.
908 * Casts @klass to #GtsBBoxClass.
910 #define GTS_BBOX_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
911 GtsBBoxClass,\
912 gts_bbox_class ())
914 struct _GtsBBox {
915 GtsObject object;
916 gpointer bounded;
917 gdouble x1, y1, z1;
918 gdouble x2, y2, z2;
921 struct _GtsBBoxClass {
922 GtsObjectClass parent_class;
925 GtsBBoxClass * gts_bbox_class (void);
926 GtsBBox * gts_bbox_new (GtsBBoxClass * klass,
927 gpointer bounded,
928 gdouble x1,
929 gdouble y1,
930 gdouble z1,
931 gdouble x2,
932 gdouble y2,
933 gdouble z2);
934 void gts_bbox_set (GtsBBox * bbox,
935 gpointer bounded,
936 gdouble x1,
937 gdouble y1,
938 gdouble z1,
939 gdouble x2,
940 gdouble y2,
941 gdouble z2);
942 GtsBBox * gts_bbox_segment (GtsBBoxClass * klass,
943 GtsSegment * s);
944 GtsBBox * gts_bbox_triangle (GtsBBoxClass * klass,
945 GtsTriangle * t);
946 GtsBBox * gts_bbox_surface (GtsBBoxClass * klass,
947 GtsSurface * surface);
948 GtsBBox * gts_bbox_bboxes (GtsBBoxClass * klass,
949 GSList * bboxes);
950 GtsBBox * gts_bbox_points (GtsBBoxClass * klass,
951 GSList * points);
953 * gts_bbox_point_is_inside:
954 * @bbox: a #GtsBBox.
955 * @p: a #GtsPoint.
957 * Evaluates to %TRUE if @p is inside (or on the boundary) of @bbox, %FALSE otherwise.
959 #define gts_bbox_point_is_inside(bbox, p) ((p)->x >= (bbox)->x1 &&\
960 (p)->y >= (bbox)->y1 &&\
961 (p)->z >= (bbox)->z1 &&\
962 (p)->x <= (bbox)->x2 &&\
963 (p)->y <= (bbox)->y2 &&\
964 (p)->z <= (bbox)->z2)
965 gboolean gts_bboxes_are_overlapping (GtsBBox * bb1,
966 GtsBBox * bb2);
967 void gts_bbox_draw (GtsBBox * bb,
968 FILE * fptr);
969 gdouble gts_bbox_diagonal2 (GtsBBox * bb);
970 void gts_bbox_point_distance2 (GtsBBox * bb,
971 GtsPoint * p,
972 gdouble * min,
973 gdouble * max);
974 gboolean gts_bbox_is_stabbed (GtsBBox * bb,
975 GtsPoint * p);
976 gboolean gts_bbox_overlaps_triangle (GtsBBox * bb,
977 GtsTriangle * t);
978 gboolean gts_bbox_overlaps_segment (GtsBBox * bb,
979 GtsSegment * s);
981 GNode * gts_bb_tree_new (GSList * bboxes);
982 GNode * gts_bb_tree_surface (GtsSurface * s);
983 GSList * gts_bb_tree_stabbed (GNode * tree,
984 GtsPoint * p);
985 GSList * gts_bb_tree_overlap (GNode * tree,
986 GtsBBox * bbox);
987 gboolean gts_bb_tree_is_overlapping (GNode * tree,
988 GtsBBox * bbox);
989 void gts_bb_tree_traverse_overlapping (GNode * tree1,
990 GNode * tree2,
991 GtsBBTreeTraverseFunc func,
992 gpointer data);
993 void gts_bb_tree_draw (GNode * tree,
994 guint depth,
995 FILE * fptr);
996 GSList * gts_bb_tree_point_closest_bboxes (GNode * tree,
997 GtsPoint * p);
998 gdouble gts_bb_tree_point_distance (GNode * tree,
999 GtsPoint * p,
1000 GtsBBoxDistFunc distance,
1001 GtsBBox ** bbox);
1002 GtsPoint * gts_bb_tree_point_closest (GNode * tree,
1003 GtsPoint * p,
1004 GtsBBoxClosestFunc closest,
1005 gdouble * distance);
1006 void gts_bb_tree_segment_distance (GNode * tree,
1007 GtsSegment * s,
1008 GtsBBoxDistFunc distance,
1009 gdouble delta,
1010 GtsRange * range);
1011 void gts_bb_tree_triangle_distance (GNode * tree,
1012 GtsTriangle * t,
1013 GtsBBoxDistFunc distance,
1014 gdouble delta,
1015 GtsRange * range);
1016 void gts_bb_tree_surface_distance (GNode * tree,
1017 GtsSurface * s,
1018 GtsBBoxDistFunc distance,
1019 gdouble delta,
1020 GtsRange * range);
1021 void gts_bb_tree_surface_boundary_distance
1022 (GNode * tree,
1023 GtsSurface * s,
1024 GtsBBoxDistFunc distance,
1025 gdouble delta,
1026 GtsRange * range);
1027 void gts_bb_tree_destroy (GNode * tree,
1028 gboolean free_leaves);
1030 /* Surfaces: surface.c */
1032 typedef struct _GtsSurfaceStats GtsSurfaceStats;
1033 typedef struct _GtsSurfaceQualityStats GtsSurfaceQualityStats;
1034 typedef GtsVertex * (*GtsRefineFunc) (GtsEdge * e,
1035 GtsVertexClass * klass,
1036 gpointer data);
1037 typedef GtsVertex * (*GtsCoarsenFunc) (GtsEdge * e,
1038 GtsVertexClass * klass,
1039 gpointer data);
1040 typedef gboolean (*GtsStopFunc) (gdouble cost,
1041 guint nedge,
1042 gpointer data);
1044 struct _GtsSurfaceStats {
1045 guint n_faces;
1046 guint n_incompatible_faces;
1047 guint n_duplicate_faces;
1048 guint n_duplicate_edges;
1049 guint n_boundary_edges;
1050 guint n_non_manifold_edges;
1051 GtsRange edges_per_vertex, faces_per_edge;
1052 GtsSurface * parent;
1055 struct _GtsSurfaceQualityStats {
1056 GtsRange face_quality;
1057 GtsRange face_area;
1058 GtsRange edge_length;
1059 GtsRange edge_angle;
1060 GtsSurface * parent;
1063 struct _GtsSurface {
1064 GtsObject object;
1066 #ifdef USE_SURFACE_BTREE
1067 GTree * faces;
1068 #else /* not USE_SURFACE_BTREE */
1069 GHashTable * faces;
1070 #endif /* not USE_SURFACE_BTREE */
1071 GtsFaceClass * face_class;
1072 GtsEdgeClass * edge_class;
1073 GtsVertexClass * vertex_class;
1074 gboolean keep_faces;
1077 struct _GtsSurfaceClass {
1078 GtsObjectClass parent_class;
1080 void (* add_face) (GtsSurface *, GtsFace *);
1081 void (* remove_face) (GtsSurface *, GtsFace *);
1084 #define GTS_IS_SURFACE(obj) (gts_object_is_from_class (obj,\
1085 gts_surface_class ()))
1086 #define GTS_SURFACE(obj) GTS_OBJECT_CAST (obj,\
1087 GtsSurface,\
1088 gts_surface_class ())
1089 #define GTS_SURFACE_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
1090 GtsSurfaceClass,\
1091 gts_surface_class ())
1093 GtsSurfaceClass * gts_surface_class (void);
1094 GtsSurface * gts_surface_new (GtsSurfaceClass * klass,
1095 GtsFaceClass * face_class,
1096 GtsEdgeClass * edge_class,
1097 GtsVertexClass * vertex_class);
1098 void gts_surface_add_face (GtsSurface * s,
1099 GtsFace * f);
1100 void gts_surface_remove_face (GtsSurface * s,
1101 GtsFace * f);
1102 guint gts_surface_read (GtsSurface * surface,
1103 GtsFile * f);
1104 gdouble gts_surface_area (GtsSurface * s);
1105 void gts_surface_stats (GtsSurface * s,
1106 GtsSurfaceStats * stats);
1107 void gts_surface_quality_stats (GtsSurface * s,
1108 GtsSurfaceQualityStats * stats);
1109 void gts_surface_print_stats (GtsSurface * s,
1110 FILE * fptr);
1111 void gts_surface_write (GtsSurface * s,
1112 FILE * fptr);
1113 void gts_surface_write_oogl (GtsSurface * s,
1114 FILE * fptr);
1115 void gts_surface_write_vtk (GtsSurface * s,
1116 FILE * fptr);
1117 void gts_surface_write_oogl_boundary (GtsSurface * s,
1118 FILE * fptr);
1119 void gts_surface_foreach_vertex (GtsSurface * s,
1120 GtsFunc func,
1121 gpointer data);
1122 void gts_surface_foreach_edge (GtsSurface * s,
1123 GtsFunc func,
1124 gpointer data);
1125 void gts_surface_foreach_face (GtsSurface * s,
1126 GtsFunc func,
1127 gpointer data);
1128 guint gts_surface_foreach_face_remove (GtsSurface * s,
1129 GtsFunc func,
1130 gpointer data);
1131 typedef struct _GtsSurfaceTraverse GtsSurfaceTraverse;
1132 GtsSurfaceTraverse * gts_surface_traverse_new (GtsSurface * s,
1133 GtsFace * f);
1134 GtsFace * gts_surface_traverse_next (GtsSurfaceTraverse * t,
1135 guint * level);
1136 void gts_surface_traverse_destroy (GtsSurfaceTraverse * t);
1137 void gts_surface_refine (GtsSurface * surface,
1138 GtsKeyFunc cost_func,
1139 gpointer cost_data,
1140 GtsRefineFunc refine_func,
1141 gpointer refine_data,
1142 GtsStopFunc stop_func,
1143 gpointer stop_data);
1144 gboolean gts_edge_collapse_is_valid (GtsEdge * e);
1145 void gts_surface_coarsen (GtsSurface * surface,
1146 GtsKeyFunc cost_func,
1147 gpointer cost_data,
1148 GtsCoarsenFunc coarsen_func,
1149 gpointer coarsen_data,
1150 GtsStopFunc stop_func,
1151 gpointer stop_data,
1152 gdouble minangle);
1153 gboolean gts_coarsen_stop_number (gdouble cost,
1154 guint nedge,
1155 guint * min_number);
1156 gboolean gts_coarsen_stop_cost (gdouble cost,
1157 guint nedge,
1158 gdouble * max_cost);
1159 void gts_surface_tessellate (GtsSurface * s,
1160 GtsRefineFunc refine_func,
1161 gpointer refine_data);
1162 GtsSurface * gts_surface_generate_sphere (GtsSurface * s,
1163 guint geodesation_order);
1164 GtsSurface * gts_surface_copy (GtsSurface * s1,
1165 GtsSurface * s2);
1166 void gts_surface_merge (GtsSurface * s,
1167 GtsSurface * with);
1168 gboolean gts_surface_is_manifold (GtsSurface * s);
1169 gboolean gts_surface_is_closed (GtsSurface * s);
1170 gboolean gts_surface_is_orientable (GtsSurface * s);
1171 gdouble gts_surface_volume (GtsSurface * s);
1172 gdouble gts_surface_center_of_mass (GtsSurface * s,
1173 GtsVector cm);
1174 gdouble gts_surface_center_of_area (GtsSurface * s,
1175 GtsVector cm);
1176 guint gts_surface_vertex_number (GtsSurface * s);
1177 guint gts_surface_edge_number (GtsSurface * s);
1178 guint gts_surface_face_number (GtsSurface * s);
1179 void gts_surface_distance (GtsSurface * s1,
1180 GtsSurface * s2,
1181 gdouble delta,
1182 GtsRange * face_range,
1183 GtsRange * boundary_range);
1184 GSList * gts_surface_boundary (GtsSurface * surface);
1185 GSList * gts_surface_split (GtsSurface * s);
1187 /* Discrete differential operators: curvature.c */
1189 gboolean gts_vertex_mean_curvature_normal (GtsVertex * v,
1190 GtsSurface * s,
1191 GtsVector Kh);
1192 gboolean gts_vertex_gaussian_curvature (GtsVertex * v,
1193 GtsSurface * s,
1194 gdouble * Kg);
1195 void gts_vertex_principal_curvatures (gdouble Kh,
1196 gdouble Kg,
1197 gdouble * K1,
1198 gdouble * K2);
1199 void gts_vertex_principal_directions (GtsVertex * v,
1200 GtsSurface * s,
1201 GtsVector Kh,
1202 gdouble Kg,
1203 GtsVector e1,
1204 GtsVector e2);
1206 /* Volume optimization: vopt.c */
1207 typedef struct _GtsVolumeOptimizedParams GtsVolumeOptimizedParams;
1209 struct _GtsVolumeOptimizedParams {
1210 gdouble volume_weight;
1211 gdouble boundary_weight;
1212 gdouble shape_weight;
1215 GtsVertex * gts_volume_optimized_vertex (GtsEdge * edge,
1216 GtsVertexClass * klass,
1217 GtsVolumeOptimizedParams * params);
1218 gdouble gts_volume_optimized_cost (GtsEdge * e,
1219 GtsVolumeOptimizedParams * params);
1221 /* bool operations: boolean.c */
1223 GSList * gts_surface_intersection (GtsSurface * s1,
1224 GtsSurface * s2,
1225 GNode * faces_tree1,
1226 GNode * faces_tree2);
1228 typedef struct _GtsSurfaceInter GtsSurfaceInter;
1229 typedef struct _GtsSurfaceInterClass GtsSurfaceInterClass;
1231 * GtsBooleanOperation:
1232 * @GTS_1_OUT_2: identifies the part of the first surface which lies
1233 * outside the second surface.
1234 * @GTS_1_IN_2: identifies the part of the first surface which lies
1235 * inside the second surface.
1236 * @GTS_2_OUT_1: identifies the part of the second surface which lies
1237 * outside the first surface.
1238 * @GTS_2_IN_1: identifies the part of the second surface which lies
1239 * inside the first surface.
1241 typedef enum { GTS_1_OUT_2,
1242 GTS_1_IN_2,
1243 GTS_2_OUT_1,
1244 GTS_2_IN_1 } GtsBooleanOperation;
1247 * GTS_IS_SURFACE_INTER:
1248 * @obj: a #GtsObject.
1250 * Evaluates to %TRUE if @obj is a #GtsSurfaceInter, %FALSE otherwise.
1252 #define GTS_IS_SURFACE_INTER(obj) (gts_object_is_from_class (obj,\
1253 gts_surface_inter_class ()))
1255 * GTS_SURFACE_INTER:
1256 * @obj: a descendant of #GtsSurfaceInter.
1258 * Casts @obj to #GtsSurfaceInter.
1260 #define GTS_SURFACE_INTER(obj) GTS_OBJECT_CAST (obj,\
1261 GtsSurfaceInter,\
1262 gts_surface_inter_class ())
1264 * GTS_SURFACE_INTER_CLASS:
1265 * @klass: a descendant of #GtsSurfaceInterClass.
1267 * Casts @klass to #GtsSurfaceInterClass.
1269 #define GTS_SURFACE_INTER_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
1270 GtsSurfaceInterClass,\
1271 gts_surface_inter_class ())
1273 struct _GtsSurfaceInter {
1274 GtsObject object;
1276 GtsSurface * s1;
1277 GtsSurface * s2;
1278 GSList * edges;
1281 struct _GtsSurfaceInterClass {
1282 GtsObjectClass parent_class;
1285 GtsSurfaceInterClass *
1286 gts_surface_inter_class (void);
1287 GtsSurfaceInter *
1288 gts_surface_inter_new (GtsSurfaceInterClass * klass,
1289 GtsSurface * s1,
1290 GtsSurface * s2,
1291 GNode * faces_tree1,
1292 GNode * faces_tree2,
1293 gboolean is_open1,
1294 gboolean is_open2);
1295 gboolean
1296 gts_surface_inter_check (GtsSurfaceInter * si,
1297 gboolean * closed);
1298 void
1299 gts_surface_inter_boolean (GtsSurfaceInter * si,
1300 GtsSurface * surface,
1301 GtsBooleanOperation op);
1302 gboolean gts_surface_foreach_intersecting_face (GtsSurface * s,
1303 GtsBBTreeTraverseFunc func,
1304 gpointer data);
1305 GtsSurface *
1306 gts_surface_is_self_intersecting (GtsSurface * s);
1308 /* Binary Heap: heap.c */
1310 typedef struct _GtsHeap GtsHeap;
1312 GtsHeap * gts_heap_new (GCompareFunc compare_func);
1313 void gts_heap_insert (GtsHeap * heap, gpointer p);
1314 gpointer gts_heap_remove_top (GtsHeap * heap);
1315 gpointer gts_heap_top (GtsHeap * heap);
1316 void gts_heap_thaw (GtsHeap * heap);
1317 void gts_heap_foreach (GtsHeap * heap,
1318 GFunc func,
1319 gpointer user_data);
1320 void gts_heap_freeze (GtsHeap * heap);
1321 guint gts_heap_size (GtsHeap * heap);
1322 void gts_heap_destroy (GtsHeap * heap);
1324 /* Extended Binary Heap: eheap.c */
1326 typedef struct _GtsEHeap GtsEHeap;
1327 typedef struct _GtsEHeapPair GtsEHeapPair;
1329 struct _GtsEHeap {
1330 GPtrArray * elts;
1331 GtsKeyFunc func;
1332 gpointer data;
1333 gboolean frozen, randomized;
1337 * _GtsEHeapPair:
1338 * @data: Points to the item stored in the heap.
1339 * @key: Value of the key for this item.
1340 * @pos: Private field.
1342 struct _GtsEHeapPair {
1343 gpointer data;
1344 gdouble key;
1345 guint pos;
1348 GtsEHeap * gts_eheap_new (GtsKeyFunc key_func,
1349 gpointer data);
1350 GtsEHeapPair * gts_eheap_insert (GtsEHeap * heap,
1351 gpointer p);
1352 GtsEHeapPair * gts_eheap_insert_with_key (GtsEHeap * heap,
1353 gpointer p,
1354 gdouble key);
1355 gpointer gts_eheap_remove_top (GtsEHeap * heap,
1356 gdouble * key);
1357 gpointer gts_eheap_top (GtsEHeap * heap,
1358 gdouble * key);
1359 void gts_eheap_thaw (GtsEHeap * heap);
1360 void gts_eheap_foreach (GtsEHeap * heap,
1361 GFunc func,
1362 gpointer data);
1363 gpointer gts_eheap_remove (GtsEHeap * heap,
1364 GtsEHeapPair * p);
1365 void gts_eheap_decrease_key (GtsEHeap * heap,
1366 GtsEHeapPair * p,
1367 gdouble new_key);
1368 void gts_eheap_freeze (GtsEHeap * heap);
1369 guint gts_eheap_size (GtsEHeap * heap);
1370 void gts_eheap_update (GtsEHeap * heap);
1371 gdouble gts_eheap_key (GtsEHeap * heap,
1372 gpointer p);
1373 void gts_eheap_randomized (GtsEHeap * heap,
1374 gboolean randomized);
1375 void gts_eheap_destroy (GtsEHeap * heap);
1377 /* FIFO queues: fifo.c */
1379 typedef struct _GtsFifo GtsFifo;
1381 GtsFifo * gts_fifo_new (void);
1382 void gts_fifo_write (GtsFifo * fifo,
1383 FILE * fp);
1384 void gts_fifo_push (GtsFifo * fifo,
1385 gpointer data);
1386 gpointer gts_fifo_pop (GtsFifo * fifo);
1387 gpointer gts_fifo_top (GtsFifo * fifo);
1388 guint gts_fifo_size (GtsFifo * fifo);
1389 gboolean gts_fifo_is_empty (GtsFifo * fifo);
1390 void gts_fifo_foreach (GtsFifo * fifo,
1391 GtsFunc func,
1392 gpointer data);
1393 void gts_fifo_reverse (GtsFifo * fifo);
1394 void gts_fifo_destroy (GtsFifo * fifo);
1396 /* Progressive surfaces */
1398 /* split.c */
1400 typedef struct _GtsSplit GtsSplit;
1401 typedef struct _GtsSplitClass GtsSplitClass;
1402 typedef struct _GtsSplitCFace GtsSplitCFace;
1404 struct _GtsSplit {
1405 GtsObject object;
1407 GtsVertex * v;
1408 GtsObject * v1;
1409 GtsObject * v2;
1410 GtsSplitCFace * cfaces;
1411 guint ncf;
1414 struct _GtsSplitClass {
1415 GtsObjectClass parent_class;
1418 #define GTS_IS_SPLIT(obj) (gts_object_is_from_class (obj,\
1419 gts_split_class ()))
1420 #define GTS_SPLIT(obj) GTS_OBJECT_CAST (obj,\
1421 GtsSplit,\
1422 gts_split_class ())
1423 #define GTS_SPLIT_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
1424 GtsSplitClass,\
1425 gts_split_class ())
1426 #define GTS_SPLIT_V1(vs) (GTS_IS_SPLIT ((vs)->v1) ?\
1427 GTS_SPLIT ((vs)->v1)->v :\
1428 GTS_VERTEX ((vs)->v1))
1429 #define GTS_SPLIT_V2(vs) (GTS_IS_SPLIT ((vs)->v2) ?\
1430 GTS_SPLIT ((vs)->v2)->v :\
1431 GTS_VERTEX ((vs)->v2))
1433 GtsSplitClass * gts_split_class (void);
1434 GtsSplit * gts_split_new (GtsSplitClass * klass,
1435 GtsVertex * v,
1436 GtsObject * o1,
1437 GtsObject * o2);
1438 void gts_split_collapse (GtsSplit * vs,
1439 GtsEdgeClass * klass,
1440 GtsEHeap * heap);
1441 void gts_split_expand (GtsSplit * vs,
1442 GtsSurface * s,
1443 GtsEdgeClass * klass);
1444 typedef gboolean (*GtsSplitTraverseFunc) (GtsSplit * vs,
1445 gpointer data);
1446 void gts_split_traverse (GtsSplit * root,
1447 GTraverseType order,
1448 gint depth,
1449 GtsSplitTraverseFunc func,
1450 gpointer data);
1451 guint gts_split_height (GtsSplit * root);
1453 /* psurface.c */
1455 typedef struct _GtsPSurface GtsPSurface;
1456 typedef struct _GtsPSurfaceClass GtsPSurfaceClass;
1458 struct _GtsPSurface {
1459 GtsObject object;
1461 GtsSurface * s;
1462 GPtrArray * split;
1463 GtsSplitClass * split_class;
1464 guint pos, min;
1466 GPtrArray * vertices;
1467 GPtrArray * faces;
1470 struct _GtsPSurfaceClass {
1471 GtsObjectClass parent_class;
1474 #define GTS_IS_PSURFACE(obj) (gts_object_is_from_class (obj,\
1475 gts_psurface_class ()))
1476 #define GTS_PSURFACE(obj) GTS_OBJECT_CAST (obj,\
1477 GtsPSurface,\
1478 gts_psurface_class ())
1479 #define GTS_PSURFACE_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
1480 GtsPSurfaceClass,\
1481 gts_psurface_class ())
1482 #define GTS_PSURFACE_IS_CLOSED(ps) (!(ps)->vertices)
1484 GtsPSurfaceClass * gts_psurface_class (void);
1485 GtsPSurface * gts_psurface_new (GtsPSurfaceClass * klass,
1486 GtsSurface * surface,
1487 GtsSplitClass * split_class,
1488 GtsKeyFunc cost_func,
1489 gpointer cost_data,
1490 GtsCoarsenFunc coarsen_func,
1491 gpointer coarsen_data,
1492 GtsStopFunc stop_func,
1493 gpointer stop_data,
1494 gdouble minangle);
1495 GtsSplit * gts_psurface_add_vertex (GtsPSurface * ps);
1496 GtsSplit * gts_psurface_remove_vertex (GtsPSurface * ps);
1497 guint gts_psurface_max_vertex_number (GtsPSurface * ps);
1498 guint gts_psurface_min_vertex_number (GtsPSurface * ps);
1499 void gts_psurface_set_vertex_number (GtsPSurface * ps,
1500 guint n);
1501 guint gts_psurface_get_vertex_number (GtsPSurface * ps);
1502 void gts_psurface_write (GtsPSurface * ps,
1503 FILE * fptr);
1504 GtsPSurface * gts_psurface_open (GtsPSurfaceClass * klass,
1505 GtsSurface * s,
1506 GtsSplitClass * split_class,
1507 GtsFile * f);
1508 GtsSplit * gts_psurface_read_vertex (GtsPSurface * ps,
1509 GtsFile * fp);
1510 void gts_psurface_close (GtsPSurface * ps);
1511 void gts_psurface_foreach_vertex (GtsPSurface * ps,
1512 GtsFunc func,
1513 gpointer data);
1515 /* hsurface.c */
1517 typedef struct _GtsHSplit GtsHSplit;
1518 typedef struct _GtsHSplitClass GtsHSplitClass;
1519 typedef struct _GtsHSurface GtsHSurface;
1520 typedef struct _GtsHSurfaceClass GtsHSurfaceClass;
1522 struct _GtsHSplit {
1523 GtsSplit split;
1525 GtsEHeapPair * index;
1526 GtsHSplit * parent;
1527 guint nchild;
1530 struct _GtsHSplitClass {
1531 GtsSplitClass parent_class;
1534 #define GTS_IS_HSPLIT(obj) (gts_object_is_from_class (obj,\
1535 gts_hsplit_class ()))
1536 #define GTS_HSPLIT(obj) GTS_OBJECT_CAST (obj,\
1537 GtsHSplit,\
1538 gts_hsplit_class ())
1539 #define GTS_HSPLIT_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
1540 GtsHSplitClass,\
1541 gts_hsplit_class ())
1543 GtsHSplitClass * gts_hsplit_class (void);
1544 GtsHSplit * gts_hsplit_new (GtsHSplitClass * klass,
1545 GtsSplit * vs);
1546 void gts_hsplit_collapse (GtsHSplit * hs,
1547 GtsHSurface * hsurface);
1548 void gts_hsplit_expand (GtsHSplit * hs,
1549 GtsHSurface * hsurface);
1550 void gts_hsplit_force_expand (GtsHSplit * hs,
1551 GtsHSurface * hsurface);
1553 struct _GtsHSurface {
1554 GtsObject object;
1556 GtsSurface * s;
1557 GSList * roots;
1558 GtsEHeap * expandable;
1559 GtsEHeap * collapsable;
1560 GPtrArray * split;
1561 guint nvertex;
1564 struct _GtsHSurfaceClass {
1565 GtsObjectClass parent_class;
1568 #define GTS_IS_HSURFACE(obj) (gts_object_is_from_class (obj,\
1569 gts_hsurface_class ()))
1570 #define GTS_HSURFACE(obj) GTS_OBJECT_CAST (obj,\
1571 GtsHSurface,\
1572 gts_hsurface_class ())
1573 #define GTS_HSURFACE_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
1574 GtsHSurfaceClass,\
1575 gts_hsurface_class ())
1577 GtsHSurfaceClass * gts_hsurface_class (void);
1578 GtsHSurface * gts_hsurface_new (GtsHSurfaceClass * klass,
1579 GtsHSplitClass * hsplit_class,
1580 GtsPSurface * psurface,
1581 GtsKeyFunc expand_key,
1582 gpointer expand_data,
1583 GtsKeyFunc collapse_key,
1584 gpointer collapse_data);
1585 void gts_hsurface_traverse (GtsHSurface * hsurface,
1586 GTraverseType order,
1587 gint depth,
1588 GtsSplitTraverseFunc func,
1589 gpointer data);
1590 void gts_hsurface_foreach (GtsHSurface * hsurface,
1591 GTraverseType order,
1592 GtsFunc func,
1593 gpointer data);
1594 guint gts_hsurface_height (GtsHSurface * hsurface);
1596 /* Constrained Delaunay triangulation: cdt.c */
1599 * GTS_IS_CONSTRAINT:
1600 * @obj: a #GtsObject.
1602 * Evaluates to %TRUE if @obj is a #GtsConstraint, %FALSE otherwise.
1604 #define GTS_IS_CONSTRAINT(obj) (gts_object_is_from_class (obj,\
1605 gts_constraint_class ()))
1607 * GTS_CONSTRAINT:
1608 * @obj: a descendant of #GtsConstraint.
1610 * Casts @obj to #GtsConstraint.
1612 #define GTS_CONSTRAINT(obj) GTS_OBJECT_CAST (obj,\
1613 GtsConstraint,\
1614 gts_constraint_class ())
1616 * GTS_CONSTRAINT_CLASS:
1617 * @klass: a desscendant of #GtsConstraintClass.
1619 * Casts @klass to #GtsConstraintClass.
1621 #define GTS_CONSTRAINT_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
1622 GtsConstraintClass,\
1623 gts_constraint_class ())
1625 struct _GtsConstraint {
1626 GtsEdge edge;
1629 struct _GtsConstraintClass {
1630 GtsEdgeClass parent_class;
1633 typedef struct _GtsConstraint GtsConstraint;
1634 typedef struct _GtsConstraintClass GtsConstraintClass;
1636 GtsConstraintClass * gts_constraint_class (void);
1638 GtsFace * gts_point_locate (GtsPoint * p,
1639 GtsSurface * surface,
1640 GtsFace * guess);
1641 GtsVertex * gts_delaunay_add_vertex_to_face (GtsSurface * surface,
1642 GtsVertex * v,
1643 GtsFace * f);
1644 GtsVertex * gts_delaunay_add_vertex (GtsSurface * surface,
1645 GtsVertex * v,
1646 GtsFace * guess);
1647 void gts_delaunay_remove_vertex (GtsSurface * surface,
1648 GtsVertex * v);
1649 GtsFace * gts_delaunay_check (GtsSurface * surface);
1650 GSList * gts_delaunay_add_constraint (GtsSurface * surface,
1651 GtsConstraint * c);
1652 void gts_delaunay_remove_hull (GtsSurface * surface);
1654 /* GtsListFace: Header */
1656 typedef struct _GtsListFace GtsListFace;
1658 struct _GtsListFace {
1659 /*< private >*/
1660 GtsFace parent;
1662 /*< public >*/
1663 GSList * points;
1666 #define GTS_LIST_FACE(obj) GTS_OBJECT_CAST (obj,\
1667 GtsListFace,\
1668 gts_list_face_class ())
1669 #define GTS_IS_LIST_FACE(obj) (gts_object_is_from_class (obj,\
1670 gts_list_face_class ()))
1672 GtsFaceClass * gts_list_face_class (void);
1674 /* Constrained Delaunay refinement: refine.c */
1676 typedef gboolean (* GtsEncroachFunc) (GtsVertex * v,
1677 GtsEdge * e,
1678 GtsSurface * s,
1679 gpointer data);
1681 gboolean gts_vertex_encroaches_edge (GtsVertex * v,
1682 GtsEdge * e);
1683 GtsVertex * gts_edge_is_encroached (GtsEdge * e,
1684 GtsSurface * s,
1685 GtsEncroachFunc encroaches,
1686 gpointer data);
1687 guint gts_delaunay_conform (GtsSurface * surface,
1688 gint steiner_max,
1689 GtsEncroachFunc encroaches,
1690 gpointer data);
1691 guint gts_delaunay_refine (GtsSurface * surface,
1692 gint steiner_max,
1693 GtsEncroachFunc encroaches,
1694 gpointer encroach_data,
1695 GtsKeyFunc cost,
1696 gpointer cost_data);
1698 /* Isosurfaces (marching cubes): iso.c */
1700 typedef struct _GtsGridPlane GtsGridPlane;
1701 typedef struct _GtsIsoSlice GtsIsoSlice;
1702 typedef struct _GtsCartesianGrid GtsCartesianGrid;
1704 struct _GtsGridPlane {
1705 GtsPoint ** p;
1706 guint nx, ny;
1709 struct _GtsCartesianGrid {
1710 guint nx, ny, nz;
1711 gdouble x, dx, y, dy, z, dz;
1714 typedef void (*GtsIsoCartesianFunc) (gdouble ** a,
1715 GtsCartesianGrid g,
1716 guint i,
1717 gpointer data);
1719 GtsGridPlane * gts_grid_plane_new (guint nx,
1720 guint ny);
1721 void gts_grid_plane_destroy (GtsGridPlane * g);
1722 GtsIsoSlice * gts_iso_slice_new (guint nx, guint ny);
1723 void gts_iso_slice_fill (GtsIsoSlice * slice,
1724 GtsGridPlane * plane1,
1725 GtsGridPlane * plane2,
1726 gdouble ** f1,
1727 gdouble ** f2,
1728 gdouble iso,
1729 GtsVertexClass * klass);
1730 void gts_iso_slice_fill_cartesian (GtsIsoSlice * slice,
1731 GtsCartesianGrid g,
1732 gdouble ** f1,
1733 gdouble ** f2,
1734 gdouble iso,
1735 GtsVertexClass * klass);
1736 void gts_iso_slice_destroy (GtsIsoSlice * slice);
1737 void gts_isosurface_slice (GtsIsoSlice * slice1,
1738 GtsIsoSlice * slice2,
1739 GtsSurface * surface);
1740 void gts_isosurface_cartesian (GtsSurface * surface,
1741 GtsCartesianGrid g,
1742 GtsIsoCartesianFunc f,
1743 gpointer data,
1744 gdouble iso);
1746 /* Isosurfaces (marching tetrahedra): isotetra.c */
1748 void gts_isosurface_tetra (GtsSurface * surface,
1749 GtsCartesianGrid g,
1750 GtsIsoCartesianFunc f,
1751 gpointer data,
1752 gdouble iso);
1753 void gts_isosurface_tetra_bcl (GtsSurface * surface,
1754 GtsCartesianGrid g,
1755 GtsIsoCartesianFunc f,
1756 gpointer data,
1757 gdouble iso);
1758 void gts_isosurface_tetra_bounded (GtsSurface * surface,
1759 GtsCartesianGrid g,
1760 GtsIsoCartesianFunc f,
1761 gpointer data,
1762 gdouble iso);
1764 /* Named vertices, edges and triangles: named.c */
1766 #define GTS_NAME_LENGTH 40
1768 #define GTS_NVERTEX(obj) GTS_OBJECT_CAST (obj,\
1769 GtsNVertex,\
1770 gts_nvertex_class ())
1771 #define GTS_NVERTEX_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
1772 GtsNVertexClass,\
1773 gts_nvertex_class())
1774 #define GTS_IS_NVERTEX(obj) (gts_object_is_from_class (obj,\
1775 gts_nvertex_class ()))
1777 typedef struct _GtsNVertex GtsNVertex;
1778 typedef struct _GtsNVertexClass GtsNVertexClass;
1780 struct _GtsNVertex {
1781 GtsVertex parent;
1782 char name[GTS_NAME_LENGTH];
1785 struct _GtsNVertexClass {
1786 GtsVertexClass parent_class;
1789 GtsNVertexClass * gts_nvertex_class (void);
1791 #define GTS_NEDGE(obj) GTS_OBJECT_CAST (obj,\
1792 GtsNEdge,\
1793 gts_nedge_class ())
1794 #define GTS_NEDGE_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
1795 GtsNEdgeClass,\
1796 gts_nedge_class())
1797 #define GTS_IS_NEDGE(obj) (gts_object_is_from_class (obj,\
1798 gts_nedge_class ()))
1800 typedef struct _GtsNEdge GtsNEdge;
1801 typedef struct _GtsNEdgeClass GtsNEdgeClass;
1803 struct _GtsNEdge {
1804 GtsEdge parent;
1805 char name[GTS_NAME_LENGTH];
1808 struct _GtsNEdgeClass {
1809 GtsEdgeClass parent_class;
1812 GtsNEdgeClass * gts_nedge_class (void);
1814 #define GTS_NFACE(obj) GTS_OBJECT_CAST (obj,\
1815 GtsNFace,\
1816 gts_nface_class ())
1817 #define GTS_NFACE_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
1818 GtsNFaceClass,\
1819 gts_nface_class())
1820 #define GTS_IS_NFACE(obj) (gts_object_is_from_class (obj,\
1821 gts_nface_class ()))
1823 typedef struct _GtsNFace GtsNFace;
1824 typedef struct _GtsNFaceClass GtsNFaceClass;
1826 struct _GtsNFace {
1827 GtsFace parent;
1828 char name[GTS_NAME_LENGTH];
1831 struct _GtsNFaceClass {
1832 GtsFaceClass parent_class;
1835 GtsNFaceClass * gts_nface_class (void);
1837 /* Cluster object for out-of-core simplification: oocs.c */
1839 #define GTS_CLUSTER(obj) GTS_OBJECT_CAST (obj,\
1840 GtsCluster,\
1841 gts_cluster_class ())
1842 #define GTS_CLUSTER_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
1843 GtsClusterClass,\
1844 gts_cluster_class())
1845 #define GTS_IS_CLUSTER(obj) (gts_object_is_from_class (obj,\
1846 gts_cluster_class ()))
1848 typedef struct _GtsCluster GtsCluster;
1849 typedef struct _GtsClusterClass GtsClusterClass;
1850 typedef struct _GtsClusterId GtsClusterId;
1852 struct _GtsClusterId {
1853 guint x, y, z;
1856 struct _GtsCluster {
1857 GtsObject parent;
1859 GtsClusterId id;
1860 GtsVertex * v;
1861 guint n;
1864 struct _GtsClusterClass {
1865 GtsObjectClass parent_class;
1867 void (* add) (GtsCluster * c, GtsPoint * p, gpointer data);
1868 void (* update) (GtsCluster * c);
1871 GtsClusterClass * gts_cluster_class (void);
1872 GtsCluster * gts_cluster_new (GtsClusterClass * klass,
1873 GtsClusterId id,
1874 GtsVertexClass * vklass);
1875 void gts_cluster_add (GtsCluster * c,
1876 GtsPoint * p,
1877 gpointer data);
1878 void gts_cluster_update (GtsCluster * c);
1880 /* Cluster group object for out-of-core simplification: oocs.c */
1882 #define GTS_CLUSTER_GRID(obj) GTS_OBJECT_CAST (obj,\
1883 GtsClusterGrid,\
1884 gts_cluster_grid_class ())
1885 #define GTS_CLUSTER_GRID_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
1886 GtsClusterGridClass,\
1887 gts_cluster_grid_class())
1888 #define GTS_IS_CLUSTER_GRID(obj) (gts_object_is_from_class (obj,\
1889 gts_cluster_grid_class ()))
1891 typedef struct _GtsClusterGrid GtsClusterGrid;
1892 typedef struct _GtsClusterGridClass GtsClusterGridClass;
1894 struct _GtsClusterGrid {
1895 GtsObject parent;
1897 GtsSurface * surface;
1898 GtsBBox * bbox;
1899 GtsVector size;
1901 GtsClusterClass * cluster_class;
1902 GHashTable * clusters;
1905 struct _GtsClusterGridClass {
1906 GtsObjectClass parent_class;
1909 GtsClusterGridClass * gts_cluster_grid_class (void);
1910 GtsClusterGrid * gts_cluster_grid_new (GtsClusterGridClass * klass,
1911 GtsClusterClass * cluster_class,
1912 GtsSurface * s,
1913 GtsBBox * bbox,
1914 gdouble delta);
1915 void gts_cluster_grid_add_triangle (GtsClusterGrid * cluster_grid,
1916 GtsPoint * p1,
1917 GtsPoint * p2,
1918 GtsPoint * p3,
1919 gpointer data);
1920 GtsRange gts_cluster_grid_update (GtsClusterGrid * cluster_grid);
1922 /* Triangle strip generation: stripe.c */
1923 GSList * gts_surface_strip (GtsSurface * s);
1925 /* GtsContainee: container.c */
1927 typedef struct _GtsContainee GtsContainee;
1928 typedef struct _GtsContaineeClass GtsContaineeClass;
1929 typedef struct _GtsContainer GtsContainer;
1930 typedef struct _GtsContainerClass GtsContainerClass;
1932 struct _GtsContainee {
1933 GtsObject object;
1936 struct _GtsContaineeClass {
1937 GtsObjectClass parent_class;
1939 void (* add_container) (GtsContainee *, GtsContainer *);
1940 void (* remove_container) (GtsContainee *, GtsContainer *);
1941 void (* foreach) (GtsContainee *, GtsFunc, gpointer);
1942 gboolean (* is_contained) (GtsContainee *, GtsContainer *);
1943 void (* replace) (GtsContainee *, GtsContainee *);
1946 #define GTS_CONTAINEE(obj) GTS_OBJECT_CAST (obj,\
1947 GtsContainee,\
1948 gts_containee_class ())
1949 #define GTS_CONTAINEE_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
1950 GtsContaineeClass,\
1951 gts_containee_class())
1952 #define GTS_IS_CONTAINEE(obj) (gts_object_is_from_class (obj,\
1953 gts_containee_class ()))
1955 GtsContaineeClass * gts_containee_class (void);
1956 GtsContainee * gts_containee_new (GtsContaineeClass * klass);
1957 gboolean gts_containee_is_contained (GtsContainee * item,
1958 GtsContainer * c);
1959 void gts_containee_replace (GtsContainee * item,
1960 GtsContainee * with);
1962 /* GtsSListContainee: container.c */
1964 typedef struct _GtsSListContainee GtsSListContainee;
1965 typedef struct _GtsSListContaineeClass GtsSListContaineeClass;
1967 struct _GtsSListContainee {
1968 GtsContainee containee;
1970 GSList * containers;
1973 struct _GtsSListContaineeClass {
1974 GtsContaineeClass parent_class;
1977 #define GTS_SLIST_CONTAINEE(obj) GTS_OBJECT_CAST (obj,\
1978 GtsSListContainee,\
1979 gts_slist_containee_class ())
1980 #define GTS_SLIST_CONTAINEE_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
1981 GtsSListContaineeClass,\
1982 gts_slist_containee_class())
1983 #define GTS_IS_SLIST_CONTAINEE(obj) (gts_object_is_from_class (obj,\
1984 gts_slist_containee_class ()))
1986 GtsSListContaineeClass * gts_slist_containee_class (void);
1988 /* GtsContainer: container.c */
1990 struct _GtsContainer {
1991 GtsSListContainee object;
1994 struct _GtsContainerClass {
1995 GtsSListContaineeClass parent_class;
1997 void (* add) (GtsContainer *, GtsContainee *);
1998 void (* remove) (GtsContainer *, GtsContainee *);
1999 void (* foreach) (GtsContainer *, GtsFunc, gpointer);
2000 guint (* size) (GtsContainer *);
2003 #define GTS_CONTAINER(obj) GTS_OBJECT_CAST (obj,\
2004 GtsContainer,\
2005 gts_container_class ())
2006 #define GTS_CONTAINER_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
2007 GtsContainerClass,\
2008 gts_container_class())
2009 #define GTS_IS_CONTAINER(obj) (gts_object_is_from_class (obj,\
2010 gts_container_class ()))
2012 GtsContainerClass * gts_container_class (void);
2013 GtsContainer * gts_container_new (GtsContainerClass * klass);
2014 void gts_container_add (GtsContainer * c,
2015 GtsContainee * item);
2016 void gts_container_remove (GtsContainer * c,
2017 GtsContainee * item);
2018 void gts_container_foreach (GtsContainer * c,
2019 GtsFunc func,
2020 gpointer data);
2021 guint gts_container_size (GtsContainer * c);
2023 /* GtsHashContainer: container.c */
2025 typedef struct _GtsHashContainer GtsHashContainer;
2026 typedef struct _GtsHashContainerClass GtsHashContainerClass;
2028 struct _GtsHashContainer {
2029 GtsContainer c;
2031 GHashTable * items;
2032 gboolean frozen;
2035 struct _GtsHashContainerClass {
2036 GtsContainerClass parent_class;
2039 #define GTS_HASH_CONTAINER(obj) GTS_OBJECT_CAST (obj,\
2040 GtsHashContainer,\
2041 gts_hash_container_class ())
2042 #define GTS_HASH_CONTAINER_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
2043 GtsHashContainerClass,\
2044 gts_hash_container_class())
2045 #define GTS_IS_HASH_CONTAINER(obj) (gts_object_is_from_class (obj,\
2046 gts_hash_container_class ()))
2048 GtsHashContainerClass * gts_hash_container_class (void);
2050 /* GtsSListContainer: container.c */
2052 typedef struct _GtsSListContainer GtsSListContainer;
2053 typedef struct _GtsSListContainerClass GtsSListContainerClass;
2055 struct _GtsSListContainer {
2056 GtsContainer c;
2058 GSList * items;
2059 gboolean frozen;
2062 struct _GtsSListContainerClass {
2063 GtsContainerClass parent_class;
2066 #define GTS_SLIST_CONTAINER(obj) GTS_OBJECT_CAST (obj,\
2067 GtsSListContainer,\
2068 gts_slist_container_class ())
2069 #define GTS_SLIST_CONTAINER_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
2070 GtsSListContainerClass,\
2071 gts_slist_container_class())
2072 #define GTS_IS_SLIST_CONTAINER(obj) (gts_object_is_from_class (obj,\
2073 gts_slist_container_class ()))
2075 GtsSListContainerClass * gts_slist_container_class (void);
2077 /* GtsGNode: graph.c */
2079 typedef struct _GtsGNode GtsGNode;
2080 typedef struct _GtsGNodeClass GtsGNodeClass;
2081 typedef struct _GtsGraph GtsGraph;
2082 typedef struct _GtsGraphClass GtsGraphClass;
2084 struct _GtsGNode {
2085 GtsSListContainer container;
2087 guint level;
2090 struct _GtsGNodeClass {
2091 GtsSListContainerClass parent_class;
2093 gfloat (* weight) (GtsGNode *);
2094 void (* write) (GtsGNode *, FILE *);
2097 #define GTS_GNODE(obj) GTS_OBJECT_CAST (obj,\
2098 GtsGNode,\
2099 gts_gnode_class ())
2100 #define GTS_GNODE_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
2101 GtsGNodeClass,\
2102 gts_gnode_class())
2103 #define GTS_IS_GNODE(obj) (gts_object_is_from_class (obj,\
2104 gts_gnode_class ()))
2105 #define GTS_GNODE_NEIGHBOR(n,e) (GTS_GEDGE (e)->n1 == n ? GTS_GEDGE (e)->n2 : GTS_GEDGE (e)->n2 == n ? GTS_GEDGE (e)->n1 : NULL)
2107 GtsGNodeClass * gts_gnode_class (void);
2108 GtsGNode * gts_gnode_new (GtsGNodeClass * klass);
2109 void gts_gnode_foreach_neighbor (GtsGNode * n,
2110 GtsGraph * g,
2111 GtsFunc func,
2112 gpointer data);
2113 void gts_gnode_foreach_edge (GtsGNode * n,
2114 GtsGraph * g,
2115 GtsFunc func,
2116 gpointer data);
2117 guint gts_gnode_degree (GtsGNode * n,
2118 GtsGraph * g);
2119 gfloat gts_gnode_move_cost (GtsGNode * n,
2120 GtsGraph * src,
2121 GtsGraph * dst);
2122 gfloat gts_gnode_weight (GtsGNode * n);
2124 GTS_C_VAR
2125 gboolean gts_allow_floating_gnodes;
2127 /* GtsNGNode: graph.c */
2129 typedef struct _GtsNGNode GtsNGNode;
2130 typedef struct _GtsNGNodeClass GtsNGNodeClass;
2132 struct _GtsNGNode {
2133 GtsGNode node;
2135 guint id;
2138 struct _GtsNGNodeClass {
2139 GtsGNodeClass parent_class;
2142 #define GTS_NGNODE(obj) GTS_OBJECT_CAST (obj,\
2143 GtsNGNode,\
2144 gts_ngnode_class ())
2145 #define GTS_NGNODE_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
2146 GtsNGNodeClass,\
2147 gts_ngnode_class())
2148 #define GTS_IS_NGNODE(obj) (gts_object_is_from_class (obj,\
2149 gts_ngnode_class ()))
2151 GtsNGNodeClass * gts_ngnode_class (void);
2152 GtsNGNode * gts_ngnode_new (GtsNGNodeClass * klass,
2153 guint id);
2155 /* GtsWGNode: graph.c */
2157 typedef struct _GtsWGNode GtsWGNode;
2158 typedef struct _GtsWGNodeClass GtsWGNodeClass;
2160 struct _GtsWGNode {
2161 GtsGNode node;
2163 gfloat weight;
2166 struct _GtsWGNodeClass {
2167 GtsGNodeClass parent_class;
2170 #define GTS_WGNODE(obj) GTS_OBJECT_CAST (obj,\
2171 GtsWGNode,\
2172 gts_wgnode_class ())
2173 #define GTS_WGNODE_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
2174 GtsWGNodeClass,\
2175 gts_wgnode_class())
2176 #define GTS_IS_WGNODE(obj) (gts_object_is_from_class (obj,\
2177 gts_wgnode_class ()))
2179 GtsWGNodeClass * gts_wgnode_class (void);
2180 GtsWGNode * gts_wgnode_new (GtsWGNodeClass * klass,
2181 gfloat weight);
2183 /* GtsPNode */
2185 typedef struct _GtsPNode GtsPNode;
2186 typedef struct _GtsPNodeClass GtsPNodeClass;
2188 struct _GtsPNode {
2189 GtsGNode node;
2191 gpointer data;
2194 struct _GtsPNodeClass {
2195 GtsGNodeClass parent_class;
2198 #define GTS_PNODE(obj) GTS_OBJECT_CAST (obj,\
2199 GtsPNode,\
2200 gts_pnode_class ())
2201 #define GTS_PNODE_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
2202 GtsPNodeClass,\
2203 gts_pnode_class())
2204 #define GTS_IS_PNODE(obj) (gts_object_is_from_class (obj,\
2205 gts_pnode_class ()))
2207 GtsPNodeClass * gts_pnode_class (void);
2208 GtsPNode * gts_pnode_new (GtsPNodeClass * klass,
2209 gpointer data);
2211 /* GtsFNode */
2213 typedef struct _GtsFNode GtsFNode;
2214 typedef struct _GtsFNodeClass GtsFNodeClass;
2216 struct _GtsFNode {
2217 GtsGNode node;
2219 GtsFace * f;
2222 struct _GtsFNodeClass {
2223 GtsGNodeClass parent_class;
2226 #define GTS_FNODE(obj) GTS_OBJECT_CAST (obj,\
2227 GtsFNode,\
2228 gts_fnode_class ())
2229 #define GTS_FNODE_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
2230 GtsFNodeClass,\
2231 gts_fnode_class())
2232 #define GTS_IS_FNODE(obj) (gts_object_is_from_class (obj,\
2233 gts_fnode_class ()))
2235 GtsFNodeClass * gts_fnode_class (void);
2236 GtsFNode * gts_fnode_new (GtsFNodeClass * klass,
2237 GtsFace * f);
2239 /* GtsGEdge: graph.c */
2241 typedef struct _GtsGEdge GtsGEdge;
2242 typedef struct _GtsGEdgeClass GtsGEdgeClass;
2244 struct _GtsGEdge {
2245 GtsContainee containee;
2247 GtsGNode * n1;
2248 GtsGNode * n2;
2251 struct _GtsGEdgeClass {
2252 GtsContaineeClass parent_class;
2254 GtsGEdge * (* link) (GtsGEdge * e, GtsGNode * n1, GtsGNode * n2);
2255 gfloat (* weight) (GtsGEdge * e);
2256 void (* write) (GtsGEdge * e, FILE * fp);
2259 #define GTS_GEDGE(obj) GTS_OBJECT_CAST (obj,\
2260 GtsGEdge,\
2261 gts_gedge_class ())
2262 #define GTS_GEDGE_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
2263 GtsGEdgeClass,\
2264 gts_gedge_class())
2265 #define GTS_IS_GEDGE(obj) (gts_object_is_from_class (obj,\
2266 gts_gedge_class ()))
2268 GtsGEdgeClass * gts_gedge_class (void);
2269 GtsGEdge * gts_gedge_new (GtsGEdgeClass * klass,
2270 GtsGNode * n1,
2271 GtsGNode * n2);
2272 gfloat gts_gedge_weight (GtsGEdge * e);
2273 #define gts_gedge_connects(e, a1, a2)\
2274 (((e)->n1 == a1 && (e)->n2 == a2) || ((e)->n1 == a2 && (e)->n2 == a1))
2276 /* GtsPGEdge: graph.c */
2278 typedef struct _GtsPGEdge GtsPGEdge;
2279 typedef struct _GtsPGEdgeClass GtsPGEdgeClass;
2281 struct _GtsPGEdge {
2282 GtsGEdge gedge;
2284 gpointer data;
2287 struct _GtsPGEdgeClass {
2288 GtsGEdgeClass parent_class;
2291 #define GTS_PGEDGE(obj) GTS_OBJECT_CAST (obj,\
2292 GtsPGEdge,\
2293 gts_pgedge_class ())
2294 #define GTS_PGEDGE_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
2295 GtsPGEdgeClass,\
2296 gts_pgedge_class())
2297 #define GTS_IS_PGEDGE(obj) (gts_object_is_from_class (obj,\
2298 gts_pgedge_class ()))
2300 GtsPGEdgeClass * gts_pgedge_class (void);
2301 GtsPGEdge * gts_pgedge_new (GtsPGEdgeClass * klass,
2302 GtsGNode * n1,
2303 GtsGNode * n2,
2304 gpointer data);
2306 /* GtsWGEdge: graph.c */
2308 typedef struct _GtsWGEdge GtsWGEdge;
2309 typedef struct _GtsWGEdgeClass GtsWGEdgeClass;
2311 struct _GtsWGEdge {
2312 GtsGEdge gedge;
2314 gfloat weight;
2317 struct _GtsWGEdgeClass {
2318 GtsGEdgeClass parent_class;
2321 #define GTS_WGEDGE(obj) GTS_OBJECT_CAST (obj,\
2322 GtsWGEdge,\
2323 gts_wgedge_class ())
2324 #define GTS_WGEDGE_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
2325 GtsWGEdgeClass,\
2326 gts_wgedge_class())
2327 #define GTS_IS_WGEDGE(obj) (gts_object_is_from_class (obj,\
2328 gts_wgedge_class ()))
2330 GtsWGEdgeClass * gts_wgedge_class (void);
2331 GtsWGEdge * gts_wgedge_new (GtsWGEdgeClass * klass,
2332 GtsGNode * n1,
2333 GtsGNode * n2,
2334 gfloat weight);
2336 /* GtsGraph: graph.c */
2338 struct _GtsGraph {
2339 GtsHashContainer object;
2341 GtsGraphClass * graph_class;
2342 GtsGNodeClass * node_class;
2343 GtsGEdgeClass * edge_class;
2346 struct _GtsGraphClass {
2347 GtsHashContainerClass parent_class;
2349 gfloat (* weight) (GtsGraph *);
2352 #define GTS_GRAPH(obj) GTS_OBJECT_CAST (obj,\
2353 GtsGraph,\
2354 gts_graph_class ())
2355 #define GTS_GRAPH_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
2356 GtsGraphClass,\
2357 gts_graph_class())
2358 #define GTS_IS_GRAPH(obj) (gts_object_is_from_class (obj,\
2359 gts_graph_class ()))
2361 GtsGraphClass * gts_graph_class (void);
2362 GtsGraph * gts_graph_new (GtsGraphClass * klass,
2363 GtsGNodeClass * node_class,
2364 GtsGEdgeClass * edge_class);
2365 void gts_graph_print_stats (GtsGraph * g,
2366 FILE * fp);
2367 typedef struct _GtsGraphTraverse GtsGraphTraverse;
2368 typedef enum { GTS_BREADTH_FIRST
2369 } GtsTraverseType;
2370 GtsGraphTraverse * gts_graph_traverse_new (GtsGraph * g,
2371 GtsGNode * n,
2372 GtsTraverseType type,
2373 gboolean reinit);
2374 GtsGNode * gts_graph_traverse_next (GtsGraphTraverse * t);
2375 GtsGNode * gts_graph_traverse_what_next (GtsGraphTraverse * t);
2376 void gts_graph_traverse_destroy (GtsGraphTraverse * t);
2377 void gts_graph_foreach_edge (GtsGraph * g,
2378 GtsFunc func,
2379 gpointer data);
2380 gfloat gts_graph_weight (GtsGraph * g);
2381 guint gts_graph_distance_sum (GtsGraph * g,
2382 GtsGNode * center);
2383 GtsGNode * gts_graph_farthest (GtsGraph * g,
2384 GSList * gnodes);
2385 guint gts_graph_edges_cut (GtsGraph * g);
2386 gfloat gts_graph_edges_cut_weight (GtsGraph * g);
2387 void gts_graph_write (GtsGraph * g,
2388 FILE * fp);
2389 void gts_graph_write_dot (GtsGraph * g,
2390 FILE * fp);
2391 GtsGraph * gts_graph_read (GtsFile * fp);
2392 guint gts_graph_read_jostle (GtsGraph * g,
2393 GtsFile * fp);
2395 /* GtsWGraph: graph.c */
2397 typedef struct _GtsWGraph GtsWGraph;
2398 typedef struct _GtsWGraphClass GtsWGraphClass;
2400 struct _GtsWGraph {
2401 GtsGraph graph;
2403 gfloat weight;
2406 struct _GtsWGraphClass {
2407 GtsGraphClass parent_class;
2410 #define GTS_WGRAPH(obj) GTS_OBJECT_CAST (obj,\
2411 GtsWGraph,\
2412 gts_wgraph_class ())
2413 #define GTS_WGRAPH_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
2414 GtsWGraphClass,\
2415 gts_wgraph_class())
2416 #define GTS_IS_WGRAPH(obj) (gts_object_is_from_class (obj,\
2417 gts_wgraph_class ()))
2419 GtsWGraphClass * gts_wgraph_class (void);
2420 gfloat gts_wgraph_weight_max (GtsWGraph * wg);
2422 /* Surface graph: graph.c */
2424 GtsGraph * gts_surface_graph_new (GtsGraphClass * klass,
2425 GtsSurface * s);
2426 GtsSurface * gts_surface_graph_surface (GtsGraph * surface_graph,
2427 GtsSurface * s);
2429 /* Segments graph: graph.c */
2431 GtsGraph * gts_segments_graph_new (GtsGraphClass * klass,
2432 GSList * segments);
2434 /* GtsGNodeSplit: pgraph.c */
2436 typedef struct _GtsGNodeSplit GtsGNodeSplit;
2437 typedef struct _GtsGNodeSplitClass GtsGNodeSplitClass;
2439 struct _GtsGNodeSplit {
2440 GtsObject object;
2442 GtsGNode * n;
2443 GtsObject * n1;
2444 GtsObject * n2;
2447 struct _GtsGNodeSplitClass {
2448 GtsObjectClass parent_class;
2451 #define GTS_GNODE_SPLIT(obj) GTS_OBJECT_CAST (obj,\
2452 GtsGNodeSplit,\
2453 gts_gnode_split_class ())
2454 #define GTS_GNODE_SPLIT_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
2455 GtsGNodeSplitClass,\
2456 gts_gnode_split_class())
2457 #define GTS_IS_GNODE_SPLIT(obj) (gts_object_is_from_class (obj,\
2458 gts_gnode_split_class ()))
2459 #define GTS_GNODE_SPLIT_N1(ns) (GTS_IS_GNODE_SPLIT ((ns)->n1) ? GTS_GNODE_SPLIT ((ns)->n1)->n : GTS_GNODE ((ns)->n1))
2460 #define GTS_GNODE_SPLIT_N2(ns) (GTS_IS_GNODE_SPLIT ((ns)->n2) ? GTS_GNODE_SPLIT ((ns)->n2)->n : GTS_GNODE ((ns)->n2))
2462 GtsGNodeSplitClass * gts_gnode_split_class (void);
2463 GtsGNodeSplit * gts_gnode_split_new (GtsGNodeSplitClass * klass,
2464 GtsGNode * n,
2465 GtsObject * n1,
2466 GtsObject * n2);
2467 void gts_gnode_split_collapse (GtsGNodeSplit * ns,
2468 GtsGraph * g,
2469 GtsWGEdgeClass * klass);
2470 void gts_gnode_split_expand (GtsGNodeSplit * ns,
2471 GtsGraph * g);
2473 /* GtsPGraph: pgraph.c */
2475 typedef struct _GtsPGraph GtsPGraph;
2476 typedef struct _GtsPGraphClass GtsPGraphClass;
2478 struct _GtsPGraph {
2479 GtsObject object;
2481 GtsGraph * g;
2482 GPtrArray * split;
2483 GArray * levels;
2484 GtsGNodeSplitClass * split_class;
2485 GtsWGEdgeClass * edge_class;
2486 guint pos, min, level;
2489 struct _GtsPGraphClass {
2490 GtsObjectClass parent_class;
2493 #define GTS_PGRAPH(obj) GTS_OBJECT_CAST (obj,\
2494 GtsPGraph,\
2495 gts_pgraph_class ())
2496 #define GTS_PGRAPH_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
2497 GtsPGraphClass,\
2498 gts_pgraph_class())
2499 #define GTS_IS_PGRAPH(obj) (gts_object_is_from_class (obj,\
2500 gts_pgraph_class ()))
2502 GtsPGraphClass * gts_pgraph_class (void);
2503 GtsPGraph * gts_pgraph_new (GtsPGraphClass * klass,
2504 GtsGraph * g,
2505 GtsGNodeSplitClass * split_class,
2506 GtsWGNodeClass * node_class,
2507 GtsWGEdgeClass * edge_class,
2508 guint min);
2509 GtsGNodeSplit * gts_pgraph_add_node (GtsPGraph * pg);
2510 GtsGNodeSplit * gts_pgraph_remove_node (GtsPGraph * pg);
2511 void gts_pgraph_set_node_number (GtsPGraph *pg,
2512 guint n);
2513 guint gts_pgraph_get_node_number (GtsPGraph *pg);
2514 guint gts_pgraph_min_node_number (GtsPGraph *pg);
2515 guint gts_pgraph_max_node_number (GtsPGraph *pg);
2516 void gts_pgraph_foreach_node (GtsPGraph *pg,
2517 GtsFunc func,
2518 gpointer data);
2519 gboolean gts_pgraph_down (GtsPGraph * pg,
2520 GtsFunc func,
2521 gpointer data);
2522 /* Graph partition: partition.c */
2524 GSList * gts_graph_bubble_partition (GtsGraph * g,
2525 guint np,
2526 guint niter,
2527 GtsFunc step_info,
2528 gpointer data);
2529 guint gts_graph_partition_edges_cut (GSList * partition);
2530 gfloat gts_graph_partition_edges_cut_weight (GSList * partition);
2531 void gts_graph_partition_print_stats (GSList * partition,
2532 FILE * fp);
2533 gfloat gts_graph_partition_balance (GSList * partition);
2534 GSList * gts_graph_partition_clone (GSList * partition);
2535 GSList * gts_graph_recursive_bisection (GtsWGraph * wg,
2536 guint n,
2537 guint ntry,
2538 guint mmax,
2539 guint nmin,
2540 gfloat imbalance);
2541 void gts_graph_partition_destroy (GSList * partition);
2543 /* Graph bisection: partition.c */
2545 typedef struct _GtsGraphBisection GtsGraphBisection;
2547 struct _GtsGraphBisection {
2548 GtsGraph * g;
2549 GtsGraph * g1;
2550 GtsGraph * g2;
2551 GHashTable * bg1;
2552 GHashTable * bg2;
2555 gboolean gts_graph_bisection_check (GtsGraphBisection * bg);
2556 GtsGraphBisection * gts_graph_ggg_bisection (GtsGraph * g,
2557 guint ntry);
2558 GtsGraphBisection * gts_graph_bfgg_bisection (GtsGraph * g,
2559 guint ntry);
2560 gdouble gts_graph_bisection_kl_refine (GtsGraphBisection * bg,
2561 guint mmax);
2562 gdouble gts_graph_bisection_bkl_refine (GtsGraphBisection * bg,
2563 guint mmax,
2564 gfloat imbalance);
2565 GtsGraphBisection * gts_graph_bisection_new (GtsWGraph * wg,
2566 guint ntry,
2567 guint mmax,
2568 guint nmin,
2569 gfloat imbalance);
2570 void gts_graph_bisection_destroy (GtsGraphBisection * bg,
2571 gboolean destroy_graphs);
2573 #ifdef __cplusplus
2575 #endif /* __cplusplus */
2577 #endif /* __GTS_H__ */