VTK – Use vtkOBBTree To Find Axes Of 3D Model

I will show how to use vtkOBBTree to calculate X, Y and Z axis of the 3D model in the article. Create a simple cone. #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 <vtkRenderWindowInteractor.h> #include <vtkLight.h> #include <vtkCamera.h> #include Read more…

VTK – Area Layouts Of Graph Visualizations

There are three examples using views displaying relations of vtk classes. The article learned from VTKUsersGuide vtkTreeRingView Python #!/usr/bin/env python from vtk import * def main(): datapath = “/Users/weiyang/Downloads/VTKData” #vtk.util.misc.vtkGetDataRoot() reader1 = vtkXMLTreeReader() reader1.SetFileName(datapath + “/Data/Infovis/XML/vtkclasses.xml”) reader1.SetEdgePedigreeIdArrayName(“tree edge”) reader1.GenerateVertexPedigreeIdsOff(); reader1.SetVertexPedigreeIdArrayName(“id”); reader2 = vtkXMLTreeReader() reader2.SetFileName(datapath + “/Data/Infovis/XML/vtklibrary.xml”) reader2.SetEdgePedigreeIdArrayName(“graph edge”) reader2.GenerateVertexPedigreeIdsOff(); reader2.SetVertexPedigreeIdArrayName(“id”); Read more…

Two Ways To Add Data Object For vtkView

Two ways to add data object for a vtkView. 1) Create a representation object, set the inputs for it by calling SetInputConnection() or SetInput(), then add representation for the view. 2) Use AddRepresentationFromInputConnection or AddRepresentationFromInput to create representation automatically. 1) Python from vtk import * surfaceRepresentation = vtkRenderedSurfaceRepresentation() sphere = Read more…

CPP – Ignore Case To Compare String

STL Algorithm std::lexicographical_compare is an algorithm which can be used to compare string lexicographically.We can give our comparing function to make it work without pay attention to capital and small letter. C++ template constexpr bool lexicographical_compare( InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, Compare comp ); Example: C++ #include Read more…

CPP – Unique Copy In STL

std::unique_copy is an algorithm which can be used to copy elements without duplicating objects in adjacent locations. template< class InputIt, class OutputIt > OutputIt uniquecopy( InputIt first, InputIt last, OutputIt dfirst ); Usage example: C++ #include #include #include #include int main() { std::string s1 = “This is a story about Read more…

Example: vtkGraphLayoutView And vtkGraphToGlyphs

vtkGraphLayoutView is a subclass of vtkGraphLayoutView which has own renderer, renderWindow, command observer, actor and etc. The following code shows how to use it to display a 2D image. from vtk import * def main(): # create a random graph source = vtkRandomGraphSource() source.SetNumberOfVertices(100) source.SetNumberOfEdges(110) source.StartWithTreeOn() source.Update() arcParallelStrategy = vtkArcParallelEdgeStrategy() Read more…

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

X