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.
26 #define GTS_MAJOR_VERSION 0
27 #define GTS_MINOR_VERSION 7
28 #define GTS_MICRO_VERSION 6
32 #endif /* __cplusplus */
34 /* Added based on glib.h by M J Loehr 01/01/01 */
36 * we prefix variable declarations so they can
37 * properly get exported in windows dlls.
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
;
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
,
116 typedef struct _GtsColor GtsColor
;
122 typedef gint (*GtsFunc
) (gpointer item
,
127 typedef struct _GtsFile GtsFile
;
134 GTS_DOUBLE
= 1 << 12,
135 GTS_STRING
= 1 << 13,
148 guint curline
, curpos
;
149 guint scope
, scope_max
;
156 typedef struct _GtsFileVariable GtsFileVariable
;
158 struct _GtsFileVariable
{
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
,
173 void gts_file_error (GtsFile
* f
,
174 const gchar
* format
,
176 gint
gts_file_getc (GtsFile
* f
);
177 guint
gts_file_read (GtsFile
* f
,
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
,
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
,
194 const gchar
* format
,
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,\
212 #define GTS_OBJECT_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
215 #define GTS_IS_OBJECT(obj) (gts_object_is_from_class (obj,\
216 gts_object_class ()))
220 GTS_DESTROYED
= 1 << 0,
221 GTS_USER_FLAG
= 1 /* user flags start from here */
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
];
233 GtsObjectClassInitFunc class_init_func
;
234 GtsObjectInitFunc object_init_func
;
235 GtsArgSetFunc arg_set_func
;
236 GtsArgGetFunc arg_get_func
;
240 GtsObjectClass
* klass
;
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
,
263 gpointer
gts_object_class_check_cast (gpointer klass
,
267 gpointer
gts_object_is_from_class (gpointer object
,
272 g_return_val_if_fail (klass
!= NULL
, NULL
);
277 c
= ((GtsObject
*) object
)->klass
;
279 g_return_val_if_fail (c
!= NULL
, NULL
);
291 gpointer
gts_object_class_is_from_class (gpointer klass
,
296 g_return_val_if_fail (klass
!= NULL
, NULL
);
297 g_return_val_if_fail (from
!= NULL
, NULL
);
299 c
= (GtsObjectClass
*) klass
;
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
,
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
;
325 gdouble min
, max
, sum
, sum2
, mean
, stddev
;
329 void gts_range_init (GtsRange
* r
);
330 void gts_range_reset (GtsRange
* r
);
331 void gts_range_add_value (GtsRange
* r
,
333 void gts_range_update (GtsRange
* r
);
334 void gts_range_print (GtsRange
* r
,
337 /* Points: point.c */
339 #define GTS_IS_POINT(obj) (gts_object_is_from_class (obj,\
341 #define GTS_POINT(obj) GTS_OBJECT_CAST (obj,\
344 #define GTS_POINT_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
351 gdouble x
, y
, z
; /* must be contiguous (cast to robust functions) */
354 struct _GtsPointClass
{
355 GtsObjectClass parent_class
;
359 GtsPointClass
* gts_point_class (void);
360 GtsPoint
* gts_point_new (GtsPointClass
* klass
,
364 void gts_point_set (GtsPoint
* p
,
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 &&\
374 GtsPoint
* gts_segment_triangle_intersection (GtsSegment
* s
,
377 GtsPointClass
* klass
);
378 void gts_point_transform (GtsPoint
* p
,
380 gdouble
gts_point_distance (GtsPoint
* p1
,
382 gdouble
gts_point_distance2 (GtsPoint
* p1
,
384 gdouble
gts_point_orientation_3d (GtsPoint
* p1
,
388 gint
gts_point_orientation_3d_sos (GtsPoint
* p1
,
392 GtsIntersect
gts_point_is_in_triangle (GtsPoint
* p
,
394 gdouble
gts_point_in_circle (GtsPoint
* p
,
398 gdouble
gts_point_in_sphere (GtsPoint
* p
,
403 gdouble
gts_point_in_triangle_circle (GtsPoint
* p
,
405 gdouble
gts_point_orientation (GtsPoint
* p1
,
408 gint
gts_point_orientation_sos (GtsPoint
* p1
,
411 gdouble
gts_point_segment_distance2 (GtsPoint
* p
,
413 gdouble
gts_point_segment_distance (GtsPoint
* p
,
415 void gts_point_segment_closest (GtsPoint
* p
,
418 gdouble
gts_point_triangle_distance2 (GtsPoint
* p
,
420 gdouble
gts_point_triangle_distance (GtsPoint
* p
,
422 void gts_point_triangle_closest (GtsPoint
* p
,
425 gboolean
gts_point_is_inside_surface (GtsPoint
* p
,
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,\
436 #define GTS_VERTEX_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
445 struct _GtsVertexClass
{
446 GtsPointClass parent_class
;
448 void (* intersection_attributes
) (GtsVertex
*,
454 gboolean gts_allow_floating_vertices
;
456 GtsVertexClass
* gts_vertex_class (void);
457 GtsVertex
* gts_vertex_new (GtsVertexClass
* klass
,
461 void gts_vertex_replace (GtsVertex
* v
,
463 gboolean
gts_vertex_is_unattached (GtsVertex
* v
);
464 GtsSegment
* gts_vertices_are_connected (GtsVertex
* v1
,
466 GSList
* gts_vertex_triangles (GtsVertex
* v
,
468 GSList
* gts_vertex_faces (GtsVertex
* v
,
469 GtsSurface
* surface
,
471 GSList
* gts_vertex_neighbors (GtsVertex
* v
,
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
,
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
{
496 #define GTS_VERTEX_NORMAL(obj) GTS_OBJECT_CAST (obj,\
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
{
516 #define GTS_COLOR_VERTEX(obj) GTS_OBJECT_CAST (obj,\
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,\
530 gts_segment_class ())
531 #define GTS_SEGMENT_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
533 gts_segment_class ())
542 struct _GtsSegmentClass
{
543 GtsObjectClass parent_class
;
546 GtsSegmentClass
* gts_segment_class (void);
547 GtsSegment
* gts_segment_new (GtsSegmentClass
* klass
,
550 #define gts_segment_connect(s, e1, e2) (((s)->v1 == 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
,
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
);
573 #define GTS_IS_EDGE(obj) (gts_object_is_from_class (obj,\
575 #define GTS_EDGE(obj) GTS_OBJECT_CAST (obj,\
578 #define GTS_EDGE_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
588 struct _GtsEdgeClass
{
589 GtsSegmentClass parent_class
;
593 gboolean gts_allow_floating_edges
;
595 GtsEdgeClass
* gts_edge_class (void);
596 GtsEdge
* gts_edge_new (GtsEdgeClass
* klass
,
600 * gts_edge_is_unattached:
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
,
613 GSList
* gts_edges_from_vertices (GSList
* vertices
,
614 GtsSurface
* parent
);
615 guint
gts_edge_face_number (GtsEdge
* e
,
617 gboolean
gts_edge_collapse_is_valid (GtsEdge
* e
);
618 gboolean
gts_edge_collapse_creates_fold (GtsEdge
* e
,
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
,
627 gboolean
gts_edge_manifold_faces (GtsEdge
* e
,
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,\
638 gts_triangle_class ())
639 #define GTS_TRIANGLE_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
641 gts_triangle_class ())
643 struct _GtsTriangle
{
651 struct _GtsTriangleClass
{
652 GtsObjectClass parent_class
;
655 GtsTriangleClass
* gts_triangle_class (void);
656 void gts_triangle_set (GtsTriangle
* triangle
,
660 GtsTriangle
* gts_triangle_new (GtsTriangleClass
* klass
,
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
,
672 GtsEdge
* gts_triangle_edge_opposite (GtsTriangle
* t
,
674 gdouble
gts_triangles_angle (GtsTriangle
* t1
,
676 gboolean
gts_triangles_are_compatible (GtsTriangle
* t1
,
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
,
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
,
697 GtsTriangle
* gts_triangle_enclosing (GtsTriangleClass
* klass
,
700 guint
gts_triangle_neighbor_number (GtsTriangle
* t
);
701 GSList
* gts_triangle_neighbors (GtsTriangle
* t
);
702 GtsEdge
* gts_triangles_common_edge (GtsTriangle
* t1
,
704 GtsTriangle
* gts_triangle_is_duplicate (GtsTriangle
* t
);
705 GtsTriangle
* gts_triangle_use_edges (GtsEdge
* e1
,
708 gboolean
gts_triangle_is_ok (GtsTriangle
* t
);
709 void gts_triangle_vertices (GtsTriangle
* t
,
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
,
718 GtsObject
* gts_triangle_is_stabbed (GtsTriangle
* t
,
720 gdouble
* orientation
);
721 void gts_triangle_interpolate_height (GtsTriangle
* t
,
726 #define GTS_IS_FACE(obj) (gts_object_is_from_class (obj,\
728 #define GTS_FACE(obj) GTS_OBJECT_CAST (obj,\
731 #define GTS_FACE_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
736 GtsTriangle triangle
;
741 struct _GtsFaceClass
{
742 GtsTriangleClass parent_class
;
746 gboolean gts_allow_floating_faces
;
748 GtsFaceClass
* gts_face_class (void);
749 GtsFace
* gts_face_new (GtsFaceClass
* klass
,
753 gboolean
gts_face_has_parent_surface (GtsFace
* f
,
755 GSList
* gts_faces_from_edges (GSList
* edges
,
757 guint
gts_face_neighbor_number (GtsFace
* f
,
759 GSList
* gts_face_neighbors (GtsFace
* f
,
761 void gts_face_foreach_neighbor (GtsFace
* f
,
765 gboolean
gts_face_is_compatible (GtsFace
* f
,
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] +\
780 #define gts_vector_norm(v) (sqrt ((v)[0]*(v)[0] +\
783 #define gts_vector_normalize(v) {\
784 gdouble __gts_n = gts_vector_norm (v);\
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
,
807 guint
gts_matrix_compatible_row (GtsMatrix
* A
,
812 guint
gts_matrix_quadratic_optimization (GtsMatrix
* A
,
817 GtsMatrix
* gts_matrix_product (GtsMatrix
* m1
,
819 GtsMatrix
* gts_matrix_zero (GtsMatrix
* m
);
820 GtsMatrix
* gts_matrix_identity (GtsMatrix
* m
);
821 GtsMatrix
* gts_matrix_scale (GtsMatrix
* m
,
823 GtsMatrix
* gts_matrix_translate (GtsMatrix
* m
,
825 GtsMatrix
* gts_matrix_rotate (GtsMatrix
* m
,
828 void gts_matrix_destroy (GtsMatrix
* m
);
829 void gts_vector_print (GtsVector v
,
831 void gts_vector4_print (GtsVector4 v
,
834 /* Kdtrees: kdtree.c */
836 #define gts_kdtree_destroy(tree) g_node_destroy(tree)
838 GNode
* gts_kdtree_new (GPtrArray
* points
,
842 GSList
* gts_kdtree_range (GNode
* tree
,
848 /* Bboxtrees: bbtree.c */
851 * GtsBBTreeTraverseFunc:
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
,
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
,
875 * GtsBBoxClosestFunc:
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
,
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,\
897 * @obj: a #GtsObject.
899 * Casts @obj to #GtsBBox.
901 #define GTS_BBOX(obj) GTS_OBJECT_CAST (obj,\
906 * @klass: a descendant of #GtsBBoxClass.
908 * Casts @klass to #GtsBBoxClass.
910 #define GTS_BBOX_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
921 struct _GtsBBoxClass
{
922 GtsObjectClass parent_class
;
925 GtsBBoxClass
* gts_bbox_class (void);
926 GtsBBox
* gts_bbox_new (GtsBBoxClass
* klass
,
934 void gts_bbox_set (GtsBBox
* bbox
,
942 GtsBBox
* gts_bbox_segment (GtsBBoxClass
* klass
,
944 GtsBBox
* gts_bbox_triangle (GtsBBoxClass
* klass
,
946 GtsBBox
* gts_bbox_surface (GtsBBoxClass
* klass
,
947 GtsSurface
* surface
);
948 GtsBBox
* gts_bbox_bboxes (GtsBBoxClass
* klass
,
950 GtsBBox
* gts_bbox_points (GtsBBoxClass
* klass
,
953 * gts_bbox_point_is_inside:
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
,
967 void gts_bbox_draw (GtsBBox
* bb
,
969 gdouble
gts_bbox_diagonal2 (GtsBBox
* bb
);
970 void gts_bbox_point_distance2 (GtsBBox
* bb
,
974 gboolean
gts_bbox_is_stabbed (GtsBBox
* bb
,
976 gboolean
gts_bbox_overlaps_triangle (GtsBBox
* bb
,
978 gboolean
gts_bbox_overlaps_segment (GtsBBox
* bb
,
981 GNode
* gts_bb_tree_new (GSList
* bboxes
);
982 GNode
* gts_bb_tree_surface (GtsSurface
* s
);
983 GSList
* gts_bb_tree_stabbed (GNode
* tree
,
985 GSList
* gts_bb_tree_overlap (GNode
* tree
,
987 gboolean
gts_bb_tree_is_overlapping (GNode
* tree
,
989 void gts_bb_tree_traverse_overlapping (GNode
* tree1
,
991 GtsBBTreeTraverseFunc func
,
993 void gts_bb_tree_draw (GNode
* tree
,
996 GSList
* gts_bb_tree_point_closest_bboxes (GNode
* tree
,
998 gdouble
gts_bb_tree_point_distance (GNode
* tree
,
1000 GtsBBoxDistFunc distance
,
1002 GtsPoint
* gts_bb_tree_point_closest (GNode
* tree
,
1004 GtsBBoxClosestFunc closest
,
1005 gdouble
* distance
);
1006 void gts_bb_tree_segment_distance (GNode
* tree
,
1008 GtsBBoxDistFunc distance
,
1011 void gts_bb_tree_triangle_distance (GNode
* tree
,
1013 GtsBBoxDistFunc distance
,
1016 void gts_bb_tree_surface_distance (GNode
* tree
,
1018 GtsBBoxDistFunc distance
,
1021 void gts_bb_tree_surface_boundary_distance
1024 GtsBBoxDistFunc distance
,
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
,
1037 typedef GtsVertex
* (*GtsCoarsenFunc
) (GtsEdge
* e
,
1038 GtsVertexClass
* klass
,
1040 typedef gboolean (*GtsStopFunc
) (gdouble cost
,
1044 struct _GtsSurfaceStats
{
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
;
1058 GtsRange edge_length
;
1059 GtsRange edge_angle
;
1060 GtsSurface
* parent
;
1063 struct _GtsSurface
{
1066 #ifdef USE_SURFACE_BTREE
1068 #else /* not USE_SURFACE_BTREE */
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,\
1088 gts_surface_class ())
1089 #define GTS_SURFACE_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
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
,
1100 void gts_surface_remove_face (GtsSurface
* s
,
1102 guint
gts_surface_read (GtsSurface
* surface
,
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
,
1111 void gts_surface_write (GtsSurface
* s
,
1113 void gts_surface_write_oogl (GtsSurface
* s
,
1115 void gts_surface_write_vtk (GtsSurface
* s
,
1117 void gts_surface_write_oogl_boundary (GtsSurface
* s
,
1119 void gts_surface_foreach_vertex (GtsSurface
* s
,
1122 void gts_surface_foreach_edge (GtsSurface
* s
,
1125 void gts_surface_foreach_face (GtsSurface
* s
,
1128 guint
gts_surface_foreach_face_remove (GtsSurface
* s
,
1131 typedef struct _GtsSurfaceTraverse GtsSurfaceTraverse
;
1132 GtsSurfaceTraverse
* gts_surface_traverse_new (GtsSurface
* s
,
1134 GtsFace
* gts_surface_traverse_next (GtsSurfaceTraverse
* t
,
1136 void gts_surface_traverse_destroy (GtsSurfaceTraverse
* t
);
1137 void gts_surface_refine (GtsSurface
* surface
,
1138 GtsKeyFunc cost_func
,
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
,
1148 GtsCoarsenFunc coarsen_func
,
1149 gpointer coarsen_data
,
1150 GtsStopFunc stop_func
,
1153 gboolean
gts_coarsen_stop_number (gdouble cost
,
1155 guint
* min_number
);
1156 gboolean
gts_coarsen_stop_cost (gdouble cost
,
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
,
1166 void gts_surface_merge (GtsSurface
* s
,
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
,
1174 gdouble
gts_surface_center_of_area (GtsSurface
* s
,
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
,
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
,
1192 gboolean
gts_vertex_gaussian_curvature (GtsVertex
* v
,
1195 void gts_vertex_principal_curvatures (gdouble Kh
,
1199 void gts_vertex_principal_directions (GtsVertex
* v
,
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
,
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
,
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,\
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
{
1281 struct _GtsSurfaceInterClass
{
1282 GtsObjectClass parent_class
;
1285 GtsSurfaceInterClass
*
1286 gts_surface_inter_class (void);
1288 gts_surface_inter_new (GtsSurfaceInterClass
* klass
,
1291 GNode
* faces_tree1
,
1292 GNode
* faces_tree2
,
1296 gts_surface_inter_check (GtsSurfaceInter
* si
,
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
,
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
,
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
;
1333 gboolean frozen
, randomized
;
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
{
1348 GtsEHeap
* gts_eheap_new (GtsKeyFunc key_func
,
1350 GtsEHeapPair
* gts_eheap_insert (GtsEHeap
* heap
,
1352 GtsEHeapPair
* gts_eheap_insert_with_key (GtsEHeap
* heap
,
1355 gpointer
gts_eheap_remove_top (GtsEHeap
* heap
,
1357 gpointer
gts_eheap_top (GtsEHeap
* heap
,
1359 void gts_eheap_thaw (GtsEHeap
* heap
);
1360 void gts_eheap_foreach (GtsEHeap
* heap
,
1363 gpointer
gts_eheap_remove (GtsEHeap
* heap
,
1365 void gts_eheap_decrease_key (GtsEHeap
* heap
,
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
,
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
,
1384 void gts_fifo_push (GtsFifo
* fifo
,
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
,
1393 void gts_fifo_reverse (GtsFifo
* fifo
);
1394 void gts_fifo_destroy (GtsFifo
* fifo
);
1396 /* Progressive surfaces */
1400 typedef struct _GtsSplit GtsSplit
;
1401 typedef struct _GtsSplitClass GtsSplitClass
;
1402 typedef struct _GtsSplitCFace GtsSplitCFace
;
1410 GtsSplitCFace
* cfaces
;
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,\
1423 #define GTS_SPLIT_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
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
,
1438 void gts_split_collapse (GtsSplit
* vs
,
1439 GtsEdgeClass
* klass
,
1441 void gts_split_expand (GtsSplit
* vs
,
1443 GtsEdgeClass
* klass
);
1444 typedef gboolean (*GtsSplitTraverseFunc
) (GtsSplit
* vs
,
1446 void gts_split_traverse (GtsSplit
* root
,
1447 GTraverseType order
,
1449 GtsSplitTraverseFunc func
,
1451 guint
gts_split_height (GtsSplit
* root
);
1455 typedef struct _GtsPSurface GtsPSurface
;
1456 typedef struct _GtsPSurfaceClass GtsPSurfaceClass
;
1458 struct _GtsPSurface
{
1463 GtsSplitClass
* split_class
;
1466 GPtrArray
* vertices
;
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,\
1478 gts_psurface_class ())
1479 #define GTS_PSURFACE_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
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
,
1490 GtsCoarsenFunc coarsen_func
,
1491 gpointer coarsen_data
,
1492 GtsStopFunc stop_func
,
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
,
1501 guint
gts_psurface_get_vertex_number (GtsPSurface
* ps
);
1502 void gts_psurface_write (GtsPSurface
* ps
,
1504 GtsPSurface
* gts_psurface_open (GtsPSurfaceClass
* klass
,
1506 GtsSplitClass
* split_class
,
1508 GtsSplit
* gts_psurface_read_vertex (GtsPSurface
* ps
,
1510 void gts_psurface_close (GtsPSurface
* ps
);
1511 void gts_psurface_foreach_vertex (GtsPSurface
* ps
,
1517 typedef struct _GtsHSplit GtsHSplit
;
1518 typedef struct _GtsHSplitClass GtsHSplitClass
;
1519 typedef struct _GtsHSurface GtsHSurface
;
1520 typedef struct _GtsHSurfaceClass GtsHSurfaceClass
;
1525 GtsEHeapPair
* index
;
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,\
1538 gts_hsplit_class ())
1539 #define GTS_HSPLIT_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
1541 gts_hsplit_class ())
1543 GtsHSplitClass
* gts_hsplit_class (void);
1544 GtsHSplit
* gts_hsplit_new (GtsHSplitClass
* klass
,
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
{
1558 GtsEHeap
* expandable
;
1559 GtsEHeap
* collapsable
;
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,\
1572 gts_hsurface_class ())
1573 #define GTS_HSURFACE_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
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
,
1588 GtsSplitTraverseFunc func
,
1590 void gts_hsurface_foreach (GtsHSurface
* hsurface
,
1591 GTraverseType order
,
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 ()))
1608 * @obj: a descendant of #GtsConstraint.
1610 * Casts @obj to #GtsConstraint.
1612 #define GTS_CONSTRAINT(obj) GTS_OBJECT_CAST (obj,\
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
{
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
,
1641 GtsVertex
* gts_delaunay_add_vertex_to_face (GtsSurface
* surface
,
1644 GtsVertex
* gts_delaunay_add_vertex (GtsSurface
* surface
,
1647 void gts_delaunay_remove_vertex (GtsSurface
* surface
,
1649 GtsFace
* gts_delaunay_check (GtsSurface
* surface
);
1650 GSList
* gts_delaunay_add_constraint (GtsSurface
* surface
,
1652 void gts_delaunay_remove_hull (GtsSurface
* surface
);
1654 /* GtsListFace: Header */
1656 typedef struct _GtsListFace GtsListFace
;
1658 struct _GtsListFace
{
1666 #define GTS_LIST_FACE(obj) GTS_OBJECT_CAST (obj,\
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
,
1681 gboolean
gts_vertex_encroaches_edge (GtsVertex
* v
,
1683 GtsVertex
* gts_edge_is_encroached (GtsEdge
* e
,
1685 GtsEncroachFunc encroaches
,
1687 guint
gts_delaunay_conform (GtsSurface
* surface
,
1689 GtsEncroachFunc encroaches
,
1691 guint
gts_delaunay_refine (GtsSurface
* surface
,
1693 GtsEncroachFunc encroaches
,
1694 gpointer encroach_data
,
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
{
1709 struct _GtsCartesianGrid
{
1711 gdouble x
, dx
, y
, dy
, z
, dz
;
1714 typedef void (*GtsIsoCartesianFunc
) (gdouble
** a
,
1719 GtsGridPlane
* gts_grid_plane_new (guint nx
,
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
,
1729 GtsVertexClass
* klass
);
1730 void gts_iso_slice_fill_cartesian (GtsIsoSlice
* slice
,
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
,
1742 GtsIsoCartesianFunc f
,
1746 /* Isosurfaces (marching tetrahedra): isotetra.c */
1748 void gts_isosurface_tetra (GtsSurface
* surface
,
1750 GtsIsoCartesianFunc f
,
1753 void gts_isosurface_tetra_bcl (GtsSurface
* surface
,
1755 GtsIsoCartesianFunc f
,
1758 void gts_isosurface_tetra_bounded (GtsSurface
* surface
,
1760 GtsIsoCartesianFunc f
,
1764 /* Named vertices, edges and triangles: named.c */
1766 #define GTS_NAME_LENGTH 40
1768 #define GTS_NVERTEX(obj) GTS_OBJECT_CAST (obj,\
1770 gts_nvertex_class ())
1771 #define GTS_NVERTEX_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
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
{
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,\
1794 #define GTS_NEDGE_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
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
;
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,\
1817 #define GTS_NFACE_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
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
;
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,\
1841 gts_cluster_class ())
1842 #define GTS_CLUSTER_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
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
{
1856 struct _GtsCluster
{
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
,
1874 GtsVertexClass
* vklass
);
1875 void gts_cluster_add (GtsCluster
* c
,
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,\
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
{
1897 GtsSurface
* surface
;
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
,
1915 void gts_cluster_grid_add_triangle (GtsClusterGrid
* cluster_grid
,
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
{
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,\
1948 gts_containee_class ())
1949 #define GTS_CONTAINEE_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
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
,
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,\
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,\
2005 gts_container_class ())
2006 #define GTS_CONTAINER_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
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
,
2021 guint
gts_container_size (GtsContainer
* c
);
2023 /* GtsHashContainer: container.c */
2025 typedef struct _GtsHashContainer GtsHashContainer
;
2026 typedef struct _GtsHashContainerClass GtsHashContainerClass
;
2028 struct _GtsHashContainer
{
2035 struct _GtsHashContainerClass
{
2036 GtsContainerClass parent_class
;
2039 #define GTS_HASH_CONTAINER(obj) GTS_OBJECT_CAST (obj,\
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
{
2062 struct _GtsSListContainerClass
{
2063 GtsContainerClass parent_class
;
2066 #define GTS_SLIST_CONTAINER(obj) GTS_OBJECT_CAST (obj,\
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
;
2085 GtsSListContainer container
;
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,\
2100 #define GTS_GNODE_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
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
,
2113 void gts_gnode_foreach_edge (GtsGNode
* n
,
2117 guint
gts_gnode_degree (GtsGNode
* n
,
2119 gfloat
gts_gnode_move_cost (GtsGNode
* n
,
2122 gfloat
gts_gnode_weight (GtsGNode
* n
);
2125 gboolean gts_allow_floating_gnodes
;
2127 /* GtsNGNode: graph.c */
2129 typedef struct _GtsNGNode GtsNGNode
;
2130 typedef struct _GtsNGNodeClass GtsNGNodeClass
;
2138 struct _GtsNGNodeClass
{
2139 GtsGNodeClass parent_class
;
2142 #define GTS_NGNODE(obj) GTS_OBJECT_CAST (obj,\
2144 gts_ngnode_class ())
2145 #define GTS_NGNODE_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
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
,
2155 /* GtsWGNode: graph.c */
2157 typedef struct _GtsWGNode GtsWGNode
;
2158 typedef struct _GtsWGNodeClass GtsWGNodeClass
;
2166 struct _GtsWGNodeClass
{
2167 GtsGNodeClass parent_class
;
2170 #define GTS_WGNODE(obj) GTS_OBJECT_CAST (obj,\
2172 gts_wgnode_class ())
2173 #define GTS_WGNODE_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
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
,
2185 typedef struct _GtsPNode GtsPNode
;
2186 typedef struct _GtsPNodeClass GtsPNodeClass
;
2194 struct _GtsPNodeClass
{
2195 GtsGNodeClass parent_class
;
2198 #define GTS_PNODE(obj) GTS_OBJECT_CAST (obj,\
2201 #define GTS_PNODE_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
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
,
2213 typedef struct _GtsFNode GtsFNode
;
2214 typedef struct _GtsFNodeClass GtsFNodeClass
;
2222 struct _GtsFNodeClass
{
2223 GtsGNodeClass parent_class
;
2226 #define GTS_FNODE(obj) GTS_OBJECT_CAST (obj,\
2229 #define GTS_FNODE_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
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
,
2239 /* GtsGEdge: graph.c */
2241 typedef struct _GtsGEdge GtsGEdge
;
2242 typedef struct _GtsGEdgeClass GtsGEdgeClass
;
2245 GtsContainee containee
;
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,\
2262 #define GTS_GEDGE_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
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
,
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
;
2287 struct _GtsPGEdgeClass
{
2288 GtsGEdgeClass parent_class
;
2291 #define GTS_PGEDGE(obj) GTS_OBJECT_CAST (obj,\
2293 gts_pgedge_class ())
2294 #define GTS_PGEDGE_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
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
,
2306 /* GtsWGEdge: graph.c */
2308 typedef struct _GtsWGEdge GtsWGEdge
;
2309 typedef struct _GtsWGEdgeClass GtsWGEdgeClass
;
2317 struct _GtsWGEdgeClass
{
2318 GtsGEdgeClass parent_class
;
2321 #define GTS_WGEDGE(obj) GTS_OBJECT_CAST (obj,\
2323 gts_wgedge_class ())
2324 #define GTS_WGEDGE_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
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
,
2336 /* GtsGraph: graph.c */
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,\
2355 #define GTS_GRAPH_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
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
,
2367 typedef struct _GtsGraphTraverse GtsGraphTraverse
;
2368 typedef enum { GTS_BREADTH_FIRST
2370 GtsGraphTraverse
* gts_graph_traverse_new (GtsGraph
* g
,
2372 GtsTraverseType type
,
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
,
2380 gfloat
gts_graph_weight (GtsGraph
* g
);
2381 guint
gts_graph_distance_sum (GtsGraph
* g
,
2383 GtsGNode
* gts_graph_farthest (GtsGraph
* g
,
2385 guint
gts_graph_edges_cut (GtsGraph
* g
);
2386 gfloat
gts_graph_edges_cut_weight (GtsGraph
* g
);
2387 void gts_graph_write (GtsGraph
* g
,
2389 void gts_graph_write_dot (GtsGraph
* g
,
2391 GtsGraph
* gts_graph_read (GtsFile
* fp
);
2392 guint
gts_graph_read_jostle (GtsGraph
* g
,
2395 /* GtsWGraph: graph.c */
2397 typedef struct _GtsWGraph GtsWGraph
;
2398 typedef struct _GtsWGraphClass GtsWGraphClass
;
2406 struct _GtsWGraphClass
{
2407 GtsGraphClass parent_class
;
2410 #define GTS_WGRAPH(obj) GTS_OBJECT_CAST (obj,\
2412 gts_wgraph_class ())
2413 #define GTS_WGRAPH_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
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
,
2426 GtsSurface
* gts_surface_graph_surface (GtsGraph
* surface_graph
,
2429 /* Segments graph: graph.c */
2431 GtsGraph
* gts_segments_graph_new (GtsGraphClass
* klass
,
2434 /* GtsGNodeSplit: pgraph.c */
2436 typedef struct _GtsGNodeSplit GtsGNodeSplit
;
2437 typedef struct _GtsGNodeSplitClass GtsGNodeSplitClass
;
2439 struct _GtsGNodeSplit
{
2447 struct _GtsGNodeSplitClass
{
2448 GtsObjectClass parent_class
;
2451 #define GTS_GNODE_SPLIT(obj) GTS_OBJECT_CAST (obj,\
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
,
2467 void gts_gnode_split_collapse (GtsGNodeSplit
* ns
,
2469 GtsWGEdgeClass
* klass
);
2470 void gts_gnode_split_expand (GtsGNodeSplit
* ns
,
2473 /* GtsPGraph: pgraph.c */
2475 typedef struct _GtsPGraph GtsPGraph
;
2476 typedef struct _GtsPGraphClass GtsPGraphClass
;
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,\
2495 gts_pgraph_class ())
2496 #define GTS_PGRAPH_CLASS(klass) GTS_OBJECT_CLASS_CAST (klass,\
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
,
2505 GtsGNodeSplitClass
* split_class
,
2506 GtsWGNodeClass
* node_class
,
2507 GtsWGEdgeClass
* edge_class
,
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
,
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
,
2519 gboolean
gts_pgraph_down (GtsPGraph
* pg
,
2522 /* Graph partition: partition.c */
2524 GSList
* gts_graph_bubble_partition (GtsGraph
* g
,
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
,
2533 gfloat
gts_graph_partition_balance (GSList
* partition
);
2534 GSList
* gts_graph_partition_clone (GSList
* partition
);
2535 GSList
* gts_graph_recursive_bisection (GtsWGraph
* wg
,
2541 void gts_graph_partition_destroy (GSList
* partition
);
2543 /* Graph bisection: partition.c */
2545 typedef struct _GtsGraphBisection GtsGraphBisection
;
2547 struct _GtsGraphBisection
{
2555 gboolean
gts_graph_bisection_check (GtsGraphBisection
* bg
);
2556 GtsGraphBisection
* gts_graph_ggg_bisection (GtsGraph
* g
,
2558 GtsGraphBisection
* gts_graph_bfgg_bisection (GtsGraph
* g
,
2560 gdouble
gts_graph_bisection_kl_refine (GtsGraphBisection
* bg
,
2562 gdouble
gts_graph_bisection_bkl_refine (GtsGraphBisection
* bg
,
2565 GtsGraphBisection
* gts_graph_bisection_new (GtsWGraph
* wg
,
2570 void gts_graph_bisection_destroy (GtsGraphBisection
* bg
,
2571 gboolean destroy_graphs
);
2575 #endif /* __cplusplus */
2577 #endif /* __GTS_H__ */