void write_file(const char* strName) { int i; PlyFile *ply; int num_elem_types; /*** Write out the transformed PLY object ***/ FILE* pFile = fopen(strName,"w"); ply = write_ply (pFile, nelems, elem_names, PLY_ASCII); /* describe what properties go into the vertex elements */ describe_element_ply (ply, "vertex", nverts); describe_property_ply (ply, &vert_props[0]); describe_property_ply (ply, &vert_props[1]); describe_property_ply (ply, &vert_props[2]); if (has_normals) { describe_property_ply (ply, &vert_props[4]); describe_property_ply (ply, &vert_props[5]); describe_property_ply (ply, &vert_props[6]); } if (texture_coords) { describe_property_ply (ply, &vert_props[7]); describe_property_ply (ply, &vert_props[8]); } describe_element_ply (ply, "face", nfaces); describe_property_ply (ply, &face_props[0]); for (i = 0; i < ncomments; i++) append_comment_ply (ply, comments[i]); append_comment_ply (ply, "converted from OBJ by obj2ply"); header_complete_ply (ply); /* set up and write the vertex elements */ put_element_setup_ply (ply, "vertex"); for (i = 0; i < nverts; i++) put_element_ply (ply, &vVertex[i]);//(void *) &vlist[i]); /* set up and write the face elements */ put_element_setup_ply (ply, "face"); for (i = 0; i < nfaces; i++){ int idx[3]; memcpy(idx,&vIndex[i*3],sizeof(int)*3); Face f; f.nverts = 3; f.verts = idx; put_element_ply (ply, (void *)&f);// &flist[i]); } close_ply (ply); free_ply (ply); fclose(pFile); }
write_file() { int i; PlyFile *ply; char **elist; int num_elem_types; /*** Write out the transformed PLY object ***/ elist = get_element_list_ply (in_ply, &num_elem_types); ply = write_ply (stdout, num_elem_types, elist, in_ply->file_type); /* describe what properties go into the vertex elements */ describe_element_ply (ply, "vertex", nverts); describe_property_ply (ply, &vert_props[0]); describe_property_ply (ply, &vert_props[1]); describe_property_ply (ply, &vert_props[2]); describe_other_properties_ply (ply, vert_other, offsetof(Vertex,other_props)); describe_other_elements_ply (ply, in_ply->other_elems); copy_comments_ply (ply, in_ply); append_comment_ply (ply, "modified by xformply"); copy_obj_info_ply (ply, in_ply); header_complete_ply (ply); /* set up and write the vertex elements */ put_element_setup_ply (ply, "vertex"); for (i = 0; i < nverts; i++) put_element_ply (ply, (void *) vlist[i]); put_other_elements_ply (ply); close_ply (ply); free_ply (ply); }
write_file() { int i; PlyFile *ply; int num_elem_types; /*** Write out the transformed PLY object ***/ ply = write_ply (stdout, nelems, elem_names, PLY_ASCII); /* describe what properties go into the vertex elements */ describe_element_ply (ply, "vertex", nverts); describe_property_ply (ply, &vert_props[0]); describe_property_ply (ply, &vert_props[1]); describe_property_ply (ply, &vert_props[2]); describe_element_ply (ply, "face", nfaces); describe_property_ply (ply, &face_props[0]); append_comment_ply (ply, "created by platoply"); header_complete_ply (ply); /* set up and write the vertex elements */ put_element_setup_ply (ply, "vertex"); for (i = 0; i < nverts; i++) put_element_ply (ply, (void *) &vlist[i]); /* set up and write the face elements */ put_element_setup_ply (ply, "face"); for (i = 0; i < nfaces; i++) put_element_ply (ply, (void *) &flist[i]); close_ply (ply); free_ply (ply); }
void write_file ( void ) /******************************************************************************/ /* Purpose: WRITE_FILE writes the PLY file to the standard output unit. Modified: 17 January 2011 Author: Greg Turk */ { int i; int num_elem_types; PlyFile *ply; /* Write out the transformed PLY object. */ ply = write_ply (stdout, nelems, elem_names, PLY_ASCII); /* Describe what properties go into the vertex elements. */ describe_element_ply (ply, "vertex", nverts); describe_property_ply (ply, &vert_props[0]); describe_property_ply (ply, &vert_props[1]); describe_property_ply (ply, &vert_props[2]); if ( has_normals ) { describe_property_ply (ply, &vert_props[3]); describe_property_ply (ply, &vert_props[4]); describe_property_ply (ply, &vert_props[5]); } if (texture_coords) { describe_property_ply (ply, &vert_props[6]); describe_property_ply (ply, &vert_props[7]); } describe_element_ply (ply, "face", nfaces); describe_property_ply (ply, &face_props[0]); /* Insert the comments. */ for (i = 0; i < ncomments; i++) { append_comment_ply (ply, comments[i]); } append_comment_ply (ply, "converted from OBJ by obj2ply"); header_complete_ply (ply); /* Set up and write the vertex elements. */ put_element_setup_ply (ply, "vertex"); for (i = 0; i < nverts; i++) { put_element_ply (ply, (void *) &vlist[i]); } /* Set up and write the face elements. */ put_element_setup_ply (ply, "face"); for (i = 0; i < nfaces; i++) { put_element_ply (ply, (void *) &flist[i]); } close_ply ( ply ); free_ply ( ply ); return; }
write_file() { int i; PlyFile *ply; char **elist; int num_elem_types; /*** Write out the transformed PLY object ***/ elist = get_element_list_ply (in_ply, &num_elem_types); ply = write_ply (stdout, num_elem_types, elist, in_ply->file_type); /* describe what properties go into the vertex elements */ /* (position x,y,z and normals nx,ny,nz if they were provided) */ describe_element_ply (ply, "vertex", nverts); describe_property_ply (ply, &vert_props[0]); describe_property_ply (ply, &vert_props[1]); describe_property_ply (ply, &vert_props[2]); if (has_nx) describe_property_ply (ply, &vert_props[3]); if (has_ny) describe_property_ply (ply, &vert_props[4]); if (has_nz) describe_property_ply (ply, &vert_props[5]); /* all other vertex properties besides position and normal */ describe_other_properties_ply (ply, vert_other, offsetof(Vertex,other_props)); /* describe face properties (just list of vertex indices) */ describe_element_ply (ply, "face", nfaces); describe_property_ply (ply, &face_props[0]); describe_other_properties_ply (ply, face_other, offsetof(Face,other_props)); /* all other properties that we tucked away are mentioned here */ describe_other_elements_ply (ply, in_ply->other_elems); /* copy the comments and other textual object information */ copy_comments_ply (ply, in_ply); append_comment_ply (ply, "modified by flipply"); copy_obj_info_ply (ply, in_ply); /* we've told the routines enough information so that the file header */ /* can be written out now */ header_complete_ply (ply); /* set up and write the vertex elements */ put_element_setup_ply (ply, "vertex"); for (i = 0; i < nverts; i++) put_element_ply (ply, (void *) vlist[i]); /* set up and write the face elements */ put_element_setup_ply (ply, "face"); for (i = 0; i < nfaces; i++) put_element_ply (ply, (void *) flist[i]); /* the other properties that we tucked away are written out here */ put_other_elements_ply (ply); /* close the file and free up the memory */ close_ply (ply); free_ply (ply); }