Fix name replication
This commit is contained in:
parent
ea82082304
commit
68cf4748d8
@ -24,16 +24,16 @@ class GDMLTransformer(val root: GDML) {
|
||||
private val random = Random(222)
|
||||
|
||||
enum class Action {
|
||||
ACCEPT,
|
||||
ADD,
|
||||
REJECT,
|
||||
CACHE
|
||||
PROTOTYPE
|
||||
}
|
||||
|
||||
var lUnit: LUnit = LUnit.MM
|
||||
var aUnit: AUnit = AUnit.RADIAN
|
||||
|
||||
var solidAction: (GDMLSolid) -> Action = { Action.CACHE }
|
||||
var volumeAction: (GDMLGroup) -> Action = { Action.CACHE }
|
||||
var solidAction: (GDMLSolid) -> Action = { Action.PROTOTYPE }
|
||||
var volumeAction: (GDMLGroup) -> Action = { Action.PROTOTYPE }
|
||||
|
||||
/**
|
||||
* A special group for local templates
|
||||
@ -49,6 +49,15 @@ class GDMLTransformer(val root: GDML) {
|
||||
internal val volumes by lazy {
|
||||
proto.group(volumesName)
|
||||
}
|
||||
|
||||
// fun proxySolid(group: SolidGroup, solid: GDMLSolid, name: String): Proxy {
|
||||
// val fullName = solidsName + name
|
||||
// if (proto[fullName] == null) {
|
||||
// solids.addSolid(this, solid, name)
|
||||
// }
|
||||
// return group.ref(fullName, name)
|
||||
// }
|
||||
|
||||
private val styleCache = HashMap<Name, Meta>()
|
||||
|
||||
var solidConfiguration: Solid.(parent: GDMLVolume, solid: GDMLSolid) -> Unit = { parent, _ ->
|
||||
@ -245,19 +254,17 @@ private fun SolidGroup.addSolid(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private fun SolidGroup.addSolidWithCaching(
|
||||
context: GDMLTransformer,
|
||||
solid: GDMLSolid,
|
||||
name: String = solid.name
|
||||
): Solid? {
|
||||
return when (context.solidAction(solid)) {
|
||||
GDMLTransformer.Action.ACCEPT -> {
|
||||
GDMLTransformer.Action.ADD -> {
|
||||
addSolid(context, solid, name)
|
||||
}
|
||||
GDMLTransformer.Action.CACHE -> {
|
||||
GDMLTransformer.Action.PROTOTYPE -> {
|
||||
// context.proxySolid(this, solid, name)
|
||||
val fullName = solidsName + solid.name.asName()
|
||||
if (context.proto[fullName] == null) {
|
||||
context.solids.addSolid(context, solid, solid.name)
|
||||
@ -271,7 +278,6 @@ private fun SolidGroup.addSolidWithCaching(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun SolidGroup.addPhysicalVolume(
|
||||
context: GDMLTransformer,
|
||||
physVolume: GDMLPhysVolume
|
||||
@ -291,16 +297,15 @@ private fun SolidGroup.addPhysicalVolume(
|
||||
}
|
||||
|
||||
when (context.volumeAction(volume)) {
|
||||
GDMLTransformer.Action.ACCEPT -> {
|
||||
GDMLTransformer.Action.ADD -> {
|
||||
val group: SolidGroup = volume(context, volume)
|
||||
this[physVolume.name ?: ""] = group.withPosition(context, physVolume)
|
||||
}
|
||||
GDMLTransformer.Action.CACHE -> {
|
||||
GDMLTransformer.Action.PROTOTYPE -> {
|
||||
val fullName = volumesName + volume.name.asName()
|
||||
if (context.proto[fullName] == null) {
|
||||
context.proto[fullName] = volume(context, volume)
|
||||
}
|
||||
|
||||
ref(fullName, physVolume.name ?: "").withPosition(context, physVolume)
|
||||
}
|
||||
GDMLTransformer.Action.REJECT -> {
|
||||
|
@ -17,10 +17,11 @@ class ThreeProxyFactory(val three: ThreePlugin) : ThreeFactory<Proxy> {
|
||||
private fun Object3D.replicate(): Object3D {
|
||||
return when (this) {
|
||||
is Mesh -> Mesh(geometry as BufferGeometry, material).also {
|
||||
it.applyMatrix(matrix)
|
||||
it.applyMatrix4(matrix)
|
||||
}
|
||||
else -> clone(false)
|
||||
}.also { obj: Object3D ->
|
||||
obj.name = this.name
|
||||
children.forEach { child: Object3D ->
|
||||
obj.add(child.replicate())
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ open external class BufferGeometry {
|
||||
fun merge(bufferGeometry: BufferGeometry, offset: Int = definedExternally): BufferGeometry
|
||||
|
||||
|
||||
fun applyMatrix(matrix: Matrix4)
|
||||
fun applyMatrix4(matrix: Matrix4)
|
||||
fun lookAt(vector: Vector3): BufferGeometry
|
||||
fun rotateX(radians: Double): BufferGeometry
|
||||
fun rotateY(radians: Double): BufferGeometry
|
||||
|
@ -70,7 +70,7 @@ open external class Geometry {
|
||||
var lineDistancesNeedUpdate: Boolean
|
||||
var groupsNeedUpdate: Boolean
|
||||
|
||||
fun applyMatrix(matrix: Matrix4): Geometry
|
||||
fun applyMatrix4(matrix: Matrix4): Geometry
|
||||
fun rotateX(angle: Number): Geometry
|
||||
fun rotateY(angle: Number): Geometry
|
||||
fun rotateZ(angle: Number): Geometry
|
||||
|
@ -165,7 +165,7 @@ open external class Object3D {
|
||||
/**
|
||||
* Applies the matrix transform to the object and updates the object's position, rotation and scale.
|
||||
*/
|
||||
fun applyMatrix(matrix: Matrix4)
|
||||
fun applyMatrix4(matrix: Matrix4)
|
||||
|
||||
/**
|
||||
* Applies the rotation represented by the quaternion to the object.
|
||||
|
Loading…
Reference in New Issue
Block a user