// generated by Fast Light User Interface Designer (fluid) version 1.00 #include #include #include #include #include #include "vtkAMRStructuredPointsReader.h" vtkRenderer *renderer; vtkRenderWindow* renWin; vtkOutlineFilter *outline; vtkContourFilter *contour; vtkPolyDataMapper *outlineMapper; vtkPolyDataMapper *contMapper; vtkActor *outlineActor; vtkActor *contActor; vtkPolyData *t, *outlineOut, *contOut, *t1; vtkStructuredPoints *temp, *out; vtkAMRStructuredPointsReader* spr=0; int main(int argc, char** argv) { // Make a window to put the rendering window in. FLTK interface. // Fl_Window* w; //{ Fl_Window* o = w = MainWin = // new Fl_Window(500, 500, "AMRTest"); // w = o; // o->end(); // } //renWin = vtkFlRenderWindow::New(); renderer = vtkRenderer::New(); // uncomment this to use the VTK rendering window //renderer->SetBackground(0.5, 0.5, 0.5); renWin = vtkRenderWindow::New(); renWin->AddRenderer(renderer); // uncomment this to use VTK event handler vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New(); iren->SetRenderWindow(renWin); //create a reader and open the file "amr.raw" spr = vtkAMRStructuredPointsReader::New(); spr->SetFileName("/nfs/zeus/lcascr1/pushkare/work/amr.raw"); cout<<"NLevels: "<GetNumLevels()<GetNumTimeSteps()<1) nlevel=atoi(argv[1]); spr->SelectLevel(nlevel); spr->SelectTimeStep(0); spr->Update(); int n = spr->GetNumDatasets(); cout<<"NDataSets: "<SelectDataset(i); spr->Update(); out = spr->GetOutput(); temp = (vtkStructuredPoints*)out->MakeObject(); temp->CopyStructure(out); temp->GetPointData()->DeepCopy(out->GetPointData()); temp->GetCellData()->DeepCopy(out->GetCellData()); temp->ForceUpdate(); Data->AddItem(temp); } int NContours = 0; Data->InitTraversal(); // This loop takes the grids from Data and processes them to get an outline // and isosurface for each grid. The isovalue for the dataset is set to 0.86 // for now. for (int j=0; jGetNextItem(); x1 = temp->GetPointData()->GetScalars()->GetRange(); Iso = 0.86; //if the isovalue is out of bounds for a particular grid, then just //ignore that grid. if (Iso < x1[0] || Iso > x1[1]) continue; NContours++; //produce the isosurface and stick it into the PolyData collection. contour->SetInput(temp); contour->SetValue(0, Iso); contour->Update(); contOut = contour->GetOutput(); t = (vtkPolyData*)contOut->MakeObject(); t->CopyStructure(contOut); t->GetPointData()->DeepCopy(contOut->GetPointData()); t->GetCellData()->DeepCopy(contOut->GetCellData()); t->ForceUpdate(); PolyData->AddItem(t); //produce a bounding box and put it into an Outlines collection outline->SetInput(temp); outline->Update(); outlineOut = outline->GetOutput(); t1 = (vtkPolyData*)outlineOut->MakeObject(); t1->CopyStructure(outlineOut); Outlines->AddItem(t1); } PolyData->InitTraversal(); Outlines->InitTraversal(); //This loop takes care of the final mapper and actor steps of the pipeline for (int k=0; kSetInput(PolyData->GetNextItem()); contMapper->ImmediateModeRenderingOn(); contActor = vtkActor::New(); contActor->SetMapper(contMapper); contActor->GetProperty()->SetRepresentationToSurface(); renderer->AddActor(contActor); //produce and add the bounding box actor, which is colored RED outlineMapper = vtkPolyDataMapper::New(); outlineMapper->SetInput(Outlines->GetNextItem()); outlineActor = vtkActor::New(); outlineActor->SetMapper(outlineMapper); outlineActor->GetProperty()->SetColor(1.0, 0.0, 0.0); renderer->AddActor(outlineActor); } // this part makes sure that something actually does show up on the screen // w->show(argc, argv); // w->begin(); // vtkwin = new Fl_vtk_Window( renWin, 1, 1, 498, 498); // vtkwin->show(1, argv); //w->end(); //return Fl::run(); //uncomment this and comment the FLTK stuff to use VTK window and event loop. renWin->Render(); iren->Start(); }