/* Copyright (c) 1997-2004
Ewgenij Gawrilow, Michael Joswig (Technische Universitaet Berlin, Germany)
http://www.math.tu-berlin.de/polymake, mailto:polymake@math.tu-berlin.de
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version: http://www.gnu.org/licenses/gpl.txt.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
$Project: polymake $$Id: JRealityControl.java 7501 2006-12-12 16:05:54Z thilosch $
*/
package de.tuberlin.polymake.common;
import java.io.BufferedReader;
import java.io.IOException;
import java.nio.channels.Pipe;
import de.jreality.reader.ReaderBSH;
import de.jreality.scene.SceneGraphComponent;
import de.tuberlin.polymake.common.PolymakeControl;
public abstract class JRealityControl extends PolymakeControl {
protected SceneGraphComponent geom;
//protected boolean explodable = false;
public JRealityControl(
BufferedReader psReader,
BufferedReader clientReader,
Pipe.SinkChannel sink) throws IOException{
super(psReader, clientReader, sink);
try {
final ReaderBSH bshReader = new ReaderBSH();
geom = bshReader.getComponent();
final BufferedReader pserver = psReader;
Runnable runner = new Runnable() {
public void run() {
try {
bshReader.processReader(pserver,System.out, System.err);
} catch (Exception e) {
e.printStackTrace();
}
}
};
Thread bshThread = new Thread(runner);
synchronized(geom){
bshThread.start();
geom.wait();
}
}
catch (Exception e) {
e.printStackTrace();
geom=new SceneGraphComponent();
}
bbuf.putInt(1);
}
}
syntax highlighted by Code2HTML, v. 0.9.1