File: testMeta7Line.cxx

package info (click to toggle)
insighttoolkit 3.20.1%2Bgit20120521-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 80,652 kB
  • sloc: cpp: 458,133; ansic: 196,223; fortran: 28,000; python: 3,839; tcl: 1,811; sh: 1,184; java: 583; makefile: 430; csh: 220; perl: 193; xml: 20
file content (68 lines) | stat: -rw-r--r-- 1,697 bytes parent folder | download | duplicates (8)
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
#include <stdio.h>
#include <ctype.h>
#include <metaLine.h>

int main(int argc, char **argv)
{

  METAIO_STREAM::cout << "Creating test file ...";
  MetaLine* Line = new MetaLine(3);
  Line->ID(0);
  LinePnt* pnt;

  unsigned int i;
  for(i=0;i<10;i++)
  {
    pnt = new LinePnt(3);
    pnt->m_X[0]=(float)0.2;pnt->m_X[1]=i;pnt->m_X[2]=i;
    pnt->m_V[0][0]=(float)0.3;pnt->m_V[0][1]=i;pnt->m_V[0][2]=i;
    pnt->m_V[1][0]=(float)0.4;pnt->m_V[1][1]=i+1;pnt->m_V[1][2]=i+1;
    Line->GetPoints().push_back(pnt);
  }
  
  METAIO_STREAM::cout << "Writing test file ...";
   
  Line->BinaryData(true);

  Line->Write("myLine.meta");

  METAIO_STREAM::cout << "done" << METAIO_STREAM::endl;
  METAIO_STREAM::cout << "Reading test file ...";

  Line->Clear();
  Line->Read("myLine.meta");

  Line->PrintInfo();

  MetaLine::PointListType list =  Line->GetPoints();
  MetaLine::PointListType::const_iterator it = list.begin();
  
  i=0;
  while(it != list.end())
  {
    METAIO_STREAM::cout << "Point #" << i++ << ":" << METAIO_STREAM::endl;
    METAIO_STREAM::cout << "position = ";
    unsigned int d=0;
    for(d = 0; d < 3; d++)
    {
      METAIO_STREAM::cout << (*it)->m_X[d] << " ";
    }
    METAIO_STREAM::cout << METAIO_STREAM::endl;
    METAIO_STREAM::cout << "First normal = ";
    for(d = 0; d < 3; d++)
    {
      METAIO_STREAM::cout << (*it)->m_V[0][d] << " ";
    }
    METAIO_STREAM::cout << METAIO_STREAM::endl;
    METAIO_STREAM::cout << "Second normal = ";
    for(d = 0; d < 3; d++)
    {
      METAIO_STREAM::cout << (*it)->m_V[1][d] << " ";
    }
    METAIO_STREAM::cout << METAIO_STREAM::endl;
    it++;
  }

  METAIO_STREAM::cout << "done" << METAIO_STREAM::endl;
  return 1;
}