Polydata And Image Converter

convert polydata to image data #include <vtkVersion.h> #include <vtkImageData.h> #include <vtkImageMapper3D.h> #include <vtkImageStencil.h> #include <vtkImageStencilData.h> #include <vtkImageToImageStencil.h> #include <vtkJPEGReader.h> #include <vtkPointData.h> #include <vtkSmartPointer.h> #include <vtkRenderWindow.h> #include <vtkRenderWindowInteractor.h> #include <vtkInteractorStyleImage.h> #include <vtkRenderer.h> #include <vtkImageActor.h> #include <vtkPolyDataToImageStencil.h> #include <vtkPolyData.h> #include <vtkSTLReader.h> #include <vtkImageProperty.h> #include <vtkSphereSource.h> #define vSP vtkSmartPointer #define vSPNew(Var, Type) vSP<Type> Read more…

Explore Scale A Plane And Keep Position

The article shows a way to enlarge a plane and keep its original position, scale it and translate it back. #include <iostream> #include <vtkSmartPointer.h> #include <vtkProperty.h> #include <vtkPolyData.h> #include <vtkTriangleFilter.h> #include <vtkRegularPolygonSource.h> #include <vtkPolyDataMapper.h> #include <vtkActor.h> #include <vtkRenderWindow.h> #include <vtkRenderer.h> #include <vtkRenderWindowInteractor.h> #include <vtkInteractorStyleTrackballCamera.h> #include <vtkCamera.h> #include <vtkNamedColors.h> #include <vtkImageActor.h> Read more…

Explore How To Rotate Object And Keep It Facing Camera

The following code comes from vtkFollower, we used it to make the original axes always face the camera. #include <iostream> #include <vtkSmartPointer.h> #include <vtkProperty.h> #include <vtkPolyData.h> #include <vtkTriangleFilter.h> #include <vtkRegularPolygonSource.h> #include <vtkPolyDataMapper.h> #include <vtkActor.h> #include <vtkRenderWindow.h> #include <vtkRenderer.h> #include <vtkRenderWindowInteractor.h> #include <vtkInteractorStyleTrackballCamera.h> #include <vtkCamera.h> #include <vtkNamedColors.h> #include <vtkImageActor.h> #include <vtkImageViewer2.h> Read more…

Explore The Orientation Of 3D Object

The algorithm vtkOBBTree::ComputeOBB can help us to calculate the three axes defining the orientation of the OBB(oriented bounding box). It is very useful for us to get the model’s spatial features. #include <iostream> #include <vtkSmartPointer.h> #include <vtkSphereSource.h> #include <vtkActor.h> #include <vtkConeSource.h> #include <vtkRenderer.h> #include <vtkRenderWindow.h> #include <vtkPolyDataMapper.h> #include <vtkProperty.h> #include Read more…

boost::progress_display

The class progress_display has definition and implementation in progress.hpp. The relevant example is in the following code snippet. Qt pro file: TEMPLATE = app CONFIG += console c++11 CONFIG -= app_bundle CONFIG -= qt INCLUDEPATH += /usr/local/Cellar/boost/1.66.0/include/ SOURCES += \ main.cpp main.cpp: #include <iostream> #include <boost/progress.hpp> #include <vector> #include <fstream> Read more…

Use vtkObjectBase’s Function Delete To Free Object

Explore what will happen when we use delete on vtkSmartPointer<vtkActor> object. vtkSmartPointer<vtkActor> leftActor = vtkSmartPointer<vtkActor>::New(); leftActor->SetMapper( mapper ); //… void *ptr = leftActor.Get(); leftActor->GetProperty()->SetColor( 1, 0, 0 ); rightActor->GetProperty()->SetColor( 0, 1, 0 ); leftActor->Delete(); cout << “leftActor: ” << (void *)leftActor.Get() << endl; cout << “leftActor reference count: ” << Read more…

Wolfram – Coordinates and Graphics

Draw a circle and an inner circle Graphics[{Circle[{0, 0}, 1], Circle[{0, -0.5}, 0.5]}] Draw 10 circles which has center (i,i) and i is in {1,10} Graphics[Table[Circle[{i, i}, 0.5], {i, 10}]] Connect 10 points which is at (i,i) data = Table[{i, i}, {i, 10}] ListLinePlot[data] Or: Graphics[Line[data]] ListLinePlot[{{1, 1}, {2, 3}, {3, Read more…

Tex To PDF
: convert the Latex file which suffix is tex to a PDF file

X