<div dir="ltr"><div><span style="font-size:13px">This also looks fishy.</span></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span style="font-size:13px">ostream *vtkFile = writer->OpenVTKFile();<br></span><span style="font-size:13px">writer->SetHeader("vtkFile");<br></span><span style="font-size:13px">writer->WriteHeader(vtkFile);<br></span><span style="font-size:13px">*vtkFile << "DATASET POLYDATA\n";<br></span><span style="font-size:13px">writer->WritePoints(vtkFile, polyData->GetPoints());<br></span><span style="font-size:13px">writer->WriteCells(vtkFile, polyData->GetPolys(), "POLYGONS");<br></span><span style="font-size:13px">writer->CloseVTKFile(vtkFile);</span></blockquote><div><br></div><div>You shouldn't have to do the low level bits, instead just let the class to the work like so:</div><div>writer->SetInputData(polyData);<br></div><div>writer->Write();</div><div> </div><div class="gmail_extra">hah<br clear="all"><div><div>David E DeMarle<br>Kitware, Inc.<br>R&D Engineer<br>21 Corporate Drive<br>Clifton Park, NY 12065-8662<br>Phone: <a href="tel:518-881-4909" value="+15188814909" target="_blank">518-881-4909</a></div></div>
<br><div class="gmail_quote">On Tue, Mar 8, 2016 at 3:20 PM, Cory Quammen <span dir="ltr"><<a href="mailto:cory.quammen@kitware.com" target="_blank">cory.quammen@kitware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">You can't do this:<br>
<br>
strcat(vrmlFileName, ".vtk");<br>
<br>
You can do this:<br>
<br>
vrmlFileName.append(".vtk");<br>
<br>
HTH,<br>
Cory<br>
<div><div><br>
On Tue, Mar 8, 2016 at 12:41 PM, Jose Soto <<a href="mailto:sotoglzz@gmail.com" target="_blank">sotoglzz@gmail.com</a>> wrote:<br>
><br>
> Dears vtk users:<br>
><br>
> I'm trying to convert a VRML file to a vtk ASCII format using this code from<br>
> this vtk topic:<br>
> <a href="http://vtk.1045678.n5.nabble.com/Conversion-from-VRML-into-VTK-format-td1243521.html#a1243526" rel="noreferrer" target="_blank">http://vtk.1045678.n5.nabble.com/Conversion-from-VRML-into-VTK-format-td1243521.html#a1243526</a><br>
> , here's the code:<br>
><br>
> #include <vtkVRMLImporter.h><br>
> #include <vtkDataSet.h><br>
> #include <vtkActorCollection.h><br>
> #include <vtkPolyData.h><br>
> #include <vtkPolyDataWriter.h><br>
> #include <vtkRenderer.h><br>
> #include <vtkMapper.h><br>
><br>
> int main (int argc, char *argv[]) {<br>
><br>
> std::string Fichier = argv[1];<br>
> std::string vrmlFileName = argv[2];<br>
><br>
> vtkVRMLImporter *imp = vtkVRMLImporter::New();<br>
> imp->SetFileName(Fichier.c_str());<br>
> imp->Read();<br>
> imp->Update();<br>
> vtkDataSet *pDataset;<br>
> vtkActorCollection *actors = imp->GetRenderer()->GetActors();<br>
> actors->InitTraversal();<br>
> pDataset = actors->GetNextActor()->GetMapper()->GetInput();<br>
><br>
> vtkPolyData *polyData = vtkPolyData::SafeDownCast(pDataset);<br>
> polyData->Update();<br>
><br>
> vtkPolyDataWriter *writer = vtkPolyDataWriter::New();<br>
> strcat(vrmlFileName, ".vtk");<br>
> writer->SetFileName(vrmlFileName);<br>
> writer->SetFileTypeToASCII();<br>
><br>
> ostream *vtkFile = writer->OpenVTKFile();<br>
> writer->SetHeader("vtkFile");<br>
> writer->WriteHeader(vtkFile);<br>
> *vtkFile << "DATASET POLYDATA\n";<br>
> writer->WritePoints(vtkFile, polyData->GetPoints());<br>
> writer->WriteCells(vtkFile, polyData->GetPolys(), "POLYGONS");<br>
> writer->CloseVTKFile(vtkFile);<br>
><br>
> return EXIT_SUCCESS;<br>
><br>
> }<br>
><br>
> When I'm trying to compile it I get the following errror<br>
><br>
> [100%] Building CXX object CMakeFiles/VRML.dir/VRML.cxx.o<br>
> /home/trinidad/VRMLConv/VRML.cxx: In function ‘int main(int, const char**)’:<br>
> /home/trinidad/VRMLConv/VRML.cxx:28:28: error: cannot convert ‘std::string<br>
> {aka std::basic_string<char>}’ to ‘char*’ for argument ‘1’ to ‘char*<br>
> strcat(char*, const char*)’<br>
> strcat(vrmlFileName, ".vtk");<br>
><br>
> Can someone give me a little help please??<br>
> Thanks, in advance<br>
> José Soto<br>
><br>
</div></div>> _______________________________________________<br>
> Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
><br>
> Visit other Kitware open-source projects at<br>
> <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
><br>
> Please keep messages on-topic and check the VTK FAQ at:<br>
> <a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
><br>
> Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=vtkusers</a><br>
><br>
> Follow this link to subscribe/unsubscribe:<br>
> <a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a><br>
><br>
<br>
<br>
<br>
--<br>
Cory Quammen<br>
R&D Engineer<br>
Kitware, Inc.<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a><br>
</blockquote></div><br></div></div>