Skip to content

Commit

Permalink
fix: correct horizontal alignment measurement marks
Browse files Browse the repository at this point in the history
  • Loading branch information
agviegas committed Apr 10, 2024
1 parent 705cfe5 commit fc3de10
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 10 deletions.
19 changes: 14 additions & 5 deletions resources/openbim-components.js
Original file line number Diff line number Diff line change
Expand Up @@ -121394,6 +121394,7 @@ class PlanHighlighter extends CurveHighlighter {
}
showLineInfo(curveMesh, offset) {
this.kpManager.clearMarkersByType("Length");
this.kpManager.clearMarkersByType("Radius");
const positions = curveMesh.geometry.attributes.position.array;
const parallelCurvePoints = this.calculateParallelCurve(positions, positions.length / 3, offset);
const lengthGeometry = new THREE$1.BufferGeometry().setFromPoints(parallelCurvePoints);
Expand All @@ -121415,6 +121416,7 @@ class PlanHighlighter extends CurveHighlighter {
}
showClothoidInfo(curveMesh, offset) {
this.kpManager.clearMarkersByType("Length");
this.kpManager.clearMarkersByType("Radius");
const positions = curveMesh.geometry.attributes.position.array;
const parallelCurvePoints = this.calculateParallelCurve(positions, positions.length / 3, offset);
const lengthGeometry = new THREE$1.BufferGeometry().setFromPoints(parallelCurvePoints);
Expand Down Expand Up @@ -121612,9 +121614,12 @@ class MarkerManager {
manageCluster() {
this.resetMarkers();
for (const marker of this.markers) {
if (!marker.merged) {
if (!marker.merged && !marker.static) {
this.currentKeys.clear();
for (const marker2 of this.markers) {
if (marker2.static) {
continue;
}
if (marker.key !== marker2.key && !marker2.merged) {
const distance = this.distance(marker.label, marker2.label);
if (distance < this._clusterThreeshold) {
Expand Down Expand Up @@ -121694,10 +121699,11 @@ class MarkerManager {
mesh,
key: this._markerKey.toString(),
merged: false,
static: false,
});
this._markerKey++;
}
addMarkerAtPoint(text, point, type) {
addMarkerAtPoint(text, point, type, isStatic = false) {
if (type !== undefined) {
const span = document.createElement("span");
span.innerHTML = text;
Expand All @@ -121710,6 +121716,7 @@ class MarkerManager {
key: this._markerKey.toString(),
merged: false,
type,
static: isStatic,
});
this._markerKey++;
}
Expand Down Expand Up @@ -121750,6 +121757,7 @@ class MarkerManager {
mesh,
key: this._markerKey.toString(),
merged: false,
static: false,
});
this._markerKey++;
}
Expand Down Expand Up @@ -121791,6 +121799,7 @@ class MarkerManager {
key: this._markerKey.toString(),
type,
merged: false,
static: false,
});
this._markerKey++;
return marker;
Expand Down Expand Up @@ -121935,7 +121944,7 @@ class KPManager extends MarkerManager {
const formattedLength = `${length.toFixed(2)} m`;
const midpointIndex = Math.round(count / 2);
const middlePoint = points[midpointIndex];
this.addMarkerAtPoint(formattedLength, middlePoint, "Length");
this.addMarkerAtPoint(formattedLength, middlePoint, "Length", true);
}
showLineLength(line, length) {
const startPoint = new THREE$1.Vector3();
Expand All @@ -121949,7 +121958,7 @@ class KPManager extends MarkerManager {
const formattedLength = `${length.toFixed(2)} m`;
const middlePoint = new THREE$1.Vector3();
middlePoint.addVectors(startPoint, endPoint).multiplyScalar(0.5);
this.addMarkerAtPoint(formattedLength, middlePoint, "Length");
this.addMarkerAtPoint(formattedLength, middlePoint, "Length", true);
}
showCurveRadius(line, radius) {
const startPoint = new THREE$1.Vector3();
Expand All @@ -121963,7 +121972,7 @@ class KPManager extends MarkerManager {
const formattedLength = `R = ${radius.toFixed(2)} m`;
const middlePoint = new THREE$1.Vector3();
middlePoint.addVectors(startPoint, endPoint).multiplyScalar(0.5);
this.addMarkerAtPoint(formattedLength, middlePoint, "Radius");
this.addMarkerAtPoint(formattedLength, middlePoint, "Radius", true);
}
generateStartAndEndKP(mesh) {
const { alignment } = mesh.curve;
Expand Down
6 changes: 3 additions & 3 deletions src/civil/RoadNavigator/src/kp-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class KPManager extends MarkerManager {
const midpointIndex = Math.round(count / 2);
const middlePoint = points[midpointIndex];

this.addMarkerAtPoint(formattedLength, middlePoint, "Length");
this.addMarkerAtPoint(formattedLength, middlePoint, "Length", true);
}

showLineLength(line: THREE.Line, length: number) {
Expand All @@ -61,7 +61,7 @@ export class KPManager extends MarkerManager {
const middlePoint = new THREE.Vector3();
middlePoint.addVectors(startPoint, endPoint).multiplyScalar(0.5);

this.addMarkerAtPoint(formattedLength, middlePoint, "Length");
this.addMarkerAtPoint(formattedLength, middlePoint, "Length", true);
}

showCurveRadius(line: THREE.Line, radius: number) {
Expand All @@ -79,7 +79,7 @@ export class KPManager extends MarkerManager {
const middlePoint = new THREE.Vector3();
middlePoint.addVectors(startPoint, endPoint).multiplyScalar(0.5);

this.addMarkerAtPoint(formattedLength, middlePoint, "Radius");
this.addMarkerAtPoint(formattedLength, middlePoint, "Radius", true);
}

private generateStartAndEndKP(mesh: FRAGS.CurveMesh) {
Expand Down
2 changes: 2 additions & 0 deletions src/civil/RoadPlanNavigator/src/plan-highlighter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ export class PlanHighlighter extends CurveHighlighter {

private showLineInfo(curveMesh: FRAGS.CurveMesh, offset: number) {
this.kpManager.clearMarkersByType("Length");
this.kpManager.clearMarkersByType("Radius");
const positions = curveMesh.geometry.attributes.position.array;
const parallelCurvePoints = this.calculateParallelCurve(
positions,
Expand Down Expand Up @@ -220,6 +221,7 @@ export class PlanHighlighter extends CurveHighlighter {

private showClothoidInfo(curveMesh: FRAGS.CurveMesh, offset: number) {
this.kpManager.clearMarkersByType("Length");
this.kpManager.clearMarkersByType("Radius");
const positions = curveMesh.geometry.attributes.position.array;
const parallelCurvePoints = this.calculateParallelCurve(
positions,
Expand Down
13 changes: 11 additions & 2 deletions src/core/Simple2DMarker/src/marker-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ interface IMarker {
mesh: FRAGS.CurveMesh | THREE.Mesh | THREE.Line;
type?: CivilLabels;
merged: boolean;
static: boolean;
}

interface IGroupedLabels {
Expand Down Expand Up @@ -137,9 +138,12 @@ export class MarkerManager {
this.resetMarkers();

for (const marker of this.markers) {
if (!marker.merged) {
if (!marker.merged && !marker.static) {
this.currentKeys.clear();
for (const marker2 of this.markers) {
if (marker2.static) {
continue;
}
if (marker.key !== marker2.key && !marker2.merged) {
const distance = this.distance(marker.label, marker2.label);
if (distance < this._clusterThreeshold) {
Expand Down Expand Up @@ -232,14 +236,16 @@ export class MarkerManager {
mesh,
key: this._markerKey.toString(),
merged: false,
static: false,
});
this._markerKey++;
}

addMarkerAtPoint(
text: string,
point: THREE.Vector3,
type?: CivilLabels | undefined
type?: CivilLabels | undefined,
isStatic = false
) {
if (type !== undefined) {
const span = document.createElement("span");
Expand All @@ -255,6 +261,7 @@ export class MarkerManager {
key: this._markerKey.toString(),
merged: false,
type,
static: isStatic,
});
this._markerKey++;
} else {
Expand Down Expand Up @@ -323,6 +330,7 @@ export class MarkerManager {
mesh,
key: this._markerKey.toString(),
merged: false,
static: false,
});
this._markerKey++;
}
Expand Down Expand Up @@ -380,6 +388,7 @@ export class MarkerManager {
key: this._markerKey.toString(),
type,
merged: false,
static: false,
});
this._markerKey++;

Expand Down

0 comments on commit fc3de10

Please sign in to comment.