Пример #1
0
void OBJMeshFileWriter::write(const IMeshWalker& walker)
{
    if (m_file == 0)
    {
        // Open the file for writing.
        m_file = fopen(m_filename.c_str(), "wt");
        if (m_file == 0)
            throw ExceptionIOError();

        // Write the file header.
        fprintf(
            m_file,
            "# File generated by %s.\n",
            Appleseed::get_synthetic_version_string());
    }

    // Write the mesh object name.
    fprintf(m_file, "o %s\n", walker.get_name());

    // Write the mesh data.
    write_vertices(walker);
    write_vertex_normals(walker);
    write_texture_coordinates(walker);
    write_faces(walker);

    // Update base indices.
    m_base_vertex_index += walker.get_vertex_count();
    m_base_vertex_normal_index += walker.get_vertex_normal_count();
    m_base_tex_coords_index += walker.get_tex_coords_count();
}
Пример #2
0
void PLYDataWriter::write ( const char * filename )
{
    assert ( mesh != NULL );
    p_ply oply;
    oply = ply_create( filename, PLY_ASCII, NULL, 0, NULL );

    if ( oply == NULL )
    {
        throw std::runtime_error( "Access to output file was impossible." );
    }
    write_header ( oply );
    write_vertices ( oply );
    write_faces ( oply );
    ply_close ( oply );
}
Пример #3
0
/* write piecewise polynomial molecular surface to output file */
int write_surface (struct surface *srf, FILE *fp_surface)
{
	/* writing */
	write_header (srf, srf -> mol -> name, fp_surface); if (error()) return(0);
	write_varieties (srf, fp_surface); if (error()) return(0);
	write_vertices (srf, fp_surface); if (error()) return(0);
	write_circles (srf, fp_surface); if (error()) return(0);
	write_arcs (srf, fp_surface); if (error()) return(0);
	write_faces (srf, fp_surface); if (error()) return(0);
	write_cycles (srf, fp_surface); if (error()) return(0);
	write_edges (srf, fp_surface); if (error()) return(0);
	write_components (srf, fp_surface); if (error()) return(0);

	fclose (fp_surface);
	return (1);
}
Пример #4
0
int 
main(int argc, char *argv[])
{
   // -s option writes "simple" format, meaning faces are written as:
   //
   //   f 1 3 2
   //
   // instead of:
   //
   //   f 1//1 3//3 2//2

   bool do_simple = false;
   if (argc == 2 && string(argv[1]) == "-s") {
      do_simple = true;
   } else if (argc != 1) {
      err_msg("Usage: %s [ -s ] < input.sm > output.sm", argv[0]);
      return 1;
   }

   BMESHptr mesh = BMESH::read_jot_stream(cin);
   if (!mesh || mesh->empty())
      return 1; // didn't work

   if (Config::get_var_bool("JOT_RECENTER"))
      mesh->recenter();

   if (Config::get_var_bool("JOT_PRINT_MESH"))
      mesh->print();

   // write verts
   write_verts(*mesh, cout);

   // write faces
   write_faces(*mesh, cout, do_simple);

   return 0;
}