|
|
@ -1,5 +1,4 @@
|
|
|
|
import { Matrix4, Vector2, Vector3 } from "three";
|
|
|
|
import { Matrix4, Vector2, Vector3 } from "three";
|
|
|
|
import { app } from "../../ApplicationServices/Application";
|
|
|
|
|
|
|
|
import { arrayLast, arrayRemoveDuplicateBySort, arraySortByNumber } from "../../Common/ArrayExt";
|
|
|
|
import { arrayLast, arrayRemoveDuplicateBySort, arraySortByNumber } from "../../Common/ArrayExt";
|
|
|
|
import { Board } from "../../DatabaseServices/Entity/Board";
|
|
|
|
import { Board } from "../../DatabaseServices/Entity/Board";
|
|
|
|
import { Line } from "../../DatabaseServices/Entity/Line";
|
|
|
|
import { Line } from "../../DatabaseServices/Entity/Line";
|
|
|
@ -7,9 +6,9 @@ import { Polyline } from "../../DatabaseServices/Entity/Polyline";
|
|
|
|
import { equaln, MoveMatrix, polar, XAxis, YAxis, ZAxis, AsVector2 } from "../../Geometry/GeUtils";
|
|
|
|
import { equaln, MoveMatrix, polar, XAxis, YAxis, ZAxis, AsVector2 } from "../../Geometry/GeUtils";
|
|
|
|
import { ISpaceParse } from "../../Geometry/SpaceParse/ISpaceParse";
|
|
|
|
import { ISpaceParse } from "../../Geometry/SpaceParse/ISpaceParse";
|
|
|
|
import { IntersectOption } from "../../GraphicsSystem/IntersectWith";
|
|
|
|
import { IntersectOption } from "../../GraphicsSystem/IntersectWith";
|
|
|
|
import { EFullDir, EFullType, EWRackArrayType } from "../../UI/Store/WineRackInterface";
|
|
|
|
import { EFullDir, EFullType, EWRackArrayType, IWineRackOption } from "../../UI/Store/WineRackInterface";
|
|
|
|
import { GetMirrorMat } from "../Mirror";
|
|
|
|
|
|
|
|
import { DrawWineRackTool, SIN45 } from "./DrawWinRackTool";
|
|
|
|
import { DrawWineRackTool, SIN45 } from "./DrawWinRackTool";
|
|
|
|
|
|
|
|
import { GetMirrorMat } from "../../Common/Matrix4Utils";
|
|
|
|
|
|
|
|
|
|
|
|
export interface IWineRackData
|
|
|
|
export interface IWineRackData
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -29,10 +28,9 @@ export interface IParsePlRes
|
|
|
|
|
|
|
|
|
|
|
|
export class DrawBlisWineRackTool extends DrawWineRackTool
|
|
|
|
export class DrawBlisWineRackTool extends DrawWineRackTool
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Draw(space: ISpaceParse)
|
|
|
|
Parse(space: ISpaceParse, config: IWineRackOption)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
super.Draw(space);
|
|
|
|
super.Parse(space, config);
|
|
|
|
const config = this.getConfig();
|
|
|
|
|
|
|
|
const size = space.Size;
|
|
|
|
const size = space.Size;
|
|
|
|
const spaceHeight = size.z;
|
|
|
|
const spaceHeight = size.z;
|
|
|
|
const spaceWidth = size.x;
|
|
|
|
const spaceWidth = size.x;
|
|
|
@ -130,22 +128,21 @@ export class DrawBlisWineRackTool extends DrawWineRackTool
|
|
|
|
//补板
|
|
|
|
//补板
|
|
|
|
this.AddLayerOrVerticalBoard(res.width, res.height);
|
|
|
|
this.AddLayerOrVerticalBoard(res.width, res.height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.config = null;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private CalGridWidth(length: number)
|
|
|
|
private CalGridWidth(length: number)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const count = (length - this.config.boardThick * 2 / SIN45) / ((this.config.boardThick + this.config.gripWidth) * Math.sqrt(2));
|
|
|
|
const count = (length - this.Config.boardThick * 2 / SIN45) / ((this.Config.boardThick + this.Config.gripWidth) * Math.sqrt(2));
|
|
|
|
this.config.gripWidth = ((length - this.config.boardThick / SIN45) / Math.floor(count)) / Math.sqrt(2) - this.config.boardThick;
|
|
|
|
this.Config.gripWidth = ((length - this.Config.boardThick / SIN45) / Math.floor(count)) / Math.sqrt(2) - this.Config.boardThick;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/**获取矩形多段线的4个对角点并判断是否有效 */
|
|
|
|
/**获取矩形多段线的4个对角点并判断是否有效 */
|
|
|
|
private GetRect4Pts(xline: Line, rectPl: Polyline, p1: Vector3, p2: Vector3, p3: Vector3, p4: Vector3)
|
|
|
|
private GetRect4Pts(xline: Line, rectPl: Polyline, p1: Vector3, p2: Vector3, p3: Vector3, p4: Vector3)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
let res1 = this.GetRect2Pts(xline, rectPl, p1, p2);
|
|
|
|
let res1 = this.GetRect2Pts(xline, rectPl, p1, p2);
|
|
|
|
let vec = polar(new Vector3(), Math.PI * 0.75, this.config.boardThick);
|
|
|
|
let vec = polar(new Vector3(), Math.PI * 0.75, this.Config.boardThick);
|
|
|
|
xline.ApplyMatrix(MoveMatrix(vec));
|
|
|
|
xline.ApplyMatrix(MoveMatrix(vec));
|
|
|
|
let res2 = this.GetRect2Pts(xline, rectPl, p3, p4);
|
|
|
|
let res2 = this.GetRect2Pts(xline, rectPl, p3, p4);
|
|
|
|
return res1 && res2 && p1.distanceTo(p2) > this.config.gripWidth;
|
|
|
|
return res1 && res2 && p1.distanceTo(p2) > this.Config.gripWidth;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/**获取矩形一边的点 */
|
|
|
|
/**获取矩形一边的点 */
|
|
|
|
private GetRect2Pts(xline: Line, rectPl: Polyline, p1: Vector3, p2: Vector3)
|
|
|
|
private GetRect2Pts(xline: Line, rectPl: Polyline, p1: Vector3, p2: Vector3)
|
|
|
@ -169,55 +166,55 @@ export class DrawBlisWineRackTool extends DrawWineRackTool
|
|
|
|
private CalcWineRackDataByWidth(lWRDataList: IWineRackData[], rWRDataList: IWineRackData[])
|
|
|
|
private CalcWineRackDataByWidth(lWRDataList: IWineRackData[], rWRDataList: IWineRackData[])
|
|
|
|
{
|
|
|
|
{
|
|
|
|
let size = this.space.Size;
|
|
|
|
let size = this.space.Size;
|
|
|
|
let config = this.getConfig();
|
|
|
|
let Config = this.Config;
|
|
|
|
|
|
|
|
|
|
|
|
let widthCount = 0, heightCount = 0, gripWidth = 0;
|
|
|
|
let widthCount = 0, heightCount = 0, gripWidth = 0;
|
|
|
|
let width = size.x - 2 * config.boardThick * SIN45;
|
|
|
|
let width = size.x - 2 * Config.boardThick * SIN45;
|
|
|
|
let height = size.z - 2 * config.boardThick * SIN45;
|
|
|
|
let height = size.z - 2 * Config.boardThick * SIN45;
|
|
|
|
if (config.fullType === EFullType.ByWidth)
|
|
|
|
if (Config.fullType === EFullType.ByWidth)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
widthCount = Math.floor(width / ((config.gripWidth + config.boardThick) * SIN45));
|
|
|
|
widthCount = Math.floor(width / ((Config.gripWidth + Config.boardThick) * SIN45));
|
|
|
|
gripWidth = width / widthCount;
|
|
|
|
gripWidth = width / widthCount;
|
|
|
|
|
|
|
|
|
|
|
|
//处理锁定个数
|
|
|
|
//处理锁定个数
|
|
|
|
if (!config.isLock)
|
|
|
|
if (!Config.isLock)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
heightCount = Math.floor(height / gripWidth);
|
|
|
|
heightCount = Math.floor(height / gripWidth);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
heightCount = Math.floor(config.heightCount * 2);
|
|
|
|
heightCount = Math.floor(Config.heightCount * 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
height = heightCount * gripWidth + 2 * config.boardThick * SIN45;
|
|
|
|
height = heightCount * gripWidth + 2 * Config.boardThick * SIN45;
|
|
|
|
width = size.x;
|
|
|
|
width = size.x;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
heightCount = Math.floor(height / ((config.gripWidth + config.boardThick) * SIN45));
|
|
|
|
heightCount = Math.floor(height / ((Config.gripWidth + Config.boardThick) * SIN45));
|
|
|
|
gripWidth = height / heightCount;
|
|
|
|
gripWidth = height / heightCount;
|
|
|
|
|
|
|
|
|
|
|
|
//处理锁定个数
|
|
|
|
//处理锁定个数
|
|
|
|
|
|
|
|
|
|
|
|
if (!config.isLock)
|
|
|
|
if (!Config.isLock)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
widthCount = Math.floor(width / gripWidth);
|
|
|
|
widthCount = Math.floor(width / gripWidth);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
widthCount = Math.floor(config.widthCount * 2);
|
|
|
|
widthCount = Math.floor(Config.widthCount * 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
width = widthCount * gripWidth + 2 * config.boardThick * SIN45;
|
|
|
|
width = widthCount * gripWidth + 2 * Config.boardThick * SIN45;
|
|
|
|
height = size.z;
|
|
|
|
height = size.z;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.GetWineRackData(width, height, gripWidth, config.boardThick, widthCount, heightCount, lWRDataList, rWRDataList);
|
|
|
|
this.GetWineRackData(width, height, gripWidth, Config.boardThick, widthCount, heightCount, lWRDataList, rWRDataList);
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
width: width, height: height
|
|
|
|
width: width, height: height
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private CalcWineRackDataByCount(lWRDataList: IWineRackData[], rWRDataList: IWineRackData[])
|
|
|
|
private CalcWineRackDataByCount(lWRDataList: IWineRackData[], rWRDataList: IWineRackData[])
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const config = this.getConfig();
|
|
|
|
const config = this.Config;
|
|
|
|
const size = this.space.Size;
|
|
|
|
const size = this.space.Size;
|
|
|
|
let widthCount = Math.floor(config.widthCount * 2);
|
|
|
|
let widthCount = Math.floor(config.widthCount * 2);
|
|
|
|
let heightCount = Math.floor(config.heightCount * 2);
|
|
|
|
let heightCount = Math.floor(config.heightCount * 2);
|
|
|
@ -253,7 +250,7 @@ export class DrawBlisWineRackTool extends DrawWineRackTool
|
|
|
|
}
|
|
|
|
}
|
|
|
|
CalcWineRackDataByFixed(lWRDataList: IWineRackData[], rWRDataList: IWineRackData[])
|
|
|
|
CalcWineRackDataByFixed(lWRDataList: IWineRackData[], rWRDataList: IWineRackData[])
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const config = this.getConfig();
|
|
|
|
const config = this.Config;
|
|
|
|
let widthCount = Math.floor(config.widthCount * 2);
|
|
|
|
let widthCount = Math.floor(config.widthCount * 2);
|
|
|
|
let heightCount = Math.floor(config.heightCount * 2);
|
|
|
|
let heightCount = Math.floor(config.heightCount * 2);
|
|
|
|
let gripWidth = config.gripWidth * SIN45;
|
|
|
|
let gripWidth = config.gripWidth * SIN45;
|
|
|
@ -293,28 +290,28 @@ export class DrawBlisWineRackTool extends DrawWineRackTool
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let minDis = this.config.boardThick / Math.sqrt(2);
|
|
|
|
let minDis = this.Config.boardThick / Math.sqrt(2);
|
|
|
|
//如果左边停靠
|
|
|
|
//如果左边停靠
|
|
|
|
if (p1.x < minDis)
|
|
|
|
if (p1.x < minDis)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
p1.copy(polar(p3.clone(), Math.PI * -0.25, this.config.boardThick));
|
|
|
|
p1.copy(polar(p3.clone(), Math.PI * -0.25, this.Config.boardThick));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
p3.copy(polar(p1.clone(), Math.PI * 0.75, this.config.boardThick));
|
|
|
|
p3.copy(polar(p1.clone(), Math.PI * 0.75, this.Config.boardThick));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//右边点 上面停靠
|
|
|
|
//右边点 上面停靠
|
|
|
|
let size = this.space.Size;
|
|
|
|
let size = this.space.Size;
|
|
|
|
if (p2.y > size.z - minDis)
|
|
|
|
if (p2.y > size.z - minDis)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
p2.copy(polar(p4.clone(), -Math.PI * 0.25, this.config.boardThick));
|
|
|
|
p2.copy(polar(p4.clone(), -Math.PI * 0.25, this.Config.boardThick));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
p4.copy(polar(p2.clone(), Math.PI * 0.75, this.config.boardThick));
|
|
|
|
p4.copy(polar(p2.clone(), Math.PI * 0.75, this.Config.boardThick));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (p1.distanceTo(p2) < (this.config.gripWidth + this.config.boardThick * 1.8) && p1.y > this.config.boardThick * 2)
|
|
|
|
if (p1.distanceTo(p2) < (this.Config.gripWidth + this.Config.boardThick * 1.8) && p1.y > this.Config.boardThick * 2)
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
|
|
let lineData = [p1, p2, p4, p3].map(p =>
|
|
|
|
let lineData = [p1, p2, p4, p3].map(p =>
|
|
|
@ -478,7 +475,7 @@ export class DrawBlisWineRackTool extends DrawWineRackTool
|
|
|
|
/**根据酒格数据获取多段线 */
|
|
|
|
/**根据酒格数据获取多段线 */
|
|
|
|
private CreatePolylineByWineData(data: IWineRackData, isLeft = true)
|
|
|
|
private CreatePolylineByWineData(data: IWineRackData, isLeft = true)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
let thick = this.config.boardThick;
|
|
|
|
let thick = this.Config.boardThick;
|
|
|
|
let lineData = [
|
|
|
|
let lineData = [
|
|
|
|
{
|
|
|
|
{
|
|
|
|
pt: new Vector2(),
|
|
|
|
pt: new Vector2(),
|
|
|
@ -606,7 +603,7 @@ export class DrawBlisWineRackTool extends DrawWineRackTool
|
|
|
|
if (!lData.length)
|
|
|
|
if (!lData.length)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
const config = this.getConfig();
|
|
|
|
const config = this.Config;
|
|
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < lData.length; i++)
|
|
|
|
for (let i = 0; i < lData.length; i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -642,7 +639,7 @@ export class DrawBlisWineRackTool extends DrawWineRackTool
|
|
|
|
br.ApplyMatrix(MoveMatrix(new Vector3(this.space.Size.x - actualWidth)));
|
|
|
|
br.ApplyMatrix(MoveMatrix(new Vector3(this.space.Size.x - actualWidth)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
br.ApplyMatrix(this.space.m_SpaceOCS);
|
|
|
|
br.ApplyMatrix(this.space.m_SpaceOCS);
|
|
|
|
app.Database.ModelSpace.Append(br);
|
|
|
|
this.boardlist.push(br);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -654,7 +651,7 @@ export class DrawBlisWineRackTool extends DrawWineRackTool
|
|
|
|
pl.Create2Pt(new Vector3(), new Vector3(size.y, len));
|
|
|
|
pl.Create2Pt(new Vector3(), new Vector3(size.y, len));
|
|
|
|
pl.CloseMark = true;
|
|
|
|
pl.CloseMark = true;
|
|
|
|
|
|
|
|
|
|
|
|
const config = this.getConfig();
|
|
|
|
const config = this.Config;
|
|
|
|
let addWidth = config.grooveWidthAdd;
|
|
|
|
let addWidth = config.grooveWidthAdd;
|
|
|
|
let leftEdge = config.leftEdge;
|
|
|
|
let leftEdge = config.leftEdge;
|
|
|
|
let rightEdge = config.rightEdge;
|
|
|
|
let rightEdge = config.rightEdge;
|
|
|
|