#include "vtkBoxCutPolyLines.h" #include #include #include #include #include #include vtkCxxRevisionMacro(vtkBoxCutPolyLines, "$Revision: 1.1 $"); vtkStandardNewMacro(vtkBoxCutPolyLines); vtkBoxCutPolyLines::vtkBoxCutPolyLines() { } //---------------------------------------------------------------------------- // Specify the bounding box for clipping void vtkBoxCutPolyLines::SetBoxClip(double xmin,double xmax, double ymin,double ymax, double zmin,double zmax) { this->XMin = xmin; this->XMax = xmax; this->YMin = ymin; this->YMax = ymax; this->ZMin = zmin; this->ZMax = zmax; this->Modified(); } int vtkBoxCutPolyLines::RequestData (vtkInformation *vtkNotUsed(request), vtkInformationVector **inputVector, vtkInformationVector *outputVector) { // get the info objects vtkInformation *inInfo = inputVector[0]->GetInformationObject(0); vtkInformation *outInfo = outputVector->GetInformationObject(0); // get the input and ouptut vtkPolyData *input = vtkPolyData::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT())); vtkPolyData *output = vtkPolyData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT())); output->Initialize(); output->Allocate(); vtkPoints* points = input->GetPoints(); output->SetPoints ( points ); output->GetPointData()->SetScalars ( input->GetPointData()->GetScalars() ); vtkCellArray* lines = input->GetLines(); if( lines==0 ) return 0; lines->InitTraversal(); int npt, *pto; int test = lines->GetNextCell (npt, pto); while( test!=0 ) { int i=0; while( iGetPoint (pto[i]); if(( pt[0]>this->XMin && pt[0]XMax && pt[1]>this->YMin && pt[1]YMax && pt[2]>this->ZMin && pt[2]ZMax )) test2 = 1; vtkIdList* idlist = vtkIdList::New(); while (test2 == 1 && iInsertNextId (pto[i]); i++; if (iGetPoint (pto[i]); if(( pt[0]>this->XMin && pt[0]XMax && pt[1]>this->YMin && pt[1]YMax && pt[2]>this->ZMin && pt[2]ZMax )) test2 = 1; else test2 = 0; } output->InsertNextCell (VTK_POLY_LINE, idlist); idlist->Delete(); i++; } test = lines->GetNextCell (npt, pto); } return 1; }