-
Notifications
You must be signed in to change notification settings - Fork 2
/
Model.cpp
107 lines (85 loc) · 2.1 KB
/
Model.cpp
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
#include "Model.h"
#include "AbstractReader.h"
#include "ReaderBuilder.h"
#include "FEMReader.h"
#include "Element.h"
#include "Compare.h"
#include "Predicate.h"
#include <iterator>
#include <algorithm>
namespace fesolv {
Model::Model(const std::string fileName)
{
_nodes = new nodes;
_elements = new elements;
_materials = new materials;
_readerbuilder = new ReaderBuilder;
_reader = _readerbuilder->BuildReader(fileName);
if (_reader){
_reader->Read(this);
FinalizeModelInit();
}
}
Model::~Model()
{
node_reverse_iterator node = _nodes->rbegin();
for ( ; node != _nodes->rend(); node++ )
delete *node;
_nodes->clear();
delete _nodes;
element_reverse_iterator element = _elements->rbegin();
for ( ; element != _elements->rend(); element++ )
delete *element;
_elements->clear();
delete _elements;
material_reverse_iterator material = _materials->rbegin();
for ( ; material != _materials->rend(); material++ )
delete *material;
_materials->clear();
delete _materials;
delete _readerbuilder;
}
Node* Model::GetNode(FEint n) const
{
Predicate<Node,FEint> nodepred;
return *find_if(_nodes->begin(),_nodes->end(),nodepred,n);
}
Element* Model::GetElement(FEint n) const
{
Predicate<Element,FEint> elempred;
return *find_if(_elements->begin(),_elements->end(),elempred,n);
}
Material* Model::GetMaterial(FEint n) const
{
Predicate<Material,FEint> matpred;
return *find_if(_materials->begin(),_materials->end(),matpred,n);
}
void Model::AddNode(Node* const nodePtr)
{
_nodes->push_back(nodePtr);
}
void Model::AddElement(Element* const elementPtr)
{
_elements->push_back(elementPtr);
}
void Model::AddMaterial(Material* const materialPtr)
{
_materials->push_back(materialPtr);
}
Model::Model(const Model& original)
{
}
Model& Model::operator=(const Model& original)
{
return *this;
}
void Model::FinalizeModelInit()
{
Compare<Element> cmpElem;
Compare<Node> cmpNode;
Compare<Material> cmpMat;
std::sort(_elements->begin(), _elements->end(), cmpElem);
std::sort(_nodes->begin(), _nodes->end(), cmpNode);
std::sort(_materials->begin(), _materials->end(), cmpMat);
}
}//end namespace