Exemplo n.º 1
0
/** Get all tuples for a structure. */
struct mdt_tuple_list *tupclass(const struct mod_structure *struc,
                                const struct mod_sequence *seq,
                                const struct mdt_atom_class_list *atclass,
                                const struct mod_libraries *libs)
{
  int i;
  struct mdt_tuple_list *tuples;
  GArray *tlist;
  tuples = g_malloc(sizeof(struct mdt_tuple_list) * struc->cd.natm);
  tlist = g_array_new(FALSE, FALSE, sizeof(struct mdt_tuple));
  for (i = 0; i < struc->cd.natm; i++) {
    if (atmdefd(i, &struc->cd)) {
      get_tuples(i, struc, seq, atclass, tlist, libs);
    }
    if (tlist->len > 0) {
      tuples[i].ntuples = tlist->len;
      tuples[i].tuples = (struct mdt_tuple *)g_array_free(tlist, FALSE);
      tlist = g_array_new(FALSE, FALSE, sizeof(struct mdt_tuple));
    } else {
      tuples[i].ntuples = 0;
      tuples[i].tuples = NULL;
    }
  }
  g_array_free(tlist, TRUE);
  return tuples;
}
Exemplo n.º 2
0
//returns -1 on fail, number of vertices on success
int load_off_mesh(FILE* fp, jmesh *jm){
    fseek(fp, 0, SEEK_SET); //ensure we are at the start of the file

    if(is_off_file(fp) != 0){
        fprintf(stderr, "not an off file\n");
        return -1;
    }

    int i;
    i=get_verts_faces(fp, jm);
    if(i != 3){
        fprintf(stderr,"off file corrupt on line 2\n");
        return -1;
    }
    i=get_tuples(fp, jm);
    if(i != jm->nvert){
        fprintf(stderr,"off file corrupt on tuple line %d\n", i);
        return -1;
    }
    i=get_faces(fp, jm);
    if(i != jm->ntri){
        fprintf(stderr,"off file corrupt on polygon line %d\n", i);
        return -1;
    }
    get_normals(jm);
    get_centroid(jm, jm->center);
    return i;
}