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

Adding ImplicitDataSet, ImplicitSelectionLoop

parent 43dedce6
No related branches found
No related tags found
1 merge request!391Removing some links in Cxx.md, adding ImageTranslateExtent
#include <vtkCamera.h>
#include <vtkClipPolyData.h>
#include <vtkImplicitSelectionLoop.h>
#include <vtkLODActor.h>
......@@ -72,19 +73,23 @@ int main(int, char*[])
clipActor->GetProperty()->SetColor(colors->GetColor3d("Banana").GetData());
vtkNew<vtkRenderer> renderer;
renderer->SetBackground(colors->GetColor3d("SlateGray").GetData());
vtkNew<vtkRenderWindow> renderWindow;
renderWindow->SetSize(500, 500);
renderWindow->SetWindowName("ImplicitSelectionLoop");
renderWindow->AddRenderer(renderer);
vtkNew<vtkRenderWindowInteractor> interactor;
interactor->SetRenderWindow(renderWindow);
// Add the actors to the renderer, set the background and size
renderer->AddActor(clipActor);
renderer->SetBackground(colors->GetColor3d("SlateGray").GetData());
renderWindow->SetSize(500, 500);
renderWindow->SetWindowName("ImplicitSelectionLoop");
// Get a good orientation.
renderer->ResetCamera();
renderer->GetActiveCamera()->Azimuth(22.5);
renderer->GetActiveCamera()->Elevation(10.0);
renderer->GetActiveCamera()->Zoom(1.5);
renderWindow->Render();
interactor->Start();
......
......@@ -176,6 +176,7 @@ This Python script, [SelectExamples](../PythonicAPI/Utilities/SelectExamples), w
[ExtractData](/PythonicAPI/VisualizationAlgorithms/ExtractData) | Implicit functions used to select data: Two ellipsoids are combined using the union operation used to select voxels from a volume. Voxels are shrunk 50 percent.
[ExtractLargestIsosurface](/PythonicAPI/Modelling/ExtractLargestIsosurface) | Extract largest isosurface.
[IceCream](/PythonicAPI/VisualizationAlgorithms/IceCream) | How to use boolean combinations of implicit functions to create a model of an ice cream cone.
[ImplicitDataSet](/PythonicAPI/ImplicitFunctions/ImplicitDataSet) | Convert an imagedata to an implicit function.
[ImplicitQuadric](/PythonicAPI/ImplicitFunctions/ImplicitQuadric) | Create an ellipsoid using an implicit quadric
[ImplicitSphere](/PythonicAPI/ImplicitFunctions/ImplicitSphere) | Demonstrate sampling of a sphere implicit function
[ImplicitSphere1](/PythonicAPI/ImplicitFunctions/ImplicitSphere1) | Demonstrate sampling of a sphere implicit function
......@@ -268,6 +269,7 @@ This section includes examples of manipulating meshes.
[FitToHeightMap](/PythonicAPI/Meshes/FitToHeightMap) | Drape a polydata over an elevation map.
[GreedyTerrainDecimation](/PythonicAPI/PolyData/GreedyTerrainDecimation) | Create a mesh from an ImageData
[IdentifyHoles](/PythonicAPI/Meshes/IdentifyHoles) | Close holes in a mesh and identify the holes.
[ImplicitSelectionLoop](/PythonicAPI/PolyData/ImplicitSelectionLoop) | Select a region of a mesh with an implicit function.
[PointInterpolator](/PythonicAPI/Meshes/PointInterpolator) | Plot a scalar field of points onto a PolyData surface.
#### Clipping
......
#!/usr/bin/env python3
from vtkmodules.vtkCommonDataModel import vtkImplicitDataSet
from vtkmodules.vtkImagingCore import vtkRTAnalyticSource
def main():
wavelet_source = vtkRTAnalyticSource()
implicit_wavelet = vtkImplicitDataSet(data_set=wavelet_source.update().output)
x = (0.5, 0, 0)
print(f'The value should roughly be 258.658:\n'
f'x: {implicit_wavelet.EvaluateFunction(x):0.3f}')
if __name__ == '__main__':
main()
#!/usr/bin/env python3
# noinspection PyUnresolvedReferences
import vtkmodules.vtkInteractionStyle
# noinspection PyUnresolvedReferences
import vtkmodules.vtkRenderingOpenGL2
from vtkmodules.vtkCommonColor import vtkNamedColors
from vtkmodules.vtkCommonCore import vtkPoints
from vtkmodules.vtkCommonDataModel import vtkImplicitSelectionLoop
from vtkmodules.vtkFiltersCore import vtkClipPolyData
from vtkmodules.vtkFiltersSources import vtkSphereSource
from vtkmodules.vtkRenderingCore import (
vtkPolyDataMapper,
vtkProperty,
vtkRenderer,
vtkRenderWindow,
vtkRenderWindowInteractor
)
from vtkmodules.vtkRenderingLOD import vtkLODActor
def main():
colors = vtkNamedColors()
sphere_source = vtkSphereSource(phi_resolution=100, theta_resolution=100)
selection_points = vtkPoints()
selection_points.InsertPoint(0, -0.16553, 0.135971, 0.451972)
selection_points.InsertPoint(1, -0.0880123, -0.134952, 0.4747)
selection_points.InsertPoint(2, 0.00292618, -0.134604, 0.482459)
selection_points.InsertPoint(3, 0.0641941, 0.067112, 0.490947)
selection_points.InsertPoint(4, 0.15577, 0.0734765, 0.469245)
selection_points.InsertPoint(5, 0.166667, -0.129217, 0.454622)
selection_points.InsertPoint(6, 0.241259, -0.123363, 0.420581)
selection_points.InsertPoint(7, 0.240334, 0.0727106, 0.432555)
selection_points.InsertPoint(8, 0.308529, 0.0844311, 0.384357)
selection_points.InsertPoint(9, 0.32672, -0.121674, 0.359187)
selection_points.InsertPoint(10, 0.380721, -0.117342, 0.302527)
selection_points.InsertPoint(11, 0.387804, 0.0455074, 0.312375)
selection_points.InsertPoint(12, 0.43943, -0.111673, 0.211707)
selection_points.InsertPoint(13, 0.470984, -0.0801913, 0.147919)
selection_points.InsertPoint(14, 0.436777, 0.0688872, 0.233021)
selection_points.InsertPoint(15, 0.44874, 0.188852, 0.109882)
selection_points.InsertPoint(16, 0.391352, 0.254285, 0.176943)
selection_points.InsertPoint(17, 0.373274, 0.154162, 0.294296)
selection_points.InsertPoint(18, 0.274659, 0.311654, 0.276609)
selection_points.InsertPoint(19, 0.206068, 0.31396, 0.329702)
selection_points.InsertPoint(20, 0.263789, 0.174982, 0.387308)
selection_points.InsertPoint(21, 0.213034, 0.175485, 0.417142)
selection_points.InsertPoint(22, 0.169113, 0.261974, 0.390286)
selection_points.InsertPoint(23, 0.102552, 0.25997, 0.414814)
selection_points.InsertPoint(24, 0.131512, 0.161254, 0.454705)
selection_points.InsertPoint(25, 0.000192443, 0.156264, 0.475307)
selection_points.InsertPoint(26, -0.0392091, 0.000251724, 0.499943)
selection_points.InsertPoint(27, -0.096161, 0.159646, 0.46438)
loop = vtkImplicitSelectionLoop(loop=selection_points)
clip = vtkClipPolyData(clip_function=loop, value=0.0)
clip_mapper = vtkPolyDataMapper(scalar_visibility=False)
sphere_source >> clip >> clip_mapper
back_prop = vtkProperty()
back_prop.color = colors.GetColor3d('Tomato')
clip_actor = vtkLODActor(mapper=clip_mapper, backface_property=back_prop)
clip_actor.property.color = colors.GetColor3d('Banana')
renderer = vtkRenderer(background=colors.GetColor3d('SlateGray'))
render_window = vtkRenderWindow(size=(500, 500), window_name='ImplicitSelectionLoop')
render_window.AddRenderer(renderer)
renderer.AddActor(clip_actor)
interactor = vtkRenderWindowInteractor()
interactor.render_window = render_window
# Get a good orientation.
renderer.ResetCamera()
renderer.active_camera.Azimuth(22.5)
renderer.active_camera.Elevation(10.0)
renderer.active_camera.Zoom(1.5)
render_window.Render()
interactor.Start()
if __name__ == '__main__':
main()
src/Testing/Baseline/Cxx/PolyData/TestImplicitSelectionLoop.png

130 B | W: | H:

src/Testing/Baseline/Cxx/PolyData/TestImplicitSelectionLoop.png

130 B | W: | H:

src/Testing/Baseline/Cxx/PolyData/TestImplicitSelectionLoop.png
src/Testing/Baseline/Cxx/PolyData/TestImplicitSelectionLoop.png
src/Testing/Baseline/Cxx/PolyData/TestImplicitSelectionLoop.png
src/Testing/Baseline/Cxx/PolyData/TestImplicitSelectionLoop.png
  • 2-up
  • Swipe
  • Onion skin
src/Testing/Baseline/PythonicAPI/PolyData/TestImplicitSelectionLoop.png

130 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