Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const modelId = PhysicalModel.insert(this.iModelDb, IModelDb.rootSubjectId, modelName);
/** generate a geometry stream containing the polyface */
const geometry = this.generateGeometryStreamFromPolyface(polyface);
/** generate DisplayStyles to view the PolyfaceAuxData. The display styles contain channel selection and gradient specification for the [[PolyfaceAuxData]]
*/
const analysisStyleProps = this.getPolyfaceAnalysisStyleProps(polyface, displacementScale);
const vf = new ViewFlags();
const bgColor = ColorDef.white; // White background...
vf.renderMode = RenderMode.SolidFill; // SolidFill rendering ... no lighting etc.
/** The [[GeometricElement3dProps]] */
const props: GeometricElement3dProps = {
model: modelId,
code: Code.createEmpty(),
classFullName: "Generic:PhysicalObject",
category: categoryId,
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 }));
public static insertRobot(iModelDb: IModelDb, modelId: Id64String, name: string, location: Point3d, radius: number = 0.1): Id64String {
const props = {
model: modelId,
code: Code.createEmpty(),
classFullName: RobotWorld.Class.Robot, // In this example, I know what class and category to use.
category: Robot.getCategory(iModelDb).id,
geom: Robot.generateGeometry(radius), // In this example, I know how to generate geometry, and I know that the placement is empty.
placement: { origin: location, angles: new YawPitchRollAngles() },
userLabel: name,
radius, // Add extra, Robot-specific properties. Be sure to spell them correctly, as the compiler won't help you here.
};
return iModelDb.elements.insertElement(props);
}
// __PUBLISH_EXTRACT_END__
public static insertBarrier(iModelDb: IModelDb, modelId: Id64String, location: Point3d, angle: Angle, length: number): Id64String {
const props = { // I know what class and category to use.
model: modelId,
code: Code.createEmpty(),
classFullName: RobotWorld.Class.Barrier,
category: Barrier.getCategory(iModelDb).id,
geom: Barrier.generateGeometry(length),
placement: { origin: location, angles: new YawPitchRollAngles(angle, Angle.zero(), Angle.zero()) },
length,
};
return iModelDb.elements.insertElement(props);
}
protected convertFeatureCollection(): void {
const featureProps: GeometricElement3dProps = {
model: this.physicalModelId,
code: Code.createEmpty(),
classFullName: this.featureClassFullName,
category: this.featureCategoryId,
};
for (const featureJson of this._geoJson.data.features) {
featureProps.geom = this.convertFeatureGeometry(featureJson.geometry);
if (featureJson.properties) {
if (this._labelProperty !== undefined && featureJson.properties[this._labelProperty] !== undefined)
featureProps.userLabel = featureJson.properties[this._labelProperty];
else
featureProps.userLabel = featureJson.properties.mapname;
}
this.iModelDb.elements.insertElement(featureProps);
}
}
public static createCode(iModel: IModelDb, scopeModelId: CodeScopeProps, name: string): Code {
const codeSpec: CodeSpec = iModel.codeSpecs.getByName(BisCodeSpec.texture);
return 0 === name.length ? Code.createEmpty() : new Code({ spec: codeSpec.id, scope: scopeModelId, value: name });
}
/**
public static createCode(iModel: IModelDb, scopeModelId: CodeScopeProps, name: string): Code {
const codeSpec: CodeSpec = iModel.codeSpecs.getByName(BisCodeSpec.texture);
return 0 === name.length ? Code.createEmpty() : new Code({ spec: codeSpec.id, scope: scopeModelId, value: name });
}
/**