00001 00012 #include "ContourFunctionRep.h" 00013 00014 #include "colorreps/BinToBlack.h" 00015 #include "datasrcs/DataPointTuple.h" 00016 #include "datasrcs/NTuple.h" 00017 #include "functions/FunctionBase.h" 00018 00019 using std::string; 00020 using std::vector; 00021 00022 namespace dp = hippodraw::DataPoint3DTuple; 00023 00024 namespace hippodraw { 00025 00026 ContourFunctionRep:: 00027 ContourFunctionRep ( ) 00028 : ContourPointRep ( ), 00029 m_steps ( 25 ) 00030 { 00031 BinToBlack * btb = new BinToBlack ( "black" ); 00032 setValueTransform ( btb ); 00033 00034 unsigned int cols = dp::SIZE; 00035 m_ntuple = new NTuple ( cols ); 00036 m_ntuple -> reserve ( m_steps * m_steps ); 00037 00038 vector < unsigned int > shape ( 3 ); 00039 shape[0] = m_steps; 00040 shape[1] = m_steps; 00041 shape[2] = 3; 00042 m_ntuple -> setShape ( shape ); 00043 } 00044 00045 ContourFunctionRep:: 00046 ~ContourFunctionRep() 00047 { 00048 } 00049 00050 00051 void 00052 ContourFunctionRep:: 00053 drawProjectedValues ( const Range & x_range, const Range & y_range, 00054 const FunctionBase * function, 00055 TransformBase * transform, 00056 ViewBase * view ) 00057 { 00058 m_ntuple-> clear (); 00059 00060 double dx = x_range.length() / m_steps; 00061 double x = x_range.low () + 0.5 * dx; 00062 00063 double dy = y_range.length() / m_steps; 00064 double y_low = y_range.low () + 0.5 * dy; 00065 00066 vector < double > coord ( 2 ); 00067 vector < double > row ( dp::SIZE ); 00068 row [dp::XERR] = 0.5 * dx; 00069 row [dp::YERR] = 0.5 * dy; 00070 row [dp::ZERR] = 0.; 00071 00072 for ( unsigned int i = 0; i < m_steps; i++, x += dx ) { 00073 coord [0] = x; 00074 double y = y_low; 00075 for ( unsigned int j = 0; j < m_steps; j++, y += dy ) { 00076 coord [1] = y; 00077 double value = function -> operator() ( coord ); 00078 00079 row[dp::X] = x; 00080 row[dp::Y] = y; 00081 row[dp::Z] = value; 00082 00083 m_ntuple -> addRow ( row ); 00084 } 00085 } 00086 00087 ContourPointRep::drawProjectedValues ( m_ntuple, transform, view ); 00088 } 00089 00090 } // namespace hippodraw 00091