diff --git a/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/dRootToSolid.kt b/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/dRootToSolid.kt index d6b7b4ce..ba3e4616 100644 --- a/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/dRootToSolid.kt +++ b/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/dRootToSolid.kt @@ -188,7 +188,7 @@ private fun SolidGroup.addShape( } "TGeoPgon" -> { - //TODO add a inner polygone layer + val fDphi by shape.meta.double(0.0) val fNz by shape.meta.int(2) val fPhi1 by shape.meta.double(360.0) @@ -201,19 +201,26 @@ private fun SolidGroup.addShape( val startphi = degToRad(fPhi1) val deltaphi = degToRad(fDphi) - extruded(name) { + fun Shape2DBuilder.pGon(radius: Double){ + (0.. 1) { "The polyhedron geometry requires at least two planes" } - val baseRadius = fRmax[0] - shape { - (0.. - //scaling all radii relative to first layer radius - layer(fZ[index], scale = fRmax[index] / baseRadius) + for (index in 0 until fNz){ + layer( + fZ[index], + innerBuilder = { + pGon(fRmin[index]) + }, + outerBuilder = { + pGon(fRmax[index]) + } + ) } }.apply(block) } diff --git a/demo/playground/src/jvmMain/kotlin/extruded.kt b/demo/playground/src/jvmMain/kotlin/extruded.kt index af8fe6d0..c45b2564 100644 --- a/demo/playground/src/jvmMain/kotlin/extruded.kt +++ b/demo/playground/src/jvmMain/kotlin/extruded.kt @@ -14,6 +14,7 @@ fun main() = makeVisionFile { polygon(8, 100) } layer(-30) + layer(0, x = 10, y = 10) layer(30) } } diff --git a/demo/playground/src/jvmMain/kotlin/surface.kt b/demo/playground/src/jvmMain/kotlin/surface.kt index 9bcc9e2f..01fbfb50 100644 --- a/demo/playground/src/jvmMain/kotlin/surface.kt +++ b/demo/playground/src/jvmMain/kotlin/surface.kt @@ -10,9 +10,9 @@ fun main() = makeVisionFile { solid { ambientLight() surface("surface") { - layer(0, {polygon(8,10)}, {polygon(8,20)}) - layer(10, {polygon(8,10)}, {polygon(8,30)}) - + layer(0, { polygon(8, 10) }, { polygon(8, 20) }) + layer(10, { polygon(8, 20) }, { polygon(8, 30) }) + layer(20, { polygon(8, 10) }, { polygon(8, 20) }) } } }