diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 66d4716..a29907b 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -5,7 +5,8 @@ name: CI
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
- branches: [ master ]
+ branches:
+ - master
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
diff --git a/App.config b/App.config
index 51e82ea..f41c146 100644
--- a/App.config
+++ b/App.config
@@ -148,6 +148,27 @@
True
+
+
+
+
+ min
+
+
+ False
+
+
+ False
+
+
+ 0.5
+
+
+ False
+
+
+ False
+
diff --git a/Build.cmd b/Build.cmd
index 88aae09..eb971f9 100644
--- a/Build.cmd
+++ b/Build.cmd
@@ -4,7 +4,8 @@ if exist Debug rd /s /q Debug
if exist Release rd /s /q Release
if exist x64 rd /s /q x64
-"%programfiles(x86)%\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\msbuild.exe" /p:Configuration=Release
+"%programfiles%\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\msbuild.exe" /p:Configuration=Release
+REM "%programfiles%\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\msbuild.exe" /p:Configuration=Release
:exit
popd
diff --git a/Icons/app.ico b/Icons/app.ico
index e7ead2e..23d50df 100644
Binary files a/Icons/app.ico and b/Icons/app.ico differ
diff --git a/Interfaces/ILogger.cs b/Interfaces/ILogger.cs
index 1f3659d..86ebaa0 100644
--- a/Interfaces/ILogger.cs
+++ b/Interfaces/ILogger.cs
@@ -61,7 +61,7 @@ public static class LoggerFactory
{
public static ILogger CreateLogger(bool isJSON)
{
- Trace.WriteLine($"Creating logger with JSON: {isJSON}");
+ //Trace.WriteLine($"Creating logger with JSON: {isJSON}");
if (isJSON)
{
return new LogJSON();
diff --git a/Interfaces/IWriter.cs b/Interfaces/IWriter.cs
index 6be0fcf..e975d24 100644
--- a/Interfaces/IWriter.cs
+++ b/Interfaces/IWriter.cs
@@ -6,7 +6,7 @@ public interface IWriter
{
// create output filestream, called before looping through points
//bool InitWriter(TSettings importSettings, int pointCount);
- bool InitWriter(dynamic importSettings, int pointCount, ILogger logger);
+ bool InitWriter(dynamic importSettings, long pointCount, ILogger logger);
// optional: if need to create special file header
void CreateHeader(int pointCount);
// output point X,Y,Z values to file
@@ -14,7 +14,7 @@ public interface IWriter
// output R,G,B values (float 0-1) to file
void WriteRGB(float r, float g, float b);
// optional: if you need to collect points for later processing
- void AddPoint(int index, float x, float y, float z, float r, float g, float b, bool hasIntensity, float i, bool hasTime, double time);
+ void AddPoint(int index, float x, float y, float z, float r, float g, float b, ushort intensity, double time, byte classification);
// optional: randomizes points (to use dynamic resolution/tile LOD in Unity)
void Randomize();
// called after all points have been looped through
@@ -24,6 +24,8 @@ public interface IWriter
// close filestream
void Close();
void Dispose();
+ // used for intensity detection
+ void SetIntensityRange(bool isCustomRange);
}
}
diff --git a/LICENSE b/LICENSE
index 8000a6f..24d19d6 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,3 +1,7 @@
+MULTIPLE LICENSES FOR LIBRARIES USED
+
+ ### shintadono/laszip.net
+
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
@@ -502,3 +506,1091 @@ necessary. Here is a sample; alter the names:
Ty Coon, President of Vice
That's all there is to it!
+
+
+### aardwark.base
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+### Aardvark.Data.E57
+
+ GNU AFFERO GENERAL PUBLIC LICENSE
+ Version 3, 19 November 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU Affero General Public License is a free, copyleft license for
+software and other kinds of works, specifically designed to ensure
+cooperation with the community in the case of network server software.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+our General Public Licenses are intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ Developers that use our General Public Licenses protect your rights
+with two steps: (1) assert copyright on the software, and (2) offer
+you this License which gives you legal permission to copy, distribute
+and/or modify the software.
+
+ A secondary benefit of defending all users' freedom is that
+improvements made in alternate versions of the program, if they
+receive widespread use, become available for other developers to
+incorporate. Many developers of free software are heartened and
+encouraged by the resulting cooperation. However, in the case of
+software used on network servers, this result may fail to come about.
+The GNU General Public License permits making a modified version and
+letting the public access it on a server without ever releasing its
+source code to the public.
+
+ The GNU Affero General Public License is designed specifically to
+ensure that, in such cases, the modified source code becomes available
+to the community. It requires the operator of a network server to
+provide the source code of the modified version running there to the
+users of that server. Therefore, public use of a modified version, on
+a publicly accessible server, gives the public access to the source
+code of the modified version.
+
+ An older license, called the Affero General Public License and
+published by Affero, was designed to accomplish similar goals. This is
+a different license, not a version of the Affero GPL, but Affero has
+released a new version of the Affero GPL which permits relicensing under
+this license.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU Affero General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Remote Network Interaction; Use with the GNU General Public License.
+
+ Notwithstanding any other provision of this License, if you modify the
+Program, your modified version must prominently offer all users
+interacting with it remotely through a computer network (if your version
+supports such interaction) an opportunity to receive the Corresponding
+Source of your version by providing access to the Corresponding Source
+from a network server at no charge, through some standard or customary
+means of facilitating copying of software. This Corresponding Source
+shall include the Corresponding Source for any work covered by version 3
+of the GNU General Public License that is incorporated pursuant to the
+following paragraph.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the work with which it is combined will remain governed by version
+3 of the GNU General Public License.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU Affero General Public License from time to time. Such new versions
+will be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU Affero General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU Affero General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU Affero General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+
+ Copyright (C)
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If your software can interact with users remotely through a computer
+network, you should also make sure that it provides a way for users to
+get its source. For example, if your program is a web application, its
+interface could display a "Source" link that leads users to an archive
+of the code. There are many ways you could offer source, and different
+solutions will be better for different programs; see section 13 for the
+specific requirements.
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU AGPL, see
+.
+
+
+### Newtonsoft.Json
+
+The MIT License (MIT)
+
+Copyright (c) 2007 James Newton-King
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+### ply.net
+
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright 2018-2023 Stefan Maierhofer
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
diff --git a/MainWindow.xaml b/MainWindow.xaml
index f982f02..a0a3c86 100644
--- a/MainWindow.xaml
+++ b/MainWindow.xaml
@@ -5,28 +5,29 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:PointCloudConverter"
mc:Ignorable="d"
- Title="PointCloudConverter" Height="720" Width="907" Background="#FF252222" Closing="Window_Closing" Loaded="Window_Loaded">
+ Title="PointCloudConverter" Height="737" Width="940" Background="#FF252222" Closing="Window_Closing" Loaded="Window_Loaded" MinWidth="940">
-
-
+
+
-
-
-
+
+
+
-
-
-
-
+
+
+
+
+
-
+
-
+
@@ -40,8 +41,12 @@
+
+
+
+
+
-
@@ -77,26 +82,32 @@
+
+
+
+
+
-
+
+
+
+
+
-
-
-
-
+
@@ -120,17 +131,13 @@
+
-
-
-
-
-
@@ -141,12 +148,24 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs
index 020497f..d51049c 100644
--- a/MainWindow.xaml.cs
+++ b/MainWindow.xaml.cs
@@ -23,12 +23,14 @@
using PointCloudConverter.Writers;
using System.Reflection;
using System.Globalization;
+using System.Windows.Media;
+using PointCloudConverter.Structs.Metadata;
namespace PointCloudConverter
{
public partial class MainWindow : Window
{
- static readonly string version = "16.09.2024";
+ static readonly string version = "27.08.2025";
static readonly string appname = "PointCloud Converter - " + version;
static readonly string rootFolder = AppDomain.CurrentDomain.BaseDirectory;
@@ -53,7 +55,7 @@ public partial class MainWindow : Window
public static MainWindow mainWindowStatic;
bool isInitialiazing = true;
- static List lasHeaders = new List();
+ static JobMetadata jobMetadata = new JobMetadata();
// progress bar data
static int progressPoint = 0;
@@ -65,6 +67,10 @@ public partial class MainWindow : Window
public static int errorCounter = 0; // how many errors when importing or reading files (single file could have multiple errors)
private CancellationTokenSource _cancellationTokenSource = new CancellationTokenSource();
+ // filter by distance
+ private readonly float cellSize = 0.5f;
+ private static ConcurrentDictionary<(int, int, int), byte> occupiedCells = new();
+
// plugins
string externalFileFormats = "";
@@ -98,47 +104,59 @@ private async void Main()
////testwriter.Close();
//externalWriters = AppDomain.CurrentDomain.GetAssemblies().SelectMany(assembly => assembly.GetTypes()).Where(type => typeof(IWriter).IsAssignableFrom(type) && !type.IsInterface);
- var pluginsDirectory = "plugins";
+ // Get the directory of the running executable
+ var exeDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
+
+ // Build absolute path to plugins folder
+ var pluginsDirectory = Path.Combine(exeDir, "plugins");
- if (!Directory.Exists(pluginsDirectory))
+ if (Directory.Exists(pluginsDirectory))
{
- Log.Write("Plugins directory not found.");
- return;
- }
+ //Log.Write("Plugins directory not found.");
- // Get all DLL files in the plugins directory
- var pluginFiles = Directory.GetFiles(pluginsDirectory, "*.dll");
+ // Get all DLL files in the plugins directory
+ var pluginFiles = Directory.GetFiles(pluginsDirectory, "*.dll");
- foreach (var pluginDLL in pluginFiles)
- {
- try
+ foreach (var pluginDLL in pluginFiles)
{
- // Load the DLL file as an assembly
- var assembly = Assembly.LoadFrom(pluginDLL);
+ try
+ {
+ // Load the DLL file as an assembly
+ var assembly = Assembly.LoadFrom(pluginDLL);
- // Find all types in the assembly that implement IWriter
- var writerTypes = assembly.GetTypes().Where(type => typeof(IWriter).IsAssignableFrom(type) && !type.IsInterface && !type.IsAbstract);
+ // Find all types in the assembly that implement IWriter
+ var writerTypes = assembly.GetTypes().Where(type => typeof(IWriter).IsAssignableFrom(type) && !type.IsInterface && !type.IsAbstract);
- foreach (var writerType in writerTypes)
- {
- // Derive a unique key for the writer (e.g., from its name or class name)
- string writerName = writerType.Name;//.Replace("Writer", ""); // Customize the key generation logic
- if (!externalWriters.ContainsKey(writerName))
+ foreach (var writerType in writerTypes)
{
- // Add the writer type to the dictionary for later use
- externalWriters.Add(writerName, writerType);
- //Log.Write($"Found writer: {writerType.FullName} in {pluginDLL}");
+ // Derive a unique key for the writer (e.g., from its name or class name)
+ string writerName = writerType.Name;//.Replace("Writer", ""); // Customize the key generation logic
+ if (!externalWriters.ContainsKey(writerName))
+ {
+ // Add the writer type to the dictionary for later use
+ externalWriters.Add(writerName, writerType);
+ //Log.Write($"Found writer: {writerType.FullName} in {pluginDLL}");
- // TODO take extensions from plugin? has 2: .glb and .gltf
- externalFileFormats += "|" + writerName + " (" + writerType.FullName + ")|*." + writerName.ToLower();
+ // TODO take extensions from plugin? has 2: .glb and .gltf
+ externalFileFormats += "|" + writerName + " (" + writerType.FullName + ")|*." + writerName.ToLower();
+ }
}
}
+ catch (ReflectionTypeLoadException rex)
+ {
+ Log.Write($"Error loading plugin {pluginDLL}: {rex.Message}");
+
+ foreach (var loaderException in rex.LoaderExceptions)
+ {
+ Log.Write(" - " + loaderException?.Message);
+ }
+ }
+ catch (Exception ex)
+ {
+ Log.Write($"General error loading plugin {pluginDLL}: {ex.Message}");
+ }
}
- catch (Exception ex)
- {
- Console.WriteLine($"Error loading plugin {pluginDLL}: {ex.Message}");
- }
- }
+ } // if plugins folder exists
//return;
@@ -259,19 +277,23 @@ private static async Task ProcessAllFiles(object workerParamsObject)
List boundsListTemp = new List();
+ // clear filter by distance
+ occupiedCells.Clear();
+
// get all file bounds, if in batch mode and RGB+INT+PACK
// TODO: check what happens if its too high? over 128/256?
//if (importSettings.useAutoOffset == true && importSettings.importIntensity == true && importSettings.importRGB == true && importSettings.packColors == true && importSettings.importMetadataOnly == false)
-
//Log.Write(importSettings.useAutoOffset + " && " + importSettings.importMetadataOnly + " || (" + importSettings.importIntensity + " && " + importSettings.importRGB + " && " + importSettings.packColors + " && " + importSettings.importMetadataOnly + ")");
//bool istrue1 = (importSettings.useAutoOffset == true && importSettings.importMetadataOnly == false);
//bool istrue2 = (importSettings.importIntensity == true && importSettings.importRGB == true && importSettings.packColors == true && importSettings.importMetadataOnly == false);
//Log.Write(istrue1 ? "1" : "0");
//Log.Write(istrue2 ? "1" : "0");
- if ((importSettings.useAutoOffset == true && importSettings.importMetadataOnly == false) || (importSettings.importIntensity == true && importSettings.importRGB == true && importSettings.packColors == true && importSettings.importMetadataOnly == false))
+ if ((importSettings.useAutoOffset == true && importSettings.importMetadataOnly == false) || ((importSettings.importIntensity == true || importSettings.importClassification == true) && importSettings.importRGB == true && importSettings.packColors == true && importSettings.importMetadataOnly == false))
{
- for (int i = 0, len = importSettings.maxFiles; i < len; i++)
+ int iterations = importSettings.offsetMode == "min" ? importSettings.maxFiles : 1; // 1 for legacy mode (first cloud only)
+
+ for (int i = 0, len = iterations; i < len; i++)
{
if (cancellationToken.IsCancellationRequested)
{
@@ -300,6 +322,7 @@ private static async Task ProcessAllFiles(object workerParamsObject)
}
}
+ // NOTE this fails with some files? returns 0,0,0 for some reason
// find lowest bounds from boundsListTemp
float lowestX = float.MaxValue;
float lowestY = float.MaxValue;
@@ -311,14 +334,22 @@ private static async Task ProcessAllFiles(object workerParamsObject)
if (boundsListTemp[iii].z < lowestZ) lowestZ = (float)boundsListTemp[iii].z;
}
- //Console.WriteLine("Lowest bounds: " + lowestX + " " + lowestY + " " + lowestZ);
+ //Log.Write("Lowest bounds: " + lowestX + " " + lowestY + " " + lowestZ);
// TODO could take center for XZ, and lowest for Y?
importSettings.offsetX = lowestX;
importSettings.offsetY = lowestY;
importSettings.offsetZ = lowestZ;
} // if useAutoOffset
- lasHeaders.Clear();
+
+ //lasHeaders.Clear();
+ jobMetadata.Job = new Job
+ {
+ ConverterVersion = version,
+ ImportSettings = importSettings,
+ StartTime = DateTime.Now
+ };
+ jobMetadata.lasHeaders.Clear();
progressFile = 0;
//for (int i = 0, len = importSettings.maxFiles; i < len; i++)
@@ -383,11 +414,18 @@ private static async Task ProcessAllFiles(object workerParamsObject)
}
finally
{
- //// Ensure the semaphore is released, if needed
- //if (semaphore.CurrentCount == 0) // Make sure we don't release more times than we acquire
- //{
- // semaphore.Release();
- //}
+ // Ensure the semaphore is released safely
+ if (semaphore.CurrentCount == 0) // Make sure we don't release more times than we acquire
+ {
+ try
+ {
+ semaphore.Release();
+ }
+ catch (SemaphoreFullException ex)
+ {
+ //Log.Write($"Semaphore was already fully released. Exception: {ex.Message}");
+ }
+ }
}
//int? taskId = Task.CurrentId; // Get the current task ID
@@ -413,12 +451,23 @@ private static async Task ProcessAllFiles(object workerParamsObject)
Interlocked.Increment(ref errorCounter); // thread-safe error counter increment
if (importSettings.useJSONLog)
{
- Trace.WriteLine("useJSONLoguseJSONLoguseJSONLoguseJSONLog");
- Log.Write("{\"event\": \"" + LogEvent.File + "\", \"path\": " + System.Text.Json.JsonSerializer.Serialize(importSettings.inputFiles[i]) + ", \"status\": \"" + LogStatus.Processing + "\"}", LogEvent.Error);
+ // if canceled, we dont want to log this (causes nullref)
+ if (cancellationToken.IsCancellationRequested == false)
+ {
+ Log.Write("{\"event\": \"" + LogEvent.File + "\", \"path\": " + System.Text.Json.JsonSerializer.Serialize(importSettings.inputFiles[i]) + ", \"status\": \"" + LogStatus.Processing + "\"}", LogEvent.Error);
+ }
}
else
{
- Log.Write("Error> Failed to parse file: " + importSettings.inputFiles[i], LogEvent.Error);
+ if (cancellationToken.IsCancellationRequested)
+ {
+ Log.Write("Task was canceled.");
+ }
+ else
+ {
+ Log.Write("files" + importSettings.inputFiles.Count + " i:" + i);
+ Log.Write("Error> Failed to parse file: " + importSettings.inputFiles[i], LogEvent.Error);
+ }
}
}
}
@@ -465,14 +514,25 @@ private static async Task ProcessAllFiles(object workerParamsObject)
StringEscapeHandling = StringEscapeHandling.Default // This prevents escaping of characters and write the WKT string properly
};
- string jsonMeta = JsonConvert.SerializeObject(lasHeaders, settings);
+ // add job date
+ jobMetadata.Job.EndTime = DateTime.Now;
+ jobMetadata.Job.Elapsed = jobMetadata.Job.EndTime - jobMetadata.Job.StartTime;
+
+ string jsonMeta = JsonConvert.SerializeObject(jobMetadata, settings);
// var jsonMeta = JsonSerializer.Serialize(lasHeaders, new JsonSerializerOptions() { WriteIndented = true });
//Log.Write("MetaData: " + jsonMeta);
// write metadata to file
if (importSettings.importMetadata == true)
{
- var jsonFile = Path.Combine(Path.GetDirectoryName(importSettings.outputFile), Path.GetFileNameWithoutExtension(importSettings.outputFile) + ".json");
+ string filename = Path.GetFileNameWithoutExtension(importSettings.outputFile);
+ // for gltf, there is no output filename
+ if (string.IsNullOrEmpty(filename))
+ {
+ // get last folder name
+ filename = Path.GetFileName(Path.GetDirectoryName(importSettings.inputFiles[0]));
+ }
+ var jsonFile = Path.Combine(Path.GetDirectoryName(importSettings.outputFile), filename + ".json");
Log.Write("Writing metadata to file: " + jsonFile);
File.WriteAllText(jsonFile, jsonMeta);
}
@@ -527,7 +587,7 @@ static void StartProgressTimer()
//Log.Write("Starting progress timer..*-*************************");
progressTimerThread = new DispatcherTimer(DispatcherPriority.Background, Application.Current.Dispatcher);
progressTimerThread.Tick += ProgressTick;
- progressTimerThread.Interval = TimeSpan.FromSeconds(0.1);
+ progressTimerThread.Interval = TimeSpan.FromSeconds(1);
progressTimerThread.Start();
Application.Current.Dispatcher.Invoke(new Action(() =>
@@ -544,8 +604,8 @@ static void StartProgressTimer()
public class ProgressInfo
{
public int Index { get; internal set; } // Index of the ProgressBar in the UI
- public int CurrentValue { get; internal set; } // Current progress value
- public int MaxValue { get; internal set; } // Maximum value for the progress
+ public long CurrentValue { get; internal set; } // Current progress value
+ public long MaxValue { get; internal set; } // Maximum value for the progress
public string FilePath { get; internal set; }
public bool UseJsonLog { get; internal set; }
}
@@ -615,8 +675,8 @@ static void ProgressTick(object sender, EventArgs e)
foreach (var progressInfo in progressInfos)
{
int index = progressInfo.Index;
- int currentValue = progressInfo.CurrentValue;
- int maxValue = progressInfo.MaxValue;
+ long currentValue = progressInfo.CurrentValue;
+ long maxValue = progressInfo.MaxValue;
// Access ProgressBar directly from the StackPanel.Children using its index
if (index >= 0 && index < mainWindowStatic.ProgressBarsContainer.Children.Count)
@@ -625,9 +685,9 @@ static void ProgressTick(object sender, EventArgs e)
{
progressBar.Maximum = maxValue;
progressBar.Value = currentValue;
- progressBar.Foreground = (currentValue + 1 >= maxValue ? Brushes.Lime : Brushes.Red); //+1 hack fix
- //progressBar.ToolTip = $"Thread {index} - {currentValue} / {maxValue}"; // not visible, because modal dialog
- //Log.Write("ProgressTick: " + index + " " + currentValue + " / " + maxValue);
+ progressBar.Foreground = ((currentValue + 1 >= maxValue) ? Brushes.Lime : Brushes.Red); //+1 hack fix
+ //progressBar.ToolTip = $"Thread {index} - {currentValue} / {maxValue}"; // not visible, because modal dialog
+ //Log.Write("ProgressTick: " + index + " " + currentValue + " / " + maxValue);
// print json progress
if (progressInfo.UseJsonLog) // TODO now same bool value is for each progressinfo..
@@ -637,7 +697,7 @@ static void ProgressTick(object sender, EventArgs e)
"\"thread\": " + index + "," +
"\"currentPoint\": " + currentValue + "," +
"\"totalPoints\": " + maxValue + "," +
- "\"percentage\": " + (int)((currentValue / (float)maxValue) * 100) + "," +
+ "\"percentage\": " + (int)((currentValue / (float)maxValue) * 100.0) + "," +
"\"file\": " + System.Text.Json.JsonSerializer.Serialize(progressInfo.FilePath) +
"}";
Log.Write(jsonString, LogEvent.Progress);
@@ -646,12 +706,12 @@ static void ProgressTick(object sender, EventArgs e)
}
} // foreach progressinfo
} // lock
- //}
- //else // finished ?
- //{
- // Log.Write("*************** ProgressTick: progressTotalPoints is 0, finishing..");
- // mainWindowStatic.progressBarFiles.Value = 0;
- // mainWindowStatic.lblStatus.Content = "";
+ //}
+ //else // finished ?
+ //{
+ // Log.Write("*************** ProgressTick: progressTotalPoints is 0, finishing..");
+ // mainWindowStatic.progressBarFiles.Value = 0;
+ // mainWindowStatic.lblStatus.Content = "";
// foreach (UIElement element in mainWindowStatic.ProgressBarsContainer.Children)
// {
@@ -686,7 +746,7 @@ static void ProgressTick(object sender, EventArgs e)
// process single file
static bool ParseFile(ImportSettings importSettings, int fileIndex, int? taskId, CancellationToken cancellationToken)
{
- progressTotalPoints = 1; // FIXME dummy for progress bar
+ progressTotalPoints = 0;
Log.Write("Started processing file: " + importSettings.inputFiles[fileIndex]);
@@ -697,7 +757,7 @@ static bool ParseFile(ImportSettings importSettings, int fileIndex, int? taskId,
IReader taskReader = importSettings.GetOrCreateReader(taskId);
ProgressInfo progressInfo = null;
- lock (lockObject)
+ //lock (lockObject)
{
//Log.Write(progressInfos.Count + " : " + fileIndex, LogEvent.Info);
progressInfo = progressInfos[fileIndex % progressInfos.Count];
@@ -721,16 +781,10 @@ static bool ParseFile(ImportSettings importSettings, int fileIndex, int? taskId,
return false;
}
- if (importSettings.importMetadata == true)
- {
- var metaData = taskReader.GetMetaData(importSettings, fileIndex);
- lasHeaders.Add(metaData);
- }
-
if (importSettings.importMetadataOnly == false)
{
- int fullPointCount = taskReader.GetPointCount();
- int pointCount = fullPointCount;
+ long fullPointCount = taskReader.GetPointCount();
+ long pointCount = fullPointCount;
// show stats for decimations
if (importSettings.skipPoints == true)
@@ -759,8 +813,9 @@ static bool ParseFile(ImportSettings importSettings, int fileIndex, int? taskId,
// NOTE only works with formats that have bounds defined in header, otherwise need to loop whole file to get bounds?
// dont use these bounds, in this case
- if (importSettings.useAutoOffset == true || (importSettings.importIntensity == true && importSettings.importRGB == true && importSettings.packColors == true))
+ if (importSettings.useAutoOffset == true || ((importSettings.importIntensity == true || importSettings.importClassification == true) && importSettings.importRGB == true && importSettings.packColors == true))
{
+ // TODO add manual offset here still?
// we use global bounds or Y offset to fix negative Y
}
else if (importSettings.useManualOffset == true)
@@ -769,13 +824,18 @@ static bool ParseFile(ImportSettings importSettings, int fileIndex, int? taskId,
importSettings.offsetY = importSettings.manualOffsetY;
importSettings.offsetZ = importSettings.manualOffsetZ;
}
- else // neither
+ else // no autooffset either
{
- importSettings.offsetX = 0;
- importSettings.offsetY = 0;
- importSettings.offsetZ = 0;
+ if (importSettings.useAutoOffset == false)
+ {
+ importSettings.offsetX = 0;
+ importSettings.offsetY = 0;
+ importSettings.offsetZ = 0;
+ }
}
+ //Log.Write("************** Offsets: " + importSettings.offsetX + " " + importSettings.offsetY + " " + importSettings.offsetZ);
+
var taskWriter = importSettings.GetOrCreateWriter(taskId);
// for saving pcroot header, we need this writer
@@ -800,8 +860,6 @@ static bool ParseFile(ImportSettings importSettings, int fileIndex, int? taskId,
//progressPoint = 0;
progressInfo.CurrentValue = 0;
progressInfo.MaxValue = importSettings.useLimit ? pointCount : fullPointCount;
- //progressTotalPoints = importSettings.useLimit ? pointCount : fullPointCount;
-
progressInfo.FilePath = importSettings.inputFiles[fileIndex];
lastStatusMessage = "Processing points..";
@@ -816,15 +874,16 @@ static bool ParseFile(ImportSettings importSettings, int fileIndex, int? taskId,
Log.Write(jsonString, LogEvent.File);
- int checkCancelEvery = fullPointCount / 100;
+ long checkCancelEvery = fullPointCount / 128;
+
+ // detect is 0-255 or 0-65535 range
+ bool isCustomIntensityRange = false;
// Loop all points
- for (int i = 0; i < fullPointCount; i++)
- //for (int i = 0; i < 1000; i++)
+ // FIXME: would be nicer, if use different STEP value for skip, keep and limit..(to collect points all over the file, not just start)
+ long maxPointIterations = importSettings.useLimit ? pointCount : fullPointCount;
+ for (int i = 0; i < maxPointIterations; i++)
{
- // stop at limit count
- if (importSettings.useLimit == true && i > pointCount) break;
-
// check for cancel every 1% of points
if (i % checkCancelEvery == 0)
{
@@ -835,11 +894,31 @@ static bool ParseFile(ImportSettings importSettings, int fileIndex, int? taskId,
}
}
- // FIXME: need to add skip and keep point skipper here, to make skipping faster!
-
// get point XYZ
Float3 point = taskReader.GetXYZ();
- if (point.hasError == true) break;
+ if (point.hasError == true) break; // TODO display errors
+
+ // get point color
+ Color rgb = (default);
+
+ if (importSettings.importRGB == true)
+ {
+ rgb = taskReader.GetRGB();
+
+ // convert from srg to linear (if your model seems too bright)
+ if (importSettings.sRGB)
+ {
+ rgb.r = Tools.SRGBToLinear(rgb.r);
+ rgb.g = Tools.SRGBToLinear(rgb.g);
+ rgb.b = Tools.SRGBToLinear(rgb.b);
+ }
+ }
+
+ // skip points
+ if (importSettings.skipPoints == true && (i % importSettings.skipEveryN == 0)) continue;
+
+ // keep points
+ if (importSettings.keepPoints == true && (i % importSettings.keepEveryN != 0)) continue;
// add offsets (its 0 if not used)
point.x -= importSettings.offsetX;
@@ -847,9 +926,6 @@ static bool ParseFile(ImportSettings importSettings, int fileIndex, int? taskId,
point.z -= importSettings.offsetZ;
// scale if enabled
- //point.x = importSettings.useScale ? point.x * importSettings.scale : point.x;
- //point.y = importSettings.useScale ? point.y * importSettings.scale : point.y;
- //point.z = importSettings.useScale ? point.z * importSettings.scale : point.z;
if (importSettings.useScale == true)
{
point.x *= importSettings.scale;
@@ -877,28 +953,74 @@ static bool ParseFile(ImportSettings importSettings, int fileIndex, int? taskId,
point.x = -point.x;
}
- // get point color
- Color rgb = (default);
- Color intensity = (default);
- double time = 0;
-
- if (importSettings.importRGB == true)
+ // filtering is done after scaling and offsets
+ if (importSettings.useFilter)
{
- rgb = taskReader.GetRGB();
+ var cell = ((int)Math.Floor(point.x / importSettings.filterDistance), (int)Math.Floor(point.y / importSettings.filterDistance), (int)Math.Floor(point.z / importSettings.filterDistance));
+
+ if (!occupiedCells.TryAdd(cell, 0))
+ {
+ continue; // cell already taken, skip this point
+ }
}
- // TODO get intensity as separate value, TODO is this float or rgb?
+ ushort intensity = 0;
+ byte classification = 0;
+ double time = 0;
+
+ // TODO get intensity as separate value
if (importSettings.importIntensity == true)
{
+ //intensity = 0;
intensity = taskReader.GetIntensity();
- //if (i < 100) Console.WriteLine(intensity.r);
+
+ //if (i < 20000) Log.Write("int: " + intensity);
+
+ if (importSettings.detectIntensityRange && isCustomIntensityRange == false)
+ {
+ // check if intensity is 0-255 or 0-65535
+ isCustomIntensityRange = intensity > 255;
+ //Log.Write("Detecting intensity range " + intensity + " " + (isCustomIntensityRange ? "************" : "")+" "+ importSettings.inputFiles[fileIndex]);
+ }
+
+ // if no rgb, then replace RGB with intensity, NOTE this doesnt work correctly if using detect intensity range! (since raw value is now ushort, can be 0-65k)
+ if (importSettings.importRGB == false)
+ {
+ rgb.r = intensity / 255f; // convert byte to float
+ rgb.g = rgb.r;
+ rgb.b = rgb.r;
+ }
+ }
+
+ // FIXME cannot have both classification and intensity, because both save into RGB here
+
+ if (importSettings.importClassification == true)
+ {
+ classification = taskReader.GetClassification();
+
+ //classification = (byte)255;
+
+ //if (classification<0 || classification>1) Log.Write("****: " + classification.ToString());
+
+ //if (i < 10000) Log.Write("class: " + classification.ToString() + " minClass: " + minClass + " maxClass: " + maxClass);
+ //classification = 0;
+ //if (intensity.r < minInt)
+ //{
+ // minInt = intensity.r;
+ // Log.Write("Min: " + minInt + " Max: " + maxInt);
+ //}
+ //if (intensity.r > maxInt)
+ //{
+ // maxInt = intensity.r;
+ // Log.Write("Min: " + minInt + " Max: " + maxInt);
+ //}
// if no rgb, then replace RGB with intensity
if (importSettings.importRGB == false)
{
- rgb.r = intensity.r;
- rgb.g = intensity.r;
- rgb.b = intensity.r;
+ rgb.r = classification / 255f;
+ rgb.g = rgb.r;
+ rgb.b = rgb.r;
}
}
@@ -912,11 +1034,19 @@ static bool ParseFile(ImportSettings importSettings, int fileIndex, int? taskId,
// collect this point XYZ and RGB into node, optionally intensity also
//importSettings.writer.AddPoint(i, (float)point.x, (float)point.y, (float)point.z, rgb.r, rgb.g, rgb.b, importSettings.importIntensity, intensity.r, importSettings.averageTimestamp, time);
// TODO can remove importsettings, its already passed on init
- taskWriter.AddPoint(i, (float)point.x, (float)point.y, (float)point.z, rgb.r, rgb.g, rgb.b, importSettings.importIntensity, intensity.r, importSettings.averageTimestamp, time);
+ taskWriter.AddPoint(index: i, x: (float)point.x, y: (float)point.y, z: (float)point.z, r: rgb.r, g: rgb.g, b: rgb.b, intensity: intensity, time: time, classification: classification);
//progressPoint = i;
progressInfo.CurrentValue = i;
} // for all points
+ // hack for missing 100% progress
+ progressInfo.CurrentValue = maxPointIterations;
+
+ if (importSettings.detectIntensityRange == true)
+ {
+ taskWriter.SetIntensityRange(isCustomIntensityRange);
+ }
+
lastStatusMessage = "Saving files..";
//importSettings.writer.Save(fileIndex);
taskWriter.Save(fileIndex);
@@ -940,7 +1070,21 @@ static bool ParseFile(ImportSettings importSettings, int fileIndex, int? taskId,
//Log.Write(jsonString, LogEvent.File);
- } // if importMetadataOnly == false
+ if (importSettings.importMetadata == true)
+ {
+ var metaData = taskReader.GetMetaData(importSettings, fileIndex);
+ jobMetadata.lasHeaders.Add(metaData);
+ }
+
+ } // if importMetadataOnly == false ^
+ else // only metadata:
+ {
+ if (importSettings.importMetadata == true)
+ {
+ var metaData = taskReader.GetMetaData(importSettings, fileIndex);
+ jobMetadata.lasHeaders.Add(metaData);
+ }
+ }
//Log.Write("taskid: " + taskId + " done");
return true;
@@ -1007,24 +1151,46 @@ void StartProcess(bool doProcess = true)
var args = new List();
// add enabled args to list, TODO use binding later?
- args.Add("-input=" + txtInputFile.Text);
+ string inputFile = txtInputFile.Text;
+ string outputFile = txtOutput.Text;
+
+ // add quotes, if contains space in path
+ if (inputFile.Contains(" ")) inputFile = "\"" + inputFile + "\"";
+ if (outputFile.Contains(" ")) outputFile = "\"" + outputFile + "\"";
if (cmbImportFormat.SelectedItem != null)
{
args.Add("-importformat=" + cmbImportFormat.SelectedItem.ToString());
}
+
+ args.Add("-input=" + inputFile);
+
if (cmbExportFormat.SelectedItem != null)
{
args.Add("-exportformat=" + cmbExportFormat.SelectedItem.ToString());
}
- args.Add("-output=" + txtOutput.Text);
- args.Add("-offset=" + (bool)chkAutoOffset.IsChecked);
+ args.Add("-output=" + outputFile);
+
+ // check if using autooffset
+ //if ((bool)chkAutoOffset.IsChecked && !(bool)chkManualOffset.IsChecked)
+ if (!(bool)chkManualOffset.IsChecked)
+ {
+ args.Add("-offset=" + (bool)chkAutoOffset.IsChecked);
+ }
+
+ args.Add("-offsetmode=" + txtOffsetMode.Text.ToLower());
+
+ // or manual offset, TODO later should allow using both (first autooffset, then add manual)
+ if ((bool)chkManualOffset.IsChecked) args.Add("-offset=" + txtOffsetX.Text + "," + txtOffsetY.Text + "," + txtOffsetZ.Text);
+
args.Add("-rgb=" + (bool)chkImportRGB.IsChecked);
args.Add("-intensity=" + (bool)chkImportIntensity.IsChecked);
+ args.Add("-classification=" + (bool)chkImportClassification.IsChecked);
+
bool isPCROOT = (cmbExportFormat.SelectedItem.ToString() == "PCROOT");
- bool isGLTF = (cmbExportFormat.SelectedItem.ToString() == "GLTF");
+ bool isGLTF = (cmbExportFormat.SelectedItem.ToString().ToUpper() == "GLTF" || cmbExportFormat.SelectedItem.ToString().ToUpper() == "GLB");
// cmbExportFormat.SelectedItem?.ToString()?.ToUpper()?.Contains("PCROOT")
if (isPCROOT == true) args.Add("-gridsize=" + txtGridSize.Text);
@@ -1040,7 +1206,6 @@ void StartProcess(bool doProcess = true)
if ((bool)chkUseSkip.IsChecked) args.Add("-skip=" + txtSkipEvery.Text);
if ((bool)chkUseKeep.IsChecked) args.Add("-keep=" + txtKeepEvery.Text);
if ((bool)chkUseMaxFileCount.IsChecked) args.Add("-maxfiles=" + txtMaxFileCount.Text);
- if ((bool)chkManualOffset.IsChecked) args.Add("-offset=" + txtOffsetX.Text + "," + txtOffsetY.Text + "," + txtOffsetZ.Text);
args.Add("-randomize=" + (bool)chkRandomize.IsChecked);
if ((bool)chkSetRandomSeed.IsChecked) args.Add("-seed=" + txtRandomSeed.Text);
if ((bool)chkUseJSONLog.IsChecked) args.Add("-json=true");
@@ -1050,12 +1215,17 @@ void StartProcess(bool doProcess = true)
if ((bool)chkCalculateOverlappingTiles.IsChecked) args.Add("-checkoverlap=true");
args.Add("-maxthreads=" + txtMaxThreads.Text);
+ if ((bool)chkUseFilter.IsChecked) args.Add("-filter=" + txtFilterDistance.Text);
+ if ((bool)chkConvertSRGB.IsChecked) args.Add("-srgb=true");
+
+
if (isGLTF == true) args.Add(("-usegrid=" + (bool)chkUseGrid.IsChecked).ToLower());
if (((bool)chkImportIntensity.IsChecked) && ((bool)chkCustomIntensityRange.IsChecked)) args.Add("-customintensityrange=True");
+ if (((bool)chkDetectIntensityRange.IsChecked) && ((bool)chkDetectIntensityRange.IsChecked)) args.Add("-detectintensityrange=True");
// check input files
- Trace.WriteLine("loggeris:" + Log.GetType().ToString());
+ //Trace.WriteLine("loggeris:" + Log.GetType().ToString());
var importSettings = ArgParser.Parse(args.ToArray(), rootFolder, Log);
@@ -1116,6 +1286,9 @@ void ImportArgs(string rawArgs)
bool isFirstArgExe = args[0].EndsWith(".exe", StringComparison.OrdinalIgnoreCase);
int startIndex = isFirstArgExe ? 1 : 0;
+ // reset all checkboxes to false
+ UncheckAllCheckboxes(this);
+
for (int i = startIndex; i < args.Length; i++)
{
string arg = args[i];
@@ -1134,6 +1307,8 @@ void ImportArgs(string rawArgs)
string key = parts[0].ToLower().TrimStart('-');
string value = parts[1];
+ // FIXME, if value is not saved, need to use default value
+
// Apply the key-value pairs to the GUI elements
switch (key)
{
@@ -1158,6 +1333,9 @@ void ImportArgs(string rawArgs)
case "intensity":
chkImportIntensity.IsChecked = value.ToLower() == "true";
break;
+ case "classification":
+ chkImportClassification.IsChecked = value.ToLower() == "true";
+ break;
case "gridsize":
txtGridSize.Text = value;
break;
@@ -1237,6 +1415,27 @@ void ImportArgs(string rawArgs)
} // for all args
} // ImportArgs()
+ private void UncheckAllCheckboxes(DependencyObject parent)
+ {
+ // Loop through all the child elements
+ for (int i = 0; i < VisualTreeHelper.GetChildrenCount(parent); i++)
+ {
+ var child = VisualTreeHelper.GetChild(parent, i);
+
+ // If the child is a CheckBox, set it to unchecked
+ if (child is CheckBox checkBox)
+ {
+ checkBox.IsChecked = false;
+ }
+
+ // If the child is a container, recursively call the function to check its children
+ if (VisualTreeHelper.GetChildrenCount(child) > 0)
+ {
+ UncheckAllCheckboxes(child);
+ }
+ }
+ }
+
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
SaveSettings();
@@ -1250,7 +1449,27 @@ private void btnBrowseInput_Click(object sender, RoutedEventArgs e)
// select single file
var dialog = new OpenFileDialog();
dialog.Title = "Select file to import";
- dialog.Filter = "LAS|*.las;*.laz";
+
+ if (cmbImportFormat.SelectedItem != null)
+ {
+ var format = cmbImportFormat.SelectedItem.ToString();
+ if (format == "LAS" || format == "LAZ")
+ {
+ dialog.Filter = "LAS Files|*.las;*.laz|All Files|*.*";
+ }
+ else if (format == "PLY")
+ {
+ dialog.Filter = "PLY Files|*.ply|All Files|*.*";
+ }
+ else
+ {
+ dialog.Filter = "All Files|*.*";
+ }
+ }
+ else
+ {
+ dialog.Filter = "Point Cloud Files|*.las;*.laz;*.ply|LAS Files|*.las;*.laz|PLY Files|*.ply|All Files|*.*";
+ }
// take folder from field
if (string.IsNullOrEmpty(txtInputFile.Text) == false)
@@ -1354,7 +1573,7 @@ private void LoadSettings()
{
if ((ExportFormat)item == ExportFormat.Unknown) continue;
if ((ExportFormat)item == ExportFormat.External) continue;
- cmbExportFormat.Items.Add(item);
+ cmbExportFormat.Items.Add(item.ToString());
}
// Add dynamic export formats discovered from plugins
@@ -1376,6 +1595,7 @@ private void LoadSettings()
chkImportRGB.IsChecked = Properties.Settings.Default.importRGB;
chkImportIntensity.IsChecked = Properties.Settings.Default.importIntensity;
+ chkImportClassification.IsChecked = Properties.Settings.Default.importClassification;
chkAutoOffset.IsChecked = Properties.Settings.Default.useAutoOffset;
txtGridSize.Text = Properties.Settings.Default.gridSize.ToString();
@@ -1399,6 +1619,7 @@ private void LoadSettings()
txtMaxFileCount.Text = Properties.Settings.Default.maxFileCount.ToString();
chkRandomize.IsChecked = Properties.Settings.Default.randomize;
chkCustomIntensityRange.IsChecked = Properties.Settings.Default.customintensityrange;
+ chkDetectIntensityRange.IsChecked = Properties.Settings.Default.detectIntensityRange;
chkOpenOutputFolder.IsChecked = Properties.Settings.Default.openOutputFolder;
chkManualOffset.IsChecked = Properties.Settings.Default.useManualOffset;
txtOffsetX.Text = Properties.Settings.Default.manualOffsetX.ToString();
@@ -1413,6 +1634,10 @@ private void LoadSettings()
chkCalculateOverlappingTiles.IsChecked = Properties.Settings.Default.calculateOverlappingTiles;
txtMaxThreads.Text = Properties.Settings.Default.maxThreads;
chkUseGrid.IsChecked = Properties.Settings.Default.useGrid;
+ txtOffsetMode.Text = Properties.Settings.Default.offsetMode;
+ chkUseFilter.IsChecked = Properties.Settings.Default.useFilter;
+ txtFilterDistance.Text = Properties.Settings.Default.filterDistance.ToString();
+ chkConvertSRGB.IsChecked = Properties.Settings.Default.useSRGB;
isInitialiazing = false;
}
@@ -1444,9 +1669,10 @@ void SaveSettings()
Properties.Settings.Default.maxFileCount = Tools.ParseInt(txtMaxFileCount.Text);
Properties.Settings.Default.randomize = (bool)chkRandomize.IsChecked;
Properties.Settings.Default.customintensityrange = (bool)chkCustomIntensityRange.IsChecked;
+ Properties.Settings.Default.detectIntensityRange = (bool)chkDetectIntensityRange.IsChecked;
Properties.Settings.Default.openOutputFolder = (bool)chkOpenOutputFolder.IsChecked;
Properties.Settings.Default.useManualOffset = (bool)chkManualOffset.IsChecked;
- float.TryParse(txtOffsetX.Text.Replace(",","."), NumberStyles.Float, CultureInfo.InvariantCulture, out float offsetX);
+ float.TryParse(txtOffsetX.Text.Replace(",", "."), NumberStyles.Float, CultureInfo.InvariantCulture, out float offsetX);
Properties.Settings.Default.manualOffsetX = offsetX;
float.TryParse(txtOffsetY.Text.Replace(",", "."), NumberStyles.Float, CultureInfo.InvariantCulture, out float offsetY);
Properties.Settings.Default.manualOffsetY = offsetY;
@@ -1463,6 +1689,10 @@ void SaveSettings()
Properties.Settings.Default.calculateOverlappingTiles = (bool)chkCalculateOverlappingTiles.IsChecked;
Properties.Settings.Default.maxThreads = txtMaxThreads.Text;
Properties.Settings.Default.useGrid = (bool)chkUseGrid.IsChecked;
+ Properties.Settings.Default.offsetMode = txtOffsetMode.Text;
+ Properties.Settings.Default.useFilter = (bool)chkUseFilter.IsChecked;
+ Properties.Settings.Default.filterDistance = Tools.ParseFloat(txtFilterDistance.Text);
+ Properties.Settings.Default.useSRGB = (bool)chkConvertSRGB.IsChecked;
Properties.Settings.Default.Save();
}
@@ -1535,6 +1765,16 @@ private void chkImportRGB_Checked(object sender, RoutedEventArgs e)
Properties.Settings.Default.Save();
}
+ private void chkImportRGB_Unchecked(object sender, RoutedEventArgs e)
+ {
+ if (isInitialiazing == true) return;
+ Properties.Settings.Default.importRGB = false;
+
+ //chkImportIntensity.IsChecked = true;
+ //Properties.Settings.Default.importIntensity = true;
+ Properties.Settings.Default.Save();
+ }
+
private void chkImportIntensity_Checked(object sender, RoutedEventArgs e)
{
if (isInitialiazing == true) return;
@@ -1549,21 +1789,30 @@ private void chkImportIntensity_Unchecked(object sender, RoutedEventArgs e)
if (isInitialiazing == true) return;
Properties.Settings.Default.importIntensity = false;
- chkImportRGB.IsChecked = true;
- Properties.Settings.Default.importRGB = true;
+ //chkImportRGB.IsChecked = true;
+ //Properties.Settings.Default.importRGB = true;
+ Properties.Settings.Default.importIntensity = false;
Properties.Settings.Default.Save();
}
- private void chkImportRGB_Unchecked(object sender, RoutedEventArgs e)
+ private void chkImportClassification_Checked(object sender, RoutedEventArgs e)
{
if (isInitialiazing == true) return;
- Properties.Settings.Default.importRGB = false;
- chkImportIntensity.IsChecked = true;
- Properties.Settings.Default.importIntensity = true;
+ // TODO for now only can import classification as RGB color
+ Properties.Settings.Default.importClassification = true;
Properties.Settings.Default.Save();
}
+ private void chkImportClassification_Unchecked(object sender, RoutedEventArgs e)
+ {
+ if (isInitialiazing == true) return;
+ // TODO for now only can import classification as RGB color
+ Properties.Settings.Default.importClassification = false;
+ Properties.Settings.Default.Save();
+ }
+
+
private void txtInputFile_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
@@ -1628,11 +1877,8 @@ private void chkManualOffset_Checked(object sender, RoutedEventArgs e)
private void btnCopyToClipboard_Click(object sender, RoutedEventArgs e)
{
- // copy console to clipboard
- System.Windows.Clipboard.SetText(txtConsole.Text);
- // focus
+ Clipboard.SetText(txtConsole.Text);
txtConsole.Focus();
- // select all text
txtConsole.SelectAll();
e.Handled = true;
}
@@ -1640,15 +1886,26 @@ private void btnCopyToClipboard_Click(object sender, RoutedEventArgs e)
private void btnImportSettings_Click(object sender, RoutedEventArgs e)
{
var dialog = new OpenFileDialog();
- dialog.Title = "Select settings file";
+ dialog.Title = "Import settings file";
dialog.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*";
+ // if have previously used config dir use that, if not, use local config dir if exists, if neither, use default..
+ if (string.IsNullOrEmpty(Properties.Settings.Default.lastUsedConfigFolder) == false)
+ {
+ dialog.InitialDirectory = Properties.Settings.Default.lastUsedConfigFolder;
+ }
+ else if (Directory.Exists(Path.Combine(Directory.GetCurrentDirectory(), "configs")))
+ {
+ dialog.InitialDirectory = Path.Combine(Directory.GetCurrentDirectory(), "configs");
+ }
+
if (dialog.ShowDialog() == true)
{
if (File.Exists(dialog.FileName))
{
var contents = File.ReadAllText(dialog.FileName);
ImportArgs(contents);
+ Properties.Settings.Default.lastUsedConfigFolder = Path.GetDirectoryName(dialog.FileName);
}
}
}
@@ -1659,13 +1916,33 @@ private void btnExportSettings_Click(object sender, RoutedEventArgs e)
dialog.Title = "Save settings file";
dialog.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*";
+ if (string.IsNullOrEmpty(Properties.Settings.Default.lastUsedConfigFolder) == false)
+ {
+ dialog.InitialDirectory = Properties.Settings.Default.lastUsedConfigFolder;
+ }
+ else if (Directory.Exists(Path.Combine(Directory.GetCurrentDirectory(), "configs")))
+ {
+ dialog.InitialDirectory = Path.Combine(Directory.GetCurrentDirectory(), "configs");
+ }
+
if (dialog.ShowDialog() == true)
{
StartProcess(false);
File.WriteAllText(dialog.FileName, txtConsole.Text);
+ Properties.Settings.Default.lastUsedConfigFolder = Path.GetDirectoryName(dialog.FileName);
}
}
+ private void btnPlugins_Click(object sender, RoutedEventArgs e)
+ {
+ // open plugins folder in explorer at location of this exe
+ var pluginsFolder = Path.Combine(Directory.GetCurrentDirectory(), "plugins");
+ if (Directory.Exists(pluginsFolder) == false)
+ {
+ Directory.CreateDirectory(pluginsFolder);
+ }
+ Process.Start(new ProcessStartInfo("explorer.exe", pluginsFolder));
+ }
} // class
} // namespace
diff --git a/PointCloudConverter.csproj b/PointCloudConverter.csproj
index 3f43361..34c5a9d 100644
--- a/PointCloudConverter.csproj
+++ b/PointCloudConverter.csproj
@@ -34,14 +34,17 @@
+
+
+
-
+
diff --git a/PointCloudConverter.sln b/PointCloudConverter.sln
index 09242a5..a1166b6 100644
--- a/PointCloudConverter.sln
+++ b/PointCloudConverter.sln
@@ -23,10 +23,10 @@ Global
{B348688B-00FB-45A8-8BBD-D2D64FD7E8D8}.Release|Any CPU.Build.0 = Release|Any CPU
{B348688B-00FB-45A8-8BBD-D2D64FD7E8D8}.Release|x64.ActiveCfg = Release|x64
{B348688B-00FB-45A8-8BBD-D2D64FD7E8D8}.Release|x64.Build.0 = Release|x64
- {692B05A5-DEB5-4B3B-8171-1C126783003B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {692B05A5-DEB5-4B3B-8171-1C126783003B}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {692B05A5-DEB5-4B3B-8171-1C126783003B}.Debug|x64.ActiveCfg = Debug|Any CPU
- {692B05A5-DEB5-4B3B-8171-1C126783003B}.Debug|x64.Build.0 = Debug|Any CPU
+ {692B05A5-DEB5-4B3B-8171-1C126783003B}.Debug|Any CPU.ActiveCfg = Debug|x64
+ {692B05A5-DEB5-4B3B-8171-1C126783003B}.Debug|Any CPU.Build.0 = Debug|x64
+ {692B05A5-DEB5-4B3B-8171-1C126783003B}.Debug|x64.ActiveCfg = Debug|x64
+ {692B05A5-DEB5-4B3B-8171-1C126783003B}.Debug|x64.Build.0 = Debug|x64
{692B05A5-DEB5-4B3B-8171-1C126783003B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{692B05A5-DEB5-4B3B-8171-1C126783003B}.Release|Any CPU.Build.0 = Release|Any CPU
{692B05A5-DEB5-4B3B-8171-1C126783003B}.Release|x64.ActiveCfg = Release|x64
diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs
index f5bcac6..679867d 100644
--- a/Properties/Settings.Designer.cs
+++ b/Properties/Settings.Designer.cs
@@ -12,7 +12,7 @@ namespace PointCloudConverter.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.10.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.13.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
@@ -574,5 +574,89 @@ public bool useGrid {
this["useGrid"] = value;
}
}
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("")]
+ public string lastUsedConfigFolder {
+ get {
+ return ((string)(this["lastUsedConfigFolder"]));
+ }
+ set {
+ this["lastUsedConfigFolder"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("min")]
+ public string offsetMode {
+ get {
+ return ((string)(this["offsetMode"]));
+ }
+ set {
+ this["offsetMode"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("False")]
+ public bool importClassification {
+ get {
+ return ((bool)(this["importClassification"]));
+ }
+ set {
+ this["importClassification"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("False")]
+ public bool useFilter {
+ get {
+ return ((bool)(this["useFilter"]));
+ }
+ set {
+ this["useFilter"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("0.5")]
+ public float filterDistance {
+ get {
+ return ((float)(this["filterDistance"]));
+ }
+ set {
+ this["filterDistance"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("False")]
+ public bool detectIntensityRange {
+ get {
+ return ((bool)(this["detectIntensityRange"]));
+ }
+ set {
+ this["detectIntensityRange"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("False")]
+ public bool useSRGB {
+ get {
+ return ((bool)(this["useSRGB"]));
+ }
+ set {
+ this["useSRGB"] = value;
+ }
+ }
}
}
diff --git a/Properties/Settings.settings b/Properties/Settings.settings
index 64c244a..df5fb1a 100644
--- a/Properties/Settings.settings
+++ b/Properties/Settings.settings
@@ -140,5 +140,26 @@
True
+
+
+
+
+ min
+
+
+ False
+
+
+ False
+
+
+ 0.5
+
+
+ False
+
+
+ False
+
\ No newline at end of file
diff --git a/README.md b/README.md
index 32665a4..72a3ffb 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,8 @@
# PointCloudConverter
-PointCloud converter (commandline and GUI) for [Point Cloud Viewer & Tools (Unity plugin)](https://assetstore.unity.com/packages/tools/utilities/point-cloud-viewer-and-tools-16019?aid=1101lGti)
+This is pointCloud converter (commandline and GUI) for [Point Cloud Viewer & Tools 3 (Unity plugin)](https://assetstore.unity.com/packages/tools/utilities/point-cloud-viewer-and-tools-3-310385?aid=1101lGti)
+
+### Documentation
+- Check [Wiki](https://github.com/unitycoder/PointCloudConverter/wiki)
### Download prebuild exe
- From Releases https://github.com/unitycoder/PointCloudConverter/releases
@@ -7,25 +10,21 @@ PointCloud converter (commandline and GUI) for [Point Cloud Viewer & Tools (
### Arguments
- https://github.com/unitycoder/PointCloudConverter/wiki/Commandline-Arguments
-### Building
-- Open project in VS2019 or later
-- Press F5 to build
-- Executable is created in the /bin/ folder (you can launch it from command prompt, or from Explorer to use GUI)
-
-### Notes
-- See Project/PointCloudConverter Properties.. > Build Events / Post build: Small robocopy script is used to move output files into lib/ folder (so that executable is alone in the root folder)
-
### Import Formats
- LAZ/LAS
+- PLY (ascii/binary) *Initial version
+- E57 *Experimental version
- (more to be added)
### Export Formats
- UCPC (V2) for https://github.com/unitycoder/UnityPointCloudViewer
- PCROOT (V3) for https://github.com/unitycoder/UnityPointCloudViewer
+- GLTF (GLB) output https://las2gltf.kelobyte.fi/ *Paid plugin
+- (more to be added)
### Requirements
-- Windows 10
-- Visual Studio 2017 or later
+- Windows 10 or later
+- Visual Studio 2022 or later
- To view converted Point Clouds inside Unity, this viewer is required: from Unity Asset Store: https://github.com/unitycoder/UnityPointCloudViewer
### Pull Request
@@ -33,8 +32,16 @@ This standalone converter is open-source, so you can create your own Forks and v
Pull requests to improve this converter are welcome! (please create Issue first, so i/users can comment on it)
### Images
-
+
+### Building
+- Open project in VS2019 or later
+- Press F5 to build
+- Executable is created in the /bin/ folder (you can launch it from command prompt, or from Explorer to use GUI)
+### Notes
+- See Project/PointCloudConverter Properties.. > Build Events / Post build: Small robocopy script is used to move output files into lib/ folder (so that executable is alone in the root folder)
+### Powered by
+[](https://jb.gg/OpenSourceSupport)
diff --git a/Readers/E57.cs b/Readers/E57.cs
new file mode 100644
index 0000000..7f61530
--- /dev/null
+++ b/Readers/E57.cs
@@ -0,0 +1,210 @@
+using System;
+using System.IO;
+using System.Collections.Generic;
+using Aardvark.Base;
+using Aardvark.Data.Points.Import;
+using PointCloudConverter.Structs;
+using static Aardvark.Data.Points.Import.E57;
+using Aardvark.Data.Points;
+using System.Text.Json;
+using Aardvark.Data.E57;
+
+namespace PointCloudConverter.Readers
+{
+ public class E57 : IReader, IDisposable
+ {
+ private IEnumerator chunkEnumerator;
+ private E57Chunk currentChunk;
+ private int currentPointIndex = 0;
+
+ private ASTM_E57.E57FileHeader header;
+ private E57MetaData metaData;
+
+ private Float3 lastXYZ;
+
+ public struct E57MetaData
+ {
+ public string Name { get; set; }
+ public double X { get; set; }
+ public double Y { get; set; }
+ public double Z { get; set; }
+ public double RX { get; set; }
+ public double RY { get; set; }
+ public double RZ { get; set; }
+ public double RW { get; set; }
+ }
+
+ public bool InitReader(ImportSettings importSettings, int fileIndex)
+ {
+ try
+ {
+ var filePath = importSettings.inputFiles[fileIndex];
+
+ // Read header metadata
+ using var stream = File.OpenRead(filePath);
+ header = ASTM_E57.E57FileHeader.Parse(stream, new FileInfo(filePath).Length, false);
+ stream.Close();
+
+ var data3D = header.E57Root.Data3D[0];
+ var pose = data3D.Pose;
+
+ metaData = new E57MetaData
+ {
+ Name = data3D.Name
+ };
+
+ if (pose != null)
+ {
+ metaData.X = pose.Translation.X;
+ metaData.Y = importSettings.swapYZ ? pose.Translation.Z : pose.Translation.Y;
+ metaData.Z = importSettings.swapYZ ? pose.Translation.Y : pose.Translation.Z;
+
+ metaData.RX = pose.Rotation.X;
+ metaData.RY = importSettings.swapYZ ? pose.Rotation.Z : pose.Rotation.Y;
+ metaData.RZ = importSettings.swapYZ ? pose.Rotation.Y : pose.Rotation.Z;
+ metaData.RW = pose.Rotation.W;
+ }
+ else
+ {
+ // Optional: assign default values or log warning
+ metaData.X = metaData.Y = metaData.Z = 0;
+ metaData.RX = metaData.RY = metaData.RZ = 0;
+ metaData.RW = 1;
+
+ Console.WriteLine("Warning: E57 scan pose is null.");
+ }
+
+
+ var chunks = ChunksFull(filePath, ParseConfig.Default);
+ chunkEnumerator = chunks.GetEnumerator();
+
+ if (!chunkEnumerator.MoveNext())
+ return false;
+
+ currentChunk = chunkEnumerator.Current;
+ currentPointIndex = 0;
+
+ return true;
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine("E57 InitReader error: " + ex.Message);
+ return false;
+ }
+ }
+
+ public LasHeader GetMetaData(ImportSettings importSettings, int fileIndex)
+ {
+ return new LasHeader
+ {
+ FileName = importSettings.inputFiles[fileIndex],
+ NumberOfPointRecords = (uint)(header?.E57Root?.Data3D?[0]?.Points?.RecordCount ?? 0)
+ };
+ }
+
+ public Bounds GetBounds()
+ {
+ var bounds = header.E57Root.Data3D[0].CartesianBounds.Bounds;
+
+ return new Bounds
+ {
+ minX = (float)bounds.X.Min,
+ maxX = (float)bounds.X.Max,
+ minY = (float)bounds.Y.Min,
+ maxY = (float)bounds.Y.Max,
+ minZ = (float)bounds.Z.Min,
+ maxZ = (float)bounds.Z.Max
+ };
+ }
+
+ public long GetPointCount()
+ {
+ return header?.E57Root?.Data3D?[0]?.Points?.RecordCount ?? 0;
+ }
+
+ public Float3 GetXYZ()
+ {
+ if (currentChunk == null || currentPointIndex >= currentChunk.Count)
+ {
+ if (!chunkEnumerator.MoveNext())
+ return new Float3 { hasError = true };
+
+ currentChunk = chunkEnumerator.Current;
+ currentPointIndex = 0;
+
+ // clear cachedColors when chunk changes
+ cachedColors = null;
+ }
+
+ var p = currentChunk.Positions[currentPointIndex];
+ lastXYZ.x = p.X;
+ lastXYZ.y = p.Y;
+ lastXYZ.z = p.Z;
+ lastXYZ.hasError = false;
+
+ currentPointIndex++;
+ return lastXYZ;
+ }
+
+ private C3b[] cachedColors = null;
+
+ public Color GetRGB()
+ {
+ if (cachedColors == null && currentChunk?.Colors != null)
+ {
+ cachedColors = currentChunk.Colors;
+ }
+
+ int i = currentPointIndex - 1;
+
+ if (cachedColors != null && i >= 0 && i < cachedColors.Length)
+ {
+ var c = cachedColors[i];
+ return new Color
+ {
+ r = c.R / 255f,
+ g = c.G / 255f,
+ b = c.B / 255f
+ };
+ }
+
+ return default;
+ }
+
+ public ushort GetIntensity()
+ {
+ var i = currentPointIndex - 1;
+ if (currentChunk?.Intensities != null && i >= 0 && i < currentChunk.Intensities.Length)
+ {
+ return (byte)currentChunk.Intensities[i];
+ }
+ return 0;
+ }
+
+ public byte GetClassification() => 0;
+
+ public double GetTime()
+ {
+ // Not implemented for now
+ return 0;
+ }
+
+ public void Close() { }
+
+ public void Dispose()
+ {
+ Close();
+ GC.SuppressFinalize(this);
+ }
+
+ ~E57()
+ {
+ Dispose();
+ }
+
+ public string GetMetaDataJSON()
+ {
+ return JsonSerializer.Serialize(metaData);
+ }
+ }
+}
diff --git a/Readers/IReader.cs b/Readers/IReader.cs
index e02a26f..4b26a29 100644
--- a/Readers/IReader.cs
+++ b/Readers/IReader.cs
@@ -8,7 +8,7 @@ public interface IReader
// open filestream
bool InitReader(ImportSettings importSettings, int fileIndex);
// returns total point count, this is required to correctly read all points
- int GetPointCount();
+ long GetPointCount();
// bounds are used for AutoOffset
Bounds GetBounds();
// retrieve single point X,Y,Z coordinates (float)
@@ -18,10 +18,11 @@ public interface IReader
// retrieve single point scan time
double GetTime();
- // close filestream
void Close();
- Color GetIntensity();
+ ushort GetIntensity();
+ byte GetClassification();
LasHeader GetMetaData(ImportSettings importSettings, int fileIndex);
+
void Dispose();
}
}
diff --git a/Readers/LAZ.cs b/Readers/LAZ.cs
index 6ecbe82..8df06c8 100644
--- a/Readers/LAZ.cs
+++ b/Readers/LAZ.cs
@@ -30,6 +30,11 @@ public class LAZ : IReader, IDisposable
//bool importIntensity = false;
bool customIntensityRange = false;
+ byte minClassification = 255;
+ byte maxClassification = 0;
+ ushort minIntensity = 65535;
+ ushort maxIntensity = 0;
+
int? taskID;
// add constructor
@@ -44,25 +49,33 @@ bool IReader.InitReader(ImportSettings importSettings, int fileIndex)
int res = 1;
//try
//{
- //Log.WriteLine("--------------------- initreader: " + fileIndex + " taskID: " + taskID);
- // TODO check errors
- var file = importSettings.inputFiles[fileIndex];
- //importRGB = importSettings.importRGB;
- //importIntensity = importSettings.importIntensity;
- customIntensityRange = importSettings.useCustomIntensityRange;
- res = lazReader.open_reader(file, out compressedLAZ); // 0 = ok, 1 = error
+ //Log.WriteLine("--------------------- initreader: " + fileIndex + " taskID: " + taskID);
+ // TODO check errors
+ var file = importSettings.inputFiles[fileIndex];
+ //importRGB = importSettings.importRGB;
+ //importIntensity = importSettings.importIntensity;
+ customIntensityRange = importSettings.useCustomIntensityRange;
+
+ minClassification = 255;
+ maxClassification = 0;
+ minIntensity = 65535;
+ maxIntensity = 0;
+
+ res = lazReader.open_reader(file, out compressedLAZ); // 0 = ok, 1 = error
//}
//catch (Exception e)
//{
// Log.WriteLine("Error in LAZ.InitReader: " + e.Message);
// throw;
//}
+
return (res == 0);
}
LasHeader IReader.GetMetaData(ImportSettings importSettings, int fileIndex)
{
var h = new LasHeader();
+
h.FileName = importSettings.inputFiles[fileIndex];
h.FileSourceID = lazReader.header.file_source_ID;
h.GlobalEncoding = lazReader.header.global_encoding;
@@ -98,6 +111,18 @@ LasHeader IReader.GetMetaData(ImportSettings importSettings, int fileIndex)
h.MinZ = lazReader.header.min_z;
h.MaxZ = lazReader.header.max_z;
+ if (importSettings.importClassification && importSettings.importMetadataOnly == false)
+ {
+ h.MinClassification = minClassification;
+ h.MaxClassification = maxClassification;
+ }
+
+ if (importSettings.importIntensity && importSettings.importMetadataOnly == false)
+ {
+ h.MinIntensity = minIntensity;
+ h.MaxIntensity = maxIntensity;
+ }
+
if (h.NumberOfVariableLengthRecords > 0)
{
h.VariableLengthRecords = new System.Collections.Generic.List();
@@ -112,7 +137,7 @@ LasHeader IReader.GetMetaData(ImportSettings importSettings, int fileIndex)
vlr.Description = System.Text.Encoding.UTF8.GetString(lazReader.header.vlrs[i].description);
vlr.Description = vlr.Description.Replace("\0", string.Empty);
- //Get WKT (Well Known Text String)
+ // Get WKT (Well Known Text String)
if (vlr.RecordID == 2112)
{
string wkt = Encoding.ASCII.GetString(lazReader.header.vlrs[i].data);
@@ -152,7 +177,6 @@ LasHeader IReader.GetMetaData(ImportSettings importSettings, int fileIndex)
h.ProjectionID = newEntry.Value_Offset;
h.Projection = newEntry.Value_OffsetString;
}
-
gk.KeyEntries.Add(newEntry);
//gk.KeyEntries.Add(new sKeyEntry
@@ -178,9 +202,40 @@ LasHeader IReader.GetMetaData(ImportSettings importSettings, int fileIndex)
h.VariableLengthRecords.Add(vlr);
}
}
+
+ // additional data for LAS 1.3/1.4
+
+ // LAS 1.3 and higher: waveform data packet record pointer.
+ if (h.VersionMajor > 1 || (h.VersionMajor == 1 && h.VersionMinor >= 3))
+ {
+ h.StartOfWaveformDataPacketRecord = lazReader.header.start_of_waveform_data_packet_record;
+ }
+
+ // LAS 1.4 and higher: extended VLRs and extended point record counts.
+ if (h.VersionMajor > 1 || (h.VersionMajor == 1 && h.VersionMinor >= 4))
+ {
+ h.StartOfFirstExtendedVariableLengthRecord = lazReader.header.start_of_first_extended_variable_length_record;
+ h.NumberOfExtendedVariableLengthRecords = lazReader.header.number_of_extended_variable_length_records;
+ h.ExtendedNumberOfPointRecords = lazReader.header.extended_number_of_point_records;
+ h.ExtendedNumberOfPointsByReturn = lazReader.header.extended_number_of_points_by_return;
+ }
+
+ // optional user data in header
+ if (lazReader.header.user_data_in_header_size > 0)
+ {
+ h.UserDataInHeader = lazReader.header.user_data_in_header;
+ }
+
+ // optional user data after header
+ if (lazReader.header.user_data_after_header_size > 0)
+ {
+ h.UserDataAfterHeader = lazReader.header.user_data_after_header;
+ }
+
return h;
}
+
public GeoKeys ParseGeoKeysFromByteArray(byte[] byteArray)
{
GeoKeys geoKeys = new GeoKeys
@@ -292,7 +347,7 @@ Bounds IReader.GetBounds()
return b;
}
- int IReader.GetPointCount()
+ long IReader.GetPointCount()
{
// get gps week offset from header
@@ -301,7 +356,7 @@ int IReader.GetPointCount()
// check alternative point counts
if (count == 0) count = (int)lazReader.header.extended_number_of_point_records;
if (count == 0) count = lazReader.header.number_of_point_records;
- return (int)count;
+ return count;
}
Color IReader.GetRGB()
@@ -310,8 +365,6 @@ Color IReader.GetRGB()
// get point reference
var p = lazReader.point;
- // TODO get timestamp
- //var pointTime = lazReader.point.gps_time;
if (p.rgb[0] > 255 || p.rgb[1] > 255 || p.rgb[2] > 255)
{
@@ -329,26 +382,40 @@ Color IReader.GetRGB()
return c;
}
- Color IReader.GetIntensity()
+ ushort IReader.GetIntensity()
{
- var c = new Color();
+ var p = lazReader.point;
- // get point reference
+ ushort i = p.intensity;
+ //if (customIntensityRange == true) // NOTE now only supports 65535 as custom range
+ //{
+ // i = (byte)(p.intensity / 257f);
+ //}
+ //else
+ //{
+ // i = (byte)(p.intensity);
+ //}
+ // get min and max
+ if (i < minIntensity) minIntensity = i;
+ if (i > maxIntensity) maxIntensity = i;
+
+ return i;
+ }
+
+ byte IReader.GetClassification()
+ {
var p = lazReader.point;
+ // now reads both, we dont know which one is enabled?
+ byte classification = p.classification;
+ byte extended = p.extended_classification;
+ // Choose extended if it's valid and not equal to default "unclassified"
+ byte finalClassification = (extended > 0 && extended != classification) ? extended : classification;
- float i = 0;
- if (customIntensityRange == true) // NOTE now only supports 65535 as custom range
- {
- i = Tools.LUT255[(byte)(p.intensity / 255f)];
- }
- else
- {
- i = Tools.LUT255[(byte)(p.intensity)];
- }
- c.r = i;
- c.g = i;
- c.b = i;
- return c;
+ // get min and max
+ if (finalClassification < minClassification) minClassification = finalClassification;
+ if (finalClassification > maxClassification) maxClassification = finalClassification;
+
+ return finalClassification;
}
Float3 IReader.GetXYZ()
@@ -387,6 +454,16 @@ double IReader.GetTime()
return lazReader.point.gps_time;
}
+ //(byte, byte) IReader.GetClassificationRange()
+ //{
+ // return (minClassification, maxClassification);
+ //}
+
+ //(byte, byte) IReader.GetIntensityRange()
+ //{
+ // return (minIntensity, maxIntensity);
+ //}
+
void IReader.Close()
{
lazReader.close_reader();
diff --git a/Readers/PLY.cs b/Readers/PLY.cs
new file mode 100644
index 0000000..306a28b
--- /dev/null
+++ b/Readers/PLY.cs
@@ -0,0 +1,210 @@
+using PointCloudConverter.Structs;
+using Ply.Net;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using Color = PointCloudConverter.Structs.Color;
+using System.Diagnostics;
+using static Ply.Net.PlyParser;
+using System.Collections.Immutable;
+
+namespace PointCloudConverter.Readers
+{
+ public class PLY : IReader, IDisposable
+ {
+ private PlyParser.Dataset dataset;
+ private int pointIndex;
+ private long pointCount;
+
+ private List vertexChunks;
+ private int currentChunkIndex;
+ private int currentPointInChunk;
+
+ private PropertyData px, py, pz;
+ private PropertyData pr, pg, pb;
+
+ //private PlyParser.PropertyData pintensity, pclass, ptime;
+
+ private Float3 currentPoint;
+ private Color currentColor;
+ // private double currentTime;
+ // private byte currentIntensity;
+ // private byte currentClassification;
+ private Bounds bounds;
+
+
+ //int? taskID;
+ //// add constructor
+ //public PLY(int? _taskID)
+ //{
+ // taskID = _taskID;
+ //}
+
+ public bool InitReader(ImportSettings importSettings, int fileIndex)
+ {
+ var file = importSettings.inputFiles[fileIndex];
+
+ using var stream = File.OpenRead(file);
+ dataset = PlyParser.Parse(stream, 4096);
+
+ vertexChunks = dataset.Data
+ .Where(d => d.Element.Type == ElementType.Vertex)
+ .ToList();
+
+ if (vertexChunks.Count == 0) return false;
+
+ pointCount = vertexChunks.Sum(chunk => ((Array)chunk.Data[0].Data).Length);
+ currentChunkIndex = 0;
+ currentPointInChunk = 0;
+
+ SetCurrentChunkProperties(); // helper method to cache px, py, pz, etc.
+
+ CalculateBounds();
+
+ return true;
+
+ }
+
+ public long GetPointCount() => pointCount;
+
+ public Bounds GetBounds() => bounds;
+
+ public Float3 GetXYZ()
+ {
+ if (currentChunkIndex >= vertexChunks.Count)
+ return new Float3 { hasError = true };
+
+ int chunkSize = ((Array)px.Data).Length;
+ if (currentPointInChunk >= chunkSize)
+ {
+ currentChunkIndex++;
+ if (currentChunkIndex >= vertexChunks.Count)
+ return new Float3 { hasError = true };
+
+ currentPointInChunk = 0;
+ SetCurrentChunkProperties();
+ }
+
+ currentPoint = new Float3
+ {
+ x = Convert.ToSingle(px.Data.GetValue(currentPointInChunk)),
+ y = Convert.ToSingle(py.Data.GetValue(currentPointInChunk)),
+ z = Convert.ToSingle(pz.Data.GetValue(currentPointInChunk)),
+ hasError = false
+ };
+
+ currentColor = new Color
+ {
+ r = Convert.ToSingle(Convert.ToByte(pr.Data.GetValue(currentPointInChunk))) / 255f,
+ g = Convert.ToSingle(Convert.ToByte(pg.Data.GetValue(currentPointInChunk))) / 255f,
+ b = Convert.ToSingle(Convert.ToByte(pb.Data.GetValue(currentPointInChunk))) / 255f
+ };
+
+ currentPointInChunk++;
+ return currentPoint;
+ }
+
+
+ public Color GetRGB()
+ {
+ //currentColor = new Color();
+ //currentColor.r = 255;
+ //currentColor.g = 0;
+ //currentColor.b = 0;
+ return currentColor;
+ }
+
+ public double GetTime()
+ {
+ return 0.0;
+ }
+
+ public byte GetIntensity()
+ {
+ return 0;
+ }
+
+ public byte GetClassification()
+ {
+ return 0;
+ }
+
+ // TODO return ply data
+ public LasHeader GetMetaData(ImportSettings importSettings, int fileIndex)
+ {
+ return new LasHeader
+ {
+ FileName = importSettings.inputFiles[fileIndex],
+ NumberOfPointRecords = (uint)pointCount,
+ MinX = bounds.minX,
+ MaxX = bounds.maxX,
+ MinY = bounds.minY,
+ MaxY = bounds.maxY,
+ MinZ = bounds.minZ,
+ MaxZ = bounds.maxZ
+ };
+ }
+
+ public void Close()
+ {
+ dataset = null;
+ }
+
+ public void Dispose() => Close();
+
+ private void CalculateBounds()
+ {
+ bounds = new Bounds
+ {
+ minX = float.MaxValue,
+ maxX = float.MinValue,
+ minY = float.MaxValue,
+ maxY = float.MinValue,
+ minZ = float.MaxValue,
+ maxZ = float.MinValue
+ };
+
+ foreach (var chunk in vertexChunks)
+ {
+ var cx = chunk["x"]!;
+ var cy = chunk["y"]!;
+ var cz = chunk["z"]!;
+ int count = ((Array)cx.Data).Length;
+
+ for (int i = 0; i < count; i++)
+ {
+ float x = Convert.ToSingle(cx.Data.GetValue(i));
+ float y = Convert.ToSingle(cy.Data.GetValue(i));
+ float z = Convert.ToSingle(cz.Data.GetValue(i));
+
+ bounds.minX = Math.Min(bounds.minX, x);
+ bounds.maxX = Math.Max(bounds.maxX, x);
+ bounds.minY = Math.Min(bounds.minY, y);
+ bounds.maxY = Math.Max(bounds.maxY, y);
+ bounds.minZ = Math.Min(bounds.minZ, z);
+ bounds.maxZ = Math.Max(bounds.maxZ, z);
+ }
+ }
+ }
+
+
+ ushort IReader.GetIntensity()
+ {
+ return GetIntensity();
+ }
+
+ private void SetCurrentChunkProperties()
+ {
+ var chunk = vertexChunks[currentChunkIndex];
+ px = chunk["x"] ?? throw new Exception("Missing 'x' property");
+ py = chunk["y"] ?? throw new Exception("Missing 'y' property");
+ pz = chunk["z"] ?? throw new Exception("Missing 'z' property");
+ pr = chunk["red"] ?? throw new Exception("Missing 'red' property");
+ pg = chunk["green"] ?? throw new Exception("Missing 'green' property");
+ pb = chunk["blue"] ?? throw new Exception("Missing 'blue' property");
+ }
+
+
+ }
+}
diff --git a/Structs/ImportFormat.cs b/Structs/ImportFormat.cs
index 3553e19..27d37a8 100644
--- a/Structs/ImportFormat.cs
+++ b/Structs/ImportFormat.cs
@@ -3,6 +3,8 @@
public enum ImportFormat
{
Unknown,
- LAS // and LAZ
+ LAS, // and LAZ
+ PLY,
+ E57
}
}
diff --git a/Structs/ImportSettings.cs b/Structs/ImportSettings.cs
index 9b5a0bb..87258c9 100644
--- a/Structs/ImportSettings.cs
+++ b/Structs/ImportSettings.cs
@@ -15,16 +15,22 @@ namespace PointCloudConverter
{
public class ImportSettings
{
- // filled in by program (so that json serializer is easier)
- public string version { get; set; } = "0.0.0";
+ // filled in by program (so that json serializer is easier), not used
+ //public string version { get; set; } = "0.0.0";
[JsonConverter(typeof(JsonStringEnumConverter))]
public Logger.LogEvent @event { get; set; }
-
- public IReader reader = new LAZ(null); // single threaded reader
+
+ [JsonIgnore] // FIXME doesnt ígnore it
+ public IReader reader; // single threaded reader
//public Dictionary Readers { get; set; } = new Dictionary();
public ConcurrentDictionary Readers { get; set; } = new ConcurrentDictionary();
+ [JsonIgnore]
public IWriter writer = new UCPC();
+
+ public string ReaderType => reader?.GetType().Name;
+ public string WriterType => writer?.GetType().Name;
+
//public Dictionary Writers { get; set; } = new Dictionary();
//public ConcurrentDictionary> Writers { get; set; } = new ConcurrentDictionary>();
private readonly ConcurrentBag _writerPool = new ConcurrentBag();
@@ -48,9 +54,29 @@ public void InitWriterPool(int maxThreads, ExportFormat export)
// Method to get or create a reader for a specific task ID
public IReader GetOrCreateReader(int? taskId)
{
+ //Log.Write(">>>>> Getting or creating reader for task ID: " + taskId+" format: "+importFormat);
+
if (!Readers.ContainsKey(taskId))
{
- Readers[taskId] = new LAZ(taskId);
+ IReader readerInstance;
+
+ switch (importFormat)
+ {
+ case ImportFormat.LAS:
+ readerInstance = new LAZ(taskId);
+ break;
+ case ImportFormat.PLY:
+ readerInstance = new PLY(); // no taskId needed here
+ break;
+ case ImportFormat.E57:
+ readerInstance = new E57();
+ break;
+ default:
+ Log.Write($"Unsupported import format: {importFormat}", LogEvent.Error);
+ throw new NotSupportedException($"Unsupported import format: {importFormat}");
+ }
+
+ Readers[taskId] = readerInstance;
}
//Log.Write(">>>>> Total Readers in dictionary: " + Readers.Count);
@@ -161,7 +187,7 @@ public void ReleaseReader(int? taskId)
public float scale { get; set; } = 1f;
[JsonConverter(typeof(JsonStringEnumConverter))]
- public ImportFormat importFormat { get; set; } = ImportFormat.LAS; //default to las for now
+ public ImportFormat importFormat { get; set; } = ImportFormat.Unknown; //default to las for now
[JsonConverter(typeof(JsonStringEnumConverter))]
public ExportFormat exportFormat { get; set; }
@@ -173,8 +199,9 @@ public void ReleaseReader(int? taskId)
// FIXME default values will be used unless otherwise specified.. randomize = true
// TODO these should be export settings..
- public bool importRGB { get; set; } = true; // this or intensity must be on
+ public bool importRGB { get; set; } = true;
public bool importIntensity { get; set; } = false;
+ public bool importClassification { get; set; } = false;
public bool useAutoOffset { get; set; } = true;
public bool swapYZ { get; set; } = true;
public bool invertX { get; set; } = false;
@@ -200,15 +227,20 @@ public void ReleaseReader(int? taskId)
public float manualOffsetY { get; set; } = 0;
public float manualOffsetZ { get; set; } = 0;
public bool useCustomIntensityRange { get; set; } = false; // if false, 0-255 range is used, if ture: 0-65535
+ public bool detectIntensityRange { get; set; } = false; // if true, reads some points from file to detect min/max intensity range 0-255 or 0-65535
public int seed { get; set; } = -1; // random seed for shuffling
public int maxThreads { get; set; }
- public bool useJSONLog = false;
- public bool importMetadata = false;
- public bool importMetadataOnly = false;
- public bool averageTimestamp = false; // calculate average timestamp for all points for this tile
- public bool checkoverlap = false; // check if tile overlaps with other tiles (save into pcroot)
- public bool useGrid = true; // required for PCROOT format
+ public bool useJSONLog { get; set; } = false;
+ public bool importMetadata { get; set; } = false;
+ public bool importMetadataOnly { get; set; } = false;
+ public bool averageTimestamp { get; set; } = false; // calculate average timestamp for all points for this tile
+ public bool checkoverlap { get; set; } = false; // check if tile overlaps with other tiles (save into pcroot)
+ public bool useGrid { get; set; } = false; // required for PCROOT format (will be automatically enabled for v3)
+ public string offsetMode { get; set; } = "min"; // TODO use enum: "min" or "legacy" now (legacy is first bounds min only)
+ public bool useFilter { get; set; } = false; // filter by distance
+ public float filterDistance { get; set; } = 0.5f;
+ public bool sRGB { get; set; } = false; // use sRGB color space for RGB values
public override string ToString()
{
@@ -222,6 +254,7 @@ public override string ToString()
t += "\n invertZ=" + invertZ;
t += "\n readRGB=" + importRGB;
t += "\n readIntensity=" + importIntensity;
+ t += "\n readClassification=" + importClassification;
//t += "\n metaData=" + importIntensity;
t += "\n useAutoOffset=" + useAutoOffset;
t += "\n offsetX=" + offsetX;
@@ -251,6 +284,14 @@ public override string ToString()
t += "\n importMetadataOnly=" + importMetadataOnly;
t += "\n averageTimestamp=" + averageTimestamp;
t += "\n checkoverlap=" + checkoverlap;
+ t += "\n useGrid=" + useGrid;
+ t += "\n offsetMode=" + offsetMode;
+ t += "\n useFilter=" + useFilter;
+ t += "\n filterDistance=" + filterDistance;
+ t += "\n sRGB=" + sRGB;
+ t += "\n importFormat=" + importFormat;
+ t += "\n exportFormat=" + exportFormat;
+ t += "\n maxThreads=" + maxThreads;
return t;
}
diff --git a/Structs/Metadata/Job.cs b/Structs/Metadata/Job.cs
new file mode 100644
index 0000000..9e3234f
--- /dev/null
+++ b/Structs/Metadata/Job.cs
@@ -0,0 +1,20 @@
+using System.Text.Json.Serialization;
+
+namespace PointCloudConverter.Structs.Metadata
+{
+ public class Job
+ {
+ public string ConverterVersion { get; set; }
+ public ImportSettings ImportSettings { get; set; }
+ public DateTime StartTime { get; set; }
+ public DateTime EndTime { get; set; }
+ public TimeSpan Elapsed { get; internal set; }
+ }
+
+ public class JobMetadata
+ {
+ [JsonPropertyOrder(0)]
+ public Job Job { get; set; }
+ public List lasHeaders { get; set; } = new List();
+ }
+}
diff --git a/Structs/Metadata/LasHeader.cs b/Structs/Metadata/LasHeader.cs
index 40051b3..6094196 100644
--- a/Structs/Metadata/LasHeader.cs
+++ b/Structs/Metadata/LasHeader.cs
@@ -43,6 +43,19 @@ public class LasHeader
public double MinY { get; set; }
public double MaxZ { get; set; }
public double MinZ { get; set; }
+
+ public byte MinClassification { get; set; }
+ public byte MaxClassification { get; set; }
+ public ushort MinIntensity { get; set; }
+ public ushort MaxIntensity { get; set; }
+
public List VariableLengthRecords { get; set; }
+ public ulong StartOfWaveformDataPacketRecord { get; internal set; }
+ public ulong StartOfFirstExtendedVariableLengthRecord { get; internal set; }
+ public uint NumberOfExtendedVariableLengthRecords { get; internal set; }
+ public ulong ExtendedNumberOfPointRecords { get; internal set; }
+ public ulong[] ExtendedNumberOfPointsByReturn { get; internal set; }
+ public byte[] UserDataInHeader { get; internal set; }
+ public byte[] UserDataAfterHeader { get; internal set; }
}
}
diff --git a/Tools/ArgParser.cs b/Tools/ArgParser.cs
index 1b1d010..b519961 100644
--- a/Tools/ArgParser.cs
+++ b/Tools/ArgParser.cs
@@ -152,18 +152,33 @@ public static ImportSettings Parse(string[] args, string rootFolder, ILogger log
string importFormatParsed = param.ToUpper();
- // TODO check what reader interfaces are available
- if (string.IsNullOrEmpty(importFormatParsed) == true || (importFormatParsed != "LAS" && importFormatParsed != "LAZ"))
+ if (string.IsNullOrEmpty(importFormatParsed) ||
+ (importFormatParsed != "LAS" && importFormatParsed != "LAZ" && importFormatParsed != "PLY") && importFormatParsed != "E57")
{
importSettings.errors.Add("Unsupported import format: " + param);
importSettings.importFormat = ImportFormat.Unknown;
}
else
{
- importSettings.importFormat = ImportFormat.LAS;
- importSettings.reader = new LAZ(null);
+ switch (importFormatParsed)
+ {
+ case "LAS":
+ case "LAZ":
+ importSettings.importFormat = ImportFormat.LAS;
+ importSettings.reader = new LAZ(null);
+ break;
+ case "PLY":
+ importSettings.importFormat = ImportFormat.PLY;
+ importSettings.reader = new PLY();
+ break;
+ case "E57":
+ importSettings.importFormat = ImportFormat.E57;
+ importSettings.reader = new E57();
+ break;
+ }
}
break;
+
case "-exportformat":
Log.Write("exportformat = " + param);
@@ -216,6 +231,15 @@ public static ImportSettings Parse(string[] args, string rootFolder, ILogger log
case "-input":
Log.Write("input = " + param);
+ if (string.IsNullOrEmpty(param.Trim()))
+ {
+ importSettings.errors.Add("Input file not defined: " + param);
+ break;
+ }
+
+ // remove quotes (needed for paths with spaces)
+ param = param.Trim('"');
+
// if relative folder, FIXME this fails on -input="C:\asdf\etryj\folder\" -importformat=las because backslash in \", apparently this https://stackoverflow.com/a/9288040/5452781
if (Path.IsPathRooted(param) == false)
{
@@ -231,18 +255,30 @@ public static ImportSettings Parse(string[] args, string rootFolder, ILogger log
// TODO get file extension from commandline param? but then need to set -format before input.. for now only LAS/LAZ
// TODO parse/sort args in required order, not in given order
- var filePaths = Directory.GetFiles(param).Where(file => Regex.IsMatch(file, @"^.+\.(las|laz)$", RegexOptions.IgnoreCase)).ToArray();
-
- for (int j = 0; j < filePaths.Length; j++)
+ if (importSettings.importFormat == ImportFormat.Unknown)
{
- Console.ForegroundColor = ConsoleColor.Gray;
- Log.Write("Found file: " + filePaths[j]);
- Console.ForegroundColor = ConsoleColor.White;
- importSettings.inputFiles.Add(filePaths[j]);
+ importSettings.errors.Add("Import format not defined before -input folder for batch (use -importformat" + argValueSeparator + "LAS or PLY or E57)");
}
+ else
+ {
+ string importExtensions = "";
+ if (importSettings.importFormat == ImportFormat.LAS) importExtensions = "las|laz";
+ if (importSettings.importFormat == ImportFormat.PLY) importExtensions = "ply";
+ if (importSettings.importFormat == ImportFormat.E57) importExtensions = "e57";
+ var filePaths = Directory.GetFiles(param).Where(file => Regex.IsMatch(file, @"^.+\.(" + importExtensions + ")$", RegexOptions.IgnoreCase)).ToArray();
+ for (int j = 0; j < filePaths.Length; j++)
+ {
+ Console.ForegroundColor = ConsoleColor.Gray;
+ Log.Write("Found file: " + filePaths[j]);
+ Console.ForegroundColor = ConsoleColor.White;
+ importSettings.inputFiles.Add(filePaths[j]);
+ }
+
+ }
importSettings.batch = true;
+
}
else // single file
{
@@ -266,6 +302,14 @@ public static ImportSettings Parse(string[] args, string rootFolder, ILogger log
case "-output":
Log.Write("output = " + param);
+ if (string.IsNullOrEmpty(param.Trim()))
+ {
+ importSettings.errors.Add("Output not defined: " + param);
+ break;
+ }
+
+ param = param.Trim('"');
+
// check if relative or not
if (Path.IsPathRooted(param) == false)
{
@@ -393,6 +437,19 @@ public static ImportSettings Parse(string[] args, string rootFolder, ILogger log
}
break;
+ case "-detectintensityrange":
+ Log.Write("detectintensityrange = " + param);
+
+ if (param != "true" && param != "false")
+ {
+ importSettings.errors.Add("Invalid detectintensityrange parameter: " + param);
+ }
+ else
+ {
+ importSettings.detectIntensityRange = param == "true";
+ }
+ break;
+
case "-invertx":
Log.Write("invertx = " + param);
@@ -595,16 +652,15 @@ public static ImportSettings Parse(string[] args, string rootFolder, ILogger log
case "-offset":
Log.Write("offset = " + param);
- // check if its true or false
+ // check if its true or false (for automatic offset)
if (param != "false" && param != "true")
{
- // check if its valid integer x,z
+ // check if have x,y,z values, NOTE should be in this format: -offset=10.5,-123,0
if (param.IndexOf(',') > -1)
{
var temp = param.Split(',');
if (temp.Length == 3)
{
-
float xOff, yOff, zOff;
if (float.TryParse(temp[0].Trim(), out xOff) && float.TryParse(temp[1].Trim(), out yOff) && float.TryParse(temp[2].Trim(), out zOff))
{
@@ -626,7 +682,7 @@ public static ImportSettings Parse(string[] args, string rootFolder, ILogger log
}
else
{
- importSettings.errors.Add("Invalid offset parameter: " + param);
+ importSettings.errors.Add("Invalid offset parameter (Use: min or legacy): " + param);
}
}
else // autooffset
@@ -729,6 +785,61 @@ public static ImportSettings Parse(string[] args, string rootFolder, ILogger log
}
break;
+ case "-classification":
+ Log.Write("classification = " + param);
+
+ if (param != "false" && param != "true")
+ {
+ importSettings.errors.Add("Invalid classification parameter: " + param);
+ }
+ else
+ {
+ importSettings.importClassification = (param == "true");
+ }
+ break;
+
+ case "-srgb":
+ Log.Write("srgb = " + param);
+
+ if (param != "false" && param != "true")
+ {
+ importSettings.errors.Add("Invalid srgb parameter: " + param);
+ }
+ else
+ {
+ importSettings.sRGB = (param == "true");
+ }
+ break;
+
+ case "-offsetmode":
+ Log.Write("offsetmode = " + param);
+
+ if (param != "legacy" && param != "min")
+ {
+ importSettings.errors.Add("Invalid offset parameter: (Use: min or legacy)" + param);
+ }
+ else
+ {
+ importSettings.offsetMode = param;
+ }
+ break;
+
+ case "-filter":
+ Log.Write("filter = " + param);
+
+ bool filterDistValue = float.TryParse(param, out tempFloat);
+ if (filterDistValue == false || tempFloat <= 0f)
+
+ {
+ importSettings.errors.Add("Invalid filter value (must be greater than 0) : " + param);
+ }
+ else
+ {
+ importSettings.useFilter = true;
+ importSettings.filterDistance = tempFloat;
+ }
+ break;
+
// TODO load whole commandline args list from text file
case "-config":
Log.Write("config = " + param);
@@ -768,6 +879,9 @@ public static ImportSettings Parse(string[] args, string rootFolder, ILogger log
Tools.PrintHelpAndExit(argValueSeparator, waitEnter: true);
}
+
+ // *** VALIDATE SETTINGS ***
+
// check that we had input
if (importSettings.inputFiles.Count == 0 || string.IsNullOrEmpty(importSettings.inputFiles[0]) == true)
{
@@ -810,9 +924,9 @@ public static ImportSettings Parse(string[] args, string rootFolder, ILogger log
{
importSettings.errors.Add("(E) PCROOT Requires some output filename (example: output.pcroot)");
}
- if (importSettings.exportFormat == ExportFormat.External)
+ if (importSettings.exportFormat == ExportFormat.External && importSettings.batch == false)
{
- importSettings.errors.Add("(E2) External formats require some output filename (example: basefilename)");
+ importSettings.errors.Add("(E2) External formats require some output filename for non-batch operations (example: basefilename)");
}
}
}
@@ -837,12 +951,45 @@ public static ImportSettings Parse(string[] args, string rootFolder, ILogger log
}
} // have input
+
// check required settings
if (importSettings.exportFormat == ExportFormat.Unknown)
{
importSettings.errors.Add("No export format defined (Example: -exportformat" + argValueSeparator + "PCROOT)");
}
+ // check that files are in correct format
+ if (importSettings.inputFiles != null && importSettings.inputFiles.Count > 0)
+ {
+ var currentExtension = importSettings.importFormat.ToString().ToLower();
+ bool wrongExtension = false;
+
+ for (int i = 0; i < importSettings.inputFiles.Count; i++)
+ {
+ var ext = Path.GetExtension(importSettings.inputFiles[i]).ToLower();
+
+ if (currentExtension == "las")
+ {
+ if (ext != ".las" && ext != ".laz")
+ {
+ wrongExtension = true;
+ break;
+ }
+ }
+ else if (currentExtension == "ply")
+ {
+ if (ext != ".ply")
+ {
+ wrongExtension = true;
+ break;
+ }
+ }
+ }
+
+ if (wrongExtension) importSettings.errors.Add("Input files are not in the selected format (" + importSettings.importFormat + ")");
+ }
+
+
// cannot have both rgb & intensity
//if (importSettings.importRGB == true && importSettings.importIntensity == true)
//{
@@ -850,9 +997,15 @@ public static ImportSettings Parse(string[] args, string rootFolder, ILogger log
//}
// must have at least one
- if (importSettings.importRGB == false && importSettings.importIntensity == false)
+ if (importSettings.importRGB == false && importSettings.importIntensity == false && importSettings.importClassification == false)
+ {
+ importSettings.errors.Add("Must have -rgb OR -intensity OR -classification enabled");
+ }
+
+ // but cannot have int and class only
+ if (importSettings.importRGB == false && importSettings.importIntensity == true && importSettings.importClassification == true)
{
- importSettings.errors.Add("Must have -rgb OR -intensity enabled");
+ importSettings.errors.Add("Cannot have -intensity and -classification enabled without -rgb");
}
if (importSettings.exportFormat == ExportFormat.UCPC && importSettings.maxThreads > 1)
@@ -868,7 +1021,12 @@ public static ImportSettings Parse(string[] args, string rootFolder, ILogger log
if (importSettings.batch == true && importSettings.exportFormat == ExportFormat.UCPC && Path.GetExtension(importSettings.outputFile).ToLower() == ".ucpc")
{
- importSettings.errors.Add("With UCPC batching, do not set output filename - set ONLY output folder (each ucpc file will be saved separately)");
+ importSettings.errors.Add("With batch processing whole input folder, do not set output filename - Set output folder (each .UCPP file will be saved separately)");
+ }
+
+ if (importSettings.batch == true && importSettings.exportFormat == ExportFormat.External && Path.GetExtension(importSettings.outputFile).ToLower() == ".glb")
+ {
+ importSettings.errors.Add("With batch processing whole input folder, do not set output filename - Set output folder (each .GLB file will be saved separately)");
}
if (importSettings.skipPoints == true && importSettings.keepPoints == true)
@@ -883,13 +1041,23 @@ public static ImportSettings Parse(string[] args, string rootFolder, ILogger log
Log.Write("No import format defined, using Default: " + importSettings.importFormat.ToString());
}
+ if (importSettings.importFormat == ImportFormat.PLY)
+ {
+ if (importSettings.importIntensity || importSettings.importClassification) Log.Write("PLY doesnt support intensity or classification importing.");
+ if (importSettings.packColors) Log.Write("PLY doesnt support color packing.");
+ }
+
if (importSettings.exportFormat == ExportFormat.PCROOT && importSettings.useGrid == false)
{
//importSettings.errors.Add("V3 pcroot export format requires -usegrid=true to use grid");
- Log.Write("V3 pcroot export format requires -usegrid=true to use grid, enabling it..");
+ Log.Write("V3 pcroot export format requires -usegrid=true to use grid, enabling it now.");
importSettings.useGrid = true;
}
+ if (importSettings.useCustomIntensityRange == true && importSettings.detectIntensityRange == true)
+ {
+ importSettings.errors.Add("Cannot use -customintensityrange and -detectintensityrange at the same time");
+ }
// disable this error, if user really wants to use it
//if (importSettings.randomize == false && importSettings.exportFormat == ExportFormat.PCROOT)
diff --git a/Tools/PluginLoader.cs b/Tools/PluginLoader.cs
index 1cdf17a..3d7cb00 100644
--- a/Tools/PluginLoader.cs
+++ b/Tools/PluginLoader.cs
@@ -13,24 +13,31 @@ namespace PointCloudConverter.Plugins
{
public static class PluginLoader
{
- static readonly string pluginDirectory = Path.Combine(Directory.GetCurrentDirectory(), "Plugins");
+ // Resolve plugin folder relative to the .exe location instead of current working directory
+ static readonly string pluginDirectory = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Plugins");
// TODO add logger, if needed
- //static ILogger Log;
+ // static ILogger Log;
public static IWriter LoadWriter(string pluginName)
{
- //Log = logger;
+ // Log = logger;
+ // Build the full path to the plugin DLL
string pluginPath = Path.Combine(pluginDirectory, pluginName + ".dll");
- //Log.Write($"Loading plugin at {pluginPath}");
- if (File.Exists(pluginPath) == false) throw new FileNotFoundException($"The plugin at {pluginPath} could not be found.");
- // Load the plugin assembly
+ // Log.Write($"Loading plugin at {pluginPath}");
+
+ // Check if the plugin DLL exists
+ if (File.Exists(pluginPath) == false)
+ throw new FileNotFoundException($"The plugin at {pluginPath} could not be found.");
+
+ // Load the plugin assembly from the DLL
var pluginAssembly = Assembly.LoadFrom(pluginPath);
- // Find the specific type 'PointCloudConverter.Writers.GLTF'
- var writerType = pluginAssembly.GetType("PointCloudConverter.Writers.GLTF");
+ // Find the specific type 'PointCloudConverter.Writers.'
+ // This assumes the type name inside the DLL matches the filename
+ var writerType = pluginAssembly.GetType("PointCloudConverter.Writers." + pluginName);
if (writerType == null)
throw new InvalidOperationException($"No valid implementation of IWriter found in {pluginPath}");
diff --git a/Tools/Tools.cs b/Tools/Tools.cs
index e7f04b9..4151a64 100644
--- a/Tools/Tools.cs
+++ b/Tools/Tools.cs
@@ -1,5 +1,6 @@
using PointCloudConverter.Structs;
using SharpNeatLib.Maths;
+using System.Collections;
using System.Globalization;
using System.IO;
using System.Numerics;
@@ -139,87 +140,226 @@ public static Vector2 SuperUnpacker(float f, float GridSizeAndPackMagic)
// return (ax * bx + ay * by + az * bz);
//}
- public static void Shuffle(ref List array1, ref List array2, ref List array3, ref List arrayR, ref List arrayG, ref List arrayB)
- {
- int index = array1.Count;
- while (index > 1)
- {
- //int rand = rnd.Next(index--);
- int rand = frnd.Next(0, index--);
+ //public static void ShuffleInPlace(params IList[] arrays)
+ //{
+ // //ResetRandom();
+ // // Assume all lists are the same length
+ // if (arrays.Length == 0 || arrays[0] == null)
+ // return;
- // Swap using tuple assignment
- (array1[index], array1[rand]) = (array1[rand], array1[index]);
- (array2[index], array2[rand]) = (array2[rand], array2[index]);
- (array3[index], array3[rand]) = (array3[rand], array3[index]);
- (arrayR[index], arrayR[rand]) = (arrayR[rand], arrayR[index]);
- (arrayG[index], arrayG[rand]) = (arrayG[rand], arrayG[index]);
- (arrayB[index], arrayB[rand]) = (arrayB[rand], arrayB[index]);
- }
- }
+ // int count = arrays[0].Count;
- public static void Shuffle(ref List array1, ref List array2, ref List array3, ref List arrayR, ref List arrayG, ref List arrayB, ref List arrayIntensity)
- {
- int index = array1.Count;
- while (index > 1)
- {
- //int rand = rnd.Next(index--);
- int rand = frnd.Next(0, index--);
-
-
- // Swap using tuple assignment
- (array1[index], array1[rand]) = (array1[rand], array1[index]);
- (array2[index], array2[rand]) = (array2[rand], array2[index]);
- (array3[index], array3[rand]) = (array3[rand], array3[index]);
- (arrayR[index], arrayR[rand]) = (arrayR[rand], arrayR[index]);
- (arrayG[index], arrayG[rand]) = (arrayG[rand], arrayG[index]);
- (arrayB[index], arrayB[rand]) = (arrayB[rand], arrayB[index]);
- (arrayIntensity[index], arrayIntensity[rand]) = (arrayIntensity[rand], arrayIntensity[index]);
- }
- }
+ // for (int i = count - 1; i > 0; i--)
+ // {
+ // int rand = frnd.Next(0, i + 1);
- public static void Shuffle(ref List array1, ref List array2, ref List array3, ref List arrayR, ref List arrayG, ref List arrayB, ref List arrayIntensity, ref List arrayTime)
+ // foreach (var list in arrays)
+ // {
+ // if (list == null || list.Count <= i || list.Count <= rand)
+ // continue;
+
+ // object temp = list[i];
+ // list[i] = list[rand];
+ // list[rand] = temp;
+ // }
+ // }
+ //}
+
+ private static readonly ThreadLocal threadRand = new(() => new Random());
+
+ public static void ShufflePointAttributes(int count,
+ List x, List y, List z,
+ List? r = null, List? g = null, List? b = null,
+ List? intensity = null,
+ List? classification = null,
+ List? time = null)
{
- int index = array1.Count;
- while (index > 1)
+ var rand = threadRand.Value!;
+ for (int i = count - 1; i > 0; i--)
{
- //int rand = rnd.Next(index--);
- int rand = frnd.Next(0, index--);
-
- // Swap using tuple assignment
- (array1[index], array1[rand]) = (array1[rand], array1[index]);
- (array2[index], array2[rand]) = (array2[rand], array2[index]);
- (array3[index], array3[rand]) = (array3[rand], array3[index]);
- (arrayR[index], arrayR[rand]) = (arrayR[rand], arrayR[index]);
- (arrayG[index], arrayG[rand]) = (arrayG[rand], arrayG[index]);
- (arrayB[index], arrayB[rand]) = (arrayB[rand], arrayB[index]);
- (arrayIntensity[index], arrayIntensity[rand]) = (arrayIntensity[rand], arrayIntensity[index]);
-
- // Handle double separately since it's a different type
- (arrayTime[index], arrayTime[rand]) = (arrayTime[rand], arrayTime[index]);
- }
- }
+ int j = rand.Next(i + 1);
- public static void Shuffle(ref List array1, ref List array2, ref List array3, ref List arrayR, ref List arrayG, ref List arrayB, ref List arrayTime)
- {
- int index = array1.Count;
+ // Swap X/Y/Z
+ (x[i], x[j]) = (x[j], x[i]);
+ (y[i], y[j]) = (y[j], y[i]);
+ (z[i], z[j]) = (z[j], z[i]);
- while (index > 1)
- {
- //int rand = rnd.Next(index--);
- int rand = frnd.Next(0, index--);
-
- // Swapping using tuples
- (array1[index], array1[rand]) = (array1[rand], array1[index]);
- (array2[index], array2[rand]) = (array2[rand], array2[index]);
- (array3[index], array3[rand]) = (array3[rand], array3[index]);
- (arrayR[index], arrayR[rand]) = (arrayR[rand], arrayR[index]);
- (arrayG[index], arrayG[rand]) = (arrayG[rand], arrayG[index]);
- (arrayB[index], arrayB[rand]) = (arrayB[rand], arrayB[index]);
- (arrayTime[index], arrayTime[rand]) = (arrayTime[rand], arrayTime[index]);
+ // RGB
+ if (r != null) (r[i], r[j]) = (r[j], r[i]);
+ if (g != null) (g[i], g[j]) = (g[j], g[i]);
+ if (b != null) (b[i], b[j]) = (b[j], b[i]);
+
+ // Intensity
+ if (intensity != null) (intensity[i], intensity[j]) = (intensity[j], intensity[i]);
+
+ // Classification
+ if (classification != null) (classification[i], classification[j]) = (classification[j], classification[i]);
+
+ // Time
+ if (time != null) (time[i], time[j]) = (time[j], time[i]);
}
}
+
+ //public static void Shuffle(ref List array)
+ //{
+ // ResetRandom();
+ // int index = array.Count;
+ // while (index > 1)
+ // {
+ // int rand = frnd.Next(0, index--);
+ // (array[index], array[rand]) = (array[rand], array[index]);
+ // }
+ //}
+
+ //public static void Shuffle(ref List array)
+ //{
+ // ResetRandom();
+ // int index = array.Count;
+ // while (index > 1)
+ // {
+ // int rand = frnd.Next(0, index--);
+ // (array[index], array[rand]) = (array[rand], array[index]);
+ // }
+ //}
+
+ //public static void Shuffle(ref List array)
+ //{
+ // ResetRandom();
+ // int index = array.Count;
+ // while (index > 1)
+ // {
+ // int rand = frnd.Next(0, index--);
+ // (array[index], array[rand]) = (array[rand], array[index]);
+ // }
+ //}
+
+
+
+ //// x,y,z,r,g,b
+ //public static void Shuffle(ref List x, ref List y, ref List z, ref List r, ref List g, ref List b)
+ //{
+ // int index = x.Count;
+ // while (index > 1)
+ // {
+ // //int rand = rnd.Next(index--);
+ // int rand = frnd.Next(0, index--);
+
+ // // Swap using tuple assignment
+ // (x[index], x[rand]) = (x[rand], x[index]);
+ // (y[index], y[rand]) = (y[rand], y[index]);
+ // (z[index], z[rand]) = (z[rand], z[index]);
+ // (r[index], r[rand]) = (r[rand], r[index]);
+ // (g[index], g[rand]) = (g[rand], g[index]);
+ // (b[index], b[rand]) = (b[rand], b[index]);
+ // }
+ //}
+
+ //// x,y,z,r,g,b,i,t,c
+ //public static void Shuffle(ref List x, ref List y, ref List z, ref List r, ref List g, ref List b, ref List i, ref List t, ref List c)
+ //{
+ // int index = x.Count;
+ // while (index > 1)
+ // {
+ // //int rand = rnd.Next(index--);
+ // int rand = frnd.Next(0, index--);
+
+ // (x[index], x[rand]) = (x[rand], x[index]);
+ // (y[index], y[rand]) = (y[rand], y[index]);
+ // (z[index], z[rand]) = (z[rand], z[index]);
+ // (r[index], r[rand]) = (r[rand], r[index]);
+ // (g[index], g[rand]) = (g[rand], g[index]);
+ // (b[index], b[rand]) = (b[rand], b[index]);
+ // (i[index], i[rand]) = (i[rand], i[index]);
+ // (c[index], c[rand]) = (c[rand], c[index]);
+ // }
+ //}
+
+ //// x,y,z,r,g,b,i,c
+ //public static void Shuffle(ref List x, ref List y, ref List z, ref List r, ref List g, ref List b, ref List i, ref List c)
+ //{
+ // int index = x.Count;
+ // while (index > 1)
+ // {
+ // //int rand = rnd.Next(index--);
+ // int rand = frnd.Next(0, index--);
+ // (x[index], x[rand]) = (x[rand], x[index]);
+ // (y[index], y[rand]) = (y[rand], y[index]);
+ // (z[index], z[rand]) = (z[rand], z[index]);
+ // (r[index], r[rand]) = (r[rand], r[index]);
+ // (g[index], g[rand]) = (g[rand], g[index]);
+ // (b[index], b[rand]) = (b[rand], b[index]);
+ // (i[index], i[rand]) = (i[rand], i[index]);
+ // (c[index], c[rand]) = (c[rand], c[index]);
+ // }
+ //}
+
+ //// x,y,z,r,g,b,i
+ //public static void Shuffle(ref List x, ref List y, ref List z, ref List r, ref List g, ref List b, ref List i)
+ //{
+ // int index = x.Count;
+ // while (index > 1)
+ // {
+ // //int rand = rnd.Next(index--);
+ // int rand = frnd.Next(0, index--);
+
+
+ // // Swap using tuple assignment
+ // (x[index], x[rand]) = (x[rand], x[index]);
+ // (y[index], y[rand]) = (y[rand], y[index]);
+ // (z[index], z[rand]) = (z[rand], z[index]);
+ // (r[index], r[rand]) = (r[rand], r[index]);
+ // (g[index], g[rand]) = (g[rand], g[index]);
+ // (b[index], b[rand]) = (b[rand], b[index]);
+ // (i[index], i[rand]) = (i[rand], i[index]);
+ // }
+ //}
+
+ //// x,y,z,r,g,b,i,t
+ //public static void Shuffle(ref List x, ref List y, ref List z, ref List r, ref List g, ref List b, ref List i, ref List t)
+ //{
+ // int index = x.Count;
+ // while (index > 1)
+ // {
+ // //int rand = rnd.Next(index--);
+ // int rand = frnd.Next(0, index--);
+
+ // // Swap using tuple assignment
+ // (x[index], x[rand]) = (x[rand], x[index]);
+ // (y[index], y[rand]) = (y[rand], y[index]);
+ // (z[index], z[rand]) = (z[rand], z[index]);
+ // (r[index], r[rand]) = (r[rand], r[index]);
+ // (g[index], g[rand]) = (g[rand], g[index]);
+ // (b[index], b[rand]) = (b[rand], b[index]);
+ // (i[index], i[rand]) = (i[rand], i[index]);
+
+ // // Handle double separately since it's a different type
+ // (t[index], t[rand]) = (t[rand], t[index]);
+ // }
+ //}
+
+ //// x,y,z,r,g,b,t
+ //public static void Shuffle(ref List x, ref List y, ref List z, ref List r, ref List g, ref List b, ref List t)
+ //{
+ // int index = x.Count;
+
+ // while (index > 1)
+ // {
+ // //int rand = rnd.Next(index--);
+ // int rand = frnd.Next(0, index--);
+
+ // // Swapping using tuples
+ // (x[index], x[rand]) = (x[rand], x[index]);
+ // (y[index], y[rand]) = (y[rand], y[index]);
+ // (z[index], z[rand]) = (z[rand], z[index]);
+ // (r[index], r[rand]) = (r[rand], r[index]);
+ // (g[index], g[rand]) = (g[rand], g[index]);
+ // (b[index], b[rand]) = (b[rand], b[index]);
+ // (t[index], t[rand]) = (t[rand], t[index]);
+ // }
+ //}
+
// https://stackoverflow.com/a/110570/5452781
public static void ShuffleXYZ(ref float[] array1)
{
@@ -239,6 +379,7 @@ public static void ShuffleXYZ(ref float[] array1)
}
}
+
public static int ParseInt(string s)
{
int f = 0;
@@ -255,6 +396,11 @@ public static float ParseFloat(string s)
return f;
}
+ public static float SRGBToLinear(float c)
+ {
+ return c <= 0.04045f ? c / 12.92f : MathF.Pow((c + 0.055f) / 1.055f, 2.4f);
+ }
+
public static void PrintHelpAndExit(char argSeparator, bool waitEnter = false)
{
Console.ForegroundColor = ConsoleColor.Gray;
@@ -275,7 +421,8 @@ public static void PrintHelpAndExit(char argSeparator, bool waitEnter = false)
Console.WriteLine("-output" + argSeparator + "yourfile.ucpc\t(Default is same folder as input file. For v3 you dont need to set file extension)");
Console.WriteLine("-rgb" + argSeparator + "true or false\tReads RGB colors\tDefault is true");
Console.WriteLine("-intensity" + argSeparator + "true or false\tReads Intensity as RGB color\tDefault is false");
- Console.WriteLine("-offset" + argSeparator + "true or false\tAuto-offsets cloud near 0,0,0 by using the first point as offset value\tDefault is true");
+ Console.WriteLine("-classification" + argSeparator + "false\t\tImport classification data\tDefault is false");
+ Console.WriteLine("-offset" + argSeparator + "true or false\tAuto-offsets cloud near 0,0,0\tDefault is true");
Console.WriteLine("-gridsize" + argSeparator + "5\t\tGridsize in meters, splits cloud into tiles with this size. v3 only!\tDefault is 5, minimum is 0.1 (Note: values below 1 are not really tested)");
Console.WriteLine("-minpoints" + argSeparator + "1000\t\tIf tile has less points than this value, its discarded. Good for removing straypoints. v3 only!\tDefault is 1000");
Console.WriteLine("-scale" + argSeparator + "0.1\t\tScale XYZ values (You need meters inside Unity)\tDefault is off");
@@ -285,17 +432,24 @@ public static void PrintHelpAndExit(char argSeparator, bool waitEnter = false)
Console.WriteLine("-limit" + argSeparator + "10000\t\tLoad only this many points (good for testing settings first)\tDefault is off");
Console.WriteLine("-skip" + argSeparator + "0\t\t\tSkip every Nth point (For reducing point count)\tDefault is off");
Console.WriteLine("-keep" + argSeparator + "0\t\t\tKeep only every Nth point (For reducing point count)\tDefault is off");
+ Console.WriteLine("-filter" + argSeparator + "0\t\t\tKeep only first point within this distance on world grid (In Unity units)\tDefault is off");
Console.WriteLine("-maxfiles" + argSeparator + "10\t\t\tFor batch processing, parse only this many files (good for testing with few files first)\tDefault is parse all found files");
// TODO Console.WriteLine("-decimate" + separator + "50\t\t\tRemoves 50% of the points (by skipping every x point)\tDefault is off");
//Console.WriteLine("-version" + argSeparator + "2\t\t2=v2 .ucpc, 3=v3 .pcroot tiles\tDefault is 2");
Console.WriteLine("-randomize" + argSeparator + "true\t\tRandomize point indexes, to use Dynamic resolution\tDefault is true (Always enabled for v3)");
- Console.WriteLine("-seed" + argSeparator + "42\t\tSet random seed\tDefault is random value");
+ Console.WriteLine("-seed" + argSeparator + "42\t\tSet random seed\tDefault is some random value");
Console.WriteLine("-json" + argSeparator + "false\t\tOutput console log in JSON format\tDefault is false");
- Console.WriteLine("-customintensityrange" + argSeparator + "false\t\tCustom intensity range (0-65535)\tDefault is false");
+ Console.WriteLine("-customintensityrange" + argSeparator + "false\t\tUse custom intensity range (0-65535) instead of 0-255\tDefault is false");
Console.WriteLine("-metadata" + argSeparator + "false\t\tRead metadata from header, outputs into json file\tDefault is false");
Console.WriteLine("-metadataonly" + argSeparator + "false\t\tRead metadata only (dont process points)\tDefault is false");
Console.WriteLine("-averagetimestamp" + argSeparator + "false\t\tGet Average timestamp per Tile\tDefault is false");
Console.WriteLine("-checkoverlap" + argSeparator + "false\t\tCalculate overlapping tiles\tDefault is false");
+ Console.WriteLine("-config" + argSeparator + "filename\t\tLoad arguments from text file (easier to handle separate settings for different projects)");
+ Console.WriteLine("-usegrid" + argSeparator + "true\t\tSplits point cloud to grid (multiple files). Required for V3 format (automatically enabled if its off). \tDefault is true for v3");
+ Console.WriteLine("-offsetmode" + argSeparator + "min\t\tGet auto-offset bounds, min=min from all bounds, legacy=first cloud min bound\tDefault is min");
+ Console.WriteLine("-srgb" + argSeparator + "false\t\tConvert raw sRGB values to Linear RGB\tDefault is false, enable this is your model seems too bright");
+
+
Console.WriteLine("");
Console.WriteLine("? /? -? help -help /help");
Console.ForegroundColor = ConsoleColor.White;
diff --git a/Writers/PCROOT.cs b/Writers/PCROOT.cs
index 23bfd80..9e3ede2 100644
--- a/Writers/PCROOT.cs
+++ b/Writers/PCROOT.cs
@@ -2,6 +2,7 @@
using PointCloudConverter.Logger;
using System;
+using System.Collections;
using System.Diagnostics;
using System.IO;
using System.Runtime.CompilerServices;
@@ -17,7 +18,7 @@ public class PCROOT : IWriter, IDisposable
BufferedStream bsPoints = null;
BinaryWriter writerPoints = null;
- ImportSettings importSettings;
+ ImportSettings importSettings; // this is per file here
static List nodeBounds = new List(); // for all tiles
static float cloudMinX = float.PositiveInfinity;
@@ -37,15 +38,19 @@ public class PCROOT : IWriter, IDisposable
Dictionary> nodeR = new Dictionary>();
Dictionary> nodeG = new Dictionary>();
Dictionary> nodeB = new Dictionary>();
- Dictionary> nodeIntensity = new Dictionary>();
+ Dictionary> nodeIntensity = new Dictionary>();
+ Dictionary> nodeClassification = new Dictionary>();
Dictionary> nodeTime = new Dictionary>();
//int? taskID;
static int skippedNodesCounter = 0;
- static int skippedPointsCounter = 0;
+ static int skippedPointsCounter = 0; // FIXME, not used in regular mode, only for lossy filtering, TODO can calculate from importsetting values
static bool useLossyFiltering = false; //not used, for testing only
+ private readonly List _shuffleListBuffer = new(4096 * 4);
+ private readonly List[] _tempArray = new List[4096 * 4];
+
public void Dispose()
{
//Log.Write("Memory used: " + GC.GetTotalMemory(false));
@@ -72,6 +77,32 @@ private void ClearDictionary(Dictionary> dictionary)
}
}
+ private void ClearDictionary(Dictionary> dictionary)
+ {
+ if (dictionary != null)
+ {
+ foreach (var list in dictionary.Values)
+ {
+ list.Clear(); // Clear the list to free up memory
+ }
+ dictionary.Clear(); // Clear the dictionary itself
+ dictionary = null; // Help GC by removing reference
+ }
+ }
+
+ private void ClearDictionary(Dictionary> dictionary)
+ {
+ if (dictionary != null)
+ {
+ foreach (var list in dictionary.Values)
+ {
+ list.Clear(); // Clear the list to free up memory
+ }
+ dictionary.Clear(); // Clear the dictionary itself
+ dictionary = null; // Help GC by removing reference
+ }
+ }
+
private void ClearDictionary(Dictionary> dictionary)
{
if (dictionary != null)
@@ -101,6 +132,7 @@ protected virtual void Dispose(bool disposing)
ClearDictionary(nodeG);
ClearDictionary(nodeB);
ClearDictionary(nodeIntensity);
+ ClearDictionary(nodeClassification);
ClearDictionary(nodeTime);
keyCache.Clear();
@@ -125,7 +157,7 @@ public PCROOT(int? _taskID)
static ILogger Log;
- public bool InitWriter(dynamic _importSettings, int pointCount, ILogger logger)
+ public bool InitWriter(dynamic _importSettings, long pointCount, ILogger logger)
{
//Log.Write("--------------------- initwriter for taskID: " + taskID);
var res = true;
@@ -141,8 +173,8 @@ public bool InitWriter(dynamic _importSettings, int pointCount, ILogger logger)
nodeG.Clear();
nodeB.Clear();
nodeIntensity.Clear();
+ nodeClassification.Clear();
nodeTime.Clear();
-
bsPoints = null;
writerPoints = null;
importSettings = (ImportSettings)(object)_importSettings;
@@ -168,6 +200,9 @@ void IWriter.WriteRGB(float r, float g, float b)
// for pcroot, this is saving the rootfile
void IWriter.Close()
{
+ // this happens if imported metadata only?
+ if (importSettings == null) return;
+
// save rootfile
// only save after last file, TODO should save this if process fails or user cancels, so no need to start from 0 again.. but then needs some merge or continue from index n feature
// if (isLastTask == true)
@@ -230,7 +265,10 @@ void IWriter.Close()
// add to tileroot list
for (int i = 0, len = nodeBounds.Count; i < len; i++)
{
- var tilerow = nodeBounds[i].fileName + sep + nodeBounds[i].totalPoints + sep + nodeBounds[i].minX + sep + nodeBounds[i].minY + sep + nodeBounds[i].minZ + sep + nodeBounds[i].maxX + sep + nodeBounds[i].maxY + sep + nodeBounds[i].maxZ + sep + nodeBounds[i].cellX + sep + nodeBounds[i].cellY + sep + nodeBounds[i].cellZ + sep + nodeBounds[i].averageTimeStamp + sep + nodeBounds[i].overlapRatio;
+ var tilerow = nodeBounds[i].totalPoints + sep + nodeBounds[i].minX + sep + nodeBounds[i].minY + sep + nodeBounds[i].minZ + sep + nodeBounds[i].maxX + sep + nodeBounds[i].maxY + sep + nodeBounds[i].maxZ + sep + nodeBounds[i].cellX + sep + nodeBounds[i].cellY + sep + nodeBounds[i].cellZ + sep + nodeBounds[i].averageTimeStamp + sep + nodeBounds[i].overlapRatio;
+ // force dot as decimal separator for values
+ tilerow = tilerow.Replace(",", ".");
+ tilerow = nodeBounds[i].fileName + sep + tilerow;
tilerootdata.Add(tilerow);
totalPointCount += nodeBounds[i].totalPoints;
}
@@ -249,7 +287,8 @@ void IWriter.Close()
int versionID = importSettings.packColors ? 2 : 1; // (1 = original, 2 = packed v3 format)
if (importSettings.packColors == true) versionID = 2;
if (useLossyFiltering == true) versionID = 3;
- if (importSettings.importIntensity == true && importSettings.importRGB && importSettings.packColors) versionID = 4; // new int packed format
+ if ((importSettings.importIntensity == true || importSettings.importClassification == true) && importSettings.importRGB && importSettings.packColors) versionID = 4; // new int packed format
+ if ((importSettings.importIntensity == true && importSettings.importClassification == true) && importSettings.importRGB && importSettings.packColors) versionID = 5; // new int packed format + classification
bool addComments = false;
@@ -259,6 +298,7 @@ void IWriter.Close()
string commentRow = "# version" + sep + "gridsize" + sep + "pointcount" + sep + "boundsMinX" + sep + "boundsMinY" + sep + "boundsMinZ" + sep + "boundsMaxX" + sep + "boundsMaxY" + sep + "boundsMaxZ" + sep + "autoOffsetX" + sep + "autoOffsetY" + sep + "autoOffsetZ" + sep + "packMagicValue";
if (importSettings.importRGB == true && importSettings.importIntensity == true) commentRow += sep + "intensity";
+ if (importSettings.importRGB == true && importSettings.importClassification == true) commentRow += sep + "classification";
if (addComments) tilerootdata.Insert(1, commentRow);
// add global header settings to first row
@@ -266,6 +306,9 @@ void IWriter.Close()
string globalData = versionID + sep + importSettings.gridSize.ToString() + sep + totalPointCount + sep + cloudMinX + sep + cloudMinY + sep + cloudMinZ + sep + cloudMaxX + sep + cloudMaxY + sep + cloudMaxZ;
// autoOffsetX, globalOffsetY, globalOffsetZ, packMagic
globalData += sep + importSettings.offsetX + sep + importSettings.offsetY + sep + importSettings.offsetZ + sep + importSettings.packMagicValue;
+ // force dot as decimal separator
+ globalData = globalData.Replace(",", ".");
+
if (addComments)
{
tilerootdata.Insert(2, globalData);
@@ -345,8 +388,8 @@ void IWriter.Cleanup(int fileIndex)
ClearDictionary(nodeG);
ClearDictionary(nodeB);
ClearDictionary(nodeIntensity);
+ ClearDictionary(nodeClassification);
ClearDictionary(nodeTime);
-
keyCache.Clear();
}
@@ -355,7 +398,7 @@ void IWriter.Randomize()
}
- void IWriter.AddPoint(int index, float x, float y, float z, float r, float g, float b, bool hasIntensity, float i, bool hasTime, double time)
+ void IWriter.AddPoint(int index, float x, float y, float z, float r, float g, float b, ushort intensity, double time, byte classification)
{
// get global all clouds bounds
cloudMinX = Math.Min(cloudMinX, x);
@@ -400,8 +443,10 @@ void IWriter.AddPoint(int index, float x, float y, float z, float r, float g, fl
nodeG[key].Add(g);
nodeB[key].Add(b);
- if (hasIntensity == true) nodeIntensity[key].Add(i);
- if (hasTime == true) nodeTime[key].Add(time);
+ if (importSettings.importRGB && importSettings.importIntensity == true) nodeIntensity[key].Add(intensity);
+ // TODO separate if rgb and or int?
+ if (importSettings.importRGB && importSettings.importClassification == true) nodeClassification[key].Add(classification);
+ if (importSettings.averageTimestamp == true) nodeTime[key].Add(time);
}
else // create new list for this key
{
@@ -413,8 +458,9 @@ void IWriter.AddPoint(int index, float x, float y, float z, float r, float g, fl
nodeG[key] = new List { g };
nodeB[key] = new List { b };
- if (hasIntensity == true) nodeIntensity[key] = new List { i };
- if (hasTime == true) nodeTime[key] = new List { time };
+ if (importSettings.importRGB && importSettings.importIntensity == true) nodeIntensity[key] = new List { intensity };
+ if (importSettings.importRGB && importSettings.importClassification == true) nodeClassification[key] = new List { classification };
+ if (importSettings.averageTimestamp == true) nodeTime[key] = new List { time };
}
} // addpoint()
@@ -462,7 +508,8 @@ void IWriter.Save(int fileIndex)
List nodeTempG;
List nodeTempB;
- List nodeTempIntensity = null;
+ List nodeTempIntensity = null;
+ List nodeTempClassification = null;
List nodeTempTime = null;
List outputFiles = new List();
@@ -489,44 +536,40 @@ void IWriter.Save(int fileIndex)
nodeTempG = nodeG[key];
nodeTempB = nodeB[key];
- // collect both
+ // collect both rgb and intensity
if (importSettings.importRGB == true && importSettings.importIntensity == true)
+ //if (importSettings.importIntensity == true)
{
nodeTempIntensity = nodeIntensity[key];
}
+ // TODO separate?
+ if (importSettings.importRGB == true && importSettings.importClassification == true)
+ {
+ nodeTempClassification = nodeClassification[key];
+ }
+
if (importSettings.averageTimestamp == true)
{
nodeTempTime = nodeTime[key];
}
-
// randomize points in this node
- if (importSettings.randomize == true)
+ if (importSettings.randomize)
{
- if (importSettings.importRGB == true && importSettings.importIntensity == true)
- {
- if (importSettings.averageTimestamp == true)
- {
- Tools.Shuffle(ref nodeTempX, ref nodeTempY, ref nodeTempZ, ref nodeTempR, ref nodeTempG, ref nodeTempB, ref nodeTempIntensity, ref nodeTempTime);
- }
- else
- {
- Tools.Shuffle(ref nodeTempX, ref nodeTempY, ref nodeTempZ, ref nodeTempR, ref nodeTempG, ref nodeTempB, ref nodeTempIntensity);
- }
- }
- else
- {
- if (importSettings.averageTimestamp == true)
- {
- Tools.Shuffle(ref nodeTempX, ref nodeTempY, ref nodeTempZ, ref nodeTempR, ref nodeTempG, ref nodeTempB, ref nodeTempTime);
- }
- else
- {
- Tools.Shuffle(ref nodeTempX, ref nodeTempY, ref nodeTempZ, ref nodeTempR, ref nodeTempG, ref nodeTempB);
- }
- }
- } // randomize
+ Tools.ShufflePointAttributes(
+ nodeTempX.Count,
+ nodeTempX, nodeTempY, nodeTempZ,
+ importSettings.importRGB ? nodeTempR : null,
+ importSettings.importRGB ? nodeTempG : null,
+ importSettings.importRGB ? nodeTempB : null,
+ importSettings.importIntensity ? nodeTempIntensity : null,
+ importSettings.importClassification ? nodeTempClassification : null,
+ importSettings.averageTimestamp ? nodeTempTime : null
+ );
+ }
+
+
// get this node bounds, TODO but we know node(grid cell) x,y,z values?
float minX = float.PositiveInfinity;
@@ -541,13 +584,15 @@ void IWriter.Save(int fileIndex)
string fullpathFileOnly = fileOnly + "_" + fileIndex + "_" + key + tileExtension;
// if batch mode (more than 1 file), FIXME generates new unique filename..but why not overwrite?
- if (fileIndex > 0 && File.Exists(fullpath))
- {
- //Console.WriteLine("File already exists! " + fullpath);
- Int32 unixTimestamp = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
- fullpath = Path.Combine(baseFolder, fileOnly) + "_" + fileIndex + "_" + key + "_r" + (unixTimestamp) + tileExtension;
- fullpathFileOnly = fileOnly + "_" + fileIndex + "_" + key + tileExtension;
- }
+ // THIS is now disabled, it didnt really work since pcroot was not updated with new file names!
+ //if (fileIndex > 0 && File.Exists(fullpath))
+ //{
+ //Log.Write("File already exists! " + fullpath);
+ ////Console.WriteLine("File already exists! " + fullpath);
+ //Int32 unixTimestamp = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
+ //fullpath = Path.Combine(baseFolder, fileOnly) + "_" + fileIndex + "_" + key + "_r" + (unixTimestamp) + tileExtension;
+ //fullpathFileOnly = fileOnly + "_" + fileIndex + "_" + key + tileExtension;
+ //}
// save this tile
//Log.Write("*** Saving tile: " + fullpathFileOnly + " (" + nodeTempX.Count + " points)");
@@ -580,17 +625,18 @@ void IWriter.Save(int fileIndex)
// loop and output all points within that node/tile
for (int i = 0, len = nodeTempX.Count; i < len; i++)
{
- // skip points
- if (importSettings.skipPoints == true && (i % importSettings.skipEveryN == 0)) continue;
+ //// skip points
+ //if (importSettings.skipPoints == true && (i % importSettings.skipEveryN == 0)) continue;
- // keep points
- if (importSettings.keepPoints == true && (i % importSettings.keepEveryN != 0)) continue;
+ //// keep points
+ //if (importSettings.keepPoints == true && (i % importSettings.keepEveryN != 0)) continue;
// get original world positions
float px = nodeTempX[i];
float py = nodeTempY[i];
float pz = nodeTempZ[i];
- int packed = 0;
+ int packedX = 0;
+ int packedY = 0;
// FIXME bounds is wrong if appended (but append is disabled now), should include previous data also, but now append is disabled.. also probably should use known cell xyz bounds directly
if (px < minX) minX = px;
if (px > maxX) maxX = px;
@@ -613,24 +659,56 @@ void IWriter.Save(int fileIndex)
py -= (cellY * importSettings.gridSize);
pz -= (cellZ * importSettings.gridSize);
- // pack G, PY and INTensity
- if (importSettings.importRGB == true && importSettings.importIntensity == true)
+ // pack G, Py and INTensity
+ if (importSettings.importRGB == true && importSettings.importIntensity == true && importSettings.importClassification == false)
{
float c = py;
int cIntegral = (int)c;
int cFractional = (int)((c - cIntegral) * 255);
- byte br = (byte)(nodeTempG[i] * 255);
- byte bi = (byte)(nodeTempIntensity[i] * 255);
- packed = (br << 24) | (bi << 16) | (cIntegral << 8) | cFractional;
+ byte bg = (byte)(nodeTempG[i] * 255);
+ byte bi = importSettings.useCustomIntensityRange ? (byte)(nodeTempIntensity[i] / 257) : (byte)nodeTempIntensity[i];
+ packedY = (bg << 24) | (bi << 16) | (cIntegral << 8) | cFractional;
+ } // pack G, Py, CLASSification
+ else if (importSettings.importRGB == true && importSettings.importIntensity == false && importSettings.importClassification == true)
+ {
+ float c = py;
+ int cIntegral = (int)c;
+ int cFractional = (int)((c - cIntegral) * 255);
+ byte bg = (byte)(nodeTempG[i] * 255);
+ byte bc = nodeTempClassification[i];
+ packedY = (bg << 24) | (bc << 16) | (cIntegral << 8) | cFractional;
+ } // pack G, Py, INTensity, CLASSification
+ else if (importSettings.importRGB == true && importSettings.importIntensity == true && importSettings.importClassification == true)
+ {
+ float c = py;
+ int cIntegral = (int)c;
+ int cFractional = (int)((c - cIntegral) * 255);
+ byte bg = (byte)(nodeTempG[i] * 255);
+ byte bi = importSettings.useCustomIntensityRange ? (byte)(nodeTempIntensity[i] / 257) : (byte)nodeTempIntensity[i];
+ // byte bi = nodeTempIntensity[i];
+ packedY = (bg << 24) | (bi << 16) | (cIntegral << 8) | cFractional;
}
- else
+ else // pack G and Py
{
- // pack green and y
+ // pack green and y (note this is lossy, especially with *0.98)
py = Tools.SuperPacker(nodeTempG[i] * 0.98f, py, importSettings.gridSize * importSettings.packMagicValue);
}
- // pack red and x
- px = Tools.SuperPacker(nodeTempR[i] * 0.98f, px, importSettings.gridSize * importSettings.packMagicValue);
+ // pack Red, Px, CLASSification (since intensity is already in green)
+ if (importSettings.importRGB == true && importSettings.importIntensity == true && importSettings.importClassification == true)
+ {
+ float c = px;
+ int cIntegral = (int)c;
+ int cFractional = (int)((c - cIntegral) * 255);
+ byte br = (byte)(nodeTempR[i] * 255);
+ byte bc = nodeTempClassification[i];
+ packedX = (br << 24) | (bc << 16) | (cIntegral << 8) | cFractional;
+ }
+ else // pack Red and Px
+ {
+ px = Tools.SuperPacker(nodeTempR[i] * 0.98f, px, importSettings.gridSize * importSettings.packMagicValue);
+ }
+
// pack blue and z
pz = Tools.SuperPacker(nodeTempB[i] * 0.98f, pz, importSettings.gridSize * importSettings.packMagicValue);
@@ -687,7 +765,7 @@ void IWriter.Save(int fileIndex)
}
reservedGridCells[reservedTileLocalCellIndex] = true;
- }
+ } // if packed or lossy
if (useLossyFiltering == true)
{
@@ -733,29 +811,38 @@ void IWriter.Save(int fileIndex)
//}
//writerPoints.Write(pz);
+ // x, red, classification
+ if (importSettings.packColors == true && importSettings.importRGB == true && importSettings.importIntensity == true && importSettings.importClassification == true)
+ {
+ IntToBytes(packedX, pointBuffer, 0); // Convert int to bytes manually
+ }
+ else // x, red
+ {
+ FloatToBytes(px, pointBuffer, 0);
+ }
- FloatToBytes(px, pointBuffer, 0);
-
- if (importSettings.packColors == true && importSettings.importRGB == true && importSettings.importIntensity == true)
+ // packed: y, green, intensity AND/OR classification
+ if (importSettings.packColors == true && importSettings.importRGB == true && (importSettings.importIntensity == true || importSettings.importClassification == true))
{
- IntToBytes(packed, pointBuffer, 4); // Convert int to bytes manually
+ // y, int, classification for now
+ IntToBytes(packedY, pointBuffer, 4);
}
- else
+ else // y
{
- FloatToBytes(py, pointBuffer, 4); // Convert float to bytes manually
+ FloatToBytes(py, pointBuffer, 4);
}
+ // z
FloatToBytes(pz, pointBuffer, 8);
writerPoints.Write(pointBuffer);
-
- }
+ } // wrote packed or unpacked xyz
if (importSettings.averageTimestamp == true)
{
//double ptime =
totalTime += nodeTempTime[i]; // time for this single point
- //Console.WriteLine(ptime);
+ //Console.WriteLine(ptime);
}
totalPointsWritten++;
@@ -768,45 +855,44 @@ void IWriter.Save(int fileIndex)
// not packed
if (importSettings.packColors == false && useLossyFiltering == false)
{
- try
+ //try
+ //{
+ // save separate RGB
+ using (var writerColors = new BinaryWriter(new BufferedStream(new FileStream(fullpath + ".rgb", FileMode.Create))))
{
+ //bool skipPoints = importSettings.skipPoints;
+ //bool keepPoints = importSettings.keepPoints;
+ //int skipEveryN = importSettings.skipEveryN;
+ //int keepEveryN = importSettings.keepEveryN;
- // save separate RGB
- using (var writerColors = new BinaryWriter(new BufferedStream(new FileStream(fullpath + ".rgb", FileMode.Create))))
+ int len = nodeTempX.Count;
+ byte[] colorBuffer = new byte[12]; // Buffer to hold the RGB values as bytes
+
+ //unsafe void FloatToBytes(float value, byte[] buffer, int offset)
+ //{
+ // fixed (byte* b = &buffer[offset])
+ // {
+ // *(float*)b = value;
+ // }
+ //}
+
+ for (int i = 0; i < len; i++)
{
- bool skipPoints = importSettings.skipPoints;
- bool keepPoints = importSettings.keepPoints;
- int skipEveryN = importSettings.skipEveryN;
- int keepEveryN = importSettings.keepEveryN;
-
- int len = nodeTempX.Count;
- byte[] colorBuffer = new byte[12]; // Buffer to hold the RGB values as bytes
-
- //unsafe void FloatToBytes(float value, byte[] buffer, int offset)
- //{
- // fixed (byte* b = &buffer[offset])
- // {
- // *(float*)b = value;
- // }
- //}
-
- for (int i = 0; i < len; i++)
- {
- if ((skipPoints && (i % skipEveryN == 0)) || (keepPoints && (i % keepEveryN != 0))) continue;
+ //if ((skipPoints && (i % skipEveryN == 0)) || (keepPoints && (i % keepEveryN != 0))) continue;
- FloatToBytes(nodeTempR[i], colorBuffer, 0);
- FloatToBytes(nodeTempG[i], colorBuffer, 4);
- FloatToBytes(nodeTempB[i], colorBuffer, 8);
+ FloatToBytes(nodeTempR[i], colorBuffer, 0);
+ FloatToBytes(nodeTempG[i], colorBuffer, 4);
+ FloatToBytes(nodeTempB[i], colorBuffer, 8);
- writerColors.Write(colorBuffer);
- }
+ writerColors.Write(colorBuffer);
}
}
- catch (Exception e)
- {
- Trace.WriteLine("Error writing RGB file: " + e.Message);
- throw;
- }
+ //}
+ //catch (Exception e)
+ //{
+ // Trace.WriteLine("Error writing RGB file: " + e.Message);
+ // throw;
+ //}
// TESTING save separate Intensity, if both rgb and intensity are enabled
if (importSettings.importRGB == true && importSettings.importIntensity == true)
@@ -818,16 +904,17 @@ void IWriter.Save(int fileIndex)
// output all points within that node cell
for (int i = 0, len = nodeTempX.Count; i < len; i++)
{
- // skip points
- if (importSettings.skipPoints == true && (i % importSettings.skipEveryN == 0)) continue;
+ //// skip points
+ //if (importSettings.skipPoints == true && (i % importSettings.skipEveryN == 0)) continue;
- // keep points
- if (importSettings.keepPoints == true && (i % importSettings.keepEveryN != 0)) continue;
+ //// keep points
+ //if (importSettings.keepPoints == true && (i % importSettings.keepEveryN != 0)) continue;
- // TODO write as byte (not RGB floats)
- writerIntensity.Write(nodeTempIntensity[i]);
- writerIntensity.Write(nodeTempIntensity[i]);
- writerIntensity.Write(nodeTempIntensity[i]);
+ // TODO write as byte (not RGB floats) and write all in one
+ float c = nodeTempIntensity[i] / 255f;
+ writerIntensity.Write(c);
+ writerIntensity.Write(c);
+ writerIntensity.Write(c);
} // loop all point in cell cells
// close tile/node
@@ -835,6 +922,34 @@ void IWriter.Save(int fileIndex)
bsIntensity.Dispose();
}
+ // TEST separate classification
+ if (importSettings.importRGB == true && importSettings.importClassification == true)
+ {
+ BufferedStream bsClassification;
+ bsClassification = new BufferedStream(new FileStream(fullpath + ".cla", FileMode.Create));
+ var writerClassification = new BinaryWriter(bsClassification);
+
+ // output all points within that node cell
+ for (int i = 0, len = nodeTempX.Count; i < len; i++)
+ {
+ //// skip points
+ //if (importSettings.skipPoints == true && (i % importSettings.skipEveryN == 0)) continue;
+
+ //// keep points
+ //if (importSettings.keepPoints == true && (i % importSettings.keepEveryN != 0)) continue;
+
+ // TODO write as byte (not RGB floats)
+ float c = nodeTempClassification[i] / 255f;
+ writerClassification.Write(c);
+ writerClassification.Write(c);
+ writerClassification.Write(c);
+ } // loop all point in cell cells
+
+ // close tile/node
+ writerClassification.Close();
+ bsClassification.Dispose();
+ }
+
} // if packColors == false && useLossyFiltering == false
// collect node bounds, name and pointcount
@@ -912,5 +1027,9 @@ void RGBtoHSV(float r, float g, float b, out float h, out float s, out float v)
if (h < 0) h += 360;
}
+ public void SetIntensityRange(bool isCustomRange)
+ {
+ importSettings.useCustomIntensityRange = isCustomRange;
+ }
} // class
} // namespace
diff --git a/Writers/UCPC.cs b/Writers/UCPC.cs
index 96e6a7c..67084c2 100644
--- a/Writers/UCPC.cs
+++ b/Writers/UCPC.cs
@@ -46,12 +46,18 @@ public ImportSettings importSettings
static ILogger Log;
- bool IWriter.InitWriter(dynamic _importSettings, int _pointCount, ILogger logger)
+ bool IWriter.InitWriter(dynamic _importSettings, long _pointCount, ILogger logger)
{
importSettings = (ImportSettings)(object)_importSettings;
Log = logger;
- pointCount = _pointCount;
+ if (_pointCount > int.MaxValue)
+ {
+ Log.Write("Point count exceeds maximum value of int: " + _pointCount, LogEvent.Error);
+ return false;
+ }
+
+ pointCount = (int)_pointCount;
pointsTempFile = importSettings.outputFile + "_PointsTemp";
colorsTempFile = importSettings.outputFile + "_ColorsTemp";
@@ -250,13 +256,13 @@ void IWriter.Randomize()
}
}
- void IWriter.AddPoint(int index, float x, float y, float z, float r, float g, float b, bool hasIntensity, float i, bool hasTime, double time)
+ void IWriter.AddPoint(int index, float x, float y, float z, float r, float g, float b, ushort intensity, double time, byte classification)
{
- // skip points
- if (importSettings.skipPoints == true && (index % importSettings.skipEveryN == 0)) return;
+ //// skip points
+ //if (importSettings.skipPoints == true && (index % importSettings.skipEveryN == 0)) return;
- // keep points
- if (importSettings.keepPoints == true && (index % importSettings.keepEveryN != 0)) return;
+ //// keep points
+ //if (importSettings.keepPoints == true && (index % importSettings.keepEveryN != 0)) return;
// get bounds
if (x < cloudMinX) cloudMinX = x;
@@ -368,5 +374,10 @@ void IWriter.Dispose()
{
// TODO ?
}
+
+ public void SetIntensityRange(bool isCustomRange)
+ {
+ throw new NotImplementedException();
+ }
}
}
diff --git a/libs/laszip.net-develop/LASreadItemCompressed_RGBNIR14_v3.cs b/libs/laszip.net-develop/LASreadItemCompressed_RGBNIR14_v3.cs
index 2a1c4c2..0f56f29 100644
--- a/libs/laszip.net-develop/LASreadItemCompressed_RGBNIR14_v3.cs
+++ b/libs/laszip.net-develop/LASreadItemCompressed_RGBNIR14_v3.cs
@@ -143,8 +143,8 @@ public override bool init(laszip_point item, ref uint context) // context is onl
if (num_bytes_NIR != 0)
{
if (!instream.getBytes(bytes, num_bytes, num_bytes_NIR)) throw new EndOfStreamException();
- instream_NIR = new MemoryStream(bytes, num_bytes, num_bytes_RGB);
- dec_NIR.init(instream_NIR);
+ instream_NIR = new MemoryStream(bytes, num_bytes, num_bytes_NIR);
+ dec_NIR.init(instream_NIR);
changed_NIR = true;
}
else
diff --git a/libs/laszip.net-develop/LASreadItemCompressed_RGBNIR14_v4.cs b/libs/laszip.net-develop/LASreadItemCompressed_RGBNIR14_v4.cs
index ba0e29e..f4f0ffc 100644
--- a/libs/laszip.net-develop/LASreadItemCompressed_RGBNIR14_v4.cs
+++ b/libs/laszip.net-develop/LASreadItemCompressed_RGBNIR14_v4.cs
@@ -143,8 +143,8 @@ public override bool init(laszip_point item, ref uint context) // context is onl
if (num_bytes_NIR != 0)
{
if (!instream.getBytes(bytes, num_bytes, num_bytes_NIR)) throw new EndOfStreamException();
- instream_NIR = new MemoryStream(bytes, num_bytes, num_bytes_RGB);
- dec_NIR.init(instream_NIR);
+ instream_NIR = new MemoryStream(bytes, num_bytes, num_bytes_NIR);
+ dec_NIR.init(instream_NIR);
changed_NIR = true;
}
else