From 63697df5699a6b0e69591ed47db3c0fdfdd816c3 Mon Sep 17 00:00:00 2001 From: Anthony Liot Date: Wed, 5 May 2021 23:29:31 -0700 Subject: [PATCH] Fix to build basel-face-model-viewer #15 (#16) * Update the scala version to 2.13.0 Update the scalismo-faces version to 0.90.0 Fix 2.13 warning Signed-off-by: wolfviking0 * Fix IntelliJ warning Signed-off-by: Anthony Liot Co-authored-by: Anthony Liot --- build.sbt | 4 ++-- src/main/scala/faces/apps/ModelViewer.scala | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/build.sbt b/build.sbt index 0ff1d55..e985c53 100644 --- a/build.sbt +++ b/build.sbt @@ -1,7 +1,7 @@ name := """model-viewer""" version := "1.0" -scalaVersion := "2.11.12" +scalaVersion := "2.13.0" scalacOptions := Seq("-unchecked", "-deprecation", "-encoding", "utf8") @@ -9,7 +9,7 @@ resolvers += Resolver.jcenterRepo resolvers += Resolver.bintrayRepo("unibas-gravis", "maven") -libraryDependencies += "ch.unibas.cs.gravis" %% "scalismo-faces" % "0.9.2+" +libraryDependencies += "ch.unibas.cs.gravis" %% "scalismo-faces" % "0.90.0" mainClass in assembly := Some("faces.apps.ModelViewer") diff --git a/src/main/scala/faces/apps/ModelViewer.scala b/src/main/scala/faces/apps/ModelViewer.scala index 43dcb54..1ca4604 100644 --- a/src/main/scala/faces/apps/ModelViewer.scala +++ b/src/main/scala/faces/apps/ModelViewer.scala @@ -17,21 +17,20 @@ import java.awt.Dimension import java.io.{File, IOException} - import javax.swing._ import javax.swing.event.{ChangeEvent, ChangeListener} import breeze.linalg.min + import scalismo.color.{RGB, RGBA} import scalismo.faces.gui.{GUIBlock, GUIFrame, ImagePanel} import scalismo.faces.gui.GUIBlock._ import scalismo.faces.parameters.RenderParameter import scalismo.faces.io.{MeshIO, MoMoIO, PixelImageIO, RenderParameterIO} import scalismo.faces.sampling.face.MoMoRenderer - import scalismo.faces.color.RGB import scalismo.faces.image.PixelImage import scalismo.utils.Random - import scalismo.faces.color.RGBA import scalismo.faces.momo.MoMo + import scala.math.Ordering.Double import scala.reflect.io.Path import scala.util.{Failure, Try} @@ -39,7 +38,7 @@ object ModelViewer extends App { final val DEFAULT_DIR = new File(".") - val modelFile: Option[File] = getModelFile(args) + val modelFile: Option[File] = getModelFile(args.toIndexedSeq) modelFile.map(SimpleModelViewer(_)) private def getModelFile(args: Seq[String]): Option[File] = { @@ -131,9 +130,9 @@ case class SimpleModelViewer( (value / maximalSigma * sliderSteps).toInt } - val bg = PixelImage(imageWidth, imageHeight, (_, _) => RGBA.Black) + val bg: PixelImage[RGBA] = PixelImage(imageWidth, imageHeight, (_, _) => RGBA.Black) - val imageWindow = ImagePanel(renderWithBG(init)) + val imageWindow: ImagePanel[RGB] = ImagePanel(renderWithBG(init)) //--- SHAPE ----- val shapeSlider: IndexedSeq[JSlider] = for (n <- 0 until shapeRank) yield { @@ -323,13 +322,13 @@ case class SimpleModelViewer( else renderer = MoMoRenderer(model, RGBA.BlackTransparent).cached(5) showExpressionModel = !showExpressionModel - updateToggleExpressioButton() + updateToggleExpressionButton() addRemoveExpressionTab() updateImage() } }) - def updateToggleExpressioButton(): Unit = { + def updateToggleExpressionButton(): Unit = { if ( showExpressionModel ) toggleExpressionButton.setText("expressions off") else toggleExpressionButton.setText("expressions on") } @@ -355,7 +354,7 @@ case class SimpleModelViewer( if (fc.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) { var file = fc.getSelectedFile if (file.isDirectory) file = new File(file,"instance.ply") - if ( !file.getName.endsWith(".ply")) file = new File( file+".ply") + if ( !file.getName.endsWith(".ply")) file = new File( file.getAbsolutePath+".ply") if (!file.exists() || askToOverwrite(file)) { MeshIO.write(VCM3D, file) } else { @@ -382,7 +381,7 @@ case class SimpleModelViewer( if (fc.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) { var file = fc.getSelectedFile if (file.isDirectory) file = new File(file,"instance.png") - if ( !file.getName.endsWith(".png")) file = new File( file+".png") + if ( !file.getName.endsWith(".png")) file = new File( file.getAbsolutePath+".png") if (!file.exists() || askToOverwrite(file)) { PixelImageIO.write(img, file) } else { @@ -446,6 +445,7 @@ case class SimpleModelViewer( { for {rpsFile <- askUserForRPSFile(new File(".")) rpsParams <- RenderParameterIO.read(rpsFile)} { + implicit val order: Double.TotalOrdering.type = Ordering.Double.TotalOrdering val maxSigma = (rpsParams.momo.shape ++ rpsParams.momo.color ++ rpsParams.momo.expression).map(math.abs).max if ( maxSigma > maximalSigma ) { maximalSigma = math.ceil(maxSigma).toInt