pyviewfactor 1.0.1__tar.gz → 1.0.3__tar.gz
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.
- pyviewfactor-1.0.3/PKG-INFO +183 -0
- pyviewfactor-1.0.3/README.md +161 -0
- {pyviewfactor-1.0.1 → pyviewfactor-1.0.3}/pyviewfactor/__init__.py +4 -2
- {pyviewfactor-1.0.1 → pyviewfactor-1.0.3}/pyviewfactor/_version.py +2 -1
- {pyviewfactor-1.0.1 → pyviewfactor-1.0.3}/pyviewfactor/pvf_geometry_preprocess.py +160 -13
- {pyviewfactor-1.0.1 → pyviewfactor-1.0.3}/pyviewfactor/pvf_integrators.py +2 -0
- {pyviewfactor-1.0.1 → pyviewfactor-1.0.3}/pyviewfactor/pvf_plot.py +1 -0
- {pyviewfactor-1.0.1 → pyviewfactor-1.0.3}/pyviewfactor/pvf_viewfactor_computations.py +95 -55
- {pyviewfactor-1.0.1 → pyviewfactor-1.0.3}/pyviewfactor/pvf_visibility_obstruction.py +213 -74
- pyviewfactor-1.0.3/pyviewfactor.egg-info/PKG-INFO +183 -0
- {pyviewfactor-1.0.1 → pyviewfactor-1.0.3}/pyviewfactor.egg-info/SOURCES.txt +2 -1
- {pyviewfactor-1.0.1 → pyviewfactor-1.0.3}/setup.cfg +2 -2
- pyviewfactor-1.0.3/setup.py +6 -0
- {pyviewfactor-1.0.1 → pyviewfactor-1.0.3}/test/test_geometry_preprocess.py +41 -0
- {pyviewfactor-1.0.1 → pyviewfactor-1.0.3}/test/test_view_factor.py +208 -0
- {pyviewfactor-1.0.1 → pyviewfactor-1.0.3}/test/test_visibility_obstruction.py +134 -6
- pyviewfactor-1.0.3/test/test_visibility_obstruction_semantics.py +462 -0
- pyviewfactor-1.0.1/PKG-INFO +0 -487
- pyviewfactor-1.0.1/README.md +0 -466
- pyviewfactor-1.0.1/pyviewfactor.egg-info/PKG-INFO +0 -487
- pyviewfactor-1.0.1/setup.py +0 -7
- {pyviewfactor-1.0.1 → pyviewfactor-1.0.3}/LICENSE.txt +0 -0
- {pyviewfactor-1.0.1 → pyviewfactor-1.0.3}/pyviewfactor.egg-info/dependency_links.txt +0 -0
- {pyviewfactor-1.0.1 → pyviewfactor-1.0.3}/pyviewfactor.egg-info/requires.txt +0 -0
- {pyviewfactor-1.0.1 → pyviewfactor-1.0.3}/pyviewfactor.egg-info/top_level.txt +0 -0
- {pyviewfactor-1.0.1 → pyviewfactor-1.0.3}/test/__init__.py +0 -0
- {pyviewfactor-1.0.1 → pyviewfactor-1.0.3}/test/test_plot.py +0 -0
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pyviewfactor
|
|
3
|
+
Version: 1.0.3
|
|
4
|
+
Summary: "A lightweight open-source Python library for exact view-factor computations on polygonal meshes"
|
|
5
|
+
Home-page: https://gitlab.com/arep-dev/pyViewFactor/
|
|
6
|
+
Author: Mateusz BOGDAN, Edouard WALTHER
|
|
7
|
+
Author-email: mateusz.bogdan@arep.fr
|
|
8
|
+
License: MIT
|
|
9
|
+
Keywords: radiative-transfer,radiation,vtk,geometry,viewfactor,visibility
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Requires-Python: >=3.10
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE.txt
|
|
17
|
+
Requires-Dist: numpy>=1.26
|
|
18
|
+
Requires-Dist: scipy>=1.11
|
|
19
|
+
Requires-Dist: numba>=0.61
|
|
20
|
+
Requires-Dist: pyvista>=0.45
|
|
21
|
+
Dynamic: license-file
|
|
22
|
+
|
|
23
|
+
# PyViewFactor
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
<div align="center">
|
|
27
|
+
<img src="https://gitlab.com/arep-dev/pyViewFactor/-/raw/da36d4a0b08308009d9e71876091492ecb97d476/img/Logo%20pVF%20512x512%20v3%20transparent%20crop.png" alt="pvf_logo" width="256px"/>
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
> `pyViewFactor` is a lightweight open-source Python library for exact view-factor computations on polygonal meshes.
|
|
32
|
+
> It provides robust tools for:
|
|
33
|
+
> - geometric visibility analysis,
|
|
34
|
+
> - obstruction detection,
|
|
35
|
+
> - accurate view factor computation.
|
|
36
|
+
|
|
37
|
+
*Full documentation available [here](https://arep-dev.gitlab.io/pyViewFactor/).*
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
<img src="https://gitlab.com/arep-dev/pyViewFactor/-/raw/3d40d1804eccbaefbc8b1736ff30d0d9f08141ad/img/FF_sceneUrbaine_cyl_RT.png" alt="Urban View Factor" width="800" />
|
|
41
|
+
|
|
42
|
+
[](https://gitlab.com/arep-dev/pyViewFactor/-/releases)
|
|
43
|
+
[](https://gitlab.com/arep-dev/pyViewFactor/pipelines)
|
|
44
|
+
[](https://codecov.io/gl/arep-dev/pyViewFactor)
|
|
45
|
+
[](https://opensource.org/licenses/MIT)
|
|
46
|
+
[](https://pypi.org/project/pyviewfactor/)
|
|
47
|
+
[](https://pypi.org/project/pyviewfactor/)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
## Features
|
|
52
|
+
|
|
53
|
+
* This library enables the computation of radiation view factors between planar polygons using an **accurate** double‐contour integration method described in
|
|
54
|
+
[(Mazumder and Ravishankar 2012)](https://www.academia.edu/download/77459051/Viewfactor_paper_IJHMT.pdf)
|
|
55
|
+
with insights from [(Schmid 2016)](https://hal.archives-ouvertes.fr/tel-01734545/).
|
|
56
|
+
* It uses the handy [`Pyvista`](https://docs.pyvista.org/) package to deal with geometry imports (`*.stl`, `*.vtk`, `*.obj`, ...),
|
|
57
|
+
geometry creations, and some other mesh functionalities under the hood.
|
|
58
|
+
* It enables:
|
|
59
|
+
- 🔺 View factor computation between planar polygons
|
|
60
|
+
- 👁️ Visibility checks based on face orientation
|
|
61
|
+
- 🚧 Obstruction detection using ray-triangle intersection
|
|
62
|
+
- ⚙️ Strict / non-strict modes for robustness control
|
|
63
|
+
- ⚡ Optimized full matrix computation with caching
|
|
64
|
+
- 📦 Built on `numpy`, `scipy`, `pyvista`, `numba`
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
## Installation
|
|
69
|
+
`pyViewFactor` can be installed from [PyPi](https://pypi.org/project/pyviewfactor/)
|
|
70
|
+
using `pip` on Python >= 3.10:
|
|
71
|
+
```shell
|
|
72
|
+
pip install pyviewfactor
|
|
73
|
+
```
|
|
74
|
+
You can also visit [PyPi](https://pypi.org/project/pyviewfactor/) or
|
|
75
|
+
[Gitlab](https://gitlab.com/arep-dev/pyViewFactor) to download the sources.
|
|
76
|
+
|
|
77
|
+
Requirements:
|
|
78
|
+
```
|
|
79
|
+
numpy==1.26.4
|
|
80
|
+
pyvista==0.45
|
|
81
|
+
scipy==1.11.4
|
|
82
|
+
numba==0.61.2
|
|
83
|
+
tqdm==4.65.0
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
The code will probably work with lower versions of the required packages, however this has not been tested.
|
|
87
|
+
|
|
88
|
+
> [!NOTE]
|
|
89
|
+
> If you are alergic to `numba`, you may `pip install pyviewfactor==0.0.10` that works (and give up the times 3+ speed-up in view factor computation).
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
## Quick Start
|
|
93
|
+
|
|
94
|
+
Suppose we want to compute the radiation view factor between a triangle
|
|
95
|
+
and a rectangle facing each other:
|
|
96
|
+
|
|
97
|
+
<img src="https://gitlab.com/arep-dev/pyViewFactor/-/raw/9dbd31d124eb898cc5d17913cfc1f010116e2245/img/mwe.png" alt="Triangle and rectangle configuration" width="260"/>
|
|
98
|
+
|
|
99
|
+
You are few lines of code away from your first view factor computation:
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
import pyvista as pv
|
|
103
|
+
import pyviewfactor as pvf
|
|
104
|
+
|
|
105
|
+
# Create a rectangle and a triangle facing each other
|
|
106
|
+
pointa1 = [0.0, 0.0, 0.0]
|
|
107
|
+
pointb1 = [1.0, 0.0, 0.0]
|
|
108
|
+
pointc1 = [0.0, 1.0, 0.0]
|
|
109
|
+
rectangle = pv.Rectangle([pointa1, pointb1, pointc1])
|
|
110
|
+
|
|
111
|
+
pointa2 = [0.0, 0.0, 1.0]
|
|
112
|
+
pointb2 = [0.0, 1.0, 1.0]
|
|
113
|
+
pointc2 = [1.0, 1.0, 1.0]
|
|
114
|
+
triangle = pv.Triangle([pointa2, pointb2, pointc2])
|
|
115
|
+
|
|
116
|
+
if pvf.get_visibility(rectangle, triangle)[0]:
|
|
117
|
+
F = pvf.compute_viewfactor(triangle, rectangle)
|
|
118
|
+
print("VF from rectangle to triangle :", F)
|
|
119
|
+
else:
|
|
120
|
+
print("Not facing each other")
|
|
121
|
+
|
|
122
|
+
pl = pv.Plotter()
|
|
123
|
+
pl.add_mesh(rectangle, color="lightblue", opacity=0.7)
|
|
124
|
+
pl.add_mesh(triangle, color="salmon", opacity=0.7)
|
|
125
|
+
|
|
126
|
+
# compute and glyph normals for mesh1
|
|
127
|
+
n1 = rectangle.compute_normals(cell_normals=True, point_normals=False)
|
|
128
|
+
arrows1 = n1.glyph(orient="Normals", factor=0.1)
|
|
129
|
+
pl.add_mesh(arrows1, color="blue")
|
|
130
|
+
# similarly for mesh2
|
|
131
|
+
n2 = triangle.compute_normals(cell_normals=True, point_normals=False)
|
|
132
|
+
arrows2 = n2.glyph(orient="Normals", factor=0.1)
|
|
133
|
+
pl.add_mesh(arrows2, color="darkred")
|
|
134
|
+
|
|
135
|
+
pl.show()
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
You usually get your geometry from a different format?
|
|
139
|
+
(`*.dat`, `*.idf`, ...)
|
|
140
|
+
|
|
141
|
+
Check pyvista's documentation on [how to generate a PolyData facet from points](https://docs.pyvista.org/examples/00-load/create-poly.html).
|
|
142
|
+
|
|
143
|
+
## Documentation
|
|
144
|
+
|
|
145
|
+
For detailed explanations and advanced usage, see:
|
|
146
|
+
|
|
147
|
+
https://arep-dev.gitlab.io/pyViewFactor/pyviewfactor.html
|
|
148
|
+
|
|
149
|
+
The documentation includes:
|
|
150
|
+
* Visibility and obstruction semantics,
|
|
151
|
+
* Strict vs non-strict modes,
|
|
152
|
+
* Geometry preprocessing utilities,
|
|
153
|
+
* Numerical robustness guidelines,
|
|
154
|
+
* Extended examples (that can also be found in the `examples/` folder of the repository).
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
## Citation & Acknowledgments
|
|
158
|
+
* Main contributors:
|
|
159
|
+
* Mateusz BOGDAN,
|
|
160
|
+
* Edouard WALTHER.
|
|
161
|
+
* Acknowledgment: The authors would like to acknowledge *M. Alecian* for his initial work on the quadrature
|
|
162
|
+
code and *M. Chapon* for her contribution to the code validation.
|
|
163
|
+
|
|
164
|
+
There is even a [conference paper](https://www.researchgate.net/publication/360835982_Calcul_des_facteurs_de_forme_entre_polygones_-Application_a_la_thermique_urbaine_et_aux_etudes_de_confort), showing analytical validations.
|
|
165
|
+
|
|
166
|
+
So if you use `pyViewFactor` in your work, please cite:
|
|
167
|
+
> [!IMPORTANT] Citation:
|
|
168
|
+
> Mateusz BOGDAN, Edouard WALTHER, Marc ALECIAN and Mina CHAPON. *Calcul des facteurs de forme entre polygones - Application à la thermique urbaine et aux études de confort*. IBPSA France 2022, Châlons-en-Champagne.
|
|
169
|
+
|
|
170
|
+
Bibtex entry:
|
|
171
|
+
``` latex
|
|
172
|
+
@inproceedings{pyViewFactor22bogdan,
|
|
173
|
+
authors = "Mateusz BOGDAN and Edouard WALTHER and Marc ALECIAN and Mina CHAPON",
|
|
174
|
+
title = "Calcul des facteurs de forme entre polygones - Application à la thermique urbaine et aux études de confort",
|
|
175
|
+
year = "2022",
|
|
176
|
+
organization = "IBPSA France",
|
|
177
|
+
venue = "Châlons-en-Champagne, France"
|
|
178
|
+
note = "IBPSA France 2022",
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## License
|
|
183
|
+
MIT License - Copyright (c) AREP 2025
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# PyViewFactor
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
<div align="center">
|
|
5
|
+
<img src="https://gitlab.com/arep-dev/pyViewFactor/-/raw/da36d4a0b08308009d9e71876091492ecb97d476/img/Logo%20pVF%20512x512%20v3%20transparent%20crop.png" alt="pvf_logo" width="256px"/>
|
|
6
|
+
</div>
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
> `pyViewFactor` is a lightweight open-source Python library for exact view-factor computations on polygonal meshes.
|
|
10
|
+
> It provides robust tools for:
|
|
11
|
+
> - geometric visibility analysis,
|
|
12
|
+
> - obstruction detection,
|
|
13
|
+
> - accurate view factor computation.
|
|
14
|
+
|
|
15
|
+
*Full documentation available [here](https://arep-dev.gitlab.io/pyViewFactor/).*
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
<img src="https://gitlab.com/arep-dev/pyViewFactor/-/raw/3d40d1804eccbaefbc8b1736ff30d0d9f08141ad/img/FF_sceneUrbaine_cyl_RT.png" alt="Urban View Factor" width="800" />
|
|
19
|
+
|
|
20
|
+
[](https://gitlab.com/arep-dev/pyViewFactor/-/releases)
|
|
21
|
+
[](https://gitlab.com/arep-dev/pyViewFactor/pipelines)
|
|
22
|
+
[](https://codecov.io/gl/arep-dev/pyViewFactor)
|
|
23
|
+
[](https://opensource.org/licenses/MIT)
|
|
24
|
+
[](https://pypi.org/project/pyviewfactor/)
|
|
25
|
+
[](https://pypi.org/project/pyviewfactor/)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
## Features
|
|
30
|
+
|
|
31
|
+
* This library enables the computation of radiation view factors between planar polygons using an **accurate** double‐contour integration method described in
|
|
32
|
+
[(Mazumder and Ravishankar 2012)](https://www.academia.edu/download/77459051/Viewfactor_paper_IJHMT.pdf)
|
|
33
|
+
with insights from [(Schmid 2016)](https://hal.archives-ouvertes.fr/tel-01734545/).
|
|
34
|
+
* It uses the handy [`Pyvista`](https://docs.pyvista.org/) package to deal with geometry imports (`*.stl`, `*.vtk`, `*.obj`, ...),
|
|
35
|
+
geometry creations, and some other mesh functionalities under the hood.
|
|
36
|
+
* It enables:
|
|
37
|
+
- 🔺 View factor computation between planar polygons
|
|
38
|
+
- 👁️ Visibility checks based on face orientation
|
|
39
|
+
- 🚧 Obstruction detection using ray-triangle intersection
|
|
40
|
+
- ⚙️ Strict / non-strict modes for robustness control
|
|
41
|
+
- ⚡ Optimized full matrix computation with caching
|
|
42
|
+
- 📦 Built on `numpy`, `scipy`, `pyvista`, `numba`
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
## Installation
|
|
47
|
+
`pyViewFactor` can be installed from [PyPi](https://pypi.org/project/pyviewfactor/)
|
|
48
|
+
using `pip` on Python >= 3.10:
|
|
49
|
+
```shell
|
|
50
|
+
pip install pyviewfactor
|
|
51
|
+
```
|
|
52
|
+
You can also visit [PyPi](https://pypi.org/project/pyviewfactor/) or
|
|
53
|
+
[Gitlab](https://gitlab.com/arep-dev/pyViewFactor) to download the sources.
|
|
54
|
+
|
|
55
|
+
Requirements:
|
|
56
|
+
```
|
|
57
|
+
numpy==1.26.4
|
|
58
|
+
pyvista==0.45
|
|
59
|
+
scipy==1.11.4
|
|
60
|
+
numba==0.61.2
|
|
61
|
+
tqdm==4.65.0
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
The code will probably work with lower versions of the required packages, however this has not been tested.
|
|
65
|
+
|
|
66
|
+
> [!NOTE]
|
|
67
|
+
> If you are alergic to `numba`, you may `pip install pyviewfactor==0.0.10` that works (and give up the times 3+ speed-up in view factor computation).
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
## Quick Start
|
|
71
|
+
|
|
72
|
+
Suppose we want to compute the radiation view factor between a triangle
|
|
73
|
+
and a rectangle facing each other:
|
|
74
|
+
|
|
75
|
+
<img src="https://gitlab.com/arep-dev/pyViewFactor/-/raw/9dbd31d124eb898cc5d17913cfc1f010116e2245/img/mwe.png" alt="Triangle and rectangle configuration" width="260"/>
|
|
76
|
+
|
|
77
|
+
You are few lines of code away from your first view factor computation:
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
import pyvista as pv
|
|
81
|
+
import pyviewfactor as pvf
|
|
82
|
+
|
|
83
|
+
# Create a rectangle and a triangle facing each other
|
|
84
|
+
pointa1 = [0.0, 0.0, 0.0]
|
|
85
|
+
pointb1 = [1.0, 0.0, 0.0]
|
|
86
|
+
pointc1 = [0.0, 1.0, 0.0]
|
|
87
|
+
rectangle = pv.Rectangle([pointa1, pointb1, pointc1])
|
|
88
|
+
|
|
89
|
+
pointa2 = [0.0, 0.0, 1.0]
|
|
90
|
+
pointb2 = [0.0, 1.0, 1.0]
|
|
91
|
+
pointc2 = [1.0, 1.0, 1.0]
|
|
92
|
+
triangle = pv.Triangle([pointa2, pointb2, pointc2])
|
|
93
|
+
|
|
94
|
+
if pvf.get_visibility(rectangle, triangle)[0]:
|
|
95
|
+
F = pvf.compute_viewfactor(triangle, rectangle)
|
|
96
|
+
print("VF from rectangle to triangle :", F)
|
|
97
|
+
else:
|
|
98
|
+
print("Not facing each other")
|
|
99
|
+
|
|
100
|
+
pl = pv.Plotter()
|
|
101
|
+
pl.add_mesh(rectangle, color="lightblue", opacity=0.7)
|
|
102
|
+
pl.add_mesh(triangle, color="salmon", opacity=0.7)
|
|
103
|
+
|
|
104
|
+
# compute and glyph normals for mesh1
|
|
105
|
+
n1 = rectangle.compute_normals(cell_normals=True, point_normals=False)
|
|
106
|
+
arrows1 = n1.glyph(orient="Normals", factor=0.1)
|
|
107
|
+
pl.add_mesh(arrows1, color="blue")
|
|
108
|
+
# similarly for mesh2
|
|
109
|
+
n2 = triangle.compute_normals(cell_normals=True, point_normals=False)
|
|
110
|
+
arrows2 = n2.glyph(orient="Normals", factor=0.1)
|
|
111
|
+
pl.add_mesh(arrows2, color="darkred")
|
|
112
|
+
|
|
113
|
+
pl.show()
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
You usually get your geometry from a different format?
|
|
117
|
+
(`*.dat`, `*.idf`, ...)
|
|
118
|
+
|
|
119
|
+
Check pyvista's documentation on [how to generate a PolyData facet from points](https://docs.pyvista.org/examples/00-load/create-poly.html).
|
|
120
|
+
|
|
121
|
+
## Documentation
|
|
122
|
+
|
|
123
|
+
For detailed explanations and advanced usage, see:
|
|
124
|
+
|
|
125
|
+
https://arep-dev.gitlab.io/pyViewFactor/pyviewfactor.html
|
|
126
|
+
|
|
127
|
+
The documentation includes:
|
|
128
|
+
* Visibility and obstruction semantics,
|
|
129
|
+
* Strict vs non-strict modes,
|
|
130
|
+
* Geometry preprocessing utilities,
|
|
131
|
+
* Numerical robustness guidelines,
|
|
132
|
+
* Extended examples (that can also be found in the `examples/` folder of the repository).
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
## Citation & Acknowledgments
|
|
136
|
+
* Main contributors:
|
|
137
|
+
* Mateusz BOGDAN,
|
|
138
|
+
* Edouard WALTHER.
|
|
139
|
+
* Acknowledgment: The authors would like to acknowledge *M. Alecian* for his initial work on the quadrature
|
|
140
|
+
code and *M. Chapon* for her contribution to the code validation.
|
|
141
|
+
|
|
142
|
+
There is even a [conference paper](https://www.researchgate.net/publication/360835982_Calcul_des_facteurs_de_forme_entre_polygones_-Application_a_la_thermique_urbaine_et_aux_etudes_de_confort), showing analytical validations.
|
|
143
|
+
|
|
144
|
+
So if you use `pyViewFactor` in your work, please cite:
|
|
145
|
+
> [!IMPORTANT] Citation:
|
|
146
|
+
> Mateusz BOGDAN, Edouard WALTHER, Marc ALECIAN and Mina CHAPON. *Calcul des facteurs de forme entre polygones - Application à la thermique urbaine et aux études de confort*. IBPSA France 2022, Châlons-en-Champagne.
|
|
147
|
+
|
|
148
|
+
Bibtex entry:
|
|
149
|
+
``` latex
|
|
150
|
+
@inproceedings{pyViewFactor22bogdan,
|
|
151
|
+
authors = "Mateusz BOGDAN and Edouard WALTHER and Marc ALECIAN and Mina CHAPON",
|
|
152
|
+
title = "Calcul des facteurs de forme entre polygones - Application à la thermique urbaine et aux études de confort",
|
|
153
|
+
year = "2022",
|
|
154
|
+
organization = "IBPSA France",
|
|
155
|
+
venue = "Châlons-en-Champagne, France"
|
|
156
|
+
note = "IBPSA France 2022",
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## License
|
|
161
|
+
MIT License - Copyright (c) AREP 2025
|
|
@@ -47,7 +47,40 @@ def fc_unstruc2poly(mesh_unstruc):
|
|
|
47
47
|
return pv.PolyData(points, faces)
|
|
48
48
|
|
|
49
49
|
|
|
50
|
-
def
|
|
50
|
+
def count_shared_vertices(pts1, pts2, rounding_decimal=8):
|
|
51
|
+
"""
|
|
52
|
+
Count the number of shared vertices between two faces after rounding.
|
|
53
|
+
|
|
54
|
+
Parameters
|
|
55
|
+
----------
|
|
56
|
+
* **pts1** : *numpy.ndarray*, shape (n1, 3)
|
|
57
|
+
|
|
58
|
+
> Vertex coordinates of the first face.
|
|
59
|
+
|
|
60
|
+
* **pts2** : *numpy.ndarray*, shape (n2, 3)
|
|
61
|
+
|
|
62
|
+
> Vertex coordinates of the second face.
|
|
63
|
+
|
|
64
|
+
* **rounding_decimal** : *int*, optional
|
|
65
|
+
|
|
66
|
+
> Number of decimals used to round coordinates before comparison.
|
|
67
|
+
|
|
68
|
+
Returns
|
|
69
|
+
-------
|
|
70
|
+
* *int*
|
|
71
|
+
|
|
72
|
+
> Number of shared vertices.
|
|
73
|
+
|
|
74
|
+
* *set[tuple]*
|
|
75
|
+
|
|
76
|
+
> Set of rounded shared vertex coordinates.
|
|
77
|
+
"""
|
|
78
|
+
set1 = {tuple(np.round(p, rounding_decimal)) for p in pts1}
|
|
79
|
+
set2 = {tuple(np.round(p, rounding_decimal)) for p in pts2}
|
|
80
|
+
return len(set1 & set2), set1 & set2
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def face_to_array(face, rounding_decimal=8):
|
|
51
84
|
"""
|
|
52
85
|
Extract the vertex coordinates of a single PolyData face as a NumPy array.
|
|
53
86
|
|
|
@@ -288,11 +321,6 @@ class ProcessedGeometry:
|
|
|
288
321
|
self.sizes = np.zeros(self.N, dtype=np.float64)
|
|
289
322
|
|
|
290
323
|
for i in range(self.N):
|
|
291
|
-
# raw = mesh.extract_cells(i)
|
|
292
|
-
# face = fc_unstruc2poly(raw)
|
|
293
|
-
# faces_i = face.faces
|
|
294
|
-
# n_i = int(faces_i[0])
|
|
295
|
-
# idxs = faces_i[1:1 + n_i]
|
|
296
324
|
raw = mesh.extract_cells(i)
|
|
297
325
|
face = fc_unstruc2poly(raw)
|
|
298
326
|
pts = face.get_cell(0).points.round(rounding_decimal).astype(np.float64)
|
|
@@ -300,29 +328,101 @@ class ProcessedGeometry:
|
|
|
300
328
|
self.points.append(pts)
|
|
301
329
|
self.centroids[i] = polygon_centroid(pts)
|
|
302
330
|
|
|
303
|
-
|
|
304
|
-
v2 = pts[2] - pts[0]
|
|
305
|
-
norm = np.cross(v1, v2)
|
|
306
|
-
self.normals[i] = norm / np.linalg.norm(norm)
|
|
331
|
+
self.normals[i] = face_normal_numpy(pts)
|
|
307
332
|
|
|
308
|
-
self.areas[i] = polygon_area(
|
|
333
|
+
self.areas[i] = polygon_area(pts)
|
|
309
334
|
edges = np.roll(pts, -1, axis=0) - pts
|
|
310
335
|
edge_lengths = np.linalg.norm(edges, axis=1)
|
|
311
336
|
self.sizes[i] = np.mean(edge_lengths)
|
|
312
337
|
|
|
313
338
|
def get_face(self, i):
|
|
339
|
+
"""
|
|
340
|
+
Return the rounded vertex coordinates of face `i`.
|
|
341
|
+
|
|
342
|
+
Parameters
|
|
343
|
+
----------
|
|
344
|
+
* **i** : *int*
|
|
345
|
+
|
|
346
|
+
> Face index.
|
|
347
|
+
|
|
348
|
+
Returns
|
|
349
|
+
-------
|
|
350
|
+
* *numpy.ndarray*, shape (n, 3)
|
|
351
|
+
|
|
352
|
+
> Ordered vertex coordinates of the face.
|
|
353
|
+
"""
|
|
314
354
|
return self.points[i]
|
|
315
355
|
|
|
316
356
|
def get_normal(self, i):
|
|
357
|
+
"""
|
|
358
|
+
Return the unit normal vector of face `i`.
|
|
359
|
+
|
|
360
|
+
Parameters
|
|
361
|
+
----------
|
|
362
|
+
* **i** : *int*
|
|
363
|
+
|
|
364
|
+
> Face index.
|
|
365
|
+
|
|
366
|
+
Returns
|
|
367
|
+
-------
|
|
368
|
+
* *numpy.ndarray*, shape (3,)
|
|
369
|
+
|
|
370
|
+
> Unit normal vector of the face.
|
|
371
|
+
"""
|
|
317
372
|
return self.normals[i]
|
|
318
373
|
|
|
319
374
|
def get_centroid(self, i):
|
|
375
|
+
"""
|
|
376
|
+
Return the centroid of face `i`.
|
|
377
|
+
|
|
378
|
+
Parameters
|
|
379
|
+
----------
|
|
380
|
+
* **i** : *int*
|
|
381
|
+
|
|
382
|
+
> Face index.
|
|
383
|
+
|
|
384
|
+
Returns
|
|
385
|
+
-------
|
|
386
|
+
* *numpy.ndarray*, shape (3,)
|
|
387
|
+
|
|
388
|
+
> Area-weighted centroid of the face.
|
|
389
|
+
"""
|
|
320
390
|
return self.centroids[i]
|
|
321
391
|
|
|
322
392
|
def get_area(self, i):
|
|
393
|
+
"""
|
|
394
|
+
Return the area of face `i`.
|
|
395
|
+
|
|
396
|
+
Parameters
|
|
397
|
+
----------
|
|
398
|
+
* **i** : *int*
|
|
399
|
+
|
|
400
|
+
> Face index.
|
|
401
|
+
|
|
402
|
+
Returns
|
|
403
|
+
-------
|
|
404
|
+
* *float*
|
|
405
|
+
|
|
406
|
+
> Area of the face.
|
|
407
|
+
"""
|
|
323
408
|
return self.areas[i]
|
|
324
409
|
|
|
325
410
|
def get_size(self, i):
|
|
411
|
+
"""
|
|
412
|
+
Return the characteristic size of face `i`.
|
|
413
|
+
|
|
414
|
+
Parameters
|
|
415
|
+
----------
|
|
416
|
+
* **i** : *int*
|
|
417
|
+
|
|
418
|
+
> Face index.
|
|
419
|
+
|
|
420
|
+
Returns
|
|
421
|
+
-------
|
|
422
|
+
* *float*
|
|
423
|
+
|
|
424
|
+
> Mean edge length of the face.
|
|
425
|
+
"""
|
|
326
426
|
return self.sizes[i]
|
|
327
427
|
|
|
328
428
|
|
|
@@ -367,6 +467,25 @@ class FaceMeshPreprocessor:
|
|
|
367
467
|
self.triangles = np.array([self.points[c] for c in cells], dtype=np.float64)
|
|
368
468
|
|
|
369
469
|
def aabb_filter(self, aabb_min, aabb_max):
|
|
470
|
+
"""
|
|
471
|
+
Filter obstacle triangles by axis-aligned bounding box overlap.
|
|
472
|
+
|
|
473
|
+
Parameters
|
|
474
|
+
----------
|
|
475
|
+
* **aabb_min** : *numpy.ndarray*, shape (3,)
|
|
476
|
+
|
|
477
|
+
> Minimum coordinates of the bounding box.
|
|
478
|
+
|
|
479
|
+
* **aabb_max** : *numpy.ndarray*, shape (3,)
|
|
480
|
+
|
|
481
|
+
> Maximum coordinates of the bounding box.
|
|
482
|
+
|
|
483
|
+
Returns
|
|
484
|
+
-------
|
|
485
|
+
* *numpy.ndarray*, shape (m, 3, 3)
|
|
486
|
+
|
|
487
|
+
> Triangles overlapping the bounding box.
|
|
488
|
+
"""
|
|
370
489
|
kept = []
|
|
371
490
|
for tri in self.triangles: # tri.shape == (3,3)
|
|
372
491
|
if tri_overlaps_aabb(tri, aabb_min, aabb_max):
|
|
@@ -374,17 +493,45 @@ class FaceMeshPreprocessor:
|
|
|
374
493
|
return np.array(kept, dtype=np.float64)
|
|
375
494
|
|
|
376
495
|
def exclude_exact_match(self, pts1, pts2, tris, rounding_decimal=8):
|
|
496
|
+
"""
|
|
497
|
+
Remove triangles that exactly match either of the tested faces.
|
|
498
|
+
|
|
499
|
+
Parameters
|
|
500
|
+
----------
|
|
501
|
+
* **pts1** : *numpy.ndarray*, shape (n1, 3)
|
|
502
|
+
|
|
503
|
+
> Vertex coordinates of the first tested face.
|
|
504
|
+
|
|
505
|
+
* **pts2** : *numpy.ndarray*, shape (n2, 3)
|
|
506
|
+
|
|
507
|
+
> Vertex coordinates of the second tested face.
|
|
508
|
+
|
|
509
|
+
* **tris** : *numpy.ndarray*, shape (m, 3, 3)
|
|
510
|
+
|
|
511
|
+
> Candidate obstacle triangles.
|
|
512
|
+
|
|
513
|
+
* **rounding_decimal** : *int*, optional
|
|
514
|
+
|
|
515
|
+
> Number of decimals used before comparing triangle vertices.
|
|
516
|
+
|
|
517
|
+
Returns
|
|
518
|
+
-------
|
|
519
|
+
* *numpy.ndarray*
|
|
520
|
+
|
|
521
|
+
> Candidate triangles excluding those identical to `pts1` or `pts2`.
|
|
522
|
+
"""
|
|
377
523
|
# build frozensets of each vertex array
|
|
378
524
|
vs1 = frozenset(sorted(tuple(np.round(p, rounding_decimal)) for p in pts1))
|
|
379
525
|
vs2 = frozenset(sorted(tuple(np.round(p, rounding_decimal)) for p in pts2))
|
|
380
526
|
out = []
|
|
381
527
|
for tri in tris:
|
|
382
|
-
tri_set = frozenset(
|
|
528
|
+
tri_set = frozenset(
|
|
529
|
+
sorted(tuple(np.round(p, rounding_decimal)) for p in tri)
|
|
530
|
+
)
|
|
383
531
|
# if not tri_set.isdisjoint(vs1) or not tri_set.isdisjoint(vs2):
|
|
384
532
|
if tri_set == vs1 or tri_set == vs2:
|
|
385
533
|
continue
|
|
386
534
|
out.append(tri)
|
|
387
535
|
return np.array(out, dtype=np.float64)
|
|
388
536
|
|
|
389
|
-
# #-----------------------------------------------------------------------------------#
|
|
390
537
|
# End of File
|