This commit is contained in:
2024-12-14 01:28:19 +08:00
commit dfd9c13212
42 changed files with 4664 additions and 0 deletions
+7
View File
@@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: npm
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 20
+8
View File
@@ -0,0 +1,8 @@
.DS_Store
Thumbs.db
db.json
*.log
node_modules/
public/
.deploy*/
_multiconfig.yml
File diff suppressed because it is too large Load Diff
+1129
View File
File diff suppressed because it is too large Load Diff
+162
View File
@@ -0,0 +1,162 @@
# Hexo Configuration
## Docs: https://hexo.io/docs/configuration.html
## Source: https://github.com/hexojs/hexo/
# Site
title: Vanessa
subtitle: ''
description: ''
keywords:
author: lain
language: zh-CN # 指定语言,会影响主题显示的语言,按需修改
timezone: ''
email: '[email protected]'
# URL
## Set your site url here. For example, if you use GitHub Page, set url as 'https://username.github.io/project'
url: http://aniakea.github.io
permalink: :year/:month/:day/:title/
permalink_defaults:
pretty_urls:
trailing_index: true # Set to false to remove trailing 'index.html' from permalinks
trailing_html: true # Set to false to remove trailing '.html' from permalinks
# Directory
source_dir: source
public_dir: public
tag_dir: tags
archive_dir: archives
category_dir: categories
code_dir: downloads/code
i18n_dir: :lang
skip_render:
# Writing
new_post_name: :title.md # File name of new posts
default_layout: post
titlecase: false # Transform title into titlecase
external_link:
enable: true # Open external links in new tab
field: site # Apply to the whole site
exclude: ''
filename_case: 0
render_drafts: false
post_asset_folder: false
relative_link: false
future: true
syntax_highlighter: highlight.js
highlight:
line_number: true
auto_detect: false
tab_replace: ''
wrap: true
hljs: false
exclude_languages: ['mermaid']
prismjs:
preprocess: true
line_number: true
tab_replace: ''
exclude_languages: ['mermaid']
# Home page setting
# path: Root path for your blogs index page. (default = '')
# per_page: Posts displayed per page. (0 = disable pagination)
# order_by: Posts order. (Order by date descending by default)
index_generator:
path: ''
per_page: 10
order_by: -date
# Category & Tag
default_category: uncategorized
category_map:
tag_map:
# Metadata elements
## https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta
meta_generator: true
# Date / Time format
## Hexo uses Moment.js to parse and display date
## You can customize the date format as defined in
## http://momentjs.com/docs/#/displaying/format/
date_format: YYYY-MM-DD
time_format: HH:mm:ss
## updated_option supports 'mtime', 'date', 'empty'
updated_option: 'mtime'
# Pagination
## Set per_page to 0 to disable pagination
per_page: 10
pagination_dir: page
# Include / Exclude file(s)
## include:/exclude: options only apply to the 'source/' folder
include:
exclude:
ignore:
# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
theme: butterfly
markdown:
preset: 'default'
render:
html: true
xhtmlOut: false
langPrefix: 'language-'
breaks: true
linkify: true
typographer: true
quotes: '“”‘’'
enable_rules:
disable_rules:
plugins:
- markdown-it-abbr
- markdown-it-cjk-breaks
- markdown-it-deflist
- markdown-it-emoji
- markdown-it-footnote
- markdown-it-ins
- markdown-it-mark
- markdown-it-sub
- markdown-it-sup
- markdown-it-imsize
- markdown-it-expandable
- name: markdown-it-container
options: success
- name: markdown-it-container
options: tips
- name: markdown-it-container
options: warning
- name: markdown-it-container
options: danger
anchors:
level: 2
collisionSuffix: ''
permalink: false
permalinkClass: 'header-anchor'
permalinkSide: 'left'
permalinkSymbol: '¶'
case: 0
separator: '-'
images:
lazyload: false
prepend_root: false
post_asset: false
inline: false # https://markdown-it.github.io/markdown-it/#MarkdownIt.renderInline
search:
path: search.xml
field: post
content: true
# Deployment
## Docs: https://hexo.io/docs/one-command-deployment
deploy:
type: 'git'
repo: [email protected]:Aniakea/Aniakea.github.io.git
branch: master
+37
View File
@@ -0,0 +1,37 @@
{
"name": "hexo-site",
"version": "0.0.0",
"private": true,
"scripts": {
"build": "hexo generate",
"clean": "hexo clean",
"deploy": "hexo deploy",
"server": "hexo server"
},
"hexo": {
"version": "7.3.0"
},
"dependencies": {
"hexo": "^7.3.0",
"hexo-asset-image": "^1.0.0",
"hexo-deployer-git": "^4.0.0",
"hexo-generator-archive": "^2.0.0",
"hexo-generator-category": "^2.0.0",
"hexo-generator-index": "^4.0.0",
"hexo-generator-search": "^2.4.3",
"hexo-generator-tag": "^2.0.0",
"hexo-renderer-ejs": "^2.0.0",
"hexo-renderer-markdown-it": "^7.1.1",
"hexo-renderer-pug": "^3.0.0",
"hexo-renderer-stylus": "^3.0.1",
"hexo-server": "^3.0.0",
"hexo-theme-ayer": "^1.9.7-0",
"hexo-theme-butterfly": "^5.2.2",
"hexo-theme-fluid": "^1.9.8",
"hexo-theme-landscape": "^1.0.0",
"hexo-wordcount": "^6.0.1",
"markdown-it-container": "^4.0.0",
"markdown-it-expandable": "^1.0.2",
"markdown-it-imsize": "^2.0.1"
}
}
+9
View File
@@ -0,0 +1,9 @@
---
title: {{ title }}
date: {{ date }}
tags: []
categories: 开发
toc: true
cover: /img/cov5.JPG
top_img: /img/dev.jpg
---
+4
View File
@@ -0,0 +1,4 @@
---
title: {{ title }}
tags:
---
+4
View File
@@ -0,0 +1,4 @@
---
title: {{ title }}
date: {{ date }}
---
+5
View File
@@ -0,0 +1,5 @@
---
title: {{ title }}
date: {{ date }}
tags:
---
+16
View File
@@ -0,0 +1,16 @@
---
title: anaconda安装
tags: [python, 开发环境]
categories: 开发
toc: true
date:
cover: /img/cov5.JPG
top_img: /img/dev.jpg
---
<!-- ![IMG_0239](https://cdn.jsdelivr.net/gh/Aniakea/blog_pic@main/blog/Images/IMG_0239.PNG) -->
### 为什么需要 anaconda
### 下载和安装
### 基本使用
+237
View File
@@ -0,0 +1,237 @@
---
title: pyvista初试
tags: [python, 数据可视化]
categories: 开发
toc: true
date: 2024-11-27 15:27:30
cover: /img/cov5.JPG
top_img: /img/dev.jpg
---
跳槽后工作没那么忙了, 遂开始写博客打法时间.
因为现在的项目需要加载三维模型并显示应力, 所以需要vtk, 为了开发简单, 选择了`python`
### 开发环境
需要 `python > 3.8`
使用 **`pip`** 进行安装
```bash
pip install pyvista
```
使用 **`conda`** 进行安装
需要有[*`Anaconda`*](https://aniakea.github.io/2024/11/29/anaconda%E5%AE%89%E8%A3%85/ "安装教程")环境
```bash
conda install -c conda-forge pyvista
```
详情参考 *[官方文档](https://docs.pyvista.org/getting-started/installation.html)*.
### 尝试
尝试官方示例
```python
import pyvista
mesh = pyvista.Sphere()
mesh.plot()
```
可以看到![示例图像1](/pic/image1.png)
```python
from pyvista import examples
mesh = examples.download_dragon()
mesh['scalars'] = mesh.points[:, 1]
mesh.plot(cpos='xy', cmap='plasma')
```
可以看到![示例图像2](/pic/image2.png)
更多请查看 *[官方文档](https://docs.pyvista.org/user-guide/)*
### 尝试通过excel或csv提供数据
为了方便,这里我们需要使用`pandas`.`pyvistaqt`.`pyqt`库
```shell
pip install pandas pyvistaqt PyQt5
```
分为两个数据文件, 一个为提供点的xyz轴数据, 一个提供单元所用的点
*point.xlsx*文件结构为
| 编号 | x | y | z |
| --- | --- | --- | --- |
*node.xlsx*文件结构为
| 编号 | unit | p1 | p2 | ... |
| --- | --- | --- | --- | --- |
考虑到单元类型不唯一, 这里只能选择 `UnStructedGrid`
代码如下
```python
from PyQt5.QtWidgets import (
QFrame,
QVBoxLayout,
QApplication,
QHBoxLayout,
QButtonGroup,
QRadioButton,
)
import pyvista as pv
import numpy as np
import pandas as pd
from pyvistaqt import QtInteractor
import os
class Widget(QFrame):
def __init__(self):
super().__init__()
processor.change(0)
self.vmin = 0
self.vmax = 0.1319
layout = QVBoxLayout()
self.plotter = QtInteractor(self, auto_update=1)
layout.addWidget(self.plotter.interactor)
self.setLayout(layout)
self.read_excel()
def read_excel(self):
point_data = pd.read_excel("./point.xlsx", header=None)
point_pos = []
point_keys = []
for row in point_data.values:
point_pos.append(row[1:4])
point_keys.append(row[1])
cell_data = pd.read_excel("./node.xlsx", header=None)
cell = []
cell_shapes = []
def covert(code):
return point_keys.index(code)
for row in cell_data.values:
cell_shapes.append(pv.CellType.QUAD)
cell.append([4].append(map(covert, row[2:])))
self.grid = pv.UnstructuredGrid(cell, cell_shapes, point_pos)
self.actor = self.plotter.add_mesh(
self.grid, cmap="viridis", smooth_shading=True, copy_mesh=True
)
app = QApplication(sys.argv)
widget = Widget()
widget.show()
```
需要注意的一点为cell中的值对应的是point数组的下标, 这里这么写主要是应对point编号非从0开始递增的情况
目前的`unit_type`没有考虑非四边形的情况, 若需要考虑多类型组合的方式, 请参考[官方文档](https://docs.pyvista.org/examples/00-load/create-polyhedron#sphx-glr-examples-00-load-create-polyhedron-py)
从excel中加载数据通常很大, 建议完成读取后存储为模型文件
```python
self.grid.save("./mesh.vtk")
```
这种方式不能储存stl文件, 若是确定只需要表面的点需要存储为stl文件, 需要提取表面
```python
self.grid.extract_surface().save("./mesh.stl")
```
### 尝试添加数据到模型
注意数据的数量必须要和当前显示的模型的点的数量一致
```python
self.grid["range"] = data
self.actor = self.plotter.add_mesh(
self.grid,
cmap="viridis",
scalars="range",
smooth_shading=True,
copy_mesh=True
)
```
### 尝试自定义色彩映射
```python
from matplotlib.colors import LinearSegmentedColormap
def make_cmap(vmin, vmax, n=256):
"""
创建一个从蓝黑色到黄色再到红色的自定义颜色映射
参数:
vmin : float
颜色映射的最小值
vmax : float
颜色映射的最大值
n : int, 可选
颜色映射中的颜色数量,默认为256
返回:
pyvista.LookupTable
PyVista 查找表对象,可用于设置 mesh 的标量条
"""
# 定义颜色映射的颜色
colors = ['#000033', '#0000FF', '#00FFFF', '#FFFF00', '#FF0000']
# 创建 matplotlib 颜色映射
cmap = LinearSegmentedColormap.from_list("custom_blue_black_to_yellow_red", colors, N=n)
# 创建 PyVista 查找表
lut = pv.LookupTable()
# 设置颜色映射的范围
lut.SetRange(vmin, vmax)
# 填充查找表
for i in range(n):
r, g, b, _ = cmap(i / (n - 1))
lut.SetTableValue(i, r, g, b)
return lut
```
函数 `make_cmap` 前两个参数决定了映射的上下限, 第三个参数决定映射的色阶数量
colors至少需要两个颜色, 此时色阶在rgb上线性变化, 这里定义了中间色号, 所以色阶呈贝塞尔曲线变化
在 add_mesh 函数中的 `cmap` 参数设置为函数 `make_cmap` 的返回值
```python
self.grid["range"] = data
actor = self.plotter.add_mesh(
self.grid,
scalars="range",
cmap = make_cmap(self.vmin,self.vmax),
# cmap="viridis",
smooth_shading=True,
copy_mesh=True,
)
```
@@ -0,0 +1,64 @@
---
title: 在c++中嵌入python解释器
tags: [c++, python]
categories: 开发
toc: true
date:
cover: /img/cov5.JPG
top_img: /img/dev.jpg
---
还是哪个展示应力模型的项目, 由于是基于之前的项目的, 而之前的项目的gui是qt做的, 之前又没有告诉我需要嵌入这个程序, 而我python的已经写完了
所以开始研究嵌入方案
首先需要确定python是否独立运行于老的gui程序
如果独立运行的情况, 我需要在python端额外写一个网络模块来和老gui程序进行交互,两边都得改, 怪麻烦的, 不考虑
非独立运行的话, 就需要嵌入python解释器来执行我写的python代码
### 准备
首先我们先安装 pybind11 库, 这是个 head-only 的库, 所以只需要下载源码, 在项目中添加头文件搜索的路径即可
先下载, ~~最简单的方案就是去github下载zip(he~~
为了不出现违法收入, 我们使用`gitee`的镜像, [链接](https://gitee.com/mirrors/pybind11)
直接一键下载或者使用git
```bash
# if has ssh
git clone [email protected]:mirrors/pybind11.git
# or use https
git clone https://gitee.com/mirrors/pybind11.git
```
如果是项目是cmake的话可以直接用 `FetchContent`
```cmake
include(FetchContent)
FetchContent_Declare(
pybind11
GIT_REPOSITORY https://gitee.com/mirrors/pybind11.git
GIT_TAG v2.13
)
FetchContent_MakeAvailable(pybind11)
```
如果环境变量中包含python的路径会自动寻找到python和libpython
可惜的是, 这~~傻逼~~项目用的qmake, 所以我们只能在pro文件里手动加include路径和link路径了
### 使用
这里建议去逛[官方文档](https://pybind11.readthedocs.io/en/stable/index.html), 比我这啰啰嗦嗦好多了, 在这我只讲一些我遇见的坑
1. 解释器需要自己设置`pythonhome`, 不设置的话啥都import不了
但是pybind11库没有提供接口, 只能使用libpython提供的c接口, libpython提供的接口命名又怪的要死
1. 暂留, 之后想起来了再更新
+3
View File
@@ -0,0 +1,3 @@
---
type: categories
---
+27
View File
@@ -0,0 +1,27 @@
.tips {
padding-left: 10px;
background-color: rgba(52,152,219,.3);
border-left: 4px solid rgb(52, 152, 219);
color: darken(rgb(52,152,219), 20%);
}
.success {
padding-left: 10px;
background-color: rgba(46,204,113,.3);
border-left: 4px solid rgb(46,204,113);
color: darken(rgb(46,204,113), 20%);
}
.warning {
padding-left: 10px;
background-color: rgba(241,196,15,.3);
border-left: 4px solid rgb(241,196,15);
color: darken(rgb(241,196,15), 20%);
}
.danger {
padding-left: 10px;
background-color: rgba(231,76,60,.3);
border-left: 4px solid rgb(231,76,60);
color: darken(rgb(231,76,60), 20%);
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 269 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 180 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 195 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 143 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 257 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 542 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 304 KiB

+5
View File
@@ -0,0 +1,5 @@
---
type: tags
layout: tags
comments: false
---
View File
+1836
View File
File diff suppressed because it is too large Load Diff