101 if (node.chlds.empty())
140 if (++
fChild >= prnt.chlds.size()) {
179 size_t pos = path.find(
'/');
185 while (++
pos < path.length()) {
188 pos = path.find(
'/', last);
190 if (
pos == std::string::npos)
193 std::string folder = path.substr(last,
pos - last);
201 find = (folder.compare(
GetName()) == 0);
202 }
while (!find &&
Next());
212 bool Navigate(
const std::vector<std::string> &path)
216 for (
auto &folder : path) {
224 find = (folder.compare(
GetName()) == 0);
225 }
while (!find &&
Next());
250 std::vector<int> res;
266using namespace std::string_literals;
270int compare_stacks(
const std::vector<int> &stack1,
const std::vector<int> &stack2)
272 unsigned len1 = stack1.size(), len2 = stack2.size(), len = (len1 < len2) ? len1 : len2, indx = 0;
274 if (stack1[indx] < stack2[indx])
276 if (stack1[indx] > stack2[indx])
295 std::vector<RGeomSignalFunc_t> funcs;
300 if (!handler || (
pair.first != handler))
301 funcs.emplace_back(
pair.second);
305 for (
auto func : funcs)
315 fSignals.emplace_back(handler, func);
326 if (handler == iter->first) {
355 if (!is_translate && !is_scale && !is_rotate) {
358 auto test = [](
double val,
double chk) {
return (val == chk) || (
TMath::Abs(val - chk) < 1
e-20); };
360 bool no_scale = test(scale[0], 1) && test(scale[1], 1) && test(scale[2], 1);
361 bool no_trans = test(trans[0], 0) && test(trans[1], 0) && test(trans[2], 0);
362 bool no_rotate = test(rotate[0], 1) && test(rotate[1], 0) && test(rotate[2], 0) && test(rotate[3], 0) &&
363 test(rotate[4], 1) && test(rotate[5], 0) && test(rotate[6], 0) && test(rotate[7], 0) &&
366 if (no_scale && no_trans && no_rotate)
369 if (no_scale && no_trans && !no_rotate) {
371 }
else if (no_scale && !no_trans && no_rotate) {
373 }
else if (!no_scale && no_trans && no_rotate) {
397 for (
int n = 0;
n < 9; ++
n)
413 vect[10] = rotate[8];
442 SetMaxVisFaces((maxnodes > 5000 ? 5000 : (maxnodes < 1000 ? 1000 : maxnodes)) * 100);
448 if (!volname.empty()) {
449 auto vol = mgr->
GetVolume(volname.c_str());
451 if (vol && (vol != topnode->GetVolume()) && iter.
Navigate(vol))
497 std::vector<int> numbers;
498 int offset = 1000000000;
505 numbers.emplace_back(offset);
506 fNodes.emplace_back(
nullptr);
507 }
else if (snode->
GetNumber() >= offset) {
511 numbers.emplace_back(snode->
GetNumber());
513 fNodes.emplace_back(snode);
515 }
while ((snode = iter()) !=
nullptr);
521 std::vector<RGeomNode *> sortarr;
522 sortarr.reserve(
fNodes.size());
526 for (
auto node :
fNodes) {
528 fDesc.emplace_back(node ? node->GetNumber() - offset : 0);
529 TGeoVolume *vol = node ? node->GetVolume() : topvolume;
531 auto &desc =
fDesc[cnt++];
533 sortarr.emplace_back(&desc);
535 desc.name = node ? node->GetName() : vol->
GetName();
539 desc.vol =
TMath::Sqrt(shape->GetDX() * shape->GetDX() + shape->GetDY() * shape->GetDY() +
540 shape->GetDZ() * shape->GetDZ());
546 auto chlds = node ? node->GetNodes() : vol->
GetNodes();
548 PackMatrix(desc.matr, node ? node->GetMatrix() :
nullptr);
551 for (
int n = 0;
n <= chlds->GetLast(); ++
n) {
552 auto chld =
dynamic_cast<TGeoNode *
>(chlds->At(
n));
553 desc.chlds.emplace_back(chld->GetNumber() - offset);
559 for (
auto node :
fNodes) {
560 auto number = numbers[cnt++];
562 node->SetNumber(number);
566 std::sort(sortarr.begin(), sortarr.end(), [](
RGeomNode *
a,
RGeomNode *
b) { return a->vol > b->vol; });
569 for (
auto &elem : sortarr) {
571 elem->sortid = cnt++;
585 auto node =
fNodes[nodeid];
587 return node->GetVolume();
597 for (
int nodeid = 0; nodeid < (
int)
fNodes.size(); nodeid++) {
599 auto node =
fNodes[nodeid];
601 auto &desc =
fDesc[nodeid];
603 desc.nochlds =
false;
606 if (!node || node->IsOnScreen())
612 if (node && !node->IsVisDaughters())
615 if ((desc.vis > 0) && (!desc.chlds.empty()) && !desc.nochlds)
619 if (desc.IsVisible() && desc.CanDisplay())
631 for (
auto &node :
fDesc)
636 ScanFunc_t scan_func = [&,
this](
RGeomNode &node) {
637 if (node.idshift < 0) {
639 for (
auto id : node.chlds)
640 node.idshift += scan_func(
fDesc[
id]);
643 return node.idshift + 1;
658 std::vector<int> stack;
663 using ScanFunc_t = std::function<
int(
int,
int,
bool)>;
665 ScanFunc_t scan_func = [&,
this](
int nodeid,
int lvl,
bool is_inside) {
669 auto &desc =
fDesc[nodeid];
670 auto desc_vis = desc.vis;
673 if (desc.nochlds && (lvl > 0))
676 bool can_display = desc.CanDisplay(), scan_childs =
true;
678 if ((viter !=
fVisibility.end()) && (compare_stacks(viter->stack, stack) == 0)) {
679 can_display = scan_childs = viter->visible;
680 desc_vis = !viter->visible ? 0 : (!desc.chlds.empty() ? 1 : 99);
685 bool is_visible = (lvl >= 0) && (desc_vis > lvl) && can_display && is_inside;
687 if (is_visible || !only_visible)
688 if (func(desc, stack, is_visible, counter))
693 if ((!desc.chlds.empty()) && (((lvl > 0) && scan_childs) || !only_visible)) {
694 auto pos = stack.size();
695 stack.emplace_back(0);
696 for (
unsigned k = 0; k < desc.chlds.size(); ++k) {
698 res += scan_func(desc.chlds[k], is_inside ? lvl - 1 : lvl, is_inside);
702 counter += desc.idshift;
715 return scan_func(0, maxlvl,
false);
728 for (
auto &node :
fDesc)
729 drawing.
nodes.emplace_back(&node);
734 for (
auto &node :
fDesc)
735 node.useflag =
false;
737 for (
auto &item : drawing.
visibles) {
739 for (
auto &chindx : item.stack) {
740 auto &node =
fDesc[nodeid];
743 drawing.
nodes.emplace_back(&node);
745 if (chindx >= (
int)node.chlds.size())
747 nodeid = node.chlds[chindx];
750 if (nodeid != item.nodeid)
751 printf(
"Nodeid mismatch %d != %d when extracting nodes for visibles\n", nodeid, item.nodeid);
753 auto &node =
fDesc[nodeid];
756 drawing.
nodes.emplace_back(&node);
796 request = std::make_unique<RBrowserRequest>();
798 request->number = 100;
806 std::vector<RGeomNodeBase *> vect(
fDesc.size(),
nullptr);
809 for (
auto &item :
fDesc)
815 res +=
":__PHYSICAL_VISIBILITY__:";
819 res +=
":__SELECTED_STACK__:";
823 std::vector<RGeoItem> temp_nodes;
824 bool toplevel = request->path.empty();
828 reply.
path = request->path;
829 reply.
first = request->first;
838 while ((request->first > 0) && iter.
Next()) {
845 while (iter.
IsValid() && (request->number > 0)) {
850 temp_nodes.back().SetExpanded(
true);
852 temp_nodes.back().SetTop(
true);
859 stack[stack.size() - 1]++;
867 for (
auto &
n : temp_nodes)
868 reply.
nodes.emplace_back(&
n);
883 if (descr.fShape == shape)
899 std::unique_ptr<RootCsg::TBaseMesh> res;
907 for (
UInt_t i = 0; i < b3d->NbPnts(); ++i) {
909 buf[1] =
v[i * 3 + 1];
910 buf[2] =
v[i * 3 + 2];
915 res.reset(RootCsg::ConvertToMesh(*b3d.get()));
925 mleft.
Multiply(node->GetLeftMatrix());
926 auto left =
MakeGeoMesh(&mleft, node->GetLeftShape());
928 mright.
Multiply(node->GetRightMatrix());
929 auto right =
MakeGeoMesh(&mright, node->GetRightShape());
932 res.reset(RootCsg::BuildUnion(left.get(), right.get()));
934 res.reset(RootCsg::BuildIntersection(left.get(), right.get()));
936 res.reset(RootCsg::BuildDifference(left.get(), right.get()));
954 return nsegm > min ? nsegm : min;
965 auto countTubeFaces = [
this](
const std::array<Double_t, 2> &outerR,
const std::array<Double_t, 2> &innerR,
966 Double_t thetaLength = 360.) ->
int {
967 auto hasrmin = (innerR[0] > 0) || (innerR[1] > 0);
972 int numfaces = radiusSegments * (((outerR[0] <= 0) || (outerR[1] <= 0)) ? 1 : 2);
976 numfaces += radiusSegments * (((innerR[0] <= 0) || (innerR[1] <= 0)) ? 1 : 2);
980 numfaces += radiusSegments * ((innerR[0] > 0) ? 2 : 1);
983 numfaces += radiusSegments * ((innerR[1] > 0) ? 2 : 1);
985 if (thetaLength < 360)
986 numfaces += ((outerR[0] > innerR[0]) ? 2 : 0) + ((outerR[1] > innerR[1]) ? 2 : 0);
994 auto heightSegments = sphere->
GetNz();
996 auto noInside = sphere->
GetRmin() <= 0;
998 auto numoutside = widthSegments * heightSegments * 2;
999 auto numtop = widthSegments * (noInside ? 1 : 2);
1000 auto numbottom = widthSegments * (noInside ? 1 : 2);
1001 auto numcut = (phiLength == 360.) ? 0 : heightSegments * (noInside ? 2 : 4);
1003 return numoutside * (noInside ? 1 : 2) + numtop + numbottom + numcut;
1006 return countTubeFaces({cone->GetRmax2(), cone->GetRmax1()}, {cone->GetRmin2(), cone->GetRmin1()});
1009 return countTubeFaces({cone->GetRmax2(), cone->GetRmax1()}, {cone->GetRmin2(), cone->GetRmin1()},
1010 cone->GetPhi2() - cone->GetPhi1());
1013 return countTubeFaces({tube->GetRmax(), tube->GetRmax()}, {tube->GetRmin(), tube->GetRmin()});
1016 return countTubeFaces({tube->GetRmax(), tube->GetRmax()}, {tube->GetRmin(), tube->GetRmin()},
1017 tube->GetPhi2() - tube->GetPhi1());
1020 return countTubeFaces({tube->GetRmax(), tube->GetRmax()}, {tube->GetRmin(), tube->GetRmin()},
1021 tube->GetPhi2() - tube->GetPhi1());
1028 return (torus->GetRmin() > 0 ? 4 : 2) * radialSegments * (tubularSegments + (torus->GetDphi() != 360. ? 1 : 0));
1032 bool hasrmin =
false;
1034 for (
int layer = 0; layer < pcon->GetNz(); ++layer)
1035 if (pcon->GetRmin(layer) > 0.)
1037 return (hasrmin ? 4 : 2) * radiusSegments * (pcon->GetNz() - 1);
1041 bool hasrmin =
false;
1043 for (
int layer = 0; layer < pgon->GetNz(); ++layer)
1044 if (pgon->GetRmin(layer) > 0.)
1046 return (hasrmin ? 4 : 2) * radiusSegments * (pgon->GetNz() - 1);
1049 return (xtru->GetNz() - 1) * xtru->GetNvert() * 2 + xtru->GetNvert() * 3;
1053 int numfaces = (heightSegments + 1) * radiusSegments * 2;
1054 if (para->GetRlo() == 0.)
1055 numfaces -= radiusSegments * 2;
1056 if (para->GetRhi() == 0.)
1057 numfaces -= radiusSegments * 2;
1064 return radiusSegments * (heightSegments + 1) * ((hype->
GetRmin() > 0.) ? 4 : 2);
1068 for (
int i = 0; i < tess->GetNfacets(); ++i) {
1069 if (tess->GetFacet(i).GetNvert() == 4)
1080 if (!comp->GetBoolNode())
1097 if (elem.nfaces == 0) {
1110 elem.fShapeInfo.shape = shape;
1124 Int_t num_vertices = mesh->NumberOfVertices(), num_polynoms = 0;
1126 for (
unsigned polyIndex = 0; polyIndex < mesh->NumberOfPolys(); ++polyIndex) {
1128 auto size_of_polygon = mesh->SizeOfPoly(polyIndex);
1130 if (size_of_polygon >= 3)
1131 num_polynoms += (size_of_polygon - 2);
1134 Int_t index_buffer_size = num_polynoms * 3,
1135 vertex_buffer_size = num_vertices * 3;
1137 elem.nfaces = num_polynoms;
1139 std::vector<float> vertices(vertex_buffer_size);
1141 for (
Int_t i = 0; i < num_vertices; ++i) {
1142 auto v = mesh->GetVertex(i);
1143 vertices[i * 3] =
v[0];
1144 vertices[i * 3 + 1] =
v[1];
1145 vertices[i * 3 + 2] =
v[2];
1148 elem.fRawInfo.raw.resize(vertices.size() *
sizeof(
float));
1150 memcpy(
reinterpret_cast<char *
>(elem.fRawInfo.raw.data()), vertices.data(), vertices.size() *
sizeof(
float));
1152 auto &indexes = elem.fRawInfo.idx;
1154 indexes.resize(index_buffer_size);
1157 for (
unsigned polyIndex = 0; polyIndex < mesh->NumberOfPolys(); ++polyIndex) {
1158 auto size_of_polygon = mesh->SizeOfPoly(polyIndex);
1161 if (size_of_polygon >= 3)
1162 for (
int i = 0; i < 3; ++i)
1163 indexes[
pos++] = mesh->GetVertexIndex(polyIndex, i);
1166 if (size_of_polygon > 3)
1167 for (
unsigned vertex = 3; vertex < size_of_polygon; vertex++) {
1168 indexes[
pos++] = mesh->GetVertexIndex(polyIndex, 0);
1169 indexes[
pos++] = mesh->GetVertexIndex(polyIndex, vertex - 1);
1170 indexes[
pos++] = mesh->GetVertexIndex(polyIndex, vertex);
1198 node.
material = material->GetName();
1200 auto fillstyle = material->GetFillStyle();
1201 if ((fillstyle >= 3000) && (fillstyle <= 3100))
1202 node.
opacity = (3100 - fillstyle) / 100.;
1204 col =
gROOT->GetColor(material->GetFillColor());
1211 colbuf.
Form(
"#%02x%02x%02x", (
int)(col->
GetRed() * 255), (
int)(col->
GetGreen() * 255),
1257 std::vector<int> viscnt(
fDesc.size(), 0);
1262 int numnodes =
ScanNodes(
true, level, [&viscnt](
RGeomNode &node, std::vector<int> &,
bool,
int) {
1270 viscnt.assign(viscnt.size(), 0);
1271 numnodes =
ScanNodes(
true, level, [&viscnt](
RGeomNode &node, std::vector<int> &,
bool,
int) {
1281 int totalnumfaces = 0, totalnumnodes = 0;
1289 auto &desc =
fDesc[sid];
1291 if ((viscnt[sid] <= 0) || (desc.vol <= 0))
1302 if (shape_descr.nfaces <= 0) {
1303 R__LOG_ERROR(
RGeomLog()) <<
"No faces for the shape " << shape->GetName() <<
" class " << shape->ClassName();
1308 totalnumfaces += shape_descr.nfaces * viscnt[sid];
1313 totalnumnodes += viscnt[sid];
1325 bool has_shape =
false;
1327 ScanNodes(
true, level, [&,
this](
RGeomNode &node, std::vector<int> &stack,
bool,
int seqid) {
1329 drawing.
visibles.emplace_back(node.
id, seqid, stack);
1331 auto &item = drawing.
visibles.back();
1332 item.color = node.
color;
1339 item.ri = sd.rndr_info();
1422 if ((nodeid < 0) || (nodeid >= (
int)
fDesc.size()))
1425 auto &desc =
fDesc[nodeid];
1427 return (desc.sortid <
fDrawIdCut) && desc.IsVisible() && desc.CanDisplay() && (desc.chlds.empty());
1443 hjson =
"FOUND:RESET";
1447 std::vector<int> nodescnt(
fDesc.size(), 0), viscnt(
fDesc.size(), 0);
1450 std::string test = find;
1452 if (test.compare(0, 2,
"c:") == 0) {
1455 }
else if (test.compare(0, 2,
"m:") == 0) {
1462 auto match_func = [®exp, kind](
RGeomNode &node) {
1463 return (node.vol > 0) && (
TString(node.GetArg(kind)).
Index(regexp) >= 0);
1468 [&nodescnt, &viscnt, &match_func, &nmatches](
RGeomNode &node, std::vector<int> &,
bool is_vis,
int) {
1469 if (match_func(node)) {
1471 nodescnt[node.
id]++;
1479 if (nmatches == 0) {
1485 hjson =
"FOUND:Too many " + std::to_string(nmatches);
1491 int totalnumfaces = 0, totalnumnodes = 0, scnt = 0;
1492 bool send_rawdata =
true;
1499 if (viscnt[sid] == 0)
1502 auto &desc =
fDesc[sid];
1503 if ((viscnt[sid] <= 0) && (desc.vol <= 0))
1514 if (shape_descr.nfaces <= 0) {
1515 R__LOG_ERROR(
RGeomLog()) <<
"No faces for the shape " << shape->GetName() <<
" class " << shape->ClassName();
1520 totalnumfaces += shape_descr.nfaces * viscnt[sid];
1522 send_rawdata =
false;
1527 totalnumnodes += viscnt[sid];
1529 send_rawdata =
false;
1540 std::vector<RGeomNodeBase> found_desc;
1541 std::vector<int> found_map(
fDesc.size(), -1);
1545 found_desc.emplace_back(0);
1546 found_desc[0].vis =
fDesc[0].vis;
1547 found_desc[0].name =
fDesc[0].name;
1548 found_desc[0].color =
fDesc[0].color;
1554 bool has_shape =
true;
1556 ScanNodes(
false, 0, [&,
this](
RGeomNode &node, std::vector<int> &stack,
bool is_vis,
int seqid) {
1558 if (!match_func(node))
1563 for (
auto &s : stack) {
1564 int chldid =
fDesc[prntid].chlds[s];
1565 if (found_map[chldid] <= 0) {
1566 int newid = found_desc.size();
1567 found_desc.emplace_back(newid);
1568 found_map[chldid] = newid;
1570 found_desc.back().vis =
fDesc[chldid].vis;
1571 found_desc.back().name =
fDesc[chldid].name;
1572 found_desc.back().color =
fDesc[chldid].color;
1573 found_desc.back().material =
fDesc[chldid].material;
1576 auto pid = found_map[prntid];
1577 auto cid = found_map[chldid];
1580 auto &pchlds = found_desc[pid].chlds;
1581 if (std::find(pchlds.begin(), pchlds.end(), cid) == pchlds.end())
1582 pchlds.emplace_back(cid);
1591 drawing.
visibles.emplace_back(node.
id, seqid, stack);
1600 auto &item = drawing.
visibles.back();
1603 item.color = node.
color;
1608 item.ri = sd.rndr_info();
1632 for (
auto &chindx : stack) {
1633 auto &node =
fDesc[nodeid];
1634 if (chindx >= (
int)node.chlds.size())
1636 nodeid = node.chlds[chindx];
1649 std::vector<int> stack;
1655 printf(
"Wrong first id\n");
1661 for (
unsigned k = 1; k < ids.size(); ++k) {
1663 int prntid = nodeid;
1666 if (nodeid >= (
int)
fDesc.size()) {
1667 printf(
"Wrong node id %d\n", nodeid);
1671 auto &chlds =
fDesc[prntid].chlds;
1672 auto pos = std::find(chlds.begin(), chlds.end(), nodeid);
1673 if (
pos == chlds.end()) {
1674 printf(
"Wrong id %d not a child of %d - fail to find stack num %d\n", nodeid, prntid, (
int)chlds.size());
1679 stack.emplace_back(std::distance(chlds.begin(),
pos));
1693 std::vector<int> res;
1711 std::vector<int> ids;
1713 ids.emplace_back(0);
1715 bool failure =
false;
1717 for (
auto s : stack) {
1718 auto &chlds =
fDesc[nodeid].chlds;
1719 if (s >= (
int)chlds.size()) {
1724 ids.emplace_back(chlds[s]);
1730 printf(
"Fail to convert stack into list of nodes\n");
1744 std::vector<std::string> path;
1747 path.reserve(ids.size());
1762 std::vector<RGeomNodeBase *> nodes;
1769 for (
auto &desc :
fDesc)
1771 nodes.emplace_back(&desc);
1796 ScanNodes(
true, 0, [&,
this](
RGeomNode &node, std::vector<int> &stack,
bool,
int seq_id) {
1803 if (node.
id != nodeid)
1807 drawing.
visibles.emplace_back(node.
id, seq_id, stack);
1809 auto &item = drawing.
visibles.back();
1811 item.color = node.
color;
1824 bool has_shape =
false, has_raw =
false;
1829 for (
auto &item : drawing.
visibles) {
1830 item.ri = sd.rndr_info();
1841 return has_raw || has_shape;
1884 auto &dnode =
fDesc[nodeid];
1889 if (vol->IsVisible() == selected)
1892 dnode.vis = selected ? 99 : 0;
1893 vol->SetVisibility(selected);
1894 if (!dnode.chlds.empty()) {
1897 vol->SetVisDaughters(selected);
1901 for (
auto &desc :
fDesc)
1903 desc.vis = dnode.vis;
1909 if (compare_stacks(iter->stack, stack) == 0) {
1929 std::unique_ptr<RGeomNodeInfo> res;
1939 res = std::make_unique<RGeomNodeInfo>();
1942 res->node_name = node ? node->GetName() :
"node_name";
1943 res->node_type = node ? node->ClassName() :
"no class";
1947 TGeoShape *shape = vol ? vol->GetShape() :
nullptr;
1950 res->shape_name = shape->
GetName();
1954 if (shape && desc.CanDisplay()) {
1958 res->ri = shape_descr.rndr_info();
2008 auto res = compare_stacks(iter->stack, stack);
2011 bool changed = iter->visible != on;
2017 if ((
fDesc[nodeid].vis > 0) == on)
2042 std::vector<std::string> path;
2043 std::string::size_type p1 = 0;
2045 while (p1 < itemname.length()) {
2046 if (itemname[p1] ==
'/') {
2050 auto p = itemname.find(
'/', p1);
2051 if (p == std::string::npos) {
2052 path.emplace_back(itemname.substr(p1));
2053 p1 = itemname.length();
2055 path.emplace_back(itemname.substr(p1, p - p1));
2070 unsigned sz = item.stack.size();
2071 if (stack.size() < sz)
2074 for (
unsigned n = 0;
n < sz; ++
n)
2075 if (stack[
n] != item.stack[
n]) {
2081 return item.visible ? 1 : 0;
2101 if (compare_stacks(iter->stack, stack) == 0) {
2169 std::string prefix =
" ";
2171 if (
fCfg.vislevel != 0)
2172 fs << prefix <<
name <<
"SetVisLevel(" <<
fCfg.vislevel <<
");" << std::endl;
2173 if (
fCfg.maxnumnodes != 0)
2174 fs << prefix <<
name <<
"SetMaxVisNodes(" <<
fCfg.maxnumnodes <<
");" << std::endl;
2175 if (
fCfg.maxnumfaces != 0)
2176 fs << prefix <<
name <<
"SetMaxVisFaces(" <<
fCfg.maxnumfaces <<
");" << std::endl;
2178 fs << prefix <<
name <<
"SetTopVisible(true);" << std::endl;
2179 if (
fCfg.build_shapes != 1)
2180 fs << prefix <<
name <<
"SetBuildShapes(" <<
fCfg.build_shapes <<
");" << std::endl;
2181 if (
fCfg.nsegm != 0)
2182 fs << prefix <<
name <<
"SetNSegments(" <<
fCfg.nsegm <<
");" << std::endl;
2183 if (!
fCfg.drawopt.empty())
2184 fs << prefix <<
name <<
"SetDrawOptions(\"" <<
fCfg.drawopt <<
"\");" << std::endl;
2186 fs << prefix <<
name <<
"SetJsonComp(" <<
fJsonComp <<
");" << std::endl;
2191 fs << prefix <<
name <<
"SetPhysNodeVisibility(";
2192 for (
int i = 0; i < (
int)path.size(); ++i)
2193 fs << (i == 0 ?
"{\"" :
", \"") << path[i] <<
"\"";
2194 fs <<
"}, " << (item.visible ?
"true" :
"false") <<
");" << std::endl;
std::unique_ptr< RootCsg::TBaseMesh > MakeGeoMesh(TGeoMatrix *matr, TGeoShape *shape)
Function produces mesh for provided shape, applying matrix to the result.
#define R__LOG_ERROR(...)
int Int_t
Signed integer 4 bytes (int).
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
double Double_t
Double 8 bytes.
externTGeoManager * gGeoManager
Reply on browser request.
std::vector< std::string > path
reply path
std::vector< const Browsable::RItem * > nodes
list of pointers, no ownership!
int first
first node in returned list
int nchilds
total number of childs in the node
Representation of single item in the geometry browser.
RGeomBrowserIter(RGeomDescription &desc)
std::vector< int > CurrentIds() const
Returns array of ids to currently selected node.
bool Navigate(TGeoVolume *vol)
Navigate to specified volume - find first occurrence.
std::vector< int > fStackChilds
bool Navigate(const std::string &path)
Navigate to specified path - path specified as string and should start with "/".
const std::string & GetMaterial() const
std::vector< int > fStackParents
const std::string & GetColor() const
const std::string & GetName() const
bool Navigate(const std::vector< std::string > &path)
Navigate to specified path.
RGeomConfig fCfg
! configuration parameter editable from GUI
std::vector< std::pair< const void *, RGeomSignalFunc_t > > fSignals
! registered signals
int IsPhysNodeVisible(const std::vector< int > &stack)
Check if there special settings for specified physical node returns -1 if nothing is found.
std::vector< int > fSelectedStack
! selected branch of geometry by stack
void SetMaxVisNodes(int cnt)
Set maximal number of nodes which should be selected for drawing.
std::string ProcessBrowserRequest(const std::string &req="")
Find description object for requested shape If not exists - will be created.
std::vector< RGeomNode > fDesc
! converted description, send to client
void PackMatrix(std::vector< float > &arr, TGeoMatrix *matr)
Pack matrix into vector, which can be send to client Following sizes can be used for vector: 0 - Iden...
bool ProduceDrawingFor(int nodeid, std::string &json, bool check_volume=false)
Produce shape rendering data for given stack All nodes, which are referencing same shape will be tran...
std::unique_ptr< RGeomNodeInfo > MakeNodeInfo(const std::vector< int > &stack)
Change visibility for specified element Returns true if changes was performed.
bool HasDrawData() const
Check if there is draw data available.
std::vector< int > MakeIdsByStack(const std::vector< int > &stack)
Produce list of node ids for given stack If found nodes preselected - use their ids.
int MarkVisible(bool on_screen=false)
Set visibility flag for each nodes.
void SetVisLevel(int lvl=3)
Set maximal visible level.
void IssueSignal(const void *handler, const std::string &kind)
Issue signal, which distributed on all handlers - excluding source handler.
int GetUsedNSegments(int min=20)
Returns really used number of cylindrical segments.
bool IsPrincipalEndNode(int nodeid)
return true when node used in main geometry drawing and does not have childs for such nodes one could...
bool SetSearch(const std::string &query, const std::string &json)
Change search query and belongs to it json string Returns true if any parameter was really changed.
std::vector< RGeomNodeVisibility > fVisibility
! custom visibility flags for physical nodes
bool SelectTop(const std::vector< std::string > &path)
Select top node by path Used by the client to change active node Returns true if selected node was ch...
int GetMaxVisNodes() const
Returns maximal visible number of nodes, ignored when non-positive.
int GetVisLevel() const
Returns maximal visible level.
int GetMaxVisFaces() const
Returns maximal visible number of faces, ignored when non-positive.
void ClearCache()
Clear cached data, need to be clear when connection broken.
virtual void RefineGeoItem(RGeoItem &item, const std::vector< int > &stack)
Method which allows to add/modify information in RGeoItem which will be provided to client - like tit...
void ClearDescription()
Clear geometry description.
std::vector< int > MakeStackByIds(const std::vector< int > &ids)
Creates stack for given array of ids, first element always should be 0.
void SetMaxVisFaces(int cnt)
Set maximal number of faces which should be selected for drawing.
bool IsPreferredOffline() const
Is offline operations preferred.
std::vector< ShapeDescr > fShapes
! shapes with created descriptions
int fJsonComp
! default JSON compression
bool ChangeNodeVisibility(const std::vector< std::string > &path, bool on)
Change visibility for specified element Returns true if changes was performed.
std::string fSearch
! search string in hierarchy
std::string fSearchJson
! drawing json for search
void SavePrimitive(std::ostream &fs, const std::string &name)
Save geometry configuration as C++ macro.
bool ClearAllPhysVisibility()
Reset all custom visibility settings.
std::string MakeDrawingJson(RGeomDrawing &drawing, bool has_shapes=false)
Produce JSON for the drawing If TGeoShape appears in the drawing, one has to keep typeinfo But in thi...
int fActualLevel
! level can be reduced when selecting nodes
TGeoVolume * GetVolume(int nodeid)
Get volume for specified nodeid If specific volume was configured, it will be returned for nodeid==0.
int GetNumNodes() const
Number of unique nodes in the geometry.
void ProduceDrawData()
Collect all information required to draw geometry on the client This includes list of each visible no...
void SetNSegments(int n=0)
Set number of segments for cylindrical shapes, if 0 - default value will be used.
bool SetPhysNodeVisibility(const std::vector< std::string > &path, bool on=true)
Set visibility of physical node by path It overrules TGeo visibility flags - but only for specific ph...
bool ClearPhysNodeVisibility(const std::vector< std::string > &path)
Reset custom visibility of physical node by path.
void BuildDescription(TGeoNode *topnode, TGeoVolume *topvolume)
Build geometry description.
int SearchVisibles(const std::string &find, std::string &hjson, std::string &json)
Search visible nodes for provided name If number of found elements less than 100, create description ...
std::vector< int > fSortMap
! nodes in order large -> smaller volume
friend class RGeomBrowserIter
std::string ProduceJson(bool all_nodes=false)
Produce JSON string which can be directly used with build function from JSROOT to create three....
void ClearDrawData()
Clear drawing data.
std::vector< std::string > MakePathByStack(const std::vector< int > &stack)
Returns path string for provided stack.
TVirtualMutex * fMutex
! external mutex used to protect all data
void AddSignalHandler(const void *handler, RGeomSignalFunc_t func)
Add signal handler.
bool ChangeConfiguration(const std::string &json)
Change configuration by client Returns true if any parameter was really changed.
void CopyMaterialProperties(TGeoVolume *vol, RGeomNode &node)
Copy material properties.
std::vector< int > MakeStackByPath(const std::vector< std::string > &path)
Produce stack based on string path Used to highlight geo volumes by browser hover event.
int ScanNodes(bool only_visible, int maxlvl, RGeomScanFunc_t func)
Iterate over all nodes and call function for visible.
int IsBuildShapes() const
Returns true if binary 3D model build already by C++ server (default).
void ProduceSearchData()
Produces search data if necessary.
void CollectNodes(RGeomDrawing &drawing, bool all_nodes=false)
Collect nodes which are used in visibles.
int fDrawIdCut
! sortid used for selection of most-significant nodes
TGeoVolume * fDrawVolume
! select volume independent from TGeoManager
int CountShapeFaces(TGeoShape *shape)
Count number of faces for the shape.
ShapeDescr & MakeShapeDescr(TGeoShape *shape)
Find description object and create render information.
void _ClearDrawData()
clear drawing data without locking mutex
ShapeDescr & FindShapeDescr(TGeoShape *shape)
Find description object for requested shape If not exists - will be created.
std::string fDrawJson
! JSON with main nodes drawn by client
void RemoveSignalHandler(const void *handler)
Remove signal handler.
int FindNodeId(const std::vector< int > &stack)
Returns nodeid for given stack array, returns -1 in case of failure.
void ProduceIdShifts()
Count total number of visible childs under each node.
std::string ProduceModifyReply(int nodeid)
Return string with only part of nodes description which were modified Checks also volume.
void ResetRndrInfos()
Reset shape info, which used to pack binary data.
int GetNSegments() const
Return of segments for cylindrical shapes, if 0 - default value will be used.
std::vector< TGeoNode * > fNodes
! flat list of all nodes
int GetJsonComp() const
Returns JSON compression level for data transfer.
virtual bool IsFullModelStreamedAtOnce() const
Decide if the whole model is streamed at once Function is called from ProcessBrowserRequest.
void Build(TGeoManager *mgr, const std::string &volname="")
Collect information about geometry hierarchy into flat list like it done in JSROOT ClonedNodes....
Object with full description for drawing geometry It includes list of visible items and list of nodes...
int numnodes
total number of nodes in description
std::vector< RGeomVisible > visibles
all visible items
RGeomConfig * cfg
current configurations
std::vector< RGeomNode * > nodes
all used nodes to display visible items and not known for client
std::string material
name of the material
int sortid
! place in sorted array, to check cuts, or id of original node when used search structures
std::string color
rgb code in hex format
int id
node id, index in array
Full node description including matrices and other attributes.
float opacity
! opacity of the color
A log configuration for a channel, e.g.
virtual Color_t GetFillColor() const
Return the fill area color.
virtual Color_t GetLineColor() const
Return the line color.
Class for serializing object to and from JavaScript Object Notation (JSON) format.
static TString ToJSON(const T *obj, Int_t compact=0, const char *member_name=nullptr)
@ kSkipTypeInfo
do not store typenames in JSON
static Bool_t FromJSON(T *&obj, const char *json)
void SetCompact(int level)
Set level of space/newline/array compression Lower digit of compact parameter define formatting rules...
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
Composite shapes are Boolean combinations of two or more shape components.
TGeoBoolNode * GetBoolNode() const
Matrix class used for computing global transformations Should NOT be used for node definition.
void Multiply(const TGeoMatrix *right)
multiply to the right with an other transformation if right is identity matrix, just return
Double_t GetStOut() const
void Skip()
Stop iterating the current branch.
The manager class for any TGeo geometry.
TGeoVolume * GetVolume(const char *name) const
Search for a named volume. All trailing blanks stripped.
Int_t GetMaxVisNodes() const
TGeoNode * GetTopNode() const
Int_t GetVisLevel() const
Returns current depth to which geometry is drawn.
Int_t GetNsegments() const
Get number of segments approximating circles.
Geometrical transformation package.
virtual const Double_t * GetTranslation() const =0
TClass * IsA() const override
virtual void LocalToMaster(const Double_t *local, Double_t *master) const
convert a point by multiplying its column vector (x, y, z, 1) to matrix inverse
virtual const Double_t * GetScale() const =0
Bool_t IsIdentity() const
virtual const Double_t * GetRotationMatrix() const =0
TGeoMaterial * GetMaterial() const
A node represent a volume positioned inside another.They store links to both volumes and to the TGeoM...
void SetNumber(Int_t number)
A paraboloid is defined by the revolution surface generated by a parabola and is bounded by two plane...
A shape scaled by a TGeoScale transformation.
Base abstract class for all shapes.
virtual Bool_t IsComposite() const
virtual Bool_t IsCylType() const =0
const char * GetName() const override
Get the shape name.
TClass * IsA() const override
virtual TBuffer3D * MakeBuffer3D() const
Int_t GetNumberOfDivisions() const
virtual Double_t GetRmin() const
virtual Double_t GetRmin() const
virtual Double_t GetRmax() const
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
TGeoMedium * GetMedium() const
static TGeoMedium * DummyMedium()
TGeoShape * GetShape() const
A TGeoXtru shape is represented by the extrusion of an arbitrary polygon with fixed outline between s...
const char * GetName() const override
Returns name of object.
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Regular expression class.
const char * Data() const
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
RLogChannel & RGeomLog()
Log channel for Geomviewer diagnostics.
std::function< bool(RGeomNode &, std::vector< int > &, bool, int)> RGeomScanFunc_t
std::function< void(const std::string &)> RGeomSignalFunc_t
Int_t Nint(T x)
Round to nearest integer. Rounds half integers to the nearest even integer.
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Double_t Sqrt(Double_t x)
Returns the square root of x.
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.