Home » U++ Library support » U++ Core » Arrys vs Vectors
Re: Arrys vs Vectors [message #30268 is a reply to message #30267] |
Tue, 21 December 2010 12:08 |
281264
Messages: 270 Registered: June 2010 Location: Spain
|
Experienced Member |
|
|
Data are geometric objects (that require to be painted with OpenGL in a loop). For example:
template<class T>
class Point3D:MoveableAndDeepCopyOption<Point3D<T>>{
private:
T x,y,z,w;
unsigned int id,layer;
bool picked;
void Copy(const Point3D<T>& src){
x=src.x;
y=src.y;
z=src.z;
w=src.w;
id=src.id;
picked=src.picked;
layer=src.layer;
}
public:
Point3D (){
x=T();
y=T();
z=T();
w=static_cast<T>(1.0);
id=0;picked=0;
}
Point3D (T a, T b, T c,unsigned int e, bool f, unsigned int g, T d=static_cast<T>(1.0)){
x=a;y=b;z=c;w=d;
id=e;
picked=f;
layer=g;
}
Point3D (Point3D<T> &point){
x=point.get_x();y=point.get_y();z=point.get_z();w=point.get_w();
id=point.get_id();
picked=point.get_picked();
layer=point.get_layer();
}
Point3D (const Point3D<T> &src,int){Copy(src);}
void set_x(T a){x=a;}
void set_y(T a){y=a;}
void set_z(T a){z=a;}
void set_w(T a){w=a;}
void set_id(unsigned int a){id=a;}
void set_picked(bool a){picked=a;}
void set_layer(unsigned int a){layer=a;}
T get_x()const{return x;}
T get_y()const{return y;}
T get_z()const{return z;}
T get_w()const{return w;}
unsigned int get_id(){return id;}
bool get_picked(){return picked;}
unsigned int get_layer(){return layer;}
void operator*(const T& obj){
x=x*obj;
y=y*obj;
z=z*obj;
w=w*obj;
}
Point3D<T> operator+(const Point3D<T> &obj){
return Point3D<T>(x+obj.get_x(),y+obj.get_y(),z+obj.get_z(),w+obj.get_w());
}
void Serialize(Stream& s){
s%x%y%z%w%id%picked%layer;
}
String ToString()const{
String s;
s<<"x:"<<x<<","<<"y:"<<y<<","<<"z:"<<z<<","<<"w:"<<w<<","<<"id:"<<id<<","<<"picked:"<<picked<<", "<<"layer:"<<layer;
return s;
}
};
I am using other geometrical structures, for example line3D, nurbs lines and surfaces.
Let us take a line. Here is the question: the two points that form part of a line, is it better to reference them by using pointers (hence Array has to be used to store the point3D) or by emulating their content or by storing a simple identifier (an unsigned int which looks the easiest way to do it)?.
Remark: I have tried to debug an Arry<int> array and added an integer array.Add(1): when debugging U++ crashes when clicking on the .vector, what is it going on wrong? It is weird, is it not?
Thanks,
Javier
|
|
|
|
|
Arrys vs Vectors
By: 281264 on Tue, 21 December 2010 10:43
|
|
|
Re: Arrys vs Vectors
By: kohait00 on Tue, 21 December 2010 11:20
|
|
|
Re: Arrys vs Vectors
By: 281264 on Tue, 21 December 2010 11:43
|
|
|
Re: Arrys vs Vectors
By: kohait00 on Tue, 21 December 2010 11:51
|
|
|
Re: Arrys vs Vectors
By: 281264 on Tue, 21 December 2010 12:08
|
|
|
Re: Arrys vs Vectors
By: kohait00 on Tue, 21 December 2010 12:36
|
|
|
Re: Arrys vs Vectors
By: 281264 on Tue, 21 December 2010 17:23
|
|
|
Re: Arrys vs Vectors
By: kohait00 on Tue, 21 December 2010 17:54
|
|
|
Re: Arrys vs Vectors
By: mirek on Sat, 25 December 2010 10:57
|
|
|
Re: Arrys vs Vectors
By: kohait00 on Sun, 26 December 2010 10:07
|
|
|
Re: Arrys vs Vectors
By: 281264 on Mon, 27 December 2010 11:51
|
|
|
Re: Arrys vs Vectors
By: mirek on Mon, 27 December 2010 13:29
|
|
|
Re: Arrys vs Vectors
By: kohait00 on Mon, 27 December 2010 14:15
|
|
|
Re: Arrys vs Vectors
|
|
|
Re: Arrys vs Vectors
By: mirek on Mon, 27 December 2010 13:23
|
|
|
Re: Arrys vs Vectors
By: 281264 on Tue, 21 December 2010 18:20
|
|
|
Re: Arrys vs Vectors
By: kohait00 on Tue, 21 December 2010 19:48
|
|
|
Re: Arrys vs Vectors
By: 281264 on Tue, 21 December 2010 21:54
|
|
|
Re: Arrys vs Vectors
By: 281264 on Tue, 21 December 2010 22:04
|
|
|
Re: Arrys vs Vectors
By: kohait00 on Tue, 21 December 2010 22:12
|
|
|
Re: Arrys vs Vectors
By: 281264 on Tue, 21 December 2010 19:04
|
|
|
Re: Arrys vs Vectors
By: Didier on Tue, 21 December 2010 19:45
|
Goto Forum:
Current Time: Wed Jun 12 00:32:06 CEST 2024
Total time taken to generate the page: 0.01067 seconds
|