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


C++ OBMol::Center方法代码示例

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


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

示例1: main

int main(int argc,char **argv)
{
  char *program_name= argv[0];
  int c;
  char *FileIn = NULL;

  if (argc != 2) {
    cerr << " Usage: " << program_name << " <input file>\n";
    exit(-1);
  }
  else {
      FileIn  = argv[1];
  }

  // Find Input filetype
  OBConversion conv;
  OBFormat *inFormat = conv.FormatFromExt(FileIn);
    
  if (!inFormat || !conv.SetInFormat(inFormat)) {
    cerr << program_name << ": cannot read input format!" << endl;
    exit (-1);
  }

  ifstream ifs;

  // Read the file
  ifs.open(FileIn);
  if (!ifs) {
    cerr << program_name << ": cannot read input file!" << endl;
    exit (-1);
  }

  OBMol mol;
  OBPointGroup pg;

  for (c = 1;; ++c)
    {
      mol.Clear();
      conv.Read(&mol, &ifs);
      if (mol.Empty())
        break;
      
      // not needed by OBPointGroup, but useful for external programs
      mol.Center();
      mol.ToInertialFrame();

      pg.Setup(&mol);
      cout << "Point Group: " << pg.IdentifyPointGroup() << endl;

    } // end for loop
  
  return(1);
}
开发者ID:RitaDo,项目名称:pgchem,代码行数:53,代码来源:obsym.cpp

示例2: main


//.........这里部分代码省略.........
  if (inFileArg == 0 || outFileArg == 0
      || (inFileArg < 0 && !gotInType)
      || (outFileArg < 0 && !gotOutType))
    usage();

  if (!gotInType)
    {
      if (extab.CanReadExtension(argv[inFileArg]))
	inFileType = extab.FilenameToType(argv[inFileArg]);
      else
	{
	  cerr << program_name << ": cannot read input format!" << endl;
	  usage();
	}
    }
  if (!gotOutType)
    {
      if (extab.CanWriteExtension(argv[outFileArg]))
	outFileType = extab.FilenameToType(argv[outFileArg]);
      else
	{
	  cerr << program_name << ": cannot write output format!" << endl;
	  usage();
	}
    }

  // Finally, we can do some work!
  OBMolVector moleculeList;
  ifstream inFileStream;
  bool usingStdin = false;
  bool canRead = true;
  int currentMol = 1;

  // read
  if (inFileArg > 0)
    {
      inFileStream.open(argv[inFileArg]);
      if (!inFileStream)
	{
	  cerr << program_name << ": cannot read input file!" << endl;
	  exit (-1);
	}
    }
  else
    usingStdin = true;

  while (canRead)
    {
      OBMol *mol = new OBMol(inFileType, outFileType);
      if (!usingStdin)
	fileFormat.ReadMolecule(inFileStream, *mol, argv[inFileArg]);
      else
	fileFormat.ReadMolecule(cin, *mol, "STDIN");

      if (mol->NumAtoms() != 0)
	{
	  // Perform any requested transformations
	  if (removeHydrogens)
	    mol->DeleteHydrogens();
	  if (addHydrogens)
	    mol->AddHydrogens(false, usePH);
	  if (centerCoords)
	    mol->Center();
      
	  if (currentMol >= firstMol && currentMol <= lastMol)
	    moleculeList.PushMol(mol);

	  if (!usingStdin && 
	      (inFileStream.peek() == EOF || !inFileStream.good()) )
	    canRead = false;
	  else if (usingStdin && (cin.peek() == EOF || !cin.good()) )
	    canRead = false;
	  else if (currentMol > lastMol)
	    canRead = false;
	}
      else // 0 atoms in this molecule! 
	{
	  //	  cerr << " error: has zero atoms! " << endl;
	  canRead = false;
	}

      currentMol++;
    }
 
  // write
  if (outFileArg > 0)
    {
      ofstream outFileStream(argv[outFileArg]);
      if (!outFileStream)
	{
	  cerr << program_name << ": cannot write to output file!" << endl;
	  exit (-1);
	}
      moleculeList.Write(outFileStream, formatOptions);
    }
  else
    moleculeList.Write(cout, formatOptions);

  return(0);
}
开发者ID:daju1,项目名称:winlibghemical,代码行数:101,代码来源:main.cpp


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