Skip to content

Commit 07b4b7b

Browse files
committed
Merge branch 'master' into embbWidget
2 parents e5ad4d6 + 8101d34 commit 07b4b7b

File tree

6 files changed

+116
-204
lines changed

6 files changed

+116
-204
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ https://github.com/SCIInstitute/SCIRun
1919

2020
### Summary
2121

22-
| Warning! | SCIRun 5 is alpha software, you may use for real science but beware of instability. |
22+
| Warning! | SCIRun 5 is beta software, you may use for real science but beware of instability. |
2323
|:--------:|:-------------------------------------------------------------------------------------:|
2424

2525
### Goals

src/Core/IEPlugin/IEPluginInit.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ void IEPluginManager::Initialize()
6666
static FieldIEPluginLegacyAdapter CurveField_plugin("CurveField", "*.pts *.pos *.edge", "", TextToCurveField_reader, CurveFieldToTextBaseIndexZero_writer);
6767

6868
static MatrixIEPluginLegacyAdapter EcgsimFileMatrix_plugin("ECGSimFile", "", "", EcgsimFileMatrix_reader, EcgsimFileMatrix_writer);
69-
static MatrixIEPluginLegacyAdapter IgbFileMatrix_plugin("IGBFile", "*.igb", "*.igb", IgbFileMatrix_reader, IgbFileMatrix_writer);
69+
static MatrixIEPluginLegacyAdapter IgbFileMatrix_plugin("IGBFile", "*.igb", "*.igb", IgbFileMatrix_reader, nullptr);
7070

7171
static FieldIEPluginLegacyAdapter TriSurfField_plugin("TriSurfField", "*.fac *.tri *.pts *.pos", "", TextToTriSurfField_reader, TriSurfFieldToTextBaseIndexZero_writer);
7272
static FieldIEPluginLegacyAdapter TriSurfFieldBaseIndexOne_plugin("TriSurfField[BaseIndex 1]", "*.fac *.pts", "", nullptr, TriSurfFieldToTextBaseIndexOne_writer);

src/Core/IEPlugin/IgbFileToMatrix_Plugin.cc

Lines changed: 108 additions & 196 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@
2727
*/
2828

2929
/*
30-
* EcgsimFileToMatrix_Plugin.cc
30+
* IgbFiletoMatrix_Plugin.cc
3131
*
3232
* Written by:
33-
* Jeroen Stinstra
34-
* Department of Computer Science
33+
* Karli Gillette
34+
* Department of Bioengineering
3535
* University of Utah
3636
*
3737
*/
@@ -46,222 +46,134 @@
4646
#include <Core/ImportExport/Matrix/MatrixIEPlugin.h>
4747
#include <Core/Datatypes/DenseMatrix.h>
4848

49+
#include <string.h>
50+
#include <stdlib.h>
51+
#include <string>
52+
#include <stdio.h>
53+
#include <vector>
54+
#include <boost/tokenizer.hpp>
55+
#include <boost/foreach.hpp>
56+
#include <boost/algorithm/string.hpp>
57+
#include <boost/algorithm/string/iter_find.hpp>
58+
#include <cmath>
59+
4960
#include <iostream>
5061
#include <fstream>
5162
#include <sstream>
5263

64+
using namespace std;
5365
using namespace SCIRun;
5466
using namespace SCIRun::Core;
5567
using namespace SCIRun::Core::Logging;
5668
using namespace SCIRun::Core::Datatypes;
5769

5870
MatrixHandle SCIRun::IgbFileMatrix_reader(LoggerHandle pr, const char *filename)
5971
{
60-
DenseMatrixHandle result;
61-
62-
int ncols = 0;
63-
int nrows = 0;
64-
int line_ncols = 0;
65-
int header_rows = 0;
66-
int header_cols = 0;
67-
68-
std::string line;
69-
double data;
70-
71-
// STAGE 1 - SCAN THE FILE TO DETERMINE THE DIMENSIONS OF THE MATRIX
72-
// AND CHECK THE FILE'S INTEGRITY.
73-
74-
{
75-
std::ifstream inputfile;
76-
inputfile.exceptions( std::ifstream::badbit );
77-
78-
try
72+
73+
string line;
74+
vector<string> strs;
75+
int x_size=0;
76+
int t_size=0;
77+
int count=0;
78+
79+
80+
ifstream myfile (filename);
81+
if (myfile.is_open())
7982
{
80-
inputfile.open(filename);
81-
82-
// get header information
83-
getline(inputfile,line,'\n');
84-
for (size_t p = 0;p<line.size();p++)
85-
{
86-
if ((line[p] == '\t')||(line[p] == ',')||(line[p]=='"')) line[p] = ' ';
87-
}
88-
std::istringstream iss(line);
89-
iss >> header_rows;
90-
iss >> header_cols;
91-
92-
while( getline(inputfile,line,'\n'))
93-
{
94-
if (line.size() > 0)
95-
{
96-
// block out comments
97-
if ((line[0] == '#')||(line[0] == '%')) continue;
98-
}
99-
100-
// replace comma's and tabs with white spaces
101-
for (size_t p = 0;p<line.size();p++)
102-
{
103-
if ((line[p] == '\t')||(line[p] == ',')||(line[p]=='"')) line[p] = ' ';
104-
}
105-
std::istringstream iss(line);
106-
iss.exceptions( std::ifstream::failbit | std::ifstream::badbit);
107-
108-
try
109-
{
110-
line_ncols = 0;
111-
while(1)
112-
{
113-
iss >> data;
114-
line_ncols++;
115-
}
116-
}
117-
catch(...)
118-
{
119-
}
120-
121-
if (line_ncols > 0)
83+
//while ( myfile.good() )
84+
for(int i=0; i<5; i++)
12285
{
123-
nrows++;
124-
if (ncols > 0)
125-
{
126-
if (ncols != line_ncols)
86+
getline (myfile,line);
87+
88+
boost::split(strs,line,boost::is_any_of(":, "));
89+
size_t sz;
90+
sz=line.size();
91+
92+
93+
for(int p=0;p<sz;p++)
12794
{
128-
if (pr) pr->error("Improper format of text file, not every line contains the same amount of numbers");
129-
return (result);
95+
96+
std::cout << p << std::endl;
97+
98+
if (boost::iequals(strs[p], "x"))
99+
{
100+
x_size=atoi(strs[p+1].c_str());
101+
count += 1;
102+
103+
}
104+
if (boost::iequals(strs[p], "t"))
105+
{
106+
t_size=atoi(strs[p+1].c_str());
107+
count +=1;
108+
109+
}
110+
111+
if (count ==2 ) break;
112+
113+
130114
}
131-
}
132-
else
133-
{
134-
ncols = line_ncols;
135-
}
136-
}
137-
}
138-
139-
if(ncols*nrows != header_cols*header_rows)
140-
{
141-
if (pr) pr->error("Data does not match header information.");
142-
return(result);
143-
}
115+
116+
117+
}
118+
myfile.close();
144119
}
145-
catch (...)
146-
{
147-
if (pr) pr->error("Could not open file: "+std::string(filename));
148-
return (result);
149-
}
150-
151-
inputfile.close();
152-
}
153-
154-
// STAGE 2 - NOW ACTUALLY READ AND STORE THE MATRIX
155120

156-
{
157-
std::ifstream inputfile;
158-
inputfile.exceptions( std::ifstream::badbit );
159-
160-
result.reset(new DenseMatrix(header_rows,header_cols));
161-
if (!result)
162-
{
163-
if (pr) pr->error("Could not allocate matrix");
164-
return(result);
165-
}
166-
167-
double* dataptr = result->data();
168-
int k = 0;
121+
122+
streamoff length=0;
123+
streamsize numbyts=0;
124+
//char * buffer;
125+
126+
127+
128+
129+
ifstream is;
130+
is.open (filename, ios::in | ios::binary );
131+
if (is.is_open())
132+
{
133+
// get length of file:
134+
is.seekg (0, ios::end);
135+
length = is.tellg();
136+
is.seekg (1024, ios::beg);
137+
t_size=t_size;
138+
length=length-1024;
139+
140+
vector<float> vec;
141+
vec.resize(length);
142+
is.read ((char*)&vec[0],length);
143+
144+
if (!is)
145+
{
146+
numbyts=is.gcount();
147+
cout << "Error reading binary data. Number of bytes read: " << numbyts << endl;
169148

170-
try
171-
{
172-
inputfile.open(filename);
149+
}
150+
is.close();
151+
152+
153+
auto result(boost::make_shared<DenseMatrix>(x_size,t_size));
154+
155+
156+
157+
for(size_t p=0;p<t_size;p++ )
158+
{
159+
160+
for(size_t pp=0;pp<x_size;pp++ )
161+
{
162+
163+
164+
(*result)(pp, p) = vec[(p*x_size)+pp];
165+
166+
}
167+
}
168+
173169

174-
// get header information
175-
getline(inputfile,line,'\n');
176-
177-
while( getline(inputfile,line,'\n'))
178-
{
179-
if (line.size() > 0)
180-
{
181-
// block out comments
182-
if ((line[0] == '#')||(line[0] == '%')) continue;
183-
}
184-
185-
// replace comma's and tabs with white spaces
186-
for (size_t p = 0;p<line.size();p++)
187-
{
188-
if ((line[p] == '\t')||(line[p] == ',')||(line[p]=='"')) line[p] = ' ';
189-
}
190-
std::istringstream iss(line);
191-
iss.exceptions( std::ifstream::failbit | std::ifstream::badbit);
192-
try
193-
{
194-
while(1)
195-
{
196-
iss >> data;
197-
dataptr[k++] = data;
198-
}
199-
}
200-
catch(...)
201-
{
170+
return(result);
202171
}
203-
}
204-
}
205-
catch (...)
206-
{
207-
if (pr) pr->error("Could not open and read data in file: " + std::string(filename));
208-
return (result);
209-
}
210-
211-
inputfile.close();
212-
}
213-
return(result);
214172
}
215-
216-
217-
bool SCIRun::IgbFileMatrix_writer(LoggerHandle pr, MatrixHandle matrixInput, const char *filename)
218-
{
219-
220-
std::ofstream outputfile;
221-
outputfile.exceptions( std::ofstream::failbit | std::ofstream::badbit );
222-
223-
DenseMatrixHandle matrix = castMatrix::toDense(matrixInput);
224173

225-
if (!matrix)
226-
{
227-
if (pr) pr->error("Empty matrix detected");
228-
return(false);
229-
}
230-
231-
double* dataptr = matrix->data();
232-
if (!dataptr)
233-
{
234-
if (pr) pr->error("Empty matrix detected");
235-
return(false);
236-
}
237-
238-
try
239-
{
240-
outputfile.open(filename);
241-
}
242-
catch (...)
243-
{
244-
if (pr) pr->error("Could not open file: "+std::string(filename));
245-
return (false);
246-
}
247-
248-
// output header line
249-
//int rows = matrix->nrows();
250-
//int cols = matrix->ncols();
251-
outputfile << matrix->nrows() << " " << matrix->ncols() << std::endl;
252-
253-
size_t k = 0;
254-
for (int p=0; p<matrix->nrows(); p++)
255-
{
256-
for (int q=0; q<matrix->ncols(); q++)
257-
{
258-
outputfile << dataptr[k++] << " ";
259-
}
260-
outputfile << "\n";
261-
}
262174

263-
return (true);
264-
}
175+
176+
265177

266178

267179

src/Interface/Application/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ SET(Interface_Application_HEADERS
102102
SET(Interface_Application_FORMS
103103
DeveloperConsole.ui
104104
Module.ui
105-
ConnectionStyleWizardPage.ui
106105
ModuleLogWindow.ui
106+
ConnectionStyleWizardPage.ui
107107
NoteEditor.ui
108108
Preferences.ui
109109
ProvenanceWindow.ui

src/Interface/Application/MainWindowCollaborators.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,9 @@ QWizardPage* NewUserWizard::createLicensePage()
224224
QString licenseText(
225225
"<p><a href = \"https://raw.githubusercontent.com/SCIInstitute/SCIRun/master/src/LICENSE.txt\">SCIRun License</a>"
226226
"<p><a href = \"https://raw.githubusercontent.com/CIBC-Internal/teem/master/LICENSE.txt\">Teem License</a>"
227-
#if WITH_TETGEN
228-
"<p><a href = \"http://wias-berlin.de/software/tetgen/1.5/FAQ-license.html\">Tetgen License</a>"
229-
#endif
227+
//#if WITH_TETGEN
228+
// "<p><a href = \"http://wias-berlin.de/software/tetgen/1.5/FAQ-license.html\">Tetgen License</a>"
229+
//#endif
230230
);
231231
auto layout = new QVBoxLayout;
232232
auto licenseLabel = new QLabel(licenseText);

src/Interface/Modules/Render/ES/SRInterface.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1841,8 +1841,8 @@ namespace SCIRun {
18411841
GLsizei(w), GLsizei(h), 0,
18421842
GL_RGBA,
18431843
GL_UNSIGNED_BYTE, (GLvoid*)font));
1844-
delete font_data;
1845-
delete font;
1844+
delete [] font_data;
1845+
delete [] font;
18461846
}
18471847
}
18481848
} // namespace Render

0 commit comments

Comments
 (0)