Skip to content

Commit 662b2fb

Browse files
authored
Merge branch 'master' into carpmeshIO
2 parents 47e11d3 + 48e03f6 commit 662b2fb

30 files changed

+1082
-861
lines changed

src/Core/Algorithms/Legacy/Fields/MeshDerivatives/GetFieldBoundaryAlgo.cc

Lines changed: 43 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,10 @@ GetFieldBoundaryAlgo::GetFieldBoundaryAlgo()
5353
addOption(AlgorithmParameterName("mapping"),"auto","auto|node|elem|none");
5454
}
5555

56-
struct IndexHash {
57-
static const size_t bucket_size = 4;
58-
static const size_t min_buckets = 8;
59-
56+
struct IndexHash
57+
{
6058
size_t operator()(const index_type &idx) const
6159
{ return (static_cast<size_t>(idx)); }
62-
63-
bool operator()(const index_type &i1, const index_type &i2) const
64-
{ return (i1 < i2); }
6560
};
6661

6762
bool
@@ -70,7 +65,7 @@ GetFieldBoundaryAlgo::run(FieldHandle input, FieldHandle& output, MatrixHandle&
7065
ScopedAlgorithmStatusReporter asr(this, "GetFieldBoundary");
7166

7267
/// Define types we need for mapping
73-
typedef boost::unordered_map<index_type,index_type,IndexHash> hash_map_type;
68+
using hash_map_type = boost::unordered_map<index_type,index_type,IndexHash>;
7469

7570
hash_map_type node_map;
7671
hash_map_type elem_map;
@@ -94,7 +89,7 @@ GetFieldBoundaryAlgo::run(FieldHandle input, FieldHandle& output, MatrixHandle&
9489
}
9590

9691
/// Figure out which type of field the output is:
97-
bool found_method = false;
92+
auto found_method = false;
9893
if (fi.is_hex_element()) { fo.make_quadsurfmesh(); found_method = true; }
9994
if (fi.is_prism_element()) { fo.make_quadsurfmesh(); found_method = true; }
10095
if (fi.is_tet_element()) { fo.make_trisurfmesh(); found_method = true; }
@@ -123,13 +118,13 @@ GetFieldBoundaryAlgo::run(FieldHandle input, FieldHandle& output, MatrixHandle&
123118
}
124119

125120
/// Get the virtual interfaces:
126-
VMesh* imesh = input->vmesh();
127-
VMesh* omesh = output->vmesh();
128-
VField* ifield = input->vfield();
129-
VField* ofield = output->vfield();
130-
131-
imesh->synchronize(Mesh::DELEMS_E|Mesh::ELEM_NEIGHBORS_E);
132-
121+
auto imesh = input->vmesh();
122+
auto omesh = output->vmesh();
123+
auto ifield = input->vfield();
124+
auto ofield = output->vfield();
125+
126+
imesh->synchronize(Mesh::DELEMS_E | Mesh::ELEM_NEIGHBORS_E);
127+
133128
/// These are all virtual iterators, virtual index_types and array_types
134129
VMesh::Elem::iterator be, ee;
135130
VMesh::Elem::index_type nci, ci;
@@ -148,31 +143,31 @@ GetFieldBoundaryAlgo::run(FieldHandle input, FieldHandle& output, MatrixHandle&
148143
imesh->begin(be);
149144
imesh->end(ee);
150145

151-
while (be != ee)
146+
while (be != ee)
152147
{
153148
checkForInterruption();
154149
ci = *be;
155-
imesh->get_delems(delems,ci);
156-
for (size_t p =0; p < delems.size(); p++)
150+
imesh->get_delems(delems, ci);
151+
for (size_t p = 0; p < delems.size(); p++)
157152
{
158-
bool includeface = false;
159-
160-
if(!(imesh->get_neighbor(nci,ci,delems[p]))) includeface = true;
153+
auto includeface = false;
154+
155+
if (!(imesh->get_neighbor(nci, ci, delems[p]))) includeface = true;
161156

162157
if (includeface)
163158
{
164-
imesh->get_nodes(inodes,delems[p]);
159+
imesh->get_nodes(inodes, delems[p]);
165160
onodes.resize(inodes.size());
166161

167-
for (size_t q=0; q<inodes.size(); q++)
162+
for (size_t q = 0; q < inodes.size(); q++)
168163
{
169164
a = inodes[q];
170-
hash_map_type::iterator it = node_map.find(a);
165+
auto it = node_map.find(a);
171166
if (it == node_map.end())
172167
{
173-
imesh->get_center(point,a);
168+
imesh->get_center(point, a);
174169
onodes[q] = omesh->add_node(point);
175-
node_map[a] = onodes[q];
170+
node_map[a] = onodes[q];
176171
}
177172
else
178173
{
@@ -184,11 +179,11 @@ GetFieldBoundaryAlgo::run(FieldHandle input, FieldHandle& output, MatrixHandle&
184179
}
185180
++be;
186181
}
187-
182+
188183
mapping.reset();
189-
184+
190185
ofield->resize_fdata();
191-
186+
192187
if (
193188
(
194189
(ifield->basis_order() == 0)
@@ -308,12 +303,12 @@ GetFieldBoundaryAlgo::run(FieldHandle input, FieldHandle& output, MatrixHandle&
308303
/// project nodes on.
309304

310305
bool
311-
GetFieldBoundaryAlgo::run(FieldHandle input, FieldHandle& output)
306+
GetFieldBoundaryAlgo::run(FieldHandle input, FieldHandle& output) const
312307
{
313308
ScopedAlgorithmStatusReporter asr(this, "GetFieldBoundary");
314309

315310
/// Define types we need for mapping
316-
typedef boost::unordered_map<index_type,index_type,IndexHash> hash_map_type;
311+
using hash_map_type = boost::unordered_map<index_type,index_type,IndexHash>;
317312

318313
hash_map_type node_map;
319314
hash_map_type elem_map;
@@ -337,7 +332,7 @@ GetFieldBoundaryAlgo::run(FieldHandle input, FieldHandle& output)
337332
}
338333

339334
/// Figure out which type of field the output is:
340-
bool found_method = false;
335+
auto found_method = false;
341336
if (fi.is_hex_element()) { fo.make_quadsurfmesh(); found_method = true; }
342337
if (fi.is_prism_element()) { fo.make_quadsurfmesh(); found_method = true; }
343338
if (fi.is_tet_element()) { fo.make_trisurfmesh(); found_method = true; }
@@ -366,10 +361,10 @@ GetFieldBoundaryAlgo::run(FieldHandle input, FieldHandle& output)
366361
}
367362

368363
/// Get the virtual interfaces:
369-
VMesh* imesh = input->vmesh();
370-
VMesh* omesh = output->vmesh();
371-
VField* ifield = input->vfield();
372-
VField* ofield = output->vfield();
364+
auto imesh = input->vmesh();
365+
auto omesh = output->vmesh();
366+
auto ifield = input->vfield();
367+
auto ofield = output->vfield();
373368

374369
imesh->synchronize(Mesh::DELEMS_E|Mesh::ELEM_NEIGHBORS_E);
375370

@@ -391,30 +386,30 @@ GetFieldBoundaryAlgo::run(FieldHandle input, FieldHandle& output)
391386
imesh->begin(be);
392387
imesh->end(ee);
393388

394-
while (be != ee)
389+
while (be != ee)
395390
{
396391
checkForInterruption();
397392
ci = *be;
398-
imesh->get_delems(delems,ci);
399-
for (size_t p =0; p < delems.size(); p++)
393+
imesh->get_delems(delems, ci);
394+
for (size_t p = 0; p < delems.size(); p++)
400395
{
401-
bool includeface = false;
402-
403-
if(!(imesh->get_neighbor(nci,ci,delems[p]))) includeface = true;
396+
auto includeface = false;
397+
398+
if (!(imesh->get_neighbor(nci, ci, delems[p]))) includeface = true;
404399

405400
if (includeface)
406401
{
407-
imesh->get_nodes(inodes,delems[p]);
402+
imesh->get_nodes(inodes, delems[p]);
408403
if (onodes.size() == 0) onodes.resize(inodes.size());
409-
for (size_t q=0; q<onodes.size(); q++)
404+
for (size_t q = 0; q < onodes.size(); q++)
410405
{
411406
a = inodes[q];
412-
hash_map_type::iterator it = node_map.find(a);
407+
auto it = node_map.find(a);
413408
if (it == node_map.end())
414409
{
415-
imesh->get_center(point,a);
410+
imesh->get_center(point, a);
416411
onodes[q] = omesh->add_node(point);
417-
node_map[a] = onodes[q];
412+
node_map[a] = onodes[q];
418413
}
419414
else
420415
{

src/Core/Algorithms/Legacy/Fields/MeshDerivatives/GetFieldBoundaryAlgo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class SCISHARE GetFieldBoundaryAlgo : public AlgorithmBase, public Thread::Inter
5252
/// With mapping
5353
bool run(FieldHandle input, FieldHandle& output, Datatypes::MatrixHandle& mapping) const;
5454
/// Without mapping
55-
bool run(FieldHandle input, FieldHandle& output);
55+
bool run(FieldHandle input, FieldHandle& output) const;
5656

5757
AlgorithmOutput run(const AlgorithmInput& input) const;
5858
};

src/Core/Application/Preferences/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ TARGET_LINK_LIBRARIES(Core_Application_Preferences
4646
${SCI_BOOST_LIBRARY}
4747
)
4848

49+
IF(BUILD_WITH_PYTHON)
50+
TARGET_LINK_LIBRARIES(Core_Application_Preferences
51+
Core_Python
52+
)
53+
ENDIF()
54+
4955
IF(BUILD_SHARED_LIBS)
5056
ADD_DEFINITIONS(-DBUILD_Core_Application_Preferences)
5157
ENDIF(BUILD_SHARED_LIBS)

src/Core/Application/Preferences/Preferences.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
#include <boost/algorithm/string/predicate.hpp>
3434
#include <boost/algorithm/string/split.hpp>
3535
#include <boost/algorithm/string/classification.hpp>
36+
#ifdef BUILD_WITH_PYTHON
37+
#include <Core/Python/PythonInterpreter.h>
38+
#endif
3639

3740
using namespace SCIRun::Core;
3841
using namespace SCIRun::Core::Logging;
@@ -80,6 +83,11 @@ void Preferences::setDataDirectory(const boost::filesystem::path& path)
8083

8184
AlgorithmParameterHelper::setDataDir(dataDir_);
8285
AlgorithmParameterHelper::setDataDirPlaceholder(dataDirectoryPlaceholder());
86+
87+
#ifdef BUILD_WITH_PYTHON
88+
auto setDataDir = "import os; os.environ[\"SCIRUNDATADIR\"] = \"" + dataDir_.string() + "\"";
89+
PythonInterpreter::Instance().run_string(setDataDir);
90+
#endif
8391
}
8492

8593
/// @todo: not sure where this should go.

src/Core/Datatypes/Legacy/Field/HexVolMesh.h

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060

6161
#include <Core/Thread/Mutex.h>
6262
#include <Core/Thread/ConditionVariable.h>
63+
#include <boost/unordered_map.hpp>
6364
#include <boost/thread.hpp>
6465

6566
#include <set>
@@ -2732,29 +2733,10 @@ class HexVolMesh : public Mesh
27322733
}
27332734
};
27342735

2735-
/// Define the hash_map type, as this is not yet an approved type under Windows
2736-
/// it is located in stdext
2737-
2738-
#ifdef HAVE_HASH_MAP
2739-
#if defined(_WIN32)
2740-
/// hash_map is in stdext namespace
2741-
typedef stdext::hash_map<PFace, typename Face::index_type, FaceHash> face_ht;
2742-
typedef stdext::hash_map<PFaceNode, typename Face::index_type, FaceHash> face_nt;
2743-
typedef stdext::hash_map<PEdge, typename Edge::index_type, EdgeHash> edge_ht;
2744-
typedef stdext::hash_map<PEdgeNode, typename Edge::index_type, EdgeHash> edge_nt;
2745-
#else
2746-
/// hash_map is in std namespace
2747-
typedef hash_map<PFace, typename Face::index_type, FaceHash> face_ht;
2748-
typedef hash_map<PFaceNode, typename Face::index_type, FaceHash> face_nt;
2749-
typedef hash_map<PEdge, typename Edge::index_type, EdgeHash> edge_ht;
2750-
typedef hash_map<PEdgeNode, typename Edge::index_type, EdgeHash> edge_nt;
2751-
#endif
2752-
#else
2753-
typedef std::map<PFace, typename Face::index_type, FaceHash> face_ht;
2754-
typedef std::map<PFaceNode, typename Face::index_type, FaceHash> face_nt;
2755-
typedef std::map<PEdge, typename Edge::index_type, EdgeHash> edge_ht;
2756-
typedef std::map<PEdgeNode, typename Edge::index_type, EdgeHash> edge_nt;
2757-
#endif
2736+
using face_ht = boost::unordered_map<PFace, typename Face::index_type, FaceHash>;
2737+
using face_nt = boost::unordered_map<PFaceNode, typename Face::index_type, FaceHash>;
2738+
using edge_ht = boost::unordered_map<PEdge, typename Edge::index_type, EdgeHash>;
2739+
using edge_nt = boost::unordered_map<PEdgeNode, typename Edge::index_type, EdgeHash>;
27582740

27592741
typedef std::vector<PFaceCell> face_ct;
27602742
typedef std::vector<PEdgeCell> edge_ct;

src/Core/Datatypes/Legacy/Field/PrismVolMesh.h

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
#include <Core/GeometryPrimitives/BBox.h>
4242
#include <Core/GeometryPrimitives/CompGeom.h>
4343
#include <Core/GeometryPrimitives/Point.h>
44-
#include <Core/GeometryPrimitives/Plane.h>
4544
#include <Core/GeometryPrimitives/Transform.h>
4645
#include <Core/GeometryPrimitives/Vector.h>
4746

@@ -58,6 +57,7 @@
5857
#include <Core/Utils/Legacy/CheckSum.h>
5958

6059
#include <boost/thread.hpp>
60+
#include <boost/unordered_map.hpp>
6161
#include <Core/Thread/Mutex.h>
6262
#include <Core/Thread/ConditionVariable.h>
6363

@@ -2468,23 +2468,8 @@ class PrismVolMesh : public Mesh
24682468
}
24692469
};
24702470

2471-
/// Define the hash_map type, as this is not yet an approved type under Windows
2472-
/// it is located in stdext
2473-
2474-
#ifdef HAVE_HASH_MAP
2475-
#if defined(_WIN32)
2476-
/// hash_map is in stdext namespace
2477-
typedef stdext::hash_map<PFace, typename Face::index_type, FaceHash> face_ht;
2478-
typedef stdext::hash_map<PEdge, typename Edge::index_type, EdgeHash> edge_ht;
2479-
#else
2480-
/// hash_map is in std namespace
2481-
typedef hash_map<PFace, typename Face::index_type, FaceHash> face_ht;
2482-
typedef hash_map<PEdge, typename Edge::index_type, EdgeHash> edge_ht;
2483-
#endif
2484-
#else
2485-
typedef std::map<PFace, typename Face::index_type, FaceHash> face_ht;
2486-
typedef std::map<PEdge, typename Edge::index_type, EdgeHash> edge_ht;
2487-
#endif
2471+
using face_ht = boost::unordered_map<PFace, typename Face::index_type, FaceHash>;
2472+
using edge_ht = boost::unordered_map<PEdge, typename Edge::index_type, EdgeHash>;
24882473

24892474
/// container for face storage. Must be computed each time
24902475
/// nodes or cells change.

0 commit comments

Comments
 (0)