WebGL-iTwin.js】实战篇(二):用nodejs代码详解iTwin.js中PhysicalObject生成方法

news2024/11/19 2:32:04

PhysicalObject

即真实存在的物理对象,比如:电脑、桌子等。在webgl中,我们人眼能看到的模型都是PhysicalObject,由多种几何图元类型构成,如:网格、实体、曲面、曲线,点云等。
在这里插入图片描述
其中带索引的多边形网格(indexed mesh)是常用的构造模型的方法。其数据结构在我的上一篇博客有具体解释。

如何生成PhysicalObject

我们用到了iTwin.js一下几个npm包:

  • @itwin/core-backend
  • @itwin/core-common
  • @itwin/core-geometry
1. 首先,需要初始化itwin,不然无法使用其itwin.js的API
const imHostConfig = new IModelHostConfiguration()
await IModelHost.startup(imHostConfig)
2. 创建一个空的模型,得到的db是支持读写模式的一个空的.bim模型
const db = StandaloneDb.createEmpty(filePath, { rootSubject: { name: "root" } })
3. 在空的模型里创建根节点、model、code、图层等,后面创建模型需要
db.codeSpecs.insert("Generic:PhysicalObject", CodeScopeSpec.Type.Model)
const subjectCode = Subject.createCode(db, IModel.rootSubjectId, "Subject")
const subjectId = Subject.insert(db, subjectCode.scope, subjectCode.value)

const physicalPartitionCode = PhysicalPartition.createCode(db, subjectId, "3DModels")
const physicalModelId = PhysicalModel.insert(db, physicalPartitionCode.scope, physicalPartitionCode.value)

const definitionPartitionCode = DefinitionPartition.createCode(db, subjectId, "Definitions")
const definitionModelId = DefinitionModel.insert(db, definitionPartitionCode.scope, definitionPartitionCode.value)

const modelSelectorCode = ModelSelector.createCode(db, definitionModelId, "Physical Models")
const modelSelectorId = ModelSelector.insert(db, definitionModelId, modelSelectorCode.value, [physicalModelId])

const categoryId = SpatialCategory.insert(db, definitionModelId, "Default", { color: ColorDef.white })

const specId = db.codeSpecs.getByName("Generic:PhysicalObject").id
const scopeId = physicalModelId.toString()
const codeTmp = new Code({ spec: specId, scope: scopeId })
4. 在db里插入材质,得到材质图层id,后面往模型上贴图需要使用
const imageBuffer = fs.readFileSync(imagePath)

const img = {
    data: imageBuffer,
    name: 'name',
    label: 'label',
    code: type,
    type: undefined
  }

const textureId = Texture.insertTexture(db, definitionModelId, img.label, img.type, img.data)

const patternMap = {
    TextureId: textureId,
    pattern_scale: [1, 1],
  }

const materialId = RenderMaterialElement.insert(db, definitionModelId, img.name, { patternMap })

const subCategoryId = SubCategory.insert(db, categoryId, img.code, { material: materialId })
5. 画出模型,生成几何流
// 定义一个三角网格数据
const structure = {
    points: [[0, 0, 0], [10, 0, 0], [10, 0, 10]],
    pointIndices: [0, 1, 2],
    params: [[0, 0], [1, 0], [1, 1]],
    paramIndices: [0, 1, 2],
    normals: [[0, 0, 1], [0, 0, 1], [0, 0, 1]],
    normalIndices: [0, 1, 2]
  }

const geometryStreamBuilder = new GeometryStreamBuilder()

const indexedPolyface = IndexedPolyface.create()

for (let i = 0; i < structure.pointIndices.length; i++) {

    const point = structure.points[structure.pointIndices[i]]
    indexedPolyface.addPoint(new Point3d(point[0], point[1], point[2]))
    indexedPolyface.addPointIndex(i, true)

    const param = structure.params[structure.paramIndices[i]]
    indexedPolyface.addParam(new Point2d(param[0], param[1]))
    indexedPolyface.addParamIndex(i)

    const normal = structure.normals[structure.normalIndices[i]]
    indexedPolyface.addNormal(new Vector3d(normal[0], normal[1], normal[2]))
    indexedPolyface.addNormalIndex(i)
  }

indexedPolyface.terminateFacet()

geometryStreamBuilder.appendSubCategoryChange(subCategoryId)
geometryStreamBuilder.appendGeometry(indexedPolyface)

const geometryStream = geometryStreamBuilder.geometryStream
6. 将几何流,插入进db里,生成PhysicalObject
function insertElement (db, props) {
  const buildingProps = {
    classFullName: PhysicalObject.classFullName,
    model: props.physicalModelId,
    category: props.categoryId
  }

  buildingProps.userLabel = props.userLabel
  buildingProps.geom = props.geom
  buildingProps.code = props.code
  const elementId = db.elements.insertElement(buildingProps)

  return elementId
}
7. 收尾工作,创建模型可视范围、显示样式、视图等,最后保存变更并关闭模型
function finish (db, props) {
  const projectExtents = db.computeProjectExtents()
  const extents = projectExtents.extents

  const viewFlagProps = {
    cameraLights: true,
    sourceLights: true,
    visibleEdges: false,
    renderMode: RenderMode.SmoothShade
  }

  const viewFlags = ViewFlags.fromJSON(viewFlagProps)

  const displayStyle = {
    name: 'Default',
    lights: {
      solar: { direction: [-0.9833878378071199, -0.18098510351728977, 0.013883542698953828], intensity: 1.05 },
      ambient: { intensity: 0.25 },
      hemisphere: {
        upperColor: { r: 100, g: 100, b: 100 },
        intensity: 0.5,
      },
      portrait: { intensity: 0 },
    },
    viewFlags,
    backgroundColor: ColorDef.create('#E1FFFF')
  }

  const displayStyle3dCode = DisplayStyle3d.createCode(db, props.definitionModelId, displayStyle.name)
  const displayStyle3dId = DisplayStyle3d.insert(db, props.definitionModelId, displayStyle3dCode.value, displayStyle)

  const spatialCategorySelectorCode = CategorySelector.createCode(db, props.definitionModelId, "Spatial Categories")
  const spatialCategorySelectorId = CategorySelector.insert(db, props.definitionModelId, spatialCategorySelectorCode.value, [props.categoryId])

  const viewCode = SpatialViewDefinition.createCode(db, props.definitionModelId, 'Default View')
  const viewId = SpatialViewDefinition.insertWithCamera(db, props.definitionModelId, viewCode.value, props.modelSelectorId, spatialCategorySelectorId, displayStyle3dId, extents)

  db.views.setDefaultViewId(viewId)
  db.updateProjectExtents(extents)
  db.saveChanges()
  db.close()
}
8. 最后看一下效果

在这里插入图片描述

附上完整代码

nodejs脚本实现:

const { IModelHost, SubCategory, IModelJsFs, Subject, PhysicalPartition, PhysicalModel, DefinitionPartition, DefinitionModel, ModelSelector,
  SpatialCategory, CategorySelector, DisplayStyle3d, SpatialViewDefinition, RenderMaterialElement, StandaloneDb, IModelHostConfiguration, PhysicalObject, Texture } = require('@itwin/core-backend');
const { CodeScopeSpec, IModel, ColorDef, Code, ViewFlags, RenderMode, GeometryStreamBuilder } = require('@itwin/core-common');
const { Matrix3d, Transform, Vector3d, Arc3d, Range3d, Point3d, IndexedPolyface, Sphere, Box, Cone, TorusPipe, AngleSweep, LineString3d, PointString3d, Point2d } = require('@itwin/core-geometry')
const math = require('mathjs')
const fs = require('fs')

//立方体mesh数据
const meshData = {
  // 顶点数据
  point: [
    [0.0, 1.0, 0.0], //点A 
    [0.0, 0.0, 0.0], //点B 
    [1.0, 0.0, 0.0], //点C 
    [1.0, 1.0, 0.0], //点D 
    [0.0, 1.0, 1.0], //点E 
    [0.0, 0.0, 1.0], //点F 
    [1.0, 0.0, 1.0], //点G 
    [1.0, 1.0, 1.0]  //点H 
  ],
  //顶点索引
  pointIndex: [
    [0, 1, 2, 3], //A-B-C-D 上面
    [4, 5, 6, 7], //E-F-G-H 下面
    [2, 3, 7, 6], //C-D-H-G 前面
    [1, 0, 4, 5], //B-A-E-F 后面
    [2, 1, 5, 6], //C-B-F-G 左面
    [3, 0, 4, 7]  //D-A-E-H 右面
  ]
}

/**
 * 画图例子
 */
async function draw () {

  // 初始化并启动imodelhost
  await init()

  //创建一个iModelDb
  const db = createStandaloneDb("./demo.bim")

  //获取db中必要的参数
  const params = getDbParams(db)

  const props = {
    physicalModelId: params.physicalModelId,
    categoryId: params.categoryId,
    userLabel: undefined,
    code: undefined,
    geom: undefined
  }

  const elemets = []
  const drawTypes = ['mesh', 'sphere', 'box', 'cone', 'cylinder', 'torusPipe', 'line', 'point', 'triangulated']
  for (let i = 0; i < drawTypes.length; i++) {
    params.codeTmp.value = drawTypes[i]
    props.userLabel = drawTypes[i]
    props.code = params.codeTmp
    switch (drawTypes[i]) {
      case 'mesh':
        props.geom = drawMesh(db, params.definitionModelId, params.categoryId)
        break;
      case 'sphere':
        const center = new Point3d(2, 0.5, 0.5)
        const radius = 0.5
        props.geom = drawSphere(db, params.categoryId, center, radius, drawTypes[i])
        break;
      case 'box':
        const range = Range3d.create(...[new Point3d(3, 0, 0), new Point3d(4, 1, 1)])
        props.geom = drawBox(db, params.categoryId, range, drawTypes[i])
        break;
      case 'cone':
        const coneCenterA = new Point3d(5, 0.5, 0)
        const coneCenterB = new Point3d(5, 0.5, 1)
        const coneRadiusA = 0.5
        const coneRadiusB = 0.25
        props.geom = drawCone(db, params.categoryId, coneCenterA, coneCenterB, coneRadiusA, coneRadiusB, drawTypes[i])
        break;
      case 'cylinder':
        const cylinderCenterA = new Point3d(6.5, 0.5, 0)
        const cylinderCenterB = new Point3d(6.5, 0.5, 1)
        const cylinderRadiusA = 0.5
        const cylinderRadiusB = 0.5
        props.geom = drawCone(db, params.categoryId, cylinderCenterA, cylinderCenterB, cylinderRadiusA, cylinderRadiusB, drawTypes[i])
        break;
      case 'torusPipe':
        const PipeCenter = new Point3d(7.5, 0.5, 0)
        const vector0 = new Vector3d(0, 1, 0)
        const vector90 = new Vector3d(0, 0, 1)
        const sweep = AngleSweep.createStartSweepDegrees(0, 180)
        const arc = Arc3d.create(PipeCenter, vector0, vector90, sweep)
        const minorRadius = 0.2
        props.geom = drawPipe(db, params.categoryId, arc, minorRadius, drawTypes[i])
        break;
      case 'line':
        const linePoints = [new Point3d(10, 0, 0), new Point3d(10.5, 2, 1), new Point3d(11, 5, -0.5)]
        const index = [0, 2, 1]
        props.geom = drawLine(db, params.categoryId, linePoints, index, drawTypes[i])
        break;
      case 'point':
        const points = [new Point3d(12, 1, 1), new Point3d(13, 3, 3)]
        props.geom = drawPoint(db, params.categoryId, points, drawTypes[i])
        break;
      case 'triangulated':
        const subCategoryId = createTexture('./data.jpg', db, params.definitionModelId, params.categoryId, drawTypes[i])
        props.geom = drawTriangulated(subCategoryId)
        break;
    }
    const elementId = insertElement(db, props)
    elemets.push(elementId)
  }

  finish(db, params)
  console.log(`INSERT SUCCESS ElementIds: ${elemets}`)
}

async function init () {
  const imHostConfig = new IModelHostConfiguration()
  await IModelHost.startup(imHostConfig)
}

function createStandaloneDb (filePath) {
  if (IModelJsFs.existsSync(filePath)) {
    IModelJsFs.unlinkSync(filePath)
  }

  if (IModelJsFs.existsSync(`${filePath}.Tiles`)) {
    IModelJsFs.unlinkSync(`${filePath}.Tiles`)
  }

  const db = StandaloneDb.createEmpty(filePath, { rootSubject: { name: "root" } })

  return db
}

function getDbParams (db) {
  db.codeSpecs.insert("Generic:PhysicalObject", CodeScopeSpec.Type.Model)
  const subjectCode = Subject.createCode(db, IModel.rootSubjectId, "Subject")
  const subjectId = Subject.insert(db, subjectCode.scope, subjectCode.value)

  const physicalPartitionCode = PhysicalPartition.createCode(db, subjectId, "3DModels")
  const physicalModelId = PhysicalModel.insert(db, physicalPartitionCode.scope, physicalPartitionCode.value)

  const definitionPartitionCode = DefinitionPartition.createCode(db, subjectId, "Definitions")
  const definitionModelId = DefinitionModel.insert(db, definitionPartitionCode.scope, definitionPartitionCode.value)

  const modelSelectorCode = ModelSelector.createCode(db, definitionModelId, "Physical Models")
  const modelSelectorId = ModelSelector.insert(db, definitionModelId, modelSelectorCode.value, [physicalModelId])

  const categoryId = SpatialCategory.insert(db, definitionModelId, "Default", { color: ColorDef.white })

  const specId = db.codeSpecs.getByName("Generic:PhysicalObject").id
  const scopeId = physicalModelId.toString()
  const codeTmp = new Code({ spec: specId, scope: scopeId })

  return {
    physicalModelId,
    definitionModelId,
    modelSelectorId,
    categoryId,
    codeTmp
  }
}

function drawMesh (db, definitionModelId, categoryId) {
  const geometryStreamBuilder = new GeometryStreamBuilder()
  //1.画立方体
  for (let i = 0; i < meshData.pointIndex.length; i++) {
    //indexed mesh
    const indexedPolyface = IndexedPolyface.create()
    for (let j = 0; j < meshData.pointIndex[i].length; j++) {
      //添加顶点
      let point = meshData.point[meshData.pointIndex[i][j]]
      indexedPolyface.addPoint(new Point3d(point[0], point[1], point[2]))

      //添加顶点索引
      indexedPolyface.addPointIndex(j, true)
    }

    indexedPolyface.terminateFacet()

    //着色
    const props = {
      material: undefined,
      color: undefined,
      transp: 0.5
    }
    const colorMode = ['material', 'category']
    switch (colorMode[1]) {
      //漫反射颜色(将颜色以材质方式的贴上去)
      case 'material':
        const params = {
          color:  //颜色: 百分比格式的RGBA(100%,0%,0%,1.0)
            [
              math.fix(math.random(0, 1), 3),   //R
              math.fix(math.random(0, 1), 3),   //G
              math.fix(math.random(0, 1), 3),  //B
              1.0                              //alpha
            ],
          transmit: 0,  //透明度:0为不透明, 1为完全透明
          diffuse: 0.9 //颜色反射率:0最暗淡,1最鲜艳
        }
        const materialId = RenderMaterialElement.insert(db, definitionModelId, i, params)
        props.material = materialId
        break;
      //常规颜色(直接画上去)
      case 'category':
        const color = ColorDef.from(math.randomInt(0, 255), math.randomInt(0, 255), math.randomInt(0, 255))
        props.color = color.toJSON()
        break;
    }
    const subCategoryId = SubCategory.insert(db, categoryId, i, props)
    geometryStreamBuilder.appendSubCategoryChange(subCategoryId)
    geometryStreamBuilder.appendGeometry(indexedPolyface)
  }
  return geometryStreamBuilder.geometryStream
}

function drawSphere (db, categoryId, center, radius, type) {

  const geometryStreamBuilder = new GeometryStreamBuilder()
  const sphere = Sphere.createCenterRadius(center, radius)

  sphere.capped = true

  const color = ColorDef.from(math.randomInt(0, 255), math.randomInt(0, 255), math.randomInt(0, 255))
  const subCategoryId = SubCategory.insert(db, categoryId, type, { color: color.toJSON(), transp: 0 })

  geometryStreamBuilder.appendSubCategoryChange(subCategoryId)
  geometryStreamBuilder.appendGeometry(sphere)

  return geometryStreamBuilder.geometryStream
}

function drawBox (db, categoryId, range, type) {
  const geometryStreamBuilder = new GeometryStreamBuilder()
  const box = Box.createRange(range, true)

  const color = ColorDef.from(math.randomInt(0, 255), math.randomInt(0, 255), math.randomInt(0, 255))
  const subCategoryId = SubCategory.insert(db, categoryId, type, { color: color.toJSON(), transp: 0 })

  geometryStreamBuilder.appendSubCategoryChange(subCategoryId)
  geometryStreamBuilder.appendGeometry(box)

  return geometryStreamBuilder.geometryStream
}

function drawCone (db, categoryId, centerA, centerB, radiusA, radiusB, type) {
  const geometryStreamBuilder = new GeometryStreamBuilder()
  const cone = Cone.createAxisPoints(centerA, centerB, radiusA, radiusB, true)

  const matrix = Matrix3d.create90DegreeRotationAroundAxis(0)
  const transform = Transform.createOriginAndMatrix(new Point3d(0, 0, 0), matrix)
  cone.tryTransformInPlace(transform)

  const color = ColorDef.from(math.randomInt(0, 255), math.randomInt(0, 255), math.randomInt(0, 255))
  const subCategoryId = SubCategory.insert(db, categoryId, type, { color: color.toJSON(), transp: 0 })

  geometryStreamBuilder.appendSubCategoryChange(subCategoryId)
  geometryStreamBuilder.appendGeometry(cone)

  return geometryStreamBuilder.geometryStream
}

function drawPipe (db, categoryId, arc, minorRadius, type) {
  const geometryStreamBuilder = new GeometryStreamBuilder()

  const pipe = TorusPipe.createAlongArc(arc, minorRadius, true)

  const color = ColorDef.from(math.randomInt(0, 255), math.randomInt(0, 255), math.randomInt(0, 255))
  const subCategoryId = SubCategory.insert(db, categoryId, type, { color: color.toJSON(), transp: 0 })

  geometryStreamBuilder.appendSubCategoryChange(subCategoryId)
  geometryStreamBuilder.appendGeometry(pipe)

  return geometryStreamBuilder.geometryStream
}

function drawLine (db, categoryId, points, index, type) {
  const geometryStreamBuilder = new GeometryStreamBuilder()

  const line = LineString3d.createIndexedPoints(points, index, false)

  const color = ColorDef.from(math.randomInt(0, 255), math.randomInt(0, 255), math.randomInt(0, 255))
  const subCategoryId = SubCategory.insert(db, categoryId, type, { color: color.toJSON(), transp: 0 })

  geometryStreamBuilder.appendSubCategoryChange(subCategoryId)
  geometryStreamBuilder.appendGeometry(line)

  return geometryStreamBuilder.geometryStream
}

function drawPoint (db, categoryId, points, type) {
  const geometryStreamBuilder = new GeometryStreamBuilder()

  const point = PointString3d.createPoints(points)

  const color = ColorDef.from(math.randomInt(0, 255), math.randomInt(0, 255), math.randomInt(0, 255))
  const subCategoryId = SubCategory.insert(db, categoryId, type, { color: color.toJSON(), transp: 0 })

  geometryStreamBuilder.appendSubCategoryChange(subCategoryId)
  geometryStreamBuilder.appendGeometry(point)

  return geometryStreamBuilder.geometryStream
}

function drawTriangulated (subCategoryId) {

  const structure = {
    points: [[0, 0, 0], [10, 0, 0], [10, 0, 10]],
    pointIndices: [0, 1, 2],
    params: [[0, 0], [1, 0], [1, 1]],
    paramIndices: [0, 1, 2],
    normals: [[0, 0, 1], [0, 0, 1], [0, 0, 1]],
    normalIndices: [0, 1, 2]
  }

  const geometryStreamBuilder = new GeometryStreamBuilder()

  const indexedPolyface = IndexedPolyface.create()

  for (let i = 0; i < structure.pointIndices.length; i++) {

    const point = structure.points[structure.pointIndices[i]]
    indexedPolyface.addPoint(new Point3d(point[0], point[1], point[2]))
    indexedPolyface.addPointIndex(i, true)

    const param = structure.params[structure.paramIndices[i]]
    indexedPolyface.addParam(new Point2d(param[0], param[1]))
    indexedPolyface.addParamIndex(i)

    const normal = structure.normals[structure.normalIndices[i]]
    indexedPolyface.addNormal(new Vector3d(normal[0], normal[1], normal[2]))
    indexedPolyface.addNormalIndex(i)
  }

  indexedPolyface.terminateFacet()

  geometryStreamBuilder.appendSubCategoryChange(subCategoryId)
  geometryStreamBuilder.appendGeometry(indexedPolyface)

  return geometryStreamBuilder.geometryStream
}

function finish (db, props) {
  const projectExtents = db.computeProjectExtents()
  const extents = projectExtents.extents

  const viewFlagProps = {
    cameraLights: true,
    sourceLights: true,
    visibleEdges: false,
    renderMode: RenderMode.SmoothShade
  }

  const viewFlags = ViewFlags.fromJSON(viewFlagProps)

  const displayStyle = {
    name: 'Default',
    lights: {
      solar: { direction: [-0.9833878378071199, -0.18098510351728977, 0.013883542698953828], intensity: 1.05 },
      ambient: { intensity: 0.25 },
      hemisphere: {
        upperColor: { r: 100, g: 100, b: 100 },
        intensity: 0.5,
      },
      portrait: { intensity: 0 },
    },
    viewFlags,
    backgroundColor: ColorDef.create('#E1FFFF')
  }

  const displayStyle3dCode = DisplayStyle3d.createCode(db, props.definitionModelId, displayStyle.name)
  const displayStyle3dId = DisplayStyle3d.insert(db, props.definitionModelId, displayStyle3dCode.value, displayStyle)

  const spatialCategorySelectorCode = CategorySelector.createCode(db, props.definitionModelId, "Spatial Categories")
  const spatialCategorySelectorId = CategorySelector.insert(db, props.definitionModelId, spatialCategorySelectorCode.value, [props.categoryId])

  const viewCode = SpatialViewDefinition.createCode(db, props.definitionModelId, 'Default View')
  const viewId = SpatialViewDefinition.insertWithCamera(db, props.definitionModelId, viewCode.value, props.modelSelectorId, spatialCategorySelectorId, displayStyle3dId, extents)

  db.views.setDefaultViewId(viewId)
  db.updateProjectExtents(extents)
  db.saveChanges()
  db.close()
}

function insertElement (db, props) {
  const buildingProps = {
    classFullName: PhysicalObject.classFullName,
    model: props.physicalModelId,
    category: props.categoryId
  }

  buildingProps.userLabel = props.userLabel
  buildingProps.geom = props.geom
  buildingProps.code = props.code
  const elementId = db.elements.insertElement(buildingProps)

  return elementId
}

function createTexture (imagePath, db, definitionModelId, categoryId, type) {

  const imageBuffer = fs.readFileSync(imagePath)

  const img = {
    data: imageBuffer,
    name: 'name',
    label: 'label',
    code: type,
    type: undefined
  }

  const textureId = Texture.insertTexture(db, definitionModelId, img.label, img.type, img.data)

  const patternMap = {
    TextureId: textureId,
    pattern_scale: [1, 1],
  }

  const materialId = RenderMaterialElement.insert(db, definitionModelId, img.name, { patternMap })

  const subCategoryId = SubCategory.insert(db, categoryId, img.code, { material: materialId })
  return subCategoryId
}

draw()

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/157271.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

XCTF:cat

打开是一个输入框&#xff0c;要求输入域名&#xff0c;尝试输入baidu.com进行测试 并无任何回显&#xff0c;测试下127.0.0.1本地地址 执行成功&#xff0c;并出现ping命令结果&#xff0c;这里很容易联想到命令注入&#xff0c;尝试进行命令拼接注入 但测试了常用的拼接字…

【5】变量和常量

一、什么是变量 首先我们要理解这么一个概念&#xff0c;在程序的运行过程中所有数据是保存在内存中的&#xff0c;我们代码中想使用这个数据的时候就要从内存中找&#xff0c;而变量的作用类似就是将内存地址保存&#xff0c;之后直接通过这个变量找内存中的数在Go语言中&…

JNI和Ndk开发

按照一下配置&#xff0c;基本能保证demo跑通 1、下载NDK&#xff0c;下载需要的版本 2、下载Cmake版本 3、项目结构&#xff1a;含C源码 4、编写JNI的加载类 public class YjkModel {static {System.loadLibrary("nativ"); //跟CMakeLists.txt 库名一致}public nat…

基于 APISIX 的服务网格方案 Amesh 积极开发中!

作者lingsamuel&#xff0c;API7.ai 云原生技术专家&#xff0c;Apache APISIX Committer。 在云原生快速发展的前提下&#xff0c;服务网格领域也开始逐渐火热。目前阶段&#xff0c;大家所熟知的服务网格解决方案很多&#xff0c;每种产品又各有其优势。因此在面对不同的行业…

python直接赋值、浅拷贝与深拷贝

本文主要参考这篇博文python浅拷贝与深拷贝 基本概念 首先了解python中的一些基本概念 变量&#xff1a;是一个系统表的元素&#xff0c;拥有指向对象的连接空间对象&#xff1a;被分配的一块内存&#xff0c;存储其所代表的值引用&#xff1a;是自动形成的从变量到对象的指…

ECU Extract + OS Task Mapping 步骤

纲要&#xff1a; 通过 Composition里面的Assembly Connection (Intra-ECU Communication)System Extract 里面的SystemDataMapping (Inter-ECU Communication) 已经把SWC的所有Data Element都连接上了&#xff0c;接下来就是把SWC的Runnable给Mapping到对应的OS Task上&…

(三)redis五大数据类型和key

目录 一、redis键&#xff08;key&#xff09;的常用操作 二、redis字符串&#xff08;String&#xff09; 1、简介 2、常用命令 3、数据结构 三、redis列表&#xff08;List&#xff09; 1、简介 2、常用命令 3、数据结构 四、redis集合&#xff08;Set&#xff09;…

Django(16):rest_framework框架使用指南

目录1.安装配置2.数据序列化2.1 Serializer2.2 ModelSerializer2.3 序列化对象的属性和方法3.请求和响应3.1 Request3.2 Response3.3 状态码3.4 as_view3.5 format_suffix_patterns3.6 示例4.CBV构建&#xff08;基于类的视图&#xff09;4.1 如何构建4.2 类型视图的扩展功能4.…

DMIPS, FLOPS, OPS概念

DMIPS DMIPS(Dhrystone Million Instructions executed Per Second)&#xff1a;Dhrystone是测量处理器运算能力的最常见基准程序之一&#xff0c;常用于处理器的整型运算性能的测量。Dhrystone是一种整数运算测试程序。换句话说&#xff0c;就是使用Dhrystone这种程序在不同的…

【云原生 | 52】Docker三剑客之Docker Compose第三节

&#x1f341;博主简介&#xff1a; &#x1f3c5;云计算领域优质创作者 &#x1f3c5;2022年CSDN新星计划python赛道第一名 &#x1f3c5;2022年CSDN原力计划优质作者 &#x1f3c5;阿里云ACE认证高级工程师 &#x1f3c5;阿里云开发者社区专…

FineReport填报报表

二次确认&#xff0c;删除行&#xff1a;参考&#xff1a; JS实现删除时二次确认- FineReport帮助文档 - 全面的报表使用教程和学习资料JS实现记录填报操作- FineReport帮助文档 - 全面的报表使用教程和学习资料确认后直接校验提交// 二次确认 var cell this.options.location…

开始安装Domino 12.0.2

大家好&#xff0c;才是真的好。 上周我们话题是NotesDomino12.0.2产品发布&#xff0c;主要说到了Domino12.0.2的新特性&#xff0c;新特性很多&#xff0c;要用很多篇来进行测试和说明。 今天我们主要谈谈Domino 12.0.2的系统要求和安装等。 首先&#xff0c;Domino12.0.2…

一、初识FreeRTOS之FreeRTOS简介

目录 一、什么是FreeRTOS&#xff1f; 二、为什么选择FreeRTOS&#xff1f; 三、FreeRTOS的特点 四、FreeRTOS资料与源码下载 五、FreeRTOS源码文件介绍 一、什么是FreeRTOS&#xff1f; Free即免费的&#xff0c;RTOS的全称是Real time operating system,中文就是实时操作…

python数据结构(一):字符串

一、字符串的格式化输出 1.1、格式化运算符 print("我跑完了第" str(lap 1) "圈")上面这段输出的代码使用了两个加号做了字符串拼接&#xff0c;并且将整形转换成了字符串。也可以使用一种更好的办法&#xff0c;格式化输出来打印这句话。 print(&quo…

xilinx srio ip学习笔记之再识srio

提示&#xff1a;文章写完后&#xff0c;目录可以自动生成&#xff0c;如何生成可参考右边的帮助文档 xilinx srio ip学习笔记之再识srio前言SRIO的理解IP核的理解前言 这段时间&#xff0c;随着对SRIO的学习&#xff0c;又有了更深的一点认识&#xff0c;不像一开始这么慌张了…

年终汇报工作,如何用项目管理工具展现成果

据报道&#xff0c;2022年11月20日的一次京东内部会议上&#xff0c;刘强东痛批京东中高层管理人员&#xff0c;表示部分高管醉心于 PPT 和奇妙词汇&#xff0c;或吹得天花乱坠但是执行一塌糊涂。 不可否认&#xff0c;刘强东提到的现象&#xff0c;的确是当今众多互联网大厂和…

基于frp实现外网访问个人本地服务器

适用对象想要通过frp实现内网服务被外网访问的人。关键词描述内网&#xff1a;内网指的是局域网&#xff0c;几台或者几十台电脑之间互访&#xff0c;也叫私网。外网&#xff1a;指的是我们上的Internet网络&#xff0c;也叫公网。需要具备的知识基础和条件1&#xff1a;外网服…

Java异常分类常见使用场景

今天在自己实现RxJava框架时&#xff0c;发现一些参数异常、流关闭异常等&#xff0c;Rxjava框架是会抛出相应的异常的&#xff0c;所以自己编写实现这块源码的时候&#xff0c;渐渐的也需要使用到这些知识&#xff0c;这里对这块做一下回顾总结。 使用 我们代码编写实现中&am…

开年喜讯!知道创宇一连斩获2022年度“IT168技术卓越奖”三项大奖

近日&#xff0c;业界知名IT垂直门户媒体IT168发布“2022年度IT168技术卓越奖”获奖名单&#xff0c;知道创宇凭借强大的技术优势与出色的产品能力脱颖而出&#xff0c;一举斩获网络安全领域三项大奖&#xff1a; 知道创宇创始人、CEO赵伟获评“数字化转型领军人物” ScanV-互…

【C++】优先级队列priority_queue/仿函数(函数对象)

这里写目录标题一.优先级队列1.优先级队列的介绍2.priority_queue的定义与使用二.仿函数/函数对象三.优先级队列的模拟实现一.优先级队列 1.优先级队列的介绍 1&#xff09;注意优先级队列和队列不是一个东西&#xff0c;队列是容器&#xff0c;优先级队列是一种容器适配器&am…