Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 34 additions & 2 deletions src/core/SmootherTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,8 +565,40 @@ Coordinates SmootherTools::collapsePointsOnContour(
}

if (!validContourIds.empty()) {
for (auto const& interiorId : cG.getInterior()) {
res[interiorId] = coords[*validContourIds.begin()];
const IdSet interior = cG.getInterior();
bool collapseToMinExterior = false;
if (interior.size() > 1 && validContourIds.size() == 2) {
const CoordinateId minExt = *validContourIds.begin();
const CoordinateId maxExt = *validContourIds.rbegin();
// Preserve the established behavior for a contour run that
// extends toward both anchors: collapse the run as a unit.
for (const auto interiorId : interior) {
if ((coords[interiorId] - coords[maxExt]).norm()
< (coords[interiorId] - coords[minExt]).norm()) {
collapseToMinExterior = true;
break;
}
}
}

if (collapseToMinExterior) {
const CoordinateId anchor = *validContourIds.begin();
for (const auto interiorId : interior) {
res[interiorId] = coords[anchor];
}
}
else {
for (const auto interiorId : interior) {
if (res[interiorId] != coords[interiorId]) {
continue;
}
const IdSet targets =
cG.getClosestVerticesInSet(interiorId, validContourIds);
if (targets.empty()) {
continue;
}
res[interiorId] = coords[*targets.begin()];
}
}
}

Expand Down
9 changes: 9 additions & 0 deletions test/app/launcherTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,15 @@ TEST_F(LauncherTest, launches_conformal_sphere_case)
EXPECT_EQ(exitCode, EXIT_SUCCESS);
}

TEST_F(LauncherTest, launches_conformal_smallSphere_case)
{
int ac = 3;
const char* av[] = { NULL, "-i", "testData/cases/smallSphere/smallSphere.conformal.tessellator.json"};
int exitCode;
EXPECT_NO_THROW(exitCode = launcher(ac, av));
EXPECT_EQ(exitCode, EXIT_SUCCESS);
}

TEST_F(LauncherTest, launches_conformal_thinCylinder_case)
{
int ac = 3;
Expand Down
52 changes: 52 additions & 0 deletions test/core/SmootherToolsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,43 @@ class SmootherToolsTest : public ::testing::Test {
return res;
}

static Mesh buildCollapseEdgeMeshWithInnerDent()
{
// 7-------------6
// | _-'/|
// | _-' / |
// | _-' / |
// | _-' / |
// 4---3----------5
// | __--
// 2-' --__
// 0----------1
Mesh res;
res.grid = utils::GridTools::buildCartesianGrid(0.0, 1.0, 2);
res.coordinates = {
Coordinate({0.00, 0.00, 1.00}), // 0
Coordinate({0.60, 0.00, 1.00}), // 1
Coordinate({0.00, 0.10, 1.00}), // 2
Coordinate({0.20, 0.40, 1.00}), // 3
Coordinate({0.00, 0.40, 1.00}), // 4
Coordinate({1.00, 0.40, 1.00}), // 5
Coordinate({1.00, 1.00, 1.00}), // 6
Coordinate({0.00, 1.00, 1.00}), // 7
};

res.groups.push_back(Group());
res.groups[0].elements = {
Element({0, 1, 2}, Element::Type::Surface),
Element({1, 3, 2}, Element::Type::Surface),
Element({2, 3, 4}, Element::Type::Surface),
Element({3, 5, 6}, Element::Type::Surface),
Element({3, 6, 4}, Element::Type::Surface),
Element({4, 6, 7}, Element::Type::Surface),
};

return res;
}

static Mesh buildElementsToRemesh()
{
// 4 ---- 5
Expand Down Expand Up @@ -649,6 +686,21 @@ TEST_F(SmootherToolsTest, collapse_two_points_in_contour)
EXPECT_EQ(collapsed[6], collapsed[7]);
}

TEST_F(SmootherToolsTest, collapsePointsInContourWithInnerDent)
{
Mesh mesh = buildCollapseEdgeMeshWithInnerDent();
const Elements& elements = mesh.groups[0].elements;

const Coordinates collapsed = SmootherTools(mesh.grid).collapsePointsOnContour(
elements, mesh.coordinates, alignmentAngle);

EXPECT_EQ(8, countDifferentCoordinates(mesh.coordinates));
ASSERT_EQ(6, countDifferentCoordinates(collapsed));
EXPECT_NE(collapsed[2], collapsed[4]);
EXPECT_EQ(collapsed[2], collapsed[0]);
EXPECT_EQ(collapsed[4], collapsed[7]);
}

/// Build the list of singular Ids corresponding to a corner structure with the following ids
/// \verbatim
/// 2 ----- 6
Expand Down
17 changes: 17 additions & 0 deletions testData/cases/smallSphere/smallSphere.conformal.tessellator.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"grid": {
"numberOfCells": [5, 5, 5],
"boundingBox": [
[-3.0, -3.0, -3.0],
[ 2.0, 2.0, 2.0]
]
},
"object": {"filename": "smallSphere.stl"},
"mesher": {
"type": "conformal",
"options": {
"edgePoints": 4,
"forbiddenLength": 0.0
}
}
}
Binary file added testData/cases/smallSphere/smallSphere.stl
Binary file not shown.
Loading