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


C++ Molecule::getAtomPos方法代码示例

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


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

示例1: edge_intersection

bool edge_intersection (const Molecule &mol, int edge1_idx, int edge2_idx, Vec2f &p)
{
   const Edge &edge1 = mol.getEdge(edge1_idx);
   const Edge &edge2 = mol.getEdge(edge2_idx);

   if (edge1.beg == edge2.beg || edge1.beg == edge2.end || edge1.end == edge2.beg || edge1.end == edge2.end)
      return false;

   Vec2f v1_1(mol.getAtomPos(edge1.beg).x, mol.getAtomPos(edge1.beg).y);
   Vec2f v1_2(mol.getAtomPos(edge1.end).x, mol.getAtomPos(edge1.end).y);
   Vec2f v2_1(mol.getAtomPos(edge2.beg).x, mol.getAtomPos(edge2.beg).y);
   Vec2f v2_2(mol.getAtomPos(edge2.end).x, mol.getAtomPos(edge2.end).y);

   return Vec2f::intersection(v1_1, v1_2, v2_1, v2_2, p);
}
开发者ID:cambDI,项目名称:camb,代码行数:15,代码来源:patmake.cpp

示例2: convertMolfile

void convertMolfile (char *path, char *filename, FileOutput &cpp_file)
{
   FileScanner molfile("%s\\%s", path, filename);
   MolfileLoader mf_loader(molfile);
   Molecule mol;
   QS_DEF(Array<int>, edges);

   printf("%s\n", filename);

   mf_loader.loadMolecule(mol, true);

   BiconnectedDecomposer bd(mol); 

   if (bd.decompose() != 1)
   {
      printf("Error: %s is not biconnected\n", filename);
      return;
   }

   int i, j;

   edges.clear_reserve(mol.edgeCount());

   for (i = mol.edgeBegin() ; i < mol.edgeEnd(); i = mol.edgeNext(i))
      edges.push(i);

   edges.qsort(edge_cmp, &mol);

   const Edge &edge = mol.getEdge(edges[edges.size() / 2]);

   Vec3f v1 = mol.getAtomPos(edge.beg);
   Vec3f v2 = mol.getAtomPos(edge.end);

   v1.z = 0.f;
   v2.z = 0.f;

   float scale = Vec3f::dist(v1, v2);

   if (scale < 0.0001f)
   {
      printf("Error: %s has zero bond\n", filename);
      return;
   }

   scale = 1.f / scale;

   int first_idx = mol.vertexBegin();
   Vec3f pos = mol.getAtomPos(first_idx);

   for (i = mol.vertexNext(first_idx); i < mol.vertexEnd(); i = mol.vertexNext(i))
   {
      if (mol.getAtomPos(i).y < pos.y)
      {
         pos = mol.getAtomPos(i);
         first_idx = i;
      }
   }


   for (i = mol.vertexBegin() ; i < mol.vertexEnd(); i = mol.vertexNext(i))
   {
      mol.getAtom2(i).pos.sub(pos);
      mol.getAtom2(i).pos.scale(scale);
   }

   char buf[1024];

   sprintf_s(buf, "BEGIN_PATTERN(\"%s\")", filename);
   cpp_file.writeStringCR(buf);   

   for (i = mol.vertexBegin(); i < mol.vertexEnd(); i = mol.vertexNext(i))
   {
      sprintf_s(buf, "   ADD_ATOM(%d, %ff, %ff)", i, mol.getAtomPos(i).x, mol.getAtomPos(i).y);
      cpp_file.writeStringCR(buf);   
   }

   for (i = mol.edgeBegin(); i < mol.edgeEnd(); i = mol.edgeNext(i))
   {
      const Edge &edge = mol.getEdge(i);
      int type = mol.getBond(i).type;
      int qtype = mol.getQueryBond(i).type;

      sprintf_s(buf, "   ADD_BOND(%d, %d, %d)", edge.beg, edge.end, qtype != 0 ? qtype : type);
      cpp_file.writeStringCR(buf);   
   }

   Vec2f v, inter;
   Vec2f pos_i;
   int idx = mol.vertexCount();

   i = first_idx;

   float max_angle, cur_angle;
   float i_angle = 0;
   int next_nei = 0;
   int point_idx = 0;

   pos_i.set(mol.getAtomPos(i).x, mol.getAtomPos(i).y);

   while (true)
//.........这里部分代码省略.........
开发者ID:cambDI,项目名称:camb,代码行数:101,代码来源:patmake.cpp


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