Back to home page

EIC code displayed by LXR

 
 

    


Warning, /include/Geant4/tools/sg/markers is written in an unsupported language. File is not indexed.

0001 // Copyright (C) 2010, Guy Barrand. All rights reserved.
0002 // See the file tools.license for terms.
0003 
0004 #ifndef tools_sg_markers
0005 #define tools_sg_markers
0006 
0007 #include "node"
0008 
0009 #include "sf_enum"
0010 #include "mf"
0011 #include "render_action"
0012 #include "pick_action"
0013 #include "bbox_action"
0014 #include "../mathf"
0015 #include "../lina/vec2f"
0016 #include "../lina/geom2"
0017 
0018 namespace tools {
0019 namespace sg {
0020 
0021 class markers : public node {
0022   TOOLS_NODE(markers,tools::sg::markers,node)
0023 public:
0024   sf_enum<marker_style> style;
0025   mf<float> xyzs; //[x,y,z]
0026   sf<float> size; //horizontal size in pixels.
0027 public:
0028   virtual const desc_fields& node_desc_fields() const {
0029     TOOLS_FIELD_DESC_NODE_CLASS(tools::sg::markers)
0030     static const desc_fields s_v(parent::node_desc_fields(),3, //WARNING : take care of count.
0031       TOOLS_ARG_FIELD_DESC(style),
0032       TOOLS_ARG_FIELD_DESC(xyzs),
0033       TOOLS_ARG_FIELD_DESC(size)
0034     );
0035     return s_v;
0036   }
0037 private:
0038   void add_fields(){
0039     add_field(&style);
0040     add_field(&xyzs);
0041     add_field(&size);
0042   }
0043 public:
0044   virtual bool draw_in_frame_buffer() const {return true;}
0045 
0046   virtual void render(render_action& a_action) {
0047     size_t num = xyzs.size()/3;
0048     if(!num) return;
0049 
0050     //NOTE : gstos would not work because of project_point() that must be done at each render().
0051 
0052     const state& state = a_action.state();
0053 
0054     const std::vector<float>& _xyzs = xyzs.values();
0055 
0056     std::vector<float> pts;
0057 
0058     float sx = size.value()/float(state.m_ww); //in [-1,1]
0059     float hsx = sx*0.5f;
0060 
0061     float sy = size.value()/float(state.m_wh); //in [-1,1]
0062     float hsy = sy*0.5f;
0063 
0064     float rad  = hsx;
0065     float hsx2 = hsx*0.5f;
0066     float hsy2 = hsy*0.5f;
0067 
0068     float x,y,z,w;
0069 
0070     bool filled = false;
0071     if(style.value()==marker_circle_line) {
0072       unsigned int segs = 16;
0073       float _cos[16];float _sin[16];
0074       float dtheta = ftwo_pi()/float(segs);
0075       float theta = dtheta;
0076      {for(unsigned int i=0;i<segs;i++,theta+=dtheta) {_cos[i] = rad*fcos(theta);_sin[i] = rad*fsin(theta);}}
0077       float xprev,yprev,xnext,ynext;
0078       std::vector<float>::const_iterator it;
0079       for(it=_xyzs.begin();it!=_xyzs.end();){
0080         x = *it;it++;
0081         y = *it;it++;
0082         z = *it;it++;
0083         a_action.project_point(x,y,z,w); //in [-1,1][-1,1]
0084         xprev = x+rad;
0085         yprev = y;
0086         for(unsigned int i=0;i<segs;i++) {
0087           xnext = x+_cos[i];
0088           ynext = y+_sin[i];
0089           _add(pts,xprev,yprev,z);
0090           _add(pts,xnext,ynext,z);
0091           xprev = xnext;
0092           yprev = ynext;
0093         }
0094       }
0095 
0096     } else if(style.value()==marker_circle_filled) {
0097       filled = true;
0098       unsigned int segs = 16;
0099       float _cos[16];float _sin[16];
0100       float dtheta = ftwo_pi()/float(segs);
0101       float theta = dtheta;
0102      {for(unsigned int i=0;i<segs;i++,theta+=dtheta) {_cos[i] = rad*fcos(theta);_sin[i] = rad*fsin(theta);}}
0103       float xprev,yprev,xnext,ynext;
0104       std::vector<float>::const_iterator it;
0105       for(it=_xyzs.begin();it!=_xyzs.end();){
0106         x = *it;it++;
0107         y = *it;it++;
0108         z = *it;it++;
0109         a_action.project_point(x,y,z,w); //in [-1,1][-1,1]
0110         xprev = x+rad;
0111         yprev = y;
0112         for(unsigned int i=0;i<segs;i++) {
0113           xnext = x+_cos[i];
0114           ynext = y+_sin[i];
0115           _add(pts,x    ,y    ,z);
0116           _add(pts,xprev,yprev,z);
0117           _add(pts,xnext,ynext,z);
0118           xprev = xnext;
0119           yprev = ynext;
0120         }
0121       }
0122 
0123     } else if(style.value()==marker_square_line) {
0124       std::vector<float>::const_iterator it;
0125       for(it=_xyzs.begin();it!=_xyzs.end();){
0126         x = *it;it++;
0127         y = *it;it++;
0128         z = *it;it++;
0129         a_action.project_point(x,y,z,w); //in [-1,1][-1,1]
0130         _add(pts, x-hsx,y-hsy,z);
0131         _add(pts, x+hsx,y-hsy,z);
0132 
0133         _add(pts, x+hsx,y-hsy,z);
0134         _add(pts, x+hsx,y+hsy,z);
0135 
0136         _add(pts, x+hsx,y+hsy,z);
0137         _add(pts, x-hsx,y+hsy,z);
0138 
0139         _add(pts, x-hsx,y+hsy,z);
0140         _add(pts, x-hsx,y-hsy,z);
0141       }
0142     } else if((style.value()==marker_square_filled)||(style.value()==marker_dot)) {
0143       filled = true;
0144       std::vector<float>::const_iterator it;
0145       for(it=_xyzs.begin();it!=_xyzs.end();){
0146         x = *it;it++;
0147         y = *it;it++;
0148         z = *it;it++;
0149         a_action.project_point(x,y,z,w); //in [-1,1][-1,1]
0150         _add(pts, x-hsx,y-hsy,z);
0151         _add(pts, x+hsx,y-hsy,z);
0152         _add(pts, x+hsx,y+hsy,z);
0153 
0154         _add(pts, x-hsx,y-hsy,z);
0155         _add(pts, x+hsx,y+hsy,z);
0156         _add(pts, x-hsx,y+hsy,z);
0157       }
0158 
0159     } else if(style.value()==marker_triangle_up_line) {
0160       std::vector<float>::const_iterator it;
0161       for(it=_xyzs.begin();it!=_xyzs.end();){
0162         x = *it;it++;
0163         y = *it;it++;
0164         z = *it;it++;
0165         a_action.project_point(x,y,z,w); //in [-1,1][-1,1]
0166         _add(pts, x-hsx,y-hsy,z);
0167         _add(pts, x+hsx,y-hsy,z);
0168 
0169         _add(pts, x+hsx,y-hsy,z);
0170         _add(pts, x    ,y+hsy,z);
0171 
0172         _add(pts, x    ,y+hsy,z);
0173         _add(pts, x-hsx,y-hsy,z);
0174       }
0175     } else if(style.value()==marker_triangle_up_filled) {
0176       filled = true;
0177       std::vector<float>::const_iterator it;
0178       for(it=_xyzs.begin();it!=_xyzs.end();){
0179         x = *it;it++;
0180         y = *it;it++;
0181         z = *it;it++;
0182         a_action.project_point(x,y,z,w); //in [-1,1][-1,1]
0183         _add(pts, x-hsx,y-hsy,z);
0184         _add(pts, x+hsx,y-hsy,z);
0185         _add(pts, x    ,y+hsy,z);
0186       }
0187 
0188     } else if(style.value()==marker_triangle_down_line) {
0189       std::vector<float>::const_iterator it;
0190       for(it=_xyzs.begin();it!=_xyzs.end();){
0191         x = *it;it++;
0192         y = *it;it++;
0193         z = *it;it++;
0194         a_action.project_point(x,y,z,w); //in [-1,1][-1,1]
0195         _add(pts, x-hsx,y+hsy,z);
0196         _add(pts, x    ,y-hsy,z);
0197 
0198         _add(pts, x    ,y-hsy,z);
0199         _add(pts, x+hsx,y+hsy,z);
0200 
0201         _add(pts, x+hsx,y+hsy,z);
0202         _add(pts, x-hsx,y+hsy,z);
0203       }
0204     } else if(style.value()==marker_triangle_down_filled) {
0205       filled = true;
0206       std::vector<float>::const_iterator it;
0207       for(it=_xyzs.begin();it!=_xyzs.end();){
0208         x = *it;it++;
0209         y = *it;it++;
0210         z = *it;it++;
0211         a_action.project_point(x,y,z,w); //in [-1,1][-1,1]
0212         _add(pts, x-hsx,y+hsy,z);
0213         _add(pts, x    ,y-hsy,z);
0214         _add(pts, x+hsx,y+hsy,z);
0215       }
0216 
0217     } else if(style.value()==marker_diamond_line) {
0218       std::vector<float>::const_iterator it;
0219       for(it=_xyzs.begin();it!=_xyzs.end();){
0220         x = *it;it++;
0221         y = *it;it++;
0222         z = *it;it++;
0223         a_action.project_point(x,y,z,w); //in [-1,1][-1,1]
0224         _add(pts, x    ,y-hsy,z);
0225         _add(pts, x+hsx,    y,z);
0226 
0227         _add(pts, x+hsx,    y,z);
0228         _add(pts, x    ,y+hsy,z);
0229 
0230         _add(pts, x    ,y+hsy,z);
0231         _add(pts, x-hsx,y    ,z);
0232 
0233         _add(pts, x-hsx,y    ,z);
0234         _add(pts, x    ,y-hsy,z);
0235       }
0236     } else if(style.value()==marker_diamond_filled) {
0237       filled = true;
0238       std::vector<float>::const_iterator it;
0239       for(it=_xyzs.begin();it!=_xyzs.end();){
0240         x = *it;it++;
0241         y = *it;it++;
0242         z = *it;it++;
0243         a_action.project_point(x,y,z,w); //in [-1,1][-1,1]
0244         _add(pts, x    ,y-hsy,z);
0245         _add(pts, x+hsx,    y,z);
0246         _add(pts, x    ,y+hsy,z);
0247 
0248         _add(pts, x    ,y+hsy,z);
0249         _add(pts, x-hsx,y    ,z);
0250         _add(pts, x    ,y-hsy,z);
0251       }
0252 
0253     } else if(style.value()==marker_swiss_cross_line) {
0254       std::vector<float>::const_iterator it;
0255       for(it=_xyzs.begin();it!=_xyzs.end();){
0256         x = *it;it++;
0257         y = *it;it++;
0258         z = *it;it++;
0259         a_action.project_point(x,y,z,w); //in [-1,1][-1,1]
0260         _add(pts, x-hsx2,y-hsy,z);
0261         _add(pts, x+hsx2,y-hsy,z);
0262 
0263         _add(pts, x+hsx2,y-hsy ,z);
0264         _add(pts, x+hsx2,y-hsy2,z);
0265 
0266         _add(pts, x+hsx2,y-hsy2,z);
0267         _add(pts, x+hsx ,y-hsy2,z);
0268 
0269         _add(pts, x+hsx ,y-hsy2,z);
0270         _add(pts, x+hsx ,y+hsy2,z);
0271 
0272         _add(pts, x+hsx ,y+hsy2,z);
0273         _add(pts, x+hsx2,y+hsy2,z);
0274 
0275         _add(pts, x+hsx2,y+hsy2,z);
0276         _add(pts, x+hsx2,y+hsy ,z);
0277 
0278         _add(pts, x+hsx2,y+hsy ,z);
0279         _add(pts, x-hsx2,y+hsy ,z);
0280 
0281         _add(pts, x-hsx2,y+hsy ,z);
0282         _add(pts, x-hsx2,y+hsy2,z);
0283 
0284         _add(pts, x-hsx2,y+hsy2,z);
0285         _add(pts, x-hsx ,y+hsy2,z);
0286 
0287         _add(pts, x-hsx ,y+hsy2,z);
0288         _add(pts, x-hsx ,y-hsy2,z);
0289 
0290         _add(pts, x-hsx ,y-hsy2,z);
0291         _add(pts, x-hsx2,y-hsy2,z);
0292 
0293         _add(pts, x-hsx2,y-hsy2,z);
0294         _add(pts, x-hsx2,y-hsy, z);
0295       }
0296     } else if(style.value()==marker_swiss_cross_filled) {
0297       filled = true;
0298       std::vector<float>::const_iterator it;
0299       for(it=_xyzs.begin();it!=_xyzs.end();){
0300         x = *it;it++;
0301         y = *it;it++;
0302         z = *it;it++;
0303         a_action.project_point(x,y,z,w); //in [-1,1][-1,1]
0304         _add(pts, x-hsx2,y-hsy,z);
0305         _add(pts, x+hsx2,y-hsy,z);
0306         _add(pts, x+hsx2,y+hsy,z);
0307 
0308         _add(pts, x+hsx2,y+hsy,z);
0309         _add(pts, x-hsx2,y+hsy,z);
0310         _add(pts, x-hsx2,y-hsy,z);
0311 
0312         _add(pts, x-hsx ,y-hsy2,z);
0313         _add(pts, x+hsx ,y-hsy2,z);
0314         _add(pts, x+hsx ,y+hsy2,z);
0315 
0316         _add(pts, x+hsx ,y+hsy2,z);
0317         _add(pts, x-hsx ,y+hsy2,z);
0318         _add(pts, x-hsx ,y-hsy2,z);
0319       }
0320 
0321     } else if(style.value()==marker_david_star_line) {
0322       std::vector<float>::const_iterator it;
0323       for(it=_xyzs.begin();it!=_xyzs.end();){
0324         x = *it;it++;
0325         y = *it;it++;
0326         z = *it;it++;
0327         a_action.project_point(x,y,z,w); //in [-1,1][-1,1]
0328         _add(pts, x-hsx,y-hsy2,z);
0329         _add(pts, x+hsx,y-hsy2,z);
0330 
0331         _add(pts, x+hsx,y-hsy2,z);
0332         _add(pts, x    ,y+hsy ,z);
0333 
0334         _add(pts, x    ,y+hsy ,z);
0335         _add(pts, x-hsx,y-hsy2,z);
0336 
0337         _add(pts, x+hsx,y+hsy2,z);
0338         _add(pts, x-hsx,y+hsy2,z);
0339 
0340         _add(pts, x-hsx,y+hsy2,z);
0341         _add(pts, x    ,y-hsy ,z);
0342 
0343         _add(pts, x    ,y-hsy ,z);
0344         _add(pts, x+hsx,y+hsy2,z);
0345       }
0346     } else if(style.value()==marker_david_star_filled) {
0347       filled = true;
0348       std::vector<float>::const_iterator it;
0349       for(it=_xyzs.begin();it!=_xyzs.end();){
0350         x = *it;it++;
0351         y = *it;it++;
0352         z = *it;it++;
0353         a_action.project_point(x,y,z,w); //in [-1,1][-1,1]
0354         _add(pts, x-hsx,y-hsy2,z);
0355         _add(pts, x+hsx,y-hsy2,z);
0356         _add(pts, x    ,y+hsy ,z);
0357 
0358         _add(pts, x+hsx,y+hsy2,z);
0359         _add(pts, x-hsx,y+hsy2,z);
0360         _add(pts, x    ,y-hsy ,z);
0361       }
0362 
0363     } else if(style.value()==marker_penta_star_line) {
0364       float _cos[5];float _sin[5];
0365       float dtheta = ftwo_pi()/5.0f;
0366       float theta = fhalf_pi();
0367      {for(unsigned int i=0;i<5;i++,theta+=dtheta) {_cos[i] = rad*fcos(theta);_sin[i] = rad*fsin(theta);}}
0368       std::vector<float>::const_iterator it;
0369       for(it=_xyzs.begin();it!=_xyzs.end();){
0370         x = *it;it++;
0371         y = *it;it++;
0372         z = *it;it++;
0373         a_action.project_point(x,y,z,w); //in [-1,1][-1,1]
0374         _add(pts, x+_cos[0],y+_sin[0] ,z);
0375         _add(pts, x+_cos[2],y+_sin[2] ,z);
0376 
0377         _add(pts, x+_cos[2],y+_sin[2] ,z);
0378         _add(pts, x+_cos[4],y+_sin[4] ,z);
0379 
0380         _add(pts, x+_cos[4],y+_sin[4] ,z);
0381         _add(pts, x+_cos[1],y+_sin[1] ,z);
0382 
0383         _add(pts, x+_cos[1],y+_sin[1] ,z);
0384         _add(pts, x+_cos[3],y+_sin[3] ,z);
0385 
0386         _add(pts, x+_cos[3],y+_sin[3] ,z);
0387         _add(pts, x+_cos[0],y+_sin[0] ,z);
0388       }
0389     } else if(style.value()==marker_penta_star_filled) {
0390       filled = true;
0391       float _cos[5];float _sin[5];
0392       float dtheta = ftwo_pi()/5.0f;
0393       float theta = fhalf_pi();
0394      {for(unsigned int i=0;i<5;i++,theta+=dtheta) {_cos[i] = rad*fcos(theta);_sin[i] = rad*fsin(theta);}}
0395       vec2f i3;
0396      {vec2f p1(_cos[2],_sin[2]);
0397       vec2f q1(_cos[4],_sin[4]);
0398       vec2f p2(_cos[3],_sin[3]);
0399       vec2f q2(_cos[0],_sin[0]);
0400       if(!intersect(p1,q1,p2,q2,i3)) {}}
0401       vec2f i4;
0402      {vec2f p1(_cos[1],_sin[1]);
0403       vec2f q1(_cos[4],_sin[4]);
0404       vec2f p2(_cos[3],_sin[3]);
0405       vec2f q2(_cos[0],_sin[0]);
0406       if(!intersect(p1,q1,p2,q2,i4)) {}}
0407       vec2f i0;
0408      {vec2f p1(_cos[1],_sin[1]);
0409       vec2f q1(_cos[4],_sin[4]);
0410       vec2f p2(_cos[0],_sin[0]);
0411       vec2f q2(_cos[2],_sin[2]);
0412       if(!intersect(p1,q1,p2,q2,i0)) {}}
0413       std::vector<float>::const_iterator it;
0414       for(it=_xyzs.begin();it!=_xyzs.end();){
0415         x = *it;it++;
0416         y = *it;it++;
0417         z = *it;it++;
0418         a_action.project_point(x,y,z,w); //in [-1,1][-1,1]
0419         _add(pts, x+_cos[0],y+_sin[0] ,z);
0420         _add(pts, x+_cos[2],y+_sin[2] ,z);
0421         _add(pts, x+ i3.x(),y+ i3.y() ,z);
0422 
0423         _add(pts, x+_cos[1],y+_sin[1] ,z);
0424         _add(pts, x+_cos[3],y+_sin[3] ,z);
0425         _add(pts, x+ i4.x(),y+ i4.y() ,z);
0426 
0427         _add(pts, x+ i0.x(),y+ i0.y() ,z);
0428         _add(pts, x+_cos[2],y+_sin[2] ,z);
0429         _add(pts, x+_cos[4],y+_sin[4] ,z);
0430       }
0431 
0432     } else if(style.value()==marker_plus) {
0433       std::vector<float>::const_iterator it;
0434       for(it=_xyzs.begin();it!=_xyzs.end();){
0435         x = *it;it++;
0436         y = *it;it++;
0437         z = *it;it++;
0438         a_action.project_point(x,y,z,w); //in [-1,1][-1,1]
0439         _add(pts, x-hsx,y,z);
0440         _add(pts, x+hsx,y,z);
0441         _add(pts, x    ,y-hsy,z);
0442         _add(pts, x    ,y+hsy,z);
0443       }
0444     } else if(style.value()==marker_asterisk) {
0445       std::vector<float>::const_iterator it;
0446       for(it=_xyzs.begin();it!=_xyzs.end();){
0447         x = *it;it++;
0448         y = *it;it++;
0449         z = *it;it++;
0450         a_action.project_point(x,y,z,w); //in [-1,1][-1,1]
0451         _add(pts, x    ,y-hsy ,z);
0452         _add(pts, x    ,y+hsy ,z);
0453         _add(pts, x-hsx,y-hsy2,z);
0454         _add(pts, x+hsx,y+hsy2,z);
0455         _add(pts, x-hsx,y+hsy2,z);
0456         _add(pts, x+hsx,y-hsy2,z);
0457       }
0458     } else if(style.value()==marker_star) {
0459       std::vector<float>::const_iterator it;
0460       for(it=_xyzs.begin();it!=_xyzs.end();){
0461         x = *it;it++;
0462         y = *it;it++;
0463         z = *it;it++;
0464         a_action.project_point(x,y,z,w); //in [-1,1][-1,1]
0465         _add(pts, x    ,y-hsy ,z);
0466         _add(pts, x    ,y+hsy ,z);
0467         _add(pts, x-hsx,y-hsy2,z);
0468         _add(pts, x+hsx,y+hsy2,z);
0469         _add(pts, x-hsx,y+hsy2,z);
0470         _add(pts, x+hsx,y-hsy2,z);
0471         _add(pts, x-hsx,y     ,z);
0472         _add(pts, x+hsx,y     ,z);
0473       }
0474     } else if(style.value()==marker_minus) {
0475       std::vector<float>::const_iterator it;
0476       for(it=_xyzs.begin();it!=_xyzs.end();){
0477         x = *it;it++;
0478         y = *it;it++;
0479         z = *it;it++;
0480         a_action.project_point(x,y,z,w); //in [-1,1][-1,1]
0481         _add(pts, x-hsx,y,z);
0482         _add(pts, x+hsx,y,z);
0483       }
0484     } else { //marker_cross.
0485       std::vector<float>::const_iterator it;
0486       for(it=_xyzs.begin();it!=_xyzs.end();){
0487         x = *it;it++;
0488         y = *it;it++;
0489         z = *it;it++;
0490         a_action.project_point(x,y,z,w); //in [-1,1][-1,1]
0491         _add(pts, x-hsx,y-hsy,z);
0492         _add(pts, x+hsx,y+hsy,z);
0493         _add(pts, x+hsx,y-hsy,z);
0494         _add(pts, x-hsx,y+hsy,z);
0495       }
0496     }
0497 
0498     a_action.load_matrices_to_identity();
0499 
0500     //Same logic as Inventor SoLightModel.model = BASE_COLOR.
0501     a_action.set_lighting(false);
0502     a_action.draw_vertex_array(filled?gl::triangles():gl::lines(),pts);
0503     a_action.set_lighting(a_action.state().m_GL_LIGHTING);
0504     a_action.load_matrices_from_state();
0505   }
0506 
0507   virtual void pick(pick_action& a_action) {
0508     size_t num = xyzs.size()/3;
0509     if(!num) return;
0510 
0511     state& state = a_action.state();
0512 
0513     const std::vector<float>& _xyzs = xyzs.values();
0514 
0515     std::vector<float> pts;
0516 
0517     float sx = size.value()/float(state.m_ww); //in [-1,1]
0518     float hsx = sx*0.5f;
0519 
0520     float sy = size.value()/float(state.m_wh); //in [-1,1]
0521     float hsy = sy*0.5f;
0522 
0523     float x,y,z,w;
0524 
0525     std::vector<float>::const_iterator it;
0526     for(it=_xyzs.begin();it!=_xyzs.end();){
0527       x = *it;it++;
0528       y = *it;it++;
0529       z = *it;it++;
0530 
0531       a_action.project_point(x,y,z,w); //in [-1,1][-1,1]
0532 
0533       _add(pts, x-hsx,y-hsy,z);  //in [-1,1][-1,1]
0534       _add(pts, x+hsx,y+hsy,z);
0535       _add(pts, x+hsx,y-hsy,z);
0536       _add(pts, x-hsx,y+hsy,z);
0537     }
0538 
0539     a_action.set_matrices_to_identity();
0540     a_action.add__lines(*this,pts);
0541     a_action.set_matrices_from_state();
0542   }
0543 
0544   virtual void bbox(bbox_action& a_action) {
0545     const std::vector<float>& _xyzs = xyzs.values();
0546     float x,y,z;
0547     std::vector<float>::const_iterator it;
0548     for(it=_xyzs.begin();it!=_xyzs.end();){
0549       x = *it;it++;
0550       y = *it;it++;
0551       z = *it;it++;
0552       a_action.add_one_point(x,y,z);
0553     }
0554   }
0555 public:
0556   markers()
0557   :parent()
0558   ,style(marker_cross)
0559   ,size(10)
0560   {
0561     add_fields();
0562   }
0563   virtual ~markers(){
0564   }
0565 public:
0566   markers(const markers& a_from)
0567   :parent(a_from)
0568   ,style(a_from.style)
0569   ,xyzs(a_from.xyzs)
0570   ,size(a_from.size)
0571   {
0572     add_fields();
0573   }
0574   markers& operator=(const markers& a_from){
0575     parent::operator=(a_from);
0576     style = a_from.style;
0577     xyzs = a_from.xyzs;
0578     size = a_from.size;
0579     return *this;
0580   }
0581 public:
0582   template <class VEC>
0583   void add(const VEC& a_v) {
0584     xyzs.add(a_v.x());
0585     xyzs.add(a_v.y());
0586     xyzs.add(a_v.z());
0587   }
0588   void add(float a_x,float a_y,float a_z) {
0589     xyzs.add(a_x);
0590     xyzs.add(a_y);
0591     xyzs.add(a_z);
0592   }
0593   void add_allocated(size_t& a_pos,float a_x,float a_y,float a_z) {
0594     std::vector<float>& v = xyzs.values();
0595     v[a_pos] = a_x;a_pos++;
0596     v[a_pos] = a_y;a_pos++;
0597     v[a_pos] = a_z;a_pos++;
0598     xyzs.touch();
0599   }
0600   bool add(const std::vector<float>& a_v) {
0601     std::vector<float>::size_type _number = a_v.size()/3;
0602     if(3*_number!=a_v.size()) return false;
0603     std::vector<float>::const_iterator it;
0604     for(it=a_v.begin();it!=a_v.end();it+=3) {
0605       xyzs.add(*(it+0));
0606       xyzs.add(*(it+1));
0607       xyzs.add(*(it+2));
0608     }
0609     return true;
0610   }
0611   size_t number() const {return xyzs.size()/3;}
0612   void clear() {xyzs.clear();}
0613 protected:
0614   void _add(std::vector<float>& a_v,float a_x,float a_y,float a_z) {
0615     a_v.push_back(a_x);
0616     a_v.push_back(a_y);
0617     a_v.push_back(a_z);
0618   }
0619 };
0620 
0621 }}
0622 
0623 #endif