Segments

Name

Segments -- segment object and related functions.

Synopsis


#include <gts.h>


#define     GTS_SEGMENT_CLASS               (klass)
#define     GTS_SEGMENT                     (obj)
#define     GTS_IS_SEGMENT                  (obj)
struct      GtsSegmentClass;
struct      GtsSegment;

GtsSegmentClass* gts_segment_class          (void);
GtsSegment* gts_segment_new                 (GtsSegmentClass *klass,
                                             GtsVertex *v1,
                                             GtsVertex *v2);
#define     gts_segments_are_identical      (s1, s2)
GtsIntersect gts_segments_are_intersecting  (GtsSegment *s1,
                                             GtsSegment *s2);
GtsSegment* gts_segment_is_duplicate        (GtsSegment *s);
gboolean    gts_segment_is_ok               (GtsSegment *s);
#define     gts_segment_connect             (s, e1, e2)
#define     gts_segments_touch              (s1, s2)
GSList*     gts_segments_from_vertices      (GSList *vertices);
GtsVertex*  gts_segment_midvertex           (GtsSegment *s,
                                             GtsVertexClass *klass);

Description

Segments are defined by their two GtsVertex. They are not oriented.

When destroying a GtsSegment, all the vertices not used by another edge are also destroyed. This default behaviour can be changed punctually by setting the global variable gts_allow_floating_vertices to TRUE. You must not forget to set this variable back to FALSE as all the algorithms of GTS assume the default behaviour.

Details

GTS_SEGMENT_CLASS()

#define     GTS_SEGMENT_CLASS(klass)

Casts klass to GtsSegmentClass.

klass :

a descendant of GtsSegmentClass.


GTS_SEGMENT()

#define     GTS_SEGMENT(obj)

Casts obj to GtsSegment.

obj :

a descendant of GtsSegment.


GTS_IS_SEGMENT()

#define     GTS_IS_SEGMENT(obj)

Evaluates to TRUE if obj is a descendant of GtsSegment, FALSE otherwise.

obj :

a pointer to test.


struct GtsSegmentClass

struct GtsSegmentClass {

  GtsObjectClass parent_class;
};

The segment class. No virtual functions are assiocated.


struct GtsSegment

struct GtsSegment {

  GtsObject object;

  GtsVertex * v1;
  GtsVertex * v2;
};

The segment object.

GtsObject object

The parent object.

GtsVertex *v1

First endpoint of the segment.

GtsVertex *v2

Second endpoint of the segment.


gts_segment_class ()

GtsSegmentClass* gts_segment_class          (void);

Returns :

the GtsSegmentClass.


gts_segment_new ()

GtsSegment* gts_segment_new                 (GtsSegmentClass *klass,
                                             GtsVertex *v1,
                                             GtsVertex *v2);

klass :

a GtsSegmentClass.

v1 :

a GtsVertex.

v2 :

another GtsVertex different from v1.

Returns :

a new GtsSegment linking v1 and v2.


gts_segments_are_identical()

#define     gts_segments_are_identical(s1, s2)

Evaluates to TRUE if s1 and s2 link the same vertices, FALSE otherwise.

s1 :

a GtsSegment.

s2 :

another GtsSegment.


gts_segments_are_intersecting ()

GtsIntersect gts_segments_are_intersecting  (GtsSegment *s1,
                                             GtsSegment *s2);

s1 :

a GtsSegment.

s2 :

a GtsSegment.

Returns :

GTS_IN if s1 and s2 are intersecting, GTS_ON if one of the endpoints of s1 (resp. s2) lies on s2 (resp. s1), GTS_OUT otherwise.


gts_segment_is_duplicate ()

GtsSegment* gts_segment_is_duplicate        (GtsSegment *s);

s :

a GtsSegment.

Returns :

the first GtsSegment different from s which shares the same endpoints or NULL if there is none.


gts_segment_is_ok ()

gboolean    gts_segment_is_ok               (GtsSegment *s);

s :

a GtsSegment.

Returns :

TRUE if s is not degenerate (i.e. s->v1 != s->v2) and not duplicate, FALSE otherwise.


gts_segment_connect()

#define     gts_segment_connect(s, e1, e2)

Evaluates to TRUE if s connects e1 with e2, FALSE otherwise.

s :

a GtsSegment.

e1 :

a GtsVertex.

e2 :

another GtsVertex.


gts_segments_touch()

#define     gts_segments_touch(s1, s2)

s1 :

s2 :


gts_segments_from_vertices ()

GSList*     gts_segments_from_vertices      (GSList *vertices);

vertices :

a list of GtsVertex.

Returns :

a list of unique GtsSegment which have one of their vertices in vertices.


gts_segment_midvertex ()

GtsVertex*  gts_segment_midvertex           (GtsSegment *s,
                                             GtsVertexClass *klass);

s :

a GtsSegment.

klass :

a GtsVertexClass to be used for the new vertex.

Returns :

a new GtsVertex, midvertex of s.