Spaces:
Running

File size: 17,095 Bytes
08149ec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
(() => {
  const toastEl = document.getElementById("copy-toast");

  function showToast(msg) {
    if (!toastEl) return;
    toastEl.textContent = msg;
    setTimeout(() => {
      if (toastEl.textContent === msg) toastEl.textContent = "";
    }, 2200);
  }

  async function copyText(text) {
    try {
      await navigator.clipboard.writeText(text);
    } catch {
      const ta = document.createElement("textarea");
      ta.value = text;
      document.body.appendChild(ta);
      ta.select();
      document.execCommand("copy");
      document.body.removeChild(ta);
    }
    showToast("Copied to clipboard");
  }

  document.querySelectorAll("[data-copy-target]").forEach((btn) => {
    btn.addEventListener("click", () => {
      const target = document.getElementById(btn.dataset.copyTarget);
      if (target) copyText(target.textContent.trim());
    });
  });

  // 1. Video switcher
  const VIDEO_DATA = {
    full: {
      src: "assets/videos/full_paper_demo.mp4",
      poster: "assets/videos/full_paper_demo_poster.jpg",
      title: "Full CAD 2025 Supplemental Video Walkthrough",
      desc: "Complete narrated paper video showcasing patch developability formulation, live interactive Blender drag design, human-in-the-loop seam cutting, quantitative comparisons, and real cardstock fabrication.",
    },
    drag: {
      src: "assets/videos/drag_patch.mp4",
      poster: "assets/videos/drag_patch_poster.jpg",
      title: "Real-Time Optimization under Drag-and-Drop Deformation (Figs. 2 & 7)",
      desc: "As the user drags control points or lattice handles on the irregular triangular patch, cached bidirectional UV sampling maps the surface to a 64x64 masked geometry image and back after coarse-to-fine ResUNet inference.",
    },
    cut: {
      src: "assets/videos/interactive_cut.mp4",
      poster: "assets/videos/interactive_cut_poster.jpg",
      title: "Interactive Piecewise Developable Approximation via Seam Cutting (Fig. 14)",
      desc: "Users mark or sketch seam strokes interactively on complex 3D surfaces; only affected patches are incrementally re-parameterized, optimized in parallel, fused across seams, and post-processed.",
    },
    compare: {
      src: "assets/videos/model_comparison.mp4",
      poster: "assets/videos/model_comparison_poster.jpg",
      title: "360-Degree Turntable Comparison: Bunny, Dog, and Kitten (Fig. 17)",
      desc: "Full visual comparison against Ion et al. (2020), Zhao et al. (2022), and Zhao et al. (2023), showing tighter shape preservation with significantly fewer developable patches.",
    },
    craft: {
      src: "assets/videos/papercraft_making.mp4",
      poster: "assets/videos/papercraft_making_poster.jpg",
      title: "Physical Papercraft Printing, Cutting & Assembly (Fig. 18)",
      desc: "Optimized patches unfold isometrically into planar A4 cutting sheets with matched seam IDs, producing lifelike physical cardstock models.",
    },
  };

  const videoEl = document.getElementById("demo-video");
  const videoSrc = document.getElementById("demo-video-src");
  const videoTitle = document.getElementById("video-title");
  const videoDesc = document.getElementById("video-desc");

  document.querySelectorAll("[data-video]").forEach((btn) => {
    btn.addEventListener("click", () => {
      document.querySelectorAll("[data-video]").forEach((b) => b.classList.remove("active"));
      btn.classList.add("active");
      const info = VIDEO_DATA[btn.dataset.video];
      if (!info || !videoEl) return;
      videoEl.pause();
      videoEl.poster = info.poster;
      videoSrc.src = info.src;
      videoEl.load();
      videoTitle.textContent = info.title;
      videoDesc.textContent = info.desc;
    });
  });

  // 2. Method switcher
  const METHOD_DATA = {
    pipeline: {
      img: "assets/figures/patch_process.jpg",
      title: "Two-Stage Coarse-to-Fine Patch Pipeline (Section 3)",
      desc: "Any surface patch with arbitrary boundary shape (or interior holes) is parameterized with angle-preserving LSCM UV coordinates and resampled into a (64, 64, 4) normalized masked geometry image. Coarse and fine ResUNet stages eliminate Gaussian curvature before barycentric inverse sampling reconstructs the triangular mesh.",
    },
    sampling: {
      img: "assets/figures/sample_inverse.jpg",
      title: "Forward UV Sampling & Inverse Barycentric Reconstruction (Fig. 3)",
      desc: "Points inside triangular mesh faces map onto regular 64x64 pixels via barycentric interpolation, dilated along the boundary to prevent clipping, then inverted back onto arbitrary triangle vertices at sub-millisecond cost.",
    },
    stencils: {
      img: "assets/figures/region_conv.jpg",
      title: "Masked Region, Fairness & Gaussian Curvature Stencils (Eqs. 4-6)",
      desc: "A zero-padded exterior border combined with 5-point cross fairness erosion (W_fair) and 7-point hexagonal Gaussian curvature erosion (W_gc) constrains masked CNN gradients purely inside valid patch pixels.",
    },
    postproc: {
      img: "assets/figures/post_process_vert.jpg",
      title: "Two-Stage Numerical Post-Processing (Section 3.5)",
      desc: "Stage 1 optimizes slit boundary vertices and their 1-ring neighbors with analytical L-BFGS-B gradients; Stage 2 alternates global/local interior refinement (Algorithm 1) until 97%-100% of interior vertices satisfy |K| <= 5e-4 rad.",
    },
    motivation: {
      img: "assets/figures/tang_strip_patch.jpg",
      title: "Motivation: Spline-Based vs. Patch-Based Optimization (Fig. 1)",
      desc: "Compared against spline-strip methods, directly learning developability over arbitrary surface patches enables local surface control with substantially tighter fidelity to reference geometry.",
    },
  };

  const methodImg = document.getElementById("method-img");
  const methodTitle = document.getElementById("method-title");
  const methodDesc = document.getElementById("method-desc");

  document.querySelectorAll("[data-method]").forEach((btn) => {
    btn.addEventListener("click", () => {
      document.querySelectorAll("[data-method]").forEach((b) => b.classList.remove("active"));
      btn.classList.add("active");
      const info = METHOD_DATA[btn.dataset.method];
      if (!info) return;
      methodImg.src = info.img;
      methodTitle.textContent = info.title;
      methodDesc.textContent = info.desc;
    });
  });

  // 3. Before/After model slider
  const SLIDER_MODELS = {
    bunny: {
      before: "assets/renders/bunny_zhao2023.png",
      after: "assets/renders/bunny_ours_final.png",
      stat: "Ours: 6 patches, d_H-a = 0.382% | Zhao2023: 11 patches (paper), 0.729%",
    },
    dog: {
      before: "assets/renders/dog_zhao2023.png",
      after: "assets/renders/dog_ours_final.png",
      stat: "Ours: 10 patches, d_H-a = 0.485% | Zhao2023: 11 patches (paper), 0.843%",
    },
    kitten: {
      before: "assets/renders/kitten_zhao2023.png",
      after: "assets/renders/kitten_ours_final.png",
      stat: "Ours: 11 patches, d_H-a = 0.323% | Baseline: Zhao et al. (2023) visual render",
    },
  };

  const baWrapper = document.getElementById("ba-wrapper");
  const baClip = document.getElementById("ba-before-clip");
  const baDivider = document.getElementById("ba-divider");
  const baRange = document.getElementById("ba-range");
  const baBefore = document.getElementById("ba-before");
  const baAfter = document.getElementById("ba-after");
  const sliderStat = document.getElementById("slider-stat");

  function setSliderPct(pct) {
    const p = Math.max(0, Math.min(100, pct));
    baClip.style.clipPath = `inset(0 ${100 - p}% 0 0)`;
    baDivider.style.left = `${p}%`;
    baRange.value = String(Math.round(p));
  }

  if (baRange && baWrapper) {
    baRange.addEventListener("input", (e) => setSliderPct(Number(e.target.value)));
    let dragging = false;
    const updateFromClientX = (clientX) => {
      const rect = baWrapper.getBoundingClientRect();
      setSliderPct(((clientX - rect.left) / rect.width) * 100);
    };
    baWrapper.addEventListener("pointerdown", (e) => {
      dragging = true;
      updateFromClientX(e.clientX);
    });
    window.addEventListener("pointermove", (e) => {
      if (dragging) updateFromClientX(e.clientX);
    });
    window.addEventListener("pointerup", () => {
      dragging = false;
    });
  }

  document.querySelectorAll("[data-slider-model]").forEach((btn) => {
    btn.addEventListener("click", () => {
      document.querySelectorAll("[data-slider-model]").forEach((b) => b.classList.remove("active"));
      btn.classList.add("active");
      const info = SLIDER_MODELS[btn.dataset.sliderModel];
      if (!info) return;
      baBefore.src = info.before;
      baAfter.src = info.after;
      sliderStat.textContent = info.stat;
    });
  });

  // 4. Multi-model figure gallery
  const MFIG_DATA = {
    compare_other: {
      img: "assets/figures/compare_other.jpg",
      cap: "Visual comparison against Ion et al. (2020), Zhao et al. (2022), and Zhao et al. (2023) on Bunny, Dog, and Kitten (Fig. 17).",
    },
    dog_process: {
      img: "assets/figures/dog_process.jpg",
      cap: "Fig. 15: Step-by-step optimization on Dog (Input -> Coarse+Fine Fusion -> Slit Boundary -> Interior Refinement -> Patch Merging).",
    },
    plot_opt: {
      img: "assets/figures/plot_opt_process.png",
      cap: "Fig. 16: Mean |K| reduction vs. bilateral Hausdorff distance evolution across pipeline stages on Bunny, Dog, and Kitten.",
    },
    metric_hausdorff: {
      img: "assets/figures/metric_hausdorff.jpg",
      cap: "Fig. 5: Comparison of bilateral Hausdorff metrics d_H, d_{H-99}, and d_{H-a} on Smooth vs. Zhao et al. (2023) Bunny.",
    },
    bunny_process: {
      img: "assets/figures/bunny_process.jpg",
      cap: "Appendix Fig. 20: Full optimization stages, Gaussian curvature maps, and Hausdorff error maps on Bunny.",
    },
    kitten_process: {
      img: "assets/figures/kitten_process.jpg",
      cap: "Appendix Fig. 21: Full optimization stages, Gaussian curvature maps, and Hausdorff error maps on Kitten.",
    },
    haus_app: {
      triple: true,
      cap: "Appendix Figs. 22-24: Per-vertex bilateral Hausdorff error heatmaps across baselines vs. Ours on Bunny, Dog, and Kitten.",
    },
  };

  const mfigImg = document.getElementById("mfig-img");
  const mfigTriple = document.getElementById("mfig-triple");
  const mfigCap = document.getElementById("mfig-cap");

  document.querySelectorAll("[data-mfig]").forEach((btn) => {
    btn.addEventListener("click", () => {
      document.querySelectorAll("[data-mfig]").forEach((b) => b.classList.remove("active"));
      btn.classList.add("active");
      const info = MFIG_DATA[btn.dataset.mfig];
      if (!info) return;
      if (info.triple) {
        mfigImg.classList.add("hidden");
        mfigTriple.classList.remove("hidden");
      } else {
        mfigTriple.classList.add("hidden");
        mfigImg.classList.remove("hidden");
        mfigImg.src = info.img;
      }
      mfigCap.textContent = info.cap;
    });
  });

  // 5. Patch robustness gallery
  const PFIG_DATA = {
    drag: {
      img: "assets/figures/drag_patch.jpg",
      cap: "Fig. 7: Real-time drag-and-drop sequence preserving developability across four continuous control-point deformations.",
    },
    smooth: {
      img: "assets/figures/smooth_patch.jpg",
      cap: "Fig. 8: Smooth free-form patches before and after neural developability optimization (curvature reduction 66.6%-92.8%).",
    },
    model: {
      img: "assets/figures/patch_model.jpg",
      cap: "Fig. 9: Complex patches segmented from Bunny, Rabbit, and Einstein models (-99.68% curvature reduction on Einstein).",
    },
    resolution: {
      img: "assets/figures/patch_resolutions.jpg",
      cap: "Fig. 10: Resolution independence across meshes with 500 to 4,096 vertices using fixed 64x64 grid inference.",
    },
    hole: {
      img: "assets/figures/patch_hole.jpg",
      cap: "Fig. 11: Patches containing arbitrary interior holes, arrays, and non-trivial cutouts natively handled by UV masking.",
    },
    nonuniform: {
      img: "assets/figures/patch_nonuniform.jpg",
      cap: "Fig. 12: Robust optimization across uniform and severely non-uniform triangulations (cyclide benchmark).",
    },
    noise: {
      img: "assets/figures/patch_noise.jpg",
      cap: "Fig. 13: Stability under N(0.5%), N(1.0%), and N(2.0%) Gaussian vertex noise (up to 99.21% curvature reduction).",
    },
    gridres: {
      img: "assets/figures/sample_resolution.jpg",
      cap: "Appendix Fig. 19: Bidirectional UV grid reconstruction precision at 32x32 (0.036%), 64x64 (0.017%), and 128x128 (0.008%).",
    },
  };

  const pfigImg = document.getElementById("pfig-img");
  const pfigCap = document.getElementById("pfig-cap");
  document.querySelectorAll("[data-pfig]").forEach((btn) => {
    btn.addEventListener("click", () => {
      document.querySelectorAll("[data-pfig]").forEach((b) => b.classList.remove("active"));
      btn.classList.add("active");
      const info = PFIG_DATA[btn.dataset.pfig];
      if (!info) return;
      pfigImg.src = info.img;
      pfigCap.textContent = info.cap;
    });
  });

  // 6. CLI snippets switcher
  const CODE_DATA = {
    setup: `git clone https://github.com/chaoyunwang/I-DevNet.git
cd I-DevNet
conda create -n idevnet python=3.10 -y && conda activate idevnet
pip install -e ".[full]"
python -m unittest discover -s tests -v`,
    infer: `# Single patch (.obj or .npy) + Stage 2 interior post-processing
python scripts/optimize_patch.py \\
  --input examples/patches/patch_811v.obj \\
  --output outputs/patch_811v_opt.obj \\
  --iters 2 --postprocess

# Segmented multi-patch mesh + seam JSON + A4 papercraft PDF
python scripts/optimize_mesh.py \\
  --input examples/models/bunny/seg_input.obj \\
  --seams examples/models/bunny/seg_seams.json \\
  --output outputs/bunny_opt.obj --iters 2 --slit-postprocess --interior-postprocess
python scripts/export_papercraft_pdf.py --input examples/models/bunny/ours_final.obj --output outputs/bunny.pdf`,
    eval: `# Table 1 quantitative reproduction (Bunny, Dog, Kitten)
python scripts/reproduce_table1.py --output-json outputs/table1.json

# End-to-end segmented pipeline (Bunny, Dog, Kitten from scratch)
python scripts/verify_full_pipeline.py --models bunny,dog,kitten

# All 25 Section 4.2 paper patches + UV sampling error
python scripts/verify_paper_patches.py
python scripts/eval_sampling_error.py`,
    train: `# Download stratified real dataset into datasets/real_sample_subset (see docs/CLOUD_DRIVE_ASSETS.md)
python scripts/run_training_curriculum.py \\
  --data-dir datasets/real_sample_subset \\
  --output-dir runs/full_curriculum

# Or 1-epoch smoke curriculum on included examples/grid_samples/
python scripts/run_training_curriculum.py \\
  --data-dir examples/grid_samples --output-dir runs/smoke \\
  --stages stage1,stage5,opt2,stage6,export --epochs-override 1 --batch-size 2`,
    blender: `# 1. Zip blender_addons/patch_dev_addon/ (or install directly from repo)
# 2. In Blender 3.6 / 4.x / 5.x: Edit -> Preferences -> Add-ons -> Install
# 3. Install Blender Python dependencies if needed:
"<BLENDER_PYTHON>" -m pip install numpy scipy onnxruntime pillow joblib

# 4. Run full headless operator verification inside Blender:
blender --background --python scripts/verify_blender_addon.py -- --output-json outputs/blender_verify.json`,
    studio: `# Launch the Blender-Free Interactive 3D Web Studio (requires only Python + browser)
python scripts/web_studio.py --port 8080

# Includes live ONNX patch sculpting, Stage 2 SciPy interior refine,
# segmented 3D model inspector, and A4 unfolded papercraft PDF export.`,
  };

  const codeEl = document.getElementById("code-snippet");
  const copyCodeBtn = document.getElementById("copy-code-btn");
  document.querySelectorAll("[data-code]").forEach((btn) => {
    btn.addEventListener("click", () => {
      document.querySelectorAll("[data-code]").forEach((b) => b.classList.remove("active"));
      btn.classList.add("active");
      if (codeEl) codeEl.textContent = CODE_DATA[btn.dataset.code] || "";
    });
  });
  if (copyCodeBtn && codeEl) {
    copyCodeBtn.addEventListener("click", () => copyText(codeEl.textContent));
  }

  // 7. Lightbox modal for all figures
  const lightbox = document.getElementById("lightbox");
  const lightboxImg = document.getElementById("lightbox-img");
  const lightboxClose = document.getElementById("lightbox-close");

  document.querySelectorAll(".zoomable").forEach((img) => {
    img.addEventListener("click", () => {
      lightboxImg.src = img.src;
      lightboxImg.alt = img.alt;
      lightbox.classList.remove("hidden");
    });
  });
  const closeBox = () => lightbox && lightbox.classList.add("hidden");
  if (lightboxClose) lightboxClose.addEventListener("click", closeBox);
  if (lightbox) {
    lightbox.addEventListener("click", (e) => {
      if (e.target === lightbox) closeBox();
    });
    window.addEventListener("keydown", (e) => {
      if (e.key === "Escape") closeBox();
    });
  }
})();