434{
436
437
438
440
441
442
443
444
445
446
447
448 std::vector<G4Point3D> vertices;
449 std::vector<G4Normal3D> normals;
450
451
452
453 typedef std::pair<G4Point3D,G4Point3D> Line;
454 std::vector<Line> lines;
455 auto insertIfNew = [&lines](const Line& newLine) {
456
457
458
459
460
461 lines.push_back(newLine);
462 };
463
466 do {
471 notLastFace = a_polyhedron.
GetNextFacet(nEdges, vertex, edgeFlag, normal);
472 vertices.push_back(vertex[0]);
473 vertices.push_back(vertex[1]);
474 vertices.push_back(vertex[2]);
475 normals.push_back(normal[0]);
476 normals.push_back(normal[1]);
477 normals.push_back(normal[2]);
478 if(isAuxilaryEdgeVisible||edgeFlag[0]>0)insertIfNew(Line(vertex[0],vertex[1]));
479 if(isAuxilaryEdgeVisible||edgeFlag[1]>0)insertIfNew(Line(vertex[1],vertex[2]));
480 if (nEdges == 3) {
481
482
483 if(isAuxilaryEdgeVisible||edgeFlag[2]>0)insertIfNew(Line(vertex[2],vertex[0]));
484 } else if (nEdges == 4) {
485
486
487 vertices.push_back(vertex[2]);
488 vertices.push_back(vertex[3]);
489 vertices.push_back(vertex[0]);
490 normals.push_back(normal[2]);
491 normals.push_back(normal[3]);
492 normals.push_back(normal[0]);
493 if(isAuxilaryEdgeVisible||edgeFlag[2]>0)insertIfNew(Line(vertex[2],vertex[3]));
494 if(isAuxilaryEdgeVisible||edgeFlag[3]>0)insertIfNew(Line(vertex[3],vertex[0]));
495 } else {
497 << "ERROR: polyhedron face with unexpected number of edges (" << nEdges << ')'
500 return;
501 }
502 } while (notLastFace);
503
505 switch (drawing_style) {
507
508 break;
510 break;
512
513 break;
515 break;
517
518 return;
519 }
520
522 if (!currentNode) return;
523
524 tools::sg::separator* sep = new tools::sg::separator;
525 currentNode->add(sep);
526
527
528 {tools::sg::matrix* mtx = new tools::sg::matrix;
533 0, 0, 0, 1);
534 sep->add(mtx);}
535
536 {
const auto& colour =
GetColour(a_polyhedron);
537 tools::sg::rgba* mat = new tools::sg::rgba();
538 mat->color =
539 tools::colorf(float(colour.GetRed()),
540 float(colour.GetGreen()),
541 float(colour.GetBlue()),
542 float(colour.GetAlpha()));
543 sep->add(mat);}
544
548
549 {tools::sg::draw_style* ds = new tools::sg::draw_style;
550 ds->style = tools::sg::draw_filled;
551
552 sep->add(ds);}
553
554 tools::sg::atb_vertices* vtxs = new tools::sg::atb_vertices;
555 vtxs->mode = tools::gl::triangles();
556 sep->add(vtxs);
557
558 const auto nVerts = vertices.size();
559 for (size_t i = 0; i < nVerts; i++) {
560 vtxs->add(float(vertices[i].x()),float(vertices[i].y()),float(vertices[i].z()));
561 vtxs->add_normal(float(normals[i].x()),float(normals[i].y()),float(normals[i].z()));
562 }
563 }
564
568
569 {tools::sg::draw_style* ds = new tools::sg::draw_style;
570 ds->style = tools::sg::draw_lines;
571 ds->line_width = 1;
572 sep->add(ds);}
573
574 tools::sg::vertices* vtxs = new tools::sg::vertices;
575 vtxs->mode = tools::gl::lines();
576 sep->add(vtxs);
577
578 for (const auto& line: lines) {
579 vtxs->add(float(line.first.x()),float(line.first.y()),float(line.first.z()));
580 vtxs->add(float(line.second.x()),float(line.second.y()),float(line.second.z()));
581 }
582
583 }
584}
G4GLOB_DLL std::ostream G4cerr
virtual G4String GetCurrentTag() const
const G4Colour & GetColour()
G4Transform3D fObjectTransformation
const G4VisAttributes * fpVisAttribs
G4ViewParameters::DrawingStyle GetDrawingStyle(const G4VisAttributes *)
const G4VisAttributes * GetApplicableVisAttributes(const G4VisAttributes *) const
const G4ViewParameters & GetViewParameters() const
G4bool IsAuxEdgeVisible() const
const G4VisAttributes * GetVisAttributes() const
G4int GetNoFacets() const
G4bool GetNextFacet(G4int &n, G4Point3D *nodes, G4int *edgeFlags=nullptr, G4Normal3D *normals=nullptr) const