Skip to content
Snippets Groups Projects
Commit b1f67872 authored by David Thompson's avatar David Thompson
Browse files

Fix the vertex cell-grid source.

+ The shape function must have a function space named "constant".
+ Also, the "point" array-group is renamed "points" to match the
  group name for the point coordinates so that HGRAD values are
  shown in the array editor.
+ Finally, the centers of all sides (not just the edges) are
  glyphed when rendering glyphs to better illustrate the vector fields
  in the CellGridSource application.
+ Make Ctrl+Q a shortcut to quit the example CellGridSource app.
parent 2826dd74
No related branches found
No related tags found
No related merge requests found
......@@ -29,6 +29,7 @@
#include <QMainWindow>
#include <QPointer>
#include <QPushButton>
#include <QShortcut>
#include <QTableView>
#include <QVBoxLayout>
......@@ -209,12 +210,16 @@ int main(int argc, char* argv[])
bdyActor->GetProperty()->SetRepresentationToSurface();
bdyActor->SetVisibility(false); // Turn off initially.
vtkNew<vtkCellGridComputeSides> centerSides;
vtkNew<vtkCellGridCellCenters> centers;
vtkNew<vtkCellGridToUnstructuredGrid> ugridCvt;
vtkNew<vtkGlyph3DMapper> glyMapper;
vtkNew<vtkArrowSource> arrow;
vtkNew<vtkActor> glyActor;
centers->SetInputConnection(cellEdges->GetOutputPort());
centerSides->SetInputDataObject(0, cellSource->GetOutput());
centerSides->SetOutputDimensionControl(vtkCellGridSidesQuery::SideFlags::AllSides);
centerSides->OmitSidesForRenderableInputsOff();
centers->SetInputConnection(centerSides->GetOutputPort());
ugridCvt->SetInputConnection(centers->GetOutputPort());
glyMapper->SetInputConnection(ugridCvt->GetOutputPort());
glyMapper->OrientOn();
......@@ -237,7 +242,12 @@ int main(int argc, char* argv[])
// Re-render upon each user edit of a cell-grid data-array:
QObject::connect(&model, &ArrayGroupModel::dataChanged,
[&vtkRenderWidget]() { vtkRenderWidget->renderWindow()->Render(); });
[&vtkRenderWidget, &cellEdges, &centerSides]()
{
cellEdges->Modified();
centerSides->Modified();
vtkRenderWidget->renderWindow()->Render();
});
QObject::connect(&bdyBtn, &QCheckBox::toggled,
[&](bool enabled)
......@@ -277,6 +287,8 @@ int main(int argc, char* argv[])
updateGlyphSources(cellSource, &glySelector);
updateArrayGroups(model, cellSource, &arrayGroupSelector, false);
QShortcut exitKey(QKeySequence("Ctrl+Q"), &mainWindow);
QObject::connect(&exitKey, &QShortcut::activated, [&]() { app.exit(); });
mainWindow.show();
return app.exec();
......
......@@ -107,11 +107,22 @@ bool vtkDGCellSourceResponder::Query(
grid->SetShapeAttribute(shape);
// clang-format off
this->CreateCellAttribute(
dgCell, cellTypeToken,
"hgrad", "ℝ³", 3,
"HGRAD"_token, "C"_token, 1,
dgCell->GetNumberOfSidesOfDimension(0) * 3, 1, "point"_token);
if (cellTypeToken == "vtkDGVert"_token)
{
this->CreateCellAttribute(
dgCell, cellTypeToken,
"constant", "ℝ³", 3,
"constant"_token, "C"_token, 0,
3, 1, "points"_token);
}
else
{
this->CreateCellAttribute(
dgCell, cellTypeToken,
"hgrad", "ℝ³", 3,
"HGRAD"_token, "C"_token, 1,
dgCell->GetNumberOfSidesOfDimension(0) * 3, 1, "points"_token);
}
// clang-format on
if (dgCell->IsA("vtkDeRhamCell"))
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment