|
|
|
@ -8,7 +8,7 @@ import { AsVector2, equaln, equalv3, isParallelTo, MoveMatrix, polar, XAxis, YAx
|
|
|
|
|
import { ISpaceParse } from "../../Geometry/SpaceParse/ISpaceParse";
|
|
|
|
|
import { IntersectOption } from "../../GraphicsSystem/IntersectWith";
|
|
|
|
|
import { BoardType } from "../../UI/Store/BoardInterface";
|
|
|
|
|
import { EFullDir, EFullType, EWRackArrayType, IR2WROption, IWineRackOption } from "../../UI/Store/WineRackInterface";
|
|
|
|
|
import { EFullDir, EFullType, EWineRackStyle, EWRackArrayType, IR2WROption, IWineRackOption } from "../../UI/Store/WineRackInterface";
|
|
|
|
|
import { DrawWineRackTool, SIN45 } from "./DrawWinRackTool";
|
|
|
|
|
|
|
|
|
|
export interface IWineRackData
|
|
|
|
@ -30,6 +30,17 @@ export interface IParsePlRes
|
|
|
|
|
isRo?: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface GetWineRackDataOption
|
|
|
|
|
{
|
|
|
|
|
width: number,
|
|
|
|
|
height: number,
|
|
|
|
|
gripWidth: number,
|
|
|
|
|
brThick: number,
|
|
|
|
|
widthCount: number,
|
|
|
|
|
heightCount: number,
|
|
|
|
|
lWRDataList: IWineRackData[],
|
|
|
|
|
rWRDataList: IWineRackData[],
|
|
|
|
|
}
|
|
|
|
|
export const R2WRTolerance = 1e-3;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -92,16 +103,17 @@ export class DrawObliqueWineRackTool extends DrawWineRackTool
|
|
|
|
|
let lWRData: IWineRackData[] = [];
|
|
|
|
|
let rWRData: IWineRackData[] = [];
|
|
|
|
|
let res: { width: number, height: number; };
|
|
|
|
|
let wineRackStyle = config.wineRackStyle;
|
|
|
|
|
switch (config.arrayType)
|
|
|
|
|
{
|
|
|
|
|
case EWRackArrayType.ByWidth:
|
|
|
|
|
res = this.CalcWineRackDataByWidth(lWRData, rWRData);
|
|
|
|
|
res = this.CalcWineRackDataByWidth(lWRData, rWRData, wineRackStyle);
|
|
|
|
|
break;
|
|
|
|
|
case EWRackArrayType.ByCount:
|
|
|
|
|
res = this.CalcWineRackDataByCount(lWRData, rWRData);
|
|
|
|
|
res = this.CalcWineRackDataByCount(lWRData, rWRData, wineRackStyle);
|
|
|
|
|
break;
|
|
|
|
|
case EWRackArrayType.Fixed:
|
|
|
|
|
res = this.CalcWineRackDataByFixed(lWRData, rWRData);
|
|
|
|
|
res = this.CalcWineRackDataByFixed(lWRData, rWRData, wineRackStyle);
|
|
|
|
|
}
|
|
|
|
|
let pls: Polyline[] = [];
|
|
|
|
|
for (let data of lWRData)
|
|
|
|
@ -164,7 +176,7 @@ export class DrawObliqueWineRackTool extends DrawWineRackTool
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
/**按格子宽获取酒格数据 */
|
|
|
|
|
private CalcWineRackDataByWidth(lWRDataList: IWineRackData[], rWRDataList: IWineRackData[])
|
|
|
|
|
private CalcWineRackDataByWidth(lWRDataList: IWineRackData[], rWRDataList: IWineRackData[], wineRackStyle: EWineRackStyle)
|
|
|
|
|
{
|
|
|
|
|
let size = this.space.Size;
|
|
|
|
|
let Config = this.Config;
|
|
|
|
@ -208,12 +220,12 @@ export class DrawObliqueWineRackTool extends DrawWineRackTool
|
|
|
|
|
width = widthCount * gripWidth + 2 * Config.boardThick * SIN45;
|
|
|
|
|
height = size.z;
|
|
|
|
|
}
|
|
|
|
|
this.GetWineRackData(width, height, gripWidth, Config.boardThick, widthCount, heightCount, lWRDataList, rWRDataList);
|
|
|
|
|
this.GetWineRackData({ width, height, gripWidth, brThick: Config.boardThick, widthCount, heightCount, lWRDataList, rWRDataList }, wineRackStyle);
|
|
|
|
|
return {
|
|
|
|
|
width: width, height: height
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
private CalcWineRackDataByCount(lWRDataList: IWineRackData[], rWRDataList: IWineRackData[])
|
|
|
|
|
private CalcWineRackDataByCount(lWRDataList: IWineRackData[], rWRDataList: IWineRackData[], wineRackStyle: EWineRackStyle)
|
|
|
|
|
{
|
|
|
|
|
const config = this.Config;
|
|
|
|
|
const size = this.space.Size;
|
|
|
|
@ -244,12 +256,12 @@ export class DrawObliqueWineRackTool extends DrawWineRackTool
|
|
|
|
|
height = size.z;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.GetWineRackData(width, height, gripWidth, config.boardThick, widthCount, heightCount, lWRDataList, rWRDataList);
|
|
|
|
|
this.GetWineRackData({ width, height, gripWidth, brThick: config.boardThick, widthCount, heightCount, lWRDataList, rWRDataList }, wineRackStyle);
|
|
|
|
|
return {
|
|
|
|
|
width: width, height: height
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
CalcWineRackDataByFixed(lWRDataList: IWineRackData[], rWRDataList: IWineRackData[])
|
|
|
|
|
CalcWineRackDataByFixed(lWRDataList: IWineRackData[], rWRDataList: IWineRackData[], wineRackStyle: EWineRackStyle)
|
|
|
|
|
{
|
|
|
|
|
const config = this.Config;
|
|
|
|
|
let widthCount = Math.floor(config.widthCount * 2);
|
|
|
|
@ -258,7 +270,7 @@ export class DrawObliqueWineRackTool extends DrawWineRackTool
|
|
|
|
|
let width = widthCount * gripWidth + 2 * config.boardThick * SIN45;
|
|
|
|
|
let height = heightCount * gripWidth + 2 * config.boardThick * SIN45;
|
|
|
|
|
|
|
|
|
|
this.GetWineRackData(width, height, gripWidth, config.boardThick, widthCount, heightCount, lWRDataList, rWRDataList);
|
|
|
|
|
this.GetWineRackData({ width, height, gripWidth, brThick: config.boardThick, widthCount, heightCount, lWRDataList, rWRDataList }, wineRackStyle);
|
|
|
|
|
return {
|
|
|
|
|
width: width, height: height
|
|
|
|
|
};
|
|
|
|
@ -326,16 +338,197 @@ export class DrawObliqueWineRackTool extends DrawWineRackTool
|
|
|
|
|
pl.CloseMark = true;
|
|
|
|
|
return pl;
|
|
|
|
|
}
|
|
|
|
|
//获取酒格数据
|
|
|
|
|
GetWineRackData(width: number,
|
|
|
|
|
|
|
|
|
|
GetWineRackData(option: GetWineRackDataOption, wineRackStyle: EWineRackStyle)
|
|
|
|
|
{
|
|
|
|
|
switch (wineRackStyle)
|
|
|
|
|
{
|
|
|
|
|
case EWineRackStyle.Semilattice:
|
|
|
|
|
this.GetWineRackDataPreferentialSemilattice(option);
|
|
|
|
|
break;
|
|
|
|
|
case EWineRackStyle.WholeLattice:
|
|
|
|
|
this.GetWineRackDataPreferentialWholeLattice(option);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取酒格数据半格优先
|
|
|
|
|
* @param {{width: number 总宽
|
|
|
|
|
* height: number 总高
|
|
|
|
|
* gripWidth: number 半格宽
|
|
|
|
|
* brThick: number 板厚
|
|
|
|
|
* widthCount: number 半格宽数量
|
|
|
|
|
* heightCount: number 半格高数量
|
|
|
|
|
* lWRDataList: IWineRackData[], 往左倒
|
|
|
|
|
* rWRDataList: IWineRackData[], 往右倒
|
|
|
|
|
* }} option
|
|
|
|
|
* @memberof DrawObliqueWineRackTool
|
|
|
|
|
*/
|
|
|
|
|
GetWineRackDataPreferentialSemilattice(option: {
|
|
|
|
|
width: number,
|
|
|
|
|
height: number,
|
|
|
|
|
gripWidth: number,
|
|
|
|
|
brThick: number,
|
|
|
|
|
widthCount: number,
|
|
|
|
|
heightCount: number,
|
|
|
|
|
lWRDataList: IWineRackData[], //往左倒
|
|
|
|
|
rWRDataList: IWineRackData[], //往右倒
|
|
|
|
|
})
|
|
|
|
|
{
|
|
|
|
|
const { width, height, gripWidth, brThick, widthCount, heightCount, lWRDataList, rWRDataList } = option;
|
|
|
|
|
/** 板厚对角的一半 */
|
|
|
|
|
const brThickDiagonal = brThick * SIN45;
|
|
|
|
|
|
|
|
|
|
for (let i = 0, Lenght = Math.floor((widthCount + 1) / 2); i < Lenght; i++)
|
|
|
|
|
{
|
|
|
|
|
let p1 = brThickDiagonal + gripWidth * i * 2;
|
|
|
|
|
let data = {
|
|
|
|
|
basePt: new Vector3(p1, 0, 0),
|
|
|
|
|
brLength: 0
|
|
|
|
|
};
|
|
|
|
|
if (width - p1 >= height - brThickDiagonal)
|
|
|
|
|
{
|
|
|
|
|
data.brLength = (height - brThickDiagonal) / SIN45;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
data.brLength = (width - p1) / SIN45;
|
|
|
|
|
}
|
|
|
|
|
rWRDataList.push(data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (let i = 0, Lenght = Math.floor((heightCount - 1) / 2); i < Lenght; i++)
|
|
|
|
|
{
|
|
|
|
|
let p1 = (i + 1) * gripWidth * 2;
|
|
|
|
|
let data = {
|
|
|
|
|
basePt: new Vector3(brThickDiagonal, p1, 0),
|
|
|
|
|
brLength: 0
|
|
|
|
|
};
|
|
|
|
|
if (height - p1 > width - brThickDiagonal)
|
|
|
|
|
{
|
|
|
|
|
data.brLength = (width - brThickDiagonal) / SIN45;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
data.brLength = (height - p1 - brThickDiagonal) / SIN45;
|
|
|
|
|
}
|
|
|
|
|
rWRDataList.push(data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (let i = 0, flag = true, Lenght = Math.floor((widthCount - 1) / 2); i < Lenght; i++)
|
|
|
|
|
{
|
|
|
|
|
let p1 = brThickDiagonal + gripWidth * (i + 1) * 2;
|
|
|
|
|
let data = {
|
|
|
|
|
basePt: new Vector3(p1, brThickDiagonal * 2, 0),
|
|
|
|
|
brLength: 0
|
|
|
|
|
};
|
|
|
|
|
if (p1 >= height - brThickDiagonal)
|
|
|
|
|
{
|
|
|
|
|
if (flag && heightCount % 2 === 0)
|
|
|
|
|
data.brLength = (height - brThickDiagonal * 2) / SIN45;
|
|
|
|
|
else
|
|
|
|
|
data.brLength = (height - brThickDiagonal * 3) / SIN45;
|
|
|
|
|
flag = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
data.brLength = (p1 - brThickDiagonal * 2) / SIN45;
|
|
|
|
|
}
|
|
|
|
|
lWRDataList.push(data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (widthCount % 2 === 0)
|
|
|
|
|
{
|
|
|
|
|
for (let i = 0, flag = true, Lenght = Math.ceil(heightCount / 2); i < Lenght; i++)
|
|
|
|
|
{
|
|
|
|
|
let p1 = height - gripWidth * 2 * (i - 1) - gripWidth * (heightCount % 2 === 0 ? 2 : 1);
|
|
|
|
|
let data = {
|
|
|
|
|
basePt: new Vector3(width - brThickDiagonal, p1, 0),
|
|
|
|
|
brLength: 0
|
|
|
|
|
};
|
|
|
|
|
if (i === 0)
|
|
|
|
|
{
|
|
|
|
|
data.basePt = new Vector3(width, brThickDiagonal, 0);
|
|
|
|
|
if (height === width)
|
|
|
|
|
{
|
|
|
|
|
data.brLength = (width - brThickDiagonal) / SIN45;
|
|
|
|
|
flag = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
data.brLength = (Math.min(width, height) - brThickDiagonal * 2) / SIN45;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (height - p1 + brThickDiagonal * 2 >= width)
|
|
|
|
|
{
|
|
|
|
|
if (flag)
|
|
|
|
|
data.brLength = (width - brThickDiagonal * 2) / SIN45;
|
|
|
|
|
else
|
|
|
|
|
data.brLength = (width - brThickDiagonal * 3) / SIN45;
|
|
|
|
|
flag = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
data.brLength = (height - p1 - brThickDiagonal) / SIN45;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
lWRDataList.push(data);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
for (let i = 0, flag = true, Lenght = Math.floor(heightCount / 2); i < Lenght; i++)
|
|
|
|
|
{
|
|
|
|
|
let p1 = height - gripWidth * 2 * i - gripWidth * (heightCount % 2 === 0 ? 1 : 2);
|
|
|
|
|
let data = {
|
|
|
|
|
basePt: new Vector3(width - brThickDiagonal, p1, 0),
|
|
|
|
|
brLength: 0
|
|
|
|
|
};
|
|
|
|
|
if (height - p1 + brThickDiagonal * 2 >= width)
|
|
|
|
|
{
|
|
|
|
|
if (flag)
|
|
|
|
|
data.brLength = (width - brThickDiagonal * 2) / SIN45;
|
|
|
|
|
else
|
|
|
|
|
data.brLength = (width - brThickDiagonal * 3) / SIN45;
|
|
|
|
|
flag = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
data.brLength = (height - p1 - brThickDiagonal) / SIN45;
|
|
|
|
|
}
|
|
|
|
|
lWRDataList.push(data);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取酒格数据整格优先
|
|
|
|
|
* @param {{width: number 总宽
|
|
|
|
|
* height: number 总高
|
|
|
|
|
* gripWidth: number 半格宽
|
|
|
|
|
* brThick: number 板厚
|
|
|
|
|
* widthCount: number 半格宽数量
|
|
|
|
|
* heightCount: number 半格高数量
|
|
|
|
|
* lWRDataList: IWineRackData[], //往左倒
|
|
|
|
|
* rWRDataList: IWineRackData[], //往右倒
|
|
|
|
|
* }} option
|
|
|
|
|
* @memberof DrawObliqueWineRackTool
|
|
|
|
|
*/
|
|
|
|
|
GetWineRackDataPreferentialWholeLattice(option: {
|
|
|
|
|
width: number,
|
|
|
|
|
height: number,
|
|
|
|
|
gripWidth: number,
|
|
|
|
|
brThick: number,
|
|
|
|
|
widthCount: number,
|
|
|
|
|
heightCount: number,
|
|
|
|
|
lWRDataList: IWineRackData[],
|
|
|
|
|
rWRDataList: IWineRackData[])
|
|
|
|
|
lWRDataList: IWineRackData[], //往左倒
|
|
|
|
|
rWRDataList: IWineRackData[], //往右倒
|
|
|
|
|
})
|
|
|
|
|
{
|
|
|
|
|
const { width, height, gripWidth, brThick, widthCount, heightCount, lWRDataList, rWRDataList } = option;
|
|
|
|
|
let data: IWineRackData;
|
|
|
|
|
for (let i = 0; i < Math.floor(widthCount / 2); i++)
|
|
|
|
|
{
|
|
|
|
|