├── .gitignore
├── .gitmodules
├── LICENSE
├── README.md
├── STL-Viewer.sln
├── STL-Viewer
├── App.config
├── AppAboutForm.Designer.cs
├── AppAboutForm.cs
├── AppAboutForm.resx
├── AppHowToUseForm.Designer.cs
├── AppHowToUseForm.cs
├── AppHowToUseForm.resx
├── AppMainForm.Designer.cs
├── AppMainForm.cs
├── AppMainForm.resx
├── BatuGL.cs
├── Program.cs
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
├── Resources
│ └── stl_viewer_iconpng.png
├── STL-Viewer.csproj
├── STL_Tools
│ ├── STLExport.cs
│ ├── STLReader.cs
│ ├── TriangleMesh.cs
│ └── Vector3.cs
├── bin
│ └── Debug
│ │ ├── OpenTK.Compatibility.dll
│ │ ├── OpenTK.GLControl.dll
│ │ ├── OpenTK.dll
│ │ └── STL Viewer.exe.config
├── obj
│ └── Debug
│ │ ├── STL-Viewer.csproj.CopyComplete
│ │ ├── STL-Viewer.csproj.FileListAbsolute.txt
│ │ ├── STLViewer.AppAboutForm.resources
│ │ ├── STLViewer.AppHowToUseForm.resources
│ │ ├── STLViewer.AppMainForm.resources
│ │ ├── STLViewer.Properties.Resources.resources
│ │ ├── TempPE
│ │ └── Properties.Resources.Designer.cs.dll
│ │ ├── TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
│ │ ├── TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
│ │ └── TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
└── stl_viewer_icon.ico
├── sample_stl
├── Planetary_Toy_D80.stl
└── Star_Destroyer_Fixed.stl
└── visuals
└── STL_Viewer_Demo.gif
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.suo
8 | *.user
9 | *.userosscache
10 | *.sln.docstates
11 |
12 | # User-specific files (MonoDevelop/Xamarin Studio)
13 | *.userprefs
14 |
15 | # Build results
16 | #[Dd]ebug/
17 | [Dd]ebugPublic/
18 | #[Rr]elease/
19 | [Rr]eleases/
20 | x64/
21 | x86/
22 | bld/
23 | #[Bb]in/
24 | #[Oo]bj/
25 | [Ll]og/
26 |
27 | # Visual Studio 2015/2017 cache/options directory
28 | .vs/
29 | # Uncomment if you have tasks that create the project's static files in wwwroot
30 | #wwwroot/
31 |
32 | # Visual Studio 2017 auto generated files
33 | Generated\ Files/
34 |
35 | # MSTest test Results
36 | [Tt]est[Rr]esult*/
37 | [Bb]uild[Ll]og.*
38 |
39 | # NUNIT
40 | *.VisualState.xml
41 | TestResult.xml
42 |
43 | # Build Results of an ATL Project
44 | [Dd]ebugPS/
45 | [Rr]eleasePS/
46 | dlldata.c
47 |
48 | # Benchmark Results
49 | BenchmarkDotNet.Artifacts/
50 |
51 | # .NET Core
52 | project.lock.json
53 | project.fragment.lock.json
54 | artifacts/
55 | **/Properties/launchSettings.json
56 |
57 | # StyleCop
58 | StyleCopReport.xml
59 |
60 | # Files built by Visual Studio
61 | *_i.c
62 | *_p.c
63 | *_i.h
64 | *.ilk
65 | *.meta
66 | *.obj
67 | *.pch
68 | *.pdb
69 | *.pgc
70 | *.pgd
71 | *.rsp
72 | *.sbr
73 | *.tlb
74 | *.tli
75 | *.tlh
76 | *.tmp
77 | *.tmp_proj
78 | *.log
79 | *.vspscc
80 | *.vssscc
81 | .builds
82 | *.pidb
83 | *.svclog
84 | *.scc
85 |
86 | # Chutzpah Test files
87 | _Chutzpah*
88 |
89 | # Visual C++ cache files
90 | ipch/
91 | *.aps
92 | *.ncb
93 | *.opendb
94 | *.opensdf
95 | *.sdf
96 | *.cachefile
97 | *.VC.db
98 | *.VC.VC.opendb
99 |
100 | # Visual Studio profiler
101 | *.psess
102 | *.vsp
103 | *.vspx
104 | *.sap
105 |
106 | # Visual Studio Trace Files
107 | *.e2e
108 |
109 | # TFS 2012 Local Workspace
110 | $tf/
111 |
112 | # Guidance Automation Toolkit
113 | *.gpState
114 |
115 | # ReSharper is a .NET coding add-in
116 | _ReSharper*/
117 | *.[Rr]e[Ss]harper
118 | *.DotSettings.user
119 |
120 | # JustCode is a .NET coding add-in
121 | .JustCode
122 |
123 | # TeamCity is a build add-in
124 | _TeamCity*
125 |
126 | # DotCover is a Code Coverage Tool
127 | *.dotCover
128 |
129 | # AxoCover is a Code Coverage Tool
130 | .axoCover/*
131 | !.axoCover/settings.json
132 |
133 | # Visual Studio code coverage results
134 | *.coverage
135 | *.coveragexml
136 |
137 | # NCrunch
138 | _NCrunch_*
139 | .*crunch*.local.xml
140 | nCrunchTemp_*
141 |
142 | # MightyMoose
143 | *.mm.*
144 | AutoTest.Net/
145 |
146 | # Web workbench (sass)
147 | .sass-cache/
148 |
149 | # Installshield output folder
150 | [Ee]xpress/
151 |
152 | # DocProject is a documentation generator add-in
153 | DocProject/buildhelp/
154 | DocProject/Help/*.HxT
155 | DocProject/Help/*.HxC
156 | DocProject/Help/*.hhc
157 | DocProject/Help/*.hhk
158 | DocProject/Help/*.hhp
159 | DocProject/Help/Html2
160 | DocProject/Help/html
161 |
162 | # Click-Once directory
163 | publish/
164 |
165 | # Publish Web Output
166 | *.[Pp]ublish.xml
167 | *.azurePubxml
168 | # Note: Comment the next line if you want to checkin your web deploy settings,
169 | # but database connection strings (with potential passwords) will be unencrypted
170 | *.pubxml
171 | *.publishproj
172 |
173 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
174 | # checkin your Azure Web App publish settings, but sensitive information contained
175 | # in these scripts will be unencrypted
176 | PublishScripts/
177 |
178 | # NuGet Packages
179 | *.nupkg
180 | # The packages folder can be ignored because of Package Restore
181 | **/[Pp]ackages/*
182 | # except build/, which is used as an MSBuild target.
183 | !**/[Pp]ackages/build/
184 | # Uncomment if necessary however generally it will be regenerated when needed
185 | #!**/[Pp]ackages/repositories.config
186 | # NuGet v3's project.json files produces more ignorable files
187 | *.nuget.props
188 | *.nuget.targets
189 |
190 | # Microsoft Azure Build Output
191 | csx/
192 | *.build.csdef
193 |
194 | # Microsoft Azure Emulator
195 | ecf/
196 | rcf/
197 |
198 | # Windows Store app package directories and files
199 | AppPackages/
200 | BundleArtifacts/
201 | Package.StoreAssociation.xml
202 | _pkginfo.txt
203 | *.appx
204 |
205 | # Visual Studio cache files
206 | # files ending in .cache can be ignored
207 | *.[Cc]ache
208 | # but keep track of directories ending in .cache
209 | !*.[Cc]ache/
210 |
211 | # Others
212 | ClientBin/
213 | ~$*
214 | *~
215 | *.dbmdl
216 | *.dbproj.schemaview
217 | *.jfm
218 | *.pfx
219 | *.publishsettings
220 | orleans.codegen.cs
221 |
222 | # Including strong name files can present a security risk
223 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
224 | #*.snk
225 |
226 | # Since there are multiple workflows, uncomment next line to ignore bower_components
227 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
228 | #bower_components/
229 |
230 | # RIA/Silverlight projects
231 | Generated_Code/
232 |
233 | # Backup & report files from converting an old project file
234 | # to a newer Visual Studio version. Backup files are not needed,
235 | # because we have git ;-)
236 | _UpgradeReport_Files/
237 | Backup*/
238 | UpgradeLog*.XML
239 | UpgradeLog*.htm
240 | ServiceFabricBackup/
241 |
242 | # SQL Server files
243 | *.mdf
244 | *.ldf
245 | *.ndf
246 |
247 | # Business Intelligence projects
248 | *.rdl.data
249 | *.bim.layout
250 | *.bim_*.settings
251 | *.rptproj.rsuser
252 |
253 | # Microsoft Fakes
254 | FakesAssemblies/
255 |
256 | # GhostDoc plugin setting file
257 | *.GhostDoc.xml
258 |
259 | # Node.js Tools for Visual Studio
260 | .ntvs_analysis.dat
261 | node_modules/
262 |
263 | # Visual Studio 6 build log
264 | *.plg
265 |
266 | # Visual Studio 6 workspace options file
267 | *.opt
268 |
269 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
270 | *.vbw
271 |
272 | # Visual Studio LightSwitch build output
273 | **/*.HTMLClient/GeneratedArtifacts
274 | **/*.DesktopClient/GeneratedArtifacts
275 | **/*.DesktopClient/ModelManifest.xml
276 | **/*.Server/GeneratedArtifacts
277 | **/*.Server/ModelManifest.xml
278 | _Pvt_Extensions
279 |
280 | # Paket dependency manager
281 | .paket/paket.exe
282 | paket-files/
283 |
284 | # FAKE - F# Make
285 | .fake/
286 |
287 | # JetBrains Rider
288 | .idea/
289 | *.sln.iml
290 |
291 | # CodeRush
292 | .cr/
293 |
294 | # Python Tools for Visual Studio (PTVS)
295 | __pycache__/
296 | *.pyc
297 |
298 | # Cake - Uncomment if you are using it
299 | # tools/**
300 | # !tools/packages.config
301 |
302 | # Tabs Studio
303 | *.tss
304 |
305 | # Telerik's JustMock configuration file
306 | *.jmconfig
307 |
308 | # BizTalk build output
309 | *.btp.cs
310 | *.btm.cs
311 | *.odx.cs
312 | *.xsd.cs
313 |
314 | # OpenCover UI analysis results
315 | OpenCover/
316 |
317 | # Azure Stream Analytics local run output
318 | ASALocalRun/
319 |
320 | # MSBuild Binary and Structured Log
321 | *.binlog
322 |
323 | # NVidia Nsight GPU debugger configuration file
324 | *.nvuser
325 | *.manifest
326 | *.exe
327 | triangle_mesh 1/obj/
328 | obj/
329 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "Mouse-Orbit"]
2 | path = Mouse-Orbit
3 | url = https://github.com/batu92k/Mouse-Orbit
4 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2023 Ali Batuhan KINDAN
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining
4 | a copy of this software and associated documentation files (the
5 | "Software"), to deal in the Software without restriction, including
6 | without limitation the rights to use, copy, modify, merge, publish,
7 | distribute, sublicense, and/or sell copies of the Software, and to
8 | permit persons to whom the Software is furnished to do so, subject to
9 | the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be
12 | included in all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # **STL Viewer v2.4.5**
2 |
3 | ## **About**
4 |
5 | Visualization tool for Binary and ASCII formatted STL files.
6 |
7 |
8 |
9 | ## **How to Use**
10 |
11 | * Click File->Import or use Drag-Drop to select and import **Binary** or **ASCII** formatted STL file
12 | * Hold right mouse button to **rotate** the object
13 | * Hold left mouse button to **move** the object
14 | * Use mouse wheel to **scale** the object
15 | * Press **R** key to **reset** view
16 |
17 | **Note:** Update Mouse Orbit submodule with **"git submodule update --init"** before building the project or clone the repository via **"git clone --recursive https://github.com/batu92k/STL-Viewer.git"**
18 |
19 | ## **v2.4.5 Release notes**
20 | * Better lighting of the model
21 |
22 | ## **v1.0 to v2.4.4 Release notes**
23 | * Drag-Drop feature implemented
24 | * Toolbar added to UI with Help and File menus
25 | * Mouse Orbit module upgraded
26 | * Tao Framework changed to more up to date OpenGL Frameork OpenTK
27 | * Mouse Orbit feature implemented to rotate, move, scale the object
28 | * Model alignment adjusted
29 | * OpenGL lighting and material features improved
30 |
31 |
--------------------------------------------------------------------------------
/STL-Viewer.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.29411.108
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "STL-Viewer", "STL-Viewer\STL-Viewer.csproj", "{50493E1F-6012-49DC-ABA7-0DF6F019E79F}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {50493E1F-6012-49DC-ABA7-0DF6F019E79F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {50493E1F-6012-49DC-ABA7-0DF6F019E79F}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {50493E1F-6012-49DC-ABA7-0DF6F019E79F}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {50493E1F-6012-49DC-ABA7-0DF6F019E79F}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {367D125D-89C4-4262-A13E-439E11798D81}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/STL-Viewer/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/STL-Viewer/AppAboutForm.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace STLViewer
2 | {
3 | partial class AppAboutForm
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows Form Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AppAboutForm));
32 | this.AppLogoPicBx = new System.Windows.Forms.PictureBox();
33 | this.AppNameLb = new System.Windows.Forms.Label();
34 | this.AuthorEMailLb = new System.Windows.Forms.Label();
35 | this.AppVersionLb = new System.Windows.Forms.Label();
36 | this.AuthorTitleLb = new System.Windows.Forms.Label();
37 | this.CloseBt = new System.Windows.Forms.Button();
38 | this.AuthorNameLinkLb = new System.Windows.Forms.LinkLabel();
39 | ((System.ComponentModel.ISupportInitialize)(this.AppLogoPicBx)).BeginInit();
40 | this.SuspendLayout();
41 | //
42 | // AppLogoPicBx
43 | //
44 | this.AppLogoPicBx.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
45 | | System.Windows.Forms.AnchorStyles.Left)
46 | | System.Windows.Forms.AnchorStyles.Right)));
47 | this.AppLogoPicBx.BackgroundImage = global::STLViewer.Properties.Resources.stl_viewer_iconpng;
48 | this.AppLogoPicBx.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
49 | this.AppLogoPicBx.Location = new System.Drawing.Point(196, 15);
50 | this.AppLogoPicBx.Name = "AppLogoPicBx";
51 | this.AppLogoPicBx.Size = new System.Drawing.Size(120, 120);
52 | this.AppLogoPicBx.TabIndex = 1;
53 | this.AppLogoPicBx.TabStop = false;
54 | //
55 | // AppNameLb
56 | //
57 | this.AppNameLb.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
58 | | System.Windows.Forms.AnchorStyles.Left)
59 | | System.Windows.Forms.AnchorStyles.Right)));
60 | this.AppNameLb.BackColor = System.Drawing.Color.Transparent;
61 | this.AppNameLb.Font = new System.Drawing.Font("Segoe UI", 13.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(162)));
62 | this.AppNameLb.ForeColor = System.Drawing.Color.Gainsboro;
63 | this.AppNameLb.Location = new System.Drawing.Point(186, 145);
64 | this.AppNameLb.Name = "AppNameLb";
65 | this.AppNameLb.Size = new System.Drawing.Size(139, 32);
66 | this.AppNameLb.TabIndex = 2;
67 | this.AppNameLb.Text = "STL Viewer";
68 | this.AppNameLb.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
69 | //
70 | // AuthorEMailLb
71 | //
72 | this.AuthorEMailLb.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
73 | | System.Windows.Forms.AnchorStyles.Left)
74 | | System.Windows.Forms.AnchorStyles.Right)));
75 | this.AuthorEMailLb.BackColor = System.Drawing.Color.Transparent;
76 | this.AuthorEMailLb.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(162)));
77 | this.AuthorEMailLb.ForeColor = System.Drawing.Color.Gainsboro;
78 | this.AuthorEMailLb.Location = new System.Drawing.Point(122, 290);
79 | this.AuthorEMailLb.Name = "AuthorEMailLb";
80 | this.AuthorEMailLb.Size = new System.Drawing.Size(270, 28);
81 | this.AuthorEMailLb.TabIndex = 3;
82 | this.AuthorEMailLb.Text = "batuhan.kindan@gmail.com";
83 | this.AuthorEMailLb.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
84 | //
85 | // AppVersionLb
86 | //
87 | this.AppVersionLb.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
88 | | System.Windows.Forms.AnchorStyles.Left)
89 | | System.Windows.Forms.AnchorStyles.Right)));
90 | this.AppVersionLb.BackColor = System.Drawing.Color.Transparent;
91 | this.AppVersionLb.Font = new System.Drawing.Font("Segoe UI", 13.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(162)));
92 | this.AppVersionLb.ForeColor = System.Drawing.Color.Gainsboro;
93 | this.AppVersionLb.Location = new System.Drawing.Point(173, 180);
94 | this.AppVersionLb.Name = "AppVersionLb";
95 | this.AppVersionLb.Size = new System.Drawing.Size(163, 32);
96 | this.AppVersionLb.TabIndex = 4;
97 | this.AppVersionLb.Text = "Version 2.4.5";
98 | this.AppVersionLb.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
99 | //
100 | // AuthorTitleLb
101 | //
102 | this.AuthorTitleLb.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
103 | | System.Windows.Forms.AnchorStyles.Left)
104 | | System.Windows.Forms.AnchorStyles.Right)));
105 | this.AuthorTitleLb.BackColor = System.Drawing.Color.Transparent;
106 | this.AuthorTitleLb.Font = new System.Drawing.Font("Segoe UI", 13.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(162)));
107 | this.AuthorTitleLb.ForeColor = System.Drawing.Color.Gainsboro;
108 | this.AuthorTitleLb.Location = new System.Drawing.Point(121, 230);
109 | this.AuthorTitleLb.Name = "AuthorTitleLb";
110 | this.AuthorTitleLb.Size = new System.Drawing.Size(270, 28);
111 | this.AuthorTitleLb.TabIndex = 5;
112 | this.AuthorTitleLb.Text = "Author";
113 | this.AuthorTitleLb.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
114 | //
115 | // CloseBt
116 | //
117 | this.CloseBt.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
118 | | System.Windows.Forms.AnchorStyles.Left)
119 | | System.Windows.Forms.AnchorStyles.Right)));
120 | this.CloseBt.BackColor = System.Drawing.Color.BlanchedAlmond;
121 | this.CloseBt.FlatAppearance.BorderSize = 0;
122 | this.CloseBt.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
123 | this.CloseBt.Location = new System.Drawing.Point(206, 335);
124 | this.CloseBt.Name = "CloseBt";
125 | this.CloseBt.Size = new System.Drawing.Size(100, 35);
126 | this.CloseBt.TabIndex = 6;
127 | this.CloseBt.Text = "Close";
128 | this.CloseBt.UseVisualStyleBackColor = false;
129 | this.CloseBt.Click += new System.EventHandler(this.CloseBt_Click);
130 | //
131 | // AuthorNameLinkLb
132 | //
133 | this.AuthorNameLinkLb.ActiveLinkColor = System.Drawing.Color.Gainsboro;
134 | this.AuthorNameLinkLb.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
135 | | System.Windows.Forms.AnchorStyles.Left)
136 | | System.Windows.Forms.AnchorStyles.Right)));
137 | this.AuthorNameLinkLb.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(162)));
138 | this.AuthorNameLinkLb.LinkColor = System.Drawing.Color.Gainsboro;
139 | this.AuthorNameLinkLb.Location = new System.Drawing.Point(122, 262);
140 | this.AuthorNameLinkLb.Name = "AuthorNameLinkLb";
141 | this.AuthorNameLinkLb.Size = new System.Drawing.Size(270, 28);
142 | this.AuthorNameLinkLb.TabIndex = 7;
143 | this.AuthorNameLinkLb.TabStop = true;
144 | this.AuthorNameLinkLb.Text = "Ali Batuhan KINDAN";
145 | this.AuthorNameLinkLb.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
146 | this.AuthorNameLinkLb.VisitedLinkColor = System.Drawing.Color.Gainsboro;
147 | //
148 | // AppAboutForm
149 | //
150 | this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 19F);
151 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
152 | this.BackColor = System.Drawing.Color.DarkSlateBlue;
153 | this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
154 | this.ClientSize = new System.Drawing.Size(512, 384);
155 | this.Controls.Add(this.AuthorNameLinkLb);
156 | this.Controls.Add(this.CloseBt);
157 | this.Controls.Add(this.AuthorTitleLb);
158 | this.Controls.Add(this.AppVersionLb);
159 | this.Controls.Add(this.AuthorEMailLb);
160 | this.Controls.Add(this.AppNameLb);
161 | this.Controls.Add(this.AppLogoPicBx);
162 | this.DoubleBuffered = true;
163 | this.Font = new System.Drawing.Font("Segoe UI", 10.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(162)));
164 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
165 | this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
166 | this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
167 | this.Name = "AppAboutForm";
168 | this.Text = "AppAboutForm";
169 | ((System.ComponentModel.ISupportInitialize)(this.AppLogoPicBx)).EndInit();
170 | this.ResumeLayout(false);
171 |
172 | }
173 |
174 | #endregion
175 | private System.Windows.Forms.PictureBox AppLogoPicBx;
176 | private System.Windows.Forms.Label AppNameLb;
177 | private System.Windows.Forms.Label AuthorEMailLb;
178 | private System.Windows.Forms.Label AppVersionLb;
179 | private System.Windows.Forms.Label AuthorTitleLb;
180 | private System.Windows.Forms.Button CloseBt;
181 | private System.Windows.Forms.LinkLabel AuthorNameLinkLb;
182 | }
183 | }
--------------------------------------------------------------------------------
/STL-Viewer/AppAboutForm.cs:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file AppAboutForm.cs
4 | * @author Ali Batuhan KINDAN
5 | * @date 19.02.2020
6 | * @brief This file is contains the functionality of application About window
7 | ******************************************************************************
8 | */
9 |
10 | using System;
11 | using System.Windows.Forms;
12 |
13 | namespace STLViewer
14 | {
15 | public partial class AppAboutForm : Form
16 | {
17 | public AppAboutForm()
18 | {
19 | InitializeComponent();
20 | CenterToScreen(); // open center of the screen
21 | AuthorNameLinkLb.LinkArea = new LinkArea(0, 22);
22 | AuthorNameLinkLb.Links.Add(24, 9, "https://github.com/batu92k");
23 | AuthorNameLinkLb.LinkClicked += new LinkLabelLinkClickedEventHandler(LinkedLabelClicked);
24 | }
25 |
26 | private void CloseBt_Click(object sender, EventArgs e)
27 | {
28 | this.Close();
29 | }
30 |
31 | private void LinkedLabelClicked(object sender, LinkLabelLinkClickedEventArgs e)
32 | {
33 | AuthorNameLinkLb.LinkVisited = true;
34 | System.Diagnostics.Process.Start("https://github.com/batu92k");
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/STL-Viewer/AppHowToUseForm.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace STLViewer
2 | {
3 | partial class AppHowToUseForm
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows Form Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AppHowToUseForm));
32 | this.HowToUseTitleLb = new System.Windows.Forms.Label();
33 | this.Info_1Lb = new System.Windows.Forms.Label();
34 | this.Info_2Lb = new System.Windows.Forms.Label();
35 | this.Info_3Lb = new System.Windows.Forms.Label();
36 | this.Info_4Lb = new System.Windows.Forms.Label();
37 | this.Info_5Lb = new System.Windows.Forms.Label();
38 | this.CloseBt = new System.Windows.Forms.Button();
39 | this.SuspendLayout();
40 | //
41 | // HowToUseTitleLb
42 | //
43 | this.HowToUseTitleLb.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
44 | | System.Windows.Forms.AnchorStyles.Left)
45 | | System.Windows.Forms.AnchorStyles.Right)));
46 | this.HowToUseTitleLb.Font = new System.Drawing.Font("Segoe UI", 16.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(162)));
47 | this.HowToUseTitleLb.ForeColor = System.Drawing.Color.Gainsboro;
48 | this.HowToUseTitleLb.Location = new System.Drawing.Point(225, 33);
49 | this.HowToUseTitleLb.Name = "HowToUseTitleLb";
50 | this.HowToUseTitleLb.Size = new System.Drawing.Size(200, 35);
51 | this.HowToUseTitleLb.TabIndex = 0;
52 | this.HowToUseTitleLb.Text = "How to Use";
53 | this.HowToUseTitleLb.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
54 | //
55 | // Info_1Lb
56 | //
57 | this.Info_1Lb.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
58 | | System.Windows.Forms.AnchorStyles.Left)
59 | | System.Windows.Forms.AnchorStyles.Right)));
60 | this.Info_1Lb.BackColor = System.Drawing.Color.Transparent;
61 | this.Info_1Lb.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(162)));
62 | this.Info_1Lb.ForeColor = System.Drawing.Color.Gainsboro;
63 | this.Info_1Lb.Location = new System.Drawing.Point(45, 120);
64 | this.Info_1Lb.Name = "Info_1Lb";
65 | this.Info_1Lb.Size = new System.Drawing.Size(550, 35);
66 | this.Info_1Lb.TabIndex = 1;
67 | this.Info_1Lb.Text = " Click File->Import or use Drag-Drop to select STL files";
68 | this.Info_1Lb.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
69 | //
70 | // Info_2Lb
71 | //
72 | this.Info_2Lb.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
73 | | System.Windows.Forms.AnchorStyles.Left)
74 | | System.Windows.Forms.AnchorStyles.Right)));
75 | this.Info_2Lb.BackColor = System.Drawing.Color.Transparent;
76 | this.Info_2Lb.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(162)));
77 | this.Info_2Lb.ForeColor = System.Drawing.Color.Gainsboro;
78 | this.Info_2Lb.Location = new System.Drawing.Point(45, 170);
79 | this.Info_2Lb.Name = "Info_2Lb";
80 | this.Info_2Lb.Size = new System.Drawing.Size(550, 35);
81 | this.Info_2Lb.TabIndex = 2;
82 | this.Info_2Lb.Text = "Hold right mouse button to rotate the object";
83 | this.Info_2Lb.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
84 | //
85 | // Info_3Lb
86 | //
87 | this.Info_3Lb.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
88 | | System.Windows.Forms.AnchorStyles.Left)
89 | | System.Windows.Forms.AnchorStyles.Right)));
90 | this.Info_3Lb.BackColor = System.Drawing.Color.Transparent;
91 | this.Info_3Lb.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(162)));
92 | this.Info_3Lb.ForeColor = System.Drawing.Color.Gainsboro;
93 | this.Info_3Lb.Location = new System.Drawing.Point(45, 220);
94 | this.Info_3Lb.Name = "Info_3Lb";
95 | this.Info_3Lb.Size = new System.Drawing.Size(550, 35);
96 | this.Info_3Lb.TabIndex = 3;
97 | this.Info_3Lb.Text = "Hold left mouse button to move the object";
98 | this.Info_3Lb.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
99 | //
100 | // Info_4Lb
101 | //
102 | this.Info_4Lb.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
103 | | System.Windows.Forms.AnchorStyles.Left)
104 | | System.Windows.Forms.AnchorStyles.Right)));
105 | this.Info_4Lb.BackColor = System.Drawing.Color.Transparent;
106 | this.Info_4Lb.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(162)));
107 | this.Info_4Lb.ForeColor = System.Drawing.Color.Gainsboro;
108 | this.Info_4Lb.Location = new System.Drawing.Point(45, 270);
109 | this.Info_4Lb.Name = "Info_4Lb";
110 | this.Info_4Lb.Size = new System.Drawing.Size(550, 35);
111 | this.Info_4Lb.TabIndex = 4;
112 | this.Info_4Lb.Text = "Use mouse wheel to scale the object";
113 | this.Info_4Lb.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
114 | //
115 | // Info_5Lb
116 | //
117 | this.Info_5Lb.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
118 | | System.Windows.Forms.AnchorStyles.Left)
119 | | System.Windows.Forms.AnchorStyles.Right)));
120 | this.Info_5Lb.BackColor = System.Drawing.Color.Transparent;
121 | this.Info_5Lb.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(162)));
122 | this.Info_5Lb.ForeColor = System.Drawing.Color.Gainsboro;
123 | this.Info_5Lb.Location = new System.Drawing.Point(45, 320);
124 | this.Info_5Lb.Name = "Info_5Lb";
125 | this.Info_5Lb.Size = new System.Drawing.Size(550, 35);
126 | this.Info_5Lb.TabIndex = 5;
127 | this.Info_5Lb.Text = "Press R key to reset view";
128 | this.Info_5Lb.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
129 | //
130 | // CloseBt
131 | //
132 | this.CloseBt.BackColor = System.Drawing.Color.BlanchedAlmond;
133 | this.CloseBt.FlatAppearance.BorderSize = 0;
134 | this.CloseBt.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
135 | this.CloseBt.Location = new System.Drawing.Point(267, 395);
136 | this.CloseBt.Name = "CloseBt";
137 | this.CloseBt.Size = new System.Drawing.Size(100, 40);
138 | this.CloseBt.TabIndex = 6;
139 | this.CloseBt.Text = "Close";
140 | this.CloseBt.UseVisualStyleBackColor = false;
141 | this.CloseBt.Click += new System.EventHandler(this.CloseBt_Click);
142 | //
143 | // AppHowToUseForm
144 | //
145 | this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 23F);
146 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
147 | this.BackColor = System.Drawing.Color.DarkSlateBlue;
148 | this.BackgroundImage = global::STLViewer.Properties.Resources.stl_viewer_iconpng;
149 | this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
150 | this.ClientSize = new System.Drawing.Size(640, 480);
151 | this.Controls.Add(this.CloseBt);
152 | this.Controls.Add(this.Info_5Lb);
153 | this.Controls.Add(this.Info_4Lb);
154 | this.Controls.Add(this.Info_3Lb);
155 | this.Controls.Add(this.Info_2Lb);
156 | this.Controls.Add(this.Info_1Lb);
157 | this.Controls.Add(this.HowToUseTitleLb);
158 | this.DoubleBuffered = true;
159 | this.Font = new System.Drawing.Font("Segoe UI", 10.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(162)));
160 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
161 | this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
162 | this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
163 | this.Name = "AppHowToUseForm";
164 | this.Text = "AppHowToUseForm";
165 | this.ResumeLayout(false);
166 |
167 | }
168 |
169 | #endregion
170 |
171 | private System.Windows.Forms.Label HowToUseTitleLb;
172 | private System.Windows.Forms.Label Info_1Lb;
173 | private System.Windows.Forms.Label Info_2Lb;
174 | private System.Windows.Forms.Label Info_3Lb;
175 | private System.Windows.Forms.Label Info_4Lb;
176 | private System.Windows.Forms.Label Info_5Lb;
177 | private System.Windows.Forms.Button CloseBt;
178 | }
179 | }
--------------------------------------------------------------------------------
/STL-Viewer/AppHowToUseForm.cs:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file AppHowToUseForm.cs
4 | * @author Ali Batuhan KINDAN
5 | * @date 19.02.2020
6 | * @brief This file is contains the functionality of application How to Use window
7 | ******************************************************************************
8 | */
9 |
10 | using System;
11 | using System.Windows.Forms;
12 |
13 | namespace STLViewer
14 | {
15 | public partial class AppHowToUseForm : Form
16 | {
17 | public AppHowToUseForm()
18 | {
19 | InitializeComponent();
20 | CenterToScreen();
21 | }
22 |
23 | private void CloseBt_Click(object sender, EventArgs e)
24 | {
25 | this.Close();
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/STL-Viewer/AppMainForm.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace STLViewer
2 | {
3 | partial class AppMainForm
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows Form Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.components = new System.ComponentModel.Container();
32 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AppMainForm));
33 | this.DrawTimer = new System.Windows.Forms.Timer(this.components);
34 | this.GL_Monitor = new OpenTK.GLControl();
35 | this.AppToolBarMStp = new System.Windows.Forms.MenuStrip();
36 | this.ToolBarFileMenuBt = new System.Windows.Forms.ToolStripMenuItem();
37 | this.FileMenuImportBt = new System.Windows.Forms.ToolStripMenuItem();
38 | this.FileMenuExitBt = new System.Windows.Forms.ToolStripMenuItem();
39 | this.ToolBarHelpMenuBt = new System.Windows.Forms.ToolStripMenuItem();
40 | this.HelpMenuHowToUseBt = new System.Windows.Forms.ToolStripMenuItem();
41 | this.HelpMenuAboutBt = new System.Windows.Forms.ToolStripMenuItem();
42 | this.CloseBt = new System.Windows.Forms.Button();
43 | this.MinimizeBt = new System.Windows.Forms.Button();
44 | this.AppTitleSymbolPicBx = new System.Windows.Forms.PictureBox();
45 | this.MaximizeBt = new System.Windows.Forms.Button();
46 | this.AppTitleLb = new System.Windows.Forms.Label();
47 | this.AppToolBarMStp.SuspendLayout();
48 | ((System.ComponentModel.ISupportInitialize)(this.AppTitleSymbolPicBx)).BeginInit();
49 | this.SuspendLayout();
50 | //
51 | // DrawTimer
52 | //
53 | this.DrawTimer.Enabled = true;
54 | this.DrawTimer.Interval = 25;
55 | this.DrawTimer.Tick += new System.EventHandler(this.DrawTimer_Tick);
56 | //
57 | // GL_Monitor
58 | //
59 | this.GL_Monitor.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
60 | this.GL_Monitor.Dock = System.Windows.Forms.DockStyle.Fill;
61 | this.GL_Monitor.Location = new System.Drawing.Point(0, 32);
62 | this.GL_Monitor.Name = "GL_Monitor";
63 | this.GL_Monitor.Size = new System.Drawing.Size(784, 514);
64 | this.GL_Monitor.TabIndex = 15;
65 | this.GL_Monitor.VSync = false;
66 | this.GL_Monitor.Load += new System.EventHandler(this.GL_Monitor_Load);
67 | this.GL_Monitor.DragDrop += new System.Windows.Forms.DragEventHandler(this.GL_Monitor_DragDrop);
68 | this.GL_Monitor.DragEnter += new System.Windows.Forms.DragEventHandler(this.GL_Monitor_DragEnter);
69 | this.GL_Monitor.Paint += new System.Windows.Forms.PaintEventHandler(this.GL_Monitor_Paint);
70 | //
71 | // AppToolBarMStp
72 | //
73 | this.AppToolBarMStp.AutoSize = false;
74 | this.AppToolBarMStp.BackColor = System.Drawing.Color.DarkSlateBlue;
75 | this.AppToolBarMStp.Font = new System.Drawing.Font("Segoe UI", 12F);
76 | this.AppToolBarMStp.ImageScalingSize = new System.Drawing.Size(20, 20);
77 | this.AppToolBarMStp.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
78 | this.ToolBarFileMenuBt,
79 | this.ToolBarHelpMenuBt});
80 | this.AppToolBarMStp.Location = new System.Drawing.Point(0, 0);
81 | this.AppToolBarMStp.Name = "AppToolBarMStp";
82 | this.AppToolBarMStp.Padding = new System.Windows.Forms.Padding(4, 2, 0, 2);
83 | this.AppToolBarMStp.Size = new System.Drawing.Size(784, 32);
84 | this.AppToolBarMStp.TabIndex = 16;
85 | this.AppToolBarMStp.Text = "AppToolBar";
86 | this.AppToolBarMStp.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.AppToolBarMStp_MouseDoubleClick);
87 | this.AppToolBarMStp.MouseDown += new System.Windows.Forms.MouseEventHandler(this.AppToolBarMStp_MouseDown);
88 | this.AppToolBarMStp.MouseUp += new System.Windows.Forms.MouseEventHandler(this.AppToolBarMStp_MouseUp);
89 | //
90 | // ToolBarFileMenuBt
91 | //
92 | this.ToolBarFileMenuBt.BackColor = System.Drawing.Color.DarkSlateBlue;
93 | this.ToolBarFileMenuBt.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
94 | this.FileMenuImportBt,
95 | this.FileMenuExitBt});
96 | this.ToolBarFileMenuBt.Font = new System.Drawing.Font("Segoe UI", 10.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(162)));
97 | this.ToolBarFileMenuBt.Margin = new System.Windows.Forms.Padding(35, 0, 0, 0);
98 | this.ToolBarFileMenuBt.Name = "ToolBarFileMenuBt";
99 | this.ToolBarFileMenuBt.Size = new System.Drawing.Size(41, 28);
100 | this.ToolBarFileMenuBt.Text = "File";
101 | //
102 | // FileMenuImportBt
103 | //
104 | this.FileMenuImportBt.BackColor = System.Drawing.SystemColors.ControlLight;
105 | this.FileMenuImportBt.Name = "FileMenuImportBt";
106 | this.FileMenuImportBt.Size = new System.Drawing.Size(120, 24);
107 | this.FileMenuImportBt.Text = "Import";
108 | this.FileMenuImportBt.Click += new System.EventHandler(this.FileMenuImportBt_Click);
109 | //
110 | // FileMenuExitBt
111 | //
112 | this.FileMenuExitBt.BackColor = System.Drawing.SystemColors.ControlLight;
113 | this.FileMenuExitBt.Name = "FileMenuExitBt";
114 | this.FileMenuExitBt.Size = new System.Drawing.Size(120, 24);
115 | this.FileMenuExitBt.Text = "Exit";
116 | this.FileMenuExitBt.Click += new System.EventHandler(this.FileMenuExitBt_Click);
117 | //
118 | // ToolBarHelpMenuBt
119 | //
120 | this.ToolBarHelpMenuBt.BackColor = System.Drawing.Color.DarkSlateBlue;
121 | this.ToolBarHelpMenuBt.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
122 | this.HelpMenuHowToUseBt,
123 | this.HelpMenuAboutBt});
124 | this.ToolBarHelpMenuBt.Font = new System.Drawing.Font("Segoe UI", 10.2F);
125 | this.ToolBarHelpMenuBt.Name = "ToolBarHelpMenuBt";
126 | this.ToolBarHelpMenuBt.Size = new System.Drawing.Size(49, 28);
127 | this.ToolBarHelpMenuBt.Text = "Help";
128 | //
129 | // HelpMenuHowToUseBt
130 | //
131 | this.HelpMenuHowToUseBt.BackColor = System.Drawing.SystemColors.ControlLight;
132 | this.HelpMenuHowToUseBt.Name = "HelpMenuHowToUseBt";
133 | this.HelpMenuHowToUseBt.Size = new System.Drawing.Size(150, 24);
134 | this.HelpMenuHowToUseBt.Text = "How to Use";
135 | this.HelpMenuHowToUseBt.Click += new System.EventHandler(this.HelpMenuHowToUseBt_Click);
136 | //
137 | // HelpMenuAboutBt
138 | //
139 | this.HelpMenuAboutBt.BackColor = System.Drawing.SystemColors.ControlLight;
140 | this.HelpMenuAboutBt.Name = "HelpMenuAboutBt";
141 | this.HelpMenuAboutBt.Size = new System.Drawing.Size(150, 24);
142 | this.HelpMenuAboutBt.Text = "About";
143 | this.HelpMenuAboutBt.Click += new System.EventHandler(this.HelpMenuAboutBt_Click);
144 | //
145 | // CloseBt
146 | //
147 | this.CloseBt.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
148 | this.CloseBt.BackColor = System.Drawing.Color.DarkSlateBlue;
149 | this.CloseBt.FlatAppearance.BorderSize = 0;
150 | this.CloseBt.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
151 | this.CloseBt.Font = new System.Drawing.Font("Microsoft Sans Serif", 10.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(162)));
152 | this.CloseBt.ForeColor = System.Drawing.Color.Black;
153 | this.CloseBt.Location = new System.Drawing.Point(754, 0);
154 | this.CloseBt.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
155 | this.CloseBt.Name = "CloseBt";
156 | this.CloseBt.Size = new System.Drawing.Size(30, 32);
157 | this.CloseBt.TabIndex = 18;
158 | this.CloseBt.Text = "X";
159 | this.CloseBt.UseVisualStyleBackColor = false;
160 | this.CloseBt.Click += new System.EventHandler(this.CloseBt_Click);
161 | //
162 | // MinimizeBt
163 | //
164 | this.MinimizeBt.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
165 | this.MinimizeBt.BackColor = System.Drawing.Color.DarkSlateBlue;
166 | this.MinimizeBt.FlatAppearance.BorderSize = 0;
167 | this.MinimizeBt.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
168 | this.MinimizeBt.Font = new System.Drawing.Font("Microsoft Sans Serif", 13.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(162)));
169 | this.MinimizeBt.ForeColor = System.Drawing.Color.Black;
170 | this.MinimizeBt.Location = new System.Drawing.Point(685, 0);
171 | this.MinimizeBt.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
172 | this.MinimizeBt.Name = "MinimizeBt";
173 | this.MinimizeBt.Size = new System.Drawing.Size(30, 32);
174 | this.MinimizeBt.TabIndex = 19;
175 | this.MinimizeBt.Text = "-";
176 | this.MinimizeBt.UseVisualStyleBackColor = false;
177 | this.MinimizeBt.Click += new System.EventHandler(this.MinimizeBt_Click);
178 | //
179 | // AppTitleSymbolPicBx
180 | //
181 | this.AppTitleSymbolPicBx.BackColor = System.Drawing.Color.DarkSlateBlue;
182 | this.AppTitleSymbolPicBx.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("AppTitleSymbolPicBx.BackgroundImage")));
183 | this.AppTitleSymbolPicBx.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
184 | this.AppTitleSymbolPicBx.ImageLocation = "";
185 | this.AppTitleSymbolPicBx.Location = new System.Drawing.Point(6, 4);
186 | this.AppTitleSymbolPicBx.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
187 | this.AppTitleSymbolPicBx.Name = "AppTitleSymbolPicBx";
188 | this.AppTitleSymbolPicBx.Size = new System.Drawing.Size(22, 24);
189 | this.AppTitleSymbolPicBx.TabIndex = 20;
190 | this.AppTitleSymbolPicBx.TabStop = false;
191 | //
192 | // MaximizeBt
193 | //
194 | this.MaximizeBt.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
195 | this.MaximizeBt.BackColor = System.Drawing.Color.DarkSlateBlue;
196 | this.MaximizeBt.FlatAppearance.BorderSize = 0;
197 | this.MaximizeBt.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
198 | this.MaximizeBt.Font = new System.Drawing.Font("Microsoft Sans Serif", 13.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(162)));
199 | this.MaximizeBt.ForeColor = System.Drawing.Color.Black;
200 | this.MaximizeBt.Location = new System.Drawing.Point(719, 0);
201 | this.MaximizeBt.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
202 | this.MaximizeBt.Name = "MaximizeBt";
203 | this.MaximizeBt.Size = new System.Drawing.Size(30, 32);
204 | this.MaximizeBt.TabIndex = 21;
205 | this.MaximizeBt.Text = "▭";
206 | this.MaximizeBt.UseVisualStyleBackColor = false;
207 | this.MaximizeBt.Click += new System.EventHandler(this.MaximizeBt_Click);
208 | //
209 | // AppTitleLb
210 | //
211 | this.AppTitleLb.Anchor = System.Windows.Forms.AnchorStyles.Top;
212 | this.AppTitleLb.BackColor = System.Drawing.Color.DarkSlateBlue;
213 | this.AppTitleLb.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(162)));
214 | this.AppTitleLb.Location = new System.Drawing.Point(300, 0);
215 | this.AppTitleLb.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
216 | this.AppTitleLb.Name = "AppTitleLb";
217 | this.AppTitleLb.Size = new System.Drawing.Size(180, 32);
218 | this.AppTitleLb.TabIndex = 22;
219 | this.AppTitleLb.Text = "STL Viewer v2.4.5";
220 | this.AppTitleLb.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
221 | this.AppTitleLb.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.AppTitleLb_MouseDoubleClick);
222 | this.AppTitleLb.MouseDown += new System.Windows.Forms.MouseEventHandler(this.AppTitleLb_MouseDown);
223 | this.AppTitleLb.MouseUp += new System.Windows.Forms.MouseEventHandler(this.AppTitleLb_MouseUp);
224 | //
225 | // AppMainForm
226 | //
227 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
228 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
229 | this.ClientSize = new System.Drawing.Size(784, 546);
230 | this.Controls.Add(this.AppTitleLb);
231 | this.Controls.Add(this.MaximizeBt);
232 | this.Controls.Add(this.AppTitleSymbolPicBx);
233 | this.Controls.Add(this.MinimizeBt);
234 | this.Controls.Add(this.CloseBt);
235 | this.Controls.Add(this.GL_Monitor);
236 | this.Controls.Add(this.AppToolBarMStp);
237 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
238 | this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
239 | this.MainMenuStrip = this.AppToolBarMStp;
240 | this.Name = "AppMainForm";
241 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
242 | this.Text = "STL Viewer";
243 | this.Load += new System.EventHandler(this.Form1_Load);
244 | this.AppToolBarMStp.ResumeLayout(false);
245 | this.AppToolBarMStp.PerformLayout();
246 | ((System.ComponentModel.ISupportInitialize)(this.AppTitleSymbolPicBx)).EndInit();
247 | this.ResumeLayout(false);
248 |
249 | }
250 |
251 | #endregion
252 | private System.Windows.Forms.Timer DrawTimer;
253 | private OpenTK.GLControl GL_Monitor;
254 | private System.Windows.Forms.MenuStrip AppToolBarMStp;
255 | private System.Windows.Forms.ToolStripMenuItem ToolBarFileMenuBt;
256 | private System.Windows.Forms.ToolStripMenuItem FileMenuImportBt;
257 | private System.Windows.Forms.ToolStripMenuItem FileMenuExitBt;
258 | private System.Windows.Forms.Button CloseBt;
259 | private System.Windows.Forms.Button MinimizeBt;
260 | private System.Windows.Forms.PictureBox AppTitleSymbolPicBx;
261 | private System.Windows.Forms.Button MaximizeBt;
262 | private System.Windows.Forms.ToolStripMenuItem ToolBarHelpMenuBt;
263 | private System.Windows.Forms.ToolStripMenuItem HelpMenuHowToUseBt;
264 | private System.Windows.Forms.ToolStripMenuItem HelpMenuAboutBt;
265 | private System.Windows.Forms.Label AppTitleLb;
266 | }
267 | }
268 |
269 |
--------------------------------------------------------------------------------
/STL-Viewer/AppMainForm.cs:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file AppMainForm.cs
4 | * @author Ali Batuhan KINDAN
5 | * @date 21.09.2016
6 | * @brief This file contains the implementaion of main application form functionality
7 | ******************************************************************************
8 | */
9 |
10 | using System;
11 | using System.Drawing;
12 | using System.Windows.Forms;
13 | using System.Globalization;
14 | using System.Threading;
15 | using STL_Tools;
16 | using OpenTK.Graphics.OpenGL;
17 | using BatuGL;
18 | using Mouse_Orbit;
19 |
20 | namespace STLViewer
21 | {
22 | public partial class AppMainForm : Form
23 | {
24 | bool monitorLoaded = false;
25 | bool moveForm = false;
26 | int moveOffsetX = 0;
27 | int moveOffsetY = 0;
28 | Batu_GL.VAO_TRIANGLES modelVAO = null; // 3d model vertex array object
29 | private Orbiter orb;
30 | Vector3 minPos = new Vector3();
31 | Vector3 maxPos = new Vector3();
32 | private const float kScaleFactor = 5.0f;
33 |
34 | public AppMainForm()
35 | {
36 | /* dot/comma selection for floating point numbers */
37 | Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
38 | Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");
39 | InitializeComponent();
40 | orb = new Orbiter();
41 | GL_Monitor.MouseDown += orb.Control_MouseDownEvent;
42 | GL_Monitor.MouseUp += orb.Control_MouseUpEvent;
43 | GL_Monitor.MouseWheel += orb.Control_MouseWheelEvent;
44 | GL_Monitor.KeyPress += orb.Control_KeyPress_Event;
45 | }
46 |
47 | private void DrawTimer_Tick(object sender, EventArgs e)
48 | {
49 | orb.UpdateOrbiter(MousePosition.X, MousePosition.Y);
50 | GL_Monitor.Invalidate();
51 | if (moveForm)
52 | {
53 | this.SetDesktopLocation(MousePosition.X - moveOffsetX, MousePosition.Y - moveOffsetY);
54 | }
55 | }
56 |
57 | private void GL_Monitor_Load(object sender, EventArgs e)
58 | {
59 | GL_Monitor.AllowDrop = true;
60 | monitorLoaded = true;
61 | GL.ClearColor(Color.Black);
62 | }
63 |
64 | private void Form1_Load(object sender, EventArgs e)
65 | {
66 | Batu_GL.Configure(GL_Monitor, Batu_GL.Ortho_Mode.CENTER);
67 | }
68 |
69 | private void ConfigureBasicLighting(Color modelColor)
70 | {
71 | float[] light_1 = new float[] {
72 | 0.2f * modelColor.R / 255.0f,
73 | 0.2f * modelColor.G / 255.0f,
74 | 0.2f * modelColor.B / 255.0f,
75 | 1.0f };
76 | float[] light_2 = new float[] {
77 | 10.0f * modelColor.R / 255.0f,
78 | 10.0f * modelColor.G / 255.0f,
79 | 10.0f * modelColor.B / 255.0f,
80 | 1.0f };
81 | float[] specref = new float[] {
82 | 0.2f * modelColor.R / 255.0f,
83 | 0.2f * modelColor.G / 255.0f,
84 | 0.2f * modelColor.B / 255.0f,
85 | 1.0f };
86 | float[] specular_0 = new float[] { -1.0f, -1.0f, 1.0f, 1.0f };
87 | float[] specular_1 = new float[] { 1.0f, -1.0f, 1.0f, 1.0f };
88 | float[] lightPos_0 = new float[] { 1000f, 1000f, -200.0f, 0.0f };
89 | float[] lightPos_1 = new float[] { -1000f, 1000f, -200.0f, 0.0f };
90 |
91 | GL.Enable(EnableCap.Lighting);
92 | /* light 0 */
93 | GL.Light(LightName.Light0, LightParameter.Ambient, light_1);
94 | GL.Light(LightName.Light0, LightParameter.Diffuse, light_2);
95 | GL.Light(LightName.Light0, LightParameter.Specular, specular_0);
96 | GL.Light(LightName.Light0, LightParameter.Position, lightPos_0);
97 | GL.Enable(EnableCap.Light0);
98 | /* light 1 */
99 | GL.Light(LightName.Light1, LightParameter.Ambient, light_1);
100 | GL.Light(LightName.Light1, LightParameter.Diffuse, light_2);
101 | GL.Light(LightName.Light1, LightParameter.Specular, specular_1);
102 | GL.Light(LightName.Light1, LightParameter.Position, lightPos_1);
103 | GL.Enable(EnableCap.Light1);
104 | /*material settings */
105 | GL.Enable(EnableCap.ColorMaterial);
106 | GL.ColorMaterial(MaterialFace.Front, ColorMaterialParameter.AmbientAndDiffuse);
107 | GL.Material(MaterialFace.Front, MaterialParameter.Specular, specref);
108 | GL.Material(MaterialFace.Front, MaterialParameter.Shininess, 10);
109 | GL.Enable(EnableCap.Normalize);
110 | }
111 |
112 | private void GL_Monitor_Paint(object sender, PaintEventArgs e)
113 | {
114 | if (!monitorLoaded)
115 | return;
116 |
117 | Batu_GL.Configure(GL_Monitor, Batu_GL.Ortho_Mode.CENTER);
118 | if (modelVAO != null) ConfigureBasicLighting(modelVAO.color);
119 | GL.Translate(orb.PanX, orb.PanY, 0);
120 | GL.Rotate(orb.orbitStr.angle, orb.orbitStr.ox, orb.orbitStr.oy, orb.orbitStr.oz);
121 | GL.Scale(orb.scaleVal * kScaleFactor, orb.scaleVal * kScaleFactor, orb.scaleVal * kScaleFactor); // small multiplication factor to scaling
122 | GL.Translate(-minPos.x, -minPos.y, -minPos.z);
123 | GL.Translate(-(maxPos.x - minPos.x) / 2.0f, -(maxPos.y - minPos.y) / 2.0f, -(maxPos.z - minPos.z) / 2.0f);
124 | if (modelVAO != null) modelVAO.Draw();
125 |
126 | GL_Monitor.SwapBuffers();
127 | }
128 |
129 | private void ReadSelectedFile(string fileName)
130 | {
131 | STLReader stlReader = new STLReader(fileName);
132 | TriangleMesh[] meshArray = stlReader.ReadFile();
133 | modelVAO = new Batu_GL.VAO_TRIANGLES();
134 | modelVAO.parameterArray = STLExport.Get_Mesh_Vertices(meshArray);
135 | modelVAO.normalArray = STLExport.Get_Mesh_Normals(meshArray);
136 | modelVAO.color = Color.Crimson;
137 | minPos = stlReader.GetMinMeshPosition(meshArray);
138 | maxPos = stlReader.GetMaxMeshPosition(meshArray);
139 | orb.Reset_Orientation();
140 | orb.Reset_Pan();
141 | orb.Reset_Scale();
142 | if (stlReader.Get_Process_Error())
143 | {
144 | modelVAO = null;
145 | /* if there is an error, deinitialize the gl monitor to clear the screen */
146 | Batu_GL.Configure(GL_Monitor, Batu_GL.Ortho_Mode.CENTER);
147 | GL_Monitor.SwapBuffers();
148 | }
149 | }
150 |
151 | private void FileMenuImportBt_Click(object sender, EventArgs e)
152 | {
153 | OpenFileDialog newFileDialog = new OpenFileDialog();
154 | newFileDialog.Filter = "STL Files|*.stl;*.txt;";
155 |
156 | if (newFileDialog.ShowDialog() == DialogResult.OK)
157 | {
158 | ReadSelectedFile(newFileDialog.FileName);
159 | }
160 | }
161 |
162 | private void FileMenuExitBt_Click(object sender, EventArgs e)
163 | {
164 | Application.Exit();
165 | }
166 |
167 | private void CloseBt_Click(object sender, EventArgs e)
168 | {
169 | Application.Exit();
170 | }
171 |
172 | private void MinimizeBt_Click(object sender, EventArgs e)
173 | {
174 | this.WindowState = FormWindowState.Minimized;
175 | }
176 |
177 | private void AppToolBarMStp_MouseDown(object sender, MouseEventArgs e)
178 | {
179 | moveForm = true;
180 | moveOffsetX = MousePosition.X - this.Location.X;
181 | moveOffsetY = MousePosition.Y - this.Location.Y;
182 | }
183 |
184 | private void AppToolBarMStp_MouseUp(object sender, MouseEventArgs e)
185 | {
186 | moveForm = false;
187 | moveOffsetX = 0;
188 | moveOffsetY = 0;
189 | }
190 |
191 | private void AppToolBarMStp_MouseDoubleClick(object sender, MouseEventArgs e)
192 | {
193 | if (this.WindowState == FormWindowState.Maximized) this.WindowState = FormWindowState.Normal;
194 | else this.WindowState = FormWindowState.Maximized;
195 | }
196 |
197 | private void AppTitleLb_MouseDown(object sender, MouseEventArgs e)
198 | {
199 | moveForm = true;
200 | moveOffsetX = MousePosition.X - this.Location.X;
201 | moveOffsetY = MousePosition.Y - this.Location.Y;
202 | }
203 |
204 | private void AppTitleLb_MouseUp(object sender, MouseEventArgs e)
205 | {
206 | moveForm = false;
207 | moveOffsetX = 0;
208 | moveOffsetY = 0;
209 | }
210 |
211 | private void AppTitleLb_MouseDoubleClick(object sender, MouseEventArgs e)
212 | {
213 | if (this.WindowState == FormWindowState.Maximized) this.WindowState = FormWindowState.Normal;
214 | else this.WindowState = FormWindowState.Maximized;
215 | }
216 |
217 | private void MaximizeBt_Click(object sender, EventArgs e)
218 | {
219 | if (this.WindowState == FormWindowState.Maximized) this.WindowState = FormWindowState.Normal;
220 | else this.WindowState = FormWindowState.Maximized;
221 | }
222 |
223 | private void GL_Monitor_DragDrop(object sender, DragEventArgs e)
224 | {
225 | var data = e.Data.GetData(DataFormats.FileDrop);
226 | if (data != null)
227 | {
228 | string[] fileNames = data as string[];
229 | string ext = System.IO.Path.GetExtension(fileNames[0]);
230 | if (fileNames.Length > 0 && (ext == ".stl" || ext == ".STL" || ext == ".txt" || ext == ".TXT"))
231 | {
232 | ReadSelectedFile(fileNames[0]);
233 | }
234 | }
235 | }
236 |
237 | private void GL_Monitor_DragEnter(object sender, DragEventArgs e)
238 | {
239 | // if the extension is not *.txt or *.stl change drag drop effect symbol
240 | var data = e.Data.GetData(DataFormats.FileDrop);
241 | if (data != null)
242 | {
243 | string[] fileNames = data as string[];
244 | string ext = System.IO.Path.GetExtension(fileNames[0]);
245 | if (ext == ".stl" || ext == ".STL" || ext == ".txt" || ext == ".TXT")
246 | {
247 | e.Effect = DragDropEffects.Copy;
248 | }
249 | else
250 | {
251 | e.Effect = DragDropEffects.None;
252 | }
253 | }
254 | }
255 |
256 | private void HelpMenuHowToUseBt_Click(object sender, EventArgs e)
257 | {
258 | AppHowToUseForm newHowToUseForm = new AppHowToUseForm();
259 | newHowToUseForm.ShowDialog();
260 | }
261 |
262 | private void HelpMenuAboutBt_Click(object sender, EventArgs e)
263 | {
264 | AppAboutForm aboutForm = new AppAboutForm();
265 | aboutForm.ShowDialog();
266 | }
267 | }
268 | }
--------------------------------------------------------------------------------
/STL-Viewer/BatuGL.cs:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file BatuGL.cs
4 | * @author Ali Batuhan KINDAN
5 | * @date 01.02.2020
6 | * @brief This file contains the methods for opengl graphics features
7 | ******************************************************************************
8 | */
9 | using System.Drawing;
10 | using OpenTK.Graphics.OpenGL;
11 |
12 | namespace BatuGL
13 | {
14 | public static class Batu_GL
15 | {
16 | public enum Ortho_Mode { CENTER, BLEFT };
17 |
18 | public static void Configure(OpenTK.GLControl refGLControl, Ortho_Mode ortho)
19 | {
20 | GL.ClearColor(Color.Black);
21 | refGLControl.VSync = false;
22 | GL.Clear(ClearBufferMask.ColorBufferBit);
23 | GL.Enable(EnableCap.Blend);
24 | GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
25 |
26 | GL.ClearColor(Color.Black);
27 | GL.MatrixMode(MatrixMode.Modelview);
28 | GL.LoadIdentity();
29 | GL.Viewport(refGLControl.Size);
30 | if(ortho == Ortho_Mode.CENTER)
31 | {
32 | GL.Ortho(-refGLControl.Width / 2, refGLControl.Width / 2, -refGLControl.Height / 2, refGLControl.Height / 2, -20000, +20000);
33 | }
34 | else
35 | {
36 | GL.Ortho(0, refGLControl.Width, 0, refGLControl.Height, -20000, +20000);
37 | }
38 | GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
39 | GL.ClearDepth(1.0f);
40 | GL.Enable(EnableCap.DepthTest);
41 | GL.DepthFunc(DepthFunction.Lequal);
42 |
43 | GL.Hint(HintTarget.PerspectiveCorrectionHint, HintMode.Nicest);
44 | GL.Enable(EnableCap.LineSmooth);
45 | GL.Hint(HintTarget.LineSmoothHint, HintMode.Nicest);
46 | /* Somehow had a bad effect on model rendering just comment out */
47 | //GL.Enable(EnableCap.PolygonSmooth);
48 | //GL.Hint(HintTarget.PolygonSmoothHint, HintMode.Nicest);
49 | }
50 |
51 | public static void Draw_WCS(float size = 1000.0f)
52 | {
53 | /* WCS for Debug X+ = Red, Y+ = Green, Z+ = Blue */
54 | float wcsSize = 1000.0f;
55 | GL.LineWidth(5.0f);
56 | GL.Begin(PrimitiveType.Lines);
57 | GL.Color3(1.0f, 0.0f, 0.0f);
58 | GL.Vertex3(0.0f, 0.0f, 0.0f);
59 | GL.Vertex3(wcsSize, 0.0f, 0.0f);
60 | GL.Color3(0.0f, 1.0f, 0.0f);
61 | GL.Vertex3(0.0f, 0.0f, 0.0f);
62 | GL.Vertex3(0.0f, wcsSize, 0.0f);
63 | GL.Color3(0.0f, 0.0f, 1.0f);
64 | GL.Vertex3(0.0f, 0.0f, 0.0f);
65 | GL.Vertex3(0.0f, 0.0f, wcsSize);
66 | GL.End();
67 | }
68 |
69 | public class VAO_TRIANGLES
70 | {
71 | public Color color { get; set; }
72 | public float[] scale { get; set; }
73 | public float[] parameterArray { get; set; }
74 | public float[] normalArray { get; set; }
75 |
76 | public VAO_TRIANGLES()
77 | {
78 | color = Color.Red;
79 | scale = new float[3] { 1.0f, 1.0f, 1.0f };
80 | }
81 |
82 | public void Draw()
83 | {
84 | GL.PushMatrix();
85 | GL.Scale(scale[0], scale[1], scale[2]);
86 | GL.EnableClientState(ArrayCap.VertexArray);
87 | GL.EnableClientState(ArrayCap.NormalArray);
88 | GL.VertexPointer(3, VertexPointerType.Float, 0, parameterArray);
89 | GL.Color3(color.R / 255.0, color.G / 255.0, color.B / 255.0);
90 | GL.NormalPointer(NormalPointerType.Float, 0, normalArray);
91 | GL.DrawArrays(PrimitiveType.Triangles, 0, parameterArray.Length / 3); // Okunan dosyadaki her 3 nokta 1 vertex oluşturduğundan toplam nokta sayısı 3'e bölünür
92 | GL.DisableClientState(ArrayCap.NormalArray);
93 | GL.DisableClientState(ArrayCap.VertexArray);
94 | GL.PopMatrix();
95 | }
96 | }
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/STL-Viewer/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using System.Windows.Forms;
6 |
7 | namespace STLViewer
8 | {
9 | static class Program
10 | {
11 | ///
12 | /// The main entry point for the application.
13 | ///
14 | [STAThread]
15 | static void Main()
16 | {
17 | Application.EnableVisualStyles();
18 | Application.SetCompatibleTextRenderingDefault(false);
19 | Application.Run(new AppMainForm());
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/STL-Viewer/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("STL-Viewer")]
9 | [assembly: AssemblyDescription("Viewer Tool for ASCII and Binary Formatted STL Files")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("batu92k")]
12 | [assembly: AssemblyProduct("STL-Viewer")]
13 | [assembly: AssemblyCopyright("Copyright © 2016")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("0e9e1848-17d8-486f-a474-51eaddb9c712")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/STL-Viewer/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace STLViewer.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// Returns the cached ResourceManager instance used by this class.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("STLViewer.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 |
63 | ///
64 | /// Looks up a localized resource of type System.Drawing.Bitmap.
65 | ///
66 | internal static System.Drawing.Bitmap stl_viewer_iconpng {
67 | get {
68 | object obj = ResourceManager.GetObject("stl_viewer_iconpng", resourceCulture);
69 | return ((System.Drawing.Bitmap)(obj));
70 | }
71 | }
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/STL-Viewer/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 |
122 | ..\Resources\stl_viewer_iconpng.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
123 |
124 |
--------------------------------------------------------------------------------
/STL-Viewer/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace STLViewer.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.0.3.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/STL-Viewer/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/STL-Viewer/Resources/stl_viewer_iconpng.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batu92k/STL-Viewer/a4900620efb27bf1867ad2b8b3affd95618898d2/STL-Viewer/Resources/stl_viewer_iconpng.png
--------------------------------------------------------------------------------
/STL-Viewer/STL-Viewer.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {50493E1F-6012-49DC-ABA7-0DF6F019E79F}
8 | WinExe
9 | Properties
10 | STLViewer
11 | STL Viewer
12 | v4.8
13 | 512
14 |
15 |
16 |
17 | AnyCPU
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | AnyCPU
28 | pdbonly
29 | true
30 | bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 |
35 |
36 | stl_viewer_icon.ico
37 |
38 |
39 |
40 | False
41 | bin\Debug\OpenTK.dll
42 |
43 |
44 | False
45 | bin\Debug\OpenTK.Compatibility.dll
46 |
47 |
48 | False
49 | bin\Debug\OpenTK.GLControl.dll
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 | Orbiter.cs
65 |
66 |
67 | Form
68 |
69 |
70 | AppAboutForm.cs
71 |
72 |
73 | Form
74 |
75 |
76 | AppHowToUseForm.cs
77 |
78 |
79 |
80 | Form
81 |
82 |
83 | AppMainForm.cs
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 | AppAboutForm.cs
93 |
94 |
95 | AppHowToUseForm.cs
96 |
97 |
98 | AppMainForm.cs
99 |
100 |
101 | ResXFileCodeGenerator
102 | Resources.Designer.cs
103 | Designer
104 |
105 |
106 | True
107 | Resources.resx
108 | True
109 |
110 |
111 | SettingsSingleFileGenerator
112 | Settings.Designer.cs
113 |
114 |
115 | True
116 | Settings.settings
117 | True
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
135 |
--------------------------------------------------------------------------------
/STL-Viewer/STL_Tools/STLExport.cs:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file STLExport.cs
4 | * @author Ali Batuhan KINDAN
5 | * @version V1.0.0
6 | * @date 03.07.2018
7 | * @brief
8 | ******************************************************************************
9 | */
10 | using System.Collections.Generic;
11 |
12 |
13 | namespace STL_Tools
14 | {
15 |
16 | public static class STLExport
17 | {
18 |
19 | /**
20 | * @brief This function creates a vertice array for OpenGL vertex array object from gşven triangular mesh array
21 | * @param meshArray
22 | * @retval vertices
23 | */
24 | public static float[] Get_Mesh_Vertices(TriangleMesh[] meshArray)
25 | {
26 | List vertices = new List();
27 |
28 | for (int i = 0; i < meshArray.Length; i++)
29 | {
30 | /* vertex 1 */
31 | vertices.Add(meshArray[i].vert1.x);
32 | vertices.Add(meshArray[i].vert1.y);
33 | vertices.Add(meshArray[i].vert1.z);
34 | /* vertex 2 */
35 | vertices.Add(meshArray[i].vert2.x);
36 | vertices.Add(meshArray[i].vert2.y);
37 | vertices.Add(meshArray[i].vert2.z);
38 | /* vertex 3 */
39 | vertices.Add(meshArray[i].vert3.x);
40 | vertices.Add(meshArray[i].vert3.y);
41 | vertices.Add(meshArray[i].vert3.z);
42 | }
43 |
44 | return vertices.ToArray();
45 | }
46 |
47 |
48 | /**
49 | * @brief This function creates a normal array for OpenGL vertex array object from given triangular mesh array
50 | * @param meshArray
51 | * @retval normals
52 | */
53 | public static float[] Get_Mesh_Normals(TriangleMesh[] meshArray)
54 | {
55 | List normals = new List();
56 |
57 | for (int i = 0; i < meshArray.Length; i++)
58 | {
59 | /* normal 1 */
60 | normals.Add(meshArray[i].normal1.x);
61 | normals.Add(meshArray[i].normal1.y);
62 | normals.Add(meshArray[i].normal1.z);
63 | /* normal 2 */
64 | normals.Add(meshArray[i].normal2.x);
65 | normals.Add(meshArray[i].normal2.y);
66 | normals.Add(meshArray[i].normal2.z);
67 | /* normal 3 */
68 | normals.Add(meshArray[i].normal3.x);
69 | normals.Add(meshArray[i].normal3.y);
70 | normals.Add(meshArray[i].normal3.z);
71 | }
72 |
73 | return normals.ToArray();
74 | }
75 |
76 |
77 | }
78 |
79 | }
80 |
--------------------------------------------------------------------------------
/STL-Viewer/STL_Tools/STLReader.cs:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file STLReader.cs
4 | * @author Ali Batuhan KINDAN
5 | * @version V1.0.0
6 | * @date 03.07.2018
7 | * @brief
8 | ******************************************************************************
9 | */
10 | using System.Collections.Generic;
11 | using System.Linq;
12 | using System.IO;
13 | using System.Globalization;
14 | using System.Threading;
15 |
16 | namespace STL_Tools
17 | {
18 |
19 | public class STLReader
20 | {
21 |
22 | public string path; // file path
23 | private enum FileType { NONE, BINARY, ASCII }; // stl file type enumeration
24 | private bool processError;
25 |
26 | /**
27 | * @brief Class instance constructor
28 | * @param none
29 | * @retval none
30 | */
31 | public STLReader(string filePath = "")
32 | {
33 | Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
34 | Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");
35 | path = filePath;
36 | processError = false;
37 | }
38 |
39 |
40 | /**
41 | * @brief This function returns the process error value if its true there is an error on process
42 | * @param none
43 | * @retval none
44 | */
45 | public bool Get_Process_Error()
46 | {
47 | return processError;
48 | }
49 |
50 |
51 | /**
52 | * @brief *.stl file main read function
53 | * @param none
54 | * @retval meshList
55 | */
56 | public TriangleMesh[] ReadFile()
57 | {
58 | TriangleMesh[] meshList;
59 |
60 | FileType stlFileType = GetFileType(path);
61 |
62 | if(stlFileType == FileType.ASCII)
63 | {
64 | meshList = ReadASCIIFile(path);
65 | }
66 | else if(stlFileType == FileType.BINARY)
67 | {
68 | meshList = ReadBinaryFile(path);
69 | }
70 | else
71 | {
72 | meshList = null;
73 | }
74 |
75 | return meshList;
76 | }
77 |
78 | /**
79 | * @brief This function returns the min position of objects bounding box by checking
80 | * all triangle meshes
81 | * @param meshArray
82 | * @retval Vector3
83 | */
84 | public Vector3 GetMinMeshPosition(TriangleMesh[] meshArray)
85 | {
86 | Vector3 minVec = new Vector3();
87 | float[] minRefArray = new float[3];
88 | minRefArray[0] = meshArray.Min(j => j.vert1.x);
89 | minRefArray[1] = meshArray.Min(j => j.vert2.x);
90 | minRefArray[2] = meshArray.Min(j => j.vert3.x);
91 | minVec.x = minRefArray.Min();
92 | minRefArray[0] = meshArray.Min(j => j.vert1.y);
93 | minRefArray[1] = meshArray.Min(j => j.vert2.y);
94 | minRefArray[2] = meshArray.Min(j => j.vert3.y);
95 | minVec.y = minRefArray.Min();
96 | minRefArray[0] = meshArray.Min(j => j.vert1.z);
97 | minRefArray[1] = meshArray.Min(j => j.vert2.z);
98 | minRefArray[2] = meshArray.Min(j => j.vert3.z);
99 | minVec.z = minRefArray.Min();
100 | return minVec;
101 | }
102 |
103 | /**
104 | * @brief This function returns the max position of objects bounding box by checking
105 | * all triangle meshes
106 | * @param meshArray
107 | * @retval Vector3
108 | */
109 | public Vector3 GetMaxMeshPosition(TriangleMesh[] meshArray)
110 | {
111 | Vector3 maxVec = new Vector3();
112 | float[] maxRefArray = new float[3];
113 | maxRefArray[0] = meshArray.Max(j => j.vert1.x);
114 | maxRefArray[1] = meshArray.Max(j => j.vert2.x);
115 | maxRefArray[2] = meshArray.Max(j => j.vert3.x);
116 | maxVec.x = maxRefArray.Max();
117 | maxRefArray[0] = meshArray.Max(j => j.vert1.y);
118 | maxRefArray[1] = meshArray.Max(j => j.vert2.y);
119 | maxRefArray[2] = meshArray.Max(j => j.vert3.y);
120 | maxVec.y = maxRefArray.Max();
121 | maxRefArray[0] = meshArray.Max(j => j.vert1.z);
122 | maxRefArray[1] = meshArray.Max(j => j.vert2.z);
123 | maxRefArray[2] = meshArray.Max(j => j.vert3.z);
124 | maxVec.z = maxRefArray.Max();
125 | return maxVec;
126 | }
127 |
128 | /**
129 | * @brief This function checks the type of stl file binary or ascii, function is assuming
130 | * given file as proper *.stl file
131 | * @param none
132 | * @retval stlFileType
133 | */
134 | private FileType GetFileType(string filePath)
135 | {
136 | FileType stlFileType = FileType.NONE;
137 |
138 | /* check path is exist */
139 | if (File.Exists(filePath))
140 | {
141 | int lineCount = 0;
142 | lineCount = File.ReadLines(filePath).Count(); // number of lines in the file
143 |
144 | string firstLine = File.ReadLines(filePath).First();
145 |
146 | string endLines = File.ReadLines(filePath).Skip(lineCount - 1).Take(1).First() +
147 | File.ReadLines(filePath).Skip(lineCount - 2).Take(1).First();
148 |
149 | /* check the file is ascii or not */
150 | if((firstLine.IndexOf("solid") != -1) &
151 | (endLines.IndexOf("endsolid") != -1))
152 | {
153 | stlFileType = FileType.ASCII;
154 | }
155 | else
156 | {
157 | stlFileType = FileType.BINARY;
158 | }
159 |
160 | }
161 | else
162 | {
163 | stlFileType = FileType.NONE;
164 | }
165 |
166 |
167 | return stlFileType;
168 | }
169 |
170 |
171 | /**
172 | * @brief *.stl file binary read function
173 | * @param filePath
174 | * @retval meshList
175 | */
176 | private TriangleMesh[] ReadBinaryFile(string filePath)
177 | {
178 | List meshList = new List();
179 | int numOfMesh = 0;
180 | int i = 0;
181 | int byteIndex = 0;
182 | byte[] fileBytes = File.ReadAllBytes(filePath);
183 |
184 | byte[] temp = new byte[4];
185 |
186 | /* 80 bytes title + 4 byte num of triangles + 50 bytes (1 of triangular mesh) */
187 | if (fileBytes.Length > 120)
188 | {
189 |
190 | temp[0] = fileBytes[80];
191 | temp[1] = fileBytes[81];
192 | temp[2] = fileBytes[82];
193 | temp[3] = fileBytes[83];
194 |
195 | numOfMesh = System.BitConverter.ToInt32(temp, 0);
196 |
197 | byteIndex = 84;
198 |
199 | for(i = 0; i < numOfMesh; i++)
200 | {
201 | TriangleMesh newMesh = new TriangleMesh();
202 |
203 | /* this try-catch block will be reviewed */
204 | try
205 | {
206 | /* face normal */
207 | newMesh.normal1.x = System.BitConverter.ToSingle(new byte[] { fileBytes[byteIndex], fileBytes[byteIndex + 1], fileBytes[byteIndex + 2], fileBytes[byteIndex + 3] }, 0);
208 | byteIndex += 4;
209 | newMesh.normal1.y = System.BitConverter.ToSingle(new byte[] { fileBytes[byteIndex], fileBytes[byteIndex + 1], fileBytes[byteIndex + 2], fileBytes[byteIndex + 3] }, 0);
210 | byteIndex += 4;
211 | newMesh.normal1.z = System.BitConverter.ToSingle(new byte[] { fileBytes[byteIndex], fileBytes[byteIndex + 1], fileBytes[byteIndex + 2], fileBytes[byteIndex + 3] }, 0);
212 | byteIndex += 4;
213 |
214 | /* normals of vertex 2 and 3 equals to vertex 1's normals */
215 | newMesh.normal2 = newMesh.normal1;
216 | newMesh.normal3 = newMesh.normal1;
217 |
218 | /* vertex 1 */
219 | newMesh.vert1.x = System.BitConverter.ToSingle(new byte[] { fileBytes[byteIndex], fileBytes[byteIndex + 1], fileBytes[byteIndex + 2], fileBytes[byteIndex + 3] }, 0);
220 | byteIndex += 4;
221 | newMesh.vert1.y = System.BitConverter.ToSingle(new byte[] { fileBytes[byteIndex], fileBytes[byteIndex + 1], fileBytes[byteIndex + 2], fileBytes[byteIndex + 3] }, 0);
222 | byteIndex += 4;
223 | newMesh.vert1.z = System.BitConverter.ToSingle(new byte[] { fileBytes[byteIndex], fileBytes[byteIndex + 1], fileBytes[byteIndex + 2], fileBytes[byteIndex + 3] }, 0);
224 | byteIndex += 4;
225 |
226 | /* vertex 2 */
227 | newMesh.vert2.x = System.BitConverter.ToSingle(new byte[] { fileBytes[byteIndex], fileBytes[byteIndex + 1], fileBytes[byteIndex + 2], fileBytes[byteIndex + 3] }, 0);
228 | byteIndex += 4;
229 | newMesh.vert2.y = System.BitConverter.ToSingle(new byte[] { fileBytes[byteIndex], fileBytes[byteIndex + 1], fileBytes[byteIndex + 2], fileBytes[byteIndex + 3] }, 0);
230 | byteIndex += 4;
231 | newMesh.vert2.z = System.BitConverter.ToSingle(new byte[] { fileBytes[byteIndex], fileBytes[byteIndex + 1], fileBytes[byteIndex + 2], fileBytes[byteIndex + 3] }, 0);
232 | byteIndex += 4;
233 |
234 | /* vertex 3 */
235 | newMesh.vert3.x = System.BitConverter.ToSingle(new byte[] { fileBytes[byteIndex], fileBytes[byteIndex + 1], fileBytes[byteIndex + 2], fileBytes[byteIndex + 3] }, 0);
236 | byteIndex += 4;
237 | newMesh.vert3.y = System.BitConverter.ToSingle(new byte[] { fileBytes[byteIndex], fileBytes[byteIndex + 1], fileBytes[byteIndex + 2], fileBytes[byteIndex + 3] }, 0);
238 | byteIndex += 4;
239 | newMesh.vert3.z = System.BitConverter.ToSingle(new byte[] { fileBytes[byteIndex], fileBytes[byteIndex + 1], fileBytes[byteIndex + 2], fileBytes[byteIndex + 3] }, 0);
240 | byteIndex += 4;
241 |
242 | byteIndex += 2; // Attribute byte count
243 | }
244 | catch
245 | {
246 | processError = true;
247 | break;
248 | }
249 |
250 | meshList.Add(newMesh);
251 |
252 | }
253 |
254 | }
255 | else
256 | {
257 | // nitentionally left blank
258 | }
259 |
260 | return meshList.ToArray();
261 | }
262 |
263 |
264 | /**
265 | * @brief *.stl file ascii read function
266 | * @param filePath
267 | * @retval meshList
268 | */
269 | private TriangleMesh[] ReadASCIIFile(string filePath)
270 | {
271 | List meshList = new List();
272 |
273 | StreamReader txtReader = new StreamReader(filePath);
274 |
275 | string lineString;
276 |
277 | while (!txtReader.EndOfStream)
278 | {
279 | lineString = txtReader.ReadLine().Trim(); /* delete whitespace in front and tail of the string */
280 | string[] lineData = lineString.Split(' ');
281 |
282 | if (lineData[0] == "solid")
283 | {
284 | while (lineData[0] != "endsolid")
285 | {
286 | lineString = txtReader.ReadLine().Trim(); // facetnormal
287 | lineData = lineString.Split(' ');
288 |
289 | if (lineData[0] == "endsolid") // check if we reach at the end of file
290 | {
291 | break;
292 | }
293 |
294 | TriangleMesh newMesh = new TriangleMesh(); // define new mesh object
295 |
296 | /* this try-catch block will be reviewed */
297 | try
298 | {
299 | // FaceNormal
300 | newMesh.normal1.x = float.Parse(lineData[2]);
301 | newMesh.normal1.y = float.Parse(lineData[3]);
302 | newMesh.normal1.z = float.Parse(lineData[4]);
303 |
304 | /* normals of vertex 2 and 3 equals to vertex 1's normals */
305 | newMesh.normal2 = newMesh.normal1;
306 | newMesh.normal3 = newMesh.normal1;
307 |
308 | //----------------------------------------------------------------------
309 | lineString = txtReader.ReadLine(); // Just skip the OuterLoop line
310 | //----------------------------------------------------------------------
311 |
312 | // Vertex1
313 | lineString = txtReader.ReadLine().Trim();
314 | /* reduce spaces until string has proper format for split */
315 | while (lineString.IndexOf(" ") != -1) lineString = lineString.Replace(" ", " ");
316 | lineData = lineString.Split(' ');
317 |
318 | newMesh.vert1.x = float.Parse(lineData[1]); // x1
319 | newMesh.vert1.y = float.Parse(lineData[2]); // y1
320 | newMesh.vert1.z = float.Parse(lineData[3]); // z1
321 |
322 | // Vertex2
323 | lineString = txtReader.ReadLine().Trim();
324 | /* reduce spaces until string has proper format for split */
325 | while (lineString.IndexOf(" ") != -1) lineString = lineString.Replace(" ", " ");
326 | lineData = lineString.Split(' ');
327 |
328 | newMesh.vert2.x = float.Parse(lineData[1]); // x2
329 | newMesh.vert2.y = float.Parse(lineData[2]); // y2
330 | newMesh.vert2.z = float.Parse(lineData[3]); // z2
331 |
332 | // Vertex3
333 | lineString = txtReader.ReadLine().Trim();
334 | /* reduce spaces until string has proper format for split */
335 | while (lineString.IndexOf(" ") != -1) lineString = lineString.Replace(" ", " ");
336 | lineData = lineString.Split(' ');
337 |
338 | newMesh.vert3.x = float.Parse(lineData[1]); // x3
339 | newMesh.vert3.y = float.Parse(lineData[2]); // y3
340 | newMesh.vert3.z = float.Parse(lineData[3]); // z3
341 | }
342 | catch
343 | {
344 | processError = true;
345 | break;
346 | }
347 |
348 | //----------------------------------------------------------------------
349 | lineString = txtReader.ReadLine(); // Just skip the endloop
350 | //----------------------------------------------------------------------
351 | lineString = txtReader.ReadLine(); // Just skip the endfacet
352 |
353 | meshList.Add(newMesh); // add mesh to meshList
354 |
355 | } // while linedata[0]
356 | } // if solid
357 | } // while !endofstream
358 |
359 | return meshList.ToArray();
360 | }
361 |
362 | }
363 | }
364 |
--------------------------------------------------------------------------------
/STL-Viewer/STL_Tools/TriangleMesh.cs:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file TriangleMesh.cs
4 | * @author Ali Batuhan KINDAN
5 | * @version V1.0.0
6 | * @date 03.07.2018
7 | * @brief
8 | ******************************************************************************
9 | */
10 |
11 | namespace STL_Tools
12 | {
13 | public class TriangleMesh
14 | {
15 | public Vector3 normal1;
16 | public Vector3 normal2;
17 | public Vector3 normal3;
18 | public Vector3 vert1;
19 | public Vector3 vert2;
20 | public Vector3 vert3;
21 |
22 | /**
23 | * @brief Class instance constructor
24 | * @param none
25 | * @retval none
26 | */
27 | public TriangleMesh()
28 | {
29 | normal1 = new Vector3();
30 | normal2 = new Vector3();
31 | normal3 = new Vector3();
32 | vert1 = new Vector3();
33 | vert2 = new Vector3();
34 | vert3 = new Vector3();
35 | }
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/STL-Viewer/STL_Tools/Vector3.cs:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file Vector3.cs
4 | * @author Ali Batuhan KINDAN
5 | * @version V1.0.0
6 | * @date 03.07.2018
7 | * @brief
8 | ******************************************************************************
9 | */
10 |
11 | namespace STL_Tools
12 | {
13 | public class Vector3
14 | {
15 | public float x;
16 | public float y;
17 | public float z;
18 |
19 | /**
20 | * @brief Class instance constructor
21 | * @param none
22 | * @retval none
23 | */
24 | public Vector3(float xVal = 0, float yVal = 0, float zVal = 0)
25 | {
26 | x = xVal;
27 | y = yVal;
28 | z = zVal;
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/STL-Viewer/bin/Debug/OpenTK.Compatibility.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batu92k/STL-Viewer/a4900620efb27bf1867ad2b8b3affd95618898d2/STL-Viewer/bin/Debug/OpenTK.Compatibility.dll
--------------------------------------------------------------------------------
/STL-Viewer/bin/Debug/OpenTK.GLControl.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batu92k/STL-Viewer/a4900620efb27bf1867ad2b8b3affd95618898d2/STL-Viewer/bin/Debug/OpenTK.GLControl.dll
--------------------------------------------------------------------------------
/STL-Viewer/bin/Debug/OpenTK.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batu92k/STL-Viewer/a4900620efb27bf1867ad2b8b3affd95618898d2/STL-Viewer/bin/Debug/OpenTK.dll
--------------------------------------------------------------------------------
/STL-Viewer/bin/Debug/STL Viewer.exe.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/STL-Viewer/obj/Debug/STL-Viewer.csproj.CopyComplete:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batu92k/STL-Viewer/a4900620efb27bf1867ad2b8b3affd95618898d2/STL-Viewer/obj/Debug/STL-Viewer.csproj.CopyComplete
--------------------------------------------------------------------------------
/STL-Viewer/obj/Debug/STL-Viewer.csproj.FileListAbsolute.txt:
--------------------------------------------------------------------------------
1 | C:\Users\b92k\Documents\GitHub\STL-Viewer\triangle_mesh 1\bin\Debug\STL Viewer.exe.config
2 | C:\Users\b92k\Documents\GitHub\STL-Viewer\triangle_mesh 1\bin\Debug\STL Viewer.exe
3 | C:\Users\b92k\Documents\GitHub\STL-Viewer\triangle_mesh 1\bin\Debug\STL Viewer.pdb
4 | C:\Users\b92k\Documents\GitHub\STL-Viewer\triangle_mesh 1\obj\Debug\STL-Viewer.csprojAssemblyReference.cache
5 | C:\Users\b92k\Documents\GitHub\STL-Viewer\triangle_mesh 1\obj\Debug\triangle_mesh_1.Form1.resources
6 | C:\Users\b92k\Documents\GitHub\STL-Viewer\triangle_mesh 1\obj\Debug\triangle_mesh_1.Properties.Resources.resources
7 | C:\Users\b92k\Documents\GitHub\STL-Viewer\triangle_mesh 1\obj\Debug\STL-Viewer.csproj.GenerateResource.cache
8 | C:\Users\b92k\Documents\GitHub\STL-Viewer\triangle_mesh 1\obj\Debug\STL-Viewer.csproj.CopyComplete
9 | C:\Users\b92k\Documents\GitHub\STL-Viewer\triangle_mesh 1\obj\Debug\STL Viewer.exe
10 | C:\Users\b92k\Documents\GitHub\STL-Viewer\triangle_mesh 1\obj\Debug\STL Viewer.pdb
11 | C:\Users\b92k\Documents\GitHub\STL-Viewer\STL-Viewer\bin\Debug\STL Viewer.exe.config
12 | C:\Users\b92k\Documents\GitHub\STL-Viewer\STL-Viewer\bin\Debug\STL Viewer.exe
13 | C:\Users\b92k\Documents\GitHub\STL-Viewer\STL-Viewer\bin\Debug\STL Viewer.pdb
14 | C:\Users\b92k\Documents\GitHub\STL-Viewer\STL-Viewer\obj\Debug\STL-Viewer.csproj.GenerateResource.cache
15 | C:\Users\b92k\Documents\GitHub\STL-Viewer\STL-Viewer\obj\Debug\STL-Viewer.csproj.CopyComplete
16 | C:\Users\b92k\Documents\GitHub\STL-Viewer\STL-Viewer\obj\Debug\STL Viewer.exe
17 | C:\Users\b92k\Documents\GitHub\STL-Viewer\STL-Viewer\obj\Debug\STL Viewer.pdb
18 | C:\Users\b92k\Documents\GitHub\STL-Viewer\STL-Viewer\obj\Debug\STLViewer.Properties.Resources.resources
19 | C:\Users\b92k\Documents\GitHub\STL-Viewer\STL-Viewer\obj\Debug\STLViewer.AppMainForm.resources
20 | C:\Users\b92k\Documents\GitHub\STL-Viewer\STL-Viewer\obj\Debug\STLViewer.AppAboutForm.resources
21 | C:\Users\b92k\Documents\GitHub\STL-Viewer\STL-Viewer\obj\Debug\STLViewer.AppHowToUseForm.resources
22 | C:\Users\b92k\Documents\GitHub\STL-Viewer\STL-Viewer\obj\Debug\STL-Viewer.csprojAssemblyReference.cache
23 |
--------------------------------------------------------------------------------
/STL-Viewer/obj/Debug/STLViewer.AppAboutForm.resources:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batu92k/STL-Viewer/a4900620efb27bf1867ad2b8b3affd95618898d2/STL-Viewer/obj/Debug/STLViewer.AppAboutForm.resources
--------------------------------------------------------------------------------
/STL-Viewer/obj/Debug/STLViewer.AppHowToUseForm.resources:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batu92k/STL-Viewer/a4900620efb27bf1867ad2b8b3affd95618898d2/STL-Viewer/obj/Debug/STLViewer.AppHowToUseForm.resources
--------------------------------------------------------------------------------
/STL-Viewer/obj/Debug/STLViewer.AppMainForm.resources:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batu92k/STL-Viewer/a4900620efb27bf1867ad2b8b3affd95618898d2/STL-Viewer/obj/Debug/STLViewer.AppMainForm.resources
--------------------------------------------------------------------------------
/STL-Viewer/obj/Debug/STLViewer.Properties.Resources.resources:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batu92k/STL-Viewer/a4900620efb27bf1867ad2b8b3affd95618898d2/STL-Viewer/obj/Debug/STLViewer.Properties.Resources.resources
--------------------------------------------------------------------------------
/STL-Viewer/obj/Debug/TempPE/Properties.Resources.Designer.cs.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batu92k/STL-Viewer/a4900620efb27bf1867ad2b8b3affd95618898d2/STL-Viewer/obj/Debug/TempPE/Properties.Resources.Designer.cs.dll
--------------------------------------------------------------------------------
/STL-Viewer/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batu92k/STL-Viewer/a4900620efb27bf1867ad2b8b3affd95618898d2/STL-Viewer/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
--------------------------------------------------------------------------------
/STL-Viewer/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batu92k/STL-Viewer/a4900620efb27bf1867ad2b8b3affd95618898d2/STL-Viewer/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
--------------------------------------------------------------------------------
/STL-Viewer/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batu92k/STL-Viewer/a4900620efb27bf1867ad2b8b3affd95618898d2/STL-Viewer/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
--------------------------------------------------------------------------------
/STL-Viewer/stl_viewer_icon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batu92k/STL-Viewer/a4900620efb27bf1867ad2b8b3affd95618898d2/STL-Viewer/stl_viewer_icon.ico
--------------------------------------------------------------------------------
/sample_stl/Planetary_Toy_D80.stl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batu92k/STL-Viewer/a4900620efb27bf1867ad2b8b3affd95618898d2/sample_stl/Planetary_Toy_D80.stl
--------------------------------------------------------------------------------
/sample_stl/Star_Destroyer_Fixed.stl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batu92k/STL-Viewer/a4900620efb27bf1867ad2b8b3affd95618898d2/sample_stl/Star_Destroyer_Fixed.stl
--------------------------------------------------------------------------------
/visuals/STL_Viewer_Demo.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batu92k/STL-Viewer/a4900620efb27bf1867ad2b8b3affd95618898d2/visuals/STL_Viewer_Demo.gif
--------------------------------------------------------------------------------