Skip to content

Commit 3ce4945

Browse files
author
allywarner
committed
Merge remote-tracking branch 'SCIInstitute/master'
2 parents 9f18eba + 9bd0adf commit 3ce4945

File tree

12 files changed

+1287
-98
lines changed

12 files changed

+1287
-98
lines changed

src/Core/Algorithms/Legacy/Fields/MarchingCubes/MarchingCubes.cc

Lines changed: 53 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Copyright (c) 2009 Scientific Computing and Imaging Institute,
77
University of Utah.
88
9-
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
@@ -90,73 +90,73 @@ template <class TESSELATOR>
9090
class MarchingCubesAlgoP {
9191

9292
public:
93-
94-
MarchingCubesAlgoP(FieldHandle input,const std::vector<double>& iso_values) :
93+
94+
MarchingCubesAlgoP(FieldHandle input,const std::vector<double>& iso_values) :
9595
input_(input),
9696
iso_values_(iso_values) { }
97-
97+
9898
~MarchingCubesAlgoP()
9999
{
100100
#ifdef SCIRUN4_CODE_TO_BE_ENABLED_LATER
101101
delete_all_items(tesselator_);
102102
#endif
103103
}
104-
104+
105105
FieldHandle input_;
106-
106+
107107
std::vector<TESSELATOR*> tesselator_;
108108
std::vector<FieldHandle> output_field_;
109109
std::vector<MatrixHandle> output_interpolant_matrix_;
110110
std::vector<MatrixHandle> output_parent_cell_matrix_;
111111
#ifdef SCIRUN4_CODE_TO_BE_ENABLED_LATER
112112
std::vector<GeomHandle> output_geometry_;
113113
#endif
114-
114+
115115
bool build_field_;
116116
bool build_node_interpolant_;
117117
bool build_elem_interpolant_;
118118
bool build_geometry_;
119119
bool transparency_;
120-
120+
121121
const std::vector<double>& iso_values_;
122122
const AlgorithmBase* algo_;
123-
123+
124124
bool run(const AlgorithmBase* algo, FieldHandle& output,
125125
MatrixHandle& node_interpolant,MatrixHandle& elem_interpolant );
126-
126+
127127
void parallel(int proc, int nproc, size_t iso);
128-
128+
129129
private:
130130
AppendFieldsAlgorithm append_fields_;
131131
AppendMatrixAlgorithm append_matrices_;
132132

133133
};
134134

135135

136-
bool
137-
MarchingCubesAlgo::run(FieldHandle input, std::vector<double>& isovalues)
136+
bool
137+
MarchingCubesAlgo::run(FieldHandle input, const std::vector<double>& isovalues)
138138
{
139139
FieldHandle dummy0;
140140
MatrixHandle dummy1, dummy2;
141141
return run(input,isovalues,dummy0,dummy1,dummy2);
142142
}
143143

144-
bool
145-
MarchingCubesAlgo::run(FieldHandle input, std::vector<double>& isovalues, FieldHandle& field )
144+
bool
145+
MarchingCubesAlgo::run(FieldHandle input, const std::vector<double>& isovalues, FieldHandle& field )
146146
{
147147
MatrixHandle dummy1, dummy2;
148148
return run(input,isovalues,field,dummy1,dummy2);
149149
}
150150

151151
template <class TESSELATOR>
152152
bool
153-
MarchingCubesAlgoP<TESSELATOR>::run(const AlgorithmBase* algo,
154-
FieldHandle& output,
153+
MarchingCubesAlgoP<TESSELATOR>::run(const AlgorithmBase* algo,
154+
FieldHandle& output,
155155
MatrixHandle& node_interpolant,
156-
MatrixHandle& elem_interpolant)
156+
MatrixHandle& elem_interpolant)
157157
{
158158
algo_ = algo;
159-
159+
160160
#ifdef SCIRUN4_CODE_TO_BE_ENABLED_LATER
161161
int np = algo->get_int("num_threads");
162162
/// By default (-1) choose number of processors
@@ -165,47 +165,47 @@ MarchingCubesAlgoP<TESSELATOR>::run(const AlgorithmBase* algo,
165165
if (np > 4*Thread::numProcessors()) np = 4*Thread::numProcessors();
166166
*/
167167
/// @todo: FIX MULTI THREADING OF MARCHING CUBES FIELDS ARE NOT PROPORLY LINKED
168-
#endif
168+
#endif
169169
int np = Parallel::NumCores();
170-
170+
171171
np = 1;
172172
size_t num_values = iso_values_.size();
173-
173+
174174
tesselator_.resize(np);
175175
for (size_t j=0; j<tesselator_.size(); j++)
176176
tesselator_[j] = new TESSELATOR(input_);
177-
177+
178178
output_field_.resize(np*num_values);
179179
output_interpolant_matrix_.resize(np*num_values);
180-
output_parent_cell_matrix_.resize(np*num_values);
180+
output_parent_cell_matrix_.resize(np*num_values);
181181
//output_geometry_.resize(np*num_values);
182-
182+
183183
build_field_ = algo->get(MarchingCubesAlgo::build_field).toBool();
184184
build_geometry_ = algo->get(MarchingCubesAlgo::build_geometry).toBool();
185185
build_node_interpolant_ = algo->get(MarchingCubesAlgo::build_node_interpolant).toBool();
186186
build_elem_interpolant_ = algo->get(MarchingCubesAlgo::build_elem_interpolant).toBool();
187187
transparency_ = algo->get(MarchingCubesAlgo::transparency).toBool();
188-
189-
#ifdef SCIRUN4_CODE_TO_BE_ENABLED_LATER
188+
189+
#ifdef SCIRUN4_CODE_TO_BE_ENABLED_LATER
190190
append_fields_.set_progress_reporter(algo->get_progress_reporter());
191191
append_matrices_.set_progress_reporter(algo->get_progress_reporter());
192192
append_matrices_.setOption("method","append_rows");
193193
#endif
194194

195195
for (size_t j=0; j<iso_values_.size(); j++)
196196
{
197-
if (np == 1)
197+
if (np == 1)
198198
{
199199
parallel(0,1,j);
200200
}
201201
else
202202
{
203-
#ifdef SCIRUN4_CODE_TO_BE_ENABLED_LATER
203+
#ifdef SCIRUN4_CODE_TO_BE_ENABLED_LATER
204204
Thread::parallel(this,&MarchingCubesAlgoP<TESSELATOR>::parallel,np,np,j);
205205
#endif
206206
}
207207
}
208-
#ifdef SCIRUN4_CODE_TO_BE_ENABLED_LATER
208+
#ifdef SCIRUN4_CODE_TO_BE_ENABLED_LATER
209209
if (output_geometry_.size() == 0)
210210
{
211211
geometry = 0;
@@ -219,45 +219,45 @@ MarchingCubesAlgoP<TESSELATOR>::run(const AlgorithmBase* algo,
219219
// link geometries
220220
GeomGroup* group = new GeomGroup;
221221
for (size_t j=0; j < output_geometry_.size(); j++) group->add(output_geometry_[j]);
222-
geometry = group;
222+
geometry = group;
223223
}
224224
#endif
225-
225+
226226
if (build_field_)
227227
{
228-
if (!(append_fields_.run(output_field_,output)))
228+
if (!(append_fields_.run(output_field_,output)))
229229
return (false);
230230
}
231231

232232
#ifdef SCIRUN4_CODE_TO_BE_ENABLED_LATER
233233
if (build_node_interpolant_)
234234
{
235-
if (!(append_matrices_.run(output_interpolant_matrix_,node_interpolant)))
235+
if (!(append_matrices_.run(output_interpolant_matrix_,node_interpolant)))
236236
return (false);
237237
}
238238

239239
if (build_elem_interpolant_)
240240
{
241-
if (!(append_matrices_.run(output_parent_cell_matrix_,elem_interpolant)))
241+
if (!(append_matrices_.run(output_parent_cell_matrix_,elem_interpolant)))
242242
return (false);
243243
}
244244
#endif
245-
245+
246246
return (true);
247247
}
248248

249-
bool MarchingCubesAlgo::run(FieldHandle input, std::vector<double>& isovalues, FieldHandle& field, MatrixHandle& node_interpolant, MatrixHandle& elem_interpolant) const
249+
bool MarchingCubesAlgo::run(FieldHandle input, const std::vector<double>& isovalues, FieldHandle& field, MatrixHandle& node_interpolant, MatrixHandle& elem_interpolant) const
250250
{
251251

252252
if (!input)
253253
{
254254
error("MarchingCube algorithm error: Input field is Null pointer.");
255255
}
256-
256+
257257
bool success = false;
258-
258+
259259
FieldInformation fi(input);
260-
260+
261261
if (fi.is_pnt_element())
262262
{
263263
error("Field needs to have elements in order to extract isosurfaces");
@@ -300,7 +300,7 @@ bool MarchingCubesAlgo::run(FieldHandle input, std::vector<double>& isovalues, F
300300
success = algo.run(this,field,node_interpolant,elem_interpolant);
301301
}
302302
}
303-
303+
304304
return true;
305305
}
306306

@@ -311,21 +311,21 @@ void MarchingCubesAlgoP<TESSELATOR>::parallel( int proc, int nproc, size_t iso)
311311
tesselator_[proc]->reset(0, build_field_, build_geometry_, transparency_);
312312

313313
VMesh* imesh = input_->vmesh();
314-
315-
VMesh::size_type num_elems = imesh->num_elems();
316-
314+
315+
VMesh::size_type num_elems = imesh->num_elems();
316+
317317
index_type start = (proc)*(num_elems/nproc);
318318
index_type end = (proc < nproc-1) ? (proc+1)*(num_elems/nproc) : num_elems;
319319

320320
index_type cnt = 0;
321321
size_type total = (num_elems*iso_values_.size()/nproc);
322-
index_type offset = (num_elems*iso/nproc);
322+
index_type offset = (num_elems*iso/nproc);
323323
double isoval = iso_values_[iso];
324324

325325
for(VMesh::Elem::index_type idx= start ; idx<end; idx++)
326326
{
327327
tesselator_[proc]->extract(idx, isoval);
328-
if (proc == 0)
328+
if (proc == 0)
329329
{
330330
cnt++;
331331
if (cnt == 300)
@@ -335,17 +335,17 @@ void MarchingCubesAlgoP<TESSELATOR>::parallel( int proc, int nproc, size_t iso)
335335
}
336336
}
337337
}
338-
338+
339339
output_field_[iso*nproc+proc] = 0;
340340
output_interpolant_matrix_[iso*nproc+proc] = 0;
341341
output_parent_cell_matrix_[iso*nproc+proc] = 0;
342-
342+
343343
#ifdef SCIRUN4_CODE_TO_BE_ENABLED_LATER
344344
output_geometry_[iso*nproc+proc] = 0;
345345
#endif
346-
347-
if (build_field_)
348-
{
346+
347+
if (build_field_)
348+
{
349349
output_field_[iso*nproc+proc] = tesselator_[proc]->get_field(isoval);
350350
}
351351
if (build_node_interpolant_)
@@ -356,7 +356,7 @@ void MarchingCubesAlgoP<TESSELATOR>::parallel( int proc, int nproc, size_t iso)
356356
{
357357
output_parent_cell_matrix_[iso*nproc+proc] = tesselator_[proc]->get_parent_cells();
358358
}
359-
359+
360360
#ifdef SCIRUN4_CODE_TO_BE_ENABLED_LATER
361361
if (build_geometry_)
362362
{
@@ -383,6 +383,5 @@ void MarchingCubesAlgoP<TESSELATOR>::parallel( int proc, int nproc, size_t iso)
383383
}
384384
}
385385
#endif
386-
387-
}
388386

387+
}

src/Core/Algorithms/Legacy/Fields/MarchingCubes/MarchingCubes.h

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Copyright (c) 2015 Scientific Computing and Imaging Institute,
77
University of Utah.
88
9-
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
@@ -48,43 +48,43 @@
4848
namespace SCIRun {
4949
namespace Core {
5050
namespace Algorithms {
51-
52-
class SCISHARE MarchingCubesAlgo : public AlgorithmBase
51+
52+
class SCISHARE MarchingCubesAlgo : public AlgorithmBase
5353
{
5454

5555
public:
5656

5757
MarchingCubesAlgo();
58-
58+
5959
static AlgorithmParameterName transparency;
6060
static AlgorithmParameterName build_geometry;
6161
static AlgorithmParameterName build_field;
6262
static AlgorithmParameterName build_node_interpolant;
6363
static AlgorithmParameterName build_elem_interpolant;
6464
static AlgorithmParameterName num_threads;
65-
65+
6666
#ifdef SCIRUN4_CODE_TO_BE_ENABLED_LATER
67-
{
67+
{
6868
add_color("color",Color(0.5,0.5,0.5));
6969
add_colormap("colormap",0);
7070
};
7171
#endif
72-
73-
bool run(FieldHandle input, std::vector<double>& isovalues);
74-
75-
bool run(FieldHandle input, std::vector<double>& isovalues, FieldHandle& field);
76-
77-
bool run(FieldHandle input, std::vector<double>& isovalues,
72+
73+
bool run(FieldHandle input, const std::vector<double>& isovalues);
74+
75+
bool run(FieldHandle input, const std::vector<double>& isovalues, FieldHandle& field);
76+
77+
bool run(FieldHandle input, const std::vector<double>& isovalues,
7878
FieldHandle& field, Datatypes::MatrixHandle& interpolant );
79-
79+
8080
AlgorithmOutput run(const AlgorithmInput& input) const;
81-
82-
bool run(FieldHandle input, std::vector<double>& isovalues,
81+
82+
bool run(FieldHandle input, const std::vector<double>& isovalues,
8383
FieldHandle& field,
8484
Datatypes::MatrixHandle& node_interpolant,
8585
Datatypes::MatrixHandle& elem_interpolant ) const;
8686
};
87-
87+
8888
}
8989
} // End namespace SCIRun
9090
}

0 commit comments

Comments
 (0)