Skip to content

Commit 229b041

Browse files
committed
Typos, clean up, header slimming, etc
1 parent e068ef3 commit 229b041

File tree

10 files changed

+198
-202
lines changed

10 files changed

+198
-202
lines changed

src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,7 @@ SET_PROPERTY(TARGET Core_Application_Preferences PROPERTY FOLDER "Core")
588588
SET_PROPERTY(TARGET Core_Application_Session PROPERTY FOLDER "Core")
589589
SET_PROPERTY(TARGET Core_Utils PROPERTY FOLDER "Core")
590590
SET_PROPERTY(TARGET Core_Math PROPERTY FOLDER "Core")
591+
SET_PROPERTY(TARGET Core_Matlab PROPERTY FOLDER "Core")
591592
SET_PROPERTY(TARGET Core_Parser PROPERTY FOLDER "Core")
592593
SET_PROPERTY(TARGET Core_Exceptions_Legacy PROPERTY FOLDER "Core")
593594
SET_PROPERTY(TARGET Core_Util_Legacy PROPERTY FOLDER "Core")

src/Core/Matlab/CMakeLists.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,12 @@ ADD_LIBRARY(Core_Matlab ${Core_Matlab_SRCS})
5757

5858
TARGET_LINK_LIBRARIES(Core_Matlab
5959
Core_Datatypes
60-
Core_Exceptions
61-
Core_Thread
62-
Core_Geometry
63-
Core_Util
60+
#Core_Exceptions
61+
#Core_Thread
62+
Core_Geometry_Primitives
63+
#Core_Util
6464
Core_Math
65+
Core_Logging
6566
${SCI_ZLIB_LIBRARY}
6667
${SCI_TEEM_LIBRARY}
6768
)

src/Core/Matlab/fieldtomatlab.cc

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,46 @@
3434

3535
#include <Core/Matlab/fieldtomatlab.h>
3636

37-
namespace MatlabIO {
37+
using namespace SCIRun::MatlabIO;
3838

39+
FieldToMatlabAlgo::FieldToMatlabAlgo() :
40+
option_forceoldnames_(false),
41+
option_nofieldconnectivity_(false),
42+
option_indexbase_(1),
43+
pr_(0)
44+
{
45+
}
46+
47+
void FieldToMatlabAlgo::setreporter(SCIRun::ProgressReporter* pr)
48+
{
49+
pr_ = pr;
50+
}
51+
52+
53+
void FieldToMatlabAlgo::option_forceoldnames(bool value)
54+
{
55+
option_forceoldnames_ = value;
56+
}
57+
58+
void FieldToMatlabAlgo::option_nofieldconnectivity(bool value)
59+
{
60+
option_nofieldconnectivity_ = value;
61+
}
62+
63+
void FieldToMatlabAlgo::option_indexbase(int indexbase)
64+
{
65+
option_indexbase_ = indexbase;
66+
}
3967

40-
using namespace SCIRun;
68+
void FieldToMatlabAlgo::error(std::string error)
69+
{
70+
if(pr_) pr_->error(error);
71+
}
72+
73+
void FieldToMatlabAlgo::warning(std::string warning)
74+
{
75+
if(pr_) pr_->warning(warning);
76+
}
4177

4278

4379
FieldToMatlabAlgo::~FieldToMatlabAlgo()
@@ -269,13 +305,13 @@ bool FieldToMatlabAlgo::mladdnodes(SCIRun::VMesh* mesh,matlabarray mlarray)
269305
// Request that it generates the node matrix
270306
mesh->synchronize(SCIRun::Mesh::NODES_E);
271307

272-
// Buffers for exporting the data to matlab.
308+
// Buffers for exporting the data to Matlab.
273309
// The MatlabIO does not use SCIRun style iterators hence we need to extract
274310
// the data first.
275311
std::vector<double> nodes(3*numnodes);
276312
std::vector<int> dims(2);
277313

278-
// Setup the dimensions of the matlab array
314+
// Setup the dimensions of the Matlab array
279315
dims[0] = 3; dims[1] = static_cast<int>(numnodes);
280316

281317
// Extracting data from the SCIRun classes is a painfull process.
@@ -587,7 +623,7 @@ FieldToMatlabAlgo::mladdxyzmesh2d(SCIRun::VMesh* mesh,matlabarray mlarray)
587623
y.createdensearray(static_cast<int>(dim2),static_cast<int>(dim1),matlabarray::miDOUBLE);
588624
z.createdensearray(static_cast<int>(dim2),static_cast<int>(dim1),matlabarray::miDOUBLE);
589625

590-
// We use temp buffers to store all the values before committing them to the matlab
626+
// We use temp buffers to store all the values before committing them to the Matlab
591627
// classes, this takes up more memory, but should decrease the number of actual function
592628
// calls, which should be boost performance
593629
std::vector<double> xbuffer(numnodes);
@@ -644,7 +680,7 @@ FieldToMatlabAlgo::mladdxyzmesh3d(SCIRun::VMesh* mesh,matlabarray mlarray)
644680
y.createdensearray(dims,matlabarray::miDOUBLE);
645681
z.createdensearray(dims,matlabarray::miDOUBLE);
646682

647-
// We use temp buffers to store all the values before committing them to the matlab
683+
// We use temp buffers to store all the values before committing them to the Matlab
648684
// classes, this takes up more memory, but should decrease the number of actual function
649685
// calls, which should be boost performance
650686
std::vector<double> xbuffer(numnodes);

src/Core/Matlab/fieldtomatlab.h

Lines changed: 32 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ DEALINGS IN THE SOFTWARE.
5959
#define CORE_MATLABIO_MATLABCONVERTER_FIELDTOMATLAB_H 1
6060

6161
#include <Core/Matlab/matfilebase.h>
62+
#include <Core/Datatypes/DatatypeFwd.h>
6263
#include <Core/Matlab/share.h>
6364

6465
namespace SCIRun
@@ -69,14 +70,12 @@ namespace SCIRun
6970
class SCISHARE FieldToMatlabAlgo : public matfilebase
7071
{
7172
public:
72-
73-
//////// CONSTRUCTOR ///////////////////////////////////
74-
inline FieldToMatlabAlgo();
73+
FieldToMatlabAlgo();
7574
virtual ~FieldToMatlabAlgo();
7675

7776
//////// OPTIONS FOR CONVERTER ////////////////////////
7877

79-
// Set the index base for the matlab code, normally htis one is 1
78+
// Set the index base for the Matlab code, normally this one is 1
8079
inline void option_indexbase(int indexbase);
8180
// Option to switch on the old way of dealing with tensors, the ordering
8281
// is different. When switched off, ordering will be same as SCIRun
@@ -89,49 +88,47 @@ namespace SCIRun
8988
// elements.
9089
inline void option_forceoldnames(bool value);
9190

92-
//////// DYNAMIC ALGO ENTRY POINT /////////////////////
93-
94-
virtual bool execute(SCIRun::FieldHandle fieldH, matlabarray &mlarray);
91+
virtual bool execute(SCIRun::FieldHandle fieldH, matlabarray& mlarray);
9592

96-
inline void setreporter(SCIRun::ProgressReporter* pr);
93+
inline void setreporter(SCIRun::Logging::LoggerHandle pr);
9794

9895
protected:
9996

100-
bool mladdmeshheader(SCIRun::FieldInformation fi, matlabarray mlarray);
101-
bool mladdnodes(SCIRun::VMesh* mesh,matlabarray mlarray);
102-
bool mladdedges(SCIRun::VMesh* mesh,matlabarray mlarray);
103-
bool mladdfaces(SCIRun::VMesh* mesh,matlabarray mlarray);
104-
bool mladdcells(SCIRun::VMesh* mesh,matlabarray mlarray);
105-
bool mladdmeshderivatives(SCIRun::VMesh* mesh,matlabarray mlarray);
97+
bool mladdmeshheader(SCIRun::FieldInformation fi, const matlabarray& mlarray);
98+
bool mladdnodes(SCIRun::VMesh* mesh,const matlabarray& mlarray);
99+
bool mladdedges(SCIRun::VMesh* mesh,const matlabarray& mlarray);
100+
bool mladdfaces(SCIRun::VMesh* mesh,const matlabarray& mlarray);
101+
bool mladdcells(SCIRun::VMesh* mesh,const matlabarray& mlarray);
102+
bool mladdmeshderivatives(SCIRun::VMesh* mesh,const matlabarray& mlarray);
106103

107-
bool mladdtransform(SCIRun::VMesh* mesh,matlabarray mlarray);
108-
bool mladdxyzmesh1d(SCIRun::VMesh* mesh,matlabarray mlarray);
109-
bool mladdxyzmesh2d(SCIRun::VMesh* mesh,matlabarray mlarray);
110-
bool mladdxyzmesh3d(SCIRun::VMesh* mesh,matlabarray mlarray);
104+
bool mladdtransform(SCIRun::VMesh* mesh,const matlabarray& mlarray);
105+
bool mladdxyzmesh1d(SCIRun::VMesh* mesh,const matlabarray& mlarray);
106+
bool mladdxyzmesh2d(SCIRun::VMesh* mesh,const matlabarray& mlarray);
107+
bool mladdxyzmesh3d(SCIRun::VMesh* mesh,const matlabarray& mlarray);
111108

112-
bool mladddimension1d(SCIRun::VMesh* mesh,matlabarray mlarray);
113-
bool mladddimension2d(SCIRun::VMesh* mesh,matlabarray mlarray);
114-
bool mladddimension3d(SCIRun::VMesh* mesh,matlabarray mlarray);
109+
bool mladddimension1d(SCIRun::VMesh* mesh,const matlabarray& mlarray);
110+
bool mladddimension2d(SCIRun::VMesh* mesh,const matlabarray& mlarray);
111+
bool mladddimension3d(SCIRun::VMesh* mesh,const matlabarray& mlarray);
115112

116-
bool mladdfieldheader(SCIRun::FieldInformation fi, matlabarray mlarray);
113+
bool mladdfieldheader(SCIRun::FieldInformation fi, const matlabarray& mlarray);
117114

118-
bool mladdfielddata(SCIRun::VField* field,SCIRun::VMesh* mesh,matlabarray mlarray);
115+
bool mladdfielddata(SCIRun::VField* field,SCIRun::VMesh* mesh,const matlabarray& mlarray);
119116

120-
bool mladdfieldedges(SCIRun::VField *field,SCIRun::VMesh *mesh,matlabarray mlarray);
121-
bool mladdfieldfaces(SCIRun::VField *field,SCIRun::VMesh *mesh,matlabarray mlarray);
122-
bool mladdfieldcells(SCIRun::VField *field,SCIRun::VMesh *mesh,matlabarray mlarray);
117+
bool mladdfieldedges(SCIRun::VField *field,SCIRun::VMesh *mesh,const matlabarray& mlarray);
118+
bool mladdfieldfaces(SCIRun::VField *field,SCIRun::VMesh *mesh,const matlabarray& mlarray);
119+
bool mladdfieldcells(SCIRun::VField *field,SCIRun::VMesh *mesh,const matlabarray& mlarray);
123120

124-
bool mladdfieldedgederivatives(SCIRun::VField *field,SCIRun::VMesh *mesh,matlabarray mlarray);
125-
bool mladdfieldfacederivatives(SCIRun::VField *field,SCIRun::VMesh *mesh,matlabarray mlarray);
126-
bool mladdfieldcellderivatives(SCIRun::VField *field,SCIRun::VMesh *mesh,matlabarray mlarray);
121+
bool mladdfieldedgederivatives(SCIRun::VField *field,SCIRun::VMesh *mesh,const matlabarray& mlarray);
122+
bool mladdfieldfacederivatives(SCIRun::VField *field,SCIRun::VMesh *mesh,const matlabarray& mlarray);
123+
bool mladdfieldcellderivatives(SCIRun::VField *field,SCIRun::VMesh *mesh,const matlabarray& mlarray);
127124

128-
bool mladdfieldderivatives(SCIRun::VField *field,SCIRun::VMesh *mesh,matlabarray mlarray);
125+
bool mladdfieldderivatives(SCIRun::VField *field,SCIRun::VMesh *mesh,const matlabarray& mlarray);
129126

130127

131-
//////// ERROR REPORTERING MECHANISM /////////////////
128+
//////// ERROR REPORTING MECHANISM /////////////////
132129

133-
inline void error(std::string error);
134-
inline void warning(std::string warning);
130+
void error(const std::string& error);
131+
void warning(const std::string& warning);
135132

136133
//////// OPTION PARAMETERS //////////////////////////
137134

@@ -140,49 +137,11 @@ namespace SCIRun
140137
int option_indexbase_;
141138

142139
private:
143-
SCIRun::ProgressReporter *pr_;
140+
SCIRun::Logging::LoggerHandle pr_;
144141

145142
};
146143

147-
inline FieldToMatlabAlgo::FieldToMatlabAlgo() :
148-
option_forceoldnames_(false),
149-
option_nofieldconnectivity_(false),
150-
option_indexbase_(1),
151-
pr_(0)
152-
{
153-
}
154-
155-
inline void FieldToMatlabAlgo::setreporter(SCIRun::ProgressReporter* pr)
156-
{
157-
pr_ = pr;
158-
}
159-
160-
161-
inline void FieldToMatlabAlgo::option_forceoldnames(bool value)
162-
{
163-
option_forceoldnames_ = value;
164-
}
165-
166-
inline void FieldToMatlabAlgo::option_nofieldconnectivity(bool value)
167-
{
168-
option_nofieldconnectivity_ = value;
169-
}
170-
171-
inline void FieldToMatlabAlgo::option_indexbase(int indexbase)
172-
{
173-
option_indexbase_ = indexbase;
174-
}
175-
176-
inline void FieldToMatlabAlgo::error(std::string error)
177-
{
178-
if(pr_) pr_->error(error);
179-
}
180-
181-
inline void FieldToMatlabAlgo::warning(std::string warning)
182-
{
183-
if(pr_) pr_->warning(warning);
184-
}
185-
144+
186145

187146
}}
188147

src/Core/Matlab/matfile.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
*
8383
*/
8484

85+
#include <stack>
8586
#include <Core/Matlab/matfiledata.h>
8687
#include <Core/Matlab/share.h>
8788

@@ -107,7 +108,7 @@ class SCISHARE matfile : public matfilebase {
107108
};
108109

109110
// This next struct is used for buffering sections of the compressed
110-
// data chuncks in V7 of matlab.
111+
// data chuncks in V7 of Matlab.
111112
// The basic idea is to decompress compressed pieces of the files and maintain a
112113
// list of the pieces that have been compresse
113114
// Using the offset in the file these pieces can be unique identified and cataloged
@@ -185,7 +186,7 @@ class SCISHARE matfile : public matfilebase {
185186
bool byteswap();
186187
bool byteswapmachine();
187188

188-
// Reading the matlab-file header
189+
// Reading the Matlab-file header
189190
// This header contains text (126 bytes) explaining the origin of the data
190191
// Can be an arbritrary text
191192

@@ -242,7 +243,7 @@ class SCISHARE matfile : public matfilebase {
242243
void closechild();
243244

244245
// open and close a compressed section of data
245-
// Compression is only used for reading matlab V7 files
246+
// Compression is only used for reading Matlab V7 files
246247
// Data is exported as non compressed data to be compatible with
247248
// version 5 and 6.
248249

src/Core/Matlab/matfilebase.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ namespace SCIRun
5959
namespace MatlabIO
6060
{
6161

62+
class matlabarray;
63+
6264
class SCISHARE matfilebase
6365
{
6466
public:
@@ -147,5 +149,6 @@ namespace SCIRun
147149
};
148150
};
149151

150-
} // end namespace
152+
}}
153+
151154
#endif

0 commit comments

Comments
 (0)