[vtkusers] unable to pass globalids through vtk filters.
John Platt
jcplatt at dsl.pipex.com
Wed Jun 22 18:42:56 EDT 2016
Hi sreeram,
Clipping/cutting global Ids would generate new Ids by interpolation from
the point global Ids in a cell. These would need to be rounded to
vtkIdType with new points possibly having the same interpolated global
Id and therefore no longer unique. The exception is vertices where no
interpolation occurs.
HTH
John.
On 6/22/2016 9:29 PM, sreeram wrote:
> I am having trouble passing global ids through vtk filters. Particularly
> vtkclipDataSet. It appears that, the global copy flag is unset by the
> filter. Forcing it the flag to set in debugger does not help.
>
> My global ids are vtkIdTypeArray. I am setting them on vtkPointData. Here
> is the code snippet.
>
> vtkSmartPointer<vtkPoints> points =
> vtkSmartPointer<vtkPoints>::New();
> points->InsertNextPoint(0.0, 0.0, 0.0);
> points->InsertNextPoint(1.0, 0.0, 0.0);
> points->InsertNextPoint(0.0, 1.0, 0.0);
> auto arr = vtkSmartPointer<vtkIdTypeArray>::New();
> std::vector<vtkIdType> varr = { 0, 1, 2 };
> arr->SetArray(&varr[0], 3, 1);
> // arr->SetName("myarr");
> vtkSmartPointer<vtkPolyData> pointsPolydata =
> vtkSmartPointer<vtkPolyData>::New();
>
> pointsPolydata->SetPoints(points);
> pointsPolydata->GetPointData()->SetGlobalIds(arr);
>
> pointsPolydata->GetPointData()->CopyGlobalIdsOn();
>
> //pointsPolydata->GetPointData()->SetActiveAttribute("arr",
> vtkDataSetAttributes::GLOBALIDS);
> // pointsPolydata->GetPointData()->CopyGlobalIdsOn();
>
> vtkSmartPointer<vtkVertexGlyphFilter> vertexFilter =
> vtkSmartPointer<vtkVertexGlyphFilter>::New();
> #if VTK_MAJOR_VERSION <= 5
> vertexFilter->SetInputConnection(pointsPolydata->GetProducerPort());
> #else
> vertexFilter->SetInputData(pointsPolydata);
> #endif
> //vertexFilter->SetOutput(vertexFilter->GetInput());
> //auto n0 = vertexFilter->GetOutput()->GetPointData()->GetCopyGlobalIds();
>
> vertexFilter->Update();
> auto nCells = vertexFilter->GetOutput()->GetNumberOfCells();
> auto n = vertexFilter->GetOutput()->GetPointData()->GetGlobalIds();
> // auto n2 =
> vertexFilter->GetOutput()->GetPointData()->GetGlobalIds("myarr");
>
> vtkSmartPointer<vtkPolyData> polydata =
> vtkSmartPointer<vtkPolyData>::New();
> polydata->ShallowCopy(vertexFilter->GetOutput());
> auto n3 = polydata->GetPointData()->GetGlobalIds();
>
> // Setup colors
> unsigned char red[3] = { 255, 0, 0 };
> unsigned char green[3] = { 0, 255, 0 };
> unsigned char blue[3] = { 0, 0, 255 };
>
> vtkSmartPointer<vtkUnsignedCharArray> colors =
> vtkSmartPointer<vtkUnsignedCharArray>::New();
> colors->SetNumberOfComponents(3);
> colors->SetName("Colors");
> colors->InsertNextTupleValue(red);
> colors->InsertNextTupleValue(green);
> colors->InsertNextTupleValue(blue);
>
> polydata->GetPointData()->SetScalars(colors);
>
>
> auto pPlane = vtkSmartPointer<vtkPlane>::New();
> std::vector<double> vdNormal = { 0.1, 0, 0 };
> std::vector<double> vdOrigin = {0, 1.0, 0};
>
> pPlane->SetNormal(&vdNormal[0]);
> pPlane->SetOrigin(&vdOrigin[0]);
>
> auto pClipper = vtkSmartPointer<vtkClipDataSet>::New();
> pClipper->SetClipFunction(pPlane);
> pClipper->SetInputData(polydata);
>
> vtkDataSet::SafeDownCast(pClipper->GetInput())->GetPointData()->CopyGlobalIdsOn();
> pClipper->GetOutput()->GetPointData()->CopyGlobalIdsOn();
>
> auto pPt = pClipper->GetOutput()->GetPointData();
>
> vtkDataSet::SafeDownCast(pClipper->GetInput())->GetPointData()->Print(std::cout);
> pClipper->Update();
> // pClipper->GetOutput()->GetPointData()->CopyAllOn();
> pClipper->GetOutput()->GetPointData()->Print(std::cout);
>
> auto nnn0 =
> vtkDataSet::SafeDownCast(pClipper->GetInput())->GetPointData()->GetGlobalIds();
>
> auto a =
> vtkDataSet::SafeDownCast(pClipper->GetInput())->GetPointData()->GetCopyGlobalIds();
> auto a2 = pClipper->GetOutput()->GetPointData()->GetCopyGlobalIds();
> auto nnn = pClipper->GetOutput()->GetPointData()->GetGlobalIds();
>
> The globalids' does pass through vertexFilter. But does not pass through
> the clip filter.
>
> Any help is highly appreciated.
>
> thanks,
>
> Sreeram
>
>
>
>
>
>
> --
> View this message in context: http://vtk.1045678.n5.nabble.com/unable-to-pass-globalids-through-vtk-filters-tp5738851.html
> Sent from the VTK - Users mailing list archive at Nabble.com.
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
More information about the vtkusers
mailing list