File: Cell.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 (118 lines) | stat: -rw-r--r-- 4,499 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
118
/***************************************************************************
                                   Cell.h 
                             -------------------
    begin             : Wed Aug 8 2001
    copyright         : (C) 2001 TIMC (Emmanuel Promayon, Matthieu Chabanas)
    email             : Emmanuel.Promayon@imag.fr
    Date              : $Date: 2006/10/17 14:33:21 $
    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 CELL_H
#define CELL_H

#include "Structure.h"
#include "StructuralComponent.h"

#include <sofa/helper/system/config.h>

class CellProperties;

/** A cell has an unique index in the physical model object, is composed by atoms, and different basic properties.
  * It is the most basic component composing a physical model.
  * $Revision: 1.9 $
  */
class Cell : public Structure , public StructuralComponent {
public:
    /** constructor that generates a unique index
    * @param t the type of the cell
    */
    Cell(PhysicalModel *, const StructureProperties::GeometricType t);
	/** constructor from xml node: try to read and get the parmaters from xml */
	Cell(PhysicalModel *, const StructureProperties::GeometricType t, xmlNodePtr);
    /** When you know the index of the cell, use this constructor.
    * @param t the type of the cell
    * @param ind give the unique index
    */
    Cell(PhysicalModel *, const StructureProperties::GeometricType t, const unsigned int ind);
    /// the destructor, my tailor. BECAREFUL: the atoms should not not be deleted here...
    virtual ~Cell() ;

    /** print to an output stream in "pseudo" XML format.
     *	If the StructuralComponent that calls this method is not the first in the
     *  list of composing SC, then a cellRef tag is printed (otherwise the list
     * 	of atom is printed).
     */
    void xmlPrint(std::ostream &, const StructuralComponent *);

    /** return true only if the parameter is equal to "MultiComponent" */
    virtual bool isInstanceOf(const char *) const;

    /**
     * This method overload the one defined in StructuralComponent.
     * The difference here is that the atoms composing the cell ARE NOT delete, still the
     *  list is cleared.
     * After this methode getNumberOfSubStructures() should return 0
     */
    virtual void deleteAllStructures();

    /// return the property
    CellProperties * getProperties();

    /// overloaded from Structural component, always return StructuralComponent::ATOMS
    StructuralComponent::ComposedBy composedBy();

    /** is this sc the one that will be the one that will make the cell to print out all its data
      * or is this a sc that will just print out the cell ref?
      */
    bool makePrintData(const StructuralComponent *);

    /** set the index.
     *  The index <b>have to be unique</b> otherwise this method
     *  has no effect. 
     *  The sub-classes method will check that this index is not in use.
     *  @return true only if the index of the structure was changed
     */
    virtual bool setIndex(const unsigned int);

	/** compute the normal of the facet
	 *  Warning : Only available for QUAD and TRIANGLE type cells
	 */
	SReal* normal(); 

	/** Return a structural component composed by the facets of the cells.
	 *  the facets are quads or/and triangles 
	 */
	StructuralComponent * getFacets();

	///Compute the surface of the cell
	SReal surface();

	/// Compute the volume of the cell
	SReal volume();


    
private:
    /// unique number (used to generate unique index for atoms if not given at the instanciation)
    static unsigned int nextUniqueIndex;

};

inline bool Cell::isInstanceOf(const char *className) const {
    return (strcmp(className, "Cell")==0);
}

inline StructuralComponent::ComposedBy Cell::composedBy() {
    return StructuralComponent::ATOMS;
}
#endif //CELL_H