27 #include "ObjCryst/ObjCryst/Atom.h"
29 #include "ObjCryst/Quirks/VFNStreamFormat.h"
30 #include "ObjCryst/Quirks/VFNDebug.h"
34 #include <OpenGL/glu.h>
41 #include "ObjCryst/wxCryst/wxAtom.h"
58 :mScattCompList(1),mpScattPowAtom(0)
60 VFN_DEBUG_MESSAGE(
"Atom::Atom()",5)
67 :mScattCompList(1),mpScattPowAtom(pow)
69 VFN_DEBUG_MESSAGE(
"Atom::Atom(x,y,z,name,ScatteringPower):"<<name,5)
70 this->
Init(x,y,z,name,pow,1);
73 Atom::Atom(
const REAL x,
const REAL y,
const REAL z,
const string &name,
75 :mScattCompList(1),mpScattPowAtom(pow)
77 VFN_DEBUG_MESSAGE(
"Atom::Atom(x,y,z,P,B,name,ScatteringPower):"<<name,5)
82 :
Scatterer(old),mScattCompList(1),mpScattPowAtom(old.mpScattPowAtom)
84 VFN_DEBUG_MESSAGE(
"Atom::Atom(&old):/Name="<<old.
mName,5)
97 VFN_DEBUG_MESSAGE(
"Atom::CreateCopy():/Name="<<
mName,10)
98 return new Atom(*
this);
104 VFN_DEBUG_MESSAGE(
"Atom::~Atom():("<<
mName<<
")",5)
110 const static string className=
"Atom";
114 void Atom::operator=(
const Atom &rhs)
116 VFN_DEBUG_MESSAGE(
"Atom::operator=():/Name="<<rhs.
mName,5)
130 void Atom::
Init(const REAL x, const REAL y, const REAL z,
134 VFN_DEBUG_MESSAGE(
"Atom::Init():"<<name,3)
143 VFN_DEBUG_MESSAGE(
"Atom::Init()Dummy Atom:/Name="<<this->
GetName(),5)
153 VFN_DEBUG_MESSAGE(
"Atom::Init():End.",5)
171 VFN_DEBUG_MESSAGE(
"Atom::Print()",1)
174 cout <<
"Atom (DUMMY) :"
197 if(
true==this->
IsDummy())
return 0;
203 if(this->
IsDummy())
return 0.5;
212 const REAL xMin=options.
mXmin;
const REAL xMax=options.mXmax;
213 const REAL yMin=options.mYmin;
const REAL yMax=options.mYmax;
214 const REAL zMin=options.mZmin;
const REAL zMax=options.mZmax;
222 CrystMatrix_REAL xyzCoords ;
224 int nbSymmetrics=xyzCoords.rows();
225 os <<
"// Description of Atom :" << this->
GetName()<< endl;
226 for(
int i=0;i<nbSymmetrics;i++)
231 x0 = fmod((
float) x0,(
float)1);
if(x0<0) x0+=1.;
232 y0 = fmod((
float) y0,(
float)1);
if(y0<0) y0+=1.;
233 z0 = fmod((
float) z0,(
float)1);
if(z0<0) z0+=1.;
235 CrystMatrix_int translate(27,3);
263 for(
int j=0;j<translate.rows();j++)
265 REAL x=x0+translate(j,0);
266 REAL y=y0+translate(j,1);
267 REAL z=z0+translate(j,2);
268 const bool isinside=((x>=xMin) && (x<=xMax)) && ((y>=yMin) && (y<=yMax)) && ((z>=zMin) && (z<=zMax));
270 if(isinside) borderdist=0;
274 if(xMin>x) borderdist+=(xMin-x)*aa*(xMin-x)*aa;
275 if(yMin>y) borderdist+=(yMin-y)*bb*(yMin-y)*bb;
276 if(zMin>z) borderdist+=(zMin-z)*cc*(zMin-z)*cc;
277 if(xMax<x) borderdist+=(xMax-x)*aa*(xMax-x)*aa;
278 if(yMax<y) borderdist+=(yMax-y)*bb*(yMax-y)*bb;
279 if(zMax<z) borderdist+=(zMax-z)*cc*(zMax-z)*cc;
280 borderdist=sqrt(borderdist);
287 os <<
" ObjCrystAtom("
302 void Atom::GLInitDisplayList(
const bool onlyIndependentAtoms,
303 const REAL xMin,
const REAL xMax,
304 const REAL yMin,
const REAL yMax,
305 const REAL zMin,
const REAL zMax,
306 const bool displayEnantiomer,
307 const bool displayNames,
308 const bool hideHydrogens,
309 const REAL fadeDistance,
310 const bool fullMoleculeInLimits)
const
312 VFN_DEBUG_MESSAGE(
"Atom::GLInitDisplayList():"<<this->
GetName(),5)
315 if(displayEnantiomer==true) en=-1;
322 const GLfloat colour0[] = {.0, .0, .0, 0.0};
323 GLfloat colourChar [] = {1.0, 1.0, 1.0, 1.0};
324 if((r>0.8)&&(g>0.8)&&(b>0.8))
335 GLUquadricObj* pQuadric = gluNewQuadric();
336 if(
true==onlyIndependentAtoms)
338 const GLfloat colourAtom [] = {r, g, b, f};
343 x = fmod((REAL)x,(
int)1);
if(x<0) x+=1.;
344 y = fmod((REAL)y,(
int)1);
if(y<0) y+=1.;
345 z = fmod((REAL)z,(
int)1);
if(z<0) z+=1.;
348 glTranslatef(x*en, y, z);
351 glMaterialfv(GL_FRONT, GL_AMBIENT, colour0);
352 glMaterialfv(GL_FRONT, GL_DIFFUSE, colour0);
353 glMaterialfv(GL_FRONT, GL_SPECULAR, colour0);
354 glMaterialfv(GL_FRONT, GL_EMISSION, colourChar);
355 glMaterialfv(GL_FRONT, GL_SHININESS, colour0);
356 glRasterPos3f(0,0,0);
361 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, colourAtom);
362 glMaterialfv(GL_FRONT, GL_SPECULAR, colour0);
363 glMaterialfv(GL_FRONT, GL_EMISSION, colour0);
364 glMaterialfv(GL_FRONT, GL_SHININESS, colour0);
365 glPolygonMode(GL_FRONT, GL_FILL);
366 gluSphere(pQuadric,this->
GetRadius()/3.,20,20);
376 CrystMatrix_REAL xyzCoords ;
378 int nbSymmetrics=xyzCoords.rows();
379 for(
int i=0;i<nbSymmetrics;i++)
384 x0 = fmod((REAL) x0,(
int)1);
if(x0<0) x0+=1.;
385 y0 = fmod((REAL) y0,(
int)1);
if(y0<0) y0+=1.;
386 z0 = fmod((REAL) z0,(
int)1);
if(z0<0) z0+=1.;
388 CrystMatrix_int translate(27,3);
416 for(
int j=0;j<translate.rows();j++)
418 REAL x=x0+translate(j,0);
419 REAL y=y0+translate(j,1);
420 REAL z=z0+translate(j,2);
421 const bool isinside=((x>=xMin) && (x<=xMax)) && ((y>=yMin) && (y<=yMax)) && ((z>=zMin) && (z<=zMax));
423 if(isinside) borderdist=0;
427 if(xMin>x) borderdist+=(xMin-x)*aa*(xMin-x)*aa;
428 if(yMin>y) borderdist+=(yMin-y)*bb*(yMin-y)*bb;
429 if(zMin>z) borderdist+=(zMin-z)*cc*(zMin-z)*cc;
430 if(xMax<x) borderdist+=(xMax-x)*aa*(xMax-x)*aa;
431 if(yMax<y) borderdist+=(yMax-y)*bb*(yMax-y)*bb;
432 if(zMax<z) borderdist+=(zMax-z)*cc*(zMax-z)*cc;
433 borderdist=sqrt(borderdist);
441 if ((fadeDistance == 0) || borderdist>fadeDistance) fout = 0;
446 const GLfloat colourAtom [] = {r, g, b, f*fout};
449 glTranslatef(x*en, y, z);
454 glMaterialfv(GL_FRONT, GL_AMBIENT, colour0);
455 glMaterialfv(GL_FRONT, GL_DIFFUSE, colour0);
456 glMaterialfv(GL_FRONT, GL_SPECULAR, colour0);
457 glMaterialfv(GL_FRONT, GL_EMISSION, colourChar);
458 glMaterialfv(GL_FRONT, GL_SHININESS, colour0);
459 glRasterPos3f(0,0,0);
465 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, colourAtom);
466 glMaterialfv(GL_FRONT, GL_SPECULAR, colour0);
467 glMaterialfv(GL_FRONT, GL_EMISSION, colour0);
468 glMaterialfv(GL_FRONT, GL_SHININESS, colour0);
469 glPolygonMode(GL_FRONT, GL_FILL);
470 gluSphere(pQuadric,this->
GetRadius()/3.,20,20);
477 gluDeleteQuadric(pQuadric);
478 VFN_DEBUG_MESSAGE(
"Atom::GLInitDisplayList():End",5)
500 CrystVector_uint & groupIndex,
501 unsigned int &first)
const
504 unsigned int posIndex=0;
505 VFN_DEBUG_MESSAGE(
"Atom::GetGeneGroup()",4)
507 for(
long j=0;j<this->
GetNbPar();j++)
512 if(posIndex==0) posIndex=first++;
513 groupIndex(i)=posIndex;
515 else groupIndex(i)= first++;
522 VFN_DEBUG_MESSAGE(
"Atom::InitRefParList()",5)
527 REFPAR_DERIV_STEP_ABSOLUTE,
false,
false,
true,
true,1.,1.);
533 REFPAR_DERIV_STEP_ABSOLUTE,
false,
false,
true,
true,1.,1.);
539 REFPAR_DERIV_STEP_ABSOLUTE,
false,
false,
true,
true,1.,1.);
547 gpRefParTypeScattOccup,REFPAR_DERIV_STEP_ABSOLUTE,
true,
true);
558 mpWXCrystObj=
new WXAtom(parent,
this);
The namespace which includes all objects (crystallographic and algorithmic) in ObjCryst++.
The basic atom scatterer, in a crystal.
void SetScatteringPower(const ScatteringPower &pow)
Change the ScatteringPower for this atom.
const ScatteringPower * mpScattPowAtom
The ScatteringPowerAtom associated to that atom.
REAL GetRadius() const
Returns the radius (in Angstroems) of the atom.
bool IsDummy() const
Is this a dummy atom ? (ie no ScatteringPower) Dummy atoms should not exist !
virtual void InitRefParList()
Prepare refinable parameters for the scatterer object.
virtual void Print() const
Print some info about the scatterer (ideally this should be one line...).
virtual const ScatteringComponentList & GetScatteringComponentList() const
Get the list of all scattering components for this scatterer.
REAL GetMass() const
Returns the molar mass of the atom.
virtual int GetNbComponent() const
Number of components in the scatterer (eg number of point scatterers)
ScatteringComponentList mScattCompList
The list of scattering components.
virtual ostream & POVRayDescription(ostream &os, const CrystalPOVRayOptions &options) const
XMLOutput a description of the scatterer for POVRay.
void Init(const REAL x, const REAL y, const REAL z, const string &name, const ScatteringPower *pow, const REAL popu=1)
initialize the atom (used for arrays of atoms).
const ScatteringPower & GetScatteringPower() const
Get the ScatteringPowerAtom corresponding to this atom.
virtual string GetComponentName(const int i) const
Name for the i-th component of this scatterer.
virtual void GetGeneGroup(const RefinableObj &obj, CrystVector_uint &groupIndex, unsigned int &firstGroup) const
Get the gene group assigned to each parameter.
virtual const string & GetClassName() const
Name for this class ("RefinableObj", "Crystal",...).
virtual Atom * CreateCopy() const
Atom()
Default constructor.
REAL GetDynPopCorr(const Scatterer *pscatt, unsigned int component) const
Access the Dynamical Occupancy Correction for a given component (atom) in a given Scatterer.
Class to store POV-Ray output options.
bool mShowHydrogens
Show hydrogens ?
REAL mXmin
Display limits in reduced coordinates.
Generic type of scatterer: can be an atom, or a more complex assembly of atoms.
virtual const float * GetColourRGB() const
Colour associated to this scatterer, 3 RGB Coordinates.
REAL GetOccupancy() const
Get the occupancy of the scatterer (0.
const Crystal & GetCrystal() const
In which crystal is this Scatterer included ?
RefinableObjClock mClockScattCompList
CrystVector_REAL mXYZ
coordinates of the scatterer (or of its center..)
REAL GetX() const
X coordinate (fractionnal) of the scatterer (for complex scatterers, this corresponds to the position...
REAL GetZ() const
Z coordinate (fractionnal) of the scatterer (for complex scatterers, this corresponds to the position...
RefinableObjClock mClockScatterer
Last time anything (number of atoms, positions, scattering power) was changed.
REAL mOccupancy
Occupancy : 0 <= occ <= 1 For a multi-atom scatterer (polyhedron,..), this is the overall occupancy o...
REAL GetY() const
Y coordinate (fractionnal) of the scatterer (for complex scatterers, this corresponds to the position...
Abstract Base Class to describe the scattering power of any Scatterer component in a crystal.
REAL GetBiso() const
Returns the isotropic temperature B factor.
virtual REAL GetForwardScatteringFactor(const RadiationType) const =0
Get the scattering factor at (0,0,0).
virtual REAL GetRadius() const =0
Return the physical radius of this type of scatterer (for 3D display purposes).
virtual const string & GetSymbol() const
Symbol for this Scattering power (the atom name for atoms)
list of scattering positions in a crystal, associated with the corresponding occupancy and a pointer ...
CrystMatrix_REAL GetAllSymmetrics(const REAL x, const REAL y, const REAL z, const bool noCenter=false, const bool noTransl=false, const bool noIdentical=false) const
Get all equivalent positions of a (xyz) position.
CrystVector_REAL GetLatticePar() const
Lattice parameters (a,b,c,alpha,beta,gamma) as a 6-element vector in Angstroems and radians.
const SpaceGroup & GetSpaceGroup() const
Access to the SpaceGroup object.
void FractionalToOrthonormalCoords(REAL &x, REAL &y, REAL &z) const
Get orthonormal cartesian coordinates for a set of (x,y,z) fractional coordinates.
bool IsDescendantFromOrSameAs(const RefParType *type) const
Returns true if the parameter is a descendant of 'type'.
void Click()
Record an event for this clock (generally, the 'time' an object has been modified,...
Generic class for parameters of refinable objects.
void CopyAttributes(const RefinablePar &)
Copy all attributes (limits, flags, etc...) from another RefinablePar object.
void SetGlobalOptimStep(const REAL)
Maximum step to use during Global Optimization algorithms.
void AssignClock(RefinableObjClock &clock)
Generic Refinable Object.
void AddPar(const RefinablePar &newRefPar)
Add a refinable parameter.
virtual void RegisterClient(RefinableObj &) const
Register a new object using this object.
RefinablePar & GetPar(const long i)
Access all parameters in the order they were inputted.
virtual const string & GetName() const
Name of the object.
long GetNbPar() const
Total number of refinable parameter in the object.
void ResetParList()
Re-init the list of refinable parameters, removing all parameters.
virtual void DeRegisterClient(RefinableObj &) const
Deregister an object (which not any more) using this object.
string mName
Name for this RefinableObject. Should be unique, at least in the same scope.+.
output a number as a formatted float:
output a string with a fixed length (adding necessary space or removing excess characters) :
Abstract base class for all objects in wxCryst.