/** * Update the triangulation by removing the cavity triangles and then filling the cavity with * new triangles. * * @param site the site that created the cavity * @param cavity the triangles with site in their circumcircle * @return one of the new triangles */ private Triangle update(Pnt site, Set<Triangle> cavity) { Set<Set<Pnt>> boundary = new HashSet<Set<Pnt>>(); Set<Triangle> theTriangles = new HashSet<Triangle>(); // Find boundary facets and adjacent triangles for (Triangle triangle : cavity) { theTriangles.addAll(neighbors(triangle)); for (Pnt vertex : triangle) { Set<Pnt> facet = triangle.facetOpposite(vertex); if (boundary.contains(facet)) boundary.remove(facet); else boundary.add(facet); } } theTriangles.removeAll(cavity); // Adj triangles only // Remove the cavity triangles from the triangulation for (Triangle triangle : cavity) triGraph.remove(triangle); // Build each new triangle and add it to the // triangulation Set<Triangle> newTriangles = new HashSet<Triangle>(); for (Set<Pnt> vertices : boundary) { vertices.add(site); Triangle tri = new Triangle(vertices); triGraph.add(tri); newTriangles.add(tri); } // Update the graph links for each new triangle theTriangles.addAll(newTriangles); // Adj triangle + new // triangles for (Triangle triangle : newTriangles) for (Triangle other : theTriangles) if (triangle.isNeighbor(other)) triGraph.add(triangle, other); // Return one of the new triangles return newTriangles.iterator().next(); }
/** * Adds a set of precomputed triples to the deductions store. These do not, themselves, fire any * rules but provide additional axioms that might enable future rule firing when real data is * added. Used to implement bindSchema processing in the parent Reasoner. * * @return return true if the rule set has also been loaded */ protected boolean preloadDeductions(Graph preloadIn) { Graph d = fdeductions.getGraph(); BasicForwardRuleInfGraph preload = (BasicForwardRuleInfGraph) preloadIn; // If the rule set is the same we can reuse those as well if (preload.rules == rules) { // Load raw deductions for (Iterator<Triple> i = preload.find(null, null, null); i.hasNext(); ) { d.add(i.next()); } engine.setRuleStore(preload.engine.getRuleStore()); return true; } else { return false; } }
@Override protected Boolean processMethod() throws AsyncException { Graph d = fdeductions.getGraph(); BasicForwardRuleInfGraph preload = (BasicForwardRuleInfGraph) preloadIn; // If the rule set is the same we can reuse those as well if (preload.rules == rules) { // Load raw deductions for (Iterator<Triple> i = preload.find(getHandler(""), null, null, null); i.hasNext(); ) { d.add(getHandler(""), i.next()); } engine.setRuleStore(preload.engine.getRuleStore()); return true; } else { return false; } }
/** * All sites must fall within the initial triangle. * * @param triangle the initial triangle */ public Triangulation(Triangle triangle) { triGraph = new Graph<Triangle>(); triGraph.add(triangle); mostRecent = triangle; }