Skip to content

Commit

Permalink
Fixes compilation issue in M3D module.
Browse files Browse the repository at this point in the history
Signed-off-by: Ralph Gasser <[email protected]>
  • Loading branch information
ppanopticon committed Jul 26, 2024
1 parent ba8a0b4 commit 6cac8e1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import org.joml.Vector4f
import org.lwjgl.BufferUtils
import org.lwjgl.assimp.*
import org.lwjgl.assimp.Assimp.*

import org.lwjgl.system.MemoryStack
import org.vitrivr.engine.core.model.mesh.*
import java.io.File
Expand All @@ -15,7 +14,6 @@ import java.io.InputStream
import java.nio.ByteBuffer
import java.nio.IntBuffer
import java.util.*
import kotlin.collections.ArrayList

class ModelHandler {

Expand Down Expand Up @@ -95,9 +93,6 @@ class ModelHandler {
LOGGER.trace("Try loading model {} from InputStream", modelId)

val aiScene = loadAIScene(modelId, inputStream)

val modelDir = File("").absolutePath // You may need to adjust this to the appropriate directory

val materialList: MutableList<Material> = ArrayList()
val defaultMaterial = Material(mutableListOf()) // Define a default material
val aiMeshes = aiScene.mMeshes()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ class SphericalHarmonics: Analyser<Model3DContent, FloatVectorDescriptor> {
val numberOfCoefficients: Int = SphericalHarmonicsFunction.numberOfCoefficients(maxL, true) - SphericalHarmonicsFunction.numberOfCoefficients(minL - 1, true)

/* Prepares an empty array for the feature vector. */
val feature = Array((R - cap) * numberOfCoefficients) { _ -> Value.Float(0f) }
val feature = FloatArray((R - cap) * numberOfCoefficients) { _ -> 0f }

/* Voxelizes the grid from the mesh. If the resulting grid is invisible, the method returns immediately. */
val grid: VoxelModel = voxelizer.voxelize(mesh, gridSize + 1, gridSize + 1, gridSize + 1)
if (!grid.isVisible()) {
return FloatVectorDescriptor(UUID.randomUUID(), null, feature.toList())
return FloatVectorDescriptor(UUID.randomUUID(), null, Value.FloatVector(feature))
}

val descriptors: MutableList<MutableList<Complex>> = LinkedList()
Expand Down Expand Up @@ -144,12 +144,12 @@ class SphericalHarmonics: Analyser<Model3DContent, FloatVectorDescriptor> {
var index = 0
for (radius in descriptors) {
for (descriptor in radius) {
feature[index++] = Value.Float(descriptor.abs().toFloat())
feature[index++] = descriptor.abs().toFloat()
}
}

/* Returns the normalized vector. */
return FloatVectorDescriptor(UUID.randomUUID(), null, MathHelper.normalizeL2(feature).toList())
return FloatVectorDescriptor(UUID.randomUUID(), null, Value.FloatVector(MathHelper.normalizeL2(feature)))
}
}

Expand All @@ -162,16 +162,16 @@ class SphericalHarmonics: Analyser<Model3DContent, FloatVectorDescriptor> {
val maxL = field.parameters[MAXL_PARAMETER_NAME]?.toIntOrNull() ?: MAXL_PARAMETER_DEFAULT
val numberOfCoefficients: Int = SphericalHarmonicsFunction.numberOfCoefficients(maxL, true) - SphericalHarmonicsFunction.numberOfCoefficients(minL - 1, true)
val vectorSize = ((gridSize / 2) - cap) * numberOfCoefficients
return FloatVectorDescriptor(UUID.randomUUID(), UUID.randomUUID(), List(vectorSize) { Value.Float(0f) })
return FloatVectorDescriptor(UUID.randomUUID(), UUID.randomUUID(), Value.FloatVector(FloatArray(vectorSize)))
}

override fun newRetrieverForQuery(field: Schema.Field<Model3DContent, FloatVectorDescriptor>, query: Query, context: QueryContext): Retriever<Model3DContent, FloatVectorDescriptor> {
require(field.analyser == this) { "The field '${field.fieldName}' analyser does not correspond with this analyser. This is a programmer's error!" }
require(query is ProximityQuery<*> && query.value.first() is Value.Float) { }
require(query is ProximityQuery<*> && query.value is Value.FloatVector) { }

/* Construct query. */
@Suppress("UNCHECKED_CAST")
return SphericalHarmonicsRetriever(field, query as ProximityQuery<Value.Float>, context)
return SphericalHarmonicsRetriever(field, query as ProximityQuery<Value.FloatVector>, context)
}

override fun newRetrieverForDescriptors(field: Schema.Field<Model3DContent, FloatVectorDescriptor>, descriptors: Collection<FloatVectorDescriptor>, context: QueryContext): Retriever<Model3DContent, FloatVectorDescriptor> {
Expand Down

0 comments on commit 6cac8e1

Please sign in to comment.