|
| 1 | +// Global variables |
| 2 | + |
| 3 | +const points_defaultVisibility = true; |
| 4 | +const edges_defaultVisibility = true; |
| 5 | +const polygons_defaultVisibility = true; |
| 6 | +const polyhedra_defaultVisibility = true; |
| 7 | +const points_defaultSize = 10; |
| 8 | +const points_defaultColor = { r: 20, g: 20, b: 20 }; |
| 9 | +const edges_defaultSize = 5; |
| 10 | +const edges_defaultColor = { r: 20, g: 20, b: 20 }; |
| 11 | +const polygons_defaultColor = { r: 255, g: 255, b: 255 }; |
| 12 | +const polyhedra_defaultColor = { r: 255, g: 255, b: 255 }; |
| 13 | + |
| 14 | +const corners_defaultVisibility = true; |
| 15 | +const lines_defaultVisibility = true; |
| 16 | +const surfaces_defaultVisibility = true; |
| 17 | +const blocks_defaultVisibility = true; |
| 18 | +const lines_defaultColor = { r: 20, g: 20, b: 20 }; |
| 19 | + |
| 20 | +// Mesh functions |
| 21 | +const meshPointsDefaultStyle = ( |
| 22 | + visibility = points_defaultVisibility, |
| 23 | + size = points_defaultSize, |
| 24 | + color = points_defaultColor |
| 25 | +) => { |
| 26 | + return { |
| 27 | + visibility, |
| 28 | + coloring: { |
| 29 | + active: "color", |
| 30 | + color, |
| 31 | + vertex: null, |
| 32 | + }, |
| 33 | + size, |
| 34 | + }; |
| 35 | +}; |
| 36 | + |
| 37 | +const meshEdgesDefaultStyle = ( |
| 38 | + visibility = edges_defaultVisibility, |
| 39 | + size = edges_defaultSize, |
| 40 | + color = edges_defaultColor |
| 41 | +) => { |
| 42 | + return { |
| 43 | + visibility, |
| 44 | + coloring: { |
| 45 | + active: "color", |
| 46 | + color, |
| 47 | + }, |
| 48 | + size, |
| 49 | + }; |
| 50 | +}; |
| 51 | + |
| 52 | +const meshPolygonsDefaultStyle = ( |
| 53 | + visibility = polygons_defaultVisibility, |
| 54 | + color = polygons_defaultColor |
| 55 | +) => { |
| 56 | + return { |
| 57 | + visibility, |
| 58 | + coloring: { |
| 59 | + active: "color", |
| 60 | + color, |
| 61 | + textures: null, |
| 62 | + polygon: null, |
| 63 | + vertex: null, |
| 64 | + }, |
| 65 | + }; |
| 66 | +}; |
| 67 | + |
| 68 | +const meshPolyhedraDefaultStyle = ( |
| 69 | + visibility = polyhedra_defaultVisibility, |
| 70 | + color = polyhedra_defaultColor |
| 71 | +) => { |
| 72 | + return { |
| 73 | + visibility, |
| 74 | + coloring: { |
| 75 | + active: "color", |
| 76 | + color, |
| 77 | + polyhedron: null, |
| 78 | + vertex: null, |
| 79 | + }, |
| 80 | + }; |
| 81 | +}; |
| 82 | + |
| 83 | +const pointSet_defaultStyle = () => { |
| 84 | + return { |
| 85 | + visibility: true, |
| 86 | + points: meshPointsDefaultStyle(), |
| 87 | + }; |
| 88 | +}; |
| 89 | + |
| 90 | +const edgedCurve_defaultStyle = () => { |
| 91 | + return { |
| 92 | + visibility: true, |
| 93 | + points: meshPointsDefaultStyle(false), |
| 94 | + edges: meshEdgesDefaultStyle(), |
| 95 | + }; |
| 96 | +}; |
| 97 | + |
| 98 | +const surface_defaultStyle = (visibility = true) => { |
| 99 | + return { |
| 100 | + visibility, |
| 101 | + points: meshPointsDefaultStyle(false), |
| 102 | + edges: meshEdgesDefaultStyle(false), |
| 103 | + polygons: meshPolygonsDefaultStyle(), |
| 104 | + }; |
| 105 | +}; |
| 106 | + |
| 107 | +const solid_defaultStyle = () => { |
| 108 | + return { |
| 109 | + visibility: true, |
| 110 | + points: meshPointsDefaultStyle(false), |
| 111 | + edges: meshEdgesDefaultStyle(false), |
| 112 | + polygons: meshPolygonsDefaultStyle(), |
| 113 | + polyhedra: meshPolyhedraDefaultStyle(), |
| 114 | + }; |
| 115 | +}; |
| 116 | + |
| 117 | +// Model functions |
| 118 | +const modelCornersDefaultStyle = (visibility = corners_defaultVisibility) => { |
| 119 | + return { visibility }; |
| 120 | +}; |
| 121 | +const modelLinesDefaultStyle = ( |
| 122 | + visibility = lines_defaultVisibility, |
| 123 | + color = lines_defaultColor |
| 124 | +) => { |
| 125 | + return { visibility, color }; |
| 126 | +}; |
| 127 | +const modelSurfacesDefaultStyle = (visibility = surfaces_defaultVisibility) => { |
| 128 | + return { visibility }; |
| 129 | +}; |
| 130 | +const modelBlocksDefaultStyle = (visibility = blocks_defaultVisibility) => { |
| 131 | + return { visibility }; |
| 132 | +}; |
| 133 | +const modelPointsDefaultStyle = ( |
| 134 | + visibility = points_defaultVisibility, |
| 135 | + size |
| 136 | +) => { |
| 137 | + return { visibility, size }; |
| 138 | +}; |
| 139 | +const modelEdgesDefaultStyle = (visibility = edges_defaultVisibility) => { |
| 140 | + return { visibility }; |
| 141 | +}; |
| 142 | + |
| 143 | +const brep_defaultStyle = () => { |
| 144 | + return { |
| 145 | + visibility: true, |
| 146 | + corners: modelCornersDefaultStyle(), |
| 147 | + lines: modelLinesDefaultStyle(), |
| 148 | + surfaces: modelSurfacesDefaultStyle(), |
| 149 | + blocks: modelBlocksDefaultStyle(), |
| 150 | + points: modelPointsDefaultStyle(false, points_defaultSize), |
| 151 | + edges: modelEdgesDefaultStyle(false, edges_defaultSize), |
| 152 | + }; |
| 153 | +}; |
| 154 | + |
| 155 | +const crossSection_defaultStyle = () => { |
| 156 | + return { |
| 157 | + visibility: true, |
| 158 | + corners: modelCornersDefaultStyle(), |
| 159 | + lines: modelLinesDefaultStyle(), |
| 160 | + surfaces: modelSurfacesDefaultStyle(), |
| 161 | + points: modelPointsDefaultStyle(false, points_defaultSize), |
| 162 | + edges: modelEdgesDefaultStyle(false, edges_defaultSize), |
| 163 | + }; |
| 164 | +}; |
| 165 | + |
| 166 | +const structuralModel_defaultStyle = () => { |
| 167 | + return { |
| 168 | + visibility: true, |
| 169 | + corners: modelCornersDefaultStyle(), |
| 170 | + lines: modelLinesDefaultStyle(), |
| 171 | + surfaces: modelSurfacesDefaultStyle(), |
| 172 | + blocks: modelBlocksDefaultStyle(), |
| 173 | + points: modelPointsDefaultStyle(false, points_defaultSize), |
| 174 | + edges: modelEdgesDefaultStyle(false, edges_defaultSize), |
| 175 | + }; |
| 176 | +}; |
| 177 | + |
| 178 | +const section_defaultStyle = () => { |
| 179 | + return { |
| 180 | + visibility: true, |
| 181 | + corners: modelCornersDefaultStyle(), |
| 182 | + lines: modelLinesDefaultStyle(), |
| 183 | + surfaces: modelSurfacesDefaultStyle(), |
| 184 | + points: modelPointsDefaultStyle(false, points_defaultSize), |
| 185 | + edges: modelEdgesDefaultStyle(false, edges_defaultSize), |
| 186 | + }; |
| 187 | +}; |
| 188 | + |
| 189 | +const implicitCrossSection_defaultStyle = () => { |
| 190 | + return { |
| 191 | + visibility: true, |
| 192 | + corners: modelCornersDefaultStyle(), |
| 193 | + lines: modelLinesDefaultStyle(), |
| 194 | + surfaces: modelSurfacesDefaultStyle(), |
| 195 | + points: modelPointsDefaultStyle(false, points_defaultSize), |
| 196 | + edges: modelEdgesDefaultStyle(false, edges_defaultSize), |
| 197 | + }; |
| 198 | +}; |
| 199 | + |
| 200 | +const implicitStructuralModel_defaultStyle = () => { |
| 201 | + return { |
| 202 | + visibility: true, |
| 203 | + corners: modelCornersDefaultStyle(), |
| 204 | + lines: modelLinesDefaultStyle(), |
| 205 | + surfaces: modelSurfacesDefaultStyle(), |
| 206 | + blocks: modelBlocksDefaultStyle(), |
| 207 | + points: modelPointsDefaultStyle(false, points_defaultSize), |
| 208 | + edges: modelEdgesDefaultStyle(false, edges_defaultSize), |
| 209 | + }; |
| 210 | +}; |
| 211 | + |
| 212 | +const default_styles = () => { |
| 213 | + return { |
| 214 | + BRep: brep_defaultStyle(), |
| 215 | + CrossSection: crossSection_defaultStyle(), |
| 216 | + EdgedCurve2D: edgedCurve_defaultStyle(), |
| 217 | + EdgedCurve3D: edgedCurve_defaultStyle(), |
| 218 | + Graph: {}, |
| 219 | + HybridSolid3D: solid_defaultStyle(), |
| 220 | + ImplicitCrossSection: implicitCrossSection_defaultStyle(), |
| 221 | + ImplicitStructuralModel: implicitStructuralModel_defaultStyle(), |
| 222 | + LightRegularGrid2D: surface_defaultStyle(), |
| 223 | + LightRegularGrid3D: solid_defaultStyle(), |
| 224 | + PointSet2D: pointSet_defaultStyle(), |
| 225 | + PointSet3D: pointSet_defaultStyle(), |
| 226 | + PolygonalSurface2D: surface_defaultStyle(), |
| 227 | + PolygonalSurface3D: surface_defaultStyle(), |
| 228 | + PolyhedralSolid3D: solid_defaultStyle(), |
| 229 | + RasterImage2D: {}, |
| 230 | + RasterImage3D: {}, |
| 231 | + RegularGrid2D: surface_defaultStyle(), |
| 232 | + RegularGrid3D: solid_defaultStyle(), |
| 233 | + Section: section_defaultStyle(), |
| 234 | + StructuralModel: structuralModel_defaultStyle(), |
| 235 | + TetrahedralSolid3D: solid_defaultStyle(), |
| 236 | + TriangulatedSurface2D: surface_defaultStyle(), |
| 237 | + TriangulatedSurface3D: surface_defaultStyle(), |
| 238 | + VertexSet: {}, |
| 239 | + }; |
| 240 | +}; |
| 241 | + |
| 242 | +function getDefaultStyle(type) { |
| 243 | + return default_styles()[type]; |
| 244 | +} |
| 245 | + |
| 246 | +export { getDefaultStyle }; |
0 commit comments