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

"IQuantVis" first draft #2370

Merged
merged 53 commits into from
Apr 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
c0fe63d
Convert network
dcwhite Dec 14, 2021
f113652
Simplify network
dcwhite Dec 14, 2021
4aac170
Add TendFiber src from 4
dcwhite Dec 16, 2021
71f85f4
Start converting module code
dcwhite Dec 17, 2021
8c13d21
WIP
dcwhite Dec 17, 2021
69b83d2
Module builds
dcwhite Dec 17, 2021
ff15b80
Start converting #2367
dcwhite Jan 26, 2022
84ca68c
Working on algo
dcwhite Jan 26, 2022
5c1da2c
Algo compiles
dcwhite Jan 26, 2022
fc17331
Module compiles
dcwhite Jan 26, 2022
bbfe967
Add gui files
dcwhite Jan 26, 2022
28267fa
UI
dcwhite Jan 26, 2022
62b875b
Windows fix
dcwhite Jan 26, 2022
c40a293
Tested scalar metrics
dcwhite Jan 27, 2022
36ca39b
Wrong return value
dcwhite Jan 27, 2022
7dfe36c
Add module code
dcwhite Jan 28, 2022
ab18916
Add algo
dcwhite Jan 28, 2022
3ab01de
Remove commented code
dcwhite Jan 28, 2022
5c45fc0
Reformat
dcwhite Jan 28, 2022
45bd090
Algo compiles
dcwhite Jan 29, 2022
f97f97b
Fix link
dcwhite Feb 1, 2022
74b8b09
Add GUI skeleton
dcwhite Feb 1, 2022
74ae02f
Working on TendFiber UI
dcwhite Feb 1, 2022
43e9aca
clean up
dcwhite Feb 1, 2022
e29865e
Gui adjustments
dcwhite Feb 1, 2022
7caa7fc
more UI WIP
dcwhite Feb 1, 2022
5ff9582
Finish GUI
dcwhite Feb 2, 2022
1ee5f68
Finish CBD GUI
dcwhite Feb 2, 2022
796459e
Update v4 network
dcwhite Feb 2, 2022
bea4b60
Merge branch 'master' into iquantvis
dcwhite Feb 2, 2022
eca0859
Merge branch 'master' into iquantvis
dcwhite Feb 16, 2022
6151139
Merge branch 'master' into iquantvis
dcwhite Mar 2, 2022
9d946d8
Small fixes + sample network
dcwhite Mar 10, 2022
756cb3f
Update calcBundleDifference.srn5
dcwhite Mar 12, 2022
91788cf
Start on WriteBundle
dcwhite Mar 14, 2022
bdc3f57
Module compiles
dcwhite Mar 15, 2022
d767fce
Add UI
dcwhite Mar 15, 2022
21b75a7
Closes #1646
dcwhite Mar 15, 2022
02202de
Start on CBTF
dcwhite Mar 15, 2022
1d7632e
Algo compiles
dcwhite Mar 16, 2022
247d2c3
Module builds
dcwhite Mar 16, 2022
ebcb2ab
Module works, needs a UI
dcwhite Mar 16, 2022
b6d9b2d
CBTF UI. Closes #2354
dcwhite Mar 16, 2022
4b22f50
Merge branch 'master' into iquantvis
dcwhite Mar 17, 2022
ae54d9b
CodeFactor clean up
dcwhite Mar 18, 2022
1e00b56
Windows ospray build fix
dcwhite Mar 18, 2022
a040699
Closes #2375
dcwhite Mar 18, 2022
a197cd0
Update TendFiber.cc
dcwhite Mar 30, 2022
baef2b3
Add output bundle to SFBCR
dcwhite Mar 30, 2022
d84feb2
some edits to the test networks
jessdtate Mar 30, 2022
e9b466c
added initialization for impl
jessdtate Mar 30, 2022
dc3712a
added initialization for impl
jessdtate Mar 30, 2022
e074d3d
builds now
jessdtate Mar 30, 2022
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
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,7 @@ SET_PROPERTY(TARGET Modules_Legacy_Matlab_DataIO PROPERTY FOLDER "Modules/DataIO
SET_PROPERTY(TARGET Modules_Legacy_Visualization PROPERTY FOLDER "Modules/Visualization")
SET_PROPERTY(TARGET Modules_Legacy_Teem_DataIO PROPERTY FOLDER "Modules/Teem")
SET_PROPERTY(TARGET Modules_Legacy_Teem_Misc PROPERTY FOLDER "Modules/Teem")
SET_PROPERTY(TARGET Modules_Legacy_Teem_Tend PROPERTY FOLDER "Modules/Teem")
SET_PROPERTY(TARGET Modules_Legacy_Teem_Converters PROPERTY FOLDER "Modules/Teem")
SET_PROPERTY(TARGET Modules_Factory PROPERTY FOLDER "Modules")

Expand Down
11 changes: 10 additions & 1 deletion src/Core/Algorithms/Base/AlgorithmData.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ namespace Algorithms {
void setTransient(boost::any t) { transient_ = t; }
boost::any getTransient() const { return transient_; }

private:
protected:
Map data_;
boost::any transient_;
};
Expand All @@ -92,6 +92,15 @@ namespace Algorithms {
public:
VariableHandle additionalAlgoOutput() const { return additionalAlgoOutput_; }
void setAdditionalAlgoOutput(VariableHandle var) { additionalAlgoOutput_ = var; }
Datatypes::DatatypeHandle at(size_t index) const
{
if (index >= size())
return nullptr;
auto iter = data_.begin();
std::advance(iter, index);
return iter->second[0];
}
size_t size() const { return data_.size(); }
private:
VariableHandle additionalAlgoOutput_;
};
Expand Down
4 changes: 3 additions & 1 deletion src/Core/Algorithms/Legacy/Converter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ SET(Core_Algorithms_Legacy_Converter_SRCS
FieldToNrrd.cc
ConvertToNrrd.cc
#MatricesToDipoleField.cc
#ConvertBundleToField.cc
ConvertBundleToField.cc
ConvertMatrixToString.cc
)

Expand All @@ -45,6 +45,7 @@ SET(Core_Algorithms_Legacy_Converter_HEADERS
FieldToNrrd.h
ConvertToNrrd.h
ConvertMatrixToString.h
ConvertBundleToField.h
share.h
)

Expand All @@ -57,6 +58,7 @@ TARGET_LINK_LIBRARIES(Core_Algorithms_Legacy_Converter
Core_Datatypes
Core_Datatypes_Legacy_Field
Core_Datatypes_Legacy_Nrrd
Core_Datatypes_Legacy_Bundle
)

IF(BUILD_SHARED_LIBS)
Expand Down
114 changes: 56 additions & 58 deletions src/Core/Algorithms/Legacy/Converter/ConvertBundleToField.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,71 +29,60 @@
*/


#include <Core/Algorithms/Converter/ConvertBundleToField.h>
#include <Core/Datatypes/MatrixTypeConverter.h>

#include <Core/Datatypes/SparseRowMatrix.h>
#include <Core/Algorithms/Fields/MergeFields/JoinFields.h>
#include <Core/Datatypes/FieldInformation.h>
#include <Core/Datatypes/Mesh.h>
#include <Core/Containers/SearchGridT.h>
#include <vector>
#include <Core/Algorithms/Legacy/Converter/ConvertBundleToField.h>
#include <Core/Algorithms/Base/AlgorithmVariableNames.h>
#include <Core/Algorithms/Base/AlgorithmPreconditions.h>
#include <Core/Datatypes/Legacy/Field/FieldInformation.h>
#include <Core/Datatypes/Legacy/Field/Field.h>
#include <Core/Datatypes/Legacy/Field/VField.h>
#include <Core/Datatypes/Legacy/Field/VMesh.h>
#include <Core/Datatypes/Legacy/Bundle/Bundle.h>

using namespace SCIRun;

namespace SCIRunAlgo {
using namespace SCIRun::Core;
using namespace SCIRun::Core::Algorithms;
using namespace SCIRun::Core::Datatypes;
using namespace SCIRun::Core::Utility;
using namespace SCIRun::Core::Geometry;
using namespace SCIRun::Core::Algorithms::Converters;

ALGORITHM_PARAMETER_DEF(Converters, MergeNodes);
ALGORITHM_PARAMETER_DEF(Converters, Tolerance);
ALGORITHM_PARAMETER_DEF(Converters, MatchNodeValues);
ALGORITHM_PARAMETER_DEF(Converters, MakeNoData);

ConvertBundleToFieldAlgo::ConvertBundleToFieldAlgo()
{
using namespace Parameters;
//! Merge duplicate nodes?
add_bool("merge_nodes", true);
addParameter(Parameters::MergeNodes, true);

//! Tolerance for merging duplicate nodes?
add_scalar("tolerance", 1e-6);
addParameter(Parameters::Tolerance, 1e-6);

//! Only merge nodes whose value is the same
//! in this module, this option always set false
add_bool("match_node_values", false);
addParameter(Parameters::MatchNodeValues, false);

//! Create a field with no data
add_bool("make_no_data", false);
addParameter(Parameters::MakeNoData, false);
}

ConvertBundleToFieldAlgo::~ConvertBundleToFieldAlgo() {}

bool
ConvertBundleToFieldAlgo::run(BundleHandle& input, FieldHandle& output)
bool ConvertBundleToFieldAlgo::runImpl(const BundleHandle& input, FieldHandle& output) const
{
// Mark that we are starting the algorithm
algo_start("ConvertBundleToField");

std::vector<FieldHandle> inputs;
FieldHandle fhandle;
std::string fieldname;

int numFields = input->numFields();

//! deal with the empty field, if the field is empty, just return and do nothing
//if (numFields==0) return true;

for (int p = 0; p < numFields; p++)
{
fieldname=input->getFieldName(p);
fhandle = input->getField(fieldname);
inputs.push_back(fhandle);
}
ScopedAlgorithmStatusReporter asr(this, "ConvertBundleToField");

const auto inputs = input->getFields();
if (inputs.empty())
{
error("Input bundle is empty");
algo_end();
return false;
}

bool match_node_values = get_bool("match_node_values");
bool make_no_data = get_bool("make_no_data");
bool merge_nodes = get_bool("merge_nodes");
double tol = get_scalar("tolerance");
const bool match_node_values = get(Parameters::MatchNodeValues).toBool();
const bool make_no_data = get(Parameters::MakeNoData).toBool();
const bool merge_nodes = get(Parameters::MergeNodes).toBool();
const double tol = get(Parameters::Tolerance).toDouble();
const double tol2 = tol*tol;

// Check whether mesh types are the same
Expand All @@ -108,14 +97,12 @@ ConvertBundleToFieldAlgo::run(BundleHandle& input, FieldHandle& output)
if (fi.get_mesh_type() != first.get_mesh_type())
{
error("Mesh elements need to be equal in order to join multiple fields together");
algo_end();
return false;
}

if (fi.mesh_basis_order() != first.mesh_basis_order())
{
error("Mesh elements need to be of the same order in for joining multiple fields together");
algo_end();
return false;
}
}
Expand All @@ -132,7 +119,7 @@ ConvertBundleToFieldAlgo::run(BundleHandle& input, FieldHandle& output)
if (fi.field_basis_order() != first.field_basis_order())
{
error("Fields need to have the same basis order");
algo_end();

return false;
}

Expand All @@ -146,7 +133,6 @@ ConvertBundleToFieldAlgo::run(BundleHandle& input, FieldHandle& output)
else
{
error("Fields have different, possibly non-scalar, data types");
algo_end();
return false;
}
}
Expand All @@ -161,7 +147,6 @@ ConvertBundleToFieldAlgo::run(BundleHandle& input, FieldHandle& output)
if (! fi.is_scalar() )
{
error("Node values can only be matched for scalar values");
algo_end();
return false;
}

Expand All @@ -174,7 +159,7 @@ ConvertBundleToFieldAlgo::run(BundleHandle& input, FieldHandle& output)
}

BBox box;
Handle<SearchGridT<index_type> > node_grid;
std::unique_ptr<SearchGridT<index_type>> node_grid;
size_type ni = 0, nj = 0, nk = 0;

size_type tot_num_nodes = 0;
Expand Down Expand Up @@ -208,26 +193,25 @@ ConvertBundleToFieldAlgo::run(BundleHandle& input, FieldHandle& output)
size_type sy = static_cast<size_type>(ceil(diag.y() / trace*s));
size_type sz = static_cast<size_type>(ceil(diag.z() / trace*s));

node_grid = new SearchGridT<index_type>(sx, sy, sz, box.min(), box.max());
node_grid = std::make_unique<SearchGridT<index_type>>(sx, sy, sz, box.get_min(), box.get_max());

ni = node_grid->get_ni() - 1;
nj = node_grid->get_nj() - 1;
nk = node_grid->get_nk() - 1;
}

MeshHandle mesh = CreateMesh(first);
if (mesh.get_rep() == 0)
auto mesh = CreateMesh(first);
if (!mesh)
{
error("Could not create output mesh");
algo_end();

return false;
}

output = CreateField(first,mesh);
if (output.get_rep() == 0)
output = CreateField(first, mesh);
if (!output)
{
error("Could not create output field");
algo_end();
return false;
}

Expand Down Expand Up @@ -429,11 +413,25 @@ ConvertBundleToFieldAlgo::run(BundleHandle& input, FieldHandle& output)
elems_offset += elems_count;
nodes_offset += nodes_count;

update_progress(p+1, inputs.size());
update_progress_max(p+1, inputs.size());
}

algo_end();
return true;
}

} // end namespace SCIRunAlgo
const AlgorithmInputName ConvertBundleToFieldAlgo::InputBundle("InputBundle");

AlgorithmOutput ConvertBundleToFieldAlgo::run(const AlgorithmInput& input) const
{
auto bundle = input.get<Bundle>(InputBundle);

FieldHandle outputField;

if (!runImpl(bundle, outputField))
THROW_ALGORITHM_PROCESSING_ERROR("False thrown on legacy run call");

AlgorithmOutput output;
output[Variables::OutputField] = outputField;

return output;
}
36 changes: 16 additions & 20 deletions src/Core/Algorithms/Legacy/Converter/ConvertBundleToField.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,30 +32,26 @@
#ifndef CORE_ALGORITHMS_CONVERTER_CONVERTBUNDLETOFIELD_H
#define CORE_ALGORITHMS_CONVERTER_CONVERTBUNDLETOFIELD_H 1

//! Datatypes used
#include <Core/Datatypes/Bundle.h>
#include <Core/Datatypes/Field.h>
#include <Core/Datatypes/DatatypeFwd.h>
#include <Core/Algorithms/Base/AlgorithmBase.h>
#include <Core/Algorithms/Legacy/Converter/share.h>

//! Base for algorithm
#include <Core/Algorithms/Util/AlgoBase.h>

//! for Windows support
#include <Core/Algorithms/Converter/share.h>

namespace SCIRunAlgo {
namespace SCIRun::Core::Algorithms::Converters
{
ALGORITHM_PARAMETER_DECL(MergeNodes);
ALGORITHM_PARAMETER_DECL(Tolerance);
ALGORITHM_PARAMETER_DECL(MatchNodeValues);
ALGORITHM_PARAMETER_DECL(MakeNoData);

class SCISHARE ConvertBundleToFieldAlgo : public AlgoBase
class SCISHARE ConvertBundleToFieldAlgo : public AlgorithmBase
{
public:
// Algorithm defaults
ConvertBundleToFieldAlgo();
~ConvertBundleToFieldAlgo();

public:
// Algorithm Functions
bool run(SCIRun::BundleHandle& input, SCIRun::FieldHandle& output);
public:
ConvertBundleToFieldAlgo();
static const AlgorithmInputName InputBundle;
bool runImpl(const SCIRun::Core::Datatypes::BundleHandle& input, SCIRun::FieldHandle& output) const;
AlgorithmOutput run(const AlgorithmInput& input) const override;
};

} // namespace SCIRunAlgo
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ AlgorithmOutput ConvertMatrixToStringAlgo::run(const AlgorithmInput& input) cons
return output;
}

AlgorithmOutputName ConvertMatrixToStringAlgo::ResultString("ResultString");
const AlgorithmOutputName ConvertMatrixToStringAlgo::ResultString("ResultString");
4 changes: 2 additions & 2 deletions src/Core/Algorithms/Legacy/Converter/ConvertMatrixToString.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ namespace SCIRun {
class SCISHARE ConvertMatrixToStringAlgo : public AlgorithmBase
{
public:
static AlgorithmOutputName ResultString;
static const AlgorithmOutputName ResultString;
ConvertMatrixToStringAlgo() {}
bool run(Datatypes::MatrixHandle input, Datatypes::StringHandle& output) const;
AlgorithmOutput run(const AlgorithmInput& input) const override;
AlgorithmOutput run(const AlgorithmInput& input) const override;
};
}}}}

Expand Down
7 changes: 5 additions & 2 deletions src/Core/Algorithms/Legacy/Fields/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ SET(Core_Algorithms_Legacy_Fields_HEADERS
Mapping/ApplyMappingMatrix.h
FieldData/BuildMatrixOfSurfaceNormalsAlgo.h
#Mapping/ApplyMappingMatrix.h
#FieldData/CalculateFieldDataMetric.h
FieldData/CalculateFieldDataMetric.h
FieldData/ConvertIndicesToFieldDataAlgo.h
FieldData/CalculateGradientsAlgo.h
FieldData/CalculateVectorMagnitudesAlgo.h
Expand Down Expand Up @@ -108,6 +108,7 @@ SET(Core_Algorithms_Legacy_Fields_HEADERS
Cleanup/ReorderNormalCoherentlyAlgo.h
MeshDerivatives/CalculateMeshCenterAlgo.h
MeshDerivatives/GetCentroids.h
MeshDerivatives/CalculateBundleDifference.h
)

SET(Core_Algorithms_Legacy_Fields_SRCS
Expand Down Expand Up @@ -142,7 +143,7 @@ SET(Core_Algorithms_Legacy_Fields_SRCS
FieldData/CalculateGradientsAlgo.cc
#FieldData/CalculateLatVolGradientsAtNodes.cc
FieldData/CalculateVectorMagnitudesAlgo.cc
#FieldData/CalculateFieldDataMetric.cc
FieldData/CalculateFieldDataMetric.cc
FieldData/ConvertFieldDataType.cc
FieldData/ConvertFieldBasisType.cc
FieldData/SwapFieldDataWithMatrixEntriesAlgo.cc
Expand Down Expand Up @@ -197,6 +198,7 @@ SET(Core_Algorithms_Legacy_Fields_SRCS
#MeshDerivatives/GetBoundingBox.cc
MeshDerivatives/SplitByConnectedRegion.cc
MeshDerivatives/ExtractSimpleIsosurfaceAlgo.cc
MeshDerivatives/CalculateBundleDifference.cc
RefineMesh/RefineMesh.cc
RefineMesh/RefineMeshCurveAlgoV.cc
RefineMesh/RefineMeshHexVolAlgoV.cc
Expand Down Expand Up @@ -231,6 +233,7 @@ TARGET_LINK_LIBRARIES(Core_Algorithms_Legacy_Fields
Core_Datatypes
Core_Datatypes_Legacy_Field
Core_Datatypes_Legacy_Nrrd
Core_Datatypes_Legacy_Bundle
Algorithms_Base
Core_Exceptions_Legacy
Core_Thread
Expand Down
Loading