|
|
Home » Community » U++ community news and announcements » New graph packages
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: New graph packages [message #35603 is a reply to message #35601] |
Sun, 04 March 2012 13:48 |
Didier
Messages: 690 Registered: November 2008 Location: France
|
Contributor |
|
|
Hi Koldo,
I think DataSource used in ScatterDraw should go template:
The only reason for this is to enable high performance if needed:
class DataSource {
public:
typedef double (DataSource::*Getdatafun)(int id);
DataSource() : isParam(false) {}
virtual ~DataSource() {};
virtual double z(int id) {return Null;};
virtual double y(int id) {return Null;};
virtual double x(int id) {return Null;};
virtual int GetCount() {return Null;};
bool IsParam() {return isParam;};
virtual double MinX() {return Min(&DataSource::x);}
virtual double MinY() {return Min(&DataSource::y);}
virtual double MinZ() {return Min(&DataSource::z);}
virtual double MaxX() {return Max(&DataSource::x);}
virtual double MaxY() {return Max(&DataSource::y);}
virtual double MaxZ() {return Max(&DataSource::z);}
virtual double AvgX() {return Avg(&DataSource::x);}
virtual double AvgY() {return Avg(&DataSource::y);}
virtual double AvgZ() {return Avg(&DataSource::z);}
Class DataSource is a pure virtual class
==> so all method calls need to go by the virtual table ==> poor performance
This is specially true for the x,y,z methods which get called for each point drawn.
If Scatter Draw had was defined the following way:
template<class DATASOURCE = DataSource>
class ScatterDraw {
public:
...
The following high performance trivial class could be used intead:
template<int NBPOINTS>
class DataSource {
private:
double _x[NBPOINTS];
double _y[NBPOINTS];
double _z[NBPOINTS];
public:
DataSource() {}
inline double z(int id) {return _x[id];}
inline double y(int id) {return _y[id];}
inline double x(int id) {return _z[id];}
inline int GetCount() {return NBPOINTS;}
inline bool IsParam() {return false;}
inline double MinX() {return ....;}
inline double MinY() {return ....;}
inline double MinZ() {return ....;}
inline double MaxX() {return ....;}
inline double MaxY() {return ....;}
inline double MaxZ() {return ....;}
inline double AvgX() {return ....;}
inline double AvgY() {return ....;}
inline double AvgZ() {return ....;}
};
The backdraw to this is that most of ScatterDraw should go in the header
But after all that is not such a big issue.
NB: I know that most of the performance is due to drawing speed but all enhancements are welcome I think
What do you think ?
[Updated on: Sun, 04 March 2012 14:42] Report message to a moderator
|
|
|
|
Goto Forum:
Current Time: Fri Nov 01 00:54:09 CET 2024
Total time taken to generate the page: 0.03182 seconds
|
|
|