MESH * cvinit( /* initialize empty mesh */ char *nm ) { /* free old mesh, first */ if (ourmesh != NULL) { freemesh(ourmesh); ourmesh = NULL; freeobjects(0, nobjects); donesets(); } if (nm == NULL) return(NULL); ourmesh = (MESH *)calloc(1, sizeof(MESH)); if (ourmesh == NULL) goto nomem; ourmesh->name = savestr(nm); ourmesh->nref = 1; ourmesh->ldflags = 0; ourmesh->mcube.cutree = EMPTY; ourmesh->uvlim[0][0] = ourmesh->uvlim[0][1] = FHUGE; ourmesh->uvlim[1][0] = ourmesh->uvlim[1][1] = -FHUGE; meshbounds[0][0] = meshbounds[0][1] = meshbounds[0][2] = FHUGE; meshbounds[1][0] = meshbounds[1][1] = meshbounds[1][2] = -FHUGE; return(ourmesh); nomem: error(SYSTEM, "out of memory in cvinit"); return(NULL); }
void freemeshinst(OBJREC *o) /* free mesh instance */ { if (o->os == NULL) return; freemesh((*(MESHINST *)o->os).msh); free((void *)o->os); o->os = NULL; }
int32_t main() { mat33 m, mr, mp; vec3 b; vec3 sol; mat22 m2, mr2, mp2; vec2 b2; vec2 sol2; triangle t; mesh * msh; m[0][0] = 1.0; m[0][1] = 2.0; m[0][2] = 3.0; m[1][0] = 1.0; m[1][1] = 5.0; m[1][2] = 6.0; m[2][0] = 2.0; m[2][1] = 3.0; m[2][2] = 1.0; b[0] = 10.0; b[1] = 5.0; b[2] = 15.0; printmat((double *)m, 3, 3); printvec(b, 3); if (solsyst3(m, b, sol) == 0) printf("determinant nul\n"); printvec(sol, 3); multmat3vec3(m, sol, b); printvec(b, 3); invmat3(m, mr); printmat((double *)mr, 3, 3); multmat3mat3(m, mr, mp); printmat((double *)mp, 3, 3); m2[0][0] = 1.0; m2[0][1] = 2.0; m2[1][0] = 1.0; m2[1][1] = 5.0; b2[0] = 10.0; b2[1] = 5.0; printmat((double *)m2, 2, 2); printvec(b2, 2); if (solsyst2(m2, b2, sol2) == 0) printf("determinant nul\n"); printvec(sol2, 2); multmat2vec2(m2, sol2, b2); printvec(b2, 2); invmat2(m2, mr2); printmat((double *)mr2, 2, 2); multmat2mat2(m2, mr2, mp2); printmat((double *)mp2, 2, 2); t.xa = 1.0; t.ya = 1.0; t.xb = 2.0; t.yb = 1.0; t.xc = 1.0; t.yc = 2.0; if (inittriangle(&t) == 0) printf("mauvais triangle\n"); printtriangle(&t); msh = readmesh("essai.msh"); printmesh(msh); freemesh(msh); }