VTK/Tutorials/TriangleGeometryOnly: Difference between revisions
From KitwarePublic
Jump to navigationJump to search
Daviddoria (talk | contribs) m (Write a file of triangle corners moved to Triangle - Geometry only: Changed structure of polydata examples) |
Daviddoria (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
This example writes the coordinates of the corners of a triangle to a vtp file. There is geometry (points), but there is no topology (vertices), so if you open this file in Paraview, you will not see anything. You can "glyph" the points to see them, but generally some type of topology exists. We will see topology in the next example. | This example writes the coordinates of the corners of a triangle to a vtp file. There is geometry (points), but there is no topology (vertices), so if you open this file in Paraview, you will not see anything. You can "glyph" the points to see them, but generally some type of topology exists. We will see topology in the next example. | ||
==TrianglePoints.cxx== | |||
<source lang="cpp"> | <source lang="cpp"> | ||
#include < | #include <vtkSmartPointer.h> | ||
#include < | #include <vtkPoints.h> | ||
#include <vtkXMLPolyDataWriter.h> | |||
#include <vtkPolyData.h> | |||
int main() | |||
{ | |||
//create a set of points | |||
vtkSmartPointer<vtkPoints> Points = vtkSmartPointer<vtkPoints>::New(); | |||
Points->InsertNextPoint ( 1.0, 0.0, 0.0 ); | |||
Points->InsertNextPoint ( 0.0, 0.0, 0.0 ); | |||
Points->InsertNextPoint ( 0.0, 1.0, 0.0 ); | |||
//create a polydata | |||
vtkSmartPointer<vtkPolyData> polydata = vtkSmartPointer<vtkPolyData>::New(); | |||
//add the points to the polydata | |||
polydata->SetPoints ( Points ); | |||
//write the polydata to a file | |||
vtkSmartPointer<vtkXMLPolyDataWriter> writer = vtkSmartPointer<vtkXMLPolyDataWriter>::New(); | |||
writer->SetFileName ( "TrianglePoints.vtp" ); | |||
writer->SetInput ( polydata ); | |||
writer->Write(); | |||
return 0; | |||
} | |||
</source> | |||
==CMakeLists.txt== | |||
<source lang="text"> | |||
cmake_minimum_required(VERSION 2.6) | |||
PROJECT(TrianglePoints) | |||
FIND_PACKAGE(VTK REQUIRED) | |||
INCLUDE(${VTK_USE_FILE}) | |||
ADD_EXECUTABLE(TrianglePoints TrianglePoints.cxx) | |||
TARGET_LINK_LIBRARIES(TrianglePoints vtkHybrid) | |||
</source> |
Revision as of 18:22, 22 October 2009
This example writes the coordinates of the corners of a triangle to a vtp file. There is geometry (points), but there is no topology (vertices), so if you open this file in Paraview, you will not see anything. You can "glyph" the points to see them, but generally some type of topology exists. We will see topology in the next example.
TrianglePoints.cxx
<source lang="cpp">
- include <vtkSmartPointer.h>
- include <vtkPoints.h>
- include <vtkXMLPolyDataWriter.h>
- include <vtkPolyData.h>
int main() {
//create a set of points vtkSmartPointer<vtkPoints> Points = vtkSmartPointer<vtkPoints>::New(); Points->InsertNextPoint ( 1.0, 0.0, 0.0 ); Points->InsertNextPoint ( 0.0, 0.0, 0.0 ); Points->InsertNextPoint ( 0.0, 1.0, 0.0 );
//create a polydata vtkSmartPointer<vtkPolyData> polydata = vtkSmartPointer<vtkPolyData>::New();
//add the points to the polydata polydata->SetPoints ( Points );
//write the polydata to a file vtkSmartPointer<vtkXMLPolyDataWriter> writer = vtkSmartPointer<vtkXMLPolyDataWriter>::New(); writer->SetFileName ( "TrianglePoints.vtp" ); writer->SetInput ( polydata ); writer->Write();
return 0;
}
</source>
CMakeLists.txt
<source lang="text"> cmake_minimum_required(VERSION 2.6)
PROJECT(TrianglePoints)
FIND_PACKAGE(VTK REQUIRED) INCLUDE(${VTK_USE_FILE})
ADD_EXECUTABLE(TrianglePoints TrianglePoints.cxx) TARGET_LINK_LIBRARIES(TrianglePoints vtkHybrid)
</source>