void VertexListConstrcutFromSurface(Solid * * solid, txTriSurfaceData *surf) { std::vector<txVector3> &verts = surf->GetVerts(); for (size_t i=0; i<verts.size(); i++) { VertexConstructN(solid,verts[i].x, verts[i].y, verts[i].z, 0.0, 0.0, 0.0); } }
Solid *ConstructHalfEdge_ModelFromOBJ_WStatus( 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] ); printf(" (-) Constructing faces (%8.4f%% done)...", 0.0f ); fflush( stdout ); 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); if (i%1000 == 0) { printf("\r (-) Constructing faces (%8.4f%% done)...", 100.0f*((float)i/m->numTriangles) ); fflush( stdout ); } } printf("\r (-) Constructing faces (%8.4f%% done)...\n", 100.0f ); fflush( stdout ); EdgeListConstructVerbose(&s, m->numTriangles); return 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; }