-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
570138c
commit 10a71a4
Showing
23 changed files
with
2,084 additions
and
528 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
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
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 |
---|---|---|
@@ -1,73 +1,69 @@ | ||
#Region "Microsoft.VisualBasic::050e16ba84ef1932bc43eda21a2e551e, sciBASIC#\gr\Landscape\PLY\Header.vb" | ||
|
||
' Author: | ||
' | ||
' asuka ([email protected]) | ||
' xie ([email protected]) | ||
' xieguigang ([email protected]) | ||
' | ||
' Copyright (c) 2018 GPL3 Licensed | ||
' | ||
' | ||
' GNU GENERAL PUBLIC LICENSE (GPL3) | ||
' | ||
' | ||
' 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 <http://www.gnu.org/licenses/>. | ||
|
||
|
||
|
||
' /********************************************************************************/ | ||
|
||
' Summaries: | ||
|
||
|
||
' Code Statistics: | ||
|
||
' Total Lines: 94 | ||
' Code Lines: 76 | ||
' Comment Lines: 0 | ||
' Blank Lines: 18 | ||
' File Size: 3.52 KB | ||
|
||
|
||
' Class Header | ||
' | ||
' Properties: comment, element_face, element_vertex, properties | ||
' | ||
' Sub: WriteAsciiText | ||
' | ||
' Module SimplePlyWriter | ||
' | ||
' Function: WriteAsciiText | ||
' | ||
' Class PointCloud | ||
' | ||
' Properties: color, intensity, x, y, z | ||
' | ||
' Function: ToString | ||
' | ||
' | ||
' /********************************************************************************/ | ||
' Author: | ||
' | ||
' asuka ([email protected]) | ||
' xie ([email protected]) | ||
' xieguigang ([email protected]) | ||
' | ||
' Copyright (c) 2018 GPL3 Licensed | ||
' | ||
' | ||
' GNU GENERAL PUBLIC LICENSE (GPL3) | ||
' | ||
' | ||
' 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 <http://www.gnu.org/licenses/>. | ||
|
||
|
||
|
||
' /********************************************************************************/ | ||
|
||
' Summaries: | ||
|
||
|
||
' Code Statistics: | ||
|
||
' Total Lines: 94 | ||
' Code Lines: 76 | ||
' Comment Lines: 0 | ||
' Blank Lines: 18 | ||
' File Size: 3.52 KB | ||
|
||
|
||
' Class Header | ||
' | ||
' Properties: comment, element_face, element_vertex, properties | ||
' | ||
' Sub: WriteAsciiText | ||
' | ||
' Module SimplePlyWriter | ||
' | ||
' Function: WriteAsciiText | ||
' | ||
' Class PointCloud | ||
' | ||
' Properties: color, intensity, x, y, z | ||
' | ||
' Function: ToString | ||
' | ||
' | ||
' /********************************************************************************/ | ||
|
||
#End Region | ||
|
||
Imports System.Drawing | ||
Imports System.IO | ||
Imports System.Text | ||
Imports Microsoft.VisualBasic.ComponentModel.DataSourceModel | ||
Imports Microsoft.VisualBasic.ComponentModel.Ranges.Model | ||
Imports Microsoft.VisualBasic.Imaging.Drawing2D.Colors | ||
|
||
Namespace Ply | ||
|
||
|
@@ -91,68 +87,5 @@ Namespace Ply | |
|
||
Call file.WriteLine($"end_header") | ||
End Sub | ||
|
||
End Class | ||
|
||
Public Module SimplePlyWriter | ||
|
||
Public Function WriteAsciiText(pointCloud As IEnumerable(Of PointCloud), | ||
buffer As Stream, | ||
Optional colors As ScalerPalette = ScalerPalette.turbo, | ||
Optional levels As Integer = 200) As Boolean | ||
|
||
Using file As New StreamWriter(buffer, Encoding.ASCII) With { | ||
.AutoFlush = True, | ||
.NewLine = vbLf | ||
} | ||
Dim vertex As PointCloud() = pointCloud.ToArray | ||
Dim header As New Header With { | ||
.comment = "Point Cloud Model", | ||
.element_face = -1, | ||
.element_vertex = vertex.Length, | ||
.properties = { | ||
New NamedValue(Of String)("x", "float"), | ||
New NamedValue(Of String)("y", "float"), | ||
New NamedValue(Of String)("z", "float"), | ||
New NamedValue(Of String)("intensity", "float"), | ||
New NamedValue(Of String)("color", "string") | ||
} | ||
} | ||
Dim colorSet As String() = Designer _ | ||
.GetColors(colors.Description, levels) _ | ||
.Select(Function(c) c.ToHtmlColor) _ | ||
.ToArray | ||
Dim scale As New DoubleRange(From v As PointCloud In vertex Select v.intensity) | ||
Dim i As Integer | ||
Dim index As New DoubleRange(0, levels - 1) | ||
Dim clr As String | ||
|
||
Call header.WriteAsciiText(file) | ||
Call file.Flush() | ||
|
||
For Each point As PointCloud In vertex | ||
i = scale.ScaleMapping(point.intensity, index) | ||
clr = colorSet(i) | ||
|
||
Call file.WriteLine($"{point.x.ToString("F3")} {point.y.ToString("F3")} {point.z.ToString("F3")} {point.intensity} {clr}") | ||
Next | ||
End Using | ||
|
||
Return True | ||
End Function | ||
End Module | ||
|
||
Public Class PointCloud | ||
|
||
Public Property x As Double | ||
Public Property y As Double | ||
Public Property z As Double | ||
Public Property color As String | ||
Public Property intensity As Double | ||
|
||
Public Overrides Function ToString() As String | ||
Return $"[{x},{y},{z}] {intensity}" | ||
End Function | ||
|
||
End Class | ||
End Namespace |
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,16 @@ | ||
Namespace Ply | ||
|
||
Public Class PointCloud | ||
|
||
Public Property x As Double | ||
Public Property y As Double | ||
Public Property z As Double | ||
Public Property color As String | ||
Public Property intensity As Double | ||
|
||
Public Overrides Function ToString() As String | ||
Return $"[{x},{y},{z}] {intensity}" | ||
End Function | ||
|
||
End Class | ||
End Namespace |
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,56 @@ | ||
Imports Microsoft.VisualBasic.ComponentModel.DataSourceModel | ||
Imports Microsoft.VisualBasic.ComponentModel.Ranges.Model | ||
Imports Microsoft.VisualBasic.Imaging.Drawing2D.Colors | ||
Imports System.IO | ||
Imports System.Text | ||
|
||
Namespace Ply | ||
|
||
Public Module SimplePlyWriter | ||
|
||
Public Function WriteAsciiText(pointCloud As IEnumerable(Of PointCloud), | ||
buffer As Stream, | ||
Optional colors As ScalerPalette = ScalerPalette.turbo, | ||
Optional levels As Integer = 200) As Boolean | ||
|
||
Using file As New StreamWriter(buffer, Encoding.ASCII) With { | ||
.AutoFlush = True, | ||
.NewLine = vbLf | ||
} | ||
Dim vertex As PointCloud() = pointCloud.ToArray | ||
Dim header As New Header With { | ||
.comment = "Point Cloud Model", | ||
.element_face = -1, | ||
.element_vertex = vertex.Length, | ||
.properties = { | ||
New NamedValue(Of String)("x", "float"), | ||
New NamedValue(Of String)("y", "float"), | ||
New NamedValue(Of String)("z", "float"), | ||
New NamedValue(Of String)("intensity", "float"), | ||
New NamedValue(Of String)("color", "string") | ||
} | ||
} | ||
Dim colorSet As String() = Designer _ | ||
.GetColors(colors.Description, levels) _ | ||
.Select(Function(c) c.ToHtmlColor) _ | ||
.ToArray | ||
Dim scale As New DoubleRange(From v As PointCloud In vertex Select v.intensity) | ||
Dim i As Integer | ||
Dim index As New DoubleRange(0, levels - 1) | ||
Dim clr As String | ||
|
||
Call header.WriteAsciiText(file) | ||
Call file.Flush() | ||
|
||
For Each point As PointCloud In vertex | ||
i = scale.ScaleMapping(point.intensity, index) | ||
clr = colorSet(i) | ||
|
||
Call file.WriteLine($"{point.x.ToString("F3")} {point.y.ToString("F3")} {point.z.ToString("F3")} {point.intensity} {clr}") | ||
Next | ||
End Using | ||
|
||
Return True | ||
End Function | ||
End Module | ||
End Namespace |
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,10 @@ | ||
Namespace Wavefront | ||
|
||
Public Class Triangle | ||
|
||
Public Property v3 As Integer() | ||
Public Property vn3 As Integer() | ||
Public Property comment As String | ||
|
||
End Class | ||
End Namespace |
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,49 @@ | ||
Imports System.IO | ||
Imports System.Runtime.CompilerServices | ||
Imports Microsoft.VisualBasic.Imaging.Drawing3D | ||
Imports Microsoft.VisualBasic.Language | ||
|
||
Namespace Wavefront | ||
|
||
Public Class OBJ | ||
|
||
''' <summary> | ||
''' lib file name of mtl data | ||
''' </summary> | ||
''' <returns></returns> | ||
Public Property mtllib As String | ||
Public Property parts As ObjectPart() | ||
Public Property comment As String | ||
|
||
<MethodImpl(MethodImplOptions.AggressiveInlining)> | ||
<DebuggerStepThrough> | ||
Public Shared Function ReadFile(file As StreamReader) As OBJ | ||
Return TextParser.ParseFile(file) | ||
End Function | ||
|
||
End Class | ||
|
||
Public Class ObjectPart | ||
|
||
Public Property g As String | ||
Public Property vertex As Point3D() | ||
Public Property vn As Point3D() | ||
Public Property usemtl As String | ||
Public Property f As Triangle() | ||
|
||
Public ReadOnly Property IsEmpty As Boolean | ||
Get | ||
Return g.StringEmpty AndAlso | ||
vertex.IsNullOrEmpty AndAlso | ||
vn.IsNullOrEmpty AndAlso | ||
usemtl.StringEmpty AndAlso | ||
f.IsNullOrEmpty | ||
End Get | ||
End Property | ||
|
||
Public Overrides Function ToString() As String | ||
Return $"{g Or "no_label".AsDefault}: {vertex.Length} vertexs and {f.Length} triangles" | ||
End Function | ||
|
||
End Class | ||
End Namespace |
Oops, something went wrong.