@labelbee/lb-annotation 1.28.0-alpha.3 → 1.28.0-alpha.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/_virtual/highlightWorker.js +1 -1
  2. package/dist/constant/tool.js +1 -1
  3. package/dist/core/pointCloud/annotation.js +1 -1
  4. package/dist/core/pointCloud/index.js +4 -4
  5. package/dist/core/pointCloud/matrix.js +1 -1
  6. package/dist/core/scheduler.js +1 -1
  7. package/dist/core/toolOperation/basicToolOperation.js +1 -1
  8. package/dist/core/toolOperation/pointCloud2dOperation.js +1 -1
  9. package/dist/core/toolOperation/pointOperation.js +1 -1
  10. package/dist/core/toolOperation/polygonOperation.js +2 -1
  11. package/dist/core/toolOperation/rectOperation.js +2 -2
  12. package/dist/index.js +1 -1
  13. package/dist/types/constant/tool.d.ts +7 -0
  14. package/dist/types/core/pointCloud/QuadTree25D.d.ts +78 -0
  15. package/dist/types/core/pointCloud/annotation.d.ts +4 -3
  16. package/dist/types/core/pointCloud/index.d.ts +17 -8
  17. package/dist/types/core/scheduler.d.ts +1 -1
  18. package/dist/types/core/toolOperation/ScribbleTool.d.ts +1 -9
  19. package/dist/types/core/toolOperation/basicToolOperation.d.ts +8 -1
  20. package/dist/types/core/toolOperation/pointCloud2dOperation.d.ts +19 -0
  21. package/dist/types/core/toolOperation/pointOperation.d.ts +1 -0
  22. package/dist/types/core/toolOperation/polygonOperation.d.ts +20 -13
  23. package/dist/types/core/toolOperation/rectOperation.d.ts +14 -4
  24. package/dist/types/utils/tool/AxisUtils.d.ts +3 -27
  25. package/dist/utils/tool/AxisUtils.js +1 -1
  26. package/dist/utils/tool/DrawUtils.js +1 -1
  27. package/dist/utils/tool/PolygonUtils.js +1 -1
  28. package/dist/utils/tool/TagUtils.js +1 -1
  29. package/dist/utils/tool/polygonTool.js +1 -1
  30. package/es/_virtual/highlightWorker.js +1 -1
  31. package/es/constant/tool.js +1 -1
  32. package/es/core/pointCloud/annotation.js +1 -1
  33. package/es/core/pointCloud/index.js +4 -4
  34. package/es/core/pointCloud/matrix.js +1 -1
  35. package/es/core/scheduler.js +1 -1
  36. package/es/core/toolOperation/basicToolOperation.js +1 -1
  37. package/es/core/toolOperation/pointCloud2dOperation.js +1 -1
  38. package/es/core/toolOperation/pointOperation.js +1 -1
  39. package/es/core/toolOperation/polygonOperation.js +2 -1
  40. package/es/core/toolOperation/rectOperation.js +2 -2
  41. package/es/index.js +1 -1
  42. package/es/utils/tool/AxisUtils.js +1 -1
  43. package/es/utils/tool/DrawUtils.js +3 -3
  44. package/es/utils/tool/PolygonUtils.js +1 -1
  45. package/es/utils/tool/TagUtils.js +1 -1
  46. package/es/utils/tool/polygonTool.js +1 -1
  47. package/package.json +4 -4
@@ -4,8 +4,8 @@
4
4
  * @author Ron <ron.f.luo@gmail.com>
5
5
  */
6
6
  import * as THREE from 'three';
7
- import { TMatrix4Tuple, EPerspectiveView, IVolume, IPointCloudBox, IPointCloudSphere, I3DSpaceCoord, IPointCloudConfig, ICalib, IPointCloudBoxList } from '@labelbee/lb-utils';
8
- import { OrthographicCamera, PerspectiveCamera } from 'three';
7
+ import { TMatrix4Tuple, EPerspectiveView, IVolume, IPointCloudBox, IPointCloudSphere, I3DSpaceCoord, IPointCloudConfig, ICalib, IPointCloudBoxList, ITipScopeParams } from '@labelbee/lb-utils';
8
+ import { BufferAttribute, OrthographicCamera, PerspectiveCamera } from 'three';
9
9
  import { IPolygonPoint } from '@/types/tool/polygon';
10
10
  import { PCDLoader } from './PCDLoader';
11
11
  import { OrbitControls } from './OrbitControls';
@@ -30,6 +30,7 @@ interface IProps {
30
30
  isSegment?: boolean;
31
31
  checkMode?: boolean;
32
32
  hiddenText?: boolean;
33
+ view?: string;
33
34
  }
34
35
  interface IPipeTypes {
35
36
  setSelectedIDs: (ids?: string[] | string) => void;
@@ -70,7 +71,9 @@ export declare class PointCloud extends EventListener {
70
71
  private backgroundColor;
71
72
  private pointCloudObjectName;
72
73
  private rangeObjectName;
74
+ private tipScopeObjectName;
73
75
  private highlightGroupName;
76
+ private cacheTipScopeList;
74
77
  private cacheInstance;
75
78
  private showDirection;
76
79
  private currentPCDSrc?;
@@ -91,10 +94,10 @@ export declare class PointCloud extends EventListener {
91
94
  private hiddenText;
92
95
  private filterBoxWorker;
93
96
  private geometry;
94
- private filterBoxWorkerTimer;
95
97
  private highlightColor;
98
+ private view;
96
99
  constructor({ container, noAppend, isOrthographicCamera, orthographicParams, backgroundColor, // GRAY_BACKGROUND
97
- config, isSegment, checkMode, hiddenText, }: IProps);
100
+ config, isSegment, checkMode, hiddenText, view, }: IProps);
98
101
  setHighlightColor(selectedId?: string): void;
99
102
  private updateMaterialColor;
100
103
  setHandlerPipe(pipe: IPipeTypes): void;
@@ -230,6 +233,8 @@ export declare class PointCloud extends EventListener {
230
233
  } | undefined>;
231
234
  getCameraVector(centerPoint: I3DSpaceCoord, rotationZ: number, volume: IVolume, perspectiveView?: EPerspectiveView, defaultDistance?: number): THREE.Vector3;
232
235
  createRange(radius: number): THREE.Line<THREE.BufferGeometry, THREE.LineBasicMaterial>;
236
+ /** Create prompt range */
237
+ createTipScope(tipScope: ITipScopeParams, index: number): THREE.Object3D<THREE.Event> | null;
233
238
  initShaderMaterial: () => {
234
239
  vertexShader: string;
235
240
  fragmentShader: string;
@@ -239,7 +244,7 @@ export declare class PointCloud extends EventListener {
239
244
  };
240
245
  };
241
246
  };
242
- renderPointCloud(points: THREE.Points, radius?: number): void;
247
+ renderPointCloud(points: THREE.Points, radius?: number, tipScopeList?: ITipScopeParams[]): void;
243
248
  clearAllBox(): void;
244
249
  clearAllSphere(): void;
245
250
  clearAllGroupByPrefix(prefix?: string): void;
@@ -251,7 +256,7 @@ export declare class PointCloud extends EventListener {
251
256
  * @param src
252
257
  * @param radius Render the range of circle
253
258
  */
254
- loadPCDFile: (src?: string | undefined, radius?: number) => Promise<void>;
259
+ loadPCDFile: (src?: string | undefined, radius?: number, tipScopeList?: ITipScopeParams[]) => Promise<void>;
255
260
  /**
256
261
  * Highlight PointCloud by MappingImgList.
257
262
  * @param param0
@@ -275,14 +280,17 @@ export declare class PointCloud extends EventListener {
275
280
  highlightOriginPointCloud(pointCloudBoxList?: IPointCloudBox[], highlightIndex?: number[], config?: {
276
281
  modifiedBoxIds: string[];
277
282
  resetAreas: ICoordinate[][];
278
- }): Promise<THREE.BufferAttribute[] | undefined>;
283
+ }): Promise<{
284
+ color: BufferAttribute[];
285
+ currentPCDSrc: string | undefined;
286
+ } | undefined>;
279
287
  /**
280
288
  * Clean all highlightBox
281
289
  */
282
290
  clearHighlightBoxes(): void;
283
291
  clearHighlightBoxesAndRender(): void;
284
292
  highlightBoxes(boxes: IPointCloudBox[]): void;
285
- updateColor(color: any[]): void;
293
+ updateColor(color: any[], src?: string): void;
286
294
  /**
287
295
  * Load PCD File by box
288
296
  * @param src
@@ -296,6 +304,7 @@ export declare class PointCloud extends EventListener {
296
304
  }>) => Promise<void>;
297
305
  setShowDirection(showDirection: boolean): void;
298
306
  generateRange: (radius: number) => void;
307
+ generateTipScopeList: (tipScopeList: ITipScopeParams[]) => void;
299
308
  generateBoxArrow: ({ width }: IPointCloudBox) => THREE.ArrowHelper;
300
309
  /**
301
310
  * Universal generation of label information
@@ -81,7 +81,7 @@ export declare class ToolScheduler implements IToolSchedulerOperation {
81
81
  * there is no more specific instance like pointCloud2dOperation you can reach,
82
82
  * so if you need to update result in specific operation instance, you can try this.
83
83
  */
84
- updateDataByToolName(toolName: EToolName, result: any): void;
84
+ updateDataByToolName(toolName: EToolName, result: any, isDeleteSelectedID?: boolean): void;
85
85
  clearStatusAndResult(): void;
86
86
  destroyAllLayer(): void;
87
87
  init(): void;
@@ -25,15 +25,7 @@ declare class ScribbleTool extends BasicToolOperation {
25
25
  get color(): string;
26
26
  get penSizeWithZoom(): number;
27
27
  get cacheCanvasToDataUrl(): string | undefined;
28
- getOriginCoordinate: (e: MouseEvent) => {
29
- x: number;
30
- y: number;
31
- specialPoint?: boolean | undefined;
32
- specialEdge?: boolean | undefined;
33
- } | {
34
- x: number;
35
- y: number;
36
- };
28
+ getOriginCoordinate: (e: MouseEvent) => IPoint;
37
29
  setPenSize(size: number): void;
38
30
  initCacheCanvas(imgNode?: HTMLImageElement): void;
39
31
  updateCacheCanvasSize(imgNode: HTMLImageElement): void;
@@ -28,6 +28,7 @@ interface IBasicToolOperationProps {
28
28
  ratio: number;
29
29
  };
30
30
  language?: ELang;
31
+ isOffscreenCanvas?: boolean;
31
32
  }
32
33
  /**
33
34
  * 参考显示数据
@@ -91,10 +92,13 @@ declare class BasicToolOperation extends EventListener {
91
92
  max: number;
92
93
  ratio: number;
93
94
  };
95
+ offscreenCanvas: HTMLCanvasElement;
96
+ private isOffscreenCanvas;
94
97
  constructor(props: IBasicToolOperationProps);
95
98
  onContextmenu(e: MouseEvent): void;
96
99
  get ctx(): CanvasRenderingContext2D | null;
97
100
  get basicCtx(): CanvasRenderingContext2D | null;
101
+ get offscreenCtx(): CanvasRenderingContext2D | null;
98
102
  get rotate(): any;
99
103
  get valid(): any;
100
104
  get baseIcon(): any;
@@ -224,13 +228,16 @@ declare class BasicToolOperation extends EventListener {
224
228
  redo(): void;
225
229
  clearCanvas(): void;
226
230
  clearBasicCanvas(): void;
231
+ clearOffscreenCanvas(): void;
227
232
  /** 事件绑定 */
228
233
  eventBinding(): void;
229
234
  eventUnbinding(): void;
230
235
  clearImgDrag(): void;
231
236
  clearCursorLine(): void;
237
+ private moveAnimationFrameId;
238
+ optimizeMouseMove(event: MouseEvent): boolean | void;
232
239
  onMouseDown(e: MouseEvent): void | boolean;
233
- onMouseMove(e: MouseEvent): boolean | void;
240
+ onMouseMove(e: MouseEvent, isRender?: boolean): boolean | void;
234
241
  onMouseUp(e: MouseEvent): boolean | void;
235
242
  onMouseLeave(): void;
236
243
  onClick(e: MouseEvent): void;
@@ -14,10 +14,13 @@ declare class PointCloud2dOperation extends PolygonOperation {
14
14
  pointCloudConfig: IPointCloudConfig;
15
15
  private checkMode;
16
16
  private highlightAttributeList;
17
+ private rectToolMode?;
17
18
  constructor(props: IPolygonOperationProps & IPointCloud2dOperationProps);
18
19
  get getSelectedIDs(): string[];
19
20
  get enableDrag(): boolean;
20
21
  get visiblePolygonList(): IPolygonData[];
22
+ get lastStepByThreePointsMode(): boolean;
23
+ get lastStepByTwoPointsMode(): boolean;
21
24
  setHiddenAttributes(hideAttributes: string[]): void;
22
25
  setConfig(config: string): void;
23
26
  dragMouseDown(e: MouseEvent): void;
@@ -106,6 +109,22 @@ declare class PointCloud2dOperation extends PolygonOperation {
106
109
  setResultAndSelectedID(polygonList: IPolygonData[], selectedID: string): void;
107
110
  emitUpdatePolygonByDrag: () => void;
108
111
  setHighlightAttribute(attribute: string): void;
112
+ /**
113
+ * used in isTwoPointsMode;
114
+ * Effect:Determine the order of the four points, because the orientation is drawn along the line between the starting point and the first point;
115
+ * Orientation Logic: to the first point, adjacent to the two sides take one for orientation, such as side 1, Side 2, if side 1 clockwise rotation 90 degrees can get side 2, then take side 1 for orientation;
116
+ */
117
+ private createRectByTwoPointsMode;
118
+ protected addPointInDrawingHook(coordinateWithOrigin: ICoordinate): {
119
+ continue: boolean;
120
+ };
121
+ protected renderPolygonHook(polygon: IPolygonPoint[]): {
122
+ continue: boolean;
123
+ };
124
+ protected getPointListByRectDrawing(coordinate: ICoordinate, drawingPointList: IPolygonPoint[]): {
125
+ continue: boolean;
126
+ value: ICoordinate[] | undefined;
127
+ };
109
128
  }
110
129
  export default PointCloud2dOperation;
111
130
  export { IPointCloud2dOperationProps };
@@ -78,6 +78,7 @@ declare class PointOperation extends BasicToolOperation {
78
78
  onMouseDown(e: MouseEvent): true | undefined;
79
79
  onMouseMove(e: MouseEvent): undefined;
80
80
  onMouseUp(e: MouseEvent): true | undefined;
81
+ setPointValidAndRender(id?: string): void;
81
82
  onDragMove(e: MouseEvent): void;
82
83
  onKeyDown(e: KeyboardEvent): void;
83
84
  isMinDistance: (coord: ICoordinate) => boolean;
@@ -4,6 +4,10 @@ import { IPolygonConfig, IPolygonData, IPolygonPoint } from '../../types/tool/po
4
4
  import { BasicToolOperation, IBasicToolOperationProps } from './basicToolOperation';
5
5
  import TextAttributeClass from './textAttributeClass';
6
6
  import Selection from './Selection';
7
+ interface IHookResult<T> {
8
+ continue: boolean;
9
+ value?: T;
10
+ }
7
11
  export interface IPolygonOperationProps extends IBasicToolOperationProps {
8
12
  }
9
13
  declare class PolygonOperation extends BasicToolOperation {
@@ -32,6 +36,7 @@ declare class PolygonOperation extends BasicToolOperation {
32
36
  _textAttributeInstance?: TextAttributeClass;
33
37
  forbidAddNewPolygonFuc?: (e: MouseEvent) => boolean;
34
38
  selection: Selection;
39
+ private attrChangeTrigger;
35
40
  constructor(props: IPolygonOperationProps);
36
41
  get selectedIDs(): string[];
37
42
  get selectedID(): string | undefined;
@@ -45,15 +50,7 @@ declare class PolygonOperation extends BasicToolOperation {
45
50
  get enableDrag(): boolean;
46
51
  get visiblePolygonList(): IPolygonData[];
47
52
  get polygonListUnderZoom(): {
48
- pointList: ({
49
- x: number;
50
- y: number;
51
- specialPoint?: boolean | undefined;
52
- specialEdge?: boolean | undefined;
53
- } | {
54
- x: number;
55
- y: number;
56
- })[];
53
+ pointList: IPoint[];
57
54
  sourceID: string;
58
55
  id: string;
59
56
  valid: boolean;
@@ -62,6 +59,9 @@ declare class PolygonOperation extends BasicToolOperation {
62
59
  attribute: string;
63
60
  isRect?: boolean | undefined;
64
61
  trackID?: number | undefined;
62
+ subAttribute?: {
63
+ [key: string]: string;
64
+ } | undefined;
65
65
  }[];
66
66
  get selectedText(): string | undefined;
67
67
  isAllowDouble: (e: MouseEvent) => boolean;
@@ -83,7 +83,7 @@ declare class PolygonOperation extends BasicToolOperation {
83
83
  * @param polygonList
84
84
  */
85
85
  setResultAndSelectedID(polygonList: IPolygonData[], selectedID: string): void;
86
- setResult(polygonList: IPolygonData[]): void;
86
+ setResult(polygonList: IPolygonData[], isDeleteSelectedID?: boolean): void;
87
87
  /**
88
88
  * 外层 sidabr 调用
89
89
  * @param v
@@ -108,10 +108,11 @@ declare class PolygonOperation extends BasicToolOperation {
108
108
  /**
109
109
  * 清楚所有的中间状态
110
110
  */
111
- clearActiveStatus(): void;
111
+ clearActiveStatus(isDeleteSelectedID?: boolean): void;
112
112
  clearDrawingStatus(): void;
113
113
  setPolygonList(polygonList: IPolygonData[]): void;
114
114
  setSelectedID(newID?: string, isAppend?: boolean): void;
115
+ setAttrChangeTrigger(attrChangeTrigger?: number): void;
115
116
  setDefaultAttribute(defaultAttribute?: string): void;
116
117
  setStyle(toolStyle: any): void;
117
118
  /**
@@ -178,6 +179,9 @@ declare class PolygonOperation extends BasicToolOperation {
178
179
  y: number;
179
180
  };
180
181
  dragPolygon(e: MouseEvent, selectedPolygon: IPolygonData): IPolygonPoint[] | undefined;
182
+ private lastMouseMoveTime;
183
+ private mouseMoveThrottle;
184
+ private determineTrigger;
181
185
  onMouseMove(e: MouseEvent): void;
182
186
  /**
183
187
  * Emit updateList for views update
@@ -207,13 +211,16 @@ declare class PolygonOperation extends BasicToolOperation {
207
211
  renderSelectedPolygons(): void;
208
212
  renderSelectedPolygon(polygon: IPolygonData): void;
209
213
  renderHoverPolygon(): void;
210
- renderPolygon(): void;
211
- render(): void;
214
+ renderPolygon(trigger?: string): void;
215
+ render(trigger?: string): void;
212
216
  renderCursorLine(lineColor: string): void;
213
217
  /** 撤销 */
214
218
  undo(): void;
215
219
  /** 重做 */
216
220
  redo(): void;
217
221
  deleteSelectedID(): void;
222
+ protected addPointInDrawingHook(..._args: unknown[]): IHookResult<unknown>;
223
+ protected renderPolygonHook(..._args: unknown[]): IHookResult<unknown>;
224
+ protected getPointListByRectDrawing(..._args: unknown[]): IHookResult<unknown>;
218
225
  }
219
226
  export default PolygonOperation;
@@ -137,13 +137,22 @@ declare class RectOperation extends BasicToolOperation {
137
137
  */
138
138
  onDragMoveAll(offset: ICoordinate): void;
139
139
  onDragMove(coordinate: ICoordinate): void;
140
- onMouseMove(e: MouseEvent): undefined;
140
+ private lastMouseMoveTime;
141
+ private mouseMoveThrottle;
142
+ onMouseMove(e: MouseEvent): void;
141
143
  setHighlightVisible(highlightVisible: boolean): void;
142
144
  setAttributeLockList(attributeLockList: string[]): void;
143
145
  setBasicResult(basicResult: any): void;
144
- setRectValidAndRender(id: string): void;
146
+ setRectValidAndRender(id?: string): void;
145
147
  setDefaultSubAttribute: () => void;
146
148
  createNewDrawingRect(e: MouseEvent, basicSourceID: string): void;
149
+ checkSize({ width, height, minWidth, minHeight, isAttributeConfig, }: {
150
+ width: number;
151
+ height: number;
152
+ minWidth: number;
153
+ minHeight: number;
154
+ isAttributeConfig?: boolean;
155
+ }): boolean;
147
156
  /**
148
157
  * 将绘制中的框体添加进 rectList 中
149
158
  * @returns
@@ -204,8 +213,9 @@ declare class RectOperation extends BasicToolOperation {
204
213
  /**
205
214
  * 渲染矩形框体
206
215
  */
207
- renderRect(): void;
208
- render(): void;
216
+ renderRect(trigger?: string): void;
217
+ render(trigger?: string): void;
218
+ renderCursorLine(lineColor: string): void;
209
219
  setDefaultAttribute(defaultAttribute?: string): void;
210
220
  setValid(valid: boolean): void;
211
221
  private clearDrawingStatus;
@@ -47,15 +47,7 @@ export default class AxisUtils {
47
47
  * @param currentPos
48
48
  * @returns
49
49
  */
50
- static changePointByZoom(point: IPoint | IPolygonPoint, zoom: number, currentPos?: ICoordinate): {
51
- x: number;
52
- y: number;
53
- specialPoint?: boolean | undefined;
54
- specialEdge?: boolean | undefined;
55
- } | {
56
- x: number;
57
- y: number;
58
- };
50
+ static changePointByZoom(point: IPoint | IPolygonPoint, zoom: number, currentPos?: ICoordinate): IPoint;
59
51
  /**
60
52
  * 计算点集在 zoom 和 currentPos 的转换
61
53
  * @param pointList
@@ -63,15 +55,7 @@ export default class AxisUtils {
63
55
  * @param currentPos
64
56
  * @returns
65
57
  */
66
- static changePointListByZoom(pointList: IPoint[] | IPolygonPoint[], zoom: number, currentPos?: ICoordinate): ({
67
- x: number;
68
- y: number;
69
- specialPoint?: boolean | undefined;
70
- specialEdge?: boolean | undefined;
71
- } | {
72
- x: number;
73
- y: number;
74
- })[];
58
+ static changePointListByZoom(pointList: IPoint[] | IPolygonPoint[], zoom: number, currentPos?: ICoordinate): IPoint[];
75
59
  static changePlanePointByZoom(planePoints: IPlanePoints, zoom: number, currentPos?: ICoordinate): IPlanePoints;
76
60
  static changeCuboidByZoom(cuboid: ICuboid | IDrawingCuboid, zoom: number, currentPos?: ICoordinate): ICuboid | IDrawingCuboid;
77
61
  static transformPlain2PointList({ tl, tr, br, bl }: IPlanePoints): any[];
@@ -140,15 +124,7 @@ export default class AxisUtils {
140
124
  zoom: number;
141
125
  }>): {
142
126
  type: string;
143
- points: ({
144
- x: number;
145
- y: number;
146
- specialPoint?: boolean | undefined;
147
- specialEdge?: boolean | undefined;
148
- } | {
149
- x: number;
150
- y: number;
151
- })[];
127
+ points: IPoint[];
152
128
  originCuboid: ICuboid;
153
129
  positions: import("@/types/tool/cuboid").ICuboidPosition[];
154
130
  }[] | undefined;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var tool=require("../../constant/tool.js"),MathUtils=require("../MathUtils.js"),PolygonUtils=require("./PolygonUtils.js"),LineToolUtils=require("./LineToolUtils.js"),CuboidUtils=require("./CuboidUtils.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(h,t,e)=>t in h?__defProp(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,__spreadValues=(h,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(h,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(h,e,t[e]);return h},__spreadProps=(h,t)=>__defProps(h,__getOwnPropDescs(t));class AxisUtils{static getOffsetCoordinate(t,e,i){return{x:t.x*i+e.x,y:t.y*i+e.y}}static changeDrawOutsideTarget(t,e,i,s,n,o){return typeof s=="boolean"&&!s&&(n&&o?(t.x-e.x>(n.x+n.width)*o&&(t.x=(n.x+n.width)*o+e.x),t.x-e.x<n.x*o&&(t.x=n.x*o+e.x),t.y-e.y>(n.y+n.height)*o&&(t.y=(n.y+n.height)*o+e.y),t.y-e.y<n.y*o&&(t.y=n.y*o+e.y)):(t.x-e.x>i.width&&(t.x=i.width+e.x),t.x-e.x<0&&(t.x=e.x),t.y-e.y>i.height&&(t.y=i.height+e.y),t.y-e.y<0&&(t.y=e.y))),t}static changeCoordinateByRotate(t,e,i){const{width:s,height:n}=i,{x:o,y:r}=t;switch(e%360){case 90:return{x:n-r,y:o};case 180:return{x:s-o,y:n-r};case 270:return{x:r,y:s-o};default:return t}}static changeRectByZoom(t,e,i={x:0,y:0}){return __spreadProps(__spreadValues({},t),{x:t.x*e+i.x,y:t.y*e+i.y,width:t.width*e,height:t.height*e})}static changePointByZoom(t,e,i={x:0,y:0}){return __spreadProps(__spreadValues({},t),{x:t.x*e+i.x,y:t.y*e+i.y})}static changePointListByZoom(t,e,i={x:0,y:0}){return t==null?void 0:t.map(s=>this.changePointByZoom(s,e,i))}static changePlanePointByZoom(t,e,i={x:0,y:0}){return Object.entries(t).reduce((s,[n,o])=>{const r=AxisUtils.changePointByZoom(o,e,i);return __spreadProps(__spreadValues({},s),{[n]:r})},{})}static changeCuboidByZoom(t,e,i={x:0,y:0}){return __spreadProps(__spreadValues({},t),{frontPoints:this.changePlanePointByZoom(t.frontPoints,e,i),backPoints:t.backPoints?this.changePlanePointByZoom(t.backPoints,e,i):t.backPoints})}static transformPlain2PointList({tl:t,tr:e,br:i,bl:s}){return[t,e,i,s]}static axisArea(t,e=3){const{x:i,y:s}=t,n=[];for(let o=i-e;o<i+e;o+=e/3)for(let r=s-e;r<s+e;r+=e/3)n.push({x:o,y:r});return n}static getOriginCoordinateWithOffsetCoordinate(t,e=1,i={x:0,y:0}){return{x:(t.x-i.x)/e,y:(t.y-i.y)/e}}static returnClosePointIndex(t,e,i=3){let s=-1;for(let n=0;n<e.length;n++){const o=e[n];this.getIsInScope(t,o,i)&&(s=n)}return s}static isCloseCuboid(t,e,i={scope:5,zoom:1}){const s=CuboidUtils.getHighlightPoints(e),{scope:n=5}=i;for(let r=0;r<s.length;r++){const g=s[r];if(this.getIsInScope(t,g.point,n))return!0}const o=CuboidUtils.getHighlightLines(e);for(let r=0;r<o.length;r++){const g=o[r],{length:y}=MathUtils.default.getFootOfPerpendicular(t,g.p1,g.p2,!0);if(y<n)return!0}return!!PolygonUtils.isInPolygon(t,CuboidUtils.getCuboidHoverRange(e))}static isCloseCuboidList(t,e,i={scope:5,zoom:1}){return e.some(s=>this.isCloseCuboid(t,s,i))}static returnClosePointOrLineInCuboid(t,e,i={scope:5,zoom:1}){const s=CuboidUtils.getHighlightPoints(e),{scope:n=5,zoom:o=1}=i;for(let a=0;a<s.length;a++){const l=s[a];if(this.getIsInScope(t,l.point,n))return[{type:"point",points:[this.changePointByZoom(s[a].point,o)],originCuboid:e,positions:l.positions}]}let r=n;const g=CuboidUtils.getHighlightLines(e);let y;for(let a=0;a<g.length;a++){const l=g[a],{length:p}=MathUtils.default.getFootOfPerpendicular(t,l.p1,l.p2,!0);p<r&&(r=p,y=[{type:"line",points:this.changePointListByZoom([l.p1,l.p2],o),originCuboid:e,positions:l.positions}])}if(y)return y}static getIsInScope(t,e,i){return Math.abs(t.x-e.x)<i&&Math.abs(t.y-e.y)<i}}class CoordinateUtils{constructor(t){this.currentPos=t.currentPos,this.zoom=t.zoom,this.basicImgInfo=t.basicImgInfo,this.dependToolName=""}get isDependPolygon(){return this.dependToolName===tool.EToolName.Polygon}get isDependRect(){return this.dependToolName===tool.EToolName.Rect}get isDependOriginalImage(){return this.dependToolName===""}getAbsCoord(t){return{x:(t.x-this.currentPos.x)/this.zoom,y:(t.y-this.currentPos.y)/this.zoom}}getRenderCoord(t){return{x:t.x*this.zoom+this.currentPos.x,y:t.y*this.zoom+this.currentPos.y}}coordInsideRect(t,e){const{x:i,y:s,width:n,height:o}=e;return{x:MathUtils.default.withinRange(t.x,[i,i+n]),y:MathUtils.default.withinRange(t.y,[s,s+o])}}getPolygonPointList(t,e){return t===tool.ELineTypes.Curve?PolygonUtils.createSmoothCurvePointsFromPointList(e):e}getIntersection(t,e,i){const s=this.getRenderCoord(e),n=this.getRenderCoord(t),o={pointA:s,pointB:n};return LineToolUtils.default.calcOptimalIntersection(i,o,s,LineToolUtils.POINT_RADIUS,this.zoom)}coordInsidePolygon(t,e,i,s){const{pointList:n}=i,o=s==null?void 0:s.lineType;if(n.length===0)return t;const r=this.getPolygonPointList(o,n);if(PolygonUtils.isInPolygon(t,r))return t;const y=r.concat(r[0]).map(l=>this.getRenderCoord(l)),a=this.getIntersection(t,e,y);return a?this.getAbsCoord(a==null?void 0:a.point):t}coordInsideImage(t){return this.coordInsideRect(t,__spreadProps(__spreadValues({},this.basicImgInfo),{x:0,y:0}))}getNextCoordByDependTool(t,e){if(this.isDependRect)return this.coordInsideRect(t,this.basicResult);if(this.isDependPolygon)return this.coordInsidePolygon(t,e,this.basicResult,this.dependToolConfig);if(this.isDependOriginalImage)return this.coordInsideImage(t)}setDependInfo(t,e){this.dependToolName=t!=null?t:"",this.dependToolConfig=t?e:void 0}setBasicImgInfo(t){this.basicImgInfo=t}setBasicResult(t){this.basicResult=t}setZoomAndCurrentPos(t,e){this.zoom=t,this.currentPos=e}isCoordInsideTarget(t){if(this.isDependPolygon)return this.isInBasicPolygon(t);if(this.isDependRect){const{x:e,y:i,width:s,height:n}=this.basicResult,o=[e,e+s],r=[i,i+n];return MathUtils.default.isInRange(t.x,o)&&MathUtils.default.isInRange(t.y,r)}return MathUtils.default.isInRange(t.x,[0,this.basicImgInfo.width])&&MathUtils.default.isInRange(t.y,[0,this.basicImgInfo.height])}isInBasicPolygon(t){var e,i;return PolygonUtils.isInPolygon(t,((e=this.basicResult)==null?void 0:e.pointList)||[],(i=this.dependToolConfig)==null?void 0:i.lineType)}}exports.CoordinateUtils=CoordinateUtils,exports.default=AxisUtils;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var tool=require("../../constant/tool.js"),MathUtils=require("../MathUtils.js"),PolygonUtils=require("./PolygonUtils.js"),LineToolUtils=require("./LineToolUtils.js"),CuboidUtils=require("./CuboidUtils.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(h,t,e)=>t in h?__defProp(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,__spreadValues=(h,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(h,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(h,e,t[e]);return h},__spreadProps=(h,t)=>__defProps(h,__getOwnPropDescs(t));class AxisUtils{static getOffsetCoordinate(t,e,i){return{x:t.x*i+e.x,y:t.y*i+e.y}}static changeDrawOutsideTarget(t,e,i,s,n,o){return typeof s=="boolean"&&!s&&(n&&o?(t.x-e.x>(n.x+n.width)*o&&(t.x=(n.x+n.width)*o+e.x),t.x-e.x<n.x*o&&(t.x=n.x*o+e.x),t.y-e.y>(n.y+n.height)*o&&(t.y=(n.y+n.height)*o+e.y),t.y-e.y<n.y*o&&(t.y=n.y*o+e.y)):(t.x-e.x>i.width&&(t.x=i.width+e.x),t.x-e.x<0&&(t.x=e.x),t.y-e.y>i.height&&(t.y=i.height+e.y),t.y-e.y<0&&(t.y=e.y))),t}static changeCoordinateByRotate(t,e,i){const{width:s,height:n}=i,{x:o,y:r}=t;switch(e%360){case 90:return{x:n-r,y:o};case 180:return{x:s-o,y:n-r};case 270:return{x:r,y:s-o};default:return t}}static changeRectByZoom(t,e,i={x:0,y:0}){return __spreadProps(__spreadValues({},t),{x:t.x*e+i.x,y:t.y*e+i.y,width:t.width*e,height:t.height*e})}static changePointByZoom(t,e,i={x:0,y:0}){return e===1&&i.x===0&&i.y===0?t:__spreadProps(__spreadValues({},t),{x:t.x*e+i.x,y:t.y*e+i.y})}static changePointListByZoom(t,e,i={x:0,y:0}){return t==null?void 0:t.map(s=>this.changePointByZoom(s,e,i))}static changePlanePointByZoom(t,e,i={x:0,y:0}){return Object.entries(t).reduce((s,[n,o])=>{const r=AxisUtils.changePointByZoom(o,e,i);return __spreadProps(__spreadValues({},s),{[n]:r})},{})}static changeCuboidByZoom(t,e,i={x:0,y:0}){return __spreadProps(__spreadValues({},t),{frontPoints:this.changePlanePointByZoom(t.frontPoints,e,i),backPoints:t.backPoints?this.changePlanePointByZoom(t.backPoints,e,i):t.backPoints})}static transformPlain2PointList({tl:t,tr:e,br:i,bl:s}){return[t,e,i,s]}static axisArea(t,e=3){const{x:i,y:s}=t,n=[];for(let o=i-e;o<i+e;o+=e/3)for(let r=s-e;r<s+e;r+=e/3)n.push({x:o,y:r});return n}static getOriginCoordinateWithOffsetCoordinate(t,e=1,i={x:0,y:0}){return{x:(t.x-i.x)/e,y:(t.y-i.y)/e}}static returnClosePointIndex(t,e,i=3){let s=-1;for(let n=0;n<e.length;n++){const o=e[n];this.getIsInScope(t,o,i)&&(s=n)}return s}static isCloseCuboid(t,e,i={scope:5,zoom:1}){const s=CuboidUtils.getHighlightPoints(e),{scope:n=5}=i;for(let r=0;r<s.length;r++){const g=s[r];if(this.getIsInScope(t,g.point,n))return!0}const o=CuboidUtils.getHighlightLines(e);for(let r=0;r<o.length;r++){const g=o[r],{length:y}=MathUtils.default.getFootOfPerpendicular(t,g.p1,g.p2,!0);if(y<n)return!0}return!!PolygonUtils.isInPolygon(t,CuboidUtils.getCuboidHoverRange(e))}static isCloseCuboidList(t,e,i={scope:5,zoom:1}){return e.some(s=>this.isCloseCuboid(t,s,i))}static returnClosePointOrLineInCuboid(t,e,i={scope:5,zoom:1}){const s=CuboidUtils.getHighlightPoints(e),{scope:n=5,zoom:o=1}=i;for(let a=0;a<s.length;a++){const l=s[a];if(this.getIsInScope(t,l.point,n))return[{type:"point",points:[this.changePointByZoom(s[a].point,o)],originCuboid:e,positions:l.positions}]}let r=n;const g=CuboidUtils.getHighlightLines(e);let y;for(let a=0;a<g.length;a++){const l=g[a],{length:p}=MathUtils.default.getFootOfPerpendicular(t,l.p1,l.p2,!0);p<r&&(r=p,y=[{type:"line",points:this.changePointListByZoom([l.p1,l.p2],o),originCuboid:e,positions:l.positions}])}if(y)return y}static getIsInScope(t,e,i){return Math.abs(t.x-e.x)<i&&Math.abs(t.y-e.y)<i}}class CoordinateUtils{constructor(t){this.currentPos=t.currentPos,this.zoom=t.zoom,this.basicImgInfo=t.basicImgInfo,this.dependToolName=""}get isDependPolygon(){return this.dependToolName===tool.EToolName.Polygon}get isDependRect(){return this.dependToolName===tool.EToolName.Rect}get isDependOriginalImage(){return this.dependToolName===""}getAbsCoord(t){return{x:(t.x-this.currentPos.x)/this.zoom,y:(t.y-this.currentPos.y)/this.zoom}}getRenderCoord(t){return{x:t.x*this.zoom+this.currentPos.x,y:t.y*this.zoom+this.currentPos.y}}coordInsideRect(t,e){const{x:i,y:s,width:n,height:o}=e;return{x:MathUtils.default.withinRange(t.x,[i,i+n]),y:MathUtils.default.withinRange(t.y,[s,s+o])}}getPolygonPointList(t,e){return t===tool.ELineTypes.Curve?PolygonUtils.createSmoothCurvePointsFromPointList(e):e}getIntersection(t,e,i){const s=this.getRenderCoord(e),n=this.getRenderCoord(t),o={pointA:s,pointB:n};return LineToolUtils.default.calcOptimalIntersection(i,o,s,LineToolUtils.POINT_RADIUS,this.zoom)}coordInsidePolygon(t,e,i,s){const{pointList:n}=i,o=s==null?void 0:s.lineType;if(n.length===0)return t;const r=this.getPolygonPointList(o,n);if(PolygonUtils.isInPolygon(t,r))return t;const y=r.concat(r[0]).map(l=>this.getRenderCoord(l)),a=this.getIntersection(t,e,y);return a?this.getAbsCoord(a==null?void 0:a.point):t}coordInsideImage(t){return this.coordInsideRect(t,__spreadProps(__spreadValues({},this.basicImgInfo),{x:0,y:0}))}getNextCoordByDependTool(t,e){if(this.isDependRect)return this.coordInsideRect(t,this.basicResult);if(this.isDependPolygon)return this.coordInsidePolygon(t,e,this.basicResult,this.dependToolConfig);if(this.isDependOriginalImage)return this.coordInsideImage(t)}setDependInfo(t,e){this.dependToolName=t!=null?t:"",this.dependToolConfig=t?e:void 0}setBasicImgInfo(t){this.basicImgInfo=t}setBasicResult(t){this.basicResult=t}setZoomAndCurrentPos(t,e){this.zoom=t,this.currentPos=e}isCoordInsideTarget(t){if(this.isDependPolygon)return this.isInBasicPolygon(t);if(this.isDependRect){const{x:e,y:i,width:s,height:n}=this.basicResult,o=[e,e+s],r=[i,i+n];return MathUtils.default.isInRange(t.x,o)&&MathUtils.default.isInRange(t.y,r)}return MathUtils.default.isInRange(t.x,[0,this.basicImgInfo.width])&&MathUtils.default.isInRange(t.y,[0,this.basicImgInfo.height])}isInBasicPolygon(t){var e,i;return PolygonUtils.isInPolygon(t,((e=this.basicResult)==null?void 0:e.pointList)||[],(i=this.dependToolConfig)==null?void 0:i.lineType)}}exports.CoordinateUtils=CoordinateUtils,exports.default=AxisUtils;
@@ -1,3 +1,3 @@
1
1
  "use strict";var rgba=require("color-rgba"),lbUtils=require("@labelbee/lb-utils"),tool=require("../../constant/tool.js"),PolygonUtils=require("./PolygonUtils.js"),UnitUtils=require("./UnitUtils.js"),AxisUtils=require("./AxisUtils.js"),CuboidUtils=require("./CuboidUtils.js"),AttributeUtils=require("./AttributeUtils.js");function _interopDefaultLegacy(r){return r&&typeof r=="object"&&"default"in r?r:{default:r}}var rgba__default=_interopDefaultLegacy(rgba),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(r,t,i)=>t in r?__defProp(r,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):r[t]=i,__spreadValues=(r,t)=>{for(var i in t||(t={}))__hasOwnProp.call(t,i)&&__defNormalProp(r,i,t[i]);if(__getOwnPropSymbols)for(var i of __getOwnPropSymbols(t))__propIsEnum.call(t,i)&&__defNormalProp(r,i,t[i]);return r},__spreadProps=(r,t)=>__defProps(r,__getOwnPropDescs(t));const DEFAULT_ZOOM=1,DEFAULT_CURRENT_POS={x:0,y:0},DEFAULT_ROTATE=0,DEFAULT_COLOR="",HIGHLIGHT_ICON_SVG_PATHS=[{d:"M0.423514 10.1595C-0.362666 7.22543 1.37854 4.20957 4.3126 3.42339C7.24666 2.63721 10.2625 4.37842 11.0487 7.31248L49.8716 152.201C50.6577 155.135 48.9165 158.151 45.9825 158.937C43.0484 159.724 40.0325 157.982 39.2464 155.048L0.423514 10.1595Z"},{d:"M14.0774 9.47294C28.5 -16.5001 91.5 25.5001 113.138 0.529419L131.773 70.076C112 96.9999 50.5 54 32.7124 79.0196L14.0774 9.47294Z"}],_DrawUtils=class{static drawLine(r,t,i,e={}){const o=r.getContext("2d"),{color:s=DEFAULT_COLOR,thickness:l=1,lineCap:c="round",lineDash:n}=e;o.save(),o.strokeStyle=s,o.lineWidth=l,o.lineCap=c,n&&o.setLineDash(n),o.beginPath(),o.moveTo(t.x,t.y),o.lineTo(i.x+1,i.y+1),o.stroke(),o.restore()}static drawRect(r,t,i={}){const e=r.getContext("2d"),{color:o=DEFAULT_COLOR,thickness:s=1,lineCap:l="round",hiddenText:c=!1,lineDash:n}=i;if(e.save(),e.strokeStyle=o,e.lineWidth=s,e.lineCap=l,Array.isArray(n)&&e.setLineDash(n),e.fillStyle=o,e.strokeRect(t.x,t.y,t.width,t.height),c===!1){let a="";if(t.attribute&&(a=`${a} ${t.attribute}`),this.drawText(r,{x:t.x,y:t.y-5},a),t.textAttribute){const h=`${~~t.width} * ${~~t.height}`.length*7,u=0,y=Math.max(20,t.width-h);this.drawText(r,{x:t.x,y:t.y+t.height+20+u},t.textAttribute,{textMaxWidth:y})}}e.restore()}static drawRectWithFill(r,t,i={}){const e=r.getContext("2d"),{color:o=DEFAULT_COLOR}=i;e.save(),e.fillStyle=o,e.fillRect(t.x,t.y,t.width,t.height),e.restore()}static drawTagByDom(r,t,i){const e=r;if(!((t==null?void 0:t.length)>0))return;const o=document.createElement("div");return o.innerHTML=t,o.setAttribute("id",i),e==null||e.appendChild(o),o}static drawTag(r,t){var i;const e=r==null?void 0:r.parentNode,o=window.self.document.getElementById("tagToolTag");if(o&&e&&e.contains(o)&&(e==null||e.removeChild(o)),!((t==null?void 0:t.length)>0))return;const s=document.createElement("div");return s.innerHTML=(i=t.reduce((l,c)=>`${l}${c.keyName}: ${c.value.join(" \u3001 ")}
2
- `,""))!=null?i:"",s.setAttribute("id","tagToolTag"),e==null||e.appendChild(s),s}static drawLineWithPointList(r,t,i={}){if(t.length<2)return;const e=r.getContext("2d"),{color:o=DEFAULT_COLOR,thickness:s=1,lineCap:l="round",lineType:c=tool.ELineTypes.Line,lineDash:n,hoverEdgeIndex:a}=i;e.save(),(()=>{e.strokeStyle=o,e.lineWidth=s,e.lineCap=l,Array.isArray(n)?e.setLineDash(n):e.setLineDash([])})(),c===tool.ELineTypes.Curve?(a!==void 0&&a>-1&&t.push(t[0]),t=PolygonUtils.createSmoothCurvePointsFromPointList([...t],tool.SEGMENT_NUMBER),a!==void 0&&a>-1&&(t=t.slice((tool.SEGMENT_NUMBER+1)*a,(tool.SEGMENT_NUMBER+1)*(a+1)))):a!==void 0&&a>-1&&(t=[...t,t[0]],t=t.slice(a,a+2));const h=[];e.beginPath(),e.moveTo(t[0].x,t[0].y);for(let f=0;f<t.length-1;f++)t[f].specialEdge&&h.push({i1:f,i2:f+1}),e.lineTo(t[f+1].x,t[f+1].y);e.stroke(),e.save(),e.lineWidth=s*.8,e.lineCap="butt",e.strokeStyle="white",e.setLineDash([3,3]),h.forEach(f=>{const g=t[f.i1],w=t[f.i2];e.beginPath(),e.moveTo(g.x,g.y),e.lineTo(w.x,w.y),e.stroke()}),e.restore();const u=4,y=2;return t.forEach(f=>{f.specialPoint&&(this.drawSpecialPoint(r,f,u+y,o),this.drawSpecialPoint(r,f,u,"white"))}),e.restore(),t}static drawCircle(r,t,i,e={}){const o=r.getContext("2d"),{startAngleDeg:s=0,endAngleDeg:l=360,thickness:c=1,color:n=DEFAULT_COLOR,fill:a=DEFAULT_COLOR}=e,d=UnitUtils.deg2rad(s),h=UnitUtils.deg2rad(l);o.save(),o.beginPath(),o.strokeStyle=n,o.fillStyle=a,o.lineWidth=c,o.arc(t.x,t.y,i,d,h,!1),o.stroke(),a&&o.fill(),o.closePath(),o.restore()}static drawCircleWithFill(r,t,i=3,e={}){const o=r.getContext("2d"),{color:s=DEFAULT_COLOR}=e;o.save();const l=UnitUtils.deg2rad(0),c=UnitUtils.deg2rad(360);o.fillStyle=s,o.beginPath(),o.arc(t.x,t.y,i,l,c,!1),o.fill(),o.restore()}static drawSpecialPoint(r,t,i=6,e){const o=r.getContext("2d"),{x:s,y:l}=t;o.save(),o.beginPath(),o.fillStyle=e;const c=i*1.5,n=c*Math.sqrt(3)/2,a=c/2;o.moveTo(s,l-c),o.lineTo(s-n,l+a),o.lineTo(s+n,l+a),o.closePath(),o.fill(),o.restore()}static drawPolygon(r,t,i={}){const{isClose:e=!1,lineType:o=tool.ELineTypes.Line}=i;return e===!0&&(t=[...t,t[0]]),o===tool.ELineTypes.Curve&&(t=PolygonUtils.createSmoothCurvePointsFromPointList([...t])),this.drawLineWithPointList(r,t,__spreadProps(__spreadValues({},i),{lineType:tool.ELineTypes.Line})),t}static drawPolygonWithFill(r,t,i={}){if(t.length<2)return;const e=r.getContext("2d"),{color:o=DEFAULT_COLOR,lineType:s=tool.ELineTypes.Line}=i;e.save(),e.fillStyle=o,e.beginPath(),s===tool.ELineTypes.Curve&&(t=PolygonUtils.createSmoothCurvePointsFromPointList([...t,t[0]]));const[l,...c]=t;return e.moveTo(l.x,l.y),c.forEach(n=>{e.lineTo(n.x,n.y)}),e.fill(),e.restore(),t}static drawPolygonWithFillAndLine(r,t,i={}){const{strokeColor:e,fillColor:o,thickness:s,lineCap:l,isClose:c,lineType:n}=i,a=this.drawPolygon(r,t,{color:e,thickness:s,lineCap:l,isClose:c,lineType:n});return this.drawPolygonWithFill(r,t,{color:o,lineType:n}),a}static drawPolygonWithKeyPoint(r,t,i={}){const{pointColor:e="white",strokeColor:o}=i,s=this.drawPolygon(r,t,i);return s.forEach(l=>{this.drawCircleWithFill(r,l,4,{color:o}),this.drawCircleWithFill(r,l,3,{color:e})}),s}static drawSelectedPolygonWithFillAndLine(r,t,i={}){const{pointColor:e="white",strokeColor:o}=i,s=this.drawPolygonWithFillAndLine(r,t,i);return s.forEach(l=>{this.drawCircleWithFill(r,l,4,{color:o}),this.drawCircleWithFill(r,l,3,{color:e})}),s}static drawText(r,t,i,e={}){if(!i)return;const o=r.getContext("2d"),{color:s=DEFAULT_COLOR,font:l=tool.DEFAULT_FONT,shadowColor:c="",shadowBlur:n=0,shadowOffsetX:a=0,shadowOffsetY:d=0,textMaxWidth:h=164,offsetX:u=0,offsetY:y=0,textAlign:f="start",lineHeight:g}=e;o.save(),o.textAlign=f,o.fillStyle=s!=null?s:"white",o.font=l,o.shadowColor=c,o.shadowOffsetX=a,o.shadowOffsetY=d,o.shadowBlur=n,this.wrapText(r,`${i}`,t.x+u,t.y+y,h,g),o.restore()}static wrapText(r,t,i,e,o,s){if(typeof t!="string"||typeof i!="number"||typeof e!="number")return;const l=r.getContext("2d");typeof o=="undefined"&&(o=r&&r.width||300),typeof s=="undefined"&&(s=r&&parseInt(window.getComputedStyle(r).lineHeight,10)||parseInt(window.getComputedStyle(document.body).lineHeight,10));const c=t.split(`
2
+ `,""))!=null?i:"",s.setAttribute("id","tagToolTag"),e==null||e.appendChild(s),s}static drawLineWithPointList(r,t,i={}){if(t.length<2)return;const e=r.getContext("2d"),{color:o=DEFAULT_COLOR,thickness:s=1,lineCap:l="round",lineType:c=tool.ELineTypes.Line,lineDash:n,hoverEdgeIndex:a}=i;e.save(),(()=>{e.strokeStyle=o,e.lineWidth=s,e.lineCap=l,Array.isArray(n)?e.setLineDash(n):e.setLineDash([])})(),c===tool.ELineTypes.Curve?(a!==void 0&&a>-1&&t.push(t[0]),t=PolygonUtils.createSmoothCurvePointsFromPointList([...t],tool.SEGMENT_NUMBER),a!==void 0&&a>-1&&(t=t.slice((tool.SEGMENT_NUMBER+1)*a,(tool.SEGMENT_NUMBER+1)*(a+1)))):a!==void 0&&a>-1&&(t=[...t,t[0]],t=t.slice(a,a+2));const h=[];e.beginPath(),e.moveTo(t[0].x,t[0].y);for(let f=0;f<t.length-1;f++)t[f].specialEdge&&h.push({i1:f,i2:f+1}),e.lineTo(t[f+1].x,t[f+1].y);e.stroke(),e.save(),e.lineWidth=s*.8,e.lineCap="butt",e.strokeStyle="white",e.setLineDash([3,3]),h.forEach(f=>{const g=t[f.i1],w=t[f.i2];e.beginPath(),e.moveTo(g.x,g.y),e.lineTo(w.x,w.y),e.stroke()}),e.restore();const u=4,y=2;return t.forEach(f=>{f.specialPoint&&(this.drawSpecialPoint(r,f,u+y,o),this.drawSpecialPoint(r,f,u,"white"))}),e.restore(),t}static drawCircle(r,t,i,e={}){const o=r.getContext("2d"),{startAngleDeg:s=0,endAngleDeg:l=360,thickness:c=1,color:n=DEFAULT_COLOR,fill:a=DEFAULT_COLOR}=e,d=UnitUtils.deg2rad(s),h=UnitUtils.deg2rad(l);o.save(),o.beginPath(),o.strokeStyle=n,o.fillStyle=a,o.lineWidth=c,o.arc(t.x,t.y,i,d,h,!1),o.stroke(),a&&o.fill(),o.closePath(),o.restore()}static drawCircleWithFill(r,t,i=3,e={}){const o=r.getContext("2d"),{color:s=DEFAULT_COLOR}=e;o.save();const l=UnitUtils.deg2rad(0),c=UnitUtils.deg2rad(360);o.fillStyle=s,o.beginPath(),o.arc(t.x,t.y,i,l,c,!1),o.fill(),o.restore()}static drawSpecialPoint(r,t,i=6,e){const o=r.getContext("2d"),{x:s,y:l}=t;o.save(),o.beginPath(),o.fillStyle=e;const c=i*1.5,n=c*Math.sqrt(3)/2,a=c/2;o.moveTo(s,l-c),o.lineTo(s-n,l+a),o.lineTo(s+n,l+a),o.closePath(),o.fill(),o.restore()}static drawPolygon(r,t,i={}){const{isClose:e=!1,lineType:o=tool.ELineTypes.Line}=i;return e===!0&&(t=[...t,t[0]]),o===tool.ELineTypes.Curve&&(t=PolygonUtils.createSmoothCurvePointsFromPointList([...t])),this.drawLineWithPointList(r,t,__spreadProps(__spreadValues({},i),{lineType:tool.ELineTypes.Line})),t}static drawPolygonWithFill(r,t,i={}){if(t.length<2)return;const e=r.getContext("2d"),{color:o=DEFAULT_COLOR,lineType:s=tool.ELineTypes.Line}=i;e.save(),e.fillStyle=o,e.beginPath(),s===tool.ELineTypes.Curve&&(t=PolygonUtils.createSmoothCurvePointsFromPointList([...t,t[0]]));const[l,...c]=t;return e.moveTo(l.x,l.y),c.forEach(n=>{e.lineTo(n.x,n.y)}),e.fill(),e.restore(),t}static drawPolygonWithFillAndLine(r,t,i={}){const{strokeColor:e,fillColor:o,thickness:s,lineCap:l,isClose:c,lineType:n}=i,a=this.drawPolygon(r,t,{color:e,thickness:s,lineCap:l,isClose:c,lineType:n});return this.drawPolygonWithFill(r,t,{color:o,lineType:n}),a}static drawPolygonWithKeyPoint(r,t,i={}){const{pointColor:e="white",strokeColor:o}=i,s=this.drawPolygon(r,t,i);return s.forEach(l=>{this.drawCircleWithFill(r,l,4,{color:o}),this.drawCircleWithFill(r,l,3,{color:e})}),s}static drawSelectedPolygonWithFillAndLine(r,t,i={}){const{pointColor:e="white",strokeColor:o}=i,s=this.drawPolygonWithFillAndLine(r,t,i);return s.forEach(l=>{this.drawCircleWithFill(r,l,4,{color:o}),this.drawCircleWithFill(r,l,3,{color:e})}),s}static drawText(r,t,i,e={}){if(!i)return;const o=r.getContext("2d"),{color:s=DEFAULT_COLOR,font:l=tool.DEFAULT_FONT,shadowColor:c="",shadowBlur:n=0,shadowOffsetX:a=0,shadowOffsetY:d=0,textMaxWidth:h=164,offsetX:u=0,offsetY:y=0,textAlign:f="start",lineHeight:g}=e;!o||(o.save(),Object.assign(o,{textAlign:f,fillStyle:s!=null?s:"white",font:l,shadowColor:c,shadowOffsetX:a,shadowOffsetY:d,shadowBlur:n}),this.wrapText(r,i,t.x+u,t.y+y,h,g),o.restore())}static wrapText(r,t,i,e,o,s){if(typeof t!="string"||typeof i!="number"||typeof e!="number")return;const l=r.getContext("2d");typeof o=="undefined"&&(o=r&&r.width||300),typeof s=="undefined"&&(s=r&&parseInt(window.getComputedStyle(r).lineHeight,10)||parseInt(window.getComputedStyle(document.body).lineHeight,10));const c=t.split(`
3
3
  `);for(let n=0;n<c.length;n++){const a=c[n].split("");let d="";for(let h=0;h<a.length;h++){const u=d+a[h],f=l.measureText(u).width;o||(o=300),f>o&&h>0?(l.fillText(d,i,e),d=a[h],e+=s):d=u}l.fillText(d,i,e),e+=s}}static drawArrow(r,t,i,e={}){const{color:o=DEFAULT_COLOR,thickness:s=1,lineCap:l="round",theta:c=30,headLen:n=10}=e,a=Math.atan2(t.y-i.y,t.x-i.x)*180/Math.PI,d=(a+c)*Math.PI/180,h=(a-c)*Math.PI/180,u=n*Math.cos(d),y=n*Math.sin(d),f=n*Math.cos(h),g=n*Math.sin(h);r.save(),r.strokeStyle=o,r.lineWidth=s,r.lineCap=l,r.beginPath(),r.moveTo(i.x+u,i.y+y),r.lineTo(i.x,i.y),r.lineTo(i.x+f,i.y+g),r.stroke(),r.restore()}static drawArrowByCanvas(r,t,i,e={}){const o=r.getContext("2d");this.drawArrow(o,t,i,e)}static drawCuboid(r,t,i={}){const{backPoints:e,direction:o,frontPoints:s}=t,{strokeColor:l,thickness:c,fillColor:n}=i,a={color:l,thickness:c};if(e){const h=AxisUtils.default.transformPlain2PointList(e);_DrawUtils.drawPolygon(r,h,__spreadProps(__spreadValues({},a),{isClose:!0}));const u=CuboidUtils.getCuboidAllSideLine(t);u==null||u.forEach(y=>{_DrawUtils.drawLine(r,y.p1,y.p2,__spreadValues({},a))})}const d=AxisUtils.default.transformPlain2PointList(s);if(o&&e&&s){const h=CuboidUtils.getPointListsByDirection({direction:o,frontPoints:s,backPoints:e});h&&_DrawUtils.drawPolygonWithFill(r,h,{color:n})}_DrawUtils.drawPolygon(r,d,__spreadProps(__spreadValues({},a),{isClose:!0}))}static drawCuboidWithText(r,t,i,e){const{strokeColor:o}=i,s=o,{config:l,hiddenText:c,selectedID:n,headerText:a,bottomText:d}=e,{backPoints:h,frontPoints:u,textAttribute:y}=t,f=u.br.x-u.bl.x;_DrawUtils.drawCuboid(r,t,i);let g="";(l==null?void 0:l.isShowOrder)&&t.order&&(t==null?void 0:t.order)>0&&(g=`${t.order}`),t.attribute&&(g=`${g} ${AttributeUtils.default.getAttributeShowText(t.attribute,l==null?void 0:l.attributeList)}`),!c&&h&&g&&_DrawUtils.drawText(r,{x:h.tl.x,y:h.tl.y-5},a!=null?a:g,{color:o,textMaxWidth:300});const w=CuboidUtils.getCuboidTextAttributeOffset({cuboid:t,currentPos:{x:0,y:0},zoom:1,topOffset:16,leftOffset:0});if(!c&&y&&t.id!==n){const x=Math.max(20,f*.8);_DrawUtils.drawText(r,{x:w.left,y:w.top},d!=null?d:y,{color:s,textMaxWidth:x})}}static drawPixel({canvas:r,points:t,size:i,defaultRGBA:e,pixelSize:o=13}){const s=r.getContext("2d"),{width:l,height:c}=i,n=s.getImageData(0,0,l,c),[a,d,h,u]=rgba__default.default(e!=null?e:lbUtils.NULL_COLOR),y=g=>{n.data[g]=a,n.data[g+1]=d,n.data[g+2]=h,n.data[g+3]=Math.floor(255*u)},f=lbUtils.MathUtils.generateCoordinates(o);return t.forEach(g=>{for(const[w,x]of f){const C=(g.y+x)*(n.width*4)+(g.x+w)*4;y(C)}}),s.putImageData(n,0,0),{canvas:r}}static drawHighlightFlag(r){const{canvas:t,position:i,color:e,scale:o=.1}=r,s=t.getContext("2d");if(!!s)for(const l of HIGHLIGHT_ICON_SVG_PATHS){s.beginPath();const c=l.d.split(/(?=[CLMZclmz])/);for(const n of c){const d=n.slice(1).split(" ").map(Number).map((h,u)=>u%2==0?h*o+i.x:h*o+i.y);switch(n[0]){case"M":s.moveTo(d[0],d[1]);break;case"C":s.bezierCurveTo(d[0],d[1],d[2],d[3],d[4],d[5]);break;case"L":s.lineTo(d[0],d[1]);break;case"Z":s.closePath();break}}s.fillStyle=e,s.fill()}}};let DrawUtils=_DrawUtils;DrawUtils.drawImg=(r,t,i={})=>{const e=r.getContext("2d"),{zoom:o=DEFAULT_ZOOM,currentPos:s=DEFAULT_CURRENT_POS,rotate:l=DEFAULT_ROTATE,imgAttribute:c}=i;switch(e.save(),l){case 0:e.translate(s.x,s.y);break;case 90:e.translate(s.x+t.height*o,s.y),e.rotate(90*Math.PI/180);break;case 180:e.translate(s.x+t.width*o,s.y+t.height*o),e.rotate(Math.PI);break;case 270:e.translate(s.x,s.y+t.width*o),e.rotate(270*Math.PI/180);break;default:e.translate(s.x,s.y);break}if(c){const{contrast:n,saturation:a,brightness:d}=c;e.filter=`saturate(${a+100}%) contrast(${n+100}%) brightness(${d+100}%)`}e.drawImage(t,0,0,t.width*o,t.height*o),e.restore()},module.exports=DrawUtils;
@@ -1 +1 @@
1
- "use strict";var turf=require("@turf/turf"),annotation=require("../../constant/annotation.js"),CommonToolUtils=require("./CommonToolUtils.js"),tool=require("../../constant/tool.js"),AxisUtils=require("./AxisUtils.js"),MathUtils=require("../MathUtils.js"),LineToolUtils=require("./LineToolUtils.js"),__defProp=Object.defineProperty,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(p,e,t)=>e in p?__defProp(p,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):p[e]=t,__spreadValues=(p,e)=>{for(var t in e||(e={}))__hasOwnProp.call(e,t)&&__defNormalProp(p,t,e[t]);if(__getOwnPropSymbols)for(var t of __getOwnPropSymbols(e))__propIsEnum.call(e,t)&&__defNormalProp(p,t,e[t]);return p};class PolygonUtils{static getHoverPolygonID(e,t,n=3,i=tool.ELineTypes.Line){let o="",r=Infinity;const l=AxisUtils.default.axisArea(e,n);return t.forEach(s=>{s.pointList&&l.forEach(c=>{const u=this.calcPolygonSize(s.pointList);this.isInPolygon(c,s.pointList,i)&&u<r&&(o=s.id,r=u)})}),o}static calcPolygonSize(e=[]){if((e==null?void 0:e.length)<=2)return 0;const t=e.length,n=e.reduce((i,o,r,l)=>{const s=l[(r+1)%t];return i+o.x*s.y-s.x*o.y},0);return Math.abs(n)/2}static isInPolygon(e,t,n=tool.ELineTypes.Line){return t=[...t],n===tool.ELineTypes.Curve&&(t=this.createSmoothCurvePoints(t.reduce((i,o)=>[...i,o.x,o.y],[]),.5,!0,20)),this.isPointInOrOnPolygon(e,t)}static isPointInOrOnPolygon(e,t,n=1e-9){const{x:i,y:o}=e;let r=!1;for(let l=0,s=t.length-1;l<t.length;s=l++){const{x:c,y:u}=t[l],{x:h,y:d}=t[s],y=i<=Math.max(c,h)&&i>=Math.min(c,h)&&o<=Math.max(u,d)&&o>=Math.min(u,d),P=(o-u)*(h-c)-(i-c)*(d-u);if(y&&Math.abs(P)<n)return!0;u>o!=d>o&&i<(h-c)*(o-u)/(d-u)+c&&(r=!r)}return r}static createSmoothCurvePointsFromPointList(e,t=tool.SEGMENT_NUMBER){return this.createSmoothCurvePoints(e.reduce((i,o)=>[...i,o.x,o.y],[]),.5,!1,t).map((i,o)=>{var r;const l=o/(tool.SEGMENT_NUMBER+1),s=Math.floor(l),c=(r=e[s])!=null?r:{};return __spreadValues(s===l?__spreadValues({},c):{specialEdge:c.specialEdge},i)})}static createSmoothCurvePoints(e,t=.5,n=!1,i=tool.SEGMENT_NUMBER){if(e.length<4)return e;const o=[],r=e.slice(0);let l,s,c,u,h,d,y,P,x,m,a,g,f;for(n?(r.unshift(e[e.length-1]),r.unshift(e[e.length-2]),r.unshift(e[e.length-1]),r.unshift(e[e.length-2]),r.push(e[0]),r.push(e[1])):(r.unshift(e[1]),r.unshift(e[0]),r.push(e[e.length-2]),r.push(e[e.length-1])),f=2;f<r.length-4;f+=2)for(c=(r[f+2]-r[f-2])*t,u=(r[f+4]-r[f-0])*t,h=(r[f+3]-r[f-1])*t,d=(r[f+5]-r[f+1])*t,g=0;g<=i;g++)a=g/i,y=2*Math.pow(a,3)-3*Math.pow(a,2)+1,P=-(2*Math.pow(a,3))+3*Math.pow(a,2),x=Math.pow(a,3)-2*Math.pow(a,2)+a,m=Math.pow(a,3)-Math.pow(a,2),l=y*r[f]+P*r[f+2]+x*c+m*u,s=y*r[f+1]+P*r[f+3]+x*h+m*d,o.push(l),o.push(s);const v=[];for(let E=0;E<o.length-1;E+=2)v.push({x:o[E],y:o[E+1]});if(n)for(let E=0;E<i+1;E++){const L=v.shift();v.push(L)}return v}static getPolygonByID(e,t){return e.find(n=>n.id===t)}static getPolygonByIDs(e,t){return t&&(t==null?void 0:t.length)>0?e.filter(n=>t.includes(n.id)):[]}static getHoverEdgeIndex(e,t,n=tool.ELineTypes.Line,i=5){let o=[...t];n===tool.ELineTypes.Curve?o=this.createSmoothCurvePoints(t.reduce((s,c)=>[...s,c.x,c.y],[]),.5,!0,tool.SEGMENT_NUMBER):n===tool.ELineTypes.Line&&o.push(o[0]);let r=-1,l=i;for(let s=0;s<o.length-1;s++){const{length:c}=MathUtils.default.getFootOfPerpendicular(e,o[s],o[s+1],!0);c<l&&(r=s,l=c)}return r===-1?-1:n===tool.ELineTypes.Curve?Math.floor(r/tool.SEGMENT_NUMBER):r}static getClosestPoint(e,t,n=tool.ELineTypes.Line,i=3,o){var r;let l=!1;const s=(r=o==null?void 0:o.isClose)!=null?r:!0;let c="",u=-1,h=Infinity,d=e;const y=20;let P=!1;return t.forEach(x=>{if(!P&&!!x.pointList)switch(n){case tool.ELineTypes.Line:CommonToolUtils.findAllLine(x.pointList,s).forEach((a,g)=>{if(P)return;let{length:f,footPoint:v}=MathUtils.default.getFootOfPerpendicular(e,a.point1,a.point2);const E=MathUtils.default.getLineLength(a.point1,e),L=MathUtils.default.getLineLength(a.point2,e);E<i*2&&(v=a.point1,f=E,P=!0),L<i*2&&(v=a.point2,f=L,P=!0),f<h&&f<i&&(c=x.id,u=g,h=f,d=v,l=!0)});break;case tool.ELineTypes.Curve:{const m=this.createSmoothCurvePoints(x.pointList.reduce((a,g)=>[...a,g.x,g.y],[]),.5,s,y);for(let a=0;a<m.length-1;a++){const{length:g,footPoint:f}=MathUtils.default.getFootOfPerpendicular(e,m[a],m[a+1]);g<h&&g<i&&(c=x.id,u=Math.floor(a/(y+1)),h=g,d=f,l=!0)}}break}}),{dropFoot:d,closestEdgeIndex:u,closestPolygonID:c,hasClosed:l}}static isPointListInPolygon(e,t,n=tool.ELineTypes.Line){return e.every(i=>this.isInPolygon(i,t,n))}static isPointListOutSidePolygon(e,t,n=tool.ELineTypes.Line){return e.some(i=>!this.isInPolygon(i,t,n))}static getPolygonArea(e){let t=0;for(let n=0,i=e.length;n<i;n++){const o=e[n].x,r=e[n===e.length-1?0:n+1].y,l=e[n===e.length-1?0:n+1].x,s=e[n].y;t+=o*r*.5,t-=l*s*.5}return Math.abs(t)}static updatePolygonByRotate(e,t=1,n){let i=1;return e===annotation.ERotateDirection.Anticlockwise&&(i=-1),i*=t,MathUtils.default.rotateRectPointList(i,n)}static deletePolygonLastPoint(e,t,n,i){return n===i.length-1?e:[...e,{x:t[0],y:t[1]}]}static concatBeginAndEnd(e){return e.length<1?e:[...e,e[0]]}static segmentPolygonByPolygon(e,t){var n,i;try{let o=turf.polygon([[...PolygonUtils.concatBeginAndEnd(e.map(l=>[l.x,l.y]))]]);return t.forEach(l=>{const s=turf.polygon([[...PolygonUtils.concatBeginAndEnd(l.pointList.map(u=>[u.x,u.y]))]]),c=turf.difference(o,s);c&&(o=c)}),((i=(n=o==null?void 0:o.geometry)==null?void 0:n.coordinates.map(l=>{var s;return((s=o==null?void 0:o.geometry)==null?void 0:s.type)==="MultiPolygon"?l[0].reduce(PolygonUtils.deletePolygonLastPoint,[]):l.reduce(PolygonUtils.deletePolygonLastPoint,[])}))!=null?i:[]).reduce((l,s)=>{const c=s.length,u=s.filter((h,d)=>{const y=(d+1)%c;return!AxisUtils.default.getIsInScope(h,s[y],1)});return u.length<3?l:[...l,u]},[])}catch(o){console.error(o)}}static getPolygonPointList(e,t){const n=t.find(i=>i.id===e);return n&&n.pointList&&n.pointList.length>0?n.pointList:[]}static getWrapPolygonIndex(e,t){return t.findIndex(n=>PolygonUtils.isPointListInPolygon(e,n.pointList))}static clipPolygonFromWrapPolygon(e,t){const n=PolygonUtils.isPolygonClosewise(t),i=PolygonUtils.isPolygonClosewise(e),o=PolygonUtils.getClosePointDistanceFromPolygon(e[0],t),r=t[o];let l=[...t.slice(0,o),r,...e,e[0],...t.slice(o,t.length)];return n===i&&(l=[...t.slice(0,o),r,e[0],...e.reverse(),...t.slice(o,t.length)]),l}static isPolygonClosewise(e){const t=e.length;let n,i,o,r=0,l;if(t<3)return 0;for(n=0;n<t;n++)i=(n+1)%t,o=(n+2)%t,l=(e[i].x-e[n].x)*(e[o].y-e[i].y),l-=(e[i].y-e[n].y)*(e[o].x-e[i].x),l<0?r--:l>0&&r++;return r>0?1:r<0?-1:0}static getClosePointDistanceFromPolygon(e,t){let n=Number.MAX_SAFE_INTEGER,i=-1;return t.forEach((o,r)=>{const l=LineToolUtils.default.calcDistance(e,o);l<n&&(n=l,i=r)}),i}static combinePolygonWithPolygon(e,t){var n,i;try{const o=turf.polygon([[...PolygonUtils.concatBeginAndEnd(e.pointList.map(u=>[u.x,u.y]))]]),r=turf.polygon([[...PolygonUtils.concatBeginAndEnd(t.pointList.map(u=>[u.x,u.y]))]]),l=turf.union(o,r),s=[],c=e;if(((i=(n=l==null?void 0:l.geometry)==null?void 0:n.coordinates)==null?void 0:i.length)===1){s.push(t.id);const u=l==null?void 0:l.geometry.coordinates.map(h=>{var d;return((d=l==null?void 0:l.geometry)==null?void 0:d.type)==="MultiPolygon"?h[0].reduce(PolygonUtils.deletePolygonLastPoint,[]):h.reduce(PolygonUtils.deletePolygonLastPoint,[])})[0];c.pointList=u}return{newPolygon:c,unionList:s}}catch(o){console.error(o)}}static composePointList(e,t){let n=0,i=0,o=Number.MAX_VALUE;return e.forEach((r,l)=>{t.forEach((s,c)=>{const u=LineToolUtils.default.calcDistance(r,s);u<o&&(n=l+1,i=c+1,o=u)})}),[...e.slice(0,n),...t.slice(i,t.length),...t.slice(0,i),...e.slice(n,e.length)]}static composeSegmentPolygonList(e){var t,n;const i=[];for(let o=0;o<e.length;o++)for(let r=0;r<e.length;r++){const l=(t=e[o])==null?void 0:t.pointList,s=(n=e[r])==null?void 0:n.pointList;o!==r&&l&&s&&PolygonUtils.isPointListInPolygon(s,l)&&(e[o].pointList=PolygonUtils.composePointList(l,s),i.unshift(r))}return i.forEach(o=>{e.splice(o,1)}),e}static computeConvexHull(e){e.sort((o,r)=>o.x!==r.x?o.x-r.x:o.y-r.y);const t=(o,r,l)=>(r.x-o.x)*(l.y-o.y)-(r.y-o.y)*(l.x-o.x),n=[];for(const o of e){for(;n.length>=2&&t(n[n.length-2],n[n.length-1],o)<=0;)n.pop();n.push(o)}const i=[];for(let o=e.length-1;o>=0;o--){const r=e[o];for(;i.length>=2&&t(i[i.length-2],i[i.length-1],r)<=0;)i.pop();i.push(r)}return i.pop(),n.pop(),n.concat(i)}static createConvexHullGroup(e){const t={};return e.forEach(n=>{n.type==="line"&&(t[n.annotation.id]||(t[n.annotation.id]={points:[],convexHull:[]}),t[n.annotation.id].points.push(...n.annotation.pointList))}),Object.keys(t).forEach(n=>{t[n].convexHull=this.computeConvexHull(t[n].points)}),t}}module.exports=PolygonUtils;
1
+ "use strict";var turf=require("@turf/turf"),annotation=require("../../constant/annotation.js"),CommonToolUtils=require("./CommonToolUtils.js"),tool=require("../../constant/tool.js"),AxisUtils=require("./AxisUtils.js"),MathUtils=require("../MathUtils.js"),LineToolUtils=require("./LineToolUtils.js"),__defProp=Object.defineProperty,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(p,e,t)=>e in p?__defProp(p,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):p[e]=t,__spreadValues=(p,e)=>{for(var t in e||(e={}))__hasOwnProp.call(e,t)&&__defNormalProp(p,t,e[t]);if(__getOwnPropSymbols)for(var t of __getOwnPropSymbols(e))__propIsEnum.call(e,t)&&__defNormalProp(p,t,e[t]);return p};class PolygonUtils{static getHoverPolygonID(e,t,n=3,i=tool.ELineTypes.Line){let o="",r=Infinity;const l=AxisUtils.default.axisArea(e,n);return t.forEach(s=>{s.pointList&&l.forEach(c=>{if(this.isInPolygon(c,s.pointList,i)){const u=this.calcPolygonSize(s.pointList);u<r&&(o=s.id,r=u)}})}),o}static calcPolygonSize(e=[]){if((e==null?void 0:e.length)<=2)return 0;const t=e.length,n=e.reduce((i,o,r,l)=>{const s=l[(r+1)%t];return i+o.x*s.y-s.x*o.y},0);return Math.abs(n)/2}static isInPolygon(e,t,n=tool.ELineTypes.Line){return t=[...t],n===tool.ELineTypes.Curve&&(t=this.createSmoothCurvePoints(t.reduce((i,o)=>[...i,o.x,o.y],[]),.5,!0,20)),this.isPointInOrOnPolygon(e,t)}static isPointInOrOnPolygon(e,t,n=1e-9){const{x:i,y:o}=e;let r=!1;for(let l=0,s=t.length-1;l<t.length;s=l++){const{x:c,y:u}=t[l],{x:h,y:d}=t[s],y=i<=Math.max(c,h)&&i>=Math.min(c,h)&&o<=Math.max(u,d)&&o>=Math.min(u,d),P=(o-u)*(h-c)-(i-c)*(d-u);if(y&&Math.abs(P)<n)return!0;u>o!=d>o&&i<(h-c)*(o-u)/(d-u)+c&&(r=!r)}return r}static createSmoothCurvePointsFromPointList(e,t=tool.SEGMENT_NUMBER){return this.createSmoothCurvePoints(e.reduce((i,o)=>[...i,o.x,o.y],[]),.5,!1,t).map((i,o)=>{var r;const l=o/(tool.SEGMENT_NUMBER+1),s=Math.floor(l),c=(r=e[s])!=null?r:{};return __spreadValues(s===l?__spreadValues({},c):{specialEdge:c.specialEdge},i)})}static createSmoothCurvePoints(e,t=.5,n=!1,i=tool.SEGMENT_NUMBER){if(e.length<4)return e;const o=[],r=e.slice(0);let l,s,c,u,h,d,y,P,x,m,a,g,f;for(n?(r.unshift(e[e.length-1]),r.unshift(e[e.length-2]),r.unshift(e[e.length-1]),r.unshift(e[e.length-2]),r.push(e[0]),r.push(e[1])):(r.unshift(e[1]),r.unshift(e[0]),r.push(e[e.length-2]),r.push(e[e.length-1])),f=2;f<r.length-4;f+=2)for(c=(r[f+2]-r[f-2])*t,u=(r[f+4]-r[f-0])*t,h=(r[f+3]-r[f-1])*t,d=(r[f+5]-r[f+1])*t,g=0;g<=i;g++)a=g/i,y=2*Math.pow(a,3)-3*Math.pow(a,2)+1,P=-(2*Math.pow(a,3))+3*Math.pow(a,2),x=Math.pow(a,3)-2*Math.pow(a,2)+a,m=Math.pow(a,3)-Math.pow(a,2),l=y*r[f]+P*r[f+2]+x*c+m*u,s=y*r[f+1]+P*r[f+3]+x*h+m*d,o.push(l),o.push(s);const v=[];for(let E=0;E<o.length-1;E+=2)v.push({x:o[E],y:o[E+1]});if(n)for(let E=0;E<i+1;E++){const L=v.shift();v.push(L)}return v}static getPolygonByID(e,t){return e.find(n=>n.id===t)}static getPolygonByIDs(e,t){return t&&(t==null?void 0:t.length)>0?e.filter(n=>t.includes(n.id)):[]}static getHoverEdgeIndex(e,t,n=tool.ELineTypes.Line,i=5){let o=[...t];n===tool.ELineTypes.Curve?o=this.createSmoothCurvePoints(t.reduce((s,c)=>[...s,c.x,c.y],[]),.5,!0,tool.SEGMENT_NUMBER):n===tool.ELineTypes.Line&&o.push(o[0]);let r=-1,l=i;for(let s=0;s<o.length-1;s++){const{length:c}=MathUtils.default.getFootOfPerpendicular(e,o[s],o[s+1],!0);c<l&&(r=s,l=c)}return r===-1?-1:n===tool.ELineTypes.Curve?Math.floor(r/tool.SEGMENT_NUMBER):r}static getClosestPoint(e,t,n=tool.ELineTypes.Line,i=3,o){var r;let l=!1;const s=(r=o==null?void 0:o.isClose)!=null?r:!0;let c="",u=-1,h=Infinity,d=e;const y=20;let P=!1;return t.forEach(x=>{if(!P&&!!x.pointList)switch(n){case tool.ELineTypes.Line:CommonToolUtils.findAllLine(x.pointList,s).forEach((a,g)=>{if(P)return;let{length:f,footPoint:v}=MathUtils.default.getFootOfPerpendicular(e,a.point1,a.point2);const E=MathUtils.default.getLineLength(a.point1,e),L=MathUtils.default.getLineLength(a.point2,e);E<i*2&&(v=a.point1,f=E,P=!0),L<i*2&&(v=a.point2,f=L,P=!0),f<h&&f<i&&(c=x.id,u=g,h=f,d=v,l=!0)});break;case tool.ELineTypes.Curve:{const m=this.createSmoothCurvePoints(x.pointList.reduce((a,g)=>[...a,g.x,g.y],[]),.5,s,y);for(let a=0;a<m.length-1;a++){const{length:g,footPoint:f}=MathUtils.default.getFootOfPerpendicular(e,m[a],m[a+1]);g<h&&g<i&&(c=x.id,u=Math.floor(a/(y+1)),h=g,d=f,l=!0)}}break}}),{dropFoot:d,closestEdgeIndex:u,closestPolygonID:c,hasClosed:l}}static isPointListInPolygon(e,t,n=tool.ELineTypes.Line){return e.every(i=>this.isInPolygon(i,t,n))}static isPointListOutSidePolygon(e,t,n=tool.ELineTypes.Line){return e.some(i=>!this.isInPolygon(i,t,n))}static getPolygonArea(e){let t=0;for(let n=0,i=e.length;n<i;n++){const o=e[n].x,r=e[n===e.length-1?0:n+1].y,l=e[n===e.length-1?0:n+1].x,s=e[n].y;t+=o*r*.5,t-=l*s*.5}return Math.abs(t)}static updatePolygonByRotate(e,t=1,n){let i=1;return e===annotation.ERotateDirection.Anticlockwise&&(i=-1),i*=t,MathUtils.default.rotateRectPointList(i,n)}static deletePolygonLastPoint(e,t,n,i){return n===i.length-1?e:[...e,{x:t[0],y:t[1]}]}static concatBeginAndEnd(e){return e.length<1?e:[...e,e[0]]}static segmentPolygonByPolygon(e,t){var n,i;try{let o=turf.polygon([[...PolygonUtils.concatBeginAndEnd(e.map(l=>[l.x,l.y]))]]);return t.forEach(l=>{const s=turf.polygon([[...PolygonUtils.concatBeginAndEnd(l.pointList.map(u=>[u.x,u.y]))]]),c=turf.difference(o,s);c&&(o=c)}),((i=(n=o==null?void 0:o.geometry)==null?void 0:n.coordinates.map(l=>{var s;return((s=o==null?void 0:o.geometry)==null?void 0:s.type)==="MultiPolygon"?l[0].reduce(PolygonUtils.deletePolygonLastPoint,[]):l.reduce(PolygonUtils.deletePolygonLastPoint,[])}))!=null?i:[]).reduce((l,s)=>{const c=s.length,u=s.filter((h,d)=>{const y=(d+1)%c;return!AxisUtils.default.getIsInScope(h,s[y],1)});return u.length<3?l:[...l,u]},[])}catch(o){console.error(o)}}static getPolygonPointList(e,t){const n=t.find(i=>i.id===e);return n&&n.pointList&&n.pointList.length>0?n.pointList:[]}static getWrapPolygonIndex(e,t){return t.findIndex(n=>PolygonUtils.isPointListInPolygon(e,n.pointList))}static clipPolygonFromWrapPolygon(e,t){const n=PolygonUtils.isPolygonClosewise(t),i=PolygonUtils.isPolygonClosewise(e),o=PolygonUtils.getClosePointDistanceFromPolygon(e[0],t),r=t[o];let l=[...t.slice(0,o),r,...e,e[0],...t.slice(o,t.length)];return n===i&&(l=[...t.slice(0,o),r,e[0],...e.reverse(),...t.slice(o,t.length)]),l}static isPolygonClosewise(e){const t=e.length;let n,i,o,r=0,l;if(t<3)return 0;for(n=0;n<t;n++)i=(n+1)%t,o=(n+2)%t,l=(e[i].x-e[n].x)*(e[o].y-e[i].y),l-=(e[i].y-e[n].y)*(e[o].x-e[i].x),l<0?r--:l>0&&r++;return r>0?1:r<0?-1:0}static getClosePointDistanceFromPolygon(e,t){let n=Number.MAX_SAFE_INTEGER,i=-1;return t.forEach((o,r)=>{const l=LineToolUtils.default.calcDistance(e,o);l<n&&(n=l,i=r)}),i}static combinePolygonWithPolygon(e,t){var n,i;try{const o=turf.polygon([[...PolygonUtils.concatBeginAndEnd(e.pointList.map(u=>[u.x,u.y]))]]),r=turf.polygon([[...PolygonUtils.concatBeginAndEnd(t.pointList.map(u=>[u.x,u.y]))]]),l=turf.union(o,r),s=[],c=e;if(((i=(n=l==null?void 0:l.geometry)==null?void 0:n.coordinates)==null?void 0:i.length)===1){s.push(t.id);const u=l==null?void 0:l.geometry.coordinates.map(h=>{var d;return((d=l==null?void 0:l.geometry)==null?void 0:d.type)==="MultiPolygon"?h[0].reduce(PolygonUtils.deletePolygonLastPoint,[]):h.reduce(PolygonUtils.deletePolygonLastPoint,[])})[0];c.pointList=u}return{newPolygon:c,unionList:s}}catch(o){console.error(o)}}static composePointList(e,t){let n=0,i=0,o=Number.MAX_VALUE;return e.forEach((r,l)=>{t.forEach((s,c)=>{const u=LineToolUtils.default.calcDistance(r,s);u<o&&(n=l+1,i=c+1,o=u)})}),[...e.slice(0,n),...t.slice(i,t.length),...t.slice(0,i),...e.slice(n,e.length)]}static composeSegmentPolygonList(e){var t,n;const i=[];for(let o=0;o<e.length;o++)for(let r=0;r<e.length;r++){const l=(t=e[o])==null?void 0:t.pointList,s=(n=e[r])==null?void 0:n.pointList;o!==r&&l&&s&&PolygonUtils.isPointListInPolygon(s,l)&&(e[o].pointList=PolygonUtils.composePointList(l,s),i.unshift(r))}return i.forEach(o=>{e.splice(o,1)}),e}static computeConvexHull(e){e.sort((o,r)=>o.x!==r.x?o.x-r.x:o.y-r.y);const t=(o,r,l)=>(r.x-o.x)*(l.y-o.y)-(r.y-o.y)*(l.x-o.x),n=[];for(const o of e){for(;n.length>=2&&t(n[n.length-2],n[n.length-1],o)<=0;)n.pop();n.push(o)}const i=[];for(let o=e.length-1;o>=0;o--){const r=e[o];for(;i.length>=2&&t(i[i.length-2],i[i.length-1],r)<=0;)i.pop();i.push(r)}return i.pop(),n.pop(),n.concat(i)}static createConvexHullGroup(e){const t={};return e.forEach(n=>{n.type==="line"&&(t[n.annotation.id]||(t[n.annotation.id]={points:[],convexHull:[]}),t[n.annotation.id].points.push(...n.annotation.pointList))}),Object.keys(t).forEach(n=>{t[n].convexHull=this.computeConvexHull(t[n].points)}),t}}module.exports=PolygonUtils;
@@ -1 +1 @@
1
- "use strict";var uuid=require("../uuid.js"),__defProp=Object.defineProperty,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(n,t,e)=>t in n?__defProp(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,__spreadValues=(n,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(n,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(n,e,t[e]);return n};class TagUtil{static getTagKeyName(t,e){var r,l;if(!!e)return(l=(r=e.find(u=>u.value===t))==null?void 0:r.key)!=null?l:""}static getTagName([t="",e=""],r){if(!!r){for(const l of r)if(l.value===t){if(!l.subSelected)return console.error("\u6807\u7B7E\u89E3\u6790\u9519\u8BEF",t,e),"";for(const u of l.subSelected)if(u.value===e)return u.key}}}static getTagNameList(t,e){return Object.keys(t).length<=0?[]:Object.entries(t).reduce((r,l)=>{const[u,s]=l;if(s&&s.length>0){const i=s.split(";"),a={keyName:this.getTagKeyName(u,e),value:i.map(o=>this.getTagName([u,o],e))};return[...r,a]}return r},[]).filter(r=>r)}static getTagnameListWithoutConfig(t){return Object.keys(t).length<=0?[]:Object.entries(t).reduce((e,r)=>{const[l,u]=r,s=u.split(";"),i={keyName:l,value:s};return[...e,i]},[]).filter(e=>e)}static judgeResultIsInInputList(t,e,r){return!t||!e||!r?!1:r.filter(u=>{if(u.value===t&&u.subSelected){const s=e==null?void 0:e.split(";");return(u==null?void 0:u.subSelected.filter(i=>s.indexOf(i.value)>-1).length)>0}return!1}).length>0}static getDefaultResultByConfig(t){return t.reduce((e,r)=>(r.subSelected&&r.subSelected.forEach(l=>{var u;if(l.isDefault){const s=(u=e[r.value])!=null?u:"";let i=[];s.length>0&&(i=s.split(";")),i.push(l.value),e[r.value]=i.join(";")}}),e),{})}static getDefaultTagResult(t,e){const r=this.getDefaultResultByConfig(t!=null?t:[]);return e.length>0?e.map(l=>({id:uuid(),sourceID:l.id,result:__spreadValues({},r)})):[{id:uuid(),sourceID:"",result:__spreadValues({},r)}]}}module.exports=TagUtil;
1
+ "use strict";var uuid=require("../uuid.js"),__defProp=Object.defineProperty,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(n,t,e)=>t in n?__defProp(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,__spreadValues=(n,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(n,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(n,e,t[e]);return n};class TagUtil{static getTagKeyName(t,e){var r,l;if(!!e)return(l=(r=e.find(u=>u.value===t))==null?void 0:r.key)!=null?l:""}static getTagName([t="",e=""],r){if(!!r){for(const l of r)if(l.value===t){if(!l.subSelected)return console.error("\u6807\u7B7E\u89E3\u6790\u9519\u8BEF",t,e),"";for(const u of l.subSelected)if(u.value===e)return u.key}}}static getTagNameList(t,e){return Object.keys(t).length<=0?[]:Object.entries(t).reduce((r,l)=>{var u;const[i,s]=l;if(s&&s.length>0){const o=s.split(";"),a=(u=this.getTagKeyName(i,e))!=null?u:"",f=o.map(c=>this.getTagName([i,c],e));if(a.trim()!=="")return[...r,{keyName:a,value:f}]}return r},[]).filter(r=>r)}static getTagnameListWithoutConfig(t){return Object.keys(t).length<=0?[]:Object.entries(t).reduce((e,r)=>{const[l,u]=r,i=u.split(";"),s={keyName:l,value:i};return[...e,s]},[]).filter(e=>e)}static judgeResultIsInInputList(t,e,r){return!t||!e||!r?!1:r.filter(u=>{if(u.value===t&&u.subSelected){const i=e==null?void 0:e.split(";");return(u==null?void 0:u.subSelected.filter(s=>i.indexOf(s.value)>-1).length)>0}return!1}).length>0}static getDefaultResultByConfig(t){return t.reduce((e,r)=>(r.subSelected&&r.subSelected.forEach(l=>{var u;if(l.isDefault){const i=(u=e[r.value])!=null?u:"";let s=[];i.length>0&&(s=i.split(";")),s.push(l.value),e[r.value]=s.join(";")}}),e),{})}static getDefaultTagResult(t,e){const r=this.getDefaultResultByConfig(t!=null?t:[]);return e.length>0?e.map(l=>({id:uuid(),sourceID:l.id,result:__spreadValues({},r)})):[{id:uuid(),sourceID:"",result:__spreadValues({},r)}]}}module.exports=TagUtil;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var tool=require("../../constant/tool.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,l)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[t]=l,__spreadValues=(e,t)=>{for(var l in t||(t={}))__hasOwnProp.call(t,l)&&__defNormalProp(e,l,t[l]);if(__getOwnPropSymbols)for(var l of __getOwnPropSymbols(t))__propIsEnum.call(t,l)&&__defNormalProp(e,l,t[l]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t));function createSmoothCurvePoints(e,t=.5,l=!1,s=16){if(e.length<4)return e;const f=[],r=e.slice(0);let a,o,x,y,p,m,_,v,w,P,h,c,u;for(l?(r.unshift(e[e.length-1]),r.unshift(e[e.length-2]),r.unshift(e[e.length-1]),r.unshift(e[e.length-2]),r.push(e[0]),r.push(e[1])):(r.unshift(e[1]),r.unshift(e[0]),r.push(e[e.length-2]),r.push(e[e.length-1])),u=2;u<r.length-4;u+=2)for(x=(r[u+2]-r[u-2])*t,y=(r[u+4]-r[u-0])*t,p=(r[u+3]-r[u-1])*t,m=(r[u+5]-r[u+1])*t,c=0;c<=s;c++)h=c/s,_=2*Math.pow(h,3)-3*Math.pow(h,2)+1,v=-(2*Math.pow(h,3))+3*Math.pow(h,2),w=Math.pow(h,3)-2*Math.pow(h,2)+h,P=Math.pow(h,3)-Math.pow(h,2),a=_*r[u]+v*r[u+2]+w*x+P*y,o=_*r[u+1]+v*r[u+3]+w*p+P*m,f.push(a),f.push(o);const i=[];for(let n=0;n<f.length-1;n+=2)i.push({x:f[n],y:f[n+1]});if(l)for(let n=0;n<s+1;n++){const M=i.shift();i.push(M)}return i}const createSmoothCurvePointsFromPointList=(e,t=16)=>createSmoothCurvePoints(e.reduce((l,s)=>[...l,s.x,s.y],[]),.5,!1,t);function isInPolygon(e,t,l=tool.ELineTypes.Line){let s=0,f,r,a,o;t=[...t],l===tool.ELineTypes.Curve&&(t=createSmoothCurvePoints(t.reduce((y,p)=>[...y,p.x,p.y],[]),.5,!0,tool.SEGMENT_NUMBER)),[a]=t;const x=t.length;for(f=1;f<=x;f++)o=t[f%x],e.x>Math.min(a.x,o.x)&&e.x<=Math.max(a.x,o.x)&&e.y<=Math.max(a.y,o.y)&&a.x!==o.x&&(r=(e.x-a.x)*(o.y-a.y)/(o.x-a.x)+a.y,(a.y===o.y||e.y<=r)&&s++),a=o;return s%2!=0}function getPolygonPointUnderZoom(e,t=1){return e.map(l=>__spreadProps(__spreadValues({},l),{x:l.x*t,y:l.y*t}))}exports.createSmoothCurvePoints=createSmoothCurvePoints,exports.createSmoothCurvePointsFromPointList=createSmoothCurvePointsFromPointList,exports.getPolygonPointUnderZoom=getPolygonPointUnderZoom,exports.isInPolygon=isInPolygon;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var tool=require("../../constant/tool.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,a)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,__spreadValues=(e,t)=>{for(var a in t||(t={}))__hasOwnProp.call(t,a)&&__defNormalProp(e,a,t[a]);if(__getOwnPropSymbols)for(var a of __getOwnPropSymbols(t))__propIsEnum.call(t,a)&&__defNormalProp(e,a,t[a]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t));function createSmoothCurvePoints(e,t=.5,a=!1,h=16){if(e.length<4)return e;const l=[],r=e.slice(0);let m,_,M,c,u,o,i,p,y,x,n,v,f;for(a?(r.unshift(e[e.length-1]),r.unshift(e[e.length-2]),r.unshift(e[e.length-1]),r.unshift(e[e.length-2]),r.push(e[0]),r.push(e[1])):(r.unshift(e[1]),r.unshift(e[0]),r.push(e[e.length-2]),r.push(e[e.length-1])),f=2;f<r.length-4;f+=2)for(M=(r[f+2]-r[f-2])*t,c=(r[f+4]-r[f-0])*t,u=(r[f+3]-r[f-1])*t,o=(r[f+5]-r[f+1])*t,v=0;v<=h;v++)n=v/h,i=2*Math.pow(n,3)-3*Math.pow(n,2)+1,p=-(2*Math.pow(n,3))+3*Math.pow(n,2),y=Math.pow(n,3)-2*Math.pow(n,2)+n,x=Math.pow(n,3)-Math.pow(n,2),m=i*r[f]+p*r[f+2]+y*M+x*c,_=i*r[f+1]+p*r[f+3]+y*u+x*o,l.push(m),l.push(_);const w=[];for(let s=0;s<l.length-1;s+=2)w.push({x:l[s],y:l[s+1]});if(a)for(let s=0;s<h+1;s++){const g=w.shift();w.push(g)}return w}const createSmoothCurvePointsFromPointList=(e,t=16)=>createSmoothCurvePoints(e.reduce((a,h)=>[...a,h.x,h.y],[]),.5,!1,t);function isInPolygon(e,t,a=tool.ELineTypes.Line){let h=0,l,r;a===tool.ELineTypes.Curve&&(t=createSmoothCurvePoints(t.flatMap(u=>[u.x,u.y]),.5,!0,tool.SEGMENT_NUMBER));const[m,_,M,c]=t.reduce(([u,o,i,p],{x:y,y:x})=>[Math.min(u,y),Math.max(o,y),Math.min(i,x),Math.max(p,x)],[Infinity,-Infinity,Infinity,-Infinity]);if(e.x<m||e.x>_||e.y<M||e.y>c)return!1;l=t[t.length-1];for(let u=0;u<t.length;u++){if(r=t[u],e.y>Math.min(l.y,r.y)&&e.y<=Math.max(l.y,r.y)&&e.x<=Math.max(l.x,r.x)){const o=l.y!==r.y?(e.y-l.y)*(r.x-l.x)/(r.y-l.y)+l.x:l.x;e.x<=o&&h++}if(l=r,h%2!=0&&u>t.length/2)break}return h%2!=0}function getPolygonPointUnderZoom(e,t=1){return e.map(a=>__spreadProps(__spreadValues({},a),{x:a.x*t,y:a.y*t}))}exports.createSmoothCurvePoints=createSmoothCurvePoints,exports.createSmoothCurvePointsFromPointList=createSmoothCurvePointsFromPointList,exports.getPolygonPointUnderZoom=getPolygonPointUnderZoom,exports.isInPolygon=isInPolygon;
@@ -1 +1 @@
1
- import{createBase64WorkerFactory as b}from"./_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js";var l=b("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwp2YXIgd29ya2VyX2NvZGU9ZnVuY3Rpb24ocCl7InVzZSBzdHJpY3QiO2NvbnN0IHY9Wy0xLC0xLC0xXTtsZXQgST0hMTtmdW5jdGlvbiBCKGUpe2NvbnN0IHQ9LTcsbz0zLG49by10O3JldHVybiBlPHQmJihlPXQpLGU+byYmKGU9byksTWF0aC5mbG9vcigoZS10KS9uKjI1NSl9ZnVuY3Rpb24gRSgpe2xldCBlO2NvbnN0IHQ9b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h7cG9seWdvblBvaW50TGlzdDpmLnBvbHlnb25Qb2ludExpc3Qsek1pbjpmLnpNaW4sek1heDpmLnpNYXgseDpDLHk6TCx6OmQsYXR0cmlidXRlOmYuYXR0cmlidXRlLGNvbG9yTGlzdDp4LHZhbGlkOmYudmFsaWR9KTtyZXR1cm4gTT8oYygpLGc9TSxzPSEwLCEwKTohMX0pLCFzJiZ1Lmxlbmd0aCYmKHM9dS5zb21lKGY9Pmgoe3g6Qyx5Okx9LGYpPyhnPW0oZCksITApOiExKSksIXMmJiFfJiYoST9nPW0oZCk6Zz12KX1lbHNlIHcuc29tZShzPT57Y29uc3QgZj1PKHtwb2x5Z29uUG9pbnRMaXN0OnMucG9seWdvblBvaW50TGlzdCx6TWluOnMuek1pbix6TWF4OnMuek1heCx4OkMseTpMLHo6ZCxhdHRyaWJ1dGU6cy5hdHRyaWJ1dGUsY29sb3JMaXN0OngsdmFsaWQ6cy52YWxpZH0pO3JldHVybiBmPyhjKCksZz1mLCEwKTohMX0pO2NvbnN0IEE9cz0+e2NvbnN0IGY9TWF0aC5mbG9vcihzLzMpO3JldHVybiBpJiZpW2ZdPT09MX07aWYoZylpZihnWzBdPT09dlswXSYmQShyKSluW3JdPTAsbltyKzFdPTAsbltyKzJdPTA7ZWxzZXtjb25zdFtzLGYsTV09ZztuW3JdPXMsbltyKzFdPWYsbltyKzJdPU19ZWxzZSBpZihBKHIpKW5bcl09MCxuW3IrMV09MCxuW3IrMl09MDtlbHNle2NvbnN0W3MsZixNXT1tKGQpO25bcl09cyxuW3IrMV09ZixuW3IrMl09TX19ST1fLHBvc3RNZXNzYWdlKHtwb2ludHM6byxjb2xvcjpuLG51bTp5fSl9LHAuaXNJblBvbHlnb249aCxPYmplY3QuZGVmaW5lUHJvcGVydHkocCwiX19lc01vZHVsZSIse3ZhbHVlOiEwfSkscH0oe30pOwoK",null,!1);export{l as default};
1
+ import{createBase64WorkerFactory as b}from"./_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFact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