@eturnity/eturnity_3d 1.0.13-debug → 1.0.15

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@eturnity/eturnity_3d",
3
3
  "private": false,
4
- "version": "1.0.13-debug",
4
+ "version": "1.0.15",
5
5
  "main": "dist/main.js",
6
6
  "scripts": {
7
7
  "dev": "vue-cli-service serve --skip-plugins @vue/cli-plugin-eslint",
@@ -1,6 +1,8 @@
1
1
  import {
2
2
  isInsidePolygon,
3
3
  verticalProjectionOnPlane,
4
+ intersectOutlines,
5
+ calculateArea
4
6
  } from '@eturnity/eturnity_maths'
5
7
  //this function just update the "roof" and "moduleField(s)" properties of panels,moduleFields and roofs
6
8
  export function UpdateRoofModuleFieldRelations(state) {
@@ -28,16 +30,20 @@ export function UpdateRoofModuleFieldRelations(state) {
28
30
 
29
31
  for (let k in moduleFieldPolygons) {
30
32
  const moduleField = moduleFieldPolygons[k]
33
+ const moduleFieldArea=calculateArea(moduleField.outline)
31
34
  //check if everypoint is in the same roof and if they are not too far from the flat surface.(at least above)
32
- const roofPolygonCandidates = roofPolygons.filter((roof) =>
35
+ let roofPolygonCandidates = roofPolygons.filter((roof) =>
33
36
  {
34
- return moduleField.outline.every(p=>{
35
- console.log(p,roof.margins.innerOutline,isInsidePolygon(p, roof.margins.innerOutline))
36
- return isInsidePolygon(p, roof.margins.innerOutline)
37
- })
37
+ const intersection=intersectOutlines(
38
+ moduleField.outline,
39
+ roof.outline
40
+ )
41
+ if(intersection.length==0) return false
42
+ const intersectionArea=calculateArea(intersection[0])
43
+ return intersectionArea>0.9*moduleFieldArea
44
+
38
45
  }
39
46
  )
40
- console.log(roofPolygonCandidates)
41
47
  //roofs on roof can lead to multiple roof under a point. moduleField is in the smallest
42
48
  let smallestRoof = null
43
49
  for (let roof of roofPolygonCandidates) {
@@ -46,30 +52,10 @@ export function UpdateRoofModuleFieldRelations(state) {
46
52
  }
47
53
  }
48
54
  let roofPolygon = smallestRoof
49
-
50
55
  if (!roofPolygon) {
51
56
  //no roof found under first node of moduleField => moduleField will be deleted
52
57
  continue
53
58
  }
54
- let moduleFieldBelongsToRoof = true
55
- moduleField.outline.forEach((p) => {
56
- const distanceToFlatRoof =
57
- p.z -
58
- verticalProjectionOnPlane(
59
- p,
60
- roofPolygon.normalVector,
61
- roofPolygon.flatOutline[0]
62
- ).z
63
- if (
64
- !isInsidePolygon(p, roofPolygon.margins.innerOutline) ||
65
- distanceToFlatRoof < -1 ||
66
- distanceToFlatRoof > 50
67
- ) {
68
- // one point from moduleField is not inside the roof or too far from it's flat surface => moduleField will be deleted
69
- moduleFieldBelongsToRoof = false
70
- }
71
- })
72
- if (moduleFieldBelongsToRoof) {
73
59
  roofPolygon.moduleFields.push(moduleField)
74
60
  moduleField.roof = roofPolygon
75
61
  moduleField.panels.forEach((panel) => (panel.roof = roofPolygon))
@@ -78,7 +64,7 @@ export function UpdateRoofModuleFieldRelations(state) {
78
64
  p.roof = roofPolygon
79
65
  }
80
66
  })
81
- }
67
+ //}
82
68
  }
83
69
 
84
70
  let newPolygons = state.polygons.map((p) => {