vtkPLYWriter and polydata

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

vtkPLYWriter and polydata

cerina
Hi all,
i divide my mesh to regions with the vtkOctree class, and now, i'm trying to write each region in a ply File. I tried to use the vtkPLYWriter, but i get 2errors:
error LNK1120: 1 unresolved externals
error LNK2019: unresolved external symbol "__declspec(dllimport) public: static class vtkExtractSelection * __cdecl vtkExtractSelection::New(void)" (__imp_?New@vtkExtractSelection@@SAPAV1@XZ) referenced in function "public: static class vtkSmartPointer<class vtkExtractSelection> __cdecl vtkSmartPointer<class vtkExtractSelection>::New(void)" (?New@?$vtkSmartPointer@VvtkExtractSelection@@@@SA?AV1@)

i had this part of code:

// Assign all points to root node
for (int i=0;i<this->Input->GetNumberOfPoints();i++)
PointsNode->SetValue(i,0);

int NumberOfSplitNodes;
int Level=0;
for(int h=0;h<8; h++)
{
.................. // subdividing the octree
}

for(int m=0; m<NumberOfSplitNodes; m++)
{
 vtkSmartPointer<vtkIdTypeArray> ids =
vtkSmartPointer<vtkIdTypeArray>::New();
ids->SetNumberOfComponents(1);
for (int kk=0; kk<this->Input->GetNumberOfCells();kk++)
{
if(PointsNode->GetValue(kk)==m)
ids->InsertNextValue(kk);
}
vtkSmartPointer<vtkSelectionNode> selectionNode =
 vtkSmartPointer<vtkSelectionNode>::New();
 selectionNode->SetFieldType(vtkSelectionNode::CELL);
 selectionNode->SetContentType(vtkSelectionNode::INDICES);
 selectionNode->SetSelectionList(ids);
vtkSmartPointer<vtkSelection> selection =
vtkSmartPointer<vtkSelection>::New();
selection->AddNode(selectionNode);
vtkSmartPointer<vtkExtractSelection> extractSelection =
vtkSmartPointer<vtkExtractSelection>::New();

extractSelection->SetInputData(0, this->Input);
extractSelection->SetInputData(1, selection);

extractSelection->Update();

vtkSmartPointer<vtkUnstructuredGrid> selected =
vtkSmartPointer<vtkUnstructuredGrid>::New();
selected->ShallowCopy(extractSelection->GetOutput());
vtkSmartPointer<vtkPolyData> newdata =
vtkSmartPointer<vtkPolyData>::New();
vtkPoints* cellPoints = selected->GetPoints();
newdata->SetPoints(cellPoints);
vtkPLYWriter *Writer=vtkPLYWriter::New();
        Writer->SetInput(newdata);
std::stringstream strfile;
strfile<<"Region"<<m<<".ply";
Writer->SetFileName(strfile.str().c_str());
Writer->Write();
}

Any help pleaaaaase, and thanks in advance

Cerina
Reply | Threaded
Open this post in threaded view
|

Re: vtkPLYWriter and polydata

David Doria-2-3
On Mon, Sep 17, 2012 at 4:33 AM, cerina <[hidden email]> wrote:
Hi all,
i divide my mesh to regions with the vtkOctree class, and now, i'm trying to
write each region in a ply File. I tried to use the vtkPLYWriter, but i get
2errors:
*error LNK1120: 1 unresolved externals*
*error LNK2019: unresolved external symbol "__declspec(dllimport) public:
static class vtkExtractSelection * __cdecl vtkExtractSelection::New(void)"
(__imp_?New@vtkExtractSelection@@SAPAV1@XZ) referenced in function "public:
static class vtkSmartPointer<class vtkExtractSelection> __cdecl
vtkSmartPointer<class vtkExtractSelection>::New(void)"
(?New@?$vtkSmartPointer@VvtkExtractSelection@@@@SA?AV1@)*

That is a linker error. What does your CMakeLists.txt file look like?

DavidĀ 

_______________________________________________
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

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: vtkPLYWriter and polydata

cerina
David Doria-2-3 wrote
That is a linker error. What does your CMakeLists.txt file look like?

David
thanks for reply. this is my CMakeLists.txt file :
INCLUDE_DIRECTORIES(
    ${VTK_INCLUDE_DIR}
    ${VTKSURFACE_INCLUDE_DIR}
)

ADD_EXECUTABLE(Octree Octree.cxx vtkOctree.cxx)

TARGET_LINK_LIBRARIES(Octree vtkSurface
            vtkCommon
            vtkFiltering
            vtkGraphics
            vtkImaging
            vtkIO
            vtkRendering
            vtkWidgets
vtkHybrid)
Reply | Threaded
Open this post in threaded view
|

Re: vtkPLYWriter and polydata

David Doria-2-3
On Mon, Sep 17, 2012 at 7:45 AM, cerina <[hidden email]> wrote:

>
>
> David Doria-2-3 wrote
> >
> > That is a linker error. What does your CMakeLists.txt file look like?
> >
> > David
> >
> thanks for reply. this is my CMakeLists.txt file :
> INCLUDE_DIRECTORIES(
>     ${VTK_INCLUDE_DIR}
>     ${VTKSURFACE_INCLUDE_DIR}
> )
>
> ADD_EXECUTABLE(Octree Octree.cxx vtkOctree.cxx)
>
> TARGET_LINK_LIBRARIES(Octree vtkSurface
>             vtkCommon
>             vtkFiltering
>             vtkGraphics
>             vtkImaging
>             vtkIO
>             vtkRendering
>             vtkWidgets
> vtkHybrid)


Is that the whole file?

You should certainly have lines like:

find_package(VTK REQUIRED)
include(${VTK_USE_FILE})

and then:

target_link_libraries(ParticleReader ${VTK_LIBRARIES})

(Every example on the wiki has an almost identical CMakeLists.txt, for
example: http://www.vtk.org/Wiki/VTK/Examples/Cxx/IO/ParticleReader )

David
_______________________________________________
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

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: vtkPLYWriter and polydata

cerina
David Doria-2-3 wrote
Is that the whole file?

You should certainly have lines like:

find_package(VTK REQUIRED)
include(${VTK_USE_FILE})

and then:

target_link_libraries(ParticleReader ${VTK_LIBRARIES})

(Every example on the wiki has an almost identical CMakeLists.txt, for
example: http://www.vtk.org/Wiki/VTK/Examples/Cxx/IO/ParticleReader )

David
_______________________________________________
Yeah,this is my whole file. I downloaded this project from internet, i subdivide the mesh into region with octree. I'd like to save each region in a PLY file by using the PLYWriter
Reply | Threaded
Open this post in threaded view
|

Re: vtkPLYWriter and polydata

cerina
In reply to this post by David Doria-2-3
David Doria-2-3 wrote
Is that the whole file?

You should certainly have lines like:

find_package(VTK REQUIRED)
include(${VTK_USE_FILE})

and then:

target_link_libraries(ParticleReader ${VTK_LIBRARIES})

(Every example on the wiki has an almost identical CMakeLists.txt, for
example: http://www.vtk.org/Wiki/VTK/Examples/Cxx/IO/ParticleReader )

David
Thanks David. Your remarque resolved my problem of linking.
But I still have a problem with y selection.
Indeed, this code generate ply file. but when i open them with my proogram, i don't see any thing in the window, as if i don't have a polydata defined in the file.

I think that my selection didn't have nor points neither cells :o .
any help please to correct this problem.

Thaaaaaannnks again


------
cerina
Reply | Threaded
Open this post in threaded view
|

Re: vtkPLYWriter and polydata

cerina
when i open with my program my generated files and i put
cout<<" the number of points in your polydata is "<<polydata->getNumberofPoints();

it shows me that i have 155 points. But i can't see them :(


Regards,

----
Cerina
Reply | Threaded
Open this post in threaded view
|

Re: vtkPLYWriter and polydata

David Doria-2-3
On Mon, Sep 17, 2012 at 9:14 AM, cerina <[hidden email]> wrote:
> when i open with my program my generated files and i put
> cout<<" the number of points in your polydata is
> "<<polydata->getNumberofPoints();
>
> it shows me that i have 155 points. But i can't see them :(

Sounds like you need to add a vertex to each point:
http://www.vtk.org/Wiki/VTK/Examples/Cxx/Filters/vtkVertexGlyphFilter

I suggest you check out:
http://www.vtk.org/Wiki/VTK/Tutorials/GeometryTopology

David
_______________________________________________
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

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: vtkPLYWriter and polydata

cerina
This post was updated on .
oh yeah, i understand now what is going on, when i ewtract, my newdata contains just points without vertices.
have you any suggestion about how to get the vertices that are in the extracted region in order to add them to my newdata.

I mean: if i use:
 vtkIdType v1;
vtkIdType v2;
vtkIdType v3;
vtkIdList *pts=vtkIdList::New();
vtkSmartPointer<vtkIdTypeArray> ids =
vtkSmartPointer<vtkIdTypeArray>::New();
ids->SetNumberOfComponents(1);

vtkSmartPointer<vtkCellArray> vertices = vtkSmartPointer<vtkCellArray>::New();
for (int k=0; k<this->Input->GetNumberOfCells();k++)
{
if(PointsNode->GetValue(k)==m)
{
ids->InsertNextValue(k);
this->Input->GetFaceVertices(k,v1,v2,v3);
pts->InsertNextId(v1);
pts->InsertNextId(v2);
pts->InsertNextId(v3);
vertices->InsertNextCell(pts);
}
}
and then:
newdata->setVerts(vertices);

May be it works!!


Regards

-----
Cerina
Reply | Threaded
Open this post in threaded view
|

Re: vtkPLYWriter and polydata

cerina
it didn't work, i think i have to add vertices and triangles may be