use of org.twak.tweed.gen.skel.SkelGen in project chordatlas by twak.
the class HouseTool method clickedOn.
@Override
public void clickedOn(Spatial target, Vector3f loc, Vector2f cursorPosition) {
// (Line) new XStream().fromXML( new File( "/home/twak/data/regent/March_30/congo/1/line.xml" ) ));
MegaFeatures mf = new MegaFeatures(new Line(0, 0, 10, 0));
// FeatureCache.readFeatures( new File( "/home/twak/data/regent/March_30/congo/1/0" ), mf );
ImageFeatures imf = new ImageFeatures();
imf.mega = mf;
double[] minMax = new double[] { 0, 15, 0, 25 };
HalfMesh2.Builder builder = new HalfMesh2.Builder(SuperEdge.class, SuperFace.class);
builder.newPoint(new Point2d(minMax[0] + loc.x, minMax[3] + loc.z));
builder.newPoint(new Point2d(minMax[1] + loc.x, minMax[3] + loc.z));
builder.newPoint(new Point2d(minMax[1] + loc.x, minMax[2] + loc.z));
builder.newPoint(new Point2d(minMax[0] + loc.x, minMax[2] + loc.z));
builder.newFace();
HalfMesh2 mesh = builder.done();
Prof p = new Prof();
p.add(new Point2d(0, 0));
p.add(new Point2d(0, 20));
p.add(new Point2d(-5, 25));
boolean first = true;
for (HalfFace f : mesh) {
for (HalfEdge e : f) {
SuperEdge se = (SuperEdge) e;
se.prof = p;
MiniFacade mini = newMini(imf, se.length());
if (true) {
se.addMini(mini);
se.proceduralFacade = mf;
se.toEdit = mini;
if (first)
se.addMini(mini);
}
first = false;
}
SuperFace sf = (SuperFace) f;
sf.maxProfHeights = new ArrayList();
sf.maxProfHeights.add(Double.valueOf(100));
sf.height = 100;
}
SkelGen sg = new SkelGen(mesh, tweed, null);
tweed.frame.addGen(sg, true);
}
use of org.twak.tweed.gen.skel.SkelGen in project chordatlas by twak.
the class SkelFootprintConsole method main.
public static void main(String[] args) {
System.out.println("solving: first arg: input state. second arg: output state");
System.out.println("reconstruction: first arg: input state. outputs as obj. can be given a folder of blocks");
File f = new File(args[0]);
if (!f.exists()) {
System.out.println(args[0] + " not found");
return;
}
if (args.length >= 2) {
System.out.println("running solver");
long runTime = Long.MAX_VALUE;
if (args.length >= 3) {
runTime = Long.parseLong(args[2]);
System.out.println("for " + runTime + " seconds");
}
new SkelFootprintConsole().go((SolverState) new XStream().fromXML(f), new File(args[1]), runTime);
} else if (args.length == 1) {
// File f = new File (args[0]);
ObjDump obj = new ObjDump();
TweedFrame.HEADLESS = true;
TweedFrame tf = new TweedFrame();
SkelGen gen = new SkelGen(tf.tweed);
File out;
if (f.exists() && f.isDirectory()) {
out = new File("combined.obj");
for (File b : f.listFiles()) dump(gen, new File(b, "done.xml"), obj);
} else {
out = new File(args[0] + ".obj");
dump(gen, new File(args[1]), obj);
}
obj.dump(out);
tf.tweed.destroy();
System.exit(0);
} else {
System.out.println("takes 1 or 2 arguments");
return;
}
}
use of org.twak.tweed.gen.skel.SkelGen in project chordatlas by twak.
the class BlockGen method getUI.
@Override
public JComponent getUI() {
JPanel panel = (JPanel) super.getUI();
JButton profiles = new JButton("find profiles");
profiles.addActionListener(e -> doProfile());
JButton panos = new JButton("render panoramas");
panos.addActionListener(e -> renderPanos());
JButton features = new JButton("find image features");
features.addActionListener(e -> segnetFacade());
JButton viewFeatures = new JButton("features viewer");
viewFeatures.addActionListener(e -> viewFeatures());
JButton slice = new JButton("slice");
slice.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new Thread() {
public void run() {
File fs = getSlicedFile();
if (!fs.exists()) {
new SliceSolver(fs, new Slice(getCroppedFile(), getGISFile(), P, false), P);
}
tweed.frame.addGen(new ObjGen(tweed.makeWorkspaceRelative(fs).toString(), tweed), true);
}
}.start();
}
});
JButton tooD = new JButton("slice UI");
tooD.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new Slice(root, ProfileGen.SLICE_SCALE);
}
});
JButton loadSln = new JButton("load last solution");
loadSln.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
File f = getSolutionFile();
if (f.exists()) {
SolverState SS = (SolverState) new XStream().fromXML(f);
SkelFootprint.postProcesss(SS);
// PaintThing.debug.clear();
// new Plot(SS.mesh).add( new ICanPaint() {
//
// @Override
// public void paint( Graphics2D g, PanMouseAdaptor ma ) {
//
// g.setColor( Color.black );
// g.setStroke( new BasicStroke( 2 ) );
//
// if (SS.footprint != null)
// for (Line l : SS.footprint) {
// g.drawLine(
// ma.toX( l.start.x ),
// ma.toY( l.start.y ),
// ma.toX( l.end.x ),
// ma.toY( l.end.y ) );
// }
//
// }
// });
tweed.frame.addGen(new SkelGen(SS.mesh, tweed, BlockGen.this), true);
} else {
JOptionPane.showMessageDialog(tweed.frame(), "Unable to find pre-computed solution.\n" + f);
}
}
});
JTextArea name = new JTextArea(nameCoords());
name.setEditable(false);
panel.add(profiles, 0);
panel.add(panos, 1);
panel.add(features, 2);
panel.add(new JLabel("other:"), 4);
panel.add(slice);
panel.add(viewFeatures);
// panel.add( tooD );
if (getSolutionFile().exists())
panel.add(loadSln);
panel.add(new JLabel("name:"));
panel.add(name);
return panel;
}
use of org.twak.tweed.gen.skel.SkelGen in project chordatlas by twak.
the class ResultsGen method calculate.
@Override
public void calculate() {
synchronized (toAdd) {
for (MeshFile block : toAdd) {
if (block != null) {
Node n = rendered.get(block.file);
if (n != null)
n.removeFromParent();
rendered.remove(block.file);
SkelGen sg = new SkelGen(tweed);
sg.toRender = block.mesh;
sg.parentNode = gNode;
sg.calculate();
ResultsGen.this.gNode.attachChild(sg.gNode);
rendered.put(block.file, sg.gNode);
}
}
toAdd.clear();
}
System.out.println(" before: " + plansIn.get() + " after " + plansOut.get());
System.out.println(" buidling facades: " + meshFacades.get());
System.out.println(" minifacades read: " + Regularizer.miniFacadesUsed + " fac regularised " + Regularizer.regularised + " total images " + Regularizer.seenImages.size());
System.out.println(" total features: " + Regularizer.totalFeature);
gNode.updateModelBound();
gNode.updateGeometricState();
super.calculate();
}
Aggregations