-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release-1.0' of github.com:unibas-gravis/scalismo into …
…release-1.0
- Loading branch information
Showing
29 changed files
with
7,543 additions
and
336 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package scalismo.io | ||
|
||
import java.io.RandomAccessFile | ||
import java.nio.ByteBuffer | ||
|
||
object FileReader { | ||
def readFileToByteBuffer(file: String): ByteBuffer = { | ||
val raf = new RandomAccessFile(file, "r") | ||
val channel = raf.getChannel | ||
val buffer = ByteBuffer.allocate(channel.size.toInt) | ||
channel.read(buffer) | ||
buffer.rewind() | ||
buffer | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright 2015 University of Basel, Graphics and Vision Research Group | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package scalismo.io.ply | ||
|
||
import scalismo.geometry._3D | ||
import scalismo.mesh.{TriangleMesh, VertexColorMesh3D} | ||
|
||
import java.io.{File, IOException} | ||
import scala.util.{Failure, Try} | ||
|
||
object PLY { | ||
|
||
def write(mesh: TriangleMesh[_3D], filename: File): Try[Unit] = { | ||
PLYMeshWriter.write(mesh, None, filename) | ||
} | ||
|
||
def write(mesh: VertexColorMesh3D, filename: File): Try[Unit] = { | ||
PLYMeshWriter.write(mesh.shape, Option(mesh.color.pointData.iterator), filename) | ||
} | ||
|
||
def read(file: File): Try[Either[TriangleMesh[_3D], VertexColorMesh3D]] = { | ||
if (!file.exists()) { | ||
val filename = file.getCanonicalFile | ||
Failure(new IOException(s"Could not read ply file with name $filename. Reason: The file does not exist")) | ||
} else { | ||
PLYMeshReader.readFileAndParseHeader(file) | ||
} | ||
} | ||
} |
Oops, something went wrong.