fixed edge display for volume cells
[engrid-github.git] / src / libengrid / vertexmeshdensity.cpp
blobe7bedd7ee6bf6f377945b01b5683215a81ac71db
1 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 // + +
3 // + This file is part of enGrid. +
4 // + +
5 // + Copyright 2008-2014 enGits GmbH +
6 // + +
7 // + enGrid is free software: you can redistribute it and/or modify +
8 // + it under the terms of the GNU General Public License as published by +
9 // + the Free Software Foundation, either version 3 of the License, or +
10 // + (at your option) any later version. +
11 // + +
12 // + enGrid is distributed in the hope that it will be useful, +
13 // + but WITHOUT ANY WARRANTY; without even the implied warranty of +
14 // + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +
15 // + GNU General Public License for more details. +
16 // + +
17 // + You should have received a copy of the GNU General Public License +
18 // + along with enGrid. If not, see <http://www.gnu.org/licenses/>. +
19 // + +
20 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
21 #include "vertexmeshdensity.h"
22 #include "egvtkobject.h"
23 #include <iostream>
24 using namespace std;
26 VertexMeshDensity::VertexMeshDensity()
28 type = EG_SIMPLE_VERTEX;
29 CurrentNode = 0;
32 //this=user defined
33 //VMD=VMD of current node
34 //This operator is NOT SYMMETRICAL. But it can be used with indexOf.
35 bool VertexMeshDensity::operator==(const VertexMeshDensity & VMD) const
37 if(this->nodeset.size()>0) //node ID mode
39 if(this->nodeset.contains(VMD.CurrentNode) ) return(true);//node ID given, we're done
40 else return(false);
42 else //node properties mode
44 if(this->type!=VMD.type && this->type!=-1) return(false);
46 QMapIterator<int, int> i(this->BCmap);
47 while (i.hasNext()) {
48 i.next();
49 int index=i.key();
50 if((this->BCmap)[index]!=VMD.BCmap[index] && (this->BCmap)[index]!=1) return(false);
53 return(true);
57 int VertexMeshDensity::findSmallestVMD( QVector <VertexMeshDensity> vector)
59 int ret = -1;
60 double Lmin = 0;
61 bool first = true;
62 for(int i=0;i<vector.size();i++){
63 if(vector[i]==*this) {
64 if(first) {
65 ret = i;
66 Lmin = vector[i].density;
67 first = false;
69 else if(vector[i].density < Lmin) {
70 ret = i;
71 Lmin = vector[i].density;
75 return(ret);
78 //converts string to nodeset
79 void VertexMeshDensity::setNodes(QString str)
81 nodeset.clear();//empty by default
82 // cout<<"str.size="<<str.size()<<endl;
83 if(str.size()>0)
85 QStringList L = str.split(",");
86 foreach(QString elt,L) nodeset.insert(elt.toInt());
90 ostream& operator<<(ostream &out, VertexMeshDensity A)
92 out<<" BCmap="<<A.BCmap;
93 out<<" type="<<(int)A.type;
94 out<<" nodeset="<<A.nodeset;
95 out<<" density="<<A.density;
96 return(out);
99 ostream& operator<<(ostream &out, QVector<VertexMeshDensity> VMDvector)
101 int N=VMDvector.size();
102 out<<"Size="<<N;
103 if(N>0) out<<endl;
104 for(int i=0;i<N;i++)
106 out<<VMDvector[i];
107 if(i!=N-1) out<<endl;
109 return(out);