当前位置: 首页>>代码示例>>C++>>正文


C++ OBConversion::ReadFile方法代码示例

本文整理汇总了C++中OBConversion::ReadFile方法的典型用法代码示例。如果您正苦于以下问题:C++ OBConversion::ReadFile方法的具体用法?C++ OBConversion::ReadFile怎么用?C++ OBConversion::ReadFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OBConversion的用法示例。


在下文中一共展示了OBConversion::ReadFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: testPdbOccupancies

void testPdbOccupancies()
{
  // See https://github.com/openbabel/openbabel/pull/1558
  OBConversion conv;
  OBMol mol;
  conv.SetInFormat("cif");
  conv.SetOutFormat("pdb");
  conv.ReadFile(&mol, GetFilename("test08.cif"));

  string pdb = conv.WriteString(&mol);
  conv.AddOption("o", OBConversion::OUTOPTIONS);
  pdb = conv.WriteString(&mol);

  OB_ASSERT(pdb.find("HETATM    1 NA   UNL     1       0.325   0.000   4.425  0.36") != string::npos);
  OB_ASSERT(pdb.find("HETATM   17  O   UNL     8       1.954   8.956   3.035  1.00") != string::npos);

  OBMol mol_pdb;
  conv.SetInFormat("pdb");
  conv.ReadFile(&mol_pdb, GetFilename("test09.pdb"));

  pdb = conv.WriteString(&mol_pdb);
  OB_ASSERT(pdb.find("HETATM    1 NA   UNL     1       0.325   0.000   4.425  0.36") != string::npos);
  OB_ASSERT(pdb.find("HETATM    2 NA   UNL     1       0.002   8.956   1.393  0.10") != string::npos);
  OB_ASSERT(pdb.find("HETATM   17  O   UNL     8       1.954   8.956   3.035  1.00") != string::npos);
}
开发者ID:fredrikw,项目名称:openbabel,代码行数:25,代码来源:cifspacegrouptest.cpp

示例2: MakeQueriesFromMolInFile

bool MakeQueriesFromMolInFile(vector<OBQuery*>& queries, const std::string& filename, int* pnAtoms, bool noH)
{
    OBMol patternMol;
    patternMol.SetIsPatternStructure();
    OBConversion patternConv;
    OBFormat* pFormat;
    //Need to distinguish between filename and SMARTS. Not infallable...
    if( filename.empty() ||
        filename.find('.')==string::npos ||
        !(pFormat = patternConv.FormatFromExt(filename.c_str())) ||
        !patternConv.SetInFormat(pFormat) ||
        !patternConv.ReadFile(&patternMol, filename) ||
        patternMol.NumAtoms()==0)
      return false;

    if(noH)
      patternMol.DeleteHydrogens();

    do
    {
      *pnAtoms = patternMol.NumHvyAtoms();
      queries.push_back(CompileMoleculeQuery(&patternMol));
    }while(patternConv.Read(&patternMol));
    return true;
}
开发者ID:CooperLiu,项目名称:openbabel,代码行数:25,代码来源:opisomorph.cpp

示例3: testSpaceGroupClean

void testSpaceGroupClean()
{
  // See https://github.com/openbabel/openbabel/pull/254
  OBConversion conv;
  OBMol mol;
  conv.SetInFormat("cif");
  conv.SetOutFormat("pdb");
  conv.ReadFile(&mol, GetFilename("test02.cif"));
  OBUnitCell* pUC = (OBUnitCell*)mol.GetData(OBGenericDataType::UnitCell);
  const SpaceGroup* pSG = pUC->GetSpaceGroup();
  SpaceGroup* sg = new SpaceGroup(*pSG);
  pSG = SpaceGroup::Find(sg);
  OB_ASSERT( pSG != NULL );

  // Check also for errors and warnings
  string summary = obErrorLog.GetMessageSummary();
  OB_ASSERT( summary.find("error") == string::npos);
  OB_ASSERT( summary.find("warning") == string::npos);

  OB_ASSERT( pSG->GetId() == 166 );

  string pdb = conv.WriteString(&mol);
  pdb = conv.WriteString(&mol);

  OB_ASSERT(pdb.find("H -3 m") != string::npos);
}
开发者ID:timvdm,项目名称:openbabel,代码行数:26,代码来源:cifspacegrouptest.cpp

示例4: color

void ColoredMol::color()
{
    OBConversion conv;

    std::string ext = boost::filesystem::extension(ligName);
    if(ext.compare(".pdb") == 0)
    {
        conv.SetInFormat("PDB");
    }
    else if(ext.compare(".pdbqt") == 0)
    {
        conv.SetInFormat("PDBQT");
    }
    else
    {
        std::cout << "File extension not supported: " << ligName << '\n';
        std::cout << "Please use .pdb or .pdbqt for ligand\n";
        exit(0);
    }

    conv.ReadFile(&ligMol, ligName);

    ext = boost::filesystem::extension(recName);
    if(ext.compare(".pdb") == 0)
    {
      conv.SetInFormat("PDB");
    }
    else
    {
        std::cout << "File extension not supported: " << recName << '\n';
        std::cout << "Please use .pdb for receptor\n";
        exit(0);
    }

    conv.ReadFile(&recMol, recName);

    addHydrogens();
    ligCenter();

    removeResidues();
    removeEachAtom();
}
开发者ID:earlhoch,项目名称:visual-scoring-cpp,代码行数:42,代码来源:visualize.cpp

示例5: testCIFMolecules

void testCIFMolecules()
{
  // See https://github.com/openbabel/openbabel/pull/1558
  OBConversion conv;
  OBMol mol;
  conv.SetInFormat("cif");
  conv.SetOutFormat("smi"); // check for disconnected fragments
  conv.ReadFile(&mol, GetFilename("1519159.cif"));

  string smi = conv.WriteString(&mol);
  // never, never disconnected fragments from a molecule
  OB_ASSERT(smi.find(".") == string::npos);
}
开发者ID:fredrikw,项目名称:openbabel,代码行数:13,代码来源:cifspacegrouptest.cpp

示例6: testPdbRemSpacesHMName

void testPdbRemSpacesHMName()
{
  // See https://github.com/openbabel/openbabel/pull/1558
  OBConversion conv;
  OBMol mol;
  conv.SetInFormat("cif");
  conv.SetOutFormat("pdb");
  conv.ReadFile(&mol, GetFilename("test07.cif"));

  string pdb = conv.WriteString(&mol);
  conv.AddOption("o", OBConversion::OUTOPTIONS);
  pdb = conv.WriteString(&mol);

  OB_ASSERT(pdb.find("I41/amd:2") != string::npos);
}
开发者ID:timvdm,项目名称:openbabel,代码行数:15,代码来源:cifspacegrouptest.cpp

示例7: testPdbOutHexagonalAlternativeOrigin2

void testPdbOutHexagonalAlternativeOrigin2()
{
  // See https://github.com/openbabel/openbabel/pull/1558
  OBConversion conv;
  OBMol mol;
  conv.SetInFormat("cif");
  conv.SetOutFormat("pdb");
  conv.ReadFile(&mol, GetFilename("test06.cif"));

  string pdb = conv.WriteString(&mol);
  conv.AddOption("o", OBConversion::OUTOPTIONS);
  pdb = conv.WriteString(&mol);

  OB_ASSERT(pdb.find("H -3 m") != string::npos);
}
开发者ID:timvdm,项目名称:openbabel,代码行数:15,代码来源:cifspacegrouptest.cpp

示例8: testAlternativeOrigin

void testAlternativeOrigin()
{
  // See https://github.com/openbabel/openbabel/pull/1558
  OBConversion conv;
  OBMol mol;
  conv.SetInFormat("cif");
  conv.ReadFile(&mol, GetFilename("test04.cif"));
  OBUnitCell* pUC = (OBUnitCell*)mol.GetData(OBGenericDataType::UnitCell);
  const SpaceGroup* pSG = pUC->GetSpaceGroup();
  SpaceGroup* sg = new SpaceGroup(*pSG);
  pSG = SpaceGroup::Find(sg);

  string summary = obErrorLog.GetMessageSummary();
  OB_ASSERT( summary.find("warning") == string::npos);
  OB_ASSERT( pSG != NULL );
  OB_ASSERT( pSG->GetOriginAlternative() == 1);
}
开发者ID:timvdm,项目名称:openbabel,代码行数:17,代码来源:cifspacegrouptest.cpp

示例9: testPdbOutAlternativeOrigin

void testPdbOutAlternativeOrigin()
{
  // See https://github.com/openbabel/openbabel/pull/1558
  OBConversion conv;
  OBMol mol;
  conv.SetInFormat("cif");
  conv.SetOutFormat("pdb");
  conv.ReadFile(&mol, GetFilename("test04.cif"));

  string pdb = conv.WriteString(&mol);
  // ending space is needed to check that there is no origin set
  OB_ASSERT(pdb.find("P 4/n b m ") != string::npos);

  conv.AddOption("o", OBConversion::OUTOPTIONS);
  pdb = conv.WriteString(&mol);

  OB_ASSERT(pdb.find("P 4/n b m:1") != string::npos);
}
开发者ID:timvdm,项目名称:openbabel,代码行数:18,代码来源:cifspacegrouptest.cpp

示例10: testDecayToP1

void testDecayToP1()
{
  // See https://github.com/openbabel/openbabel/pull/261
  OBConversion conv;
  OBMol mol;
  conv.SetInFormat("cif");
  conv.ReadFile(&mol, GetFilename("test03.cif"));
  OBUnitCell* pUC = (OBUnitCell*)mol.GetData(OBGenericDataType::UnitCell);
  const SpaceGroup* pSG = pUC->GetSpaceGroup();
  SpaceGroup* sg = new SpaceGroup(*pSG);
  pSG = SpaceGroup::Find(sg);
  OB_ASSERT( pSG != NULL );

  // Check also for errors and warnings
  string summary = obErrorLog.GetMessageSummary();
  OB_ASSERT( summary.find("2 warnings") != string::npos);

  OB_ASSERT( pSG->GetId() == 1 );
}
开发者ID:timvdm,项目名称:openbabel,代码行数:19,代码来源:cifspacegrouptest.cpp

示例11: main

int main(int argc, char *argv[])
{
    string prog_name(argv[0]);
    string root;
    string::size_type i = prog_name.find_last_of("/\\");
    if(i == string::npos)
	root = "./";
    else
	root = prog_name.substr(0,i+1);

    if(argc<3 || argc>7) {
	cerr << endl << "  OBJ  : to find maximum common subgraph between mol1 and mol2" << endl
	    << endl << "  Usage: " << argv[0] << "[options] mol1 mol2" << endl
            << "  [options]" << endl
            << "  --rmax n: stop recursion after 'n' steps" << endl
            << "    (default: do not stop)" << endl
            << "  --atom file: where atom types are defined" << endl
            << "    (default: " << root << "atom_type.txt)" << endl << endl
            << "  Attention: for molecules with lots of atoms, it could be very time-consuming!" << endl
            << "             In that case, you can use './mcs' to get a quasi-MCS instead!" << endl << endl;
        exit(EXIT_FAILURE);
    }

    int rmax = 0;
    atom_type_file = root + "atom_type.txt";
    int ii;
    for(ii=1; ii<argc; ) {
        if(strncmp(argv[ii],"--",2) != 0)
            break;
        if(strcmp(argv[ii],"--rmax") == 0)
            rmax = atoi(argv[ii+1]);
        else if(strcmp(argv[ii],"--atom") == 0)
            atom_type_file = argv[ii+1];
        else {
            cerr << "Error: invalid option <" << argv[ii] << ">" << endl;
            exit(EXIT_FAILURE);
        }
        ii += 2;
    }
    if(argc-ii != 2) {
        cerr << "Error: invalid number of arguments, need 2 molecule files" << endl;
        exit(EXIT_FAILURE);
    }
    string name1(argv[ii]);
    string name2(argv[ii+1]);
    string format1 = name1.substr(name1.rfind(".")+1);
    string format2 = name2.substr(name2.rfind(".")+1);
    OBConversion conv;
    OBMol mol1,mol2;
    if(!conv.SetInFormat(format1.c_str()) || !conv.ReadFile(&mol1,name1)) {
        cerr << "Error: failed to read molecule from " << name1 << endl;
        exit(EXIT_FAILURE);
    }
    if(!conv.SetInFormat(format2.c_str()) || !conv.ReadFile(&mol2,name2)) {
        cerr << "Error: failed to read molecule from " << name2 << endl;
        exit(EXIT_FAILURE);
    }
    vector<pair<vector<int>,vector<int> > > graph_indices = mcs(mol1,mol2,rmax);

    for(vector<pair<vector<int>,vector<int> > >::iterator i=graph_indices.begin(); i!=graph_indices.end(); ++i) {
        cout << endl << "atom mapping:" << endl;
	cout << " g1:";
        for(vector<int>::iterator j=(*i).first.begin();j!=(*i).first.end();++j)
	    printf(" %-2d",*j+1);
        cout << endl << " g2:";
	for(vector<int>::iterator j=(*i).second.begin();j!=(*i).second.end();++j)
	    printf(" %-2d",*j+1);
        cout << endl;
    }
    cout << endl << "totally " << graph_indices.size() << " atom mappings for MCS" << endl << endl;

    return 0;
}
开发者ID:Jianlong-Peng,项目名称:mcs,代码行数:73,代码来源:main.bak.cpp

示例12: main


//.........这里部分代码省略.........

	// Enter event loop.
	cout << local_time() << "Entering event loop" << endl;
	bool sleeping = false;
	while (true)
	{
		// Fetch an incompleted job in a first-come-first-served manner.
		if (!sleeping) cout << local_time() << "Fetching an incompleted job" << endl;
		BSONObj info;
		conn.runCommand("istar", BSON("findandmodify" << "usr" << "query" << BSON("done" << BSON("$exists" << false) << "started" << BSON("$exists" << false)) << "sort" << BSON("submitted" << 1) << "update" << BSON("$set" << BSON("started" << Date_t(duration_cast<std::chrono::milliseconds>(system_clock::now().time_since_epoch()).count())))), info); // conn.findAndModify() is available since MongoDB C++ Driver legacy-1.0.0
		const auto value = info["value"];
		if (value.isNull())
		{
			// No incompleted jobs. Sleep for a while.
			if (!sleeping) cout << local_time() << "Sleeping" << endl;
			sleeping = true;
			this_thread::sleep_for(chrono::seconds(10));
			continue;
		}
		sleeping = false;
		const auto job = value.Obj();

		// Obtain job properties.
		const auto _id = job["_id"].OID();
		cout << local_time() << "Executing job " << _id.str() << endl;
		const auto job_path = jobs_path / _id.str();
		const auto format = job["format"].String();
		const auto email = job["email"].String();

		// Parse the user-supplied ligand.
		OBMol obMol;
		OBConversion obConversion;
		obConversion.SetInFormat(format.c_str());
		obConversion.ReadFile(&obMol, (job_path / ("ligand." + format)).string());
		const auto num_atoms = obMol.NumAtoms();
//		obMol.AddHydrogens(); // Adding hydrogens does not seem to affect SMARTS matching.

		// Classify subset atoms.
		array<vector<int>, num_subsets> subsets;
		for (size_t k = 0; k < num_subsets; ++k)
		{
			auto& subset = subsets[k];
			subset.reserve(num_atoms);
			OBSmartsPattern smarts;
			smarts.Init(SubsetSMARTS[k]);
			smarts.Match(obMol);
			for (const auto& map : smarts.GetMapList())
			{
				subset.push_back(map.front());
			}
		}
		const auto& subset0 = subsets.front();

		// Check user-provided ligand validity.
		if (subset0.empty())
		{
			// Record job completion time stamp.
			const auto millis_since_epoch = duration_cast<std::chrono::milliseconds>(system_clock::now().time_since_epoch()).count();
			conn.update(collection, BSON("_id" << _id), BSON("$set" << BSON("done" << Date_t(millis_since_epoch))));

			// Send error notification email.
			cout << local_time() << "Sending an error notification email to " << email << endl;
			MailMessage message;
			message.setSender("usr <[email protected]>");
			message.setSubject("Your usr job has failed");
			message.setContent("Description: " + job["description"].String() + "\nSubmitted: " + to_simple_string(ptime(epoch, boost::posix_time::milliseconds(job["submitted"].Date().millis))) + " UTC\nFailed: " + to_simple_string(ptime(epoch, boost::posix_time::milliseconds(millis_since_epoch))) + " UTC\nReason: failed to parse the provided ligand.");
开发者ID:ZhangJingrong,项目名称:istar,代码行数:67,代码来源:main.cpp

示例13: ObtainTarget

  bool FastSearchFormat::ObtainTarget(OBConversion* pConv, vector<OBMol>& patternMols, const string& indexname)
  {
    //Obtains an OBMol from:
    // the filename in the -s option or
    // the SMARTS string in the -s option or
    // by converting the file in the -S or -aS options (deprecated).
    // If there is no -s -S or -aS option, information on the index file is displayed.

    OBMol patternMol;
    patternMol.SetIsPatternStructure();

    const char* p = pConv->IsOption("s",OBConversion::GENOPTIONS);

    bool OldSOption=false;
    //If no -s option, make OBMol from file in -S option or -aS option (both deprecated)
    if(!p)
    {
      p = pConv->IsOption("S",OBConversion::GENOPTIONS);
      if(!p)
        p = pConv->IsOption("S",OBConversion::INOPTIONS);//for GUI mainly
      OldSOption = true;
    }
    if(p)
    {
      vector<string> vec;
      tokenize(vec, p);

      //ignore leading ~ (not relevant to fastsearch)
      if(vec[0][0]=='~')
        vec[0].erase(0,1);

      if(vec.size()>1 && vec[1]=="exact")
        pConv->AddOption("e", OBConversion::INOPTIONS);

      OBConversion patternConv;
      OBFormat* pFormat;
      //Interpret as a filename if possible
      string& txt =vec [0];
      if( txt.empty() ||
          txt.find('.')==string::npos ||
          !(pFormat = patternConv.FormatFromExt(txt.c_str())) ||
          !patternConv.SetInFormat(pFormat) ||
          !patternConv.ReadFile(&patternMol, txt) ||
          patternMol.NumAtoms()==0)
        //if false, have a valid patternMol from a file
      {
        //is SMARTS/SMILES
        //Replace e.g. [#6] in SMARTS by C so that it can be converted as SMILES
        //for the fingerprint phase, but allow more generality in the SMARTS phase.
        for(;;)
        {
          string::size_type pos1, pos2;
          pos1 = txt.find("[#");
          if(pos1==string::npos)
            break;
          pos2 = txt.find(']');
          int atno;
          if(pos2!=string::npos &&  (atno = atoi(txt.substr(pos1+2, pos2-pos1-2).c_str())) && atno>0)
            txt.replace(pos1, pos2-pos1+1, etab.GetSymbol(atno));
          else
          {
            obErrorLog.ThrowError(__FUNCTION__,"Ill-formed [#n] atom in SMARTS", obError);
            return false;
          }
        }

        bool hasTildeBond;
        if( (hasTildeBond = (txt.find('~')!=string::npos)) ) // extra parens to indicate truth value
        {
          //Find ~ bonds and make versions of query molecule with a single and aromatic bonds
          //To avoid having to parse the SMILES here, replace ~ by $ (quadruple bond)
          //and then replace this in patternMol. Check first that there are no $ already
          //Sadly, isocynanides may have $ bonds.
          if(txt.find('$')!=string::npos)
          {
            obErrorLog.ThrowError(__FUNCTION__,
              "Cannot use ~ bonds in patterns with $ (quadruple) bonds.)", obError);
            return false;
          }
          replace(txt.begin(),txt.end(), '~' , '$');
        }

        //read as standard SMILES
        patternConv.SetInFormat("smi");
        if(!patternConv.ReadString(&patternMol, vec[0]))
        {
          obErrorLog.ThrowError(__FUNCTION__,"Cannot read the SMILES string",obError);
          return false;
        }
        if(hasTildeBond)
        {
          AddPattern(patternMols, patternMol, 0); //recursively add all combinations of tilde bond values
          return true;
        }
      }
      else
      {
        // target(s) are in a file
        patternMols.push_back(patternMol);
        while(patternConv.Read(&patternMol))
//.........这里部分代码省略.........
开发者ID:Acpharis,项目名称:openbabel,代码行数:101,代码来源:fastsearchformat.cpp

示例14: main

int main(int argc,char *argv[])
{
  // turn off slow sync with C-style output (we don't use it anyway).
  std::ios::sync_with_stdio(false);

  if (argc != 1)
    {
      cout << "Usage: conversion" << endl;
      cout << " Unit tests for OBConversion " << endl;
      return(-1);
    }

  cout << "# Unit tests for OBConversion \n";

  // the number of tests for "prove"
  cout << "1..9\n";

  cout << "ok 1\n"; // for loading tests

  OBMol obMol;
  OBConversion obConversion;
  obConversion.SetInAndOutFormats("smi", "mdl");
  cout << "ok 2\n";

  obConversion.ReadString(&obMol, "C1=CC=CS1");
  cout << "ok 3\n";

  if (obMol.NumAtoms() == 5) {
    cout << "ok 4\n";
  } else {
    cout << "not ok 4\n";
  }

  obMol.AddHydrogens();
  if (obMol.NumAtoms() == 9) {
    cout << "ok 5\n";
  } else {
    cout << "not ok 5\n";
  }

  if ( (obConversion.WriteString(&obMol)).length() > 0)
    cout << "ok 6\n";
  else
    cout << "not ok 6\n";

  // PR#1474265
  obConversion.WriteFile(&obMol, "test.mdl");
  ifstream ifs("test.mdl");
  if (ifs.good())
    cout << "ok 7\n";
  else
    cout << "not ok 7\n";

  // PR#143577
  obConversion.SetInFormat("mdl");
  obConversion.ReadFile(&obMol, "test.mdl");
  if ( remove("test.mdl") != -1)
    cout << "ok 8\n";
  else
    cout << "not ok 8\n";
  
  // gzip input
  // gzip output

  // multi-molecule reading
  // PR#1465586
  // aromatics.smi
  // attype.00.smi

  //ReadFile()
  //Read()
  //WriteString()
  // GetOutputIndex()
  // IsLast

  //ReadString()
  //IsFirstInput
  //Read()

  // splitting
  
  // splitting using gzip-input
  // PR#1357705
  
  // size 0 input
  // PR#1250900
  
  // RegisterFormat
  // FindFormat
  // FormatFromExt
  // FormatFromMIME
  // GetNextFormat
  // GetDefaultFormat

  // BatchFileName
  // IncrementedFileName

  // option handling
  // AddOption
  // IsOption
//.........这里部分代码省略.........
开发者ID:baoilleach,项目名称:obstereo-2-2-x,代码行数:101,代码来源:conversion.cpp

示例15: printf

extern "C" int readgrid_(float *vdata, int *nx, int *ny, int *nz,
  float *x0, float *y0, float *z0, float *xx, float *yy, float *zz,
  char *file, int fsize) {

  float dx,dy,dz;
  int gsize;
  float v, vmin, vmax, vavg;
  int navg = 0;

  OBMol mol;
  OBConversion conv;
  conv.SetInFormat("cube");
 
  std::string fname = file;
  int blank = fname.find(" ");
  //printf("%d,'%s'\n", blank, fname.substr(0,blank).c_str());
  conv.ReadFile(&mol, fname.substr(0,blank).c_str());
  //cout << mol.NumAtoms() << " atoms." << endl;
  if (mol.HasData(OBGenericDataType::GridData)) {
    std::vector<OBGenericData*> grids = mol.GetAllData(OBGenericDataType::GridData);
    OBGridData *grid = dynamic_cast<OBGridData *> (grids[0]);
    gsize = grid->GetNumberOfPoints();
    grid->GetNumberOfPoints(*nx, *ny, *nz);
    vector3 origin = grid->GetOriginVector();
    *x0 = origin[0]; *y0 = origin[1]; *z0 = origin[2];
    vector3 maxv = grid->GetMaxVector();
    *xx = maxv[0]; *yy = maxv[1]; *zz = maxv[2];
    dx=(*xx-*x0)/(*nx-1);
    dy=(*yy-*y0)/(*ny-1);
    dz=(*zz-*z0)/(*nz-1);
    printf("%s %d=%d*%d*%d\n", grid->GetAttribute().c_str(), gsize, *nx, *ny, *nz);
    printf("%f %f\n", grid->GetMinValue(), grid->GetMaxValue());
    printf("%f,%f,%f\n", *x0,*y0,*z0);
    printf("%f,%f,%f\n", *xx,*yy,*zz);
    printf("%f,%f,%f\n", dx,dy,dz);
 
    //vdata = (float *)calloc(gsize, sizeof(float));
/* this is for fortran, so reverse sense of slowest/fastest moving dimensions */
    //for (int i=0; i<*nx; ++i) {
    vmin = grid->GetValue(0,0,0);
    vmax = vmin;
    for (int i=0; i<*nz; ++i) {
      for (int j=0; j<*ny; ++j) {
        //for (int k=0; k<*nz; ++k) {
        for (int k=0; k<*nx; ++k) {
          //*vdata++ = grid->GetValue(i,j,k);
          v = grid->GetValue(k,j,i);
          if (v < 1e30 && v > -1e30) {
            if (v < vmin) vmin = v;
            if (v > vmax) vmax = v;
            ++navg;
            vavg += v;
          } else {
            v = vmax * 1000; // just a guess
          }
          *vdata++ = v;
        }
      }
    }
  }
  vavg = vavg/navg;
  printf("min/avg/max = %f/%f/%f\n", vmin, vavg, vmax);
  return 0;
}
开发者ID:tjod,项目名称:gMol,代码行数:64,代码来源:readgrid.cpp


注:本文中的OBConversion::ReadFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。