#ifndef toposlice_hedge_H #define toposlice_hedge_H /* Copyright (C) 2023 Jorge Stolfi, UNICAMP */ /* Last edited on 2023-10-04 08:16:07 by stolfi */ #include #include #include struct hedge_face_t *left; /* face on left side. */ struct hedge_vert_t *org; /* Origin vertex. */ double bend; /* Modifies the direction at endpoints. */ The {bend} attribute is used when drawing the structure. typedef struct toposlice_hedge_face_t { struct hedge_arc_t *side; /* One {arc_t} on the perimeter. */ r3_t ctr; /* Nominal center, for plotting. */ bool_t show; /* True to draw the record. */ int32_t id; /* Sequential number. */ } toposlice_hedge_face_t; /* A record of the half-edge structure representing a face of the mesh. The {ctr} and {show} attributes are used when drawing the structure. */ vec_typedef(toposlice_hedge_face_vec_t, toposlice_hedge_face_vec, toposlice_hedge_face_t*); /* A vector of pointers to {Vace_t} records. */ typedef struct hedge_arc_t { struct hedge_arc_t *twin; /* Same edge in opposite orientation. */ struct hedge_arc_t *next; /* Next edge around left face. */ struct hedge_face_t *left; /* face on left side. */ struct hedge_vert_t *org; /* Origin vertex. */ double bend; /* Modifies the direction at endpoints. */ int32_t id; /* Sequential number. */ } hedge_arc_t; /* A record of the half-edge structure representing a directed edge of the mesh. The {bow} attribute is used when drawing the structure. */ vec_typedef(toposlice_hedge_arc_vec_t, toposlice_hedge_arc_vec, hedge_arc_t*); /* A vector of pointers to {hedge_arc_t} records. The twin of an arc {a[i]} is {a[i^1]}. */ typedef struct toposlice_hedge_vert_t { struct hedge_arc_t *out; /* One arc out the vertex. */ r3_t pos; /* Nominal position. */ bool_t show; /* True to draw the record. */ int32_t id; /* Sequential number. */ } toposlice_hedge_vert_t; /* A record of the half-edge structure representing a vertex of the mesh. The {pos} and {show} attributes are used when drawing the structure. */ vec_typedef(toposlice_hedge_vert_vec_t, toposlice_hedge_vert_vec, toposlice_hedge_vert_t*); /* A vector of pointers to {vert_t} records. */ typedef struct toposlice_hedge_t { int32_t nv; toposlice_hedge_vert_vec_t V; /* The vertices are V.e[0..nv-1]. */ int32_t na; toposlice_hedge_arc_vec_t A; /* The arcs are A.e[0..na-1]. */ int32_t nf; toposlice_hedge_face_vec_t F; /* The faces are F.e[0..nf-1]. */ } toposlice_hedge_t; /* A half-edge structure. */ toposlice_hedge_t *toposlice_hedge_new(int32_t nf_alloc, int32_t ne_alloc, int32_t nv_alloc); /* Creates a new half-edge structure, with tables initially allocatde for the give number of faces, edges, and vertices. */ toposlice_hedge_face_t *toposlice_hedge_add_face(toposlice_hedge_t *H, double X, double Y, double Z, bool_t show); /* Adds to {H} a new face record {f} to the end of {H.F}, expanding it if needed. The nominal centroid {f.pos} is set to {(X,Y,Z)}, and {f.show} is set to {show}. The pointer {f.side} is set to {NULL}. */ toposlice_hedge_vert_t *toposlice_hedge_add_vert(toposlice_hedge_t *H, double X, double Y, double Z, bool_t show); /* Adds to {H} a new vertex record {v} to the end of {H.V}, expanding it if needed. The position {v.pos} is set to {(X,Y,Z)}, and {v.show} is set to {show}. The pointer {v.out} is set to {NULL}. */ hedge_arc_t *toposlice_hedge_add_edge ( toposlice_hedge_t *H, toposlice_hedge_vert_t *org, toposlice_hedge_vert_t *dst, toposlice_hedge_face_t *left, toposlice_hedge_face_t *right, double bend ); /* Adds to {H} an edge, consisting of two {arc_t} records {a,b}, each the {twin} of the other, respectively from {org} to {dst} (with left face {left}) and from {dst} to {org} (with left face {right}). The arcs are added at the end of {H.A}, expanding it if needed. Returns the arc {a}. The pointers {org.out} and {left.side} are set to {a} while {dst.out} and {right.side are set to {b}. The {next} pointers of the two arcs are set to {NULL}; they should be eventually defined by the client with {hedge_set_next} below. */ void hedge_set_next(hedge_arc_t *a,hedge_arc_t *b); /* Sets the pointer {a.next} (which must be {NULL}) to point to {b}. The two must have the same non-{NULL} {left} face link, and that face record must have a non-null {side} link. */ void hedge_check_topology(hedge_t *H); /* Topological consistency checks. */ #endif