XClasses

The library is under construction and some major changes can be made shortly. So use it at your own risk - the old version will not be supported

struct TEllipsoid

{
    TVPoint EX, EY, EZ; // internal orthogonal vectors; Length defines scaling
    int Id;
};

struct TEBond

{
    int IdA, IdB;
};

class TEBonds

{
    TEList *EBonds;
public:
    TEBonds();
    ~TEBonds();
    TVPoint Vector;
    void Clear();
    TEBond * AddEBond();
    int EBondCount();
    TEBond *EBond(int i);
}

class TSObject: public TSreamableObj

// object defines basic behaviour and a structural object
{
protected:
    TNetwork* FNetwork;     // a pointer to parent Network
public:
    TSObject(TNetwork* Parent);
    ~TSObject();
    void Assign(TSObject *S);

    void virtual operator << (class TIniStream *S); // saves the content of the object to a stream
    void virtual operator >> (class TIniStream *S); // loads the content of the object from a stream

    short Type;   // object type: e.g. bond, atom, centroid, etc
    int NetId;      // reference in the network container
    int LatId;       // reference in the lattice container
    short NodId; // reference in the node container
    int Tag;          // for internal iterations use
};

class TBasicBond: public TSObject

{
protected:
    TSAtom *FA, // first atom of the bond
    *FB;               // second atom of the bond
public:
    TBasicBond(TNetwork *P);
    ~TBasicBond();
    TSAtom * A();          // returns a pointer to a the first atom
    void A(TSAtom * a);// assigns the value of the first atom
    TSAtom * B();         // returns a pointer to a the second atom
    void B(TSAtom * b);// assigns the value of the second atom
};

class TBasicNode: public TSObject

{
protected:
    TEList *FNodes; // list of attached nodes
    TEList *FBonds; // list of bonds. for quick referencing etc
public:
    TBasicNode(TNetwork *N);
    ~TBasicNode();

    void Assign(TBasicNode *S);
    void virtual Clear();

    int NodeCount()
    virtual TBasicNode *& Node(int i)
    void virtual AddNode(TBasicNode *N);

    int BondCount()
    virtual TBasicBond * Bond(int i)
    void virtual AddBond(TBasicBond *N);
};

class TNetwork: public TBasicNode

{
protected:
    void Load(TEList *Atoms); // loads one fragment form list of atoms
public:
    TNetwork(TLattice* P, TNetwork *N);
    ~TNetwork();

    TLattice *Lattice;

    void virtual Clear();
    void virtual AddNode(TBasicNode *N);
    void virtual AddBond(TBasicBond *N);

    void Assign(TNetwork *S);
    void FindBonds(TNetwork *Net, TEList *L);
    void Disassemble(TEList *Atoms, TEList *Frags); // disassembles list of atoms to fragments

    void virtual operator << (class TIniStream *S);
    void virtual operator >> (class TIniStream *S);
};

class TCAtom: public TStreamableObj

{
public:
    TCAtom();
    ~TCAtom();

    void Assign(TCAtom *S);
    void GetEllipsoid(TEllipsoid *E);

    void virtual operator << (class TIniStream *S);
    void virtual operator >> (class TIniStream *S);

    int            Id;                                 //  atom's id
    short        Part,                              // PART instruction
                    Afix;                              // AFIX instruction
    float         Occp;                            // occupancy
    TVector   Ellps;                             // six values from INS file
    TVector   EllpsE;                           // errors for the values six values from INS file
    TEVPoint CCenter;                       // atom centre in cell coordinates
    class TBasicAtomInfo* AtomInfo;  // a pointer to TBasisAtomInfo object
    TEString Label;                              // atom's label
};

class TSAtom: public TBasicNode

{
private:
    TEList* Matrices; // a list of matrices used for generation of atom
public:
    TSAtom(TNetwork *N);
    ~TSAtom();
    void Assign(TSAtom *S);
    void Assign(TCAtom *S);

    int MatrixCount();
    TMatrix *Matrix(int i);
    void AddMatrix(TMatrix *M);
    void AddMatrices(TSAtom *A);

    void virtual operator << (class TIniStream *S);
    void virtual operator >> (class TIniStream *S);

    TEString Label;         //  atom's label
    TEllipsoid* Ellipsoid; //  a pointer to TEllipse object
    TVPoint CCenter;     //  atom center in cell coordinates
    TCAtom* CAtom;    //  basic crystallographic information
    TVPoint Center;        //  atom centre in Cartesian coordinates
};

class TSBond: public TBasicBond

{
public:
    TSBond(TNetwork *Parent);
    ~TSBond();

    void virtual operator << (class TIniStream *S);
    void virtual operator >> (class TIniStream *S);
};

class TAsymmUnit

{
    TEList* FCAtoms;     // list of TCAtoms
    TEList* Matrices;      // list of matrices (a unique set with Latt, or full set with Latt =-1)
public:
    TEVPoint Axes;        // axes with errors
    TEVPoint Angles;     // angles + errors
    VType Z;                 // FZ
    TEString FCellSymmetry;
    TMatrix    *Cell2Cartesian, // transformation from cell crd to Cartesian
                    *Cartesian2Cell; // transformation from Cartesian crd to cell
    short         Latt;                   // INS instructions
    TLattice    *Lattice;             // parent lattice

    TAsymmUnit(TLattice *L);
    ~TAsymmUnit();
    void Assign( TAsymmUnit *C);
    void Init();                           // initialises transformation matrices
    void Clear();

    TCAtom * NewAtom();
    TCAtom * Atom(int index);
    TCAtom * Atom(const TEString &Label);
    int AtomCount();

    int MatrixCount();
    TMatrix *Matrix(int i);
    void AddMatrix(TMatrix *a);  // note that the object deletes the matrices in the destructor

    TVPoint GetOCenter();
    TEString SummFormula(const TEString &Sep);
    VType MolWeight();
};

class TUnitCell

Constructors TUnitCell(TLattice *L)
Functions return arguments  
       
Clear void bool ClearUnitCell  
       
InitMatrices void    
       
       
FragmentCount int    
Fragment TNetwork * int index  
MatrixCount int    
Matrix TMatrix * int index  
AtomCount int    
Atom TSAtom *    
EllipsoidCount int    
Ellipsoid TEllipsoid *    
BondCount int    
Bond TSBond *    

 

Properties:      
  Name Type  
public: Lattice TLattice *  
private:      
  FNetwork TNetwork *  
  Matrices TEList *  
  Atoms TEList *  
  EBonds TEList *  
  Ellipsoids TEList *  
  Fragments TEList *  


class TLattice

Constructors TLattice(TAtomsInfo *Info)
Functions return arguments  
GetAtom TSAtom* int index returns corresponding value of the atoms list
Clear void bool ClearUnitCell  
Uniq void    
Init void    
Generated bool   Checks if the structure is already generated
Generate void TVPoint VFrom
TVPoint VTo
TVPoint MFrom
TVPoint MTo
 
FragmentCount int    
Fragment TNetwork * int index  
MatrixCount int    
Matrix TMatrix * int index  
AtomCount int    
Atom TSAtom *    
BondCount int    
Bond TSBond *    

      

Properties:      
  Name Type  
public: AsymmUnit TAsymmUnit*  
  UnitCell TUnitCell *  
  Delta float  
  DeltaI float  
protected: AtomsInfo TAtomsInfo *  
  FGenerated bool  
private:      
  FNetwork TNetwork *  
  Matrices TEList *  
  Atoms TEList *  
  Bonds TEList *  
  Fragments TEList *  

class TBasicCFile

Constructors TBasicCFile(TAtomsInfo *S)
Functions return arguments  
virtual Adopt bool TXFile * adopts the content of the AsymmUnit to the virtual format
virtual LoadFromFile bool const TEString &A  
virtual SaveToFile bool const TEString &A  

 

Properties:      
  Name Type  
public: AsymmUnit TAsymmUnit*  
  Title TEString  
protected: AtomsInfo  TAtomsInfo *  

class TXFile

Constructors TXFile(TAtomsInfo *S)
Functions return arguments  
RegusterFileFormat bool TBasicCFile *File
const TEString &Ext
 
virtual LoadFromFile bool const TEString &A  
virtual SaveToFile bool const TEString &A  
GetFormat TBasicCFile *Format    

 

Properties:      
  Name Type  
public: AsymmUnit TAsymmUnit* Simply a pointer to Lattice->AsymmUnit
  Lattice TLattice  
protected: FileFormats TEStringList *  
AtomsInfo TAtomsInfo *

 

class TSymmParser

{
public:
    static class TEString MatrixToSymm( TMatrix &M); // Transforms matrix to standard SYMM operation (INS, CIF files)
    static bool SymmToMatrix(char *S,   TMatrix &M);  // Transforms standard SYMM operation (INS, CIF files) to a matrix
};
 

How to use TXFile:

#include "log.h"
#include "xclasses.h"
#include "chemobj.h"
TLog * Log;
int main(int argc, char* argv[] )
{
    Log = new TLog("log.file");
    Log->BaseDir = TEFiles::ExtractFileDir(argv[0]);
    TAtomsInfo *AI = new TAtomsInfo(Log->BaseDir+"ptablex.dat", true); // the file should be in the folder!
    TCif Cif(AI);
    TIns Ins(AI);
    TXFile XFile;
    XFile.RegisterFileFormat(&Cif, "cif" );
    XFile.RegisterFileFormat(&Ins, "ins" );
    XFile.RegisterFileFormat(&Ins, "res" );
    XFile.LoadFromFile("xxx.cif"); //  load a CIF
    XFile.SaveToFile("xxx.ins");    // saves an INS
    // note that all format-dependent information, such as loops of a CIF file or restraints of an INS file will be lost after formats inter-conversion
    // To change an atom label in an INS file call Ins.LoadFromFile(...) and Ins.SaveToFile(...) directly. A label can be changed as follows
    // Ins.AsymmUnit->Atom("old label")->Label = "new label"; It is completely the same for a CIF.
}
© Oleg V. Dolomanov, 2004
Last Updated 2004.04.01