├── .gitignore
├── CMakeLists.txt
├── LICENSE
├── LICENSE.LGPLv3
├── README.md
├── example
├── CMakeLists.txt
├── data
│ ├── bunny.pcd
│ └── bunny_normal.pcd
├── qml.qrc
├── qml
│ └── main.qml
├── shader
│ ├── pointcloud.frag
│ ├── pointcloud.vert
│ ├── surfel.frag
│ └── surfel.vert
└── src
│ └── main.cpp
├── include
├── qpointcloud.h
├── qpointcloudgeometry.h
├── qpointcloudreader.h
└── qpointfield.h
└── src
├── qpointcloud.cpp
├── qpointcloudgeometry.cpp
├── qpointcloudreader.cpp
└── qpointfield.cpp
/.gitignore:
--------------------------------------------------------------------------------
1 | *.pro.user
2 | *.user*
3 | *.autosave
4 | *.backup
5 | *.tmp
6 | *.pyc
7 | *.obj
8 | *.orig
9 | *build*
10 | moc_*
11 | CMakeLists.txt.user
12 | *~
13 | *.rej
14 | *.BACKUP.*
15 | *.BASE.*
16 | *.LOCAL.*
17 | *.REMOTE.*
18 | externals/libs/*
19 | .directory
20 | *.swp
21 |
22 | Release
23 | Debug
24 | GeneratedFiles
25 |
26 | docs/doxygen/html
27 | docs/doxygen/latex
28 |
--------------------------------------------------------------------------------
/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | project(Qt3DPointcloudRenderer)
2 | cmake_minimum_required(VERSION 3.0.2)
3 |
4 | set(CMAKE_AUTOMOC ON)
5 | set(CMAKE_INCLUDE_CURRENT_DIR ON)
6 |
7 | find_package(Qt5Core REQUIRED)
8 | find_package(Qt5Qml REQUIRED)
9 | find_package(Qt5Widgets REQUIRED)
10 | find_package(Qt5Quick REQUIRED)
11 | find_package(Qt53DInput REQUIRED)
12 | find_package(Qt53DQuick REQUIRED)
13 | find_package(Qt53DRender REQUIRED)
14 | find_package(Qt53DQuickRender REQUIRED)
15 |
16 | set(WITH_PCL ON CACHE BOOL "Enable pcl")
17 | set(WITH_LAS OFF CACHE BOOL "Enable las")
18 |
19 | if(WITH_PCL)
20 | find_package(PCL REQUIRED COMPONENTS common io)
21 | link_directories(${PCL_LIBRARY_DIRS})
22 | endif(WITH_PCL)
23 |
24 | if(WITH_LAS)
25 | # LibLAS is used for easy integration with windows. Thus it is not included
26 | # with an additional find-script, but quick-and-dirty by integrating LAS into
27 | # the the project. Retain libLAS copyright notice in your project (BSD License).
28 |
29 | set(HAVE_GDAL FALSE CACHE BOOL "Enable GDAL for LibLAS")
30 | set(HAVE_LIBGEOTIFF FALSE CACHE BOOL "Enable libGeoTIFF for LibLAS")
31 | set(HAVE_LASZIP TRUE CACHE BOOL "Enable Laszip for LibLAS")
32 | set(LIBLAS_PATH CACHE PATH "Path to libLAS folder, containing \"include\" and \"src\"")
33 | set(LIBLASZIP_PATH CACHE PATH "Path to LASzip folder VERSION v2.2.0! (newer versions are incompatible)")
34 |
35 | file(GLOB_RECURSE LASZIP_SOURCES ${LIBLASZIP_PATH}/include/*.hpp
36 | ${LIBLASZIP_PATH}/include/*.h
37 | ${LIBLASZIP_PATH}/src/*.hpp
38 | ${LIBLASZIP_PATH}/src/*.h
39 | ${LIBLAS_PATH}/src/*.cpp )
40 |
41 | file(GLOB_RECURSE LIBLAS_SOURCES ${LIBLAS_PATH}/include/*.hpp
42 | ${LIBLAS_PATH}/include/*.h
43 | ${LIBLAS_PATH}/src/*.hpp
44 | ${LIBLAS_PATH}/src/*.h
45 | ${LIBLAS_PATH}/src/*.cpp )
46 | if(NOT HAVE_GDAL)
47 | file(GLOB_RECURSE GT_SRC ${LIBLAS_PATH}/src/gt_*.cpp
48 | ${LIBLAS_PATH}/src/gt_*.h)
49 | list(REMOVE_ITEM LIBLAS_SOURCES "${GT_SRC}")
50 | endif(NOT HAVE_GDAL)
51 |
52 | if(NOT HAVE_LIBGEOTIFF)
53 | file(GLOB_RECURSE GEO_SRC ${LIBLAS_PATH}/src/tifvsi.cpp)
54 | list(REMOVE_ITEM LIBLAS_SOURCES "${GEO_SRC}")
55 | endif(NOT HAVE_LIBGEOTIFF)
56 | endif(WITH_LAS)
57 |
58 | set(SOURCE
59 | ${CMAKE_CURRENT_SOURCE_DIR}/src/qpointcloud.cpp
60 | ${CMAKE_CURRENT_SOURCE_DIR}/src/qpointcloudgeometry.cpp
61 | ${CMAKE_CURRENT_SOURCE_DIR}/src/qpointfield.cpp
62 | ${CMAKE_CURRENT_SOURCE_DIR}/src/qpointcloudreader.cpp
63 | # ${CMAKE_CURRENT_SOURCE_DIR}/src/xyzcsvreader.cpp
64 | )
65 | set(HEADER
66 | ${CMAKE_CURRENT_SOURCE_DIR}/include/qpointcloud.h
67 | ${CMAKE_CURRENT_SOURCE_DIR}/include/qpointcloudgeometry.h
68 | ${CMAKE_CURRENT_SOURCE_DIR}/include/qpointfield.h
69 | ${CMAKE_CURRENT_SOURCE_DIR}/include/qpointcloudreader.h
70 | # ${CMAKE_CURRENT_SOURCE_DIR}/include/xyzcsvreader.h
71 | )
72 |
73 | set(BUILD_EXAMPLE ON CACHE BOOL "Build the example project")
74 |
75 | if(BUILD_EXAMPLE)
76 | add_subdirectory(example)
77 | endif(BUILD_EXAMPLE)
78 |
79 | add_library(Qt3DPointcloudRenderer ${SOURCE} ${HEADER} ${LIBLAS_SOURCES} ${LASZIP_SOURCES})
80 |
81 | target_include_directories(Qt3DPointcloudRenderer PUBLIC ${PROJECT_SOURCE_DIR}/include/
82 | PRIVATE ${PROJECT_SOURCE_DIR}/src/ )
83 |
84 | if(WITH_PCL)
85 | target_link_libraries(Qt3DPointcloudRenderer ${PCL_LIBRARIES} stdc++)
86 | target_include_directories(${PROJECT_NAME} PRIVATE PRIVATE ${PCL_INCLUDE_DIRS})
87 | #target_compile_definitions(${PROJECT_NAME} PRIVATE ${PCL_DEFINITIONS}) causes command-line error in cmake from ubuntu 16.04
88 | target_compile_definitions(${PROJECT_NAME} PUBLIC WITH_PCL=1)
89 | endif(WITH_PCL)
90 |
91 | if(WITH_LAS)
92 | target_include_directories(${PROJECT_NAME} PRIVATE ${LIBLAS_PATH}/include/)
93 | target_compile_definitions(${PROJECT_NAME} PUBLIC WITH_LAS=1)
94 | if(HAVE_LASZIP)
95 | target_include_directories(${PROJECT_NAME} PRIVATE ${LIBLASZIP_PATH}/include/
96 | ${LIBLASZIP_PATH}/include/laszip
97 | ${LIBLASZIP_PATH}/src/)
98 | endif(HAVE_LASZIP)
99 | endif(WITH_LAS)
100 |
101 | qt5_use_modules(Qt3DPointcloudRenderer Qml Widgets Quick 3DCore 3DQuick 3DRender 3DQuickRender)
102 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 | {one line to give the program's name and a brief idea of what it does.}
635 | Copyright (C) {year} {name of author}
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | {project} Copyright (C) {year} {fullname}
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/LICENSE.LGPLv3:
--------------------------------------------------------------------------------
1 | GNU LESSER GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright © 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies of this
6 | licensedocument, but changing it is not allowed.
7 |
8 | This version of the GNU Lesser General Public License incorporates
9 | the terms and conditions of version 3 of the GNU General Public
10 | License, supplemented by the additional permissions listed below.
11 |
12 | 0. Additional Definitions.
13 |
14 | As used herein, “this License” refers to version 3 of the GNU Lesser
15 | General Public License, and the “GNU GPL” refers to version 3 of the
16 | GNU General Public License.
17 |
18 | “The Library” refers to a covered work governed by this License,
19 | other than an Application or a Combined Work as defined below.
20 |
21 | An “Application” is any work that makes use of an interface provided
22 | by the Library, but which is not otherwise based on the Library.
23 | Defining a subclass of a class defined by the Library is deemed a mode
24 | of using an interface provided by the Library.
25 |
26 | A “Combined Work” is a work produced by combining or linking an
27 | Application with the Library. The particular version of the Library
28 | with which the Combined Work was made is also called the “Linked
29 | Version”.
30 |
31 | The “Minimal Corresponding Source” for a Combined Work means the
32 | Corresponding Source for the Combined Work, excluding any source code
33 | for portions of the Combined Work that, considered in isolation, are
34 | based on the Application, and not on the Linked Version.
35 |
36 | The “Corresponding Application Code” for a Combined Work means the
37 | object code and/or source code for the Application, including any data
38 | and utility programs needed for reproducing the Combined Work from the
39 | Application, but excluding the System Libraries of the Combined Work.
40 |
41 | 1. Exception to Section 3 of the GNU GPL.
42 |
43 | You may convey a covered work under sections 3 and 4 of this License
44 | without being bound by section 3 of the GNU GPL.
45 |
46 | 2. Conveying Modified Versions.
47 |
48 | If you modify a copy of the Library, and, in your modifications, a
49 | facility refers to a function or data to be supplied by an Application
50 | that uses the facility (other than as an argument passed when the
51 | facility is invoked), then you may convey a copy of the modified
52 | version:
53 |
54 | a) under this License, provided that you make a good faith effort
55 | to ensure that, in the event an Application does not supply the
56 | function or data, the facility still operates, and performs
57 | whatever part of its purpose remains meaningful, or
58 |
59 | b) under the GNU GPL, with none of the additional permissions of
60 | this License applicable to that copy.
61 |
62 | 3. Object Code Incorporating Material from Library Header Files.
63 |
64 | The object code form of an Application may incorporate material from
65 | a header file that is part of the Library. You may convey such object
66 | code under terms of your choice, provided that, if the incorporated
67 | material is not limited to numerical parameters, data structure
68 | layouts and accessors, or small macros, inline functions and templates
69 | (ten or fewer lines in length), you do both of the following:
70 |
71 | a) Give prominent notice with each copy of the object code that
72 | the Library is used in it and that the Library and its use are
73 | covered by this License.
74 |
75 | b) Accompany the object code with a copy of the GNU GPL and this
76 | license document.
77 |
78 | 4. Combined Works.
79 |
80 | You may convey a Combined Work under terms of your choice that, taken
81 | together, effectively do not restrict modification of the portions of
82 | the Library contained in the Combined Work and reverse engineering for
83 | debugging such modifications, if you also do each of the following:
84 |
85 | a) Give prominent notice with each copy of the Combined Work that
86 | the Library is used in it and that the Library and its use are
87 | covered by this License.
88 |
89 | b) Accompany the Combined Work with a copy of the GNU GPL and this
90 | license document.
91 |
92 | c) For a Combined Work that displays copyright notices during
93 | execution, include the copyright notice for the Library among
94 | these notices, as well as a reference directing the user to the
95 | copies of the GNU GPL and this license document.
96 |
97 | d) Do one of the following:
98 |
99 | 0) Convey the Minimal Corresponding Source under the terms of
100 | this License, and the Corresponding Application Code in a form
101 | suitable for, and under terms that permit, the user to
102 | recombine or relink the Application with a modified version of
103 | the Linked Version to produce a modified Combined Work, in the
104 | manner specified by section 6 of the GNU GPL for conveying
105 | Corresponding Source.
106 |
107 | 1) Use a suitable shared library mechanism for linking with
108 | the Library. A suitable mechanism is one that (a) uses at run
109 | time a copy of the Library already present on the user's
110 | computer system, and (b) will operate properly with a modified
111 | version of the Library that is interface-compatible with the
112 | Linked Version.
113 |
114 | e) Provide Installation Information, but only if you would
115 | otherwise be required to provide such information under section 6
116 | of the GNU GPL, and only to the extent that such information is
117 | necessary to install and execute a modified version of the
118 | Combined Work produced by recombining or relinking the Application
119 | with a modified version of the Linked Version. (If you use option
120 | 4d0, the Installation Information must accompany the Minimal
121 | Corresponding Source and Corresponding Application Code. If you
122 | use option 4d1, you must provide the Installation Information in
123 | the manner specified by section 6 of the GNU GPL for conveying
124 | Corresponding Source.)
125 |
126 | 5. Combined Libraries.
127 |
128 | You may place library facilities that are a work based on the Library
129 | side by side in a single library together with other library
130 | facilities that are not Applications and are not covered by this
131 | License, and convey such a combined library under terms of your
132 | choice, if you do both of the following:
133 |
134 | a) Accompany the combined library with a copy of the same work
135 | based on the Library, uncombined with any other library
136 | facilities, conveyed under the terms of this License.
137 |
138 | b) Give prominent notice with the combined library that part of
139 | it is a work based on the Library, and explaining where to find
140 | the accompanying uncombined form of the same work.
141 |
142 | 6. Revised Versions of the GNU Lesser General Public License.
143 |
144 | The Free Software Foundation may publish revised and/or new versions
145 | of the GNU Lesser General Public License from time to time. Such new
146 | versions will be similar in spirit to the present version, but may
147 | differ in detail to address new problems or concerns.
148 |
149 | Each version is given a distinguishing version number. If the Library
150 | as you received it specifies that a certain numbered version of the
151 | GNU Lesser General Public License “or any later version” applies to
152 | it, you have the option of following the terms and conditions either
153 | of that published version or of any later version published by the
154 | Free Software Foundation. If the Library as you received it does not
155 | specify a version number of the GNU Lesser General Public License,
156 | you may choose any version of the GNU Lesser General Public License
157 | ever published by the Free Software Foundation.
158 |
159 | If the Library as you received it specifies that a proxy can decide
160 | whether future versions of the GNU Lesser General Public License shall
161 | apply, that proxy's public statement of acceptance of any version is
162 | permanent authorization for you to choose that version for the Library.
163 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Qt3DPointcloudRenderer
2 |
3 | Adds C++ Classes and Qmltypes for rendering Point Cloud Library Pointcloud2 and libLAS pointclouds. Interfaces to both libraries look the same in qml. PCL or libLAS can be disabled to avoid the dependency to one of the libraries.
4 | This library adds classes to be used with the Qt3D GeometryRenderer-Component. Moreover a Qml-Pointcloud type and pcd/ply-reader exist. The compiled library can be used by a program, that does not need PCL/libLAS-headers.
5 | Pointclouds are read-only. However Qml binding re-evaluate if the internal pointcloud is changed.
6 |
7 | ## Qml Types
8 |
9 | * Pointcloud: Wraps pcl::PCLPointCloud2; Reads LAS files using a provided liblas::Reader (TODO: this is only C++ yet)
10 | * Pointfield: Wraps pcl::PCLPointField
11 | * PointcloudReader: Wraps pcl::PCDReader and pcl::PLYReader
12 | * QPointcloudGeometry: Can be used as Qt3DRender::QGeometry to render a Pointcloud using Qt3DRender::GeometryRenderer
13 |
14 | ## Usage
15 |
16 | Register Qml-Types:
17 |
18 | qmlRegisterType("pcl", 1, 0, "PointcloudReader");
19 | qmlRegisterType("pcl", 1, 0, "Pointcloud");
20 | qmlRegisterType("pcl", 1, 0, "PointcloudGeometry");
21 | qmlRegisterUncreatableType("pcl", 1, 0, "Pointfield", "Can not yet be created in qml, use PointcloudReader.");
22 |
23 | Read Pointcloud in Qml:
24 |
25 | PointcloudReader {
26 | id: pointcloudreader
27 | filename: "data/bunny.pcd"
28 | }
29 |
30 | Add your Pointcloud-Entity to the scenegraph.
31 |
32 | Entity {
33 | id: pointcloud
34 | property Layer layerPoints: Layer {
35 | names: "points"
36 | }
37 | property GeometryRenderer pointcloudMesh: GeometryRenderer {
38 | geometry: PointcloudGeometry { pointcloud: pointcloudreader.pointcloud }
39 | primitiveType: GeometryRenderer.Points
40 | }
41 | property Material materialPoint: PerVertexColorMaterial {}
42 | components: [ pointcloudMesh, materialPoint, meshTransform, layerPoints ]
43 | }
44 |
45 | The layer is needed to identify pointclouds in the framegraph:
46 |
47 | FrameGraph {
48 | (...)
49 | LayerFilter {
50 | layers: ["points"]
51 | StateSet {
52 | renderStates: [
53 | //PointSize { specification: PointSize.StaticValue; value: 5 /*pixels*/ },
54 | PointSize { specification: PointSize.Programmable },
55 | DepthTest { func: DepthTest.Less },
56 | DepthMask { mask: true }
57 | ]
58 | }
59 | }
60 | (...)
61 | }
62 |
63 | Instead of PerVertexColorMaterial, a custom shader can be used to enable programmable per vertex point size:
64 |
65 | property Material materialPoint: Material {
66 | effect: Effect {
67 | techniques: Technique {
68 | renderPasses: RenderPass {
69 | shaderProgram: ShaderProgram {
70 | vertexShaderCode: loadSource("qrc:/shader/pointcloud.vert")
71 | fragmentShaderCode: loadSource("qrc:/shader/pointcloud.frag")
72 | }
73 | }
74 | }
75 | }
76 | parameters: Parameter { name: "pointSize"; value: 0.1 }
77 | }
78 |
79 |
--------------------------------------------------------------------------------
/example/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | project(Qt3DPointcloudRenderer_example)
2 | cmake_minimum_required(VERSION 2.8)
3 |
4 | # Note, that this is pcl-free
5 |
6 | find_package(Qt5Core REQUIRED)
7 | find_package(Qt5Gui REQUIRED)
8 | find_package(Qt5Qml REQUIRED)
9 | find_package(Qt5Widgets REQUIRED)
10 | find_package(Qt5Quick REQUIRED)
11 | find_package(Qt53DCore REQUIRED)
12 | find_package(Qt53DInput REQUIRED)
13 | find_package(Qt53DLogic REQUIRED)
14 | find_package(Qt53DQuick REQUIRED)
15 | find_package(Qt53DRender REQUIRED)
16 | find_package(Qt53DQuickInput REQUIRED)
17 | find_package(Qt53DQuickRender REQUIRED)
18 |
19 | include_directories(${PROJECT_SOURCE_DIR}/src/)
20 |
21 | QT5_ADD_RESOURCES(RESOURCES_RCC qml.qrc)
22 |
23 | set(SOURCE
24 | ${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp
25 | )
26 | set(QML
27 | ${CMAKE_CURRENT_SOURCE_DIR}/qml/main.qml
28 | )
29 | file(GLOB_RECURSE SHADER
30 | ${CMAKE_CURRENT_SOURCE_DIR}/shader/*
31 | )
32 | file(GLOB_RECURSE DATA
33 | ${CMAKE_CURRENT_SOURCE_DIR}/data/*
34 | )
35 |
36 | add_executable(Qt3DPointcloudRenderer_example ${SOURCE} ${RESOURCES_RCC} ${QML} ${SHADER} ${data})
37 |
38 | target_link_libraries(Qt3DPointcloudRenderer_example Qt3DPointcloudRenderer)
39 |
40 | qt5_use_modules(Qt3DPointcloudRenderer_example
41 | Gui
42 | Widgets
43 | Qml
44 | Quick
45 | 3DCore
46 | 3DInput
47 | 3DLogic
48 | 3DQuick
49 | 3DRender
50 | 3DQuickInput
51 | 3DQuickRender)
52 |
53 | execute_process(
54 | COMMAND "${CMAKE_COMMAND}" "-E" "create_symlink" ${CMAKE_CURRENT_SOURCE_DIR}/data ${CMAKE_CURRENT_BINARY_DIR}/data
55 | )
56 |
--------------------------------------------------------------------------------
/example/data/bunny.pcd:
--------------------------------------------------------------------------------
1 | # .PCD v.5 - Point Cloud Data file format
2 | VERSION .5
3 | FIELDS x y z
4 | SIZE 4 4 4
5 | TYPE F F F
6 | COUNT 1 1 1
7 | WIDTH 397
8 | HEIGHT 1
9 | POINTS 397
10 | DATA ascii
11 | 0.0054216 0.11349 0.040749
12 | -0.0017447 0.11425 0.041273
13 | -0.010661 0.11338 0.040916
14 | 0.026422 0.11499 0.032623
15 | 0.024545 0.12284 0.024255
16 | 0.034137 0.11316 0.02507
17 | 0.02886 0.11773 0.027037
18 | 0.02675 0.12234 0.017605
19 | 0.03575 0.1123 0.019109
20 | 0.015982 0.12307 0.031279
21 | 0.0079813 0.12438 0.032798
22 | 0.018101 0.11674 0.035493
23 | 0.0086687 0.11758 0.037538
24 | 0.01808 0.12536 0.026132
25 | 0.0080861 0.12866 0.02619
26 | 0.02275 0.12146 0.029671
27 | -0.0018689 0.12456 0.033184
28 | -0.011168 0.12376 0.032519
29 | -0.0020063 0.11937 0.038104
30 | -0.01232 0.11816 0.037427
31 | -0.0016659 0.12879 0.026782
32 | -0.011971 0.12723 0.026219
33 | 0.016484 0.12828 0.01928
34 | 0.0070921 0.13103 0.018415
35 | 0.0014615 0.13134 0.017095
36 | -0.013821 0.12886 0.019265
37 | -0.01725 0.11202 0.040077
38 | -0.074556 0.13415 0.051046
39 | -0.065971 0.14396 0.04109
40 | -0.071925 0.14545 0.043266
41 | -0.06551 0.13624 0.042195
42 | -0.071112 0.13767 0.047518
43 | -0.079528 0.13416 0.051194
44 | -0.080421 0.14428 0.042793
45 | -0.082672 0.1378 0.046806
46 | -0.08813 0.13514 0.042222
47 | -0.066325 0.12347 0.050729
48 | -0.072399 0.12662 0.052364
49 | -0.066091 0.11973 0.050881
50 | -0.072012 0.11811 0.052295
51 | -0.062433 0.12627 0.043831
52 | -0.068326 0.12998 0.048875
53 | -0.063094 0.11811 0.044399
54 | -0.071301 0.11322 0.04841
55 | -0.080515 0.12741 0.052034
56 | -0.078179 0.1191 0.051116
57 | -0.085216 0.12609 0.049001
58 | -0.089538 0.12621 0.044589
59 | -0.082659 0.11661 0.04797
60 | -0.089536 0.11784 0.04457
61 | -0.0565 0.15248 0.030132
62 | -0.055517 0.15313 0.026915
63 | -0.03625 0.17198 0.00017688
64 | -0.03775 0.17198 0.00022189
65 | -0.03625 0.16935 0.00051958
66 | -0.033176 0.15711 0.0018682
67 | -0.051913 0.1545 0.011273
68 | -0.041707 0.16642 0.0030522
69 | -0.049468 0.16414 0.0041988
70 | -0.041892 0.15669 0.0054879
71 | -0.051224 0.15878 0.0080283
72 | -0.062417 0.15317 0.033161
73 | -0.07167 0.15319 0.033701
74 | -0.062543 0.15524 0.027405
75 | -0.07211 0.1555 0.027645
76 | -0.078663 0.15269 0.032268
77 | -0.081569 0.15374 0.026085
78 | -0.08725 0.1523 0.022135
79 | -0.05725 0.15568 0.010325
80 | -0.057888 0.1575 0.0073225
81 | -0.0885 0.15223 0.019215
82 | -0.056129 0.14616 0.03085
83 | -0.054705 0.13555 0.032127
84 | -0.054144 0.14714 0.026275
85 | -0.046625 0.13234 0.021909
86 | -0.05139 0.13694 0.025787
87 | -0.018278 0.12238 0.030773
88 | -0.021656 0.11643 0.035209
89 | -0.031921 0.11566 0.032851
90 | -0.021348 0.12421 0.024562
91 | -0.03241 0.12349 0.023293
92 | -0.024869 0.12094 0.028745
93 | -0.031747 0.12039 0.028229
94 | -0.052912 0.12686 0.034968
95 | -0.041672 0.11564 0.032998
96 | -0.052037 0.1168 0.034582
97 | -0.042495 0.12488 0.024082
98 | -0.047946 0.12736 0.028108
99 | -0.042421 0.12035 0.028633
100 | -0.047661 0.12024 0.028871
101 | -0.035964 0.1513 0.0005395
102 | -0.050598 0.1474 0.013881
103 | -0.046375 0.13293 0.018289
104 | -0.049125 0.13856 0.016269
105 | -0.042976 0.14915 0.0054003
106 | -0.047965 0.14659 0.0086783
107 | -0.022926 0.1263 0.018077
108 | -0.031583 0.1259 0.017804
109 | -0.041733 0.12796 0.01665
110 | -0.061482 0.14698 0.036168
111 | -0.071729 0.15026 0.038328
112 | -0.060526 0.1368 0.035999
113 | -0.082619 0.14823 0.035955
114 | -0.087824 0.14449 0.033779
115 | -0.089 0.13828 0.037774
116 | -0.085662 0.15095 0.028208
117 | -0.089601 0.14725 0.025869
118 | -0.090681 0.13748 0.02369
119 | -0.058722 0.12924 0.038992
120 | -0.060075 0.11512 0.037685
121 | -0.091812 0.12767 0.038703
122 | -0.091727 0.11657 0.039619
123 | -0.093164 0.12721 0.025211
124 | -0.093938 0.12067 0.024399
125 | -0.091583 0.14522 0.01986
126 | -0.090929 0.13667 0.019817
127 | -0.093094 0.11635 0.018959
128 | 0.024948 0.10286 0.041418
129 | 0.0336 0.092627 0.040463
130 | 0.02742 0.096386 0.043312
131 | 0.03392 0.086911 0.041034
132 | 0.028156 0.086837 0.045084
133 | 0.03381 0.078604 0.040854
134 | 0.028125 0.076874 0.045059
135 | 0.0145 0.093279 0.05088
136 | 0.0074817 0.09473 0.052315
137 | 0.017407 0.10535 0.043139
138 | 0.0079536 0.10633 0.042968
139 | 0.018511 0.097194 0.047253
140 | 0.0086436 0.099323 0.048079
141 | -0.0020197 0.095698 0.053906
142 | -0.011446 0.095169 0.053862
143 | -0.001875 0.10691 0.043455
144 | -0.011875 0.10688 0.043019
145 | -0.0017622 0.10071 0.046648
146 | -0.012498 0.10008 0.045916
147 | 0.016381 0.085894 0.051642
148 | 0.0081167 0.08691 0.055228
149 | 0.017644 0.076955 0.052372
150 | 0.008125 0.076853 0.055536
151 | 0.020575 0.088169 0.049006
152 | 0.022445 0.075721 0.049563
153 | -0.0017931 0.086849 0.056843
154 | -0.011943 0.086771 0.057009
155 | -0.0019567 0.076863 0.057803
156 | -0.011875 0.076964 0.057022
157 | 0.03325 0.067541 0.040033
158 | 0.028149 0.066829 0.042953
159 | 0.026761 0.057829 0.042588
160 | 0.023571 0.04746 0.040428
161 | 0.015832 0.067418 0.051639
162 | 0.0080431 0.066902 0.055006
163 | 0.013984 0.058886 0.050416
164 | 0.0080973 0.056888 0.05295
165 | 0.020566 0.065958 0.0483
166 | 0.018594 0.056539 0.047879
167 | 0.012875 0.052652 0.049689
168 | -0.0017852 0.066712 0.056503
169 | -0.011785 0.066885 0.055015
170 | -0.001875 0.056597 0.05441
171 | -0.01184 0.057054 0.052714
172 | -0.015688 0.052469 0.049615
173 | 0.0066154 0.04993 0.051259
174 | 0.018088 0.046655 0.043321
175 | 0.008841 0.045437 0.046623
176 | 0.017688 0.039719 0.043084
177 | 0.008125 0.039516 0.045374
178 | -0.0016111 0.049844 0.05172
179 | -0.01245 0.046773 0.050903
180 | -0.013851 0.039778 0.051036
181 | -0.0020294 0.044874 0.047587
182 | -0.011653 0.04686 0.048661
183 | -0.0018611 0.039606 0.047339
184 | -0.0091545 0.03958 0.049415
185 | 0.043661 0.094028 0.02252
186 | 0.034642 0.10473 0.031831
187 | 0.028343 0.1072 0.036339
188 | 0.036339 0.096552 0.034843
189 | 0.031733 0.099372 0.038505
190 | 0.036998 0.10668 0.026781
191 | 0.032875 0.11108 0.02959
192 | 0.040938 0.097132 0.026663
193 | 0.044153 0.086466 0.024241
194 | 0.05375 0.072221 0.020429
195 | 0.04516 0.076574 0.023594
196 | 0.038036 0.086663 0.035459
197 | 0.037861 0.076625 0.035658
198 | 0.042216 0.087237 0.028254
199 | 0.042355 0.076747 0.02858
200 | 0.043875 0.096228 0.015269
201 | 0.044375 0.096797 0.0086445
202 | 0.039545 0.1061 0.017655
203 | 0.042313 0.10009 0.017237
204 | 0.045406 0.087417 0.015604
205 | 0.055118 0.072639 0.017944
206 | 0.048722 0.07376 0.017434
207 | 0.045917 0.086298 0.0094211
208 | 0.019433 0.1096 0.039063
209 | 0.01097 0.11058 0.039648
210 | 0.046657 0.057153 0.031337
211 | 0.056079 0.066335 0.024122
212 | 0.048168 0.06701 0.026298
213 | 0.056055 0.057253 0.024902
214 | 0.051163 0.056662 0.029137
215 | 0.036914 0.067032 0.036122
216 | 0.033 0.06472 0.039903
217 | 0.038004 0.056507 0.033119
218 | 0.030629 0.054915 0.038484
219 | 0.041875 0.066383 0.028357
220 | 0.041434 0.06088 0.029632
221 | 0.044921 0.049904 0.031243
222 | 0.054635 0.050167 0.022044
223 | 0.04828 0.04737 0.025845
224 | 0.037973 0.048347 0.031456
225 | 0.028053 0.047061 0.035991
226 | 0.025595 0.040346 0.03415
227 | 0.038455 0.043509 0.028278
228 | 0.032031 0.043278 0.029253
229 | 0.036581 0.040335 0.025144
230 | 0.03019 0.039321 0.026847
231 | 0.059333 0.067891 0.017361
232 | 0.0465 0.071452 0.01971
233 | 0.059562 0.057747 0.01834
234 | 0.055636 0.049199 0.019173
235 | 0.0505 0.045064 0.019181
236 | 0.023 0.047803 0.039776
237 | 0.022389 0.03886 0.038795
238 | -0.019545 0.0939 0.052205
239 | -0.021462 0.10618 0.042059
240 | -0.031027 0.10395 0.041228
241 | -0.022521 0.097723 0.045194
242 | -0.031858 0.097026 0.043878
243 | -0.043262 0.10412 0.040891
244 | -0.052154 0.10404 0.040972
245 | -0.041875 0.096944 0.042424
246 | -0.051919 0.096967 0.043563
247 | -0.021489 0.086672 0.054767
248 | -0.027 0.083087 0.050284
249 | -0.02107 0.077249 0.054365
250 | -0.026011 0.089634 0.048981
251 | -0.031893 0.087035 0.044169
252 | -0.025625 0.074892 0.047102
253 | -0.03197 0.0769 0.042177
254 | -0.041824 0.086954 0.043295
255 | -0.051825 0.086844 0.044933
256 | -0.041918 0.076728 0.042564
257 | -0.051849 0.076877 0.042992
258 | -0.061339 0.10393 0.041164
259 | -0.072672 0.10976 0.044294
260 | -0.061784 0.096825 0.043327
261 | -0.070058 0.096203 0.041397
262 | -0.080439 0.11091 0.044343
263 | -0.061927 0.086724 0.04452
264 | -0.070344 0.087352 0.041908
265 | -0.06141 0.077489 0.042178
266 | -0.068579 0.080144 0.041024
267 | -0.019045 0.067732 0.052388
268 | -0.017742 0.058909 0.050809
269 | -0.023548 0.066382 0.045226
270 | -0.03399 0.067795 0.040929
271 | -0.02169 0.056549 0.045164
272 | -0.036111 0.060706 0.040407
273 | -0.041231 0.066951 0.041392
274 | -0.048588 0.070956 0.040357
275 | -0.0403 0.059465 0.040446
276 | -0.02192 0.044965 0.052258
277 | -0.029187 0.043585 0.051088
278 | -0.021919 0.039826 0.053521
279 | -0.030331 0.039749 0.052133
280 | -0.021998 0.049847 0.046725
281 | -0.031911 0.046848 0.045187
282 | -0.035276 0.039753 0.047529
283 | -0.042016 0.044823 0.041594
284 | -0.05194 0.044707 0.043498
285 | -0.041928 0.039327 0.043582
286 | -0.051857 0.039252 0.046212
287 | -0.059453 0.04424 0.042862
288 | -0.060765 0.039087 0.044363
289 | -0.024273 0.11038 0.039129
290 | -0.032379 0.10878 0.037952
291 | -0.041152 0.10853 0.037969
292 | -0.051698 0.10906 0.038258
293 | -0.062091 0.10877 0.038274
294 | -0.071655 0.10596 0.037516
295 | -0.074634 0.097746 0.038347
296 | -0.07912 0.10508 0.032308
297 | -0.080203 0.096758 0.033592
298 | -0.08378 0.10568 0.025985
299 | -0.087292 0.10314 0.020825
300 | -0.08521 0.097079 0.02781
301 | -0.088082 0.096456 0.022985
302 | -0.07516 0.08604 0.038816
303 | -0.064577 0.073455 0.03897
304 | -0.072279 0.076416 0.036413
305 | -0.076375 0.072563 0.02873
306 | -0.080031 0.087076 0.03429
307 | -0.078919 0.079371 0.032477
308 | -0.084834 0.086686 0.026974
309 | -0.087891 0.089233 0.022611
310 | -0.081048 0.077169 0.025829
311 | -0.086393 0.10784 0.018635
312 | -0.087672 0.10492 0.017264
313 | -0.089333 0.098483 0.01761
314 | -0.086375 0.083067 0.018607
315 | -0.089179 0.089186 0.018947
316 | -0.082879 0.076109 0.017794
317 | -0.0825 0.074674 0.0071175
318 | -0.026437 0.064141 0.039321
319 | -0.030035 0.06613 0.038942
320 | -0.026131 0.056531 0.038882
321 | -0.031664 0.056657 0.037742
322 | -0.045716 0.064541 0.039166
323 | -0.051959 0.066869 0.036733
324 | -0.042557 0.055545 0.039026
325 | -0.049406 0.056892 0.034344
326 | -0.0555 0.062391 0.029498
327 | -0.05375 0.058574 0.026313
328 | -0.03406 0.050137 0.038577
329 | -0.041741 0.04959 0.03929
330 | -0.050975 0.049435 0.036965
331 | -0.053 0.051065 0.029209
332 | -0.054145 0.054568 0.012257
333 | -0.055848 0.05417 0.0083272
334 | -0.054844 0.049295 0.011462
335 | -0.05615 0.050619 0.0092929
336 | -0.061451 0.068257 0.035376
337 | -0.069725 0.069958 0.032788
338 | -0.062823 0.063322 0.026886
339 | -0.071037 0.066787 0.025228
340 | -0.060857 0.060568 0.022643
341 | -0.067 0.061558 0.020109
342 | -0.0782 0.071279 0.021032
343 | -0.062116 0.045145 0.037802
344 | -0.065473 0.039513 0.037964
345 | -0.06725 0.03742 0.033413
346 | -0.072702 0.065008 0.018701
347 | -0.06145 0.059165 0.018731
348 | -0.0675 0.061479 0.019221
349 | -0.057411 0.054114 0.0038257
350 | -0.079222 0.070654 0.017735
351 | -0.062473 0.04468 0.01111
352 | -0.06725 0.042258 0.010414
353 | -0.066389 0.040515 0.01316
354 | -0.068359 0.038502 0.011958
355 | -0.061381 0.04748 0.007607
356 | -0.068559 0.043549 0.0081576
357 | -0.070929 0.03983 0.0085888
358 | -0.016625 0.18375 -0.019735
359 | -0.015198 0.17471 -0.018868
360 | -0.015944 0.16264 -0.0091037
361 | -0.015977 0.1607 -0.0088072
362 | -0.013251 0.16708 -0.015264
363 | -0.014292 0.16098 -0.011252
364 | -0.013986 0.184 -0.023739
365 | -0.011633 0.17699 -0.023349
366 | -0.0091029 0.16988 -0.021457
367 | -0.025562 0.18273 -0.0096247
368 | -0.02725 0.18254 -0.0094384
369 | -0.025736 0.17948 -0.0089653
370 | -0.031216 0.17589 -0.0051154
371 | -0.020399 0.1845 -0.014943
372 | -0.021339 0.17645 -0.014566
373 | -0.027125 0.17234 -0.010156
374 | -0.03939 0.1733 -0.0023575
375 | -0.022876 0.16406 -0.0078103
376 | -0.031597 0.16651 -0.0049292
377 | -0.0226 0.15912 -0.003799
378 | -0.030372 0.15767 -0.0012672
379 | -0.021158 0.16849 -0.012383
380 | -0.027 0.1712 -0.01022
381 | -0.041719 0.16813 -0.00074958
382 | -0.04825 0.16748 -0.00015191
383 | -0.03725 0.16147 -7.2628e-05
384 | -0.066429 0.15783 -0.0085673
385 | -0.071284 0.15839 -0.005998
386 | -0.065979 0.16288 -0.017792
387 | -0.071623 0.16384 -0.01576
388 | -0.066068 0.16051 -0.013567
389 | -0.073307 0.16049 -0.011832
390 | -0.077 0.16204 -0.019241
391 | -0.077179 0.15851 -0.01495
392 | -0.073691 0.17286 -0.037944
393 | -0.07755 0.17221 -0.039175
394 | -0.065921 0.16586 -0.025022
395 | -0.072095 0.16784 -0.024725
396 | -0.066 0.16808 -0.030916
397 | -0.073448 0.17051 -0.032045
398 | -0.07777 0.16434 -0.025938
399 | -0.077893 0.16039 -0.021299
400 | -0.078211 0.169 -0.034566
401 | -0.034667 0.15131 -0.00071029
402 | -0.066117 0.17353 -0.047453
403 | -0.071986 0.17612 -0.045384
404 | -0.06925 0.182 -0.055026
405 | -0.064992 0.17802 -0.054645
406 | -0.069935 0.17983 -0.051988
407 | -0.07793 0.17516 -0.0444
408 |
--------------------------------------------------------------------------------
/example/data/bunny_normal.pcd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MASKOR/Qt3DPointcloudRenderer/72ab626e01d4255f97344638b20abfd196cc5e08/example/data/bunny_normal.pcd
--------------------------------------------------------------------------------
/example/qml.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | qml/main.qml
4 | shader/pointcloud.frag
5 | shader/pointcloud.vert
6 | shader/surfel.frag
7 | shader/surfel.vert
8 |
9 |
10 |
--------------------------------------------------------------------------------
/example/qml/main.qml:
--------------------------------------------------------------------------------
1 | import QtQuick 2.4
2 | import QtQuick.Controls 1.3
3 | import QtQuick.Layouts 1.1
4 | import QtGraphicalEffects 1.0
5 | import QtQuick.Scene3D 2.0
6 | import Qt3D.Core 2.0 as Q3D
7 | import Qt3D.Render 2.0
8 | import Qt3D.Input 2.0
9 | import Qt3D.Extras 2.0
10 |
11 | import pcl 1.0
12 |
13 | ApplicationWindow {
14 | id: window
15 | title: qsTr("Map Visualization")
16 | width: 1200
17 | height: 800
18 | visible: true
19 |
20 | PointcloudReader {
21 | id: readerBunny
22 | filename: "data/bunny.pcd"
23 | }
24 | PointcloudReader {
25 | id: readerBunnyNormal
26 | filename: "data/bunny_normal.pcd"
27 | }
28 |
29 | GridLayout {
30 | anchors.fill: parent
31 | Scene3D {
32 | id: scene3d
33 | Layout.minimumWidth: 50
34 | Layout.fillWidth: true
35 | Layout.fillHeight: true
36 | aspects: ["input", "logic"]
37 | cameraAspectRatioMode: Scene3D.AutomaticAspectRatio
38 | focus: true
39 | Q3D.Entity {
40 | id: sceneRoot
41 |
42 | Camera {
43 | id: mainCamera
44 | projectionType: CameraLens.PerspectiveProjection
45 | fieldOfView: 75
46 | aspectRatio: scene3d.width/scene3d.height
47 | nearPlane : 0.1
48 | farPlane : 1000.0
49 | position: Qt.vector3d( 0.0, 0.0, -20.0 )
50 | upVector: Qt.vector3d( 0.0, 1.0, 0.0 )
51 | viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 )
52 | }
53 |
54 | FirstPersonCameraController {
55 | //OrbitCameraController {
56 | camera: mainCamera
57 | }
58 |
59 | components: [
60 | RenderSettings {
61 | activeFrameGraph: Viewport {
62 | id: viewport
63 | normalizedRect: Qt.rect(0.0, 0.0, 1.0, 1.0) // From Top Left
64 | RenderSurfaceSelector {
65 | CameraSelector {
66 | id : cameraSelector
67 | camera: mainCamera
68 | FrustumCulling {
69 | ClearBuffers {
70 | buffers : ClearBuffers.ColorDepthBuffer
71 | clearColor: "white"
72 | NoDraw {}
73 | }
74 | LayerFilter {
75 | layers: solidLayer
76 | }
77 | LayerFilter {
78 | layers: pointLayer
79 | RenderStateSet {
80 | renderStates: [
81 | // If this is uncommented, following pointsizes are ignored in Qt5.7
82 | //PointSize { sizeMode: PointSize.Fixed; value: 5.0 }, // exception when closing application in qt 5.7. Moreover PointSize
83 | //PointSize { sizeMode: PointSize.Programmable }, //supported since OpenGL 3.2
84 | DepthTest { depthFunction: DepthTest.Less }
85 | //DepthMask { mask: true }
86 | ]
87 | }
88 | }
89 | LayerFilter {
90 | layers: surfelLayer
91 | RenderStateSet {
92 | renderStates: [
93 | PointSize { sizeMode: PointSize.Programmable }, //supported since OpenGL 3.2
94 | DepthTest { depthFunction: DepthTest.Less }
95 | //DepthMask { mask: true }
96 | ]
97 | }
98 | }
99 | }
100 | }
101 | }
102 | }
103 | },
104 | // Event Source will be set by the Qt3DQuickWindow
105 | InputSettings {
106 | eventSource: window
107 | enabled: true
108 | }
109 | ]
110 |
111 | PhongMaterial {
112 | id: phongMaterial
113 | }
114 |
115 | TorusMesh {
116 | id: torusMesh
117 | radius: 5
118 | minorRadius: 1
119 | rings: 100
120 | slices: 20
121 | }
122 |
123 | Q3D.Transform {
124 | id: torusTransform
125 | scale3D: Qt.vector3d(2.5, 2.5, 2.5)
126 | //rotation: fromAxisAndAngle(Qt.vector3d(1, 0, 0), 45)
127 | }
128 |
129 | Layer {
130 | id: solidLayer
131 | }
132 | Layer {
133 | id: pointLayer
134 | }
135 | Q3D.Entity {
136 | id: torusEntity
137 | components: [ solidLayer, torusMesh, phongMaterial, torusTransform ]
138 | }
139 |
140 | Q3D.Entity {
141 | id: pointcloud
142 | property var meshTransform: Q3D.Transform {
143 | id: pointcloudTransform
144 | property real userAngle: rotator.rotationAnimation
145 | scale: 20
146 | translation: Qt.vector3d(0, -2, 0)
147 | rotation: fromAxisAndAngle(Qt.vector3d(0, 1, 0), userAngle)
148 | }
149 | property GeometryRenderer pointcloudMesh: GeometryRenderer {
150 | geometry: PointcloudGeometry { pointcloud: readerBunny.pointcloud }
151 | primitiveType: GeometryRenderer.Points
152 | }
153 | property Material materialPoint: Material {
154 | effect: Effect {
155 | techniques: Technique {
156 | renderPasses: RenderPass {
157 | shaderProgram: ShaderProgram {
158 | vertexShaderCode: loadSource("qrc:/shader/pointcloud.vert")
159 | fragmentShaderCode: loadSource("qrc:/shader/pointcloud.frag")
160 | }
161 | }
162 | }
163 | }
164 | parameters: Parameter { name: "pointSize"; value: 0.7 }
165 | }
166 | //property Material materialPoint: PerVertexColorMaterial {}
167 | components: [ pointcloudMesh, materialPoint, meshTransform, pointLayer ]
168 | }
169 |
170 | Q3D.Entity {
171 | id: pointcloudSurfel
172 | property Layer layerPoints: Layer {
173 | id: surfelLayer
174 | }
175 | property var meshTransform: Q3D.Transform {
176 | id: pointcloudSurfelTransform
177 | property real userAngle: rotator.rotationAnimation
178 | scale: 20
179 | translation: Qt.vector3d(0, 2, 0)
180 | rotation: fromAxisAndAngle(Qt.vector3d(0, 1, 0), userAngle)
181 | }
182 | property GeometryRenderer surfelMesh: GeometryRenderer {
183 | geometry: PointcloudGeometry { pointcloud: readerBunnyNormal.pointcloud }
184 | primitiveType: GeometryRenderer.Points
185 | }
186 | property Material materialSurfel: Material {
187 | effect: Effect {
188 | techniques: Technique {
189 | renderPasses: RenderPass {
190 | shaderProgram: ShaderProgram {
191 | vertexShaderCode: loadSource("qrc:/shader/surfel.vert")
192 | fragmentShaderCode: loadSource("qrc:/shader/surfel.frag")
193 | }
194 | }
195 | }
196 | }
197 | parameters: [
198 | Parameter { name: "pointSize"; value: 0.06 },
199 | Parameter { name: "fieldOfView"; value: mainCamera.fieldOfView },
200 | Parameter { name: "fieldOfViewVertical"; value: mainCamera.fieldOfView/mainCamera.aspectRatio },
201 | Parameter { name: "nearPlane"; value: mainCamera.nearPlane },
202 | Parameter { name: "farPlane"; value: mainCamera.farPlane },
203 | Parameter { name: "width"; value: scene3d.width },
204 | Parameter { name: "height"; value: scene3d.height }
205 | ]
206 | }
207 | components: [ surfelMesh, materialSurfel, meshTransform, surfelLayer ]
208 | }
209 | }
210 | }
211 | }
212 | NumberAnimation {
213 | id: rotator
214 | property real rotationAnimation
215 | target: rotator
216 | property: "rotationAnimation"
217 | duration: 10000
218 | from: -180
219 | to: 180
220 |
221 | loops: Animation.Infinite
222 | running: true
223 | }
224 |
225 | SystemPalette {
226 | id: palette
227 | }
228 | }
229 |
--------------------------------------------------------------------------------
/example/shader/pointcloud.frag:
--------------------------------------------------------------------------------
1 | #version 130
2 |
3 | in vec3 normal;
4 | in vec3 position;
5 | in vec3 color;
6 |
7 | uniform vec3 finalColor;
8 |
9 | out vec4 fragColor;
10 |
11 | void main()
12 | {
13 | // vec3 n = normalize(normal);
14 | // vec3 s = normalize(vec3(1.0, 0.0, 1.0) - position);
15 | // vec3 v = normalize(-position);
16 | // float diffuse = max(dot(s, n), 0.0);
17 | // fragColor = vec4(diffuse * finalColor, 1.0);
18 | // fragColor = vec4(0.0, 0.0, 0.0, 1.0);
19 | fragColor = vec4(color, 1.0);
20 | }
21 |
--------------------------------------------------------------------------------
/example/shader/pointcloud.vert:
--------------------------------------------------------------------------------
1 | #version 130
2 |
3 | in vec3 vertexPosition;
4 | in vec3 vertexNormal;
5 | in vec3 vertexColor;
6 |
7 | out vec3 position;
8 | out vec3 normal;
9 | out vec3 color;
10 |
11 | uniform mat4 modelView;
12 | uniform mat3 modelViewNormal;
13 | uniform mat4 mvp;
14 | uniform mat4 projectionMatrix;
15 | uniform mat4 viewportMatrix;
16 |
17 | uniform float pointSize;
18 |
19 | void main()
20 | {
21 | normal = normalize(modelViewNormal * vertexNormal);
22 | position = vec3(modelView * vec4(vertexPosition, 1.0));
23 | color = vertexPosition * 0.1;//vertexColor;
24 | gl_Position = mvp * vec4(vertexPosition, 1.0);
25 | gl_PointSize = viewportMatrix[1][1] * projectionMatrix[1][1] * pointSize / gl_Position.w;
26 | }
27 |
--------------------------------------------------------------------------------
/example/shader/surfel.frag:
--------------------------------------------------------------------------------
1 | #version 150
2 |
3 | uniform mat4 modelView;
4 | uniform mat4 viewMatrix;
5 | uniform mat3 modelViewNormal;
6 | uniform mat4 mvp;
7 | uniform mat4 projectionMatrix;
8 | uniform mat4 inverseProjectionMatrix;
9 | uniform mat4 viewportMatrix;
10 | uniform float nearPlane;
11 | uniform float farPlane;
12 | uniform float width;
13 | uniform float height;
14 |
15 | in vec3 viewspacePosition;
16 | in vec3 viewspaceNormal;
17 | in vec3 viewspaceTang;
18 | in vec3 viewspaceBitang;
19 | in vec3 color;
20 |
21 |
22 | uniform float pointSize;
23 |
24 | out vec4 fragColor;
25 |
26 | void main(void)
27 | {
28 |
29 | // vec3 eyePos = vec3(viewPoint.xy+(gl_PointCoord.xy - vec2(0.5))*2.0, viewPoint.z); //< this is not enough. perspective division was skipped?
30 | // unproject
31 | vec3 ndcPos;
32 | ndcPos.xy = gl_FragCoord.xy / vec2(width, height);
33 | ndcPos.z = 0.0;
34 | ndcPos -= 0.5;
35 | ndcPos *= 2.0;
36 | vec4 clipPos;
37 | clipPos.w = projectionMatrix[3][2] / (ndcPos.z - (projectionMatrix[2][2] / projectionMatrix[2][3]));
38 | //clipPos.w = (2.0 * nearPlane * farPlane / ((nearPlane + farPlane) + ndcPos.z * (nearPlane - farPlane)));
39 | clipPos.xyz = ndcPos * clipPos.w;
40 | vec3 viewspacePositionFragment = vec3(inverseProjectionMatrix * clipPos);
41 |
42 | vec3 normal = normalize(viewspaceNormal);
43 |
44 | // line plane intersection
45 | // t = ( dot(N,O) + d ) / ( dot(N,D) )
46 | // p = O + t*D
47 | // vec3 O = vec3(0.0);
48 | vec3 ray_dir = normalize(viewspacePositionFragment);
49 | float d = dot(normal, viewspacePosition);
50 | float t = d / dot(normal, ray_dir);
51 | vec3 p = t * ray_dir;
52 | // float distSphere = length(cross(ray_dir, viewspacePosition)); //< sphere
53 | float distDisc = distance(p, viewspacePosition); //< disc
54 | float dist = distDisc;
55 | if(pointSize <= dist) discard;
56 |
57 | fragColor.rgb = color.rgb;
58 | fragColor.a = 1.0;//smoothstep(pointSize*0.5+fwidth(dist), pointSize*0.5, dist);
59 | //if(fragColor.a <= 0.0) discard;
60 |
61 | // todo: fix
62 | //vec3 pp = projectionMatrix * p;
63 | //vec4 reprojeced_ndc_pos = projectionmatrix * -p;
64 | //float ndc_depth = reprojeced_ndc_pos.z / reprojeced_ndc_pos.w;
65 |
66 | //float depth = (((viewport.w-viewport.z) * ndc_depth) + viewport.z + viewport.w) / 2.0;
67 | //gl_FragDepth = depth;
68 | }
69 |
--------------------------------------------------------------------------------
/example/shader/surfel.vert:
--------------------------------------------------------------------------------
1 | #version 150
2 |
3 | in vec3 vertexPosition;
4 | in vec3 vertexNormal;
5 | in vec3 vertexColor;
6 |
7 | uniform mat4 modelView;
8 | uniform mat3 modelViewNormal;
9 | uniform mat4 mvp;
10 | uniform mat4 projectionMatrix;
11 | uniform mat4 viewportMatrix;
12 | uniform float fieldOfView;
13 | uniform float fieldOfViewVertical;
14 |
15 | out vec3 viewspacePosition;
16 | out vec3 viewspaceNormal;
17 | out vec3 viewspaceTang;
18 | out vec3 viewspaceBitang;
19 | out vec3 color;
20 |
21 | uniform float pointSize;
22 |
23 | vec4 hsv_to_rgb(float h, float s, float v, float a)
24 | {
25 | float c = v * s;
26 | h = mod((h * 6.0), 6.0);
27 | float x = c * (1.0 - abs(mod(h, 2.0) - 1.0));
28 | vec4 color;
29 |
30 | if (0.0 <= h && h < 1.0) {
31 | color = vec4(c, x, 0.0, a);
32 | } else if (1.0 <= h && h < 2.0) {
33 | color = vec4(x, c, 0.0, a);
34 | } else if (2.0 <= h && h < 3.0) {
35 | color = vec4(0.0, c, x, a);
36 | } else if (3.0 <= h && h < 4.0) {
37 | color = vec4(0.0, x, c, a);
38 | } else if (4.0 <= h && h < 5.0) {
39 | color = vec4(x, 0.0, c, a);
40 | } else if (5.0 <= h && h < 6.0) {
41 | color = vec4(c, 0.0, x, a);
42 | } else {
43 | color = vec4(0.0, 0.0, 0.0, a);
44 | }
45 |
46 | color.rgb += v - c;
47 |
48 | return color;
49 | }
50 |
51 | void main(void)
52 | {
53 | vec4 viewSpacePos = modelView * vec4(vertexPosition, 1.0);
54 | viewspacePosition = viewSpacePos.xyz;
55 | viewspaceNormal = modelViewNormal * vertexNormal;
56 | viewspaceTang = normalize(cross(viewspaceNormal, vec3(0.0,0.0,1.0))); //longest radius
57 | viewspaceBitang = normalize(cross(viewspaceTang, viewspaceNormal)); //smallest radius
58 | gl_Position = projectionMatrix * viewSpacePos;
59 |
60 | // VERY SLOW
61 | //vec2 csize = max(max(max(max(max(abs(Ap.xy-Bp.xy), abs(Ap.xy-Cp.xy)), abs(Ap.xy-Dp.xy)), abs(Bp.xy-Cp.xy)), abs(Bp.xy-Dp.xy)), abs(Cp.xy-Dp.xy));
62 |
63 | float dist = -viewSpacePos.z; // == gl_Position.w
64 |
65 | // x2 would be perfect. But the smaller the points are, the better performance is.
66 | gl_PointSize = 1.9 * viewportMatrix[1][1] * projectionMatrix[1][1] * pointSize / gl_Position.w;
67 | color = hsv_to_rgb(vertexPosition.y*10.0, 1.0, 1.0, 0.0).rgb;// * 0.1;
68 | }
69 |
--------------------------------------------------------------------------------
/example/src/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include "qpointcloud.h"
7 | #include "qpointcloudgeometry.h"
8 | #include "qpointfield.h"
9 | #include "qpointcloudreader.h"
10 |
11 | int main(int argc, char *argv[])
12 | {
13 | QGuiApplication app(argc, argv);
14 |
15 | qmlRegisterType("pcl", 1, 0, "PointcloudReader");
16 | qmlRegisterType("pcl", 1, 0, "Pointcloud");
17 | qmlRegisterType("pcl", 1, 0, "PointcloudGeometry");
18 | qmlRegisterUncreatableType("pcl", 1, 0, "Pointfield", "Can not yet be created in qml, use PointcloudReader.");
19 | QQmlApplicationEngine engine;
20 | engine.load(QUrl(QStringLiteral("qrc:///qml/main.qml")));
21 |
22 | int result = app.exec();
23 | return result;
24 | }
25 |
26 | #ifdef _WIN32
27 | int WINAPI WinMain(HINSTANCE hinst, HINSTANCE, LPSTR argv, int argc)
28 | {
29 | // int argc=1;
30 | // char *argv[] = {"temp"};
31 | return main(argc, &argv);
32 | }
33 | #endif
34 |
--------------------------------------------------------------------------------
/include/qpointcloud.h:
--------------------------------------------------------------------------------
1 | #ifndef QPOINTCLOUD_H
2 | #define QPOINTCLOUD_H
3 |
4 | #include
5 | #include
6 | #include
7 | #include "qpointfield.h"
8 |
9 |
10 | #if WITH_PCL
11 | namespace pcl
12 | {
13 | class PCLPointCloud2;
14 | }
15 | #endif
16 |
17 | #if WITH_LAS
18 | namespace liblas
19 | {
20 | class Reader;
21 | }
22 | #endif
23 |
24 | class QPointcloudPrivate;
25 | class QPointcloud : public QObject
26 | {
27 | Q_OBJECT
28 | Q_PROPERTY(quint32 height READ height WRITE setHeight NOTIFY heightChanged)
29 | Q_PROPERTY(quint32 width READ width WRITE setWidth NOTIFY widthChanged)
30 | Q_PROPERTY(QQmlListProperty fields READ fields NOTIFY fieldsChanged)
31 | Q_PROPERTY(quint8 is_bigendian READ is_bigendian WRITE setIs_bigendian NOTIFY is_bigendianChanged)
32 | Q_PROPERTY(quint32 point_step READ point_step WRITE setPoint_step NOTIFY point_stepChanged)
33 | Q_PROPERTY(quint32 row_step READ row_step WRITE setRow_step NOTIFY row_stepChanged)
34 | Q_PROPERTY(QByteArray data READ data WRITE setData NOTIFY dataChanged)
35 | Q_PROPERTY(quint8 is_dense READ is_dense WRITE setIs_dense NOTIFY is_denseChanged)
36 | Q_PROPERTY(QVector3D minimum READ minimum NOTIFY minimumChanged)
37 | Q_PROPERTY(QVector3D maximum READ maximum NOTIFY maximumChanged)
38 | Q_PROPERTY(QVector3D centroid READ centroid NOTIFY centroidChanged)
39 | Q_PROPERTY(QVector3D offset READ offset NOTIFY offsetChanged)
40 | public:
41 | QPointcloud(QPointcloud *copy);
42 | QPointcloud(QObject *parent = NULL);
43 | ////
44 | /// \brief QPointcloud takes ownership of the given pointcloud
45 | /// \param pointcloud will be deleted in destructor. Do not use shared pointer pcl::PCLPointcloud2Ptr from outside.
46 | ///
47 | QPointcloud(pcl::PCLPointCloud2 *pointcloud);
48 | ~QPointcloud();
49 |
50 | void updateAttributes();
51 |
52 | quint32 height() const;
53 | quint32 width() const;
54 |
55 | QQmlListProperty fields();
56 |
57 | quint8 is_bigendian() const;
58 | quint32 point_step() const;
59 | quint32 row_step() const;
60 | QByteArray data() const;
61 | quint8 is_dense() const;
62 |
63 | const QList &getFields();
64 |
65 | #if WITH_PCL
66 | pcl::PCLPointCloud2* pointcloud();
67 | void setPointcloud(const pcl::PCLPointCloud2 ©);
68 | #endif
69 | #if WITH_LAS
70 | ///
71 | /// \brief read Reads a LAS dataset. LAS files often have big offsets which cannot be expressed using float.
72 | /// Thus, an offset must be applied in order to have floatingpoint data which can be visualized.
73 | /// This offset must be either known in advance or must be caluclated in this method
74 | /// (before conversion to floats happens).
75 | /// \param reader the liblas::Reader
76 | /// \param useOffset use the provided offset or output the calculated offset
77 | /// \param offset this is _substracted_ from every point. Offset of pointcloud to viewing coordinate system.
78 | /// \param demean calculate new offset. This overrides useOffset.
79 | /// \param normalize resize the pointcloud to fit a box with size normalizeScale in each direction. This overrides useOffset.
80 | /// \param normalizeScale size to bring the normalized model to.
81 | /// \param flipYZ if visualization uses Y axis up and pointcloud uses Z axis up, this must be true. Should not be used.
82 | /// \param nth only read in every nth point (fake level of detail).
83 | ///
84 | void read(liblas::Reader* reader
85 | , const bool useOffset = false
86 | , double *offsetX = nullptr
87 | , double *offsetY = nullptr
88 | , double *offsetZ = nullptr
89 | , bool demean = false
90 | , bool normalize = false
91 | , float normalizeScale = 1.0f
92 | , bool flipYZ = false
93 | , int nth = 1);
94 | #endif
95 |
96 | void readXyz(QString &path, bool demean = true, bool normalize = true, float normalizeScale = 10.f, bool flipYZ = true);
97 | QVector3D minimum() const;
98 | QVector3D maximum() const;
99 | QVector3D centroid() const;
100 | QVector3D offset() const;
101 |
102 | public Q_SLOTS:
103 | void setHeight(quint32 height);
104 | void setWidth(quint32 width);
105 | void setIs_bigendian(quint8 is_bigendian);
106 | void setPoint_step(quint32 point_step);
107 | void setRow_step(quint32 row_step);
108 | void setData(QByteArray data);
109 | void setIs_dense(quint8 is_dense);
110 |
111 | Q_SIGNALS:
112 | void heightChanged(quint32 height);
113 | void widthChanged(quint32 width);
114 | void fieldsChanged(QQmlListProperty fields);
115 | void is_bigendianChanged(quint8 is_bigendian);
116 | void point_stepChanged(quint32 point_step);
117 | void row_stepChanged(quint32 row_step);
118 | void dataChanged(QByteArray data);
119 | void is_denseChanged(quint8 is_dense);
120 | void minimumChanged(QVector3D minimum);
121 | void maximumChanged(QVector3D maximum);
122 | void centroidChanged(QVector3D centroid);
123 | void offsetChanged(QVector3D offset);
124 |
125 | private:
126 | QPointcloudPrivate *m_priv;
127 | };
128 |
129 |
130 |
131 | #endif
132 |
--------------------------------------------------------------------------------
/include/qpointcloudgeometry.h:
--------------------------------------------------------------------------------
1 | #ifndef QPOINTCLOUDGEOMETRY_H
2 | #define QPOINTCLOUDGEOMETRY_H
3 |
4 | #include
5 | #include "qpointcloud.h"
6 |
7 | class QPointcloudGeometryPrivate;
8 |
9 | class QPointcloudGeometry : public Qt3DRender::QGeometry
10 | {
11 | Q_OBJECT
12 | Q_PROPERTY(QPointcloud *pointcloud READ pointcloud WRITE setPointcloud NOTIFY pointcloudChanged)
13 |
14 | public:
15 | explicit QPointcloudGeometry(QNode *parent = NULL);
16 | ~QPointcloudGeometry();
17 | void updateVertices();
18 |
19 | QPointcloud *pointcloud() const;
20 |
21 |
22 | public Q_SLOTS:
23 | void setPointcloud(QPointcloud *pointcloud);
24 | private Q_SLOTS:
25 | void updateAttributes();
26 | Q_SIGNALS:
27 | void pointcloudChanged(QPointcloud *pointcloud);
28 |
29 | private:
30 | QPointcloudGeometryPrivate *m_p;
31 | };
32 |
33 |
34 | #endif
35 |
--------------------------------------------------------------------------------
/include/qpointcloudreader.h:
--------------------------------------------------------------------------------
1 | #ifndef QPOINTCLOUDREADER_H
2 | #define QPOINTCLOUDREADER_H
3 |
4 | #include
5 | #include "qpointcloud.h"
6 |
7 | class QPointCloudReader : public QObject
8 | {
9 | Q_OBJECT
10 | Q_PROPERTY(QString filename READ filename WRITE setFilename NOTIFY filenameChanged)
11 | Q_PROPERTY(QPointcloud *pointcloud READ pointcloud NOTIFY pointcloudChanged)
12 | public:
13 | QPointCloudReader();
14 |
15 | QString filename() const;
16 |
17 | QPointcloud *pointcloud() const;
18 |
19 | public Q_SLOTS:
20 | void setFilename(QString filename);
21 |
22 | Q_SIGNALS:
23 | void filenameChanged(QString filename);
24 | void pointcloudChanged(QPointcloud * pointcloud);
25 |
26 | private:
27 | QString m_filename;
28 | QPointcloud *m_pointcloud;
29 | };
30 |
31 | #endif
32 |
--------------------------------------------------------------------------------
/include/qpointfield.h:
--------------------------------------------------------------------------------
1 | #ifndef QPOINTFIELD_H
2 | #define QPOINTFIELD_H
3 |
4 | #if WITH_PCL
5 | namespace pcl {
6 | class PCLPointField;
7 | }
8 | #endif
9 |
10 | #include
11 |
12 | class QPointfield : public QObject
13 | {
14 | Q_OBJECT
15 | Q_ENUMS(PointFieldTypes)
16 |
17 | Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
18 | Q_PROPERTY(quint32 offset READ offset WRITE setOffset NOTIFY offsetChanged)
19 | Q_PROPERTY(PointFieldTypes datatype READ datatype WRITE setDatatype NOTIFY datatypeChanged)
20 | Q_PROPERTY(quint32 count READ count WRITE setCount NOTIFY countChanged)
21 | public:
22 | enum PointFieldTypes { INT8,
23 | UINT8,
24 | INT16,
25 | UINT16,
26 | INT32,
27 | UINT32,
28 | FLOAT32,
29 | FLOAT64};
30 | #if WITH_PCL
31 | QPointfield(QObject *parent, pcl::PCLPointField *field);
32 | QPointfield(pcl::PCLPointField *field);
33 | #endif
34 | QPointfield(QObject *parent, QString name, quint32 offset, PointFieldTypes type, quint32 count);
35 | //QPointfield(const QPointfield &cpy);
36 | QString name() const;
37 | quint32 offset() const;
38 | PointFieldTypes datatype() const;
39 | quint32 count() const;
40 |
41 | #if WITH_PCL
42 | const pcl::PCLPointField* getPointfield() { return m_pointfield; }
43 | #endif
44 | public Q_SLOTS:
45 |
46 | void setName(QString name);
47 | void setOffset(quint32 offset);
48 | void setDatatype(PointFieldTypes datatype);
49 | void setCount(quint32 count);
50 |
51 | Q_SIGNALS:
52 | void nameChanged(QString name);
53 | void offsetChanged(quint32 offset);
54 | void datatypeChanged(PointFieldTypes datatype);
55 | void countChanged(quint32 count);
56 |
57 | private:
58 |
59 | QString m_name;
60 | quint32 m_offset;
61 | PointFieldTypes m_datatype;
62 | quint32 m_count;
63 | #if WITH_PCL
64 | pcl::PCLPointField *m_pointfield;
65 | #endif
66 | };
67 |
68 | #endif
69 |
--------------------------------------------------------------------------------
/src/qpointcloud.cpp:
--------------------------------------------------------------------------------
1 | #include "qpointcloud.h"
2 | #if WITH_PCL
3 | #include
4 | #include
5 | #include
6 | #include
7 | #endif
8 | #if WITH_LAS
9 | #include
10 | #endif
11 | #include
12 | #include
13 | #include
14 | #include
15 | #include //DBG
16 |
17 | class QPointcloudPrivate
18 | {
19 | public:
20 | QPointcloudPrivate(QPointcloud* p)
21 | : m_parent(p)
22 | , m_pointcloud(nullptr)
23 | , m_width(0)
24 | , m_height(1)
25 | , m_is_bigendian(0)
26 | , m_point_step(0)
27 | , m_row_step(0)
28 | , m_data()
29 | , m_is_dense(0)
30 | , m_minimum()
31 | , m_maximum()
32 | , m_centroid()
33 | , m_offset()
34 | , m_dirtyMinMax(true)
35 | , m_dirtyCentroid(true)
36 | {}
37 | QPointcloud *m_parent;
38 | pcl::PCLPointCloud2 *m_pointcloud;
39 | QList m_fields;
40 |
41 | quint32 m_height;
42 | quint32 m_width;
43 |
44 | quint8 m_is_bigendian;
45 | quint32 m_point_step;
46 | quint32 m_row_step;
47 | QByteArray m_data;
48 | quint8 m_is_dense;
49 |
50 | QVector3D m_minimum;
51 | QVector3D m_maximum;
52 | QVector3D m_centroid;
53 | QVector3D m_offset;
54 | bool m_dirtyMinMax;
55 | bool m_dirtyCentroid;
56 |
57 | static void fields_append(QQmlListProperty *self, QPointfield* f);
58 | static int fields_count(QQmlListProperty *self);
59 | static QPointfield* fields_at(QQmlListProperty *self, int i);
60 | static void fields_clear(QQmlListProperty *self);
61 |
62 | void updateMinMax()
63 | {
64 | #if WITH_PCL
65 | pcl::PointXYZ min;
66 | pcl::PointXYZ max;
67 | pcl::PointCloud pc;
68 | pcl::fromPCLPointCloud2( *m_pointcloud, pc);
69 | pcl::getMinMax3D(pc, min, max);
70 | m_minimum = QVector3D(min.x, min.y, min.z);
71 | m_maximum = QVector3D(max.x, max.y, max.z);
72 | m_dirtyMinMax = false;
73 | #endif
74 | #if WITH_LAS
75 | //already done on read
76 | m_dirtyMinMax = false;
77 | #endif
78 | }
79 | void updateCentroid()
80 | {
81 |
82 | }
83 |
84 | // void updateFields()
85 | // {
86 | // for(QList::iterator qiter(m_fields.begin()) ; qiter != m_fields.end() ; qiter++)
87 | // {
88 | // (*qiter)->deleteLater();
89 | // }
90 | // m_fields.clear();
91 | //#if WITH_PCL
92 | // if(m_pointcloud)
93 | // {
94 | // for(std::vector< ::pcl::PCLPointField>::iterator iter(m_pointcloud->fields.begin());
95 | // iter != m_pointcloud->fields.end(); iter++)
96 | // {
97 | // m_fields.append( new QPointfield(m_parent, &(*iter) ) );
98 | // }
99 | // }
100 | // #if WITH_LAS
101 | // else
102 | // #endif
103 | //#endif
104 | //#if WITH_LAS
105 | // {
106 | // // Standard LAS fields
107 | // QPointfield *f;
108 | // f = new QPointfield(m_parent, "x", 0, QPointfield::FLOAT32, 1);
109 | // f = new QPointfield(m_parent, "y", 8, QPointfield::FLOAT32, 1);
110 | // f = new QPointfield(m_parent, "z", 16, QPointfield::FLOAT32, 1);
111 | // f = new QPointfield(m_parent, "intensity", 24, QPointfield::FLOAT32, 1);
112 | // }
113 | //#endif
114 | // //else TODO: completely custom format for pointclouds
115 | // }
116 | };
117 |
118 | QPointcloud::QPointcloud(QPointcloud *copy)
119 | :m_priv(new QPointcloudPrivate(this))
120 | {
121 | #if WITH_PCL
122 | this->setPointcloud( *copy->m_priv->m_pointcloud );
123 | #endif
124 | }
125 |
126 | QPointcloud::QPointcloud(QObject *parent)
127 | :QObject(parent),
128 | m_priv(new QPointcloudPrivate(this))
129 | {
130 | #if WITH_PCL
131 | //m_priv->m_pointcloud = new pcl::PCLPointCloud2();
132 | #endif
133 | }
134 |
135 | #if WITH_PCL
136 | QPointcloud::QPointcloud(pcl::PCLPointCloud2 *pointcloud)
137 | :m_priv(new QPointcloudPrivate(this))
138 | {
139 | m_priv->m_pointcloud = pointcloud;
140 | }
141 | #endif
142 |
143 | QPointcloud::~QPointcloud()
144 | {
145 | #if WITH_PCL
146 | if(m_priv->m_pointcloud != nullptr)
147 | {
148 | delete m_priv->m_pointcloud;
149 | }
150 | #endif
151 | delete m_priv;
152 | }
153 |
154 | void QPointcloud::updateAttributes()
155 | {
156 | #if WITH_PCL
157 | if(m_priv->m_pointcloud)
158 | {
159 | m_priv->m_fields.clear();
160 | for(int i=0 ; m_priv->m_pointcloud->fields.size() >i ; ++i)
161 | {
162 | pcl::PCLPointField &pf( m_priv->m_pointcloud->fields[i] );
163 | m_priv->m_fields.append(new QPointfield(&pf));
164 | }
165 | }
166 | else
167 | #endif
168 | {
169 | // LAS Attributes are read when LAS is read
170 | }
171 | }
172 |
173 | quint32 QPointcloud::height() const
174 | {
175 | #if WITH_PCL
176 | if(m_priv->m_pointcloud)
177 | {
178 | return m_priv->m_pointcloud->height;
179 | }
180 | else
181 | #endif
182 | {
183 | return m_priv->m_height;
184 | }
185 | }
186 |
187 | quint32 QPointcloud::width() const
188 | {
189 | #if WITH_PCL
190 | if(m_priv->m_pointcloud)
191 | {
192 | return m_priv->m_pointcloud->width;
193 | }
194 | else
195 | #endif
196 | {
197 | return m_priv->m_width;
198 | }
199 | }
200 |
201 | QQmlListProperty QPointcloud::fields()
202 | {
203 | return QQmlListProperty(this, static_cast(m_priv), &QPointcloudPrivate::fields_append, &QPointcloudPrivate::fields_count, &QPointcloudPrivate::fields_at, &QPointcloudPrivate::fields_clear);
204 | }
205 |
206 | void QPointcloudPrivate::fields_append(QQmlListProperty *self, QPointfield *f)
207 | {
208 | QPointcloudPrivate *that = static_cast(self->data);
209 | #if WITH_PCL
210 | if(that->m_pointcloud)
211 | {
212 | // This is not typical for PCL. PCL would create a new pointcloud instead.
213 | // if this is needed, there should be a conversion from PCL Pointcloud to a
214 | // custom pointcloud format.
215 | Q_ASSERT_X(false, "QPointcloud::fields_append", "Must not be called.");
216 | pcl::PCLPointCloud2 *p = static_cast(that->m_pointcloud);
217 | p->fields.push_back(*f->getPointfield());
218 | }
219 | else
220 | #endif
221 | {
222 | that->m_fields.append(f);
223 | }
224 | }
225 |
226 | int QPointcloudPrivate::fields_count(QQmlListProperty *self)
227 | {
228 | QPointcloudPrivate *that = static_cast(self->data);
229 | #if WITH_PCL
230 | if(that->m_pointcloud)
231 | {
232 | Q_ASSERT_X(that->m_fields.count() == 0, "QPointcloudPrivate::fields_count", "Mixed up pcl and non pcl.");
233 | pcl::PCLPointCloud2 *p = static_cast(that->m_pointcloud);
234 | return p->fields.size();
235 | }
236 | else
237 | #endif
238 | {
239 | that->m_fields.count();
240 | }
241 | }
242 |
243 | QPointfield *QPointcloudPrivate::fields_at(QQmlListProperty *self, int i)
244 | {
245 | QPointcloudPrivate *that = static_cast(self->data);
246 | #if WITH_PCL
247 | if(that->m_pointcloud)
248 | {
249 | Q_ASSERT_X(that->m_fields.count() == 0, "QPointcloudPrivate::fields_count", "Mixed up pcl and non pcl.");
250 | pcl::PCLPointCloud2 *p = static_cast(that->m_pointcloud);
251 | return new QPointfield(&p->fields.at(i));
252 | }
253 | else
254 | #endif
255 | {
256 | that->m_fields.at(i);
257 | }
258 | }
259 |
260 | void QPointcloudPrivate::fields_clear(QQmlListProperty *self)
261 | {
262 | QPointcloudPrivate *that = static_cast(self->data);
263 | #if WITH_PCL
264 | if(that->m_pointcloud)
265 | {
266 | Q_ASSERT_X(that->m_fields.count() == 0, "QPointcloudPrivate::fields_count", "Mixed up pcl and non pcl.");
267 | pcl::PCLPointCloud2 *p = static_cast(that->m_pointcloud);
268 | p->fields.clear();
269 | }
270 | else
271 | #endif
272 | {
273 | that->m_fields.clear();
274 | }
275 | }
276 |
277 | quint8 QPointcloud::is_bigendian() const
278 | {
279 | #if WITH_PCL
280 | if(m_priv->m_pointcloud)
281 | {
282 | return m_priv->m_pointcloud->is_bigendian;
283 | }
284 | else
285 | #endif
286 | {
287 | return m_priv->m_is_bigendian;
288 | }
289 | }
290 |
291 | quint32 QPointcloud::point_step() const
292 | {
293 | #if WITH_PCL
294 | if(m_priv->m_pointcloud)
295 | {
296 | return m_priv->m_pointcloud->point_step;
297 | }
298 | else
299 | #endif
300 | {
301 | return m_priv->m_point_step;
302 | }
303 | }
304 |
305 | quint32 QPointcloud::row_step() const
306 | {
307 | #if WITH_PCL
308 | if(m_priv->m_pointcloud)
309 | {
310 | return m_priv->m_pointcloud->row_step;
311 | }
312 | else
313 | #endif
314 | {
315 | return m_priv->m_row_step;
316 | }
317 | }
318 |
319 | QByteArray QPointcloud::data() const
320 | {
321 | #if WITH_PCL
322 | if(m_priv->m_pointcloud)
323 | {
324 | return QByteArray(reinterpret_cast(&m_priv->m_pointcloud->data[0]), m_priv->m_pointcloud->data.size());
325 | //return QByteArray::fromRawData(reinterpret_cast(&m_priv->m_pointcloud->data[0]), m_priv->m_pointcloud->data.size());
326 | }
327 | else
328 | #endif
329 | {
330 | return m_priv->m_data;
331 | }
332 | }
333 |
334 | quint8 QPointcloud::is_dense() const
335 | {
336 | #if WITH_PCL
337 | if(m_priv->m_pointcloud)
338 | {
339 | return m_priv->m_pointcloud->is_dense;
340 | }
341 | else
342 | #endif
343 | {
344 | return m_priv->m_is_dense;
345 | }
346 | }
347 |
348 | const QList &QPointcloud::getFields()
349 | {
350 | return m_priv->m_fields;
351 | }
352 |
353 | #if WITH_PCL
354 | pcl::PCLPointCloud2 *QPointcloud::pointcloud()
355 | {
356 | if(nullptr == m_priv->m_pointcloud)
357 | {
358 | m_priv->m_pointcloud = new pcl::PCLPointCloud2();
359 | }
360 | return m_priv->m_pointcloud;
361 | }
362 |
363 | void QPointcloud::setPointcloud(const pcl::PCLPointCloud2& copy)
364 | {
365 | if(m_priv->m_pointcloud != nullptr)
366 | {
367 | delete m_priv->m_pointcloud;
368 | }
369 | m_priv->m_pointcloud = new pcl::PCLPointCloud2(copy);
370 | }
371 | #endif
372 |
373 | void QPointcloud::readXyz(QString &path, bool demean, bool normalize, float normalizeScale, bool flipYZ)
374 | {
375 | // Not yet implemented
376 | }
377 |
378 | QVector3D QPointcloud::minimum() const
379 | {
380 | if(m_priv->m_dirtyMinMax)
381 | {
382 | m_priv->updateMinMax();
383 | }
384 | return m_priv->m_minimum;
385 | }
386 |
387 | QVector3D QPointcloud::maximum() const
388 | {
389 | if(m_priv->m_dirtyMinMax)
390 | {
391 | m_priv->updateMinMax();
392 | }
393 | return m_priv->m_maximum;
394 | }
395 |
396 | QVector3D QPointcloud::centroid() const
397 | {
398 | if(m_priv->m_dirtyCentroid)
399 | {
400 | m_priv->updateCentroid();
401 | }
402 | return m_priv->m_centroid;
403 | }
404 |
405 | QVector3D QPointcloud::offset() const
406 | {
407 | return m_priv->m_offset;
408 | }
409 |
410 | #if WITH_LAS
411 | void QPointcloud::read(liblas::Reader *reader
412 | , const bool useOffset
413 | , double *offsetX
414 | , double *offsetY
415 | , double *offsetZ
416 | , bool demean
417 | , bool normalize
418 | , float normalizeScale
419 | , bool flipYZ
420 | , int nth
421 | )
422 | {
423 | const liblas::Header header = reader->GetHeader();
424 | uint32_t points = header.GetPointRecordsCount();
425 |
426 | bool hasData = false;// TODO: check if data is a useful feature. // header.GetDataRecordLength() >= 3;
427 | const size_t pointSize = sizeof(float) * 4 // pos
428 | + sizeof(uint8_t) // intensity
429 | + sizeof(uint32_t) // color
430 | + sizeof(uint8_t) * (hasData ? 3 : 0); // data
431 | m_priv->m_data.resize(points*pointSize/nth);
432 |
433 | setPoint_step(pointSize);
434 | setWidth(points/nth);
435 |
436 | size_t offsetIntens = sizeof(float)*3;
437 | size_t offsetColor = offsetIntens + sizeof(uint16_t);
438 | size_t offsetData = offsetColor + sizeof(QRgb);
439 |
440 | double scale, cx, cy, cz;
441 | double minX = header.GetMinX();
442 | double maxX = header.GetMaxX();
443 | double minY;
444 | double maxY;
445 | double minZ;
446 | double maxZ;
447 | if(flipYZ)
448 | {
449 | minY = header.GetMinZ();
450 | maxY = header.GetMaxZ();
451 | minZ = header.GetMinY();
452 | maxZ = header.GetMaxY();
453 | }
454 | else
455 | {
456 | minY = header.GetMinY();
457 | maxY = header.GetMaxY();
458 | minZ = header.GetMinZ();
459 | maxZ = header.GetMaxZ();
460 | }
461 | if(demean || normalize)
462 | {
463 | double sx = maxX-minX;
464 | double sy = maxY-minY;
465 | double sz = maxZ-minZ;
466 | double maxDim = std::max(std::max(sx, sy), sz);
467 |
468 | if(normalize)
469 | {
470 | scale = normalizeScale / maxDim;
471 | }
472 | else
473 | {
474 | scale = 1.;
475 | }
476 |
477 | cx = minX+sx*0.5;
478 | cy = minY+sy*0.5;
479 | cz = minZ+sz*0.5;
480 | }
481 | else
482 | {
483 | scale = 1.;
484 | if(useOffset)
485 | {
486 | assert(offsetX != nullptr);
487 | assert(offsetY != nullptr);
488 | assert(offsetZ != nullptr);
489 | cx = *offsetX;
490 | cy = *offsetY;
491 | cz = *offsetZ;
492 | }
493 | else
494 | {
495 | cx = header.GetOffsetX();
496 | cy = header.GetOffsetY();
497 | cz = header.GetOffsetZ();
498 | assert(offsetX != nullptr);
499 | assert(offsetY != nullptr);
500 | assert(offsetZ != nullptr);
501 | *offsetX = cx;
502 | *offsetY = cy;
503 | *offsetZ = cz;
504 | }
505 | }
506 | m_priv->m_centroid = QVector3D(cx, cy, cz); // TODO: bounding box center, not really centroid
507 | m_priv->m_minimum = QVector3D(minX-cx, minY-cy, minZ-cz);
508 | m_priv->m_maximum = QVector3D(maxX-cx, maxY-cy, maxZ-cz);
509 | m_priv->m_offset = m_priv->m_centroid;
510 | m_priv->m_dirtyMinMax = false;
511 | m_priv->m_dirtyCentroid = false;
512 |
513 | typedef double (liblas::Point::*GetDimension)() const;
514 | GetDimension dim2, dim3;
515 | if(flipYZ)
516 | {
517 | dim2 = &liblas::Point::GetZ;
518 | dim3 = &liblas::Point::GetY;
519 | }
520 | else
521 | {
522 | dim2 = &liblas::Point::GetY;
523 | dim3 = &liblas::Point::GetZ;
524 | }
525 | m_priv->m_offset = QVector3D(cx, cy, cz);
526 |
527 | // double max[3];
528 | // double min[3];
529 | // for(int i=0 ; i<3 ; ++i)
530 | // {
531 | // min[i] = +std::numeric_limits::infinity();
532 | // max[i] = -std::numeric_limits::infinity();
533 | // }
534 | uint32_t i=0;
535 | uint32_t pointsPos=0;
536 | while(reader->ReadNextPoint())
537 | {
538 | if(i++%nth != 0)
539 | continue;
540 | liblas::Point current(reader->GetPoint());
541 | float value;
542 | // qDebug() << "DBG: x " << current.GetX() << " y: " << current.GetY() << " z: " << current.GetZ();
543 | // qDebug() << "DBG:rx " << current.GetRawX() << " y: " << current.GetRawY() << " z: " << current.GetRawZ();
544 | double x = current.GetX();
545 | double y = (current.*dim2)();
546 | double z = (current.*dim3)();
547 | // if(min[0] > x) min[0] = x;
548 | // if(max[0] < x) max[0] = x;
549 | // if(min[1] > y) min[1] = y;
550 | // if(max[1] < y) max[1] = y;
551 | // if(min[2] > z) min[2] = z;
552 | // if(max[2] < z) max[2] = z;
553 | // if(x > maxX) ++outOfBoundsX1;
554 | // if(x < minX) ++outOfBoundsX2;
555 | // if(y > maxY) ++outOfBoundsY1;
556 | // if(y < minY) ++outOfBoundsY2;
557 | // if(z > maxZ) ++outOfBoundsZ1;
558 | // if(z < minZ) ++outOfBoundsZ2;
559 | value = (x-cx)*scale;
560 | memcpy(&m_priv->m_data.data()[pointsPos], &value, sizeof(float));
561 | value = (y-cy)*scale;
562 | memcpy(&m_priv->m_data.data()[pointsPos+sizeof(float)], &value, sizeof(float));
563 | value = (z-cz)*scale;
564 | memcpy(&m_priv->m_data.data()[pointsPos+sizeof(float)*2], &value, sizeof(float));
565 |
566 | uint16_t intensity = current.GetIntensity();
567 | memcpy(&m_priv->m_data.data()[pointsPos+offsetIntens], &intensity, sizeof(uint16_t));
568 |
569 | liblas::Color color = current.GetColor();
570 | QRgb rgb(qRgb(color.GetRed(), color.GetGreen(), color.GetBlue()));
571 | memcpy(&m_priv->m_data.data()[pointsPos+offsetColor], &rgb, sizeof(QRgb));
572 |
573 | if(hasData)
574 | {
575 | assert(current.GetData().size() >= 3); // In this case header was wrong
576 | memcpy(&m_priv->m_data.data()[pointsPos+offsetData], current.GetData().data(), sizeof(uint8_t)*3);
577 | }
578 | assert(offsetData + sizeof(uint8_t)*3 == pointSize);
579 | pointsPos+=pointSize;
580 | }
581 | // qDebug() << "real bounds: " << min[0] << "|" << max[0] << ","
582 | // << min[1] << "|" << max[1] << ","
583 | // << min[2] << "|" << max[2] << ";";
584 |
585 | QPointfield *f;
586 | f = new QPointfield(this, "x", 0, QPointfield::FLOAT32, i);
587 | m_priv->m_fields.append(f);
588 | f = new QPointfield(this, "y", 4, QPointfield::FLOAT32, i);
589 | m_priv->m_fields.append(f);
590 | f = new QPointfield(this, "z", 8, QPointfield::FLOAT32, i);
591 | m_priv->m_fields.append(f);
592 | f = new QPointfield(this, "intensity", 12, QPointfield::UINT16, i);
593 | m_priv->m_fields.append(f);
594 | f = new QPointfield(this, "color", 14, QPointfield::UINT32, i);
595 | m_priv->m_fields.append(f);
596 | if(hasData)
597 | {
598 | f = new QPointfield(this, "datax", 18, QPointfield::UINT8, i);
599 | m_priv->m_fields.append(f);
600 | f = new QPointfield(this, "datay", 19, QPointfield::UINT8, i);
601 | m_priv->m_fields.append(f);
602 | f = new QPointfield(this, "dataz", 20, QPointfield::UINT8, i);
603 | m_priv->m_fields.append(f);
604 | }
605 | }
606 | #endif
607 |
608 | void QPointcloud::setHeight(quint32 height)
609 | {
610 | #if WITH_PCL
611 | if(m_priv->m_pointcloud)
612 | {
613 | if (m_priv->m_pointcloud->height == height)
614 | return;
615 | m_priv->m_pointcloud->height = height;
616 | }
617 | else
618 | #endif
619 | {
620 | if (m_priv->m_height == height)
621 | return;
622 | m_priv->m_height = height;
623 | }
624 | Q_EMIT heightChanged(height);
625 | }
626 |
627 | void QPointcloud::setWidth(quint32 width)
628 | {
629 | #if WITH_PCL
630 | if(m_priv->m_pointcloud)
631 | {
632 | if (m_priv->m_pointcloud->width == width)
633 | return;
634 | m_priv->m_pointcloud->width = width;
635 | }
636 | else
637 | #endif
638 | {
639 | if (m_priv->m_width == width)
640 | return;
641 | m_priv->m_width = width;
642 | }
643 | Q_EMIT widthChanged(width);
644 | }
645 |
646 | void QPointcloud::setIs_bigendian(quint8 is_bigendian)
647 | {
648 | #if WITH_PCL
649 | if(m_priv->m_pointcloud)
650 | {
651 | if (m_priv->m_pointcloud->is_bigendian == is_bigendian)
652 | return;
653 | m_priv->m_pointcloud->is_bigendian = is_bigendian;
654 | }
655 | else
656 | #endif
657 | {
658 | if (m_priv->m_is_bigendian == is_bigendian)
659 | return;
660 | m_priv->m_is_bigendian = is_bigendian;
661 | }
662 | Q_EMIT is_bigendianChanged(is_bigendian);
663 | }
664 |
665 | void QPointcloud::setPoint_step(quint32 point_step)
666 | {
667 | #if WITH_PCL
668 | if(m_priv->m_pointcloud)
669 | {
670 | if (m_priv->m_pointcloud->point_step == point_step)
671 | return;
672 | m_priv->m_pointcloud->point_step = point_step;
673 | }
674 | else
675 | #endif
676 | {
677 | if (m_priv->m_point_step == point_step)
678 | return;
679 | m_priv->m_point_step = point_step;
680 | }
681 |
682 | Q_EMIT point_stepChanged(point_step);
683 | }
684 |
685 | void QPointcloud::setRow_step(quint32 row_step)
686 | {
687 | #if WITH_PCL
688 | if(m_priv->m_pointcloud)
689 | {
690 | if (m_priv->m_pointcloud->row_step == row_step)
691 | return;
692 |
693 | m_priv->m_pointcloud->row_step = row_step;
694 | }
695 | else
696 | #endif
697 | {
698 | if (m_priv->m_row_step == row_step)
699 | return;
700 | m_priv->m_row_step = row_step;
701 | }
702 | Q_EMIT row_stepChanged(row_step);
703 | }
704 |
705 | void QPointcloud::setData(QByteArray data)
706 | {
707 | #if WITH_PCL
708 | if(m_priv->m_pointcloud)
709 | {
710 | m_priv->m_pointcloud->data.resize(data.size());
711 | memcpy(&m_priv->m_pointcloud->data[0], data.data(), m_priv->m_pointcloud->data.size());
712 | }
713 | else
714 | #endif
715 | {
716 | m_priv->m_data = data;
717 | }
718 | Q_EMIT dataChanged(data);
719 | }
720 |
721 | void QPointcloud::setIs_dense(quint8 is_dense)
722 | {
723 | #if WITH_PCL
724 | if(m_priv->m_pointcloud)
725 | {
726 | if (m_priv->m_pointcloud->is_dense == is_dense)
727 | return;
728 |
729 | m_priv->m_pointcloud->is_dense = is_dense;
730 | }
731 | else
732 | #endif
733 | {
734 | if (m_priv->m_is_dense == is_dense)
735 | return;
736 | m_priv->m_is_dense = is_dense;
737 | }
738 | Q_EMIT is_denseChanged(is_dense);
739 | }
740 |
--------------------------------------------------------------------------------
/src/qpointcloudgeometry.cpp:
--------------------------------------------------------------------------------
1 | #include "qpointcloudgeometry.h"
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 |
10 | #include
11 |
12 | //QByteArray createPointcloudVertexData(pcl::PCLPointCloud2 *pointcloud)
13 | //{
14 | // if(pointcloud == NULL || pointcloud->data.size() == 0)
15 | // return QByteArray();
16 | // //QByteArray arr;
17 | // //arr.append(reinterpret_cast(&pointcloud->data[0]), pointcloud->data.size());
18 | // return QByteArray(reinterpret_cast(&pointcloud->data[0]), pointcloud->data.size());//arr;
19 | //}
20 |
21 | class PointcloudVertexDataGenerator : public Qt3DRender::QBufferDataGenerator /*Qt3DRender::QBufferFunctor*/
22 | {
23 | public:
24 | PointcloudVertexDataGenerator(QPointcloud *pointcloud)
25 | : m_bytes(pointcloud->data())
26 | {
27 | }
28 |
29 | QByteArray operator ()() Q_DECL_OVERRIDE
30 | {
31 | return m_bytes;
32 | }
33 |
34 | bool operator ==(const Qt3DRender::QBufferDataGenerator &other) const Q_DECL_OVERRIDE
35 | {
36 | const PointcloudVertexDataGenerator *otherFunctor = Qt3DRender::functor_cast(&other);
37 | if (otherFunctor != NULL)
38 | return otherFunctor->m_bytes == m_bytes;
39 | return false;
40 | }
41 |
42 | QT3D_FUNCTOR(PointcloudVertexDataGenerator)
43 |
44 | private:
45 | QByteArray m_bytes;
46 | };
47 |
48 | class PointcloudColorVertexDataGenerator : public Qt3DRender::QBufferDataGenerator /*Qt3DRender::QBufferFunctor*/
49 | {
50 | public:
51 | PointcloudColorVertexDataGenerator(QPointcloud *pointcloud, bool isUintRgba, int offset)
52 | : m_pointcloud(new QPointcloud(pointcloud))
53 | , m_isUintRgba(isUintRgba)
54 | , m_colorOffset(offset)
55 | {
56 | }
57 |
58 | QByteArray operator ()() Q_DECL_OVERRIDE
59 | {
60 | int colorChannels = 3;
61 | int size = m_pointcloud->width() * m_pointcloud->height();
62 | int pointStep = m_pointcloud->point_step();
63 | QByteArray data = m_pointcloud->data();
64 | QByteArray colorData;
65 | colorData.resize(sizeof(float)*size*colorChannels);
66 | float *colorDataFloats = reinterpret_cast(colorData.data());
67 | for(int i=m_colorOffset ; i(&other);
81 | if (otherFunctor != NULL)
82 | return otherFunctor->m_pointcloud == m_pointcloud;
83 | return false;
84 | }
85 |
86 | QT3D_FUNCTOR(PointcloudVertexDataGenerator)
87 |
88 | private:
89 | QSharedPointer m_pointcloud;
90 | bool m_isUintRgba;
91 | int m_colorOffset;
92 | };
93 |
94 | class QPointcloudGeometryPrivate
95 | {
96 | public:
97 | QPointcloudGeometryPrivate()
98 | :m_vertexBuffer(NULL)
99 | ,m_colorBuffer(NULL)
100 | ,m_pointcloud(NULL)
101 | ,m_colorOffset(0)
102 | ,m_colorFormatUintRgba(false)
103 | ,m_colorAvailable(false)
104 | {}
105 | Qt3DRender::QBuffer *m_vertexBuffer;
106 | Qt3DRender::QBuffer *m_colorBuffer;
107 | QPointcloud *m_pointcloud;
108 | int m_colorOffset;
109 | bool m_colorFormatUintRgba;
110 | bool m_colorAvailable;
111 | };
112 |
113 | QPointcloudGeometry::QPointcloudGeometry(Qt3DCore::QNode *parent)
114 | :m_p(new QPointcloudGeometryPrivate)
115 | {
116 | m_p->m_vertexBuffer = new Qt3DRender::QBuffer(Qt3DRender::QBuffer::VertexBuffer, this);
117 | m_p->m_colorBuffer = new Qt3DRender::QBuffer(Qt3DRender::QBuffer::VertexBuffer, this);
118 | }
119 |
120 | QPointcloudGeometry::~QPointcloudGeometry()
121 | {
122 | delete m_p;
123 | }
124 |
125 | Qt3DRender::QAttribute::VertexBaseType pclTypeToAttributeType(const QPointfield::PointFieldTypes &inp)
126 | {
127 | switch(inp)
128 | {
129 | case QPointfield::INT8:
130 | return Qt3DRender::QAttribute::Byte;
131 | case QPointfield::INT16:
132 | return Qt3DRender::QAttribute::Short;
133 | case QPointfield::INT32:
134 | return Qt3DRender::QAttribute::Int;
135 | case QPointfield::UINT8:
136 | return Qt3DRender::QAttribute::UnsignedByte;
137 | case QPointfield::UINT16:
138 | return Qt3DRender::QAttribute::UnsignedShort;
139 | case QPointfield::UINT32:
140 | return Qt3DRender::QAttribute::UnsignedInt;
141 | case QPointfield::FLOAT32:
142 | return Qt3DRender::QAttribute::Float;
143 | case QPointfield::FLOAT64:
144 | return Qt3DRender::QAttribute::Double;
145 | default:
146 | Q_ASSERT(false);
147 | return Qt3DRender::QAttribute::Float;
148 | }
149 | }
150 |
151 | void QPointcloudGeometry::updateVertices()
152 | {
153 | if(
154 | #if WITH_PCL
155 | ( m_p->m_pointcloud == NULL
156 | || m_p->m_pointcloud->pointcloud() == NULL
157 | || m_p->m_pointcloud->pointcloud()->data.size() == 0)
158 | &&
159 | #endif
160 | ( m_p->m_pointcloud->data().length() == 0))
161 | return;
162 |
163 | // if(m_p->m_vertexBuffer)
164 | // {
165 | // m_p->m_vertexBuffer->deleteLater();
166 | // }
167 |
168 | //m_p->m_vertexBuffer->setBufferFunctor(Qt3DRender::QBufferFunctorPtr(new PointcloudVertexDataFunctor(m_p->m_pointcloud->pointcloud())));
169 |
170 | updateAttributes();
171 | //QMetaObject::invokeMethod(this, "updateAttributes", Qt::QueuedConnection);
172 | m_p->m_vertexBuffer->setDataGenerator(Qt3DRender::QBufferDataGeneratorPtr(new PointcloudVertexDataGenerator(this->m_p->m_pointcloud)));
173 | if(m_p->m_colorAvailable) {
174 | m_p->m_colorBuffer->setDataGenerator(Qt3DRender::QBufferDataGeneratorPtr(new PointcloudColorVertexDataGenerator(this->m_p->m_pointcloud, m_p->m_colorFormatUintRgba, m_p->m_colorOffset)));
175 | }
176 | }
177 |
178 | QPointcloud *QPointcloudGeometry::pointcloud() const
179 | {
180 | return m_p->m_pointcloud;
181 | }
182 |
183 | void QPointcloudGeometry::updateAttributes()
184 | {
185 | // completely rebuild attribute list and remove all previous attributes
186 | QVector atts = attributes();
187 | Q_FOREACH(Qt3DRender::QAttribute *attr, atts)
188 | {
189 | if(attr->attributeType() == Qt3DRender::QAttribute::VertexAttribute)
190 | {
191 | removeAttribute(attr);
192 | attr->deleteLater();
193 | }
194 | else
195 | {
196 | qDebug() << "skipped index";
197 | }
198 | }
199 |
200 | // Prepare hash table to query attribute names easily
201 | QHash pfs;
202 | m_p->m_pointcloud->updateAttributes();
203 |
204 | const QList &fieldList = m_p->m_pointcloud->getFields();
205 | for(auto fieldIter = fieldList.cbegin(); fieldIter != fieldList.cend() ; ++fieldIter)
206 | {
207 | pfs.insert((*fieldIter)->name(), *fieldIter);
208 | }
209 | m_p->m_colorAvailable = false;
210 |
211 | // parse point fields and make reasonable attributes out of them
212 | QHash::const_iterator pf(pfs.find("x"));
213 | if(pf != pfs.cend())
214 | {
215 | int num = 1 + (pfs.contains("y")?1:0) + (pfs.contains("z")?1:0) + (pfs.contains("w")?1:0);
216 | Qt3DRender::QAttribute* attrib = new Qt3DRender::QAttribute(nullptr);
217 | attrib->setName(Qt3DRender::QAttribute::defaultPositionAttributeName());
218 | attrib->setDataType(pclTypeToAttributeType((*pf)->datatype()));
219 | attrib->setDataSize(num);
220 | attrib->setAttributeType(Qt3DRender::QAttribute::VertexAttribute);
221 | attrib->setBuffer(m_p->m_vertexBuffer);
222 | attrib->setByteStride(m_p->m_pointcloud->point_step());
223 | attrib->setByteOffset((*pf)->offset());
224 | attrib->setCount(m_p->m_pointcloud->width() * m_p->m_pointcloud->height());
225 | addAttribute(attrib);
226 | setBoundingVolumePositionAttribute(attrib);
227 | }
228 | pf = pfs.find("rgb");
229 | if(pf != pfs.cend())
230 | {
231 | int num = 3;
232 | Qt3DRender::QAttribute* attrib = new Qt3DRender::QAttribute(nullptr);
233 | attrib->setName(Qt3DRender::QAttribute::defaultColorAttributeName());
234 | attrib->setDataType(Qt3DRender::QAttribute::Float);
235 | attrib->setDataSize(num);
236 | attrib->setAttributeType(Qt3DRender::QAttribute::VertexAttribute);
237 | attrib->setBuffer(m_p->m_colorBuffer);
238 | attrib->setByteStride(num * sizeof(float));
239 | attrib->setByteOffset(0);
240 | attrib->setCount(m_p->m_pointcloud->width() * m_p->m_pointcloud->height());
241 | addAttribute(attrib);
242 | m_p->m_colorOffset = (*pf)->offset();
243 | m_p->m_colorFormatUintRgba = false;
244 | m_p->m_colorAvailable = true;
245 | }
246 | pf = pfs.find("rgba");
247 | if(pf != pfs.cend())
248 | {
249 | int num = 3;
250 | Qt3DRender::QAttribute* attrib = new Qt3DRender::QAttribute(nullptr);
251 | attrib->setName(Qt3DRender::QAttribute::defaultColorAttributeName());
252 | attrib->setDataType(Qt3DRender::QAttribute::Float);
253 | attrib->setDataSize(num);
254 | attrib->setAttributeType(Qt3DRender::QAttribute::VertexAttribute);
255 | attrib->setBuffer(m_p->m_colorBuffer);
256 | attrib->setByteStride(num * sizeof(float));
257 | attrib->setByteOffset(0);
258 | attrib->setCount(m_p->m_pointcloud->width() * m_p->m_pointcloud->height());
259 | addAttribute(attrib);
260 | m_p->m_colorOffset = (*pf)->offset();
261 | m_p->m_colorFormatUintRgba = true;
262 | m_p->m_colorAvailable = true;
263 | }
264 | pf = pfs.find("normal_x");
265 | if(pf != pfs.cend())
266 | {
267 | int num = 1 + (pfs.contains("normal_y")?1:0) + (pfs.contains("normal_z")?1:0) + (pfs.contains("curvature")?1:0);
268 | Qt3DRender::QAttribute* attrib = new Qt3DRender::QAttribute(nullptr);
269 | attrib->setName(Qt3DRender::QAttribute::defaultNormalAttributeName());
270 | attrib->setDataType(pclTypeToAttributeType((*pf)->datatype()));
271 | attrib->setDataSize(num);
272 | attrib->setAttributeType(Qt3DRender::QAttribute::VertexAttribute);
273 | attrib->setBuffer(m_p->m_vertexBuffer);
274 | attrib->setByteStride(m_p->m_pointcloud->point_step());
275 | attrib->setByteOffset((*pf)->offset());
276 | attrib->setCount(m_p->m_pointcloud->width() * m_p->m_pointcloud->height());
277 | addAttribute(attrib);
278 | }
279 | pf = pfs.find("intensity");
280 | if(pf != pfs.cend())
281 | {
282 | Qt3DRender::QAttribute* attrib = new Qt3DRender::QAttribute(nullptr);
283 | attrib->setName("intensity");
284 | attrib->setDataType(pclTypeToAttributeType((*pf)->datatype()));
285 | attrib->setDataSize(1);
286 | attrib->setAttributeType(Qt3DRender::QAttribute::VertexAttribute);
287 | attrib->setBuffer(m_p->m_vertexBuffer);
288 | attrib->setByteStride(m_p->m_pointcloud->point_step());
289 | attrib->setByteOffset((*pf)->offset());
290 | attrib->setCount(m_p->m_pointcloud->width() * m_p->m_pointcloud->height());
291 | addAttribute(attrib);
292 | }
293 | }
294 |
295 | void QPointcloudGeometry::setPointcloud(QPointcloud *pointcloud)
296 | {
297 | if (m_p->m_pointcloud == pointcloud)
298 | return;
299 |
300 | m_p->m_pointcloud = pointcloud;
301 | updateVertices();
302 | Q_EMIT pointcloudChanged(pointcloud);
303 | }
304 |
--------------------------------------------------------------------------------
/src/qpointcloudreader.cpp:
--------------------------------------------------------------------------------
1 | #include "qpointcloudreader.h"
2 | #include "pcl/io/pcd_io.h"
3 | #include "pcl/io/ply_io.h"
4 | #include
5 |
6 | QPointCloudReader::QPointCloudReader()
7 | :m_pointcloud(new QPointcloud())
8 | {
9 | }
10 |
11 | QString QPointCloudReader::filename() const
12 | {
13 | return m_filename;
14 | }
15 |
16 | QPointcloud *QPointCloudReader::pointcloud() const
17 | {
18 | return m_pointcloud;
19 | }
20 |
21 | void QPointCloudReader::setFilename(QString filename)
22 | {
23 | if (m_filename == filename)
24 | return;
25 |
26 | if(filename.endsWith(".pcd", Qt::CaseInsensitive))
27 | {
28 | pcl::PCDReader reader;
29 | reader.read(filename.toStdString(), *m_pointcloud->pointcloud());
30 | }
31 | else if(filename.endsWith(".ply", Qt::CaseInsensitive))
32 | {
33 | pcl::PLYReader reader;
34 | reader.read(filename.toStdString(), *m_pointcloud->pointcloud());
35 | }
36 | qDebug() << "Read Pointcloud" << filename << "with" << ((m_pointcloud->pointcloud()->width) * (m_pointcloud->pointcloud()->height)) << "points.";
37 | m_filename = filename;
38 | Q_EMIT filenameChanged(filename);
39 | Q_EMIT pointcloudChanged(m_pointcloud);
40 | }
41 |
--------------------------------------------------------------------------------
/src/qpointfield.cpp:
--------------------------------------------------------------------------------
1 | #include "qpointfield.h"
2 |
3 | #if WITH_PCL
4 | #include
5 |
6 | pcl::uint8_t toPCLDatatype(const QPointfield::PointFieldTypes& datatype)
7 | {
8 | switch(datatype)
9 | {
10 | case QPointfield::INT8:
11 | return pcl::PCLPointField::INT8;
12 | case QPointfield::UINT8:
13 | return pcl::PCLPointField::UINT8;
14 | case QPointfield::INT16:
15 | return pcl::PCLPointField::INT16;
16 | case QPointfield::UINT16:
17 | return pcl::PCLPointField::UINT16;
18 | case QPointfield::INT32:
19 | return pcl::PCLPointField::INT32;
20 | case QPointfield::UINT32:
21 | return pcl::PCLPointField::UINT32;
22 | case QPointfield::FLOAT32:
23 | return pcl::PCLPointField::FLOAT32;
24 | case QPointfield::FLOAT64:
25 | return pcl::PCLPointField::FLOAT64;
26 | }
27 | Q_ASSERT_X(false, "fromPCLDatatype", "unknown PCL pointfield");
28 | return pcl::PCLPointField::INT8;
29 | }
30 | QPointfield::PointFieldTypes fromPCLDatatype(const pcl::uint8_t &datatype)
31 | {
32 | switch(datatype)
33 | {
34 | case pcl::PCLPointField::INT8:
35 | return QPointfield::INT8;
36 | case pcl::PCLPointField::UINT8:
37 | return QPointfield::UINT8;
38 | case pcl::PCLPointField::INT16:
39 | return QPointfield::INT16;
40 | case pcl::PCLPointField::UINT16:
41 | return QPointfield::UINT16;
42 | case pcl::PCLPointField::INT32:
43 | return QPointfield::INT32;
44 | case pcl::PCLPointField::UINT32:
45 | return QPointfield::UINT32;
46 | case pcl::PCLPointField::FLOAT32:
47 | return QPointfield::FLOAT32;
48 | case pcl::PCLPointField::FLOAT64:
49 | return QPointfield::FLOAT64;
50 | }
51 | Q_ASSERT_X(false, "toPCLDatatype", "unknown pointfield");
52 | return QPointfield::INT8;
53 | }
54 | #endif
55 |
56 | #if WITH_PCL
57 | QPointfield::QPointfield(QObject *parent, pcl::PCLPointField *field)
58 | :QObject(parent)
59 | ,m_name(field->name.c_str())
60 | ,m_offset(field->offset)
61 | ,m_datatype(fromPCLDatatype(field->datatype))
62 | ,m_count(field->count)
63 | ,m_pointfield(field)
64 | {
65 | }
66 |
67 | QPointfield::QPointfield(pcl::PCLPointField *field)
68 | :m_name(field->name.c_str())
69 | ,m_offset(field->offset)
70 | ,m_datatype(fromPCLDatatype(field->datatype))
71 | ,m_count(field->count)
72 | ,m_pointfield(field)
73 | {
74 | }
75 | #endif
76 |
77 | QPointfield::QPointfield(QObject *parent, QString name, quint32 offset, PointFieldTypes type, quint32 count)
78 | :QObject(parent)
79 | ,m_name(name)
80 | ,m_offset(offset)
81 | ,m_datatype(type)
82 | ,m_count(count)
83 | #if WITH_PCL
84 | // Note, there is no way to obtain a pcl point field, if it is not given in constructor.
85 | ,m_pointfield(nullptr)
86 | #endif
87 | {
88 | }
89 |
90 | QString QPointfield::name() const
91 | {
92 | return m_name;
93 | }
94 |
95 | quint32 QPointfield::offset() const
96 | {
97 | return m_offset;
98 | }
99 |
100 | QPointfield::PointFieldTypes QPointfield::datatype() const
101 | {
102 | return m_datatype;
103 | }
104 |
105 | quint32 QPointfield::count() const
106 | {
107 | return m_count;
108 | }
109 |
110 | void QPointfield::setName(QString name)
111 | {
112 | if (m_name == name)
113 | return;
114 | m_name = name;
115 | #if WITH_PCL
116 | if(m_pointfield)
117 | {
118 | std::string stdname(name.toStdString());
119 | m_pointfield->name = stdname;
120 | }
121 | #endif
122 | Q_EMIT nameChanged(name);
123 | }
124 |
125 | void QPointfield::setOffset(quint32 offset)
126 | {
127 | if (m_offset == offset)
128 | return;
129 | m_offset = offset;
130 | #if WITH_PCL
131 | if(m_pointfield)
132 | {
133 | m_pointfield->offset = offset;
134 | }
135 | #endif
136 | Q_EMIT offsetChanged(offset);
137 | }
138 |
139 | void QPointfield::setDatatype(QPointfield::PointFieldTypes datatype)
140 | {
141 | if (m_datatype == datatype)
142 | return;
143 | m_datatype = datatype;
144 | #if WITH_PCL
145 | if(m_pointfield)
146 | {
147 | m_pointfield->datatype = toPCLDatatype(datatype);
148 | }
149 | #endif
150 | Q_EMIT datatypeChanged(datatype);
151 | }
152 |
153 | void QPointfield::setCount(quint32 count)
154 | {
155 | if (m_count == count)
156 | return;
157 | m_count = count;
158 | #if WITH_PCL
159 | if(m_pointfield)
160 | {
161 | m_pointfield->count = count;
162 | }
163 | #endif
164 | Q_EMIT countChanged(count);
165 | }
166 |
--------------------------------------------------------------------------------