summaryrefslogtreecommitdiffstats
path: root/lib/tqwtplot3d/examples/mesh2/src/mesh.cpp
blob: 60683eb311b109d5eba759e24edf5413ce84fda3 (plain)
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
#include "functions.h"

using namespace std;
using namespace Qwt3D;


void createCone(Qwt3D::TripleField& conepos, Qwt3D::CellField& conecell)
{
  conepos.clear(); conecell.clear();
  Cell cell;
  
  conepos.push_back(Triple(0,0,0));

  const unsigned int count = 17;
  double r1 = 0.7;
  double r2 = 0.9 * r1;
  
  double h1 = 2;
  double h2 = 1.03 * h1;

  unsigned i;
  
  Cell c1;
  // outer top border
  for (i=0; i<count; ++i)
  {
    conepos.push_back(Triple(r1*cos(2*i*Qwt3D::PI/count), r1*sin(2*i*Qwt3D::PI/count),h1));
  }
  // inner top border
  for (i=0; i<count; ++i)
  {
    conepos.push_back(Triple(r2*cos(2*i*Qwt3D::PI/count), r2*sin(2*i*Qwt3D::PI/count),h2));
    c1.push_back(count+i+1);
  }
  // top polygon
  conecell.push_back(c1);
  
  // triangles
  Cell c2(3);
  for (i=1; i<count+1; ++i)
  {
    c2[0] = 0;
    c2[1] = i%count +1;
    c2[2] = i;
    conecell.push_back(c2);
  }
  // quadrangles
  c2 = Cell(4);
  for (i=1; i<count+1; ++i)
  {
    c2[0] = i;
    c2[1] = i%count +1;
    c2[2] = count+i%count +1;
    c2[3] = count+i;
    conecell.push_back(c2);
  }
}