public TreeSearchProtocol(ShapeGrammarModel grammar, int randomizationLevel) {
super(grammar, randomizationLevel);
}
public boolean executeNext(IProgressMonitor monitor) {
StateExecution state = this.getNext();
if (state == null) {
Debugger.getInstance().addMessage("No possible step found!");
return false;
}
// execute current rule
ShapeModel currentShape = state.getRule().execute(state);
this.getShapeBasket().add(currentShape);
state.setExecuted(true);
// this is the code for finding symmetries in object
// try {
// ArrayList<ShapeModel> shapes =
// ShapeTools.findSubShape(currentShape, currentShape, new ArrayList<ShapeModel>(), 1, this
// .isUseMarkers(), monitor, 100);
//
// System.out.println("Found subshapes: " + shapes.size());
// for (ShapeModel shape : shapes) {
// AffineTransform trans = new AffineTransform(state.getAffineTransform());
// trans.preConcatenate(shape.getInitialTransform());
// StateExecution newState = new StateExecution(
// shape, trans);
//
// // create child of current state
// state.getChildren().add(newState);
//
// // insert this state into protocol
// this.insertState(newState);
// }
//
// } catch (Exception e) {
// e.printStackTrace();
// }
// do postprocessing
// now insert new "shape" state to the execution protocol remembering last transformation
StateExecution newState = new StateExecution(
currentShape, new AffineTransform(state.getAffineTransform()));
// create child of current state
state.getChildren().add(newState);