All Downloads are FREE. Search and download functionalities are using the official Maven repository.

scalismo.ui.model.LineMeshNode.scala Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (C) 2016  University of Basel, Graphics and Vision Research Group
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see .
 */

package scalismo.ui.model

import scalismo.geometry.{_3D, Point, Point3D}
import scalismo.mesh.LineMesh
import scalismo.ui.model.capabilities._
import scalismo.ui.model.properties._

class LineMeshesNode(override val parent: GroupNode) extends SceneNodeCollection[LineMeshNode] {
  override val name: String = "Line Meshes"

  def add(mesh: LineMesh[_3D], name: String): LineMeshNode = {
    val node = new LineMeshNode(this, mesh, name)
    add(node)
    node
  }
}

class LineMeshNode(override val parent: LineMeshesNode, override val source: LineMesh[_3D], initialName: String)
    extends Transformable[LineMesh[_3D]]
    with InverseTransformation
    with Renameable
    with Removeable
    with HasColor
    with HasOpacity
    with HasLineWidth {
  name = initialName

  override val color = new ColorProperty()
  override val opacity = new OpacityProperty()
  override val lineWidth = new LineWidthProperty()

  override def inverseTransform(point: Point[_3D]): Point[_3D] = {
    val id = transformedSource.pointSet.findClosestPoint(point).id
    source.pointSet.point(id)
  }

  override def group: GroupNode = parent.parent

  override def transform(untransformed: LineMesh[_3D], transformation: PointTransformation): LineMesh[_3D] = {
    untransformed.transform(transformation)
  }

  override def remove(): Unit = parent.remove(this)

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy