[vtkusers] Issue with clipping vtkPolyhedron with vtkBoxClipDataSet

Amélie Thery theryame at gmail.com
Thu Jan 14 10:59:44 EST 2016


Hi !
I am trying to clip a vtkPolyhedron in a vtkUnstructuredGrid with a
vtkBoxClipDataSet, but the whole disappears after clipping.
I am using :
vtkSmartPointer<vtkBoxClipDataSet> clipper
=vtkSmartPointer<vtkBoxClipDataSet>::New();
clipper->SetInputData(Grid);
clipper->SetBoxClip(plan[1]->GetNormal(),plan[1]->GetOrigin(),plan[2]->GetNormal(),plan[2]->GetOrigin(),plan[3]->GetNormal(),plan[3]->GetOrigin(),plan[0]->GetNormal(),plan[0]->GetOrigin(),plan[4]->GetNormal(),plan[4]->GetOrigin(),plan[5]->GetNormal(),plan[5]->GetOrigin());
clipper->Update();
vtkDataSetMapper* clipMapper =vtkDataSetMapper::New();
clipMapper->ImmediateModeRenderingOn();
clipMapper->SetInputData(clipper->GetOutput());
actor->SetMapper(clipMapper);

The grid is defined with this function, and without clipping it works :
void CTestMDI2109Doc::MakePolyhedron(int
numpiece,vtkSmartPointer<vtkUnstructuredGrid> uGrid,\
                    vtkSmartPointer<vtkCellArray> hexs,int nbsommet,int
neg0pos1,\
                    int x0y1z2, vtkSmartPointer<vtkPoints> points, float
epaisseur,int nbface, int nbmaxsommetface)
{
      int coef=1; double x=0,y=0,z=0;
    if (neg0pos1==0) coef=-1;
    if (x0y1z2==0)
        x=coef*epaisseur;
    if (x0y1z2==1)
        y=coef*epaisseur;
    if (x0y1z2==2)
        z=coef*epaisseur;

    double* pt;
  vtkSmartPointer<vtkPoints> Points =vtkSmartPointer<vtkPoints>::New();
  for (int i=0; i<nbmaxsommetface; i++){
      Points->InsertNextPoint(points->GetPoint(i));
  }
  for (int j=nbmaxsommetface; j<nbsommet;j++){
      pt=points->GetPoint(j-nbmaxsommetface);
      pt[0]+=x; pt[1]+=y; pt[2]+=z;
      Points->InsertNextPoint(pt);
  }

  vtkIdType PointsIds[NBSOMMETMAX];
  for (int k=0; k<nbsommet; k++){PointsIds[k]=k;}

  vtkIdType Face[NBFACEMAX][NBSOMMETFACEMAX];
  for (int l=0; l<nbface ; l++){
      for (int n=0; n<nbmaxsommetface; n++){
      if (l==0) Face[l][n]=n;
      if (l==1){if (n==0) Face[l][n]=0;
                else if (n==1) Face[l][n]=1;
                else if (n==2) Face[l][n]=6;
                else Face[l][n]=5;}
        if (l==2){if (n==0) Face[l][n]=1;
                else if (n==1) Face[l][n]=2;
                else if (n==2) Face[l][n]=7;
                else Face[l][n]=6;}
      if (l==3){if (n==0) Face[l][n]=2;
                else if (n==1) Face[l][n]=3;
                else if (n==2) Face[l][n]=8;
                else  Face[l][n]=7;}
        if (l==4){if (n==0) Face[l][n]=3;
                else if (n==1) Face[l][n]=4;
                else if (n==2) Face[l][n]=9;
                else  Face[l][n]=8;}
        if (l==5){if (n==0) Face[l][n]=4;
                else if (n==1) Face[l][n]=0;
                else if (n==2) Face[l][n]=5;
                else Face[l][n]=9;}
      if (l==6) Face[l][n]=n+nbmaxsommetface-1;
      }
  }

  vtkSmartPointer<vtkCellArray> Faces =vtkSmartPointer<vtkCellArray>::New();
  for (int i = 0; i < nbface; i++)
    {
   Faces->InsertNextCell(nbmaxsommetface, Face[i]);
    }

  uGrid->InsertNextCell(VTK_POLYHEDRON,nbsommet, PointsIds,nbface,
Faces->GetPointer());
  uGrid->SetPoints(Points);
}

If someone has an any idea :)
Thanks,
Amélie
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160114/618d2288/attachment.html>


More information about the vtkusers mailing list