void FaceListConstructFromSurface(Solid * * solid, txTriSurfaceData *surf)
{
	int a, b, c;
	Vertex *va, *vb, *vc;
	std::vector<int> &indexes = surf->GetIndexes();
	for (size_t i=0; i<indexes.size()/3; i++) {
		a = indexes[i*3];
		b = indexes[i*3+1];
		c = indexes[i*3+2];
		va = VertexListIndex(*solid, a);
		vb = VertexListIndex(*solid, b);
		vc = VertexListIndex(*solid, c);
		FaceConstruct( solid, va, vb, vc);
	}
}
Example #2
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;
}
void  FaceListConstruct(Solid ** solid ,int face_number,FILE *fp)
{
  int i;
  int face_size, a, b, c;
  Vertex * va, *vb, *vc;
  char Line[1024];

  for( i = 0; i < face_number && !feof(fp); i ++ ){

		 fgets(Line,1024,fp);
		 sscanf(Line,"%d %d %d %d", &face_size, &a,&b,&c);
		 va = VertexListIndex( *solid, a );
		 vb = VertexListIndex( *solid, b );
		 vc = VertexListIndex( *solid, c );
		 FaceConstruct( solid, va, vb, vc);

		}

}
Example #4
0
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;
}