[vtkusers] Strange problem.

Said. Said.El_Kasmi at sophia.inria.fr
Tue Nov 4 02:46:57 EST 2003


Hi ,

In attachement a java class I use to read a mesh file. When I launch it,
it break immmediately and print the following.

Any idea ?



java.lang.UnsatisfiedLinkError: VTKInit
	at vtk.vtkPoints.VTKInit(Native Method)
	at vtk.vtkObject.<init>(vtkObject.java:98)
	at vtk.vtkPoints.<init>(vtkPoints.java:166)
	at caiman.vizu.vtk.Reader.readMeshFile(Reader.java:62)
	at caiman.vizu.vtk.Reader.main(Reader.java:172)
-------------- next part --------------
package caiman.vizu.vtk;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.StringTokenizer;

import vtk.vtkDataSetWriter;
import vtk.vtkIdList;
import vtk.vtkPoints;
import vtk.vtkUnstructuredGrid;

/*
 * Created on Oct 30, 2003
 */
 
/**
 * @author Said El kasmi - caiman team.
 */
public class Reader {
  
  /** Number of points. */
  private int nbVtx;
  /** Number of elements. */
  private int nbElt;
  /** Number of facets. */
  private int nbFts;
  /** Mesh file name. */
  private String fname;
  /** A vtkPoints onbject to store points.*/
  private vtkPoints points;
  /** A vtkUnstructuredGrid object necessary to build a grid.*/
  private vtkUnstructuredGrid data ;

	public Reader(String fname) {
		this.fname = fname;
	}

  
  /**
   * Read the mesh file given in input. The input mesh file looks
   * like <br>
   * numberOfVertices  numberOfElements  numberOfFacets <br>
   * vertex1 xCoordinate yCoordinate zCoordinate <br>
   * .......... <br>
   * .......... <br>
   * element1 ID1 ID2 ID3 ID4 <br>
   * .......... <br>
   * .......... <br>
   * facet1 ID1 ID2 ID3 FACET_TYPE <br>
   * .......... <br>
   * .......... <br>
   * Where FACET_TYPE tells if the facet is metallic or infinte.
   */
	public void readMeshFile() {
		FileReader reader = null;
		BufferedReader br = null;
		int counter;
		String line;
		try {
			points = new vtkPoints();
			data = new vtkUnstructuredGrid();
			reader = new FileReader(fname);
			br = new BufferedReader(reader);
			line = br.readLine();
			/* Read headers ie. nbVtx, nbElt, nbFts. */
			redaHeaders(line);
			/* Initialize points. */
			points.SetNumberOfPoints(nbVtx);
			/* Read vertices coordinates. */
			for (counter = 0; counter < nbVtx; counter++) {
				line = br.readLine();
				readVertex(line, counter);
			}
			/* Read elements. */
			for (counter = 0; counter < nbElt; counter++) {
				line = br.readLine();
				readElement(line);
			}
			/* Read facets. */
			for (counter = 0; counter < nbFts; counter++) {
				line = br.readLine();
				readFacet(line);
			}
			//
			vtkDataSetWriter dsw = new vtkDataSetWriter();
			dsw.SetInput(data);
			dsw.SetFileName("Falcon.vtk");
			dsw.Write();
			//
		} catch (FileNotFoundException e) {
			e.printStackTrace(System.err);
		} catch (IOException e) {
			e.printStackTrace(System.err);
		} catch (java.lang.Throwable exc) {
			exc.printStackTrace(System.err);
		}
	}
  
  /**
   * The mesh file begin by a line that specifies the number of 
   * vertices, elements and facets. This line lokks like:<br>
   * nbVtx  nbElt  nbFts <br>
   * This method have in charge to read the mesh file header.
   * @param line - Headers line.
   */
  private void redaHeaders(String line){
    StringTokenizer tokenizer = new StringTokenizer(line);
    nbVtx = Integer.parseInt(tokenizer.nextToken());
    nbElt = Integer.parseInt(tokenizer.nextToken());
    nbFts = Integer.parseInt(tokenizer.nextToken());
    System.out.print(nbVtx+" "+nbElt+" "+nbFts);
  }
  
  /**
   * This method takes as parameter a line from the vertices 
   * block and extract from it vertices' coordinates.<br>
   * This line looks like <br>
   * vtxID xCoordinate yCoordinate zCoordinate <br>
   * where vtxID is the vertex identifier (number in the connectivity 
   * table).
   * @param line - A line from the connectivity table.
   */
  private void readVertex(String line,int vtxNumber){
    StringTokenizer tokenizer = new StringTokenizer(line);
    double[] xyz = new double[3];
    xyz[0] = Double.parseDouble(tokenizer.nextToken());
    xyz[1] = Double.parseDouble(tokenizer.nextToken());
    xyz[2] = Double.parseDouble(tokenizer.nextToken());
    points.InsertPoint(vtxNumber,xyz);
  }
  
  /**
   * This method takes as parameter a line from the elements 
   * block and extract from it the list of vertices' identifiers 
   * that constitute the element. This line looks like :<br>
   * vtxID1  vtkID2 vtxID3 ... vtxIDn <br>
   * In Jem3D, n = 4 because it uses tetrahedrons.
   * @param line - A line from the connectivity table.
   */
  private void readElement(String line){
    StringTokenizer tokenizer = new StringTokenizer(line);
    vtkIdList idList = new vtkIdList();
    int[] eltId = new int[4];
    idList.SetNumberOfIds(4);
    eltId[0] = Integer.parseInt(tokenizer.nextToken());
    eltId[1] = Integer.parseInt(tokenizer.nextToken());
    eltId[2] = Integer.parseInt(tokenizer.nextToken());
    eltId[3] = Integer.parseInt(tokenizer.nextToken());
    idList.SetId(0,eltId[0]-1);
    idList.SetId(1,eltId[1]-1);
    idList.SetId(2,eltId[2]-1);
    idList.SetId(3,eltId[3]-1);  
    data.InsertNextCell(10,idList);//In vtk, a Tetra has a the tag 10.
  }
  
  /**
   * This method takes as parameter a line from the facets 
   * block and extract from it the list of vertices' identifiers 
   * that constitute the facet. This line looks like :<br>
   * vtxID1  vtkID2 vtxID3 ftType<br>
   * where ftType is an integer that inform about the facet type.
   * @param line - A line from the connectivity table.
   */
  private void readFacet(String line){
    StringTokenizer tokenizer = new StringTokenizer(line);
  }
  
  public static void main(String[] arg){
    Reader r = new Reader("/net/home/selkasmi/dev2s/Develop/Dev2s-OLD-24-Oct/data/Falcon30514/FALC30514-mesh");
    r.readMeshFile();
  }

}


More information about the vtkusers mailing list