Skip to content

Commit

Permalink
Merge pull request #1 from MarvinZeising/code-style-updates
Browse files Browse the repository at this point in the history
Code style updates
  • Loading branch information
theudebart authored Feb 1, 2025
2 parents dac85f6 + 20b17bb commit 1a63289
Show file tree
Hide file tree
Showing 36 changed files with 289 additions and 280 deletions.
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = tab
insert_final_newline = true
max_line_length = 120
tab_width = 4
trim_trailing_whitespace = true
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ dist
# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# IntelliJ
.idea

# yarn v2
.yarn/cache
.yarn/unplugged
Expand All @@ -123,4 +126,4 @@ desktop.ini
.DS_Store
.Spotlight-V100
.Trashes
._*
._*
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions src/_helpers/ConvexGeometry.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/**
* @author qiao / https://github.com/qiao
* @fileoverview This is a convex hull generator using the incremental method.
* @fileoverview This is a convex hull generator using the incremental method.
* The complexity is O(n^2) where n is the number of vertices.
* O(nlogn) algorithms do exist, but they are much more complicated.
*
* Benchmark:
* Benchmark:
*
* Platform: CPU: P7350 @2.00GHz Engine: V8
*
Expand All @@ -21,7 +21,7 @@ THREE.ConvexGeometry = function( vertices ) {

THREE.Geometry.call( this );

var faces = [ [ 0, 1, 2 ], [ 0, 2, 1 ] ];
var faces = [ [ 0, 1, 2 ], [ 0, 2, 1 ] ];

for ( var i = 3; i < vertices.length; i++ ) {

Expand Down Expand Up @@ -90,7 +90,7 @@ THREE.ConvexGeometry = function( vertices ) {
// construct the new faces formed by the edges of the hole and the vertex
for ( var h = 0; h < hole.length; h++ ) {

faces.push( [
faces.push( [
hole[ h ][ 0 ],
hole[ h ][ 1 ],
vertexId
Expand All @@ -113,7 +113,7 @@ THREE.ConvexGeometry = function( vertices ) {
// distance from face to origin
var dist = n.dot( va );

return n.dot( vertex ) >= dist;
return n.dot( vertex ) >= dist;

}

Expand Down Expand Up @@ -142,7 +142,7 @@ THREE.ConvexGeometry = function( vertices ) {
*/
function equalEdge( ea, eb ) {

return ea[ 0 ] === eb[ 1 ] && ea[ 1 ] === eb[ 0 ];
return ea[ 0 ] === eb[ 1 ] && ea[ 1 ] === eb[ 0 ];

}

Expand Down Expand Up @@ -192,7 +192,7 @@ THREE.ConvexGeometry = function( vertices ) {
// Convert faces into instances of THREE.Face3
for ( var i = 0; i < faces.length; i++ ) {

this.faces.push( new THREE.Face3(
this.faces.push( new THREE.Face3(
faces[ i ][ 0 ],
faces[ i ][ 1 ],
faces[ i ][ 2 ]
Expand Down
2 changes: 1 addition & 1 deletion src/_helpers/handlebars/cmp.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ module.exports = function(lvalue, rvalue, options) {
if( lvalue != rvalue )
return options.inverse(this);
return options.fn(this);
}
}
8 changes: 4 additions & 4 deletions src/_helpers/keyNormalizer.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@ module.exports = (someKey, silent=false, parent = null) ->
if match
gid = match[2] if match[2]
return [match[1], gid]

# it is just the gid
reg = new RegExp '([0-9]+)'
match = reg.exec someKey
if match and parent
parent = parent.split '/'
gid = match[1] if match[1]
return [parent[0], gid]

# it is a short specification
reg = new RegExp '([^\/]+)(?:\/([0-9]+))?'
match = reg.exec someKey
if match
gid = match[2] if match[2]
return [match[1], gid]

if silent
return false

alert "Ungültige Datenquelle: In '#{someKey}' konnte nicht der Tabellen-Key gefunden werden!"
return ["", 0]
5 changes: 2 additions & 3 deletions src/collections/ConstructionList.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ module.exports = class ConstructionList extends Backbone.Collection
selected: null
setSelected: (ds) ->
console.log "CL select: ", ds, @selected
return if ds is @selected
return if ds is @selected
@trigger "unselect", @selected if @selected
@selected = ds
console.log "CL triggered select"
@trigger "select", @selected
@trigger "sync" if @selected.fetched



initialize: (models, options)->
@app = options.app
# console.log "init ConstructionList"
4 changes: 2 additions & 2 deletions src/collections/DataSourceList.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ module.exports = class DataSourceList extends Backbone.Collection
model: DataSource
selected: null
setSelected: (ds) ->
return if ds is @selected
return if ds is @selected
@trigger "unselect", @selected if @selected
@selected = ds
@trigger "select", @selected
@trigger "sync" if @selected.fetched

initialize: (models, options)->
@app = options.app
console.log "init DataSourceList", @app
2 changes: 0 additions & 2 deletions src/collections/ElementList.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,3 @@ module.exports = class extends Backbone.Collection
model: ConstructionElement
initialize: (models, options)->
@app = options.app
# console.log "init ConstructionElements"

28 changes: 14 additions & 14 deletions src/egs/Common.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,31 @@ class EGS_Common_Elements
@RohrDurchmesserAussen = 48.3
@RohrDurchmesserInnen = 45.1
@TellerHoehe = 9

@rohr: (length) ->
Helpers.cylinder @RohrDurchmesserAussen, @RohrDurchmesserInnen, length

@teller: ->
Helpers.cylinder @TellerDurchmesser, @RohrDurchmesserAussen, @TellerHoehe

@rohrverbinder: ->
rv = Helpers.cylinder 45, 30, 400
rv.applyMatrix4 Helpers.matrix(0,0,-200)
rv

@keilKupplungRiegel: ->
vertices = [
[25, 7, 38], [26,0, 38], [25,-7, 38],
[25, 7, 38], [26,0, 38], [25,-7, 38],
[25, 7, 11], [26,0, 11], [25,-7, 11],
[25, 7, -1], [26,0, -1], [25,-7, -1],
[25, 7,-35], [26,0,-35], [25,-7,-35], # 12
[65, 12, 24], [65,-12, 24],
[65, 22, 11], [65,-22, 11],
[65, 22, -1], [65,-22, -1],
[65, 12,-24], [65,-12,-24], # 20
[77, 0, 24], [77,-17, 17],
[77,-24, 0], [77,-17,-17],
[77, 0,-24], [77, 17,-17],
[77, 0, 24], [77,-17, 17],
[77,-24, 0], [77,-17,-17],
[77, 0,-24], [77, 17,-17],
[77, 24, 0], [77, 17, 17]
]
faces = [
Expand All @@ -50,21 +50,21 @@ class EGS_Common_Elements
[26,16,14], [26,14,27], [27,14,12], [27,12,20]
]
new CustomGeometry vertices, faces

@keilKupplungDiagonale: (d, r = 1)->
z = 35
vertices = [
[25, 7, 38], [26,0, 38], [25,-7, 38],
[25, 7, 38], [26,0, 38], [25,-7, 38],
[25, 7, 11], [26,0, 11], [25,-7, 11], # 6
[25, 7, -1], [26,0, -1], [25,-7, -1],
[25, 7,-35], [26,0,-35], [25,-7,-35], # 12
[65, 12, 24], [65,-12, 24],
[65, 22, 11], [65,-22, 11], # 16
[65, 22, -1], [65,-22, -1],
[65, 12,-24], [65,-12,-24], # 20
[65, 1*r, 20], [65, 1*r,-20],
[65, 1*r, 20], [65, 1*r,-20],
[65, 11*r,-20], [65, 11*r, 20], # 24
[65+z, 1*r+z*r, 20], [65+z, 1*r+z*r,-20],
[65+z, 1*r+z*r, 20], [65+z, 1*r+z*r,-20],
[65+z-5, 6*r+z*r,-20], [65+z-5, 6*r+z*r, 20]
]
faces = [
Expand All @@ -74,7 +74,7 @@ class EGS_Common_Elements
[ 7, 6,10], [10, 6, 9], [ 8, 7,11], [11, 7,10], # innen
[ 4, 3,14], [ 4,14,15], [ 5, 4,15], # zwischen
[ 6, 7,16], [ 7,17,16], [ 7, 8,17], # zwischen
[14,17,15], [14,16,17], [14,15,17], [14,17,16],
[14,17,15], [14,16,17], [14,15,17], [14,17,16],
[ 3, 0,14], [ 0,12,14], [16, 9, 6], [18, 9,16], #links
[ 2, 5,15], [ 2,15,13], [17, 8,11], [17,11,19],
[12,13,14], [13,15,14], [16,17,18], [17,19,18], # HINTEN
Expand All @@ -89,7 +89,7 @@ class EGS_Common_Elements
faces.push fd
else
faces.push [fd[1], fd[0], fd[2]]

kkd = new CustomGeometry vertices, faces
kkd.applyMatrix4 Helpers.matrix(0,0,0, 'Z', .5*r*d)
kkd
Expand Down
4 changes: 2 additions & 2 deletions src/egs/Elements.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ Betonblockstein = require("./elements/Betonblockstein")
EuroPalette = require("./elements/EuroPalette")

class EGS_Elements

getGeometry: (element) ->
name = element.get 'element'
x = element.get 'x'
y = element.get 'y'
h = element.get 'h'
direction = element.get 'direction'
special = element.get 'special'

switch name
when "F40" then new GewindeFussPlatte 40, x, y, h, special
when "F60" then new GewindeFussPlatte 60, x, y, h, special
Expand Down
Loading

0 comments on commit 1a63289

Please sign in to comment.