Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private _createStandalone(): string {
const pathname: string = path.join(this._localIModelDbPath, this._iModelName + ".bim");
if (fs.existsSync(pathname))
fs.unlinkSync(pathname);
this._iModelDb = IModelDb.createStandalone(pathname, { rootSubject: { name: this._iModelName } });
const definitionModelId: Id64String = IModel.dictionaryId;
this._physicalModelId = PhysicalModel.insert(this._iModelDb, IModel.rootSubjectId, "TestModel");
this._codeSpecId = this._iModelDb.codeSpecs.insert("TestCodeSpec", CodeScopeSpec.Type.Model);
this._categoryId = SpatialCategory.insert(this._iModelDb, definitionModelId, "TestCategory", { color: new ColorDef("blanchedAlmond") });
// Insert a ViewDefinition for the PhysicalModel
const viewName = "Physical View";
const modelSelectorId: Id64String = ModelSelector.insert(this._iModelDb, definitionModelId, viewName, [this._physicalModelId]);
const categorySelectorId: Id64String = CategorySelector.insert(this._iModelDb, definitionModelId, viewName, [this._categoryId]);
const displayStyleId: Id64String = DisplayStyle3d.insert(this._iModelDb, definitionModelId, viewName);
const viewRange = new Range3d(0, 0, 0, 50, 50, 50);
OrthographicViewDefinition.insert(this._iModelDb, definitionModelId, viewName, modelSelectorId, categorySelectorId, displayStyleId, viewRange);
this._iModelDb.updateProjectExtents(new Range3d(-1000, -1000, -1000, 1000, 1000, 1000));
this._iModelDb.saveChanges("Setup new iModel");
this._iModelDb.closeStandalone();
this._iModelDb = undefined;
return pathname;
}
private _initializeLogger(): void {
geom: geometry,
};
this.iModelDb.elements.insertElement(props);
const displayStyleIds: Id64Array = [];
const names = [];
for (const analysisStyleProp of analysisStyleProps) {
let name = analysisStyleProp.scalarChannelName!;
if (undefined !== analysisStyleProp.displacementChannelName) {
const exaggeration = (analysisStyleProp.displacementScale === 1.0) ? "" : (" X " + analysisStyleProp.displacementScale);
name = modelName + ": " + name + " and " + analysisStyleProp.displacementChannelName + exaggeration;
}
names.push(name);
displayStyleIds.push(DisplayStyle3d.insert(this.iModelDb, this.definitionModelId, name, { viewFlags: vf, backgroundColor: bgColor, analysisStyle: analysisStyleProp }));
}
const modelSelectorId = ModelSelector.insert(this.iModelDb, this.definitionModelId, modelName, [modelId]);
const categorySelectorId = CategorySelector.insert(this.iModelDb, this.definitionModelId, modelName, [categoryId]);
DisplayStyle3d.insert(this.iModelDb, this.definitionModelId, modelName + ": No AuxData", { viewFlags: vf, backgroundColor: bgColor });
return OrthographicViewDefinition.insert(this.iModelDb, this.definitionModelId, modelName, modelSelectorId, categorySelectorId, displayStyleIds[0], polyface.range());
}
/** Import a polyface with auxillary data */
protected insertSpatialView(viewName: string, range: AxisAlignedBox3d, realityModels: ContextRealityModelProps[], geoLocated: boolean): Id64String {
const modelSelectorId: Id64String = ModelSelector.insert(this.iModelDb, this.definitionModelId, viewName, [this.physicalModelId]);
const categorySelectorId: Id64String = CategorySelector.insert(this.iModelDb, this.definitionModelId, viewName, []);
const vf = new ViewFlags();
vf.backgroundMap = geoLocated;
vf.renderMode = RenderMode.SmoothShade;
vf.cameraLights = true;
const displayStyleId: Id64String = DisplayStyle3d.insert(this.iModelDb, this.definitionModelId, viewName, { viewFlags: vf, contextRealityModels: realityModels });
return OrthographicViewDefinition.insert(this.iModelDb, this.definitionModelId, viewName, modelSelectorId, categorySelectorId, displayStyleId, range, StandardViewIndex.Iso);
}
}
const projectExtents = Range3d.createFrom(iModelDb.projectExtents);
let range;
try {
const ecefRange = await RealityModelTileUtils.rangeFromUrl(url);
range = iModelDb.getEcefTransform().inverse()!.multiplyRange(ecefRange);
} catch (err) {
range = projectExtents;
range.low.z = -200.0;
range.high.z = 200.0;
}
projectExtents.low.z = Math.min(range.low.z, projectExtents.low.z);
projectExtents.high.z = Math.max(range.high.z, projectExtents.high.z);
iModelDb.updateProjectExtents(projectExtents);
const modelSelectorId: Id64String = ModelSelector.insert(iModelDb, IModel.dictionaryId, name, []);
const categorySelectorId: Id64String = CategorySelector.insert(iModelDb, IModel.dictionaryId, name, [classifierCategoryId]);
OrthographicViewDefinition.insert(iModelDb, IModel.dictionaryId, name, modelSelectorId, categorySelectorId, displayStyleId, range, StandardViewIndex.Iso);
}
protected insertSpatialView(viewName: string, range: AxisAlignedBox3d): Id64String {
const modelSelectorId: Id64String = ModelSelector.insert(this.iModelDb, this.definitionModelId, viewName, [this.physicalModelId]);
const categorySelectorId: Id64String = CategorySelector.insert(this.iModelDb, this.definitionModelId, viewName, [this.featureCategoryId]);
const displayStyleId: Id64String = DisplayStyle3d.insert(this.iModelDb, this.definitionModelId, viewName, { viewFlags: this._viewFlags, backgroundMap: this._backgroundMap });
return OrthographicViewDefinition.insert(this.iModelDb, this.definitionModelId, viewName, modelSelectorId, categorySelectorId, displayStyleId, range, StandardViewIndex.Top);
}
}