|
@@ -1,23 +1,36 @@
|
|
|
+/*
|
|
|
+ * iGeom by LInE
|
|
|
+ * Provides service to construct intersetion point of Geometric Objects (GO)
|
|
|
+ * www.matematica.br/igeom
|
|
|
+ * ./app/components/intersection-component/services/intersection-service.js
|
|
|
+ * @calledby ./app/components/<go>-component/models/<go>-model.js
|
|
|
+ * @version 2020/11/02: Implemented Line instersection
|
|
|
+ */
|
|
|
+
|
|
|
+// Provides service to (any) intersections
|
|
|
class IntersectionService {
|
|
|
- constructor() {
|
|
|
- this.intersectionsMap = new Map()
|
|
|
+
|
|
|
+ constructor () { // load under iGeom initialization
|
|
|
+ this.intersectionsMap = new Map()
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- *
|
|
|
- * @param {[]} intersections
|
|
|
- */
|
|
|
- addIntersections(intersections) {
|
|
|
- const key = intersections.map((intersection) => {
|
|
|
- return `r_${intersection.r.id}_s_${intersection.s.id}`;
|
|
|
- });
|
|
|
- if (this.intersectionsMap.has(key)) {
|
|
|
- this.intersectionsMap.get(key).forEach((x, i) => intersections[i] = x.id);
|
|
|
- delete this.intersectionsMap.get(key);
|
|
|
- this.intersectionsMap.delete(key);
|
|
|
- }
|
|
|
- this.intersectionsMap.set(key, intersections);
|
|
|
- return intersections;
|
|
|
+ // @param {[]} intersections
|
|
|
+ // @calledby ./app/components/intersection-component/drawers/intersection-drawer.js
|
|
|
+ addIntersections (intersections) { try { //D //leo
|
|
|
+ //D console.log("intersection-service.js: addIntersections(" + intersections + ")");
|
|
|
+ const key = intersections.map((intersection) => {
|
|
|
+ return `og1_${intersection.og1.id}_og2_${intersection.og2.id}`;
|
|
|
+ });
|
|
|
+ if (this.intersectionsMap.has(key)) {
|
|
|
+ this.intersectionsMap.get(key).forEach((x, i) => intersections[i] = x.id);
|
|
|
+ delete this.intersectionsMap.get(key);
|
|
|
+ this.intersectionsMap.delete(key);
|
|
|
+ }
|
|
|
+ this.intersectionsMap.set(key, intersections);
|
|
|
+ return intersections;
|
|
|
+ } catch (e) { console.log("app/components/intersection-component/services/intersection-service.js: addIntersections(.): erro!\n" + e.stack); }
|
|
|
}
|
|
|
-}
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
export const intersectionService = new IntersectionService();
|