ContourFunctionRep.cxx
Go to the documentation of this file.
1 
12 #include "ContourFunctionRep.h"
13 
14 #include "colorreps/BinToBlack.h"
16 #include "datasrcs/NTuple.h"
17 #include "functions/FunctionBase.h"
18 
19 using std::string;
20 using std::vector;
21 
22 namespace dp = hippodraw::DataPoint3DTuple;
23 
24 namespace hippodraw {
25 
28  : ContourPointRep ( ),
29  m_steps ( 25 )
30 {
31  BinToBlack * btb = new BinToBlack ( "black" );
32  setValueTransform ( btb );
33 
34  unsigned int cols = dp::SIZE;
35  m_ntuple = new NTuple ( cols );
36  m_ntuple -> reserve ( m_steps * m_steps );
37 
38  vector < unsigned int > shape ( 3 );
39  shape[0] = m_steps;
40  shape[1] = m_steps;
41  shape[2] = 3;
42  m_ntuple -> setShape ( shape );
43 }
44 
47 {
48 }
49 
50 
51 void
53 drawProjectedValues ( const Range & x_range, const Range & y_range,
54  const FunctionBase * function,
55  TransformBase * transform,
56  ViewBase * view )
57 {
58  m_ntuple-> clear ();
59 
60  double dx = x_range.length() / m_steps;
61  double x = x_range.low () + 0.5 * dx;
62 
63  double dy = y_range.length() / m_steps;
64  double y_low = y_range.low () + 0.5 * dy;
65 
66  vector < double > coord ( 2 );
67  vector < double > row ( dp::SIZE );
68  row [dp::XERR] = 0.5 * dx;
69  row [dp::YERR] = 0.5 * dy;
70  row [dp::ZERR] = 0.;
71 
72  for ( unsigned int i = 0; i < m_steps; i++, x += dx ) {
73  coord [0] = x;
74  double y = y_low;
75  for ( unsigned int j = 0; j < m_steps; j++, y += dy ) {
76  coord [1] = y;
77  double value = function -> operator() ( coord );
78 
79  row[dp::X] = x;
80  row[dp::Y] = y;
81  row[dp::Z] = value;
82 
83  m_ntuple -> addRow ( row );
84  }
85  }
86 
88 }
89 
90 } // namespace hippodraw
91 

Generated for HippoDraw Class Library by doxygen