|
28 | 28 |
|
29 | 29 | #include "ObjCryst/Quirks/VFNStreamFormat.h" |
30 | 30 | #include "ObjCryst/ObjCryst/Molecule.h" |
| 31 | +#include "ObjCryst/ObjCryst/ZScatterer.h" |
31 | 32 | #include "ObjCryst/RefinableObj/GlobalOptimObj.h" |
32 | 33 |
|
33 | 34 | #ifdef OBJCRYST_GL |
@@ -3792,9 +3793,9 @@ void Molecule::GLInitDisplayList(const bool onlyIndependentAtoms, |
3792 | 3793 | } |
3793 | 3794 | } |
3794 | 3795 | const float f=(mvpBond[k]->GetAtom1().GetOccupancy()+mvpBond[k]->GetAtom2().GetOccupancy())/2*this->GetOccupancy(); |
3795 | | - const GLfloat colour_bondnonfree[]= { 0.2*fout, .2*fout, .2*fout, f*fout }; |
3796 | | - const GLfloat colour_bondrigid[]= { 0.5*fout, .3*fout, .3*fout, f*fout }; |
3797 | | - const GLfloat colour_bondfree[]= { 0.8*fout, .8*fout, .8*fout, f*fout }; |
| 3796 | + const GLfloat colour_bondnonfree[]= { 0.2f*fout, .2f*fout, .2f*fout, f*fout }; |
| 3797 | + const GLfloat colour_bondrigid[]= { 0.5f*fout, .3f*fout, .3f*fout, f*fout }; |
| 3798 | + const GLfloat colour_bondfree[]= { 0.8f*fout, .8f*fout, .8f*fout, f*fout }; |
3798 | 3799 | if(isRigidGroup) |
3799 | 3800 | glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE,colour_bondrigid); |
3800 | 3801 | else |
@@ -7904,4 +7905,147 @@ WXCrystObjBasic* Molecule::WXCreate(wxWindow* parent) |
7904 | 7905 | } |
7905 | 7906 | #endif |
7906 | 7907 |
|
| 7908 | + |
| 7909 | +Molecule *ZScatterer2Molecule(ZScatterer *scatt) |
| 7910 | +{ |
| 7911 | + VFN_DEBUG_ENTRY("ZScatterer2Molecule()",6) |
| 7912 | + Molecule *mol=new Molecule(scatt->GetCrystal(),scatt->GetName()); |
| 7913 | + const unsigned long nb=scatt->GetZAtomRegistry().GetNb(); |
| 7914 | + REAL x0=0,y0=0,z0=0; |
| 7915 | + for(unsigned int i=0;i<nb;++i) |
| 7916 | + { |
| 7917 | + const REAL x=scatt->GetZAtomX(i); |
| 7918 | + const REAL y=scatt->GetZAtomY(i); |
| 7919 | + const REAL z=scatt->GetZAtomZ(i); |
| 7920 | + x0+=x; |
| 7921 | + y0+=y; |
| 7922 | + z0+=z; |
| 7923 | + mol->AddAtom(x,y,z,scatt->GetZAtomRegistry().GetObj(i).GetScatteringPower(), |
| 7924 | + scatt->GetZAtomRegistry().GetObj(i).GetName()); |
| 7925 | + |
| 7926 | + #if 0 |
| 7927 | + if(i>0) |
| 7928 | + { |
| 7929 | + const RefinablePar* pLength=&(scatt->GetPar(&(scatt->GetZAtomRegistry() |
| 7930 | + .GetObj(i).GetZBondLength()))); |
| 7931 | + if(pLength->IsFixed()) |
| 7932 | + mol->AddBond(mol->GetAtom(i),mol->GetAtom(scatt->GetZBondAtom(i)), |
| 7933 | + pLength->GetValue(),.01,.02,false); |
| 7934 | + else |
| 7935 | + if(pLength->IsLimited()) |
| 7936 | + mol->AddBond(mol->GetAtom(i),mol->GetAtom(scatt->GetZBondAtom(i)), |
| 7937 | + (pLength->GetMin()+pLength->GetMax())/2.,.01,.02,false); |
| 7938 | + } |
| 7939 | + if(i>1) |
| 7940 | + { |
| 7941 | + const RefinablePar* pAngle=&(scatt->GetPar(&(scatt->GetZAtomRegistry() |
| 7942 | + .GetObj(i).GetZAngle()))); |
| 7943 | + if(pAngle->IsFixed()) |
| 7944 | + mol->AddBondAngle(mol->GetAtom(i),mol->GetAtom(scatt->GetZBondAtom(i)), |
| 7945 | + mol->GetAtom(scatt->GetZAngleAtom(i)), |
| 7946 | + pAngle->GetValue(),.01,.02,false); |
| 7947 | + else |
| 7948 | + if(pAngle->IsLimited()) |
| 7949 | + mol->AddBondAngle(mol->GetAtom(i),mol->GetAtom(scatt->GetZBondAtom(i)), |
| 7950 | + mol->GetAtom(scatt->GetZAngleAtom(i)), |
| 7951 | + (pAngle->GetMin()+pAngle->GetMax())/2.,.01,.02,false); |
| 7952 | + } |
| 7953 | + if(i>2) |
| 7954 | + { |
| 7955 | + const RefinablePar* pDihed=&(scatt->GetPar(&(scatt->GetZAtomRegistry() |
| 7956 | + .GetObj(i).GetZDihedralAngle()))); |
| 7957 | + MolAtom *p1=&(mol->GetAtom(i)); |
| 7958 | + MolAtom *p2=&(mol->GetAtom(scatt->GetZBondAtom(i))); |
| 7959 | + MolAtom *p3=&(mol->GetAtom(scatt->GetZAngleAtom(i))); |
| 7960 | + MolAtom *p4=&(mol->GetAtom(scatt->GetZDihedralAngleAtom(i))); |
| 7961 | + if( (fabs(GetBondAngle(*p1,*p2,*p3)-M_PI)>0.3) |
| 7962 | + &&(fabs(GetBondAngle(*p1,*p2,*p4)-M_PI)>0.3) |
| 7963 | + &&(fabs(GetBondAngle(*p1,*p3,*p4)-M_PI)>0.3) |
| 7964 | + &&(fabs(GetBondAngle(*p2,*p3,*p4)-M_PI)>0.3)) |
| 7965 | + { |
| 7966 | + if(pDihed->IsFixed()) |
| 7967 | + mol->AddDihedralAngle(*p1,*p2,*p3,*p4,pDihed->GetValue(),.01,.02,false); |
| 7968 | + else |
| 7969 | + if(((pDihed->GetMax()-pDihed->GetMax())<0.3)&&(i>2)&&(pDihed->IsLimited())) |
| 7970 | + mol->AddDihedralAngle(*p1,*p2,*p3,*p4, |
| 7971 | + (pDihed->GetMin()+pDihed->GetMax())/2.,.01,.02,false); |
| 7972 | + } |
| 7973 | + } |
| 7974 | + #endif |
| 7975 | + mol->GetAtom(i).SetOccupancy(scatt->GetZAtomRegistry().GetObj(i).GetOccupancy()); |
| 7976 | + } |
| 7977 | + |
| 7978 | + CrystVector_REAL x(nb),y(nb),z(nb),radius(nb); |
| 7979 | + vector<pair<const ScatteringPowerAtom *,long> > scattpow(nb); |
| 7980 | + for(unsigned int i=0;i<nb;++i) |
| 7981 | + { |
| 7982 | + x(i)=mol->GetAtom(i).GetX(); |
| 7983 | + y(i)=mol->GetAtom(i).GetY(); |
| 7984 | + z(i)=mol->GetAtom(i).GetZ(); |
| 7985 | + if(mol->GetAtom(i).IsDummy()) |
| 7986 | + { |
| 7987 | + radius(i)=-1; |
| 7988 | + scattpow[i].first=0; |
| 7989 | + } |
| 7990 | + else |
| 7991 | + { |
| 7992 | + radius(i)=mol->GetAtom(i).GetScatteringPower().GetRadius(); |
| 7993 | + scattpow[i].first=dynamic_cast<const ScatteringPowerAtom *> |
| 7994 | + (&(mol->GetAtom(i).GetScatteringPower())); |
| 7995 | + scattpow[i].second=scattpow[i].first->GetAtomicNumber(); |
| 7996 | + } |
| 7997 | + } |
| 7998 | + for(unsigned int i=0;i<nb;++i) |
| 7999 | + { |
| 8000 | + if(scattpow[i].first==0) continue; |
| 8001 | + const REAL x1=x(i),y1=y(i),z1=z(i); |
| 8002 | + x += -x1; |
| 8003 | + y += -y1; |
| 8004 | + z += -z1; |
| 8005 | + for(unsigned int j=i+1;j<nb;++j) |
| 8006 | + { |
| 8007 | + if(scattpow[j].first==0) continue; |
| 8008 | + const REAL dist=sqrt(x(j)*x(j)+y(j)*y(j)+z(j)*z(j)); |
| 8009 | + //cout<<" -> d="<<dist<<"("<<radius(i)<<","<<radius(j)<<"):"<<scattpow[i].second<<","<<scattpow[j].second<<endl; |
| 8010 | + if(dist<(1.10*(radius(i)+radius(j)))) |
| 8011 | + { |
| 8012 | + if((1!=scattpow[i].second)||(1!=scattpow[j].second)) |
| 8013 | + { |
| 8014 | + mol->AddBond(mol->GetAtom(i),mol->GetAtom(j),dist,.01,.02,false); |
| 8015 | + } |
| 8016 | + } |
| 8017 | + } |
| 8018 | + x += x1; |
| 8019 | + y += y1; |
| 8020 | + z += z1; |
| 8021 | + } |
| 8022 | + mol->BuildConnectivityTable(); |
| 8023 | + for(map<MolAtom*,set<MolAtom*> >::const_iterator pos=mol->GetConnectivityTable().begin(); |
| 8024 | + pos!=mol->GetConnectivityTable().end();++pos) |
| 8025 | + { |
| 8026 | + for(set<MolAtom*>::const_iterator pos1=pos->second.begin(); |
| 8027 | + pos1!=pos->second.end();++pos1) |
| 8028 | + { |
| 8029 | + for(set<MolAtom*>::const_iterator pos2=pos1; |
| 8030 | + pos2!=pos->second.end();++pos2) |
| 8031 | + { |
| 8032 | + if(pos2==pos1) continue; |
| 8033 | + if(mol->FindBondAngle(**pos1,*(pos->first),**pos2)== mol->GetBondAngleList().end()) |
| 8034 | + mol->AddBondAngle(**pos1,*(pos->first),**pos2, |
| 8035 | + GetBondAngle(**pos1,*(pos->first),**pos2),0.01,0.02,false); |
| 8036 | + } |
| 8037 | + } |
| 8038 | + } |
| 8039 | + x0 /= nb; |
| 8040 | + y0 /= nb; |
| 8041 | + z0 /= nb; |
| 8042 | + mol->GetCrystal().OrthonormalToFractionalCoords(x0,y0,z0); |
| 8043 | + mol->SetX(x0); |
| 8044 | + mol->SetY(y0); |
| 8045 | + mol->SetZ(z0); |
| 8046 | + mol->UpdateDisplay(); |
| 8047 | + VFN_DEBUG_EXIT("ZScatterer2Molecule()",6) |
| 8048 | + return mol; |
| 8049 | +} |
| 8050 | + |
7907 | 8051 | }//namespace |
0 commit comments