How do I get vertices and edges from indexedfaceset?

Have jReality programming problems or questions? Post them here.
Post Reply
Andre
Posts: 226
Joined: Fri 18. Sep 2009, 11:30

How do I get vertices and edges from indexedfaceset?

Post by Andre » Fri 10. Sep 2010, 18:51

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!!!

		}
	}


User avatar
steffen
Posts: 186
Joined: Fri 16. Jun 2006, 13:30
Location: TU Berlin
Contact:

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

Post by steffen » Sun 12. Sep 2010, 15:50

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.

Andre
Posts: 226
Joined: Fri 18. Sep 2009, 11:30

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

Post by Andre » Sun 12. Sep 2010, 15:52

Ahhh great thanks for your answer.

Post Reply