Git Komut Rehberi & Terminal Asistanı
Sıfırdan Yeni Bir Depo Başlatın:
Mevcut Bir Git Deposu veya Klasörü Gönderin:
Hataları Geri Alma, İptal & Temizlik:
Son commit'i geri al (yapılan değişiklikleri korur):
git reset --soft HEAD~1
Yapılan yerel değişiklikleri iptal et (çalışma ağacını temizler):
git restore .
Takip edilmeyen gereksiz dosyaları sil:
git clean -fd
Değişiklikleri geçici sakla ve geri getir (stash):
git stash git stash pop
Dal (Branch) ve Sürüm Etiketleri:
Yeni dal aç ve geçiş yap:
git checkout -b yeni-ozellik git push -u origin yeni-ozellik
Sürüm etiketi (tag) oluştur ve gönder:
git tag -a v1.0.0 -m "Sürüm 1.0.0" git push origin --tags
release: SnapCAD Studio 1.0.10 (desktop menuler, macOS kisayollari, YakNet SSO)
Build and Push Docker Images / build (push) Canceled after 0s
Desktop Release / Build linux desktop (push) Canceled after 0s
Desktop Release / Build windows desktop (push) Canceled after 0s
Desktop Release / Attach packages to release (push) Canceled after 0s
Desktop Release / Build macos desktop (push) Canceled after 0s
CI / Typecheck and unit tests (push) Canceled after 0s
Build and Push Docker Images / build (push) Canceled after 0s
Desktop Release / Build linux desktop (push) Canceled after 0s
Desktop Release / Build windows desktop (push) Canceled after 0s
Desktop Release / Attach packages to release (push) Canceled after 0s
Desktop Release / Build macos desktop (push) Canceled after 0s
CI / Typecheck and unit tests (push) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
solveSketchConstraints,
|
||||
autoConstrainAndSolveSnapCadProfile,
|
||||
} from "@/lib/planegcsSolver";
|
||||
import type { SketchProfile } from "@/types/sketchforge";
|
||||
|
||||
describe("FreeCAD PlaneGCS WASM 2D Constraint Solver", () => {
|
||||
it("solves a constrained 3-4-5 right triangle from imprecise initial points", async () => {
|
||||
const result = await solveSketchConstraints({
|
||||
points: [
|
||||
{ id: "p0", x: 0, y: 0, fixed: true },
|
||||
{ id: "p1", x: 35, y: 2 },
|
||||
{ id: "p2", x: 2, y: 45 },
|
||||
],
|
||||
lines: [
|
||||
{ id: "l01", p1Id: "p0", p2Id: "p1" },
|
||||
{ id: "l02", p1Id: "p0", p2Id: "p2" },
|
||||
{ id: "l12", p1Id: "p1", p2Id: "p2" },
|
||||
],
|
||||
constraints: [
|
||||
{ id: "c1", type: "horizontal", lineId: "l01" },
|
||||
{ id: "c2", type: "vertical", lineId: "l02" },
|
||||
{ id: "c3", type: "distance", p1Id: "p0", p2Id: "p1", distance: 30 },
|
||||
{ id: "c4", type: "distance", p1Id: "p1", p2Id: "p2", distance: 50 },
|
||||
],
|
||||
});
|
||||
|
||||
expect(result.solved).toBe(true);
|
||||
expect(result.dof).toBe(0);
|
||||
const p1 = result.points.find((p) => p.id === "p1")!;
|
||||
const p2 = result.points.find((p) => p.id === "p2")!;
|
||||
expect(p1.x).toBeCloseTo(30, 3);
|
||||
expect(p1.y).toBeCloseTo(0, 3);
|
||||
expect(p2.x).toBeCloseTo(0, 3);
|
||||
expect(p2.y).toBeCloseTo(40, 3);
|
||||
});
|
||||
|
||||
it("solves a line tangent to a fixed-radius circle", async () => {
|
||||
const result = await solveSketchConstraints({
|
||||
points: [
|
||||
{ id: "c_center", x: 50, y: 50, fixed: true },
|
||||
{ id: "p_a", x: 0, y: 72, fixed: true },
|
||||
{ id: "p_b", x: 100, y: 80 },
|
||||
],
|
||||
lines: [{ id: "l_ab", p1Id: "p_a", p2Id: "p_b" }],
|
||||
circles: [{ id: "circle1", centerId: "c_center", radius: 20 }],
|
||||
constraints: [
|
||||
{ id: "c_rad", type: "circle_radius", circleId: "circle1", radius: 20 },
|
||||
{ id: "c_tan", type: "tangent_lc", lineId: "l_ab", circleId: "circle1" },
|
||||
],
|
||||
});
|
||||
|
||||
expect(result.solved).toBe(true);
|
||||
const pa = result.points.find((p) => p.id === "p_a")!;
|
||||
const pb = result.points.find((p) => p.id === "p_b")!;
|
||||
const dist =
|
||||
Math.abs((pb.y - pa.y) * 50 - (pb.x - pa.x) * 50 + pb.x * pa.y - pb.y * pa.x) /
|
||||
Math.hypot(pb.y - pa.y, pb.x - pa.x);
|
||||
expect(dist).toBeCloseTo(20, 2);
|
||||
});
|
||||
|
||||
it("auto-constrains nearly orthogonal SnapCAD sketch profiles to exact axis alignment", async () => {
|
||||
const skewedRect: SketchProfile = {
|
||||
points: [
|
||||
{ id: "p1", x: 0, z: 0 },
|
||||
{ id: "p2", x: 100, z: 2.5 },
|
||||
{ id: "p3", x: 98, z: 51 },
|
||||
{ id: "p4", x: -1.5, z: 49 },
|
||||
],
|
||||
segments: [
|
||||
{ id: "s1", startId: "p1", endId: "p2", kind: "line" },
|
||||
{ id: "s2", startId: "p2", endId: "p3", kind: "line" },
|
||||
{ id: "s3", startId: "p3", endId: "p4", kind: "line" },
|
||||
{ id: "s4", startId: "p4", endId: "p1", kind: "line" },
|
||||
],
|
||||
};
|
||||
|
||||
const solved = await autoConstrainAndSolveSnapCadProfile(skewedRect);
|
||||
expect(solved.solved).toBe(true);
|
||||
expect(solved.appliedConstraintsCount).toBe(4);
|
||||
expect(solved.changedPointsCount).toBeGreaterThanOrEqual(2);
|
||||
|
||||
const p = new Map(solved.profile.points.map((pt) => [pt.id, pt]));
|
||||
expect(p.get("p2")!.z).toBeCloseTo(p.get("p1")!.z, 1);
|
||||
expect(p.get("p3")!.x).toBeCloseTo(p.get("p2")!.x, 1);
|
||||
expect(p.get("p4")!.z).toBeCloseTo(p.get("p3")!.z, 1);
|
||||
expect(p.get("p4")!.x).toBeCloseTo(p.get("p1")!.x, 1);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user