[vtkusers] Problem with vtkDataSetWriter

Stevan Dubljevic stevand at seas.ucla.edu
Wed Mar 7 20:06:01 EST 2007


Dear all,
I have a code that work OK on my vtk-5.0 installation on one machine
however the sam code does not compile at another where I installed vtk-5.1
...

however I installed vtk-5.0 also hoping that will work but it gives me an
error ...
problem is in vtkDataSetWriter .... the last two commands are giving error
..

I read vtk file then I applay filter to make entire grid into tetrahedra
and then I threshold to get mesh that I used for FEM  ....

However I started having problems .... with vtkDataSetWriter ....
it says

stevand at stevand-desktop:~/Desktop/SanDiegoHeart$ make
g++ -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\"
-DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"heart1\"
-DVERSION=\"1.0\"  -I. -I.  -I ./                                   -I
/usr/local/include/vtk-5.0         -I /usr/local/include/vtk-5.0/Graphics
-I /usr/local/include/vtk-5.0/IO    -g -O2 -c heart.cpp
In file included from
/usr/lib/gcc/i486-linux-gnu/4.0.3/../../../../include/c++/4.0.3/backward/strstream:51,
                 from /usr/local/include/vtk-5.0/vtkIOStream.h:36,
                 from /usr/local/include/vtk-5.0/vtkSystemIncludes.h:40,
                 from /usr/local/include/vtk-5.0/vtkIndent.h:24,
                 from /usr/local/include/vtk-5.0/vtkObjectBase.h:43,
                 from /usr/local/include/vtk-5.0/vtkObject.h:41,
                 from /usr/local/include/vtk-5.0/vtkAlgorithm.h:32,
                 from /usr/local/include/vtk-5.0/vtkDataReader.h:29,
                 from /usr/local/include/vtk-5.0/vtkDataSetReader.h:34,
                 from heart.cpp:12:
/usr/lib/gcc/i486-linux-gnu/4.0.3/../../../../include/c++/4.0.3/backward/backward_warning.h:32:2:
warning: #warning This file includes at least one deprecated or antiquated
header. Please consider using one of the 32 headers found in section
17.4.1.2 of the C++ standard. Examples include substituting the <X> header
for the <X.h> header for C++ includes, or <iostream> instead of the
deprecated header <iostream.h>. To disable this warning use
-Wno-deprecated.
heart.cpp: In function int main(int, char**):
heart.cpp:107: error: invalid conversion from vtkDataObject* to int
heart.cpp:107: error:   initializing argument 1 of vtkDataSet*
vtkDataSetWriter::GetInput(int)
make: *** [heart.o] Error 1


I belive that there is some kind of trick that can fix this ..... or I am
making some error .. but the same code used to work on other machine .....

Please if you have any hint ....
Thanks a LOT


Here is a code ......



#include "vtkDataSetReader.h"
#include "vtkDataObjectReader.h"
#include "vtkDataSetWriter.h"
#include "vtkDataObjectWriter.h"
#include "vtkPolyDataWriter.h"
#include "vtkUnstructuredGridWriter.h"
#include "vtkDataSetTriangleFilter.h"
#include "vtkThreshold.h"
#include <iostream>
#include <fstream>
#include <vector>

using namespace std;

int main(int argc, char* argv[]){
  string fileName = argv[1];
  string inputFileName = fileName + ".vtk";
  ifstream ifs( inputFileName.c_str() );
  if (!ifs) {
    cerr << "Cannot open file " << inputFileName << endl;
    return (1);
  }
  cout << "Opened file " << inputFileName;
  vector<char> v1(inputFileName.length()+1);
  strcpy( &v1[0],inputFileName.c_str() );
  const char *inputFileNameC = &v1[0];

  //  VTK STUFF BEGINS.
	cout << "Opening input file... "<<endl;
	vtkDataSetReader *reader = vtkDataSetReader::New();
	reader->SetFileName( inputFileNameC );
	cout << "done."<< endl;

	cout << "Creating tetrahedra... ";
	vtkDataSetTriangleFilter  *tetrahedralizator=vtkDataSetTriangleFilter::New();
	tetrahedralizator->SetInput( (vtkDataObject*)(reader->GetOutput()));
	cout << "done."<< endl;

  vtkDataSetWriter *writer = vtkDataSetWriter::New();

  cout << "Thresholding... ";
  vtkThreshold* threshold = vtkThreshold::New();
  threshold->SetInput( (vtkDataObject*)(tetrahedralizator->GetOutput()) );
  threshold->ThresholdBetween(0.5,1);
  cout << "done."<<endl;

  string threshOut;
  threshOut = fileName + "-thresh.vtk";
  writer->SetFileName( threshOut.c_str() );
  writer->SetFileTypeToASCII();
  writer->SetInput( (vtkDataObject*)(threshold->GetOutput()) );
  writer->Write();
  cout << "done." <<endl;
  return (0);
}


**********************************************************
	Stevan Dubljevic, Ph.D
	UCLA Division of Cardiology
	Los Angeles, CA 90095
**********************************************************



More information about the vtkusers mailing list