Skip to content

Commit d05e07b

Browse files
committed
Merge branch 'master' into vtkReader
2 parents e0efd27 + 560b15b commit d05e07b

Some content is hidden

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

49 files changed

+4330
-142
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
*.swp
77
*.vcxproj*
88
*DS_Store
9+
src/Documentation/*/*/*.aux
10+
src/Documentation/*/*/*.blg
11+
src/Documentation/*/*/*.bbl
12+
src/Documentation/*/*/*.log
13+
src/Documentation/*/*/*.out
14+
src/Documentation/*/*/*.toc
915
bin*/*/*
1016
bin64/*
1117
doc/*

Superbuild/Superbuild.cmake

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,6 @@ SET(SCIRUN_CACHE_ARGS
165165
"-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}"
166166
"-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}"
167167
"-DSCIRUN_BINARY_DIR:PATH=${SCIRUN_BINARY_DIR}"
168-
"-DBUILD_LARGE_VOLUME_TOOLS:BOOL=${BUILD_LARGE_VOLUME_TOOLS}"
169-
"-DBUILD_MOSAIC_TOOLS:BOOL=${BUILD_MOSAIC_TOOLS}"
170168
"-DSCIRUN_BITS:STRING=${SCIRUN_BITS}"
171169
"-DBUILD_TESTING:BOOL=${BUILD_TESTING}"
172170
"-DBUILD_DOCUMENTATION:BOOL=${BUILD_DOCUMENTATION}"

src/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,8 @@ MESSAGE(STATUS "Configuring CPMs")
405405
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
406406

407407
# CPM Setup.
408-
set(CPM_DIR "${CMAKE_CURRENT_BINARY_DIR}/Externals/cpm-packages" CACHE TYPE STRING)
408+
#set(CPM_DIR "${CMAKE_CURRENT_BINARY_DIR}/Externals/cpm-packages" CACHE TYPE STRING)
409+
set(CPM_DIR "${CMAKE_CURRENT_BINARY_DIR}/cpm-packages" CACHE TYPE STRING)
409410
find_package(Git)
410411
if(NOT GIT_FOUND)
411412
message(FATAL_ERROR "CPM requires Git.")
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
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+
#include <Core/Algorithms/Math/SortMatrixAlgo.h>
30+
#include <Core/Datatypes/MatrixTypeConversions.h>
31+
#include <Core/Math/MiscMath.h>
32+
33+
using namespace SCIRun;
34+
using namespace SCIRun::Core::Datatypes;
35+
using namespace SCIRun::Core::Algorithms;
36+
using namespace SCIRun::Core::Algorithms::Math;
37+
38+
SortMatrixAlgo::SortMatrixAlgo()
39+
{
40+
//set parameter defaults for UI
41+
addParameter(Variables::Method, 0);
42+
}
43+
44+
45+
AlgorithmOutput SortMatrixAlgo::run_generic(const AlgorithmInput& input) const
46+
{
47+
auto input_matrix = input.get<Matrix>(Variables::InputMatrix);
48+
AlgorithmOutput output;
49+
50+
//sparse support not fully implemented yet.
51+
if (!matrix_is::dense(input_matrix))
52+
{
53+
//TODO implement something with sparse
54+
error("SortMatrix: Currently only works with dense matrices");
55+
output[Variables::OutputMatrix] = 0;
56+
return output;
57+
}
58+
auto mat = matrix_cast::as_dense (input_matrix);
59+
DenseMatrixHandle return_matrix;
60+
61+
//pull parameter from UI
62+
auto method = get(Variables::Method).toInt();
63+
64+
Sort(mat,return_matrix,method);
65+
output[Variables::OutputMatrix] = return_matrix;
66+
return output;
67+
}
68+
69+
70+
bool
71+
SortMatrixAlgo::Sort(DenseMatrixHandle input, DenseMatrixHandle& output,int method) const
72+
{
73+
if (!input)
74+
{
75+
error("SortAscending: no input matrix found");
76+
return false;
77+
}
78+
//get size of original matrix
79+
size_type nrows = input->nrows();
80+
size_type ncols = input->ncols();
81+
//copy original matrix for processing
82+
output.reset(new DenseMatrix(*input));
83+
//pointer to matrix data
84+
double *data = output->data();
85+
86+
if (!output)
87+
{
88+
error("ApplyRowOperation: could not create output matrix");
89+
return false;
90+
}
91+
92+
size_type n = nrows*ncols;
93+
//call the sorting functions
94+
Quicksort(data,0,n-1);
95+
96+
if (method==1)
97+
{
98+
//if set to descending, reverse the order.
99+
output.reset(new DenseMatrix(output -> reverse()));
100+
}
101+
return true;
102+
}
103+
104+
bool
105+
SortMatrixAlgo::Quicksort(double* input, index_type lo, index_type hi) const
106+
{
107+
//splits matrix based on Partition function
108+
index_type ind;
109+
if (lo<hi)
110+
{
111+
ind=Partition(input,lo,hi);
112+
Quicksort(input,lo,ind-1);
113+
Quicksort(input,ind+1,hi);
114+
}
115+
return true;
116+
}
117+
118+
index_type
119+
SortMatrixAlgo::Partition(double* input, index_type lo, index_type hi) const
120+
{
121+
// places the last entry in its proper place in relation to the other
122+
// entries, ie, smaller values before and larger values after.
123+
index_type ind=lo;
124+
125+
double pivot = input[hi];
126+
double tmp;
127+
for (index_type k=lo;k<hi;k++)
128+
{
129+
if (input[k]<=pivot)
130+
{
131+
tmp=input[ind];
132+
input[ind]=input[k];
133+
input[k]=tmp;
134+
ind+=1;
135+
}
136+
}
137+
tmp=input[ind];
138+
input[ind]=input[hi];
139+
input[hi]=tmp;
140+
return ind;
141+
}
142+
143+
144+
145+
146+
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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+
#ifndef CORE_ALGORITHMS_MATH_SortMatrixALGO_H
30+
#define CORE_ALGORITHMS_MATH_SortMatrixALGO_H
31+
32+
#include <Core/Datatypes/Matrix.h>
33+
#include <Core/Datatypes/DenseMatrix.h>
34+
#include <Core/Datatypes/DenseColumnMatrix.h>
35+
36+
37+
#include <string>
38+
#include <sstream>
39+
#include <vector>
40+
#include <algorithm>
41+
42+
#include <Core/Algorithms/Base/AlgorithmVariableNames.h>
43+
#include <Core/Algorithms/Base/AlgorithmBase.h>
44+
#include <Core/Algorithms/Math/share.h>
45+
46+
namespace SCIRun {
47+
namespace Core {
48+
namespace Algorithms {
49+
namespace Math {
50+
51+
class SCISHARE SortMatrixAlgo : public AlgorithmBase
52+
{
53+
54+
public:
55+
SortMatrixAlgo();
56+
AlgorithmOutput run_generic(const AlgorithmInput& input) const;
57+
58+
bool Sort(Datatypes::DenseMatrixHandle input, Datatypes::DenseMatrixHandle& output, int method) const;
59+
60+
bool Quicksort(double* input, index_type lo, index_type hi) const;
61+
index_type Partition(double* input, index_type lo, index_type hi) const;
62+
};
63+
64+
}}}}// end SCIRun namespace
65+
#endif

src/Core/IEPlugin/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ SET(Core_IEPlugin_SRCS
3131
#CVRTIFileToMatrix_Plugin.cc
3232
CurveField_Plugin.cc
3333
#DIF_Plugin.cc
34-
#EcgsimFileToMatrix_Plugin.cc
34+
EcgsimFileToMatrix_Plugin.cc
3535
#EcgsimFileToTriSurf_Plugin.cc
3636
#HexVolField_Plugin.cc
3737
IEPluginInit.cc
@@ -59,7 +59,7 @@ SET(Core_IEPlugin_HEADERS
5959
#CVRTIFileToMatrix_Plugin.h
6060
CurveField_Plugin.h
6161
#DIF_Plugin.h
62-
#EcgsimFileToMatrix_Plugin.h
62+
EcgsimFileToMatrix_Plugin.h
6363
#EcgsimFileToTriSurf_Plugin.h
6464
#HexVolField_Plugin.h
6565
#MRC_Plugin.h

src/Core/IEPlugin/EcgsimFileToMatrix_Plugin.cc

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -37,24 +37,27 @@
3737
*/
3838

3939

40-
// This is a plugin is meant to read simple text files with pure data
41-
// in ascii format into a SCIRun matrix.
42-
40+
#include <Core/ImportExport/Matrix/MatrixIEPlugin.h>
41+
#include <Core/IEPlugin/EcgsimFileToMatrix_Plugin.h>
42+
#include <Core/Datatypes/DenseMatrix.h>
43+
#include <Core/Datatypes/MatrixTypeConversions.h>
44+
#include <Core/Utils/Legacy/StringUtil.h>
45+
#include <Core/Logging/LoggerInterface.h>
4346
#include <Core/ImportExport/Matrix/MatrixIEPlugin.h>
4447
#include <Core/Datatypes/DenseMatrix.h>
4548

4649
#include <iostream>
4750
#include <fstream>
4851
#include <sstream>
4952

50-
namespace SCIRun {
51-
52-
MatrixHandle EcgsimFileMatrix_reader(ProgressReporter *pr, const char *filename);
53-
bool EcgsimFileMatrix_writer(ProgressReporter *pr, MatrixHandle matrix, const char *filename);
53+
using namespace SCIRun;
54+
using namespace SCIRun::Core;
55+
using namespace SCIRun::Core::Logging;
56+
using namespace SCIRun::Core::Datatypes;
5457

55-
MatrixHandle EcgsimFileMatrix_reader(ProgressReporter *pr, const char *filename)
58+
MatrixHandle SCIRun::EcgsimFileMatrix_reader(LoggerHandle pr, const char *filename)
5659
{
57-
MatrixHandle result;
60+
DenseMatrixHandle result;
5861

5962
int ncols = 0;
6063
int nrows = 0;
@@ -154,14 +157,14 @@ MatrixHandle EcgsimFileMatrix_reader(ProgressReporter *pr, const char *filename)
154157
std::ifstream inputfile;
155158
inputfile.exceptions( std::ifstream::badbit );
156159

157-
result = new DenseMatrix(header_rows,header_cols);
158-
if (result.get_rep() == 0)
160+
result.reset(new DenseMatrix(header_rows,header_cols));
161+
if (!result)
159162
{
160163
if (pr) pr->error("Could not allocate matrix");
161164
return(result);
162165
}
163166

164-
double* dataptr = result->get_data_pointer();
167+
double* dataptr = result->data();
165168
int k = 0;
166169

167170
try
@@ -211,23 +214,22 @@ MatrixHandle EcgsimFileMatrix_reader(ProgressReporter *pr, const char *filename)
211214
}
212215

213216

214-
bool EcgsimFileMatrix_writer(ProgressReporter *pr, MatrixHandle matrix, const char *filename)
217+
bool SCIRun::EcgsimFileMatrix_writer(LoggerHandle pr, MatrixHandle matrixInput, const char *filename)
215218
{
216219

217220
std::ofstream outputfile;
218221
outputfile.exceptions( std::ofstream::failbit | std::ofstream::badbit );
219222

220-
MatrixHandle temp = matrix->dense();
221-
matrix = temp;
223+
DenseMatrixHandle matrix = matrix_cast::as_dense(matrixInput);
222224

223-
if (matrix.get_rep() == 0)
225+
if (!matrix)
224226
{
225227
if (pr) pr->error("Empty matrix detected");
226228
return(false);
227229
}
228230

229-
double* dataptr = matrix->get_data_pointer();
230-
if (dataptr == 0)
231+
double* dataptr = matrix->data();
232+
if (!dataptr)
231233
{
232234
if (pr) pr->error("Empty matrix detected");
233235
return(false);
@@ -261,7 +263,5 @@ bool EcgsimFileMatrix_writer(ProgressReporter *pr, MatrixHandle matrix, const ch
261263
return (true);
262264
}
263265

264-
static MatrixIEPlugin EcgsimFileMatrix_plugin("ECGSimFile","", "",EcgsimFileMatrix_reader,EcgsimFileMatrix_writer);
265266

266-
} // end namespace
267267

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
For more information, please see: http://software.sci.utah.edu
3+
4+
The MIT License
5+
6+
Copyright (c) 2015 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+
#ifndef CORE_IEPLUGIN_ECGSIMFILETOMATRIX_PLUGIN_H__
30+
#define CORE_IEPLUGIN_ECGSIMFILETOMATRIX_PLUGIN_H__
31+
32+
#include <Core/Logging/LoggerFwd.h>
33+
#include <Core/Datatypes/DatatypeFwd.h>
34+
#include <Core/IEPlugin/share.h>
35+
36+
namespace SCIRun
37+
{
38+
SCISHARE Core::Datatypes::MatrixHandle EcgsimFileMatrix_reader(Core::Logging::LoggerHandle pr, const char *filename);
39+
40+
SCISHARE bool EcgsimFileMatrix_writer(Core::Logging::LoggerHandle pr, Core::Datatypes::MatrixHandle fh, const char* filename);
41+
}
42+
43+
#endif

0 commit comments

Comments
 (0)