Skip to content

Commit 90eb4f2

Browse files
committed
- Added InvalidFace checks to overlap mesh generator
1 parent f25d26a commit 90eb4f2

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

src/OverlapMesh.cpp

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,9 +1570,16 @@ int FindFaceContainingNode(
15701570
if (ixSourceFaceSeed > meshSource.faces.size()) {
15711571
_EXCEPTIONT("SourceFaceSeed greater than Source mesh size");
15721572
}
1573+
if (ixSourceFaceSeed < 0) {
1574+
_EXCEPTIONT("SourceFaceSeed less than zero");
1575+
}
15731576
if (ixTargetFaceSeed > meshTarget.faces.size()) {
15741577
_EXCEPTIONT("TargetFaceSeed greater than Target mesh size");
15751578
}
1579+
if (ixTargetFaceSeed < 0) {
1580+
_EXCEPTIONT("TargetFaceSeed less than zero");
1581+
1582+
}
15761583

15771584
const Node & node =
15781585
meshSource.nodes[meshSource.faces[ixSourceFaceSeed][0]];
@@ -1595,6 +1602,10 @@ int FindFaceContainingNode(
15951602
int ixCurrentTargetFace = queueTargetFaces.front();
15961603
queueTargetFaces.pop();
15971604

1605+
if (ixCurrentTargetFace == InvalidFace) {
1606+
continue;
1607+
}
1608+
15981609
const Face & faceTarget = meshTarget.faces[ixCurrentTargetFace];
15991610

16001611
utils.ContainsNode(
@@ -1658,7 +1669,8 @@ int FindFaceContainingNode(
16581669
}
16591670
}
16601671

1661-
_EXCEPTIONT("Unable to find Target Face");
1672+
return InvalidFace;
1673+
//_EXCEPTIONT("Unable to find Target Face");
16621674
}
16631675

16641676
///////////////////////////////////////////////////////////////////////////////
@@ -1705,13 +1717,19 @@ void GenerateOverlapMeshFromFace(
17051717
_EXCEPTIONT("No target face found");
17061718
}
17071719
*/
1720+
17081721
int ixCurrentTargetFace =
17091722
FindFaceContainingNode<MeshUtilitiesFuzzy, Node>(
17101723
meshSource,
17111724
meshTarget,
17121725
ixSourceFace,
17131726
ixTargetFaceSeed);
17141727

1728+
if (ixCurrentTargetFace == InvalidFace) {
1729+
std::cout << "\tNo overlapping face found" << std::endl;
1730+
return;
1731+
}
1732+
17151733
std::cout << "\tFirst overlap match " << ixCurrentTargetFace << std::endl;
17161734
/*
17171735
// Verify starting Node is not on the Exterior
@@ -1743,6 +1761,9 @@ void GenerateOverlapMeshFromFace(
17431761
ixCurrentTargetFace = queueTargetFaces.front();
17441762
queueTargetFaces.pop();
17451763

1764+
if (ixCurrentTargetFace == InvalidFace) {
1765+
_EXCEPTIONT("Logic error");
1766+
}
17461767
const Face & faceTarget = meshTarget.faces[ixCurrentTargetFace];
17471768

17481769
// Find the overlap polygon
@@ -1785,6 +1806,10 @@ void GenerateOverlapMeshFromFace(
17851806
_EXCEPTIONT("EdgeMap error");
17861807
}
17871808

1809+
if (iPushFace == InvalidFace) {
1810+
continue;
1811+
}
1812+
17881813
std::set<int>::const_iterator iterFace =
17891814
setExaminedTargetFaces.find(iPushFace);
17901815

@@ -1906,7 +1931,6 @@ void GenerateOverlapMesh_v2(
19061931
// Calculate Face areas
19071932
double dTotalAreaOverlap = meshOverlap.CalculateFaceAreas();
19081933
Announce("Overlap Mesh Geometric Area: %1.15e (%1.15e)", dTotalAreaOverlap, 4.0 * M_PI);
1909-
19101934
}
19111935

19121936
///////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)