@itwin/core-backend 3.0.0-dev.84 → 3.0.0-dev.88
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/CHANGELOG.md +1525 -1525
- package/README.md +11 -11
- package/lib/cjs/BisCoreSchema.js.map +1 -1
- package/lib/cjs/Category.js.map +1 -1
- package/lib/cjs/ChangeSummaryManager.d.ts +2 -2
- package/lib/cjs/ChangeSummaryManager.js +2 -2
- package/lib/cjs/ChangeSummaryManager.js.map +1 -1
- package/lib/cjs/ChangedElementsDb.d.ts +0 -2
- package/lib/cjs/ChangedElementsDb.d.ts.map +1 -1
- package/lib/cjs/ChangedElementsDb.js +0 -2
- package/lib/cjs/ChangedElementsDb.js.map +1 -1
- package/lib/cjs/ClassRegistry.js.map +1 -1
- package/lib/cjs/CloudStorageBackend.js.map +1 -1
- package/lib/cjs/CodeSpecs.js.map +1 -1
- package/lib/cjs/DisplayStyle.js.map +1 -1
- package/lib/cjs/ECDb.js.map +1 -1
- package/lib/cjs/ECSchemaXmlContext.js.map +1 -1
- package/lib/cjs/ECSqlStatement.js.map +1 -1
- package/lib/cjs/ElementAspect.js.map +1 -1
- package/lib/cjs/ElementGraphics.js.map +1 -1
- package/lib/cjs/Entity.js.map +1 -1
- package/lib/cjs/GeometrySummary.js +47 -47
- package/lib/cjs/GeometrySummary.js.map +1 -1
- package/lib/cjs/IModelJsFs.js.map +1 -1
- package/lib/cjs/LineStyle.js.map +1 -1
- package/lib/cjs/LocalhostIpcHost.js.map +1 -1
- package/lib/cjs/PromiseMemoizer.js.map +1 -1
- package/lib/cjs/Relationship.js.map +1 -1
- package/lib/cjs/RpcBackend.js.map +1 -1
- package/lib/cjs/Schema.js.map +1 -1
- package/lib/cjs/assets/IModelChange.02.00.00.ecschema.xml +90 -90
- package/lib/cjs/core-backend.js.map +1 -1
- package/lib/cjs/domains/FunctionalElements.js.map +1 -1
- package/lib/cjs/domains/FunctionalSchema.js.map +1 -1
- package/lib/cjs/domains/GenericElements.js.map +1 -1
- package/lib/cjs/domains/GenericSchema.js.map +1 -1
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
- package/package.json +22 -22
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GeometrySummary.js","sourceRoot":"","sources":["../../src/GeometrySummary.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,sDAAwF;AACxF,wDAK8B;AAC9B,oDAG4B;AAC5B,uCAAoE;AAQpE,uBAAuB;AAEvB,yDAAyD;AACzD,MAAM,iBAAiB;IAUrB,YAAmB,OAAoC,EAAE,MAAgB;QATlE,cAAS,GAAG,sCAAwB,CAAC,KAAK,CAAC;QAC3C,qBAAgB,GAAG,KAAK,CAAC;QAEzB,qBAAgB,GAAG,KAAK,CAAC;QAO9B,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QACrC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC;QAC7B,IAAI,SAAS,KAAK,IAAI,EAAE;YACtB,IAAI,CAAC,SAAS,GAAG,SAAS,KAAK,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,sCAAwB,CAAC,KAAK,CAAC;YAChH,IAAI,CAAC,gBAAgB,GAAG,IAAI,KAAK,IAAI,CAAC,gBAAgB,CAAC;YACvD,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC,qBAAqB,CAAC;YACxD,IAAI,CAAC,gBAAgB,GAAG,IAAI,KAAK,IAAI,CAAC,gBAAgB,CAAC;SACxD;IACH,CAAC;IAZD,IAAW,UAAU,KAAK,OAAO,sCAAwB,CAAC,IAAI,KAAK,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IAc7E,iBAAiB;QACtB,MAAM,SAAS,GAA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AO,GAAG,GAAG,OAAO,aAAa,IAAI,CAAC,OAAO,EAAE,CAAC;gBAChD,MAAM;YACR,KAAK,MAAM;gBACT,MAAM,IAAI,GAAS,MAAc,CAAC;gBAClC,OAAO,GAAG,GAAG,OAAO,YAAY,IAAI,CAAC,UAAU,EAAE,CAAC;gBAClD,MAAM;SACT;QAED,OAAO,GAAG,OAAO;mBACF,MAAM,CAAC,sBAAsB,EAAE,CAAC,MAAM;kBACvC,MAAM,CAAC,eAAe,EAAE,EAAE,CAAC;IAC3C,CAAC;CACF;AAED,gBAAgB;AAChB,SAAgB,yBAAyB,CAAC,OAAoC,EAAE,MAAgB;IAC9F,MAAM,SAAS,GAAG,IAAI,iBAAiB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACzD,OAAO,SAAS,CAAC,iBAAiB,EAAE,CAAC;AACvC,CAAC;AAHD,8DAGC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport { BentleyError, Id64Array, Id64String, IModelStatus } from \"@itwin/core-bentley\";\nimport {\n AkimaCurve3d, AnyGeometryQuery, Arc3d, BezierCurveBase, Box, BSplineCurve3d, Cone, CurveChainWithDistanceIndex, CurveCollection, CurvePrimitive, IModelJson,\n InterpolationCurve3d,\n LinearSweep, LineSegment3d, LineString3d, Loop, Path, Range3d, RotationalSweep, RuledSweep, SolidPrimitive, Sphere, TorusPipe, Transform,\n TransitionSpiral3d, UVSelect,\n} from \"@itwin/core-geometry\";\nimport {\n BRepEntity, GeometricElement3dProps, GeometryParams, GeometryStreamIterator, GeometrySummaryRequestProps, GeometrySummaryVerbosity, ImagePrimitive,\n IModelError, TextStringPrimitive,\n} from \"@itwin/core-common\";\nimport { Element, GeometricElement, GeometryPart } from \"./Element\";\nimport { IModelDb } from \"./IModelDb\";\n\ninterface ElementGeom {\n iterator: GeometryStreamIterator;\n geometricElement?: GeometricElement;\n}\n\n// cspell:ignore earlin\n\n/** Generates an array of GeometryStreamResponseProps. */\nclass ResponseGenerator {\n public verbosity = GeometrySummaryVerbosity.Basic;\n public includePlacement = false;\n public includePartReferences?: \"2d\" | \"3d\";\n public verboseSymbology = false;\n public elementIds: Id64Array;\n public iModel: IModelDb;\n\n public get wantSquish() { return GeometrySummaryVerbosity.Full !== this.verbosity; }\n\n public constructor(request: GeometrySummaryRequestProps, iModel: IModelDb) {\n this.elementIds = request.elementIds;\n this.iModel = iModel;\n const opts = request.options;\n if (undefined !== opts) {\n this.verbosity = undefined !== opts.geometryVerbosity ? opts.geometryVerbosity : GeometrySummaryVerbosity.Basic;\n this.includePlacement = true === opts.includePlacement;\n this.includePartReferences = opts.includePartReferences;\n this.verboseSymbology = true === opts.verboseSymbology;\n }\n }\n\n public generateSummaries(): string {\n const summaries: string[] = [];\n for (const elementId of this.elementIds)\n summaries.push(this.generateSummary(elementId));\n\n return summaries.join(\"\\n\");\n }\n\n public generateSummary(id: Id64String): string {\n let lines = [`[Geometry Summary for Element ${id}]`];\n try {\n const geom = this.getElementGeom(id);\n if (undefined === geom)\n throw new IModelError(IModelStatus.NoGeometry, \"Element is neither a geometric element nor a geometry part\");\n\n if (undefined !== geom.geometricElement)\n lines.push(this.summarizeElement(geom.geometricElement));\n else if (undefined !== this.includePartReferences)\n lines.push(this.summarizePartReferences(id, \"2d\" === this.includePartReferences)); // NB: Hideously inefficient if more than one element's summary was requested.\n\n let curGeomParams: GeometryParams | undefined;\n let curLocalRange: Range3d | undefined;\n for (const entry of geom.iterator) {\n if (this.verboseSymbology && (undefined === curGeomParams || !curGeomParams.isEquivalent(entry.geomParams))) {\n lines.push(`Symbology: ${this.stringify(entry.geomParams)}`);\n curGeomParams = entry.geomParams.clone();\n }\n\n if (undefined !== entry.localRange && (undefined === curLocalRange || !curLocalRange.isAlmostEqual(entry.localRange))) {\n lines.push(this.summarizeRange3d(entry.localRange));\n curLocalRange = entry.localRange;\n }\n\n const prim = entry.primitive;\n switch (prim.type) {\n case \"textString\":\n case \"image\":\n this.summarizePrimitive(lines, prim);\n break;\n case \"brep\":\n this.summarizeBRep(lines, prim.brep);\n break;\n case \"geometryQuery\":\n this.summarizeGeometryQuery(lines, prim.geometry);\n break;\n case \"partReference\":\n lines.push(this.summarizePartReference(prim.part.id, prim.part.toLocal));\n break;\n }\n }\n } catch (err) {\n lines = lines.slice(0, 1);\n lines.push(`ERROR: ${BentleyError.getErrorMessage(err)}`);\n }\n\n return lines.filter((line) => line !== \"\").join(\"\\n\");\n }\n\n public summarizeElement(elem: GeometricElement): string {\n const lines: string[] = [];\n lines.push(`(${elem.is2d() ? \"2D\" : \"3D\"}) Category: ${elem.category}`);\n lines.push(`Model: ${elem.model}`);\n if (this.includePlacement) {\n lines.push(`Range: ${this.stringify(elem.calculateRange3d())}`);\n lines.push(`Transform: ${this.stringify(elem.getPlacementTransform())}`);\n }\n\n return lines.join(\"\\n\");\n }\n\n public summarizePartReferences(id: Id64String, is2d: boolean): string {\n const refIds = this.iModel.nativeDb.findGeometryPartReferences([id], is2d);\n return `Part references (${refIds.length}): ${refIds.join()}`;\n }\n\n public getElementGeom(id: Id64String): ElementGeom | undefined {\n const elem = this.iModel.elements.getElement<Element>({ id, wantGeometry: true });\n let iterator: GeometryStreamIterator | undefined;\n let geometricElement: GeometricElement | undefined;\n if (elem instanceof GeometricElement) {\n geometricElement = elem;\n if (geometricElement.is2d())\n iterator = GeometryStreamIterator.fromGeometricElement2d(geometricElement);\n else\n iterator = GeometryStreamIterator.fromGeometricElement3d(geometricElement as GeometricElement3dProps);\n } else if (elem instanceof GeometryPart) {\n iterator = GeometryStreamIterator.fromGeometryPart(elem);\n }\n\n return undefined !== iterator ? { iterator, geometricElement } : undefined;\n }\n\n public summarizeRange3d(range: Range3d): string {\n return `SubGraphicRange: ${this.stringify(range)}`;\n }\n\n public summarizePrimitive(lines: string[], primitive: TextStringPrimitive | ImagePrimitive): void {\n const summary = primitive.type;\n if (GeometrySummaryVerbosity.Basic >= this.verbosity) {\n lines.push(summary);\n return;\n }\n\n const json = this.stringify(primitive.type === \"textString\" ? primitive.textString : primitive.image);\n if (GeometrySummaryVerbosity.Detailed >= this.verbosity) {\n lines.push(`${summary}: ${json}`);\n return;\n }\n\n lines.push(`${summary}:`);\n lines.push(json);\n }\n\n public summarizeBRep(lines: string[], brep: BRepEntity.DataProps): void {\n const summary = \"brep\";\n if (GeometrySummaryVerbosity.Basic >= this.verbosity) {\n lines.push(summary);\n return;\n }\n\n const json = this.stringify({ type: brep.type, transform: brep.transform, faceSymbology: brep.faceSymbology });\n if (GeometrySummaryVerbosity.Detailed >= this.verbosity) {\n lines.push(`${summary}: ${json}`);\n return;\n }\n\n lines.push(`${summary}:`);\n lines.push(json);\n }\n\n public summarizePartReference(partId: string, partToLocal?: Transform): string {\n let line = `part id: ${partId}`;\n if (undefined !== partToLocal)\n line = `${line} transform: ${this.stringify(partToLocal)}`;\n\n return line;\n }\n\n public summarizeGeometryQuery(lines: string[], query: AnyGeometryQuery): void {\n switch (this.verbosity) {\n case GeometrySummaryVerbosity.Detailed:\n lines.push(this.summarizeGeometryQueryDetailed(query));\n break;\n case GeometrySummaryVerbosity.Full:\n lines.push(this.summarizeGeometryQueryFull(query));\n break;\n default:\n lines.push(this.summarizeGeometryQueryBasic(query));\n break;\n }\n }\n\n public summarizeGeometryQueryBasic(query: AnyGeometryQuery): string {\n switch (query.geometryCategory) {\n case \"solid\":\n return query.solidPrimitiveType;\n case \"curvePrimitive\":\n return query.curvePrimitiveType;\n case \"curveCollection\":\n return query.curveCollectionType;\n default:\n return query.geometryCategory;\n }\n }\n\n public summarizeGeometryQueryFull(query: AnyGeometryQuery): string {\n return this.geometryQueryToJson(query);\n }\n\n public geometryQueryToJson(query: AnyGeometryQuery): string {\n try {\n const json = IModelJson.Writer.toIModelJson(query);\n const str = JSON.stringify(json);\n return this.wantSquish ? this.squish(str) : str;\n } catch (err) {\n return BentleyError.getErrorMessage(err);\n }\n }\n\n // Earlin likes to put tons of whitespace + newlines into his JSON. Remove it.\n public squish(str: string): string {\n return str.replace(/\\s+/g, \"\");\n }\n\n public stringify(obj: object): string {\n const json = JSON.stringify(obj);\n return this.wantSquish ? this.squish(json) : json;\n }\n\n public summarizeGeometryQueryDetailed(query: AnyGeometryQuery): string {\n let summary = `${this.summarizeGeometryQueryBasic(query)}: `;\n switch (query.geometryCategory) {\n case \"solid\":\n return summary + this.summarizeSolidPrimitive(query);\n case \"curvePrimitive\":\n return summary + this.summarizeCurvePrimitive(query);\n case \"curveCollection\":\n return summary + this.summarizeCurveCollection(query);\n case \"pointCollection\":\n return `${summary} numPoints: ${query.points.length}`;\n case \"bsurf\":\n return `${summary}'\n ' poleDimension: ${query.poleDimension}'\n ' numPolesTotal: ${query.numPolesTotal()}'\n ' degree[U,V]: ${JSON.stringify([query.degreeUV(UVSelect.uDirection), query.degreeUV(UVSelect.VDirection)])}'\n ' order[U,V]: ${JSON.stringify([query.orderUV(UVSelect.uDirection), query.orderUV(UVSelect.VDirection)])}'\n ' numSpan[U,V]: ${JSON.stringify([query.numSpanUV(UVSelect.uDirection), query.numSpanUV(UVSelect.VDirection)])}'\n ' numPoles[U,V]: ${JSON.stringify([query.numPolesUV(UVSelect.uDirection), query.numPolesUV(UVSelect.VDirection)])}'\n ' poleStep[U,V]: ${JSON.stringify([query.poleStepUV(UVSelect.uDirection), query.poleStepUV(UVSelect.VDirection)])}`;\n case \"polyface\": {\n const data = query.data;\n summary = `${summary} pointCount: ${data.point.length}'\n ' pointIndexCount: ${data.pointIndex.length}`;\n if (query.twoSided)\n summary = `${summary} (two-sided)`;\n if (undefined !== data.normal)\n summary = `${summary} normalCount: ${data.normal.length}`;\n if (undefined !== data.param)\n summary = `${summary} paramCount: ${data.param.length}`;\n if (undefined !== data.color)\n summary = `${summary} colorCount: ${data.color.length}`;\n\n return summary;\n }\n case \"point\":\n return summary + this.geometryQueryToJson(query);\n }\n }\n\n public summarizeSolidPrimitive(solid: SolidPrimitive): string {\n const summary: string = solid.capped ? \" capped\" : \" uncapped\";\n switch (solid.solidPrimitiveType) {\n case \"box\":\n const box: Box = (solid as Box);\n return `${summary}'\n ' baseOrigin: ${JSON.stringify(box.getBaseOrigin().toJSON())}'\n ' topOrigin: ${JSON.stringify(box.getTopOrigin().toJSON())}'\n ' baseX: ${box.getBaseX()}'\n ' baseY: ${box.getBaseY()}`;\n case \"cone\":\n const cone: Cone = solid as Cone;\n return `${summary}'\n ' baseCenterPoint: ${JSON.stringify(cone.getCenterA())}'\n ' topCenterPoint: ${JSON.stringify(cone.getCenterB())}'\n ' baseCenterRadius: ${JSON.stringify(cone.getRadiusA())}'\n ' topCenterRadius: ${JSON.stringify(cone.getRadiusB())}`;\n case \"sphere\":\n const sphere: Sphere = solid as Sphere;\n return `${summary}'\n ' centerPoint: ${JSON.stringify(sphere.cloneCenter().toJSON())}'\n ' radius: ${JSON.stringify(sphere.trueSphereRadius())}`;\n case \"linearSweep\":\n const linearSweep: LinearSweep = solid as LinearSweep;\n return `${summary}'\n ' vector: ${linearSweep.cloneSweepVector().toJSON()}'\n ' curves${this.summarizeCurveCollection(linearSweep.getCurvesRef())}`;\n case \"rotationalSweep\":\n const rotationalSweep: RotationalSweep = solid as RotationalSweep;\n const axis = rotationalSweep.cloneAxisRay();\n return `${summary}'\n ' center: ${axis.origin.toJSON()}'\n ' axis: ${JSON.stringify(axis.direction.toJSON())}'\n ' sweepAngle: ${rotationalSweep.getSweep().degrees}`;\n case \"ruledSweep\":\n const ruledSweep: RuledSweep = solid as RuledSweep;\n const summarizedCollection = ruledSweep.cloneContours().map((curveCollection) => this.summarizeCurveCollection(curveCollection));\n return `${summary}'\n ' isClosedVolume${ruledSweep.isClosedVolume}'\n ' contours: ${JSON.stringify(summarizedCollection)}`;\n case \"torusPipe\":\n const torusPipe: TorusPipe = solid as TorusPipe;\n const vectorX = torusPipe.cloneVectorX();\n const vectorY = torusPipe.cloneVectorY();\n const sweep = torusPipe.getSweepAngle();\n if (torusPipe.getIsReversed()) {\n vectorY.scaleInPlace(-1.0);\n sweep.setRadians(-sweep.radians);\n }\n return `${summary}'\n ' center: ${torusPipe.cloneCenter().toJSON()}'\n ' xyVectors: ${JSON.stringify([vectorX.toJSON(), vectorY.toJSON()])}'\n ' majorRadius: ${torusPipe.getMajorRadius()}'\n ' minorRadius: ${torusPipe.getMinorRadius()}'\n ' sweepAngle: ${sweep.degrees}`;\n }\n }\n\n public summarizeCurvePrimitive(curve: CurvePrimitive): string {\n let summary: string = \"\";\n const writer = new IModelJson.Writer();\n switch (curve.curvePrimitiveType) {\n case \"arc\":\n const arc: Arc3d = curve as Arc3d;\n summary = `${summary} center: ${JSON.stringify(arc.center.toJSON())}`;\n if (undefined !== arc.circularRadius)\n summary = `${summary} radius: ${arc.circularRadius()}`;\n summary = `${summary}'\n ' vectorX:${arc.vector0.toJSON()}'\n ' vectorY:${arc.vector90.toJSON()}'\n ' sweepStartEnd [${arc.sweep.startDegrees}, ${arc.sweep.endDegrees}]`\n + ` curveLength: ${curve.curveLength()}`;\n return summary;\n case \"lineSegment\":\n const lineSegment: LineSegment3d = curve as LineSegment3d;\n summary = `${summary} points: ${JSON.stringify(lineSegment.toJSON())}`;\n summary = `${summary} curveLength: ${curve.curveLength()}`;\n return summary;\n case \"lineString\":\n const lineString: LineString3d = curve as LineString3d;\n summary = `${summary} pointCount: ${lineString.numPoints()}'\n ' curveLength: ${curve.curveLength()}`;\n return summary;\n case \"bsplineCurve\":\n const bsplineCurve: BSplineCurve3d = curve as BSplineCurve3d;\n summary = `${summary}'\n ' curveOrder: ${bsplineCurve.order}'\n ' controlPointsCount: ${bsplineCurve.numPoles}'\n ' curveLength: ${curve.curveLength()}`;\n return summary;\n case \"interpolationCurve\":\n const interpolationCurve: InterpolationCurve3d = curve as InterpolationCurve3d;\n const interpolationProps = interpolationCurve.cloneProps();\n summary = `${summary}'\n ' curveOrder: ${interpolationProps.order}'\n ' controlPointsCount: ${interpolationProps.fitPoints.length}`;\n return summary;\n case \"akimaCurve\":\n const akimaCurve: AkimaCurve3d = curve as AkimaCurve3d;\n const akimaProps = akimaCurve.cloneProps();\n summary = `${summary}'\n ' controlPointsCount: ${akimaProps.fitPoints.length}`;\n return summary;\n case \"bezierCurve\":\n const bezierCurve: BezierCurveBase = curve as BezierCurveBase;\n summary = `${summary}'\n ' curveOrder: ${bezierCurve.order}'\n ' controlPointsCount: ${bezierCurve.numPoles}'\n ' curveLength: ${curve.curveLength()}`;\n return summary;\n case \"transitionSpiral\":\n const transitionSpiral: TransitionSpiral3d = curve as TransitionSpiral3d;\n const json = writer.handleTransitionSpiral(transitionSpiral);\n summary = summary + JSON.stringify(json);\n return summary;\n case \"curveChainWithDistanceIndex\":\n const curveChainWithDistanceIndex: CurveChainWithDistanceIndex = curve as CurveChainWithDistanceIndex;\n const path = curveChainWithDistanceIndex.path;\n summary = `${summary}'\n ' curveLength: ${curve.curveLength()}'\n ' isOpen: ${path.isOpenPath}`;\n return summary;\n }\n }\n\n public summarizeCurveCollection(curves: CurveCollection): string {\n let summary: string = \"\";\n switch (curves.curveCollectionType) {\n case \"loop\":\n const loop: Loop = curves as Loop;\n summary = `${summary} isInner: ${loop.isInner}`;\n break;\n case \"path\":\n const path: Path = curves as Path;\n summary = `${summary} isOpen: ${path.isOpenPath}`;\n break;\n }\n\n return `${summary}'\n ' numCurves: ${curves.collectCurvePrimitives().length}'\n ' boundary: ${curves.dgnBoundaryType()}`;\n }\n}\n\n/** @internal */\nexport function generateGeometrySummaries(request: GeometrySummaryRequestProps, iModel: IModelDb): string {\n const generator = new ResponseGenerator(request, iModel);\n return generator.generateSummaries();\n}\n"]}
|
|
1
|
+
{"version":3,"file":"GeometrySummary.js","sourceRoot":"","sources":["../../src/GeometrySummary.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,sDAAwF;AACxF,wDAK8B;AAC9B,oDAG4B;AAC5B,uCAAoE;AAQpE,uBAAuB;AAEvB,yDAAyD;AACzD,MAAM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IAC9F,MAAM,SAAS,GAAG,IAAI,iBAAiB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACzD,OAAO,SAAS,CAAC,iBAAiB,EAAE,CAAC;AACvC,CAAC;AAHD,8DAGC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport { BentleyError, Id64Array, Id64String, IModelStatus } from \"@itwin/core-bentley\";\r\nimport {\r\n AkimaCurve3d, AnyGeometryQuery, Arc3d, BezierCurveBase, Box, BSplineCurve3d, Cone, CurveChainWithDistanceIndex, CurveCollection, CurvePrimitive, IModelJson,\r\n InterpolationCurve3d,\r\n LinearSweep, LineSegment3d, LineString3d, Loop, Path, Range3d, RotationalSweep, RuledSweep, SolidPrimitive, Sphere, TorusPipe, Transform,\r\n TransitionSpiral3d, UVSelect,\r\n} from \"@itwin/core-geometry\";\r\nimport {\r\n BRepEntity, GeometricElement3dProps, GeometryParams, GeometryStreamIterator, GeometrySummaryRequestProps, GeometrySummaryVerbosity, ImagePrimitive,\r\n IModelError, TextStringPrimitive,\r\n} from \"@itwin/core-common\";\r\nimport { Element, GeometricElement, GeometryPart } from \"./Element\";\r\nimport { IModelDb } from \"./IModelDb\";\r\n\r\ninterface ElementGeom {\r\n iterator: GeometryStreamIterator;\r\n geometricElement?: GeometricElement;\r\n}\r\n\r\n// cspell:ignore earlin\r\n\r\n/** Generates an array of GeometryStreamResponseProps. */\r\nclass ResponseGenerator {\r\n public verbosity = GeometrySummaryVerbosity.Basic;\r\n public includePlacement = false;\r\n public includePartReferences?: \"2d\" | \"3d\";\r\n public verboseSymbology = false;\r\n public elementIds: Id64Array;\r\n public iModel: IModelDb;\r\n\r\n public get wantSquish() { return GeometrySummaryVerbosity.Full !== this.verbosity; }\r\n\r\n public constructor(request: GeometrySummaryRequestProps, iModel: IModelDb) {\r\n this.elementIds = request.elementIds;\r\n this.iModel = iModel;\r\n const opts = request.options;\r\n if (undefined !== opts) {\r\n this.verbosity = undefined !== opts.geometryVerbosity ? opts.geometryVerbosity : GeometrySummaryVerbosity.Basic;\r\n this.includePlacement = true === opts.includePlacement;\r\n this.includePartReferences = opts.includePartReferences;\r\n this.verboseSymbology = true === opts.verboseSymbology;\r\n }\r\n }\r\n\r\n public generateSummaries(): string {\r\n const summaries: string[] = [];\r\n for (const elementId of this.elementIds)\r\n summaries.push(this.generateSummary(elementId));\r\n\r\n return summaries.join(\"\\n\");\r\n }\r\n\r\n public generateSummary(id: Id64String): string {\r\n let lines = [`[Geometry Summary for Element ${id}]`];\r\n try {\r\n const geom = this.getElementGeom(id);\r\n if (undefined === geom)\r\n throw new IModelError(IModelStatus.NoGeometry, \"Element is neither a geometric element nor a geometry part\");\r\n\r\n if (undefined !== geom.geometricElement)\r\n lines.push(this.summarizeElement(geom.geometricElement));\r\n else if (undefined !== this.includePartReferences)\r\n lines.push(this.summarizePartReferences(id, \"2d\" === this.includePartReferences)); // NB: Hideously inefficient if more than one element's summary was requested.\r\n\r\n let curGeomParams: GeometryParams | undefined;\r\n let curLocalRange: Range3d | undefined;\r\n for (const entry of geom.iterator) {\r\n if (this.verboseSymbology && (undefined === curGeomParams || !curGeomParams.isEquivalent(entry.geomParams))) {\r\n lines.push(`Symbology: ${this.stringify(entry.geomParams)}`);\r\n curGeomParams = entry.geomParams.clone();\r\n }\r\n\r\n if (undefined !== entry.localRange && (undefined === curLocalRange || !curLocalRange.isAlmostEqual(entry.localRange))) {\r\n lines.push(this.summarizeRange3d(entry.localRange));\r\n curLocalRange = entry.localRange;\r\n }\r\n\r\n const prim = entry.primitive;\r\n switch (prim.type) {\r\n case \"textString\":\r\n case \"image\":\r\n this.summarizePrimitive(lines, prim);\r\n break;\r\n case \"brep\":\r\n this.summarizeBRep(lines, prim.brep);\r\n break;\r\n case \"geometryQuery\":\r\n this.summarizeGeometryQuery(lines, prim.geometry);\r\n break;\r\n case \"partReference\":\r\n lines.push(this.summarizePartReference(prim.part.id, prim.part.toLocal));\r\n break;\r\n }\r\n }\r\n } catch (err) {\r\n lines = lines.slice(0, 1);\r\n lines.push(`ERROR: ${BentleyError.getErrorMessage(err)}`);\r\n }\r\n\r\n return lines.filter((line) => line !== \"\").join(\"\\n\");\r\n }\r\n\r\n public summarizeElement(elem: GeometricElement): string {\r\n const lines: string[] = [];\r\n lines.push(`(${elem.is2d() ? \"2D\" : \"3D\"}) Category: ${elem.category}`);\r\n lines.push(`Model: ${elem.model}`);\r\n if (this.includePlacement) {\r\n lines.push(`Range: ${this.stringify(elem.calculateRange3d())}`);\r\n lines.push(`Transform: ${this.stringify(elem.getPlacementTransform())}`);\r\n }\r\n\r\n return lines.join(\"\\n\");\r\n }\r\n\r\n public summarizePartReferences(id: Id64String, is2d: boolean): string {\r\n const refIds = this.iModel.nativeDb.findGeometryPartReferences([id], is2d);\r\n return `Part references (${refIds.length}): ${refIds.join()}`;\r\n }\r\n\r\n public getElementGeom(id: Id64String): ElementGeom | undefined {\r\n const elem = this.iModel.elements.getElement<Element>({ id, wantGeometry: true });\r\n let iterator: GeometryStreamIterator | undefined;\r\n let geometricElement: GeometricElement | undefined;\r\n if (elem instanceof GeometricElement) {\r\n geometricElement = elem;\r\n if (geometricElement.is2d())\r\n iterator = GeometryStreamIterator.fromGeometricElement2d(geometricElement);\r\n else\r\n iterator = GeometryStreamIterator.fromGeometricElement3d(geometricElement as GeometricElement3dProps);\r\n } else if (elem instanceof GeometryPart) {\r\n iterator = GeometryStreamIterator.fromGeometryPart(elem);\r\n }\r\n\r\n return undefined !== iterator ? { iterator, geometricElement } : undefined;\r\n }\r\n\r\n public summarizeRange3d(range: Range3d): string {\r\n return `SubGraphicRange: ${this.stringify(range)}`;\r\n }\r\n\r\n public summarizePrimitive(lines: string[], primitive: TextStringPrimitive | ImagePrimitive): void {\r\n const summary = primitive.type;\r\n if (GeometrySummaryVerbosity.Basic >= this.verbosity) {\r\n lines.push(summary);\r\n return;\r\n }\r\n\r\n const json = this.stringify(primitive.type === \"textString\" ? primitive.textString : primitive.image);\r\n if (GeometrySummaryVerbosity.Detailed >= this.verbosity) {\r\n lines.push(`${summary}: ${json}`);\r\n return;\r\n }\r\n\r\n lines.push(`${summary}:`);\r\n lines.push(json);\r\n }\r\n\r\n public summarizeBRep(lines: string[], brep: BRepEntity.DataProps): void {\r\n const summary = \"brep\";\r\n if (GeometrySummaryVerbosity.Basic >= this.verbosity) {\r\n lines.push(summary);\r\n return;\r\n }\r\n\r\n const json = this.stringify({ type: brep.type, transform: brep.transform, faceSymbology: brep.faceSymbology });\r\n if (GeometrySummaryVerbosity.Detailed >= this.verbosity) {\r\n lines.push(`${summary}: ${json}`);\r\n return;\r\n }\r\n\r\n lines.push(`${summary}:`);\r\n lines.push(json);\r\n }\r\n\r\n public summarizePartReference(partId: string, partToLocal?: Transform): string {\r\n let line = `part id: ${partId}`;\r\n if (undefined !== partToLocal)\r\n line = `${line} transform: ${this.stringify(partToLocal)}`;\r\n\r\n return line;\r\n }\r\n\r\n public summarizeGeometryQuery(lines: string[], query: AnyGeometryQuery): void {\r\n switch (this.verbosity) {\r\n case GeometrySummaryVerbosity.Detailed:\r\n lines.push(this.summarizeGeometryQueryDetailed(query));\r\n break;\r\n case GeometrySummaryVerbosity.Full:\r\n lines.push(this.summarizeGeometryQueryFull(query));\r\n break;\r\n default:\r\n lines.push(this.summarizeGeometryQueryBasic(query));\r\n break;\r\n }\r\n }\r\n\r\n public summarizeGeometryQueryBasic(query: AnyGeometryQuery): string {\r\n switch (query.geometryCategory) {\r\n case \"solid\":\r\n return query.solidPrimitiveType;\r\n case \"curvePrimitive\":\r\n return query.curvePrimitiveType;\r\n case \"curveCollection\":\r\n return query.curveCollectionType;\r\n default:\r\n return query.geometryCategory;\r\n }\r\n }\r\n\r\n public summarizeGeometryQueryFull(query: AnyGeometryQuery): string {\r\n return this.geometryQueryToJson(query);\r\n }\r\n\r\n public geometryQueryToJson(query: AnyGeometryQuery): string {\r\n try {\r\n const json = IModelJson.Writer.toIModelJson(query);\r\n const str = JSON.stringify(json);\r\n return this.wantSquish ? this.squish(str) : str;\r\n } catch (err) {\r\n return BentleyError.getErrorMessage(err);\r\n }\r\n }\r\n\r\n // Earlin likes to put tons of whitespace + newlines into his JSON. Remove it.\r\n public squish(str: string): string {\r\n return str.replace(/\\s+/g, \"\");\r\n }\r\n\r\n public stringify(obj: object): string {\r\n const json = JSON.stringify(obj);\r\n return this.wantSquish ? this.squish(json) : json;\r\n }\r\n\r\n public summarizeGeometryQueryDetailed(query: AnyGeometryQuery): string {\r\n let summary = `${this.summarizeGeometryQueryBasic(query)}: `;\r\n switch (query.geometryCategory) {\r\n case \"solid\":\r\n return summary + this.summarizeSolidPrimitive(query);\r\n case \"curvePrimitive\":\r\n return summary + this.summarizeCurvePrimitive(query);\r\n case \"curveCollection\":\r\n return summary + this.summarizeCurveCollection(query);\r\n case \"pointCollection\":\r\n return `${summary} numPoints: ${query.points.length}`;\r\n case \"bsurf\":\r\n return `${summary}'\r\n ' poleDimension: ${query.poleDimension}'\r\n ' numPolesTotal: ${query.numPolesTotal()}'\r\n ' degree[U,V]: ${JSON.stringify([query.degreeUV(UVSelect.uDirection), query.degreeUV(UVSelect.VDirection)])}'\r\n ' order[U,V]: ${JSON.stringify([query.orderUV(UVSelect.uDirection), query.orderUV(UVSelect.VDirection)])}'\r\n ' numSpan[U,V]: ${JSON.stringify([query.numSpanUV(UVSelect.uDirection), query.numSpanUV(UVSelect.VDirection)])}'\r\n ' numPoles[U,V]: ${JSON.stringify([query.numPolesUV(UVSelect.uDirection), query.numPolesUV(UVSelect.VDirection)])}'\r\n ' poleStep[U,V]: ${JSON.stringify([query.poleStepUV(UVSelect.uDirection), query.poleStepUV(UVSelect.VDirection)])}`;\r\n case \"polyface\": {\r\n const data = query.data;\r\n summary = `${summary} pointCount: ${data.point.length}'\r\n ' pointIndexCount: ${data.pointIndex.length}`;\r\n if (query.twoSided)\r\n summary = `${summary} (two-sided)`;\r\n if (undefined !== data.normal)\r\n summary = `${summary} normalCount: ${data.normal.length}`;\r\n if (undefined !== data.param)\r\n summary = `${summary} paramCount: ${data.param.length}`;\r\n if (undefined !== data.color)\r\n summary = `${summary} colorCount: ${data.color.length}`;\r\n\r\n return summary;\r\n }\r\n case \"point\":\r\n return summary + this.geometryQueryToJson(query);\r\n }\r\n }\r\n\r\n public summarizeSolidPrimitive(solid: SolidPrimitive): string {\r\n const summary: string = solid.capped ? \" capped\" : \" uncapped\";\r\n switch (solid.solidPrimitiveType) {\r\n case \"box\":\r\n const box: Box = (solid as Box);\r\n return `${summary}'\r\n ' baseOrigin: ${JSON.stringify(box.getBaseOrigin().toJSON())}'\r\n ' topOrigin: ${JSON.stringify(box.getTopOrigin().toJSON())}'\r\n ' baseX: ${box.getBaseX()}'\r\n ' baseY: ${box.getBaseY()}`;\r\n case \"cone\":\r\n const cone: Cone = solid as Cone;\r\n return `${summary}'\r\n ' baseCenterPoint: ${JSON.stringify(cone.getCenterA())}'\r\n ' topCenterPoint: ${JSON.stringify(cone.getCenterB())}'\r\n ' baseCenterRadius: ${JSON.stringify(cone.getRadiusA())}'\r\n ' topCenterRadius: ${JSON.stringify(cone.getRadiusB())}`;\r\n case \"sphere\":\r\n const sphere: Sphere = solid as Sphere;\r\n return `${summary}'\r\n ' centerPoint: ${JSON.stringify(sphere.cloneCenter().toJSON())}'\r\n ' radius: ${JSON.stringify(sphere.trueSphereRadius())}`;\r\n case \"linearSweep\":\r\n const linearSweep: LinearSweep = solid as LinearSweep;\r\n return `${summary}'\r\n ' vector: ${linearSweep.cloneSweepVector().toJSON()}'\r\n ' curves${this.summarizeCurveCollection(linearSweep.getCurvesRef())}`;\r\n case \"rotationalSweep\":\r\n const rotationalSweep: RotationalSweep = solid as RotationalSweep;\r\n const axis = rotationalSweep.cloneAxisRay();\r\n return `${summary}'\r\n ' center: ${axis.origin.toJSON()}'\r\n ' axis: ${JSON.stringify(axis.direction.toJSON())}'\r\n ' sweepAngle: ${rotationalSweep.getSweep().degrees}`;\r\n case \"ruledSweep\":\r\n const ruledSweep: RuledSweep = solid as RuledSweep;\r\n const summarizedCollection = ruledSweep.cloneContours().map((curveCollection) => this.summarizeCurveCollection(curveCollection));\r\n return `${summary}'\r\n ' isClosedVolume${ruledSweep.isClosedVolume}'\r\n ' contours: ${JSON.stringify(summarizedCollection)}`;\r\n case \"torusPipe\":\r\n const torusPipe: TorusPipe = solid as TorusPipe;\r\n const vectorX = torusPipe.cloneVectorX();\r\n const vectorY = torusPipe.cloneVectorY();\r\n const sweep = torusPipe.getSweepAngle();\r\n if (torusPipe.getIsReversed()) {\r\n vectorY.scaleInPlace(-1.0);\r\n sweep.setRadians(-sweep.radians);\r\n }\r\n return `${summary}'\r\n ' center: ${torusPipe.cloneCenter().toJSON()}'\r\n ' xyVectors: ${JSON.stringify([vectorX.toJSON(), vectorY.toJSON()])}'\r\n ' majorRadius: ${torusPipe.getMajorRadius()}'\r\n ' minorRadius: ${torusPipe.getMinorRadius()}'\r\n ' sweepAngle: ${sweep.degrees}`;\r\n }\r\n }\r\n\r\n public summarizeCurvePrimitive(curve: CurvePrimitive): string {\r\n let summary: string = \"\";\r\n const writer = new IModelJson.Writer();\r\n switch (curve.curvePrimitiveType) {\r\n case \"arc\":\r\n const arc: Arc3d = curve as Arc3d;\r\n summary = `${summary} center: ${JSON.stringify(arc.center.toJSON())}`;\r\n if (undefined !== arc.circularRadius)\r\n summary = `${summary} radius: ${arc.circularRadius()}`;\r\n summary = `${summary}'\r\n ' vectorX:${arc.vector0.toJSON()}'\r\n ' vectorY:${arc.vector90.toJSON()}'\r\n ' sweepStartEnd [${arc.sweep.startDegrees}, ${arc.sweep.endDegrees}]`\r\n + ` curveLength: ${curve.curveLength()}`;\r\n return summary;\r\n case \"lineSegment\":\r\n const lineSegment: LineSegment3d = curve as LineSegment3d;\r\n summary = `${summary} points: ${JSON.stringify(lineSegment.toJSON())}`;\r\n summary = `${summary} curveLength: ${curve.curveLength()}`;\r\n return summary;\r\n case \"lineString\":\r\n const lineString: LineString3d = curve as LineString3d;\r\n summary = `${summary} pointCount: ${lineString.numPoints()}'\r\n ' curveLength: ${curve.curveLength()}`;\r\n return summary;\r\n case \"bsplineCurve\":\r\n const bsplineCurve: BSplineCurve3d = curve as BSplineCurve3d;\r\n summary = `${summary}'\r\n ' curveOrder: ${bsplineCurve.order}'\r\n ' controlPointsCount: ${bsplineCurve.numPoles}'\r\n ' curveLength: ${curve.curveLength()}`;\r\n return summary;\r\n case \"interpolationCurve\":\r\n const interpolationCurve: InterpolationCurve3d = curve as InterpolationCurve3d;\r\n const interpolationProps = interpolationCurve.cloneProps();\r\n summary = `${summary}'\r\n ' curveOrder: ${interpolationProps.order}'\r\n ' controlPointsCount: ${interpolationProps.fitPoints.length}`;\r\n return summary;\r\n case \"akimaCurve\":\r\n const akimaCurve: AkimaCurve3d = curve as AkimaCurve3d;\r\n const akimaProps = akimaCurve.cloneProps();\r\n summary = `${summary}'\r\n ' controlPointsCount: ${akimaProps.fitPoints.length}`;\r\n return summary;\r\n case \"bezierCurve\":\r\n const bezierCurve: BezierCurveBase = curve as BezierCurveBase;\r\n summary = `${summary}'\r\n ' curveOrder: ${bezierCurve.order}'\r\n ' controlPointsCount: ${bezierCurve.numPoles}'\r\n ' curveLength: ${curve.curveLength()}`;\r\n return summary;\r\n case \"transitionSpiral\":\r\n const transitionSpiral: TransitionSpiral3d = curve as TransitionSpiral3d;\r\n const json = writer.handleTransitionSpiral(transitionSpiral);\r\n summary = summary + JSON.stringify(json);\r\n return summary;\r\n case \"curveChainWithDistanceIndex\":\r\n const curveChainWithDistanceIndex: CurveChainWithDistanceIndex = curve as CurveChainWithDistanceIndex;\r\n const path = curveChainWithDistanceIndex.path;\r\n summary = `${summary}'\r\n ' curveLength: ${curve.curveLength()}'\r\n ' isOpen: ${path.isOpenPath}`;\r\n return summary;\r\n }\r\n }\r\n\r\n public summarizeCurveCollection(curves: CurveCollection): string {\r\n let summary: string = \"\";\r\n switch (curves.curveCollectionType) {\r\n case \"loop\":\r\n const loop: Loop = curves as Loop;\r\n summary = `${summary} isInner: ${loop.isInner}`;\r\n break;\r\n case \"path\":\r\n const path: Path = curves as Path;\r\n summary = `${summary} isOpen: ${path.isOpenPath}`;\r\n break;\r\n }\r\n\r\n return `${summary}'\r\n ' numCurves: ${curves.collectCurvePrimitives().length}'\r\n ' boundary: ${curves.dgnBoundaryType()}`;\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport function generateGeometrySummaries(request: GeometrySummaryRequestProps, iModel: IModelDb): string {\r\n const generator = new ResponseGenerator(request, iModel);\r\n return generator.generateSummaries();\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelJsFs.js","sourceRoot":"","sources":["../../src/IModelJsFs.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,uBAAuB;AAEvB,+BAA+B;AAC/B,6BAA6B;AAE7B,uDAAuD;AACvD;;GAEG;AACH,MAAa,eAAe;IAC1B,YACS,IAAY,EACZ,OAAe,EACf,OAAe,EACf,WAAmB,EACnB,WAAoB,EACpB,MAAe,EACf,QAAiB,EACjB,cAAuB,EACvB,UAAmB;QARnB,SAAI,GAAJ,IAAI,CAAQ;QACZ,YAAO,GAAP,OAAO,CAAQ;QACf,YAAO,GAAP,OAAO,CAAQ;QACf,gBAAW,GAAX,WAAW,CAAQ;QACnB,gBAAW,GAAX,WAAW,CAAS;QACpB,WAAM,GAAN,MAAM,CAAS;QACf,aAAQ,GAAR,QAAQ,CAAS;QACjB,mBAAc,GAAd,cAAc,CAAS;QACvB,eAAU,GAAV,UAAU,CAAS;IACxB,CAAC;CACN;AAZD,0CAYC;AAED;;GAEG;AACH,MAAa,UAAU;IAErB,oCAAoC;IAC7B,MAAM,CAAC,UAAU,CAAC,QAAgB,IAAa,OAAO,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAEv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KAAK,EAAE;gBACT,UAAU,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;gBAClC,UAAU,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;aACjC;iBAAM;gBACL,UAAU,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;aACjC;YACD,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAhID,gCAgIC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\n/** @packageDocumentation\n * @module Portability\n */\n\n// cspell: ignore wflag\n\nimport * as fs from \"fs-extra\";\nimport * as path from \"path\";\n\n/* TODO: define File Mode Constants: S_IWUSR, et al. */\n/** Information about a file. See [[IModelJsFs.lstatSync]]\n * @public\n */\nexport class IModelJsFsStats {\n constructor(\n public size: number,\n public atimeMs: number,\n public mtimeMs: number,\n public birthtimeMs: number,\n public isDirectory: boolean,\n public isFile: boolean,\n public isSocket: boolean,\n public isSymbolicLink: boolean,\n public isReadOnly: boolean,\n ) { }\n}\n\n/** File system operations that are defined on all platforms. See also [[Platform]] and [[KnownLocations]]\n * @public\n */\nexport class IModelJsFs {\n\n /** Does file or directory exist? */\n public static existsSync(pathname: string): boolean { return fs.existsSync(pathname); }\n\n /** Delete a file. */\n public static unlinkSync(pathname: string): void { fs.unlinkSync(pathname); }\n\n /** Delete a file or remove a directory (rm -r). */\n public static removeSync(pathname: string): void { fs.removeSync(pathname); }\n\n /** Create a directory. */\n public static mkdirSync(pathname: string): void { fs.mkdirSync(pathname); }\n\n /** Remove a directory. */\n public static rmdirSync(pathname: string): void { fs.rmdirSync(pathname); }\n\n /** Write to a file. */\n public static writeFileSync(pathname: string, data: string | Uint8Array, wflag: string = \"w\"): void { fs.writeFileSync(pathname, data, { flag: wflag }); }\n\n /** Append to a file. */\n public static appendFileSync(pathname: string, str: string): void { fs.appendFileSync(pathname, str); }\n\n /** Make a copy of a file */\n public static copySync(src: string, dest: string, opts?: any): void { fs.copySync(src, dest, opts); }\n\n /** Get the file and directory names in the specified directory. Excludes \".\" and \"..\". */\n public static readdirSync(pathname: string): string[] { return fs.readdirSync(pathname); }\n\n /** Read file */\n public static readFileSync(pathname: string): string | Buffer { return fs.readFileSync(pathname); }\n\n /** Test if the current user has permission to write to a file. */\n private static isFileWritable(pathname: string): boolean {\n try {\n fs.accessSync(pathname, fs.constants.W_OK);\n return true;\n } catch (_err) {\n return false;\n }\n }\n\n /** Get information about a file. */\n public static lstatSync(pathname: string): IModelJsFsStats | undefined {\n const stats = fs.lstatSync(pathname);\n if (stats === undefined)\n return undefined;\n\n return new IModelJsFsStats(\n stats.size,\n stats.atime.getTime(),\n stats.mtime.getTime(),\n stats.birthtime.getTime(),\n stats.isDirectory(),\n stats.isFile(),\n stats.isSocket(),\n stats.isSymbolicLink(),\n !IModelJsFs.isFileWritable(pathname));\n }\n\n /**\n * Finds files recursively based on a pattern\n * @param rootDir Directory from where to start searching for files.\n * @param pattern A Regex that would be match to basename of files including extension\n * @returns list of file that match the pattern.\n */\n public static recursiveFindSync(rootDir: string, pattern: RegExp): string[] {\n const files: string[] = [];\n IModelJsFs.walkDirSync(rootDir, (pathname: string, isDir: boolean) => {\n if (!isDir) {\n const fileName = path.basename(pathname);\n if (pattern.test(fileName)) {\n files.push(pathname);\n }\n }\n return true;\n });\n return files;\n }\n\n /**\n * Walks a directory in breadth first fashion\n * @param rootDir directory from where the traversal starts\n * @param cb callback that would be called with full path of file or directory\n */\n public static walkDirSync(rootDir: string, cb: (pathname: string, isDir: boolean) => boolean): void {\n const subDir = [];\n for (const childPath of IModelJsFs.readdirSync(rootDir)) {\n const fullPath = path.join(rootDir, childPath);\n const isDir = IModelJsFs.lstatSync(fullPath)?.isDirectory;\n if (!cb(fullPath, isDir!)) {\n return;\n }\n // Need to check if the directory still exists in case the callback has deleted it.\n if (isDir && IModelJsFs.existsSync(fullPath)) {\n subDir.push(fullPath);\n }\n }\n subDir.forEach((v) => {\n IModelJsFs.walkDirSync(v, cb);\n });\n }\n\n /** Create a directory, recursively setting up the path as necessary */\n public static recursiveMkDirSync(dirPath: string) {\n if (IModelJsFs.existsSync(dirPath))\n return;\n const parentPath = path.dirname(dirPath);\n if (parentPath !== dirPath)\n IModelJsFs.recursiveMkDirSync(parentPath);\n IModelJsFs.mkdirSync(dirPath);\n }\n\n /** Remove a directory, recursively */\n public static purgeDirSync(dirPath: string) {\n if (!IModelJsFs.existsSync(dirPath))\n return;\n\n IModelJsFs.walkDirSync(dirPath, (pathName: string, isDir: boolean) => {\n if (isDir) {\n IModelJsFs.purgeDirSync(pathName);\n IModelJsFs.removeSync(pathName);\n } else {\n IModelJsFs.unlinkSync(pathName);\n }\n return true;\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"IModelJsFs.js","sourceRoot":"","sources":["../../src/IModelJsFs.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,uBAAuB;AAEvB,+BAA+B;AAC/B,6BAA6B;AAE7B,uDAAuD;AACvD;;GAEG;AACH,MAAa,eAAe;IAC1B,YACS,IAAY,EACZ,OAAe,EACf,OAAe,EACf,WAAmB,EACnB,WAAoB,EACpB,MAAe,EACf,QAAiB,EACjB,cAAuB,EACvB,UAAmB;QARnB,SAAI,GAAJ,IAAI,CAAQ;QACZ,YAAO,GAAP,OAAO,CAAQ;QACf,YAAO,GAAP,OAAO,CAAQ;QACf,gBAAW,GAAX,WAAW,CAAQ;QACnB,gBAAW,GAAX,WAAW,CAAS;QACpB,WAAM,GAAN,MAAM,CAAS;QACf,aAAQ,GAAR,QAAQ,CAAS;QACjB,mBAAc,GAAd,cAAc,CAAS;QACvB,eAAU,GAAV,UAAU,CAAS;IACxB,CAAC;CACN;AAZD,0CAYC;AAED;;GAEG;AACH,MAAa,UAAU;IAErB,oCAAoC;IAC7B,MAAM,CAAC,UAAU,CAAC,QAA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C,WAAW,CAAC,OAAO,EAAE,CAAC,QAAgB,EAAE,KAAc,EAAE,EAAE;YACnE,IAAI,KAAK,EAAE;gBACT,UAAU,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;gBAClC,UAAU,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;aACjC;iBAAM;gBACL,UAAU,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;aACjC;YACD,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAhID,gCAgIC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module Portability\r\n */\r\n\r\n// cspell: ignore wflag\r\n\r\nimport * as fs from \"fs-extra\";\r\nimport * as path from \"path\";\r\n\r\n/* TODO: define File Mode Constants: S_IWUSR, et al. */\r\n/** Information about a file. See [[IModelJsFs.lstatSync]]\r\n * @public\r\n */\r\nexport class IModelJsFsStats {\r\n constructor(\r\n public size: number,\r\n public atimeMs: number,\r\n public mtimeMs: number,\r\n public birthtimeMs: number,\r\n public isDirectory: boolean,\r\n public isFile: boolean,\r\n public isSocket: boolean,\r\n public isSymbolicLink: boolean,\r\n public isReadOnly: boolean,\r\n ) { }\r\n}\r\n\r\n/** File system operations that are defined on all platforms. See also [[Platform]] and [[KnownLocations]]\r\n * @public\r\n */\r\nexport class IModelJsFs {\r\n\r\n /** Does file or directory exist? */\r\n public static existsSync(pathname: string): boolean { return fs.existsSync(pathname); }\r\n\r\n /** Delete a file. */\r\n public static unlinkSync(pathname: string): void { fs.unlinkSync(pathname); }\r\n\r\n /** Delete a file or remove a directory (rm -r). */\r\n public static removeSync(pathname: string): void { fs.removeSync(pathname); }\r\n\r\n /** Create a directory. */\r\n public static mkdirSync(pathname: string): void { fs.mkdirSync(pathname); }\r\n\r\n /** Remove a directory. */\r\n public static rmdirSync(pathname: string): void { fs.rmdirSync(pathname); }\r\n\r\n /** Write to a file. */\r\n public static writeFileSync(pathname: string, data: string | Uint8Array, wflag: string = \"w\"): void { fs.writeFileSync(pathname, data, { flag: wflag }); }\r\n\r\n /** Append to a file. */\r\n public static appendFileSync(pathname: string, str: string): void { fs.appendFileSync(pathname, str); }\r\n\r\n /** Make a copy of a file */\r\n public static copySync(src: string, dest: string, opts?: any): void { fs.copySync(src, dest, opts); }\r\n\r\n /** Get the file and directory names in the specified directory. Excludes \".\" and \"..\". */\r\n public static readdirSync(pathname: string): string[] { return fs.readdirSync(pathname); }\r\n\r\n /** Read file */\r\n public static readFileSync(pathname: string): string | Buffer { return fs.readFileSync(pathname); }\r\n\r\n /** Test if the current user has permission to write to a file. */\r\n private static isFileWritable(pathname: string): boolean {\r\n try {\r\n fs.accessSync(pathname, fs.constants.W_OK);\r\n return true;\r\n } catch (_err) {\r\n return false;\r\n }\r\n }\r\n\r\n /** Get information about a file. */\r\n public static lstatSync(pathname: string): IModelJsFsStats | undefined {\r\n const stats = fs.lstatSync(pathname);\r\n if (stats === undefined)\r\n return undefined;\r\n\r\n return new IModelJsFsStats(\r\n stats.size,\r\n stats.atime.getTime(),\r\n stats.mtime.getTime(),\r\n stats.birthtime.getTime(),\r\n stats.isDirectory(),\r\n stats.isFile(),\r\n stats.isSocket(),\r\n stats.isSymbolicLink(),\r\n !IModelJsFs.isFileWritable(pathname));\r\n }\r\n\r\n /**\r\n * Finds files recursively based on a pattern\r\n * @param rootDir Directory from where to start searching for files.\r\n * @param pattern A Regex that would be match to basename of files including extension\r\n * @returns list of file that match the pattern.\r\n */\r\n public static recursiveFindSync(rootDir: string, pattern: RegExp): string[] {\r\n const files: string[] = [];\r\n IModelJsFs.walkDirSync(rootDir, (pathname: string, isDir: boolean) => {\r\n if (!isDir) {\r\n const fileName = path.basename(pathname);\r\n if (pattern.test(fileName)) {\r\n files.push(pathname);\r\n }\r\n }\r\n return true;\r\n });\r\n return files;\r\n }\r\n\r\n /**\r\n * Walks a directory in breadth first fashion\r\n * @param rootDir directory from where the traversal starts\r\n * @param cb callback that would be called with full path of file or directory\r\n */\r\n public static walkDirSync(rootDir: string, cb: (pathname: string, isDir: boolean) => boolean): void {\r\n const subDir = [];\r\n for (const childPath of IModelJsFs.readdirSync(rootDir)) {\r\n const fullPath = path.join(rootDir, childPath);\r\n const isDir = IModelJsFs.lstatSync(fullPath)?.isDirectory;\r\n if (!cb(fullPath, isDir!)) {\r\n return;\r\n }\r\n // Need to check if the directory still exists in case the callback has deleted it.\r\n if (isDir && IModelJsFs.existsSync(fullPath)) {\r\n subDir.push(fullPath);\r\n }\r\n }\r\n subDir.forEach((v) => {\r\n IModelJsFs.walkDirSync(v, cb);\r\n });\r\n }\r\n\r\n /** Create a directory, recursively setting up the path as necessary */\r\n public static recursiveMkDirSync(dirPath: string) {\r\n if (IModelJsFs.existsSync(dirPath))\r\n return;\r\n const parentPath = path.dirname(dirPath);\r\n if (parentPath !== dirPath)\r\n IModelJsFs.recursiveMkDirSync(parentPath);\r\n IModelJsFs.mkdirSync(dirPath);\r\n }\r\n\r\n /** Remove a directory, recursively */\r\n public static purgeDirSync(dirPath: string) {\r\n if (!IModelJsFs.existsSync(dirPath))\r\n return;\r\n\r\n IModelJsFs.walkDirSync(dirPath, (pathName: string, isDir: boolean) => {\r\n if (isDir) {\r\n IModelJsFs.purgeDirSync(pathName);\r\n IModelJsFs.removeSync(pathName);\r\n } else {\r\n IModelJsFs.unlinkSync(pathName);\r\n }\r\n return true;\r\n });\r\n }\r\n}\r\n"]}
|
package/lib/cjs/LineStyle.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LineStyle.js","sourceRoot":"","sources":["../../src/LineStyle.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA+D;AAC/D,oDAAgG;AAChG,uCAAoD;AAGpD;;;;;;;;;GASG;AACH,IAAiB,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K,wBAAU,CAAC,KAAK;oBACnB,QAAQ,GAAG,CAAC,CAAC;oBACb,MAAM;gBACR;oBACE,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;aACpE;YACD,MAAM,IAAI,GAAG,wBAAwB,QAAQ,EAAE,CAAC;YAChD,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC;YACzD,OAAO,CAAC,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAC5I,CAAC;KACF;IArJY,yBAAK,QAqJjB,CAAA;AACH,CAAC,EA7agB,mBAAmB,GAAnB,2BAAmB,KAAnB,2BAAmB,QA6anC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Symbology\n */\n\nimport { Id64String, IModelStatus } from \"@itwin/core-bentley\";\nimport { FilePropertyProps, IModelError, LinePixels, LineStyleProps } from \"@itwin/core-common\";\nimport { GeometryPart, LineStyle } from \"./Element\";\nimport { IModelDb } from \"./IModelDb\";\n\n/** A line style definition is a uniquely named pattern that repeats as it is displayed along a curve path. In the absence of a line style, curve display is limited to solid lines with a width in pixels.\n * There are three varieties of line styles:\n * - A style described by a stroke pattern (series of dashes and gaps) that may also include symbol graphics.\n * - A style using pre-defined pixel bit patterns [[LinePixels]] for dashed display (Code1-Code7).\n * - A style that uses a texture.\n *\n * A definition is defined by one or more components. A component is saved as a \"file property\" and can be referenced by other components. The line style definition references a component\n * by file property id and type and is saved as a dictionary element.\n * @public\n */\nexport namespace LineStyleDefinition {\n\n /** Line style component type identifiers */\n export enum ComponentType {\n /** Component type for [[LineStyleDefinition.PointSymbolProps]] */\n PointSymbol = 1,\n /** Component type for [[LineStyleDefinition.CompoundProps]] */\n Compound = 2,\n /** Component type for [[LineStyleDefinition.StrokePatternProps]] */\n StrokePattern = 3,\n /** Component type for [[LineStyleDefinition.StrokePointProps]] */\n StrokePoint = 4,\n /** Component type for [[LinePixels]], never saved as a file property */\n Internal = 6,\n /** Component type for [[LineStyleDefinition.RasterImageProps]] */\n RasterImage = 7,\n }\n\n /** Mask of values for StrokeMode */\n export enum StrokeMode {\n /** Stroke represents a blank space */\n Gap = 0x00,\n /** Stroke represents a solid dash */\n Dash = 0x01,\n /** Treat stroke as rigid and continue past a corner to complete the stroke as opposed to breaking at the corner */\n Ray = 0x02,\n /** Stroke length can be stretched when [[LineStyleDefinition.StrokePatternOptions.Iteration]] and [[LineStyleDefinition.StrokePatternOptions.AutoPhase]] options are set, applicable to both Gap and Dash strokes */\n Scale = 0x04,\n /** Invert stroke in first stroke pattern */\n FirstInvert = 0x08,\n /** Invert stroke in last stroke pattern */\n LastInvert = 0x10,\n }\n\n /** Define constant width or tapered strokes with distance specified in meters */\n export enum StrokeWidth {\n /** Stroke draws as one pixel wide line */\n None = 0,\n /** Half [[LineStyleDefinition.StrokeProps.orgWidth]] and [[LineStyleDefinition.StrokeProps.endWidth]] applied to left side of stroke */\n Left = 1,\n /** Half [[LineStyleDefinition.StrokeProps.orgWidth]] and [[LineStyleDefinition.StrokeProps.endWidth]] applied to right side of stroke */\n Right = 2,\n /** Half [[LineStyleDefinition.StrokeProps.orgWidth]] and [[LineStyleDefinition.StrokeProps.endWidth]] applied to both sides of stroke */\n Full = 3,\n }\n\n /** Controls appearance of stroke end caps. If StrokeCap is >= Hexagon, the end cap is stroked as an arc and the value of\n * StrokeCap indicates the number of vectors in the arc.\n */\n export enum StrokeCap {\n /** Stroke displays as a closed polygon */\n Closed = 0,\n /** Stroke displays lines at specified width instead of a polygon */\n Open = 1,\n /** Stroke length extended by half the stroke width */\n Extended = 2,\n /** Stroke end cap is a hexagon */\n Hexagon = 3,\n /** Stroke end cap is an octagon */\n Octagon = 4,\n /** Stroke end cap is a decagon */\n Decagon = 5,\n /** Stroke end cap is an arc */\n Arc = 30,\n }\n\n /** A stroke representing either a dash or gap in a stroke pattern */\n export interface StrokeProps {\n /** Length of stroke in meters */\n length: number;\n /** Width at start of stroke. Behavior controlled by [[LineStyleDefinition.StrokeWidth]], choose value other than [[LineStyleDefinition.StrokeWidth.None]] */\n orgWidth?: number;\n /** Width at end of stroke, same as start width if not present. Behavior controlled by [[LineStyleDefinition.StrokeWidth]], choose value other than [[LineStyleDefinition.StrokeWidth.None]] */\n endWidth?: number;\n /** Type and behavior of stroke */\n strokeMode?: StrokeMode;\n /** How to apply orgWidth and endWidth to stroke */\n widthMode?: StrokeWidth;\n /** Appearance of stroke end cap */\n capMode?: StrokeCap;\n }\n\n export type Strokes = StrokeProps[];\n\n /** Options to control how stroke pattern is applied to underlying curve */\n export enum StrokePatternOptions {\n /** Use default stroke behavior */\n None = 0x00,\n /** [[LineStyleDefinition.StrokePatternProps.phase]] represents fractional distance into first stroke of pattern */\n AutoPhase = 0x01,\n /** Use [[LineStyleDefinition.StrokePatternProps.maxIter]] to limit the number of iterations of the stroke pattern */\n Iteration = 0x08,\n /** Single segment mode restarts the stroke pattern at corners instead of continuing around corners */\n Segment = 0x10,\n /** Center the line style and stretch the ends */\n CenterStretch = 0x20,\n }\n\n /** Stroke pattern component definition [[LineStyleDefinition.ComponentType.StrokePattern]].\n * A stroke pattern component consists of a series of dashes and gaps having specified lengths and widths in meters. Simple dash-dot type line styles that do not\n * include point symbols can be created by referencing a stroke pattern component by its file property id.\n */\n export interface StrokePatternProps {\n /** Name for this stroke pattern */\n descr: string;\n /** Skip into the pattern before starting to draw. Value treated as fraction of the first stroke when [[LineStyleDefinition.StrokePatternOptions.AutoPhase]] set. Value used as distance when [[LineStyleDefinition.StrokePatternOptions.CenterStretch]] is not set. */\n phase?: number;\n /** Options mask for this stroke pattern */\n options?: StrokePatternOptions;\n /** The entire stroke pattern will be repeated no more than maxIter on curve or segment when [[LineStyleDefinition.StrokePatternOptions.Iteration]] is set and stroke pattern includes stretchable strokes. */\n maxIter?: number;\n /** Array of strokes, maximum number that will be used is 32 */\n strokes: Strokes;\n }\n\n /** Flags to identify point symbol behavior */\n export enum PointSymbolFlags {\n /** Default symbol behavior */\n None = 0x0,\n /** Symbol includes 3d geometry */\n Is3d = 0x01,\n /** Symbol does not allow scaling */\n NoScale = 0x02,\n }\n\n /** Point symbol component definition [[LineStyleDefinition.ComponentType.PointSymbol]].\n * A point symbol component identifies a GeometryPart for reference by a [[LineStyleDefinition.SymbolProps]].\n */\n export interface PointSymbolProps {\n /** GeometryPart Id to use as a pattern symbol */\n geomPartId: Id64String;\n /** GeometryPart.bbox.low.x */\n baseX?: number;\n /** GeometryPart.bbox.low.y */\n baseY?: number;\n /** GeometryPart.bbox.low.z */\n baseZ?: number;\n /** GeometryPart.bbox.high.x */\n sizeX?: number;\n /** GeometryPart.bbox.high.y */\n sizeY?: number;\n /** GeometryPart.bbox.high.z */\n sizeZ?: number;\n /** Symbol behavior flags */\n symFlags?: PointSymbolFlags;\n /** Symbol scale, defaults to 1 */\n scale?: number;\n }\n\n /** Symbol options for location, orientation, and behavior */\n export enum SymbolOptions {\n /** No point symbol */\n None = 0x00,\n /** Symbol at origin of stroke */\n Origin = 0x01,\n /** Symbol at end of stroke */\n End = 0x02,\n /** symbol at center of stroke */\n Center = 0x03,\n /** Symbol at curve start point */\n CurveOrigin = 0x0004,\n /** Symbol at curve end point */\n CurveEnd = 0x0008,\n /** Symbol at each vertex */\n CurveVertex = 0x0010,\n /** Adjust symbol rotation left->right */\n AdjustRotation = 0x0020,\n /** Angle of symbol not relative to stroke direction */\n AbsoluteRotation = 0x0040,\n /** No scale on variable strokes */\n NoScale = 0x0100,\n /** No clip on partial strokes */\n NoClip = 0x0200,\n /** No partial strokes */\n NoPartial = 0x0400,\n /** Project partial origin */\n ProjectOrigin = 0x0800,\n /** Use color from symbol instead of inheriting curve color */\n UseColor = 0x4000,\n /** Use weight from symbol instead of inheriting curve weight */\n UseWeight = 0x8000,\n }\n\n /** Identifies a symbol and its location and orientation relative to a stroke pattern */\n export interface SymbolProps {\n /** The file property id of the symbol component, assumed to be [[LineStyleDefinition.ComponentType.PointSymbol]] if symType is undefined. */\n symId: number;\n /** The component type, leave undefined if symId is a [[LineStyleDefinition.ComponentType.PointSymbol]] */\n symType?: ComponentType;\n /** The 0 based stroke index for base stroke pattern [[LineStyleDefinition.ComponentType.StrokePattern]] component */\n strokeNum?: number;\n /** Symbol x offset distance in meters */\n xOffset?: number;\n /** Symbol y offset distance in meters */\n yOffset?: number;\n /** Symbol rotation in radians */\n angle?: number;\n /** Must set location for symbol as default value is [[LineStyleDefinition.SymbolOptions.None]] */\n mod1?: SymbolOptions;\n }\n\n export type Symbols = SymbolProps[];\n\n /** Stroke point component definition [[LineStyleDefinition.ComponentType.StrokePoint]].\n * A stroke point component identifies the locations of point symbol components relative to a base stroke pattern component.\n */\n export interface StrokePointProps {\n /** Name for this stroke point component */\n descr: string;\n /** The file property id of the stroke component, assumed to be [[LineStyleDefinition.ComponentType.StrokePattern]] if lcType is undefined */\n lcId: number;\n /** The component type, leave undefined if lcId is a [[LineStyleDefinition.ComponentType.StrokePattern]] */\n lcType?: ComponentType;\n /** Array of symbols */\n symbols: Symbols;\n }\n\n /** Raster component definition [[LineStyleDefinition.ComponentType.RasterImage]].\n * A raster component identifies a texture for a line style.\n */\n export interface RasterImageProps {\n /** Name for this raster image component */\n descr: string;\n /** Raster width */\n x: number;\n /** Raster height */\n y: number;\n /** True width flag */\n trueWidth?: number;\n /** Raster flags */\n flags?: number;\n /** The file property id of raster image */\n imageId?: number;\n }\n\n /** Identifies a component by file property id and type */\n export interface ComponentProps {\n /** The file property id of [[LineStyleDefinition.ComponentType.StrokePattern]] or [[LineStyleDefinition.ComponentType.StrokePoint]] component */\n id: number;\n /** The type of component for specified file property id */\n type: ComponentType;\n /** Offset distance for this component, default is 0 */\n offset?: number;\n }\n\n export type Components = ComponentProps[];\n\n /** Compound component definition [[LineStyleDefinition.ComponentType.Compound]].\n * A compound component is used to link stroke pattern and stroke point components to create a style that displays dashes, gaps, and symbols.\n */\n export interface CompoundProps {\n comps: Components;\n }\n\n /** Flags to describe a style or control style behavior */\n export enum StyleFlags {\n /** Use defaults */\n None = 0x00,\n /** Only snap to center line and not individual strokes and symbols of line style */\n NoSnap = 0x04,\n /** Style represents a continuous line with width (determined by looking at components if not set) */\n Continuous = 0x08,\n /** Style represents physical geometry and should be scaled as such */\n Physical = 0x80,\n }\n\n /** The line style definition element data */\n export interface StyleProps {\n /** The file property id for either a [[LineStyleDefinition.ComponentType.StrokePattern]] or [[LineStyleDefinition.ComponentType.Compound]] component */\n compId: number;\n /** The type of component for specified file property id */\n compType: ComponentType;\n /** Style behavior flags. Defaults to [[LineStyleDefinition.StyleFlags.NoSnap]] if left undefined */\n flags?: StyleFlags;\n /** Style scale, defaults to 1 */\n unitDef?: number;\n }\n\n /** Helper methods for creating and querying line styles */\n export class Utils {\n\n /** Create a file property for a new stroke pattern component. */\n public static createStrokePatternComponent(iModel: IModelDb, props: StrokePatternProps): StyleProps {\n const fileProps: FilePropertyProps = { name: \"LineCodeV1\", namespace: \"dgn_LStyle\" };\n fileProps.id = iModel.queryNextAvailableFileProperty(fileProps);\n iModel.saveFileProperty(fileProps, JSON.stringify(props));\n return { compId: fileProps.id, compType: ComponentType.StrokePattern };\n }\n\n /** Create a file property for a new point symbol component.\n * If base and size parameters are not supplied, queries GeometryPart by id to set them.\n */\n public static createPointSymbolComponent(iModel: IModelDb, props: PointSymbolProps): StyleProps | undefined {\n // if part extents weren't supplied, set them up now.\n if (!props.baseX && !props.baseY && !props.baseZ && !props.sizeX && !props.sizeY && !props.sizeZ) {\n const geomPart = iModel.elements.getElement<GeometryPart>(props.geomPartId);\n if (!geomPart)\n return undefined;\n\n props.baseX = geomPart.bbox.low.x;\n props.baseY = geomPart.bbox.low.y;\n props.baseZ = geomPart.bbox.low.z;\n\n props.sizeX = geomPart.bbox.high.x;\n props.sizeY = geomPart.bbox.high.y;\n props.sizeZ = geomPart.bbox.high.z;\n }\n\n const fileProps: FilePropertyProps = { name: \"PointSymV1\", namespace: \"dgn_LStyle\" };\n fileProps.id = iModel.queryNextAvailableFileProperty(fileProps);\n iModel.saveFileProperty(fileProps, JSON.stringify(props));\n return { compId: fileProps.id, compType: ComponentType.PointSymbol };\n }\n\n /** Create a file property for a new stroke point component. */\n public static createStrokePointComponent(iModel: IModelDb, props: StrokePointProps): StyleProps {\n const fileProps: FilePropertyProps = { name: \"LinePointV1\", namespace: \"dgn_LStyle\" };\n fileProps.id = iModel.queryNextAvailableFileProperty(fileProps);\n iModel.saveFileProperty(fileProps, JSON.stringify(props));\n return { compId: fileProps.id, compType: ComponentType.StrokePoint };\n }\n\n /** Create a file property for a new compound component. */\n public static createCompoundComponent(iModel: IModelDb, props: CompoundProps): StyleProps {\n const fileProps: FilePropertyProps = { name: \"CompoundV1\", namespace: \"dgn_LStyle\" };\n fileProps.id = iModel.queryNextAvailableFileProperty(fileProps);\n iModel.saveFileProperty(fileProps, JSON.stringify(props));\n return { compId: fileProps.id, compType: ComponentType.Compound };\n }\n\n /** Create a file property for a new raster image component. */\n public static createRasterComponent(iModel: IModelDb, props: RasterImageProps, image: Uint8Array): StyleProps | undefined {\n const rasterFileProps: FilePropertyProps = { name: \"RasterImageV1\", namespace: \"dgn_LStyle\" };\n rasterFileProps.id = iModel.queryNextAvailableFileProperty(rasterFileProps);\n iModel.saveFileProperty(rasterFileProps, undefined, image);\n props.imageId = rasterFileProps.id;\n const fileProps: FilePropertyProps = { name: \"RasterComponentV1\", namespace: \"dgn_LStyle\" };\n fileProps.id = iModel.queryNextAvailableFileProperty(fileProps);\n iModel.saveFileProperty(fileProps, JSON.stringify(props));\n return { compId: fileProps.id, compType: ComponentType.RasterImage };\n }\n\n /** Query for an existing line style with the supplied name. */\n public static queryStyle(imodel: IModelDb, scopeModelId: Id64String, name: string): Id64String | undefined {\n return imodel.elements.queryElementIdByCode(LineStyle.createCode(imodel, scopeModelId, name));\n }\n\n /** Insert a new line style with the supplied name.\n * @throws [[IModelError]] if unable to insert the line style definition element.\n */\n public static createStyle(imodel: IModelDb, scopeModelId: Id64String, name: string, props: StyleProps): Id64String {\n if (undefined === props.flags)\n props.flags = StyleFlags.NoSnap; // If flags weren't supplied, default to not snapping to stroke geometry.\n\n const lsProps: LineStyleProps = {\n classFullName: \"BisCore:LineStyle\",\n model: scopeModelId,\n code: LineStyle.createCode(imodel, scopeModelId, name),\n data: JSON.stringify(props),\n };\n\n return imodel.elements.insertElement(lsProps);\n }\n\n /** Query for a continuous line style that can be used to create curves with physical width instead of weight in pixels and create one if it does not already exist.\n * There are 2 ways to define a continuous line style:\n * - Width is not specified in the style itself and instead will be supplied as an override for each curve that is drawn.\n * - Defined using [[LineStyleDefinition.ComponentType.Internal]] with component id 0 [[LinePixels.Solid]] which has special behavior of being affected by width overrides.\n * - Width is specified in the style.\n * - Defined using a single stroke component that is a long dash.\n *\n * @throws [[IModelError]] if unable to insert the line style definition element.\n */\n public static getOrCreateContinuousStyle(imodel: IModelDb, scopeModelId: Id64String, width?: number): Id64String {\n if (width === undefined) {\n const name0 = \"Continuous\";\n const lsId0 = this.queryStyle(imodel, scopeModelId, name0);\n return (undefined === lsId0 ? this.createStyle(imodel, scopeModelId, name0, { compId: 0, compType: ComponentType.Internal, flags: StyleFlags.Continuous | StyleFlags.NoSnap }) : lsId0);\n }\n\n const name = `Continuous-${width}`;\n const lsId = this.queryStyle(imodel, scopeModelId, name);\n if (undefined !== lsId)\n return lsId;\n\n const strokePatternData = this.createStrokePatternComponent(imodel, { descr: name, strokes: [{ length: 1e37, orgWidth: width, strokeMode: StrokeMode.Dash, widthMode: StrokeWidth.Full }] });\n if (undefined === strokePatternData)\n throw new IModelError(IModelStatus.BadArg, \"Unable to insert stroke component\");\n\n return this.createStyle(imodel, scopeModelId, name, { compId: strokePatternData.compId, compType: strokePatternData.compType, flags: StyleFlags.Continuous | StyleFlags.NoSnap });\n }\n\n /** Query for a line style using the supplied [[LinePixels]] value (Code1-Code7) and create one if it does not already exist.\n * Most applications should instead use [[createStrokePatternComponent]] to define a style with physical dash and gap lengths.\n * Unlike other components, [[LineStyleDefinition.ComponentType.Internal]] uses the line code as the compId instead of a file property id.\n * @throws [[IModelError]] if supplied an invalid [[LinePixels]] value or if unable to insert the line style definition element.\n */\n public static getOrCreateLinePixelsStyle(imodel: IModelDb, scopeModelId: Id64String, linePixels: LinePixels): Id64String {\n let lineCode;\n switch (linePixels) {\n case LinePixels.Code1:\n lineCode = 1;\n break;\n case LinePixels.Code2:\n lineCode = 2;\n break;\n case LinePixels.Code3:\n lineCode = 3;\n break;\n case LinePixels.Code4:\n lineCode = 4;\n break;\n case LinePixels.Code5:\n lineCode = 5;\n break;\n case LinePixels.Code6:\n lineCode = 6;\n break;\n case LinePixels.Code7:\n lineCode = 7;\n break;\n default:\n throw new IModelError(IModelStatus.BadArg, \"Invalid LinePixels\");\n }\n const name = `LinePixelsCodeNumber-${lineCode}`;\n const lsId = this.queryStyle(imodel, scopeModelId, name);\n return (undefined === lsId ? this.createStyle(imodel, scopeModelId, name, { compId: lineCode, compType: ComponentType.Internal }) : lsId);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"LineStyle.js","sourceRoot":"","sources":["../../src/LineStyle.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA+D;AAC/D,oDAAgG;AAChG,uCAAoD;AAGpD;;;;;;;;;GASG;AACH,IAAiB,mBAAmB,CA6anC;AA7aD,WAAiB,mBAAmB;IAElC,4CAA4C;IAC5C,IAAY,aAaX;IAbD,WAAY,aAAa;QACvB,kEAAkE;QAClE,+DAAe,CAAA;QACf,+DAA+D;QAC/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,CAAC;aACpE;YACD,MAAM,IAAI,GAAG,wBAAwB,QAAQ,EAAE,CAAC;YAChD,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC;YACzD,OAAO,CAAC,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAC5I,CAAC;KACF;IArJY,yBAAK,QAqJjB,CAAA;AACH,CAAC,EA7agB,mBAAmB,GAAnB,2BAAmB,KAAnB,2BAAmB,QA6anC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Symbology\r\n */\r\n\r\nimport { Id64String, IModelStatus } from \"@itwin/core-bentley\";\r\nimport { FilePropertyProps, IModelError, LinePixels, LineStyleProps } from \"@itwin/core-common\";\r\nimport { GeometryPart, LineStyle } from \"./Element\";\r\nimport { IModelDb } from \"./IModelDb\";\r\n\r\n/** A line style definition is a uniquely named pattern that repeats as it is displayed along a curve path. In the absence of a line style, curve display is limited to solid lines with a width in pixels.\r\n * There are three varieties of line styles:\r\n * - A style described by a stroke pattern (series of dashes and gaps) that may also include symbol graphics.\r\n * - A style using pre-defined pixel bit patterns [[LinePixels]] for dashed display (Code1-Code7).\r\n * - A style that uses a texture.\r\n *\r\n * A definition is defined by one or more components. A component is saved as a \"file property\" and can be referenced by other components. The line style definition references a component\r\n * by file property id and type and is saved as a dictionary element.\r\n * @public\r\n */\r\nexport namespace LineStyleDefinition {\r\n\r\n /** Line style component type identifiers */\r\n export enum ComponentType {\r\n /** Component type for [[LineStyleDefinition.PointSymbolProps]] */\r\n PointSymbol = 1,\r\n /** Component type for [[LineStyleDefinition.CompoundProps]] */\r\n Compound = 2,\r\n /** Component type for [[LineStyleDefinition.StrokePatternProps]] */\r\n StrokePattern = 3,\r\n /** Component type for [[LineStyleDefinition.StrokePointProps]] */\r\n StrokePoint = 4,\r\n /** Component type for [[LinePixels]], never saved as a file property */\r\n Internal = 6,\r\n /** Component type for [[LineStyleDefinition.RasterImageProps]] */\r\n RasterImage = 7,\r\n }\r\n\r\n /** Mask of values for StrokeMode */\r\n export enum StrokeMode {\r\n /** Stroke represents a blank space */\r\n Gap = 0x00,\r\n /** Stroke represents a solid dash */\r\n Dash = 0x01,\r\n /** Treat stroke as rigid and continue past a corner to complete the stroke as opposed to breaking at the corner */\r\n Ray = 0x02,\r\n /** Stroke length can be stretched when [[LineStyleDefinition.StrokePatternOptions.Iteration]] and [[LineStyleDefinition.StrokePatternOptions.AutoPhase]] options are set, applicable to both Gap and Dash strokes */\r\n Scale = 0x04,\r\n /** Invert stroke in first stroke pattern */\r\n FirstInvert = 0x08,\r\n /** Invert stroke in last stroke pattern */\r\n LastInvert = 0x10,\r\n }\r\n\r\n /** Define constant width or tapered strokes with distance specified in meters */\r\n export enum StrokeWidth {\r\n /** Stroke draws as one pixel wide line */\r\n None = 0,\r\n /** Half [[LineStyleDefinition.StrokeProps.orgWidth]] and [[LineStyleDefinition.StrokeProps.endWidth]] applied to left side of stroke */\r\n Left = 1,\r\n /** Half [[LineStyleDefinition.StrokeProps.orgWidth]] and [[LineStyleDefinition.StrokeProps.endWidth]] applied to right side of stroke */\r\n Right = 2,\r\n /** Half [[LineStyleDefinition.StrokeProps.orgWidth]] and [[LineStyleDefinition.StrokeProps.endWidth]] applied to both sides of stroke */\r\n Full = 3,\r\n }\r\n\r\n /** Controls appearance of stroke end caps. If StrokeCap is >= Hexagon, the end cap is stroked as an arc and the value of\r\n * StrokeCap indicates the number of vectors in the arc.\r\n */\r\n export enum StrokeCap {\r\n /** Stroke displays as a closed polygon */\r\n Closed = 0,\r\n /** Stroke displays lines at specified width instead of a polygon */\r\n Open = 1,\r\n /** Stroke length extended by half the stroke width */\r\n Extended = 2,\r\n /** Stroke end cap is a hexagon */\r\n Hexagon = 3,\r\n /** Stroke end cap is an octagon */\r\n Octagon = 4,\r\n /** Stroke end cap is a decagon */\r\n Decagon = 5,\r\n /** Stroke end cap is an arc */\r\n Arc = 30,\r\n }\r\n\r\n /** A stroke representing either a dash or gap in a stroke pattern */\r\n export interface StrokeProps {\r\n /** Length of stroke in meters */\r\n length: number;\r\n /** Width at start of stroke. Behavior controlled by [[LineStyleDefinition.StrokeWidth]], choose value other than [[LineStyleDefinition.StrokeWidth.None]] */\r\n orgWidth?: number;\r\n /** Width at end of stroke, same as start width if not present. Behavior controlled by [[LineStyleDefinition.StrokeWidth]], choose value other than [[LineStyleDefinition.StrokeWidth.None]] */\r\n endWidth?: number;\r\n /** Type and behavior of stroke */\r\n strokeMode?: StrokeMode;\r\n /** How to apply orgWidth and endWidth to stroke */\r\n widthMode?: StrokeWidth;\r\n /** Appearance of stroke end cap */\r\n capMode?: StrokeCap;\r\n }\r\n\r\n export type Strokes = StrokeProps[];\r\n\r\n /** Options to control how stroke pattern is applied to underlying curve */\r\n export enum StrokePatternOptions {\r\n /** Use default stroke behavior */\r\n None = 0x00,\r\n /** [[LineStyleDefinition.StrokePatternProps.phase]] represents fractional distance into first stroke of pattern */\r\n AutoPhase = 0x01,\r\n /** Use [[LineStyleDefinition.StrokePatternProps.maxIter]] to limit the number of iterations of the stroke pattern */\r\n Iteration = 0x08,\r\n /** Single segment mode restarts the stroke pattern at corners instead of continuing around corners */\r\n Segment = 0x10,\r\n /** Center the line style and stretch the ends */\r\n CenterStretch = 0x20,\r\n }\r\n\r\n /** Stroke pattern component definition [[LineStyleDefinition.ComponentType.StrokePattern]].\r\n * A stroke pattern component consists of a series of dashes and gaps having specified lengths and widths in meters. Simple dash-dot type line styles that do not\r\n * include point symbols can be created by referencing a stroke pattern component by its file property id.\r\n */\r\n export interface StrokePatternProps {\r\n /** Name for this stroke pattern */\r\n descr: string;\r\n /** Skip into the pattern before starting to draw. Value treated as fraction of the first stroke when [[LineStyleDefinition.StrokePatternOptions.AutoPhase]] set. Value used as distance when [[LineStyleDefinition.StrokePatternOptions.CenterStretch]] is not set. */\r\n phase?: number;\r\n /** Options mask for this stroke pattern */\r\n options?: StrokePatternOptions;\r\n /** The entire stroke pattern will be repeated no more than maxIter on curve or segment when [[LineStyleDefinition.StrokePatternOptions.Iteration]] is set and stroke pattern includes stretchable strokes. */\r\n maxIter?: number;\r\n /** Array of strokes, maximum number that will be used is 32 */\r\n strokes: Strokes;\r\n }\r\n\r\n /** Flags to identify point symbol behavior */\r\n export enum PointSymbolFlags {\r\n /** Default symbol behavior */\r\n None = 0x0,\r\n /** Symbol includes 3d geometry */\r\n Is3d = 0x01,\r\n /** Symbol does not allow scaling */\r\n NoScale = 0x02,\r\n }\r\n\r\n /** Point symbol component definition [[LineStyleDefinition.ComponentType.PointSymbol]].\r\n * A point symbol component identifies a GeometryPart for reference by a [[LineStyleDefinition.SymbolProps]].\r\n */\r\n export interface PointSymbolProps {\r\n /** GeometryPart Id to use as a pattern symbol */\r\n geomPartId: Id64String;\r\n /** GeometryPart.bbox.low.x */\r\n baseX?: number;\r\n /** GeometryPart.bbox.low.y */\r\n baseY?: number;\r\n /** GeometryPart.bbox.low.z */\r\n baseZ?: number;\r\n /** GeometryPart.bbox.high.x */\r\n sizeX?: number;\r\n /** GeometryPart.bbox.high.y */\r\n sizeY?: number;\r\n /** GeometryPart.bbox.high.z */\r\n sizeZ?: number;\r\n /** Symbol behavior flags */\r\n symFlags?: PointSymbolFlags;\r\n /** Symbol scale, defaults to 1 */\r\n scale?: number;\r\n }\r\n\r\n /** Symbol options for location, orientation, and behavior */\r\n export enum SymbolOptions {\r\n /** No point symbol */\r\n None = 0x00,\r\n /** Symbol at origin of stroke */\r\n Origin = 0x01,\r\n /** Symbol at end of stroke */\r\n End = 0x02,\r\n /** symbol at center of stroke */\r\n Center = 0x03,\r\n /** Symbol at curve start point */\r\n CurveOrigin = 0x0004,\r\n /** Symbol at curve end point */\r\n CurveEnd = 0x0008,\r\n /** Symbol at each vertex */\r\n CurveVertex = 0x0010,\r\n /** Adjust symbol rotation left->right */\r\n AdjustRotation = 0x0020,\r\n /** Angle of symbol not relative to stroke direction */\r\n AbsoluteRotation = 0x0040,\r\n /** No scale on variable strokes */\r\n NoScale = 0x0100,\r\n /** No clip on partial strokes */\r\n NoClip = 0x0200,\r\n /** No partial strokes */\r\n NoPartial = 0x0400,\r\n /** Project partial origin */\r\n ProjectOrigin = 0x0800,\r\n /** Use color from symbol instead of inheriting curve color */\r\n UseColor = 0x4000,\r\n /** Use weight from symbol instead of inheriting curve weight */\r\n UseWeight = 0x8000,\r\n }\r\n\r\n /** Identifies a symbol and its location and orientation relative to a stroke pattern */\r\n export interface SymbolProps {\r\n /** The file property id of the symbol component, assumed to be [[LineStyleDefinition.ComponentType.PointSymbol]] if symType is undefined. */\r\n symId: number;\r\n /** The component type, leave undefined if symId is a [[LineStyleDefinition.ComponentType.PointSymbol]] */\r\n symType?: ComponentType;\r\n /** The 0 based stroke index for base stroke pattern [[LineStyleDefinition.ComponentType.StrokePattern]] component */\r\n strokeNum?: number;\r\n /** Symbol x offset distance in meters */\r\n xOffset?: number;\r\n /** Symbol y offset distance in meters */\r\n yOffset?: number;\r\n /** Symbol rotation in radians */\r\n angle?: number;\r\n /** Must set location for symbol as default value is [[LineStyleDefinition.SymbolOptions.None]] */\r\n mod1?: SymbolOptions;\r\n }\r\n\r\n export type Symbols = SymbolProps[];\r\n\r\n /** Stroke point component definition [[LineStyleDefinition.ComponentType.StrokePoint]].\r\n * A stroke point component identifies the locations of point symbol components relative to a base stroke pattern component.\r\n */\r\n export interface StrokePointProps {\r\n /** Name for this stroke point component */\r\n descr: string;\r\n /** The file property id of the stroke component, assumed to be [[LineStyleDefinition.ComponentType.StrokePattern]] if lcType is undefined */\r\n lcId: number;\r\n /** The component type, leave undefined if lcId is a [[LineStyleDefinition.ComponentType.StrokePattern]] */\r\n lcType?: ComponentType;\r\n /** Array of symbols */\r\n symbols: Symbols;\r\n }\r\n\r\n /** Raster component definition [[LineStyleDefinition.ComponentType.RasterImage]].\r\n * A raster component identifies a texture for a line style.\r\n */\r\n export interface RasterImageProps {\r\n /** Name for this raster image component */\r\n descr: string;\r\n /** Raster width */\r\n x: number;\r\n /** Raster height */\r\n y: number;\r\n /** True width flag */\r\n trueWidth?: number;\r\n /** Raster flags */\r\n flags?: number;\r\n /** The file property id of raster image */\r\n imageId?: number;\r\n }\r\n\r\n /** Identifies a component by file property id and type */\r\n export interface ComponentProps {\r\n /** The file property id of [[LineStyleDefinition.ComponentType.StrokePattern]] or [[LineStyleDefinition.ComponentType.StrokePoint]] component */\r\n id: number;\r\n /** The type of component for specified file property id */\r\n type: ComponentType;\r\n /** Offset distance for this component, default is 0 */\r\n offset?: number;\r\n }\r\n\r\n export type Components = ComponentProps[];\r\n\r\n /** Compound component definition [[LineStyleDefinition.ComponentType.Compound]].\r\n * A compound component is used to link stroke pattern and stroke point components to create a style that displays dashes, gaps, and symbols.\r\n */\r\n export interface CompoundProps {\r\n comps: Components;\r\n }\r\n\r\n /** Flags to describe a style or control style behavior */\r\n export enum StyleFlags {\r\n /** Use defaults */\r\n None = 0x00,\r\n /** Only snap to center line and not individual strokes and symbols of line style */\r\n NoSnap = 0x04,\r\n /** Style represents a continuous line with width (determined by looking at components if not set) */\r\n Continuous = 0x08,\r\n /** Style represents physical geometry and should be scaled as such */\r\n Physical = 0x80,\r\n }\r\n\r\n /** The line style definition element data */\r\n export interface StyleProps {\r\n /** The file property id for either a [[LineStyleDefinition.ComponentType.StrokePattern]] or [[LineStyleDefinition.ComponentType.Compound]] component */\r\n compId: number;\r\n /** The type of component for specified file property id */\r\n compType: ComponentType;\r\n /** Style behavior flags. Defaults to [[LineStyleDefinition.StyleFlags.NoSnap]] if left undefined */\r\n flags?: StyleFlags;\r\n /** Style scale, defaults to 1 */\r\n unitDef?: number;\r\n }\r\n\r\n /** Helper methods for creating and querying line styles */\r\n export class Utils {\r\n\r\n /** Create a file property for a new stroke pattern component. */\r\n public static createStrokePatternComponent(iModel: IModelDb, props: StrokePatternProps): StyleProps {\r\n const fileProps: FilePropertyProps = { name: \"LineCodeV1\", namespace: \"dgn_LStyle\" };\r\n fileProps.id = iModel.queryNextAvailableFileProperty(fileProps);\r\n iModel.saveFileProperty(fileProps, JSON.stringify(props));\r\n return { compId: fileProps.id, compType: ComponentType.StrokePattern };\r\n }\r\n\r\n /** Create a file property for a new point symbol component.\r\n * If base and size parameters are not supplied, queries GeometryPart by id to set them.\r\n */\r\n public static createPointSymbolComponent(iModel: IModelDb, props: PointSymbolProps): StyleProps | undefined {\r\n // if part extents weren't supplied, set them up now.\r\n if (!props.baseX && !props.baseY && !props.baseZ && !props.sizeX && !props.sizeY && !props.sizeZ) {\r\n const geomPart = iModel.elements.getElement<GeometryPart>(props.geomPartId);\r\n if (!geomPart)\r\n return undefined;\r\n\r\n props.baseX = geomPart.bbox.low.x;\r\n props.baseY = geomPart.bbox.low.y;\r\n props.baseZ = geomPart.bbox.low.z;\r\n\r\n props.sizeX = geomPart.bbox.high.x;\r\n props.sizeY = geomPart.bbox.high.y;\r\n props.sizeZ = geomPart.bbox.high.z;\r\n }\r\n\r\n const fileProps: FilePropertyProps = { name: \"PointSymV1\", namespace: \"dgn_LStyle\" };\r\n fileProps.id = iModel.queryNextAvailableFileProperty(fileProps);\r\n iModel.saveFileProperty(fileProps, JSON.stringify(props));\r\n return { compId: fileProps.id, compType: ComponentType.PointSymbol };\r\n }\r\n\r\n /** Create a file property for a new stroke point component. */\r\n public static createStrokePointComponent(iModel: IModelDb, props: StrokePointProps): StyleProps {\r\n const fileProps: FilePropertyProps = { name: \"LinePointV1\", namespace: \"dgn_LStyle\" };\r\n fileProps.id = iModel.queryNextAvailableFileProperty(fileProps);\r\n iModel.saveFileProperty(fileProps, JSON.stringify(props));\r\n return { compId: fileProps.id, compType: ComponentType.StrokePoint };\r\n }\r\n\r\n /** Create a file property for a new compound component. */\r\n public static createCompoundComponent(iModel: IModelDb, props: CompoundProps): StyleProps {\r\n const fileProps: FilePropertyProps = { name: \"CompoundV1\", namespace: \"dgn_LStyle\" };\r\n fileProps.id = iModel.queryNextAvailableFileProperty(fileProps);\r\n iModel.saveFileProperty(fileProps, JSON.stringify(props));\r\n return { compId: fileProps.id, compType: ComponentType.Compound };\r\n }\r\n\r\n /** Create a file property for a new raster image component. */\r\n public static createRasterComponent(iModel: IModelDb, props: RasterImageProps, image: Uint8Array): StyleProps | undefined {\r\n const rasterFileProps: FilePropertyProps = { name: \"RasterImageV1\", namespace: \"dgn_LStyle\" };\r\n rasterFileProps.id = iModel.queryNextAvailableFileProperty(rasterFileProps);\r\n iModel.saveFileProperty(rasterFileProps, undefined, image);\r\n props.imageId = rasterFileProps.id;\r\n const fileProps: FilePropertyProps = { name: \"RasterComponentV1\", namespace: \"dgn_LStyle\" };\r\n fileProps.id = iModel.queryNextAvailableFileProperty(fileProps);\r\n iModel.saveFileProperty(fileProps, JSON.stringify(props));\r\n return { compId: fileProps.id, compType: ComponentType.RasterImage };\r\n }\r\n\r\n /** Query for an existing line style with the supplied name. */\r\n public static queryStyle(imodel: IModelDb, scopeModelId: Id64String, name: string): Id64String | undefined {\r\n return imodel.elements.queryElementIdByCode(LineStyle.createCode(imodel, scopeModelId, name));\r\n }\r\n\r\n /** Insert a new line style with the supplied name.\r\n * @throws [[IModelError]] if unable to insert the line style definition element.\r\n */\r\n public static createStyle(imodel: IModelDb, scopeModelId: Id64String, name: string, props: StyleProps): Id64String {\r\n if (undefined === props.flags)\r\n props.flags = StyleFlags.NoSnap; // If flags weren't supplied, default to not snapping to stroke geometry.\r\n\r\n const lsProps: LineStyleProps = {\r\n classFullName: \"BisCore:LineStyle\",\r\n model: scopeModelId,\r\n code: LineStyle.createCode(imodel, scopeModelId, name),\r\n data: JSON.stringify(props),\r\n };\r\n\r\n return imodel.elements.insertElement(lsProps);\r\n }\r\n\r\n /** Query for a continuous line style that can be used to create curves with physical width instead of weight in pixels and create one if it does not already exist.\r\n * There are 2 ways to define a continuous line style:\r\n * - Width is not specified in the style itself and instead will be supplied as an override for each curve that is drawn.\r\n * - Defined using [[LineStyleDefinition.ComponentType.Internal]] with component id 0 [[LinePixels.Solid]] which has special behavior of being affected by width overrides.\r\n * - Width is specified in the style.\r\n * - Defined using a single stroke component that is a long dash.\r\n *\r\n * @throws [[IModelError]] if unable to insert the line style definition element.\r\n */\r\n public static getOrCreateContinuousStyle(imodel: IModelDb, scopeModelId: Id64String, width?: number): Id64String {\r\n if (width === undefined) {\r\n const name0 = \"Continuous\";\r\n const lsId0 = this.queryStyle(imodel, scopeModelId, name0);\r\n return (undefined === lsId0 ? this.createStyle(imodel, scopeModelId, name0, { compId: 0, compType: ComponentType.Internal, flags: StyleFlags.Continuous | StyleFlags.NoSnap }) : lsId0);\r\n }\r\n\r\n const name = `Continuous-${width}`;\r\n const lsId = this.queryStyle(imodel, scopeModelId, name);\r\n if (undefined !== lsId)\r\n return lsId;\r\n\r\n const strokePatternData = this.createStrokePatternComponent(imodel, { descr: name, strokes: [{ length: 1e37, orgWidth: width, strokeMode: StrokeMode.Dash, widthMode: StrokeWidth.Full }] });\r\n if (undefined === strokePatternData)\r\n throw new IModelError(IModelStatus.BadArg, \"Unable to insert stroke component\");\r\n\r\n return this.createStyle(imodel, scopeModelId, name, { compId: strokePatternData.compId, compType: strokePatternData.compType, flags: StyleFlags.Continuous | StyleFlags.NoSnap });\r\n }\r\n\r\n /** Query for a line style using the supplied [[LinePixels]] value (Code1-Code7) and create one if it does not already exist.\r\n * Most applications should instead use [[createStrokePatternComponent]] to define a style with physical dash and gap lengths.\r\n * Unlike other components, [[LineStyleDefinition.ComponentType.Internal]] uses the line code as the compId instead of a file property id.\r\n * @throws [[IModelError]] if supplied an invalid [[LinePixels]] value or if unable to insert the line style definition element.\r\n */\r\n public static getOrCreateLinePixelsStyle(imodel: IModelDb, scopeModelId: Id64String, linePixels: LinePixels): Id64String {\r\n let lineCode;\r\n switch (linePixels) {\r\n case LinePixels.Code1:\r\n lineCode = 1;\r\n break;\r\n case LinePixels.Code2:\r\n lineCode = 2;\r\n break;\r\n case LinePixels.Code3:\r\n lineCode = 3;\r\n break;\r\n case LinePixels.Code4:\r\n lineCode = 4;\r\n break;\r\n case LinePixels.Code5:\r\n lineCode = 5;\r\n break;\r\n case LinePixels.Code6:\r\n lineCode = 6;\r\n break;\r\n case LinePixels.Code7:\r\n lineCode = 7;\r\n break;\r\n default:\r\n throw new IModelError(IModelStatus.BadArg, \"Invalid LinePixels\");\r\n }\r\n const name = `LinePixelsCodeNumber-${lineCode}`;\r\n const lsId = this.queryStyle(imodel, scopeModelId, name);\r\n return (undefined === lsId ? this.createStyle(imodel, scopeModelId, name, { compId: lineCode, compType: ComponentType.Internal }) : lsId);\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LocalhostIpcHost.js","sourceRoot":"","sources":["../../src/LocalhostIpcHost.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,yBAAyB;AACzB,oDAAmH;AACnH,uCAAoC;AASpC,MAAM,cAAe,SAAQ,mCAAqB;IAIhD,YAAmB,IAA0B;;QAC3C,KAAK,EAAE,CAAC;QAHF,iBAAY,GAAY,IAAI,GAAG,EAAE,CAAC;QAKxC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YAClB,IAAI,CAAC,OAAO,GAAG,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,MAAA,IAAI,CAAC,UAAU,mCAAI,IAAI,EAAE,CAAC,CAAC;YAChE,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC,gBAAgB,CAAC,OAAO,CAAC,UAAU,CAAC,C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;CACF;AAVD,4CAUC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module IModelHost\n */\n\nimport * as ws from \"ws\";\nimport { IpcWebSocket, IpcWebSocketBackend, IpcWebSocketMessage, IpcWebSocketTransport } from \"@itwin/core-common\";\nimport { IpcHost } from \"./IpcHost\";\nimport { IModelHostConfiguration } from \"./IModelHost\";\n\n/** @internal */\nexport interface LocalhostIpcHostOpts {\n socketPort?: number;\n noServer?: boolean;\n}\n\nclass LocalTransport extends IpcWebSocketTransport {\n private _server: ws.Server | undefined;\n private _connections: Set<ws> = new Set();\n\n public constructor(opts: LocalhostIpcHostOpts) {\n super();\n\n if (!opts.noServer) {\n this._server = new ws.Server({ port: opts.socketPort ?? 3002 });\n this._server.on(\"connection\", (connection) => LocalhostIpcHost.connect(connection));\n }\n }\n\n public send(message: IpcWebSocketMessage): void {\n this._connections.forEach((connection) => connection.send(JSON.stringify(message)));\n }\n\n public connect(connection: ws) {\n this._connections.add(connection);\n\n connection.on(\"message\", (data) => {\n for (const listener of IpcWebSocket.receivers) {\n listener({} as Event, JSON.parse(data as string));\n }\n });\n\n connection.on(\"close\", () => {\n this._connections.delete(connection);\n });\n }\n}\n\n/** @internal */\nexport class LocalhostIpcHost {\n public static connect(connection: ws) {\n (IpcWebSocket.transport as LocalTransport).connect(connection);\n }\n\n public static async startup(opts?: { localhostIpcHost?: LocalhostIpcHostOpts, iModelHost?: IModelHostConfiguration }) {\n IpcWebSocket.transport = new LocalTransport(opts?.localhostIpcHost ?? {});\n const socket = new IpcWebSocketBackend();\n await IpcHost.startup({ ipcHost: { socket }, iModelHost: opts?.iModelHost });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"LocalhostIpcHost.js","sourceRoot":"","sources":["../../src/LocalhostIpcHost.ts"],"names":[],"mappings":";AAAA;;;+F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C,OAAO,CAAC,UAAc;QACjC,0BAAY,CAAC,SAA4B,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IACjE,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,IAAwF;;QAClH,0BAAY,CAAC,SAAS,GAAG,IAAI,cAAc,CAAC,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,gBAAgB,mCAAI,EAAE,CAAC,CAAC;QAC1E,MAAM,MAAM,GAAG,IAAI,iCAAmB,EAAE,CAAC;QACzC,MAAM,iBAAO,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,UAAU,EAAE,CAAC,CAAC;IAC/E,CAAC;CACF;AAVD,4CAUC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module IModelHost\r\n */\r\n\r\nimport * as ws from \"ws\";\r\nimport { IpcWebSocket, IpcWebSocketBackend, IpcWebSocketMessage, IpcWebSocketTransport } from \"@itwin/core-common\";\r\nimport { IpcHost } from \"./IpcHost\";\r\nimport { IModelHostConfiguration } from \"./IModelHost\";\r\n\r\n/** @internal */\r\nexport interface LocalhostIpcHostOpts {\r\n socketPort?: number;\r\n noServer?: boolean;\r\n}\r\n\r\nclass LocalTransport extends IpcWebSocketTransport {\r\n private _server: ws.Server | undefined;\r\n private _connections: Set<ws> = new Set();\r\n\r\n public constructor(opts: LocalhostIpcHostOpts) {\r\n super();\r\n\r\n if (!opts.noServer) {\r\n this._server = new ws.Server({ port: opts.socketPort ?? 3002 });\r\n this._server.on(\"connection\", (connection) => LocalhostIpcHost.connect(connection));\r\n }\r\n }\r\n\r\n public send(message: IpcWebSocketMessage): void {\r\n this._connections.forEach((connection) => connection.send(JSON.stringify(message)));\r\n }\r\n\r\n public connect(connection: ws) {\r\n this._connections.add(connection);\r\n\r\n connection.on(\"message\", (data) => {\r\n for (const listener of IpcWebSocket.receivers) {\r\n listener({} as Event, JSON.parse(data as string));\r\n }\r\n });\r\n\r\n connection.on(\"close\", () => {\r\n this._connections.delete(connection);\r\n });\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport class LocalhostIpcHost {\r\n public static connect(connection: ws) {\r\n (IpcWebSocket.transport as LocalTransport).connect(connection);\r\n }\r\n\r\n public static async startup(opts?: { localhostIpcHost?: LocalhostIpcHostOpts, iModelHost?: IModelHostConfiguration }) {\r\n IpcWebSocket.transport = new LocalTransport(opts?.localhostIpcHost ?? {});\r\n const socket = new IpcWebSocketBackend();\r\n await IpcHost.startup({ ipcHost: { socket }, iModelHost: opts?.iModelHost });\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PromiseMemoizer.js","sourceRoot":"","sources":["../../src/PromiseMemoizer.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA6C;AAC7C,mEAAgE;AAEhE;;GAEG;AACH,MAAa,gBAAgB;IAU3B,YAAmC,OAAmB;QAAnB,YAAO,GAAP,OAAO,CAAY;QAN9C,eAAU,GAAY,KAAK,CAAC;QAC5B,cAAS,GAAY,KAAK,CAAC;QAMjC,IAAI,CAAC,OAAO;aACT,IAAI,CAAC,CAAC,GAAM,EAAE,EAAE,GAAG,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;aAChE,KAAK,CAAC,CAAC,GAAQ,EAAE,EAAE,GAAG,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IACvE,CAAC;IAPD,IAAW,SAAS,KAAc,OAAO,CAA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GAAG,MAAM,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACvG,EAAE,GAAG,IAAI,gBAAgB,CAAI,CAAC,CAAC,CAAC;YAChC,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;YAClC,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC;QAEF,mCAAmC;QAC5B,mBAAc,GAAG,CAAC,GAAG,IAAW,EAAE,EAAE;YACzC,MAAM,GAAG,GAAW,IAAI,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,CAAC;YACjD,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACnC,CAAC,CAAC;QAEF,8CAA8C;QACvC,eAAU,GAAG,GAAG,EAAE;YACvB,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;QAC/B,CAAC,CAAC;QAvCA,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;QACpC,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;QAClC,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;IACpC,CAAC;CAoCF;AAzDD,0CAyDC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Utils\n */\n\nimport { Logger } from \"@itwin/core-bentley\";\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\n\n/** Wrapper around a promise that allows synchronous queries of it's state\n * @internal\n */\nexport class QueryablePromise<T> {\n public result?: T;\n public error?: any;\n\n private _fulfilled: boolean = false;\n private _rejected: boolean = false;\n\n public get isPending(): boolean { return !this.isFulfilled && !this.isRejected; }\n public get isFulfilled(): boolean { return this._fulfilled; }\n public get isRejected(): boolean { return this._rejected; }\n public constructor(public readonly promise: Promise<T>) {\n this.promise\n .then((res: T) => { this.result = res; this._fulfilled = true; })\n .catch((err: any) => { this.error = err; this._rejected = true; });\n }\n}\n\n/** @internal */\nexport type MemoizeFnType<T> = (...args: any[]) => Promise<T>;\n/** @internal */\nexport type GenerateKeyFnType = (...args: any[]) => string;\n\n/** Utility to cache and retrieve results of long running asynchronous functions.\n * The cache is keyed on the input arguments passed to these functions\n * @internal\n */\nexport class PromiseMemoizer<T> {\n private readonly _cachedPromises: Map<string, QueryablePromise<T>> = new Map<string, QueryablePromise<T>>();\n private readonly _memoizeFn: MemoizeFnType<T>;\n private readonly _generateKeyFn: GenerateKeyFnType;\n private readonly _maxCacheSize: number;\n private readonly _cacheTimeout: number;\n\n /**\n * Constructor\n * @param memoizeFn Function to memoize\n * @param generateKeyFn Function to generate the key for the memoized function\n * @param maxCacheSize Maximum size of the memoizer cache.\n * If the maximum cache size is exceeded, fulfilled/rejected entries are first discarded - these\n * may have been unclaimed/orphaned promises. If the cache size is still above the maxCacheSize\n * threshold, the entire cache is then cleared.\n */\n public constructor(memoizeFn: MemoizeFnType<T>, generateKeyFn: GenerateKeyFnType, maxCacheSize: number = 500, cacheTimeout: number = 30000) {\n this._memoizeFn = memoizeFn;\n this._generateKeyFn = generateKeyFn;\n this._maxCacheSize = maxCacheSize;\n this._cacheTimeout = cacheTimeout;\n }\n\n /** Call the memoized function */\n public memoize = (...args: any[]): QueryablePromise<T> => {\n const key: string = this._generateKeyFn(...args);\n let qp: QueryablePromise<T> | undefined = this._cachedPromises.get(key);\n if (qp)\n return qp;\n\n if (this._cachedPromises.size >= this._maxCacheSize) {\n if (this._maxCacheSize > 1)\n Logger.logError(BackendLoggerCategory.PromiseMemoizer, \"Cleared too many unresolved entries in memoizer cache\");\n this.clearCache();\n }\n\n const removeCachedPromise = (v: T) => {\n setTimeout(() => this._cachedPromises.delete(key), this._cacheTimeout);\n return v;\n };\n\n const p = this._memoizeFn(...args).then(removeCachedPromise, (e) => { throw removeCachedPromise(e); });\n qp = new QueryablePromise<T>(p);\n this._cachedPromises.set(key, qp);\n return qp;\n };\n\n /** Delete the memoized function */\n public deleteMemoized = (...args: any[]) => {\n const key: string = this._generateKeyFn(...args);\n this._cachedPromises.delete(key);\n };\n\n /** Clear all entries in the memoizer cache */\n public clearCache = () => {\n this._cachedPromises.clear();\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"PromiseMemoizer.js","sourceRoot":"","sources":["../../src/PromiseMemoizer.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA6C;AAC7C,mEAAgE;AAEhE;;GAEG;AACH,MAAa,gBAAgB;IAU3B,YAAmC,OAAmB;QAAnB,YAAO,GAAP,OAAO,CAAY;QAN9C,eAAU,GAAY,KAAK,CAAC;QAC5B,cAAS,GAAY,KAAK,CAAC;QAMjC,IAAI,CAAC,OAAO;aACT,IAAI,CAAC,CAAC,GAAM,EAAE,EAAE,GAAG,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;aAChE,KAAK,CAAC,CAAC,GAAQ,EAAE,EAAE,GAAG,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IACvE,CAAC;IAPD,IAAW,SAAS,KAAc,OAAO,CAAC,IAAI,CAAC,WAAW,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;IACjF,IAAW,WAAW,KAAc,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;IAC7D,IAAW,UAAU,KAAc,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;CAM5D;AAfD,4CAeC;AAOD;;;GAGG;AACH,MAAa,eAAe;IAO1B;;;;;;;;OAQG;IACH,YAAmB,SAA2B,EAAE,aAAgC,EAAE,eAAuB,GAAG,EAAE,eAAuB,KAAK;Q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AAC,GAAG,IAAI,CAAC,CAAC;YACjD,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACnC,CAAC,CAAC;QAEF,8CAA8C;QACvC,eAAU,GAAG,GAAG,EAAE;YACvB,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;QAC/B,CAAC,CAAC;QAvCA,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;QACpC,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;QAClC,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;IACpC,CAAC;CAoCF;AAzDD,0CAyDC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Utils\r\n */\r\n\r\nimport { Logger } from \"@itwin/core-bentley\";\r\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\r\n\r\n/** Wrapper around a promise that allows synchronous queries of it's state\r\n * @internal\r\n */\r\nexport class QueryablePromise<T> {\r\n public result?: T;\r\n public error?: any;\r\n\r\n private _fulfilled: boolean = false;\r\n private _rejected: boolean = false;\r\n\r\n public get isPending(): boolean { return !this.isFulfilled && !this.isRejected; }\r\n public get isFulfilled(): boolean { return this._fulfilled; }\r\n public get isRejected(): boolean { return this._rejected; }\r\n public constructor(public readonly promise: Promise<T>) {\r\n this.promise\r\n .then((res: T) => { this.result = res; this._fulfilled = true; })\r\n .catch((err: any) => { this.error = err; this._rejected = true; });\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport type MemoizeFnType<T> = (...args: any[]) => Promise<T>;\r\n/** @internal */\r\nexport type GenerateKeyFnType = (...args: any[]) => string;\r\n\r\n/** Utility to cache and retrieve results of long running asynchronous functions.\r\n * The cache is keyed on the input arguments passed to these functions\r\n * @internal\r\n */\r\nexport class PromiseMemoizer<T> {\r\n private readonly _cachedPromises: Map<string, QueryablePromise<T>> = new Map<string, QueryablePromise<T>>();\r\n private readonly _memoizeFn: MemoizeFnType<T>;\r\n private readonly _generateKeyFn: GenerateKeyFnType;\r\n private readonly _maxCacheSize: number;\r\n private readonly _cacheTimeout: number;\r\n\r\n /**\r\n * Constructor\r\n * @param memoizeFn Function to memoize\r\n * @param generateKeyFn Function to generate the key for the memoized function\r\n * @param maxCacheSize Maximum size of the memoizer cache.\r\n * If the maximum cache size is exceeded, fulfilled/rejected entries are first discarded - these\r\n * may have been unclaimed/orphaned promises. If the cache size is still above the maxCacheSize\r\n * threshold, the entire cache is then cleared.\r\n */\r\n public constructor(memoizeFn: MemoizeFnType<T>, generateKeyFn: GenerateKeyFnType, maxCacheSize: number = 500, cacheTimeout: number = 30000) {\r\n this._memoizeFn = memoizeFn;\r\n this._generateKeyFn = generateKeyFn;\r\n this._maxCacheSize = maxCacheSize;\r\n this._cacheTimeout = cacheTimeout;\r\n }\r\n\r\n /** Call the memoized function */\r\n public memoize = (...args: any[]): QueryablePromise<T> => {\r\n const key: string = this._generateKeyFn(...args);\r\n let qp: QueryablePromise<T> | undefined = this._cachedPromises.get(key);\r\n if (qp)\r\n return qp;\r\n\r\n if (this._cachedPromises.size >= this._maxCacheSize) {\r\n if (this._maxCacheSize > 1)\r\n Logger.logError(BackendLoggerCategory.PromiseMemoizer, \"Cleared too many unresolved entries in memoizer cache\");\r\n this.clearCache();\r\n }\r\n\r\n const removeCachedPromise = (v: T) => {\r\n setTimeout(() => this._cachedPromises.delete(key), this._cacheTimeout);\r\n return v;\r\n };\r\n\r\n const p = this._memoizeFn(...args).then(removeCachedPromise, (e) => { throw removeCachedPromise(e); });\r\n qp = new QueryablePromise<T>(p);\r\n this._cachedPromises.set(key, qp);\r\n return qp;\r\n };\r\n\r\n /** Delete the memoized function */\r\n public deleteMemoized = (...args: any[]) => {\r\n const key: string = this._generateKeyFn(...args);\r\n this._cachedPromises.delete(key);\r\n };\r\n\r\n /** Clear all entries in the memoizer cache */\r\n public clearCache = () => {\r\n this._cachedPromises.clear();\r\n };\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Relationship.js","sourceRoot":"","sources":["../../src/Relationship.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAiE;AACjE,oDAAmG;AAEnG,qCAAkC;AAKlC;;GAEG;AACH,MAAa,YAAa,SAAQ,eAAM;IAMtC,gBAAgB;IAChB,YAAY,KAAwB,EAAE,MAAgB;QACpD,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,mBAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAC9C,IAAI,CAAC,QAAQ,GAAG,mBAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAChD,CAAC;IAVD,gBAAgB;IACT,MAAM,KAAc,SAAS,KAAa,OAAO,cAAc,CAAC,CAAC,CAAC;IAWzE,gBAAgB;IACA,MAAM;QACpB,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,EAAuB,CAAC;QAChD,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC7B,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC7B,OAAO,GAAG,CAAC;IACb,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,aAAa,CAAC,MAAyB,EAAE,OAAiB,IAAU,CAAC;IAEnF;;;;;OAKG;IACI,MAAM,CAAC,mBAAmB,CAAC,MAAyB,EAAE,OAAiB,IAAU,CAAC;IAEzF,gDAAgD;IACzC,MAAM,KAAiB,OAAO,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACtF,8CAA8C;IACvC,MAAM,KAAK,I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SAAS,KAAK,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,eAAe,CAAI,iBAAiB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC1G,CAAC;CACF;AAvGD,sCAuGC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Relationships\n */\n\nimport { DbResult, Id64, Id64String } from \"@itwin/core-bentley\";\nimport { IModelError, IModelStatus, RelationshipProps, SourceAndTarget } from \"@itwin/core-common\";\nimport { ECSqlStatement } from \"./ECSqlStatement\";\nimport { Entity } from \"./Entity\";\nimport { IModelDb } from \"./IModelDb\";\n\nexport type { SourceAndTarget, RelationshipProps } from \"@itwin/core-common\"; // for backwards compatibility\n\n/** Base class for all link table ECRelationships\n * @public\n */\nexport class Relationship extends Entity implements RelationshipProps {\n /** @internal */\n public static override get className(): string { return \"Relationship\"; }\n public readonly sourceId: Id64String;\n public readonly targetId: Id64String;\n\n /** @internal */\n constructor(props: RelationshipProps, iModel: IModelDb) {\n super(props, iModel);\n this.sourceId = Id64.fromJSON(props.sourceId);\n this.targetId = Id64.fromJSON(props.targetId);\n }\n\n /** @internal */\n public override toJSON(): RelationshipProps {\n const val = super.toJSON() as RelationshipProps;\n val.sourceId = this.sourceId;\n val.targetId = this.targetId;\n return val;\n }\n\n /**\n * Callback invoked by saveChanges on an ElementDrivesElement relationship when its input has changed or is the output of some upstream relationship whose input has changed.\n * This callback is invoked after the input element has been processed by upstream relationships.\n * A subclass of ElementDrivesElement can re-implement this static method to take some action. onRootChanged may modify the output element only.\n * @param _props The ElementDrivesElement relationship instance.\n * @param _iModel The iModel\n */\n public static onRootChanged(_props: RelationshipProps, _iModel: IModelDb): void { }\n\n /**\n * Callback invoked by saveChanges on an ElementDrivesElement relationship when the relationship instance has been deleted.\n * A subclass of ElementDrivesElement can re-implement this static method to take some action.\n * @param _props The deleted ElementDrivesElement relationship instance.\n * @param _iModel The iModel\n */\n public static onDeletedDependency(_props: RelationshipProps, _iModel: IModelDb): void { }\n\n /** Insert this Relationship into the iModel. */\n public insert(): Id64String { return this.iModel.relationships.insertInstance(this); }\n /** Update this Relationship in the iModel. */\n public update() { this.iModel.relationships.updateInstance(this); }\n /** Delete this Relationship from the iModel. */\n public delete() { this.iModel.relationships.deleteInstance(this); }\n\n public static getInstance<T extends Relationship>(iModel: IModelDb, criteria: Id64String | SourceAndTarget): T { return iModel.relationships.getInstance(this.classFullName, criteria); }\n}\n\n/** A Relationship where one Element refers to another Element\n * @public\n */\nexport class ElementRefersToElements extends Relationship {\n /** @internal */\n public static override get className(): string { return \"ElementRefersToElements\"; }\n /** Create an instance of the Relationship.\n * @param iModel The iModel that will contain the relationship\n * @param sourceId The sourceId of the relationship, that is, the driver element\n * @param targetId The targetId of the relationship, that is, the driven element\n * @return an instance of the specified class.\n */\n public static create<T extends ElementRefersToElements>(iModel: IModelDb, sourceId: Id64String, targetId: Id64String): T {\n return iModel.relationships.createInstance({ sourceId, targetId, classFullName: this.classFullName }) as T;\n }\n /** Insert a new instance of the Relationship.\n * @param iModel The iModel that will contain the relationship\n * @param sourceId The sourceId of the relationship, that is, the driver element\n * @param targetId The targetId of the relationship, that is, the driven element\n * @return The Id of the inserted Relationship.\n */\n public static insert<T extends ElementRefersToElements>(iModel: IModelDb, sourceId: Id64String, targetId: Id64String): Id64String {\n const relationship: T = this.create(iModel, sourceId, targetId);\n return iModel.relationships.insertInstance(relationship);\n }\n}\n\n/** Relates a [[DrawingGraphic]] to the [[Element]] that it represents\n * @public\n */\nexport class DrawingGraphicRepresentsElement extends ElementRefersToElements {\n /** @internal */\n public static override get className(): string { return \"DrawingGraphicRepresentsElement\"; }\n}\n\n/** Relates a [[GraphicalElement3d]] to the [[Element]] that it represents\n * @public\n */\nexport class GraphicalElement3dRepresentsElement extends ElementRefersToElements {\n /** @internal */\n public static override get className(): string { return \"GraphicalElement3dRepresentsElement\"; }\n}\n\n/** Relates a [[SynchronizationConfigLink]] to N [[ExternalSource]] instances.\n * Each relationship instance represents an external source processed by the synchronization configuration.\n * @note The associated ECClass was added to the BisCore schema in version 1.0.13\n * @beta\n */\nexport class SynchronizationConfigProcessesSources extends ElementRefersToElements {\n /** @internal */\n public static override get className(): string { return \"SynchronizationConfigProcessesSources\"; }\n}\n\n/** Relates a [[SynchronizationConfigLink]] to *root* [[ExternalSource]] instances.\n * @note The associated ECClass was added to the BisCore schema in version 1.0.13\n * @beta\n */\nexport class SynchronizationConfigSpecifiesRootSources extends SynchronizationConfigProcessesSources {\n /** @internal */\n public static override get className(): string { return \"SynchronizationConfigSpecifiesRootSources\"; }\n}\n\n/** Properties that are common to all types of link table ECRelationships\n * @public\n */\nexport interface ElementGroupsMembersProps extends RelationshipProps {\n memberPriority: number;\n}\n\n/** An ElementRefersToElements relationship where one Element *groups* a set of other Elements.\n * @public\n */\nexport class ElementGroupsMembers extends ElementRefersToElements {\n /** @internal */\n public static override get className(): string { return \"ElementGroupsMembers\"; }\n public memberPriority: number;\n\n constructor(props: ElementGroupsMembersProps, iModel: IModelDb) {\n super(props, iModel);\n this.memberPriority = props.memberPriority;\n }\n\n public static override create<T extends ElementRefersToElements>(iModel: IModelDb, sourceId: Id64String, targetId: Id64String, memberPriority: number = 0): T {\n const props: ElementGroupsMembersProps = { sourceId, targetId, memberPriority, classFullName: this.classFullName };\n return iModel.relationships.createInstance(props) as T;\n }\n}\n\n/** Relates a [[DefinitionGroup]] to its [[DefinitionElement]] members.\n * @note The associated ECClass was added to the BisCore schema in version 1.0.10\n * @public\n */\nexport class DefinitionGroupGroupsDefinitions extends ElementGroupsMembers {\n /** @internal */\n public static override get className(): string { return \"DefinitionGroupGroupsDefinitions\"; }\n}\n\n/** Represents group membership where the group Element (and its properties) impart information about the member Elements above mere membership.\n * Implies that properties of the group should be considered as properties of its members.\n * @note The associated ECClass was added to the BisCore schema in version 1.0.11\n * @public\n */\nexport class GroupImpartsToMembers extends ElementGroupsMembers {\n /** @internal */\n public static override get className(): string { return \"GroupImpartsToMembers\"; }\n}\n\n/** Relates an [[ExternalSourceGroup]] to its [[ExternalSource]] members.\n * @note The associated ECClass was added to the BisCore schema in version 1.0.13\n * @beta\n */\nexport class ExternalSourceGroupGroupsSources extends ElementGroupsMembers {\n /** @internal */\n public static override get className(): string { return \"ExternalSourceGroupGroupsSources\"; }\n}\n\n/** Properties that are common to all types of ElementDrivesElements\n * @beta\n */\nexport interface ElementDrivesElementProps extends RelationshipProps {\n status: number;\n priority: number;\n}\n\n/** A Relationship indicating that one Element *drives* another Element.\n * An ElementDrivesElement relationship defines a one-way \"driving\" relationship from the source to the target.\n * When the source of an ElementDrivesElement relationship changes, the ElementDrivesElement itself can get a callback, and both the source and target elements can get callbacks.\n * By inserting ElementDrivesElement relationships, an app can create and store an acyclic directed graph of dependencies between elements.\n *\n * # Defining dependencies\n * Create an ElementDrivesElement relationship to specify that the source element drives the target element.\n * For example, to specify that element e1 drives element e2, create a relationship between them like this:\n * ```ts\n * const ede = ElementDrivesElement.create(iModel, e1id, e2id);\n * ede.insert();\n * ```\n * This creates a persistent relationship. The fact that e1 drives e2 is persisted in the iModel.\n *\n * # Defining dependency graphs\n * When you create multiple ElementDrivesElement relationships, you create a network of dependencies. The target of one may be the source of another.\n * A change in the content of an DgnElement can therefore trigger changes to many downstream elements.\n *\n * For example, to make element e1 drive element e2 and e2 drive another element, e3, create two relationships like this:\n * ```ts\n * const ede12 = ElementDrivesElement.create(iModel, e1id, e2id);\n * const ede23 = ElementDrivesElement.create(iModel, e2id, e3id);\n * ede12.insert();\n * ede23.insert();\n * ```\n * Those two relationships create this graph:\n * ```\n * e1 --> e2 --> e3\n * ```\n * Where the \"-->\" is meant to represent a driving relationship.\n *\n * The order in which you create the relationships does not matter.\n * The graph indicates that e3 depends on e2 and e2 depends on e1.\n *\n * An ElementDrivesElement relationship is between one source element and one target element.\n * Many ElementDrivesElement relationships can point to a given element, and many can point out of it.\n * Thus, you can define many:many relationships.\n * For example:\n * ```ts\n * const ede12 = ElementDrivesElement.create(iModel, e1id, e2id);\n * const ede112 = ElementDrivesElement.create(iModel, e11id, e2id);\n * const ede23 = ElementDrivesElement.create(iModel, e2id, e3id);\n * const ede231 = ElementDrivesElement.create(iModel, e2id, e31id);\n * ede12.insert();\n * ede112.insert();\n * ede23.insert();\n * ede231.insert();\n * ```\n * Creates this graph:\n * ```\n * e1 e3\n * \\ /\n * e2\n * / \\\n * e11 e31\n * ```\n * e2 depends on both e1 and e11. e2 then drives e3 and e31.\n *\n * In an ElementDrivesElement dependency graph, the relationships are the \"edges\" and the Elements are the \"nodes\".\n * The following terms are used when referring to the elements (nodes) in a dependency graph:\n * * Inputs - The sources of all edges that point to the element. This includes all upstream elements that flow into the element.\n * * Outputs - The targets of all edges that point out of the element. This includes all downstream elements.\n *\n * #Subgraph Processing\n * When changes are made, iModel.js finds and processes only the part of the overall graph that is affected. So, for example,\n * suppose we have this graph:\n * ```\n * e1 --> e2 --> e3\n * ```\n * If e1 changes, then the subgraph to be processed is equal to the full graph, as shown.\n *\n * If only e2 changes, then the subgraph to be processed is just:\n * ```\n * e2 --> e3\n * ```\n * If only e3 changes, then the subgraph consists of e3 by itself.\n *\n * Returning to the second example above, suppose we have this graph:\n * ```\n * e1 e3\n * \\ /\n * e2\n * / \\\n * e11 e31\n * ```\n * If e1 is changed, the affected subgraph is:\n * ```\n * e1 e3\n * \\ /\n * e2\n * \\\n * e31\n * ```\n * If e2 is changed, the affected subgraph is:\n * ```\n * e3\n * /\n * e2\n * \\\n * e31\n * ```\n * # Callbacks\n * Once iModel.js has found the affected subgraph to process, it propagates changes through it by making callbacks.\n * Classes for both elements (nodes) and ElementDrivesElements relationships (edges) can receive callbacks.\n *\n * ## ElementDrivesElement Callbacks\n * The following callbacks are invoked on ElementDrivesElement relationship classes (edges):\n * * onRootChanged\n * * onDeletedDependency\n *\n * Note that these are static methods. Their default implementations do nothing.\n * To receive and act on these callbacks, a domain should define a subclass of ElementDrivesElement and use that to create relationships.\n * The subclass should then implement the callbacks that it would like to act on.\n *\n * A ElementDrivesElement subclass callback is expected to make changes to the output element only!\n *\n * ## Element Callbacks\n * The following callbacks are invoked on Element classes (nodes):\n * * Element.onBeforeOutputsHandled\n * * Element.onAllInputsHandled\n *\n * ## Order\n * Callbacks are invoked by BriefcaseDb.saveChanges.\n * They are invoked in dependency (topological) order: driving elements first, then driven elements.\n *\n * Each callback is invoked only once. No matter how many times a given element was changed during the transaction,\n * a callback such as ElementDrivesElement.onRootChanged will be invoked only once.\n * In the same way, no matter how many of its inputs were changed, a callback such as Element.onAllInputsHandled will be\n * invoked only once.\n *\n * For example, suppose we have a graph:\n * ```\n * e1 --> e2 --> e3\n * ```\n *\n * Suppose that e1 is directly modified. No callbacks are made at that time.\n * Later, when BriefcaseDb.saveChanges is called, the following callbacks are made, in order:\n * 1. Element.onBeforeOutputsHandled e1\n * 1. ElementDrivesElement.onRootChanged e1->e2\n * 1. Element.onAllInputsHandled e2\n * 1. ElementDrivesElement.onRootChanged e2->e3\n * 1. Element.onAllInputsHandled e3\n *\n * Suppose that e3 is modified directly and BriefcaseDb.saveChanges is called.\n * Since no input to a relationship was changed, the sub-graph will be empty, and no callbacks will be made.\n *\n * Returning to the second example above, suppose we have this graph:\n * ```\n * e1 e3\n * \\ /\n * e2\n * / \\\n * e11 e31\n * ```\n * If e1 is changed and BriefcaseDb.saveChanges is called, the subgraph is:\n * ```\n * e1 e3\n * \\ /\n * e2\n * \\\n * e31\n * ```\n * The callbacks are:\n * 1. Element.onBeforeOutputsHandled e1\n * 1. ElementDrivesElement.onRootChanged e1->e2\n * 1. Element.onAllInputsHandled e2\n * 1. ElementDrivesElement.onRootChanged e2->e3\n * 1. Element.onAllInputsHandled e3\n * 1. ElementDrivesElement.onRootChanged e2->e31\n * 1. Element.onAllInputsHandled e31\n *\n * (The ElementDrivesElement.)\n *\n * #Errors\n * Circular dependencies are not permitted. If a cycle is detected, that is treated as a fatal error. All ElementDrivesElement relationships\n * involved in a cycle will have their status set to 1, indicating a failure.\n *\n * A callback may call txnManager.reportError to reject an invalid change. It can classify the error as fatal or just a warning.\n * A callback make set the status value of an ElementDrivesElement instance to 1 to indicate a processing falure in that edge.\n *\n * After BriefcaseDb.saveChanges is called, an app should check db.txns.validationErrors and db.txns.hasFatalError to find out if graph-evaluation failed.\n *\n * @beta\n */\nexport class ElementDrivesElement extends Relationship implements ElementDrivesElementProps {\n /** @internal */\n public static override get className(): string { return \"ElementDrivesElement\"; }\n /** Relationship status\n * * 0 indicates no errors. iModel.js sets this after a successful evaluation.\n * * 1 indicates that this driving relationship could not be evaluated. The callback itself can set this to indicate that it failed to process the input changes. Also, iModel.js sets this if it finds that the relationship is part of a circular dependency.\n * * 0x80 The app or callback can set this to tell iModel.js not propagate changes through this relationship.\n */\n public status: number;\n /** Affects the order in which relationships are processed in the case where two relationships have the same output. */\n public priority: number;\n\n /** @internal */\n constructor(props: ElementDrivesElementProps, iModel: IModelDb) {\n super(props, iModel);\n this.status = props.status;\n this.priority = props.priority;\n }\n\n public static create<T extends ElementRefersToElements>(iModel: IModelDb, sourceId: Id64String, targetId: Id64String, priority: number = 0): T {\n const props: ElementDrivesElementProps = { sourceId, targetId, priority, status: 0, classFullName: this.classFullName };\n return iModel.relationships.createInstance(props) as T;\n }\n}\n\n/** Manages [[Relationship]]s.\n * @public\n */\nexport class Relationships {\n private _iModel: IModelDb;\n\n /** @internal */\n constructor(iModel: IModelDb) { this._iModel = iModel; }\n\n /** Create a new instance of a Relationship.\n * @param props The properties of the new Relationship.\n * @throws [[IModelError]] if there is a problem creating the Relationship.\n */\n public createInstance(props: RelationshipProps): Relationship { return this._iModel.constructEntity<Relationship>(props); }\n\n /** Check classFullName to ensure it is a link table relationship class. */\n private checkRelationshipClass(classFullName: string) {\n if (!this._iModel.nativeDb.isLinkTableRelationship(classFullName.replace(\".\", \":\"))) {\n throw new IModelError(DbResult.BE_SQLITE_ERROR, `Class '${classFullName}' must be a relationship class and it should be subclass of BisCore:ElementRefersToElements or BisCore:ElementDrivesElement.`);\n }\n }\n\n /** Insert a new relationship instance into the iModel. The relationship provided must be subclass of BisCore:ElementRefersToElements or BisCore:ElementDrivesElement.\n * @param props The properties of the new relationship.\n * @returns The Id of the newly inserted relationship.\n * @note The id property of the props object is set as a side effect of this function.\n */\n public insertInstance(props: RelationshipProps): Id64String {\n this.checkRelationshipClass(props.classFullName);\n return props.id = this._iModel.nativeDb.insertLinkTableRelationship(props);\n }\n\n /** Update the properties of an existing relationship instance in the iModel.\n * @param props the properties of the relationship instance to update. Any properties that are not present will be left unchanged.\n */\n public updateInstance(props: RelationshipProps): void {\n this._iModel.nativeDb.updateLinkTableRelationship(props);\n }\n\n /** Delete an Relationship instance from this iModel. */\n public deleteInstance(props: RelationshipProps): void {\n this._iModel.nativeDb.deleteLinkTableRelationship(props);\n }\n\n /** Get the props of a Relationship instance\n * @param relClassFullName The full class name of the relationship in the form of \"schema:class\"\n * @param criteria Either the relationship instanceId or the source and target Ids\n * @throws [IModelError]($common) if the relationship is not found or cannot be loaded.\n * @see tryGetInstanceProps\n */\n public getInstanceProps<T extends RelationshipProps>(relClassFullName: string, criteria: Id64String | SourceAndTarget): T {\n const relationshipProps = this.tryGetInstanceProps<T>(relClassFullName, criteria);\n if (undefined === relationshipProps) {\n throw new IModelError(IModelStatus.NotFound, \"Relationship not found\");\n }\n return relationshipProps;\n }\n\n /** Get the props of a Relationship instance\n * @param relClassFullName The full class name of the relationship in the form of \"schema:class\"\n * @param criteria Either the relationship instanceId or the source and target Ids\n * @returns The RelationshipProps or `undefined` if the relationship is not found.\n * @note Useful for cases when a relationship may or may not exist and throwing an `Error` would be overkill.\n * @see getInstanceProps\n */\n public tryGetInstanceProps<T extends RelationshipProps>(relClassFullName: string, criteria: Id64String | SourceAndTarget): T | undefined {\n let props: T | undefined;\n if (typeof criteria === \"string\") {\n props = this._iModel.withPreparedStatement(`SELECT * FROM ${relClassFullName} WHERE ecinstanceid=?`, (stmt: ECSqlStatement) => {\n stmt.bindId(1, criteria);\n return DbResult.BE_SQLITE_ROW === stmt.step() ? stmt.getRow() as T : undefined;\n });\n } else {\n props = this._iModel.withPreparedStatement(`SELECT * FROM ${relClassFullName} WHERE SourceECInstanceId=? AND TargetECInstanceId=?`, (stmt: ECSqlStatement) => {\n stmt.bindId(1, criteria.sourceId);\n stmt.bindId(2, criteria.targetId);\n return DbResult.BE_SQLITE_ROW === stmt.step() ? stmt.getRow() as T : undefined;\n });\n }\n if (undefined !== props) {\n props.classFullName = (props as any).className.replace(\".\", \":\");\n }\n return props;\n }\n\n /** Get a Relationship instance\n * @param relClassFullName The full class name of the relationship in the form of \"schema:class\"\n * @param criteria Either the relationship instanceId or the source and target Ids\n * @throws [IModelError]($common) if the relationship is not found or cannot be loaded.\n * @see tryGetInstance\n */\n public getInstance<T extends Relationship>(relClassSqlName: string, criteria: Id64String | SourceAndTarget): T {\n return this._iModel.constructEntity<T>(this.getInstanceProps(relClassSqlName, criteria));\n }\n\n /** Get a Relationship instance\n * @param relClassFullName The full class name of the relationship in the form of \"schema:class\"\n * @param criteria Either the relationship instanceId or the source and target Ids\n * @returns The relationship or `undefined` if the relationship is not found.\n * @note Useful for cases when a relationship may or may not exist and throwing an `Error` would be overkill.\n * @see getInstance\n */\n public tryGetInstance<T extends Relationship>(relClassFullName: string, criteria: Id64String | SourceAndTarget): T | undefined {\n const relationshipProps = this.tryGetInstanceProps<T>(relClassFullName, criteria);\n return undefined !== relationshipProps ? this._iModel.constructEntity<T>(relationshipProps) : undefined;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Relationship.js","sourceRoot":"","sources":["../../src/Relationship.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAiE;AACjE,oDAAmG;AAEnG,qCAAkC;AAKlC;;GAEG;AACH,MAAa,YAAa,SAAQ,eAAM;IAMtC,gBAAgB;IAChB,YAAY,KA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B,gBAAgB,sDAAsD,EAAE,CAAC,IAAoB,EAAE,EAAE;gBAC3J,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;gBAClC,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;gBAClC,OAAO,uBAAQ,CAAC,aAAa,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,EAAO,CAAC,CAAC,CAAC,SAAS,CAAC;YACjF,CAAC,CAAC,CAAC;SACJ;QACD,IAAI,SAAS,KAAK,KAAK,EAAE;YACvB,KAAK,CAAC,aAAa,GAAI,KAAa,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;SAClE;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;;OAKG;IACI,WAAW,CAAyB,eAAuB,EAAE,QAAsC;QACxG,OAAO,IAAI,CAAC,OAAO,CAAC,eAAe,CAAI,IAAI,CAAC,gBAAgB,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC3F,CAAC;IAED;;;;;;OAMG;IACI,cAAc,CAAyB,gBAAwB,EAAE,QAAsC;QAC5G,MAAM,iBAAiB,GAAG,IAAI,CAAC,mBAAmB,CAAI,gBAAgB,EAAE,QAAQ,CAAC,CAAC;QAClF,OAAO,SAAS,KAAK,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,eAAe,CAAI,iBAAiB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC1G,CAAC;CACF;AAvGD,sCAuGC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Relationships\r\n */\r\n\r\nimport { DbResult, Id64, Id64String } from \"@itwin/core-bentley\";\r\nimport { IModelError, IModelStatus, RelationshipProps, SourceAndTarget } from \"@itwin/core-common\";\r\nimport { ECSqlStatement } from \"./ECSqlStatement\";\r\nimport { Entity } from \"./Entity\";\r\nimport { IModelDb } from \"./IModelDb\";\r\n\r\nexport type { SourceAndTarget, RelationshipProps } from \"@itwin/core-common\"; // for backwards compatibility\r\n\r\n/** Base class for all link table ECRelationships\r\n * @public\r\n */\r\nexport class Relationship extends Entity implements RelationshipProps {\r\n /** @internal */\r\n public static override get className(): string { return \"Relationship\"; }\r\n public readonly sourceId: Id64String;\r\n public readonly targetId: Id64String;\r\n\r\n /** @internal */\r\n constructor(props: RelationshipProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n this.sourceId = Id64.fromJSON(props.sourceId);\r\n this.targetId = Id64.fromJSON(props.targetId);\r\n }\r\n\r\n /** @internal */\r\n public override toJSON(): RelationshipProps {\r\n const val = super.toJSON() as RelationshipProps;\r\n val.sourceId = this.sourceId;\r\n val.targetId = this.targetId;\r\n return val;\r\n }\r\n\r\n /**\r\n * Callback invoked by saveChanges on an ElementDrivesElement relationship when its input has changed or is the output of some upstream relationship whose input has changed.\r\n * This callback is invoked after the input element has been processed by upstream relationships.\r\n * A subclass of ElementDrivesElement can re-implement this static method to take some action. onRootChanged may modify the output element only.\r\n * @param _props The ElementDrivesElement relationship instance.\r\n * @param _iModel The iModel\r\n */\r\n public static onRootChanged(_props: RelationshipProps, _iModel: IModelDb): void { }\r\n\r\n /**\r\n * Callback invoked by saveChanges on an ElementDrivesElement relationship when the relationship instance has been deleted.\r\n * A subclass of ElementDrivesElement can re-implement this static method to take some action.\r\n * @param _props The deleted ElementDrivesElement relationship instance.\r\n * @param _iModel The iModel\r\n */\r\n public static onDeletedDependency(_props: RelationshipProps, _iModel: IModelDb): void { }\r\n\r\n /** Insert this Relationship into the iModel. */\r\n public insert(): Id64String { return this.iModel.relationships.insertInstance(this); }\r\n /** Update this Relationship in the iModel. */\r\n public update() { this.iModel.relationships.updateInstance(this); }\r\n /** Delete this Relationship from the iModel. */\r\n public delete() { this.iModel.relationships.deleteInstance(this); }\r\n\r\n public static getInstance<T extends Relationship>(iModel: IModelDb, criteria: Id64String | SourceAndTarget): T { return iModel.relationships.getInstance(this.classFullName, criteria); }\r\n}\r\n\r\n/** A Relationship where one Element refers to another Element\r\n * @public\r\n */\r\nexport class ElementRefersToElements extends Relationship {\r\n /** @internal */\r\n public static override get className(): string { return \"ElementRefersToElements\"; }\r\n /** Create an instance of the Relationship.\r\n * @param iModel The iModel that will contain the relationship\r\n * @param sourceId The sourceId of the relationship, that is, the driver element\r\n * @param targetId The targetId of the relationship, that is, the driven element\r\n * @return an instance of the specified class.\r\n */\r\n public static create<T extends ElementRefersToElements>(iModel: IModelDb, sourceId: Id64String, targetId: Id64String): T {\r\n return iModel.relationships.createInstance({ sourceId, targetId, classFullName: this.classFullName }) as T;\r\n }\r\n /** Insert a new instance of the Relationship.\r\n * @param iModel The iModel that will contain the relationship\r\n * @param sourceId The sourceId of the relationship, that is, the driver element\r\n * @param targetId The targetId of the relationship, that is, the driven element\r\n * @return The Id of the inserted Relationship.\r\n */\r\n public static insert<T extends ElementRefersToElements>(iModel: IModelDb, sourceId: Id64String, targetId: Id64String): Id64String {\r\n const relationship: T = this.create(iModel, sourceId, targetId);\r\n return iModel.relationships.insertInstance(relationship);\r\n }\r\n}\r\n\r\n/** Relates a [[DrawingGraphic]] to the [[Element]] that it represents\r\n * @public\r\n */\r\nexport class DrawingGraphicRepresentsElement extends ElementRefersToElements {\r\n /** @internal */\r\n public static override get className(): string { return \"DrawingGraphicRepresentsElement\"; }\r\n}\r\n\r\n/** Relates a [[GraphicalElement3d]] to the [[Element]] that it represents\r\n * @public\r\n */\r\nexport class GraphicalElement3dRepresentsElement extends ElementRefersToElements {\r\n /** @internal */\r\n public static override get className(): string { return \"GraphicalElement3dRepresentsElement\"; }\r\n}\r\n\r\n/** Relates a [[SynchronizationConfigLink]] to N [[ExternalSource]] instances.\r\n * Each relationship instance represents an external source processed by the synchronization configuration.\r\n * @note The associated ECClass was added to the BisCore schema in version 1.0.13\r\n * @beta\r\n */\r\nexport class SynchronizationConfigProcessesSources extends ElementRefersToElements {\r\n /** @internal */\r\n public static override get className(): string { return \"SynchronizationConfigProcessesSources\"; }\r\n}\r\n\r\n/** Relates a [[SynchronizationConfigLink]] to *root* [[ExternalSource]] instances.\r\n * @note The associated ECClass was added to the BisCore schema in version 1.0.13\r\n * @beta\r\n */\r\nexport class SynchronizationConfigSpecifiesRootSources extends SynchronizationConfigProcessesSources {\r\n /** @internal */\r\n public static override get className(): string { return \"SynchronizationConfigSpecifiesRootSources\"; }\r\n}\r\n\r\n/** Properties that are common to all types of link table ECRelationships\r\n * @public\r\n */\r\nexport interface ElementGroupsMembersProps extends RelationshipProps {\r\n memberPriority: number;\r\n}\r\n\r\n/** An ElementRefersToElements relationship where one Element *groups* a set of other Elements.\r\n * @public\r\n */\r\nexport class ElementGroupsMembers extends ElementRefersToElements {\r\n /** @internal */\r\n public static override get className(): string { return \"ElementGroupsMembers\"; }\r\n public memberPriority: number;\r\n\r\n constructor(props: ElementGroupsMembersProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n this.memberPriority = props.memberPriority;\r\n }\r\n\r\n public static override create<T extends ElementRefersToElements>(iModel: IModelDb, sourceId: Id64String, targetId: Id64String, memberPriority: number = 0): T {\r\n const props: ElementGroupsMembersProps = { sourceId, targetId, memberPriority, classFullName: this.classFullName };\r\n return iModel.relationships.createInstance(props) as T;\r\n }\r\n}\r\n\r\n/** Relates a [[DefinitionGroup]] to its [[DefinitionElement]] members.\r\n * @note The associated ECClass was added to the BisCore schema in version 1.0.10\r\n * @public\r\n */\r\nexport class DefinitionGroupGroupsDefinitions extends ElementGroupsMembers {\r\n /** @internal */\r\n public static override get className(): string { return \"DefinitionGroupGroupsDefinitions\"; }\r\n}\r\n\r\n/** Represents group membership where the group Element (and its properties) impart information about the member Elements above mere membership.\r\n * Implies that properties of the group should be considered as properties of its members.\r\n * @note The associated ECClass was added to the BisCore schema in version 1.0.11\r\n * @public\r\n */\r\nexport class GroupImpartsToMembers extends ElementGroupsMembers {\r\n /** @internal */\r\n public static override get className(): string { return \"GroupImpartsToMembers\"; }\r\n}\r\n\r\n/** Relates an [[ExternalSourceGroup]] to its [[ExternalSource]] members.\r\n * @note The associated ECClass was added to the BisCore schema in version 1.0.13\r\n * @beta\r\n */\r\nexport class ExternalSourceGroupGroupsSources extends ElementGroupsMembers {\r\n /** @internal */\r\n public static override get className(): string { return \"ExternalSourceGroupGroupsSources\"; }\r\n}\r\n\r\n/** Properties that are common to all types of ElementDrivesElements\r\n * @beta\r\n */\r\nexport interface ElementDrivesElementProps extends RelationshipProps {\r\n status: number;\r\n priority: number;\r\n}\r\n\r\n/** A Relationship indicating that one Element *drives* another Element.\r\n * An ElementDrivesElement relationship defines a one-way \"driving\" relationship from the source to the target.\r\n * When the source of an ElementDrivesElement relationship changes, the ElementDrivesElement itself can get a callback, and both the source and target elements can get callbacks.\r\n * By inserting ElementDrivesElement relationships, an app can create and store an acyclic directed graph of dependencies between elements.\r\n *\r\n * # Defining dependencies\r\n * Create an ElementDrivesElement relationship to specify that the source element drives the target element.\r\n * For example, to specify that element e1 drives element e2, create a relationship between them like this:\r\n * ```ts\r\n * const ede = ElementDrivesElement.create(iModel, e1id, e2id);\r\n * ede.insert();\r\n * ```\r\n * This creates a persistent relationship. The fact that e1 drives e2 is persisted in the iModel.\r\n *\r\n * # Defining dependency graphs\r\n * When you create multiple ElementDrivesElement relationships, you create a network of dependencies. The target of one may be the source of another.\r\n * A change in the content of an DgnElement can therefore trigger changes to many downstream elements.\r\n *\r\n * For example, to make element e1 drive element e2 and e2 drive another element, e3, create two relationships like this:\r\n * ```ts\r\n * const ede12 = ElementDrivesElement.create(iModel, e1id, e2id);\r\n * const ede23 = ElementDrivesElement.create(iModel, e2id, e3id);\r\n * ede12.insert();\r\n * ede23.insert();\r\n * ```\r\n * Those two relationships create this graph:\r\n * ```\r\n * e1 --> e2 --> e3\r\n * ```\r\n * Where the \"-->\" is meant to represent a driving relationship.\r\n *\r\n * The order in which you create the relationships does not matter.\r\n * The graph indicates that e3 depends on e2 and e2 depends on e1.\r\n *\r\n * An ElementDrivesElement relationship is between one source element and one target element.\r\n * Many ElementDrivesElement relationships can point to a given element, and many can point out of it.\r\n * Thus, you can define many:many relationships.\r\n * For example:\r\n * ```ts\r\n * const ede12 = ElementDrivesElement.create(iModel, e1id, e2id);\r\n * const ede112 = ElementDrivesElement.create(iModel, e11id, e2id);\r\n * const ede23 = ElementDrivesElement.create(iModel, e2id, e3id);\r\n * const ede231 = ElementDrivesElement.create(iModel, e2id, e31id);\r\n * ede12.insert();\r\n * ede112.insert();\r\n * ede23.insert();\r\n * ede231.insert();\r\n * ```\r\n * Creates this graph:\r\n * ```\r\n * e1 e3\r\n * \\ /\r\n * e2\r\n * / \\\r\n * e11 e31\r\n * ```\r\n * e2 depends on both e1 and e11. e2 then drives e3 and e31.\r\n *\r\n * In an ElementDrivesElement dependency graph, the relationships are the \"edges\" and the Elements are the \"nodes\".\r\n * The following terms are used when referring to the elements (nodes) in a dependency graph:\r\n * * Inputs - The sources of all edges that point to the element. This includes all upstream elements that flow into the element.\r\n * * Outputs - The targets of all edges that point out of the element. This includes all downstream elements.\r\n *\r\n * #Subgraph Processing\r\n * When changes are made, iModel.js finds and processes only the part of the overall graph that is affected. So, for example,\r\n * suppose we have this graph:\r\n * ```\r\n * e1 --> e2 --> e3\r\n * ```\r\n * If e1 changes, then the subgraph to be processed is equal to the full graph, as shown.\r\n *\r\n * If only e2 changes, then the subgraph to be processed is just:\r\n * ```\r\n * e2 --> e3\r\n * ```\r\n * If only e3 changes, then the subgraph consists of e3 by itself.\r\n *\r\n * Returning to the second example above, suppose we have this graph:\r\n * ```\r\n * e1 e3\r\n * \\ /\r\n * e2\r\n * / \\\r\n * e11 e31\r\n * ```\r\n * If e1 is changed, the affected subgraph is:\r\n * ```\r\n * e1 e3\r\n * \\ /\r\n * e2\r\n * \\\r\n * e31\r\n * ```\r\n * If e2 is changed, the affected subgraph is:\r\n * ```\r\n * e3\r\n * /\r\n * e2\r\n * \\\r\n * e31\r\n * ```\r\n * # Callbacks\r\n * Once iModel.js has found the affected subgraph to process, it propagates changes through it by making callbacks.\r\n * Classes for both elements (nodes) and ElementDrivesElements relationships (edges) can receive callbacks.\r\n *\r\n * ## ElementDrivesElement Callbacks\r\n * The following callbacks are invoked on ElementDrivesElement relationship classes (edges):\r\n * * onRootChanged\r\n * * onDeletedDependency\r\n *\r\n * Note that these are static methods. Their default implementations do nothing.\r\n * To receive and act on these callbacks, a domain should define a subclass of ElementDrivesElement and use that to create relationships.\r\n * The subclass should then implement the callbacks that it would like to act on.\r\n *\r\n * A ElementDrivesElement subclass callback is expected to make changes to the output element only!\r\n *\r\n * ## Element Callbacks\r\n * The following callbacks are invoked on Element classes (nodes):\r\n * * Element.onBeforeOutputsHandled\r\n * * Element.onAllInputsHandled\r\n *\r\n * ## Order\r\n * Callbacks are invoked by BriefcaseDb.saveChanges.\r\n * They are invoked in dependency (topological) order: driving elements first, then driven elements.\r\n *\r\n * Each callback is invoked only once. No matter how many times a given element was changed during the transaction,\r\n * a callback such as ElementDrivesElement.onRootChanged will be invoked only once.\r\n * In the same way, no matter how many of its inputs were changed, a callback such as Element.onAllInputsHandled will be\r\n * invoked only once.\r\n *\r\n * For example, suppose we have a graph:\r\n * ```\r\n * e1 --> e2 --> e3\r\n * ```\r\n *\r\n * Suppose that e1 is directly modified. No callbacks are made at that time.\r\n * Later, when BriefcaseDb.saveChanges is called, the following callbacks are made, in order:\r\n * 1. Element.onBeforeOutputsHandled e1\r\n * 1. ElementDrivesElement.onRootChanged e1->e2\r\n * 1. Element.onAllInputsHandled e2\r\n * 1. ElementDrivesElement.onRootChanged e2->e3\r\n * 1. Element.onAllInputsHandled e3\r\n *\r\n * Suppose that e3 is modified directly and BriefcaseDb.saveChanges is called.\r\n * Since no input to a relationship was changed, the sub-graph will be empty, and no callbacks will be made.\r\n *\r\n * Returning to the second example above, suppose we have this graph:\r\n * ```\r\n * e1 e3\r\n * \\ /\r\n * e2\r\n * / \\\r\n * e11 e31\r\n * ```\r\n * If e1 is changed and BriefcaseDb.saveChanges is called, the subgraph is:\r\n * ```\r\n * e1 e3\r\n * \\ /\r\n * e2\r\n * \\\r\n * e31\r\n * ```\r\n * The callbacks are:\r\n * 1. Element.onBeforeOutputsHandled e1\r\n * 1. ElementDrivesElement.onRootChanged e1->e2\r\n * 1. Element.onAllInputsHandled e2\r\n * 1. ElementDrivesElement.onRootChanged e2->e3\r\n * 1. Element.onAllInputsHandled e3\r\n * 1. ElementDrivesElement.onRootChanged e2->e31\r\n * 1. Element.onAllInputsHandled e31\r\n *\r\n * (The ElementDrivesElement.)\r\n *\r\n * #Errors\r\n * Circular dependencies are not permitted. If a cycle is detected, that is treated as a fatal error. All ElementDrivesElement relationships\r\n * involved in a cycle will have their status set to 1, indicating a failure.\r\n *\r\n * A callback may call txnManager.reportError to reject an invalid change. It can classify the error as fatal or just a warning.\r\n * A callback make set the status value of an ElementDrivesElement instance to 1 to indicate a processing falure in that edge.\r\n *\r\n * After BriefcaseDb.saveChanges is called, an app should check db.txns.validationErrors and db.txns.hasFatalError to find out if graph-evaluation failed.\r\n *\r\n * @beta\r\n */\r\nexport class ElementDrivesElement extends Relationship implements ElementDrivesElementProps {\r\n /** @internal */\r\n public static override get className(): string { return \"ElementDrivesElement\"; }\r\n /** Relationship status\r\n * * 0 indicates no errors. iModel.js sets this after a successful evaluation.\r\n * * 1 indicates that this driving relationship could not be evaluated. The callback itself can set this to indicate that it failed to process the input changes. Also, iModel.js sets this if it finds that the relationship is part of a circular dependency.\r\n * * 0x80 The app or callback can set this to tell iModel.js not propagate changes through this relationship.\r\n */\r\n public status: number;\r\n /** Affects the order in which relationships are processed in the case where two relationships have the same output. */\r\n public priority: number;\r\n\r\n /** @internal */\r\n constructor(props: ElementDrivesElementProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n this.status = props.status;\r\n this.priority = props.priority;\r\n }\r\n\r\n public static create<T extends ElementRefersToElements>(iModel: IModelDb, sourceId: Id64String, targetId: Id64String, priority: number = 0): T {\r\n const props: ElementDrivesElementProps = { sourceId, targetId, priority, status: 0, classFullName: this.classFullName };\r\n return iModel.relationships.createInstance(props) as T;\r\n }\r\n}\r\n\r\n/** Manages [[Relationship]]s.\r\n * @public\r\n */\r\nexport class Relationships {\r\n private _iModel: IModelDb;\r\n\r\n /** @internal */\r\n constructor(iModel: IModelDb) { this._iModel = iModel; }\r\n\r\n /** Create a new instance of a Relationship.\r\n * @param props The properties of the new Relationship.\r\n * @throws [[IModelError]] if there is a problem creating the Relationship.\r\n */\r\n public createInstance(props: RelationshipProps): Relationship { return this._iModel.constructEntity<Relationship>(props); }\r\n\r\n /** Check classFullName to ensure it is a link table relationship class. */\r\n private checkRelationshipClass(classFullName: string) {\r\n if (!this._iModel.nativeDb.isLinkTableRelationship(classFullName.replace(\".\", \":\"))) {\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, `Class '${classFullName}' must be a relationship class and it should be subclass of BisCore:ElementRefersToElements or BisCore:ElementDrivesElement.`);\r\n }\r\n }\r\n\r\n /** Insert a new relationship instance into the iModel. The relationship provided must be subclass of BisCore:ElementRefersToElements or BisCore:ElementDrivesElement.\r\n * @param props The properties of the new relationship.\r\n * @returns The Id of the newly inserted relationship.\r\n * @note The id property of the props object is set as a side effect of this function.\r\n */\r\n public insertInstance(props: RelationshipProps): Id64String {\r\n this.checkRelationshipClass(props.classFullName);\r\n return props.id = this._iModel.nativeDb.insertLinkTableRelationship(props);\r\n }\r\n\r\n /** Update the properties of an existing relationship instance in the iModel.\r\n * @param props the properties of the relationship instance to update. Any properties that are not present will be left unchanged.\r\n */\r\n public updateInstance(props: RelationshipProps): void {\r\n this._iModel.nativeDb.updateLinkTableRelationship(props);\r\n }\r\n\r\n /** Delete an Relationship instance from this iModel. */\r\n public deleteInstance(props: RelationshipProps): void {\r\n this._iModel.nativeDb.deleteLinkTableRelationship(props);\r\n }\r\n\r\n /** Get the props of a Relationship instance\r\n * @param relClassFullName The full class name of the relationship in the form of \"schema:class\"\r\n * @param criteria Either the relationship instanceId or the source and target Ids\r\n * @throws [IModelError]($common) if the relationship is not found or cannot be loaded.\r\n * @see tryGetInstanceProps\r\n */\r\n public getInstanceProps<T extends RelationshipProps>(relClassFullName: string, criteria: Id64String | SourceAndTarget): T {\r\n const relationshipProps = this.tryGetInstanceProps<T>(relClassFullName, criteria);\r\n if (undefined === relationshipProps) {\r\n throw new IModelError(IModelStatus.NotFound, \"Relationship not found\");\r\n }\r\n return relationshipProps;\r\n }\r\n\r\n /** Get the props of a Relationship instance\r\n * @param relClassFullName The full class name of the relationship in the form of \"schema:class\"\r\n * @param criteria Either the relationship instanceId or the source and target Ids\r\n * @returns The RelationshipProps or `undefined` if the relationship is not found.\r\n * @note Useful for cases when a relationship may or may not exist and throwing an `Error` would be overkill.\r\n * @see getInstanceProps\r\n */\r\n public tryGetInstanceProps<T extends RelationshipProps>(relClassFullName: string, criteria: Id64String | SourceAndTarget): T | undefined {\r\n let props: T | undefined;\r\n if (typeof criteria === \"string\") {\r\n props = this._iModel.withPreparedStatement(`SELECT * FROM ${relClassFullName} WHERE ecinstanceid=?`, (stmt: ECSqlStatement) => {\r\n stmt.bindId(1, criteria);\r\n return DbResult.BE_SQLITE_ROW === stmt.step() ? stmt.getRow() as T : undefined;\r\n });\r\n } else {\r\n props = this._iModel.withPreparedStatement(`SELECT * FROM ${relClassFullName} WHERE SourceECInstanceId=? AND TargetECInstanceId=?`, (stmt: ECSqlStatement) => {\r\n stmt.bindId(1, criteria.sourceId);\r\n stmt.bindId(2, criteria.targetId);\r\n return DbResult.BE_SQLITE_ROW === stmt.step() ? stmt.getRow() as T : undefined;\r\n });\r\n }\r\n if (undefined !== props) {\r\n props.classFullName = (props as any).className.replace(\".\", \":\");\r\n }\r\n return props;\r\n }\r\n\r\n /** Get a Relationship instance\r\n * @param relClassFullName The full class name of the relationship in the form of \"schema:class\"\r\n * @param criteria Either the relationship instanceId or the source and target Ids\r\n * @throws [IModelError]($common) if the relationship is not found or cannot be loaded.\r\n * @see tryGetInstance\r\n */\r\n public getInstance<T extends Relationship>(relClassSqlName: string, criteria: Id64String | SourceAndTarget): T {\r\n return this._iModel.constructEntity<T>(this.getInstanceProps(relClassSqlName, criteria));\r\n }\r\n\r\n /** Get a Relationship instance\r\n * @param relClassFullName The full class name of the relationship in the form of \"schema:class\"\r\n * @param criteria Either the relationship instanceId or the source and target Ids\r\n * @returns The relationship or `undefined` if the relationship is not found.\r\n * @note Useful for cases when a relationship may or may not exist and throwing an `Error` would be overkill.\r\n * @see getInstance\r\n */\r\n public tryGetInstance<T extends Relationship>(relClassFullName: string, criteria: Id64String | SourceAndTarget): T | undefined {\r\n const relationshipProps = this.tryGetInstanceProps<T>(relClassFullName, criteria);\r\n return undefined !== relationshipProps ? this._iModel.constructEntity<T>(relationshipProps) : undefined;\r\n }\r\n}\r\n"]}
|