Added polygone with a hole to Root converter

This commit is contained in:
Alexander Nozik 2023-10-07 15:42:03 +03:00
parent c7640a686a
commit 52d346453c
3 changed files with 23 additions and 15 deletions

View File

@ -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) {
//getting the radius of first
require(fNz > 1) { "The polyhedron geometry requires at least two planes" }
val baseRadius = fRmax[0]
shape {
fun Shape2DBuilder.pGon(radius: Double){
(0..<fNedges).forEach {
val phi = deltaphi / fNedges * it + startphi
point(baseRadius * cos(phi), baseRadius * sin(phi))
point(radius * cos(phi), radius * sin(phi))
}
}
(0 until fNz).forEach { index ->
//scaling all radii relative to first layer radius
layer(fZ[index], scale = fRmax[index] / baseRadius)
surface(name) {
//getting the radius of first
require(fNz > 1) { "The polyhedron geometry requires at least two planes" }
for (index in 0 until fNz){
layer(
fZ[index],
innerBuilder = {
pGon(fRmin[index])
},
outerBuilder = {
pGon(fRmax[index])
}
)
}
}.apply(block)
}

View File

@ -14,6 +14,7 @@ fun main() = makeVisionFile {
polygon(8, 100)
}
layer(-30)
layer(0, x = 10, y = 10)
layer(30)
}
}

View File

@ -11,8 +11,8 @@ fun main() = makeVisionFile {
ambientLight()
surface("surface") {
layer(0, { polygon(8, 10) }, { polygon(8, 20) })
layer(10, {polygon(8,10)}, {polygon(8,30)})
layer(10, { polygon(8, 20) }, { polygon(8, 30) })
layer(20, { polygon(8, 10) }, { polygon(8, 20) })
}
}
}