14 #ifndef CORE_VISUALIZATION_ROOT_ADAPTOR_H_
15 #define CORE_VISUALIZATION_ROOT_ADAPTOR_H_
20 #include <TGeoManager.h>
24 #include "Math/AxisAngle.h"
25 #include "Math/EulerAngles.h"
37 using ROOT::Math::AxisAngle;
38 using ROOT::Math::EulerAngles;
55 if (total_steps % param->visualization_interval != 0) {
64 auto container =
new TGeoVolumeAssembly(
"A");
66 top_->AddNode(container,
top_->GetNdaughters());
69 gSystem->ProcessEvents();
70 gGeoManager->Export(
outfile_.c_str(),
"biodynamo");
73 void DrawInCanvas(
size_t w = 300,
size_t h = 300, std::string opt =
"") {
74 canvas_->GetListOfPrimitives()->Clear();
76 canvas_->GetListOfPrimitives()->Add(gGeoManager->GetTopVolume(),
"all");
79 canvas_->GetListOfPrimitives()->Add(gGeoManager->GetTopVolume(),
82 canvas_->SetCanvasSize(
static_cast<UInt_t
>(w),
static_cast<UInt_t
>(h));
89 gGeoManager =
new TGeoManager(
"Visualization",
"BioDynaMo");
90 canvas_ =
new TCanvas(
"BioDynaMo Canvas",
"For ROOT Notebooks ", 300, 300);
96 gGeoManager->SetNsegments(15);
99 mat_solid_ =
new TGeoMaterial(
"Solid", .938, 1., 10000.);
105 top_ =
new TGeoVolumeAssembly(
"WORLD");
107 gGeoManager->SetTopVolume(
top_);
108 gGeoManager->SetVisLevel(4);
117 canvas_->GetListOfPrimitives()->Add(gGeoManager->GetTopVolume(),
"all");
133 "Tried to add a shape to the Root visualization that's not "
134 "one of the supported types : ",
145 auto x = massLocation[0];
146 auto y = massLocation[1];
147 auto z = massLocation[2];
148 auto position =
new TGeoTranslation(x, y, z);
149 auto volume = gGeoManager->MakeSphere(name.c_str(),
med_solid_, 0, radius);
150 volume->SetLineColor(kBlue);
151 container->AddNode(volume, container->GetNdaughters(), position);
158 auto radius = neurite->GetDiameter() / 2;
159 auto half_length = neurite->GetLength() / 2;
160 auto massLocation = neurite->GetPosition();
161 auto x = massLocation[0];
162 auto y = massLocation[1];
163 auto z = massLocation[2];
164 auto trans =
new TGeoTranslation(x, y, z);
167 TVector3 orig(0, 0, 1);
171 Real3 d = neurite->GetSpringAxis();
172 TVector3 dir(d[0], d[1], d[2]);
176 auto dot_product = dir.Dot(orig);
177 auto angle = std::acos(dot_product);
179 TVector3 n = dir.Cross(orig);
181 auto axis = AxisAngle::AxisVector(n[0], n[1], n[2]);
182 AxisAngle aa(axis, angle);
184 TGeoRotation *rot =
new TGeoRotation(
"rot",
Math::ToDegree(ea.Phi()),
187 TGeoCombiTrans *transrot =
new TGeoCombiTrans(*trans, *rot);
188 auto volume = gGeoManager->MakeTube(name.c_str(),
med_solid_, 0, radius,
190 volume->SetLineColor(kBlue);
191 container->AddNode(volume, container->GetNdaughters(), transrot);
193 Log::Error(
"RootAdaptor",
"This is not a cylindrical shaped object!");
218 #endif // CORE_VISUALIZATION_ROOT_ADAPTOR_H_