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 //} else if((style.value()==marker_circle_filled)||(style.value()==marker_dot)) {
0098 filled = true;
0099 unsigned int segs = 16;
0100 float _cos[16];float _sin[16];
0101 float dtheta = ftwo_pi()/float(segs);
0102 float theta = dtheta;
0103 {for(unsigned int i=0;i<segs;i++,theta+=dtheta) {_cos[i] = rad*fcos(theta);_sin[i] = rad*fsin(theta);}}
0104 float xprev,yprev,xnext,ynext;
0105 std::vector<float>::const_iterator it;
0106 for(it=_xyzs.begin();it!=_xyzs.end();){
0107 x = *it;it++;
0108 y = *it;it++;
0109 z = *it;it++;
0110 a_action.project_point(x,y,z,w); //in [-1,1][-1,1]
0111 xprev = x+rad;
0112 yprev = y;
0113 for(unsigned int i=0;i<segs;i++) {
0114 xnext = x+_cos[i];
0115 ynext = y+_sin[i];
0116 _add(pts,x ,y ,z);
0117 _add(pts,xprev,yprev,z);
0118 _add(pts,xnext,ynext,z);
0119 xprev = xnext;
0120 yprev = ynext;
0121 }
0122 }
0123
0124 } else if(style.value()==marker_square_line) {
0125 std::vector<float>::const_iterator it;
0126 for(it=_xyzs.begin();it!=_xyzs.end();){
0127 x = *it;it++;
0128 y = *it;it++;
0129 z = *it;it++;
0130 a_action.project_point(x,y,z,w); //in [-1,1][-1,1]
0131 _add(pts, x-hsx,y-hsy,z);
0132 _add(pts, x+hsx,y-hsy,z);
0133
0134 _add(pts, x+hsx,y-hsy,z);
0135 _add(pts, x+hsx,y+hsy,z);
0136
0137 _add(pts, x+hsx,y+hsy,z);
0138 _add(pts, x-hsx,y+hsy,z);
0139
0140 _add(pts, x-hsx,y+hsy,z);
0141 _add(pts, x-hsx,y-hsy,z);
0142 }
0143 //} else if(style.value()==marker_square_filled) {
0144 } else if((style.value()==marker_square_filled)||(style.value()==marker_dot)) {
0145 filled = true;
0146 std::vector<float>::const_iterator it;
0147 for(it=_xyzs.begin();it!=_xyzs.end();){
0148 x = *it;it++;
0149 y = *it;it++;
0150 z = *it;it++;
0151 a_action.project_point(x,y,z,w); //in [-1,1][-1,1]
0152 _add(pts, x-hsx,y-hsy,z);
0153 _add(pts, x+hsx,y-hsy,z);
0154 _add(pts, x+hsx,y+hsy,z);
0155
0156 _add(pts, x-hsx,y-hsy,z);
0157 _add(pts, x+hsx,y+hsy,z);
0158 _add(pts, x-hsx,y+hsy,z);
0159 }
0160
0161 } else if(style.value()==marker_triangle_up_line) {
0162 std::vector<float>::const_iterator it;
0163 for(it=_xyzs.begin();it!=_xyzs.end();){
0164 x = *it;it++;
0165 y = *it;it++;
0166 z = *it;it++;
0167 a_action.project_point(x,y,z,w); //in [-1,1][-1,1]
0168 _add(pts, x-hsx,y-hsy,z);
0169 _add(pts, x+hsx,y-hsy,z);
0170
0171 _add(pts, x+hsx,y-hsy,z);
0172 _add(pts, x ,y+hsy,z);
0173
0174 _add(pts, x ,y+hsy,z);
0175 _add(pts, x-hsx,y-hsy,z);
0176 }
0177 } else if(style.value()==marker_triangle_up_filled) {
0178 filled = true;
0179 std::vector<float>::const_iterator it;
0180 for(it=_xyzs.begin();it!=_xyzs.end();){
0181 x = *it;it++;
0182 y = *it;it++;
0183 z = *it;it++;
0184 a_action.project_point(x,y,z,w); //in [-1,1][-1,1]
0185 _add(pts, x-hsx,y-hsy,z);
0186 _add(pts, x+hsx,y-hsy,z);
0187 _add(pts, x ,y+hsy,z);
0188 }
0189
0190 } else if(style.value()==marker_triangle_down_line) {
0191 std::vector<float>::const_iterator it;
0192 for(it=_xyzs.begin();it!=_xyzs.end();){
0193 x = *it;it++;
0194 y = *it;it++;
0195 z = *it;it++;
0196 a_action.project_point(x,y,z,w); //in [-1,1][-1,1]
0197 _add(pts, x-hsx,y+hsy,z);
0198 _add(pts, x ,y-hsy,z);
0199
0200 _add(pts, x ,y-hsy,z);
0201 _add(pts, x+hsx,y+hsy,z);
0202
0203 _add(pts, x+hsx,y+hsy,z);
0204 _add(pts, x-hsx,y+hsy,z);
0205 }
0206 } else if(style.value()==marker_triangle_down_filled) {
0207 filled = true;
0208 std::vector<float>::const_iterator it;
0209 for(it=_xyzs.begin();it!=_xyzs.end();){
0210 x = *it;it++;
0211 y = *it;it++;
0212 z = *it;it++;
0213 a_action.project_point(x,y,z,w); //in [-1,1][-1,1]
0214 _add(pts, x-hsx,y+hsy,z);
0215 _add(pts, x ,y-hsy,z);
0216 _add(pts, x+hsx,y+hsy,z);
0217 }
0218
0219 } else if(style.value()==marker_diamond_line) {
0220 std::vector<float>::const_iterator it;
0221 for(it=_xyzs.begin();it!=_xyzs.end();){
0222 x = *it;it++;
0223 y = *it;it++;
0224 z = *it;it++;
0225 a_action.project_point(x,y,z,w); //in [-1,1][-1,1]
0226 _add(pts, x ,y-hsy,z);
0227 _add(pts, x+hsx, y,z);
0228
0229 _add(pts, x+hsx, y,z);
0230 _add(pts, x ,y+hsy,z);
0231
0232 _add(pts, x ,y+hsy,z);
0233 _add(pts, x-hsx,y ,z);
0234
0235 _add(pts, x-hsx,y ,z);
0236 _add(pts, x ,y-hsy,z);
0237 }
0238 } else if(style.value()==marker_diamond_filled) {
0239 filled = true;
0240 std::vector<float>::const_iterator it;
0241 for(it=_xyzs.begin();it!=_xyzs.end();){
0242 x = *it;it++;
0243 y = *it;it++;
0244 z = *it;it++;
0245 a_action.project_point(x,y,z,w); //in [-1,1][-1,1]
0246 _add(pts, x ,y-hsy,z);
0247 _add(pts, x+hsx, y,z);
0248 _add(pts, x ,y+hsy,z);
0249
0250 _add(pts, x ,y+hsy,z);
0251 _add(pts, x-hsx,y ,z);
0252 _add(pts, x ,y-hsy,z);
0253 }
0254
0255 } else if(style.value()==marker_swiss_cross_line) {
0256 std::vector<float>::const_iterator it;
0257 for(it=_xyzs.begin();it!=_xyzs.end();){
0258 x = *it;it++;
0259 y = *it;it++;
0260 z = *it;it++;
0261 a_action.project_point(x,y,z,w); //in [-1,1][-1,1]
0262 _add(pts, x-hsx2,y-hsy,z);
0263 _add(pts, x+hsx2,y-hsy,z);
0264
0265 _add(pts, x+hsx2,y-hsy ,z);
0266 _add(pts, x+hsx2,y-hsy2,z);
0267
0268 _add(pts, x+hsx2,y-hsy2,z);
0269 _add(pts, x+hsx ,y-hsy2,z);
0270
0271 _add(pts, x+hsx ,y-hsy2,z);
0272 _add(pts, x+hsx ,y+hsy2,z);
0273
0274 _add(pts, x+hsx ,y+hsy2,z);
0275 _add(pts, x+hsx2,y+hsy2,z);
0276
0277 _add(pts, x+hsx2,y+hsy2,z);
0278 _add(pts, x+hsx2,y+hsy ,z);
0279
0280 _add(pts, x+hsx2,y+hsy ,z);
0281 _add(pts, x-hsx2,y+hsy ,z);
0282
0283 _add(pts, x-hsx2,y+hsy ,z);
0284 _add(pts, x-hsx2,y+hsy2,z);
0285
0286 _add(pts, x-hsx2,y+hsy2,z);
0287 _add(pts, x-hsx ,y+hsy2,z);
0288
0289 _add(pts, x-hsx ,y+hsy2,z);
0290 _add(pts, x-hsx ,y-hsy2,z);
0291
0292 _add(pts, x-hsx ,y-hsy2,z);
0293 _add(pts, x-hsx2,y-hsy2,z);
0294
0295 _add(pts, x-hsx2,y-hsy2,z);
0296 _add(pts, x-hsx2,y-hsy, z);
0297 }
0298 } else if(style.value()==marker_swiss_cross_filled) {
0299 filled = true;
0300 std::vector<float>::const_iterator it;
0301 for(it=_xyzs.begin();it!=_xyzs.end();){
0302 x = *it;it++;
0303 y = *it;it++;
0304 z = *it;it++;
0305 a_action.project_point(x,y,z,w); //in [-1,1][-1,1]
0306 _add(pts, x-hsx2,y-hsy,z);
0307 _add(pts, x+hsx2,y-hsy,z);
0308 _add(pts, x+hsx2,y+hsy,z);
0309
0310 _add(pts, x+hsx2,y+hsy,z);
0311 _add(pts, x-hsx2,y+hsy,z);
0312 _add(pts, x-hsx2,y-hsy,z);
0313
0314 _add(pts, x-hsx ,y-hsy2,z);
0315 _add(pts, x+hsx ,y-hsy2,z);
0316 _add(pts, x+hsx ,y+hsy2,z);
0317
0318 _add(pts, x+hsx ,y+hsy2,z);
0319 _add(pts, x-hsx ,y+hsy2,z);
0320 _add(pts, x-hsx ,y-hsy2,z);
0321 }
0322
0323 } else if(style.value()==marker_david_star_line) {
0324 std::vector<float>::const_iterator it;
0325 for(it=_xyzs.begin();it!=_xyzs.end();){
0326 x = *it;it++;
0327 y = *it;it++;
0328 z = *it;it++;
0329 a_action.project_point(x,y,z,w); //in [-1,1][-1,1]
0330 _add(pts, x-hsx,y-hsy2,z);
0331 _add(pts, x+hsx,y-hsy2,z);
0332
0333 _add(pts, x+hsx,y-hsy2,z);
0334 _add(pts, x ,y+hsy ,z);
0335
0336 _add(pts, x ,y+hsy ,z);
0337 _add(pts, x-hsx,y-hsy2,z);
0338
0339 _add(pts, x+hsx,y+hsy2,z);
0340 _add(pts, x-hsx,y+hsy2,z);
0341
0342 _add(pts, x-hsx,y+hsy2,z);
0343 _add(pts, x ,y-hsy ,z);
0344
0345 _add(pts, x ,y-hsy ,z);
0346 _add(pts, x+hsx,y+hsy2,z);
0347 }
0348 } else if(style.value()==marker_david_star_filled) {
0349 filled = true;
0350 std::vector<float>::const_iterator it;
0351 for(it=_xyzs.begin();it!=_xyzs.end();){
0352 x = *it;it++;
0353 y = *it;it++;
0354 z = *it;it++;
0355 a_action.project_point(x,y,z,w); //in [-1,1][-1,1]
0356 _add(pts, x-hsx,y-hsy2,z);
0357 _add(pts, x+hsx,y-hsy2,z);
0358 _add(pts, x ,y+hsy ,z);
0359
0360 _add(pts, x+hsx,y+hsy2,z);
0361 _add(pts, x-hsx,y+hsy2,z);
0362 _add(pts, x ,y-hsy ,z);
0363 }
0364
0365 } else if(style.value()==marker_penta_star_line) {
0366 float _cos[5];float _sin[5];
0367 float dtheta = ftwo_pi()/5.0f;
0368 float theta = fhalf_pi();
0369 {for(unsigned int i=0;i<5;i++,theta+=dtheta) {_cos[i] = rad*fcos(theta);_sin[i] = rad*fsin(theta);}}
0370 std::vector<float>::const_iterator it;
0371 for(it=_xyzs.begin();it!=_xyzs.end();){
0372 x = *it;it++;
0373 y = *it;it++;
0374 z = *it;it++;
0375 a_action.project_point(x,y,z,w); //in [-1,1][-1,1]
0376 _add(pts, x+_cos[0],y+_sin[0] ,z);
0377 _add(pts, x+_cos[2],y+_sin[2] ,z);
0378
0379 _add(pts, x+_cos[2],y+_sin[2] ,z);
0380 _add(pts, x+_cos[4],y+_sin[4] ,z);
0381
0382 _add(pts, x+_cos[4],y+_sin[4] ,z);
0383 _add(pts, x+_cos[1],y+_sin[1] ,z);
0384
0385 _add(pts, x+_cos[1],y+_sin[1] ,z);
0386 _add(pts, x+_cos[3],y+_sin[3] ,z);
0387
0388 _add(pts, x+_cos[3],y+_sin[3] ,z);
0389 _add(pts, x+_cos[0],y+_sin[0] ,z);
0390 }
0391 } else if(style.value()==marker_penta_star_filled) {
0392 filled = true;
0393 float _cos[5];float _sin[5];
0394 float dtheta = ftwo_pi()/5.0f;
0395 float theta = fhalf_pi();
0396 {for(unsigned int i=0;i<5;i++,theta+=dtheta) {_cos[i] = rad*fcos(theta);_sin[i] = rad*fsin(theta);}}
0397 vec2f i3;
0398 {vec2f p1(_cos[2],_sin[2]);
0399 vec2f q1(_cos[4],_sin[4]);
0400 vec2f p2(_cos[3],_sin[3]);
0401 vec2f q2(_cos[0],_sin[0]);
0402 if(!intersect(p1,q1,p2,q2,i3)) {}}
0403 vec2f i4;
0404 {vec2f p1(_cos[1],_sin[1]);
0405 vec2f q1(_cos[4],_sin[4]);
0406 vec2f p2(_cos[3],_sin[3]);
0407 vec2f q2(_cos[0],_sin[0]);
0408 if(!intersect(p1,q1,p2,q2,i4)) {}}
0409 vec2f i0;
0410 {vec2f p1(_cos[1],_sin[1]);
0411 vec2f q1(_cos[4],_sin[4]);
0412 vec2f p2(_cos[0],_sin[0]);
0413 vec2f q2(_cos[2],_sin[2]);
0414 if(!intersect(p1,q1,p2,q2,i0)) {}}
0415 std::vector<float>::const_iterator it;
0416 for(it=_xyzs.begin();it!=_xyzs.end();){
0417 x = *it;it++;
0418 y = *it;it++;
0419 z = *it;it++;
0420 a_action.project_point(x,y,z,w); //in [-1,1][-1,1]
0421 _add(pts, x+_cos[0],y+_sin[0] ,z);
0422 _add(pts, x+_cos[2],y+_sin[2] ,z);
0423 _add(pts, x+ i3.x(),y+ i3.y() ,z);
0424
0425 _add(pts, x+_cos[1],y+_sin[1] ,z);
0426 _add(pts, x+_cos[3],y+_sin[3] ,z);
0427 _add(pts, x+ i4.x(),y+ i4.y() ,z);
0428
0429 _add(pts, x+ i0.x(),y+ i0.y() ,z);
0430 _add(pts, x+_cos[2],y+_sin[2] ,z);
0431 _add(pts, x+_cos[4],y+_sin[4] ,z);
0432 }
0433
0434 } else if(style.value()==marker_plus) {
0435 std::vector<float>::const_iterator it;
0436 for(it=_xyzs.begin();it!=_xyzs.end();){
0437 x = *it;it++;
0438 y = *it;it++;
0439 z = *it;it++;
0440 a_action.project_point(x,y,z,w); //in [-1,1][-1,1]
0441 _add(pts, x-hsx,y,z);
0442 _add(pts, x+hsx,y,z);
0443 _add(pts, x ,y-hsy,z);
0444 _add(pts, x ,y+hsy,z);
0445 }
0446 } else if(style.value()==marker_asterisk) {
0447 std::vector<float>::const_iterator it;
0448 for(it=_xyzs.begin();it!=_xyzs.end();){
0449 x = *it;it++;
0450 y = *it;it++;
0451 z = *it;it++;
0452 a_action.project_point(x,y,z,w); //in [-1,1][-1,1]
0453 _add(pts, x ,y-hsy ,z);
0454 _add(pts, x ,y+hsy ,z);
0455 _add(pts, x-hsx,y-hsy2,z);
0456 _add(pts, x+hsx,y+hsy2,z);
0457 _add(pts, x-hsx,y+hsy2,z);
0458 _add(pts, x+hsx,y-hsy2,z);
0459 }
0460 } else if(style.value()==marker_star) {
0461 std::vector<float>::const_iterator it;
0462 for(it=_xyzs.begin();it!=_xyzs.end();){
0463 x = *it;it++;
0464 y = *it;it++;
0465 z = *it;it++;
0466 a_action.project_point(x,y,z,w); //in [-1,1][-1,1]
0467 _add(pts, x ,y-hsy ,z);
0468 _add(pts, x ,y+hsy ,z);
0469 _add(pts, x-hsx,y-hsy2,z);
0470 _add(pts, x+hsx,y+hsy2,z);
0471 _add(pts, x-hsx,y+hsy2,z);
0472 _add(pts, x+hsx,y-hsy2,z);
0473 _add(pts, x-hsx,y ,z);
0474 _add(pts, x+hsx,y ,z);
0475 }
0476 } else if(style.value()==marker_minus) {
0477 std::vector<float>::const_iterator it;
0478 for(it=_xyzs.begin();it!=_xyzs.end();){
0479 x = *it;it++;
0480 y = *it;it++;
0481 z = *it;it++;
0482 a_action.project_point(x,y,z,w); //in [-1,1][-1,1]
0483 _add(pts, x-hsx,y,z);
0484 _add(pts, x+hsx,y,z);
0485 }
0486 } else { //marker_cross.
0487 std::vector<float>::const_iterator it;
0488 for(it=_xyzs.begin();it!=_xyzs.end();){
0489 x = *it;it++;
0490 y = *it;it++;
0491 z = *it;it++;
0492 a_action.project_point(x,y,z,w); //in [-1,1][-1,1]
0493 _add(pts, x-hsx,y-hsy,z);
0494 _add(pts, x+hsx,y+hsy,z);
0495 _add(pts, x+hsx,y-hsy,z);
0496 _add(pts, x-hsx,y+hsy,z);
0497 }
0498 }
0499
0500 a_action.load_matrices_to_identity();
0501
0502 //Same logic as Inventor SoLightModel.model = BASE_COLOR.
0503 a_action.set_lighting(false);
0504 a_action.draw_vertex_array(filled?gl::triangles():gl::lines(),pts);
0505 a_action.set_lighting(a_action.state().m_GL_LIGHTING);
0506 a_action.load_matrices_from_state();
0507 }
0508
0509 virtual void pick(pick_action& a_action) {
0510 size_t num = xyzs.size()/3;
0511 if(!num) return;
0512
0513 state& state = a_action.state();
0514
0515 const std::vector<float>& _xyzs = xyzs.values();
0516
0517 std::vector<float> pts;
0518
0519 float sx = size.value()/float(state.m_ww); //in [-1,1]
0520 float hsx = sx*0.5f;
0521
0522 float sy = size.value()/float(state.m_wh); //in [-1,1]
0523 float hsy = sy*0.5f;
0524
0525 float x,y,z,w;
0526
0527 std::vector<float>::const_iterator it;
0528 for(it=_xyzs.begin();it!=_xyzs.end();){
0529 x = *it;it++;
0530 y = *it;it++;
0531 z = *it;it++;
0532
0533 a_action.project_point(x,y,z,w); //in [-1,1][-1,1]
0534
0535 _add(pts, x-hsx,y-hsy,z); //in [-1,1][-1,1]
0536 _add(pts, x+hsx,y+hsy,z);
0537 _add(pts, x+hsx,y-hsy,z);
0538 _add(pts, x-hsx,y+hsy,z);
0539 }
0540
0541 a_action.set_matrices_to_identity();
0542 a_action.add__lines(*this,pts);
0543 a_action.set_matrices_from_state();
0544 }
0545
0546 virtual void bbox(bbox_action& a_action) {
0547 const std::vector<float>& _xyzs = xyzs.values();
0548 float x,y,z;
0549 std::vector<float>::const_iterator it;
0550 for(it=_xyzs.begin();it!=_xyzs.end();){
0551 x = *it;it++;
0552 y = *it;it++;
0553 z = *it;it++;
0554 a_action.add_one_point(x,y,z);
0555 }
0556 }
0557 public:
0558 markers()
0559 :parent()
0560 ,style(marker_cross)
0561 ,size(10)
0562 {
0563 #ifdef TOOLS_MEM
0564 mem::increment(s_class().c_str());
0565 #endif
0566 add_fields();
0567 }
0568 virtual ~markers(){
0569 #ifdef TOOLS_MEM
0570 mem::decrement(s_class().c_str());
0571 #endif
0572 }
0573 public:
0574 markers(const markers& a_from)
0575 :parent(a_from)
0576 ,style(a_from.style)
0577 ,xyzs(a_from.xyzs)
0578 ,size(a_from.size)
0579 {
0580 #ifdef TOOLS_MEM
0581 mem::increment(s_class().c_str());
0582 #endif
0583 add_fields();
0584 }
0585 markers& operator=(const markers& a_from){
0586 parent::operator=(a_from);
0587 style = a_from.style;
0588 xyzs = a_from.xyzs;
0589 size = a_from.size;
0590 return *this;
0591 }
0592 public:
0593 template <class VEC>
0594 void add(const VEC& a_v) {
0595 xyzs.add(a_v.x());
0596 xyzs.add(a_v.y());
0597 xyzs.add(a_v.z());
0598 }
0599 void add(float a_x,float a_y,float a_z) {
0600 xyzs.add(a_x);
0601 xyzs.add(a_y);
0602 xyzs.add(a_z);
0603 }
0604 void add_allocated(size_t& a_pos,float a_x,float a_y,float a_z) {
0605 std::vector<float>& v = xyzs.values();
0606 v[a_pos] = a_x;a_pos++;
0607 v[a_pos] = a_y;a_pos++;
0608 v[a_pos] = a_z;a_pos++;
0609 xyzs.touch();
0610 }
0611 bool add(const std::vector<float>& a_v) {
0612 std::vector<float>::size_type _number = a_v.size()/3;
0613 if(3*_number!=a_v.size()) return false;
0614 std::vector<float>::const_iterator it;
0615 for(it=a_v.begin();it!=a_v.end();it+=3) {
0616 xyzs.add(*(it+0));
0617 xyzs.add(*(it+1));
0618 xyzs.add(*(it+2));
0619 }
0620 return true;
0621 }
0622 size_t number() const {return xyzs.size()/3;}
0623 void clear() {xyzs.clear();}
0624 protected:
0625 void _add(std::vector<float>& a_v,float a_x,float a_y,float a_z) {
0626 a_v.push_back(a_x);
0627 a_v.push_back(a_y);
0628 a_v.push_back(a_z);
0629 }
0630 };
0631
0632 }}
0633
0634 #endif