Skip to content

Commit

Permalink
Merge pull request #314 from favreau/master
Browse files Browse the repository at this point in the history
Additional information in models metadata
  • Loading branch information
favreau authored Oct 10, 2023
2 parents d49b259 + 95c5a87 commit 1c0d772
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
23 changes: 20 additions & 3 deletions bioexplorer/backend/science/BioExplorerPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1243,7 +1243,9 @@ Response BioExplorerPlugin::_addSpheres(const AddSpheresDetails &payload)
model->addSphere(materialId, {position, static_cast<float>(payload.radii[i])});
}
model->updateBounds();
scene.addModel(std::make_shared<ModelDescriptor>(std::move(model), payload.name));
ModelMetadata metadata;
metadata["Number of spheres"] = std::to_string(payload.radii.size());
scene.addModel(std::make_shared<ModelDescriptor>(std::move(model), payload.name, metadata));
}
CATCH_STD_EXCEPTION()
return response;
Expand Down Expand Up @@ -1279,18 +1281,29 @@ Response BioExplorerPlugin::_addCones(const AddConesDetails &payload)
material->setOpacity(payload.opacity);

PLUGIN_INFO(3, "Adding cones " + payload.name + " to the scene");
uint64_t nbCones = 0;
uint64_t nbCylinders = 0;
for (uint64_t i = 0; i < payload.originsRadii.size(); ++i)
{
const auto origin = Vector3d(origins[i * 3], origins[i * 3 + 1], origins[i * 3 + 2]);
const auto target = Vector3d(targets[i * 3], targets[i * 3 + 1], targets[i * 3 + 2]);
const auto originRadius = payload.originsRadii[i];
const auto targetRadius = payload.targetsRadii[i];
if (originRadius == targetRadius)
{
model->addCylinder(0, {origin, target, static_cast<float>(originRadius)});
++nbCylinders;
}
else
{
model->addCone(0, {origin, target, static_cast<float>(originRadius), static_cast<float>(targetRadius)});
++nbCones;
}
}
scene.addModel(std::make_shared<ModelDescriptor>(std::move(model), payload.name));
ModelMetadata metadata;
metadata["Number of cones"] = std::to_string(nbCones);
metadata["Number of cylinders"] = std::to_string(nbCylinders);
scene.addModel(std::make_shared<ModelDescriptor>(std::move(model), payload.name, metadata));
}
CATCH_STD_EXCEPTION()
return response;
Expand Down Expand Up @@ -1417,6 +1430,7 @@ Response BioExplorerPlugin::_addStreamlines(const AddStreamlinesDetails &payload
auto material = model->createMaterial(0, "Streamlines");
material->setDiffuseColor({1, 1, 1});

uint64_t nbStreamlines = 0;
for (uint64_t index = 0; index < nbIndices - 1; ++index)
{
// Create streamline geometry
Expand Down Expand Up @@ -1455,9 +1469,12 @@ Response BioExplorerPlugin::_addStreamlines(const AddStreamlinesDetails &payload

const Streamline streamline(points, colors, radii);
model->addStreamline(materialId, streamline);
++nbStreamlines;
}

auto modelDescriptor = std::make_shared<core::ModelDescriptor>(std::move(model), name);
ModelMetadata metadata;
metadata["Number of streamlines"] = std::to_string(nbStreamlines);
auto modelDescriptor = std::make_shared<core::ModelDescriptor>(std::move(model), name, metadata);
scene.addModel(modelDescriptor);

PLUGIN_INFO(1, nbIndices << " streamlines added");
Expand Down
2 changes: 1 addition & 1 deletion bioexplorer/backend/science/fields/FieldsHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ void FieldsHandler::_buildOctree(const Scene& scene, const double voxelSize, con
_frameSize = _frameData.size();

PLUGIN_INFO(1, "--------------------------------------------");
PLUGIN_INFO(1, "Octree information");
PLUGIN_INFO(1, "Octree information (" << events.size() / 5 << " events)");
PLUGIN_INFO(1, "--------------------------------------------");
PLUGIN_INFO(1, "Scene AABB : " << bounds);
PLUGIN_INFO(1, "Scene dimension : " << sceneSize);
Expand Down

0 comments on commit 1c0d772

Please sign in to comment.