16#define ROOT_CsgOps_cxx
102 if (node.chlds.empty())
141 if (++
fChild >= prnt.chlds.size()) {
180 size_t pos = path.find(
'/');
186 while (++pos < path.length()) {
189 pos = path.find(
'/', last);
191 if (pos == std::string::npos)
194 std::string folder = path.substr(last, pos - last);
202 find = (folder.compare(
GetName()) == 0);
203 }
while (!find &&
Next());
213 bool Navigate(
const std::vector<std::string> &path)
217 for (
auto &folder : path) {
225 find = (folder.compare(
GetName()) == 0);
226 }
while (!find &&
Next());
251 std::vector<int> res;
267using namespace std::string_literals;
271int compare_stacks(
const std::vector<int> &stack1,
const std::vector<int> &stack2)
273 unsigned len1 = stack1.size(), len2 = stack2.size(),
len = (len1 < len2) ? len1 : len2, indx = 0;
275 if (stack1[indx] < stack2[indx])
277 if (stack1[indx] > stack2[indx])
296 std::vector<RGeomSignalFunc_t>
funcs;
301 if (!handler || (pair.first != handler))
302 funcs.emplace_back(pair.second);
306 for (
auto func :
funcs)
316 fSignals.emplace_back(handler, func);
327 if (handler == iter->first) {
356 if (!is_translate && !is_scale && !is_rotate) {
359 auto test = [](
double val,
double chk) {
return (val == chk) || (
TMath::Abs(val - chk) < 1
e-20); };
361 bool no_scale = test(scale[0], 1) && test(scale[1], 1) && test(scale[2], 1);
362 bool no_trans = test(trans[0], 0) && test(trans[1], 0) && test(trans[2], 0);
363 bool no_rotate = test(rotate[0], 1) && test(rotate[1], 0) && test(rotate[2], 0) && test(rotate[3], 0) &&
364 test(rotate[4], 1) && test(rotate[5], 0) && test(rotate[6], 0) && test(rotate[7], 0) &&
367 if (no_scale && no_trans && no_rotate)
370 if (no_scale && no_trans && !no_rotate) {
372 }
else if (no_scale && !no_trans && no_rotate) {
374 }
else if (!no_scale && no_trans && no_rotate) {
398 for (
int n = 0;
n < 9; ++
n)
414 vect[10] = rotate[8];
443 SetMaxVisFaces((maxnodes > 5000 ? 5000 : (maxnodes < 1000 ? 1000 : maxnodes)) * 100);
449 if (!volname.empty()) {
450 auto vol = mgr->
GetVolume(volname.c_str());
452 if (vol && (vol != topnode->GetVolume()) && iter.
Navigate(vol))
498 std::vector<int> numbers;
506 numbers.emplace_back(
offset);
507 fNodes.emplace_back(
nullptr);
512 numbers.emplace_back(snode->
GetNumber());
514 fNodes.emplace_back(snode);
516 }
while ((snode = iter()) !=
nullptr);
522 std::vector<RGeomNode *> sortarr;
523 sortarr.reserve(
fNodes.size());
527 for (
auto node :
fNodes) {
529 fDesc.emplace_back(node ? node->GetNumber() -
offset : 0);
530 TGeoVolume *vol = node ? node->GetVolume() : topvolume;
532 auto &desc =
fDesc[cnt++];
534 sortarr.emplace_back(&desc);
536 desc.name = node ? node->GetName() : vol->
GetName();
540 desc.vol =
TMath::Sqrt(shape->GetDX() * shape->GetDX() + shape->GetDY() * shape->GetDY() +
541 shape->GetDZ() * shape->GetDZ());
547 auto chlds = node ? node->GetNodes() : vol->
GetNodes();
549 PackMatrix(desc.matr, node ? node->GetMatrix() :
nullptr);
552 for (
int n = 0;
n <= chlds->GetLast(); ++
n) {
553 auto chld =
dynamic_cast<TGeoNode *
>(chlds->At(
n));
554 desc.chlds.emplace_back(chld->GetNumber() -
offset);
560 for (
auto node :
fNodes) {
561 auto number = numbers[cnt++];
563 node->SetNumber(number);
567 std::sort(sortarr.begin(), sortarr.end(), [](
RGeomNode *
a,
RGeomNode *
b) { return a->vol > b->vol; });
570 for (
auto &elem : sortarr) {
572 elem->sortid = cnt++;
586 auto node =
fNodes[nodeid];
588 return node->GetVolume();
598 for (
int nodeid = 0; nodeid < (
int)
fNodes.size(); nodeid++) {
600 auto node =
fNodes[nodeid];
602 auto &desc =
fDesc[nodeid];
604 desc.nochlds =
false;
607 if (!node || node->IsOnScreen())
613 if (node && !node->IsVisDaughters())
616 if ((desc.vis > 0) && (!desc.chlds.empty()) && !desc.nochlds)
620 if (desc.IsVisible() && desc.CanDisplay())
632 for (
auto &node :
fDesc)
637 ScanFunc_t scan_func = [&,
this](
RGeomNode &node) {
638 if (node.idshift < 0) {
640 for (
auto id : node.chlds)
641 node.idshift += scan_func(
fDesc[
id]);
644 return node.idshift + 1;
659 std::vector<int> stack;
664 using ScanFunc_t = std::function<
int(
int,
int,
bool)>;
666 ScanFunc_t scan_func = [&,
this](
int nodeid,
int lvl,
bool is_inside) {
670 auto &desc =
fDesc[nodeid];
671 auto desc_vis = desc.vis;
674 if (desc.nochlds && (lvl > 0))
677 bool can_display = desc.CanDisplay(), scan_childs =
true;
679 if ((viter !=
fVisibility.end()) && (compare_stacks(viter->stack, stack) == 0)) {
680 can_display = scan_childs = viter->visible;
681 desc_vis = !viter->visible ? 0 : (!desc.chlds.empty() ? 1 : 99);
686 bool is_visible = (lvl >= 0) && (desc_vis > lvl) && can_display && is_inside;
688 if (is_visible || !only_visible)
689 if (func(desc, stack, is_visible, counter))
694 if ((!desc.chlds.empty()) && (((lvl > 0) && scan_childs) || !only_visible)) {
695 auto pos = stack.size();
696 stack.emplace_back(0);
697 for (
unsigned k = 0; k < desc.chlds.size(); ++k) {
699 res += scan_func(desc.chlds[k], is_inside ? lvl - 1 : lvl, is_inside);
703 counter += desc.idshift;
716 return scan_func(0, maxlvl,
false);
729 for (
auto &node :
fDesc)
730 drawing.
nodes.emplace_back(&node);
735 for (
auto &node :
fDesc)
736 node.useflag =
false;
738 for (
auto &item : drawing.
visibles) {
740 for (
auto &chindx : item.stack) {
741 auto &node =
fDesc[nodeid];
744 drawing.
nodes.emplace_back(&node);
746 if (chindx >= (
int)node.chlds.size())
748 nodeid = node.chlds[chindx];
751 if (nodeid != item.nodeid)
752 printf(
"Nodeid mismatch %d != %d when extracting nodes for visibles\n", nodeid, item.nodeid);
754 auto &node =
fDesc[nodeid];
757 drawing.
nodes.emplace_back(&node);
794 auto request = TBufferJSON::FromJSON<RBrowserRequest>(msg);
797 request = std::make_unique<RBrowserRequest>();
799 request->number = 100;
807 std::vector<RGeomNodeBase *> vect(
fDesc.size(),
nullptr);
810 for (
auto &item :
fDesc)
816 res +=
":__PHYSICAL_VISIBILITY__:";
820 res +=
":__SELECTED_STACK__:";
824 std::vector<RGeoItem> temp_nodes;
825 bool toplevel = request->path.empty();
829 reply.
path = request->path;
830 reply.
first = request->first;
839 while ((request->first > 0) && iter.
Next()) {
846 while (iter.
IsValid() && (request->number > 0)) {
851 temp_nodes.back().SetExpanded(
true);
853 temp_nodes.back().SetTop(
true);
860 stack[stack.size() - 1]++;
868 for (
auto &
n : temp_nodes)
869 reply.
nodes.emplace_back(&
n);
884 if (descr.fShape == shape)
900 std::unique_ptr<RootCsg::TBaseMesh> res;
908 for (
UInt_t i = 0; i < b3d->NbPnts(); ++i) {
910 buf[1] =
v[i * 3 + 1];
911 buf[2] =
v[i * 3 + 2];
916 res.reset(RootCsg::ConvertToMesh(*b3d.get()));
926 mleft.
Multiply(node->GetLeftMatrix());
927 auto left =
MakeGeoMesh(&mleft, node->GetLeftShape());
929 mright.
Multiply(node->GetRightMatrix());
930 auto right =
MakeGeoMesh(&mright, node->GetRightShape());
933 res.reset(RootCsg::BuildUnion(left.get(), right.get()));
935 res.reset(RootCsg::BuildIntersection(left.get(), right.get()));
937 res.reset(RootCsg::BuildDifference(left.get(), right.get()));
955 return nsegm > min ? nsegm : min;
966 auto countTubeFaces = [
this](
const std::array<Double_t, 2> &outerR,
const std::array<Double_t, 2> &innerR,
967 Double_t thetaLength = 360.) ->
int {
968 auto hasrmin = (innerR[0] > 0) || (innerR[1] > 0);
973 int numfaces = radiusSegments * (((outerR[0] <= 0) || (outerR[1] <= 0)) ? 1 : 2);
977 numfaces += radiusSegments * (((innerR[0] <= 0) || (innerR[1] <= 0)) ? 1 : 2);
981 numfaces += radiusSegments * ((innerR[0] > 0) ? 2 : 1);
984 numfaces += radiusSegments * ((innerR[1] > 0) ? 2 : 1);
986 if (thetaLength < 360)
987 numfaces += ((outerR[0] > innerR[0]) ? 2 : 0) + ((outerR[1] > innerR[1]) ? 2 : 0);
995 auto heightSegments = sphere->
GetNz();
997 auto noInside = sphere->
GetRmin() <= 0;
999 auto numoutside = widthSegments * heightSegments * 2;
1000 auto numtop = widthSegments * (noInside ? 1 : 2);
1001 auto numbottom = widthSegments * (noInside ? 1 : 2);
1002 auto numcut = (phiLength == 360.) ? 0 : heightSegments * (noInside ? 2 : 4);
1004 return numoutside * (noInside ? 1 : 2) + numtop + numbottom + numcut;
1007 return countTubeFaces({cone->GetRmax2(), cone->GetRmax1()}, {cone->GetRmin2(), cone->GetRmin1()});
1010 return countTubeFaces({cone->GetRmax2(), cone->GetRmax1()}, {cone->GetRmin2(), cone->GetRmin1()},
1011 cone->GetPhi2() - cone->GetPhi1());
1014 return countTubeFaces({tube->GetRmax(), tube->GetRmax()}, {tube->GetRmin(), tube->GetRmin()});
1017 return countTubeFaces({tube->GetRmax(), tube->GetRmax()}, {tube->GetRmin(), tube->GetRmin()},
1018 tube->GetPhi2() - tube->GetPhi1());
1021 return countTubeFaces({tube->GetRmax(), tube->GetRmax()}, {tube->GetRmin(), tube->GetRmin()},
1022 tube->GetPhi2() - tube->GetPhi1());
1029 return (torus->GetRmin() > 0 ? 4 : 2) * radialSegments * (tubularSegments + (torus->GetDphi() != 360. ? 1 : 0));
1033 bool hasrmin =
false;
1035 for (
int layer = 0; layer < pcon->GetNz(); ++layer)
1036 if (pcon->GetRmin(layer) > 0.)
1038 return (hasrmin ? 4 : 2) * radiusSegments * (pcon->GetNz() - 1);
1042 bool hasrmin =
false;
1044 for (
int layer = 0; layer < pgon->GetNz(); ++layer)
1045 if (pgon->GetRmin(layer) > 0.)
1047 return (hasrmin ? 4 : 2) * radiusSegments * (pgon->GetNz() - 1);
1050 return (xtru->GetNz() - 1) * xtru->GetNvert() * 2 + xtru->GetNvert() * 3;
1054 int numfaces = (heightSegments + 1) * radiusSegments * 2;
1055 if (para->GetRlo() == 0.)
1056 numfaces -= radiusSegments * 2;
1057 if (para->GetRhi() == 0.)
1058 numfaces -= radiusSegments * 2;
1065 return radiusSegments * (heightSegments + 1) * ((hype->
GetRmin() > 0.) ? 4 : 2);
1069 for (
int i = 0; i < tess->GetNfacets(); ++i) {
1070 if (tess->GetFacet(i).GetNvert() == 4)
1081 if (!comp->GetBoolNode())
1098 if (elem.nfaces == 0) {
1111 elem.fShapeInfo.shape = shape;
1125 Int_t num_vertices = mesh->NumberOfVertices(), num_polynoms = 0;
1127 for (
unsigned polyIndex = 0; polyIndex < mesh->NumberOfPolys(); ++polyIndex) {
1129 auto size_of_polygon = mesh->SizeOfPoly(polyIndex);
1131 if (size_of_polygon >= 3)
1132 num_polynoms += (size_of_polygon - 2);
1135 Int_t index_buffer_size = num_polynoms * 3,
1136 vertex_buffer_size = num_vertices * 3;
1138 elem.nfaces = num_polynoms;
1140 std::vector<float> vertices(vertex_buffer_size);
1142 for (
Int_t i = 0; i < num_vertices; ++i) {
1143 auto v = mesh->GetVertex(i);
1144 vertices[i * 3] =
v[0];
1145 vertices[i * 3 + 1] =
v[1];
1146 vertices[i * 3 + 2] =
v[2];
1149 elem.fRawInfo.raw.resize(vertices.size() *
sizeof(
float));
1151 memcpy(
reinterpret_cast<char *
>(elem.fRawInfo.raw.data()), vertices.data(), vertices.size() *
sizeof(
float));
1153 auto &indexes = elem.fRawInfo.idx;
1155 indexes.resize(index_buffer_size);
1158 for (
unsigned polyIndex = 0; polyIndex < mesh->NumberOfPolys(); ++polyIndex) {
1159 auto size_of_polygon = mesh->SizeOfPoly(polyIndex);
1162 if (size_of_polygon >= 3)
1163 for (
int i = 0; i < 3; ++i)
1164 indexes[pos++] = mesh->GetVertexIndex(polyIndex, i);
1167 if (size_of_polygon > 3)
1168 for (
unsigned vertex = 3; vertex < size_of_polygon; vertex++) {
1169 indexes[pos++] = mesh->GetVertexIndex(polyIndex, 0);
1170 indexes[pos++] = mesh->GetVertexIndex(polyIndex, vertex - 1);
1171 indexes[pos++] = mesh->GetVertexIndex(polyIndex, vertex);
1199 node.
material = material->GetName();
1201 auto fillstyle = material->GetFillStyle();
1202 if ((fillstyle >= 3000) && (fillstyle <= 3100))
1203 node.
opacity = (3100 - fillstyle) / 100.;
1212 colbuf.
Form(
"#%02x%02x%02x", (
int)(col->
GetRed() * 255), (
int)(col->
GetGreen() * 255),
1258 std::vector<int> viscnt(
fDesc.size(), 0);
1263 int numnodes =
ScanNodes(
true, level, [&viscnt](
RGeomNode &node, std::vector<int> &,
bool,
int) {
1271 viscnt.assign(viscnt.size(), 0);
1272 numnodes =
ScanNodes(
true, level, [&viscnt](
RGeomNode &node, std::vector<int> &,
bool,
int) {
1282 int totalnumfaces = 0, totalnumnodes = 0;
1290 auto &desc =
fDesc[sid];
1292 if ((viscnt[sid] <= 0) || (desc.vol <= 0))
1303 if (shape_descr.nfaces <= 0) {
1304 R__LOG_ERROR(
RGeomLog()) <<
"No faces for the shape " << shape->GetName() <<
" class " << shape->ClassName();
1309 totalnumfaces += shape_descr.nfaces * viscnt[sid];
1314 totalnumnodes += viscnt[sid];
1326 bool has_shape =
false;
1328 ScanNodes(
true, level, [&,
this](
RGeomNode &node, std::vector<int> &stack,
bool,
int seqid) {
1330 drawing.visibles.emplace_back(node.id, seqid, stack);
1332 auto &item = drawing.visibles.back();
1333 item.color = node.color;
1334 item.opacity = node.opacity;
1336 auto volume = GetVolume(node.id);
1338 auto &sd = MakeShapeDescr(volume->GetShape());
1340 item.ri = sd.rndr_info();
1423 if ((nodeid < 0) || (nodeid >= (
int)
fDesc.size()))
1426 auto &desc =
fDesc[nodeid];
1428 return (desc.sortid <
fDrawIdCut) && desc.IsVisible() && desc.CanDisplay() && (desc.chlds.empty());
1444 hjson =
"FOUND:RESET";
1448 std::vector<int> nodescnt(
fDesc.size(), 0), viscnt(
fDesc.size(), 0);
1451 std::string test = find;
1453 if (test.compare(0, 2,
"c:") == 0) {
1456 }
else if (test.compare(0, 2,
"m:") == 0) {
1463 auto match_func = [®exp, kind](
RGeomNode &node) {
1464 return (node.vol > 0) && (
TString(node.GetArg(kind)).
Index(regexp) >= 0);
1469 [&nodescnt, &viscnt, &match_func, &nmatches](
RGeomNode &node, std::vector<int> &,
bool is_vis,
int) {
1470 if (match_func(node)) {
1472 nodescnt[node.
id]++;
1480 if (nmatches == 0) {
1486 hjson =
"FOUND:Too many " + std::to_string(nmatches);
1492 int totalnumfaces = 0, totalnumnodes = 0, scnt = 0;
1493 bool send_rawdata =
true;
1500 if (viscnt[sid] == 0)
1503 auto &desc =
fDesc[sid];
1504 if ((viscnt[sid] <= 0) && (desc.vol <= 0))
1515 if (shape_descr.nfaces <= 0) {
1516 R__LOG_ERROR(
RGeomLog()) <<
"No faces for the shape " << shape->GetName() <<
" class " << shape->ClassName();
1521 totalnumfaces += shape_descr.nfaces * viscnt[sid];
1523 send_rawdata =
false;
1528 totalnumnodes += viscnt[sid];
1530 send_rawdata =
false;
1541 std::vector<RGeomNodeBase> found_desc;
1542 std::vector<int> found_map(
fDesc.size(), -1);
1546 found_desc.emplace_back(0);
1547 found_desc[0].vis =
fDesc[0].vis;
1548 found_desc[0].name =
fDesc[0].name;
1549 found_desc[0].color =
fDesc[0].color;
1555 bool has_shape =
true;
1557 ScanNodes(
false, 0, [&,
this](
RGeomNode &node, std::vector<int> &stack,
bool is_vis,
int seqid) {
1559 if (!match_func(node))
1564 for (
auto &s : stack) {
1565 int chldid =
fDesc[prntid].chlds[s];
1566 if (found_map[chldid] <= 0) {
1567 int newid = found_desc.size();
1568 found_desc.emplace_back(newid);
1569 found_map[chldid] = newid;
1571 found_desc.back().vis =
fDesc[chldid].vis;
1572 found_desc.back().name =
fDesc[chldid].name;
1573 found_desc.back().color =
fDesc[chldid].color;
1574 found_desc.back().material =
fDesc[chldid].material;
1577 auto pid = found_map[prntid];
1578 auto cid = found_map[chldid];
1581 auto &pchlds = found_desc[pid].chlds;
1582 if (std::find(pchlds.begin(), pchlds.end(), cid) == pchlds.end())
1583 pchlds.emplace_back(cid);
1592 drawing.
visibles.emplace_back(node.
id, seqid, stack);
1601 auto &item = drawing.
visibles.back();
1604 item.color = node.
color;
1609 item.ri = sd.rndr_info();
1633 for (
auto &chindx : stack) {
1634 auto &node =
fDesc[nodeid];
1635 if (chindx >= (
int)node.chlds.size())
1637 nodeid = node.chlds[chindx];
1650 std::vector<int> stack;
1656 printf(
"Wrong first id\n");
1662 for (
unsigned k = 1; k < ids.size(); ++k) {
1664 int prntid = nodeid;
1667 if (nodeid >= (
int)
fDesc.size()) {
1668 printf(
"Wrong node id %d\n", nodeid);
1672 auto &chlds =
fDesc[prntid].chlds;
1673 auto pos = std::find(chlds.begin(), chlds.end(), nodeid);
1674 if (pos == chlds.end()) {
1675 printf(
"Wrong id %d not a child of %d - fail to find stack num %d\n", nodeid, prntid, (
int)chlds.size());
1680 stack.emplace_back(std::distance(chlds.begin(), pos));
1694 std::vector<int> res;
1712 std::vector<int> ids;
1714 ids.emplace_back(0);
1716 bool failure =
false;
1718 for (
auto s : stack) {
1719 auto &chlds =
fDesc[nodeid].chlds;
1720 if (s >= (
int)chlds.size()) {
1725 ids.emplace_back(chlds[s]);
1731 printf(
"Fail to convert stack into list of nodes\n");
1745 std::vector<std::string> path;
1748 path.reserve(ids.size());
1750 path.emplace_back(
fDesc[
id].name);
1763 std::vector<RGeomNodeBase *> nodes;
1770 for (
auto &desc :
fDesc)
1772 nodes.emplace_back(&desc);
1797 ScanNodes(
true, 0, [&,
this](
RGeomNode &node, std::vector<int> &stack,
bool,
int seq_id) {
1804 if (node.
id != nodeid)
1808 drawing.
visibles.emplace_back(node.
id, seq_id, stack);
1810 auto &item = drawing.
visibles.back();
1812 item.color = node.
color;
1825 bool has_shape =
false, has_raw =
false;
1830 for (
auto &item : drawing.
visibles) {
1831 item.ri = sd.rndr_info();
1842 return has_raw || has_shape;
1862 json.SetSkipClassInfo(TClass::GetClass<RGeomDrawing>());
1863 json.SetSkipClassInfo(TClass::GetClass<RGeomNode>());
1864 json.SetSkipClassInfo(TClass::GetClass<RGeomVisible>());
1865 json.SetSkipClassInfo(TClass::GetClass<RGeomShapeRenderInfo>());
1866 json.SetSkipClassInfo(TClass::GetClass<RGeomRawRenderInfo>());
1868 return json.StoreObject(&drawing, TClass::GetClass<RGeomDrawing>()).Data();
1885 auto &dnode =
fDesc[nodeid];
1890 if (vol->IsVisible() == selected)
1893 dnode.vis = selected ? 99 : 0;
1894 vol->SetVisibility(selected);
1895 if (!dnode.chlds.empty()) {
1898 vol->SetVisDaughters(selected);
1902 for (
auto &desc :
fDesc)
1904 desc.vis = dnode.vis;
1910 if (compare_stacks(iter->stack, stack) == 0) {
1930 std::unique_ptr<RGeomNodeInfo> res;
1940 res = std::make_unique<RGeomNodeInfo>();
1943 res->node_name = node ? node->GetName() :
"node_name";
1944 res->node_type = node ? node->ClassName() :
"no class";
1948 TGeoShape *shape = vol ? vol->GetShape() :
nullptr;
1951 res->shape_name = shape->
GetName();
1955 if (shape && desc.CanDisplay()) {
1959 res->ri = shape_descr.rndr_info();
2009 auto res = compare_stacks(iter->stack, stack);
2012 bool changed = iter->visible !=
on;
2018 if ((
fDesc[nodeid].vis > 0) ==
on)
2043 std::vector<std::string> path;
2044 std::string::size_type p1 = 0;
2046 while (p1 < itemname.length()) {
2047 if (itemname[p1] ==
'/') {
2051 auto p = itemname.find(
'/', p1);
2052 if (
p == std::string::npos) {
2053 path.emplace_back(itemname.substr(p1));
2054 p1 = itemname.length();
2056 path.emplace_back(itemname.substr(p1,
p - p1));
2071 unsigned sz = item.stack.size();
2072 if (stack.size() < sz)
2075 for (
unsigned n = 0;
n < sz; ++
n)
2076 if (stack[
n] != item.stack[
n]) {
2082 return item.visible ? 1 : 0;
2102 if (compare_stacks(iter->stack, stack) == 0) {
2132 auto cfg = TBufferJSON::FromJSON<RGeomConfig>(
json);
2170 std::string prefix =
" ";
2179 fs << prefix <<
name <<
"SetTopVisible(true);" << std::endl;
2183 fs << prefix <<
name <<
"SetNSegments(" <<
fCfg.
nsegm <<
");" << std::endl;
2185 fs << prefix <<
name <<
"SetDrawOptions(\"" <<
fCfg.
drawopt <<
"\");" << std::endl;
2187 fs << prefix <<
name <<
"SetJsonComp(" <<
fJsonComp <<
");" << std::endl;
2192 fs << prefix <<
name <<
"SetPhysNodeVisibility(";
2193 for (
int i = 0; i < (
int)path.size(); ++i)
2194 fs << (i == 0 ?
"{\"" :
", \"") << path[i] <<
"\"";
2195 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(...)
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void funcs
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize fs
R__EXTERN TGeoManager * 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.
Iterator of hierarchical geometry structures.
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
bool showtop
show geometry top volume, off by default
int maxnumfaces
maximal number of faces
int vislevel
visible level
int maxnumnodes
maximal number of nodes
std::string drawopt
draw options for TGeoPainter
int build_shapes
when shapes build on server 0 - never, 1 - TGeoComposite, 2 - plus non-cylindrical,...
int nsegm
number of segments for cylindrical shapes
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
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
void SetCompact(int level)
Set level of space/newline/array compression Lower digit of compact parameter define formatting rules...
The color creation and management class.
static Int_t GetColor(const char *hexcolor)
Static method returning color number for color specified by hex color string of form: "#rrggbb",...
Composite shapes are Boolean combinations of two or more shape components.
TGeoBoolNode * GetBoolNode() const
A cone segment is a cone having a range in phi.
The cones are defined by 5 parameters:
The cut tubes constructor has the form:
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
A hyperboloid is represented as a solid limited by two planes perpendicular to the Z axis (top and bo...
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
void SetNsegments(Int_t nseg)
Set number of segments for approximating circles in drawing.
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 polycone is represented by a sequence of tubes/cones, glued together at defined Z planes.
Polygons are defined in the same way as polycones, the difference being just that the segments betwee...
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
TGeoSphere are not just balls having internal and external radii, but sectors of a sphere having defi...
Int_t GetNumberOfDivisions() const
virtual Double_t GetRmin() const
The torus is defined by its axial radius, its inner and outer radius.
A tube segment is a tube having a range in phi.
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.