void SolidConstrcutFromSurface(Solid * * solid, txTriSurfaceData *surf) { Solid * s; s = SolidNew(); VertexListConstrcutFromSurface(&s, surf); VertexListIndexConstruct(&s); FaceListConstructFromSurface(&s,surf); EdgeListConstruct(&s); *solid = s; }
Solid *ConstructHalfEdge_ModelFromOBJ( char *FileName ) { struct _Model *m; FILE *file; Solid *s; int i; /* open the file */ file = fopen(FileName, "r"); if (!file) return NULL; /* load the OBJ, unitize it, compute facet normals, etc */ m = (struct _Model *) malloc( sizeof( struct _Model ) ); memset( m, 0, sizeof( struct _Model ) ); m->file = strdup( FileName ); ReadOBJFirstPass( m, file ); rewind(file); ReadOBJSecondPass( m, file ); Unitize_Model( m ); ComputeFacetNormals( m ); ComputeVertexNormals( m ); fclose( file ); s = SolidNew( ); for (i=0; i< m->numVertices; i++) VertexConstructN( &s, m->vertexPos[3*i+0], m->vertexPos[3*i+1], m->vertexPos[3*i+2], m->normList[3*i+0], m->normList[3*i+1], m->normList[3*i+2] ); for (i=0; i< m->numTriangles; i++) { Vertex *va = VertexListIndex( s, m->triVertexIndex[3*i+0] ); Vertex *vb = VertexListIndex( s, m->triVertexIndex[3*i+1] ); Vertex *vc = VertexListIndex( s, m->triVertexIndex[3*i+2] ); FaceConstruct( &s, va, vb, vc); } EdgeListConstruct(&s); return s; }