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

Adding/Fixing ClipUnstructuredGrid

parent b9aa5483
No related branches found
No related tags found
1 merge request!349Classes in python not in pythonic api 07
Showing
with 397 additions and 53 deletions
......@@ -70,7 +70,7 @@ int main(int argc, char* argv[])
insideActor->SetMapper(insideMapper);
insideActor->GetProperty()->SetDiffuseColor(
colors->GetColor3d("Banana").GetData());
insideActor->GetProperty()->SetAmbient(.3);
insideActor->GetProperty()->SetAmbient(0.3);
insideActor->GetProperty()->EdgeVisibilityOn();
vtkNew<vtkDataSetMapper> clippedMapper;
......@@ -81,7 +81,7 @@ int main(int argc, char* argv[])
clippedActor->SetMapper(clippedMapper);
clippedActor->GetProperty()->SetDiffuseColor(
colors->GetColor3d("Tomato").GetData());
insideActor->GetProperty()->SetAmbient(.3);
insideActor->GetProperty()->SetAmbient(0.3);
clippedActor->GetProperty()->EdgeVisibilityOn();
// Create transforms to make a better visualization
......
......@@ -7,21 +7,23 @@ Note that unlike other clipping filters (except for vtkClipPolyData), vtkTableBa
After exiting, the example reports the number of each cell type for each output:
``` text
The inside dataset contains a
vtkUnstructuredGrid that has 26116 cells
------------------------
The inside dataset contains a
vtkUnstructuredGrid that has 26116 cells
Cell type vtkTetra occurs 3751 times.
Cell type vtkHexahedron occurs 17361 times.
Cell type vtkWedge occurs 628 times.
Cell type vtkPyramid occurs 4376 times.
------------------------
The clipped dataset contains a
vtkUnstructuredGrid that has 25655 cells
vtkUnstructuredGrid that has 25655 cells
Cell type vtkTetra occurs 3715 times.
Cell type vtkHexahedron occurs 16984 times.
Cell type vtkWedge occurs 616 times.
Cell type vtkPyramid occurs 4340 times.
```
Compare these results with [ClipUnstructuredGridWithPlane2 (C++)](../ClipUnstructuredGridWithPlane2), [ClipUnstructuredGridWithPlane2 (Python)](../../../Python/UnstructuredGrid/ClipUnstructuredGridWithPlane2). Also, the resulting vtkUnstructuredGrid's has 1/4 the number of cells.
Compare these results with [ClipUnstructuredGridWithPlane2](../ClipUnstructuredGridWithPlane2). Also, the resulting vtkUnstructuredGrid's has 1/4 the number of cells.
!!! example "usage"
ClipUnstructuredGridWithPlane treemesh.vtk
......
......@@ -69,8 +69,8 @@ int main(int argc, char* argv[])
vtkNew<vtkActor> insideActor;
insideActor->SetMapper(insideMapper);
insideActor->GetProperty()->SetDiffuseColor(
colors->GetColor3d("banana").GetData());
insideActor->GetProperty()->SetAmbient(.3);
colors->GetColor3d("Banana").GetData());
insideActor->GetProperty()->SetAmbient(0.3);
insideActor->GetProperty()->EdgeVisibilityOn();
vtkNew<vtkDataSetMapper> clippedMapper;
......@@ -80,8 +80,8 @@ int main(int argc, char* argv[])
vtkNew<vtkActor> clippedActor;
clippedActor->SetMapper(clippedMapper);
clippedActor->GetProperty()->SetDiffuseColor(
colors->GetColor3d("tomato").GetData());
insideActor->GetProperty()->SetAmbient(.3);
colors->GetColor3d("Tomato").GetData());
insideActor->GetProperty()->SetAmbient(0.3);
clippedActor->GetProperty()->EdgeVisibilityOn();
// Create transforms to make a better visualization
......@@ -95,7 +95,7 @@ int main(int argc, char* argv[])
vtkNew<vtkTransform> clippedTransform;
clippedTransform->Translate((bounds[1] - bounds[0]) * .75, 0, 0);
clippedTransform->Translate(center[0], center[1], center[2]);
clippedTransform->RotateY(60.0);
clippedTransform->RotateY(-120.0);
clippedTransform->Translate(-center[0], -center[1], -center[2]);
clippedActor->SetUserTransform(clippedTransform);
......
......@@ -7,17 +7,19 @@ Note that this clipping filter does not retain the original cells if they are no
After exiting, the example reports the number of each cell type for each output:
``` text
The inside dataset contains a
vtkUnstructuredGrid that has 110148 cells
Cell type vtkTetra occurs 106998 times.
Cell type vtkWedge occurs 3150 times.
The clipped dataset contains a
vtkUnstructuredGrid that has 111824 cells
Cell type vtkTetra occurs 107420 times.
Cell type vtkWedge occurs 4404 times.
------------------------
The inside dataset contains a
vtkUnstructuredGrid that has 110084 cells
Cell type vtkTetra occurs 106934 times.
Cell type vtkWedge occurs 3150 times.
------------------------
The clipped dataset contains a
vtkUnstructuredGrid that has 110084 cells
Cell type vtkTetra occurs 106934 times.
Cell type vtkWedge occurs 3150 times.
```
Compare these results with [ClipUnstructuredGridWithPlane (C++)](../ClipUnstructuredGridWithPlane) [ClipUnstructuredGridWithPlane (Python)](../../../Python/UnstructuredGrid/ClipUnstructuredGridWithPlane). Notice that in this example, the original vtkHexahedron in the unclipped regions are converted to vtkTetra. Also, the resulting vtkUnstructuredGrid's have more than 4 times the number of cells.
Compare these results with [ClipUnstructuredGridWithPlane](../ClipUnstructuredGridWithPlane). Notice that in this example, the original vtkHexahedron in the unclipped regions are converted to vtkTetra. Also, the resulting vtkUnstructuredGrid's have more than 4 times the number of cells.
!!! example "usage"
ClipUnstructuredGridWithPlane2 treemesh.vtk
......
......@@ -7,21 +7,23 @@ Note that unlike other clipping filters (except for vtkClipPolyData), vtkTableBa
After exiting, the example reports the number of each cell type for each output:
``` text
The inside dataset contains a
vtkUnstructuredGrid that has 26116 cells
------------------------
The inside dataset contains a
vtkUnstructuredGrid that has 26116 cells
Cell type vtkTetra occurs 3751 times.
Cell type vtkHexahedron occurs 17361 times.
Cell type vtkWedge occurs 628 times.
Cell type vtkPyramid occurs 4376 times.
------------------------
The clipped dataset contains a
vtkUnstructuredGrid that has 25655 cells
vtkUnstructuredGrid that has 25655 cells
Cell type vtkTetra occurs 3715 times.
Cell type vtkHexahedron occurs 16984 times.
Cell type vtkWedge occurs 616 times.
Cell type vtkPyramid occurs 4340 times.
```
Compare these results with [ClipUnstructuredGridWithPlane2 (C++)](../../../Cxx/UnstructuredGrid/ClipUnstructuredGridWithPlane2), [ClipUnstructuredGridWithPlane2 (Python)](../ClipUnstructuredGridWithPlane2). Also, the resulting vtkUnstructuredGrid's has 1/4 the number of cells.
Compare these results with [ClipUnstructuredGridWithPlane2](../UnstructuredGrid/ClipUnstructuredGridWithPlane2). ClipUnstructuredGridWithPlane2). Also, the resulting vtkUnstructuredGrid's has 1/4 the number of cells.
!!! example "usage"
ClipUnstructuredGridWithPlane treemesh.vtk
......
......@@ -83,8 +83,8 @@ def main():
insideActor = vtkActor()
insideActor.SetMapper(insideMapper)
insideActor.GetProperty().SetDiffuseColor(colors.GetColor3d('banana'))
insideActor.GetProperty().SetAmbient(.3)
insideActor.GetProperty().SetDiffuseColor(colors.GetColor3d('Banana'))
insideActor.GetProperty().SetAmbient(0.3)
insideActor.GetProperty().EdgeVisibilityOn()
clippedMapper = vtkDataSetMapper()
......@@ -93,8 +93,8 @@ def main():
clippedActor = vtkActor()
clippedActor.SetMapper(clippedMapper)
clippedActor.GetProperty().SetDiffuseColor(colors.GetColor3d('tomato'))
insideActor.GetProperty().SetAmbient(.3)
clippedActor.GetProperty().SetDiffuseColor(colors.GetColor3d('Tomato'))
insideActor.GetProperty().SetAmbient(0.3)
clippedActor.GetProperty().EdgeVisibilityOn()
# Create transforms to make a better visualization
......
......@@ -7,17 +7,19 @@ Note that this clipping filter does not retain the original cells if they are no
After exiting, the example reports the number of each cell type for each output:
``` text
The inside dataset contains a
vtkUnstructuredGrid that has 110148 cells
Cell type vtkTetra occurs 106998 times.
Cell type vtkWedge occurs 3150 times.
The clipped dataset contains a
vtkUnstructuredGrid that has 111824 cells
Cell type vtkTetra occurs 107420 times.
Cell type vtkWedge occurs 4404 times.
------------------------
The inside dataset contains a
vtkUnstructuredGrid that has 110084 cells
Cell type vtkTetra occurs 106934 times.
Cell type vtkWedge occurs 3150 times.
------------------------
The clipped dataset contains a
vtkUnstructuredGrid that has 110084 cells
Cell type vtkTetra occurs 106934 times.
Cell type vtkWedge occurs 3150 times.
```
Compare these results with [ClipUnstructuredGridWithPlane2 (C++)](../../../Cxx/UnstructuredGrid/ClipUnstructuredGridWithPlane), [ClipUnstructuredGridWithPlane2 (Python)](../ClipUnstructuredGridWithPlane). Notice that in this example, the original vtkHexahedron in the unclipped regions are converted to vtkTetra. Also, the resulting vtkUnstructuredGrid's have more than 4 times the number of cells.
Compare these results with [ClipUnstructuredGridWithPlane](../ClipUnstructuredGridWithPlane). Notice that in this example, the original vtkHexahedron in the unclipped regions are converted to vtkTetra. Also, the resulting vtkUnstructuredGrid's have more than 4 times the number of cells.
!!! example "usage"
ClipUnstructuredGridWithPlane2 treemesh.vtk
......
......@@ -82,8 +82,8 @@ def main():
insideActor = vtkActor()
insideActor.SetMapper(insideMapper)
insideActor.GetProperty().SetDiffuseColor(colors.GetColor3d('banana'))
insideActor.GetProperty().SetAmbient(.3)
insideActor.GetProperty().SetDiffuseColor(colors.GetColor3d('Banana'))
insideActor.GetProperty().SetAmbient(0.3)
insideActor.GetProperty().EdgeVisibilityOn()
clippedMapper = vtkDataSetMapper()
......@@ -93,7 +93,7 @@ def main():
clippedActor = vtkActor()
clippedActor.SetMapper(clippedMapper)
clippedActor.GetProperty().SetDiffuseColor(colors.GetColor3d('tomato'))
insideActor.GetProperty().SetAmbient(.3)
insideActor.GetProperty().SetAmbient(0.3)
clippedActor.GetProperty().EdgeVisibilityOn()
# Create transforms to make a better visualization
......@@ -107,7 +107,7 @@ def main():
clippedTransform = vtkTransform()
clippedTransform.Translate((bounds[1] - bounds[0]) * 0.75, 0, 0)
clippedTransform.Translate(center[0], center[1], center[2])
clippedTransform.RotateY(60.0)
clippedTransform.RotateY(-120.0)
clippedTransform.Translate(-center[0], -center[1], -center[2])
clippedActor.SetUserTransform(clippedTransform)
......
......@@ -245,6 +245,11 @@ This section includes ?vtkUnstructuredGrid?.
#### ?vtkUnstructuredGrid?
| Example Name | Description | Image |
| -------------- | ------------- | ------- |
[ClipUnstructuredGridWithPlane](/PythonicAPI/UnstructuredGrid/ClipUnstructuredGridWithPlane) | Clip a UGrid with a plane.
[ClipUnstructuredGridWithPlane2](/PythonicAPI/UnstructuredGrid/ClipUnstructuredGridWithPlane2) | Clip a UGrid with a plane.
### Registration
### Medical
......
### Description
The example uses vtkTableBasedClipDataSet to clip a vtkUnstructuredGrid. The resulting output and clipped output are presented in yellow and red respectively. To illustrate the clipped interfaces, the example uses a vtkTransform to rotate each output about their centers.
Note that unlike other clipping filters (except for vtkClipPolyData), vtkTableBasedClipDataSet retains the original cells if they are not clipped.
After exiting, the example reports the number of each cell type for each output:
``` text
------------------------
The inside dataset contains a vtkUnstructuredGrid that has 26116 cells
Cell type vtkTetra occurs 3751 times.
Cell type vtkHexahedron occurs 17361 times.
Cell type vtkWedge occurs 628 times.
Cell type vtkPyramid occurs 4376 times.
------------------------
The clipped dataset contains a vtkUnstructuredGrid that has 25655 cells
Cell type vtkTetra occurs 3715 times.
Cell type vtkHexahedron occurs 16984 times.
Cell type vtkWedge occurs 616 times.
Cell type vtkPyramid occurs 4340 times.
```
Compare these results with [ClipUnstructuredGridWithPlane2](../ClipUnstructuredGridWithPlane2). Also, the resulting vtkUnstructuredGrid's has 1/4 the number of cells.
!!! example "usage"
ClipUnstructuredGridWithPlane treemesh.vtk
!!! info "thanks"
Thanks to Bane Sullivan for sharing the treemesh.vtk unstructured grid dataset.
\ No newline at end of file
#!/usr/bin/env python3
import collections
# noinspection PyUnresolvedReferences
import vtkmodules.vtkInteractionStyle
# noinspection PyUnresolvedReferences
import vtkmodules.vtkRenderingOpenGL2
from vtkmodules.vtkCommonColor import vtkNamedColors
from vtkmodules.vtkCommonDataModel import (
vtkCellTypes,
vtkPlane
)
from vtkmodules.vtkCommonTransforms import vtkTransform
from vtkmodules.vtkFiltersGeneral import vtkTableBasedClipDataSet
from vtkmodules.vtkIOLegacy import vtkUnstructuredGridReader
from vtkmodules.vtkRenderingCore import (
vtkActor,
vtkDataSetMapper,
vtkRenderWindow,
vtkRenderWindowInteractor,
vtkRenderer
)
def get_program_parameters():
import argparse
description = 'Use a vtkTableBasedClipDataSet to clip a vtkUnstructuredGrid.'
epilogue = '''
Use a vtkTableBasedClipDataSet to clip a vtkUnstructuredGrid.
The resulting output and clipped output are presented in yellow and red respectively.
To illustrate the clipped interfaces, the example uses a vtkTransform to rotate each
output about their centers.
Note: This clipping filter does retain the original cells if they are not clipped.
'''
parser = argparse.ArgumentParser(description=description, epilog=epilogue,
formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument('filename', help='treemesh.vtk')
args = parser.parse_args()
return args.filename
def main():
filename = get_program_parameters()
# Create the reader for the data.
reader = vtkUnstructuredGridReader(file_name=filename)
reader.update()
bounds = reader.output.bounds
center = reader.output.center
colors = vtkNamedColors()
renderer = vtkRenderer(background=colors.GetColor3d('Wheat'))
renderer.UseHiddenLineRemovalOn()
render_window = vtkRenderWindow(size=(640, 480), window_name='ClipUnstructuredGridWithPlane')
render_window.AddRenderer(renderer)
interactor = vtkRenderWindowInteractor()
interactor.render_window = render_window
x_norm = [-1.0, -1.0, 1.0]
clip_plane = vtkPlane(origin=center, normal=x_norm)
clipper = vtkTableBasedClipDataSet(clip_function=clip_plane, input_data=reader.output,
value=0.0, generate_clipped_output=True)
clipper.update()
inside_mapper = vtkDataSetMapper(scalar_visibility=False, input_data=clipper.output)
inside_actor = vtkActor(mapper=inside_mapper)
inside_actor.property.diffuse_color = colors.GetColor3d('Banana')
inside_actor.property.ambient = 0.3
inside_actor.property.edge_visibility = True
clipped_mapper = vtkDataSetMapper(scalar_visibility=False, input_data=clipper.clipped_output)
clipped_actor = vtkActor(mapper=clipped_mapper)
clipped_actor.property.diffuse_color = colors.GetColor3d('Tomato')
clipped_actor.property.ambient = 0.3
clipped_actor.property.edge_visibility = True
# Create transforms to make a better visualization
# Reverse the sign of each element in center.
rev_center = tuple(-i for i in center)
inside_transform = vtkTransform()
inside_transform.Translate(-(bounds[1] - bounds[0]) * 0.75, 0, 0)
inside_transform.Translate(*center)
inside_transform.RotateY(-120.0)
inside_transform.Translate(*rev_center)
inside_actor.user_transform = inside_transform
clipped_transform = vtkTransform()
clipped_transform.Translate((bounds[1] - bounds[0]) * 0.75, 0, 0)
clipped_transform.Translate(*center)
clipped_transform.RotateY(60.0)
clipped_transform.Translate(*rev_center)
clipped_actor.user_transform = clipped_transform
renderer.AddViewProp(clipped_actor)
renderer.AddViewProp(inside_actor)
renderer.ResetCamera()
renderer.GetActiveCamera().Dolly(1.4)
renderer.ResetCameraClippingRange()
render_window.Render()
interactor.Start()
# Generate a report.
number_of_cells = clipper.GetOutput().GetNumberOfCells()
print('------------------------')
print(f'The inside dataset contains a {clipper.output.class_name} that has {number_of_cells} cells')
cell_map = dict()
for i in range(0, number_of_cells):
cell_map.setdefault(clipper.output.GetCellType(i), 0)
cell_map[clipper.output.GetCellType(i)] += 1
# Sort by key and put into an OrderedDict.
# An OrderedDict remembers the order in which the keys have been inserted.
for k, v in collections.OrderedDict(sorted(cell_map.items())).items():
print(f' Cell type {vtkCellTypes.GetClassNameFromTypeId(k)} occurs {v} times.')
number_of_cells = clipper.GetClippedOutput().GetNumberOfCells()
print('------------------------')
print(f'The clipped dataset contains a {clipper.output.class_name} that has {number_of_cells} cells')
outside_cell_map = dict()
for i in range(0, number_of_cells):
outside_cell_map.setdefault(clipper.GetClippedOutput().GetCellType(i), 0)
outside_cell_map[clipper.GetClippedOutput().GetCellType(i)] += 1
for k, v in collections.OrderedDict(sorted(outside_cell_map.items())).items():
print(f' Cell type {vtkCellTypes.GetClassNameFromTypeId(k)} occurs {v} times.')
if __name__ == '__main__':
main()
### Description
The example uses vtkClipDataSet to clip a vtkUnstructuredGrid. The resulting output and clipped output are presented in yellow and red respectively. To illustrate the clipped interfaces, the example uses a vtkTransform to rotate each output about their centers.
Note that this clipping filter does not retain the original cells if they are not clipped.
After exiting, the example reports the number of each cell type for each output:
``` text
------------------------
The inside dataset contains a vtkUnstructuredGrid that has 110084 cells
Cell type vtkTetra occurs 106934 times.
Cell type vtkWedge occurs 3150 times.
------------------------
The clipped dataset contains a vtkUnstructuredGrid that has 110084 cells
Cell type vtkTetra occurs 106934 times.
Cell type vtkWedge occurs 3150 times.
```
Compare these results with [ClipUnstructuredGridWithPlane](../ClipUnstructuredGridWithPlane). Notice that in this example, the original vtkHexahedron in the unclipped regions are converted to vtkTetra. Also, the resulting vtkUnstructuredGrid's have more than 4 times the number of cells.
!!! example "usage"
ClipUnstructuredGridWithPlane2 treemesh.vtk
!!! info "thanks"
Thanks to Bane Sullivan for sharing the treemesh.vtk unstructured grid dataset.
\ No newline at end of file
#!/usr/bin/env python3
import collections
# noinspection PyUnresolvedReferences
import vtkmodules.vtkInteractionStyle
# noinspection PyUnresolvedReferences
import vtkmodules.vtkRenderingOpenGL2
from vtkmodules.vtkCommonColor import vtkNamedColors
from vtkmodules.vtkCommonDataModel import (
vtkCellTypes,
vtkPlane
)
from vtkmodules.vtkCommonTransforms import vtkTransform
from vtkmodules.vtkFiltersGeneral import vtkClipDataSet
from vtkmodules.vtkIOLegacy import vtkUnstructuredGridReader
from vtkmodules.vtkRenderingCore import (
vtkActor,
vtkDataSetMapper,
vtkRenderWindow,
vtkRenderWindowInteractor,
vtkRenderer
)
def get_program_parameters():
import argparse
description = 'Use a vtkClipDataSet to clip a vtkUnstructuredGrid..'
epilogue = '''
Use a vtkClipDataSet to clip a vtkUnstructuredGrid..
The resulting output and clipped output are presented in yellow and red respectively.
To illustrate the clipped interfaces, the example uses a vtkTransform to rotate each
output about their centers.
Note: This clipping filter does not retain the original cells if they are not clipped.
'''
parser = argparse.ArgumentParser(description=description, epilog=epilogue,
formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument('filename', help='treemesh.vtk')
args = parser.parse_args()
return args.filename
def main():
filename = get_program_parameters()
# Create the reader for the data.
reader = vtkUnstructuredGridReader(file_name=filename)
reader.update()
bounds = reader.output.bounds
center = reader.output.center
colors = vtkNamedColors()
renderer = vtkRenderer(background=colors.GetColor3d('Wheat'))
renderer.UseHiddenLineRemovalOn()
render_window = vtkRenderWindow(size=(640, 480), window_name='ClipUnstructuredGridWithPlane2')
render_window.AddRenderer(renderer)
interactor = vtkRenderWindowInteractor()
interactor.render_window = render_window
x_norm = [-1.0, -1.0, 1.0]
clip_plane = vtkPlane(origin=center, normal=x_norm)
clipper = vtkClipDataSet(clip_function=clip_plane, input_data=reader.output,
value=0.0, generate_clipped_output=True)
clipper.update()
inside_mapper = vtkDataSetMapper(scalar_visibility=False, input_data=clipper.output)
inside_actor = vtkActor(mapper=inside_mapper)
inside_actor.property.diffuse_color = colors.GetColor3d('Banana')
inside_actor.property.ambient = 0.3
inside_actor.property.edge_visibility = True
clipped_mapper = vtkDataSetMapper(scalar_visibility=False, input_data=clipper.clipped_output)
clipped_actor = vtkActor(mapper=clipped_mapper)
clipped_actor.property.diffuse_color = colors.GetColor3d('Tomato')
clipped_actor.property.ambient = 0.3
clipped_actor.property.edge_visibility = True
# Create transforms to make a better visualization
# Reverse the sign of each element in center.
rev_center = tuple(-i for i in center)
inside_transform = vtkTransform()
inside_transform.Translate(-(bounds[1] - bounds[0]) * 0.75, 0, 0)
inside_transform.Translate(*center)
inside_transform.RotateY(-120.0)
inside_transform.Translate(*rev_center)
inside_actor.user_transform = inside_transform
clipped_transform = vtkTransform()
clipped_transform.Translate((bounds[1] - bounds[0]) * 0.75, 0, 0)
clipped_transform.Translate(*center)
clipped_transform.RotateY(-120.0)
clipped_transform.Translate(*rev_center)
clipped_actor.user_transform = clipped_transform
renderer.AddViewProp(clipped_actor)
renderer.AddViewProp(inside_actor)
renderer.ResetCamera()
renderer.GetActiveCamera().Dolly(1.4)
renderer.ResetCameraClippingRange()
render_window.Render()
interactor.Start()
# Generate a report.
number_of_cells = clipper.GetOutput().GetNumberOfCells()
print('------------------------')
print(f'The inside dataset contains a {clipper.output.class_name} that has {number_of_cells} cells')
cell_map = dict()
for i in range(0, number_of_cells):
cell_map.setdefault(clipper.output.GetCellType(i), 0)
cell_map[clipper.output.GetCellType(i)] += 1
# Sort by key and put into an OrderedDict.
# An OrderedDict remembers the order in which the keys have been inserted.
for k, v in collections.OrderedDict(sorted(cell_map.items())).items():
print(f' Cell type {vtkCellTypes.GetClassNameFromTypeId(k)} occurs {v} times.')
number_of_cells = clipper.GetClippedOutput().GetNumberOfCells()
print('------------------------')
print(f'The clipped dataset contains a {clipper.output.class_name} that has {number_of_cells} cells')
outside_cell_map = dict()
for i in range(0, number_of_cells):
outside_cell_map.setdefault(clipper.GetClippedOutput().GetCellType(i), 0)
outside_cell_map[clipper.GetClippedOutput().GetCellType(i)] += 1
for k, v in collections.OrderedDict(sorted(outside_cell_map.items())).items():
print(f' Cell type {vtkCellTypes.GetClassNameFromTypeId(k)} occurs {v} times.')
if __name__ == '__main__':
main()
......@@ -51,14 +51,14 @@ def main():
reader = vtkStructuredGridReader(file_name=file_name)
# Force a read to occur.
reader.update()
# length = reader.output.length
if reader.output.point_data.scalars:
scalar_range = reader.output.point_data.scalars.GetRange()
if reader.output.point_data.vectors:
length = reader.output.length
max_velocity = reader.output.point_data.vectors.GetMaxNorm()
max_time = 4.0 * reader.GetOutput().GetLength() / max_velocity
max_time = 4.0 * length / max_velocity
# Outline around the data.
outline_filter = vtkStructuredGridOutlineFilter()
......@@ -128,7 +128,7 @@ def main():
sg_filter = get_shaded_surfaces(extent, reader, colors, 'Silver')
sg_filter.property.opacity = 0.75
# For fun, lets put a screen across the sg_filter
# For fun, lets put a screen across the sg_filter.
bounds = sg_filter.GetBounds()
origin = (bounds[0], bounds[2], bounds[4])
p1 = (bounds[1], bounds[2], bounds[4])
......@@ -139,7 +139,7 @@ def main():
sg_scr_src >> sg_scr_mapper
sg_screen = vtkActor(mapper=sg_scr_mapper)
sg_screen.property.representation = Property.Representation.VTK_WIREFRAME
sg_screen.property.color = colors.GetColor3d('LampBLack')
sg_screen.property.color = colors.GetColor3d('LampBlack')
sg_screen.property.line_width = 1
# Regular streamlines.
......@@ -195,10 +195,8 @@ def main():
ren.AddActor(lines)
ren.AddActor(rake)
ren.SetBackground(colors.GetColor3d('SlateGray'))
camera = vtkCamera()
ren.SetActiveCamera(camera)
ren.active_camera = camera
ren.ResetCamera()
camera.focal_point = (3.505, 2.505, 1.255)
......@@ -217,7 +215,7 @@ def main():
def get_shaded_surfaces(extent, reader, colors, color: str):
"""
Set up shaded surfaces (i.e., supporting geometry).
Set up shaded surfaces (the supporting geometry).
:param extent: The extent of the geometry.
:param reader: The data source.
......
src/Testing/Baseline/Cxx/UnstructuredGrid/TestClipUnstructuredGridWithPlane2.png

130 B | W: | H:

src/Testing/Baseline/Cxx/UnstructuredGrid/TestClipUnstructuredGridWithPlane2.png

131 B | W: | H:

src/Testing/Baseline/Cxx/UnstructuredGrid/TestClipUnstructuredGridWithPlane2.png
src/Testing/Baseline/Cxx/UnstructuredGrid/TestClipUnstructuredGridWithPlane2.png
src/Testing/Baseline/Cxx/UnstructuredGrid/TestClipUnstructuredGridWithPlane2.png
src/Testing/Baseline/Cxx/UnstructuredGrid/TestClipUnstructuredGridWithPlane2.png
  • 2-up
  • Swipe
  • Onion skin
src/Testing/Baseline/Python/UnstructuredGrid/TestClipUnstructuredGridWithPlane2.png

130 B | W: | H:

src/Testing/Baseline/Python/UnstructuredGrid/TestClipUnstructuredGridWithPlane2.png

131 B | W: | H:

src/Testing/Baseline/Python/UnstructuredGrid/TestClipUnstructuredGridWithPlane2.png
src/Testing/Baseline/Python/UnstructuredGrid/TestClipUnstructuredGridWithPlane2.png
src/Testing/Baseline/Python/UnstructuredGrid/TestClipUnstructuredGridWithPlane2.png
src/Testing/Baseline/Python/UnstructuredGrid/TestClipUnstructuredGridWithPlane2.png
  • 2-up
  • Swipe
  • Onion skin
src/Testing/Baseline/PythonicAPI/UnstructuredGrid/TestClipUnstructuredGridWithPlane.png

131 B

src/Testing/Baseline/PythonicAPI/UnstructuredGrid/TestClipUnstructuredGridWithPlane2.png

131 B

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