1+ // TODO: Create a material base class
2+ class StructuralMaterial {
3+ constructor ( )
4+ {
5+ this . addInput ( "model_part_name" , "string" ) ;
6+ this . properties = {
7+ "model_part_name" : "Structure.Parts_Solid_Solid_Auto1" ,
8+ "properties_id" : 1 ,
9+ "Material" : {
10+ "constitutive_law" : {
11+ "name" : "LinearElasticPlaneStress2DLaw"
12+ } ,
13+ "Variables" : {
14+ "DENSITY" : 7850.0 ,
15+ "YOUNG_MODULUS" : 206900000000.0 ,
16+ "POISSON_RATIO" : 0.29 ,
17+ "THICKNESS" : 0.1
18+ } ,
19+ "Tables" : { }
20+ }
21+ } ;
22+
23+ this . properties_id = this . addWidget ( "combo" , "Properties_ID" , 1 , function ( v ) { } , { values :[ 1 , 2 , 3 , 4 , 5 ] } ) ;
24+ this . name = this . addWidget ( "text" , "Name" , "LinearElasticPlaneStress2DLaw" , function ( v ) { } , function ( v ) { } , { } ) ;
25+ this . DENSITY = this . addWidget ( "number" , "Density" , 7850.0 , function ( v ) { } , { } ) ;
26+ this . YOUNG_MODULUS = this . addWidget ( "number" , "Young_Modulus" , 206900000000.0 , function ( v ) { } , { } ) ;
27+ this . POISSON_RATIO = this . addWidget ( "number" , "Poisson_Ratio" , 0.29 , function ( v ) { } , { } ) ;
28+ this . THICKNESS = this . addWidget ( "number" , "Thinckness" , 0.1 , function ( v ) { } , { } ) ;
29+ this . addInput ( "tables" , "process_array" ) ;
30+ this . addOutput ( "Material" , "material" ) ;
31+
32+ this . size = this . computeSize ( ) ;
33+ }
34+
35+ onExecute ( )
36+ {
37+ this . _value = Object . assign ( { } , this . properties ) ;
38+
39+ // Current material model part
40+ this . _value [ "model_part_name" ] = this . getInputData ( 0 )
41+
42+ // Table
43+ if ( this . getInputData ( 7 ) != undefined ) {
44+ this . _value [ "Material" ] [ "Table" ] = this . getInputData ( 7 )
45+ } else {
46+ this . _value [ "Material" ] [ "Table" ] = this . properties [ "Table" ]
47+ }
48+ this . _value [ "properties_id" ] = this . properties_id . value
49+ this . _value [ "Material" ] [ "constitutive_law" ] [ "name" ] = this . name . value
50+ this . _value [ "Material" ] [ "Variables" ] [ "DENSITY" ] = this . DENSITY . value
51+ this . _value [ "Material" ] [ "Variables" ] [ "YOUNG_MODULUS" ] = this . YOUNG_MODULUS . value
52+ this . _value [ "Material" ] [ "Variables" ] [ "POISSON_RATIO" ] = this . POISSON_RATIO . value
53+ this . _value [ "Material" ] [ "Variables" ] [ "THICKNESS" ] = this . THICKNESS . value
54+
55+ this . setOutputData ( 0 , this . _value ) ;
56+ }
57+ }
58+
59+ StructuralMaterial . title = "Structural material" ;
60+ StructuralMaterial . desc = "Node to specify a Structurall material." ;
61+
62+ LiteGraph . registerNodeType ( "materials/StructuralMaterial" , StructuralMaterial ) ;
63+
64+ console . log ( "StructuralMaterialNew node created" ) ; //helps to debug
0 commit comments