Page 1 of 1

How do I get vertices and edges from indexedfaceset?

Posted: Fri 10. Sep 2010, 18:51
by Andre
I have an SceneGraphComponent, with a tetahedron-ifs as geometry. How do I get the
- vertexpositions
- vertexindices
- edgeindices

My Code looks like this:

Code: Select all

	public static void main(String[] args) {
			
			
		// register the reader class for the DEMO-format
		Readers.registerReader("DEMO", ReaderTET.class);
		// register the file ending .demo for files containing DEMO-format data
		Readers.registerFileEndings("DEMO", "tet");
		
		URL fileUrl = MainElasticDef.class.getResource("bunny.tet");
		SceneGraphComponent content = null;
		try {
			content = Readers.read(fileUrl);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		ElasticDef ed = new ElasticDef(content); 
		
		JRViewer v = new JRViewer();
		v.addBasicUI();
		v.addContentSupport(ContentType.CenteredAndScaled);
		v.addContentUI();
		v.setContent(content);
		v.startup();
	}

Code: Select all

	public ElasticDef(SceneGraphComponent content) {
		this.sc= new ArmijoStepController();
		this.sgc = content; 
		
		for (SceneGraphComponent s :sgc.getChildComponents()){
			IndexedFaceSet tet = (IndexedFaceSet) s.getGeometry();
			
			//TODO HELP!!!

		}
	}


Re: How do I get vertices and edges from indexedfaceset?

Posted: Sun 12. Sep 2010, 15:50
by steffen
Hi Andre, sorry for the slow response - you can get the data out of the IndexedFaceSet as follows:

Code: Select all

double[][] vertexPositions = tet.getVertexAttributes(Attribute.COORDINATES).toDoubleArrayArray(null);
int[][] edgeIndices = tet.getEdgeAttributes(Attribute.INDICES).toIntArrayArray(null);
int[][] faceIndices = tet.getFaceAttributes(Attribute.INDICES).toIntArrayArray(null);
The data is copied, so modifying the arrays does not change the geometry...

Steffen.

Re: How do I get vertices and edges from indexedfaceset?

Posted: Sun 12. Sep 2010, 15:52
by Andre
Ahhh great thanks for your answer.