@@ -58,6 +58,9 @@ void Gen::moab_printer(moab::ErrorCode error_code) {
5858 if (error_code == moab::MB_FAILURE ) {
5959 std::cerr << " ERROR: moab::MB_FAILURE" << std::endl;
6060 }
61+ else {
62+ std::cerr << " ERROR CODE NOT RECOGNIZED" << std::endl;
63+ }
6164 return ;
6265}
6366
@@ -69,7 +72,7 @@ void Gen::print_vertex_cubit(const moab::EntityHandle vertex) {
6972
7073 moab::ErrorCode result;
7174 double coords[3 ];
72- int n_precision = 20 ;
75+ const int n_precision = 20 ;
7376 result = MBI ()->get_coords (&vertex, 1 , coords);
7477 assert (moab::MB_SUCCESS == result);
7578 std::cout << " create vertex "
@@ -214,7 +217,7 @@ void Gen::print_loop(const std::vector<moab::EntityHandle> loop_of_verts) {
214217// / For efficiency: only get_coords on the reference vertex once
215218// / if specified, limit search length along curve
216219moab::ErrorCode Gen::find_closest_vert (const moab::EntityHandle reference_vert,
217- const std::vector<moab::EntityHandle> arc_of_verts,
220+ const std::vector<moab::EntityHandle>& arc_of_verts,
218221 unsigned & position,
219222 const double dist_limit) {
220223 moab::ErrorCode rval;
@@ -264,7 +267,7 @@ moab::ErrorCode Gen::find_closest_vert(const moab::EntityHandle reference_vert,
264267// This ensure that both are returned as candidates.
265268moab::ErrorCode Gen::find_closest_vert (const double tol,
266269 const moab::EntityHandle reference_vert,
267- const std::vector<moab::EntityHandle> loop_of_verts,
270+ const std::vector<moab::EntityHandle>& loop_of_verts,
268271 std::vector<unsigned >& positions,
269272 std::vector<double >& dists) {
270273
@@ -305,7 +308,7 @@ moab::ErrorCode Gen::merge_vertices(moab::Range verts /* in */, const double tol
305308 const double SQR_TOL = tol * tol;
306309 // Clean up the created tree, and track verts so that if merged away they are
307310 // removed from the tree.
308- moab::AdaptiveKDTree kdtree (MBI ()); // , true, 0, moab::MESHSET_TRACK_OWNER);
311+ moab::AdaptiveKDTree kdtree (MBI ());
309312 // initialize the KD Tree
310313 moab::EntityHandle root;
311314 const char settings[] = " MAX_PER_LEAF=6;MAX_DEPTH=50;SPLITS_PER_DIR=1;PLANE_SET=2;MESHSET_FLAGS=0x1;TAG_NAME=0" ;
@@ -327,8 +330,12 @@ moab::ErrorCode Gen::merge_vertices(moab::Range verts /* in */, const double tol
327330 std::vector<moab::EntityHandle> leaf_verts;
328331 result = MBI ()->get_entities_by_type (leaves_out[j], moab::MBVERTEX , leaf_verts);
329332 assert (moab::MB_SUCCESS == result);
330- if (100 < leaf_verts.size ())
333+
334+ // write number of leaf verts to screen if there is an abnormally high number of them
335+ const int large_leaf_limit = 100 ;
336+ if (leaf_verts.size () > large_leaf_limit)
331337 std::cout << " *i=" << *i << " leaf_verts.size()=" << leaf_verts.size () << std::endl;
338+
332339 for (unsigned int k = 0 ; k < leaf_verts.size (); k++) {
333340 if (leaf_verts[k] == *i)
334341 continue ;
@@ -357,7 +364,7 @@ moab::ErrorCode Gen::merge_vertices(moab::Range verts /* in */, const double tol
357364
358365moab::ErrorCode Gen::squared_dist_between_verts (const moab::EntityHandle v0,
359366 const moab::EntityHandle v1,
360- double & d ) {
367+ double & squared_dist ) {
361368 moab::ErrorCode result;
362369 moab::CartVect coords0, coords1;
363370 result = MBI ()->get_coords (&v0, 1 , coords0.array ());
@@ -373,7 +380,7 @@ moab::ErrorCode Gen::squared_dist_between_verts(const moab::EntityHandle v0,
373380 return result;
374381 }
375382 const moab::CartVect diff = coords0 - coords1;
376- d = diff.length_squared ();
383+ squared_dist = diff.length_squared ();
377384 return moab::MB_SUCCESS ;
378385}
379386
@@ -427,15 +434,14 @@ double Gen::length(std::vector<moab::EntityHandle> edges) {
427434 return 0 ;
428435
429436 moab::ErrorCode result;
430- std::vector<moab::EntityHandle>::iterator i;
431437 double dist = 0 ;
432438 moab::EntityType type = MBI ()->type_from_handle (edges[0 ]);
433439
434440 // if vector has both edges and verts, only use edges
435441 // NOTE: The curve sets from ReadCGM do not contain duplicate endpoints for loops!
436442 moab::EntityType end_type = MBI ()->type_from_handle (edges.back ());
437443 if (type != end_type) {
438- for (std::vector<moab::EntityHandle>::iterator i = edges.begin (); i != edges.end (); i++) {
444+ for (auto i = edges.begin (); i != edges.end (); i++) {
439445 if (moab::MBVERTEX == MBI ()->type_from_handle (*i)) {
440446 i = edges.erase (i) - 1 ;
441447 }
@@ -447,7 +453,7 @@ double Gen::length(std::vector<moab::EntityHandle> edges) {
447453 if (moab::MBEDGE == type) {
448454 if (edges.empty ())
449455 return 0.0 ;
450- for (i = edges.begin (); i != edges.end (); i++) {
456+ for (auto i = edges.begin (); i != edges.end (); i++) {
451457 int n_verts;
452458 const moab::EntityHandle* conn;
453459 result = MBI ()->get_connectivity (*i, conn, n_verts);
@@ -463,7 +469,7 @@ double Gen::length(std::vector<moab::EntityHandle> edges) {
463469 if (2 > edges.size ())
464470 return 0.0 ;
465471 moab::EntityHandle front_vert = edges.front ();
466- for (i = edges.begin () + 1 ; i != edges.end (); i++) {
472+ for (auto i = edges.begin () + 1 ; i != edges.end (); i++) {
467473 dist += dist_between_verts (front_vert, *i);
468474 front_vert = *i;
469475 }
@@ -510,7 +516,6 @@ bool Gen::edges_adjacent(moab::EntityHandle edge0, moab::EntityHandle edge1) {
510516// get the direction unit vector from one vertex to another vertex
511517moab::ErrorCode Gen::get_direction (const moab::EntityHandle from_vert, const moab::EntityHandle to_vert,
512518 moab::CartVect& dir) {
513- // double d[3];
514519 moab::ErrorCode result;
515520 moab::CartVect coords0, coords1;
516521 result = MBI ()->get_coords (&from_vert, 1 , coords0.array ());
@@ -821,11 +826,6 @@ bool Gen::collinear(const moab::EntityHandle a, const moab::EntityHandle b,
821826 return false ;
822827}
823828
824- // Exclusive or: T iff exactly one argument is true
825- bool logical_xor (const bool x, const bool y) {
826- return (x || y) && !(x && y);
827- }
828-
829829bool Gen::intersect_prop (const moab::EntityHandle a, const moab::EntityHandle b,
830830 const moab::EntityHandle c, const moab::EntityHandle d,
831831 const moab::CartVect n) {
@@ -835,8 +835,8 @@ bool Gen::intersect_prop(const moab::EntityHandle a, const moab::EntityHandle b,
835835 collinear (c, d, b, n)) {
836836 return false ;
837837 } else {
838- return logical_xor (left (a, b, c, n), left (a, b, d, n)) &&
839- logical_xor (left (c, d, a, n), left (c, d, b, n));
838+ return (left (a, b, c, n) != left (a, b, d, n)) &&
839+ (left (c, d, a, n) != left (c, d, b, n));
840840 }
841841}
842842
@@ -1246,18 +1246,11 @@ moab::ErrorCode Gen::dist_between_arcs(bool debug,
12461246 }
12471247 }
12481248
1249- for (unsigned int i = 0 ; i < mgd_params.size (); i++) {
1250-
1251- }
1252-
12531249 // Insert new points to match the other arcs points, by parameter.
12541250 for (unsigned int i = 0 ; i < 2 ; i++) {
12551251 for (unsigned int j = 0 ; j < mgd_params.size (); j++) {
1256- // std::cout << "params[" << i << "][" << j << "]=" << params[i][j]
1257- // << " mgd_params[" << j << "]=" << mgd_params[j] << std::endl;
12581252 if (params[i][j] > mgd_params[j]) {
12591253 double ratio = (mgd_params[j] - params[i][j - 1 ]) / (params[i][j] - params[i][j - 1 ]);
1260- // std::cout << "j=" << j << " ratio=" << ratio << std::endl;
12611254 moab::CartVect pt = coords[i][j - 1 ] + ratio * (coords[i][j] - coords[i][j - 1 ]);
12621255 coords[i].insert (coords[i].begin () + j, pt);
12631256 params[i].insert (params[i].begin () + j, mgd_params[j]);
@@ -1533,7 +1526,11 @@ moab::ErrorCode Gen::get_signed_volume(const moab::EntityHandle surf_set, double
15331526 return moab::MB_SUCCESS ;
15341527}
15351528
1536- moab::ErrorCode Gen::measure (const moab::EntityHandle set, const moab::Tag geom_tag, double & size, bool debug, bool verbose) {
1529+ moab::ErrorCode Gen::measure (const moab::EntityHandle set,
1530+ const moab::Tag geom_tag,
1531+ double & measurement,
1532+ bool debug,
1533+ bool verbose) {
15371534 moab::ErrorCode result;
15381535 int dim;
15391536 result = MBI ()->tag_get_data (geom_tag, &set, 1 , &dim);
@@ -1546,17 +1543,17 @@ moab::ErrorCode Gen::measure(const moab::EntityHandle set, const moab::Tag geom_
15461543 std::vector<moab::EntityHandle> vctr;
15471544 result = get_meshset (set, vctr);
15481545 assert (moab::MB_SUCCESS == result);
1549- size = length (vctr);
1546+ measurement = length (vctr);
15501547
15511548 } else if (2 == dim) {
15521549 moab::Range tris;
15531550 result = MBI ()->get_entities_by_type (set, moab::MBTRI , tris);
15541551 assert (moab::MB_SUCCESS == result);
1555- size = triangle_area (tris);
1552+ measurement = triangle_area (tris);
15561553
15571554 } else if (3 == dim) {
15581555
1559- result = measure_volume (set, size , debug, verbose);
1556+ result = measure_volume (set, measurement , debug, verbose);
15601557
15611558 if (moab::MB_SUCCESS != result) {
15621559 std::cout << " result=" << result << " vol_id="
@@ -1758,10 +1755,8 @@ moab::ErrorCode Gen::remove_surf_sense_data(moab::EntityHandle del_surf, bool de
17581755 moab::Range del_surf_curves;
17591756 result = MBI () -> get_child_meshsets (del_surf, del_surf_curves);
17601757 MB_CHK_SET_ERR (result, " could not get the curves of the surface to delete" );
1761- if (debug)
1762- std::cout << " got the curves" << std::endl;
1763-
17641758 if (debug) {
1759+ std::cout << " got the curves" << std::endl;
17651760 std::cout << " number of curves to the deleted surface = " << del_surf_curves.size () << std::endl;
17661761 for (unsigned int index = 0 ; index < del_surf_curves.size () ; index++) {
17671762 std::cout << " deleted surface's child curve id " << index << " = " << geom_id_by_handle (del_surf_curves[index]) << std::endl;
0 commit comments