Skip to content

Commit aa327ac

Browse files
authored
Merge branch 'master' into ospray-features
2 parents 7f5ade8 + 8bc0be2 commit aa327ac

File tree

83 files changed

+2553
-7435
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+2553
-7435
lines changed

src/Core/Algorithms/Describe/DescribeDatatype.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,15 @@ std::string DescribeDatatype::describe(const DatatypeHandle& data) const
7272
return "[Complex Matrix Data] Info:\n" + ReportComplexMatrixInfoAlgo::summarize(info);
7373
}
7474

75+
auto cmatsp = boost::dynamic_pointer_cast<ComplexSparseRowMatrix>(data);
76+
if (cmatsp)
77+
{
78+
ReportComplexMatrixInfoAlgo algo;
79+
auto info = algo.runImpl(cmatsp);
80+
81+
return "[Complex Matrix Data] Info:\n" + ReportComplexMatrixInfoAlgo::summarize(info);
82+
}
83+
7584
auto field = boost::dynamic_pointer_cast<Field>(data);
7685
if (field)
7786
{

src/Core/Algorithms/Describe/Tests/DescribeDatatypeTests.cc

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <Testing/Utils/MatrixTestUtilities.h>
3333
#include <Testing/Utils/SCIRunUnitTests.h>
3434
#include <Testing/ModuleTestBase/ModuleTestBase.h>
35+
#include <Core/Datatypes/MatrixTypeConversions.h>
3536

3637

3738
using namespace SCIRun;
@@ -70,3 +71,28 @@ TEST(DescribeDatatypeAlgorithmTests, CanDescribeField)
7071

7172
EXPECT_EQ("[Field Data] Info:\nType: GenericField<LatVolMesh<HexTrilinearLgn<Point> > ,HexTrilinearLgn<double> ,FData3d<double,LatVolMesh<HexTrilinearLgn<Point> > > > \nCenter: [0 0 0]\nSize: [2 2 2]\nData min,max: 0 , 0\n# nodes: 60\n# elements: 24\n# data: 60\nData location: Nodes (linear basis)\nDims (x,y,z): [3 4 5]\nGeometric size: 8\n", desc);
7273
}
74+
75+
TEST(DescribeDatatypeAlgorithmTests, CanDescribeComplexDenseMatrix)
76+
{
77+
DescribeDatatype algo;
78+
79+
auto m = boost::make_shared<ComplexDenseMatrix>(2, 2);
80+
*m << complex{ 1, 2 }, complex{ 3, -1 }, complex{ 0, 1 }, complex{ -2, -1 };
81+
82+
auto desc = algo.describe(m);
83+
84+
EXPECT_EQ("[Complex Matrix Data] Info:\nType:\t\tComplexDenseMatrix\n# Rows:\t\t2\n# Columns:\t\t2\n# Elements:\t\t4\nMinimum (by norm):\t(0,1)\nMaximum (by norm):\t(3,-1)\n", desc);
85+
}
86+
87+
TEST(DescribeDatatypeAlgorithmTests, CanDescribeComplexSparseMatrix)
88+
{
89+
DescribeDatatype algo;
90+
91+
ComplexDenseMatrix m(2, 2);
92+
m << complex{ 1, 2 }, complex{ 3, -1 }, complex{ 0, 1 }, complex{ -2, -1 };
93+
auto s = convertMatrix::fromDenseToSparse(m);
94+
95+
auto desc = algo.describe(s);
96+
97+
EXPECT_EQ("[Complex Matrix Data] Info:\nType:\t\tComplexSparseRowMatrix\n# Rows:\t\t2\n# Columns:\t\t2\n# Elements:\t\t4\nMinimum (by norm):\t(0,1)\nMaximum (by norm):\t(3,-1)\n", desc);
98+
}

src/Core/Algorithms/Legacy/Fields/FieldData/BuildMatrixOfSurfaceNormalsAlgo.cc

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,21 @@
2626
DEALINGS IN THE SOFTWARE.
2727
*/
2828

29-
#include <Core/Algorithms/Legacy/Fields/FieldData/BuildMatrixOfSurfaceNormalsAlgo.h>
29+
#include <Core/Algorithms/Legacy/Fields/FieldData/BuildMatrixOfSurfaceNormalsAlgo.h>
3030
#include <Core/Algorithms/Base/AlgorithmPreconditions.h>
3131
#include <Core/Algorithms/Base/AlgorithmVariableNames.h>
32-
//#include <Core/GeometryPrimitives/Vector.h>
3332
#include <Core/Datatypes/Legacy/Field/Field.h>
3433
#include <Core/Datatypes/Legacy/Field/VField.h>
35-
#include <Core/Datatypes/DenseMatrix.h>
34+
#include <Core/Datatypes/DenseMatrix.h>
3635
#include <Core/GeometryPrimitives/Vector.h>
37-
#include <Core/Datatypes/Legacy/Matrix/Matrix.h>
3836
#include <Core/Datatypes/Legacy/Field/FieldInformation.h>
3937

40-
//#include <Core/Datatypes/DenseMatrix.h>
41-
//#include <Core/Datatypes/Legacy/Field/VMesh.h>
42-
43-
//#include <iostream>
44-
4538
using namespace SCIRun::Core::Algorithms;
4639
using namespace SCIRun::Core::Algorithms::Fields;
4740
using namespace SCIRun::Core::Datatypes;
4841
using namespace SCIRun::Core::Geometry;
49-
using namespace SCIRun::Core::Logging;
50-
using namespace SCIRun::Core::Utility;
42+
using namespace SCIRun::Core::Logging;
43+
using namespace SCIRun::Core::Utility;
5144
using namespace SCIRun;
5245

5346
BuildMatrixOfSurfaceNormalsAlgo::BuildMatrixOfSurfaceNormalsAlgo() {}
@@ -61,19 +54,19 @@ bool BuildMatrixOfSurfaceNormalsAlgo::runImpl(FieldHandle input, DenseMatrixHand
6154
error("No input source field");
6255
return (false);
6356
}
64-
65-
FieldInformation fi(input);
57+
58+
FieldInformation fi(input);
6659
if (!(fi.is_surface()))
6760
{
6861
error("This algorithm only works on a surface mesh");
6962
return (false);
7063
}
71-
64+
7265
VMesh* vmesh = input->vmesh();
7366
vmesh->synchronize(Mesh::NORMALS_E);
7467
VMesh::size_type num_nodes = vmesh->num_nodes();
7568

76-
output.reset(new DenseMatrix(num_nodes, 3));
69+
output.reset(new DenseMatrix(num_nodes, 3));
7770

7871
if (!output)
7972
{
@@ -86,10 +79,10 @@ bool BuildMatrixOfSurfaceNormalsAlgo::runImpl(FieldHandle input, DenseMatrixHand
8679
Vector norm;
8780
for (VMesh::Node::index_type i=0; i<num_nodes; ++i)
8881
{
89-
vmesh->get_normal(norm,i);
82+
vmesh->get_normal(norm,i);
9083
(*output)(k) = norm.x();
9184
(*output)(k+1) = norm.y();
92-
(*output)(k+2) = norm.z();
85+
(*output)(k+2) = norm.z();
9386
k += 3;
9487
cnt++; if (cnt == 400) {cnt=0; update_progress_max(i,num_nodes); }
9588
}
@@ -99,12 +92,12 @@ bool BuildMatrixOfSurfaceNormalsAlgo::runImpl(FieldHandle input, DenseMatrixHand
9992
AlgorithmOutput BuildMatrixOfSurfaceNormalsAlgo::run(const AlgorithmInput& input) const
10093
{
10194
auto field = input.get<Field>(Variables::InputField);
102-
DenseMatrixHandle outputMatrix;
95+
DenseMatrixHandle outputMatrix;
10396

10497
if(!runImpl(field, outputMatrix))
105-
THROW_ALGORITHM_PROCESSING_ERROR("False returned on legacy call.");
98+
THROW_ALGORITHM_PROCESSING_ERROR("False returned on legacy call.");
10699

107100
AlgorithmOutput output;
108101
output[Variables::OutputMatrix] = outputMatrix;
109102
return output;
110-
}
103+
}

src/Core/Algorithms/Legacy/Fields/FieldData/SetFieldData.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ FieldHandle SetFieldDataAlgo::runImplRealComplex(FieldHandle input_field, DenseM
399399
found = verify_input_data(input_field, realData->nrows(), realData->ncols(), numvals, fi);
400400
else if (complexData)
401401
{
402-
found = verify_input_data(input_field, complexData->nrows(), complexData->ncols(), numvals, fi, "std::complex<double>");
402+
found = verify_input_data(input_field, complexData->nrows(), complexData->ncols(), numvals, fi, "complex");
403403
}
404404

405405
if (!found)

0 commit comments

Comments
 (0)