From de017713c36ed8ff3e32cadf6ae07cc96090b78a Mon Sep 17 00:00:00 2001 From: Yaroslav Shirokov Date: Thu, 25 Aug 2016 23:15:52 -0700 Subject: [PATCH 01/14] Ignore common VS trash --- .gitignore | 264 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 264 insertions(+) diff --git a/.gitignore b/.gitignore index 0a61ee3..782edb0 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,267 @@ csgtool.dbg *.exe *.out *.app + +### Import of +### https://raw.githubusercontent.com/github/gitignore/master/VisualStudio.gitignore + +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# DNX +project.lock.json +project.fragment.lock.json +artifacts/ + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config +# NuGet v3's project.json files produces more ignoreable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.pfx +*.publishsettings +node_modules/ +orleans.codegen.cs + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc From 16ac813591521669a884adda0c6d689c1c1131de Mon Sep 17 00:00:00 2001 From: Yaroslav Shirokov Date: Thu, 25 Aug 2016 23:16:53 -0700 Subject: [PATCH 02/14] Conditional includes --- src/poly.h | 5 ++++- src/stl.c | 3 +++ src/stl.h | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/poly.h b/src/poly.h index 9524b77..603d1d7 100644 --- a/src/poly.h +++ b/src/poly.h @@ -1,5 +1,8 @@ -#include +#ifndef _WIN32 #include +#endif + +#include #include "dbg.h" #include "klist.h" #include "vector.h" diff --git a/src/stl.c b/src/stl.c index 9640122..d5cc704 100644 --- a/src/stl.c +++ b/src/stl.c @@ -6,7 +6,10 @@ #include #include #include + +#ifndef _WIN32 #include +#endif #include "dbg.h" diff --git a/src/stl.h b/src/stl.h index 0f12905..750b427 100644 --- a/src/stl.h +++ b/src/stl.h @@ -1,4 +1,7 @@ +#ifndef _WIN32 #include +#endif + #include #include From 70723b9206ef3a9f3bd72bf5ab1ac5442f547527 Mon Sep 17 00:00:00 2001 From: Yaroslav Shirokov Date: Thu, 25 Aug 2016 23:27:19 -0700 Subject: [PATCH 03/14] POSIX rename in windows --- src/stl.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/stl.c b/src/stl.c index d5cc704..244344d 100644 --- a/src/stl.c +++ b/src/stl.c @@ -16,6 +16,10 @@ #include "stl.h" #include "util.h" +#ifdef _WIN32 +#define fdopen _fdopen +#endif + void stl_free(stl_object *obj) { if(obj == NULL) return; if(obj->facets) free(obj->facets); From 7474543235c6da03229cc9f257a18ef02c738047 Mon Sep 17 00:00:00 2001 From: Yaroslav Shirokov Date: Thu, 25 Aug 2016 23:27:31 -0700 Subject: [PATCH 04/14] Whoops! --- src/stl.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/stl.c b/src/stl.c index 244344d..e6059b4 100644 --- a/src/stl.c +++ b/src/stl.c @@ -16,6 +16,7 @@ #include "stl.h" #include "util.h" +// Thanks, Windows/C++/World <3 #ifdef _WIN32 #define fdopen _fdopen #endif From f03bd75a3d4cf259b1746b23017d50efdb505036 Mon Sep 17 00:00:00 2001 From: Yaroslav Shirokov Date: Thu, 25 Aug 2016 23:28:00 -0700 Subject: [PATCH 05/14] Signed match --- src/stl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stl.c b/src/stl.c index e6059b4..aee8504 100644 --- a/src/stl.c +++ b/src/stl.c @@ -240,7 +240,7 @@ stl_object *stl_read_file(char *path, int recompute_normals) { close(fd); if(recompute_normals) { - for(int i = 0; i < obj->facet_count; i++) { + for(unsigned int i = 0; i < obj->facet_count; i++) { stl_facet_update_normal(&obj->facets[i]); } } From 6aae0eb83ccbd0ae8c119b583e0fb8df5a3ed235 Mon Sep 17 00:00:00 2001 From: Yaroslav Shirokov Date: Thu, 25 Aug 2016 23:40:49 -0700 Subject: [PATCH 06/14] More specific types --- src/export.c | 2 +- src/poly.c | 4 ++-- src/util.c | 2 +- src/vector.c | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/export.c b/src/export.c index f705153..cdde916 100644 --- a/src/export.c +++ b/src/export.c @@ -45,7 +45,7 @@ bsp_node_t *stl_to_bsp(stl_object *stl) { klist_t(poly) *polys = kl_init(poly); poly_t *poly = NULL; - for(int i = 0; i < stl->facet_count; i++) { + for(unsigned int i = 0; i < stl->facet_count; i++) { poly = poly_make_triangle(stl->facets[i].vertices[0], stl->facets[i].vertices[1], stl->facets[i].vertices[2]); diff --git a/src/poly.c b/src/poly.c index 1702a58..7ea483d 100644 --- a/src/poly.c +++ b/src/poly.c @@ -102,11 +102,11 @@ float poly_triangle_2area(poly_t *triangle) { // The actual area of a triangle `triangle` // Works through poly_triangle_2area float poly_triangle_area(poly_t *triangle) { - return 0.5 * poly_triangle_2area(triangle); + return 0.5f * poly_triangle_2area(triangle); } float poly_area(poly_t *poly) { - return poly_2area(poly) / 2.0; + return poly_2area(poly) / 2.0f; } float poly_2area(poly_t *poly) { diff --git a/src/util.c b/src/util.c index 26c06a0..8b03742 100644 --- a/src/util.c +++ b/src/util.c @@ -110,7 +110,7 @@ char *read_line(FILE *f, bool downcase, bool trim) { } if(downcase == true) { - for(int i = 0; i < strlen(line); i++) { + for(size_t i = 0; i < strlen(line); i++) { line[i] = tolower(line[i]); } } diff --git a/src/vector.c b/src/vector.c index 0a72d5d..e73ad64 100644 --- a/src/vector.c +++ b/src/vector.c @@ -11,7 +11,7 @@ float3 *clone_f3(float3 f) { } float f3_magnitude(float3 *v) { - return sqrt((*v)[0] * (*v)[0] + + return sqrtf((*v)[0] * (*v)[0] + (*v)[1] * (*v)[1] + (*v)[2] * (*v)[2]); } @@ -60,7 +60,7 @@ float3 *f3_interpolate(float3 *result, float3 start, float3 v, float alpha) { } float f3_distance(float3 a, float3 b) { - return sqrt(f3_distance2(a, b)); + return sqrtf(f3_distance2(a, b)); } float f3_distance2(float3 a, float3 b) { From ee6d4669193c3dc7fa359f308fc75cc00ca32104 Mon Sep 17 00:00:00 2001 From: Yaroslav Shirokov Date: Thu, 25 Aug 2016 23:41:00 -0700 Subject: [PATCH 07/14] Define the platform specific IO --- src/stl.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/stl.c b/src/stl.c index aee8504..92ac5e0 100644 --- a/src/stl.c +++ b/src/stl.c @@ -7,8 +7,20 @@ #include #include +// Platform specific IO #ifndef _WIN32 #include +#else +#include + +// And also rename the basics +#define read _read +#define write _write +#define open _open +#define close _close + +// Not technically part of `io.h` +#define fdopen _fdopen #endif #include "dbg.h" @@ -16,11 +28,6 @@ #include "stl.h" #include "util.h" -// Thanks, Windows/C++/World <3 -#ifdef _WIN32 -#define fdopen _fdopen -#endif - void stl_free(stl_object *obj) { if(obj == NULL) return; if(obj->facets) free(obj->facets); From e29b05e60c697a26ea88bdead8e1a4e68cf8e331 Mon Sep 17 00:00:00 2001 From: Yaroslav Shirokov Date: Thu, 25 Aug 2016 23:46:14 -0700 Subject: [PATCH 08/14] The start of a solution and a static lib project --- csgtool.sln | 28 +++++++++ csgtool.vcxproj | 133 ++++++++++++++++++++++++++++++++++++++++ csgtool.vcxproj.filters | 99 ++++++++++++++++++++++++++++++ 3 files changed, 260 insertions(+) create mode 100644 csgtool.sln create mode 100644 csgtool.vcxproj create mode 100644 csgtool.vcxproj.filters diff --git a/csgtool.sln b/csgtool.sln new file mode 100644 index 0000000..ea76cb0 --- /dev/null +++ b/csgtool.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25123.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "csgtool", "csgtool.vcxproj", "{9B4E69A7-C992-4566-9DCD-0DDA1356DF89}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9B4E69A7-C992-4566-9DCD-0DDA1356DF89}.Debug|x64.ActiveCfg = Debug|x64 + {9B4E69A7-C992-4566-9DCD-0DDA1356DF89}.Debug|x64.Build.0 = Debug|x64 + {9B4E69A7-C992-4566-9DCD-0DDA1356DF89}.Debug|x86.ActiveCfg = Debug|Win32 + {9B4E69A7-C992-4566-9DCD-0DDA1356DF89}.Debug|x86.Build.0 = Debug|Win32 + {9B4E69A7-C992-4566-9DCD-0DDA1356DF89}.Release|x64.ActiveCfg = Release|x64 + {9B4E69A7-C992-4566-9DCD-0DDA1356DF89}.Release|x64.Build.0 = Release|x64 + {9B4E69A7-C992-4566-9DCD-0DDA1356DF89}.Release|x86.ActiveCfg = Release|Win32 + {9B4E69A7-C992-4566-9DCD-0DDA1356DF89}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/csgtool.vcxproj b/csgtool.vcxproj new file mode 100644 index 0000000..1793ebd --- /dev/null +++ b/csgtool.vcxproj @@ -0,0 +1,133 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {9B4E69A7-C992-4566-9DCD-0DDA1356DF89} + Win32Proj + libcsg + + + + StaticLibrary + true + v140 + + + StaticLibrary + false + v140 + + + Application + true + v140 + + + Application + false + v140 + + + + + + + + + + + + + + + + + + + + + true + + + true + + + + WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + MultiThreadedDebugDLL + Level3 + ProgramDatabase + Disabled + + + MachineX86 + true + Windows + + + + + WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + MultiThreadedDLL + Level3 + ProgramDatabase + + + MachineX86 + true + Windows + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/csgtool.vcxproj.filters b/csgtool.vcxproj.filters new file mode 100644 index 0000000..22ac7b4 --- /dev/null +++ b/csgtool.vcxproj.filters @@ -0,0 +1,99 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + \ No newline at end of file From 93512a5951e236f2212b9b5738c75c3bb057e82a Mon Sep 17 00:00:00 2001 From: Yaroslav Shirokov Date: Thu, 25 Aug 2016 23:50:19 -0700 Subject: [PATCH 09/14] Include the src/*.[ch] as wildcards --- csgtool.vcxproj | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/csgtool.vcxproj b/csgtool.vcxproj index 1793ebd..028bca5 100644 --- a/csgtool.vcxproj +++ b/csgtool.vcxproj @@ -98,36 +98,12 @@ - - - - - - - - - - - - + - - - - - - - - - - - - - - + - \ No newline at end of file + From 8ab94ee74339db2bf8cb5c306784ab08056c7f73 Mon Sep 17 00:00:00 2001 From: Yaroslav Shirokov Date: Thu, 25 Aug 2016 23:55:27 -0700 Subject: [PATCH 10/14] Even More Wildcards --- csgtool.vcxproj.filters | 80 ++--------------------------------------- 1 file changed, 3 insertions(+), 77 deletions(-) diff --git a/csgtool.vcxproj.filters b/csgtool.vcxproj.filters index 22ac7b4..97d3f99 100644 --- a/csgtool.vcxproj.filters +++ b/csgtool.vcxproj.filters @@ -15,85 +15,11 @@ - + Source Files - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - + Header Files - \ No newline at end of file + From 8bc6b459d2ae1406a74021c5f1143a2cc86faaff Mon Sep 17 00:00:00 2001 From: Yaroslav Shirokov Date: Fri, 26 Aug 2016 00:12:40 -0700 Subject: [PATCH 11/14] A second project for the exe Also, a rename of the `csgtool` project to `libcsg` and `csgtool` becoming the binary project --- csgtool.sln | 12 ++++- csgtool.vcxproj | 87 ++++++++++++++++++++++++-------- csgtool.vcxproj.filters | 9 ++-- libcsg.vcxproj | 109 ++++++++++++++++++++++++++++++++++++++++ libcsg.vcxproj.filters | 25 +++++++++ 5 files changed, 215 insertions(+), 27 deletions(-) create mode 100644 libcsg.vcxproj create mode 100644 libcsg.vcxproj.filters diff --git a/csgtool.sln b/csgtool.sln index ea76cb0..70f016b 100644 --- a/csgtool.sln +++ b/csgtool.sln @@ -3,7 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 VisualStudioVersion = 14.0.25123.0 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "csgtool", "csgtool.vcxproj", "{9B4E69A7-C992-4566-9DCD-0DDA1356DF89}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcsg", "libcsg.vcxproj", "{9B4E69A7-C992-4566-9DCD-0DDA1356DF89}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "csgtool", "csgtool.vcxproj", "{38CD99E1-3B79-4DC3-B9BB-8A30D5E68B9F}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -21,6 +23,14 @@ Global {9B4E69A7-C992-4566-9DCD-0DDA1356DF89}.Release|x64.Build.0 = Release|x64 {9B4E69A7-C992-4566-9DCD-0DDA1356DF89}.Release|x86.ActiveCfg = Release|Win32 {9B4E69A7-C992-4566-9DCD-0DDA1356DF89}.Release|x86.Build.0 = Release|Win32 + {38CD99E1-3B79-4DC3-B9BB-8A30D5E68B9F}.Debug|x64.ActiveCfg = Debug|x64 + {38CD99E1-3B79-4DC3-B9BB-8A30D5E68B9F}.Debug|x64.Build.0 = Debug|x64 + {38CD99E1-3B79-4DC3-B9BB-8A30D5E68B9F}.Debug|x86.ActiveCfg = Debug|Win32 + {38CD99E1-3B79-4DC3-B9BB-8A30D5E68B9F}.Debug|x86.Build.0 = Debug|Win32 + {38CD99E1-3B79-4DC3-B9BB-8A30D5E68B9F}.Release|x64.ActiveCfg = Release|x64 + {38CD99E1-3B79-4DC3-B9BB-8A30D5E68B9F}.Release|x64.Build.0 = Release|x64 + {38CD99E1-3B79-4DC3-B9BB-8A30D5E68B9F}.Release|x86.ActiveCfg = Release|Win32 + {38CD99E1-3B79-4DC3-B9BB-8A30D5E68B9F}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/csgtool.vcxproj b/csgtool.vcxproj index 028bca5..ba18261 100644 --- a/csgtool.vcxproj +++ b/csgtool.vcxproj @@ -19,30 +19,37 @@ - {9B4E69A7-C992-4566-9DCD-0DDA1356DF89} + {38CD99E1-3B79-4DC3-B9BB-8A30D5E68B9F} Win32Proj - libcsg + exe + 8.1 - StaticLibrary + Application true v140 + Unicode - StaticLibrary + Application false v140 + true + Unicode Application true v140 + Unicode Application false v140 + true + Unicode @@ -64,46 +71,86 @@ true + $(Configuration)\$(ProjectName)\ - + true + + false + $(Configuration)\$(ProjectName)\ + + + false + - WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - MultiThreadedDebugDLL + + Level3 - ProgramDatabase Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true - MachineX86 + Console + true + + + + + + + Level3 + Disabled + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console true - Windows - WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - MultiThreadedDLL Level3 - ProgramDatabase + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true - MachineX86 + Console + true + true true - Windows + + + + + Level3 + + + MaxSpeed + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console true true + true - - - - + - + \ No newline at end of file diff --git a/csgtool.vcxproj.filters b/csgtool.vcxproj.filters index 97d3f99..896a9db 100644 --- a/csgtool.vcxproj.filters +++ b/csgtool.vcxproj.filters @@ -11,15 +11,12 @@ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - + Source Files - - Header Files - - + \ No newline at end of file diff --git a/libcsg.vcxproj b/libcsg.vcxproj new file mode 100644 index 0000000..028bca5 --- /dev/null +++ b/libcsg.vcxproj @@ -0,0 +1,109 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {9B4E69A7-C992-4566-9DCD-0DDA1356DF89} + Win32Proj + libcsg + + + + StaticLibrary + true + v140 + + + StaticLibrary + false + v140 + + + Application + true + v140 + + + Application + false + v140 + + + + + + + + + + + + + + + + + + + + + true + + + true + + + + WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + MultiThreadedDebugDLL + Level3 + ProgramDatabase + Disabled + + + MachineX86 + true + Windows + + + + + WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + MultiThreadedDLL + Level3 + ProgramDatabase + + + MachineX86 + true + Windows + true + true + + + + + + + + + + + + diff --git a/libcsg.vcxproj.filters b/libcsg.vcxproj.filters new file mode 100644 index 0000000..97d3f99 --- /dev/null +++ b/libcsg.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav + + + + + Source Files + + + Header Files + + + From 23904fcaf24252c588d555e8f622d06f169bd988 Mon Sep 17 00:00:00 2001 From: Yaroslav Shirokov Date: Fri, 26 Aug 2016 00:26:13 -0700 Subject: [PATCH 12/14] Depend and compile --- csgtool.vcxproj | 11 +++++++++-- libcsg.vcxproj | 7 +++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/csgtool.vcxproj b/csgtool.vcxproj index ba18261..f974d93 100644 --- a/csgtool.vcxproj +++ b/csgtool.vcxproj @@ -89,8 +89,9 @@ Level3 Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) true + $(ProjectDir)src Console @@ -119,8 +120,9 @@ MaxSpeed true true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true + $(ProjectDir)src Console @@ -150,6 +152,11 @@ + + + {9b4e69a7-c992-4566-9dcd-0dda1356df89} + + diff --git a/libcsg.vcxproj b/libcsg.vcxproj index 028bca5..9b85751 100644 --- a/libcsg.vcxproj +++ b/libcsg.vcxproj @@ -22,6 +22,7 @@ {9B4E69A7-C992-4566-9DCD-0DDA1356DF89} Win32Proj libcsg + 8.1 @@ -64,9 +65,11 @@ true + $(Configuration)\$(ProjectName)\ true + $(Configuration)\$(ProjectName)\ @@ -84,7 +87,7 @@ - WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;NDEBUG;%(PreprocessorDefinitions) MultiThreadedDLL Level3 ProgramDatabase @@ -106,4 +109,4 @@ - + \ No newline at end of file From 2057361e52ef19c6974801bfdb29812aacd9ad69 Mon Sep 17 00:00:00 2001 From: Yaroslav Shirokov Date: Fri, 26 Aug 2016 00:43:02 -0700 Subject: [PATCH 13/14] O_BINARY on all `open()` Because windows has a destinction, and binary files can sometimes read wrong because of it. REMEMBER THE PAST? IT LIVES FOREVER WITH US NOW! --- src/stl.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/stl.c b/src/stl.c index 92ac5e0..845f4d0 100644 --- a/src/stl.c +++ b/src/stl.c @@ -10,6 +10,9 @@ // Platform specific IO #ifndef _WIN32 #include + +// Thanks, windows. Love this. +#define O_BINARY 0 #else #include @@ -236,7 +239,7 @@ stl_object *stl_read_file(char *path, int recompute_normals) { int fd = -1; check((reader = stl_detect_reader(path)), "Unable to find reader for format of %s", path); - check((fd = open(path, O_RDONLY)) != -1, "Unable to open '%s'", path); + check((fd = open(path, O_RDONLY | O_BINARY)) != -1, "Unable to open '%s'", path); obj = reader(fd); check(obj != NULL, "Failed to read STL from %s", path); @@ -261,7 +264,7 @@ stl_object *stl_read_file(char *path, int recompute_normals) { int stl_write_file(stl_object *obj, char *path) { int rc = -1; - int fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0755); + int fd = open(path, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0755); check(fd != -1, "Failed to open '%s' for write", path); rc = stl_write_object(obj, fd); @@ -315,6 +318,7 @@ stl_reader* stl_detect_reader(char *path) { for(int i = 0; i < upto; i++) { check((rc = read(fd, &c, 1)) == 1, "Failed to read byte %d for reader detection of %s", i, path); if(!isprint(c) && !isspace(c)) { + log_info("Using binary reader for %s", path); reader = stl_read_object; break; } From eeaf7a8c9192d27d07f79c2b4a309b22b03b7c7b Mon Sep 17 00:00:00 2001 From: Yaroslav Shirokov Date: Fri, 26 Aug 2016 00:47:56 -0700 Subject: [PATCH 14/14] Debug noise --- src/stl.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/stl.c b/src/stl.c index 845f4d0..480df22 100644 --- a/src/stl.c +++ b/src/stl.c @@ -318,7 +318,6 @@ stl_reader* stl_detect_reader(char *path) { for(int i = 0; i < upto; i++) { check((rc = read(fd, &c, 1)) == 1, "Failed to read byte %d for reader detection of %s", i, path); if(!isprint(c) && !isspace(c)) { - log_info("Using binary reader for %s", path); reader = stl_read_object; break; }