Spaces:
Sleeping
Sleeping
Delete index.html
Browse files- index.html +0 -105
index.html
DELETED
|
@@ -1,105 +0,0 @@
|
|
| 1 |
-
|
| 2 |
-
<!DOCTYPE html>
|
| 3 |
-
<html lang="en">
|
| 4 |
-
<head>
|
| 5 |
-
<meta charset="UTF-8" />
|
| 6 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 7 |
-
<title>DCM Assembly Visualizer</title>
|
| 8 |
-
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
|
| 9 |
-
<style>
|
| 10 |
-
body { font-family: sans-serif; padding: 20px; }
|
| 11 |
-
#plot { width: 100%; height: 700px; }
|
| 12 |
-
</style>
|
| 13 |
-
</head>
|
| 14 |
-
<body>
|
| 15 |
-
<h1>DCM Assembly Visualizer</h1>
|
| 16 |
-
<input type="file" id="file1" accept=".txt"> File A<br>
|
| 17 |
-
<input type="file" id="file2" accept=".txt"> File B<br><br>
|
| 18 |
-
<button onclick="uploadFiles()">Visualize</button>
|
| 19 |
-
<div id="plot"></div>
|
| 20 |
-
|
| 21 |
-
<script>
|
| 22 |
-
async function uploadFiles() {
|
| 23 |
-
const file1 = document.getElementById("file1").files[0];
|
| 24 |
-
const file2 = document.getElementById("file2").files[0];
|
| 25 |
-
|
| 26 |
-
if (!file1 && !file2) {
|
| 27 |
-
alert("Please select at least one file.");
|
| 28 |
-
return;
|
| 29 |
-
}
|
| 30 |
-
|
| 31 |
-
const traces = [];
|
| 32 |
-
|
| 33 |
-
if (file1) {
|
| 34 |
-
const data1 = await sendFile(file1);
|
| 35 |
-
traces.push(...extractTraces(data1, 'File A', 'red', 'blue'));
|
| 36 |
-
}
|
| 37 |
-
|
| 38 |
-
if (file2) {
|
| 39 |
-
const data2 = await sendFile(file2);
|
| 40 |
-
traces.push(...extractTraces(data2, 'File B', 'purple', 'orange'));
|
| 41 |
-
}
|
| 42 |
-
|
| 43 |
-
Plotly.newPlot('plot', traces, {
|
| 44 |
-
margin: { t: 30 },
|
| 45 |
-
scene: { aspectmode: 'data' },
|
| 46 |
-
title: '3D Assembly Viewer'
|
| 47 |
-
});
|
| 48 |
-
}
|
| 49 |
-
|
| 50 |
-
async function sendFile(file) {
|
| 51 |
-
const formData = new FormData();
|
| 52 |
-
formData.append("file", file);
|
| 53 |
-
const res = await fetch("/parse", {
|
| 54 |
-
method: "POST",
|
| 55 |
-
body: formData
|
| 56 |
-
});
|
| 57 |
-
return await res.json();
|
| 58 |
-
}
|
| 59 |
-
|
| 60 |
-
function extractTraces(data, prefix, baseColor, normalColor) {
|
| 61 |
-
const traces = [];
|
| 62 |
-
|
| 63 |
-
for (const [tag, g] of Object.entries(data.geometry)) {
|
| 64 |
-
const [x, y, z] = g.base_point;
|
| 65 |
-
const [nx, ny, nz] = g.normal;
|
| 66 |
-
|
| 67 |
-
traces.push({
|
| 68 |
-
type: 'scatter3d',
|
| 69 |
-
mode: 'markers+text',
|
| 70 |
-
x: [x], y: [y], z: [z],
|
| 71 |
-
marker: { color: baseColor, size: 5 },
|
| 72 |
-
text: [`${prefix}: ${g.label || tag}`],
|
| 73 |
-
textposition: 'top center'
|
| 74 |
-
});
|
| 75 |
-
|
| 76 |
-
traces.push({
|
| 77 |
-
type: 'scatter3d',
|
| 78 |
-
mode: 'lines',
|
| 79 |
-
x: [x, x + nx],
|
| 80 |
-
y: [y, y + ny],
|
| 81 |
-
z: [z, z + nz],
|
| 82 |
-
line: { color: normalColor, width: 3 }
|
| 83 |
-
});
|
| 84 |
-
}
|
| 85 |
-
|
| 86 |
-
for (const c of data.constraints) {
|
| 87 |
-
const g1 = data.geometry[c.from];
|
| 88 |
-
const g2 = data.geometry[c.to];
|
| 89 |
-
if (g1 && g2) {
|
| 90 |
-
const [x1, y1, z1] = g1.base_point;
|
| 91 |
-
const [x2, y2, z2] = g2.base_point;
|
| 92 |
-
traces.push({
|
| 93 |
-
type: 'scatter3d',
|
| 94 |
-
mode: 'lines',
|
| 95 |
-
x: [x1, x2], y: [y1, y2], z: [z1, z2],
|
| 96 |
-
line: { color: 'green', dash: 'dot', width: 2 }
|
| 97 |
-
});
|
| 98 |
-
}
|
| 99 |
-
}
|
| 100 |
-
|
| 101 |
-
return traces;
|
| 102 |
-
}
|
| 103 |
-
</script>
|
| 104 |
-
</body>
|
| 105 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|