refactor: Update wall rendering and aisle position handling, enhance room filtering logic in wall classification

This commit is contained in:
Jerald-Golden-B 2025-06-05 12:23:29 +05:30
parent e4196eee8c
commit db4ec62af8
5 changed files with 39 additions and 13 deletions

View File

@ -283,7 +283,7 @@ export default function Builder() {
plane={plane}
/>
{/* <WallGroup /> */}
<WallGroup />
<AislesGroup />

View File

@ -161,7 +161,7 @@ const FloorPlanGroup = ({ floorPlanGroup, floorPlanGroupLine, floorPlanGroupPoin
}
if (toolMode === "Wall") {
drawWall(raycaster, plane, floorPlanGroupPoint, snappedPoint, isSnapped, isSnappedUUID, line, ispreSnapped, anglesnappedPoint, isAngleSnapped, lines, floorPlanGroupLine, floorPlanGroup, ReferenceLineMesh, LineCreated, currentLayerPoint, dragPointControls, setNewLines, setDeletedLines, activeLayer, socket, projectId);
// drawWall(raycaster, plane, floorPlanGroupPoint, snappedPoint, isSnapped, isSnappedUUID, line, ispreSnapped, anglesnappedPoint, isAngleSnapped, lines, floorPlanGroupLine, floorPlanGroup, ReferenceLineMesh, LineCreated, currentLayerPoint, dragPointControls, setNewLines, setDeletedLines, activeLayer, socket, projectId);
}
if (toolMode === "Floor") {

View File

@ -97,7 +97,7 @@ function Point({ point }: { readonly point: Point }) {
const aisleSnappedPosition = snapPosition(newPosition);
const finalSnappedPosition = checkSnapForAisle(aisleSnappedPosition.position);
setAislePosition(point.pointUuid, finalSnappedPosition.position);
const aisle = setAislePosition(point.pointUuid, finalSnappedPosition.position);
}
} else if (point.pointType === 'Wall') {
if (position) {

View File

@ -68,7 +68,27 @@ export function useWallClassification(walls: Walls) {
// Filter out duplicate rooms (same set of points in different orders)
const uniqueRooms = removeDuplicateRooms(potentialRooms);
return uniqueRooms;
// Remove rooms that fully contain other rooms (i.e., outer enclosing rooms)
const turfRooms = uniqueRooms.map(room => ({
points: room,
polygon: createPolygon(room),
}));
const filteredRooms = turfRooms.filter((roomA, i) => {
// If any other room is strictly inside roomA, mark roomA for deletion
return !turfRooms.some((roomB, j) => {
if (i === j) return false;
// Ensure were not comparing same polygon
const areaA = turf.area(roomA.polygon);
const areaB = turf.area(roomB.polygon);
if (areaB >= areaA) return false;
return turf.booleanWithin(turf.centerOfMass(roomB.polygon), roomA.polygon);
});
});
return filteredRooms.map(room => room.points);
};
// Check if a cycle already exists in our list (considering different orders)
@ -132,7 +152,7 @@ export function useWallClassification(walls: Walls) {
// Rest of the implementation remains the same...
const rooms = useMemo(() => findRooms(), [walls]);
const createPolygon = (points: Point[]) => {
function createPolygon(points: Point[]) {
const coordinates = points.map(p => [p.position[0], p.position[2]]);
return turf.polygon([coordinates]);
};

View File

@ -8,7 +8,7 @@ interface AisleStore {
updateAisle: (uuid: string, updated: Partial<Aisle>) => void;
removeAisle: (uuid: string) => void;
removePoint: (uuid: string) => Aisles;
setPosition: (pointUuid: string, position: [number, number, number]) => void;
setPosition: (pointUuid: string, position: [number, number, number]) => Aisle | undefined;
setLayer: (pointUuid: string, layer: number) => void;
setColor: (aisleUuid: string, color: AisleColors) => void;
@ -75,14 +75,20 @@ export const useAisleStore = create<AisleStore>()(
return removedAisles;
},
setPosition: (pointUuid, position) => set((state) => {
setPosition: (pointUuid, position) => {
let updatedAisle: Aisle | undefined;
set((state) => {
for (const aisle of state.aisles) {
const point = aisle.points.find(p => p.pointUuid === pointUuid);
if (point) {
point.position = position;
updatedAisle = JSON.parse(JSON.stringify(aisle));
}
}
}),
})
return updatedAisle;
},
setLayer: (pointUuid, layer) => set((state) => {
for (const aisle of state.aisles) {