I work with UnstructuredGrid and I want to triangulate it like in Paraview (when I clicked for model).
How I can do it?
I tried vtkDelaunay3D, vtkDelaunay2D and vtkTriangleFilter.
vtkDelaunay3D :
I've transformed UnstructuredGrid to vtkPolyData, after used vtkCleanPolyData and vtkDelaunay3D. It's not worked. It's crushed with this warning :
vtkMath.cxx: Unable to factor linear system
vtkDelaunay2D :
Similarly I used vtkDelaunay2D, but result is not good for me.
Also I use vtkTriangleFilter, it's result not good for me too.
When you click (or interact) in ParaView, ParaView is rendering a simplified geometry -- not simply a triangulated geometry. The filter it uses to do that is vtkQuadricClustering. Apply the vtkGeometryFilter first to your unstructured grid to convert your vtkUnstructuredGrid to a vtkPolyData. Then connect it to vtkQuadricClustering. You can play with parameters in vtkQuadricClustering to control the simplification.
Related
I am developing on an application based on VTK and GDCM for viewing medical (DICOM) images.
The application has three windows that respectively show XY, YZ and XZ orientations (axial, coronal and sagittal). This is similar to the 2D views here. I use vtkImageViewer2 for this. The voxel values of the DICOM images are passed on to an instance of vtkImageData. The instance of the vtkImageData is the passed on the to three instances of vtkImageViewer2 (let's use imageViewerXY, imageViewerYZ and imageViewerXZ). The orientation of each instance of vtkImageViewer2 is then set using SetSliceOrientationToXY(), SetSliceOrientationToYZ() and SetSliceOrientationToXZ(). Without the mask, I can see the slices, couple the windows and scroll through the images perfectly fine.
To add the mask so that it is shown in the three views, I use vtkImageActor. For the XY view, which is the default view, this works fine. I update the instance of vtkImageActor, which I call maskActorXY based on the mouse events of XY window as follows:
int extent[6];
imageViewerXY->GetImageActor->GetDisplayExtent(extent);
maskActorXY->SetDisplayExtent(extent);
maskActorXY->Update();
imageViewerXY->GetRenerer->Render();
Now, when I do the same for the other two windows so that I can see the 3D mask in the other two orientations, for example for the YZ orientation,
imageViewerYZ->GetImageActor->GetDisplayExtent(extent);
maskActorYZ->SetDisplayExtent(extent);
maskActorYZ->Update();
imageViewerYZ->GetRenerer->Render();
I get an error message that traces to vtkImageData and accessing pixel values outside of the extent set for the mask actor.
I have a limited familiarity with VTK, but looking at the source code of vtkImageViewer2 (see UpdateDisplayExtent() on line 341), I don't understand why pixel values out side of the specified display extent are requested from my instances of vtkImageActor that represent the mask.
I found a solution. Since I am not familiar with VTK, I may not be able to provide a clear explanation. All that I needed were the following two lines for each mask to force its mappers to face the camera:
maskActorYZ->GetMapper()->SetAtFocalPointOn();
maskActorYZ->GetMapper()->SliceFacesCameraOn();
(see [vtkImageMapper3D][1] class.)
My objective here is to allow users to specify territories or regions given a background world-map overlay, which is an SVG generated from GeoJSON data using D3. I have done the part where the territories' points are pinpointed by the user, and an SVG is generated. This works well.
Now I would like to save the territory's coordinates, using the background map's projection, scale and translation. I saw a lot of documentation about translating GeoJSON data to SVG s, but nothing about the other way. Is it even possible ?
Thanks Ben Lyall, eventually I used the native SVG functions getTotalLength() and getPointAtLength() to convert my path to an array of top/left positions (in pixels), then d3's projection.invert() to translate them into coordinates.
I am trying to add a target (bullseye) to an image without the use of importing python functions, it is proving to be rather difficult however I believe I need to define a circle through use of code. It should be done by changing the pixels as opposed to importing functions.
Thanks
Needs to be in the centre of an image
You will need to add more information here - how is your image represnted in Python? Normally for porduction code, dealing with images is done through 3rd party modules, each of which have a way to draw or change different pixels. If you are using none you have to define your image reading and writting code (or a way to display the image on the screen).
Anyway, doing all of that without any "importing" will be quite artificial, though feasible.
Maybe you should use pnm files which have a minimum of encoding required.
That said, you could represent the image in memory as a bytesarray object, and use math.sin and math.cos (you will have to import those, or resort to a "raytracing" approach which can render the circle based on x**2 + y * 2 = r ** 2 ) to draw your circle.
I want to render a scene interactively. The controls are already provided so that you can position the camera with mouse but you never know the exact value.
I want to manipulate the internal camera values as well e.g focal length.
Externally I want to set the translation and rotation of the camera.
I want to give all the values manually. Could anyone please help to point to such a demo or a code snippet to do it. Preferably in python.
Thanks a lot.
You can get the camera from the renderer with renderer->GetActiveCamera(). Then you can manipulate it using the class functions: http://www.vtk.org/doc/nightly/html/classvtkCamera.html
Here is a simple Python example: http://www.vtk.org/Wiki/VTK/Examples/Python/Camera
I am new to opengl and visual c++. I have done a sample application which rotates 3D shapes in opengl. I want to allow the user to rotate and zoom the object. Please give me an example of how to do this.
I have tried NeHe tutorial: http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=48
I can't understand the class structure in the example. Is there anysimple way to achieve this?
I have found a library as well: http://www.nigels.com/glt/gltzpr/
But still can't figure out how to do this.
Please help me.
Zooming is usually done through gluLookAt. The third parameter is the view distance.
Here is some basic example running this :
http://graphics.stanford.edu/courses/cs248-01/OpenGLHelpSession/code_example.html
Look in display() to see how the viewing distance is used and in MouseMotion() to see how the value is modified and the painting updated.