File: BasicAtomProperties.h

package info (click to toggle)
sofa-framework 1.0~beta4-9
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 88,688 kB
  • ctags: 27,205
  • sloc: cpp: 151,126; ansic: 2,387; xml: 581; sh: 417; makefile: 67
file content (117 lines) | stat: -rw-r--r-- 4,221 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/***************************************************************************
                            BasicAtomProperties.h
                             -------------------
    begin             : Wed Aug 8 2001
    copyright         : (C) 2001 TIMC (Emmanuel Promayon, Matthieu Chabanas)
    email             : Emmanuel.Promayon@imag.fr
    Date              : $Date: 2004/08/11 14:05:24 $
    Version           : $Revision: 1.9 $
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef BASICATOMPROPERTIES_H
#define BASICATOMPROPERTIES_H



#include "PhysicalModelIO.h"
#include "StructureProperties.h"
#include <sofa/helper/system/config.h>

/**
  * This class is the basic Atom Properties class.
  * You should derive from this class a AtomProperties class and use it to implement your own custom stuff.
  * This is a pure virtual class.
  *
  * @author Emmanuel Promayon
  * $Revision: 1.9 $
  */
class BasicAtomProperties : public StructureProperties {
public:
    /** Default constructor : set the position to the origin, and generate an unique index */
    BasicAtomProperties(PhysicalModel *);
	/** constructor from xml node: try to read and get the parmaters from xml */
    BasicAtomProperties(PhysicalModel *, xmlNodePtr);
    /** set the position to the origin
     * @param ind an unique index
     */
    BasicAtomProperties(PhysicalModel *, const unsigned int ind);
    /** generate an unique index.
     * @param pos the initial position
     */
    BasicAtomProperties(PhysicalModel *, const SReal pos[3]);
    /** everything is given here
     * @param pos the initial position
     * @param ind an unique index
     */
    BasicAtomProperties(PhysicalModel *, const unsigned int ind, const SReal pos[3]);
    /** the destructor...
        */
    virtual ~BasicAtomProperties() {};

    /// print to an output stream in "pseudo" XML format.
    virtual void xmlPrint(std::ostream &) =0;

    /** Reinitialize the unique index to zero (usually that what you want to do when you
        * start to load a new PhysicalModel
        */
    static void resetUniqueIndex();

    /// get the position of the atom (array of 3 SReals)
    void getPosition(SReal pos[3]) const;

    /// set the position of the atom
    void setPosition(const SReal [3]);
    /// set the position of the atom
    void setPosition(const SReal,const SReal,const SReal);
        
    /** Position of the atom */
    SReal X[3];

    /// Set the temporary int property
    void setTempProp(const int);
    /// Set the temporary int property
    int getTempProp() const ;

protected:
    /// write the default xml properties (beginning)
    void beginXML(std::ostream &);
    /// write the default xml properties (end)
    void endXML(std::ostream &);

private:
    /// unique number (used to generate unique index for atoms if not given at the instanciation)
    static unsigned int maxUniqueIndex;
    /// this property is temporary and could be used by various algorithm (like connectivity builds)
    int intTempProp;
};

// inlines
inline void BasicAtomProperties::setTempProp(const int ti) {
    intTempProp = ti;
}
inline int BasicAtomProperties::getTempProp() const {
    return intTempProp;
}

inline void BasicAtomProperties::getPosition(SReal pos[3]) const {
    pos[0]=X[0]; pos[1]=X[1]; pos[2]=X[2];
}

inline void BasicAtomProperties::setPosition(const SReal pos[3]) {
    X[0]=pos[0]; X[1]=pos[1]; X[2]=pos[2];
}

inline void BasicAtomProperties::setPosition(const SReal x,const SReal y,const SReal z) {
    X[0]=x; X[1]=y; X[2]=z;
}

#endif //BasicAtomProperties_H