Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bring back morphology types as enum array in HTTP API #271

Merged
merged 1 commit into from
Jan 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion brayns/common/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,13 +256,22 @@ enum class GeometryQuality
/** Morphology element types */
enum class MorphologySectionType
{
undefined = 0x00,
soma = 0x01,
axon = 0x02,
dendrite = 0x04,
apical_dendrite = 0x08,
all = 0xff
};
using MorphologySectionTypes = std::vector<MorphologySectionType>;

template <typename T>
size_t enumsToBitmask(const std::vector<T> enums)
{
size_t bit{0};
for (auto& val : enums)
bit |= size_t(val);
return bit;
}

/**
* @brief The Histogram struct contains the range as well as the values of the
Expand Down
6 changes: 3 additions & 3 deletions brayns/io/MorphologyLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ class MorphologyLoader::Impl
try
{
const size_t morphologySectionTypes =
_geometryParameters.getMorphologySectionTypes();
enumsToBitmask(_geometryParameters.getMorphologySectionTypes());

brain::neuron::Morphology morphology(uri, transformation);
const auto sectionTypes = _getSectionTypes(morphologySectionTypes);
Expand Down Expand Up @@ -590,7 +590,7 @@ class MorphologyLoader::Impl
Vector3f translation;

const size_t morphologySectionTypes =
_geometryParameters.getMorphologySectionTypes();
enumsToBitmask(_geometryParameters.getMorphologySectionTypes());

brain::neuron::Morphology morphology(uri, transformation);
brain::neuron::SectionTypes sectionTypes;
Expand Down Expand Up @@ -871,7 +871,7 @@ class MorphologyLoader::Impl
{
bool returnValue = true;
const size_t morphologySectionTypes =
_geometryParameters.getMorphologySectionTypes();
enumsToBitmask(_geometryParameters.getMorphologySectionTypes());
if (morphologySectionTypes ==
static_cast<size_t>(MorphologySectionType::soma))
return _importMorphologyAsPoint(index, material, transformation,
Expand Down
22 changes: 17 additions & 5 deletions brayns/parameters/GeometryParameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ GeometryParameters::GeometryParameters()
, _radiusCorrection(0.f)
, _colorScheme(ColorScheme::none)
, _geometryQuality(GeometryQuality::high)
, _morphologySectionTypes(size_t(MorphologySectionType::all))
, _morphologySectionTypes{MorphologySectionType::all}
, _metaballsGridSize(0)
, _metaballsThreshold(1.f)
, _metaballsSamplesFromSoma(3)
Expand Down Expand Up @@ -297,8 +297,20 @@ bool GeometryParameters::_parse(const po::variables_map& vm)
_circuitConfiguration._circuitMeshFolder =
vm[PARAM_CIRCUIT_MESH_FOLDER].as<std::string>();
if (vm.count(PARAM_MORPHOLOGY_SECTION_TYPES))
_morphologySectionTypes =
vm[PARAM_MORPHOLOGY_SECTION_TYPES].as<size_t>();
{
_morphologySectionTypes.clear();
const auto bits = vm[PARAM_MORPHOLOGY_SECTION_TYPES].as<size_t>();
if (bits & size_t(MorphologySectionType::soma))
_morphologySectionTypes.push_back(MorphologySectionType::soma);
if (bits & size_t(MorphologySectionType::axon))
_morphologySectionTypes.push_back(MorphologySectionType::axon);
if (bits & size_t(MorphologySectionType::dendrite))
_morphologySectionTypes.push_back(MorphologySectionType::dendrite);
if (bits & size_t(MorphologySectionType::apical_dendrite))
_morphologySectionTypes.push_back(
MorphologySectionType::apical_dendrite);
}

if (vm.count(PARAM_MORPHOLOGY_LAYOUT))
{
size_ts values = vm[PARAM_MORPHOLOGY_LAYOUT].as<size_ts>();
Expand Down Expand Up @@ -473,8 +485,8 @@ void GeometryParameters::print()
<< (_circuitConfiguration._circuitMeshTransformation ? "Yes"
: "No")
<< std::endl;
BRAYNS_INFO << "Morphology section types : " << _morphologySectionTypes
<< std::endl;
BRAYNS_INFO << "Morphology section types : "
<< enumsToBitmask(_morphologySectionTypes) << std::endl;
BRAYNS_INFO << "Morphology Layout : " << std::endl;
BRAYNS_INFO << " - Columns : "
<< _morphologyLayout.nbColumns << std::endl;
Expand Down
7 changes: 5 additions & 2 deletions brayns/parameters/GeometryParameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,10 @@ class GeometryParameters : public AbstractParameters
const GeometryQuality value) const;

/** Morphology section types*/
size_t getMorphologySectionTypes() const { return _morphologySectionTypes; }
const MorphologySectionTypes& getMorphologySectionTypes() const
{
return _morphologySectionTypes;
}
/** Morphology layout */
const MorphologyLayout& getMorphologyLayout() const
{
Expand Down Expand Up @@ -341,7 +344,7 @@ class GeometryParameters : public AbstractParameters
float _radiusCorrection;
ColorScheme _colorScheme;
GeometryQuality _geometryQuality;
size_t _morphologySectionTypes;
MorphologySectionTypes _morphologySectionTypes;
MorphologyLayout _morphologyLayout;
bool _generateMultipleModels;
std::string _molecularSystemConfig;
Expand Down
1 change: 0 additions & 1 deletion plugins/extensions/plugins/SDK.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ STATICJSON_DECLARE_ENUM(brayns::GeometryQuality,
{"high", brayns::GeometryQuality::high});

STATICJSON_DECLARE_ENUM(brayns::MorphologySectionType,
{"undefined", brayns::MorphologySectionType::undefined},
{"soma", brayns::MorphologySectionType::soma},
{"axon", brayns::MorphologySectionType::axon},
{"dendrite", brayns::MorphologySectionType::dendrite},
Expand Down
6 changes: 4 additions & 2 deletions tests/brayns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,10 @@ BOOST_AUTO_TEST_CASE(defaults)
brayns::SceneEnvironment::none);
BOOST_CHECK(geomParams.getGeometryQuality() ==
brayns::GeometryQuality::high);
BOOST_CHECK_EQUAL(geomParams.getMorphologySectionTypes(),
size_t(brayns::MorphologySectionType::all));
BOOST_CHECK_EQUAL(
brayns::enumsToBitmask(geomParams.getMorphologySectionTypes()),
brayns::enumsToBitmask(std::vector<brayns::MorphologySectionType>{
brayns::MorphologySectionType::all}));
BOOST_CHECK_EQUAL(geomParams.getMorphologyLayout().nbColumns, 0);
BOOST_CHECK_EQUAL(geomParams.getCircuitStartSimulationTime(), 0.f);
BOOST_CHECK_EQUAL(geomParams.getCircuitEndSimulationTime(),
Expand Down