@eturnity/eturnity_maths 7.2.2-qa-7.2.2 → 7.2.2

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@eturnity/eturnity_maths",
3
- "version": "7.2.2-qa-7.2.2",
3
+ "version": "7.2.2",
4
4
  "author": "Eturnity Team",
5
5
  "main": "src/index.js",
6
6
  "private": false,
package/src/config.js CHANGED
@@ -5,7 +5,7 @@ export const snapToPointTolerance = 15
5
5
  export const snapToIntersectionPointTolerance = 15
6
6
  export const snapToLineTolerance = 10
7
7
  export const distanceToCloseNode = 70
8
- export const mmTolerance=1
8
+ export const mmTolerance=50
9
9
  export const earthRadius=6371008
10
10
 
11
11
  export const layerColors = {
@@ -210,7 +210,27 @@ export class Polygon {
210
210
  if (!this.userDeactivatedPanels) {
211
211
  this.userDeactivatedPanels = []
212
212
  }
213
- const modules = this.data.modules
213
+ const modules = this.panels.map((p) => {
214
+ return {
215
+ index: p.index,
216
+ outline: p.outline.map((v) => [v.x, v.y, v.z]),
217
+ status: p.status || "active",
218
+ clipped: p.clipped === undefined ? false : p.clipped
219
+ }
220
+ })
221
+ const user_deactivated_modules = this.userDeactivatedPanels.map((p) => {
222
+ return {
223
+ index: p.index,
224
+ outline: p.outline.map((v) => [v.x, v.y, v.z]),
225
+ }
226
+ })
227
+ user_deactivated_modules.forEach(p=>{
228
+ modules.push({
229
+ ...p,
230
+ status: p.status || "user_deactivated",
231
+ clipped: p.clipped === undefined ? false : p.clipped
232
+ })
233
+ })
214
234
  return {
215
235
  module_field_uuid: this.id,
216
236
  roof_uuid: this.roof.id,
@@ -16,10 +16,9 @@ import {
16
16
  isAlmostSamePoint2D,
17
17
  getDistanceBetweenPoints
18
18
  } from '../../geometry'
19
- import { maximumGapLimit, mmTolerance } from '../../config'
19
+ import { maximumGapLimit } from '../../config'
20
20
  import { SVD } from 'svd-js'
21
21
  import {updateMarginOutlinePolygon} from './AddMargin'
22
- import { isSelfIntersecting } from '../../intersectionPolygon'
23
22
 
24
23
  //This function calculate derived field from polygon outline and margin outline
25
24
  export function updateComputedGeometryState(state) {
@@ -101,41 +100,28 @@ export function updateComputedGeometryPolygon(polygon) {
101
100
  export function calculateValidOutlineFromPolygon(outline){
102
101
  //check if two nodes are same
103
102
  const nodeIndexToSplit=[]
104
- const nodesToRemove=[]
105
103
  for(let k=0;k<outline.length-1;k++){
106
104
  for(let i=k+1;i<outline.length;i++){
107
- if(isAlmostSamePoint2D(outline[k],outline[i],2*mmTolerance)){
108
- if(i==k+1){
109
- nodesToRemove.push(i)
110
- }else{
111
- nodeIndexToSplit.push([k,i])
112
- }
105
+ if(isAlmostSamePoint2D(outline[k],outline[i],100)){
106
+ nodeIndexToSplit.push([k,i])
113
107
  }
114
108
  }
115
109
  }
116
-
117
110
  for(let coupleToSplit of nodeIndexToSplit){
118
111
  const A = outline[(coupleToSplit[0]-1+outline.length)%outline.length]
119
112
  const B = outline[coupleToSplit[0]]
120
113
  const C = outline[(coupleToSplit[0]+1)%outline.length]
121
- const D = outline[(coupleToSplit[1]-1+outline.length)%outline.length]
122
- const E = outline[coupleToSplit[1]]
123
- const F = outline[(coupleToSplit[1]+1)%outline.length]
124
- let u = normalizedVectorTowardInsideAngle(A,B,C)
125
- let v = normalizedVectorTowardInsideAngle(D,E,F)
126
-
114
+ let v = normalizedVectorTowardInsideAngle(A,B,C)
115
+ // let v0=normalizeVector(substractVector())
127
116
  outline[coupleToSplit[0]] = {
128
- ...addVector(multiplyVector(-mmTolerance,u),B),
117
+ ...addVector(multiplyVector(-50,v),B),
129
118
  z:outline[coupleToSplit[0]].z
130
119
  }
131
120
  outline[coupleToSplit[1]] = {
132
- ...addVector(multiplyVector(mmTolerance,v),E),
121
+ ...addVector(multiplyVector(50,v),B),
133
122
  z:outline[coupleToSplit[1]].z
134
123
  }
135
124
  }
136
- for(let index=nodesToRemove.length-1;index>=0;index--){
137
- outline.splice(nodesToRemove[index],1)
138
- }
139
125
  return outline
140
126
  }
141
127
 
@@ -3,7 +3,6 @@ export function hydratePolygon(serializedPolygon){
3
3
  const layer=serializedPolygon.layer
4
4
  let polygon=new Polygon(serializedPolygon.outline,layer)
5
5
  polygon.id=serializedPolygon.id
6
- polygon.version=serializedPolygon.version
7
6
  polygon.name=serializedPolygon.name
8
7
  polygon.margins=serializedPolygon.margins
9
8
  if(layer=="obstacle"){