Exemplo n.º 1
0
static void
p2tr_edge_remove_one_side (P2trEdge *self)
{
  if (self->tri != NULL)
  {
    p2tr_triangle_remove (self->tri);
    p2tr_triangle_unref (self->tri);
    self->tri = NULL;
  }
  _p2tr_point_remove_edge(P2TR_EDGE_START(self), self);
  p2tr_point_unref (self->end);
  self->end = NULL;
}
Exemplo n.º 2
0
/** Insert a point into a triangle. This function assumes the point is
 * inside the triangle - not on one of its edges and not outside of it.
 */
void
p2tr_cdt_insert_point_into_triangle (P2trCDT      *self,
                                     P2trPoint    *P,
                                     P2trTriangle *tri)
{
  P2trVEdgeSet *flip_candidates = p2tr_vedge_set_new ();

  P2trPoint *A = tri->edges[0]->end;
  P2trPoint *B = tri->edges[1]->end;
  P2trPoint *C = tri->edges[2]->end;

  P2trEdge *CA = tri->edges[0];
  P2trEdge *AB = tri->edges[1];
  P2trEdge *BC = tri->edges[2];

  P2trEdge *AP, *BP, *CP;

  p2tr_triangle_remove (tri);

  AP = p2tr_mesh_new_edge (self->mesh, A, P, FALSE);
  BP = p2tr_mesh_new_edge (self->mesh, B, P, FALSE);
  CP = p2tr_mesh_new_edge (self->mesh, C, P, FALSE);

  p2tr_triangle_unref (p2tr_mesh_new_triangle (self->mesh, AB, BP, AP->mirror));
  p2tr_triangle_unref (p2tr_mesh_new_triangle (self->mesh, BC, CP, BP->mirror));
  p2tr_triangle_unref (p2tr_mesh_new_triangle (self->mesh, CA, AP, CP->mirror));

  p2tr_vedge_set_add (flip_candidates, CP);
  p2tr_vedge_set_add (flip_candidates, AP);
  p2tr_vedge_set_add (flip_candidates, BP);

  p2tr_vedge_set_add (flip_candidates, p2tr_edge_ref (CA));
  p2tr_vedge_set_add (flip_candidates, p2tr_edge_ref (AB));
  p2tr_vedge_set_add (flip_candidates, p2tr_edge_ref (BC));

  /* Flip fix the newly created triangles to preserve the the
   * constrained delaunay property. The flip-fix function will unref the
   * new triangles for us! */
  p2tr_cdt_flip_fix (self, flip_candidates);

  p2tr_vedge_set_free (flip_candidates);
}
Exemplo n.º 3
0
/** Insert a point into a triangle. This function assumes the point is
 * inside the triangle - not on one of its edges and not outside of it.
 */
void
p2tr_cdt_insert_point_into_triangle (P2trCDT      *self,
                                     P2trPoint    *P,
                                     P2trTriangle *tri)
{
    GList *new_tris;

    P2trPoint *A = tri->edges[0]->end;
    P2trPoint *B = tri->edges[1]->end;
    P2trPoint *C = tri->edges[2]->end;

    P2trEdge *CA = tri->edges[1];
    P2trEdge *AB = tri->edges[2];
    P2trEdge *BC = tri->edges[0];

    P2trEdge *AP, *BP, *CP;

    p2tr_triangle_remove (tri);

    AP = p2tr_mesh_new_edge (self->mesh, A, P, FALSE);
    BP = p2tr_mesh_new_edge (self->mesh, B, P, FALSE);
    CP = p2tr_mesh_new_edge (self->mesh, C, P, FALSE);

    new_tris = p2tr_utils_new_reversed_pointer_list (3,
               p2tr_mesh_new_triangle (self->mesh, AB, BP, AP->mirror),
               p2tr_mesh_new_triangle (self->mesh, BC, CP, BP->mirror),
               p2tr_mesh_new_triangle (self->mesh, CA, AP, CP->mirror));

    p2tr_edge_unref (CP);
    p2tr_edge_unref (BP);
    p2tr_edge_unref (AP);

    /* Flip fix the newly created triangles to preserve the the
     * constrained delaunay property. The flip-fix function will unref the
     * new triangles for us! */
    p2tr_cdt_flip_fix (self, new_tris);

    g_list_free (new_tris);
}