支持返回空
This commit is contained in:
		
							
								
								
									
										23
									
								
								api.cjs.js
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								api.cjs.js
									
									
									
									
									
								
							@@ -23207,8 +23207,15 @@ NestCache.NoPutCache = {};
 | 
				
			|||||||
NestCache.CacheRect = new Map();
 | 
					NestCache.CacheRect = new Map();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const TEXT_BOX = NestCache.CreatePath(570, 110);
 | 
					const TEXT_BOX = NestCache.CreatePath(570, 110);
 | 
				
			||||||
//分析文字放置位置
 | 
					/**
 | 
				
			||||||
function ParseRegionTextPos(contour, holes, textBox = TEXT_BOX) {
 | 
					 * 分析文字放置位置
 | 
				
			||||||
 | 
					 * @param contour 轮廓点表
 | 
				
			||||||
 | 
					 * @param holes   网洞点表
 | 
				
			||||||
 | 
					 * @param [textBox=TEXT_BOX] 标签盒子
 | 
				
			||||||
 | 
					 * @param [allowReturnNullPos=false] 允许返回null 当没有找到合适的位置返回null
 | 
				
			||||||
 | 
					 * @returns Vector3
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					function ParseRegionTextPos(contour, holes, textBox = TEXT_BOX, allowReturnNullPos = false) {
 | 
				
			||||||
    let hasTextBox = true;
 | 
					    let hasTextBox = true;
 | 
				
			||||||
    let path = new Path(contour);
 | 
					    let path = new Path(contour);
 | 
				
			||||||
    let nfps = path.GetInsideNFP(textBox)?.map(nfp => Path2Polyline(PathTranslate_Self(PathScale(nfp, 1e-4), path.OrigionMinPoint.x, path.OrigionMinPoint.y))); //可能无法获得
 | 
					    let nfps = path.GetInsideNFP(textBox)?.map(nfp => Path2Polyline(PathTranslate_Self(PathScale(nfp, 1e-4), path.OrigionMinPoint.x, path.OrigionMinPoint.y))); //可能无法获得
 | 
				
			||||||
@@ -23216,7 +23223,7 @@ function ParseRegionTextPos(contour, holes, textBox = TEXT_BOX) {
 | 
				
			|||||||
        nfps = [Path2Polyline(contour)];
 | 
					        nfps = [Path2Polyline(contour)];
 | 
				
			||||||
        hasTextBox = false;
 | 
					        hasTextBox = false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    let holenfps = [];
 | 
					    let holeNFPs = [];
 | 
				
			||||||
    for (let hole of holes) {
 | 
					    for (let hole of holes) {
 | 
				
			||||||
        let hpath = new Path(hole);
 | 
					        let hpath = new Path(hole);
 | 
				
			||||||
        let nfps = hpath.GetOutsideNFP(textBox);
 | 
					        let nfps = hpath.GetOutsideNFP(textBox);
 | 
				
			||||||
@@ -23226,11 +23233,11 @@ function ParseRegionTextPos(contour, holes, textBox = TEXT_BOX) {
 | 
				
			|||||||
        let boxpl = new exports.Polyline().RectangleFrom2Pt(new three.Vector3(box.min.x - 1e5, box.min.y - 1), new three.Vector3(box.max.x + 1e5, box.min.y + 1));
 | 
					        let boxpl = new exports.Polyline().RectangleFrom2Pt(new three.Vector3(box.min.x - 1e5, box.min.y - 1), new three.Vector3(box.max.x + 1e5, box.min.y + 1));
 | 
				
			||||||
        let con1 = Contour.CreateContour(pl, false);
 | 
					        let con1 = Contour.CreateContour(pl, false);
 | 
				
			||||||
        let con2 = Contour.CreateContour(boxpl, false);
 | 
					        let con2 = Contour.CreateContour(boxpl, false);
 | 
				
			||||||
        holenfps.push(...con1.UnionBoolOperation(con2).contours);
 | 
					        holeNFPs.push(...con1.UnionBoolOperation(con2).contours);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    let shapes = nfps.map(pl => new Shape(Contour.CreateContour(pl, false)));
 | 
					    let shapes = nfps.map(pl => new Shape(Contour.CreateContour(pl, false)));
 | 
				
			||||||
    let subShapes = new ShapeManager;
 | 
					    let subShapes = new ShapeManager;
 | 
				
			||||||
    holenfps.forEach(pl => {
 | 
					    holeNFPs.forEach(pl => {
 | 
				
			||||||
        subShapes.UnionBoolOperation(new ShapeManager([new Shape(pl)]));
 | 
					        subShapes.UnionBoolOperation(new ShapeManager([new Shape(pl)]));
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    let resShapes = [];
 | 
					    let resShapes = [];
 | 
				
			||||||
@@ -23238,8 +23245,12 @@ function ParseRegionTextPos(contour, holes, textBox = TEXT_BOX) {
 | 
				
			|||||||
        // TestDraw(shape.Outline.Curve, 6);
 | 
					        // TestDraw(shape.Outline.Curve, 6);
 | 
				
			||||||
        resShapes.push(...shape.SubstactBoolOperation(subShapes.ShapeList)); //可能减完丢了
 | 
					        resShapes.push(...shape.SubstactBoolOperation(subShapes.ShapeList)); //可能减完丢了
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (resShapes.length === 0)
 | 
					    if (resShapes.length === 0) {
 | 
				
			||||||
 | 
					        //允许返回空的点 因为无法放置
 | 
				
			||||||
 | 
					        if (allowReturnNullPos)
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
        resShapes = shapes;
 | 
					        resShapes = shapes;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    let maxDist = -Infinity;
 | 
					    let maxDist = -Infinity;
 | 
				
			||||||
    let minp;
 | 
					    let minp;
 | 
				
			||||||
    for (let shape of resShapes) {
 | 
					    for (let shape of resShapes) {
 | 
				
			||||||
 
 | 
				
			|||||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										23
									
								
								api.esm.js
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								api.esm.js
									
									
									
									
									
								
							@@ -23180,8 +23180,15 @@ NestCache.NoPutCache = {};
 | 
				
			|||||||
NestCache.CacheRect = new Map();
 | 
					NestCache.CacheRect = new Map();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const TEXT_BOX = NestCache.CreatePath(570, 110);
 | 
					const TEXT_BOX = NestCache.CreatePath(570, 110);
 | 
				
			||||||
//分析文字放置位置
 | 
					/**
 | 
				
			||||||
function ParseRegionTextPos(contour, holes, textBox = TEXT_BOX) {
 | 
					 * 分析文字放置位置
 | 
				
			||||||
 | 
					 * @param contour 轮廓点表
 | 
				
			||||||
 | 
					 * @param holes   网洞点表
 | 
				
			||||||
 | 
					 * @param [textBox=TEXT_BOX] 标签盒子
 | 
				
			||||||
 | 
					 * @param [allowReturnNullPos=false] 允许返回null 当没有找到合适的位置返回null
 | 
				
			||||||
 | 
					 * @returns Vector3
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					function ParseRegionTextPos(contour, holes, textBox = TEXT_BOX, allowReturnNullPos = false) {
 | 
				
			||||||
    let hasTextBox = true;
 | 
					    let hasTextBox = true;
 | 
				
			||||||
    let path = new Path(contour);
 | 
					    let path = new Path(contour);
 | 
				
			||||||
    let nfps = path.GetInsideNFP(textBox)?.map(nfp => Path2Polyline(PathTranslate_Self(PathScale(nfp, 1e-4), path.OrigionMinPoint.x, path.OrigionMinPoint.y))); //可能无法获得
 | 
					    let nfps = path.GetInsideNFP(textBox)?.map(nfp => Path2Polyline(PathTranslate_Self(PathScale(nfp, 1e-4), path.OrigionMinPoint.x, path.OrigionMinPoint.y))); //可能无法获得
 | 
				
			||||||
@@ -23189,7 +23196,7 @@ function ParseRegionTextPos(contour, holes, textBox = TEXT_BOX) {
 | 
				
			|||||||
        nfps = [Path2Polyline(contour)];
 | 
					        nfps = [Path2Polyline(contour)];
 | 
				
			||||||
        hasTextBox = false;
 | 
					        hasTextBox = false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    let holenfps = [];
 | 
					    let holeNFPs = [];
 | 
				
			||||||
    for (let hole of holes) {
 | 
					    for (let hole of holes) {
 | 
				
			||||||
        let hpath = new Path(hole);
 | 
					        let hpath = new Path(hole);
 | 
				
			||||||
        let nfps = hpath.GetOutsideNFP(textBox);
 | 
					        let nfps = hpath.GetOutsideNFP(textBox);
 | 
				
			||||||
@@ -23199,11 +23206,11 @@ function ParseRegionTextPos(contour, holes, textBox = TEXT_BOX) {
 | 
				
			|||||||
        let boxpl = new Polyline().RectangleFrom2Pt(new Vector3(box.min.x - 1e5, box.min.y - 1), new Vector3(box.max.x + 1e5, box.min.y + 1));
 | 
					        let boxpl = new Polyline().RectangleFrom2Pt(new Vector3(box.min.x - 1e5, box.min.y - 1), new Vector3(box.max.x + 1e5, box.min.y + 1));
 | 
				
			||||||
        let con1 = Contour.CreateContour(pl, false);
 | 
					        let con1 = Contour.CreateContour(pl, false);
 | 
				
			||||||
        let con2 = Contour.CreateContour(boxpl, false);
 | 
					        let con2 = Contour.CreateContour(boxpl, false);
 | 
				
			||||||
        holenfps.push(...con1.UnionBoolOperation(con2).contours);
 | 
					        holeNFPs.push(...con1.UnionBoolOperation(con2).contours);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    let shapes = nfps.map(pl => new Shape(Contour.CreateContour(pl, false)));
 | 
					    let shapes = nfps.map(pl => new Shape(Contour.CreateContour(pl, false)));
 | 
				
			||||||
    let subShapes = new ShapeManager;
 | 
					    let subShapes = new ShapeManager;
 | 
				
			||||||
    holenfps.forEach(pl => {
 | 
					    holeNFPs.forEach(pl => {
 | 
				
			||||||
        subShapes.UnionBoolOperation(new ShapeManager([new Shape(pl)]));
 | 
					        subShapes.UnionBoolOperation(new ShapeManager([new Shape(pl)]));
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    let resShapes = [];
 | 
					    let resShapes = [];
 | 
				
			||||||
@@ -23211,8 +23218,12 @@ function ParseRegionTextPos(contour, holes, textBox = TEXT_BOX) {
 | 
				
			|||||||
        // TestDraw(shape.Outline.Curve, 6);
 | 
					        // TestDraw(shape.Outline.Curve, 6);
 | 
				
			||||||
        resShapes.push(...shape.SubstactBoolOperation(subShapes.ShapeList)); //可能减完丢了
 | 
					        resShapes.push(...shape.SubstactBoolOperation(subShapes.ShapeList)); //可能减完丢了
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (resShapes.length === 0)
 | 
					    if (resShapes.length === 0) {
 | 
				
			||||||
 | 
					        //允许返回空的点 因为无法放置
 | 
				
			||||||
 | 
					        if (allowReturnNullPos)
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
        resShapes = shapes;
 | 
					        resShapes = shapes;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    let maxDist = -Infinity;
 | 
					    let maxDist = -Infinity;
 | 
				
			||||||
    let minp;
 | 
					    let minp;
 | 
				
			||||||
    for (let shape of resShapes) {
 | 
					    for (let shape of resShapes) {
 | 
				
			||||||
 
 | 
				
			|||||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							@@ -1,5 +1,13 @@
 | 
				
			|||||||
import { Vector3 } from "three";
 | 
					import { Vector3 } from "three";
 | 
				
			||||||
import { Point } from "../../../Nest/Common/Point";
 | 
					import { Point } from "../../../Nest/Common/Point";
 | 
				
			||||||
import { Path } from "../../../Nest/Core/Path";
 | 
					import { Path } from "../../../Nest/Core/Path";
 | 
				
			||||||
export declare function ParseRegionTextPos(contour: Point[], holes: (Point[])[], textBox?: Path): Vector3;
 | 
					/**
 | 
				
			||||||
 | 
					 * 分析文字放置位置
 | 
				
			||||||
 | 
					 * @param contour 轮廓点表
 | 
				
			||||||
 | 
					 * @param holes   网洞点表
 | 
				
			||||||
 | 
					 * @param [textBox=TEXT_BOX] 标签盒子
 | 
				
			||||||
 | 
					 * @param [allowReturnNullPos=false] 允许返回null 当没有找到合适的位置返回null
 | 
				
			||||||
 | 
					 * @returns Vector3
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					export declare function ParseRegionTextPos(contour: Point[], holes: (Point[])[], textBox?: Path, allowReturnNullPos?: boolean): Vector3 | undefined;
 | 
				
			||||||
//# sourceMappingURL=ParseRegionTextPos.d.ts.map
 | 
					//# sourceMappingURL=ParseRegionTextPos.d.ts.map
 | 
				
			||||||
@@ -1 +1 @@
 | 
				
			|||||||
{"version":3,"file":"ParseRegionTextPos.d.ts","sourceRoot":"","sources":["../../../../../src/DatabaseServices/Room/ParseService/ParseRegionTextPos.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAInD,OAAO,EAAE,IAAI,EAAiC,MAAM,yBAAyB,CAAC;AAS9E,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,OAAO,OAAW,WAuG1F"}
 | 
					{"version":3,"file":"ParseRegionTextPos.d.ts","sourceRoot":"","sources":["../../../../../src/DatabaseServices/Room/ParseService/ParseRegionTextPos.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAInD,OAAO,EAAE,IAAI,EAAiC,MAAM,yBAAyB,CAAC;AAQ9E;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,OAAO,OAAW,EAAE,kBAAkB,UAAQ,GAAG,OAAO,GAAG,SAAS,CA2G5I"}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user