Skip to content

Fix optimizer hack to detect contour types #2457

@akenmorris

Description

@akenmorris
// TODO This is a HACK for detecting contours
if (poly_data->GetCell(0)->GetNumberOfPoints() == 2) {
  optimize->AddContour(poly_data);
} else {
  optimize->AddMesh(poly_data);
}

This hack needs to be removed/replaced. Loading the attached mesh, if grooming is skipped causes it to be detected as a contour instead of a mesh.

In fact, I can't even remesh it to fix it due to a similar check in Groom.cpp

if (params.get_remesh()) {
  auto poly_data = mesh.getVTKMesh();
  if (poly_data->GetNumberOfCells() == 0 || poly_data->GetCell(0)->GetNumberOfPoints() == 2) {
    SW_DEBUG("Number of cells: {}", poly_data->GetNumberOfCells());
    SW_DEBUG("Number of points in first cell: {}", poly_data->GetCell(0)->GetNumberOfPoints());
    // write out to /tmp
    std::string tmpname = "/tmp/bad_mesh.vtk";
    MeshUtils::threadSafeWriteMesh(tmpname, mesh);
    throw std::runtime_error("malformed mesh, mesh should be triangular");
  }

mesh_mistaken_contour.vtk.zip

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions