List<ModelImpl> hulls = new ArrayList<ModelImpl>();
Node[] nodes = graph.getNodes().toArray();
for (Node n : nodes) {
Node parent = graph.getParent(n);
if (parent != null) {
Group group = (Group) parent;
Model hullModel = group.getGroupData().getHullModel();
if (hullModel != null && hullModel.isCacheMatching(cacheMarker)) {
ConvexHull hull = (ConvexHull) hullModel.getObj();
hull.addNode(n);
hull.setModel(hullModel);
} else if (hullModel != null) {
//Its not the first time the hull exist
ConvexHullModel model = (ConvexHullModel) hullModel;
model.setScale(1f);
hullModel.setCacheMarker(cacheMarker);
hulls.add((ModelImpl) hullModel);
} else {
ConvexHull ch = new ConvexHull();
ch.setMetaNode(parent);
ch.addNode(n);
ModelImpl obj = potInit.initModel(ch);
group.getGroupData().setHullModel(obj);
obj.setCacheMarker(cacheMarker);
hulls.add(obj);
}
}
}