SCM

Discussion Forums: help

Monitor Forum | Start New Thread Start New Thread

 

RE: Make a meshComponent from a set of points [ reply ]
By: Emmanuel Promayon on 2016-06-08 13:08
[forum:3651]
Hi all,

thanks Claude for the question and the feedback, and thanks Aurélien for the definite and correct answer.

Just a little note for Claude: since CamiTK 3.4 the new Frame service is available. That can considerably simplify going from 3D to 2D. You should check the camitk/tutorials/vtkwidget/ContourWidget example of the develop branch and the wiki page about Frame. Transformation from 3D to 2D viewers are now simplified...

Let us know!
Mahnu

RE: Make a meshComponent from a set of points [ reply ]
By: Claude Goubet on 2016-06-08 11:47
[forum:3650]
Super,

Now the lines appear! thanks a lot.

I still have problems with the coordinates. I now need to fix them since the mesh appears on the 3D axis and not on the coronal slice axis.

I will try to convert them using formulas in the previous question: https://forge.imag.fr/forum/message.php?msg_id=1538&group_id=184

I'll update when I get the right formula (or if someone has one before me :) )


Claude

RE: Make a meshComponent from a set of points [ reply ]
By: Aurélien Jaffard on 2016-06-07 10:34
[forum:3649]
Hello Claude, you were close to a working solution

short version
1/ vtk don't display directly the points from a polydata, you have to add some vtkLine to your vtkPolyData to see lines (see long version for more info)
2/ And you have to tell Camitk how to display your mesh


much longer version (steps of my solution)
1/ store points in a vtkPoints
vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
and setting each points :
points->InsertNextPoint(x, y, z);

2/ Store lines in a vtkCellArray
vtkSmartPointer<vtkCellArray> lines = vtkSmartPointer<vtkCellArray>::New();
and for each lines
vtkSmartPointer<vtkLine> line = vtkSmartPointer<vtkLine>::New();
line->GetPointIds()->SetId(0, idBegin);
line->GetPointIds()->SetId(1, idEnd);
lines->InsertNextCell(line);

idBegin & idEnd are the id of the points in vtkPoints.

if you want a line with more than 2 points you may use vtkPolyLine

3/ you may also add a vtkVertex for each points in an other vtkCellArray if you want to show points

4/ you may also add some vtkPolygon in an other vtkCellArray to show the sides of an 3d mesh

5/ create and fill the vtkPolydata
vtkSmartPointer<vtkPolyData> polydata = vtkSmartPointer<vtkPolyData>::New();
add points
polydata->SetPoints(points);
add lines
polydata->SetLines(lines);
add vertices
polydata->SetVerts(vertices);
add polygons
polydata->SetPolys(polygons);

6/ create the MeshComponent
MeshComponent* mesh1 = new MeshComponent(polydata, "mesh1");


7/ define how and where to show the mesh display points display lines
mesh1->setRenderingModes(mesh1->getRenderingModes() | InterfaceGeometry::Points | InterfaceGeometry::Wireframe);
mesh1->setVisibility(InteractiveViewer::getCoronalViewer(), true);
mesh1->refresh();

8/ finally add the mesh actor to the ImageComponent and refresh the application
vtkSmartPointer<vtkActor> meshActor = mesh1->getActor(InterfaceGeometry::Points);
imgC->getCoronalSlices()->addProp("meshActor", meshActor);


And now you can see lines in Coronal viewer

Aurélien


RE: Make a meshComponent from a set of points [ reply ]
By: Claude Goubet on 2016-06-07 09:47
[forum:3648]
So I've got my answer.

No need for a mapper to create a vtkPointSet since vtkPolyData inherits from vtkPointSet.
I just have to use the vtkPolyData to generate the mesh.

I now have a mesh of 70 points. Although it isn't yet displayed in any viewer even though I set the visibility true, but I didn't think yet about it.

Claude

Make a meshComponent from a set of points [ reply ]
By: Claude Goubet on 2016-06-06 15:16
[forum:3647]
Hello,

I wish to display lines on the coronal viewer. To do so I intend to create a mesh (as suggested in the post https://forge.imag.fr/forum/message.php?msg_id=1520&group_id=184 )

I then wish to create a new mesh from a set of points.

I follow the steps bellow (I tried multiple ways and this is the last in date):

1/ I store the points (in my test it contains 70 points)
in the variable of type:
vtkSmartPointer<vtkPoints> points1;

2/ I create a vtkPolyData
vtkSmartPointer<vtkPolyData> points1Polydata = vtkSmartPointer<vtkPolyData>::New();
points1Polydata->SetPoints(points1);

3/ I create a mapper
vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputData(points1Polydata);

4/ From this mapper I create a vtkPointset
vtkSmartPointer<vtkPointSet> set = mapper->GetInput();

5/ From the vtkPointSet I create the mesh
camitk::MeshComponent * mesh1 = new MeshComponent(set, "mesh1");
rightMesh->setVisibility(InteractiveViewer::getCoronalViewer(), true);
rightMesh->refresh();

6/ finaly I add the mesh actor to the ImageComponent and refresh the application

vtkSmartPointer<vtkActor> meshActor = mesh1->getActor(InterfaceGeometry::Points);
imgC->getCoronalSlices()->addProp("meshActor", meshActor);

(imgC->getCoronalSlices()->getProp("meshActor")->SetVisibility(true); makes a call on a null pointer)


When I run this, it does create a mesh but it seems to be empty (Number of points 0, number of cells 0, size in memory 0).

Does anyone know where I made a misstake?

Thanks,

Claude


   
Powered By FusionForge