12 #ifndef ROOT7_REveGeomData
13 #define ROOT7_REveGeomData
31 namespace Experimental {
34 class RGeomBrowserIter;
38 class REveGeomNodeBase {
42 std::vector<int> chlds;
49 REveGeomNodeBase(
int _id = 0) : id(_id) {}
51 bool IsVisible()
const {
return vis > 0; }
56 class REveGeomNode :
public REveGeomNodeBase {
58 std::vector<float> matr;
65 REveGeomNode(
int _id = 0) : REveGeomNodeBase(_id) {}
68 bool CanDisplay()
const {
return (vol > 0.) && (nfaces > 0); }
72 class RGeomRenderInfo {
75 virtual ~RGeomRenderInfo() =
default;
79 class RGeomRawRenderInfo :
public RGeomRenderInfo {
83 std::vector<unsigned char> raw;
84 virtual ~RGeomRawRenderInfo() =
default;
88 class RGeomShapeRenderInfo :
public RGeomRenderInfo {
90 TGeoShape *shape{
nullptr};
91 virtual ~RGeomShapeRenderInfo() =
default;
98 class REveGeomVisible {
102 std::vector<int> stack;
105 RGeomRenderInfo *ri{
nullptr};
107 REveGeomVisible() =
default;
108 REveGeomVisible(
int _nodeid,
int _seqid,
const std::vector<int> &_stack) : nodeid(_nodeid), seqid(_seqid), stack(_stack) {}
115 class REveGeomConfig {
130 class REveGeomDrawing {
132 REveGeomConfig *cfg{
nullptr};
134 std::vector<REveGeomNode*> nodes;
135 std::vector<REveGeomVisible> visibles;
140 class REveGeomRequest {
144 std::vector<int> stack;
147 class REveGeomNodeInfo {
149 std::string fullpath;
150 std::string node_type;
151 std::string node_name;
152 std::string shape_type;
153 std::string shape_name;
155 RGeomRenderInfo *ri{
nullptr};
158 using REveGeomScanFunc_t = std::function<bool(REveGeomNode &, std::vector<int> &, bool, int)>;
161 class REveGeomDescription {
163 friend class RGeomBrowserIter;
168 TGeoShape *fShape{
nullptr};
170 RGeomRawRenderInfo fRawInfo;
171 RGeomShapeRenderInfo fShapeInfo;
172 ShapeDescr(TGeoShape *s) : fShape(s) {}
174 bool has_shape()
const {
return nfaces == 1; }
175 bool has_raw()
const {
return nfaces > 1; }
178 RGeomRenderInfo *rndr_info()
180 if (has_shape())
return &fShapeInfo;
181 if (has_raw())
return &fRawInfo;
188 fShapeInfo.shape =
nullptr;
189 fRawInfo.raw.clear();
193 std::vector<TGeoNode *> fNodes;
194 std::vector<REveGeomNode> fDesc;
196 std::vector<int> fSortMap;
197 std::vector<ShapeDescr> fShapes;
199 std::string fDrawJson;
202 bool fPreferredOffline{
false};
207 void PackMatrix(std::vector<float> &arr, TGeoMatrix *matr);
209 int MarkVisible(
bool on_screen =
false);
211 void ProduceIdShifts();
213 int ScanNodes(
bool only_visible,
int maxlvl, REveGeomScanFunc_t func);
215 void ResetRndrInfos();
217 ShapeDescr &FindShapeDescr(TGeoShape *shape);
219 ShapeDescr &MakeShapeDescr(TGeoShape *shape);
221 void CopyMaterialProperties(TGeoVolume *vol, REveGeomNode &node);
223 void CollectNodes(REveGeomDrawing &drawing);
225 std::string MakeDrawingJson(REveGeomDrawing &drawing,
bool has_shapes =
false);
228 REveGeomDescription() =
default;
230 void Build(TGeoManager *mgr,
const std::string &volname =
"");
233 int GetNumNodes()
const {
return fDesc.size(); }
235 bool IsBuild()
const {
return GetNumNodes() > 0; }
238 void SetMaxVisNodes(
int cnt) { fCfg.maxnumnodes = cnt; }
241 int GetMaxVisNodes()
const {
return fCfg.maxnumnodes; }
244 void SetMaxVisFaces(
int cnt) { fCfg.maxnumfaces = cnt; }
247 int GetMaxVisFaces()
const {
return fCfg.maxnumfaces; }
250 void SetVisLevel(
int lvl = 3) { fCfg.vislevel = lvl; }
253 int GetVisLevel()
const {
return fCfg.vislevel; }
257 void SetPreferredOffline(
bool on) { fPreferredOffline = on; }
261 bool IsPreferredOffline()
const {
return fPreferredOffline; }
263 bool CollectVisibles();
265 bool IsPrincipalEndNode(
int nodeid);
267 std::string ProcessBrowserRequest(
const std::string &req =
"");
269 bool HasDrawData()
const {
return (fDrawJson.length() > 0) && (fDrawIdCut > 0); }
270 const std::string &GetDrawJson()
const {
return fDrawJson; }
271 void ClearDrawData();
273 int SearchVisibles(
const std::string &find, std::string &hjson, std::string &json);
275 int FindNodeId(
const std::vector<int> &stack);
277 std::string ProduceModifyReply(
int nodeid);
279 std::vector<int> MakeStackByIds(
const std::vector<int> &ids);
281 std::vector<int> MakeIdsByStack(
const std::vector<int> &stack);
283 std::vector<int> MakeStackByPath(
const std::string &path);
285 std::string MakePathByStack(
const std::vector<int> &stack);
287 bool ProduceDrawingFor(
int nodeid, std::string &json,
bool check_volume =
false);
289 bool ChangeNodeVisibility(
int nodeid,
bool selected);
292 void SetNSegments(
int n = 0) { fCfg.nsegm = n; }
294 int GetNSegments()
const {
return fCfg.nsegm; }
297 void SetJsonComp(
int comp = 0) { fJsonComp = comp; }
299 int GetJsonComp()
const {
return fJsonComp; }
302 void SetDrawOptions(
const std::string &opt =
"") { fCfg.drawopt = opt; }
304 std::string GetDrawOptions()
const {
return fCfg.drawopt; }
307 void SetBuildShapes(
int lvl = 1) { fCfg.build_shapes = lvl; }
309 int IsBuildShapes()
const {
return fCfg.build_shapes; }
311 bool ChangeConfiguration(
const std::string &json);
313 std::unique_ptr<REveGeomNodeInfo> MakeNodeInfo(
const std::string &path);