@armyc2.c5isr.renderer/mil-sym-ts-web 2.2.0
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.
- package/LICENSE +201 -0
- package/README.md +57 -0
- package/buildNode.bat +2 -0
- package/buildWeb.bat +2 -0
- package/dist/C5Ren.d.ts +6970 -0
- package/dist/C5Ren.js +2 -0
- package/dist/C5Ren.js.map +1 -0
- package/dist/LICENSE +201 -0
- package/dist/README.md +57 -0
- package/dist/armyc2.c5isr.renderer-mil-sym-ts-web-2.2.0.tgz +0 -0
- package/dist/manifest.json +4 -0
- package/dist/package.json +16 -0
- package/index.ts +169 -0
- package/package.bak +50 -0
- package/package.json +40 -0
- package/package.node.json +43 -0
- package/package.pack.json +19 -0
- package/package.packWeb.json +16 -0
- package/package.web.json +40 -0
- package/src/main/ts/android/graphics/Bitmap.ts +7 -0
- package/src/main/ts/android/graphics/Paint.ts +26 -0
- package/src/main/ts/android/graphics/Path.ts +78 -0
- package/src/main/ts/android/graphics/PointF.ts +14 -0
- package/src/main/ts/android/graphics/Rect.ts +18 -0
- package/src/main/ts/android/graphics/RectF.ts +50 -0
- package/src/main/ts/android/graphics/Region.ts +36 -0
- package/src/main/ts/android/graphics/Typeface.ts +11 -0
- package/src/main/ts/armyc2/c5isr/JavaLineArray/BasicShapes.ts +99 -0
- package/src/main/ts/armyc2/c5isr/JavaLineArray/CChannelPoints2.ts +34 -0
- package/src/main/ts/armyc2/c5isr/JavaLineArray/CELineArray.ts +193 -0
- package/src/main/ts/armyc2/c5isr/JavaLineArray/Channels.ts +2971 -0
- package/src/main/ts/armyc2/c5isr/JavaLineArray/DISMSupport.ts +4008 -0
- package/src/main/ts/armyc2/c5isr/JavaLineArray/POINT2.ts +93 -0
- package/src/main/ts/armyc2/c5isr/JavaLineArray/Shape2.ts +89 -0
- package/src/main/ts/armyc2/c5isr/JavaLineArray/TacticalLines.ts +515 -0
- package/src/main/ts/armyc2/c5isr/JavaLineArray/arraysupport.ts +5403 -0
- package/src/main/ts/armyc2/c5isr/JavaLineArray/countsupport.ts +1084 -0
- package/src/main/ts/armyc2/c5isr/JavaLineArray/flot.ts +2173 -0
- package/src/main/ts/armyc2/c5isr/JavaLineArray/lineutility.ts +4934 -0
- package/src/main/ts/armyc2/c5isr/JavaLineArray/ref.ts +7 -0
- package/src/main/ts/armyc2/c5isr/JavaTacticalRenderer/Modifier2.ts +5601 -0
- package/src/main/ts/armyc2/c5isr/JavaTacticalRenderer/P1.ts +14 -0
- package/src/main/ts/armyc2/c5isr/JavaTacticalRenderer/TGLight.ts +648 -0
- package/src/main/ts/armyc2/c5isr/JavaTacticalRenderer/clsChannelUtility.ts +647 -0
- package/src/main/ts/armyc2/c5isr/JavaTacticalRenderer/clsMETOC.ts +2994 -0
- package/src/main/ts/armyc2/c5isr/JavaTacticalRenderer/clsUtility.ts +2663 -0
- package/src/main/ts/armyc2/c5isr/JavaTacticalRenderer/mdlGeodesic.ts +669 -0
- package/src/main/ts/armyc2/c5isr/RenderMultipoints/clsClipPolygon2.ts +971 -0
- package/src/main/ts/armyc2/c5isr/RenderMultipoints/clsClipQuad.ts +871 -0
- package/src/main/ts/armyc2/c5isr/RenderMultipoints/clsRenderer.ts +3507 -0
- package/src/main/ts/armyc2/c5isr/RenderMultipoints/clsRenderer2.ts +500 -0
- package/src/main/ts/armyc2/c5isr/RenderMultipoints/clsUtility.ts +1089 -0
- package/src/main/ts/armyc2/c5isr/RenderMultipoints/clsUtilityCPOF.ts +2656 -0
- package/src/main/ts/armyc2/c5isr/RenderMultipoints/clsUtilityGE.ts +1419 -0
- package/src/main/ts/armyc2/c5isr/data/genc.json +1407 -0
- package/src/main/ts/armyc2/c5isr/data/msd.json +17311 -0
- package/src/main/ts/armyc2/c5isr/data/mse.json +18500 -0
- package/src/main/ts/armyc2/c5isr/data/svgd.json +31214 -0
- package/src/main/ts/armyc2/c5isr/data/svge.json +30558 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/AffineTransform.ts +10 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/Area.ts +437 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/BasicStroke.ts +429 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/BasicTypes.ts +7 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/BufferedImage.ts +35 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/Font.ts +111 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/FontMetrics.ts +29 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/FontRenderContext.ts +18 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/GeneralPath.ts +211 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/Graphics2D.ts +80 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/IPathIterator.ts +33 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/ImageIO.ts +16 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/Line2D.ts +726 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/PathIterator.ts +141 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/Point.ts +112 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/Point2D.ts +261 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/Polygon.ts +391 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/Rectangle.ts +567 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/Rectangle2D.ts +445 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/Shape.ts +31 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/Stroke.ts +18 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/TextLayout.ts +45 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/TexturePaint.ts +25 -0
- package/src/main/ts/armyc2/c5isr/renderer/IIconRenderer.ts +15 -0
- package/src/main/ts/armyc2/c5isr/renderer/IconRenderer.ts +22 -0
- package/src/main/ts/armyc2/c5isr/renderer/MilStdIconRenderer.ts +269 -0
- package/src/main/ts/armyc2/c5isr/renderer/ModifierRenderer.ts +9882 -0
- package/src/main/ts/armyc2/c5isr/renderer/PatternFillRenderer.ts +146 -0
- package/src/main/ts/armyc2/c5isr/renderer/SinglePointSVGRenderer.ts +1265 -0
- package/src/main/ts/armyc2/c5isr/renderer/shapes/arc.ts +64 -0
- package/src/main/ts/armyc2/c5isr/renderer/shapes/bcurve.ts +95 -0
- package/src/main/ts/armyc2/c5isr/renderer/shapes/ellipse.ts +93 -0
- package/src/main/ts/armyc2/c5isr/renderer/shapes/line.ts +114 -0
- package/src/main/ts/armyc2/c5isr/renderer/shapes/path.ts +555 -0
- package/src/main/ts/armyc2/c5isr/renderer/shapes/pathiterator.ts +62 -0
- package/src/main/ts/armyc2/c5isr/renderer/shapes/point.ts +120 -0
- package/src/main/ts/armyc2/c5isr/renderer/shapes/rectangle.ts +431 -0
- package/src/main/ts/armyc2/c5isr/renderer/shapes/roundedrectangle.ts +99 -0
- package/src/main/ts/armyc2/c5isr/renderer/shapes/types.ts +25 -0
- package/src/main/ts/armyc2/c5isr/renderer/shapes/utilities.ts +203 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/AffiliationColors.ts +104 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/Color.ts +481 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/DistanceUnit.ts +40 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/DrawRules.ts +1323 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/EntityCode.ts +51 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/ErrorLogger.ts +736 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/GENCLookup.ts +106 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/GeoPixelConversion3D.ts +84 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/IMultiPointRenderer.ts +87 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/IPointConversion.ts +34 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/ImageInfo.ts +324 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/LRUCache.ts +127 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/LRUEntry.ts +18 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/LogLevel.ts +111 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/MODrawRules.ts +219 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/MSInfo.ts +1008 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/MSLookup.ts +882 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/MilStdAttributes.ts +380 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/MilStdSymbol.ts +797 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/Modifiers.ts +1699 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/PointConversion.ts +178 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/PointConversionDummy.ts +45 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/PointConverter3D.ts +126 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/RectUtilities.ts +118 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/RendererException.ts +11 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/RendererSettings.ts +1201 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/RendererUtilities.ts +591 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/SVGInfo.ts +29 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/SVGLookup.ts +753 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/SVGSymbolInfo.ts +137 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/SVGTextInfo.ts +438 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/SettingsChangedEvent.ts +19 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/SettingsChangedEventListener.ts +10 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/SettingsEventListener.ts +5 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/Shape2SVG.ts +404 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/ShapeInfo.ts +525 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/ShapeUtilities.ts +55 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/SymbolDimensionInfo.ts +36 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/SymbolID.ts +1055 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/SymbolUtilities.ts +2085 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/TextInfo.ts +157 -0
- package/src/main/ts/armyc2/c5isr/web/render/GeoPixelConversion.ts +86 -0
- package/src/main/ts/armyc2/c5isr/web/render/MultiPointHandler.ts +3798 -0
- package/src/main/ts/armyc2/c5isr/web/render/MultiPointHandlerSVG.ts +412 -0
- package/src/main/ts/armyc2/c5isr/web/render/PointConverter.ts +124 -0
- package/src/main/ts/armyc2/c5isr/web/render/SymbolModifiers.ts +26 -0
- package/src/main/ts/armyc2/c5isr/web/render/WebRenderer.ts +677 -0
- package/src/main/ts/armyc2/c5isr/web/render/utilities/JavaRendererUtilities.ts +484 -0
- package/src/main/ts/armyc2/c5isr/web/render/utilities/LineInfo.ts +62 -0
- package/src/main/ts/armyc2/c5isr/web/render/utilities/SymbolInfo.ts +46 -0
- package/src/main/ts/armyc2/c5isr/web/render/utilities/TextInfo.ts +51 -0
- package/src/main/ts/org/gavaghan/geodesy/Angle.ts +31 -0
- package/src/main/ts/org/gavaghan/geodesy/Ellipsoid.ts +71 -0
- package/src/main/ts/org/gavaghan/geodesy/GeodeticCalculator.ts +200 -0
- package/src/main/ts/org/gavaghan/geodesy/GeodeticCurve.ts +55 -0
- package/src/main/ts/org/gavaghan/geodesy/GeodeticMeasurement.ts +68 -0
- package/src/main/ts/org/gavaghan/geodesy/GlobalCoordinates.ts +103 -0
- package/src/main/ts/org/gavaghan/geodesy/GlobalPosition.ts +90 -0
- package/test/ExportSPImages.js +692 -0
- package/test/MPWW.html +556 -0
- package/test/MPWorker.js +318 -0
- package/test/SPWorker.js +233 -0
- package/test/SVGWW.html +363 -0
- package/test/singlePointTester3.html +751 -0
- package/tsconfig.json +54 -0
- package/typedoc.json +30 -0
- package/updateVersion.js +21 -0
- package/webpack.config.js +34 -0
- package/webpackn.config.js +28 -0
- package/webpackr.config.js +47 -0
- package/webpackw.config.js +23 -0
|
@@ -0,0 +1,871 @@
|
|
|
1
|
+
import { type int, type double } from "../../c5isr/graphics2d/BasicTypes";
|
|
2
|
+
|
|
3
|
+
import { lineutility } from "../JavaLineArray/lineutility"
|
|
4
|
+
import { POINT2 } from "../JavaLineArray/POINT2"
|
|
5
|
+
import { Shape2 } from "../JavaLineArray/Shape2"
|
|
6
|
+
import { TacticalLines } from "../JavaLineArray/TacticalLines"
|
|
7
|
+
import { TGLight } from "../JavaTacticalRenderer/TGLight"
|
|
8
|
+
import { ErrorLogger } from "../renderer/utilities/ErrorLogger"
|
|
9
|
+
import { RendererException } from "../renderer/utilities/RendererException"
|
|
10
|
+
import { clsUtility } from "../JavaTacticalRenderer/clsUtility"
|
|
11
|
+
import { clsUtilityCPOF } from "../RenderMultipoints/clsUtilityCPOF"
|
|
12
|
+
import { clsUtilityGE } from "../RenderMultipoints/clsUtilityGE"
|
|
13
|
+
import { Point2D } from "../graphics2d/Point2D";
|
|
14
|
+
import { Polygon } from "../graphics2d/Polygon";
|
|
15
|
+
import { Line2D } from "../graphics2d/Line2D";
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Class to clip polygons
|
|
20
|
+
*
|
|
21
|
+
*/
|
|
22
|
+
export class clsClipQuad {
|
|
23
|
+
private static readonly _className: string = "clsClipQuad";
|
|
24
|
+
/**
|
|
25
|
+
* Use the new version which takes an array for polygon clip bounds instead of rectangle
|
|
26
|
+
* @param polygon
|
|
27
|
+
* @param clipBounds
|
|
28
|
+
* @return
|
|
29
|
+
*/
|
|
30
|
+
private static AddBoundaryPointsForLines(polygon: Array<Point2D>,
|
|
31
|
+
clipBounds: Array<Point2D>): int {
|
|
32
|
+
let result: int = 0;
|
|
33
|
+
try {
|
|
34
|
+
let pt02d: Point2D = polygon[0];
|
|
35
|
+
let ptLast2d: Point2D = polygon[(polygon.length - 1)];
|
|
36
|
+
let pt0: POINT2 = new POINT2(pt02d.getX(), pt02d.getY());
|
|
37
|
+
let ptLast: POINT2 = new POINT2(ptLast2d.getX(), ptLast2d.getY());
|
|
38
|
+
let nearestPt: Point2D = new Point2D();
|
|
39
|
+
let clipArray: Polygon = new Polygon();
|
|
40
|
+
let j: int = 0;
|
|
41
|
+
let minDist: double = Number.MAX_VALUE;
|
|
42
|
+
let dist: double = 0;
|
|
43
|
+
let sidePt: POINT2 = new POINT2();
|
|
44
|
+
let addToFront: boolean = false;
|
|
45
|
+
let addToEnd: boolean = false;
|
|
46
|
+
//int n=clipBounds.length;
|
|
47
|
+
//for(j=0;j<clipBounds.length;j++)
|
|
48
|
+
for (j = 0; j < clipBounds.length; j++) //was n
|
|
49
|
+
{
|
|
50
|
+
clipArray.addPoint(clipBounds[j].getX() as int, clipBounds[j].getY() as int);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
let totalX: double = 0;
|
|
54
|
+
let totalY: double = 0;
|
|
55
|
+
let counter: int = 0;
|
|
56
|
+
//for(j=0;j<clipBounds.length-1;j++)
|
|
57
|
+
for (j = 0; j < clipBounds.length - 1; j++) //was n-1
|
|
58
|
+
{
|
|
59
|
+
totalX += clipBounds[j].getX();
|
|
60
|
+
totalY += clipBounds[j].getY();
|
|
61
|
+
counter++;
|
|
62
|
+
}
|
|
63
|
+
//if clipBounds is not closed add the jth point
|
|
64
|
+
if (clipBounds[0].getX() !== clipBounds[j].getX() ||
|
|
65
|
+
clipBounds[0].getY() !== clipBounds[j].getY()) {
|
|
66
|
+
totalX += clipBounds[j].getX();
|
|
67
|
+
totalY += clipBounds[j].getY();
|
|
68
|
+
counter++;
|
|
69
|
+
}
|
|
70
|
+
let avgX: double = totalX / counter;
|
|
71
|
+
let avgY: double = totalY / counter;
|
|
72
|
+
let ptCenter: POINT2 = new POINT2(avgX, avgY);
|
|
73
|
+
let ptNear: POINT2;
|
|
74
|
+
//first point outside the clip bounds
|
|
75
|
+
if (clipArray.contains(pt02d) === false) {
|
|
76
|
+
//add nearest segment midpoint to the front
|
|
77
|
+
//for(j=0;j<clipBounds.length;j++)
|
|
78
|
+
for (j = 0; j < clipBounds.length; j++) //was n
|
|
79
|
+
{
|
|
80
|
+
sidePt.x = clipBounds[j].getX();
|
|
81
|
+
sidePt.y = clipBounds[j].getY();
|
|
82
|
+
dist = lineutility.CalcDistanceDouble(pt0, sidePt);
|
|
83
|
+
if (dist < minDist) {
|
|
84
|
+
minDist = dist;
|
|
85
|
+
//minDistIndex=j;
|
|
86
|
+
nearestPt.setLocation(sidePt.x, sidePt.y);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
//move nearestPt in a bit to not get clipped
|
|
90
|
+
ptNear = new POINT2(nearestPt.getX(), nearestPt.getY());
|
|
91
|
+
ptNear = lineutility.ExtendAlongLineDouble(ptNear, ptCenter, 2);
|
|
92
|
+
nearestPt.setLocation(ptNear.x, ptNear.y);
|
|
93
|
+
polygon.splice(0, 0, nearestPt);
|
|
94
|
+
addToFront = true;
|
|
95
|
+
}
|
|
96
|
+
//re-initialize variables
|
|
97
|
+
nearestPt = new Point2D();
|
|
98
|
+
minDist = Number.MAX_VALUE;
|
|
99
|
+
//last point outside the clip bounds
|
|
100
|
+
if (clipArray.contains(ptLast2d) === false) {
|
|
101
|
+
//add nearest segment midpoint to the front
|
|
102
|
+
//for(j=0;j<clipBounds.length;j++)
|
|
103
|
+
for (j = 0; j < clipBounds.length; j++) //was n
|
|
104
|
+
{
|
|
105
|
+
sidePt.x = clipBounds[j].getX();
|
|
106
|
+
sidePt.y = clipBounds[j].getY();
|
|
107
|
+
dist = lineutility.CalcDistanceDouble(ptLast, sidePt);
|
|
108
|
+
if (dist < minDist) {
|
|
109
|
+
minDist = dist;
|
|
110
|
+
//minDistIndex=j;
|
|
111
|
+
nearestPt.setLocation(sidePt.x, sidePt.y);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
//move nearestPt in a bit to not get clipped
|
|
115
|
+
ptNear = new POINT2(nearestPt.getX(), nearestPt.getY());
|
|
116
|
+
ptNear = lineutility.ExtendAlongLineDouble(ptNear, ptCenter, 2);
|
|
117
|
+
nearestPt.setLocation(ptNear.x, ptNear.y);
|
|
118
|
+
polygon.push(nearestPt);
|
|
119
|
+
addToEnd = true;
|
|
120
|
+
}
|
|
121
|
+
if (addToFront === false && addToEnd === false) {
|
|
122
|
+
result = 0;
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
if (addToFront === true && addToEnd === false) {
|
|
126
|
+
result = 1;
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
if (addToFront === false && addToEnd === true) {
|
|
130
|
+
result = 2;
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
if (addToFront === true && addToEnd === true) {
|
|
134
|
+
result = 3;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
} catch (exc) {
|
|
143
|
+
if (exc instanceof Error) {
|
|
144
|
+
ErrorLogger.LogException(clsClipQuad._className, "AddBoundaryPointsForLines",
|
|
145
|
+
new RendererException("Failed inside AddBoundaryPointsForLines", exc));
|
|
146
|
+
} else {
|
|
147
|
+
throw exc;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return result;
|
|
151
|
+
}
|
|
152
|
+
private static CalcTrueIntersectDouble(m1: double,
|
|
153
|
+
b1: double,
|
|
154
|
+
m2: double,
|
|
155
|
+
b2: double,
|
|
156
|
+
bolVertical1: int,
|
|
157
|
+
bolVertical2: int,
|
|
158
|
+
X1: double, //x intercept if line1 is vertical
|
|
159
|
+
X2: double): Point2D {
|
|
160
|
+
let ptIntersect: Point2D = new Point2D(X1, X2);
|
|
161
|
+
try {
|
|
162
|
+
let x: double = 0;
|
|
163
|
+
let y: double = 0;
|
|
164
|
+
|
|
165
|
+
if (bolVertical1 === 0 && bolVertical2 === 0) {
|
|
166
|
+
//both lines vertical
|
|
167
|
+
return ptIntersect;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
//the following 3 if blocks are the only ways to get an intersection
|
|
171
|
+
if (bolVertical1 === 0 && bolVertical2 === 1) //line1 vertical, line2 not
|
|
172
|
+
{
|
|
173
|
+
ptIntersect.setLocation(X1, m2 * X1 + b2);
|
|
174
|
+
return ptIntersect;
|
|
175
|
+
}
|
|
176
|
+
if (bolVertical1 === 1 && bolVertical2 === 0) //line2 vertical, line1 not
|
|
177
|
+
{
|
|
178
|
+
ptIntersect.setLocation(X2, m1 * X2 + b1);
|
|
179
|
+
return ptIntersect;
|
|
180
|
+
}
|
|
181
|
+
//if either of the lines is vertical function has already returned
|
|
182
|
+
//so both m1 and m2 should be valid
|
|
183
|
+
//should always be using this ocase because the lines are neither vertical
|
|
184
|
+
//or horizontal and are perpendicular
|
|
185
|
+
if (m1 !== m2) {
|
|
186
|
+
x = (b2 - b1) / (m1 - m2); //cannot blow up
|
|
187
|
+
y = (m1 * x + b1);
|
|
188
|
+
ptIntersect.setLocation(x, y);
|
|
189
|
+
return ptIntersect;
|
|
190
|
+
}
|
|
191
|
+
} catch (exc) {
|
|
192
|
+
if (exc instanceof Error) {
|
|
193
|
+
ErrorLogger.LogException(clsClipQuad._className, "CalcTrueIntersectDouble",
|
|
194
|
+
new RendererException("Failed inside CalcTrueIntersectDouble", exc));
|
|
195
|
+
} else {
|
|
196
|
+
throw exc;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return ptIntersect;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Gets theoretical intersection of an edge with the line connecting previous and current points.
|
|
203
|
+
* @param previous
|
|
204
|
+
* @param current
|
|
205
|
+
* @param currentEdge the current edge of the clip area, assumed to not be vertical
|
|
206
|
+
* @return
|
|
207
|
+
*/
|
|
208
|
+
private static intersectPoint2(previous: Point2D,
|
|
209
|
+
current: Point2D,
|
|
210
|
+
currentEdge: Line2D): Point2D {
|
|
211
|
+
|
|
212
|
+
let ptIntersect: Point2D;
|
|
213
|
+
try {
|
|
214
|
+
let ll: Point2D = currentEdge.getP1();
|
|
215
|
+
let ul: Point2D = currentEdge.getP2();
|
|
216
|
+
|
|
217
|
+
//no vertical client segments
|
|
218
|
+
//if(current.getX()==previous.getX())
|
|
219
|
+
if (Math.abs(current.getX() - previous.getX()) < 1) {
|
|
220
|
+
|
|
221
|
+
current.setLocation(current.getX() + 1, current.getY());
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
let m1: double = (ul.getY() - ll.getY()) / (ul.getX() - ll.getX());
|
|
226
|
+
let m2: double = (current.getY() - previous.getY()) / (current.getX() - previous.getX());
|
|
227
|
+
let b1: double = ul.getY() - m1 * ul.getX();
|
|
228
|
+
let b2: double = current.getY() - m2 * current.getX();
|
|
229
|
+
ptIntersect = clsClipQuad.CalcTrueIntersectDouble(m1, b1, m2, b2, 1, 1, 0, 0);
|
|
230
|
+
} catch (exc) {
|
|
231
|
+
if (exc instanceof Error) {
|
|
232
|
+
ErrorLogger.LogException(clsClipQuad._className, "intersectPoint2",
|
|
233
|
+
new RendererException("Failed inside intersectPoint2", exc));
|
|
234
|
+
} else {
|
|
235
|
+
throw exc;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return ptIntersect;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* clips array of pts against a side of the clip bounds polygon
|
|
243
|
+
* assumes clipBounds has no vertical or horizontal segments
|
|
244
|
+
* @param pts array of points to clip against the clip bounds
|
|
245
|
+
* @param index starting index of clipBounds for the side to clip against
|
|
246
|
+
* @param clipBounds a quadrilateral or a polygon array that is the clipping area
|
|
247
|
+
* @return the clipped array of points
|
|
248
|
+
*/
|
|
249
|
+
private static clipSide(tg: TGLight, pts: Array<Point2D>,
|
|
250
|
+
index: int,
|
|
251
|
+
clipBounds: Array<Point2D>): Array<Point2D> {
|
|
252
|
+
let ptsResult: Array<Point2D>;
|
|
253
|
+
try {
|
|
254
|
+
let pt1: Point2D = new Point2D(clipBounds[index].getX(), clipBounds[index].getY());//first point of clip side
|
|
255
|
+
let pt2: Point2D = new Point2D(clipBounds[index + 1].getX(), clipBounds[index + 1].getY());//last point of clip side
|
|
256
|
+
let clipBoundsPoint: Point2D;//some point in the clipbounds not on the side
|
|
257
|
+
let ptClipBoundsIntersect: Point2D;//some point in the clipbounds not on the side
|
|
258
|
+
let m1: double = 0;
|
|
259
|
+
let m2: double = 0;
|
|
260
|
+
let b1: double = 0;
|
|
261
|
+
let b2: double = 0;
|
|
262
|
+
let b3: double = 0;
|
|
263
|
+
let b4: double = 0;
|
|
264
|
+
let ptPreviousIntersect: Point2D;
|
|
265
|
+
let ptCurrentIntersect: Point2D;
|
|
266
|
+
let j: int = 0;
|
|
267
|
+
let clipBoundsQuadrant: int = -1;
|
|
268
|
+
let previousQuadrant: int = -1;
|
|
269
|
+
let currentQuadrant: int = -1; //quadrants relative to side
|
|
270
|
+
let current: Point2D;
|
|
271
|
+
let previous: Point2D;
|
|
272
|
+
let intersectPt: Point2D;
|
|
273
|
+
let edge: Line2D;
|
|
274
|
+
ptsResult = new Array();
|
|
275
|
+
//set some point in the array which is not in the side
|
|
276
|
+
//this point will be used to define which side of the clipping side the rest of the clipbounds points are on
|
|
277
|
+
//then it can be used to figure out whether a given point is to be clipped
|
|
278
|
+
//for this scheme to work it needs to be a convex clipping area
|
|
279
|
+
if (index === 0) {
|
|
280
|
+
clipBoundsPoint = new Point2D(clipBounds[index + 2].getX(), clipBounds[index + 2].getY());
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
if (index > 1) {
|
|
284
|
+
clipBoundsPoint = new Point2D(clipBounds[index - 2].getX(), clipBounds[index - 2].getY());
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
if (index === 1) {
|
|
288
|
+
clipBoundsPoint = new Point2D(clipBounds[0].getX(), clipBounds[0].getY());
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
//no vertical segments
|
|
296
|
+
//if(pt2.getX()==pt1.getX())
|
|
297
|
+
if (Math.abs(pt2.getX() - pt1.getX()) < 1) {
|
|
298
|
+
|
|
299
|
+
pt2.setLocation(pt2.getX() + 1, pt2.getY());
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
//if(pt2.getY()==pt1.getY())
|
|
303
|
+
if (Math.abs(pt2.getY() - pt1.getY()) < 1) {
|
|
304
|
+
|
|
305
|
+
pt2.setLocation(pt2.getX(), pt2.getY() + 1);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
for (j = 0; j < pts.length; j++) {
|
|
310
|
+
current = pts[j];
|
|
311
|
+
if (j === 0) {
|
|
312
|
+
previous = pts[pts.length - 1];
|
|
313
|
+
}
|
|
314
|
+
else {
|
|
315
|
+
previous = pts[j - 1];
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
m1 = (pt2.getY() - pt1.getY()) / (pt2.getX() - pt1.getX());
|
|
319
|
+
m2 = -1 / m1; //the slope of the line perpendicular to m1,b1
|
|
320
|
+
b1 = pt2.getY() - m1 * pt2.getX();
|
|
321
|
+
b2 = previous.getY() - m2 * previous.getX();
|
|
322
|
+
b3 = current.getY() - m2 * current.getX();
|
|
323
|
+
b4 = clipBoundsPoint.getY() - m2 * clipBoundsPoint.getX();
|
|
324
|
+
ptPreviousIntersect = clsClipQuad.CalcTrueIntersectDouble(m1, b1, m2, b2, 1, 1, 0, 0);
|
|
325
|
+
ptCurrentIntersect = clsClipQuad.CalcTrueIntersectDouble(m1, b1, m2, b3, 1, 1, 0, 0);
|
|
326
|
+
ptClipBoundsIntersect = clsClipQuad.CalcTrueIntersectDouble(m1, b1, m2, b4, 1, 1, 0, 0);
|
|
327
|
+
clipBoundsQuadrant = lineutility.GetQuadrantDouble(clipBoundsPoint.getX(), clipBoundsPoint.getY(), ptClipBoundsIntersect.getX(), ptClipBoundsIntersect.getY());
|
|
328
|
+
previousQuadrant = lineutility.GetQuadrantDouble(previous.getX(), previous.getY(), ptPreviousIntersect.getX(), ptPreviousIntersect.getY());
|
|
329
|
+
currentQuadrant = lineutility.GetQuadrantDouble(current.getX(), current.getY(), ptCurrentIntersect.getX(), ptCurrentIntersect.getY());
|
|
330
|
+
|
|
331
|
+
//case: both inside
|
|
332
|
+
if (previousQuadrant === clipBoundsQuadrant && currentQuadrant === clipBoundsQuadrant) {
|
|
333
|
+
|
|
334
|
+
ptsResult.push(current);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
else {
|
|
338
|
+
if (previousQuadrant === clipBoundsQuadrant && currentQuadrant !== clipBoundsQuadrant)//previous inside, current outside
|
|
339
|
+
{
|
|
340
|
+
edge = new Line2D(pt1, pt2);
|
|
341
|
+
intersectPt = clsClipQuad.intersectPoint2(previous, current, edge);
|
|
342
|
+
if (intersectPt != null) {
|
|
343
|
+
ptsResult.push(intersectPt);
|
|
344
|
+
}
|
|
345
|
+
tg.set_WasClipped(true);
|
|
346
|
+
}
|
|
347
|
+
else {
|
|
348
|
+
if (previousQuadrant !== clipBoundsQuadrant && currentQuadrant === clipBoundsQuadrant)//current inside, previous outside
|
|
349
|
+
{
|
|
350
|
+
edge = new Line2D(pt1, pt2);
|
|
351
|
+
intersectPt = clsClipQuad.intersectPoint2(previous, current, edge);
|
|
352
|
+
if (intersectPt != null) {
|
|
353
|
+
ptsResult.push(intersectPt);
|
|
354
|
+
}
|
|
355
|
+
ptsResult.push(current);
|
|
356
|
+
tg.set_WasClipped(true);
|
|
357
|
+
}
|
|
358
|
+
else {
|
|
359
|
+
if (previousQuadrant !== clipBoundsQuadrant && currentQuadrant !== clipBoundsQuadrant) {
|
|
360
|
+
|
|
361
|
+
continue;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
}//end for j=0 to pts.length-1
|
|
371
|
+
} catch (exc) {
|
|
372
|
+
if (exc instanceof Error) {
|
|
373
|
+
ErrorLogger.LogException(clsClipQuad._className, "clipSide",
|
|
374
|
+
new RendererException("Failed inside clipSide", exc));
|
|
375
|
+
} else {
|
|
376
|
+
throw exc;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
return ptsResult;
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* for pre-clipped lines which also require fill but need the processed points
|
|
383
|
+
* to create the fill. This function is called after the clip, so the fill
|
|
384
|
+
* does not get clipped.
|
|
385
|
+
* @param tg
|
|
386
|
+
* @param shapes
|
|
387
|
+
*/
|
|
388
|
+
protected static addAbatisFill(tg: TGLight,
|
|
389
|
+
shapes: Array<Shape2>): void {
|
|
390
|
+
try {
|
|
391
|
+
if (tg.Pixels == null ||
|
|
392
|
+
tg.Pixels.length < 2 ||
|
|
393
|
+
tg.get_FillColor() == null ||
|
|
394
|
+
tg.get_FillColor().getAlpha() < 2 ||
|
|
395
|
+
shapes == null) {
|
|
396
|
+
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
let j: int = 0;
|
|
402
|
+
let n: int = tg.Pixels.length;
|
|
403
|
+
let shape: Shape2;
|
|
404
|
+
let tg2: TGLight;
|
|
405
|
+
switch (tg.get_LineType()) {
|
|
406
|
+
case TacticalLines.MSDZ: {
|
|
407
|
+
let dist0: double = 0;
|
|
408
|
+
let dist1: double = 0;
|
|
409
|
+
let dist2: double = 0;
|
|
410
|
+
shape = new Shape2(Shape2.SHAPE_TYPE_POLYLINE);
|
|
411
|
+
shape.setFillColor(tg.get_FillColor());
|
|
412
|
+
if (tg.Pixels != null && tg.Pixels.length >= 300) {
|
|
413
|
+
dist0 = Math.abs(tg.Pixels[0].x - tg.Pixels[50].x);
|
|
414
|
+
dist1 = Math.abs(tg.Pixels[100].x - tg.Pixels[150].x);
|
|
415
|
+
dist2 = Math.abs(tg.Pixels[200].x - tg.Pixels[250].x);
|
|
416
|
+
let start: int = -1;
|
|
417
|
+
let end: int = -1;
|
|
418
|
+
if (dist0 >= dist1 && dist0 >= dist2) {
|
|
419
|
+
start = 0;
|
|
420
|
+
end = 99;
|
|
421
|
+
}
|
|
422
|
+
else {
|
|
423
|
+
if (dist1 >= dist0 && dist1 >= dist2) {
|
|
424
|
+
start = 100;
|
|
425
|
+
end = 199;
|
|
426
|
+
}
|
|
427
|
+
else {
|
|
428
|
+
start = 200;
|
|
429
|
+
end = 299;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
shape.moveTo(tg.Pixels[start]);
|
|
434
|
+
for (j = start; j <= end; j++) {
|
|
435
|
+
|
|
436
|
+
shape.lineTo(tg.Pixels[j]);
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
|
|
440
|
+
//shapes.add(0,shape);
|
|
441
|
+
}
|
|
442
|
+
break;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
case TacticalLines.ABATIS: {
|
|
446
|
+
shape = new Shape2(Shape2.SHAPE_TYPE_POLYLINE);
|
|
447
|
+
shape.setFillColor(tg.get_FillColor());
|
|
448
|
+
tg2 = new TGLight();
|
|
449
|
+
tg2.set_LineType(TacticalLines.GENERAL);
|
|
450
|
+
tg2.Pixels = new Array();
|
|
451
|
+
if (tg.Pixels != null && tg.Pixels.length > 2) {
|
|
452
|
+
tg2.Pixels.push(tg.Pixels[n - 3]);
|
|
453
|
+
tg2.Pixels.push(tg.Pixels[n - 2]);
|
|
454
|
+
tg2.Pixels.push(tg.Pixels[n - 1]);
|
|
455
|
+
tg2.Pixels.push(tg.Pixels[n - 3]);
|
|
456
|
+
|
|
457
|
+
shape.moveTo(tg2.Pixels[0]);
|
|
458
|
+
for (j = 1; j < tg2.Pixels.length; j++) {
|
|
459
|
+
|
|
460
|
+
shape.lineTo(tg2.Pixels[j]);
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
|
|
464
|
+
//shapes.push(shape);
|
|
465
|
+
}
|
|
466
|
+
break;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
default: {
|
|
470
|
+
return;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
}//end switch
|
|
474
|
+
if (shapes != null) {
|
|
475
|
+
|
|
476
|
+
shapes.splice(0, 0, shape);
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
} catch (exc) {
|
|
480
|
+
if (exc instanceof Error) {
|
|
481
|
+
ErrorLogger.LogException(clsClipQuad._className, "addAbatisFill",
|
|
482
|
+
new RendererException("Failed inside addAbatisFill", exc));
|
|
483
|
+
} else {
|
|
484
|
+
throw exc;
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
/**
|
|
490
|
+
* for lines with glyphs the fill must be handled (clipped) as a separate shape.
|
|
491
|
+
* this function needs to be called before the clipping is done to the line
|
|
492
|
+
* @param tg
|
|
493
|
+
* @param clipBounds
|
|
494
|
+
* @return
|
|
495
|
+
*/
|
|
496
|
+
static LinesWithFill(tg: TGLight,
|
|
497
|
+
clipBounds: Array<Point2D>): Array<Shape2> | null {
|
|
498
|
+
let shapes: Array<Shape2>;
|
|
499
|
+
try {
|
|
500
|
+
if (tg.get_FillColor() == null || tg.get_FillColor().getAlpha() <= 1 ||
|
|
501
|
+
tg.Pixels == null || tg.Pixels.length === 0) {
|
|
502
|
+
|
|
503
|
+
return shapes;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
|
|
507
|
+
switch (tg.get_LineType()) {
|
|
508
|
+
case TacticalLines.ABATIS:
|
|
509
|
+
case TacticalLines.SPT:
|
|
510
|
+
case TacticalLines.MAIN:
|
|
511
|
+
case TacticalLines.AAAAA:
|
|
512
|
+
case TacticalLines.AIRAOA:
|
|
513
|
+
case TacticalLines.CATK:
|
|
514
|
+
case TacticalLines.CATKBYFIRE:
|
|
515
|
+
case TacticalLines.CORDONSEARCH:
|
|
516
|
+
case TacticalLines.CORDONKNOCK:
|
|
517
|
+
case TacticalLines.SECURE:
|
|
518
|
+
case TacticalLines.OCCUPY:
|
|
519
|
+
case TacticalLines.RETAIN:
|
|
520
|
+
case TacticalLines.ISOLATE:
|
|
521
|
+
case TacticalLines.CONVOY:
|
|
522
|
+
case TacticalLines.HCONVOY: {
|
|
523
|
+
return shapes;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
case TacticalLines.PAA_RECTANGULAR:
|
|
527
|
+
case TacticalLines.RECTANGULAR_TARGET: {
|
|
528
|
+
return null;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
case TacticalLines.OBSFAREA:
|
|
532
|
+
case TacticalLines.OBSAREA:
|
|
533
|
+
case TacticalLines.STRONG:
|
|
534
|
+
case TacticalLines.ZONE:
|
|
535
|
+
case TacticalLines.FORT_REVD:
|
|
536
|
+
case TacticalLines.FORT:
|
|
537
|
+
case TacticalLines.ENCIRCLE:
|
|
538
|
+
case TacticalLines.ATDITCHC:
|
|
539
|
+
case TacticalLines.ATDITCHM: {
|
|
540
|
+
return clsClipQuad.fillDMA(tg, clipBounds);
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
default: {
|
|
544
|
+
break;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
}
|
|
548
|
+
if (clsUtility.LinesWithFill(tg.get_LineType()) === false) {
|
|
549
|
+
|
|
550
|
+
return shapes;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
|
|
554
|
+
shapes = new Array();
|
|
555
|
+
//undo any fillcolor that might have been set for the existing shape
|
|
556
|
+
//because we are divorcing fill from the line
|
|
557
|
+
let shape: Shape2;
|
|
558
|
+
|
|
559
|
+
//create a generic area tg from the pixels and clip it
|
|
560
|
+
let tg2: TGLight = new TGLight();
|
|
561
|
+
tg2.set_LineType(TacticalLines.GENERAL);
|
|
562
|
+
tg2.Pixels = new Array();
|
|
563
|
+
tg2.Pixels.push(...tg.Pixels);
|
|
564
|
+
clsClipQuad.closeAreaTG(tg2);
|
|
565
|
+
//tg2.Pixels.push(tg.Pixels[0]);
|
|
566
|
+
if (clipBounds != null) {
|
|
567
|
+
|
|
568
|
+
clsClipQuad.ClipPolygon(tg2, clipBounds);
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
|
|
572
|
+
|
|
573
|
+
if (tg2.Pixels == null || tg2.Pixels.length === 0) {
|
|
574
|
+
|
|
575
|
+
return null;
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
|
|
579
|
+
let j: int = 0;
|
|
580
|
+
shape = new Shape2(Shape2.SHAPE_TYPE_POLYLINE);
|
|
581
|
+
shape.setFillColor(tg.get_FillColor());
|
|
582
|
+
|
|
583
|
+
shape.moveTo(tg2.Pixels[0]);
|
|
584
|
+
for (j = 1; j < tg2.Pixels.length; j++) {
|
|
585
|
+
|
|
586
|
+
shape.lineTo(tg2.Pixels[j]);
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
|
|
590
|
+
if (tg.get_FillColor() != null || tg.get_FillColor().getAlpha() > 1) {
|
|
591
|
+
shapes.push(shape);
|
|
592
|
+
}
|
|
593
|
+
else {
|
|
594
|
+
|
|
595
|
+
return null;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
} catch (exc) {
|
|
599
|
+
if (exc instanceof Error) {
|
|
600
|
+
ErrorLogger.LogException(clsClipQuad._className, "LinesWithFill",
|
|
601
|
+
new RendererException("Failed inside LinesWithFill", exc));
|
|
602
|
+
} else {
|
|
603
|
+
throw exc;
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
return shapes;
|
|
607
|
+
}
|
|
608
|
+
/**
|
|
609
|
+
* closes an area
|
|
610
|
+
* @param tg
|
|
611
|
+
*/
|
|
612
|
+
private static closeAreaTG(tg: TGLight): void {
|
|
613
|
+
try {
|
|
614
|
+
if (tg.Pixels == null || tg.Pixels.length === 0) {
|
|
615
|
+
|
|
616
|
+
return;
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
|
|
620
|
+
let pt0: POINT2 = tg.Pixels[0];
|
|
621
|
+
let ptn: POINT2 = tg.Pixels[tg.Pixels.length - 1];
|
|
622
|
+
if (pt0.x !== ptn.x || pt0.y !== ptn.y) {
|
|
623
|
+
|
|
624
|
+
tg.Pixels.push(pt0);
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
|
|
628
|
+
} catch (exc) {
|
|
629
|
+
if (exc instanceof Error) {
|
|
630
|
+
ErrorLogger.LogException(clsClipQuad._className, "closeAreaTG",
|
|
631
|
+
new RendererException("Failed inside closeAreaTG", exc));
|
|
632
|
+
} else {
|
|
633
|
+
throw exc;
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
/**
|
|
638
|
+
* DMA, DMAF fill must be handled separately because of the feint
|
|
639
|
+
* @param tg
|
|
640
|
+
* @param clipBounds
|
|
641
|
+
* @return
|
|
642
|
+
*/
|
|
643
|
+
protected static fillDMA(tg: TGLight,
|
|
644
|
+
clipBounds: Array<Point2D>): Array<Shape2> {
|
|
645
|
+
let shapes: Array<Shape2> = new Array();
|
|
646
|
+
try {
|
|
647
|
+
switch (tg.get_LineType()) {
|
|
648
|
+
case TacticalLines.OBSFAREA:
|
|
649
|
+
case TacticalLines.OBSAREA:
|
|
650
|
+
case TacticalLines.STRONG:
|
|
651
|
+
case TacticalLines.ZONE:
|
|
652
|
+
case TacticalLines.FORT_REVD:
|
|
653
|
+
case TacticalLines.FORT:
|
|
654
|
+
case TacticalLines.ENCIRCLE:
|
|
655
|
+
case TacticalLines.ATDITCHC:
|
|
656
|
+
case TacticalLines.ATDITCHM: {
|
|
657
|
+
break;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
default: {
|
|
661
|
+
return shapes;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
}
|
|
665
|
+
let shape: Shape2;
|
|
666
|
+
|
|
667
|
+
//create a generic area tg from the pixels and clip it
|
|
668
|
+
let j: int = 0;
|
|
669
|
+
let tg2: TGLight = new TGLight();
|
|
670
|
+
tg2.set_LineType(TacticalLines.GENERAL);
|
|
671
|
+
tg2.Pixels = new Array();
|
|
672
|
+
//to get the original pixels size
|
|
673
|
+
let n: int = 0;
|
|
674
|
+
n = tg.Pixels.length;
|
|
675
|
+
|
|
676
|
+
for (j = 0; j < n; j++) {
|
|
677
|
+
|
|
678
|
+
tg2.Pixels.push(tg.Pixels[j]);
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
|
|
682
|
+
clsClipQuad.closeAreaTG(tg2);
|
|
683
|
+
|
|
684
|
+
if (clipBounds != null) {
|
|
685
|
+
|
|
686
|
+
clsClipQuad.ClipPolygon(tg2, clipBounds);
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
|
|
690
|
+
if (tg2.Pixels == null || tg2.Pixels.length === 0) {
|
|
691
|
+
|
|
692
|
+
return shapes;
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
|
|
696
|
+
shape = new Shape2(Shape2.SHAPE_TYPE_POLYLINE);
|
|
697
|
+
shape.setFillColor(tg.get_FillColor());
|
|
698
|
+
|
|
699
|
+
shape.moveTo(tg2.Pixels[0]);
|
|
700
|
+
//original pixels do not include feint
|
|
701
|
+
for (j = 1; j < tg2.Pixels.length; j++) {
|
|
702
|
+
|
|
703
|
+
shape.lineTo(tg2.Pixels[j]);
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
|
|
707
|
+
shapes.push(shape);
|
|
708
|
+
} catch (exc) {
|
|
709
|
+
if (exc instanceof Error) {
|
|
710
|
+
ErrorLogger.LogException(clsClipQuad._className, "fillDMA",
|
|
711
|
+
new RendererException("Failed inside fillDMA", exc));
|
|
712
|
+
} else {
|
|
713
|
+
throw exc;
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
return shapes;
|
|
717
|
+
}
|
|
718
|
+
// private static Boolean isClosed(ArrayList<POINT2>pts)
|
|
719
|
+
// {
|
|
720
|
+
// boolean closed=false;
|
|
721
|
+
// POINT2 pt0=pts[0];
|
|
722
|
+
// POINT2 ptLast=pts[pts.length-1];
|
|
723
|
+
// if(pt0.x==ptLast.x && pt0.y==ptLast.y)
|
|
724
|
+
// closed=true;
|
|
725
|
+
// return closed;
|
|
726
|
+
// }
|
|
727
|
+
/**
|
|
728
|
+
*
|
|
729
|
+
* @param tg
|
|
730
|
+
* @param clipBounds polygon representing clipping area
|
|
731
|
+
* @return
|
|
732
|
+
*/
|
|
733
|
+
static ClipPolygon(tg: TGLight,
|
|
734
|
+
clipBounds: Array<Point2D>): Array<Point2D> {
|
|
735
|
+
let poly: Array<Point2D> = new Array();
|
|
736
|
+
try {
|
|
737
|
+
//diagnostic
|
|
738
|
+
let isClosed: boolean = clsUtility.isClosedPolygon(tg.get_LineType());
|
|
739
|
+
//Boolean isClosed = isClosed(tg.Pixels);
|
|
740
|
+
//M. Deutch commented one line 12-27-12
|
|
741
|
+
//clipBounds=clsUtilityGE.expandPolygon(clipBounds, 20);
|
|
742
|
+
clipBounds = clsUtilityGE.expandPolygon(clipBounds, 20);
|
|
743
|
+
//int n=clipBounds.length;
|
|
744
|
+
let polygon: Array<Point2D> = clsUtilityCPOF.POINT2toPoint2D(tg.Pixels);
|
|
745
|
+
|
|
746
|
+
let j: int = 0;
|
|
747
|
+
let hashMap: Map<string, Point2D> = new Map<string, Point2D>();
|
|
748
|
+
//int hashCode=0;
|
|
749
|
+
for (j = 0; j < polygon.length; j++) {
|
|
750
|
+
|
|
751
|
+
hashMap.set(j.toString(), polygon[j]);
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
|
|
755
|
+
//close the clipbounds if necessary
|
|
756
|
+
let clipBoundsPtStart: Point2D = clipBounds[0];
|
|
757
|
+
let clipBoundsPtEnd: Point2D = clipBounds[clipBounds.length - 1];
|
|
758
|
+
if (clipBoundsPtStart.getX() !== clipBoundsPtEnd.getX() ||
|
|
759
|
+
clipBoundsPtStart.getY() !== clipBoundsPtEnd.getY()) {
|
|
760
|
+
|
|
761
|
+
clipBounds.push(clipBoundsPtStart);
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
|
|
765
|
+
let addedLinePoints: int = 0;
|
|
766
|
+
if (isClosed) {
|
|
767
|
+
|
|
768
|
+
polygon.splice(polygon.length - 1, 1);
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
else {
|
|
772
|
+
addedLinePoints = clsClipQuad.AddBoundaryPointsForLines(polygon, clipBounds);
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
//for(j=0;j<clipBounds.length-1;j++)
|
|
776
|
+
for (j = 0; j < clipBounds.length - 1; j++) {
|
|
777
|
+
if (j === 0) {
|
|
778
|
+
|
|
779
|
+
poly = clsClipQuad.clipSide(tg, polygon, j, clipBounds);
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
else {
|
|
783
|
+
|
|
784
|
+
poly = clsClipQuad.clipSide(tg, poly, j, clipBounds);
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
|
|
790
|
+
if (isClosed) {
|
|
791
|
+
if (poly.length > 0) {
|
|
792
|
+
poly.push(poly[0]);
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
else {
|
|
796
|
+
switch (addedLinePoints) {
|
|
797
|
+
case 0: { //no points were added, do nothing
|
|
798
|
+
break;
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
case 1: { //point was added to the front to make algorithm work, remove segment
|
|
802
|
+
if (poly.length > 0) {
|
|
803
|
+
poly.splice(0, 1);
|
|
804
|
+
}
|
|
805
|
+
if (poly.length > 0) {
|
|
806
|
+
poly.splice(0, 1);
|
|
807
|
+
}
|
|
808
|
+
break;
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
case 2: { //point was added to the end to make algorithm work, remove segment
|
|
812
|
+
if (poly.length > 0) {
|
|
813
|
+
poly.splice(poly.length - 1, 1);
|
|
814
|
+
}
|
|
815
|
+
if (poly.length > 0) {
|
|
816
|
+
poly.splice(poly.length - 1, 1);
|
|
817
|
+
}
|
|
818
|
+
break;
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
case 3: { //point was added to the front and end to make algorithm work, remove segments
|
|
822
|
+
if (poly.length > 0) {
|
|
823
|
+
poly.splice(0, 1);
|
|
824
|
+
}
|
|
825
|
+
if (poly.length > 0) {
|
|
826
|
+
poly.splice(0, 1);
|
|
827
|
+
}
|
|
828
|
+
if (poly.length > 0) {
|
|
829
|
+
poly.splice(poly.length - 1, 1);
|
|
830
|
+
}
|
|
831
|
+
if (poly.length > 0) {
|
|
832
|
+
poly.splice(poly.length - 1, 1);
|
|
833
|
+
}
|
|
834
|
+
break;
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
|
|
838
|
+
default:
|
|
839
|
+
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
if (isClosed === true) {
|
|
844
|
+
if (poly.length > 2) {
|
|
845
|
+
tg.Pixels = clsUtilityCPOF.Point2DtoPOINT2Mapped(poly, hashMap);
|
|
846
|
+
}
|
|
847
|
+
else {
|
|
848
|
+
tg.Pixels = new Array();
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
}
|
|
852
|
+
else {
|
|
853
|
+
if (poly.length > 1) {
|
|
854
|
+
tg.Pixels = clsUtilityCPOF.Point2DtoPOINT2Mapped(poly, hashMap);
|
|
855
|
+
}
|
|
856
|
+
else {
|
|
857
|
+
tg.Pixels = new Array();
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
} catch (exc) {
|
|
862
|
+
if (exc instanceof Error) {
|
|
863
|
+
ErrorLogger.LogException(clsClipQuad._className, "ClipPolygon",
|
|
864
|
+
new RendererException("Failed inside ClipPolygon", exc));
|
|
865
|
+
} else {
|
|
866
|
+
throw exc;
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
return poly;
|
|
870
|
+
}
|
|
871
|
+
}
|