Skip to content
Snippets Groups Projects
Commit a1430b6e authored by Andrew Maclean's avatar Andrew Maclean
Browse files

BlankPoint was not showing the blanked point

parent 856f71b8
No related branches found
No related tags found
1 merge request!327Add pythonic api examples 1
......@@ -7,9 +7,9 @@
#include <vtkRenderWindowInteractor.h>
#include <vtkRenderer.h>
#include <vtkStructuredGrid.h>
#include <vtkStructuredGridGeometryFilter.h>
#include <iostream>
#include <string>
int main(int, char*[])
{
......@@ -22,6 +22,7 @@ int main(int, char*[])
unsigned int gridSize = 8;
unsigned int counter = 0;
unsigned int ptIdx = 0;
// Create a 5x5 grid of points
for (unsigned int j = 0; j < gridSize; j++)
{
......@@ -31,6 +32,7 @@ int main(int, char*[])
{
points->InsertNextPoint(i, j, 2);
std::cout << "The different point is number " << counter << std::endl;
ptIdx = counter;
}
else
{
......@@ -41,12 +43,10 @@ int main(int, char*[])
}
}
// Specify the dimensions of the grid
// Specify the dimensions of the grid, set the points and blank one point.
structuredGrid->SetDimensions(gridSize, gridSize, 1);
structuredGrid->SetPoints(points);
structuredGrid->BlankPoint(27);
structuredGrid->BlankPoint(ptIdx);
structuredGrid->Modified();
// Check.
......@@ -62,20 +62,27 @@ int main(int, char*[])
};
// Should not be visible.
isVisible(27);
isVisible(ptIdx);
// Should be visible.
isVisible(7);
// Create a mapper and actor
// We need the geometry filter to ensure that the
// blanked point and surrounding faces is missing.
vtkNew<vtkStructuredGridGeometryFilter>geometryFilter;
geometryFilter->SetInputData(structuredGrid);
// Create a mapper and actor.
vtkNew<vtkDataSetMapper> gridMapper;
gridMapper->SetInputData(structuredGrid);
// gridMapper->SetInputData(structuredGrid);
gridMapper->SetInputConnection(geometryFilter->GetOutputPort());
vtkNew<vtkActor> gridActor;
gridActor->SetMapper(gridMapper);
gridActor->GetProperty()->EdgeVisibilityOn();
gridActor->GetProperty()->SetEdgeColor(colors->GetColor3d("Blue").GetData());
// Create a renderer, render window, and interactor
// Create a renderer, render window, and interactor.
vtkNew<vtkRenderer> renderer;
vtkNew<vtkRenderWindow> renderWindow;
renderWindow->AddRenderer(renderer);
......@@ -84,11 +91,11 @@ int main(int, char*[])
vtkNew<vtkRenderWindowInteractor> renderWindowInteractor;
renderWindowInteractor->SetRenderWindow(renderWindow);
// Add the actor to the scene
// Add the actor to the scene.
renderer->AddActor(gridActor);
renderer->SetBackground(colors->GetColor3d("ForestGreen").GetData());
// Render and interact
// Render and interact.
renderWindow->Render();
renderWindowInteractor->Start();
......
......@@ -7,6 +7,7 @@ import vtkmodules.vtkRenderingOpenGL2
from vtkmodules.vtkCommonColor import vtkNamedColors
from vtkmodules.vtkCommonCore import vtkPoints
from vtkmodules.vtkCommonDataModel import vtkStructuredGrid
from vtkmodules.vtkFiltersGeometry import vtkStructuredGridGeometryFilter
from vtkmodules.vtkRenderingCore import (
vtkActor,
vtkDataSetMapper,
......@@ -19,46 +20,49 @@ from vtkmodules.vtkRenderingCore import (
def main():
colors = vtkNamedColors()
structured_grid = vtkStructuredGrid()
points = vtkPoints()
grid_size = 8
counter = 0
pt_idx = 0
# Create a 5x5 grid of points
for j in range(0, grid_size):
for i in range(0, grid_size):
if i == 3 and j == 3: # Make one point higher than the rest.
points.InsertNextPoint(i, j, 2)
print('The different point is number ', counter)
print(f'The different point is number {counter}.')
pt_idx = counter
else:
# Make most of the points the same height.
points.InsertNextPoint(i, j, 0)
counter += 1
# Specify the dimensions of the grid.
structured_grid = vtkStructuredGrid()
# Specify the dimensions of the grid, set the points and blank one point.
structured_grid.SetDimensions(grid_size, grid_size, 1)
structured_grid.SetPoints(points)
structured_grid.BlankPoint(27)
structured_grid.Modified()
structured_grid.BlankPoint(pt_idx)
# Check.
def is_visible(pt_num):
if structured_grid.IsPointVisible(pt_num):
return f'Point {pt_num} is visible.'
return f'Point {pt_num:2d} is visible.'
else:
return f'Point {pt_num} is not visible.'
return f'Point {pt_num:2d} is not visible.'
# Should not be visible.
print(is_visible(27))
print(is_visible(pt_idx))
# Should be visible.
print(is_visible(7))
# We need the geometry filter to ensure that the
# blanked point and surrounding faces is missing.
geometry_filter = vtkStructuredGridGeometryFilter()
geometry_filter.SetInputData(structured_grid)
# Create a mapper and actor.
grid_mapper = vtkDataSetMapper()
grid_mapper.SetInputData(structured_grid)
grid_mapper.SetInputConnection(geometry_filter.GetOutputPort())
grid_actor = vtkActor()
grid_actor.SetMapper(grid_mapper)
......
src/Testing/Baseline/Cxx/StructuredGrid/TestBlankPoint.png

129 B | W: | H:

src/Testing/Baseline/Cxx/StructuredGrid/TestBlankPoint.png

129 B | W: | H:

src/Testing/Baseline/Cxx/StructuredGrid/TestBlankPoint.png
src/Testing/Baseline/Cxx/StructuredGrid/TestBlankPoint.png
src/Testing/Baseline/Cxx/StructuredGrid/TestBlankPoint.png
src/Testing/Baseline/Cxx/StructuredGrid/TestBlankPoint.png
  • 2-up
  • Swipe
  • Onion skin
src/Testing/Baseline/Python/StructuredGrid/TestBlankPoint.png

129 B | W: | H:

src/Testing/Baseline/Python/StructuredGrid/TestBlankPoint.png

129 B | W: | H:

src/Testing/Baseline/Python/StructuredGrid/TestBlankPoint.png
src/Testing/Baseline/Python/StructuredGrid/TestBlankPoint.png
src/Testing/Baseline/Python/StructuredGrid/TestBlankPoint.png
src/Testing/Baseline/Python/StructuredGrid/TestBlankPoint.png
  • 2-up
  • Swipe
  • Onion skin
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