00001
00002 #include <iostream>
00003
00004 #include "newTools.h"
00005 #include "commonDef.h"
00006 #include "pdbstruct.h"
00007
00008 int giveNumberOfOA(const std::string & atom) {
00009 int number = 0 , pos = 0 ;
00010 const std::string heavyAtoms1("C,F,I,O,P,N,S,") , atomH("H");
00011 const std::string heavyAtoms2("Al,Be,Bi,Br,Cd,In,Mg,Pb,Hg,Sb,Si,Sn,Cl,Te,Tl,Zn,Ga,Ge,As,Se,") ;
00012 if( atom[0] >= '1' && atom[0] <= '9' )
00013 {pos++;}
00014 if( atom[pos] == atomH[0]){
00015 number = 1 ;}
00016 else{
00017 number = 4 ;
00018 }
00019
00020
00021 return number ;
00022 }
00023 bool skipString(std::ifstream &data, const std::string &keyword) {
00024
00025 std::string line, key ;
00026 bool isFind = false ;
00027
00028 while ( !data.eof() ){
00029 std::stringstream sline ;
00030 std::getline(data,line) ;
00031 sline << line ;
00032 sline >> key ;
00033 if( keyword == key)
00034 { isFind = true ; break; }
00035 }
00036
00037 return isFind;
00038 }
00039
00040 void sortInFirstDimension(setOfAtoms& atoms, std::vector<int>& oldNum) {
00041
00042
00043
00044
00045
00046
00047 int i, j;
00048 int temp1;
00049 double temp3;
00050
00051 for(i = 1 ; i < atoms.numberOfAtoms() ; ++i) {
00052 temp3 = atoms.getElement(i)._xyz[0] ;
00053 for(j = 0 ; j < i ; ++j) {
00054
00055 if (temp3 < (atoms.getElement(j))._xyz[0] ){
00056 atoms.swap(i,j) ;
00057 temp1 = oldNum[j];
00058 oldNum[j] = oldNum[i];
00059 oldNum[i] = temp1;
00060 }
00061
00062 }
00063 }
00064
00065
00066
00067 std::vector<int> inverseNewNum(oldNum.size());
00068 for(i = 0 ; i < static_cast<int>(oldNum.size()) ; ++i) {
00069 inverseNewNum[oldNum[i]] = i ;
00070 }
00071
00072
00073
00074
00075
00076
00077 for(i = 0 ; i < static_cast<int>(oldNum.size()) ; ++i) {
00078 std::cout << i << " "<< (atoms.getElement(i))._num << " "
00079 << oldNum[i]<< " " << inverseNewNum[i] <<std::endl ;
00080 }
00081
00082 atoms.fixConnectivity(inverseNewNum) ;
00083 }
00084 void readPartitionAndSetColor(std::ifstream& part ,
00085 std::vector<std::string>& color){
00086
00087 std::vector<std::string> colorRef(10) ;
00088 std::string sharedZoneColor("gray") ;
00089
00090 colorRef[0] = "red" ;
00091 colorRef[1] = "blue" ;
00092 colorRef[2] = "green" ;
00093 colorRef[3] = "yellow" ;
00094 colorRef[4] = "gold" ;
00095 colorRef[5] = "purple" ;
00096 colorRef[6] = "orchid" ;
00097 colorRef[7] = "pink" ;
00098 colorRef[8] = "khaki" ;
00099 colorRef[9] = "white" ;
00100
00101
00102 part.clear() ;
00103 part.seekg(0,std::ios::beg) ;
00104
00105 std::string line ;
00106 int _nbOfbSubDomains=0 , _nbAtoms =0;
00107
00108 skipString(part,"NUMBER") ;
00109 part >> _nbOfbSubDomains ;
00110 skipString(part,"NUMBER") ;
00111 part >> _nbAtoms ;
00112 std::cout << "NUMBER OF SUBDOMAINS : " << _nbOfbSubDomains << std::endl
00113 << "NUMBER OF ATOMS : " << _nbAtoms << " " << std::endl;
00114 if(static_cast<int>(color.size()) != _nbAtoms )
00115 { exit(1) ;}
00116 skipString(part,"PARTITION") ;
00117 skipString(part,"PARTITION") ;
00118 int numAt, nbSD, numSD,zoneIJ, localOrder;
00119 std::ofstream out ;
00120 out.open("colorAtoms.tmp");
00121 bool debug ;
00122 for ( int i = 0 ; i < _nbAtoms ; ++i) {
00123 debug = false ;
00124 part >> numAt >> nbSD ;
00125 for(int j = 0 ; j < nbSD ; ++j) {
00126 part >> numSD >> zoneIJ >> localOrder ;
00127 if( zoneIJ == Overlap_Zone ){
00128 color[i] = sharedZoneColor ; std::getline(part,line);
00129 debug = true ;
00130 break ;
00131 }
00132 else if ( zoneIJ == Core_Zone ){
00133 debug = true ;
00134 color[i] = colorRef[numSD] ;
00135
00136
00137 }
00138 }
00139 if ( ! debug){
00140 std::cout << "BUG COLOR is not affected " << i << " "<< numSD << " "<< zoneIJ <<" "<< localOrder <<std::endl;
00141 }
00142 out << i <<" -"<< color[i]<<"-"<< std::endl ;
00143 }
00144 out.close();
00145 }