Zunächst einmal mein Code in verkürzter Ausführung:
Code: Select all
var doc = new RDocument(new RMemoryStorage(), new RSpatialIndexNavel()),
di = new RDocumentInterface(doc);
di.importFile(file);
var rects = [];
doc.queryAllEntities(false, false, RS.EntityPolyline).forEach(function (id) {
rects.push(doc.queryEntity(id));
});
var all = doc.queryAllEntities(false, false, [RS.EntityCircle, RS.EntityBlockRef, RS.EntityEllipse, RS.EntityPolyline, RS.EntityHatch, RS.EntityText, RS.EntityLine, RS.EntityAttribute]);
rects.forEach(function (rect) {
var bbA = rect.getBoundingBox().growXY(1e-5),
childs = [];
all.forEach(function (id) {
var ent = doc.queryEntity(id),
bbB = ent.getBoundingBox();
if (bbA.contains(bbB)) {
childs.push(ent);
}
});
});
Kann man das irgendwie mit builtin-Methoden beschleunigen? Ein AABB-Tree wollte ich jetzt nicht einbauen.
Wird der RSpatialIndexNavel überhaupt genutzt oder muss man da noch etwas zusätzlich aufrufen?