Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <vtkSmartPointer.h>
- #include <vtkHedgeHog.h>
- #include <vtkActor.h>
- #include <vtkCamera.h>
- #include "vtkPointSet.h"
- #include "vtkVolume16Reader.h"
- #include "vtkOutlineFilter.h"
- #include "vtkRenderer.h"
- #include "vtkPolyDataNormals.h"
- #include "vtkContourFilter.h"
- #include "vtkColorTransferFunction.h"
- #include "vtkPiecewiseFunction.h"
- #include "vtkVolumeProperty.h"
- #include <vtkFloatArray.h>
- #include <vtkMath.h>
- #include <vtkPointData.h>
- #include <vtkPoints.h>
- #include <vtkPolyDataMapper.h>
- #include <vtkProperty.h>
- #include <vtkRenderWindow.h>
- #include <vtkRenderWindowInteractor.h>
- #include <vtkRenderer.h>
- #include "vtkMarchingCubes.h"
- #include "vtkRecursiveDividingCubes.h"
- #include "vtkScalarBarWidget.h"
- #include "vtkScalarBarActor.h"
- #include "vtkPiecewiseFunction.h"
- #include "vtkThresholdPoints.h"
- #include "vtkStructuredPointsReader.h"
- #include "vtkMaskPoints.h"
- #include "vtkConeSource.h"
- #include "vtkVolumeRayCastCompositeFunction.h"
- #include "vtkVolumeRayCastMapper.h"
- #include "vtkVolumeRayCastMIPFunction.h"
- #include "vtkGlyph3D.h"
- #include "vtkLookupTable.h"
- #include "vtkCommand.h"
- #include <vtkStructuredGrid.h>
- #include <vtkStreamLine.h>
- #include "vtkStreamPoints.h"
- #include <vtkNamedColors.h>
- #include "vtkPointSource.h"
- #include "vtkPointSet.h"
- int main(int argc, char **argv)
- {
- // Create the renderer, the render window, and the interactor. The renderer
- // draws into the render window, the interactor enables mouse- and
- // keyboard-based interaction with the data within the render window.
- vtkRenderer *aRenderer = vtkRenderer::New();
- vtkRenderWindow *renWin = vtkRenderWindow::New();
- renWin->AddRenderer(aRenderer);
- vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
- iren->SetRenderWindow(renWin);
- // Read
- vtkStructuredPointsReader *reader = vtkStructuredPointsReader::New();
- reader->SetFileName("../data/wind.vtk");
- reader->Update();
- // Hedgehog setup.
- //vtkHedgeHog *hhog = vtkHedgeHog::New();
- //hhog->SetInputConnection(reader->GetOutputPort());
- //hhog->SetScaleFactor(1.0);
- /* vtkConeSource *coneSource = vtkConeSource::New();
- vtkGlyph3D *glyph = vtkGlyph3D::New();
- glyph->SetInputConnection(reader->GetOutputPort());
- glyph->SetScaleFactor(1.6);
- glyph->SetSourceConnection(coneSource->GetOutputPort());
- coneSource->SetResolution(6);
- coneSource->SetHeight(1.5);
- coneSource->SetRadius(1.5);
- glyph->SetScaleModeToScaleByVector();
- //glyph.SetScaleFactor(5);
- //vtkExtractGrid extg = new vtkExtractGrid();
- //extg.SetInput(vtkStructuredGrid.SafeDownCast(
- //glyph.GetOutput()));
- //extg.SetSampleRate(2, 2, 1);
- // Lookup Table
- //lut.SetHueRange(0.667, 1.0);
- vtkLookupTable *lut = vtkLookupTable::New();
- lut->SetHueRange(0.667, 0.0);
- lut->Build();
- // Poly Mapper
- vtkPolyDataMapper *mapper = vtkPolyDataMapper::New();
- mapper->SetInputConnection(glyph->GetOutputPort());
- mapper->SetScalarRange(0.0, 1.0);
- mapper->SetLookupTable(lut);*/
- /************** Streamline DATA 1 *******************************************/
- /*int count = 0;
- vtkPoints *points = vtkPoints::New(); //DIMENSIONS 36 36 1 ORIGIN 0.0 0.0 0.0
- for (int x = 0; x <= 36; x+=5) { // can change to += 3 5 6, 4 will error
- for (int y = 0; y <= 36; y++) {
- for (int z = 0; z <=1 ; z++) {
- points->InsertPoint(count, x, y, z);
- count++;
- }
- }
- }
- vtkPolyData *startPoints = vtkPolyData::New();
- startPoints->SetPoints(points);
- //StreamLine Setup
- vtkStreamLine *streamLine = vtkStreamLine::New();
- streamLine->SetInputConnection(reader->GetOutputPort());
- streamLine->SetSourceData(startPoints);
- streamLine->SetMaximumPropagationTime(100);
- streamLine->SetStepLength(0.2);
- streamLine->SetIntegrationStepLength(0.02);
- streamLine->SetNumberOfThreads(2);
- streamLine->SetIntegrationDirectionToIntegrateBothDirections();
- */
- /***********************************************************/
- /************** Streamline DATA 2 *******************************************/
- /*int count = 0;
- vtkPoints *points = vtkPoints::New(); //DIMENSIONS 357 357 1 ORIGIN 0.0 0.0 0.0
- for (int x = 0; x <= 357; x+=10) {
- for (int y = 0; y <= 357; y+=10) {
- for (int z = 0; z <= 1; z++) {
- points->InsertPoint(count, x, y, z);
- count++;
- }
- }
- }
- vtkPolyData *startPoints = vtkPolyData::New();
- startPoints->SetPoints(points);
- //StreamLine Setup
- vtkStreamLine *streamLine = vtkStreamLine::New();
- streamLine->SetInputConnection(reader->GetOutputPort());
- streamLine->SetSourceData(startPoints);
- streamLine->SetMaximumPropagationTime(100);
- streamLine->SetStepLength(0.2);
- streamLine->SetIntegrationStepLength(0.02);
- streamLine->SetNumberOfThreads(2);
- streamLine->SetIntegrationDirectionToIntegrateBothDirections();
- */
- /***********************************************************/
- /************** Streamline Carotid *******************************************/
- /*int count = 0;
- vtkPoints *points = vtkPoints::New();
- for (int x = 100; x < 176; x+=7) { // DIMENSIONS 76 49 45 ORIGIN 100.0 80.0 1.0
- for (int y = 80; y < 129; y+=7) {
- for (int z = 1; z < 46; z+=2) {
- points->InsertPoint(count, x, y, z);
- count++;
- }
- }
- }
- vtkPolyData *startPoints = vtkPolyData::New();
- startPoints->SetPoints(points);
- //StreamLine Setup
- vtkStreamLine *streamLine = vtkStreamLine::New();
- streamLine->SetInputConnection(reader->GetOutputPort());
- streamLine->SetSourceData(startPoints);
- streamLine->SetMaximumPropagationTime(100);
- streamLine->SetStepLength(0.2);
- streamLine->SetIntegrationStepLength(0.02);
- streamLine->SetNumberOfThreads(2);
- streamLine->SetIntegrationDirectionToIntegrateBothDirections();
- */
- /***********************************************************/
- /************** Streamline wind *******************************************/
- int count = 0;
- vtkPoints *point = vtkPoints::New();
- for (int x = 18; x <= 53; x += 1) { // DIMENSIONS 35 41 15
- for (int y = 70; y <= 111; y += 1) {
- for (int z = 0; z <= 15; z += 5) {
- point->InsertPoint(count, x, y, z);
- count++;
- }
- }
- }
- vtkPolyData *startPointz = vtkPolyData::New();
- startPointz->SetPoints(point);
- //StreamLine Setup
- //vtkStreamLine *streamLine = vtkStreamLine::New();/////////////////////////////////////////////////
- //streamLine->SetInputConnection(reader->GetOutputPort());
- //streamLine->SetSourceData(startPoints);
- //streamLine->SetMaximumPropagationTime(100);
- //streamLine->SetStepLength(0.2);
- //streamLine->SetIntegrationStepLength(0.02);
- //streamLine->SetNumberOfThreads(2);
- //streamLine->SetIntegrationDirectionToIntegrateBothDirections();
- //StreamPoints Setup
- vtkStreamPoints *streamPoints = vtkStreamPoints::New();
- streamPoints->SetInputConnection(reader->GetOutputPort());
- streamPoints->SetSourceData(startPointz);
- streamPoints->SetMaximumPropagationTime(100);
- streamPoints->SetIntegrationStepLength(0.02);
- streamPoints->SetNumberOfThreads(2);
- streamPoints->SetIntegrationDirectionToIntegrateBothDirections();
- //Glyph Setup
- vtkConeSource *coneSource = vtkConeSource::New();
- vtkGlyph3D *glyph = vtkGlyph3D::New();
- glyph->SetInputConnection(reader->GetOutputPort());
- glyph->SetScaleFactor(0.1);
- glyph->SetSourceConnection(coneSource->GetOutputPort());
- coneSource->SetResolution(5);
- coneSource->SetHeight(0.5);
- coneSource->SetRadius(0.05);
- glyph->SetScaleModeToScaleByVector();
- /***********************************************************/
- // Lookup Table
- //lut.SetHueRange(0.667, 1.0);
- vtkLookupTable *lut = vtkLookupTable::New();
- lut->SetHueRange(0.667, 1.0);
- lut->Build();
- //vtkLookupTable *lut2 = vtkLookupTable::New();
- //lut2->SetHueRange(0.667, 1.0);
- //lut2->Build();
- // Poly Mapper glyph
- vtkPolyDataMapper *mapper = vtkPolyDataMapper::New();
- mapper->SetInputConnection(glyph->GetOutputPort());
- //mapper->SetScalarRange(0.0, 0.5);
- mapper->ScalarVisibilityOff();
- mapper->SetLookupTable(lut);
- // Poly Mapper streamPoints
- vtkPolyDataMapper *mapper2 = vtkPolyDataMapper::New();
- mapper2->SetInputConnection(streamPoints->GetOutputPort());
- mapper2->SetScalarRange(0, 0.05);
- mapper2->ScalarVisibilityOff();
- mapper2->SetLookupTable(lut);
- // Poly Mapper streamLine
- //vtkPolyDataMapper *mapper3 = vtkPolyDataMapper::New();/////////////////////////////////////////////////
- //mapper3->SetInputConnection(streamLine->GetOutputPort());
- //mapper3->SetScalarRange(0.0, 0.5);
- //mapper3->SetLookupTable(lut);
- // Actor
- vtkActor *actor = vtkActor::New();
- actor->SetMapper(mapper);
- actor->GetProperty()->SetColor(0, 0, 255);
- // Actor2 for streamPoints
- vtkActor *actor2 = vtkActor::New();
- actor2->SetMapper(mapper2);
- actor2->GetProperty()->SetColor(255, 255, 255);
- // Actor2 for streamPoints
- //vtkActor *actor3 = vtkActor::New();/////////////////////////////////////////////////
- //actor3->SetMapper(mapper3);
- // Actors are added to the renderer. An initial camera view is created.
- // The Dolly() method moves the camera towards the FocalPoint,
- // thereby enlarging the image.
- aRenderer->AddActor(actor);//////
- aRenderer->AddActor(actor2);
- //aRenderer->AddActor(actor3);/////////////////////////////////////////////////
- // Set a background color for the renderer and set the size of the
- // render window (expressed in pixels).
- aRenderer->SetBackground(0, 0, 0);
- renWin->SetSize(800, 600);
- // Initialize the event loop and then start it.
- iren->Initialize();
- renWin->SetWindowName("Simple Volume Renderer");
- renWin->Render();
- iren->Start();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement