예제 #1
0
static solid *tetrahedron(jigglystruct *js)
{
    solid *s;
    vertex *vtx;
    vector v;
    hedge *h;
    face *f;
    int i;

    vector_init(v, 1, 1, 1);
    s = solid_new(v);
    vector_init(v, -1, -1, 1);
    h = s->faces->start;
    vtx = vertex_split(h, v);
    vector_init(v, -1, 1, -1);
    vtx = vertex_split(vtx->h, v);
    h = vtx->h;
    f = face_split(s->faces, h, h->prev);
    vector_init(v, 1, -1, -1);
    vertex_split(f->start, v);
    f = s->faces->next->next;
    h = f->start;
    face_split(f, h, h->next->next);

    if(js->color_style == COLOR_STYLE_FLOWERBOX) {
        f = s->faces;
        for(i=0; i<4; i++) {
            f->color = flowerbox_colors[i];
            f = f->next;
        }
    }

    return s;
}
예제 #2
0
// vertex_split and helpers
int FEM_Adapt::vertex_split(int n, int n1, int n2) 
{
  int e1 = theMesh->getElementOnEdge(n, n1);
  if (e1 < 0) {
    CkPrintf("ERROR: vertex_split: no element with edge [%d,%d]\n", n, n1);
    return -1;	     
  }
  int e3 = theMesh->getElementOnEdge(n, n2);
  if (e3 < 0) {
    CkPrintf("ERROR: vertex_split: no element with edge [%d,%d]\n", n, n2);
    return -1;	     
  }
  return vertex_split(n, n1, n2, e1, e3);
}
예제 #3
0
/* This will only work with solids composed entirely of
 * triangular faces. It first add a vertex to the middle
 * of each edge, then walks the faces, connecting the
 * dots.
 * I'm abusing the fact that new faces and edges are always
 * added at the head of the list. If that ever changes,
 * this is borked.
 */
static void solid_tesselate(solid *s)
{
    edge *e = s->edges;
    face *f = s->faces;

    while(e) {
        vector v;
        midpoint(e->left->vtx->v, e->right->vtx->v, v);
        vertex_split(e->left, v);
        e = e->next;
    }
    while(f) {
        face_tessel2(f);
        f=f->next;
    }
}