pcb 4.1.1
An interactive printed circuit board layout editor.

split.c File Reference

#include <stdlib.h>
#include <string.h>
#include "gts.h"
Include dependency graph for split.c:

Go to the source code of this file.

Data Structures

struct  _GtsSplitCFace
struct  _CFace
struct  _CFaceClass

Defines

#define DYNAMIC_SPLIT
#define NEW
#define IS_CFACE(obj)   (gts_object_is_from_class (obj, cface_class ()))
#define CFACE(obj)   ((CFace *) obj)
#define CFACE_ORIENTATION(cf)   ((cf)->flags & 0x1)
#define CFACE_ORIENTATION_DIRECT(cf)   ((cf)->flags |= 0x1)
#define CFACE_VVS(cf)   ((cf)->flags & 0x2)
#define CFACE_VVS_DIRECT(cf)   ((cf)->flags |= 0x2)
#define CFACE_E1   0x4
#define CFACE_E2   0x8
#define CFACE_KEEP_VVS   0x10
#define ROTATE_ORIENT(e, e1, e2, e3)
#define SEGMENT_USE_VERTEX(s, v)   ((s)->v1 == v || (s)->v2 == v)
#define TRIANGLE_REPLACE_EDGE(t, e, with)
#define HEAP_INSERT_OBJECT(h, e)
#define HEAP_REMOVE_OBJECT(h, e)

Typedefs

typedef struct _CFace CFace
typedef struct _CFaceClass CFaceClass

Functions

static GtsObjectClasscface_class (void)
static GtsTrianglereplace_edge_collapse (GtsEdge *e, GtsEdge *with, CFace *cf, GtsEHeap *heap, GtsTriangle ***a1, guint edge_flag)
static CFacecface_new (GtsFace *f, GtsEdge *e, GtsVertex *v1, GtsVertex *v2, GtsSplit *vs, GtsEHeap *heap, GtsEdgeClass *klass, GtsSplitCFace *scf)
static void find_vvs (GtsVertex *vs, GtsTriangle *t, GtsVertex **v, GtsEdge **vvs, gboolean orientation)
static void replace_edge_expand (GtsEdge *e, GtsEdge *with, GtsTriangle **a, GtsVertex *v)
static void cface_expand (CFace *cf, GtsTriangle **a1, GtsTriangle **a2, GtsEdge *e, GtsVertex *v1, GtsVertex *v2, GtsVertex *vs, GtsEdgeClass *klass)
static void split_destroy (GtsObject *object)
static void split_class_init (GtsObjectClass *klass)
static void split_init (GtsSplit *split)
GtsSplitClassgts_split_class (void)
void gts_split_collapse (GtsSplit *vs, GtsEdgeClass *klass, GtsEHeap *heap)
void gts_split_expand (GtsSplit *vs, GtsSurface *s, GtsEdgeClass *klass)
GtsSplitgts_split_new (GtsSplitClass *klass, GtsVertex *v, GtsObject *o1, GtsObject *o2)
static gboolean split_traverse_pre_order (GtsSplit *vs, GtsSplitTraverseFunc func, gpointer data)
static gboolean split_depth_traverse_pre_order (GtsSplit *vs, guint depth, GtsSplitTraverseFunc func, gpointer data)
static gboolean split_traverse_post_order (GtsSplit *vs, GtsSplitTraverseFunc func, gpointer data)
static gboolean split_depth_traverse_post_order (GtsSplit *vs, guint depth, GtsSplitTraverseFunc func, gpointer data)
void gts_split_traverse (GtsSplit *root, GTraverseType order, gint depth, GtsSplitTraverseFunc func, gpointer data)
guint gts_split_height (GtsSplit *root)
void gts_hsplit_force_expand (GtsHSplit *hs, GtsHSurface *hsurface)
static void index_object (GtsObject *o, guint *n)
static void index_face (GtsFace *f, gpointer *data)
void gts_psurface_write (GtsPSurface *ps, FILE *fptr)
static guint surface_read (GtsSurface *surface, GtsFile *f, GPtrArray *vertices, GPtrArray *faces)
GtsPSurfacegts_psurface_open (GtsPSurfaceClass *klass, GtsSurface *s, GtsSplitClass *split_class, GtsFile *f)
GtsSplitgts_psurface_read_vertex (GtsPSurface *ps, GtsFile *fp)
void gts_psurface_close (GtsPSurface *ps)

Define Documentation

#define CFACE (   obj)    ((CFace *) obj)
#define CFACE_E1   0x4

Definition at line 68 of file split.c.

Referenced by cface_expand(), and cface_new().

#define CFACE_E2   0x8

Definition at line 69 of file split.c.

Referenced by cface_expand(), and cface_new().

#define CFACE_KEEP_VVS   0x10

Definition at line 70 of file split.c.

Referenced by cface_expand(), and replace_edge_collapse().

#define CFACE_ORIENTATION (   cf)    ((cf)->flags & 0x1)

Definition at line 64 of file split.c.

Referenced by cface_expand().

#define CFACE_ORIENTATION_DIRECT (   cf)    ((cf)->flags |= 0x1)

Definition at line 65 of file split.c.

Referenced by cface_new().

#define CFACE_VVS (   cf)    ((cf)->flags & 0x2)

Definition at line 66 of file split.c.

Referenced by cface_expand().

#define CFACE_VVS_DIRECT (   cf)    ((cf)->flags |= 0x2)

Definition at line 67 of file split.c.

Referenced by cface_new().

#define DYNAMIC_SPLIT

Definition at line 33 of file split.c.

Referenced by gts_split_collapse().

#define HEAP_INSERT_OBJECT (   h,
 
)
Value:
(GTS_OBJECT (e)->reserved =\
                                  gts_eheap_insert (h, e))

Definition at line 86 of file split.c.

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

Definition at line 88 of file split.c.

Referenced by replace_edge_collapse().

#define IS_CFACE (   obj)    (gts_object_is_from_class (obj, cface_class ()))
#define NEW

Definition at line 34 of file split.c.

Referenced by cface_new().

#define ROTATE_ORIENT (   e,
  e1,
  e2,
  e3 
)
Value:
{ if (e1 == e) { e1 = e2; e2 = e3; }\
                                 else if (e2 == e) { e2 = e1; e1 = e3; }\
                                 else g_assert (e3 == e); }

Definition at line 72 of file split.c.

Referenced by cface_new().

#define SEGMENT_USE_VERTEX (   s,
 
)    ((s)->v1 == v || (s)->v2 == v)

Definition at line 75 of file split.c.

Referenced by cface_new(), and find_vvs().

#define TRIANGLE_REPLACE_EDGE (   t,
  e,
  with 
)
Value:
{ if ((t)->e1 == e)\
                                              (t)->e1 = with;\
                                            else if ((t)->e2 == e)\
                                              (t)->e2 = with;\
                                            else {\
                                              g_assert ((t)->e3 == e);\
                                              (t)->e3 = with;\
                                            }\
                                          }

Definition at line 76 of file split.c.

Referenced by replace_edge_collapse(), and replace_edge_expand().


Typedef Documentation

typedef struct _CFace CFace

Definition at line 45 of file split.c.

typedef struct _CFaceClass CFaceClass

Definition at line 46 of file split.c.


Function Documentation

static GtsObjectClass* cface_class ( void  ) [static]

Definition at line 91 of file split.c.

References gts_object_class(), and gts_object_class_new().

Referenced by cface_new(), gts_psurface_read_vertex(), and gts_split_collapse().

Here is the call graph for this function:

static void find_vvs ( GtsVertex vs,
GtsTriangle t,
GtsVertex **  v,
GtsEdge **  vvs,
gboolean  orientation 
) [static]
void gts_hsplit_force_expand ( GtsHSplit hs,
GtsHSurface hsurface 
)

gts_hsplit_force_expand: : a GtsHSplit. : a GtsHSurface.

Forces the expansion of by first expanding all its dependencies not already expanded.

Definition at line 1184 of file split.c.

References _GtsSplitCFace::a1, _GtsSplitCFace::a2, CFACE, _GtsSplitCFace::f, GTS_HSPLIT, gts_hsplit_expand(), gts_hsplit_force_expand(), GTS_SPLIT, IS_CFACE, _GtsHSplit::nchild, and _GtsHSplit::parent.

Referenced by gts_hsplit_force_expand().

Here is the call graph for this function:

void gts_psurface_close ( GtsPSurface ps)

gts_psurface_close: : a GtsPSurface prealably created with gts_psurface_open().

Closes a progressive surface.

Definition at line 1804 of file split.c.

References _GtsPSurface::faces, gts_object_reset_reserved(), GTS_PSURFACE_IS_CLOSED, gts_surface_foreach_vertex(), n, _GtsPSurface::pos, _GtsPSurface::s, _GtsPSurface::split, TRUE, and _GtsPSurface::vertices.

Referenced by psurface_destroy().

Here is the call graph for this function:

GtsPSurface* gts_psurface_open ( GtsPSurfaceClass klass,
GtsSurface s,
GtsSplitClass split_class,
GtsFile f 
)

gts_psurface_open: : a GtsPSurfaceClass. : a GtsSurface. : a GtsSplitClass to use for the GtsSplit. : a GtsFile.

Creates a new GtsPSurface prepared for input from the file containing a valid GTS representation of a progressive surface. The initial shape of the progressive surface is loaded into .

Before being usable as such this progressive surface must be closed using gts_psurface_close(). While open however, the functions gts_psurface_get_vertex_number(), gts_psurface_min_vertex_number() and gts_psurface_max_vertex_number() can still be used.

Returns: a new GtsPSurface or NULL if there was a format error while reading the file, in which case contains information about the error.

Definition at line 1563 of file split.c.

References _GtsPSurface::faces, gts_file_first_token_after(), GTS_INT, GTS_OBJECT, GTS_OBJECT_CLASS, gts_object_destroy(), gts_object_new(), GTS_PSURFACE, gts_surface_vertex_number(), _GtsPSurface::min, _GtsPSurface::pos, s, _GtsPSurface::s, _GtsPSurface::split, _GtsPSurface::split_class, surface_read(), _GtsFile::token, _GtsFile::type, and _GtsPSurface::vertices.

Here is the call graph for this function:

GtsSplit* gts_psurface_read_vertex ( GtsPSurface ps,
GtsFile fp 
)
GtsSplitClass* gts_split_class ( void  )

gts_split_class:

Returns: the GtsSplitClass.

Definition at line 463 of file split.c.

References gts_object_class(), gts_object_class_new(), split_class_init(), and split_init().

Referenced by gts_hsplit_class(), psurface_init(), and split_destroy().

Here is the call graph for this function:

void gts_split_collapse ( GtsSplit vs,
GtsEdgeClass klass,
GtsEHeap heap 
)

gts_split_collapse: : a GtsSplit. : a GtsEdgeClass. : a GtsEHeap or NULL.

Collapses the vertex split . Any new edge created during the process will be of class . If heap is not NULL, the new edges will be inserted into it and the destroyed edges will be removed from it.

Definition at line 554 of file split.c.

References _GtsSplitCFace::a1, _GtsSplitCFace::a2, CFACE, cface_class(), cface_new(), _GtsSplit::cfaces, DYNAMIC_SPLIT, _GtsTriangle::e1, _GtsTriangle::e2, _GtsTriangle::e3, _GtsSplitCFace::f, FALSE, gts_allow_floating_vertices, GTS_EDGE, GTS_FACE, GTS_IS_FACE, GTS_OBJECT, GTS_OBJECT_CLASS, gts_object_destroy(), GTS_POINT, GTS_SEGMENT, gts_segment_is_duplicate(), gts_split_expand(), GTS_SPLIT_V1, GTS_SPLIT_V2, gts_triangle_is_duplicate(), gts_vertex_triangles(), gts_vertices_are_connected(), _GtsSplit::ncf, s, _GtsVertex::segments, _GtsEdge::triangles, TRUE, _GtsSplit::v, _GtsSegment::v1, and _GtsSegment::v2.

Referenced by edge_collapse(), gts_hsplit_collapse(), and gts_psurface_remove_vertex().

Here is the call graph for this function:

void gts_split_expand ( GtsSplit vs,
GtsSurface s,
GtsEdgeClass klass 
)
guint gts_split_height ( GtsSplit root)

gts_split_height: : a GtsSplit.

Returns: the maximum height of the vertex split tree having as root.

Definition at line 1080 of file split.c.

References GTS_IS_SPLIT, GTS_SPLIT, gts_split_height(), _GtsSplit::v1, and _GtsSplit::v2.

Referenced by gts_hsurface_height(), and gts_split_height().

Here is the call graph for this function:

GtsSplit* gts_split_new ( GtsSplitClass klass,
GtsVertex v,
GtsObject o1,
GtsObject o2 
)

gts_split_new: : a GtsSplitClass. : a GtsVertex. : either a GtsVertex or a GtsSplit. : either a GtsVertex or a GtsSplit.

Creates a new GtsSplit which would collapse and into . The collapse itself is not performed.

Returns: the new GtsSplit.

Definition at line 907 of file split.c.

References _GtsSplit::cfaces, _GtsSplitCFace::f, GTS_EDGE, GTS_IS_SPLIT, GTS_IS_VERTEX, GTS_OBJECT_CLASS, gts_object_new(), GTS_SPLIT, GTS_SPLIT_V1, GTS_SPLIT_V2, gts_vertices_are_connected(), _GtsSplit::ncf, _GtsEdge::triangles, _GtsSplit::v, _GtsSplit::v1, and _GtsSplit::v2.

Referenced by edge_collapse().

Here is the call graph for this function:

void gts_split_traverse ( GtsSplit root,
GTraverseType  order,
gint  depth,
GtsSplitTraverseFunc  func,
gpointer  data 
)

gts_split_traverse: : the GtsSplit to start the traversal from. : the order in which nodes are visited - G_PRE_ORDER or G_POST_ORDER. : the maximum depth of the traversal. Nodes below this depth will not be visited. If depth is -1 all nodes in the tree are visited. If depth is 1, only the root is visited. If depth is 2, the root and its children are visited. And so on. : the function to call for each visited GtsHSplit. : user data to pass to the function.

Traverses the GtsSplit tree having as root. Calls for each GtsSplit of the tree in the order specified by . If order is set to G_PRE_ORDER is called for the GtsSplit then its children, if order is set to G_POST_ORDER is called for the children and then for the GtsSplit.

Definition at line 1045 of file split.c.

References split_depth_traverse_post_order(), split_depth_traverse_pre_order(), split_traverse_post_order(), and split_traverse_pre_order().

Referenced by gts_hsurface_traverse().

Here is the call graph for this function:

static void index_face ( GtsFace f,
gpointer *  data 
) [static]

Definition at line 1257 of file split.c.

Referenced by gts_psurface_write().

static void index_object ( GtsObject o,
guint *  n 
) [static]

Definition at line 1252 of file split.c.

References _GtsObject::reserved.

Referenced by gts_psurface_write().

static GtsTriangle* replace_edge_collapse ( GtsEdge e,
GtsEdge with,
CFace cf,
GtsEHeap heap,
GtsTriangle ***  a1,
guint  edge_flag 
) [static]

Definition at line 115 of file split.c.

References CFACE_KEEP_VVS, GTS_OBJECT, gts_object_destroy(), HEAP_REMOVE_OBJECT, IS_CFACE, TRIANGLE_REPLACE_EDGE, and _GtsEdge::triangles.

Referenced by cface_new().

Here is the call graph for this function:

static void replace_edge_expand ( GtsEdge e,
GtsEdge with,
GtsTriangle **  a,
GtsVertex v 
) [static]

Definition at line 335 of file split.c.

References GTS_OBJECT, IS_CFACE, TRIANGLE_REPLACE_EDGE, and _GtsEdge::triangles.

Referenced by cface_expand().

static void split_class_init ( GtsObjectClass klass) [static]

Definition at line 445 of file split.c.

References _GtsObjectClass::destroy, and split_destroy().

Referenced by gts_split_class().

Here is the call graph for this function:

static gboolean split_depth_traverse_post_order ( GtsSplit vs,
guint  depth,
GtsSplitTraverseFunc  func,
gpointer  data 
) [static]

Definition at line 1007 of file split.c.

References FALSE, GTS_IS_SPLIT, GTS_SPLIT, TRUE, _GtsSplit::v1, and _GtsSplit::v2.

Referenced by gts_split_traverse().

static gboolean split_depth_traverse_pre_order ( GtsSplit vs,
guint  depth,
GtsSplitTraverseFunc  func,
gpointer  data 
) [static]

Definition at line 969 of file split.c.

References FALSE, GTS_IS_SPLIT, GTS_SPLIT, TRUE, _GtsSplit::v1, and _GtsSplit::v2.

Referenced by gts_split_traverse().

static void split_destroy ( GtsObject object) [static]
static void split_init ( GtsSplit split) [static]

Definition at line 450 of file split.c.

References _GtsSplit::cfaces, _GtsSplit::ncf, _GtsSplit::v, _GtsSplit::v1, and _GtsSplit::v2.

Referenced by gts_split_class().

static gboolean split_traverse_post_order ( GtsSplit vs,
GtsSplitTraverseFunc  func,
gpointer  data 
) [static]

Definition at line 991 of file split.c.

References FALSE, GTS_IS_SPLIT, GTS_SPLIT, TRUE, _GtsSplit::v1, and _GtsSplit::v2.

Referenced by gts_split_traverse().

static gboolean split_traverse_pre_order ( GtsSplit vs,
GtsSplitTraverseFunc  func,
gpointer  data 
) [static]

Definition at line 953 of file split.c.

References FALSE, GTS_IS_SPLIT, GTS_SPLIT, TRUE, _GtsSplit::v1, and _GtsSplit::v2.

Referenced by gts_split_traverse().