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
87 lines
3.0 KiB
TypeScript
87 lines
3.0 KiB
TypeScript
import type { SketchPoint, SketchProfile } from "@/types/sketchforge";
|
|||
|
|
|
||
|
|
export type SketchGeometrySelection = {
|
||
|
|
pointIds: readonly string[];
|
||
|
|
segmentIds: readonly string[];
|
||
|
|
imageIds?: readonly string[];
|
||
|
|
};
|
||
|
|
|
||
|
|
export function selectedClosedSketchPoints(
|
||
|
|
profile: SketchProfile,
|
||
|
|
selection: SketchGeometrySelection,
|
||
|
|
): SketchPoint[] | null {
|
||
|
|
if (selection.imageIds?.length) return null;
|
||
|
|
|
||
|
|
const pointIds = new Set(selection.pointIds);
|
||
|
|
const segmentIds = new Set(selection.segmentIds);
|
||
|
|
if (pointIds.size < 3 || segmentIds.size !== pointIds.size) return null;
|
||
|
|
|
||
|
|
const selectedPoints = profile.points.filter((point) => pointIds.has(point.id));
|
||
|
|
if (selectedPoints.length !== pointIds.size) return null;
|
||
|
|
|
||
|
|
const segmentById = new Map(profile.segments.map((segment) => [segment.id, segment]));
|
||
|
|
const adjacency = new Map([...pointIds].map((pointId) => [pointId, new Set<string>()]));
|
||
|
|
|
||
|
|
for (const segmentId of segmentIds) {
|
||
|
|
const segment = segmentById.get(segmentId);
|
||
|
|
if (
|
||
|
|
!segment
|
||
|
|
|| segment.startId === segment.endId
|
||
|
|
|| !pointIds.has(segment.startId)
|
||
|
|
|| !pointIds.has(segment.endId)
|
||
|
|
) {
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
adjacency.get(segment.startId)?.add(segment.endId);
|
||
|
|
adjacency.get(segment.endId)?.add(segment.startId);
|
||
|
|
}
|
||
|
|
|
||
|
|
if ([...adjacency.values()].some((neighbors) => neighbors.size !== 2)) return null;
|
||
|
|
|
||
|
|
const unvisited = new Set(pointIds);
|
||
|
|
while (unvisited.size > 0) {
|
||
|
|
const start = unvisited.values().next().value as string | undefined;
|
||
|
|
if (!start) return null;
|
||
|
|
const stack = [start];
|
||
|
|
let componentSize = 0;
|
||
|
|
while (stack.length > 0) {
|
||
|
|
const pointId = stack.pop();
|
||
|
|
if (!pointId || !unvisited.delete(pointId)) continue;
|
||
|
|
componentSize += 1;
|
||
|
|
adjacency.get(pointId)?.forEach((neighborId) => {
|
||
|
|
if (unvisited.has(neighborId)) stack.push(neighborId);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
if (componentSize < 3) return null;
|
||
|
|
}
|
||
|
|
|
||
|
|
return selectedPoints;
|
||
|
|
}
|
||
|
|
|
||
|
|
export function rotateSketchPoints(points: readonly SketchPoint[], degrees = 45): SketchPoint[] {
|
||
|
|
if (points.length === 0) return [];
|
||
|
|
|
||
|
|
const minX = Math.min(...points.map((point) => point.x));
|
||
|
|
const maxX = Math.max(...points.map((point) => point.x));
|
||
|
|
const minZ = Math.min(...points.map((point) => point.z));
|
||
|
|
const maxZ = Math.max(...points.map((point) => point.z));
|
||
|
|
const pivot = { x: (minX + maxX) / 2, z: (minZ + maxZ) / 2 };
|
||
|
|
const radians = degrees * Math.PI / 180;
|
||
|
|
const cosine = Math.cos(radians);
|
||
|
|
const sine = Math.sin(radians);
|
||
|
|
const rotatePosition = (position: { x: number; z: number }) => {
|
||
|
|
const deltaX = position.x - pivot.x;
|
||
|
|
const deltaZ = position.z - pivot.z;
|
||
|
|
return {
|
||
|
|
x: pivot.x + deltaX * cosine - deltaZ * sine,
|
||
|
|
z: pivot.z + deltaX * sine + deltaZ * cosine,
|
||
|
|
};
|
||
|
|
};
|
||
|
|
|
||
|
|
return points.map((point) => ({
|
||
|
|
...point,
|
||
|
|
...rotatePosition(point),
|
||
|
|
handleIn: point.handleIn ? rotatePosition(point.handleIn) : undefined,
|
||
|
|
handleOut: point.handleOut ? rotatePosition(point.handleOut) : undefined,
|
||
|
|
}));
|
||
|
|
}
|