Пример #1
0
void CBaseModel::ReadFile(const string& filename)
{
	int nDot = (int)filename.rfind('.');
	if (nDot == -1)
	{
		throw "File name doesn't contain a dot!";
	}
	string extension = filename.substr(nDot + 1);

	if (extension == "obj")
	{
		//ReadObjFile(filename);
		FastReadObjFile(filename);
	}
	else if (extension == "off")
	{
		ReadOffFile(filename);
	}
	else if (extension == "m")
	{
		ReadMFile(filename);
	}
	else
	{
		throw "This format can't be handled!";
	}
}
// Initialize Mesh
void Mesh::Init(const char *filename)
{
	int err_code = ReadOffFile(filename);
	if (err_code != 0)
	{
		std::cerr << "Could not parse file " << filename << "\n";
	}
}
BOOL CSampleImportGeomviewPlugIn::ReadFile( const wchar_t* filename, int index, CRhinoDoc& doc, const CRhinoFileReadOptions& options )
{
  // Description:
  //   Rhino calls ReadFile() to create document geometry from an external file.
  // Parameters:
  //   filename [in] The name of file to read.
  //   index [in] The index of file extension added to list in AddToFileType().
  //   doc [in] If importing, then the current Rhino document. Otherwise, an empty Rhino document.
  //   options [in] File read options.
  // Remarks:
  //   The plug-in is responsible for opening the file and writing to it.
  // Return TRUE if successful, otherwise return FALSE.

  // TODO: Add file import code here.
  if( index == 0 )
    return ReadOffFile( filename, doc );

  RhinoApp().Print( L"%s has encountered an unsupported file type index: %d\n", PlugInName(), index );
  return FALSE;
}