fixed bug in search method
[engrid.git] / src / showinfo.cpp
blob1d4cb8b04b388b3d6ed4d755d522da76d08db250
1 //
2 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 // + +
4 // + This file is part of enGrid. +
5 // + +
6 // + Copyright 2008,2009 Oliver Gloth +
7 // + +
8 // + enGrid is free software: you can redistribute it and/or modify +
9 // + it under the terms of the GNU General Public License as published by +
10 // + the Free Software Foundation, either version 3 of the License, or +
11 // + (at your option) any later version. +
12 // + +
13 // + enGrid is distributed in the hope that it will be useful, +
14 // + but WITHOUT ANY WARRANTY; without even the implied warranty of +
15 // + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +
16 // + GNU General Public License for more details. +
17 // + +
18 // + You should have received a copy of the GNU General Public License +
19 // + along with enGrid. If not, see <http://www.gnu.org/licenses/>. +
20 // + +
21 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
23 #include "showinfo.h"
25 #include "insertpoints.h"
27 #include "geometrytools.h"
28 using namespace GeometryTools;
30 #include <vtkCharArray.h>
32 ShowInfo::ShowInfo(bool b, vtkIdType P, vtkIdType C) : SurfaceOperation()
34 CellInfo = b;
35 PickedPoint = P;
36 PickedCell = C;
39 void ShowInfo::operate()
41 l2g_t nodes = getPartNodes();
42 g2l_t _nodes = getPartLocalNodes();
43 l2g_t cells = getPartCells();
44 g2l_t _cells = getPartLocalCells();
45 l2l_t c2c = getPartC2C();
46 l2l_t n2n = getPartN2N();
47 l2l_t n2c = getPartN2C();
49 int N_cells=m_Grid->GetNumberOfCells();
50 int N_points=m_Grid->GetNumberOfPoints();
51 if(CellInfo) {
52 if(PickedCell>=0 && PickedCell<N_cells) {
53 cout<<"=== INFO ON CELL "<<PickedCell<<" ==="<<endl;
54 QVector<vtkIdType> absolute_c2c;
55 foreach(int i, c2c[_cells[PickedCell]]) {
56 if(i!=-1) absolute_c2c.push_back(cells[i]);
59 cout<<"absolute_c2c(PickedCell)="<<absolute_c2c<<endl;
60 vtkIdType *pts, N_pts;
61 m_Grid->GetCellPoints(PickedCell, N_pts, pts);
62 cout<<"pts=";
63 for(int i=0;i<N_pts;i++) cout<<pts[i]<<" ";
64 cout<<endl;
65 cout<<"coords:"<<endl;
66 for(int i=0;i<N_pts;i++) {
67 vec3_t X;
68 m_Grid->GetPoint(pts[i],X.data());
69 cout<<"pts["<<i<<"]="<<X<<endl;
71 cout<<"area="<<cellVA(m_Grid,PickedCell)<<endl;
72 cout<<"Q_L("<<PickedCell<<")="<<Q_L(PickedCell)<<endl;
73 cout<<"====================================="<<endl;
74 } else {
75 cout<<"Invalid cell"<<endl;
77 } else {
78 if(PickedPoint>=0 && PickedPoint<N_points) {
79 cout<<"=== INFO ON POINT "<<PickedPoint<<" ==="<<endl;
81 QSet<vtkIdType> absolute_n2n;
82 foreach(int i, n2n[_nodes[PickedPoint]]) {
83 if(i!=-1) absolute_n2n.insert(nodes[i]);
85 cout<<"absolute_n2n(PickedPoint)="<<absolute_n2n<<endl;
87 QSet<vtkIdType> absolute_n2c;
88 foreach(int i, n2c[_nodes[PickedPoint]]) {
89 if(i!=-1) absolute_n2c.insert(cells[i]);
91 cout<<"absolute_n2c(PickedPoint)="<<absolute_n2c<<endl;
93 EG_VTKDCN(vtkCharArray, node_type, m_Grid, "node_type");//node type
94 cout<<"node_type="<<VertexType2Str(node_type->GetValue(PickedPoint))<<endl;
95 vec3_t X;
96 m_Grid->GetPoint(PickedPoint,X.data());
97 cout<<"X="<<X<<endl;
98 cout<<"desiredEdgeLength("<<PickedPoint<<")="<<desiredEdgeLength(PickedPoint)<<endl;
99 cout<<"Q_L1("<<PickedPoint<<")="<<Q_L1(PickedPoint)<<endl;
100 cout<<"Q_L2("<<PickedPoint<<")="<<Q_L2(PickedPoint)<<endl;
101 cout<<"CurrentVertexAvgDist("<<PickedPoint<<")="<<CurrentVertexAvgDist(PickedPoint)<<endl;
102 cout<<"====================================="<<endl;
103 } else {
104 cout<<"Invalid point"<<endl;