Skip to content

Commit

Permalink
Merge pull request #352 from favreau/master
Browse files Browse the repository at this point in the history
Replace Octree volume type with Field geometry object
  • Loading branch information
favreau authored Jan 15, 2024
2 parents cf7cae7 + a71165a commit 000e44d
Show file tree
Hide file tree
Showing 1,328 changed files with 41,878 additions and 43,395 deletions.
11 changes: 5 additions & 6 deletions bioexplorer/backend/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,8 @@ set(${NAME}_SOURCES
science/common/shapes/PointShape.cpp
science/common/Assembly.cpp
science/common/ThreadSafeContainer.cpp
science/fields/FieldsHandler.cpp
science/fields/PointFieldsHandler.cpp
science/fields/VectorFieldsHandler.cpp
science/fields/PointFieldBuilder.cpp
science/fields/VectorFieldBuilder.cpp
science/io/CacheLoader.cpp
science/io/OOCManager.cpp
science/io/db/DBConnector.cpp
Expand Down Expand Up @@ -145,9 +144,9 @@ set(${NAME}_PUBLIC_HEADERS
science/common/shapes/RNAShape.h
science/common/shapes/PointShape.h
science/meshing/PointCloudMesher.h
science/fields/FieldsHandler.h
science/fields/PointFieldsHandler.h
science/fields/VectorFieldsHandler.h
science/fields/FieldBuilder.h
science/fields/PointFieldBuilder.h
science/fields/VectorFieldBuilder.h
science/meshing/SurfaceMesher.h
science/api/Params.h
science/BioExplorerPlugin.h
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void DensityRenderer::commit()

// Transfer function
::ospray::TransferFunction* transferFunction =
(::ospray::TransferFunction*)getParamObject(RENDERER_PROPERTY_TRANSFER_FUNCTION, nullptr);
(::ospray::TransferFunction*)getParamObject(DEFAULT_COMMON_TRANSFER_FUNCTION, nullptr);
if (transferFunction)
::ispc::DensityRenderer_setTransferFunction(getIE(), transferFunction->getIE());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void PointFieldsRenderer::commit()

// Transfer function
::ospray::TransferFunction* transferFunction =
(::ospray::TransferFunction*)getParamObject(RENDERER_PROPERTY_TRANSFER_FUNCTION, nullptr);
(::ospray::TransferFunction*)getParamObject(DEFAULT_COMMON_TRANSFER_FUNCTION, nullptr);
if (transferFunction)
::ispc::PointFieldsRenderer_setTransferFunction(getIE(), transferFunction->getIE());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void VectorFieldsRenderer::commit()

// Transfer function
::ospray::TransferFunction* transferFunction =
(::ospray::TransferFunction*)getParamObject(RENDERER_PROPERTY_TRANSFER_FUNCTION, nullptr);
(::ospray::TransferFunction*)getParamObject(DEFAULT_COMMON_TRANSFER_FUNCTION, nullptr);
if (transferFunction)
::ispc::VectorFieldsRenderer_setTransferFunction(getIE(), transferFunction->getIE());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void MetabolismRenderer::commit()

// Transfer function
::ospray::TransferFunction* transferFunction =
(::ospray::TransferFunction*)getParamObject(RENDERER_PROPERTY_TRANSFER_FUNCTION, nullptr);
(::ospray::TransferFunction*)getParamObject(DEFAULT_COMMON_TRANSFER_FUNCTION, nullptr);
if (transferFunction)
::ispc::MetabolismRenderer_setTransferFunction(getIE(), transferFunction->getIE());

Expand Down
16 changes: 6 additions & 10 deletions bioexplorer/backend/science/BioExplorerPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#include <science/common/Properties.h>
#include <science/common/Utils.h>
#include <science/connectomics/whitematter/WhiteMatterLoader.h>
#include <science/fields/PointFieldBuilder.h>
#include <science/fields/VectorFieldBuilder.h>
#include <science/io/CacheLoader.h>
#include <science/io/OOCManager.h>
#include <science/morphologies/AstrocytesLoader.h>
Expand Down Expand Up @@ -1796,20 +1798,14 @@ Response BioExplorerPlugin::_buildFields(const BuildFieldsDetails &payload)
{
case FieldDataType::point:
{
auto handler = std::make_shared<PointFieldsHandler>(engine, *model, payload.voxelSize, payload.density,
payload.modelIds);
// Force Octree initialization (if not already done) by specifying a negative frame number
handler->getFrameData(-1);
model->setSimulationHandler(handler);
PointFieldBuilder builder;
builder.buildOctree(engine, *model, payload.voxelSize, payload.density, payload.modelIds);
break;
}
case FieldDataType::vector:
{
auto handler = std::make_shared<VectorFieldsHandler>(engine, *model, payload.voxelSize, payload.density,
payload.modelIds);
// Force Octree initialization (if not already done) by specifying a negative frame number
handler->getFrameData(-1);
model->setSimulationHandler(handler);
VectorFieldBuilder builder;
builder.buildOctree(engine, *model, payload.voxelSize, payload.density, payload.modelIds);
break;
}
default:
Expand Down
2 changes: 0 additions & 2 deletions bioexplorer/backend/science/BioExplorerPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
#pragma once

#include <science/api/Params.h>
#include <science/fields/PointFieldsHandler.h>
#include <science/fields/VectorFieldsHandler.h>
#include <science/vasculature/Vasculature.h>

#include <platform/core/pluginapi/ExtensionPlugin.h>
Expand Down
16 changes: 7 additions & 9 deletions bioexplorer/backend/science/connectomics/synaptome/Synaptome.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ void Synaptome::_addNode(const uint64_t id, const Vector3f& position, float mass
void Synaptome::_addEdge(uint64_t source, uint64_t target, const core::Vector3f& direction)
{
_edges.push_back({source, target});
_nodes[source].position += direction;
_nodes[source].direction += direction;
_nodes[source].mass++;
_nodes[target].position -= direction;
_nodes[target].direction -= direction;
_nodes[target].mass++;
}

Expand All @@ -90,7 +90,7 @@ void Synaptome::_buildModel(const LoaderProgress& callback)
const size_t edgeMaterialId = 1;
const bool useSdf = false;
const float nodeRadius = _details.radius;
const float edgeRadius = _details.radius / 10.f;
const float edgeRadius = _details.radius / 5.f;

for (const auto& soma : somas)
_addNode(soma.first, soma.second.position, 1.f);
Expand All @@ -105,14 +105,12 @@ void Synaptome::_buildModel(const LoaderProgress& callback)
_addEdge(edge.first, edge.second, direction);
}
}

// Draw nodes
for (const auto& node : _nodes)
container.addSphere(node.second.position, nodeRadius, nodeMaterialId, useSdf);

// Draw edges
container.addSphere(node.second.position + node.second.direction * node.second.mass, nodeRadius, nodeMaterialId,
useSdf);
for (const auto& edge : _edges)
container.addCone(_nodes[edge.x].position, edgeRadius, _nodes[edge.y].position, edgeRadius,
container.addCone(_nodes[edge.x].position + _nodes[edge.x].direction * _nodes[edge.x].mass, edgeRadius,
_nodes[edge.y].position + _nodes[edge.y].direction * _nodes[edge.y].mass, edgeRadius,
static_cast<size_t>(_nodes[edge.x].mass + 1), useSdf);
container.commitToModel();
model->applyDefaultColormap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,38 +23,28 @@

#pragma once

#include "FieldsHandler.h"
#include <platform/core/common/simulation/AbstractSimulationHandler.h>

#include <platform/core/common/Types.h>
#include <platform/core/engineapi/Scene.h>

namespace bioexplorer
{
namespace fields
{
/**
* @brief The VectorFieldsHandler class handles electro-magnetic fields data
* @brief The FieldBuilder class handles electro-magnetic fields data
* structures
*/
class VectorFieldsHandler : public FieldsHandler
class FieldBuilder
{
public:
/**
* @brief Default constructor
*/
VectorFieldsHandler(core::Engine& engine, core::Model& model, const double voxelSize, const double density,
const uint32_ts& modelIds);
FieldBuilder() {}

/**
* @brief Clone the AbstractSimulationHandler
*
* @return AbstractSimulationHandlerPtr Clone of the AbstractSimulationHandler
*/
core::AbstractSimulationHandlerPtr clone() const final;

private:
void _buildOctree() final;
virtual void buildOctree(core::Engine& engine, core::Model& model, const double voxelSize, const double density,
const uint32_ts& modelIds) = 0;
};
typedef std::shared_ptr<VectorFieldsHandler> VectorFieldsHandlerPtr;
} // namespace fields
} // namespace bioexplorer
76 changes: 0 additions & 76 deletions bioexplorer/backend/science/fields/FieldsHandler.cpp

This file was deleted.

115 changes: 0 additions & 115 deletions bioexplorer/backend/science/fields/FieldsHandler.h

This file was deleted.

Loading

0 comments on commit 000e44d

Please sign in to comment.