Skip to content

Commit f6f51cd

Browse files
merge with master - new nrrd support
2 parents b495dc7 + e621deb commit f6f51cd

Some content is hidden

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

48 files changed

+7243
-424
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
![alt text](http://www.sci.utah.edu/images/banners/splash-scirun.png "")
1+
![SCIRun Banner](http://www.sci.utah.edu/images/software/SCIRun/scirun.png "")
22

33
## SCIRun 5
44
https://github.com/SCIInstitute/SCIRun

src/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,12 +563,14 @@ SET_PROPERTY(TARGET Algorithms_Factory PROPERTY FOLDER "Core/Algorithms")
563563
SET_PROPERTY(TARGET Core_Algorithms_Legacy_Fields PROPERTY FOLDER "Core/Algorithms")
564564
SET_PROPERTY(TARGET Core_Algorithms_Legacy_FiniteElements PROPERTY FOLDER "Core/Algorithms")
565565
SET_PROPERTY(TARGET Core_Algorithms_Legacy_DataIO PROPERTY FOLDER "Core/Algorithms")
566+
SET_PROPERTY(TARGET Core_Algorithms_Legacy_Converter PROPERTY FOLDER "Core/Algorithms")
566567

567568
SET_PROPERTY(TARGET Dataflow_Network PROPERTY FOLDER "Dataflow")
568569
SET_PROPERTY(TARGET Core_Datatypes PROPERTY FOLDER "Core")
569570
SET_PROPERTY(TARGET Core_Datatypes_Mesh PROPERTY FOLDER "Core")
570571
SET_PROPERTY(TARGET Core_Datatypes_Legacy_Base PROPERTY FOLDER "Core")
571572
SET_PROPERTY(TARGET Core_Datatypes_Legacy_Field PROPERTY FOLDER "Core")
573+
SET_PROPERTY(TARGET Core_Datatypes_Legacy_Nrrd PROPERTY FOLDER "Core")
572574
SET_PROPERTY(TARGET Core_Datatypes_Legacy_Bundle PROPERTY FOLDER "Core")
573575
SET_PROPERTY(TARGET Core_Basis PROPERTY FOLDER "Core")
574576
SET_PROPERTY(TARGET Core_Persistent PROPERTY FOLDER "Core")

src/Core/Algorithms/Base/AlgorithmData.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
#include <map>
3333
#include <boost/filesystem/path.hpp>
34+
#include <boost/any.hpp>
3435
#include <Core/Datatypes/DatatypeFwd.h>
3536
#include <Core/Algorithms/Base/Name.h>
3637
#include <Core/Algorithms/Base/Variable.h>

src/Core/Algorithms/DataIO/Tests/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ SET(Algorithms_DataIO_Tests_SRCS
3030
ReadMatrixTests.cc
3131
WriteMatrixTests.cc
3232
ReadTriSurfTests.cc
33+
ReadWriteNrrdTests.cc
3334
)
3435

3536
SCIRUN_ADD_UNIT_TEST(Algorithms_DataIO_Tests
@@ -40,6 +41,7 @@ TARGET_LINK_LIBRARIES(Algorithms_DataIO_Tests
4041
Algorithms_DataIO
4142
Core_Datatypes
4243
Testing_Utils
44+
Core_IEPlugin
4345
gtest_main
4446
gtest
4547
gmock
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
/*
2+
For more information, please see: http://software.sci.utah.edu
3+
4+
The MIT License
5+
6+
Copyright (c) 2012 Scientific Computing and Imaging Institute,
7+
University of Utah.
8+
9+
License for the specific language governing rights and limitations under
10+
Permission is hereby granted, free of charge, to any person obtaining a
11+
copy of this software and associated documentation files (the "Software"),
12+
to deal in the Software without restriction, including without limitation
13+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
14+
and/or sell copies of the Software, and to permit persons to whom the
15+
Software is furnished to do so, subject to the following conditions:
16+
17+
The above copyright notice and this permission notice shall be included
18+
in all copies or substantial portions of the Software.
19+
20+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23+
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26+
DEALINGS IN THE SOFTWARE.
27+
*/
28+
29+
#include <Testing/Utils/SCIRunUnitTests.h>
30+
#include <Core/IEPlugin/NrrdField_Plugin.h>
31+
#include <Core/Datatypes/Legacy/Field/Field.h>
32+
#include <Core/Datatypes/Legacy/Field/VMesh.h>
33+
34+
using namespace SCIRun;
35+
using namespace SCIRun::Core;
36+
using namespace SCIRun::Core::Datatypes;
37+
using namespace SCIRun::TestUtils;
38+
39+
namespace
40+
{
41+
boost::filesystem::path testNrrd = TestResources::rootDir() / "ToolKits" / "FwdInvToolbox" / "pot_based_FEM_forward" / "Segmentation.nrrd";
42+
boost::filesystem::path testNrrdHeader = TestResources::rootDir() / "Fields" / "nrrd" / "fieldOut.nhdr";
43+
}
44+
45+
TEST(ReadNrrdTests, CanReadFullNrrdFile)
46+
{
47+
auto field = NrrdToField_reader(nullptr, testNrrd.string().c_str());
48+
49+
ASSERT_TRUE(field != nullptr);
50+
EXPECT_EQ(18869130, field->vmesh()->num_nodes());
51+
EXPECT_EQ(18620000, field->vmesh()->num_elems());
52+
EXPECT_EQ(1, field->vmesh()->basis_order());
53+
}
54+
55+
TEST(ReadNrrdTests, CanReadNrrdHeaderFile)
56+
{
57+
auto field = NrrdToField_reader(nullptr, testNrrdHeader.string().c_str());
58+
59+
ASSERT_TRUE(field != nullptr);
60+
EXPECT_EQ(19120104, field->vmesh()->num_nodes());
61+
EXPECT_EQ(18869130, field->vmesh()->num_elems());
62+
EXPECT_EQ(1, field->vmesh()->basis_order());
63+
}
64+
65+
TEST(ReadNrrdTests, CanReadNrrdFile_Nodal)
66+
{
67+
auto field = Nodal_NrrdToField_reader(nullptr, testNrrd.string().c_str());
68+
69+
ASSERT_TRUE(field != nullptr);
70+
EXPECT_EQ(18869130, field->vmesh()->num_nodes());
71+
EXPECT_EQ(18620000, field->vmesh()->num_elems());
72+
EXPECT_EQ(1, field->vmesh()->basis_order());
73+
}
74+
75+
TEST(ReadNrrdTests, CanReadNrrdFile_Modal)
76+
{
77+
auto field = Modal_NrrdToField_reader(nullptr, testNrrd.string().c_str());
78+
79+
ASSERT_TRUE(field != nullptr);
80+
EXPECT_EQ(19120104, field->vmesh()->num_nodes());
81+
EXPECT_EQ(18869130, field->vmesh()->num_elems());
82+
EXPECT_EQ(1, field->vmesh()->basis_order());
83+
}
84+
85+
TEST(ReadNrrdTests, CanReadNrrdFile_IPNodal)
86+
{
87+
auto field = IPNodal_NrrdToField_reader(nullptr, testNrrd.string().c_str());
88+
89+
ASSERT_TRUE(field != nullptr);
90+
EXPECT_EQ(18869130, field->vmesh()->num_nodes());
91+
EXPECT_EQ(18620000, field->vmesh()->num_elems());
92+
EXPECT_EQ(1, field->vmesh()->basis_order());
93+
}
94+
95+
TEST(ReadNrrdTests, CanReadNrrdFile_IPModal)
96+
{
97+
auto field = IPModal_NrrdToField_reader(nullptr, testNrrd.string().c_str());
98+
99+
ASSERT_TRUE(field != nullptr);
100+
EXPECT_EQ(19120104, field->vmesh()->num_nodes());
101+
EXPECT_EQ(18869130, field->vmesh()->num_elems());
102+
EXPECT_EQ(1, field->vmesh()->basis_order());
103+
}
104+
105+
TEST(WriteNrrdTests, CanWriteNrrdFile)
106+
{
107+
auto field = NrrdToField_reader(nullptr, testNrrd.string().c_str());
108+
109+
ASSERT_TRUE(field != nullptr);
110+
EXPECT_EQ(18869130, field->vmesh()->num_nodes());
111+
EXPECT_EQ(18620000, field->vmesh()->num_elems());
112+
EXPECT_EQ(1, field->vmesh()->basis_order());
113+
114+
boost::filesystem::path out(TestResources::rootDir() / "TransientOutput" / "fieldOutUnit.nrrd");
115+
ASSERT_TRUE(FieldToNrrd_writer(nullptr, field, out.string().c_str()));
116+
}
117+
118+
TEST(WriteNrrdTests, CanWriteNrrdFileHeader)
119+
{
120+
auto field = NrrdToField_reader(nullptr, testNrrd.string().c_str());
121+
122+
ASSERT_TRUE(field != nullptr);
123+
EXPECT_EQ(18869130, field->vmesh()->num_nodes());
124+
EXPECT_EQ(18620000, field->vmesh()->num_elems());
125+
EXPECT_EQ(1, field->vmesh()->basis_order());
126+
127+
boost::filesystem::path out(TestResources::rootDir() / "TransientOutput" / "fieldOutUnitHeader.nhdr");
128+
ASSERT_TRUE(FieldToNrrd_writer(nullptr, field, out.string().c_str()));
129+
}
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
#
22
# For more information, please see: http://software.sci.utah.edu
3-
#
3+
#
44
# The MIT License
5-
#
5+
#
66
# Copyright (c) 2012 Scientific Computing and Imaging Institute,
77
# University of Utah.
8-
#
9-
#
8+
#
9+
#
1010
# Permission is hereby granted, free of charge, to any person obtaining a
1111
# copy of this software and associated documentation files (the "Software"),
1212
# to deal in the Software without restriction, including without limitation
1313
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
1414
# and/or sell copies of the Software, and to permit persons to whom the
1515
# Software is furnished to do so, subject to the following conditions:
16-
#
16+
#
1717
# The above copyright notice and this permission notice shall be included
18-
# in all copies or substantial portions of the Software.
19-
#
18+
# in all copies or substantial portions of the Software.
19+
#
2020
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
2121
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2222
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
@@ -28,5 +28,6 @@
2828

2929
ADD_SUBDIRECTORY(Fields)
3030
ADD_SUBDIRECTORY(DataIO)
31+
ADD_SUBDIRECTORY(Converter)
3132
#ADD_SUBDIRECTORY(Math)
3233
ADD_SUBDIRECTORY(FiniteElements)
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#
2+
# For more information, please see: http://software.sci.utah.edu
3+
#
4+
# The MIT License
5+
#
6+
# Copyright (c) 2009 Scientific Computing and Imaging Institute,
7+
# University of Utah.
8+
#
9+
#
10+
# Permission is hereby granted, free of charge, to any person obtaining a
11+
# copy of this software and associated documentation files (the "Software"),
12+
# to deal in the Software without restriction, including without limitation
13+
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
14+
# and/or sell copies of the Software, and to permit persons to whom the
15+
# Software is furnished to do so, subject to the following conditions:
16+
#
17+
# The above copyright notice and this permission notice shall be included
18+
# in all copies or substantial portions of the Software.
19+
#
20+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21+
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23+
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26+
# DEALINGS IN THE SOFTWARE.
27+
#
28+
29+
# Sources of Core/Algorithms/Converter classes
30+
31+
SET(Core_Algorithms_Legacy_Converter_SRCS
32+
ConverterAlgo.cc
33+
#MatrixToField.cc
34+
NrrdToField.cc
35+
FieldToNrrd.cc
36+
#ConvertToNrrd.cc
37+
#MatricesToDipoleField.cc
38+
#ConvertBundleToField.cc
39+
)
40+
41+
SET(Core_Algorithms_Legacy_Converter_HEADERS
42+
ConverterAlgo.h
43+
NrrdToField.h
44+
FieldToNrrd.h
45+
)
46+
47+
ADD_LIBRARY(Core_Algorithms_Legacy_Converter
48+
${Core_Algorithms_Legacy_Converter_SRCS}
49+
${Core_Algorithms_Legacy_Converter_HEADERS})
50+
51+
TARGET_LINK_LIBRARIES(Core_Algorithms_Legacy_Converter
52+
Algorithms_Base
53+
Core_Datatypes
54+
Core_Datatypes_Legacy_Field
55+
Core_Datatypes_Legacy_Nrrd
56+
#Core_Util
57+
#Core_Exceptions
58+
#Core_Thread
59+
#Core_Geom
60+
#Core_Geometry
61+
#Core_Persistent
62+
#Core_Basis
63+
#${M_LIBRARY}
64+
#${SCI_TEEM_LIBRARY}
65+
)
66+
67+
IF(BUILD_SHARED_LIBS)
68+
ADD_DEFINITIONS(-DBUILD_Core_Algorithms_Legacy_Converter)
69+
ENDIF(BUILD_SHARED_LIBS)

0 commit comments

Comments
 (0)