Beispiel #1
0
int _tmain(int argc, _TCHAR* argv[]) //命令行传参调用
{
    TCHAR dir_in[MAX_PATH];           // 打包目录
    TCHAR dir_out[MAX_PATH];          // 输出目录
    TCHAR dir_index[MAX_PATH];        // 索引文件目录
 
    switch (argc)
    {
    case 2:
        // 检查路径是否合法(不允许反斜线结束)
        if (isFolderExist(argv[1]))
        {
            lstrcpynW(dir_in, argv[1], MAX_PATH);
            swprintf_s(dir_out, MAX_PATH, _T("%s.pak"), dir_in);
            swprintf_s(dir_index, MAX_PATH, _T("%s.dat"), dir_in);
        }
        else
        {
            printf_s("无法打开指定的路径\n");
            return 0;
        }
        break;
        
    case 3:
        if (isFolderExist(argv[1]) && isFolderExist(argv[2]))
        {
            lstrcpynW(dir_in, argv[1], MAX_PATH);
            swprintf_s(dir_out, MAX_PATH, _T("%s\\%s.pak"), argv[2], GetFolderName(argv[2]));
            swprintf_s(dir_index, MAX_PATH, _T("%s\\%s.dat"), argv[2], GetFolderName(argv[2]));
        }
        else
        {
            printf_s("无法打开指定的路径\n");
            return 0;
        }
        break;
        
    default:
        printf_s("用法: KEPacker 资源目录 [输出目录]\n注意: 路径不能以反斜线结尾\n");
        return 0;
    }
 
    try
    {
        pack mypack(dir_out, TCHAR dir_index, TCHAR dir_in);
    }
    catch(int)
    {
        printf_s("打包过程中出现错误\n");
    }
    
    getchar();
    return 0;
}
void SecondaryStructureRMSD::performTask( const unsigned& task_index, const unsigned& current, MultiValue& myvals ) const {
  // Retrieve the positions
  std::vector<Vector> pos( references[0]->getNumberOfAtoms() );
  const unsigned n=pos.size();
  for(unsigned i=0;i<n;++i) pos[i]=ActionAtomistic::getPosition( getAtomIndex(current,i) );

  // This does strands cutoff
  Vector distance=pbcDistance( pos[align_atom_1],pos[align_atom_2] ); 
  if( s_cutoff2>0 ){
     if( distance.modulo2()>s_cutoff2 ){
       myvals.setValue( 0, 0.0 );
       return;
     }
  }

  // This aligns the two strands if this is required
  if( alignType!="DRMSD" && align_strands ){
     Vector origin_old, origin_new; origin_old=pos[align_atom_2];
     origin_new=pos[align_atom_1]+distance;
     for(unsigned i=15;i<30;++i){
         pos[i]+=( origin_new - origin_old );
     }
  }
  // Create a holder for the derivatives
  ReferenceValuePack mypack( 0, pos.size(), myvals ); mypack.setValIndex( 1 );
  for(unsigned i=0;i<n;++i) mypack.setAtomIndex( i, getAtomIndex(current,i) );

  // And now calculate the RMSD
  const Pbc& pbc=getPbc(); 
  unsigned closest=0; 
  double r = references[0]->calculate( pos, pbc, mypack, false );
  const unsigned rs = references.size();
  for(unsigned i=1;i<rs;++i){
    mypack.setValIndex( i+1 );
    double nr=references[i]->calculate( pos, pbc, mypack, false );
    if( nr<r ){ closest=i; r=nr; }
  }

  // Transfer everything to the value
  myvals.setValue( 0, 1.0 ); myvals.setValue( 1, r );
  if( closest>0 ) mypack.moveDerivatives( closest+1, 1 );

  if( !mypack.virialWasSet() ){
    Tensor vir;
    const unsigned cacs = colvar_atoms[current].size();
    for(unsigned i=0;i<cacs;++i){
       vir+=(-1.0*Tensor( pos[i], mypack.getAtomDerivative(i) ));
    } 
    mypack.setValIndex(1); mypack.addBoxDerivatives( vir );
  }

  return;
}