[vtkusers] vtkSTLReader Convert hexadecimal to decimal
David Doria
daviddoria at gmail.com
Wed Feb 1 14:19:19 EST 2012
On Wed, Feb 1, 2012 at 2:02 PM, Bayliss, Chris (Chicago)
<cbayliss at gnresound.com> wrote:
> Hello users,
>
>
>
> I am trying to input an .stl file and print the point count as a base 10
> number. The code below works for printing the point count in hexadecimal,
> but I am having trouble converting that number to a standard base 10
> decimal.
>
>
>
> The errors I am getting are:
>
>
>
> Error C2440: Cannot convert from ‘vtkSTLReader*’ to ‘const char’
>
> Error C2663: ‘strtoul cannot convert parameter 1 from ‘const char’ to ‘const
> char’.
>
>
>
> vtkSTLReader *Reader = vtkSTLReader::New();
>
> Reader->SetFileName(argv[1]);
>
> Reader->Update();
>
> Reader->GetOutput()->GetNumberOfPoints();
>
>
>
> std::cout << Reader << std::endl;
>
>
>
> std::cout << "Reader is of type" <<typeid(Reader).name() << std::endl;
>
>
>
> const char pntcount = Reader;
>
> pntcount->Update();
>
> std::cout<<strtoul( pntcount ,NULL,16);
>
>
>
> std::cin.get();
>
>
>
> Reader->Delete();
>
>
>
> Thanks in advance for the help.
>
>
>
> Chris
Is this what you want?
vtkIdType pntcount = Reader->GetOutput()->GetNumberOfPoints();
Also, I think you should prefer this method to using typeif:
http://www.vtk.org/Wiki/VTK/Examples/Cxx/Utilities/DetermineVariableType
David
More information about the vtkusers
mailing list